From 7182d9b8cc6e60f54aa0fdf7fc12a3d70ea638d7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 26 Jan 2023 17:18:05 +0100 Subject: [PATCH] start to manually transfer com mode tree from old PR --- common/config/eive/objects.h | 2 + mission/system/tree/CMakeLists.txt | 2 +- mission/system/tree/comModeTree.cpp | 110 ++++++++++++++++++++++++++++ mission/system/tree/comModeTree.h | 16 ++++ 4 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 mission/system/tree/comModeTree.cpp create mode 100644 mission/system/tree/comModeTree.h diff --git a/common/config/eive/objects.h b/common/config/eive/objects.h index 304af823..840b188c 100644 --- a/common/config/eive/objects.h +++ b/common/config/eive/objects.h @@ -142,6 +142,8 @@ enum commonObjects : uint32_t { ACS_SUBSYSTEM = 0x73010001, PL_SUBSYSTEM = 0x73010002, TCS_SUBSYSTEM = 0x73010003, + COM_SUBSYSTEM = 0x73010004, + TM_FUNNEL = 0x73000100, PUS_TM_FUNNEL = 0x73000101, CFDP_TM_FUNNEL = 0x73000102, diff --git a/mission/system/tree/CMakeLists.txt b/mission/system/tree/CMakeLists.txt index 9a48af42..9c5fecd5 100644 --- a/mission/system/tree/CMakeLists.txt +++ b/mission/system/tree/CMakeLists.txt @@ -1,2 +1,2 @@ -target_sources(${LIB_EIVE_MISSION} PRIVATE acsModeTree.cpp payloadModeTree.cpp +target_sources(${LIB_EIVE_MISSION} PRIVATE acsModeTree.cpp payloadModeTree.cpp comModeTree.cpp tcsModeTree.cpp system.cpp util.cpp) diff --git a/mission/system/tree/comModeTree.cpp b/mission/system/tree/comModeTree.cpp new file mode 100644 index 00000000..fc7b5635 --- /dev/null +++ b/mission/system/tree/comModeTree.cpp @@ -0,0 +1,110 @@ +#include "comModeTree.h" + +#include "eive/objects.h" +#include +#include +#include +#include + +#include "util.h" + +const auto check = subsystem::checkInsert; + +static const auto OFF = HasModesIF::MODE_OFF; +static const auto ON = HasModesIF::MODE_ON; +static const auto NML = DeviceHandlerIF::MODE_NORMAL; + +auto COM_SEQUENCE_TX_OFF = std::make_pair(NML << 24, FixedArrayList()); +auto COM_TABLE_TX_OFF_TGT = std::make_pair((NML << 24) | 1, FixedArrayList()); +auto COM_TABLE_TX_OFF_TRANS = std::make_pair((NML << 24) | 2, FixedArrayList()); + +auto COM_SEQUENCE_TX_ON = std::make_pair(NML << 24, FixedArrayList()); +auto COM_TABLE_TX_ON_TGT = std::make_pair((NML << 24) | 1, FixedArrayList()); +auto COM_TABLE_TX_ON_TRANS = std::make_pair((NML << 24) | 2, FixedArrayList()); + +namespace { +void buildTxOffSequence(Subsystem* ss, ModeListEntry& eh); +void buildTxOnSequence(Subsystem* ss, ModeListEntry& eh); +} // namespace + +void satsystem::com::init() { + ModeListEntry entry; + Subsystem* comSubsystem = new Subsystem(objects::COM_SUBSYSTEM, objects::EIVE_SYSTEM, 12, 24); + buildTxOffSequence(comSubsystem, entry); + buildTxOnSequence(comSubsystem, entry); + comSubsystem->setInitialMode(NML, 0 /* TODO: Which submode? */); +} + +namespace { + +void buildTxOffSequence(Subsystem* ss, ModeListEntry& eh) { + std::string context = "satsystem::com::buildTxOffSequence"; + 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); + }; + + // Build TX OFF table + iht(objects::SYRLINKS_HK_HANDLER, NML, 0/* TODO */, COM_TABLE_TX_OFF_TGT.second); + check(ss->addTable(TableEntry(COM_SEQUENCE_TX_OFF.first, &COM_TABLE_TX_OFF_TGT.second)), ctxc); + + // Build TX OFF transition + iht(objects::SYRLINKS_HK_HANDLER, NML, 0/* TODO */, COM_TABLE_TX_OFF_TRANS.second); + check(ss->addTable(TableEntry(COM_SEQUENCE_TX_OFF.first, &COM_TABLE_TX_OFF_TRANS.second)), ctxc); + + // Build TX OFF sequence + ihs(COM_SEQUENCE_TX_OFF.second, COM_TABLE_TX_OFF_TGT.first, 0, false); + ihs(COM_SEQUENCE_TX_OFF.second, COM_TABLE_TX_OFF_TRANS.first, 0, false); + check(ss->addSequence(SequenceEntry(COM_TABLE_TX_OFF_TRANS.first, &COM_TABLE_TX_OFF_TRANS.second, + COM_TABLE_TX_OFF_TRANS.first)), + ctxc); +} + +void buildTxOnSequence(Subsystem* ss, ModeListEntry& eh) { + std::string context = "satsystem::com::buildTxOnSequence"; + 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); + }; + + // Build TX ON table + iht(objects::SYRLINKS_HK_HANDLER, NML, /*TODO*/0, COM_TABLE_TX_ON_TGT.second); + check(ss->addTable(TableEntry(COM_SEQUENCE_TX_ON.first, &COM_TABLE_TX_ON_TGT.second)), ctxc); + + // Build TX ON transition + iht(objects::SYRLINKS_HK_HANDLER, NML, /*TODO*/0, COM_TABLE_TX_ON_TRANS.second); + check(ss->addTable(TableEntry(COM_SEQUENCE_TX_ON.first, &COM_TABLE_TX_ON_TRANS.second)), ctxc); + + // Build TX ON sequence + ihs(COM_SEQUENCE_TX_ON.second, COM_TABLE_TX_ON_TGT.first, 0, false); + ihs(COM_SEQUENCE_TX_ON.second, COM_TABLE_TX_ON_TRANS.first, 0, false); + check(ss->addSequence(SequenceEntry(COM_TABLE_TX_ON_TRANS.first, &COM_TABLE_TX_ON_TRANS.second, + COM_TABLE_TX_ON_TRANS.first)), + ctxc); +} + +} // namespace diff --git a/mission/system/tree/comModeTree.h b/mission/system/tree/comModeTree.h new file mode 100644 index 00000000..7b6dc1e2 --- /dev/null +++ b/mission/system/tree/comModeTree.h @@ -0,0 +1,16 @@ +#ifndef MISSION_SYSTEM_TREE_COMMODETREE_H_ +#define MISSION_SYSTEM_TREE_COMMODETREE_H_ + +#include + +namespace satsystem { + +namespace com { +extern Subsystem SUBSYSTEM; + +void init(); +} + +} // namespace satsystem + +#endif /* MISSION_SYSTEM_TREE_COMMODETREE_H_ */