Improve Subsystem DHB logic #112

Merged
muellerr merged 16 commits from mueller/improve-ss-dhb-logic into develop 2022-11-02 10:32:27 +01:00
11 changed files with 73 additions and 62 deletions
Showing only changes of commit 10dd855244 - Show all commits

View File

@ -102,6 +102,10 @@ const HasHealthIF* ControllerBase::getOptHealthIF() const { return this; }
const HasModesIF& ControllerBase::getModeIF() const { return *this; }
ModeTreeChildIF& ControllerBase::getModeTreeChildIF() {
return *this;
}
ReturnValue_t ControllerBase::connectModeTreeParent(HasModeTreeChildrenIF& parent) {
return modetree::connectModeTreeParent(parent, *this, healthHelper, modeHelper);
}

View File

@ -8,7 +8,7 @@
#include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/subsystem/HasModeTreeChildrenIF.h"
#include "fsfw/subsystem/ModeTreeChildIF.h"
#include "fsfw/subsystem/modes/ModeTreeConnectionIF.h"
#include "fsfw/subsystem/ModeTreeConnectionIF.h"
#include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/tasks/PeriodicTaskIF.h"
@ -31,6 +31,7 @@ class ControllerBase : public HasModesIF,
~ControllerBase() override;
ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override;
ModeTreeChildIF& getModeTreeChildIF() override;
/** SystemObject override */
ReturnValue_t initialize() override;

View File

@ -3,11 +3,11 @@
#include "fsfw/subsystem/SubsystemBase.h"
ChildHandlerBase::ChildHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication,
CookieIF* cookie, object_id_t parent,
CookieIF* cookie, HasModeTreeChildrenIF& parent,
FailureIsolationBase* customFdir, size_t cmdQueueSize)
: DeviceHandlerBase(setObjectId, deviceCommunication, cookie,
(customFdir == nullptr ? &childHandlerFdir : customFdir), cmdQueueSize),
parentId(parent),
parent(parent),
childHandlerFdir(setObjectId) {}
ChildHandlerBase::~ChildHandlerBase() {}
@ -18,22 +18,5 @@ ReturnValue_t ChildHandlerBase::initialize() {
return result;
}
// TODO: Fix this
// MessageQueueId_t parentQueue = 0;
//
// if (parentId != objects::NO_OBJECT) {
// SubsystemBase* parent = ObjectManager::instance()->get<SubsystemBase>(parentId);
// if (parent == NULL) {
// return returnvalue::FAILED;
// }
// parentQueue = parent->getCommandQueue();
//
// parent->registerChild(getObjectId());
// }
//
// healthHelper.setParentQueue(parentQueue);
//
// modeHelper.setParentQueue(parentQueue);
return returnvalue::OK;
return DeviceHandlerBase::connectModeTreeParent(parent);
}

View File

@ -1,13 +1,14 @@
#ifndef FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_
#define FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_
#include <fsfw/subsystem/HasModeTreeChildrenIF.h>
#include "ChildHandlerFDIR.h"
#include "DeviceHandlerBase.h"
class ChildHandlerBase : public DeviceHandlerBase {
public:
ChildHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication, CookieIF* cookie,
object_id_t parent = objects::NO_OBJECT,
HasModeTreeChildrenIF& parent,
FailureIsolationBase* customFdir = nullptr, size_t cmdQueueSize = 20);
virtual ~ChildHandlerBase();
@ -15,7 +16,7 @@ class ChildHandlerBase : public DeviceHandlerBase {
virtual ReturnValue_t initialize();
protected:
const uint32_t parentId;
HasModeTreeChildrenIF& parent;
ChildHandlerFDIR childHandlerFdir;
};

View File

@ -1,5 +1,6 @@
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "DeviceHandlerBase.h"
#include "fsfw/subsystem/helper.h"
#include "fsfw/datapoollocal/LocalPoolVariable.h"
#include "fsfw/devicehandlers/AcceptsDeviceResponsesIF.h"
#include "fsfw/devicehandlers/DeviceTmReportingWrapper.h"
@ -1591,3 +1592,19 @@ void DeviceHandlerBase::disableCommandsAndReplies() {
}
}
}
ReturnValue_t DeviceHandlerBase::connectModeTreeParent(HasModeTreeChildrenIF &parent) {
return modetree::connectModeTreeParent(parent, *this, healthHelper, modeHelper);
}
const HasHealthIF* DeviceHandlerBase::getOptHealthIF() const {
return this;
}
const HasModesIF& DeviceHandlerBase::getModeIF() const {
return *this;
}
ModeTreeChildIF& DeviceHandlerBase::getModeTreeChildIF() {
return *this;
}

View File

