cotinued distir datapool

This commit is contained in:
Robin Müller 2020-07-16 11:45:23 +02:00
parent e5ab7ada68
commit a0b8f8855c
8 changed files with 48 additions and 10 deletions

View File

@ -41,6 +41,7 @@ public:
virtual~ HasLocalDataPoolIF() {}; virtual~ HasLocalDataPoolIF() {};
static constexpr uint8_t INTERFACE_ID = CLASS_ID::LOCAL_POOL_OWNER_IF; static constexpr uint8_t INTERFACE_ID = CLASS_ID::LOCAL_POOL_OWNER_IF;
static constexpr lp_id_t NO_POOL_ID = 0xffffffff;
/** Command queue for housekeeping messages. */ /** Command queue for housekeeping messages. */
virtual MessageQueueId_t getCommandQueue() const = 0; virtual MessageQueueId_t getCommandQueue() const = 0;

View File

@ -109,13 +109,32 @@ public:
/** /**
* Different types of housekeeping reporting are possible. * Different types of housekeeping reporting are possible.
* 1. PERIODIC: HK packets are generated in fixed intervals * 1. PERIODIC: HK packets are generated in fixed intervals and sent to
* 2. UPDATED: HK packets are generated if a value was updated * destination. Fromat will be raw.
* 3. REQUESTED: HK packets are only generated if explicitely requested * 2. UPDATED: Notification will be sent out if HK data has changed.
* Question: Send Raw data directly or just the message?
* 3. REQUESTED: HK packets are only generated if explicitely requested.
* Propably not necessary, just use multiple local data sets or
* shared datasets.
*
* TODO: This is a big architecture question. Use raw data or shared
* datasets? dumb thing about shared datasets: It propably would be better
* if each task who uses the data has their own copy of the pool
* variables. Then the LPIDs should be hardcoded in the dataset implementations
* so the users don't have to worry about it anymore.
*
* Notifications should also be possible for single variables instead of
* full dataset updates.
*/ */
enum class ReportingType: uint8_t { enum class ReportingType: uint8_t {
// Periodic generation of HK packets.
PERIODIC, PERIODIC,
// Notification will be sent out as message.
// Data is accessed via shared data set or multiple local data sets.
ON_UPDATE, ON_UPDATE,
// actually, requested is propably unnecessary. If another component
// needs data on request, they can just use the new SharedDataSet
// which is thread-safe to also have full access to the interface..
REQUESTED REQUESTED
}; };
@ -136,6 +155,7 @@ private:
*/ */
struct HkReceiver { struct HkReceiver {
LocalDataSetBase* dataSet = nullptr; LocalDataSetBase* dataSet = nullptr;
lp_id_t localPoolId = HasLocalDataPoolIF::NO_POOL_ID;
MessageQueueId_t destinationQueue = MessageQueueIF::NO_QUEUE; MessageQueueId_t destinationQueue = MessageQueueIF::NO_QUEUE;
ReportingType reportingType = ReportingType::PERIODIC; ReportingType reportingType = ReportingType::PERIODIC;
bool reportingStatus = true; bool reportingStatus = true;

View File

@ -5,3 +5,7 @@ LocalDataSet::LocalDataSet(HasLocalDataPoolIF *hkOwner, const size_t maxSize):
this->setContainer(poolVarList.data()); this->setContainer(poolVarList.data());
} }
LocalDataSet::LocalDataSet(object_id_t owner, const size_t maxSize):
LocalDataSetBase(owner, nullptr, maxSize), poolVarList(maxSize) {
this->setContainer(poolVarList.data());
}

View File

