AutomataBased Programming General Purpose Finite State Machines Daniela
![Automata-Based Programming General Purpose Finite State Machines Daniela Kolarova Automata-Based Programming General Purpose Finite State Machines Daniela Kolarova](https://slidetodoc.com/presentation_image_h/d91b5fb046275c34ac5f6c4b458f6489/image-1.jpg)
Automata-Based Programming General Purpose Finite State Machines Daniela Kolarova
![Agenda ▪ Automata-Based Programming ▪ Applications ▪ Finite State Machine Definition ▪ Finite State Agenda ▪ Automata-Based Programming ▪ Applications ▪ Finite State Machine Definition ▪ Finite State](http://slidetodoc.com/presentation_image_h/d91b5fb046275c34ac5f6c4b458f6489/image-2.jpg)
Agenda ▪ Automata-Based Programming ▪ Applications ▪ Finite State Machine Definition ▪ Finite State Machine Example ▪ FSM Model Simplification ▪ FSM Design Approaches ▪ What We Achieved …
![Automata-Based Programming “A programming technique in which the program or part of it can Automata-Based Programming “A programming technique in which the program or part of it can](http://slidetodoc.com/presentation_image_h/d91b5fb046275c34ac5f6c4b458f6489/image-3.jpg)
Automata-Based Programming “A programming technique in which the program or part of it can be thought of as a model of a FSM. ” ▪ 1997 - Introduced on a Multiagent systems conference by N. Polikarpova and A. Shalyto (authors of the book “Автоматное программирование”); ▪ 1943 - Warren Mc. Culloch and Walter Pitts, two neurophysiologists, were the first to present a description of finite automata (“A Logical Calculus Immanent in Nervous Activity”); ▪ 1967 - Marvin Minsky – Computation: Finite and Infinite Machines, Prentice-Hall; ▪ 2015 Spring State. Machine Framework.
![Automata-Based Programming Applications ▪ Transformation systems – compilers, archivers; ▪ Interactive systems – text Automata-Based Programming Applications ▪ Transformation systems – compilers, archivers; ▪ Interactive systems – text](http://slidetodoc.com/presentation_image_h/d91b5fb046275c34ac5f6c4b458f6489/image-4.jpg)
Automata-Based Programming Applications ▪ Transformation systems – compilers, archivers; ▪ Interactive systems – text editors; ▪ Reactive systems – telecommunication systems, hardware controllers;
![Automata-Based Programming Applications ▪ Finite State Machines in Hardware ▪ Programming Language Compilers ▪ Automata-Based Programming Applications ▪ Finite State Machines in Hardware ▪ Programming Language Compilers ▪](http://slidetodoc.com/presentation_image_h/d91b5fb046275c34ac5f6c4b458f6489/image-5.jpg)
Automata-Based Programming Applications ▪ Finite State Machines in Hardware ▪ Programming Language Compilers ▪ Workflow Modeling ▪ Game Programming ▪ State Machines Replication (Implementation of Fault-Tolerant Services)
![FSM Definition An abstract machine that can be in exactly one of finite number FSM Definition An abstract machine that can be in exactly one of finite number](http://slidetodoc.com/presentation_image_h/d91b5fb046275c34ac5f6c4b458f6489/image-6.jpg)
FSM Definition An abstract machine that can be in exactly one of finite number of states at any given time where: ▪ The FSM can change from one state to another in response to some external inputs; ▪ The change from one state to another is called a transition; ▪ A FSM is defined by a list of its states, its initial state, and the conditions for each transition.
![FSM Model Simplification Set of States and a defined Start State Set of Inputs FSM Model Simplification Set of States and a defined Start State Set of Inputs](http://slidetodoc.com/presentation_image_h/d91b5fb046275c34ac5f6c4b458f6489/image-7.jpg)
FSM Model Simplification Set of States and a defined Start State Set of Inputs Set of Outputs Transition function: Input(I) x State(S) -> State(S') Output function: Input(I) x State(S) -> Output(O) or State(S) -> Output(O)
![FSM Example: Subway Turnstile SM State Transition Diagram pass/alarm Locked pass/lock State Transition Table FSM Example: Subway Turnstile SM State Transition Diagram pass/alarm Locked pass/lock State Transition Table](http://slidetodoc.com/presentation_image_h/d91b5fb046275c34ac5f6c4b458f6489/image-8.jpg)
FSM Example: Subway Turnstile SM State Transition Diagram pass/alarm Locked pass/lock State Transition Table State coin/unlock Unlocked coin/thankyou Event Action State Locked pass alarm Locked coin unlock Unlocked pass lock Locked Unlocked coin thankyou Unlocked
![FSM Design Approaches Nested Switch/Case Statements § Complex code - hard to understand change/extend; FSM Design Approaches Nested Switch/Case Statements § Complex code - hard to understand change/extend;](http://slidetodoc.com/presentation_image_h/d91b5fb046275c34ac5f6c4b458f6489/image-9.jpg)
FSM Design Approaches Nested Switch/Case Statements § Complex code - hard to understand change/extend; § No separation of FM logic and actions; § No way to send data to a specific state; § Not thread safe.
![FSM Design Approaches State Design Pattern: Allows an object to alter its behavior when FSM Design Approaches State Design Pattern: Allows an object to alter its behavior when](http://slidetodoc.com/presentation_image_h/d91b5fb046275c34ac5f6c4b458f6489/image-10.jpg)
FSM Design Approaches State Design Pattern: Allows an object to alter its behavior when its internal state changes.
![FSM Design Approaches State Design Pattern: § Strong separation between actions and the SM FSM Design Approaches State Design Pattern: § Strong separation between actions and the SM](http://slidetodoc.com/presentation_image_h/d91b5fb046275c34ac5f6c4b458f6489/image-11.jpg)
FSM Design Approaches State Design Pattern: § Strong separation between actions and the SM Logic; § Explicit transitions defined in the states; § Distributed logic across states; § Tight coupling between state and context.
![FSM Design Approaches State Transition Table: § Transition logic defined on one place; § FSM Design Approaches State Transition Table: § Transition logic defined on one place; §](http://slidetodoc.com/presentation_image_h/d91b5fb046275c34ac5f6c4b458f6489/image-12.jpg)
FSM Design Approaches State Transition Table: § Transition logic defined on one place; § Adding new transition requires insertion of a row in the table; § Efficiency increases if the list is replaced by a Map/Hash. Map; § Readability increases if the construction is implemented via Builder and fluent API; § The table defined can easily be validated against the graphically defined one.
![What We Achieved … § Transition logic defined on one place and avoided the What We Achieved … § Transition logic defined on one place and avoided the](http://slidetodoc.com/presentation_image_h/d91b5fb046275c34ac5f6c4b458f6489/image-13.jpg)
What We Achieved … § Transition logic defined on one place and avoided the traversal of all transitions using a Hash. Map; § Java 8 Features appliade - lambda expressions are optional; § Unified Unit testing of all approaches; § The Action interface can be used as a wrapper for parallel tasks execution; § The example can be easily transformed into a generic state machine and reused.
![References § Polikarpova N. I. , Shalyto http: //is. ifmo. ru/books/_book. pdf A. Automata-Based References § Polikarpova N. I. , Shalyto http: //is. ifmo. ru/books/_book. pdf A. Automata-Based](http://slidetodoc.com/presentation_image_h/d91b5fb046275c34ac5f6c4b458f6489/image-14.jpg)
References § Polikarpova N. I. , Shalyto http: //is. ifmo. ru/books/_book. pdf A. Automata-Based programming, § Volnei A. Pedroni, Finite State Machines in Hardware Theory and Design (with VHDL and System. Verilog) § Robert C. Martin (2003) Agile Software Development, Principles, Patterns, and Practices 1 st Edition, Prentice Halle § Erich Gamma, Richard Help, Ralph Johnson, John Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software 1 st Edition, Addison-Wesley § David Lafreniere, State Machine Design in C++, Dr Dobb's Journal, May 01, 2000, § FRED B. SCHNEIDER, Implementing Fault-Tolerant Services Using the State Machine Approach: A Tutorial, https: //www. cs. cornell. edu/fbs/publications/SMSurvey. pdf § Source code with JUnit tests is available at https: //github. com/Daniela. Kolarova/automata. Based. Programming
- Slides: 14