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 there is input
while environment.inputRemaining():
# 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
break
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 = transition.target
if currentState.type == TERM:
print "input accepted"
else:
print "input rejected"