2022-06-16 07:00:09 +02:00
|
|
|
#include <dummies/SusDummy.h>
|
2022-02-14 13:49:12 +01:00
|
|
|
#include <fsfw/ipc/QueueFactory.h>
|
2022-11-28 10:39:47 +01:00
|
|
|
#include <fsfw/power/DummyPowerSwitcher.h>
|
2022-06-16 07:00:09 +02:00
|
|
|
#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>
|
2022-02-10 18:54:09 +01:00
|
|
|
|
2022-02-11 16:20:26 +01:00
|
|
|
#include <catch2/catch_test_macros.hpp>
|
2022-02-10 18:54:09 +01:00
|
|
|
|
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"
|
2022-02-10 18:29:28 +01:00
|
|
|
|
2022-02-11 16:20:26 +01:00
|
|
|
TEST_CASE("Thermal Controller", "[ThermalController]") {
|
2022-02-14 13:49:12 +01:00
|
|
|
const object_id_t THERMAL_CONTROLLER_ID = 0x123;
|
2023-04-12 00:25:21 +02:00
|
|
|
std::atomic_bool tcsBrdShortlyUnavailable = false;
|
2022-02-14 13:49:12 +01:00
|
|
|
|
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
|
|
|
|
2022-10-10 10:18:29 +02:00
|
|
|
// testEnvironment::initialize();
|
2022-02-17 17:48:32 +01:00
|
|
|
|
2023-07-03 17:32:35 +02:00
|
|
|
ThermalController controller(THERMAL_CONTROLLER_ID, *heaterHandler, tcsBrdShortlyUnavailable,
|
|
|
|
true);
|
2022-06-16 07:00:09 +02:00
|
|
|
ReturnValue_t result = controller.initialize();
|
2022-08-24 17:27:47 +02:00
|
|
|
REQUIRE(result == returnvalue::OK);
|
2022-06-16 07:00:09 +02:00
|
|
|
|
|
|
|
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-06-16 07:00:09 +02:00
|
|
|
|
2022-08-24 17:27:47 +02:00
|
|
|
REQUIRE(controller.initializeAfterTaskCreation() == returnvalue::OK);
|
2022-02-14 13:49:12 +01:00
|
|
|
|
2022-02-17 17:48:32 +01:00
|
|
|
testEnvironment::eventManager->clearEventList();
|
2022-02-17 15:49:39 +01:00
|
|
|
|
2022-02-14 13:49:12 +01:00
|
|
|
MessageQueueId_t controllerQueue = controller.getCommandQueue();
|
|
|
|
|
|
|
|
CommandMessage modeMessage;
|
|
|
|
|
2023-04-13 23:24:32 +02:00
|
|
|
ModeMessage::setModeMessage(&modeMessage, ModeMessage::CMD_MODE_COMMAND, HasModesIF::MODE_ON,
|
|
|
|
HasModesIF::SUBMODE_NONE);
|
2022-02-14 13:49:12 +01:00
|
|
|
|
2022-02-17 15:49:39 +01:00
|
|
|
MessageQueueIF* commandQueue =
|
|
|
|
QueueFactory::instance()->createMessageQueue(5, MessageQueueMessage::MAX_MESSAGE_SIZE);
|
|
|
|
|
|
|
|
commandQueue->sendMessage(controllerQueue, &modeMessage);
|
2022-02-14 13:49:12 +01:00
|
|
|
|
2022-08-24 17:27:47 +02:00
|
|
|
REQUIRE(controller.performOperation(0) == returnvalue::OK);
|
2022-02-14 13:49:12 +01:00
|
|
|
|
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);
|
2022-02-17 15:49:39 +01:00
|
|
|
|
2022-02-14 13:49:12 +01:00
|
|
|
QueueFactory::instance()->deleteMessageQueue(commandQueue);
|
2022-05-10 17:49:10 +02:00
|
|
|
}
|