public TrafficLight(InputData _ipd) { ipd = _ipd; opd = new OutputData(); cars1 = new List <int>(); cars2 = new List <int>(); sCarCount1 = 0; sCarCount2 = 0; tmax1 = 0; tmin1 = 0; tmax2 = 0; tmin2 = 0; sTime1 = 0; sTime2 = 0; }
public void run() { cars1.Clear(); cars2.Clear(); generateQueue(); opd = new OutputData(); sCarCount1 = 0; sCarCount2 = 0; tmax1 = 0; tmin1 = 0; tmax2 = 0; tmin2 = 0; sTime1 = 0; sTime2 = 0; for (var i = 0; i < ipd.iterationCount; i++) { timeProcessing1(cars1[i]); opd.sTime += ipd.sTime; timeProcessing2(cars2[i]); opd.sTime += ipd.sTime; } var carCount1 = cars1.ToArray().Sum(); var carCount2 = cars2.ToArray().Sum(); opd.wTime1 = sTime1 / sCarCount1; opd.wTime2 = sTime2 / sCarCount2; opd.aLength1 = (double)carCount1 / ipd.iterationCount; opd.aLength2 = (double)carCount2 / ipd.iterationCount; opd.aCount1 = (double)sCarCount1 / ipd.iterationCount; opd.aCount2 = (double)sCarCount2 / ipd.iterationCount; opd.tmin1 = (double)tmin1 / ipd.iterationCount; opd.tmax1 = (double)tmax1 / ipd.iterationCount; opd.tmin2 = (double)tmin2 / ipd.iterationCount; opd.tmax2 = (double)tmax2 / ipd.iterationCount; }