From c01e045c9679096d0c1d15ad1a13b7baf71ecc2b Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Mon, 24 Sep 2018 16:04:28 +0200 Subject: [PATCH] adding another lookup table --- .../ShiftStrategy/ShareIdleLowReader.cs | 2 +- .../ShareTorque99lLookupReader.cs | 30 +++++++++++++++++++ .../ShiftStrategy/ShareTorque99lLookup.cs | 19 ++++++++++++ .../GearshiftParameters/ShareTq99L.csv | 12 ++++++++ VectoCore/VectoCore/VectoCore.csproj | 13 ++++++++ .../ShiftstrategyParameterTests.cs | 16 ++++++++++ 6 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 VectoCore/VectoCore/InputData/Reader/ShiftStrategy/ShareTorque99lLookupReader.cs create mode 100644 VectoCore/VectoCore/Models/SimulationComponent/Data/ShiftStrategy/ShareTorque99lLookup.cs create mode 100644 VectoCore/VectoCore/Resources/Declaration/GearshiftParameters/ShareTq99L.csv diff --git a/VectoCore/VectoCore/InputData/Reader/ShiftStrategy/ShareIdleLowReader.cs b/VectoCore/VectoCore/InputData/Reader/ShiftStrategy/ShareIdleLowReader.cs index 22ef9444e3..f195e4fcbe 100644 --- a/VectoCore/VectoCore/InputData/Reader/ShiftStrategy/ShareIdleLowReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ShiftStrategy/ShareIdleLowReader.cs @@ -42,7 +42,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ShiftStrategy } - private class Fields + public static class Fields { public const string Velocity = "velocity"; public const string WeightingFactor = "weighting factor"; diff --git a/VectoCore/VectoCore/InputData/Reader/ShiftStrategy/ShareTorque99lLookupReader.cs b/VectoCore/VectoCore/InputData/Reader/ShiftStrategy/ShareTorque99lLookupReader.cs new file mode 100644 index 0000000000..17520e231e --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/ShiftStrategy/ShareTorque99lLookupReader.cs @@ -0,0 +1,30 @@ +using System.IO; +using System.Linq; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.Reader.ShiftStrategy +{ + public class ShareTorque99lLookupReader + { + public static ShareTorque99lLookup ReadFromStream(Stream stream) + { + return Create(VectoCSVFile.ReadStream(stream)); + } + + private static ShareTorque99lLookup Create(TableData data) + { + return new ShareTorque99lLookup( + new LookupDataReader<MeterPerSecond, double>("Share T_99l", new[] { Fields.Velocity, Fields.ShareT99l }) + .Create(data, x => x.ParseDouble(Fields.Velocity).KMPHtoMeterPerSecond(), y => y.ParseDouble(Fields.ShareT99l)) + .OrderBy(x => x.Key).ToArray()); + } + + public static class Fields + { + public const string Velocity = "v"; + public const string ShareT99l = "share T_99l"; + } + } +} diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/ShiftStrategy/ShareTorque99lLookup.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/ShiftStrategy/ShareTorque99lLookup.cs new file mode 100644 index 0000000000..67ee2f02e0 --- /dev/null +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/ShiftStrategy/ShareTorque99lLookup.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using TUGraz.VectoCommon.Utils; + +namespace TUGraz.VectoCore.InputData.Reader.ShiftStrategy { + public class ShareTorque99lLookup + { + private KeyValuePair<MeterPerSecond, double>[] _entries; + + public ShareTorque99lLookup(KeyValuePair<MeterPerSecond, double>[] entries) + { + _entries = entries; + } + + public double Lookup(MeterPerSecond velocity) + { + return _entries.Interpolate(x => x.Key.Value(), y => y.Value, velocity.Value()); + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/Resources/Declaration/GearshiftParameters/ShareTq99L.csv b/VectoCore/VectoCore/Resources/Declaration/GearshiftParameters/ShareTq99L.csv new file mode 100644 index 0000000000..2a73152af6 --- /dev/null +++ b/VectoCore/VectoCore/Resources/Declaration/GearshiftParameters/ShareTq99L.csv @@ -0,0 +1,12 @@ +v [km/h] , share T_99L + 0 , 0.6 + 10 , 0.6 + 20 , 0.8 + 30 , 1.0 + 40 , 1.0 + 50 , 1.0 + 60 , 1.0 + 70 , 1.0 + 80 , 1.0 + 90 , 1.0 +100 , 1.0 \ No newline at end of file diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index 7a91de004f..435433a031 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -163,7 +163,16 @@ <Compile Include="InputData\Reader\Impl\EngineeringModeVectoRunDataFactory.cs" /> <Compile Include="InputData\Reader\Impl\EngineOnlyVectoRunDataFactory.cs" /> <Compile Include="InputData\Reader\ShiftPolygonReader.cs" /> + <Compile Include="Models\SimulationComponent\Data\ShiftStrategy\ShareTorque99lLookup.cs" /> + <Compile Include="InputData\Reader\ShiftStrategy\ShareTorque99lLookupReader.cs" /> + <Compile Include="Models\SimulationComponent\Data\ShiftStrategy\AccelerationReserveLookup.cs" /> + <Compile Include="InputData\Reader\ShiftStrategy\AccelerationReserveLookupReader.cs" /> + <Compile Include="Models\SimulationComponent\Data\ShiftStrategy\EngineSpeedHighFactorLookup.cs" /> + <Compile Include="InputData\Reader\ShiftStrategy\EngineSpeedHighLookupReader.cs" /> + <Compile Include="InputData\Reader\ShiftStrategy\LookupDataReader.cs" /> <Compile Include="InputData\Reader\ShiftStrategy\PredictionDurationLookupReader.cs" /> + <Compile Include="Models\SimulationComponent\Data\ShiftStrategy\ShareIdleLowLookup.cs" /> + <Compile Include="InputData\Reader\ShiftStrategy\ShareIdleLowReader.cs" /> <Compile Include="Models\Declaration\AuxDemandEntry.cs" /> <Compile Include="Models\Declaration\AuxiliaryTypeHelper.cs" /> <Compile Include="Models\Connector\Ports\IDriverDemandPort.cs" /> @@ -467,6 +476,10 @@ <SubType>Designer</SubType> </EmbeddedResource> <EmbeddedResource Include="Resources\Declaration\GearshiftParameters\PredictionTimeLookup.csv" /> + <EmbeddedResource Include="Resources\Declaration\GearshiftParameters\AccelerationReserveLookup.csv" /> + <EmbeddedResource Include="Resources\Declaration\GearshiftParameters\ShareEngineSpeedHigh.csv" /> + <EmbeddedResource Include="Resources\Declaration\GearshiftParameters\ShareIdleLow.csv" /> + <EmbeddedResource Include="Resources\Declaration\GearshiftParameters\ShareTq99L.csv" /> <None Include="Utils\VectoVersionCore.tt"> <Generator>TextTemplatingFileGenerator</Generator> <LastGenOutput>VectoVersionCore.cs</LastGenOutput> diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/ShiftstrategyParameterTests.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/ShiftstrategyParameterTests.cs index f8ddd1a0b6..dd2270ad53 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/ShiftstrategyParameterTests.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/ShiftstrategyParameterTests.cs @@ -91,5 +91,21 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData Assert.AreEqual(expected, val.Value(), 1e-6); } + + [TestCase(0, 0.6), + TestCase(20, 0.8), + TestCase(30, 1.0), + TestCase(110, 1.0), + TestCase(15, 0.7), + TestCase(25, 0.9),] + public void TestShareTq99l(double velcoity, double expected) + { + var lookup = ShareTorque99lLookupReader.ReadFromStream( + RessourceHelper.ReadStream( + DeclarationData.DeclarationDataResourcePrefix + ".GearshiftParameters.ShareTq99L.csv")); + var val = lookup.Lookup(velcoity.KMPHtoMeterPerSecond()); + + Assert.AreEqual(expected, val, 1e-6); + } } } -- GitLab