eive-obsw/unittest/controller/testThermalController.cpp

66 lines
2.6 KiB
C++
Raw Normal View History

#include <dummies/SusDummy.h>
#include <fsfw/ipc/QueueFactory.h>
2022-11-28 10:39:47 +01:00
#include <fsfw/power/DummyPowerSwitcher.h>
#include <fsfw/tasks/PeriodicTaskIF.h>
#include <fsfw/tasks/TaskFactory.h>
2022-06-17 08:31:36 +02:00
#include <mission/controller/ThermalController.h>
2023-03-14 20:35:49 +01:00
#include <mission/system/objects/CamSwitcher.h>
#include <catch2/catch_test_macros.hpp>
2022-02-17 17:48:32 +01:00
#include "../testEnvironment.h"
2023-02-09 14:25:29 +01:00
#include "dummies/TemperatureSensorInserter.h"
2023-03-26 16:58:05 +02:00
#include "mission/genericFactory.h"
2022-11-28 10:39:47 +01:00
#include "test/gpio/DummyGpioIF.h"
TEST_CASE("Thermal Controller", "[ThermalController]") {
const object_id_t THERMAL_CONTROLLER_ID = 0x123;
2023-04-12 00:25:21 +02:00
std::atomic_bool tcsBrdShortlyUnavailable = false;
2023-02-08 16:58:32 +01:00
TemperatureSensorInserter::Max31865DummyMap map0;
TemperatureSensorInserter::Tmp1075DummyMap map1;
new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER, map0, map1);
2022-11-28 10:39:47 +01:00
auto dummyGpioIF = new DummyGpioIF();
2023-03-14 20:35:49 +01:00
auto* dummySwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0);
2023-03-17 17:40:11 +01:00
new CamSwitcher(objects::CAM_SWITCHER, *dummySwitcher, power::Switches::PDU2_CH8_PAYLOAD_CAMERA);
2022-11-24 16:40:59 +01:00
// TODO: Create dummy heater handler
2022-11-28 10:39:47 +01:00
HeaterHandler* heaterHandler = nullptr;
// new ThermalController(objects::THERMAL_CONTROLLER);
ObjectFactory::createGenericHeaterComponents(*dummyGpioIF, *dummySwitcher, heaterHandler);
2022-02-17 17:48:32 +01:00
// testEnvironment::initialize();
2022-02-17 17:48:32 +01:00
2023-04-12 00:25:21 +02:00
ThermalController controller(THERMAL_CONTROLLER_ID, *heaterHandler, tcsBrdShortlyUnavailable);
ReturnValue_t result = controller.initialize();
2022-08-24 17:27:47 +02:00
REQUIRE(result == returnvalue::OK);
PeriodicTaskIF* thermalTask = TaskFactory::instance()->createPeriodicTask(
"THERMAL_CTL_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
result = thermalTask->addComponent(THERMAL_CONTROLLER_ID);
2022-08-24 17:27:47 +02:00
REQUIRE(result == returnvalue::OK);
2022-08-24 17:27:47 +02:00
REQUIRE(controller.initializeAfterTaskCreation() == returnvalue::OK);
2022-02-17 17:48:32 +01:00
testEnvironment::eventManager->clearEventList();
MessageQueueId_t controllerQueue = controller.getCommandQueue();
CommandMessage modeMessage;
2023-04-13 23:31:33 +02:00
ModeMessage::setModeMessage(&modeMessage, ModeMessage::CMD_MODE_COMMAND, HasModesIF::MODE_ON,
HasModesIF::SUBMODE_NONE);
MessageQueueIF* commandQueue =
QueueFactory::instance()->createMessageQueue(5, MessageQueueMessage::MAX_MESSAGE_SIZE);
commandQueue->sendMessage(controllerQueue, &modeMessage);
2022-08-24 17:27:47 +02:00
REQUIRE(controller.performOperation(0) == returnvalue::OK);
2022-02-17 17:48:32 +01:00
REQUIRE(testEnvironment::eventManager->isEventInEventList(
2023-04-06 15:31:32 +02:00
THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO, HasModesIF::MODE_ON,
2022-02-17 17:48:32 +01:00
HasModesIF::SUBMODE_NONE) == true);
QueueFactory::instance()->deleteMessageQueue(commandQueue);
2022-05-10 17:49:10 +02:00
}