eive-obsw/mission/system/acs/ImtqAssembly.cpp

58 lines
1.8 KiB
C++
Raw Normal View History

2023-03-02 16:01:36 +01:00
#include "ImtqAssembly.h"
2023-03-02 16:08:31 +01:00
#include <eive/objects.h>
using namespace returnvalue;
2023-03-06 11:46:37 +01:00
ImtqAssembly::ImtqAssembly(object_id_t objectId) : AssemblyBase(objectId) {
ModeListEntry entry;
entry.setObject(objects::IMTQ_HANDLER);
entry.setMode(MODE_OFF);
entry.setSubmode(SUBMODE_NONE);
commandTable.insert(entry);
}
2023-03-02 16:08:31 +01:00
ReturnValue_t ImtqAssembly::commandChildren(Mode_t mode, Submode_t submode) {
commandTable[0].setMode(mode);
commandTable[0].setSubmode(submode);
if (recoveryState == RECOVERY_IDLE) {
ReturnValue_t result = checkAndHandleHealthState(mode, submode);
if (result == NEED_TO_CHANGE_HEALTH) {
2023-04-05 16:19:53 +02:00
return result;
2023-03-02 16:08:31 +01:00
}
}
HybridIterator<ModeListEntry> iter(commandTable.begin(), commandTable.end());
executeTable(iter);
return returnvalue::OK;
}
ReturnValue_t ImtqAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) {
if (childrenMap[objects::IMTQ_HANDLER].mode != wantedMode) {
return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE;
}
return returnvalue::OK;
}
ReturnValue_t ImtqAssembly::isModeCombinationValid(Mode_t mode, Submode_t submode) {
if (mode == MODE_ON or mode == DeviceHandlerIF::MODE_NORMAL or mode == MODE_OFF) {
2023-04-05 16:41:49 +02:00
if (submode != SUBMODE_NONE) {
2023-04-05 15:29:03 +02:00
return HasModesIF::INVALID_SUBMODE;
}
2023-03-02 16:08:31 +01:00
return returnvalue::OK;
}
2023-04-05 15:29:03 +02:00
return HasModesIF::INVALID_MODE;
2023-03-02 16:08:31 +01:00
}
ReturnValue_t ImtqAssembly::checkAndHandleHealthState(Mode_t deviceMode, Submode_t deviceSubmode) {
2023-03-06 14:02:03 +01:00
HealthState health = healthHelper.healthTable->getHealth(objects::IMTQ_HANDLER);
2023-03-02 16:08:31 +01:00
if (health == FAULTY or health == PERMANENT_FAULTY) {
2023-03-06 14:02:03 +01:00
overwriteDeviceHealth(objects::IMTQ_HANDLER, health);
2023-03-02 16:08:31 +01:00
return NEED_TO_CHANGE_HEALTH;
} else if (health == EXTERNAL_CONTROL) {
modeHelper.setForced(true);
}
return OK;
}
2023-03-06 14:02:03 +01:00
2023-03-06 14:25:26 +01:00
void ImtqAssembly::handleChildrenLostMode(ReturnValue_t result) { startTransition(mode, submode); }