My project is about code generation from UML statecharts. Using Java and XSLT, I take the XMI that represents the statecharts, and generate a QHSM state machine in Java/C.
Confused? Sorry. I'll try to explain:
- Statecharts are a graphical representation of complex systems. They are based on finite state automata, but extend (and complicate) them greatly.
- UML is the Unified Modeling Language. It is a graphical language that allows software developers to describe their software designs in a visual way. Statecharts are a part of UML. There's a FAQ about UML here.
- XSLT is a language for transforming XML into other text, including other XML. Here's a tutorial.
- XMI (the XML Metadata Interchange) is a representation of UML data (and some other metadata) in XML format.
- QHSM is "Quantum Hierarchical State Machine", which is Miro Samek's implementation of a state machine (a state machine is an executable statechart). It is described in his book.
For implementing both Java and C code generation, I use something like Martin Fowler's Two Step View pattern (I was actually told that there exists such a pattern right after I suggested my approach, which I though to be original) - first, I create an XML pseudo-code state machine. Then I take this XML and turn it to either a Java or a C state machine.
It was fun, and I learn a lot, especially on XSLT and XML. I have more things to do for this project. Among them:
- Implement the C code generator - at the moment I only have a Java code generator, because that's the main priority of the company for which I develop the software.
- Build some king of testing tool, that can take events from a script file and fire them at a running machine.