move retvals

This commit is contained in:
Robin Müller 2022-09-30 15:05:32 +02:00
parent acab5f6bce
commit 1eceef4645
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
11 changed files with 44 additions and 48 deletions

View File

@ -7,6 +7,13 @@
#include "../returnvalues/returnvalue.h"
#include "ArrayList.h"
namespace mapdefs {
static const uint8_t INTERFACE_ID = CLASS_ID::FIXED_MAP;
static const ReturnValue_t KEY_ALREADY_EXISTS = MAKE_RETURN_CODE(0x01);
static const ReturnValue_t MAP_FULL = MAKE_RETURN_CODE(0x02);
static const ReturnValue_t KEY_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x03);
} // namespace mapdefs
/**
* @brief Map implementation for maps with a pre-defined size.
* @details
@ -24,11 +31,6 @@ class FixedMap : public SerializeIF {
"derived class from SerializeIF to be serialize-able");
public:
static const uint8_t INTERFACE_ID = CLASS_ID::FIXED_MAP;
static const ReturnValue_t KEY_ALREADY_EXISTS = MAKE_RETURN_CODE(0x01);
static const ReturnValue_t MAP_FULL = MAKE_RETURN_CODE(0x02);
static const ReturnValue_t KEY_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x03);
private:
static const key_t EMPTY_SLOT = -1;
ArrayList<std::pair<key_t, T>, uint32_t> theMap;
@ -76,10 +78,10 @@ class FixedMap : public SerializeIF {
ReturnValue_t insert(key_t key, T value, Iterator* storedValue = nullptr) {
if (exists(key) == returnvalue::OK) {
return KEY_ALREADY_EXISTS;
return mapdefs::KEY_ALREADY_EXISTS;
}
if (_size == theMap.maxSize()) {
return MAP_FULL;
return mapdefs::MAP_FULL;
}
theMap[_size].first = key;
theMap[_size].second = value;
@ -93,7 +95,7 @@ class FixedMap : public SerializeIF {
ReturnValue_t insert(std::pair<key_t, T> pair) { return insert(pair.first, pair.second); }
ReturnValue_t exists(key_t key) const {
ReturnValue_t result = KEY_DOES_NOT_EXIST;
ReturnValue_t result = mapdefs::KEY_DOES_NOT_EXIST;
if (findIndex(key) < _size) {
result = returnvalue::OK;
}
@ -103,7 +105,7 @@ class FixedMap : public SerializeIF {
ReturnValue_t erase(Iterator* iter) {
uint32_t i;
if ((i = findIndex((*iter).value->first)) >= _size) {
return KEY_DOES_NOT_EXIST;
return mapdefs::KEY_DOES_NOT_EXIST;
}
theMap[i] = theMap[_size - 1];
--_size;
@ -114,7 +116,7 @@ class FixedMap : public SerializeIF {
ReturnValue_t erase(key_t key) {
uint32_t i;
if ((i = findIndex(key)) >= _size) {
return KEY_DOES_NOT_EXIST;
return mapdefs::KEY_DOES_NOT_EXIST;
}
theMap[i] = theMap[_size - 1];
--_size;

View File

@ -21,11 +21,11 @@ ControllerBase::~ControllerBase() { QueueFactory::instance()->deleteMessageQueue
ReturnValue_t ControllerBase::initialize() {
ReturnValue_t result = modeHelper.initialize();
if(result != returnvalue::OK) {
if (result != returnvalue::OK) {
return result;
}
result = healthHelper.initialize();
if(result != returnvalue::OK) {
if (result != returnvalue::OK) {
return result;
}
return SystemObject::initialize();
@ -106,9 +106,7 @@ const HasHealthIF* ControllerBase::getOptHealthIF() const { return this; }
const HasModesIF& ControllerBase::getModeIF() const { return *this; }
ModeTreeChildIF& ControllerBase::getModeTreeChildIF() {
return *this;
}
ModeTreeChildIF& ControllerBase::getModeTreeChildIF() { return *this; }
ReturnValue_t ControllerBase::connectModeTreeParent(HasModeTreeChildrenIF& parent) {
return modetree::connectModeTreeParent(parent, *this, healthHelper, modeHelper);

View File

@ -31,7 +31,7 @@ class ControllerBase : public HasModesIF,
~ControllerBase() override;
ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override;
ModeTreeChildIF& getModeTreeChildIF() override;
ModeTreeChildIF &getModeTreeChildIF() override;
/** SystemObject override */
ReturnValue_t initialize() override;

View File

@ -2,14 +2,15 @@
#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,
HasModeTreeChildrenIF& parent,
FailureIsolationBase* customFdir = nullptr, size_t cmdQueueSize = 20);
HasModeTreeChildrenIF& parent, FailureIsolationBase* customFdir = nullptr,
size_t cmdQueueSize = 20);
virtual ~ChildHandlerBase();

View File

