From a0b8f8855ced699701290f643c1fab8658bd323b Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 16 Jul 2020 11:45:23 +0200 Subject: [PATCH] cotinued distir datapool --- datapoollocal/HasLocalDataPoolIF.h | 1 + datapoollocal/LocalDataPoolManager.h | 26 +++++++++++++++++++++++--- datapoollocal/LocalDataSet.cpp | 4 ++++ datapoollocal/LocalDataSet.h | 2 +- datapoollocal/LocalPoolDataSetBase.h | 2 ++ datapoollocal/LocalPoolVariable.tpp | 2 +- datapoollocal/SharedLocalDataSet.h | 8 +++++++- datapoollocal/StaticLocalDataSet.h | 13 +++++++++---- 8 files changed, 48 insertions(+), 10 deletions(-) diff --git a/datapoollocal/HasLocalDataPoolIF.h b/datapoollocal/HasLocalDataPoolIF.h index 0095f894..7727c3b4 100644 --- a/datapoollocal/HasLocalDataPoolIF.h +++ b/datapoollocal/HasLocalDataPoolIF.h @@ -41,6 +41,7 @@ public: virtual~ HasLocalDataPoolIF() {}; 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. */ virtual MessageQueueId_t getCommandQueue() const = 0; diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index 5a840303..9c413aa4 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -109,13 +109,32 @@ public: /** * Different types of housekeeping reporting are possible. - * 1. PERIODIC: HK packets are generated in fixed intervals - * 2. UPDATED: HK packets are generated if a value was updated - * 3. REQUESTED: HK packets are only generated if explicitely requested + * 1. PERIODIC: HK packets are generated in fixed intervals and sent to + * destination. Fromat will be raw. + * 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 { + // Periodic generation of HK packets. PERIODIC, + // Notification will be sent out as message. + // Data is accessed via shared data set or multiple local data sets. 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 }; @@ -136,6 +155,7 @@ private: */ struct HkReceiver { LocalDataSetBase* dataSet = nullptr; + lp_id_t localPoolId = HasLocalDataPoolIF::NO_POOL_ID; MessageQueueId_t destinationQueue = MessageQueueIF::NO_QUEUE; ReportingType reportingType = ReportingType::PERIODIC; bool reportingStatus = true; diff --git a/datapoollocal/LocalDataSet.cpp b/datapoollocal/LocalDataSet.cpp index b6508ada..74b1376e 100644 --- a/datapoollocal/LocalDataSet.cpp +++ b/datapoollocal/LocalDataSet.cpp @@ -5,3 +5,7 @@ LocalDataSet::LocalDataSet(HasLocalDataPoolIF *hkOwner, const size_t maxSize): this->setContainer(poolVarList.data()); } +LocalDataSet::LocalDataSet(object_id_t owner, const size_t maxSize): + LocalDataSetBase(owner, nullptr, maxSize), poolVarList(maxSize) { + this->setContainer(poolVarList.data()); +} diff --git a/datapoollocal/LocalDataSet.h b/datapoollocal/LocalDataSet.h index c26d540c..e6bd2012 100644 --- a/datapoollocal/LocalDataSet.h +++ b/datapoollocal/LocalDataSet.h @@ -6,7 +6,7 @@ class LocalDataSet: public LocalDataSetBase { public: LocalDataSet(HasLocalDataPoolIF* hkOwner, const size_t maxSize); - + LocalDataSet(object_id_t owner, const size_t maxSize); virtual~ LocalDataSet() {}; //! Copying forbidden for now. diff --git a/datapoollocal/LocalPoolDataSetBase.h b/datapoollocal/LocalPoolDataSetBase.h index 5ef8f3d4..f7a2cae4 100644 --- a/datapoollocal/LocalPoolDataSetBase.h +++ b/datapoollocal/LocalPoolDataSetBase.h @@ -46,6 +46,8 @@ public: * owner should implement the HasHkPoolParametersIF. * The constructor simply sets the fill_count to zero and sets * the state to "uninitialized". + * @details + * */ LocalDataSetBase(object_id_t ownerId, PoolVariableIF** registeredVariablesArray, diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index 0b96bb4f..59bf78d0 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -28,7 +28,7 @@ inline LocalPoolVar::LocalPoolVar(lp_id_t poolId, template inline LocalPoolVar::LocalPoolVar(lp_id_t poolId, object_id_t poolOwner, pool_rwm_t setReadWriteMode, DataSetIF *dataSet): - readWriteMode(readWriteMode) { + readWriteMode(setReadWriteMode) { if(poolId == PoolVariableIF::NO_PARAMETER) { sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the " "NO_PARAMETER value!" << std::endl; diff --git a/datapoollocal/SharedLocalDataSet.h b/datapoollocal/SharedLocalDataSet.h index 8fe613ba..acb0cd26 100644 --- a/datapoollocal/SharedLocalDataSet.h +++ b/datapoollocal/SharedLocalDataSet.h @@ -5,6 +5,13 @@ #include #include +/** + * 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, public LocalDataSetBase, public SharedDataSetIF { @@ -15,7 +22,6 @@ public: ReturnValue_t unlockDataset() override; private: - MutexIF* datasetLock = nullptr; std::vector poolVarVector; }; diff --git a/datapoollocal/StaticLocalDataSet.h b/datapoollocal/StaticLocalDataSet.h index f31018af..fbe1545f 100644 --- a/datapoollocal/StaticLocalDataSet.h +++ b/datapoollocal/StaticLocalDataSet.h @@ -1,6 +1,7 @@ #ifndef FRAMEWORK_DATAPOOLLOCAL_STATICLOCALDATASET_H_ #define FRAMEWORK_DATAPOOLLOCAL_STATICLOCALDATASET_H_ #include +#include #include /** @@ -12,12 +13,16 @@ * other software objects. * @tparam capacity */ -template -class StaticLocalDataSet: public PoolDataSetBase { - StaticLocalDataSet(): PoolDataSetBase(poolVarList.data(), capacity) {} +template +class StaticLocalDataSet: public LocalDataSetBase { +public: + StaticLocalDataSet(object_id_t owner): + LocalDataSetBase(owner, poolVarList.data(), NUM_VARIABLES) { + } + virtual~ StaticLocalDataSet(); private: - std::array poolVarList; + std::array poolVarList; }; #endif /* FRAMEWORK_DATAPOOLLOCAL_STATICLOCALDATASET_H_ */