OPC Studio User's Guide and Reference
Examples - OPC XML-DA - Subscribe to multiple items with percent deadband
// This example shows how subscribe to changes of multiple items with percent deadband.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using System.Threading;
using OpcLabs.BaseLib.ComInterop;
using OpcLabs.EasyOpc;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;

namespace DocExamples.DataAccess.Xml
{
    partial class SubscribeMultipleItems
    {
        public static void PercentDeadbandXml()
        {
            // Instantiate the client object.
            using (var client = new EasyDAClient())
            {
                client.ItemChanged += client_PercentDeadband_ItemChanged;

                Console.WriteLine("Subscribing with different percent deadbands...");
                client.SubscribeMultipleItems(
                    new[] {
                            new DAItemGroupArguments("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", new DAItemDescriptor("Dynamic/Analog Types/Int", 
                                VarTypes.Empty), new DAGroupParameters(requestedUpdateRate:100, percentDeadband:10.0f), null), 
                            new DAItemGroupArguments("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", new DAItemDescriptor("Dynamic/Analog Types/Double",
                                VarTypes.Empty), new DAGroupParameters(requestedUpdateRate:100, percentDeadband:5.0f), null),
                        });

                Console.WriteLine("Processing item changed events for 1 minute...");
                Thread.Sleep(60 * 1000);
            }
        }

        // Item changed event handler
        static void client_PercentDeadband_ItemChanged(object sender, EasyDAItemChangedEventArgs e)
        {
            if (e.Succeeded)
                Console.WriteLine("{0}: {1}", e.Arguments.ItemDescriptor.ItemId, e.Vtq);
            else
                Console.WriteLine("{0} *** Failure: {1}", e.Arguments.ItemDescriptor.ItemId, e.ErrorMessageBrief);
        }
    }
}
# This example shows how subscribe to changes of multiple items with percent deadband.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc
import time

# Import .NET namespaces.
from OpcLabs.BaseLib.ComInterop import *
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.DataAccess.OperationModel import *


# Item changed event handler
def itemChanged(sender, e):
    if e.Succeeded:
        print(e.Arguments.ItemDescriptor.ItemId, ': ', e.Vtq, sep='')
    else:
        print(e.Arguments.ItemDescriptor.ItemId, ' *** Failure: ', e.ErrorMessageBrief, sep='')


# Instantiate the client object
client = EasyDAClient()
client.ItemChanged += itemChanged

print('Subscribing with different percent deadbands...')
IEasyDAClientExtension.SubscribeMultipleItems(client,
    [
        DAItemGroupArguments(
            ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'),
            DAItemDescriptor('Dynamic/Analog Types/Int', VarType(VarTypes.Empty)),
            DAGroupParameters(100, 10.0),
            None),
        DAItemGroupArguments(
            ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'),
            DAItemDescriptor('Dynamic/Analog Types/Double', VarType(VarTypes.Empty)),
            DAGroupParameters(100, 5.0),
            None),
    ])

print('Processing item change notifications for 1 minute...')
time.sleep(60)

print('Unsubscribing all items...')
client.UnsubscribeAllItems()

client.ItemChanged -= itemChanged

print('Finished.')
' This example shows how subscribe to changes of multiple items with percent deadband.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports System.Threading
Imports OpcLabs.BaseLib.ComInterop
Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.OperationModel

Namespace DataAccess.Xml
    Partial Friend Class SubscribeMultipleItems
        Public Shared Sub PercentDeadbandXml()
            ' Instantiate the client object.
            Using client = New EasyDAClient()
                AddHandler client.ItemChanged, AddressOf client_PercentDeadband_ItemChanged

                Console.WriteLine("Subscribing with different percent deadbands...")
                client.SubscribeMultipleItems(New DAItemGroupArguments() {
                    New DAItemGroupArguments("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", New DAItemDescriptor("Dynamic/Analog Types/Int",
                                VarTypes.Empty), New DAGroupParameters(requestedUpdateRate:=100, percentDeadband:=10.0F), Nothing),
                    New DAItemGroupArguments("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", New DAItemDescriptor("Dynamic/Analog Types/Double",
                                VarTypes.Empty), New DAGroupParameters(requestedUpdateRate:=100, percentDeadband:=5.0F), Nothing)
                    })

                Console.WriteLine("Processing item changed events for 1 minute...")
                Thread.Sleep(60 * 1000)
            End Using
        End Sub

        ' Item changed event handler
        Private Shared Sub client_PercentDeadband_ItemChanged(ByVal sender As Object, ByVal e As EasyDAItemChangedEventArgs)
            If e.Succeeded Then
                Console.WriteLine("{0}: {1}", e.Arguments.ItemDescriptor.ItemId, e.Vtq)
            Else
                Console.WriteLine("{0} *** Failure: {1}", e.Arguments.ItemDescriptor.ItemId, e.ErrorMessageBrief)
            End If
        End Sub
    End Class
End Namespace

 

OPC Data Client supports OPC XML-DA also on Linux and macOS.
See Also

Examples - OPC Data Access

Conceptual

Examples - OPC Unified Architecture