170 likes | 453 Views
Automata Based Programming. Margarita Spit šakova Institute of Cybernetics at Tallinn University of Technology 19 . 03 . 08. Outline. Introduction Definition of FSM Usage of FSM FSM as programs Example Future work Conclusions Software, further reading. Introduction.
E N D
Automata Based Programming Margarita Spitšakova Institute of Cybernetics at Tallinn University of Technology 19.03.08
Outline • Introduction • Definition of FSM • Usage of FSM • FSM as programs • Example • Future work • Conclusions • Software, further reading
Introduction • Master thesis: “Genetic Inference of Finite State Machines” • Finite state machine is something abstract • Why I need to generate FSMs?
Finite State Machines • States, transitions, input and output alphabets, final state, initial state. • Moore machine (output at state) • Mealy machine (output at transition) • Deterministic machine
Using FSM • FSM as hardware model • Text recognition (regular expressions) • Text transformations • Pushdown automata in parsers
FSM as program Event Controlled object Controller = Finite State Machines Controlled object Event Controlled object Event
Example. Traffic Lights Red Yellow Red + yellow Blinking green Green
Source code. Controlled object publicclass TrafficLight implements ControlledObject { publicvoid red(StateMachineContext context) { System.out.println("Red"); } publicvoid green(StateMachineContext context) { System.out.println("Green"); } publicvoid yellow(StateMachineContext context) { System.out.println("Yellow"); } publicvoid greenblink(StateMachineContext context) { System.out.println("Green Blinking"); } publicvoid redyellow(StateMachineContext context) { System.out.println("red yellow"); } }
Source code. Controller switch (s) { casegreen: switch (event) { casenext tick: if (counter_x4 < 20) { make transition to state “blinking green”; returnnew StateMachineConfig("blinking green"); } if (counter_x4 >= 20) { make transition to final state; returnnew StateMachineConfig(" final state "); } … } Switch technology
Conclusions • Modeling system • Modeling=writing the code • Step-by-step • Easier to verify • Good for modeling reactive systems
Future work Event Controlled object Controller = Finite State Machine Controlled object Event Controlled object Event Can be generated
Software. Further reading • Unimod. Eclipse plugin for designing object-oriented event-driven applications using automata-based programming adapted for UML. http://unimod.sourceforge.net • AutoFSM. http://autogen.sourceforge.net • Сайт по автоматному программированию http://is.ifmo.ru/