本文整理汇总了C++中QACTIVE_POST函数的典型用法代码示例。如果您正苦于以下问题:C++ QACTIVE_POST函数的具体用法?C++ QACTIVE_POST怎么用?C++ QACTIVE_POST使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QACTIVE_POST函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Missile_flying
/*..........................................................................*/
QState Missile_flying(Missile *me, QEvt const *e) {
switch (e->sig) {
case TIME_TICK_SIG: {
ObjectImageEvt *oie;
if (me->x + GAME_MISSILE_SPEED_X < GAME_SCREEN_WIDTH) {
me->x += GAME_MISSILE_SPEED_X;
/*tell the Tunnel to draw the Missile and test for wall hits*/
oie = Q_NEW(ObjectImageEvt, MISSILE_IMG_SIG);
oie->x = me->x;
oie->y = me->y;
oie->bmp = MISSILE_BMP;
QACTIVE_POST(AO_Tunnel, (QEvt *)oie, me);
}
else { /* Missile outside the range, make it ready to fire again*/
return Q_TRAN(&Missile_armed);
}
return Q_HANDLED();
}
case HIT_WALL_SIG: {
return Q_TRAN(&Missile_exploding);
}
case DESTROYED_MINE_SIG: {
/* tell the Ship the score for destroing this Mine */
QACTIVE_POST(AO_Ship, e, me);
/* re-arm immediately & let the destroyed Mine do the exploding */
return Q_TRAN(&Missile_armed);
}
}
return Q_SUPER(&QHsm_top);
}
示例2: Ship_exploding
/* ${AOs::Ship::SM::active::exploding} */
static QState Ship_exploding(Ship * const me, QEvt const * const e) {
QState status_;
switch (e->sig) {
/* ${AOs::Ship::SM::active::exploding::TIME_TICK} */
case TIME_TICK_SIG: {
/* ${AOs::Ship::SM::active::exploding::TIME_TICK::[me->exp_ctr<1~]} */
if (me->exp_ctr < 15U) {
ObjectImageEvt *oie;
++me->exp_ctr;
/* tell the Tunnel to draw the current stage of Explosion */
oie = Q_NEW(ObjectImageEvt, EXPLOSION_SIG);
oie->bmp = EXPLOSION0_BMP + (me->exp_ctr >> 2);
oie->x = me->x; /* x of explosion */
oie->y = (int8_t)((int)me->y - 4U + SHIP_HEIGHT);
QACTIVE_POST(AO_Tunnel, (QEvt *)oie, me);
status_ = QM_HANDLED();
}
/* ${AOs::Ship::SM::active::exploding::TIME_TICK::[else]} */
else {
static QMTranActTable const tatbl_ = { /* transition-action table */
&Ship_parked_s,
{
Q_ACTION_CAST(0) /* zero terminator */
}
};
ScoreEvt *gameOver = Q_NEW(ScoreEvt, GAME_OVER_SIG);
gameOver->score = me->score;
QACTIVE_POST(AO_Tunnel, (QEvt *)gameOver, me);
status_ = QM_TRAN(&tatbl_);
}
break;
}
示例3: QF_publish_
void QF_publish_(QEvt const * const e, void const * const sender)
#endif
{
QF_CRIT_STAT_
/* make sure that the published signal is within the configured range */
Q_REQUIRE(e->sig < (QSignal)QF_maxSignal_);
QF_CRIT_ENTRY_();
QS_BEGIN_NOCRIT_(QS_QF_PUBLISH, (void *)0, (void *)0)
QS_TIME_(); /* the timestamp */
QS_OBJ_(sender); /* the sender object */
QS_SIG_(e->sig); /* the signal of the event */
QS_2U8_(e->poolId_, e->refCtr_);/* pool Id & ref Count of the event */
QS_END_NOCRIT_()
if (e->poolId_ != (uint8_t)0) { /* is it a dynamic event? */
QF_EVT_REF_CTR_INC_(e); /* increment reference counter, NOTE01 */
}
QF_CRIT_EXIT_();
#if (QF_MAX_ACTIVE <= 8)
{
uint8_t tmp = QF_subscrList_[e->sig].bits[0];
while (tmp != (uint8_t)0) {
uint8_t p = QF_LOG2(tmp);
tmp &= Q_ROM_BYTE(QF_invPwr2Lkup[p]); /* clear subscriber bit */
Q_ASSERT(QF_active_[p] != (QActive *)0); /* must be registered */
/* QACTIVE_POST() asserts internally if the queue overflows */
QACTIVE_POST(QF_active_[p], e, sender);
}
}
#else
{
uint_t i = (uint_t)Q_DIM(QF_subscrList_[0].bits);
do { /* go through all bytes in the subscription list */
uint8_t tmp;
--i;
tmp = QF_PTR_AT_(QF_subscrList_, e->sig).bits[i];
while (tmp != (uint8_t)0) {
uint8_t p = QF_LOG2(tmp);
tmp &= Q_ROM_BYTE(QF_invPwr2Lkup[p]);/*clear subscriber bit */
p = (uint8_t)(p + (uint8_t)(i << 3));/* adjust the priority */
Q_ASSERT(QF_active_[p] != (QActive *)0);/*must be registered*/
/* QACTIVE_POST() asserts internally if the queue overflows */
QACTIVE_POST(QF_active_[p], e, sender);
}
} while (i != (uint_t)0);
}
#endif
QF_gc(e); /* run the garbage collector, see NOTE01 */
}
示例4: Cruncher_processing
/*..........................................................................*/
QState Cruncher_processing(Cruncher * const me, QEvt const * const e) {
QState status;
switch (e->sig) {
case Q_ENTRY_SIG: {
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
reminder->iter = 0;
QACTIVE_POST((QActive *)me, (QEvt const *)reminder, me);
me->sum = 0.0;
status = Q_HANDLED();
break;
}
case CRUNCH_SIG: {
uint32_t i = ((ReminderEvt const *)e)->iter;
uint32_t n = i;
i += 100;
for (; n < i; ++n) {
if ((n & 1) == 0) {
me->sum += 1.0/(2*n + 1);
}
else {
me->sum -= 1.0/(2*n + 1);
}
}
if (i < 0x07000000) {
ReminderEvt *reminder = Q_NEW(ReminderEvt, CRUNCH_SIG);
reminder->iter = i;
QACTIVE_POST((QActive *)me, (QEvt const *)reminder, me);
status = Q_HANDLED();
}
else {
printf("pi=%16.14f\n", 4.0*me->sum);
status = Q_TRAN(&Cruncher_processing);
}
break;
}
case ECHO_SIG: {
printf("Echo! pi=%16.14f\n", 4.0*me->sum);
status = Q_HANDLED();
break;
}
case TERMINATE_SIG: {
status = Q_TRAN(&Cruncher_final);
break;
}
default: {
status = Q_SUPER(&QHsm_top);
break;
}
}
return status;
}
示例5: Missile_exploding
/*..........................................................................*/
QState Missile_exploding(Missile *me, QEvt const *e) {
switch (e->sig) {
case Q_ENTRY_SIG: {
me->exp_ctr = 0;
return Q_HANDLED();
}
case TIME_TICK_SIG: {
if ((me->x >= GAME_SPEED_X) && (me->exp_ctr < 15)) {
ObjectImageEvt *oie;
++me->exp_ctr; /* advance the explosion counter */
me->x -= GAME_SPEED_X; /* move the explosion by one step */
/* tell the Tunnel to render the current stage of Explosion */
oie = Q_NEW(ObjectImageEvt, EXPLOSION_SIG);
oie->x = me->x + 3; /* x-pos of explosion */
oie->y = (int8_t)((int)me->y - 4); /* y-pos */
oie->bmp = EXPLOSION0_BMP + (me->exp_ctr >> 2);
QACTIVE_POST(AO_Tunnel, (QEvt *)oie, me);
}
else { /* explosion finished or moved outside the game */
return Q_TRAN(&Missile_armed);
}
return Q_HANDLED();
}
示例6: Philo_hungry
/*${AOs::Philo::SM::hungry} ................................................*/
QState Philo_hungry(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*${AOs::Philo::SM::hungry} */
case Q_ENTRY_SIG: {
QACTIVE_POST(&AO_Table, HUNGRY_SIG, me->num);
status_ = Q_HANDLED();
break;
}
/*${AOs::Philo::SM::hungry::EAT} */
case EAT_SIG: {
status_ = Q_TRAN(&Philo_eating);
break;
}
/*${AOs::Philo::SM::hungry::DONE} */
case DONE_SIG: {
Q_ERROR(); /* this event should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
示例7: Philo_eating
/*${AOs::Philo::SM::eating} ................................................*/
QState Philo_eating(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*${AOs::Philo::SM::eating} */
case Q_ENTRY_SIG: {
me->tickCtr = EAT_TIME;
status_ = Q_HANDLED();
break;
}
/*${AOs::Philo::SM::eating} */
case Q_EXIT_SIG: {
me->tickCtr = 0U;
QACTIVE_POST(QF_ACTIVE_CAST(&AO_Table), DONE_SIG, me->num);
status_ = Q_HANDLED();
break;
}
/*${AOs::Philo::SM::eating::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Philo_thinking);
break;
}
/*${AOs::Philo::SM::eating::EAT, DONE} */
case EAT_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR(); /* these events should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
示例8: Ship_exploding
/* @(/2/1/4/1/4) ...........................................................*/
static QState Ship_exploding(Ship * const me, QEvt const * const e) {
QState status;
switch (e->sig) {
/* @(/2/1/4/1/4) */
case Q_ENTRY_SIG: {
me->exp_ctr = 0U;
status = Q_HANDLED();
break;
}
/* @(/2/1/4/1/4/0) */
case TIME_TICK_SIG: {
/* @(/2/1/4/1/4/0/0) */
if (me->exp_ctr < 15U) {
++me->exp_ctr;
/* tell the Tunnel to draw the current stage of Explosion */
QACTIVE_POST(AO_Tunnel,
(QEvt *)Q_NEW(ObjectImageEvt, EXPLOSION_SIG,
me->x,
(int8_t)((int)me->y - 4 + SHIP_HEIGHT),
EXPLOSION0_BMP + (me->exp_ctr >> 2)),
me);
status = Q_HANDLED();
}
/* @(/2/1/4/1/4/0/1) */
else {
QACTIVE_POST(AO_Tunnel,
(QEvt *)Q_NEW(ScoreEvt, GAME_OVER_SIG, me->score),
me);
status = Q_TRAN(&Ship_parked);
}
break;
}
示例9: Mine2_exploding
/* ${AOs::Mine2::SM::used::exploding} */
static QState Mine2_exploding(Mine2 * const me, QEvt const * const e) {
QState status_;
switch (e->sig) {
/* ${AOs::Mine2::SM::used::exploding::TIME_TICK} */
case TIME_TICK_SIG: {
/* ${AOs::Mine2::SM::used::exploding::TIME_TICK::[stillonscreen?]} */
if ((me->x >= GAME_SPEED_X) && (me->exp_ctr < 15U)) {
ObjectImageEvt *oie;
++me->exp_ctr; /* advance the explosion counter */
me->x -= GAME_SPEED_X; /* move explosion by 1 step */
/* tell the Game to render the current stage of Explosion */
oie = Q_NEW(ObjectImageEvt, EXPLOSION_SIG);
oie->x = me->x + 1U; /* x of explosion */
oie->y = (int8_t)((int)me->y - 4 + 2); /* y of explosion */
oie->bmp = EXPLOSION0_BMP + (me->exp_ctr >> 2);
QACTIVE_POST(AO_Tunnel, (QEvt *)oie, me);
status_ = QM_HANDLED();
}
/* ${AOs::Mine2::SM::used::exploding::TIME_TICK::[else]} */
else {
static struct {
QMState const *target;
QActionHandler act[2];
} const tatbl_ = { /* transition-action table */
&Mine2_unused_s, /* target state */
{
Q_ACTION_CAST(&Mine2_used_x), /* exit */
Q_ACTION_CAST(0) /* zero terminator */
}
};
status_ = QM_TRAN(&tatbl_);
}
break;
}
示例10: INT_Excep_IRQ9
//;0x0124 IRQ9
void INT_Excep_IRQ9(void) {
QF_ISR_ENTRY(); /* inform the QF Vanilla kernel about entering the ISR */
QACTIVE_POST(AO_Philo[1], Q_NEW(QEvt, MAX_PUB_SIG), /* for testing... */
&QS_Excep_IRQ9);
QF_ISR_EXIT(); /* inform the QF Vanilla kernel about exiting the ISR */
}
示例11: Missile_exploding
/* ${AOs::Missile::SM::exploding} */
static QState Missile_exploding(Missile * const me, QEvt const * const e) {
QState status_;
switch (e->sig) {
/* ${AOs::Missile::SM::exploding::TIME_TICK} */
case TIME_TICK_SIG: {
/* ${AOs::Missile::SM::exploding::TIME_TICK::[(me->x>=GAME_SPEED_X)&&(me->exp~} */
if ((me->x >= GAME_SPEED_X) && (me->exp_ctr < 15U)) {
ObjectImageEvt *oie;
++me->exp_ctr; /* advance the explosion counter */
me->x -= GAME_SPEED_X; /* move the explosion by one step */
/* tell the Tunnel to render the current stage of Explosion */
oie = Q_NEW(ObjectImageEvt, EXPLOSION_SIG);
oie->x = me->x + 3U; /* x-pos of explosion */
oie->y = (int8_t)((int)me->y - 4U); /* y-pos */
oie->bmp = EXPLOSION0_BMP + (me->exp_ctr >> 2);
QACTIVE_POST(AO_Tunnel, (QEvt *)oie, me);
status_ = QM_HANDLED();
}
/* ${AOs::Missile::SM::exploding::TIME_TICK::[else]} */
else {
static QMTranActTable const tatbl_ = { /* transition-action table */
&Missile_armed_s,
{
Q_ACTION_CAST(0) /* zero terminator */
}
};
status_ = QM_TRAN(&tatbl_);
}
break;
}
示例12: Mine2_exploding
/*..........................................................................*/
QState Mine2_exploding(Mine2 *me, QEvt const *e) {
switch (e->sig) {
case Q_ENTRY_SIG: {
me->exp_ctr = 0;
return Q_HANDLED();
}
case TIME_TICK_SIG: {
if ((me->x >= GAME_SPEED_X) && (me->exp_ctr < 15)) {
ObjectImageEvt *oie;
++me->exp_ctr; /* advance the explosion counter */
me->x -= GAME_SPEED_X; /* move explosion by 1 step */
/* tell the Game to render the current stage of Explosion */
oie = Q_NEW(ObjectImageEvt, EXPLOSION_SIG);
oie->x = me->x + 1; /* x of explosion */
oie->y = (int8_t)((int)me->y - 4 + 2); /* y of explosion */
oie->bmp = EXPLOSION0_BMP + (me->exp_ctr >> 2);
QACTIVE_POST(AO_Tunnel, (QEvt *)oie, me);
}
else {
return Q_TRAN(&Mine2_unused);
}
return Q_HANDLED();
}
示例13: Philo_hungry
/* @(/2/0/2/2) .............................................................*/
QState Philo_hungry(Philo *me, QEvent const *e) {
switch (e->sig) {
/* @(/2/0/2/2) */
case Q_ENTRY_SIG: {
TableEvt *pe = Q_NEW(TableEvt, HUNGRY_SIG);
pe->philoNum = PHILO_ID(me);
QACTIVE_POST(AO_Table, (QEvent const *)pe, me);
return Q_HANDLED();
}
/* @(/2/0/2/2/0) */
case EAT_SIG: {
/* @(/2/0/2/2/0/0) */
if (((TableEvt const *)e)->philoNum == PHILO_ID(me)) {
BSP_busyDelay();
return Q_TRAN(&Philo_eating);
}
break;
}
/* @(/2/0/2/2/1) */
case TERMINATE_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR();
return Q_HANDLED();
}
}
return Q_SUPER(&QHsm_top);
}
示例14: INT_Excep_IRQ10
//;0x0128 IRQ10
void INT_Excep_IRQ10(void) {
QK_ISR_ENTRY(); /* inform the QK kernel about entering the ISR */
QACTIVE_POST(AO_Table, Q_NEW(QEvt, MAX_PUB_SIG), /* for testing... */
&QS_Excep_IRQ10);
QK_ISR_EXIT(); /* inform the QK kernel about exiting the ISR */
}
示例15: QF_tick
void QF_tick(void) { /* see NOTE01 */
#else
void QF_tick(void const *sender) {
#endif
QTimeEvt *t;
QF_CRIT_STAT_
QF_CRIT_ENTRY_();
QS_BEGIN_NOCRIT_(QS_QF_TICK, (void *)0, (void *)0)
QS_TEC_((QTimeEvtCtr)(++QS_tickCtr_)); /* the tick counter */
QS_END_NOCRIT_()
t = QF_timeEvtListHead_;
while (t != (QTimeEvt *)0) {
--t->ctr;
if (t->ctr == (QTimeEvtCtr)0) { /* is time evt about to expire? */
if (t->interval != (QTimeEvtCtr)0) { /* is it periodic timeout? */
t->ctr = t->interval; /* rearm the time event */
}
else { /* one-shot timeout, disarm by removing it from the list */
if (t == QF_timeEvtListHead_) {
QF_timeEvtListHead_ = t->next;
}
else {
if (t->next != (QTimeEvt *)0) { /* not the last event? */
t->next->prev = t->prev;
}
t->prev->next = t->next;
}
t->prev = (QTimeEvt *)0; /* mark the event disarmed */
QS_BEGIN_NOCRIT_(QS_QF_TIMEEVT_AUTO_DISARM, QS_teObj_, t)
QS_OBJ_(t); /* this time event object */
QS_OBJ_(t->act); /* the active object */
QS_END_NOCRIT_()
}
QS_BEGIN_NOCRIT_(QS_QF_TIMEEVT_POST, QS_teObj_, t)
QS_TIME_(); /* timestamp */
QS_OBJ_(t); /* the time event object */
QS_SIG_(t->super.sig); /* signal of this time event */
QS_OBJ_(t->act); /* the active object */
QS_END_NOCRIT_()
QF_CRIT_EXIT_();/* exit crit. section before calling QF service */
/* QACTIVE_POST() asserts internally if the queue overflows */
QACTIVE_POST(t->act, &t->super, sender);
}
else {
static uint8_t volatile dummy;
QF_CRIT_EXIT_();
dummy = (uint8_t)0; /* execute a few instructions, see NOTE02 */
}
QF_CRIT_ENTRY_(); /* enter crit. section again to advance the link */
t = t->next;
}