eive-obsw/unittest/controller/testThermalController.cpp

61 lines
2.3 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>
#include <catch2/catch_test_macros.hpp>
2022-11-24 16:40:59 +01:00
#include "../../dummies/TemperatureSensorInserter.h"
2022-02-17 17:48:32 +01:00
#include "../testEnvironment.h"
2022-11-28 10:39:47 +01:00
#include "mission/core/GenericFactory.h"
#include "test/gpio/DummyGpioIF.h"
TEST_CASE("Thermal Controller", "[ThermalController]") {
const object_id_t THERMAL_CONTROLLER_ID = 0x123;
2022-11-24 16:40:59 +01:00
new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER);
2022-11-28 10:39:47 +01:00
auto dummyGpioIF = new DummyGpioIF();
auto dummySwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0);
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
2022-11-28 10:39:47 +01:00
ThermalController controller(THERMAL_CONTROLLER_ID, *heaterHandler);
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;
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);
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(
THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO, ControllerBase::MODE_NORMAL,
HasModesIF::SUBMODE_NONE) == true);
QueueFactory::instance()->deleteMessageQueue(commandQueue);
2022-05-10 17:49:10 +02:00
}