#ifndef MISSION_SYSTEM_SUSASSEMBLY_H_ #define MISSION_SYSTEM_SUSASSEMBLY_H_ #include #include #include "DualLaneAssemblyBase.h" struct SusAssHelper { public: SusAssHelper(std::array susIds) : susIds(susIds) {} std::array susIds = {objects::NO_OBJECT}; std::array 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, object_id_t parentId, PowerSwitchIF* pwrSwitcher, SusAssHelper helper); private: enum class States { IDLE, SWITCHING_POWER, MODE_COMMANDING } state = States::IDLE; static constexpr pcduSwitches::Switches SWITCH_NOM = pcduSwitches::Switches::PDU1_CH4_SUS_NOMINAL_3V3; static constexpr pcduSwitches::Switches SWITCH_RED = pcduSwitches::Switches::PDU2_CH4_SUS_REDUNDANT_3V3; FixedArrayList modeTable; SusAssHelper helper; PowerSwitchIF* pwrSwitcher = nullptr; bool tryingOtherSide = false; bool dualModeErrorSwitch = true; 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 handleModeReached() override; /** * Check whether it makes sense to send mode commands to the device * @param object * @param mode * @return */ 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 refreshHelperModes(); }; #endif /* MISSION_SYSTEM_SUSASSEMBLY_H_ */