Andy's insights

Opinions, thoughts, archivements

Sat, 29 Nov 2008

Finite state machine XML dialect

I just discovered the SCXML a W3C working draft. This sounds like a good idea.

No, I don’t like XML designed to be hand crafted. We need obviously front end tools to actually generate those XML files. I think about graphical connect-your-boxes-tools (e.g. Dia ) as well as text based tools like the SMC .

Well, let’s look closed at SMC: Why do we need an XML dialect while this is an already text based FSM description? The reason is quite simple: to dynamically load a state machine description based on the (well designed) SMC syntax we need a fully grown parser. If we use SCXML we can simply use a XML parser. Then we load the state machine dynamically in our application. Or we write or own backend to generate the FSM source code in our desired target language.

The funny thing about this all is that I wrote a proof-of-concept FSM generator in early 2008 which used a SCXML like XML dialect I designed. It wasn’t that complex, but enough to describe SDL State machines. I also wrote a export for Dia to translate SDL diagrams into my FSM XML Syntax. If I only known about SCXML before…

My motivation was to have a simple tool to easy decribe a FSM in my applications without the need to use a complex SDL or UML tool chain. While you can implement your state machines with simple switch (state) {} statements, it’s easier to have a specialized tool for this that allows you to easily modify the states as well as to generate a graphical representation of the state machine (e.g. with GraphViz ).

How did I found SCXML? Well, I came across the Qt SCXML Engine .

posted at: 09:05 | path: /development | permanent link to this entry