@ -11,6 +11,7 @@
#include "fsfw/action/HasActionsIF.h"
#include "fsfw/datapool/PoolVariableIF.h"
#include "fsfw/datapoollocal/HasLocalDataPoolIF.h"
#include "fsfw/subsystem/ModeTreeConnectionIF.h"
#include "fsfw/datapoollocal/LocalDataPoolManager.h"
#include "fsfw/health/HealthHelper.h"
#include "fsfw/ipc/MessageQueueIF.h"
@ -84,6 +85,8 @@ class DeviceHandlerBase : public DeviceHandlerIF,
public HasModesIF,
public HasHealthIF,
public HasActionsIF,
public ModeTreeChildIF,
public ModeTreeConnectionIF,
public ReceivesParameterMessagesIF,
public HasLocalDataPoolIF {
friend void(Factory::setStaticFrameworkObjectIds)();
@ -120,6 +123,10 @@ class DeviceHandlerBase : public DeviceHandlerIF,
lp_id_t thermalStatePoolId = DeviceHandlerIF::DEFAULT_THERMAL_STATE_POOL_ID,
lp_id_t thermalRequestPoolId = DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID,
uint32_t thermalSetId = DeviceHandlerIF::DEFAULT_THERMAL_SET_ID);
ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override;
ModeTreeChildIF& getModeTreeChildIF() override;
/**
* @brief Helper function to ease device handler development.
* This will instruct the transition to MODE_ON immediately
@ -165,7 +172,7 @@ class DeviceHandlerBase : public DeviceHandlerIF,
* @param counter Specifies which Action to perform
* @return returnvalue::OK for successful execution
*/
virtual ReturnValue_t performOperation(uint8_t counter) override;
ReturnValue_t performOperation(uint8_t counter) override;
/**
* @brief Initializes the device handler
@ -175,14 +182,14 @@ class DeviceHandlerBase : public DeviceHandlerIF,
* Calls fillCommandAndReplyMap().
* @return
*/
virtual ReturnValue_t initialize() override;
ReturnValue_t initialize() override;
/**
* @brief Intialization steps performed after all tasks have been created.
* This function will be called by the executing task.
* @return
*/
virtual ReturnValue_t initializeAfterTaskCreation() override;
ReturnValue_t initializeAfterTaskCreation() override;
/** Destructor. */
virtual ~DeviceHandlerBase();
@ -960,6 +967,9 @@ class DeviceHandlerBase : public DeviceHandlerIF,
*/
LocalDataPoolManager *getHkManagerHandle() override;
const HasHealthIF* getOptHealthIF() const override;
const HasModesIF& getModeIF() const override;
/**
* Returns the delay cycle count of a reply.
* A count != 0 indicates that the command is already executed.

View File

@ -7,6 +7,7 @@ class ModeTreeConnectionIF {
public:
virtual ~ModeTreeConnectionIF() = default;
virtual ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) = 0;
virtual ModeTreeChildIF& getModeTreeChildIF() = 0;
};
#endif /* FSFW_SRC_FSFW_SUBSYSTEM_MODES_MODETREECONNECTIONIF_H_ */

View File

