SMC The State Machine Compiler (40 ) Franois Perrad - - PowerPoint PPT Presentation

smc the state machine compiler 40
SMART_READER_LITE
LIVE PREVIEW

SMC The State Machine Compiler (40 ) Franois Perrad - - PowerPoint PPT Presentation

SMC The State Machine Compiler (40 ) Franois Perrad francois.perrad@gadz.org fperrad@OSDC.fr2009 The State Machine Compiler Introduction Basic concepts Advanced concepts More features A case study : a Telephone


slide-1
SLIDE 1

fperrad@OSDC.fr2009

SMC The State Machine Compiler (40 ’)

François Perrad

francois.perrad@gadz.org

slide-2
SLIDE 2

fperrad@OSDC.fr2009

The State Machine Compiler

 Introduction  Basic concepts  Advanced concepts  More features  A case study : a Telephone  Conclusion

slide-3
SLIDE 3

fperrad@OSDC.fr2009

FSM are everywhere

FSM : Finite State Machine

Not a new technology

Strong theorical base

Reactive systems / Transformational systems

Event driven

Applications :

Telephones, automobiles, communication networks, avionic systems, man-machine interface

slide-4
SLIDE 4

fperrad@OSDC.fr2009

FSM graphical view

 Moore  Mealy  Grafcet  UML = Harel statechart

slide-5
SLIDE 5

fperrad@OSDC.fr2009

A SourceForge project

Some facts :

registered in 2000

~500 downloads / month

~100 bugs (closed)

written in Java

mature codebase

well documented

3 developers

Licence MPL

See : http://www.ohloh.net/projects/7339?p=SMC

slide-6
SLIDE 6

fperrad@OSDC.fr2009

The State Machine Compiler

 Introduction  Basic concepts  Advanced concepts  More features  A case study : a Telephone  Conclusion

slide-7
SLIDE 7

fperrad@OSDC.fr2009

A Compiler

 A input source .sm (yacc-like syntax)  A output source (readable) in your

language

 Currently 14 target languages :

C, C++, C#, Groovy, Java, Lua, Objective- C, Perl, PHP, Python, Ruby, Scala, Tcl and VB.net

 An Object Oriented design :

your class has a member which is the FSM generated class

 A small RunTime Library

slide-8
SLIDE 8

fperrad@OSDC.fr2009

A Simple Transition

// State Idle { // Trans Next State Actions Run Running {} }

slide-9
SLIDE 9

fperrad@OSDC.fr2009

A Reflexive Transition

// State Idle { // Trans Next State Actions Timeout Idle {} }

slide-10
SLIDE 10

fperrad@OSDC.fr2009

A Internal Event

// State Idle { // Trans Next State Actions Timeout nil {} }

slide-11
SLIDE 11

fperrad@OSDC.fr2009

A Transition with Actions

// State Idle { // Trans Run // Next State Running // Actions { StopTimer("Idle"); DoWork(); } }

slide-12
SLIDE 12

fperrad@OSDC.fr2009

Transition Guards

// State Idle { // Trans Run // Guard condition [ctxt.isValid()] // Next State Running // Actions { StopTimer("Idle"); DoWork(); } Run Idle { RejectRequest(); } }

slide-13
SLIDE 13

fperrad@OSDC.fr2009

Transition Arguments

// State Idle { // Transition Run(msg: const Message&) // Guard condition [msg.isValid()] // Next State Running // Actions { StopTimer("Idle"); DoWork(msg); } Run(msg: const Message&) // Next State Actions Idle { RejectRequest(msg); } }

slide-14
SLIDE 14

fperrad@OSDC.fr2009

Entry and Exit Actions

// State Idle Entry { StartTimer("Idle", 1); CheckQueue(); } Exit { StopTimer("Idle"); } { // Transitions }

slide-15
SLIDE 15

fperrad@OSDC.fr2009

the State Machine Compiler

 Introduction  Basic concepts  Advanced concepts  More features  A case study : a Telephone  Conclusion

slide-16
SLIDE 16

fperrad@OSDC.fr2009

Advanced Features

 Map : state container

 only one level (multiple with UML)

 Push/Pop

 with stack context  see UML History

 Default state

 factorisation of common behavior

in a map

 No concurrency (ie //)

slide-17
SLIDE 17

fperrad@OSDC.fr2009

The Design Pattern

slide-18
SLIDE 18

fperrad@OSDC.fr2009

the State Machine Compiler

 Introduction  Basic concepts  Advanced concepts  More features  A case study : a Telephone  Conclusion

slide-19
SLIDE 19

fperrad@OSDC.fr2009

More features

Event management is yours

Graphviz output generation

HTML table generation

Dynamic trace

Namespace support

Reflection (for MMI)

slide-20
SLIDE 20

fperrad@OSDC.fr2009

Graphviz output

slide-21
SLIDE 21

fperrad@OSDC.fr2009

the State Machine Compiler

 Introduction  Basic concepts  Advanced concepts  More Features  A case study : a Telephone  Conclusion

slide-22
SLIDE 22

fperrad@OSDC.fr2009

A Telephone

 Go to the WEB  Play with the demo (Applet Java)

@ http://smc.sourceforge.net/SmcDemo.htm

slide-23
SLIDE 23

fperrad@OSDC.fr2009

the State Machine Compiler

 Introduction  Basic concepts  Advanced concepts  More Features  A case study : NSquare  Conclusion

slide-24
SLIDE 24

fperrad@OSDC.fr2009

all contributions welcomed

Eclipse plugin

Debian packaging

Pluggable language support

New target language

Regression test

slide-25
SLIDE 25

fperrad@OSDC.fr2009

Bibliography / Webography

  • SMC : http://smc.sourceforge.net/
  • Robert C. Martin, "Agile Software Development"
  • http://en.wikipedia.org/wiki/Finite_state_machine
  • http://en.wikipedia.org/wiki/Statechart
  • D. Harel, "Statecharts: A Visual Formalism for Complex

Systems"

  • http://www.uml.org/
  • http://fr.wikipedia.org/wiki/Grafcet
  • NF C03-190 - Diagramme fonctionnel "GRAFCET"
  • http://en.wikipedia.org/wiki/Augmented_transition_network