eive-obsw/bsp_q7s/core/acsModeTree.cpp
Robin Mueller 874e06baa1
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
continued acs subsystem
2022-04-22 17:49:28 +02:00

172 lines
5.7 KiB
C++

#include <commonObjects.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include "acsModeTree.h"
#include "mission/controller/controllerdefinitions/AcsControllerDefinitions.h"
#include <fsfw/subsystem/modes/ModeDefinitions.h>
#include <fsfw/subsystem/Subsystem.h>
#include <fsfw/modes/HasModesIF.h>
FixedArrayList<ModeListEntry, 2> ACS_SEQUENCE_OFF = FixedArrayList<ModeListEntry, 2>();
FixedArrayList<ModeListEntry, 0> ACS_TABLE_OFF_TGT = FixedArrayList<ModeListEntry, 0>();
FixedArrayList<ModeListEntry, 6> ACS_TABLE_OFF_TRANS = FixedArrayList<ModeListEntry, 6>();
static constexpr Mode_t ACS_SEQUENCE_OFF_ID = acs::CtrlModes::OFF;
static constexpr Mode_t ACS_TABLE_OFF_TGT_ID = (acs::CtrlModes::OFF << 8) | 1;
static constexpr Mode_t ACS_TABLE_OFF_TRANS_ID = (acs::CtrlModes::OFF << 8) | 2;
FixedArrayList<ModeListEntry, 2> ACS_SEQUENCE_DETUMBLE = FixedArrayList<ModeListEntry, 2>();
FixedArrayList<ModeListEntry, 3> ACS_TABLE_DETUMBLE_TGT = FixedArrayList<ModeListEntry, 3>();
FixedArrayList<ModeListEntry, 5> ACS_TABLE_DETUMBLE_TRANS_0 = FixedArrayList<ModeListEntry, 5>();
FixedArrayList<ModeListEntry, 1> ACS_TABLE_DETUMBLE_TRANS_1 = FixedArrayList<ModeListEntry, 1>();
static constexpr Mode_t ACS_SEQUENCE_DETUMBLE_ID = acs::CtrlModes::DETUMBLE;
static constexpr Mode_t ACS_TABLE_DETUMBLE_TGT_ID = (acs::CtrlModes::DETUMBLE << 8) | 1;
static constexpr Mode_t ACS_TABLE_DETUMBLE_TRANS_0_ID = (acs::CtrlModes::DETUMBLE << 8) | 2;
static constexpr Mode_t ACS_TABLE_DETUMBLE_TRANS_1_ID = (acs::CtrlModes::DETUMBLE << 8) | 3;
// Alias for checker function
const auto CHK = satsystem::checkInsert;
static const auto OFF = HasModesIF::MODE_OFF;
static const auto NML = DeviceHandlerIF::MODE_NORMAL;
void satsystem::acsSubsystemInit() {
ModeListEntry entry;
Subsystem *acsSubsystem = new Subsystem(objects::ACS_SUBSYSTEM, objects::EIVE_SYSTEM, 20, 20);
buildOffSequence(acsSubsystem, entry);
buildDetumbleSequence(acsSubsystem, entry);
acsSubsystem->setInitialMode(HasModesIF::MODE_OFF);
}
void satsystem::buildOffSequence(Subsystem* ss, ModeListEntry& eh) {
std::string context = "satsystem::buildOffSequence";
auto ctxc = context.c_str();
// Build OFF target
ss->addTable(&ACS_TABLE_OFF_TGT, ACS_TABLE_OFF_TGT_ID, false, true);
// Build OFF transition
eh.setObject(objects::ACS_CONTROLLER);
eh.setMode(OFF);
eh.setSubmode(0);
CHK(ACS_TABLE_OFF_TRANS.insert(eh), ctxc);
eh.setObject(objects::IMTQ_HANDLER);
eh.setMode(OFF);
eh.setSubmode(0);
CHK(ACS_TABLE_OFF_TRANS.insert(eh), ctxc);
eh.setObject(objects::STAR_TRACKER);
eh.setMode(OFF);
eh.setSubmode(0);
CHK(ACS_TABLE_OFF_TRANS.insert(eh), ctxc);
eh.setObject(objects::ACS_BOARD_ASS);
eh.setMode(OFF);
eh.setSubmode(0);
CHK(ACS_TABLE_OFF_TRANS.insert(eh), ctxc);
eh.setObject(objects::SUS_BOARD_ASS);
eh.setMode(OFF);
eh.setSubmode(0);
CHK(ACS_TABLE_OFF_TRANS.insert(eh), ctxc);
eh.setObject(objects::RW_ASS);
eh.setMode(OFF);
eh.setSubmode(0);
CHK(ACS_TABLE_OFF_TRANS.insert(eh), ctxc);
ss->addTable(&ACS_TABLE_OFF_TRANS, ACS_TABLE_OFF_TRANS_ID, false, true);
// Build OFF sequence
eh.setTableId(ACS_TABLE_OFF_TGT_ID);
eh.setWaitSeconds(0);
eh.setCheckSuccess(false);
CHK(ACS_SEQUENCE_OFF.insert(eh), ctxc);
eh.setTableId(ACS_TABLE_OFF_TRANS_ID);
eh.setWaitSeconds(0);
eh.setCheckSuccess(false);
CHK(ACS_SEQUENCE_OFF.insert(eh), ctxc);
ss->addSequence(&ACS_SEQUENCE_OFF, ACS_SEQUENCE_OFF_ID, ACS_SEQUENCE_OFF_ID, false, true);
}
void satsystem::buildDetumbleSequence(Subsystem* ss, ModeListEntry& eh) {
std::string context = "satsystem::buildDetumbleSequence";
auto ctxc = context.c_str();
// Build DETUMBLE target
eh.setObject(objects::ACS_CONTROLLER);
eh.setMode(acs::CtrlModes::DETUMBLE);
eh.setSubmode(0);
CHK(ACS_TABLE_DETUMBLE_TGT.insert(eh), ctxc);
eh.setObject(objects::IMTQ_HANDLER);
eh.setMode(NML);
eh.setSubmode(0);
CHK(ACS_TABLE_DETUMBLE_TGT.insert(eh), ctxc);
eh.setObject(objects::SUS_BOARD_ASS);
eh.setMode(NML);
eh.setSubmode(0);
CHK(ACS_TABLE_DETUMBLE_TGT.insert(eh), ctxc);
eh.setObject(objects::ACS_BOARD_ASS);
eh.setMode(NML);
eh.setSubmode(0);
CHK(ACS_TABLE_DETUMBLE_TGT.insert(eh), ctxc);
ss->addTable(&ACS_TABLE_DETUMBLE_TGT, ACS_TABLE_DETUMBLE_TGT_ID, false, true);
// Build DETUMBLE transition 0
eh.setObject(objects::IMTQ_HANDLER);
eh.setMode(NML);
eh.setSubmode(0);
CHK(ACS_TABLE_DETUMBLE_TRANS_0.insert(eh), ctxc);
eh.setObject(objects::STAR_TRACKER);
eh.setMode(OFF);
eh.setSubmode(0);
CHK(ACS_TABLE_DETUMBLE_TRANS_0.insert(eh), ctxc);
eh.setObject(objects::ACS_BOARD_ASS);
eh.setMode(NML);
eh.setSubmode(0);
CHK(ACS_TABLE_DETUMBLE_TRANS_0.insert(eh), ctxc);
eh.setObject(objects::SUS_BOARD_ASS);
eh.setMode(NML);
eh.setSubmode(0);
CHK(ACS_TABLE_DETUMBLE_TRANS_0.insert(eh), ctxc);
eh.setObject(objects::RW_ASS);
eh.setMode(OFF);
eh.setSubmode(0);
CHK(ACS_TABLE_DETUMBLE_TRANS_0.insert(eh), ctxc);
ss->addTable(&ACS_TABLE_DETUMBLE_TRANS_0, ACS_TABLE_DETUMBLE_TRANS_0_ID, false, true);
// Build DETUMBLE transition 1
eh.setObject(objects::ACS_CONTROLLER);
eh.setMode(acs::CtrlModes::DETUMBLE);
eh.setSubmode(0);
CHK(ACS_TABLE_DETUMBLE_TRANS_1.insert(eh), ctxc);
ss->addTable(&ACS_TABLE_DETUMBLE_TRANS_1, ACS_TABLE_DETUMBLE_TRANS_1_ID, false, true);
ss->addSequence(&ACS_SEQUENCE_DETUMBLE, ACS_SEQUENCE_DETUMBLE_ID, 0 /*Ü TODO*/, false, true);
}
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) {
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "Insertion failed at " << ctx << std::endl;
}
}