Heater Health IF #236

Merged
meierj merged 44 commits from mueller/heater-health-if into develop 2022-05-13 18:38:13 +02:00
3 changed files with 27 additions and 32 deletions
Showing only changes of commit b98c691c2b - Show all commits

View File

@ -623,7 +623,7 @@ void ObjectFactory::createHeaterComponents(PowerSwitchIF* pwrSwitcher, HealthTab
heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpio); heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpio);
new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie, pwrSwitcher, new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie, pwrSwitcher,
pcdu::Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V, healthTable); pcdu::Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V);
} }
void ObjectFactory::createSolarArrayDeploymentComponents() { void ObjectFactory::createSolarArrayDeploymentComponents() {

View File

@ -12,20 +12,17 @@
HeaterHandler::HeaterHandler(object_id_t setObjectId_, object_id_t gpioDriverId_, HeaterHandler::HeaterHandler(object_id_t setObjectId_, object_id_t gpioDriverId_,
CookieIF* gpioCookie_, PowerSwitchIF* mainLineSwitcher_, CookieIF* gpioCookie_, PowerSwitchIF* mainLineSwitcher_,
power::Switch_t mainLineSwitch_, HealthTableIF* healthTable_) power::Switch_t mainLineSwitch_)
: SystemObject(setObjectId_), : SystemObject(setObjectId_),
gpioDriverId(gpioDriverId_), gpioDriverId(gpioDriverId_),
gpioCookie(gpioCookie_), gpioCookie(gpioCookie_),
mainLineSwitcher(mainLineSwitcher_), mainLineSwitcher(mainLineSwitcher_),
mainLineSwitch(mainLineSwitch_), mainLineSwitch(mainLineSwitch_),
healthTable(healthTable_), healthHelper(this, getObjectId()),
actionHelper(this, nullptr) { actionHelper(this, nullptr) {
if (mainLineSwitcher == nullptr) { if (mainLineSwitcher == nullptr) {
throw std::invalid_argument("HeaterHandler::HeaterHandler: Invalid PowerSwitchIF"); 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)); auto mqArgs = MqArgs(setObjectId_, static_cast<void*>(this));
commandQueue = QueueFactory::instance()->createMessageQueue( commandQueue = QueueFactory::instance()->createMessageQueue(
cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
@ -65,9 +62,7 @@ ReturnValue_t HeaterHandler::initialize() {
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
} }
if (healthTable != nullptr) { healthHelper.initialize(commandQueue->getId());
healthTable->registerObject(getObjectId());
}
IPCStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE); IPCStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
if (IPCStore == nullptr) { if (IPCStore == nullptr) {
@ -103,16 +98,24 @@ void HeaterHandler::setInitialSwitchStates() {
} }
void HeaterHandler::readCommandQueue() { void HeaterHandler::readCommandQueue() {
ReturnValue_t result = RETURN_OK;
CommandMessage command; CommandMessage command;
ReturnValue_t result = commandQueue->receiveMessage(&command); do {
if (result != RETURN_OK) { result = commandQueue->receiveMessage(&command);
return; if (result == MessageQueueIF::EMPTY) {
break;
} else if (result != RETURN_OK) {
sif::warning << "HeaterHandler::readCommandQueue: Message reception error" << std::endl;
} }
result = actionHelper.handleActionMessage(&command); result = actionHelper.handleActionMessage(&command);
if (result == RETURN_OK) { if (result == RETURN_OK) {
return; continue;
} }
result = healthHelper.handleHealthCommand(&command);
if (result == RETURN_OK) {
continue;
}
} while (result == RETURN_OK);
} }
ReturnValue_t HeaterHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, ReturnValue_t HeaterHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
@ -353,16 +356,8 @@ ReturnValue_t HeaterHandler::getFuseState(uint8_t fuseNr) const { return 0; }
uint32_t HeaterHandler::getSwitchDelayMs(void) const { return 2000; } uint32_t HeaterHandler::getSwitchDelayMs(void) const { return 2000; }
ReturnValue_t HeaterHandler::setHealth(HealthState health) { ReturnValue_t HeaterHandler::setHealth(HealthState health) {
if (healthTable != nullptr) { healthHelper.setHealth(health);
healthTable->setHealth(getObjectId(), health);
return RETURN_OK; return RETURN_OK;
}
return RETURN_FAILED;
} }
HasHealthIF::HealthState HeaterHandler::getHealth() { HasHealthIF::HealthState HeaterHandler::getHealth() { return healthHelper.getHealth(); }
if (healthTable != nullptr) {
return healthTable->getHealth(getObjectId());
}
return HasHealthIF::HealthState::HEALTHY;
}

View File

@ -5,6 +5,7 @@
#include <fsfw/devicehandlers/CookieIF.h> #include <fsfw/devicehandlers/CookieIF.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h> #include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <fsfw/health/HasHealthIF.h> #include <fsfw/health/HasHealthIF.h>
#include <fsfw/health/HealthHelper.h>
#include <fsfw/objectmanager/SystemObject.h> #include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/power/PowerSwitchIF.h> #include <fsfw/power/PowerSwitchIF.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h> #include <fsfw/returnvalues/HasReturnvaluesIF.h>
@ -42,8 +43,7 @@ class HeaterHandler : public ExecutableObjectIF,
static const DeviceCommandId_t SWITCH_HEATER = 0x0; static const DeviceCommandId_t SWITCH_HEATER = 0x0;
HeaterHandler(object_id_t setObjectId, object_id_t gpioDriverId, CookieIF* gpioCookie, HeaterHandler(object_id_t setObjectId, object_id_t gpioDriverId, CookieIF* gpioCookie,
PowerSwitchIF* mainLineSwitcherObjectId, power::Switch_t mainLineSwitch, PowerSwitchIF* mainLineSwitcherObjectId, power::Switch_t mainLineSwitch);
HealthTableIF* healthTable);
virtual ~HeaterHandler(); virtual ~HeaterHandler();
@ -141,7 +141,7 @@ class HeaterHandler : public ExecutableObjectIF,
/** Switch number of the heater power supply switch */ /** Switch number of the heater power supply switch */
power::Switch_t mainLineSwitch; power::Switch_t mainLineSwitch;
HealthTableIF* healthTable = nullptr; HealthHelper healthHelper;
ActionHelper actionHelper; ActionHelper actionHelper;