eive-obsw/mission/system/tcs/tcsModeTree.cpp

127 lines
5.3 KiB
C++
Raw Normal View History

2022-11-11 11:23:13 +01:00
#include "tcsModeTree.h"
2022-11-14 13:46:26 +01:00
#include "eive/objects.h"
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
2022-11-11 11:23:13 +01:00
#include "fsfw/subsystem/Subsystem.h"
2023-04-06 16:50:33 +02:00
#include "mission/system/treeUtil.h"
2022-11-11 11:23:13 +01:00
2023-02-13 01:26:30 +01:00
TcsSubsystem satsystem::tcs::SUBSYSTEM(objects::TCS_SUBSYSTEM, 12, 24);
2022-11-11 11:23:13 +01:00
namespace {
// Alias for checker function
const auto check = subsystem::checkInsert;
2022-11-14 13:46:26 +01:00
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;
2023-01-23 11:31:15 +01:00
auto TCS_SEQUENCE_OFF = std::make_pair(OFF, FixedArrayList<ModeListEntry, 3>());
2022-11-14 17:17:34 +01:00
auto TCS_TABLE_OFF_TGT = std::make_pair((OFF << 24) | 1, FixedArrayList<ModeListEntry, 2>());
2023-03-06 17:59:28 +01:00
auto TCS_TABLE_OFF_TRANS_0 = std::make_pair((OFF << 24) | 2, FixedArrayList<ModeListEntry, 2>());
auto TCS_TABLE_OFF_TRANS_1 = std::make_pair((OFF << 24) | 3, FixedArrayList<ModeListEntry, 7>());
2022-11-14 13:46:26 +01:00
2023-01-23 11:31:15 +01:00
auto TCS_SEQUENCE_NORMAL = std::make_pair(NML, FixedArrayList<ModeListEntry, 3>());
2022-11-14 17:17:34 +01:00
auto TCS_TABLE_NORMAL_TGT = std::make_pair((NML << 24) | 1, FixedArrayList<ModeListEntry, 2>());
auto TCS_TABLE_NORMAL_TRANS_0 = std::make_pair((NML << 24) | 2, FixedArrayList<ModeListEntry, 7>());
2023-01-23 11:31:15 +01:00
auto TCS_TABLE_NORMAL_TRANS_1 = std::make_pair((NML << 24) | 3, FixedArrayList<ModeListEntry, 2>());
2022-11-14 13:46:26 +01:00
2023-02-10 17:52:46 +01:00
Subsystem& satsystem::tcs::init() {
2022-11-14 13:46:26 +01:00
ModeListEntry entry;
buildOffSequence(SUBSYSTEM, entry);
buildNormalSequence(SUBSYSTEM, entry);
SUBSYSTEM.setInitialMode(OFF);
2023-02-10 17:52:46 +01:00
return SUBSYSTEM;
2022-11-11 11:23:13 +01:00
}
2022-11-14 13:46:26 +01:00
namespace {
2022-11-14 16:58:01 +01:00
void buildOffSequence(Subsystem& ss, ModeListEntry& eh) {
std::string context = "satsystem::tcs::buildOffSequence";
auto ctxc = context.c_str();
// Insert Helper Table
auto iht = [&](object_id_t obj, Mode_t mode, Submode_t submode, ArrayList<ModeListEntry>& table) {
eh.setObject(obj);
eh.setMode(mode);
eh.setSubmode(submode);
check(table.insert(eh), ctxc);
};
// Insert Helper Sequence
auto ihs = [&](ArrayList<ModeListEntry>& sequence, Mode_t tableId, uint32_t waitSeconds,
bool checkSuccess) {
eh.setTableId(tableId);
eh.setWaitSeconds(waitSeconds);
eh.setCheckSuccess(checkSuccess);
check(sequence.insert(eh), ctxc);
};
2022-11-14 13:46:26 +01:00
2022-11-14 16:58:01 +01:00
// OFF target table is empty
2023-01-23 11:31:15 +01:00
check(ss.addTable(TableEntry(TCS_TABLE_OFF_TGT.first, &TCS_TABLE_OFF_TGT.second)), ctxc);
2022-11-14 16:58:01 +01:00
2023-03-06 17:59:28 +01:00
// Transition 1
2022-11-14 16:58:01 +01:00
iht(objects::THERMAL_CONTROLLER, OFF, 0, TCS_TABLE_OFF_TRANS_0.second);
2023-03-08 19:06:48 +01:00
check(ss.addTable(TableEntry(TCS_TABLE_OFF_TRANS_0.first, &TCS_TABLE_OFF_TRANS_0.second)), ctxc);
2023-03-06 17:59:28 +01:00
iht(objects::TCS_BOARD_ASS, OFF, 0, TCS_TABLE_OFF_TRANS_1.second);
iht(objects::TMP1075_HANDLER_TCS_0, OFF, 0, TCS_TABLE_OFF_TRANS_1.second);
iht(objects::TMP1075_HANDLER_TCS_1, OFF, 0, TCS_TABLE_OFF_TRANS_1.second);
iht(objects::TMP1075_HANDLER_PLPCDU_0, OFF, 0, TCS_TABLE_OFF_TRANS_1.second);
// TMP PL PCDU 1 is damaged
iht(objects::TMP1075_HANDLER_IF_BOARD, OFF, 0, TCS_TABLE_OFF_TRANS_1.second);
2023-01-23 11:31:15 +01:00
check(ss.addTable(TableEntry(TCS_TABLE_OFF_TRANS_1.first, &TCS_TABLE_OFF_TRANS_1.second)), ctxc);
2022-11-14 13:46:26 +01:00
2022-11-14 16:58:01 +01:00
ihs(TCS_SEQUENCE_OFF.second, TCS_TABLE_OFF_TGT.first, 0, false);
ihs(TCS_SEQUENCE_OFF.second, TCS_TABLE_OFF_TRANS_0.first, 0, false);
ihs(TCS_SEQUENCE_OFF.second, TCS_TABLE_OFF_TRANS_1.first, 0, false);
2023-01-23 11:31:15 +01:00
check(ss.addSequence(SequenceEntry(TCS_SEQUENCE_OFF.first, &TCS_SEQUENCE_OFF.second,
TCS_SEQUENCE_OFF.first)),
2022-11-14 16:58:01 +01:00
ctxc);
}
2022-11-14 17:17:34 +01:00
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<ModeListEntry>& table) {
eh.setObject(obj);
eh.setMode(mode);
eh.setSubmode(submode);
check(table.insert(eh), ctxc);
};
// Insert Helper Sequence
auto ihs = [&](ArrayList<ModeListEntry>& sequence, Mode_t tableId, uint32_t waitSeconds,
bool checkSuccess) {
eh.setTableId(tableId);
eh.setWaitSeconds(waitSeconds);
eh.setCheckSuccess(checkSuccess);
check(sequence.insert(eh), ctxc);
};
2023-03-06 17:59:28 +01:00
// Normal target table is empty
2023-01-23 11:44:03 +01:00
check(ss.addTable(TableEntry(TCS_TABLE_NORMAL_TGT.first, &TCS_TABLE_NORMAL_TGT.second)), ctxc);
2022-11-14 17:17:34 +01:00
iht(objects::TCS_BOARD_ASS, NML, 0, TCS_TABLE_NORMAL_TRANS_0.second);
iht(objects::TMP1075_HANDLER_TCS_0, NML, 0, TCS_TABLE_NORMAL_TRANS_0.second);
iht(objects::TMP1075_HANDLER_TCS_1, NML, 0, TCS_TABLE_NORMAL_TRANS_0.second);
iht(objects::TMP1075_HANDLER_PLPCDU_0, NML, 0, TCS_TABLE_NORMAL_TRANS_0.second);
2023-03-06 17:59:28 +01:00
// TMP PL PCDU 1 is damaged
2022-11-14 17:17:34 +01:00
iht(objects::TMP1075_HANDLER_IF_BOARD, NML, 0, TCS_TABLE_NORMAL_TRANS_0.second);
2023-01-23 11:44:03 +01:00
check(ss.addTable(TableEntry(TCS_TABLE_NORMAL_TRANS_0.first, &TCS_TABLE_NORMAL_TRANS_0.second)),
2022-11-14 17:17:34 +01:00
ctxc);
2023-03-06 17:59:28 +01:00
// Transition 1
2023-04-06 12:13:24 +02:00
iht(objects::THERMAL_CONTROLLER, HasModesIF::MODE_ON, 0, TCS_TABLE_NORMAL_TRANS_1.second);
2023-01-23 11:44:03 +01:00
check(ss.addTable(TableEntry(TCS_TABLE_NORMAL_TRANS_1.first, &TCS_TABLE_NORMAL_TRANS_1.second)),
2022-11-14 17:17:34 +01:00
ctxc);
ihs(TCS_SEQUENCE_NORMAL.second, TCS_TABLE_NORMAL_TGT.first, 0, false);
ihs(TCS_SEQUENCE_NORMAL.second, TCS_TABLE_NORMAL_TRANS_0.first, 0, false);
ihs(TCS_SEQUENCE_NORMAL.second, TCS_TABLE_NORMAL_TRANS_1.first, 0, false);
2023-01-23 11:44:03 +01:00
check(ss.addSequence(SequenceEntry(TCS_SEQUENCE_NORMAL.first, &TCS_SEQUENCE_NORMAL.second,
TCS_SEQUENCE_NORMAL.first)),
2022-11-14 17:17:34 +01:00
ctxc);
}
2022-11-14 13:46:26 +01:00
} // namespace