mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-4 GCS/System Created CPU utilization measurement and created object to report system information (load, heap and time)
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@520 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
40beb15129
commit
b92cf530a5
94
ground/src/plugins/uavobjects/systemalarms.cpp
Normal file
94
ground/src/plugins/uavobjects/systemalarms.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file systemalarms.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the SystemAlarms object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: systemalarms.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
|
||||
*/
|
||||
#include "systemalarms.h"
|
||||
#include "uavobjectfields.h"
|
||||
|
||||
const QString SystemAlarms::NAME = QString("SystemAlarms");
|
||||
|
||||
SystemAlarms::SystemAlarms(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
|
||||
{
|
||||
// Create fields
|
||||
QList<UAVObjectField*> fields;
|
||||
QStringList TypeEnumOptions;
|
||||
TypeEnumOptions.append("None");
|
||||
TypeEnumOptions.append("StackOverflow");
|
||||
TypeEnumOptions.append("OutOfMemory");
|
||||
fields.append(new UAVObjectFieldEnum(QString("Type"), QString(""), 1, TypeEnumOptions));
|
||||
QStringList SeverityEnumOptions;
|
||||
SeverityEnumOptions.append("Info");
|
||||
SeverityEnumOptions.append("Warning");
|
||||
SeverityEnumOptions.append("Error");
|
||||
SeverityEnumOptions.append("Critical");
|
||||
fields.append(new UAVObjectFieldEnum(QString("Severity"), QString(""), 1, SeverityEnumOptions));
|
||||
QStringList ActiveEnumOptions;
|
||||
ActiveEnumOptions.append("True");
|
||||
ActiveEnumOptions.append("False");
|
||||
fields.append(new UAVObjectFieldEnum(QString("Active"), QString("bool"), 1, ActiveEnumOptions));
|
||||
fields.append(new UAVObjectFieldUInt32(QString("Info"), QString(""), 1));
|
||||
|
||||
// Initialize object
|
||||
initializeFields(fields, (quint8*)&data, NUMBYTES);
|
||||
}
|
||||
|
||||
UAVObject::Metadata SystemAlarms::getDefaultMetadata()
|
||||
{
|
||||
UAVObject::Metadata metadata;
|
||||
metadata.gcsTelemetryAcked = 1;
|
||||
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
|
||||
metadata.gcsTelemetryUpdatePeriod = 0;
|
||||
metadata.flightTelemetryAcked = 1;
|
||||
metadata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
|
||||
metadata.flightTelemetryUpdatePeriod = 0;
|
||||
metadata.loggingUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
|
||||
metadata.loggingUpdatePeriod = 0;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
SystemAlarms::DataFields SystemAlarms::getData()
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
return data;
|
||||
}
|
||||
|
||||
void SystemAlarms::setData(DataFields& data)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
this->data = data;
|
||||
emit objectUpdatedAuto(this); // trigger object updated event
|
||||
emit objectUpdated(this);
|
||||
}
|
||||
|
||||
UAVDataObject* SystemAlarms::clone(quint32 instID)
|
||||
{
|
||||
SystemAlarms* obj = new SystemAlarms();
|
||||
obj->initialize(instID, this->getMetaObject());
|
||||
return obj;
|
||||
}
|
76
ground/src/plugins/uavobjects/systemalarms.h
Normal file
76
ground/src/plugins/uavobjects/systemalarms.h
Normal file
@ -0,0 +1,76 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file systemalarms.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the SystemAlarms object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: systemalarms.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
|
||||
*/
|
||||
#ifndef SYSTEMALARMS_H
|
||||
#define SYSTEMALARMS_H
|
||||
|
||||
#include "uavdataobject.h"
|
||||
|
||||
class UAVOBJECTS_EXPORT SystemAlarms: public UAVDataObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Field structure
|
||||
typedef struct {
|
||||
quint8 Type;
|
||||
quint8 Severity;
|
||||
quint8 Active;
|
||||
quint32 Info;
|
||||
|
||||
} __attribute__((packed)) DataFields;
|
||||
|
||||
// Enumeration types
|
||||
typedef enum { TYPE_NONE=0, TYPE_STACKOVERFLOW=1, TYPE_OUTOFMEMORY=2, } TypeEnum;
|
||||
typedef enum { SEVERITY_INFO=0, SEVERITY_WARNING=1, SEVERITY_ERROR=2, SEVERITY_CRITICAL=3, } SeverityEnum;
|
||||
typedef enum { ACTIVE_TRUE=0, ACTIVE_FALSE=1, } ActiveEnum;
|
||||
|
||||
|
||||
// Constants
|
||||
static const quint32 OBJID = 1784134234U;
|
||||
static const QString NAME;
|
||||
static const bool ISSINGLEINST = 1;
|
||||
static const bool ISSETTINGS = 0;
|
||||
static const quint32 NUMBYTES = sizeof(DataFields);
|
||||
|
||||
// Functions
|
||||
SystemAlarms();
|
||||
|
||||
DataFields getData();
|
||||
void setData(DataFields& data);
|
||||
Metadata getDefaultMetadata();
|
||||
UAVDataObject* clone(quint32 instID);
|
||||
|
||||
private:
|
||||
DataFields data;
|
||||
|
||||
};
|
||||
|
||||
#endif // SYSTEMALARMS_H
|
81
ground/src/plugins/uavobjects/systemstats.cpp
Normal file
81
ground/src/plugins/uavobjects/systemstats.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file systemstats.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the SystemStats object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: systemstats.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
|
||||
*/
|
||||
#include "systemstats.h"
|
||||
#include "uavobjectfields.h"
|
||||
|
||||
const QString SystemStats::NAME = QString("SystemStats");
|
||||
|
||||
SystemStats::SystemStats(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
|
||||
{
|
||||
// Create fields
|
||||
QList<UAVObjectField*> fields;
|
||||
fields.append(new UAVObjectFieldUInt32(QString("FlightTime"), QString("ms"), 1));
|
||||
fields.append(new UAVObjectFieldUInt16(QString("HeapRemaining"), QString("bytes"), 1));
|
||||
fields.append(new UAVObjectFieldUInt8(QString("CPULoad"), QString("%"), 1));
|
||||
|
||||
// Initialize object
|
||||
initializeFields(fields, (quint8*)&data, NUMBYTES);
|
||||
}
|
||||
|
||||
UAVObject::Metadata SystemStats::getDefaultMetadata()
|
||||
{
|
||||
UAVObject::Metadata metadata;
|
||||
metadata.gcsTelemetryAcked = 1;
|
||||
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_NEVER;
|
||||
metadata.gcsTelemetryUpdatePeriod = 0;
|
||||
metadata.flightTelemetryAcked = 1;
|
||||
metadata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
|
||||
metadata.flightTelemetryUpdatePeriod = 1000;
|
||||
metadata.loggingUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
|
||||
metadata.loggingUpdatePeriod = 1000;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
SystemStats::DataFields SystemStats::getData()
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
return data;
|
||||
}
|
||||
|
||||
void SystemStats::setData(DataFields& data)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
this->data = data;
|
||||
emit objectUpdatedAuto(this); // trigger object updated event
|
||||
emit objectUpdated(this);
|
||||
}
|
||||
|
||||
UAVDataObject* SystemStats::clone(quint32 instID)
|
||||
{
|
||||
SystemStats* obj = new SystemStats();
|
||||
obj->initialize(instID, this->getMetaObject());
|
||||
return obj;
|
||||
}
|
72
ground/src/plugins/uavobjects/systemstats.h
Normal file
72
ground/src/plugins/uavobjects/systemstats.h
Normal file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file systemstats.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the SystemStats object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: systemstats.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
|
||||
*/
|
||||
#ifndef SYSTEMSTATS_H
|
||||
#define SYSTEMSTATS_H
|
||||
|
||||
#include "uavdataobject.h"
|
||||
|
||||
class UAVOBJECTS_EXPORT SystemStats: public UAVDataObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Field structure
|
||||
typedef struct {
|
||||
quint32 FlightTime;
|
||||
quint16 HeapRemaining;
|
||||
quint8 CPULoad;
|
||||
|
||||
} __attribute__((packed)) DataFields;
|
||||
|
||||
// Enumeration types
|
||||
|
||||
|
||||
// Constants
|
||||
static const quint32 OBJID = 680908530U;
|
||||
static const QString NAME;
|
||||
static const bool ISSINGLEINST = 1;
|
||||
static const bool ISSETTINGS = 0;
|
||||
static const quint32 NUMBYTES = sizeof(DataFields);
|
||||
|
||||
// Functions
|
||||
SystemStats();
|
||||
|
||||
DataFields getData();
|
||||
void setData(DataFields& data);
|
||||
Metadata getDefaultMetadata();
|
||||
UAVDataObject* clone(quint32 instID);
|
||||
|
||||
private:
|
||||
DataFields data;
|
||||
|
||||
};
|
||||
|
||||
#endif // SYSTEMSTATS_H
|
@ -26,7 +26,9 @@ HEADERS += uavobjects_global.h \
|
||||
settingspersistence.h \
|
||||
gpsobject.h \
|
||||
gcstelemetrystats.h \
|
||||
flighttelemetrystats.h
|
||||
flighttelemetrystats.h \
|
||||
systemstats.h \
|
||||
systemalarms.h
|
||||
SOURCES += uavobject.cpp \
|
||||
uavmetaobject.cpp \
|
||||
uavobjectmanager.cpp \
|
||||
@ -49,6 +51,8 @@ SOURCES += uavobject.cpp \
|
||||
settingspersistence.cpp \
|
||||
gpsobject.cpp \
|
||||
gcstelemetrystats.cpp \
|
||||
flighttelemetrystats.cpp
|
||||
flighttelemetrystats.cpp \
|
||||
systemstats.cpp \
|
||||
systemalarms.cpp
|
||||
DEFINES += UAVOBJECTS_LIBRARY
|
||||
OTHER_FILES += UAVObjects.pluginspec
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include "gcstelemetrystats.h"
|
||||
#include "gpsobject.h"
|
||||
#include "settingspersistence.h"
|
||||
#include "systemalarms.h"
|
||||
#include "systemstats.h"
|
||||
|
||||
|
||||
/**
|
||||
@ -52,5 +54,7 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr)
|
||||
objMngr->registerObject( new GCSTelemetryStats() );
|
||||
objMngr->registerObject( new GpsObject() );
|
||||
objMngr->registerObject( new SettingsPersistence() );
|
||||
objMngr->registerObject( new SystemAlarms() );
|
||||
objMngr->registerObject( new SystemStats() );
|
||||
|
||||
}
|
||||
|
11
ground/src/shared/uavobjectdefinition/systemalarms.xml
Normal file
11
ground/src/shared/uavobjectdefinition/systemalarms.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<xml>
|
||||
<object name="SystemAlarms" singleinstance="true" settings="false">
|
||||
<field name="Type" units="" type="enum" elements="1" options="None,StackOverflow,OutOfMemory"/>
|
||||
<field name="Severity" units="" type="enum" elements="1" options="Info,Warning,Error,Critical"/>
|
||||
<field name="Active" units="bool" type="enum" elements="1" options="True,False"/>
|
||||
<field name="Info" units="" type="uint32" elements="1"/>
|
||||
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
||||
<telemetryflight acked="true" updatemode="onchange" period="0"/>
|
||||
<logging updatemode="onchange" period="0"/>
|
||||
</object>
|
||||
</xml>
|
10
ground/src/shared/uavobjectdefinition/systemstats.xml
Normal file
10
ground/src/shared/uavobjectdefinition/systemstats.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<xml>
|
||||
<object name="SystemStats" singleinstance="true" settings="false">
|
||||
<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"/>
|
||||
<telemetrygcs acked="true" updatemode="never" period="0"/>
|
||||
<telemetryflight acked="true" updatemode="periodic" period="1000"/>
|
||||
<logging updatemode="periodic" period="1000"/>
|
||||
</object>
|
||||
</xml>
|
Loading…
x
Reference in New Issue
Block a user