OTX-Runtime for DotNet
|
|
To interact with OTX sequences the following parameters and variables can be handled at the API:
From the OTX point of view each parameter and variable can have an arbitrary OTX data type. But at the level of the API not all OTX data types are supported, because most of them are only valid inside the OTX runtime context. The table below describes all data types supported at the API.
Note: This does not mean, that no other data type can be used, but it will be not exchangeable with all systems! The DotNet API supports more data types like the APP in C++. As example a List with 10 levels is possible at DotNet API but not at C++ API. At C++ API it is limited to 3 levels.
Data type | Is complex | Description | Example in OTL Literal notation | Corresponding C# data type for direct usage |
---|---|---|---|---|
String | Simple string | "MyText" or "" | System.String | |
Boolean | Boolean value TRUE or FALSE | true or false | System.Boolean | |
Integer | 64 bit integer number | 123 | System.Int64 | |
Float | Floating point number with double precision | 1.23 | System.Double | |
ByteField | x | Array of bytes, see also ByteField at API | &123456789ABCDEF0 or &NULL | OpenTestSystem.Otx.Runtime.Api.DataTypes.ByteField |
List | x | Array of a data type listed here in any combination. Only 3 levels are supported! | { "Value1", "Value2", "Value3" } or {} | System.Collections.Generic.List<T> |
Map | x | Dictionary of key, value pairs. The key must be of data type String or Integer. The value an be a data type listed here in any combination. Only 3 levels are supported! | { "Key1":"Value1","Key2":"Value2","Key3":"Value3" } or {} | System.Collections.Generic.Dictionary<TKey,TValue> |
Enumeration | Named Integer, see also Enumeration at API | Element1 | OpenTestSystem.Otx.Runtime.Api.DataTypes.EnumerationElement | |
Structure | x | Structure with arbitrary elements of data types listed here in any combination. Only 3 levels are supported! See also Structure at API | {BooleanElement1 = true, IntegerElement2 = 3, StringElement3 = "Text"} **Please see note below!** | OpenTestSystem.Otx.Runtime.Api.DataTypes.Structure |
ResourceLocation | x | ResourceLocation represents a string value which addresses a location of a resource associated with an ID. See also ResourceLocation at API. | @ResourceLocation:"MyResource"/"file:///C:/path/to/resource.res" | OpenTestSystem.Otx.Runtime.Api.DataTypes.ResourceLocation |
Note: Currently OTX (ISO 13209-4:2022) does not support literals for Structures. Structure literals will be supported in edition 2 of ISO 13209-4. Structure literals are only supported at the API for the conversion of structure values, see Literal Conversion.
Note: The
Literal
from a String must start and end with double quotes, e.g. "Hello World".
In certain situations values with complex OTX data types, e.g. List, Map, Enumeration, Structure or ResourceLocation, must be handled by the application. Data types from the application must be mapped to data types available at the API (OTX data types), see picture.
The OTX-Runtime API supports two ways for OTX Data Type Mapping for all supported data types.
Note: The conversion of OTX data types into the data types of the application must handled within the application, since only the application knows their data types.
For the direct usage all supported data types have a corresponding data type of the certain target system (C++, DotNet, Java), see table above. Most simple data types are delivered as native data types of the target system. They do not need a special handling. Dependent from the target system some complex OTX data types needs a special handling. This data types are listed in the DataTypes section of the OTX-Runtime API. This data type support methods or properties to get detailed inner information of that data type, so that values can be read or written.
The Literal Conversion is a convenient and fully generic way. The following two conversion methods are provided:
Value2String(Object value)
This method converts a value from an element of the API like a ProcedureParameter to a string. The string is formated in OTLLiteral
notation and is therefore independent from the underlying software platform.
String2Value(String literal, String dataType)
This method converts a string in OTLLiteral
notation (e.g. given from Value2String(Object value)) into a value of the given data type. The string for the data type is also formated in OTL notation and is therefore independent from the underlying software platform. The data type string can be get via the related method or property of the related OTX element, e.g. procedure parameter data type.
Note: To convert a value of a supported data type from a string to a value the application must create a literal in OTL notation. This can become complex, especially with nested complex data types. In this case the usage of Direct usage (Data Type Reflexion) is recommended.
Note: Do not use a certain
ToString
method of the application! To convert a value of a supported data type to and from a string, these methods are recommended to use!
The example shows the pseudo code of the principle handling of data types of the OTX-Runtime API.