OPC Studio User's Guide and Reference
DAReadItemArguments Class
Members 



OpcLabs.EasyOpcClassicCore Assembly > OpcLabs.EasyOpc.DataAccess.OperationModel Namespace : DAReadItemArguments Class
Holds information necessary to read an OPC item, such OPC server and item descriptor, and read parameters.
Object Model
DAReadItemArguments ClassDAReadParameters ClassDAItemDescriptor ClassDAReadParameters ClassServerDescriptor Class
Syntax
'Declaration
 
<CLSCompliantAttribute(True)>
<ComDefaultInterfaceAttribute(OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAReadItemArguments)>
<ComVisibleAttribute(True)>
<GuidAttribute("B5DACA52-2B85-4278-81BD-CA4F3386B4FF")>
<TypeConverterAttribute(System.ComponentModel.ExpandableObjectConverter)>
<ValueControlAttribute("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.80.82.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   DefaultReadWrite=False, 
   Export=True, 
   PageId=10001)>
<SerializableAttribute()>
Public NotInheritable Class DAReadItemArguments 
   Inherits DAItemArguments
   Implements LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.OperationModel.ComTypes._OperationArguments, OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAItemArguments, OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAReadItemArguments, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable 
'Usage
 
Dim instance As DAReadItemArguments
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAReadItemArguments)]
[ComVisible(true)]
[Guid("B5DACA52-2B85-4278-81BD-CA4F3386B4FF")]
[TypeConverter(System.ComponentModel.ExpandableObjectConverter)]
[ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.80.82.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   DefaultReadWrite=false, 
   Export=true, 
   PageId=10001)]
[Serializable()]
public sealed class DAReadItemArguments : DAItemArguments, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.OperationModel.ComTypes._OperationArguments, OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAItemArguments, OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAReadItemArguments, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable  
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAReadItemArguments)]
[ComVisible(true)]
[Guid("B5DACA52-2B85-4278-81BD-CA4F3386B4FF")]
[TypeConverter(System.ComponentModel.ExpandableObjectConverter)]
[ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.80.82.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   DefaultReadWrite=false, 
   Export=true, 
   PageId=10001)]
[Serializable()]
public ref class DAReadItemArguments sealed : public DAItemArguments, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.OperationModel.ComTypes._OperationArguments, OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAItemArguments, OpcLabs.EasyOpc.DataAccess.OperationModel.ComTypes._DAReadItemArguments, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable  
Remarks

 

In OPC Data Access, reading data from OPC items is one of the most common tasks. The OPC server generally provides current data for any OPC item in form of a Value, Timestamp and Quality combination (VTQ).

A single item

If you want to read the current VTQ from a specific OPC item, call the ReadItem method. You pass in individual arguments for machine name, server class, ItemID, and an optional data type. You will receive back a DAVtq object holding the current value, timestamp, and quality of the OPC item. The ReadItem method returns the current VTQ, regardless of the quality. You may receive an Uncertain or even Bad quality (and no usable data value), and your code needs to deal with such situations accordingly.

In OPC Data Client.NET, you can also pass ServerDescriptor and DAItemDescriptor objects in place of individual arguments to the ReadItem method.

.NET

// This example shows how to read a single item, and display its value, timestamp and quality.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    partial class ReadItem
    {
        public static void Main1()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            DAVtq vtq;
            try
            {
                vtq = client.ReadItem("", "OPCLabs.KitServer.2", "Simulation.Random");
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            Console.WriteLine("Vtq: {0}", vtq);
        }
    }
}
# This example shows how to read a single item, and display its value, timestamp and quality.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

#requires -Version 5.1
using namespace OpcLabs.EasyOpc.DataAccess
using namespace OpcLabs.EasyOpc.OperationModel

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicCore.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassic.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicComponents.dll"

# Instantiate the client object.
$client = New-Object EasyDAClient

try {
    $vtq = [IEasyDAClientExtension]::ReadItem($client, "", "OPCLabs.KitServer.2", "Simulation.Random")
}
catch [OpcException] {
    Write-Host "*** Failure: $($PSItem.Exception.GetBaseException().Message)"
    return
}

Write-Host "Vtq: $($vtq)"
# This example shows how to read a single item, and display its value, timestamp and quality.
#
# 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 .NET namespaces.
from OpcLabs.BaseLib.Navigation import *
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.OperationModel import *


# Instantiate the client object.
client = EasyDAClient()

# Perform the operation.
try:
    vtq = IEasyDAClientExtension.ReadItem(client, '', 'OPCLabs.KitServer.2', 'Simulation.Random')
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message, sep='')
    exit()

# Display results.
print('Vtq: ', vtq, sep='')
' This example shows how to read a single item, and display its value, timestamp and quality.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel

Namespace DataAccess._EasyDAClient
    Partial Friend Class ReadItem
        Public Shared Sub Main1()
            Dim client = New EasyDAClient()

            Dim vtq As DAVtq
            Try
                vtq = client.ReadItem("", "OPCLabs.KitServer.2", "Simulation.Random")
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            Console.WriteLine("Vtq: {0}", vtq)
        End Sub
    End Class
End Namespace

COM

// This example shows how to read a single item, and display its value, timestamp and quality.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

$Client = new COM("OpcLabs.EasyOpc.DataAccess.EasyDAClient");

try
{
    $Vtq = $Client->ReadItem("", "OPCLabs.KitServer.2", "Simulation.Random");
}
catch (com_exception $e)
{
    printf("*** Failure: %s\n", $e->getMessage());
    Exit();
}

printf("Vtq: %s\n", $Vtq);
// This example shows how to read a single item, and display its value, timestamp and quality.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

var Client = new ActiveXObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient");
var VTQ = Client.ReadItem("", "OPCLabs.KitServer.2", "Simulation.Random");
WScript.Echo("VTQ.ToString(): " + VTQ.ToString());
// This example shows how to read a single item, and display its value, timestamp and quality.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

class procedure ReadItem.Main;
var
  Client: OpcLabs_EasyOpcClassic_TLB._EasyDAClient;
  Vtq: _DAVtq;
begin
  // Instantiate the client object
  Client := CoEasyDAClient.Create;

  try
    Vtq := Client.ReadItem('', 'OPCLabs.KitServer.2', 'Simulation.Random');
  except
    on E: EOleException do
    begin
      WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
      Exit;
    end;
  end;

  // Display results
  WriteLn('Vtq: ', Vtq.ToString);
end;
// This example shows how to read a single item, and display its value, timestamp and quality.

mle_outputtext.Text = ""

// Instantiate the client object
OLEObject client
client = CREATE OLEObject
client.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")

// Obtain value/timestamp/quality
OLEObject vtq
TRY
    vtq = client.ReadItem("", "OPCLabs.KitServer.2", "Demo.Ramp")
CATCH (OLERuntimeError oleRuntimeError)
    mle_outputtext.Text = mle_outputtext.Text + "*** Failure: " + oleRuntimeError.Description + "~r~n"
    RETURN
END TRY

// Display results
mle_outputtext.Text = mle_outputtext.Text + "Vtq: " + vtq.DisplayString + "~r~n"
REM This example shows how to read a single item, and display its value, timestamp and quality.
REM
REM Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Private Sub ReadItem_Main_Command_Click()
    OutputText = ""
    
    ' Instantiate the client object
    Dim client As New EasyDAClient

    On Error Resume Next
    Dim vtq As DAVtq
    Set vtq = client.ReadItem("", "OPCLabs.KitServer.2", "Simulation.Random")
    If Err.Number <> 0 Then
        OutputText = OutputText & "*** Failure: " & Err.Source & ": " & Err.Description & vbCrLf
        Exit Sub
    End If
    On Error GoTo 0

    ' Display results
    OutputText = OutputText & "Vtq: " & vtq & vbCrLf
End Sub
Rem This example shows how to read a single item, and display its value, timestamp and quality.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Option Explicit

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
On Error Resume Next
Dim Vtq: Set Vtq = Client.ReadItem("", "OPCLabs.KitServer.2", "Simulation.Random")
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0
WScript.Echo "Vtq: " & Vtq
// This example shows how to read a single item using a browse path, and display its value, timestamp and quality.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using OpcLabs.EasyOpc;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    partial class ReadItem
    {
        public static void BrowsePath()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            DAVtq vtq;
            try
            {
                vtq = client.ReadItem(
                    new ServerDescriptor("", "OPCLabs.KitServer.2"),
                    new DAItemDescriptor(null, "/Simulation/Random"));
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            Console.WriteLine("Vtq: {0}", vtq);
        }
    }
}
# This example shows how to read a single item using a browse path, and display its value, timestamp and quality.
#
# 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 .NET namespaces.
from OpcLabs.BaseLib.Navigation import *
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.OperationModel import *


# Instantiate the client object.
client = EasyDAClient()

# Perform the operation.
try:
    vtq = IEasyDAClientExtension.ReadItem(client,
                                          ServerDescriptor('', 'OPCLabs.KitServer.2'),
                                          DAItemDescriptor(None, BrowsePath('/Simulation/Random')))
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message)
    exit()

