Introduction to Complex Data Types
HumanOS Runtime allows to define your own data structures as "complex data types". Typically, they contain several fields of primitive data types and arrays.
Declaration of EntityTypes
A complex data type can be declared as a EntityTypeNode
in the HumanOS Runtime. The entity type can be seen as a schema to build generic entity objects later on.
Check the reference manual for EntityTypes.
Following example shows an entity type with fields
Name
declaring a string of 32 charactersValidFlag
as booleanSettings
array of 5 unsigned integersTimer
as signed integer
Each complex data type contains a key field called
Id
of typeSystem.Guid
. This key is used internally and should not be changed.
Declaration as JSON
{
"Id": "dafc41ad-e571-40c8-8fb0-53540ccf0224",
"Name": "MyComplexDataType",
"Fields": [
{
"Name": "Id",
"DataType": "System.Guid",
"IsKey": true
},
{
"Name": "Name",
"DataType": "System.String",
"ArraySize": 1,
"Length": 32
},
{
"Name": "ValidFlag",
"DataType": "System.Boolean",
"ArraySize": 1,
"Length": 255
},
{
"Name": "Settings",
"DataType": "System.UInt32[]",
"ArraySize": 5,
"Length": 255
},
{
"Name": "Timer",
"DataType": "System.Int32",
"ArraySize": 1,
"Length": 255
}
],
"Properties": []
}
Declaration in Designer
Reading Complex DataTypes from UHAL Plugins
Complex data type can be directly read from memory of a CNC or PLC control. Therefore, the PLC/CNC memory is read as byte-array. A special conversion is done to convert the byte stream into a generic entity or into an array of generic entities.
The match is done byte wise. Use the exact data types, fixed string length and fixed array sizes, to prevent mismatching of data.
The order of the fields must exactly match the order in the PLC.
Check the manual of the specific control in order to choose the right data types.
Some controllers has an inverted byte order, like Siemens S7. If the byte order is inverse, set the property
InvertByteOrder
totrue
.{
"Name": "InvertByteOrder",
"DataType": "System.Boolean",
"Value": "true"
}This settings inverts bytes for data types like 16bit and 32bit integers.
Definition in Designer
Data nodes hosting complex data types must be of type HumanOS.Kernel.DataModel.Entity.TGenericEntity, HumanOS.Kernel.Base
or HumanOS.Kernel.DataModel.Entity.TGenericEntity[], HumanOS.Kernel.Base
.
A link between the entity type and data node must be created, so that generic entities can be created out of a byte array.
More information about "Data Nodes with complex data types".