From cd94fad8e5795a72b05c4da86861d7ee6d10311b Mon Sep 17 00:00:00 2001 From: "spahr@ksat-stuttgart.de" Date: Sat, 29 Mar 2025 23:30:04 +0100 Subject: [PATCH] Change the SubsystemBase to allow commanding of objects in executeTable which are not in the childrenMap. This enebales us to wiretap mode messages and operate the power switch of a shared power line without breaking the mode tree --- src/fsfw/subsystem/SubsystemBase.cpp | 15 ++++++++++++++- src/fsfw/subsystem/SubsystemBase.h | 9 +++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index 87fcfebf..16154cb5 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -64,6 +64,11 @@ void SubsystemBase::executeTable(HybridIterator tableIter, Submod for (; tableIter.value != nullptr; ++tableIter) { object_id_t object = tableIter.value->getObject(); + + // As default, the objectId in the commandTable is the same as the one in the childrenMap. + // The user has to specify otherwise if required. + object = commandObjectIdToChildrenMapObjectId(object); + if ((iter = childrenMap.find(object)) == childrenMap.end()) { // illegal table entry, should only happen due to misconfigured mode table #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -119,7 +124,11 @@ void SubsystemBase::executeTable(HybridIterator tableIter, Submod continue; // don't send redundant mode commands (produces event spam), but still command if // mode is forced to reach lower levels } - ReturnValue_t result = commandQueue->sendMessage(iter->second.commandQueue, &command); + + // Get the messageQueueId if the receiver specified by the commandTable. + // This the same MessageQueueId as stored in the childrenMap if the commanded object is part of the childrenMap. + MessageQueueId_t commandedReceiver = ObjectManager::instance()->get(tableIter->getObject())->getCommandQueue(); + ReturnValue_t result = commandQueue->sendMessage(commandedReceiver, &command); if (result == returnvalue::OK) { ++commandsOutstanding; } @@ -353,3 +362,7 @@ ReturnValue_t SubsystemBase::registerChild(object_id_t childObjectId, MessageQue } return returnvalue::OK; } + +object_id_t SubsystemBase::commandObjectIdToChildrenMapObjectId(object_id_t commandId) { + return commandId; +} diff --git a/src/fsfw/subsystem/SubsystemBase.h b/src/fsfw/subsystem/SubsystemBase.h index 072b4ca4..d96fa424 100644 --- a/src/fsfw/subsystem/SubsystemBase.h +++ b/src/fsfw/subsystem/SubsystemBase.h @@ -153,6 +153,15 @@ class SubsystemBase : public SystemObject, virtual void announceMode(bool recursive) override; virtual void modeChanged(); + + /** + * @brief This converts the objectId of the object we want to send a mode command to into the + * objectId of the corresponding object in the childrenMap for the current mode command. + * As default implementation, this is the same objectId, and this functions returns it's input value + * + * It is up to the user to specify otherwise. + */ + virtual object_id_t commandObjectIdToChildrenMapObjectId(object_id_t commandId); }; #endif /* FSFW_SUBSYSTEM_SUBSYSTEMBASE_H_ */