1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-48 GCS/UAVObjects Update object generator to support the new access mode metadata fields. XML object definitions also updated, see r643 for more details.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@644 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
vassilis 2010-05-20 01:01:01 +00:00 committed by vassilis
parent e3556a3f31
commit 713c76bc6e
42 changed files with 411 additions and 118 deletions

View File

@ -58,6 +58,10 @@ UAVObjectParser::UAVObjectParser()
updateModeStrXML << QString("periodic") << QString("onchange") <<
QString("manual") << QString("never");
accessModeStr << QString("ACCESS_READWRITE") << QString("ACCESS_READONLY");
accessModeStrXML << QString("readwrite") << QString("readonly");
}
/**
@ -138,6 +142,11 @@ QString UAVObjectParser::parseXML(QString& xml, QString& filename)
// Process child elements (fields and metadata)
QDomNode childNode = node.firstChild();
bool fieldFound = false;
bool accessFound = false;
bool telGCSFound = false;
bool telFlightFound = false;
bool logFound = false;
while ( !childNode.isNull() )
{
// Process element depending on its type
@ -148,6 +157,16 @@ QString UAVObjectParser::parseXML(QString& xml, QString& filename)
{
return status;
}
fieldFound = true;
}
else if ( childNode.nodeName().compare(QString("access")) == 0 )
{
QString status = processObjectAccess(childNode, info);
if (!status.isNull())
{
return status;
}
accessFound = true;
}
else if ( childNode.nodeName().compare(QString("telemetrygcs")) == 0 )
{
@ -157,6 +176,7 @@ QString UAVObjectParser::parseXML(QString& xml, QString& filename)
{
return status;
}
telGCSFound = true;
}
else if ( childNode.nodeName().compare(QString("telemetryflight")) == 0 )
{
@ -166,6 +186,7 @@ QString UAVObjectParser::parseXML(QString& xml, QString& filename)
{
return status;
}
telFlightFound = true;
}
else if ( childNode.nodeName().compare(QString("logging")) == 0 )
{
@ -175,6 +196,7 @@ QString UAVObjectParser::parseXML(QString& xml, QString& filename)
{
return status;
}
logFound = true;
}
else
{
@ -184,6 +206,24 @@ QString UAVObjectParser::parseXML(QString& xml, QString& filename)
childNode = childNode.nextSibling();
}
// Make sure that required elements were found
if ( !accessFound )
{
return QString("Object::access element is missing");
}
else if ( !telGCSFound )
{
return QString("Object::telemetrygcs element is missing");
}
else if ( !telFlightFound )
{
return QString("Object::telemetryflight element is missing");
}
else if ( !logFound )
{
return QString("Object::logging element is missing");
}
// Calculate ID
calculateID(info);
@ -308,6 +348,52 @@ QString UAVObjectParser::processObjectMetadata(QDomNode& childNode, UpdateMode*
return QString();
}
/**
* Process the object access tag of the XML
*/
QString UAVObjectParser::processObjectAccess(QDomNode& childNode, ObjectInfo* info)
{
// Get gcs attribute
QDomNamedNodeMap elemAttributes = childNode.attributes();
QDomNode elemAttr = elemAttributes.namedItem("gcs");
if ( elemAttr.isNull() )
{
return QString("Object:access:gcs attribute is missing");
}
else
{
int index = accessModeStrXML.indexOf( elemAttr.nodeValue() );
if (index >= 0)
{
info->gcsAccess = (AccessMode)index;
}
else
{
return QString("Object:access:gcs attribute value is invalid");
}
}
// Get flight attribute
elemAttr = elemAttributes.namedItem("flight");
if ( elemAttr.isNull() )
{
return QString("Object:access:flight attribute is missing");
}
else
{
int index = accessModeStrXML.indexOf( elemAttr.nodeValue() );
if (index >= 0)
{
info->flightAccess = (AccessMode)index;
}
else
{
return QString("Object:access:flight attribute value is invalid");
}
}
// Done
return QString();
}
/**
* Process the object fields of the XML
*/
@ -517,6 +603,12 @@ void UAVObjectParser::replaceCommonTags(QString& out, ObjectInfo* info)
// Replace $(ISSETTINGS) tag
value = boolToString( info->isSettings );
out.replace(QString("$(ISSETTINGS)"), value);
// Replace $(GCSACCESS) tag
value = accessModeStr[info->gcsAccess];
out.replace(QString("$(GCSACCESS)"), value);
// Replace $(FLIGHTACCESS) tag
value = accessModeStr[info->flightAccess];
out.replace(QString("$(FLIGHTACCESS)"), value);
// Replace $(FLIGHTTELEM_ACKED) tag
value = boolToString( info->flightTelemetryAcked );
out.replace(QString("$(FLIGHTTELEM_ACKED)"), value);

