diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs index 6b85bd9ac403de1823d3424041e01cf563296e52..025db95ebd5017acf54dd3580b238108140c7563 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs @@ -62,7 +62,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON protected readonly string Version; - protected readonly JObject Body; + protected internal readonly JObject Body; protected JSONFile(JObject data, string filename, bool tolerateMissing = false) { diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs index a3ed1715f5c742a406ca1c19b021255369f00958..511accceb00c23ff0046564e0138b949b0b54238 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs @@ -602,7 +602,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter VelocityDropFactor = DeclarationData.GearboxTCU.VelocityDropFactor, AccelerationFactor = DeclarationData.GearboxTCU.AccelerationFactor, MinEngineSpeedPostUpshift = 0.RPMtoRad(), - ATLookAheadTime = DeclarationData.Gearbox.PowershiftShiftTime, + ATLookAheadTime = DeclarationData.GearboxTCU.ATLookAheadTime, LoadStageThresoldsUp = DeclarationData.GearboxTCU.LoadStageThresholdsUp, LoadStageThresoldsDown = DeclarationData.GearboxTCU.LoadStageThresoldsDown, diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs index a345872947e138ece977da4dddb4deb44c483448..ce6675079bff2164deff9bd133feab6688c7e4dc 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs @@ -428,9 +428,6 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter DeclarationData.GearboxTCU.CurrentCardanPowerThresholdPropulsion, TargetSpeedDeviationFactor = gsInputData.TargetSpeedDeviationFactor ?? DeclarationData.GearboxTCU.TargetSpeedDeviationFactor, EngineSpeedHighDriveOffFactor = gsInputData.EngineSpeedHighDriveOffFactor ?? DeclarationData.GearboxTCU.EngineSpeedHighDriveOffFactor, - RatingFactorCurrentGear = gsInputData.RatingFactorCurrentGear ?? (gbxType.AutomaticTransmission() - ? DeclarationData.GearboxTCU.RatingFactorCurrentGearAT - : DeclarationData.GearboxTCU.RatingFactorCurrentGear), AccelerationReserveLookup = AccelerationReserveLookupReader.Create(gsInputData.AccelerationReserveLookup) ?? AccelerationReserveLookupReader.ReadFromStream( RessourceHelper.ReadStream( @@ -455,13 +452,17 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter DeclarationData.DeclarationDataResourcePrefix + ".GearshiftParameters.ShareEngineSpeedHigh.csv") ), //--------------- + RatingFactorCurrentGear = gsInputData.RatingFactorCurrentGear ?? (gbxType.AutomaticTransmission() + ? DeclarationData.GearboxTCU.RatingFactorCurrentGearAT + : DeclarationData.GearboxTCU.RatingFactorCurrentGear), + RatioEarlyUpshiftFC = (gsInputData.RatioEarlyUpshiftFC ?? DeclarationData.GearboxTCU.RatioEarlyUpshiftFC) / axleRatio, RatioEarlyDownshiftFC = (gsInputData.RatioEarlyDownshiftFC ?? DeclarationData.GearboxTCU.RatioEarlyDownshiftFC) / axleRatio, AllowedGearRangeFC = gsInputData.AllowedGearRangeFC ?? (gbxType.AutomaticTransmission() ? DeclarationData.GearboxTCU.AllowedGearRangeFCAT : DeclarationData.GearboxTCU.AllowedGearRangeFCAMT), VelocityDropFactor = gsInputData.VeloictyDropFactor ?? DeclarationData.GearboxTCU.VelocityDropFactor, AccelerationFactor = gsInputData.AccelerationFactor ?? DeclarationData.GearboxTCU.AccelerationFactor, - MinEngineSpeedPostUpshift = gsInputData.MinEngineSpeedPostUpshift ?? 0.RPMtoRad(), - ATLookAheadTime = gsInputData.ATLookAheadTime ?? DeclarationData.Gearbox.PowershiftShiftTime, + MinEngineSpeedPostUpshift = gsInputData.MinEngineSpeedPostUpshift ?? DeclarationData.GearboxTCU.MinEngineSpeedPostUpshift, + ATLookAheadTime = gsInputData.ATLookAheadTime ?? DeclarationData.GearboxTCU.ATLookAheadTime, LoadStageThresoldsDown = gsInputData.LoadStageThresoldsDown?.ToArray() ?? DeclarationData.GearboxTCU.LoadStageThresoldsDown, LoadStageThresoldsUp = gsInputData.LoadStageThresoldsUp?.ToArray() ?? DeclarationData.GearboxTCU.LoadStageThresholdsUp, diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index a543fe5e6cf077a4d8762ae68872e90a6b9d72f6..05ee610761790fe73fed98ca00f95600c92b4257 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -32,11 +32,14 @@ using System; using System.Collections.Generic; using System.Data; +using System.IO; using System.Linq; +using Newtonsoft.Json.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.FileIO.JSON; using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; @@ -201,23 +204,27 @@ namespace TUGraz.VectoCore.Models.Declaration public const double TargetSpeedDeviationFactor = 0.1; - public const double RatingFactorCurrentGear = 0.97; - public const double RatingFactorCurrentGearAT = 0.97; + public static double RatingFactorCurrentGear = 0.97; + public static double RatingFactorCurrentGearAT = 0.97; public static readonly MeterPerSquareSecond DriverAccelerationThresholdLow = 0.1.SI<MeterPerSquareSecond>(); public static double VelocityDropFactor = 1.0; public static double AccelerationFactor = 0.5; - public const double RatioEarlyUpshiftFC = 24; - public const double RatioEarlyDownshiftFC = 24; + public static double RatioEarlyUpshiftFC = 24; + public static double RatioEarlyDownshiftFC = 24; - public const int AllowedGearRangeFCAMT = 2; - public const int AllowedGearRangeFCAT = 1; + public static int AllowedGearRangeFCAMT = 2; + public static int AllowedGearRangeFCAT = 1; - public static readonly double[] LoadStageThresholdsUp = new[] { 19.7, 36.34, 53.01, 69.68, 86.35 }; - public static readonly double[] LoadStageThresoldsDown = new[] { 13.7, 30.34, 47.01, 63.68, 80.35 }; + public static PerSecond MinEngineSpeedPostUpshift = 0.RPMtoRad(); - public static readonly double[][] ShiftSpeedsTCToLocked = new[] { + public static Second ATLookAheadTime = Gearbox.PowershiftShiftTime; + + public static double[] LoadStageThresholdsUp = { 19.7, 36.34, 53.01, 69.68, 86.35 }; + public static double[] LoadStageThresoldsDown = { 13.7, 30.34, 47.01, 63.68, 80.35 }; + + public static double[][] ShiftSpeedsTCToLocked = { new[] { 650.0, 680, 725, 650, 680, 725 }, new[] { 650.0, 680, 725, 650, 680, 725 }, new[] { 650.0, 680, 725, 650, 680, 725 }, @@ -228,6 +235,60 @@ namespace TUGraz.VectoCore.Models.Declaration public const double DownhillSlope = -5; public const double UphillSlope = 5; + + public static string DefaultShiftStrategy = ""; + + + // TODO: MQ 2019-11-26 remove, once the parameters are fixed! make fields above read-only or const + static GearboxTCU() + { + var expectedFile = @"Declaration\EffShiftParameters.vtcu"; + if (!File.Exists(expectedFile)) { + return; + } + + var tcuData = JSONInputDataFactory.ReadShiftParameters(expectedFile, true); + if (tcuData.RatingFactorCurrentGear.HasValue) { + RatingFactorCurrentGear = tcuData.RatingFactorCurrentGear.Value; + RatingFactorCurrentGearAT = tcuData.RatingFactorCurrentGear.Value; + } + if (tcuData.RatioEarlyDownshiftFC.HasValue) { + RatioEarlyDownshiftFC = tcuData.RatioEarlyDownshiftFC.Value; + } + if (tcuData.RatioEarlyUpshiftFC.HasValue) { + RatioEarlyUpshiftFC = tcuData.RatioEarlyUpshiftFC.Value; + } + if (tcuData.AllowedGearRangeFC.HasValue) { + AllowedGearRangeFCAMT = tcuData.AllowedGearRangeFC.Value; + AllowedGearRangeFCAT = tcuData.AllowedGearRangeFC.Value; + } + if (tcuData.VeloictyDropFactor.HasValue) { + VelocityDropFactor = tcuData.VeloictyDropFactor.Value; + } + if (tcuData.AccelerationFactor.HasValue) { + AccelerationFactor = tcuData.AccelerationFactor.Value; + } + if (tcuData.ATLookAheadTime != null) { + ATLookAheadTime = tcuData.ATLookAheadTime; + } + if (LoadStageThresoldsDown != null && LoadStageThresoldsDown.Length > 0) { + LoadStageThresoldsDown = tcuData.LoadStageThresoldsDown.ToArray(); + } + if (LoadStageThresholdsUp != null && LoadStageThresholdsUp.Length > 0) { + LoadStageThresholdsUp = tcuData.LoadStageThresoldsUp.ToArray(); + } + if (ShiftSpeedsTCToLocked != null && ShiftSpeedsTCToLocked.Length > 0) { + ShiftSpeedsTCToLocked = tcuData.ShiftSpeedsTCToLocked; + } + if (tcuData.MinEngineSpeedPostUpshift != null) { + MinEngineSpeedPostUpshift = tcuData.MinEngineSpeedPostUpshift; + } + var tmp = tcuData as JSONFile; + if (tmp != null && tmp.Body["ShiftStrategy"] != null) { + DefaultShiftStrategy = tmp.Body["ShiftStrategy"].Value<string>(); + } + } + } public static class Gearbox