eive-obsw/mission/system/AcsBoardAssembly.h

123 lines
4.2 KiB
C
Raw Normal View History

#ifndef MISSION_SYSTEM_ACSBOARDASSEMBLY_H_
#define MISSION_SYSTEM_ACSBOARDASSEMBLY_H_
2022-03-04 00:55:51 +01:00
#include <common/config/commonSubsystemIds.h>
#include <devices/powerSwitcherList.h>
2022-03-02 17:56:54 +01:00
#include <fsfw/devicehandlers/AssemblyBase.h>
#include <fsfw/objectmanager/frameworkObjects.h>
2022-03-02 17:56:54 +01:00
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) {}
2022-03-02 17:56:54 +01:00
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;
2022-03-02 17:56:54 +01:00
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;
2022-03-04 00:55:51 +01:00
class GpioIF;
2022-03-02 17:56:54 +01:00
class AcsBoardAssembly : public AssemblyBase {
public:
2022-03-04 00:55:51 +01:00
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;
2022-03-04 00:55:51 +01:00
enum Submodes : Submode_t { A_SIDE = 0, B_SIDE = 1, DUAL_MODE = 2 };
AcsBoardAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher,
2022-03-04 00:55:51 +01:00
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);
2022-03-02 17:56:54 +01:00
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;
2022-03-02 17:56:54 +01:00
PowerSwitchIF* pwrSwitcher = nullptr;
2022-03-04 00:55:51 +01:00
bool tryingOtherSide = false;
2022-03-02 17:56:54 +01:00
AcsBoardHelper helper;
2022-03-04 00:55:51 +01:00
GpioIF* gpioIF = nullptr;
Submodes defaultSubmode = Submodes::A_SIDE;
bool dualModeErrorSwitch = true;
FixedArrayList<ModeListEntry, NUMBER_DEVICES_MODE_TABLE> modeTable;
2022-03-02 17:56:54 +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;
ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override;
void handleModeReached() override;
2022-03-03 20:11:12 +01:00
void handleModeTransitionFailed(ReturnValue_t result) override;
2022-03-04 00:55:51 +01:00
void handleChildrenLostMode(ReturnValue_t result) override;
2022-03-02 17:56:54 +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);
2022-03-03 10:12:59 +01:00
ReturnValue_t handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode);
void powerStateMachine(Mode_t mode, Submode_t submode);
2022-03-03 20:11:12 +01:00
void initModeTableEntry(object_id_t id, ModeListEntry& entry);
2022-03-03 10:28:55 +01:00
void refreshHelperModes();
2022-03-02 17:56:54 +01:00
};
#endif /* MISSION_SYSTEM_ACSBOARDASSEMBLY_H_ */