eive-obsw/mission/system/acs/AcsBoardAssembly.h

144 lines
5.5 KiB
C
Raw Normal View History

#ifndef MISSION_SYSTEM_ACSBOARDASSEMBLY_H_
#define MISSION_SYSTEM_ACSBOARDASSEMBLY_H_
#include <devices/powerSwitcherList.h>
2022-03-02 17:56:54 +01:00
#include <fsfw/objectmanager/frameworkObjects.h>
#include <fsfw_hal/common/gpio/gpioDefinitions.h>
2022-03-10 10:54:27 +01:00
#include "DualLaneAssemblyBase.h"
2022-09-16 12:28:39 +02:00
#include "eive/eventSubsystemIds.h"
2023-03-24 20:50:33 +01:00
#include "mission/system/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,
2023-03-30 17:16:59 +02:00
object_id_t gpsId, object_id_t gps0HealthDev, object_id_t gps1HealthDev)
2022-03-02 17:56:54 +01:00
: mgm0Lis3IdSideA(mgm0Id),
mgm1Rm3100IdSideA(mgm1Id),
mgm2Lis3IdSideB(mgm2Id),
mgm3Rm3100IdSideB(mgm3Id),
gyro0AdisIdSideA(gyro0Id),
gyro1L3gIdSideA(gyro1Id),
gyro2AdisIdSideB(gyro2Id),
2022-03-04 18:12:16 +01:00
gyro3L3gIdSideB(gyro3Id),
2023-04-03 19:15:14 +02:00
gpsId(gpsId),
healthDevGps0(gps0HealthDev),
healthDevGps1(gps1HealthDev) {}
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;
2023-03-30 17:16:59 +02:00
object_id_t healthDevGps0 = objects::NO_OBJECT;
object_id_t healthDevGps1 = objects::NO_OBJECT;
2022-03-02 17:56:54 +01:00
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
/**
* @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-10 10:54:27 +01:00
class AcsBoardAssembly : public DualLaneAssemblyBase {
2022-03-02 17:56:54 +01:00
public:
2022-03-11 14:33:09 +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-04 00:55:51 +01:00
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::ACS_BOARD_ASS;
static constexpr Event TRANSITION_OTHER_SIDE_FAILED =
2022-03-11 14:33:09 +01:00
event::makeEvent(SUBSYSTEM_ID, 0, severity::HIGH);
2022-03-04 00:55:51 +01:00
static constexpr Event NOT_ENOUGH_DEVICES_DUAL_MODE =
2022-03-11 14:33:09 +01:00
event::makeEvent(SUBSYSTEM_ID, 1, severity::HIGH);
static constexpr Event POWER_STATE_MACHINE_TIMEOUT =
2022-03-11 14:33:09 +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);
2023-03-30 17:16:59 +02:00
//! [EXPORT] : [COMMENT] This is triggered when the assembly would have normally switched
//! the board side, but the GPS device of the other side was marked faulty.
//! P1: Current submode.
static constexpr Event DIRECT_TRANSITION_TO_DUAL_OTHER_GPS_FAULTY =
event::makeEvent(SUBSYSTEM_ID, 4, severity::MEDIUM);
static constexpr uint8_t NUMBER_DEVICES_MODE_TABLE = 9;
2022-09-29 19:40:00 +02:00
AcsBoardAssembly(object_id_t objectId, PowerSwitchIF* pwrSwitcher, AcsBoardHelper helper,
GpioIF* gpioIF);
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
*/
void selectGpsInDualMode(duallane::Submodes side);
2022-03-02 17:56:54 +01:00
private:
2023-03-16 18:47:51 +01:00
static constexpr power::Switches SWITCH_A = power::Switches::PDU1_CH7_ACS_A_SIDE_3V3;
static constexpr power::Switches SWITCH_B = power::Switches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3;
2022-03-02 17:56:54 +01:00
AcsBoardHelper helper;
2022-03-04 00:55:51 +01:00
GpioIF* gpioIF = nullptr;
2022-03-10 10:54:27 +01:00
FixedArrayList<ModeListEntry, NUMBER_DEVICES_MODE_TABLE> modeTable;
void gpioHandler(gpioId_t gpio, bool high, std::string error);
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;
2022-03-10 10:54:27 +01:00
2023-03-30 17:16:59 +02:00
void handleChildrenLostMode(ReturnValue_t result) override;
2022-03-03 10:12:59 +01:00
ReturnValue_t handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode);
2023-03-02 15:02:02 +01:00
ReturnValue_t checkAndHandleHealthStates(Mode_t deviceMode, Submode_t deviceSubmode);
2022-03-03 10:28:55 +01:00
void refreshHelperModes();
2023-04-03 18:02:45 +02:00
bool gps0HealthDevFaulty() const;
bool gps1HealthDevFaulty() const;
2023-04-03 18:54:47 +02:00
bool isGpsUsable(uint8_t targetSubmode) const;
2022-03-02 17:56:54 +01:00
};
#endif /* MISSION_SYSTEM_ACSBOARDASSEMBLY_H_ */