OPC Studio User's Guide and Reference
ReadMultipleItemValues Method (_EasyDAClient)
Example 



OpcLabs.EasyOpcClassic Assembly > OpcLabs.EasyOpc.DataAccess.ComTypes Namespace > _EasyDAClient Interface : ReadMultipleItemValues Method
Array of arguments, one element per each OPC item involved in the operation.

The value of this parameter cannot be null (Nothing in Visual Basic).

The individual elements of the parameter value cannot be null (Nothing in Visual Basic).

Reads multiple named item values from a single OPC server, using array of argument objects as an input.
Syntax
'Declaration
 
<NotNullAttribute()>
Function ReadMultipleItemValues( _
   ByVal argumentsArray As Object _
) As Object()
'Usage
 
Dim instance As _EasyDAClient
Dim argumentsArray As Object
Dim value() As Object
 
value = instance.ReadMultipleItemValues(argumentsArray)
[NotNull()]
object[] ReadMultipleItemValues( 
   object argumentsArray
)
[NotNull()]
array<Object^>^ ReadMultipleItemValues( 
   Object^ argumentsArray
) 

Parameters

argumentsArray
Array of arguments, one element per each OPC item involved in the operation.

The value of this parameter cannot be null (Nothing in Visual Basic).

The individual elements of the parameter value cannot be null (Nothing in Visual Basic).

Return Value

The function returns an array of OpcLabs.BaseLib.OperationModel.ValueResult objects. The indices of elements in the output array are the same as those in the input array, argumentsArray.

This method never returns null (Nothing in Visual Basic).

The individual elements of the returned value are never null (Nothing in Visual Basic).

Exceptions
ExceptionDescription

A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

Remarks
The size of the input array will become the size of the output array. The element positions (indices) in the output array are the same as in the input array.

This member or type is for use from COM. It is not meant to be used from .NET or Python. Refer to the corresponding .NET member or type instead, if you are developing in .NET or Python.

This is an extension method (info: C#, VB.NET). In languages that have support for extensions methods (such as C# and VB.NET), you can use the extension method as if it were a regular method on the object that is its first parameter. In other languages (such as with Python.NET), you will call the extension as a static method, and pass it the object on which it acts as its first parameter.

Example

COM

// This example shows how to read values of 4 items at once, and display them.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

class procedure ReadMultipleItemValues.Main;
var
  Arguments: OleVariant;
  Client: OpcLabs_EasyOpcClassic_TLB._EasyDAClient;
  I: Cardinal;
  ReadItemArguments1: _DAReadItemArguments;
  ReadItemArguments2: _DAReadItemArguments;
  ReadItemArguments3: _DAReadItemArguments;
  ReadItemArguments4: _DAReadItemArguments;
  ValueResult: _ValueResult;
  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.ReadMultipleItemValues(Arguments));

  // Display results
  for I := VarArrayLowBound(Results, 1) to VarArrayHighBound(Results, 1) do
  begin
      ValueResult := IInterface(Results[I]) as _ValueResult;

      if ValueResult.Succeeded then
        WriteLn('results(', i, ').Value: ', ValueResult.Value)
      else
        WriteLn('results(', i, ') *** Failure: ', ValueResult.ErrorMessageBrief);
  end;

  VarClear(Results);
  VarClear(Arguments);
end;
REM This example shows how to read values of 4 items at once, and display them.
REM
REM Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
REM OPC client and subscriber examples in Visual Basic on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VB .
REM Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
REM a commercial license in order to use Online Forums, and we reply to every post.

Private Sub ReadMultipleItemValues_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.ReadMultipleItemValues(arguments)

    ' Display results
    Dim i: For i = LBound(results) To UBound(results)
        Dim valueResult As valueResult: Set valueResult = results(i)
        If valueResult.Succeeded Then
            OutputText = OutputText & "results(" & i & ").Value: " & valueResult.value & vbCrLf
        Else
            OutputText = OutputText & "results(" & i & ") *** Failure: " & valueResult.ErrorMessageBrief & vbCrLf
        End If
    Next
End Sub
Rem This example shows how to read values of 4 items at once, and display them.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.

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.ReadMultipleItemValues(arguments)

Dim i: For i = LBound(results) To UBound(results)
    Dim ValueResult: Set ValueResult = results(i)
    If ValueResult.Succeeded Then
        WScript.Echo "results(" & i & ").Value: " & ValueResult.Value
    Else
        WScript.Echo "results(" & i & ") *** Failure: " & ValueResult.ErrorMessageBrief
    End If
Next
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