This page defines the FSM Tool specification language syntax.
For the specification language grammar, please see FSM Tool FSM DSL Grammar. |
FSM specification syntax
You define an FSM specification with the fsm
keyword, followed by the name of the FSM, and then a body contained by {
and }
. For example:
fsm NameOfFsmSpecification {
... fsm specification body ...
}
FSM specification body
The body of the FSM specification has the following elements:
description
The description element describes the FSM, using the description
keyword followed by the text in quotes (which can span multiple lines):
description "text of the description of the fsm";
state
The state element defines states in the FSM, including actions and transitions.
Keyword + name of state + body | Initial and final states | ||
---|---|---|---|
You define a state with the
|
You define initial and final states using the
|
state body
The order of declaration of elements must be in the order they are listed below. |
The state body has the following elements, defined by keywords and other variables, and declared in the following order:
Element | Keyword + … | Example | Number |
---|---|---|---|
description |
|
|
|
entry actions |
|
|
0 or 1 |
exit actions |
|
|
0 or 1 |
input actions |
|
|
0 or more |
transitions |
|
|
0 or more |
endpoint
The endpoint element declares the name of an endpoint for the FSM:
endpoint tcp;
inputdictionary
The inputdictionary must declare all inputs used in the state body elements. You define an inputdictionary element with the inputdictionary
keyword, followed by the inputdictionary body.
inputdictionary {
... inputdictionary body ...
}
inputdictionary body
The inputdictionary body declares 0 or more inputs. Each input can either be an external input (received through an endpoint) or a local input (internal to the current FSM).
External inputs are declared by the name of the endpoint on which they are received, followed by a .
, the name of the input and finally a body enclosed in {
and }
:
tcp.hello {
... input declaration body ...
}
Local inputs are declared simply by the name of the input and followed by a body enclosed in {
and }
:
niceweather {
... input declaration body ...
}
Each input declaration body can contain the following elements:
-
description — keyword followed by text in quotes.
-
type — defined with the
type
keyword, followed by eithertransient
ordurable
; defaults totransient
if not specified; determines whether you need to manually unset the input (if durable) or whether the input is cleared automatically at the end of the FSM execution cycle (see "Extend the generated SBB" in FSM Tool Procedures). -
send — defiend with the
send
keyword, followed by an input name typically an endpoint related input. Used to specify the behaviour of an action.
Local inputs are declared in the FSM DSL without endpoint names. However, when referring to them when writing Java code in the implementation class, they are accessed through a default endpoint called local which is present in all FSMs. |
actiondictionary
The actiondictionary must declare all entry, exit and input actions used in state body elements. An actiondictionary element is defined with the actiondictionary
keyword, followed by the actiondictionary body.
actiondictionary {
... actiondictionary body ...
}
actiondictionary body
The actiondictionary body declares 0 or more actions, each with an action name followed by a body enclosed in {
and }
.
setTimer {
... action declaration body ...
}
Each action declaration body can contain the following elements:
-
description — keyword followed by text in quotes.
Conditional expressions
Conditional expressions consist of:
-
Variables (inputs)
-
AND (
&&
) and OR (||
) operators -
NOT (
!
) operator -
parentheses to specify the order of precedence — if not specified,
&&
(conditional AND) takes precedence over||
(conditional OR).!
(NOT) takes precedence over&&
and||
.
For example:
tcp.hello
tcp.hello && niceWeather
!niceWeather
capv2.idp
capv2.idp && parametersCorrect
(capv2.idp && authenticated) || (capv2.idp && authenticationNotRequired)
In the example, tcp.hello
and capv2.idp
are both external inputs, and niceWeather
, parameterCorrect
, authenticated
, and authenticationNotRequired
are all local inputs.