2023-03-01 18:06:36 +01:00
|
|
|
#include "SyrlinksAssembly.h"
|
|
|
|
|
|
|
|
#include <eive/objects.h>
|
|
|
|
|
|
|
|
using namespace returnvalue;
|
|
|
|
|
2023-03-02 17:25:32 +01:00
|
|
|
SyrlinksAssembly::SyrlinksAssembly(object_id_t objectId) : AssemblyBase(objectId) {
|
|
|
|
ModeListEntry entry;
|
|
|
|
entry.setObject(objects::SYRLINKS_HANDLER);
|
|
|
|
entry.setMode(MODE_OFF);
|
|
|
|
entry.setSubmode(SUBMODE_NONE);
|
|
|
|
commandTable.insert(entry);
|
|
|
|
}
|
2023-03-01 18:06:36 +01:00
|
|
|
|
|
|
|
ReturnValue_t SyrlinksAssembly::commandChildren(Mode_t mode, Submode_t submode) {
|
|
|
|
commandTable[0].setMode(mode);
|
|
|
|
commandTable[0].setSubmode(submode);
|
|
|
|
HybridIterator<ModeListEntry> iter(commandTable.begin(), commandTable.end());
|
2023-03-02 11:27:19 +01:00
|
|
|
if (recoveryState == RECOVERY_IDLE) {
|
|
|
|
ReturnValue_t result = checkAndHandleHealthState(mode, submode);
|
|
|
|
if (result == NEED_TO_CHANGE_HEALTH) {
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
}
|
2023-03-01 18:06:36 +01:00
|
|
|
executeTable(iter);
|
|
|
|
return returnvalue::OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) {
|
|
|
|
if (childrenMap[objects::SYRLINKS_HANDLER].mode != wantedMode) {
|
|
|
|
return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE;
|
|
|
|
}
|
|
|
|
return returnvalue::OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksAssembly::isModeCombinationValid(Mode_t mode, Submode_t submode) {
|
|
|
|
if (mode == MODE_ON or mode == DeviceHandlerIF::MODE_NORMAL or mode == MODE_OFF) {
|
|
|
|
return returnvalue::OK;
|
|
|
|
}
|
|
|
|
return returnvalue::FAILED;
|
|
|
|
}
|
2023-03-02 11:27:19 +01:00
|
|
|
|
|
|
|
ReturnValue_t SyrlinksAssembly::checkAndHandleHealthState(Mode_t deviceMode,
|
|
|
|
Submode_t deviceSubmode) {
|
|
|
|
HealthState health = healthHelper.healthTable->getHealth(objects::SYRLINKS_HANDLER);
|
|
|
|
if (health == FAULTY or health == PERMANENT_FAULTY) {
|
|
|
|
overwriteDeviceHealth(objects::SYRLINKS_HANDLER, health);
|
|
|
|
return NEED_TO_CHANGE_HEALTH;
|
|
|
|
} else if (health == EXTERNAL_CONTROL) {
|
|
|
|
modeHelper.setForced(true);
|
|
|
|
}
|
|
|
|
return OK;
|
|
|
|
}
|