diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/AuxiliaryDataReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/AuxiliaryDataReader.cs index 83aef8d8b764730a22698e01a1d0a5c43d776b79..620d6018fceb09973c3ba8dbd27b2bc40fc19d80 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/AuxiliaryDataReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/AuxiliaryDataReader.cs @@ -34,7 +34,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData var map = ReadAuxMap(id, table); return new AuxiliaryData(transmissionRatio, efficiencyToEngine, efficiencyToSupply, map); - ; + } catch (FileNotFoundException e) { throw new VectoException("Auxiliary file not found: " + fileName, e); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs index 5c50170cc42919bfc0baa5becd15939e798afcaa..e427d65f315ec4f607a1a561684bb4faa0b87d1d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs @@ -65,6 +65,25 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox get { return _downShiftPolygon.AsReadOnly(); } } + public bool IsBelowDownshiftCurve(NewtonMeter inTorque, PerSecond inAngularVelocity) + { + var section = Downshift.GetSection(entry => entry.AngularSpeed < inAngularVelocity); + if (section.Item2.AngularSpeed < inAngularVelocity) { + return false; + } + return IsLeftOf(inAngularVelocity, inTorque, section); + } + + public bool IsAboveUpshiftCurve(NewtonMeter inTorque, PerSecond inAngularVelocity) + { + var section = Upshift.GetSection(entry => entry.AngularSpeed < inAngularVelocity); + + if (section.Item2.AngularSpeed < inAngularVelocity) { + return true; + } + return IsRightOf(inAngularVelocity, inTorque, section); + } + /// <summary> /// Tests if current power request is on the left side of the shiftpolygon segment /// </summary> @@ -74,13 +93,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox /// <returns><c>true</c> if current power request is on the left side of the shiftpolygon segment; otherwise, <c>false</c>.</returns> /// <remarks>Computes a simplified cross product for the vectors: from--X, from--to and checks /// if the z-component is positive (which means that X was on the right side of from--to).</remarks> - public static bool IsLeftOf(PerSecond angularSpeed, NewtonMeter torque, + protected static bool IsLeftOf(PerSecond angularSpeed, NewtonMeter torque, Tuple<ShiftPolygonEntry, ShiftPolygonEntry> segment) { - var abX = segment.Item2.AngularSpeed - segment.Item1.AngularSpeed; - var abY = segment.Item2.Torque - segment.Item1.Torque; - var acX = angularSpeed - segment.Item1.AngularSpeed; - var acY = torque - segment.Item1.Torque; + var abX = segment.Item2.AngularSpeed.Value() - segment.Item1.AngularSpeed.Value(); + var abY = segment.Item2.Torque.Value() - segment.Item1.Torque.Value(); + var acX = angularSpeed.Value() - segment.Item1.AngularSpeed.Value(); + var acY = torque.Value() - segment.Item1.Torque.Value(); var z = abX * acY - abY * acX; return z.IsGreater(0); } @@ -94,13 +113,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox /// <returns><c>true</c> if current power request is on the left side of the shiftpolygon segment; otherwise, <c>false</c>.</returns> /// <remarks>Computes a simplified cross product for the vectors: from--X, from--to and checks /// if the z-component is negative (which means that X was on the left side of from--to).</remarks> - public static bool IsRightOf(PerSecond angularSpeed, NewtonMeter torque, + protected static bool IsRightOf(PerSecond angularSpeed, NewtonMeter torque, Tuple<ShiftPolygonEntry, ShiftPolygonEntry> segment) { - var abX = segment.Item2.AngularSpeed - segment.Item1.AngularSpeed; - var abY = segment.Item2.Torque - segment.Item1.Torque; - var acX = angularSpeed - segment.Item1.AngularSpeed; - var acY = torque - segment.Item1.Torque; + var abX = segment.Item2.AngularSpeed.Value() - segment.Item1.AngularSpeed.Value(); + var abY = segment.Item2.Torque.Value() - segment.Item1.Torque.Value(); + var acX = angularSpeed.Value() - segment.Item1.AngularSpeed.Value(); + var acY = torque.Value() - segment.Item1.Torque.Value(); var z = abX * acY - abY * acX; return z.IsSmaller(0); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs index f52e98af080d7eef9164161f8a03d3970ad1fb2e..261a7d10273ebe206c6c92c730dcdffa6d48020b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs @@ -121,13 +121,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (gear <= 1) { return false; } - - var downSection = Data.Gears[gear].ShiftPolygon.Downshift.GetSection(entry => entry.AngularSpeed < inEngineSpeed); - if (downSection.Item2.AngularSpeed < inEngineSpeed) { - return false; - } - - return ShiftPolygon.IsLeftOf(inEngineSpeed, inTorque, downSection); + return Data.Gears[gear].ShiftPolygon.IsBelowDownshiftCurve(inTorque, inEngineSpeed); } /// <summary> @@ -142,14 +136,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (gear >= Data.Gears.Count) { return false; } - - var upSection = Data.Gears[gear].ShiftPolygon.Upshift.GetSection(entry => entry.AngularSpeed < inEngineSpeed); - - if (upSection.Item2.AngularSpeed < inEngineSpeed) { - return true; - } - - return ShiftPolygon.IsRightOf(inEngineSpeed, inTorque, upSection); + return Data.Gears[gear].ShiftPolygon.IsAboveUpshiftCurve(inTorque, inEngineSpeed); } } } \ No newline at end of file