diff --git a/VectoCore/VectoCore/InputData/Reader/ShiftStrategy/PredictionDurationLookupReader.cs b/VectoCore/VectoCore/InputData/Reader/ShiftStrategy/PredictionDurationLookupReader.cs index a9d7b69f5a82e24157f5960eece684a41ec47f39..9905ab53af56c8d6ad40236b4669a697861e8f9d 100644 --- a/VectoCore/VectoCore/InputData/Reader/ShiftStrategy/PredictionDurationLookupReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ShiftStrategy/PredictionDurationLookupReader.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; @@ -54,11 +55,11 @@ namespace TUGraz.VectoCore.InputData.Reader.ShiftStrategy return new PredictionDurationLookup( data.Rows.Cast<DataRow>() .Select( - r => new PredictionDurationLookup.Entry() { - SpeedRatio = r.ParseDouble(Fields.SpeedRatio), - PredictionTimeRatio = r.ParseDouble(Fields.PredictionTimeRatio) - }) - .OrderBy(x => x.SpeedRatio) + r => new KeyValuePair<double, double>( + r.ParseDouble(Fields.SpeedRatio), + r.ParseDouble(Fields.PredictionTimeRatio) + )) + .OrderBy(x => x.Key) .ToList()); } diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index 5333e84a473a842461bb6721b457dbe5e61eb0af..7a91de004f58449ee56d273526a8d386f4df54e3 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -163,6 +163,7 @@ <Compile Include="InputData\Reader\Impl\EngineeringModeVectoRunDataFactory.cs" /> <Compile Include="InputData\Reader\Impl\EngineOnlyVectoRunDataFactory.cs" /> <Compile Include="InputData\Reader\ShiftPolygonReader.cs" /> + <Compile Include="InputData\Reader\ShiftStrategy\PredictionDurationLookupReader.cs" /> <Compile Include="Models\Declaration\AuxDemandEntry.cs" /> <Compile Include="Models\Declaration\AuxiliaryTypeHelper.cs" /> <Compile Include="Models\Connector\Ports\IDriverDemandPort.cs" /> @@ -465,6 +466,7 @@ <EmbeddedResource Include="Resources\XSD\VectoOutputManufacturer.0.6.xsd"> <SubType>Designer</SubType> </EmbeddedResource> + <EmbeddedResource Include="Resources\Declaration\GearshiftParameters\PredictionTimeLookup.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 new file mode 100644 index 0000000000000000000000000000000000000000..ddad73654f75d78953d80a389d149cb1ce8d751a --- /dev/null +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/ShiftstrategyParameterTests.cs @@ -0,0 +1,30 @@ +using NUnit.Framework; +using NUnit.Framework.Internal; +using TUGraz.VectoCore.InputData.Reader.ShiftStrategy; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.SimulationComponent.Data.ShiftStrategy; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData +{ + [TestFixture] + public class ShiftstrategyParameterTests + { + + [TestCase(0.3, 1.0), + TestCase(0.8, 1.0), + TestCase(0.9, 0.5), + TestCase(1.5, 0.5), + TestCase(0.85, 0.75) + ] + public void TestPredictionIntervalLookup(double speedRatio, double expected) + { + var lookup = PredictionDurationLookupReader.ReadFromStream( + RessourceHelper.ReadStream( + DeclarationData.DeclarationDataResourcePrefix + ".GearshiftParameters.PredictionTimeLookup.csv")); + var val = lookup.Lookup(speedRatio); + + Assert.AreEqual(expected, val, 1e-6); + } + } +} diff --git a/VectoCore/VectoCoreTest/VectoCoreTest.csproj b/VectoCore/VectoCoreTest/VectoCoreTest.csproj index a97a3edacd070695097c0eec811aa1260ebcee41..b5f47043db07e774982b9bb85b9cdb5415e78cda 100644 --- a/VectoCore/VectoCoreTest/VectoCoreTest.csproj +++ b/VectoCore/VectoCoreTest/VectoCoreTest.csproj @@ -100,6 +100,7 @@ <Compile Include="Models\Declaration\DataAdapter\DeclarationDataAdapterTest_Class2.cs" /> <Compile Include="Models\Declaration\DataAdapter\DeclarationDataAdapterTest_Class9.cs" /> <Compile Include="Models\Declaration\ShiftPolygonTest.cs" /> + <Compile Include="Models\SimulationComponentData\ShiftstrategyParameterTests.cs" /> <Compile Include="Models\SimulationComponentData\TorqueConverterDataTest.cs" /> <Compile Include="Models\SimulationComponentData\ValidationTest.cs" /> <Compile Include="Models\SimulationComponent\ATGearboxTest.cs" />