diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro
index 4c409bd9e3a81426610a48200e273affcf0b9643..edb59b6b47b19341b5114a314042507fe824f073 100644
--- a/qgroundcontrol.pro
+++ b/qgroundcontrol.pro
@@ -18,8 +18,8 @@ TARGET = qgroundcontrol
BASEDIR = .
BUILDDIR = build
LANGUAGE = C++
-CONFIG += release #debug_and_release \
- #console
+CONFIG += debug_and_release \
+ console
OBJECTS_DIR = $$BUILDDIR/obj
MOC_DIR = $$BUILDDIR/moc
UI_HEADERS_DIR = src/ui/generated
diff --git a/settings/ParameterList.xml b/settings/ParameterList.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3894080f4c43a26c423c7b3cce235ec4cb77a275
--- /dev/null
+++ b/settings/ParameterList.xml
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/comm/OpalRT.h b/src/comm/OpalRT.h
index e2c64a7ff5e9fb3b8754e4ea3fae5a8449144fe5..678c44f177d2ce36416024070f35578fea2c4312 100644
--- a/src/comm/OpalRT.h
+++ b/src/comm/OpalRT.h
@@ -95,8 +95,10 @@ namespace OpalRT
enum SubsystemIds
{
NAV_ID = 1,
- LOG_ID = 1,
- CONTROLLER_ID = 1
+ LOG_ID,
+ CONTROLLER_ID,
+ SERVO_OUTPUTS,
+ SERVO_INPUTS
};
class OpalErrorMsg
diff --git a/src/comm/Parameter.cc b/src/comm/Parameter.cc
index 6f97f0c53cb78100a14529dcf4b4f8a25f05c5a6..512982e019d507a98f0f8caa13b95f60aed12a12 100644
--- a/src/comm/Parameter.cc
+++ b/src/comm/Parameter.cc
@@ -29,7 +29,17 @@ This file is part of the QGROUNDCONTROL project
#include "Parameter.h"
using namespace OpalRT;
-Parameter::Parameter(char *simulinkPath, char *simulinkName, uint8_t componentID,
+//Parameter::Parameter(char *simulinkPath, char *simulinkName, uint8_t componentID,
+// QGCParamID paramID, unsigned short opalID)
+// : simulinkPath(new QString(simulinkPath)),
+// simulinkName(new QString(simulinkName)),
+// componentID(componentID),
+// paramID(new QGCParamID(paramID)),
+// opalID(opalID)
+//
+//{
+//}
+Parameter::Parameter(QString simulinkPath, QString simulinkName, uint8_t componentID,
QGCParamID paramID, unsigned short opalID)
: simulinkPath(new QString(simulinkPath)),
simulinkName(new QString(simulinkName)),
diff --git a/src/comm/Parameter.h b/src/comm/Parameter.h
index 48abc6d6a76beec8969162317add64407da1af4f..695cd8a79d6a24b474f006db54337c1196d1e329 100644
--- a/src/comm/Parameter.h
+++ b/src/comm/Parameter.h
@@ -46,8 +46,13 @@ namespace OpalRT
class Parameter
{
public:
- Parameter(char *simulinkPath = "",
- char *simulinkName = "",
+// Parameter(char *simulinkPath = "",
+// char *simulinkName = "",
+// uint8_t componentID = 0,
+// QGCParamID paramID = QGCParamID(),
+// unsigned short opalID = 0);
+ Parameter(QString simulinkPath = QString(),
+ QString simulinkName = QString(),
uint8_t componentID = 0,
QGCParamID paramID = QGCParamID(),
unsigned short opalID = 0);
diff --git a/src/comm/ParameterList.cc b/src/comm/ParameterList.cc
index 7ffc66d6830d256b5243af9ae39a52d59d101abe..0b1d3762468c953925a21ca7c61fc16408534004 100644
--- a/src/comm/ParameterList.cc
+++ b/src/comm/ParameterList.cc
@@ -34,9 +34,16 @@ ParameterList::ParameterList()
:params(new QMap >),
paramList(new QList >())
{
-// params = new QMap >;
- /* Populate the map with parameter names. There is no elegant way of doing this so all
+ QDir settingsDir = QDir(qApp->applicationDirPath());
+ if (settingsDir.dirName() == "bin")
+ settingsDir.cdUp();
+ settingsDir.cd("settings");
+
+ QString filename(settingsDir.path() + "/ParameterList.xml");
+ if ((QFile::exists(filename)) && open(filename))
+ {
+ /* Populate the map with parameter names. There is no elegant way of doing this so all
parameter paths and names must be known at compile time and defined here.
Note: This function is written in a way that calls a lot of copy constructors and is
therefore not particularly efficient. However since it is only called once memory
@@ -44,58 +51,58 @@ ParameterList::ParameterList()
parameters.
When defining the path, the trailing slash is necessary
*/
- Parameter *p;
- /* Component: Navigation Filter */
- p = new Parameter("avionics_src/sm_ampro/NAV_FILT_INIT/",
- "Value",
- OpalRT::NAV_ID,
- QGCParamID("NAV_FILT_INIT"));
- (*params)[OpalRT::NAV_ID].insert(p->getParamID(), *p);
- delete p;
-
- p = new Parameter("avionics_src/sm_ampro/Gain/",
- "Gain",
- OpalRT::NAV_ID,
- QGCParamID("TEST_OUTP_GAIN"));
- (*params)[OpalRT::NAV_ID].insert(p->getParamID(), *p);
- delete p;
-
- /* Component: Log Facility */
- p = new Parameter("avionics_src/sm_ampro/LOG_FILE_ON/",
- "Value",
- OpalRT::LOG_ID,
- QGCParamID("LOG_FILE_ON"));
- (*params)[OpalRT::LOG_ID].insert(p->getParamID(), *p);
- delete p;
-
- /* Get a list of the available parameters from opal-rt */
- QMap *opalParams = new QMap;
- getParameterList(opalParams);
-
- /* Iterate over the parameters we want to use in qgc and populate their ids */
- QMap >::iterator componentIter;
- QMap::iterator paramIter;
- QString s;
- for (componentIter = params->begin(); componentIter != params->end(); ++componentIter)
- {
- paramList->append(QList());
- for (paramIter = (*componentIter).begin(); paramIter != (*componentIter).end(); ++paramIter)
+ // Parameter *p;
+ // /* Component: Navigation Filter */
+ // p = new Parameter("avionics_src/sm_ampro/NAV_FILT_INIT/",
+ // "Value",
+ // OpalRT::NAV_ID,
+ // QGCParamID("NAV_FILT_INIT"));
+ // (*params)[OpalRT::NAV_ID].insert(p->getParamID(), *p);
+ // delete p;
+ //
+ // p = new Parameter("avionics_src/sm_ampro/Gain/",
+ // "Gain",
+ // OpalRT::NAV_ID,
+ // QGCParamID("TEST_OUTP_GAIN"));
+ // (*params)[OpalRT::NAV_ID].insert(p->getParamID(), *p);
+ // delete p;
+ //
+ // /* Component: Log Facility */
+ // p = new Parameter("avionics_src/sm_ampro/LOG_FILE_ON/",
+ // "Value",
+ // OpalRT::LOG_ID,
+ // QGCParamID("LOG_FILE_ON"));
+ // (*params)[OpalRT::LOG_ID].insert(p->getParamID(), *p);
+ // delete p;
+
+ /* Get a list of the available parameters from opal-rt */
+ QMap *opalParams = new QMap;
+ getParameterList(opalParams);
+
+ /* Iterate over the parameters we want to use in qgc and populate their ids */
+ QMap >::iterator componentIter;
+ QMap::iterator paramIter;
+ QString s;
+ for (componentIter = params->begin(); componentIter != params->end(); ++componentIter)
{
- paramList->last().append(paramIter.operator ->());
- s = (*paramIter).getSimulinkPath() + (*paramIter).getSimulinkName();
- if (opalParams->contains(s))
- {
- (*paramIter).setOpalID(opalParams->value(s));
-// qDebug() << __FILE__ << " Line:" << __LINE__ << ": Successfully added " << s;
- }
- else
+ paramList->append(QList());
+ for (paramIter = (*componentIter).begin(); paramIter != (*componentIter).end(); ++paramIter)
{
- qWarning() << __FILE__ << " Line:" << __LINE__ << ": " << s << " was not found in param list";
+ paramList->last().append(paramIter.operator ->());
+ s = (*paramIter).getSimulinkPath() + (*paramIter).getSimulinkName();
+ if (opalParams->contains(s))
+ {
+ (*paramIter).setOpalID(opalParams->value(s));
+ // qDebug() << __FILE__ << " Line:" << __LINE__ << ": Successfully added " << s;
+ }
+ else
+ {
+ qWarning() << __FILE__ << " Line:" << __LINE__ << ": " << s << " was not found in param list";
+ }
}
}
+ delete opalParams;
}
- delete opalParams;
-
}
ParameterList::~ParameterList()
@@ -245,3 +252,96 @@ int ParameterList::count()
count += (*iter).count();
return count;
}
+
+/* Functions related to reading the xml config file */
+
+bool ParameterList::open(QString filename)
+{
+ QFile paramFile(filename);
+ if (!paramFile.exists())
+ {
+ /// \todo open dialog box (maybe: that could also go in comm config window)
+ return false;
+ }
+
+ if (!paramFile.open(QIODevice::ReadOnly))
+ {
+ return false;
+ }
+
+ read(¶mFile);
+
+ return true;
+}
+
+bool ParameterList::read(QIODevice *device)
+{
+ QDomDocument *paramConfig = new QDomDocument();
+
+ QString errorStr;
+ int errorLine;
+ int errorColumn;
+
+ if (!paramConfig->setContent(device, true, &errorStr, &errorLine,
+ &errorColumn))
+ {
+ qDebug() << "Error reading XML Parameter File on line: " << errorLine << errorStr;
+ return false;
+ }
+
+ QDomElement root = paramConfig->documentElement();
+ if (root.tagName() != "ParameterList") {
+ qDebug() << __FILE__ << __LINE__ << "This is not a parameter list xml file";
+ return false;
+ }
+
+ QDomElement child = root.firstChildElement("Block");
+ while (!child.isNull())
+ {
+ parseBlock(child);
+ child = child.nextSiblingElement("Block");
+ }
+
+ delete paramConfig;
+ return true;
+}
+
+void ParameterList::parseBlock(const QDomElement &block)
+{
+
+ QDomNodeList paramList;
+ QDomElement e;
+ Parameter *p;
+ SubsystemIds id;
+ if (block.attribute("name") == "Navigation")
+ id = OpalRT::NAV_ID;
+ else if (block.attribute("name") == "Controller")
+ id = OpalRT::CONTROLLER_ID;
+ else if (block.attribute("name") == "ServoOutputs")
+ id = OpalRT::SERVO_OUTPUTS;
+ else if (block.attribute("name") == "ServoInputs")
+ id = OpalRT::SERVO_INPUTS;
+
+ paramList = block.elementsByTagName("Parameter");
+ for (int i=0; i < paramList.size(); ++i)
+ {
+ e = paramList.item(i).toElement();
+ if (e.hasAttribute("SimulinkPath") &&
+ e.hasAttribute("SimulinkParameterName") &&
+ e.hasAttribute("QGCParamID"))
+ {
+
+ p = new Parameter(e.attribute("SimulinkPath"),
+ e.attribute("SimulinkParameterName"),
+ static_cast(id),
+ QGCParamID(e.attribute("QGCParamID")));
+ (*params)[id].insert(p->getParamID(), *p);
+ delete p;
+ }
+ else
+ {
+ qDebug() << __FILE__ << ":" << __LINE__ << ": error in xml doc";
+ }
+ }
+
+}
diff --git a/src/comm/ParameterList.h b/src/comm/ParameterList.h
index a674f8ce9e18a2ccb5d441680de0fc649202f9c6..f93ffac779a3a4b96f55408ab7bc655409812bae 100644
--- a/src/comm/ParameterList.h
+++ b/src/comm/ParameterList.h
@@ -26,6 +26,11 @@ This file is part of the QGROUNDCONTROL project
#include
#include
+#include
+#include
+#include
+#include
+#include
#include "mavlink_types.h"
#include "QGCParamID.h"
@@ -83,7 +88,6 @@ namespace OpalRT
qDebug() << "PID_GAIN is at index " << index;
\endcode
*/
-
int indexOf(const Parameter& p);
bool contains(int compid, QGCParamID paramid) const {return (*params)[compid].contains(paramid);}
@@ -120,6 +124,19 @@ namespace OpalRT
\param[out] opalParams Map of parameter paths/names to ids which are valid in Opal-RT
*/
void getParameterList(QMap* opalParams);
+
+ /**
+ Open a file for reading in the xml config data
+ */
+ bool open(QString filename=QString());
+ /**
+ Attempt to read XML configuration data from device
+ \param[in] the device to read the xml data from
+ \return true if the configuration was read successfully, false otherwise
+ */
+ bool read(QIODevice *device);
+
+ void parseBlock(const QDomElement &block);
};
}
#endif // PARAMETERLIST_H
diff --git a/src/comm/ParameterList.xml b/src/comm/ParameterList.xml
deleted file mode 100644
index 78d3b5af897bfc6a0d46361ea794ea548ad767d0..0000000000000000000000000000000000000000
--- a/src/comm/ParameterList.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
- avionics_src/sm_ampro/NAV_FILT_INIT/
- Value
- NAV_FILT_INIT
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/ui/MainWindow.ui b/src/ui/MainWindow.ui
index 49c27902d82da3085c6f171a5979af21b92d71cc..7a936e1e7ed83c5d9050db2678bf617d92692843 100644
--- a/src/ui/MainWindow.ui
+++ b/src/ui/MainWindow.ui
@@ -38,7 +38,7 @@
0
0
1000
- 22
+ 23
-
-
-
+
actionExit