APPENDIX A. SOURCE CODE
77
A.3 MorevtsSotlPhase
updateT LDs and decideT Ls of the Sotl-phase traffic light controller is given
below.
public void updateTLDs() {
for ( int i = 0; i < tld . length ; i++) {
boolean switched = false ;
for ( int j = 0; j < tld [i ]. length ; j++)
if( tld [i ][j ]. getTL (). getCycleSwitched()==getCurCycle()-1)
switched = true ;
if ( switched) {
if (! tld [i ][0]. getTL (). getNode (). getKeepTLDFlag())
{
tld [i ][0]. getTL (). getNode (). setKeepTLDFlag(true);
tld [i ][0]. getTL (). getNode (). setPhaseMinimal(PHASE_MIN);
for ( int j= 0; j < tld [i ]. length ; j++)
if ( tld [ i ][ j ]. getTL (). getState ())
tld [i ][ j ]. setKappa (0);
}
}
}
}
public TLDecision [][] decideTLs() {
TLDecision currentDec ;
Drivelane curLane;
// adjust data after last cycle
updateTLDs();
for ( int i = 0; i < tld . length ; i++) { // for all nodes
Node currentNode = null ;
for ( int j = 0; j < tld [i ]. length ; j++)
if (currentNode == null ) currentNode= tld [ i ][ j ]. getTL (). getNode ();