From f8d349cf140a35019f85b9b256af0ede3e0139cb Mon Sep 17 00:00:00 2001 From: Michael Krisper <michael.krisper@tugraz.at> Date: Tue, 23 Feb 2016 09:09:28 +0100 Subject: [PATCH] simplification of PWheel mode (with CycleGear from MeasuredSpeed Mode) --- .../Impl/PowertrainDrivingCycle.cs | 6 +++-- .../SimulationComponent/Impl/ShiftStrategy.cs | 27 ------------------- .../Simulation/MeasuredSpeedModeTest.cs | 4 +-- .../Models/Simulation/PwheelModeTests.cs | 7 ++--- 4 files changed, 10 insertions(+), 34 deletions(-) diff --git a/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs b/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs index 586795bc95..c89317fc39 100644 --- a/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs +++ b/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs @@ -195,13 +195,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <param name="container">The container.</param> /// <param name="cycle">The cycle.</param> /// <param name="axleRatio">The axle ratio.</param> + /// <param name="gearRatios"></param> public PWheelCycle(IVehicleContainer container, DrivingCycleData cycle, double axleRatio, - Dictionary<uint, double> ratios) + IReadOnlyDictionary<uint, double> gearRatios) : base(container, cycle) { foreach (var entry in Data.Entries) { + // calculate angularVelocity on Wheel: n / (axelRatio * gearRatio) entry.AngularVelocity = entry.AngularVelocity / - (axleRatio * (entry.Gear == 0 ? 1 : ratios[entry.Gear])); + (entry.Gear == 0 ? axleRatio : axleRatio * gearRatios[entry.Gear]); entry.Torque = entry.PWheel / entry.AngularVelocity; } } diff --git a/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs b/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs index 81959e699b..f7d4cb58fb 100644 --- a/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs +++ b/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs @@ -353,33 +353,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } - /// <summary> - /// Shift Strategy for PWheel Mode. The Cycle should set the gear, therefore the shift strategy has nothing to do. - /// </summary> - public class PWheelShiftStrategy : ShiftStrategy - { - public PWheelShiftStrategy(GearboxData data, IDataBus bus) : base(data, bus) {} - - public override uint Engage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed) - { - return DataBus.CycleData.LeftSample.Gear; - } - - public override void Disengage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed) {} - - public override bool ShiftRequired(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, - NewtonMeter inTorque, - PerSecond inAngularSpeed, uint gear, Second lastShiftTime) - { - return false; - } - - public override uint InitGear(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed) - { - return DataBus.CycleData.LeftSample.Gear == 0 ? 1u : DataBus.CycleData.LeftSample.Gear; - } - } - // TODO Implement ATShiftStrategy public class ATShiftStrategy : ShiftStrategy { diff --git a/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs b/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs index d7fd35183e..3ababa20cb 100644 --- a/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs +++ b/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs @@ -158,14 +158,14 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation if (cycleType == CycleType.MeasuredSpeed) { var cycle = new MeasuredSpeedDrivingCycle(container, drivingCycle); } else { - var gearbox = new Gearbox(container, + var gearbox = new CycleGearbox(container, new GearboxData { Gears = new Dictionary<uint, GearData> { { 1, new GearData { Ratio = 6.696 } }, { 2, new GearData { Ratio = 3.806 } }, { 3, new GearData { Ratio = 2.289 } } } - }, new PWheelShiftStrategy(null, container)); + }); var cycle = new MeasuredSpeedGearDrivingCycle(container, drivingCycle); } } diff --git a/VectoCoreTest/Models/Simulation/PwheelModeTests.cs b/VectoCoreTest/Models/Simulation/PwheelModeTests.cs index 3c43d4b730..2717e12f56 100644 --- a/VectoCoreTest/Models/Simulation/PwheelModeTests.cs +++ b/VectoCoreTest/Models/Simulation/PwheelModeTests.cs @@ -55,12 +55,13 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var cycleFile = new MemoryStream(Encoding.UTF8.GetBytes(inputData)); var drivingCycle = DrivingCycleDataReader.ReadFromStream(cycleFile, CycleType.PWheel); - var gearbox = new Gearbox(container, + var gearbox = new CycleGearbox(container, new GearboxData { Gears = new Dictionary<uint, GearData> { { 1, new GearData { Ratio = 2.0 } }, { 2, new GearData { Ratio = 3.5 } } } - }, new PWheelShiftStrategy(null, container)); + }); - var cycle = new PWheelCycle(container, drivingCycle, 2.3, gearbox); + var cycle = new PWheelCycle(container, drivingCycle, 2.3, + gearbox.ModelData.Gears.ToDictionary(g => g.Key, g => g.Value.Ratio)); Assert.AreEqual(container.CycleData.LeftSample.Time, 1.SI<Second>()); Assert.AreEqual(container.CycleData.RightSample.Time, 2.SI<Second>()); -- GitLab