2022-04-25 08:48:22 +02:00
|
|
|
#include "acsModeTree.h"
|
|
|
|
|
2022-04-22 17:00:23 +02:00
|
|
|
#include <commonObjects.h>
|
2022-04-22 17:49:28 +02:00
|
|
|
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
2022-04-22 17:00:23 +02:00
|
|
|
#include <fsfw/modes/HasModesIF.h>
|
2022-04-25 08:48:22 +02:00
|
|
|
#include <fsfw/subsystem/Subsystem.h>
|
|
|
|
#include <fsfw/subsystem/modes/ModeDefinitions.h>
|
2022-04-22 17:00:23 +02:00
|
|
|
|
2022-04-25 08:48:22 +02:00
|
|
|
#include "mission/controller/controllerdefinitions/AcsControllerDefinitions.h"
|
2022-04-22 17:49:28 +02:00
|
|
|
|
|
|
|
// Alias for checker function
|
|
|
|
const auto CHK = satsystem::checkInsert;
|
|
|
|
static const auto OFF = HasModesIF::MODE_OFF;
|
|
|
|
static const auto NML = DeviceHandlerIF::MODE_NORMAL;
|
2022-04-22 17:00:23 +02:00
|
|
|
|
2022-04-25 08:48:22 +02:00
|
|
|
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, 2>());
|
|
|
|
auto ACS_TABLE_DETUMBLE_TGT =
|
|
|
|
std::make_pair((acs::CtrlModes::DETUMBLE << 8) | 1, FixedArrayList<ModeListEntry, 3>());
|
|
|
|
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>());
|
|
|
|
|
2022-04-22 17:00:23 +02:00
|
|
|
void satsystem::acsSubsystemInit() {
|
|
|
|
ModeListEntry entry;
|
2022-04-25 08:48:22 +02:00
|
|
|
Subsystem* acsSubsystem = new Subsystem(objects::ACS_SUBSYSTEM, objects::EIVE_SYSTEM, 20, 20);
|
2022-04-22 17:00:23 +02:00
|
|
|
buildOffSequence(acsSubsystem, entry);
|
2022-04-22 17:49:28 +02:00
|
|
|
buildDetumbleSequence(acsSubsystem, entry);
|
|
|
|
acsSubsystem->setInitialMode(HasModesIF::MODE_OFF);
|
2022-04-22 17:00:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void satsystem::buildOffSequence(Subsystem* ss, ModeListEntry& eh) {
|
2022-04-22 17:49:28 +02:00
|
|
|
std::string context = "satsystem::buildOffSequence";
|
|
|
|
auto ctxc = context.c_str();
|
2022-04-25 08:48:22 +02:00
|
|
|
|
|
|
|
auto ih = [&](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);
|
|
|
|
};
|
2022-04-22 17:00:23 +02:00
|
|
|
|
|
|
|
// Build OFF transition
|
2022-04-25 08:48:22 +02:00
|
|
|
ih(objects::ACS_CONTROLLER, OFF, 0, ACS_TABLE_OFF_TRANS.second);
|
|
|
|
ih(objects::IMTQ_HANDLER, OFF, 0, ACS_TABLE_OFF_TRANS.second);
|
|
|
|
ih(objects::STAR_TRACKER, OFF, 0, ACS_TABLE_OFF_TRANS.second);
|
|
|
|
ih(objects::ACS_BOARD_ASS, OFF, 0, ACS_TABLE_OFF_TRANS.second);
|
|
|
|
ih(objects::SUS_BOARD_ASS, OFF, 0, ACS_TABLE_OFF_TRANS.second);
|
|
|
|
ih(objects::RW_ASS, OFF, 0, ACS_TABLE_OFF_TRANS.second);
|
2022-04-22 17:00:23 +02:00
|
|
|
|
|
|
|
// Build OFF sequence
|
2022-04-25 08:48:22 +02:00
|
|
|
eh.setTableId(ACS_TABLE_OFF_TGT.first);
|
2022-04-22 17:00:23 +02:00
|
|
|
eh.setWaitSeconds(0);
|
|
|
|
eh.setCheckSuccess(false);
|
2022-04-25 08:48:22 +02:00
|
|
|
CHK(ACS_SEQUENCE_OFF.second.insert(eh), ctxc);
|
2022-04-22 17:00:23 +02:00
|
|
|
|
2022-04-25 08:48:22 +02:00
|
|
|
eh.setTableId(ACS_TABLE_OFF_TRANS.first);
|
2022-04-22 17:00:23 +02:00
|
|
|
eh.setWaitSeconds(0);
|
|
|
|
eh.setCheckSuccess(false);
|
2022-04-25 08:48:22 +02:00
|
|
|
CHK(ACS_SEQUENCE_OFF.second.insert(eh), ctxc);
|
2022-04-22 17:00:23 +02:00
|
|
|
|
2022-04-25 08:48:22 +02:00
|
|
|
// Build OFF target
|
|
|
|
ss->addTable(&ACS_TABLE_OFF_TGT.second, ACS_TABLE_OFF_TGT.first, false, true);
|
|
|
|
ss->addTable(&ACS_TABLE_OFF_TRANS.second, ACS_TABLE_OFF_TRANS.first, false, true);
|
|
|
|
ss->addSequence(&ACS_SEQUENCE_OFF.second, ACS_SEQUENCE_OFF.first, ACS_SEQUENCE_OFF.first, false,
|
|
|
|
true);
|
2022-04-22 17:49:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void satsystem::buildDetumbleSequence(Subsystem* ss, ModeListEntry& eh) {
|
|
|
|
std::string context = "satsystem::buildDetumbleSequence";
|
|
|
|
auto ctxc = context.c_str();
|
2022-04-25 08:48:22 +02:00
|
|
|
auto ih = [&](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);
|
|
|
|
};
|
2022-04-22 17:49:28 +02:00
|
|
|
// Build DETUMBLE target
|
2022-04-25 08:48:22 +02:00
|
|
|
ih(objects::ACS_CONTROLLER, acs::CtrlModes::DETUMBLE, 0, ACS_TABLE_DETUMBLE_TGT.second);
|
|
|
|
ih(objects::IMTQ_HANDLER, NML, 0, ACS_TABLE_DETUMBLE_TGT.second);
|
|
|
|
ih(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_DETUMBLE_TGT.second);
|
|
|
|
ih(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_DETUMBLE_TGT.second);
|
2022-04-22 17:49:28 +02:00
|
|
|
|
2022-04-25 08:48:22 +02:00
|
|
|
ss->addTable(&ACS_TABLE_DETUMBLE_TGT.second, ACS_TABLE_DETUMBLE_TGT.first, false, true);
|
2022-04-22 17:49:28 +02:00
|
|
|
|
|
|
|
// Build DETUMBLE transition 0
|
2022-04-25 08:48:22 +02:00
|
|
|
ih(objects::IMTQ_HANDLER, NML, 0, ACS_TABLE_DETUMBLE_TRANS_0.second);
|
|
|
|
ih(objects::ACS_BOARD_ASS, NML, 0, ACS_TABLE_DETUMBLE_TRANS_0.second);
|
|
|
|
ih(objects::SUS_BOARD_ASS, NML, 0, ACS_TABLE_DETUMBLE_TRANS_0.second);
|
|
|
|
ih(objects::STAR_TRACKER, OFF, 0, ACS_TABLE_DETUMBLE_TRANS_0.second);
|
|
|
|
ih(objects::RW_ASS, OFF, 0, ACS_TABLE_DETUMBLE_TRANS_0.second);
|
2022-04-22 17:49:28 +02:00
|
|
|
|
|
|
|
// Build DETUMBLE transition 1
|
2022-04-25 08:48:22 +02:00
|
|
|
ih(objects::ACS_CONTROLLER, acs::CtrlModes::DETUMBLE, 0, ACS_TABLE_DETUMBLE_TRANS_1.second);
|
2022-04-22 17:49:28 +02:00
|
|
|
|
2022-04-25 08:48:22 +02:00
|
|
|
// Build full sequence
|
|
|
|
ss->addTable(&ACS_TABLE_DETUMBLE_TRANS_0.second, ACS_TABLE_DETUMBLE_TRANS_0.first, false, true);
|
|
|
|
ss->addTable(&ACS_TABLE_DETUMBLE_TRANS_1.second, ACS_TABLE_DETUMBLE_TRANS_1.first, false, true);
|
|
|
|
ss->addSequence(&ACS_SEQUENCE_DETUMBLE.second, ACS_SEQUENCE_DETUMBLE.first,
|
|
|
|
ACS_SEQUENCE_DETUMBLE.first, false, true);
|
2022-04-22 17:49:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void satsystem::buildSafeSequence(Subsystem* ss, ModeListEntry& eh) {}
|
|
|
|
|
|
|
|
void satsystem::buildIdleSequence(Subsystem* ss, ModeListEntry& eh) {}
|
|
|
|
|
|
|
|
void satsystem::buildTargetPtSequence(Subsystem* ss, ModeListEntry& eh) {}
|
|
|
|
|
|
|
|
void satsystem::checkInsert(ReturnValue_t result, const char* ctx) {
|
2022-04-25 08:48:22 +02:00
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
2022-04-22 17:49:28 +02:00
|
|
|
sif::error << "Insertion failed at " << ctx << std::endl;
|
|
|
|
}
|
2022-04-22 17:00:23 +02:00
|
|
|
}
|