Download Latest Version EasyFSM-0.0.006.jar (24.1 kB)
Email in envelope

Get an email when there's a new version of Java FSM Library : DynamicEasyFSM

Home
Name Modified Size InfoDownloads / Week
EasyFSM-0.0.006.jar 2016-04-29 24.1 kB
EasyFSM-0.0.005.jar 2016-04-28 20.8 kB
EasyFSM-0.0.004.jar 2016-04-14 20.8 kB
EasyFSM-0.0.003.jar 2016-04-02 20.1 kB
EasyFSM-0.0.002.zip 2016-03-29 108.3 kB
EasyFSM-0.0.002.jar 2016-03-29 20.0 kB
README.txt 2014-03-30 3.0 kB
EasyFSM.zip 2014-03-30 33.5 kB
Totals: 8 Items   250.7 kB 0
EasyFSM (A Java Library; to facilitate Finite State Machine (FSM) creation.
---------------------------------------------------------------------------

Description:
------------

This library facilitates creation of a Finite State Machine (FSM).
Library generates a Finite State Machine (FSM) from a configuration
file specified while invoking the object for the FSM class.

Current library has been built as Java Library Project in Netbeans 7.0.1

Source code (EasyFSM.zip) can be extracted and built in a Netbeans IDE 
or can even be ported to an Eclipse environment.


Usage:
------

Just a test example for usage:

<Code>

    public static void testFSM() {
        try {
            FSM f = new FSM("C://config.xml", new FSMAction() {
                @Override
                public boolean action(String curState, String message, String nextState, Object args) {
                    javax.swing.JOptionPane.showMessageDialog(null, curState + ":" + message +" : " +nextState);
                    /*
                     * Here we can implement our login of how we wish to handle an action
                     */
                    return true;
                }
            });
            System.out.println(f.getCurrentState());
            f.ProcessFSM("MOVELEFT");
            System.out.println(f.getCurrentState());
            f.ProcessFSM("MOVE");
            System.out.println(f.getCurrentState());
            f.ProcessFSM("MOVERIGHT");
            System.out.println(f.getCurrentState());
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(TestOwnCode.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(TestOwnCode.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(TestOwnCode.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static void main(String[] args) {
        try {
            testFSM();
        } catch (Exception ex) {
            Logger.getLogger(TestOwnCode.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
</Code>

XML Configuration file should be of the following format:

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

<!--
    Document   : config.xml
    Created on : 22 March, 2013, 9:05 AM
    Author     : ANKIT
    Description:
        File specifies states and transition of an FSM.
        This is an example file.
-->

<FSM>
	<STATE id="START" type="ID">
		<MESSAGE id="MOVE" action="move" nextState="START"/>
		<MESSAGE id="MOVELEFT" action="moveLeft" nextState="INTERMEDIATE"/>
		<MESSAGE id="MOVERIGHT" action="moveRight" nextState="STOP"/>
	</STATE>
	<STATE id="INTERMEDIATE">
		<MESSAGE id="MOVELEFT" action="moveLeft" nextState="STOP"/>
		<MESSAGE id="MOVERIGHT" action="moveRight" nextState="ANKIT"/>
	</STATE>
	<STATE id="STOP">
	</STATE>
	<STATE id="ANKIT">
	</STATE>
	
</FSM>

Source: README.txt, updated 2014-03-30