From eb79386c9272d4d346beb1c53f24aafb04e8c705 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 30 May 2022 11:25:08 +0200 Subject: [PATCH] new addSlot function taking executable pointer --- src/fsfw/tasks/FixedTimeslotTaskBase.cpp | 22 ++++++++++------------ src/fsfw/tasks/FixedTimeslotTaskBase.h | 2 +- src/fsfw/tasks/FixedTimeslotTaskIF.h | 16 ++++++++++++++++ src/fsfw/tasks/PeriodicTaskIF.h | 18 +++++++++++++----- 4 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/fsfw/tasks/FixedTimeslotTaskBase.cpp b/src/fsfw/tasks/FixedTimeslotTaskBase.cpp index 05c08109..5d12d565 100644 --- a/src/fsfw/tasks/FixedTimeslotTaskBase.cpp +++ b/src/fsfw/tasks/FixedTimeslotTaskBase.cpp @@ -11,19 +11,17 @@ bool FixedTimeslotTaskBase::isEmpty() const { return pollingSeqTable.isEmpty(); ReturnValue_t FixedTimeslotTaskBase::checkSequence() { return pollingSeqTable.checkSequence(); } -ReturnValue_t FixedTimeslotTaskBase::addSlot(object_id_t componentId, uint32_t slotTimeMs, - int8_t executionStep) { - auto* executableObject = ObjectManager::instance()->get(componentId); - if (executableObject != nullptr) { - pollingSeqTable.addSlot(componentId, slotTimeMs, executionStep, executableObject, this); - return HasReturnvaluesIF::RETURN_OK; - } - +ReturnValue_t FixedTimeslotTaskBase::addSlot(object_id_t execId, ExecutableObjectIF* execObj, + uint32_t slotTimeMs, int8_t executionStep) { + if (execObj == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Component 0x" << std::hex << std::setw(8) << std::setfill('0') << componentId - << std::setfill(' ') << " not found, not adding it to PST" << std::dec << std::endl; + sif::error << "Component 0x" << std::hex << std::setw(8) << std::setfill('0') << execObj + << std::setfill(' ') << " not found, not adding it to PST" << std::dec << std::endl; #else - sif::printError("Component 0x%08x not found, not adding it to PST\n"); + sif::printError("Component 0x%08x not found, not adding it to PST\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return HasReturnvaluesIF::RETURN_FAILED; + } + pollingSeqTable.addSlot(execId, slotTimeMs, executionStep, execObj, this); + return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/tasks/FixedTimeslotTaskBase.h b/src/fsfw/tasks/FixedTimeslotTaskBase.h index 6f08e3fe..b88b393c 100644 --- a/src/fsfw/tasks/FixedTimeslotTaskBase.h +++ b/src/fsfw/tasks/FixedTimeslotTaskBase.h @@ -37,7 +37,7 @@ class FixedTimeslotTaskBase : public FixedTimeslotTaskIF { [[nodiscard]] bool isEmpty() const override; - ReturnValue_t addSlot(object_id_t componentId, uint32_t slotTimeMs, + ReturnValue_t addSlot(object_id_t execId, ExecutableObjectIF* componentId, uint32_t slotTimeMs, int8_t executionStep) override; }; diff --git a/src/fsfw/tasks/FixedTimeslotTaskIF.h b/src/fsfw/tasks/FixedTimeslotTaskIF.h index dec382c3..7ca23814 100644 --- a/src/fsfw/tasks/FixedTimeslotTaskIF.h +++ b/src/fsfw/tasks/FixedTimeslotTaskIF.h @@ -2,6 +2,7 @@ #define FRAMEWORK_TASKS_FIXEDTIMESLOTTASKIF_H_ #include "PeriodicTaskIF.h" +#include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/objectmanager/ObjectManagerIF.h" #include "fsfw/returnvalues/FwClassIds.h" @@ -15,6 +16,7 @@ class FixedTimeslotTaskIF : public PeriodicTaskIF { static constexpr ReturnValue_t SLOT_LIST_EMPTY = HasReturnvaluesIF::makeReturnCode(CLASS_ID::FIXED_SLOT_TASK_IF, 0); + /** * Add an object with a slot time and the execution step to the task. * The execution step will be passed to the object (e.g. as an operation @@ -25,6 +27,20 @@ class FixedTimeslotTaskIF : public PeriodicTaskIF { * @return */ virtual ReturnValue_t addSlot(object_id_t componentId, uint32_t slotTimeMs, + int8_t executionStep) { + auto* execObj = ObjectManager::instance()->get(componentId); + return addSlot(componentId, execObj, slotTimeMs, executionStep); + } + /** + * Add an object with a slot time and the execution step to the task. + * The execution step will be passed to the object (e.g. as an operation + * code in #performOperation) + * @param componentId + * @param slotTimeMs + * @param executionStep + * @return + */ + virtual ReturnValue_t addSlot(object_id_t execId, ExecutableObjectIF* obj, uint32_t slotTimeMs, int8_t executionStep) = 0; /** * Check whether the sequence is valid and perform all other required diff --git a/src/fsfw/tasks/PeriodicTaskIF.h b/src/fsfw/tasks/PeriodicTaskIF.h index a6d6a6d6..0a26cac3 100644 --- a/src/fsfw/tasks/PeriodicTaskIF.h +++ b/src/fsfw/tasks/PeriodicTaskIF.h @@ -31,25 +31,33 @@ class PeriodicTaskIF { * @param object Id of the object to add. * @return RETURN_OK on success, RETURN_FAILED if the object could not be added. */ - virtual ReturnValue_t addComponent(object_id_t object, uint8_t opCode = 0) { + virtual ReturnValue_t addComponent(object_id_t object, uint8_t opCode) { return HasReturnvaluesIF::RETURN_FAILED; }; + virtual ReturnValue_t addComponent(object_id_t object) { + return addComponent(object, 0); + }; + /** * Adds an object to the list of objects to be executed. * The objects are executed in the order added. * @param object pointer to the object to add. * @return RETURN_OK on success, RETURN_FAILED if the object could not be added. */ - virtual ReturnValue_t addComponent(ExecutableObjectIF* object, uint8_t opCode = 0) { + virtual ReturnValue_t addComponent(ExecutableObjectIF* object, uint8_t opCode) { return HasReturnvaluesIF::RETURN_FAILED; }; + virtual ReturnValue_t addComponent(ExecutableObjectIF* object) { + return addComponent(object, 0); + } + virtual ReturnValue_t sleepFor(uint32_t ms) = 0; - virtual uint32_t getPeriodMs() const = 0; + [[nodiscard]] virtual uint32_t getPeriodMs() const = 0; - virtual bool isEmpty() const = 0; + [[nodiscard]] virtual bool isEmpty() const = 0; }; -#endif /* PERIODICTASKIF_H_ */ +#endif /* FRAMEWORK_TASK_PERIODICTASKIF_H_ */