-
Notifications
You must be signed in to change notification settings - Fork 247
/
qpc.qm
6895 lines (6049 loc) · 235 KB
/
qpc.qm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8"?>
<model version="7.0.0" links="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.state-machine.com/qm/qm7.xsd">
<documentation>QP/C Real-Time Embedded Framework (RTEF)
This model is used to generate the whole QP/C source code.
Copyright (c) 2005 Quantum Leaps, LLC. All rights reserved.
Q u a n t u m L e a P s
------------------------
Modern Embedded Software
SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
The QP/C software is dual-licensed under the terms of the open-source GNU
General Public License (GPL) or under the terms of one of the closed-
source Quantum Leaps commercial licenses.
Redistributions in source code must retain this top-level comment block.
Plagiarizing this software to sidestep the license obligations is illegal.
NOTE:
The GPL (see <www.gnu.org/licenses/gpl-3.0>) does NOT permit the
incorporation of the QP/C software into proprietary programs. Please
contact Quantum Leaps for commercial licensing options, which expressly
supersede the GPL and are designed explicitly for licensees interested
in using QP/C in closed-source proprietary applications.
Quantum Leaps contact information:
<www.state-machine.com/licensing>
<info@state-machine.com></documentation>
<!--${qpc}-->
<framework name="qpc">
<license name="LicenseRef-QL-dual">public
qpc
2025-12-31
Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
Q u a n t u m L e a P s
------------------------
Modern Embedded Software
SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
The QP/C software is dual-licensed under the terms of the open-source GNU
General Public License (GPL) or under the terms of one of the closed-
source Quantum Leaps commercial licenses.
Redistributions in source code must retain this top-level comment block.
Plagiarizing this software to sidestep the license obligations is illegal.
NOTE:
The GPL does NOT permit the incorporation of this code into proprietary
programs. Please contact Quantum Leaps for commercial licensing options,
which expressly supersede the GPL and are designed explicitly for
closed-source distribution.
Quantum Leaps contact information:
<www.state-machine.com/licensing>
<info@state-machine.com>
#2BACD81DCE8ED122C193E4F48A14170D660DFF1E</license>
</framework>
<!--${QP-FuSa}-->
<package name="QP-FuSa" stereotype="0x05">
<!--${QP-FuSa::enabled}-->
<package name="enabled" stereotype="0x05">
<!--${QP-FuSa::enabled::Q_DEFINE_THIS_MODULE}-->
<operation name="Q_DEFINE_THIS_MODULE" type="" visibility="0x03" properties="0x00">
<!--${QP-FuSa::enabled::Q_DEFINE_THIS_MO~::name_}-->
<parameter name="name_" type="char const *"/>
<code>\
static char const Q_this_module_[] = name_;</code>
</operation>
<!--${QP-FuSa::enabled::Q_ASSERT_INCRIT}-->
<operation name="Q_ASSERT_INCRIT" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::enabled::Q_ASSERT_INCRIT::id_}-->
<parameter name="id_" type="int"/>
<!--${QP-FuSa::enabled::Q_ASSERT_INCRIT::expr_}-->
<parameter name="expr_" type="bool"/>
<code> \
((expr_) ? ((void)0) : Q_onError(&Q_this_module_[0], (id_)))</code>
</operation>
<!--${QP-FuSa::enabled::Q_ERROR_INCRIT}-->
<operation name="Q_ERROR_INCRIT" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::enabled::Q_ERROR_INCRIT::id_}-->
<parameter name="id_" type="int"/>
<code> \
(Q_onError(&Q_this_module_[0], (id_)))</code>
</operation>
<!--${QP-FuSa::enabled::Q_ASSERT_ID}-->
<operation name="Q_ASSERT_ID" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::enabled::Q_ASSERT_ID::id_}-->
<parameter name="id_" type="int"/>
<!--${QP-FuSa::enabled::Q_ASSERT_ID::expr_}-->
<parameter name="expr_" type="bool"/>
<code>do { \
QF_CRIT_STAT \
QF_CRIT_ENTRY(); \
(expr_) ? ((void)0) : Q_onError(&Q_this_module_[0], (id_)); \
QF_CRIT_EXIT(); \
} while (false)</code>
</operation>
<!--${QP-FuSa::enabled::Q_ERROR_ID}-->
<operation name="Q_ERROR_ID" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::enabled::Q_ERROR_ID::id_}-->
<parameter name="id_" type="int"/>
<code>do { \
QF_CRIT_STAT \
QF_CRIT_ENTRY(); \
Q_onError(&Q_this_module_[0], (id_)); \
QF_CRIT_EXIT(); \
} while (false)</code>
</operation>
</package>
<!--${QP-FuSa::disabled}-->
<package name="disabled" stereotype="0x05">
<!--${QP-FuSa::disabled::Q_DEFINE_THIS_MODULE}-->
<operation name="Q_DEFINE_THIS_MODULE" type="" visibility="0x03" properties="0x00">
<!--${QP-FuSa::disabled::Q_DEFINE_THIS_MO~::name_}-->
<parameter name="name_" type="char const *"/>
</operation>
<!--${QP-FuSa::disabled::Q_ASSERT_INCRIT}-->
<operation name="Q_ASSERT_INCRIT" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::disabled::Q_ASSERT_INCRIT::id_}-->
<parameter name="id_" type="int"/>
<!--${QP-FuSa::disabled::Q_ASSERT_INCRIT::expr_}-->
<parameter name="expr_" type="bool"/>
<code>((void)0)</code>
</operation>
<!--${QP-FuSa::disabled::Q_ERROR_INCRIT}-->
<operation name="Q_ERROR_INCRIT" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::disabled::Q_ERROR_INCRIT::id_}-->
<parameter name="id_" type="int"/>
<code>((void)0)</code>
</operation>
<!--${QP-FuSa::disabled::Q_ASSERT_ID}-->
<operation name="Q_ASSERT_ID" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::disabled::Q_ASSERT_ID::id_}-->
<parameter name="id_" type="int"/>
<!--${QP-FuSa::disabled::Q_ASSERT_ID::expr_}-->
<parameter name="expr_" type="bool"/>
<code>((void)0)</code>
</operation>
<!--${QP-FuSa::disabled::Q_ERROR_ID}-->
<operation name="Q_ERROR_ID" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::disabled::Q_ERROR_ID::id_}-->
<parameter name="id_" type="int"/>
<code>((void)0)</code>
</operation>
</package>
<!--${QP-FuSa::Q_DEFINE_THIS_FILE}-->
<attribute name="Q_DEFINE_THIS_FILE" type="" visibility="0x03" properties="0x00">
<code>Q_DEFINE_THIS_MODULE(__FILE__)</code>
</attribute>
<!--${QP-FuSa::Q_ASSERT}-->
<operation name="Q_ASSERT" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::Q_ASSERT::expr_}-->
<parameter name="expr_" type="bool"/>
<code>Q_ASSERT_ID(__LINE__, (expr_))</code>
</operation>
<!--${QP-FuSa::Q_ERROR}-->
<operation name="Q_ERROR" type="void" visibility="0x03" properties="0x00">
<code>Q_ERROR_ID(__LINE__)</code>
</operation>
<!--${QP-FuSa::Q_REQUIRE_ID}-->
<operation name="Q_REQUIRE_ID" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::Q_REQUIRE_ID::id_}-->
<parameter name="id_" type="int"/>
<!--${QP-FuSa::Q_REQUIRE_ID::expr_}-->
<parameter name="expr_" type="bool"/>
<code>Q_ASSERT_ID((id_), (expr_))</code>
</operation>
<!--${QP-FuSa::Q_REQUIRE}-->
<operation name="Q_REQUIRE" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::Q_REQUIRE::expr_}-->
<parameter name="expr_" type="bool"/>
<code>Q_ASSERT(expr_)</code>
</operation>
<!--${QP-FuSa::Q_REQUIRE_INCRIT}-->
<operation name="Q_REQUIRE_INCRIT" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::Q_REQUIRE_INCRIT::id_}-->
<parameter name="id_" type="int"/>
<!--${QP-FuSa::Q_REQUIRE_INCRIT::expr_}-->
<parameter name="expr_" type="bool"/>
<code>Q_ASSERT_INCRIT((id_), (expr_))</code>
</operation>
<!--${QP-FuSa::Q_ENSURE_ID}-->
<operation name="Q_ENSURE_ID" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::Q_ENSURE_ID::id_}-->
<parameter name="id_" type="int"/>
<!--${QP-FuSa::Q_ENSURE_ID::expr_}-->
<parameter name="expr_" type="bool"/>
<code>Q_ASSERT_ID((id_), (expr_))</code>
</operation>
<!--${QP-FuSa::Q_ENSURE}-->
<operation name="Q_ENSURE" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::Q_ENSURE::expr_}-->
<parameter name="expr_" type="bool"/>
<code>Q_ASSERT(expr_)</code>
</operation>
<!--${QP-FuSa::Q_ENSURE_INCRIT}-->
<operation name="Q_ENSURE_INCRIT" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::Q_ENSURE_INCRIT::id_}-->
<parameter name="id_" type="int"/>
<!--${QP-FuSa::Q_ENSURE_INCRIT::expr_}-->
<parameter name="expr_" type="bool"/>
<code>Q_ASSERT_INCRIT((id_), (expr_))</code>
</operation>
<!--${QP-FuSa::Q_INVARIANT_ID}-->
<operation name="Q_INVARIANT_ID" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::Q_INVARIANT_ID::id_}-->
<parameter name="id_" type="int"/>
<!--${QP-FuSa::Q_INVARIANT_ID::expr_}-->
<parameter name="expr_" type="bool"/>
<code>Q_ASSERT_ID((id_), (expr_))</code>
</operation>
<!--${QP-FuSa::Q_INVARIANT}-->
<operation name="Q_INVARIANT" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::Q_INVARIANT::expr_}-->
<parameter name="expr_" type="bool"/>
<code>Q_ASSERT(expr_)</code>
</operation>
<!--${QP-FuSa::Q_INVARIANT_INCRIT}-->
<operation name="Q_INVARIANT_INCRIT" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::Q_INVARIANT_INCR~::id_}-->
<parameter name="id_" type="int"/>
<!--${QP-FuSa::Q_INVARIANT_INCR~::expr_}-->
<parameter name="expr_" type="bool"/>
<code>Q_ASSERT_INCRIT((id_), (expr_))</code>
</operation>
<!--${QP-FuSa::Q_ASSERT_STATIC}-->
<operation name="Q_ASSERT_STATIC" type="void" visibility="0x03" properties="0x00">
<!--${QP-FuSa::Q_ASSERT_STATIC::expr_}-->
<parameter name="expr_" type="bool"/>
<code>extern char Q_static_assert_[(expr_) ? 1 : -1]</code>
</operation>
<!--${QP-FuSa::Q_NORETURN}-->
<attribute name="Q_NORETURN?ndef Q_NORETURN" type="void" visibility="0x03" properties="0x00">
<code>_Noreturn void</code>
</attribute>
<!--${QP-FuSa::int_t}-->
<attribute name="int_t?ndef QP_VERSION" type="typedef int" visibility="0x04" properties="0x00"/>
<!--${QP-FuSa::Q_onError}-->
<operation name="Q_onError" type="Q_NORETURN" visibility="0x00" properties="0x00">
<!--${QP-FuSa::Q_onError::module}-->
<parameter name="module" type="char const * const"/>
<!--${QP-FuSa::Q_onError::id}-->
<parameter name="id" type="int_t const"/>
</operation>
<!--${QP-FuSa::Q_DIM}-->
<operation name="Q_DIM?ndef QP_VERSION" type="unsigned" visibility="0x03" properties="0x00">
<!--${QP-FuSa::Q_DIM::array_}-->
<parameter name="array_" type="1-dimensional array"/>
<code>(sizeof(array_) / sizeof((array_)[0U]))</code>
</operation>
</package>
<!--${glob-types}-->
<package name="glob-types" stereotype="0x00">
<!--${glob-types::int_t}-->
<attribute name="int_t" type="typedef int" visibility="0x04" properties="0x00"/>
<!--${glob-types::enum_t}-->
<attribute name="enum_t" type="typedef int" visibility="0x04" properties="0x00"/>
<!--${glob-types::float32_t}-->
<attribute name="float32_t" type="typedef float" visibility="0x04" properties="0x00"/>
<!--${glob-types::float64_t}-->
<attribute name="float64_t" type="typedef double" visibility="0x04" properties="0x00"/>
</package>
<!--${QEP}-->
<package name="QEP" stereotype="0x05">
<!--${QEP::QP_versionStr[16]}-->
<attribute name="QP_versionStr[16]" type="char const" visibility="0x00" properties="0x00">
<documentation>//! the current QP version number string in ROM, based on #QP_VERSION_STR</documentation>
<code>= QP_VERSION_STR;</code>
</attribute>
<!--${QEP::QSignal}-->
<attribute name="QSignal? (Q_SIGNAL_SIZE == 1U)" type="typedef uint8_t" visibility="0x04" properties="0x00"/>
<!--${QEP::QSignal}-->
<attribute name="QSignal? (Q_SIGNAL_SIZE == 2U)" type="typedef uint16_t" visibility="0x04" properties="0x00"/>
<!--${QEP::QSignal}-->
<attribute name="QSignal? (Q_SIGNAL_SIZE == 4U)" type="typedef uint32_t" visibility="0x04" properties="0x00"/>
<!--${QEP::QEvt}-->
<class name="QEvt">
<documentation>//! @class QEvt</documentation>
<!--${QEP::QEvt::sig}-->
<attribute name="sig" type="QSignal" visibility="0x00" properties="0x00">
<documentation>//! @public @memberof QEvt</documentation>
</attribute>
<!--${QEP::QEvt::evtTag_}-->
<attribute name="evtTag_" type="uint8_t" visibility="0x02" properties="0x00">
<documentation>//! @private @memberof QEvt</documentation>
</attribute>
<!--${QEP::QEvt::refCtr_}-->
<attribute name="refCtr_" type="uint8_t volatile" visibility="0x02" properties="0x00">
<documentation>//! @private @memberof QEvt</documentation>
</attribute>
<!--${QEP::QEvt::reserved_[4]}-->
<attribute name="reserved_[4]" type="QEvt const" visibility="0x02" properties="0x01">
<code>= {
QEVT_INITIALIZER(Q_EMPTY_SIG),
QEVT_INITIALIZER(Q_ENTRY_SIG),
QEVT_INITIALIZER(Q_EXIT_SIG),
QEVT_INITIALIZER(Q_INIT_SIG)
};</code>
</attribute>
<!--${QEP::QEvt::ctor}-->
<operation name="ctor" type="void" visibility="0x00" properties="0x02">
<documentation>//! @public @memberof QEvt
//! @public @memberof QEvt</documentation>
<!--${QEP::QEvt::ctor::sig}-->
<parameter name="sig" type="enum_t const"/>
<code>me->sig = (QSignal)sig;
me->evtTag_ = 0x0FU;
me->refCtr_ = 0U;</code>
</operation>
<!--${QEP::QEvt::init}-->
<operation name="init" type="QEvt *" visibility="0x00" properties="0x02">
<documentation>//! @public @memberof QEvt
//! @public @memberof QEvt</documentation>
<!--${QEP::QEvt::init::dummy}-->
<parameter name="dummy" type="uint8_t"/>
<code>(void)dummy;
return me;</code>
</operation>
<!--${QEP::QEvt::verify_}-->
<operation name="verify_?ndef Q_UNSAFE" type="bool" visibility="0x02" properties="0x02">
<specifiers>const</specifiers>
<documentation>//! @private @memberof QEvt
//! @private @memberof QEvt</documentation>
<code>uint8_t rc = me->refCtr_;
return (rc <= 2U*QF_MAX_ACTIVE)
&& (((me->evtTag_ ^ rc) & 0x0FU) == 0x0FU);</code>
</operation>
<!--${QEP::QEvt::getPoolNum_}-->
<operation name="getPoolNum_" type="uint_fast8_t" visibility="0x02" properties="0x02">
<specifiers>const</specifiers>
<documentation>//! @private @memberof QEvt
//! @private @memberof QEvt</documentation>
<code>return (uint_fast8_t)(me->evtTag_ >> 4U);</code>
</operation>
</class>
<!--${QEP::QStateRet}-->
<attribute name="QStateRet" type="enum" visibility="0x04" properties="0x00">
<documentation>//! All possible values returned from state/action handlers
//! @note
//! The order of enumeration matters for algorithmic correctness.</documentation>
<code>{
// unhandled and need to "bubble up"
Q_RET_SUPER, //!< event passed to superstate to handle
Q_RET_UNHANDLED, //!< event unhandled due to guard
// handled and do not need to "bubble up"
Q_RET_HANDLED, //!< event handled (internal transition)
Q_RET_IGNORED, //!< event silently ignored (bubbled up to top)
// entry/exit
Q_RET_ENTRY, //!< state entry action executed
Q_RET_EXIT, //!< state exit action executed
// no side effects
Q_RET_NULL, //!< return value without any effect
// transitions need to execute transition-action table in ::QMsm
Q_RET_TRAN, //!< regular transition
Q_RET_TRAN_INIT, //!< initial transition in a state
// transitions that additionally clobber me->state
Q_RET_TRAN_HIST, //!< transition to history of a given state
};</code>
</attribute>
<!--${QEP::QState}-->
<attribute name="QState" type="typedef enum QStateRet" visibility="0x04" properties="0x00"/>
<!--${QEP::QStateHandler}-->
<attribute name="QStateHandler" type="typedef QState (*" visibility="0x04" properties="0x00">
<code>)(void * const me, QEvt const * const e);</code>
</attribute>
<!--${QEP::QActionHandler}-->
<attribute name="QActionHandler" type="typedef QState (*" visibility="0x04" properties="0x00">
<code>)(void * const me);</code>
</attribute>
<!--${QEP::QXThread}-->
<attribute name="QXThread" type="struct" visibility="0x04" properties="0x00">
<documentation>// forward declaration</documentation>
</attribute>
<!--${QEP::QXThreadHandler}-->
<attribute name="QXThreadHandler" type="typedef void (*" visibility="0x04" properties="0x00">
<code>)(struct QXThread * const me);</code>
</attribute>
<!--${QEP::QMState}-->
<attribute name="QMState" type="typedef struct" visibility="0x04" properties="0x00">
<code>{
struct QMState const *superstate; //!< @private @memberof QMState
QStateHandler const stateHandler; //!< @private @memberof QMState
QActionHandler const entryAction; //!< @private @memberof QMState
QActionHandler const exitAction; //!< @private @memberof QMState
QActionHandler const initAction; //!< @private @memberof QMState
} QMState;</code>
</attribute>
<!--${QEP::QMTranActTable}-->
<attribute name="QMTranActTable" type="typedef struct" visibility="0x04" properties="0x00">
<code>{
QMState const *target; //!< @private @memberof QMTranActTable
QActionHandler const act[1]; //!< @private @memberof QMTranActTable
} QMTranActTable;</code>
</attribute>
<!--${QEP::QAsmAttr}-->
<attribute name="QAsmAttr" type="union" visibility="0x04" properties="0x00">
<code>{
QStateHandler fun; //!< @private @memberof QAsmAttr
QActionHandler act; //!< @private @memberof QAsmAttr
QXThreadHandler thr; //!< @private @memberof QAsmAttr
QMTranActTable const *tatbl; //!< @private @memberof QAsmAttr
struct QMState const *obj; //!< @private @memberof QAsmAttr
#ifndef Q_UNSAFE
uintptr_t uint; //!< @private @memberof QAsmAttr
#endif
};</code>
</attribute>
<!--${QEP::QAsm}-->
<class name="QAsm">
<documentation>//! @class QAsm</documentation>
<!--${QEP::QAsm::vptr}-->
<attribute name="vptr" type="struct QAsmVtable const *" visibility="0x02" properties="0x00">
<documentation>//! @protected @memberof QAsm</documentation>
</attribute>
<!--${QEP::QAsm::state}-->
<attribute name="state" type="union QAsmAttr" visibility="0x01" properties="0x00">
<documentation>//! @protected @memberof QAsm</documentation>
</attribute>
<!--${QEP::QAsm::temp}-->
<attribute name="temp" type="union QAsmAttr" visibility="0x01" properties="0x00">
<documentation>//! @protected @memberof QAsm</documentation>
</attribute>
<!--${QEP::QAsm::ctor}-->
<operation name="ctor" type="void" visibility="0x01" properties="0x00">
<documentation>//! @protected @memberof QAsm
//! @protected @memberof QAsm</documentation>
<code>me->vptr = (QAsmVtable *)0;
me->state.fun = Q_STATE_CAST(0);
me->temp.fun = Q_STATE_CAST(0);</code>
</operation>
</class>
<!--${QEP::QAsmVtable}-->
<attribute name="QAsmVtable" type="struct" visibility="0x04" properties="0x00">
<code>{
void (*init)(QAsm * const me, void const * const e,
uint_fast8_t const qsId);
void (*dispatch)(QAsm * const me, QEvt const * const e,
uint_fast8_t const qsId);
bool (*isIn)(QAsm * const me, QStateHandler const s);
#ifdef Q_SPY
QStateHandler (*getStateHandler)(QAsm * const me);
#endif // Q_SPY
};</code>
</attribute>
<!--${QEP::QHsm}-->
<class name="QHsm" superclass="QEP::QAsm">
<documentation>//! @class QHsm
//! @extends QAsm
State machine implementation strategy suitable for
manual coding</documentation>
<!--${QEP::QHsm::ctor}-->
<operation name="ctor" type="void" visibility="0x01" properties="0x00">
<documentation>//! @protected @memberof QHsm
//! @protected @memberof QHsm</documentation>
<!--${QEP::QHsm::ctor::initial}-->
<parameter name="initial" type="QStateHandler const"/>
<code>static struct QAsmVtable const vtable = { // QAsm virtual table
&QHsm_init_,
&QHsm_dispatch_,
&QHsm_isIn_
#ifdef Q_SPY
,&QHsm_getStateHandler_
#endif
};
// do not call the QAsm_ctor() here
me->super.vptr = &vtable;
me->super.state.fun = Q_STATE_CAST(&QHsm_top);
me->super.temp.fun = initial;</code>
</operation>
<!--${QEP::QHsm::init_}-->
<operation name="init_" type="void" visibility="0x02" properties="0x01">
<documentation>//! @private @memberof QHsm
//! @private @memberof QHsm</documentation>
<!--${QEP::QHsm::init_::me}-->
<parameter name="me" type="QAsm * const"/>
<!--${QEP::QHsm::init_::e}-->
<parameter name="e" type="void const * const"/>
<!--${QEP::QHsm::init_::qsId}-->
<parameter name="qsId" type="uint_fast8_t const"/>
<code>QF_CRIT_STAT
QState r;
// produce QS dictionary for QHsm_top()
#ifdef Q_SPY
QS_CRIT_ENTRY();
QS_MEM_SYS();
if ((QS_priv_.flags & 0x01U) == 0U) {
QS_priv_.flags |= 0x01U;
r = Q_RET_HANDLED;
}
else {
r = Q_RET_IGNORED;
}
QS_MEM_APP();
QS_CRIT_EXIT();
if (r == Q_RET_HANDLED) {
QS_FUN_DICTIONARY(&QHsm_top);
}
#else
Q_UNUSED_PAR(qsId);
#endif // def Q_SPY
QStateHandler t = me->state.fun;
QF_CRIT_ENTRY();
Q_REQUIRE_INCRIT(200, (me->vptr != (struct QAsmVtable *)0)
&& (me->temp.fun != Q_STATE_CAST(0))
&& (t == Q_STATE_CAST(&QHsm_top)));
QF_CRIT_EXIT();
// execute the top-most initial tran.
r = (*me->temp.fun)(me, Q_EVT_CAST(QEvt));
QF_CRIT_ENTRY();
// the top-most initial tran. must be taken
Q_ASSERT_INCRIT(210, r == Q_RET_TRAN);
QS_MEM_SYS();
QS_BEGIN_PRE(QS_QEP_STATE_INIT, qsId)
QS_OBJ_PRE(me); // this state machine object
QS_FUN_PRE(t); // the source state
QS_FUN_PRE(me->temp.fun); // the target of the initial tran.
QS_END_PRE()
QS_MEM_APP();
QF_CRIT_EXIT();
// drill down into the state hierarchy with initial transitions...
do {
QStateHandler path[QHSM_MAX_NEST_DEPTH_]; // tran. entry path array
int_fast8_t ip = 0; // tran. entry path index
path[0] = me->temp.fun;
(void)QHSM_RESERVED_EVT_(me->temp.fun, Q_EMPTY_SIG);
// note: ip is the fixed upper loop bound
while ((me->temp.fun != t) && (ip < (QHSM_MAX_NEST_DEPTH_ - 1))) {
++ip;
path[ip] = me->temp.fun;
(void)QHSM_RESERVED_EVT_(me->temp.fun, Q_EMPTY_SIG);
}
QF_CRIT_ENTRY();
// too many state nesting levels or "malformed" HSM
Q_ENSURE_INCRIT(220, ip < QHSM_MAX_NEST_DEPTH_);
QF_CRIT_EXIT();
me->temp.fun = path[0];
// retrace the entry path in reverse (desired) order...
// note: ip is the fixed upper loop bound
do {
// enter path[ip]
if (QHSM_RESERVED_EVT_(path[ip], Q_ENTRY_SIG)
== Q_RET_HANDLED)
{
QS_STATE_ENTRY_(path[ip], qsId);
}
--ip;
} while (ip >= 0);
t = path[0]; // current state becomes the new source
r = QHSM_RESERVED_EVT_(t, Q_INIT_SIG); // execute initial tran.
#ifdef Q_SPY
if (r == Q_RET_TRAN) {
QS_CRIT_ENTRY();
QS_MEM_SYS();
QS_BEGIN_PRE(QS_QEP_STATE_INIT, qsId)
QS_OBJ_PRE(me); // this state machine object
QS_FUN_PRE(t); // the source state
QS_FUN_PRE(me->temp.fun); // the target of the initial tran.
QS_END_PRE()
QS_MEM_APP();
QS_CRIT_EXIT();
}
#endif // Q_SPY
} while (r == Q_RET_TRAN);
QF_CRIT_ENTRY();
QS_MEM_SYS();
QS_BEGIN_PRE(QS_QEP_INIT_TRAN, qsId)
QS_TIME_PRE(); // time stamp
QS_OBJ_PRE(me); // this state machine object
QS_FUN_PRE(t); // the new active state
QS_END_PRE()
QS_MEM_APP();
QF_CRIT_EXIT();
me->state.fun = t; // change the current active state
#ifndef Q_UNSAFE
me->temp.uint = ~me->state.uint;
#endif</code>
</operation>
<!--${QEP::QHsm::dispatch_}-->
<operation name="dispatch_" type="void" visibility="0x02" properties="0x01">
<documentation>//! @private @memberof QHsm
//! @private @memberof QHsm</documentation>
<!--${QEP::QHsm::dispatch_::me}-->
<parameter name="me" type="QAsm * const"/>
<!--${QEP::QHsm::dispatch_::e}-->
<parameter name="e" type="QEvt const * const"/>
<!--${QEP::QHsm::dispatch_::qsId}-->
<parameter name="qsId" type="uint_fast8_t const"/>
<code>#ifndef Q_SPY
Q_UNUSED_PAR(qsId);
#endif
QStateHandler s = me->state.fun;
QStateHandler t = s;
QF_CRIT_STAT
QF_CRIT_ENTRY();
Q_REQUIRE_INCRIT(300,
(e != (QEvt *)0)
&& (s != Q_STATE_CAST(0))
&& (me->state.uint == (uintptr_t)(~me->temp.uint)));
#ifndef Q_UNSAFE
Q_INVARIANT_INCRIT(301, QEvt_verify_(e));
#endif
QS_MEM_SYS();
QS_BEGIN_PRE(QS_QEP_DISPATCH, qsId)
QS_TIME_PRE(); // time stamp
QS_SIG_PRE(e->sig); // the signal of the event
QS_OBJ_PRE(me); // this state machine object
QS_FUN_PRE(s); // the current state
QS_END_PRE()
QS_MEM_APP();
QF_CRIT_EXIT();
// process the event hierarchically...
QState r;
me->temp.fun = s;
int_fast8_t ip = QHSM_MAX_NEST_DEPTH_; // fixed upper loop bound
do {
s = me->temp.fun;
r = (*s)(me, e); // invoke state handler s
if (r == Q_RET_UNHANDLED) { // unhandled due to a guard?
QS_CRIT_ENTRY();
QS_MEM_SYS();
QS_BEGIN_PRE(QS_QEP_UNHANDLED, qsId)
QS_SIG_PRE(e->sig); // the signal of the event
QS_OBJ_PRE(me); // this state machine object
QS_FUN_PRE(s); // the current state
QS_END_PRE()
QS_MEM_APP();
QS_CRIT_EXIT();
r = QHSM_RESERVED_EVT_(s, Q_EMPTY_SIG); // superstate of s
}
--ip;
} while ((r == Q_RET_SUPER) && (ip > 0));
QF_CRIT_ENTRY();
Q_ENSURE_INCRIT(310, ip > 0);
QF_CRIT_EXIT();
if (r >= Q_RET_TRAN) { // tran. (regular or history) taken?
#ifdef Q_SPY
if (r == Q_RET_TRAN_HIST) { // tran. to history?
QS_CRIT_ENTRY();
QS_MEM_SYS();
QS_BEGIN_PRE(QS_QEP_TRAN_HIST, qsId)
QS_OBJ_PRE(me); // this state machine object
QS_FUN_PRE(s); // tran. to history source
QS_FUN_PRE(me->temp.fun); // tran. to history target
QS_END_PRE()
QS_MEM_APP();
QS_CRIT_EXIT();
}
#endif // Q_SPY
QStateHandler path[QHSM_MAX_NEST_DEPTH_];
path[0] = me->temp.fun; // tran. target
path[1] = t; // current state
path[2] = s; // tran. source
// exit current state to tran. source s...
ip = QHSM_MAX_NEST_DEPTH_; // fixed upper loop bound
for (; (t != s) && (ip > 0); t = me->temp.fun) {
// exit from t
if (QHSM_RESERVED_EVT_(t, Q_EXIT_SIG) == Q_RET_HANDLED) {
QS_STATE_EXIT_(t, qsId);
// find superstate of t
(void)QHSM_RESERVED_EVT_(t, Q_EMPTY_SIG);
}
--ip;
}
QF_CRIT_ENTRY();
Q_ENSURE_INCRIT(320, ip > 0);
QF_CRIT_EXIT();
ip = QHsm_tran_(me, path, qsId); // take the tran.
// execute state entry actions in the desired order...
// note: ip is the fixed upper loop bound
for (; ip >= 0; --ip) {
// enter path[ip]
if (QHSM_RESERVED_EVT_(path[ip], Q_ENTRY_SIG)
== Q_RET_HANDLED)
{
QS_STATE_ENTRY_(path[ip], qsId);
}
}
t = path[0]; // stick the target into register
me->temp.fun = t; // update the next state
// drill into the target hierarchy...
while (QHSM_RESERVED_EVT_(t, Q_INIT_SIG) == Q_RET_TRAN) {
QS_CRIT_ENTRY();
QS_MEM_SYS();
QS_BEGIN_PRE(QS_QEP_STATE_INIT, qsId)
QS_OBJ_PRE(me); // this state machine object
QS_FUN_PRE(t); // the source (pseudo)state
QS_FUN_PRE(me->temp.fun); // the target of the tran.
QS_END_PRE()
QS_MEM_APP();
QS_CRIT_EXIT();
ip = 0;
path[0] = me->temp.fun;
// find superstate
(void)QHSM_RESERVED_EVT_(me->temp.fun, Q_EMPTY_SIG);
// note: ip is the fixed upper loop bound
while ((me->temp.fun != t) && (ip < (QHSM_MAX_NEST_DEPTH_ - 1))) {
++ip;
path[ip] = me->temp.fun;
// find superstate
(void)QHSM_RESERVED_EVT_(me->temp.fun, Q_EMPTY_SIG);
}
QF_CRIT_ENTRY();
// too many state nesting levels or "malformed" HSM
Q_ENSURE_INCRIT(330, ip < QHSM_MAX_NEST_DEPTH_);
QF_CRIT_EXIT();
me->temp.fun = path[0];
// retrace the entry path in reverse (correct) order...
// note: ip is the fixed upper loop bound
do {
// enter path[ip]
if (QHSM_RESERVED_EVT_(path[ip], Q_ENTRY_SIG)
== Q_RET_HANDLED)
{
QS_STATE_ENTRY_(path[ip], qsId);
}
--ip;
} while (ip >= 0);
t = path[0]; // current state becomes the new source
}
QS_CRIT_ENTRY();
QS_MEM_SYS();
QS_BEGIN_PRE(QS_QEP_TRAN, qsId)
QS_TIME_PRE(); // time stamp
QS_SIG_PRE(e->sig); // the signal of the event
QS_OBJ_PRE(me); // this state machine object
QS_FUN_PRE(s); // the source of the tran.
QS_FUN_PRE(t); // the new active state
QS_END_PRE()
QS_MEM_APP();
QS_CRIT_EXIT();
}
#ifdef Q_SPY
else if (r == Q_RET_HANDLED) {
QS_CRIT_ENTRY();
QS_MEM_SYS();
QS_BEGIN_PRE(QS_QEP_INTERN_TRAN, qsId)
QS_TIME_PRE(); // time stamp
QS_SIG_PRE(e->sig); // the signal of the event
QS_OBJ_PRE(me); // this state machine object
QS_FUN_PRE(s); // the source state
QS_END_PRE()
QS_MEM_APP();
QS_CRIT_EXIT();
}
else {
QS_CRIT_ENTRY();
QS_MEM_SYS();
QS_BEGIN_PRE(QS_QEP_IGNORED, qsId)
QS_TIME_PRE(); // time stamp
QS_SIG_PRE(e->sig); // the signal of the event
QS_OBJ_PRE(me); // this state machine object
QS_FUN_PRE(me->state.fun); // the current state
QS_END_PRE()
QS_MEM_APP();
QS_CRIT_EXIT();
}
#endif // Q_SPY
me->state.fun = t; // change the current active state
#ifndef Q_UNSAFE
me->temp.uint = ~me->state.uint;
#endif</code>
</operation>
<!--${QEP::QHsm::getStateHandler_}-->
<operation name="getStateHandler_?def Q_SPY" type="QStateHandler" visibility="0x02" properties="0x01">
<documentation>//! @private @memberof QHsm
//! @private @memberof QHsm</documentation>
<!--${QEP::QHsm::getStateHandler_::me}-->
<parameter name="me" type="QAsm * const"/>
<code>return me->state.fun;</code>
</operation>
<!--${QEP::QHsm::isIn_}-->
<operation name="isIn_" type="bool" visibility="0x00" properties="0x01">
<documentation>//! @private @memberof QHsm
//! @private @memberof QHsm</documentation>
<!--${QEP::QHsm::isIn_::me}-->
<parameter name="me" type="QAsm * const"/>
<!--${QEP::QHsm::isIn_::state}-->
<parameter name="state" type="QStateHandler const"/>
<code>QF_CRIT_STAT
QF_CRIT_ENTRY();
Q_INVARIANT_INCRIT(602,
me->state.uint == (uintptr_t)(~me->temp.uint));
QF_CRIT_EXIT();
bool inState = false; // assume that this HSM is not in 'state'
// scan the state hierarchy bottom-up
QStateHandler s = me->state.fun;
int_fast8_t lbound = QHSM_MAX_NEST_DEPTH_ + 1; // fixed upper loop bound
QState r = Q_RET_SUPER;
for (; (r != Q_RET_IGNORED) && (lbound > 0); --lbound) {
if (s == state) { // do the states match?
inState = true; // 'true' means that match found
break; // break out of the for-loop
}
else {
r = QHSM_RESERVED_EVT_(s, Q_EMPTY_SIG);
s = me->temp.fun;
}
}
QF_CRIT_ENTRY();
Q_ENSURE_INCRIT(690, lbound > 0);
QF_CRIT_EXIT();
#ifndef Q_UNSAFE
me->temp.uint = ~me->state.uint;
#endif
return inState; // return the status</code>
</operation>
<!--${QEP::QHsm::state}-->
<operation name="state" type="QStateHandler" visibility="0x00" properties="0x02">
<specifiers>const</specifiers>
<documentation>//! @public @memberof QHsm
//! @public @memberof QHsm</documentation>
<code>return me->super.state.fun;</code>
</operation>
<!--${QEP::QHsm::childState}-->
<operation name="childState" type="QStateHandler" visibility="0x00" properties="0x00">
<documentation>//! @public @memberof QHsm
//! @public @memberof QHsm</documentation>
<!--${QEP::QHsm::childState::parent}-->
<parameter name="parent" type="QStateHandler const"/>
<code>QStateHandler child = me->super.state.fun; // start with current state
bool isFound = false; // start with the child not found
// establish stable state configuration
me->super.temp.fun = child;
QState r;
int_fast8_t lbound = QHSM_MAX_NEST_DEPTH_; // fixed upper loop bound
do {
// is this the parent of the current child?
if (me->super.temp.fun == parent) {
isFound = true; // child is found
r = Q_RET_IGNORED; // break out of the loop
}
else {
child = me->super.temp.fun;
r = QHSM_RESERVED_EVT_(me->super.temp.fun, Q_EMPTY_SIG);
}
--lbound;
} while ((r != Q_RET_IGNORED) // the top state not reached
&& (lbound > 0));
#ifndef Q_UNSAFE
me->super.temp.uint = ~me->super.state.uint;
#else
Q_UNUSED_PAR(isFound);
#endif
QF_CRIT_STAT
QF_CRIT_ENTRY();
// NOTE: the following postcondition can only succeed when
// (lbound > 0), so no extra check is necessary.
Q_ENSURE_INCRIT(890, isFound);
QF_CRIT_EXIT();
return child;</code>
</operation>
<!--${QEP::QHsm::tran_}-->
<operation name="tran_" type="int_fast8_t" visibility="0x02" properties="0x01">
<documentation>//! @private @memberof QHsm
//! @private @memberof QHsm</documentation>
<!--${QEP::QHsm::tran_::me}-->
<parameter name="me" type="QAsm * const"/>
<!--${QEP::QHsm::tran_::path}-->
<parameter name="path" type="QStateHandler * const"/>
<!--${QEP::QHsm::tran_::qsId}-->
<parameter name="qsId" type="uint_fast8_t const"/>
<code>#ifndef Q_SPY
Q_UNUSED_PAR(qsId);
#endif
int_fast8_t ip = -1; // tran. entry path index
QStateHandler t = path[0];
QStateHandler const s = path[2];
QF_CRIT_STAT
// (a) check source==target (tran. to self)...
if (s == t) {
// exit source s
if (QHSM_RESERVED_EVT_(s, Q_EXIT_SIG) == Q_RET_HANDLED) {
QS_STATE_EXIT_(s, qsId);
}
ip = 0; // enter the target
}
else {
// find superstate of target
(void)QHSM_RESERVED_EVT_(t, Q_EMPTY_SIG);
t = me->temp.fun;
// (b) check source==target->super...
if (s == t) {
ip = 0; // enter the target
}
else {
// find superstate of src
(void)QHSM_RESERVED_EVT_(s, Q_EMPTY_SIG);
// (c) check source->super==target->super...
if (me->temp.fun == t) {
// exit source s
if (QHSM_RESERVED_EVT_(s, Q_EXIT_SIG) == Q_RET_HANDLED) {
QS_STATE_EXIT_(s, qsId);
}
ip = 0; // enter the target
}
else {
// (d) check source->super==target...
if (me->temp.fun == path[0]) {
// exit source s
if (QHSM_RESERVED_EVT_(s, Q_EXIT_SIG) == Q_RET_HANDLED) {
QS_STATE_EXIT_(s, qsId);
}
}
else {
// (e) check rest of source==target->super->super..
// and store the entry path along the way
int_fast8_t iq = 0; // indicate that LCA was found
ip = 1; // enter target and its superstate
path[1] = t; // save the superstate of target
t = me->temp.fun; // save source->super
// find target->super->super...
// note: ip is the fixed upper loop bound
QState r = QHSM_RESERVED_EVT_(path[1], Q_EMPTY_SIG);
while ((r == Q_RET_SUPER)
&& (ip < (QHSM_MAX_NEST_DEPTH_ - 1)))
{