mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-05 21:52:10 +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:
parent
2f38fe2269
commit
76be2b991b
@ -3,7 +3,7 @@
|
|||||||
* @addtogroup UAVObjects OpenPilot UAVObjects
|
* @addtogroup UAVObjects OpenPilot UAVObjects
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup FlightBatteryState FlightBatteryState
|
* @addtogroup FlightBatteryState FlightBatteryState
|
||||||
* @brief Battery status information. Not currently updated.
|
* @brief Battery status information.
|
||||||
*
|
*
|
||||||
* Autogenerated files and functions for FlightBatteryState Object
|
* 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
|
// Initialize object fields to their default values
|
||||||
UAVObjGetInstanceData(obj, instId, &data);
|
UAVObjGetInstanceData(obj, instId, &data);
|
||||||
memset(&data, 0, sizeof(FlightBatteryStateData));
|
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);
|
UAVObjSetInstanceData(obj, instId, &data);
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* @addtogroup UAVObjects OpenPilot UAVObjects
|
* @addtogroup UAVObjects OpenPilot UAVObjects
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup FlightBatteryState FlightBatteryState
|
* @addtogroup FlightBatteryState FlightBatteryState
|
||||||
* @brief Battery status information. Not currently updated.
|
* @brief Battery status information.
|
||||||
*
|
*
|
||||||
* Autogenerated files and functions for FlightBatteryState Object
|
* Autogenerated files and functions for FlightBatteryState Object
|
||||||
|
|
||||||
@ -41,7 +41,7 @@
|
|||||||
#define FLIGHTBATTERYSTATE_H
|
#define FLIGHTBATTERYSTATE_H
|
||||||
|
|
||||||
// Object constants
|
// Object constants
|
||||||
#define FLIGHTBATTERYSTATE_OBJID 144318184U
|
#define FLIGHTBATTERYSTATE_OBJID 126985486U
|
||||||
#define FLIGHTBATTERYSTATE_NAME "FlightBatteryState"
|
#define FLIGHTBATTERYSTATE_NAME "FlightBatteryState"
|
||||||
#define FLIGHTBATTERYSTATE_METANAME "FlightBatteryStateMeta"
|
#define FLIGHTBATTERYSTATE_METANAME "FlightBatteryStateMeta"
|
||||||
#define FLIGHTBATTERYSTATE_ISSINGLEINST 1
|
#define FLIGHTBATTERYSTATE_ISSINGLEINST 1
|
||||||
@ -73,14 +73,20 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
float Voltage;
|
float Voltage;
|
||||||
float Current;
|
float Current;
|
||||||
uint32_t ConsumedEnergy;
|
float PeakCurrent;
|
||||||
|
float AvgCurrent;
|
||||||
|
float ConsumedEnergy;
|
||||||
|
float EstimatedFlightTime;
|
||||||
|
|
||||||
} __attribute__((packed)) FlightBatteryStateData;
|
} __attribute__((packed)) FlightBatteryStateData;
|
||||||
|
|
||||||
// Field information
|
// Field information
|
||||||
// Field Voltage information
|
// Field Voltage information
|
||||||
// Field Current information
|
// Field Current information
|
||||||
|
// Field PeakCurrent information
|
||||||
|
// Field AvgCurrent information
|
||||||
// Field ConsumedEnergy information
|
// Field ConsumedEnergy information
|
||||||
|
// Field EstimatedFlightTime information
|
||||||
|
|
||||||
|
|
||||||
// Generic interface functions
|
// Generic interface functions
|
||||||
|
@ -122,7 +122,10 @@ function [] = OPLogConvert()
|
|||||||
FlightBatteryState.timestamp = 0;
|
FlightBatteryState.timestamp = 0;
|
||||||
FlightBatteryState(1).Voltage = 0;
|
FlightBatteryState(1).Voltage = 0;
|
||||||
FlightBatteryState(1).Current = 0;
|
FlightBatteryState(1).Current = 0;
|
||||||
|
FlightBatteryState(1).PeakCurrent = 0;
|
||||||
|
FlightBatteryState(1).AvgCurrent = 0;
|
||||||
FlightBatteryState(1).ConsumedEnergy = 0;
|
FlightBatteryState(1).ConsumedEnergy = 0;
|
||||||
|
FlightBatteryState(1).EstimatedFlightTime = 0;
|
||||||
|
|
||||||
flighttelemetrystatsIdx = 1;
|
flighttelemetrystatsIdx = 1;
|
||||||
FlightTelemetryStats.timestamp = 0;
|
FlightTelemetryStats.timestamp = 0;
|
||||||
@ -449,7 +452,7 @@ function [] = OPLogConvert()
|
|||||||
case 879185696
|
case 879185696
|
||||||
FirmwareIAPObj(firmwareiapobjIdx) = ReadFirmwareIAPObjObject(fid, timestamp);
|
FirmwareIAPObj(firmwareiapobjIdx) = ReadFirmwareIAPObjObject(fid, timestamp);
|
||||||
firmwareiapobjIdx = firmwareiapobjIdx + 1;
|
firmwareiapobjIdx = firmwareiapobjIdx + 1;
|
||||||
case 144318184
|
case 126985486
|
||||||
FlightBatteryState(flightbatterystateIdx) = ReadFlightBatteryStateObject(fid, timestamp);
|
FlightBatteryState(flightbatterystateIdx) = ReadFlightBatteryStateObject(fid, timestamp);
|
||||||
flightbatterystateIdx = flightbatterystateIdx + 1;
|
flightbatterystateIdx = flightbatterystateIdx + 1;
|
||||||
case 1712072286
|
case 1712072286
|
||||||
@ -784,7 +787,10 @@ function [FlightBatteryState] = ReadFlightBatteryStateObject(fid, timestamp)
|
|||||||
FlightBatteryState.timestamp = timestamp;
|
FlightBatteryState.timestamp = timestamp;
|
||||||
FlightBatteryState.Voltage = double(fread(fid, 1, 'float32'));
|
FlightBatteryState.Voltage = double(fread(fid, 1, 'float32'));
|
||||||
FlightBatteryState.Current = 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
|
% read CRC
|
||||||
fread(fid, 1, 'uint8');
|
fread(fid, 1, 'uint8');
|
||||||
end
|
end
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include "uavobjectfield.h"
|
#include "uavobjectfield.h"
|
||||||
|
|
||||||
const QString FlightBatteryState::NAME = QString("FlightBatteryState");
|
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
|
* Constructor
|
||||||
@ -49,9 +49,18 @@ FlightBatteryState::FlightBatteryState(): UAVDataObject(OBJID, ISSINGLEINST, ISS
|
|||||||
QStringList CurrentElemNames;
|
QStringList CurrentElemNames;
|
||||||
CurrentElemNames.append("0");
|
CurrentElemNames.append("0");
|
||||||
fields.append( new UAVObjectField(QString("Current"), QString("A"), UAVObjectField::FLOAT32, CurrentElemNames, QStringList()) );
|
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;
|
QStringList ConsumedEnergyElemNames;
|
||||||
ConsumedEnergyElemNames.append("0");
|
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
|
// Initialize object
|
||||||
initializeFields(fields, (quint8*)&data, NUMBYTES);
|
initializeFields(fields, (quint8*)&data, NUMBYTES);
|
||||||
@ -87,6 +96,12 @@ UAVObject::Metadata FlightBatteryState::getDefaultMetadata()
|
|||||||
*/
|
*/
|
||||||
void FlightBatteryState::setDefaultFieldValues()
|
void FlightBatteryState::setDefaultFieldValues()
|
||||||
{
|
{
|
||||||
|
data.Voltage = 0;
|
||||||
|
data.Current = 0;
|
||||||
|
data.PeakCurrent = 0;
|
||||||
|
data.AvgCurrent = 0;
|
||||||
|
data.ConsumedEnergy = 0;
|
||||||
|
data.EstimatedFlightTime = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,18 +45,24 @@ public:
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
float Voltage;
|
float Voltage;
|
||||||
float Current;
|
float Current;
|
||||||
quint32 ConsumedEnergy;
|
float PeakCurrent;
|
||||||
|
float AvgCurrent;
|
||||||
|
float ConsumedEnergy;
|
||||||
|
float EstimatedFlightTime;
|
||||||
|
|
||||||
} __attribute__((packed)) DataFields;
|
} __attribute__((packed)) DataFields;
|
||||||
|
|
||||||
// Field information
|
// Field information
|
||||||
// Field Voltage information
|
// Field Voltage information
|
||||||
// Field Current information
|
// Field Current information
|
||||||
|
// Field PeakCurrent information
|
||||||
|
// Field AvgCurrent information
|
||||||
// Field ConsumedEnergy information
|
// Field ConsumedEnergy information
|
||||||
|
// Field EstimatedFlightTime information
|
||||||
|
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
static const quint32 OBJID = 144318184U;
|
static const quint32 OBJID = 126985486U;
|
||||||
static const QString NAME;
|
static const QString NAME;
|
||||||
static const QString DESCRIPTION;
|
static const QString DESCRIPTION;
|
||||||
static const bool ISSINGLEINST = 1;
|
static const bool ISSINGLEINST = 1;
|
||||||
|
@ -57,9 +57,39 @@ _fields = [ \
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
uavobject.UAVObjectField(
|
||||||
|
'PeakCurrent',
|
||||||
|
'f',
|
||||||
|
1,
|
||||||
|
[
|
||||||
|
'0',
|
||||||
|
],
|
||||||
|
{
|
||||||
|
}
|
||||||
|
),
|
||||||
|
uavobject.UAVObjectField(
|
||||||
|
'AvgCurrent',
|
||||||
|
'f',
|
||||||
|
1,
|
||||||
|
[
|
||||||
|
'0',
|
||||||
|
],
|
||||||
|
{
|
||||||
|
}
|
||||||
|
),
|
||||||
uavobject.UAVObjectField(
|
uavobject.UAVObjectField(
|
||||||
'ConsumedEnergy',
|
'ConsumedEnergy',
|
||||||
'I',
|
'f',
|
||||||
|
1,
|
||||||
|
[
|
||||||
|
'0',
|
||||||
|
],
|
||||||
|
{
|
||||||
|
}
|
||||||
|
),
|
||||||
|
uavobject.UAVObjectField(
|
||||||
|
'EstimatedFlightTime',
|
||||||
|
'f',
|
||||||
1,
|
1,
|
||||||
[
|
[
|
||||||
'0',
|
'0',
|
||||||
@ -72,7 +102,7 @@ _fields = [ \
|
|||||||
|
|
||||||
class FlightBatteryState(uavobject.UAVObject):
|
class FlightBatteryState(uavobject.UAVObject):
|
||||||
## Object constants
|
## Object constants
|
||||||
OBJID = 144318184
|
OBJID = 126985486
|
||||||
NAME = "FlightBatteryState"
|
NAME = "FlightBatteryState"
|
||||||
METANAME = "FlightBatteryStateMeta"
|
METANAME = "FlightBatteryStateMeta"
|
||||||
ISSINGLEINST = 1
|
ISSINGLEINST = 1
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<xml>
|
<xml>
|
||||||
<object name="FlightBatteryState" singleinstance="true" settings="false">
|
<object name="FlightBatteryState" singleinstance="true" settings="false">
|
||||||
<description>Battery status information. Not currently updated.</description>
|
<description>Battery status information.</description>
|
||||||
<field name="Voltage" units="V" type="float" elements="1"/>
|
<field name="Voltage" units="V" type="float" elements="1" defaultvalue="0.0"/>
|
||||||
<field name="Current" units="A" type="float" elements="1"/>
|
<field name="Current" units="A" type="float" elements="1" defaultvalue="0.0"/>
|
||||||
<field name="ConsumedEnergy" units="mAh" type="uint32" elements="1"/>
|
<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"/>
|
<access gcs="readonly" flight="readwrite"/>
|
||||||
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
||||||
<telemetryflight acked="false" updatemode="periodic" period="1000"/>
|
<telemetryflight acked="false" updatemode="periodic" period="1000"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user