2018-07-12 16:29:32 +02:00
|
|
|
#include "AbstractTemperatureSensor.h"
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "../ipc/QueueFactory.h"
|
2018-07-12 16:29:32 +02:00
|
|
|
|
|
|
|
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);
|
2018-07-12 16:29:32 +02:00
|
|
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
2020-12-03 18:32:32 +01:00
|
|
|
result = healthHelper.handleHealthCommand(&command);
|
2018-07-12 16:29:32 +02:00
|
|
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
return;
|
|
|
|
}
|
2020-12-03 18:32:32 +01:00
|
|
|
result = parameterHelper.handleParameterMessage(&command);
|
2018-07-12 16:29:32 +02:00
|
|
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
return;
|
|
|
|
}
|
2020-12-03 18:32:32 +01:00
|
|
|
command.setToUnknownCommand();
|
|
|
|
commandQueue->reply(&command);
|
2018-07-12 16:29:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t AbstractTemperatureSensor::setHealth(HealthState health) {
|
|
|
|
healthHelper.setHealth(health);
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HasHealthIF::HealthState AbstractTemperatureSensor::getHealth() {
|
|
|
|
return healthHelper.getHealth();
|
|
|
|
}
|