Commit ed807d4f authored by Don Gagne's avatar Don Gagne

Mock param mgr is created with full set of params

parent 9d20690a
......@@ -22,6 +22,8 @@
======================================================================*/
#include "MockQGCUASParamManager.h"
#include "mavlink.h"
#include <QTest>
#include <QDebug>
......@@ -29,7 +31,7 @@ Q_LOGGING_CATEGORY(MockQGCUASParamManagerLog, "MockQGCUASParamManagerLog")
MockQGCUASParamManager::MockQGCUASParamManager(void)
{
_loadParams();
}
bool MockQGCUASParamManager::getParameterValue(int component, const QString& parameter, QVariant& value) const
......@@ -52,3 +54,51 @@ void MockQGCUASParamManager::setParameter(int component, QString parameterName,
_mapParams[parameterName] = value;
emit parameterUpdated(_defaultComponentId, parameterName, value);
}
void MockQGCUASParamManager::_loadParams(void)
{
QFile paramFile(":/unittest/MockLink.param");
bool success = paramFile.open(QFile::ReadOnly);
Q_UNUSED(success);
Q_ASSERT(success);
QTextStream paramStream(&paramFile);
while (!paramStream.atEnd()) {
QString line = paramStream.readLine();
if (line.startsWith("#")) {
continue;
}
QStringList paramData = line.split("\t");
Q_ASSERT(paramData.count() == 5);
QString paramName = paramData.at(2);
QString valStr = paramData.at(3);
uint paramType = paramData.at(4).toUInt();
QVariant paramValue;
switch (paramType) {
case MAV_PARAM_TYPE_REAL32:
paramValue = QVariant(valStr.toFloat());
break;
case MAV_PARAM_TYPE_UINT32:
paramValue = QVariant(valStr.toUInt());
break;
case MAV_PARAM_TYPE_INT32:
paramValue = QVariant(valStr.toInt());
break;
case MAV_PARAM_TYPE_INT8:
paramValue = QVariant((unsigned char)valStr.toUInt());
break;
default:
Q_ASSERT(false);
break;
}
Q_ASSERT(!_mapParams.contains(paramName));
_mapParams[paramName] = paramValue;
}
}
......@@ -97,6 +97,8 @@ public slots:
virtual void copyPersistentParamsToVolatile() { Q_ASSERT(false); }
private:
void _loadParams(void);
ParamMap_t _mapParams;
static const int _defaultComponentId = 50;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment