need to fix all of these TODOs

This commit is contained in:
Robin Müller 2022-09-29 19:39:37 +02:00
parent 7c5308429c
commit f824004897
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
11 changed files with 67 additions and 114 deletions

View File

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

View File

@ -30,8 +30,7 @@ class ControllerBase : public HasModesIF,
ControllerBase(object_id_t setObjectId, size_t commandQueueDepth = 3);
~ControllerBase() override;
ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent,
const ModeTreeChildIF &child) override;
ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override;
/** SystemObject override */
ReturnValue_t initialize() override;

View File

@ -1,7 +1,7 @@
#include "fsfw/devicehandlers/AssemblyBase.h"
AssemblyBase::AssemblyBase(object_id_t objectId, object_id_t parentId, uint16_t commandQueueDepth)
: SubsystemBase(objectId, parentId, MODE_OFF, commandQueueDepth),
AssemblyBase::AssemblyBase(object_id_t objectId, uint16_t commandQueueDepth)
: SubsystemBase(objectId, MODE_OFF, commandQueueDepth),
internalState(STATE_NONE),
recoveryState(RECOVERY_IDLE),
recoveringDevice(childrenMap.end()),

View File

@ -41,7 +41,7 @@ class AssemblyBase : public SubsystemBase {
static const ReturnValue_t NEED_TO_CHANGE_HEALTH = MAKE_RETURN_CODE(0x05);
static const ReturnValue_t NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE = MAKE_RETURN_CODE(0xa1);
AssemblyBase(object_id_t objectId, object_id_t parentId, uint16_t commandQueueDepth = 8);
AssemblyBase(object_id_t objectId, uint16_t commandQueueDepth = 8);
virtual ~AssemblyBase();
protected:

View File

@ -18,21 +18,22 @@ ReturnValue_t ChildHandlerBase::initialize() {
return result;
}
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);
// 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;
}

View File

@ -9,9 +9,9 @@
#include "fsfw/serialize/SerialLinkedListAdapter.h"
#include "fsfw/serialize/SerializeElement.h"
Subsystem::Subsystem(object_id_t setObjectId, object_id_t parent, uint32_t maxNumberOfSequences,
Subsystem::Subsystem(object_id_t setObjectId, uint32_t maxNumberOfSequences,
uint32_t maxNumberOfTables)
: SubsystemBase(setObjectId, parent, 0),
: SubsystemBase(setObjectId, 0),
isInTransition(false),
childrenChangedHealth(false),
currentTargetTable(),

View File

@ -66,8 +66,7 @@ class Subsystem : public SubsystemBase, public HasModeSequenceIF {
* @param maxNumberOfSequences
* @param maxNumberOfTables
*/
Subsystem(object_id_t setObjectId, object_id_t parent, uint32_t maxNumberOfSequences,
uint32_t maxNumberOfTables);
Subsystem(object_id_t setObjectId, uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables);
virtual ~Subsystem();
ReturnValue_t addSequence(SequenceEntry sequence);

View File

@ -4,14 +4,14 @@
#include "fsfw/ipc/QueueFactory.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface.h"
#include "fsfw/subsystem/helper.h"
SubsystemBase::SubsystemBase(object_id_t setObjectId, object_id_t parent, Mode_t initialMode,
SubsystemBase::SubsystemBase(object_id_t setObjectId, Mode_t initialMode,
uint16_t commandQueueDepth)
: SystemObject(setObjectId),
mode(initialMode),
healthHelper(this, setObjectId),
modeHelper(this),
parentId(parent) {
modeHelper(this) {
auto mqArgs = MqArgs(setObjectId, static_cast<void*>(this));
commandQueue = QueueFactory::instance()->createMessageQueue(
commandQueueDepth, CommandMessage::MAX_MESSAGE_SIZE, &mqArgs);
@ -19,36 +19,6 @@ SubsystemBase::SubsystemBase(object_id_t setObjectId, object_id_t parent, Mode_t
SubsystemBase::~SubsystemBase() { QueueFactory::instance()->deleteMessageQueue(commandQueue); }
ReturnValue_t SubsystemBase::registerChild(object_id_t objectId) {
ChildInfo info;
HasModesIF* child = ObjectManager::instance()->get<HasModesIF>(objectId);
// This is a rather ugly hack to have the changedHealth info for all
// children available.
HasHealthIF* healthChild = ObjectManager::instance()->get<HasHealthIF>(objectId);
if (child == nullptr) {
if (healthChild == nullptr) {
return CHILD_DOESNT_HAVE_MODES;
} else {
info.commandQueue = healthChild->getCommandQueue();
info.mode = MODE_OFF;
}
} else {
// intentional to force an initial command during system startup
info.commandQueue = child->getCommandQueue();
info.mode = HasModesIF::MODE_UNDEFINED;
}
info.submode = SUBMODE_NONE;
info.healthChanged = false;
auto resultPair = childrenMap.emplace(objectId, info);
if (not resultPair.second) {
return COULD_NOT_INSERT_CHILD;
}
return returnvalue::OK;
}
ReturnValue_t SubsystemBase::checkStateAgainstTable(HybridIterator<ModeListEntry> tableIter,
Submode_t targetSubmode) {
std::map<object_id_t, ChildInfo>::iterator childIter;
@ -88,7 +58,8 @@ void SubsystemBase::executeTable(HybridIterator<ModeListEntry> tableIter, Submod
if ((iter = childrenMap.find(object)) == childrenMap.end()) {
// illegal table entry, should only happen due to misconfigured mode table
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << std::hex << getObjectId() << ": invalid mode table entry" << std::endl;
sif::debug << std::hex << SystemObject::getObjectId() << ": invalid mode table entry"
<< std::endl;
#endif
continue;
}
@ -158,38 +129,7 @@ ReturnValue_t SubsystemBase::updateChildChangedHealth(MessageQueueId_t queue, bo
MessageQueueId_t SubsystemBase::getCommandQueue() const { return commandQueue->getId(); }
ReturnValue_t SubsystemBase::initialize() {
MessageQueueId_t parentQueue = MessageQueueIF::NO_QUEUE;
ReturnValue_t result = SystemObject::initialize();
if (result != returnvalue::OK) {
return result;
}
if (parentId != objects::NO_OBJECT) {
SubsystemBase* parent = ObjectManager::instance()->get<SubsystemBase>(parentId);
if (parent == nullptr) {
return returnvalue::FAILED;
}
parentQueue = parent->getCommandQueue();
parent->registerChild(getObjectId());
}
result = healthHelper.initialize(parentQueue);
if (result != returnvalue::OK) {
return result;
}
result = modeHelper.initialize(parentQueue);
if (result != returnvalue::OK) {
return result;
}
return returnvalue::OK;
}
ReturnValue_t SubsystemBase::initialize() { return SystemObject::initialize(); }
ReturnValue_t SubsystemBase::performOperation(uint8_t opCode) {
childrenChangedMode = false;
@ -247,7 +187,7 @@ ReturnValue_t SubsystemBase::checkTable(HybridIterator<ModeListEntry> tableIter)
using namespace std;
sif::warning << "SubsystemBase::checkTable: Could not find Object " << setfill('0') << hex
<< "0x" << setw(8) << tableIter.value->getObject() << " in object " << setw(8)
<< "0x" << getObjectId() << dec << std::endl;
<< "0x" << SystemObject::getObjectId() << dec << std::endl;
#endif
return TABLE_CONTAINS_INVALID_OBJECT_ID;
}
@ -333,6 +273,12 @@ ReturnValue_t SubsystemBase::setHealth(HealthState health) {
HasHealthIF::HealthState SubsystemBase::getHealth() { return healthHelper.getHealth(); }
ReturnValue_t SubsystemBase::connectModeTreeParent(HasModeTreeChildrenIF& parent) {
return modetree::connectModeTreeParent(parent, *this, healthHelper, modeHelper);
}
object_id_t SubsystemBase::getObjectId() const { return SystemObject::getObjectId(); }
void SubsystemBase::modeChanged() {}
ReturnValue_t SubsystemBase::registerChild(const ModeTreeChildIF& child) {
@ -351,3 +297,7 @@ ReturnValue_t SubsystemBase::registerChild(const ModeTreeChildIF& child) {
}
return returnvalue::OK;
}
const HasHealthIF* SubsystemBase::getOptHealthIF() const { return this; }
const HasModesIF& SubsystemBase::getModeIF() const { return *this; }

View File

@ -1,6 +1,8 @@
#ifndef FSFW_SUBSYSTEM_SUBSYSTEMBASE_H_
#define FSFW_SUBSYSTEM_SUBSYSTEMBASE_H_
#include <fsfw/subsystem/modes/ModeTreeConnectionIF.h>
#include <map>
#include "fsfw/container/HybridIterator.h"
@ -29,6 +31,8 @@ class SubsystemBase : public SystemObject,
public HasModesIF,
public HasHealthIF,
public HasModeTreeChildrenIF,
public ModeTreeConnectionIF,
public ModeTreeChildIF,
public ExecutableObjectIF {
public:
static const uint8_t INTERFACE_ID = CLASS_ID::SUBSYSTEM_BASE;
@ -38,24 +42,25 @@ class SubsystemBase : public SystemObject,
static const ReturnValue_t COULD_NOT_INSERT_CHILD = MAKE_RETURN_CODE(0x04);
static const ReturnValue_t TABLE_CONTAINS_INVALID_OBJECT_ID = MAKE_RETURN_CODE(0x05);
SubsystemBase(object_id_t setObjectId, object_id_t parent, Mode_t initialMode = 0,
uint16_t commandQueueDepth = 8);
SubsystemBase(object_id_t setObjectId, Mode_t initialMode = 0, uint16_t commandQueueDepth = 8);
virtual ~SubsystemBase();
virtual MessageQueueId_t getCommandQueue() const override;
ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override;
/**
* Function to register the child objects.
* Performs a checks if the child does implement HasHealthIF and/or HasModesIF
*
* Also adds them to the internal childrenMap.
* Also adds them to the internal childrenMap.
*
* @param objectId
* @return returnvalue::OK if successful
* CHILD_DOESNT_HAVE_MODES if Child is no HasHealthIF and no HasModesIF
* COULD_NOT_INSERT_CHILD If the Child could not be added to the ChildrenMap
* CHILD_DOESNT_HAVE_MODES if Child is no HasHealthIF and no HasModesIF
* COULD_NOT_INSERT_CHILD If the Child could not be added to the ChildrenMap
*/
ReturnValue_t registerChild(object_id_t objectId);
ReturnValue_t registerChild(const ModeTreeChildIF &child) override;
virtual ReturnValue_t initialize() override;
@ -90,8 +95,6 @@ class SubsystemBase : public SystemObject,
ModeHelper modeHelper;
const object_id_t parentId;
typedef std::map<object_id_t, ChildInfo> ChildrenMap;
ChildrenMap childrenMap;
@ -131,8 +134,6 @@ class SubsystemBase : public SystemObject,
virtual void performChildOperation() = 0;
ReturnValue_t registerChild(const ModeTreeChildIF &child) override;
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode) override = 0;
@ -140,6 +141,10 @@ class SubsystemBase : public SystemObject,
virtual void getMode(Mode_t *mode, Submode_t *submode) override;
object_id_t getObjectId() const override;
const HasHealthIF *getOptHealthIF() const override;
const HasModesIF &getModeIF() const override;
virtual void setToExternalControl() override;
virtual void announceMode(bool recursive) override;

View File

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

View File

@ -142,14 +142,15 @@ ReturnValue_t TestAssembly::initialize() {
handler0->setParentQueue(this->getCommandQueue());
handler1->setParentQueue(this->getCommandQueue());
result = registerChild(deviceHandler0Id);
if (result != returnvalue::OK) {
return result;
}
result = registerChild(deviceHandler1Id);
if (result != returnvalue::OK) {
return result;
}
// TODO: Fix this
// result = registerChild(deviceHandler0Id);
// if (result != returnvalue::OK) {
// return result;
// }
// result = registerChild(deviceHandler1Id);
// if (result != returnvalue::OK) {
// return result;
// }
return result;
}