2022-02-14 13:49:12 +01:00
|
|
|
#include <fsfw/events/EventManagerIF.h>
|
2022-02-11 16:20:26 +01:00
|
|
|
#include <fsfw/health/HealthTable.h>
|
|
|
|
#include <fsfw/housekeeping/AcceptsHkPacketsIF.h>
|
|
|
|
#include <fsfw/internalerror/InternalErrorReporter.h>
|
2022-02-14 13:49:12 +01:00
|
|
|
#include <fsfw/ipc/QueueFactory.h>
|
2022-02-10 18:29:28 +01:00
|
|
|
#include <mission/controller/ThermalController.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 15:49:39 +01:00
|
|
|
#include "../mocks/EventManagerMock.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;
|
|
|
|
|
|
|
|
ThermalController controller(THERMAL_CONTROLLER_ID, objects::NO_OBJECT);
|
2022-02-17 16:29:22 +01:00
|
|
|
REQUIRE(controller.initialize() == HasReturnvaluesIF::RETURN_OK);
|
|
|
|
REQUIRE(controller.initializeAfterTaskCreation() == HasReturnvaluesIF::RETURN_OK);
|
2022-02-14 13:49:12 +01:00
|
|
|
|
2022-02-17 15:49:39 +01:00
|
|
|
EventManagerMock* eventmanager =
|
|
|
|
ObjectManager::instance()->get<EventManagerMock>(objects::EVENT_MANAGER);
|
|
|
|
REQUIRE(eventmanager->isEventInEventList(THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO) == false);
|
|
|
|
|
2022-02-14 13:49:12 +01:00
|
|
|
MessageQueueId_t controllerQueue = controller.getCommandQueue();
|
|
|
|
|
|
|
|
CommandMessage modeMessage;
|
|
|
|
|
|
|
|
ModeMessage::setModeMessage(&modeMessage, ModeMessage::CMD_MODE_COMMAND,
|
|
|
|
ControllerBase::MODE_NORMAL, HasModesIF::SUBMODE_NONE);
|
|
|
|
|
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-02-11 16:20:26 +01:00
|
|
|
REQUIRE(controller.performOperation(0) == HasReturnvaluesIF::RETURN_OK);
|
2022-02-14 13:49:12 +01:00
|
|
|
|
2022-02-17 16:29:22 +01:00
|
|
|
REQUIRE(eventmanager->isEventInEventList(THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO,
|
|
|
|
ControllerBase::MODE_NORMAL,
|
|
|
|
HasModesIF::SUBMODE_NONE) == true);
|
2022-02-17 15:49:39 +01:00
|
|
|
|
2022-02-14 13:49:12 +01:00
|
|
|
thermalControllerDefinitions::ComponentTemperatures componentTemperatures(THERMAL_CONTROLLER_ID);
|
|
|
|
|
|
|
|
componentTemperatures.read();
|
|
|
|
REQUIRE(componentTemperatures.rw == 0);
|
2022-02-16 18:15:06 +01:00
|
|
|
|
2022-02-17 15:49:39 +01:00
|
|
|
componentTemperatures.commit();
|
2022-02-16 18:15:06 +01:00
|
|
|
|
2022-02-14 13:49:12 +01:00
|
|
|
QueueFactory::instance()->deleteMessageQueue(commandQueue);
|
2022-02-10 18:15:33 +01:00
|
|
|
}
|