QuickOPC User's Guide and Reference
UACallArguments Class
Members  Example 



OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA.OperationModel Namespace : UACallArguments Class
Holds all arguments needed to call a method in an OPC-UA server.
Object Model
UACallArguments ClassUANodeDescriptor ClassUAEndpointDescriptor ClassUANodeDescriptor ClassUANodeDescriptor Class
Syntax
'Declaration
 
<CLSCompliantAttribute(True)>
<ComDefaultInterfaceAttribute(OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UACallArguments)>
<ComVisibleAttribute(True)>
<GuidAttribute("F8BF32D9-A46C-4C9F-BAFB-45A19DB553BD")>
<TypeConverterAttribute(System.ComponentModel.ExpandableObjectConverter)>
<ValueControlAttribute("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.72.465.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   DefaultReadWrite=False, 
   Export=True, 
   PageId=10001)>
<SerializableAttribute()>
Public Class UACallArguments 
   Inherits UANodeArguments
   Implements LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.OperationModel.ComTypes._OperationArguments, OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UACallArguments, OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UANodeArguments, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable 
'Usage
 
Dim instance As UACallArguments
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UACallArguments)]
[ComVisible(true)]
[Guid("F8BF32D9-A46C-4C9F-BAFB-45A19DB553BD")]
[TypeConverter(System.ComponentModel.ExpandableObjectConverter)]
[ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.72.465.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   DefaultReadWrite=false, 
   Export=true, 
   PageId=10001)]
[Serializable()]
public class UACallArguments : UANodeArguments, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.OperationModel.ComTypes._OperationArguments, OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UACallArguments, OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UANodeArguments, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable  
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UACallArguments)]
[ComVisible(true)]
[Guid("F8BF32D9-A46C-4C9F-BAFB-45A19DB553BD")]
[TypeConverter(System.ComponentModel.ExpandableObjectConverter)]
[ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.72.465.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   DefaultReadWrite=false, 
   Export=true, 
   PageId=10001)]
[Serializable()]
public ref class UACallArguments : public UANodeArguments, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.BaseLib.OperationModel.ComTypes._OperationArguments, OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UACallArguments, OpcLabs.EasyOpc.UA.OperationModel.ComTypes._UANodeArguments, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable  
Remarks

 

In OPC-UA, Methods represent the function calls of Objects. Methods are called (invoked) and return after completion, whether successful or unsuccessful. Execution times for Methods may vary, depending on the function they are performing. A Method is always a component of an Object.

A single method

If you want to call a method on a specific object node in OPC UA, use the EasyUAClient.CallMethod method, passing it the endpoint descriptor, object node ID, method node ID, and optionally the method input arguments (if the method has any). The input arguments are specified by an array of objects. The number of arguments and their types must conform to the method's requirements.

If the operation is successful, it returns an array of output arguments of the method call. The number of output arguments and their types are given by the UA method.

.NET

// This example shows how to call a single method, and pass arguments to and from it.

using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples._EasyUAClient
{
    class CallMethod
    {
        public static void Main1()
        {
            UAEndpointDescriptor endpointDescriptor =
                "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
            // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
            // or "https://opcua.demo-this.com:51212/UA/SampleServer/"

            object[] inputs =
            {
                false, 
                1, 
                2, 
                3, 
                4, 
                5, 
                6, 
                7, 
                8, 
                9, 
                10
            };

            TypeCode[] typeCodes =
            {
                TypeCode.Boolean,
                TypeCode.SByte,
                TypeCode.Byte,
                TypeCode.Int16,
                TypeCode.UInt16,
                TypeCode.Int32,
                TypeCode.UInt32,
                TypeCode.Int64,
                TypeCode.UInt64,
                TypeCode.Single,
                TypeCode.Double
            };

            // Instantiate the client object
            var client = new EasyUAClient();

            // Perform the operation.
            object[] outputs;
            try
            {
                outputs = client.CallMethod(
                    endpointDescriptor,
                    "nsu=http://test.org/UA/Data/ ;i=10755",
                    "nsu=http://test.org/UA/Data/ ;i=10756",
                    inputs,
                    typeCodes);
            }
            catch (UAException uaException)
            {
                Console.WriteLine($"*** Failure: {uaException.GetBaseException().Message}");
                return;
            }

            // Display results
            for (int i = 0; i < outputs.Length; i++)
                Console.WriteLine($"outputs[{i}]: {outputs[i]}");

            // Example output:
            //outputs[0]: False
            //outputs[1]: 1
            //outputs[2]: 2
            //outputs[3]: 3
            //outputs[4]: 4
            //outputs[5]: 5
            //outputs[6]: 6
            //outputs[7]: 7
            //outputs[8]: 8
            //outputs[9]: 9
            //outputs[10]: 10        
        }
    }
}
# This example shows how to call a single method, and pass arguments to and from it.

#requires -Version 5.1
using namespace System
using namespace OpcLabs.EasyOpc.UA
using namespace OpcLabs.EasyOpc.UA.OperationModel

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

[UAEndpointDescriptor]$endpointDescriptor =
    "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
# or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
# or "https://opcua.demo-this.com:51212/UA/SampleServer/"

$inputs = @(
    $false,
    1, 
    2, 
    3, 
    4, 
    5, 
    6, 
    7, 
    8, 
    9, 
    10)

$typeCodes = @(
    [TypeCode]::Boolean,
    [TypeCode]::SByte,
    [TypeCode]::Byte,
    [TypeCode]::Int16,
    [TypeCode]::UInt16,
    [TypeCode]::Int32,
    [TypeCode]::UInt32,
    [TypeCode]::Int64,
    [TypeCode]::UInt64,
    [TypeCode]::Single,
    [TypeCode]::Double)

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

# Perform the operation.
try {
    $outputs = $client.CallMethod(
                    $endpointDescriptor,
                    "nsu=http://test.org/UA/Data/ ;i=10755",
                    "nsu=http://test.org/UA/Data/ ;i=10756",
                    $inputs,
                    $typeCodes)
}
catch [UAException] {
    Write-Host "*** Failure: $($PSItem.Exception.GetBaseException().Message)"
    return
}

# Display results
for ($i = 0; $i -lt $outputs.Length; $i++) {
    Write-Host "outputs[$($i)]: $($outputs[$i])"
}


# Example output:
#
#outputs[0]: False
#outputs[1]: 1
#outputs[2]: 2
#outputs[3]: 3
#outputs[4]: 4
#outputs[5]: 5
#outputs[6]: 6
#outputs[7]: 7
#outputs[8]: 8
#outputs[9]: 9
#outputs[10]: 10        

# This example shows how to call a single method, and pass arguments to and from it.

# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from System import *
from OpcLabs.EasyOpc.UA import *
from OpcLabs.EasyOpc.UA.OperationModel import *


endpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer')
# or 'http://opcua.demo-this.com:51211/UA/SampleServer' (currently not supported)
# or 'https://opcua.demo-this.com:51212/UA/SampleServer/'

# 
inputs = [False, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
typeCodes = [
    TypeCode.Boolean,
    TypeCode.SByte,
    TypeCode.Byte,
    TypeCode.Int16,
    TypeCode.UInt16,
    TypeCode.Int32,
    TypeCode.UInt32,
    TypeCode.Int64,
    TypeCode.UInt64,
    TypeCode.Single,
    TypeCode.Double,
    ]

# Instantiate the client object.
client = EasyUAClient()

# Perform the operation.
try:
    outputs = IEasyUAClientExtension.CallMethod(client,
        endpointDescriptor,
        UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10755'),
        UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10756'),
        inputs,
        typeCodes)
except UAException as uaException:
    print('*** Failure: ' + uaException.GetBaseException().Message)
    exit()

# Display results.
for i, value in enumerate(outputs):
     print('outputs[', i, ']: ', value, sep='')


# Example output:
#outputs[0]: False
#outputs[1]: 1
#outputs[2]: 2
#outputs[3]: 3
#outputs[4]: 4
#outputs[5]: 5
#outputs[6]: 6
#outputs[7]: 7
#outputs[8]: 8
#outputs[9]: 9.0
#outputs[10]: 10.0

' This example shows how to call a single method, and pass arguments to and from it.

Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.OperationModel

Namespace _EasyUAClient
    Friend Class CallMethod
        Public Shared Sub Main1()

            Dim endpointDescriptor As UAEndpointDescriptor =
                "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
            ' or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
            ' or "https://opcua.demo-this.com:51212/UA/SampleServer/"

            Dim inputs() As Object =
            { _
                False,
                1,
                2,
                3,
                4,
                5,
                6,
                7,
                8,
                9,
                10
            }

            Dim typeCodes() As TypeCode =
            { _
                TypeCode.Boolean,
                TypeCode.SByte,
                TypeCode.Byte,
                TypeCode.Int16,
                TypeCode.UInt16,
                TypeCode.Int32,
                TypeCode.UInt32,
                TypeCode.Int64,
                TypeCode.UInt64,
                TypeCode.Single,
                TypeCode.Double
            }

            ' Instantiate the client object
            Dim client = New EasyUAClient()

            ' Perform the operation
            Dim outputs() As Object
            Try
                outputs = client.CallMethod( _
                    endpointDescriptor, _
                    "nsu=http://test.org/UA/Data/ ;i=10755", _
                    "nsu=http://test.org/UA/Data/ ;i=10756", _
                    inputs, _
                    typeCodes)
            Catch uaException As UAException
                Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message)
                Exit Sub
            End Try

            ' Display results
            For i As Integer = 0 To outputs.Length - 1
                Console.WriteLine("outputs[{0}]: {1}", i, outputs(i))
            Next i

            ' Example output:
            'outputs[0]: False
            'outputs[1]: 1
            'outputs[2]: 2
            'outputs[3]: 3
            'outputs[4]: 4
            'outputs[5]: 5
            'outputs[6]: 6
            'outputs[7]: 7
            'outputs[8]: 8
            'outputs[9]: 9
            'outputs[10]: 10        
        End Sub
    End Class
End Namespace

COM

// This example shows how to call a single method, and pass arguments to and from it.

#include "stdafx.h"    // Includes "QuickOpc.h", and other commonly used files
#include <atlsafe.h>
#include "CallMethod.h"

namespace _EasyUAClient
{
    void CallMethod::Main()
    {
        // Initialize the COM library
        CoInitializeEx(NULL, COINIT_MULTITHREADED);
        {
            CComSafeArray<VARIANT> inputs(11);
            inputs.SetAt(0, _variant_t(false));
            inputs.SetAt(1, _variant_t(1));
            inputs.SetAt(2, _variant_t(2));
            inputs.SetAt(3, _variant_t(3));
            inputs.SetAt(4, _variant_t(4));
            inputs.SetAt(5, _variant_t(5));
            inputs.SetAt(6, _variant_t(6));
            inputs.SetAt(7, _variant_t(7));
            inputs.SetAt(8, _variant_t(8));
            inputs.SetAt(9, _variant_t(9));
            inputs.SetAt(10, _variant_t(10));
            CComVariant vInputs(inputs);

            CComSafeArray<VARIANT> typeCodes(11);
            typeCodes.SetAt(0, _variant_t(TypeCode_Boolean));
            typeCodes.SetAt(1, _variant_t(TypeCode_SByte));
            typeCodes.SetAt(2, _variant_t(TypeCode_Byte));
            typeCodes.SetAt(3, _variant_t(TypeCode_Int16));
            typeCodes.SetAt(4, _variant_t(TypeCode_UInt16));
            typeCodes.SetAt(5, _variant_t(TypeCode_Int32));
            typeCodes.SetAt(6, _variant_t(TypeCode_UInt32));
            typeCodes.SetAt(7, _variant_t(TypeCode_Int64));
            typeCodes.SetAt(8, _variant_t(TypeCode_UInt64));
            typeCodes.SetAt(9, _variant_t(TypeCode_Single));
            typeCodes.SetAt(10, _variant_t(TypeCode_Double));
            CComVariant vTypeCodes(typeCodes);

            // Instantiate the client object
            _EasyUAClientPtr ClientPtr(__uuidof(EasyUAClient));

            // Perform the operation
            CComSafeArray<VARIANT> outputs;
            outputs.Attach(ClientPtr->CallMethod(
                //L"http://opcua.demo-this.com:51211/UA/SampleServer",
                L"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer",
                L"nsu=http://test.org/UA/Data/ ;i=10755",
                L"nsu=http://test.org/UA/Data/ ;i=10756",
                &vInputs,
                &vTypeCodes));
    
            // Display results
            for (int i = outputs.GetLowerBound(); i <= outputs.GetUpperBound(); i++)
            {
                _variant_t output(outputs[i]);
                _variant_t vString;
                vString.ChangeType(VT_BSTR, &output);
                _tprintf(_T("outputs(d)s\n"), i, (LPCTSTR)CW2CT((_bstr_t)vString));
            }
        }
         // Release all interface pointers BEFORE calling CoUninitialize()
        CoUninitialize();
    }
}
// This example shows how to call a single method, and pass arguments to and
// from it.

