Graphical Modeling and Automatic Code Generation
Large parts of the QP example qp_dpp have been automatically generated by the QM (QP Modeler) tool, which is a free, cross-platform, graphical UML modeling tool for designing and implementing real-time embedded applications based on the QP frameworks. QM provides best-in-class, intuitive state machine diagramming and generates very compact C or C++ code that is 100% traceable from your design. QM is available for Windows, Linux, and Mac OS X. The steps of obtaining the free QM tool and generating the code are described in the QL Notebook page "Graphical Modeling and Automatic Code Generation ".
The UML state machine diagrams below correspond to the Table state machine and Philosopher state machine in the Dining Philosopher Problem (DPP) model.
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 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 DPP Model
Unfortunately, the DPP model could not be included in the qp_dpp example program, where it belongs, because the mbed archive accepts only .h and .cpp source files. Therefore, you need to download the DPP model file separately, as described in the box below.
Downloading the QM model
Please right-click on the link below and and select "Save link as..." option to save the dpp.qm
model file to your computer.
To view the model, assuming that you have installed the QM tool, you can just double-click on the dpp.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 below. 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 toolbar button or the F7 keyboard shortcut (the "Code Generation" button in the Tools toolbar). The steps of code generation are show in the Log window. This particular model is setup to generate the code in the same directory as the dpp.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.
8 comments on Graphical Modeling and Automatic Code Generation:
Please log in to post comments.
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