/************************************************************************************
* Copyright (C) 2008 by Politehnica University of Bucharest and Rutgers University
* All rights reserved.
* Refer to LICENSE for terms and conditions of use.
***********************************************************************************/
package vnsim.vehicular.simulator.intersections;
import java.io.Serializable;
import vnsim.map.object.Globals;
public class TrafficLightInfo implements Serializable {
/** serialVersionUID
*/
private static final long serialVersionUID = -5883719321862303634L;
//[secs]
public int greenStart;
public int greenEnd;
public int yellowStart;
public int yellowEnd;
public static int TIMEYELLOW=3;
//any other time is red
public TrafficLightInfo(int greenStart, int greenEnd) {
this.greenStart=greenStart;
this.greenEnd=greenEnd;
yellowStart=greenEnd;
yellowEnd=yellowStart+TIMEYELLOW;
}
public TrafficLightInfo(int greenStart, int greenEnd, int yellowTime) {
this.greenStart=greenStart;
this.greenEnd=greenEnd;
yellowStart=greenEnd;
yellowEnd=yellowStart + yellowTime;
}
public int getColor(double timeSec) {
//1=RED, 2=YELLOW, 3=GREEN
if(timeSec>=greenStart && timeSec=yellowStart && timeSec