v1.9.0 #175
@ -1,20 +1,50 @@
|
|||||||
#include "ThermalController.h"
|
#include "ThermalController.h"
|
||||||
|
|
||||||
ThermalController::ThermalController(object_id_t objectId, object_id_t parentId) :ExtendedControllerBase(objectId, parentId) {}
|
ThermalController::ThermalController(object_id_t objectId, object_id_t parentId)
|
||||||
|
: ExtendedControllerBase(objectId, parentId),
|
||||||
|
sensorTemperatures(this),
|
||||||
|
componentTemperatures(this) {}
|
||||||
|
|
||||||
ReturnValue_t ThermalController::perform() { return HasReturnvaluesIF::RETURN_FAILED; }
|
ReturnValue_t ThermalController::perform() { return HasReturnvaluesIF::RETURN_FAILED; }
|
||||||
|
|
||||||
ReturnValue_t ThermalController::handleCommandMessage(CommandMessage* message) {
|
ReturnValue_t ThermalController::handleCommandMessage(CommandMessage* message) {
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
void ThermalController::performControlOperation() {}
|
void ThermalController::performControlOperation() {
|
||||||
|
sif::info << "tc performOperation()" << std::endl;
|
||||||
|
|
||||||
|
ReturnValue_t result = sensorTemperatures.read();
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
result = componentTemperatures.read();
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
componentTemperatures.rw = (sensorTemperatures.rw.value + sensorTemperatures.gps.value) / 2;
|
||||||
|
|
||||||
|
sensorTemperatures.commit();
|
||||||
|
componentTemperatures.commit();
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||||
LocalDataPoolManager& poolManager) {
|
LocalDataPoolManager& poolManager) {
|
||||||
|
localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_RW, new PoolEntry<float>({0.0}));
|
||||||
|
localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_GPS, new PoolEntry<float>({0.0}));
|
||||||
|
localDataPoolMap.emplace(thermalControllerDefinitions::COMPONENT_RW, new PoolEntry<float>({0.0}));
|
||||||
|
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
LocalPoolDataSetBase* ThermalController::getDataSetHandle(sid_t sid) { return nullptr; }
|
LocalPoolDataSetBase* ThermalController::getDataSetHandle(sid_t sid) { return nullptr; }
|
||||||
|
|
||||||
ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, Submode_t submode,
|
ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, Submode_t submode,
|
||||||
uint32_t* msToReachTheMode) {
|
uint32_t* msToReachTheMode) {
|
||||||
return RETURN_FAILED;
|
if (submode != SUBMODE_NONE) {
|
||||||
|
return INVALID_SUBMODE;
|
||||||
|
}
|
||||||
|
if ((mode != MODE_OFF) && (mode != MODE_ON) && (mode != MODE_NORMAL)) {
|
||||||
|
return INVALID_MODE;
|
||||||
|
}
|
||||||
|
return RETURN_OK;
|
||||||
}
|
}
|
@ -2,8 +2,7 @@
|
|||||||
#define MISSION_CONTROLLER_THERMALCONTROLLER_H_
|
#define MISSION_CONTROLLER_THERMALCONTROLLER_H_
|
||||||
|
|
||||||
#include <fsfw/controller/ExtendedControllerBase.h>
|
#include <fsfw/controller/ExtendedControllerBase.h>
|
||||||
|
#include <mission/controller/controllerdefinitions/ThermalControllerDefinitions.h>
|
||||||
|
|
||||||
|
|
||||||
class ThermalController : public ExtendedControllerBase {
|
class ThermalController : public ExtendedControllerBase {
|
||||||
public:
|
public:
|
||||||
@ -11,7 +10,7 @@ class ThermalController : public ExtendedControllerBase {
|
|||||||
|
|
||||||
ReturnValue_t perform();
|
ReturnValue_t perform();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ReturnValue_t handleCommandMessage(CommandMessage* message) override;
|
virtual ReturnValue_t handleCommandMessage(CommandMessage* message) override;
|
||||||
virtual void performControlOperation() override;
|
virtual void performControlOperation() override;
|
||||||
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||||
@ -21,6 +20,10 @@ protected:
|
|||||||
// Mode abstract functions
|
// Mode abstract functions
|
||||||
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
||||||
uint32_t* msToReachTheMode) override;
|
uint32_t* msToReachTheMode) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
thermalControllerDefinitions::SensorTemperatures sensorTemperatures;
|
||||||
|
thermalControllerDefinitions::ComponentTemperatures componentTemperatures;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */
|
#endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
#ifndef MISSION_CONTROLLER_CONTROLLERDEFINITIONS_THERMALCONTROLLERDEFINITIONS_H_
|
||||||
|
#define MISSION_CONTROLLER_CONTROLLERDEFINITIONS_THERMALCONTROLLERDEFINITIONS_H_
|
||||||
|
|
||||||
|
#include <fsfw/datapoollocal/LocalPoolVariable.h>
|
||||||
|
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||||
|
|
||||||
|
namespace thermalControllerDefinitions {
|
||||||
|
|
||||||
|
enum SetIds : uint32_t { SENSOR_TEMPERATURES, COMPONENT_TEMPERATURES };
|
||||||
|
|
||||||
|
enum PoolIds : lp_id_t { SENSOR_RW, SENSOR_GPS, COMPONENT_RW };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This dataset can be used to store the collected temperatures of all temperature sensors
|
||||||
|
*/
|
||||||
|
class SensorTemperatures : public StaticLocalDataSet<2> {
|
||||||
|
public:
|
||||||
|
SensorTemperatures(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SENSOR_TEMPERATURES) {}
|
||||||
|
|
||||||
|
SensorTemperatures(object_id_t objectId)
|
||||||
|
: StaticLocalDataSet(sid_t(objectId, SENSOR_TEMPERATURES)) {}
|
||||||
|
|
||||||
|
lp_var_t<float> rw = lp_var_t<float>(sid.objectId, PoolIds::SENSOR_RW, this);
|
||||||
|
lp_var_t<float> gps = lp_var_t<float>(sid.objectId, PoolIds::SENSOR_GPS, this);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This dataset can be used to store the collected temperatures of all components
|
||||||
|
*/
|
||||||
|
class ComponentTemperatures : public StaticLocalDataSet<2> {
|
||||||
|
public:
|
||||||
|
ComponentTemperatures(HasLocalDataPoolIF* owner)
|
||||||
|
: StaticLocalDataSet(owner, SENSOR_TEMPERATURES) {}
|
||||||
|
|
||||||
|
ComponentTemperatures(object_id_t objectId)
|
||||||
|
: StaticLocalDataSet(sid_t(objectId, SENSOR_TEMPERATURES)) {}
|
||||||
|
|
||||||
|
lp_var_t<float> rw = lp_var_t<float>(sid.objectId, PoolIds::COMPONENT_RW, this);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace thermalControllerDefinitions
|
||||||
|
|
||||||
|
#endif /* MISSION_CONTROLLER_CONTROLLERDEFINITIONS_THERMALCONTROLLERDEFINITIONS_H_ */
|
@ -1,13 +1,11 @@
|
|||||||
|
#include <fsfw/events/EventManagerIF.h>
|
||||||
#include <fsfw/health/HealthTable.h>
|
#include <fsfw/health/HealthTable.h>
|
||||||
#include <fsfw/housekeeping/AcceptsHkPacketsIF.h>
|
#include <fsfw/housekeeping/AcceptsHkPacketsIF.h>
|
||||||
#include <fsfw/internalerror/InternalErrorReporter.h>
|
#include <fsfw/internalerror/InternalErrorReporter.h>
|
||||||
|
#include <fsfw/ipc/QueueFactory.h>
|
||||||
#include <fsfw/objectmanager.h>
|
#include <fsfw/objectmanager.h>
|
||||||
#include <fsfw/storagemanager/PoolManager.h>
|
#include <fsfw/storagemanager/PoolManager.h>
|
||||||
#include <fsfw/timemanager/TimeStamper.h>
|
#include <fsfw/timemanager/TimeStamper.h>
|
||||||
#include <fsfw/events/EventManagerIF.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <mission/controller/ThermalController.h>
|
#include <mission/controller/ThermalController.h>
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
@ -34,14 +32,38 @@ void factory(void* args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Thermal Controller", "[ThermalController]") {
|
TEST_CASE("Thermal Controller", "[ThermalController]") {
|
||||||
bool test = true;
|
|
||||||
REQUIRE(test == true);
|
const object_id_t THERMAL_CONTROLLER_ID = 0x123;
|
||||||
|
|
||||||
ThermalController controller(0x123, objects::NO_OBJECT);
|
|
||||||
|
ThermalController controller(THERMAL_CONTROLLER_ID, objects::NO_OBJECT);
|
||||||
|
|
||||||
ObjectManager::instance()->setObjectFactoryFunction(factory, nullptr);
|
ObjectManager::instance()->setObjectFactoryFunction(factory, nullptr);
|
||||||
ObjectManager::instance()->initialize();
|
ObjectManager::instance()->initialize();
|
||||||
ObjectManager::instance()->printList();
|
ObjectManager::instance()->printList();
|
||||||
|
|
||||||
|
controller.initializeAfterTaskCreation();
|
||||||
|
|
||||||
|
MessageQueueId_t controllerQueue = controller.getCommandQueue();
|
||||||
|
|
||||||
|
CommandMessage modeMessage;
|
||||||
|
|
||||||
|
ModeMessage::setModeMessage(&modeMessage, ModeMessage::CMD_MODE_COMMAND,
|
||||||
|
ControllerBase::MODE_NORMAL, HasModesIF::SUBMODE_NONE);
|
||||||
|
|
||||||
|
MessageQueueIF* commandQueue = QueueFactory::instance()->createMessageQueue(
|
||||||
|
5, MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||||
|
|
||||||
|
commandQueue->sendMessage(controllerQueue,&modeMessage);
|
||||||
|
|
||||||
REQUIRE(controller.performOperation(0) == HasReturnvaluesIF::RETURN_OK);
|
REQUIRE(controller.performOperation(0) == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
|
||||||
|
thermalControllerDefinitions::ComponentTemperatures componentTemperatures(THERMAL_CONTROLLER_ID);
|
||||||
|
|
||||||
|
componentTemperatures.read();
|
||||||
|
REQUIRE(componentTemperatures.rw == 0);
|
||||||
|
|
||||||
|
componentTemperatures.commit();
|
||||||
|
|
||||||
|
QueueFactory::instance()->deleteMessageQueue(commandQueue);
|
||||||
}
|
}
|
@ -1,10 +1,6 @@
|
|||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <catch2/catch_session.hpp>
|
#include <catch2/catch_session.hpp>
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
puts("unittests");
|
|
||||||
|
|
||||||
|
|
||||||
// Catch internal function call
|
// Catch internal function call
|
||||||
int result = Catch::Session().run(argc, argv);
|
int result = Catch::Session().run(argc, argv);
|
||||||
|
Loading…
Reference in New Issue
Block a user