Class OpcUaSubscription
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe state of the Subscription as it exists on the server, after the most recent successful operation.static interfacestatic enum -
Constructor Summary
ConstructorsConstructorDescriptionOpcUaSubscription(OpcUaClient client) OpcUaSubscription(OpcUaClient client, double publishingInterval) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a MonitoredItem to this Subscription.voidaddMonitoredItems(List<OpcUaMonitoredItem> items) Add a group of MonitoredItems to this Subscription.voidcreate()Create this Subscription on the Server.CompletionStage<org.eclipse.milo.opcua.stack.core.util.Unit>Create this Subscription on the Server.Create any MonitoredItems that have been added to the Subscription but not yet created on the Server.Create any MonitoredItems that have been added to the Subscription but not yet created on the Server, filtered by the given predicate.voiddelete()Delete this Subscription from the Server.CompletionStage<org.eclipse.milo.opcua.stack.core.util.Unit>Delete this Subscription from the Server.Delete any MonitoredItems that have been removed from the Subscription.Get the client this Subscription belongs to.org.eclipse.milo.opcua.stack.core.util.TaskQueueGet the TaskQueue used to deliver notifications for this Subscription.org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UIntegerGet the current LifetimeCount for this Subscription.org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UIntegerGet the current MaxKeepAliveCount for this Subscription.org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UIntegerGet the Subscription's MaxNotificationsPerPublish setting.Get a list of the MonitoredItems belonging to this Subscription.org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UByteGet the Subscription's Priority setting.Get the current PublishingInterval for this Subscription.Optional<org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger>Get the revised LifetimeCount from the most recent create or modify operation.Optional<org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger>Get the revised MaxKeepAliveCount from the most recent create or modify operation.Get the revised PublishingInterval from the most recent create or modify operation.Optional<org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger>Get the SubscriptionId assigned to this Subscription by the Server.booleanGet whether publishing is enabled for this Subscription.voidmodify()Call the ModifySubscription service to update the Subscription's parameters on the Server.CompletionStage<org.eclipse.milo.opcua.stack.core.util.Unit>Call the ModifySubscription service to update the Subscription's parameters on the Server.Modify any MonitoredItems that have been changed.voidnotifyTransferFailed(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode status) voidRemove a MonitoredItem from this Subscription.voidRemove a group of MonitoredItems from this Subscription.voidreset()Reset this Subscription.voidsetLifetimeAndKeepAliveCalculated(boolean lifetimeAndKeepAliveCalculated) Set whether the LifetimeCount and MaxKeepAliveCount should be calculated automatically any time the PublishingInterval is set.voidsetLifetimeCount(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger lifetimeCount) Set a new LifetimeCount for this Subscription.voidsetMaxKeepAliveCount(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger maxKeepAliveCount) Set a new MaxKeepAliveCount for this Subscription.voidsetMaxMonitoredItemsPerCall(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger maxMonitoredItemsPerCall) Set the maximum number of MonitoredItems that can be created/modified/deleted in a single service call.voidsetMaxNotificationsPerPublish(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger maxNotificationsPerPublish) Set a new MaxNotificationsPerPublish for this Subscription.setMonitoringMode(org.eclipse.milo.opcua.stack.core.types.enumerated.MonitoringMode monitoringMode, List<OpcUaMonitoredItem> monitoredItems) Set theMonitoringModefor a group of MonitoredItems.voidsetPriority(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UByte priority) Set a new Priority for this Subscription.voidsetPublishingInterval(Double publishingInterval) Set a new PublishingInterval for this Subscription.voidsetPublishingMode(boolean enabled) Set the publishing mode, i.e. enable or disable publishing, for this Subscription.CompletionStage<org.eclipse.milo.opcua.stack.core.util.Unit>setPublishingModeAsync(boolean enabled) Set the publishing mode, i.e. enable or disable publishing, for this Subscription.voidsetSubscriptionListener(@Nullable OpcUaSubscription.SubscriptionListener listener) Set theOpcUaSubscription.SubscriptionListenerfor this Subscription.voidsetTargetKeepAliveInterval(double targetKeepAliveInterval) Set the target keep-alive interval, in milliseconds, for this Subscription.voidsetUserObject(@Nullable Object userObject) Associate an arbitrary user object with this Subscription.voidsetWatchdogMultiplier(double watchdogMultiplier) Set the multiplier used to calculate the watchdog timeout.voidSynchronize the Subscription's MonitoredItems with the Server.toString()
-
Constructor Details
-
OpcUaSubscription
-
OpcUaSubscription
-
-
Method Details
-
getClient
Get the client this Subscription belongs to.- Returns:
- the
OpcUaClientthis Subscription belongs to.
-
create
public void create() throws org.eclipse.milo.opcua.stack.core.UaExceptionCreate this Subscription on the Server.- Throws:
org.eclipse.milo.opcua.stack.core.UaException- if a service- or operation-level error occurs.
-
createAsync
Create this Subscription on the Server.- Returns:
- a
CompletionStagethat completes successfully if the Subscription was created, or completes exceptionally if there was a service- or operation-level error.
-
modify
public void modify() throws org.eclipse.milo.opcua.stack.core.UaExceptionCall the ModifySubscription service to update the Subscription's parameters on the Server.- Throws:
org.eclipse.milo.opcua.stack.core.UaException- if a service- or operation-level error occurs.
-
modifyAsync
Call the ModifySubscription service to update the Subscription's parameters on the Server.- Returns:
- a
CompletionStagethat completes successfully if the Subscription was modified, or completes exceptionally if there was a service- or operation-level error.
-
delete
public void delete() throws org.eclipse.milo.opcua.stack.core.UaExceptionDelete this Subscription from the Server.- Throws:
org.eclipse.milo.opcua.stack.core.UaException- if a service- or operation-level error occurs.
-
deleteAsync
Delete this Subscription from the Server.- Returns:
- a
CompletionStagethat completes successfully if the Subscription was deleted, or completes exceptionally if there was a service- or operation-level error.
-
addMonitoredItem
Add a MonitoredItem to this Subscription.This item will not be created on the server until
synchronizeMonitoredItems()is called.- Parameters:
item- the MonitoredItem to add.- Throws:
org.eclipse.milo.opcua.stack.core.UaRuntimeException- if the Subscription has not been created yet.
-
addMonitoredItems
Add a group of MonitoredItems to this Subscription.These items will not be created on the server until
synchronizeMonitoredItems()is called.- Parameters:
items- the MonitoredItems to add.- Throws:
org.eclipse.milo.opcua.stack.core.UaRuntimeException- if the Subscription has not been created yet.
-
removeMonitoredItem
Remove a MonitoredItem from this Subscription.This item will not be deleted from the server until
synchronizeMonitoredItems()is called- Parameters:
item- the MonitoredItem to remove.
-
removeMonitoredItems
Remove a group of MonitoredItems from this Subscription.These items will not be deleted from the server until
synchronizeMonitoredItems()is called.- Parameters:
items- the MonitoredItems to remove.- Throws:
org.eclipse.milo.opcua.stack.core.UaRuntimeException- if the Subscription has not been created yet.
-
synchronizeMonitoredItems
Synchronize the Subscription's MonitoredItems with the Server.This is a compound operation that deletes any MonitoredItems that have been removed from the Subscription, modifies any existing MonitoredItems that have been changed, and creates any new MonitoredItems that have been added but not yet created on the Server.
- Throws:
MonitoredItemSynchronizationException- if one or more MonitoredItems failed to synchronize for any reason. This could be a service-level failure or an operation-level failure. Check theMonitoredItemServiceOperationResults for details.
-
createMonitoredItems
Create any MonitoredItems that have been added to the Subscription but not yet created on the Server.- Returns:
- a List of
MonitoredItemServiceOperationResults that contain the MonitoredItem and the service- and operation-level results associated with the attempt to create it.
-
createMonitoredItems
public List<MonitoredItemServiceOperationResult> createMonitoredItems(Predicate<OpcUaMonitoredItem> filter) Create any MonitoredItems that have been added to the Subscription but not yet created on the Server, filtered by the given predicate.This could be used to e.g. further restrict the MonitoredItems to be created to only those that have not had a previous creation attempt:
List
results = subscription.createMonitoredItems( item -> item.getCreateResult().isEmpty() ); - Parameters:
filter- a predicate that allows further restriction of the MonitoredItems to be created.- Returns:
- a List of
MonitoredItemServiceOperationResults that contain the MonitoredItem and the service- and operation-level results associated with the attempt to create it.
-
modifyMonitoredItems
Modify any MonitoredItems that have been changed.- Returns:
- a List of the MonitoredItems that were modified.
-
deleteMonitoredItems
Delete any MonitoredItems that have been removed from the Subscription.- Returns:
- a List of the MonitoredItems that were deleted.
-
setMonitoringMode
public List<MonitoredItemServiceOperationResult> setMonitoringMode(org.eclipse.milo.opcua.stack.core.types.enumerated.MonitoringMode monitoringMode, List<OpcUaMonitoredItem> monitoredItems) Set theMonitoringModefor a group of MonitoredItems.These MonitoredItems must exist on the Server before setting the MonitoringMode.
- Parameters:
monitoringMode- the MonitoringMode to set.monitoredItems- the MonitoredItems to set the MonitoringMode for.- Returns:
- a List of
MonitoredItemServiceOperationResults that contain the MonitoredItem and the service- and operation-level results associated with the attempt to set the MonitoringMode.
-
setPublishingMode
public void setPublishingMode(boolean enabled) throws org.eclipse.milo.opcua.stack.core.UaException Set the publishing mode, i.e. enable or disable publishing, for this Subscription.- Parameters:
enabled-trueto enable publishing,falseto disable publishing.- Throws:
org.eclipse.milo.opcua.stack.core.UaException- if a service- or operation-level error occurs.
-
setPublishingModeAsync
public CompletionStage<org.eclipse.milo.opcua.stack.core.util.Unit> setPublishingModeAsync(boolean enabled) Set the publishing mode, i.e. enable or disable publishing, for this Subscription.- Parameters:
enabled-trueto enable publishing,falseto disable publishing.- Returns:
- a
CompletionStagethat completes successfully if the operation was successful, or completes exceptionally if there was a service- or operation-level error.
-
getSyncState
- Returns:
- the current
OpcUaSubscription.SyncStateof this Subscription.
-
getServerState
- Returns:
- the current
OpcUaSubscription.ServerStateof this Subscription, if it has been created.
-
getMonitoredItems
Get a list of the MonitoredItems belonging to this Subscription.If
synchronizeMonitoredItems()has not been called since adding or removing MonitoredItems, this List may not represent the server's view of the MonitoredItems.- Returns:
- a List of the MonitoredItems belonging to this Subscription.
-
getPublishingInterval
Get the current PublishingInterval for this Subscription.The server may have revised it upon creation or modification.
- Returns:
- the current PublishingInterval for this Subscription.
- See Also:
-
getLifetimeCount
public org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger getLifetimeCount()Get the current LifetimeCount for this Subscription.The server may have revised it upon creation or modification.
- Returns:
- the current LifetimeCount for this Subscription.
- See Also:
-
getMaxKeepAliveCount
public org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger getMaxKeepAliveCount()Get the current MaxKeepAliveCount for this Subscription.The server may have revised it upon creation or modification.
- Returns:
- the current MaxKeepAliveCount for this Subscription.
- See Also:
-
getPriority
public org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UByte getPriority()Get the Subscription's Priority setting.The Server does not revise this setting, so the value reflects the most recently requested by a create or modify operation.
- Returns:
- the Subscription's Priority setting.
-
getMaxNotificationsPerPublish
public org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger getMaxNotificationsPerPublish()Get the Subscription's MaxNotificationsPerPublish setting.The Server does not revise this setting, so the value reflects the most recently requested by a create or modify operation.
- Returns:
- the Subscription's MaxNotificationsPerPublish setting.
-
isPublishingEnabled
Get whether publishing is enabled for this Subscription.This is available only after the Subscription has been created.
- Returns:
trueif publishing is enabled for this Subscription.
-
getSubscriptionId
public Optional<org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger> getSubscriptionId()Get the SubscriptionId assigned to this Subscription by the Server.The SubscriptionId is available only after the Subscription has been created.
- Returns:
- the SubscriptionId assigned to this Subscription by the Server.
-
getRevisedPublishingInterval
Get the revised PublishingInterval from the most recent create or modify operation.The revised PublishingInterval is available only after the Subscription has been created or modified.
- Returns:
- the revised PublishingInterval from the most recent create or modify operation.
-
getRevisedLifetimeCount
public Optional<org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger> getRevisedLifetimeCount()Get the revised LifetimeCount from the most recent create or modify operation.The revised LifetimeCount is available only after the Subscription has been created or modified.
- Returns:
- the revised LifetimeCount from the most recent create or modify operation.
-
getRevisedMaxKeepAliveCount
public Optional<org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger> getRevisedMaxKeepAliveCount()Get the revised MaxKeepAliveCount from the most recent create or modify operation.The revised MaxKeepAliveCount is available only after the Subscription has been created or modified.
- Returns:
- the revised MaxKeepAliveCount from the most recent create or modify operation.
-
setPublishingInterval
Set a new PublishingInterval for this Subscription.If the Subscription has not yet been created, this will be the PublishingInterval used during the create service call.
If the Subscription has already been created, this will be the PublishingInterval used during the next modify service call.
- Parameters:
publishingInterval- the new PublishingInterval.- See Also:
-
setLifetimeCount
public void setLifetimeCount(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger lifetimeCount) Set a new LifetimeCount for this Subscription.If the Subscription has not yet been created, this will be the LifetimeCount used during the create service call.
If the Subscription has already been created, this will be the LifetimeCount used during the next modify service call.
- Parameters:
lifetimeCount- the new LifetimeCount.- See Also:
-
setMaxKeepAliveCount
public void setMaxKeepAliveCount(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger maxKeepAliveCount) Set a new MaxKeepAliveCount for this Subscription.If the Subscription has not yet been created, this will be the MaxKeepAliveCount used during the create service call.
If the Subscription has already been created, this will be the MaxKeepAliveCount used during the next modify service call.
- Parameters:
maxKeepAliveCount- the new MaxKeepAliveCount.- See Also:
-
setPriority
public void setPriority(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UByte priority) Set a new Priority for this Subscription.If the Subscription has not yet been created, this will be the Priority used during the create service call.
If the Subscription has already been created, this will be the Priority used during the next modify service call.
- Parameters:
priority- the new Priority.- See Also:
-
setMaxNotificationsPerPublish
public void setMaxNotificationsPerPublish(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger maxNotificationsPerPublish) Set a new MaxNotificationsPerPublish for this Subscription.If the Subscription has not yet been created, this will be the MaxNotificationsPerPublish used during the create service call.
If the Subscription has already been created, this will be the MaxNotificationsPerPublish used during the next modify service call.
- Parameters:
maxNotificationsPerPublish- the new MaxNotificationsPerPublish.- See Also:
-
setLifetimeAndKeepAliveCalculated
public void setLifetimeAndKeepAliveCalculated(boolean lifetimeAndKeepAliveCalculated) Set whether the LifetimeCount and MaxKeepAliveCount should be calculated automatically any time the PublishingInterval is set.- Parameters:
lifetimeAndKeepAliveCalculated-trueif the LifetimeCount and MaxKeepAliveCount should be calculated automatically.- See Also:
-
isLifetimeAndKeepAliveCalculated
public boolean isLifetimeAndKeepAliveCalculated()- Returns:
trueif the LifetimeCount and MaxKeepAliveCount are calculated automatically any time the Publishing Interval is set.- See Also:
-
setTargetKeepAliveInterval
public void setTargetKeepAliveInterval(double targetKeepAliveInterval) Set the target keep-alive interval, in milliseconds, for this Subscription.The Subscription must be configured to automatically calculate the Lifetime and KeepAlive for this to have any effect. MaxKeepAliveCount and LifetimeCount will be recalculated based on the target value. The Subscription settings must be synchronized before this change takes effect.
- Parameters:
targetKeepAliveInterval- the target keep-alive interval, in milliseconds.- See Also:
-
setMaxMonitoredItemsPerCall
public void setMaxMonitoredItemsPerCall(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger maxMonitoredItemsPerCall) Set the maximum number of MonitoredItems that can be created/modified/deleted in a single service call.This value is compared against the value read from the Server's OperationLimits object, and the smaller of the two is used.
- Parameters:
maxMonitoredItemsPerCall- the maximum number of MonitoredItems that can be created/modified/deleted in a single service call.
-
setWatchdogMultiplier
public void setWatchdogMultiplier(double watchdogMultiplier) Set the multiplier used to calculate the watchdog timeout. The multiplier is applied to the keep-alive interval.- Parameters:
watchdogMultiplier- the watchdog multiplier.
-
setSubscriptionListener
Set theOpcUaSubscription.SubscriptionListenerfor this Subscription.- Parameters:
listener- theOpcUaSubscription.SubscriptionListenerfor this Subscription.
-
setUserObject
Associate an arbitrary user object with this Subscription.- Parameters:
userObject- the user object to associate with this Subscription.
-
getUserObject
- Returns:
- the user object associated with this Subscription.
-
getDeliveryQueue
public org.eclipse.milo.opcua.stack.core.util.TaskQueue getDeliveryQueue()Get the TaskQueue used to deliver notifications for this Subscription.- Returns:
- the TaskQueue used to deliver notifications for this Subscription.
-
reset
public void reset()Reset this Subscription.Resetting the Subscription removes it from the Client and PublishingManager, cancels the watchdog timer, and sets the
OpcUaSubscription.SyncStateback toOpcUaSubscription.SyncState.INITIAL.OpcUaMonitoredItems that have been added are reset, but the collection is not cleared. If the Subscription is created again, the callsynchronizeMonitoredItems()orcreateMonitoredItems()to create the items on the Server again.This is called automatically when the Subscription is deleted, but can also be called manually when necessary if it has been determined the Subscription no longer exists on the Server.
-
toString
-
notifyTransferFailed
public void notifyTransferFailed(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode status)
-