Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

traffic
Class OIntersection  view OIntersection download OIntersection.java

java.lang.Object
  extended bytraffic.OIntersection
All Implemented Interfaces:
java.io.Serializable

public class OIntersection
extends java.lang.Object
implements java.io.Serializable

A named container for traffic Phases. Also handles logic for traffic lights. OIntersection is created by GIntersection, modified by GPhases and stored in OCity

Since:
2003/06/07 04:25:52
Version:
1.5, 2003/08/01 17:39:53

Field Summary
private  float[] actext
           
private  float[] actime
           
private  float[] actmax
           
private  boolean[][] actph
           
private  int[] frags
           
private  boolean[] fragused
           
private  float[] gleft
           
private  boolean gmainup
           
private  boolean gothup
           
private  float[] gtime
           
private  float intrad
           
private  java.lang.String[] IStreet
           
private  int lasturn
           
private  boolean leading
           
private  int[] llph
           
private  float[] looploc
           
private  float[] ltpct
           
private  int[] ltque
           
private  int main
           
private  boolean majon
           
private  boolean mapped
           
private  int mapx
           
private  int mapy
           
private  float offleft
           
private  float offset
           
private  boolean[] olon
           
private  boolean[] olused
           
private  int other
           
private  boolean[] permleft
           
private  boolean phma
           
private  boolean phmb
           
private  boolean phoa
           
private  boolean phob
           
private  boolean[] phused
           
private  float redc
           
private  float redleft
           
private  boolean[] redright
           
private  boolean[] restact
           
private  float[] rtpct
           
private  int[] rtque
           
private  boolean[] stop
           
private  boolean[] vehtrp
           
private  float[] yleft
           
private  boolean ymainup
           
private  boolean yothup
           
private  float[] ytime
           
 
Constructor Summary
OIntersection(java.lang.String[] stname, int[] pfrag, boolean[] used)
          Constructs the OIntersection Object.
 
