FSM Template
void function taskX() {
 
/* this snippet illustrates the general FSM implementation */
/* behaviour in this case is nothing more than showing the current state (P1) and
    stepping  from  state to state */
 
   enum  tTask2State {INIT,NORMAL,REPORTING};
   static enum tTask2State state = INIT;
   switch (state) {
 
     case INIT:
       /* do activities */
       P1=INIT;
 
       /* check need for transitions*/
       state=(++state)%3; 
     break;
 
     case NORMAL:
       /* do activities */
       P1=NORMAL;
       /* check need for transitions*/
       state=(++state)%3;        
     break;
 
     case REPORTING:
        /* do activities */
        P1=REPORTING;
 
       /* check need for transitions*/
       state=(++state)%3;
 
     break;
 
     default:
 
     break;
    }  
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License