<?xml version="1.0" encoding="UTF-8"?>
<model version="4.6.0" links="1">
 <documentation>PEdestrian LIght CONtrolled (PELICAN) crossing example</documentation>
 <!--${qpn}-->
 <framework name="qpn"/>
 <!--${components}-->
 <package name="components" stereotype="0x02">
  <!--${components::Pelican}-->
  <class name="Pelican" superclass="qpn::QActive">
   <documentation>PEdestrian LIght CONtrolled (PELICAN) crossing</documentation>
   <!--${components::Pelican::flashCtr}-->
   <attribute name="flashCtr" type="uint8_t" visibility="0x02" properties="0x00"/>
   <!--${components::Pelican::SM}-->
   <statechart properties="0x01">
    <!--${components::Pelican::SM::initial}-->
    <initial target="../1">
     <initial_glyph conn="2,2,5,1,72,4,-2">
      <action box="1,-2,27,4"/>
     </initial_glyph>
    </initial>
    <!--${components::Pelican::SM::operational}-->
    <state name="operational">
     <entry brief="CARS_RED; PEDS_DONT_WALK">BSP_signalCars(CARS_RED);
BSP_signalPeds(PEDS_DONT_WALK);</entry>
     <!--${components::Pelican::SM::operational::initial}-->
     <initial target="../3">
      <initial_glyph conn="3,9,5,1,34,9,-2">
       <action box="1,-2,6,2"/>
      </initial_glyph>
     </initial>
     <!--${components::Pelican::SM::operational::OFF}-->
     <tran trig="OFF" target="../../2">
      <tran_glyph conn="2,14,3,1,72,66,-2">
       <action box="0,-2,5,2"/>
      </tran_glyph>
     </tran>
     <!--${components::Pelican::SM::operational::TERMINATE}-->
     <tran trig="TERMINATE">
      <action>QF_stop();</action>
      <tran_glyph conn="2,12,3,-1,15">
       <action box="0,-2,10,2"/>
      </tran_glyph>
     </tran>
     <!--${components::Pelican::SM::operational::carsEnabled}-->
     <state name="carsEnabled">
      <exit brief="CARS_RED">BSP_signalCars(CARS_RED);</exit>
      <!--${components::Pelican::SM::operational::carsEnabled::initial}-->
      <initial target="../1">
       <initial_glyph conn="5,21,5,1,26,4,-2">
        <action box="1,-2,6,2"/>
       </initial_glyph>
      </initial>
      <!--${components::Pelican::SM::operational::carsEnabled::carsGreen}-->
      <state name="carsGreen">
       <entry brief="CARS_GREEN">BSP_signalCars(CARS_GREEN);
