program ReadDataType;
uses
Sysutils, Generics.Collections,
ua.client, ua.datatypes, ua.complextypes;
procedure ShowDatatypeInDict(OPCClient: TdOPCUAClient);
var
DDItems : TArray<TuaDictDatatypeItem>;
DItem : TuaDictDatatypeItem;
BuildInType : TuaDatatypeItem;
begin
DDItems := uaDatatypeDictionary.ToArray; // reads all datatype from dictionary into a arrayfor DItem in DDItems do// for all data types in dictionarybegin
BuildInType := uaDatatypeDictionary.GetBuiltInDatatype(DItem.value.NodeId);
Writeln(DItem.Value.DatatypeName+' ('+DItem.Key+'); ' +BuildInType.DatatypeName+' ('+BuildInType.NodeId.ToString+')');
end;
end;
var
OPCClient: TdOPCUAClient;
DType : TuaDatatypeItem;
Field : uaStructureField;
i : integer;
begin
OPCClient := TdOPCUAClient.Create(nil);
OPCClient.Url := ' opc.tcp://opcuademo.sterfive.com:26543';
try
OPCClient.Active := true;
// Read all the data type information from the variable ServerStatus (ns=0;i=2256).
DType := uaDatatypeDictionary.ReadAllNodeDatatypes(OPCClient,'ns=0;i=2256');
Writeln('Name: ', Dtype.DatatypeName);
Writeln('Node id: ', Dtype.NodeId.ToString);
Writeln('Id: ', Dtype.Id);
Writeln('Is base type: ', Dtype.IsBuildInType);
Writeln('Is structure: ', Dtype.IsStructure);
Writeln('Has fields: ',DType.FieldCount > 0);
Writeln; // Now write all the field information that exists.for i := 0 to DType.FieldCount-1 dobegin
Field := DType.Fields[i];
Writeln(Field.Name);
//Writeln(Field.ToString); // shows all information about the fieldend;
Writeln; // Now write all existing datatypes from the directory
ShowDatatypeInDict(OPCClient);
except
on E: Exception do writeln(E.Message);
end;
Writeln('Press Enter to exit');
Readln;
OPCClient.Free;
end.