introduced new accessor IF

This commit is contained in:
Robin Müller 2021-01-12 00:13:49 +01:00
parent 0109428d47
commit bb10c25909
16 changed files with 85 additions and 38 deletions

View File

@ -106,6 +106,10 @@ 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,6 +33,7 @@ public:
virtual ReturnValue_t initializeAfterTaskCreation() override;
ProvidesDataPoolSubscriptionIF* getSubscriptionInterface() override;
AccessLocalPoolIF* getAccessorHandle() override;
protected:
LocalDataPoolManager localPoolManager;

View File

@ -1,17 +1,31 @@
#ifndef FSFW_DATAPOOLLOCAL_ACCESSLOCALPOOLF_H_
#define FSFW_DATAPOOLLOCAL_ACCESSLOCALPOOLF_H_
#include <fsfw/datapool/PoolEntry.h>
#include <fsfw/datapoollocal/locPoolDefinitions.h>
#include <fsfw/datapool/PoolEntry.h>
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
#include <fsfw/ipc/MutexIF.h>
template <typename T>
class AccessLocalPoolIF {
public:
virtual ~AccessLocalPoolIF() {};
virtual ReturnValue_t fetchPoolEntry(lp_id_t localPoolId, PoolEntry<T> **poolEntry) = 0;
virtual ReturnValue_t retrieveLocalPoolMutex(MutexIF* mutex) = 0;
virtual object_id_t getCreatorObjectId() const = 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

@ -1,6 +1,7 @@
#ifndef FSFW_DATAPOOLLOCAL_HASLOCALDATAPOOLIF_H_
#define FSFW_DATAPOOLLOCAL_HASLOCALDATAPOOLIF_H_
#include "AccessLocalPoolF.h"
#include "ProvidesDataPoolSubscriptionIF.h"
#include "locPoolDefinitions.h"
@ -54,8 +55,6 @@ 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;
@ -124,6 +123,8 @@ public:
* @return
*/
virtual ProvidesDataPoolSubscriptionIF* getSubscriptionInterface() = 0;
virtual AccessLocalPoolIF* getAccessorHandle() = 0;
protected:
/**

View File

@ -410,7 +410,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForSetUpdateMessages(
MessageQueueId_t targetQueueId, bool generateSnapshot) {
struct HkReceiver hkReceiver;
hkReceiver.dataType = DataType::DATA_SET;
hkReceiver.dataId.sid = sid_t(this->getOwner()->getObjectId(), setId);
hkReceiver.dataId.sid = sid_t(this->getCreatorObjectId(), setId);
hkReceiver.destinationQueue = targetQueueId;
hkReceiver.objectId = destinationObject;
if(generateSnapshot) {
@ -822,6 +822,18 @@ 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;
}
object_id_t LocalDataPoolManager::getCreatorObjectId() const {
return owner->getAccessorHandle()->getCreatorObjectId();
}
void LocalDataPoolManager::printWarningOrError(fsfw::OutputTypes outputType,
const char* functionName, ReturnValue_t error, const char* errorPrint) {
if(errorPrint == nullptr) {
@ -857,7 +869,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 << owner->getObjectId() << " | " << errorPrint
<< std::hex << this->getCreatorObjectId() << " | " << errorPrint
<< std::dec << std::setfill(' ') << std::endl;
#else
fsfw::printWarning("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n",
@ -868,7 +880,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 << owner->getObjectId() << " | " << errorPrint
<< std::hex << this->getCreatorObjectId() << " | " << errorPrint
<< std::dec << std::setfill(' ') << std::endl;
#else
fsfw::printError("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n",

View File

@ -50,10 +50,11 @@ class HousekeepingPacketUpdate;
* Each pool entry has a valid state too.
* @author R. Mueller
*/
class LocalDataPoolManager: public ProvidesDataPoolSubscriptionIF {
class LocalDataPoolManager: public ProvidesDataPoolSubscriptionIF,
public AccessLocalPoolIF {
template<typename T> friend class LocalPoolVariable;
template<typename T, uint16_t vecSize> friend class LocalPoolVector;
friend class LocalPoolDataSetBase;
//friend class LocalPoolDataSetBase;
friend void (Factory::setStaticFrameworkObjectIds)();
public:
static constexpr uint8_t INTERFACE_ID = CLASS_ID::HOUSEKEEPING_MANAGER;
@ -176,6 +177,8 @@ public:
MessageQueueId_t targetQueueId,
bool generateSnapshot) override;
ReturnValue_t retrieveLocalPoolMutex(MutexIF* mutex) override;
/**
* Non-Diagnostics packets usually have a lower minimum sampling frequency
* than diagnostic packets.
@ -259,6 +262,8 @@ public:
* the insertion operations allocate dynamically.
*/
void clearReceiversList();
object_id_t getCreatorObjectId() const override;
private:
LocalDataPool localPoolMap;
//! Every housekeeping data manager has a mutex to protect access

View File

@ -23,13 +23,14 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner,
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
return;
}
hkManager = hkOwner->getHkManagerHandle();
localPoolAccessor = hkOwner->getAccessorHandle();
if(hkManager != nullptr) {
mutexIfSingleDataCreator = hkManager->getMutexHandle();
if(localPoolAccessor != nullptr) {
localPoolAccessor->retrieveLocalPoolMutex(mutexIfSingleDataCreator);
//mutexIfSingleDataCreator = hkManager->getAc();
}
this->sid.objectId = hkOwner->getObjectId();
this->sid.objectId = localPoolAccessor->getCreatorObjectId();
this->sid.ownerSetId = setId;
// Data creators get a periodic helper for periodic HK data generation.
@ -42,15 +43,15 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid,
PoolVariableIF** registeredVariablesArray,
const size_t maxNumberOfVariables):
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
HasLocalDataPoolIF* hkOwner = objectManager->get<HasLocalDataPoolIF>(
AccessLocalPoolIF* hkOwner = objectManager->get<AccessLocalPoolIF>(
sid.objectId);
if(hkOwner != nullptr) {
hkManager = hkOwner->getHkManagerHandle();
ReturnValue_t result = hkOwner->retrieveLocalPoolMutex(mutexIfSingleDataCreator);
}
if(hkManager != nullptr) {
mutexIfSingleDataCreator = hkManager->getMutexHandle();
}
//if(hkManager != nullptr) {
// mutexIfSingleDataCreator = hkManager->getMutexHandle();
//}
this->sid = sid;
}
@ -308,12 +309,9 @@ void LocalPoolDataSetBase::setValidity(bool valid, bool setEntriesRecursively) {
this->valid = valid;
}
object_id_t LocalPoolDataSetBase::getCreatorObjectId(object_id_t objectId) {
if(hkManager != nullptr) {
HasLocalDataPoolIF* owner = hkManager->getOwner();
if(owner != nullptr) {
return owner->getObjectId();
}
object_id_t LocalPoolDataSetBase::getCreatorObjectId() {
if(localPoolAccessor != nullptr) {
return localPoolAccessor->getCreatorObjectId();
}
return objects::NO_OBJECT;
}

View File

@ -150,7 +150,7 @@ public:
void setChanged(bool changed) override;
bool hasChanged() const override;
object_id_t getCreatorObjectId(object_id_t objectId);
object_id_t getCreatorObjectId();
protected:
sid_t sid;
//! This mutex is used if the data is created by one object only.
@ -217,7 +217,7 @@ protected:
bool bitGetter(const uint8_t* byte, uint8_t position) const;
PeriodicHousekeepingHelper* periodicHelper = nullptr;
LocalDataPoolManager* hkManager = nullptr;
AccessLocalPoolIF* localPoolAccessor = nullptr;
};

View File

@ -24,7 +24,7 @@
* @ingroup data_pool
*/
template<typename T>
class LocalPoolVariable: public LocalPoolObjectBase, public AccessLocalPoolIF<T> {
class LocalPoolVariable: public LocalPoolObjectBase {
public:
//! Default ctor is forbidden.
LocalPoolVariable() = delete;

View File

@ -33,7 +33,7 @@ inline ReturnValue_t LocalPoolVariable<T>::read(
template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
if(readWriteMode == pool_rwm_t::VAR_WRITE) {
object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector",
PoolVariableIF::INVALID_READ_WRITE_MODE, true, targetObjectId,
localPoolId);
@ -43,7 +43,7 @@ inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
if(result != RETURN_OK) {
object_id_t ownerObjectId = hkManager->getOwner()->getObjectId();
object_id_t ownerObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVariable", result,
false, ownerObjectId, localPoolId);
return result;
@ -80,7 +80,7 @@ inline ReturnValue_t LocalPoolVariable<T>::commit(
template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
if(readWriteMode == pool_rwm_t::VAR_READ) {
object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector",
PoolVariableIF::INVALID_READ_WRITE_MODE, false, targetObjectId,
localPoolId);
@ -90,7 +90,7 @@ inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
if(result != RETURN_OK) {
object_id_t ownerObjectId = hkManager->getOwner()->getObjectId();
object_id_t ownerObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVariable", result,
false, ownerObjectId, localPoolId);
return result;

View File

@ -32,7 +32,7 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(
template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
if(readWriteMode == pool_rwm_t::VAR_WRITE) {
object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector",
PoolVariableIF::INVALID_READ_WRITE_MODE, true, targetObjectId,
localPoolId);
@ -44,7 +44,7 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
memset(this->value, 0, vectorSize * sizeof(T));
if(result != RETURN_OK) {
object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector", result, true, targetObjectId,
localPoolId);
return result;
@ -71,7 +71,7 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(
template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() {
if(readWriteMode == pool_rwm_t::VAR_READ) {
object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector",
PoolVariableIF::INVALID_READ_WRITE_MODE, false, targetObjectId,
localPoolId);
@ -80,7 +80,7 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() {
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
if(result != RETURN_OK) {
object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
object_id_t targetObjectId = hkManager->getCreatorObjectId();
reportReadCommitError("LocalPoolVector", result, false, targetObjectId,
localPoolId);
return result;

View File

@ -1488,6 +1488,10 @@ void DeviceHandlerBase::setNormalDatapoolEntriesInvalid() {
}
}
AccessLocalPoolIF* DeviceHandlerBase::getAccessorHandle() {
return &hkManager;
}
void DeviceHandlerBase::printWarningOrError(fsfw::OutputTypes errorType,
const char *functionName, ReturnValue_t errorCode,
const char *errorPrint) {

View File

@ -517,11 +517,14 @@ protected:
virtual ReturnValue_t initializeLocalDataPool(LocalDataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
/** Get the HK manager object handle */
LocalDataPoolManager* getHkManagerHandle() override;
ProvidesDataPoolSubscriptionIF* getSubscriptionInterface() override;
AccessLocalPoolIF* getAccessorHandle() override;
/**
* @brief Hook function for child handlers which is called once per
* performOperation(). Default implementation is empty.

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->getObjectId(), setId,
DeviceHandlerThermalSet(hkOwner->getAccessorHandle()->getCreatorObjectId(), setId,
thermalStateId, heaterRequestId) {}
DeviceHandlerThermalSet(object_id_t deviceHandler, uint32_t setId =

View File

@ -134,6 +134,10 @@ uint32_t InternalErrorReporter::getStoreHits() {
return value;
}
AccessLocalPoolIF* InternalErrorReporter::getAccessorHandle() {
return &poolManager;
}
void InternalErrorReporter::incrementStoreHits() {
mutex->lockMutex(timeoutType, timeoutMs);
storeHits++;

View File

@ -47,6 +47,7 @@ public:
virtual dur_millis_t getPeriodicOperationFrequency() const override;
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
ProvidesDataPoolSubscriptionIF* getSubscriptionInterface() override;
AccessLocalPoolIF* getAccessorHandle() override;
virtual ReturnValue_t initialize() override;
virtual ReturnValue_t initializeAfterTaskCreation() override;