eive-obsw/mission/power/gsDefs.h
Robin Mueller c5b2b5c56c
All checks were successful
EIVE/eive-obsw/pipeline/pr-v4.0.0-dev This commit looks good
Merge remote-tracking branch 'origin/v4.0.0-dev' into p60dock-hk-improvements
2023-06-11 21:49:45 +02:00

756 lines
28 KiB
C++

#ifndef MISSION_POWER_GSDEFS_H_
#define MISSION_POWER_GSDEFS_H_
#include <fsfw/datapoollocal/LocalPoolVariable.h>
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <fsfw/power/definitions.h>
#include <mission/power/gsLibDefs.h>
#include <cstdint>
#include "devices/powerSwitcherList.h"
#include "fsfw/platform.h"
#include "mission/power/defs.h"
namespace GOMSPACE {
struct TableInfo {
uint8_t sourceTable;
uint8_t targetTable;
};
enum DeviceType { PDU, ACU, P60DOCK };
enum class SpecialRequestTypes {
DEFAULT_COM_IF,
GET_PDU_HK,
GET_PDU_CONFIG,
GET_ACU_HK,
GET_ACU_CONFIG,
GET_P60DOCK_HK,
GET_P60DOCK_CONFIG,
SAVE_TABLE,
LOAD_TABLE
};
enum CspPorts : uint8_t {
CSP_PING = 1,
CSP_REBOOT = 4,
P60_PORT_RPARAM_ENUM = 7,
P60_PORT_GNDWDT_RESET_ENUM = 9
};
enum class Pdu { PDU1, PDU2 };
using ChannelSwitchHook = void (*)(Pdu pdu, uint8_t channel, bool on, void* args);
static const uint16_t IGNORE_CHECKSUM = 0xbb0;
/** The size of the header of a gomspace CSP packet. */
static const uint8_t GS_HDR_LENGTH = 12;
/** CSP port to ping gomspace devices. */
static const uint8_t PING_PORT = 1;
static const uint8_t REBOOT_PORT = 4;
/** CSP port of gomspace devices to request or set parameters */
static const uint8_t PARAM_PORT = 7;
static const uint8_t P60_PORT_GNDWDT_RESET = 9;
/**
* Device commands are derived from the rparam.h of the gomspace lib..
* IDs above 50 are reserved for device specific commands.
*/
static const DeviceCommandId_t PARAM_GET = 0; //!< [EXPORT] : [COMMAND]
static const DeviceCommandId_t PING = 1; //!< [EXPORT] : [COMMAND]
static const DeviceCommandId_t NONE = 2; // Set when no command is pending
static const DeviceCommandId_t REBOOT = 4; //!< [EXPORT] : [COMMAND]
static const DeviceCommandId_t GNDWDT_RESET = 9; //!< [EXPORT] : [COMMAND]
static const DeviceCommandId_t REQUEST_HK_TABLE = 16; //!< [EXPORT] : [COMMAND]
static const DeviceCommandId_t REQUEST_CONFIG_TABLE = 17; //!< [EXPORT] : [COMMAND]
static const DeviceCommandId_t SAVE_TABLE_FILE = 18;
static const DeviceCommandId_t SAVE_TABLE_DEFAULT = 19;
static const DeviceCommandId_t LOAD_TABLE = 20;
static const DeviceCommandId_t PARAM_SET = 255; //!< [EXPORT] : [COMMAND]
// Not implemented yet
// static const DeviceCommandId_t REQUEST_CALIB_TABLE = 18; //!< [EXPORT] : [COMMAND]
//! [EXPORT] : [COMMAND] Print switch states, voltages and currents to the console
//! For the ACU device, only print voltages and currents of the 6 ACU channels
static const DeviceCommandId_t PRINT_SWITCH_V_I = 32;
static const DeviceCommandId_t PRINT_LATCHUPS = 33;
enum ParamRequestIds : uint8_t {
GET = 0x00,
REPLY = 0x55,
SET = 0xFF,
TABLE_SPEC = 0x44,
// Copy memory slot to memory slot
COPY = 0x77,
// Load from file to slot. Load from primary slot
LOAD = 0x88,
// Load by name(s)
LOAD_FROM_STORE = 0x89,
// Save to primary slot
SAVE = 0x99,
// Save by name(s)
SAVE_TO_STORE = 0x9a
};
enum TableIds : uint8_t { BOARD_PARAMS = 0, CONFIG = 1, CALIBRATION = 2, HK = 4 };
} // namespace GOMSPACE
namespace P60System {
enum class BatteryModes : uint8_t { CRITICAL = 1, SAFE = 2, NORMAL = 3, FULL = 4 };
enum class SetIds : uint32_t { CORE = 1, AUX = 2, CONFIG = 3 };
} // namespace P60System
namespace P60Dock {
static const uint16_t CONFIG_ADDRESS_OUT_EN_3V3_STACK = 0x71;
static const uint16_t CONFIG_ADDRESS_OUT_EN_5V_STACK = 0x72;
namespace pool {
enum Ids : lp_id_t {
P60_CURRENTS,
P60_VOLTAGES,
P60_OUTPUT_ENABLE,
P60DOCK_TEMPERATURE_1,
P60DOCK_TEMPERATURE_2,
P60DOCK_BOOT_CAUSE,
P60DOCK_BOOT_CNT,
P60DOCK_UPTIME,
P60DOCK_RESETCAUSE,
P60DOCK_BATT_MODE,
P60DOCK_HEATER_ON,
P60DOCK_CONV_5V_ENABLE_STATUS,
LATCHUPS,
P60DOCK_DOCK_VBAT,
P60DOCK_DOCK_VCC_CURRENT,
// Difference between charge and discharge
P60DOCK_BATTERY_CURRENT,
P60DOCK_BATTERY_VOLTAGE,
P60DOCK_BATTERY_TEMPERATURE_1,
P60DOCK_BATTERY_TEMPERATURE_2,
DEVICES_TYPE,
DEVICES_STATUS,
P60DOCK_DEVICE_TYPE_GROUP,
P60DOCK_DEVICE_STATUS_GROUP,
P60DOCK_DEARM_STATUS,
P60DOCK_WDT_CNT_GND,
P60DOCK_WDT_CNT_I2C,
P60DOCK_WDT_CNT_CAN,
P60DOCK_WDT_CNT_CSP_1,
P60DOCK_WDT_CNT_CSP_2,
P60DOCK_WDT_GND_LEFT,
P60DOCK_WDT_I2C_LEFT,
P60DOCK_WDT_CAN_LEFT,
P60DOCK_WDT_CSP_LEFT_1,
P60DOCK_WDT_CSP_LEFT_2,
P60DOCK_BATT_CHARGE_CURRENT,
P60DOCK_BATT_DISCHARGE_CURRENT,
P60DOCK_ANT6_DEPL,
P60DOCK_AR6_DEPL,
};
}
static constexpr uint8_t NUM_DEVS = 8;
namespace hk {
enum Index : uint8_t {
ACU_VCC = 0,
PDU1_VCC = 1,
X3_IDLE_VCC = 2,
PDU2_VCC = 3,
ACU_VBAT = 4,
PDU1_VBAT = 5,
X3_IDLE_VBAT = 6,
PDU2_VBAT = 7,
STACK_VBAT = 8,
STACK_3V3 = 9,
STACK_5V = 10,
GS3V3 = 11,
GS5V = 12,
CHNLS_LEN = 13
};
}
enum SwitchChannels : uint8_t {
ACU = 0,
PDU1 = 1,
X3_IDLE = 2,
PDU2_VCC = 3,
ACU_VBAT = 4,
PDU1_VBAT = 5,
X3_IDLE_VBAT = 6,
PDU2_VBAT = 7,
STACK_VBAT = 8,
STACK_3V3 = 9,
STACK_5V = 10,
GS3V3 = 11,
GS5V = 12
};
static const uint16_t MAX_CONFIGTABLE_ADDRESS = 408;
static const uint16_t MAX_HKTABLE_ADDRESS = 187;
// Sources:
// GomSpace library lib/p60-dock_client/include/gs/p60-dock/param
static const uint16_t HK_TABLE_SIZE = gsConstants::P60DOCK_HK_SIZE;
static const uint16_t CONFIG_TABLE_SIZE = gsConstants::P60DOCK_PARAM_SIZE;
static const size_t MAX_REPLY_SIZE = CONFIG_TABLE_SIZE;
static const uint16_t CAL_TABLE = 0xAE;
static const uint8_t HK_TABLE_ENTRIES = 100;
class CoreHkSet : public StaticLocalDataSet<16> {
public:
CoreHkSet(HasLocalDataPoolIF* owner)
: StaticLocalDataSet(owner, static_cast<uint32_t>(::P60System::SetIds::CORE)) {}
CoreHkSet(object_id_t objectId)
: StaticLocalDataSet(sid_t(objectId, static_cast<uint32_t>(::P60System::SetIds::CORE))) {}
/** Measured output currents */
lp_vec_t<int16_t, P60Dock::hk::Index::CHNLS_LEN> currents =
lp_vec_t<int16_t, P60Dock::hk::Index::CHNLS_LEN>(sid.objectId, pool::P60_CURRENTS, this);
/** Measured output voltages */
lp_vec_t<uint16_t, P60Dock::hk::Index::CHNLS_LEN> voltages =
lp_vec_t<uint16_t, P60Dock::hk::Index::CHNLS_LEN>(sid.objectId, pool::P60_VOLTAGES, this);
/** Output enable states */
lp_vec_t<uint8_t, P60Dock::hk::Index::CHNLS_LEN> outputEnables =
lp_vec_t<uint8_t, P60Dock::hk::Index::CHNLS_LEN>(sid.objectId, pool::P60_OUTPUT_ENABLE, this);
lp_var_t<uint32_t> bootCount = lp_var_t<uint32_t>(sid.objectId, pool::P60DOCK_BOOT_CNT, this);
lp_var_t<uint8_t> battMode = lp_var_t<uint8_t>(sid.objectId, pool::P60DOCK_BATT_MODE, this);
// Difference between charge and discharge current
lp_var_t<int16_t> batteryCurrent =
lp_var_t<int16_t>(sid.objectId, pool::P60DOCK_BATTERY_CURRENT, this);
lp_var_t<uint16_t> batteryVoltage =
lp_var_t<uint16_t>(sid.objectId, pool::P60DOCK_BATTERY_VOLTAGE, this);
lp_var_t<float> temperature1 = lp_var_t<float>(sid.objectId, pool::P60DOCK_TEMPERATURE_1, this);
lp_var_t<float> temperature2 = lp_var_t<float>(sid.objectId, pool::P60DOCK_TEMPERATURE_2, this);
};
/**
* @brief This class defines a dataset for the hk table of the P60 Dock.
* @details
* The GS port and X3 are not required for EIVE. X3 is another slot on the P60 dock and
* GS is required for a module from Gomspace which is not used.
*/
class HkTableDataset : public StaticLocalDataSet<32> {
public:
HkTableDataset(HasLocalDataPoolIF* owner)
: StaticLocalDataSet(owner, static_cast<uint32_t>(::P60System::SetIds::AUX)) {}
HkTableDataset(object_id_t objectId)
: StaticLocalDataSet(sid_t(objectId, static_cast<uint32_t>(::P60System::SetIds::AUX))) {}
/** Number of detected latchups on each output channel */
lp_vec_t<uint16_t, P60Dock::hk::Index::CHNLS_LEN> latchups =
lp_vec_t<uint16_t, P60Dock::hk::Index::CHNLS_LEN>(sid.objectId, pool::LATCHUPS, this);
lp_var_t<uint32_t> bootcause = lp_var_t<uint32_t>(sid.objectId, pool::P60DOCK_BOOT_CAUSE, this);
lp_var_t<uint32_t> uptime = lp_var_t<uint32_t>(sid.objectId, pool::P60DOCK_UPTIME, this);
lp_var_t<uint16_t> resetcause = lp_var_t<uint16_t>(sid.objectId, pool::P60DOCK_RESETCAUSE, this);
/** Battery heater control only possible on BP4 packs */
lp_var_t<uint8_t> heaterForBp4PackOn =
lp_var_t<uint8_t>(sid.objectId, pool::P60DOCK_HEATER_ON, this);
lp_var_t<uint8_t> converter5VStatus =
lp_var_t<uint8_t>(sid.objectId, pool::P60DOCK_CONV_5V_ENABLE_STATUS, this);
lp_var_t<uint16_t> dockVbatVoltageValue =
lp_var_t<uint16_t>(sid.objectId, pool::P60DOCK_DOCK_VBAT, this);
lp_var_t<int16_t> dockVccCurrent =
lp_var_t<int16_t>(sid.objectId, pool::P60DOCK_DOCK_VCC_CURRENT, this);
lp_var_t<int16_t> batteryTemperature1 =
lp_var_t<int16_t>(sid.objectId, pool::P60DOCK_BATTERY_TEMPERATURE_1, this);
lp_var_t<int16_t> batteryTemperature2 =
lp_var_t<int16_t>(sid.objectId, pool::P60DOCK_BATTERY_TEMPERATURE_2, this);
lp_var_t<uint8_t> dearmStatus = lp_var_t<uint8_t>(sid.objectId, pool::P60DOCK_DEARM_STATUS, this);
/** Number of reboots due to gnd, i2c, csp watchdog timeout */
lp_var_t<uint32_t> wdtCntGnd = lp_var_t<uint32_t>(sid.objectId, pool::P60DOCK_WDT_CNT_GND, this);
lp_var_t<uint32_t> wdtCntI2c = lp_var_t<uint32_t>(sid.objectId, pool::P60DOCK_WDT_CNT_I2C, this);
lp_var_t<uint32_t> wdtCntCan = lp_var_t<uint32_t>(sid.objectId, pool::P60DOCK_WDT_CNT_CAN, this);
lp_var_t<uint32_t> wdtCntCsp1 =
lp_var_t<uint32_t>(sid.objectId, pool::P60DOCK_WDT_CNT_CSP_1, this);
lp_var_t<uint32_t> wdtCntCsp2 =
lp_var_t<uint32_t>(sid.objectId, pool::P60DOCK_WDT_CNT_CSP_2, this);
lp_var_t<uint32_t> wdtGndLeft =
lp_var_t<uint32_t>(sid.objectId, pool::P60DOCK_WDT_GND_LEFT, this);
lp_var_t<uint32_t> wdtI2cLeft =
lp_var_t<uint32_t>(sid.objectId, pool::P60DOCK_WDT_I2C_LEFT, this);
lp_var_t<uint32_t> wdtCanLeft =
lp_var_t<uint32_t>(sid.objectId, pool::P60DOCK_WDT_CAN_LEFT, this);
lp_var_t<uint8_t> wdtCspLeft1 =
lp_var_t<uint8_t>(sid.objectId, pool::P60DOCK_WDT_CSP_LEFT_1, this);
lp_var_t<uint8_t> wdtCspLeft2 =
lp_var_t<uint8_t>(sid.objectId, pool::P60DOCK_WDT_CSP_LEFT_2, this);
lp_var_t<int16_t> batteryChargeCurrent =
lp_var_t<int16_t>(sid.objectId, pool::P60DOCK_BATT_CHARGE_CURRENT, this);
lp_var_t<int16_t> batteryDischargeCurrent =
lp_var_t<int16_t>(sid.objectId, pool::P60DOCK_BATT_DISCHARGE_CURRENT, this);
lp_var_t<int8_t> ant6Depl = lp_var_t<int8_t>(sid.objectId, pool::P60DOCK_ANT6_DEPL, this);
lp_var_t<int8_t> ar6Depl = lp_var_t<int8_t>(sid.objectId, pool::P60DOCK_AR6_DEPL, this);
lp_vec_t<uint8_t, P60Dock::NUM_DEVS> devicesType =
lp_vec_t<uint8_t, P60Dock::NUM_DEVS>(sid.objectId, pool::DEVICES_TYPE, this);
lp_vec_t<uint8_t, P60Dock::NUM_DEVS> devicesStatus =
lp_vec_t<uint8_t, P60Dock::NUM_DEVS>(sid.objectId, pool::DEVICES_STATUS, this);
};
} // namespace P60Dock
/**
* @brief Constants common for both PDU1 and PDU2.
*/
namespace PDU {
namespace pool {
enum Ids {
// IDs for both PDUs
PDU_CURRENTS,
PDU_VOLTAGES,
PDU_VCC,
PDU_VBAT,
PDU_TEMPERATURE,
PDU_CONV_EN,
PDU_OUT_ENABLE,
PDU_BOOTCAUSE,
PDU_BOOTCNT,
PDU_UPTIME,
PDU_RESETCAUSE,
PDU_BATT_MODE,
PDU_LATCHUPS,
PDU_DEVICES,
PDU_STATUSES,
PDU_WDT_CNT_GND,
PDU_WDT_CNT_I2C,
PDU_WDT_CNT_CAN,
PDU_WDT_CNT_CSP1,
PDU_WDT_CNT_CSP2,
PDU_WDT_GND_LEFT,
PDU_WDT_I2C_LEFT,
PDU_WDT_CAN_LEFT,
PDU_WDT_CSP_LEFT1,
PDU_WDT_CSP_LEFT2,
OUT_ON_CNT,
OUT_OFF_CNT,
INIT_OUT_NORM,
INIT_OUT_SAFE,
INIT_ON_DLY,
INIT_OFF_DLY,
SAFE_OFF_DLY,
CUR_LU_LIM,
CUR_LIM,
CUR_EMA,
OUT_LINK,
OUT_CONV,
OUT_VOLTAGE,
CONV_EN,
CUR_EMA_GAIN,
BATT_HWMAX,
BATT_MAX,
BATT_NORM,
BATT_SAFE,
BATT_CRIT,
WDT_I2C_RST,
WDT_CAN_RST,
WDT_I2C,
WDT_CAN,
WDT_CSP,
WDT_CSP_PING,
WDT_CSP_CHAN,
WDT_CSP_ADDR
};
}
static const uint16_t MAX_CONFIGTABLE_ADDRESS = 316;
static const uint16_t MAX_HKTABLE_ADDRESS = 141;
/** The size of the csp reply containing the housekeeping table data */
static const uint16_t HK_TABLE_SIZE = gsConstants::P60PDU_HK_SIZE;
static const uint16_t CONFIG_TABLE_SIZE = gsConstants::P60PDU_PARAM_SIZE;
/** When retrieving full configuration parameter table */
static const uint16_t MAX_REPLY_SIZE = CONFIG_TABLE_SIZE;
static const uint8_t HK_TABLE_ENTRIES = 73;
static constexpr uint8_t CHANNELS_LEN = 9;
static constexpr uint8_t DEVICES_NUM = 8;
class PduCoreHk : public StaticLocalDataSet<9> {
public:
PduCoreHk(HasLocalDataPoolIF* owner, uint32_t setId) : StaticLocalDataSet(owner, setId) {}
PduCoreHk(object_id_t objectId, uint32_t setId) : StaticLocalDataSet(sid_t(objectId, setId)) {}
/** Measured output currents */
lp_vec_t<int16_t, 9> currents = lp_vec_t<int16_t, 9>(sid.objectId, pool::PDU_CURRENTS, this);
/** Measured output currents */
lp_vec_t<int16_t, 9> voltages = lp_vec_t<int16_t, 9>(sid.objectId, pool::PDU_VOLTAGES, this);
/** Output switch states */
lp_vec_t<uint8_t, 9> outputEnables =
lp_vec_t<uint8_t, 9>(sid.objectId, pool::PDU_OUT_ENABLE, this);
/** Number of reboots */
lp_var_t<uint32_t> bootcount = lp_var_t<uint32_t>(sid.objectId, pool::PDU_BOOTCNT, this);
/** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */
lp_var_t<uint8_t> battMode = lp_var_t<uint8_t>(sid.objectId, pool::PDU_BATT_MODE, this);
lp_var_t<float> temperature = lp_var_t<float>(sid.objectId, pool::PDU_TEMPERATURE, this);
/** Measured VCC */
lp_var_t<int16_t> vcc = lp_var_t<int16_t>(sid.objectId, pool::PDU_VCC, this);
/** Measured VBAT */
lp_var_t<int16_t> vbat = lp_var_t<int16_t>(sid.objectId, pool::PDU_VBAT, this);
};
class PduConfig : public StaticLocalDataSet<32> {
public:
PduConfig(HasLocalDataPoolIF* owner, uint32_t setId) : StaticLocalDataSet(owner, setId) {}
lp_vec_t<uint16_t, 9> outOnDelaySecs =
lp_vec_t<uint16_t, 9>(sid.objectId, pool::OUT_ON_CNT, this);
lp_vec_t<uint16_t, 9> outOffDelaySecs =
lp_vec_t<uint16_t, 9>(sid.objectId, pool::OUT_OFF_CNT, this);
lp_vec_t<uint8_t, 9> initOutNorm = lp_vec_t<uint8_t, 9>(sid.objectId, pool::INIT_OUT_NORM, this);
lp_vec_t<uint8_t, 9> initOutSafe = lp_vec_t<uint8_t, 9>(sid.objectId, pool::INIT_OUT_SAFE, this);
lp_vec_t<uint16_t, 9> initOnDly = lp_vec_t<uint16_t, 9>(sid.objectId, pool::INIT_ON_DLY, this);
lp_vec_t<uint16_t, 9> initOffDly = lp_vec_t<uint16_t, 9>(sid.objectId, pool::INIT_OFF_DLY, this);
lp_vec_t<uint8_t, 9> safeOffDly = lp_vec_t<uint8_t, 9>(sid.objectId, pool::SAFE_OFF_DLY, this);
lp_vec_t<uint16_t, 9> curLuLim = lp_vec_t<uint16_t, 9>(sid.objectId, pool::CUR_LU_LIM, this);
lp_vec_t<uint16_t, 9> curLim = lp_vec_t<uint16_t, 9>(sid.objectId, pool::CUR_LIM, this);
lp_vec_t<uint16_t, 9> curEma = lp_vec_t<uint16_t, 9>(sid.objectId, pool::CUR_EMA, this);
lp_vec_t<uint8_t, 9> outLink = lp_vec_t<uint8_t, 9>(sid.objectId, pool::OUT_LINK, this);
lp_vec_t<uint8_t, 9> outConv = lp_vec_t<uint8_t, 9>(sid.objectId, pool::OUT_CONV, this);
lp_vec_t<uint16_t, 9> outVoltage = lp_vec_t<uint16_t, 9>(sid.objectId, pool::OUT_VOLTAGE, this);
lp_vec_t<uint8_t, 9> convEnable = lp_vec_t<uint8_t, 9>(sid.objectId, pool::CONV_EN, this);
lp_var_t<float> curEmaGain = lp_var_t<float>(sid.objectId, pool::CUR_EMA_GAIN, this);
lp_var_t<uint16_t> battHwMax = lp_var_t<uint16_t>(sid.objectId, pool::BATT_HWMAX, this);
lp_var_t<uint16_t> battMax = lp_var_t<uint16_t>(sid.objectId, pool::BATT_MAX, this);
lp_var_t<uint16_t> battNorm = lp_var_t<uint16_t>(sid.objectId, pool::BATT_NORM, this);
lp_var_t<uint16_t> battSafe = lp_var_t<uint16_t>(sid.objectId, pool::BATT_SAFE, this);
lp_var_t<uint16_t> battCrit = lp_var_t<uint16_t>(sid.objectId, pool::BATT_CRIT, this);
lp_var_t<uint16_t> wdtI2cRst = lp_var_t<uint16_t>(sid.objectId, pool::WDT_I2C_RST, this);
lp_var_t<uint16_t> wdtCanRst = lp_var_t<uint16_t>(sid.objectId, pool::WDT_CAN_RST, this);
lp_var_t<uint32_t> wdtI2c = lp_var_t<uint32_t>(sid.objectId, pool::WDT_I2C, this);
lp_var_t<uint32_t> wdtCan = lp_var_t<uint32_t>(sid.objectId, pool::WDT_CAN, this);
lp_vec_t<uint32_t, 2> wdtCsp = lp_vec_t<uint32_t, 2>(sid.objectId, pool::WDT_CSP, this);
lp_vec_t<uint8_t, 2> wdtCspPing = lp_vec_t<uint8_t, 2>(sid.objectId, pool::WDT_CSP_PING, this);
lp_vec_t<uint8_t, 2> wdtCspChannel = lp_vec_t<uint8_t, 2>(sid.objectId, pool::WDT_CSP_CHAN, this);
lp_vec_t<uint8_t, 2> wdtCspAddr = lp_vec_t<uint8_t, 2>(sid.objectId, pool::WDT_CSP_ADDR, this);
};
/**
* @brief This class defines a dataset for the hk table of a PDU
*/
class PduAuxHk : public StaticLocalDataSet<36> {
public:
PduAuxHk(HasLocalDataPoolIF* owner, uint32_t setId) : StaticLocalDataSet(owner, setId) {}
PduAuxHk(object_id_t objectId, uint32_t setId) : StaticLocalDataSet(sid_t(objectId, setId)) {}
/** Output converter enable status */
lp_vec_t<uint8_t, 3> converterEnable =
lp_vec_t<uint8_t, 3>(sid.objectId, pool::PDU_CONV_EN, this);
lp_var_t<uint32_t> bootcause = lp_var_t<uint32_t>(sid.objectId, pool::PDU_BOOTCAUSE, this);
/** Uptime in seconds */
lp_var_t<uint32_t> uptime = lp_var_t<uint32_t>(sid.objectId, pool::PDU_UPTIME, this);
lp_var_t<uint16_t> resetcause = lp_var_t<uint16_t>(sid.objectId, pool::PDU_RESETCAUSE, this);
/** Number of detected latchups on each output channel */
lp_vec_t<uint16_t, 9> latchups = lp_vec_t<uint16_t, 9>(sid.objectId, pool::PDU_LATCHUPS, this);
/**
* There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is
* identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18.
*/
lp_vec_t<uint8_t, 8> deviceTypes = lp_vec_t<uint8_t, 8>(sid.objectId, pool::PDU_DEVICES, this);
/** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */
lp_vec_t<uint8_t, 8> devicesStatus = lp_vec_t<uint8_t, 8>(sid.objectId, pool::PDU_STATUSES, this);
/** Number of reboots triggered by the ground watchdog */
lp_var_t<uint32_t> gndWdtReboots = lp_var_t<uint32_t>(sid.objectId, pool::PDU_WDT_CNT_GND, this);
/** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */
lp_var_t<uint32_t> i2cWdtReboots = lp_var_t<uint32_t>(sid.objectId, pool::PDU_WDT_CNT_I2C, this);
/** Number of reboots triggered through the CAN watchdog */
lp_var_t<uint32_t> canWdtReboots = lp_var_t<uint32_t>(sid.objectId, pool::PDU_WDT_CNT_CAN, this);
/** Number of reboots triggered through the CSP watchdog */
lp_var_t<uint32_t> csp1WdtReboots =
lp_var_t<uint32_t>(sid.objectId, pool::PDU_WDT_CNT_CSP1, this);
lp_var_t<uint32_t> csp2WdtReboots =
lp_var_t<uint32_t>(sid.objectId, pool::PDU_WDT_CNT_CSP2, this);
/** Ground watchdog remaining seconds before rebooting */
lp_var_t<uint32_t> groundWatchdogSecondsLeft =
lp_var_t<uint32_t>(sid.objectId, pool::PDU_WDT_GND_LEFT, this);
/** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */
lp_var_t<uint32_t> i2cWatchdogSecondsLeft =
lp_var_t<uint32_t>(sid.objectId, pool::PDU_WDT_I2C_LEFT, this);
/** CAN watchdog remaining seconds before rebooting. */
lp_var_t<uint32_t> canWatchdogSecondsLeft =
lp_var_t<uint32_t>(sid.objectId, pool::PDU_WDT_CAN_LEFT, this);
/** CSP watchdogs remaining pings before rebooting. */
lp_var_t<uint8_t> csp2WatchdogPingsLeft =
lp_var_t<uint8_t>(sid.objectId, pool::PDU_WDT_CSP_LEFT1, this);
lp_var_t<uint8_t> csp1WatchdogPingsLeft =
lp_var_t<uint8_t>(sid.objectId, pool::PDU_WDT_CSP_LEFT2, this);
};
} // namespace PDU
namespace PDU1 {
enum Channels : uint8_t {
TCS_BOARD_3V3 = 0,
SYRLINKS = 1,
STR = 2,
MGT = 3,
SUS_NOMINAL = 4,
SOL_CELL_EXPERIMENT = 5,
PLOC = 6,
ACS_A_SIDE = 7,
UNUSED = 8,
LEN = 9
};
/**
* Addresses within configuration table to enable or disable output channels. Refer also to
* gs-man-nanopower-p60-pdu-200.pdf on page 16.
*/
static const uint16_t CONFIG_ADDRESS_OUT_EN_TCS_BOARD_3V3 = 0x48;
static const uint16_t CONFIG_ADDRESS_OUT_EN_SYRLINKS = 0x49;
static const uint16_t CONFIG_ADDRESS_OUT_EN_STAR_TRACKER = 0x4A;
static const uint16_t CONFIG_ADDRESS_OUT_EN_MGT = 0x4B;
static const uint16_t CONFIG_ADDRESS_OUT_EN_SUS_NOMINAL = 0x4C;
static const uint16_t CONFIG_ADDRESS_OUT_EN_SOLAR_CELL_EXP = 0x4D;
static const uint16_t CONFIG_ADDRESS_OUT_EN_PLOC = 0x4E;
static const uint16_t CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_A = 0x4F;
static const uint16_t CONFIG_ADDRESS_OUT_EN_CHANNEL8 = 0x50;
class Pdu1CoreHk : public ::PDU::PduCoreHk {
public:
Pdu1CoreHk(HasLocalDataPoolIF* owner)
: PduCoreHk(owner, static_cast<uint32_t>(::P60System::SetIds::CORE)) {}
Pdu1CoreHk(object_id_t objectId)
: PduCoreHk(objectId, static_cast<uint32_t>(::P60System::SetIds::CORE)) {}
};
class Pdu1AuxHk : public ::PDU::PduAuxHk {
public:
Pdu1AuxHk(HasLocalDataPoolIF* owner)
: PduAuxHk(owner, static_cast<uint32_t>(::P60System::SetIds::AUX)) {}
Pdu1AuxHk(object_id_t objectId)
: PduAuxHk(objectId, static_cast<uint32_t>(::P60System::SetIds::AUX)) {}
};
class Pdu1Config : public ::PDU::PduConfig {
public:
Pdu1Config(HasLocalDataPoolIF* owner)
: PduConfig(owner, static_cast<uint32_t>(::P60System::SetIds::CONFIG)) {}
};
} // namespace PDU1
namespace PDU2 {
enum Channels : uint8_t {
Q7S = 0,
PAYLOAD_PCDU_CH1 = 1,
RW = 2,
TCS_HEATER_IN = 3,
SUS_REDUNDANT = 4,
DEPY_MECHANISM = 5,
PAYLOAD_PCDU_CH6 = 6,
ACS_B_SIDE = 7,
PAYLOAD_CAMERA = 8,
LEN = 9
};
/**
* Addresses within configuration table to enable or disable output channels. Refer also to
* gs-man-nanopower-p60-pdu-200.pdf on page 16.
*/
static const uint16_t CONFIG_ADDRESS_OUT_EN_Q7S = 0x48;
static const uint16_t CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH1 = 0x49;
static const uint16_t CONFIG_ADDRESS_OUT_EN_RW = 0x4A;
static const uint16_t CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN = 0x4B;
static const uint16_t CONFIG_ADDRESS_OUT_EN_SUS_REDUNDANT = 0x4C;
static const uint16_t CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM = 0x4D;
static const uint16_t CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH6 = 0x4E;
static const uint16_t CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_B = 0x4F;
static const uint16_t CONFIG_ADDRESS_OUT_EN_PAYLOAD_CAMERA = 0x50;
class Pdu2CoreHk : public ::PDU::PduCoreHk {
public:
Pdu2CoreHk(HasLocalDataPoolIF* owner)
: PduCoreHk(owner, static_cast<uint32_t>(::P60System::SetIds::CORE)) {}
Pdu2CoreHk(object_id_t objectId)
: PduCoreHk(objectId, static_cast<uint32_t>(::P60System::SetIds::CORE)) {}
};
class Pdu2AuxHk : public ::PDU::PduAuxHk {
public:
Pdu2AuxHk(HasLocalDataPoolIF* owner)
: PduAuxHk(owner, static_cast<uint32_t>(::P60System::SetIds::AUX)) {}
Pdu2AuxHk(object_id_t objectId)
: PduAuxHk(objectId, static_cast<uint32_t>(::P60System::SetIds::AUX)) {}
};
class Pdu2Config : public ::PDU::PduConfig {
public:
Pdu2Config(HasLocalDataPoolIF* owner)
: PduConfig(owner, static_cast<uint32_t>(::P60System::SetIds::CONFIG)) {}
};
} // namespace PDU2
namespace ACU {
namespace pool {
enum Ids : lp_id_t {
/** ACU Ids */
ACU_CURRENT_IN_CHANNELS,
ACU_VOLTAGE_IN_CHANNELS,
ACU_VCC,
ACU_VBAT,
ACU_TEMPERATURES,
ACU_MPPT_MODE,
ACU_VBOOST_IN_CHANNELS,
ACU_POWER_IN_CHANNELS,
ACU_DAC_ENABLES,
ACU_DAC_RAW_CHANNELS,
ACU_BOOTCAUSE,
ACU_BOOTCNT,
ACU_UPTIME,
ACU_RESET_CAUSE,
ACU_MPPT_TIME,
ACU_MPPT_PERIOD,
ACU_DEVICES,
ACU_DEVICES_STATUS,
ACU_WDT_CNT_GND,
ACU_WDT_GND_LEFT
};
}
static const uint16_t MAX_CONFIGTABLE_ADDRESS = 26;
static const uint16_t MAX_HKTABLE_ADDRESS = 120;
static const uint8_t HK_TABLE_ENTRIES = 64;
static const uint16_t HK_TABLE_SIZE = gsConstants::P60ACU_HK_SIZE;
static const uint16_t CONFIG_TABLE_SIZE = gsConstants::P60ACU_PARAM_SIZE;
static const size_t MAX_REPLY_SIZE = HK_TABLE_SIZE;
class CoreHk : public StaticLocalDataSet<14> {
public:
CoreHk(HasLocalDataPoolIF* owner)
: StaticLocalDataSet(owner, static_cast<uint32_t>(::P60System::SetIds::CORE)) {}
CoreHk(object_id_t objectId)
: StaticLocalDataSet(sid_t(objectId, static_cast<uint32_t>(::P60System::SetIds::CORE))) {}
lp_var_t<uint8_t> mpptMode = lp_var_t<uint8_t>(sid.objectId, pool::ACU_MPPT_MODE, this);
lp_vec_t<int16_t, 6> currentInChannels =
lp_vec_t<int16_t, 6>(sid.objectId, pool::ACU_CURRENT_IN_CHANNELS, this);
lp_vec_t<uint16_t, 6> voltageInChannels =
lp_vec_t<uint16_t, 6>(sid.objectId, pool::ACU_VOLTAGE_IN_CHANNELS, this);
lp_var_t<uint16_t> vcc = lp_var_t<uint16_t>(sid.objectId, pool::ACU_VCC, this);
lp_var_t<uint16_t> vbat = lp_var_t<uint16_t>(sid.objectId, pool::ACU_VBAT, this);
lp_vec_t<uint16_t, 6> vboostInChannels =
lp_vec_t<uint16_t, 6>(sid.objectId, pool::ACU_VBOOST_IN_CHANNELS, this);
lp_vec_t<uint16_t, 6> powerInChannels =
lp_vec_t<uint16_t, 6>(sid.objectId, pool::ACU_POWER_IN_CHANNELS, this);
lp_vec_t<float, 3> temperatures = lp_vec_t<float, 3>(sid.objectId, pool::ACU_TEMPERATURES, this);
lp_var_t<uint32_t> bootcnt = lp_var_t<uint32_t>(sid.objectId, pool::ACU_BOOTCNT, this);
lp_var_t<uint32_t> uptime = lp_var_t<uint32_t>(sid.objectId, pool::ACU_UPTIME, this);
lp_var_t<uint16_t> mpptTime = lp_var_t<uint16_t>(sid.objectId, pool::ACU_MPPT_TIME, this);
lp_var_t<uint16_t> mpptPeriod = lp_var_t<uint16_t>(sid.objectId, pool::ACU_MPPT_PERIOD, this);
};
/**
* @brief This class defines a dataset for the hk table of the ACU.
*/
class AuxHk : public StaticLocalDataSet<12> {
public:
AuxHk(HasLocalDataPoolIF* owner)
: StaticLocalDataSet(owner, static_cast<uint32_t>(::P60System::SetIds::AUX)) {}
AuxHk(object_id_t objectId)
: StaticLocalDataSet(sid_t(objectId, static_cast<uint32_t>(::P60System::SetIds::AUX))) {}
lp_vec_t<uint8_t, 3> dacEnables = lp_vec_t<uint8_t, 3>(sid.objectId, pool::ACU_DAC_ENABLES, this);
lp_vec_t<uint16_t, 6> dacRawChannelVals =
lp_vec_t<uint16_t, 6>(sid.objectId, pool::ACU_DAC_RAW_CHANNELS, this);
lp_var_t<uint32_t> bootCause = lp_var_t<uint32_t>(sid.objectId, pool::ACU_BOOTCAUSE, this);
lp_var_t<uint16_t> resetCause = lp_var_t<uint16_t>(sid.objectId, pool::ACU_RESET_CAUSE, this);
lp_var_t<uint32_t> wdtCntGnd = lp_var_t<uint32_t>(sid.objectId, pool::ACU_WDT_CNT_GND, this);
lp_var_t<uint32_t> wdtGndLeft = lp_var_t<uint32_t>(sid.objectId, pool::ACU_WDT_GND_LEFT, this);
/**
* There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is
* identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18.
*/
lp_vec_t<uint8_t, 8> deviceTypes = lp_vec_t<uint8_t, 8>(sid.objectId, pool::ACU_DEVICES, this);
/** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */
lp_vec_t<uint8_t, 8> devicesStatus =
lp_vec_t<uint8_t, 8>(sid.objectId, pool::ACU_DEVICES_STATUS, this);
};
} // namespace ACU
namespace pcdu {
enum PoolIds : uint32_t { PDU1_SWITCHES, PDU2_SWITCHES, P60DOCK_5V, P60DOCK_3V3 };
static const uint8_t ON = 1;
static const uint8_t OFF = 0;
// Output states after reboot of the PDUs
const std::array<uint8_t, PDU::CHANNELS_LEN> INIT_SWITCHES_PDU1 = {
// Because the TE0720 is not connected to the PCDU, this switch is always on
#ifdef TE0720_1CFA
ON,
#else
OFF,
#endif
OFF, OFF, OFF, OFF, OFF, OFF, OFF, OFF,
};
const std::array<uint8_t, PDU::CHANNELS_LEN> INIT_SWITCHES_PDU2 = {ON, OFF, OFF, OFF, OFF,
OFF, OFF, OFF, OFF};
static constexpr uint32_t SWITCHER_SET_ID = 0;
class SwitcherStates : public StaticLocalDataSet<power::NUMBER_OF_SWITCHES> {
public:
SwitcherStates(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SWITCHER_SET_ID) {}
SwitcherStates(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, SWITCHER_SET_ID)) {}
lp_vec_t<uint8_t, PDU::CHANNELS_LEN> pdu1Switches =
lp_vec_t<uint8_t, PDU::CHANNELS_LEN>(sid.objectId, PDU1_SWITCHES, this);
lp_vec_t<uint8_t, PDU::CHANNELS_LEN> pdu2Switches =
lp_vec_t<uint8_t, PDU::CHANNELS_LEN>(sid.objectId, PDU2_SWITCHES, this);
lp_var_t<uint8_t> p60Dock5VStack = lp_var_t<uint8_t>(sid.objectId, P60DOCK_5V, this);
lp_var_t<uint8_t> p60Dock3V3Stack = lp_var_t<uint8_t>(sid.objectId, P60DOCK_3V3, this);
};
} // namespace pcdu
#endif /* MISSION_POWER_GSDEFS_H_ */