dOPC Client Toolkit

Writes an array of nodes and with new values.

function WriteNodeAttributes(NodeIds: TArray<string>; Attributes: TArray<integer>; Values: TArray<uaDataValue>): uaStatuscodeArray;
__fastcall uaStatuscodeArray WriteNodeAttributes(TArray<string> NodeIds, TArray<integer> Attributes, TArray<uaDataValue> Values);

This method can be used to write an array of nodes. It returns an array of uaStatuscodes.

Array of nodes you want to write.
Defines which attributes you want to write. For further information look also at: TuaAttributes
Defines the value you want to write, see also example below.
returns a uaStatuscode (look also at: uaStatusCodeToString)
program Project11; {$APPTYPE CONSOLE} {$R *.res} uses ua.client, ua.datatypes, ua.buildintypes, ua.statuscodes; var OPCClient : TdOPCUAClient; Nodes : TArray<String>; WriteValues : TArray<uaDatavalue>; Rets : TArray<uaStatuscode>; Attributes : TArray<uaInt32>; V : uaDataValue; Ret : uaStatuscode; i : integer; begin OPCClient := TdOPCUAClient.Create(nil); OPCClient.Url := 'opc.tcp://'; Setlength(Nodes,2); Setlength(WriteValues,2); Setlength(Attributes,2); Nodes[0] := 'ns=2;s=Demo.Static.Scalar.Int16'; Attributes[0] := TuaAttributes.Value; WriteValues[0] := uaDatavalue.Create(uaVariant.Create(uaInt16(16))); Nodes[1] := 'ns=2;s=Demo.Static.Scalar.Int32'; Attributes[1] := TuaAttributes.Value; WriteValues[1] := uaDatavalue.Create(uaVariant.Create(uaInt32(32))); OPCClient.Active := true; Rets := OPCClient.WriteNodeAttributes(Nodes,Attributes,WriteValues); for i := 0 to Length(Rets)-1 do begin if not Ret.IsGood then writeln('Node: '+ Nodes[i]+': Error write node:', Statuscodes.ToString(Ret)) else writeln('Node: '+ Nodes[i]+': successfully written :-)'); end; for V in WriteValues do V.Free; Writeln('Press Enter to exit'); Readln; OPCClient.Free; end.
Kassl GmbH Copyright © 2022. All rights reserved.