From d24ebacaa86e1547c12495a4c0b7def39406a851 Mon Sep 17 00:00:00 2001 From: Quantum Leaps Date: Wed, 22 Feb 2017 08:32:45 -0500 Subject: [PATCH] 5.8.2b --- doxygen/Doxyfile | 8 +- doxygen/Doxyfile-CHM | 8 +- doxygen/history.dox | 1 + doxygen/metrics.dox | 62 +++++++------- examples/win32/qhsmtst/log.txt | 2 +- source/qep_hsm.cpp | 151 +++++++++++++++++---------------- 6 files changed, 117 insertions(+), 115 deletions(-) diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 7782a5e2..14f6b4e5 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -108,7 +108,7 @@ WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = \ +INPUT = \ main.dox \ gs.dox \ struct.dox \ @@ -191,10 +191,10 @@ IGNORE_PREFIX = GENERATE_HTML = YES HTML_OUTPUT = ../../html/qpcpp HTML_FILE_EXTENSION = .html -HTML_HEADER = ../../doxygen/header.html -HTML_FOOTER = ../../doxygen/footer.html +HTML_HEADER = ../../html/header.html +HTML_FOOTER = ../../html/footer.html HTML_STYLESHEET = -HTML_EXTRA_STYLESHEET = ../../doxygen/ql.css +HTML_EXTRA_STYLESHEET = ../../html/ql.css HTML_EXTRA_FILES = HTML_COLORSTYLE_HUE = 220 HTML_COLORSTYLE_SAT = 100 diff --git a/doxygen/Doxyfile-CHM b/doxygen/Doxyfile-CHM index 46b8959a..e7e35cb0 100644 --- a/doxygen/Doxyfile-CHM +++ b/doxygen/Doxyfile-CHM @@ -108,7 +108,7 @@ WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = \ +INPUT = \ main.dox \ gs.dox \ struct.dox \ @@ -191,10 +191,10 @@ IGNORE_PREFIX = GENERATE_HTML = YES HTML_OUTPUT = tmp HTML_FILE_EXTENSION = .html -HTML_HEADER = ../../doxygen/header.html -HTML_FOOTER = ../../doxygen/footer.html +HTML_HEADER = ../../html/header.html +HTML_FOOTER = ../../html/footer.html HTML_STYLESHEET = -HTML_EXTRA_STYLESHEET = ../../doxygen/ql.css +HTML_EXTRA_STYLESHEET = ../../html/ql.css HTML_EXTRA_FILES = HTML_COLORSTYLE_HUE = 220 HTML_COLORSTYLE_SAT = 100 diff --git a/doxygen/history.dox b/doxygen/history.dox index a2351db3..c9d106a5 100644 --- a/doxygen/history.dox +++ b/doxygen/history.dox @@ -24,6 +24,7 @@ Finally, this release fixes the following bugs: - bug#152 Typo (qpcpp\ports\arm7-9\qk\gnu\qk_port.s:42) prevents compilation - bug#151 QTicker compile error when #Q_EVT_CTOR is defined +- bug#154 qspy.c parses history transitions incorrectly ------------------------------------------------------------------------------ diff --git a/doxygen/metrics.dox b/doxygen/metrics.dox index de3f7e6b..2574ec2d 100644 --- a/doxygen/metrics.dox +++ b/doxygen/metrics.dox @@ -9,7 +9,7 @@ License Type: Windows Single User License Licensed To : Quantum Leaps, LLC License No. : WS2975 License Date: Dec 15, 2013 - Build Date : Sep 2 2009 Run Date: Feb 07, 2017 + Build Date : Sep 2 2009 Run Date: Feb 21, 2017 (C)1996-2009 M Squared Technologies LLC ________________________________________________________________________ @@ -813,9 +813,10 @@ Cyclomatic Complexity Vg Detail Function Base : 1 Loops while / do : 3 + Conditional if / else if: 1 Logical and ( && ) : 1 - Complexity Param 1 Return 1 Cyclo Vg 5 Total 7 - LOC 38 eLOC 36 lLOC 26 Comment 25 Lines 57 + Complexity Param 1 Return 1 Cyclo Vg 6 Total 8 + LOC 48 eLOC 45 lLOC 30 Comment 30 Lines 66 Function: QP::QHsm::top Parameters: (void * const, QEvt const * const) @@ -826,13 +827,12 @@ Parameters: (QEvt const * const e) Cyclomatic Complexity Vg Detail Function Base : 1 - Loops while / do : 5 - Loops for / foreach : 1 + Loops while / do : 4 + Loops for / foreach : 2 Conditional if / else if: 5 - Logical or ( || ) : 1 Logical and ( && ) : 1 - Complexity Param 1 Return 1 Cyclo Vg 14 Total 16 - LOC 112 eLOC 99 lLOC 63 Comment 68 Lines 154 + Complexity Param 1 Return 1 Cyclo Vg 13 Total 15 + LOC 105 eLOC 94 lLOC 61 Comment 65 Lines 146 Function: QP::QHsm::hsm_tran Parameters: (QStateHandler (&path)[MAX_NEST_DEPTH_]) @@ -865,21 +865,21 @@ ~~ Total File Summary ~~ - LOC 341 eLOC 294 lLOC 167 Comment 287 Lines 607 + LOC 344 eLOC 298 lLOC 169 Comment 289 Lines 608 ------------------------------------------------------------------------ ~~ File Functional Summary ~~ File Function Count....: 8 - Total Function LOC.....: 292 Total Function Pts LOC : 6.4 - Total Function eLOC....: 248 Total Function Pts eLOC: 5.5 - Total Function lLOC....: 161 Total Function Pts lLOC: 3.2 + Total Function LOC.....: 295 Total Function Pts LOC : 6.5 + Total Function eLOC....: 252 Total Function Pts eLOC: 5.6 + Total Function lLOC....: 163 Total Function Pts lLOC: 3.2 Total Function Params .: 8 Total Function Return .: 8 Total Cyclo Complexity : 43 Total Function Complex.: 59 ------ ----- ----- ------ ------ ----- - Max Function LOC ......: 112 Average Function LOC ..: 36.50 - Max Function eLOC .....: 99 Average Function eLOC .: 31.00 - Max Function lLOC .....: 63 Average Function lLOC .: 20.13 + Max Function LOC ......: 105 Average Function LOC ..: 36.88 + Max Function eLOC .....: 94 Average Function eLOC .: 31.50 + Max Function lLOC .....: 61 Average Function lLOC .: 20.38 ------ ----- ----- ------ ------ ----- Max Function Parameters: 2 Avg Function Parameters: 1.00 Max Function Returns ..: 1 Avg Function Returns ..: 1.00 @@ -2585,7 +2585,7 @@ ~~ Total Project Summary ~~ - LOC 5753 eLOC 5032 lLOC 2374 Comment 6652 Lines 12677 + LOC 5756 eLOC 5036 lLOC 2376 Comment 6654 Lines 12678 Average per File, metric/40 files LOC 143 eLOC 125 lLOC 59 Comment 166 Lines 316 @@ -2941,8 +2941,8 @@ Function: QP::QHsm::init Parameters: (QEvt const * const e) - Complexity Param 1 Return 1 Cyclo Vg 5 Total 7 - LOC 38 eLOC 36 lLOC 26 Comment 25 Lines 57 + Complexity Param 1 Return 1 Cyclo Vg 6 Total 8 + LOC 48 eLOC 45 lLOC 30 Comment 30 Lines 66 Function: QP::QHsm::top Parameters: (void * const, QEvt const * const) @@ -2951,8 +2951,8 @@ Function: QP::QHsm::dispatch Parameters: (QEvt const * const e) - Complexity Param 1 Return 1 Cyclo Vg 14 Total 16 - LOC 112 eLOC 99 lLOC 63 Comment 68 Lines 154 + Complexity Param 1 Return 1 Cyclo Vg 13 Total 15 + LOC 105 eLOC 94 lLOC 61 Comment 65 Lines 146 Function: QP::QHsm::hsm_tran Parameters: (QStateHandler (&path)[MAX_NEST_DEPTH_]) @@ -3649,26 +3649,26 @@ LOC 14 eLOC 11 lLOC 7 Comment 2 Lines 16 Total: Functions - LOC 3564 eLOC 2955 lLOC 1805 InCmp 419 CycloCmp 587 - Function Points FP(LOC) 62.4 FP(eLOC) 52.3 FP(lLOC) 32.2 + LOC 3567 eLOC 2959 lLOC 1807 InCmp 419 CycloCmp 587 + Function Points FP(LOC) 62.5 FP(eLOC) 52.3 FP(lLOC) 32.3 ------------------------------------------------------------------------ ~~ Project Functional Analysis ~~ - Total Functions .......: 207 Total Physical Lines ..: 4596 - Total LOC .............: 3564 Total Function Pts LOC : 62.4 - Total eLOC ............: 2955 Total Function Pts eLOC: 52.3 - Total lLOC.............: 1805 Total Function Pts lLOC: 32.2 + Total Functions .......: 207 Total Physical Lines ..: 4597 + Total LOC .............: 3567 Total Function Pts LOC : 62.5 + Total eLOC ............: 2959 Total Function Pts eLOC: 52.3 + Total lLOC.............: 1807 Total Function Pts lLOC: 32.3 Total Cyclomatic Comp. : 587 Total Interface Comp. .: 419 Total Parameters ......: 212 Total Return Points ...: 207 - Total Comment Lines ...: 2844 Total Blank Lines .....: 545 + Total Comment Lines ...: 2846 Total Blank Lines .....: 546 ------ ----- ----- ------ ------ ----- - Avg Physical Lines ....: 22.20 - Avg LOC ...............: 17.22 Avg eLOC ..............: 14.28 - Avg lLOC ..............: 8.72 Avg Cyclomatic Comp. ..: 2.84 + Avg Physical Lines ....: 22.21 + Avg LOC ...............: 17.23 Avg eLOC ..............: 14.29 + Avg lLOC ..............: 8.73 Avg Cyclomatic Comp. ..: 2.84 Avg Interface Comp. ...: 2.02 Avg Parameters ........: 1.02 - Avg Return Points .....: 1.00 Avg Comment Lines .....: 13.74 + Avg Return Points .....: 1.00 Avg Comment Lines .....: 13.75 ------ ----- ----- ------ ------ ----- Max LOC ...............: 260 Max eLOC ..............: 202 Max lLOC ..............: 125 diff --git a/examples/win32/qhsmtst/log.txt b/examples/win32/qhsmtst/log.txt index 4a500e5f..d9427315 100644 --- a/examples/win32/qhsmtst/log.txt +++ b/examples/win32/qhsmtst/log.txt @@ -1,4 +1,4 @@ -QHsmTst example, QEP 5.8.0 +QHsmTst example, QEP 5.8.2 top-INIT;s-ENTRY;s2-ENTRY;s2-INIT;s21-ENTRY;s211-ENTRY; A:s21-A;s211-EXIT;s21-EXIT;s21-ENTRY;s21-INIT;s211-ENTRY; B:s21-B;s211-EXIT;s211-ENTRY; diff --git a/source/qep_hsm.cpp b/source/qep_hsm.cpp index ef51a654..351e135b 100644 --- a/source/qep_hsm.cpp +++ b/source/qep_hsm.cpp @@ -3,14 +3,14 @@ /// @ingroup qep /// @cond ///*************************************************************************** -/// Last updated for version 5.8.0 -/// Last updated on 2016-11-19 +/// Last updated for version 5.8.2 +/// Last updated on 2017-02-08 /// /// Q u a n t u m L e a P s /// --------------------------- /// innovating embedded systems /// -/// Copyright (C) Quantum Leaps. All rights reserved. +/// Copyright (C) Quantum Leaps, LLC. All rights reserved. /// /// This program is open source software: you can redistribute it and/or /// modify it under the terms of the GNU General Public License as published @@ -136,7 +136,7 @@ QHsm::~QHsm() { void QHsm::init(QEvt const * const e) { QStateHandler t = m_state.fun; - /// @pre ctor must be executed and initial tran. NOT taken + /// @pre ctor must have been executed and initial tran NOT taken Q_REQUIRE_ID(200, (m_temp.fun != Q_STATE_CAST(0)) && (t == Q_STATE_CAST(&QHsm::top))); @@ -147,20 +147,16 @@ void QHsm::init(QEvt const * const e) { Q_ASSERT_ID(210, r == Q_RET_TRAN); QS_CRIT_STAT_ + QS_BEGIN_(QS_QEP_STATE_INIT, QS::priv_.smObjFilter, this) + QS_OBJ_(this); // this state machine object + QS_FUN_(t); // the source state + QS_FUN_(m_temp.fun); // the target of the initial transition + QS_END_() // drill down into the state hierarchy with initial transitions... do { - // transition entry path - QStateHandler path[MAX_NEST_DEPTH_]; - - // transition entry path index - int_fast8_t ip = static_cast(0); - - QS_BEGIN_(QS_QEP_STATE_INIT, QS::priv_.smObjFilter, this) - QS_OBJ_(this); // this state machine object - QS_FUN_(t); // the source state - QS_FUN_(m_temp.fun); // the target of the initial transition - QS_END_() + QStateHandler path[MAX_NEST_DEPTH_]; // tran entry path array + int_fast8_t ip = static_cast(0); // tran entry path index path[0] = m_temp.fun; (void)QEP_TRIG_(m_temp.fun, QEP_EMPTY_SIG_); @@ -179,12 +175,25 @@ void QHsm::init(QEvt const * const e) { } while (ip >= static_cast(0)); t = path[0]; // current state becomes the new source - } while (QEP_TRIG_(t, Q_INIT_SIG) == Q_RET_TRAN); - QS_BEGIN_(QS_QEP_STATE_INIT, QS::priv_.smObjFilter, this) - QS_OBJ_(this); // this state machine object - QS_FUN_(&QHsm::top); // source of initial tran (the top state) - QS_FUN_(t); // the new active state + r = QEP_TRIG_(t, Q_INIT_SIG); // execute initial transition + +#ifdef Q_SPY + if (r == Q_RET_TRAN) { + QS_BEGIN_(QS_QEP_STATE_INIT, QS::priv_.smObjFilter, this) + QS_OBJ_(this); // this state machine object + QS_FUN_(t); // the source state + QS_FUN_(m_temp.fun); // the target of the initial transition + QS_END_() + } +#endif /* Q_SPY */ + + } while (r == Q_RET_TRAN); + + QS_BEGIN_(QS_QEP_INIT_TRAN, QS::priv_.smObjFilter, this) + QS_TIME_(); // time stamp + QS_OBJ_(this); // this state machine object + QS_FUN_(t); // the new active state QS_END_() m_state.fun = t; // change the current active state @@ -222,16 +231,15 @@ QState QHsm::top(void * const, QEvt const * const) { /// void QHsm::dispatch(QEvt const * const e) { QStateHandler t = m_state.fun; + QStateHandler s; + QState r; + QS_CRIT_STAT_ /// @pre the current state must be initialized and /// the state configuration must be stable Q_REQUIRE_ID(400, (t != Q_STATE_CAST(0)) && (t == m_temp.fun)); - QStateHandler s; - QState r; - QS_CRIT_STAT_ - QS_BEGIN_(QS_QEP_DISPATCH, QS::priv_.smObjFilter, this) QS_TIME_(); // time stamp QS_SIG_(e->sig); // the signal of the event @@ -258,7 +266,7 @@ void QHsm::dispatch(QEvt const * const e) { } while (r == Q_RET_SUPER); // transition taken? - if ((r == Q_RET_TRAN) || (r == Q_RET_TRAN_HIST)) { + if (r >= Q_RET_TRAN) { QStateHandler path[MAX_NEST_DEPTH_]; path[0] = m_temp.fun; // save the target of the transition @@ -266,21 +274,32 @@ void QHsm::dispatch(QEvt const * const e) { path[2] = s; // exit current state to transition source s... - while (t != s) { + for (; t != s; t = m_temp.fun) { // exit handled? if (QEP_TRIG_(t, Q_EXIT_SIG) == Q_RET_HANDLED) { QS_BEGIN_(QS_QEP_STATE_EXIT, QS::priv_.smObjFilter, this) - QS_OBJ_(this); // this state machine object - QS_FUN_(t); // the exited state + QS_OBJ_(this); // this state machine object + QS_FUN_(t); // the exited state QS_END_() (void)QEP_TRIG_(t, QEP_EMPTY_SIG_); // find superstate of t } - t = m_temp.fun; // m_temp.fun holds the superstate } int_fast8_t ip = hsm_tran(path); // take the HSM transition +#ifdef Q_SPY + if (r == Q_RET_TRAN_HIST) { + + QS_BEGIN_(QS_QEP_TRAN_HIST, QS::priv_.smObjFilter, this) + QS_OBJ_(this); // this state machine object + QS_FUN_(t); // the source of the transition + QS_FUN_(path[0]); // the target of the tran. to history + QS_END_() + + } +#endif // Q_SPY + // retrace the entry path in reverse (desired) order... for (; ip >= static_cast(0); --ip) { QEP_ENTER_(path[ip]); // enter path[ip] @@ -299,7 +318,9 @@ void QHsm::dispatch(QEvt const * const e) { ip = static_cast(0); path[0] = m_temp.fun; + (void)QEP_TRIG_(m_temp.fun, QEP_EMPTY_SIG_); // find superstate + while (m_temp.fun != t) { ++ip; path[ip] = m_temp.fun; @@ -310,7 +331,7 @@ void QHsm::dispatch(QEvt const * const e) { // entry path must not overflow Q_ASSERT_ID(410, ip < static_cast(MAX_NEST_DEPTH_)); - // retrace the entry path in reverse (correct) order... + // retrace the entry path in reverse (correct) order... do { QEP_ENTER_(path[ip]); // enter path[ip] --ip; @@ -319,57 +340,37 @@ void QHsm::dispatch(QEvt const * const e) { t = path[0]; } + QS_BEGIN_(QS_QEP_TRAN, QS::priv_.smObjFilter, this) + QS_TIME_(); // time stamp + QS_SIG_(e->sig); // the signal of the event + QS_OBJ_(this); // this state machine object + QS_FUN_(s); // the source of the transition + QS_FUN_(t); // the new active state + QS_END_() + } + #ifdef Q_SPY - if (r == Q_RET_TRAN) { + if (r == Q_RET_HANDLED) { - QS_BEGIN_(QS_QEP_TRAN, QS::priv_.smObjFilter, this) - QS_TIME_(); // time stamp - QS_SIG_(e->sig); // the signal of the event - QS_OBJ_(this); // this state machine object - QS_FUN_(s); // the source of the transition - QS_FUN_(t); // the new active state - QS_END_() - - } - else { - - QS_BEGIN_(QS_QEP_TRAN_HIST, QS::priv_.smObjFilter, this) - QS_TIME_(); // time stamp - QS_SIG_(e->sig); // the signal of the event - QS_OBJ_(this); // this state machine object - QS_FUN_(s); // the source of the transition - QS_FUN_(t); // the new active state - QS_END_() - - } -#endif // Q_SPY + QS_BEGIN_(QS_QEP_INTERN_TRAN, QS::priv_.smObjFilter, this) + QS_TIME_(); // time stamp + QS_SIG_(e->sig); // the signal of the event + QS_OBJ_(this); // this state machine object + QS_FUN_(s); // the source state + QS_END_() } - // transition not taken else { -#ifdef Q_SPY - if (r == Q_RET_HANDLED) { - QS_BEGIN_(QS_QEP_INTERN_TRAN, QS::priv_.smObjFilter, this) - QS_TIME_(); // time stamp - QS_SIG_(e->sig); // the signal of the event - QS_OBJ_(this); // this state machine object - QS_FUN_(m_state.fun);// the state that handled the event - QS_END_() + QS_BEGIN_(QS_QEP_IGNORED, QS::priv_.smObjFilter, this) + QS_TIME_(); // time stamp + QS_SIG_(e->sig); // the signal of the event + QS_OBJ_(this); // this state machine object + QS_FUN_(m_state.fun);// the current state + QS_END_() - } - else { - - QS_BEGIN_(QS_QEP_IGNORED, QS::priv_.smObjFilter, this) - QS_TIME_(); // time stamp - QS_SIG_(e->sig); // the signal of the event - QS_OBJ_(this); // this state machine object - QS_FUN_(m_state.fun);// the current state - QS_END_() - - } -#endif } +#endif // Q_SPY m_state.fun = t; // change the current active state m_temp.fun = t; // mark the configuration as stable @@ -442,7 +443,7 @@ int_fast8_t QHsm::hsm_tran(QStateHandler (&path)[MAX_NEST_DEPTH_]) { iq = static_cast(1); // entry path must not overflow - Q_ASSERT_ID(520, + Q_ASSERT_ID(510, ip < static_cast(MAX_NEST_DEPTH_)); --ip; // do not enter the source r = Q_RET_HANDLED; // terminate the loop @@ -456,7 +457,7 @@ int_fast8_t QHsm::hsm_tran(QStateHandler (&path)[MAX_NEST_DEPTH_]) { // LCA found yet? if (iq == static_cast(0)) { // entry path must not overflow - Q_ASSERT_ID(510, + Q_ASSERT_ID(520, ip < static_cast(MAX_NEST_DEPTH_)); QEP_EXIT_(s); // exit the source