Skip navigation links
org.vishia.states

Class StateMachine

Any state should override the method StateSimple.checkTrans(EventObject). This method checks all conditions which can fire any transition and returns the selected transition instance or null if nothing should fire. This method should not execute actions. It should only test the condition and select the transition. The actions are done in the calling environment of this method, lastly if processEvent(EventObject) of the whole statemachine is invoked.

On construction of the whole StateMachine all state classes are instantiated and listed in the StateMachine. All transitions are evaluated and transformed in a unified list of transition objects. For all transitions the necessary exitState()- and entryState() operations are detected and stored, so that complex state switches are executed correctly. The designation of destination states in the written source code uses the class names of the states. The transition evaluation process on construction searches and lists the instances of the states.

A state instance can be gotten with getState(Class)

The StateMachine can be quested whether a state is active yet: isInState(Class) or isInState(Class)


Creation of a StateMachine with or without a timer and an event queue:
One can execute the state machine in 2 modes: In the first case an instance of EventTimerThread#EventThread(String) are necessary which is a parameter for the constructor #StateMachine(EventTimerThread, EventTimerMng).

If an EventTimerThread is used an instance of EventTimerMng is possible and recommended . The timer manager can manage any number of time orders. It sends an EventTimerMng.TimeEvent to this StateMachine it the time is expired.

The state machine can be animated using processEvent(EventObject) with or without events by given a null argument, for example cyclically if an EventTimerThread is not used.

To see how transitions and timeouts should be written see on StateSimple.Trans and StateSimple.Timeout.
Skip navigation links