![](dotnetdiagramimages/OpcLabs_EasyOpcUA_OpcLabs_EasyOpc_UA_OperationModel_UAMonitoredItemArguments.png)
'Declaration
<CLSCompliantAttribute(True)> <ComDefaultInterfaceAttribute(OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UAMonitoredItemArguments)> <ComVisibleAttribute(True)> <GuidAttribute("2A0F366C-98F5-4651-AEB4-D9D57C6AD86A")> <TypeConverterAttribute(System.ComponentModel.ExpandableObjectConverter)> <ValueControlAttribute("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.81.455.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", DefaultReadWrite=False, Export=True, PageId=10001)> <SerializableAttribute()> Public Class UAMonitoredItemArguments Inherits UAAttributeArguments Implements LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.OperationModel.ComTypes._OperationArguments, OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UAAttributeArguments, OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UAMonitoredItemArguments, OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UANodeArguments, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
'Usage
Dim instance As UAMonitoredItemArguments
[CLSCompliant(true)] [ComDefaultInterface(OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UAMonitoredItemArguments)] [ComVisible(true)] [Guid("2A0F366C-98F5-4651-AEB4-D9D57C6AD86A")] [TypeConverter(System.ComponentModel.ExpandableObjectConverter)] [ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.81.455.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", DefaultReadWrite=false, Export=true, PageId=10001)] [Serializable()] public class UAMonitoredItemArguments : UAAttributeArguments, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.OperationModel.ComTypes._OperationArguments, OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UAAttributeArguments, OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UAMonitoredItemArguments, OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UANodeArguments, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
[CLSCompliant(true)] [ComDefaultInterface(OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UAMonitoredItemArguments)] [ComVisible(true)] [Guid("2A0F366C-98F5-4651-AEB4-D9D57C6AD86A")] [TypeConverter(System.ComponentModel.ExpandableObjectConverter)] [ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.81.455.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", DefaultReadWrite=false, Export=true, PageId=10001)] [Serializable()] public ref class UAMonitoredItemArguments : public UAAttributeArguments, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.OperationModel.ComTypes._OperationArguments, OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UAAttributeArguments, OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UAMonitoredItemArguments, OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UANodeArguments, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
Subscription is initiated by calling one of the SubscribeMonitoredItem, SubscribeDataChange, or SubscribeMultipleMonitoredItems method. For any significant change in the subscribed item, your application will receive the DataChangeNotification event notification, described further below. Obviously, you first need to hook up event handler for that event, and in order to prevent event loss, you should do it before subscribing. Alternatively, you can pass a callback method into the SubscribeMonitoredItem, SubscribeDataChange or SubscribeMultipleMonitoredItems call.
Some items may be changing quite frequently, and receiving all changes that are generated is not desirable for performance reasons; there are also physical limitations to the event throughput in the system. You may also want to influence the amount of received information, or control how and how often the information is delivered. QuickOPC-UA has two sets of parameters for this: subscription parameters and monitoring parameters.
Subscription parameters (can be fully contained in UASubscriptionParameters object) influence the information delivery. Main subscription parameters are the relative priority, and publishing interval (in milliseconds). The publishing interval defines the cyclic rate that the subscription is requested to return notifications to the client.
Monitoring parameters (can be fully contained in UAMonitoringParameters object) influence which information is delivered to the client. Main monitoring parameters are the data change filter (optional), size of monitored item queue, and sampling interval (in milliseconds; it is the fastest rate at which the monitored items should be accessed and evaluated).
The data change filter, if present, is contained in the UADataChangeFilter object, and defines the conditions under which a data change notification should be reported and, optionally, a deadband for value changes where no notification is generated. The Trigger property selects whether a notification is generated only when the status code associated with the value changes, or either the status code or the value change, or if any of the status code, value, or a source timestamp change. The DeadbandType property determines the type of deadband used, and can either select no deadband, absolute deadband, or percent deadband.
There are implicit conversions available from System.Double and UADataChangeTrigger to UADataChangeFilter. This allows the developer to simply use the absolute deadband, or the trigger selection, in place of any data change filter.
In order to make the settings of various parameters easier, QuickOPC-UA allows you to omit the specification of publishing interval in subscription parameters by leaving it at zero (the default). In this case, the component will calculate the publishing interval by dividing the sampling interval by the so-called automatic publishing factor (EasyUAClient.SharedParameters.EngineParameters.AutomaticPublishingFactor) with a default pre-set by the component. The resulting value is limited by the value of EasyUAClient.SharedParameters.EngineParameters.FastestAutomaticPublishingInterval property. This algorithm should determine a suitable publishing interval in the most common cases.
If you want to subscribe to a specific value in OPC address space, call the SubscribeDataChange or SubscribeMonitoredItem method. These methods have number of overloads, but in its simplest form, only three arguments are necessary: an endpoint descriptor, node ID, and a sampling interval. Other callbacks allow you to specify e.g. the callback method, a user-defined state object, absolute deadband value, or pass in a full set of parameters using EasyUAMonitoredItemArguments object. The SubscribeDataChange and SubscribeMonitoredItem methods return a subscription handle that you can later use to change the subscription parameters, or unsubscribe.
It is common to pass in a State argument of type Object. When the monitored item’s value changes, the State argument is then passed to the DataChangeNotification event handler (or your callback method) in the EasyUADataChangeNotificationEventArgs.Arguments object.
The State argument is typically used to provide some sort of correlation between objects in your application, and the event notifications. For example, if you are programming an HMI application and you want the event handler to update the control that displays the item’s value, you may want to set the State argument to the control object itself. When the event notification arrives, you simply update the control indicated by the State property of EasyUADataChangeNotificationEventArgs.Arguments, without having to look it up by Node Id or so. See Use the state instead of handles to identify subscribed entities.
To subscribe to multiple items simultaneously in an efficient manner, call the SubscribeMultipleMonitoredItems method (instead of multiple SubscribeDataChange or SubscribeMonitoredItem calls in a loop). You receive back an array of subscription handles. You pass in an array of EasyUAMonitoredItemArguments objects (each containing information for a single subscription to be made), to the SubscribeMultipleMonitoredItems method.
If you are only interested in certain kinds of changes in the monitored item, or need to reduce the amount of incoming notifications by specifying a deadband, use OPC UA Data Change Filter.
Note: It is NOT an error to subscribe to the same item twice (or more times), even with precisely same parameters. You will receive separate subscription handles, and with regard to your application, this situation will look no different from subscribing to different items. Internally, however, the subscription made to the OPC server might be optimized (merged together), depending on other parameters and circumstances.
OPC UA has one underlying mechanism for subscriptions, and the mechanism is further differentiated by the arguments used and the types of notifications generated. The general subscription mechanism refers to "monitored items", and in the current OPC UA version, the monitored item can represent two types of subscriptions: a subscription to either data changes, or events. The distinction is made by the type of filter specified with the subscription (in its monitoring parameters): It is either a data change filter, or an event filter. Depending on which type of subscription (filter) the monitored item uses, either data change notifications, or event notifications, are generated by the subscription.
Subscription methods that have "MonitoredItem" in their name are the most general ones. They allow you to create either data change or event subscriptions, depending on the data you pass in.
Subscription methods that have "DataChange" in their name are designed to create data change subscriptions only. Because of this specialization, they can have simplified set of arguments that makes most sense with data change subscriptions. These methods, however, do not do anything new as far as OPC UA subscriptions go: They just call the SubscribeMultipleMonitoredItems method internally, creating the generalized input arguments for it as needed.
Subscription methods that have "Event" in their name are designed to create event subscriptions only. Because of this specialization, they can have simplified set of arguments that makes most sense with event subscriptions. These methods, however, also do not do anything new as far as OPC UA subscriptions go: They just call the SubscribeMultipleMonitoredItems method internally, creating the generalized input arguments for it as needed.
You can use the more specialized methods if they provide the functionality you need, and give shorter code. In some cases, the more advanced functionality might be missing from the specialized methods, and in that case you should use the generalized methods and assemble the input arguments yourself.
The example below logs OPC Unified Architecture data changes into an XML file.
The main program:
System.Object
OpcLabs.BaseLib.Object2
OpcLabs.BaseLib.Info
OpcLabs.BaseLib.OperationModel.OperationArguments
OpcLabs.EasyOpc.UA.OperationModel.UANodeArguments
OpcLabs.EasyOpc.UA.OperationModel.UAAttributeArguments
OpcLabs.EasyOpc.UA.OperationModel.UAMonitoredItemArguments
OpcLabs.EasyOpc.UA.OperationModel.EasyUAMonitoredItemArguments