Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Server] Improve publishing operation to avoid discarding values in edge cases #2763

Draft
wants to merge 10 commits into
base: develop/main374
Choose a base branch
from
2 changes: 1 addition & 1 deletion Libraries/Opc.Ua.Server/Subscription/MonitoredItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@
}


int notificationCount = overflowEvent != null ? 1 : 0;

Check warning on line 1193 in Libraries/Opc.Ua.Server/Subscription/MonitoredItem.cs

View check run for this annotation

Codecov / codecov/patch

Libraries/Opc.Ua.Server/Subscription/MonitoredItem.cs#L1193

Added line #L1193 was not covered by tests

for (int ii = 0; ii < m_events.Count; ii++)
{
Expand Down Expand Up @@ -1218,7 +1218,7 @@

notifications.Enqueue(m_events[ii]);

m_events.RemoveAt(ii);
m_events.RemoveAt(ii--);

Check warning on line 1221 in Libraries/Opc.Ua.Server/Subscription/MonitoredItem.cs

View check run for this annotation

Codecov / codecov/patch

Libraries/Opc.Ua.Server/Subscription/MonitoredItem.cs#L1221

Added line #L1221 was not covered by tests
romanett marked this conversation as resolved.
Show resolved Hide resolved
}

// place event at the end of the queue.
Expand All @@ -1234,11 +1234,11 @@

// reset state variables.
m_overflow = m_overflow && moreValuesToPublish && !m_discardOldest;
m_readyToPublish = moreValuesToPublish;
m_readyToTrigger = moreValuesToPublish;

Check warning on line 1238 in Libraries/Opc.Ua.Server/Subscription/MonitoredItem.cs

View check run for this annotation

Codecov / codecov/patch

Libraries/Opc.Ua.Server/Subscription/MonitoredItem.cs#L1237-L1238

Added lines #L1237 - L1238 were not covered by tests
m_triggered = false;

return moreValuesToPublish;

Check warning on line 1241 in Libraries/Opc.Ua.Server/Subscription/MonitoredItem.cs

View check run for this annotation

Codecov / codecov/patch

Libraries/Opc.Ua.Server/Subscription/MonitoredItem.cs#L1241

Added line #L1241 was not covered by tests
}
}

Expand Down
5 changes: 4 additions & 1 deletion Libraries/Opc.Ua.Server/Subscription/Subscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -862,10 +862,13 @@
}
else
{
hasMoreValuesToPublish = ((IEventMonitoredItem)monitoredItem).Publish(context, events, maxNotificationsPerMonitoredItem);

Check warning on line 865 in Libraries/Opc.Ua.Server/Subscription/Subscription.cs

View check run for this annotation

Codecov / codecov/patch

Libraries/Opc.Ua.Server/Subscription/Subscription.cs#L865

Added line #L865 was not covered by tests
}

// add back to list to check.
// if item has more values to publish leave it at the front of the list
// to execute publish in next cycle, no checking needed
// if no more values to publish are left add it to m_itemsToCheck
// to check status on next publish cylce
if (!hasMoreValuesToPublish)
{
m_itemsToPublish.Remove(current);
romanett marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading