DHB: performOperation Hook + polling counter

polling counter to specify how often communication opertions are
performed, however this still needs to be changed..
This commit is contained in:
Robin Müller 2020-03-06 18:48:48 +01:00
parent 22e4dabd1b
commit 68cda479d6
4 changed files with 44 additions and 11 deletions

View File

@ -9,7 +9,7 @@
* @brief Map implementation for maps with a pre-defined size. * @brief Map implementation for maps with a pre-defined size.
* @details Can be initialized with desired maximum size. * @details Can be initialized with desired maximum size.
* Iterator is used to access <key,value> pair and * Iterator is used to access <key,value> pair and
* iterate through map entries. * iterate through map entries. Complexity O(n).
* @ingroup container * @ingroup container
*/ */
template<typename key_t, typename T> template<typename key_t, typename T>

View File

@ -4,11 +4,9 @@
/** /**
* @defgroup container Container * @defgroup container Container
* *
* General Purpose Container to store various elements. * General Purpose Containers to store various elements.
* * As opposed to the STL library implementation, these implementations
* Also contains Adapter classes to print elements to a * don't allocate memory dynamically.
* bytestream and to read them from a bytestream, as well
* as an Adapter to swap the endianness.
*/ */

View File

@ -32,8 +32,9 @@ DeviceHandlerBase::DeviceHandlerBase(uint32_t logicalAddress_,
ignoreMissedRepliesCount(0), fdirInstance(fdirInstance), hkSwitcher(this), ignoreMissedRepliesCount(0), fdirInstance(fdirInstance), hkSwitcher(this),
defaultFDIRUsed(fdirInstance == NULL), switchOffWasReported(false), defaultFDIRUsed(fdirInstance == NULL), switchOffWasReported(false),
executingTask(NULL), actionHelper(this, NULL), cookieInfo(), logicalAddress(logicalAddress_), executingTask(NULL), actionHelper(this, NULL), cookieInfo(), logicalAddress(logicalAddress_),
timeoutStart(0), childTransitionDelay(5000), transitionSourceMode(_MODE_POWER_DOWN), pollingFrequency(1), pollingCounter(1), timeoutStart(0), childTransitionDelay(5000),
transitionSourceSubMode(SUBMODE_NONE), deviceSwitch(setDeviceSwitch) transitionSourceMode(_MODE_POWER_DOWN), transitionSourceSubMode(SUBMODE_NONE),
deviceSwitch(setDeviceSwitch)
{ {
commandQueue = QueueFactory::instance()-> commandQueue = QueueFactory::instance()->
createMessageQueue(cmdQueueSize, CommandMessage::MAX_MESSAGE_SIZE); createMessageQueue(cmdQueueSize, CommandMessage::MAX_MESSAGE_SIZE);
@ -63,10 +64,20 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
decrementDeviceReplyMap(); decrementDeviceReplyMap();
fdirInstance->checkForFailures(); fdirInstance->checkForFailures();
hkSwitcher.performOperation(); hkSwitcher.performOperation();
performOperationHook();
} }
if (mode == MODE_OFF) { if (mode == MODE_OFF) {
return RETURN_OK; return RETURN_OK;
} }
if (pollingCounter != pollingFrequency) {
pollingCounter ++;
return RETURN_OK;
}
else {
pollingCounter = 1;
}
switch (getRmapAction()) { switch (getRmapAction()) {
case SEND_WRITE: case SEND_WRITE:
if ((cookieInfo.state == COOKIE_UNUSED)) { if ((cookieInfo.state == COOKIE_UNUSED)) {
@ -87,6 +98,7 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
default: default:
break; break;
} }
return RETURN_OK; return RETURN_OK;
} }
@ -166,7 +178,6 @@ ReturnValue_t DeviceHandlerBase::initialize() {
mySet.commit(PoolVariableIF::VALID); mySet.commit(PoolVariableIF::VALID);
return RETURN_OK; return RETURN_OK;
} }
void DeviceHandlerBase::decrementDeviceReplyMap() { void DeviceHandlerBase::decrementDeviceReplyMap() {
@ -1278,3 +1289,6 @@ void DeviceHandlerBase::debugInterface(uint8_t positionTracker, object_id_t obje
uint32_t DeviceHandlerBase::getLogicalAddress() { uint32_t DeviceHandlerBase::getLogicalAddress() {
return logicalAddress; return logicalAddress;
} }
void DeviceHandlerBase::performOperationHook() {
}

View File

@ -18,9 +18,9 @@
#include <framework/devicehandlers/DeviceHandlerFailureIsolation.h> #include <framework/devicehandlers/DeviceHandlerFailureIsolation.h>
#include <framework/datapool/HkSwitchHelper.h> #include <framework/datapool/HkSwitchHelper.h>
#include <framework/serialize/SerialFixedArrayListAdapter.h> #include <framework/serialize/SerialFixedArrayListAdapter.h>
#include <map>
#include <framework/ipc/MessageQueueIF.h> #include <framework/ipc/MessageQueueIF.h>
#include <framework/tasks/PeriodicTaskIF.h> #include <framework/tasks/PeriodicTaskIF.h>
#include <map>
namespace Factory{ namespace Factory{
void setStaticFrameworkObjectIds(); void setStaticFrameworkObjectIds();
@ -88,7 +88,7 @@ public:
* The constructor passes the objectId to the SystemObject(). * The constructor passes the objectId to the SystemObject().
* *
* @param setObjectId the ObjectId to pass to the SystemObject() Constructor * @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 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 deviceCommuncation Communcation Interface object which is used to implement communication functions
* @param thermalStatePoolId * @param thermalStatePoolId
@ -349,6 +349,12 @@ protected:
virtual ReturnValue_t getSwitches(const uint8_t **switches, virtual ReturnValue_t getSwitches(const uint8_t **switches,
uint8_t *numberOfSwitches); 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: public:
/** /**
* @param parentQueueId * @param parentQueueId
@ -934,6 +940,19 @@ private:
*/ */
const uint32_t logicalAddress; 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. * Used for timing out mode transitions.
* *
@ -981,6 +1000,8 @@ private:
* - checks whether commanded mode transitions are required and calls handleCommandedModeTransition() * - 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 * - 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() * - 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); void doStateMachine(void);