updated attorneys

This commit is contained in:
Robin Müller 2021-01-12 14:08:51 +01:00
parent bb10c25909
commit cafc8e4ccb
21 changed files with 266 additions and 151 deletions

View File

@ -26,7 +26,7 @@ object_id_t ExtendedControllerBase::getObjectId() const {
return SystemObject::getObjectId();
}
LocalDataPoolManager* ExtendedControllerBase::getHkManagerHandle() {
AccessPoolManagerIF* ExtendedControllerBase::getAccessorHandle() {
return &localPoolManager;
}
@ -106,10 +106,6 @@ MessageQueueId_t ExtendedControllerBase::getCommandQueue() const {
return commandQueue->getId();
}
AccessLocalPoolIF* ExtendedControllerBase::getAccessorHandle() {
return &localPoolManager;
}
LocalPoolDataSetBase* ExtendedControllerBase::getDataSetHandle(sid_t sid) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "ExtendedControllerBase::getDataSetHandle: No child "

View File

@ -33,7 +33,7 @@ public:
virtual ReturnValue_t initializeAfterTaskCreation() override;
ProvidesDataPoolSubscriptionIF* getSubscriptionInterface() override;
AccessLocalPoolIF* getAccessorHandle() override;
AccessPoolManagerIF* getAccessorHandle() override;
protected:
LocalDataPoolManager localPoolManager;
@ -65,7 +65,6 @@ protected:
virtual ReturnValue_t initializeLocalDataPool(
LocalDataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
virtual LocalDataPoolManager* getHkManagerHandle() override;
virtual uint32_t getPeriodicOperationFrequency() const override;
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
};

View File

@ -1,31 +1,26 @@
#ifndef FSFW_DATAPOOLLOCAL_ACCESSLOCALPOOLF_H_
#define FSFW_DATAPOOLLOCAL_ACCESSLOCALPOOLF_H_
#include <fsfw/datapoollocal/locPoolDefinitions.h>
#include <fsfw/datapool/PoolEntry.h>
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
//#include "LocalDataPoolManager.h"
#include <fsfw/ipc/MutexIF.h>
class AccessLocalPoolIF {
public:
virtual ~AccessLocalPoolIF() {};
class LocalDataPoolManager;
virtual ReturnValue_t retrieveLocalPoolMutex(MutexIF* mutex) = 0;
virtual object_id_t getCreatorObjectId() const = 0;
class AccessPoolManagerIF {
public:
virtual ~AccessPoolManagerIF() {};
virtual MutexIF* getLocalPoolMutex() = 0;
/**
* Can be used to get a handle to the local data pool manager.
* This function is protected because it should only be used by the
* class imlementing the interface.
*/
virtual LocalDataPoolManager* getHkManagerHandle() = 0;
protected:
//virtual LocalDataPoolManager* getHkManagerHandle() = 0;
};
//template <typename T>
//class AccessLocalPoolTypedIF {
//public:
// virtual ~AccessLocalPoolTypedIF() {};
//
// virtual ReturnValue_t fetchPoolEntry(lp_id_t localPoolId, PoolEntry<T> **poolEntry) = 0;
//};
#endif /* FSFW_DATAPOOLLOCAL_ACCESSLOCALPOOLF_H_ */

View File

@ -12,7 +12,6 @@
#include <map>
class LocalDataPoolManager;
class LocalPoolDataSetBase;
class LocalPoolObjectBase;
@ -20,31 +19,26 @@ using LocalDataPool = std::map<lp_id_t, PoolEntryIF*>;
using LocalDataPoolMapIter = LocalDataPool::iterator;
/**
* @brief This interface is implemented by classes which posses a local
* data pool (not the managing class). It defines the relationship
* between the local data pool owner and the LocalDataPoolManager.
* @brief This interface is implemented by classes which posses a local data pool (not the
* managing class). It defines the relationship between the local data pool owner
* and the LocalDataPoolManager.
* @details
* Any class implementing this interface shall also have a LocalDataPoolManager
* member class which contains the actual pool data structure
* and exposes the public interface for it.
* This is required because the pool entries are templates, which makes
* specifying an interface rather difficult. The local data pool can be
* accessed by using the LocalPoolVariable, LocalPoolVector or LocalDataSet
* classes.
* Any class implementing this interface shall also have a LocalDataPoolManager member class which
* contains the actual pool data structure and exposes the public interface for it.
* This is required because the pool entries are templates, which makes specifying an interface
* rather difficult. The local data pool can be accessed by using the LocalPoolVariable,
* LocalPoolVector or LocalDataSet classes.
*
* Architectural Note:
* This could be circumvented by using a wrapper/accessor function or
* implementing the templated function in this interface..
* The first solution sounds better than the second but
* the LocalPoolVariable classes are templates as well, so this just shifts
* the problem somewhere else. Interfaces are nice, but the most
* pragmatic solution I found was to offer the client the full interface
* of the LocalDataPoolManager.
* This could be circumvented by using a wrapper/accessor function or implementing the templated
* function in this interface.. The first solution sounds better than the second but the
* LocalPoolVariable classes are templates as well, so this just shifts the problem somewhere else.
* Interfaces are nice, but the most pragmatic solution I found was to offer the client the full
* interface of the LocalDataPoolManager.
*/
class HasLocalDataPoolIF {
friend class LocalDataPoolManager;
friend class LocalPoolDataSetBase;
friend class LocalPoolObjectBase;
friend class HasLocalDpIFManagerAttorney;
friend class HasLocalDpIFUserAttorney;
public:
virtual~ HasLocalDataPoolIF() {};
@ -55,6 +49,8 @@ public:
static constexpr uint32_t INVALID_LPID = localpool::INVALID_LPID;
virtual object_id_t getObjectId() const = 0;
/** Command queue for housekeeping messages. */
virtual MessageQueueId_t getCommandQueue() const = 0;
@ -63,8 +59,7 @@ public:
* The manager instance shall also be passed to this function.
* It can be used to subscribe for periodic packets for for updates.
*/
virtual ReturnValue_t initializeLocalDataPool(
LocalDataPool& localDataPoolMap,
virtual ReturnValue_t initializeLocalDataPool(LocalDataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) = 0;
/**
@ -84,7 +79,7 @@ public:
* the IPC store with this store ID.
*/
virtual void handleChangedDataset(sid_t sid,
store_address_t storeId = storeId::INVALID_STORE_ADDRESS) {
store_address_t storeId = storeId::INVALID_STORE_ADDRESS) {
return;
}
@ -112,27 +107,20 @@ public:
virtual ReturnValue_t removeDataSet(sid_t sid) {
return HasReturnvaluesIF::RETURN_FAILED;
};
virtual ReturnValue_t changeCollectionInterval(sid_t sid,
float newIntervalSeconds) {
virtual ReturnValue_t changeCollectionInterval(sid_t sid, float newIntervalSeconds) {
return HasReturnvaluesIF::RETURN_FAILED;
};
/**
* This function can be used by data pool consumers to retrieve a handle
* This function can be used by data pool consumers to retrieve a handle
* which allows subscriptions to dataset and variable updates.
* @return
*/
virtual ProvidesDataPoolSubscriptionIF* getSubscriptionInterface() = 0;
virtual AccessLocalPoolIF* getAccessorHandle() = 0;
protected:
/**
* Can be used to get a handle to the local data pool manager.
* This function is protected because it should only be used by the
* class imlementing the interface.
*/
virtual LocalDataPoolManager* getHkManagerHandle() = 0;
virtual AccessPoolManagerIF* getAccessorHandle() = 0;
/**
* This function is used by the pool manager to get a valid dataset

View File

@ -0,0 +1,38 @@
#ifndef FSFW_DATAPOOLLOCAL_HASLOCALDATAPOOLIFATTORNEY_H_
#define FSFW_DATAPOOLLOCAL_HASLOCALDATAPOOLIFATTORNEY_H_
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
class HasLocalDpIFUserAttorney {
private:
static AccessPoolManagerIF* getAccessorHandle(HasLocalDataPoolIF* interface) {
return interface->getAccessorHandle();
}
friend class LocalPoolObjectBase;
friend class LocalPoolDataSetBase;
};
class HasLocalDpIFManagerAttorney {
static LocalPoolDataSetBase* getDataSetHandle(HasLocalDataPoolIF* interface, sid_t sid) {
return interface->getDataSetHandle(sid);
}
static LocalPoolObjectBase* getPoolObjectHandle(HasLocalDataPoolIF* interface,
lp_id_t localPoolId) {
return interface->getPoolObjectHandle(localPoolId);
}
static object_id_t getObjectId(HasLocalDataPoolIF* interface) {
return interface->getObjectId();
}
friend class LocalDataPoolManager;
};
#endif /* FSFW_DATAPOOLLOCAL_HASLOCALDATAPOOLIFATTORNEY_H_ */

View File

@ -1,6 +1,8 @@
#include "LocalDataPoolManager.h"
#include "LocalPoolObjectBase.h"
#include "LocalPoolDataSetBase.h"
#include "HasLocalDataPoolIFAttorney.h"
#include "LocalPoolDataSetAttorney.h"
#include "../housekeeping/HousekeepingPacketUpdate.h"
#include "../housekeeping/HousekeepingSetPacket.h"
@ -132,7 +134,7 @@ ReturnValue_t LocalDataPoolManager::handleHkUpdate(HkReceiver& receiver,
// Update packets shall only be generated from datasets.
return HasReturnvaluesIF::RETURN_FAILED;
}
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner,
receiver.dataId.sid);
if(dataSet->hasChanged()) {
// prepare and send update notification
@ -151,7 +153,9 @@ ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(HkReceiver& receive
ReturnValue_t& status) {
MarkChangedIF* toReset = nullptr;
if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
LocalPoolObjectBase* poolObj = owner->getPoolObjectHandle(receiver.dataId.localPoolId);
LocalPoolObjectBase* poolObj = HasLocalDpIFManagerAttorney::getPoolObjectHandle(owner,
receiver.dataId.localPoolId);
//LocalPoolObjectBase* poolObj = owner->getPoolObjectHandle(receiver.dataId.localPoolId);
if(poolObj == nullptr) {
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
"handleNotificationUpdate", POOLOBJECT_NOT_FOUND);
@ -172,7 +176,8 @@ ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(HkReceiver& receive
}
else {
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(receiver.dataId.sid);
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner,
receiver.dataId.sid);
if(dataSet == nullptr) {
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
"handleNotificationUpdate", DATASET_NOT_FOUND);
@ -203,7 +208,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(
MarkChangedIF* toReset = nullptr;
// check whether data has changed and send messages in case it has.
if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
LocalPoolObjectBase* poolObj = owner->getPoolObjectHandle(
LocalPoolObjectBase* poolObj = HasLocalDpIFManagerAttorney::getPoolObjectHandle(owner,
receiver.dataId.localPoolId);
if(poolObj == nullptr) {
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
@ -221,7 +226,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(
CCSDSTime::CDS_short cds;
CCSDSTime::convertToCcsds(&cds, &now);
HousekeepingPacketUpdate updatePacket(reinterpret_cast<uint8_t*>(&cds),
sizeof(cds), owner->getPoolObjectHandle(
sizeof(cds), HasLocalDpIFManagerAttorney::getPoolObjectHandle(owner,
receiver.dataId.localPoolId));
store_address_t storeId;
@ -241,7 +246,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(
toReset = poolObj;
}
else {
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner,
receiver.dataId.sid);
if(dataSet == nullptr) {
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
@ -259,7 +264,8 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(
CCSDSTime::CDS_short cds;
CCSDSTime::convertToCcsds(&cds, &now);
HousekeepingPacketUpdate updatePacket(reinterpret_cast<uint8_t*>(&cds),
sizeof(cds), owner->getDataSetHandle(receiver.dataId.sid));
sizeof(cds), HasLocalDpIFManagerAttorney::getDataSetHandle(owner,
receiver.dataId.sid));
store_address_t storeId;
ReturnValue_t result = addUpdateToStore(updatePacket, storeId);
@ -363,11 +369,12 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid,
hkReceiver.dataType = DataType::DATA_SET;
hkReceiver.destinationQueue = hkReceiverObject->getHkQueue();
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
//LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
if(dataSet != nullptr) {
dataSet->setReportingEnabled(enableReporting);
dataSet->setDiagnostic(isDiagnostics);
dataSet->initializePeriodicHelper(collectionInterval,
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enableReporting);
LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics);
LocalPoolDataSetAttorney::initializePeriodicHelper(*dataSet, collectionInterval,
owner->getPeriodicOperationFrequency(), isDiagnostics);
}
@ -393,10 +400,11 @@ ReturnValue_t LocalDataPoolManager::subscribeForUpdatePackets(sid_t sid,
hkReceiver.dataType = DataType::DATA_SET;
hkReceiver.destinationQueue = hkReceiverObject->getHkQueue();
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
//LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
if(dataSet != nullptr) {
dataSet->setReportingEnabled(true);
dataSet->setDiagnostic(isDiagnostics);
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, true);
LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics);
}
hkReceiversMap.push_back(hkReceiver);
@ -410,7 +418,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForSetUpdateMessages(
MessageQueueId_t targetQueueId, bool generateSnapshot) {
struct HkReceiver hkReceiver;
hkReceiver.dataType = DataType::DATA_SET;
hkReceiver.dataId.sid = sid_t(this->getCreatorObjectId(), setId);
hkReceiver.dataId.sid = sid_t(owner->getObjectId(), setId);
hkReceiver.destinationQueue = targetQueueId;
hkReceiver.objectId = destinationObject;
if(generateSnapshot) {
@ -534,13 +542,14 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
case(HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT):
case(HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT): {
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
LocalPoolDataSetBase* dataSet =HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
//LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
if(command == HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT
and dataSet->isDiagnostics()) {
and LocalPoolDataSetAttorney::isDiagnostics(*dataSet)) {
return WRONG_HK_PACKET_TYPE;
}
else if(command == HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT
and not dataSet->isDiagnostics()) {
and not LocalPoolDataSetAttorney::isDiagnostics(*dataSet)) {
return WRONG_HK_PACKET_TYPE;
}
return generateHousekeepingPacket(HousekeepingMessage::getSid(message),
@ -629,7 +638,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
// and now we set a HK message and send it the HK packet destination.
CommandMessage hkMessage;
if(dataSet->isDiagnostics()) {
if(LocalPoolDataSetAttorney::isDiagnostics(*dataSet)) {
HousekeepingMessage::setHkDiagnosticsReply(&hkMessage, sid, storeId);
}
else {
@ -683,7 +692,8 @@ void LocalDataPoolManager::setNonDiagnosticIntervalFactor(
void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
sid_t sid = receiver.dataId.sid;
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
//LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
if(dataSet == nullptr) {
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
"performPeriodicHkGeneration",
@ -691,16 +701,19 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
return;
}
if(not dataSet->getReportingEnabled()) {
if(not LocalPoolDataSetAttorney::getReportingEnabled(*dataSet)) {
return;
}
if(dataSet->periodicHelper == nullptr) {
PeriodicHousekeepingHelper* periodicHelper =
LocalPoolDataSetAttorney::getPeriodicHelper(*dataSet);
if(periodicHelper == nullptr) {
// Configuration error.
return;
}
if(not dataSet->periodicHelper->checkOpNecessary()) {
if(periodicHelper->checkOpNecessary()) {
return;
}
@ -721,43 +734,49 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
ReturnValue_t LocalDataPoolManager::togglePeriodicGeneration(sid_t sid,
bool enable, bool isDiagnostics) {
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
if((dataSet->isDiagnostics() and not isDiagnostics) or
(not dataSet->isDiagnostics() and isDiagnostics)) {
//LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
if((LocalPoolDataSetAttorney::isDiagnostics(*dataSet) and not isDiagnostics) or
(not LocalPoolDataSetAttorney::isDiagnostics(*dataSet) and isDiagnostics)) {
return WRONG_HK_PACKET_TYPE;
}
if((dataSet->getReportingEnabled() and enable) or
(not dataSet->getReportingEnabled() and not enable)) {
if((LocalPoolDataSetAttorney::getReportingEnabled(*dataSet) and enable) or
(not LocalPoolDataSetAttorney::getReportingEnabled(*dataSet) and not enable)) {
return REPORTING_STATUS_UNCHANGED;
}
dataSet->setReportingEnabled(enable);
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enable);
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid,
float newCollectionInterval, bool isDiagnostics) {
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
bool targetIsDiagnostics = dataSet->isDiagnostics();
//LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
bool targetIsDiagnostics = LocalPoolDataSetAttorney::isDiagnostics(*dataSet);
if((targetIsDiagnostics and not isDiagnostics) or
(not targetIsDiagnostics and isDiagnostics)) {
return WRONG_HK_PACKET_TYPE;
}
if(dataSet->periodicHelper == nullptr) {
PeriodicHousekeepingHelper* periodicHelper =
LocalPoolDataSetAttorney::getPeriodicHelper(*dataSet);
if(periodicHelper == nullptr) {
// config error
return PERIODIC_HELPER_INVALID;
}
dataSet->periodicHelper->changeCollectionInterval(newCollectionInterval);
periodicHelper->changeCollectionInterval(newCollectionInterval);
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid,
bool isDiagnostics) {
// Get and check dataset first.
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
//LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
if(dataSet == nullptr) {
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
"performPeriodicHkGeneration",
@ -766,16 +785,16 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid,
}
bool targetIsDiagnostics = dataSet->isDiagnostics();
bool targetIsDiagnostics = LocalPoolDataSetAttorney::isDiagnostics(*dataSet);
if((targetIsDiagnostics and not isDiagnostics) or
(not targetIsDiagnostics and isDiagnostics)) {
return WRONG_HK_PACKET_TYPE;
}
bool valid = dataSet->isValid();
bool reportingEnabled = dataSet->getReportingEnabled();
float collectionInterval =
dataSet->periodicHelper->getCollectionIntervalInSeconds();
bool reportingEnabled = LocalPoolDataSetAttorney::getReportingEnabled(*dataSet);
float collectionInterval = LocalPoolDataSetAttorney::getPeriodicHelper(*dataSet)->
getCollectionIntervalInSeconds();
// Generate set packet which can be serialized.
HousekeepingSetPacket setPacket(sid,
@ -822,16 +841,13 @@ void LocalDataPoolManager::clearReceiversList() {
HkReceivers().swap(hkReceiversMap);
}
ReturnValue_t LocalDataPoolManager::retrieveLocalPoolMutex(MutexIF *mutex) {
if(this->mutex == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
mutex = this->mutex;
return HasReturnvaluesIF::RETURN_OK;
MutexIF* LocalDataPoolManager::getLocalPoolMutex() {
return this->mutex;
}
object_id_t LocalDataPoolManager::getCreatorObjectId() const {
return owner->getAccessorHandle()->getCreatorObjectId();
return owner->getObjectId();
//return owner->getObjectId();
}
void LocalDataPoolManager::printWarningOrError(fsfw::OutputTypes outputType,
@ -869,7 +885,7 @@ void LocalDataPoolManager::printWarningOrError(fsfw::OutputTypes outputType,
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalDataPoolManager::" << functionName
<< ": Object ID " << std::setw(8) << std::setfill('0')
<< std::hex << this->getCreatorObjectId() << " | " << errorPrint
<< std::hex << owner->getObjectId() << " | " << errorPrint
<< std::dec << std::setfill(' ') << std::endl;
#else
fsfw::printWarning("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n",
@ -880,7 +896,7 @@ void LocalDataPoolManager::printWarningOrError(fsfw::OutputTypes outputType,
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalDataPoolManager::" << functionName
<< ": Object ID " << std::setw(8) << std::setfill('0')
<< std::hex << this->getCreatorObjectId() << " | " << errorPrint
<< std::hex << owner->getObjectId() << " | " << errorPrint
<< std::dec << std::setfill(' ') << std::endl;
#else
fsfw::printError("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n",
@ -888,3 +904,7 @@ void LocalDataPoolManager::printWarningOrError(fsfw::OutputTypes outputType,
#endif
}
}
LocalDataPoolManager* LocalDataPoolManager::getHkManagerHandle() {
return this;
}

View File

@ -51,11 +51,11 @@ class HousekeepingPacketUpdate;
* @author R. Mueller
*/
class LocalDataPoolManager: public ProvidesDataPoolSubscriptionIF,
public AccessLocalPoolIF {
template<typename T> friend class LocalPoolVariable;
template<typename T, uint16_t vecSize> friend class LocalPoolVector;
//friend class LocalPoolDataSetBase;
public AccessPoolManagerIF {
friend void (Factory::setStaticFrameworkObjectIds)();
//! Some classes using the pool manager directly need to access class internals of the
//! manager. The attorney provides granular control of access to these internals.
friend class LocalDpManagerAttorney;
public:
static constexpr uint8_t INTERFACE_ID = CLASS_ID::HOUSEKEEPING_MANAGER;
@ -177,7 +177,7 @@ public:
MessageQueueId_t targetQueueId,
bool generateSnapshot) override;
ReturnValue_t retrieveLocalPoolMutex(MutexIF* mutex) override;
MutexIF* getLocalPoolMutex() override;
/**
* Non-Diagnostics packets usually have a lower minimum sampling frequency
@ -263,7 +263,9 @@ public:
*/
void clearReceiversList();
object_id_t getCreatorObjectId() const override;
object_id_t getCreatorObjectId() const;
virtual LocalDataPoolManager* getHkManagerHandle() override;
private:
LocalDataPool localPoolMap;
//! Every housekeeping data manager has a mutex to protect access

View File

@ -0,0 +1,32 @@
#ifndef FSFW_DATAPOOLLOCAL_LOCALDPMANAGERATTORNEY_H_
#define FSFW_DATAPOOLLOCAL_LOCALDPMANAGERATTORNEY_H_
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
/**
* @brief This is a helper class implements the Attorney-Client idiom for access to
* LocalDataPoolManager internals
* @details
* This helper class provides better control over which classes are allowed to access
* LocalDataPoolManager internals in a granular and encapsulated way when compared to
* other methods like direct friend declarations. It allows these classes to use
* an explicit subset of the pool manager private/protected functions.
* See: https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Friendship_and_the_Attorney-Client
*/
class LocalDpManagerAttorney {
private:
template<typename T> static ReturnValue_t fetchPoolEntry(LocalDataPoolManager& manager,
lp_id_t localPoolId, PoolEntry<T> **poolEntry) {
return manager.fetchPoolEntry(localPoolId, poolEntry);
}
static MutexIF* getMutexHandle(LocalDataPoolManager& manager) {
return manager.getMutexHandle();
}
template<typename T> friend class LocalPoolVariable;
template<typename T, uint16_t vecSize> friend class LocalPoolVector;
};
#endif /* FSFW_DATAPOOLLOCAL_LOCALDPMANAGERATTORNEY_H_ */

View File

@ -0,0 +1,40 @@
#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLDATASETATTORNEY_H_
#define FSFW_DATAPOOLLOCAL_LOCALPOOLDATASETATTORNEY_H_
#include <fsfw/datapoollocal/LocalPoolDataSetBase.h>
class LocalPoolDataSetAttorney {
private:
static void setDiagnostic(LocalPoolDataSetBase& set, bool diagnostics) {
set.setDiagnostic(diagnostics);
}
static bool isDiagnostics(LocalPoolDataSetBase& set) {
return set.isDiagnostics();
}
static void initializePeriodicHelper(LocalPoolDataSetBase& set, float collectionInterval,
uint32_t minimumPeriodicIntervalMs,
bool isDiagnostics, uint8_t nonDiagIntervalFactor = 5) {
set.initializePeriodicHelper(collectionInterval, minimumPeriodicIntervalMs, isDiagnostics,
nonDiagIntervalFactor);
}
static void setReportingEnabled(LocalPoolDataSetBase& set, bool enabled) {
set.setReportingEnabled(enabled);
}
static bool getReportingEnabled(LocalPoolDataSetBase& set) {
return set.getReportingEnabled();
}
static PeriodicHousekeepingHelper* getPeriodicHelper(LocalPoolDataSetBase& set) {
return set.periodicHelper;
}
friend class LocalDataPoolManager;
};
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLDATASETATTORNEY_H_ */

View File

@ -1,4 +1,5 @@
#include "LocalPoolDataSetBase.h"
#include "HasLocalDataPoolIFAttorney.h"
#include "../serviceinterface/ServiceInterface.h"
#include "../datapoollocal/LocalDataPoolManager.h"
@ -23,14 +24,14 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner,
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
return;
}
localPoolAccessor = hkOwner->getAccessorHandle();
AccessPoolManagerIF* accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
if(localPoolAccessor != nullptr) {
localPoolAccessor->retrieveLocalPoolMutex(mutexIfSingleDataCreator);
//mutexIfSingleDataCreator = hkManager->getAc();
if(poolManager != nullptr) {
poolManager = accessor->getHkManagerHandle();
mutexIfSingleDataCreator = accessor->getLocalPoolMutex();
}
this->sid.objectId = localPoolAccessor->getCreatorObjectId();
this->sid.objectId = hkOwner->getObjectId();
this->sid.ownerSetId = setId;
// Data creators get a periodic helper for periodic HK data generation.
@ -43,10 +44,10 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid,
PoolVariableIF** registeredVariablesArray,
const size_t maxNumberOfVariables):
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
AccessLocalPoolIF* hkOwner = objectManager->get<AccessLocalPoolIF>(
AccessPoolManagerIF* hkOwner = objectManager->get<AccessPoolManagerIF>(
sid.objectId);
if(hkOwner != nullptr) {
ReturnValue_t result = hkOwner->retrieveLocalPoolMutex(mutexIfSingleDataCreator);
mutexIfSingleDataCreator = hkOwner->getLocalPoolMutex();
}
//if(hkManager != nullptr) {
@ -310,8 +311,8 @@ void LocalPoolDataSetBase::setValidity(bool valid, bool setEntriesRecursively) {
}
object_id_t LocalPoolDataSetBase::getCreatorObjectId() {
if(localPoolAccessor != nullptr) {
return localPoolAccessor->getCreatorObjectId();
if(poolManager != nullptr) {
return poolManager->getCreatorObjectId();
}
return objects::NO_OBJECT;
}

View File

@ -42,7 +42,8 @@ class PeriodicHousekeepingHelper;
*/
class LocalPoolDataSetBase: public PoolDataSetBase,
public MarkChangedIF {
friend class LocalDataPoolManager;
//friend class LocalDataPoolManager;
friend class LocalPoolDataSetAttorney;
friend class PeriodicHousekeepingHelper;
public:
/**
@ -217,7 +218,7 @@ protected:
bool bitGetter(const uint8_t* byte, uint8_t position) const;
PeriodicHousekeepingHelper* periodicHelper = nullptr;
AccessLocalPoolIF* localPoolAccessor = nullptr;
LocalDataPoolManager* poolManager = nullptr;
};

View File

@ -1,4 +1,5 @@
#include "LocalPoolObjectBase.h"
#include "HasLocalDataPoolIFAttorney.h"
LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId, HasLocalDataPoolIF* hkOwner,
DataSetIF* dataSet, pool_rwm_t setReadWriteMode):
@ -16,7 +17,9 @@ LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId, HasLocalDataPoolIF* hkO
#endif
return;
}
hkManager = hkOwner->getHkManagerHandle();
AccessPoolManagerIF* poolManAccessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
hkManager = poolManAccessor->getHkManagerHandle();
//HasLohkOwner->getHkManagerHandle();
if (dataSet != nullptr) {
dataSet->registerVariable(this);
}
@ -41,7 +44,10 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId,
#endif
return;
}
hkManager = hkOwner->getHkManagerHandle();
//hkManager = hkOwner->getHkManagerHandle();
AccessPoolManagerIF* poolManAccessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
//hkManager = HasLocalDpIFUserAttorney::getHkManagerHandle(hkOwner);
hkManager = poolManAccessor->getHkManagerHandle();
if(dataSet != nullptr) {
dataSet->registerVariable(this);
}

View File

@ -1,11 +1,11 @@
#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_
#define FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_
#include <fsfw/datapoollocal/LocalDpManagerAttorney.h>
#include "LocalPoolObjectBase.h"
#include "HasLocalDataPoolIF.h"
#include "LocalDataPoolManager.h"
#include "AccessLocalPoolF.h"
#include "../datapool/PoolVariableIF.h"
#include "../datapool/DataSetIF.h"
#include "../serviceinterface/ServiceInterface.h"

View File

@ -26,7 +26,7 @@ inline LocalPoolVariable<T>::LocalPoolVariable(gp_id_t globalPoolId,
template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::read(
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
MutexHelper(hkManager->getMutexHandle(), timeoutType, timeoutMs);
MutexHelper(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
return readWithoutLock();
}
@ -41,7 +41,9 @@ inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
&poolEntry);
//ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
if(result != RETURN_OK) {
object_id_t ownerObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVariable", result,
@ -73,7 +75,7 @@ inline ReturnValue_t LocalPoolVariable<T>::commit(bool setValid,
template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::commit(
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
MutexHelper(hkManager->getMutexHandle(), timeoutType, timeoutMs);
MutexHelper(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
return commitWithoutLock();
}
@ -88,7 +90,9 @@ inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
//ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
&poolEntry);
if(result != RETURN_OK) {
object_id_t ownerObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVariable", result,

View File

@ -1,6 +1,7 @@
#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLVECTOR_H_
#define FSFW_DATAPOOLLOCAL_LOCALPOOLVECTOR_H_
#include <fsfw/datapoollocal/LocalDpManagerAttorney.h>
#include "LocalPoolObjectBase.h"
#include "../datapool/DataSetIF.h"
#include "../datapool/PoolEntry.h"

View File

@ -26,7 +26,7 @@ inline LocalPoolVector<T, vectorSize>::LocalPoolVector(gp_id_t globalPoolId,
template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
MutexHelper(hkManager->getMutexHandle(), timeoutType, timeoutMs);
MutexHelper(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
return readWithoutLock();
}
template<typename T, uint16_t vectorSize>
@ -40,7 +40,8 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
&poolEntry);
memset(this->value, 0, vectorSize * sizeof(T));
if(result != RETURN_OK) {
@ -64,7 +65,7 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(bool valid,
template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
MutexHelper(hkManager->getMutexHandle(), timeoutType, timeoutMs);
MutexHelper(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
return commitWithoutLock();
}
@ -78,7 +79,8 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() {
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
&poolEntry);
if(result != RETURN_OK) {
object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector", result, false, targetObjectId,

View File

@ -1432,11 +1432,6 @@ ReturnValue_t DeviceHandlerBase::initializeLocalDataPool(
return RETURN_OK;
}
LocalDataPoolManager* DeviceHandlerBase::getHkManagerHandle() {
return &hkManager;
}
ReturnValue_t DeviceHandlerBase::initializeAfterTaskCreation() {
// In this function, the task handle should be valid if the task
// was implemented correctly. We still check to be 1000 % sure :-)
@ -1488,7 +1483,7 @@ void DeviceHandlerBase::setNormalDatapoolEntriesInvalid() {
}
}
AccessLocalPoolIF* DeviceHandlerBase::getAccessorHandle() {
AccessPoolManagerIF* DeviceHandlerBase::getAccessorHandle() {
return &hkManager;
}

View File

@ -519,11 +519,11 @@ protected:
/** Get the HK manager object handle */
LocalDataPoolManager* getHkManagerHandle() override;
//LocalDataPoolManager* getHkManagerHandle() override;
ProvidesDataPoolSubscriptionIF* getSubscriptionInterface() override;
AccessLocalPoolIF* getAccessorHandle() override;
AccessPoolManagerIF* getAccessorHandle() override;
/**
* @brief Hook function for child handlers which is called once per

View File

@ -15,7 +15,7 @@ public:
DeviceHandlerIF::DEFAULT_THERMAL_STATE_POOL_ID,
lp_id_t heaterRequestId =
DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID):
DeviceHandlerThermalSet(hkOwner->getAccessorHandle()->getCreatorObjectId(), setId,
DeviceHandlerThermalSet(hkOwner->getObjectId(), setId,
thermalStateId, heaterRequestId) {}
DeviceHandlerThermalSet(object_id_t deviceHandler, uint32_t setId =

View File

@ -134,7 +134,7 @@ uint32_t InternalErrorReporter::getStoreHits() {
return value;
}
AccessLocalPoolIF* InternalErrorReporter::getAccessorHandle() {
AccessPoolManagerIF* InternalErrorReporter::getAccessorHandle() {
return &poolManager;
}
@ -166,10 +166,6 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool(
return HasReturnvaluesIF::RETURN_OK;
}
LocalDataPoolManager* InternalErrorReporter::getHkManagerHandle() {
return &poolManager;
}
dur_millis_t InternalErrorReporter::getPeriodicOperationFrequency() const {
return this->executingTask->getPeriodMs();
}

View File

@ -43,11 +43,10 @@ public:
virtual ReturnValue_t initializeLocalDataPool(
LocalDataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
virtual LocalDataPoolManager* getHkManagerHandle() override;
virtual dur_millis_t getPeriodicOperationFrequency() const override;
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
ProvidesDataPoolSubscriptionIF* getSubscriptionInterface() override;
AccessLocalPoolIF* getAccessorHandle() override;
AccessPoolManagerIF* getAccessorHandle() override;
virtual ReturnValue_t initialize() override;
virtual ReturnValue_t initializeAfterTaskCreation() override;