eive-obsw/mission/system/acs/SusAssembly.h
Robin Mueller a06d90daad
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
remove duplicate code
2023-04-04 18:29:07 +02:00

66 lines
2.6 KiB
C++

#ifndef MISSION_SYSTEM_SUSASSEMBLY_H_
#define MISSION_SYSTEM_SUSASSEMBLY_H_
#include <devices/powerSwitcherList.h>
#include <fsfw/devicehandlers/AssemblyBase.h>
#include "DualLaneAssemblyBase.h"
#include "events/subsystemIdRanges.h"
#include "returnvalues/classIds.h"
struct SusAssHelper {
public:
SusAssHelper(std::array<object_id_t, 12> susIds) : susIds(susIds) {}
std::array<object_id_t, 12> susIds = {objects::NO_OBJECT};
std::array<Mode_t, 12> susModes = {HasModesIF::MODE_OFF};
};
class PowerSwitchIF;
class SusAssembly : public DualLaneAssemblyBase {
public:
static constexpr uint8_t NUMBER_SUN_SENSORS_ONE_SIDE = 6;
static constexpr uint8_t NUMBER_SUN_SENSORS = 12;
// Use these variables instead of magic numbers when generator was updated
// TRANSITION_OTHER_SIDE_FAILED_ID
// NOT_ENOUGH_DEVICES_DUAL_MODE_ID
// POWER_STATE_MACHINE_TIMEOUT_ID
// SIDE_SWITCH_TRANSITION_NOT_ALLOWED_ID
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SUS_BOARD_ASS;
static constexpr Event TRANSITION_OTHER_SIDE_FAILED =
event::makeEvent(SUBSYSTEM_ID, 0, severity::HIGH);
static constexpr Event NOT_ENOUGH_DEVICES_DUAL_MODE =
event::makeEvent(SUBSYSTEM_ID, 1, severity::HIGH);
static constexpr Event POWER_STATE_MACHINE_TIMEOUT =
event::makeEvent(SUBSYSTEM_ID, 2, severity::MEDIUM);
//! [EXPORT] : [COMMENT] Not implemented, would increase already high complexity. Operator
//! should instead command the assembly off first and then command the assembly on into the
//! desired mode/submode combination
static constexpr Event SIDE_SWITCH_TRANSITION_NOT_ALLOWED =
event::makeEvent(SUBSYSTEM_ID, 3, severity::LOW);
SusAssembly(object_id_t objectId, PowerSwitchIF* pwrSwitcher, SusAssHelper helper);
private:
enum class States { IDLE, SWITCHING_POWER, MODE_COMMANDING } state = States::IDLE;
static constexpr power::Switches SWITCH_NOM = power::Switches::PDU1_CH4_SUS_NOMINAL_3V3;
static constexpr power::Switches SWITCH_RED = power::Switches::PDU2_CH4_SUS_REDUNDANT_3V3;
FixedArrayList<ModeListEntry, NUMBER_SUN_SENSORS> modeTable;
SusAssHelper helper;
PowerSwitchIF* pwrSwitcher = nullptr;
ReturnValue_t initialize() override;
// AssemblyBase overrides
ReturnValue_t commandChildren(Mode_t mode, Submode_t submode) override;
ReturnValue_t checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) override;
void powerStateMachine(Mode_t mode, Submode_t submode);
ReturnValue_t handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode);
void refreshHelperModes();
ReturnValue_t checkAndHandleHealthStates(Mode_t deviceMode, Submode_t deviceSubmode);
};
#endif /* MISSION_SYSTEM_SUSASSEMBLY_H_ */