// This example shows how to read the DataType attributes of 3 different nodes at
// once. Using the same method, it is also possible to read multiple attributes
// of the same node.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
class procedure ReadMultipleValues.DataType;
var
Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient;
ReadArguments1, ReadArguments2, ReadArguments3: _UAReadArguments;
Arguments, Results: OleVariant;
I: Cardinal;
Result: _ValueResult;
begin
// Instantiate the client object
Client := CoEasyUAClient.Create;
ReadArguments1 := CoUAReadArguments.Create;
ReadArguments1.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';
ReadArguments1.NodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10845';
ReadArguments1.AttributeId := UAAttributeId_DataType;
ReadArguments2 := CoUAReadArguments.Create;
ReadArguments2.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';
ReadArguments2.NodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10853';
ReadArguments2.AttributeId := UAAttributeId_DataType;
ReadArguments3 := CoUAReadArguments.Create;
ReadArguments3.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';
ReadArguments3.NodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10855';
ReadArguments3.AttributeId := UAAttributeId_DataType;
Arguments := VarArrayCreate([0, 2], varVariant);
Arguments[0] := ReadArguments1;
Arguments[1] := ReadArguments2;
Arguments[2] := ReadArguments3;
// Obtain values. By default, the Value attributes of the nodes will be read.
TVarData(Results).VType := varArray or varVariant;
TVarData(Results).VArray := PVarArray(Client.ReadMultipleValues(Arguments));
// Display results
for I := VarArrayLowBound(Results, 1) to VarArrayHighBound(Results, 1) do
begin
Result := IInterface(Results[I]) as _ValueResult;
WriteLn;
if Result.Succeeded then
begin
WriteLn('Value: ', Result.Value);
WriteLn('Value.ExpandedText: ', Result.Value.ExpandedText);
WriteLn('Value.NamespaceUriString: ', Result.Value.NamespaceUriString);
WriteLn('Value.NamespaceIndex: ', Result.Value.NamespaceIndex);
WriteLn('Value.NumericIdentifier: ', Result.Value.NumericIdentifier);
end
else
WriteLn('results(', I, ') *** Failure: ', Result.ErrorMessageBrief);
end;
VarClear(Results);
VarClear(Arguments);
// Example output:
//
//
//Value: SByte
//Value.ExpandedText: nsu=http://opcfoundation.org/UA/;i=2
//Value.NamespaceUriString: http://opcfoundation.org/UA/
//Value.NamespaceIndex: 0
//Value.NumericIdentifier: 2
//
//Value: Float
//Value.ExpandedText: nsu=http://opcfoundation.org/UA/;i=10
//Value.NamespaceUriString: http://opcfoundation.org/UA/
//Value.NamespaceIndex: 0
//Value.NumericIdentifier: 10
//
//Value: String
//Value.ExpandedText: nsu=http://opcfoundation.org/UA/;i=12
//Value.NamespaceUriString: http://opcfoundation.org/UA/
//Value.NamespaceIndex: 0
//Value.NumericIdentifier: 12
end;
// This example shows how to read the DataType attributes of 3 different nodes at
// once. Using the same method, it is also possible to read multiple attributes
// of the same node.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
const UAAttributeId_DataType = 14;
// Instantiate the client object
$Client = new COM("OpcLabs.EasyOpc.UA.EasyUAClient");
$ReadArguments1 = new COM("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments");
$ReadArguments1->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";
$ReadArguments1->NodeDescriptor->NodeId->ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10845";
$ReadArguments1->AttributeId = UAAttributeId_DataType;
$ReadArguments2 = new COM("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments");
$ReadArguments2->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";
$ReadArguments2->NodeDescriptor->NodeId->ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10853";
$ReadArguments2->AttributeId = UAAttributeId_DataType;
$ReadArguments3 = new COM("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments");
$ReadArguments3->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";
$ReadArguments3->NodeDescriptor->NodeId->ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10855";
$ReadArguments3->AttributeId = UAAttributeId_DataType;
$arguments[0] = $ReadArguments1;
$arguments[1] = $ReadArguments2;
$arguments[2] = $ReadArguments3;
// Obtain values. By default, the Value attributes of the nodes will be read.
$results = $Client->ReadMultipleValues($arguments);
// Display results
for ($i = 0; $i < count($results); $i++)
{
$ValueResult = $results[$i];
printf("\n");
if ($ValueResult->Succeeded)
{
printf("Value: %s\n", $ValueResult->Value);
printf("Value.ExpandedText: %s\n", $ValueResult->Value->ExpandedText);
printf("Value.NamespaceUriString: %s\n", $ValueResult->Value->NamespaceUriString);
printf("Value.NamespaceIndex: %s\n", $ValueResult->Value->NamespaceIndex);
printf("Value.NumericIdentifier: %s\n", $ValueResult->Value->NumericIdentifier);
}
else
printf("*** Failure: %s\n", $ValueResult->ErrorMessageBrief);
}
// Example output:
//
//
//Value: SByte
//Value.ExpandedText: nsu=http://opcfoundation.org/UA/;i=2
//Value.NamespaceUriString: http://opcfoundation.org/UA/
//Value.NamespaceIndex: 0
//Value.NumericIdentifier: 2
//
//Value: Float
//Value.ExpandedText: nsu=http://opcfoundation.org/UA/;i=10
//Value.NamespaceUriString: http://opcfoundation.org/UA/
//Value.NamespaceIndex: 0
//Value.NumericIdentifier: 10
//
//Value: String
//Value.ExpandedText: nsu=http://opcfoundation.org/UA/;i=12
//Value.NamespaceUriString: http://opcfoundation.org/UA/
//Value.NamespaceIndex: 0
//Value.NumericIdentifier: 12
Rem This example shows how to read the DataType attributes of 3 different nodes at once. Using the same method, it is also possible
Rem to read multiple attributes of the same node.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Option Explicit
Const UAAttributeId_DataType = 14
' Instantiate the client object
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")
Dim ReadArguments1: Set ReadArguments1 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments")
ReadArguments1.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
ReadArguments1.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10845"
ReadArguments1.AttributeId = UAAttributeId_DataType
Dim ReadArguments2: Set ReadArguments2 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments")
ReadArguments2.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
ReadArguments2.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10853"
ReadArguments2.AttributeId = UAAttributeId_DataType
Dim ReadArguments3: Set ReadArguments3 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments")
ReadArguments3.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
ReadArguments3.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10855"
ReadArguments3.AttributeId = UAAttributeId_DataType
Dim arguments(2)
Set arguments(0) = ReadArguments1
Set arguments(1) = ReadArguments2
Set arguments(2) = ReadArguments3
' Obtain values.
Dim results: results = Client.ReadMultipleValues(arguments)
' Display results
Dim i: For i = LBound(results) To UBound(results)
WScript.Echo
Dim ValueResult: Set ValueResult = results(i)
If ValueResult.Succeeded Then
WScript.Echo "Value: " & ValueResult.Value
On Error Resume Next
WScript.Echo "Value.ExpandedText: " & ValueResult.Value.ExpandedText
WScript.Echo "Value.NamespaceUriString: " & ValueResult.Value.NamespaceUriString
WScript.Echo "Value.NamespaceIndex: " & ValueResult.Value.NamespaceIndex
WScript.Echo "Value.NumericIdentifier: " & ValueResult.Value.NumericIdentifier
On Error Goto 0
Else
WScript.Echo "*** Failure: " & ValueResult.ErrorMessageBrief
End If
Next
' Example output:
'
'Value: SByte
'Value.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2
'Value.NamespaceUriString: http://opcfoundation.org/UA/
'Value.NamespaceIndex: 0
'Value.NumericIdentifier: 2
'
'Value: Float
'Value.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=10
'Value.NamespaceUriString: http://opcfoundation.org/UA/
'Value.NamespaceIndex: 0
'Value.NumericIdentifier: 10
'
'Value: String
'Value.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=12
'Value.NamespaceUriString: http://opcfoundation.org/UA/
'Value.NamespaceIndex: 0
'Value.NumericIdentifier: 12
REM This example shows how to read the Value attributes of 3 different nodes at once. Using the same method, it is also possible
REM to read multiple attributes of the same node.
REM
REM Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Public Sub ReadMultipleValues_DataType_Command_Click()
OutputText = ""
' Instantiate the client object
Dim Client As New EasyUAClient
Dim readArguments1 As New UAReadArguments
readArguments1.endpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
readArguments1.nodeDescriptor.NodeId.expandedText = "nsu=http://test.org/UA/Data/ ;i=10845"
readArguments1.AttributeId = UAAttributeId_DataType
Dim ReadArguments2 As New UAReadArguments
ReadArguments2.endpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
ReadArguments2.nodeDescriptor.NodeId.expandedText = "nsu=http://test.org/UA/Data/ ;i=10853"
ReadArguments2.AttributeId = UAAttributeId_DataType
Dim ReadArguments3 As New UAReadArguments
ReadArguments3.endpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
ReadArguments3.nodeDescriptor.NodeId.expandedText = "nsu=http://test.org/UA/Data/ ;i=10855"
ReadArguments3.AttributeId = UAAttributeId_DataType
Dim arguments(2) As Variant
Set arguments(0) = readArguments1
Set arguments(1) = ReadArguments2
Set arguments(2) = ReadArguments3
' Obtain values.
Dim results() As Variant
results = Client.ReadMultipleValues(arguments)
' Display results
Dim i: For i = LBound(results) To UBound(results)
OutputText = OutputText & vbCrLf
Dim Result As valueResult: Set Result = results(i)
If Result.Succeeded Then
OutputText = OutputText & "Value: " & Result.value & vbCrLf
On Error Resume Next
OutputText = OutputText & "Value.ExpandedText: " & Result.value.expandedText & vbCrLf
OutputText = OutputText & "Value.NamespaceUriString: " & Result.value.NamespaceUriString & vbCrLf
OutputText = OutputText & "Value.NamespaceIndex: " & Result.value.NamespaceIndex & vbCrLf
OutputText = OutputText & "Value.NumericIdentifier: " & Result.value.NumericIdentifier & vbCrLf
On Error GoTo 0
Else
OutputText = OutputText & "*** Failure: " & Result.ErrorMessageBrief & vbCrLf
End If
Next
' Example output:
'
'Value: SByte
'Value.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2
'Value.NamespaceUriString: http://opcfoundation.org/UA/
'Value.NamespaceIndex: 0
'Value.NumericIdentifier: 2
'
'Value: Float
'Value.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=10
'Value.NamespaceUriString: http://opcfoundation.org/UA/
'Value.NamespaceIndex: 0
'Value.NumericIdentifier: 10
'
'Value: String
'Value.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=12
'Value.NamespaceUriString: http://opcfoundation.org/UA/
'Value.NamespaceIndex: 0
'Value.NumericIdentifier: 12
End Sub