Added "QUIT" (QP Unit Internal Testing); refined AO encapsulation in examples: workstation/dpp and arm-cm/game
This commit is contained in:
MMS 2021-02-12 15:42:38 -05:00
parent 499889baff
commit 428d023cf2
28 changed files with 901 additions and 453 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -51,50 +51,6 @@ enum GameSignals { /* signals used in the game */
MAX_SIG /* the last signal (keep always last) */ MAX_SIG /* the last signal (keep always last) */
}; };
/*.$declare${Events::ObjectPosEvt} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${Events::ObjectPosEvt} .................................................*/
typedef struct {
/* protected: */
QEvt super;
/* public: */
uint8_t x;
uint8_t y;
} ObjectPosEvt;
/*.$enddecl${Events::ObjectPosEvt} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${Events::ObjectImageEvt} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${Events::ObjectImageEvt} ...............................................*/
typedef struct {
/* protected: */
QEvt super;
/* public: */
uint8_t x;
int8_t y;
uint8_t bmp;
} ObjectImageEvt;
/*.$enddecl${Events::ObjectImageEvt} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${Events::MineEvt} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${Events::MineEvt} ......................................................*/
typedef struct {
/* protected: */
QEvt super;
/* public: */
uint8_t id;
} MineEvt;
/*.$enddecl${Events::MineEvt} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${Events::ScoreEvt} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${Events::ScoreEvt} .....................................................*/
typedef struct {
/* protected: */
QEvt super;
/* public: */
uint16_t score;
} ScoreEvt;
/*.$enddecl${Events::ScoreEvt} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#define GAME_TUNNEL_WIDTH BSP_SCREEN_WIDTH #define GAME_TUNNEL_WIDTH BSP_SCREEN_WIDTH
#define GAME_TUNNEL_HEIGHT (BSP_SCREEN_HEIGHT - 10U) #define GAME_TUNNEL_HEIGHT (BSP_SCREEN_HEIGHT - 10U)
#define GAME_MINES_MAX 5U #define GAME_MINES_MAX 5U
@ -119,45 +75,62 @@ enum GameBitmapIds {
MAX_BMP MAX_BMP
}; };
/* active objects' "constructors" */ /* declare shared facilities */
/*.$declare${AOs::Tunnel_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$declare${Shared} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Tunnel_ctor} .....................................................*/ /*.${Shared::ObjectPosEvt} .................................................*/
void Tunnel_ctor(void); typedef struct {
/*.$enddecl${AOs::Tunnel_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /* protected: */
/*.$declare${AOs::Ship_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ QEvt super;
/*.${AOs::Ship_ctor} .......................................................*/
void Ship_ctor(void);
/*.$enddecl${AOs::Ship_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Missile_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Missile_ctor} ....................................................*/
void Missile_ctor(void);
/*.$enddecl${AOs::Missile_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* instantiation of the Mines orthogonal components */ /* public: */
/*.$declare${AOs::Mine1_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ uint8_t x;
/*.${AOs::Mine1_ctor} ......................................................*/ uint8_t y;
QHsm * Mine1_ctor(uint8_t id); } ObjectPosEvt;
/*.$enddecl${AOs::Mine1_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.${Shared::ObjectImageEvt} ...............................................*/
/*.$declare${AOs::Mine2_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ typedef struct {
/*.${AOs::Mine2_ctor} ......................................................*/ /* protected: */
QHsm * Mine2_ctor(uint8_t id); QEvt super;
/*.$enddecl${AOs::Mine2_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* opaque pointers to active objects in the application */ /* public: */
/*.$declare${AOs::AO_Tunnel} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ uint8_t x;
int8_t y;
uint8_t bmp;
} ObjectImageEvt;
/*.${Shared::MineEvt} ......................................................*/
typedef struct {
/* protected: */
QEvt super;
/* public: */
uint8_t id;
} MineEvt;
/*.${Shared::ScoreEvt} .....................................................*/
typedef struct {
/* protected: */
QEvt super;
/* public: */
uint16_t score;
} ScoreEvt;
/* opaque AO pointer */ /* opaque AO pointer */
extern QActive * const AO_Tunnel; extern QActive * const AO_Tunnel;
/*.$enddecl${AOs::AO_Tunnel} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Ship} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/* opaque AO pointer */ /* opaque AO pointer */
extern QActive * const AO_Ship; extern QActive * const AO_Ship;
/*.$enddecl${AOs::AO_Ship} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Missile} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/* opaque AO pointer */ /* opaque AO pointer */
extern QActive * const AO_Missile; extern QActive * const AO_Missile;
/*.$enddecl${AOs::AO_Missile} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.${Shared::Tunnel_ctor_call} .............................................*/
void Tunnel_ctor_call(void);
/*.${Shared::Ship_ctor_call} ...............................................*/
void Ship_ctor_call(void);
/*.${Shared::Missile_ctor_call} ............................................*/
void Missile_ctor_call(void);
/*.${Shared::Mine1_ctor_call} ..............................................*/
QHsm * Mine1_ctor_call(uint8_t id);
/*.${Shared::Mine2_ctor_call} ..............................................*/
QHsm * Mine2_ctor_call(uint8_t id);
/*.$enddecl${Shared} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#endif /* GAME_H */ #endif /* GAME_H */

View File