# Display results.
print('Vtq: ', vtq, sep='')
' This example shows how to read a single item using a browse path, and display its value, timestamp and quality.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports OpcLabs.EasyOpc
Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel

Namespace DataAccess._EasyDAClient
    Partial Friend Class ReadItem
        Public Shared Sub BrowsePath()
            Dim client = New EasyDAClient()

            Dim vtq As DAVtq
            Try
                vtq = client.ReadItem(New ServerDescriptor("", "OPCLabs.KitServer.2"), New DAItemDescriptor(Nothing, "/Simulation/Random"))
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            Console.WriteLine("Vtq: {0}", vtq)
        End Sub
    End Class
End Namespace

 

// This example shows how to read a single item, and display its value, timestamp and quality.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.DataAccess.Xml
{
    partial class ReadItem
    {
        public static void Main1Xml()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            DAVtq vtq;
            try
            {
                vtq = client.ReadItem("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", "Dynamic/Analog Types/Int");
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            Console.WriteLine("Vtq: {0}", vtq);
        }
    }
}
# This example shows how to read a single item, and display its value, timestamp and quality.
#
# 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 .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.OperationModel import *

# Instantiate the client object.
client = EasyDAClient()

# Perform the operation.
try:
    vtq = IEasyDAClientExtension.ReadItem(client, ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'), DAItemDescriptor('Dynamic/Analog Types/Int'))
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message, sep='')
    exit()

# Display results.
print('Vtq: ', vtq, sep='')
' This example shows how to read a single item, and display its value, timestamp and quality.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel

Namespace DataAccess.Xml
    Partial Friend Class ReadItem
        Public Shared Sub Main1Xml()
            Dim client = New EasyDAClient()

            Dim vtq As DAVtq
            Try
                vtq = client.ReadItem("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", "Dynamic/Analog Types/Int")
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            Console.WriteLine("Vtq: {0}", vtq)
        End Sub
    End Class
End Namespace

 

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

Multiple items

For reading VTQs of multiple items simultaneously in an efficient manner, call the ReadMultipleItems method (instead of multiple ReadItem calls in a loop). You will receive back an array of DAVtqResult objects.

In OPC Data Client.NET, you can pass in a ServerDescriptor object and an array of DAItemDescriptor objects, or an array of DAItemArguments objects, to the ReadMultipleItems method.

Example 1 (four items at once)

.NET

// This example shows how to read 4 items at once, and display their values, timestamps and qualities.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using System.Diagnostics;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;

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

            DAVtqResult[] vtqResults = client.ReadMultipleItems("OPCLabs.KitServer.2",
                new DAItemDescriptor[]
                    {
                        "Simulation.Random", "Trends.Ramp (1 min)", "Trends.Sine (1 min)", "Simulation.Register_I4"
                    });

            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);
            }
        }
    }
}
# This example shows how to read 4 items at once, and display their values, timestamps and qualities.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

#requires -Version 5.1
using namespace OpcLabs.EasyOpc.DataAccess

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicCore.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassic.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicComponents.dll"

# Instantiate the client object.
$client = New-Object EasyDAClient

$vtqResults = [IEasyDAClientExtension]::ReadMultipleItems($client, "OPCLabs.KitServer.2", @(
    (New-Object DAItemDescriptor("Simulation.Random")),
    (New-Object DAItemDescriptor("Trends.Ramp (1 min)")),
    (New-Object DAItemDescriptor("Trends.Sine (1 min)")),
    (New-Object DAItemDescriptor("Simulation.Register_I4"))
    ))

for ($i = 0; $i -lt $vtqResults.Length; $i++) {
    $vtqResult = $vtqResults[$i]
    if ($vtqResult.Succeeded) {
        Write-Host "vtqResults[$($i)].Vtq: $($vtqResult.Vtq)"
    }
    else {
        Write-Host "vtqResults[$($i)] *** Failure: $($vtqResult.ErrorMessageBrief)"
    }
}
# This example shows how to read 4 items at once, and display their values, timestamps and qualities.
#
# 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 .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.DataAccess.OperationModel import *
from OpcLabs.EasyOpc.OperationModel import *


# Instantiate the client object.
client = EasyDAClient()

#
vtqResultArray = client.ReadMultipleItems([
    DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Simulation.Random')),
    DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Trends.Ramp (1 min)')),
    DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Trends.Sine (1 min)')),
    DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Simulation.Register_I4')),
    ])

for i, vtqResult in enumerate(vtqResultArray):
    assert vtqResult is not None
    if vtqResult.Succeeded:
        print('vtqResultArray[', i, '].Vtq: ', vtqResult.Vtq, sep='')
    else:
        print('vtqResultArray[', i, '] *** Failure: ', vtqResult.ErrorMessageBrief, sep='')
' This example shows how to read 4 items at once, and display their values, timestamps and qualities.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.OperationModel

Namespace DataAccess._EasyDAClient
    Partial Friend Class ReadMultipleItems
        Public Shared Sub Main1()
            Dim client = New EasyDAClient()

            Dim vtqResults() As DAVtqResult = client.ReadMultipleItems(
                "OPCLabs.KitServer.2",
                New DAItemDescriptor() {"Simulation.Random", "Trends.Ramp (1 min)", "Trends.Sine (1 min)", "Simulation.Register_I4"})

            For i = 0 To vtqResults.Length - 1
                Debug.Assert(vtqResults(i) IsNot Nothing)

                If vtqResults(i).Succeeded Then
                    Console.WriteLine("vtqResult[{0}].Vtq: {1}", i, vtqResults(i).Vtq)
                Else
                    Console.WriteLine("vtqResult[{0}] *** Failure: {1}", i, vtqResults(i).ErrorMessageBrief)
                End If
            Next i
        End Sub
    End Class
End Namespace

COM

// This example shows how to read 4 items at once, and display their values, timestamps and qualities.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

$ReadItemArguments1 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments");
$ReadItemArguments1->ServerDescriptor->ServerClass = "OPCLabs.KitServer.2";
$ReadItemArguments1->ItemDescriptor->ItemID = "Simulation.Random";

$ReadItemArguments2 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments");
$ReadItemArguments2->ServerDescriptor->ServerClass = "OPCLabs.KitServer.2";
$ReadItemArguments2->ItemDescriptor->ItemID = "Trends.Ramp (1 min)";

$ReadItemArguments3 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments");
$ReadItemArguments3->ServerDescriptor->ServerClass = "OPCLabs.KitServer.2";
$ReadItemArguments3->ItemDescriptor->ItemID = "Trends.Sine (1 min)";

$ReadItemArguments4 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments");
$ReadItemArguments4->ServerDescriptor->ServerClass = "OPCLabs.KitServer.2";
$ReadItemArguments4->ItemDescriptor->ItemID = "Simulation.Register_I4";

$arguments[0] = $ReadItemArguments1;
$arguments[1] = $ReadItemArguments2;
$arguments[2] = $ReadItemArguments3;
$arguments[3] = $ReadItemArguments4;

$Client = new COM("OpcLabs.EasyOpc.DataAccess.EasyDAClient");

$results = $Client->ReadMultipleItems($arguments);

for ($i = 0; $i < count($results); $i++)
{
    $VtqResult = $results[$i];
    if ($VtqResult->Succeeded)
        printf("results[d].Vtq.ToString()s\n", $i, $VtqResult->Vtq->ToString);
    else
        printf("results[d]: *** Failures\n", $i, $VtqResult->ErrorMessageBrief);
}
// This example shows how to read 4 items at once, and display their values, timestamps and qualities.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

class procedure ReadMultipleItems.Main;
var
  Arguments: OleVariant;
  Client: OpcLabs_EasyOpcClassic_TLB._EasyDAClient;
  I: Cardinal;
  ReadItemArguments1: _DAReadItemArguments;
  ReadItemArguments2: _DAReadItemArguments;
  ReadItemArguments3: _DAReadItemArguments;
  ReadItemArguments4: _DAReadItemArguments;
  VtqResult: _DAVtqResult;
  Results: OleVariant;
begin
  ReadItemArguments1 := CoDAReadItemArguments.Create;
  ReadItemArguments1.ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2';
  ReadItemArguments1.ItemDescriptor.ItemID := 'Simulation.Random';

  ReadItemArguments2 := CoDAReadItemArguments.Create;
  ReadItemArguments2.ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2';
  ReadItemArguments2.ItemDescriptor.ItemID := 'Trends.Ramp (1 min)';

  ReadItemArguments3 := CoDAReadItemArguments.Create;
  ReadItemArguments3.ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2';
  ReadItemArguments3.ItemDescriptor.ItemID := 'Trends.Sine (1 min)';

  ReadItemArguments4 := CoDAReadItemArguments.Create;
  ReadItemArguments4.ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2';
  ReadItemArguments4.ItemDescriptor.ItemID := 'Simulation.Register_I4';

  Arguments := VarArrayCreate([0, 3], varVariant);
  Arguments[0] := ReadItemArguments1;
  Arguments[1] := ReadItemArguments2;
  Arguments[2] := ReadItemArguments3;
  Arguments[3] := ReadItemArguments4;

  // Instantiate the client object
  Client := CoEasyDAClient.Create;

  TVarData(Results).VType := varArray or varVariant;
  TVarData(Results).VArray := PVarArray(
    Client.ReadMultipleItems(Arguments));

  // Display results
  for I := VarArrayLowBound(Results, 1) to VarArrayHighBound(Results, 1) do
  begin
      VtqResult := IInterface(Results[I]) as _DAVtqResult;
      if VtqResult.Succeeded then
        WriteLn('results(', i, ').Vtq.ToString(): ', VtqResult.Vtq.ToString)
      else
        WriteLn('results(', i, ') *** Failure: ', VtqResult.ErrorMessageBrief);
  end;

  VarClear(Results);
  VarClear(Arguments);
