Diag: send operate (O000) only if State has changed

This commit is contained in:
Siegfried Siegert 2024-03-12 14:47:13 +01:00
parent 58f50b0ea6
commit 70b488de66
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
2 changed files with 17 additions and 4 deletions

View File

@ -12,6 +12,7 @@ DeviceControllerDiag::DeviceControllerDiag(PersistentData *pData, QObject *paren
, eventReceiver(nullptr)
, isRequestRunning(false)
, flagInterruptDiag(false)
, lastState(DeviceController::State::INITIAL_STATE)
, pData(pData)
{
diagRequestTimeoutTimer = new QTimer(this);
@ -365,7 +366,6 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
{
qCritical() << "DeviceControllerDiag::private_sendDiagEvent() result: " << result;
if (this->eventReceiver == nullptr) {
qCritical() << "DeviceControllerDiag: no eventReceiver";
return;
@ -388,6 +388,9 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
QString parameter;
switch (result) {
case DeviceController::State::INITIAL_STATE:
return;
break;
case DeviceController::State::A000: // alarm / intrusion
eventClass = EVENT_CLASS::ALARM;
parameter = "alarm / intrusion";
@ -480,7 +483,13 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
this->machineEventSet.clear();
eventClass = EVENT_CLASS::OPERATE;
parameter = "";
if (this->lastState == DeviceController::State::O000) {
qCritical() << " ... everything fine, no state change -> skip sending";
return;
}
else {
qCritical() << " ... everything fine";
}
break;
case DeviceController::State::W001: // paper low
@ -501,6 +510,7 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
break;
}
this->lastState = result;
ATBMachineEvent *machineEvent = new ATBMachineEvent(
eventId,

View File

@ -52,7 +52,9 @@ namespace DeviceController {
W001,
W002,
W003,
W004
W004,
INITIAL_STATE
};
Q_ENUM_NS(State)
}
@ -91,6 +93,7 @@ private:
int lastVoltage;
DeviceController::State lastState;
QSet<DeviceController::State> machineEventSet;
PersistentData* pData;