本文整理汇总了C++中Q_TRAN函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_TRAN函数的具体用法?C++ Q_TRAN怎么用?C++ Q_TRAN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Q_TRAN函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: AlarmMgr_playing
/*..........................................................................*/
QState AlarmMgr_playing(AlarmMgr *me, QEvt const *e) {
switch (e->sig) {
case Q_ENTRY_SIG: {
QTimeEvt_postIn(&me->timer, (QActive *)me,
l_alarms[me->curr_alarm].note[me->curr_note].dur);
TIM_PrescalerConfig(TIM3,
l_alarms[me->curr_alarm].note[me->curr_note].freq);
TIM_CounterCmd(TIM3, TIM_START); /* start noise */
return Q_HANDLED();
}
case Q_EXIT_SIG: {
QTimeEvt_disarm(&me->timer);
return Q_HANDLED();
}
case TIMEOUT_SIG: {
++me->curr_note;
if (me->curr_note == l_alarms[me->curr_alarm].length) {
me->curr_note = 0; /* start over again */
}
return Q_TRAN(&AlarmMgr_playing); /* transition to self */
}
}
return Q_SUPER(&AlarmMgr_on);
}
开发者ID:SmartCocktailFactory,项目名称:QP_LWIP_STM32F2xx_eth_DPP_Example,代码行数:25,代码来源:alarm.c
示例2: switch
// @(/2/1/5/1/3) .............................................................
QP::QState Ship::flying(Ship * const me, QP::QEvt const * const e) {
QP::QState status;
switch (e->sig) {
// @(/2/1/5/1/3)
case Q_ENTRY_SIG: {
me->m_score = 0U; /* reset the score */
ScoreEvt *sev = Q_NEW(ScoreEvt, SCORE_SIG);
sev->score = me->m_score;
AO_Tunnel->POST(sev, me);
status = Q_HANDLED();
break;
}
// @(/2/1/5/1/3/0)
case TIME_TICK_SIG: {
// tell the Tunnel to draw the Ship and test for hits
ObjectImageEvt *oie = Q_NEW(ObjectImageEvt, SHIP_IMG_SIG);
oie->x = me->m_x;
oie->y = me->m_y;
oie->bmp = SHIP_BMP;
AO_Tunnel->POST(oie, me);
++me->m_score; // increment the score for surviving another tick
if ((me->m_score % 10U) == 0U) { // is the score "round"?
ScoreEvt *sev = Q_NEW(ScoreEvt, SCORE_SIG);
sev->score = me->m_score;
AO_Tunnel->POST(sev, me);
}
status = Q_HANDLED();
break;
}
// @(/2/1/5/1/3/1)
case PLAYER_TRIGGER_SIG: {
ObjectPosEvt *ope = Q_NEW(ObjectPosEvt, MISSILE_FIRE_SIG);
ope->x = me->m_x;
ope->y = me->m_y + SHIP_HEIGHT - 1U;
AO_Missile->POST(ope, me);
status = Q_HANDLED();
break;
}
// @(/2/1/5/1/3/2)
case DESTROYED_MINE_SIG: {
me->m_score += Q_EVT_CAST(ScoreEvt)->score;
// the score will be sent to the Tunnel by the next TIME_TICK
status = Q_HANDLED();
break;
}
// @(/2/1/5/1/3/3)
case HIT_WALL_SIG: {
status = Q_TRAN(&Ship::exploding);
break;
}
// @(/2/1/5/1/3/4)
case HIT_MINE_SIG: {
status = Q_TRAN(&Ship::exploding);
break;
}
default: {
status = Q_SUPER(&Ship::active);
break;
}
}
return status;
}
开发者ID:dongkc,项目名称:rtu_drv,代码行数:65,代码来源:ship.cpp
示例3: Q_TRAN
// $(AOs::Usbtask::Statechart) ...............................................
// @(/2/3/2/0)
QState Usbtask::initial(Usbtask *me, QEvent const *e) {
me->usb_tick.postIn(me, USB_TICK_TIME);
return Q_TRAN(&Usbtask::usb_task);
}
开发者ID:felis,项目名称:FSA-EOS,代码行数:6,代码来源:usbtask.cpp
示例4: uiShowMin
static QState uiShowMin(struct UI *me)
{
QTimeEvtCtr timeout = showmaxmintimeout;
int16_t ti;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG:
me->showmaxmincounter ++;
switch (me->showmaxmincounter) {
case 1:
lcd_showstring("MIN T ");
timeout = showmaxmintimeout;
break;
case 2:
lcd_showstring("SINCE ");
timeout = showmaxmintimeout;
break;
case 3:
lcd_showstring("9 AM ");
timeout = showmaxmintimeout;
break;
case 4:
ti = get_min_today()->ti;
if (INVALIDTI == ti)
me->showmaxmincounter ++;
show_temperature(ti);
timeout = 3 * showmaxmintimeout;
break;
case 5:
show_at(&(get_min_today()->time));
timeout = 3 * showmaxmintimeout;
break;
case 6:
lcd_showstring("MIN T ");
timeout = showmaxmintimeout;
break;
case 7:
lcd_showstring("TO LAST");
timeout = showmaxmintimeout;
break;
case 8:
lcd_showstring("9 AM ");
timeout = showmaxmintimeout;
break;
case 9:
ti = get_min_yesterday()->ti;
if (INVALIDTI == ti)
me->showmaxmincounter ++;
show_temperature(ti);
timeout = 3 * showmaxmintimeout;
break;
case 10:
show_at(&(get_min_yesterday()->time));
timeout = 3 * showmaxmintimeout;
break;
default:
Q_ASSERT( 0 );
break;
}
QActive_armX(&me->super, 1, timeout);
return Q_HANDLED();
case Q_TIMEOUT1_SIG:
case BUTTON_DOWN_PRESS_SIGNAL:
if (10 == me->showmaxmincounter)
return Q_TRAN(uiRun);
else
return Q_TRAN(uiShowMin);
}
return Q_SUPER(uiShowMinTop);
}
开发者ID:russells,项目名称:hc2,代码行数:70,代码来源:ui.c
示例5: QHsmTst_initial
/* HSM definition ----------------------------------------------------------*/
QState QHsmTst_initial(QHsmTst *me, QEvt const *e) {
(void)e; /* suppress "e not used" compiler warning */
BSP_display("top-INIT;");
me->foo = 0; /* initialize extended state variable */
return Q_TRAN(&QHsmTst_s2);
}
开发者ID:christation,项目名称:STM32491_CPLR,代码行数:7,代码来源:qhsmtst.c
示例6: Q_TRAN
//--------------------------------------------------------------------------------------------------------------
QState Temperature::initial(Temperature *me, QEvent const *) {
me->initMotorTemperature();
return Q_TRAN(&Temperature::run);
}
开发者ID:tumanako,项目名称:tumanako-inverter-fw-qp,代码行数:6,代码来源:temperature.cpp
示例7: Mine2_planted
/*..........................................................................*/
QState Mine2_planted(Mine2 *me, QEvt const *e) {
uint8_t x;
uint8_t y;
uint8_t bmp;
switch (e->sig) {
case TIME_TICK_SIG: {
if (me->x >= GAME_SPEED_X) {
ObjectImageEvt *oie;
me->x -= GAME_SPEED_X; /* move the mine 1 step */
/* tell the Tunnel to draw the Mine */
oie = Q_NEW(ObjectImageEvt, MINE_IMG_SIG);
oie->x = me->x;
oie->y = me->y;
oie->bmp = MINE2_BMP;
QACTIVE_POST(AO_Tunnel, (QEvt *)oie, me);
}
else {
return Q_TRAN(&Mine2_unused);
}
return Q_HANDLED();
}
case SHIP_IMG_SIG: {
x = (uint8_t)((ObjectImageEvt const *)e)->x;
y = (uint8_t)((ObjectImageEvt const *)e)->y;
bmp = (uint8_t)((ObjectImageEvt const *)e)->bmp;
/* test for incoming Ship hitting this mine */
if (do_bitmaps_overlap(MINE2_BMP, me->x, me->y, bmp, x, y)) {
static MineEvt const mine2_hit = {
{ HIT_MINE_SIG, 0, 0 }, /* the QEvt base instance */
2 /* type of the mine (2 for type-2 mine) */
};
QACTIVE_POST(AO_Ship, (QEvt *)&mine2_hit, me);
/* go straight to 'disabled' and let the Ship do
* the exploding
*/
return Q_TRAN(&Mine2_unused);
}
return Q_HANDLED();
}
case MISSILE_IMG_SIG: {
x = (uint8_t)((ObjectImageEvt const *)e)->x;
y = (uint8_t)((ObjectImageEvt const *)e)->y;
bmp = (uint8_t)((ObjectImageEvt const *)e)->bmp;
/* test for incoming Missile hitting this mine */
/* NOTE: Mine type-2 is nastier than Mine type-1.
* The type-2 mine can hit the Ship with any of its
* "tentacles". However, it can be destroyed by the
* Missile only by hitting its center, defined as
* a smaller bitmap MINE2_MISSILE_BMP.
*/
if (do_bitmaps_overlap(MINE2_MISSILE_BMP,
me->x, me->y, bmp, x, y))
{
static ScoreEvt const mine2_destroyed = {
{ DESTROYED_MINE_SIG, 0, 0 },/*the QEvt base instance */
45 /* score for destroying Mine type-2 */
};
QACTIVE_POST(AO_Missile, (QEvt *)&mine2_destroyed, me);
return Q_TRAN(&Mine2_exploding);
}
return Q_HANDLED();
}
}
return Q_SUPER(&Mine2_used);
}
开发者ID:christation,项目名称:STM32491_CPLR,代码行数:72,代码来源:mine2.c
示例8: UI_num_sd_handler
/*..........................................................................*/
QState UI_num_sd_handler(UI_num_sd *me, QEvt const *e) {
switch (e->sig) {
case Q_ENTRY_SIG: {
uint8_t c;
static char const * const help_sd[] = {
"Standard Deviation: ",
"Find the mean value and the ",
" root-mean-square (RMS) ",
"deviation of n data samples ",
"xi, where i = 1..n. ",
"Mean value <x> is calculated",
"as follows: ",
"<x> = Sum(xi)/n; ",
"Two RMS estimatators are ",
"provided: ",
"sig(n) = ",
" sqrt(Sum(xi-<x>)**2 / n);",
"sig(n-1) = ",
"sqrt(Sum(xi-<x>)**2 / (n-1))"
};
/* instantiate the state-local objects */
me->super.super.help_text = help_sd;
me->super.super.help_len = Q_DIM(help_sd);
me->n = 0.0;
me->sum = 0.0;
me->sum_sq = 0.0;
Video_printStrAt(2, 10, VIDEO_FGND_BLACK,
"Screen 1: Standard Deviation ");
Video_clearRect( 0, 11, 35, 23, VIDEO_BGND_BLUE);
Video_clearRect(35, 11, 80, 23, VIDEO_BGND_BLACK);
c = VIDEO_FGND_LIGHT_GRAY;
Video_printStrAt(36, 12, c,
"Press '-' to enter a negative number");
Video_printStrAt(36, 13, c,
"Press '0' .. '9' to enter a digit");
Video_printStrAt(36, 14, c,
"Press '.' to enter the decimal point");
Video_printStrAt(36, 15, c,
"Press <Enter> to enter the data sample");
Video_printStrAt(36, 16, c,
"Press 'e' or 'E' to Cancel last entry");
Video_printStrAt(36, 17, c,
"Press 'c' or 'C' to Cancel the data set");
c = VIDEO_FGND_WHITE;
Video_printStrAt(36, 20, c,
"Press UP-arrow for previous screen");
Video_printStrAt(36, 21, c,
"Press DOWN-arrow for next screen");
Video_printStrAt(36, 22, c,
"Press F1 for help");
Video_clearRect(NUM_ENTRY_X, NUM_ENTRY_Y,
NUM_ENTRY_X + NUM_STR_WIDTH, NUM_ENTRY_Y + 1,
VIDEO_BGND_BLACK);
Video_drawRect(NUM_ENTRY_X - 1, NUM_ENTRY_Y - 1,
NUM_ENTRY_X + NUM_STR_WIDTH + 1, NUM_ENTRY_Y + 2,
VIDEO_FGND_WHITE, 2);
NumEntry_config(&me->super.num_entry, NUM_ENTRY_X, NUM_ENTRY_Y,
NUM_ENTRY_COLOR);
QHsm_dispatch((QHsm *)&me->super.num_entry, &l_clear_evt);
c = VIDEO_FGND_WHITE; /* labels */
Video_printStrAt(NUM_ENTRY_X - 1, NUM_ENTRY_Y + 4, c,
"n =");
Video_printStrAt(NUM_ENTRY_X - 1, NUM_ENTRY_Y + 5, c,
"<x> =");
Video_printStrAt(NUM_ENTRY_X - 1, NUM_ENTRY_Y + 6, c,
"sig(n) =");
Video_printStrAt(NUM_ENTRY_X - 1, NUM_ENTRY_Y + 7, c,
"sig(n-1) =");
c = VIDEO_FGND_YELLOW; /* values */
Video_printStrAt(NUM_ENTRY_X + 10, NUM_ENTRY_Y + 4, c,
"0 ");
Video_printStrAt(NUM_ENTRY_X + 10, NUM_ENTRY_Y + 5, c,
"N/A ");
Video_printStrAt(NUM_ENTRY_X + 10, NUM_ENTRY_Y + 6, c,
"N/A ");
Video_printStrAt(NUM_ENTRY_X + 10, NUM_ENTRY_Y + 7, c,
"N/A ");
return Q_HANDLED();
}
case Q_EXIT_SIG: {
/* destroy the state-local objects... */
/* noting to destroy */
return Q_HANDLED();
}
case C_SIG: {
return Q_TRAN(&UI_num_sd_handler); /* transition-to-self */
}
case CE_SIG: {
QHsm_dispatch((QHsm *)&me->super.num_entry, &l_clear_evt);
return Q_HANDLED();
}
//.........这里部分代码省略.........
开发者ID:SmartCocktailFactory,项目名称:QP_LWIP_STM32F2xx_eth_DPP_Example,代码行数:101,代码来源:ui_num.c
示例9: Q_TRAN
QState PSConsole::Initial(PSConsole *me, QEvent const *e)
{
return Q_TRAN(&PSConsole::Inactive);
}
开发者ID:Coderlarry,项目名称:PTP_2.0,代码行数:4,代码来源:psconsole.cpp
示例10: switch
QP::QState Txr::flashing(Txr * const me, QP::QEvt const * const e) {
static char ledCnt = 0;
QP::QState status_;
switch (e->sig) {
case Q_ENTRY_SIG:
{
ENC_RED_LED_OFF();
ENC_GREEN_LED_TOGGLE();
me->mFlashTimeout.postEvery(me, FLASH_RATE_TOUT);
me->mCalibrationTimeout.postIn(me, FLASH_DURATION_TOUT);
ledCnt = 0;
/*if (FREESWITCH_ON()) {
me->UpdatePosition(me);
}
else if (ZSWITCH_ON()) {
me->UpdatePositionZMode(me);
}
else {
me->UpdatePositionPlayBack(me);
}*/
status_ = Q_HANDLED();
break;
}
case Q_EXIT_SIG:
{
me->mFlashTimeout.disarm();
ENC_RED_LED_ON();
ENC_GREEN_LED_OFF();
status_ = Q_HANDLED();
break;
}
case CALIBRATION_SIG:
{
// if they've pressed button 2 times calibration should be complete
if (me->mEncPushes >= 2) {
if (FREESWITCH_ON()) {
status_ = Q_TRAN(&freeRun);
}
else if (ZSWITCH_ON()) {
status_ = Q_TRAN(&zmode);
}
else {
status_ = Q_TRAN(&playBack);
}
}
else {
status_ = Q_TRAN(&uncalibrated);
}
break;
}
case FLASH_RATE_SIG:
{
ENC_GREEN_LED_TOGGLE();
status_ = Q_HANDLED();
break;
}
case ENC_DOWN_SIG:
{
// here to swallow the encoder press while flashing; else an exception occurs
status_ = Q_HANDLED();
break;
}
default:
{
status_ = Q_SUPER(&uncalibrated);
break;
}
}
return status_;
}
开发者ID:MotionDogs,项目名称:Lenzhound-dev-pre-release,代码行数:71,代码来源:ao_Txr.cpp
示例11: MenuAO_AlarmMenu
/**
* AlarmMenu state handler
**/
static QState MenuAO_AlarmMenu(MenuAO *me, QEvent const *e)
{
switch ( e->sig )
{
case Q_INIT_SIG:
{
return Q_HANDLED();
}
case Q_ENTRY_SIG:
{
// get current alarm
RTC_GetAlarm(&rtcTime);
sprintf(output, "3: Alarm %02d:%02d", rtcTime.RTC_Hour, rtcTime.RTC_Min);
// display alarm menu (1st row of LCD)
lcd_clear();
set_cursor(0, 0);
lcd_print((unsigned char*)output);
return Q_HANDLED();
}
case BUTTON_SHORTPRESS_SIG:
{
// short press > proceed to next submenu
if (!me->waitingForSetTime)
// guard condition: only if not waiting for set time
return Q_TRAN(&MenuAO_ClockMenu);
else
return Q_HANDLED();
}
case BUTTON_LONGPRESS_SIG:
{
if (me->waitingForSetTime != true)
{
// long press > send change time request and wait for response
me->waitingForSetTime = true;
// send ENTER_SET_TIME_SIG to SetTimeAO
QActive_postFIFO(SetTimeAOBase, (QEvent*)&l_EnterSetTimeEvt);
}
return Q_HANDLED();
}
case TIME_SET_SIG:
{
TimeSetEvt* evt = (TimeSetEvt*)e;
me->waitingForSetTime = false;
// save and arm time at RTC
RTC_AlarmDisable();
RTC_SetAlarm(&evt->time);
RTC_AlarmEnable();
// display new alarm
sprintf(output, "3: Alarm %02d:%02d", evt->time.RTC_Hour, evt->time.RTC_Min);
lcd_clear();
set_cursor(0, 0);
lcd_print((unsigned char*)output);
return Q_HANDLED();
}
case Q_EXIT_SIG:
{
return Q_HANDLED();
}
}
return Q_SUPER(&MenuAO_Idle);
}
开发者ID:roland-wilhelm,项目名称:eds,代码行数:78,代码来源:menu_ao.c
示例12: Philo_initial
/*..........................................................................*/
QState Philo_initial(Philo *me) {
return Q_TRAN(&Philo_thinking);
}
开发者ID:westlicht,项目名称:camcontrol,代码行数:4,代码来源:philo.c
示例13: Bomb4_initial
/*..........................................................................*/
QState Bomb4_initial(Bomb4 *me, QEvent const *e) {
(void)e;
me->timeout = INIT_TIMEOUT;
return Q_TRAN(&Bomb4_setting);
}
开发者ID:keke9036,项目名称:tortoise,代码行数:6,代码来源:bomb4.c
示例14: uiInitial
static QState uiInitial(struct UI *me)
{
return Q_TRAN(scrollText);
}
开发者ID:russells,项目名称:hc2,代码行数:4,代码来源:ui.c
示例15: TServer_initial
/* HSM definition ----------------------------------------------------------*/
QState TServer_initial(TServer *me) {
me->deferredRequest.sig = 0; /* no deferred requests */
return Q_TRAN(&TServer_operational);
}
开发者ID:westlicht,项目名称:camcontrol,代码行数:5,代码来源:defer.c
示例16: aoGrinder_initial
/*${components::aoGrinder::SM} .............................................*/
static QState aoGrinder_initial(aoGrinder * const me) {
/* ${components::aoGrinder::SM::initial} */
TargetDose = 7;
return Q_TRAN(&aoGrinder_idle);
}
开发者ID:stefan-frauenfelder,项目名称:mega2560-qpn-doser,代码行数:6,代码来源:aoGrinder.cpp
示例17: QPrinter_initial
/* @(/1/15/0/0) */
static QState QPrinter_initial(QPrinter * const me, QEvt const * const e) {
return Q_TRAN(&QPrinter_state1);
}
开发者ID:chalot,项目名称:BWRecorder,代码行数:4,代码来源:qprinter.c
示例18: Oper_initial
/*..........................................................................*/
QState Oper_initial(Oper *me) {
return Q_TRAN(&Oper_run);
}
开发者ID:westlicht,项目名称:camcontrol,代码行数:4,代码来源:oper.c
示例19: Q_TRAN
// @(/1/0/3) .................................................................
// @(/1/0/3/0)
QP::QState Pelican::initial(Pelican * const me, QP::QEvt const * const e) {
me->subscribe(PEDS_WAITING_SIG);
return Q_TRAN(&Pelican::operational);
}
开发者ID:ankiys,项目名称:QP_Fraunchpad,代码行数:6,代码来源:ao_pelican.cpp
示例20: switch
//............................................................................
QState Table::serving(Table *me, QEvt const *e) {
uint8_t n, m;
TableEvt *pe;
switch (e->sig) {
case Q_ENTRY_SIG: {
displyTableStat("serving");
for (n = 0; n < N_PHILO; ++n) { // give permissions to eat...
if (me->m_isHungry[n]
&& (me->m_fork[LEFT(n)] == FREE)
&& (me->m_fork[n] == FREE))
{
me->m_fork[LEFT(n)] = me->m_fork[n] = USED;
pe = Q_NEW(TableEvt, EAT_SIG);
pe->philoNum = n;
QF::PUBLISH(pe, me);
me->m_isHungry[n] = 0;
displyPhilStat(n, "eating ");
}
}
return Q_HANDLED();
}
case HUNGRY_SIG: {
n = ((TableEvt *)e)->philoNum;
Q_ASSERT(n < N_PHILO && !me->m_isHungry[n]);
displyPhilStat(n, "hungry ");
m = LEFT(n);
if (me->m_fork[m] == FREE && me->m_fork[n] == FREE) {
me->m_fork[m] = me->m_fork[n] = USED;
pe = Q_NEW(TableEvt, EAT_SIG);
pe->philoNum = n;
QF::PUBLISH(pe, me);
displyPhilStat(n, "eating ");
}
else {
me->m_isHungry[n] = 1;
}
return Q_HANDLED();
}
case DONE_SIG: {
n = ((TableEvt *)e)->philoNum;
Q_ASSERT(n < N_PHILO);
displyPhilStat(n, "thinking");
me->m_fork[LEFT(n)] = me->m_fork[n] = FREE;
m = RIGHT(n); // check the right neighbor
if (me->m_isHungry[m] && me->m_fork[m] == FREE) {
me->m_fork[n] = me->m_fork[m] = USED;
me->m_isHungry[m] = 0;
pe = Q_NEW(TableEvt, EAT_SIG);
pe->philoNum = m;
QF::PUBLISH(pe, me);
displyPhilStat(m, "eating ");
}
m = LEFT(n); // check the left neighbor
n = LEFT(m);
if (me->m_isHungry[m] && me->m_fork[n] == FREE) {
me->m_fork[m] = me->m_fork[n] = USED;
me->m_isHungry[m] = 0;
pe = Q_NEW(TableEvt, EAT_SIG);
pe->philoNum = m;
QF::PUBLISH(pe, me);
displyPhilStat(m, "eating ");
}
return Q_HANDLED();
}
case PAUSE_SIG: // "Toggle" button pressed
case KEY_CENTER_PRESS_SIG: { // hardkey CENTER pressed
return Q_TRAN(&Table::paused);
}
}
return Q_SUPER(&Table::ready);
}
开发者ID:QuantumLeaps,项目名称:qpcpp,代码行数:73,代码来源:table.cpp
注:本文中的Q_TRAN函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论