From 1b16191c0b39db479dad7c42647d3979d235b1ad Mon Sep 17 00:00:00 2001 From: Peter Kurhajec <61538034+PTKu@users.noreply.github.com> Date: Wed, 10 Jun 2026 21:13:42 +0200 Subject: [PATCH] fix(core): publish MsgCnt once per cycle to prevent partial reads S7-1500 WebAPI samples variables at an arbitrary point of the PLC cycle. MsgCnt was reset and re-accumulated live within each cycle, so readers could observe 0 or a partial sum, causing message counts to flicker in the UI. Aggregate into protected _msgCntAcc during the cycle and publish the completed total into MsgCnt at the next cycle's Run/Initialize call. MsgCnt holds the total of the last completed cycle and is written once per cycle, at the cost of one cycle of latency. --- .../ctrl/src/AxoMessaging/Static/AxoMessenger.st | 2 +- src/core/ctrl/src/AxoObject/AxoObject.st | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/core/ctrl/src/AxoMessaging/Static/AxoMessenger.st b/src/core/ctrl/src/AxoMessaging/Static/AxoMessenger.st index 295568388..7539a09be 100644 --- a/src/core/ctrl/src/AxoMessaging/Static/AxoMessenger.st +++ b/src/core/ctrl/src/AxoMessaging/Static/AxoMessenger.st @@ -84,7 +84,7 @@ NAMESPACE AXOpen.Messaging.Static IF(_lastMessageAggregationCycle <> _context.OpenCycleCount()) THEN - THIS.MsgCnt := LINT#0; + THIS._msgCntAcc := LINT#0; END_IF; IF((THIS.MessengerState = eAxoMessengerState#ActiveAlreadyAcknowledged || diff --git a/src/core/ctrl/src/AxoObject/AxoObject.st b/src/core/ctrl/src/AxoObject/AxoObject.st index 125428d0d..1eb1b08a9 100644 --- a/src/core/ctrl/src/AxoObject/AxoObject.st +++ b/src/core/ctrl/src/AxoObject/AxoObject.st @@ -96,7 +96,8 @@ NAMESPACE AXOpen.Core END_VAR // We always reset message count upon initialization. - THIS.MsgCnt := LINT#0; + THIS.MsgCnt := _msgCntAcc; + _msgCntAcc := LINT#0; IF _isInitialized THEN RETURN; @@ -146,7 +147,9 @@ NAMESPACE AXOpen.Core // We always reset message count upon initialization. - THIS.MsgCnt := LINT#0; + THIS.MsgCnt := _msgCntAcc; + _msgCntAcc := LINT#0; + IF _isInitialized THEN RETURN; END_IF; @@ -164,9 +167,11 @@ NAMESPACE AXOpen.Core END_METHOD - VAR + VAR PROTECTED {#ix-attr:[RenderIgnore()]} _lastMessageAggregationCycle : ULINT; + {#ix-attr:[RenderIgnore()]} + _msgCntAcc : LINT; END_VAR /// @@ -183,7 +188,7 @@ NAMESPACE AXOpen.Core END_IF; IF(_lastMessageAggregationCycle <> _context.OpenCycleCount()) THEN - THIS.MsgCnt := LINT#0; + THIS._msgCntAcc := LINT#0; END_IF; IF(inCount = 0) THEN @@ -193,7 +198,7 @@ NAMESPACE AXOpen.Core RETURN; END_IF; - THIS.MsgCnt := inCount + THIS.MsgCnt; + THIS._msgCntAcc := inCount + THIS._msgCntAcc; IF(_parent <> NULL && THIS._parent <> THIS._parent.GetParent()) THEN THIS._parent.AggregateMessage(inCount);