Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I'm creating a subscription with a monitored item:

OpcUaSubscription uaSubscription = new OpcUaSubscription(uaClient);
uaSubscription.setPublishingInterval(...);
uaSubscription.setLifetimeCount(...);
uaSubscription.setMaxKeepAliveCount(...);
uaSubscription.setMaxNotificationsPerPublish(...);
uaSubscription.setPriority(...);
uaSubscription.setSubscriptionListener(new Listener());

uaSubscription.create();

uaSubscription.setPublishingMode(publishingEnabled);

Then I'm adding a monitored item:

ReadValueId readValueId = new ReadValueId(nodeId, AttributeId.Value.uid(), indexRange, QualifiedName.NULL_VALUE);
OpcUaMonitoredItem monitoredDataItem = new OpcUaMonitoredItem(readValueId, monitoringMode);
monitoredDataItem.setDataValueListener(new ValueConsumer(...));
monitoredDataItem.setQueueSize(queueSize);
monitoredDataItem.setSamplingInterval(samplingInterval);

uaSubscription.addMonitoredItem(monitoredDataItem);

And finally call synchronizeMonitoredItems and log the OpcUaSubscription

subscription.synchronizeMonitoredItems();
LOG.debug("synchronizeMonitoredItems for subscription: " + subscription);

The logging shows:

...synchronizeMonitoredItems for subscription: OpcUaSubscription[subscriptionId=1775131576, syncState=UNSYNCHRONIZED]

I would have expected that the syncState=SYNCHRONIZED.

Am I'm doing something wrong?

The subscription itself seems to work and I'm getting data changes.

You must be logged in to vote

Replies: 2 comments · 4 replies

Comment options

Hmm, that seems like a reasonable expectation. I wonder if the syncState isn't being updated after synchronizeMonitoredItems() or any of the other item modification methods run.

I'll look into it. Seems like it could be a bug.

You must be logged in to vote
2 replies
@kevinherron
Comment options

Yeah, it looks like originally OpcUaSubscription.SyncState was about tracking creation of and modifications to the Subscription settings, not including adding/removing MonitoredItems, then at some point grew to include MonitoredItem add/remove, but the logic isn't complete.

@dcntrd
Comment options

Yes, I can confirm that the syncState = SYNCHRONIZED after

uaSubscription.create();

after

uaSubscription.addMonitoredItem(monitoredDataItem);

it is UNSYNCHRONIZED

and after

subscription.synchronizeMonitoredItems();

it stays UNSYCHRONIZED

Comment options

Okay, so what I'm leaning towards is: fully decouple OpcUaSubscription.SyncState from monitored items, like I think was the original intention. There's already a OpcUaMonitoredItem.SyncState for each item.

This means OpcUaSubscription.SyncState is only about Subscription creation and settings sync; adding and removing items would not change this state.

Then add isFullySynchronized() and possibly getAggregateSyncState() that would allow you to get the combined state of subscription + item synchronization. AggregateSyncState would be a new enum or something. Might be enough to just have the boolean isFullySynchronized() that was something like:

public boolean isFullySynchronized() {
    return syncState == SyncState.SYNCHRONIZED
        && monitoredItems.values().stream()
               .allMatch(item -> item.getSyncState() == OpcUaMonitoredItem.SyncState.SYNCHRONIZED);
}
You must be logged in to vote
2 replies
@dcntrd
Comment options

Sounds good

@kevinherron
Comment options

#1726

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.