/* traffic light FSM */ #if 1 void vTask2(void *pvParameters) { const char *pcTaskName = "Task 2 is running\n"; int *pxPedestrianMessage; int pedestrianVal; current_state = STATE_0; /* As per most tasks, this task is implemented in an infinite loop. */ for (;;) { /* Print out the name of this task. */ vPrintString(pcTaskName); /* here we are in STATE_0 */ long_delay(); FSM(EVENT_FOR_STATE_1); short_delay(); FSM(EVENT_FOR_STATE_2); short_delay(); FSM(EVENT_FOR_STATE_3); short_delay(); FSM(EVENT_FOR_STATE_4); long_delay(); FSM(EVENT_FOR_STATE_5); short_delay(); FSM(EVENT_FOR_STATE_6); short_delay(); #if 1 /* don't block on message */ if (xQueueReceive( xQPedestrian, &( pxPedestrianMessage ), ( portTickType ) 0 )) { /* pxPedestrianMessage either enables or disables * the pedestrian functionality */ if ((int) pxPedestrianMessage == 1) { FSM(EVENT_FOR_STATE_8); long_delay(); FSM(EVENT_FOR_STATE_9); short_delay(); } } #endif FSM(EVENT_FOR_STATE_7); short_delay(); FSM(EVENT_FOR_STATE_0); /* here we are back to STATE_0 * let's re-enable the shell in case it was disabled before */ if (GetUseInputVal() == 0) { SetUseInputVal(1); } } } #else void vTask2(void *pvParameters) { const char *pcTaskName = "Task 2 is running\n"; int *pxPedestrianMessage; int pedestrianVal; current_state = STATE_0; vPrintString(pcTaskName); /* As per most tasks, this task is implemented in an infinite loop. */ for (;;) { /* Print out the name of this task. */ /* here we are in STATE_0 */ /* @@@ todo: add the appropriate delays and states */ /* @@@ todo: replace this with a queue */ /*FSM(EVENT_FOR_STATE_7);*/ /* short_delay(); */ /*FSM(EVENT_FOR_STATE_0);*/ /* here we are back to STATE_0 * let's re-enable the shell in case it was disabled before */ if (GetUseInputVal() == 0) { SetUseInputVal(1); } } } #endif