Method Summary
 void checkMajor()
          Check the major street (1/5) to find the first phases
 void checkMinor()
          Check the minor street (3/7) to find the first phases
 void doActGreen(int iphs)
          Decrements the remaining green time and handle actuation if needed.
 void expungeLights()
          Sets the time for all of the lights back to their starting points.
 float getActExt(int iphs)
          Gets the time that will replace the current green time each time the loop is actuated.
 float getActMax(int iphs)
          Gets the maximum amout of green time allowed.
 float getGLeft(int sidx)
          Gets the phase Yellow time remaining.
 float getGTime(int sidx)
          Gets the phase green time
 float getIntRad()
          Gets the OIntersection radius
 java.lang.String getIStreet(int sidx)
          Gets an OStreet from this OIntersection.
 float getLeftPCT(int ifrag)
          Gets the OIntersection left turn preference percent.
 int getLeftQue(int ifrag)
          Gets the OIntersection left turn queue length.
 float getLoopLoc(int iphs)
          Gets the distance between the loop and the center of the intersection, in seconds at the speed limit.
 int getMapX()
          Gets the OIntersection X map coordinate.
 int getMapY()
          Gets the OIntersection Y map coordinate.
 float getOffSet()
          Gets the OIntersection offset from time zero.
 int getPFrag(int sidx)
          Gets an OFragment from this OIntersection.
 float getRedC()
          Gets the OIntersection all red clearance time
 float getRightPCT(int ifrag)
          Gets the OIntersection right turn preference percent.
 int getRightQue(int ifrag)
          Gets the OIntersection right turn queue length.
 float getYLeft(int sidx)
          Gets the phase Green time remaining.
 float getYTime(int sidx)
          Gets the phase Yellow time.
 boolean isActPh(int iphs, int ophs)
          True if the first phase actuates the second (recall) phase.
 boolean isActTripped(int curph)
          True if a recall phase is actuating the current phase.
 boolean isFragUsed(int ifrag)
          True if OFragment is used at this OIntersection
 boolean isGreen(int sidx)
          True if phase is green
 boolean isLeading()
          True if the left turns lead at this OIntersection
 boolean isLoopHit(int iphs)
          True if a loop has been actuated.
 boolean isMapped()
          True if OIntersection is mapped.
 boolean isOLGreen(int sidx)
          True if overlap is green.
 boolean isOLRed(int sidx)
          True if overlap is red
 boolean isOLUsed(int ifrag)
          True if the overlap is used.
 boolean isOLYellow(int sidx)
          True if overlap is yellow
 boolean isPermLeft(int ifrag)
          True if the OFragment permits left turns.
 boolean isPhUsed(int iphs)
          True if phase is used.
 boolean isRed(int sidx)
          True if phase is red
 boolean isRedRight(int ifrag)
          True if the OFragment permits right on red.
 boolean isRestAct(int iphs)
          True if the phase is a recall phase.
 boolean isStop(int ifrag)
          True if a stop sign is at the end of the OFragment
 boolean isYellow(int sidx)
          True if phase is yellow
 boolean leftStop(int ifrag)
          Returns true when oncoming traffic has cleared and it is safe to proceed through a permitted left.
 boolean rightStop(int ifrag)
          Returns true when oncoming left turn and left hand traffic has cleared and it is safe to proceed through a right on red.
 void runTraffic()
          this method handles the signal sequence.
 boolean safeStop(int ifrag)
          Returns true when it is safe to proceed through a stop sign.
 void setActExt(float ext, int iphs)
          Sets the time that will replace the current green time each time the loop is actuated.
 void setActMax(float max, int iphs)
          Sets the maximum amout of green time allowed.
 void setActPh(boolean state, int iphs, int ophs)
          Set the first phase to actuate (or stop actuating) the second (recall) phase.
 void setFragUsed(boolean state, int ifrag)
          Set OFragment usage at this OIntersection.
 void setGTime(float itime, int sidx)
          Sets the phase green time
 void setIntRad(float rad)
          Sets the OIntersection radius.
 void setIStreet(java.lang.String name, int sidx)
          Sets an OStreet at this OIntersection.
 void setLeading(boolean state)
          Specify that the left turns should lead at this OIntersection
 void setLeftPCT(float lpct, int ifrag)
          Sets the OFragment left turn preference percent.
 void setLeftQue(int lque, int ifrag)
          Sets the OFragment left turn queue length.
 void setLoopLoc(float time, int iphs)
          Sets the location of the loop.
 void setMapCoords(int xxx, int yyy)
          Sets the OIntersection X and Y map coordinate.
 void setMapped(boolean state)
          Sets the OIntersection mapped state.
 void setOffSet(float itime)
          sets the OIntersection offset from time zero.
 void setOLUsed(boolean state, int ifrag)
          Specify that the overlap should be used.
 void setPermLeft(boolean state, int ifrag)
          Specify if the OFragment should permit left turns.
 void setPFrag(int ifrag, int sidx)
          Sets an OFragment at this OIntersection.
 void setPhUsed(boolean state, int iphs)
          specify that phase is used.
 void setRedC(float itime)
          Sets the OIntersection all red clearance time.
 void setRedRight(boolean state, int ifrag)
          Specify if the OFragment should permit right on red.
 void setRestAct(boolean state, int iphs)
          Make the phase a recall phase.
 void setRightPCT(float rpct, int ifrag)
          Sets the OFragment right turn preference percent.
 void setRightQue(int rque, int ifrag)
          Sets the OFragment right turn queue length.
 void setStop(boolean state, int ifrag)
          Plant (or remove) a stop sign at the end of the OFragment
 void setYTime(float itime, int sidx)
          Sets the phase Yellow time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IStreet

private java.lang.String[] IStreet

frags

private int[] frags

fragused

private boolean[] fragused

leading

private boolean leading

intrad

private float intrad

lasturn

private int lasturn

stop

private boolean[] stop

permleft

private boolean[] permleft

redright

private boolean[] redright

rtpct

private float[] rtpct

rtque

private int[] rtque

ltpct

private float[] ltpct

ltque

private int[] ltque

restact

private boolean[] restact

actph

private boolean[][] actph

vehtrp

private boolean[] vehtrp

looploc

private float[] looploc

actmax

private float[] actmax

actext

private float[] actext

offset

private float offset

redc

private float redc

offleft

private float offleft

redleft

private float redleft

gtime

private float[] gtime

gleft

private float[] gleft

ytime

private float[] ytime

yleft

private float[] yleft

actime

private float[] actime

main

private int main

other

private int other

majon

private boolean majon

phma

private boolean phma

phmb

private boolean phmb

phoa

private boolean phoa

phob

private boolean phob

gmainup

private boolean gmainup

gothup

private boolean gothup

ymainup

