Deleted.

Committer:
QL
Date:
Tue Feb 15 20:13:34 2011 +0000
Revision:
0:9601fa787c8b
Child:
1:3fe0c7f27d97

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
QL 0:9601fa787c8b 1 //////////////////////////////////////////////////////////////////////////////
QL 0:9601fa787c8b 2 // Model: pelican.qm
QL 0:9601fa787c8b 3 // File: ./ped.cpp
QL 0:9601fa787c8b 4 //
QL 0:9601fa787c8b 5 // This file has been generated automatically by QP Modeler (QM).
QL 0:9601fa787c8b 6 // DO NOT EDIT THIS FILE MANUALLY.
QL 0:9601fa787c8b 7 //
QL 0:9601fa787c8b 8 // Please visit www.state-machine.com/qm for more information.
QL 0:9601fa787c8b 9 //////////////////////////////////////////////////////////////////////////////
QL 0:9601fa787c8b 10 #include "qp_port.h"
QL 0:9601fa787c8b 11 #include "bsp.h"
QL 0:9601fa787c8b 12 #include "pelican.h"
QL 0:9601fa787c8b 13
QL 0:9601fa787c8b 14 Q_DEFINE_THIS_FILE
QL 0:9601fa787c8b 15
QL 0:9601fa787c8b 16 enum PedTimeouts { // various timeouts in ticks
QL 0:9601fa787c8b 17 N_ATTEMPTS = 10, // number of PED_WAITING attempts
QL 0:9601fa787c8b 18 WAIT_TOUT = BSP_TICKS_PER_SEC * 3, // wait between posting PED_WAITING
QL 0:9601fa787c8b 19 OFF_TOUT = BSP_TICKS_PER_SEC * 8 // wait time after posting OFF_SIG
QL 0:9601fa787c8b 20 };
QL 0:9601fa787c8b 21
QL 0:9601fa787c8b 22 // Ped class -----------------------------------------------------------------
QL 0:9601fa787c8b 23 // $(components::Ped) ........................................................
QL 0:9601fa787c8b 24 class Ped : public QActive {
QL 0:9601fa787c8b 25 private:
QL 0:9601fa787c8b 26 QTimeEvt m_timeout;
QL 0:9601fa787c8b 27 uint8_t m_retryCtr;
QL 0:9601fa787c8b 28
QL 0:9601fa787c8b 29 public:
QL 0:9601fa787c8b 30 Ped();
QL 0:9601fa787c8b 31
QL 0:9601fa787c8b 32 protected:
QL 0:9601fa787c8b 33 static QState initial(Ped *me, QEvent const *e);
QL 0:9601fa787c8b 34 static QState wait(Ped *me, QEvent const *e);
QL 0:9601fa787c8b 35 static QState off(Ped *me, QEvent const *e);
QL 0:9601fa787c8b 36 };
QL 0:9601fa787c8b 37
QL 0:9601fa787c8b 38 // Local objects -------------------------------------------------------------
QL 0:9601fa787c8b 39 static Ped l_Ped; // the single instance of Ped active object
QL 0:9601fa787c8b 40
QL 0:9601fa787c8b 41 // Global objects ------------------------------------------------------------
QL 0:9601fa787c8b 42 QActive * const AO_Ped = &l_Ped; // the opaque pointer
QL 0:9601fa787c8b 43
QL 0:9601fa787c8b 44 // Ped class definition ------------------------------------------------------
QL 0:9601fa787c8b 45 // $(components::Ped) ........................................................
QL 0:9601fa787c8b 46 // $(components::Ped::Ped) ...................................................
QL 0:9601fa787c8b 47 Ped::Ped() : QActive((QStateHandler)&Ped::initial), m_timeout(TIMEOUT_SIG) {
QL 0:9601fa787c8b 48 }
QL 0:9601fa787c8b 49 // $(components::Ped::Statechart) ............................................
QL 0:9601fa787c8b 50 // @(/1/1/3/0)
QL 0:9601fa787c8b 51 QState Ped::initial(Ped *me, QEvent const *e) {
QL 0:9601fa787c8b 52 QS_OBJ_DICTIONARY(&l_Ped);
QL 0:9601fa787c8b 53 QS_OBJ_DICTIONARY(&me->m_timeout);
QL 0:9601fa787c8b 54
QL 0:9601fa787c8b 55 QS_FUN_DICTIONARY(&Ped::initial);
QL 0:9601fa787c8b 56 QS_FUN_DICTIONARY(&Ped::wait);
QL 0:9601fa787c8b 57 QS_FUN_DICTIONARY(&Ped::off);
QL 0:9601fa787c8b 58
QL 0:9601fa787c8b 59 QS_SIG_DICTIONARY(TIMEOUT_SIG, &l_Ped); // just for Ped
QL 0:9601fa787c8b 60 return Q_TRAN(&Ped::wait);
QL 0:9601fa787c8b 61 }
QL 0:9601fa787c8b 62 // $(components::Ped::Statechart::wait) ......................................
QL 0:9601fa787c8b 63 QState Ped::wait(Ped *me, QEvent const *e) {
QL 0:9601fa787c8b 64 switch (e->sig) {
QL 0:9601fa787c8b 65 // @(/1/1/3/1)
QL 0:9601fa787c8b 66 case Q_ENTRY_SIG: {
QL 0:9601fa787c8b 67 me->m_retryCtr = N_ATTEMPTS;
QL 0:9601fa787c8b 68 me->m_timeout.postEvery(me, WAIT_TOUT);
QL 0:9601fa787c8b 69 return Q_HANDLED();
QL 0:9601fa787c8b 70 }
QL 0:9601fa787c8b 71 // @(/1/1/3/1)
QL 0:9601fa787c8b 72 case Q_EXIT_SIG: {
QL 0:9601fa787c8b 73 me->m_timeout.disarm();
QL 0:9601fa787c8b 74 return Q_HANDLED();
QL 0:9601fa787c8b 75 }
QL 0:9601fa787c8b 76 // @(/1/1/3/1/0)
QL 0:9601fa787c8b 77 case TIMEOUT_SIG: {
QL 0:9601fa787c8b 78 --me->m_retryCtr;
QL 0:9601fa787c8b 79 // @(/1/1/3/1/0/1)
QL 0:9601fa787c8b 80 if (me->m_retryCtr != 0) {
QL 0:9601fa787c8b 81 QF::publish(Q_NEW(QEvent, PEDS_WAITING_SIG));
QL 0:9601fa787c8b 82 return Q_HANDLED();
QL 0:9601fa787c8b 83 }
QL 0:9601fa787c8b 84 // @(/1/1/3/1/0/0)
QL 0:9601fa787c8b 85 else {
QL 0:9601fa787c8b 86 return Q_TRAN(&Ped::off);
QL 0:9601fa787c8b 87 }
QL 0:9601fa787c8b 88 }
QL 0:9601fa787c8b 89 }
QL 0:9601fa787c8b 90 return Q_SUPER(&QHsm::top);
QL 0:9601fa787c8b 91 }
QL 0:9601fa787c8b 92 // $(components::Ped::Statechart::off) .......................................
QL 0:9601fa787c8b 93 QState Ped::off(Ped *me, QEvent const *e) {
QL 0:9601fa787c8b 94 switch (e->sig) {
QL 0:9601fa787c8b 95 // @(/1/1/3/2)
QL 0:9601fa787c8b 96 case Q_ENTRY_SIG: {
QL 0:9601fa787c8b 97 me->m_timeout.postEvery(me, OFF_TOUT);
QL 0:9601fa787c8b 98 AO_Pelican->postFIFO(Q_NEW(QEvent, OFF_SIG));
QL 0:9601fa787c8b 99 return Q_HANDLED();
QL 0:9601fa787c8b 100 }
QL 0:9601fa787c8b 101 // @(/1/1/3/2)
QL 0:9601fa787c8b 102 case Q_EXIT_SIG: {
QL 0:9601fa787c8b 103 me->m_timeout.disarm();
QL 0:9601fa787c8b 104 return Q_HANDLED();
QL 0:9601fa787c8b 105 }
QL 0:9601fa787c8b 106 // @(/1/1/3/2/0)
QL 0:9601fa787c8b 107 case TIMEOUT_SIG: {
QL 0:9601fa787c8b 108 AO_Pelican->postFIFO(Q_NEW(QEvent, ON_SIG));
QL 0:9601fa787c8b 109
QL 0:9601fa787c8b 110 return Q_TRAN(&Ped::wait);
QL 0:9601fa787c8b 111 }
QL 0:9601fa787c8b 112 }
QL 0:9601fa787c8b 113 return Q_SUPER(&QHsm::top);
QL 0:9601fa787c8b 114 }
QL 0:9601fa787c8b 115