public abstract class SubscriptionBase extends Object implements Comparable<SubscriptionBase>
| Modifier and Type | Field and Description |
|---|---|
protected Map<UnsignedInteger,MonitoredItemBase> |
items |
protected long |
lifetimeCount |
protected long |
maxKeepAliveCount |
protected int |
maxNotificationsPerPublish |
protected int |
priority |
protected boolean |
publishingEnabled |
protected double |
publishingInterval |
protected int |
updateCount |
| Constructor and Description |
|---|
SubscriptionBase(UnsignedInteger id,
boolean publishingEnabled,
double publishingInterval,
long lifetimeCount,
long maxKeepAliveCount,
int maxNotificationsPerPublish,
int priority) |
SubscriptionBase(UnsignedInteger id,
Boolean publishingEnabled,
Double publishingInterval,
UnsignedInteger lifetimeCount,
UnsignedInteger maxKeepAliveCount,
UnsignedInteger maxNotificationsPerPublish,
UnsignedByte priority) |
| Modifier and Type | Method and Description |
|---|---|
void |
addItem(MonitoredItemBase item,
UnsignedInteger itemId)
Add a new monitoring item to the subscription.
|
protected void |
applyUpdates()
Apply the pending modifications guarded by beginUpdate/endUpdate.
|
void |
beginUpdate()
Starts a property or item modification sequence.
|
int |
compareTo(SubscriptionBase s) |
protected void |
enabledChanged()
Handles a change in PublishingEnabled
|
void |
endUpdate()
Ends a property or item modification, which was started with
beginUpdate(). |
MonitoredItemBase |
getItem(NodeId nodeId)
Find the item that is listening to the specified node.
|
MonitoredItemBase |
getItem(NodeId nodeId,
UnsignedInteger attributeId)
Find the item that is listening to the specified node attribute.
|
MonitoredItemBase |
getItem(UnsignedInteger itemId)
Get an item from the subscription.
|
int |
getItemCount() |
MonitoredItemBase[] |
getItems() |
long |
getLifetimeCount()
The lifetime count should be a mimimum of three times the keep-alive count.
|
long |
getMaxKeepAliveCount()
Max keep alive count defines the number of Publishing Intervals that may pass without any
notification being sent.
|
int |
getMaxNotificationsPerPublish()
The maximum number of notifications that the Client wishes to receive in a single Publish
response.
|
int |
getPriority()
Indicates the relative priority of the Subscription.
|
double |
getPublishingInterval()
This interval defines the cyclic rate that the Subscription is being requested to return
Notifications to the Client.
|
UnsignedInteger |
getSubscriptionId()
The Server-assigned identifier for the Subscription.
|
Object |
getUserData()
Returns a previously
setUserData(Object) object. |
boolean |
hasItem(NodeId nodeId)
Checks if the subscription contains an item that is listening to the specified node.
|
boolean |
hasItem(NodeId nodeId,
UnsignedInteger attributeId)
Checks if the subscription contains an item that is listening to the specified node attribute.
|
boolean |
hasItem(UnsignedInteger itemId)
Checks if the subscription contains an item with the ID.
|
boolean |
isPublishingEnabled() |
protected void |
paramChanged()
Parameter change "event".
|
abstract MonitoredItemBase |
removeItem(MonitoredItemBase item)
Remove an item from the subscription.
|
MonitoredItemBase |
removeItem(UnsignedInteger itemId)
Remove an item from the subscription.
|
void |
setLifetimeCount(long requestedLifetimeCount)
The lifetime count should be a mimimum of three times the keep-alive count.
|
void |
setLifetimeCount(UnsignedInteger requestedLifetimeCount)
The lifetime count shall be a mimimum of three times the keep-alive count.
|
void |
setMaxKeepAliveCount(long requestedMaxKeepAliveCount)
Requested rate of KeepAlive messages.
|
void |
setMaxKeepAliveCount(UnsignedInteger requestedMaxKeepAliveCount)
Requested rate of KeepAlive messages.
|
void |
setMaxNotificationsPerPublish(long maxNotificationsPerPublish)
The maximum number of notifications that the Client wishes to receive in a single Publish
response.
|
void |
setMaxNotificationsPerPublish(UnsignedInteger maxNotificationsPerPublish)
The maximum number of notifications that the Client wishes to receive in a single Notification
Message.
|
void |
setPriority(int priority)
Indicates the relative priority of the Subscription.
|
void |
setPriority(UnsignedByte priority)
Indicates the relative priority of the Subscription.
|
void |
setPublishingEnabled(boolean publishingEnabled)
A Boolean parameter with the following values :
TRUE
publishing is enabled for the Subscription.
|
void |
setPublishingInterval(double requestedPublishingInterval)
This interval defines the cyclic rate that the Subscription is being requested to return
Notifications to the Client.
|
void |
setPublishingInterval(long requestedPublishingInterval,
TimeUnit timeUnit) |
protected void |
setSubscriptionId(UnsignedInteger id) |
void |
setUserData(Object userData)
Set a custom data object to this item that can be later retrieved with
getUserData(). |
String |
toString() |
protected final Map<UnsignedInteger,MonitoredItemBase> items
protected long lifetimeCount
protected long maxKeepAliveCount
protected int maxNotificationsPerPublish
protected int priority
protected boolean publishingEnabled
protected double publishingInterval
protected int updateCount
public SubscriptionBase(UnsignedInteger id, boolean publishingEnabled, double publishingInterval, long lifetimeCount, long maxKeepAliveCount, int maxNotificationsPerPublish, int priority)
public SubscriptionBase(UnsignedInteger id, Boolean publishingEnabled, Double publishingInterval, UnsignedInteger lifetimeCount, UnsignedInteger maxKeepAliveCount, UnsignedInteger maxNotificationsPerPublish, UnsignedByte priority)
public void addItem(MonitoredItemBase item, UnsignedInteger itemId)
item - itemId - The ID to use to map the item in the list. On server side this is the
monitoredItemId. On client side it is the clientHandle.public void beginUpdate()
The method must be paired with endUpdate(), preferably with a try-finally block. You
can nest several beginUpdate/endUpdate blocks. The final endUpdate will trigger the changes
being written to the server using a modifySubscription or modifyMonitoredItems service call.
public int compareTo(SubscriptionBase s)
compareTo in interface Comparable<SubscriptionBase>public final void endUpdate()
throws ServiceException
beginUpdate().ServiceException - if the update fails due to an error in modifySubscription, modifyItems
or setMonitoringMode service call to the server. In that case, you can retry by using a
new beginUpdate/endUpdate sequence.public MonitoredItemBase getItem(NodeId nodeId)
nodeId - the listened nodepublic MonitoredItemBase getItem(NodeId nodeId, UnsignedInteger attributeId)
nodeId - the listened nodeattributeId - the attributepublic MonitoredItemBase getItem(UnsignedInteger itemId) throws StatusException
itemId - the ID of the item. On the client side this is the ClientHandle and on the server
side it is the MonitoredItemId.StatusException - if the item is not found, with StatusCode=Bad_MonitoredItemIdInvalidpublic int getItemCount()
public MonitoredItemBase[] getItems()
public long getLifetimeCount()
When the publishing timer has expired this number of times without a Publish request being available to send a NotificationMessage, then the Subscription will be deleted by the Server.
setLifetimeCount(long)public long getMaxKeepAliveCount()
If the client does not receive any notification message during the interval specified by the MaxKeepAliveCount (plus some tolerance), the subscription can be considered to be at timeout and the client can assume a problem with a connection to the server.
public int getMaxNotificationsPerPublish()
setMaxNotificationsPerPublish(long)public int getPriority()
A Client that does not require special priority settings should set this value to zero.
setPriority(int)public double getPublishingInterval()
The negotiated value for this parameter returned in the response is used as the default sample interval for MonitoredItems assigned to this Subscription.
The value 0 is invalid.
setPublishingInterval(double)public UnsignedInteger getSubscriptionId()
public Object getUserData()
setUserData(Object) object.public boolean hasItem(NodeId nodeId)
nodeId - the nodepublic boolean hasItem(NodeId nodeId, UnsignedInteger attributeId)
nodeId - the nodeattributeId - the attributepublic boolean hasItem(UnsignedInteger itemId)
itemId - the ID of the item. On the client side this is the ClientHandle and on the server
side it is the MonitoredItemId.public boolean isPublishingEnabled()
setPublishingEnabled(boolean)public abstract MonitoredItemBase removeItem(MonitoredItemBase item) throws ServiceException, StatusException
item - The item to remove.ServiceException - if the (possible) service call to delete the item from the server
fails.StatusException - if the subscription does not contain the itempublic MonitoredItemBase removeItem(UnsignedInteger itemId) throws ServiceException, StatusException
itemId - The ID of the item to remove. In the client side this should be the ClientHandle,
but on server side, the MonitoredItemId is used.ServiceException - if the service call to delete the item from the server fails.StatusException - if the delete response from the server is badpublic final void setLifetimeCount(long requestedLifetimeCount)
throws ServiceException
When the publishing timer has expired this number of times without a Publish request being available to send a NotificationMessage, then the Subscription will be deleted by the Server.
requestedLifetimeCount - The value must be in the range of UnsignedIntegerServiceException - If the parameter could not be changed.public void setLifetimeCount(UnsignedInteger requestedLifetimeCount) throws ServiceException
When the publishing timer has expired this number of times without a Publish request being available to send a NotificationMessage, then the Subscription will be deleted by the Server.
ServiceException - If the parameter could not be changed.public final void setMaxKeepAliveCount(long requestedMaxKeepAliveCount)
throws ServiceException
The value 0 is invalid.
requestedMaxKeepAliveCount - The value must be in the range of UnsignedIntegerServiceException - If the parameter could not be changed.public void setMaxKeepAliveCount(UnsignedInteger requestedMaxKeepAliveCount) throws ServiceException
The value 0 is invalid.
requestedMaxKeepAliveCount - ServiceException - If the parameter could not be changed.public final void setMaxNotificationsPerPublish(long maxNotificationsPerPublish)
throws ServiceException
maxNotificationsPerPublish - The value must be in the range of UnsignedInteger, but if the
value is bigger than Integer.MAX_VALUE, Integer.MAX_VALUE will be used instead.ServiceException - If the parameter could not be changed.public void setMaxNotificationsPerPublish(UnsignedInteger maxNotificationsPerPublish) throws ServiceException
maxNotificationsPerPublish - If the value is bigger than Integer.MAX_VALUE,
Integer.MAX_VALUE will be used instead.ServiceException - If the parameter could not be changed.public final void setPriority(int priority)
throws ServiceException
A Client that does not require special priority settings should set this value to zero.
priority - The value must be in the range of UnsignedByteServiceException - If the parameter could not be changed.public void setPriority(UnsignedByte priority) throws ServiceException
A Client that does not require special priority settings should set this value to zero.
priority - ServiceException - If the parameter could not be changed.public void setPublishingEnabled(boolean publishingEnabled)
throws ServiceException,
StatusException
| TRUE | publishing is enabled for the Subscription. |
| FALSE | publishing is disabled for the Subscription. |
publishingEnabled - the new value to setStatusException - If the parameter could not be changed due to an operation error from
the server.ServiceException - If the parameter could not be changed due to a service call error.public void setPublishingInterval(double requestedPublishingInterval)
throws ServiceException
The negotiated value for this parameter returned in the response is used as the default sample interval for MonitoredItems assigned to this Subscription.
The value 0 is invalid.
requestedPublishingInterval - requested value for the publishing interval in millisecondsServiceException - If the parameter could not be changed.public void setPublishingInterval(long requestedPublishingInterval,
TimeUnit timeUnit)
throws ServiceException
ServiceExceptionsetPublishingInterval(double)public void setUserData(Object userData)
getUserData().
This can be used to store business logic object mapping directly in the Subscription. It will
be stored using strong reference and equivalent to having the 'volatile' keyword. Set null to
remove. This data is not used in Object.equals(Object), Object.hashCode() or
toString().protected void applyUpdates()
throws ServiceException
ServiceExceptionprotected void enabledChanged()
throws ServiceException,
StatusException
ServiceExceptionStatusExceptionprotected void paramChanged()
throws ServiceException
ServiceExceptionprotected void setSubscriptionId(UnsignedInteger id)
id - Copyright © 2026. All rights reserved.