Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 82f7ef83 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

implemented steering pump auxiliaries in declaration mode, renamed declaration...

implemented steering pump auxiliaries in declaration mode, renamed declaration classes (removed declaration from name, because it is already in namespace)
parent 9d3c7939
No related branches found
No related tags found
No related merge requests found
Showing with 234 additions and 169 deletions
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
namespace TUGraz.VectoCore.Models.Declaration
{
public class DeclarationData
{
private static DeclarationData _instance;
private DeclarationSegments _segments;
private DeclarationRims _rims;
private DeclarationWheels _wheels;
private DeclarationPT1 _pt1;
private Segments _segments;
private Rims _rims;
private Wheels _wheels;
private PT1 _pt1;
private ElectricSystem _electricSystem;
private DeclarationFan _fan;
private DeclarationHVAC _hvac;
private DeclarationPneumaticSystem _pneumaticSystem;
private DeclarationSteeringPump _steeringPump;
private Fan _fan;
private HVAC _hvac;
private PneumaticSystem _pneumaticSystem;
private SteeringPump _steeringPump;
public static DeclarationWheels Wheels
public static Wheels Wheels
{
get { return Instance()._wheels ?? (Instance()._wheels = new DeclarationWheels()); }
get { return Instance()._wheels ?? (Instance()._wheels = new Wheels()); }
}
public static DeclarationRims Rims
public static Rims Rims
{
get { return Instance()._rims ?? (Instance()._rims = new DeclarationRims()); }
get { return Instance()._rims ?? (Instance()._rims = new Rims()); }
}
public static DeclarationSegments Segments
public static Segments Segments
{
get { return Instance()._segments ?? (Instance()._segments = new DeclarationSegments()); }
get { return Instance()._segments ?? (Instance()._segments = new Segments()); }
}
public static DeclarationPT1 PT1
public static PT1 PT1
{
get { return Instance()._pt1 ?? (Instance()._pt1 = new DeclarationPT1()); }
get { return Instance()._pt1 ?? (Instance()._pt1 = new PT1()); }
}
public static ElectricSystem ElectricSystem
......@@ -44,24 +38,24 @@ namespace TUGraz.VectoCore.Models.Declaration
get { return Instance()._electricSystem ?? (Instance()._electricSystem = new ElectricSystem()); }
}
public static DeclarationFan Fan
public static Fan Fan
{
get { return Instance()._fan ?? (Instance()._fan = new DeclarationFan()); }
get { return Instance()._fan ?? (Instance()._fan = new Fan()); }
}
public static DeclarationHVAC HVAC
public static HVAC HVAC
{
get { return Instance()._hvac ?? (Instance()._hvac = new DeclarationHVAC()); }
get { return Instance()._hvac ?? (Instance()._hvac = new HVAC()); }
}
public static DeclarationPneumaticSystem PneumaticSystem
public static PneumaticSystem PneumaticSystem
{
get { return Instance()._pneumaticSystem ?? (Instance()._pneumaticSystem = new DeclarationPneumaticSystem()); }
get { return Instance()._pneumaticSystem ?? (Instance()._pneumaticSystem = new PneumaticSystem()); }
}
public static DeclarationSteeringPump SteeringPump
public static SteeringPump SteeringPump
{
get { return Instance()._steeringPump ?? (Instance()._steeringPump = new DeclarationSteeringPump()); }
get { return Instance()._steeringPump ?? (Instance()._steeringPump = new SteeringPump()); }
}
private static DeclarationData Instance()
......@@ -69,128 +63,4 @@ namespace TUGraz.VectoCore.Models.Declaration
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 readonly Dictionary<Tuple<MissionType, string>, Watt> _data =
new Dictionary<Tuple<MissionType, string>, Watt>();
public override Watt Lookup(MissionType mission, string hdvClass)
{
return _data[Tuple.Create(mission, hdvClass)];
}
protected override string ResourceId
{
get { return "TUGraz.VectoCore.Resources.Declaration.VAUX.PS-Table.csv"; }
}
protected override void ParseData(DataTable table)
{
_data.Clear();
NormalizeTable(table);
foreach (DataRow row in table.Rows) {
var hdvClass = row.Field<string>("hdvclass/power");
foreach (MissionType mission in Enum.GetValues(typeof(MissionType))) {
_data[Tuple.Create(mission, hdvClass)] = row.ParseDouble(mission.ToString().ToLower()).SI<Watt>();
}
}
}
}
public class DeclarationHVAC : LookupData<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)
{
return _data[Tuple.Create(mission, hdvClass)];
}
protected override string ResourceId
{
get { return "TUGraz.VectoCore.Resources.Declaration.VAUX.HVAC-Table.csv"; }
}
protected override void ParseData(DataTable table)
{
_data.Clear();
NormalizeTable(table);
foreach (DataRow row in table.Rows) {
var hdvClass = row.Field<string>("hdvclass/power");
foreach (MissionType mission in Enum.GetValues(typeof(MissionType))) {
_data[Tuple.Create(mission, hdvClass)] = row.ParseDouble(mission.ToString().ToLower()).SI<Watt>();
}
}
}
}
public class DeclarationFan : LookupData<MissionType, string, Watt>
{
private readonly Dictionary<Tuple<MissionType, string>, Watt> _data =
new Dictionary<Tuple<MissionType, string>, Watt>();
private const string DefaultTechnology = "Crankshaft mounted - Electronically controlled visco clutch (Default)";
protected override string ResourceId
{
get { return "TUGraz.VectoCore.Resources.Declaration.VAUX.Fan-Tech.csv"; }
}
protected override void ParseData(DataTable table)
{
NormalizeTable(table);
_data.Clear();
foreach (DataRow row in table.Rows) {
foreach (MissionType mission in Enum.GetValues(typeof(MissionType))) {
_data[Tuple.Create(mission, row.Field<string>("Technology"))] =
row.ParseDouble(mission.ToString().ToLower()).SI<Watt>();
}
}
}
public override Watt Lookup(MissionType mission, string technology)
{
if (string.IsNullOrWhiteSpace(technology.Trim())) {
technology = DefaultTechnology;
}
return _data[Tuple.Create(mission, technology)];
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Data;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public class Fan : LookupData<MissionType, string, Watt>
{
private readonly Dictionary<Tuple<MissionType, string>, Watt> _data =
new Dictionary<Tuple<MissionType, string>, Watt>();
private const string DefaultTechnology = "Crankshaft mounted - Electronically controlled visco clutch (Default)";
protected override string ResourceId
{
get { return "TUGraz.VectoCore.Resources.Declaration.VAUX.Fan-Tech.csv"; }
}
protected override void ParseData(DataTable table)
{
NormalizeTable(table);
_data.Clear();
foreach (DataRow row in table.Rows) {
foreach (MissionType mission in Enum.GetValues(typeof(MissionType))) {
_data[Tuple.Create(mission, row.Field<string>("Technology"))] =
row.ParseDouble(mission.ToString().ToLower()).SI<Watt>();
}
}
}
public override Watt Lookup(MissionType mission, string technology)
{
if (string.IsNullOrWhiteSpace(technology.Trim())) {
technology = DefaultTechnology;
}
return _data[Tuple.Create(mission, technology)];
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Data;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public class HVAC : LookupData<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)
{
return _data[Tuple.Create(mission, hdvClass)];
}
protected override string ResourceId
{
get { return "TUGraz.VectoCore.Resources.Declaration.VAUX.HVAC-Table.csv"; }
}
protected override void ParseData(DataTable table)
{
_data.Clear();
NormalizeTable(table);
foreach (DataRow row in table.Rows) {
var hdvClass = row.Field<string>("hdvclass/power");
foreach (MissionType mission in Enum.GetValues(typeof(MissionType))) {
_data[Tuple.Create(mission, hdvClass)] = row.ParseDouble(mission.ToString().ToLower()).SI<Watt>();
}
}
}
}
}
\ No newline at end of file
......@@ -43,7 +43,7 @@ namespace TUGraz.VectoCore.Models.Declaration
public abstract class LookupData<TKey, TValue> : LookupData
{
protected Dictionary<TKey, TValue> Data;
protected Dictionary<TKey, TValue> Data = new Dictionary<TKey, TValue>();
public virtual TValue Lookup(TKey key)
{
......
......@@ -6,7 +6,7 @@ using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public class DeclarationPT1 : LookupData<PerSecond, Second>
public class PT1 : LookupData<PerSecond, Second>
{
private List<KeyValuePair<PerSecond, Second>> _entries;
......
using System;
using System.Collections.Generic;
using System.Data;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public class PneumaticSystem : LookupData<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)
{
return _data[Tuple.Create(mission, hdvClass)];
}
protected override string ResourceId
{
get { return "TUGraz.VectoCore.Resources.Declaration.VAUX.PS-Table.csv"; }
}
protected override void ParseData(DataTable table)
{
_data.Clear();
NormalizeTable(table);
foreach (DataRow row in table.Rows) {
var hdvClass = row.Field<string>("hdvclass/power");
foreach (MissionType mission in Enum.GetValues(typeof(MissionType))) {
_data[Tuple.Create(mission, hdvClass)] = row.ParseDouble(mission.ToString().ToLower()).SI<Watt>();
}
}
}
}
}
\ No newline at end of file
......@@ -4,9 +4,9 @@ using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public class DeclarationRims : LookupData<string, DeclarationRims.RimsEntry>
public class Rims : LookupData<string, Rims.RimsEntry>
{
internal DeclarationRims()
internal Rims()
{
var csvFile = ReadCsvFile(ResourceId);
ParseData(csvFile);
......
......@@ -6,7 +6,7 @@ using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public class DeclarationSegments : LookupData<VehicleCategory, AxleConfiguration, Kilogram, Kilogram, Segment>
public class Segments : LookupData<VehicleCategory, AxleConfiguration, Kilogram, Kilogram, Segment>
{
private const string ResourceNamespace = "TUGraz.VectoCore.Resources.Declaration.";
......
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public class SteeringPump : LookupData<MissionType, string, string, Watt>
{
private readonly SteeringPumpTechnologies _technologies = new SteeringPumpTechnologies();
private readonly Dictionary<Tuple<MissionType, string>, Watt[]> _data =
new Dictionary<Tuple<MissionType, string>, Watt[]>();
public override Watt Lookup(MissionType mission, string hdvClass, string technology)
{
var shares = _data[Tuple.Create(mission, hdvClass)];
var sum = 0.SI<Watt>();
var factors = _technologies.Lookup(technology);
for (var i = 0; i < 4; i++) {
sum += shares[i] * factors[i];
}
return sum;
}
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))) {
var values = row.Field<string>(mission.ToString().ToLower()).Split('/').ToDouble();
values = values.Concat(Enumerable.Repeat(0.0, 3));
_data[Tuple.Create(mission, hdvClass)] = values.Take(4).SI<Watt>().ToArray();
}
}
}
public class SteeringPumpTechnologies : LookupData<string, double[]>
{
protected override string ResourceId
{
get { return "TUGraz.VectoCore.Resources.Declaration.VAUX.SP-Tech.csv"; }
}
protected override void ParseData(DataTable table)
{
Data.Clear();
foreach (DataRow row in table.Rows) {
var tech = row.Field<string>("Scaling Factors");
var factors = new[] { row.ParseDouble("U"), row.ParseDouble("F"), row.ParseDouble("B"), row.ParseDouble("S") };
Data[tech] = factors;
}
}
public override double[] Lookup(string tech)
{
return Data[tech];
}
}
}
}
\ No newline at end of file
......@@ -5,7 +5,7 @@ using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public class DeclarationWheels : LookupData<string, DeclarationWheels.WheelsEntry>
public class Wheels : LookupData<string, Wheels.WheelsEntry>
{
protected override string ResourceId
{
......
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace TUGraz.VectoCore.Utils
{
......@@ -100,7 +103,7 @@ namespace TUGraz.VectoCore.Utils
/// <returns></returns>
public static SI SI(this double self)
{
return (SI)self;
return (SI) self;
}
/// <summary>
......@@ -113,5 +116,10 @@ namespace TUGraz.VectoCore.Utils
{
return SIBase<T>.Create(self);
}
public static IEnumerable<T> SI<T>(this IEnumerable<double> self) where T : SIBase<T>
{
return self.Select(x => x.SI<T>());
}
}
}
\ No newline at end of file
......@@ -122,18 +122,22 @@
<Compile Include="Models\Connector\Ports\Impl\Response.cs" />
<Compile Include="Models\Connector\Ports\IFvPort.cs" />
<Compile Include="Models\Connector\Ports\ITnPort.cs" />
<Compile Include="Models\Declaration\Fan.cs" />
<Compile Include="Models\Declaration\HVAC.cs" />
<Compile Include="Models\Declaration\PneumaticSystem.cs" />
<Compile Include="Models\Declaration\SteeringPump.cs" />
<Compile Include="Models\SimulationComponent\Data\AccelerationCurve.cs" />
<Compile Include="Models\Declaration\DeclarationData.cs" />
<Compile Include="Models\Declaration\DeclarationPT1.cs" />
<Compile Include="Models\Declaration\PT1.cs" />
<Compile Include="Models\Declaration\ElectricSystem.cs" />
<Compile Include="Models\Declaration\LookupData.cs" />
<Compile Include="Models\Declaration\Declaration.cs" />
<Compile Include="Models\Declaration\DeclarationWheels.cs" />
<Compile Include="Models\Declaration\Rims.cs" />
<Compile Include="Models\Declaration\Wheels.cs" />
<Compile Include="Models\Declaration\Mission.cs" />
<Compile Include="Models\Declaration\MissionType.cs" />
<Compile Include="Utils\RessourceHelper.cs" />
<Compile Include="Models\Declaration\Segment.cs" />
<Compile Include="Models\Declaration\DeclarationSegments.cs" />
<Compile Include="Models\Declaration\Segments.cs" />
<Compile Include="Models\SimulationComponent\Data\AuxiliaryCycleDataAdapter.cs" />
<Compile Include="Models\Declaration\Axle.cs" />
<Compile Include="Models\Declaration\AxleConfiguration.cs" />
......
......@@ -336,8 +336,6 @@ namespace TUGraz.VectoCore.Tests.Models
}
}
}
Assert.Inconclusive();
}
[TestMethod]
......@@ -443,7 +441,7 @@ namespace TUGraz.VectoCore.Tests.Models
// // todo axleGear
// var wheels = new DeclarationWheels(container, 0.SI<Meter>());
// var wheels = new Wheels(container, 0.SI<Meter>());
// var missionVehicleData = new VehicleData(vehicleData, loading, mission.AxleWeightDistribution);
// var vehicle = new Vehicle(container, missionVehicleData);
......
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