2 ******************************************************************************
4 * @file uavobjectparser.h
5 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
6 * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
7 * @brief Parses XML files and extracts object information.
9 * @see The GNU Public License (GPL) Version 3
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifndef UAVOBJECTPARSER_H
29 #define UAVOBJECTPARSER_H
32 #include <QStringList>
57 QStringList elementNames
;
58 QStringList options
; // for enums only
59 bool defaultElementNames
;
60 QStringList defaultValues
;
62 QString parentObjectName
;
63 QString parentFieldName
;
70 UPDATEMODE_MANUAL
= 0, /** Manually update object, by calling the updated() function */
71 UPDATEMODE_PERIODIC
= 1, /** Automatically update object at periodic intervals */
72 UPDATEMODE_ONCHANGE
= 2, /** Only update object when its data changes */
73 UPDATEMODE_THROTTLED
= 3 /** Object is updated on change, but not more often than the interval time */
85 QString namelc
; /** name in lowercase */
92 AccessMode flightAccess
;
93 bool flightTelemetryAcked
;
94 UpdateMode flightTelemetryUpdateMode
; /** Update mode used by the autopilot (UpdateMode) */
95 int flightTelemetryUpdatePeriod
; /** Update period used by the autopilot (only if telemetry mode is PERIODIC) */
96 bool gcsTelemetryAcked
;
97 UpdateMode gcsTelemetryUpdateMode
; /** Update mode used by the GCS (UpdateMode) */
98 int gcsTelemetryUpdatePeriod
; /** Update period used by the GCS (only if telemetry mode is PERIODIC) */
99 UpdateMode loggingUpdateMode
; /** Update mode used by the logging module (UpdateMode) */
100 int loggingUpdatePeriod
; /** Update period used by the logging module (only if logging mode is PERIODIC) */
101 QList
<FieldInfo
*> fields
; /** The data fields for the object **/
102 QString description
; /** Description used for Doxygen **/
103 QString category
; /** Description used for Doxygen **/
106 class UAVObjectParser
{
111 QString
parseXML(QString
& xml
, QString
& filename
);
113 QList
<ObjectInfo
*> getObjectInfo();
114 QString
getObjectName(int objIndex
);
115 quint32
getObjectID(int objIndex
);
117 ObjectInfo
*getObjectByIndex(int objIndex
);
118 ObjectInfo
*getObjectByName(const QString
& objName
);
119 int getNumBytes(int objIndex
);
120 QStringList all_units
;
123 QList
<ObjectInfo
*> objInfo
;
124 QStringList fieldTypeStrXML
;
125 QList
<int> fieldTypeNumBytes
;
126 QStringList updateModeStr
;
127 QStringList updateModeStrXML
;
128 QStringList accessModeStr
;
129 QStringList accessModeStrXML
;
131 QString
processObjectAttributes(QDomNode
& node
, ObjectInfo
*info
);
132 QString
processObjectFields(QDomNode
& childNode
, ObjectInfo
*info
);
133 QString
processObjectAccess(QDomNode
& childNode
, ObjectInfo
*info
);
134 QString
processObjectDescription(QDomNode
& childNode
, QString
*description
);
135 QString
processObjectCategory(QDomNode
& childNode
, QString
*category
);
136 QString
processObjectMetadata(QDomNode
& childNode
, UpdateMode
*mode
, int *period
, bool *acked
);
137 void calculateID(ObjectInfo
*info
);
138 quint32
updateHash(quint32 value
, quint32 hash
);
139 quint32
updateHash(QString
& value
, quint32 hash
);
142 #endif // UAVOBJECTPARSER_H