mirror of
https://github.com/QuantumLeaps/qpcpp.git
synced 2025-01-28 06:02:56 +08:00
321 lines
11 KiB
Plaintext
321 lines
11 KiB
Plaintext
|
<?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(&Pelican::initial)), m_timeout(TIMEOUT_SIG)" visibility="0x00" properties="0x02">
|
||
|
<documentation>constructor</documentation>
|
||
|
</operation>
|
||
|
<statechart>
|
||
|
<initial target="../1">
|
||
|
<action>me->subscribe(PEDS_WAITING_SIG);
|
||
|
me->subscribe(TERMINATE_SIG);
|
||
|
|
||
|
QS_OBJ_DICTIONARY(&l_Pelican);
|
||
|
QS_OBJ_DICTIONARY(&l_Pelican.m_timeout);
|
||
|
|
||
|
QS_FUN_DICTIONARY(&QP::QHsm::top);
|
||
|
QS_FUN_DICTIONARY(&Pelican::initial);
|
||
|
QS_FUN_DICTIONARY(&Pelican::offline);
|
||
|
QS_FUN_DICTIONARY(&Pelican::operational);
|
||
|
QS_FUN_DICTIONARY(&Pelican::carsEnabled);
|
||
|
QS_FUN_DICTIONARY(&Pelican::carsGreen);
|
||
|
QS_FUN_DICTIONARY(&Pelican::carsGreenNoPed);
|
||
|
QS_FUN_DICTIONARY(&Pelican::carsGreenPedWait);
|
||
|
QS_FUN_DICTIONARY(&Pelican::carsGreenInt);
|
||
|
QS_FUN_DICTIONARY(&Pelican::carsYellow);
|
||
|
QS_FUN_DICTIONARY(&Pelican::pedsEnabled);
|
||
|
QS_FUN_DICTIONARY(&Pelican::pedsWalk);
|
||
|
QS_FUN_DICTIONARY(&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, &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->m_timeout.postIn(me, CARS_GREEN_MIN_TOUT);</entry>
|
||
|
<exit>(void)me->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("carsGreenNoPed");</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("carsGreenInt");</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("carsGreenPedWait");</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("carsYellow");
|
||
|
BSP_signalCars(CARS_YELLOW);
|
||
|
me->m_timeout.postIn(me, CARS_YELLOW_TOUT);</entry>
|
||
|
<exit>(void)me->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("pedsWalk");
|
||
|
BSP_signalPeds(PEDS_WALK);
|
||
|
me->m_timeout.postIn(me, PEDS_WALK_TOUT);</entry>
|
||
|
<exit>(void)me->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("pedsFlash");
|
||
|
me->m_timeout.postIn(me, PEDS_FLASH_TOUT);
|
||
|
me->m_flashCtr = PEDS_FLASH_NUM*2 + 1;</entry>
|
||
|
<exit>(void)me->m_timeout.disarm();</exit>
|
||
|
<tran trig="TIMEOUT">
|
||
|
<choice>
|
||
|
<guard>me->m_flashCtr != 0U</guard>
|
||
|
<action>--me->m_flashCtr;</action>
|
||
|
<choice>
|
||
|
<guard>(me->m_flashCtr & 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("offline");
|
||
|
me->m_timeout.postEvery(me, OFF_FLASH_TOUT);
|
||
|
me->m_flashCtr = 0U;</entry>
|
||
|
<exit>(void)me->m_timeout.disarm();</exit>
|
||
|
<tran trig="TIMEOUT">
|
||
|
<action>me->m_flashCtr ^= 1U;</action>
|
||
|
<choice>
|
||
|
<guard>(me->m_flashCtr & 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 "qp_port.h"
|
||
|
#include "bsp.h"
|
||
|
#include "pelican.h"
|
||
|
|
||
|
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 = &l_Pelican; // the opaque pointer
|
||
|
|
||
|
// Pelican class definition --------------------------------------------------
|
||
|
$define(components::Pelican)
|
||
|
|
||
|
} // namespace PELICAN</text>
|
||
|
</file>
|
||
|
</directory>
|
||
|
</model>
|