eive-obsw/dummies/TemperatureSensorInserter.cpp

104 lines
3.7 KiB
C++
Raw Normal View History

2022-11-24 16:40:59 +01:00
#include "TemperatureSensorInserter.h"
2023-04-06 12:13:24 +02:00
#include <fsfw/datapool/PoolReadGuard.h>
2022-11-24 16:40:59 +01:00
#include <objects/systemObjectList.h>
#include <cmath>
#include <cstdlib>
#include <utility>
2022-11-24 16:40:59 +01:00
2023-02-06 15:59:30 +01:00
TemperatureSensorInserter::TemperatureSensorInserter(object_id_t objectId,
Max31865DummyMap tempSensorDummies_,
Tmp1075DummyMap tempTmpSensorDummies_)
: SystemObject(objectId),
max31865DummyMap(std::move(tempSensorDummies_)),
tmp1075DummyMap(std::move(tempTmpSensorDummies_)) {}
2022-11-24 16:40:59 +01:00
ReturnValue_t TemperatureSensorInserter::initialize() {
2023-04-14 21:02:39 +02:00
testCase = TestCase::NONE;
2022-11-24 16:40:59 +01:00
return returnvalue::OK;
}
ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) {
2023-03-09 09:37:10 +01:00
// TODO: deviceSensors
2023-02-22 21:46:56 +01:00
if (not tempsWereInitialized) {
for (auto& rtdDummy : max31865DummyMap) {
rtdDummy.second->setTemperature(10, true);
}
2023-02-22 21:46:56 +01:00
for (auto& tmpDummy : tmp1075DummyMap) {
tmpDummy.second->setTemperature(10, true);
}
tempsWereInitialized = true;
}
2023-04-06 12:13:24 +02:00
switch (testCase) {
case (TestCase::NONE): {
break;
}
2023-04-06 13:24:16 +02:00
case (TestCase::COLD_SYRLINKS): {
2023-04-06 12:13:24 +02:00
// TODO: How do I insert this?
// Does not work on EM, where a real syrlinks device is connected.
if (cycles == 15) {
lp_var_t<float> tempSyrlinksBasebandBoard =
lp_var_t<float>(objects::SYRLINKS_HANDLER, syrlinks::TEMP_BASEBAND_BOARD);
PoolReadGuard pg(&tempSyrlinksBasebandBoard);
tempSyrlinksBasebandBoard.value = -50;
}
if (cycles == 30) {
lp_var_t<float> tempSyrlinksBasebandBoard =
lp_var_t<float>(objects::SYRLINKS_HANDLER, syrlinks::TEMP_BASEBAND_BOARD);
PoolReadGuard pg(&tempSyrlinksBasebandBoard);
tempSyrlinksBasebandBoard.value = 0;
}
break;
}
2023-04-06 13:24:16 +02:00
case (TestCase::COLD_HPA): {
2023-04-06 12:13:24 +02:00
if (cycles == 15) {
2023-04-06 13:09:48 +02:00
sif::debug << "Setting cold HPA temperature" << std::endl;
2023-04-06 12:13:24 +02:00
max31865DummyMap[objects::RTD_9_IC12_HPA]->setTemperature(-60, true);
}
if (cycles == 30) {
2023-04-06 13:09:48 +02:00
sif::debug << "Setting HPA temperature back to normal" << std::endl;
2023-04-06 12:13:24 +02:00
max31865DummyMap[objects::RTD_9_IC12_HPA]->setTemperature(0, true);
}
break;
}
2023-04-06 13:24:16 +02:00
case (TestCase::COLD_MGT): {
2023-04-06 12:13:24 +02:00
if (cycles == 15) {
2023-04-06 13:09:48 +02:00
sif::debug << "Setting cold MGT temperature" << std::endl;
2023-04-06 12:13:24 +02:00
max31865DummyMap[objects::RTD_15_IC18_IMTQ]->setTemperature(-60, true);
}
if (cycles == 30) {
2023-04-06 13:09:48 +02:00
sif::debug << "Setting MGT temperature back to normal" << std::endl;
2023-04-06 12:13:24 +02:00
max31865DummyMap[objects::RTD_15_IC18_IMTQ]->setTemperature(0, true);
}
break;
}
2023-04-06 13:24:16 +02:00
case (TestCase::COLD_STR):
case (TestCase::COLD_STR_CONSECUTIVE): {
2023-04-06 13:09:48 +02:00
if (cycles == 15) {
sif::debug << "Setting cold STR temperature" << std::endl;
max31865DummyMap[objects::RTD_4_IC7_STARTRACKER]->setTemperature(-40, true);
}
if (cycles == 30) {
sif::debug << "Setting STR temperature back to normal" << std::endl;
max31865DummyMap[objects::RTD_4_IC7_STARTRACKER]->setTemperature(0, true);
}
2023-04-06 13:24:16 +02:00
if (testCase == TestCase::COLD_STR_CONSECUTIVE) {
if (cycles == 45) {
sif::debug << "Setting cold STR temperature again" << std::endl;
max31865DummyMap[objects::RTD_4_IC7_STARTRACKER]->setTemperature(-40, true);
}
if (cycles == 60) {
sif::debug << "Setting STR temperature back to normal again" << std::endl;
max31865DummyMap[objects::RTD_4_IC7_STARTRACKER]->setTemperature(0, true);
}
}
2023-04-06 13:09:48 +02:00
break;
}
2022-11-24 16:40:59 +01:00
}
2023-02-22 17:50:03 +01:00
cycles++;
2022-11-24 16:40:59 +01:00
return returnvalue::OK;
}
2023-02-22 21:46:56 +01:00
ReturnValue_t TemperatureSensorInserter::initializeAfterTaskCreation() { return returnvalue::OK; }