eive-obsw/unittest/controller/testThermalController.cpp
Robin Mueller 5c430212e7
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
that should fix the host build
2023-07-03 17:32:35 +02:00

67 lines
2.6 KiB
C++

#include <dummies/SusDummy.h>
#include <fsfw/ipc/QueueFactory.h>
#include <fsfw/power/DummyPowerSwitcher.h>
#include <fsfw/tasks/PeriodicTaskIF.h>
#include <fsfw/tasks/TaskFactory.h>
#include <mission/controller/ThermalController.h>
#include <mission/system/objects/CamSwitcher.h>
#include <catch2/catch_test_macros.hpp>
#include "../testEnvironment.h"
#include "dummies/TemperatureSensorInserter.h"
#include "mission/genericFactory.h"
#include "test/gpio/DummyGpioIF.h"
TEST_CASE("Thermal Controller", "[ThermalController]") {
const object_id_t THERMAL_CONTROLLER_ID = 0x123;
std::atomic_bool tcsBrdShortlyUnavailable = false;
TemperatureSensorInserter::Max31865DummyMap map0;
TemperatureSensorInserter::Tmp1075DummyMap map1;
new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER, map0, map1);
auto dummyGpioIF = new DummyGpioIF();
auto* dummySwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0);
new CamSwitcher(objects::CAM_SWITCHER, *dummySwitcher, power::Switches::PDU2_CH8_PAYLOAD_CAMERA);
// TODO: Create dummy heater handler
HeaterHandler* heaterHandler = nullptr;
// new ThermalController(objects::THERMAL_CONTROLLER);
ObjectFactory::createGenericHeaterComponents(*dummyGpioIF, *dummySwitcher, heaterHandler);
// testEnvironment::initialize();
ThermalController controller(THERMAL_CONTROLLER_ID, *heaterHandler, tcsBrdShortlyUnavailable,
true);
ReturnValue_t result = controller.initialize();
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);
REQUIRE(result == returnvalue::OK);
REQUIRE(controller.initializeAfterTaskCreation() == returnvalue::OK);
testEnvironment::eventManager->clearEventList();
MessageQueueId_t controllerQueue = controller.getCommandQueue();
CommandMessage modeMessage;
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);
REQUIRE(controller.performOperation(0) == returnvalue::OK);
REQUIRE(testEnvironment::eventManager->isEventInEventList(
THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO, HasModesIF::MODE_ON,
HasModesIF::SUBMODE_NONE) == true);
QueueFactory::instance()->deleteMessageQueue(commandQueue);
}