QM  4.1.1
Model Examples

QM™ model examples and projects for ARM Cortex-M, POSIX (Linux, Embedded Linux), and Windows (including QWIN GUI Kit for Prototyping Embedded Systems on Windows ) are included in the QP™ Baseline Distributions available for download from SourceForge.net.

Specifically:


Finding the QM™ Examples in the QP™ Distribution

The following directory chart shows QM™ example models and projects in the QP/C Baseline Distribution (version 5.4.0 or newer). The QP/C++ and QP-nano Baseline Distributions have a similar structure.

Note
Starting with QP release 5.4.0, all available ports and examples are bundled into the QP downloads, as opposed to being distributed as separate QP Development Kits (QDKs).
qpc/                - QP installation folder
+-examples/
| +-win32/          - examples for Windows PC
| | +-blinky/       - Blinky example ======================================++
| | +-dpp-gui/      - Dining Philosophers Problem (DPP) with GUI =====++   ||
| | +-game-gui/     - "Fly 'n' Shoot" game example with GUI =====++   ||   ||
| |                                                              ||   ||   ||
| +-arm-cm/         - examples for ARM Cortex-M                  ||   ||   ||
| | +-blinky_ek-tm4c123gxl/ - Blinky example for EK-TM4C123GXL   ||   ||   ||
| | | +-qk/         - examples for the preemptive QK kernel      ||   ||   ||
| | | | +-arm/      - ARM-Keil toolset                           ||   ||   ||
| | | | | +-dbg/    - debug build directory                      ||   ||   ||
| | | | | | +-blinky-qk.axf - Blinky image for debugging         ||   ||   ||
| | | | | | +-blinky-qk.bin - Blinky image for flash download    ||   ||   ||
| | | | | +-...                                                  ||   ||   ||
| | | | | +-blinky-qk.uvprojx - Keil uVision project             ||   ||   ||
| | | | | +...                                                   ||   ||   ||
| | | | +-gnu/      - GNU-ARM toolset                            ||   ||   ||
| | | | | +-dbg/    - debug build directory                      ||   ||   ||
| | | | | | +-blinky-qk.elf - Blinky image for debugging         ||   ||   ||
| | | | | | +-blinky-qk.bin - Blinky image for flash download    ||   ||   ||
| | | | | +-...                                                  ||   ||   ||
| | | | | +-Makefile  - makefile to build the project            ||   ||   ||
| | | | | +...                                                   ||   ||   ||
| | | | +-iar/      - IAR EWARM toolset                          ||   ||   ||
| | | | | +-dbg/    - debug build directory                      ||   ||   ||
| | | | | | +-blinky-qk.bin - Blinky image for flash download    ||   ||   ||
| | | | | +-...                                                  ||   ||   ||
| | | | | +-blinky-qk.ewp - IAR EW project                       ||   ||   ||
| | | | | +-blinky-qk.eww - IAR EW workspace                     ||   ||   ||
| | | | | +-...                                                  ||   ||   ||
| | | +-qv/         - examples for the cooperative QV kernel     ||   ||   ||
| | | | +-arm/      - ARM-Keil toolset                           ||   ||   ||
| | | | | +-dbg/    - debug build directory                      ||   ||   ||
| | | | | | +-blinky-qv.axf - Blinky image for debugging         ||   ||   ||
| | | | | | +-blinky-qv.bin - Blinky image for flash download    ||   ||   ||
| | | | | +-...                                                  ||   ||   ||
| | | | | +-blinky-qv.uvprojx - Keil uVision project             ||   ||   ||
| | | | | +...                                                   ||   ||   ||
| | | | +-gnu/      - GNU-ARM toolset                            ||   ||   ||
| | | | | +-dbg/    - debug build directory                      ||   ||   ||
| | | | | | +-blinky-qv.elf - Blinky image for debugging         ||   ||   ||
| | | | | | +-blinky-qv.bin - Blinky image for flash download    ||   ||   ||
| | | | | +-...                                                  ||   ||   ||
| | | | | +-Makefile  - makefile to build the project            ||   ||   ||
| | | | | +...                                                   ||   ||   ||
| | | | +-iar/      - IAR EWARM toolset                          ||   ||   ||
| | | | | +-dbg/    - debug build directory                      ||   ||   ||
| | | | | | +-blinky-qv.bin - Blinky image for flash download    ||   ||   ||
| | | | | +-...                                                  ||   ||   ||
| | | | | +-blinky-qv.ewp - IAR EW project                       ||   ||   ||
| | | | | +-blinky-qv.eww - IAR EW workspace                     ||   ||   ||
| | | | | +-...                                                  ||   ||   ||
| | | +-win32/      - examples for Windows (multithreded)   <=====|====|===++
| | | | +-dbg/      - debug build directory (MinGW)              ||   ||
| | | |   +-blinky.exe - Blinky executable                       ||   ||
| | | | +-Debug/    - debug build directory (Visual C++)         ||   ||
| | | | | +-blinky.exe - Blinky executable                       ||   ||
| | | | +-...                                                    ||   ||
| | | | +-Makefile  - makefile to build the project (MinGW)      ||   ||
| | | | +-dpp_gui.sln - Visual Studio solution file              ||   ||
| | | | +-dpp_gui.vcxproj - Visual Studio project file           ||   ||
| | | | +-...                                                    ||   ||
| | | +-win32-qv/   - examples for Windows (single-threaded)     ||   ||
| | | | +-...                                                    ||   ||
| | | | |                                                        ||   ||
| | +-dpp-qk_ek-tm4c123gxl/ - DPP example for EK-TM4C123GXL      ||   ||
| | | +-qk/         - examples for the preemptive QK kernel      ||   ||
| | | | +-arm/      - ARM-Keil toolset                           ||   ||
| | | | | +-...                                                  ||   ||
| | | | | +-dpp-qk.uvprojx - Keil uVision project                ||   ||
| | | | | +...                                                   ||   ||
| | | | +-gnu/      - examples for GNU-ARM                       ||   ||
| | | | | +-...                                                  ||   ||
| | | | | +-Makefile  - makefile to build the project            ||   ||
| | | | | +...                                                   ||   ||
| | | | +-iar/      - examples for the IAR EWARM                 ||   ||
| | | | | +-dpp-qk.ewp - IAR EW project                          ||   ||
| | | | | +-dpp-qk.eww - IAR EW workspace                        ||   ||
| | | | | +-...                                                  ||   ||
| | | +-qv/         - examples for the cooperative QV kernel     ||   ||
| | | | +-arm/      - ARM-Keil toolset                           ||   ||
| | | | | +-...                                                  ||   ||
| | | | | +-dpp-qv.uvprojx - Keil uVision project                ||   ||
| | | | | +...                                                   ||   ||
| | | | +-gnu/      - examples for GNU-ARM                       ||   ||
| | | | | +-...                                                  ||   ||
| | | | | +-Makefile  - makefile to build the project            ||   ||
| | | | | +...                                                   ||   ||
| | | | +-iar/      - examples for the IAR EWARM                 ||   ||
| | | | | +-dpp-qv.ewp - IAR EW project                          ||   ||
| | | | | +-dpp-qv.eww - IAR EW workspace                        ||   ||
| | | | | +-...                                                  ||   ||
| | | +-win32/      - examples for Windows (multithreded)   <=====|===++
| | | | +-dbg/      - debug build directory (MinGW)              ||
| | | |   +-dpp.exe - DPP executable                             ||
| | | | +-Debug/    - debug build directory (Visual C++)         ||
| | | | | +-dpp.exe - DPP executable                             ||
| | | | +-...                                                    ||
| | | | +-dpp.qm    - QM model  <=================               ||
| | | | +-Makefile  - makefile to build the project (MinGW)      ||
| | | | +-dpp_gui.sln - Visual Studio solution file              ||
| | | | +-dpp_gui.vcxproj - Visual Studio project file           ||
| | | | +-...                                                    ||
| | | +-win32-qv/   - examples for Windows (single-threaded)     ||
| | | | +-...                                                    ||
| | | | |                                                        ||
| | +-game_ek-lm3s811/ - "Fly 'n' Shoot" game for EK-LM3S811     ||
| | | +-qk/         - examples for the preemptive QK kernel      ||
| | | | +-arm/      - ARM-Keil toolset                           ||
| | | | +-gnu/      - examples for GNU-ARM                       ||
| | | | +-iar/      - examples for IAR EWARM                     ||
| | | +-qv/         - examples for the cooperative QV kernel     ||
| | | | +-arm/      - ARM-Keil toolset                           ||
| | | | +-gnu/      - examples for GNU-ARM                       ||
| | | | +-iar/      - examples for IAR EWARM                     ||
| | | +-win32/      - examples for Windows (multithreded) <======++
| | | | +-...