end;
// This example shows how to read 4 items at once, and display their values, timestamps and qualities.

mle_outputtext.Text = ""

// Instantiate the client object
OLEObject client
client = CREATE OLEObject
client.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")

// Prepare arguments.

OLEObject readItemArguments1
readItemArguments1 = CREATE OLEObject
readItemArguments1.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
readItemArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
readItemArguments1.ItemDescriptor.ItemID = "Simulation.Random"

OLEObject readItemArguments2
readItemArguments2 = CREATE OLEObject
readItemArguments2.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
readItemArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
readItemArguments2.ItemDescriptor.ItemID = "Trends.Ramp (1 min)"

OLEObject readItemArguments3
readItemArguments3 = CREATE OLEObject
readItemArguments3.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
readItemArguments3.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
readItemArguments3.ItemDescriptor.ItemID = "Trends.Sine (1 min)"

OLEObject readItemArguments4
readItemArguments4 = CREATE OLEObject
readItemArguments4.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
readItemArguments4.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
readItemArguments4.ItemDescriptor.ItemID = "Simulation.Register_I4"

OLEObject readItemArgumentsList
readItemArgumentsList = CREATE OLEObject
readItemArgumentsList.ConnectToNewObject("OpcLabs.BaseLib.Collections.ElasticVector")
readItemArgumentsList.Add(readItemArguments1)
readItemArgumentsList.Add(readItemArguments2)
readItemArgumentsList.Add(readItemArguments3)
readItemArgumentsList.Add(readItemArguments4)

// Obtain values/timestamps/qualities.
OLEObject vtqResultList
vtqResultList = client.ReadItemList(readItemArgumentsList)

// Display results
Int i
FOR i = 0 TO vtqResultList.Count - 1
    OLEObject vtqResult
    vtqResult = vtqResultList.Item[i]
    IF vtqResult.Succeeded THEN
        mle_outputtext.Text = mle_outputtext.Text + "vtqResult[" + String(i) + "].Vtq: " + String(vtqResult.Vtq) + "~r~n"
    ELSE
        mle_outputtext.Text = mle_outputtext.Text + "vtqResult[" + String(i) + "] *** Failure: " + vtqResult.ErrorMessageBrief + "~r~n"
    END IF    
NEXT
Rem $Header: $ Rem This example shows how to read 4 items at once, and display their values, timestamps and qualities.

Dim ReadItemArguments1 As New OLEObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments1.ItemDescriptor.ItemID = "Simulation.Random"

Dim ReadItemArguments2 As New OLEObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments2.ItemDescriptor.ItemID = "Trends.Ramp (1 min)"

Dim ReadItemArguments3 As New OLEObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments3.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments3.ItemDescriptor.ItemID = "Trends.Sine (1 min)"

Dim ReadItemArguments4 As New OLEObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments4.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments4.ItemDescriptor.ItemID = "Simulation.Register_I4"

Dim argumentsList As New OLEObject("OpcLabs.BaseLib.Collections.ElasticVector")
argumentsList.Add(ReadItemArguments1)
argumentsList.Add(ReadItemArguments2)
argumentsList.Add(ReadItemArguments3)
argumentsList.Add(ReadItemArguments4)

'Dim arguments(3) As OLEObject
'arguments(0) = ReadItemArguments1
'arguments(1) = ReadItemArguments2
'arguments(2) = ReadItemArguments3
'arguments(3) = ReadItemArguments4

Dim Client As New OLEObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")

Dim resultList As OLEObject
resultList = Client.ReadItemList(argumentsList)
Dim n As Integer
n = resultList.Count

'Dim results() As Variant
'results = Client.ReadMultipleItems(arguments)

Dim i As Integer
For i = 0 To n - 1
  'For i = results.FirstRowIndex To results.LastRowIndex
  Dim VtqResult As OLEObject
  VtqResult = resultList.GetAt(i)
  'VtqResult = results(i)
  If VtqResult.Succeeded Then
    Dim Vtq As OLEObject
    Vtq = VtqResult.Vtq
    Print "results(" + CStr(i) + ").Vtq.ToString(): " + Vtq.ToString()
  Else
    Print "results(" + CStr(i) + ") *** Failure: " + VtqResult.ErrorMessageBrief
  End If
Next
REM This example shows how to read 4 items at once, and display their values, timestamps and qualities.
REM
REM Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Private Sub ReadMultipleItems_Main_Command_Click()
    OutputText = ""
    
    Dim readArguments1 As New DAReadItemArguments
    readArguments1.serverDescriptor.ServerClass = "OPCLabs.KitServer.2"
    readArguments1.ItemDescriptor.itemId = "Simulation.Random"
    
    Dim readArguments2 As New DAReadItemArguments
    readArguments2.serverDescriptor.ServerClass = "OPCLabs.KitServer.2"
    readArguments2.ItemDescriptor.itemId = "Trends.Ramp (1 min)"
    
    Dim readArguments3 As New DAReadItemArguments
    readArguments3.serverDescriptor.ServerClass = "OPCLabs.KitServer.2"
    readArguments3.ItemDescriptor.itemId = "Trends.Sine (1 min)"
    
    Dim readArguments4 As New DAReadItemArguments
    readArguments4.serverDescriptor.ServerClass = "OPCLabs.KitServer.2"
    readArguments4.ItemDescriptor.itemId = "Simulation.Register_I4"
    
    Dim arguments(3) As Variant
    Set arguments(0) = readArguments1
    Set arguments(1) = readArguments2
    Set arguments(2) = readArguments3
    Set arguments(3) = readArguments4

    ' Instantiate the client object
    Dim client As New EasyDAClient

    Dim results() As Variant
    results = client.ReadMultipleItems(arguments)

    ' Display results
    Dim i: For i = LBound(results) To UBound(results)
        Dim vtqResult As DAVtqResult: Set vtqResult = results(i)
        If vtqResult.Succeeded Then
            OutputText = OutputText & "results(" & i & ").Vtq: " & vtqResult.vtq & vbCrLf
        Else
            OutputText = OutputText & "results(" & i & ") *** Failure: " & vtqResult.ErrorMessageBrief & vbCrLf
        End If
    Next
End Sub
Rem This example shows how to read 4 items at once, and display their values, timestamps and qualities.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Option Explicit

Dim ReadItemArguments1: Set ReadItemArguments1 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments1.ItemDescriptor.ItemID = "Simulation.Random"

Dim ReadItemArguments2: Set ReadItemArguments2 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments2.ItemDescriptor.ItemID = "Trends.Ramp (1 min)"

Dim ReadItemArguments3: Set ReadItemArguments3 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments3.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments3.ItemDescriptor.ItemID = "Trends.Sine (1 min)"

Dim ReadItemArguments4: Set ReadItemArguments4 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments4.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments4.ItemDescriptor.ItemID = "Simulation.Register_I4"

Dim arguments(3)
Set arguments(0) = ReadItemArguments1
Set arguments(1) = ReadItemArguments2
Set arguments(2) = ReadItemArguments3
Set arguments(3) = ReadItemArguments4

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
Dim results: results = Client.ReadMultipleItems(arguments)

Dim i: For i = LBound(results) To UBound(results)
    Dim VtqResult: Set VtqResult = results(i)
    If VtqResult.Succeeded Then
        WScript.Echo "results(" & i & ").Vtq.ToString(): " & VtqResult.Vtq.ToString()
    Else
        WScript.Echo "results(" & i & ") *** Failure: " & VtqResult.ErrorMessageBrief
    End If
Next

Example 2 (many items)

.NET

// This example repeatedly reads a large number of items.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    partial class ReadMultipleItems
    {
        private const int RepeatCount = 10;
        private const int NumberOfItems = 1000;

        public static void ManyRepeat()
        {
            Console.WriteLine("Creating array of arguments...");
            var arguments = new DAReadItemArguments[NumberOfItems];
            for (int i = 0; i < NumberOfItems; i++)
            {
                int copy = (i / 100) + 1;
                int phase = i % 100;
                string itemId = FormattableString.Invariant($"Simulation.Incrementing.Copy_{copy}.Phase_{phase}");
                Console.WriteLine(itemId);

                var readItemArguments = new DAReadItemArguments("OPCLabs.KitServer.2", itemId);
                arguments[i] = readItemArguments;
            }

            // Instantiate the client object.
            var client = new EasyDAClient();

            for (int iRepeat = 1; iRepeat <= RepeatCount; iRepeat++)
            {
                Console.WriteLine("Reading items...");
                DAVtqResult[] vtqResults = client.ReadMultipleItems(arguments);

                int successCount = 0;
                foreach (DAVtqResult vtqResult in vtqResults)
                    if (vtqResult.Succeeded)
                        successCount++;
                Console.WriteLine($"Success count: {successCount}");
            }
        }
    }
}
# This example repeatedly reads a large number of items.
#
# 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 .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.DataAccess.OperationModel import *
from OpcLabs.EasyOpc.OperationModel import *