@ -5,34 +5,77 @@
NOTE: Requries QP6.</documentation> NOTE: Requries QP6.</documentation>
<!--${qpc}--> <!--${qpc}-->
<framework name="qpc"/> <framework name="qpc"/>
<!--${Events}--> <!--${Shared}-->
<package name="Events" stereotype="0x01"> <package name="Shared" stereotype="0x01">
<!--${Events::ObjectPosEvt}--> <!--${Shared::ObjectPosEvt}-->
<class name="ObjectPosEvt" superclass="qpc::QEvt"> <class name="ObjectPosEvt" superclass="qpc::QEvt">
<!--${Events::ObjectPosEvt::x}--> <!--${Shared::ObjectPosEvt::x}-->
<attribute name="x" type="uint8_t" visibility="0x00" properties="0x00"/> <attribute name="x" type="uint8_t" visibility="0x00" properties="0x00"/>
<!--${Events::ObjectPosEvt::y}--> <!--${Shared::ObjectPosEvt::y}-->
<attribute name="y" type="uint8_t" visibility="0x00" properties="0x00"/> <attribute name="y" type="uint8_t" visibility="0x00" properties="0x00"/>
</class> </class>
<!--${Events::ObjectImageEvt}--> <!--${Shared::ObjectImageEvt}-->
<class name="ObjectImageEvt" superclass="qpc::QEvt"> <class name="ObjectImageEvt" superclass="qpc::QEvt">
<!--${Events::ObjectImageEvt::x}--> <!--${Shared::ObjectImageEvt::x}-->
<attribute name="x" type="uint8_t" visibility="0x00" properties="0x00"/> <attribute name="x" type="uint8_t" visibility="0x00" properties="0x00"/>
<!--${Events::ObjectImageEvt::y}--> <!--${Shared::ObjectImageEvt::y}-->
<attribute name="y" type="int8_t" visibility="0x00" properties="0x00"/> <attribute name="y" type="int8_t" visibility="0x00" properties="0x00"/>
<!--${Events::ObjectImageEvt::bmp}--> <!--${Shared::ObjectImageEvt::bmp}-->
<attribute name="bmp" type="uint8_t" visibility="0x00" properties="0x00"/> <attribute name="bmp" type="uint8_t" visibility="0x00" properties="0x00"/>
</class> </class>
<!--${Events::MineEvt}--> <!--${Shared::MineEvt}-->
<class name="MineEvt" superclass="qpc::QEvt"> <class name="MineEvt" superclass="qpc::QEvt">
<!--${Events::MineEvt::id}--> <!--${Shared::MineEvt::id}-->
<attribute name="id" type="uint8_t" visibility="0x00" properties="0x00"/> <attribute name="id" type="uint8_t" visibility="0x00" properties="0x00"/>
</class> </class>
<!--${Events::ScoreEvt}--> <!--${Shared::ScoreEvt}-->
<class name="ScoreEvt" superclass="qpc::QEvt"> <class name="ScoreEvt" superclass="qpc::QEvt">
<!--${Events::ScoreEvt::score}--> <!--${Shared::ScoreEvt::score}-->
<attribute name="score" type="uint16_t" visibility="0x00" properties="0x00"/> <attribute name="score" type="uint16_t" visibility="0x00" properties="0x00"/>
</class> </class>
<!--${Shared::AO_Tunnel}-->
<attribute name="AO_Tunnel" type="QActive * const" visibility="0x00" properties="0x00">
<documentation>/* opaque AO pointer */</documentation>
<code>= &amp;Tunnel_inst.super;</code>
</attribute>
<!--${Shared::AO_Ship}-->
<attribute name="AO_Ship" type="QActive * const" visibility="0x00" properties="0x00">
<documentation>/* opaque AO pointer */</documentation>
<code>= &amp;Ship_inst.super;</code>
</attribute>
<!--${Shared::AO_Missile}-->
<attribute name="AO_Missile" type="QActive * const" visibility="0x00" properties="0x00">
<documentation>/* opaque AO pointer */</documentation>
<code>= &amp;Missile_inst.super;</code>
</attribute>
<!--${Shared::Tunnel_ctor_call}-->
<operation name="Tunnel_ctor_call" type="void" visibility="0x00" properties="0x01">
<code>Tunnel_ctor(&amp;Tunnel_inst);</code>
</operation>
<!--${Shared::Ship_ctor_call}-->
<operation name="Ship_ctor_call" type="void" visibility="0x00" properties="0x01">
<code>Ship_ctor(&amp;Ship_inst);</code>
</operation>
<!--${Shared::Missile_ctor_call}-->
<operation name="Missile_ctor_call" type="void" visibility="0x00" properties="0x01">
<code>Missile_ctor(&amp;Missile_inst);</code>
</operation>
<!--${Shared::Mine1_ctor_call}-->
<operation name="Mine1_ctor_call" type="QHsm *" visibility="0x00" properties="0x01">
<!--${Shared::Mine1_ctor_call::id}-->
<parameter name="id" type="uint8_t"/>
<code>Q_REQUIRE(id &lt; GAME_MINES_MAX);
Mine1_ctor(&amp;Mine1_inst[id]);
return &amp;Mine1_inst[id].super;</code>
</operation>
<!--${Shared::Mine2_ctor_call}-->
<operation name="Mine2_ctor_call" type="QHsm *" visibility="0x00" properties="0x01">
<!--${Shared::Mine2_ctor_call::id}-->
<parameter name="id" type="uint8_t"/>
<code>Q_REQUIRE(id &lt; GAME_MINES_MAX);
Mine2_ctor(&amp;Mine2_inst[id]);
return &amp;Mine2_inst[id].super;</code>
</operation>
</package> </package>
<!--${AOs}--> <!--${AOs}-->
<package name="AOs" stereotype="0x02"> <package name="AOs" stereotype="0x02">
@ -61,6 +104,10 @@ NOTE: Requries QP6.</documentation>
<attribute name="wall_thickness_bottom" type="uint8_t" visibility="0x02" properties="0x00"/> <attribute name="wall_thickness_bottom" type="uint8_t" visibility="0x02" properties="0x00"/>
<!--${AOs::Tunnel::wall_gap}--> <!--${AOs::Tunnel::wall_gap}-->
<attribute name="wall_gap" type="uint8_t" visibility="0x02" properties="0x00"/> <attribute name="wall_gap" type="uint8_t" visibility="0x02" properties="0x00"/>
<!--${AOs::Tunnel::inst}-->
<attribute name="inst" type="Tunnel" visibility="0x00" properties="0x01">
<documentation>static instance (Singleton)</documentation>
</attribute>
<!--${AOs::Tunnel::advance}--> <!--${AOs::Tunnel::advance}-->
<operation name="advance" type="void" visibility="0x02" properties="0x00"> <operation name="advance" type="void" visibility="0x02" properties="0x00">
<code>uint32_t rnd; <code>uint32_t rnd;
@ -157,6 +204,21 @@ for (n = 0U; n &lt; GAME_MINES_MAX; ++n) {
QHSM_DISPATCH(me-&gt;mines[n], e, me-&gt;super.prio); QHSM_DISPATCH(me-&gt;mines[n], e, me-&gt;super.prio);
} }
}</code> }</code>
</operation>
<!--${AOs::Tunnel::ctor}-->
<operation name="ctor" type="void" visibility="0x00" properties="0x00">
<documentation>constructor</documentation>
<code>uint8_t n;
QActive_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;Tunnel_initial));
QTimeEvt_ctorX(&amp;me-&gt;blinkTimeEvt, &amp;me-&gt;super, BLINK_TIMEOUT_SIG, 0U);
QTimeEvt_ctorX(&amp;me-&gt;screenTimeEvt, &amp;me-&gt;super, SCREEN_TIMEOUT_SIG, 0U);
for (n = 0; n &lt; GAME_MINES_MAX; ++n) {
me-&gt;mine1_pool[n] = Mine1_ctor_call(n); /* instantiate Mine1 */
me-&gt;mine2_pool[n] = Mine2_ctor_call(n); /* instantiate Mine2 */
me-&gt;mines[n] = (QHsm *)0; /* mine 'n' is unused */
}
me-&gt;last_mine_x = 0; /* the last mine at the right edge of the tunnel */
me-&gt;last_mine_y = 0;</code>
</operation> </operation>
<!--${AOs::Tunnel::SM}--> <!--${AOs::Tunnel::SM}-->
<statechart properties="0x03"> <statechart properties="0x03">
@ -174,8 +236,8 @@ QActive_subscribe(&amp;me-&gt;super, PLAYER_TRIGGER_SIG);
QActive_subscribe(&amp;me-&gt;super, PLAYER_QUIT_SIG); QActive_subscribe(&amp;me-&gt;super, PLAYER_QUIT_SIG);
/* object dictionaries... */ /* object dictionaries... */
QS_OBJ_DICTIONARY(&amp;l_tunnel.blinkTimeEvt); QS_OBJ_DICTIONARY(&amp;Tunnel_inst.blinkTimeEvt);
QS_OBJ_DICTIONARY(&amp;l_tunnel.screenTimeEvt); QS_OBJ_DICTIONARY(&amp;Tunnel_inst.screenTimeEvt);
/* local signals... */ /* local signals... */
QS_SIG_DICTIONARY(BLINK_TIMEOUT_SIG, me); QS_SIG_DICTIONARY(BLINK_TIMEOUT_SIG, me);
@ -539,6 +601,17 @@ QF_stop(); /* stop QF and cleanup */</entry>
<attribute name="exp_ctr" type="uint8_t" visibility="0x02" properties="0x00"/> <attribute name="exp_ctr" type="uint8_t" visibility="0x02" properties="0x00"/>
<!--${AOs::Ship::score}--> <!--${AOs::Ship::score}-->
<attribute name="score" type="uint16_t" visibility="0x02" properties="0x00"/> <attribute name="score" type="uint16_t" visibility="0x02" properties="0x00"/>
<!--${AOs::Ship::inst}-->
<attribute name="inst" type="Ship" visibility="0x00" properties="0x01">
<documentation>static instance (Singleton)</documentation>
</attribute>
<!--${AOs::Ship::ctor}-->
<operation name="ctor" type="void" visibility="0x00" properties="0x00">
<documentation>constructor</documentation>
<code>QActive_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;Ship_initial));
me-&gt;x = GAME_SHIP_X;
me-&gt;y = (GAME_SHIP_Y &lt;&lt; 2);</code>
</operation>
<!--${AOs::Ship::SM}--> <!--${AOs::Ship::SM}-->
<statechart properties="0x03"> <statechart properties="0x03">
<!--${AOs::Ship::SM::initial}--> <!--${AOs::Ship::SM::initial}-->
@ -706,6 +779,15 @@ QACTIVE_POST(AO_Tunnel, (QEvt *)gameOver, me);</action>
<attribute name="y" type="uint8_t" visibility="0x02" properties="0x00"/> <attribute name="y" type="uint8_t" visibility="0x02" properties="0x00"/>
<!--${AOs::Missile::exp_ctr}--> <!--${AOs::Missile::exp_ctr}-->
<attribute name="exp_ctr" type="uint8_t" visibility="0x02" properties="0x00"/> <attribute name="exp_ctr" type="uint8_t" visibility="0x02" properties="0x00"/>
<!--${AOs::Missile::inst}-->
<attribute name="inst" type="Missile" visibility="0x00" properties="0x01">
<documentation>static instance (Singleton)</documentation>
</attribute>
<!--${AOs::Missile::ctor}-->
<operation name="ctor" type="void" visibility="0x00" properties="0x00">
<documentation>constructor</documentation>
<code>QActive_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;Missile_initial));</code>
</operation>
<!--${AOs::Missile::SM}--> <!--${AOs::Missile::SM}-->
<statechart properties="0x03"> <statechart properties="0x03">
<!--${AOs::Missile::SM::initial}--> <!--${AOs::Missile::SM::initial}-->
@ -828,6 +910,16 @@ QACTIVE_POST(AO_Tunnel, (QEvt *)oie, me);</action>
<attribute name="y" type="uint8_t" visibility="0x02" properties="0x00"/> <attribute name="y" type="uint8_t" visibility="0x02" properties="0x00"/>
<!--${AOs::Mine1::exp_ctr}--> <!--${AOs::Mine1::exp_ctr}-->
<attribute name="exp_ctr" type="uint8_t" visibility="0x00" properties="0x00"/> <attribute name="exp_ctr" type="uint8_t" visibility="0x00" properties="0x00"/>
<!--${AOs::Mine1::inst[GAME_MINES_MAX]}-->
<attribute name="inst[GAME_MINES_MAX]" type="Mine1" visibility="0x00" properties="0x01">
<documentation>static instances (Singletons)</documentation>
</attribute>
<!--${AOs::Mine1::ctor}-->
<operation name="ctor" type="void" visibility="0x00" properties="0x00">
<documentation>constructor</documentation>
<code>/* superclass' ctor */
QHsm_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;Mine1_initial));</code>
</operation>
<!--${AOs::Mine1::SM}--> <!--${AOs::Mine1::SM}-->
<statechart properties="0x01"> <statechart properties="0x01">
<!--${AOs::Mine1::SM::initial}--> <!--${AOs::Mine1::SM::initial}-->
@ -835,11 +927,11 @@ QACTIVE_POST(AO_Tunnel, (QEvt *)oie, me);</action>
<action>static uint8_t dict_sent; <action>static uint8_t dict_sent;
if (!dict_sent) { if (!dict_sent) {
QS_OBJ_DICTIONARY(&amp;l_mine1[0]); /* obj. dictionaries for Mine1 pool */ QS_OBJ_DICTIONARY(&amp;Mine1_inst[0]);
QS_OBJ_DICTIONARY(&amp;l_mine1[1]); QS_OBJ_DICTIONARY(&amp;Mine1_inst[1]);
QS_OBJ_DICTIONARY(&amp;l_mine1[2]); QS_OBJ_DICTIONARY(&amp;Mine1_inst[2]);
QS_OBJ_DICTIONARY(&amp;l_mine1[3]); QS_OBJ_DICTIONARY(&amp;Mine1_inst[3]);
QS_OBJ_DICTIONARY(&amp;l_mine1[4]); QS_OBJ_DICTIONARY(&amp;Mine1_inst[4]);
QS_FUN_DICTIONARY(&amp;Mine1_initial);/*fun. dictionaries for Mine1 HSM */ QS_FUN_DICTIONARY(&amp;Mine1_initial);/*fun. dictionaries for Mine1 HSM */
QS_FUN_DICTIONARY(&amp;Mine1_unused); QS_FUN_DICTIONARY(&amp;Mine1_unused);
@ -1014,6 +1106,16 @@ QACTIVE_POST(AO_Tunnel, (QEvt *)oie, me);</action>
<attribute name="y" type="uint8_t" visibility="0x02" properties="0x00"/> <attribute name="y" type="uint8_t" visibility="0x02" properties="0x00"/>
<!--${AOs::Mine2::exp_ctr}--> <!--${AOs::Mine2::exp_ctr}-->
<attribute name="exp_ctr" type="uint8_t" visibility="0x00" properties="0x00"/> <attribute name="exp_ctr" type="uint8_t" visibility="0x00" properties="0x00"/>
<!--${AOs::Mine2::inst[GAME_MINES_MAX]}-->
<attribute name="inst[GAME_MINES_MAX]" type="Mine2" visibility="0x00" properties="0x01">
<documentation>static instances (Singletons)</documentation>
</attribute>
<!--${AOs::Mine2::ctor}-->
<operation name="ctor" type="void" visibility="0x00" properties="0x00">
<documentation>constructor</documentation>
<code>/* superclass' ctor */
QHsm_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;Mine2_initial));</code>
</operation>
<!--${AOs::Mine2::SM}--> <!--${AOs::Mine2::SM}-->
<statechart properties="0x01"> <statechart properties="0x01">
<!--${AOs::Mine2::SM::initial}--> <!--${AOs::Mine2::SM::initial}-->
@ -1022,11 +1124,11 @@ QACTIVE_POST(AO_Tunnel, (QEvt *)oie, me);</action>
if (!dict_sent) { if (!dict_sent) {
/* object dictionaries for Mine2 pool... */ /* object dictionaries for Mine2 pool... */
QS_OBJ_DICTIONARY(&amp;l_mine2[0]); QS_OBJ_DICTIONARY(&amp;Mine2_inst[0]);
QS_OBJ_DICTIONARY(&amp;l_mine2[1]); QS_OBJ_DICTIONARY(&amp;Mine2_inst[1]);
QS_OBJ_DICTIONARY(&amp;l_mine2[2]); QS_OBJ_DICTIONARY(&amp;Mine2_inst[2]);
QS_OBJ_DICTIONARY(&amp;l_mine2[3]); QS_OBJ_DICTIONARY(&amp;Mine2_inst[3]);
QS_OBJ_DICTIONARY(&amp;l_mine2[4]); QS_OBJ_DICTIONARY(&amp;Mine2_inst[4]);
/*function dictionaries for Mine2 HSM... */ /*function dictionaries for Mine2 HSM... */
QS_FUN_DICTIONARY(&amp;Mine2_initial); QS_FUN_DICTIONARY(&amp;Mine2_initial);
@ -1199,70 +1301,6 @@ QACTIVE_POST(AO_Tunnel, (QEvt *)oie, me);</action>
<state_diagram size="53,68"/> <state_diagram size="53,68"/>
</statechart> </statechart>
</class> </class>
<!--${AOs::AO_Tunnel}-->
<attribute name="AO_Tunnel" type="QActive * const" visibility="0x00" properties="0x00">
<documentation>/* opaque AO pointer */</documentation>
<code>= &amp;l_tunnel.super;</code>
</attribute>
<!--${AOs::AO_Ship}-->
<attribute name="AO_Ship" type="QActive * const" visibility="0x00" properties="0x00">
<documentation>/* opaque AO pointer */</documentation>
<code>= &amp;l_ship.super;</code>
</attribute>
<!--${AOs::AO_Missile}-->
<attribute name="AO_Missile" type="QActive * const" visibility="0x00" properties="0x00">
<documentation>/* opaque AO pointer */</documentation>
<code>= &amp;l_missile.super;</code>
</attribute>
<!--${AOs::Tunnel_ctor}-->
<operation name="Tunnel_ctor" type="void" visibility="0x00" properties="0x01">
<code>uint8_t n;
Tunnel *me = &amp;l_tunnel;
QActive_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;Tunnel_initial));
QTimeEvt_ctorX(&amp;me-&gt;blinkTimeEvt, &amp;me-&gt;super, BLINK_TIMEOUT_SIG, 0U);
QTimeEvt_ctorX(&amp;me-&gt;screenTimeEvt, &amp;me-&gt;super, SCREEN_TIMEOUT_SIG, 0U);
for (n = 0; n &lt; GAME_MINES_MAX; ++n) {
me-&gt;mine1_pool[n] = Mine1_ctor(n); /* instantiate Mine1 in the pool */
me-&gt;mine2_pool[n] = Mine2_ctor(n); /* instantiate Mine2 in the pool */
me-&gt;mines[n] = (QHsm *)0; /* mine 'n' is unused */
}
me-&gt;last_mine_x = 0; /* the last mine at the right edge of the tunnel */
me-&gt;last_mine_y = 0;</code>
</operation>
<!--${AOs::Ship_ctor}-->
<operation name="Ship_ctor" type="void" visibility="0x00" properties="0x01">
<code>Ship *me = &amp;l_ship;
QActive_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;Ship_initial));
me-&gt;x = GAME_SHIP_X;
me-&gt;y = (GAME_SHIP_Y &lt;&lt; 2);</code>
</operation>
<!--${AOs::Missile_ctor}-->
<operation name="Missile_ctor" type="void" visibility="0x00" properties="0x01">
<code>Missile *me = &amp;l_missile;
QActive_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;Missile_initial));</code>
</operation>
<!--${AOs::Mine1_ctor}-->
<operation name="Mine1_ctor" type="QHsm *" visibility="0x00" properties="0x01">
<!--${AOs::Mine1_ctor::id}-->
<parameter name="id" type="uint8_t"/>
<code>Mine1 *me;
Q_REQUIRE(id &lt; GAME_MINES_MAX);
me = &amp;l_mine1[id];
/* superclass' ctor */
QHsm_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;Mine1_initial));
return (QHsm *)me;</code>
</operation>
<!--${AOs::Mine2_ctor}-->
<operation name="Mine2_ctor" type="QHsm *" visibility="0x00" properties="0x01">
<!--${AOs::Mine2_ctor::id}-->
<parameter name="id" type="uint8_t"/>
<code>Mine2 *me;
Q_REQUIRE(id &lt; GAME_MINES_MAX);
me = &amp;l_mine2[id];
/* superclass' ctor */
QHsm_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;Mine2_initial));
return (QHsm *)me;</code>
</operation>
</package> </package>
<!--${.}--> <!--${.}-->
<directory name="."> <directory name=".">
@ -1303,11 +1341,6 @@ enum GameSignals { /* signals used in the game */
MAX_SIG /* the last signal (keep always last) */ MAX_SIG /* the last signal (keep always last) */
}; };
$declare${Events::ObjectPosEvt}
$declare${Events::ObjectImageEvt}
$declare${Events::MineEvt}
$declare${Events::ScoreEvt}
#define GAME_TUNNEL_WIDTH BSP_SCREEN_WIDTH #define GAME_TUNNEL_WIDTH BSP_SCREEN_WIDTH
#define GAME_TUNNEL_HEIGHT (BSP_SCREEN_HEIGHT - 10U) #define GAME_TUNNEL_HEIGHT (BSP_SCREEN_HEIGHT - 10U)
#define GAME_MINES_MAX 5U #define GAME_MINES_MAX 5U
@ -1332,19 +1365,8 @@ enum GameBitmapIds {
MAX_BMP MAX_BMP
}; };
/* active objects' &quot;constructors&quot; */ /* declare shared facilities */
$declare${AOs::Tunnel_ctor} $declare${Shared}
$declare${AOs::Ship_ctor}
$declare${AOs::Missile_ctor}
/* instantiation of the Mines orthogonal components */
$declare${AOs::Mine1_ctor}
$declare${AOs::Mine2_ctor}
/* opaque pointers to active objects in the application */
$declare${AOs::AO_Tunnel}
$declare${AOs::AO_Ship}
$declare${AOs::AO_Missile}
#endif /* GAME_H */ #endif /* GAME_H */
</text> </text>
@ -1359,13 +1381,12 @@ $declare${AOs::AO_Missile}
/* local objects -----------------------------------------------------------*/ /* local objects -----------------------------------------------------------*/
$declare${AOs::Missile} $declare${AOs::Missile}
static Missile l_missile; /* the sole instance of the Missile active object */
/* Public-scope objects ----------------------------------------------------*/ /* Public-scope objects ----------------------------------------------------*/
$define${AOs::AO_Missile} $define${Shared::AO_Missile}
/* Active object definition ------------------------------------------------*/ /* Active object definition ------------------------------------------------*/
$define${AOs::Missile_ctor} $define${Shared::Missile_ctor_call}
$define${AOs::Missile}</text> $define${AOs::Missile}</text>
</file> </file>
<!--${.::ship.c}--> <!--${.::ship.c}-->
@ -1382,14 +1403,11 @@ $define${AOs::Missile}</text>
/* encapsulated delcaration of the Ship active object ----------------------*/ /* encapsulated delcaration of the Ship active object ----------------------*/
$declare${AOs::Ship} $declare${AOs::Ship}
/* local objects -----------------------------------------------------------*/
static Ship l_ship; /* the sole instance of the Ship active object */
/* Public-scope objects ----------------------------------------------------*/ /* Public-scope objects ----------------------------------------------------*/
$define${AOs::AO_Ship} $define${Shared::AO_Ship}
/* Active object definition ------------------------------------------------*/ /* Active object definition ------------------------------------------------*/
$define${AOs::Ship_ctor} $define${Shared::Ship_ctor_call}
$define${AOs::Ship}</text> $define${AOs::Ship}</text>
</file> </file>
<!--${.::tunnel.c}--> <!--${.::tunnel.c}-->
@ -1402,13 +1420,12 @@ Q_DEFINE_THIS_FILE
/* local objects -----------------------------------------------------------*/ /* local objects -----------------------------------------------------------*/
$declare${AOs::Tunnel} $declare${AOs::Tunnel}
static Tunnel l_tunnel; /* the sole instance of the Tunnel active object */
/* Public-scope objects ----------------------------------------------------*/ /* Public-scope objects ----------------------------------------------------*/
$define${AOs::AO_Tunnel} $define${Shared::AO_Tunnel}
/* Active object definition ================================================*/ /* Active object definition ================================================*/
$define${AOs::Tunnel_ctor} $define${Shared::Tunnel_ctor_call}
$define${AOs::Tunnel}</text> $define${AOs::Tunnel}</text>
</file> </file>
<!--${.::mine1.c}--> <!--${.::mine1.c}-->
@ -1422,14 +1439,11 @@ Q_DEFINE_THIS_FILE
/* encapsulated delcaration of the Mine1 HSM -------------------------------*/ /* encapsulated delcaration of the Mine1 HSM -------------------------------*/
$declare(AOs::Mine1) $declare(AOs::Mine1)
/* local objects -----------------------------------------------------------*/
static Mine1 l_mine1[GAME_MINES_MAX]; /* a pool of type-1 mines */
/* helper macro to provide the ID of this mine */ /* helper macro to provide the ID of this mine */
#define MINE_ID(me_) ((uint8_t)((me_) - l_mine1)) #define MINE_ID(me_) ((uint8_t)((me_) - &amp;Mine1_inst[0]))
/* Mine1 class definition --------------------------------------------------*/ /* Mine1 class definition --------------------------------------------------*/
$define(AOs::Mine1_ctor) $define(Shared::Mine1_ctor_call)
$define(AOs::Mine1)</text> $define(AOs::Mine1)</text>
</file> </file>
<!--${.::mine2.c}--> <!--${.::mine2.c}-->
@ -1443,14 +1457,11 @@ Q_DEFINE_THIS_FILE
/* encapsulated delcaration of the Mine2 HSM -------------------------------*/ /* encapsulated delcaration of the Mine2 HSM -------------------------------*/
$declare(AOs::Mine2) $declare(AOs::Mine2)
/* local objects -----------------------------------------------------------*/
static Mine2 l_mine2[GAME_MINES_MAX]; /* a pool of type-2 mines */
/* helper macro to provide the ID of this mine */ /* helper macro to provide the ID of this mine */
#define MINE_ID(me_) ((uint8_t)((me_) - l_mine2)) #define MINE_ID(me_) ((uint8_t)((me_) - &amp;Mine2_inst[0]))
/* Mine2 class definition --------------------------------------------------*/ /* Mine2 class definition --------------------------------------------------*/
$define(AOs::Mine2_ctor) $define(Shared::Mine2_ctor_call)
$define(AOs::Mine2)</text> $define(AOs::Mine2)</text>
</file> </file>
</directory> </directory>