@ -6,7 +6,7 @@
class LocalDataSet: public LocalDataSetBase { class LocalDataSet: public LocalDataSetBase {
public: public:
LocalDataSet(HasLocalDataPoolIF* hkOwner, const size_t maxSize); LocalDataSet(HasLocalDataPoolIF* hkOwner, const size_t maxSize);
LocalDataSet(object_id_t owner, const size_t maxSize);
virtual~ LocalDataSet() {}; virtual~ LocalDataSet() {};
//! Copying forbidden for now. //! Copying forbidden for now.

View File

@ -46,6 +46,8 @@ public:
* owner should implement the HasHkPoolParametersIF. * owner should implement the HasHkPoolParametersIF.
* 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".
* @details
*
*/ */
LocalDataSetBase(object_id_t ownerId, LocalDataSetBase(object_id_t ownerId,
PoolVariableIF** registeredVariablesArray, PoolVariableIF** registeredVariablesArray,

View File

@ -28,7 +28,7 @@ inline LocalPoolVar<T>::LocalPoolVar(lp_id_t poolId,
template<typename T> template<typename T>
inline LocalPoolVar<T>::LocalPoolVar(lp_id_t poolId, object_id_t poolOwner, inline LocalPoolVar<T>::LocalPoolVar(lp_id_t poolId, object_id_t poolOwner,
pool_rwm_t setReadWriteMode, DataSetIF *dataSet): pool_rwm_t setReadWriteMode, DataSetIF *dataSet):
readWriteMode(readWriteMode) { readWriteMode(setReadWriteMode) {
if(poolId == PoolVariableIF::NO_PARAMETER) { if(poolId == PoolVariableIF::NO_PARAMETER) {
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;

View File

@ -5,6 +5,13 @@
#include <framework/objectmanager/SystemObject.h> #include <framework/objectmanager/SystemObject.h>
#include <vector> #include <vector>
/**
* Baseline question: If this dataset is shared, is there once instance
* shared among many objects or multiple instances? Maybe be flexible
* and provide both ways? Sharing one instance requires a mutex lock.
* If there are multiple instances, it is not shared anymore, to be fair..
* Then a regular local data set is sufficient.
*/
class SharedLocalDataSet: public SystemObject, class SharedLocalDataSet: public SystemObject,
public LocalDataSetBase, public LocalDataSetBase,
public SharedDataSetIF { public SharedDataSetIF {
@ -15,7 +22,6 @@ public:
ReturnValue_t unlockDataset() override; ReturnValue_t unlockDataset() override;
private: private:
MutexIF* datasetLock = nullptr; MutexIF* datasetLock = nullptr;
std::vector<PoolVariableIF*> poolVarVector; std::vector<PoolVariableIF*> poolVarVector;
}; };

View File

@ -1,6 +1,7 @@
#ifndef FRAMEWORK_DATAPOOLLOCAL_STATICLOCALDATASET_H_ #ifndef FRAMEWORK_DATAPOOLLOCAL_STATICLOCALDATASET_H_
#define FRAMEWORK_DATAPOOLLOCAL_STATICLOCALDATASET_H_ #define FRAMEWORK_DATAPOOLLOCAL_STATICLOCALDATASET_H_
#include <framework/datapool/PoolDataSetBase.h> #include <framework/datapool/PoolDataSetBase.h>
#include <framework/objectmanager/SystemObjectIF.h>
#include <array> #include <array>
/** /**
@ -12,12 +13,16 @@
* other software objects. * other software objects.
* @tparam capacity * @tparam capacity
*/ */
template <uint8_t capacity> template <uint8_t NUM_VARIABLES>
class StaticLocalDataSet: public PoolDataSetBase { class StaticLocalDataSet: public LocalDataSetBase {
StaticLocalDataSet(): PoolDataSetBase(poolVarList.data(), capacity) {} public:
StaticLocalDataSet(object_id_t owner):
LocalDataSetBase(owner, poolVarList.data(), NUM_VARIABLES) {
}
virtual~ StaticLocalDataSet(); virtual~ StaticLocalDataSet();
private: private:
std::array<PoolVariableIF*, capacity> poolVarList; std::array<PoolVariableIF*, NUM_VARIABLES> poolVarList;
}; };
#endif /* FRAMEWORK_DATAPOOLLOCAL_STATICLOCALDATASET_H_ */ #endif /* FRAMEWORK_DATAPOOLLOCAL_STATICLOCALDATASET_H_ */