only handle one message per cycle
This commit is contained in:
parent
15a67b81f9
commit
1e767afa11
@ -105,25 +105,23 @@ ReturnValue_t HeaterHandler::initializeHeaterMap() {
|
||||
void HeaterHandler::readCommandQueue() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
CommandMessage command;
|
||||
do {
|
||||
if (not busyWithSwitchCommanding) {
|
||||
result = commandQueue->receiveMessage(&command);
|
||||
if (result == MessageQueueIF::EMPTY) {
|
||||
break;
|
||||
} else if (result != returnvalue::OK) {
|
||||
sif::warning << "HeaterHandler::readCommandQueue: Message reception error" << std::endl;
|
||||
break;
|
||||
}
|
||||
result = modeHelper.handleModeCommand(&command);
|
||||
if (result == returnvalue::OK) {
|
||||
continue;
|
||||
}
|
||||
result = actionHelper.handleActionMessage(&command);
|
||||
if (result == returnvalue::OK) {
|
||||
continue;
|
||||
}
|
||||
if (not busyWithSwitchCommanding) {
|
||||
result = commandQueue->receiveMessage(&command);
|
||||
if (result == MessageQueueIF::EMPTY) {
|
||||
return;
|
||||
} else if (result != returnvalue::OK) {
|
||||
sif::warning << "HeaterHandler::readCommandQueue: Message reception error" << std::endl;
|
||||
return;
|
||||
}
|
||||
} while (result == returnvalue::OK);
|
||||
result = modeHelper.handleModeCommand(&command);
|
||||
if (result == returnvalue::OK) {
|
||||
return;
|
||||
}
|
||||
result = actionHelper.handleActionMessage(&command);
|
||||
if (result == returnvalue::OK) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t HeaterHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
@ -276,15 +274,10 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switch heaterIdx) {
|
||||
triggerEvent(GPIO_PULL_HIGH_FAILED, result);
|
||||
}
|
||||
if (result == returnvalue::OK) {
|
||||
if (getSwitchState(heaterIdx) == SwitchState::OFF) {
|
||||
triggerEvent(HEATER_WENT_ON, heaterIdx, 0);
|
||||
{
|
||||
MutexGuard mg(handlerLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||
heater.switchState = ON;
|
||||
}
|
||||
|
||||
} else {
|
||||
triggerEvent(SWITCH_ALREADY_ON, heaterIdx);
|
||||
triggerEvent(HEATER_WENT_ON, heaterIdx, 0);
|
||||
{
|
||||
MutexGuard mg(handlerLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||
heater.switchState = ON;
|
||||
}
|
||||
EventManagerIF::triggerEvent(helper.heaters[heaterIdx].first->getObjectId(), MODE_INFO,
|
||||
MODE_ON, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user