View File

@ -1,13 +1,13 @@
/***************************************************************************** /*****************************************************************************
* Product: "Fly 'n' Shoot" game example * Product: "Fly 'n' Shoot" game example
* Last updated for version 6.8.2 * Last updated for version 6.9.2
* Last updated on 2020-07-17 * Last updated on 2021-02-12
* *
* Q u a n t u m L e a P s * Q u a n t u m L e a P s
* ------------------------ * ------------------------
* Modern Embedded Software * Modern Embedded Software
* *
* Copyright (C) 2005-2020 Quantum Leaps, LLC. All rights reserved. * Copyright (C) 2005-2021 Quantum Leaps, LLC. All rights reserved.
* *
* This program is open source software: you can redistribute it and/or * 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 * modify it under the terms of the GNU General Public License as published
@ -51,14 +51,8 @@ int main() {
static QSubscrList subscrSto[MAX_PUB_SIG]; static QSubscrList subscrSto[MAX_PUB_SIG];
/* explicitly invoke the active objects' ctors... */ QF_init(); /* initialize the framework and the underlying RT kernel */
QTicker_ctor(&l_ticker0, 0U); /* active object for tick rate 0 */ BSP_init(); /* initialize the Board Support Package */
Missile_ctor();
Ship_ctor();
Tunnel_ctor();
QF_init(); /* initialize the framework and the underlying RT kernel */
BSP_init(); /* initialize the Board Support Package */
/* init publish-subscribe... */ /* init publish-subscribe... */
QF_psInit(subscrSto, Q_DIM(subscrSto)); QF_psInit(subscrSto, Q_DIM(subscrSto));
@ -79,19 +73,23 @@ int main() {
QS_SIG_DICTIONARY(GAME_OVER_SIG, (void *)0); QS_SIG_DICTIONARY(GAME_OVER_SIG, (void *)0);
/* start the active objects... */ /* start the active objects... */
QTicker_ctor(&l_ticker0, 0U); /* active object for tick rate 0 */
QACTIVE_START(the_Ticker0, QACTIVE_START(the_Ticker0,
1U, /* QP priority */ 1U, /* QP priority */
0, 0, 0, 0, 0); /* no queue, no stack , no init. event */ 0, 0, 0, 0, 0); /* no queue, no stack , no init. event */
Tunnel_ctor_call();
QACTIVE_START(AO_Tunnel, QACTIVE_START(AO_Tunnel,
2U, /* QP priority */ 2U, /* QP priority */
tunnelQueueSto, Q_DIM(tunnelQueueSto), /* evt queue */ tunnelQueueSto, Q_DIM(tunnelQueueSto), /* evt queue */
(void *)0, 0U, /* no per-thread stack */ (void *)0, 0U, /* no per-thread stack */
(QEvt *)0); /* no initialization event */ (QEvt *)0); /* no initialization event */
Ship_ctor_call();
QACTIVE_START(AO_Ship, QACTIVE_START(AO_Ship,
3U, /* QP priority */ 3U, /* QP priority */
shipQueueSto, Q_DIM(shipQueueSto), /* evt queue */ shipQueueSto, Q_DIM(shipQueueSto), /* evt queue */
(void *)0, 0U, /* no per-thread stack */ (void *)0, 0U, /* no per-thread stack */
(QEvt *)0); /* no initialization event */ (QEvt *)0); /* no initialization event */
Missile_ctor_call();
QACTIVE_START(AO_Missile, QACTIVE_START(AO_Missile,
4U, /* QP priority */ 4U, /* QP priority */
missileQueueSto, Q_DIM(missileQueueSto), /* evt queue */ missileQueueSto, Q_DIM(missileQueueSto), /* evt queue */

View File

@ -25,7 +25,7 @@ Q_DEFINE_THIS_FILE
/* encapsulated delcaration of the Mine1 HSM -------------------------------*/ /* encapsulated delcaration of the Mine1 HSM -------------------------------*/
/*.$declare${AOs::Mine1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$declare${AOs::Mine1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Mine1} ...........................................................*/ /*.${AOs::Mine1} ...........................................................*/
typedef struct { typedef struct Mine1 {
/* protected: */ /* protected: */
QHsm super; QHsm super;
@ -37,6 +37,10 @@ typedef struct {
uint8_t exp_ctr; uint8_t exp_ctr;
} Mine1; } Mine1;
/* public: */
static void Mine1_ctor(Mine1 * const me);
extern Mine1 Mine1_inst[GAME_MINES_MAX];
/* protected: */ /* protected: */
static QState Mine1_initial(Mine1 * const me, void const * const par); static QState Mine1_initial(Mine1 * const me, void const * const par);
static QState Mine1_unused(Mine1 * const me, QEvt const * const e); static QState Mine1_unused(Mine1 * const me, QEvt const * const e);
@ -45,11 +49,8 @@ static QState Mine1_planted(Mine1 * const me, QEvt const * const e);
static QState Mine1_exploding(Mine1 * const me, QEvt const * const e); static QState Mine1_exploding(Mine1 * const me, QEvt const * const e);
/*.$enddecl${AOs::Mine1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$enddecl${AOs::Mine1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* local objects -----------------------------------------------------------*/
static Mine1 l_mine1[GAME_MINES_MAX]; /* a pool of type-1 mines */
/* helper macro to provide the ID of this mine */ /* helper macro to provide the ID of this mine */
#define MINE_ID(me_) ((uint8_t)((me_) - l_mine1)) #define MINE_ID(me_) ((uint8_t)((me_) - &Mine1_inst[0]))
/* Mine1 class definition --------------------------------------------------*/ /* Mine1 class definition --------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
@ -58,30 +59,34 @@ static Mine1 l_mine1[GAME_MINES_MAX]; /* a pool of type-1 mines */
#error qpc version 6.8.0 or higher required #error qpc version 6.8.0 or higher required
#endif #endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Mine1_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$define${Shared::Mine1_ctor_call} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Mine1_ctor} ......................................................*/ /*.${Shared::Mine1_ctor_call} ..............................................*/
QHsm * Mine1_ctor(uint8_t id) { QHsm * Mine1_ctor_call(uint8_t id) {
Mine1 *me;
Q_REQUIRE(id < GAME_MINES_MAX); Q_REQUIRE(id < GAME_MINES_MAX);
me = &l_mine1[id]; Mine1_ctor(&Mine1_inst[id]);
/* superclass' ctor */ return &Mine1_inst[id].super;
QHsm_ctor(&me->super, Q_STATE_CAST(&Mine1_initial));
return (QHsm *)me;
} }
/*.$enddef${AOs::Mine1_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$enddef${Shared::Mine1_ctor_call} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Mine1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$define${AOs::Mine1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Mine1} ...........................................................*/ /*.${AOs::Mine1} ...........................................................*/
Mine1 Mine1_inst[GAME_MINES_MAX];
/*.${AOs::Mine1::ctor} .....................................................*/
static void Mine1_ctor(Mine1 * const me) {
/* superclass' ctor */
QHsm_ctor(&me->super, Q_STATE_CAST(&Mine1_initial));
}
/*.${AOs::Mine1::SM} .......................................................*/ /*.${AOs::Mine1::SM} .......................................................*/
static QState Mine1_initial(Mine1 * const me, void const * const par) { static QState Mine1_initial(Mine1 * const me, void const * const par) {
/*.${AOs::Mine1::SM::initial} */ /*.${AOs::Mine1::SM::initial} */
static uint8_t dict_sent; static uint8_t dict_sent;
if (!dict_sent) { if (!dict_sent) {
QS_OBJ_DICTIONARY(&l_mine1[0]); /* obj. dictionaries for Mine1 pool */ QS_OBJ_DICTIONARY(&Mine1_inst[0]);
QS_OBJ_DICTIONARY(&l_mine1[1]); QS_OBJ_DICTIONARY(&Mine1_inst[1]);
QS_OBJ_DICTIONARY(&l_mine1[2]); QS_OBJ_DICTIONARY(&Mine1_inst[2]);
QS_OBJ_DICTIONARY(&l_mine1[3]); QS_OBJ_DICTIONARY(&Mine1_inst[3]);
QS_OBJ_DICTIONARY(&l_mine1[4]); QS_OBJ_DICTIONARY(&Mine1_inst[4]);
QS_FUN_DICTIONARY(&Mine1_initial);/*fun. dictionaries for Mine1 HSM */ QS_FUN_DICTIONARY(&Mine1_initial);/*fun. dictionaries for Mine1 HSM */
QS_FUN_DICTIONARY(&Mine1_unused); QS_FUN_DICTIONARY(&Mine1_unused);

View File

@ -25,7 +25,7 @@ Q_DEFINE_THIS_FILE
/* encapsulated delcaration of the Mine2 HSM -------------------------------*/ /* encapsulated delcaration of the Mine2 HSM -------------------------------*/
/*.$declare${AOs::Mine2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$declare${AOs::Mine2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Mine2} ...........................................................*/ /*.${AOs::Mine2} ...........................................................*/
typedef struct { typedef struct Mine2 {
/* protected: */ /* protected: */
QHsm super; QHsm super;
@ -37,6 +37,10 @@ typedef struct {
uint8_t exp_ctr; uint8_t exp_ctr;
} Mine2; } Mine2;
/* public: */
static void Mine2_ctor(Mine2 * const me);
extern Mine2 Mine2_inst[GAME_MINES_MAX];
/* protected: */ /* protected: */
static QState Mine2_initial(Mine2 * const me, void const * const par); static QState Mine2_initial(Mine2 * const me, void const * const par);
static QState Mine2_unused(Mine2 * const me, QEvt const * const e); static QState Mine2_unused(Mine2 * const me, QEvt const * const e);
@ -45,11 +49,8 @@ static QState Mine2_planted(Mine2 * const me, QEvt const * const e);
static QState Mine2_exploding(Mine2 * const me, QEvt const * const e); static QState Mine2_exploding(Mine2 * const me, QEvt const * const e);
/*.$enddecl${AOs::Mine2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$enddecl${AOs::Mine2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* local objects -----------------------------------------------------------*/
static Mine2 l_mine2[GAME_MINES_MAX]; /* a pool of type-2 mines */
/* helper macro to provide the ID of this mine */ /* helper macro to provide the ID of this mine */
#define MINE_ID(me_) ((uint8_t)((me_) - l_mine2)) #define MINE_ID(me_) ((uint8_t)((me_) - &Mine2_inst[0]))
/* Mine2 class definition --------------------------------------------------*/ /* Mine2 class definition --------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
@ -58,19 +59,23 @@ static Mine2 l_mine2[GAME_MINES_MAX]; /* a pool of type-2 mines */
#error qpc version 6.8.0 or higher required #error qpc version 6.8.0 or higher required
#endif #endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Mine2_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$define${Shared::Mine2_ctor_call} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Mine2_ctor} ......................................................*/ /*.${Shared::Mine2_ctor_call} ..............................................*/
QHsm * Mine2_ctor(uint8_t id) { QHsm * Mine2_ctor_call(uint8_t id) {
Mine2 *me;
Q_REQUIRE(id < GAME_MINES_MAX); Q_REQUIRE(id < GAME_MINES_MAX);
me = &l_mine2[id]; Mine2_ctor(&Mine2_inst[id]);
/* superclass' ctor */ return &Mine2_inst[id].super;
QHsm_ctor(&me->super, Q_STATE_CAST(&Mine2_initial));
return (QHsm *)me;
} }
/*.$enddef${AOs::Mine2_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$enddef${Shared::Mine2_ctor_call} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Mine2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$define${AOs::Mine2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Mine2} ...........................................................*/ /*.${AOs::Mine2} ...........................................................*/
Mine2 Mine2_inst[GAME_MINES_MAX];
/*.${AOs::Mine2::ctor} .....................................................*/
static void Mine2_ctor(Mine2 * const me) {
/* superclass' ctor */
QHsm_ctor(&me->super, Q_STATE_CAST(&Mine2_initial));
}
/*.${AOs::Mine2::SM} .......................................................*/ /*.${AOs::Mine2::SM} .......................................................*/
static QState Mine2_initial(Mine2 * const me, void const * const par) { static QState Mine2_initial(Mine2 * const me, void const * const par) {
/*.${AOs::Mine2::SM::initial} */ /*.${AOs::Mine2::SM::initial} */
@ -78,11 +83,11 @@ static QState Mine2_initial(Mine2 * const me, void const * const par) {
if (!dict_sent) { if (!dict_sent) {
/* object dictionaries for Mine2 pool... */ /* object dictionaries for Mine2 pool... */
QS_OBJ_DICTIONARY(&l_mine2[0]); QS_OBJ_DICTIONARY(&Mine2_inst[0]);
QS_OBJ_DICTIONARY(&l_mine2[1]); QS_OBJ_DICTIONARY(&Mine2_inst[1]);
QS_OBJ_DICTIONARY(&l_mine2[2]); QS_OBJ_DICTIONARY(&Mine2_inst[2]);
QS_OBJ_DICTIONARY(&l_mine2[3]); QS_OBJ_DICTIONARY(&Mine2_inst[3]);
QS_OBJ_DICTIONARY(&l_mine2[4]); QS_OBJ_DICTIONARY(&Mine2_inst[4]);
/*function dictionaries for Mine2 HSM... */ /*function dictionaries for Mine2 HSM... */
QS_FUN_DICTIONARY(&Mine2_initial); QS_FUN_DICTIONARY(&Mine2_initial);

View File

@ -25,7 +25,7 @@
/* local objects -----------------------------------------------------------*/ /* local objects -----------------------------------------------------------*/
/*.$declare${AOs::Missile} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$declare${AOs::Missile} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Missile} .........................................................*/ /*.${AOs::Missile} .........................................................*/
typedef struct { typedef struct Missile {
/* protected: */ /* protected: */
QActive super; QActive super;
@ -33,15 +33,20 @@ typedef struct {
uint8_t x; uint8_t x;
uint8_t y; uint8_t y;
uint8_t exp_ctr; uint8_t exp_ctr;
/* public: */
} Missile; } Missile;
/* public: */
static void Missile_ctor(Missile * const me);
extern Missile Missile_inst;
/* protected: */ /* protected: */
static QState Missile_initial(Missile * const me, void const * const par); static QState Missile_initial(Missile * const me, void const * const par);
static QState Missile_armed(Missile * const me, QEvt const * const e); static QState Missile_armed(Missile * const me, QEvt const * const e);
static QState Missile_flying(Missile * const me, QEvt const * const e); static QState Missile_flying(Missile * const me, QEvt const * const e);
static QState Missile_exploding(Missile * const me, QEvt const * const e); static QState Missile_exploding(Missile * const me, QEvt const * const e);
/*.$enddecl${AOs::Missile} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$enddecl${AOs::Missile} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
static Missile l_missile; /* the sole instance of the Missile active object */
/* Public-scope objects ----------------------------------------------------*/ /* Public-scope objects ----------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
@ -50,23 +55,28 @@ static Missile l_missile; /* the sole instance of the Missile active object */
#error qpc version 6.8.0 or higher required #error qpc version 6.8.0 or higher required
#endif #endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Missile} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$define${Shared::AO_Missile} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/* opaque AO pointer */ /* opaque AO pointer */
/*.${AOs::AO_Missile} ......................................................*/ /*.${Shared::AO_Missile} ...................................................*/
QActive * const AO_Missile = &l_missile.super; QActive * const AO_Missile = &Missile_inst.super;
/*.$enddef${AOs::AO_Missile} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$enddef${Shared::AO_Missile} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Active object definition ------------------------------------------------*/ /* Active object definition ------------------------------------------------*/
/*.$define${AOs::Missile_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$define${Shared::Missile_ctor_call} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Missile_ctor} ....................................................*/ /*.${Shared::Missile_ctor_call} ............................................*/
void Missile_ctor(void) { void Missile_ctor_call(void) {
Missile *me = &l_missile; Missile_ctor(&Missile_inst);
QActive_ctor(&me->super, Q_STATE_CAST(&Missile_initial));
} }
/*.$enddef${AOs::Missile_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$enddef${Shared::Missile_ctor_call} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Missile} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$define${AOs::Missile} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Missile} .........................................................*/ /*.${AOs::Missile} .........................................................*/
Missile Missile_inst;
/*.${AOs::Missile::ctor} ...................................................*/
static void Missile_ctor(Missile * const me) {
QActive_ctor(&me->super, Q_STATE_CAST(&Missile_initial));
}
/*.${AOs::Missile::SM} .....................................................*/ /*.${AOs::Missile::SM} .....................................................*/
static QState Missile_initial(Missile * const me, void const * const par) { static QState Missile_initial(Missile * const me, void const * const par) {
/*.${AOs::Missile::SM::initial} */ /*.${AOs::Missile::SM::initial} */

View File

@ -28,7 +28,7 @@
/* encapsulated delcaration of the Ship active object ----------------------*/ /* encapsulated delcaration of the Ship active object ----------------------*/
/*.$declare${AOs::Ship} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$declare${AOs::Ship} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Ship} ............................................................*/ /*.${AOs::Ship} ............................................................*/
typedef struct { typedef struct Ship {
/* protected: */ /* protected: */
QActive super; QActive super;
@ -37,8 +37,14 @@ typedef struct {
uint16_t y; uint16_t y;
uint8_t exp_ctr; uint8_t exp_ctr;
uint16_t score; uint16_t score;
/* public: */
} Ship; } Ship;
/* public: */
static void Ship_ctor(Ship * const me);
extern Ship Ship_inst;
/* protected: */ /* protected: */
static QState Ship_initial(Ship * const me, void const * const par); static QState Ship_initial(Ship * const me, void const * const par);
static QState Ship_active(Ship * const me, QEvt const * const e); static QState Ship_active(Ship * const me, QEvt const * const e);
@ -47,9 +53,6 @@ static QState Ship_flying(Ship * const me, QEvt const * const e);
static QState Ship_exploding(Ship * const me, QEvt const * const e); static QState Ship_exploding(Ship * const me, QEvt const * const e);
/*.$enddecl${AOs::Ship} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$enddecl${AOs::Ship} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* local objects -----------------------------------------------------------*/
static Ship l_ship; /* the sole instance of the Ship active object */
/* Public-scope objects ----------------------------------------------------*/ /* Public-scope objects ----------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */ /*. Check for the minimum required QP version */
@ -57,25 +60,30 @@ static Ship l_ship; /* the sole instance of the Ship active object */
#error qpc version 6.8.0 or higher required #error qpc version 6.8.0 or higher required
#endif #endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Ship} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$define${Shared::AO_Ship} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/* opaque AO pointer */ /* opaque AO pointer */
/*.${AOs::AO_Ship} .........................................................*/ /*.${Shared::AO_Ship} ......................................................*/
QActive * const AO_Ship = &l_ship.super; QActive * const AO_Ship = &Ship_inst.super;
/*.$enddef${AOs::AO_Ship} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$enddef${Shared::AO_Ship} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Active object definition ------------------------------------------------*/ /* Active object definition ------------------------------------------------*/
/*.$define${AOs::Ship_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$define${Shared::Ship_ctor_call} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Ship_ctor} .......................................................*/ /*.${Shared::Ship_ctor_call} ...............................................*/
void Ship_ctor(void) { void Ship_ctor_call(void) {
Ship *me = &l_ship; Ship_ctor(&Ship_inst);
}
/*.$enddef${Shared::Ship_ctor_call} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Ship} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Ship} ............................................................*/
Ship Ship_inst;
/*.${AOs::Ship::ctor} ......................................................*/
static void Ship_ctor(Ship * const me) {
QActive_ctor(&me->super, Q_STATE_CAST(&Ship_initial)); QActive_ctor(&me->super, Q_STATE_CAST(&Ship_initial));
me->x = GAME_SHIP_X; me->x = GAME_SHIP_X;
me->y = (GAME_SHIP_Y << 2); me->y = (GAME_SHIP_Y << 2);
} }
/*.$enddef${AOs::Ship_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Ship} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Ship} ............................................................*/
/*.${AOs::Ship::SM} ........................................................*/ /*.${AOs::Ship::SM} ........................................................*/
static QState Ship_initial(Ship * const me, void const * const par) { static QState Ship_initial(Ship * const me, void const * const par) {
/*.${AOs::Ship::SM::initial} */ /*.${AOs::Ship::SM::initial} */

View File

@ -25,7 +25,7 @@ Q_DEFINE_THIS_FILE
/* local objects -----------------------------------------------------------*/ /* local objects -----------------------------------------------------------*/
/*.$declare${AOs::Tunnel} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$declare${AOs::Tunnel} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Tunnel} ..........................................................*/ /*.${AOs::Tunnel} ..........................................................*/
typedef struct { typedef struct Tunnel {
/* protected: */ /* protected: */
QActive super; QActive super;
@ -41,6 +41,8 @@ typedef struct {
uint8_t wall_thickness_top; uint8_t wall_thickness_top;
uint8_t wall_thickness_bottom; uint8_t wall_thickness_bottom;
uint8_t wall_gap; uint8_t wall_gap;
/* public: */
} Tunnel; } Tunnel;
/* private: */ /* private: */
@ -48,6 +50,10 @@ static void Tunnel_advance(Tunnel * const me);
static void Tunnel_plantMine(Tunnel * const me); static void Tunnel_plantMine(Tunnel * const me);
static void Tunnel_dispatchToAllMines(Tunnel * const me, QEvt const * e); static void Tunnel_dispatchToAllMines(Tunnel * const me, QEvt const * e);
/* public: */
static void Tunnel_ctor(Tunnel * const me);
extern Tunnel Tunnel_inst;
/* protected: */ /* protected: */
static QState Tunnel_initial(Tunnel * const me, void const * const par); static QState Tunnel_initial(Tunnel * const me, void const * const par);
static QState Tunnel_active(Tunnel * const me, QEvt const * const e); static QState Tunnel_active(Tunnel * const me, QEvt const * const e);
@ -60,7 +66,6 @@ static QState Tunnel_screen_saver_hide(Tunnel * const me, QEvt const * const e);
static QState Tunnel_screen_saver_show(Tunnel * const me, QEvt const * const e); static QState Tunnel_screen_saver_show(Tunnel * const me, QEvt const * const e);
static QState Tunnel_final(Tunnel * const me, QEvt const * const e); static QState Tunnel_final(Tunnel * const me, QEvt const * const e);
/*.$enddecl${AOs::Tunnel} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$enddecl${AOs::Tunnel} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
static Tunnel l_tunnel; /* the sole instance of the Tunnel active object */
/* Public-scope objects ----------------------------------------------------*/ /* Public-scope objects ----------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
@ -69,33 +74,23 @@ static Tunnel l_tunnel; /* the sole instance of the Tunnel active object */
#error qpc version 6.8.0 or higher required #error qpc version 6.8.0 or higher required
#endif #endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Tunnel} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$define${Shared::AO_Tunnel} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/* opaque AO pointer */ /* opaque AO pointer */
/*.${AOs::AO_Tunnel} .......................................................*/ /*.${Shared::AO_Tunnel} ....................................................*/
QActive * const AO_Tunnel = &l_tunnel.super; QActive * const AO_Tunnel = &Tunnel_inst.super;
/*.$enddef${AOs::AO_Tunnel} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$enddef${Shared::AO_Tunnel} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Active object definition ================================================*/ /* Active object definition ================================================*/
/*.$define${AOs::Tunnel_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$define${Shared::Tunnel_ctor_call} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Tunnel_ctor} .....................................................*/ /*.${Shared::Tunnel_ctor_call} .............................................*/
void Tunnel_ctor(void) { void Tunnel_ctor_call(void) {
uint8_t n; Tunnel_ctor(&Tunnel_inst);
Tunnel *me = &l_tunnel;
QActive_ctor(&me->super, Q_STATE_CAST(&Tunnel_initial));
QTimeEvt_ctorX(&me->blinkTimeEvt, &me->super, BLINK_TIMEOUT_SIG, 0U);
QTimeEvt_ctorX(&me->screenTimeEvt, &me->super, SCREEN_TIMEOUT_SIG, 0U);
for (n = 0; n < GAME_MINES_MAX; ++n) {
me->mine1_pool[n] = Mine1_ctor(n); /* instantiate Mine1 in the pool */
me->mine2_pool[n] = Mine2_ctor(n); /* instantiate Mine2 in the pool */
me->mines[n] = (QHsm *)0; /* mine 'n' is unused */
}
me->last_mine_x = 0; /* the last mine at the right edge of the tunnel */
me->last_mine_y = 0;
} }
/*.$enddef${AOs::Tunnel_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$enddef${Shared::Tunnel_ctor_call} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Tunnel} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$define${AOs::Tunnel} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Tunnel} ..........................................................*/ /*.${AOs::Tunnel} ..........................................................*/
Tunnel Tunnel_inst;
/*.${AOs::Tunnel::advance} .................................................*/ /*.${AOs::Tunnel::advance} .................................................*/
static void Tunnel_advance(Tunnel * const me) { static void Tunnel_advance(Tunnel * const me) {
uint32_t rnd; uint32_t rnd;
@ -194,6 +189,21 @@ static void Tunnel_dispatchToAllMines(Tunnel * const me, QEvt const * e) {
} }
} }
/*.${AOs::Tunnel::ctor} ....................................................*/
static void Tunnel_ctor(Tunnel * const me) {
uint8_t n;
QActive_ctor(&me->super, Q_STATE_CAST(&Tunnel_initial));
QTimeEvt_ctorX(&me->blinkTimeEvt, &me->super, BLINK_TIMEOUT_SIG, 0U);
QTimeEvt_ctorX(&me->screenTimeEvt, &me->super, SCREEN_TIMEOUT_SIG, 0U);
for (n = 0; n < GAME_MINES_MAX; ++n) {
me->mine1_pool[n] = Mine1_ctor_call(n); /* instantiate Mine1 */
me->mine2_pool[n] = Mine2_ctor_call(n); /* instantiate Mine2 */
me->mines[n] = (QHsm *)0; /* mine 'n' is unused */
}
me->last_mine_x = 0; /* the last mine at the right edge of the tunnel */
me->last_mine_y = 0;
}
/*.${AOs::Tunnel::SM} ......................................................*/ /*.${AOs::Tunnel::SM} ......................................................*/
static QState Tunnel_initial(Tunnel * const me, void const * const par) { static QState Tunnel_initial(Tunnel * const me, void const * const par) {
/*.${AOs::Tunnel::SM::initial} */ /*.${AOs::Tunnel::SM::initial} */
@ -209,8 +219,8 @@ static QState Tunnel_initial(Tunnel * const me, void const * const par) {
QActive_subscribe(&me->super, PLAYER_QUIT_SIG); QActive_subscribe(&me->super, PLAYER_QUIT_SIG);
/* object dictionaries... */ /* object dictionaries... */
QS_OBJ_DICTIONARY(&l_tunnel.blinkTimeEvt); QS_OBJ_DICTIONARY(&Tunnel_inst.blinkTimeEvt);
QS_OBJ_DICTIONARY(&l_tunnel.screenTimeEvt); QS_OBJ_DICTIONARY(&Tunnel_inst.screenTimeEvt);
/* local signals... */ /* local signals... */
QS_SIG_DICTIONARY(BLINK_TIMEOUT_SIG, me); QS_SIG_DICTIONARY(BLINK_TIMEOUT_SIG, me);

View File

@ -1,13 +1,13 @@
/***************************************************************************** /*****************************************************************************
* Product: "Fly 'n' Shoot" game example for Windows * Product: "Fly 'n' Shoot" game example for Windows
* Last updated for version 6.4.0 * Last updated for version 6.9.2
* Last updated on 2019-02-08 * Last updated on 2021-02-12
* *
* Q u a n t u m L e a P s * Q u a n t u m L e a P s
* ------------------------ * ------------------------
* Modern Embedded Software * Modern Embedded Software
* *
* Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved. * Copyright (C) 2005-2021 Quantum Leaps, LLC. All rights reserved.
* *
* This program is open source software: you can redistribute it and/or * 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 * modify it under the terms of the GNU General Public License as published
@ -48,14 +48,8 @@ int main() {
static QF_MPOOL_EL(QEvt) smlPoolSto[10*WIN_FUDGE_FACTOR]; static QF_MPOOL_EL(QEvt) smlPoolSto[10*WIN_FUDGE_FACTOR];
static QF_MPOOL_EL(ObjectImageEvt) static QF_MPOOL_EL(ObjectImageEvt)
medPoolSto[(2*GAME_MINES_MAX + 10)*WIN_FUDGE_FACTOR]; medPoolSto[(2*GAME_MINES_MAX + 10)*WIN_FUDGE_FACTOR];
static QSubscrList subscrSto[MAX_PUB_SIG]; static QSubscrList subscrSto[MAX_PUB_SIG];
/* explicitly invoke the active objects' ctors... */
Missile_ctor();
Ship_ctor();
Tunnel_ctor();
QF_init(); /* initialize the framework and the underlying RT kernel */ QF_init(); /* initialize the framework and the underlying RT kernel */
BSP_init(); /* initialize the Board Support Package */ BSP_init(); /* initialize the Board Support Package */
@ -78,16 +72,19 @@ int main() {
QS_SIG_DICTIONARY(GAME_OVER_SIG, (void *)0); QS_SIG_DICTIONARY(GAME_OVER_SIG, (void *)0);
/* start the active objects... */ /* start the active objects... */
Tunnel_ctor_call();
QACTIVE_START(AO_Tunnel, QACTIVE_START(AO_Tunnel,
1U, /* QP priority */ 1U, /* QP priority */
tunnelQueueSto, Q_DIM(tunnelQueueSto), /* evt queue */ tunnelQueueSto, Q_DIM(tunnelQueueSto), /* evt queue */
(void *)0, 0U, /* no per-thread stack */ (void *)0, 0U, /* no per-thread stack */
(QEvt *)0); /* no initialization event */ (QEvt *)0); /* no initialization event */
Ship_ctor_call();
QACTIVE_START(AO_Ship, QACTIVE_START(AO_Ship,
2U, /* QP priority */ 2U, /* QP priority */
shipQueueSto, Q_DIM(shipQueueSto), /* evt queue */ shipQueueSto, Q_DIM(shipQueueSto), /* evt queue */
(void *)0, 0U, /* no per-thread stack */ (void *)0, 0U, /* no per-thread stack */
(QEvt *)0); /* no initialization event */ (QEvt *)0); /* no initialization event */
Missile_ctor_call();
QACTIVE_START(AO_Missile, QACTIVE_START(AO_Missile,
3U, /* QP priority */ 3U, /* QP priority */
missileQueueSto, Q_DIM(missileQueueSto), /* evt queue */ missileQueueSto, Q_DIM(missileQueueSto), /* evt queue */

View File

@ -1,12 +1,7 @@
# test-script for QUTest unit testing harness # test-script for QUTest unit testing harness
# see https://www.state-machine.com/qtools/qutest.html # see https://www.state-machine.com/qtools/qutest.html
# preamble... include("test_include.pyi")
def on_setup():
expect("@timestamp FIXTURE_SETUP")
def on_teardown():
expect("@timestamp FIXTURE_TEARDOWN")
# tests... # tests...
test("Assert 0") test("Assert 0")

View File

@ -1,16 +1,11 @@
# test-script for QUTest unit testing harness # test-script for QUTest unit testing harness
# see https://www.state-machine.com/qtools/qutest.html # see https://www.state-machine.com/qtools/qutest.html
# preamble... include("test_include.pyi")
def on_setup():
expect("@timestamp FIXTURE_SETUP")
def on_teardown():
expect("@timestamp FIXTURE_TEARDOWN")
# tests... # tests...
test("Command") test("Command")
command("COMMAND_X", 1, 2, 3) command_x(1, 2, 3)
expect("@timestamp COMMAND_X 0") expect("@timestamp COMMAND_X 0")
expect("@timestamp Trg-Done QS_RX_COMMAND") expect("@timestamp Trg-Done QS_RX_COMMAND")

View File

@ -1,12 +1,7 @@
# test-script for QUTest unit testing harness # test-script for QUTest unit testing harness
# see https://www.state-machine.com/qtools/qutest.html # see https://www.state-machine.com/qtools/qutest.html
# preamble... include("test_include.pyi")
def on_setup():
expect("@timestamp FIXTURE_SETUP")
def on_teardown():
expect("@timestamp FIXTURE_TEARDOWN")
# tests... # tests...
test("FP output") test("FP output")

View File

@ -0,0 +1,16 @@
# include script for QUTest unit testing harness
# see https://www.state-machine.com/qtools/qutest.html
# preamble...
def on_setup():
expect("@timestamp FIXTURE_SETUP")
def on_teardown():
expect("@timestamp FIXTURE_TEARDOWN")
def command_x(par1=0, par2=0, par3=0):
command("COMMAND_X", par1, par2, par3)
def curr_ap_obj(obj_name):
current_obj(OBJ_AP, obj_name)

View File

@ -1,17 +1,11 @@
# test-script for QUTest unit testing harness # test-script for QUTest unit testing harness
# see https://www.state-machine.com/qtools/qutest.html # see https://www.state-machine.com/qtools/qutest.html
# preamble... include("test_include.pyi")
def on_setup():
expect("@timestamp FIXTURE_SETUP")
def on_teardown():
expect("@timestamp FIXTURE_TEARDOWN")
# tests... # tests...
test("MEM/STR") test("MEM/STR")
current_obj(OBJ_AP,"buffer") curr_ap_obj("buffer")
fill(0,1,16,0x1A) fill(0,1,16,0x1A)
poke(33,1,b"Hello World!\0") poke(33,1,b"Hello World!\0")
command("COMMAND_Y", 16) command("COMMAND_Y", 16)
@ -19,7 +13,7 @@ expect("@timestamp COMMAND_Y myFun 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A
expect("@timestamp Trg-Done QS_RX_COMMAND") expect("@timestamp Trg-Done QS_RX_COMMAND")
test("MEM/STR empty string") test("MEM/STR empty string")
current_obj(OBJ_AP,"buffer") curr_ap_obj("buffer")
fill(0,1,16,0x1A) fill(0,1,16,0x1A)
poke(33,1,b"\0") poke(33,1,b"\0")
command("COMMAND_Y", 16) command("COMMAND_Y", 16)

View File

@ -1,17 +1,11 @@
# test-script for QUTest unit testing harness # test-script for QUTest unit testing harness
# see https://www.state-machine.com/qtools/qutest.html # see https://www.state-machine.com/qtools/qutest.html
# preamble... include("test_include.pyi")
def on_setup():
expect("@timestamp FIXTURE_SETUP")
def on_teardown():
expect("@timestamp FIXTURE_TEARDOWN")
# tests... # tests...
test("Peek/Poke/Fill uint8_t") test("Peek/Poke/Fill uint8_t")
current_obj(OBJ_AP,"buffer") curr_ap_obj("buffer")
fill(0,1,100,0x1A) fill(0,1,100,0x1A)
peek(0,1,5) peek(0,1,5)
expect("@timestamp Trg-Peek Offs=0,Size=1,Num=5,Data=<1A,1A,1A,1A,1A>") expect("@timestamp Trg-Peek Offs=0,Size=1,Num=5,Data=<1A,1A,1A,1A,1A>")

View File

@ -1,20 +1,15 @@
# test-script for QUTest unit testing harness # test-script for QUTest unit testing harness
# see https://www.state-machine.com/qtools/qutest.html # see https://www.state-machine.com/qtools/qutest.html
# preamble... include("test_include.pyi")
def on_setup():
expect("@timestamp FIXTURE_SETUP")
def on_teardown():
expect("@timestamp FIXTURE_TEARDOWN")
# tests... # tests...
test("Single Test Probe") test("Single Test Probe")
command("COMMAND_X") command_x()
expect("@timestamp COMMAND_X 0") expect("@timestamp COMMAND_X 0")
expect("@timestamp Trg-Done QS_RX_COMMAND") expect("@timestamp Trg-Done QS_RX_COMMAND")
probe("myFun", 1) probe("myFun", 1)
command("COMMAND_X") command_x()
expect("@timestamp TstProbe Fun=myFun,Data=1") expect("@timestamp TstProbe Fun=myFun,Data=1")
expect("@timestamp COMMAND_X 1") expect("@timestamp COMMAND_X 1")
expect("@timestamp Trg-Done QS_RX_COMMAND") expect("@timestamp Trg-Done QS_RX_COMMAND")

View File

@ -32,8 +32,11 @@ enum DPPSignals {
MAX_SIG /* the last signal */ MAX_SIG /* the last signal */
}; };
/*.$declare${Events::TableEvt} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /* number of philosophers */
/*.${Events::TableEvt} .....................................................*/ #define N_PHILO ((uint8_t)5)
/*.$declare${Shared} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${Shared::TableEvt} .....................................................*/
typedef struct { typedef struct {
/* protected: */ /* protected: */
QEvt super; QEvt super;
@ -41,26 +44,13 @@ typedef struct {
/* public: */ /* public: */
uint8_t philoNum; uint8_t philoNum;
} TableEvt; } TableEvt;
/*.$enddecl${Events::TableEvt} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* number of philosophers */
#define N_PHILO ((uint8_t)5)
/*.$declare${AOs::Philo_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo_ctor} ......................................................*/
void Philo_ctor(void);
/*.$enddecl${AOs::Philo_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo[N_PHILO]} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern QActive * const AO_Philo[N_PHILO]; extern QActive * const AO_Philo[N_PHILO];
/*.$enddecl${AOs::AO_Philo[N_PHILO]} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Table_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table_ctor} ......................................................*/
void Table_ctor(void);
/*.$enddecl${AOs::Table_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern QActive * const AO_Table; extern QActive * const AO_Table;
/*.$enddecl${AOs::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.${Shared::Philo_ctor_call} ..............................................*/
void Philo_ctor_call(void);
/*.${Shared::Table_ctor_call} ..............................................*/
void Table_ctor_call(void);
/*.$enddecl${Shared} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#ifdef QXK_H #ifdef QXK_H
void Test1_ctor(void); void Test1_ctor(void);

View File

@ -3,13 +3,38 @@
<documentation>Dining Philosopher Problem example</documentation> <documentation>Dining Philosopher Problem example</documentation>
<!--${qpc}--> <!--${qpc}-->
<framework name="qpc"/> <framework name="qpc"/>
<!--${Events}--> <!--${Shared}-->
<package name="Events" stereotype="0x01"> <package name="Shared" stereotype="0x01">
<!--${Events::TableEvt}--> <!--${Shared::TableEvt}-->
<class name="TableEvt" superclass="qpc::QEvt"> <class name="TableEvt" superclass="qpc::QEvt">
<!--${Events::TableEvt::philoNum}--> <!--${Shared::TableEvt::philoNum}-->
<attribute name="philoNum" type="uint8_t" visibility="0x00" properties="0x00"/> <attribute name="philoNum" type="uint8_t" visibility="0x00" properties="0x00"/>
</class> </class>
<!--${Shared::AO_Philo[N_PHILO]}-->
<attribute name="AO_Philo[N_PHILO]" type="QActive * const" visibility="0x00" properties="0x00">
<code>= { /* &quot;opaque&quot; pointers to Philo AO */
&amp;Philo_inst[0].super,
&amp;Philo_inst[1].super,
&amp;Philo_inst[2].super,
&amp;Philo_inst[3].super,
&amp;Philo_inst[4].super
};</code>
</attribute>
<!--${Shared::AO_Table}-->
<attribute name="AO_Table" type="QActive * const" visibility="0x00" properties="0x00">
<code>= &amp;Table_inst.super; /* &quot;opaque&quot; pointer to Table AO */</code>
</attribute>
<!--${Shared::Philo_ctor_call}-->
<operation name="Philo_ctor_call" type="void" visibility="0x00" properties="0x00">
<code>uint8_t n;
for (n = 0U; n &lt; N_PHILO; ++n) {
Philo_ctor(&amp;Philo_inst[n]);
}</code>
</operation>
<!--${Shared::Table_ctor_call}-->
<operation name="Table_ctor_call" type="void" visibility="0x00" properties="0x00">
<code>Table_ctor(&amp;Table_inst);</code>
</operation>
</package> </package>
<!--${AOs}--> <!--${AOs}-->
<package name="AOs" stereotype="0x02"> <package name="AOs" stereotype="0x02">
@ -21,6 +46,12 @@
</attribute> </attribute>
<!--${AOs::Philo::timeEvt}--> <!--${AOs::Philo::timeEvt}-->
<attribute name="timeEvt" type="QTimeEvt" visibility="0x02" properties="0x00"/> <attribute name="timeEvt" type="QTimeEvt" visibility="0x02" properties="0x00"/>
<!--${AOs::Philo::ctor}-->
<operation name="ctor" type="void" visibility="0x00" properties="0x00">
<documentation>constructor</documentation>
<code>QActive_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;Philo_initial));
QTimeEvt_ctorX(&amp;me-&gt;timeEvt, &amp;me-&gt;super, TIMEOUT_SIG, 0U);</code>
</operation>
<!--${AOs::Philo::SM}--> <!--${AOs::Philo::SM}-->
<statechart properties="0x01"> <statechart properties="0x01">
<!--${AOs::Philo::SM::initial}--> <!--${AOs::Philo::SM::initial}-->
@ -152,6 +183,17 @@ Q_ASSERT(Q_EVT_CAST(TableEvt)-&gt;philoNum != PHILO_ID(me));</action>
<attribute name="fork[N_PHILO]" type="uint8_t" visibility="0x02" properties="0x00"/> <attribute name="fork[N_PHILO]" type="uint8_t" visibility="0x02" properties="0x00"/>
<!--${AOs::Table::isHungry[N_PHILO]}--> <!--${AOs::Table::isHungry[N_PHILO]}-->
<attribute name="isHungry[N_PHILO]" type="uint8_t" visibility="0x02" properties="0x00"/> <attribute name="isHungry[N_PHILO]" type="uint8_t" visibility="0x02" properties="0x00"/>
<!--${AOs::Table::ctor}-->
<operation name="ctor" type="void" visibility="0x00" properties="0x00">
<documentation>constructor</documentation>
<code>uint8_t n;
QActive_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;Table_initial));
for (n = 0U; n &lt; N_PHILO; ++n) {
me-&gt;fork[n] = FREE;
me-&gt;isHungry[n] = 0U;
}</code>
</operation>
<!--${AOs::Table::SM}--> <!--${AOs::Table::SM}-->
<statechart properties="0x03"> <statechart properties="0x03">
<!--${AOs::Table::SM::initial}--> <!--${AOs::Table::SM::initial}-->
@ -362,42 +404,6 @@ me-&gt;fork[n] = FREE;</action>
<state_diagram size="49,69"/> <state_diagram size="49,69"/>
</statechart> </statechart>
</class> </class>
<!--${AOs::AO_Philo[N_PHILO]}-->
<attribute name="AO_Philo[N_PHILO]" type="QActive * const" visibility="0x00" properties="0x00">
<code>= { /* &quot;opaque&quot; pointers to Philo AO */
&amp;Philo_inst[0].super,
&amp;Philo_inst[1].super,
&amp;Philo_inst[2].super,
&amp;Philo_inst[3].super,
&amp;Philo_inst[4].super
};</code>
</attribute>
<!--${AOs::AO_Table}-->
<attribute name="AO_Table" type="QActive * const" visibility="0x00" properties="0x00">
<code>= &amp;Table_inst.super; /* &quot;opaque&quot; pointer to Table AO */</code>
</attribute>
<!--${AOs::Philo_ctor}-->
<operation name="Philo_ctor" type="void" visibility="0x00" properties="0x00">
<code>uint8_t n;
Philo *me;
for (n = 0U; n &lt; N_PHILO; ++n) {
me = &amp;Philo_inst[n];
QActive_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;Philo_initial));
QTimeEvt_ctorX(&amp;me-&gt;timeEvt, &amp;me-&gt;super, TIMEOUT_SIG, 0U);
}</code>
</operation>
<!--${AOs::Table_ctor}-->
<operation name="Table_ctor" type="void" visibility="0x00" properties="0x00">
<code>Table *me = &amp;Table_inst;
uint8_t n;
QActive_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;Table_initial));
for (n = 0U; n &lt; N_PHILO; ++n) {
me-&gt;fork[n] = FREE;
me-&gt;isHungry[n] = 0U;
}</code>
</operation>
</package> </package>
<!--${.}--> <!--${.}-->
<directory name="."> <directory name=".">
@ -419,16 +425,10 @@ enum DPPSignals {
MAX_SIG /* the last signal */ MAX_SIG /* the last signal */
}; };
$declare(Events::TableEvt)
/* number of philosophers */ /* number of philosophers */
#define N_PHILO ((uint8_t)5) #define N_PHILO ((uint8_t)5)
$declare(AOs::Philo_ctor) $declare${Shared}
$declare(AOs::AO_Philo[N_PHILO])
$declare(AOs::Table_ctor)
$declare(AOs::AO_Table)
#ifdef QXK_H #ifdef QXK_H
void Test1_ctor(void); void Test1_ctor(void);
@ -459,8 +459,8 @@ $declare${AOs::Philo}
/* helper macro to provide the ID of Philo &quot;me_&quot; */ /* helper macro to provide the ID of Philo &quot;me_&quot; */
#define PHILO_ID(me_) ((uint8_t)((me_) - &amp;Philo_inst[0])) #define PHILO_ID(me_) ((uint8_t)((me_) - &amp;Philo_inst[0]))
$define${AOs::AO_Philo[N_PHILO]} $define${Shared::AO_Philo[N_PHILO]}
$define${AOs::Philo_ctor} $define${Shared::Philo_ctor_call}
$define${AOs::Philo}</text> $define${AOs::Philo}</text>
</file> </file>
<!--${.::table.c}--> <!--${.::table.c}-->
@ -479,8 +479,8 @@ $declare${AOs::Table}
#define FREE ((uint8_t)0) #define FREE ((uint8_t)0)
#define USED ((uint8_t)1) #define USED ((uint8_t)1)
$define${AOs::AO_Table} $define${Shared::AO_Table}
$define${AOs::Table_ctor} $define${Shared::Table_ctor_call}
$define${AOs::Table}</text> $define${AOs::Table}</text>
</file> </file>
</directory> </directory>

View File

@ -1,13 +1,13 @@
/***************************************************************************** /*****************************************************************************
* Product: DPP example for Windows * Product: DPP example for Windows
* Last updated for version 6.4.0 * Last updated for version 6.9.2
* Last updated on 2019-02-08 * Last updated on 2021-02-10
* *
* Q u a n t u m L e a P s * Q u a n t u m L e a P s
* ------------------------ * ------------------------
* Modern Embedded Software * Modern Embedded Software
* *
* Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved. * Copyright (C) 2005-2021 Quantum Leaps, LLC. All rights reserved.
* *
* This program is open source software: you can redistribute it and/or * 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 * modify it under the terms of the GNU General Public License as published
@ -48,8 +48,6 @@ int main(int argc, char *argv[]) {
static QF_MPOOL_EL(TableEvt) smlPoolSto[2*N_PHILO*WIN_FUDGE_FACTOR]; static QF_MPOOL_EL(TableEvt) smlPoolSto[2*N_PHILO*WIN_FUDGE_FACTOR];
uint8_t n; uint8_t n;
Philo_ctor(); /* instantiate all Philosopher active objects */
Table_ctor(); /* instantiate the Table active object */
QF_init(); /* initialize the framework and the underlying RT kernel */ QF_init(); /* initialize the framework and the underlying RT kernel */
BSP_init(argc, argv); /* initialize the Board Support Package */ BSP_init(argc, argv); /* initialize the Board Support Package */
@ -61,6 +59,7 @@ int main(int argc, char *argv[]) {
QF_poolInit(smlPoolSto, sizeof(smlPoolSto), sizeof(smlPoolSto[0])); QF_poolInit(smlPoolSto, sizeof(smlPoolSto), sizeof(smlPoolSto[0]));
/* start the active objects... */ /* start the active objects... */
Philo_ctor_call(); /* call all Philosopher ctors */
for (n = 0U; n < N_PHILO; ++n) { for (n = 0U; n < N_PHILO; ++n) {
QACTIVE_START(AO_Philo[n], /* AO to start */ QACTIVE_START(AO_Philo[n], /* AO to start */
(uint_fast8_t)(n + 1), /* QP priority of the AO */ (uint_fast8_t)(n + 1), /* QP priority of the AO */
@ -70,6 +69,7 @@ int main(int argc, char *argv[]) {
0U, /* size of the stack [bytes] */ 0U, /* size of the stack [bytes] */
(QEvt *)0); /* initialization event */ (QEvt *)0); /* initialization event */
} }
Table_ctor_call(); /* call Table ctor */
QACTIVE_START(AO_Table, /* AO to start */ QACTIVE_START(AO_Table, /* AO to start */
(uint_fast8_t)(N_PHILO + 1), /* QP priority of the AO */ (uint_fast8_t)(N_PHILO + 1), /* QP priority of the AO */
tableQueueSto, /* event queue storage */ tableQueueSto, /* event queue storage */

View File

@ -34,6 +34,9 @@ typedef struct Philo {
/* private: */ /* private: */
QTimeEvt timeEvt; QTimeEvt timeEvt;
} Philo; } Philo;
/* public: */
static void Philo_ctor(Philo * const me);
extern Philo Philo_inst[N_PHILO]; extern Philo Philo_inst[N_PHILO];
/* protected: */ /* protected: */
@ -57,8 +60,8 @@ static QState Philo_eating(Philo * const me, QEvt const * const e);
#error qpc version 6.8.0 or higher required #error qpc version 6.8.0 or higher required
#endif #endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo[N_PHILO]} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$define${Shared::AO_Philo[N_PHILO]} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo[N_PHILO]} ...............................................*/ /*.${Shared::AO_Philo[N_PHILO]} ............................................*/
QActive * const AO_Philo[N_PHILO] = { /* "opaque" pointers to Philo AO */ QActive * const AO_Philo[N_PHILO] = { /* "opaque" pointers to Philo AO */
&Philo_inst[0].super, &Philo_inst[0].super,
&Philo_inst[1].super, &Philo_inst[1].super,
@ -66,22 +69,25 @@ QActive * const AO_Philo[N_PHILO] = { /* "opaque" pointers to Philo AO */
&Philo_inst[3].super, &Philo_inst[3].super,
&Philo_inst[4].super &Philo_inst[4].super
}; };
/*.$enddef${AOs::AO_Philo[N_PHILO]} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$enddef${Shared::AO_Philo[N_PHILO]} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Philo_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$define${Shared::Philo_ctor_call} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo_ctor} ......................................................*/ /*.${Shared::Philo_ctor_call} ..............................................*/
void Philo_ctor(void) { void Philo_ctor_call(void) {
uint8_t n; uint8_t n;
Philo *me;
for (n = 0U; n < N_PHILO; ++n) { for (n = 0U; n < N_PHILO; ++n) {
me = &Philo_inst[n]; Philo_ctor(&Philo_inst[n]);
QActive_ctor(&me->super, Q_STATE_CAST(&Philo_initial));
QTimeEvt_ctorX(&me->timeEvt, &me->super, TIMEOUT_SIG, 0U);
} }
} }
/*.$enddef${AOs::Philo_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$enddef${Shared::Philo_ctor_call} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Philo} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$define${AOs::Philo} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo} ...........................................................*/ /*.${AOs::Philo} ...........................................................*/
Philo Philo_inst[N_PHILO]; Philo Philo_inst[N_PHILO];
/*.${AOs::Philo::ctor} .....................................................*/
static void Philo_ctor(Philo * const me) {
QActive_ctor(&me->super, Q_STATE_CAST(&Philo_initial));
QTimeEvt_ctorX(&me->timeEvt, &me->super, TIMEOUT_SIG, 0U);
}
/*.${AOs::Philo::SM} .......................................................*/ /*.${AOs::Philo::SM} .......................................................*/
static QState Philo_initial(Philo * const me, void const * const par) { static QState Philo_initial(Philo * const me, void const * const par) {
/*.${AOs::Philo::SM::initial} */ /*.${AOs::Philo::SM::initial} */

View File

@ -35,6 +35,9 @@ typedef struct Table {
uint8_t fork[N_PHILO]; uint8_t fork[N_PHILO];
uint8_t isHungry[N_PHILO]; uint8_t isHungry[N_PHILO];
} Table; } Table;
/* public: */
static void Table_ctor(Table * const me);
extern Table Table_inst; extern Table Table_inst;
/* protected: */ /* protected: */
@ -55,27 +58,30 @@ static QState Table_paused(Table * const me, QEvt const * const e);
#error qpc version 6.8.0 or higher required #error qpc version 6.8.0 or higher required
#endif #endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$define${Shared::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Table} ........................................................*/ /*.${Shared::AO_Table} .....................................................*/
QActive * const AO_Table = &Table_inst.super; /* "opaque" pointer to Table AO */ QActive * const AO_Table = &Table_inst.super; /* "opaque" pointer to Table AO */
/*.$enddef${AOs::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ /*.$enddef${Shared::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Table_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*.$define${Shared::Table_ctor_call} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table_ctor} ......................................................*/ /*.${Shared::Table_ctor_call} ..............................................*/
void Table_ctor(void) { void Table_ctor_call(void) {
Table *me = &Table_inst; Table_ctor(&Table_inst);
}
/*.$enddef${Shared::Table_ctor_call} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table} ...........................................................*/
Table Table_inst;
/*.${AOs::Table::ctor} .....................................................*/
static void Table_ctor(Table * const me) {
uint8_t n; uint8_t n;
QActive_ctor(&me->super, Q_STATE_CAST(&Table_initial)); QActive_ctor(&me->super, Q_STATE_CAST(&Table_initial));
for (n = 0U; n < N_PHILO; ++n) { for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE; me->fork[n] = FREE;
me->isHungry[n] = 0U; me->isHungry[n] = 0U;
} }
} }
/*.$enddef${AOs::Table_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table} ...........................................................*/
Table Table_inst;
/*.${AOs::Table::SM} .......................................................*/ /*.${AOs::Table::SM} .......................................................*/
static QState Table_initial(Table * const me, void const * const par) { static QState Table_initial(Table * const me, void const * const par) {
/*.${AOs::Table::SM::initial} */ /*.${AOs::Table::SM::initial} */

68
include/quit.h Normal file
View File

@ -0,0 +1,68 @@
/**
* @file
* @brief "QUIT" QP Unit Internal Test
* @cond
******************************************************************************
* Last updated for version 6.9.2
* Last updated on 2021-01-12
*
* Q u a n t u m L e a P s
* ------------------------
* Modern Embedded Software
*
* Copyright (C) 2005-2021 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
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <www.gnu.org/licenses>.
*
* Contact information:
* <www.state-machine.com/licensing>
* <info@state-machine.com>
******************************************************************************
* @endcond
*/
#ifndef QUIT_H
#define QUIT_H
/* macro to check an expectation */
#define EXPECT(cond_) ((cond_) \
? (void)0 : QUIT_fail_(#cond_, &Q_this_module_[0], __LINE__))
#ifdef __cplusplus
extern "C" {
#endif
void TEST(char const *title);
void QUIT_fail_(char const *cond, char const *module, int line);
void onRunTests(void); /* user-defined callback to run the tests */
#include "qf_port.h" /* QF/C port from the port directory */
#include "qassert.h" /* QP embedded systems-friendly assertions */
#ifdef Q_SPY /* software tracing enabled? */
#include "qs_port.h" /* QS/C port from the port directory */
#else
#include "qs_dummy.h" /* QS/C dummy (inactive) interface */
#endif
#ifdef __cplusplus
}
#endif
#endif /* QUIT_H */

View File

@ -0,0 +1,78 @@
/**
* @file
* @brief QEP/C port to Win32 with GNU or Visual Studio C/C++ compilers
* @cond
******************************************************************************
* Last updated for version 6.8.0
* Last updated on 2020-01-23
*
* Q u a n t u m L e a P s
* ------------------------
* Modern Embedded Software
*
* Copyright (C) 2005-2020 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
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <www.gnu.org/licenses>.
*
* Contact information:
* <www.state-machine.com/licensing>
* <info@state-machine.com>
******************************************************************************
* @endcond
*/
#ifndef QEP_PORT_H
#define QEP_PORT_H
#include <stdint.h> /* Exact-width types. WG14/N843 C99 Standard */
#include <stdbool.h> /* Boolean type. WG14/N843 C99 Standard */
#ifdef __GNUC__
/*! no-return function specifier (GCC-ARM compiler) */
#define Q_NORETURN __attribute__ ((noreturn)) void
#elif (defined _MSC_VER) && (defined __cplusplus)
/* no-return function specifier (Microsoft Visual Studio C++ compiler) */
#define Q_NORETURN [[ noreturn ]] void
/*
* This is the case where QP/C is compiled by the Microsoft Visual C++
* compiler in the C++ mode, which can happen when qep_port.h is included
* in a C++ module, or the compilation is forced to C++ by the option /TP.
*
* The following pragma suppresses the level-4 C++ warnings C4510, C4512, and
* C4610, which warn that default constructors and assignment operators could
* not be generated for structures QMState and QMTranActTable.
*
* The QP/C source code cannot be changed to avoid these C++ warnings, because
* the structures QMState and QMTranActTable must remain PODs (Plain Old
* Datatypes) to be initializable statically with constant initializers.
*/
#pragma warning (disable: 4510 4512 4610)
#endif
#include "qep.h" /* QEP platform-independent public interface */
#if (defined __cplusplus) && (defined _MSC_VER)
#pragma warning (default: 4510 4512 4610)
#endif
#endif /* QEP_PORT_H */

105
ports/win32-quit/qf_port.h Normal file
View File

@ -0,0 +1,105 @@
/**
* @file
* @brief QF/C "port" for QUIT unit internal test, Win32 with GNU or VisualC++
* @ingroup ports
* @cond
******************************************************************************
* Last updated for version 6.9.2
* Last updated on 2021-01-11
*
* Q u a n t u m L e a P s
* ------------------------
* Modern Embedded Software
*
* Copyright (C) 2002-2020 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
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <www.gnu.org/licenses/>.
*
* Contact information:
* <www.state-machine.com/licensing>
* <info@state-machine.com>
******************************************************************************
* @endcond
*/
#ifndef QF_PORT_H
#define QF_PORT_H
/* QUIT event queue and thread types */
#define QF_EQUEUE_TYPE QEQueue
/* QF_OS_OBJECT_TYPE not used */
/* QF_THREAD_TYPE not used */
/* The maximum number of active objects in the application */
#define QF_MAX_ACTIVE 64U
/* The number of system clock tick rates */
#define QF_MAX_TICK_RATE 2U
/* Activate the QF QActive_stop() API */
#define QF_ACTIVE_STOP 1
/* QF interrupt disable/enable */
#define QF_INT_DISABLE() (++QF_intNest)
#define QF_INT_ENABLE() (--QF_intNest)
/* QUIT critical section */
/* QF_CRIT_STAT_TYPE not defined */
#define QF_CRIT_ENTRY(dummy) QF_INT_DISABLE()
#define QF_CRIT_EXIT(dummy) QF_INT_ENABLE()
/* QF_LOG2 not defined -- use the internal LOG2() implementation */
#include "qep_port.h" /* QEP port */
#include "qequeue.h" /* QUIT port uses QEQueue event-queue */
#include "qmpool.h" /* QUIT port uses QMPool memory-pool */
#include "qf.h" /* QF platform-independent public interface */
/* interrupt nesting up-down counter */
extern uint8_t volatile QF_intNest;
/****************************************************************************/
/* interface used only inside QP implementation, but not in applications */
#ifdef QP_IMPL
/* QUIT scheduler locking (not used) */
#define QF_SCHED_STAT_
#define QF_SCHED_LOCK_(dummy) ((void)0)
#define QF_SCHED_UNLOCK_() ((void)0)
/* native event queue operations */
#define QACTIVE_EQUEUE_WAIT_(me_) \
Q_ASSERT_ID(110, (me_)->eQueue.frontEvt != (QEvt *)0)
#define QACTIVE_EQUEUE_SIGNAL_(me_) \
QPSet_insert(&QS_rxPriv_.readySet, (uint_fast8_t)(me_)->prio)
/* native QF event pool operations */
#define QF_EPOOL_TYPE_ QMPool
#define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \
(QMPool_init(&(p_), (poolSto_), (poolSize_), (evtSize_)))
#define QF_EPOOL_EVENT_SIZE_(p_) ((uint_fast16_t)(p_).blockSize)
#define QF_EPOOL_GET_(p_, e_, m_, qs_id_) \
((e_) = (QEvt *)QMPool_get(&(p_), (m_), (qs_id_)))
#define QF_EPOOL_PUT_(p_, e_, qs_id_) \
(QMPool_put(&(p_), (e_), (qs_id_)))
#include "qf_pkg.h" /* internal QF interface */
#endif /* QP_IMPL */
#endif /* QF_PORT_H */

View File

@ -0,0 +1,67 @@
/**
* @file
* @brief QS/C port to Win32 with GNU or Visual C++ compilers
* @ingroup ports
* @cond
******************************************************************************
* Last Updated for Version: 5.9.0
* Date of the Last Update: 2017-05-16
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) 2005-2017 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
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <www.gnu.org/licenses/>.
*
* Contact information:
* <www.state-machine.com/licensing>
* <info@state-machine.com>
******************************************************************************
* @endcond
*/
#ifndef QS_PORT_H
#define QS_PORT_H
/* QS time-stamp size in bytes */
#define QS_TIME_SIZE 4
#ifdef _WIN64 /* 64-bit architecture? */
#define QS_OBJ_PTR_SIZE 8
#define QS_FUN_PTR_SIZE 8
#else /* 32-bit architecture */
#define QS_OBJ_PTR_SIZE 4
#define QS_FUN_PTR_SIZE 4
#endif
/* flush the QS output buffer after each QS record */
#define QS_REC_DONE() QS_onFlush()
/*****************************************************************************
* NOTE: QS might be used with or without other QP components, in which
* case the separate definitions of the macros QF_CRIT_STAT_TYPE,
* QF_CRIT_ENTRY, and QF_CRIT_EXIT are needed. In this port QS is configured
* to be used with the other QP component, by simply including "qf_port.h"
* *before* "qs.h".
*/
#include "qf_port.h" /* use QS with QF */
#include "qs.h" /* QS platform-independent public interface */
#endif /* QS_PORT_H */

View File

@ -0,0 +1,127 @@
/**
* @file
* @brief QUIT (QP Unit Internal Test) port to Win32 with GNU or VisualC++
* @cond
******************************************************************************
* Last updated for version 6.9.2
* Last updated on 2021-02-12
*
* Q u a n t u m L e a P s
* ------------------------
* Modern Embedded Software
*
* Copyright (C) 2005-2021 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
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <www.gnu.org/licenses>.
*
* Contact information:
* <www.state-machine.com/licensing>
* <info@state-machine.com>
******************************************************************************
* @endcond
*/
#include "quit.h"
#include <stdio.h> /* for printf_s() */
#include <stdlib.h> /* for exit() */
#ifndef NDEBUG
#define WIN32_LEAN_AND_MEAN
#include <windows.h> /* for DebugBreak */
#endif
//Q_DEFINE_THIS_MODULE("quit_port")
/* Global objects ==========================================================*/
uint8_t volatile QF_intNest;
/*..........................................................................*/
static int l_test_count;
/*..........................................................................*/
void QUIT_fail_(char const *cond, char const *file, int line) {
printf_s(" FAILED in %s:%d\n"
"%s\n"
"---------------------------------------------\n"
"%d test(s)\n"
"FAILED\n",
file, line, cond, l_test_count);
#ifndef NDEBUG
DebugBreak();
#endif
exit(l_test_count);
}
/*..........................................................................*/
void TEST(char const *title) {
if (l_test_count > 0) {
printf_s(" PASSED\n");
}
printf_s("test: \"%s\" ...", title);
++l_test_count;
}
/*..........................................................................*/
int main(void) {
printf_s("\n%s\n", "QP Unit Internal Testing -- QUIT");
onRunTests();
if (l_test_count > 0) {
printf_s("%s\n", " PASSED");
}
printf_s("---------------------------------------------\n"
"%d test(s)\nOK\n", l_test_count);
return 0; /* success */
}
/*==========================================================================*/
Q_NORETURN Q_onAssert(char_t const * const module, int_t const location) {
QUIT_fail_("Q_onAssert", module, location);
for (;;) { /* explicitly make it "noreturn" */
}
}
/*==========================================================================*/
#ifdef Q_SPY
/*..........................................................................*/
void QS_onCleanup(void) {
}
/*..........................................................................*/
void QS_onReset(void) {
}
/*..........................................................................*/
void QS_onFlush(void) {
}
/*..........................................................................*/
QSTimeCtr QS_onGetTime(void) {
return (QSTimeCtr)0U;
}
/*..........................................................................*/
void QS_onCommand(uint8_t cmdId, uint32_t param1,
uint32_t param2, uint32_t param3)
{
(void)cmdId;
(void)param1;
(void)param2;
(void)param3;
}
#endif