Connectivity Software User's Guide and Reference
Examples - OPC Classic Specialized - Kepware KEPServerEX - Read multiple items

.NET

// This KEPServerEX example shows how to read 4 items at once, and display their values, timestamps and qualities.
//
// 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.Diagnostics;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;

namespace DocExamples.Specialized
{
    partial class Kepware_KEPServerEX
    {
        public static void ReadMultipleItems()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            DAVtqResult[] vtqResults = client.ReadMultipleItems("Kepware.KEPServerEX.V6",
                new DAItemDescriptor[]
                    {
                        "Simulation Examples.Functions.Random1",
                        "Simulation Examples.Functions.Ramp1",
                        "Simulation Examples.Functions.Sine1",
                        "Simulation Examples.Functions.User1"
                    });

            for (int i = 0; i < vtqResults.Length; i++)
            {
                Debug.Assert(vtqResults[i] != null);

                if (vtqResults[i].Succeeded)
                    Console.WriteLine("vtqResults[{0}].Vtq: {1}", i, vtqResults[i].Vtq);
                else
                    Console.WriteLine("vtqResults[{0}] *** Failure: {1}", i, vtqResults[i].ErrorMessageBrief);
            }
        }
    }
}