eive-obsw/mission/system/SusAssembly.h

73 lines
2.8 KiB
C
Raw Normal View History

#ifndef MISSION_SYSTEM_SUSASSEMBLY_H_
#define MISSION_SYSTEM_SUSASSEMBLY_H_
#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) {}
std::array<object_id_t, 12> susIds = {objects::NO_OBJECT};
std::array<Mode_t, 12> susModes = {HasModesIF::MODE_OFF};
};
class PowerSwitchIF;
2022-03-17 19:59:47 +01:00
class SusAssembly : public DualLaneAssemblyBase {
public:
2022-03-03 20:11:12 +01:00
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;
2022-04-07 19:48:09 +02:00
static constexpr pcdu::Switches SWITCH_NOM = pcdu::Switches::PDU1_CH4_SUS_NOMINAL_3V3;
static constexpr pcdu::Switches SWITCH_RED = pcdu::Switches::PDU2_CH4_SUS_REDUNDANT_3V3;
FixedArrayList<ModeListEntry, NUMBER_SUN_SENSORS> 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;
/**
* 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);
2022-03-03 20:11:12 +01:00
ReturnValue_t handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode);
void refreshHelperModes();
};
#endif /* MISSION_SYSTEM_SUSASSEMBLY_H_ */