From f1249392cf9182cf1e8fcee154d7ab3f0520686d Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 10 Feb 2022 18:54:09 +0100 Subject: [PATCH] skeleton controller now unittested including fsfw. Still dirty WIP --- mission/controller/ThermalController.cpp | 19 +++++++++-- mission/controller/ThermalController.h | 13 +++++++- unittest/CMakeLists.txt | 1 + unittest/controller/testThermalController.cpp | 32 +++++++++++++++++++ unittest/printChar.cpp | 11 +++++++ unittest/printChar.h | 6 ++++ 6 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 unittest/printChar.cpp create mode 100644 unittest/printChar.h diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 610cae0a..f0acc5fa 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1,7 +1,20 @@ #include "ThermalController.h" -ThermalController::ThermalController(object_id_t objectId) {} +ThermalController::ThermalController(object_id_t objectId) :ExtendedControllerBase(objectId, 0) {} -ReturnValue_t ThermalController::perform() { - return HasReturnvaluesIF::RETURN_FAILED; +ReturnValue_t ThermalController::perform() { return HasReturnvaluesIF::RETURN_FAILED; } + +ReturnValue_t ThermalController::handleCommandMessage(CommandMessage* message) { + return RETURN_FAILED; +} +void ThermalController::performControlOperation() {} +ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) { + return RETURN_OK; +} +LocalPoolDataSetBase* ThermalController::getDataSetHandle(sid_t sid) { return nullptr; } + +ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t* msToReachTheMode) { + return RETURN_FAILED; } \ No newline at end of file diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 52279261..25c257b7 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -5,11 +5,22 @@ -class ThermalController { +class ThermalController : public ExtendedControllerBase { public: ThermalController(object_id_t objectId); ReturnValue_t perform(); + +protected: + virtual ReturnValue_t handleCommandMessage(CommandMessage* message) override; + virtual void performControlOperation() override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + + // Mode abstract functions + virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t* msToReachTheMode) override; }; #endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */ diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index b4c26ed6..c2b09393 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -3,4 +3,5 @@ add_subdirectory(controller) target_sources(${UNITTEST_NAME} PRIVATE main.cpp + printChar.cpp ) \ No newline at end of file diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index a5b23b26..fed27834 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -1,6 +1,38 @@ #include #include +#include "fsfw/serviceinterface/ServiceInterfaceStream.h" + +/* This is configured for linux without CR */ +#ifdef PLATFORM_UNIX +ServiceInterfaceStream sif::debug("DEBUG"); +ServiceInterfaceStream sif::info("INFO"); +ServiceInterfaceStream sif::warning("WARNING"); +ServiceInterfaceStream sif::error("ERROR"); +#else +ServiceInterfaceStream sif::debug("DEBUG", true); +ServiceInterfaceStream sif::info("INFO", true); +ServiceInterfaceStream sif::warning("WARNING", true); +ServiceInterfaceStream sif::error("ERROR", true, false, true); +#endif + +#include + +namespace messagetypes { +enum MESSAGE_TYPE { + MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, +}; + +void clearMissionMessage(CommandMessage* message); +} // namespace messagetypes + + +void messagetypes::clearMissionMessage(CommandMessage* message) { + +} + + + TEST_CASE( "Thermal Controller" , "[ThermalController]") { bool test = true; diff --git a/unittest/printChar.cpp b/unittest/printChar.cpp new file mode 100644 index 00000000..0e29fe2b --- /dev/null +++ b/unittest/printChar.cpp @@ -0,0 +1,11 @@ +#include "printChar.h" + +#include + +void printChar(const char* character, bool errStream) { + if (errStream) { + std::putc(*character, stderr); + return; + } + std::putc(*character, stdout); +} diff --git a/unittest/printChar.h b/unittest/printChar.h new file mode 100644 index 00000000..1991161f --- /dev/null +++ b/unittest/printChar.h @@ -0,0 +1,6 @@ +#ifndef FSFW_UNITTEST_CORE_PRINTCHAR_H_ +#define FSFW_UNITTEST_CORE_PRINTCHAR_H_ + +extern "C" void printChar(const char*, bool errStream); + +#endif /* FSFW_UNITTEST_CORE_PRINTCHAR_H_ */