OTX Reference  
OpenTestSystem.Otx.Core.DataTypes Namespace Reference

Data types determine the value range of declarations. More...

Classes

class  Boolean
 Boolean value, which can be either true or false. More...
 
class  ByteField
 Sequence of Bytes with arbitrary length. More...
 
class  ComplexType
 Abstract data type of all complex data types. More...
 
class  CountableType
 Abstract data type of all countable data types. More...
 
class  DataType
 Abstract data type of all data types. More...
 
class  Float
 Floating point numbers. More...
 
class  Integer
 Integer numbers. More...
 
class  List
 List of items of the same data type. More...
 
class  Map
 Dictionary of key/value pairs. More...
 
class  SimpleType
 Abstract data type of all simple data types. More...
 
class  String
 Arbitrary number of characters. More...
 

Enumerations

enum class  EncodingSize { Item8BIT , Item16BIT , Item32BIT , Item64BIT }
 Number of bits for the encoding of an Integer More...
 
enum class  EncodingType { UNSIGNED , SIGNEDBINARY , TWOSCOMPLEMENT }
 Encoding type of Integer. More...
 
enum class  Endianness { LITTLEENDIAN , MIXEDENDIAN , BIGENDIAN }
 Byte order for writing encoded Integer. More...
 

Detailed Description

Data types determine the value range of declarations.

Data types determine the value range of Declarations or the return types of Terms. Data types usually define additional Terms or Actions to process the values. Here is an Overview of all data types.

OTX defines a fixed set of data types. A distinction is made between the following groups of data types.

Simple data types are all basic data types such as Boolean, Integer, Float and String. Countable data types can be used as keys (e.g. key of a Map). Complex data types are all other data types. such as ByteField, ComChannel and DiagService. List and Map are generic data types with any nesting depth. A List is a table with elements of the same data type that can be accessed via an index, e.g. List<List<Integer>>. A Map is a list of key-value pairs that are accessed via a key, e.g. Map<String, List<Integer>>. The user can define user-defined data types himself using a Signature. An enumeration is a list of integer values ‚Äč‚Äčthat are assigned to a name, e.g. Enumeration Color(Red = 0, Green = 1, Blue = 2). The structure consists of a list of elements with any number of different data types in any nesting depth, e.g. Structure Person(String FirstName, String LastName, Integer Age, Color EyeColor). Each OTX extension can define new data types.

Each data type can also define the following terms depending on its use:

  • Term (e.g. BooleanTerm)
    Term for accessing a value
  • Literal (e.g. BooleanLiteral))
    Term for the direct use of a fixed value, e.g. True
  • Value (e.g. BooleanValue))
    Term for reading (dereferencing) a value from a declaration

In addition, data types define terms for creation (e.g. ListCreate), the explicit conversion to other data types (e.g. ToBoolean), access to certain values of the data type (e.g. GetExceptionText) as well as terms for data type specific operations (e.g. BitwiseNot).

Initial Values
All data types have an initial value: The following elements can optionally overwrite this value:
  • Global constants, variables, context variables, status variables
  • Local constants and variables
  • Parameter
If no explicit initial value is specified, the element is initialized with the initial value of the respective data type.
Literals
Literal (Latin "littera" means letter) denotes a character string that is used to directly represent the values of data types. In order for literals to be identified, they must match certain syntactic rules, e.g. be enclosed in quotation marks for a character string. Examples:
Data TypeSample (OTL)
BooleanTrue or False
Integer1200 or +1200 or -12
Float12.345 or NaN or -Infinite or -0
String"Hello World"
ByteField&01020304EFFF or &FF
List{ 1, 2, 3 } or { "Text1", "Text2", "Text3" }
Map{ { "Key1":"Value1" }, { "Key2":"Value2" }, { "Key3":"Value3" } }
Type Conversion
In OTX, the data type Integer is automatically converted to Float if necessary. This means that wherever the data type Float is required, Integers can also be used. This is the only implicit type conversion. Except for this exception, data types must always be converted explicitly (Explicit Type Conversion). Every conversion from one data type to another data type (e.g. from Integer to String) must be done using a suitable conversion term, e.g. ToBoolean, ToInteger, ToFloat, ToString, ToByteField.
Reference Arithmetic
Reference arithmetic is used in OTX for complex data types (not for simple data types!). This means that the reference and not a copy is transferred for each value assignment of complex data types. Example:
procedure Procedure1()
{
List<Integer> myList1 = {1};
List<Integer> myList2 = {1, 2, 3};
// After this operation myList1 is identical with myList2
myList1 = myList2;
// Only myList1 will be cleared and will not contain any element after this operation
ListClear(myList1);
// Because myList2 is identical to myList1, myList2 does not contain any element
if (ListGetLength(myList2) == 0)
{
HMI.ConfirmDialog("OTX supports reference arithmetic!");
}
}
For complex data types, additional terms are therefore usually defined in order to create copies, e.g. ListCopy.
Data Type Handling for external Systems
From the OTX point of view each parameter and variable can have an arbitrary OTX data type. But from the view of an external system not all OTX data types are supported, because most of them are only valid inside the OTX runtime context, see Data Type Handling of external systems.

