add health IF to heater handler
This commit is contained in:
@ -1,21 +1,31 @@
|
||||
#include "HeaterHandler.h"
|
||||
|
||||
#include <fsfw/health/HealthTableIF.h>
|
||||
#include <fsfw/ipc/QueueFactory.h>
|
||||
#include <fsfw/objectmanager/ObjectManager.h>
|
||||
#include <fsfw_hal/common/gpio/GpioCookie.h>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "devices/gpioIds.h"
|
||||
#include "devices/powerSwitcherList.h"
|
||||
|
||||
HeaterHandler::HeaterHandler(object_id_t setObjectId_, object_id_t gpioDriverId_,
|
||||
CookieIF* gpioCookie_, object_id_t mainLineSwitcherObjectId_,
|
||||
uint8_t mainLineSwitch_)
|
||||
CookieIF* gpioCookie_, PowerSwitchIF* mainLineSwitcher_,
|
||||
power::Switch_t mainLineSwitch_, HealthTableIF* healthTable_)
|
||||
: SystemObject(setObjectId_),
|
||||
gpioDriverId(gpioDriverId_),
|
||||
gpioCookie(gpioCookie_),
|
||||
mainLineSwitcherObjectId(mainLineSwitcherObjectId_),
|
||||
mainLineSwitcher(mainLineSwitcher_),
|
||||
mainLineSwitch(mainLineSwitch_),
|
||||
healthTable(healthTable_),
|
||||
actionHelper(this, nullptr) {
|
||||
if (mainLineSwitcher == nullptr) {
|
||||
throw std::invalid_argument("HeaterHandler::HeaterHandler: Invalid PowerSwitchIF");
|
||||
}
|
||||
if (healthTable == nullptr) {
|
||||
throw std::invalid_argument("HeaterHandler::HeaterHandler: Invalid HealthTableIF");
|
||||
}
|
||||
auto mqArgs = MqArgs(setObjectId_, static_cast<void*>(this));
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(
|
||||
cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
|
||||
@ -55,21 +65,16 @@ ReturnValue_t HeaterHandler::initialize() {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
if (healthTable != nullptr) {
|
||||
healthTable->registerObject(getObjectId());
|
||||
}
|
||||
|
||||
IPCStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (IPCStore == nullptr) {
|
||||
sif::error << "HeaterHandler::initialize: IPC store not set up in factory." << std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
if (mainLineSwitcherObjectId != objects::NO_OBJECT) {
|
||||
mainLineSwitcher = ObjectManager::instance()->get<PowerSwitchIF>(mainLineSwitcherObjectId);
|
||||
if (mainLineSwitcher == nullptr) {
|
||||
sif::error << "HeaterHandler::initialize: Failed to get main line switcher. Make sure "
|
||||
<< "main line switcher object is initialized." << std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
result = actionHelper.initialize(commandQueue);
|
||||
if (result != RETURN_OK) {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
@ -345,4 +350,19 @@ ReturnValue_t HeaterHandler::getSwitchState(uint8_t switchNr) const { return 0;
|
||||
|
||||
ReturnValue_t HeaterHandler::getFuseState(uint8_t fuseNr) const { return 0; }
|
||||
|
||||
uint32_t HeaterHandler::getSwitchDelayMs(void) const { return 0; }
|
||||
uint32_t HeaterHandler::getSwitchDelayMs(void) const { return 2000; }
|
||||
|
||||
ReturnValue_t HeaterHandler::setHealth(HealthState health) {
|
||||
if (healthTable != nullptr) {
|
||||
healthTable->setHealth(getObjectId(), health);
|
||||
return RETURN_OK;
|
||||
}
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
HasHealthIF::HealthState HeaterHandler::getHealth() {
|
||||
if (healthTable != nullptr) {
|
||||
return healthTable->getHealth(getObjectId());
|
||||
}
|
||||
return HasHealthIF::HealthState::HEALTHY;
|
||||
}
|
||||
|
Reference in New Issue
Block a user