fsfw/thermal/AbstractTemperatureSensor.cpp

71 lines
2.0 KiB
C++
Raw Normal View History

#include "AbstractTemperatureSensor.h"
2020-08-13 20:53:35 +02:00
#include "../ipc/QueueFactory.h"
AbstractTemperatureSensor::AbstractTemperatureSensor(object_id_t setObjectid,
ThermalModuleIF *thermalModule) :
SystemObject(setObjectid), commandQueue(NULL), healthHelper(this,
setObjectid), parameterHelper(this) {
if (thermalModule != NULL) {
thermalModule->registerSensor(this);
}
commandQueue = QueueFactory::instance()->createMessageQueue();
}
AbstractTemperatureSensor::~AbstractTemperatureSensor() {
QueueFactory::instance()->deleteMessageQueue(commandQueue);
}
MessageQueueId_t AbstractTemperatureSensor::getCommandQueue() const {
return commandQueue->getId();
}
ReturnValue_t AbstractTemperatureSensor::initialize() {
ReturnValue_t result = SystemObject::initialize();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = healthHelper.initialize();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = parameterHelper.initialize();
return result;
}
ReturnValue_t AbstractTemperatureSensor::performOperation(uint8_t opCode) {
handleCommandQueue();
doChildOperation();
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t AbstractTemperatureSensor::performHealthOp() {
handleCommandQueue();
return HasReturnvaluesIF::RETURN_OK;
}
void AbstractTemperatureSensor::handleCommandQueue() {
2020-12-03 18:32:32 +01:00
CommandMessage command;
ReturnValue_t result = commandQueue->receiveMessage(&command);
if (result == HasReturnvaluesIF::RETURN_OK) {
2020-12-03 18:32:32 +01:00
result = healthHelper.handleHealthCommand(&command);
if (result == HasReturnvaluesIF::RETURN_OK) {
return;
}
2020-12-03 18:32:32 +01:00
result = parameterHelper.handleParameterMessage(&command);
if (result == HasReturnvaluesIF::RETURN_OK) {
return;
}
2020-12-03 18:32:32 +01:00
command.setToUnknownCommand();
commandQueue->reply(&command);
}
}
ReturnValue_t AbstractTemperatureSensor::setHealth(HealthState health) {
healthHelper.setHealth(health);
return HasReturnvaluesIF::RETURN_OK;
}
HasHealthIF::HealthState AbstractTemperatureSensor::getHealth() {
return healthHelper.getHealth();
}