blinky.qm 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <model version="5.1.4" links="1">
  3. <documentation>Simple &quot;Blinky&quot; model</documentation>
  4. <!--${qpc}-->
  5. <framework name="qpc"/>
  6. <!--${AOs}-->
  7. <package name="AOs" stereotype="0x02">
  8. <!--${AOs::Blinky}-->
  9. <class name="Blinky" superclass="qpc::QActive">
  10. <!--${AOs::Blinky::inst}-->
  11. <attribute name="inst" type="Blinky" visibility="0x00" properties="0x01"/>
  12. <!--${AOs::Blinky::timeEvt}-->
  13. <attribute name="timeEvt" type="QTimeEvt" visibility="0x02" properties="0x00"/>
  14. <!--${AOs::Blinky::SM}-->
  15. <statechart properties="0x03">
  16. <!--${AOs::Blinky::SM::initial}-->
  17. <initial target="../1">
  18. <action>(void)par; /* unused parameter */
  19. QTimeEvt_armX(&amp;me-&gt;timeEvt,
  20. BSP_TICKS_PER_SEC/2, BSP_TICKS_PER_SEC/2);</action>
  21. <initial_glyph conn="2,3,5,1,20,4,-4">
  22. <action box="0,-2,6,2"/>
  23. </initial_glyph>
  24. </initial>
  25. <!--${AOs::Blinky::SM::off}-->
  26. <state name="off">
  27. <entry>BSP_ledOff();</entry>
  28. <!--${AOs::Blinky::SM::off::TIMEOUT}-->
  29. <tran trig="TIMEOUT" target="../../2">
  30. <tran_glyph conn="2,13,3,1,18,6,-2">
  31. <action box="0,-2,8,2"/>
  32. </tran_glyph>
  33. </tran>
  34. <state_glyph node="2,5,16,10">
  35. <entry box="1,2,12,4"/>
  36. </state_glyph>
  37. </state>
  38. <!--${AOs::Blinky::SM::on}-->
  39. <state name="on">
  40. <entry>BSP_ledOn();</entry>
  41. <!--${AOs::Blinky::SM::on::TIMEOUT}-->
  42. <tran trig="TIMEOUT" target="../../1">
  43. <tran_glyph conn="2,25,3,1,20,-15,-4">
  44. <action box="0,-2,8,2"/>
  45. </tran_glyph>
  46. </tran>
  47. <state_glyph node="2,17,16,10">
  48. <entry box="1,2,12,4"/>
  49. </state_glyph>
  50. </state>
  51. <state_diagram size="24,29"/>
  52. </statechart>
  53. </class>
  54. </package>
  55. <!--${.}-->
  56. <directory name=".">
  57. <!--${.::blinky.c}-->
  58. <file name="blinky.c">
  59. <text>#include &lt;rtthread.h&gt;
  60. #ifdef QPC_USING_BLINKY_EXAMPLE
  61. #ifdef RT_USING_FINSH
  62. #include &lt;finsh.h&gt;
  63. #include &quot;qpc.h&quot;
  64. Q_DEFINE_THIS_FILE
  65. enum { BSP_TICKS_PER_SEC = 100 };
  66. void BSP_ledOff(void) {
  67. rt_kprintf(&quot;LED OFF\n&quot;);
  68. }
  69. void BSP_ledOn(void) {
  70. rt_kprintf(&quot;LED ON\n&quot;);
  71. }
  72. enum BlinkySignals {
  73. TIMEOUT_SIG = Q_USER_SIG,
  74. MAX_SIG
  75. };
  76. //*============== ask QM to declare the Blinky class ================*/
  77. $declare ${AOs::Blinky}
  78. QActive * const AO_Blinky = &amp;Blinky_inst.super;
  79. static void Blinky_ctor(void) {
  80. Blinky *me = &amp;Blinky_inst;
  81. QActive_ctor(&amp;me-&gt;super, Q_STATE_CAST(&amp;Blinky_initial));
  82. QTimeEvt_ctorX(&amp;me-&gt;timeEvt, &amp;me-&gt;super, TIMEOUT_SIG, 0U);
  83. }
  84. int qpc_blinky_start(void) {
  85. /* statically allocate event queue buffer for the Blinky AO */
  86. static QEvt const *blinky_queueSto[10];
  87. static uint8_t blinky_stack[1024];
  88. QF_init(); /* initialize the framework */
  89. Blinky_ctor(); /* explicitly call the &quot;constructor&quot; */
  90. QACTIVE_START(AO_Blinky,
  91. 1U, /* priority */
  92. blinky_queueSto, Q_DIM(blinky_queueSto),
  93. (void *)blinky_stack, sizeof(blinky_stack), /* no stack */
  94. (void *)0); /* no initialization parameter */
  95. return QF_run(); /* run the QF application */
  96. }
  97. MSH_CMD_EXPORT(qpc_blinky_start, start qpc blinky example);
  98. /*================ ask QM to define the Blinky class ================*/
  99. $define ${AOs::Blinky}
  100. #endif /* RT_USING_FINSH */
  101. #endif /* QPC_USING_BLINKY_EXAMPLE */
  102. </text>
  103. </file>
  104. </directory>
  105. </model>