2022-05-19 23:06:56 +02:00
|
|
|
#include "TemperatureSensorsDummy.h"
|
|
|
|
|
|
|
|
#include <objects/systemObjectList.h>
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
#include <cstdlib>
|
|
|
|
|
|
|
|
TemperatureSensorsDummy::TemperatureSensorsDummy()
|
|
|
|
: ExtendedControllerBase(objects::RTD_0_IC3_PLOC_HEATSPREADER, objects::NO_OBJECT),
|
|
|
|
max31865Set(this) {
|
|
|
|
ObjectManager::instance()->insert(objects::RTD_1_IC4_PLOC_MISSIONBOARD, this);
|
|
|
|
ObjectManager::instance()->insert(objects::RTD_2_IC5_4K_CAMERA, this);
|
|
|
|
ObjectManager::instance()->insert(objects::RTD_3_IC6_DAC_HEATSPREADER, this);
|
|
|
|
ObjectManager::instance()->insert(objects::RTD_4_IC7_STARTRACKER, this);
|
|
|
|
ObjectManager::instance()->insert(objects::RTD_5_IC8_RW1_MX_MY, this);
|
|
|
|
ObjectManager::instance()->insert(objects::RTD_6_IC9_DRO, this);
|
|
|
|
ObjectManager::instance()->insert(objects::RTD_7_IC10_SCEX, this);
|
|
|
|
ObjectManager::instance()->insert(objects::RTD_8_IC11_X8, this);
|
|
|
|
ObjectManager::instance()->insert(objects::RTD_9_IC12_HPA, this);
|
|
|
|
ObjectManager::instance()->insert(objects::RTD_10_IC13_PL_TX, this);
|
|
|
|
ObjectManager::instance()->insert(objects::RTD_11_IC14_MPA, this);
|
|
|
|
ObjectManager::instance()->insert(objects::RTD_12_IC15_ACU, this);
|
|
|
|
ObjectManager::instance()->insert(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, this);
|
|
|
|
ObjectManager::instance()->insert(objects::RTD_14_IC17_TCS_BOARD, this);
|
|
|
|
ObjectManager::instance()->insert(objects::RTD_15_IC18_IMTQ, this);
|
2022-05-23 00:37:49 +02:00
|
|
|
ObjectManager::instance()->insert(objects::TMP1075_HANDLER_1, this);
|
|
|
|
ObjectManager::instance()->insert(objects::TMP1075_HANDLER_2, this);
|
2022-05-19 23:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t TemperatureSensorsDummy::initialize() {
|
|
|
|
static bool done = false;
|
|
|
|
if (not done) {
|
|
|
|
done = true;
|
|
|
|
ReturnValue_t result = ExtendedControllerBase::initialize();
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t TemperatureSensorsDummy::handleCommandMessage(CommandMessage* message) {
|
|
|
|
return RETURN_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TemperatureSensorsDummy::performControlOperation() {
|
|
|
|
iteration++;
|
|
|
|
value = sin(iteration / 80. * M_PI) * 10;
|
|
|
|
|
|
|
|
max31865Set.read();
|
2022-05-23 00:37:49 +02:00
|
|
|
max31865Set.rtdValue = value - 5;
|
2022-05-19 23:06:56 +02:00
|
|
|
max31865Set.temperatureCelcius = value;
|
2022-05-24 16:52:21 +02:00
|
|
|
if ((iteration % 100) < 20) {
|
|
|
|
max31865Set.setValidity(false, true);
|
|
|
|
} else {
|
|
|
|
max31865Set.setValidity(true, true);
|
|
|
|
}
|
2022-05-19 23:06:56 +02:00
|
|
|
max31865Set.commit();
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t TemperatureSensorsDummy::initializeLocalDataPool(
|
|
|
|
localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) {
|
2022-06-10 14:01:34 +02:00
|
|
|
localDataPoolMap.emplace(MAX31865::PoolIds::RTD_VALUE, new PoolEntry<float>({0}));
|
|
|
|
localDataPoolMap.emplace(MAX31865::PoolIds::TEMPERATURE_C,
|
2022-05-19 23:06:56 +02:00
|
|
|
new PoolEntry<float>({0}, 1, true));
|
2022-06-10 14:01:34 +02:00
|
|
|
localDataPoolMap.emplace(MAX31865::PoolIds::FAULT_BYTE, new PoolEntry<uint8_t>({0}));
|
2022-05-19 23:06:56 +02:00
|
|
|
|
|
|
|
return RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
LocalPoolDataSetBase* TemperatureSensorsDummy::getDataSetHandle(sid_t sid) {
|
|
|
|
sif::debug << "getHandle" << std::endl;
|
|
|
|
switch (sid.ownerSetId) {
|
2022-06-10 14:01:34 +02:00
|
|
|
case MAX31865::MAX31865_SET_ID:
|
2022-05-19 23:06:56 +02:00
|
|
|
return &max31865Set;
|
|
|
|
default:
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t TemperatureSensorsDummy::checkModeCommand(Mode_t mode, Submode_t submode,
|
|
|
|
uint32_t* msToReachTheMode) {
|
|
|
|
if (submode != SUBMODE_NONE) {
|
|
|
|
return INVALID_SUBMODE;
|
|
|
|
}
|
|
|
|
if ((mode != MODE_OFF) && (mode != MODE_ON) && (mode != MODE_NORMAL)) {
|
|
|
|
return INVALID_MODE;
|
|
|
|
}
|
|
|
|
return RETURN_OK;
|
|
|
|
}
|