Skip to content

Commit

Permalink
7.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
quantum-leaps committed Sep 27, 2023
1 parent 80d9bcd commit 852525b
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 167 deletions.
59 changes: 0 additions & 59 deletions examples/arm-cm/dpp_efm32-slstk3401a/.dpp

This file was deleted.

7 changes: 4 additions & 3 deletions examples/posix-win32/reminder2/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##############################################################################
# Product: Makefile for QP/C++ for Windows and POSIX *HOSTS*
# Last updated for version 7.2.0
# Last updated on 2022-11-13
# Last updated for version 7.3.1
# Last updated on 2023-09-25
#
# Q u a n t u m L e a P s
# ------------------------
Expand Down Expand Up @@ -83,7 +83,8 @@ LIBS :=

# defines...
# QP_API_VERSION controls the QP API compatibility; 9999 means the latest API
DEFINES := -DQP_API_VERSION=9999
DEFINES := -DQP_API_VERSION=9999 \
$(DEF)

ifeq (,$(CONF))
CONF := dbg
Expand Down
2 changes: 1 addition & 1 deletion examples/posix-win32/reminder2/bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void QF::onCleanup(void) {
void QP::QF::onClockTick(void) {
QTimeEvt::TICK_X(0U, &l_clock_tick); // perform the QF clock tick processing
int key = QF::consoleGetKey();
if (key != 0) { /* any key pressed? */
if (key != 0U) { /* any key pressed? */
BSP_onKeyboardInput((uint8_t)key);
}
}
Expand Down
53 changes: 41 additions & 12 deletions examples/posix-win32/reminder2/reminder2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,19 @@ enum ReminderSignals {
class ReminderEvt : public QP::QEvt {
public:
std::uint32_t iter;

public:

#ifdef QEVT_DYN_CTOR
explicit ReminderEvt(std::uint32_t i) noexcept
: QEvt(QP::QEvt::DYNAMIC),
iter(i)
{}
#endif // def QEVT_DYN_CTOR
}; // class ReminderEvt
//$enddecl${Events::ReminderEvt} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

// Active object class -----------------------------------------------------..
// Active object class -------------------------------------------------------
//$declare${Components::Cruncher} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

//${Components::Cruncher} ....................................................
Expand Down Expand Up @@ -90,7 +99,7 @@ class Cruncher : public QP::QActive {
//${Components::Cruncher::SM} ................................................
Q_STATE_DEF(Cruncher, initial) {
//${Components::Cruncher::SM::initial}
(void)e; // unused parameter
Q_UNUSED_PAR(e);

QS_FUN_DICTIONARY(&Cruncher::processing);
QS_FUN_DICTIONARY(&Cruncher::final);
Expand All @@ -104,31 +113,41 @@ Q_STATE_DEF(Cruncher, processing) {
switch (e->sig) {
//${Components::Cruncher::SM::processing}
case Q_ENTRY_SIG: {
#ifdef QEVT_DYN_CTOR
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG, 0U);
#else
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
reminder->iter = 0;
reminder->iter = 0U;
#endif

POST(reminder, this);
m_sum = 0.0;
status_ = Q_RET_HANDLED;
break;
}
//${Components::Cruncher::SM::processing::CRUNCH}
case CRUNCH_SIG: {
uint32_t i = Q_EVT_CAST(ReminderEvt)->iter;
uint32_t n = i;
std::uint32_t i = Q_EVT_CAST(ReminderEvt)->iter;
std::uint32_t n = i;
i += 100U;
for (; n < i; ++n) {
if ((n & 1) == 0) {
m_sum += 1.0/(2*n + 1);
m_sum += 1.0/(2U*n + 1U);
}
else {
m_sum -= 1.0/(2*n + 1);
m_sum -= 1.0/(2U*n + 1U);
}
}
//${Components::Cruncher::SM::processing::CRUNCH::[i<0x07000000U]}
if (i < 0x07000000U) {
#ifdef QEVT_DYN_CTOR
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG, i);
#else
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
reminder->iter = i;
POST(reminder, me);
#endif

POST(reminder, this);
status_ = Q_RET_HANDLED;
}
//${Components::Cruncher::SM::processing::CRUNCH::[else]}
Expand Down Expand Up @@ -189,7 +208,7 @@ int main(int argc, char *argv[]) {
PRINTF_S("Reminder state pattern\nQP version: %s\n"
"Press 'e' to echo the current value...\n"
"Press ESC to quit...\n",
QP::versionStr);
QP_VERSION_STR);

BSP_init(argc, argv); // initialize the BSP
QF::init(); // initialize the framework and the underlying RT kernel
Expand All @@ -210,14 +229,24 @@ int main(int argc, char *argv[]) {
void BSP_onKeyboardInput(uint8_t key) {
switch (key) {
case 'e': {
static QEvt const echoEvt(ECHO_SIG);
l_cruncher.POST(&echoEvt, nullptr);
// NOTE:
// The following Q_NEW_X() allocation might potentially fail
// but this is acceptable becasue the "ECHO" event is not
// considered critical. This code illustrates the Q_NEW_X()
// API and its use.
#ifdef QEVT_DYN_CTOR
QEvt const *echoEvt = Q_NEW_X(QEvt, 2U, ECHO_SIG, QEvt::DYNAMIC);
#else
QEvt const *echoEvt = Q_NEW_X(QEvt, 2U, ECHO_SIG);
#endif
if (echoEvt != nullptr) { // event allocated successfully?
l_cruncher.POST(echoEvt, nullptr);
}
break;
}
case '\033': { // ESC pressed?
// NOTE: this constant event is statically pre-allocated.
// It can be posted/published as any other event.
//
static QEvt const terminateEvt(TERMINATE_SIG);
l_cruncher.POST(&terminateEvt, nullptr);
break;
Expand Down
56 changes: 42 additions & 14 deletions examples/posix-win32/reminder2/reminder2.qm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
<attribute name="iter" type="std::uint32_t" visibility="0x00" properties="0x00">
<documentation>the next iteration to perform</documentation>
</attribute>
<!--${Events::ReminderEvt::ReminderEvt}-->
<operation name="ReminderEvt?def QEVT_DYN_CTOR" type="explicit" visibility="0x00" properties="0x02">
<specifiers>noexcept</specifiers>
<!--${Events::ReminderEvt::ReminderEvt::i}-->
<parameter name="i" type="std::uint32_t"/>
<code> : QEvt(QP::QEvt::DYNAMIC),
iter(i)</code>
</operation>
</class>
</package>
<!--${Components}-->
Expand All @@ -32,28 +40,33 @@
<statechart properties="0x02">
<!--${Components::Cruncher::SM::initial}-->
<initial target="../1">
<action>(void)e; // unused parameter</action>
<action>Q_UNUSED_PAR(e);</action>
<initial_glyph conn="2,2,5,1,44,6,-2">
<action box="0,-2,6,2"/>
</initial_glyph>
</initial>
<!--${Components::Cruncher::SM::processing}-->
<state name="processing">
<entry>ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
reminder-&gt;iter = 0;
<entry>#ifdef QEVT_DYN_CTOR
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG, 0U);
#else
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
reminder-&gt;iter = 0U;
#endif

POST(reminder, this);
m_sum = 0.0;</entry>
<!--${Components::Cruncher::SM::processing::CRUNCH}-->
<tran trig="CRUNCH">
<action>uint32_t i = Q_EVT_CAST(ReminderEvt)-&gt;iter;
uint32_t n = i;
<action>std::uint32_t i = Q_EVT_CAST(ReminderEvt)-&gt;iter;
std::uint32_t n = i;
i += 100U;
for (; n &lt; i; ++n) {
if ((n &amp; 1) == 0) {
m_sum += 1.0/(2*n + 1);
m_sum += 1.0/(2U*n + 1U);
}
else {
m_sum -= 1.0/(2*n + 1);
m_sum -= 1.0/(2U*n + 1U);
}
}</action>
<!--${Components::Cruncher::SM::processing::CRUNCH::[else]}-->
Expand All @@ -67,9 +80,14 @@ for (; n &lt; i; ++n) {
<!--${Components::Cruncher::SM::processing::CRUNCH::[i<0x07000000U]}-->
<choice>
<guard>i &lt; 0x07000000U</guard>
<action>ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
<action>#ifdef QEVT_DYN_CTOR
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG, i);
#else
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
reminder-&gt;iter = i;
POST(reminder, me);</action>
#endif

POST(reminder, this);</action>
<choice_glyph conn="24,18,4,-1,-4,14">
<action box="0,-6,17,2"/>
</choice_glyph>
Expand Down Expand Up @@ -130,7 +148,7 @@ enum ReminderSignals {
//............................................................................
$declare${Events::ReminderEvt}

// Active object class -----------------------------------------------------..
// Active object class -------------------------------------------------------
$declare${Components::Cruncher}

$define${Components::Cruncher}
Expand All @@ -147,7 +165,7 @@ int main(int argc, char *argv[]) {
PRINTF_S(&quot;Reminder state pattern\nQP version: %s\n&quot;
&quot;Press 'e' to echo the current value...\n&quot;
&quot;Press ESC to quit...\n&quot;,
QP::versionStr);
QP_VERSION_STR);

BSP_init(argc, argv); // initialize the BSP
QF::init(); // initialize the framework and the underlying RT kernel
Expand All @@ -168,14 +186,24 @@ int main(int argc, char *argv[]) {
void BSP_onKeyboardInput(uint8_t key) {
switch (key) {
case 'e': {
static QEvt const echoEvt(ECHO_SIG);
l_cruncher.POST(&amp;echoEvt, nullptr);
// NOTE:
// The following Q_NEW_X() allocation might potentially fail
// but this is acceptable becasue the &quot;ECHO&quot; event is not
// considered critical. This code illustrates the Q_NEW_X()
// API and its use.
#ifdef QEVT_DYN_CTOR
QEvt const *echoEvt = Q_NEW_X(QEvt, 2U, ECHO_SIG, QEvt::DYNAMIC);
#else
QEvt const *echoEvt = Q_NEW_X(QEvt, 2U, ECHO_SIG);
#endif
if (echoEvt != nullptr) { // event allocated successfully?
l_cruncher.POST(echoEvt, nullptr);
}
break;
}
case '\033': { // ESC pressed?
// NOTE: this constant event is statically pre-allocated.
// It can be posted/published as any other event.
//
static QEvt const terminateEvt(TERMINATE_SIG);
l_cruncher.POST(&amp;terminateEvt, nullptr);
break;
Expand Down
59 changes: 0 additions & 59 deletions examples/qutest/dpp/src/.dpp

This file was deleted.

Loading

0 comments on commit 852525b

Please sign in to comment.