dummy faking the PT1000 Temperature Sensors for host build

This commit is contained in:
Ulrich Mohr 2022-05-19 23:06:56 +02:00
parent e9725e3093
commit 4a0aa6443b
7 changed files with 129 additions and 1 deletions

View File

@ -2,3 +2,4 @@ target_sources(${OBSW_NAME} PUBLIC InitMission.cpp main.cpp ObjectFactory.cpp)
add_subdirectory(fsfwconfig)
add_subdirectory(boardconfig)
add_subdirectory(dummies)

View File

@ -143,6 +143,14 @@ void initmission::initTasks() {
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("THERMAL_CONTROLLER", objects::THERMAL_CONTROLLER);
}
// needs high priority to be able to run before the controller tasks
PeriodicTaskIF* dummyTask = factory->createPeriodicTask(
"THERMAL_CTL_TASK", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc);
result = dummyTask->addComponent(objects::RTD_0_IC3_PLOC_HEATSPREADER);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("RTD_0", objects::RTD_0_IC3_PLOC_HEATSPREADER);
}
#if OBSW_ADD_TEST_CODE == 1
result = testTask->addComponent(objects::TEST_TASK);
if (result != HasReturnvaluesIF::RETURN_OK) {
@ -163,6 +171,8 @@ void initmission::initTasks() {
thermalControllerTask->startTask();
dummyTask->startTask();
#if OBSW_ADD_TEST_CODE == 1
testTask->startTask();
#endif /* OBSW_ADD_TEST_CODE == 1 */

View File

@ -26,6 +26,8 @@
#include <test/testtasks/TestTask.h>
#endif
#include "dummies/TemperatureSensorsDummy.h"
void Factory::setStaticFrameworkObjectIds() {
PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR;
PusServiceBase::packetDestination = objects::TM_FUNNEL;
@ -45,6 +47,8 @@ void ObjectFactory::produce(void* args) {
Factory::setStaticFrameworkObjectIds();
ObjectFactory::produceGenericObjects();
new TemperatureSensorsDummy();
new ThermalController(objects::THERMAL_CONTROLLER, objects::NO_OBJECT);
//new TestTask(objects::TEST_TASK);

View File

@ -1 +1 @@
target_sources(${TARGET_NAME} PUBLIC ArduinoComIF.cpp ArduinoCookie.cpp)
target_sources(${OBSW_NAME} PUBLIC ArduinoComIF.cpp ArduinoCookie.cpp)

View File

@ -0,0 +1 @@
target_sources(${OBSW_NAME} PUBLIC TemperatureSensorsDummy.cpp)

View File

@ -0,0 +1,83 @@
#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);
}
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();
max31865Set.temperatureCelcius = value;
max31865Set.commit();
}
ReturnValue_t TemperatureSensorsDummy::initializeLocalDataPool(
localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(Max31865Definitions::PoolIds::RTD_VALUE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(Max31865Definitions::PoolIds::TEMPERATURE_C,
new PoolEntry<float>({0}, 1, true));
localDataPoolMap.emplace(Max31865Definitions::PoolIds::FAULT_BYTE, new PoolEntry<uint8_t>({0}));
return RETURN_OK;
}
LocalPoolDataSetBase* TemperatureSensorsDummy::getDataSetHandle(sid_t sid) {
sif::debug << "getHandle" << std::endl;
switch (sid.ownerSetId) {
case Max31865Definitions::MAX31865_SET_ID:
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;
}

View File

@ -0,0 +1,29 @@
#pragma once
#include <fsfw/controller/ExtendedControllerBase.h>
#include <mission/devices/devicedefinitions/Max31865Definitions.h>
class TemperatureSensorsDummy : public ExtendedControllerBase {
public:
TemperatureSensorsDummy();
ReturnValue_t initialize() override;
protected:
virtual ReturnValue_t handleCommandMessage(CommandMessage* message) override;
virtual void performControlOperation() override;
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
// Mode abstract functions
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t* msToReachTheMode) override;
private:
int iteration = 0;
float value = 0;
Max31865Definitions::Max31865Set max31865Set;
void noise();
};