Example #1
0
 /// <summary>
 /// Adjusts recorded pollution in section due to pollution data
 /// </summary>
 /// <param name="vehicleData">data of vehicle passing through sensor</param>
 private static void AdjustPollution(VehicleData vehicleData)
 {
     try
     {
         _routes[vehicleData.RouteNo].AmendPollution(vehicleData);
     }
     catch (Exception ex)
     {
         throw new JunctionException("Error adjusting pollution", ex);
     }
 }
Example #2
0
 /// <summary>
 /// Amends the routes pollution due to an incoming or outgoing vehicle
 /// </summary>
 /// <param name="vehicleData">data of vehicle passing through sensor</param>
 public void AmendPollution(VehicleData vehicleData)
 {
     try
     {
         _incomingSection[vehicleData.SectionNo].AdjustPollution(vehicleData.Pollution);
     }
     catch (Exception ex)
     {
         throw new JunctionException("Error Amending pollution for route", ex);
     }
 }
Example #3
0
 /// <summary>
 /// Adjusts the light timing depending on vehicle entering or leaving section
 /// </summary>
 /// <param name="vehicleData">data of vehicle entering sensor</param>
 /// <param name="routes">routes of junction</param>
 public void AdjustTiming(VehicleData vehicleData, List <Route> routes)
 {
     try
     {
         _currentState.TimeElapsed += SignalTimer.TimeElapsed;
         SetSignalTiming(routes);
         Console.WriteLine("Current Interval time: " + _currentState.IntervalTime.ToString());
     }
     catch (Exception ex)
     {
         throw new JunctionException("Error adjusting light timing", ex);
     }
 }
Example #4
0
 /// <summary>
 /// Adjusts the timing of the light phases according to vehicle data
 /// passing through sensor
 /// </summary>
 /// <param name="vehicleData">data of vehicle passing through sensor </param>
 public static void AdjustTiming(VehicleData vehicleData)
 {
     try
     {
         Light.Pause();
         AdjustPollution(vehicleData);
         Light.AdjustTiming(vehicleData, _routes);
         Light.Restart();
     }
     catch (Exception ex)
     {
         throw new JunctionException("Error adjusting timing for phases", ex);
     }
 }
Example #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="body">request body as string</param>
 private static void ProcessANR(string body)
 {
     try
     {
         ANRRequest  aNRRequest  = new ANRRequest(body);
         VehicleData vehicleData = new VehicleData(aNRRequest.Items);
         Console.WriteLine("Vehicle: " + vehicleData.NumberPlate
                           + " RouteNo: " + vehicleData.RouteNo.ToString()
                           + " SectionNo: " + vehicleData.SectionNo.ToString()
                           + " Direction: " + vehicleData.Direction
                           + " Pollution: " + vehicleData.Pollution);
         Junction.AdjustTiming(vehicleData);
     }
     catch (Exception ex)
     {
         throw new JunctionException("Error processing ANR request", ex);
     }
 }