REPEAT_COUNT = 10
NUMBER_OF_ITEMS = 1000

print('Creating array of arguments...')
argumentArray = [None]*NUMBER_OF_ITEMS
for i in range(NUMBER_OF_ITEMS):
    copy = (i//100) + 1
    phase = i % 100
    itemId = 'Simulation.Incrementing.Copy_{}.Phase_{}'.format(copy, phase)
    print(itemId)
    #
    readItemArguments = DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor(itemId))
    argumentArray[i] = readItemArguments

# Instantiate the client object.
client = EasyDAClient()

#
for iRepeat in range(1, REPEAT_COUNT + 1):
    print('Reading items...')
    vtqResultArray = client.ReadMultipleItems(argumentArray)
    #
    successCount = 0
    for vtqResult in vtqResultArray:
        if vtqResult.Succeeded:
            successCount = successCount + 1
        print('Success count: ', successCount, sep='')

print('Finished.')

COM

Rem This example repeatedly reads a large number of items.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Option Explicit

Const repeatCount = 10
Const numberOfItems = 1000

WScript.Echo "Creating array of arguments..."
Dim arguments(): ReDim arguments(numberOfItems - 1)
Dim i: For i = 0 To numberOfItems - 1
    Dim copy: copy = Int(i / 100) + 1
    Dim phase: phase = i Mod 100
    Dim itemId: itemId = "Simulation.Incrementing.Copy_" & copy & ".Phase_" & phase
    WScript.Echo itemId

    Dim ReadItemArguments: Set ReadItemArguments = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
    ReadItemArguments.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
    ReadItemArguments.ItemDescriptor.ItemID = itemId

    Set arguments(i) = ReadItemArguments
Next

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")

Dim iRepeat: For iRepeat = 1 To repeatCount
    WScript.Echo "Reading items..."
    Dim results: results = Client.ReadMultipleItems(arguments)

    Dim successCount: successCount = 0
    For i = LBound(results) To UBound(results)
        Dim VtqResult: Set VtqResult = results(i)
        If VtqResult.Succeeded Then successCount = successCount + 1
    Next
    WScript.Echo "Success count: " & successCount
Next

Example 3 (synchronous read)

.NET

// This example shows how to read 4 items at once synchronously, and display their values, timestamps and qualities.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using System.Diagnostics;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;

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

            // Specify that only synchronous method is allowed. By default, both synchronous and asynchronous methods are
            // allowed, and the component picks a suitable method automatically. Disallowing asynchronous method leaves
            // only the synchronous method available for selection.
            client.InstanceParameters.Mode.AllowAsynchronousMethod = false;

            DAVtqResult[] vtqResults = client.ReadMultipleItems("OPCLabs.KitServer.2",
                new DAItemDescriptor[]
                    {
                        "Simulation.Random", "Trends.Ramp (1 min)", "Trends.Sine (1 min)", "Simulation.Register_I4"
                    });

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

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

        
        // Example output:
        //
        //vtqResult[0].Vtq: 0.00125125888851588 { System.Double} @2020-04-10T15:29:20.642; GoodNonspecific(192)
        //vtqResult[1].Vtq: 0.344052940607071 {System.Double} @2020-04-10T15:29:20.643; GoodNonspecific(192)
        //vtqResult[2].Vtq: 0.830410616568378 {System.Double} @2020-04-10T15:29:20.643; GoodNonspecific(192)
        //vtqResult[3].Vtq: 0 {System.Int32} @1601-01-01T00:00:00.000; GoodNonspecific(192)
    }
}
# This example shows how to read 4 items at once synchronously, and display their values, timestamps and qualities.
#
# 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 .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.DataAccess.OperationModel import *
from OpcLabs.EasyOpc.OperationModel import *


# Instantiate the client object.
client = EasyDAClient()

# Specify that only synchronous method is allowed. By default, both synchronous and asynchronous methods are
# allowed, and the component picks a suitable method automatically. Disallowing asynchronous method leaves
# only the synchronous method available for selection.
client.InstanceParameters.Mode.AllowAsynchronousMethod = False

#
vtqResultArray = client.ReadMultipleItems([
    DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Simulation.Random')),
    DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Trends.Ramp (1 min)')),
    DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Trends.Sine (1 min)')),
    DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Simulation.Register_I4')),
    ])

for i, vtqResult in enumerate(vtqResultArray):
    assert vtqResult is not None
    if vtqResult.Succeeded:
        print('vtqResultArray[', i, '].Vtq: ', vtqResult.Vtq, sep='')
    else:
        print('vtqResultArray[', i, '] *** Failure: ', vtqResult.ErrorMessageBrief, sep='')
' This example shows how to read 4 items at once synchronously, and display their values, timestamps and qualities.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.OperationModel

Namespace DataAccess._EasyDAClient
    Partial Friend Class ReadMultipleItems
        Public Shared Sub Synchronous()
            ' Instantiate the client object.
            Dim client = New EasyDAClient()

            ' Specify that only synchronous method is allowed. By default, both synchronous and asynchronous methods are
            ' allowed, and the component picks a suitable method automatically. Disallowing asynchronous method leaves
            ' only the synchronous method available for selection.
            client.InstanceParameters.Mode.AllowAsynchronousMethod = False

            Dim vtqResults() As DAVtqResult = client.ReadMultipleItems("OPCLabs.KitServer.2",
                New DAItemDescriptor() {"Simulation.Random", "Trends.Ramp (1 min)", "Trends.Sine (1 min)", "Simulation.Register_I4"})

            For i = 0 To vtqResults.Length - 1
                Debug.Assert(vtqResults(i) IsNot Nothing)

                If vtqResults(i).Succeeded Then
                    Console.WriteLine("vtqResult[{0}].Vtq: {1}", i, vtqResults(i).Vtq)
                Else
                    Console.WriteLine("vtqResult[{0}] *** Failure: {1}", i, vtqResults(i).ErrorMessageBrief)
                End If
            Next i
        End Sub

        ' Example output:
        '
        'vtqResult[0].Vtq: 0.00125125888851588 { System.Double} @2020-04-10T15:29:20.642; GoodNonspecific(192)
        'vtqResult[1].Vtq: 0.344052940607071 {System.Double} @2020-04-10T15:29:20.643; GoodNonspecific(192)
        'vtqResult[2].Vtq: 0.830410616568378 {System.Double} @2020-04-10T15:29:20.643; GoodNonspecific(192)
        'vtqResult[3].Vtq: 0 {System.Int32} @1601-01-01T00:00:00.000; GoodNonspecific(192)
    End Class
End Namespace

COM

Rem This example shows how to read 4 items at once synchronously, and display their values, timestamps and qualities.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Option Explicit

Dim ReadItemArguments1: Set ReadItemArguments1 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments1.ItemDescriptor.ItemID = "Simulation.Random"

Dim ReadItemArguments2: Set ReadItemArguments2 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments2.ItemDescriptor.ItemID = "Trends.Ramp (1 min)"

Dim ReadItemArguments3: Set ReadItemArguments3 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments3.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments3.ItemDescriptor.ItemID = "Trends.Sine (1 min)"

Dim ReadItemArguments4: Set ReadItemArguments4 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments4.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments4.ItemDescriptor.ItemID = "Simulation.Register_I4"

Dim arguments(3)
Set arguments(0) = ReadItemArguments1
Set arguments(1) = ReadItemArguments2
Set arguments(2) = ReadItemArguments3
Set arguments(3) = ReadItemArguments4

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")

' Specify that only synchronous method is allowed. By default, both synchronous and asynchronous methods are allowed, and 
' the component picks a suitable method automatically. Disallowing asynchronous method leaves only the synchronous method
' available for selection.
Client.InstanceParameters.Mode.AllowAsynchronousMethod = False

Dim results: results = Client.ReadMultipleItems(arguments)

Dim i: For i = LBound(results) To UBound(results)
    Dim VtqResult: Set VtqResult = results(i)
    If VtqResult.Succeeded Then
        WScript.Echo "results(" & i & ").Vtq.ToString(): " & VtqResult.Vtq.ToString()
    Else
        WScript.Echo "results(" & i & ") *** Failure: " & VtqResult.ErrorMessageBrief
    End If
Next

Example 4 (test success)

COM

Rem This example shows how to read 2 items (first valid, second invalid), test for success of each read and display either 
Rem the DAVtq or the Exception.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Option Explicit

Dim ReadItemArguments1: Set ReadItemArguments1 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments1.ItemDescriptor.ItemID = "Simulation.Random"

Dim ReadItemArguments2: Set ReadItemArguments2 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments2.ItemDescriptor.ItemID = "UnknownItem"

