Skip to content

Commit c2347e8

Browse files
committed
7.3.1
1 parent d4a08a1 commit c2347e8

File tree

15 files changed

+271
-57
lines changed

15 files changed

+271
-57
lines changed

examples/qutest/qhsmtst/src/qhsmtst.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include "qpc.h" // QP/C framework
3232
#include "qhsmtst.h" // this application
3333

34+
Q_DEFINE_THIS_FILE
35+
3436
//$declare${SMs::QHsmTst} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
3537

3638
//${SMs::QHsmTst} ............................................................
@@ -43,6 +45,7 @@ typedef struct QHsmTst {
4345

4446
// public:
4547
} QHsmTst;
48+
4649
extern QHsmTst QHsmTst_inst;
4750

4851
// protected:
@@ -74,6 +77,37 @@ void QHsmTst_ctor(void) {
7477
QHsm_ctor(&me->super, Q_STATE_CAST(&QHsmTst_initial));
7578
}
7679
//$enddef${Shared::QHsmTst_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
80+
//$define${Shared::QHsmTst_isIn} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
81+
82+
//${Shared::QHsmTst_isIn} ....................................................
83+
bool QHsmTst_isIn(uint32_t const state_num) {
84+
QHsm * const me = &QHsmTst_inst.super;
85+
bool stat = false;
86+
switch (state_num) {
87+
case 0:
88+
stat = QHsm_isIn(me, Q_STATE_CAST(&QHsmTst_s));
89+
break;
90+
case 1:
91+
stat = QHsm_isIn(me, Q_STATE_CAST(&QHsmTst_s1));
92+
break;
93+
case 11:
94+
stat = QHsm_isIn(me, Q_STATE_CAST(&QHsmTst_s11));
95+
break;
96+
case 2:
97+
stat = QHsm_isIn(me, Q_STATE_CAST(&QHsmTst_s2));
98+
break;
99+
case 21:
100+
stat = QHsm_isIn(me, Q_STATE_CAST(&QHsmTst_s21));
101+
break;
102+
case 211:
103+
stat = QHsm_isIn(me, Q_STATE_CAST(&QHsmTst_s211));
104+
break;
105+
default:
106+
Q_ERROR();
107+
}
108+
return stat;
109+
}
110+
//$enddef${Shared::QHsmTst_isIn} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
77111
//$define${SMs::QHsmTst} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
78112

79113
//${SMs::QHsmTst} ............................................................

examples/qutest/qhsmtst/src/qhsmtst.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,17 @@ enum QHsmTstSignals {
5252
//${Shared::the_sm} ..........................................................
5353
extern QAsm * const the_sm;
5454

55-
//${Shared::QHsmTst_ctor} ....................................................
56-
void QHsmTst_ctor(void);
57-
5855
//${Shared::BSP_display} .....................................................
5956
void BSP_display(char const * msg);
6057

6158
//${Shared::BSP_terminate} ...................................................
6259
void BSP_terminate(int16_t const result);
60+
61+
//${Shared::QHsmTst_ctor} ....................................................
62+
void QHsmTst_ctor(void);
63+
64+
//${Shared::QHsmTst_isIn} ....................................................
65+
bool QHsmTst_isIn(uint32_t const state_num);
6366
//$enddecl${Shared} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6467

6568
#endif // QHSMTST_H_

examples/qutest/qhsmtst/src/qhsmtst.qm

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@
2727
<documentation>opaque pointer to the test SM</documentation>
2828
<code>= &amp;QHsmTst_inst.super.super;</code>
2929
</attribute>
30-
<!--${Shared::QHsmTst_ctor}-->
31-
<operation name="QHsmTst_ctor" type="void" visibility="0x00" properties="0x00">
32-
<code>QHsmTst *me = &amp;QHsmTst_inst;
33-
QHsm_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;QHsmTst_initial));</code>
34-
</operation>
3530
<!--${Shared::BSP_display}-->
3631
<operation name="BSP_display" type="void" visibility="0x00" properties="0x00">
3732
<!--${Shared::BSP_display::msg}-->
@@ -42,6 +37,41 @@ QHsm_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;QHsmTst_initial));</code>
4237
<!--${Shared::BSP_terminate::result}-->
4338
<parameter name="result" type="int16_t const"/>
4439
</operation>
40+
<!--${Shared::QHsmTst_ctor}-->
41+
<operation name="QHsmTst_ctor" type="void" visibility="0x00" properties="0x00">
42+
<code>QHsmTst *me = &amp;QHsmTst_inst;
43+
QHsm_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;QHsmTst_initial));</code>
44+
</operation>
45+
<!--${Shared::QHsmTst_isIn}-->
46+
<operation name="QHsmTst_isIn" type="bool" visibility="0x00" properties="0x00">
47+
<!--${Shared::QHsmTst_isIn::state_num}-->
48+
<parameter name="state_num" type="uint32_t const"/>
49+
<code>QHsm * const me = &amp;QHsmTst_inst.super;
50+
bool stat = false;
51+
switch (state_num) {
52+
case 0:
53+
stat = QHsm_isIn(me, Q_STATE_CAST(&amp;QHsmTst_s));
54+
break;
55+
case 1:
56+
stat = QHsm_isIn(me, Q_STATE_CAST(&amp;QHsmTst_s1));
57+
break;
58+
case 11:
59+
stat = QHsm_isIn(me, Q_STATE_CAST(&amp;QHsmTst_s11));
60+
break;
61+
case 2:
62+
stat = QHsm_isIn(me, Q_STATE_CAST(&amp;QHsmTst_s2));
63+
break;
64+
case 21:
65+
stat = QHsm_isIn(me, Q_STATE_CAST(&amp;QHsmTst_s21));
66+
break;
67+
case 211:
68+
stat = QHsm_isIn(me, Q_STATE_CAST(&amp;QHsmTst_s211));
69+
break;
70+
default:
71+
Q_ERROR();
72+
}
73+
return stat;</code>
74+
</operation>
4575
</package>
4676
<!--${SMs}-->
4777
<package name="SMs" stereotype="0x02">
@@ -349,9 +379,12 @@ $declare ${Shared}
349379
<text>#include &quot;qpc.h&quot; // QP/C framework
350380
#include &quot;qhsmtst.h&quot; // this application
351381

