UA Bundle SDK .NET  2.2.1.258
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Groups Pages
Monitored Items – Set Monitoring Mode

Prerequisites

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

Description

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

All currently monitored items are shown in the list at the bottom of the dialog window. Check the box in front of an item to show the current monitoring mode in the grayed-out box. Select the desired monitoring mode from the drop-down menu and check the boxes in front of the items to modify. Press the button “Modify” to apply the changes. Check the box in front of “Use Asynchronous Pattern” to call “BeginModify” instead of “Modify”.

Sample Code

The following code changes the monitoring mode for a set of 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.SetMonitoringMode(
(MonitoringMode)MonitoringModeCB.SelectedItem,
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.Show(this.Text, exception);
}