add health IF to heater handler
This commit is contained in:
parent
0abb726b30
commit
238afbaa8b
@ -33,8 +33,16 @@ ObjectManagerIF* objectManager = nullptr;
|
||||
|
||||
void initmission::initMission() {
|
||||
sif::info << "Building global objects.." << std::endl;
|
||||
try {
|
||||
/* Instantiate global object manager and also create all objects */
|
||||
ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr);
|
||||
} catch (const std::invalid_argument& e) {
|
||||
sif::error << "initmission::initMission: Object Construction failed with an "
|
||||
"invalid argument: "
|
||||
<< e.what();
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
sif::info << "Initializing all objects.." << std::endl;
|
||||
ObjectManager::instance()->initialize();
|
||||
|
||||
|
@ -131,7 +131,8 @@ void Factory::setStaticFrameworkObjectIds() {
|
||||
|
||||
void ObjectFactory::produce(void* args) {
|
||||
ObjectFactory::setStatics();
|
||||
ObjectFactory::produceGenericObjects();
|
||||
HealthTableIF* healthTable = nullptr;
|
||||
ObjectFactory::produceGenericObjects(&healthTable);
|
||||
|
||||
LinuxLibgpioIF* gpioComIF = nullptr;
|
||||
UartComIF* uartComIF = nullptr;
|
||||
@ -151,7 +152,7 @@ void ObjectFactory::produce(void* args) {
|
||||
createAcsBoardComponents(gpioComIF, uartComIF, pwrSwitcher);
|
||||
#endif
|
||||
|
||||
createHeaterComponents();
|
||||
createHeaterComponents(pwrSwitcher, healthTable);
|
||||
createSolarArrayDeploymentComponents();
|
||||
createPlPcduComponents(gpioComIF, spiComIF, pwrSwitcher);
|
||||
#if OBSW_ADD_SYRLINKS == 1
|
||||
@ -580,7 +581,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI
|
||||
#endif /* OBSW_ADD_ACS_HANDLERS == 1 */
|
||||
}
|
||||
|
||||
void ObjectFactory::createHeaterComponents() {
|
||||
void ObjectFactory::createHeaterComponents(PowerSwitchIF* pwrSwitcher, HealthTableIF* healthTable) {
|
||||
using namespace gpio;
|
||||
GpioCookie* heaterGpiosCookie = new GpioCookie;
|
||||
GpiodRegularByLineName* gpio = nullptr;
|
||||
@ -621,8 +622,8 @@ void ObjectFactory::createHeaterComponents() {
|
||||
Levels::LOW);
|
||||
heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpio);
|
||||
|
||||
new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie,
|
||||
objects::PCDU_HANDLER, pcdu::Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V);
|
||||
new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie, pwrSwitcher,
|
||||
pcdu::Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V, healthTable);
|
||||
}
|
||||
|
||||
void ObjectFactory::createSolarArrayDeploymentComponents() {
|
||||
|
@ -6,6 +6,7 @@ class UartComIF;
|
||||
class SpiComIF;
|
||||
class I2cComIF;
|
||||
class PowerSwitchIF;
|
||||
class HealthTableIF;
|
||||
class AcsBoardAssembly;
|
||||
|
||||
namespace ObjectFactory {
|
||||
@ -22,7 +23,7 @@ void createTmpComponents();
|
||||
void createRadSensorComponent(LinuxLibgpioIF* gpioComIF);
|
||||
void createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComIF* uartComIF,
|
||||
PowerSwitchIF* pwrSwitcher);
|
||||
void createHeaterComponents();
|
||||
void createHeaterComponents(PowerSwitchIF* pwrSwitcher, HealthTableIF* healthTable);
|
||||
void createSolarArrayDeploymentComponents();
|
||||
void createSyrlinksComponents(PowerSwitchIF* pwrSwitcher);
|
||||
void createPayloadComponents(LinuxLibgpioIF* gpioComIF);
|
||||
|
@ -44,10 +44,13 @@
|
||||
#define OBSW_TM_TO_PTME 0
|
||||
#endif
|
||||
|
||||
void ObjectFactory::produceGenericObjects() {
|
||||
void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_) {
|
||||
// Framework objects
|
||||
new EventManager(objects::EVENT_MANAGER);
|
||||
new HealthTable(objects::HEALTH_TABLE);
|
||||
auto healthTable = new HealthTable(objects::HEALTH_TABLE);
|
||||
if (healthTable != nullptr) {
|
||||
*healthTable_ = healthTable;
|
||||
}
|
||||
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
|
||||
new TimeStamper(objects::TIME_STAMPER);
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
#ifndef MISSION_CORE_GENERICFACTORY_H_
|
||||
#define MISSION_CORE_GENERICFACTORY_H_
|
||||
|
||||
class HealthTableIF;
|
||||
|
||||
namespace ObjectFactory {
|
||||
|
||||
void produceGenericObjects();
|
||||
void produceGenericObjects(HealthTableIF** healthTable);
|
||||
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <fsfw/action/HasActionsIF.h>
|
||||
#include <fsfw/devicehandlers/CookieIF.h>
|
||||
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
||||
#include <fsfw/health/HasHealthIF.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
#include <fsfw/power/PowerSwitchIF.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
@ -15,6 +16,9 @@
|
||||
|
||||
#include "devices/heaterSwitcherList.h"
|
||||
|
||||
class PowerSwitchIF;
|
||||
class HealthTableIF;
|
||||
|
||||
/**
|
||||
* @brief This class intends the control of heaters.
|
||||
*
|
||||
@ -22,6 +26,7 @@
|
||||
*/
|
||||
class HeaterHandler : public ExecutableObjectIF,
|
||||
public PowerSwitchIF,
|
||||
public HasHealthIF,
|
||||
public SystemObject,
|
||||
public HasActionsIF {
|
||||
public:
|
||||
@ -37,10 +42,24 @@ class HeaterHandler : public ExecutableObjectIF,
|
||||
static const DeviceCommandId_t SWITCH_HEATER = 0x0;
|
||||
|
||||
HeaterHandler(object_id_t setObjectId, object_id_t gpioDriverId, CookieIF* gpioCookie,
|
||||
object_id_t mainLineSwitcherObjectId, uint8_t mainLineSwitch);
|
||||
PowerSwitchIF* mainLineSwitcherObjectId, power::Switch_t mainLineSwitch,
|
||||
HealthTableIF* healthTable);
|
||||
|
||||
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;
|
||||
@ -114,16 +133,15 @@ class HeaterHandler : public ExecutableObjectIF,
|
||||
/** Queue to receive messages from other objects. */
|
||||
MessageQueueIF* commandQueue = nullptr;
|
||||
|
||||
object_id_t mainLineSwitcherObjectId;
|
||||
|
||||
/** Switch number of the heater power supply switch */
|
||||
uint8_t mainLineSwitch;
|
||||
|
||||
/**
|
||||
* Power switcher object which controls the 8V main line of the heater
|
||||
* logic on the TCS board.
|
||||
*/
|
||||
PowerSwitchIF* mainLineSwitcher = nullptr;
|
||||
/** Switch number of the heater power supply switch */
|
||||
power::Switch_t mainLineSwitch;
|
||||
|
||||
HealthTableIF* healthTable = nullptr;
|
||||
|
||||
ActionHelper actionHelper;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user