Quantum Leaps e0f9c36c2f 4.5.01
2012-08-14 18:00:48 -04:00

321 lines
11 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<model version="2.2.00">
<documentation>PEdestrian LIghto CONtrolled (PELICA) crossing</documentation>
<framework name="qpcpp"/>
<package name="components" stereotype="0x02" namespace="PELCAN::">
<class name="Pelican" superclass="qpcpp::QActive">
<documentation>PEdestrian LIght CONtrolled (PELICAN) crossing</documentation>
<attribute name="m_timeout" type="QP::QTimeEvt" visibility="0x02" properties="0x00"/>
<attribute name="m_flashCtr" type="uint8_t" visibility="0x02" properties="0x00"/>
<operation name="Pelican" type="QActive(Q_STATE_CAST(&amp;Pelican::initial)), m_timeout(TIMEOUT_SIG)" visibility="0x00" properties="0x02">
<documentation>constructor</documentation>
</operation>
<statechart>
<initial target="../1">
<action>me-&gt;subscribe(PEDS_WAITING_SIG);
me-&gt;subscribe(TERMINATE_SIG);
QS_OBJ_DICTIONARY(&amp;l_Pelican);
QS_OBJ_DICTIONARY(&amp;l_Pelican.m_timeout);
QS_FUN_DICTIONARY(&amp;QP::QHsm::top);
QS_FUN_DICTIONARY(&amp;Pelican::initial);
QS_FUN_DICTIONARY(&amp;Pelican::offline);
QS_FUN_DICTIONARY(&amp;Pelican::operational);
QS_FUN_DICTIONARY(&amp;Pelican::carsEnabled);
QS_FUN_DICTIONARY(&amp;Pelican::carsGreen);
QS_FUN_DICTIONARY(&amp;Pelican::carsGreenNoPed);
QS_FUN_DICTIONARY(&amp;Pelican::carsGreenPedWait);
QS_FUN_DICTIONARY(&amp;Pelican::carsGreenInt);
QS_FUN_DICTIONARY(&amp;Pelican::carsYellow);
QS_FUN_DICTIONARY(&amp;Pelican::pedsEnabled);
QS_FUN_DICTIONARY(&amp;Pelican::pedsWalk);
QS_FUN_DICTIONARY(&amp;Pelican::pedsFlash);
QS_SIG_DICTIONARY(PEDS_WAITING_SIG, (void *)0); // global signals
QS_SIG_DICTIONARY(ON_SIG, (void *)0);
QS_SIG_DICTIONARY(OFF_SIG, (void *)0);
QS_SIG_DICTIONARY(TIMEOUT_SIG, &amp;l_Pelican); // just for Pelican</action>
<initial_glyph conn="2,2,5,1,72,4,-2">
<action box="1,-2,27,4"/>
</initial_glyph>
</initial>
<state name="operational">
<entry brief="CARS_RED; PEDS_DONT_WALK">BSP_signalCars(CARS_RED);
BSP_signalPeds(PEDS_DONT_WALK);</entry>
<initial target="../3">
<initial_glyph conn="3,9,5,1,34,8,-2">
<action box="1,-2,6,2"/>
</initial_glyph>
</initial>
<tran trig="OFF" target="../../2">
<tran_glyph conn="2,14,3,1,72,66,-2">
<action box="0,-2,5,2"/>
</tran_glyph>
</tran>
<tran trig="TERMINATE">
<action>BSP_terminate(0);</action>
<tran_glyph conn="2,12,3,-1,30">
<action box="0,-2,10,2"/>
</tran_glyph>
</tran>
<state name="carsEnabled">
<exit brief="CARS_RED">BSP_signalCars(CARS_RED);</exit>
<initial target="../1">
<initial_glyph conn="5,21,5,1,26,4,-2">
<action box="1,-2,6,2"/>
</initial_glyph>
</initial>
<state name="carsGreen">
<entry brief="CARS_GREEN">BSP_signalCars(CARS_GREEN);
me-&gt;m_timeout.postIn(me, CARS_GREEN_MIN_TOUT);</entry>
<exit>(void)me-&gt;m_timeout.disarm();</exit>
<initial target="../1">
<initial_glyph conn="7,31,5,1,17,3,-2">
<action box="0,-2,6,2"/>
</initial_glyph>
</initial>
<state name="carsGreenNoPed">
<entry>BSP_showState(&quot;carsGreenNoPed&quot;);</entry>
<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>
<tran trig="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>
<state name="carsGreenInt">
<entry>BSP_showState(&quot;carsGreenInt&quot;);</entry>
<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>
<state name="carsGreenPedWait">
<entry>BSP_showState(&quot;carsGreenPedWait&quot;);</entry>
<tran trig="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>
<state name="carsYellow">
<entry brief="CARS_YELLOW">BSP_showState(&quot;carsYellow&quot;);
BSP_signalCars(CARS_YELLOW);
me-&gt;m_timeout.postIn(me, CARS_YELLOW_TOUT);</entry>
<exit>(void)me-&gt;m_timeout.disarm();</exit>
<tran trig="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>
<state name="pedsEnabled">
<exit brief="PEDS_DONT_WALK">BSP_signalPeds(PEDS_DONT_WALK);</exit>
<initial target="../1">
<initial_glyph conn="40,21,5,1,21,4,-2">
<action box="0,-2,6,2"/>
</initial_glyph>
</initial>
<state name="pedsWalk">
<entry brief="PEDS_WALK">BSP_showState(&quot;pedsWalk&quot;);
BSP_signalPeds(PEDS_WALK);
me-&gt;m_timeout.postIn(me, PEDS_WALK_TOUT);</entry>
<exit>(void)me-&gt;m_timeout.disarm();</exit>
<tran trig="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>
<state name="pedsFlash">
<entry>BSP_showState(&quot;pedsFlash&quot;);
me-&gt;m_timeout.postIn(me, PEDS_FLASH_TOUT);
me-&gt;m_flashCtr = PEDS_FLASH_NUM*2 + 1;</entry>
<exit>(void)me-&gt;m_timeout.disarm();</exit>
<tran trig="TIMEOUT">
<choice>
<guard>me-&gt;m_flashCtr != 0U</guard>
<action>--me-&gt;m_flashCtr;</action>
<choice>
<guard>(me-&gt;m_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>
<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>
<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>
<state name="offline">
<entry>BSP_showState(&quot;offline&quot;);
me-&gt;m_timeout.postEvery(me, OFF_FLASH_TOUT);
me-&gt;m_flashCtr = 0U;</entry>
<exit>(void)me-&gt;m_timeout.disarm();</exit>
<tran trig="TIMEOUT">
<action>me-&gt;m_flashCtr ^= 1U;</action>
<choice>
<guard>(me-&gt;m_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>
<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,16,4"/>
</tran_glyph>
</tran>
<tran trig="ON" target="../../1">
<tran_glyph conn="2,86,3,2,63,-10">
<action box="0,-2,6,2"/>
</tran_glyph>
</tran>
<tran trig="TERMINATE">
<action>BSP_terminate(0);</action>
<tran_glyph conn="2,93,3,-1,23">
<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>
<attribute name="AO_Pelican" type="QP::QActive * const" visibility="0x00" properties="0x00"/>
</package>
<directory name=".">
<file name="pelican.h">
<text>#ifndef pelican_h
#define pelican_h
namespace PELICAN {
enum PelicanSignals {
PEDS_WAITING_SIG = QP::Q_USER_SIG,
TERMINATE_SIG,
MAX_PUB_SIG, // the last published signal
ON_SIG,
OFF_SIG,
TIMEOUT_SIG,
MAX_SIG // keep always last
};
// active objects ..................................................
$declare(components::AO_Pelican) // opaque pointer to Pelican AO
} // namespace PELICAN
#endif // pelican_h</text>
</file>
<file name="pelican.cpp">
<text>#include &quot;qp_port.h&quot;
#include &quot;bsp.h&quot;
#include &quot;pelican.h&quot;
namespace PELICAN {
Q_DEFINE_THIS_FILE
enum PelicanTimeouts { // various timeouts in ticks
CARS_GREEN_MIN_TOUT = BSP_TICKS_PER_SEC * 8, // min green for cars
CARS_YELLOW_TOUT = BSP_TICKS_PER_SEC * 3, // yellow for cars
PEDS_WALK_TOUT = BSP_TICKS_PER_SEC * 3, // walking time for peds
PEDS_FLASH_TOUT = BSP_TICKS_PER_SEC / 5, // flashing timeout for peds
PEDS_FLASH_NUM = 5*2, // number of flashes for peds
OFF_FLASH_TOUT = BSP_TICKS_PER_SEC / 2 // flashing timeout when off
};
// Pelican class -------------------------------------------------------------
$declare(components::Pelican)
// Local objects -------------------------------------------------------------
static Pelican l_Pelican; // the single instance of Pelican active object
// Global objects ------------------------------------------------------------
QP::QActive * const AO_Pelican = &amp;l_Pelican; // the opaque pointer
// Pelican class definition --------------------------------------------------
$define(components::Pelican)
} // namespace PELICAN</text>
</file>
</directory>
</model>