mirror of
https://github.com/QuantumLeaps/qpcpp.git
synced 2025-01-14 05:42:57 +08:00
137 lines
6.7 KiB
Plaintext
137 lines
6.7 KiB
Plaintext
/*! @page exa_os Examples for Workstations (Windows/POSIX)
|
|
|
|
@tableofcontents
|
|
|
|
<p>The examples in the <span class="img folder">qpcpp/examples/workstation</span> directory are designed for workstations (running Windows, Linux, or MacOS). Currently, the following examples are provided:
|
|
</p>
|
|
|
|
- <span class="img folder">blinky</span> — Simple "Blinky" active object (command-line)
|
|
- <span class="img folder">calc</span> — Calculator example from Chapter 2 of [PSiCC2](https://www.state-machine.com/psicc2)
|
|
- <span class="img folder">calc1</span> — Improved Calculator example from Chapter 2 of [PSiCC2](https://www.state-machine.com/psicc2)
|
|
- <span class="img folder">calc1_sub</span> — Calculator example with sub-machines
|
|
- <span class="img folder">comp</span> — Orthogonal Component design pattern
|
|
- <span class="img folder">defer</span> — Deferred Event design pattern
|
|
- <span class="img folder">dpp</span> — DPP application from Chapter 9 of [PSiCC2](https://www.state-machine.com/psicc2) (**Spy**)
|
|
- <span class="img folder">dpp_comp</span> — DPP with Orthogonal-Component pattern (**Spy**)
|
|
- <span class="img folder">dpp-gui</span> — DPP (with GUI on Windows) (**Spy**)
|
|
- <span class="img folder">game-gui</span> — "Fly 'n' Shoot" game from Chapter 1 of [PSiCC2](https://www.state-machine.com/psicc2) (**Spy**)
|
|
- <span class="img folder">history_qhsm</span> — Transition-to-History (with ::QHsm class)
|
|
- <span class="img folder">history_qmsm</span> — Transition-to-History (with ::QMsm class)
|
|
- <span class="img folder">qhsmtst</span> — Test State Machine based on ::QHsm from Chapter 2 of [PSiCC2](https://www.state-machine.com/psicc2) (**Spy**)
|
|
- <span class="img folder">qmsmtst</span> — Test State Machine based on ::QMsm (**Spy**)
|
|
- <span class="img folder">reminder</span> — Reminder design pattern from Chapter 5 of PSiCC2
|
|
- <span class="img folder">reminder2</span> — Reminder design pattern different version
|
|
|
|
@remark
|
|
The examples marked with (**Spy**) provide the @ref exa_os-spy "Spy Configuration".
|
|
|
|
|
|
------------------------------------------------------------------------------
|
|
@section exa_win_posix Windows and POSIX Workstations
|
|
All examples in the <span class="img folder">qpcpp/examples/workstation</span> 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:
|
|
|
|
- On Windows — @ref win32 "win32" or @ref win32-qv "win32-qv"; and
|
|
- On POSIX — @ref posix "posix" or @ref posix-qv "posix-qv" (Linux, MacOS, etc.)
|
|
|
|
@note
|
|
On Windows, the **make** utility and the GNU GCC toolchain (**MinGW**) are provided in the [<b>QTools collection</b>](https://www.state-machine.com/qtools), 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.
|
|
|
|
|
|
@n
|
|
![Blinky example on Windows (QP linked from a library)](blinky_win.png)
|
|
@n
|
|
![Blinky example on Linux (QP built from sources)](blinky_posix.png)
|
|
|
|
|
|
------------------------------------------------------------------------------
|
|
@section exa_os-qv Single-Threaded and Multi-Threaded QP/C++ Ports
|
|
Each of the examples can be linked to either the single-threaded QP/C++ ports (@ref win32-qv or @ref posix-qv) or multi-threaded ports (@ref win32 or @ref 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 @ref win32-qv port and leave the @ref win32 port commented-out:
|
|
|
|
@code
|
|
QP_PORT_DIR := $(QPC)/ports/win32-qv
|
|
#QP_PORT_DIR := $(QPC)/ports/win32
|
|
@endcode
|
|
|
|
To reverse the selection, you need to move the comment `#` character.
|
|
|
|
@remarks
|
|
The single-threaded QP/C++ ports (@ref win32-qv "win32-qv" and @ref posix-qv "posix-qv") are recommended for **emulating** software intended for deeply-embedded targets ("dual-targeting" the embedded software development).@n
|
|
|
|
|
|
@attention
|
|
Examples in the <span class="img folder">workstation</span> 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** @ref ports_os "QP ports" ( @ref posix "posix" and @ref win32 "win32", respectively) are recommended.
|
|
|
|
|
|
------------------------------------------------------------------------------
|
|
@section exa_os_conf Debug, Release, and Spy Build Configurations
|
|
The `Makefiles` for the examples generally support the following three build configurations.
|
|
|
|
|
|
<div class="separate"></div>
|
|
@subsection exa_os-dbg Debug Configuration
|
|
This is the default build configuration, with full debugging information and minimal optimization. To build this configuration, type:
|
|
|
|
@code
|
|
make
|
|
@endcode
|
|
|
|
To clean this build, type
|
|
|
|
@code
|
|
make clean
|
|
@endcode
|
|
|
|
The object files and the executable is located in the <span class="img folder">build</span> sub-directory.
|
|
|
|
|
|
<div class="separate"></div>
|
|
@subsection exa_os-rel 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:
|
|
|
|
@code
|
|
make CONF=rel
|
|
@endcode
|
|
|
|
To clean this build, type
|
|
|
|
@code
|
|
make CONF=rel clean
|
|
@endcode
|
|
|
|
The object files and the executable is located in the <span class="img folder">build_rel</span> directory.
|
|
|
|
|
|
<div class="separate"></div>
|
|
@subsection exa_os-spy 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:
|
|
|
|
@code
|
|
make CONF=spy
|
|
@endcode
|
|
|
|
To clean this build, type
|
|
|
|
@code
|
|
make CONF=spy clean
|
|
@endcode
|
|
|
|
The object files and the executable are located in the <span class="img folder">build_spy</span> sub-directory.
|
|
|
|
@note
|
|
The Spy build configuration requires launching the [QSPY host utility](https://www.state-machine.com/qtools/qspy.html) 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.
|
|
|
|
|
|
@remark
|
|
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.
|
|
|
|
|
|
@n
|
|
![DPP with QSPY example on Windows (QSPY running in a separate command-prompt)](dpp_win.png)
|
|
@n
|
|
![DPP with QSPY example on Linux (QSPY running in a separate terminal)](dpp_posix.png)
|
|
|
|
|
|
@next{exa_mware}
|
|
*/
|