The definition section of the statechart defines which entities of the statechart, like variables, events and operations, are accessible from the outside and which ones are only used internally. For this, a definition section can declare an internal scope and multiple interfaces.
A statechart interface declares the entities that are externally visible. These are the elements by which the client code can interact with the statechart. A statechart can declare multiple interfaces with different names. The unnamed interface is also called the default interface.
Interface Element Declaration | Meaning |
---|---|
in event SwitchOn |
Incoming event, supposed to be raised by the client code and processed by the state machine to evaluate potential state transitions. |
in event Slider : integer |
Incoming event with payload of type
integer
|
out event Finish |
Outgoing event, supposed to be raised by the state machine and delivered to the outside. |
out event Error : string |
Outgoing event with payload of type
string . Can be raised by a transition or state reaction with
raise Error : "Some error message"
|
var brightness : integer |
Variable, used to store some data. Can be changed by the state machine and by the client code. |
var brightness : integer = 3 |
Variable with initial value. |
var readonly brightness : integer |
Variable marked as readonly to ensure it is not changed by the client code. |
const PI : real = 3.14 |
Constant, used to store some immutable data that is not changeable by the client code or the state machine. Constants must have an initial value. |
operation average(a : real, b : real) : real |
Operation, connects a state machine to the outside world by making external behaviour accessible. Implementation needs to be provided by the client code. |
Typed elements must have one of the following types: integer, real, boolean or string.
The internal scope declares the entities that are only used internally by the statechart and hence are not visible to the outside.
Internal Element Declaration | Meaning |
---|---|
event Process |
Internal event, can only be raised by the state machine. |
var brightness : integer |
Internal variable, only visible by the state machine, not by the client code. |
const PI : real = 3.14 |
Internal constant, only visible by the state machine, not by the client code |
operation average(a : real, b : real) : real |
Operation, connects a state machine to the outside world by making external behaviour accessible. Implementation needs to be provided by client code. |
every 500ms / raise Process |
Statechart reaction, is evaluated on each run cycle. Used to specify reactions that are independent of the current state. |
For more details on the definition section, consult the language reference.