CIS541 / Mbed 2 deprecated Pacemaker_2

Dependencies:   mbed-rtos mbed

AMachine.h

Committer:
Huazhi
Date:
2015-11-27
Revision:
0:6477530de2c0

File content as of revision 0:6477530de2c0:

/* AMachine */
void AMachine(void const *i)
{
    int CurrentState = AMACHINE_INITIAL;
    RtosTimer local_timer = RtosTimer(AMachine_timer, osTimerPeriodic,(void *)0);
    /*rtos timer can only use static functions as callbacks*/
    local_timer.start(1);
    while (true) {
        int trn = 0;
        switch (CurrentState) {
            case AMACHINE_INITIAL:
                if(AMachine_clock > CURRENT_LRI - AVI) {
                    SyncStatus[APACE] = agre_time;
                    CurrentState = AMACHINE_V;
                    pc.printf("APace ");
                    pc.printf("Time: %ld", agre_time);
                    pc.printf("\n");
                }
        }
        for(trn=0; trn<=4; trn++) {
            if(TRANS[trn].source == CurrentState){
                TRANS[trn].active = true;
            }else{
                TRANS[trn].active = false;
            }
            if(TRANS[trn].active) {
                if(EVAL_GUARD(trn)) {
                    if(TRANS[trn].syncid == NONE || agre_time - SyncStatus[TRANS[trn].syncid] < Broadcase_delay) {
                        CurrentState = TRANS[trn].dest;
                        ASSIGN(trn);
                    }
                }
            }
        }
    }
}