private boolean ymainup

yothup

private boolean yothup

llph

private int[] llph

phused

private boolean[] phused

olused

private boolean[] olused

olon

private boolean[] olon

mapped

private boolean mapped

mapx

private int mapx

mapy

private int mapy
Constructor Detail

OIntersection

public OIntersection(java.lang.String[] stname,
                     int[] pfrag,
                     boolean[] used)
Constructs the OIntersection Object. OIntersection is created by GIntersection, modified by GPhases and stored in OCity

Method Detail

getIStreet

public java.lang.String getIStreet(int sidx)
Gets an OStreet from this OIntersection.


setIStreet

public void setIStreet(java.lang.String name,
                       int sidx)
Sets an OStreet at this OIntersection.


getPFrag

public int getPFrag(int sidx)
Gets an OFragment from this OIntersection.


setPFrag

public void setPFrag(int ifrag,
                     int sidx)
Sets an OFragment at this OIntersection.


isFragUsed

public boolean isFragUsed(int ifrag)
True if OFragment is used at this OIntersection


setFragUsed

public void setFragUsed(boolean state,
                        int ifrag)
Set OFragment usage at this OIntersection. If the OFragment is no longer used, remove the phases and overlaps that would require it.


safeStop

public boolean safeStop(int ifrag)
Returns true when it is safe to proceed through a stop sign.


leftStop

public boolean leftStop(int ifrag)
Returns true when oncoming traffic has cleared and it is safe to proceed through a permitted left.


rightStop

public boolean rightStop(int ifrag)
Returns true when oncoming left turn and left hand traffic has cleared and it is safe to proceed through a right on red.


isStop

public boolean isStop(int ifrag)
True if a stop sign is at the end of the OFragment


setStop

public void setStop(boolean state,
                    int ifrag)
Plant (or remove) a stop sign at the end of the OFragment


isActTripped

public boolean isActTripped(int curph)
True if a recall phase is actuating the current phase.


isRestAct

public boolean isRestAct(int iphs)
True if the phase is a recall phase.


setRestAct

public void setRestAct(boolean state,
                       int iphs)
Make the phase a recall phase.


isActPh

public boolean isActPh(int iphs,
                       int ophs)
True if the first phase actuates the second (recall) phase.


setActPh

public void setActPh(boolean state,
                     int iphs,
                     int ophs)
Set the first phase to actuate (or stop actuating) the second (recall) phase.


getLoopLoc

public float getLoopLoc(int iphs)
Gets the distance between the loop and the center of the intersection, in seconds at the speed limit.


setLoopLoc

public void setLoopLoc(float time,
                       int iphs)
Sets the location of the loop.


setActMax

public void setActMax(float max,
                      int iphs)
Sets the maximum amout of green time allowed.


getActMax

public float getActMax(int iphs)
Gets the maximum amout of green time allowed.


setActExt

public void setActExt(float ext,
                      int iphs)
Sets the time that will replace the current green time each time the loop is actuated. This only happens when the extension is greater than the remaining green time.


getActExt

public float getActExt(int iphs)
Gets the time that will replace the current green time each time the loop is actuated. This only happens when the extension is greater than the remaining green time.


doActGreen

public void doActGreen(int iphs)
Decrements the remaining green time and handle actuation if needed.


isLoopHit

public boolean isLoopHit(int iphs)
True if a loop has been actuated. This method was created for the query system


setRightPCT

public void setRightPCT(float rpct,
                        int ifrag)
Sets the OFragment right turn preference percent.


getRightPCT

public float getRightPCT(int ifrag)
Gets the OIntersection right turn preference percent.


setLeftPCT

public void setLeftPCT(float lpct,
                       int ifrag)
Sets the OFragment left turn preference percent.


getLeftPCT

public float getLeftPCT(int ifrag)
Gets the OIntersection left turn preference percent.


setLeftQue

public void setLeftQue(int lque,
                       int ifrag)
Sets the OFragment left turn queue length.


getLeftQue

public int getLeftQue(int ifrag)
Gets the OIntersection left turn queue length.


setRightQue

public void setRightQue(int rque,
                        int ifrag)
Sets the OFragment right turn queue length.


getRightQue

public int getRightQue(int ifrag)
Gets the OIntersection right turn queue length.


getRedC

public float getRedC()
Gets the OIntersection all red clearance time


setRedC

