dOPC Client Toolkit
Close
Example
program PDynReadWrite; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, ua.client, ua.complextypes; procedure ShowFields(ExObj: TuaStructureObject); var Field: TuaField; L : string; begin // The following code shows how easy it is to access the fields of a structure. // It is also possible to use Exobj.ToString instead (L := Exobj.ToString;) writeln(Exobj.TypeData.DisplayName.Text+' ('+Exobj.TypeData.Id+', '+Exobj.TypeData.NodeId.ToString+')'); // L := Exobj.ToString; // AddLine(L); for Field in Exobj.Fields do begin L := ' '+Field.FieldData.Name+': ' +Field.TypeData.DatatypeName+ '; //'+Field.TypeData.NodeId.ToString; if Field.ValueData <> nil then // in case we have read values as well L := L+' = '+ Field.ValueData.ToString; // show the value Writeln(L); end; if Exobj.Fields.Count <= 0 then writeln('Type is a structure, but the DataTypeDefinition attribute does not exist on the server side for this type'); end; var dOPCUAClient : TdOPCUaClient; ExObj : TuaStructureObject; begin dOPCUAClient := TdOPCUaClient.Create(nil); // create OPC UA client ExObj := TuaStructureObject.Create; // create structure object try dOPCUAClient.Url := 'opc.tcp://uademo.prosysopc.com:53530/OPCUA/SimulationServer'; dOPCUAClient.Active := true; // connect to server ExObj.UAClient := dOPCUAClient; // set OPC UA client property ExObj.Read('ns=0;i=2256',true); // now read the structure with values if ExObj.TypeData.IsStructure then // only if the nodeid is really a structure ShowFields(ExObj) else writeln('Node is not a structure it is a: '+ ExObj.TypeData.DatatypeName); readln; finally ExObj.Free; dOPCUAClient.Free; end; end.
dOPC version 5.33. Copyright © 2025 by Kassl GmbH.