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"
|
2018-07-12 16:29:32 +02:00
|
|
|
|
|
|
|
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();
|
2018-07-12 16:29:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
AbstractTemperatureSensor::~AbstractTemperatureSensor() {
|
2022-02-02 10:29:30 +01:00
|
|
|
QueueFactory::instance()->deleteMessageQueue(commandQueue);
|
2018-07-12 16:29:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MessageQueueId_t AbstractTemperatureSensor::getCommandQueue() const {
|
2022-02-02 10:29:30 +01:00
|
|
|
return commandQueue->getId();
|
2018-07-12 16:29:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2018-07-12 16:29:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2018-07-12 16:29:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t AbstractTemperatureSensor::performHealthOp() {
|
2022-02-02 10:29:30 +01:00
|
|
|
handleCommandQueue();
|
2022-08-15 20:28:16 +02:00
|
|
|
return returnvalue::OK;
|
2018-07-12 16:29:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2018-07-12 16:29:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2018-07-12 16:29:32 +02:00
|
|
|
}
|
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
HasHealthIF::HealthState AbstractTemperatureSensor::getHealth() { return healthHelper.getHealth(); }
|