diff --git a/src/fsfw/devicehandlers/HealthDevice.cpp b/src/fsfw/devicehandlers/HealthDevice.cpp index 717fadd1..d3a70c77 100644 --- a/src/fsfw/devicehandlers/HealthDevice.cpp +++ b/src/fsfw/devicehandlers/HealthDevice.cpp @@ -29,11 +29,10 @@ ReturnValue_t HealthDevice::initialize() { if (result != returnvalue::OK) { return result; } - if (parentQueue != 0) { + if (parentQueue != MessageQueueIF::NO_QUEUE) { return healthHelper.initialize(parentQueue); - } else { - return healthHelper.initialize(); } + return healthHelper.initialize(); } MessageQueueId_t HealthDevice::getCommandQueue() const { return commandQueue->getId(); } diff --git a/src/fsfw/devicehandlers/HealthDevice.h b/src/fsfw/devicehandlers/HealthDevice.h index 00ea44c5..a5c28cf7 100644 --- a/src/fsfw/devicehandlers/HealthDevice.h +++ b/src/fsfw/devicehandlers/HealthDevice.h @@ -29,7 +29,7 @@ class HealthDevice : public SystemObject, public ExecutableObjectIF, public HasH protected: HealthState lastHealth; - MessageQueueId_t parentQueue; + MessageQueueId_t parentQueue = MessageQueueIF::NO_QUEUE; MessageQueueIF* commandQueue; HealthHelper healthHelper; }; diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index eccd447c..b8c09230 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -315,20 +315,7 @@ object_id_t SubsystemBase::getObjectId() const { return SystemObject::getObjectI void SubsystemBase::modeChanged() {} ReturnValue_t SubsystemBase::registerChild(const ModeTreeChildIF& child) { - ChildInfo info; - - const HasModesIF& modeChild = child.getModeIF(); - // intentional to force an initial command during system startup - info.commandQueue = modeChild.getCommandQueue(); - info.mode = HasModesIF::MODE_UNDEFINED; - info.submode = SUBMODE_NONE; - info.healthChanged = false; - - auto resultPair = childrenMap.emplace(child.getObjectId(), info); - if (not resultPair.second) { - return COULD_NOT_INSERT_CHILD; - } - return returnvalue::OK; + return registerChild(child.getObjectId(), child.getModeIF().getCommandQueue()); } const HasHealthIF* SubsystemBase::getOptHealthIF() const { return this; } @@ -336,3 +323,19 @@ const HasHealthIF* SubsystemBase::getOptHealthIF() const { return this; } const HasModesIF& SubsystemBase::getModeIF() const { return *this; } ModeTreeChildIF& SubsystemBase::getModeTreeChildIF() { return *this; } + +ReturnValue_t SubsystemBase::registerChild(object_id_t childObjectId, MessageQueueId_t childQueue) { + ChildInfo info; + + // intentional to force an initial command during system startup + info.commandQueue = childQueue; + info.mode = HasModesIF::MODE_UNDEFINED; + info.submode = SUBMODE_NONE; + info.healthChanged = false; + + auto resultPair = childrenMap.emplace(childObjectId, info); + if (not resultPair.second) { + return COULD_NOT_INSERT_CHILD; + } + return returnvalue::OK; +} diff --git a/src/fsfw/subsystem/SubsystemBase.h b/src/fsfw/subsystem/SubsystemBase.h index c3886d61..072b4ca4 100644 --- a/src/fsfw/subsystem/SubsystemBase.h +++ b/src/fsfw/subsystem/SubsystemBase.h @@ -61,6 +61,8 @@ class SubsystemBase : public SystemObject, * COULD_NOT_INSERT_CHILD If the Child could not be added to the ChildrenMap */ ReturnValue_t registerChild(const ModeTreeChildIF &child) override; + // TODO: Add this to HasModeTreeChildrenIF. + ReturnValue_t registerChild(object_id_t childObjectId, MessageQueueId_t childQueue); ReturnValue_t initialize() override;