2022-03-03 15:37:36 +01:00
|
|
|
#ifndef MISSION_SYSTEM_SUSASSEMBLY_H_
|
|
|
|
#define MISSION_SYSTEM_SUSASSEMBLY_H_
|
|
|
|
|
2022-03-03 19:39:36 +01:00
|
|
|
#include <devices/powerSwitcherList.h>
|
2022-03-03 15:37:36 +01:00
|
|
|
#include <fsfw/devicehandlers/AssemblyBase.h>
|
|
|
|
|
2022-03-10 11:02:07 +01:00
|
|
|
#include "DualLaneAssemblyBase.h"
|
2022-09-14 13:44:43 +02:00
|
|
|
#include "events/subsystemIdRanges.h"
|
|
|
|
#include "returnvalues/classIds.h"
|
2022-03-10 11:02:07 +01:00
|
|
|
|
2022-03-03 15:37:36 +01:00
|
|
|
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 {
|
2022-03-03 15:37:36 +01:00
|
|
|
public:
|
2022-03-03 20:11:12 +01:00
|
|
|
static constexpr uint8_t NUMBER_SUN_SENSORS_ONE_SIDE = 6;
|
2022-03-03 15:37:36 +01:00
|
|
|
static constexpr uint8_t NUMBER_SUN_SENSORS = 12;
|
|
|
|
|
2022-03-17 19:23:39 +01:00
|
|
|
// 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
|
2022-03-10 11:02:07 +01:00
|
|
|
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SUS_BOARD_ASS;
|
|
|
|
static constexpr Event TRANSITION_OTHER_SIDE_FAILED =
|
2022-03-17 19:23:39 +01:00
|
|
|
event::makeEvent(SUBSYSTEM_ID, 0, severity::HIGH);
|
2022-03-10 11:02:07 +01:00
|
|
|
static constexpr Event NOT_ENOUGH_DEVICES_DUAL_MODE =
|
2022-03-17 19:23:39 +01:00
|
|
|
event::makeEvent(SUBSYSTEM_ID, 1, severity::HIGH);
|
2022-03-10 11:02:07 +01:00
|
|
|
static constexpr Event POWER_STATE_MACHINE_TIMEOUT =
|
2022-03-17 19:23:39 +01:00
|
|
|
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);
|
2022-03-03 15:37:36 +01:00
|
|
|
|
|
|
|
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;
|
2022-03-03 15:37:36 +01:00
|
|
|
FixedArrayList<ModeListEntry, NUMBER_SUN_SENSORS> modeTable;
|
|
|
|
|
|
|
|
SusAssHelper helper;
|
|
|
|
PowerSwitchIF* pwrSwitcher = nullptr;
|
2022-03-17 19:23:39 +01:00
|
|
|
bool tryingOtherSide = false;
|
|
|
|
bool dualModeErrorSwitch = true;
|
2022-03-03 15:37:36 +01:00
|
|
|
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);
|
2022-03-03 15:37:36 +01:00
|
|
|
void refreshHelperModes();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* MISSION_SYSTEM_SUSASSEMBLY_H_ */
|