示例#1
0
// @(/1/0/3/1/3/1) ...........................................................
QP::QState Pelican::pedsWalk(Pelican * const me, QP::QEvt const * const e) {
    QP::QState status_;
    switch (e->sig) {
        // @(/1/0/3/1/3/1)
        case Q_ENTRY_SIG: {
            BSP_showState("pedsWalk");
            BSP_signalPeds(PEDS_WALK);
            me->m_timeout.postIn(me, PEDS_WALK_TOUT);
            status_ = Q_HANDLED();
            break;
        }
        // @(/1/0/3/1/3/1)
        case Q_EXIT_SIG: {
            me->m_timeout.disarm();
            status_ = Q_HANDLED();
            break;
        }
        // @(/1/0/3/1/3/1/0)
        case TIMEOUT_SIG: {
            status_ = Q_TRAN(&Pelican::pedsFlash);
            break;
        }
        default: {
            status_ = Q_SUPER(&Pelican::pedsEnabled);
            break;
        }
    }
    return status_;
}
示例#2
0
// @(/1/0/3/1) ...............................................................
QP::QState Pelican::operational(Pelican * const me, QP::QEvt const * const e) {
    QP::QState status_;
    switch (e->sig) {
        // @(/1/0/3/1)
        case Q_ENTRY_SIG: {
            BSP_signalCars(CARS_RED);
            BSP_signalPeds(PEDS_DONT_WALK);
            status_ = Q_HANDLED();
            break;
        }
        // @(/1/0/3/1/0)
        case Q_INIT_SIG: {
            status_ = Q_TRAN(&Pelican::carsEnabled);
            break;
        }
        // @(/1/0/3/1/1)
        case OFF_SIG: {
            status_ = Q_TRAN(&Pelican::offline);
            break;
        }
        default: {
            status_ = Q_SUPER(&QHsm::top);
            break;
        }
    }
    return status_;
}
示例#3
0
// @(/1/0/3/2) ...............................................................
QP::QState Pelican::offline(Pelican * const me, QP::QEvt const * const e) {
    QP::QState status_;
    switch (e->sig) {
        // @(/1/0/3/2)
        case Q_ENTRY_SIG: {
            BSP_showState("offline");
            me->m_timeout.postEvery(me, OFF_FLASH_TOUT);
            me->m_flashCtr = 0;
            status_ = Q_HANDLED();
            break;
        }
        // @(/1/0/3/2)
        case Q_EXIT_SIG: {
            me->m_timeout.disarm();
            status_ = Q_HANDLED();
            break;
        }
        // @(/1/0/3/2/0)
        case TIMEOUT_SIG: {
            me->m_flashCtr ^= 1;
            // @(/1/0/3/2/0/0)
            if ((me->m_flashCtr & 1) == 0) {
                BSP_signalCars(CARS_RED);
                BSP_signalPeds(PEDS_DONT_WALK);
                status_ = Q_HANDLED();
            }
            // @(/1/0/3/2/0/1)
            else {
                BSP_signalCars(CARS_BLANK);
                BSP_signalPeds(PEDS_BLANK);
                status_ = Q_HANDLED();
            }
            break;
        }
        // @(/1/0/3/2/1)
        case ON_SIG: {
            status_ = Q_TRAN(&Pelican::operational);
            break;
        }
        default: {
            status_ = Q_SUPER(&QHsm::top);
            break;
        }
    }
    return status_;
}
示例#4
0
// @(/1/0/3/1/3/2) ...........................................................
QP::QState Pelican::pedsFlash(Pelican * const me, QP::QEvt const * const e) {
    QP::QState status_;
    switch (e->sig) {
        // @(/1/0/3/1/3/2)
        case Q_ENTRY_SIG: {
            BSP_showState("pedsWalk");
            me->m_timeout.postEvery(me, PEDS_FLASH_TOUT);
            me->m_flashCtr = PEDS_FLASH_NUM*2 + 1;
            status_ = Q_HANDLED();
            break;
        }
        // @(/1/0/3/1/3/2)
        case Q_EXIT_SIG: {
            me->m_timeout.disarm();
            status_ = Q_HANDLED();
            break;
        }
        // @(/1/0/3/1/3/2/0)
        case TIMEOUT_SIG: {
            // @(/1/0/3/1/3/2/0/0)
            if (me->m_flashCtr != 0) {
                --me->m_flashCtr;
                // @(/1/0/3/1/3/2/0/0/0)
                if ((me->m_flashCtr & 1) == 0) {
                    BSP_signalPeds(PEDS_DONT_WALK);
                    status_ = Q_HANDLED();
                }
                // @(/1/0/3/1/3/2/0/0/1)
                else {
                    BSP_signalPeds(PEDS_BLANK);
                    status_ = Q_HANDLED();
                }
            }
            // @(/1/0/3/1/3/2/0/1)
            else {
                status_ = Q_TRAN(&Pelican::carsEnabled);
            }
            break;
        }
        default: {
            status_ = Q_SUPER(&Pelican::pedsEnabled);
            break;
        }
    }
    return status_;
}
示例#5
0
static QState Pelican_offline(Pelican * const me) {
    QState status_;
    switch (Q_SIG(me)) {
        /* @(/1/0/1/2/0) */
        case Q_TIMEOUT_SIG: {
            QActive_armX(&me->super, 0U, OFF_FLASH_TOUT);
            me->flashCtr ^= 1U;
            /* @(/1/0/1/2/0/0) */
            if ((me->flashCtr & 1U) == 0U) {
                BSP_signalCars(CARS_RED);
                BSP_signalPeds(PEDS_DONT_WALK);
                status_ = QM_HANDLED();
            }
            /* @(/1/0/1/2/0/1) */
            else {
                BSP_signalCars(CARS_BLANK);
                BSP_signalPeds(PEDS_BLANK);
                status_ = QM_HANDLED();
            }
            break;
        }
        /* @(/1/0/1/2/1) */
        case ON_SIG: {
            static QActionHandler const act_[] = {
                Q_ACTION_CAST(&Pelican_operational_e),
                Q_ACTION_CAST(&Pelican_operational_i),
                Q_ACTION_CAST(0)
            };
            status_ = QM_TRAN(&Pelican_operational_s, &act_[0]);
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
示例#6
0
static QState Pelican_pedsFlash(Pelican * const me) {
    QState status_;
    switch (Q_SIG(me)) {
        /* @(/1/0/1/1/3/2/0) */
        case Q_TIMEOUT_SIG: {
            /* @(/1/0/1/1/3/2/0/0) */
            if (me->flashCtr != 0U) {
                --me->flashCtr;
                QActive_armX(&me->super, 0U, PEDS_FLASH_TOUT);
                /* @(/1/0/1/1/3/2/0/0/0) */
                if ((me->flashCtr & 1U) == 0U) {
                    BSP_signalPeds(PEDS_DONT_WALK);
                    status_ = QM_HANDLED();
                }
                /* @(/1/0/1/1/3/2/0/0/1) */
                else {
                    BSP_signalPeds(PEDS_BLANK);
                    status_ = QM_HANDLED();
                }
            }
            /* @(/1/0/1/1/3/2/0/1) */
            else {
                static QActionHandler const act_[] = {
                    Q_ACTION_CAST(&Pelican_pedsEnabled_x),
                    Q_ACTION_CAST(&Pelican_carsEnabled_i),
                    Q_ACTION_CAST(0)
                };
                status_ = QM_TRAN(&Pelican_carsEnabled_s, &act_[0]);
            }
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
示例#7
0
// @(/1/0/3/1/3) .............................................................
QP::QState Pelican::pedsEnabled(Pelican * const me, QP::QEvt const * const e) {
    QP::QState status_;
    switch (e->sig) {
        // @(/1/0/3/1/3)
        case Q_EXIT_SIG: {
            BSP_signalPeds(PEDS_DONT_WALK);
            status_ = Q_HANDLED();
            break;
        }
        // @(/1/0/3/1/3/0)
        case Q_INIT_SIG: {
            status_ = Q_TRAN(&Pelican::pedsWalk);
            break;
        }
        default: {
            status_ = Q_SUPER(&Pelican::operational);
            break;
        }
    }
    return status_;
}
示例#8
0
/*..........................................................................*/
QState Pelican_operational(Pelican * const me) { /* a regular state handler */
    QState status_;
    switch (Q_SIG(me)) {
        case Q_ENTRY_SIG: {
            BSP_signalCars(CARS_RED);
            BSP_signalPeds(PEDS_DONT_WALK);
            status_ = Q_HANDLED();
            break;
        }
        case Q_INIT_SIG: {
            status_ = Q_TRAN(&Pelican_carsEnabled); /* regular transition */
            break;
        }
        case OFF_SIG: {
            status_ = Q_TRAN(&Pelican_offline);     /* regular transition */
            break;
        }
        default: {
            status_ = Q_SUPER(&QHsm_top);            /* the superstate */
            break;
        }
    }
    return status_;
}
示例#9
0
/* @(/1/0/1/1/3/1) .........................................................*/
static QState Pelican_pedsWalk_e(Pelican * const me) {
    BSP_showState(me->super.prio, "pedsWalk");
    BSP_signalPeds(PEDS_WALK);
    QActive_armX(&me->super, 0U, PEDS_WALK_TOUT);
    return QM_ENTRY(&Pelican_pedsWalk_s);
}
示例#10
0
/* @(/1/0/1/1/3) ...........................................................*/
static QState Pelican_pedsEnabled_x(Pelican * const me) {
    BSP_signalPeds(PEDS_DONT_WALK);
    return QM_EXIT(&Pelican_pedsEnabled_s);
}
示例#11
0
/* @(/1/0/1/1) .............................................................*/
static QState Pelican_operational_e(Pelican * const me) {
    BSP_signalCars(CARS_RED);
    BSP_signalPeds(PEDS_DONT_WALK);
    return QM_ENTRY(&Pelican_operational_s);
}