dOPC Client Toolkit
Close
ua.client.TdOPCUAClient.MethodCall

If you want to call a method on a OPC UA Server.

function MethodCall(ObjectId: string; MethodId: string; inputArguments: uaBaseDataTypeArray = nil): uaBaseDataTypeArray;
__fastcall uaBaseDataTypeArray MethodCall(AnsiString ObjectId, AnsiString MethodId, uaBaseDataTypeArray inputArguments = null);

Use this method if you want to call a method on a OPC UA Server. 

The input arguments are specified by an array. 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. 

For further information about input and output arguments of a OPC UA method please look at the UACall example program. 

 

Parameter
Description
ObjectId
The NodeId shall be that of the Object or ObjectType on which the Method is invoked. If you leave it empty the method detects the automatically the ObjectId. (look also at MethodGetParent)
MethodId
The NodeId as string of the Method to invoke.
inputArguments
List of input argument values. An empty list indicates that there are no input arguments.
Result
List of output argument values. An empty list indicates that there are no output arguments.
program MethodsCall; uses sysutils, ua.client, ua.buildintypes; function VarArrayToUA(A: TArray<variant>): uaBaseDataTypeArray; var i : integer; begin Setlength(result,Length(A)); for i := 0 to Length(A)-1 do result[i] := uaVariant.createScalar(A[i],uaVariant.VariantToUADatatype(A[i])); end; var OPCClient : TdOPCUAClient; InVarParams : TArray<variant>; OutParams : uaBaseDataTypeArray; begin OPCClient := TdOPCUAClient.Create(nil); OPCClient.Url := 'opc.tcp://opcuaserver.com:48010'; OPCClient.Active := true; InVarParams := [10.01,20.02]; write(format('Multiply %s X %s = ',[InVarParams[0], InVarParams[1]])); OutParams:= OPCClient.MethodCall('','ns=2;s=Demo.Method.Multiply',VarArrayToUA(InVarParams)); writeln(format('%.f',[OutParams[0].ToType<uadouble>])); writeln('Press Enter to exit'); Readln; OutParams[0].Free; OPCClient.Free; end.
Kassl GmbH Copyright © 2021. All rights reserved.