This commit is contained in:
parent
fab259a2b5
commit
d5a09dc280
@ -1,7 +1,7 @@
|
||||
#include "BpxBatteryHandler.h"
|
||||
|
||||
BpxBatteryHandler::BpxBatteryHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie)
|
||||
: DeviceHandlerBase(objectId, comIF, comCookie) {}
|
||||
: DeviceHandlerBase(objectId, comIF, comCookie), hkSet(this), cfgSet(this) {}
|
||||
|
||||
BpxBatteryHandler::~BpxBatteryHandler() {}
|
||||
|
||||
@ -17,7 +17,14 @@ ReturnValue_t BpxBatteryHandler::buildTransitionDeviceCommand(DeviceCommandId_t*
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void BpxBatteryHandler::fillCommandAndReplyMap() {}
|
||||
void BpxBatteryHandler::fillCommandAndReplyMap() {
|
||||
insertInCommandAndReplyMap(BpxBattery::READ_HK, 1, &hkSet);
|
||||
insertInCommandAndReplyMap(BpxBattery::PING, 1);
|
||||
insertInCommandAndReplyMap(BpxBattery::REBOOT, 1);
|
||||
insertInCommandAndReplyMap(BpxBattery::RESET_COUNTERS, 1);
|
||||
insertInCommandAndReplyMap(BpxBattery::RESTORE_DEFAULT_CONFIG, 1);
|
||||
insertInCommandAndReplyMap(BpxBattery::READ_CONFIG, 1);
|
||||
}
|
||||
|
||||
ReturnValue_t BpxBatteryHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||
const uint8_t* commandData,
|
||||
|
@ -11,6 +11,9 @@ class BpxBatteryHandler : public DeviceHandlerBase {
|
||||
virtual ~BpxBatteryHandler();
|
||||
|
||||
protected:
|
||||
BpxBatteryHk hkSet;
|
||||
BpxBatteryCfg cfgSet;
|
||||
|
||||
void doStartUp() override;
|
||||
void doShutDown() override;
|
||||
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
namespace BpxBattery {
|
||||
|
||||
enum BpxPoolIds {
|
||||
enum HkPoolIds {
|
||||
CHARGE_CURRENT = 0,
|
||||
DISCHARGE_CURRENT = 1,
|
||||
HEATER_CURRENT = 2,
|
||||
@ -21,7 +21,21 @@ enum BpxPoolIds {
|
||||
BOOTCAUSE = 9
|
||||
};
|
||||
|
||||
enum CfgPoolIds { BATTERY_HEATER_MODE = 0, BATTHEAT_LOW_LIMIT = 1, BATTHEAT_HIGH_LIMIT = 2 };
|
||||
|
||||
static constexpr DeviceCommandId_t READ_HK = 0;
|
||||
static constexpr DeviceCommandId_t PING = 1;
|
||||
static constexpr DeviceCommandId_t REBOOT = 2;
|
||||
static constexpr DeviceCommandId_t RESET_COUNTERS = 3;
|
||||
static constexpr DeviceCommandId_t RESTORE_DEFAULT_CONFIG = 4;
|
||||
static constexpr DeviceCommandId_t READ_CONFIG = 5;
|
||||
static constexpr DeviceCommandId_t WRITE_CONFIG = 6;
|
||||
|
||||
static constexpr DeviceCommandId_t MANUAL_HEATER_ON = 10;
|
||||
static constexpr DeviceCommandId_t MANUAL_HEATER_OFF = 11;
|
||||
|
||||
static constexpr uint32_t HK_SET_ID = 0;
|
||||
static constexpr uint32_t CFG_SET_ID = 1;
|
||||
|
||||
static constexpr uint8_t PORT_PING = 1;
|
||||
static constexpr uint8_t PORT_REBOOT = 4;
|
||||
@ -34,7 +48,7 @@ static constexpr uint8_t PORT_MAN_HEAT_ON = 20;
|
||||
static constexpr uint8_t PORT_MAN_HEAT_OFF = 21;
|
||||
|
||||
static constexpr uint8_t HK_ENTRIES = 10;
|
||||
|
||||
static constexpr uint8_t CFG_ENTRIES = 3;
|
||||
|
||||
// Taken from BPX manual 3.14
|
||||
typedef struct __attribute__((packed)) {
|
||||
@ -46,7 +60,6 @@ typedef struct __attribute__((packed)) {
|
||||
//! Turn heater off at [degC]
|
||||
} bpx_config_t;
|
||||
|
||||
|
||||
//! Not used for more but might still be useful
|
||||
class BpxHkDeserializer : public SerialLinkedListAdapter<SerializeIF> {
|
||||
public:
|
||||
@ -88,11 +101,12 @@ class BpxHkDeserializer : public SerialLinkedListAdapter<SerializeIF> {
|
||||
}
|
||||
};
|
||||
|
||||
}; // namespace BpxBattery
|
||||
|
||||
/**
|
||||
* @brief BPX HK data holder
|
||||
*/
|
||||
class BpxBatteryHk : public StaticLocalDataSet<HK_ENTRIES> {
|
||||
class BpxBatteryHk : public StaticLocalDataSet<BpxBattery::HK_ENTRIES> {
|
||||
public:
|
||||
/**
|
||||
* Constructor for data users
|
||||
@ -148,38 +162,36 @@ class BpxBatteryHk : public StaticLocalDataSet<HK_ENTRIES> {
|
||||
return result;
|
||||
}
|
||||
|
||||
BpxBatteryHk();
|
||||
|
||||
private:
|
||||
//! Charge current in mA
|
||||
lp_var_t<uint16_t> chargeCurrent =
|
||||
lp_var_t<uint16_t>(sid.objectId, BpxBattery::BpxPoolIds::CHARGE_CURRENT, this);
|
||||
lp_var_t<uint16_t>(sid.objectId, BpxBattery::HkPoolIds::CHARGE_CURRENT, this);
|
||||
//! Discharge current in mA
|
||||
lp_var_t<uint16_t> dischargeCurrent =
|
||||
lp_var_t<uint16_t>(sid.objectId, BpxBattery::BpxPoolIds::DISCHARGE_CURRENT, this);
|
||||
lp_var_t<uint16_t>(sid.objectId, BpxBattery::HkPoolIds::DISCHARGE_CURRENT, this);
|
||||
//! Heater current in mA
|
||||
lp_var_t<uint16_t> heaterCurrent =
|
||||
lp_var_t<uint16_t>(sid.objectId, BpxBattery::BpxPoolIds::HEATER_CURRENT, this);
|
||||
lp_var_t<uint16_t>(sid.objectId, BpxBattery::HkPoolIds::HEATER_CURRENT, this);
|
||||
|
||||
//! Battery voltage in mV
|
||||
lp_var_t<uint16_t> battVoltage =
|
||||
lp_var_t<uint16_t>(sid.objectId, BpxBattery::BpxPoolIds::BATT_VOLTAGE, this);
|
||||
lp_var_t<uint16_t>(sid.objectId, BpxBattery::HkPoolIds::BATT_VOLTAGE, this);
|
||||
//! Battery temperature 1 in degC
|
||||
SerializeElement<int16_t> battTemp1 =
|
||||
lp_var_t<int16_t>(sid.objectId, BpxBattery::BpxPoolIds::BATT_TEMP_1, this);
|
||||
lp_var_t<int16_t>(sid.objectId, BpxBattery::HkPoolIds::BATT_TEMP_1, this);
|
||||
//! Battery temperature 2 in degC
|
||||
SerializeElement<int16_t> battTemp2 =
|
||||
lp_var_t<int16_t>(sid.objectId, BpxBattery::BpxPoolIds::BATT_TEMP_2, this);
|
||||
lp_var_t<int16_t>(sid.objectId, BpxBattery::HkPoolIds::BATT_TEMP_2, this);
|
||||
//! Battery temperature 3 in degC
|
||||
SerializeElement<int16_t> battTemp3 =
|
||||
lp_var_t<int16_t>(sid.objectId, BpxBattery::BpxPoolIds::BATT_TEMP_3, this);
|
||||
lp_var_t<int16_t>(sid.objectId, BpxBattery::HkPoolIds::BATT_TEMP_3, this);
|
||||
//! Battery temperature 4 in degC
|
||||
SerializeElement<int16_t> battTemp4 =
|
||||
lp_var_t<int16_t>(sid.objectId, BpxBattery::BpxPoolIds::BATT_TEMP_4, this);
|
||||
lp_var_t<int16_t>(sid.objectId, BpxBattery::HkPoolIds::BATT_TEMP_4, this);
|
||||
SerializeElement<uint32_t> rebootCounter =
|
||||
lp_var_t<uint32_t>(sid.objectId, BpxBattery::BpxPoolIds::REBOOT_COUNTER, this);
|
||||
lp_var_t<uint32_t>(sid.objectId, BpxBattery::HkPoolIds::REBOOT_COUNTER, this);
|
||||
SerializeElement<uint8_t> bootcause =
|
||||
lp_var_t<uint8_t>(sid.objectId, BpxBattery::BpxPoolIds::BOOTCAUSE, this);
|
||||
lp_var_t<uint8_t>(sid.objectId, BpxBattery::HkPoolIds::BOOTCAUSE, this);
|
||||
|
||||
friend class BpxBatteryHandler;
|
||||
/**
|
||||
@ -189,6 +201,44 @@ class BpxBatteryHk : public StaticLocalDataSet<HK_ENTRIES> {
|
||||
BpxBatteryHk(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, BpxBattery::HK_SET_ID) {}
|
||||
};
|
||||
|
||||
class BpxBatteryCfg : public StaticLocalDataSet<BpxBattery::CFG_ENTRIES> {
|
||||
public:
|
||||
/**
|
||||
* Constructor for data users
|
||||
* @param gyroId
|
||||
*/
|
||||
BpxBatteryCfg(object_id_t bpxId) : StaticLocalDataSet(sid_t(bpxId, BpxBattery::CFG_SET_ID)) {
|
||||
setAllVariablesReadOnly();
|
||||
}
|
||||
|
||||
ReturnValue_t parseRawHk(const uint8_t* data, size_t size) {
|
||||
if (size < 3) {
|
||||
return SerializeIF::STREAM_TOO_SHORT;
|
||||
}
|
||||
battheatermode.value = data[0];
|
||||
battheaterLow.value = data[1];
|
||||
battheaterHigh.value = data[2];
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
//! Mode for battheater [0=OFF,1=Auto]
|
||||
lp_var_t<uint8_t> battheatermode =
|
||||
lp_var_t<uint8_t>(sid.objectId, BpxBattery::CfgPoolIds::BATTERY_HEATER_MODE, this);
|
||||
//! Turn heater on at [degC]
|
||||
lp_var_t<int8_t> battheaterLow =
|
||||
lp_var_t<int8_t>(sid.objectId, BpxBattery::CfgPoolIds::BATTHEAT_LOW_LIMIT, this);
|
||||
//! Turn heater off at [degC]
|
||||
lp_var_t<int8_t> battheaterHigh =
|
||||
lp_var_t<int8_t>(sid.objectId, BpxBattery::CfgPoolIds::BATTHEAT_HIGH_LIMIT, this);
|
||||
|
||||
private:
|
||||
friend class BpxBatteryHandler;
|
||||
/**
|
||||
* Constructor for data creator
|
||||
* @param hkOwner
|
||||
*/
|
||||
BpxBatteryCfg(HasLocalDataPoolIF* hkOwner)
|
||||
: StaticLocalDataSet(hkOwner, BpxBattery::CFG_SET_ID) {}
|
||||
};
|
||||
|
||||
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user