Return to Website   
Quantum Leaps Discussion Forum

Search the Forum for answers or post your questions to the
Quantum Leaps community



Return to Website

  Reply
  Forum

Subject:   Re: Initial Transition QP-Nano
Name:   Miro Samek
Date Posted:   Jul 14, 08 - 10:13 AM
Email:   miro@quantum-leaps.com
Website:   http://www.quantum-leaps.com
Message:   I was thinking about the problem with posting events from top-most initial transitions in QP-nano. Actually, it is very easily to change QP-nano code to initialize all active object priorities before taking the top-most initial transitions. This way, posting events to any active object in the system from any top-most initial transitions will be allowed. I plan to make this change in the next QP-nano release 4.0.02.

For now, you can modify your QF_run() function in qfn.c as follows:

void QF_run(void) {
. . .
/* set priorities all registered active objects... */
for (p = (uint8_t)1; p <= (uint8_t)QF_MAX_ACTIVE; ++p) {
a = (QActive *)Q_ROM_PTR(QF_active[p].act);
Q_ASSERT(a != (QActive *)0);/* QF_active[p] must be initialized */
a->prio = p; /* set the priority of the active object */
}
/* trigger initial transitions in all registered active objects... */
for (p = (uint8_t)1; p <= (uint8_t)QF_MAX_ACTIVE; ++p) {
a = (QActive *)Q_ROM_PTR(QF_active[p].act);
#ifndef QF_FSM_ACTIVE
QHsm_init((QHsm *)a); /* take the initial transition in HSM */
#else
QFsm_init((QFsm *)a); /* take the initial transition in FSM */
#endif
}
. . .
}


For consistency, you should also modify QF_run() in qkn.c as follows:

void QF_run(void) {
. . .
/* set priorities all registered active objects... */
for (p = (uint8_t)1; p <= (uint8_t)QF_MAX_ACTIVE; ++p) {
l_act = (QActive *)Q_ROM_PTR(QF_active[p].act);
Q_ASSERT(l_act != (QActive *)0); /* l_act must be initialized */
l_act->prio = p; /* set the priority of the active object */
}
/* trigger initial transitions in all registered active objects... */
for (p = (uint8_t)1; p <= (uint8_t)QF_MAX_ACTIVE; ++p) {
l_act = (QActive *)Q_ROM_PTR(QF_active[p].act);
#ifndef QF_FSM_ACTIVE
QHsm_init((QHsm *)a); /* take the initial transition in HSM */
#else
QFsm_init((QFsm *)a); /* take the initial transition in FSM */
#endif
}
. . .
}


The changes will give you some more flexibility in QP-nano, where you don’t control the order of active object initialization. In the full-version QP, you control the order of active object initialization, so you can sequence it such that posting events from top-most initial transition to some active objects is possible.

Miro
Replies:    
Re: Initial Transition QP-Nano by Sven Issberner · Jul 14, 08 - 10:16 AM


  Reply
  Forum


powered by Powered by Bravenet bravenet.com