Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 9e6a9e7e authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

extending auxiliaries classes to provide list of available auxiliaries (for GUI)

parent d505e241
No related branches found
No related tags found
No related merge requests found
...@@ -31,12 +31,13 @@ ...@@ -31,12 +31,13 @@
using System; using System;
using System.Data; using System.Data;
using System.Linq;
using TUGraz.VectoCommon.Utils; using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Utils; using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration 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(); private readonly Alternator _alternator = new Alternator();
...@@ -68,8 +69,9 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -68,8 +69,9 @@ namespace TUGraz.VectoCore.Models.Declaration
public override Watt Lookup(MissionType missionType, string technology = null) public override Watt Lookup(MissionType missionType, string technology = null)
{ {
if (string.IsNullOrWhiteSpace(technology)) if (string.IsNullOrWhiteSpace(technology)) {
technology = "Standard technology"; technology = "Standard technology";
}
var value = base.Lookup(missionType, technology); var value = base.Lookup(missionType, technology);
return value / _alternator.Lookup(missionType); return value / _alternator.Lookup(missionType);
} }
...@@ -103,10 +105,16 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -103,10 +105,16 @@ namespace TUGraz.VectoCore.Models.Declaration
public override double Lookup(MissionType missionType, string technology = null) public override double Lookup(MissionType missionType, string technology = null)
{ {
if (string.IsNullOrWhiteSpace(technology)) if (string.IsNullOrWhiteSpace(technology)) {
technology = "Standard alternator efficiency"; technology = "Standard alternator efficiency";
}
return base.Lookup(missionType, technology); return base.Lookup(missionType, technology);
} }
} }
public string[] GetTechnologies()
{
return Data.Keys.Select(x => x.Item2).Distinct().ToArray();
}
} }
} }
\ No newline at end of file
...@@ -31,12 +31,13 @@ ...@@ -31,12 +31,13 @@
using System; using System;
using System.Data; using System.Data;
using System.Linq;
using TUGraz.VectoCommon.Utils; using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Utils; using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration 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 protected override string ResourceId
{ {
...@@ -55,6 +56,7 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -55,6 +56,7 @@ namespace TUGraz.VectoCore.Models.Declaration
foreach (DataRow row in table.Rows) { foreach (DataRow row in table.Rows) {
var name = row.Field<string>("technology"); var name = row.Field<string>("technology");
foreach (DataColumn col in table.Columns) { foreach (DataColumn col in table.Columns) {
if (col.Caption != "technology") { if (col.Caption != "technology") {
Data[Tuple.Create(col.Caption.ParseEnum<MissionType>(), name)] = row.ParseDouble(col).SI<Watt>(); Data[Tuple.Create(col.Caption.ParseEnum<MissionType>(), name)] = row.ParseDouble(col).SI<Watt>();
...@@ -65,9 +67,15 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -65,9 +67,15 @@ namespace TUGraz.VectoCore.Models.Declaration
public override Watt Lookup(MissionType mission, string technology = null) public override Watt Lookup(MissionType mission, string technology = null)
{ {
if (string.IsNullOrWhiteSpace(technology)) if (string.IsNullOrWhiteSpace(technology)) {
technology = "Crankshaft mounted - Electronically controlled visco clutch"; technology = "Crankshaft mounted - Electronically controlled visco clutch";
}
return base.Lookup(mission, technology); return base.Lookup(mission, technology);
} }
public string[] GetTechnologies()
{
return Data.Keys.Select(x => x.Item2).Distinct().ToArray();
}
} }
} }
\ No newline at end of file
...@@ -31,12 +31,14 @@ ...@@ -31,12 +31,14 @@
using System; using System;
using System.Data; using System.Data;
using Org.BouncyCastle.Asn1;
using TUGraz.VectoCommon.Utils; using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Utils; using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration 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 protected override string ResourceId
{ {
...@@ -63,5 +65,10 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -63,5 +65,10 @@ namespace TUGraz.VectoCore.Models.Declaration
} }
} }
} }
public string[] GetTechnologies()
{
return new[] { "Default" };
}
} }
} }
\ No newline at end of file
...@@ -31,12 +31,13 @@ ...@@ -31,12 +31,13 @@
using System; using System;
using System.Data; using System.Data;
using System.Linq;
using TUGraz.VectoCommon.Utils; using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Utils; using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration 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 protected override string ResourceId
{ {
...@@ -62,5 +63,10 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -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
...@@ -38,26 +38,26 @@ using TUGraz.VectoCore.Utils; ...@@ -38,26 +38,26 @@ using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration 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) public Watt Lookup(MissionType mission, VehicleClass hdvClass, IEnumerable<string> technologies)
{ {
var baseLookup = new SteeringPumpBaseLine(); var baseLine = _baseLookup.Lookup(mission, hdvClass);
var axleLookup = new SteeringPumpAxles();
var techLookup = new SteeringPumpTechnologies();
var baseLine = baseLookup.Lookup(mission, hdvClass);
var power = new SteeringPumpValues<Watt>(0.SI<Watt>(), 0.SI<Watt>(), 0.SI<Watt>()); var power = new SteeringPumpValues<Watt>(0.SI<Watt>(), 0.SI<Watt>(), 0.SI<Watt>());
var factors = new SteeringPumpValues<double>(0, 0, 0); var factors = new SteeringPumpValues<double>(0, 0, 0);
var i = 0; var i = 0;
foreach (var technology in technologies) { foreach (var technology in technologies) {
i++; i++;
var axles = axleLookup.Lookup(mission, i); var axles = _axleLookup.Lookup(mission, i);
power.UnloadedFriction += baseLine.UnloadedFriction * axles.UnloadedFriction; power.UnloadedFriction += baseLine.UnloadedFriction * axles.UnloadedFriction;
power.Banking += baseLine.Banking * axles.Banking; power.Banking += baseLine.Banking * axles.Banking;
power.Steering += baseLine.Steering * axles.Steering; power.Steering += baseLine.Steering * axles.Steering;
var f = techLookup.Lookup(technology, mission); var f = _techLookup.Lookup(technology, mission);
factors.UnloadedFriction += f.UnloadedFriction; factors.UnloadedFriction += f.UnloadedFriction;
factors.Banking += f.Banking; factors.Banking += f.Banking;
factors.Steering += f.Steering; factors.Steering += f.Steering;
...@@ -90,8 +90,9 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -90,8 +90,9 @@ namespace TUGraz.VectoCore.Models.Declaration
foreach (DataRow row in table.Rows) { foreach (DataRow row in table.Rows) {
var hdvClass = VehicleClassHelper.Parse(row.Field<string>("hdvclass")); var hdvClass = VehicleClassHelper.Parse(row.Field<string>("hdvclass"));
foreach (DataColumn col in table.Columns) { 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; continue;
}
var values = row.Field<string>(col.Caption).Split('/') var values = row.Field<string>(col.Caption).Split('/')
.Select(v => v.ToDouble() / 100.0).Concat(0.0.Repeat(3)).SI<Watt>().ToList(); .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], Data[Tuple.Create(col.Caption.ParseEnum<MissionType>(), hdvClass)] = new SteeringPumpValues<Watt>(values[0],
...@@ -144,6 +145,11 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -144,6 +145,11 @@ namespace TUGraz.VectoCore.Models.Declaration
} }
return values; return values;
} }
public string[] GetTechnologies()
{
return Data.Keys.Distinct().ToArray();
}
} }
private sealed class SteeringPumpAxles : LookupData<MissionType, int, SteeringPumpValues<double>> private sealed class SteeringPumpAxles : LookupData<MissionType, int, SteeringPumpValues<double>>
...@@ -166,11 +172,13 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -166,11 +172,13 @@ namespace TUGraz.VectoCore.Models.Declaration
foreach (DataRow row in table.Rows) { foreach (DataRow row in table.Rows) {
var axleNumber = int.Parse(row.Field<string>("steeredaxles")); var axleNumber = int.Parse(row.Field<string>("steeredaxles"));
foreach (DataColumn col in table.Columns) { foreach (DataColumn col in table.Columns) {
if (col.Caption == "steeredaxles") if (col.Caption == "steeredaxles") {
continue; continue;
}
var field = row.Field<string>(col.Caption); var field = row.Field<string>(col.Caption);
if (string.IsNullOrWhiteSpace(field)) if (string.IsNullOrWhiteSpace(field)) {
continue; continue;
}
var values = field.Split('/').ToDouble().Concat(0.0.Repeat(3)).ToList(); var values = field.Split('/').ToDouble().Concat(0.0.Repeat(3)).ToList();
Data[Tuple.Create(col.Caption.ParseEnum<MissionType>(), axleNumber)] = new SteeringPumpValues<double>(values[0], Data[Tuple.Create(col.Caption.ParseEnum<MissionType>(), axleNumber)] = new SteeringPumpValues<double>(values[0],
values[1], values[2]); values[1], values[2]);
...@@ -192,5 +200,10 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -192,5 +200,10 @@ namespace TUGraz.VectoCore.Models.Declaration
Steering = steering; Steering = steering;
} }
} }
public string[] GetTechnologies()
{
return _techLookup.GetTechnologies();
}
} }
} }
\ No newline at end of file
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/ */
using System.Collections.Generic;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using TUGraz.VectoCommon.Utils; using TUGraz.VectoCommon.Utils;
...@@ -38,6 +39,8 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -38,6 +39,8 @@ namespace TUGraz.VectoCore.Models.Declaration
{ {
public sealed class Wheels : LookupData<string, Wheels.Entry> public sealed class Wheels : LookupData<string, Wheels.Entry>
{ {
private string[] _dimensions;
protected override string ResourceId protected override string ResourceId
{ {
get { return "TUGraz.VectoCore.Resources.Declaration.Wheels.csv"; } get { return "TUGraz.VectoCore.Resources.Declaration.Wheels.csv"; }
...@@ -62,6 +65,7 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -62,6 +65,7 @@ namespace TUGraz.VectoCore.Models.Declaration
DynamicTyreRadius = row.ParseDouble("d").SI().Milli.Meter.Cast<Meter>(), DynamicTyreRadius = row.ParseDouble("d").SI().Milli.Meter.Cast<Meter>(),
CircumferenceFactor = row.ParseDouble("f") CircumferenceFactor = row.ParseDouble("f")
}).ToDictionary(e => e.WheelType); }).ToDictionary(e => e.WheelType);
_dimensions = table.Rows.Cast<DataRow>().Select(row => row.Field<string>(0)).ToArray();
} }
public class Entry public class Entry
...@@ -71,5 +75,10 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -71,5 +75,10 @@ namespace TUGraz.VectoCore.Models.Declaration
public Meter DynamicTyreRadius; public Meter DynamicTyreRadius;
public double CircumferenceFactor; public double CircumferenceFactor;
} }
public string[] GetWheelsDimensions()
{
return _dimensions;
}
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment