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) , eventReceiver(nullptr)
, isRequestRunning(false) , isRequestRunning(false)
, flagInterruptDiag(false) , flagInterruptDiag(false)
, lastState(DeviceController::State::INITIAL_STATE)
, pData(pData) , pData(pData)
{ {
diagRequestTimeoutTimer = new QTimer(this); diagRequestTimeoutTimer = new QTimer(this);
@ -365,7 +366,6 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
{ {
qCritical() << "DeviceControllerDiag::private_sendDiagEvent() result: " << result; qCritical() << "DeviceControllerDiag::private_sendDiagEvent() result: " << result;
if (this->eventReceiver == nullptr) { if (this->eventReceiver == nullptr) {
qCritical() << "DeviceControllerDiag: no eventReceiver"; qCritical() << "DeviceControllerDiag: no eventReceiver";
return; return;
@ -388,6 +388,9 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
QString parameter; QString parameter;
switch (result) { switch (result) {
case DeviceController::State::INITIAL_STATE:
return;
break;
case DeviceController::State::A000: // alarm / intrusion case DeviceController::State::A000: // alarm / intrusion
eventClass = EVENT_CLASS::ALARM; eventClass = EVENT_CLASS::ALARM;
parameter = "alarm / intrusion"; parameter = "alarm / intrusion";
@ -473,14 +476,20 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
case DeviceController::State::E255: // no valid data from DeviceController case DeviceController::State::E255: // no valid data from DeviceController
eventClass = EVENT_CLASS::STATE; eventClass = EVENT_CLASS::STATE;
parameter = ""; parameter = "";
qCritical() << " ... ignore " << QMetaEnum::fromType<DeviceController::State>().valueToKey(result); qCritical() << " ... ignore " << QMetaEnum::fromType<DeviceController::State>().valueToKey(result);
return; return;
break; break;
case DeviceController::State::O000: // everything is fine case DeviceController::State::O000: // everything is fine
this->machineEventSet.clear(); this->machineEventSet.clear();
eventClass = EVENT_CLASS::OPERATE; eventClass = EVENT_CLASS::OPERATE;
parameter = ""; parameter = "";
qCritical() << " ... everything fine"; if (this->lastState == DeviceController::State::O000) {
qCritical() << " ... everything fine, no state change -> skip sending";
return;
}
else {
qCritical() << " ... everything fine";
}
break; break;
case DeviceController::State::W001: // paper low case DeviceController::State::W001: // paper low
@ -501,6 +510,7 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
break; break;
} }
this->lastState = result;
ATBMachineEvent *machineEvent = new ATBMachineEvent( ATBMachineEvent *machineEvent = new ATBMachineEvent(
eventId, eventId,

View File

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