QP/C  6.3.7
Examples for Workstations (Windows/POSIX)

The examples in the qpc/examples/workstation directory are designed for workstations (running Windows, Linux, or MacOS). Currently, the following examples are provided:

  • blinky — Simple "Blinky" active object (command-line)
  • calc — Calculator example from Chapter 2 of PSiCC2
  • calc1 — Improved Calculator example from Chapter 2 of PSiCC2
  • calc1_sub — Calculator example with sub-machines
  • comp — Orthogonal Component design pattern
  • defer — Deferred Event design pattern
  • dpp — DPP application from Chapter 9 of PSiCC2 (Spy)
  • dpp_comp — DPP with Orthogonal-Component pattern (Spy)
  • dpp-gui — DPP (with GUI on Windows) (Spy)
  • game-gui — "Fly 'n' Shoot" game from Chapter 1 of PSiCC2 (Spy)
  • history_qhsm — Transition-to-History (with QHsm class)
  • history_qmsm — Transition-to-History (with QMsm class)
  • qhsmtst — Test State Machine based on QHsm from Chapter 2 of PSiCC2 (Spy)
  • qmsmtst — Test State Machine based on QMsm (Spy)
  • reminder — Reminder design pattern from Chapter 5 of PSiCC2
  • reminder2 — Reminder design pattern different version
Remarks
The examples marked with (Spy) provide the Spy Configuration.

Windows and POSIX Workstations

All examples in the qpc/examples/workstation directory work both on Windows as well as on POSIX (Linux, MacOS). On each of these operating systems you use the same cross-platform Makefile co-located with each example. The provided cross-platform Makefiles assume the GNU GCC toolchain. The Makefile discovers the host operating system and chooses the appropriate QP port version:

Note
On Windows, the make utility and the GNU GCC toolchain (MinGW) are provided in the QTools collection, which is available for a separate download. The code can be also built with other tools as well, such as the Microsoft Visual Studio 2013 and newer.


blinky_win.png
Blinky example on Windows (QP linked from a library)


blinky_posix.png
Blinky example on Linux (QP built from sources)

Single-Threaded and Multi-Threaded QP/C Ports

Each of the examples can be linked to either the single-threaded QP/C ports (Win32-QV (Windows with QV) or POSIX-QV) or multi-threaded ports (Win32 API (Windows) or POSIX). The choice is made in the Makefiles, by editing the line, which defines the QP_PORT_DIR symbol. For instance, the following lines select the Win32-QV (Windows with QV) port and leave the Win32 API (Windows) port commented-out:

QP_PORT_DIR := $(QPC)/ports/win32-qv
#QP_PORT_DIR := $(QPC)/ports/win32

To reverse the selection, you need to move the comment # character.

Remarks
The single-threaded QP/C ports (win32-qv and posix-qv) are recommended for emulating software intended for deeply-embedded targets ("dual-targeting" the embedded software development).
Attention
Examples in the workstation directory can also be used on the embedded versions of the desktop operating systems, such as Embedded Linux and Windows Embedded. For the embedded applications, the multi-threaded QP ports ( posix and win32, respectively) are recommended.

Debug, Release, and Spy Build Configurations

The Makefiles for the examples generally support the following three build configurations.

Debug Configuration

This is the default build configuration, with full debugging information and minimal optimization. To build this configuration, type:

make

To clean this build, type

make clean

The object files and the executable is located in the build sub-directory.

Release Configuration

This configuration is built with no debugging information and high optimization. Single-stepping and debugging might be difficult due to the lack of debugging information and optimized code. To build this configuration, type:

make CONF=rel

To clean this build, type

make CONF=rel clean

The object files and the executable is located in the build_rel directory.

Spy Configuration

This configuration is built with the QP's Q-SPY trace functionality. The QP/Spy output is performed by a TCP/IP socket and requires launching the QSPY host application with the -t option. To build this configuration, type:

make CONF=spy

To clean this build, type

make CONF=spy clean

The object files and the executable are located in the build_spy sub-directory.

Note
The Spy build configuration requires launching the QSPY host utility with the -t command-line option before running the example. This is so that the example code can output the QS software tracing to the TCP/IP socket of QSPY.
Remarks
Only specific examples support the Spy build configuration. The examples that don't support it, will report an error or will fail the linking stage.


dpp_win.png
DPP with QSPY example on Windows (QSPY running in a separate command-prompt)


dpp_posix.png
DPP with QSPY example on Linux (QSPY running in a separate terminal)

Next: Third-Party Middleware