diff --git a/CHANGELOG.md b/CHANGELOG.md index ed736ae4..0a119bca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,15 @@ will consitute of a breaking change warranting a new major release: # [unreleased] +- Bumped `eive-tmtc` to v5.7.0. +- Bumped `eive-fsfw` + +## Added + +- EPS Subsystem has been added to EIVE System Tree +- Power Controller for calculating the State of Charge and FDIR regarding low SoC has been + introduced. + ## Changed - Changed internals for MPSoC boot process to make the code more understandable and some diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.cpp b/bsp_hosted/fsfwconfig/events/translateEvents.cpp index d7a9d6aa..77df8166 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.cpp +++ b/bsp_hosted/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 308 translations. + * @brief Auto-generated event translation file. Contains 313 translations. * @details - * Generated on: 2023-09-25 17:49:54 + * Generated on: 2023-10-10 13:50:27 */ #include "translateEvents.h" @@ -105,6 +105,11 @@ const char *SWITCH_CMD_SENT_STRING = "SWITCH_CMD_SENT"; const char *SWITCH_HAS_CHANGED_STRING = "SWITCH_HAS_CHANGED"; const char *SWITCHING_Q7S_DENIED_STRING = "SWITCHING_Q7S_DENIED"; const char *FDIR_REACTION_IGNORED_STRING = "FDIR_REACTION_IGNORED"; +const char *DATASET_READ_FAILED_STRING = "DATASET_READ_FAILED"; +const char *VOLTAGE_OUT_OF_BOUNDS_STRING = "VOLTAGE_OUT_OF_BOUNDS"; +const char *TIMEDELTA_OUT_OF_BOUNDS_STRING = "TIMEDELTA_OUT_OF_BOUNDS"; +const char *POWER_LEVEL_LOW_STRING = "POWER_LEVEL_LOW"; +const char *POWER_LEVEL_CRITICAL_STRING = "POWER_LEVEL_CRITICAL"; const char *GPIO_PULL_HIGH_FAILED_STRING = "GPIO_PULL_HIGH_FAILED"; const char *GPIO_PULL_LOW_FAILED_STRING = "GPIO_PULL_LOW_FAILED"; const char *HEATER_WENT_ON_STRING = "HEATER_WENT_ON"; @@ -516,6 +521,16 @@ const char *translateEvents(Event event) { return SWITCHING_Q7S_DENIED_STRING; case (11303): return FDIR_REACTION_IGNORED_STRING; + case (11304): + return DATASET_READ_FAILED_STRING; + case (11305): + return VOLTAGE_OUT_OF_BOUNDS_STRING; + case (11306): + return TIMEDELTA_OUT_OF_BOUNDS_STRING; + case (11307): + return POWER_LEVEL_LOW_STRING; + case (11308): + return POWER_LEVEL_CRITICAL_STRING; case (11400): return GPIO_PULL_HIGH_FAILED_STRING; case (11401): diff --git a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp index ab0c8cec..8d80ca56 100644 --- a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp +++ b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp @@ -1,14 +1,15 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 171 translations. - * Generated on: 2023-09-25 17:49:54 + * Contains 173 translations. + * Generated on: 2023-10-10 13:50:27 */ #include "translateObjects.h" const char *TEST_TASK_STRING = "TEST_TASK"; const char *ACS_CONTROLLER_STRING = "ACS_CONTROLLER"; const char *CORE_CONTROLLER_STRING = "CORE_CONTROLLER"; +const char *POWER_CONTROLLER_STRING = "POWER_CONTROLLER"; const char *GLOBAL_JSON_CFG_STRING = "GLOBAL_JSON_CFG"; const char *THERMAL_CONTROLLER_STRING = "THERMAL_CONTROLLER"; const char *DUMMY_HANDLER_STRING = "DUMMY_HANDLER"; @@ -164,6 +165,7 @@ const char *ACS_SUBSYSTEM_STRING = "ACS_SUBSYSTEM"; const char *PL_SUBSYSTEM_STRING = "PL_SUBSYSTEM"; const char *TCS_SUBSYSTEM_STRING = "TCS_SUBSYSTEM"; const char *COM_SUBSYSTEM_STRING = "COM_SUBSYSTEM"; +const char *EPS_SUBSYSTEM_STRING = "EPS_SUBSYSTEM"; const char *MISC_TM_STORE_STRING = "MISC_TM_STORE"; const char *OK_TM_STORE_STRING = "OK_TM_STORE"; const char *NOT_OK_TM_STORE_STRING = "NOT_OK_TM_STORE"; @@ -186,6 +188,8 @@ const char *translateObject(object_id_t object) { return ACS_CONTROLLER_STRING; case 0x43000003: return CORE_CONTROLLER_STRING; + case 0x43000004: + return POWER_CONTROLLER_STRING; case 0x43000006: return GLOBAL_JSON_CFG_STRING; case 0x43400001: @@ -496,6 +500,8 @@ const char *translateObject(object_id_t object) { return TCS_SUBSYSTEM_STRING; case 0x73010004: return COM_SUBSYSTEM_STRING; + case 0x73010005: + return EPS_SUBSYSTEM_STRING; case 0x73020001: return MISC_TM_STORE_STRING; case 0x73020002: diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 976602d4..370e8d3d 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -106,6 +106,17 @@ void ObjectFactory::produce(void* args) { #endif satsystem::EIVE_SYSTEM.setI2cRecoveryParams(pwrSwitcher); + const char* battAndImtqI2cDev = q7s::I2C_PL_EIVE; + if (core::FW_VERSION_MAJOR >= 4) { + battAndImtqI2cDev = q7s::I2C_PS_EIVE; + } + static_cast(battAndImtqI2cDev); + +#if OBSW_ADD_BPX_BATTERY_HANDLER == 1 + createBpxBatteryComponent(enableHkSets, battAndImtqI2cDev); +#endif + createPowerController(true, enableHkSets); + dummy::createDummies(dummyCfg, *pwrSwitcher, gpioComIF, enableHkSets); new CoreController(objects::CORE_CONTROLLER, enableHkSets); @@ -126,12 +137,6 @@ void ObjectFactory::produce(void* args) { gpioChecker(gpioComIF->addGpios(acsBoardGpios), "ACS Board"); #endif - const char* battAndImtqI2cDev = q7s::I2C_PL_EIVE; - if (core::FW_VERSION_MAJOR >= 4) { - battAndImtqI2cDev = q7s::I2C_PS_EIVE; - } - static_cast(battAndImtqI2cDev); - #if OBSW_ADD_MGT == 1 createImtqComponents(pwrSwitcher, enableHkSets, battAndImtqI2cDev); #endif @@ -144,10 +149,6 @@ void ObjectFactory::produce(void* args) { createReactionWheelComponents(gpioComIF, pwrSwitcher); #endif -#if OBSW_ADD_BPX_BATTERY_HANDLER == 1 - createBpxBatteryComponent(enableHkSets, battAndImtqI2cDev); -#endif - #if OBSW_ADD_STAR_TRACKER == 1 createStrComponents(pwrSwitcher); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index a3ab6bba..c01c4ccb 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -81,14 +81,6 @@ void ObjectFactory::produce(void* args) { createTmpComponents(tmpDevsToAdd); #endif createSolarArrayDeploymentComponents(*pwrSwitcher, *gpioComIF); -#if OBSW_ADD_PL_PCDU == 1 - createPlPcduComponents(gpioComIF, spiMainComIF, pwrSwitcher, *stackHandler); -#endif -#if OBSW_ADD_SYRLINKS == 1 - createSyrlinksComponents(pwrSwitcher); -#endif /* OBSW_ADD_SYRLINKS == 1 */ - createRtdComponents(q7s::SPI_DEFAULT_DEV, gpioComIF, pwrSwitcher, spiMainComIF); - createPayloadComponents(gpioComIF, *pwrSwitcher); const char* battAndImtqI2cDev = q7s::I2C_PL_EIVE; if (core::FW_VERSION_MAJOR >= 4) { @@ -102,6 +94,17 @@ void ObjectFactory::produce(void* args) { #if OBSW_ADD_BPX_BATTERY_HANDLER == 1 createBpxBatteryComponent(enableHkSets, battAndImtqI2cDev); #endif + createPowerController(true, enableHkSets); + +#if OBSW_ADD_PL_PCDU == 1 + createPlPcduComponents(gpioComIF, spiMainComIF, pwrSwitcher, *stackHandler); +#endif +#if OBSW_ADD_SYRLINKS == 1 + createSyrlinksComponents(pwrSwitcher); +#endif /* OBSW_ADD_SYRLINKS == 1 */ + + createRtdComponents(q7s::SPI_DEFAULT_DEV, gpioComIF, pwrSwitcher, spiMainComIF); + createPayloadComponents(gpioComIF, *pwrSwitcher); #if OBSW_ADD_STAR_TRACKER == 1 createStrComponents(pwrSwitcher); diff --git a/bsp_q7s/scheduling.cpp b/bsp_q7s/scheduling.cpp index d7c179ad..fa7fbe18 100644 --- a/bsp_q7s/scheduling.cpp +++ b/bsp_q7s/scheduling.cpp @@ -157,6 +157,10 @@ void scheduling::initTasks() { if (result != returnvalue::OK) { scheduling::printAddObjectError("PL_SUBSYSTEM", objects::PL_SUBSYSTEM); } + result = genericSysTask->addComponent(objects::EPS_SUBSYSTEM); + if (result != returnvalue::OK) { + scheduling::printAddObjectError("EPS_SUBSYSTEM", objects::EPS_SUBSYSTEM); + } result = genericSysTask->addComponent(objects::INTERNAL_ERROR_REPORTER); if (result != returnvalue::OK) { scheduling::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER); diff --git a/common/config/eive/definitions.h b/common/config/eive/definitions.h index b369f512..d446aa8d 100644 --- a/common/config/eive/definitions.h +++ b/common/config/eive/definitions.h @@ -79,6 +79,7 @@ static constexpr uint32_t SCHED_BLOCK_RTD = 150; static constexpr uint32_t SCHED_BLOCK_7_RW_READ_MS = 300; static constexpr uint32_t SCHED_BLOCK_8_PLPCDU_MS = 320; static constexpr uint32_t SCHED_BLOCK_9_RAD_SENS_MS = 340; +static constexpr uint32_t SCHED_BLOCK_10_PWR_CTRL_MS = 350; // 15 ms for FM static constexpr float SCHED_BLOCK_1_PERIOD = static_cast(SCHED_BLOCK_1_SUS_READ_MS) / 400.0; @@ -94,6 +95,8 @@ static constexpr float SCHED_BLOCK_RTD_PERIOD = static_cast(SCHED_BLOCK_R static constexpr float SCHED_BLOCK_7_PERIOD = static_cast(SCHED_BLOCK_7_RW_READ_MS) / 400.0; static constexpr float SCHED_BLOCK_8_PERIOD = static_cast(SCHED_BLOCK_8_PLPCDU_MS) / 400.0; static constexpr float SCHED_BLOCK_9_PERIOD = static_cast(SCHED_BLOCK_9_RAD_SENS_MS) / 400.0; +static constexpr float SCHED_BLOCK_10_PERIOD = + static_cast(SCHED_BLOCK_10_PWR_CTRL_MS) / 400.0; } // namespace spiSched diff --git a/common/config/eive/objects.h b/common/config/eive/objects.h index 0cc4b9d9..5d93dffc 100644 --- a/common/config/eive/objects.h +++ b/common/config/eive/objects.h @@ -26,6 +26,7 @@ enum commonObjects : uint32_t { THERMAL_CONTROLLER = 0x43400001, ACS_CONTROLLER = 0x43000002, CORE_CONTROLLER = 0x43000003, + POWER_CONTROLLER = 0x43000004, GLOBAL_JSON_CFG = 0x43000006, /* 0x44 ('D') for device handlers */ @@ -157,6 +158,7 @@ enum commonObjects : uint32_t { PL_SUBSYSTEM = 0x73010002, TCS_SUBSYSTEM = 0x73010003, COM_SUBSYSTEM = 0x73010004, + EPS_SUBSYSTEM = 0x73010005, TM_FUNNEL = 0x73000100, PUS_TM_FUNNEL = 0x73000101, diff --git a/dummies/PlPcduDummy.cpp b/dummies/PlPcduDummy.cpp index 7dfa4464..cf652513 100644 --- a/dummies/PlPcduDummy.cpp +++ b/dummies/PlPcduDummy.cpp @@ -43,3 +43,16 @@ ReturnValue_t PlPcduDummy::initializeLocalDataPool(localpool::DataPool &localDat localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::TEMP, new PoolEntry({0.0}, true)); return returnvalue::OK; } + +ReturnValue_t PlPcduDummy::checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t *msToReachTheMode) { + if (commandedMode != MODE_OFF) { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return NON_OP_STATE_OF_CHARGE; + } + } + } + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); +} diff --git a/dummies/PlPcduDummy.h b/dummies/PlPcduDummy.h index 8bf7f0c2..70ee5c46 100644 --- a/dummies/PlPcduDummy.h +++ b/dummies/PlPcduDummy.h @@ -1,7 +1,9 @@ #ifndef DUMMIES_PLPCDUDUMMY_H_ #define DUMMIES_PLPCDUDUMMY_H_ +#include #include +#include #include class PlPcduDummy : public DeviceHandlerBase { @@ -29,6 +31,10 @@ class PlPcduDummy : public DeviceHandlerBase { uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) override; + + ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t *msToReachTheMode) override; + pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); }; #endif /* DUMMIES_PLPCDUDUMMY_H_ */ diff --git a/dummies/PlocMpsocDummy.cpp b/dummies/PlocMpsocDummy.cpp index e1410ba1..9959dd0f 100644 --- a/dummies/PlocMpsocDummy.cpp +++ b/dummies/PlocMpsocDummy.cpp @@ -23,6 +23,19 @@ ReturnValue_t PlocMpsocDummy::buildCommandFromCommand(DeviceCommandId_t deviceCo return returnvalue::OK; } +ReturnValue_t PlocMpsocDummy::checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t *msToReachTheMode) { + if (commandedMode != MODE_OFF) { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return NON_OP_STATE_OF_CHARGE; + } + } + } + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); +} + ReturnValue_t PlocMpsocDummy::scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, size_t *foundLen) { return returnvalue::OK; diff --git a/dummies/PlocMpsocDummy.h b/dummies/PlocMpsocDummy.h index cc09e45e..28960fe3 100644 --- a/dummies/PlocMpsocDummy.h +++ b/dummies/PlocMpsocDummy.h @@ -1,6 +1,8 @@ #pragma once +#include #include +#include #include "mission/power/defs.h" @@ -24,6 +26,9 @@ class PlocMpsocDummy : public DeviceHandlerBase { size_t commandDataLen) override; ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, size_t *foundLen) override; + ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t *msToReachTheMode) override; + pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; void fillCommandAndReplyMap() override; uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; diff --git a/dummies/PlocSupervisorDummy.cpp b/dummies/PlocSupervisorDummy.cpp index b9b1948f..c560c91f 100644 --- a/dummies/PlocSupervisorDummy.cpp +++ b/dummies/PlocSupervisorDummy.cpp @@ -51,3 +51,17 @@ ReturnValue_t PlocSupervisorDummy::getSwitches(const uint8_t **switches, *switches = reinterpret_cast(&switchId); return returnvalue::OK; } + +ReturnValue_t PlocSupervisorDummy::checkModeCommand(Mode_t commandedMode, + Submode_t commandedSubmode, + uint32_t *msToReachTheMode) { + if (commandedMode != MODE_OFF) { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return NON_OP_STATE_OF_CHARGE; + } + } + } + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); +} diff --git a/dummies/PlocSupervisorDummy.h b/dummies/PlocSupervisorDummy.h index 33951cb7..c5334e56 100644 --- a/dummies/PlocSupervisorDummy.h +++ b/dummies/PlocSupervisorDummy.h @@ -1,6 +1,8 @@ #pragma once +#include #include +#include #include class PlocSupervisorDummy : public DeviceHandlerBase { @@ -32,4 +34,7 @@ class PlocSupervisorDummy : public DeviceHandlerBase { ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) override; ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) override; + ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t *msToReachTheMode) override; + pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); }; diff --git a/dummies/RwDummy.cpp b/dummies/RwDummy.cpp index 0bf4db42..05e14396 100644 --- a/dummies/RwDummy.cpp +++ b/dummies/RwDummy.cpp @@ -93,3 +93,21 @@ ReturnValue_t RwDummy::initializeLocalDataPool(localpool::DataPool &localDataPoo subdp::RegularHkPeriodicParams(lastResetStatusSet.getSid(), false, 30.0)); return returnvalue::OK; } + +LocalPoolDataSetBase *RwDummy::getDataSetHandle(sid_t sid) { + switch (sid.ownerSetId) { + case (rws::SetIds::STATUS_SET_ID): { + return &statusSet; + } + case (rws::SetIds::LAST_RESET_ID): { + return &lastResetStatusSet; + } + case (rws::SetIds::SPEED_CMD_SET): { + return &rwSpeedActuationSet; + } + case (rws::SetIds::TM_SET_ID): { + return &tmDataset; + } + } + return nullptr; +} diff --git a/dummies/RwDummy.h b/dummies/RwDummy.h index 03629937..512c4250 100644 --- a/dummies/RwDummy.h +++ b/dummies/RwDummy.h @@ -37,6 +37,7 @@ class RwDummy : public DeviceHandlerBase { uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) override; + LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override; }; #endif /* DUMMIES_RWDUMMY_H_ */ diff --git a/fsfw b/fsfw index d246ce34..0f604b35 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit d246ce34d05ecc5c722fd127e61556374961c899 +Subproject commit 0f604b35c6d3a2518e3c3ce3947825102e9fc4f4 diff --git a/generators/bsp_hosted_events.csv b/generators/bsp_hosted_events.csv index 4d762f0e..2cd6ca2f 100644 --- a/generators/bsp_hosted_events.csv +++ b/generators/bsp_hosted_events.csv @@ -99,6 +99,11 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 11301;0x2c25;SWITCH_HAS_CHANGED;INFO;Indicated that a switch state has changed P1: New switch state, 1 for on, 0 for off | P2: Switch Index;mission/power/defs.h 11302;0x2c26;SWITCHING_Q7S_DENIED;MEDIUM;No description;mission/power/defs.h 11303;0x2c27;FDIR_REACTION_IGNORED;MEDIUM;No description;mission/power/defs.h +11304;0x2c28;DATASET_READ_FAILED;INFO;The dataset read for the inputs of the Power Controller has failed.;mission/power/defs.h +11305;0x2c29;VOLTAGE_OUT_OF_BOUNDS;HIGH;No description;mission/power/defs.h +11306;0x2c2a;TIMEDELTA_OUT_OF_BOUNDS;LOW;Time difference for Coulomb Counter was too large. P1: time in s * 10;mission/power/defs.h +11307;0x2c2b;POWER_LEVEL_LOW;HIGH;The State of Charge is below the limit for payload use. Setting Payload to faulty.;mission/power/defs.h +11308;0x2c2c;POWER_LEVEL_CRITICAL;HIGH;The State of Charge is below the limit for higher modes. Setting Reaction Wheels to faulty.;mission/power/defs.h 11400;0x2c88;GPIO_PULL_HIGH_FAILED;LOW;No description;mission/tcs/HeaterHandler.h 11401;0x2c89;GPIO_PULL_LOW_FAILED;LOW;No description;mission/tcs/HeaterHandler.h 11402;0x2c8a;HEATER_WENT_ON;INFO;No description;mission/tcs/HeaterHandler.h diff --git a/generators/bsp_hosted_objects.csv b/generators/bsp_hosted_objects.csv index 3faac37c..4cb21f46 100644 --- a/generators/bsp_hosted_objects.csv +++ b/generators/bsp_hosted_objects.csv @@ -1,6 +1,7 @@ 0x42694269;TEST_TASK 0x43000002;ACS_CONTROLLER 0x43000003;CORE_CONTROLLER +0x43000004;POWER_CONTROLLER 0x43000006;GLOBAL_JSON_CFG 0x43400001;THERMAL_CONTROLLER 0x44000001;DUMMY_HANDLER @@ -156,6 +157,7 @@ 0x73010002;PL_SUBSYSTEM 0x73010003;TCS_SUBSYSTEM 0x73010004;COM_SUBSYSTEM +0x73010005;EPS_SUBSYSTEM 0x73020001;MISC_TM_STORE 0x73020002;OK_TM_STORE 0x73020003;NOT_OK_TM_STORE diff --git a/generators/bsp_hosted_returnvalues.csv b/generators/bsp_hosted_returnvalues.csv index 50a86ae3..0dfc94c3 100644 --- a/generators/bsp_hosted_returnvalues.csv +++ b/generators/bsp_hosted_returnvalues.csv @@ -210,6 +210,7 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x27a8;DHI_NoReplyExpected;No description;168;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27a9;DHI_NonOpTemperature;No description;169;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27aa;DHI_CommandNotImplemented;No description;170;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x27ab;DHI_NonOpStateOfCharge;No description;171;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27b0;DHI_ChecksumError;No description;176;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27b1;DHI_LengthMissmatch;No description;177;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27b2;DHI_InvalidData;No description;178;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 4d762f0e..2cd6ca2f 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -99,6 +99,11 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 11301;0x2c25;SWITCH_HAS_CHANGED;INFO;Indicated that a switch state has changed P1: New switch state, 1 for on, 0 for off | P2: Switch Index;mission/power/defs.h 11302;0x2c26;SWITCHING_Q7S_DENIED;MEDIUM;No description;mission/power/defs.h 11303;0x2c27;FDIR_REACTION_IGNORED;MEDIUM;No description;mission/power/defs.h +11304;0x2c28;DATASET_READ_FAILED;INFO;The dataset read for the inputs of the Power Controller has failed.;mission/power/defs.h +11305;0x2c29;VOLTAGE_OUT_OF_BOUNDS;HIGH;No description;mission/power/defs.h +11306;0x2c2a;TIMEDELTA_OUT_OF_BOUNDS;LOW;Time difference for Coulomb Counter was too large. P1: time in s * 10;mission/power/defs.h +11307;0x2c2b;POWER_LEVEL_LOW;HIGH;The State of Charge is below the limit for payload use. Setting Payload to faulty.;mission/power/defs.h +11308;0x2c2c;POWER_LEVEL_CRITICAL;HIGH;The State of Charge is below the limit for higher modes. Setting Reaction Wheels to faulty.;mission/power/defs.h 11400;0x2c88;GPIO_PULL_HIGH_FAILED;LOW;No description;mission/tcs/HeaterHandler.h 11401;0x2c89;GPIO_PULL_LOW_FAILED;LOW;No description;mission/tcs/HeaterHandler.h 11402;0x2c8a;HEATER_WENT_ON;INFO;No description;mission/tcs/HeaterHandler.h diff --git a/generators/bsp_q7s_objects.csv b/generators/bsp_q7s_objects.csv index eedafc52..914b7df6 100644 --- a/generators/bsp_q7s_objects.csv +++ b/generators/bsp_q7s_objects.csv @@ -1,6 +1,7 @@ 0x00005060;P60DOCK_TEST_TASK 0x43000002;ACS_CONTROLLER 0x43000003;CORE_CONTROLLER +0x43000004;POWER_CONTROLLER 0x43000006;GLOBAL_JSON_CFG 0x43400001;THERMAL_CONTROLLER 0x44120006;MGM_0_LIS3_HANDLER @@ -161,6 +162,7 @@ 0x73010002;PL_SUBSYSTEM 0x73010003;TCS_SUBSYSTEM 0x73010004;COM_SUBSYSTEM +0x73010005;EPS_SUBSYSTEM 0x73020001;MISC_TM_STORE 0x73020002;OK_TM_STORE 0x73020003;NOT_OK_TM_STORE diff --git a/generators/bsp_q7s_returnvalues.csv b/generators/bsp_q7s_returnvalues.csv index 1bc91860..0e804457 100644 --- a/generators/bsp_q7s_returnvalues.csv +++ b/generators/bsp_q7s_returnvalues.csv @@ -210,6 +210,7 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x27a8;DHI_NoReplyExpected;No description;168;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27a9;DHI_NonOpTemperature;No description;169;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27aa;DHI_CommandNotImplemented;No description;170;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x27ab;DHI_NonOpStateOfCharge;No description;171;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27b0;DHI_ChecksumError;No description;176;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27b1;DHI_LengthMissmatch;No description;177;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27b2;DHI_InvalidData;No description;178;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index d7a9d6aa..77df8166 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 308 translations. + * @brief Auto-generated event translation file. Contains 313 translations. * @details - * Generated on: 2023-09-25 17:49:54 + * Generated on: 2023-10-10 13:50:27 */ #include "translateEvents.h" @@ -105,6 +105,11 @@ const char *SWITCH_CMD_SENT_STRING = "SWITCH_CMD_SENT"; const char *SWITCH_HAS_CHANGED_STRING = "SWITCH_HAS_CHANGED"; const char *SWITCHING_Q7S_DENIED_STRING = "SWITCHING_Q7S_DENIED"; const char *FDIR_REACTION_IGNORED_STRING = "FDIR_REACTION_IGNORED"; +const char *DATASET_READ_FAILED_STRING = "DATASET_READ_FAILED"; +const char *VOLTAGE_OUT_OF_BOUNDS_STRING = "VOLTAGE_OUT_OF_BOUNDS"; +const char *TIMEDELTA_OUT_OF_BOUNDS_STRING = "TIMEDELTA_OUT_OF_BOUNDS"; +const char *POWER_LEVEL_LOW_STRING = "POWER_LEVEL_LOW"; +const char *POWER_LEVEL_CRITICAL_STRING = "POWER_LEVEL_CRITICAL"; const char *GPIO_PULL_HIGH_FAILED_STRING = "GPIO_PULL_HIGH_FAILED"; const char *GPIO_PULL_LOW_FAILED_STRING = "GPIO_PULL_LOW_FAILED"; const char *HEATER_WENT_ON_STRING = "HEATER_WENT_ON"; @@ -516,6 +521,16 @@ const char *translateEvents(Event event) { return SWITCHING_Q7S_DENIED_STRING; case (11303): return FDIR_REACTION_IGNORED_STRING; + case (11304): + return DATASET_READ_FAILED_STRING; + case (11305): + return VOLTAGE_OUT_OF_BOUNDS_STRING; + case (11306): + return TIMEDELTA_OUT_OF_BOUNDS_STRING; + case (11307): + return POWER_LEVEL_LOW_STRING; + case (11308): + return POWER_LEVEL_CRITICAL_STRING; case (11400): return GPIO_PULL_HIGH_FAILED_STRING; case (11401): diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 19e0bf82..aeb2b405 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -1,14 +1,15 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 175 translations. - * Generated on: 2023-09-25 17:49:54 + * Contains 177 translations. + * Generated on: 2023-10-10 13:50:27 */ #include "translateObjects.h" const char *P60DOCK_TEST_TASK_STRING = "P60DOCK_TEST_TASK"; const char *ACS_CONTROLLER_STRING = "ACS_CONTROLLER"; const char *CORE_CONTROLLER_STRING = "CORE_CONTROLLER"; +const char *POWER_CONTROLLER_STRING = "POWER_CONTROLLER"; const char *GLOBAL_JSON_CFG_STRING = "GLOBAL_JSON_CFG"; const char *THERMAL_CONTROLLER_STRING = "THERMAL_CONTROLLER"; const char *MGM_0_LIS3_HANDLER_STRING = "MGM_0_LIS3_HANDLER"; @@ -169,6 +170,7 @@ const char *ACS_SUBSYSTEM_STRING = "ACS_SUBSYSTEM"; const char *PL_SUBSYSTEM_STRING = "PL_SUBSYSTEM"; const char *TCS_SUBSYSTEM_STRING = "TCS_SUBSYSTEM"; const char *COM_SUBSYSTEM_STRING = "COM_SUBSYSTEM"; +const char *EPS_SUBSYSTEM_STRING = "EPS_SUBSYSTEM"; const char *MISC_TM_STORE_STRING = "MISC_TM_STORE"; const char *OK_TM_STORE_STRING = "OK_TM_STORE"; const char *NOT_OK_TM_STORE_STRING = "NOT_OK_TM_STORE"; @@ -190,6 +192,8 @@ const char *translateObject(object_id_t object) { return ACS_CONTROLLER_STRING; case 0x43000003: return CORE_CONTROLLER_STRING; + case 0x43000004: + return POWER_CONTROLLER_STRING; case 0x43000006: return GLOBAL_JSON_CFG_STRING; case 0x43400001: @@ -510,6 +514,8 @@ const char *translateObject(object_id_t object) { return TCS_SUBSYSTEM_STRING; case 0x73010004: return COM_SUBSYSTEM_STRING; + case 0x73010005: + return EPS_SUBSYSTEM_STRING; case 0x73020001: return MISC_TM_STORE_STRING; case 0x73020002: diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index 766b5ca2..cb3e043b 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -27,6 +28,7 @@ #include "devices/gpioIds.h" #include "eive/definitions.h" #include "mission/system/acs/acsModeTree.h" +#include "mission/system/power/epsModeTree.h" #include "mission/system/tcs/tcsModeTree.h" #include "mission/system/tree/payloadModeTree.h" #include "mission/tcs/defs.h" @@ -337,6 +339,14 @@ AcsController* ObjectFactory::createAcsController(bool connectSubsystem, bool en return acsCtrl; } +PowerController* ObjectFactory::createPowerController(bool connectSubsystem, bool enableHkSets) { + auto pwrCtrl = new PowerController(objects::POWER_CONTROLLER, enableHkSets); + if (connectSubsystem) { + pwrCtrl->connectModeTreeParent(satsystem::eps::EPS_SUBSYSTEM); + } + return pwrCtrl; +} + void ObjectFactory::gpioChecker(ReturnValue_t result, std::string output) { if (result != returnvalue::OK) { sif::error << "ObjectFactory: Adding GPIOs failed for " << output << std::endl; diff --git a/linux/ObjectFactory.h b/linux/ObjectFactory.h index 16801ba9..46baa685 100644 --- a/linux/ObjectFactory.h +++ b/linux/ObjectFactory.h @@ -16,6 +16,7 @@ class GpioIF; class SpiComIF; class PowerSwitchIF; class AcsController; +class PowerController; namespace ObjectFactory { @@ -31,5 +32,6 @@ void createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher, void gpioChecker(ReturnValue_t result, std::string output); AcsController* createAcsController(bool connectSubsystem, bool enableHkSets); +PowerController* createPowerController(bool connectSubsystem, bool enableHkSets); } // namespace ObjectFactory diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index d7a9d6aa..77df8166 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 308 translations. + * @brief Auto-generated event translation file. Contains 313 translations. * @details - * Generated on: 2023-09-25 17:49:54 + * Generated on: 2023-10-10 13:50:27 */ #include "translateEvents.h" @@ -105,6 +105,11 @@ const char *SWITCH_CMD_SENT_STRING = "SWITCH_CMD_SENT"; const char *SWITCH_HAS_CHANGED_STRING = "SWITCH_HAS_CHANGED"; const char *SWITCHING_Q7S_DENIED_STRING = "SWITCHING_Q7S_DENIED"; const char *FDIR_REACTION_IGNORED_STRING = "FDIR_REACTION_IGNORED"; +const char *DATASET_READ_FAILED_STRING = "DATASET_READ_FAILED"; +const char *VOLTAGE_OUT_OF_BOUNDS_STRING = "VOLTAGE_OUT_OF_BOUNDS"; +const char *TIMEDELTA_OUT_OF_BOUNDS_STRING = "TIMEDELTA_OUT_OF_BOUNDS"; +const char *POWER_LEVEL_LOW_STRING = "POWER_LEVEL_LOW"; +const char *POWER_LEVEL_CRITICAL_STRING = "POWER_LEVEL_CRITICAL"; const char *GPIO_PULL_HIGH_FAILED_STRING = "GPIO_PULL_HIGH_FAILED"; const char *GPIO_PULL_LOW_FAILED_STRING = "GPIO_PULL_LOW_FAILED"; const char *HEATER_WENT_ON_STRING = "HEATER_WENT_ON"; @@ -516,6 +521,16 @@ const char *translateEvents(Event event) { return SWITCHING_Q7S_DENIED_STRING; case (11303): return FDIR_REACTION_IGNORED_STRING; + case (11304): + return DATASET_READ_FAILED_STRING; + case (11305): + return VOLTAGE_OUT_OF_BOUNDS_STRING; + case (11306): + return TIMEDELTA_OUT_OF_BOUNDS_STRING; + case (11307): + return POWER_LEVEL_LOW_STRING; + case (11308): + return POWER_LEVEL_CRITICAL_STRING; case (11400): return GPIO_PULL_HIGH_FAILED_STRING; case (11401): diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 19e0bf82..aeb2b405 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -1,14 +1,15 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 175 translations. - * Generated on: 2023-09-25 17:49:54 + * Contains 177 translations. + * Generated on: 2023-10-10 13:50:27 */ #include "translateObjects.h" const char *P60DOCK_TEST_TASK_STRING = "P60DOCK_TEST_TASK"; const char *ACS_CONTROLLER_STRING = "ACS_CONTROLLER"; const char *CORE_CONTROLLER_STRING = "CORE_CONTROLLER"; +const char *POWER_CONTROLLER_STRING = "POWER_CONTROLLER"; const char *GLOBAL_JSON_CFG_STRING = "GLOBAL_JSON_CFG"; const char *THERMAL_CONTROLLER_STRING = "THERMAL_CONTROLLER"; const char *MGM_0_LIS3_HANDLER_STRING = "MGM_0_LIS3_HANDLER"; @@ -169,6 +170,7 @@ const char *ACS_SUBSYSTEM_STRING = "ACS_SUBSYSTEM"; const char *PL_SUBSYSTEM_STRING = "PL_SUBSYSTEM"; const char *TCS_SUBSYSTEM_STRING = "TCS_SUBSYSTEM"; const char *COM_SUBSYSTEM_STRING = "COM_SUBSYSTEM"; +const char *EPS_SUBSYSTEM_STRING = "EPS_SUBSYSTEM"; const char *MISC_TM_STORE_STRING = "MISC_TM_STORE"; const char *OK_TM_STORE_STRING = "OK_TM_STORE"; const char *NOT_OK_TM_STORE_STRING = "NOT_OK_TM_STORE"; @@ -190,6 +192,8 @@ const char *translateObject(object_id_t object) { return ACS_CONTROLLER_STRING; case 0x43000003: return CORE_CONTROLLER_STRING; + case 0x43000004: + return POWER_CONTROLLER_STRING; case 0x43000006: return GLOBAL_JSON_CFG_STRING; case 0x43400001: @@ -510,6 +514,8 @@ const char *translateObject(object_id_t object) { return TCS_SUBSYSTEM_STRING; case 0x73010004: return COM_SUBSYSTEM_STRING; + case 0x73010005: + return EPS_SUBSYSTEM_STRING; case 0x73020001: return MISC_TM_STORE_STRING; case 0x73020002: diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 2421fcaa..66fba6d8 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -1505,3 +1505,16 @@ void PlocMpsocHandler::cmdDoneHandler(bool success, ReturnValue_t result) { } disableAllReplies(); } + +ReturnValue_t PlocMpsocHandler::checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t* msToReachTheMode) { + if (commandedMode != MODE_OFF) { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return NON_OP_STATE_OF_CHARGE; + } + } + } + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); +} diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index 10171ef5..0203b942 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -5,6 +5,7 @@ #include #include #include +#include #include @@ -309,6 +310,10 @@ class PlocMpsocHandler : public DeviceHandlerBase, public CommandsActionsIF { void stopSpecialComHelper(); void handleActionCommandFailure(ActionId_t actionId); + + pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); + ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t* msToReachTheMode) override; }; #endif /* BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_ */ diff --git a/linux/payload/PlocSupervisorHandler.cpp b/linux/payload/PlocSupervisorHandler.cpp index 0aaa7cfb..0c6311de 100644 --- a/linux/payload/PlocSupervisorHandler.cpp +++ b/linux/payload/PlocSupervisorHandler.cpp @@ -1993,6 +1993,20 @@ uint32_t PlocSupervisorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t mod return 7000; } +ReturnValue_t PlocSupervisorHandler::checkModeCommand(Mode_t commandedMode, + Submode_t commandedSubmode, + uint32_t* msToReachTheMode) { + if (commandedMode != MODE_OFF) { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return NON_OP_STATE_OF_CHARGE; + } + } + } + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); +} + // ReturnValue_t PlocSupervisorHandler::checkMramPacketApid() { // uint16_t apid = (spacePacketBuffer[0] << 8 | spacePacketBuffer[1]) & supv::APID_MASK; // TODO: Fix diff --git a/linux/payload/PlocSupervisorHandler.h b/linux/payload/PlocSupervisorHandler.h index 3e5ac2a0..d7c5cb1e 100644 --- a/linux/payload/PlocSupervisorHandler.h +++ b/linux/payload/PlocSupervisorHandler.h @@ -3,6 +3,7 @@ #include #include +#include #include "OBSWConfig.h" #include "devices/powerSwitcherList.h" @@ -395,6 +396,10 @@ class PlocSupervisorHandler : public DeviceHandlerBase { void handleExecutionFailureReport(ExecutionReport& report); void printAckFailureInfo(uint16_t statusCode, DeviceCommandId_t commandId); + + pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); + ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t* msToReachTheMode) override; }; #endif /* MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ */ diff --git a/mission/controller/CMakeLists.txt b/mission/controller/CMakeLists.txt index 6177a14b..901decc0 100644 --- a/mission/controller/CMakeLists.txt +++ b/mission/controller/CMakeLists.txt @@ -1,6 +1,7 @@ if(TGT_BSP MATCHES "arm/q7s" OR TGT_BSP MATCHES "") target_sources(${LIB_EIVE_MISSION} PRIVATE ThermalController.cpp - AcsController.cpp) + AcsController.cpp + PowerController.cpp) endif() add_subdirectory(acs) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp new file mode 100644 index 00000000..7b7db9e8 --- /dev/null +++ b/mission/controller/PowerController.cpp @@ -0,0 +1,372 @@ +#include + +PowerController::PowerController(object_id_t objectId, bool enableHkSets) + : ExtendedControllerBase(objectId), + enableHkSets(enableHkSets), + parameterHelper(this), + pwrCtrlCoreHk(this), + enablePl(this) {} + +ReturnValue_t PowerController::initialize() { + ReturnValue_t result = parameterHelper.initialize(); + if (result != returnvalue::OK) { + return result; + } + return ExtendedControllerBase::initialize(); +} + +ReturnValue_t PowerController::handleCommandMessage(CommandMessage *message) { + ReturnValue_t result = actionHelper.handleActionMessage(message); + if (result == returnvalue::OK) { + return result; + } + result = parameterHelper.handleParameterMessage(message); + if (result == returnvalue::OK) { + return result; + } + return result; +} + +MessageQueueId_t PowerController::getCommandQueue() const { return commandQueue->getId(); } + +ReturnValue_t PowerController::getParameter(uint8_t domainId, uint8_t parameterId, + ParameterWrapper *parameterWrapper, + const ParameterWrapper *newValues, + uint16_t startAtIndex) { + switch (domainId) { + case 0x0: // direct members + switch (parameterId) { + case 0x0: + parameterWrapper->set(batteryInternalResistance); + break; + case 0x1: + parameterWrapper->set(batteryMaximumCapacity); + break; + case 0x2: { + float oldCoulombCounterVoltageUpperThreshold = coulombCounterVoltageUpperThreshold; + ReturnValue_t result = newValues->getElement(&coulombCounterVoltageUpperThreshold); + if (result != returnvalue::OK) { + coulombCounterVoltageUpperThreshold = oldCoulombCounterVoltageUpperThreshold; + return result; + } + result = calculateCoulombCounterChargeUpperThreshold(); + if (result != returnvalue::OK) { + coulombCounterVoltageUpperThreshold = oldCoulombCounterVoltageUpperThreshold; + return result; + } + parameterWrapper->set(coulombCounterVoltageUpperThreshold); + break; + } + case 0x3: + parameterWrapper->set(maxAllowedTimeDiff); + break; + case 0x4: + parameterWrapper->set(payloadOpLimitOn); + break; + case 0x5: + parameterWrapper->set(payloadOpLimitLow); + break; + case 0x6: + parameterWrapper->set(higherModesLimit); + break; + default: + return INVALID_IDENTIFIER_ID; + } + break; + default: + return INVALID_DOMAIN_ID; + }; + return returnvalue::OK; +} + +void PowerController::performControlOperation() { + switch (internalState) { + case InternalState::STARTUP: { + initialCountdown.resetTimer(); + internalState = InternalState::INITIAL_DELAY; + return; + } + case InternalState::INITIAL_DELAY: { + if (initialCountdown.hasTimedOut()) { + internalState = InternalState::INIT; + } + return; + } + case InternalState::INIT: { + ReturnValue_t result = calculateCoulombCounterChargeUpperThreshold(); + if (result == returnvalue::OK) { + internalState = InternalState::READY; + } + return; + } + case InternalState::READY: { + if (mode != MODE_OFF) { + calculateStateOfCharge(); + if (mode == MODE_NORMAL) { + watchStateOfCharge(); + } else { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + enablePl.setValidity(false, true); + } + } + } + break; + } + default: + break; + } +} + +ReturnValue_t PowerController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(pwrctrl::PoolIds::TOTAL_BATTERY_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(pwrctrl::PoolIds::OPEN_CIRCUIT_VOLTAGE_CHARGE, + new PoolEntry({0.0})); + localDataPoolMap.emplace(pwrctrl::PoolIds::COULOMB_COUNTER_CHARGE, new PoolEntry({0.0})); + poolManager.subscribeForRegularPeriodicPacket({pwrCtrlCoreHk.getSid(), enableHkSets, 60.0}); + localDataPoolMap.emplace(pwrctrl::PoolIds::PAYLOAD_FLAG, new PoolEntry({false})); + poolManager.subscribeForRegularPeriodicPacket({enablePl.getSid(), false, 60.0}); + return returnvalue::OK; +} + +LocalPoolDataSetBase *PowerController::getDataSetHandle(sid_t sid) { + switch (sid.ownerSetId) { + case pwrctrl::CORE_HK: + return &pwrCtrlCoreHk; + case pwrctrl::ENABLE_PL: + return &enablePl; + default: + return nullptr; + } + return nullptr; +} + +ReturnValue_t PowerController::checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t *msToReachTheMode) { + if (mode == MODE_OFF or mode == MODE_ON or mode == MODE_NORMAL) { + if (submode == SUBMODE_NONE) { + return returnvalue::OK; + } else { + return INVALID_SUBMODE; + } + } + return INVALID_MODE; +} + +void PowerController::calculateStateOfCharge() { + // get time + Clock::getClock_timeval(&now); + + // update EPS HK values + ReturnValue_t result = updateEpsData(); + if (result != returnvalue::OK) { + triggerEvent(power::DATASET_READ_FAILED); + sif::error << "Power Controller::Reading of Datasets has failed" << std::endl; + { + PoolReadGuard pg(&pwrCtrlCoreHk); + if (pg.getReadResult() == returnvalue::OK) { + pwrCtrlCoreHk.totalBatteryCurrent.value = INVALID_TOTAL_BATTERY_CURRENT; + pwrCtrlCoreHk.openCircuitVoltageCharge.value = INVALID_SOC; + pwrCtrlCoreHk.coulombCounterCharge.value = INVALID_SOC; + pwrCtrlCoreHk.setValidity(false, true); + } + } + // store time for next run + oldTime = now; + return; + } + + // calculate total battery current + iBat = p60CoreHk.batteryCurrent.value + bpxBatteryHk.dischargeCurrent.value; + + result = calculateOpenCircuitVoltageCharge(); + if (result != returnvalue::OK) { + // notifying events have already been triggered + { + PoolReadGuard pg(&pwrCtrlCoreHk); + if (pg.getReadResult() == returnvalue::OK) { + pwrCtrlCoreHk.totalBatteryCurrent.value = iBat; + pwrCtrlCoreHk.totalBatteryCurrent.setValid(true); + pwrCtrlCoreHk.openCircuitVoltageCharge.value = INVALID_SOC; + pwrCtrlCoreHk.openCircuitVoltageCharge.setValid(false); + pwrCtrlCoreHk.coulombCounterCharge.value = INVALID_SOC; + pwrCtrlCoreHk.coulombCounterCharge.setValid(false); + } + } + // store time for next run + oldTime = now; + return; + } + + result = calculateCoulombCounterCharge(); + if (result != returnvalue::OK) { + // notifying events have already been triggered + { + PoolReadGuard pg(&pwrCtrlCoreHk); + if (pg.getReadResult() == returnvalue::OK) { + pwrCtrlCoreHk.totalBatteryCurrent.value = iBat; + pwrCtrlCoreHk.totalBatteryCurrent.setValid(true); + pwrCtrlCoreHk.openCircuitVoltageCharge.value = + charge2stateOfCharge(openCircuitVoltageCharge, false); + pwrCtrlCoreHk.openCircuitVoltageCharge.setValid(true); + pwrCtrlCoreHk.coulombCounterCharge.value = INVALID_SOC; + pwrCtrlCoreHk.coulombCounterCharge.setValid(false); + } + } + // store time for next run + oldTime = now; + return; + } + + // commit to dataset + { + PoolReadGuard pg(&pwrCtrlCoreHk); + if (pg.getReadResult() == returnvalue::OK) { + pwrCtrlCoreHk.totalBatteryCurrent.value = iBat; + pwrCtrlCoreHk.openCircuitVoltageCharge.value = + charge2stateOfCharge(openCircuitVoltageCharge, false); + pwrCtrlCoreHk.coulombCounterCharge.value = charge2stateOfCharge(coulombCounterCharge, true); + pwrCtrlCoreHk.setValidity(true, true); + } + } + // store time for next run + oldTime = now; +} + +void PowerController::watchStateOfCharge() { + if (pwrCtrlCoreHk.coulombCounterCharge.isValid()) { + if (pwrCtrlCoreHk.coulombCounterCharge.value < payloadOpLimitOn) { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + enablePl.plUseAllowed.value = false; + enablePl.setValidity(true, true); + } + } else { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + enablePl.plUseAllowed.value = true; + enablePl.setValidity(true, true); + } + } + if (not pwrLvlLowFlag and pwrCtrlCoreHk.coulombCounterCharge.value < payloadOpLimitLow) { + triggerEvent(power::POWER_LEVEL_LOW); + pwrLvlLowFlag = true; + } else if (pwrLvlLowFlag and pwrCtrlCoreHk.coulombCounterCharge.value > payloadOpLimitLow) { + pwrLvlLowFlag = false; + } + if (not pwrLvlCriticalFlag and pwrCtrlCoreHk.coulombCounterCharge.value < higherModesLimit) { + triggerEvent(power::POWER_LEVEL_CRITICAL); + pwrLvlCriticalFlag = true; + } else if (pwrLvlCriticalFlag and pwrCtrlCoreHk.coulombCounterCharge.value > higherModesLimit) { + pwrLvlCriticalFlag = false; + } + } else { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + enablePl.plUseAllowed.value = false; + enablePl.setValidity(true, true); + } + } +} + +ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() { + float vBatCorrected = + (bpxBatteryHk.battVoltage.value - iBat * batteryInternalResistance) * CONVERT_FROM_MILLI; + uint8_t lookUpTableIdx = LOOK_UP_TABLE_MAX_IDX; + ReturnValue_t result = lookUpTableOcvIdxFinder(vBatCorrected, lookUpTableIdx, false); + if (result != returnvalue::OK) { + return result; + } + openCircuitVoltageCharge = linearInterpolation( + vBatCorrected, lookUpTableOcv[1][lookUpTableIdx], lookUpTableOcv[1][lookUpTableIdx + 1], + lookUpTableOcv[0][lookUpTableIdx], lookUpTableOcv[0][lookUpTableIdx + 1]); + return returnvalue::OK; +} + +ReturnValue_t PowerController::calculateCoulombCounterCharge() { + double timeDiff = timevalOperations::toDouble(now - oldTime); + if (timeDiff > maxAllowedTimeDiff) { + // should not be a permanent state so no spam protection required + triggerEvent(power::TIMEDELTA_OUT_OF_BOUNDS, static_cast(timeDiff * 10)); + sif::error << "Power Controller::Time delta too large for Coulomb Counter: " << timeDiff + << std::endl; + return returnvalue::FAILED; + } + if (not pwrCtrlCoreHk.coulombCounterCharge.isValid()) { + coulombCounterCharge = openCircuitVoltageCharge; + } else { + coulombCounterCharge = + coulombCounterCharge + iBat * CONVERT_FROM_MILLI * timeDiff * SECONDS_TO_HOURS; + if (coulombCounterCharge >= coulombCounterChargeUpperThreshold) { + coulombCounterCharge = coulombCounterChargeUpperThreshold; + } + } + return returnvalue::OK; +} + +ReturnValue_t PowerController::updateEpsData() { + std::vector results; + { + PoolReadGuard pgBat(&bpxBatteryHk); + results.push_back(pgBat.getReadResult()); + } + { + PoolReadGuard pgP60(&p60CoreHk); + results.push_back(pgP60.getReadResult()); + } + for (const auto &result : results) { + if (result != returnvalue::OK) { + return result; + } + } + return returnvalue::OK; +} + +float PowerController::charge2stateOfCharge(float capacity, bool coulombCounter) { + if (coulombCounter) { + return capacity / coulombCounterChargeUpperThreshold; + } + return capacity / batteryMaximumCapacity; +} + +float PowerController::linearInterpolation(float x, float x0, float x1, float y0, float y1) { + return y0 + (x - x0) * (y1 - y0) / (x1 - x0); +} + +ReturnValue_t PowerController::lookUpTableOcvIdxFinder(float voltage, uint8_t &idx, bool paramCmd) { + if (voltage >= lookUpTableOcv[1][99]) { + if (not voltageOutOfBoundsFlag and not paramCmd) { + triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 0, static_cast(voltage * 10)); + voltageOutOfBoundsFlag = true; + } + sif::error << "Power Controller::Voltage is too high: " << voltage << std::endl; + return returnvalue::FAILED; + } else if (voltage <= lookUpTableOcv[1][0]) { + if (not voltageOutOfBoundsFlag and not paramCmd) { + triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 1, static_cast(voltage * 10)); + voltageOutOfBoundsFlag = true; + } + sif::error << "Power Controller::Voltage is too low: " << voltage << std::endl; + return returnvalue::FAILED; + } + voltageOutOfBoundsFlag = false; + while (lookUpTableOcv[1][idx] > voltage) { + idx--; + } + return returnvalue::OK; +} + +ReturnValue_t PowerController::calculateCoulombCounterChargeUpperThreshold() { + uint8_t lookUpTableIdx = LOOK_UP_TABLE_MAX_IDX; + ReturnValue_t result = + lookUpTableOcvIdxFinder(coulombCounterVoltageUpperThreshold, lookUpTableIdx, true); + if (result != returnvalue::OK) { + return result; + } + coulombCounterChargeUpperThreshold = + linearInterpolation(coulombCounterVoltageUpperThreshold, lookUpTableOcv[1][lookUpTableIdx], + lookUpTableOcv[1][lookUpTableIdx + 1], lookUpTableOcv[0][lookUpTableIdx], + lookUpTableOcv[0][lookUpTableIdx + 1]); + return returnvalue::OK; +} diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h new file mode 100644 index 00000000..1f27616d --- /dev/null +++ b/mission/controller/PowerController.h @@ -0,0 +1,131 @@ +#ifndef MISSION_CONTROLLER_POWERCONTROLLER_H_ +#define MISSION_CONTROLLER_POWERCONTROLLER_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +class PowerController : public ExtendedControllerBase, public ReceivesParameterMessagesIF { + public: + static constexpr dur_millis_t INIT_DELAY = 500; + + PowerController(object_id_t objectId, bool enableHkSets); + + MessageQueueId_t getCommandQueue() const; + ReturnValue_t getParameter(uint8_t domainId, uint8_t parameterId, + ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues, + uint16_t startAtIndex) override; + + private: + bool enableHkSets = false; + ParameterHelper parameterHelper; + + enum class InternalState { STARTUP, INITIAL_DELAY, INIT, READY }; + InternalState internalState = InternalState::STARTUP; + + // Initial delay to make sure all pool variables have been initialized their owners + Countdown initialCountdown = Countdown(INIT_DELAY); + + ReturnValue_t initialize() override; + ReturnValue_t handleCommandMessage(CommandMessage* message) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t* msToReachTheMode) override; + void performControlOperation() override; + + void calculateStateOfCharge(); + void watchStateOfCharge(); + ReturnValue_t calculateOpenCircuitVoltageCharge(); + ReturnValue_t calculateCoulombCounterCharge(); + ReturnValue_t updateEpsData(); + float charge2stateOfCharge(float capacity, bool coulombCounter); + ReturnValue_t lookUpTableOcvIdxFinder(float voltage, uint8_t& idx, bool paramCmd); + float linearInterpolation(float x, float x0, float x1, float y0, float y1); + ReturnValue_t calculateCoulombCounterChargeUpperThreshold(); + + // Parameters + float batteryInternalResistance = 70.0 / 2.0 / 1000.0; // [Ohm] + float batteryMaximumCapacity = 2.6 * 2; // [Ah] + float coulombCounterVoltageUpperThreshold = 16.2; // [V] + double maxAllowedTimeDiff = 1.5; // [s] + float payloadOpLimitOn = 0.90; // [%] + float payloadOpLimitLow = 0.75; // [%] + float higherModesLimit = 0.6; // [%] + + // OCV Look-up-Table {[Ah],[V]} + static constexpr uint8_t LOOK_UP_TABLE_MAX_IDX = 99; + float lookUpTableOcv[2][100] = { + {0.00000000e+00, 3.16227766e-04, 4.52809661e-04, 6.48382625e-04, 9.28425483e-04, + 1.32942162e-03, 1.90361194e-03, 2.72580074e-03, 3.90310099e-03, 5.58888885e-03, + 8.00278514e-03, 1.14592671e-02, 1.64086377e-02, 2.34956903e-02, 3.36437110e-02, + 4.81747620e-02, 6.89819174e-02, 9.87758887e-02, 1.41438170e-01, 2.02526713e-01, + 2.90000000e-01, 3.00000000e-01, 3.62820513e-01, 4.25641026e-01, 4.88461538e-01, + 5.51282051e-01, 6.14102564e-01, 6.76923077e-01, 7.39743590e-01, 8.02564103e-01, + 8.65384615e-01, 9.28205128e-01, 9.91025641e-01, 1.05384615e+00, 1.11666667e+00, + 1.17948718e+00, 1.24230769e+00, 1.30512821e+00, 1.36794872e+00, 1.43076923e+00, + 1.49358974e+00, 1.55641026e+00, 1.61923077e+00, 1.68205128e+00, 1.74487179e+00, + 1.80769231e+00, 1.87051282e+00, 1.93333333e+00, 1.99615385e+00, 2.05897436e+00, + 2.12179487e+00, 2.18461538e+00, 2.24743590e+00, 2.31025641e+00, 2.37307692e+00, + 2.43589744e+00, 2.49871795e+00, 2.56153846e+00, 2.62435897e+00, 2.68717949e+00, + 2.75000000e+00, 2.81282051e+00, 2.87564103e+00, 2.93846154e+00, 3.00128205e+00, + 3.06410256e+00, 3.12692308e+00, 3.18974359e+00, 3.25256410e+00, 3.31538462e+00, + 3.37820513e+00, 3.44102564e+00, 3.50384615e+00, 3.56666667e+00, 3.62948718e+00, + 3.69230769e+00, 3.75512821e+00, 3.81794872e+00, 3.88076923e+00, 3.94358974e+00, + 4.00641026e+00, 4.06923077e+00, 4.13205128e+00, 4.19487179e+00, 4.25769231e+00, + 4.32051282e+00, 4.38333333e+00, 4.44615385e+00, 4.50897436e+00, 4.57179487e+00, + 4.63461538e+00, 4.69743590e+00, 4.76025641e+00, 4.82307692e+00, 4.88589744e+00, + 4.94871795e+00, 5.01153846e+00, 5.07435897e+00, 5.13717949e+00, 5.20000000e+00}, + {12.52033533, 12.58720948, 12.61609309, 12.65612591, 12.67105282, 12.69242681, 12.72303245, + 12.76685696, 12.80313768, 12.83600741, 12.8830739, 12.94720576, 13.00112629, 13.07833563, + 13.17486308, 13.27128842, 13.37713879, 13.49275604, 13.60395193, 13.68708863, 13.75196335, + 13.7582376, 13.79298643, 13.82885799, 13.87028849, 13.91585718, 13.96701874, 14.02343574, + 14.07665641, 14.12626342, 14.1675095, 14.20582917, 14.23342159, 14.25724476, 14.27264301, + 14.28922389, 14.30898535, 14.32750837, 14.34358057, 14.35965277, 14.37698366, 14.3943261, + 14.41079196, 14.42679817, 14.44261008, 14.45771025, 14.47281042, 14.48751461, 14.50193089, + 14.5164887, 14.53193477, 14.54738084, 14.56341235, 14.58054578, 14.59799552, 14.61632769, + 14.63716465, 14.66935073, 14.70511347, 14.74315094, 14.77251031, 14.80005585, 14.8315427, + 14.86078285, 14.89444687, 14.93495892, 14.97114013, 15.01055751, 15.0538516, 15.09698825, + 15.14850029, 15.18947994, 15.24249483, 15.28521713, 15.335695, 15.37950723, 15.43241224, + 15.48082213, 15.53314287, 15.58907248, 15.64030253, 15.68385331, 15.74149122, 15.80051882, + 15.84959348, 15.90443241, 15.95743724, 16.01283068, 16.07629253, 16.13470801, 16.1890518, + 16.24200781, 16.30521118, 16.37368429, 16.43661267, 16.49604875, 16.56223813, 16.62741412, + 16.67249918, 16.74926904}}; + + // Variables + timeval now; + timeval oldTime; + int16_t iBat = 0; // [mA] + float openCircuitVoltageCharge = 0.0; // [Ah] + float coulombCounterCharge = 0.0; // [Ah] + float coulombCounterChargeUpperThreshold = 0.0; // [Ah] + float oldCoulombCounterVoltageUpperThreshold = 0.0; // [V] + + static constexpr float CONVERT_FROM_MILLI = 1e-3; + static constexpr float SECONDS_TO_HOURS = 1. / (60. * 60.); + + static constexpr int16_t INVALID_TOTAL_BATTERY_CURRENT = 0; + static constexpr float INVALID_SOC = -1; + + bool pwrLvlLowFlag = false; + bool pwrLvlCriticalFlag = false; + bool voltageOutOfBoundsFlag = false; + + // HK Datasets for Calculation + BpxBatteryHk bpxBatteryHk = BpxBatteryHk(objects::BPX_BATT_HANDLER); + P60Dock::CoreHkSet p60CoreHk = P60Dock::CoreHkSet(objects::P60DOCK_HANDLER); + // Output Dataset + pwrctrl::CoreHk pwrCtrlCoreHk; + // Dataset for PL Flag + pwrctrl::EnablePl enablePl; +}; + +#endif /* MISSION_CONTROLLER_POWERCONTROLLER_H_ */ diff --git a/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h b/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h new file mode 100644 index 00000000..1b378cd0 --- /dev/null +++ b/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h @@ -0,0 +1,51 @@ +#ifndef MISSION_CONTROLLER_CONTROLLERDEFINITIONS_POWERCTRLDEFINITIONS_H_ +#define MISSION_CONTROLLER_CONTROLLERDEFINITIONS_POWERCTRLDEFINITIONS_H_ + +#include +#include +#include +#include + +#include + +namespace pwrctrl { + +enum SetIds : uint32_t { CORE_HK, ENABLE_PL }; + +enum PoolIds : lp_id_t { + TOTAL_BATTERY_CURRENT, + OPEN_CIRCUIT_VOLTAGE_CHARGE, + COULOMB_COUNTER_CHARGE, + PAYLOAD_FLAG +}; + +static constexpr uint8_t CORE_HK_ENTRIES = 3; +static constexpr uint8_t ENABLE_PL_ENTRIES = 1; + +class CoreHk : public StaticLocalDataSet { + public: + CoreHk(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, CORE_HK) {} + + lp_var_t totalBatteryCurrent = + lp_var_t(sid.objectId, TOTAL_BATTERY_CURRENT, this); + lp_var_t openCircuitVoltageCharge = + lp_var_t(sid.objectId, OPEN_CIRCUIT_VOLTAGE_CHARGE, this); + lp_var_t coulombCounterCharge = + lp_var_t(sid.objectId, COULOMB_COUNTER_CHARGE, this); + + private: +}; + +class EnablePl : public StaticLocalDataSet { + public: + EnablePl(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, ENABLE_PL) {} + EnablePl(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, ENABLE_PL)) {} + + lp_var_t plUseAllowed = lp_var_t(sid.objectId, PAYLOAD_FLAG, this); + + private: +}; + +} // namespace pwrctrl + +#endif /* MISSION_CONTROLLER_CONTROLLERDEFINITIONS_POWERCTRLDEFINITIONS_H_ */ diff --git a/mission/payload/PayloadPcduHandler.cpp b/mission/payload/PayloadPcduHandler.cpp index 1e6d16db..bda15b20 100644 --- a/mission/payload/PayloadPcduHandler.cpp +++ b/mission/payload/PayloadPcduHandler.cpp @@ -564,6 +564,19 @@ bool PayloadPcduHandler::checkCurrent(float val, float upperBound, Event event) return true; } +ReturnValue_t PayloadPcduHandler::checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t* msToReachTheMode) { + if (commandedMode != MODE_OFF) { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return NON_OP_STATE_OF_CHARGE; + } + } + } + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); +} + ReturnValue_t PayloadPcduHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) { using namespace plpcdu; if (mode == MODE_NORMAL) { diff --git a/mission/payload/PayloadPcduHandler.h b/mission/payload/PayloadPcduHandler.h index d9370dcf..a4574f53 100644 --- a/mission/payload/PayloadPcduHandler.h +++ b/mission/payload/PayloadPcduHandler.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -170,6 +171,10 @@ class PayloadPcduHandler : public DeviceHandlerBase { ReturnValue_t handleDoubleParamUpdate(std::string key, ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues); LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + + pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); + ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t* msToReachTheMode) override; }; #endif /* LINUX_DEVICES_PLPCDUHANDLER_H_ */ diff --git a/mission/pollingSeqTables.cpp b/mission/pollingSeqTables.cpp index 4896d8db..e9adf83b 100644 --- a/mission/pollingSeqTables.cpp +++ b/mission/pollingSeqTables.cpp @@ -133,6 +133,7 @@ ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::ACU_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); + if (thisSequence->checkSequence() != returnvalue::OK) { sif::error << "GomSpace PST initialization failed" << std::endl; return returnvalue::FAILED; @@ -602,5 +603,8 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::RAD_SENSOR, length * config::spiSched::SCHED_BLOCK_9_PERIOD, DeviceHandlerIF::GET_READ); + + thisSequence->addSlot(objects::POWER_CONTROLLER, length * config::spiSched::SCHED_BLOCK_10_PERIOD, + 0); return returnvalue::OK; } diff --git a/mission/power/defs.h b/mission/power/defs.h index 13e5e63f..28e5eca8 100644 --- a/mission/power/defs.h +++ b/mission/power/defs.h @@ -47,6 +47,23 @@ static constexpr Event SWITCHING_Q7S_DENIED = event::makeEvent(SUBSYSTEM_ID, 2, static constexpr Event FDIR_REACTION_IGNORED = event::makeEvent(SUBSYSTEM_ID, 3, severity::MEDIUM); +//! [EXPORT] : [COMMENT] The dataset read for the inputs of the Power Controller has failed. +static constexpr Event DATASET_READ_FAILED = event::makeEvent(SUBSYSTEM_ID, 4, severity::INFO); +//! [EXPORT] : [COMMENT] The battery voltage read is out of the bounds in which it is supposed to +//! be. +//! P1: 1 too high, 0 too low +//! P2: voltage in V * 10 +static constexpr Event VOLTAGE_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 5, severity::HIGH); +//! [EXPORT] : [COMMENT] Time difference for Coulomb Counter was too large. +//! P1: time in s * 10 +static constexpr Event TIMEDELTA_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 6, severity::LOW); +//! [EXPORT] : [COMMENT] The State of Charge is below the limit for payload use. Setting Payload to +//! faulty. +static constexpr Event POWER_LEVEL_LOW = event::makeEvent(SUBSYSTEM_ID, 7, severity::HIGH); +//! [EXPORT] : [COMMENT] The State of Charge is below the limit for higher modes. Setting Reaction +//! Wheels to faulty. +static constexpr Event POWER_LEVEL_CRITICAL = event::makeEvent(SUBSYSTEM_ID, 8, severity::HIGH); + enum class States { IDLE, SWITCHING_POWER, CHECKING_POWER, MODE_COMMANDING }; enum class OpCodes { NONE, TO_OFF_DONE, TO_NOT_OFF_DONE, TIMEOUT_OCCURED }; diff --git a/mission/system/EiveSystem.cpp b/mission/system/EiveSystem.cpp index 6519806e..0df0fc95 100644 --- a/mission/system/EiveSystem.cpp +++ b/mission/system/EiveSystem.cpp @@ -81,6 +81,55 @@ ReturnValue_t EiveSystem::initialize() { return result; } + auto* plSs = ObjectManager::instance()->get(objects::PL_SUBSYSTEM); + if (plSs == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + plSsQueueId = plSs->getCommandQueue(); + + auto* plPcdu = ObjectManager::instance()->get(objects::PLPCDU_HANDLER); + if (plPcdu == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + plPcduQueueId = plPcdu->getCommandQueue(); + + auto* plocMpsoc = ObjectManager::instance()->get(objects::PLOC_MPSOC_HANDLER); + if (plocMpsoc == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + plocMpsocQueueId = plocMpsoc->getCommandQueue(); + + auto* plocSupervisor = + ObjectManager::instance()->get(objects::PLOC_SUPERVISOR_HANDLER); + if (plocSupervisor == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + plocSupervisorQueueId = plocSupervisor->getCommandQueue(); + + auto* camera = ObjectManager::instance()->get(objects::CAM_SWITCHER); + if (camera == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + cameraQueueId = camera->getCommandQueue(); + + auto* scex = ObjectManager::instance()->get(objects::SCEX); + if (scex == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + scexQueueId = scex->getCommandQueue(); + + auto* radSensor = ObjectManager::instance()->get(objects::RAD_SENSOR); + if (radSensor == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + radSensorQueueId = radSensor->getCommandQueue(); + + auto* str = ObjectManager::instance()->get(objects::STAR_TRACKER); + if (str == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + strQueueId = str->getCommandQueue(); + auto* bpxDest = ObjectManager::instance()->get(objects::BPX_BATT_HANDLER); if (bpxDest == nullptr) { return ObjectManager::CHILD_INIT_FAILED; @@ -120,6 +169,8 @@ ReturnValue_t EiveSystem::initialize() { manager->subscribeToEvent(eventQueue->getId(), event::getEventId(tcsCtrl::OBC_OVERHEATING)); manager->subscribeToEvent(eventQueue->getId(), event::getEventId(tcsCtrl::MGT_OVERHEATING)); manager->subscribeToEvent(eventQueue->getId(), event::getEventId(pdec::INVALID_TC_FRAME)); + manager->subscribeToEvent(eventQueue->getId(), event::getEventId(power::POWER_LEVEL_LOW)); + manager->subscribeToEvent(eventQueue->getId(), event::getEventId(power::POWER_LEVEL_CRITICAL)); return Subsystem::initialize(); } @@ -151,6 +202,20 @@ void EiveSystem::handleEventMessages() { commandSelfToSafe(); break; } + case power::POWER_LEVEL_LOW: { + forceOffPayload(); + break; + } + case power::POWER_LEVEL_CRITICAL: + CommandMessage msg; + HealthMessage::setHealthMessage(&msg, HealthMessage::HEALTH_SET, HasHealthIF::FAULTY); + ReturnValue_t result = MessageQueueSenderIF::sendMessage( + strQueueId, &msg, MessageQueueIF::NO_QUEUE, false); + if (result != returnvalue::OK) { + sif::error << "EIVE System: Sending FAULTY command to STR Assembly failed" + << std::endl; + } + break; } break; default: @@ -336,6 +401,42 @@ void EiveSystem::pdecRecoveryLogic() { } } +void EiveSystem::forceOffPayload() { + CommandMessage msg; + // set PL to faulty + HealthMessage::setHealthMessage(&msg, HealthMessage::HEALTH_SET, HasHealthIF::FAULTY); + + ReturnValue_t result = commandQueue->sendMessage(plPcduQueueId, &msg); + if (result != returnvalue::OK) { + sif::error << "EIVE System: Sending FAULTY command to PL PCDU failed" << std::endl; + } + + result = commandQueue->sendMessage(plocMpsocQueueId, &msg); + if (result != returnvalue::OK) { + sif::error << "EIVE System: Sending FAULTY command to PLOC MPSOC failed" << std::endl; + } + + result = commandQueue->sendMessage(plocSupervisorQueueId, &msg); + if (result != returnvalue::OK) { + sif::error << "EIVE System: Sending FAULTY command to PLOC SUPERVISOR failed" << std::endl; + } + + result = commandQueue->sendMessage(cameraQueueId, &msg); + if (result != returnvalue::OK) { + sif::error << "EIVE System: Sending FAULTY command to PL CAM failed" << std::endl; + } + + result = commandQueue->sendMessage(scexQueueId, &msg); + if (result != returnvalue::OK) { + sif::error << "EIVE System: Sending FAULTY command to SCEX failed" << std::endl; + } + + result = commandQueue->sendMessage(radSensorQueueId, &msg); + if (result != returnvalue::OK) { + sif::error << "EIVE System: Sending FAULTY command to RAD SENSOR failed" << std::endl; + } +} + void EiveSystem::commonI2cRecoverySequenceFinish() { alreadyTriedI2cRecovery = true; performI2cReboot = false; diff --git a/mission/system/EiveSystem.h b/mission/system/EiveSystem.h index e6ff19b9..78f8bdc9 100644 --- a/mission/system/EiveSystem.h +++ b/mission/system/EiveSystem.h @@ -49,6 +49,15 @@ class EiveSystem : public Subsystem, public HasActionsIF { PowerSwitchIF* powerSwitcher = nullptr; std::atomic_uint16_t& i2cErrors; + MessageQueueId_t plSsQueueId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t plPcduQueueId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t plocMpsocQueueId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t plocSupervisorQueueId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t cameraQueueId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t scexQueueId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t radSensorQueueId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t strQueueId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t pdecHandlerQueueId = MessageQueueIF::NO_QUEUE; MessageQueueId_t bpxBattQueueId = MessageQueueIF::NO_QUEUE; @@ -68,6 +77,8 @@ class EiveSystem : public Subsystem, public HasActionsIF { ReturnValue_t sendFullRebootCommand(); ReturnValue_t sendSelfRebootCommand(); + void forceOffPayload(); + void pdecRecoveryLogic(); void i2cRecoveryLogic(); diff --git a/mission/system/objects/CamSwitcher.cpp b/mission/system/objects/CamSwitcher.cpp index 90a78945..93b67646 100644 --- a/mission/system/objects/CamSwitcher.cpp +++ b/mission/system/objects/CamSwitcher.cpp @@ -1,6 +1,6 @@ #include "CamSwitcher.h" -CamSwitcher::CamSwitcher(object_id_t objectId, PowerSwitchIF &pwrSwitcher, +CamSwitcher::CamSwitcher(object_id_t objectId, PowerSwitchIF& pwrSwitcher, power::Switch_t pwrSwitch) : PowerSwitcherComponent(objectId, &pwrSwitcher, pwrSwitch) {} void CamSwitcher::performFaultyOperation() { @@ -8,3 +8,17 @@ void CamSwitcher::performFaultyOperation() { switcher.turnOff(); } } + +ReturnValue_t CamSwitcher::checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t* msToReachTheMode) { + if (commandedMode != MODE_OFF) { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return TRANS_NOT_ALLOWED; + } + } + } + return PowerSwitcherComponent::checkModeCommand(commandedMode, commandedSubmode, + msToReachTheMode); +} diff --git a/mission/system/objects/CamSwitcher.h b/mission/system/objects/CamSwitcher.h index 57f371ce..a0d1b242 100644 --- a/mission/system/objects/CamSwitcher.h +++ b/mission/system/objects/CamSwitcher.h @@ -1,13 +1,19 @@ #ifndef MISSION_SYSTEM_OBJECTS_CAMSWITCHER_H_ #define MISSION_SYSTEM_OBJECTS_CAMSWITCHER_H_ +#include #include +#include class CamSwitcher : public PowerSwitcherComponent { public: - CamSwitcher(object_id_t objectId, PowerSwitchIF &pwrSwitcher, power::Switch_t pwrSwitch); + CamSwitcher(object_id_t objectId, PowerSwitchIF& pwrSwitcher, power::Switch_t pwrSwitch); private: + pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); + ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t* msToReachTheMode) override; + void performFaultyOperation() override; }; diff --git a/mission/system/power/CMakeLists.txt b/mission/system/power/CMakeLists.txt index 8fa4967e..a7e91e05 100644 --- a/mission/system/power/CMakeLists.txt +++ b/mission/system/power/CMakeLists.txt @@ -1 +1 @@ -target_sources(${LIB_EIVE_MISSION} PRIVATE GomspacePowerFdir.cpp) +target_sources(${LIB_EIVE_MISSION} PRIVATE epsModeTree.cpp EpsSubsystem.cpp GomspacePowerFdir.cpp) diff --git a/mission/system/power/EpsSubsystem.cpp b/mission/system/power/EpsSubsystem.cpp new file mode 100644 index 00000000..2ec4155b --- /dev/null +++ b/mission/system/power/EpsSubsystem.cpp @@ -0,0 +1,27 @@ +#include + +#include "fsfw/devicehandlers/DeviceHandlerIF.h" + +EpsSubsystem::EpsSubsystem(object_id_t objectId, uint32_t maxNumberOfSequences, + uint32_t maxNumberOfTables) + : Subsystem(objectId, maxNumberOfSequences, maxNumberOfTables) {} + +void EpsSubsystem::announceMode(bool recursive) { + const char* modeStr = "UNKNOWN"; + switch (mode) { + case (HasModesIF::MODE_OFF): { + modeStr = "OFF"; + break; + } + case (HasModesIF::MODE_ON): { + modeStr = "ON"; + break; + } + case (DeviceHandlerIF::MODE_NORMAL): { + modeStr = "NORMAL"; + break; + } + } + sif::info << "EPS subsystem is now in " << modeStr << " mode" << std::endl; + return Subsystem::announceMode(recursive); +} diff --git a/mission/system/power/EpsSubsystem.h b/mission/system/power/EpsSubsystem.h new file mode 100644 index 00000000..33f24d46 --- /dev/null +++ b/mission/system/power/EpsSubsystem.h @@ -0,0 +1,13 @@ +#ifndef MISSION_SYSTEM_OBJECTS_EPSSUBSYSTEM_H_ +#define MISSION_SYSTEM_OBJECTS_EPSSUBSYSTEM_H_ +#include + +class EpsSubsystem : public Subsystem { + public: + EpsSubsystem(object_id_t objectId, uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables); + + private: + void announceMode(bool recursive) override; +}; + +#endif /* MISSION_SYSTEM_OBJECTS_EPSSUBSYSTEM_H_ */ diff --git a/mission/system/power/epsModeTree.cpp b/mission/system/power/epsModeTree.cpp new file mode 100644 index 00000000..83f04ac5 --- /dev/null +++ b/mission/system/power/epsModeTree.cpp @@ -0,0 +1,104 @@ +#include + +#include "eive/objects.h" +#include "fsfw/devicehandlers/DeviceHandlerIF.h" +#include "fsfw/subsystem/Subsystem.h" +#include "mission/system/treeUtil.h" + +EpsSubsystem satsystem::eps::EPS_SUBSYSTEM(objects::EPS_SUBSYSTEM, 12, 24); + +namespace { +// Alias for checker function +const auto check = subsystem::checkInsert; +void buildOffSequence(Subsystem& ss, ModeListEntry& eh); +void buildNormalSequence(Subsystem& ss, ModeListEntry& eh); +} // namespace + +static const auto OFF = HasModesIF::MODE_OFF; +static const auto NML = DeviceHandlerIF::MODE_NORMAL; + +auto EPS_SEQUENCE_OFF = std::make_pair(OFF, FixedArrayList()); +auto EPS_TABLE_OFF_TGT = std::make_pair((OFF << 24) | 1, FixedArrayList()); +auto EPS_TABLE_OFF_TRANS_0 = std::make_pair((OFF << 24) | 2, FixedArrayList()); + +auto EPS_SEQUENCE_NORMAL = std::make_pair(NML, FixedArrayList()); +auto EPS_TABLE_NORMAL_TGT = std::make_pair((NML << 24) | 1, FixedArrayList()); +auto EPS_TABLE_NORMAL_TRANS_0 = std::make_pair((NML << 24) | 2, FixedArrayList()); + +Subsystem& satsystem::eps::init() { + ModeListEntry entry; + buildOffSequence(EPS_SUBSYSTEM, entry); + buildNormalSequence(EPS_SUBSYSTEM, entry); + EPS_SUBSYSTEM.setInitialMode(NML); + return EPS_SUBSYSTEM; +} + +namespace { + +void buildOffSequence(Subsystem& ss, ModeListEntry& eh) { + std::string context = "satsystem::eps::buildOffSequence"; + auto ctxc = context.c_str(); + // Insert Helper Table + auto iht = [&](object_id_t obj, Mode_t mode, Submode_t submode, ArrayList& table) { + eh.setObject(obj); + eh.setMode(mode); + eh.setSubmode(submode); + check(table.insert(eh), ctxc); + }; + // Insert Helper Sequence + auto ihs = [&](ArrayList& sequence, Mode_t tableId, uint32_t waitSeconds, + bool checkSuccess) { + eh.setTableId(tableId); + eh.setWaitSeconds(waitSeconds); + eh.setCheckSuccess(checkSuccess); + check(sequence.insert(eh), ctxc); + }; + + // OFF target table is empty + check(ss.addTable(TableEntry(EPS_TABLE_OFF_TGT.first, &EPS_TABLE_OFF_TGT.second)), ctxc); + + // Transition 0 + iht(objects::POWER_CONTROLLER, OFF, 0, EPS_TABLE_OFF_TRANS_0.second); + check(ss.addTable(TableEntry(EPS_TABLE_OFF_TRANS_0.first, &EPS_TABLE_OFF_TRANS_0.second)), ctxc); + + ihs(EPS_SEQUENCE_OFF.second, EPS_TABLE_OFF_TGT.first, 0, false); + ihs(EPS_SEQUENCE_OFF.second, EPS_TABLE_OFF_TRANS_0.first, 0, false); + check(ss.addSequence(SequenceEntry(EPS_SEQUENCE_OFF.first, &EPS_SEQUENCE_OFF.second, + EPS_SEQUENCE_OFF.first)), + ctxc); +} + +void buildNormalSequence(Subsystem& ss, ModeListEntry& eh) { + std::string context = "satsystem::tcs::buildNormalSequence"; + auto ctxc = context.c_str(); + // Insert Helper Table + auto iht = [&](object_id_t obj, Mode_t mode, Submode_t submode, ArrayList& table) { + eh.setObject(obj); + eh.setMode(mode); + eh.setSubmode(submode); + check(table.insert(eh), ctxc); + }; + // Insert Helper Sequence + auto ihs = [&](ArrayList& sequence, Mode_t tableId, uint32_t waitSeconds, + bool checkSuccess) { + eh.setTableId(tableId); + eh.setWaitSeconds(waitSeconds); + eh.setCheckSuccess(checkSuccess); + check(sequence.insert(eh), ctxc); + }; + + // Normal table target table is empty + check(ss.addTable(TableEntry(EPS_TABLE_NORMAL_TGT.first, &EPS_TABLE_NORMAL_TGT.second)), ctxc); + + // Transition 0 + iht(objects::POWER_CONTROLLER, NML, 0, EPS_TABLE_NORMAL_TRANS_0.second); + check(ss.addTable(TableEntry(EPS_TABLE_NORMAL_TRANS_0.first, &EPS_TABLE_NORMAL_TRANS_0.second)), + ctxc); + + ihs(EPS_SEQUENCE_NORMAL.second, EPS_TABLE_NORMAL_TGT.first, 0, false); + ihs(EPS_SEQUENCE_NORMAL.second, EPS_TABLE_NORMAL_TRANS_0.first, 0, false); + check(ss.addSequence(SequenceEntry(EPS_SEQUENCE_NORMAL.first, &EPS_SEQUENCE_NORMAL.second, + EPS_SEQUENCE_NORMAL.first)), + ctxc); +} +} // namespace diff --git a/mission/system/power/epsModeTree.h b/mission/system/power/epsModeTree.h new file mode 100644 index 00000000..852c2c19 --- /dev/null +++ b/mission/system/power/epsModeTree.h @@ -0,0 +1,15 @@ +#ifndef MISSION_SYSTEM_TREE_EPSMODETREE_H_ +#define MISSION_SYSTEM_TREE_EPSMODETREE_H_ + +#include + +namespace satsystem { +namespace eps { + +extern EpsSubsystem EPS_SUBSYSTEM; +Subsystem& init(); + +} // namespace eps +} // namespace satsystem + +#endif /* MISSION_SYSTEM_TREE_EPSMODETREE_H_ */ diff --git a/mission/system/systemTree.cpp b/mission/system/systemTree.cpp index 10c40617..c9894f21 100644 --- a/mission/system/systemTree.cpp +++ b/mission/system/systemTree.cpp @@ -11,6 +11,7 @@ #include "eive/objects.h" #include "mission/com/defs.h" #include "mission/system/acs/acsModeTree.h" +#include "mission/system/power/epsModeTree.h" #include "mission/system/tcs/tcsModeTree.h" #include "mission/system/tree/payloadModeTree.h" #include "treeUtil.h" @@ -40,6 +41,8 @@ void satsystem::init(bool commandPlPcdu1) { tcsSubsystem.connectModeTreeParent(EIVE_SYSTEM); auto& comSubsystem = com::init(); comSubsystem.connectModeTreeParent(EIVE_SYSTEM); + auto& epsSubsystem = eps::init(); + epsSubsystem.connectModeTreeParent(EIVE_SYSTEM); ModeListEntry entry; buildBootSequence(EIVE_SYSTEM, entry); buildSafeSequence(EIVE_SYSTEM, entry); @@ -141,9 +144,11 @@ void buildBootSequence(Subsystem& ss, ModeListEntry& eh) { iht(objects::PL_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TGT.second); iht(objects::COM_SUBSYSTEM, com::RX_ONLY, 0, EIVE_TABLE_BOOT_TGT.second); iht(objects::TCS_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TGT.second); + iht(objects::EPS_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TGT.second); check(ss.addTable(TableEntry(EIVE_TABLE_BOOT_TGT.first, &EIVE_TABLE_BOOT_TGT.second)), ctxc); - // Build SAFE transition 0. + // Build BOOT transition 0. + iht(objects::EPS_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TRANS_0.second); iht(objects::TCS_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TRANS_0.second); iht(objects::COM_SUBSYSTEM, com::RX_ONLY, 0, EIVE_TABLE_BOOT_TRANS_0.second); iht(objects::PL_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TRANS_0.second); @@ -151,7 +156,7 @@ void buildBootSequence(Subsystem& ss, ModeListEntry& eh) { check(ss.addTable(TableEntry(EIVE_TABLE_BOOT_TRANS_0.first, &EIVE_TABLE_BOOT_TRANS_0.second)), ctxc); - // Build Safe sequence + // Build BOOT sequence ihs(EIVE_SEQUENCE_BOOT.second, EIVE_TABLE_BOOT_TGT.first, 0, false); ihs(EIVE_SEQUENCE_BOOT.second, EIVE_TABLE_BOOT_TRANS_0.first, 0, false); check(ss.addSequence(SequenceEntry(EIVE_SEQUENCE_BOOT.first, &EIVE_SEQUENCE_BOOT.second, @@ -187,13 +192,14 @@ void buildSafeSequence(Subsystem& ss, ModeListEntry& eh) { check(ss.addTable(TableEntry(EIVE_TABLE_SAFE_TGT.first, &EIVE_TABLE_SAFE_TGT.second)), ctxc); // Build SAFE transition 0. + iht(objects::EPS_SUBSYSTEM, NML, 0, EIVE_TABLE_SAFE_TRANS_0.second); iht(objects::TCS_SUBSYSTEM, NML, 0, EIVE_TABLE_SAFE_TRANS_0.second); iht(objects::PL_SUBSYSTEM, OFF, 0, EIVE_TABLE_SAFE_TRANS_0.second); iht(objects::ACS_SUBSYSTEM, acs::AcsMode::SAFE, 0, EIVE_TABLE_SAFE_TRANS_0.second, true); check(ss.addTable(TableEntry(EIVE_TABLE_SAFE_TRANS_0.first, &EIVE_TABLE_SAFE_TRANS_0.second)), ctxc); - // Build Safe sequence + // Build SAFE sequence ihs(EIVE_SEQUENCE_SAFE.second, EIVE_TABLE_SAFE_TGT.first, 0, false); ihs(EIVE_SEQUENCE_SAFE.second, EIVE_TABLE_SAFE_TRANS_0.first, 0, false); check(ss.addSequence(SequenceEntry(EIVE_SEQUENCE_SAFE.first, &EIVE_SEQUENCE_SAFE.second, @@ -224,6 +230,7 @@ void buildIdleSequence(Subsystem& ss, ModeListEntry& eh) { check(ss.addTable(TableEntry(EIVE_TABLE_IDLE_TGT.first, &EIVE_TABLE_IDLE_TGT.second)), ctxc); // Build IDLE transition 0 + iht(objects::EPS_SUBSYSTEM, NML, 0, EIVE_TABLE_IDLE_TRANS_0.second); iht(objects::TCS_SUBSYSTEM, NML, 0, EIVE_TABLE_IDLE_TRANS_0.second); iht(objects::ACS_SUBSYSTEM, acs::AcsMode::PTG_IDLE, 0, EIVE_TABLE_IDLE_TRANS_0.second); check(ss.addTable(TableEntry(EIVE_TABLE_IDLE_TRANS_0.first, &EIVE_TABLE_IDLE_TRANS_0.second)), @@ -261,6 +268,7 @@ void buildPtgNadirSequence(Subsystem& ss, ModeListEntry& eh) { ctxc); // Build PTG_NADIR transition 0 + iht(objects::EPS_SUBSYSTEM, NML, 0, EIVE_TABLE_PTG_NADIR_TRANS_0.second); iht(objects::TCS_SUBSYSTEM, NML, 0, EIVE_TABLE_PTG_NADIR_TRANS_0.second); iht(objects::ACS_SUBSYSTEM, acs::AcsMode::PTG_NADIR, 0, EIVE_TABLE_PTG_NADIR_TRANS_0.second); check(ss.addTable( @@ -299,6 +307,7 @@ void buildPtgTargetSequence(Subsystem& ss, ModeListEntry& eh) { ctxc); // Build PTG_TARGET transition 0 + iht(objects::EPS_SUBSYSTEM, NML, 0, EIVE_TABLE_PTG_TARGET_TRANS_0.second); iht(objects::TCS_SUBSYSTEM, NML, 0, EIVE_TABLE_PTG_TARGET_TRANS_0.second); iht(objects::ACS_SUBSYSTEM, acs::AcsMode::PTG_TARGET, 0, EIVE_TABLE_PTG_TARGET_TRANS_0.second); check(ss.addTable( @@ -338,6 +347,7 @@ void buildPtgTargetGsSequence(Subsystem& ss, ModeListEntry& eh) { ctxc); // Build PTG_TARGET_GS transition 0 + iht(objects::EPS_SUBSYSTEM, NML, 0, EIVE_TABLE_PTG_TARGET_GS_TRANS_0.second); iht(objects::TCS_SUBSYSTEM, NML, 0, EIVE_TABLE_PTG_TARGET_GS_TRANS_0.second); iht(objects::ACS_SUBSYSTEM, acs::AcsMode::PTG_TARGET_GS, 0, EIVE_TABLE_PTG_TARGET_GS_TRANS_0.second); @@ -379,6 +389,7 @@ void buildPtgInertialSequence(Subsystem& ss, ModeListEntry& eh) { ctxc); // Build PTG_INERTIAL transition 0 + iht(objects::EPS_SUBSYSTEM, NML, 0, EIVE_TABLE_PTG_INERTIAL_TRANS_0.second); iht(objects::TCS_SUBSYSTEM, NML, 0, EIVE_TABLE_PTG_INERTIAL_TRANS_0.second); iht(objects::ACS_SUBSYSTEM, acs::AcsMode::PTG_INERTIAL, 0, EIVE_TABLE_PTG_INERTIAL_TRANS_0.second);