Robin Mueller
120153e9c7
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
123 lines
4.2 KiB
C++
123 lines
4.2 KiB
C++
#ifndef MISSION_SYSTEM_ACSBOARDASSEMBLY_H_
|
|
#define MISSION_SYSTEM_ACSBOARDASSEMBLY_H_
|
|
|
|
#include <common/config/commonSubsystemIds.h>
|
|
#include <devices/powerSwitcherList.h>
|
|
#include <fsfw/devicehandlers/AssemblyBase.h>
|
|
#include <fsfw/objectmanager/frameworkObjects.h>
|
|
|
|
struct AcsBoardHelper {
|
|
AcsBoardHelper(object_id_t mgm0Id, object_id_t mgm1Id, object_id_t mgm2Id, object_id_t mgm3Id,
|
|
object_id_t gyro0Id, object_id_t gyro1Id, object_id_t gyro2Id, object_id_t gyro3Id,
|
|
object_id_t gpsId)
|
|
: mgm0Lis3IdSideA(mgm0Id),
|
|
mgm1Rm3100IdSideA(mgm1Id),
|
|
mgm2Lis3IdSideB(mgm2Id),
|
|
mgm3Rm3100IdSideB(mgm3Id),
|
|
gyro0AdisIdSideA(gyro0Id),
|
|
gyro1L3gIdSideA(gyro1Id),
|
|
gyro2AdisIdSideB(gyro2Id),
|
|
gyro3L3gIdSideB(gyro3Id) {}
|
|
|
|
object_id_t mgm0Lis3IdSideA = objects::NO_OBJECT;
|
|
object_id_t mgm1Rm3100IdSideA = objects::NO_OBJECT;
|
|
object_id_t mgm2Lis3IdSideB = objects::NO_OBJECT;
|
|
object_id_t mgm3Rm3100IdSideB = objects::NO_OBJECT;
|
|
|
|
object_id_t gyro0AdisIdSideA = objects::NO_OBJECT;
|
|
object_id_t gyro1L3gIdSideA = objects::NO_OBJECT;
|
|
object_id_t gyro2AdisIdSideB = objects::NO_OBJECT;
|
|
object_id_t gyro3L3gIdSideB = objects::NO_OBJECT;
|
|
|
|
object_id_t gpsId = objects::NO_OBJECT;
|
|
|
|
Mode_t gyro0SideAMode = HasModesIF::MODE_OFF;
|
|
Mode_t gyro1SideAMode = HasModesIF::MODE_OFF;
|
|
Mode_t gyro2SideBMode = HasModesIF::MODE_OFF;
|
|
Mode_t gyro3SideBMode = HasModesIF::MODE_OFF;
|
|
Mode_t mgm0SideAMode = HasModesIF::MODE_OFF;
|
|
Mode_t mgm1SideAMode = HasModesIF::MODE_OFF;
|
|
Mode_t mgm2SideBMode = HasModesIF::MODE_OFF;
|
|
Mode_t mgm3SideBMode = HasModesIF::MODE_OFF;
|
|
Mode_t gpsMode = HasModesIF::MODE_OFF;
|
|
};
|
|
|
|
enum ModeTableIdx : uint8_t {
|
|
MGM_0_A = 0,
|
|
MGM_1_A = 1,
|
|
MGM_2_B = 2,
|
|
MGM_3_B = 3,
|
|
GYRO_0_A = 4,
|
|
GYRO_1_A = 5,
|
|
GYRO_2_B = 6,
|
|
GYRO_3_B = 7,
|
|
GPS = 8
|
|
};
|
|
|
|
class PowerSwitchIF;
|
|
class GpioIF;
|
|
|
|
class AcsBoardAssembly : public AssemblyBase {
|
|
public:
|
|
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::ACS_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 uint8_t NUMBER_DEVICES_MODE_TABLE = 9;
|
|
|
|
enum Submodes : Submode_t { A_SIDE = 0, B_SIDE = 1, DUAL_MODE = 2 };
|
|
|
|
AcsBoardAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher,
|
|
AcsBoardHelper helper, GpioIF* gpioIF);
|
|
|
|
void setPreferredSide(Submodes submode);
|
|
|
|
/**
|
|
* In dual mode, the A side or the B side GPS device can be used, but not both.
|
|
* This function can be used to switch the used GPS device.
|
|
* @param side
|
|
*/
|
|
void selectGpsInDualMode(Submodes side);
|
|
|
|
private:
|
|
static constexpr pcduSwitches::Switches SWITCH_A =
|
|
pcduSwitches::Switches::PDU1_CH7_ACS_A_SIDE_3V3;
|
|
static constexpr pcduSwitches::Switches SWITCH_B =
|
|
pcduSwitches::Switches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3;
|
|
|
|
enum class States { IDLE, SWITCHING_POWER, MODE_COMMANDING } state = States::IDLE;
|
|
|
|
PowerSwitchIF* pwrSwitcher = nullptr;
|
|
bool tryingOtherSide = false;
|
|
AcsBoardHelper helper;
|
|
GpioIF* gpioIF = nullptr;
|
|
Submodes defaultSubmode = Submodes::A_SIDE;
|
|
bool dualModeErrorSwitch = true;
|
|
FixedArrayList<ModeListEntry, NUMBER_DEVICES_MODE_TABLE> modeTable;
|
|
|
|
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;
|
|
void handleModeReached() override;
|
|
void handleModeTransitionFailed(ReturnValue_t result) override;
|
|
void handleChildrenLostMode(ReturnValue_t result) 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);
|
|
ReturnValue_t handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode);
|
|
void powerStateMachine(Mode_t mode, Submode_t submode);
|
|
void initModeTableEntry(object_id_t id, ModeListEntry& entry);
|
|
void refreshHelperModes();
|
|
};
|
|
|
|
#endif /* MISSION_SYSTEM_ACSBOARDASSEMBLY_H_ */
|