Skip to content

Commit 3367846

Browse files
committed
docs/applications/smf: added state machine framework example documentation
Update Doc - WIP SFM doc updated - WIP Finished first documentation release Update documentation after source code changes Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
1 parent 9a9a93c commit 3367846

File tree

4 files changed

+629
-0
lines changed

4 files changed

+629
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
==================================================
2+
``smf`` State Machine Framework HSM PSiCC2 Example
3+
==================================================
4+
5+
This example implements an event-driven hierarchical state machine using the
6+
State Machine Framework (SMF). It reproduces the statechart shown in Figure 2.11
7+
of Practical UML Statecharts in C/C++, 2nd Edition, by Miro Samek (PSiCC2).
8+
The ebook is available at https://www.state-machine.com/psicc2.
9+
10+
For each state, the entry, run, and exit actions are logged to the console, as
11+
well as logging when a state handles an event or explicitly ignores it and
12+
passes it up to the parent state.
13+
14+
It should be possible to build and run this demo on most boards or emulators
15+
that support NSH, SMF, and message queues.
16+
17+
Configuration
18+
=============
19+
20+
- ``CONFIG_EXAMPLES_SMF`` – Enables the SMF PSiCC2 demo.
21+
- ``CONFIG_NSH_BUILTIN_APPS`` – Build the demo as an NSH built-in application.
22+
- ``CONFIG_SYSTEM_SMF`` – Enable the State Machine Framework support.
23+
- ``CONFIG_SYSTEM_SMF_ANCESTOR_SUPPORT`` – Enable ancestor/parent state support.
24+
- ``CONFIG_SYSTEM_SMF_INITIAL_TRANSITION`` – Enable initial transition support.
25+
- ``CONFIG_DISABLE_MQUEUE=n`` – Message queue support must be available.
26+
- ``CONFIG_EXAMPLES_SMF_PROGNAME`` – Program name, default ``hsm_psicc2``.
27+
- ``CONFIG_EXAMPLES_SMF_PRIORITY`` – Priority of the SMF task, default ``100``.
28+
- ``CONFIG_EXAMPLES_SMF_STACKSIZE`` – Stack size of the SMF task, default
29+
``2048``.
30+
- ``CONFIG_EXAMPLES_SMF_QUEUE_SIZE`` – Size of the message queue, default ``10``.
31+
- ``CONFIG_EXAMPLES_SMF_MQ_NAME`` – Name of the message queue, default
32+
``/hsm_psicc2_mq``.
33+
34+
Usage
35+
=====
36+
37+
The demo registers the ``hsm_psicc2`` NSH command (configurable via
38+
``CONFIG_EXAMPLES_SMF_PROGNAME``):
39+
40+
.. code-block:: bash
41+
42+
hsm_psicc2 start
43+
hsm_psicc2 event <A..I>
44+
hsm_psicc2 terminate
45+
46+
- ``start`` spawns the state machine thread and initializes the SMF context.
47+
- ``event <A..I>`` sends events A through I to the state machine (PSiCC2
48+
Figure 2.11).
49+
- ``terminate`` stops the state machine thread; there is no way to restart it
50+
and further events are not processed.
51+
52+
Comparison to PSiCC2 Output
53+
===========================
54+
55+
Not all transitions modeled in UML may be supported by the State Machine
56+
Framework. Unsupported transitions may lead to results different from the
57+
example run in PSiCC2 Section 2.3.15. The differences are not listed here since
58+
it is hoped SMF will support these transitions in the future and the list would
59+
become outdated.
21.1 KB
Loading
31.6 KB
Loading

0 commit comments

Comments
 (0)