fsfw/src/fsfw/thermal/AbstractTemperatureSensor.cpp

72 lines
2.0 KiB
C++
Raw Normal View History

2021-07-13 20:22:54 +02:00
#include "fsfw/thermal/AbstractTemperatureSensor.h"
2022-02-02 10:29:30 +01:00
2021-07-13 20:22:54 +02:00
#include "fsfw/ipc/QueueFactory.h"
AbstractTemperatureSensor::AbstractTemperatureSensor(object_id_t setObjectid,
2022-02-02 10:29:30 +01:00
ThermalModuleIF *thermalModule)
: SystemObject(setObjectid),
commandQueue(NULL),
healthHelper(this, setObjectid),
parameterHelper(this) {
if (thermalModule != NULL) {
thermalModule->registerSensor(this);
}
commandQueue = QueueFactory::instance()->createMessageQueue();
}
AbstractTemperatureSensor::~AbstractTemperatureSensor() {
2022-02-02 10:29:30 +01:00
QueueFactory::instance()->deleteMessageQueue(commandQueue);
}
MessageQueueId_t AbstractTemperatureSensor::getCommandQueue() const {
2022-02-02 10:29:30 +01:00
return commandQueue->getId();
}
ReturnValue_t AbstractTemperatureSensor::initialize() {
2022-02-02 10:29:30 +01:00
ReturnValue_t result = SystemObject::initialize();
2022-08-15 20:28:16 +02:00
if (result != returnvalue::OK) {
2022-02-02 10:29:30 +01:00
return result;
}
result = healthHelper.initialize();
2022-08-15 20:28:16 +02:00
if (result != returnvalue::OK) {
2022-02-02 10:29:30 +01:00
return result;
}
result = parameterHelper.initialize();
return result;
}
ReturnValue_t AbstractTemperatureSensor::performOperation(uint8_t opCode) {
2022-02-02 10:29:30 +01:00
handleCommandQueue();
doChildOperation();
2022-08-15 20:28:16 +02:00
return returnvalue::OK;
}
ReturnValue_t AbstractTemperatureSensor::performHealthOp() {
2022-02-02 10:29:30 +01:00
handleCommandQueue();
2022-08-15 20:28:16 +02:00
return returnvalue::OK;
}
void AbstractTemperatureSensor::handleCommandQueue() {
2022-02-02 10:29:30 +01:00
CommandMessage command;
ReturnValue_t result = commandQueue->receiveMessage(&command);
2022-08-15 20:28:16 +02:00
if (result == returnvalue::OK) {
2022-02-02 10:29:30 +01:00
result = healthHelper.handleHealthCommand(&command);
2022-08-15 20:28:16 +02:00
if (result == returnvalue::OK) {
2022-02-02 10:29:30 +01:00
return;
}
result = parameterHelper.handleParameterMessage(&command);
2022-08-15 20:28:16 +02:00
if (result == returnvalue::OK) {
2022-02-02 10:29:30 +01:00
return;
}
command.setToUnknownCommand();
commandQueue->reply(&command);
}
}
ReturnValue_t AbstractTemperatureSensor::setHealth(HealthState health) {
2022-02-02 10:29:30 +01:00
healthHelper.setHealth(health);
2022-08-15 20:28:16 +02:00
return returnvalue::OK;
}
2022-02-02 10:29:30 +01:00
HasHealthIF::HealthState AbstractTemperatureSensor::getHealth() { return healthHelper.getHealth(); }