@ -1,6 +1,5 @@
#include "DeviceHandlerBase.h"
#include "fsfw/subsystem/helper.h"
#include "fsfw/datapoollocal/LocalPoolVariable.h"
#include "fsfw/devicehandlers/AcceptsDeviceResponsesIF.h"
#include "fsfw/devicehandlers/DeviceTmReportingWrapper.h"
@ -13,6 +12,7 @@
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
#include "fsfw/subsystem/SubsystemBase.h"
#include "fsfw/subsystem/helper.h"
#include "fsfw/thermal/ThermalComponentIF.h"
object_id_t DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT;
@ -1593,18 +1593,12 @@ void DeviceHandlerBase::disableCommandsAndReplies() {
}
}
ReturnValue_t DeviceHandlerBase::connectModeTreeParent(HasModeTreeChildrenIF &parent) {
ReturnValue_t DeviceHandlerBase::connectModeTreeParent(HasModeTreeChildrenIF& parent) {
return modetree::connectModeTreeParent(parent, *this, healthHelper, modeHelper);
}
const HasHealthIF* DeviceHandlerBase::getOptHealthIF() const {
return this;
}
const HasHealthIF* DeviceHandlerBase::getOptHealthIF() const { return this; }
const HasModesIF& DeviceHandlerBase::getModeIF() const {
return *this;
}
const HasModesIF& DeviceHandlerBase::getModeIF() const { return *this; }
ModeTreeChildIF& DeviceHandlerBase::getModeTreeChildIF() {
return *this;
}
ModeTreeChildIF& DeviceHandlerBase::getModeTreeChildIF() { return *this; }

View File

@ -11,7 +11,6 @@
#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"
@ -22,6 +21,7 @@
#include "fsfw/returnvalues/returnvalue.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/serviceinterface/serviceInterfaceDefintions.h"
#include "fsfw/subsystem/ModeTreeConnectionIF.h"
#include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/tasks/PeriodicTaskIF.h"
#include "fsfw/util/dataWrapper.h"
@ -125,7 +125,7 @@ class DeviceHandlerBase : public DeviceHandlerIF,
uint32_t thermalSetId = DeviceHandlerIF::DEFAULT_THERMAL_SET_ID);
ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override;
ModeTreeChildIF& getModeTreeChildIF() override;
ModeTreeChildIF &getModeTreeChildIF() override;
/**
* @brief Helper function to ease device handler development.
@ -967,8 +967,8 @@ class DeviceHandlerBase : public DeviceHandlerIF,
*/
LocalDataPoolManager *getHkManagerHandle() override;
const HasHealthIF* getOptHealthIF() const override;
const HasModesIF& getModeIF() const override;
const HasHealthIF *getOptHealthIF() const override;
const HasModesIF &getModeIF() const override;
/**
* Returns the delay cycle count of a reply.

View File

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

View File

@ -36,6 +36,13 @@ ReturnValue_t Subsystem::checkSequence(HybridIterator<ModeListEntry> iter,
for (; iter.value != nullptr; ++iter) {
if (!existsModeTable(iter->getTableId())) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
using namespace std;
sif::warning << "Subsystem::checkSequence: "
<< "Object " << setfill('0') << hex << "0x" << setw(8) << getObjectId()
<< setw(0) << ": Mode table for mode ID "
<< "0x" << setw(8) << iter->getTableId() << " does not exist" << dec << endl;
#endif
return TABLE_DOES_NOT_EXIST;
} else {
ReturnValue_t result = checkTable(getTable(iter->getTableId()));

View File

@ -131,11 +131,11 @@ MessageQueueId_t SubsystemBase::getCommandQueue() const { return commandQueue->g
ReturnValue_t SubsystemBase::initialize() {
ReturnValue_t result = modeHelper.initialize();
if(result != returnvalue::OK) {
if (result != returnvalue::OK) {
return result;
}
result = healthHelper.initialize();
if(result != returnvalue::OK) {
if (result != returnvalue::OK) {
return result;
}
return SystemObject::initialize();
@ -310,10 +310,6 @@ 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;
}
ModeTreeChildIF& SubsystemBase::getModeTreeChildIF() { return *this; }

View File

@ -6,12 +6,12 @@
#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"
#include "fsfw/returnvalues/returnvalue.h"
#include "fsfw/subsystem/HasModeTreeChildrenIF.h"
#include "fsfw/subsystem/ModeTreeConnectionIF.h"
#include "fsfw/tasks/ExecutableObjectIF.h"
#include "modes/HasModeSequenceIF.h"
@ -47,7 +47,7 @@ class SubsystemBase : public SystemObject,
virtual MessageQueueId_t getCommandQueue() const override;
ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override;
ModeTreeChildIF& getModeTreeChildIF() override;
ModeTreeChildIF &getModeTreeChildIF() override;
/**
* Function to register the child objects.

View File

@ -3,10 +3,8 @@
#include <fsfw/objectmanager/ObjectManager.h>
TestAssembly::TestAssembly(object_id_t objectId, object_id_t parentId, ModeTreeChildIF& testDevice0,
ModeTreeChildIF& testDevice1)
: AssemblyBase(objectId, parentId),
deviceHandler0(testDevice0),
deviceHandler1(testDevice1) {
ModeTreeChildIF& testDevice1)
: AssemblyBase(objectId, parentId), deviceHandler0(testDevice0), deviceHandler1(testDevice1) {
ModeListEntry newModeListEntry;
newModeListEntry.setObject(testDevice0.getObjectId());
newModeListEntry.setMode(MODE_OFF);