@ -300,4 +300,10 @@ ReturnValue_t SubsystemBase::registerChild(const ModeTreeChildIF& child) {
const HasHealthIF* SubsystemBase::getOptHealthIF() const { return this; }
const HasModesIF& SubsystemBase::getModeIF() const { return *this; }
const HasModesIF& SubsystemBase::getModeIF() const {
return *this;
}
ModeTreeChildIF& SubsystemBase::getModeTreeChildIF() {
return *this;
}

View File

@ -1,13 +1,12 @@
#ifndef FSFW_SUBSYSTEM_SUBSYSTEMBASE_H_
#define FSFW_SUBSYSTEM_SUBSYSTEMBASE_H_
#include <fsfw/subsystem/modes/ModeTreeConnectionIF.h>
#include <map>
#include "fsfw/container/HybridIterator.h"
#include "fsfw/health/HasHealthIF.h"
#include "fsfw/health/HealthHelper.h"
#include "fsfw/subsystem/ModeTreeConnectionIF.h"
#include "fsfw/ipc/MessageQueueIF.h"
#include "fsfw/modes/HasModesIF.h"
#include "fsfw/objectmanager/SystemObject.h"
@ -48,6 +47,7 @@ class SubsystemBase : public SystemObject,
virtual MessageQueueId_t getCommandQueue() const override;
ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override;
ModeTreeChildIF& getModeTreeChildIF() override;
/**
* Function to register the child objects.

View File

@ -2,19 +2,19 @@
#include <fsfw/objectmanager/ObjectManager.h>
TestAssembly::TestAssembly(object_id_t objectId, object_id_t parentId, object_id_t testDevice0,
object_id_t testDevice1)
TestAssembly::TestAssembly(object_id_t objectId, object_id_t parentId, ModeTreeChildIF& testDevice0,
ModeTreeChildIF& testDevice1)
: AssemblyBase(objectId, parentId),
deviceHandler0Id(testDevice0),
deviceHandler1Id(testDevice1) {
deviceHandler0(testDevice0),
deviceHandler1(testDevice1) {
ModeListEntry newModeListEntry;
newModeListEntry.setObject(testDevice0);
newModeListEntry.setObject(testDevice0.getObjectId());
newModeListEntry.setMode(MODE_OFF);
newModeListEntry.setSubmode(SUBMODE_NONE);
commandTable.insert(newModeListEntry);
newModeListEntry.setObject(testDevice1);
newModeListEntry.setObject(testDevice1.getObjectId());
newModeListEntry.setMode(MODE_OFF);
newModeListEntry.setSubmode(SUBMODE_NONE);
@ -43,8 +43,8 @@ ReturnValue_t TestAssembly::commandChildren(Mode_t mode, Submode_t submode) {
commandTable[1].setMode(MODE_OFF);
commandTable[1].setSubmode(SUBMODE_NONE);
// We try to prefer 0 here but we try to switch to 1 even if it might fail
if (isDeviceAvailable(deviceHandler0Id)) {
if (childrenMap[deviceHandler0Id].mode == MODE_ON) {
if (isDeviceAvailable(deviceHandler0.getObjectId())) {
if (childrenMap[deviceHandler0.getObjectId()].mode == MODE_ON) {
commandTable[0].setMode(mode);
commandTable[0].setSubmode(SUBMODE_NONE);
} else {
@ -53,7 +53,7 @@ ReturnValue_t TestAssembly::commandChildren(Mode_t mode, Submode_t submode) {
result = NEED_SECOND_STEP;
}
} else {
if (childrenMap[deviceHandler1Id].mode == MODE_ON) {
if (childrenMap[deviceHandler1.getObjectId()].mode == MODE_ON) {
commandTable[1].setMode(mode);
commandTable[1].setSubmode(SUBMODE_NONE);
} else {
@ -64,7 +64,7 @@ ReturnValue_t TestAssembly::commandChildren(Mode_t mode, Submode_t submode) {
}
} else {
// Dual Mode Normal
if (childrenMap[deviceHandler0Id].mode == MODE_ON) {
if (childrenMap[deviceHandler0.getObjectId()].mode == MODE_ON) {
commandTable[0].setMode(mode);
commandTable[0].setSubmode(SUBMODE_NONE);
} else {
@ -72,7 +72,7 @@ ReturnValue_t TestAssembly::commandChildren(Mode_t mode, Submode_t submode) {
commandTable[0].setSubmode(SUBMODE_NONE);
result = NEED_SECOND_STEP;
}
if (childrenMap[deviceHandler1Id].mode == MODE_ON) {
if (childrenMap[deviceHandler1.getObjectId()].mode == MODE_ON) {
commandTable[1].setMode(mode);
commandTable[1].setSubmode(SUBMODE_NONE);
} else {
@ -89,7 +89,7 @@ ReturnValue_t TestAssembly::commandChildren(Mode_t mode, Submode_t submode) {
commandTable[1].setMode(MODE_OFF);
commandTable[1].setSubmode(SUBMODE_NONE);
// We try to prefer 0 here but we try to switch to 1 even if it might fail
if (isDeviceAvailable(deviceHandler0Id)) {
if (isDeviceAvailable(deviceHandler0.getObjectId())) {
commandTable[0].setMode(MODE_ON);
commandTable[0].setSubmode(SUBMODE_NONE);
} else {
@ -133,24 +133,14 @@ ReturnValue_t TestAssembly::initialize() {
if (result != returnvalue::OK) {
return result;
}
handler0 = ObjectManager::instance()->get<TestDevice>(deviceHandler0Id);
handler1 = ObjectManager::instance()->get<TestDevice>(deviceHandler1Id);
auto* handler0 = ObjectManager::instance()->get<TestDevice>(deviceHandler0.getObjectId());
auto* handler1 = ObjectManager::instance()->get<TestDevice>(deviceHandler1.getObjectId());
if ((handler0 == nullptr) or (handler1 == nullptr)) {
return returnvalue::FAILED;
}
handler0->setParentQueue(this->getCommandQueue());
handler1->setParentQueue(this->getCommandQueue());
// TODO: Fix this
// result = registerChild(deviceHandler0Id);
// if (result != returnvalue::OK) {
// return result;
// }
// result = registerChild(deviceHandler1Id);
// if (result != returnvalue::OK) {
// return result;
// }
handler0->connectModeTreeParent(*this);
handler1->connectModeTreeParent(*this);
return result;
}

View File

@ -7,8 +7,8 @@
class TestAssembly : public AssemblyBase {
public:
TestAssembly(object_id_t objectId, object_id_t parentId, object_id_t testDevice0,
object_id_t testDevice1);
TestAssembly(object_id_t objectId, object_id_t parentId, ModeTreeChildIF& testDevice0,
ModeTreeChildIF& testDevice1);
virtual ~TestAssembly();
ReturnValue_t initialize() override;
@ -41,10 +41,8 @@ class TestAssembly : public AssemblyBase {
private:
FixedArrayList<ModeListEntry, 2> commandTable;
object_id_t deviceHandler0Id = 0;
object_id_t deviceHandler1Id = 0;
TestDevice* handler0 = nullptr;
TestDevice* handler1 = nullptr;
ModeTreeChildIF& deviceHandler0;
ModeTreeChildIF& deviceHandler1;
bool isDeviceAvailable(object_id_t object);
};