Dim arguments(1)
Set arguments(0) = ReadItemArguments1
Set arguments(1) = ReadItemArguments2

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
Dim results: results = Client.ReadMultipleItems(arguments)

Dim i: For i = LBound(results) To UBound(results)
    Dim VtqResult: Set VtqResult = results(i)
    If VtqResult.Succeeded Then
        WScript.Echo "results(" & i & ").Vtq.ToString(): " & VtqResult.Vtq.ToString()
    Else
        WScript.Echo "results(" & i & ") *** Failure: " & VtqResult.ErrorMessageBrief
    End If
Next
# This example shows how to read 2 items (first valid, second invalid), test for success of each read and display either 
# the DAVtq or the Exception.
#
# The Python for Windows (pywin32) extensions package is needed. Install it using "pip install pypiwin32".
# CAUTION: We now recommend using Python.NET package instead. Full set of examples with Python.NET is available!
#
# Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
import win32com.client

# Instantiate the client object
client = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.EasyDAClient') 

#
readItemArguments1 = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments')
readItemArguments1.ServerDescriptor.ServerClass = 'OPCLabs.KitServer.2'
readItemArguments1.ItemDescriptor.ItemID = 'Simulation.Random'

readItemArguments2 = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments')
readItemArguments2.ServerDescriptor.ServerClass = 'OPCLabs.KitServer.2'
readItemArguments2.ItemDescriptor.ItemID = 'UnknownItem'

arguments = [
    readItemArguments1,
    readItemArguments2,
    ]
results = client.ReadMultipleItems(arguments)

for i, vtqResult in enumerate(results):
    if vtqResult.Succeeded:
        print('results(' + str(i) + '): ' + str(vtqResult.Vtq))
    else:
        print('results(' + str(i) + ') *** Failure: ' + vtqResult.ErrorMessageBrief)

Example 5 (usage error upon failure)

Rem This example attempts to read 3 items (first valid, second invalid, third valid again), and display their values, 
Rem timestamps and qualities. Without testing for a success, a run-time error occurs when accessing the Vtq property
Rem of a failed result.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Option Explicit

Dim ReadItemArguments1: Set ReadItemArguments1 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments1.ItemDescriptor.ItemID = "Simulation.Random"

Dim ReadItemArguments2: Set ReadItemArguments2 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments2.ItemDescriptor.ItemID = "UnknownItem"

Dim ReadItemArguments3: Set ReadItemArguments3 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments3.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments3.ItemDescriptor.ItemID = "Trends.Ramp (1 min)"

Dim arguments(2)
Set arguments(0) = ReadItemArguments1
Set arguments(1) = ReadItemArguments2
Set arguments(2) = ReadItemArguments3

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
Dim results: results = Client.ReadMultipleItems(arguments)

Dim i: For i = LBound(results) To UBound(results)
    ' This is an anti-example - you should not access the Vtq property without testing the success first!
    WScript.Echo "results(" & i & ").Vtq.ToString(): " & results(i).Vtq.ToString()
Next

.NET

// This example shows how to read 4 items from an OPC XML-DA server at once, and display their values, timestamps 
// and qualities.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using System.Diagnostics;
using OpcLabs.EasyOpc;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;

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

            DAVtqResult[] vtqResults = client.ReadMultipleItems(
                new ServerDescriptor { UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx" },
                new DAItemDescriptor[]
                    {
                        "Dynamic/Analog Types/Double", 
                        "Dynamic/Analog Types/Double[]", 
                        "Dynamic/Analog Types/Int", 
                        "SomeUnknownItem"
                    });

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

                if (!(vtqResults[i].Exception is null))
                {
                    Console.WriteLine($"vtqResults[{i}] *** Failure: {vtqResults[i].ErrorMessageBrief}");
                    continue;
                }
                Console.WriteLine($"vtqResults[{i}].Vtq: {vtqResults[i].Vtq}");
            }
        }
    }
}
# This example shows how to read 4 items from an OPC XML-DA server at once, and display their values, timestamps 
# and qualities.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

#requires -Version 5.1
using namespace OpcLabs.EasyOpc
using namespace OpcLabs.EasyOpc.DataAccess

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicCore.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassic.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicComponents.dll"

# Instantiate the client object.
$client = New-Object EasyDAClient

$serverDescriptor = New-Object ServerDescriptor -Property @{
    UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx"
}

$vtqResults = [IEasyDAClientExtension]::ReadMultipleItems($client, 
    $serverDescriptor, 
    @(
        (New-Object DAItemDescriptor("Dynamic/Analog Types/Double")),
        (New-Object DAItemDescriptor("Dynamic/Analog Types/Double[]")),
        (New-Object DAItemDescriptor("Dynamic/Analog Types/Int")),
        (New-Object DAItemDescriptor("SomeUnknownItem"))
        ))

for ($i = 0; $i -lt $vtqResults.Length; $i++) {
    $vtqResult = $vtqResults[$i]
    if ($vtqResult.Succeeded) {
        Write-Host "vtqResults[$($i)].Vtq: $($vtqResult.Vtq)"
    }
    else {
        Write-Host "vtqResults[$($i)] *** Failure: $($vtqResult.ErrorMessageBrief)"
    }
}
# This example shows how to read 4 items from an OPC XML-DA server at once, and display their values, timestamps
# and qualities.
#
# 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 .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.DataAccess.OperationModel import *
from OpcLabs.EasyOpc.OperationModel import *


# Instantiate the client object.
client = EasyDAClient()

#
vtqResultArray = IEasyDAClientExtension.ReadMultipleItems(client,
    ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'),
    [
        DAItemDescriptor('Dynamic/Analog Types/Double'),
        DAItemDescriptor('Dynamic/Analog Types/Double[]'),
        DAItemDescriptor('Dynamic/Analog Types/Int'),
        DAItemDescriptor('SomeUnknownItem')
    ])

for i, vtqResult in enumerate(vtqResultArray):
    assert vtqResult is not None
    if vtqResult.Succeeded:
        print('vtqResultArray[', i, '].Vtq: ', vtqResult.Vtq, sep='')
    else:
        print('vtqResultArray[', i, '] *** Failure: ', vtqResult.ErrorMessageBrief, sep='')
' This example shows how to read 4 items from an OPC XML-DA server at once, and display their values, timestamps 
' and qualities.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports OpcLabs.EasyOpc
Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.OperationModel

