added health helper to heater handler
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2022-05-02 17:51:00 +02:00
parent 238afbaa8b
commit b98c691c2b
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 27 additions and 32 deletions

View File

@ -623,7 +623,7 @@ void ObjectFactory::createHeaterComponents(PowerSwitchIF* pwrSwitcher, HealthTab
heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpio);
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() {

View File

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

View File

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