Home of

SMC

The State Machine Compiler

(Updated February 20, 2023)

Your application lives in a world of asynchronous, unordered events: mouse clicks, timeouts, messages, and OS signals. And you're ready for them. You've carefully designed your objects. You're using robust patterns that facilitate reuse and anticipates future product direction. Your dynamic models allow your objects to recover from all but the most catestrophic events. Your application is ready for anything.

But there's a hitch. Your detailed state diagrams are only pictures. How are you going to translate your drawings into code? A transition matrix is cryptic while switch statements means your state machine logic is scattered all over your code. The state pattern looks like a great solution but that means writing and maintaining a class for each state - too much work.

Enter SMC - The State Machine Compiler. Now you put your state diagram in one file using an easy-to-understand language. SMC generates the state pattern classes for you. No more hand-maintained transition matrices. No more widely scattered switch statements. Instead, the state diagram is in one place, coded directly from the picture to the SMC language and is easily maintained.

SMC uses the state pattern to its fullest extent. In the real world, events don't always happen when they should. Dealing with unexpected events is a must for a robust application. By combining virtual methods with the state pattern, SMC allows you to define "Default" transitions - transitions which allow your objects to handle unexpected events, recover and continue providing service (rather than crashing, burning and getting you into trouble).

SMC is a Java application. That means SMC will work on any platform where Java 1.7.0 or better is supported.


Version 7.6.0: Bug Fix.

Release fixes SMC bug 238. When -headerd command line option was used, an incorrect #include generated.

Version 7.5.0: Minor Bug Clean-up.

This release fixes the following bugs:

  • All: Added bin/Smc.jar to git.
    (SMC bug 234)
  • Graph: When generating Graphviz DOT file, periods (.) appearing in digraph identifier are replaced with underscores (_) since period is not acceptable character in an identifier.
    (SMC bug 235)

Version 7.4.0: Minor Bug Clean-up.

This release fixes the following bugs:

  • All: Corrected version displayed for "-version" to "7.4.0".
    (SMC bug 231)
  • C: Added missing fsm parameter to EXIT_STATE macro.
    (SMC bug 232)
  • C++: When "-noex" option used with -c++, generated "_sm.cpp" file contained static class declarations contained "NULL" state names. While this was by explicit design, these null state names made FSM trace statements unusable because state names appeared as "NAME NOT SET". SMC C++ now generates state names in all circumstances.
    (SMC bug 233)

Version 7.3.0: Yet more bug stomping.

This release fixes the following bugs:

  • Java, Java7: Java classes statemap.FSMContextbb and statemap.FSMContext7 initialize data member "PropertyChangeSupport mListeners" to null. A java.beans.PropertyChangeSupport instance is created only when method setPropertyChangeUpdate(boolean flag) is called where flag is true.
    This change is made so that SMC-generated state machines may be used in compact JRE profiles.
    (SMC feature request 102))
  • Java, Java7: Java classes statemap.FSMContext and statemap.FSMContext7 now support posting debug output to java.util.logging.Logger at a defined java.util.logging.Level. Please note that debug output may be sent either to Java logger or to an output stream but not both.
    (SMC feature request 101))
  • C: C statemap.h in git-code repository brought up to date with latest code. Macros are now properly wrapped.
    (SMC bug 226))
  • Java, Java7: If java-targeted state machine throws a TransitionUndefineException, that exception will reach the application layer.
    (SMC bug 227))
  • C: Generated C code no longer uses "#undef" for macros. A macro is defined only once in its final, correct state. There is no longer any need to undefine a macro and then redefine it.
    (SMC bug 228))
  • C: Generated C header code for ENTRY_STATE now contains an FSM parameter which is passed to the state entry function. Generated C source code passes this fsm parameter to ENTRY_STATE.
    (SMC bug 229))
  • C, C++: Removed incorrect call to <appclass state>_Default(fsm) method from generated Default state transition code.
    (SMC bug 230))


Version 7.2.0: More bug stomping.

