Main.DataTypes History
Hide minor edits - Show changes to output
Changed lines 12-14 from:
datatype Boolean;
datatype Integer;
datatype String;
datatype Integer;
to:
datatype Boolean<1>;
datatype Integer<2>;
object String;
datatype Integer<2>;
object String;
Changed line 20 from:
datatype Boolean
to:
datatype Boolean<1>
Deleted line 21:
Changed line 24 from:
datatype UInt8
to:
datatype UInt8<1>
Deleted line 25:
Changed line 28 from:
datatype Int16
to:
datatype Int16<2>
Deleted line 29:
Changed line 32 from:
to:
object String
Changed line 54 from:
enumeration DigitalState
to:
enumeration DigitalState<1>
Deleted line 56:
Changed line 20 from:
datatype Boolean
to:
datatype Boolean
Added line 22:
@c_byte_size "2"
Added line 27:
@c_byte_size "1"
Added line 32:
@c_byte_size "2"
Added line 37:
@c_byte_size "*" // * means that it has the size of a pointer
Added lines 1-91:
!!Data types and literals
The current version of ThingML allows defining two kinds of data types: primitive types and enumeration.
Remark: More complex data structures might be supported in future versions.
!!!Primitive types
Primitive types allow defining the data types used in ThingML. Here are some examples:
[@
datatype Boolean;
datatype Integer;
datatype String;
@]
At compile time these types have to be mapped to types available on the target platform. Typically, the mapping to the platform type is provided by annotating the primitive types:
[@
datatype Boolean
@c_type "uint8_t"
@java_type "boolean";
datatype UInt8
@c_type "uint8_t"
@java_type "short";
datatype Int16
@c_type "int"
@java_type "short";
datatype String
@c_type "char *";
@java_type "String";
@]
!!!Enumerations
Enumerations are defined using the "enumerations" keyword.
[@
enumeration AnalogReference
{
DEFAULT
INTERNAL
EXTERNAL
}
@]
In the same way as for primitive types, annotations are typically used to provide platform types and literal values:
[@
enumeration DigitalState
@java_type "byte"
@c_type "uint8_t"
{
LOW @enum_val "0"
HIGH @enum_val "1"
}
@]
!!!Using data types
The data types are used to specify the types of thing properties, state variables and message parameters. For example:
[@
// definition of a property of type Integer
property myProperty : Integer
// definition of a property of type DigitalState
property state: DigitalState
// defintion of a message with two parameters
message sendState(name : String, state : DigitalState );
@]
!!! Literals
ThingML defines literals for booleans, integers and strings. Notations for literals are illustrated on the example below:
[@
property myBoolean : boolean = true
property myInteger : Integer = 1000
property myString : String = "Some Value"
@]
Enumeration literals can also be used directly using the name of the enumeration and the name of the literal separated by the ":" symbol:
[@
property myDigitalState : DigitalState = DigitalState:LOW
@]
The current version of ThingML allows defining two kinds of data types: primitive types and enumeration.
Remark: More complex data structures might be supported in future versions.
!!!Primitive types
Primitive types allow defining the data types used in ThingML. Here are some examples:
[@
datatype Boolean;
datatype Integer;
datatype String;
@]
At compile time these types have to be mapped to types available on the target platform. Typically, the mapping to the platform type is provided by annotating the primitive types:
[@
datatype Boolean
@c_type "uint8_t"
@java_type "boolean";
datatype UInt8
@c_type "uint8_t"
@java_type "short";
datatype Int16
@c_type "int"
@java_type "short";
datatype String
@c_type "char *";
@java_type "String";
@]
!!!Enumerations
Enumerations are defined using the "enumerations" keyword.
[@
enumeration AnalogReference
{
DEFAULT
INTERNAL
EXTERNAL
}
@]
In the same way as for primitive types, annotations are typically used to provide platform types and literal values:
[@
enumeration DigitalState
@java_type "byte"
@c_type "uint8_t"
{
LOW @enum_val "0"
HIGH @enum_val "1"
}
@]
!!!Using data types
The data types are used to specify the types of thing properties, state variables and message parameters. For example:
[@
// definition of a property of type Integer
property myProperty : Integer
// definition of a property of type DigitalState
property state: DigitalState
// defintion of a message with two parameters
message sendState(name : String, state : DigitalState );
@]
!!! Literals
ThingML defines literals for booleans, integers and strings. Notations for literals are illustrated on the example below:
[@
property myBoolean : boolean = true
property myInteger : Integer = 1000
property myString : String = "Some Value"
@]
Enumeration literals can also be used directly using the name of the enumeration and the name of the literal separated by the ":" symbol:
[@
property myDigitalState : DigitalState = DigitalState:LOW
@]