se.ericsson.eto.norarc.javaframe
Class StateMachine

java.lang.Object
  extended byse.ericsson.eto.norarc.javaframe.ActiveObject
      extended byse.ericsson.eto.norarc.javaframe.StateMachine
All Implemented Interfaces:
Addressable, java.io.Serializable
Direct Known Subclasses:
Router

public abstract class StateMachine
extends ActiveObject
implements Addressable, java.io.Serializable

The StateMachine is a finite State machine that is executed by the associated Scheduler

See Also:
Serialized Form

Field Summary
protected  Message currentMessage
           
protected  State currentState
           
protected  boolean inSchedulerList
           
protected  MailBox messageBox
           
protected  Scheduler myScheduler
           
protected  StateMachine nextFSM
           
protected  MailBox saveQueue
           
protected  Scheduler wantedScheduler
           
 
Fields inherited from class se.ericsson.eto.norarc.javaframe.ActiveObject
activeObjectName, owner
 
Constructor Summary
StateMachine(Scheduler scheduler)
          Create a new StateMachine.
 
Method Summary
protected  void exec(Message sig)
          The treatment by this StateMachine of the next message from the mailbox.
protected abstract  void execStartTransition()
          Code to be executed at startup of this StateMachine.
 void forward(Message sig)
          Forwards the received message to the messageBox of this StateMachine.
 Message getCurrentMessage()
          Get the current Message of this StateMachine.
 State getCurrentState()
          Get the current State of this StateMachine.
 Scheduler getScheduler()
          Get the scheduler running this StateMachine.
protected  void init()
          To be overridden by programmer.
 void moveStateMachine(Scheduler aScheduler)
          Move this StateMachine to the new Scheduler given by the parameter.
 void restart()
          Restart this StateMachine.
 
Methods inherited from class se.ericsson.eto.norarc.javaframe.ActiveObject
activeObjectName, setActiveObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messageBox

protected MailBox messageBox

saveQueue

protected MailBox saveQueue

currentState

protected State currentState

currentMessage

protected Message currentMessage

myScheduler

protected transient Scheduler myScheduler

nextFSM

protected transient StateMachine nextFSM

inSchedulerList

protected transient boolean inSchedulerList

wantedScheduler

protected transient Scheduler wantedScheduler
Constructor Detail

StateMachine

public StateMachine(Scheduler scheduler)
Create a new StateMachine. A StartMessage is put into the messageBox of the StateMachine. As soon as the Scheduler gives this StateMachine attention, the StartMessage is read and execStartTransition() of this StateMachine is called.

Parameters:
scheduler - The Scheduler that runs this StateMachine. Initially the associated Scheduler may be null.
Method Detail

init

protected void init()
To be overridden by programmer. Used to initialize the state machine


moveStateMachine

public final void moveStateMachine(Scheduler aScheduler)
Move this StateMachine to the new Scheduler given by the parameter. New and/or current scheduler (myScheduler) can be null. If myScheduler == null, the movement is done immediately, else the thread of myScheduler will move the FSM (in run()).

Parameters:
aScheduler - The Scheduler to which this StateMachine wants to go

getScheduler

public final Scheduler getScheduler()
Get the scheduler running this StateMachine.

Returns:
The associated Scheduler

getCurrentState

public final State getCurrentState()
Get the current State of this StateMachine.

Returns:
The current State

getCurrentMessage

public final Message getCurrentMessage()
Get the current Message of this StateMachine.

Returns:
The current Message

forward

public final void forward(Message sig)
Forwards the received message to the messageBox of this StateMachine. Check for scheduler wakeup.

Specified by:
forward in interface Addressable
Parameters:
sig - Invariant: sig != null

execStartTransition

protected abstract void execStartTransition()
Code to be executed at startup of this StateMachine. For a non-abstract StateMachine this method must be overridden (at least to set the initial state).


restart

public void restart()
Restart this StateMachine. Note: the content of the messageBox is kept.


exec

protected void exec(Message sig)
The treatment by this StateMachine of the next message from the mailbox. NB: not to be called from user code. The signal sig is already removed from the mailbox. Default action is save.

Parameters:
sig - Invariant: sig != null