本文整理汇总了C++中Q_SIG函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_SIG函数的具体用法?C++ Q_SIG怎么用?C++ Q_SIG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Q_SIG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QHsm_init
/*..........................................................................*/
void QHsm_init(QHsm *me) {
QStateHandler t;
Q_ALLEGE((*me->state)(me) == Q_RET_TRAN);/* initial tran. must be taken */
t = (QStateHandler)&QHsm_top; /* an HSM starts in the top state */
do { /* drill into the target hierarchy... */
QStateHandler path[QEP_MAX_NEST_DEPTH_];
int8_t ip = (int8_t)0;
path[0] = me->state;
Q_SIG(me) = (QSignal)QEP_EMPTY_SIG_;
(void)(*me->state)(me);
while (me->state != t) {
++ip;
path[ip] = me->state;
(void)(*me->state)(me);
}
me->state = path[0];
/* entry path must not overflow */
Q_ASSERT(ip < (int8_t)QEP_MAX_NEST_DEPTH_);
Q_SIG(me) = (QSignal)Q_ENTRY_SIG;
do { /* retrace the entry path in reverse (correct) order... */
(void)(*path[ip])(me); /* enter path[ip] */
--ip;
} while (ip >= (int8_t)0);
t = path[0];
Q_SIG(me) = (QSignal)Q_INIT_SIG;
} while ((*t)(me) == Q_RET_TRAN); /* initial transition handled? */
me->state = t;
}
示例2: AlarmClock_mode24hr
/*..........................................................................*/
QState AlarmClock_mode24hr(AlarmClock * const me) {
QState status;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
printf("*** 24-hour mode\n");
status = Q_HANDLED();
break;
}
case Q_TIMEOUT_SIG: {
/* roll over in 24-hr mode? */
if (++me->current_time == 24U*60U) {
me->current_time = 0U;
}
printf("%02d:%02d\n",
me->current_time / 60U, me->current_time % 60U);
/* synchronously dispatch to the orthogonal component */
Q_SIG(&me->alarm) = TIME_SIG;
Q_PAR(&me->alarm) = me->current_time;
QHSM_DISPATCH(&me->alarm.super);
status = Q_HANDLED();
break;
}
default: {
status = Q_SUPER(&AlarmClock_timekeeping);
break;
}
}
return status;
}
示例3: AlarmClock_mode12hr
/*..........................................................................*/
QState AlarmClock_mode12hr(AlarmClock * const me) {
QState status;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
printf("*** 12-hour mode\n");
status = Q_HANDLED();
break;
}
case Q_TIMEOUT_SIG: {
uint32_t h; /* temporary variable to hold hour */
if (++me->current_time == 12U * 60U) { /* roll over in 12-hr mode? */
me->current_time = 0U;
}
h = me->current_time / 60U;
printf("%02d:%02d %s\n", (h % 12U) ? (h % 12U) : 12U,
me->current_time % 60U, (h / 12U) ? "PM" : "AM");
/* synchronously dispatch to the orthogonal component */
Q_SIG(&me->alarm) = TIME_SIG;
Q_PAR(&me->alarm) = me->current_time;
QHSM_DISPATCH(&me->alarm.super);
status = Q_HANDLED();
break;
}
default: {
status = Q_SUPER(&AlarmClock_timekeeping);
break;
}
}
return status;
}
示例4: main
void main(void) {
printf("Ultimate Hook pattern\nQP-nano version: %s\n"
"Press 'a'..'c' to inject signals A..C\n"
"Press 'd' or ESC to inject signal D and quit\n",
QP_getVersion());
UltimateHook_ctor(&l_test); /* instantiate the UltimateHook object */
QHsm_init((QHsm *)&l_test); /* trigger the initial transition */
for (;;) {
uint8_t c;
printf("\n");
c = (uint8_t)getch(); /* read one character from the console */
printf("%c: ", c);
switch (c) {
case 'a': Q_SIG(&l_test) = A_SIG; break;
case 'b': Q_SIG(&l_test) = B_SIG; break;
case 'c': Q_SIG(&l_test) = C_SIG; break;
case 'd':
case 0x1B: Q_SIG(&l_test) = D_SIG; break; /* terminate */
}
/* dispatch the event into the state machine */
QHsm_dispatch((QHsm *)&l_test);
}
}
示例5: AlarmClock_timekeeping
/*..........................................................................*/
QState AlarmClock_timekeeping(AlarmClock * const me) {
QState status;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
/* timeout in one second and every second */
QActive_armX(&me->super, 0U,
BSP_TICKS_PER_SEC, BSP_TICKS_PER_SEC);
status = Q_HANDLED();
break;
}
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
status = Q_HANDLED();
break;
}
case Q_INIT_SIG: {
status = Q_TRAN(&AlarmClock_mode24hr);
break;
}
case CLOCK_12H_SIG: {
status = Q_TRAN(&AlarmClock_mode12hr);
break;
}
case CLOCK_24H_SIG: {
status = Q_TRAN(&AlarmClock_mode24hr);
break;
}
case ALARM_SIG: {
printf("Wake up!!!\n");
status = Q_HANDLED();
break;
}
case ALARM_SET_SIG:
case ALARM_ON_SIG:
case ALARM_OFF_SIG: {
/* synchronously dispatch to the orthogonal component */
Q_SIG(&me->alarm) = Q_SIG(me);
Q_PAR(&me->alarm) = Q_PAR(me);
QHSM_DISPATCH(&me->alarm.super);
status = Q_HANDLED();
break;
}
case TERMINATE_SIG: {
status = Q_TRAN(&AlarmClock_final);
break;
}
default: {
status = Q_SUPER(&QHsm_top);
break;
}
}
return status;
}
示例6: uiMenuSettimeHours
static QState uiMenuSettimeHours(struct UI *me)
{
switch (Q_SIG(me)) {
case Q_ENTRY_SIG:
lcd_buttons(LCD_BUTTONS_ALL);
me->settime_YmdHM = 'H';
display_set_time(me, TRUE, TRUE);
QActive_armX((QActive*)me, 1, 17);
return Q_HANDLED();
case Q_TIMEOUT1_SIG:
return Q_TRAN(uiMenuSettimeHoursFlash);
case BUTTON_ENTER_PRESS_SIGNAL:
ACTION();
return Q_TRAN(uiMenuSettimeMinutes);
case BUTTON_UP_PRESS_SIGNAL:
case BUTTON_UP_LONG_PRESS_SIGNAL:
case BUTTON_UP_REPEAT_SIGNAL:
ACTION();
inc_hour(&me->settime);
display_set_time(me, TRUE, TRUE);
QActive_armX((QActive*)me, 1, 17);
return Q_HANDLED();
case BUTTON_DOWN_PRESS_SIGNAL:
case BUTTON_DOWN_LONG_PRESS_SIGNAL:
case BUTTON_DOWN_REPEAT_SIGNAL:
ACTION();
dec_hour(&me->settime);
display_set_time(me, TRUE, TRUE);
QActive_armX((QActive*)me, 1, 17);
return Q_HANDLED();
}
return Q_SUPER(uiMenu);
}
示例7: scroll
static QState scroll(struct UI *me)
{
switch (Q_SIG(me)) {
case Q_ENTRY_SIG:
SERIALSTR("scroll");
me->scrollstring = banner;
me->scrollindex = 0;
BSP_fast_timer_1(TRUE);
return Q_HANDLED();
case BUTTON_ENTER_PRESS_SIGNAL:
case BUTTON_ENTER_LONG_PRESS_SIGNAL:
case BUTTON_ENTER_REPEAT_SIGNAL:
case BUTTON_UP_PRESS_SIGNAL:
case BUTTON_UP_LONG_PRESS_SIGNAL:
case BUTTON_UP_REPEAT_SIGNAL:
case BUTTON_DOWN_PRESS_SIGNAL:
case BUTTON_DOWN_LONG_PRESS_SIGNAL:
case BUTTON_DOWN_REPEAT_SIGNAL:
case BUTTON_CANCEL_PRESS_SIGNAL:
case BUTTON_CANCEL_LONG_PRESS_SIGNAL:
case BUTTON_CANCEL_REPEAT_SIGNAL:
return Q_TRAN(uiRun);
case Q_EXIT_SIG:
BSP_fast_timer_1(FALSE);
/* If we exit here on a button press, the buttons AO (or the
Basic Timer 1 ISR) may see the button down immediately, with
the result that the UI immediately enters the menu. Avoid
that by telling the buttons to wait. */
post(&buttons.super, BUTTONS_WAIT_SIGNAL, 0);
return Q_HANDLED();
}
return Q_SUPER(uiTop);
}
示例8: uiMenuSettimeMinutesFlash
static QState uiMenuSettimeMinutesFlash(struct UI *me)
{
switch (Q_SIG(me)) {
case Q_ENTRY_SIG:
display_set_time(me, TRUE, FALSE);
QActive_armX((QActive*)me, 1, 8);
return Q_HANDLED();
case Q_TIMEOUT1_SIG:
display_set_time(me, TRUE, TRUE);
return Q_TRAN(uiMenuSettimeMinutes);
case BUTTON_UP_PRESS_SIGNAL:
case BUTTON_UP_LONG_PRESS_SIGNAL:
case BUTTON_UP_REPEAT_SIGNAL:
case BUTTON_DOWN_PRESS_SIGNAL:
case BUTTON_DOWN_LONG_PRESS_SIGNAL:
case BUTTON_DOWN_REPEAT_SIGNAL:
/**
* React to the event by re-displaying the time (without the
* minutes hidden), but don't handle it. This makes the time
* appear on the display as the button is pressed, which is
* move obvious to the user.
*/
display_set_time(me, TRUE, TRUE);
break;
case Q_EXIT_SIG:
QActive_armX((QActive*)me, 1, 17);
return Q_HANDLED();
}
return Q_SUPER(uiMenuSettimeMinutes);
}
示例9: QHsmTst_WAITING
QState QHsmTst_WAITING(QHsmTst *me) {
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
if(elevOrders[currentFloor]) {
arrivedAtFloor(currentFloor,waiting);
tick5();
tick5();
BSP_display("timePassed10;");
BSP_display("waiting-ENTRY;");
arrivedAtFloor(currentFloor,waiting);
}
return Q_HANDLED();
}
case Q_EXIT_SIG: {
BSP_display("waiting-EXIT;");
return Q_HANDLED();
}
case GO_DOWN: {
BSP_display("received-go-down;");
direct = DOWN;
return Q_TRAN(&QHsmTst_MOVING);
}
case GO_UP: {
BSP_display("received-go-up;");
direct = UP;
return Q_TRAN(&QHsmTst_MOVING);
}
}
return Q_SUPER(&QHsmTst_SUPER);
}
示例10: Bomb_timing
/*..........................................................................*/
QState Bomb_timing(Bomb *me) {
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
QActive_arm((QActive *)me, BSP_TICKS_PER_SEC/4);
return Q_HANDLED();
}
case Q_TIMEOUT_SIG: {
QActive_arm((QActive *)me, BSP_TICKS_PER_SEC/4);
if (me->ctr > (uint8_t)0) {
if ((me->ctr & 0x01) != 0) {
LED_on();
}
else {
LED_off();
}
--me->ctr;
}
else { /* timeout expired */
return Q_TRAN(&Bomb_blast);
}
return Q_HANDLED();
}
}
return Q_IGNORED();
}
示例11: Blink_OFF
/*${AOs::Blink::SM::OFF} ...................................................*/
static QState Blink_OFF(Blink * const me) {
QState status_;
switch (Q_SIG(me)) {
/* ${AOs::Blink::SM::OFF} */
case Q_ENTRY_SIG: {
BSP_ledOff();
QActive_arm((QActive *)me, BLINK_TOUT);
status_ = Q_HANDLED();
break;
}
/* ${AOs::Blink::SM::OFF} */
case Q_EXIT_SIG: {
QActive_disarm((QActive *)me);
status_ = Q_HANDLED();
break;
}
/* ${AOs::Blink::SM::OFF::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Blink_ON);
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
示例12: mmi_busy
static QState mmi_busy(struct mmi_ao *me)
{
static const char busy_char[] = ". ";
static uint8_t busy_index;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG:
// Print hello message
lcd_clear();
lcd_write(0, 0, "Busy ...", 0);
QActive_arm((QActive *) me, TIMEOUT_BUSY);
return Q_HANDLED();
case Q_EXIT_SIG:
QActive_disarm((QActive *) me);
return Q_HANDLED();
case Q_TIMEOUT_SIG:
lcd_char(15, 0, busy_char[busy_index]);
busy_index = (busy_index + 1) % (sizeof(busy_char) - 1);
QActive_arm((QActive *) me, TIMEOUT_BUSY);
return Q_HANDLED();
case SIG_KEY_PRESS:
if (Q_PAR(me) == KEY_LEFT) {
QActive_post((QActive *) &prog_ao, SIG_PROG_STOP, 0);
return Q_TRAN(mmi_navigate);
}
return Q_HANDLED();
case SIG_PROG_DONE:
return Q_TRAN(mmi_navigate);
}
return Q_SUPER(&QHsm_top);
}
示例13: uiMenuSettimeHoursFlash
static QState uiMenuSettimeHoursFlash(struct UI *me)
{
switch (Q_SIG(me)) {
case Q_ENTRY_SIG:
display_set_time(me, FALSE, TRUE);
QActive_armX((QActive*)me, 1, 8);
return Q_HANDLED();
case Q_TIMEOUT1_SIG:
display_set_time(me, TRUE, TRUE);
return Q_TRAN(uiMenuSettimeHours);
case BUTTON_UP_PRESS_SIGNAL:
case BUTTON_UP_LONG_PRESS_SIGNAL:
case BUTTON_UP_REPEAT_SIGNAL:
case BUTTON_DOWN_PRESS_SIGNAL:
case BUTTON_DOWN_LONG_PRESS_SIGNAL:
case BUTTON_DOWN_REPEAT_SIGNAL:
/** @see the comment in uiMenuSettimeMinutesFlash() */
display_set_time(me, TRUE, TRUE);
break;
case Q_EXIT_SIG:
QActive_armX((QActive*)me, 1, 17);
return Q_HANDLED();
}
return Q_SUPER(uiMenuSettimeHours);
}
示例14: s_light_timer
QState s_light_timer(ao_light_t * const me)
{
QState status;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG:
light_on();
status = Q_HANDLED();
break;
case LIGHT_OFF_SIG:
status = Q_TRAN(&s_light_off);
break;
case LIGHT_ON_SIG:
status = Q_TRAN(&s_light_on);
break;
case Q_TIMEOUT_SIG:
me->timer -= 1;
if (me->timer == 0)
status = Q_TRAN(&s_light_off);
else
status = Q_HANDLED();
break;
default:
status = Q_SUPER(&QHsm_top);
break;
}
return status;
}
示例15: uiTop
static QState uiTop(struct UI *me)
{
const struct Time *time;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG:
lcd_clear();
lcd_showdigits("6789");
break;
case WATCHDOG_SIGNAL:
// TODO: watchdog reset
return Q_HANDLED();
case TEMPERATURE_SIGNAL:
SERIALSTR("uiTop: TS\r\n");
return Q_HANDLED();
case TIME_SIGNAL:
time = (const struct Time*)(Q_PAR(me));
Q_ASSERT( time->ht >= '0' && time->ht <= '9' );
Q_ASSERT( time->h1 >= '0' && time->h1 <= '9' );
Q_ASSERT( time->mt >= '0' && time->mt <= '9' );
Q_ASSERT( time->m1 >= '0' && time->m1 <= '9' );
show_time(time);
return Q_HANDLED();
case CURRENT_TEMPERATURE_SIGNAL:
/* Handle this signal here, so that no matter where the UI is,
the current temperature will be available when it's
finished. */
me->ti = (int16_t) Q_PAR(me);
return Q_HANDLED();
case BUTTON_CANCEL_PRESS_SIGNAL:
return Q_TRAN(uiRun);
}
return Q_SUPER(QHsm_top);
}