custom-traffic-control.fsm
The attached model shows you how to do this. You can set the labels timeRed and timeGreen on the traffic control to control how long it is red vs green.
The On Reset and On Message triggers control whether the state label is 1 or 0 (red or green).
The On Entry Request trigger checks the state label and returns TC_ON_ENTRY_REQUEST_QUEUE if the light is red and TC_ON_ENTRY_REQUEST_ALLOW if the light is green.
In the On Message, when the light turns green, it calls the following code to release any requests that are currently pending:
int numWaiting = trafficcontrolinfo(current, TCI_NR_ENTRY_REQUESTS);
for (int i = numWaiting; i >= 1; i--) {
trafficcontrolinfo(current, TCI_ALLOW_ENTRY, i);
}
Phil BoBo
Sr. Manager, Software Development