/* one-shot timeout in CARS_GREEN_MIN_TOUT ticks */
QActive_armX(&amp;me-&gt;super, 0U, CARS_GREEN_MIN_TOUT, 0U);</entry>
       <exit>QActive_disarmX(&amp;me-&gt;super, 0U);</exit>
       <!--${components::Pelican::SM::operational::carsEnabled::carsGreen::initial}-->
       <initial target="../1">
        <initial_glyph conn="7,31,5,1,17,3,-2">
         <action box="0,-2,6,2"/>
        </initial_glyph>
       </initial>
       <!--${components::Pelican::SM::operational::carsEnabled::carsGreen::carsGreenNoPed}-->
       <state name="carsGreenNoPed">
        <entry>BSP_showState(&quot;carsGreenNoPed&quot;);</entry>
        <!--${components::Pelican::SM::operational::carsEnabled::carsGreen::carsGreenNoPed::PEDS_WAITING}-->
        <tran trig="PEDS_WAITING" target="../../3">
         <tran_glyph conn="8,38,3,1,19,15,-5">
          <action box="0,-2,11,2"/>
         </tran_glyph>
        </tran>
        <!--${components::Pelican::SM::operational::carsEnabled::carsGreen::carsGreenNoPed::Q_TIMEOUT}-->
        <tran trig="Q_TIMEOUT" target="../../2">
         <tran_glyph conn="8,41,3,1,17,4,-3">
          <action box="0,-2,10,2"/>
         </tran_glyph>
        </tran>
        <state_glyph node="8,32,14,10">
         <entry box="1,2,5,2"/>
        </state_glyph>
       </state>
       <!--${components::Pelican::SM::operational::carsEnabled::carsGreen::carsGreenInt}-->
       <state name="carsGreenInt">
        <entry>BSP_showState(&quot;carsGreenInt&quot;);</entry>
        <!--${components::Pelican::SM::operational::carsEnabled::carsGreen::carsGreenInt::PEDS_WAITING}-->
        <tran trig="PEDS_WAITING" target="../../../2">
         <tran_glyph conn="8,49,3,1,25,20,-4">
          <action box="0,-2,11,2"/>
         </tran_glyph>
        </tran>
        <state_glyph node="8,43,14,7">
         <entry box="1,2,5,2"/>
        </state_glyph>
       </state>
       <!--${components::Pelican::SM::operational::carsEnabled::carsGreen::carsGreenPedWait}-->
       <state name="carsGreenPedWait">
        <entry>BSP_showState(&quot;carsGreenPedWait&quot;);</entry>
        <!--${components::Pelican::SM::operational::carsEnabled::carsGreen::carsGreenPedWait::Q_TIMEOUT}-->
        <tran trig="Q_TIMEOUT" target="../../../2">
         <tran_glyph conn="8,57,3,1,23,9,-2">
          <action box="0,-2,10,2"/>
         </tran_glyph>
        </tran>
        <state_glyph node="8,51,14,7">
         <entry box="1,2,5,2"/>
        </state_glyph>
       </state>
       <state_glyph node="6,23,23,37">
        <entry box="1,2,17,2"/>
        <exit box="1,4,5,2"/>
       </state_glyph>
      </state>
      <!--${components::Pelican::SM::operational::carsEnabled::carsYellow}-->
      <state name="carsYellow">
       <entry brief="CARS_YELLOW">BSP_showState(&quot;carsYellow&quot;);
BSP_signalCars(CARS_YELLOW);

/* one-shot timeout in CARS_YELLOW_TOUT ticks */
QActive_armX(&amp;me-&gt;super, 0U, CARS_YELLOW_TOUT, 0U);</entry>
       <exit>QActive_disarmX(&amp;me-&gt;super, 0U);</exit>
       <!--${components::Pelican::SM::operational::carsEnabled::carsYellow::Q_TIMEOUT}-->
       <tran trig="Q_TIMEOUT" target="../../../4">
        <tran_glyph conn="6,71,3,3,33">
         <action box="0,-2,8,2"/>
        </tran_glyph>
       </tran>
       <state_glyph node="6,62,23,10">
        <entry box="1,2,17,2"/>
        <exit box="1,4,5,2"/>
       </state_glyph>
      </state>
      <state_glyph node="4,16,31,58">
       <exit box="1,2,5,2"/>
      </state_glyph>
     </state>
     <!--${components::Pelican::SM::operational::pedsEnabled}-->
     <state name="pedsEnabled">
      <exit brief="PEDS_DONT_WALK">BSP_signalPeds(PEDS_DONT_WALK);</exit>
      <!--${components::Pelican::SM::operational::pedsEnabled::initial}-->
      <initial target="../1">
       <initial_glyph conn="40,21,5,1,21,4,-2">
        <action box="0,-2,6,2"/>
       </initial_glyph>
      </initial>
      <!--${components::Pelican::SM::operational::pedsEnabled::pedsWalk}-->
      <state name="pedsWalk">
       <entry brief="PEDS_WALK">BSP_showState(&quot;pedsWalk&quot;);
BSP_signalPeds(PEDS_WALK);
/* one-shot timeout in PEDS_WALK_TOUT ticks */
QActive_armX(&amp;me-&gt;super, 0U, PEDS_WALK_TOUT, 0U);</entry>
       <exit>QActive_disarmX(&amp;me-&gt;super, 0U);</exit>
       <!--${components::Pelican::SM::operational::pedsEnabled::pedsWalk::Q_TIMEOUT}-->
       <tran trig="Q_TIMEOUT" target="../../2">
        <tran_glyph conn="41,31,3,1,27,7,-2">
         <action box="0,-2,8,2"/>
        </tran_glyph>
       </tran>
       <state_glyph node="41,23,18,10">
        <entry box="1,2,15,2"/>
        <exit box="1,4,5,2"/>
       </state_glyph>
      </state>
      <!--${components::Pelican::SM::operational::pedsEnabled::pedsFlash}-->
      <state name="pedsFlash">
       <entry>BSP_showState(&quot;pedsFlash&quot;);
