Skip to content

Commit 40a1e5f

Browse files
committed
7.3.1
1 parent 36e407d commit 40a1e5f

File tree

14 files changed

+290
-64
lines changed

14 files changed

+290
-64
lines changed

examples/qutest/qhsmtst/src/qhsmtst.cpp

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
#include "qpcpp.hpp"
3232
#include "qhsmtst.hpp"
3333

34+
namespace {
35+
Q_DEFINE_THIS_FILE
36+
}
37+
3438
namespace APP {
3539

3640
//$declare${SMs::QHsmTst} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
@@ -40,6 +44,9 @@ class QHsmTst : public QP::QHsm {
4044
private:
4145
bool m_foo;
4246

47+
public:
48+
friend bool QHsmTst_isIn(std::uint32_t const state_num);
49+
4350
public:
4451
QHsmTst()
4552
: QHsm(&initial)
@@ -63,8 +70,8 @@ QP::QAsm * const the_sm = &l_hsmtst; // the opaque pointer
6370

6471
//$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
6572
// Check for the minimum required QP version
66-
#if (QP_VERSION < 700U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
67-
#error qpcpp version 7.0.0 or higher required
73+
#if (QP_VERSION < 730U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
74+
#error qpcpp version 7.3.0 or higher required
6875
#endif
6976
//$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7077

@@ -418,4 +425,32 @@ Q_STATE_DEF(QHsmTst, s211) {
418425
}
419426
//$enddef${SMs::QHsmTst} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
420427

428+
bool QHsmTst_isIn(std::uint32_t const state_num) {
429+
QP::QHsm * const me = &l_hsmtst;
430+
bool stat = false;
431+
switch (state_num) {
432+
case 0:
433+
stat = me->isIn(Q_STATE_CAST(&QHsmTst::s));
434+
break;
435+
case 1:
436+
stat = me->isIn(Q_STATE_CAST(&QHsmTst::s1));
437+
break;
438+
case 11:
439+
stat = me->isIn(Q_STATE_CAST(&QHsmTst::s11));
440+
break;
441+
case 2:
442+
stat = me->isIn(Q_STATE_CAST(&QHsmTst::s2));
443+
break;
444+
case 21:
445+
stat = me->isIn(Q_STATE_CAST(&QHsmTst::s21));
446+
break;
447+
case 211:
448+
stat = me->isIn(Q_STATE_CAST(&QHsmTst::s211));
449+
break;
450+
default:
451+
Q_ERROR();
452+
}
453+
return stat;
454+
}
455+
421456
} // namespace APP

examples/qutest/qhsmtst/src/qhsmtst.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ enum QHsmTstSignals {
5050

5151
extern QP::QAsm * const the_sm; // opaque pointer to the test SM
5252

53+
bool QHsmTst_isIn(std::uint32_t const state_num);
54+
5355
// BSP functions to display a message and exit
5456
void BSP_display(char const *msg);
5557
void BSP_terminate(int16_t const result);

examples/qutest/qhsmtst/src/qhsmtst.qm

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
<documentation>Test active object</documentation>
1111
<!--${SMs::QHsmTst::m_foo}-->
1212
<attribute name="m_foo" type="bool" visibility="0x02" properties="0x00"/>
13+
<!--${SMs::QHsmTst::bool QHsmTst_isIn(std::uint32_t ~}-->
14+
<attribute name="bool QHsmTst_isIn(std::uint32_t const state_num);" type="friend" visibility="0x04" properties="0x00"/>
1315
<!--${SMs::QHsmTst::QHsmTst}-->
1416
<operation name="QHsmTst" type="" visibility="0x00" properties="0x02">
1517
<code> : QHsm(&amp;initial)</code>
@@ -321,6 +323,8 @@ enum QHsmTstSignals {
321323

322324
extern QP::QAsm * const the_sm; // opaque pointer to the test SM
323325

326+
bool QHsmTst_isIn(std::uint32_t const state_num);
327+
324328
// BSP functions to display a message and exit
325329
void BSP_display(char const *msg);
326330
void BSP_terminate(int16_t const result);
@@ -334,6 +338,10 @@ void BSP_terminate(int16_t const result);
334338
<text>#include &quot;qpcpp.hpp&quot;
335339
#include &quot;qhsmtst.hpp&quot;
336340

341+
namespace {
342+
Q_DEFINE_THIS_FILE
343+
}
344+
337345
namespace APP {
338346

339347
$declare ${SMs::QHsmTst}
@@ -345,6 +353,34 @@ QP::QAsm * const the_sm = &amp;l_hsmtst; // the opaque pointer
345353

346354
$define ${SMs::QHsmTst}
347355

356+
bool QHsmTst_isIn(std::uint32_t const state_num) {
357+
QP::QHsm * const me = &amp;l_hsmtst;
358+
bool stat = false;
359+
switch (state_num) {
360+
case 0:
361+
stat = me-&gt;isIn(Q_STATE_CAST(&amp;QHsmTst::s));
362+
break;
363+
case 1:
364+
stat = me-&gt;isIn(Q_STATE_CAST(&amp;QHsmTst::s1));
365+
break;
366+
case 11:
367+
stat = me-&gt;isIn(Q_STATE_CAST(&amp;QHsmTst::s11));
368+
break;
369+
case 2:
370+
stat = me-&gt;isIn(Q_STATE_CAST(&amp;QHsmTst::s2));
371+
break;
372+
case 21:
373+
stat = me-&gt;isIn(Q_STATE_CAST(&amp;QHsmTst::s21));
374+
break;
375+
case 211:
376+
stat = me-&gt;isIn(Q_STATE_CAST(&amp;QHsmTst::s211));
377+
break;
378+
default:
379+
Q_ERROR();
380+
}
381+
return stat;
382+
}
383+
348384
} // namespace APP</text>
349385
</file>
350386
</directory>

examples/qutest/qhsmtst/test/test_qhsm-funct.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ def on_reset():
1818
expect("@timestamp BSP_DISPLAY s211-ENTRY;")
1919
expect("@timestamp Trg-Done QS_RX_EVENT")
2020

21+
test("QHsmTst isIn", NORESET)
22+
command(1, 1)
23+
expect("@timestamp CMD 0 1");
24+
expect("@timestamp Trg-Done QS_RX_COMMAND")
25+
command(1, 21)
26+
expect("@timestamp CMD 1 21");
27+
expect("@timestamp Trg-Done QS_RX_COMMAND")
28+
command(1, 211)
29+
expect("@timestamp CMD 1 211");
30+
expect("@timestamp Trg-Done QS_RX_COMMAND")
31+
2132
test("QHsmTst dispatch", NORESET)
2233
dispatch("A_SIG")
2334
expect("@timestamp BSP_DISPLAY s21-A;")

examples/qutest/qhsmtst/test/test_qhsm.cpp

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//============================================================================
22
// Purpose: Fixture for QUTEST
3-
// Last updated for version 7.3.0
4-
// Last updated on 2023-07-26
3+
// Last Updated for Version: 7.3.1
4+
// Date of the Last Update: 2023-12-11
55
//
6-
// Q u a n t u m L e a P s
7-
// ------------------------
8-
// Modern Embedded Software
6+
// Q u a n t u m L e a P s
7+
// ------------------------
8+
// Modern Embedded Software
99
//
10-
// Copyright (C) 2005-2020 Quantum Leaps. All rights reserved.
10+
// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
1111
//
1212
// This program is open source software: you can redistribute it and/or
1313
// modify it under the terms of the GNU General Public License as published
@@ -25,10 +25,11 @@
2525
// GNU General Public License for more details.
2626
//
2727
// You should have received a copy of the GNU General Public License
28-
// along with this program. If not, see <www.gnu.org/licenses>.
28+
// along with this program. If not, see <www.gnu.org/licenses/>.
2929
//
3030
// Contact information:
3131
// <www.state-machine.com/licensing>
32+
3233
//============================================================================
3334
#include "qpcpp.hpp"
3435
#include "qhsmtst.hpp"
@@ -40,10 +41,11 @@ namespace APP {
4041

4142
enum {
4243
BSP_DISPLAY = QP::QS_USER,
44+
CMD,
4345
};
4446

4547
void BSP_display(char const *msg) {
46-
QS_BEGIN_ID(BSP_DISPLAY, 0U) // application-specific record
48+
QS_BEGIN_ID(BSP_DISPLAY, 0U) // app-specific record
4749
QS_STR(msg);
4850
QS_END()
4951
}
@@ -64,21 +66,33 @@ void QS::onTestSetup(void) {
6466
void QS::onTestTeardown(void) {
6567
}
6668
//............................................................................
67-
void QS::onCommand(uint8_t cmdId,
68-
uint32_t param1, uint32_t param2, uint32_t param3)
69+
void QS::onCommand(std::uint8_t cmdId, std::uint32_t param1,
70+
std::uint32_t param2, std::uint32_t param3)
6971
{
7072
Q_UNUSED_PAR(param1);
7173
Q_UNUSED_PAR(param2);
7274
Q_UNUSED_PAR(param3);
7375

76+
//PRINTF_S("<TARGET> Command id=%d param=%d\n", (int)cmdId, (int)param);
7477
switch (cmdId) {
75-
case 0U: {
76-
break;
78+
case 0U: {
79+
QS_BEGIN_ID(APP::CMD, 0U) // app-specific record
80+
QS_END()
81+
break;
82+
}
83+
case 1U: {
84+
bool ret = APP::QHsmTst_isIn(param1);
85+
QS_BEGIN_ID(APP::CMD, 0U) // app-specific record
86+
QS_U8(0U, ret ? 1 : 0);
87+
QS_U8(0U, (uint8_t)param1);
88+
QS_END()
89+
break;
7790
}
7891
default:
7992
break;
8093
}
8194
}
95+
8296
//............................................................................
8397
// callback function to "massage" the event, if necessary
8498
void QS::onTestEvt(QEvt *e) {
@@ -119,6 +133,7 @@ int main(int argc, char *argv[]) {
119133
// dictionaries...
120134
QS_OBJ_DICTIONARY(the_sm);
121135
QS_USR_DICTIONARY(BSP_DISPLAY);
136+
QS_USR_DICTIONARY(CMD);
122137

123138
return QP::QF::run();
124139
}

examples/qutest/qmsmtst/src/qmsmtst.cpp

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
#include "qpcpp.hpp"
3232
#include "qmsmtst.hpp"
3333

34+
namespace {
35+
Q_DEFINE_THIS_FILE
36+
}
37+
3438
namespace APP {
3539

3640
//$declare${SMs::QMsmTst} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
@@ -40,6 +44,9 @@ class QMsmTst : public QP::QMsm {
4044
private:
4145
bool m_foo;
4246

47+
public:
48+
friend bool QMsmTst_isInState(std::uint32_t const state_num);
49+
4350
public:
4451
QMsmTst()
4552
: QMsm(&initial)
@@ -72,15 +79,15 @@ class QMsmTst : public QP::QMsm {
7279
}; // class QMsmTst
7380
//$enddecl${SMs::QMsmTst} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7481

75-
static QMsmTst l_hsmtst; // the only instance of the QMsmTst class
82+
static QMsmTst l_msmtst; // the only instance of the QMsmTst class
7683

7784
// global-scope definitions -----------------------------------------
78-
QP::QAsm * const the_sm = &l_hsmtst; // the opaque pointer
85+
QP::QAsm * const the_sm = &l_msmtst; // the opaque pointer
7986

8087
//$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
8188
// Check for the minimum required QP version
82-
#if (QP_VERSION < 700U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
83-
#error qpcpp version 7.0.0 or higher required
89+
#if (QP_VERSION < 730U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
90+
#error qpcpp version 7.3.0 or higher required
8491
#endif
8592
//$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8693

@@ -734,4 +741,32 @@ QM_STATE_DEF(QMsmTst, s211) {
734741
}
735742
//$enddef${SMs::QMsmTst} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
736743

744+
bool QMsmTst_isInState(std::uint32_t const state_num) {
745+
QP::QMsm * const me = &l_msmtst;
746+
bool stat = false;
747+
switch (state_num) {
748+
case 0:
749+
stat = me->isInState(&QMsmTst::s_s);
750+
break;
751+
case 1:
752+
stat = me->isInState(&QMsmTst::s1_s);
753+
break;
754+
case 11:
755+
stat = me->isInState(&QMsmTst::s11_s);
756+
break;
757+
case 2:
758+
stat = me->isInState(&QMsmTst::s21_s);
759+
break;
760+
case 21:
761+
stat = me->isInState(&QMsmTst::s21_s);
762+
break;
763+
case 211:
764+
stat = me->isInState(&QMsmTst::s211_s);
765+
break;
766+
default:
767+
Q_ERROR();
768+
}
769+
return stat;
770+
}
771+
737772
} // namespace APP

examples/qutest/qmsmtst/src/qmsmtst.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ enum QMsmTstSignals {
5050

5151
extern QP::QAsm * const the_sm; // opaque pointer to the test SM
5252

53+
bool QMsmTst_isInState(std::uint32_t const state_num);
54+
5355
// BSP functions to display a message and exit
5456
void BSP_display(char const *msg);
5557
void BSP_terminate(int16_t const result);

0 commit comments

Comments
 (0)