eive-obsw/mission/acs/SusHandler.h

85 lines
3.2 KiB
C
Raw Normal View History

2023-03-01 16:36:21 +01:00
#ifndef MISSION_DEVICES_SusHandler_H_
#define MISSION_DEVICES_SusHandler_H_
2021-05-03 11:59:33 +02:00
2023-03-01 18:42:43 +01:00
#include <eive/eventSubsystemIds.h>
#include <eive/resultClassIds.h>
2023-03-26 16:42:00 +02:00
#include <mission/acs/susMax1227Helpers.h>
2023-03-02 11:27:19 +01:00
2023-03-01 16:36:21 +01:00
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
2022-02-22 20:34:25 +01:00
#include "fsfw/globalfunctions/PeriodicOperationDivider.h"
2023-03-24 20:50:33 +01:00
#include "mission/acs/acsBoardPolling.h"
2023-03-01 16:36:21 +01:00
2022-01-17 15:58:27 +01:00
class SusHandler : public DeviceHandlerBase {
public:
2023-03-01 16:36:21 +01:00
static constexpr DeviceCommandId_t REQUEST = 0x70;
static constexpr DeviceCommandId_t REPLY = 0x77;
2022-02-22 20:34:25 +01:00
2023-03-01 18:09:33 +01:00
static const uint8_t INTERFACE_ID = CLASS_ID::SUS_HANDLER;
2023-06-13 07:48:32 +02:00
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SUS_HANDLER;
2023-10-18 13:35:18 +02:00
//! [EXPORT] : [COMMENT] Detected invalid values, starting invalid message counting
static constexpr Event TEMPERATURE_ALL_ONES_START =
event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM);
2023-10-18 13:32:09 +02:00
//! [EXPORT] : [COMMENT] Detected valid values for a prolonged time again, resetting all counters.
//! P1: Number of periods with invalid messages.
//! P2: Maximum invalid message counter.
2023-09-07 16:03:36 +02:00
static constexpr Event TEMPERATURE_ALL_ONES_RECOVERY =
2023-09-11 15:39:21 +02:00
event::makeEvent(SUBSYSTEM_ID, 1, severity::INFO);
2021-05-03 11:59:33 +02:00
2023-03-01 16:36:21 +01:00
SusHandler(uint32_t objectId, uint8_t susIdx, object_id_t deviceCommunication,
CookieIF *comCookie);
2022-01-17 15:58:27 +01:00
virtual ~SusHandler();
2021-05-12 16:38:20 +02:00
2023-03-01 16:36:21 +01:00
void enablePeriodicPrintouts(bool enable, uint8_t divider);
2022-02-22 20:34:25 +01:00
void setToGoToNormalMode(bool enable);
2021-05-03 11:59:33 +02:00
2022-01-17 15:58:27 +01:00
protected:
2023-03-01 16:36:21 +01:00
/** DeviceHandlerBase overrides */
2022-01-17 15:58:27 +01:00
void doShutDown() override;
2023-03-01 16:36:21 +01:00
void doStartUp() override;
2023-03-01 18:15:53 +01:00
uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override;
2023-03-01 16:36:21 +01:00
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData,
2022-01-17 15:58:27 +01:00
size_t commandDataLen) override;
2023-03-01 16:36:21 +01:00
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId,
size_t *foundLen) override;
2023-03-01 18:15:53 +01:00
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
2023-03-01 16:36:21 +01:00
void fillCommandAndReplyMap() override;
void modeChanged(void) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override;
LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override;
2021-05-03 11:59:33 +02:00
2022-01-17 15:58:27 +01:00
private:
2023-03-01 16:36:21 +01:00
susMax1227::SusDataset dataset;
acs::SusRequest request{};
uint8_t susIdx;
2023-10-18 13:32:09 +02:00
// After 1 minute, trigger the event for the invalid messages.
Countdown invalidMsgCountdown = Countdown(60000);
2023-09-07 16:03:36 +02:00
bool waitingForRecovery = true;
uint32_t invalidMsgCounter = 0;
2023-10-18 13:32:09 +02:00
uint32_t invalidMsgCounterMax = 0;
uint32_t invalidMsgPeriodCounter = 0;
2021-05-07 18:48:42 +02:00
2023-03-01 16:36:21 +01:00
uint32_t transitionDelay = 1000;
bool goToNormalMode = false;
2021-05-07 18:48:42 +02:00
2022-02-22 20:34:25 +01:00
PoolEntry<float> tempC = PoolEntry<float>({0.0});
PoolEntry<uint16_t> channelVec = PoolEntry<uint16_t>({0, 0, 0, 0, 0, 0});
2021-05-03 11:59:33 +02:00
2023-03-01 16:36:21 +01:00
enum class InternalState {
NONE,
STARTUP,
SHUTDOWN,
};
2021-05-12 13:06:56 +02:00
2023-03-01 16:36:21 +01:00
InternalState internalState = InternalState::NONE;
bool commandExecuted = false;
2021-05-12 13:06:56 +02:00
2023-03-01 16:36:21 +01:00
ReturnValue_t prepareRequest(acs::SimpleSensorMode mode);
2021-05-03 11:59:33 +02:00
};
2023-03-01 16:36:21 +01:00
#endif /* MISSION_DEVICES_SusHandler_H_ */