// This KEPServerEX example shows how subscribe to changes of multiple items and display the value of the item with each change. // // Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-CSharp . // Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using System.Threading; using OpcLabs.EasyOpc.DataAccess; using OpcLabs.EasyOpc.DataAccess.OperationModel; namespace DocExamples.Specialized { partial class Kepware_KEPServerEX { public static void SubscribeMultipleItems() { // Instantiate the client object. using (var client = new EasyDAClient()) { client.ItemChanged += client_SubscribeMultipleItems_ItemChanged; Console.WriteLine("Subscribing item changes..."); client.SubscribeMultipleItems( new[] { new DAItemGroupArguments("", "Kepware.KEPServerEX.V6", "Simulation Examples.Functions.Random1", 1000, null), new DAItemGroupArguments("", "Kepware.KEPServerEX.V6", "Simulation Examples.Functions.Ramp1", 1000, null), new DAItemGroupArguments("", "Kepware.KEPServerEX.V6", "Simulation Examples.Functions.Sine1", 1000, null), new DAItemGroupArguments("", "Kepware.KEPServerEX.V6", "Simulation Examples.Functions.User1", 1000, null) }); Console.WriteLine("Processing item changed events for 1 minute..."); Thread.Sleep(60 * 1000); Console.WriteLine("Unsubscribing item changes..."); } Console.WriteLine("Finished."); } // Item changed event handler static void client_SubscribeMultipleItems_ItemChanged(object sender, EasyDAItemChangedEventArgs e) { if (e.Succeeded) Console.WriteLine($"{e.Arguments.ItemDescriptor.ItemId}: {e.Vtq}"); else Console.WriteLine($"{e.Arguments.ItemDescriptor.ItemId} *** Failure: {e.ErrorMessageBrief}"); } } }
Copyright © 2004-2026 CODE Consulting and Development, s.r.o., Plzen. All rights reserved. Web page: www.opclabs.com
Documentation Home, Send Feedback. Resources: Knowledge Base, Product Downloads. Technical support: Online Forums, FAQ.Missing some example? Ask us for it on our Online Forums! You do not have to own a commercial license in order to use Online Forums, and we reply to every post.
Follow us on X (Twitter) | Follow us on LinkedIn