started integrating new base obj into sus assembly
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2022-03-10 11:02:07 +01:00
parent 1742371c14
commit 3cfb58d681
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
7 changed files with 33 additions and 109 deletions

View File

@ -21,6 +21,7 @@ enum: uint8_t {
STR_HELPER = 120,
PL_PCDU_HANDLER = 121,
ACS_BOARD_ASS = 122,
SUS_BOARD_ASS = 123,
COMMON_SUBSYSTEM_ID_END
};
}

View File

@ -201,14 +201,6 @@ ReturnValue_t AcsBoardAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t s
return result;
}
ReturnValue_t AcsBoardAssembly::isModeCombinationValid(Mode_t mode, Submode_t submode) {
using namespace duallane;
if (submode != A_SIDE and submode != B_SIDE and submode != DUAL_MODE) {
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_OK;
}
void AcsBoardAssembly::handleChildrenLostMode(ReturnValue_t result) {
using namespace duallane;
// Some ACS board components are required for Safe-Mode. It would be good if the software

View File

@ -115,7 +115,6 @@ class AcsBoardAssembly : public DualLaneAssemblyBase {
// AssemblyBase overrides
ReturnValue_t commandChildren(Mode_t mode, Submode_t submode) override;
ReturnValue_t checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) override;
ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override;
void handleModeTransitionFailed(ReturnValue_t result) override;
void handleChildrenLostMode(ReturnValue_t result) override;

View File

@ -79,6 +79,14 @@ ReturnValue_t DualLaneAssemblyBase::pwrStateMachineWrapper() {
return RETURN_OK;
}
ReturnValue_t DualLaneAssemblyBase::isModeCombinationValid(Mode_t mode, Submode_t submode) {
using namespace duallane;
if (submode != A_SIDE and submode != B_SIDE and submode != DUAL_MODE) {
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_OK;
}
void DualLaneAssemblyBase::handleModeReached() {
using namespace duallane;
if (targetMode == MODE_OFF) {

View File

@ -14,9 +14,6 @@ class DualLaneAssemblyBase : public AssemblyBase {
pcduSwitches::Switches switch1, pcduSwitches::Switches switch2,
Event pwrSwitchTimeoutEvent);
virtual void performChildOperation() override;
virtual void startTransition(Mode_t mode, Submode_t submode) override;
protected:
// This helper object complete encapsulates power switching
DualLanePowerStateMachine pwrStateMachine;
@ -37,6 +34,9 @@ class DualLaneAssemblyBase : public AssemblyBase {
* @param submode
*/
virtual ReturnValue_t pwrStateMachineWrapper();
virtual ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override;
virtual void performChildOperation() override;
virtual void startTransition(Mode_t mode, Submode_t submode) override;
virtual void handleModeReached();
/**

View File

@ -6,10 +6,13 @@
SusAssembly::SusAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher,
SusAssHelper helper)
: AssemblyBase(objectId, parentId), helper(helper), pwrSwitcher(pwrSwitcher) {
: DualLaneAssemblyBase(objectId, parentId, pwrSwitcher, SWITCH_NOM, SWITCH_RED,
POWER_STATE_MACHINE_TIMEOUT),
helper(helper),
pwrSwitcher(pwrSwitcher) {
ModeListEntry entry;
for (uint8_t idx = 0; idx < NUMBER_SUN_SENSORS; idx++) {
initModeTableEntry(helper.susIds[idx], entry);
initModeTableEntry(helper.susIds[idx], entry, modeTable);
}
}
@ -34,6 +37,7 @@ ReturnValue_t SusAssembly::commandChildren(Mode_t mode, Submode_t submode) {
}
ReturnValue_t SusAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode) {
using namespace duallane;
ReturnValue_t result = RETURN_OK;
auto cmdSeq = [&](object_id_t objectId, uint8_t tableIdx) {
if (mode == DeviceHandlerIF::MODE_NORMAL) {
@ -55,7 +59,7 @@ ReturnValue_t SusAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t submod
}
};
switch (submode) {
case (NOMINAL): {
case (A_SIDE): {
for (uint8_t idx = 0; idx < NUMBER_SUN_SENSORS_ONE_SIDE; idx++) {
cmdSeq(helper.susIds[idx], idx);
// Switch off devices on redundant side
@ -64,7 +68,7 @@ ReturnValue_t SusAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t submod
}
return result;
}
case (REDUNDANT): {
case (B_SIDE): {
for (uint8_t idx = NUMBER_SUN_SENSORS_ONE_SIDE; idx < NUMBER_SUN_SENSORS; idx++) {
cmdSeq(helper.susIds[idx], idx);
// Switch devices on nominal side
@ -84,15 +88,16 @@ ReturnValue_t SusAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t submod
}
ReturnValue_t SusAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) {
using namespace duallane;
refreshHelperModes();
if (wantedSubmode == NOMINAL) {
if (wantedSubmode == A_SIDE) {
for (uint8_t idx = 0; idx < NUMBER_SUN_SENSORS_ONE_SIDE; idx++) {
if (helper.susModes[idx] != wantedMode) {
return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE;
}
}
return RETURN_OK;
} else if (wantedSubmode == REDUNDANT) {
} else if (wantedSubmode == B_SIDE) {
for (uint8_t idx = NUMBER_SUN_SENSORS_ONE_SIDE; idx < NUMBER_SUN_SENSORS; idx++) {
if (helper.susModes[idx] != wantedMode) {
return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE;
@ -108,13 +113,6 @@ ReturnValue_t SusAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wan
return RETURN_OK;
}
ReturnValue_t SusAssembly::isModeCombinationValid(Mode_t mode, Submode_t submode) {
if (submode != NOMINAL and submode != REDUNDANT and submode != DUAL_MODE) {
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t SusAssembly::initialize() {
ReturnValue_t result = RETURN_OK;
for (const auto& id : helper.susIds) {
@ -142,92 +140,13 @@ bool SusAssembly::isUseable(object_id_t object, Mode_t mode) {
return false;
}
void SusAssembly::powerStateMachine(Mode_t mode, Submode_t submode) {
ReturnValue_t switchStateNom = RETURN_OK;
ReturnValue_t switchStateRed = RETURN_OK;
if (state == States::IDLE or state == States::SWITCHING_POWER) {
switchStateNom = pwrSwitcher->getSwitchState(SWITCH_NOM);
switchStateRed = pwrSwitcher->getSwitchState(SWITCH_RED);
} else {
return;
}
if (mode == MODE_OFF) {
if (switchStateNom == PowerSwitchIF::SWITCH_OFF and
switchStateRed == PowerSwitchIF::SWITCH_OFF) {
state = States::MODE_COMMANDING;
return;
}
} else {
if (state == States::IDLE) {
if (mode == MODE_OFF) {
if (switchStateNom != PowerSwitchIF::SWITCH_OFF) {
pwrSwitcher->sendSwitchCommand(SWITCH_NOM, false);
}
if (switchStateRed != PowerSwitchIF::SWITCH_OFF) {
pwrSwitcher->sendSwitchCommand(SWITCH_RED, false);
}
} else {
switch (submode) {
case (NOMINAL): {
if (switchStateNom != PowerSwitchIF::SWITCH_ON) {
pwrSwitcher->sendSwitchCommand(SWITCH_NOM, true);
}
if (switchStateRed != PowerSwitchIF::SWITCH_OFF) {
pwrSwitcher->sendSwitchCommand(SWITCH_RED, false);
}
break;
}
case (REDUNDANT): {
if (switchStateRed != PowerSwitchIF::SWITCH_OFF) {
pwrSwitcher->sendSwitchCommand(SWITCH_RED, false);
}
if (switchStateNom != PowerSwitchIF::SWITCH_ON) {
pwrSwitcher->sendSwitchCommand(SWITCH_NOM, true);
}
break;
}
case (DUAL_MODE): {
if (switchStateNom != PowerSwitchIF::SWITCH_ON) {
pwrSwitcher->sendSwitchCommand(SWITCH_NOM, true);
}
if (switchStateRed != PowerSwitchIF::SWITCH_ON) {
pwrSwitcher->sendSwitchCommand(SWITCH_RED, true);
}
break;
}
}
}
state = States::SWITCHING_POWER;
}
if (state == States::SWITCHING_POWER) {
// TODO: Could check for a timeout (temporal or cycles) here and resend command
}
}
}
void SusAssembly::handleModeReached() {
AssemblyBase::handleModeReached();
state = States::IDLE;
}
void SusAssembly::handleModeTransitionFailed(ReturnValue_t result) {
// The sun-sensors are required for the Safe-Mode. It would be good if the software
// transitions from nominal side to redundant side and from redundant side to dual mode
// autonomously to ensure that that enough sensors are available witout an operators intervention.
// Therefore, the failure handler is overriden to perform these steps.
// TODO: Implement transitions mentioned above
}
void SusAssembly::refreshHelperModes() {
for (uint8_t idx = 0; idx < helper.susModes.size(); idx++) {
helper.susModes[idx] = childrenMap[helper.susIds[idx]].mode;
}
}
void SusAssembly::initModeTableEntry(object_id_t id, ModeListEntry& entry) {
entry.setObject(id);
entry.setMode(MODE_OFF);
entry.setSubmode(SUBMODE_NONE);
entry.setInheritSubmode(false);
modeTable.insert(entry);
}

View File

@ -4,6 +4,8 @@
#include <devices/powerSwitcherList.h>
#include <fsfw/devicehandlers/AssemblyBase.h>
#include "DualLaneAssemblyBase.h"
struct SusAssHelper {
public:
SusAssHelper(std::array<object_id_t, 12> susIds) : susIds(susIds) {}
@ -13,14 +15,18 @@ struct SusAssHelper {
class PowerSwitchIF;
class SusAssembly : AssemblyBase {
class SusAssembly : DualLaneAssemblyBase {
public:
static constexpr uint8_t NUMBER_SUN_SENSORS_ONE_SIDE = 6;
static constexpr uint8_t NUMBER_SUN_SENSORS = 12;
static constexpr Submode_t NOMINAL = 0;
static constexpr Submode_t REDUNDANT = 1;
static constexpr Submode_t DUAL_MODE = 2;
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SUS_BOARD_ASS;
static constexpr Event TRANSITION_OTHER_SIDE_FAILED =
event::makeEvent(SUBSYSTEM_ID, TRANSITION_OTHER_SIDE_FAILED_ID, severity::HIGH);
static constexpr Event NOT_ENOUGH_DEVICES_DUAL_MODE =
event::makeEvent(SUBSYSTEM_ID, NOT_ENOUGH_DEVICES_DUAL_MODE_ID, severity::HIGH);
static constexpr Event POWER_STATE_MACHINE_TIMEOUT =
event::makeEvent(SUBSYSTEM_ID, POWER_STATE_MACHINE_TIMEOUT_ID, severity::MEDIUM);
SusAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher,
SusAssHelper helper);
@ -54,7 +60,6 @@ class SusAssembly : AssemblyBase {
bool isUseable(object_id_t object, Mode_t mode);
void powerStateMachine(Mode_t mode, Submode_t submode);
ReturnValue_t handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode);
void initModeTableEntry(object_id_t id, ModeListEntry& entry);
void refreshHelperModes();
};