diff --git a/VECTO.sln.DotSettings b/VECTO.sln.DotSettings index 1e16474b715987ab4268bc61cdefb4c9b02b2768..d35b7aa96aaf9ec5613e6859310011cc46ebb1dd 100644 --- a/VECTO.sln.DotSettings +++ b/VECTO.sln.DotSettings @@ -1,4 +1,5 @@ <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> + <s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">Default: Reformat Code</s:String> <s:String x:Key="/Default/CodeStyle/CodeFormatting/CommonFormatter/ALIGNMENT_TAB_FILL_STYLE/@EntryValue">USE_TABS_ONLY</s:String> <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String> <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">END_OF_LINE</s:String> diff --git a/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/Models/Declaration/DeclarationData.cs index e12fc5d2534a63c8c8769bb7163dcb08af5e9166..801098cd99e25cd8fc2505fca22ce0c7fe458921 100644 --- a/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/Models/Declaration/DeclarationData.cs @@ -1,4 +1,6 @@ -namespace TUGraz.VectoCore.Models.Declaration +using System.Data; + +namespace TUGraz.VectoCore.Models.Declaration { public class DeclarationData { @@ -12,6 +14,7 @@ private HeatingVentilationAirConditioning _heatingVentilationAirConditioning; private PneumaticSystem _pneumaticSystem; private SteeringPump _steeringPump; + private WHTCCorrection _whtcCorrection; public static Wheels Wheels { @@ -62,9 +65,32 @@ get { return Instance()._steeringPump ?? (Instance()._steeringPump = new SteeringPump()); } } + public static WHTCCorrection WHTCCorrection + { + get { return Instance()._whtcCorrection ?? (Instance()._whtcCorrection = new WHTCCorrection()); } + } + private static DeclarationData Instance() { return _instance ?? (_instance = new DeclarationData()); } } + + public class WHTCCorrection : LookupData<MissionType, double, double, double, double> + { + public override double Lookup(MissionType key1, double key2, double key3, double key4) + { + throw new System.NotImplementedException(); + } + + protected override string ResourceId + { + get { throw new System.NotImplementedException(); } + } + + protected override void ParseData(DataTable table) + { + throw new System.NotImplementedException(); + } + } } \ No newline at end of file diff --git a/VectoCore/Resources/Declaration/WHTC-Weighting-Factors.csv b/VectoCore/Resources/Declaration/WHTC-Weighting-Factors.csv index 4d00f736a8fa3eae465182a1618051e782bc0ab9..81c75304eeeb49814de180818545548f043882c4 100644 --- a/VectoCore/Resources/Declaration/WHTC-Weighting-Factors.csv +++ b/VectoCore/Resources/Declaration/WHTC-Weighting-Factors.csv @@ -1,4 +1,4 @@ Part,Long haul,Regional delivery,Urban delivery,Municipal utility,Construction,Heavy Urban,Urban,Suburban,Interurban,Coach -Urban,11,17,69,98,62,100,100,100,45,0 -Rural,0,30,27,0,32,0,0,0,36,22 -Motorway,89,53,4,2,6,0,0,0,19,78 +Urban,0.11,0.17,0.69,0.98,0.62,1.0,1.0,1.0,0.45,0.0 +Rural,0.0,0.3,0.27,0.0,0.32,0.0,0.0,0.0,0.36,0.22 +Motorway,0.89,0.53,0.04,0.02,0.06,0.0,0.0,0.0,0.19,0.78 diff --git a/VectoCoreTest/Models/DeclarationDataTest.cs b/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs similarity index 88% rename from VectoCoreTest/Models/DeclarationDataTest.cs rename to VectoCoreTest/Models/Declaration/DeclarationDataTest.cs index 93eebf31699d4b7b261b3f1b14794c97a9e3736f..7a7bbbadb579358282ce1cc882170a44ab1a3ab5 100644 --- a/VectoCoreTest/Models/DeclarationDataTest.cs +++ b/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs @@ -9,12 +9,13 @@ using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Tests.Utils; using TUGraz.VectoCore.Utils; -namespace TUGraz.VectoCore.Tests.Models +namespace TUGraz.VectoCore.Tests.Models.Declaration { [TestClass] public class DeclarationDataTest { - public const double Tolerance = 0.0001; + private const double Tolerance = 0.0001; + private MissionType[] missions = Enum.GetValues(typeof(MissionType)).Cast<MissionType>().ToArray(); [TestMethod] public void WheelDataTest() @@ -81,6 +82,42 @@ namespace TUGraz.VectoCore.Tests.Models Assert.Inconclusive(); } + [TestMethod] + public void WHTCWeightingTest() + { + var whtc = DeclarationData.WHTCCorrection; + + var factors = new { + urban = new[] { 0.11, 0.17, 0.69, 0.98, 0.62, 1.0, 1.0, 1.0, 0.45, 0.0 }, + rural = new[] { 0.0, 0.3, 0.27, 0.0, 0.32, 0.0, 0.0, 0.0, 0.36, 0.22 }, + motorway = new[] { 0.89, 0.53, 0.04, 0.02, 0.06, 0.0, 0.0, 0.0, 0.19, 0.78 } + }; + + var r = new Random(); + for (var i = 0; i < missions.Length; i++) { + var urban = r.NextDouble() * 2; + var rural = r.NextDouble() * 2; + var motorway = r.NextDouble() * 2; + double whtcValue = whtc.Lookup(missions[i], urban, rural, motorway); + Assert.AreEqual(urban * factors.urban[i] + rural * factors.rural[i] + motorway * factors.motorway[i], whtcValue); + } + + Assert.Inconclusive(); + } + + [TestMethod] + public void VCDVTest() + { + Assert.Inconclusive(); + } + + [TestMethod] + public void DefaultTCTest() + { + Assert.Inconclusive(); + } + + [TestMethod] public void AuxElectricSystemTest() { @@ -152,17 +189,8 @@ namespace TUGraz.VectoCore.Tests.Models } }; - var missions = new[] { - MissionType.LongHaul, MissionType.RegionalDelivery, MissionType.UrbanDelivery, MissionType.MunicipalUtility, - MissionType.Construction, MissionType.HeavyUrban, MissionType.Urban, - MissionType.Suburban, MissionType.Interurban, MissionType.Coach - }; - - Assert.AreEqual(missions.Length, Enum.GetValues(typeof(MissionType)).Length, "something wrong in the mission list."); - Assert.IsTrue(expected.All(kv => kv.Value.Length == missions.Length), "something wrong in the test values lists."); - for (var i = 0; i < missions.Length; i++) { - // default + // default tech Watt defaultValue = fan.Lookup(missions[i], ""); Assert.AreEqual(expected[defaultFan][i], defaultValue.Double(), Tolerance); @@ -194,15 +222,6 @@ namespace TUGraz.VectoCore.Tests.Models { "12", new[] { 0, 0, 0, 0, 200, 0, 0, 0, 0, 0 } } }; - var missions = new[] { - MissionType.LongHaul, MissionType.RegionalDelivery, MissionType.UrbanDelivery, MissionType.MunicipalUtility, - MissionType.Construction, MissionType.HeavyUrban, MissionType.Urban, - MissionType.Suburban, MissionType.Interurban, MissionType.Coach - }; - - Assert.AreEqual(missions.Length, Enum.GetValues(typeof(MissionType)).Length, "something wrong in the mission list."); - Assert.IsTrue(expected.All(kv => kv.Value.Length == missions.Length), "something wrong in the test values lists."); - for (var i = 0; i < missions.Length; i++) { foreach (var expect in expected) { Watt value = hvac.Lookup(missions[i], expect.Key); @@ -231,15 +250,6 @@ namespace TUGraz.VectoCore.Tests.Models { "12", new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } }; - var missions = new[] { - MissionType.LongHaul, MissionType.RegionalDelivery, MissionType.UrbanDelivery, MissionType.MunicipalUtility, - MissionType.Construction, MissionType.HeavyUrban, MissionType.Urban, - MissionType.Suburban, MissionType.Interurban, MissionType.Coach - }; - - Assert.AreEqual(missions.Length, Enum.GetValues(typeof(MissionType)).Length, "something wrong in the mission list."); - Assert.IsTrue(expected.All(kv => kv.Value.Length == missions.Length), "something wrong in the test values lists."); - for (var i = 0; i < missions.Length; i++) { foreach (var expect in expected) { Watt value = ps.Lookup(missions[i], expect.Key); @@ -296,27 +306,10 @@ namespace TUGraz.VectoCore.Tests.Models } }; - var missions = new[] { - MissionType.LongHaul, - MissionType.RegionalDelivery, - MissionType.UrbanDelivery, - MissionType.MunicipalUtility, - MissionType.Construction, - MissionType.HeavyUrban, - MissionType.Urban, - MissionType.Suburban, - MissionType.Interurban, - MissionType.Coach - }; - - Assert.AreEqual(missions.Length, Enum.GetValues(typeof(MissionType)).Length, "something wrong in the mission list."); - foreach (var expect in expected) { var technology = expect.Key; foreach (var hdvClasses in expect.Value) { var hdvClass = hdvClasses.Key; - Assert.IsTrue(expected.All(kv => hdvClasses.Value.Length == missions.Length), - "something wrong in the test values lists."); for (var i = 0; i < missions.Length; i++) { Watt value = sp.Lookup(missions[i], hdvClass, technology); Assert.AreEqual(hdvClasses.Value[i], value.Double(), Tolerance); diff --git a/VectoCoreTest/VectoCoreTest.csproj b/VectoCoreTest/VectoCoreTest.csproj index 4986286459103404c35b2f53099ab0e063d1bd1f..2b918ed8dd88c8bdf460c307819c609f4b9354d1 100644 --- a/VectoCoreTest/VectoCoreTest.csproj +++ b/VectoCoreTest/VectoCoreTest.csproj @@ -70,7 +70,7 @@ <ItemGroup> <Compile Include="Exceptions\ExceptionTests.cs" /> <Compile Include="Integration\EngineOnlyCycle\EngineOnlyCycleTest.cs" /> - <Compile Include="Models\DeclarationDataTest.cs" /> + <Compile Include="Models\DeclarationData\DeclarationDataTest.cs" /> <Compile Include="Models\SimulationComponentData\AccelerationCurveTest.cs" /> <Compile Include="Models\SimulationComponentData\FuelConsumptionMapTest.cs" /> <Compile Include="Models\SimulationComponentData\FullLoadCurveTest.cs" /> @@ -267,9 +267,7 @@ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> </ItemGroup> - <ItemGroup> - <Folder Include="Models\DeclarationData\" /> - </ItemGroup> + <ItemGroup /> <Choose> <When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'"> <ItemGroup>