From ab603abada422d906a6cedb9d204ca2fe5e200ad Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 14 Oct 2020 20:05:39 +0200 Subject: [PATCH] subscription mechanism almost complete --- datapoollocal/HasLocalDataPoolIF.h | 10 ++++- datapoollocal/LocalDataPoolManager.cpp | 51 +++++++++++++++++++++++++- storagemanager/storeAddress.h | 7 +++- 3 files changed, 64 insertions(+), 4 deletions(-) diff --git a/datapoollocal/HasLocalDataPoolIF.h b/datapoollocal/HasLocalDataPoolIF.h index d7950b49c..9d4f2605a 100644 --- a/datapoollocal/HasLocalDataPoolIF.h +++ b/datapoollocal/HasLocalDataPoolIF.h @@ -96,8 +96,11 @@ public: * @details * Can be overriden by the child class to handle changed datasets. * @param sid + * @param storeId If a snapshot was requested, data will be located inside + * the IPC store with this store ID. */ - virtual void handleChangedDatasetOrVariable(sid_t sid) { + virtual void handleChangedDataset(sid_t sid, + store_address_t storeId = storeId::INVALID_STORE_ADDRESS) { return; } @@ -107,8 +110,11 @@ public: * @details * Can be overriden by the child class to handle changed pool IDs. * @param sid + * @param storeId If a snapshot was requested, data will be located inside + * the IPC store with this store ID. */ - virtual void handleChangedPoolVariable(lp_id_t poolId) { + virtual void handleChangedPoolVariable(lp_id_t poolId, + store_address_t storeId = storeId::INVALID_STORE_ADDRESS) { return; } diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index 848ade5e8..d89f597e4 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -129,6 +129,14 @@ ReturnValue_t LocalDataPoolManager::performHkOperation() { } if(poolObj->hasChanged()) { // prepare and send update notification. + CommandMessage notification; + HousekeepingMessage::setUpdateNotificationVariableCommand( + ¬ification, receiver.dataId.localPoolId); + ReturnValue_t result = hkQueue->sendMessage( + receiver.destinationQueue, ¬ification); + if(result != HasReturnvaluesIF::RETURN_OK) { + status = result; + } toReset = poolObj; } @@ -169,6 +177,16 @@ ReturnValue_t LocalDataPoolManager::performHkOperation() { } if(poolObj->hasChanged()) { // prepare and send update snapshot. + CommandMessage notification; + // todo: serialize into store with timestamp. + store_address_t storeId; + HousekeepingMessage::setUpdateSnapshotSetCommand( + ¬ification, receiver.dataId.sid, storeId); + ReturnValue_t result = hkQueue->sendMessage( + receiver.destinationQueue, ¬ification); + if(result != HasReturnvaluesIF::RETURN_OK) { + status = result; + } toReset = poolObj; } } @@ -180,6 +198,16 @@ ReturnValue_t LocalDataPoolManager::performHkOperation() { } if(dataSet->hasChanged()) { // prepare and send update snapshot. + CommandMessage notification; + // todo: serialize into store with timestamp. + store_address_t storeId; + HousekeepingMessage::setUpdateSnapshotVariableCommand( + ¬ification, receiver.dataId.localPoolId, storeId); + ReturnValue_t result = hkQueue->sendMessage( + receiver.destinationQueue, ¬ification); + if(result != HasReturnvaluesIF::RETURN_OK) { + status = result; + } toReset = dataSet; } } @@ -384,6 +412,7 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage( sid_t sid = HousekeepingMessage::getSid(message); ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; switch(command) { + // Houskeeping interface handling. case(HousekeepingMessage::ENABLE_PERIODIC_DIAGNOSTICS_GENERATION): { result = togglePeriodicGeneration(sid, true, true); break; @@ -438,8 +467,28 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage( dataSet, true); } + // Notification handling. case(HousekeepingMessage::UPDATE_NOTIFICATION_SET): { - owner->handleChangedDatasetOrVariable(sid); + owner->handleChangedDataset(sid); + return HasReturnvaluesIF::RETURN_OK; + } + case(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE): { + lp_id_t locPoolId = HousekeepingMessage:: + getUpdateNotificationVariableCommand(message); + owner->handleChangedPoolVariable(locPoolId); + return HasReturnvaluesIF::RETURN_OK; + } + case(HousekeepingMessage::UPDATE_SNAPSHOT_SET): { + store_address_t storeId; + HousekeepingMessage::getUpdateSnapshotSetCommand(message, &storeId); + owner->handleChangedDataset(sid, storeId); + return HasReturnvaluesIF::RETURN_OK; + } + case(HousekeepingMessage::UPDATE_SNAPSHOT_VARIABLE): { + store_address_t storeId; + lp_id_t localPoolId = HousekeepingMessage:: + getUpdateSnapshotVariableCommand(message, &storeId); + owner->handleChangedPoolVariable(localPoolId, storeId); return HasReturnvaluesIF::RETURN_OK; } diff --git a/storagemanager/storeAddress.h b/storagemanager/storeAddress.h index 044c07908..994998a66 100644 --- a/storagemanager/storeAddress.h +++ b/storagemanager/storeAddress.h @@ -3,16 +3,21 @@ #include +namespace storeId { +static constexpr uint32_t INVALID_STORE_ADDRESS = 0xffffffff; +} + /** * This union defines the type that identifies where a data packet is * stored in the store. It comprises of a raw part to read it as raw value and * a structured part to use it in pool-like stores. */ union store_address_t { + /** * Default Constructor, initializing to INVALID_ADDRESS */ - store_address_t():raw(0xFFFFFFFF){} + store_address_t(): raw(storeId::INVALID_STORE_ADDRESS){} /** * Constructor to create an address object using the raw address *