Namespace DataAccess.Xml
    Partial Friend Class ReadMultipleItems
        Public Shared Sub Main1Xml()
            Dim client = New EasyDAClient()

            Dim vtqResults() As DAVtqResult = client.ReadMultipleItems(
                    New ServerDescriptor() With {.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx"},
                    New DAItemDescriptor() _
                    { _
                        "Dynamic/Analog Types/Double",
                        "Dynamic/Analog Types/Double[]",
                        "Dynamic/Analog Types/Int",
                        "SomeUnknownItem"
                    })

            For i = 0 To vtqResults.Length - 1
                Debug.Assert(vtqResults(i) IsNot Nothing)

                If vtqResults(i).Exception IsNot Nothing Then
                    Console.WriteLine("vtqResult[{0}] *** Failure: {1}", i, vtqResults(i).ErrorMessageBrief)
                    Continue For
                End If
                Console.WriteLine("vtqResult[{0}].Vtq: {1}", i, vtqResults(i).Vtq)
            Next i
        End Sub
    End Class
End Namespace

COM

// This example shows how to read 4 items from an OPC XML-DA server at once, and display their values, timestamps
// and qualities.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

class procedure ReadMultipleItems.MainXml;
var
  Arguments: OleVariant;
  Client: OpcLabs_EasyOpcClassic_TLB._EasyDAClient;
  I: Cardinal;
  ReadItemArguments1: _DAReadItemArguments;
  ReadItemArguments2: _DAReadItemArguments;
  ReadItemArguments3: _DAReadItemArguments;
  ReadItemArguments4: _DAReadItemArguments;
  VtqResult: _DAVtqResult;
  Results: OleVariant;
begin
  ReadItemArguments1 := CoDAReadItemArguments.Create;
  ReadItemArguments1.ServerDescriptor.UrlString := 'http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx';
  ReadItemArguments1.ItemDescriptor.ItemID := 'Dynamic/Analog Types/Double';

  ReadItemArguments2 := CoDAReadItemArguments.Create;
  ReadItemArguments2.ServerDescriptor.UrlString := 'http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx';
  ReadItemArguments2.ItemDescriptor.ItemID := 'Dynamic/Analog Types/Double[]';

  ReadItemArguments3 := CoDAReadItemArguments.Create;
  ReadItemArguments3.ServerDescriptor.UrlString := 'http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx';
  ReadItemArguments3.ItemDescriptor.ItemID := 'Dynamic/Analog Types/Int';

  ReadItemArguments4 := CoDAReadItemArguments.Create;
  ReadItemArguments4.ServerDescriptor.UrlString := 'http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx';
  ReadItemArguments4.ItemDescriptor.ItemID := 'SomeUnknownItem';

  Arguments := VarArrayCreate([0, 3], varVariant);
  Arguments[0] := ReadItemArguments1;
  Arguments[1] := ReadItemArguments2;
  Arguments[2] := ReadItemArguments3;
  Arguments[3] := ReadItemArguments4;

  // Instantiate the client object
  Client := CoEasyDAClient.Create;

  TVarData(Results).VType := varArray or varVariant;
  TVarData(Results).VArray := PVarArray(
    Client.ReadMultipleItems(Arguments));

  // Display results
  for I := VarArrayLowBound(Results, 1) to VarArrayHighBound(Results, 1) do
  begin
      VtqResult := IInterface(Results[I]) as _DAVtqResult;
      if VtqResult.Exception <> nil then
      begin
        WriteLn('results[', i, '] *** Failure: ', VtqResult.ErrorMessageBrief);
        Continue;
      end;
      WriteLn('results[', i, '].Vtq.ToString(): ', VtqResult.Vtq.ToString);
  end;

  VarClear(Results);
  VarClear(Arguments);
end;
// This example shows how to read 4 items from an OPC XML-DA server at once, and display their values, timestamps 
// and qualities.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

$ReadItemArguments1 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments");
$ReadItemArguments1->ServerDescriptor->UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx";
$ReadItemArguments1->ItemDescriptor->ItemID = "Dynamic/Analog Types/Double";

$ReadItemArguments2 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments");
$ReadItemArguments2->ServerDescriptor->UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx";
$ReadItemArguments2->ItemDescriptor->ItemID = "Dynamic/Analog Types/Double[]";

$ReadItemArguments3 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments");
$ReadItemArguments3->ServerDescriptor->UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx";
$ReadItemArguments3->ItemDescriptor->ItemID = "Dynamic/Analog Types/Int";

$ReadItemArguments4 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments");
$ReadItemArguments4->ServerDescriptor->UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx";
$ReadItemArguments4->ItemDescriptor->ItemID = "SomeUnknownItem";

$arguments[0] = $ReadItemArguments1;
$arguments[1] = $ReadItemArguments2;
$arguments[2] = $ReadItemArguments3;
$arguments[3] = $ReadItemArguments4;

$Client = new COM("OpcLabs.EasyOpc.DataAccess.EasyDAClient");

$results = $Client->ReadMultipleItems($arguments);

for ($i = 0; $i < count($results); $i++)
{
    $VtqResult = $results[$i];
    if ($VtqResult->Succeeded)
        printf("results[d].Vtq.ToString()s\n", $i, $VtqResult->Vtq->ToString);
    else
        printf("results[d]: *** Failures\n", $i, $VtqResult->ErrorMessageBrief);
}
Rem This example shows how to read 4 items from an OPC XML-DA server at once, and display their values, timestamps
Rem and qualities.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Private Sub ReadMultipleItems_MainXml_Command_Click()
    OutputText = ""
    
    Dim readArguments1 As New DAReadItemArguments
    readArguments1.serverDescriptor.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx"
    readArguments1.ItemDescriptor.ItemId = "Dynamic/Analog Types/Double"
    
    Dim readArguments2 As New DAReadItemArguments
    readArguments2.serverDescriptor.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx"
    readArguments2.ItemDescriptor.ItemId = "Dynamic/Analog Types/Double[]"
    
    Dim readArguments3 As New DAReadItemArguments
    readArguments3.serverDescriptor.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx"
    readArguments3.ItemDescriptor.ItemId = "Dynamic/Analog Types/Int"
    
    Dim readArguments4 As New DAReadItemArguments
    readArguments4.serverDescriptor.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx"
    readArguments4.ItemDescriptor.ItemId = "SomeUnknownItem"
    
    Dim arguments(3) As Variant
    Set arguments(0) = readArguments1
    Set arguments(1) = readArguments2
    Set arguments(2) = readArguments3
    Set arguments(3) = readArguments4

    ' Instantiate the client object
    Dim client As New EasyDAClient

    Dim vtqResults() As Variant
    vtqResults = client.ReadMultipleItems(arguments)

    ' Display results
    Dim i: For i = LBound(vtqResults) To UBound(vtqResults)
        Dim vtqResult As DAVtqResult: Set vtqResult = vtqResults(i)
        If Not (vtqResult.Exception Is Nothing) Then
            OutputText = OutputText & "results(" & i & ") *** Failure: " & vtqResult.ErrorMessageBrief & vbCrLf
        Else
        OutputText = OutputText & "results(" & i & ").Vtq.ToString(): " & vtqResult.vtq & vbCrLf
        End If
    Next
End Sub
Rem This example shows how to read 4 items from an OPC XML-DA server at once, and display their values, timestamps
Rem and qualities.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Option Explicit

Dim ReadItemArguments1: Set ReadItemArguments1 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments1.ServerDescriptor.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx"
ReadItemArguments1.ItemDescriptor.ItemID = "Dynamic/Analog Types/Double"

Dim ReadItemArguments2: Set ReadItemArguments2 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments2.ServerDescriptor.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx"
ReadItemArguments2.ItemDescriptor.ItemID = "Dynamic/Analog Types/Double[]"

Dim ReadItemArguments3: Set ReadItemArguments3 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments3.ServerDescriptor.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx"
ReadItemArguments3.ItemDescriptor.ItemID = "Dynamic/Analog Types/Int"

Dim ReadItemArguments4: Set ReadItemArguments4 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments4.ServerDescriptor.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx"
ReadItemArguments4.ItemDescriptor.ItemID = "SomeUnknownItem"

Dim arguments(3)
Set arguments(0) = ReadItemArguments1
Set arguments(1) = ReadItemArguments2
Set arguments(2) = ReadItemArguments3
Set arguments(3) = ReadItemArguments4

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
Dim results: results = Client.ReadMultipleItems(arguments)

Dim i: For i = LBound(results) To UBound(results)
    Dim VtqResult: Set VtqResult = results(i)
    If Not (VtqResult.Exception Is Nothing) Then
        WScript.Echo "results(" & i & ") *** Failure: " & VtqResult.ErrorMessageBrief
    Else
        WScript.Echo "results(" & i & ").Vtq.ToString(): " & VtqResult.Vtq.ToString()
    End If
Next

 

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

Read parameters

In OPC Data Client.NET, you can use the optional argument of type DAReadParameters, and then set the ValueAge property in it to control how “old” may be the values you receive by reading from OPC items.  With the DataSource property, you can also specify that you want values from the device, or from cache. You can also use the pre-defined DAReadParameters.CacheSource and DAReadParameters.DeviceSource constants to specify the read parameters. There are also overloads of ReadXXXX methods that accept an integer valueAge argument.

Some OPC-DA (Data Access) servers only support older versions of the OPC specifications, which do not allow specifying the value age by a number; they only support reading from the cache, and reading from the device. With such servers, OPC Data Client may emulate this functionality by providing a value from its internal (client-side) cache, when it is fresh enough, and performing a read from the device otherwise.

In .NET languages, there is an implicit conversion operator from Int32 to DAReadParameters, which means that you can simply use the number of milliseconds that represents the value age in place of any argument that expects the read parameters (the DAReadParameters object). There is also a FromInt32 Method which has the same functionality as this conversion operator.

In addition, there is also an implicit conversion from the DADataSource Enumeration to DAReadParameters. You can therefore use the enumeration members such as DADataSource.Cache or DADataSource.Device in place of the read parameters. The FromDADataSource Method has the same functionality as this conversion operator. 

The default setting of read parameters, which specifies a non-zero value age, may sometimes "bite" you, if you expect to receive an up-to-date value from the data source. Furthermore, you may even receive a "bad quality" indication with some first reads, because the (OPC server) cache is not yet filled with valid data. Make sure to specify the value age that is appropriate for particular read operation in your application, if the default behavior is not what you want.

Reading from the device (or using very short value age) is, however, an ineffective practice that is discouraged, and should only be used when absolutely necessary.

Be aware that it is physically impossible for any system to always obtain fully up-to-date values all the time. 

// This example shows how to read a single item from the device, and display its value, timestamp and quality.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    partial class ReadItem
    {
        public static void DeviceSource()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            Console.WriteLine("Reading item...");
            DAVtq vtq;
            try
            {
                // DADataSource enumeration:
                // Selects the data source for OPC reads (from device, from OPC cache, or dynamically determined).
                // The data source (memory, OPC cache or OPC device) selection is based on the desired value age and
                // current status of data received from the server.

                vtq = client.ReadItem("OPCLabs.KitServer.2", "Simulation.Random", DADataSource.Device);
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            Console.WriteLine("Vtq: {0}", vtq);
        }
    }
}
# This example shows how to read a single item from the device, and display its value, timestamp and quality.
#
# 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 .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.OperationModel import *


# Instantiate the client object.
client = EasyDAClient()

print('Reading item...')
try:
    # DADataSource enumeration:
    # Selects the data source for OPC reads (from device, from OPC cache, or dynamically determined).
    # The data source (memory, OPC cache or OPC device) selection is based on the desired value age and
    # current status of data received from the server.
    vtq = IEasyDAClientExtension.ReadItem(client,
                                          ServerDescriptor('OPCLabs.KitServer.2'),
                                          DAItemDescriptor('Simulation.Random'),
                                          DAReadParameters(DADataSource.Device))
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message, sep='')
    exit()

