QuickOPC User's Guide and Reference
GetMultiplePropertyValues Method (_EasyDAClient)
Example 



OpcLabs.EasyOpcClassic Assembly > OpcLabs.EasyOpc.DataAccess.ComTypes Namespace > _EasyDAClient Interface : GetMultiplePropertyValues Method
Array of arguments, one element per each OPC property involved in the operation.
Gets values of multiple OPC properties, specifying an array of property arguments objects.
Syntax
'Declaration
 
<ElementsNotNullAttribute()>
<NotNullAttribute()>
Function GetMultiplePropertyValues( _
   ByVal argumentsArray As Object _
) As Object()
'Usage
 
Dim instance As _EasyDAClient
Dim argumentsArray As Object
Dim value() As Object
 
value = instance.GetMultiplePropertyValues(argumentsArray)
[ElementsNotNull()]
[NotNull()]
object[] GetMultiplePropertyValues( 
   object argumentsArray
)
[ElementsNotNull()]
[NotNull()]
array<Object^>^ GetMultiplePropertyValues( 
   Object^ argumentsArray
) 

Parameters

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

Return Value

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

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

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

Remarks

 

This is a multiple-operation method. In a properly written program, it does not throw any exceptions. You should therefore not put try/catch statements or similar constructs around calls to this method. The only exceptions thrown by this method are for usage errors, i.e. when your code violates the usage contract of the method, such as passing in invalid arguments or calling the method when the state of the object does not allow it. Any operation-related errors (i.e. errors that depend on external conditions that your code cannot reliably check) are indicated in the result objects returned by the method. For more information, see Multiple-operation Methods and Do not catch any exceptions with asynchronous or multiple-operation methods.
Example

COM

COM

// This example shows how to get value of multiple OPC properties.
//
// Note that some properties may not have a useful value initially (e.g. until the item is activated in a group), which also the
// case with Timestamp property as implemented by the demo server. This behavior is server-dependent, and normal. You can run
// IEasyDAClient.ReadMultipleItemValues.Main.vbs shortly before this example, in order to obtain better property values. Your
// code may also subscribe to the items in order to assure that they remain active.

class procedure GetMultiplePropertyValues.Main;
var
  Arguments: OleVariant;
  Client: OpcLabs_EasyOpcClassic_TLB._EasyDAClient;
  I: Cardinal;
  PropertyArguments1: _DAPropertyArguments;
  PropertyArguments2: _DAPropertyArguments;
  PropertyArguments3: _DAPropertyArguments;
  PropertyArguments4: _DAPropertyArguments;
  ValueResult: _ValueResult;
  Results: OleVariant;
begin

  // Get the values of Timestamp and AccessRights properties of two items.

  PropertyArguments1 := CoDAPropertyArguments.Create;
  PropertyArguments1.ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2';
  PropertyArguments1.NodeDescriptor.ItemID := 'Simulation.Random';
  PropertyArguments1.PropertyDescriptor.PropertyId.NumericalValue := DAPropertyIds_Timestamp;

  PropertyArguments2 := CoDAPropertyArguments.Create;
  PropertyArguments2.ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2';
  PropertyArguments2.NodeDescriptor.ItemID := 'Simulation.Random';
  PropertyArguments2.PropertyDescriptor.PropertyId.NumericalValue := DAPropertyIds_AccessRights;

  PropertyArguments3 := CoDAPropertyArguments.Create;
  PropertyArguments3.ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2';
  PropertyArguments3.NodeDescriptor.ItemID := 'Trends.Ramp (1 min)';
  PropertyArguments3.PropertyDescriptor.PropertyId.NumericalValue := DAPropertyIds_Timestamp;

  PropertyArguments4 := CoDAPropertyArguments.Create;
  PropertyArguments4.ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2';
  PropertyArguments4.NodeDescriptor.ItemID := 'Trends.Ramp (1 min)';
  PropertyArguments4.PropertyDescriptor.PropertyId.NumericalValue := DAPropertyIds_AccessRights;

  Arguments := VarArrayCreate([0, 3], varVariant);
  Arguments[0] := PropertyArguments1;
  Arguments[1] := PropertyArguments2;
  Arguments[2] := PropertyArguments3;
  Arguments[3] := PropertyArguments4;

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

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

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

      // Check if there has been an error getting the property value
      if ValueResult.Exception <> nil then
      begin
        WriteLn(Format('s *** Failures', [Arguments[I].NodeDescriptor.NodeId, ValueResult.Exception.Message]));
        Continue;
      end;

      WriteLn('results(', i, ').Value: ', ValueResult.Value);
  end;
  VarClear(Results);
  VarClear(Arguments);
