diff --git a/ground/src/libs/uavobjgenerator/uavobjectparser.cpp b/ground/src/libs/uavobjgenerator/uavobjectparser.cpp index 0ceae9bc4..6a32b4b73 100644 --- a/ground/src/libs/uavobjgenerator/uavobjectparser.cpp +++ b/ground/src/libs/uavobjgenerator/uavobjectparser.cpp @@ -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 */ @@ -516,7 +602,13 @@ void UAVObjectParser::replaceCommonTags(QString& out, ObjectInfo* info) out.replace(QString("$(ISSINGLEINST)"), value); // Replace $(ISSETTINGS) tag value = boolToString( info->isSettings ); - out.replace(QString("$(ISSETTINGS)"), value); + 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); diff --git a/ground/src/libs/uavobjgenerator/uavobjectparser.h b/ground/src/libs/uavobjgenerator/uavobjectparser.h index f96794908..475449a01 100644 --- a/ground/src/libs/uavobjgenerator/uavobjectparser.h +++ b/ground/src/libs/uavobjgenerator/uavobjectparser.h @@ -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); diff --git a/ground/src/plugins/uavobjects/actuatorcommand.cpp b/ground/src/plugins/uavobjects/actuatorcommand.cpp index a7039d109..b09d970d3 100644 --- a/ground/src/plugins/uavobjects/actuatorcommand.cpp +++ b/ground/src/plugins/uavobjects/actuatorcommand.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/actuatordesired.cpp b/ground/src/plugins/uavobjects/actuatordesired.cpp index 336f33231..69ab26d3a 100644 --- a/ground/src/plugins/uavobjects/actuatordesired.cpp +++ b/ground/src/plugins/uavobjects/actuatordesired.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/actuatorsettings.cpp b/ground/src/plugins/uavobjects/actuatorsettings.cpp index 3ad2213dc..261cfa585 100644 --- a/ground/src/plugins/uavobjects/actuatorsettings.cpp +++ b/ground/src/plugins/uavobjects/actuatorsettings.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/attitudedesired.cpp b/ground/src/plugins/uavobjects/attitudedesired.cpp index 4e3ba4d71..8a8a56f08 100644 --- a/ground/src/plugins/uavobjects/attitudedesired.cpp +++ b/ground/src/plugins/uavobjects/attitudedesired.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/exampleobject1.cpp b/ground/src/plugins/uavobjects/exampleobject1.cpp index 08fccdfc3..17b789908 100644 --- a/ground/src/plugins/uavobjects/exampleobject1.cpp +++ b/ground/src/plugins/uavobjects/exampleobject1.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/exampleobject2.cpp b/ground/src/plugins/uavobjects/exampleobject2.cpp index 9cc873e0c..4176162ba 100644 --- a/ground/src/plugins/uavobjects/exampleobject2.cpp +++ b/ground/src/plugins/uavobjects/exampleobject2.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/examplesettings.cpp b/ground/src/plugins/uavobjects/examplesettings.cpp index d92e9c931..3be8a4bde 100644 --- a/ground/src/plugins/uavobjects/examplesettings.cpp +++ b/ground/src/plugins/uavobjects/examplesettings.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/flighttelemetrystats.cpp b/ground/src/plugins/uavobjects/flighttelemetrystats.cpp index 315a214f3..36cbe1a53 100644 --- a/ground/src/plugins/uavobjects/flighttelemetrystats.cpp +++ b/ground/src/plugins/uavobjects/flighttelemetrystats.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/gcstelemetrystats.cpp b/ground/src/plugins/uavobjects/gcstelemetrystats.cpp index 2016b80a7..678dd842e 100644 --- a/ground/src/plugins/uavobjects/gcstelemetrystats.cpp +++ b/ground/src/plugins/uavobjects/gcstelemetrystats.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/gpsobject.cpp b/ground/src/plugins/uavobjects/gpsobject.cpp index ecb08dac5..d7f262478 100644 --- a/ground/src/plugins/uavobjects/gpsobject.cpp +++ b/ground/src/plugins/uavobjects/gpsobject.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/manualcontrolcommand.cpp b/ground/src/plugins/uavobjects/manualcontrolcommand.cpp index b3db5c818..a5b6e6336 100644 --- a/ground/src/plugins/uavobjects/manualcontrolcommand.cpp +++ b/ground/src/plugins/uavobjects/manualcontrolcommand.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/manualcontrolsettings.cpp b/ground/src/plugins/uavobjects/manualcontrolsettings.cpp index 0c023ff22..7c234ac1a 100644 --- a/ground/src/plugins/uavobjects/manualcontrolsettings.cpp +++ b/ground/src/plugins/uavobjects/manualcontrolsettings.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/objectpersistence.cpp b/ground/src/plugins/uavobjects/objectpersistence.cpp index 12b93286f..4a3d2eacf 100644 --- a/ground/src/plugins/uavobjects/objectpersistence.cpp +++ b/ground/src/plugins/uavobjects/objectpersistence.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/stabilizationsettings.cpp b/ground/src/plugins/uavobjects/stabilizationsettings.cpp index 5785d410d..2ae279263 100644 --- a/ground/src/plugins/uavobjects/stabilizationsettings.cpp +++ b/ground/src/plugins/uavobjects/stabilizationsettings.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/systemalarms.cpp b/ground/src/plugins/uavobjects/systemalarms.cpp index 1a70e359c..87ba13c99 100644 --- a/ground/src/plugins/uavobjects/systemalarms.cpp +++ b/ground/src/plugins/uavobjects/systemalarms.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/systemsettings.cpp b/ground/src/plugins/uavobjects/systemsettings.cpp index e80d8b103..2a0f7e278 100644 --- a/ground/src/plugins/uavobjects/systemsettings.cpp +++ b/ground/src/plugins/uavobjects/systemsettings.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/systemstats.cpp b/ground/src/plugins/uavobjects/systemstats.cpp index 25ac6c158..f99e793ba 100644 --- a/ground/src/plugins/uavobjects/systemstats.cpp +++ b/ground/src/plugins/uavobjects/systemstats.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/telemetrysettings.cpp b/ground/src/plugins/uavobjects/telemetrysettings.cpp index 010fc4906..2e2f437a1 100644 --- a/ground/src/plugins/uavobjects/telemetrysettings.cpp +++ b/ground/src/plugins/uavobjects/telemetrysettings.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/plugins/uavobjects/uavmetaobject.cpp b/ground/src/plugins/uavobjects/uavmetaobject.cpp index 4ef81f079..2173076c9 100644 --- a/ground/src/plugins/uavobjects/uavmetaobject.cpp +++ b/ground/src/plugins/uavobjects/uavmetaobject.cpp @@ -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"); - QList fields; + QStringList accessModeEnum; + accessModeEnum << tr("Read/Write") << tr("Read Only"); + QList 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()) ); diff --git a/ground/src/plugins/uavobjects/uavobject.h b/ground/src/plugins/uavobjects/uavobject.h index c54f10678..4634296ec 100644 --- a/ground/src/plugins/uavobjects/uavobject.h +++ b/ground/src/plugins/uavobjects/uavobject.h @@ -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) */ diff --git a/ground/src/plugins/uavobjects/uavobjectfield.cpp b/ground/src/plugins/uavobjects/uavobjectfield.cpp index f8f6eb0d5..2c8d99ecf 100644 --- a/ground/src/plugins/uavobjects/uavobjectfield.cpp +++ b/ground/src/plugins/uavobjects/uavobjectfield.cpp @@ -466,69 +466,74 @@ void UAVObjectField::setValue(const QVariant& value, quint32 index) if ( index >= numElements ) { return; - } - // Set value - switch (type) + } + // Get metadata + UAVObject::Metadata mdata = obj->getMetadata(); + // Update value if the access mode permits + if ( mdata.gcsAccess == UAVObject::ACCESS_READWRITE ) { - case INT8: + switch (type) { - qint8 tmpint8 = value.toInt(); - memcpy(&data[offset + numBytesPerElement*index], &tmpint8, numBytesPerElement); - break; - } - case INT16: - { - qint16 tmpint16 = value.toInt(); - memcpy(&data[offset + numBytesPerElement*index], &tmpint16, numBytesPerElement); - break; - } - case INT32: - { - qint32 tmpint32 = value.toInt(); - memcpy(&data[offset + numBytesPerElement*index], &tmpint32, numBytesPerElement); - break; - } - case UINT8: - { - quint8 tmpuint8 = value.toUInt(); - memcpy(&data[offset + numBytesPerElement*index], &tmpuint8, numBytesPerElement); - break; - } - case UINT16: - { - quint16 tmpuint16 = value.toUInt(); - memcpy(&data[offset + numBytesPerElement*index], &tmpuint16, numBytesPerElement); - break; - } - case UINT32: - { - quint32 tmpuint32 = value.toUInt(); - memcpy(&data[offset + numBytesPerElement*index], &tmpuint32, numBytesPerElement); - break; - } - case FLOAT32: - { - float tmpfloat = value.toFloat(); - memcpy(&data[offset + numBytesPerElement*index], &tmpfloat, numBytesPerElement); - break; - } - case ENUM: - { - qint8 tmpenum = options.indexOf( value.toString() ); - memcpy(&data[offset + numBytesPerElement*index], &tmpenum, numBytesPerElement); - break; - } - case STRING: - { - QString str = value.toString(); - QByteArray barray = str.toAscii(); - quint32 index; - for (index = 0; index < (quint32)barray.length() && index < (numElements-1); ++index) + case INT8: { - data[offset+index] = barray[index]; + qint8 tmpint8 = value.toInt(); + memcpy(&data[offset + numBytesPerElement*index], &tmpint8, numBytesPerElement); + break; + } + case INT16: + { + qint16 tmpint16 = value.toInt(); + memcpy(&data[offset + numBytesPerElement*index], &tmpint16, numBytesPerElement); + break; + } + case INT32: + { + qint32 tmpint32 = value.toInt(); + memcpy(&data[offset + numBytesPerElement*index], &tmpint32, numBytesPerElement); + break; + } + case UINT8: + { + quint8 tmpuint8 = value.toUInt(); + memcpy(&data[offset + numBytesPerElement*index], &tmpuint8, numBytesPerElement); + break; + } + case UINT16: + { + quint16 tmpuint16 = value.toUInt(); + memcpy(&data[offset + numBytesPerElement*index], &tmpuint16, numBytesPerElement); + break; + } + case UINT32: + { + quint32 tmpuint32 = value.toUInt(); + memcpy(&data[offset + numBytesPerElement*index], &tmpuint32, numBytesPerElement); + break; + } + case FLOAT32: + { + float tmpfloat = value.toFloat(); + memcpy(&data[offset + numBytesPerElement*index], &tmpfloat, numBytesPerElement); + break; + } + case ENUM: + { + qint8 tmpenum = options.indexOf( value.toString() ); + memcpy(&data[offset + numBytesPerElement*index], &tmpenum, numBytesPerElement); + break; + } + case STRING: + { + QString str = value.toString(); + QByteArray barray = str.toAscii(); + quint32 index; + for (index = 0; index < (quint32)barray.length() && index < (numElements-1); ++index) + { + data[offset+index] = barray[index]; + } + barray[index] = '\0'; + break; } - barray[index] = '\0'; - break; } } } diff --git a/ground/src/plugins/uavobjects/uavobjecttemplate.cpp b/ground/src/plugins/uavobjects/uavobjecttemplate.cpp index ac69c06f7..c5c9bf676 100644 --- a/ground/src/plugins/uavobjects/uavobjecttemplate.cpp +++ b/ground/src/plugins/uavobjects/uavobjecttemplate.cpp @@ -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); - this->data = data; - emit objectUpdatedAuto(this); // trigger object updated event - emit objectUpdated(this); + // 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); + } } /** diff --git a/ground/src/shared/uavobjectdefinition/actuatorcommand.xml b/ground/src/shared/uavobjectdefinition/actuatorcommand.xml index cf40698f4..d1f1d9a90 100644 --- a/ground/src/shared/uavobjectdefinition/actuatorcommand.xml +++ b/ground/src/shared/uavobjectdefinition/actuatorcommand.xml @@ -1,6 +1,7 @@ + diff --git a/ground/src/shared/uavobjectdefinition/actuatordesired.xml b/ground/src/shared/uavobjectdefinition/actuatordesired.xml index 5606f5278..8ebf1c273 100644 --- a/ground/src/shared/uavobjectdefinition/actuatordesired.xml +++ b/ground/src/shared/uavobjectdefinition/actuatordesired.xml @@ -4,6 +4,7 @@ + diff --git a/ground/src/shared/uavobjectdefinition/actuatorsettings.xml b/ground/src/shared/uavobjectdefinition/actuatorsettings.xml index 3f2a13db8..9d5ba2797 100644 --- a/ground/src/shared/uavobjectdefinition/actuatorsettings.xml +++ b/ground/src/shared/uavobjectdefinition/actuatorsettings.xml @@ -18,6 +18,7 @@ + diff --git a/ground/src/shared/uavobjectdefinition/attitudedesired.xml b/ground/src/shared/uavobjectdefinition/attitudedesired.xml index 35d47d9d5..6c829e775 100644 --- a/ground/src/shared/uavobjectdefinition/attitudedesired.xml +++ b/ground/src/shared/uavobjectdefinition/attitudedesired.xml @@ -4,6 +4,7 @@ + diff --git a/ground/src/shared/uavobjectdefinition/exampleobject1.xml b/ground/src/shared/uavobjectdefinition/exampleobject1.xml index 09509a998..489aaab45 100644 --- a/ground/src/shared/uavobjectdefinition/exampleobject1.xml +++ b/ground/src/shared/uavobjectdefinition/exampleobject1.xml @@ -8,6 +8,7 @@ + diff --git a/ground/src/shared/uavobjectdefinition/exampleobject2.xml b/ground/src/shared/uavobjectdefinition/exampleobject2.xml index 1c3f6d331..64824e54e 100644 --- a/ground/src/shared/uavobjectdefinition/exampleobject2.xml +++ b/ground/src/shared/uavobjectdefinition/exampleobject2.xml @@ -4,6 +4,7 @@ + diff --git a/ground/src/shared/uavobjectdefinition/examplesettings.xml b/ground/src/shared/uavobjectdefinition/examplesettings.xml index afbda6be2..c270fcfa8 100644 --- a/ground/src/shared/uavobjectdefinition/examplesettings.xml +++ b/ground/src/shared/uavobjectdefinition/examplesettings.xml @@ -3,6 +3,7 @@ + diff --git a/ground/src/shared/uavobjectdefinition/flighttelemetrystats.xml b/ground/src/shared/uavobjectdefinition/flighttelemetrystats.xml index e5c7f1124..817c064d7 100644 --- a/ground/src/shared/uavobjectdefinition/flighttelemetrystats.xml +++ b/ground/src/shared/uavobjectdefinition/flighttelemetrystats.xml @@ -6,6 +6,7 @@ + diff --git a/ground/src/shared/uavobjectdefinition/gcstelemetrystats.xml b/ground/src/shared/uavobjectdefinition/gcstelemetrystats.xml index c89e6614f..25caf6fc5 100644 --- a/ground/src/shared/uavobjectdefinition/gcstelemetrystats.xml +++ b/ground/src/shared/uavobjectdefinition/gcstelemetrystats.xml @@ -6,6 +6,7 @@ + diff --git a/ground/src/shared/uavobjectdefinition/gpsobject.xml b/ground/src/shared/uavobjectdefinition/gpsobject.xml index 3656e1433..c9f0d2be7 100644 --- a/ground/src/shared/uavobjectdefinition/gpsobject.xml +++ b/ground/src/shared/uavobjectdefinition/gpsobject.xml @@ -5,6 +5,7 @@ + diff --git a/ground/src/shared/uavobjectdefinition/manualcontrolcommand.xml b/ground/src/shared/uavobjectdefinition/manualcontrolcommand.xml index fac2f4146..613a25fae 100644 --- a/ground/src/shared/uavobjectdefinition/manualcontrolcommand.xml +++ b/ground/src/shared/uavobjectdefinition/manualcontrolcommand.xml @@ -7,6 +7,7 @@ + diff --git a/ground/src/shared/uavobjectdefinition/manualcontrolsettings.xml b/ground/src/shared/uavobjectdefinition/manualcontrolsettings.xml index 3058c144c..d965a5408 100644 --- a/ground/src/shared/uavobjectdefinition/manualcontrolsettings.xml +++ b/ground/src/shared/uavobjectdefinition/manualcontrolsettings.xml @@ -9,6 +9,7 @@ + diff --git a/ground/src/shared/uavobjectdefinition/objectpersistence.xml b/ground/src/shared/uavobjectdefinition/objectpersistence.xml index 3e6f0dfa7..9462c0e56 100644 --- a/ground/src/shared/uavobjectdefinition/objectpersistence.xml +++ b/ground/src/shared/uavobjectdefinition/objectpersistence.xml @@ -4,6 +4,7 @@ + diff --git a/ground/src/shared/uavobjectdefinition/stabilizationsettings.xml b/ground/src/shared/uavobjectdefinition/stabilizationsettings.xml index 83e661e83..2a7a86bef 100644 --- a/ground/src/shared/uavobjectdefinition/stabilizationsettings.xml +++ b/ground/src/shared/uavobjectdefinition/stabilizationsettings.xml @@ -3,6 +3,7 @@ + diff --git a/ground/src/shared/uavobjectdefinition/systemalarms.xml b/ground/src/shared/uavobjectdefinition/systemalarms.xml index 52cfff209..fa1ed819d 100644 --- a/ground/src/shared/uavobjectdefinition/systemalarms.xml +++ b/ground/src/shared/uavobjectdefinition/systemalarms.xml @@ -2,6 +2,7 @@ + diff --git a/ground/src/shared/uavobjectdefinition/systemsettings.xml b/ground/src/shared/uavobjectdefinition/systemsettings.xml index f772a57d3..6c3997808 100644 --- a/ground/src/shared/uavobjectdefinition/systemsettings.xml +++ b/ground/src/shared/uavobjectdefinition/systemsettings.xml @@ -1,6 +1,7 @@ + diff --git a/ground/src/shared/uavobjectdefinition/systemstats.xml b/ground/src/shared/uavobjectdefinition/systemstats.xml index 9fb8f1bbc..1bd5fee6a 100644 --- a/ground/src/shared/uavobjectdefinition/systemstats.xml +++ b/ground/src/shared/uavobjectdefinition/systemstats.xml @@ -3,6 +3,7 @@ + diff --git a/ground/src/shared/uavobjectdefinition/telemetrysettings.xml b/ground/src/shared/uavobjectdefinition/telemetrysettings.xml index 92a060916..6a742ed7b 100644 --- a/ground/src/shared/uavobjectdefinition/telemetrysettings.xml +++ b/ground/src/shared/uavobjectdefinition/telemetrysettings.xml @@ -1,6 +1,7 @@ +