View File

@ -59,6 +59,11 @@ public:
UPDATEMODE_NEVER /** Object is never updated */
} UpdateMode;
typedef enum {
ACCESS_READWRITE = 0,
ACCESS_READONLY = 1
} AccessMode;
typedef struct {
QString name;
QString units;
@ -75,6 +80,8 @@ public:
quint32 id;
bool isSingleInst;
bool isSettings;
AccessMode gcsAccess;
AccessMode flightAccess;
bool flightTelemetryAcked;
UpdateMode flightTelemetryUpdateMode; /** Update mode used by the autopilot (UpdateMode) */
int flightTelemetryUpdatePeriod; /** Update period used by the autopilot (only if telemetry mode is PERIODIC) */
@ -109,9 +116,12 @@ private:
QStringList fieldTypeStrXML;
QStringList updateModeStr;
QStringList updateModeStrXML;
QStringList accessModeStr;
QStringList accessModeStrXML;
QString processObjectAttributes(QDomNode& node, ObjectInfo* info);
QString processObjectFields(QDomNode& childNode, ObjectInfo* info);
QString processObjectAccess(QDomNode& childNode, ObjectInfo* info);
QString processObjectMetadata(QDomNode& childNode, UpdateMode* mode, int* period, bool* acked);
void calculateID(ObjectInfo* info);
quint32 updateHash(quint32 value, quint32 hash);

View File

@ -63,6 +63,8 @@ ActuatorCommand::ActuatorCommand(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTING
UAVObject::Metadata ActuatorCommand::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_MANUAL;
metadata.gcsTelemetryUpdatePeriod = 0;
@ -99,9 +101,15 @@ ActuatorCommand::DataFields ActuatorCommand::getData()
void ActuatorCommand::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -65,6 +65,8 @@ ActuatorDesired::ActuatorDesired(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTING
UAVObject::Metadata ActuatorDesired::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_MANUAL;
metadata.gcsTelemetryUpdatePeriod = 0;
@ -101,9 +103,15 @@ ActuatorDesired::DataFields ActuatorDesired::getData()
void ActuatorDesired::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -269,6 +269,8 @@ ActuatorSettings::ActuatorSettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTI
UAVObject::Metadata ActuatorSettings::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
metadata.gcsTelemetryUpdatePeriod = 0;
@ -345,9 +347,15 @@ ActuatorSettings::DataFields ActuatorSettings::getData()
void ActuatorSettings::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -65,6 +65,8 @@ AttitudeDesired::AttitudeDesired(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTING
UAVObject::Metadata AttitudeDesired::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_MANUAL;
metadata.gcsTelemetryUpdatePeriod = 0;
@ -101,9 +103,15 @@ AttitudeDesired::DataFields AttitudeDesired::getData()
void AttitudeDesired::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -83,6 +83,8 @@ ExampleObject1::ExampleObject1(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS,
UAVObject::Metadata ExampleObject1::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
metadata.gcsTelemetryUpdatePeriod = 200;
@ -119,9 +121,15 @@ ExampleObject1::DataFields ExampleObject1::getData()
void ExampleObject1::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -68,6 +68,8 @@ ExampleObject2::ExampleObject2(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS,
UAVObject::Metadata ExampleObject2::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
metadata.gcsTelemetryUpdatePeriod = 0;
@ -104,9 +106,15 @@ ExampleObject2::DataFields ExampleObject2::getData()
void ExampleObject2::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -65,6 +65,8 @@ ExampleSettings::ExampleSettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTING
UAVObject::Metadata ExampleSettings::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
metadata.gcsTelemetryUpdatePeriod = 0;
@ -104,9 +106,15 @@ ExampleSettings::DataFields ExampleSettings::getData()
void ExampleSettings::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -76,6 +76,8 @@ FlightTelemetryStats::FlightTelemetryStats(): UAVDataObject(OBJID, ISSINGLEINST,
UAVObject::Metadata FlightTelemetryStats::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_MANUAL;
metadata.gcsTelemetryUpdatePeriod = 0;
@ -112,9 +114,15 @@ FlightTelemetryStats::DataFields FlightTelemetryStats::getData()
void FlightTelemetryStats::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -76,6 +76,8 @@ GCSTelemetryStats::GCSTelemetryStats(): UAVDataObject(OBJID, ISSINGLEINST, ISSET
UAVObject::Metadata GCSTelemetryStats::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
metadata.gcsTelemetryUpdatePeriod = 5000;
@ -112,9 +114,15 @@ GCSTelemetryStats::DataFields GCSTelemetryStats::getData()
void GCSTelemetryStats::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -68,6 +68,8 @@ GpsObject::GpsObject(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
UAVObject::Metadata GpsObject::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_MANUAL;
metadata.gcsTelemetryUpdatePeriod = 0;
@ -104,9 +106,15 @@ GpsObject::DataFields GpsObject::getData()
void GpsObject::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -88,6 +88,8 @@ ManualControlCommand::ManualControlCommand(): UAVDataObject(OBJID, ISSINGLEINST,
UAVObject::Metadata ManualControlCommand::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_MANUAL;
metadata.gcsTelemetryUpdatePeriod = 0;
@ -124,9 +126,15 @@ ManualControlCommand::DataFields ManualControlCommand::getData()
void ManualControlCommand::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -155,6 +155,8 @@ ManualControlSettings::ManualControlSettings(): UAVDataObject(OBJID, ISSINGLEINS
UAVObject::Metadata ManualControlSettings::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
metadata.gcsTelemetryUpdatePeriod = 0;
@ -221,9 +223,15 @@ ManualControlSettings::DataFields ManualControlSettings::getData()
void ManualControlSettings::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -74,6 +74,8 @@ ObjectPersistence::ObjectPersistence(): UAVDataObject(OBJID, ISSINGLEINST, ISSET
UAVObject::Metadata ObjectPersistence::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_MANUAL;
metadata.gcsTelemetryUpdatePeriod = 0;
@ -110,9 +112,15 @@ ObjectPersistence::DataFields ObjectPersistence::getData()
void ObjectPersistence::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -62,6 +62,8 @@ StabilizationSettings::StabilizationSettings(): UAVDataObject(OBJID, ISSINGLEINS
UAVObject::Metadata StabilizationSettings::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
metadata.gcsTelemetryUpdatePeriod = 0;
@ -101,9 +103,15 @@ StabilizationSettings::DataFields StabilizationSettings::getData()
void StabilizationSettings::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -68,6 +68,8 @@ SystemAlarms::SystemAlarms(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAM
UAVObject::Metadata SystemAlarms::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
metadata.gcsTelemetryUpdatePeriod = 0;
@ -104,9 +106,15 @@ SystemAlarms::DataFields SystemAlarms::getData()
void SystemAlarms::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -60,6 +60,8 @@ SystemSettings::SystemSettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS,
UAVObject::Metadata SystemSettings::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
metadata.gcsTelemetryUpdatePeriod = 0;
@ -97,9 +99,15 @@ SystemSettings::DataFields SystemSettings::getData()
void SystemSettings::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -62,6 +62,8 @@ SystemStats::SystemStats(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
UAVObject::Metadata SystemStats::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_MANUAL;
metadata.gcsTelemetryUpdatePeriod = 0;
@ -98,9 +100,15 @@ SystemStats::DataFields SystemStats::getData()
void SystemStats::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -60,6 +60,8 @@ TelemetrySettings::TelemetrySettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSET
UAVObject::Metadata TelemetrySettings::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
metadata.gcsAccess = ACCESS_READWRITE;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
metadata.gcsTelemetryUpdatePeriod = 0;
@ -97,9 +99,15 @@ TelemetrySettings::DataFields TelemetrySettings::getData()
void TelemetrySettings::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -36,6 +36,8 @@ UAVMetaObject::UAVMetaObject(quint32 objID, const QString& name, UAVObject* pare
{
this->parent = parent;
// Setup default metadata of metaobject (can not be changed)
ownMetadata.flightAccess = ACCESS_READWRITE;
ownMetadata.gcsAccess = ACCESS_READWRITE;
ownMetadata.flightTelemetryAcked = 1;
ownMetadata.flightTelemetryUpdateMode = UPDATEMODE_ONCHANGE;
ownMetadata.flightTelemetryUpdatePeriod = 0;
@ -49,7 +51,11 @@ UAVMetaObject::UAVMetaObject(quint32 objID, const QString& name, UAVObject* pare
boolEnum << tr("False") << tr("True");
QStringList updateModeEnum;
updateModeEnum << tr("Periodic") << tr("On Change") << tr("Manual") << tr("Never");
QStringList accessModeEnum;
accessModeEnum << tr("Read/Write") << tr("Read Only");
QList<UAVObjectField*> fields;
fields.append( new UAVObjectField(tr("Flight Access Mode"), tr(""), UAVObjectField::ENUM, 1, accessModeEnum) );
fields.append( new UAVObjectField(tr("GCS Access Mode"), tr(""), UAVObjectField::ENUM, 1, accessModeEnum) );
fields.append( new UAVObjectField(tr("Flight Telemetry Acked"), tr(""), UAVObjectField::ENUM, 1, boolEnum) );
fields.append( new UAVObjectField(tr("Flight Telemetry Update Mode"), tr(""), UAVObjectField::ENUM, 1, updateModeEnum) );
fields.append( new UAVObjectField(tr("Flight Telemetry Update Period"), tr(""), UAVObjectField::UINT32, 1, QStringList()) );

View File

@ -56,11 +56,21 @@ public:
UPDATEMODE_NEVER = 3 /** Object is never updated */
} UpdateMode;
/**
* Access mode
*/
typedef enum {
ACCESS_READWRITE = 0,
ACCESS_READONLY = 1
} AccessMode;
/**
* Object metadata, each object has a meta object that holds its metadata. The metadata define
* properties for each object and can be used by multiple modules (e.g. telemetry and logger)
*/
typedef struct {
quint8 flightAccess; /** Defines the access level for the local flight transactions (readonly and readwrite) */
quint8 gcsAccess; /** Defines the access level for the local GCS transactions (readonly and readwrite) */
quint8 flightTelemetryAcked; /** Defines if an ack is required for the transactions of this object (1:acked, 0:not acked) */
quint8 flightTelemetryUpdateMode; /** Update mode used by the autopilot (UpdateMode) */
qint32 flightTelemetryUpdatePeriod; /** Update period used by the autopilot (only if telemetry mode is PERIODIC) */

View File

@ -467,7 +467,11 @@ void UAVObjectField::setValue(const QVariant& value, quint32 index)
{
return;
}
// Set value
// Get metadata
UAVObject::Metadata mdata = obj->getMetadata();
// Update value if the access mode permits
if ( mdata.gcsAccess == UAVObject::ACCESS_READWRITE )
{
switch (type)
{
case INT8:
@ -531,6 +535,7 @@ void UAVObjectField::setValue(const QVariant& value, quint32 index)
break;
}
}
}
}
double UAVObjectField::getDouble(quint32 index)

View File

@ -53,6 +53,8 @@ $(FIELDSINIT)
UAVObject::Metadata $(NAME)::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = $(FLIGHTACCESS);
metadata.gcsAccess = $(GCSACCESS);
metadata.gcsTelemetryAcked = $(GCSTELEM_ACKED);
metadata.gcsTelemetryUpdateMode = UAVObject::$(GCSTELEM_UPDATEMODE);
metadata.gcsTelemetryUpdatePeriod = $(GCSTELEM_UPDATEPERIOD);
@ -89,9 +91,15 @@ $(NAME)::DataFields $(NAME)::getData()
void $(NAME)::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
Metadata mdata = getMetadata();
// Update object if the access mode permits
if ( mdata.gcsAccess == ACCESS_READWRITE )
{
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
}
/**

View File

@ -1,6 +1,7 @@
<xml>
<object name="ActuatorCommand" singleinstance="true" settings="false">
<field name="Channel" units="us" type="int16" elements="8"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="manual" period="0"/>
<telemetryflight acked="true" updatemode="periodic" period="1000"/>
<logging updatemode="never" period="0"/>

View File

@ -4,6 +4,7 @@
<field name="Pitch" units="%" type="float" elements="1"/>
<field name="Yaw" units="%" type="float" elements="1"/>
<field name="Throttle" units="%" type="float" elements="1"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="manual" period="0"/>
<telemetryflight acked="true" updatemode="periodic" period="1000"/>
<logging updatemode="never" period="0"/>

View File

@ -18,6 +18,7 @@
<field name="ChannelMax" units="us" type="int16" elements="8" defaultvalue="2000"/>
<field name="ChannelNeutral" units="us" type="int16" elements="8" defaultvalue="1500"/>
<field name="ChannelMin" units="us" type="int16" elements="8" defaultvalue="1000"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/>
<logging updatemode="never" period="0"/>

View File

@ -4,6 +4,7 @@
<field name="Pitch" units="degrees" type="float" elements="1"/>
<field name="Yaw" units="degrees" type="float" elements="1"/>
<field name="Throttle" units="%" type="float" elements="1"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="manual" period="0"/>
<telemetryflight acked="true" updatemode="periodic" period="1000"/>
<logging updatemode="never" period="0"/>

View File

@ -8,6 +8,7 @@
<field name="Field6" units="unit6" type="uint16" elements="1"/>
<field name="Field7" units="unit7" type="uint32" elements="1"/>
<field name="Field8" units="unit8" type="enum" elements="1" options="Option1, Option2"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="periodic" period="200"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/>
<logging updatemode="never" period="0"/>

View File

@ -4,6 +4,7 @@
<field name="Field2" units="unit2" type="int16" elements="1"/>
<field name="Field3" units="unit3" type="int32" elements="1"/>
<field name="Field4" units="unit4" type="float" elements="4"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="periodic" period="100"/>
<logging updatemode="never" period="0"/>

View File

@ -3,6 +3,7 @@
<field name="UpdatePeriod" units="ms" type="int32" elements="1" defaultvalue="10"/>
<field name="StepSize" units="" type="int32" elements="1" defaultvalue="1"/>
<field name="StepDirection" units="" type="enum" elements="1" options="up,down" defaultvalue="up"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/>
<logging updatemode="never" period="0"/>

View File

@ -6,6 +6,7 @@
<field name="TxFailures" units="count" type="uint32" elements="1"/>
<field name="RxFailures" units="count" type="uint32" elements="1"/>
<field name="TxRetries" units="count" type="uint32" elements="1"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="manual" period="0"/>
<telemetryflight acked="true" updatemode="periodic" period="5000"/>
<logging updatemode="periodic" period="5000"/>

View File

@ -6,6 +6,7 @@
<field name="TxFailures" units="count" type="uint32" elements="1"/>
<field name="RxFailures" units="count" type="uint32" elements="1"/>
<field name="TxRetries" units="count" type="uint32" elements="1"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="periodic" period="5000"/>
<telemetryflight acked="true" updatemode="manual" period="0"/>
<logging updatemode="never" period="0"/>

View File

@ -5,6 +5,7 @@
<field name="Altitude" units="meters" type="float" elements="1"/>
<field name="Satellites" units="" type="int8" elements="1"/>
<field name="Updates" units="" type="uint16" elements="1"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="manual" period="0"/>
<telemetryflight acked="true" updatemode="periodic" period="1000"/>
<logging updatemode="periodic" period="1000"/>

View File

@ -7,6 +7,7 @@
<field name="Throttle" units="%" type="float" elements="1"/>
<field name="FlightMode" units="" type="enum" elements="1" options="Manual,Stabilized,Auto"/>
<field name="Channel" units="us" type="int16" elements="8"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="manual" period="0"/>
<telemetryflight acked="true" updatemode="periodic" period="3000"/>
<logging updatemode="never" period="0"/>

View File

@ -9,6 +9,7 @@
<field name="ChannelMax" units="us" type="int16" elements="8" defaultvalue="2000"/>
<field name="ChannelNeutral" units="us" type="int16" elements="8" defaultvalue="1500"/>
<field name="ChannelMin" units="us" type="int16" elements="8" defaultvalue="1000"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/>
<logging updatemode="never" period="0"/>

View File

@ -4,6 +4,7 @@
<field name="Selection" units="" type="enum" elements="1" options="SingleObject,AllSettings,AllMetaObjects,AllObjects"/>
<field name="ObjectID" units="" type="uint32" elements="1"/>
<field name="InstanceID" units="" type="uint32" elements="1"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="manual" period="0"/>
<telemetryflight acked="true" updatemode="manual" period="0"/>
<logging updatemode="never" period="0"/>

View File

@ -3,6 +3,7 @@
<field name="RollMax" units="degrees" type="float" elements="1" defaultvalue="35"/>
<field name="PitchMax" units="degrees" type="float" elements="1" defaultvalue="35"/>
<field name="ThrottleMax" units="%" type="float" elements="1" defaultvalue="100.0"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/>
<logging updatemode="never" period="0"/>

View File

@ -2,6 +2,7 @@
<object name="SystemAlarms" singleinstance="true" settings="false">
<field name="Alarm" units="" type="enum" options="OK,Warning,Error,Critical"
elementnames="OutOfMemory,StackOverflow,CPUOverload,EventSystem,SDCard,Telemetry,ManualControl,Actuator"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="periodic" period="4000"/>
<logging updatemode="periodic" period="1000"/>

View File

@ -1,6 +1,7 @@
<xml>
<object name="SystemSettings" singleinstance="true" settings="true">
<field name="AirframeType" units="" type="enum" elements="1" options="FixedWing,FixedWingElevon,VTOL" defaultvalue="FixedWing"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/>
<logging updatemode="never" period="0"/>

View File

@ -3,6 +3,7 @@
<field name="FlightTime" units="ms" type="uint32" elements="1"/>
<field name="HeapRemaining" units="bytes" type="uint16" elements="1"/>
<field name="CPULoad" units="%" type="uint8" elements="1"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="manual" period="0"/>
<telemetryflight acked="true" updatemode="periodic" period="1000"/>
<logging updatemode="periodic" period="1000"/>

View File

@ -1,6 +1,7 @@
<xml>
<object name="TelemetrySettings" singleinstance="true" settings="true">
<field name="Speed" units="" type="enum" elements="1" options="9600,38400,57600" defaultvalue="57600"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/>
<logging updatemode="never" period="0"/>