[%### An example of how to extract HTML documentation from StateML ###%] [% MACRO Handlers(name,handlers) BLOCK %] [% IF handlers %] [% IF name %]
  • [% name | html %] [% END %] [% END %] [% END %] [% MACRO Arc(name, arcs) BLOCK %] [% IF name %]
  • [% ELSE %][% END %] [% arc.event_id | html %] [% IF name %][% ELSE %][% END %] : [% arc.from_state.id | html %] -> [% arc.to_state.id | html %] [% IF arc.description %]
    [% arc.description | html %]
    [% END %] [% IF arc.handlers %] [% Handlers( "", arc.handlers ) %] [% ELSE %]
    [% END %] [% END %] [% MACRO Arcs(name, arcs) BLOCK %] [% IF arcs %] [% IF name %]
  • [% name %] [% END %] [% END %] [% ########################################################################## %] Description of State Machine [% machine.id | html %]

    Description of State Machine [% machine.id | html %]

    States

    A state is a condition that the machine rests in between events. Each state may have arcs that define what events a state handles by itself (loopback arcs), what events cause a transition to another state (exit arcs), and what events cause transitions in to that state from other states (entry arcs).

    [% IF machine.states %] [% FOREACH state = machine.states %] [% state.id | html %] [% IF state.description %]
    [% state.description | html %] [% END %] [% END %] [% ELSE %]

    No states defined.

    [% END %]

    Events

    A event is a notification, usually from outside the machine, that something has occured, like a key press or a timeout. For instance, there is usually an event that starts the machine by moving it from an undefined (power-up) state in to an initial state.

    In a given state, each event may only trigger one arc. An event need not trigger any arcs on a given state, or indeed any arcs in the machine at all. Such events are ignored except for running their event handlers.

    Events may have several types of "handlers" associated with them. These run whenever that event is recieved by the machine, regardless of whether or not the event fires an arc. These are:

    pre handlers
    code snippets that run before the arc is traversed, while still in the current state.
    handlers
    code snippets that run while the arc is being traversed; these occur "between" states: after the current state is exited and before the new state is entered.
    post handlers
    code snippets that run after the arc is traversed and the new state has been entered.

    The events in [% machine.id | html %] are:

    [% IF machine.events %] [% FOREACH event = machine.events %] [% event.id | html %] [% IF event.description %]
    [% event.description | html %] [% END %] [% END %] [% ELSE %]

    No events defined.

    [% END %]

    Arcs

    Arcs are the transitions that occur between states when events are received: they cause the state machine to move from one state to another state. A loopback arc is an arc that ends in the same state it left; these are used to handles inputs that are consumed in a given state.

    A handler routine may be associated with any arg.

    There is a special state ID "__ALL" or "#ALL" which is used to define arcs that affect all states.

    [% IF machine.arcs %] [% Arcs( "", machine.arcs ) %] [% ELSE %]

    No arcs defined.

    [% END %]