2013-04-05 23:46:56 +03:00
/**
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @ file uavmetaobject . cpp
* @ author The OpenPilot Team , http : //www.openpilot.org Copyright (C) 2010.
* @ see The GNU Public License ( GPL ) Version 3
* @ addtogroup GCSPlugins GCS Plugins
* @ {
* @ addtogroup UAVObjectsPlugin UAVObjects Plugin
* @ {
* @ brief The UAVUObjects GCS plugin
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
2013-05-19 17:37:30 +03:00
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
2013-04-05 23:46:56 +03:00
* ( at your option ) any later version .
2013-05-19 17:37:30 +03:00
*
* This program is distributed in the hope that it will be useful , but
* WITHOUT ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE . See the GNU General Public License
2013-04-05 23:46:56 +03:00
* for more details .
2013-05-19 17:37:30 +03:00
*
* You should have received a copy of the GNU General Public License along
* with this program ; if not , write to the Free Software Foundation , Inc . ,
2013-04-05 23:46:56 +03:00
* 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*/
# include "uavmetaobject.h"
# include "uavobjectfield.h"
/**
* Constructor
*/
2013-05-19 17:37:30 +03:00
UAVMetaObject : : UAVMetaObject ( quint32 objID , const QString & name , UAVObject * parent ) :
UAVObject ( objID , true , name )
2013-04-05 23:46:56 +03:00
{
this - > parent = parent ;
// Setup default metadata of metaobject (can not be changed)
UAVObject : : MetadataInitialize ( ownMetadata ) ;
// Setup fields
QStringList modesBitField ;
2013-11-17 14:00:42 +01:00
modesBitField < < tr ( " FlightReadOnly " ) < < tr ( " GCSReadOnly " ) < < tr ( " FlightTelemetryAcked " ) < < tr ( " GCSTelemetryAcked " ) < < tr ( " FlightUpdatePeriodic " ) < < tr ( " FlightUpdateOnChange " ) < < tr ( " GCSUpdatePeriodic " ) < < tr ( " GCSUpdateOnChange " ) < < tr ( " LoggingUpdatePeriodic " ) < < tr ( " LoggingUpdateOnChange " ) ;
2013-05-19 17:37:30 +03:00
QList < UAVObjectField * > fields ;
2014-10-11 16:12:58 +02:00
fields . append ( new UAVObjectField ( tr ( " Modes " ) , tr ( " Metadata modes " ) , tr ( " boolean " ) , UAVObjectField : : BITFIELD , modesBitField , QStringList ( ) ) ) ;
fields . append ( new UAVObjectField ( tr ( " Flight Telemetry Update Period " ) , tr ( " This is how often flight side will update telemetry data " ) , tr ( " ms " ) , UAVObjectField : : UINT16 , 1 , QStringList ( ) ) ) ;
fields . append ( new UAVObjectField ( tr ( " GCS Telemetry Update Period " ) , tr ( " This is how often GCS will update telemetry data " ) , tr ( " ms " ) , UAVObjectField : : UINT16 , 1 , QStringList ( ) ) ) ;
fields . append ( new UAVObjectField ( tr ( " Logging Update Period " ) , tr ( " This is how often logging will be updated. " ) , tr ( " ms " ) , UAVObjectField : : UINT16 , 1 , QStringList ( ) ) ) ;
2013-04-05 23:46:56 +03:00
// Initialize parent
UAVObject : : initialize ( 0 ) ;
2013-05-19 17:37:30 +03:00
UAVObject : : initializeFields ( fields , ( quint8 * ) & parentMetadata , sizeof ( Metadata ) ) ;
2013-04-05 23:46:56 +03:00
// Setup metadata of parent
parentMetadata = parent - > getDefaultMetadata ( ) ;
}
/**
* Get the parent object
*/
2013-05-19 17:37:30 +03:00
UAVObject * UAVMetaObject : : getParentObject ( )
2013-04-05 23:46:56 +03:00
{
return parent ;
}
/**
* Set the metadata of the metaobject , this function will
* do nothing since metaobjects have read - only metadata .
*/
2013-05-19 17:37:30 +03:00
void UAVMetaObject : : setMetadata ( const Metadata & mdata )
2013-04-05 23:46:56 +03:00
{
Q_UNUSED ( mdata ) ;
2013-05-19 17:37:30 +03:00
// can not update metaobject's metadata
2013-04-05 23:46:56 +03:00
}
/**
* Get the metadata of the metaobject
*/
UAVObject : : Metadata UAVMetaObject : : getMetadata ( )
{
return ownMetadata ;
}
/**
* Get the default metadata
*/
UAVObject : : Metadata UAVMetaObject : : getDefaultMetadata ( )
{
return ownMetadata ;
}
/**
* Set the metadata held by the metaobject
*/
2013-05-19 17:37:30 +03:00
void UAVMetaObject : : setData ( const Metadata & mdata )
2013-04-05 23:46:56 +03:00
{
QMutexLocker locker ( mutex ) ;
2013-05-19 17:37:30 +03:00
2013-04-05 23:46:56 +03:00
parentMetadata = mdata ;
emit objectUpdatedAuto ( this ) ; // trigger object updated event
emit objectUpdated ( this ) ;
}
/**
* Get the metadata held by the metaobject
*/
UAVObject : : Metadata UAVMetaObject : : getData ( )
{
QMutexLocker locker ( mutex ) ;
2013-05-19 17:37:30 +03:00
2013-04-05 23:46:56 +03:00
return parentMetadata ;
}
2014-03-06 00:41:48 +01:00
bool UAVMetaObject : : isMetaDataObject ( )
{
return true ;
}