Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

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

Merge pull request #463 in VECTO/vecto-sim from...

Merge pull request #463 in VECTO/vecto-sim from ~EMQUARIMA/vecto-sim:bugfix/VECTO-527-aux-steering-pump-electric to develop

* commit '680ed3a0':
  refactor lookup data to return value types (structs) so that the caller gets a copy
  adding testcase to show modification of SteeringPump AuxData
parents 25de9911 680ed3a0
No related branches found
No related tags found
No related merge requests found
Showing
with 510 additions and 484 deletions
......@@ -1312,7 +1312,7 @@ lbDlog:
True)
Catch
End Try
If s0 Is Nothing Then
If Not s0.Found Then
HDVclass = "-"
Else
HDVclass = s0.VehicleClass.GetClassNumber()
......@@ -1327,7 +1327,7 @@ lbDlog:
End If
PicVehicle.Image = ConvPicPath(If(s0 Is Nothing, -1, HDVclass.ToInt()), False) _
PicVehicle.Image = ConvPicPath(If(Not s0.Found, -1, HDVclass.ToInt()), False) _
'Image.FromFile(cDeclaration.ConvPicPath(HDVclass, False))
TbHVCclass.Text = String.Format("HDV Class {0}", HDVclass)
......
......@@ -132,13 +132,13 @@ Public Class VehicleForm
Catch
' no segment found - ignore
End Try
If Not s0 Is Nothing Then
If s0.Found Then
_hdVclass = s0.VehicleClass.GetClassNumber()
End If
TbHDVclass.Text = _hdVclass
PicVehicle.Image = ConvPicPath(If(s0 Is Nothing, -1, _hdVclass.ToInt()), False)
PicVehicle.Image = ConvPicPath(If(Not s0.Found, -1, _hdVclass.ToInt()), False)
End Sub
......@@ -160,7 +160,7 @@ Public Class VehicleForm
Catch
' no segment found - ignore
End Try
If Not s0 Is Nothing Then
If s0.found Then
_hdVclass = s0.VehicleClass.GetClassNumber()
Dim axleCount As Integer = s0.Missions(0).AxleWeightDistribution.Count()
Dim i0 As Integer = LvRRC.Items.Count
......
......@@ -271,7 +271,8 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
}
private static void CreateATGearData(IGearboxDeclarationInputData gearbox, uint i, GearData gearData,
ShiftPolygon tcShiftPolygon, double gearDifferenceRatio, Dictionary<uint, GearData> gears, VehicleCategory vehicleCategory)
ShiftPolygon tcShiftPolygon, double gearDifferenceRatio, Dictionary<uint, GearData> gears,
VehicleCategory vehicleCategory)
{
if (gearbox.Type == GearboxType.ATPowerSplit && i == 0) {
// powersplit transmission: torque converter already contains ratio and losses
......@@ -335,7 +336,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
mission = mission.GetNonEMSMissionType();
switch (auxType) {
case AuxiliaryType.Fan:
aux.PowerDemand = DeclarationData.Fan.Lookup(mission, auxData.Technology.FirstOrDefault());
aux.PowerDemand = DeclarationData.Fan.Lookup(mission, auxData.Technology.FirstOrDefault()).PowerDemand;
aux.ID = Constants.Auxiliaries.IDs.Fan;
break;
case AuxiliaryType.SteeringPump:
......@@ -344,15 +345,15 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
break;
case AuxiliaryType.HVAC:
aux.PowerDemand = DeclarationData.HeatingVentilationAirConditioning.Lookup(mission,
auxData.Technology.FirstOrDefault(), hvdClass);
auxData.Technology.FirstOrDefault(), hvdClass).PowerDemand;
aux.ID = Constants.Auxiliaries.IDs.HeatingVentilationAirCondition;
break;
case AuxiliaryType.PneumaticSystem:
aux.PowerDemand = DeclarationData.PneumaticSystem.Lookup(mission, auxData.Technology.FirstOrDefault());
aux.PowerDemand = DeclarationData.PneumaticSystem.Lookup(mission, auxData.Technology.FirstOrDefault()).PowerDemand;
aux.ID = Constants.Auxiliaries.IDs.PneumaticSystem;
break;
case AuxiliaryType.ElectricSystem:
aux.PowerDemand = DeclarationData.ElectricSystem.Lookup(mission, auxData.Technology.FirstOrDefault());
aux.PowerDemand = DeclarationData.ElectricSystem.Lookup(mission, auxData.Technology.FirstOrDefault()).PowerDemand;
aux.ID = Constants.Auxiliaries.IDs.ElectricSystem;
break;
default:
......
......@@ -32,6 +32,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
......@@ -90,9 +91,14 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl
_segment = GetVehicleClassification(InputDataProvider.VehicleInputData.VehicleCategory,
InputDataProvider.VehicleInputData.AxleConfiguration,
InputDataProvider.VehicleInputData.GrossVehicleMassRating, InputDataProvider.VehicleInputData.CurbMassChassis);
if (!_segment.Found) {
throw new VectoException(
"no segment found for vehicle configruation: vehicle category: {0}, axle configuration: {1}, GVMR: {2}",
InputDataProvider.VehicleInputData.VehicleCategory, InputDataProvider.VehicleInputData.AxleConfiguration,
InputDataProvider.VehicleInputData.GrossVehicleMassRating);
}
_driverdata = _dao.CreateDriverData(InputDataProvider.DriverInputData);
_driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(_segment.AccelerationFile);
var tempVehicle = _dao.CreateVehicleData(InputDataProvider.VehicleInputData, _segment.Missions.First(),
_segment.Missions.First().Loadings.First().Value, _segment.MunicipalBodyWeight);
_airdragData = _dao.CreateAirdragData(InputDataProvider.AirdragInputData, _segment.Missions.First(), _segment);
......
using TUGraz.VectoCommon.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public struct AuxDemandEntry
{
public Watt PowerDemand;
}
}
\ No newline at end of file
......@@ -37,7 +37,7 @@ using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public sealed class ElectricSystem : LookupData<MissionType, string, Watt>, IDeclarationAuxiliaryTable
public sealed class ElectricSystem : LookupData<MissionType, string, AuxDemandEntry>, IDeclarationAuxiliaryTable
{
private readonly Alternator _alternator = new Alternator();
......@@ -58,19 +58,19 @@ namespace TUGraz.VectoCore.Models.Declaration
foreach (DataColumn col in table.Columns) {
if (col.Caption != "technology") {
Data[Tuple.Create(col.Caption.ParseEnum<MissionType>(), name)] =
row.ParseDouble(col).SI<Watt>();
new AuxDemandEntry() { PowerDemand = row.ParseDouble(col).SI<Watt>() };
}
}
}
}
public override Watt Lookup(MissionType missionType, string technology = null)
public override AuxDemandEntry Lookup(MissionType missionType, string technology = null)
{
if (string.IsNullOrWhiteSpace(technology)) {
technology = "Standard technology";
}
var value = base.Lookup(missionType, technology);
return value / _alternator.Lookup(missionType);
return new AuxDemandEntry() { PowerDemand = value.PowerDemand / _alternator.Lookup(missionType) };
}
internal sealed class Alternator : LookupData<MissionType, string, double>
......
......@@ -37,7 +37,7 @@ using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public sealed class Fan : LookupData<MissionType, string, Watt>, IDeclarationAuxiliaryTable
public sealed class Fan : LookupData<MissionType, string, AuxDemandEntry>, IDeclarationAuxiliaryTable
{
protected override string ResourceId
{
......@@ -56,13 +56,13 @@ namespace TUGraz.VectoCore.Models.Declaration
foreach (DataColumn col in table.Columns) {
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)] = new AuxDemandEntry(){PowerDemand = row.ParseDouble(col).SI<Watt>()};
}
}
}
}
public override Watt Lookup(MissionType mission, string technology = null)
public override AuxDemandEntry Lookup(MissionType mission, string technology = null)
{
if (string.IsNullOrWhiteSpace(technology)) {
technology = "Crankshaft mounted - Electronically controlled visco clutch";
......
......@@ -79,9 +79,9 @@ namespace TUGraz.VectoCore.Models.Declaration
.ToDictionary(e => e.FuelType);
}
public class Entry
public struct Entry
{
public Entry(FuelType type, KilogramPerCubicMeter density, double weight, JoulePerKilogramm heatingValue)
public Entry(FuelType type, KilogramPerCubicMeter density, double weight, JoulePerKilogramm heatingValue) : this()
{
FuelType = type;
FuelDensity = density;
......
......@@ -38,7 +38,7 @@ using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public sealed class HeatingVentilationAirConditioning : LookupData<MissionType, string, VehicleClass, Watt>,
public sealed class HeatingVentilationAirConditioning : LookupData<MissionType, string, VehicleClass, AuxDemandEntry>,
IDeclarationAuxiliaryTable
{
private List<string> Technologies;
......@@ -63,7 +63,9 @@ namespace TUGraz.VectoCore.Models.Declaration
foreach (DataColumn col in table.Columns) {
var value = row.ParseDoubleOrGetDefault(col.Caption, double.NaN);
if (col.Caption != "hdvclass" && col.Caption != "technology" && !double.IsNaN(value)) {
Data[Tuple.Create(col.Caption.ParseEnum<MissionType>(), technology, hdvClass)] = value.SI<Watt>();
Data[Tuple.Create(col.Caption.ParseEnum<MissionType>(), technology, hdvClass)] = new AuxDemandEntry() {
PowerDemand = value.SI<Watt>()
};
}
}
}
......
......@@ -67,7 +67,7 @@ namespace TUGraz.VectoCore.Models.Declaration
}
}
public abstract class LookupData<TKey, TValue> : LookupData
public abstract class LookupData<TKey, TValue> : LookupData where TValue : struct
{
protected Dictionary<TKey, TValue> Data = new Dictionary<TKey, TValue>();
......@@ -81,7 +81,7 @@ namespace TUGraz.VectoCore.Models.Declaration
}
}
public abstract class LookupData<TKey1, TKey2, TValue> : LookupData
public abstract class LookupData<TKey1, TKey2, TValue> : LookupData where TValue : struct
{
protected readonly Dictionary<Tuple<TKey1, TKey2>, TValue> Data = new Dictionary<Tuple<TKey1, TKey2>, TValue>();
......@@ -95,7 +95,7 @@ namespace TUGraz.VectoCore.Models.Declaration
}
}
public abstract class LookupData<TKey1, TKey2, TKey3, TValue> : LookupData
public abstract class LookupData<TKey1, TKey2, TKey3, TValue> : LookupData where TValue : struct
{
protected readonly Dictionary<Tuple<TKey1, TKey2, TKey3>, TValue> Data =
new Dictionary<Tuple<TKey1, TKey2, TKey3>, TValue>();
......@@ -112,7 +112,7 @@ namespace TUGraz.VectoCore.Models.Declaration
//public abstract TValue Lookup(TKey1 key1, TKey2 key2, TKey3 key3);
}
public abstract class LookupData<TKey1, TKey2, TKey3, TKey4, TValue> : LookupData
public abstract class LookupData<TKey1, TKey2, TKey3, TKey4, TValue> : LookupData where TValue : struct
{
public abstract TValue Lookup(TKey1 key1, TKey2 key2, TKey3 key3, TKey4 key4);
}
......
......@@ -120,7 +120,7 @@ namespace TUGraz.VectoCore.Models.Declaration
public const string EngineSpeed = "engine speed";
}
public class PT1Result
public struct PT1Result
{
public Second Value;
public bool Extrapolated;
......
......@@ -36,7 +36,7 @@ using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public sealed class PTOTransmission : LookupData<string, Watt>, IDeclarationAuxiliaryTable
public sealed class PTOTransmission : LookupData<string, AuxDemandEntry>, IDeclarationAuxiliaryTable
{
public const string NoPTO = "None";
......@@ -54,7 +54,7 @@ namespace TUGraz.VectoCore.Models.Declaration
{
Data = table.Rows.Cast<DataRow>().ToDictionary(
r => r.Field<string>("technology"),
r => r.ParseDouble("powerloss").SI<Watt>());
r => new AuxDemandEntry { PowerDemand = r.ParseDouble("powerloss").SI<Watt>() });
}
public string[] GetTechnologies()
......
......@@ -90,7 +90,7 @@ namespace TUGraz.VectoCore.Models.Declaration
});
}
public sealed class PayloadEntry
public struct PayloadEntry
{
public Kilogram Payload10Percent;
public Kilogram Payload50Percent;
......
......@@ -37,7 +37,7 @@ using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public sealed class PneumaticSystem : LookupData<MissionType, string, Watt>, IDeclarationAuxiliaryTable
public sealed class PneumaticSystem : LookupData<MissionType, string, AuxDemandEntry>, IDeclarationAuxiliaryTable
{
protected override string ResourceId
{
......@@ -55,7 +55,9 @@ namespace TUGraz.VectoCore.Models.Declaration
var technology = row.Field<string>("technology");
foreach (DataColumn col in table.Columns) {
if (col.Caption != "technology") {
Data[Tuple.Create(col.Caption.ParseEnum<MissionType>(), technology)] = row.ParseDouble(col.Caption).SI<Watt>();
Data[Tuple.Create(col.Caption.ParseEnum<MissionType>(), technology)] = new AuxDemandEntry() {
PowerDemand = row.ParseDouble(col.Caption).SI<Watt>()
};
}
}
}
......
......@@ -35,8 +35,10 @@ using TUGraz.VectoCommon.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public class Segment
public struct Segment
{
public bool Found;
public VehicleClass VehicleClass { get; internal set; }
public VehicleCategory VehicleCategory { get; set; }
......
......@@ -78,8 +78,12 @@ namespace TUGraz.VectoCore.Models.Declaration
}
var row = GetSegmentDataRow(vehicleCategory, axleConfiguration, grossVehicleMassRating, considerInvalid);
if (row == null) {
return new Segment() { Found = false };
}
var segment = new Segment {
Found = true,
GrossVehicleWeightMin = row.ParseDouble("gvw_min").SI().Ton.Cast<Kilogram>(),
GrossVehicleWeightMax = row.ParseDouble("gvw_max").SI().Ton.Cast<Kilogram>(),
VehicleCategory = vehicleCategory,
......
......@@ -38,7 +38,7 @@ using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration
{
public sealed class StandardBody
public struct StandardBody
{
public readonly Kilogram CurbWeight;
public readonly Kilogram GrossVehicleWeight;
......@@ -53,9 +53,9 @@ namespace TUGraz.VectoCore.Models.Declaration
}
public StandardBody(string name, Kilogram curbWeight, Kilogram grossVehicleWeight, SquareMeter[] deltaCrossWindArea,
Wheels.Entry wheels, int axleCount, CubicMeter volume) :
Wheels.Entry? wheels, int axleCount, CubicMeter volume) :
this(name, curbWeight, grossVehicleWeight, deltaCrossWindArea,
wheels == null ? new List<Wheels.Entry>() : Enumerable.Repeat(wheels, axleCount).ToList(), volume) {}
!wheels.HasValue ? new List<Wheels.Entry>() : Enumerable.Repeat(wheels.Value, axleCount).ToList(), volume) {}
private StandardBody(string name, Kilogram curbWeight, Kilogram grossVehicleWeight, SquareMeter[] deltaCrossWindArea,
List<Wheels.Entry> wheels, CubicMeter volume)
......@@ -123,8 +123,8 @@ namespace TUGraz.VectoCore.Models.Declaration
deltaCdxA,
!string.IsNullOrWhiteSpace(k.Field<string>("wheels"))
? DeclarationData.Wheels.Lookup(k.Field<string>("wheels"))
: null,
Int32.Parse(k.Field<string>("axlecount")),
: (Wheels.Entry?)null,
int.Parse(k.Field<string>("axlecount")),
k.ParseDouble("cargovolume").SI<CubicMeter>());
})
.ToDictionary(kv => kv.Name);
......
......@@ -178,7 +178,7 @@ namespace TUGraz.VectoCore.Models.Declaration
}
}
private class SteeringPumpValues<T>
private struct SteeringPumpValues<T>
{
public T UnloadedFriction;
public T Banking;
......
......@@ -71,7 +71,7 @@ namespace TUGraz.VectoCore.Models.Declaration
}
}
private class Entry
private struct Entry
{
public double Rural;
public double Urban;
......
......@@ -68,7 +68,7 @@ namespace TUGraz.VectoCore.Models.Declaration
_dimensions = table.Rows.Cast<DataRow>().Select(row => row.Field<string>(0)).ToArray();
}
public class Entry
public struct Entry
{
public string WheelType;
public KilogramSquareMeter Inertia;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment