1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

Update to FlightBatteryState UAVObject in preparation for updates to PowerSensor code.

As this changes UAVObjects both flight and GCS software will need to be recompiled to stay in sync.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2302 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
andrew 2010-12-28 04:28:39 +00:00 committed by andrew
parent 2f38fe2269
commit 76be2b991b
7 changed files with 88 additions and 16 deletions

View File

@ -3,7 +3,7 @@
* @addtogroup UAVObjects OpenPilot UAVObjects
* @{
* @addtogroup FlightBatteryState FlightBatteryState
* @brief Battery status information. Not currently updated.
* @brief Battery status information.
*
* Autogenerated files and functions for FlightBatteryState Object
* @{
@ -80,6 +80,12 @@ static void setDefaults(UAVObjHandle obj, uint16_t instId)
// Initialize object fields to their default values
UAVObjGetInstanceData(obj, instId, &data);
memset(&data, 0, sizeof(FlightBatteryStateData));
data.Voltage = 0;
data.Current = 0;
data.PeakCurrent = 0;
data.AvgCurrent = 0;
data.ConsumedEnergy = 0;
data.EstimatedFlightTime = 0;
UAVObjSetInstanceData(obj, instId, &data);

View File

@ -3,7 +3,7 @@
* @addtogroup UAVObjects OpenPilot UAVObjects
* @{
* @addtogroup FlightBatteryState FlightBatteryState
* @brief Battery status information. Not currently updated.
* @brief Battery status information.
*
* Autogenerated files and functions for FlightBatteryState Object
@ -41,7 +41,7 @@
#define FLIGHTBATTERYSTATE_H
// Object constants
#define FLIGHTBATTERYSTATE_OBJID 144318184U
#define FLIGHTBATTERYSTATE_OBJID 126985486U
#define FLIGHTBATTERYSTATE_NAME "FlightBatteryState"
#define FLIGHTBATTERYSTATE_METANAME "FlightBatteryStateMeta"
#define FLIGHTBATTERYSTATE_ISSINGLEINST 1
@ -73,14 +73,20 @@
typedef struct {
float Voltage;
float Current;
uint32_t ConsumedEnergy;
float PeakCurrent;
float AvgCurrent;
float ConsumedEnergy;
float EstimatedFlightTime;
} __attribute__((packed)) FlightBatteryStateData;
// Field information
// Field Voltage information
// Field Current information
// Field PeakCurrent information
// Field AvgCurrent information
// Field ConsumedEnergy information
// Field EstimatedFlightTime information
// Generic interface functions

View File

@ -122,7 +122,10 @@ function [] = OPLogConvert()
FlightBatteryState.timestamp = 0;
FlightBatteryState(1).Voltage = 0;
FlightBatteryState(1).Current = 0;
FlightBatteryState(1).PeakCurrent = 0;
FlightBatteryState(1).AvgCurrent = 0;
FlightBatteryState(1).ConsumedEnergy = 0;
FlightBatteryState(1).EstimatedFlightTime = 0;
flighttelemetrystatsIdx = 1;
FlightTelemetryStats.timestamp = 0;
@ -449,7 +452,7 @@ function [] = OPLogConvert()
case 879185696
FirmwareIAPObj(firmwareiapobjIdx) = ReadFirmwareIAPObjObject(fid, timestamp);
firmwareiapobjIdx = firmwareiapobjIdx + 1;
case 144318184
case 126985486
FlightBatteryState(flightbatterystateIdx) = ReadFlightBatteryStateObject(fid, timestamp);
flightbatterystateIdx = flightbatterystateIdx + 1;
case 1712072286
@ -784,7 +787,10 @@ function [FlightBatteryState] = ReadFlightBatteryStateObject(fid, timestamp)
FlightBatteryState.timestamp = timestamp;
FlightBatteryState.Voltage = double(fread(fid, 1, 'float32'));
FlightBatteryState.Current = double(fread(fid, 1, 'float32'));
FlightBatteryState.ConsumedEnergy = double(fread(fid, 1, 'uint32'));
FlightBatteryState.PeakCurrent = double(fread(fid, 1, 'float32'));
FlightBatteryState.AvgCurrent = double(fread(fid, 1, 'float32'));
FlightBatteryState.ConsumedEnergy = double(fread(fid, 1, 'float32'));
FlightBatteryState.EstimatedFlightTime = double(fread(fid, 1, 'float32'));
% read CRC
fread(fid, 1, 'uint8');
end

View File

@ -34,7 +34,7 @@
#include "uavobjectfield.h"
const QString FlightBatteryState::NAME = QString("FlightBatteryState");
const QString FlightBatteryState::DESCRIPTION = QString("Battery status information. Not currently updated.");
const QString FlightBatteryState::DESCRIPTION = QString("Battery status information.");
/**
* Constructor
@ -49,9 +49,18 @@ FlightBatteryState::FlightBatteryState(): UAVDataObject(OBJID, ISSINGLEINST, ISS
QStringList CurrentElemNames;
CurrentElemNames.append("0");
fields.append( new UAVObjectField(QString("Current"), QString("A"), UAVObjectField::FLOAT32, CurrentElemNames, QStringList()) );
QStringList PeakCurrentElemNames;
PeakCurrentElemNames.append("0");
fields.append( new UAVObjectField(QString("PeakCurrent"), QString("A"), UAVObjectField::FLOAT32, PeakCurrentElemNames, QStringList()) );
QStringList AvgCurrentElemNames;
AvgCurrentElemNames.append("0");
fields.append( new UAVObjectField(QString("AvgCurrent"), QString("A"), UAVObjectField::FLOAT32, AvgCurrentElemNames, QStringList()) );
QStringList ConsumedEnergyElemNames;
ConsumedEnergyElemNames.append("0");
fields.append( new UAVObjectField(QString("ConsumedEnergy"), QString("mAh"), UAVObjectField::UINT32, ConsumedEnergyElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("ConsumedEnergy"), QString("mAh"), UAVObjectField::FLOAT32, ConsumedEnergyElemNames, QStringList()) );
QStringList EstimatedFlightTimeElemNames;
EstimatedFlightTimeElemNames.append("0");
fields.append( new UAVObjectField(QString("EstimatedFlightTime"), QString("sec"), UAVObjectField::FLOAT32, EstimatedFlightTimeElemNames, QStringList()) );
// Initialize object
initializeFields(fields, (quint8*)&data, NUMBYTES);
@ -87,6 +96,12 @@ UAVObject::Metadata FlightBatteryState::getDefaultMetadata()
*/
void FlightBatteryState::setDefaultFieldValues()
{
data.Voltage = 0;
data.Current = 0;
data.PeakCurrent = 0;
data.AvgCurrent = 0;
data.ConsumedEnergy = 0;
data.EstimatedFlightTime = 0;
}

View File

@ -45,18 +45,24 @@ public:
typedef struct {
float Voltage;
float Current;
quint32 ConsumedEnergy;
float PeakCurrent;
float AvgCurrent;
float ConsumedEnergy;
float EstimatedFlightTime;
} __attribute__((packed)) DataFields;
// Field information
// Field Voltage information
// Field Current information
// Field PeakCurrent information
// Field AvgCurrent information
// Field ConsumedEnergy information
// Field EstimatedFlightTime information
// Constants
static const quint32 OBJID = 144318184U;
static const quint32 OBJID = 126985486U;
static const QString NAME;
static const QString DESCRIPTION;
static const bool ISSINGLEINST = 1;

View File

@ -57,9 +57,39 @@ _fields = [ \
{
}
),
uavobject.UAVObjectField(
'PeakCurrent',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'AvgCurrent',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'ConsumedEnergy',
'I',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'EstimatedFlightTime',
'f',
1,
[
'0',
@ -72,7 +102,7 @@ _fields = [ \
class FlightBatteryState(uavobject.UAVObject):
## Object constants
OBJID = 144318184
OBJID = 126985486
NAME = "FlightBatteryState"
METANAME = "FlightBatteryStateMeta"
ISSINGLEINST = 1

View File

@ -1,9 +1,12 @@
<xml>
<object name="FlightBatteryState" singleinstance="true" settings="false">
<description>Battery status information. Not currently updated.</description>
<field name="Voltage" units="V" type="float" elements="1"/>
<field name="Current" units="A" type="float" elements="1"/>
<field name="ConsumedEnergy" units="mAh" type="uint32" elements="1"/>
<description>Battery status information.</description>
<field name="Voltage" units="V" type="float" elements="1" defaultvalue="0.0"/>
<field name="Current" units="A" type="float" elements="1" defaultvalue="0.0"/>
<field name="PeakCurrent" units="A" type="float" elements="1" defaultvalue="0.0"/>
<field name="AvgCurrent" units="A" type="float" elements="1" defaultvalue="0.0"/>
<field name="ConsumedEnergy" units="mAh" type="float" elements="1" defaultvalue="0.0"/>
<field name="EstimatedFlightTime" units="sec" type="float" elements="1" defaultvalue="0.0"/>
<access gcs="readonly" flight="readwrite"/>
<telemetrygcs acked="false" updatemode="manual" period="0"/>
<telemetryflight acked="false" updatemode="periodic" period="1000"/>