# Display results.
print('Vtq: ', vtq, sep='')
' This example shows how to read a single item from the device, and display its value, timestamp and quality.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel

Namespace DataAccess._EasyDAClient
    Partial Friend Class ReadItem
        Public Shared Sub DeviceSource()
            ' Instantiate the client object.
            Dim client = New EasyDAClient()

            Console.WriteLine("Reading item...")
            Dim vtq As DAVtq
            Try
                ' DADataSource enumeration:
                ' Selects the data source for OPC reads (from device, from OPC cache, or dynamically determined).
                ' The data source (memory, OPC cache or OPC device) selection is based on the desired value age and
                ' current status of data received from the server.

                vtq = client.ReadItem("OPCLabs.KitServer.2", "Simulation.Random", DADataSource.Device)
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            Console.WriteLine("Vtq: {0}", vtq)
        End Sub
    End Class
End Namespace

.NET

// This example shows how to read 4 items from the device, and display their values, timestamps and qualities.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using System.Diagnostics;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;

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

            // DADataSource enumeration:
            // Selects the data source for OPC reads (from device, from OPC cache, or dynamically determined).
            // The data source (memory, OPC cache or OPC device) selection will be based on the desired value age and
            // current status of data received from the server.

            DAVtqResult[] vtqResults = client.ReadMultipleItems(
                new []
                    {
                        new DAReadItemArguments("OPCLabs.KitServer.2", "Simulation.Random", DADataSource.Device),
                        new DAReadItemArguments("OPCLabs.KitServer.2", "Trends.Ramp (1 min)", DADataSource.Device),
                        new DAReadItemArguments("OPCLabs.KitServer.2", "Trends.Sine (1 min)", DADataSource.Device),
                        new DAReadItemArguments("OPCLabs.KitServer.2", "Simulation.Register_I4", DADataSource.Device)
                    });

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


        // Example output:
        //
        //vtqResults[0].Vtq: 0.00125125888851588 { System.Double} @2020-04-10T12:44:16.250; GoodNonspecific(192)
        //vtqResults[1].Vtq: 0.270812898874283 {System.Double} @2020-04-10T12:44:16.248; GoodNonspecific(192)
        //vtqResults[2].Vtq: 0.991434340167834 {System.Double} @2020-04-10T12:44:16.250; GoodNonspecific(192)
        //vtqResults[3].Vtq: 0 {System.Int32} @1601-01-01T00:00:00.000; GoodNonspecific(192)
    }
}
# This example shows how to read 4 items from the device, and display their values, timestamps and qualities.
#
# 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 .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.DataAccess.OperationModel import *
from OpcLabs.EasyOpc.OperationModel import *


# Instantiate the client object.
client = EasyDAClient()

# DADataSource enumeration:
# Selects the data source for OPC reads (from device, from OPC cache, or dynamically determined).
# The data source (memory, OPC cache or OPC device) selection is based on the desired value age and
# current status of data received from the server.

#
vtqResultArray = client.ReadMultipleItems([
    DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Simulation.Random'), DAReadParameters(DADataSource.Device)),
    DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Trends.Ramp (1 min)'), DAReadParameters(DADataSource.Device)),
    DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Trends.Sine (1 min)'), DAReadParameters(DADataSource.Device)),
    DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Simulation.Register_I4'), DAReadParameters(DADataSource.Device)),
    ])

for i, vtqResult in enumerate(vtqResultArray):
    assert vtqResult is not None
    if vtqResult.Succeeded:
        print('vtqResultArray[', i, '].Vtq: ', vtqResult.Vtq, sep='')
    else:
        print('vtqResultArray[', i, '] *** Failure: ', vtqResult.ErrorMessageBrief, sep='')
' This example shows how to read 4 items from the device, and display their values, timestamps and qualities.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.OperationModel

Namespace DataAccess._EasyDAClient
    Partial Friend Class ReadMultipleItems
        Public Shared Sub DeviceSource()
            ' Instantiate the client object.
            Dim client = New EasyDAClient()

            ' DADataSource enumeration
            ' Selects the data source for OPC reads (from device, from OPC cache, or dynamically determined).
            ' The data source (memory, OPC cache or OPC device) selection will be based on the desired value age and
            ' current status of data received from the server.

            Dim vtqResults() As DAVtqResult = client.ReadMultipleItems(New DAReadItemArguments() {
                New DAReadItemArguments("OPCLabs.KitServer.2", "Simulation.Random", DADataSource.Device),
                New DAReadItemArguments("OPCLabs.KitServer.2", "Trends.Ramp (1 min)", DADataSource.Device),
                New DAReadItemArguments("OPCLabs.KitServer.2", "Trends.Sine (1 min)", DADataSource.Device),
                New DAReadItemArguments("OPCLabs.KitServer.2", "Simulation.Register_I4", DADataSource.Device)
            })

            For i = 0 To vtqResults.Length - 1
                Debug.Assert(vtqResults(i) IsNot Nothing)

                If vtqResults(i).Succeeded Then
                    Console.WriteLine("vtqResults[{0}].Vtq: {1}", i, vtqResults(i).Vtq)
                Else
                    Console.WriteLine("vtqResults[{0}] *** Failure: {1}", i, vtqResults(i).ErrorMessageBrief)
                End If
            Next i
        End Sub

        ' Example output
        '
        'vtqResults[0].Vtq: 0.00125125888851588 { System.Double} @2020-04-10T12:44:16.250; GoodNonspecific(192)
        'vtqResults[1].Vtq: 0.270812898874283 {System.Double} @2020-04-10T12:44:16.248; GoodNonspecific(192)
        'vtqResults[2].Vtq: 0.991434340167834 {System.Double} @2020-04-10T12:44:16.250; GoodNonspecific(192)
        'vtqResults[3].Vtq: 0 {System.Int32} @1601-01-01T00:00:00.000; GoodNonspecific(192)
    End Class
End Namespace

COM

Rem This example shows how to read 4 items from the device, and display their values, timestamps and qualities.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Option Explicit

' Selects the data source for OPC reads (from device, from OPC cache, or dynamically determined).
' The data source (memory, OPC cache or OPC device) selection will be based on the desired value age and current status of 
' data received from the server.
Const DADataSource_ByValueAge = 0
' OPC reads will be fulfilled from the cache in the OPC server.
Const DADataSource_Cache = 1
' OPC reads will be fulfilled from the device by the OPC server.
Const DADataSource_Device = 2

Dim ReadItemArguments1: Set ReadItemArguments1 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments1.ItemDescriptor.ItemID = "Simulation.Random"
ReadItemArguments1.ReadParameters.DataSource = DADataSource_Device  ' read will be from device

Dim ReadItemArguments2: Set ReadItemArguments2 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments2.ItemDescriptor.ItemID = "Trends.Ramp (1 min)"
ReadItemArguments2.ReadParameters.DataSource = DADataSource_Device  ' read will be from device

Dim ReadItemArguments3: Set ReadItemArguments3 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments3.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments3.ItemDescriptor.ItemID = "Trends.Sine (1 min)"
ReadItemArguments3.ReadParameters.DataSource = DADataSource_Device  ' read will be from device

Dim ReadItemArguments4: Set ReadItemArguments4 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments4.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments4.ItemDescriptor.ItemID = "Simulation.Register_I4"
ReadItemArguments4.ReadParameters.DataSource = DADataSource_Device  ' read will be from device

Dim arguments(3)
Set arguments(0) = ReadItemArguments1
Set arguments(1) = ReadItemArguments2
Set arguments(2) = ReadItemArguments3
Set arguments(3) = ReadItemArguments4

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")

Dim results: results = Client.ReadMultipleItems(arguments)

Dim i: For i = LBound(results) To UBound(results)
    Dim VtqResult: Set VtqResult = results(i)
    If VtqResult.Succeeded Then
        WScript.Echo "results(" & i & ").Vtq.ToString(): " & VtqResult.Vtq.ToString()
    Else
        WScript.Echo "results(" & i & ") *** Failure: " & VtqResult.ErrorMessageBrief
    End If
Next
// This example shows how to read a single item from the device, and display its value, timestamp and quality.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.DataAccess.Xml
{
    partial class ReadItem
    {
        public static void DeviceSourceXml()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            Console.WriteLine("Reading item...");
            DAVtq vtq;
            try
            {
                // DADataSource enumeration:
                // Selects the data source for OPC reads (from device, from OPC cache, or dynamically determined).
                // The data source (memory, OPC cache or OPC device) selection is based on the desired value age and
                // current status of data received from the server.

                vtq = client.ReadItem("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", "Dynamic/Analog Types/Int", DADataSource.Device);
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            Console.WriteLine("Vtq: {0}", vtq);
        }
    }
}
# This example shows how to read a single item from the device, and display its value, timestamp and quality.
#
# 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 .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.OperationModel import *

# Instantiate the client object.
client = EasyDAClient()

print('Reading item...')

