dOPC Client Toolkit
Close
Example
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://opcuaserver.com:48010'; 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 © 2024. All rights reserved.