Skip to content

Commit 1bab916

Browse files
committed
docs/applications/smf: added state machine framework example documentation
Update Doc - WIP SFM doc updated - WIP Finished first documentation release
1 parent 9a9a93c commit 1bab916

File tree

4 files changed

+626
-0
lines changed

4 files changed

+626
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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_APPS_SMF`` – Enable the State Machine Framework support.
23+
- ``CONFIG_SMF_ANCESTOR_SUPPORT`` – Enable ancestor/parent state support.
24+
- ``CONFIG_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+
31+
Usage
32+
=====
33+
34+
The demo registers the ``hsm_psicc2`` NSH command (configurable via
35+
``CONFIG_EXAMPLES_SMF_PROGNAME``):
36+
37+
.. code-block:: bash
38+
39+
hsm_psicc2 start
40+
hsm_psicc2 event <A..I>
41+
hsm_psicc2 terminate
42+
43+
- ``start`` spawns the state machine thread and initializes the SMF context.
44+
- ``event <A..I>`` sends events A through I to the state machine (PSiCC2
45+
Figure 2.11).
46+
- ``terminate`` stops the state machine thread; there is no way to restart it
47+
and further events are not processed.
48+
49+
Comparison to PSiCC2 Output
50+
===========================
51+
52+
Not all transitions modeled in UML may be supported by the State Machine
53+
Framework. Unsupported transitions may lead to results different from the
54+
example run in PSiCC2 Section 2.3.15. The differences are not listed here since
55+
it is hoped SMF will support these transitions in the future and the list would
56+
become outdated.
21.1 KB
Loading
31.6 KB
Loading

0 commit comments

Comments
 (0)