Search Notebooks
Graphical Modeling and Automatic Code Generation (qm_pelican Example)

QM is a free graphical modeling UML tool for designing and implementing real-time embedded applications based on the QP state machine framework. This notebook page shows how to use QM to generate code for mbed.

code generation, fee tool, modeling, QM, State Machine, uml

Page owner: user Quantum Leaps

Created 15 Feb 2011.
Last updated 26 Sep 2011

Graphical Modeling and Automatic Code Generation (qm_pelican Example)

Page last updated 26 Sep 2011, by   user Quantum Leaps   tag code generation, fee tool, modeling, QM, State Machine, uml | 7 replies  

The qm_pelican example demonstrates automatic code generation from a graphical model of the software. The example contains code that is 100% generated by the free QM graphical modeling tool.

The screen shot below shows a view of the PELICAN crossing model opened in the QM tool (click on the picture to see higher resolution).

PELICAN crossing model in QM

Downloading and Installing QM

The QM tool is available for a free download, without the need for registration or relinquishing any personal information from state-machine.com/downloads. Please select the download for your platform (Windows, Linux, and Mac OS X are supported). The installation on any platform is trivial and does not require any DLLs, sharable libraries or any other third party software (no Java, Eclipse, etc.). The provided setup installs the QM application, creates a desktop icon, and associates the QM model files (*.qm) with the QM application. QM is very easy to uninstall with the provided uninstaller.

Downloading the PELICAN Crossing Model

Downloading the QM model

Please right-click on the link below and and select "Save link as..." option to save the pelican.qm model file to your computer.

QM model for the PELICAN crossing

To view the model, assuming that you have installed the QM tool, you can just double-click on the pelican.qm model file, or you can launch the QM tool first and then open the model from the File|Open menu command. Please note that the QM user interface is highly customizable, so your screen might look a little differently than the screen shot above. But you can always re-arrange the docking windows to suit best your particular taste and the tool will remember your layout for the future.

Generating the Code

Code generation is literally accomplished by pressing a single button (the "Code Generation" button, 4th from the left in the screen shot above). Once you press the button, the QM tool will show the model compilation log. This particular model is setup to generate the code in the same directory as the pelican.qm model file.

Executing the Code

Once the code is generated, you simply import the code as a program to the mbed compiler. The code should compile cleanly. You execute the synthesized program just as any hand-crafted mbed program.

More Information

Please visit state-machine.com/qm for more information.


7 comments on Graphical Modeling and Automatic Code Generation (qm_pelican Example):

31 May 2011

mbed compiler produces error

"Cannot open source input file "qp_port.h": No such file or directory

In every qp, related project I imported.

The same with code (7 files but missing qp_port.h) for Pelican project I created form QM as described above

Please advise.

SOLVED, Have to import qm library to all qm projects. It is not mentioned above..

Nikos Chalikias

25 Sep 2011

The pelican.qm model file has been updated for the latest QM version 2.0.00.

QL

30 Oct 2011

HELP!

I have a QM program that uses multiple files. If I want to import the files into the online mbed compiler I have to manually click and select each file after manually deleting the individual old files that are in the mbed directory first. This is REALLY cumbersome, each QM compile-MBED compile-upload-run iteration costs me like 10 minutes. For me programming means a lot of iterations, so I can't work like this....

Does anyone know a solution? Otherwise I'm forced to ditch the mbed platform and pick something else...

31 Oct 2011

I really don't see an easy way of integrating QM with the online mbed compiler. The whole idea of the online compiler is that everything stays "in the cloud". This philosophy works fine for traditional coding, but does not take into account automatic generation of the source code. As soon as the source needs to be created outside "the cloud", you lose the whole advantage and, in fact, your life gets quite miserable.

The only solution I could see is if there were a method to *automatically* upload the source code to the mbed "cloud" and to obtain the executable image back.

31 Oct 2011

>> Otherwise I'm forced to ditch the mbed platform

using an off-line compiler comes to mind.

31 Oct 2011

maybe you can export the whole mbed project to your pc where it is stored as a zip file, unzip on the pc, overwrite the generated QM files (assuming they have the same names), zip the project again, rename the new zip file (eg by adding a number) and import that file as a new project in mbed.

BTW You can probably just drag the new QM files to the zip file in your windows explorer. No need to explicitly unzip/zip.

02 Jan 2012

Hi, is it possible to have a blinky example for mbed. been trying to test out the state machine with the blinky example, but there were many error. Thank you

Please login to post comments.