APPENDIX A. SOURCE CODE
79
int platoonRuCntAvg = 0;
for ( int j = 0; j < tld [i ]. length ; j++)
if ( tld [i ][j ]. getTL (). getCycleSwitched()==getCurCycle()-1)
switched = true ;
// set flag and reset kappa
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);
}
}
// check if platoon is crossing .
for ( int j = 0; j < tld [i ]. length ; j++)
// if tl is green
if ( tld [ i ][ j ]. getTL (). getState ()) {
PlatoonRoaduserCount += countRoadusers(tld [i ][ j ]. getTL (). getLane (), OMEGA);
nrOfPlatoonLanes += 1;
}
if (nrOfPlatoonLanes>0) {
platoonRuCntAvg = platoonRoaduserCount/nrOfPlatoonLanes;
if (platoonRuCntAvg >= 1 && platoonRuCntAvg <= MU){
platoonCrossing = true ;
}
if ( tld [i ]. length >=1)
tld [i ][0]. getTL (). getNode (). setPlatoonCrossing ( platoonCrossing );
}
}