This release fixes the following bugs:

  • C: C code generator creates an unused default transition function. This is corrected by having that default transition referenced.
    (SMC bug 224)
  • C: C code generator places ENTRY_STATE and EXIT_STATE macros in the generated .c file which may result in a link failure. This is corrected by moving the macros to the generated header file.
    (SMC bug 225)

Version 7.1.0: Bug stomping.

This release fixes the following bugs:

  • All: Incorrect code is generated if an unguarded transition appears before a guarded transition.
    (SMC bug 216)
  • All: SMC maven plug-in does not report errors found in .sm file.
    (SMC bug 221)
  • Objective-C: All states in ObjC generated code have stateId == 0.
    (SMC bug 223)

Version 7.0.0: smc-maven-plugin.

SMC is now back up on Maven Central Repository along with a new smc-maven-plugin. This allows Java Maven projects to automatically compile .sm files and include the generate source into the overall build. The SMC plugin supports all the same options as the command line.

The downside is that the artifact only contains the Java library needed to run an application. This is due to the fact that Maven is Java-centric and does not really support other target languages easily. This means that SMC will continue to be released to SourceForge in the same manner as before.

The artifact includes the module example-java-ex6 which shows how a Java Maven project's POM can use the smc-maven-plugin.

SMC Maven identifiers are:

  • groupId: net.sf.smc
  • artifactIds: model, parser, generator, main, library, smc-maven-plugin, and example-java-ex6
  • version: 7.0.0

SMC Programmer's Manual Section 14: Pluggin In shows how to connect a Java Maven project to the smc-maven-plugin and depend upon the Java library module.

This release fixes the following bug:

  • Java: -java7 generates a non-final state machine context class. This allows developers to extend the context class.
    (SMC bug 220)

Check the SMC project's Latest News to find out the latest, report bugs, ask questions, make suggestions or to learn how you can help improve this great tool.

What's New?  
C JavaScript Python
C++ Lua Ruby
C# Objective-C Scala
Groovy Perl TCL
Java* PHP VB.net
See how easy it is to put SMC generated state machines into your code. This page walks you through the steps to using the State Machine Compiler. This page comes in fourteen flavors: C , C++ , C# , Groovy , Java , JavaScript , Lua , Objective-C , Perl , PHP , Python , Ruby , Scala , Tcl and VB.net .

* In Java, the state machine can be implemented using either the State Pattern or a transition table (using java.lang.invoke.MethodHandle).

  Step into the picture gallery and check out the finite state machine pictures at all levels of detail, both the raw, SMC-generated version to the human-edited improvements. Graphing SMC
SMC Telephone Applet Step in, close the door and place a call. The SMC Telephone Demo is a Java applet driven by an SMC-generated finite state machine . You can watch the FSM do its thing while placing your call.  
  SMC Programmer's Manual And when all else fails (and only then), READ THE MANUAL!
  Got questions? Then check out the Frequently Asked Questions (FAQ) page. Can't find your question? Then e-mail it to me and I will send you the answer and add it to the FAQ. SMC FAQ
Downloading SMC Alright, you're gonna bite. This page has the download links for SMC.
  SMC contributers Stand up and and give them a hand! Who? Why those intrepid folks who have contributed to SMC, that's who! Find out who all make SMC the success that it is.
  Is there some feature you would like to see added to SMC? Is there an irritating bug you would like to see fixed? Then make a wish. Or better yet, go here to make submit a feature request and here to submit a bug report. Your wish is my command
SourceForge.net Logo SourceForge.net has many other open source software downloads available. Surf over and check it out!  
Support This Project

And in case you were wondering, SourgeForge provides all the servers, networks and software necessary to make SMC possible - without asking for anything in return!

Well I'm asking. You can now donate to the SMC project and 100% of the donation goes to SourceForge.net. If you want SMC to keep going, then we all have to keep SourceForge going.

 
 

Contacting Me
If you have any comments or questions, contact me.

Open Hub profile for cwrapp

View Charles Rapp's profile on LinkedIn


Copyright © 2000 - 2009, 2011, 2013, 2017, 2019, 2021. Charles W. Rapp.
All rights reserved.