2022-02-25 11:58:02 +01:00
|
|
|
#ifndef MISSION_SYSTEM_ACSBOARDASSEMBLY_H_
|
|
|
|
#define MISSION_SYSTEM_ACSBOARDASSEMBLY_H_
|
|
|
|
|
2022-03-04 00:55:51 +01:00
|
|
|
#include <common/config/commonSubsystemIds.h>
|
2022-03-03 15:37:36 +01:00
|
|
|
#include <devices/powerSwitcherList.h>
|
2022-03-02 17:56:54 +01:00
|
|
|
#include <fsfw/devicehandlers/AssemblyBase.h>
|
|
|
|
#include <fsfw/objectmanager/frameworkObjects.h>
|
2022-02-25 11:58:02 +01:00
|
|
|
|
2022-03-05 03:02:09 +01:00
|
|
|
#include "DualLanePowerStateMachine.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),
|
2022-03-04 18:12:16 +01:00
|
|
|
gyro3L3gIdSideB(gyro3Id),
|
|
|
|
gpsId(gpsId) {}
|
2022-02-25 11:58:02 +01:00
|
|
|
|
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-02-25 11:58:02 +01:00
|
|
|
|
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
|
|
|
|
2022-03-05 03:02:09 +01:00
|
|
|
/**
|
|
|
|
* @brief Assembly class which manages redundant ACS board sides
|
|
|
|
* @details
|
|
|
|
* This class takes care of ensuring that enough devices on the ACS board are available at all
|
|
|
|
* times. It does so by doing autonomous transitions to the redundant side or activating both sides
|
|
|
|
* if not enough devices are available.
|
|
|
|
*
|
|
|
|
* This class also takes care of switching on the A side and/or B side power lanes. Normally,
|
|
|
|
* doing this task would be performed by the device handlers, but this is not possible for the
|
|
|
|
* ACS board where multiple sensors share the same power supply.
|
|
|
|
*/
|
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);
|
2022-03-07 16:47:15 +01:00
|
|
|
static constexpr Event POWER_STATE_MACHINE_TIMEOUT =
|
|
|
|
event::makeEvent(SUBSYSTEM_ID, 2, severity::MEDIUM);
|
|
|
|
|
2022-03-03 15:37:36 +01:00
|
|
|
static constexpr uint8_t NUMBER_DEVICES_MODE_TABLE = 9;
|
|
|
|
|
|
|
|
AcsBoardAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher,
|
2022-03-04 00:55:51 +01:00
|
|
|
AcsBoardHelper helper, GpioIF* gpioIF);
|
|
|
|
|
2022-03-05 03:02:09 +01:00
|
|
|
void setPreferredSide(duallane::Submodes submode);
|
2022-03-04 00:55:51 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2022-03-05 03:02:09 +01:00
|
|
|
void selectGpsInDualMode(duallane::Submodes side);
|
2022-03-02 17:56:54 +01:00
|
|
|
|
|
|
|
private:
|
2022-03-03 15:37:36 +01:00
|
|
|
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;
|
|
|
|
|
2022-03-05 03:02:09 +01:00
|
|
|
// This helper object complete encapsulates power switching
|
|
|
|
DualLanePowerStateMachine pwrStateMachine;
|
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;
|
2022-03-07 16:47:15 +01:00
|
|
|
uint8_t powerRetryCounter = 0;
|
2022-03-07 18:39:33 +01:00
|
|
|
// duallane::PwrStates state = duallane::PwrStates::IDLE;
|
2022-03-05 03:02:09 +01:00
|
|
|
duallane::Submodes defaultSubmode = duallane::Submodes::A_SIDE;
|
2022-03-04 00:55:51 +01:00
|
|
|
bool dualModeErrorSwitch = true;
|
2022-03-03 15:37:36 +01:00
|
|
|
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;
|
2022-03-05 03:02:09 +01:00
|
|
|
void performChildOperation() override;
|
|
|
|
void startTransition(Mode_t mode, Submode_t submode) override;
|
2022-03-03 15:37:36 +01:00
|
|
|
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);
|
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-05 03:02:09 +01:00
|
|
|
void finishModeOp();
|
|
|
|
/**
|
|
|
|
* Thin wrapper function which is required because the helper class
|
|
|
|
* can not access protected member functions.
|
|
|
|
* @param mode
|
|
|
|
* @param submode
|
|
|
|
*/
|
2022-03-07 18:39:33 +01:00
|
|
|
ReturnValue_t pwrStateMachineWrapper();
|
2022-03-02 17:56:54 +01:00
|
|
|
};
|
2022-02-25 11:58:02 +01:00
|
|
|
|
|
|
|
#endif /* MISSION_SYSTEM_ACSBOARDASSEMBLY_H_ */
|