class procedure CallMethod.Main;
var
  Client: EasyUAClient;
  I: Cardinal;
  Inputs: OleVariant;
  Outputs: OleVariant;
  TypeCodes: OleVariant;
begin
  Inputs := VarArrayCreate([0, 10], varVariant);
  Inputs[0] := False;
  Inputs[1] := 1;
  Inputs[2] := 2;
  Inputs[3] := 3;
  Inputs[4] := 4;
  Inputs[5] := 5;
  Inputs[6] := 6;
  Inputs[7] := 7;
  Inputs[8] := 8;
  Inputs[9] := 9;
  Inputs[10] := 10;

  TypeCodes := VarArrayCreate([0, 10], varVariant);
  TypeCodes[0] := TypeCode_Boolean;
  TypeCodes[1] := TypeCode_SByte;
  TypeCodes[2] := TypeCode_Byte;
  TypeCodes[3] := TypeCode_Int16;
  TypeCodes[4] := TypeCode_UInt16;
  TypeCodes[5] := TypeCode_Int32;
  TypeCodes[6] := TypeCode_UInt32;
  TypeCodes[7] := TypeCode_Int64;
  TypeCodes[8] := TypeCode_UInt64;
  TypeCodes[9] := TypeCode_Single;
  TypeCodes[10] := TypeCode_Double;

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

  // Perform the operation
  TVarData(Outputs).VType := varArray or varVariant;
  TVarData(Outputs).VArray := PVarArray(Client.CallMethod(
    //'http://opcua.demo-this.com:51211/UA/SampleServer',
    'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer',
    'nsu=http://test.org/UA/Data/ ;i=10755',
    'nsu=http://test.org/UA/Data/ ;i=10756',
    PSafeArray(TVarData(Inputs).VArray),
    PSafeArray(TVarData(TypeCodes).VArray)));

  // Display results
  for I := VarArrayLowBound(Outputs, 1) to VarArrayHighBound(Outputs, 1) do
      try
        WriteLn('outputs(', I, '): ', Outputs[I]);
      except
        on EVariantError do WriteLn('*** Error displaying the value');
      end;
end;
// This example shows how to call a single method, and pass arguments to and
// from it.

class procedure CallMethod.Main;
var
  Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient;
  I: Cardinal;
  Inputs: OleVariant;
  Outputs: OleVariant;
  TypeCodes: OleVariant;
begin
  Inputs := VarArrayCreate([0, 10], varVariant);
  Inputs[0] := False;
  Inputs[1] := 1;
  Inputs[2] := 2;
  Inputs[3] := 3;
  Inputs[4] := 4;
  Inputs[5] := 5;
  Inputs[6] := 6;
  Inputs[7] := 7;
  Inputs[8] := 8;
  Inputs[9] := 9;
  Inputs[10] := 10;

  TypeCodes := VarArrayCreate([0, 10], varVariant);
  TypeCodes[0] := TypeCode_Boolean;
  TypeCodes[1] := TypeCode_SByte;
  TypeCodes[2] := TypeCode_Byte;
  TypeCodes[3] := TypeCode_Int16;
  TypeCodes[4] := TypeCode_UInt16;
  TypeCodes[5] := TypeCode_Int32;
  TypeCodes[6] := TypeCode_UInt32;
  TypeCodes[7] := TypeCode_Int64;
  TypeCodes[8] := TypeCode_UInt64;
  TypeCodes[9] := TypeCode_Single;
  TypeCodes[10] := TypeCode_Double;

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

  // Perform the operation
  try
    TVarData(Outputs).VType := varArray or varVariant;
    TVarData(Outputs).VArray := PVarArray(Client.CallMethod(
      //'http://opcua.demo-this.com:51211/UA/SampleServer',
      //'https://opcua.demo-this.com:51212/UA/SampleServer/',
      'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer',
      'nsu=http://test.org/UA/Data/ ;i=10755',
      'nsu=http://test.org/UA/Data/ ;i=10756',
      Inputs,
      TypeCodes));
  except
    on E: EOleException do
    begin
      WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
      Exit;
    end;
  end;

  // Display results
  for I := VarArrayLowBound(Outputs, 1) to VarArrayHighBound(Outputs, 1) do
      WriteLn('outputs(', I, '): ', Outputs[I]);

   VarClear(Outputs);
   VarClear(TypeCodes);
   VarClear(Inputs);

end;
// This example shows how to call a single method, and pass arguments to and from it.

$inputs[0] = false;
$inputs[1] = 1;
$inputs[2] = 2;
$inputs[3] = 3;
$inputs[4] = 4;
$inputs[5] = 5;
$inputs[6] = 6;
$inputs[7] = 7;
$inputs[8] = 8;
$inputs[9] = 9;
$inputs[10] = 10;

$typeCodes[0] = 3;    // TypeCode.Boolean
$typeCodes[1] = 5;    // TypeCode.SByte
$typeCodes[2] = 6;    // TypeCode.Byte
$typeCodes[3] = 7;    // TypeCode.Int16
$typeCodes[4] = 8;    // TypeCode.UInt16
$typeCodes[5] = 9;    // TypeCode.Int32
$typeCodes[6] = 10;   // TypeCode.UInt32
$typeCodes[7] = 11;   // TypeCode.Int64
$typeCodes[8] = 12;   // TypeCode.UInt64
$typeCodes[9] = 13;   // TypeCode.Single
$typeCodes[10] = 14;  // TypeCode.Double

// Instantiate the client object
$Client = new COM("OpcLabs.EasyOpc.UA.EasyUAClient");

// Perform the operation
try
{
    $outputs = $Client->CallMethod(
        //"http://opcua.demo-this.com:51211/UA/SampleServer", 
        "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", 
        "nsu=http://test.org/UA/Data/ ;i=10755", 
        "nsu=http://test.org/UA/Data/ ;i=10756", 
        $inputs, 
        $typeCodes);
}
catch (com_exception $e)
{
    printf("*** Failure: %s\n", $e->getMessage());
    Exit();
}

// Display results
for ($i = 0; $i < count($outputs); $i++)
{
    printf("outputs[d]s\n", $i, $outputs[$i]);
}
# This example shows how to call a single method, and pass arguments to and from it.

# 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!
import win32com.client
from pywintypes import com_error

# Instantiate the client object
client = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.EasyUAClient') 

