.NET Based OPC UA Client/Server SDK  3.3.3.537
Data Monitored Items – Create Data Monitored Items

Prerequisites

A session and a subscription with the server must be established.

Description

The following dialog shows an example dialog for creating data monitored items. Press the button “Show Code” to display the corresponding code, and the button “Help” to show this documentation page.

clienttutorials_create_data_monitored_items.png

Enter the desired values for “Sampling Interval” and “Queue Size” into the corresponding input fields at “Monitoring Parameters”. To set the Sampling Interval to the same value as the Publishing Interval, enter “-1”. Check the box near “Discard Oldest” to discard the oldest values when the queue overflows. At “Monitoring Mode”, you can choose between “Reporting”, “Sampling” and “Disabled”. Choose between “None”, “Absolute” and “Percent” at the drop-down menu “Deadband Type” and enter the corresponding value at “Deadband”.

Press the button “Select Node” to open a browse window for selecting the variables to monitor. After selection, the variables are listed at “Monitored Items to Create”. Press the button “Create” to actually start monitoring the attribute Value of the listed items. Check the box in front of “Use Asynchronous Pattern” to call “BeginCreate” instead of “Create”.

clienttutorials_create_data_monitored_items2.png

An error will be displayed if the attribute variable doesn’t exist for a chosen node. Select a monitored item from the list to display the monitoring parameters set by the server in the grayed-out fields at “Monitoring Parameters”.

Sample Code

The following code starts monitoring the attribute “Value” of a specified node using the given monitoring parameters. The revised monitoring parameters and the status code are displayed in the dialog window.

// build list of items which have not been added yet.
List<MonitoredItem> monitoredItems = new List<MonitoredItem>();
foreach (ListViewItem item in MonitoredItemsLV.Items)
{
MonitoredItem monitoredItem = (MonitoredItem)item.Tag;
if (monitoredItem.ClientHandle == 0)
{
monitoredItem.UserData = item;
monitoredItems.Add(monitoredItem);
}
}
// create monitored items.
List<StatusCode> results = m_subscription.CreateMonitoredItems(
monitoredItems,
new RequestSettings() { OperationTimeout = 10000 });