diff --git a/VectoCommon/VectoCommon/Utils/StringExtensionMethods.cs b/VectoCommon/VectoCommon/Utils/StringExtensionMethods.cs index c89db25926b684630a9a98feba059d7ec3450a9b..6a91bd48eca9531cc55a55290826a18ddb4c3812 100644 --- a/VectoCommon/VectoCommon/Utils/StringExtensionMethods.cs +++ b/VectoCommon/VectoCommon/Utils/StringExtensionMethods.cs @@ -54,14 +54,17 @@ namespace TUGraz.VectoCommon.Utils throw new FormatException("Cannot convert an empty string to a number."); } - try { - return double.Parse(self, CultureInfo.InvariantCulture); - } catch (FormatException) { - if (defaultValue.HasValue) { - return defaultValue.Value; - } - throw; + var success = double.TryParse(self, out var retVal); + if (success) { + return retVal; + } + + if (defaultValue.HasValue) { + return defaultValue.Value; } + + // throws an exception + return double.Parse(self, CultureInfo.InvariantCulture); } public static int ToInt(this string self, int? defaultValue = null) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs index ead6520b54df8872e43876e02c015cb8df5488f4..e1a85359dd7eab76c6cb292f8f0db0b7bc17edcc 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs @@ -145,6 +145,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data EngineSpeed = entry.EngineSpeed; FanSpeed = entry.FanSpeed; PTOPowerDemandDuringDrive = entry.PTOPowerDemandDuringDrive; + Highway = entry.Highway; } /// <summary> diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index 0683d8833c5b63eb0a19c6c705a09fcdb795349e..5a40c85b1062b0aa24370d894b7d5ee75130f692 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -753,7 +753,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public bool IsOverspeedAllowed(MeterPerSecond velocity, bool prohibitOverspeed = false) => !prohibitOverspeed - && Driver.DriverData.OverSpeed.Enabled + // allow overspeed either if enabled in the driver model, or ADAS PCC option 3 is enabled in the vehicle and we are on a highway + && (Driver.DriverData.OverSpeed.Enabled || ADAS.PredictiveCruiseControl == PredictiveCruiseControlType.Option_1_2_3 && DataBus.DrivingCycleInfo.CycleData.LeftSample.Highway) && velocity > Driver.DriverData.OverSpeed.MinSpeed && ApplyOverspeed(velocity) < (DataBus.VehicleInfo.MaxVehicleSpeed ?? 500.KMPHtoMeterPerSecond()); }