.NET Based OPC UA Client/Server SDK  3.1.0.500
Event Monitored Items – Modify Event Monitored Items

Prerequisites

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

Description

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

clienttutorials_modify_event_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 box in front of an item and press the button “Event Filter” to add, edit, or delete BaseEventTypes for each item.

clienttutorials_create_event_monitored_items3.png

Choose “Add” to open a browse window and choose additional filters.

clienttutorials_create_event_monitored_items4.png

To modify a variable, choose “Edit” from the context menu, and double click on the value to open a dialog window for editing.

clienttutorials_create_event_monitored_items5.png

When finished, press the button “Modify” to actually modify the monitoring parameters and event filters of the selected items. Check the box in front of “Use Asynchronous Pattern” to call “BeginModify” instead of “Modify”.

Sample Code

The following code modifies the monitoring parameters and the event filter for existing monitored items.

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);
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;
}