Statements
Type
BaseType
Integer
Boolean
Enumeration
Literal
Fixed
Float
String
General
In Matrix the following base types (in bold) are pre-defined:
Discrete
Integer
Boolean
Enumerated
Real
Fixed
Float
String
Each type declaration statement introduces a distinct bounded type such that values of one type may not be assigned to variables of another type.
Conversion between compatible types is possible in two ways as shown below:
Assignment
Evaluation:amount
AdditionCast:Type_Fixed
AdditionData
+Type_Integer'amount
+Entity.Attribute_integer
<<IntegerOne>>
Three model data item elements require a type:
Attributes
State Data
Process Data
Model Compilers may or may not insert run-time data item bounds checking code at generation time. Checking may be a configurable option in the Model Compiler or checking may be part of the target language as in for example, Ada.
Type Statement
Type
The Type statement introduces the BaseType and Subtype statements.
BaseType Statement
Type
BaseType
The BaseType statement introduces the following types:
Integer
Boolean
Enumeration
Fixed
Float
String
The above types must appear in the order given above.
Integer Statement
Type
BaseType
Integer
Cycles : 0 .. +10000
This statement declares the minimum and maximum values of integer data items.
Boolean Statement
Type
BaseType
Boolean
Flag
Valid
This statement declares boolean types.
Enumeration Statement
Type
BaseType
Enumeration
Literal:Colour
BLACK
WHITE
The purpose of the Enumeration statement is to introduce one or more Literal statements.
Literal Statement
Type
BaseType
Enumeration
Literal:Colour
BLACK
WHITE
This statement declares allowable literal values of data items of this type.
Fixed Statement
Type
BaseType
Fixed
Swing : 0.0001 : -1.0 .. +1.0
Voltage : 0.001 : 12.0 .. 24.0
Current : +0.0001 : -1.0 .. 1.0
Amplitude : 0.001 : 0.0 .. 1.0
This statement declares fixed types which are implemented as fixed point types where the target language allows. The second data field is the magnitude of the acceptable error bound for a particular absolute accuracy. The third and fourth fields are the minimum and maximum values of data items of this type. A Model Compiler may use a software package or library to help implement this type.
Float Statement
Type
BaseType
Float
Degrees : 2 : -90.0 .. +90.0
Friction : 5 : 0.0 .. 1.0E02
Temperature : 4 : -100.0 .. 100.0
This statement declares floating types which are implemented as floating point types or alternatively, fixed point types where the target language allows. The second field is the number of significant digits of precision required for a particular relative accuracy. The third and fourth fields are the minimum and maximum values of data items of this type. A Model Compiler may use a software package or library to help implement this type.
String Statement
Type
BaseType
String
Name : 20
Address : 1_024
This statement declares a string type with a specified maximum length. Any data item declared from this type will always have the same length even when the actual string is shorter. However, a Model Compiler can make use of dynamic memory functions to implement strings so designed.
|