Heaters are own objects with HealthIF now
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
#include <fsfw/action/HasActionsIF.h>
|
||||
#include <fsfw/devicehandlers/CookieIF.h>
|
||||
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
||||
#include <fsfw/devicehandlers/HealthDevice.h>
|
||||
#include <fsfw/health/HasHealthIF.h>
|
||||
#include <fsfw/health/HealthHelper.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
@ -13,13 +14,26 @@
|
||||
#include <fsfw/timemanager/Countdown.h>
|
||||
#include <fsfw_hal/common/gpio/GpioIF.h>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "devices/heaterSwitcherList.h"
|
||||
|
||||
class PowerSwitchIF;
|
||||
class HealthTableIF;
|
||||
|
||||
namespace heater {
|
||||
|
||||
static constexpr uint8_t NUMBER_OF_HEATERS = 8;
|
||||
|
||||
}
|
||||
|
||||
using HeaterPair = std::pair<HealthDevice*, gpioId_t>;
|
||||
|
||||
struct HeaterHelper {
|
||||
public:
|
||||
HeaterHelper(std::array<HeaterPair, heater::NUMBER_OF_HEATERS> heaters) : heaters(heaters) {}
|
||||
std::array<HeaterPair, heater::NUMBER_OF_HEATERS> heaters = {};
|
||||
};
|
||||
/**
|
||||
* @brief This class intends the control of heaters.
|
||||
*
|
||||
@ -27,7 +41,6 @@ class HealthTableIF;
|
||||
*/
|
||||
class HeaterHandler : public ExecutableObjectIF,
|
||||
public PowerSwitchIF,
|
||||
public HasHealthIF,
|
||||
public SystemObject,
|
||||
public HasActionsIF {
|
||||
public:
|
||||
@ -42,24 +55,11 @@ class HeaterHandler : public ExecutableObjectIF,
|
||||
/** Device command IDs */
|
||||
static const DeviceCommandId_t SWITCH_HEATER = 0x0;
|
||||
|
||||
HeaterHandler(object_id_t setObjectId, object_id_t gpioDriverId, CookieIF* gpioCookie,
|
||||
HeaterHandler(object_id_t setObjectId, GpioIF* gpioInterface_, HeaterHelper helper,
|
||||
PowerSwitchIF* mainLineSwitcherObjectId, power::Switch_t mainLineSwitch);
|
||||
|
||||
virtual ~HeaterHandler();
|
||||
|
||||
/**
|
||||
* @brief Set the Health State
|
||||
* The parent will be informed, if the Health changes
|
||||
* @param health
|
||||
*/
|
||||
ReturnValue_t setHealth(HealthState health) override;
|
||||
|
||||
/**
|
||||
* @brief Get Health State
|
||||
* @return Health State of the object
|
||||
*/
|
||||
HasHealthIF::HealthState getHealth() override;
|
||||
|
||||
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
||||
|
||||
virtual ReturnValue_t sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) override;
|
||||
@ -88,6 +88,7 @@ class HeaterHandler : public ExecutableObjectIF,
|
||||
static const MessageQueueId_t NO_COMMANDER = 0;
|
||||
|
||||
enum SwitchState : bool { ON = true, OFF = false };
|
||||
enum SwitchAction : uint8_t { SET_SWITCH_OFF, SET_SWITCH_ON, NONE };
|
||||
|
||||
/**
|
||||
* @brief Struct holding information about a heater command to execute.
|
||||
@ -99,35 +100,27 @@ class HeaterHandler : public ExecutableObjectIF,
|
||||
* @param waitSwitchOn True if the command is waiting for the main switch being set on.
|
||||
* @param mainSwitchCountdown Sets timeout to wait for main switch being set on.
|
||||
*/
|
||||
typedef struct HeaterCommandInfo {
|
||||
uint8_t action;
|
||||
MessageQueueId_t replyQueue;
|
||||
struct HeaterWrapper {
|
||||
HeaterWrapper(HeaterPair pair) : healthDevice(pair.first), gpioId(pair.second) {}
|
||||
HealthDevice* healthDevice = nullptr;
|
||||
gpioId_t gpioId = gpio::NO_GPIO;
|
||||
SwitchAction action = SwitchAction::NONE;
|
||||
MessageQueueId_t replyQueue = MessageQueueIF::NO_QUEUE;
|
||||
bool active = false;
|
||||
SwitchState switchState = SwitchState::OFF;
|
||||
bool waitMainSwitchOn = false;
|
||||
Countdown mainSwitchCountdown;
|
||||
} HeaterCommandInfo_t;
|
||||
};
|
||||
|
||||
enum SwitchAction { SET_SWITCH_OFF, SET_SWITCH_ON };
|
||||
using HeaterMap = std::vector<HeaterWrapper>;
|
||||
|
||||
using switchNr_t = uint8_t;
|
||||
using HeaterMap = std::unordered_map<switchNr_t, HeaterCommandInfo_t>;
|
||||
using HeaterMapIter = HeaterMap::iterator;
|
||||
HeaterMap heaterVec = {};
|
||||
|
||||
HeaterMap heaterMap;
|
||||
|
||||
bool switchStates[heaterSwitches::NUMBER_OF_SWITCHES];
|
||||
HeaterHelper helper;
|
||||
|
||||
/** Size of command queue */
|
||||
size_t cmdQueueSize = 20;
|
||||
|
||||
/**
|
||||
* The object ID of the GPIO driver which enables and disables the
|
||||
* heaters.
|
||||
*/
|
||||
object_id_t gpioDriverId;
|
||||
|
||||
CookieIF* gpioCookie;
|
||||
|
||||
GpioIF* gpioInterface = nullptr;
|
||||
|
||||
/** Queue to receive messages from other objects. */
|
||||
@ -141,11 +134,9 @@ class HeaterHandler : public ExecutableObjectIF,
|
||||
/** Switch number of the heater power supply switch */
|
||||
power::Switch_t mainLineSwitch;
|
||||
|
||||
HealthHelper healthHelper;
|
||||
|
||||
ActionHelper actionHelper;
|
||||
|
||||
StorageManagerIF* IPCStore = nullptr;
|
||||
StorageManagerIF* ipcStore = nullptr;
|
||||
|
||||
void readCommandQueue();
|
||||
|
||||
@ -153,13 +144,7 @@ class HeaterHandler : public ExecutableObjectIF,
|
||||
* @brief Returns the state of a switch (ON - true, or OFF - false).
|
||||
* @param switchNr The number of the switch to check.
|
||||
*/
|
||||
bool checkSwitchState(int switchNr);
|
||||
|
||||
/**
|
||||
* @brief Returns the ID of the GPIO related to a heater identified by the switch number
|
||||
* which is defined in the heaterSwitches list.
|
||||
*/
|
||||
gpioId_t getGpioIdFromSwitchNr(int switchNr);
|
||||
SwitchState checkSwitchState(power::Switch_t switchNr);
|
||||
|
||||
/**
|
||||
* @brief This function runs commands waiting for execution.
|
||||
@ -173,9 +158,9 @@ class HeaterHandler : public ExecutableObjectIF,
|
||||
*/
|
||||
void setInitialSwitchStates();
|
||||
|
||||
void handleSwitchOnCommand(HeaterMapIter heaterMapIter);
|
||||
void handleSwitchOnCommand(uint8_t heaterIdx);
|
||||
|
||||
void handleSwitchOffCommand(HeaterMapIter heaterMapIter);
|
||||
void handleSwitchOffCommand(uint8_t heaterIdx);
|
||||
|
||||
/**
|
||||
* @brief Checks if all switches are off.
|
||||
|
Reference in New Issue
Block a user