From 67ce8d2e24dcb8636f2dd4b04e3d275bb18a7fe4 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 14 Jan 2021 11:50:33 +0100 Subject: [PATCH 1/3] improved internal interface --- controller/ExtendedControllerBase.cpp | 8 ++------ controller/ExtendedControllerBase.h | 11 +---------- datapoollocal/HasLocalDataPoolIF.h | 25 +++++++++++++++++++------ devicehandlers/DeviceHandlerBase.cpp | 8 ++------ devicehandlers/DeviceHandlerBase.h | 8 ++------ internalError/InternalErrorReporter.cpp | 8 ++------ internalError/InternalErrorReporter.h | 3 +-- 7 files changed, 29 insertions(+), 42 deletions(-) diff --git a/controller/ExtendedControllerBase.cpp b/controller/ExtendedControllerBase.cpp index e0aec63a..397c8c10 100644 --- a/controller/ExtendedControllerBase.cpp +++ b/controller/ExtendedControllerBase.cpp @@ -26,10 +26,6 @@ object_id_t ExtendedControllerBase::getObjectId() const { return SystemObject::getObjectId(); } -AccessPoolManagerIF* ExtendedControllerBase::getAccessorHandle() { - return &poolManager; -} - uint32_t ExtendedControllerBase::getPeriodicOperationFrequency() const { return this->executingTask->getPeriodMs(); } @@ -114,6 +110,6 @@ LocalPoolDataSetBase* ExtendedControllerBase::getDataSetHandle(sid_t sid) { return nullptr; } -ProvidesDataPoolSubscriptionIF* ExtendedControllerBase::getSubscriptionInterface() { - return &poolManager; +LocalDataPoolManager* ExtendedControllerBase::getHkManagerHandle() { + return &poolManager; } diff --git a/controller/ExtendedControllerBase.h b/controller/ExtendedControllerBase.h index b2760514..bcb414dd 100644 --- a/controller/ExtendedControllerBase.h +++ b/controller/ExtendedControllerBase.h @@ -32,20 +32,10 @@ public: virtual ReturnValue_t performOperation(uint8_t opCode) override; virtual ReturnValue_t initializeAfterTaskCreation() override; - /** - * Provides a subscription interface for objects which required updates on changed - * controller variables or datasets - * @return - */ - ProvidesDataPoolSubscriptionIF* getSubscriptionInterface() override; - protected: LocalDataPoolManager poolManager; ActionHelper actionHelper; - //! Accessor handle required for internal handling - AccessPoolManagerIF* getAccessorHandle() override; - /** * Implemented by child class. Handle all command messages which are * not health, mode, action or housekeeping messages. @@ -68,6 +58,7 @@ protected: size_t size) override; /** HasLocalDatapoolIF overrides */ + virtual LocalDataPoolManager* getHkManagerHandle() override; virtual object_id_t getObjectId() const override; virtual ReturnValue_t initializeLocalDataPool( localpool::DataPool& localDataPoolMap, diff --git a/datapoollocal/HasLocalDataPoolIF.h b/datapoollocal/HasLocalDataPoolIF.h index 3d822650..1d87d47c 100644 --- a/datapoollocal/HasLocalDataPoolIF.h +++ b/datapoollocal/HasLocalDataPoolIF.h @@ -2,6 +2,7 @@ #define FSFW_DATAPOOLLOCAL_HASLOCALDATAPOOLIF_H_ #include "localPoolDefinitions.h" +#include "LocalDataPoolManager.h" #include "../datapool/PoolEntryIF.h" #include "../serviceinterface/ServiceInterface.h" @@ -14,7 +15,6 @@ class AccessPoolManagerIF; class ProvidesDataPoolSubscriptionIF; class LocalPoolDataSetBase; class LocalPoolObjectBase; -class LocalDataPoolManager; /** * @brief This interface is implemented by classes which posses a local data pool (not the @@ -104,19 +104,32 @@ public: * which allows subscriptions to dataset and variable updates in form of messages. * The consumers can then read the most recent variable value by calling read with * an own pool variable or set instance or using the deserialized snapshot data. + * Returns the HK manager casted to the required interface by default. * @return */ - virtual ProvidesDataPoolSubscriptionIF* getSubscriptionInterface() = 0; + virtual ProvidesDataPoolSubscriptionIF* getSubscriptionInterface() { + return getHkManagerHandle(); + } protected: /** - * Accessor handle required for internal handling. Not intended for users and therefore - * declared protected. Users should instead use pool variables, sets or the subscription - * interface to access pool entries. + * Every class implementing this interface should have a local data pool manager. This + * function will return a reference to the manager. * @return */ - virtual AccessPoolManagerIF* getAccessorHandle() = 0; + virtual LocalDataPoolManager* getHkManagerHandle() = 0; + + /** + * Accessor handle required for internal handling. Not intended for users and therefore + * declared protected. Users should instead use pool variables, sets or the subscription + * interface to access pool entries. Returns the HK manager casted to a different interface + * by default. + * @return + */ + virtual AccessPoolManagerIF* getAccessorHandle() { + return getHkManagerHandle(); + } /** * This function is used by the pool manager to get a valid dataset diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index c4098525..6092a89f 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -1483,10 +1483,6 @@ void DeviceHandlerBase::setNormalDatapoolEntriesInvalid() { } } -AccessPoolManagerIF* DeviceHandlerBase::getAccessorHandle() { - return &poolManager; -} - void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType, const char *functionName, ReturnValue_t errorCode, const char *errorPrint) { @@ -1532,6 +1528,6 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType, } -ProvidesDataPoolSubscriptionIF* DeviceHandlerBase::getSubscriptionInterface() { - return &poolManager; +LocalDataPoolManager* DeviceHandlerBase::getHkManagerHandle() { + return &poolManager; } diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 43f61897..3a993aff 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -518,14 +518,10 @@ protected: LocalDataPoolManager& poolManager) override; /** - * Provides the subscription handle which can be used by classes like controllers - * to get messages on data updates. + * Required for HasLocalDataPoolIF, return a handle to the local pool manager. * @return */ - ProvidesDataPoolSubscriptionIF* getSubscriptionInterface() override; - - //! Accessor handle required for internal handling. - AccessPoolManagerIF* getAccessorHandle() override; + LocalDataPoolManager* getHkManagerHandle() override; /** * @brief Hook function for child handlers which is called once per diff --git a/internalError/InternalErrorReporter.cpp b/internalError/InternalErrorReporter.cpp index bc72ada2..7e5a316c 100644 --- a/internalError/InternalErrorReporter.cpp +++ b/internalError/InternalErrorReporter.cpp @@ -139,10 +139,6 @@ uint32_t InternalErrorReporter::getStoreHits() { return value; } -AccessPoolManagerIF* InternalErrorReporter::getAccessorHandle() { - return &poolManager; -} - void InternalErrorReporter::incrementStoreHits() { mutex->lockMutex(timeoutType, timeoutMs); storeHits++; @@ -201,6 +197,6 @@ void InternalErrorReporter::setMutexTimeout(MutexIF::TimeoutType timeoutType, this->timeoutMs = timeoutMs; } -ProvidesDataPoolSubscriptionIF* InternalErrorReporter::getSubscriptionInterface() { - return &poolManager; +LocalDataPoolManager* InternalErrorReporter::getHkManagerHandle() { + return &poolManager; } diff --git a/internalError/InternalErrorReporter.h b/internalError/InternalErrorReporter.h index ec9134d4..a237418e 100644 --- a/internalError/InternalErrorReporter.h +++ b/internalError/InternalErrorReporter.h @@ -45,8 +45,7 @@ public: LocalDataPoolManager& poolManager) override; virtual dur_millis_t getPeriodicOperationFrequency() const override; virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - ProvidesDataPoolSubscriptionIF* getSubscriptionInterface() override; - AccessPoolManagerIF* getAccessorHandle() override; + LocalDataPoolManager* getHkManagerHandle() override; virtual ReturnValue_t initialize() override; virtual ReturnValue_t initializeAfterTaskCreation() override; From 2c4cd756c6d868a9a1d6e08cb6bfb503012a9cae Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 14 Jan 2021 11:58:50 +0100 Subject: [PATCH 2/3] updated to new internal interface --- .../tests/datapoollocal/LocalPoolOwnerBase.h | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/unittest/tests/datapoollocal/LocalPoolOwnerBase.h b/unittest/tests/datapoollocal/LocalPoolOwnerBase.h index aaccc90e..916b3e45 100644 --- a/unittest/tests/datapoollocal/LocalPoolOwnerBase.h +++ b/unittest/tests/datapoollocal/LocalPoolOwnerBase.h @@ -56,7 +56,7 @@ class LocalPoolOwnerBase: public SystemObject, public HasLocalDataPoolIF { public: LocalPoolOwnerBase( object_id_t objectId = objects::TEST_LOCAL_POOL_OWNER_BASE): - SystemObject(objectId), hkManager(this, messageQueue), + SystemObject(objectId), poolManager(this, messageQueue), dataset(this, lpool::testSetId) { messageQueue = new MessageQueueMockBase(); } @@ -72,7 +72,7 @@ public: ReturnValue_t initializeHkManager() { if(not initialized) { initialized = true; - return hkManager.initialize(messageQueue); + return poolManager.initialize(messageQueue); } return HasReturnvaluesIF::RETURN_OK; } @@ -80,7 +80,7 @@ public: ReturnValue_t initializeHkManagerAfterTaskCreation() { if(not initializedAfterTaskCreation) { initializedAfterTaskCreation = true; - return hkManager.initializeAfterTaskCreation(); + return poolManager.initializeAfterTaskCreation(); } return HasReturnvaluesIF::RETURN_OK; } @@ -109,17 +109,8 @@ public: return HasReturnvaluesIF::RETURN_OK; } - /** - * 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() override { - return &hkManager; - } - - virtual AccessPoolManagerIF* getAccessorHandle() override { - return &hkManager; + LocalDataPoolManager* getHkManagerHandle() override { + return &poolManager; } uint32_t getPeriodicOperationFrequency() const override { @@ -163,25 +154,25 @@ public: } ReturnValue_t subscribeWrapperSetUpdate() { - return hkManager.subscribeForSetUpdateMessages(lpool::testSetId, + return poolManager.subscribeForSetUpdateMessages(lpool::testSetId, objects::NO_OBJECT, MessageQueueIF::NO_QUEUE, false); } ReturnValue_t subscribeWrapperSetUpdateHk(bool diagnostics = false) { - return hkManager.subscribeForUpdatePackets(lpool::testSid, diagnostics, + return poolManager.subscribeForUpdatePackets(lpool::testSid, diagnostics, false, objects::HK_RECEIVER_MOCK); } ReturnValue_t subscribeWrapperVariableUpdate(lp_id_t localPoolId) { - return hkManager.subscribeForVariableUpdateMessages(localPoolId, + return poolManager.subscribeForVariableUpdateMessages(localPoolId, MessageQueueIF::NO_QUEUE, objects::NO_OBJECT, false); } void resetSubscriptionList() { - hkManager.clearReceiversList(); + poolManager.clearReceiversList(); } - LocalDataPoolManager hkManager; + LocalDataPoolManager poolManager; LocalPoolTestDataSet dataset; private: From 549afaee1d5713de7700445d771a8ada95e96a2d Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 14 Jan 2021 12:02:20 +0100 Subject: [PATCH 3/3] initialized member --- datapool/PoolDataSetBase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datapool/PoolDataSetBase.h b/datapool/PoolDataSetBase.h index 65a6651e..75654146 100644 --- a/datapool/PoolDataSetBase.h +++ b/datapool/PoolDataSetBase.h @@ -162,7 +162,7 @@ protected: private: bool protectEveryReadCommitCall = false; - MutexIF::TimeoutType timeoutTypeForSingleVars; + MutexIF::TimeoutType timeoutTypeForSingleVars = MutexIF::TimeoutType::WAITING; uint32_t mutexTimeoutForSingleVars = 20; ReturnValue_t readVariable(uint16_t count);