From 9d3c79392ddefdb2a5e661b529abfd028abd9173 Mon Sep 17 00:00:00 2001 From: Michael Krisper <michael.krisper@tugraz.at> Date: Tue, 7 Jul 2015 12:26:40 +0200 Subject: [PATCH] aux steering pump --- .../Models/Declaration/DeclarationData.cs | 44 ++++++++++- VectoCoreTest/Models/DeclarationDataTest.cs | 79 +++++++++++++++++-- 2 files changed, 115 insertions(+), 8 deletions(-) diff --git a/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/Models/Declaration/DeclarationData.cs index 853535f7a4..733b33d9e9 100644 --- a/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/Models/Declaration/DeclarationData.cs @@ -17,6 +17,7 @@ namespace TUGraz.VectoCore.Models.Declaration private DeclarationFan _fan; private DeclarationHVAC _hvac; private DeclarationPneumaticSystem _pneumaticSystem; + private DeclarationSteeringPump _steeringPump; public static DeclarationWheels Wheels { @@ -58,15 +59,53 @@ namespace TUGraz.VectoCore.Models.Declaration get { return Instance()._pneumaticSystem ?? (Instance()._pneumaticSystem = new DeclarationPneumaticSystem()); } } + public static DeclarationSteeringPump SteeringPump + { + get { return Instance()._steeringPump ?? (Instance()._steeringPump = new DeclarationSteeringPump()); } + } + private static DeclarationData Instance() { return _instance ?? (_instance = new DeclarationData()); } } + public class DeclarationSteeringPump : LookupData<MissionType, string, string, Watt> + { + private readonly Dictionary<Tuple<MissionType, string, string>, Watt> _data = + new Dictionary<Tuple<MissionType, string, string>, Watt>(); + + + + + public override Watt Lookup(MissionType mission, string hdvClass, string technology) + { + return _data[Tuple.Create(mission, hdvClass, technology)]; + } + + protected override string ResourceId + { + get { return "TUGraz.VectoCore.Resources.Declaration.VAUX.SP-Table.csv"; } + } + + protected override void ParseData(DataTable table) + { + _data.Clear(); + NormalizeTable(table); + + foreach (DataRow row in table.Rows) { + var hdvClass = row.Field<string>("hdvclass/powerdemandpershare"); + foreach (MissionType mission in Enum.GetValues(typeof(MissionType))) { + _data[Tuple.Create(mission, hdvClass)] = row.ParseDouble(mission.ToString().ToLower()).SI<Watt>(); + } + } + } + } + public class DeclarationPneumaticSystem : LookupData<MissionType, string, Watt> { - private Dictionary<Tuple<MissionType, string>, Watt> _data = new Dictionary<Tuple<MissionType, string>, Watt>(); + private readonly Dictionary<Tuple<MissionType, string>, Watt> _data = + new Dictionary<Tuple<MissionType, string>, Watt>(); public override Watt Lookup(MissionType mission, string hdvClass) { @@ -94,7 +133,8 @@ namespace TUGraz.VectoCore.Models.Declaration public class DeclarationHVAC : LookupData<MissionType, string, Watt> { - private Dictionary<Tuple<MissionType, string>, Watt> _data = new Dictionary<Tuple<MissionType, string>, Watt>(); + private readonly Dictionary<Tuple<MissionType, string>, Watt> _data = + new Dictionary<Tuple<MissionType, string>, Watt>(); public override Watt Lookup(MissionType mission, string hdvClass) { diff --git a/VectoCoreTest/Models/DeclarationDataTest.cs b/VectoCoreTest/Models/DeclarationDataTest.cs index e31a3ab347..05703aba25 100644 --- a/VectoCoreTest/Models/DeclarationDataTest.cs +++ b/VectoCoreTest/Models/DeclarationDataTest.cs @@ -262,14 +262,81 @@ namespace TUGraz.VectoCore.Tests.Models } [TestMethod] - public void AuxSPTableTest() + public void AuxSPTest() { - Assert.Inconclusive(); - } + var sp = DeclarationData.SteeringPump; + + var expected = new Dictionary<string, Dictionary<string, int[]>> { + { + "Fixed displacement", new Dictionary<string, int[]> { + { "1", new[] { 0, 260, 270, 0, 0, 0, 0, 0, 0, 0 } }, + { "2", new[] { 370, 320, 310, 0, 0, 0, 0, 0, 0, 0 } }, + { "3", new[] { 0, 340, 350, 0, 0, 0, 0, 0, 0, 0 } }, + { "4", new[] { 610, 530, 0, 530, 0, 0, 0, 0, 0, 0 } }, + { "5", new[] { 720, 630, 620, 0, 0, 0, 0, 0, 0, 0 } }, + { "6", new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { "7", new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { "8", new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { "9", new[] { 720, 550, 0, 550, 0, 0, 0, 0, 0, 0 } }, + { "10", new[] { 570, 530, 0, 0, 0, 0, 0, 0, 0, 0 } } + } + }, { + "Variable displacement", new Dictionary<string, int[]> { + { "1", new[] { 0, 156, 162, 0, 0, 0, 0, 0, 0, 0 } }, + { "2", new[] { 222, 192, 186, 0, 0, 0, 0, 0, 0, 0 } }, + { "3", new[] { 0, 204, 210, 0, 0, 0, 0, 0, 0, 0 } }, + { "4", new[] { 366, 318, 0, 318, 0, 0, 0, 0, 0, 0 } }, + { "5", new[] { 432, 378, 372, 0, 0, 0, 0, 0, 0, 0 } }, + { "6", new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { "7", new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { "8", new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { "9", new[] { 432, 330, 0, 330, 0, 0, 0, 0, 0, 0 } }, + { "10", new[] { 342, 318, 0, 0, 0, 0, 0, 0, 0, 0 } } + } + }, { + "Hydraulic supported by electric", new Dictionary<string, int[]> { + { "1", new[] { 0, 225, 235, 0, 0, 0, 0, 0, 0, 0 } }, + { "2", new[] { 322, 278, 269, 0, 0, 0, 0, 0, 0, 0 } }, + { "3", new[] { 0, 295, 304, 0, 0, 0, 0, 0, 0, 0 } }, + { "4", new[] { 531, 460, 0, 460, 0, 0, 0, 0, 0, 0 } }, + { "5", new[] { 627, 546, 540, 0, 0, 0, 0, 0, 0, 0 } }, + { "6", new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { "7", new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { "8", new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { "9", new[] { 627, 478, 0, 478, 0, 0, 0, 0, 0, 0 } }, + { "10", new[] { 498, 461, 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."); + + 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); + } + } + } - [TestMethod] - public void AuxSPTechTest() - { Assert.Inconclusive(); } -- GitLab