improved documentation signigicantly
This commit is contained in:
parent
d0b218c18e
commit
fe5b50d885
@ -1,12 +1,12 @@
|
|||||||
#ifndef POOLVARIABLEIF_H_
|
#ifndef FRAMEWORK_DATAPOOL_POOLVARIABLEIF_H_
|
||||||
#define POOLVARIABLEIF_H_
|
#define FRAMEWORK_DATAPOOL_POOLVARIABLEIF_H_
|
||||||
|
|
||||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||||
#include <framework/serialize/SerializeIF.h>
|
#include <framework/serialize/SerializeIF.h>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This interface is used to control data pool variable representations.
|
* @brief This interface is used to control data pool
|
||||||
|
* variable representations.
|
||||||
* @details
|
* @details
|
||||||
* To securely handle data pool variables, all pool entries are locally
|
* To securely handle data pool variables, all pool entries are locally
|
||||||
* managed by data pool variable access classes, which are called pool
|
* managed by data pool variable access classes, which are called pool
|
||||||
@ -39,7 +39,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual ~PoolVariableIF() {}
|
virtual ~PoolVariableIF() {}
|
||||||
/**
|
/**
|
||||||
* @brief This method returns if the variable is write-only, read-write or read-only.
|
* @brief This method returns if the variable is write-only,
|
||||||
|
* read-write or read-only.
|
||||||
*/
|
*/
|
||||||
virtual ReadWriteMode_t getReadWriteMode() const = 0;
|
virtual ReadWriteMode_t getReadWriteMode() const = 0;
|
||||||
/**
|
/**
|
||||||
@ -47,7 +48,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual uint32_t getDataPoolId() const = 0;
|
virtual uint32_t getDataPoolId() const = 0;
|
||||||
/**
|
/**
|
||||||
* @brief With this call, the valid information of the variable is returned.
|
* @brief With this call, the valid information of the
|
||||||
|
* variable is returned.
|
||||||
*/
|
*/
|
||||||
virtual bool isValid() const = 0;
|
virtual bool isValid() const = 0;
|
||||||
/**
|
/**
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
|
#include <framework/datapoollocal/LocalDataPoolManager.h>
|
||||||
#include <framework/datapoollocal/LocalDataSet.h>
|
#include <framework/datapoollocal/LocalDataSet.h>
|
||||||
#include <framework/housekeeping/HousekeepingManager.h>
|
|
||||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||||
#include <framework/ipc/MutexFactory.h>
|
#include <framework/ipc/MutexFactory.h>
|
||||||
#include <framework/ipc/MutexHelper.h>
|
#include <framework/ipc/MutexHelper.h>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
HousekeepingManager::HousekeepingManager(HasHkPoolParametersIF* owner) {
|
LocalDataPoolManager::LocalDataPoolManager(OwnsLocalDataPoolIF* owner) {
|
||||||
if(owner == nullptr) {
|
if(owner == nullptr) {
|
||||||
sif::error << "HkManager: Invalid supplied owner!" << std::endl;
|
sif::error << "HkManager: Invalid supplied owner!" << std::endl;
|
||||||
std::exit(0);
|
std::exit(0);
|
||||||
@ -16,11 +16,12 @@ HousekeepingManager::HousekeepingManager(HasHkPoolParametersIF* owner) {
|
|||||||
//owner->setMinimalHkSamplingFrequency();
|
//owner->setMinimalHkSamplingFrequency();
|
||||||
}
|
}
|
||||||
|
|
||||||
HousekeepingManager::~HousekeepingManager() {}
|
LocalDataPoolManager::~LocalDataPoolManager() {}
|
||||||
|
|
||||||
ReturnValue_t HousekeepingManager::initializeHousekeepingPoolEntriesOnce() {
|
ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() {
|
||||||
if(not mapInitialized) {
|
if(not mapInitialized) {
|
||||||
ReturnValue_t result = owner->initializeHousekeepingPoolEntries(localDpMap);
|
ReturnValue_t result =
|
||||||
|
owner->initializeHousekeepingPoolEntries(localDpMap);
|
||||||
if(result == HasReturnvaluesIF::RETURN_OK) {
|
if(result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
mapInitialized = true;
|
mapInitialized = true;
|
||||||
}
|
}
|
||||||
@ -30,24 +31,24 @@ ReturnValue_t HousekeepingManager::initializeHousekeepingPoolEntriesOnce() {
|
|||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t HousekeepingManager::handleHousekeepingMessage(
|
ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
|
||||||
CommandMessage *message) {
|
CommandMessage *message) {
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t HousekeepingManager::printPoolEntry(
|
ReturnValue_t LocalDataPoolManager::printPoolEntry(
|
||||||
lp_id_t localPoolId) {
|
lp_id_t localPoolId) {
|
||||||
auto poolIter = localDpMap.find(localPoolId);
|
auto poolIter = localDpMap.find(localPoolId);
|
||||||
if (poolIter == localDpMap.end()) {
|
if (poolIter == localDpMap.end()) {
|
||||||
sif::debug << "HousekeepingManager::fechPoolEntry:"
|
sif::debug << "HousekeepingManager::fechPoolEntry:"
|
||||||
" Pool entry not found." << std::endl;
|
" Pool entry not found." << std::endl;
|
||||||
return HasHkPoolParametersIF::POOL_ENTRY_NOT_FOUND;
|
return OwnsLocalDataPoolIF::POOL_ENTRY_NOT_FOUND;
|
||||||
}
|
}
|
||||||
poolIter->second->print();
|
poolIter->second->print();
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
MutexIF* HousekeepingManager::getMutexHandle() {
|
MutexIF* LocalDataPoolManager::getMutexHandle() {
|
||||||
return mutex;
|
return mutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ MutexIF* HousekeepingManager::getMutexHandle() {
|
|||||||
//
|
//
|
||||||
//}
|
//}
|
||||||
|
|
||||||
void HousekeepingManager::generateHousekeepingPacket(sid_t sid) {
|
void LocalDataPoolManager::generateHousekeepingPacket(sid_t sid) {
|
||||||
LocalDataSet* dataSetToSerialize = dynamic_cast<LocalDataSet*>(
|
LocalDataSet* dataSetToSerialize = dynamic_cast<LocalDataSet*>(
|
||||||
owner->getDataSetHandle(sid));
|
owner->getDataSetHandle(sid));
|
||||||
if(dataSetToSerialize == nullptr) {
|
if(dataSetToSerialize == nullptr) {
|
||||||
@ -73,10 +74,10 @@ void HousekeepingManager::generateHousekeepingPacket(sid_t sid) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HousekeepingManager::setHkPacketQueue(MessageQueueIF *msgQueue) {
|
void LocalDataPoolManager::setHkPacketQueue(MessageQueueIF *msgQueue) {
|
||||||
this->hkPacketQueue = msgQueue;
|
this->hkPacketQueue = msgQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const HasHkPoolParametersIF* HousekeepingManager::getOwner() const {
|
const OwnsLocalDataPoolIF* LocalDataPoolManager::getOwner() const {
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
@ -2,19 +2,35 @@
|
|||||||
#define FRAMEWORK_HK_HOUSEKEEPINGHELPER_H_
|
#define FRAMEWORK_HK_HOUSEKEEPINGHELPER_H_
|
||||||
#include <framework/datapool/DataSetIF.h>
|
#include <framework/datapool/DataSetIF.h>
|
||||||
#include <framework/objectmanager/SystemObjectIF.h>
|
#include <framework/objectmanager/SystemObjectIF.h>
|
||||||
#include <framework/housekeeping/HasHkPoolParametersIF.h>
|
|
||||||
#include <framework/ipc/MutexIF.h>
|
#include <framework/ipc/MutexIF.h>
|
||||||
|
|
||||||
#include <framework/housekeeping/HousekeepingMessage.h>
|
#include <framework/housekeeping/HousekeepingMessage.h>
|
||||||
#include <framework/datapool/PoolEntry.h>
|
#include <framework/datapool/PoolEntry.h>
|
||||||
|
#include <framework/datapoollocal/OwnsLocalDataPoolIF.h>
|
||||||
#include <framework/ipc/CommandMessage.h>
|
#include <framework/ipc/CommandMessage.h>
|
||||||
#include <framework/ipc/MessageQueueIF.h>
|
#include <framework/ipc/MessageQueueIF.h>
|
||||||
#include <framework/ipc/MutexHelper.h>
|
#include <framework/ipc/MutexHelper.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
/**
|
||||||
class HousekeepingManager {
|
* @brief This class is the managing instance for local data pool.
|
||||||
|
* @details
|
||||||
|
* The actual data pool structure is a member of this class. Any class which
|
||||||
|
* has a local data pool shall have this class as a member and implement
|
||||||
|
* the OwnsLocalDataPoolIF.
|
||||||
|
*
|
||||||
|
* Users of the data pool use the helper classes LocalDataSet,
|
||||||
|
* LocalPoolVariable and LocalPoolVector to access pool entries in
|
||||||
|
* a thread-safe and efficient way.
|
||||||
|
*
|
||||||
|
* The local data pools employ a blackboard logic: Only the most recent
|
||||||
|
* value is stored. The helper classes offer a read() and commit() interface
|
||||||
|
* through the PoolVariableIF which is used to read and update values.
|
||||||
|
* Each pool entry has a valid state too.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class LocalDataPoolManager {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
friend class LocalPoolVar;
|
friend class LocalPoolVar;
|
||||||
template<typename T, uint16_t vecSize>
|
template<typename T, uint16_t vecSize>
|
||||||
@ -23,8 +39,8 @@ class HousekeepingManager {
|
|||||||
public:
|
public:
|
||||||
static constexpr float MINIMAL_SAMPLING_FREQUENCY = 0.2;
|
static constexpr float MINIMAL_SAMPLING_FREQUENCY = 0.2;
|
||||||
|
|
||||||
HousekeepingManager(HasHkPoolParametersIF* owner);
|
LocalDataPoolManager(OwnsLocalDataPoolIF* owner);
|
||||||
virtual~ HousekeepingManager();
|
virtual~ LocalDataPoolManager();
|
||||||
|
|
||||||
|
|
||||||
// propably will just call respective local data set functions.
|
// propably will just call respective local data set functions.
|
||||||
@ -40,7 +56,7 @@ public:
|
|||||||
ReturnValue_t initializeHousekeepingPoolEntriesOnce();
|
ReturnValue_t initializeHousekeepingPoolEntriesOnce();
|
||||||
|
|
||||||
void setHkPacketQueue(MessageQueueIF* msgQueue);
|
void setHkPacketQueue(MessageQueueIF* msgQueue);
|
||||||
const HasHkPoolParametersIF* getOwner() const;
|
const OwnsLocalDataPoolIF* getOwner() const;
|
||||||
|
|
||||||
ReturnValue_t printPoolEntry(lp_id_t localPoolId);
|
ReturnValue_t printPoolEntry(lp_id_t localPoolId);
|
||||||
|
|
||||||
@ -48,14 +64,14 @@ private:
|
|||||||
//! This is the map holding the actual data. Should only be initialized
|
//! This is the map holding the actual data. Should only be initialized
|
||||||
//! once !
|
//! once !
|
||||||
bool mapInitialized = false;
|
bool mapInitialized = false;
|
||||||
LocalDataPoolMap localDpMap;
|
LocalDataPool localDpMap;
|
||||||
|
|
||||||
//! Every housekeeping data manager has a mutex to protect access
|
//! Every housekeeping data manager has a mutex to protect access
|
||||||
//! to it's data pool.
|
//! to it's data pool.
|
||||||
MutexIF * mutex = nullptr;
|
MutexIF * mutex = nullptr;
|
||||||
|
|
||||||
//! The class which actually owns the manager (and its datapool).
|
//! The class which actually owns the manager (and its datapool).
|
||||||
HasHkPoolParametersIF* owner = nullptr;
|
OwnsLocalDataPoolIF* owner = nullptr;
|
||||||
|
|
||||||
//! Used for replies.
|
//! Used for replies.
|
||||||
//! (maybe we dont need this, the sender can be retrieved from command
|
//! (maybe we dont need this, the sender can be retrieved from command
|
||||||
@ -85,27 +101,28 @@ private:
|
|||||||
* supplied pointer.
|
* supplied pointer.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
template <class T>
|
template <class T> ReturnValue_t fetchPoolEntry(lp_id_t localPoolId,
|
||||||
ReturnValue_t fetchPoolEntry(lp_id_t localPoolId, PoolEntry<T> **poolEntry);
|
PoolEntry<T> **poolEntry);
|
||||||
void setMinimalSamplingFrequency(float frequencySeconds);
|
|
||||||
|
|
||||||
|
void setMinimalSamplingFrequency(float frequencySeconds);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template<class T> inline
|
template<class T> inline
|
||||||
ReturnValue_t HousekeepingManager::fetchPoolEntry(lp_id_t localPoolId,
|
ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId,
|
||||||
PoolEntry<T> **poolEntry) {
|
PoolEntry<T> **poolEntry) {
|
||||||
auto poolIter = localDpMap.find(localPoolId);
|
auto poolIter = localDpMap.find(localPoolId);
|
||||||
if (poolIter == localDpMap.end()) {
|
if (poolIter == localDpMap.end()) {
|
||||||
sif::debug << "HousekeepingManager::fechPoolEntry:"
|
sif::debug << "HousekeepingManager::fechPoolEntry:"
|
||||||
" Pool entry not found." << std::endl;
|
" Pool entry not found." << std::endl;
|
||||||
return HasHkPoolParametersIF::POOL_ENTRY_NOT_FOUND;
|
return OwnsLocalDataPoolIF::POOL_ENTRY_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
*poolEntry = dynamic_cast< PoolEntry<T>* >(poolIter->second);
|
*poolEntry = dynamic_cast< PoolEntry<T>* >(poolIter->second);
|
||||||
if(*poolEntry == nullptr) {
|
if(*poolEntry == nullptr) {
|
||||||
sif::debug << "HousekeepingManager::fetchPoolEntry:"
|
sif::debug << "HousekeepingManager::fetchPoolEntry:"
|
||||||
" Pool entry not found." << std::endl;
|
" Pool entry not found." << std::endl;
|
||||||
return HasHkPoolParametersIF::POOL_ENTRY_TYPE_CONFLICT;
|
return OwnsLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT;
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
|
#include <framework/datapoollocal/LocalDataPoolManager.h>
|
||||||
#include <framework/datapoollocal/LocalDataSet.h>
|
#include <framework/datapoollocal/LocalDataSet.h>
|
||||||
#include <framework/housekeeping/HousekeepingManager.h>
|
|
||||||
|
|
||||||
LocalDataSet::LocalDataSet(HasHkPoolParametersIF *hkOwner): DataSetBase() {
|
LocalDataSet::LocalDataSet(OwnsLocalDataPoolIF *hkOwner): DataSetBase() {
|
||||||
if(hkOwner != nullptr) {
|
if(hkOwner != nullptr) {
|
||||||
hkManager = hkOwner->getHkManagerHandle();
|
hkManager = hkOwner->getHkManagerHandle();
|
||||||
}
|
}
|
||||||
@ -11,7 +11,7 @@ LocalDataSet::LocalDataSet(HasHkPoolParametersIF *hkOwner): DataSetBase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LocalDataSet::LocalDataSet(object_id_t ownerId): DataSetBase() {
|
LocalDataSet::LocalDataSet(object_id_t ownerId): DataSetBase() {
|
||||||
HasHkPoolParametersIF* hkOwner = objectManager->get<HasHkPoolParametersIF>(
|
OwnsLocalDataPoolIF* hkOwner = objectManager->get<OwnsLocalDataPoolIF>(
|
||||||
ownerId);
|
ownerId);
|
||||||
if(hkOwner == nullptr) {
|
if(hkOwner == nullptr) {
|
||||||
// config error, error output here.
|
// config error, error output here.
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
#define FRAMEWORK_DATAPOOLLOCAL_LOCALDATASET_H_
|
#define FRAMEWORK_DATAPOOLLOCAL_LOCALDATASET_H_
|
||||||
#include <framework/datapool/DataSetBase.h>
|
#include <framework/datapool/DataSetBase.h>
|
||||||
#include <framework/datapool/DataSetIF.h>
|
#include <framework/datapool/DataSetIF.h>
|
||||||
#include <framework/housekeeping/HasHkPoolParametersIF.h>
|
#include <framework/datapoollocal/OwnsLocalDataPoolIF.h>
|
||||||
#include <framework/serialize/SerializeIF.h>
|
#include <framework/serialize/SerializeIF.h>
|
||||||
|
|
||||||
class HousekeepingManager;
|
class LocalDataPoolManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The LocalDataSet class manages a set of locally checked out variables
|
* @brief The LocalDataSet class manages a set of locally checked out variables
|
||||||
@ -35,7 +35,7 @@ public:
|
|||||||
* The constructor simply sets the fill_count to zero and sets
|
* The constructor simply sets the fill_count to zero and sets
|
||||||
* the state to "uninitialized".
|
* the state to "uninitialized".
|
||||||
*/
|
*/
|
||||||
LocalDataSet(HasHkPoolParametersIF* hkOwner);
|
LocalDataSet(OwnsLocalDataPoolIF* hkOwner);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Constructor for users of local pool data. The passed pool
|
* @brief Constructor for users of local pool data. The passed pool
|
||||||
@ -78,7 +78,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
ReturnValue_t unlockDataPool() override;
|
ReturnValue_t unlockDataPool() override;
|
||||||
|
|
||||||
HousekeepingManager* hkManager;
|
LocalDataPoolManager* hkManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FRAMEWORK_DATAPOOLLOCAL_LOCALDATASET_H_ */
|
#endif /* FRAMEWORK_DATAPOOLLOCAL_LOCALDATASET_H_ */
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
#include <framework/datapool/PoolVariableIF.h>
|
#include <framework/datapool/PoolVariableIF.h>
|
||||||
#include <framework/datapool/DataSetIF.h>
|
#include <framework/datapool/DataSetIF.h>
|
||||||
#include <framework/housekeeping/HasHkPoolParametersIF.h>
|
#include <framework/datapoollocal/LocalDataPoolManager.h>
|
||||||
|
#include <framework/datapoollocal/OwnsLocalDataPoolIF.h>
|
||||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||||
|
|
||||||
#include <framework/serialize/SerializeAdapter.h>
|
#include <framework/serialize/SerializeAdapter.h>
|
||||||
#include <framework/housekeeping/HousekeepingManager.h>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Local Pool Variable class which is used to access the local pools.
|
* @brief Local Pool Variable class which is used to access the local pools.
|
||||||
@ -29,9 +29,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
* This constructor is used by the data creators to have pool variable
|
* This constructor is used by the data creators to have pool variable
|
||||||
* instances which can also be stored in datasets.
|
* instances which can also be stored in datasets.
|
||||||
* It does not fetch the current value from the data pool. This is performed
|
*
|
||||||
* by the read() operation (which is not thread-safe).
|
* It does not fetch the current value from the data pool, which
|
||||||
* Datasets can be used to access local pool entires in a thread-safe way.
|
* has to be done by calling the read() operation.
|
||||||
|
* Datasets can be used to access multiple local pool entries in an
|
||||||
|
* efficient way. A pointer to a dataset can be passed to register
|
||||||
|
* the pool variable in that dataset directly.
|
||||||
* @param poolId ID of the local pool entry.
|
* @param poolId ID of the local pool entry.
|
||||||
* @param hkOwner Pointer of the owner. This will generally be the calling
|
* @param hkOwner Pointer of the owner. This will generally be the calling
|
||||||
* class itself which passes "this".
|
* class itself which passes "this".
|
||||||
@ -39,7 +42,7 @@ public:
|
|||||||
* @param dataSet The data set in which the variable shall register itself.
|
* @param dataSet The data set in which the variable shall register itself.
|
||||||
* If nullptr, the variable is not registered.
|
* If nullptr, the variable is not registered.
|
||||||
*/
|
*/
|
||||||
LocalPoolVar(lp_id_t poolId, HasHkPoolParametersIF* hkOwner,
|
LocalPoolVar(lp_id_t poolId, OwnsLocalDataPoolIF* hkOwner,
|
||||||
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE,
|
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE,
|
||||||
DataSetIF* dataSet = nullptr);
|
DataSetIF* dataSet = nullptr);
|
||||||
|
|
||||||
@ -47,12 +50,14 @@ public:
|
|||||||
* This constructor is used by data users like controllers to have
|
* This constructor is used by data users like controllers to have
|
||||||
* access to the local pool variables of data creators by supplying
|
* access to the local pool variables of data creators by supplying
|
||||||
* the respective creator object ID.
|
* the respective creator object ID.
|
||||||
* It does not fetch the current value from the data pool. This is performed
|
*
|
||||||
* by the read() operation (which is not thread-safe).
|
* It does not fetch the current value from the data pool, which
|
||||||
* Datasets can be used to access local pool entires in a thread-safe way.
|
* has to be done by calling the read() operation.
|
||||||
|
* Datasets can be used to access multiple local pool entries in an
|
||||||
|
* efficient way. A pointer to a dataset can be passed to register
|
||||||
|
* the pool variable in that dataset directly.
|
||||||
* @param poolId ID of the local pool entry.
|
* @param poolId ID of the local pool entry.
|
||||||
* @param hkOwner Pointer of the owner. This will generally be the calling
|
* @param hkOwner object ID of the pool owner.
|
||||||
* class itself which passes "this".
|
|
||||||
* @param setReadWriteMode Specify the read-write mode of the pool variable.
|
* @param setReadWriteMode Specify the read-write mode of the pool variable.
|
||||||
* @param dataSet The data set in which the variable shall register itself.
|
* @param dataSet The data set in which the variable shall register itself.
|
||||||
* If nullptr, the variable is not registered.
|
* If nullptr, the variable is not registered.
|
||||||
@ -99,7 +104,7 @@ public:
|
|||||||
* at once to avoid the overhead of unnecessary lock und unlock operations.
|
* at once to avoid the overhead of unnecessary lock und unlock operations.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
ReturnValue_t read(uint32_t lockTimeout = MutexIF::BLOCKING) override;
|
ReturnValue_t read(dur_millis_t lockTimeout = MutexIF::BLOCKING) override;
|
||||||
/**
|
/**
|
||||||
* @brief The commit call copies the array values back to the data pool.
|
* @brief The commit call copies the array values back to the data pool.
|
||||||
* @details
|
* @details
|
||||||
@ -109,7 +114,8 @@ public:
|
|||||||
* It is recommended to use DataSets to read and commit multiple variables
|
* It is recommended to use DataSets to read and commit multiple variables
|
||||||
* at once to avoid the overhead of unnecessary lock und unlock operations.
|
* at once to avoid the overhead of unnecessary lock und unlock operations.
|
||||||
*/
|
*/
|
||||||
ReturnValue_t commit(uint32_t lockTimeout = MutexIF::BLOCKING) override;
|
ReturnValue_t commit(dur_millis_t lockTimeout = MutexIF::BLOCKING) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief Like #read, but without a lock protection of the global pool.
|
* @brief Like #read, but without a lock protection of the global pool.
|
||||||
@ -144,7 +150,7 @@ private:
|
|||||||
bool valid = false;
|
bool valid = false;
|
||||||
|
|
||||||
//! Pointer to the class which manages the HK pool.
|
//! Pointer to the class which manages the HK pool.
|
||||||
HousekeepingManager* hkManager;
|
LocalDataPoolManager* hkManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <framework/datapoollocal/LocalPoolVariable.tpp>
|
#include <framework/datapoollocal/LocalPoolVariable.tpp>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline LocalPoolVar<T>::LocalPoolVar(lp_id_t poolId,
|
inline LocalPoolVar<T>::LocalPoolVar(lp_id_t poolId,
|
||||||
HasHkPoolParametersIF* hkOwner, pool_rwm_t setReadWriteMode,
|
OwnsLocalDataPoolIF* hkOwner, pool_rwm_t setReadWriteMode,
|
||||||
DataSetIF* dataSet):
|
DataSetIF* dataSet):
|
||||||
localPoolId(poolId),readWriteMode(setReadWriteMode) {
|
localPoolId(poolId),readWriteMode(setReadWriteMode) {
|
||||||
if(poolId == PoolVariableIF::NO_PARAMETER) {
|
if(poolId == PoolVariableIF::NO_PARAMETER) {
|
||||||
@ -33,8 +33,8 @@ inline LocalPoolVar<T>::LocalPoolVar(lp_id_t poolId, object_id_t poolOwner,
|
|||||||
sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the "
|
sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the "
|
||||||
"NO_PARAMETER value!" << std::endl;
|
"NO_PARAMETER value!" << std::endl;
|
||||||
}
|
}
|
||||||
HasHkPoolParametersIF* hkOwner =
|
OwnsLocalDataPoolIF* hkOwner =
|
||||||
objectManager->get<HasHkPoolParametersIF>(poolOwner);
|
objectManager->get<OwnsLocalDataPoolIF>(poolOwner);
|
||||||
if(hkOwner == nullptr) {
|
if(hkOwner == nullptr) {
|
||||||
sif::error << "LocalPoolVariable: The supplied pool owner did not implement"
|
sif::error << "LocalPoolVariable: The supplied pool owner did not implement"
|
||||||
"the correct interface HasHkPoolParametersIF!" << std::endl;
|
"the correct interface HasHkPoolParametersIF!" << std::endl;
|
||||||
@ -47,7 +47,7 @@ inline LocalPoolVar<T>::LocalPoolVar(lp_id_t poolId, object_id_t poolOwner,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline ReturnValue_t LocalPoolVar<T>::read(millis_t lockTimeout) {
|
inline ReturnValue_t LocalPoolVar<T>::read(dur_millis_t lockTimeout) {
|
||||||
MutexHelper(hkManager->getMutexHandle(), lockTimeout);
|
MutexHelper(hkManager->getMutexHandle(), lockTimeout);
|
||||||
return readWithoutLock();
|
return readWithoutLock();
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ inline ReturnValue_t LocalPoolVar<T>::readWithoutLock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline ReturnValue_t LocalPoolVar<T>::commit(millis_t lockTimeout) {
|
inline ReturnValue_t LocalPoolVar<T>::commit(dur_millis_t lockTimeout) {
|
||||||
MutexHelper(hkManager->getMutexHandle(), lockTimeout);
|
MutexHelper(hkManager->getMutexHandle(), lockTimeout);
|
||||||
return commitWithoutLock();
|
return commitWithoutLock();
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
#include <framework/datapool/DataSetIF.h>
|
#include <framework/datapool/DataSetIF.h>
|
||||||
#include <framework/datapool/PoolEntry.h>
|
#include <framework/datapool/PoolEntry.h>
|
||||||
#include <framework/datapool/PoolVariableIF.h>
|
#include <framework/datapool/PoolVariableIF.h>
|
||||||
|
#include <framework/datapoollocal/LocalDataPoolManager.h>
|
||||||
#include <framework/serialize/SerializeAdapter.h>
|
#include <framework/serialize/SerializeAdapter.h>
|
||||||
#include <framework/housekeeping/HousekeepingManager.h>
|
|
||||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||||
|
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ public:
|
|||||||
* @param dataSet The data set in which the variable shall register itself.
|
* @param dataSet The data set in which the variable shall register itself.
|
||||||
* If nullptr, the variable is not registered.
|
* If nullptr, the variable is not registered.
|
||||||
*/
|
*/
|
||||||
LocalPoolVector(lp_id_t poolId, HasHkPoolParametersIF* hkOwner,
|
LocalPoolVector(lp_id_t poolId, OwnsLocalDataPoolIF* hkOwner,
|
||||||
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE,
|
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE,
|
||||||
DataSetIF* dataSet = nullptr);
|
DataSetIF* dataSet = nullptr);
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
ReadWriteMode_t readWriteMode;
|
ReadWriteMode_t readWriteMode;
|
||||||
//! @brief Pointer to the class which manages the HK pool.
|
//! @brief Pointer to the class which manages the HK pool.
|
||||||
HousekeepingManager* hkManager;
|
LocalDataPoolManager* hkManager;
|
||||||
|
|
||||||
// std::ostream is the type for object std::cout
|
// std::ostream is the type for object std::cout
|
||||||
template <typename U, uint16_t otherSize>
|
template <typename U, uint16_t otherSize>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(lp_id_t poolId,
|
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(lp_id_t poolId,
|
||||||
HasHkPoolParametersIF* hkOwner, pool_rwm_t setReadWriteMode,
|
OwnsLocalDataPoolIF* hkOwner, pool_rwm_t setReadWriteMode,
|
||||||
DataSetIF* dataSet) :
|
DataSetIF* dataSet) :
|
||||||
localPoolId(poolId), valid(false), readWriteMode(setReadWriteMode) {
|
localPoolId(poolId), valid(false), readWriteMode(setReadWriteMode) {
|
||||||
if(poolId == PoolVariableIF::NO_PARAMETER) {
|
if(poolId == PoolVariableIF::NO_PARAMETER) {
|
||||||
@ -29,8 +29,8 @@ inline LocalPoolVector<T, vectorSize>::LocalPoolVector(lp_id_t poolId,
|
|||||||
sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the "
|
sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the "
|
||||||
"NO_PARAMETER value!" << std::endl;
|
"NO_PARAMETER value!" << std::endl;
|
||||||
}
|
}
|
||||||
HasHkPoolParametersIF* hkOwner =
|
OwnsLocalDataPoolIF* hkOwner =
|
||||||
objectManager->get<HasHkPoolParametersIF>(poolOwner);
|
objectManager->get<OwnsLocalDataPoolIF>(poolOwner);
|
||||||
if(hkOwner == nullptr) {
|
if(hkOwner == nullptr) {
|
||||||
sif::error << "LocalPoolVariable: The supplied pool owner did not implement"
|
sif::error << "LocalPoolVariable: The supplied pool owner did not implement"
|
||||||
"the correct interface HasHkPoolParametersIF!" << std::endl;
|
"the correct interface HasHkPoolParametersIF!" << std::endl;
|
||||||
|
@ -5,33 +5,40 @@
|
|||||||
#include <framework/housekeeping/HousekeepingMessage.h>
|
#include <framework/housekeeping/HousekeepingMessage.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
class HousekeepingManager;
|
class LocalDataPoolManager;
|
||||||
class DataSetIF;
|
class DataSetIF;
|
||||||
/**
|
/**
|
||||||
* @brief Type definition for local pool entries.
|
* @brief Type definition for local pool entries.
|
||||||
*/
|
*/
|
||||||
using lp_id_t = uint32_t;
|
using lp_id_t = uint32_t;
|
||||||
using LocalDataPoolMap = std::map<lp_id_t, PoolEntryIF*>;
|
using LocalDataPool = std::map<lp_id_t, PoolEntryIF*>;
|
||||||
using LocalDataPoolMapIter = LocalDataPoolMap::iterator;
|
using LocalDataPoolMapIter = LocalDataPool::iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This interface is implemented by classes which posses a local
|
* @brief This interface is implemented by classes which posses a local
|
||||||
* data pool (not the managing class)
|
* data pool (not the managing class). It defines the relationship
|
||||||
|
* between the local data pool owner and the LocalDataPoolManager.
|
||||||
* @details
|
* @details
|
||||||
* Any class implementing this interface shall also have a HousekeepingManager
|
* Any class implementing this interface shall also have a LocalDataPoolManager
|
||||||
* member class which handles the retrieval of the local pool data.
|
* 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
|
* This is required because the pool entries are templates, which makes
|
||||||
* specifying an interface rather difficult.
|
* specifying an interface rather difficult. The local data pool can be
|
||||||
|
* accessed by using the LocalPoolVariable, LocalPoolVector or LocalDataSet
|
||||||
|
* classes.
|
||||||
*
|
*
|
||||||
* This could be circumvented by using a wrapper/accessor function, but
|
* 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 LocalPoolVariable classes are templates as well, so this just shifts
|
||||||
* the problem somewhere else. Interfaces are nice, but the most
|
* the problem somewhere else. Interfaces are nice, but the most
|
||||||
* pragmatic solution I found was to offer the client the full interface
|
* pragmatic solution I found was to offer the client the full interface
|
||||||
* of the housekeeping manager.
|
* of the LocalDataPoolManager.
|
||||||
*/
|
*/
|
||||||
class HasHkPoolParametersIF {
|
class OwnsLocalDataPoolIF {
|
||||||
public:
|
public:
|
||||||
virtual~ HasHkPoolParametersIF() {};
|
virtual~ OwnsLocalDataPoolIF() {};
|
||||||
|
|
||||||
static constexpr uint8_t INTERFACE_ID = CLASS_ID::HOUSEKEEPING;
|
static constexpr uint8_t INTERFACE_ID = CLASS_ID::HOUSEKEEPING;
|
||||||
static constexpr ReturnValue_t POOL_ENTRY_NOT_FOUND = MAKE_RETURN_CODE(0XA0);
|
static constexpr ReturnValue_t POOL_ENTRY_NOT_FOUND = MAKE_RETURN_CODE(0XA0);
|
||||||
@ -39,9 +46,9 @@ public:
|
|||||||
|
|
||||||
virtual MessageQueueId_t getCommandQueue() const = 0;
|
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||||
virtual ReturnValue_t initializeHousekeepingPoolEntries(
|
virtual ReturnValue_t initializeHousekeepingPoolEntries(
|
||||||
LocalDataPoolMap& localDataPoolMap) = 0;
|
LocalDataPool& localDataPoolMap) = 0;
|
||||||
//virtual float setMinimalHkSamplingFrequency() = 0;
|
//virtual float setMinimalHkSamplingFrequency() = 0;
|
||||||
virtual HousekeepingManager* getHkManagerHandle() = 0;
|
virtual LocalDataPoolManager* getHkManagerHandle() = 0;
|
||||||
virtual DataSetIF* getDataSetHandle(sid_t sid) = 0;
|
virtual DataSetIF* getDataSetHandle(sid_t sid) = 0;
|
||||||
};
|
};
|
||||||
|
|
@ -1347,11 +1347,11 @@ void DeviceHandlerBase::performOperationHook() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t DeviceHandlerBase::initializeHousekeepingPoolEntries(
|
ReturnValue_t DeviceHandlerBase::initializeHousekeepingPoolEntries(
|
||||||
LocalDataPoolMap &localDataPoolMap) {
|
LocalDataPool &localDataPoolMap) {
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HousekeepingManager* DeviceHandlerBase::getHkManagerHandle() {
|
LocalDataPoolManager* DeviceHandlerBase::getHkManagerHandle() {
|
||||||
return &hkManager;
|
return &hkManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,15 +11,13 @@
|
|||||||
#include <framework/modes/HasModesIF.h>
|
#include <framework/modes/HasModesIF.h>
|
||||||
#include <framework/power/PowerSwitchIF.h>
|
#include <framework/power/PowerSwitchIF.h>
|
||||||
#include <framework/ipc/MessageQueueIF.h>
|
#include <framework/ipc/MessageQueueIF.h>
|
||||||
#include <framework/housekeeping/HasHkPoolParametersIF.h>
|
|
||||||
|
|
||||||
#include <framework/action/ActionHelper.h>
|
#include <framework/action/ActionHelper.h>
|
||||||
#include <framework/health/HealthHelper.h>
|
#include <framework/health/HealthHelper.h>
|
||||||
#include <framework/parameters/ParameterHelper.h>
|
#include <framework/parameters/ParameterHelper.h>
|
||||||
#include <framework/datapool/HkSwitchHelper.h>
|
#include <framework/datapool/HkSwitchHelper.h>
|
||||||
|
#include <framework/datapoollocal/LocalDataPoolManager.h>
|
||||||
#include <framework/devicehandlers/DeviceHandlerFailureIsolation.h>
|
#include <framework/devicehandlers/DeviceHandlerFailureIsolation.h>
|
||||||
#include <framework/housekeeping/HousekeepingManager.h>
|
#include <framework/datapoollocal/OwnsLocalDataPoolIF.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace Factory{
|
namespace Factory{
|
||||||
@ -87,7 +85,7 @@ class DeviceHandlerBase: public DeviceHandlerIF,
|
|||||||
public HasHealthIF,
|
public HasHealthIF,
|
||||||
public HasActionsIF,
|
public HasActionsIF,
|
||||||
public ReceivesParameterMessagesIF,
|
public ReceivesParameterMessagesIF,
|
||||||
public HasHkPoolParametersIF {
|
public OwnsLocalDataPoolIF {
|
||||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -480,10 +478,10 @@ protected:
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t initializeHousekeepingPoolEntries(
|
virtual ReturnValue_t initializeHousekeepingPoolEntries(
|
||||||
LocalDataPoolMap& localDataPoolMap) override;
|
LocalDataPool& localDataPoolMap) override;
|
||||||
|
|
||||||
/** Get the HK manager object handle */
|
/** Get the HK manager object handle */
|
||||||
virtual HousekeepingManager* getHkManagerHandle() override;
|
virtual LocalDataPoolManager* getHkManagerHandle() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Hook function for child handlers which is called once per
|
* @brief Hook function for child handlers which is called once per
|
||||||
@ -609,7 +607,7 @@ protected:
|
|||||||
/** Action helper for HasActionsIF */
|
/** Action helper for HasActionsIF */
|
||||||
ActionHelper actionHelper;
|
ActionHelper actionHelper;
|
||||||
/** Housekeeping Manager */
|
/** Housekeeping Manager */
|
||||||
HousekeepingManager hkManager;
|
LocalDataPoolManager hkManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Information about commands
|
* @brief Information about commands
|
||||||
|
Loading…
Reference in New Issue
Block a user