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>
|
|
|
|
|
|
|
|
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 : AssemblyBase {
|
|
|
|
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;
|
|
|
|
|
|
|
|
static constexpr Submode_t NOMINAL = 0;
|
|
|
|
static constexpr Submode_t REDUNDANT = 1;
|
|
|
|
static constexpr Submode_t DUAL_MODE = 2;
|
|
|
|
|
|
|
|
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-03-03 19:39:36 +01:00
|
|
|
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;
|
2022-03-03 15:37:36 +01:00
|
|
|
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;
|
|
|
|
ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override;
|
2022-03-03 20:11:12 +01:00
|
|
|
void handleModeReached() override;
|
|
|
|
void handleModeTransitionFailed(ReturnValue_t result) override;
|
2022-03-03 15:37:36 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 initModeTableEntry(object_id_t id, ModeListEntry& entry);
|
2022-03-03 15:37:36 +01:00
|
|
|
void refreshHelperModes();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* MISSION_SYSTEM_SUSASSEMBLY_H_ */
|