Example Models

Most QP™ example application contain the QM™ models (.qm) that you can open in the QM™ tool, explore, and modify. For example, the following screen shot shows the model game.qm opened in QM.

ex_game.png
Fly 'n' Shoot game model

Dining Philosopher Problem (DPP) Example

The Dining Philosopher Problem (DPP) application is used in most QP™ examples for various processors and operating systems. This example application is described in the Application Note "Dining Philosophers Problem (DPP) Example".

"Fly 'n' Shoot" Game Example

The "Fly 'n' Shoot" game example demonstrates several state machines (active objects) executing concurrently to realize a simple game. This example application is described in the Chapter 1 of the "Practical UML Statecharts in C/C++, 2nd Ed." book, which is available online in the book excerpts.


Running the Examples

All provided QM™ examples contain the per-built executables/images that you can immediately execute (on Windows/Linux) or download to the target board (EK-TM4C123GXL or EK-LM3S811 boards).

Windows

The examples for Windows come in two flavors: simple console applications and GUI simulations of an embedded board. Both types can be run by double-clicking on the executable (e.g., dpp.exe or game-gui.exe). You interact with the console applications by typing on your keyboard, whereas the legend of the recognized keys is displayed at the beginning of the run. The GUI simulations respond to mouse clicks and keyboard as described in the App Notes for the example applications.

