Home   Documentation   Demonstrations   Download

AMICO: Documentation / AMICO Modules / State Machine

 

Implementation of a finite state machine (FSM) or finite state automaton, a model of behavior composed of states, transitions and actions. A state, represented by AMICO variables, stores information about the past, i.e. it reflects the input changes from the system start to the present moment. A transition indicates a state change and is described by a condition that would need to be fulfilled to enable the transition. An action is a description of an activity that is to be performed at a given moment.

How To Run

     java -jar %AMICO_HOME%/bin/amico-state-machine.jar [<conf-url>]

 


Configuration Files

 

A main configuration file:
 

This is a minimal configuration file that uses default parameters for missing attributes.
Use this file if you want to use default settings.

---------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<state-machine>
    <state-machine-adapter url="file:conf/state-machine/state-machines.xml"/>
</state-machine>

This is a full configuration file that overrides default parameters.

---------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<state-machine>
    <communicator host="localhost" port="3320">
        <!-- Basic parameter for establishing connection with communicator. Module uses TCP connection.
             <command> element define a list of commands that will be sent to communicator
             each time a module establish a connection (see AMICO TCP protocol for details on commands)
        -->

        <command>UPDATE last-loaded-module SM</command>
        <command>ONUNLOAD DELETE last-loaded-module</command>
    </communicator>


    <state-machine-adapter url="file:conf/state-machine/state-machines.xml"/>
</state-machine>

 

 A configuration file for AMICO state machine adapter (linked from a main configuration file):
 

<?xml version="1.0" encoding="UTF-8"?>

<state-machine entry-state="state1" exit-state="state10">

    <state id="state1">

        <entry-action type="list">

            <command timeOffsetMs="1000">UPDATE-DIRECT state-info Enter-state-1</command>

        </entry-action>

        <exit-action type="list">

            <command timeOffsetMs="0">UPDATE-DIRECT state-info Exit-state-1</command>

        </exit-action>

    </state>
 

    <state id="state2">

        <entry-action type="list">

            <command timeOffsetMs="1000">UPDATE-DIRECT state-info Enter-state-2</command>

        </entry-action>

        <exit-action type="list">

            <command timeOffsetMs="0">UPDATE-DIRECT state-info Exit-state-2</command>

        </exit-action>

    </state>
 

    <transition from="state1" to="state2" trigger="state[.='2']" trigger-on-every-update="true">

        <transition-action type="list">

            <command timeOffsetMs="1000">UPDATE-DIRECT age 12</command>

            <command timeOffsetMs="1000">UPDATE-DIRECT age 13</command>

            <command timeOffsetMs="1000">UPDATE-DIRECT age 20</command>

            <command timeOffsetMs="1000">UPDATE-DIRECT age 30</command>

        </transition-action>

    </transition>
 

    <transition from="state2" to="state3" trigger="test[.='xslt']" trigger-on-every-update="true">

        <transition-action type="xml" input-type="empty" input="" xslt-url="file:conf/state-machine/derived-commands.xsl">

            <parameter name="numberOfSteps" value="&lt;%=number%&gt;"/>

            <parameter name="startNumber" value="&lt;%=number%&gt;"/> 

            <parameter name="user-id" value="&lt;%=user-id%&gt;"/-->

        </transition-action>

    </transition>
 

    <transition from="state3" to="state4" trigger="test[.='list']" trigger-on-every-update="true">

        <transition-action type="list">

            <command timeOffsetMs="1000">UPDATE-DIRECT age 12</command>

            <command timeOffsetMs="1000">UPDATE-DIRECT age 13</command>

            <command timeOffsetMs="1000">UPDATE-DIRECT age 20</command>

            <command timeOffsetMs="1000">UPDATE-DIRECT age 30</command>

        </transition-action>

    </transition>

</state-machine>

 

Each state (on entry and exit) and each transition runs a sequence of commands when transition trigger is activated. Sequence of commands can be given as list, as a link to a file that contains list of commands, or to a XSLT that derives list of commands. XSLT file can also receive parameters.

 

Validation Logos