mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
GCS/UAVObjects: Added TaskInfo object
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2348 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
d6cb01edf2
commit
1bdc03bb1c
159
ground/src/plugins/uavobjects/taskinfo.cpp
Normal file
159
ground/src/plugins/uavobjects/taskinfo.cpp
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file taskinfo.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
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @note Object definition file: taskinfo.xml.
|
||||||
|
* This is an automatically generated file.
|
||||||
|
* DO NOT modify manually.
|
||||||
|
*
|
||||||
|
* @brief The UAVUObjects GCS plugin
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* 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.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#include "taskinfo.h"
|
||||||
|
#include "uavobjectfield.h"
|
||||||
|
|
||||||
|
const QString TaskInfo::NAME = QString("TaskInfo");
|
||||||
|
const QString TaskInfo::DESCRIPTION = QString("Task information");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
TaskInfo::TaskInfo(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
|
||||||
|
{
|
||||||
|
// Create fields
|
||||||
|
QList<UAVObjectField*> fields;
|
||||||
|
QStringList StackRemainingElemNames;
|
||||||
|
StackRemainingElemNames.append("System");
|
||||||
|
StackRemainingElemNames.append("Actuator");
|
||||||
|
StackRemainingElemNames.append("TelemetryTx");
|
||||||
|
StackRemainingElemNames.append("TelemetryTxPri");
|
||||||
|
StackRemainingElemNames.append("TelemetryRx");
|
||||||
|
StackRemainingElemNames.append("GPS");
|
||||||
|
StackRemainingElemNames.append("ManualControl");
|
||||||
|
StackRemainingElemNames.append("Altitude");
|
||||||
|
StackRemainingElemNames.append("AHRSComms");
|
||||||
|
StackRemainingElemNames.append("Stabilization");
|
||||||
|
StackRemainingElemNames.append("Guidance");
|
||||||
|
StackRemainingElemNames.append("Watchdog");
|
||||||
|
fields.append( new UAVObjectField(QString("StackRemaining"), QString("bytes"), UAVObjectField::UINT16, StackRemainingElemNames, QStringList()) );
|
||||||
|
QStringList RunningElemNames;
|
||||||
|
RunningElemNames.append("System");
|
||||||
|
RunningElemNames.append("Actuator");
|
||||||
|
RunningElemNames.append("TelemetryTx");
|
||||||
|
RunningElemNames.append("TelemetryTxPri");
|
||||||
|
RunningElemNames.append("TelemetryRx");
|
||||||
|
RunningElemNames.append("GPS");
|
||||||
|
RunningElemNames.append("ManualControl");
|
||||||
|
RunningElemNames.append("Altitude");
|
||||||
|
RunningElemNames.append("AHRSComms");
|
||||||
|
RunningElemNames.append("Stabilization");
|
||||||
|
RunningElemNames.append("Guidance");
|
||||||
|
RunningElemNames.append("Watchdog");
|
||||||
|
QStringList RunningEnumOptions;
|
||||||
|
RunningEnumOptions.append("False");
|
||||||
|
RunningEnumOptions.append("True");
|
||||||
|
fields.append( new UAVObjectField(QString("Running"), QString("bool"), UAVObjectField::ENUM, RunningElemNames, RunningEnumOptions) );
|
||||||
|
|
||||||
|
// Initialize object
|
||||||
|
initializeFields(fields, (quint8*)&data, NUMBYTES);
|
||||||
|
// Set the default field values
|
||||||
|
setDefaultFieldValues();
|
||||||
|
// Set the object description
|
||||||
|
setDescription(DESCRIPTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the default metadata for this object
|
||||||
|
*/
|
||||||
|
UAVObject::Metadata TaskInfo::getDefaultMetadata()
|
||||||
|
{
|
||||||
|
UAVObject::Metadata metadata;
|
||||||
|
metadata.flightAccess = ACCESS_READWRITE;
|
||||||
|
metadata.gcsAccess = ACCESS_READWRITE;
|
||||||
|
metadata.gcsTelemetryAcked = 1;
|
||||||
|
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
|
||||||
|
metadata.gcsTelemetryUpdatePeriod = 0;
|
||||||
|
metadata.flightTelemetryAcked = 1;
|
||||||
|
metadata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
|
||||||
|
metadata.flightTelemetryUpdatePeriod = 10000;
|
||||||
|
metadata.loggingUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
|
||||||
|
metadata.loggingUpdatePeriod = 1000;
|
||||||
|
return metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize object fields with the default values.
|
||||||
|
* If a default value is not specified the object fields
|
||||||
|
* will be initialized to zero.
|
||||||
|
*/
|
||||||
|
void TaskInfo::setDefaultFieldValues()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the object data fields
|
||||||
|
*/
|
||||||
|
TaskInfo::DataFields TaskInfo::getData()
|
||||||
|
{
|
||||||
|
QMutexLocker locker(mutex);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the object data fields
|
||||||
|
*/
|
||||||
|
void TaskInfo::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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a clone of this object, a new instance ID must be specified.
|
||||||
|
* Do not use this function directly to create new instances, the
|
||||||
|
* UAVObjectManager should be used instead.
|
||||||
|
*/
|
||||||
|
UAVDataObject* TaskInfo::clone(quint32 instID)
|
||||||
|
{
|
||||||
|
TaskInfo* obj = new TaskInfo();
|
||||||
|
obj->initialize(instID, this->getMetaObject());
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Static function to retrieve an instance of the object.
|
||||||
|
*/
|
||||||
|
TaskInfo* TaskInfo::GetInstance(UAVObjectManager* objMngr, quint32 instID)
|
||||||
|
{
|
||||||
|
return dynamic_cast<TaskInfo*>(objMngr->getObject(TaskInfo::OBJID, instID));
|
||||||
|
}
|
91
ground/src/plugins/uavobjects/taskinfo.h
Normal file
91
ground/src/plugins/uavobjects/taskinfo.h
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file taskinfo.h
|
||||||
|
* @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
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @note Object definition file: taskinfo.xml.
|
||||||
|
* This is an automatically generated file.
|
||||||
|
* DO NOT modify manually.
|
||||||
|
*
|
||||||
|
* @brief The UAVUObjects GCS plugin
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* 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.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#ifndef TASKINFO_H
|
||||||
|
#define TASKINFO_H
|
||||||
|
|
||||||
|
#include "uavdataobject.h"
|
||||||
|
#include "uavobjectmanager.h"
|
||||||
|
|
||||||
|
class UAVOBJECTS_EXPORT TaskInfo: public UAVDataObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Field structure
|
||||||
|
typedef struct {
|
||||||
|
quint16 StackRemaining[12];
|
||||||
|
quint8 Running[12];
|
||||||
|
|
||||||
|
} __attribute__((packed)) DataFields;
|
||||||
|
|
||||||
|
// Field information
|
||||||
|
// Field StackRemaining information
|
||||||
|
/* Array element names for field StackRemaining */
|
||||||
|
typedef enum { STACKREMAINING_SYSTEM=0, STACKREMAINING_ACTUATOR=1, STACKREMAINING_TELEMETRYTX=2, STACKREMAINING_TELEMETRYTXPRI=3, STACKREMAINING_TELEMETRYRX=4, STACKREMAINING_GPS=5, STACKREMAINING_MANUALCONTROL=6, STACKREMAINING_ALTITUDE=7, STACKREMAINING_AHRSCOMMS=8, STACKREMAINING_STABILIZATION=9, STACKREMAINING_GUIDANCE=10, STACKREMAINING_WATCHDOG=11 } StackRemainingElem;
|
||||||
|
/* Number of elements for field StackRemaining */
|
||||||
|
static const quint32 STACKREMAINING_NUMELEM = 12;
|
||||||
|
// Field Running information
|
||||||
|
/* Enumeration options for field Running */
|
||||||
|
typedef enum { RUNNING_FALSE=0, RUNNING_TRUE=1 } RunningOptions;
|
||||||
|
/* Array element names for field Running */
|
||||||
|
typedef enum { RUNNING_SYSTEM=0, RUNNING_ACTUATOR=1, RUNNING_TELEMETRYTX=2, RUNNING_TELEMETRYTXPRI=3, RUNNING_TELEMETRYRX=4, RUNNING_GPS=5, RUNNING_MANUALCONTROL=6, RUNNING_ALTITUDE=7, RUNNING_AHRSCOMMS=8, RUNNING_STABILIZATION=9, RUNNING_GUIDANCE=10, RUNNING_WATCHDOG=11 } RunningElem;
|
||||||
|
/* Number of elements for field Running */
|
||||||
|
static const quint32 RUNNING_NUMELEM = 12;
|
||||||
|
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
static const quint32 OBJID = 3297598544U;
|
||||||
|
static const QString NAME;
|
||||||
|
static const QString DESCRIPTION;
|
||||||
|
static const bool ISSINGLEINST = 1;
|
||||||
|
static const bool ISSETTINGS = 0;
|
||||||
|
static const quint32 NUMBYTES = sizeof(DataFields);
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
TaskInfo();
|
||||||
|
|
||||||
|
DataFields getData();
|
||||||
|
void setData(const DataFields& data);
|
||||||
|
Metadata getDefaultMetadata();
|
||||||
|
UAVDataObject* clone(quint32 instID);
|
||||||
|
|
||||||
|
static TaskInfo* GetInstance(UAVObjectManager* objMngr, quint32 instID = 0);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DataFields data;
|
||||||
|
|
||||||
|
void setDefaultFieldValues();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TASKINFO_H
|
120
ground/src/plugins/uavobjects/taskinfo.py
Normal file
120
ground/src/plugins/uavobjects/taskinfo.py
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# @file taskinfo.py
|
||||||
|
# @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
# @brief Implementation of the TaskInfo object. This file has been
|
||||||
|
# automatically generated by the UAVObjectGenerator.
|
||||||
|
#
|
||||||
|
# @note Object definition file: taskinfo.xml.
|
||||||
|
# This is an automatically generated file.
|
||||||
|
# DO NOT modify manually.
|
||||||
|
#
|
||||||
|
# @see The GNU Public License (GPL) Version 3
|
||||||
|
#
|
||||||
|
#############################################################################/
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# for more details.
|
||||||
|
#
|
||||||
|
# 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.,
|
||||||
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
import uavobject
|
||||||
|
|
||||||
|
import struct
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
# This is a list of instances of the data fields contained in this object
|
||||||
|
_fields = [ \
|
||||||
|
uavobject.UAVObjectField(
|
||||||
|
'StackRemaining',
|
||||||
|
'H',
|
||||||
|
12,
|
||||||
|
[
|
||||||
|
'System',
|
||||||
|
'Actuator',
|
||||||
|
'TelemetryTx',
|
||||||
|
'TelemetryTxPri',
|
||||||
|
'TelemetryRx',
|
||||||
|
'GPS',
|
||||||
|
'ManualControl',
|
||||||
|
'Altitude',
|
||||||
|
'AHRSComms',
|
||||||
|
'Stabilization',
|
||||||
|
'Guidance',
|
||||||
|
'Watchdog',
|
||||||
|
],
|
||||||
|
{
|
||||||
|
}
|
||||||
|
),
|
||||||
|
uavobject.UAVObjectField(
|
||||||
|
'Running',
|
||||||
|
'b',
|
||||||
|
12,
|
||||||
|
[
|
||||||
|
'System',
|
||||||
|
'Actuator',
|
||||||
|
'TelemetryTx',
|
||||||
|
'TelemetryTxPri',
|
||||||
|
'TelemetryRx',
|
||||||
|
'GPS',
|
||||||
|
'ManualControl',
|
||||||
|
'Altitude',
|
||||||
|
'AHRSComms',
|
||||||
|
'Stabilization',
|
||||||
|
'Guidance',
|
||||||
|
'Watchdog',
|
||||||
|
],
|
||||||
|
{
|
||||||
|
'0' : 'False',
|
||||||
|
'1' : 'True',
|
||||||
|
}
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class TaskInfo(uavobject.UAVObject):
|
||||||
|
## Object constants
|
||||||
|
OBJID = 3297598544
|
||||||
|
NAME = "TaskInfo"
|
||||||
|
METANAME = "TaskInfoMeta"
|
||||||
|
ISSINGLEINST = 1
|
||||||
|
ISSETTINGS = 0
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
uavobject.UAVObject.__init__(self,
|
||||||
|
self.OBJID,
|
||||||
|
self.NAME,
|
||||||
|
self.METANAME,
|
||||||
|
0,
|
||||||
|
self.ISSINGLEINST)
|
||||||
|
|
||||||
|
for f in _fields:
|
||||||
|
self.add_field(f)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
s = ("0x%08X (%10u) %-30s %3u bytes format '%s'\n"
|
||||||
|
% (self.OBJID, self.OBJID, self.NAME, self.get_struct().size, self.get_struct().format))
|
||||||
|
for f in self.get_tuple()._fields:
|
||||||
|
s += ("\t%s\n" % f)
|
||||||
|
return (s)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# Instantiate the object and dump out some interesting info
|
||||||
|
x = TaskInfo()
|
||||||
|
print (x)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
#import pdb ; pdb.run('main()')
|
||||||
|
main()
|
@ -48,7 +48,8 @@ HEADERS += uavobjects_global.h \
|
|||||||
pipxtrememodemsettings.h \
|
pipxtrememodemsettings.h \
|
||||||
pipxtrememodemstatus.h \
|
pipxtrememodemstatus.h \
|
||||||
i2cstats.h \
|
i2cstats.h \
|
||||||
batterysettings.h
|
batterysettings.h \
|
||||||
|
taskinfo.h
|
||||||
|
|
||||||
SOURCES += uavobject.cpp \
|
SOURCES += uavobject.cpp \
|
||||||
uavmetaobject.cpp \
|
uavmetaobject.cpp \
|
||||||
@ -94,5 +95,6 @@ SOURCES += uavobject.cpp \
|
|||||||
pipxtrememodemsettings.cpp \
|
pipxtrememodemsettings.cpp \
|
||||||
pipxtrememodemstatus.cpp \
|
pipxtrememodemstatus.cpp \
|
||||||
i2cstats.cpp \
|
i2cstats.cpp \
|
||||||
batterysettings.cpp
|
batterysettings.cpp \
|
||||||
|
taskinfo.cpp
|
||||||
OTHER_FILES += UAVObjects.pluginspec
|
OTHER_FILES += UAVObjects.pluginspec
|
||||||
|
@ -65,6 +65,7 @@
|
|||||||
#include "systemalarms.h"
|
#include "systemalarms.h"
|
||||||
#include "systemsettings.h"
|
#include "systemsettings.h"
|
||||||
#include "systemstats.h"
|
#include "systemstats.h"
|
||||||
|
#include "taskinfo.h"
|
||||||
#include "telemetrysettings.h"
|
#include "telemetrysettings.h"
|
||||||
#include "velocityactual.h"
|
#include "velocityactual.h"
|
||||||
#include "velocitydesired.h"
|
#include "velocitydesired.h"
|
||||||
@ -111,6 +112,7 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr)
|
|||||||
objMngr->registerObject( new SystemAlarms() );
|
objMngr->registerObject( new SystemAlarms() );
|
||||||
objMngr->registerObject( new SystemSettings() );
|
objMngr->registerObject( new SystemSettings() );
|
||||||
objMngr->registerObject( new SystemStats() );
|
objMngr->registerObject( new SystemStats() );
|
||||||
|
objMngr->registerObject( new TaskInfo() );
|
||||||
objMngr->registerObject( new TelemetrySettings() );
|
objMngr->registerObject( new TelemetrySettings() );
|
||||||
objMngr->registerObject( new VelocityActual() );
|
objMngr->registerObject( new VelocityActual() );
|
||||||
objMngr->registerObject( new VelocityDesired() );
|
objMngr->registerObject( new VelocityDesired() );
|
||||||
|
11
ground/src/shared/uavobjectdefinition/taskinfo.xml
Normal file
11
ground/src/shared/uavobjectdefinition/taskinfo.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<xml>
|
||||||
|
<object name="TaskInfo" singleinstance="true" settings="false">
|
||||||
|
<description>Task information</description>
|
||||||
|
<field name="StackRemaining" units="bytes" type="uint16" elementnames="System,Actuator,TelemetryTx,TelemetryTxPri,TelemetryRx,GPS,ManualControl,Altitude,AHRSComms,Stabilization,Guidance,Watchdog"/>
|
||||||
|
<field name="Running" units="bool" type="enum" options="False,True" elementnames="System,Actuator,TelemetryTx,TelemetryTxPri,TelemetryRx,GPS,ManualControl,Altitude,AHRSComms,Stabilization,Guidance,Watchdog"/>
|
||||||
|
<access gcs="readwrite" flight="readwrite"/>
|
||||||
|
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
||||||
|
<telemetryflight acked="true" updatemode="periodic" period="10000"/>
|
||||||
|
<logging updatemode="periodic" period="1000"/>
|
||||||
|
</object>
|
||||||
|
</xml>
|
Loading…
Reference in New Issue
Block a user