From 23b15cf3029b4f0ce0daeb2fb04b93723f7850a7 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 27 Sep 2023 11:55:33 +0200 Subject: [PATCH] add EPS to transitions --- mission/system/power/epsModeTree.cpp | 73 ++++++++++++++++++++++++++-- mission/system/systemTree.cpp | 14 ++++-- 2 files changed, 79 insertions(+), 8 deletions(-) diff --git a/mission/system/power/epsModeTree.cpp b/mission/system/power/epsModeTree.cpp index feeb6e5d..dbc67fd7 100644 --- a/mission/system/power/epsModeTree.cpp +++ b/mission/system/power/epsModeTree.cpp @@ -20,23 +20,86 @@ 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_TABLE_OFF_TRANS_1 = std::make_pair((OFF << 24) | 3, 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()); -auto EPS_TABLE_NORMAL_TRANS_1 = std::make_pair((NML << 24) | 3, FixedArrayList()); Subsystem& satsystem::eps::init() { ModeListEntry entry; buildOffSequence(SUBSYSTEM, entry); buildNormalSequence(SUBSYSTEM, entry); - SUBSYSTEM.setInitialMode(OFF); + SUBSYSTEM.setInitialMode(NML); return SUBSYSTEM; } namespace { -void buildOffSequence(Subsystem& ss, ModeListEntry& eh) {} +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); + }; -void buildNormalSequence(Subsystem& ss, ModeListEntry& eh) {} // namespace + // 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); +} +} // namespace + +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 target table + iht(objects::POWER_CONTROLLER, NML, 0, EPS_TABLE_NORMAL_TGT.second); + 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/systemTree.cpp b/mission/system/systemTree.cpp index 6c45a813..c9894f21 100644 --- a/mission/system/systemTree.cpp +++ b/mission/system/systemTree.cpp @@ -144,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); @@ -154,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, @@ -190,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, @@ -227,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)), @@ -264,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( @@ -302,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( @@ -341,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); @@ -382,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);