QMsmTst is a contrived state machine from Chapter 2 of the PSiCC2 book for testing all possible transition topologies with up to 4-levels of state nesting.
NOTE: This example uses only the "QEP" component of the QP/C++ framework.
{
A_SIG = QP::Q_USER_SIG,
B_SIG,
C_SIG,
D_SIG,
E_SIG,
F_SIG,
G_SIG,
H_SIG,
I_SIG,
TERMINATE_SIG,
IGNORE_SIG,
MAX_SIG
};
opaque pointer to the test SM
= &QMsmTst::inst;
Test active object
: QMsm(&initial)
Q_UNUSED_PAR(e);
m_foo = 0U;
BSP_display("top-INIT;");
QS_SIG_DICTIONARY(A_SIG, nullptr);
QS_SIG_DICTIONARY(B_SIG, nullptr);
QS_SIG_DICTIONARY(C_SIG, nullptr);
QS_SIG_DICTIONARY(D_SIG, nullptr);
QS_SIG_DICTIONARY(E_SIG, nullptr);
QS_SIG_DICTIONARY(F_SIG, nullptr);
QS_SIG_DICTIONARY(G_SIG, nullptr);
QS_SIG_DICTIONARY(H_SIG, nullptr);
QS_SIG_DICTIONARY(I_SIG, nullptr);
QS_SIG_DICTIONARY(TERMINATE_SIG, nullptr);
QS_SIG_DICTIONARY(IGNORE_SIG, nullptr);
BSP_display("s-ENTRY;");
BSP_display("s-EXIT;");
BSP_display("s-INIT;");
m_foo
m_foo = 0U;
BSP_display("s-I;");
BSP_display("s-E;");
BSP_terminate(0);
BSP_display("s1-ENTRY;");
BSP_display("s1-EXIT;");
BSP_display("s1-INIT;");
BSP_display("s1-I;");
!m_foo
m_foo = true;
BSP_display("s1-D;");
BSP_display("s1-A;");
BSP_display("s1-B;");
BSP_display("s1-F;");
BSP_display("s1-C;");
BSP_display("s11-ENTRY;");
BSP_display("s11-EXIT;");
BSP_display("s11-H;");
m_foo
m_foo = false;
BSP_display("s11-D;");
BSP_display("s11-G;");
BSP_display("s2-ENTRY;");
BSP_display("s2-EXIT;");
BSP_display("s2-INIT;");
!m_foo
m_foo = true;
BSP_display("s2-I;");
BSP_display("s2-F;");
BSP_display("s2-C;");
BSP_display("s21-ENTRY;");
BSP_display("s21-EXIT;");
BSP_display("s21-INIT;");
BSP_display("s21-G;");
BSP_display("s21-A;");
BSP_display("s21-B;");
BSP_display("s211-ENTRY;");
BSP_display("s211-EXIT;");
BSP_display("s211-H;");
BSP_display("s211-D;");
#ifndef QMSMTST_HPP_
#define QMSMTST_HPP_
$declare ${Shared}
#endif // QMSMTST_HPP_
#include "qpcpp.hpp" // QP/C++ framework
#include "qmsmtst.hpp" // QMsmTst state machine
$declare ${SMs::QMsmTst}
$define ${Shared::the_sm}
$define ${SMs::QMsmTst}