Enumeration Type Documentation

◆ EncodingSize

Number of bits for the encoding of an Integer

Specifies how many bits are used for the encoding.

Order for Comparisons
Item8BIT < Item16BIT < Item32BIT < Item64BIT
Default value
Item64BIT
Conversion
When applying ToString, the resulting string is the name of the enumeration value. Furthermore, applying ToInteger returns the index of the value in the enumeration (smallest index is 0). The behaviour is undefined for other conversion terms.
See also
Terms.EncodeInteger
Enumerator
Item8BIT 

8-BIT will be used for the encoding.

Item16BIT 

16-BIT will be used for the encoding.

Item32BIT 

32-BIT will be used for the encoding.

Item64BIT 

64-BIT will be used for the encoding (Default).

◆ EncodingType

Encoding type of Integer.

Specifies how the Integer value shall be encoded (examples using BIGENDIAN byte order).

Order for Comparisons
UNSIGNED < SIGNEDBINARY < TWOSCOMPLEMENT
Default value
TWOSCOMPLEMENT
Conversion
When applying ToString, the resulting string is the name of the enumeration value. Furthermore, applying ToInteger returns the index of the value in the enumeration (smallest index is 0). The behaviour is undefined for other conversion terms.
See also
Terms.EncodeInteger
Enumerator
UNSIGNED 

Encoding type unsigned.

The Integer will be written to the ByteField, using all available bits (including the sign-bit). For negative integers, its absolute value will be encoded. With this encoding, an Integer value of e.g. 129 is encoded as 10000001 (Bin), and an Integer value of e.g. -129 will also be encoded as 10000001 (Bin).

SIGNEDBINARY 

Encoding type signed.

With this encoding, the first bit in the resulting bytes will mark the sign; the other bits encode the absolute value. According to this, e.g. 129 is encoded as 00000000 10000001 (Bin), whereas e.g. -129 will be encoded as 10000000 10000001 (Bin). Two bytes are required in the example, since the sign-bit reduces the value space.

TWOSCOMPLEMENT 

Two's complement encoding.

The Integer will be encoded according to the most widely used encoding called two's complement. With this encoding, an Integer value of e.g. 129 is encoded as 00000000 10000001 (Bin), whereas a negative Integer value of e.g. -129 will be encoded as 11111111 01111111 (Bin). Two bytes are required here, since the sign-bit reduces the value space.

◆ Endianness

Byte order for writing encoded Integer.

Specifies the byte order which shall be used when writing the encoded Integer value into the resulting ByteField. The most widely used byte order LITTLEENDIAN is the default.

Special Behavior for MIXEDENDIAN
The byte order of MIXEDENDIAN is used by some older systems. It is not specified in OTX and should therefore not be used. It depends on the runtime system which of the following two orders are used: MSB_FIRST_MSW_LAST or MSB_LAST_MSW_FIRST.
Byte Ordernn + 1n + 2n + 3n + 4n + 5n + 6n + 7
MSB_FIRST_MSW_LASTByte1Byte0Byte3Byte2Byte5Byte4Byte7Byte6
MSB_LAST_MSW_FIRSTByte6Byte7Byte4Byte5Byte2Byte3Byte0Byte1
MSB_FIRSTByte7Byte6Byte5Byte4Byte3Byte2Byte1Byte0
MSB_LASTByte0Byte1Byte2Byte3Byte4Byte5Byte6Byte7
(ByteN = Most Significant Byte; Byte0 = Least Significant Byte; MSB_FIRST = Motorola / LITTLEENDIAN; MSB_LAST == Intel/BIGENDIAN)
Order for Comparisons
LITTLEENDIAN < MIXEDENDIAN < BIGENDIAN
Default value
LITTLEENDIAN
Conversion
When applying ToString, the resulting string is the name of the enumeration value. Furthermore, applying ToInteger returns the index of the value in the enumeration (smallest index is 0). The behaviour is undefined for other conversion terms.
See also
Terms.EncodeInteger
Enumerator
LITTLEENDIAN 

The least significant bit (MSB) of a byte is transmitted first.

MIXEDENDIAN 

Byte order for older systems should not be used.

BIGENDIAN 

The most significant bit (MSB) of a byte is transmitted first