/* periodic timeout in PEDS_FLASH_TOUT and every PEDS_FLASH_TOUT ticks */
QActive_armX(&amp;me-&gt;super, 0U, PEDS_FLASH_TOUT, PEDS_FLASH_TOUT);
me-&gt;flashCtr = (PEDS_FLASH_NUM * 2U) + 1U;</entry>
       <exit>QActive_disarmX(&amp;me-&gt;super, 0U);</exit>
       <!--${components::Pelican::SM::operational::pedsEnabled::pedsFlash::Q_TIMEOUT}-->
       <tran trig="Q_TIMEOUT">
        <!--${components::Pelican::SM::operational::pedsEnabled::pedsFlash::Q_TIMEOUT::[me->flashCtr!=0U]}-->
        <choice>
         <guard>me-&gt;flashCtr != 0U</guard>
         <action>--me-&gt;flashCtr;</action>
         <!--${components::Pelican::SM::operational::pedsEnabled::pedsFlash::Q_TIMEOUT::[me->flashCtr!=0~::[(me->flashCtr&1U)==0U]}-->
         <choice>
          <guard>(me-&gt;flashCtr &amp; 1U) == 0U</guard>
          <action>BSP_signalPeds(PEDS_DONT_WALK);</action>
          <choice_glyph conn="49,54,5,-1,-5,9,16">
           <action box="-7,9,26,5"/>
          </choice_glyph>
         </choice>
         <!--${components::Pelican::SM::operational::pedsEnabled::pedsFlash::Q_TIMEOUT::[me->flashCtr!=0~::[else]}-->
         <choice>
          <guard>else</guard>
          <action>BSP_signalPeds(PEDS_BLANK);</action>
          <choice_glyph conn="49,54,4,-1,3,11">
           <action box="0,3,22,4"/>
          </choice_glyph>
         </choice>
         <choice_glyph conn="49,45,5,-1,11,9,-11">
          <action box="1,0,16,4"/>
         </choice_glyph>
        </choice>
        <!--${components::Pelican::SM::operational::pedsEnabled::pedsFlash::Q_TIMEOUT::[else]}-->
        <choice target="../../../../3">
         <guard>else</guard>
         <choice_glyph conn="49,45,4,1,3,-14">
          <action box="-7,3,6,2"/>
         </choice_glyph>
        </choice>
        <tran_glyph conn="41,45,3,-1,8">
         <action box="0,-2,8,2"/>
        </tran_glyph>
       </tran>
       <state_glyph node="41,36,25,32">
        <entry box="1,2,5,2"/>
        <exit box="1,4,5,2"/>
       </state_glyph>
      </state>
      <state_glyph node="39,16,31,58">
       <exit box="1,2,5,2"/>
      </state_glyph>
     </state>
     <state_glyph node="2,4,70,72">
      <entry box="1,2,28,2"/>
     </state_glyph>
    </state>
    <!--${components::Pelican::SM::offline}-->
    <state name="offline">
     <entry>BSP_showState(&quot;offline&quot;);
/* periodic timeout in OFF_FLASH_TOUT and every OFF_FLASH_TOUT ticks */
QActive_armX(&amp;me-&gt;super, 0U, OFF_FLASH_TOUT, OFF_FLASH_TOUT);
me-&gt;flashCtr = 0U;</entry>
     <exit>QActive_disarmX(&amp;me-&gt;super, 0U);</exit>
     <!--${components::Pelican::SM::offline::Q_TIMEOUT}-->
     <tran trig="Q_TIMEOUT">
      <action>me-&gt;flashCtr ^= 1U;</action>
      <!--${components::Pelican::SM::offline::Q_TIMEOUT::[(me->flashCtr&1U)==0U]}-->
      <choice>
       <guard>(me-&gt;flashCtr &amp; 1U) == 0U</guard>
       <action brief="\CARS_RED; PEDS_DONT_WALK;">BSP_signalCars(CARS_RED);
BSP_signalPeds(PEDS_DONT_WALK);</action>
       <choice_glyph conn="36,89,5,-1,29">
        <action box="1,0,23,4"/>
       </choice_glyph>
      </choice>
      <!--${components::Pelican::SM::offline::Q_TIMEOUT::[else]}-->
      <choice>
       <guard>else</guard>
       <action brief="CARS_BLANK; PEDS_BLANK;">BSP_signalCars(CARS_BLANK);
BSP_signalPeds(PEDS_BLANK);</action>
       <choice_glyph conn="36,89,4,-1,5,29">
        <action box="1,5,26,2"/>
       </choice_glyph>
      </choice>
      <tran_glyph conn="2,89,3,-1,34">
       <action box="0,-2,22,4"/>
      </tran_glyph>
     </tran>
     <!--${components::Pelican::SM::offline::ON}-->
     <tran trig="ON" target="../../1">
      <tran_glyph conn="2,86,3,2,63,-10">
       <action box="0,-2,6,2"/>
      </tran_glyph>
     </tran>
     <!--${components::Pelican::SM::offline::TERMINATE}-->
     <tran trig="TERMINATE">
      <action>QF_stop();</action>
      <tran_glyph conn="2,93,3,-1,14">
       <action box="0,-2,10,2"/>
      </tran_glyph>
     </tran>
     <state_glyph node="2,78,70,19">
      <entry box="1,2,5,2"/>
      <exit box="1,4,5,2"/>
     </state_glyph>
    </state>
    <state_diagram size="76,99"/>
   </statechart>
  </class>
  <!--${components::AO_Pelican}-->
  <attribute name="AO_Pelican" type="QActive * const" visibility="0x00" properties="0x00"/>
  <!--${components::Pelican_ctor}-->
  <operation name="Pelican_ctor" type="void" visibility="0x00" properties="0x01">
   <documentation>constructor</documentation>
   <code>QActive_ctor(&amp;AO_Pelican.super, Q_STATE_CAST(&amp;Pelican_initial));</code>
  </operation>
 </package>
 <!--${.}-->
 <directory name=".">
  <!--${.::pelican.h}-->
  <file name="pelican.h">
   <text>#ifndef PELICAN_H
#define PELICAN_H

enum PelicanSignals {
    PEDS_WAITING_SIG = Q_USER_SIG,
    OFF_SIG,
    ON_SIG,
    TERMINATE_SIG
};

/* active objects ................................................*/
$declare(components::Pelican_ctor)

extern struct Pelican AO_Pelican;

#endif /* PELICAN_H */
</text>
  </file>
  <!--${.::pelican.c}-->
  <file name="pelican.c">
   <text>#include &quot;qpn.h&quot;     /* QP-nano */
#include &quot;bsp.h&quot;     /* Board Support Package (BSP) */
#include &quot;pelican.h&quot; /* application interface */

/*Q_DEFINE_THIS_FILE*/

#define CARS_GREEN_MIN_TOUT (QTimeEvtCtr)(BSP_TICKS_PER_SEC * 8U)
#define CARS_YELLOW_TOUT    (QTimeEvtCtr)(BSP_TICKS_PER_SEC * 3U)
#define PEDS_WALK_TOUT      (QTimeEvtCtr)(BSP_TICKS_PER_SEC * 3U)
#define PEDS_FLASH_TOUT     (QTimeEvtCtr)(BSP_TICKS_PER_SEC / 5U)
#define PEDS_FLASH_NUM      (uint8_t)(5U * 2U)
#define OFF_FLASH_TOUT      (QTimeEvtCtr)(BSP_TICKS_PER_SEC / 2U)

/* Pelican class declaration -----------------------------------------------*/
$declare(components::Pelican)

/* Global objects ----------------------------------------------------------*/
struct Pelican AO_Pelican; /* the single instance of the Pelican AO */

/* Pelican class definition ------------------------------------------------*/
$define(components::Pelican_ctor)
$define(components::Pelican)</text>
  </file>
 </directory>
</model>