try:
    # DADataSource enumeration:
    # Selects the data source for OPC reads (from device, from OPC cache, or dynamically determined).
    # The data source (memory, OPC cache or OPC device) selection is based on the desired value age and
    # current status of data received from the server.

    vtq = IEasyDAClientExtension.ReadItem(client, 
                                          ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'), 
                                          DAItemDescriptor('Dynamic/Analog Types/Int'), 
                                          DAReadParameters(DADataSource.Device))
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message, sep='')
    exit()

# Display results.
print('Vtq: ', vtq, sep='')
' This example shows how to read a single item from the device, and display its value, timestamp and quality.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel

Namespace DataAccess.Xml
    Partial Friend Class ReadItem
        Public Shared Sub DeviceSourceXml()
            ' Instantiate the client object.
            Dim client = New EasyDAClient()

            Console.WriteLine("Reading item...")
            Dim vtq As DAVtq
            Try
                ' DADataSource enumeration:
                ' Selects the data source for OPC reads (from device, from OPC cache, or dynamically determined).
                ' The data source (memory, OPC cache or OPC device) selection is based on the desired value age and
                ' current status of data received from the server.

                vtq = client.ReadItem("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", "Dynamic/Analog Types/Int", DADataSource.Device)
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            Console.WriteLine("Vtq: {0}", vtq)
        End Sub
    End Class
End Namespace

 

OPC Data Client supports OPC XML-DA also on Linux and macOS.
// This example shows how to read 4 items from the device, and display their values, timestamps and qualities.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using System.Diagnostics;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;

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

            // DADataSource enumeration:
            // Selects the data source for OPC reads (from device, from OPC cache, or dynamically determined).
            // The data source (memory, OPC cache or OPC device) selection will be based on the desired value age and
            // current status of data received from the server.

            DAVtqResult[] vtqResults = client.ReadMultipleItems(
                new []
                    {
                        new DAReadItemArguments("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", "Dynamic/Analog Types/Double", DADataSource.Device),
                        new DAReadItemArguments("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", "Dynamic/Analog Types/Double[]", DADataSource.Device),
                        new DAReadItemArguments("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", "Dynamic/Analog Types/Int", DADataSource.Device),
                        new DAReadItemArguments("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", "Static/Analog Types/Int", DADataSource.Device)
                    });

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


        // Example output:
        //
        //vtqResults[0].Vtq: 100 {Double} @2024-01-01T14:31:03.232; GoodNonspecific (192)
        //vtqResults[1].Vtq: [3] {1000, 1000, 1000} {Double[]} @2024-01-01T14:31:03.232; GoodNonspecific (192)
        //vtqResults[2].Vtq: 700 {Int32} @2024-01-01T14:31:03.232; GoodNonspecific (192)
        //vtqResults[3].Vtq: 0 {Int32} @2024-01-01T14:31:03.232; GoodNonspecific (192)

    }
}
# This example shows how to read 4 items from the device, and display their values, timestamps and qualities.
#
# 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 .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.DataAccess.OperationModel import *


# Instantiate the client object.
client = EasyDAClient()

# DADataSource enumeration:
# Selects the data source for OPC reads (from device, from OPC cache, or dynamically determined).
# The data source (memory, OPC cache or OPC device) selection will be based on the desired value age and
# current status of data received from the server.

vtqResults = client.ReadMultipleItems(
    [
        DAReadItemArguments(ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'), DAItemDescriptor('Dynamic/Analog Types/Double'), DAReadParameters(DADataSource.Device)),
        DAReadItemArguments(ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'), DAItemDescriptor('Dynamic/Analog Types/Double[]'), DAReadParameters(DADataSource.Device)),
        DAReadItemArguments(ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'), DAItemDescriptor('Dynamic/Analog Types/Int'), DAReadParameters(DADataSource.Device)),
        DAReadItemArguments(ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'), DAItemDescriptor('Static/Analog Types/Int'), DAReadParameters(DADataSource.Device))
    ])

for i, vtqResult in enumerate(vtqResults):
    assert vtqResult is not None
    if vtqResult.Succeeded:
        print('vtqResults[', i, '].Vtq: ', vtqResult.Vtq, sep='')
    else:
        print('vtqResults[', i, '] *** Failure: ', vtqResult.ErrorMessageBrief, sep='')

# Example output:
#
#vtqResults[0].Vtq: 100 {Double} @2024-01-01T14:31:03.232; GoodNonspecific (192)
#vtqResults[1].Vtq: [3] {1000, 1000, 1000} {Double[]} @2024-01-01T14:31:03.232; GoodNonspecific (192)
#vtqResults[2].Vtq: 700 {Int32} @2024-01-01T14:31:03.232; GoodNonspecific (192)
#vtqResults[3].Vtq: 0 {Int32} @2024-01-01T14:31:03.232; GoodNonspecific (192)

' This example shows how to read 4 items from the device, and display their values, timestamps and qualities.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.OperationModel

Namespace DataAccess.Xml
    Partial Friend Class ReadMultipleItems
        Public Shared Sub DeviceSourceXml()
            ' Instantiate the client object.
            Dim client = New EasyDAClient()

            ' DADataSource enumeration
            ' Selects the data source for OPC reads (from device, from OPC cache, or dynamically determined).
            ' The data source (memory, OPC cache or OPC device) selection will be based on the desired value age and
            ' current status of data received from the server.

            Dim vtqResults() As DAVtqResult = client.ReadMultipleItems(New DAReadItemArguments() {
                New DAReadItemArguments("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", "Dynamic/Analog Types/Double", DADataSource.Device),
                New DAReadItemArguments("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", "Dynamic/Analog Types/Double[]", DADataSource.Device),
                New DAReadItemArguments("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", "Dynamic/Analog Types/Int", DADataSource.Device),
                New DAReadItemArguments("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", "Static/Analog Types/Int", DADataSource.Device)
            })

            For i = 0 To vtqResults.Length - 1
                Debug.Assert(vtqResults(i) IsNot Nothing)

                If vtqResults(i).Succeeded Then
                    Console.WriteLine("vtqResults[{0}].Vtq: {1}", i, vtqResults(i).Vtq)
                Else
                    Console.WriteLine("vtqResults[{0}] *** Failure: {1}", i, vtqResults(i).ErrorMessageBrief)
                End If
            Next i
        End Sub

        ' Example output
        '
        'vtqResults[0].Vtq: 100 {Double} @2024-01-01T14:31:03.232; GoodNonspecific (192)
        'vtqResults[1].Vtq: [3] {1000, 1000, 1000} {Double[]} @2024-01-01T14:31:03.232; GoodNonspecific (192)
        'vtqResults[2].Vtq: 700 {Int32} @2024-01-01T14:31:03.232; GoodNonspecific (192)
        'vtqResults[3].Vtq: 0 {Int32} @2024-01-01T14:31:03.232; GoodNonspecific (192)
    End Class
End Namespace

 

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

Synchronous and asynchronous reading

// This example shows how to read an item synchronously, and display its value, timestamp and quality.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    partial class ReadItem
    {
        public static void Synchronous()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            // Specify that only synchronous method is allowed. By default, both synchronous and asynchronous methods are
            // allowed, and the component picks a suitable method automatically. Disallowing asynchronous method leaves
            // only the synchronous method available for selection.
            client.InstanceParameters.Mode.AllowAsynchronousMethod = false;

            DAVtq vtq;
            try
            {
                vtq = client.ReadItem("", "OPCLabs.KitServer.2", "Simulation.Random");
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            Console.WriteLine("Vtq: {0}", vtq);
        }
    }
}
# This example shows how to read an item synchronously, and display its value, timestamp and quality.
#
# 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 .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.OperationModel import *


# Instantiate the client object.
client = EasyDAClient()

# Specify that only synchronous method is allowed. By default, both synchronous and asynchronous methods are
# allowed, and the component picks a suitable method automatically. Disallowing asynchronous method leaves
# only the synchronous method available for selection.
client.InstanceParameters.Mode.AllowAsynchronousMethod = False

# Perform the operation.
try:
    vtq = IEasyDAClientExtension.ReadItem(client, '', 'OPCLabs.KitServer.2', 'Simulation.Random')
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message, sep='')
    exit()

# Display results.
print('Vtq: ', vtq, sep='')
' This example shows how to read an item synchronously, and display its value, timestamp and quality.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel

Namespace DataAccess._EasyDAClient
    Partial Friend Class ReadItem
        Public Shared Sub Synchronous()
            ' Instantiate the client object.
            Dim client = New EasyDAClient()

            ' Specify that only synchronous method is allowed. By default, both synchronous and asynchronous methods are
            ' allowed, and the component picks a suitable method automatically. Disallowing asynchronous method leaves
            ' only the synchronous method available for selection.
            client.InstanceParameters.Mode.AllowAsynchronousMethod = False

            Dim vtq As DAVtq
            Try
                vtq = client.ReadItem("", "OPCLabs.KitServer.2", "Simulation.Random")
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            Console.WriteLine("Vtq: {0}", vtq)
        End Sub
    End Class
End Namespace

 

 

Inheritance Hierarchy

System.Object
   OpcLabs.BaseLib.Object2
      OpcLabs.BaseLib.Info
         OpcLabs.BaseLib.OperationModel.OperationArguments
            OpcLabs.EasyOpc.DataAccess.OperationModel.DAItemArguments
               OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments

Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also