From 92071b8e0e0bde900d50f1d5151337c4eba85818 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 9 Nov 2023 11:35:28 +0100 Subject: [PATCH] first structure --- fsfw | 2 +- linux/payload/CMakeLists.txt | 1 + linux/payload/FreshSupvHandler.cpp | 57 ++++++++++++++++++++++++++---- linux/payload/FreshSupvHandler.h | 36 +++++++++++++++++-- 4 files changed, 86 insertions(+), 10 deletions(-) diff --git a/fsfw b/fsfw index 18cc870c..35be7da3 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 18cc870c8ebc3ff0565b3b8f5ed85e9a54685358 +Subproject commit 35be7da3534423af2b4db2b86e75371749181213 diff --git a/linux/payload/CMakeLists.txt b/linux/payload/CMakeLists.txt index e697fac6..09062532 100644 --- a/linux/payload/CMakeLists.txt +++ b/linux/payload/CMakeLists.txt @@ -2,6 +2,7 @@ target_sources( ${OBSW_NAME} PUBLIC PlocMemoryDumper.cpp PlocMpsocHandler.cpp + FreshSupvHandler.cpp PlocMpsocSpecialComHelper.cpp plocMpsocHelpers.cpp PlocSupervisorHandler.cpp diff --git a/linux/payload/FreshSupvHandler.cpp b/linux/payload/FreshSupvHandler.cpp index b72e01f8..12120946 100644 --- a/linux/payload/FreshSupvHandler.cpp +++ b/linux/payload/FreshSupvHandler.cpp @@ -1,10 +1,55 @@ -/* - * FreshSupvHandler.cpp - * - * Created on: Nov 9, 2023 - * Author: rmueller - */ +#include "FreshSupvHandler.h" +FreshSupvHandler::FreshSupvHandler(DhbConfig cfg) : FreshDeviceHandlerBase(cfg) {} +void FreshSupvHandler::performDeviceOperation(uint8_t opCode) { + if (!transitionActive and mode == MODE_OFF) { + // Nothing to do for now. + return; + } + if (opCode == OpCode::DEFAULT_OPERATION) { + if (transitionActive) { + // TODO: Perform transition handling: OFF to ON and ON to OFF. + } else { + if (mode == MODE_NORMAL) { + // Normal mode handling. Request normal datasets and add them to command map. + } + } + // TODO: Check whether any active commands have timeouted. + } else if (opCode == OpCode::HANDLE_ACTIVE_CMDS) { + // TODO: Parse TM from ring buffer and check whether they complete any active commands. + // If they do, check whether anyone needs to be informed. + } +} +ReturnValue_t FreshSupvHandler::handleCommandMessage(CommandMessage *message) { + // No custom messages. + return returnvalue::FAILED; +} + +LocalPoolDataSetBase *FreshSupvHandler::getDataSetHandle(sid_t sid) { + // TODO: return all relevant datasets. + return nullptr; +} + +ReturnValue_t FreshSupvHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + // TODO: Copy code from god handler here. + return returnvalue::OK; +} + +ReturnValue_t FreshSupvHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t *data, size_t size) { + // TODO: Handle all commands here. Need to add them to some command map. Send command immediately + // then. + return returnvalue::OK; +} + +ReturnValue_t FreshSupvHandler::checkModeCommand(Mode_t mode_, Submode_t submode_, + uint32_t *msToReachTheMode) { + if (mode_ != HasModesIF::MODE_OFF and mode_ != HasModesIF::MODE_ON and mode_ != MODE_NORMAL) { + return returnvalue::FAILED; + } + return returnvalue::OK; +} diff --git a/linux/payload/FreshSupvHandler.h b/linux/payload/FreshSupvHandler.h index ce97810e..4f308361 100644 --- a/linux/payload/FreshSupvHandler.h +++ b/linux/payload/FreshSupvHandler.h @@ -2,10 +2,40 @@ #define LINUX_PAYLOAD_FRESHSUPVHANDLER_H_ #include "fsfw/devicehandlers/FreshDeviceHandlerBase.h" -class FreshSupvHandler: public FreshDeviceHandlerBase { + +class FreshSupvHandler : public FreshDeviceHandlerBase { + public: + enum OpCode { DEFAULT_OPERATION = 0, HANDLE_ACTIVE_CMDS = 1 }; + FreshSupvHandler(DhbConfig cfg); + /** + * Periodic helper executed function, implemented by child class. + */ + void performDeviceOperation(uint8_t opCode) override; + + /** + * Implemented by child class. Handle all command messages which are + * not health, mode, action or housekeeping messages. + * @param message + * @return + */ + ReturnValue_t handleCommandMessage(CommandMessage* message) override; + + private: + // HK manager abstract functions. + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + + // Mode abstract functions + ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t* msToReachTheMode) override; + // Action override. Forward to user. + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + + private: + bool transitionActive = false; }; - - #endif /* LINUX_PAYLOAD_FRESHSUPVHANDLER_H_ */