diff --git a/VectoCore/FileIO/Reader/DataObjectAdaper/AbstractSimulationDataAdapter.cs b/VectoCore/FileIO/Reader/DataObjectAdaper/AbstractSimulationDataAdapter.cs index 198a110e9f75647e48868b7b75a98a69fd318dc8..e81207e898da2bb807eae563b780ae38757ee7a5 100644 --- a/VectoCore/FileIO/Reader/DataObjectAdaper/AbstractSimulationDataAdapter.cs +++ b/VectoCore/FileIO/Reader/DataObjectAdaper/AbstractSimulationDataAdapter.cs @@ -71,7 +71,7 @@ namespace TUGraz.VectoCore.FileIO.Reader.DataObjectAdaper return new GearboxData() { SavedInDeclarationMode = data.SavedInDeclarationMode, ModelName = data.ModelName, - Type = data.GearboxType.Parse<GearboxData.GearboxType>() + Type = data.GearboxType.Parse<GearboxType>() }; } diff --git a/VectoCore/FileIO/Reader/DataObjectAdaper/DeclarationDataAdapter.cs b/VectoCore/FileIO/Reader/DataObjectAdaper/DeclarationDataAdapter.cs index 3d5c1804c3d3445e37b922780193c2bc483b9744..b4fcce3f9c3ea134f71f9080b486fd3265d30710 100644 --- a/VectoCore/FileIO/Reader/DataObjectAdaper/DeclarationDataAdapter.cs +++ b/VectoCore/FileIO/Reader/DataObjectAdaper/DeclarationDataAdapter.cs @@ -156,23 +156,21 @@ namespace TUGraz.VectoCore.FileIO.Reader.DataObjectAdaper internal GearboxData CreateGearboxData(GearboxFileV5Declaration gearbox, CombustionEngineData engine) { var retVal = SetCommonGearboxData(gearbox.Body); - - if (retVal.Type == GearboxData.GearboxType.AT) { - throw new VectoSimulationException("Automatic Transmission currently not supported in DeclarationMode!"); - } - if (retVal.Type == GearboxData.GearboxType.Custom) { - throw new VectoSimulationException("Custom Transmission not supported in DeclarationMode!"); + switch (retVal.Type) { + case GearboxType.AT: + throw new VectoSimulationException("Automatic Transmission currently not supported in DeclarationMode!"); + case GearboxType.Custom: + throw new VectoSimulationException("Custom Transmission not supported in DeclarationMode!"); } - if (gearbox.Body.Gears.Count < 2) { throw new VectoSimulationException( "At least two Gear-Entries must be defined in Gearbox: 1 Axle-Gear and at least 1 Gearbox-Gear!"); } retVal.Inertia = DeclarationData.Gearbox.Inertia.SI<KilogramSquareMeter>(); - retVal.TractionInterruption = DeclarationData.Gearbox.TractionInterruption(retVal.Type); - retVal.SkipGears = DeclarationData.Gearbox.SkipGears(retVal.Type); - retVal.EarlyShiftUp = DeclarationData.Gearbox.EarlyShiftGears((retVal.Type)); + retVal.TractionInterruption = retVal.Type.TractionInterruption(); + retVal.SkipGears = retVal.Type.SkipGears(); + retVal.EarlyShiftUp = retVal.Type.EarlyShiftGears(); retVal.TorqueReserve = DeclarationData.Gearbox.TorqueReserve; retVal.StartTorqueReserve = DeclarationData.Gearbox.TorqueReserveStart; diff --git a/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/Models/Declaration/DeclarationData.cs index 33bf955740f4a1660946f683803ada6ea3791494..bce649997019dbf707284bf5ce185ae68a427c0b 100644 --- a/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/Models/Declaration/DeclarationData.cs @@ -186,51 +186,12 @@ namespace TUGraz.VectoCore.Models.Declaration public const double MinTimeBetweenGearshifts = 2; - public static Second TractionInterruption(GearboxData.GearboxType type) - { - switch (type) { - case GearboxData.GearboxType.MT: - return 2.SI<Second>(); - case GearboxData.GearboxType.AMT: - return 1.SI<Second>(); - case GearboxData.GearboxType.AT: - return 0.8.SI<Second>(); - } - return 0.SI<Second>(); - } - public static bool EarlyShiftGears(GearboxData.GearboxType type) - { - switch (type) { - case GearboxData.GearboxType.MT: - return false; - case GearboxData.GearboxType.AMT: - return true; - case GearboxData.GearboxType.AT: - return false; - } - return false; - } - public static bool SkipGears(GearboxData.GearboxType type) - { - switch (type) { - case GearboxData.GearboxType.MT: - return true; - case GearboxData.GearboxType.AMT: - return true; - case GearboxData.GearboxType.AT: - return false; - } - return false; - } + internal static ShiftPolygon ComputeShiftPolygon(EngineFullLoadCurve fullLoadCurve, PerSecond engineIdleSpeed) { - // TODO: How to compute shift-polygons exactly? (merge with engine full load?) - //var fullLoadCurve = engine.FullLoadCurve; - //var engineIdleSpeed = engine.IdleSpeed; - var maxTorque = fullLoadCurve.MaxLoadTorque; var entriesDown = new List<ShiftPolygon.ShiftPolygonEntry>(); diff --git a/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index 3f27440d733243225b063519e8f514c06f69d68a..42e54508528f11a1a85195b087c6367a0d7a5ca4 100644 --- a/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -95,9 +95,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl protected IGearbox GetGearbox(VehicleContainer container, GearboxData data) { switch (data.Type) { - case GearboxData.GearboxType.AT: + case GearboxType.AT: throw new VectoSimulationException("Unsupported Geabox type: Automatic Transmission (AT)"); - case GearboxData.GearboxType.Custom: + case GearboxType.Custom: throw new VectoSimulationException("Custom Gearbox not supported"); default: return new Gearbox(container, data); diff --git a/VectoCore/Models/SimulationComponent/Data/GearboxData.cs b/VectoCore/Models/SimulationComponent/Data/GearboxData.cs index 4fa0721dadad8d53df4df8c57501f2eb4516f29f..86e26189dae2c98847d848762f8dc770f21c6245 100644 --- a/VectoCore/Models/SimulationComponent/Data/GearboxData.cs +++ b/VectoCore/Models/SimulationComponent/Data/GearboxData.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; using TUGraz.VectoCore.Utils; @@ -13,15 +12,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data [DataContract] public class GearboxData : SimulationComponentData { - [SuppressMessage("ReSharper", "InconsistentNaming")] - public enum GearboxType - { - MT, // Manual Transmission - AMT, // Automated Manual Transmission - AT, // Automatic Transmission - Custom - } - public string ModelName { get; internal set; } public GearData AxleGearData { get; internal set; } diff --git a/VectoCore/Models/SimulationComponent/Data/GearboxType.cs b/VectoCore/Models/SimulationComponent/Data/GearboxType.cs new file mode 100644 index 0000000000000000000000000000000000000000..921bb61959b4c704f53db261cd538ddaf072bb47 --- /dev/null +++ b/VectoCore/Models/SimulationComponent/Data/GearboxType.cs @@ -0,0 +1,56 @@ +using System.Diagnostics.CodeAnalysis; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.Models.SimulationComponent.Data +{ + [SuppressMessage("ReSharper", "InconsistentNaming")] + public enum GearboxType + { + MT, // Manual Transmission + AMT, // Automated Manual Transmission + AT, // Automatic Transmission + Custom + } + + public static class GearBoxTypeExtension + { + public static bool EarlyShiftGears(this GearboxType type) + { + switch (type) { + case GearboxType.MT: + return false; + case GearboxType.AMT: + return true; + case GearboxType.AT: + return false; + } + return false; + } + + public static bool SkipGears(this GearboxType type) + { + switch (type) { + case GearboxType.MT: + return true; + case GearboxType.AMT: + return true; + case GearboxType.AT: + return false; + } + return false; + } + + public static Second TractionInterruption(this GearboxType type) + { + switch (type) { + case GearboxType.MT: + return 2.SI<Second>(); + case GearboxType.AMT: + return 1.SI<Second>(); + case GearboxType.AT: + return 0.8.SI<Second>(); + } + return 0.SI<Second>(); + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore.csproj b/VectoCore/VectoCore.csproj index a5ae583fc2bde3c6871a28b9f98cfc6dc5e4211f..99a7378db2808be327b629dcabf858eef7874ecc 100644 --- a/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore.csproj @@ -157,6 +157,7 @@ <Compile Include="Models\Declaration\Mission.cs" /> <Compile Include="Models\Declaration\MissionType.cs" /> <Compile Include="Models\SimulationComponent\Data\Engine\PT1Curve.cs" /> + <Compile Include="Models\SimulationComponent\Data\GearboxType.cs" /> <Compile Include="Models\SimulationComponent\IBreaks.cs" /> <Compile Include="Models\SimulationComponent\IDrivingCycleInfo.cs" /> <Compile Include="Models\SimulationComponent\Impl\AuxiliaryData.cs" /> diff --git a/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs b/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs index 1d5ada447761b42f11d92b9f1592662b04afdea0..05e0728e42d56b0e730381b3b5b32c3f0ba62b91 100644 --- a/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs +++ b/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs @@ -20,7 +20,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData { var gbxData = EngineeringModeSimulationDataReader.CreateGearboxDataFromFile(GearboxFile); - Assert.AreEqual(GearboxData.GearboxType.AMT, gbxData.Type); + Assert.AreEqual(GearboxType.AMT, gbxData.Type); Assert.AreEqual(1.0, gbxData.TractionInterruption.Value(), 0.0001); Assert.AreEqual(8, gbxData.Gears.Count);