From 68cda479d699ef0f5c73b9ee95c352e178171896 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 6 Mar 2020 18:48:48 +0100 Subject: [PATCH] DHB: performOperation Hook + polling counter polling counter to specify how often communication opertions are performed, however this still needs to be changed.. --- container/FixedMap.h | 2 +- container/group.h | 8 +++----- devicehandlers/DeviceHandlerBase.cpp | 20 +++++++++++++++++--- devicehandlers/DeviceHandlerBase.h | 25 +++++++++++++++++++++++-- 4 files changed, 44 insertions(+), 11 deletions(-) diff --git a/container/FixedMap.h b/container/FixedMap.h index 39e9106d..f5ee4244 100644 --- a/container/FixedMap.h +++ b/container/FixedMap.h @@ -9,7 +9,7 @@ * @brief Map implementation for maps with a pre-defined size. * @details Can be initialized with desired maximum size. * Iterator is used to access pair and - * iterate through map entries. + * iterate through map entries. Complexity O(n). * @ingroup container */ template diff --git a/container/group.h b/container/group.h index 5a39d34e..9c70d523 100644 --- a/container/group.h +++ b/container/group.h @@ -4,11 +4,9 @@ /** * @defgroup container Container * - * General Purpose Container to store various elements. - * - * Also contains Adapter classes to print elements to a - * bytestream and to read them from a bytestream, as well - * as an Adapter to swap the endianness. + * General Purpose Containers to store various elements. + * As opposed to the STL library implementation, these implementations + * don't allocate memory dynamically. */ diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index c4f7465d..1252d61f 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -32,8 +32,9 @@ DeviceHandlerBase::DeviceHandlerBase(uint32_t logicalAddress_, ignoreMissedRepliesCount(0), fdirInstance(fdirInstance), hkSwitcher(this), defaultFDIRUsed(fdirInstance == NULL), switchOffWasReported(false), executingTask(NULL), actionHelper(this, NULL), cookieInfo(), logicalAddress(logicalAddress_), - timeoutStart(0), childTransitionDelay(5000), transitionSourceMode(_MODE_POWER_DOWN), - transitionSourceSubMode(SUBMODE_NONE), deviceSwitch(setDeviceSwitch) + pollingFrequency(1), pollingCounter(1), timeoutStart(0), childTransitionDelay(5000), + transitionSourceMode(_MODE_POWER_DOWN), transitionSourceSubMode(SUBMODE_NONE), + deviceSwitch(setDeviceSwitch) { commandQueue = QueueFactory::instance()-> createMessageQueue(cmdQueueSize, CommandMessage::MAX_MESSAGE_SIZE); @@ -63,10 +64,20 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) { decrementDeviceReplyMap(); fdirInstance->checkForFailures(); hkSwitcher.performOperation(); + performOperationHook(); } if (mode == MODE_OFF) { return RETURN_OK; } + + if (pollingCounter != pollingFrequency) { + pollingCounter ++; + return RETURN_OK; + } + else { + pollingCounter = 1; + } + switch (getRmapAction()) { case SEND_WRITE: if ((cookieInfo.state == COOKIE_UNUSED)) { @@ -87,6 +98,7 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) { default: break; } + return RETURN_OK; } @@ -166,7 +178,6 @@ ReturnValue_t DeviceHandlerBase::initialize() { mySet.commit(PoolVariableIF::VALID); return RETURN_OK; - } void DeviceHandlerBase::decrementDeviceReplyMap() { @@ -1278,3 +1289,6 @@ void DeviceHandlerBase::debugInterface(uint8_t positionTracker, object_id_t obje uint32_t DeviceHandlerBase::getLogicalAddress() { return logicalAddress; } + +void DeviceHandlerBase::performOperationHook() { +} diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 98808d87..130aedb9 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -18,9 +18,9 @@ #include #include #include -#include #include #include +#include namespace Factory{ void setStaticFrameworkObjectIds(); @@ -88,7 +88,7 @@ public: * The constructor passes the objectId to the SystemObject(). * * @param setObjectId the ObjectId to pass to the SystemObject() Constructor - * @param maxDeviceReplyLen the length the RMAP getRead call will be sent with + * @param maxDeviceReplyLen the largest allowed reply size * @param setDeviceSwitch the switch the device is connected to, for devices using two switches, overwrite getSwitches() * @param deviceCommuncation Communcation Interface object which is used to implement communication functions * @param thermalStatePoolId @@ -349,6 +349,12 @@ protected: virtual ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches); + /** + * Can be used to perform device specific periodic operations. + * This is called on the SEND_READ step of the performOperation() call + */ + virtual void performOperationHook(); + public: /** * @param parentQueueId @@ -934,6 +940,19 @@ private: */ const uint32_t logicalAddress; + /** + * Polling Frequency which specifies how often the communication functions + * and functionalities are called. + * + * This is not a time value. The time value depends on the + * respective period time of the polling sequence table. + * The actual time frequency can be calculated by multiplying that period + * with the polling frequency value. Defaults to 1 (communication operations called + * in each performOperation()). + */ + uint32_t pollingFrequency; + uint32_t pollingCounter; + /** * Used for timing out mode transitions. * @@ -981,6 +1000,8 @@ private: * - checks whether commanded mode transitions are required and calls handleCommandedModeTransition() * - does the necessary action for the current mode or calls doChildStateMachine in modes @c MODE_TO_ON and @c MODE_TO_OFF * - actions that happen in transitions (eg setting a timeout) are handled in setMode() + * - Maybe export this into own class to increase modularity of software + * and reduce the massive class size ? */ void doStateMachine(void);