end;
// This example shows how to get value of multiple OPC properties, and handle errors.
//
// Note that some properties may not have a useful value initially (e.g. until the item is activated in a group), which also the
// case with Timestamp property as implemented by the demo server. This behavior is server-dependent, and normal. You can run 
// IEasyDAClient.ReadMultipleItemValues.Main.vbs shortly before this example, in order to obtain better property values. Your 
// code may also subscribe to the items in order to assure that they remain active.

const Timestamp = 4;
const AccessRights = 5;

// Get the values of Timestamp and AccessRights properties of two items.

$PropertyArguments1 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAPropertyArguments");
$PropertyArguments1->ServerDescriptor->ServerClass = "OPCLabs.KitServer.2";
$PropertyArguments1->NodeDescriptor->ItemID = "Simulation.Random";
$PropertyArguments1->PropertyDescriptor->PropertyID->NumericalValue = Timestamp;

$PropertyArguments2 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAPropertyArguments");
$PropertyArguments2->ServerDescriptor->ServerClass = "OPCLabs.KitServer.2";
$PropertyArguments2->NodeDescriptor->ItemID = "Simulation.Random";
$PropertyArguments2->PropertyDescriptor->PropertyID->NumericalValue = AccessRights;

$PropertyArguments3 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAPropertyArguments");
$PropertyArguments3->ServerDescriptor->ServerClass = "OPCLabs.KitServer.2";
$PropertyArguments3->NodeDescriptor->ItemID = "Trends.Ramp (1 min)";
$PropertyArguments3->PropertyDescriptor->PropertyID->NumericalValue = Timestamp;

$PropertyArguments4 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAPropertyArguments");
$PropertyArguments4->ServerDescriptor->ServerClass = "OPCLabs.KitServer.2";
$PropertyArguments4->NodeDescriptor->ItemID = "Trends.Ramp (1 min)";
$PropertyArguments4->PropertyDescriptor->PropertyID->NumericalValue = AccessRights;

$arguments[0] = $PropertyArguments1;
$arguments[1] = $PropertyArguments2;
$arguments[2] = $PropertyArguments3;
$arguments[3] = $PropertyArguments4;

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

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

for ($i = 0; $i < count($results); $i++)
{
    $attributeDataResult = $results[$i];
    if ($results[$i]->Succeeded)
        printf("results[d].Values\n", $i, $results[$i]->Value);
    else
        printf("results[d]: *** Failures\n", $i, $results[$i]->ErrorMessageBrief);
}
Rem This example shows how to get value of multiple OPC properties.
Rem
Rem Note that some properties may not have a useful value initially (e.g. until the item is activated in a group), which also the
Rem case with Timestamp property as implemented by the demo server. This behavior is server-dependent, and normal. You can run
Rem IEasyDAClient.ReadMultipleItemValues.Main.vbs shortly before this example, in order to obtain better property values. Your
Rem code may also subscribe to the items in order to assure that they remain active.

Private Sub GetMultiplePropertyValues_Main_Command_Click()
    OutputText = ""
    
    ' Get the values of Timestamp and AccessRights properties of two items.

    Dim propertyArguments1 As New DAPropertyArguments
    propertyArguments1.serverDescriptor.ServerClass = "OPCLabs.KitServer.2"
    propertyArguments1.nodeDescriptor.itemId = "Simulation.Random"
    propertyArguments1.PropertyDescriptor.propertyId.NumericalValue = DAPropertyIds_Timestamp
    
    Dim propertyArguments2 As New DAPropertyArguments
    propertyArguments2.serverDescriptor.ServerClass = "OPCLabs.KitServer.2"
    propertyArguments2.nodeDescriptor.itemId = "Simulation.Random"
    propertyArguments2.PropertyDescriptor.propertyId.NumericalValue = DAPropertyIds_AccessRights
    
    Dim propertyArguments3 As New DAPropertyArguments
    propertyArguments3.serverDescriptor.ServerClass = "OPCLabs.KitServer.2"
    propertyArguments3.nodeDescriptor.itemId = "Trends.Ramp (1 min)"
    propertyArguments3.PropertyDescriptor.propertyId.NumericalValue = DAPropertyIds_Timestamp
    
    Dim propertyArguments4 As New DAPropertyArguments
    propertyArguments4.serverDescriptor.ServerClass = "OPCLabs.KitServer.2"
    propertyArguments4.nodeDescriptor.itemId = "Trends.Ramp (1 min)"
    propertyArguments4.PropertyDescriptor.propertyId.NumericalValue = DAPropertyIds_AccessRights
    
    Dim arguments(3) As Variant
    Set arguments(0) = propertyArguments1
    Set arguments(1) = propertyArguments2
    Set arguments(2) = propertyArguments3
    Set arguments(3) = propertyArguments4

    ' Instantiate the client object
    Dim client As New EasyDAClient

    ' Obtain values. By default, the Value attributes of the nodes will be read.
    Dim results() As Variant
    results = client.GetMultiplePropertyValues(arguments)

    ' Display results
    Dim i: For i = LBound(results) To UBound(results)
        Dim valueResult As valueResult: Set valueResult = results(i)
        ' Check if there has been an error getting the property value
        If Not valueResult.Exception Is Nothing Then
            OutputText = OutputText & arguments(i).nodeDescriptor.NodeId & " *** Failure: " & valueResult.Exception.Message & vbCrLf
        Else
            OutputText = OutputText & "results(" & i & ").Value: " & valueResult.value & vbCrLf
        End If
    Next
