Finite State Automata (FSA)

FSA model syntax (Class Diagram meta-model)

dia source

FSA model behaviour (pseudo-code)

 # initialize the state
 currentState = theInitState

 # as long as no Terminal state is reached
 while currentState.type != TERM:

   # get input event from the environment
   currentEvent = environment.getInput()

   # find applicable transition from currentState
   currentTransition = None
   for transition in currentState.transitions:
     if transition.inputEvent == currentEvent:
       currentTransition = transition
   if currentTransition == None:
     print "unrecognized event, rejecting input"
     sys.exit() # or ignore: pass

   # generate output event
   environment.putOutput(transition.outputEvent) # could be action

   # update the current state
   currentState =

 print "input accepted"