From 7a0028834bf4185166f9f5910faa4f9a8a618c3d Mon Sep 17 00:00:00 2001 From: "VKMTHD\\franzjosefkober" <franz.josef.kober@ivt.tugraz.at> Date: Thu, 2 Apr 2020 15:01:43 +0200 Subject: [PATCH] changes at retarderData and driverData --- .../VectoCore/Configuration/Constants.cs | 2 + .../DeclarationDataAdapterPrimaryBus.cs | 52 ---------------- .../DeclarationDataAdapterCompletedBus.cs | 51 ---------------- ...tionModeCompletedBusVectoRunDataFactory.cs | 21 +++---- .../Models/Declaration/DeclarationData.cs | 61 ++++++++++++++++++- .../CompletedBusFactorMethodTest.cs | 50 ++++++++++++--- 6 files changed, 109 insertions(+), 128 deletions(-) diff --git a/VectoCore/VectoCore/Configuration/Constants.cs b/VectoCore/VectoCore/Configuration/Constants.cs index 95ea47cbe6..03d87f0468 100644 --- a/VectoCore/VectoCore/Configuration/Constants.cs +++ b/VectoCore/VectoCore/Configuration/Constants.cs @@ -365,6 +365,8 @@ namespace TUGraz.VectoCore.Configuration public const double Td_n = 150; public const double FactorAngleDrive = 0.75; + + public const double RetarderGenericFactor = 0.5; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs index 1db63a5abf..e436a195c9 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs @@ -25,58 +25,6 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter { #region Overrides of DeclarationDataAdapterTruck - public DriverData CreateDriverData(Segment segment, IVehicleDeclarationInputData primaryVehicle) - { - var lookAheadData = new DriverData.LACData { - Enabled = DeclarationData.Driver.LookAhead.Enabled, - //Deceleration = DeclarationData.Driver.LookAhead.Deceleration, - MinSpeed = DeclarationData.Driver.LookAhead.MinimumSpeed, - LookAheadDecisionFactor = new LACDecisionFactor(), - LookAheadDistanceFactor = DeclarationData.Driver.LookAhead.LookAheadDistanceFactor - }; - - var overspeedData = new DriverData.OverSpeedData { - Enabled = true, - MinSpeed = DeclarationData.Driver.OverSpeed.MinSpeed, - OverSpeed = DeclarationData.Driver.OverSpeed.AllowedOverSpeed, - }; - - var driver = new DriverData { - AccelerationCurve = AccelerationCurveReader.ReadFromStream(segment.AccelerationFile), - LookAheadCoasting = lookAheadData, - OverSpeed = overspeedData, - EngineStopStart = primaryVehicle.ADAS.EngineStopStart - ? new DriverData.EngineStopStartData { - EngineOffStandStillActivationDelay = DeclarationData.Driver.EngineStopStart.ActivationDelay, - MaxEngineOffTimespan = DeclarationData.Driver.EngineStopStart.MaxEngineOffTimespan, - UtilityFactor = DeclarationData.Driver.EngineStopStart.UtilityFactor - } - : null, - EcoRoll = primaryVehicle.ADAS.EcoRoll != EcoRollType.None - ? new DriverData.EcoRollData { - UnderspeedThreshold = DeclarationData.Driver.EcoRoll.UnderspeedThreshold, - MinSpeed = DeclarationData.Driver.EcoRoll.MinSpeed, - ActivationPhaseDuration = DeclarationData.Driver.EcoRoll.ActivationDelay, - AccelerationLowerLimit = DeclarationData.Driver.EcoRoll.AccelerationLowerLimit, - AccelerationUpperLimit = DeclarationData.Driver.EcoRoll.AccelerationUpperLimit - } - : null, - PCC = primaryVehicle.ADAS.PredictiveCruiseControl != PredictiveCruiseControlType.None - ? new DriverData.PCCData { - PCCEnableSpeed = DeclarationData.Driver.PCC.PCCEnableSpeed, - MinSpeed = DeclarationData.Driver.PCC.MinSpeed, - PreviewDistanceUseCase1 = DeclarationData.Driver.PCC.PreviewDistanceUseCase1, - PreviewDistanceUseCase2 = DeclarationData.Driver.PCC.PreviewDistanceUseCase2, - UnderSpeed = DeclarationData.Driver.PCC.Underspeed, - OverspeedUseCase3 = DeclarationData.Driver.PCC.OverspeedUseCase3 - } - : null - }; - - return driver; - } - - public VehicleData CreateVehicleData(IVehicleDeclarationInputData pifVehicle, Mission mission, KeyValuePair<LoadingType, Kilogram> loading, Meter dynamicTyreRadius) { diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationDataAdapterCompletedBus.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationDataAdapterCompletedBus.cs index 112d4caada..e0e6762288 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationDataAdapterCompletedBus.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationDataAdapterCompletedBus.cs @@ -20,57 +20,6 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl { public class DeclarationDataAdapterCompletedBus { - public DriverData CreateDriverData(Segment segment) - { - var lookAheadData = new DriverData.LACData - { - Enabled = DeclarationData.Driver.LookAhead.Enabled, - //Deceleration = DeclarationData.Driver.LookAhead.Deceleration, - MinSpeed = DeclarationData.Driver.LookAhead.MinimumSpeed, - LookAheadDecisionFactor = new LACDecisionFactor(), - LookAheadDistanceFactor = DeclarationData.Driver.LookAhead.LookAheadDistanceFactor - }; - - var overspeedData = new DriverData.OverSpeedData - { - Enabled = true, - MinSpeed = DeclarationData.Driver.OverSpeed.MinSpeed, - OverSpeed = DeclarationData.Driver.OverSpeed.AllowedOverSpeed, - }; - - var driver = new DriverData - { - AccelerationCurve = AccelerationCurveReader.ReadFromStream(segment.AccelerationFile), - LookAheadCoasting = lookAheadData, - OverSpeed = overspeedData, - EngineStopStart = new DriverData.EngineStopStartData - { - EngineOffStandStillActivationDelay = DeclarationData.Driver.EngineStopStart.ActivationDelay, - MaxEngineOffTimespan = DeclarationData.Driver.EngineStopStart.MaxEngineOffTimespan, - UtilityFactor = DeclarationData.Driver.EngineStopStart.UtilityFactor - }, - EcoRoll = new DriverData.EcoRollData - { - UnderspeedThreshold = DeclarationData.Driver.EcoRoll.UnderspeedThreshold, - MinSpeed = DeclarationData.Driver.EcoRoll.MinSpeed, - ActivationPhaseDuration = DeclarationData.Driver.EcoRoll.ActivationDelay, - AccelerationLowerLimit = DeclarationData.Driver.EcoRoll.AccelerationLowerLimit, - AccelerationUpperLimit = DeclarationData.Driver.EcoRoll.AccelerationUpperLimit - }, - PCC = new DriverData.PCCData - { - PCCEnableSpeed = DeclarationData.Driver.PCC.PCCEnableSpeed, - MinSpeed = DeclarationData.Driver.PCC.MinSpeed, - PreviewDistanceUseCase1 = DeclarationData.Driver.PCC.PreviewDistanceUseCase1, - PreviewDistanceUseCase2 = DeclarationData.Driver.PCC.PreviewDistanceUseCase2, - UnderSpeed = DeclarationData.Driver.PCC.Underspeed, - OverspeedUseCase3 = DeclarationData.Driver.PCC.OverspeedUseCase3 - } - }; - - - return driver; - } public AirdragData CreateAirdragData(IVehicleDeclarationInputData completedVehicle, Mission mission) { diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs index 9b02a59ee4..253faa7721 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs @@ -54,6 +54,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl protected ShiftStrategyParameters _gearshiftData; private VehicleData _tmpVehicleData; + private DriverData _driverData; protected IDeclarationDataAdapter DataAdapter { get; } @@ -146,9 +147,9 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl _angledriveData = DeclarationData.FactorMethodBus.CreateAngledriveData( primaryVehicle.Components.AngledriveInputData, primaryVehicle.Components.AxleGearInputData.Ratio); - + _gearboxData = DeclarationData.FactorMethodBus.CreateGearboxData(primaryVehicle, - new VectoRunData() { EngineData = _combustionEngineData, AxleGearData = _axlegearData, VehicleData = _tmpVehicleData}, + new VectoRunData() { EngineData = _combustionEngineData, AxleGearData = _axlegearData, VehicleData = _tmpVehicleData }, null); _gearshiftData = DataAdapterPrimary.CreateGearshiftData( @@ -169,7 +170,8 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl _retarderData = DeclarationData.FactorMethodBus.CreateRetarderData(primaryVehicle.Components.RetarderInputData); - + + _driverData = DeclarationData.FactorMethodBus.CreateDriverData(_segment); } protected virtual IEnumerable<VectoRunData> GetNextRun() @@ -286,9 +288,6 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl // mission, InputDataProvider.JobInputData.Vehicle, simulationRunData); //return simulationRunData; - - // TODO MQ completedSegment == _segment? - var completedSegment = GetCompletedSegment(completedVehicle, primaryVehicle.AxleConfiguration); var primaryBusAuxiliaries = primaryVehicle.Components.BusAuxiliaries; var simulationRunData = new VectoRunData { @@ -303,7 +302,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl AngledriveData = _angledriveData, GearshiftParameters = _gearshiftData, Aux = DataAdapterPrimary.CreateAuxiliaryData(primaryVehicle.Components.AuxiliaryInputData, - primaryBusAuxiliaries, mission.MissionType, completedSegment.VehicleClass, + primaryBusAuxiliaries, mission.MissionType, _segment.VehicleClass, completedVehicle.Length) }; @@ -322,9 +321,8 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl simulationRunData.BusAuxiliaries = auxiliaryConfig; simulationRunData.Retarder = _retarderData; - - // todo MQ 20200401: move driver data to initialize method and set member. - simulationRunData.DriverData = DataAdapterCompleted.CreateDriverData(completedSegment); + + simulationRunData.DriverData = _driverData; simulationRunData.Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()); @@ -429,8 +427,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl simulationRunData.Retarder = _retarderData; - // todo: use driver data from initialize method - simulationRunData.DriverData = DataAdapterPrimary.CreateDriverData(primarySegment, primaryVehicle); + simulationRunData.DriverData = _driverData; simulationRunData.Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()); diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index ee152ea529..4bed4aea0e 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -532,8 +532,6 @@ namespace TUGraz.VectoCore.Models.Declaration private static RetarderLossMap GenerateGenericLossMap(double stepUpRatio) { - var factorGeneric = 0.5; - var retarderSpeeds = new double [] { 0, 200 , 400, 600, 900, 1200, 1600, 2000, 2500, 3000, 3500, 4000, @@ -550,7 +548,8 @@ namespace TUGraz.VectoCore.Models.Declaration for (int i = 0; i < genericRetarderLosses.Length; i++) { var newRow = torqueLoss.NewRow(); newRow[RetarderLossMapReader.Fields.RetarderSpeed] = retarderSpeeds[i]; - newRow[RetarderLossMapReader.Fields.TorqueLoss] = genericRetarderLosses[i] * factorGeneric; + newRow[RetarderLossMapReader.Fields.TorqueLoss] = genericRetarderLosses[i] * + Constants.GenericLossMapSettings.RetarderGenericFactor; torqueLoss.Rows.Add(newRow); } @@ -602,6 +601,62 @@ namespace TUGraz.VectoCore.Models.Declaration #endregion + #region Create Driver Data + + public static DriverData CreateDriverData(Segment completedSegment) + { + var lookAheadData = new DriverData.LACData + { + Enabled = Driver.LookAhead.Enabled, + //Deceleration = DeclarationData.Driver.LookAhead.Deceleration, + MinSpeed = Driver.LookAhead.MinimumSpeed, + LookAheadDecisionFactor = new LACDecisionFactor(), + LookAheadDistanceFactor = Driver.LookAhead.LookAheadDistanceFactor + }; + + var overspeedData = new DriverData.OverSpeedData + { + Enabled = true, + MinSpeed = Driver.OverSpeed.MinSpeed, + OverSpeed = Driver.OverSpeed.AllowedOverSpeed, + }; + + var driver = new DriverData + { + AccelerationCurve = AccelerationCurveReader.ReadFromStream(completedSegment.AccelerationFile), + LookAheadCoasting = lookAheadData, + OverSpeed = overspeedData, + EngineStopStart = new DriverData.EngineStopStartData + { + EngineOffStandStillActivationDelay = Driver.EngineStopStart.ActivationDelay, + MaxEngineOffTimespan = Driver.EngineStopStart.MaxEngineOffTimespan, + UtilityFactor = Driver.EngineStopStart.UtilityFactor + }, + EcoRoll = new DriverData.EcoRollData + { + UnderspeedThreshold = Driver.EcoRoll.UnderspeedThreshold, + MinSpeed = Driver.EcoRoll.MinSpeed, + ActivationPhaseDuration = Driver.EcoRoll.ActivationDelay, + AccelerationLowerLimit = Driver.EcoRoll.AccelerationLowerLimit, + AccelerationUpperLimit = Driver.EcoRoll.AccelerationUpperLimit + }, + PCC = new DriverData.PCCData + { + PCCEnableSpeed = Driver.PCC.PCCEnableSpeed, + MinSpeed = Driver.PCC.MinSpeed, + PreviewDistanceUseCase1 = Driver.PCC.PreviewDistanceUseCase1, + PreviewDistanceUseCase2 = Driver.PCC.PreviewDistanceUseCase2, + UnderSpeed = Driver.PCC.Underspeed, + OverspeedUseCase3 = Driver.PCC.OverspeedUseCase3 + } + }; + + + return driver; + } + + #endregion + } diff --git a/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs b/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs index 35ff24b1de..82cb23af1f 100644 --- a/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs +++ b/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs @@ -806,8 +806,13 @@ namespace TUGraz.VectoCore.Tests.Integration.CompletedBus var genericRetarder = relatedRun.VectoRunDataGenericBody.Retarder; var specificRetarder = relatedRun.VectoRunDataSpezificBody.Retarder; - Assert.IsNull(genericRetarder); - Assert.IsNull(specificRetarder); + Assert.AreEqual(1, genericRetarder.Ratio); + Assert.AreEqual( genericRetarder.Ratio, specificRetarder.Ratio); + + Assert.AreEqual(RetarderType.TransmissionOutputRetarder, genericRetarder.Type); + Assert.AreEqual(genericRetarder.Type, specificRetarder.Type); + + Assert.AreEqual(genericRetarder.LossMap, specificRetarder.LossMap); } #endregion @@ -835,17 +840,42 @@ namespace TUGraz.VectoCore.Tests.Integration.CompletedBus Assert.AreEqual(DeclarationData.Driver.OverSpeed.AllowedOverSpeed, genericDriver.OverSpeed.OverSpeed); Assert.AreEqual(genericDriver.OverSpeed, specificDriver.OverSpeed); - Assert.IsNull(genericDriver.EngineStopStart); - Assert.IsNull(genericDriver.EcoRoll); - Assert.IsNull(genericDriver.PCC); + AssertStopStartData(genericDriver.EngineStopStart); + AssertEcoRoll(genericDriver.EcoRoll); + AssertPccData(genericDriver.PCC); - Assert.IsNull(specificDriver.EngineStopStart); - Assert.IsNull(specificDriver.EcoRoll); - Assert.IsNull(specificDriver.PCC); + AssertStopStartData(specificDriver.EngineStopStart); + AssertEcoRoll(specificDriver.EcoRoll); + AssertPccData(specificDriver.PCC); + } + + private void AssertStopStartData(DriverData.EngineStopStartData engineStopStart) + { + Assert.AreEqual(DeclarationData.Driver.EngineStopStart.ActivationDelay, engineStopStart.EngineOffStandStillActivationDelay); + Assert.AreEqual(DeclarationData.Driver.EngineStopStart.MaxEngineOffTimespan, engineStopStart.MaxEngineOffTimespan); + Assert.AreEqual(DeclarationData.Driver.EngineStopStart.UtilityFactor, engineStopStart.UtilityFactor); } - - #endregion + private void AssertEcoRoll(DriverData.EcoRollData ecoRoll) + { + Assert.AreEqual(DeclarationData.Driver.EcoRoll.UnderspeedThreshold, ecoRoll.UnderspeedThreshold); + Assert.AreEqual(DeclarationData.Driver.EcoRoll.MinSpeed, ecoRoll.MinSpeed); + Assert.AreEqual(DeclarationData.Driver.EcoRoll.ActivationDelay, ecoRoll.ActivationPhaseDuration); + Assert.AreEqual(DeclarationData.Driver.EcoRoll.AccelerationLowerLimit, ecoRoll.AccelerationLowerLimit); + Assert.AreEqual(DeclarationData.Driver.EcoRoll.AccelerationUpperLimit, ecoRoll.AccelerationUpperLimit); + } + + private void AssertPccData(DriverData.PCCData pccData) + { + Assert.AreEqual(DeclarationData.Driver.PCC.PCCEnableSpeed, pccData.PCCEnableSpeed); + Assert.AreEqual(DeclarationData.Driver.PCC.MinSpeed, pccData.MinSpeed); + Assert.AreEqual(DeclarationData.Driver.PCC.PreviewDistanceUseCase1, pccData.PreviewDistanceUseCase1); + Assert.AreEqual(DeclarationData.Driver.PCC.PreviewDistanceUseCase2, pccData.PreviewDistanceUseCase2); + Assert.AreEqual(DeclarationData.Driver.PCC.Underspeed, pccData.UnderSpeed); + Assert.AreEqual(DeclarationData.Driver.PCC.OverspeedUseCase3, pccData.OverspeedUseCase3); + } + + #endregion private CrosswindCorrectionCdxALookup GetCrosswindCorrection(string crossWindCorrectionParams, SquareMeter aerodynamicDragArea, Meter vehicleHeight) -- GitLab