.NET Based OPC UA Client/Server SDK  3.0.10.493
Data Monitored Items – Modify Data Monitored Items

Prerequisites

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

Description

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

clienttutorials_modify_data_monitored_items.png

Check the box in front of a specific monitored item from the list to display the current monitoring parameters in the grayed-out fields. Enter the new monitoring parameters into the input fields, check the boxes in front of the items to modify and press the button “Modify”. Check the box in front of “Use Asynchronous Pattern” to call “BeginModify” instead of “Modify”. The revised monitoring parameters are now displayed in the grayed-out fields.

Sample Code

The following code modifies the monitoring parameters for existing items and displays the revised monitoring parameters and the status code in the dialog window.

try
{
// get the current session from the parent form.
Session session = m_parent.Session;
// nothing to do if no session.
if (session == null)
{
return;
}
// build list of items have been checked.
List<ListViewItem> items = new List<ListViewItem>();
List<MonitoredItem> monitoredItems = new List<MonitoredItem>();
foreach (ListViewItem item in MonitoredItemsLV.Items)
{
if (item.Checked)
{
MonitoredItem monitoredItem = (MonitoredItem)item.Tag;
monitoredItems.Add(monitoredItem);
UpdateItem(monitoredItem);
items.Add(item);
}
}
// create monitored items.
List<StatusCode> results = m_subscription.ModifyMonitoredItems(
monitoredItems,
new RequestSettings() { OperationTimeout = 10000 });
// update results in the list.
for (int ii = 0; ii < results.Count; ii++)
{
UpdateItem(items[ii], monitoredItems[ii]);
}
// display current values.
UpdateControls(monitoredItems);
// adjust widths.
foreach (ColumnHeader header in MonitoredItemsLV.Columns)
{
header.Width = -2;
}
}
catch (Exception exception)
{
ExceptionDlg.ShowInnerException(this.Text, exception);
}
finally
{
Cursor = Cursors.Default;
}