From acd365e42127d644552652406c941ae0e3db12fd Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 26 Aug 2022 16:12:22 +0200 Subject: [PATCH] Mode introspection and fixes --- bsp_q7s/core/CoreController.cpp | 4 ++++ bsp_q7s/core/CoreController.h | 2 ++ bsp_q7s/core/InitMission.cpp | 10 ++++++---- fsfw | 2 +- linux/devices/GPSHyperionLinuxController.cpp | 5 +++++ linux/devices/GPSHyperionLinuxController.h | 1 + mission/controller/AcsController.cpp | 4 ++++ mission/controller/AcsController.h | 2 ++ mission/controller/ThermalController.cpp | 4 ++++ mission/controller/ThermalController.h | 2 ++ mission/system/DualLaneAssemblyBase.cpp | 5 +++++ mission/system/DualLaneAssemblyBase.h | 2 ++ mission/system/RwAssembly.cpp | 4 ++++ mission/system/RwAssembly.h | 4 ++++ mission/system/TcsBoardAssembly.cpp | 4 ++++ mission/system/TcsBoardAssembly.h | 2 ++ mission/system/definitions.h | 3 ++- 17 files changed, 54 insertions(+), 6 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 630c4550..41339331 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1851,3 +1851,7 @@ bool CoreController::isNumber(const std::string &s) { return !s.empty() && std::find_if(s.begin(), s.end(), [](unsigned char c) { return !std::isdigit(c); }) == s.end(); } + +ModeDefinitionHelper CoreController::getModeDefinitionHelper() { + return ModeDefinitionHelper::create(); +} \ No newline at end of file diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 2cfe4e08..8c3aa6a5 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -93,6 +93,8 @@ class CoreController : public ExtendedControllerBase { ReturnValue_t handleAction(core::XscRebootObcAction* action); ReturnValue_t handleAction(core::RebootObcAction* action); + ModeDefinitionHelper getModeDefinitionHelper() override; + ReturnValue_t handleCommandMessage(CommandMessage* message) override; void performControlOperation() override; diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index ddbab300..6f5ce3a6 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -51,10 +51,10 @@ void printEnum(ParameterIF* param) { for (auto iter : param->getEnumValues()) { printf("---enum value %li: \"%s\"\n", iter, param->getEnumDescriptions()[i++]); } -} +}*/ void printModes(HasModesIF* object) { - ModeHelperIF* modeHelper = object->getModeHelper(); + const ModeHelper* modeHelper = object->getModeHelper(); auto modes = modeHelper->getModes(); @@ -68,7 +68,7 @@ void printModes(HasModesIF* object) { printf("--submode \"%s\" (%i)\n", submode.second, submode.first); } } -}*/ +} void printAction(HasActionsIF* actionIf) { auto actionMap = actionIf->getActionHelper()->getActionMap(); @@ -178,11 +178,13 @@ void initmission::initMission() { printAction(actionIf); } - /*HasModesIF* hasmodesIF = dynamic_cast(iter.second); + HasModesIF* hasmodesIF = dynamic_cast(iter.second); if (hasmodesIF != nullptr) { printModes(hasmodesIF); } + /* + HousekeepingIF* hasHousekeeping = dynamic_cast(iter.second); if (hasHousekeeping != nullptr) { printHousekeeping(hasHousekeeping); diff --git a/fsfw b/fsfw index d634bdb7..c7e6f01f 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit d634bdb7753282f009bd2581945b861d9836c1a4 +Subproject commit c7e6f01f9bdd542ceb0bc7b948b5af426ef9aa95 diff --git a/linux/devices/GPSHyperionLinuxController.cpp b/linux/devices/GPSHyperionLinuxController.cpp index d0f97566..70e46bc3 100644 --- a/linux/devices/GPSHyperionLinuxController.cpp +++ b/linux/devices/GPSHyperionLinuxController.cpp @@ -53,6 +53,11 @@ ReturnValue_t GPSHyperionLinuxController::checkModeCommand(Mode_t mode, Submode_ return HasReturnvaluesIF::RETURN_OK; } +ModeDefinitionHelper GPSHyperionLinuxController::getModeDefinitionHelper() { + //TODO verify which modes are supported + return ModeDefinitionHelper::create(); +} + ReturnValue_t GPSHyperionLinuxController::executeAction(Action *action) { return action->handle(); } diff --git a/linux/devices/GPSHyperionLinuxController.h b/linux/devices/GPSHyperionLinuxController.h index 35b01a00..cbb383e0 100644 --- a/linux/devices/GPSHyperionLinuxController.h +++ b/linux/devices/GPSHyperionLinuxController.h @@ -39,6 +39,7 @@ class GPSHyperionLinuxController : public ExtendedControllerBase { LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t* msToReachTheMode) override; + ModeDefinitionHelper getModeDefinitionHelper() override; ReturnValue_t executeAction(Action* action) override; ReturnValue_t handleAction(GPSHyperionLinuxAction * action); ReturnValue_t initialize() override; diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 4aea53a0..5f093d41 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -61,6 +61,10 @@ ReturnValue_t AcsController::checkModeCommand(Mode_t mode, Submode_t submode, return HasReturnvaluesIF::RETURN_OK; } +ModeDefinitionHelper AcsController::getModeDefinitionHelper() { + return ModeDefinitionHelper::create(); +} + void AcsController::copyMgmData() { { PoolReadGuard pg(&mgm0Lis3Set); diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h index 8dbe38aa..c791b16d 100644 --- a/mission/controller/AcsController.h +++ b/mission/controller/AcsController.h @@ -30,6 +30,8 @@ class AcsController : public ExtendedControllerBase { ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t* msToReachTheMode) override; + ModeDefinitionHelper getModeDefinitionHelper() override; + // MGMs acsctrl::MgmData mgmData; diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 9e0fbd5a..77f6b006 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -231,6 +231,10 @@ ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, Submode_t submode return RETURN_OK; } +ModeDefinitionHelper ThermalController::getModeDefinitionHelper() { + return ModeDefinitionHelper::create(); +} + void ThermalController::copySensors() { PoolReadGuard pg0(&max31865Set0); if (pg0.getReadResult() == HasReturnvaluesIF::RETURN_OK) { diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 29661d5e..d8976a49 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -27,6 +27,8 @@ class ThermalController : public ExtendedControllerBase { virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t* msToReachTheMode) override; + ModeDefinitionHelper getModeDefinitionHelper() override; + private: static const uint32_t DELAY = 500; diff --git a/mission/system/DualLaneAssemblyBase.cpp b/mission/system/DualLaneAssemblyBase.cpp index 020ce1ff..31b90829 100644 --- a/mission/system/DualLaneAssemblyBase.cpp +++ b/mission/system/DualLaneAssemblyBase.cpp @@ -1,6 +1,7 @@ #include "DualLaneAssemblyBase.h" #include +#include #include "OBSWConfig.h" @@ -92,6 +93,10 @@ ReturnValue_t DualLaneAssemblyBase::pwrStateMachineWrapper() { return RETURN_OK; } +ModeDefinitionHelper DualLaneAssemblyBase::getModeDefinitionHelper() { + return ModeDefinitionHelper::create(); +} + ReturnValue_t DualLaneAssemblyBase::isModeCombinationValid(Mode_t mode, Submode_t submode) { using namespace duallane; if (submode != A_SIDE and submode != B_SIDE and submode != DUAL_MODE) { diff --git a/mission/system/DualLaneAssemblyBase.h b/mission/system/DualLaneAssemblyBase.h index 4233d860..45f6cf4f 100644 --- a/mission/system/DualLaneAssemblyBase.h +++ b/mission/system/DualLaneAssemblyBase.h @@ -22,6 +22,8 @@ class DualLaneAssemblyBase : public AssemblyBase, public ConfirmsFailuresIF { pcdu::Switches switch1, pcdu::Switches switch2, Event pwrSwitchTimeoutEvent, Event sideSwitchNotAllowedEvent, Event transitionOtherSideFailedEvent); + ModeDefinitionHelper getModeDefinitionHelper() override; + protected: // This helper object complete encapsulates power switching DualLanePowerStateMachine pwrStateMachine; diff --git a/mission/system/RwAssembly.cpp b/mission/system/RwAssembly.cpp index 7149747e..fe800241 100644 --- a/mission/system/RwAssembly.cpp +++ b/mission/system/RwAssembly.cpp @@ -189,3 +189,7 @@ void RwAssembly::handleModeTransitionFailed(ReturnValue_t result) { } } } + +ModeDefinitionHelper RwAssembly::getModeDefinitionHelper() { + return ModeDefinitionHelper::create(); +} \ No newline at end of file diff --git a/mission/system/RwAssembly.h b/mission/system/RwAssembly.h index 482a18a3..dd60574b 100644 --- a/mission/system/RwAssembly.h +++ b/mission/system/RwAssembly.h @@ -15,6 +15,10 @@ class RwAssembly : public AssemblyBase { RwAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher, power::Switch_t switcher, RwHelper helper); + ~RwAssembly() {} + + ModeDefinitionHelper getModeDefinitionHelper() override; + private: static constexpr uint8_t NUMBER_RWS = 4; RwHelper helper; diff --git a/mission/system/TcsBoardAssembly.cpp b/mission/system/TcsBoardAssembly.cpp index f973335e..dacc0f06 100644 --- a/mission/system/TcsBoardAssembly.cpp +++ b/mission/system/TcsBoardAssembly.cpp @@ -203,3 +203,7 @@ void TcsBoardAssembly::handleModeTransitionFailed(ReturnValue_t result) { triggerEvent(MODE_TRANSITION_FAILED, result); } } + +ModeDefinitionHelper TcsBoardAssembly::getModeDefinitionHelper(){ + return ModeDefinitionHelper::create(); +} \ No newline at end of file diff --git a/mission/system/TcsBoardAssembly.h b/mission/system/TcsBoardAssembly.h index 10b451b2..7e947024 100644 --- a/mission/system/TcsBoardAssembly.h +++ b/mission/system/TcsBoardAssembly.h @@ -22,6 +22,8 @@ class TcsBoardAssembly : public AssemblyBase, public ConfirmsFailuresIF { ReturnValue_t initialize() override; + ModeDefinitionHelper getModeDefinitionHelper(); + private: static constexpr uint8_t NUMBER_RTDS = 16; PowerSwitcher switcher; diff --git a/mission/system/definitions.h b/mission/system/definitions.h index aee127bb..b7cde14e 100644 --- a/mission/system/definitions.h +++ b/mission/system/definitions.h @@ -2,6 +2,7 @@ #define MISSION_SYSTEM_DEFINITIONS_H_ #include +#include namespace power { @@ -12,7 +13,7 @@ enum class OpCodes { NONE, TO_OFF_DONE, TO_NOT_OFF_DONE, TIMEOUT_OCCURED }; namespace duallane { -enum Submodes : Submode_t { A_SIDE = 0, B_SIDE = 1, DUAL_MODE = 2 }; +FSFW_CLASSLESS_ENUM(Submodes, Submode_t, ((A_SIDE, 0, "Side A")) ((B_SIDE, 1, "Side B")) ((DUAL_MODE, 2, "Dual mode"))) } // namespace duallane