307 lines
14 KiB
C++
307 lines
14 KiB
C++
#include "acsModeTree.h"
|
|
|
|
#include <commonObjects.h>
|
|
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
|
#include <fsfw/modes/HasModesIF.h>
|
|
#include <fsfw/subsystem/Subsystem.h>
|
|
#include <fsfw/subsystem/modes/ModeDefinitions.h>
|
|
|
|
#include "mission/controller/controllerdefinitions/AcsControllerDefinitions.h"
|
|
|
|
// Alias for checker function
|
|
const auto CHK = satsystem::checkInsert;
|
|
static const auto OFF = HasModesIF::MODE_OFF;
|
|
static const auto NML = DeviceHandlerIF::MODE_NORMAL;
|
|
|
|
auto ACS_SEQUENCE_OFF = std::make_pair(acs::CtrlModes::OFF, FixedArrayList<ModeListEntry, 2>());
|
|
auto ACS_TABLE_OFF_TGT =
|
|
std::make_pair((acs::CtrlModes::OFF << 8) | 1, FixedArrayList<ModeListEntry, 0>());
|
|
auto ACS_TABLE_OFF_TRANS =
|
|
std::make_pair((acs::CtrlModes::OFF << 8) | 2, FixedArrayList<ModeListEntry, 6>());
|
|
|
|
auto ACS_SEQUENCE_DETUMBLE =
|
|
std::make_pair(acs::CtrlModes::DETUMBLE, FixedArrayList<ModeListEntry, 3>());
|
|
auto ACS_TABLE_DETUMBLE_TGT =
|
|
std::make_pair((acs::CtrlModes::DETUMBLE << 8) | 1, FixedArrayList<ModeListEntry, 4>());
|
|
auto ACS_TABLE_DETUMBLE_TRANS_0 =
|
|
std::make_pair((acs::CtrlModes::DETUMBLE << 8) | 2, FixedArrayList<ModeListEntry, 5>());
|
|
auto ACS_TABLE_DETUMBLE_TRANS_1 =
|
|
std::make_pair((acs::CtrlModes::DETUMBLE << 8) | 3, FixedArrayList<ModeListEntry, 1>());
|
|
|
|
auto ACS_SEQUENCE_SAFE =
|
|
std::make_pair(acs::CtrlModes::SAFE, FixedArrayList<ModeListEntry, 3>());
|
|
auto ACS_TABLE_SAFE_TGT =
|
|
std::make_pair((acs::CtrlModes::SAFE << 8) | 1, FixedArrayList<ModeListEntry, 4>());
|
|
auto ACS_TABLE_SAFE_TRANS_0 =
|
|
std::make_pair((acs::CtrlModes::SAFE << 8) | 2, FixedArrayList<ModeListEntry, 5>());
|
|
auto ACS_TABLE_SAFE_TRANS_1 =
|
|
std::make_pair((acs::CtrlModes::SAFE << 8) | 3, FixedArrayList<ModeListEntry, 1>());
|
|
|
|
auto ACS_SEQUENCE_IDLE =
|
|
std::make_pair(acs::CtrlModes::IDLE, FixedArrayList<ModeListEntry, 3>());
|
|
auto ACS_TABLE_IDLE_TGT =
|
|
std::make_pair((acs::CtrlModes::IDLE << 8) | 1, FixedArrayList<ModeListEntry, 5>());
|
|
auto ACS_TABLE_IDLE_TRANS_0 =
|
|
std::make_pair((acs::CtrlModes::IDLE << 8) | 2, FixedArrayList<ModeListEntry, 5>());
|
|
auto ACS_TABLE_IDLE_TRANS_1 =
|
|
std::make_pair((acs::CtrlModes::IDLE << 8) | 3, FixedArrayList<ModeListEntry, 1>());
|
|
|
|
auto ACS_SEQUENCE_TARGET_PT =
|
|
std::make_pair(acs::CtrlModes::TARGET_PT, FixedArrayList<ModeListEntry, 3>());
|
|
auto ACS_TABLE_TARGET_PT_TGT =
|
|
std::make_pair((acs::CtrlModes::TARGET_PT << 8) | 1, FixedArrayList<ModeListEntry, 5>());
|
|
auto ACS_TABLE_TARGET_PT_TRANS_0 =
|
|
std::make_pair((acs::CtrlModes::TARGET_PT << 8) | 2, FixedArrayList<ModeListEntry, 5>());
|
|
auto ACS_TABLE_TARGET_PT_TRANS_1 =
|
|
std::make_pair((acs::CtrlModes::TARGET_PT << 8) | 3, FixedArrayList<ModeListEntry, 1>());
|
|
|
|
enum InsertType {
|
|
TABLE,
|
|
SEQ
|
|
};
|
|
|
|
void satsystem::acsSubsystemInit() {
|
|
ModeListEntry entry;
|
|
Subsystem* acsSubsystem = new Subsystem(objects::ACS_SUBSYSTEM, objects::EIVE_SYSTEM, 20, 20);
|
|
buildOffSequence(acsSubsystem, entry);
|
|
buildSafeSequence(acsSubsystem, entry);
|
|
buildDetumbleSequence(acsSubsystem, entry);
|
|
buildIdleSequence(acsSubsystem, entry);
|
|
buildTargetPtSequence(acsSubsystem, entry);
|
|
acsSubsystem->setInitialMode(HasModesIF::MODE_OFF);
|
|
}
|
|
|
|
void satsystem::buildOffSequence(Subsystem* ss, ModeListEntry& eh) {
|
|
std::string context = "satsystem::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);
|
|
CHK(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);
|
|
CHK(sequence.insert(eh), ctxc);
|
|
};
|
|
|
|
// OFF Target table is empty
|
|
ss->addTable(&ACS_TABLE_OFF_TGT.second, ACS_TABLE_OFF_TGT.first, false, true);
|
|
|
|
// Build OFF transition
|
|
iht(objects::ACS_CONTROLLER, OFF, 0, ACS_TABLE_OFF_TRANS.second);
|
|
iht(objects::IMTQ_HANDLER, OFF, 0, ACS_TABLE_OFF_TRANS.second);
|
|
iht(objects::STAR_TRACKER, OFF, 0, ACS_TABLE_OFF_TRANS.second);
|
|
iht(objects::ACS_BOARD_ASS, OFF, 0, ACS_TABLE_OFF_TRANS.second);
|
|
iht(objects::SUS_BOARD_ASS, OFF, 0, ACS_TABLE_OFF_TRANS.second);
|
|
iht(objects::RW_ASS, OFF, 0, ACS_TABLE_OFF_TRANS.second);
|
|
ss->addTable(&ACS_TABLE_OFF_TRANS.second, ACS_TABLE_OFF_TRANS.first, false, true);
|
|
|
|
// Build OFF sequence
|
|
ihs(ACS_SEQUENCE_OFF.second, ACS_TABLE_OFF_TGT.first, 0, false);
|
|
ihs(ACS_SEQUENCE_OFF.second, ACS_TABLE_OFF_TRANS.first, 0, false);
|
|
ss->addSequence(&ACS_SEQUENCE_OFF.second, ACS_SEQUENCE_OFF.first, ACS_SEQUENCE_OFF.first, false,
|
|
true);
|
|
}
|
|
|
|
void satsystem::buildSafeSequence(Subsystem* ss, ModeListEntry& eh) {
|
|
std::string context = "satsystem::buildSafeSequence";
|
|
auto ctxc = context.c_str();
|
|
// Insert Helper Table
|
|
auto iht = [&](object_id_t obj, Mode_t mode, Submode_t submode,
|
|
ArrayList<ModeListEntry>& sequence) {
|
|
eh.setObject(obj);
|
|
eh.setMode(mode);
|
|
eh.setSubmode(submode);
|
|
CHK(sequence.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);
|
|
CHK(sequence.insert(eh), ctxc);
|
|
};
|
|
// Build SAFE target
|
|
iht(objects::ACS_CONTROLLER, acs::CtrlModes::SAFE, 0, ACS_TABLE_SAFE_TGT.second);
|
|
iht(objects::IMTQ_HANDLER, NML, 0, ACS_TABLE_SAFE_TGT.second);
|
|
iht(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_SAFE_TGT.second);
|
|
iht(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_SAFE_TGT.second);
|
|
ss->addTable(&ACS_TABLE_SAFE_TGT.second, ACS_TABLE_OFF_TGT.first, false, true);
|
|
|
|
// Build SAFE transition 0
|
|
iht(objects::IMTQ_HANDLER, NML, 0, ACS_TABLE_SAFE_TRANS_0.second);
|
|
iht(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_SAFE_TRANS_0.second);
|
|
iht(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_SAFE_TRANS_0.second);
|
|
iht(objects::STAR_TRACKER, OFF, 0, ACS_TABLE_SAFE_TRANS_0.second);
|
|
iht(objects::RW_ASS, OFF, 0, ACS_TABLE_SAFE_TRANS_0.second);
|
|
ss->addTable(&ACS_TABLE_SAFE_TRANS_0.second, ACS_TABLE_SAFE_TRANS_0.first, false, true);
|
|
|
|
// Build SAFE transition 1
|
|
iht(objects::ACS_CONTROLLER, acs::CtrlModes::SAFE, 0, ACS_TABLE_SAFE_TRANS_1.second);
|
|
ss->addTable(&ACS_TABLE_SAFE_TRANS_1.second, ACS_TABLE_SAFE_TRANS_1.first, false, true);
|
|
|
|
// Build SAFE sequence
|
|
ihs(ACS_SEQUENCE_SAFE.second, ACS_TABLE_SAFE_TGT.first, 0, false);
|
|
ihs(ACS_SEQUENCE_SAFE.second, ACS_TABLE_SAFE_TRANS_0.first, 0, false);
|
|
ihs(ACS_SEQUENCE_SAFE.second, ACS_TABLE_SAFE_TRANS_1.first, 0, false);
|
|
ss->addSequence(&ACS_SEQUENCE_SAFE.second, ACS_SEQUENCE_SAFE.first, ACS_SEQUENCE_OFF.first, false,
|
|
true);
|
|
}
|
|
|
|
void satsystem::buildDetumbleSequence(Subsystem* ss, ModeListEntry& eh) {
|
|
std::string context = "satsystem::buildDetumbleSequence";
|
|
auto ctxc = context.c_str();
|
|
// Insert Helper Table
|
|
auto iht = [&](object_id_t obj, Mode_t mode, Submode_t submode,
|
|
ArrayList<ModeListEntry>& sequence) {
|
|
eh.setObject(obj);
|
|
eh.setMode(mode);
|
|
eh.setSubmode(submode);
|
|
CHK(sequence.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);
|
|
CHK(sequence.insert(eh), ctxc);
|
|
};
|
|
// Build DETUMBLE target
|
|
iht(objects::ACS_CONTROLLER, acs::CtrlModes::DETUMBLE, 0, ACS_TABLE_DETUMBLE_TGT.second);
|
|
iht(objects::IMTQ_HANDLER, NML, 0, ACS_TABLE_DETUMBLE_TGT.second);
|
|
iht(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_DETUMBLE_TGT.second);
|
|
iht(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_DETUMBLE_TGT.second);
|
|
ss->addTable(&ACS_TABLE_DETUMBLE_TGT.second, ACS_TABLE_DETUMBLE_TGT.first, false, true);
|
|
|
|
// Build DETUMBLE transition 0
|
|
iht(objects::IMTQ_HANDLER, NML, 0, ACS_TABLE_DETUMBLE_TRANS_0.second);
|
|
iht(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_DETUMBLE_TRANS_0.second);
|
|
iht(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_DETUMBLE_TRANS_0.second);
|
|
iht(objects::STAR_TRACKER, OFF, 0, ACS_TABLE_DETUMBLE_TRANS_0.second);
|
|
iht(objects::RW_ASS, OFF, 0, ACS_TABLE_DETUMBLE_TRANS_0.second);
|
|
ss->addTable(&ACS_TABLE_DETUMBLE_TRANS_0.second, ACS_TABLE_DETUMBLE_TRANS_0.first, false, true);
|
|
|
|
// Build DETUMBLE transition 1
|
|
iht(objects::ACS_CONTROLLER, acs::CtrlModes::DETUMBLE, 0, ACS_TABLE_DETUMBLE_TRANS_1.second);
|
|
ss->addTable(&ACS_TABLE_DETUMBLE_TRANS_1.second, ACS_TABLE_DETUMBLE_TRANS_1.first, false, true);
|
|
|
|
// Build DETUMBLE sequence
|
|
ihs(ACS_SEQUENCE_DETUMBLE.second, ACS_TABLE_DETUMBLE_TGT.first, 0, false);
|
|
ihs(ACS_SEQUENCE_DETUMBLE.second, ACS_TABLE_DETUMBLE_TRANS_0.first, 0, false);
|
|
ihs(ACS_SEQUENCE_DETUMBLE.second, ACS_TABLE_DETUMBLE_TRANS_1.first, 0, false);
|
|
ss->addSequence(&ACS_SEQUENCE_DETUMBLE.second, ACS_SEQUENCE_DETUMBLE.first,
|
|
ACS_SEQUENCE_DETUMBLE.first, false, true);
|
|
}
|
|
|
|
|
|
void satsystem::buildIdleSequence(Subsystem* ss, ModeListEntry& eh) {
|
|
std::string context = "satsystem::buildIdleSequence";
|
|
auto ctxc = context.c_str();
|
|
// Insert Helper Table
|
|
auto iht = [&](object_id_t obj, Mode_t mode, Submode_t submode,
|
|
ArrayList<ModeListEntry>& sequence) {
|
|
eh.setObject(obj);
|
|
eh.setMode(mode);
|
|
eh.setSubmode(submode);
|
|
CHK(sequence.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);
|
|
CHK(sequence.insert(eh), ctxc);
|
|
};
|
|
// Build IDLE target
|
|
iht(objects::ACS_CONTROLLER, acs::CtrlModes::IDLE, 0, ACS_TABLE_IDLE_TGT.second);
|
|
iht(objects::IMTQ_HANDLER, NML, 0, ACS_TABLE_IDLE_TGT.second);
|
|
iht(objects::RW_ASS, NML, 0, ACS_TABLE_IDLE_TGT.second);
|
|
iht(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_IDLE_TGT.second);
|
|
iht(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_IDLE_TGT.second);
|
|
ss->addTable(&ACS_TABLE_IDLE_TGT.second, ACS_TABLE_IDLE_TGT.first, false, true);
|
|
|
|
// Build IDLE transition 0
|
|
iht(objects::IMTQ_HANDLER, NML, 0, ACS_TABLE_DETUMBLE_TRANS_0.second);
|
|
iht(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_DETUMBLE_TRANS_0.second);
|
|
iht(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_DETUMBLE_TRANS_0.second);
|
|
iht(objects::RW_ASS, NML, 0, ACS_TABLE_DETUMBLE_TRANS_0.second);
|
|
iht(objects::STAR_TRACKER, OFF, 0, ACS_TABLE_DETUMBLE_TRANS_0.second);
|
|
ss->addTable(&ACS_TABLE_IDLE_TRANS_0.second, ACS_TABLE_IDLE_TRANS_0.first, false, true);
|
|
|
|
// Build IDLE transition 1
|
|
iht(objects::ACS_CONTROLLER, acs::CtrlModes::IDLE, 0, ACS_TABLE_DETUMBLE_TRANS_1.second);
|
|
ss->addTable(&ACS_TABLE_IDLE_TRANS_1.second, ACS_TABLE_IDLE_TRANS_1.first, false, true);
|
|
|
|
// Build IDLE sequence
|
|
ihs(ACS_SEQUENCE_IDLE.second, ACS_TABLE_IDLE_TGT.first, 0, false);
|
|
ihs(ACS_SEQUENCE_IDLE.second, ACS_TABLE_IDLE_TRANS_0.first, 0, false);
|
|
ihs(ACS_SEQUENCE_IDLE.second, ACS_TABLE_IDLE_TRANS_1.first, 0, false);
|
|
ss->addSequence(&ACS_SEQUENCE_IDLE.second, ACS_SEQUENCE_IDLE.first,
|
|
ACS_SEQUENCE_IDLE.first, false, true);
|
|
}
|
|
|
|
void satsystem::buildTargetPtSequence(Subsystem* ss, ModeListEntry& eh) {
|
|
std::string context = "satsystem::buildTargetPtSequence";
|
|
auto ctxc = context.c_str();
|
|
// Insert Helper Table
|
|
auto iht = [&](object_id_t obj, Mode_t mode, Submode_t submode,
|
|
ArrayList<ModeListEntry>& sequence) {
|
|
eh.setObject(obj);
|
|
eh.setMode(mode);
|
|
eh.setSubmode(submode);
|
|
CHK(sequence.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);
|
|
CHK(sequence.insert(eh), ctxc);
|
|
};
|
|
|
|
// Build TARGET PT table
|
|
iht(objects::ACS_CONTROLLER, acs::CtrlModes::TARGET_PT, 0, ACS_TABLE_TARGET_PT_TGT.second);
|
|
iht(objects::IMTQ_HANDLER, NML, 0, ACS_TABLE_TARGET_PT_TGT.second);
|
|
iht(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_TARGET_PT_TGT.second);
|
|
iht(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_TARGET_PT_TGT.second);
|
|
iht(objects::RW_ASS, NML, 0, ACS_TABLE_TARGET_PT_TGT.second);
|
|
iht(objects::STAR_TRACKER, NML, 0, ACS_TABLE_TARGET_PT_TGT.second);
|
|
ss->addTable(&ACS_TABLE_TARGET_PT_TGT.second, ACS_TABLE_TARGET_PT_TGT.first, false, true);
|
|
|
|
// Build TARGET PT transition 0
|
|
iht(objects::IMTQ_HANDLER, NML, 0, ACS_TABLE_TARGET_PT_TRANS_0.second);
|
|
iht(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_TARGET_PT_TRANS_0.second);
|
|
iht(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_TARGET_PT_TRANS_0.second);
|
|
iht(objects::RW_ASS, NML, 0, ACS_TABLE_TARGET_PT_TRANS_0.second);
|
|
iht(objects::STAR_TRACKER, NML, 0, ACS_TABLE_TARGET_PT_TRANS_0.second);
|
|
ss->addTable(&ACS_TABLE_TARGET_PT_TRANS_0.second, ACS_TABLE_TARGET_PT_TRANS_0.first, false, true);
|
|
|
|
// Build TARGET PT transition 1
|
|
iht(objects::ACS_CONTROLLER, acs::CtrlModes::TARGET_PT, 0, ACS_TABLE_TARGET_PT_TRANS_1.second);
|
|
ss->addTable(&ACS_TABLE_TARGET_PT_TRANS_1.second, ACS_TABLE_TARGET_PT_TRANS_1.first, false, true);
|
|
|
|
// Build IDLE sequence
|
|
ihs(ACS_SEQUENCE_TARGET_PT.second, ACS_TABLE_TARGET_PT_TGT.first, 0, false);
|
|
ihs(ACS_SEQUENCE_TARGET_PT.second, ACS_TABLE_TARGET_PT_TRANS_0.first, 0, false);
|
|
ihs(ACS_SEQUENCE_TARGET_PT.second, ACS_TABLE_TARGET_PT_TRANS_1.first, 0, false);
|
|
ss->addSequence(&ACS_SEQUENCE_TARGET_PT.second, ACS_SEQUENCE_TARGET_PT.first,
|
|
ACS_SEQUENCE_TARGET_PT.first, false, true);
|
|
}
|
|
|
|
void satsystem::checkInsert(ReturnValue_t result, const char* ctx) {
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
sif::error << "Insertion failed at " << ctx << std::endl;
|
|
}
|
|
}
|