separate step for performOp now

This commit is contained in:
Robin Müller 2020-10-12 18:28:07 +02:00
parent 140aa3ab42
commit dbcd06527e
3 changed files with 29 additions and 16 deletions

View File

@ -72,8 +72,13 @@ DeviceHandlerBase::~DeviceHandlerBase() {
ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) { ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
this->pstStep = counter; this->pstStep = counter;
this->lastStep = this->pstStep;
if (getComAction() == SEND_WRITE) { if (getComAction() == CommunicationAction::NOTHING) {
return HasReturnvaluesIF::RETURN_OK;
}
if (getComAction() == CommunicationAction::PERFORM_OPERATION) {
cookieInfo.state = COOKIE_UNUSED; cookieInfo.state = COOKIE_UNUSED;
readCommandQueue(); readCommandQueue();
doStateMachine(); doStateMachine();
@ -83,26 +88,29 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
hkSwitcher.performOperation(); hkSwitcher.performOperation();
hkManager.performHkOperation(); hkManager.performHkOperation();
performOperationHook(); performOperationHook();
return RETURN_OK;
} }
if (mode == MODE_OFF) { if (mode == MODE_OFF) {
return RETURN_OK; return RETURN_OK;
} }
switch (getComAction()) { switch (getComAction()) {
case SEND_WRITE: case CommunicationAction::SEND_WRITE:
if ((cookieInfo.state == COOKIE_UNUSED)) { if (cookieInfo.state == COOKIE_UNUSED) {
// if no external command was specified, build internal command.
buildInternalCommand(); buildInternalCommand();
} }
doSendWrite(); doSendWrite();
break; break;
case GET_WRITE: case CommunicationAction::GET_WRITE:
doGetWrite(); doGetWrite();
break; break;
case SEND_READ: case CommunicationAction::SEND_READ:
doSendRead(); doSendRead();
break; break;
case GET_READ: case CommunicationAction::GET_READ:
doGetRead(); doGetRead();
cookieInfo.state = COOKIE_UNUSED;
break; break;
default: default:
break; break;
@ -821,24 +829,27 @@ void DeviceHandlerBase::replyRawData(const uint8_t *data, size_t len,
} }
//Default child implementations //Default child implementations
DeviceHandlerIF::CommunicationAction_t DeviceHandlerBase::getComAction() { DeviceHandlerIF::CommunicationAction DeviceHandlerBase::getComAction() {
switch (pstStep) { switch (pstStep) {
case 0: case 0:
return SEND_WRITE; return CommunicationAction::PERFORM_OPERATION;
break; break;
case 1: case 1:
return GET_WRITE; return CommunicationAction::SEND_WRITE;
break; break;
case 2: case 2:
return SEND_READ; return CommunicationAction::GET_WRITE;
break; break;
case 3: case 3:
return GET_READ; return CommunicationAction::SEND_READ;
break;
case 4:
return CommunicationAction::GET_READ;
break; break;
default: default:
break; break;
} }
return NOTHING; return CommunicationAction::NOTHING;
} }
MessageQueueId_t DeviceHandlerBase::getCommandQueue() const { MessageQueueId_t DeviceHandlerBase::getCommandQueue() const {

View File

@ -577,6 +577,7 @@ protected:
/** This is the counter value from performOperation(). */ /** This is the counter value from performOperation(). */
uint8_t pstStep = 0; uint8_t pstStep = 0;
uint8_t lastStep = 0;
uint32_t pstIntervalMs = 0; uint32_t pstIntervalMs = 0;
/** /**
@ -841,7 +842,7 @@ protected:
* @return The Rmap action to execute in this step * @return The Rmap action to execute in this step
*/ */
virtual CommunicationAction_t getComAction(); virtual CommunicationAction getComAction();
/** /**
* Build the device command to send for raw mode. * Build the device command to send for raw mode.

View File

@ -139,7 +139,8 @@ public:
* *
* This is used by the child class to tell the base class what to do. * This is used by the child class to tell the base class what to do.
*/ */
enum CommunicationAction_t: uint8_t { enum CommunicationAction: uint8_t {
PERFORM_OPERATION,
SEND_WRITE,//!< Send write SEND_WRITE,//!< Send write
GET_WRITE, //!< Get write GET_WRITE, //!< Get write
SEND_READ, //!< Send read SEND_READ, //!< Send read