# 
inputs = [False, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
typeCodes = [
    3,  # TypeCode.Boolean
    5,  # TypeCode.SByte
    6,  # TypeCode.Byte
    7,  # TypeCode.Int16
    8,  # TypeCode.UInt16
    9,  # TypeCode.Int32
    10, # TypeCode.UInt32
    11, # TypeCode.Int64
    12, # TypeCode.UInt64
    13, # TypeCode.Single
    14  # TypeCode.Double
    ]


# Perform the operation
try:
    outputs = client.CallMethod(
        'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer',
        'nsu=http://test.org/UA/Data/ ;i=10755',
        'nsu=http://test.org/UA/Data/ ;i=10756',
        inputs,
        typeCodes)
    # outputs[0] contains the actual results; outputs[1] and outputs[2] are copies of inputs and typeCodes.
except com_error as e:
    print('*** Failure: ' + e.args[2][1] + ': ' + e.args[2][2])
    exit()


# Display results
for i, value in enumerate(outputs[0]):
     print('outputs[', i, ']: ', value)

# Example output:
#outputs[0]: False
#outputs[1]: 1
#outputs[2]: 2
#outputs[3]: 3
#outputs[4]: 4
#outputs[5]: 5
#outputs[6]: 6
#outputs[7]: 7
#outputs[8]: 8
#outputs[9]: 9.0
#outputs[10]: 10.0

Rem This example shows how to call a single method, and pass arguments to and from it.

Public Sub CallMethod_Main_Command_Click()
    OutputText = ""

    Dim inputs(10)
    inputs(0) = False
    inputs(1) = 1
    inputs(2) = 2
    inputs(3) = 3
    inputs(4) = 4
    inputs(5) = 5
    inputs(6) = 6
    inputs(7) = 7
    inputs(8) = 8
    inputs(9) = 9
    inputs(10) = 10

    Dim typeCodes(10)
    typeCodes(0) = 3    ' TypeCode.Boolean
    typeCodes(1) = 5    ' TypeCode.SByte
    typeCodes(2) = 6    ' TypeCode.Byte
    typeCodes(3) = 7    ' TypeCode.Int16
    typeCodes(4) = 8    ' TypeCode.UInt16
    typeCodes(5) = 9    ' TypeCode.Int32
    typeCodes(6) = 10   ' TypeCode.UInt32
    typeCodes(7) = 11   ' TypeCode.Int64
    typeCodes(8) = 12   ' TypeCode.UInt64
    typeCodes(9) = 13   ' TypeCode.Single
    typeCodes(10) = 14  ' TypeCode.Double

    ' Instantiate the client object
    Dim Client As New EasyUAClient

    ' Perform the operation
    On Error Resume Next
    Dim outputs As Variant
    outputs = Client.CallMethod( _
        "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", _
        "nsu=http://test.org/UA/Data/ ;i=10755", _
        "nsu=http://test.org/UA/Data/ ;i=10756", _
        inputs, _
        typeCodes)
    If Err.Number <> 0 Then
        OutputText = OutputText & "*** Failure: " & Err.Source & ": " & Err.Description & vbCrLf
        Exit Sub
    End If
    On Error GoTo 0

    ' Display results
    Dim i: For i = LBound(outputs) To UBound(outputs)
        On Error Resume Next
        OutputText = OutputText & "outputs(" & i & "): " & outputs(i) & vbCrLf
        If Err <> 0 Then OutputText = OutputText & "*** Error" & vbCrLf ' occurrs with types not recognized by VB6
        On Error GoTo 0
    Next
End Sub
Rem This example shows how to call a single method, and pass arguments to and from it.

Option Explicit

Dim inputs(10)
inputs(0) = False
inputs(1) = 1
inputs(2) = 2
inputs(3) = 3
inputs(4) = 4
inputs(5) = 5
inputs(6) = 6
inputs(7) = 7
inputs(8) = 8
inputs(9) = 9
inputs(10) = 10

Dim typeCodes(10)
typeCodes(0) = 3    ' TypeCode.Boolean
typeCodes(1) = 5    ' TypeCode.SByte
typeCodes(2) = 6    ' TypeCode.Byte
typeCodes(3) = 7    ' TypeCode.Int16
typeCodes(4) = 8    ' TypeCode.UInt16
typeCodes(5) = 9    ' TypeCode.Int32
typeCodes(6) = 10   ' TypeCode.UInt32
typeCodes(7) = 11   ' TypeCode.Int64
typeCodes(8) = 12   ' TypeCode.UInt64
typeCodes(9) = 13   ' TypeCode.Single
typeCodes(10) = 14  ' TypeCode.Double

' Instantiate the client object
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")

' Perform the operation
On Error Resume Next
Dim outputs: outputs = Client.CallMethod( _
    "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", _
    "nsu=http://test.org/UA/Data/ ;i=10755", _
    "nsu=http://test.org/UA/Data/ ;i=10756", _
    inputs, _
    typeCodes)
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0

' Display results
Dim i: For i = LBound(outputs) To UBound(outputs)
    On Error Resume Next
    WScript.Echo "outputs(" & i & "): " & outputs(i)
    If Err <> 0 Then WScript.Echo "*** Error"   ' occurrs with types not recognized by VBScript
    On Error Goto 0
Next

 

Multiple methods; argument type conversion

For making multiple method calls (on the same or different object nodes) in an efficient manner, use the EasyUAClient.CallMultipleMethods method. You pass in an array of UACallArguments objects, each specifying the location of the object node, the method node, and the input arguments to be passed to the method.

If the originating tool or language cannot directly supply the argument in a type that is required for the method by the OPC UA server, you can have the value converted to the desired type internally by QuickOPC. The corresponding type information can be passed in some method overrides, or inside a UACallArguments object (using the InputTypeCodesInputTypeFullName or InputTypes property).

.NET

// This example shows how to call multiple methods, and pass arguments to and
// from them.

using System;
using System.Diagnostics;
using OpcLabs.BaseLib.OperationModel;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples._EasyUAClient
{
    class CallMultipleMethods
    {
        public static void Main1()
        {

            UAEndpointDescriptor endpointDescriptor =
                "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
            // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
            // or "https://opcua.demo-this.com:51212/UA/SampleServer/"
            UANodeDescriptor nodeDescriptor = "nsu=http://test.org/UA/Data/ ;i=10755";

            object[] inputs1 =
            {
                false, 
                1, 
                2, 
                3, 
                4, 
                5, 
                6, 
                7, 
                8, 
                9, 
                10
            };

            TypeCode[] typeCodes1 =
            {
                TypeCode.Boolean,
                TypeCode.SByte,
                TypeCode.Byte,
                TypeCode.Int16,
                TypeCode.UInt16,
                TypeCode.Int32,
                TypeCode.UInt32,
                TypeCode.Int64,
                TypeCode.UInt64,
                TypeCode.Single,
                TypeCode.Double
            };

            object[] inputs2 =
            {
                false, 
                1, 
                2, 
                3, 
                4, 
                5, 
                6, 
                7, 
                8, 
                9, 
                10,
                "eleven"
            };

            TypeCode[] typeCodes2 =
            {
                TypeCode.Boolean,
                TypeCode.SByte,
                TypeCode.Byte,
                TypeCode.Int16,
                TypeCode.UInt16,
                TypeCode.Int32,
                TypeCode.UInt32,
                TypeCode.Int64,
                TypeCode.UInt64,
                TypeCode.Single,
                TypeCode.Double,
                TypeCode.String
            };

            // Instantiate the client object
            var client = new EasyUAClient();

            // Perform the operation.
            ValueArrayResult[] results = client.CallMultipleMethods(new[]
            {
                new UACallArguments(endpointDescriptor, nodeDescriptor, 
                    "nsu=http://test.org/UA/Data/ ;i=10756", inputs1, typeCodes1),
                new UACallArguments(endpointDescriptor, nodeDescriptor, 
                    "nsu=http://test.org/UA/Data/ ;i=10774", inputs2, typeCodes2)
            });

            // Display results
            for (int i = 0; i < results.Length; i++)
            {
                Console.WriteLine();
                Console.WriteLine($"results[{i}]:");

                ValueArrayResult result = results[i];
                if (result.Succeeded)
                {
                    object[] outputs = result.ValueArray;
                    Debug.Assert(outputs != null);

                    for (int j = 0; j < outputs.Length; j++)
                        Console.WriteLine($"    outputs[{j}]: {outputs[j]}");
                }
                else
                    Console.WriteLine($"*** Failure: {result.ErrorMessageBrief}");
            }

            // Example output:
            //results[0]:
            //    outputs[0]: False
            //    outputs[1]: 1
            //    outputs[2]: 2
            //    outputs[3]: 3
            //    outputs[4]: 4
            //    outputs[5]: 5
            //    outputs[6]: 6
            //    outputs[7]: 7
            //    outputs[8]: 8
            //    outputs[9]: 9
            //    outputs[10]: 10

            //results[1]:
            //    outputs[0]: False
            //    outputs[1]: 1
            //    outputs[2]: 2
            //    outputs[3]: 3
            //    outputs[4]: 4
            //    outputs[5]: 5
            //    outputs[6]: 6
            //    outputs[7]: 7
            //    outputs[8]: 8
            //    outputs[9]: 9
            //    outputs[10]: 10
            //    outputs[11]: eleven
        }
    }
}
# This example shows how to call multiple methods, and pass arguments to and
# from them.

#requires -Version 5.1
using namespace OpcLabs.BaseLib.OperationModel
using namespace OpcLabs.EasyOpc.UA
using namespace OpcLabs.EasyOpc.UA.OperationModel

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

[UAEndpointDescriptor]$endpointDescriptor =
    "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
# or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
# or "https://opcua.demo-this.com:51212/UA/SampleServer/"
$nodeDescriptor = New-Object UANodeDescriptor("nsu=http://test.org/UA/Data/ ;i=10755")

$inputs1 = @(
    $false,
    1, 
    2, 
    3, 
    4, 
    5, 
    6, 
    7, 
    8, 
    9, 
    10)

$typeCodes1 = @(
    [TypeCode]::Boolean,
    [TypeCode]::SByte,
    [TypeCode]::Byte,
    [TypeCode]::Int16,
    [TypeCode]::UInt16,
    [TypeCode]::Int32,
    [TypeCode]::UInt32,
    [TypeCode]::Int64,
    [TypeCode]::UInt64,
    [TypeCode]::Single,
    [TypeCode]::Double)


$inputs2 = @(
    $false, 
    1, 
    2, 
    3, 
    4, 
    5, 
    6, 
    7, 
    8, 
    9, 
    10,
    "eleven")

$typeCodes2 = @(
    [TypeCode]::Boolean,
    [TypeCode]::SByte,
    [TypeCode]::Byte,
    [TypeCode]::Int16,
    [TypeCode]::UInt16,
    [TypeCode]::Int32,
    [TypeCode]::UInt32,
    [TypeCode]::Int64,
    [TypeCode]::UInt64,
    [TypeCode]::Single,
    [TypeCode]::Double,
    [TypeCode]::String)

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

# Perform the operation.
$results = $client.CallMultipleMethods(@(
    (New-Object UACallArguments($endpointDescriptor, $nodeDescriptor, 
        "nsu=http://test.org/UA/Data/ ;i=10756", $inputs1, $typeCodes1)),
    (New-Object UACallArguments($endpointDescriptor, $nodeDescriptor, 
        "nsu=http://test.org/UA/Data/ ;i=10774", $inputs2, $typeCodes2))
    ))

# Display results
for ($i = 0; $i -lt $results.Length; $i++) {
    Write-Host
    Write-Host "results[$($i)]:"

    $result = $results[$i]
    if ($result.Succeeded) {
        $outputs = $result.ValueArray
        for ($j = 0; $j -lt $outputs.Length; $j++) {
            Write-Host "    outputs[$($j)]: $($outputs[$j])"
        }
    }
    else {
        Write-Host "*** Failure: $($vtqResult.ErrorMessageBrief)"
    }


# Example output:
#
#results[0]:
#    outputs[0]: False
#    outputs[1]: 1
#    outputs[2]: 2
#    outputs[3]: 3
#    outputs[4]: 4
#    outputs[5]: 5
#    outputs[6]: 6
#    outputs[7]: 7
#    outputs[8]: 8
#    outputs[9]: 9
#    outputs[10]: 10

#results[1]:
#    outputs[0]: False
#    outputs[1]: 1
#    outputs[2]: 2
#    outputs[3]: 3
#    outputs[4]: 4
#    outputs[5]: 5
#    outputs[6]: 6
#    outputs[7]: 7
#    outputs[8]: 8
#    outputs[9]: 9
#    outputs[10]: 10
#    outputs[11]: eleven
}
# This example shows how to call multiple methods, and pass arguments to and
# from them.

# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from System import *
from OpcLabs.EasyOpc.UA import *
from OpcLabs.EasyOpc.UA.OperationModel import *


endpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer')
# or 'http://opcua.demo-this.com:51211/UA/SampleServer' (currently not supported)
# or 'https://opcua.demo-this.com:51212/UA/SampleServer/'
nodeDescriptor = UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10755')

#
inputs1 = [False, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
typeCodes1 = [
    TypeCode.Boolean,
    TypeCode.SByte,
    TypeCode.Byte,
    TypeCode.Int16,
    TypeCode.UInt16,
    TypeCode.Int32,
    TypeCode.UInt32,
    TypeCode.Int64,
    TypeCode.UInt64,
    TypeCode.Single,
    TypeCode.Double,
    ]

inputs2 = [False, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'eleven']
typeCodes2 = [
    TypeCode.Boolean,
    TypeCode.SByte,
    TypeCode.Byte,
    TypeCode.Int16,
    TypeCode.UInt16,
    TypeCode.Int32,
    TypeCode.UInt32,
    TypeCode.Int64,
    TypeCode.UInt64,
    TypeCode.Single,
    TypeCode.Double,
    TypeCode.String,
    ]

# Instantiate the client object.
client = EasyUAClient()

# Perform the operation.
try:
    valueArrayResultArray = client.CallMultipleMethods([
        UACallArguments(endpointDescriptor, nodeDescriptor,
                        UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10756'), inputs1, typeCodes1),
        UACallArguments(endpointDescriptor, nodeDescriptor,
                        UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10774'), inputs2, typeCodes2),
        ])
except UAException as uaException:
    print('*** Failure: ' + uaException.GetBaseException().Message)
    exit()

# Display results.
for i, valueArrayResult in enumerate(valueArrayResultArray):
    print()
    print('valueArrayResultArray[', i, ']:', sep='')
    if valueArrayResult.Succeeded:
        assert valueArrayResult.ValueArray is not None
        for j, outputValueArray in enumerate(valueArrayResult.ValueArray):
            print('    valueArray[', j, ']: ', outputValueArray, sep='')
    else:
        print('*** Failure: ', valueArrayResult.ErrorMessageBrief, sep='')

print()
print('Finished.')
' This example shows how to call multiple methods, and pass arguments to and
' from them.

Imports OpcLabs.BaseLib.OperationModel
Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.OperationModel

Namespace _EasyUAClient
    Friend Class CallMultipleMethods
        Public Shared Sub Main1()

            Dim endpointDescriptor As UAEndpointDescriptor =
                "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
            ' or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
            ' or "https://opcua.demo-this.com:51212/UA/SampleServer/"
            Dim nodeDescriptor As UANodeDescriptor = "nsu=http://test.org/UA/Data/ ;i=10755"

            Dim inputs1() As Object =
            { _
                False,
                1,
                2,
                3,
                4,
                5,
                6,
                7,
                8,
                9,
                10
            }

            Dim typeCodes1() As TypeCode =
            { _
                TypeCode.Boolean,
                TypeCode.SByte,
                TypeCode.Byte,
                TypeCode.Int16,
                TypeCode.UInt16,
                TypeCode.Int32,
                TypeCode.UInt32,
                TypeCode.Int64,
                TypeCode.UInt64,
                TypeCode.Single,
                TypeCode.Double
            }

            Dim inputs2() As Object =
            { _
                False,
                1,
                2,
                3,
                4,
                5,
                6,
                7,
                8,
                9,
                10,
                "eleven"
            }

            Dim typeCodes2() As TypeCode =
            { _
                TypeCode.Boolean,
                TypeCode.SByte,
                TypeCode.Byte,
                TypeCode.Int16,
                TypeCode.UInt16,
                TypeCode.Int32,
                TypeCode.UInt32,
                TypeCode.Int64,
                TypeCode.UInt64,
                TypeCode.Single,
                TypeCode.Double,
                TypeCode.String
            }

            ' Instantiate the client object
            Dim client = New EasyUAClient()

            ' Perform the operation
            Dim results() As ValueArrayResult = client.CallMultipleMethods(New UACallArguments() _
    { _
        New UACallArguments(endpointDescriptor, nodeDescriptor, _
            "nsu=http://test.org/UA/Data/ ;i=10756", inputs1, typeCodes1), _
        New UACallArguments(endpointDescriptor, nodeDescriptor, _
            "nsu=http://test.org/UA/Data/ ;i=10774", inputs2, typeCodes2) _
    } _
            )

            ' Display results
            For i As Integer = 0 To results.Length - 1
                Console.WriteLine()
                Console.WriteLine("results[{0}]:", i)

                Dim result As ValueArrayResult = results(i)
                If result.Succeeded Then
                    Dim outputs As Object() = result.ValueArray
                    Debug.Assert(outputs IsNot Nothing)

                    For j As Integer = 0 To outputs.Length - 1
                        Console.WriteLine("    outputs[{0}]: {1}", j, outputs(j))
                    Next j
                Else
                    Console.WriteLine("*** Failure: {0}", result.ErrorMessageBrief)
                End If
            Next i

            ' Example output:
            'outputs[0]: False
            'outputs[1]: 1
            'outputs[2]: 2
            'outputs[3]: 3
            'outputs[4]: 4
            'outputs[5]: 5
            'outputs[6]: 6
            'outputs[7]: 7
            'outputs[8]: 8
            'outputs[9]: 9
            'outputs[10]: 10       

            'results[1]:
            'outputs[0]: False
            'outputs[1]: 1
            'outputs[2]: 2
            'outputs[3]: 3
            'outputs[4]: 4
            'outputs[5]: 5
            'outputs[6]: 6
            'outputs[7]: 7
            'outputs[8]: 8
            'outputs[9]: 9
            'outputs[10]: 10
            'outputs[11]: eleven
        End Sub
    End Class
End Namespace

COM

// This example shows how to call multiple methods, and pass arguments to and from them.

#include "stdafx.h"    // Includes "QuickOpc.h", and other commonly used files
#include <atlsafe.h>
#include "CallMultipleMethods.h"

namespace _EasyUAClient
{
    void CallMultipleMethods::Main()
    {
        // Initialize the COM library
        CoInitializeEx(NULL, COINIT_MULTITHREADED);
        {
            CComSafeArray<VARIANT> inputs1(11);
            inputs1.SetAt(0, _variant_t(false));
            inputs1.SetAt(1, _variant_t(1));
            inputs1.SetAt(2, _variant_t(2));
            inputs1.SetAt(3, _variant_t(3));
            inputs1.SetAt(4, _variant_t(4));
            inputs1.SetAt(5, _variant_t(5));
            inputs1.SetAt(6, _variant_t(6));
            inputs1.SetAt(7, _variant_t(7));
            inputs1.SetAt(8, _variant_t(8));
            inputs1.SetAt(9, _variant_t(9));
            inputs1.SetAt(10, _variant_t(10));

            CComSafeArray<VARIANT> typeCodes1(11);
            typeCodes1.SetAt(0, _variant_t(TypeCode_Boolean));
            typeCodes1.SetAt(1, _variant_t(TypeCode_SByte));
            typeCodes1.SetAt(2, _variant_t(TypeCode_Byte));
            typeCodes1.SetAt(3, _variant_t(TypeCode_Int16));
            typeCodes1.SetAt(4, _variant_t(TypeCode_UInt16));
            typeCodes1.SetAt(5, _variant_t(TypeCode_Int32));
            typeCodes1.SetAt(6, _variant_t(TypeCode_UInt32));
            typeCodes1.SetAt(7, _variant_t(TypeCode_Int64));
            typeCodes1.SetAt(8, _variant_t(TypeCode_UInt64));
            typeCodes1.SetAt(9, _variant_t(TypeCode_Single));
            typeCodes1.SetAt(10, _variant_t(TypeCode_Double));
            CComVariant vTypeCodes1(typeCodes1);

            _UACallArgumentsPtr CallArguments1Ptr(__uuidof(UACallArguments));
            CallArguments1Ptr->EndpointDescriptor->UrlString = 
                //L"http://opcua.demo-this.com:51211/UA/SampleServer";
                L"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
                CallArguments1Ptr->NodeDescriptor->NodeId->ExpandedText = L"nsu=http://test.org/UA/Data/ ;i=10755";
            CallArguments1Ptr->MethodNodeDescriptor->NodeId->ExpandedText = L"nsu=http://test.org/UA/Data/ ;i=10756";
            CallArguments1Ptr->InputArguments = inputs1;
            CallArguments1Ptr->InputTypeCodes = vTypeCodes1;

            CComSafeArray<VARIANT> inputs2(12);
            inputs2.SetAt(0, _variant_t(false));
            inputs2.SetAt(1, _variant_t(1));
            inputs2.SetAt(2, _variant_t(2));
            inputs2.SetAt(3, _variant_t(3));
            inputs2.SetAt(4, _variant_t(4));
            inputs2.SetAt(5, _variant_t(5));
            inputs2.SetAt(6, _variant_t(6));
            inputs2.SetAt(7, _variant_t(7));
            inputs2.SetAt(8, _variant_t(8));
            inputs2.SetAt(9, _variant_t(9));
            inputs2.SetAt(10, _variant_t(10));
            inputs2.SetAt(11, _variant_t(L"eleven"));

            CComSafeArray<VARIANT> typeCodes2(12);
            typeCodes2.SetAt(0, _variant_t(TypeCode_Boolean));
            typeCodes2.SetAt(1, _variant_t(TypeCode_SByte));
            typeCodes2.SetAt(2, _variant_t(TypeCode_Byte));
            typeCodes2.SetAt(3, _variant_t(TypeCode_Int16));
            typeCodes2.SetAt(4, _variant_t(TypeCode_UInt16));
            typeCodes2.SetAt(5, _variant_t(TypeCode_Int32));
            typeCodes2.SetAt(6, _variant_t(TypeCode_UInt32));
            typeCodes2.SetAt(7, _variant_t(TypeCode_Int64));
            typeCodes2.SetAt(8, _variant_t(TypeCode_UInt64));
            typeCodes2.SetAt(9, _variant_t(TypeCode_Single));
            typeCodes2.SetAt(10, _variant_t(TypeCode_Double));
            typeCodes2.SetAt(11, _variant_t(TypeCode_String));
            CComVariant vTypeCodes2(typeCodes2);

            _UACallArgumentsPtr CallArguments2Ptr(__uuidof(UACallArguments));
            CallArguments2Ptr->EndpointDescriptor->UrlString = 
                //L"http://opcua.demo-this.com:51211/UA/SampleServer";
                L"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
            CallArguments2Ptr->NodeDescriptor->NodeId->ExpandedText = L"nsu=http://test.org/UA/Data/ ;i=10755";
            CallArguments2Ptr->MethodNodeDescriptor->NodeId->ExpandedText = L"nsu=http://test.org/UA/Data/ ;i=10774";
            CallArguments2Ptr->InputArguments = inputs2;
            CallArguments2Ptr->InputTypeCodes = vTypeCodes2;

            CComSafeArray<VARIANT> arguments(2);
            arguments.SetAt(0, _variant_t((IDispatch*)CallArguments1Ptr));
            arguments.SetAt(1, _variant_t((IDispatch*)CallArguments2Ptr));
            CComVariant vArguments(arguments);

            // Instantiate the client object
            _EasyUAClientPtr ClientPtr(__uuidof(EasyUAClient));

            // Perform the operation
            CComSafeArray<VARIANT> results;
            results.Attach(ClientPtr->CallMultipleMethods(&vArguments));
    
            // Display results
            for (int i = results.GetLowerBound(); i <= results.GetUpperBound(); i++)
            {
                _tprintf(_T("\n"));
                _tprintf(_T("results(%d):\n"), i);
                _ValueArrayResultPtr ResultPtr = results[i];

                if (ResultPtr->Exception == NULL)
                {
                    CComVariant valueArray(ResultPtr->ValueArray);
                    CComSafeArray<VARIANT> outputs(valueArray.parray);
                    for (int j = outputs.GetLowerBound(); j <= outputs.GetUpperBound(); j++)
                    {
                        _variant_t output(outputs[j]);
                        _variant_t vString;
                        vString.ChangeType(VT_BSTR, &output);
                        _tprintf(_T("    outputs(d)s\n"), i, (LPCTSTR)CW2CT((_bstr_t)vString));
                    }
                }
                else
                    _tprintf(_T("*** Error: %s\n"), (LPCTSTR)CW2CT(ResultPtr->Exception->ToString));
            }
        }
         // Release all interface pointers BEFORE calling CoUninitialize()
        CoUninitialize();
    }
}
// This example shows how to call multiple methods, and pass arguments to and
// from them.

class procedure CallMultipleMethods.Main;
var
  Arguments: OleVariant;
  CallArguments1, CallArguments2: _UACallArguments;
  Client: EasyUAClient;
  I, J: Cardinal;
  Inputs1, Inputs2: OleVariant;
  Outputs: OleVariant;
  Result: _ValueArrayResult;
  Results: OleVariant;
  TypeCodes1, TypeCodes2: OleVariant;
begin
  Inputs1 := VarArrayCreate([0, 10], varVariant);
  Inputs1[0] := False;
  Inputs1[1] := 1;
  Inputs1[2] := 2;
  Inputs1[3] := 3;
  Inputs1[4] := 4;
  Inputs1[5] := 5;
  Inputs1[6] := 6;
  Inputs1[7] := 7;
  Inputs1[8] := 8;
  Inputs1[9] := 9;
  Inputs1[10] := 10;

  TypeCodes1 := VarArrayCreate([0, 10], varVariant);
  TypeCodes1[0] := TypeCode_Boolean;
  TypeCodes1[1] := TypeCode_SByte;
  TypeCodes1[2] := TypeCode_Byte;
  TypeCodes1[3] := TypeCode_Int16;
  TypeCodes1[4] := TypeCode_UInt16;
  TypeCodes1[5] := TypeCode_Int32;
  TypeCodes1[6] := TypeCode_UInt32;
  TypeCodes1[7] := TypeCode_Int64;
  TypeCodes1[8] := TypeCode_UInt64;
  TypeCodes1[9] := TypeCode_Single;
  TypeCodes1[10] := TypeCode_Double;

  CallArguments1 := CoUACallArguments.Create;
  CallArguments1.EndpointDescriptor.UrlString := 
    //'http://opcua.demo-this.com:51211/UA/SampleServer';
    'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer';
  CallArguments1.NodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10755';
  CallArguments1.MethodNodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10756';
  CallArguments1.InputArguments := PSafeArray(TVarData(Inputs1).VArray);
  CallArguments1.InputTypeCodes := PSafeArray(TVarData(TypeCodes1).VArray);

  Inputs2 := VarArrayCreate([0, 11], varVariant);
  Inputs2[0] := False;
  Inputs2[1] := 1;
  Inputs2[2] := 2;
  Inputs2[3] := 3;
  Inputs2[4] := 4;
  Inputs2[5] := 5;
  Inputs2[6] := 6;
  Inputs2[7] := 7;
  Inputs2[8] := 8;
  Inputs2[9] := 9;
  Inputs2[10] := 10;
  Inputs2[11] := 'eleven';

  TypeCodes2 := VarArrayCreate([0, 11], varVariant);
  TypeCodes2[0] := TypeCode_Boolean;
  TypeCodes2[1] := TypeCode_SByte;
  TypeCodes2[2] := TypeCode_Byte;
  TypeCodes2[3] := TypeCode_Int16;
  TypeCodes2[4] := TypeCode_UInt16;
  TypeCodes2[5] := TypeCode_Int32;
  TypeCodes2[6] := TypeCode_UInt32;
  TypeCodes2[7] := TypeCode_Int64;
  TypeCodes2[8] := TypeCode_UInt64;
  TypeCodes2[9] := TypeCode_Single;
  TypeCodes2[10] := TypeCode_Double;
  TypeCodes2[11] := TypeCode_String;

  CallArguments2 := CoUACallArguments.Create;
  CallArguments2.EndpointDescriptor.UrlString := 
    //'http://opcua.demo-this.com:51211/UA/SampleServer';
    'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer';
  CallArguments2.NodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10755';
  CallArguments2.MethodNodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10774';
  CallArguments2.InputArguments := PSafeArray(TVarData(Inputs2).VArray);
  CallArguments2.InputTypeCodes := PSafeArray(TVarData(TypeCodes2).VArray);

  Arguments := VarArrayCreate([0, 1], varVariant);
  Arguments[0] := CallArguments1;
  Arguments[1] := CallArguments2;

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

  // Perform the operation
  TVarData(Results).VType := varArray or varVariant;
  TVarData(Results).VArray := PVarArray(Client.CallMultipleMethods(
    PSafeArray(TVarData(Arguments).VArray)));

  // Display results
  for I := VarArrayLowBound(Results, 1) to VarArrayHighBound(Results, 1) do
  begin
    WriteLn;
    WriteLn('results(', I, '):');
    Result := IInterface(Results[I]) as _ValueArrayResult;

    if Result.Exception = nil then
      begin
        TVarData(Outputs).VType := varArray or varVariant;
        TVarData(Outputs).VArray := PVarArray(Result.ValueArray);
        for J := VarArrayLowBound(Outputs, 1) to VarArrayHighBound(Outputs, 1) do
          try
            WriteLn('    ', 'outputs(', J, '): ', Outputs[J]);
          except
            on EVariantError do WriteLn('*** Error displaying the value');
          end;
      end
    else
      WriteLn('*** Error: ', Result.Exception.ToString);
  end;
end;
// This example shows how to call multiple methods, and pass arguments to and
// from them.

class procedure CallMultipleMethods.Main;
var
  Arguments: OleVariant;
  CallArguments1, CallArguments2: _UACallArguments;
  Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient;
  I, J: Cardinal;
  Inputs1, Inputs2: OleVariant;
  Outputs: OleVariant;
  Result: _ValueArrayResult;
  Results: OleVariant;
  TypeCodes1, TypeCodes2: OleVariant;
begin
  Inputs1 := VarArrayCreate([0, 10], varVariant);
  Inputs1[0] := False;
  Inputs1[1] := 1;
  Inputs1[2] := 2;
  Inputs1[3] := 3;
  Inputs1[4] := 4;
  Inputs1[5] := 5;
  Inputs1[6] := 6;
  Inputs1[7] := 7;
  Inputs1[8] := 8;
  Inputs1[9] := 9;
  Inputs1[10] := 10;

  TypeCodes1 := VarArrayCreate([0, 10], varVariant);
  TypeCodes1[0] := TypeCode_Boolean;
  TypeCodes1[1] := TypeCode_SByte;
  TypeCodes1[2] := TypeCode_Byte;
  TypeCodes1[3] := TypeCode_Int16;
  TypeCodes1[4] := TypeCode_UInt16;
  TypeCodes1[5] := TypeCode_Int32;
  TypeCodes1[6] := TypeCode_UInt32;
  TypeCodes1[7] := TypeCode_Int64;
  TypeCodes1[8] := TypeCode_UInt64;
  TypeCodes1[9] := TypeCode_Single;
  TypeCodes1[10] := TypeCode_Double;

  CallArguments1 := CoUACallArguments.Create;
  CallArguments1.EndpointDescriptor.UrlString := 
    //'http://opcua.demo-this.com:51211/UA/SampleServer';
    //'https://opcua.demo-this.com:51212/UA/SampleServer/';
    'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer';
  CallArguments1.NodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10755';
  CallArguments1.MethodNodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10756';
  CallArguments1.InputArguments := PSafeArray(TVarData(Inputs1).VArray);
  CallArguments1.InputTypeCodes := TypeCodes1;

  Inputs2 := VarArrayCreate([0, 11], varVariant);
  Inputs2[0] := False;
  Inputs2[1] := 1;
  Inputs2[2] := 2;
  Inputs2[3] := 3;
  Inputs2[4] := 4;
  Inputs2[5] := 5;
  Inputs2[6] := 6;
  Inputs2[7] := 7;
  Inputs2[8] := 8;
  Inputs2[9] := 9;
  Inputs2[10] := 10;
  Inputs2[11] := 'eleven';

  TypeCodes2 := VarArrayCreate([0, 11], varVariant);
  TypeCodes2[0] := TypeCode_Boolean;
  TypeCodes2[1] := TypeCode_SByte;
  TypeCodes2[2] := TypeCode_Byte;
  TypeCodes2[3] := TypeCode_Int16;
  TypeCodes2[4] := TypeCode_UInt16;
  TypeCodes2[5] := TypeCode_Int32;
  TypeCodes2[6] := TypeCode_UInt32;
  TypeCodes2[7] := TypeCode_Int64;
  TypeCodes2[8] := TypeCode_UInt64;
  TypeCodes2[9] := TypeCode_Single;
  TypeCodes2[10] := TypeCode_Double;
  TypeCodes2[11] := TypeCode_String;

  CallArguments2 := CoUACallArguments.Create;
  CallArguments2.EndpointDescriptor.UrlString := 
    //'http://opcua.demo-this.com:51211/UA/SampleServer';
    //'https://opcua.demo-this.com:51212/UA/SampleServer/';
    'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer';
  CallArguments2.NodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10755';
  CallArguments2.MethodNodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10774';
  CallArguments2.InputArguments := PSafeArray(TVarData(Inputs2).VArray);
  CallArguments2.InputTypeCodes := TypeCodes2;

  Arguments := VarArrayCreate([0, 1], varVariant);
  Arguments[0] := CallArguments1;
  Arguments[1] := CallArguments2;

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

  // Perform the operation
  TVarData(Results).VType := varArray or varVariant;
  TVarData(Results).VArray := PVarArray(Client.CallMultipleMethods(
    Arguments));

  // Display results
  for I := VarArrayLowBound(Results, 1) to VarArrayHighBound(Results, 1) do
  begin
    WriteLn;
    WriteLn('results(', I, '):');
    Result := IInterface(Results[I]) as _ValueArrayResult;

    if Result.Exception = nil then
      begin
        Outputs := Result.ValueArray;
        for J := VarArrayLowBound(Outputs, 1) to VarArrayHighBound(Outputs, 1) do
          WriteLn('    ', 'outputs(', J, '): ', Outputs[J]);
      end
    else
      WriteLn('*** Failure: ', Result.Exception.ToString);
  end;

  VarClear(Results);
  VarClear(TypeCodes2);
  VarClear(TypeCodes1);
  VarClear(Arguments);
end;
Rem This example shows how to call multiple methods, and pass arguments to and from them.

Public Sub CallMultipleMethods_Main_Command_Click()
    OutputText = ""

    Dim inputs1(10)
    inputs1(0) = False
    inputs1(1) = 1
    inputs1(2) = 2
    inputs1(3) = 3
    inputs1(4) = 4
    inputs1(5) = 5
    inputs1(6) = 6
    inputs1(7) = 7
    inputs1(8) = 8
    inputs1(9) = 9
    inputs1(10) = 10

    Dim typeCodes1(10)
    typeCodes1(0) = 3    ' TypeCode.Boolean
    typeCodes1(1) = 5    ' TypeCode.SByte
    typeCodes1(2) = 6    ' TypeCode.Byte
    typeCodes1(3) = 7    ' TypeCode.Int16
    typeCodes1(4) = 8    ' TypeCode.UInt16
    typeCodes1(5) = 9    ' TypeCode.Int32
    typeCodes1(6) = 10   ' TypeCode.UInt32
    typeCodes1(7) = 11   ' TypeCode.Int64
    typeCodes1(8) = 12   ' TypeCode.UInt64
    typeCodes1(9) = 13   ' TypeCode.Single
    typeCodes1(10) = 14  ' TypeCode.Double

    Dim CallArguments1 As New UACallArguments
    CallArguments1.endpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
    CallArguments1.nodeDescriptor.NodeId.expandedText = "nsu=http://test.org/UA/Data/ ;i=10755"
    CallArguments1.MethodNodeDescriptor.NodeId.expandedText = "nsu=http://test.org/UA/Data/ ;i=10756"
    ' Use SetXXXX methods instead of array-type property setters in Visual Basic 6.0
    CallArguments1.SetInputArguments inputs1
    CallArguments1.SetInputTypeCodes typeCodes1

    Dim inputs2(11)
    inputs2(0) = False
    inputs2(1) = 1
    inputs2(2) = 2
    inputs2(3) = 3
    inputs2(4) = 4
    inputs2(5) = 5
    inputs2(6) = 6
    inputs2(7) = 7
    inputs2(8) = 8
    inputs2(9) = 9
    inputs2(10) = 10
    inputs2(11) = "eleven"

    Dim typeCodes2(11)
    typeCodes2(0) = 3    ' TypeCode.Boolean
    typeCodes2(1) = 5    ' TypeCode.SByte
    typeCodes2(2) = 6    ' TypeCode.Byte
    typeCodes2(3) = 7    ' TypeCode.Int16
    typeCodes2(4) = 8    ' TypeCode.UInt16
    typeCodes2(5) = 9    ' TypeCode.Int32
    typeCodes2(6) = 10   ' TypeCode.UInt32
    typeCodes2(7) = 11   ' TypeCode.Int64
    typeCodes2(8) = 12   ' TypeCode.UInt64
    typeCodes2(9) = 13   ' TypeCode.Single
    typeCodes2(10) = 14  ' TypeCode.Double
    typeCodes2(11) = 18  ' TypeCode.String

    Dim CallArguments2 As New UACallArguments
    CallArguments2.endpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
    CallArguments2.nodeDescriptor.NodeId.expandedText = "nsu=http://test.org/UA/Data/ ;i=10755"
    CallArguments2.MethodNodeDescriptor.NodeId.expandedText = "nsu=http://test.org/UA/Data/ ;i=10774"
    ' Use SetXXXX methods instead of array-type property setters in Visual Basic 6.0
    CallArguments2.SetInputArguments inputs2
    CallArguments2.SetInputTypeCodes typeCodes2

    Dim arguments(1) As Variant
    Set arguments(0) = CallArguments1
    Set arguments(1) = CallArguments2

    ' Instantiate the client object
    Dim Client As New EasyUAClient

    ' Perform the operation
    Dim results As Variant
    results = Client.CallMultipleMethods(arguments)

    ' Display results
    Dim i: For i = LBound(results) To UBound(results)
        OutputText = OutputText & vbCrLf
        OutputText = OutputText & "results(" & i & "):" & vbCrLf
        Dim Result As ValueArrayResult: Set Result = results(i)

        If Result.Exception Is Nothing Then
            Dim outputs As Variant: outputs = Result.ValueArray
            Dim j: For j = LBound(outputs) To UBound(outputs)
                On Error Resume Next
                OutputText = OutputText & Space(4) & "outputs(" & j & "): " & outputs(j) & vbCrLf
                If Err <> 0 Then OutputText = OutputText & Space(4) & "*** Error" & vbCrLf ' occurrs with types not recognized by VB6
                On Error GoTo 0
            Next
        Else
            OutputText = OutputText & "*** Error: " & Result.Exception & vbCrLf
        End If
    Next
End Sub
Rem This example shows how to call multiple methods, and pass arguments to and from them.

Option Explicit

Dim inputs1(10)
inputs1(0) = False
inputs1(1) = 1
inputs1(2) = 2
inputs1(3) = 3
inputs1(4) = 4
inputs1(5) = 5
inputs1(6) = 6
inputs1(7) = 7
inputs1(8) = 8
inputs1(9) = 9
inputs1(10) = 10

Dim typeCodes1(10)
typeCodes1(0) = 3    ' TypeCode.Boolean
typeCodes1(1) = 5    ' TypeCode.SByte
typeCodes1(2) = 6    ' TypeCode.Byte
typeCodes1(3) = 7    ' TypeCode.Int16
typeCodes1(4) = 8    ' TypeCode.UInt16
typeCodes1(5) = 9    ' TypeCode.Int32
typeCodes1(6) = 10   ' TypeCode.UInt32
typeCodes1(7) = 11   ' TypeCode.Int64
typeCodes1(8) = 12   ' TypeCode.UInt64
typeCodes1(9) = 13   ' TypeCode.Single
typeCodes1(10) = 14  ' TypeCode.Double

Dim CallArguments1: Set CallArguments1 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UACallArguments")
CallArguments1.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
CallArguments1.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10755"
CallArguments1.MethodNodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10756"
CallArguments1.InputArguments = inputs1
CallArguments1.InputTypeCodes = typeCodes1

Dim inputs2(11)
inputs2(0) = False
inputs2(1) = 1
inputs2(2) = 2
inputs2(3) = 3
inputs2(4) = 4
inputs2(5) = 5
inputs2(6) = 6
inputs2(7) = 7
inputs2(8) = 8
inputs2(9) = 9
inputs2(10) = 10
inputs2(11) = "eleven"

Dim typeCodes2(11)
typeCodes2(0) = 3    ' TypeCode.Boolean
typeCodes2(1) = 5    ' TypeCode.SByte
typeCodes2(2) = 6    ' TypeCode.Byte
typeCodes2(3) = 7    ' TypeCode.Int16
typeCodes2(4) = 8    ' TypeCode.UInt16
typeCodes2(5) = 9    ' TypeCode.Int32
typeCodes2(6) = 10   ' TypeCode.UInt32
typeCodes2(7) = 11   ' TypeCode.Int64
typeCodes2(8) = 12   ' TypeCode.UInt64
typeCodes2(9) = 13   ' TypeCode.Single
typeCodes2(10) = 14  ' TypeCode.Double
typeCodes2(11) = 18  ' TypeCode.String

Dim CallArguments2: Set CallArguments2 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UACallArguments")
CallArguments2.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
CallArguments2.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10755"
CallArguments2.MethodNodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10774"
CallArguments2.InputArguments = inputs2
CallArguments2.InputTypeCodes = typeCodes2

Dim arguments(1)
Set arguments(0) = CallArguments1
Set arguments(1) = CallArguments2

' Instantiate the client object
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")

' Perform the operation
Dim results: results = Client.CallMultipleMethods(arguments)

' Display results
Dim i: For i = LBound(results) To UBound(results)
    WScript.Echo
    WScript.Echo "results(" & i & "):"
    Dim Result: Set Result = results(i)

    If Result.Exception Is Nothing Then
        Dim outputs: outputs = Result.ValueArray
        Dim j: For j = LBound(outputs) To UBound(outputs)
            On Error Resume Next
            WScript.Echo Space(4) & "outputs(" & j & "): " & outputs(j)
            If Err <> 0 Then WScript.Echo Space(4) & "*** Error"   ' occurrs with types not recognized by VBScript
            On Error Goto 0
        Next
    Else
        WScript.Echo "*** Error: " & Result.Exception
    End If
Next

 

The features discussed here, or some of them, may not be available in all editions of the product. Check the Product Editions page for differences between the editions. The trial license has all features enabled (and is limited in period for which it provides valid data), but licenses for specific commercial editions may have functionality limitations.

Advanced

If you access some node or nodes repeatedly, it might be possible to improve the performance of it by (pre-)registering the node or nodes with the server. The performance improvement will only occur if the target OPC UA server supports the necessary node registration services. For more information, see OPC UA Node Registration Service.

 

Example

.NET

COM

// This example shows how to call multiple methods, and pass arguments to and
// from them.

using System;
using System.Diagnostics;
using OpcLabs.BaseLib.OperationModel;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples._EasyUAClient
{
    class CallMultipleMethods
    {
        public static void Main1()
        {

            UAEndpointDescriptor endpointDescriptor =
                "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
            // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
            // or "https://opcua.demo-this.com:51212/UA/SampleServer/"
            UANodeDescriptor nodeDescriptor = "nsu=http://test.org/UA/Data/ ;i=10755";

            object[] inputs1 =
            {
                false, 
                1, 
                2, 
                3, 
                4, 
                5, 
                6, 
                7, 
                8, 
                9, 
                10
            };

            TypeCode[] typeCodes1 =
            {
                TypeCode.Boolean,
                TypeCode.SByte,
                TypeCode.Byte,
                TypeCode.Int16,
                TypeCode.UInt16,
                TypeCode.Int32,
                TypeCode.UInt32,
                TypeCode.Int64,
                TypeCode.UInt64,
                TypeCode.Single,
                TypeCode.Double
            };

            object[] inputs2 =
            {
                false, 
                1, 
                2, 
                3, 
                4, 
                5, 
                6, 
                7, 
                8, 
                9, 
                10,
                "eleven"
            };

            TypeCode[] typeCodes2 =
            {
                TypeCode.Boolean,
                TypeCode.SByte,
                TypeCode.Byte,
                TypeCode.Int16,
                TypeCode.UInt16,
                TypeCode.Int32,
                TypeCode.UInt32,
                TypeCode.Int64,
                TypeCode.UInt64,
                TypeCode.Single,
                TypeCode.Double,
                TypeCode.String
            };

            // Instantiate the client object
            var client = new EasyUAClient();

            // Perform the operation.
            ValueArrayResult[] results = client.CallMultipleMethods(new[]
            {
                new UACallArguments(endpointDescriptor, nodeDescriptor, 
                    "nsu=http://test.org/UA/Data/ ;i=10756", inputs1, typeCodes1),
                new UACallArguments(endpointDescriptor, nodeDescriptor, 
                    "nsu=http://test.org/UA/Data/ ;i=10774", inputs2, typeCodes2)
            });

            // Display results
            for (int i = 0; i < results.Length; i++)
            {
                Console.WriteLine();
                Console.WriteLine($"results[{i}]:");

                ValueArrayResult result = results[i];
                if (result.Succeeded)
                {
                    object[] outputs = result.ValueArray;
                    Debug.Assert(outputs != null);

                    for (int j = 0; j < outputs.Length; j++)
                        Console.WriteLine($"    outputs[{j}]: {outputs[j]}");
                }
                else
                    Console.WriteLine($"*** Failure: {result.ErrorMessageBrief}");
            }

            // Example output:
            //results[0]:
            //    outputs[0]: False
            //    outputs[1]: 1
            //    outputs[2]: 2
            //    outputs[3]: 3
            //    outputs[4]: 4
            //    outputs[5]: 5
            //    outputs[6]: 6
            //    outputs[7]: 7
            //    outputs[8]: 8
            //    outputs[9]: 9
            //    outputs[10]: 10

            //results[1]:
            //    outputs[0]: False
            //    outputs[1]: 1
            //    outputs[2]: 2
            //    outputs[3]: 3
            //    outputs[4]: 4
            //    outputs[5]: 5
            //    outputs[6]: 6
            //    outputs[7]: 7
            //    outputs[8]: 8
            //    outputs[9]: 9
            //    outputs[10]: 10
            //    outputs[11]: eleven
        }
    }
}
# This example shows how to call multiple methods, and pass arguments to and
# from them.

#requires -Version 5.1
using namespace OpcLabs.BaseLib.OperationModel
using namespace OpcLabs.EasyOpc.UA
using namespace OpcLabs.EasyOpc.UA.OperationModel

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

[UAEndpointDescriptor]$endpointDescriptor =
    "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
# or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
# or "https://opcua.demo-this.com:51212/UA/SampleServer/"
$nodeDescriptor = New-Object UANodeDescriptor("nsu=http://test.org/UA/Data/ ;i=10755")

$inputs1 = @(
    $false,
    1, 
    2, 
    3, 
    4, 
    5, 
    6, 
    7, 
    8, 
    9, 
    10)

$typeCodes1 = @(
    [TypeCode]::Boolean,
    [TypeCode]::SByte,
    [TypeCode]::Byte,
    [TypeCode]::Int16,
    [TypeCode]::UInt16,
    [TypeCode]::Int32,
    [TypeCode]::UInt32,
    [TypeCode]::Int64,
    [TypeCode]::UInt64,
    [TypeCode]::Single,
    [TypeCode]::Double)


$inputs2 = @(
    $false, 
    1, 
    2, 
    3, 
    4, 
    5, 
    6, 
    7, 
    8, 
    9, 
    10,
    "eleven")

$typeCodes2 = @(
    [TypeCode]::Boolean,
    [TypeCode]::SByte,
    [TypeCode]::Byte,
    [TypeCode]::Int16,
    [TypeCode]::UInt16,
    [TypeCode]::Int32,
    [TypeCode]::UInt32,
    [TypeCode]::Int64,
    [TypeCode]::UInt64,
    [TypeCode]::Single,
    [TypeCode]::Double,
    [TypeCode]::String)

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

# Perform the operation.
$results = $client.CallMultipleMethods(@(
    (New-Object UACallArguments($endpointDescriptor, $nodeDescriptor, 
        "nsu=http://test.org/UA/Data/ ;i=10756", $inputs1, $typeCodes1)),
    (New-Object UACallArguments($endpointDescriptor, $nodeDescriptor, 
        "nsu=http://test.org/UA/Data/ ;i=10774", $inputs2, $typeCodes2))
    ))

# Display results
for ($i = 0; $i -lt $results.Length; $i++) {
    Write-Host
    Write-Host "results[$($i)]:"

    $result = $results[$i]
    if ($result.Succeeded) {
        $outputs = $result.ValueArray
        for ($j = 0; $j -lt $outputs.Length; $j++) {
            Write-Host "    outputs[$($j)]: $($outputs[$j])"
        }
    }
    else {
        Write-Host "*** Failure: $($vtqResult.ErrorMessageBrief)"
    }


# Example output:
#
#results[0]:
#    outputs[0]: False
#    outputs[1]: 1
#    outputs[2]: 2
#    outputs[3]: 3
#    outputs[4]: 4
#    outputs[5]: 5
#    outputs[6]: 6
#    outputs[7]: 7
#    outputs[8]: 8
#    outputs[9]: 9
#    outputs[10]: 10

#results[1]:
#    outputs[0]: False
#    outputs[1]: 1
#    outputs[2]: 2
#    outputs[3]: 3
#    outputs[4]: 4
#    outputs[5]: 5
#    outputs[6]: 6
#    outputs[7]: 7
#    outputs[8]: 8
#    outputs[9]: 9
#    outputs[10]: 10
#    outputs[11]: eleven
}
# This example shows how to call multiple methods, and pass arguments to and
# from them.

# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from System import *
from OpcLabs.EasyOpc.UA import *
from OpcLabs.EasyOpc.UA.OperationModel import *


endpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer')
# or 'http://opcua.demo-this.com:51211/UA/SampleServer' (currently not supported)
# or 'https://opcua.demo-this.com:51212/UA/SampleServer/'
nodeDescriptor = UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10755')

#
inputs1 = [False, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
typeCodes1 = [
    TypeCode.Boolean,
    TypeCode.SByte,
    TypeCode.Byte,
    TypeCode.Int16,
    TypeCode.UInt16,
    TypeCode.Int32,
    TypeCode.UInt32,
    TypeCode.Int64,
    TypeCode.UInt64,
    TypeCode.Single,
    TypeCode.Double,
    ]

inputs2 = [False, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'eleven']
typeCodes2 = [
    TypeCode.Boolean,
    TypeCode.SByte,
    TypeCode.Byte,
    TypeCode.Int16,
    TypeCode.UInt16,
    TypeCode.Int32,
    TypeCode.UInt32,
    TypeCode.Int64,
    TypeCode.UInt64,
    TypeCode.Single,
    TypeCode.Double,
    TypeCode.String,
    ]

# Instantiate the client object.
client = EasyUAClient()

# Perform the operation.
try:
    valueArrayResultArray = client.CallMultipleMethods([
        UACallArguments(endpointDescriptor, nodeDescriptor,
                        UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10756'), inputs1, typeCodes1),
        UACallArguments(endpointDescriptor, nodeDescriptor,
                        UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10774'), inputs2, typeCodes2),
        ])
except UAException as uaException:
    print('*** Failure: ' + uaException.GetBaseException().Message)
    exit()

# Display results.
for i, valueArrayResult in enumerate(valueArrayResultArray):
    print()
    print('valueArrayResultArray[', i, ']:', sep='')
    if valueArrayResult.Succeeded:
        assert valueArrayResult.ValueArray is not None
        for j, outputValueArray in enumerate(valueArrayResult.ValueArray):
            print('    valueArray[', j, ']: ', outputValueArray, sep='')
    else:
        print('*** Failure: ', valueArrayResult.ErrorMessageBrief, sep='')

print()
print('Finished.')
' This example shows how to call multiple methods, and pass arguments to and
' from them.

Imports OpcLabs.BaseLib.OperationModel
Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.OperationModel

Namespace _EasyUAClient
    Friend Class CallMultipleMethods
        Public Shared Sub Main1()

            Dim endpointDescriptor As UAEndpointDescriptor =
                "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
            ' or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
            ' or "https://opcua.demo-this.com:51212/UA/SampleServer/"
            Dim nodeDescriptor As UANodeDescriptor = "nsu=http://test.org/UA/Data/ ;i=10755"

            Dim inputs1() As Object =
            { _
                False,
                1,
                2,
                3,
                4,
                5,
                6,
                7,
                8,
                9,
                10
            }

            Dim typeCodes1() As TypeCode =
            { _
                TypeCode.Boolean,
                TypeCode.SByte,
                TypeCode.Byte,
                TypeCode.Int16,
                TypeCode.UInt16,
                TypeCode.Int32,
                TypeCode.UInt32,
                TypeCode.Int64,
                TypeCode.UInt64,
                TypeCode.Single,
                TypeCode.Double
            }

            Dim inputs2() As Object =
            { _
                False,
                1,
                2,
                3,
                4,
                5,
                6,
                7,
                8,
                9,
                10,
                "eleven"
            }

            Dim typeCodes2() As TypeCode =
            { _
                TypeCode.Boolean,
                TypeCode.SByte,
                TypeCode.Byte,
                TypeCode.Int16,
                TypeCode.UInt16,
                TypeCode.Int32,
                TypeCode.UInt32,
                TypeCode.Int64,
                TypeCode.UInt64,
                TypeCode.Single,
                TypeCode.Double,
                TypeCode.String
            }

            ' Instantiate the client object
            Dim client = New EasyUAClient()

            ' Perform the operation
            Dim results() As ValueArrayResult = client.CallMultipleMethods(New UACallArguments() _
    { _
        New UACallArguments(endpointDescriptor, nodeDescriptor, _
            "nsu=http://test.org/UA/Data/ ;i=10756", inputs1, typeCodes1), _
        New UACallArguments(endpointDescriptor, nodeDescriptor, _
            "nsu=http://test.org/UA/Data/ ;i=10774", inputs2, typeCodes2) _
    } _
            )

            ' Display results
            For i As Integer = 0 To results.Length - 1
                Console.WriteLine()
                Console.WriteLine("results[{0}]:", i)

                Dim result As ValueArrayResult = results(i)
                If result.Succeeded Then
                    Dim outputs As Object() = result.ValueArray
                    Debug.Assert(outputs IsNot Nothing)

                    For j As Integer = 0 To outputs.Length - 1
                        Console.WriteLine("    outputs[{0}]: {1}", j, outputs(j))
                    Next j
                Else
                    Console.WriteLine("*** Failure: {0}", result.ErrorMessageBrief)
                End If
            Next i

            ' Example output:
            'outputs[0]: False
            'outputs[1]: 1
            'outputs[2]: 2
            'outputs[3]: 3
            'outputs[4]: 4
            'outputs[5]: 5
            'outputs[6]: 6
            'outputs[7]: 7
            'outputs[8]: 8
            'outputs[9]: 9
            'outputs[10]: 10       

            'results[1]:
            'outputs[0]: False
            'outputs[1]: 1
            'outputs[2]: 2
            'outputs[3]: 3
            'outputs[4]: 4
            'outputs[5]: 5
            'outputs[6]: 6
            'outputs[7]: 7
            'outputs[8]: 8
            'outputs[9]: 9
            'outputs[10]: 10
            'outputs[11]: eleven
        End Sub
    End Class
End Namespace
// This example shows how to call multiple methods, and pass arguments to and from them.

#include "stdafx.h"    // Includes "QuickOpc.h", and other commonly used files
#include <atlsafe.h>
#include "CallMultipleMethods.h"

namespace _EasyUAClient
{
    void CallMultipleMethods::Main()
    {
        // Initialize the COM library
        CoInitializeEx(NULL, COINIT_MULTITHREADED);
        {
            CComSafeArray<VARIANT> inputs1(11);
            inputs1.SetAt(0, _variant_t(false));
            inputs1.SetAt(1, _variant_t(1));
            inputs1.SetAt(2, _variant_t(2));
            inputs1.SetAt(3, _variant_t(3));
            inputs1.SetAt(4, _variant_t(4));
            inputs1.SetAt(5, _variant_t(5));
            inputs1.SetAt(6, _variant_t(6));
            inputs1.SetAt(7, _variant_t(7));
            inputs1.SetAt(8, _variant_t(8));
            inputs1.SetAt(9, _variant_t(9));
            inputs1.SetAt(10, _variant_t(10));

            CComSafeArray<VARIANT> typeCodes1(11);
            typeCodes1.SetAt(0, _variant_t(TypeCode_Boolean));
            typeCodes1.SetAt(1, _variant_t(TypeCode_SByte));
            typeCodes1.SetAt(2, _variant_t(TypeCode_Byte));
            typeCodes1.SetAt(3, _variant_t(TypeCode_Int16));
            typeCodes1.SetAt(4, _variant_t(TypeCode_UInt16));
            typeCodes1.SetAt(5, _variant_t(TypeCode_Int32));
            typeCodes1.SetAt(6, _variant_t(TypeCode_UInt32));
            typeCodes1.SetAt(7, _variant_t(TypeCode_Int64));
            typeCodes1.SetAt(8, _variant_t(TypeCode_UInt64));
            typeCodes1.SetAt(9, _variant_t(TypeCode_Single));
            typeCodes1.SetAt(10, _variant_t(TypeCode_Double));
            CComVariant vTypeCodes1(typeCodes1);

            _UACallArgumentsPtr CallArguments1Ptr(__uuidof(UACallArguments));
            CallArguments1Ptr->EndpointDescriptor->UrlString = 
                //L"http://opcua.demo-this.com:51211/UA/SampleServer";
                L"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
                CallArguments1Ptr->NodeDescriptor->NodeId->ExpandedText = L"nsu=http://test.org/UA/Data/ ;i=10755";
            CallArguments1Ptr->MethodNodeDescriptor->NodeId->ExpandedText = L"nsu=http://test.org/UA/Data/ ;i=10756";
            CallArguments1Ptr->InputArguments = inputs1;
            CallArguments1Ptr->InputTypeCodes = vTypeCodes1;

            CComSafeArray<VARIANT> inputs2(12);
            inputs2.SetAt(0, _variant_t(false));
            inputs2.SetAt(1, _variant_t(1));
            inputs2.SetAt(2, _variant_t(2));
            inputs2.SetAt(3, _variant_t(3));
            inputs2.SetAt(4, _variant_t(4));
            inputs2.SetAt(5, _variant_t(5));
            inputs2.SetAt(6, _variant_t(6));
            inputs2.SetAt(7, _variant_t(7));
            inputs2.SetAt(8, _variant_t(8));
            inputs2.SetAt(9, _variant_t(9));
            inputs2.SetAt(10, _variant_t(10));
            inputs2.SetAt(11, _variant_t(L"eleven"));

            CComSafeArray<VARIANT> typeCodes2(12);
            typeCodes2.SetAt(0, _variant_t(TypeCode_Boolean));
            typeCodes2.SetAt(1, _variant_t(TypeCode_SByte));
            typeCodes2.SetAt(2, _variant_t(TypeCode_Byte));
            typeCodes2.SetAt(3, _variant_t(TypeCode_Int16));
            typeCodes2.SetAt(4, _variant_t(TypeCode_UInt16));
            typeCodes2.SetAt(5, _variant_t(TypeCode_Int32));
            typeCodes2.SetAt(6, _variant_t(TypeCode_UInt32));
            typeCodes2.SetAt(7, _variant_t(TypeCode_Int64));
            typeCodes2.SetAt(8, _variant_t(TypeCode_UInt64));
            typeCodes2.SetAt(9, _variant_t(TypeCode_Single));
            typeCodes2.SetAt(10, _variant_t(TypeCode_Double));
            typeCodes2.SetAt(11, _variant_t(TypeCode_String));
            CComVariant vTypeCodes2(typeCodes2);

            _UACallArgumentsPtr CallArguments2Ptr(__uuidof(UACallArguments));
            CallArguments2Ptr->EndpointDescriptor->UrlString = 
                //L"http://opcua.demo-this.com:51211/UA/SampleServer";
                L"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
            CallArguments2Ptr->NodeDescriptor->NodeId->ExpandedText = L"nsu=http://test.org/UA/Data/ ;i=10755";
            CallArguments2Ptr->MethodNodeDescriptor->NodeId->ExpandedText = L"nsu=http://test.org/UA/Data/ ;i=10774";
            CallArguments2Ptr->InputArguments = inputs2;
            CallArguments2Ptr->InputTypeCodes = vTypeCodes2;

            CComSafeArray<VARIANT> arguments(2);
            arguments.SetAt(0, _variant_t((IDispatch*)CallArguments1Ptr));
            arguments.SetAt(1, _variant_t((IDispatch*)CallArguments2Ptr));
            CComVariant vArguments(arguments);

            // Instantiate the client object
            _EasyUAClientPtr ClientPtr(__uuidof(EasyUAClient));

            // Perform the operation
            CComSafeArray<VARIANT> results;
            results.Attach(ClientPtr->CallMultipleMethods(&vArguments));
    
            // Display results
            for (int i = results.GetLowerBound(); i <= results.GetUpperBound(); i++)
            {
                _tprintf(_T("\n"));
                _tprintf(_T("results(%d):\n"), i);
                _ValueArrayResultPtr ResultPtr = results[i];

                if (ResultPtr->Exception == NULL)
                {
                    CComVariant valueArray(ResultPtr->ValueArray);
                    CComSafeArray<VARIANT> outputs(valueArray.parray);
                    for (int j = outputs.GetLowerBound(); j <= outputs.GetUpperBound(); j++)
                    {
                        _variant_t output(outputs[j]);
                        _variant_t vString;
                        vString.ChangeType(VT_BSTR, &output);
                        _tprintf(_T("    outputs(d)s\n"), i, (LPCTSTR)CW2CT((_bstr_t)vString));
                    }
                }
                else
                    _tprintf(_T("*** Error: %s\n"), (LPCTSTR)CW2CT(ResultPtr->Exception->ToString));
            }
        }
         // Release all interface pointers BEFORE calling CoUninitialize()
        CoUninitialize();
    }
}
// This example shows how to call multiple methods, and pass arguments to and
// from them.

class procedure CallMultipleMethods.Main;
var
  Arguments: OleVariant;
  CallArguments1, CallArguments2: _UACallArguments;
  Client: EasyUAClient;
  I, J: Cardinal;
  Inputs1, Inputs2: OleVariant;
  Outputs: OleVariant;
  Result: _ValueArrayResult;
  Results: OleVariant;
  TypeCodes1, TypeCodes2: OleVariant;
begin
  Inputs1 := VarArrayCreate([0, 10], varVariant);
  Inputs1[0] := False;
  Inputs1[1] := 1;
  Inputs1[2] := 2;
  Inputs1[3] := 3;
  Inputs1[4] := 4;
  Inputs1[5] := 5;
  Inputs1[6] := 6;
  Inputs1[7] := 7;
  Inputs1[8] := 8;
  Inputs1[9] := 9;
  Inputs1[10] := 10;

  TypeCodes1 := VarArrayCreate([0, 10], varVariant);
  TypeCodes1[0] := TypeCode_Boolean;
  TypeCodes1[1] := TypeCode_SByte;
  TypeCodes1[2] := TypeCode_Byte;
  TypeCodes1[3] := TypeCode_Int16;
  TypeCodes1[4] := TypeCode_UInt16;
  TypeCodes1[5] := TypeCode_Int32;
  TypeCodes1[6] := TypeCode_UInt32;
  TypeCodes1[7] := TypeCode_Int64;
  TypeCodes1[8] := TypeCode_UInt64;
  TypeCodes1[9] := TypeCode_Single;
  TypeCodes1[10] := TypeCode_Double;

  CallArguments1 := CoUACallArguments.Create;
  CallArguments1.EndpointDescriptor.UrlString := 
    //'http://opcua.demo-this.com:51211/UA/SampleServer';
    'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer';
  CallArguments1.NodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10755';
  CallArguments1.MethodNodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10756';
  CallArguments1.InputArguments := PSafeArray(TVarData(Inputs1).VArray);
  CallArguments1.InputTypeCodes := PSafeArray(TVarData(TypeCodes1).VArray);

  Inputs2 := VarArrayCreate([0, 11], varVariant);
  Inputs2[0] := False;
  Inputs2[1] := 1;
  Inputs2[2] := 2;
  Inputs2[3] := 3;
  Inputs2[4] := 4;
  Inputs2[5] := 5;
  Inputs2[6] := 6;
  Inputs2[7] := 7;
  Inputs2[8] := 8;
  Inputs2[9] := 9;
  Inputs2[10] := 10;
  Inputs2[11] := 'eleven';

  TypeCodes2 := VarArrayCreate([0, 11], varVariant);
  TypeCodes2[0] := TypeCode_Boolean;
  TypeCodes2[1] := TypeCode_SByte;
  TypeCodes2[2] := TypeCode_Byte;
  TypeCodes2[3] := TypeCode_Int16;
  TypeCodes2[4] := TypeCode_UInt16;
  TypeCodes2[5] := TypeCode_Int32;
  TypeCodes2[6] := TypeCode_UInt32;
  TypeCodes2[7] := TypeCode_Int64;
  TypeCodes2[8] := TypeCode_UInt64;
  TypeCodes2[9] := TypeCode_Single;
  TypeCodes2[10] := TypeCode_Double;
  TypeCodes2[11] := TypeCode_String;

  CallArguments2 := CoUACallArguments.Create;
  CallArguments2.EndpointDescriptor.UrlString := 
    //'http://opcua.demo-this.com:51211/UA/SampleServer';
    'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer';
  CallArguments2.NodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10755';
  CallArguments2.MethodNodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10774';
  CallArguments2.InputArguments := PSafeArray(TVarData(Inputs2).VArray);
  CallArguments2.InputTypeCodes := PSafeArray(TVarData(TypeCodes2).VArray);

  Arguments := VarArrayCreate([0, 1], varVariant);
  Arguments[0] := CallArguments1;
  Arguments[1] := CallArguments2;

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

  // Perform the operation
  TVarData(Results).VType := varArray or varVariant;
  TVarData(Results).VArray := PVarArray(Client.CallMultipleMethods(
    PSafeArray(TVarData(Arguments).VArray)));

  // Display results
  for I := VarArrayLowBound(Results, 1) to VarArrayHighBound(Results, 1) do
  begin
    WriteLn;
    WriteLn('results(', I, '):');
    Result := IInterface(Results[I]) as _ValueArrayResult;

    if Result.Exception = nil then
      begin
        TVarData(Outputs).VType := varArray or varVariant;
        TVarData(Outputs).VArray := PVarArray(Result.ValueArray);
        for J := VarArrayLowBound(Outputs, 1) to VarArrayHighBound(Outputs, 1) do
          try
            WriteLn('    ', 'outputs(', J, '): ', Outputs[J]);
          except
            on EVariantError do WriteLn('*** Error displaying the value');
          end;
      end
    else
      WriteLn('*** Error: ', Result.Exception.ToString);
  end;
end;
// This example shows how to call multiple methods, and pass arguments to and
// from them.

class procedure CallMultipleMethods.Main;
var
  Arguments: OleVariant;
  CallArguments1, CallArguments2: _UACallArguments;
  Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient;
  I, J: Cardinal;
  Inputs1, Inputs2: OleVariant;
  Outputs: OleVariant;
  Result: _ValueArrayResult;
  Results: OleVariant;
  TypeCodes1, TypeCodes2: OleVariant;
begin
  Inputs1 := VarArrayCreate([0, 10], varVariant);
  Inputs1[0] := False;
  Inputs1[1] := 1;
  Inputs1[2] := 2;
  Inputs1[3] := 3;
  Inputs1[4] := 4;
  Inputs1[5] := 5;
  Inputs1[6] := 6;
  Inputs1[7] := 7;
  Inputs1[8] := 8;
  Inputs1[9] := 9;
  Inputs1[10] := 10;

  TypeCodes1 := VarArrayCreate([0, 10], varVariant);
  TypeCodes1[0] := TypeCode_Boolean;
  TypeCodes1[1] := TypeCode_SByte;
  TypeCodes1[2] := TypeCode_Byte;
  TypeCodes1[3] := TypeCode_Int16;
  TypeCodes1[4] := TypeCode_UInt16;
  TypeCodes1[5] := TypeCode_Int32;
  TypeCodes1[6] := TypeCode_UInt32;
  TypeCodes1[7] := TypeCode_Int64;
  TypeCodes1[8] := TypeCode_UInt64;
  TypeCodes1[9] := TypeCode_Single;
  TypeCodes1[10] := TypeCode_Double;

  CallArguments1 := CoUACallArguments.Create;
  CallArguments1.EndpointDescriptor.UrlString := 
    //'http://opcua.demo-this.com:51211/UA/SampleServer';
    //'https://opcua.demo-this.com:51212/UA/SampleServer/';
    'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer';
  CallArguments1.NodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10755';
  CallArguments1.MethodNodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10756';
  CallArguments1.InputArguments := PSafeArray(TVarData(Inputs1).VArray);
  CallArguments1.InputTypeCodes := TypeCodes1;

  Inputs2 := VarArrayCreate([0, 11], varVariant);
  Inputs2[0] := False;
  Inputs2[1] := 1;
  Inputs2[2] := 2;
  Inputs2[3] := 3;
  Inputs2[4] := 4;
  Inputs2[5] := 5;
  Inputs2[6] := 6;
  Inputs2[7] := 7;
  Inputs2[8] := 8;
  Inputs2[9] := 9;
  Inputs2[10] := 10;
  Inputs2[11] := 'eleven';

  TypeCodes2 := VarArrayCreate([0, 11], varVariant);
  TypeCodes2[0] := TypeCode_Boolean;
  TypeCodes2[1] := TypeCode_SByte;
  TypeCodes2[2] := TypeCode_Byte;
  TypeCodes2[3] := TypeCode_Int16;
  TypeCodes2[4] := TypeCode_UInt16;
  TypeCodes2[5] := TypeCode_Int32;
  TypeCodes2[6] := TypeCode_UInt32;
  TypeCodes2[7] := TypeCode_Int64;
  TypeCodes2[8] := TypeCode_UInt64;
  TypeCodes2[9] := TypeCode_Single;
  TypeCodes2[10] := TypeCode_Double;
  TypeCodes2[11] := TypeCode_String;

  CallArguments2 := CoUACallArguments.Create;
  CallArguments2.EndpointDescriptor.UrlString := 
    //'http://opcua.demo-this.com:51211/UA/SampleServer';
    //'https://opcua.demo-this.com:51212/UA/SampleServer/';
    'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer';
  CallArguments2.NodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10755';
  CallArguments2.MethodNodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10774';
  CallArguments2.InputArguments := PSafeArray(TVarData(Inputs2).VArray);
  CallArguments2.InputTypeCodes := TypeCodes2;

  Arguments := VarArrayCreate([0, 1], varVariant);
  Arguments[0] := CallArguments1;
  Arguments[1] := CallArguments2;

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

  // Perform the operation
  TVarData(Results).VType := varArray or varVariant;
  TVarData(Results).VArray := PVarArray(Client.CallMultipleMethods(
    Arguments));

  // Display results
  for I := VarArrayLowBound(Results, 1) to VarArrayHighBound(Results, 1) do
  begin
    WriteLn;
    WriteLn('results(', I, '):');
    Result := IInterface(Results[I]) as _ValueArrayResult;

    if Result.Exception = nil then
      begin
        Outputs := Result.ValueArray;
        for J := VarArrayLowBound(Outputs, 1) to VarArrayHighBound(Outputs, 1) do
          WriteLn('    ', 'outputs(', J, '): ', Outputs[J]);
      end
    else
      WriteLn('*** Failure: ', Result.Exception.ToString);
  end;

  VarClear(Results);
  VarClear(TypeCodes2);
  VarClear(TypeCodes1);
  VarClear(Arguments);
end;
Rem This example shows how to call multiple methods, and pass arguments to and from them.

Public Sub CallMultipleMethods_Main_Command_Click()
    OutputText = ""

    Dim inputs1(10)
    inputs1(0) = False
    inputs1(1) = 1
    inputs1(2) = 2
    inputs1(3) = 3
    inputs1(4) = 4
    inputs1(5) = 5
    inputs1(6) = 6
    inputs1(7) = 7
    inputs1(8) = 8
    inputs1(9) = 9
    inputs1(10) = 10

    Dim typeCodes1(10)
    typeCodes1(0) = 3    ' TypeCode.Boolean
    typeCodes1(1) = 5    ' TypeCode.SByte
    typeCodes1(2) = 6    ' TypeCode.Byte
    typeCodes1(3) = 7    ' TypeCode.Int16
    typeCodes1(4) = 8    ' TypeCode.UInt16
    typeCodes1(5) = 9    ' TypeCode.Int32
    typeCodes1(6) = 10   ' TypeCode.UInt32
    typeCodes1(7) = 11   ' TypeCode.Int64
    typeCodes1(8) = 12   ' TypeCode.UInt64
    typeCodes1(9) = 13   ' TypeCode.Single
    typeCodes1(10) = 14  ' TypeCode.Double

    Dim CallArguments1 As New UACallArguments
    CallArguments1.endpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
    CallArguments1.nodeDescriptor.NodeId.expandedText = "nsu=http://test.org/UA/Data/ ;i=10755"
    CallArguments1.MethodNodeDescriptor.NodeId.expandedText = "nsu=http://test.org/UA/Data/ ;i=10756"
    ' Use SetXXXX methods instead of array-type property setters in Visual Basic 6.0
    CallArguments1.SetInputArguments inputs1
    CallArguments1.SetInputTypeCodes typeCodes1

    Dim inputs2(11)
    inputs2(0) = False
    inputs2(1) = 1
    inputs2(2) = 2
    inputs2(3) = 3
    inputs2(4) = 4
    inputs2(5) = 5
    inputs2(6) = 6
    inputs2(7) = 7
    inputs2(8) = 8
    inputs2(9) = 9
    inputs2(10) = 10
    inputs2(11) = "eleven"

    Dim typeCodes2(11)
    typeCodes2(0) = 3    ' TypeCode.Boolean
    typeCodes2(1) = 5    ' TypeCode.SByte
    typeCodes2(2) = 6    ' TypeCode.Byte
    typeCodes2(3) = 7    ' TypeCode.Int16
    typeCodes2(4) = 8    ' TypeCode.UInt16
    typeCodes2(5) = 9    ' TypeCode.Int32
    typeCodes2(6) = 10   ' TypeCode.UInt32
    typeCodes2(7) = 11   ' TypeCode.Int64
    typeCodes2(8) = 12   ' TypeCode.UInt64
    typeCodes2(9) = 13   ' TypeCode.Single
    typeCodes2(10) = 14  ' TypeCode.Double
    typeCodes2(11) = 18  ' TypeCode.String

    Dim CallArguments2 As New UACallArguments
    CallArguments2.endpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
    CallArguments2.nodeDescriptor.NodeId.expandedText = "nsu=http://test.org/UA/Data/ ;i=10755"
    CallArguments2.MethodNodeDescriptor.NodeId.expandedText = "nsu=http://test.org/UA/Data/ ;i=10774"
    ' Use SetXXXX methods instead of array-type property setters in Visual Basic 6.0
    CallArguments2.SetInputArguments inputs2
    CallArguments2.SetInputTypeCodes typeCodes2

    Dim arguments(1) As Variant
    Set arguments(0) = CallArguments1
    Set arguments(1) = CallArguments2

    ' Instantiate the client object
    Dim Client As New EasyUAClient

    ' Perform the operation
    Dim results As Variant
    results = Client.CallMultipleMethods(arguments)

    ' Display results
    Dim i: For i = LBound(results) To UBound(results)
        OutputText = OutputText & vbCrLf
        OutputText = OutputText & "results(" & i & "):" & vbCrLf
        Dim Result As ValueArrayResult: Set Result = results(i)

        If Result.Exception Is Nothing Then
            Dim outputs As Variant: outputs = Result.ValueArray
            Dim j: For j = LBound(outputs) To UBound(outputs)
                On Error Resume Next
                OutputText = OutputText & Space(4) & "outputs(" & j & "): " & outputs(j) & vbCrLf
                If Err <> 0 Then OutputText = OutputText & Space(4) & "*** Error" & vbCrLf ' occurrs with types not recognized by VB6
                On Error GoTo 0
            Next
        Else
            OutputText = OutputText & "*** Error: " & Result.Exception & vbCrLf
        End If
    Next
End Sub
Rem This example shows how to call multiple methods, and pass arguments to and from them.

Option Explicit

Dim inputs1(10)
inputs1(0) = False
inputs1(1) = 1
inputs1(2) = 2
inputs1(3) = 3
inputs1(4) = 4
inputs1(5) = 5
inputs1(6) = 6
inputs1(7) = 7
inputs1(8) = 8
inputs1(9) = 9
inputs1(10) = 10

Dim typeCodes1(10)
typeCodes1(0) = 3    ' TypeCode.Boolean
typeCodes1(1) = 5    ' TypeCode.SByte
typeCodes1(2) = 6    ' TypeCode.Byte
typeCodes1(3) = 7    ' TypeCode.Int16
typeCodes1(4) = 8    ' TypeCode.UInt16
typeCodes1(5) = 9    ' TypeCode.Int32
typeCodes1(6) = 10   ' TypeCode.UInt32
typeCodes1(7) = 11   ' TypeCode.Int64
typeCodes1(8) = 12   ' TypeCode.UInt64
typeCodes1(9) = 13   ' TypeCode.Single
typeCodes1(10) = 14  ' TypeCode.Double

Dim CallArguments1: Set CallArguments1 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UACallArguments")
CallArguments1.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
CallArguments1.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10755"
CallArguments1.MethodNodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10756"
CallArguments1.InputArguments = inputs1
CallArguments1.InputTypeCodes = typeCodes1

Dim inputs2(11)
inputs2(0) = False
inputs2(1) = 1
inputs2(2) = 2
inputs2(3) = 3
inputs2(4) = 4
inputs2(5) = 5
inputs2(6) = 6
inputs2(7) = 7
inputs2(8) = 8
inputs2(9) = 9
inputs2(10) = 10
inputs2(11) = "eleven"

Dim typeCodes2(11)
typeCodes2(0) = 3    ' TypeCode.Boolean
typeCodes2(1) = 5    ' TypeCode.SByte
typeCodes2(2) = 6    ' TypeCode.Byte
typeCodes2(3) = 7    ' TypeCode.Int16
typeCodes2(4) = 8    ' TypeCode.UInt16
typeCodes2(5) = 9    ' TypeCode.Int32
typeCodes2(6) = 10   ' TypeCode.UInt32
typeCodes2(7) = 11   ' TypeCode.Int64
typeCodes2(8) = 12   ' TypeCode.UInt64
typeCodes2(9) = 13   ' TypeCode.Single
typeCodes2(10) = 14  ' TypeCode.Double
typeCodes2(11) = 18  ' TypeCode.String

Dim CallArguments2: Set CallArguments2 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UACallArguments")
CallArguments2.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
CallArguments2.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10755"
CallArguments2.MethodNodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10774"
CallArguments2.InputArguments = inputs2
CallArguments2.InputTypeCodes = typeCodes2

Dim arguments(1)
Set arguments(0) = CallArguments1
Set arguments(1) = CallArguments2

' Instantiate the client object
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")

' Perform the operation
Dim results: results = Client.CallMultipleMethods(arguments)

' Display results
Dim i: For i = LBound(results) To UBound(results)
    WScript.Echo
    WScript.Echo "results(" & i & "):"
    Dim Result: Set Result = results(i)

    If Result.Exception Is Nothing Then
        Dim outputs: outputs = Result.ValueArray
        Dim j: For j = LBound(outputs) To UBound(outputs)
            On Error Resume Next
            WScript.Echo Space(4) & "outputs(" & j & "): " & outputs(j)
            If Err <> 0 Then WScript.Echo Space(4) & "*** Error"   ' occurrs with types not recognized by VBScript
            On Error Goto 0
        Next
    Else
        WScript.Echo "*** Error: " & Result.Exception
    End If
Next
Inheritance Hierarchy

System.Object
   OpcLabs.BaseLib.Object2
      OpcLabs.BaseLib.Info
         OpcLabs.BaseLib.OperationModel.OperationArguments
            OpcLabs.EasyOpc.UA.OperationModel.UANodeArguments
               OpcLabs.EasyOpc.UA.OperationModel.UACallArguments

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