2021-04-20 16:12:50 +02:00
|
|
|
#ifndef FSFW_THERMAL_HEATER_H_
|
|
|
|
#define FSFW_THERMAL_HEATER_H_
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "../devicehandlers/HealthDevice.h"
|
|
|
|
#include "../parameters/ParameterHelper.h"
|
|
|
|
#include "../power/PowerSwitchIF.h"
|
|
|
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
|
|
|
#include "../timemanager/Countdown.h"
|
2021-04-20 16:12:50 +02:00
|
|
|
#include <cstdint>
|
|
|
|
|
2018-07-12 16:29:32 +02:00
|
|
|
|
|
|
|
class Heater: public HealthDevice, public ReceivesParameterMessagesIF {
|
2021-04-20 16:12:50 +02:00
|
|
|
friend class RedundantHeater;
|
2018-07-12 16:29:32 +02:00
|
|
|
public:
|
|
|
|
|
2021-04-20 16:12:50 +02:00
|
|
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER;
|
|
|
|
static const Event HEATER_ON = MAKE_EVENT(0, severity::INFO);
|
|
|
|
static const Event HEATER_OFF = MAKE_EVENT(1, severity::INFO);
|
|
|
|
static const Event HEATER_TIMEOUT = MAKE_EVENT(2, severity::LOW);
|
|
|
|
static const Event HEATER_STAYED_ON = MAKE_EVENT(3, severity::LOW);
|
|
|
|
static const Event HEATER_STAYED_OFF = MAKE_EVENT(4, severity::LOW);
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 16:12:50 +02:00
|
|
|
Heater(uint32_t objectId, uint8_t switch0, uint8_t switch1);
|
|
|
|
virtual ~Heater();
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 16:12:50 +02:00
|
|
|
ReturnValue_t performOperation(uint8_t opCode);
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 16:12:50 +02:00
|
|
|
ReturnValue_t initialize();
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 16:12:50 +02:00
|
|
|
ReturnValue_t set();
|
|
|
|
void clear(bool passive);
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 16:12:50 +02:00
|
|
|
void setPowerSwitcher(PowerSwitchIF *powerSwitch);
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 16:12:50 +02:00
|
|
|
MessageQueueId_t getCommandQueue() const;
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 16:12:50 +02:00
|
|
|
ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId,
|
|
|
|
ParameterWrapper *parameterWrapper,
|
|
|
|
const ParameterWrapper *newValues, uint16_t startAtIndex);
|
2018-07-12 16:29:32 +02:00
|
|
|
|
|
|
|
protected:
|
2021-04-20 16:12:50 +02:00
|
|
|
static const uint32_t INVALID_UPTIME = 0;
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 16:12:50 +02:00
|
|
|
enum InternalState {
|
|
|
|
STATE_ON,
|
|
|
|
STATE_OFF,
|
|
|
|
STATE_PASSIVE,
|
|
|
|
STATE_WAIT_FOR_SWITCHES_ON,
|
|
|
|
STATE_WAIT_FOR_SWITCHES_OFF,
|
|
|
|
STATE_WAIT_FOR_FDIR, // Used to avoid doing anything until fdir decided what to do
|
|
|
|
STATE_FAULTY,
|
|
|
|
STATE_WAIT, // Used when waiting for system to recover from miniops
|
|
|
|
// Entered when under external control and a fdir reaction would be triggered.
|
|
|
|
// This is useful when leaving external control into an unknown state
|
|
|
|
STATE_EXTERNAL_CONTROL
|
|
|
|
// If no fdir reaction is triggered under external control the state is still ok and
|
|
|
|
// no need for any special treatment is needed
|
|
|
|
} internalState;
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 17:29:56 +02:00
|
|
|
PowerSwitchIF *powerSwitcher = nullptr;
|
|
|
|
MessageQueueId_t pcduQueueId = MessageQueueIF::NO_QUEUE;
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 16:12:50 +02:00
|
|
|
uint8_t switch0;
|
|
|
|
uint8_t switch1;
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 17:29:56 +02:00
|
|
|
bool wasOn = false;
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 17:29:56 +02:00
|
|
|
bool timedOut = false;
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 17:29:56 +02:00
|
|
|
bool reactedToBeingFaulty = false;
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 17:29:56 +02:00
|
|
|
bool passive = false;
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 17:29:56 +02:00
|
|
|
MessageQueueIF* eventQueue = nullptr;
|
2021-04-20 16:12:50 +02:00
|
|
|
Countdown heaterOnCountdown;
|
|
|
|
Countdown switchCountdown;
|
|
|
|
ParameterHelper parameterHelper;
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 16:12:50 +02:00
|
|
|
enum Action {
|
|
|
|
SET, CLEAR
|
2021-04-20 17:29:56 +02:00
|
|
|
} lastAction = CLEAR;
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 16:12:50 +02:00
|
|
|
void doAction(Action action);
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 16:12:50 +02:00
|
|
|
void setSwitch(uint8_t number, ReturnValue_t state,
|
|
|
|
uint32_t *upTimeOfSwitching);
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 16:12:50 +02:00
|
|
|
void handleQueue();
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2021-04-20 16:12:50 +02:00
|
|
|
void handleEventQueue();
|
2018-07-12 16:29:32 +02:00
|
|
|
};
|
|
|
|
|
2021-04-20 16:12:50 +02:00
|
|
|
#endif /* FSFW_THERMAL_HEATER_H_ */
|