End Sub
Rem This example shows how to get value of multiple OPC properties, and handle errors.
Rem
Rem Note that some properties may not have a useful value initially (e.g. until the item is activated in a group), which also the
Rem case with Timestamp property as implemented by the demo server. This behavior is server-dependent, and normal. You can run 
Rem IEasyDAClient.ReadMultipleItemValues.Main.vbs shortly before this example, in order to obtain better property values. Your 
Rem code may also subscribe to the items in order to assure that they remain active.

Option Explicit

Const Timestamp = 4
Const AccessRights = 5

' Get the values of Timestamp and AccessRights properties of two items.

Dim PropertyArguments1: Set PropertyArguments1 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAPropertyArguments")
PropertyArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
PropertyArguments1.NodeDescriptor.ItemID = "Simulation.Random"
PropertyArguments1.PropertyDescriptor.PropertyID.NumericalValue = Timestamp

Dim PropertyArguments2: Set PropertyArguments2 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAPropertyArguments")
PropertyArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
PropertyArguments2.NodeDescriptor.ItemID = "Simulation.Random"
PropertyArguments2.PropertyDescriptor.PropertyID.NumericalValue = AccessRights

Dim PropertyArguments3: Set PropertyArguments3 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAPropertyArguments")
PropertyArguments3.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
PropertyArguments3.NodeDescriptor.ItemID = "Trends.Ramp (1 min)"
PropertyArguments3.PropertyDescriptor.PropertyID.NumericalValue = Timestamp

Dim PropertyArguments4: Set PropertyArguments4 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAPropertyArguments")
PropertyArguments4.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
PropertyArguments4.NodeDescriptor.ItemID = "Trends.Ramp (1 min)"
PropertyArguments4.PropertyDescriptor.PropertyID.NumericalValue = AccessRights

Dim arguments(3)
Set arguments(0) = PropertyArguments1
Set arguments(1) = PropertyArguments2
Set arguments(2) = PropertyArguments3
Set arguments(3) = PropertyArguments4

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

Dim i: For i = LBound(results) To UBound(results)
    If results(i).Exception Is Nothing Then 
        WScript.Echo "results(" & i & ").Value: " & results(i).Value
    Else
        WScript.Echo "results(" & i & ").Exception.Message: " & results(i).Exception.Message
    End If
Next
Rem This example measures the time needed to get values of all OPC properties of a single OPC item all at once.
Rem This example shows how to get value of multiple OPC properties.

Option Explicit

Dim ServerDescriptor: Set ServerDescriptor = CreateObject("OpcLabs.EasyOpc.ServerDescriptor")
ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"

Dim NodeDescriptor: Set NodeDescriptor = CreateObject("OpcLabs.EasyOpc.DataAccess.DANodeDescriptor")
NodeDescriptor.ItemID = "Simulation.ReadValue_I4"

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

Dim PropertyElementCollection
On Error Resume Next
Set PropertyElementCollection = Client.BrowseProperties(ServerDescriptor, NodeDescriptor)
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0

Dim count: count = PropertyElementCollection.Count

Dim arguments(): Redim arguments(count - 1)
Dim i: i = 0
Dim PropertyElement: For Each PropertyElement In PropertyElementCollection
    Dim PropertyArguments: Set PropertyArguments = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAPropertyArguments")
    PropertyArguments.ServerDescriptor = ServerDescriptor
    PropertyArguments.NodeDescriptor = NodeDescriptor
    PropertyArguments.PropertyDescriptor.PropertyID = PropertyElement.PropertyId

    Set arguments(i) = PropertyArguments
    i = i + 1
Next

'EasyDAClient.ReadItemValue "", "OPCLabs.KitServer.2", "Simulation.ReadValue_I4"
Dim startTime: startTime = Timer
Dim results: results = Client.GetMultiplePropertyValues(arguments)
WScript.Echo "Time taken (milliseconds): " & (Timer - startTime)*1000

'For i = LBound(results) To UBound(results)
'    If results(i).Exception Is Nothing Then 
'        WScript.Echo "results(" & i & ").Value: " & results(i).Value
'    Else
'        WScript.Echo "results(" & i & ").Exception.Message: " & results(i).Exception.Message
'    End If
''Next
Requirements

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

See Also