eive-obsw/mission/system/tcs/TcsBoardAssembly.h

60 lines
2.1 KiB
C
Raw Permalink Normal View History

#ifndef MISSION_SYSTEM_TCSSUBSYSTEM_H_
#define MISSION_SYSTEM_TCSSUBSYSTEM_H_
2022-03-22 15:49:22 +01:00
#include <fsfw/container/FixedArrayList.h>
2022-03-22 17:58:05 +01:00
#include <fsfw/devicehandlers/AssemblyBase.h>
2022-03-22 15:49:22 +01:00
#include <fsfw/power/PowerSwitcher.h>
2023-04-11 22:58:13 +02:00
#include <mission/power/defs.h>
#include <mission/system/SharedPowerAssemblyBase.h>
#include <atomic>
2022-03-21 10:12:17 +01:00
2022-09-14 13:44:43 +02:00
#include "events/subsystemIdRanges.h"
#include "returnvalues/classIds.h"
2022-03-22 11:57:48 +01:00
struct TcsBoardHelper {
TcsBoardHelper(std::array<std::pair<object_id_t, std::string>, 16> rtdInfos)
: rtdInfos(std::move(rtdInfos)) {}
2022-03-21 10:12:17 +01:00
std::array<std::pair<object_id_t, std::string>, 16> rtdInfos = {};
2022-03-22 11:57:48 +01:00
};
2023-04-11 22:58:13 +02:00
class TcsBoardAssembly : public SharedPowerAssemblyBase {
2022-03-22 15:49:22 +01:00
public:
2022-03-22 20:40:30 +01:00
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::TCS_BOARD_ASS;
2022-03-23 15:02:48 +01:00
static constexpr Event CHILDREN_LOST_MODE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM);
2022-03-22 20:40:30 +01:00
2022-09-29 19:40:00 +02:00
TcsBoardAssembly(object_id_t objectId, PowerSwitchIF* pwrSwitcher, power::Switch_t switcher,
2023-04-11 22:58:13 +02:00
TcsBoardHelper helper, std::atomic_bool& tcsShortlyUnavailable);
2022-03-22 14:30:42 +01:00
2022-03-22 15:49:22 +01:00
private:
static constexpr uint8_t NUMBER_RTDS = 16;
2022-03-22 20:35:37 +01:00
bool warningSwitch = true;
2022-03-22 15:49:22 +01:00
TcsBoardHelper helper;
FixedArrayList<ModeListEntry, NUMBER_RTDS> modeTable;
2023-04-11 22:58:13 +02:00
std::atomic_bool& tcsShortlyUnavailable;
2022-03-22 15:49:22 +01:00
2022-03-22 18:48:03 +01:00
ReturnValue_t handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode);
/**
* 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);
// AssemblyBase implementation
2022-03-22 17:58:05 +01:00
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;
2023-03-06 15:41:56 +01:00
ReturnValue_t checkAndHandleHealthStates(Mode_t deviceMode, Submode_t deviceSubmode);
2023-04-11 22:58:13 +02:00
bool checkAndHandleRecovery() override;
2022-03-22 20:40:30 +01:00
// These two overrides prevent a transition of the whole assembly back to off just because
// some devices are not working
2022-03-22 20:35:37 +01:00
void handleChildrenLostMode(ReturnValue_t result) override;
void handleModeTransitionFailed(ReturnValue_t result) override;
2022-03-21 10:12:17 +01:00
};
#endif /* MISSION_SYSTEM_TCSSUBSYSTEM_H_ */