382+
Q_DEFINE_THIS_FILE
383+
352384
$declare ${SMs::QHsmTst}
353385
$define ${Shared::the_sm}
354386
$define ${Shared::QHsmTst_ctor}
387+
$define ${Shared::QHsmTst_isIn}
355388
$define ${SMs::QHsmTst}</text>
356389
</file>
357390
</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.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//============================================================================
22
// Purpose: Fixture for QUTEST
3-
// Last Updated for Version: 7.3.0
4-
// Date of the Last Update: 2023-08-25
3+
// Last Updated for Version: 7.3.1
4+
// Date of the Last Update: 2023-12-11
55
//
66
// Q u a n t u m L e a P s
77
// ------------------------
@@ -38,6 +38,7 @@ Q_DEFINE_THIS_FILE
3838

3939
enum {
4040
BSP_DISPLAY = QS_USER,
41+
CMD,
4142
};
4243

4344
//----------------------------------------------------------------------------
@@ -56,6 +57,7 @@ int main(int argc, char *argv[]) {
5657
// dictionaries...
5758
QS_OBJ_DICTIONARY(the_sm);
5859
QS_USR_DICTIONARY(BSP_DISPLAY);
60+
QS_USR_DICTIONARY(CMD);
5961

6062
QHsmTst_ctor(); // instantiate the QHsmTst object
6163

@@ -89,8 +91,18 @@ void QS_onCommand(uint8_t cmdId,
8991

9092
//PRINTF_S("<TARGET> Command id=%d param=%d\n", (int)cmdId, (int)param);
9193
switch (cmdId) {
92-
case 0U: {
93-
break;
94+
case 0U: {
95+
QS_BEGIN_ID(CMD, 0U) // app-specific record
96+
QS_END()
97+
break;
98+
}
99+
case 1U: {
100+
bool ret = QHsmTst_isIn(param1);
101+
QS_BEGIN_ID(CMD, 0U) // app-specific record
102+
QS_U8(0U, ret ? 1 : 0);
103+
QS_U8(0U, (uint8_t)param1);
104+
QS_END()
105+
break;
94106
}
95107
default:
96108
break;

examples/qutest/qmsmtst/src/qmsmtst.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include "qpc.h" // QP/C framework
3232
#include "qmsmtst.h" // this application
3333

34+
Q_DEFINE_THIS_FILE
35+
3436
//$declare${SMs::QMsmTst} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
3537

3638
//${SMs::QMsmTst} ............................................................
@@ -43,6 +45,7 @@ typedef struct QMsmTst {
4345

4446
// public:
4547
} QMsmTst;
48+
4649
extern QMsmTst QMsmTst_inst;
4750

4851
// protected:
@@ -132,6 +135,37 @@ void QMsmTst_ctor(void) {
132135
QMsm_ctor(&me->super, Q_STATE_CAST(&QMsmTst_initial));
133136
}
134137
//$enddef${Shared::QMsmTst_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
138+
//$define${Shared::QMsmTst_isInState} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
139+
140+
//${Shared::QMsmTst_isInState} ...............................................
141+
bool QMsmTst_isInState(uint32_t const state_num) {
142+
QMsm * const me = &QMsmTst_inst.super;
143+
bool stat = false;
144+
switch (state_num) {
145+
case 0:
146+
stat = QMsm_isInState(me, &QMsmTst_s_s);
147+
break;
148+
case 1:
149+
stat = QMsm_isInState(me, &QMsmTst_s1_s);
150+
break;
151+
case 11:
152+
stat = QMsm_isInState(me, &QMsmTst_s11_s);
153+
break;
154+
case 2:
155+
stat = QMsm_isInState(me, &QMsmTst_s2_s);
156+
break;
157+
case 21:
158+
stat = QMsm_isInState(me, &QMsmTst_s21_s);
159+
break;
160+
case 211:
161+
stat = QMsm_isInState(me, &QMsmTst_s211_s);
162+
break;
163+
default:
164+
Q_ERROR();
165+
}
166+
return stat;
167+
}
168+
//$enddef${Shared::QMsmTst_isInState} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
135169
//$define${SMs::QMsmTst} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
136170

137171
//${SMs::QMsmTst} ............................................................

examples/qutest/qmsmtst/src/qmsmtst.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,17 @@ enum QMsmTstSignals {
5252
//${Shared::the_sm} ..........................................................
5353
extern QAsm * const the_sm;
5454

55-
//${Shared::QMsmTst_ctor} ....................................................
56-
void QMsmTst_ctor(void);
57-
5855
//${Shared::BSP_display} .....................................................
5956
void BSP_display(char const * msg);
6057

6158
//${Shared::BSP_terminate} ...................................................
6259
void BSP_terminate(int16_t const result);
60+
61+
//${Shared::QMsmTst_ctor} ....................................................
62+
void QMsmTst_ctor(void);
63+
64+
//${Shared::QMsmTst_isInState} ...............................................
65+
bool QMsmTst_isInState(uint32_t const state_num);
6366
//$enddecl${Shared} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6467

6568
#endif // QMSMTST_H_

examples/qutest/qmsmtst/src/qmsmtst.qm

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@
2727
<documentation>opaque pointer to the test SM</documentation>
2828
<code>= &amp;QMsmTst_inst.super.super;</code>
2929
</attribute>
30-
<!--${Shared::QMsmTst_ctor}-->
31-
<operation name="QMsmTst_ctor" type="void" visibility="0x00" properties="0x00">
32-
<code>QMsmTst *me = &amp;QMsmTst_inst;
33-
QMsm_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;QMsmTst_initial));</code>
34-
</operation>
3530
<!--${Shared::BSP_display}-->
3631
<operation name="BSP_display" type="void" visibility="0x00" properties="0x00">
3732
<!--${Shared::BSP_display::msg}-->
@@ -42,6 +37,41 @@ QMsm_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;QMsmTst_initial));</code>
4237
<!--${Shared::BSP_terminate::result}-->
4338
<parameter name="result" type="int16_t const"/>
4439
</operation>
40+
<!--${Shared::QMsmTst_ctor}-->
41+
<operation name="QMsmTst_ctor" type="void" visibility="0x00" properties="0x00">
42+
<code>QMsmTst *me = &amp;QMsmTst_inst;
43+
QMsm_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;QMsmTst_initial));</code>
44+
</operation>
45+
<!--${Shared::QMsmTst_isInState}-->
46+
<operation name="QMsmTst_isInState" type="bool" visibility="0x00" properties="0x00">
47+
<!--${Shared::QMsmTst_isInStat~::state_num}-->
48+
<parameter name="state_num" type="uint32_t const"/>
49+
<code>QMsm * const me = &amp;QMsmTst_inst.super;
50+
bool stat = false;
51+
switch (state_num) {
52+
case 0:
53+
stat = QMsm_isInState(me, &amp;QMsmTst_s_s);
54+
break;
55+
case 1:
56+
stat = QMsm_isInState(me, &amp;QMsmTst_s1_s);
57+
break;
58+
case 11:
59+
stat = QMsm_isInState(me, &amp;QMsmTst_s11_s);
60+
break;
61+
case 2:
62+
stat = QMsm_isInState(me, &amp;QMsmTst_s2_s);
63+
break;
64+
case 21:
65+
stat = QMsm_isInState(me, &amp;QMsmTst_s21_s);
66+
break;
67+
case 211:
68+
stat = QMsm_isInState(me, &amp;QMsmTst_s211_s);
69+
break;
70+
default:
71+
Q_ERROR();
72+
}
73+
return stat;</code>
74+
</operation>
4575
</package>
4676
<!--${SMs}-->
4777
<package name="SMs" stereotype="0x02">
@@ -349,9 +379,12 @@ $declare ${Shared}
349379
<text>#include &quot;qpc.h&quot; // QP/C framework
350380
#include &quot;qmsmtst.h&quot; // this application
351381

382+
Q_DEFINE_THIS_FILE
383+
352384
$declare ${SMs::QMsmTst}
353385
$define ${Shared::the_sm}
354386
$define ${Shared::QMsmTst_ctor}
387+
$define ${Shared::QMsmTst_isInState}
355388
$define ${SMs::QMsmTst}</text>
356389
</file>
357390
</directory>

examples/qutest/qmsmtst/test/test_qmsm-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("QMsmTst isInState", 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("QMsmTst dispatch", NORESET)
2233
dispatch("A_SIG")
2334
expect("@timestamp BSP_DISPLAY s21-A;")

0 commit comments

Comments
 (0)