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