Robin Mueller
36d5f8fd31
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
58 lines
1.8 KiB
C++
58 lines
1.8 KiB
C++
#include "ImtqAssembly.h"
|
|
|
|
#include <eive/objects.h>
|
|
|
|
using namespace returnvalue;
|
|
|
|
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);
|
|
}
|
|
|
|
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) {
|
|
return result;
|
|
}
|
|
}
|
|
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) {
|
|
if (submode != SUBMODE_NONE) {
|
|
return HasModesIF::INVALID_SUBMODE;
|
|
}
|
|
return returnvalue::OK;
|
|
}
|
|
return HasModesIF::INVALID_MODE;
|
|
}
|
|
|
|
ReturnValue_t ImtqAssembly::checkAndHandleHealthState(Mode_t deviceMode, Submode_t deviceSubmode) {
|
|
HealthState health = healthHelper.healthTable->getHealth(objects::IMTQ_HANDLER);
|
|
if (health == FAULTY or health == PERMANENT_FAULTY) {
|
|
overwriteDeviceHealth(objects::IMTQ_HANDLER, health);
|
|
return NEED_TO_CHANGE_HEALTH;
|
|
} else if (health == EXTERNAL_CONTROL) {
|
|
modeHelper.setForced(true);
|
|
}
|
|
return OK;
|
|
}
|
|
|
|
void ImtqAssembly::handleChildrenLostMode(ReturnValue_t result) { startTransition(mode, submode); }
|