dpp_win-gui.gif
DPP-GUI example on Windows


game_win-gui.gif
Game simulation on Windows

Linux

The examples for Linux are provided as simple console applications. You run them from the terminal window tying the name of the program. You interact with the console applications by typing on your keyboard, whereas the legend of the recognized keys is displayed at the beginning of the run.

ex_dpp_linux.jpg
DPP example in a Linux terminal

EK-TM4C123GXL and EK-LM3S811 (ARM Cortex-M)

The examples for the EK-TM4C123GXL and EK-LM3S811 boards are provided for the ARM-KEIL MDK, GNU-ARM (Sourcery CodeBench), and IAR EWARM toolsets. Free evaluation versions of all these toolsets are available for download from the respective websites. Pre-compiled images for flash download are provided in all example projects.

EK-TM4C123GXL.jpg
DPP on EK-TM4C123GXL


EK-LM3S811.jpg
Game on EK-LM3S811

Rebuilding the Examples

In order to rebuild the examples from source code you need to:

  • Install the baseline code of the QP framework type you want to use.
  • Install the ARM development toolset you want to use (ARM-KEL, GNU-ARM, or IAR).
  • Define an environment variable to point to the location of the QP baseline code (QPC for QP/C, QPCPP for QP/C++, and QPN for QP-nano).

For example, if you want to rebuild a QP/C example project, you need to download and install the QP/C baseline code and you need to define the environment variable QPC. Assuming that you have installed QP/C into the directory C:\qp\qpc, you should define the environment variable QPC to C:\qp\qpc.


Next: User Interface or alternatively
Next: Basic Modeling