diff --git a/VectoCore/VectoCore/Models/Declaration/ElectricSystem.cs b/VectoCore/VectoCore/Models/Declaration/ElectricSystem.cs index b68718cc1fab9bb45f3a0eae597c333936dce4d6..bdc17fea45f1517261528deff84eeb874417107f 100644 --- a/VectoCore/VectoCore/Models/Declaration/ElectricSystem.cs +++ b/VectoCore/VectoCore/Models/Declaration/ElectricSystem.cs @@ -31,12 +31,13 @@ using System; using System.Data; +using System.Linq; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public sealed class ElectricSystem : LookupData<MissionType, string, Watt> + public sealed class ElectricSystem : LookupData<MissionType, string, Watt>, IDeclarationAuxiliaryTable { private readonly Alternator _alternator = new Alternator(); @@ -68,8 +69,9 @@ namespace TUGraz.VectoCore.Models.Declaration public override Watt Lookup(MissionType missionType, string technology = null) { - if (string.IsNullOrWhiteSpace(technology)) + if (string.IsNullOrWhiteSpace(technology)) { technology = "Standard technology"; + } var value = base.Lookup(missionType, technology); return value / _alternator.Lookup(missionType); } @@ -103,10 +105,16 @@ namespace TUGraz.VectoCore.Models.Declaration public override double Lookup(MissionType missionType, string technology = null) { - if (string.IsNullOrWhiteSpace(technology)) + if (string.IsNullOrWhiteSpace(technology)) { technology = "Standard alternator efficiency"; + } return base.Lookup(missionType, technology); } } + + public string[] GetTechnologies() + { + return Data.Keys.Select(x => x.Item2).Distinct().ToArray(); + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Declaration/Fan.cs b/VectoCore/VectoCore/Models/Declaration/Fan.cs index b1940483d84025c8169bf112fc8fa45c5885035d..54673dff50cc6fa3f51048c1003fe5486badfeb4 100644 --- a/VectoCore/VectoCore/Models/Declaration/Fan.cs +++ b/VectoCore/VectoCore/Models/Declaration/Fan.cs @@ -31,12 +31,13 @@ using System; using System.Data; +using System.Linq; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public sealed class Fan : LookupData<MissionType, string, Watt> + public sealed class Fan : LookupData<MissionType, string, Watt>, IDeclarationAuxiliaryTable { protected override string ResourceId { @@ -55,6 +56,7 @@ namespace TUGraz.VectoCore.Models.Declaration foreach (DataRow row in table.Rows) { var name = row.Field<string>("technology"); + foreach (DataColumn col in table.Columns) { if (col.Caption != "technology") { Data[Tuple.Create(col.Caption.ParseEnum<MissionType>(), name)] = row.ParseDouble(col).SI<Watt>(); @@ -65,9 +67,15 @@ namespace TUGraz.VectoCore.Models.Declaration public override Watt Lookup(MissionType mission, string technology = null) { - if (string.IsNullOrWhiteSpace(technology)) + if (string.IsNullOrWhiteSpace(technology)) { technology = "Crankshaft mounted - Electronically controlled visco clutch"; + } return base.Lookup(mission, technology); } + + public string[] GetTechnologies() + { + return Data.Keys.Select(x => x.Item2).Distinct().ToArray(); + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Declaration/HVAC.cs b/VectoCore/VectoCore/Models/Declaration/HVAC.cs index 2dbdaa761814e506ee4347cea9b10aa736880f86..2e4f31833b5f954c8acd0f8a1435164b503f61c8 100644 --- a/VectoCore/VectoCore/Models/Declaration/HVAC.cs +++ b/VectoCore/VectoCore/Models/Declaration/HVAC.cs @@ -31,12 +31,14 @@ using System; using System.Data; +using Org.BouncyCastle.Asn1; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public sealed class HeatingVentilationAirConditioning : LookupData<MissionType, VehicleClass, Watt> + public sealed class HeatingVentilationAirConditioning : LookupData<MissionType, VehicleClass, Watt>, + IDeclarationAuxiliaryTable { protected override string ResourceId { @@ -63,5 +65,10 @@ namespace TUGraz.VectoCore.Models.Declaration } } } + + public string[] GetTechnologies() + { + return new[] { "Default" }; + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Declaration/PneumaticSystem.cs b/VectoCore/VectoCore/Models/Declaration/PneumaticSystem.cs index c0d2bbc79945a59c84b482361c16e98bfa08e79a..37d965f8d2abbdd47ffc6d9c889a7591fcd98cc5 100644 --- a/VectoCore/VectoCore/Models/Declaration/PneumaticSystem.cs +++ b/VectoCore/VectoCore/Models/Declaration/PneumaticSystem.cs @@ -31,12 +31,13 @@ using System; using System.Data; +using System.Linq; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public sealed class PneumaticSystem : LookupData<MissionType, string, Watt> + public sealed class PneumaticSystem : LookupData<MissionType, string, Watt>, IDeclarationAuxiliaryTable { protected override string ResourceId { @@ -62,5 +63,10 @@ namespace TUGraz.VectoCore.Models.Declaration } } } + + public string[] GetTechnologies() + { + return Data.Keys.Select(x => x.Item2).Distinct().ToArray(); + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Declaration/SteeringPump.cs b/VectoCore/VectoCore/Models/Declaration/SteeringPump.cs index dc2965fc589a36893cd3b05299c895d239e2f3ba..1feac2e11bdebae29a21de1d0d2ace52cbbc6c2f 100644 --- a/VectoCore/VectoCore/Models/Declaration/SteeringPump.cs +++ b/VectoCore/VectoCore/Models/Declaration/SteeringPump.cs @@ -38,26 +38,26 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public sealed class SteeringPump + public sealed class SteeringPump : IDeclarationAuxiliaryTable { + private readonly SteeringPumpBaseLine _baseLookup = new SteeringPumpBaseLine(); + private readonly SteeringPumpAxles _axleLookup = new SteeringPumpAxles(); + private readonly SteeringPumpTechnologies _techLookup = new SteeringPumpTechnologies(); + public Watt Lookup(MissionType mission, VehicleClass hdvClass, IEnumerable<string> technologies) { - var baseLookup = new SteeringPumpBaseLine(); - var axleLookup = new SteeringPumpAxles(); - var techLookup = new SteeringPumpTechnologies(); - - var baseLine = baseLookup.Lookup(mission, hdvClass); + var baseLine = _baseLookup.Lookup(mission, hdvClass); var power = new SteeringPumpValues<Watt>(0.SI<Watt>(), 0.SI<Watt>(), 0.SI<Watt>()); var factors = new SteeringPumpValues<double>(0, 0, 0); var i = 0; foreach (var technology in technologies) { i++; - var axles = axleLookup.Lookup(mission, i); + var axles = _axleLookup.Lookup(mission, i); power.UnloadedFriction += baseLine.UnloadedFriction * axles.UnloadedFriction; power.Banking += baseLine.Banking * axles.Banking; power.Steering += baseLine.Steering * axles.Steering; - var f = techLookup.Lookup(technology, mission); + var f = _techLookup.Lookup(technology, mission); factors.UnloadedFriction += f.UnloadedFriction; factors.Banking += f.Banking; factors.Steering += f.Steering; @@ -90,8 +90,9 @@ namespace TUGraz.VectoCore.Models.Declaration foreach (DataRow row in table.Rows) { var hdvClass = VehicleClassHelper.Parse(row.Field<string>("hdvclass")); foreach (DataColumn col in table.Columns) { - if (col.Caption == "hdvclass" || string.IsNullOrWhiteSpace(row.Field<string>(col.Caption))) + if (col.Caption == "hdvclass" || string.IsNullOrWhiteSpace(row.Field<string>(col.Caption))) { continue; + } var values = row.Field<string>(col.Caption).Split('/') .Select(v => v.ToDouble() / 100.0).Concat(0.0.Repeat(3)).SI<Watt>().ToList(); Data[Tuple.Create(col.Caption.ParseEnum<MissionType>(), hdvClass)] = new SteeringPumpValues<Watt>(values[0], @@ -144,6 +145,11 @@ namespace TUGraz.VectoCore.Models.Declaration } return values; } + + public string[] GetTechnologies() + { + return Data.Keys.Distinct().ToArray(); + } } private sealed class SteeringPumpAxles : LookupData<MissionType, int, SteeringPumpValues<double>> @@ -166,11 +172,13 @@ namespace TUGraz.VectoCore.Models.Declaration foreach (DataRow row in table.Rows) { var axleNumber = int.Parse(row.Field<string>("steeredaxles")); foreach (DataColumn col in table.Columns) { - if (col.Caption == "steeredaxles") + if (col.Caption == "steeredaxles") { continue; + } var field = row.Field<string>(col.Caption); - if (string.IsNullOrWhiteSpace(field)) + if (string.IsNullOrWhiteSpace(field)) { continue; + } var values = field.Split('/').ToDouble().Concat(0.0.Repeat(3)).ToList(); Data[Tuple.Create(col.Caption.ParseEnum<MissionType>(), axleNumber)] = new SteeringPumpValues<double>(values[0], values[1], values[2]); @@ -192,5 +200,10 @@ namespace TUGraz.VectoCore.Models.Declaration Steering = steering; } } + + public string[] GetTechnologies() + { + return _techLookup.GetTechnologies(); + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Declaration/Wheels.cs b/VectoCore/VectoCore/Models/Declaration/Wheels.cs index 8d70ab77e922540b9e0ec93f499e337c7900ab74..eed2c80c39fa65e46034c926cab6c1cc50d00863 100644 --- a/VectoCore/VectoCore/Models/Declaration/Wheels.cs +++ b/VectoCore/VectoCore/Models/Declaration/Wheels.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System.Collections.Generic; using System.Data; using System.Linq; using TUGraz.VectoCommon.Utils; @@ -38,6 +39,8 @@ namespace TUGraz.VectoCore.Models.Declaration { public sealed class Wheels : LookupData<string, Wheels.Entry> { + private string[] _dimensions; + protected override string ResourceId { get { return "TUGraz.VectoCore.Resources.Declaration.Wheels.csv"; } @@ -62,6 +65,7 @@ namespace TUGraz.VectoCore.Models.Declaration DynamicTyreRadius = row.ParseDouble("d").SI().Milli.Meter.Cast<Meter>(), CircumferenceFactor = row.ParseDouble("f") }).ToDictionary(e => e.WheelType); + _dimensions = table.Rows.Cast<DataRow>().Select(row => row.Field<string>(0)).ToArray(); } public class Entry @@ -71,5 +75,10 @@ namespace TUGraz.VectoCore.Models.Declaration public Meter DynamicTyreRadius; public double CircumferenceFactor; } + + public string[] GetWheelsDimensions() + { + return _dimensions; + } } } \ No newline at end of file