public void Start(List <kmlDocumentPlacemark> route, string intersectionId, ulong allowedVehicleManeuvers, int simulatedDirection, List <GPSLocation> simulatedGPSLocations, AdvisoryCalculatorMode advisoryCalculatorMode) { if (string.IsNullOrEmpty(intersectionId) == true) { throw new Exception("Intersection not specified"); } if (route == null || route.Count == 0) { throw new Exception("Route not specified"); } Debug.WriteLine("Starting Vehicle Service"); _advisoryCalculatorMode = advisoryCalculatorMode; _loggingEnabled = false; _allowedVehicleManeuvers = allowedVehicleManeuvers; _navigationService.Start(route, intersectionId, allowedVehicleManeuvers, simulatedDirection, simulatedGPSLocations); _timerFinished = false; if (_timerRunning == false) { _timerRunning = true; _timerService.StartTimer(TimeSpan.FromMilliseconds(Constants.AdvisorySpeedCalculatorProcessingIntervalMilliseconds), (() => TimerServiceCallback())); } }
public void Start(List <kmlDocumentPlacemark> route, string routeId, ulong allowedVehicleManeuvers, WaypointDetectionMethod junctionDetectionMethod, AdvisoryCalculatorMode advisoryCalculatorMode) { if (route == null || route.Count == 0) { throw new Exception("Route not specified"); } Debug.WriteLine("Starting Vehicle Service"); _advisoryCalculatorMode = advisoryCalculatorMode; _loggingEnabled = true; _allowedVehicleManeuvers = allowedVehicleManeuvers; _navigationService.Start(route, routeId, allowedVehicleManeuvers, junctionDetectionMethod); _timerFinished = false; if (_timerRunning == false) { _timerRunning = true; _timerService.StartTimer(TimeSpan.FromMilliseconds(Constants.AdvisorySpeedCalculatorProcessingIntervalMilliseconds), (() => TimerServiceCallback())); } }
public static CalculationResult CalculateAdvisorySpeed(int distance, double timeToIntersection, double currentSpeed, AdvisoryCalculatorMode advisoryCalculatorMode) { CalculationResult calculationResult = new CalculationResult(); calculationResult.AdvisorySpeed = -1; calculationResult.Errors = CalculationErrors.NoErrors; if (advisoryCalculatorMode == AdvisoryCalculatorMode.Advanced) { AdvancedAdvisorySpeedCalculator advancedAdvisorySpeedCalculator = new AdvancedAdvisorySpeedCalculator(); calculationResult = advancedAdvisorySpeedCalculator.Calculate(AccelerationPolarity.Decelerate, timeToIntersection, distance, currentSpeed); } else { BasicSpeedAdvisoryCalculator calculator = new BasicSpeedAdvisoryCalculator(); calculationResult = calculator.Calculate(distance, timeToIntersection); } var speedMPH = Convert.ToInt32(calculationResult.AdvisorySpeed) < 0 ? 0 : Convert.ToInt32(calculationResult.AdvisorySpeed); speedMPH = Convert.ToInt32(SpeedConverter.ConvertFromMetersPerSecondToMilePerHour(speedMPH)); if (speedMPH > Settings.SpeedLimit) { calculationResult.Errors = CalculationErrors.AdvisorySpeedAboveSpeedLimit; } else if (speedMPH < (Settings.SpeedLimit / 2)) { calculationResult.Errors = CalculationErrors.AdvisorySpeedBelowHalfSpeedLimit; } return(calculationResult); }