#include "acsModeTree.h" #include #include #include #include #include #include "mission/controller/controllerdefinitions/AcsControllerDefinitions.h" void checkInsert(ReturnValue_t result, const char* ctx); void buildOffSequence(Subsystem* ss, ModeListEntry& eh); void buildDetumbleSequence(Subsystem* ss, ModeListEntry& entryHelper); void buildSafeSequence(Subsystem* ss, ModeListEntry& entryHelper); void buildIdleSequence(Subsystem* ss, ModeListEntry& entryHelper); void buildIdleChargeSequence(Subsystem* ss, ModeListEntry& entryHelper); void buildTargetPtSequence(Subsystem* ss, ModeListEntry& entryHelper); // Alias for checker function const auto check = 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 << 24, FixedArrayList()); auto ACS_TABLE_OFF_TGT = std::make_pair((acs::CtrlModes::OFF << 24) | 1, FixedArrayList()); auto ACS_TABLE_OFF_TRANS = std::make_pair((acs::CtrlModes::OFF << 24) | 2, FixedArrayList()); auto ACS_SEQUENCE_DETUMBLE = std::make_pair(acs::CtrlModes::DETUMBLE << 24, FixedArrayList()); auto ACS_TABLE_DETUMBLE_TGT = std::make_pair((acs::CtrlModes::DETUMBLE << 24) | 1, FixedArrayList()); auto ACS_TABLE_DETUMBLE_TRANS_0 = std::make_pair((acs::CtrlModes::DETUMBLE << 24) | 2, FixedArrayList()); auto ACS_TABLE_DETUMBLE_TRANS_1 = std::make_pair((acs::CtrlModes::DETUMBLE << 24) | 3, FixedArrayList()); auto ACS_SEQUENCE_SAFE = std::make_pair(acs::CtrlModes::SAFE << 24, FixedArrayList()); auto ACS_TABLE_SAFE_TGT = std::make_pair((acs::CtrlModes::SAFE << 24) | 1, FixedArrayList()); auto ACS_TABLE_SAFE_TRANS_0 = std::make_pair((acs::CtrlModes::SAFE << 24) | 2, FixedArrayList()); auto ACS_TABLE_SAFE_TRANS_1 = std::make_pair((acs::CtrlModes::SAFE << 24) | 3, FixedArrayList()); auto ACS_SEQUENCE_IDLE = std::make_pair(acs::CtrlModes::IDLE << 24, FixedArrayList()); auto ACS_TABLE_IDLE_TGT = std::make_pair((acs::CtrlModes::IDLE << 24) | 1, FixedArrayList()); auto ACS_TABLE_IDLE_TRANS_0 = std::make_pair((acs::CtrlModes::IDLE << 24) | 2, FixedArrayList()); auto ACS_TABLE_IDLE_TRANS_1 = std::make_pair((acs::CtrlModes::IDLE << 24) | 3, FixedArrayList()); auto ACS_SEQUENCE_IDLE_CHRG = std::make_pair(acs::CtrlModes::IDLE << 24 | (acs::IDLE_CHARGE << 8), FixedArrayList()); auto ACS_TABLE_IDLE_CHRG_TGT = std::make_pair( (acs::CtrlModes::IDLE << 24) | (acs::IDLE_CHARGE << 8) | 1, FixedArrayList()); auto ACS_TABLE_IDLE_CHRG_TRANS_0 = std::make_pair( (acs::CtrlModes::IDLE << 24) | (acs::IDLE_CHARGE << 8) | 2, FixedArrayList()); auto ACS_TABLE_IDLE_CHRG_TRANS_1 = std::make_pair( (acs::CtrlModes::IDLE << 24) | (acs::IDLE_CHARGE << 8) | 3, FixedArrayList()); auto ACS_SEQUENCE_TARGET_PT = std::make_pair(acs::CtrlModes::TARGET_PT, FixedArrayList()); auto ACS_TABLE_TARGET_PT_TGT = std::make_pair((acs::CtrlModes::TARGET_PT << 24) | 1, FixedArrayList()); auto ACS_TABLE_TARGET_PT_TRANS_0 = std::make_pair((acs::CtrlModes::TARGET_PT << 24) | 2, FixedArrayList()); auto ACS_TABLE_TARGET_PT_TRANS_1 = std::make_pair((acs::CtrlModes::TARGET_PT << 24) | 3, FixedArrayList()); void satsystem::initAcsSubsystem() { ModeListEntry entry; Subsystem* acsSubsystem = new Subsystem(objects::ACS_SUBSYSTEM, objects::EIVE_SYSTEM, 12, 24); buildOffSequence(acsSubsystem, entry); buildSafeSequence(acsSubsystem, entry); buildDetumbleSequence(acsSubsystem, entry); buildIdleSequence(acsSubsystem, entry); buildIdleChargeSequence(acsSubsystem, entry); buildTargetPtSequence(acsSubsystem, entry); acsSubsystem->setInitialMode(HasModesIF::MODE_OFF); } void 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& 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); }; // OFF Target table is empty check(ss->addTable(&ACS_TABLE_OFF_TGT.second, ACS_TABLE_OFF_TGT.first, false, true), ctxc); // 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); check(ss->addTable(&ACS_TABLE_OFF_TRANS.second, ACS_TABLE_OFF_TRANS.first, false, true), ctxc); // 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); check(ss->addSequence(&ACS_SEQUENCE_OFF.second, ACS_SEQUENCE_OFF.first, ACS_SEQUENCE_OFF.first, false, true), ctxc); } void 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& sequence) { eh.setObject(obj); eh.setMode(mode); eh.setSubmode(submode); check(sequence.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 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); check(ss->addTable(&ACS_TABLE_SAFE_TGT.second, ACS_TABLE_OFF_TGT.first, false, true), ctxc); // 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); check(ss->addTable(&ACS_TABLE_SAFE_TRANS_0.second, ACS_TABLE_SAFE_TRANS_0.first, false, true), ctxc); // Build SAFE transition 1 iht(objects::ACS_CONTROLLER, acs::CtrlModes::SAFE, 0, ACS_TABLE_SAFE_TRANS_1.second); check(ss->addTable(&ACS_TABLE_SAFE_TRANS_1.second, ACS_TABLE_SAFE_TRANS_1.first, false, true), ctxc); // Build SAFE sequence ihs(ACS_SEQUENCE_SAFE.second, ACS_TABLE_SAFE_TGT.first, 0, true); 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); check(ss->addSequence(&ACS_SEQUENCE_SAFE.second, ACS_SEQUENCE_SAFE.first, ACS_SEQUENCE_OFF.first, false, true), ctxc); } void 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& sequence) { eh.setObject(obj); eh.setMode(mode); eh.setSubmode(submode); check(sequence.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 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); check(ss->addTable(&ACS_TABLE_DETUMBLE_TGT.second, ACS_TABLE_DETUMBLE_TGT.first, false, true), ctxc); // 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); check(ss->addTable(&ACS_TABLE_DETUMBLE_TRANS_0.second, ACS_TABLE_DETUMBLE_TRANS_0.first, false, true), ctxc); // Build DETUMBLE transition 1 iht(objects::ACS_CONTROLLER, acs::CtrlModes::DETUMBLE, 0, ACS_TABLE_DETUMBLE_TRANS_1.second); check(ss->addTable(&ACS_TABLE_DETUMBLE_TRANS_1.second, ACS_TABLE_DETUMBLE_TRANS_1.first, false, true), ctxc); // Build DETUMBLE sequence ihs(ACS_SEQUENCE_DETUMBLE.second, ACS_TABLE_DETUMBLE_TGT.first, 0, true); 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); check(ss->addSequence(&ACS_SEQUENCE_DETUMBLE.second, ACS_SEQUENCE_DETUMBLE.first, ACS_SEQUENCE_SAFE.first, false, true), ctxc); } void 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& sequence) { eh.setObject(obj); eh.setMode(mode); eh.setSubmode(submode); check(sequence.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 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_IDLE_TRANS_0.second); iht(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_IDLE_TRANS_0.second); iht(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_IDLE_TRANS_0.second); iht(objects::RW_ASS, NML, 0, ACS_TABLE_IDLE_TRANS_0.second); iht(objects::STAR_TRACKER, OFF, 0, ACS_TABLE_IDLE_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_IDLE_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, true); ihs(ACS_SEQUENCE_IDLE.second, ACS_TABLE_IDLE_TRANS_0.first, 0, true); 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_SAFE.first, false, true); } void buildIdleChargeSequence(Subsystem* ss, ModeListEntry& eh) { std::string context = "satsystem::buildIdleChargeSequence"; auto ctxc = context.c_str(); // Insert Helper Table auto iht = [&](object_id_t obj, Mode_t mode, Submode_t submode, ArrayList& sequence) { eh.setObject(obj); eh.setMode(mode); eh.setSubmode(submode); check(sequence.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 IDLE target iht(objects::ACS_CONTROLLER, acs::CtrlModes::IDLE, acs::IDLE_CHARGE, ACS_TABLE_IDLE_CHRG_TGT.second); iht(objects::IMTQ_HANDLER, NML, 0, ACS_TABLE_IDLE_CHRG_TGT.second); iht(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_IDLE_CHRG_TGT.second); iht(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_IDLE_CHRG_TGT.second); check(ss->addTable(&ACS_TABLE_IDLE_CHRG_TGT.second, ACS_TABLE_IDLE_CHRG_TGT.first, false, true), ctxc); // Build IDLE transition 0 iht(objects::IMTQ_HANDLER, NML, 0, ACS_TABLE_IDLE_CHRG_TRANS_0.second); iht(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_IDLE_CHRG_TRANS_0.second); iht(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_IDLE_CHRG_TRANS_0.second); iht(objects::RW_ASS, OFF, 0, ACS_TABLE_IDLE_CHRG_TRANS_0.second); iht(objects::STAR_TRACKER, OFF, 0, ACS_TABLE_IDLE_CHRG_TRANS_0.second); check(ss->addTable(&ACS_TABLE_IDLE_CHRG_TRANS_0.second, ACS_TABLE_IDLE_CHRG_TRANS_0.first, false, true), ctxc); // Build IDLE transition 1 iht(objects::ACS_CONTROLLER, acs::CtrlModes::IDLE, acs::IDLE_CHARGE, ACS_TABLE_IDLE_CHRG_TRANS_1.second); check(ss->addTable(&ACS_TABLE_IDLE_CHRG_TRANS_1.second, ACS_TABLE_IDLE_CHRG_TRANS_1.first, false, true), ctxc); // Build IDLE sequence ihs(ACS_SEQUENCE_IDLE_CHRG.second, ACS_TABLE_IDLE_CHRG_TGT.first, 0, true); ihs(ACS_SEQUENCE_IDLE_CHRG.second, ACS_TABLE_IDLE_CHRG_TRANS_0.first, 0, true); ihs(ACS_SEQUENCE_IDLE_CHRG.second, ACS_TABLE_IDLE_CHRG_TRANS_1.first, 0, false); check(ss->addSequence(&ACS_SEQUENCE_IDLE_CHRG.second, ACS_SEQUENCE_IDLE_CHRG.first, ACS_SEQUENCE_SAFE.first, false, true), ctxc); } void 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& sequence) { eh.setObject(obj); eh.setMode(mode); eh.setSubmode(submode); check(sequence.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 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); check(ss->addTable(&ACS_TABLE_TARGET_PT_TGT.second, ACS_TABLE_TARGET_PT_TGT.first, false, true), ctxc); // 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); check(ss->addTable(&ACS_TABLE_TARGET_PT_TRANS_0.second, ACS_TABLE_TARGET_PT_TRANS_0.first, false, true), ctxc); // Build TARGET PT transition 1 iht(objects::ACS_CONTROLLER, acs::CtrlModes::TARGET_PT, 0, ACS_TABLE_TARGET_PT_TRANS_1.second); check(ss->addTable(&ACS_TABLE_TARGET_PT_TRANS_1.second, ACS_TABLE_TARGET_PT_TRANS_1.first, false, true), ctxc); // Build IDLE sequence ihs(ACS_SEQUENCE_TARGET_PT.second, ACS_TABLE_TARGET_PT_TGT.first, 0, true); ihs(ACS_SEQUENCE_TARGET_PT.second, ACS_TABLE_TARGET_PT_TRANS_0.first, 0, true); ihs(ACS_SEQUENCE_TARGET_PT.second, ACS_TABLE_TARGET_PT_TRANS_1.first, 0, false); check(ss->addSequence(&ACS_SEQUENCE_TARGET_PT.second, ACS_SEQUENCE_TARGET_PT.first, ACS_SEQUENCE_IDLE.first, false, true), ctxc); } void checkInsert(ReturnValue_t result, const char* ctx) { if (result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "satsystem::checkInsert: Insertion failed at " << ctx << std::endl; } }