public void setRedC(float itime)
Sets the OIntersection all red clearance time. This is the time when all of the lights in an Intersection are red. This is generally used to keep the people who insist on running the light from hitting the people who insist on bolting the instant the light turns green.


getOffSet

public float getOffSet()
Gets the OIntersection offset from time zero. This plus the red clearance is the amount of time that will pass before the first light at this intersection goes green. This can be used to create a rough syncronization between intersections.


setOffSet

public void setOffSet(float itime)
sets the OIntersection offset from time zero. This plus the red clearance is the amount of time that will pass before the first light at this intersection goes green. This can be used to create a rough syncronization between intersections.


getGTime

public float getGTime(int sidx)
Gets the phase green time


setGTime

public void setGTime(float itime,
                     int sidx)
Sets the phase green time


getYTime

public float getYTime(int sidx)
Gets the phase Yellow time.


setYTime

public void setYTime(float itime,
                     int sidx)
Sets the phase Yellow time.


getGLeft

public float getGLeft(int sidx)
Gets the phase Yellow time remaining. (only used by query)


getYLeft

public float getYLeft(int sidx)
Gets the phase Green time remaining. (only used by query)


isRed

public boolean isRed(int sidx)
True if phase is red


isYellow

public boolean isYellow(int sidx)
True if phase is yellow


isGreen

public boolean isGreen(int sidx)
True if phase is green


isOLRed

public boolean isOLRed(int sidx)
True if overlap is red


isOLYellow

public boolean isOLYellow(int sidx)
True if overlap is yellow


isOLGreen

public boolean isOLGreen(int sidx)
True if overlap is green. For leading left turns, the overlap has to stay green if it's 'protecting left' will go green next. It doesn't go yellow until it's 'protecting left' goes yellow. This logic is reversed for lagging left turns.


isPhUsed

public boolean isPhUsed(int iphs)
True if phase is used. A phase is considered used if it is controlled by a traffic light.


setPhUsed

public void setPhUsed(boolean state,
                      int iphs)
specify that phase is used. A phase is considered used if it is controlled by a traffic light. If a phase pair (like 1 and 2) are both set to unused, a stop sign will be placed at the end of that fragment to prevent accidents. if either phase is set to used the stop sign will be removed.


isOLUsed

public boolean isOLUsed(int ifrag)
True if the overlap is used.


setOLUsed

public void setOLUsed(boolean state,
                      int ifrag)
Specify that the overlap should be used.


isLeading

public boolean isLeading()
True if the left turns lead at this OIntersection


setLeading

public void setLeading(boolean state)
Specify that the left turns should lead at this OIntersection


isPermLeft

public boolean isPermLeft(int ifrag)
True if the OFragment permits left turns. This can only happen when the left turn arrow is red (and blinking) and the straight through phase is green.


setPermLeft

public void setPermLeft(boolean state,
                        int ifrag)
Specify if the OFragment should permit left turns. This can only happen when the left turn arrow is red (and blinking) and the straight through phase is green.


isRedRight

public boolean isRedRight(int ifrag)
True if the OFragment permits right on red.


setRedRight

public void setRedRight(boolean state,
                        int ifrag)
Specify if the OFragment should permit right on red.


getIntRad

public float getIntRad()
Gets the OIntersection radius


setIntRad

public void setIntRad(float rad)
Sets the OIntersection radius.


isMapped

public boolean isMapped()
True if OIntersection is mapped. Once an intersection has been mapped it contains it's map coordinates and can be drawn on the map without further calculation.


setMapped

public void setMapped(boolean state)
Sets the OIntersection mapped state. Once an intersection has been mapped it contains it's map coordinates and can be drawn on the map without further calculation.


getMapX

public int getMapX()
Gets the OIntersection X map coordinate.


getMapY

public int getMapY()
Gets the OIntersection Y map coordinate.


setMapCoords

public void setMapCoords(int xxx,
                         int yyy)
Sets the OIntersection X and Y map coordinate.


expungeLights

public void expungeLights()
Sets the time for all of the lights back to their starting points.


runTraffic

public void runTraffic()
this method handles the signal sequence. Phase numbering runs from 0 to 7 rather than 1 to 8. This method is called by the JavaDriver runTraffic method.


checkMajor

public void checkMajor()
Check the major street (1/5) to find the first phases


checkMinor

public void checkMinor()
Check the minor street (3/7) to find the first phases