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

View File

@ -577,6 +577,7 @@ protected:
/** This is the counter value from performOperation(). */
uint8_t pstStep = 0;
uint8_t lastStep = 0;
uint32_t pstIntervalMs = 0;
/**
@ -841,7 +842,7 @@ protected:
* @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.

View File

@ -139,7 +139,8 @@ public:
*
* 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
GET_WRITE, //!< Get write
SEND_READ, //!< Send read