eive-obsw/mission/system/objects/AcsBoardAssembly.h
Robin Mueller 269de1782a
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
Merge branch 'mueller/obsw-update-cmds' into mueller/acs-ss-init
2022-09-27 19:26:23 +02:00

130 lines
4.8 KiB
C++

#ifndef MISSION_SYSTEM_ACSBOARDASSEMBLY_H_
#define MISSION_SYSTEM_ACSBOARDASSEMBLY_H_
#include <devices/powerSwitcherList.h>
#include <fsfw/objectmanager/frameworkObjects.h>
#include <fsfw_hal/common/gpio/gpioDefinitions.h>
#include "DualLaneAssemblyBase.h"
#include "DualLanePowerStateMachine.h"
#include "eive/eventSubsystemIds.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),
gpsId(gpsId) {}
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;
/**
* @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.
*/
class AcsBoardAssembly : public DualLaneAssemblyBase {
public:
// 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
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 Event POWER_STATE_MACHINE_TIMEOUT =
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);
static constexpr uint8_t NUMBER_DEVICES_MODE_TABLE = 9;
AcsBoardAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher,
AcsBoardHelper helper, GpioIF* gpioIF);
/**
* 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);
private:
static constexpr pcdu::Switches SWITCH_A = pcdu::Switches::PDU1_CH7_ACS_A_SIDE_3V3;
static constexpr pcdu::Switches SWITCH_B = pcdu::Switches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3;
bool tryingOtherSide = false;
bool dualModeErrorSwitch = true;
AcsBoardHelper helper;
GpioIF* gpioIF = nullptr;
FixedArrayList<ModeListEntry, NUMBER_DEVICES_MODE_TABLE> modeTable;
void gpioHandler(gpioId_t gpio, bool high, std::string error);
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 handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode);
void refreshHelperModes();
};
#endif /* MISSION_SYSTEM_ACSBOARDASSEMBLY_H_ */