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 state keyword, followed by the name of the state, and then the state body (see below).

state someState {
        ... state body ...
      }

You define initial and final states using the initial and final modifiers. For example, for an initial state:

initial state startState {
          ... state body ...
        }
Tip Only one initial state is permitted.

state body

Warning 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

description

description "text of the description of the state";

entry actions

entryaction + comma-separated list of actions

entryaction setTimer, sendMOForwardSM;

0 or 1

exit actions

exitaction + comma-separated list of actions

exitaction cancelTimer;

0 or 1

input actions

inputaction + condition & comma-separated list of actions

inputaction if(tcp.hello) checkWeather;
inputaction if(tcp.hello && niceWeather) checkTemperature;
  • The first line in this example evaluates the conditional expression tcp.hello; and if true, executes the checkWeather action.

  • The second line evaluates the conditional expression tcp.hello && niceWeather; and if the external tcp.hello and local niceWeather inputs are both true, executes the checkTemperature action.

  • The if() statement must contain a conditional expression.

0 or more

transitions

transition + condition & name of the sink state

transition if(tcp.hello) stopState;
transition if(capv2.idp && notbarred) continueCall;
  • The first line in this example evaluates the conditional expression tcp.hello; and if true, performs the transition and executes any actions as per the FSM execution model.

  • The second line evaluates the conditional expression capv2.idp && notbarred; and if true, performs the transition to the continueCall state.

transition continueCall;
  • This example shows an unconditional transition. The state machine will never wait for input in this state as this transition will be performed. Only one unconditional transition should be declared and always last. Any transitions declared after it will be unreachable and never checked or performed.

  • For multiple transitions with conditions evaluating to true, the first transition declared will take precedence and will be the only transition to execute.

  • The if() statement must contain a conditional expression.

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 either transient or durable; defaults to transient 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.

Note 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.

Previous page Next page