2023-03-06 15:51:53 +01:00
|
|
|
#include "StrAssembly.h"
|
|
|
|
|
|
|
|
#include <eive/objects.h>
|
|
|
|
|
2023-04-05 15:05:32 +02:00
|
|
|
#include "mission/acs/str/strHelpers.h"
|
|
|
|
|
2023-03-08 18:09:50 +01:00
|
|
|
StrAssembly::StrAssembly(object_id_t objectId) : AssemblyBase(objectId) {
|
2023-03-06 15:51:53 +01:00
|
|
|
ModeListEntry entry;
|
|
|
|
entry.setObject(objects::STAR_TRACKER);
|
|
|
|
entry.setMode(MODE_OFF);
|
|
|
|
entry.setSubmode(SUBMODE_NONE);
|
|
|
|
commandTable.insert(entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t StrAssembly::commandChildren(Mode_t mode, Submode_t submode) {
|
2023-04-04 01:35:05 +02:00
|
|
|
// To ensure consistent state.
|
|
|
|
commandTable[0].setMode(MODE_OFF);
|
2023-03-06 15:51:53 +01:00
|
|
|
commandTable[0].setSubmode(submode);
|
2023-04-04 01:35:05 +02:00
|
|
|
if (healthHelper.healthTable->getHealth(objects::STAR_TRACKER) != FAULTY) {
|
|
|
|
commandTable[0].setMode(mode);
|
|
|
|
commandTable[0].setSubmode(submode);
|
|
|
|
}
|
2023-03-06 15:51:53 +01:00
|
|
|
HybridIterator<ModeListEntry> iter(commandTable.begin(), commandTable.end());
|
|
|
|
executeTable(iter);
|
|
|
|
return returnvalue::OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t StrAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) {
|
|
|
|
if (childrenMap[objects::STAR_TRACKER].mode != wantedMode) {
|
|
|
|
return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE;
|
|
|
|
}
|
|
|
|
return returnvalue::OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t StrAssembly::isModeCombinationValid(Mode_t mode, Submode_t submode) {
|
2023-04-05 16:06:59 +02:00
|
|
|
if ((mode == DeviceHandlerIF::MODE_NORMAL or mode == MODE_OFF) and submode != SUBMODE_NONE) {
|
2023-04-05 15:05:32 +02:00
|
|
|
return HasModesIF::INVALID_SUBMODE;
|
|
|
|
}
|
|
|
|
if (mode == MODE_ON and
|
|
|
|
(submode != startracker::SUBMODE_BOOTLOADER and submode != startracker::SUBMODE_FIRMWARE)) {
|
|
|
|
return HasModesIF::INVALID_SUBMODE;
|
|
|
|
}
|
2023-03-06 15:51:53 +01:00
|
|
|
return returnvalue::OK;
|
|
|
|
}
|