void ApplyCalibration(bool logDetailsToFile) { // apply calibration of given profile to acceleration sensor launch detection DataItemVehicle vehicle = Database.GetInstance().GetActiveProfile(); RunStartStop startStop = new RunStartStop(vehicle); if (logDetailsToFile == true) { string latitude = gpsProvider.GetLatitude().ToString().Replace(',', '.'); string longitute = gpsProvider.GetLongitude().ToString().Replace(',', '.'); Debug.LogToFile("location [latitude, longitude]: " + latitude + ", " + longitute); Debug.LogToFile(startStop.GetStartString()); Debug.LogToFile(startStop.GetStopString()); Analytics.TrackLocation(latitude, longitute); } accelerometerProvider.SetForceDetectLimit(startStop.GetStartLimit()); accelerometerProvider.SetAxisOffset(vehicle.AxisOffsetX, vehicle.AxisOffsetY, vehicle.AxisOffsetZ); runModeProvider.StopDetectionLimit = startStop.GetStopLimit(); }
public ResultItem GetResult(ResultItem item, SubMode subMode, string unit) { ResultItem result; string start; string end; float speedStart; float speedEnd; float distanceStart; float distanceEnd; float resultValue; //Debug.LogToFileMethod("item: " + item + " // " + "subMode: " + subMode + " // " + "unit: " + unit); item.GetStartEnd(out start, out end); //Debug.LogToFileMethod("start: " + start + " // " + "end: " + end); // convert speed strings if (Settings.IsSpeedUnitKph()) { // from kph-string to m/s-float speedStart = Tools.ToMeterPerSecond(start); speedEnd = Tools.ToMeterPerSecond(end); } else { // from mph-string to m/s-float speedStart = Tools.ToMeterPerSecondM(start); speedEnd = Tools.ToMeterPerSecondM(end); } //Debug.LogToFileMethod("speedStart: " + speedStart + " // " + "speedEnd: " + speedEnd); if (mode.Equals(RunModeZeroToZero.Mode)) // zerotozero results in [time] unit { // mode zerotozero -> stop is same as start, but with stop detection limit on top (avoid unfound speedStop) RunStartStop runStartStop = new RunStartStop(Database.GetInstance().GetActiveProfile()); float speedStop = speedStart + runStartStop.GetStopLimit(); resultValue = GetDifferenceZeroToZero(speedStart, speedEnd, speedStop, subMode); resultValue = runAdjust.GetAdjusted(resultValue, mode, subMode); result = new ResultItem(start + " - " + end + " - " + start, Tools.ToResultFormat(resultValue, subMode, unit)); } else if (mode.Equals(RunModeBrake.Mode)) // brake results in [time] unit { // adjust speedEnd with calibrated stopDetection to avoid unfound speedEnd RunStartStop runStartStop = new RunStartStop(Database.GetInstance().GetActiveProfile()); speedEnd += runStartStop.GetStopLimit(); resultValue = GetDifferenceBrake(speedStart, speedEnd, subMode); resultValue = runAdjust.GetAdjusted(resultValue, mode, subMode); result = new ResultItem(start + " - " + end, Tools.ToResultFormat(resultValue, subMode, unit)); } else // acceleretion results in [time] or [distance] unit { if (subMode == SubMode.TimeDistance) { // convert distance strings if (Settings.IsDistanceUnitMeter()) { // from meter-string to meter-float distanceStart = float.Parse(start); distanceEnd = float.Parse(end); } else { // from foot-string to meter-float distanceStart = Tools.ToMeter(start); distanceEnd = Tools.ToMeter(end); } //Debug.LogToFileMethod("distanceStart: " + distanceStart + " // " + "distanceEnd: " + distanceEnd); resultValue = GetDifferenceAcceleration(distanceStart, distanceEnd, subMode); resultValue = runAdjust.GetAdjusted(resultValue, mode, subMode); float speedAtEndDistance = GetSpeed(distanceEnd); string speedAtEndDistanceString = (Settings.IsSpeedUnitKph()) ? Tools.ToKilometerPerHour(speedAtEndDistance) : Tools.ToMilesPerHour(speedAtEndDistance); string unitDistance = (Settings.IsSpeedUnitKph()) ? Localization.unitKph : Localization.unitMph; result = new ResultItem(start + " - " + end, Tools.ToResultFormat(resultValue, subMode, unit) + " @" + speedAtEndDistanceString + unitDistance); } else { resultValue = GetDifferenceAcceleration(speedStart, speedEnd, subMode); resultValue = runAdjust.GetAdjusted(resultValue, mode, subMode); result = new ResultItem(start + " - " + end, Tools.ToResultFormat(resultValue, subMode, unit)); } } return(result); }