From 548d84f7d66f0646f2499c980614f81fbab4dccf Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Thu, 21 Nov 2019 11:23:59 +0100 Subject: [PATCH] segmentation for primary buses works --- VECTO/GUI/VectoJobForm.vb | 2 +- VECTO/GUI/VectoVTPJobForm.vb | 2 +- VECTO/GUI/VehicleForm.vb | 6 +- VECTO/Input Files/Engine.vb | 6 +- VECTO/Input Files/Gearbox.vb | 2 +- VECTO/Input Files/VectoJob.vb | 2 +- VECTO/Input Files/Vehicle.vb | 9 +- .../AveragePneumaticLoadDemandTests.vb | 32 +- .../UnitTests/SSMTOOLTests.vb | 4 +- .../InputData/DeclarationInputData.cs | 4 +- .../VectoCore/Configuration/Constants.cs | 21 + .../FileIO/JSON/JSONComponentInputData.cs | 9 +- .../InputData/FileIO/JSON/JSONVehicleData.cs | 19 +- .../XMLDeclarationVehicleDataProvider.cs | 5 +- .../XMLEngineeringVehicleDataProvider.cs | 5 +- .../DeclarationDataAdapterPrimaryBus.cs | 33 + ...pter.cs => DeclarationDataAdapterTruck.cs} | 1330 ++++++++--------- .../EngineeringDataAdapter.cs | 6 +- .../IDeclarationDataAdapter.cs | 27 + .../AbstractDeclarationVectoRunDataFactory.cs | 146 ++ .../DeclarationModeBusVectoRunDataFactory.cs | 104 ++ ...DeclarationModeTruckVectoRunDataFactory.cs | 166 ++ .../DeclarationModeVectoRunDataFactory.cs | 260 ---- .../DeclarationVTPModeVectoRunDataFactory.cs | 6 +- .../Models/Declaration/BusSegments.cs | 129 +- .../Models/Declaration/DeclarationData.cs | 3 +- .../Models/Declaration/LookupData.cs | 4 + .../VectoCore/Models/Declaration/Mission.cs | 58 +- .../Models/Declaration/MissionType.cs | 26 + .../VectoCore/Models/Declaration/Segment.cs | 4 +- .../Models/Declaration/TruckSegments.cs | 141 +- .../Models/Declaration/VehicleClass.cs | 11 +- .../Simulation/Impl/SimulatorFactory.cs | 5 +- .../Declaration/HeavyBusSegmentationTable.csv | 42 +- .../Resources/Declaration/VACC/Bus.vacc | 7 + VectoCore/VectoCore/VectoCore.csproj | 13 +- .../FileIO/SimulationDataReaderTest.cs | 2 +- .../DeclarationAdapterTestHelper.cs | 2 +- .../Models/Declaration/DeclarationDataTest.cs | 56 +- .../DeclarationSegmentHeavyBusesTest.cs | 44 +- .../Models/Declaration/ShiftPolygonTest.cs | 10 +- .../Simulation/PowerTrainBuilderTest.cs | 2 +- .../Models/SimulationComponent/VehicleTest.cs | 344 ++--- .../SimulationComponentData/ValidationTest.cs | 2 +- .../VectoCoreTest/Models/WHRMapReaderTest.cs | 22 +- .../Utils/MockDeclarationVehicleInputData.cs | 7 +- .../Utils/MockSimulationDataFactory.cs | 4 +- VectoCore/VectoCoreTest/VectoCoreTest.csproj | 1 + .../XML/XMLDeclarationInputTest.cs | 4 +- 49 files changed, 1836 insertions(+), 1313 deletions(-) create mode 100644 VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs rename VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/{DeclarationDataAdapter.cs => DeclarationDataAdapterTruck.cs} (92%) create mode 100644 VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/IDeclarationDataAdapter.cs create mode 100644 VectoCore/VectoCore/InputData/Reader/Impl/AbstractDeclarationVectoRunDataFactory.cs create mode 100644 VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeBusVectoRunDataFactory.cs create mode 100644 VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeTruckVectoRunDataFactory.cs delete mode 100644 VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs create mode 100644 VectoCore/VectoCore/Resources/Declaration/VACC/Bus.vacc diff --git a/VECTO/GUI/VectoJobForm.vb b/VECTO/GUI/VectoJobForm.vb index 59eda5c1b7..cff10fe937 100644 --- a/VECTO/GUI/VectoJobForm.vb +++ b/VECTO/GUI/VectoJobForm.vb @@ -1324,7 +1324,7 @@ lbDlog: Dim s0 As Segment = Nothing Try - s0 = DeclarationData.Segments.Lookup(vehicle.VehicleCategory, vehicle.AxleConfiguration, maxMass, 0.SI(Of Kilogram), + s0 = DeclarationData.TruckSegments.Lookup(vehicle.VehicleCategory, vehicle.AxleConfiguration, maxMass, 0.SI(Of Kilogram), False) Catch End Try diff --git a/VECTO/GUI/VectoVTPJobForm.vb b/VECTO/GUI/VectoVTPJobForm.vb index b5194ccf68..ff72e2e8e6 100644 --- a/VECTO/GUI/VectoVTPJobForm.vb +++ b/VECTO/GUI/VectoVTPJobForm.vb @@ -674,7 +674,7 @@ Public Class VectoVTPJobForm Dim s0 As Segment = Nothing Try - s0 = DeclarationData.Segments.Lookup(vehicle.VehicleCategory, vehicle.AxleConfiguration, maxMass, + s0 = DeclarationData.TruckSegments.Lookup(vehicle.VehicleCategory, vehicle.AxleConfiguration, maxMass, 0.SI (Of Kilogram), False) Catch diff --git a/VECTO/GUI/VehicleForm.vb b/VECTO/GUI/VehicleForm.vb index 5196c87017..22bdca211f 100644 --- a/VECTO/GUI/VehicleForm.vb +++ b/VECTO/GUI/VehicleForm.vb @@ -83,7 +83,7 @@ Public Class VehicleForm CbAxleConfig.ValueMember = "Value" CbAxleConfig.DisplayMember = "Label" If (cfg.DeclMode) Then - CbAxleConfig.DataSource = DeclarationData.Segments.GetAxleConfigurations() _ + CbAxleConfig.DataSource = DeclarationData.TruckSegments.GetAxleConfigurations() _ .Cast(Of AxleConfiguration) _ .Select(Function(category) New With {Key .Value = category, .Label = category.GetName()}).ToList() else @@ -150,7 +150,7 @@ Public Class VehicleForm _hdVclass = "-" Dim s0 As Segment = Nothing Try - s0 = DeclarationData.Segments.Lookup(vehC, axlC, maxMass, 0.SI(Of Kilogram), False) + s0 = DeclarationData.TruckSegments.Lookup(vehC, axlC, maxMass, 0.SI(Of Kilogram), False) Catch ' no segment found - ignore @@ -179,7 +179,7 @@ Public Class VehicleForm Dim s0 As Segment = Nothing Try - s0 = DeclarationData.Segments.Lookup(vehC, axlC, maxMass, 0.SI(Of Kilogram), False) + s0 = DeclarationData.TruckSegments.Lookup(vehC, axlC, maxMass, 0.SI(Of Kilogram), False) Catch ' no segment found - ignore End Try diff --git a/VECTO/Input Files/Engine.vb b/VECTO/Input Files/Engine.vb index d6e41120f9..57386b510d 100644 --- a/VECTO/Input Files/Engine.vb +++ b/VECTO/Input Files/Engine.vb @@ -14,6 +14,7 @@ Imports System.IO Imports System.Linq Imports Newtonsoft.Json.Linq Imports TUGraz.VECTO.Input_Files +Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCommon.Exceptions Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models @@ -210,7 +211,7 @@ Public Class Engine Try If mode = ExecutionMode.Declaration Then - Dim doa As DeclarationDataAdapter = New DeclarationDataAdapter() + Dim doa As DeclarationDataAdapterTruck = New DeclarationDataAdapterTruck() Dim dummyGearboxData As IGearboxDeclarationInputData = New Gearbox() With { .Type = GearboxType.AMT, .MaxTorque = New List(Of String), @@ -612,7 +613,8 @@ Public Class DummyVehicle Public ReadOnly Property NuberOfPassengersUpperDeck As Integer Implements IVehicleDeclarationInputData.NuberOfPassengersUpperDeck Public ReadOnly Property NumberOfPassengersLowerDeck As Integer Implements IVehicleDeclarationInputData.NumberOfPassengersLowerDeck Public ReadOnly Property VehicleCode As VehicleCode Implements IVehicleDeclarationInputData.VehicleCode - Public ReadOnly Property LowEntry As Boolean Implements IVehicleDeclarationInputData.LowEntry + Public ReadOnly Property FloorType As FloorType Implements IVehicleDeclarationInputData.FloorType + Public ReadOnly Property Articulated As Boolean Implements IVehicleDeclarationInputData.Articulated Public ReadOnly Property IVehicleDeclarationInputData_Height As Meter Implements IVehicleDeclarationInputData.Height Public ReadOnly Property CurbMassExtra As Kilogram Implements IVehicleEngineeringInputData.CurbMassExtra Public ReadOnly Property Loading As Kilogram Implements IVehicleEngineeringInputData.Loading diff --git a/VECTO/Input Files/Gearbox.vb b/VECTO/Input Files/Gearbox.vb index a25a517dda..7e12f34420 100644 --- a/VECTO/Input Files/Gearbox.vb +++ b/VECTO/Input Files/Gearbox.vb @@ -211,7 +211,7 @@ Public Class Gearbox vehiclecategory = vehiclecategory.RigidTruck End Try If mode = ExecutionMode.Declaration Then - Dim doa As DeclarationDataAdapter = New DeclarationDataAdapter() + Dim doa As DeclarationDataAdapterTruck = New DeclarationDataAdapterTruck() Try engine = doa.CreateEngineData(inputData.JobInputData.Vehicle, inputData.JobInputData.Vehicle.Components.EngineInputData.EngineModes.First(), New Mission() With {.MissionType = MissionType.LongHaul}) diff --git a/VECTO/Input Files/VectoJob.vb b/VECTO/Input Files/VectoJob.vb index 51e8b6bde4..86c5cec019 100644 --- a/VECTO/Input Files/VectoJob.vb +++ b/VECTO/Input Files/VectoJob.vb @@ -427,7 +427,7 @@ Public Class VectoJob New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) End If - Dim dataFactory As DeclarationModeVectoRunDataFactory = New DeclarationModeVectoRunDataFactory(vectoJob, Nothing) + Dim dataFactory As DeclarationModeTruckVectoRunDataFactory = New DeclarationModeTruckVectoRunDataFactory(vectoJob, Nothing) jobData = dataFactory.NextRun().First() Else diff --git a/VECTO/Input Files/Vehicle.vb b/VECTO/Input Files/Vehicle.vb index 29e1445c90..b9f50d96d0 100644 --- a/VECTO/Input Files/Vehicle.vb +++ b/VECTO/Input Files/Vehicle.vb @@ -15,6 +15,7 @@ Imports System.ComponentModel.DataAnnotations Imports System.IO Imports System.Linq Imports TUGraz.VECTO.Input_Files +Imports TUGraz.VectoCommon.BusAuxiliaries Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils @@ -108,8 +109,8 @@ Public Class Vehicle Try If mode = ExecutionMode.Declaration Then - Dim doa As DeclarationDataAdapter = New DeclarationDataAdapter() - Dim segment As Segment = DeclarationData.Segments.Lookup(vehicle.VehicleCategory, vehicle.AxleConfiguration, + Dim doa As DeclarationDataAdapterTruck = New DeclarationDataAdapterTruck() + Dim segment As Segment = DeclarationData.TruckSegments.Lookup(vehicle.VehicleCategory, vehicle.AxleConfiguration, vehicle.GrossVehicleMassRating, vehicle.CurbMassChassis, false) vehicleData = doa.CreateVehicleData(vehicle, segment.Missions.First(), segment.Missions.First().Loadings.First().Value) @@ -406,9 +407,10 @@ Public Class Vehicle End Get End Property - Public ReadOnly Property LowEntry As Boolean Implements IVehicleDeclarationInputData.LowEntry Public ReadOnly Property IVehicleDeclarationInputData_Height As Meter Implements IVehicleDeclarationInputData.Height + Public ReadOnly Property Articulated As Boolean Implements IVehicleDeclarationInputData.Articulated + Public ReadOnly Property Height As Meter Implements IVehicleEngineeringInputData.Height Get Return VehicleHeight.SI(Of Meter)() @@ -752,6 +754,7 @@ Public Class Vehicle Public ReadOnly Property NuberOfPassengersUpperDeck As Integer Implements IVehicleDeclarationInputData.NuberOfPassengersUpperDeck Public ReadOnly Property NumberOfPassengersLowerDeck As Integer Implements IVehicleDeclarationInputData.NumberOfPassengersLowerDeck Public ReadOnly Property VehicleCode As VehicleCode Implements IVehicleDeclarationInputData.VehicleCode + Public ReadOnly Property FloorType As FloorType Implements IVehicleDeclarationInputData.FloorType Public ReadOnly Property Components As IVehicleComponentsDeclaration Implements IVehicleDeclarationInputData.Components get diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/AveragePneumaticLoadDemandTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/AveragePneumaticLoadDemandTests.vb index 7cf71eb32d..44db80d57c 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/AveragePneumaticLoadDemandTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/AveragePneumaticLoadDemandTests.vb @@ -53,8 +53,8 @@ Namespace UnitTests '_defaultInputConfig.RetarderBrake = True _defaultInputConfig.KneelingHeightMillimeters = 80.SI(Unit.SI.Milli.Meter).Cast (of Meter) _defaultInputConfig.AirSuspensionControl = ConsumerTechnology.Electrically ' "Electrically" - _defaultInputConfig.AdBlueDosing = ConsumerTechnology.Pneumatic ' "Pneumatic" - _defaultInputConfig.Doors = ConsumerTechnology.Pneumatic ' "Pneumatic" + _defaultInputConfig.AdBlueDosing = ConsumerTechnology.Pneumatically ' "Pneumatic" + _defaultInputConfig.Doors = ConsumerTechnology.Pneumatically ' "Pneumatic" _defaultInputConfig.SmartAirCompression = True '_Signals.TotalCycleTimeSeconds = 3114 @@ -68,10 +68,10 @@ Namespace UnitTests Dim psUserInputsConfig = New PneumaticUserInputsConfig() psUserInputsConfig.AirSuspensionControl = ConsumerTechnology.Mechanically ' "Mechanically" - psUserInputsConfig.Doors = ConsumerTechnology.Pneumatic '"Pneumatic" - psUserInputsConfig.AdBlueDosing = ConsumerTechnology.Pneumatic ' "Pneumatic" + psUserInputsConfig.Doors = ConsumerTechnology.Pneumatically '"Pneumatic" + psUserInputsConfig.AdBlueDosing = ConsumerTechnology.Pneumatically ' "Pneumatic" - Dim psAuxConfig = New DeclarationDataAdapter().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) + Dim psAuxConfig = New DeclarationDataAdapterTruck().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) Dim psActuationsMap = ActuationsMapReader.Read(_actuationsMapPath) Dim psCompressorMap = CompressorMapReader.ReadFile(_compressorMapPath) @@ -93,7 +93,7 @@ Namespace UnitTests initialise() - Dim psAuxConfig = New DeclarationDataAdapter().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) + Dim psAuxConfig = New DeclarationDataAdapterTruck().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) Dim psActuationsMap = ActuationsMapReader.Read(_actuationsMapPath) Dim psCompressorMap = CompressorMapReader.ReadFile(_compressorMapPath) @@ -119,7 +119,7 @@ Namespace UnitTests initialise() - Dim psAuxConfig = New DeclarationDataAdapter().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) + Dim psAuxConfig = New DeclarationDataAdapterTruck().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) Dim psActuationsMap = ActuationsMapReader.Read(_actuationsMapPath) @@ -149,7 +149,7 @@ Namespace UnitTests _defaultInputConfig.CompressorGearEfficiency = 0.8 - Dim psAuxConfig = New DeclarationDataAdapter().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) + Dim psAuxConfig = New DeclarationDataAdapterTruck().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) Dim psActuationsMap = ActuationsMapReader.Read(_actuationsMapPath) Dim psCompressorMap = CompressorMapReader.ReadFile(_compressorMapPath) @@ -173,7 +173,7 @@ Namespace UnitTests initialise() - Dim psAuxConfig = New DeclarationDataAdapter().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) + Dim psAuxConfig = New DeclarationDataAdapterTruck().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) Dim psActuationsMap = ActuationsMapReader.Read(_actuationsMapPath) Dim psCompressorMap = CompressorMapReader.ReadFile(_compressorMapPath) @@ -204,7 +204,7 @@ Namespace UnitTests _defaultInputConfig.SmartRegeneration = False - Dim psAuxConfig = New DeclarationDataAdapter().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) + Dim psAuxConfig = New DeclarationDataAdapterTruck().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) Dim psActuationsMap = ActuationsMapReader.Read(_actuationsMapPath) Dim psCompressorMap = CompressorMapReader.ReadFile(_compressorMapPath) @@ -233,7 +233,7 @@ Namespace UnitTests '_defaultInputConfig.RetarderBrake = False - Dim psAuxConfig = New DeclarationDataAdapter().CreatePneumaticAuxConfig(RetarderType.None) + Dim psAuxConfig = New DeclarationDataAdapterTruck().CreatePneumaticAuxConfig(RetarderType.None) Dim psActuationsMap = ActuationsMapReader.Read(_actuationsMapPath) Dim psCompressorMap = CompressorMapReader.ReadFile(_compressorMapPath) @@ -262,7 +262,7 @@ Namespace UnitTests _defaultInputConfig.KneelingHeightMillimeters = 100.SI(Unit.si.Milli.Meter).Cast (Of Meter) - Dim psAuxConfig = New DeclarationDataAdapter().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) + Dim psAuxConfig = New DeclarationDataAdapterTruck().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) Dim psActuationsMap = ActuationsMapReader.Read(_actuationsMapPath) Dim psCompressorMap = CompressorMapReader.ReadFile(_compressorMapPath) @@ -288,7 +288,7 @@ Namespace UnitTests _defaultInputConfig.AirSuspensionControl = ConsumerTechnology.Mechanically - Dim psAuxConfig = New DeclarationDataAdapter().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) + Dim psAuxConfig = New DeclarationDataAdapterTruck().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) Dim psActuationsMap = ActuationsMapReader.Read(_actuationsMapPath) Dim psCompressorMap = CompressorMapReader.ReadFile(_compressorMapPath) @@ -314,9 +314,9 @@ Namespace UnitTests initialise() - _defaultInputConfig.AdBlueDosing = ConsumerTechnology.Pneumatic + _defaultInputConfig.AdBlueDosing = ConsumerTechnology.Pneumatically - Dim psAuxConfig = New DeclarationDataAdapter().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) + Dim psAuxConfig = New DeclarationDataAdapterTruck().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) Dim psActuationsMap = ActuationsMapReader.Read(_actuationsMapPath) Dim psCompressorMap = CompressorMapReader.ReadFile(_compressorMapPath) @@ -345,7 +345,7 @@ Namespace UnitTests _defaultInputConfig.Doors = ConsumerTechnology.Electrically - Dim psAuxConfig = New DeclarationDataAdapter().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) + Dim psAuxConfig = New DeclarationDataAdapterTruck().CreatePneumaticAuxConfig(RetarderType.LossesIncludedInTransmission) Dim psActuationsMap = ActuationsMapReader.Read(_actuationsMapPath) Dim psCompressorMap = CompressorMapReader.ReadFile(_compressorMapPath) diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/SSMTOOLTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/SSMTOOLTests.vb index e386483fc9..3d6dcd3592 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/SSMTOOLTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/SSMTOOLTests.vb @@ -71,7 +71,7 @@ Namespace UnitTests <TestCase("AuxHeater")> Public Sub InstantiateDefaultSSMGenInputsTest(section As String) - Dim dao = New declarationDataAdapter() + Dim dao = New DeclarationDataAdapterTruck() Dim target As ISSMInputs = dao.CreateSSMModelParameters(Utils.GetDefaultVehicleData(), FuelData.Diesel) If section = "BusParameterisation" Then @@ -560,7 +560,7 @@ Namespace UnitTests Const filePath As String = "SSMTOOLTestSaveRetreive.json" Dim success As Boolean - Dim dao = New DeclarationDataAdapter() + Dim dao = New DeclarationDataAdapterTruck() Dim target As SSMTOOL = New SSMTOOL(dao.CreateSSMModelParameters(Utils.GetDefaultVehicleData(), FuelData.Diesel)) diff --git a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs index 34fe87f3e7..dd95d14cfd 100644 --- a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs +++ b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs @@ -164,7 +164,9 @@ namespace TUGraz.VectoCommon.InputData int NumberOfPassengersLowerDeck { get; } VehicleCode VehicleCode { get; } - bool LowEntry { get; } + FloorType FloorType { get; } + + bool Articulated { get; } Meter Height { get; } diff --git a/VectoCore/VectoCore/Configuration/Constants.cs b/VectoCore/VectoCore/Configuration/Constants.cs index 1640f234b0..eb14dffc6a 100644 --- a/VectoCore/VectoCore/Configuration/Constants.cs +++ b/VectoCore/VectoCore/Configuration/Constants.cs @@ -190,6 +190,13 @@ namespace TUGraz.VectoCore.Configuration } } + public static class BusParameters + { + public static readonly Meter DriverCompartmentLength = 1.2.SI<Meter>(); + public static readonly Kilogram PassengerWeightLow = 68.SI<Kilogram>(); + public static readonly Kilogram PassengerWeightHigh = 71.SI<Kilogram>(); + } + public static class FileExtensions { public const string PDFReport = ".pdf"; @@ -281,6 +288,20 @@ namespace TUGraz.VectoCore.Configuration public static readonly MeterPerSecond HighwaySpeedThreshold = 70.KMPHtoMeterPerSecond(); public static readonly MeterPerSecond RuralSpeedThreshold = 50.KMPHtoMeterPerSecond(); + + public static class CrosswindCorrection + { + public const int MinVehicleSpeed = 60; // km/h + public const int MaxVehicleSpeed = 130; // km/h + public const int VehicleSpeedStep = 5; // km/h + + public const int MaxAlpha = 180; // degree + public const int AlphaStep = 5; // degree + + public const int MinHeight = 5; // percent + public const int MaxHeight = 100; // percent + public const int HeightStep = 10; // percent + } } public static class XML diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs index 26c08af8ef..3b34399444 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs @@ -33,6 +33,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Xml.Linq; +using TUGraz.VectoCommon.BusAuxiliaries; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; @@ -212,15 +213,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return VehicleData.DynamicTyreRadius; } } - public bool LowEntry { get; set; } + + public bool Articulated { get { return VehicleData.Articulated; } } public Meter Height { get { return VehicleData.Height; } } - public Meter Length { get { return null; } } - public Meter Width { get { return null; } } + public Meter Length { get { return VehicleData.Length; } } + public Meter Width { get { return VehicleData.Width; } } IVehicleComponentsEngineering IVehicleEngineeringInputData.Components { @@ -387,6 +389,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public int NuberOfPassengersUpperDeck { get { return 0; } } public int NumberOfPassengersLowerDeck { get { return 0; } } public VehicleCode VehicleCode { get { return VehicleCode.NOT_APPLICABLE; } } + public FloorType FloorType { get { return VehicleData.FloorType; } } IVehicleComponentsDeclaration IVehicleDeclarationInputData.Components { diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs index 7edda6a5dd..54235f1f4c 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs @@ -58,6 +58,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return this; } } + #region Overrides of JSONVehicleDataV7 + + public override bool Articulated + { + get { return Body.GetEx<bool>("Articulated"); } + } + + #endregion + #endregion #region Implementation of IBusAuxiliariesDeclarationData @@ -205,6 +214,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #endregion } + // ################################################################### + // ################################################################### + public class JSONVehicleDataV8 : JSONVehicleDataV7 { public JSONVehicleDataV8(JObject data, string fileName, IJSONVehicleComponents job, bool tolerateMissing = false) : @@ -236,6 +248,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #endregion } + // ################################################################### + // ################################################################### + public class JSONVehicleDataV7 : JSONFile, IVehicleEngineeringInputData, IRetarderInputData, IAngledriveInputData, IPTOTransmissionInputData, IAirdragEngineeringInputData, IAdvancedDriverAssistantSystemDeclarationInputData, @@ -329,7 +344,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return Body.GetEx<double>(JsonKeys.Vehicle_DynamicTyreRadius).SI(Unit.SI.Milli.Meter).Cast<Meter>(); } } - public virtual bool LowEntry { get; set; } + public virtual bool Articulated { get { return false; } } public virtual Meter Height { @@ -574,6 +589,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return VehicleCode.NOT_APPLICABLE; } } + public virtual FloorType FloorType { get { return FloorType.Unknown; } } + IVehicleComponentsDeclaration IVehicleDeclarationInputData.Components { get { return this; } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationVehicleDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationVehicleDataProvider.cs index ae315dfcff..92dafbc5ff 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationVehicleDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationVehicleDataProvider.cs @@ -33,6 +33,7 @@ using System; using System.Collections.Generic; using System.Xml; using System.Xml.Linq; +using TUGraz.VectoCommon.BusAuxiliaries; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; @@ -271,7 +272,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public virtual int NuberOfPassengersUpperDeck { get { return 0; } } public virtual int NumberOfPassengersLowerDeck { get { return 0; } } public virtual VehicleCode VehicleCode { get { return VehicleCode.NOT_APPLICABLE; } } - public virtual bool LowEntry { get { return false; } } + public virtual FloorType FloorType { get { return FloorType.Unknown; } } + public virtual bool Articulated { get { return false; } } + public virtual Meter Height { get { return null; } } public virtual Meter Length { get { return null; } } public virtual Meter Width { get { return null; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringVehicleDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringVehicleDataProvider.cs index 3684239249..b045f37da4 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringVehicleDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/DataProvider/XMLEngineeringVehicleDataProvider.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Xml; using System.Xml.Linq; using TUGraz.IVT.VectoXML; +using TUGraz.VectoCommon.BusAuxiliaries; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; @@ -167,7 +168,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider public virtual int NuberOfPassengersUpperDeck { get { return 0; } } public virtual int NumberOfPassengersLowerDeck { get { return 0; } } public virtual VehicleCode VehicleCode { get { return VehicleCode.NOT_APPLICABLE; } } - public virtual bool LowEntry { get { return false; } } + public virtual FloorType FloorType { get { return FloorType.Unknown; } } + public virtual bool Articulated { get { return false; } } + public virtual Meter Width { get { return null; } } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs new file mode 100644 index 0000000000..62912d1713 --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data; + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter { + public class DeclarationDataAdapterPrimaryBus : DeclarationDataAdapterTruck + { + public AirdragData CreateAirdragData(Mission mission) + { + throw new NotImplementedException(); + } + + public IEnumerable<VectoRunData.AuxData> CreateAuxiliaryData() + { + throw new NotImplementedException(); + } + + #region Overrides of DeclarationDataAdapterTruck + + public override VehicleData CreateVehicleData(IVehicleDeclarationInputData data, Mission mission, Kilogram loading) + { + var retVal = base.CreateVehicleData(data, mission, loading); + retVal.CurbWeight = mission.CurbMass; + return retVal; + } + + #endregion + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterTruck.cs similarity index 92% rename from VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs rename to VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterTruck.cs index 06754a3ee9..4a31550113 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterTruck.cs @@ -1,665 +1,665 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2019 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology -*/ - -using System; -using System.Collections.Generic; -using System.Linq; -using TUGraz.VectoCommon.BusAuxiliaries; -using TUGraz.VectoCommon.Exceptions; -using TUGraz.VectoCommon.InputData; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Configuration; -using TUGraz.VectoCore.InputData.Reader.ComponentData; -using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC; -using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumatics; -using TUGraz.VectoCore.Models.Declaration; -using TUGraz.VectoCore.Models.Simulation.Data; -using TUGraz.VectoCore.Models.SimulationComponent.Data; -using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; -using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; -using TUGraz.VectoCore.OutputData; -using TUGraz.VectoCore.Utils; - -namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter -{ - public class DeclarationDataAdapter : AbstractSimulationDataAdapter - { - public static readonly GearboxType[] SupportedGearboxTypes = - { GearboxType.MT, GearboxType.AMT, GearboxType.ATPowerSplit, GearboxType.ATSerial }; - - public DriverData CreateDriverData() - { - var lookAheadData = new DriverData.LACData { - Enabled = DeclarationData.Driver.LookAhead.Enabled, - - //Deceleration = DeclarationData.Driver.LookAhead.Deceleration, - MinSpeed = DeclarationData.Driver.LookAhead.MinimumSpeed, - LookAheadDecisionFactor = new LACDecisionFactor(), - LookAheadDistanceFactor = DeclarationData.Driver.LookAhead.LookAheadDistanceFactor, - }; - var overspeedData = new DriverData.OverSpeedData { - Enabled = true, - MinSpeed = DeclarationData.Driver.OverSpeed.MinSpeed, - OverSpeed = DeclarationData.Driver.OverSpeed.AllowedOverSpeed, - }; - - var retVal = new DriverData { - LookAheadCoasting = lookAheadData, - OverSpeed = overspeedData, - EngineStopStart = new DriverData.EngineStopStartData() { - EngineOffStandStillActivationDelay = DeclarationData.Driver.EngineStopStart.ActivationDelay, - MaxEngineOffTimespan = DeclarationData.Driver.EngineStopStart.MaxEngineOffTimespan, - UtilityFactor = DeclarationData.Driver.EngineStopStart.UtilityFactor, - }, - EcoRoll = new DriverData.EcoRollData() { - UnderspeedThreshold = DeclarationData.Driver.EcoRoll.UnderspeedThreshold, - MinSpeed = DeclarationData.Driver.EcoRoll.MinSpeed, - ActivationPhaseDuration = DeclarationData.Driver.EcoRoll.ActivationDelay, - AccelerationLowerLimit = DeclarationData.Driver.EcoRoll.AccelerationLowerLimit, - AccelerationUpperLimit = DeclarationData.Driver.EcoRoll.AccelerationUpperLimit, - } - }; - return retVal; - } - - internal VehicleData CreateVehicleData(IVehicleDeclarationInputData data, Mission mission, Kilogram loading) - { - if (!data.SavedInDeclarationMode) { - WarnDeclarationMode("VehicleData"); - } - return data.ExemptedVehicle - ? CreateExemptedVehicleData(data) - : CreateNonExemptedVehicleData(data, mission, loading); - } - - private VehicleData CreateNonExemptedVehicleData(IVehicleDeclarationInputData data, Mission mission, Kilogram loading) - { - var retVal = SetCommonVehicleData(data); - retVal.AxleConfiguration = data.AxleConfiguration; - retVal.AirDensity = DeclarationData.AirDensity; - retVal.VIN = data.VIN; - retVal.ManufacturerAddress = data.ManufacturerAddress; - retVal.LegislativeClass = data.LegislativeClass; - retVal.ZeroEmissionVehicle = data.ZeroEmissionVehicle; - retVal.SleeperCab = data.SleeperCab; - retVal.TrailerGrossVehicleWeight = mission.Trailer.Sum(t => t.TrailerGrossVehicleWeight).DefaultIfNull(0); - - retVal.BodyAndTrailerWeight = - mission.BodyCurbWeight + mission.Trailer.Sum(t => t.TrailerCurbWeight).DefaultIfNull(0); - - retVal.Loading = loading; - retVal.DynamicTyreRadius = - data.Components.AxleWheels.AxlesDeclaration.Where(axle => axle.AxleType == AxleType.VehicleDriven) - .Select(da => DeclarationData.Wheels.Lookup(da.Tyre.Dimension).DynamicTyreRadius) - .Average(); - retVal.CargoVolume = mission.MissionType != MissionType.Construction ? mission.TotalCargoVolume : 0.SI<CubicMeter>(); - - retVal.VocationalVehicle = data.VocationalVehicle; - retVal.ADAS = CreateADAS(data.ADAS); - - // eco-roll is not allowed for MT transmissions! - if (retVal.ADAS.EcoRoll != EcoRollType.None && data.Components.GearboxInputData.Type == GearboxType.MT) { - retVal.ADAS.EcoRoll = EcoRollType.None; - } - if (retVal.ADAS.EcoRoll == EcoRollType.WithEngineStop && - data.Components.GearboxInputData.Type.AutomaticTransmission()) { - retVal.ADAS.EcoRoll = EcoRollType.WithoutEngineStop; - } - - var axles = data.Components.AxleWheels.AxlesDeclaration; - if (axles.Count < mission.AxleWeightDistribution.Length) { - throw new VectoException( - "Vehicle does not contain sufficient axles. {0} axles defined, {1} axles required", - axles.Count, mission.AxleWeightDistribution.Length); - } - - var axleData = new List<Axle>(); - for (var i = 0; i < mission.AxleWeightDistribution.Length; i++) { - var axleInput = axles[i]; - var axle = new Axle { - WheelsDimension = axleInput.Tyre.Dimension, - AxleType = axleInput.AxleType, - AxleWeightShare = mission.AxleWeightDistribution[i], - TwinTyres = axleInput.TwinTyres, - RollResistanceCoefficient = axleInput.Tyre.RollResistanceCoefficient, - TyreTestLoad = axleInput.Tyre.TyreTestLoad, - Inertia = DeclarationData.Wheels.Lookup(axleInput.Tyre.Dimension.RemoveWhitespace()).Inertia, - CertificationNumber = axleInput.Tyre.CertificationNumber, - DigestValueInput = axleInput.Tyre.DigestValue == null ? "" : axleInput.Tyre.DigestValue.DigestValue, - }; - axleData.Add(axle); - } - - foreach (var trailer in mission.Trailer) { - axleData.AddRange( - trailer.TrailerWheels.Select( - trailerWheel => new Axle { - AxleType = AxleType.Trailer, - AxleWeightShare = trailer.TrailerAxleWeightShare / trailer.TrailerWheels.Count, - TwinTyres = DeclarationData.Trailer.TwinTyres, - RollResistanceCoefficient = DeclarationData.Trailer.RollResistanceCoefficient, - TyreTestLoad = DeclarationData.Trailer.TyreTestLoad.SI<Newton>(), - Inertia = trailerWheel.Inertia, - WheelsDimension = trailerWheel.WheelType - })); - } - - retVal.AxleData = axleData; - return retVal; - } - - - private VehicleData CreateExemptedVehicleData(IVehicleDeclarationInputData data) - { - var exempted = SetCommonVehicleData(data); - exempted.VIN = data.VIN; - exempted.ManufacturerAddress = data.ManufacturerAddress; - exempted.LegislativeClass = data.LegislativeClass; - exempted.ZeroEmissionVehicle = data.ZeroEmissionVehicle; - exempted.HybridElectricHDV = data.HybridElectricHDV; - exempted.DualFuelVehicle = data.DualFuelVehicle; - exempted.MaxNetPower1 = data.MaxNetPower1; - exempted.MaxNetPower2 = data.MaxNetPower2; - return exempted; - } - - - internal CombustionEngineData CreateEngineData( - IVehicleDeclarationInputData vehicle, IEngineModeDeclarationInputData mode, Mission mission) - { - var engine = vehicle.Components.EngineInputData; - var gearbox = vehicle.Components.GearboxInputData; - - if (!engine.SavedInDeclarationMode) { - WarnDeclarationMode("EngineData"); - } - - var retVal = SetCommonCombustionEngineData(engine, vehicle.TankSystem); - retVal.IdleSpeed = VectoMath.Max(mode.IdleSpeed, vehicle.EngineIdleSpeed); - - retVal.Fuels = new List<CombustionEngineFuelData>(); - foreach (var fuel in mode.Fuels) { - retVal.Fuels.Add( - new CombustionEngineFuelData() { - WHTCUrban = fuel.WHTCUrban, - WHTCRural = fuel.WHTCRural, - WHTCMotorway = fuel.WHTCMotorway, - ColdHotCorrectionFactor = fuel.ColdHotBalancingFactor, - CorrectionFactorRegPer = fuel.CorrectionFactorRegPer, - FuelData = DeclarationData.FuelData.Lookup(fuel.FuelType, vehicle.TankSystem), - ConsumptionMap = FuelConsumptionMapReader.Create(fuel.FuelConsumptionMap), - FuelConsumptionCorrectionFactor = DeclarationData.WHTCCorrection.Lookup( - mission.MissionType.GetNonEMSMissionType(), fuel.WHTCRural, fuel.WHTCUrban, - fuel.WHTCMotorway) * fuel.ColdHotBalancingFactor * fuel.CorrectionFactorRegPer, - }); - } - - retVal.Inertia = DeclarationData.Engine.EngineInertia(retVal.Displacement, gearbox.Type); - retVal.EngineStartTime = DeclarationData.Engine.DefaultEngineStartTime; - var limits = vehicle.TorqueLimits.ToDictionary(e => e.Gear); - var numGears = gearbox.Gears.Count; - var fullLoadCurves = new Dictionary<uint, EngineFullLoadCurve>(numGears + 1); - fullLoadCurves[0] = FullLoadCurveReader.Create(mode.FullLoadCurve, true); - fullLoadCurves[0].EngineData = retVal; - foreach (var gear in gearbox.Gears) { - var maxTorque = VectoMath.Min( - GbxMaxTorque(gear, numGears, fullLoadCurves[0].MaxTorque), - VehMaxTorque(gear, numGears, limits, fullLoadCurves[0].MaxTorque)); - fullLoadCurves[(uint)gear.Gear] = IntersectFullLoadCurves(fullLoadCurves[0], maxTorque); - } - - retVal.FullLoadCurves = fullLoadCurves; - - var whr = CreateWHRData(mode.WasteHeatRecoveryData); - if (whr != null) { - whr.WHRCorrectionFactor = DeclarationData.WHTCCorrection.Lookup( - mission.MissionType.GetNonEMSMissionType(), whr.CFRural, whr.CFUrban, - whr.CFMotorway) * whr.CFColdHot * whr.CFRegPer; - } - retVal.WHRData = whr; - - return retVal; - } - - private static WHRData CreateWHRData(IWHRData whrInputData) - { - if (whrInputData == null || whrInputData.GeneratedElectricPower == null) { - return null; - } - - return new WHRData() { - CFUrban = whrInputData.UrbanCorrectionFactor, - CFRural = whrInputData.RuralCorrectionFactor, - CFMotorway = whrInputData.MotorwayCorrectionFactor, - CFColdHot = whrInputData.BFColdHot, - CFRegPer = whrInputData.CFRegPer, - WHRMap = WHRPowerReader.Create(whrInputData.GeneratedElectricPower) - }; - } - - private static NewtonMeter VehMaxTorque( - ITransmissionInputData gear, int numGears, - Dictionary<int, ITorqueLimitInputData> limits, - NewtonMeter maxEngineTorque) - { - if (gear.Gear - 1 >= numGears / 2) { - // only upper half of gears can limit if max-torque <= 0.95 of engine max torque - if (limits.ContainsKey(gear.Gear) && - limits[gear.Gear].MaxTorque <= DeclarationData.Engine.TorqueLimitVehicleFactor * maxEngineTorque) { - return limits[gear.Gear].MaxTorque; - } - } - - return null; - } - - private static NewtonMeter GbxMaxTorque( - ITransmissionInputData gear, int numGears, NewtonMeter maxEngineTorque - ) - { - if (gear.Gear - 1 < numGears / 2) { - // gears count from 1 to n, -> n entries, lower half can always limit - if (gear.MaxTorque != null) { - return gear.MaxTorque; - } - } else { - // upper half can only limit if max-torque <= 90% of engine max torque - if (gear.MaxTorque != null && gear.MaxTorque <= DeclarationData.Engine.TorqueLimitGearboxFactor * maxEngineTorque) { - return gear.MaxTorque; - } - } - - return null; - } - - internal GearboxData CreateGearboxData( - IGearboxDeclarationInputData gearbox, CombustionEngineData engine, double axlegearRatio, Meter dynamicTyreRadius, - VehicleCategory vehicleCategory, ITorqueConverterDeclarationInputData torqueConverter) - { - if (!gearbox.SavedInDeclarationMode) { - WarnDeclarationMode("GearboxData"); - } - var retVal = SetCommonGearboxData(gearbox); - - if (!SupportedGearboxTypes.Contains(gearbox.Type)) { - throw new VectoSimulationException("Unsupported gearbox type: {0}!", retVal.Type); - } - - var gearsInput = gearbox.Gears; - if (gearsInput.Count < 1) { - throw new VectoSimulationException( - "At least one Gear-Entry must be defined in Gearbox!"); - } - - SetDeclarationData(retVal); - - var gearDifferenceRatio = gearbox.Type.AutomaticTransmission() && gearbox.Gears.Count > 2 - ? gearbox.Gears[0].Ratio / gearbox.Gears[1].Ratio - : 1.0; - - var gears = new Dictionary<uint, GearData>(); - var tcShiftPolygon = DeclarationData.TorqueConverter.ComputeShiftPolygon(engine.FullLoadCurves[0]); - for (uint i = 0; i < gearsInput.Count; i++) { - var gear = gearsInput[(int)i]; - var lossMap = CreateGearLossMap(gear, i, false); - - var shiftPolygon = DeclarationData.Gearbox.ComputeShiftPolygon( - gearbox.Type, (int)i, engine.FullLoadCurves[i + 1], - gearsInput, engine, - axlegearRatio, dynamicTyreRadius); - - var gearData = new GearData { - ShiftPolygon = shiftPolygon, - MaxSpeed = gear.MaxInputSpeed, - Ratio = gear.Ratio, - LossMap = lossMap, - }; - - CreateATGearData(gearbox, i, gearData, tcShiftPolygon, gearDifferenceRatio, gears, vehicleCategory); - gears.Add(i + 1, gearData); - } - - retVal.Gears = gears; - if (retVal.Type.AutomaticTransmission()) { - var ratio = double.IsNaN(retVal.Gears[1].Ratio) ? 1 : retVal.Gears[1].TorqueConverterRatio / retVal.Gears[1].Ratio; - retVal.PowershiftShiftTime = DeclarationData.Gearbox.PowershiftShiftTime; - retVal.TorqueConverterData = TorqueConverterDataReader.Create( - torqueConverter.TCData, - DeclarationData.TorqueConverter.ReferenceRPM, DeclarationData.TorqueConverter.MaxInputSpeed, - ExecutionMode.Declaration, ratio, - DeclarationData.TorqueConverter.CLUpshiftMinAcceleration, - DeclarationData.TorqueConverter.CCUpshiftMinAcceleration); - retVal.TorqueConverterData.ModelName = torqueConverter.Model; - retVal.TorqueConverterData.DigestValueInput = torqueConverter.DigestValue?.DigestValue; - retVal.TorqueConverterData.CertificationMethod = torqueConverter.CertificationMethod; - retVal.TorqueConverterData.CertificationNumber = torqueConverter.CertificationNumber; - } - - return retVal; - } - - private static void CreateATGearData( - IGearboxDeclarationInputData gearbox, uint i, GearData gearData, - 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 - CretateTCFirstGearATPowerSplit(gearData, i, tcShiftPolygon); - } - if (gearbox.Type == GearboxType.ATSerial) { - if (i == 0) { - // torqueconverter is active in first gear - duplicate ratio and lossmap for torque converter mode - CreateTCFirstGearATSerial(gearData, tcShiftPolygon); - } - if (i == 1 && gearDifferenceRatio >= DeclarationData.Gearbox.TorqueConverterSecondGearThreshold(vehicleCategory)) { - // ratio between first and second gear is above threshold, torqueconverter is active in second gear as well - // -> duplicate ratio and lossmap for torque converter mode, remove locked transmission for previous gear - CreateTCSecondGearATSerial(gearData, tcShiftPolygon); - - // NOTE: the lower gear in 'gears' dictionary has index i !! - gears[i].Ratio = double.NaN; - gears[i].LossMap = null; - } - } - } - - private static void SetDeclarationData(GearboxData retVal) - { - retVal.Inertia = DeclarationData.Gearbox.Inertia; - retVal.TractionInterruption = retVal.Type.TractionInterruption(); - retVal.TorqueReserve = DeclarationData.Gearbox.TorqueReserve; - retVal.StartTorqueReserve = DeclarationData.Gearbox.TorqueReserveStart; - retVal.ShiftTime = DeclarationData.Gearbox.MinTimeBetweenGearshifts; - retVal.StartSpeed = DeclarationData.Gearbox.StartSpeed; - retVal.StartAcceleration = DeclarationData.Gearbox.StartAcceleration; - retVal.DownshiftAfterUpshiftDelay = DeclarationData.Gearbox.DownshiftAfterUpshiftDelay; - retVal.UpshiftAfterDownshiftDelay = DeclarationData.Gearbox.UpshiftAfterDownshiftDelay; - retVal.UpshiftMinAcceleration = DeclarationData.Gearbox.UpshiftMinAcceleration; - } - - public AxleGearData CreateAxleGearData(IAxleGearInputData data) - { - var retVal = SetCommonAxleGearData(data); - retVal.AxleGear.LossMap = ReadAxleLossMap(data, false); - return retVal; - } - - public AngledriveData CreateAngledriveData(IAngledriveInputData data) - { - return DoCreateAngledriveData(data, false); - } - - - public IList<VectoRunData.AuxData> CreateAuxiliaryData( - IAuxiliariesDeclarationInputData auxInputData, - MissionType mission, VehicleClass hvdClass) - { - if (!auxInputData.SavedInDeclarationMode) { - WarnDeclarationMode("AuxiliariesData"); - } - var retVal = new List<VectoRunData.AuxData>(); - - if (auxInputData.Auxiliaries.Count != 5) { - Log.Error( - "In Declaration Mode exactly 5 Auxiliaries must be defined: Fan, Steering pump, HVAC, Electric System, Pneumatic System."); - throw new VectoException( - "In Declaration Mode exactly 5 Auxiliaries must be defined: Fan, Steering pump, HVAC, Electric System, Pneumatic System."); - } - - foreach (var auxType in EnumHelper.GetValues<AuxiliaryType>()) { - var auxData = auxInputData.Auxiliaries.FirstOrDefault(a => a.Type == auxType); - if (auxData == null) { - throw new VectoException("Auxiliary {0} not found.", auxType); - } - - var aux = new VectoRunData.AuxData { - DemandType = AuxiliaryDemandType.Constant, - Technology = auxData.Technology - }; - - mission = mission.GetNonEMSMissionType(); - switch (auxType) { - case AuxiliaryType.Fan: - aux.PowerDemand = DeclarationData.Fan.Lookup(mission, auxData.Technology.FirstOrDefault()).PowerDemand; - aux.ID = Constants.Auxiliaries.IDs.Fan; - break; - case AuxiliaryType.SteeringPump: - aux.PowerDemand = DeclarationData.SteeringPump.Lookup(mission, hvdClass, auxData.Technology); - aux.ID = Constants.Auxiliaries.IDs.SteeringPump; - break; - case AuxiliaryType.HVAC: - aux.PowerDemand = DeclarationData.HeatingVentilationAirConditioning.Lookup( - mission, - auxData.Technology.FirstOrDefault(), hvdClass).PowerDemand; - aux.ID = Constants.Auxiliaries.IDs.HeatingVentilationAirCondition; - break; - case AuxiliaryType.PneumaticSystem: - 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()).PowerDemand; - aux.ID = Constants.Auxiliaries.IDs.ElectricSystem; - break; - default: continue; - } - - retVal.Add(aux); - } - - return retVal; - } - - private void WarnDeclarationMode(string inputData) - { - Log.Warn("{0} not in Declaration Mode!", inputData); - } - - public RetarderData CreateRetarderData(IRetarderInputData retarder) - { - return SetCommonRetarderData(retarder); - } - - public static List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> GetDeclarationAirResistanceCurve( - string crosswindCorrectionParameters, SquareMeter aerodynamicDragAera, Meter vehicleHeight) - { - const int startSpeed = 60; - const int maxSpeed = 130; - const int speedStep = 5; - - const int maxAlpha = 180; - const int alphaStep = 10; - - const int startHeightPercent = 5; - const int maxHeightPercent = 100; - const int heightPercentStep = 10; - const double heightShare = (double)heightPercentStep / maxHeightPercent; - - var values = DeclarationData.AirDrag.Lookup(crosswindCorrectionParameters); - - // first entry (0m/s) will get CdxA of second entry. - var points = new List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> { - new CrossWindCorrectionCurveReader.CrossWindCorrectionEntry { - Velocity = 0.SI<MeterPerSecond>(), - EffectiveCrossSectionArea = 0.SI<SquareMeter>() - } - }; - - for (var speed = startSpeed; speed <= maxSpeed; speed += speedStep) { - var vVeh = speed.KMPHtoMeterPerSecond(); - - var cdASum = 0.SI<SquareMeter>(); - - for (var heightPercent = startHeightPercent; heightPercent < maxHeightPercent; heightPercent += heightPercentStep) { - var height = heightPercent / 100.0 * vehicleHeight; - var vWind = Physics.BaseWindSpeed * Math.Pow(height / Physics.BaseWindHeight, Physics.HellmannExponent); - - for (var alpha = 0; alpha <= maxAlpha; alpha += alphaStep) { - var vAirX = vVeh + vWind * Math.Cos(alpha.ToRadian()); - var vAirY = vWind * Math.Sin(alpha.ToRadian()); - - var beta = Math.Atan(vAirY / vAirX).ToDegree(); - - // ΔCdxA = A1β + A2β² + A3β³ - var deltaCdA = values.A1 * beta + values.A2 * beta * beta + values.A3 * beta * beta * beta; - - // CdxA(β) = CdxA(0) + ΔCdxA(β) - var cdA = aerodynamicDragAera + deltaCdA; - - var share = (alpha == 0 || alpha == maxAlpha ? alphaStep / 2.0 : alphaStep) / maxAlpha; - - // v_air = sqrt(v_airX²+vAirY²) - // cdASum = CdxA(β) * v_air²/v_veh² - cdASum += heightShare * share * cdA * (vAirX * vAirX + vAirY * vAirY) / (vVeh * vVeh); - } - } - - points.Add( - new CrossWindCorrectionCurveReader.CrossWindCorrectionEntry { - Velocity = vVeh, - EffectiveCrossSectionArea = cdASum - }); - } - - points[0].EffectiveCrossSectionArea = points[1].EffectiveCrossSectionArea; - return points; - } - - public PTOData CreatePTOTransmissionData(IPTOTransmissionInputData pto) - { - if (pto.PTOTransmissionType != "None") { - return new PTOData { - TransmissionType = pto.PTOTransmissionType, - LossMap = PTOIdleLossMapReader.GetZeroLossMap(), - }; - } - - return null; - } - - public AirdragData CreateAirdragData( - IAirdragDeclarationInputData airdragInputData, Mission mission, - Segment segment) - { - if (airdragInputData == null || airdragInputData.AirDragArea == null) { - return DefaultAirdragData(mission, segment); - } - - var retVal = SetCommonAirdragData(airdragInputData); - - retVal.DeclaredAirdragArea = mission.MissionType == MissionType.Construction - ? mission.DefaultCDxA - : airdragInputData.AirDragArea; - - var aerodynamicDragArea = retVal.DeclaredAirdragArea + mission.Trailer.Sum(t => t.DeltaCdA).DefaultIfNull(0); - - retVal.CrossWindCorrectionCurve = - new CrosswindCorrectionCdxALookup( - aerodynamicDragArea, - GetDeclarationAirResistanceCurve( - mission.CrossWindCorrectionParameters, aerodynamicDragArea, segment.VehicleHeight), - CrossWindCorrectionMode.DeclarationModeCorrection); - return retVal; - } - - private AirdragData DefaultAirdragData(Mission mission, Segment segment) - { - var aerodynamicDragArea = mission.DefaultCDxA + mission.Trailer.Sum(t => t.DeltaCdA).DefaultIfNull(0); - - return new AirdragData() { - CertificationMethod = CertificationMethod.StandardValues, - DeclaredAirdragArea = mission.DefaultCDxA, - CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup( - aerodynamicDragArea, - GetDeclarationAirResistanceCurve( - mission.CrossWindCorrectionParameters, aerodynamicDragArea, segment.VehicleHeight), - CrossWindCorrectionMode.DeclarationModeCorrection) - }; - } - - public ISSMInputs CreateSSMModelParameters(IVehicleData vehicleData, IFuelProperties heatingFuel) - { - return new SSMInputs(vehicleData, null, heatingFuel) { - Technologies = DeclarationData.BusAuxiliaries.SSMTechnologyList, - DefaultConditions = new EnvironmentalConditionMapEntry( - Constants.BusAuxiliaries.SteadyStateModel.DefaultTemperature, - Constants.BusAuxiliaries.SteadyStateModel.DefaultSolar, - 1.0), - EnvironmentalConditionsMap = DeclarationData.BusAuxiliaries.DefaultEnvironmentalConditions, - HeatingBoundaryTemperature = Constants.BusAuxiliaries.SteadyStateModel.HeatingBoundaryTemperature, - CoolingBoundaryTemperature = Constants.BusAuxiliaries.SteadyStateModel.CoolingBoundaryTemperature, - HighVentilation = Constants.BusAuxiliaries.SteadyStateModel.HighVentilation, - LowVentilation = Constants.BusAuxiliaries.SteadyStateModel.LowVentilation, - SpecificVentilationPower = Constants.BusAuxiliaries.SteadyStateModel.SpecificVentilationPower, - - // TODO! MQ 2019-19-29 Compressor Type and CompressorCapacity from input data? - CompressorType = ACCompressorType.TwoStage, // "2-stage", - CompressorCapacity = 18.SI(Unit.SI.Kilo.Watt).Cast<Watt>(), - - AuxHeaterEfficiency = Constants.BusAuxiliaries.SteadyStateModel.AuxHeaterEfficiency, - FuelFiredHeaterPower = Constants.BusAuxiliaries.SteadyStateModel.FuelFiredHeaterPower, - FuelEnergyToHeatToCoolant = Constants.BusAuxiliaries.Heater.FuelEnergyToHeatToCoolant, - CoolantHeatTransferredToAirCabinHeater = Constants.BusAuxiliaries.Heater.CoolantHeatTransferredToAirCabinHeater, - GFactor = Constants.BusAuxiliaries.SteadyStateModel.GFactor, - VentilationOnDuringHeating = true, - VentilationWhenBothHeatingAndACInactive = true, - VentilationDuringAC = true, - VentilationDuringHeating = VentilationLevel.High, - VentilationDuringCooling = VentilationLevel.High, - VentilationFlowSettingWhenHeatingAndACInactive = VentilationLevel.High, - MaxPossibleBenefitFromTechnologyList = - Constants.BusAuxiliaries.SteadyStateModel.MaxPossibleBenefitFromTechnologyList, - }; - } - - public IPneumaticsConsumersDemand CreatePneumaticAuxConfig(RetarderType retarderType) - { - return new PneumaticsConsumersDemand() { - AdBlueInjection = Constants.BusAuxiliaries.PneumaticConsumersDemands.AdBlueInjection, - AirControlledSuspension = Constants.BusAuxiliaries.PneumaticConsumersDemands.AirControlledSuspension, - Braking = retarderType == RetarderType.None ? - Constants.BusAuxiliaries.PneumaticConsumersDemands.BrakingNoRetarder : - Constants.BusAuxiliaries.PneumaticConsumersDemands.BrakingWithRetarder, - BreakingWithKneeling = Constants.BusAuxiliaries.PneumaticConsumersDemands.BreakingAndKneeling, - DeadVolBlowOuts = Constants.BusAuxiliaries.PneumaticConsumersDemands.DeadVolBlowOuts, - DeadVolume = Constants.BusAuxiliaries.PneumaticConsumersDemands.DeadVolume, - NonSmartRegenFractionTotalAirDemand = Constants.BusAuxiliaries.PneumaticConsumersDemands.NonSmartRegenFractionTotalAirDemand, - SmartRegenFractionTotalAirDemand = Constants.BusAuxiliaries.PneumaticConsumersDemands.SmartRegenFractionTotalAirDemand, - OverrunUtilisationForCompressionFraction = Constants.BusAuxiliaries.PneumaticConsumersDemands.OverrunUtilisationForCompressionFraction, - DoorOpening = Constants.BusAuxiliaries.PneumaticConsumersDemands.DoorOpening, - StopBrakeActuation = Constants.BusAuxiliaries.PneumaticConsumersDemands.StopBrakeActuation, - }; - } - } -} +/* +* This file is part of VECTO. +* +* Copyright © 2012-2019 European Union +* +* Developed by Graz University of Technology, +* Institute of Internal Combustion Engines and Thermodynamics, +* Institute of Technical Informatics +* +* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved +* by the European Commission - subsequent versions of the EUPL (the "Licence"); +* You may not use VECTO except in compliance with the Licence. +* You may obtain a copy of the Licence at: +* +* https://joinup.ec.europa.eu/community/eupl/og_page/eupl +* +* Unless required by applicable law or agreed to in writing, VECTO +* distributed under the Licence is distributed on an "AS IS" basis, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the Licence for the specific language governing permissions and +* limitations under the Licence. +* +* Authors: +* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology +* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology +* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology +* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology +* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology +* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using TUGraz.VectoCommon.BusAuxiliaries; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.InputData.Reader.ComponentData; +using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC; +using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumatics; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; +using TUGraz.VectoCore.OutputData; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public class DeclarationDataAdapterTruck : AbstractSimulationDataAdapter, IDeclarationDataAdapter + { + public static readonly GearboxType[] SupportedGearboxTypes = + { GearboxType.MT, GearboxType.AMT, GearboxType.ATPowerSplit, GearboxType.ATSerial }; + + public virtual DriverData CreateDriverData() + { + var lookAheadData = new DriverData.LACData { + Enabled = DeclarationData.Driver.LookAhead.Enabled, + + //Deceleration = DeclarationData.Driver.LookAhead.Deceleration, + MinSpeed = DeclarationData.Driver.LookAhead.MinimumSpeed, + LookAheadDecisionFactor = new LACDecisionFactor(), + LookAheadDistanceFactor = DeclarationData.Driver.LookAhead.LookAheadDistanceFactor, + }; + var overspeedData = new DriverData.OverSpeedData { + Enabled = true, + MinSpeed = DeclarationData.Driver.OverSpeed.MinSpeed, + OverSpeed = DeclarationData.Driver.OverSpeed.AllowedOverSpeed, + }; + + var retVal = new DriverData { + LookAheadCoasting = lookAheadData, + OverSpeed = overspeedData, + EngineStopStart = new DriverData.EngineStopStartData() { + EngineOffStandStillActivationDelay = DeclarationData.Driver.EngineStopStart.ActivationDelay, + MaxEngineOffTimespan = DeclarationData.Driver.EngineStopStart.MaxEngineOffTimespan, + UtilityFactor = DeclarationData.Driver.EngineStopStart.UtilityFactor, + }, + EcoRoll = new DriverData.EcoRollData() { + UnderspeedThreshold = DeclarationData.Driver.EcoRoll.UnderspeedThreshold, + MinSpeed = DeclarationData.Driver.EcoRoll.MinSpeed, + ActivationPhaseDuration = DeclarationData.Driver.EcoRoll.ActivationDelay, + AccelerationLowerLimit = DeclarationData.Driver.EcoRoll.AccelerationLowerLimit, + AccelerationUpperLimit = DeclarationData.Driver.EcoRoll.AccelerationUpperLimit, + } + }; + return retVal; + } + + public virtual VehicleData CreateVehicleData(IVehicleDeclarationInputData data, Mission mission, Kilogram loading) + { + if (!data.SavedInDeclarationMode) { + WarnDeclarationMode("VehicleData"); + } + return data.ExemptedVehicle + ? CreateExemptedVehicleData(data) + : CreateNonExemptedVehicleData(data, mission, loading); + } + + protected virtual VehicleData CreateNonExemptedVehicleData(IVehicleDeclarationInputData data, Mission mission, Kilogram loading) + { + var retVal = SetCommonVehicleData(data); + retVal.AxleConfiguration = data.AxleConfiguration; + retVal.AirDensity = DeclarationData.AirDensity; + retVal.VIN = data.VIN; + retVal.ManufacturerAddress = data.ManufacturerAddress; + retVal.LegislativeClass = data.LegislativeClass; + retVal.ZeroEmissionVehicle = data.ZeroEmissionVehicle; + retVal.SleeperCab = data.SleeperCab; + retVal.TrailerGrossVehicleWeight = mission.Trailer.Sum(t => t.TrailerGrossVehicleWeight).DefaultIfNull(0); + + retVal.BodyAndTrailerWeight = + mission.BodyCurbWeight + mission.Trailer.Sum(t => t.TrailerCurbWeight).DefaultIfNull(0); + + retVal.Loading = loading; + retVal.DynamicTyreRadius = + data.Components.AxleWheels.AxlesDeclaration.Where(axle => axle.AxleType == AxleType.VehicleDriven) + .Select(da => DeclarationData.Wheels.Lookup(da.Tyre.Dimension).DynamicTyreRadius) + .Average(); + retVal.CargoVolume = mission.MissionType != MissionType.Construction ? mission.TotalCargoVolume : 0.SI<CubicMeter>(); + + retVal.VocationalVehicle = data.VocationalVehicle; + retVal.ADAS = CreateADAS(data.ADAS); + + // eco-roll is not allowed for MT transmissions! + if (retVal.ADAS.EcoRoll != EcoRollType.None && data.Components.GearboxInputData.Type == GearboxType.MT) { + retVal.ADAS.EcoRoll = EcoRollType.None; + } + if (retVal.ADAS.EcoRoll == EcoRollType.WithEngineStop && + data.Components.GearboxInputData.Type.AutomaticTransmission()) { + retVal.ADAS.EcoRoll = EcoRollType.WithoutEngineStop; + } + + var axles = data.Components.AxleWheels.AxlesDeclaration; + if (axles.Count < mission.AxleWeightDistribution.Length) { + throw new VectoException( + "Vehicle does not contain sufficient axles. {0} axles defined, {1} axles required", + axles.Count, mission.AxleWeightDistribution.Length); + } + + var axleData = new List<Axle>(); + for (var i = 0; i < mission.AxleWeightDistribution.Length; i++) { + var axleInput = axles[i]; + var axle = new Axle { + WheelsDimension = axleInput.Tyre.Dimension, + AxleType = axleInput.AxleType, + AxleWeightShare = mission.AxleWeightDistribution[i], + TwinTyres = axleInput.TwinTyres, + RollResistanceCoefficient = axleInput.Tyre.RollResistanceCoefficient, + TyreTestLoad = axleInput.Tyre.TyreTestLoad, + Inertia = DeclarationData.Wheels.Lookup(axleInput.Tyre.Dimension.RemoveWhitespace()).Inertia, + CertificationNumber = axleInput.Tyre.CertificationNumber, + DigestValueInput = axleInput.Tyre.DigestValue == null ? "" : axleInput.Tyre.DigestValue.DigestValue, + }; + axleData.Add(axle); + } + + foreach (var trailer in mission.Trailer) { + axleData.AddRange( + trailer.TrailerWheels.Select( + trailerWheel => new Axle { + AxleType = AxleType.Trailer, + AxleWeightShare = trailer.TrailerAxleWeightShare / trailer.TrailerWheels.Count, + TwinTyres = DeclarationData.Trailer.TwinTyres, + RollResistanceCoefficient = DeclarationData.Trailer.RollResistanceCoefficient, + TyreTestLoad = DeclarationData.Trailer.TyreTestLoad.SI<Newton>(), + Inertia = trailerWheel.Inertia, + WheelsDimension = trailerWheel.WheelType + })); + } + + retVal.AxleData = axleData; + return retVal; + } + + + protected virtual VehicleData CreateExemptedVehicleData(IVehicleDeclarationInputData data) + { + var exempted = SetCommonVehicleData(data); + exempted.VIN = data.VIN; + exempted.ManufacturerAddress = data.ManufacturerAddress; + exempted.LegislativeClass = data.LegislativeClass; + exempted.ZeroEmissionVehicle = data.ZeroEmissionVehicle; + exempted.HybridElectricHDV = data.HybridElectricHDV; + exempted.DualFuelVehicle = data.DualFuelVehicle; + exempted.MaxNetPower1 = data.MaxNetPower1; + exempted.MaxNetPower2 = data.MaxNetPower2; + return exempted; + } + + + public virtual CombustionEngineData CreateEngineData( + IVehicleDeclarationInputData vehicle, IEngineModeDeclarationInputData mode, Mission mission) + { + var engine = vehicle.Components.EngineInputData; + var gearbox = vehicle.Components.GearboxInputData; + + if (!engine.SavedInDeclarationMode) { + WarnDeclarationMode("EngineData"); + } + + var retVal = SetCommonCombustionEngineData(engine, vehicle.TankSystem); + retVal.IdleSpeed = VectoMath.Max(mode.IdleSpeed, vehicle.EngineIdleSpeed); + + retVal.Fuels = new List<CombustionEngineFuelData>(); + foreach (var fuel in mode.Fuels) { + retVal.Fuels.Add( + new CombustionEngineFuelData() { + WHTCUrban = fuel.WHTCUrban, + WHTCRural = fuel.WHTCRural, + WHTCMotorway = fuel.WHTCMotorway, + ColdHotCorrectionFactor = fuel.ColdHotBalancingFactor, + CorrectionFactorRegPer = fuel.CorrectionFactorRegPer, + FuelData = DeclarationData.FuelData.Lookup(fuel.FuelType, vehicle.TankSystem), + ConsumptionMap = FuelConsumptionMapReader.Create(fuel.FuelConsumptionMap), + FuelConsumptionCorrectionFactor = DeclarationData.WHTCCorrection.Lookup( + mission.MissionType.GetNonEMSMissionType(), fuel.WHTCRural, fuel.WHTCUrban, + fuel.WHTCMotorway) * fuel.ColdHotBalancingFactor * fuel.CorrectionFactorRegPer, + }); + } + + retVal.Inertia = DeclarationData.Engine.EngineInertia(retVal.Displacement, gearbox.Type); + retVal.EngineStartTime = DeclarationData.Engine.DefaultEngineStartTime; + var limits = vehicle.TorqueLimits.ToDictionary(e => e.Gear); + var numGears = gearbox.Gears.Count; + var fullLoadCurves = new Dictionary<uint, EngineFullLoadCurve>(numGears + 1); + fullLoadCurves[0] = FullLoadCurveReader.Create(mode.FullLoadCurve, true); + fullLoadCurves[0].EngineData = retVal; + foreach (var gear in gearbox.Gears) { + var maxTorque = VectoMath.Min( + GbxMaxTorque(gear, numGears, fullLoadCurves[0].MaxTorque), + VehMaxTorque(gear, numGears, limits, fullLoadCurves[0].MaxTorque)); + fullLoadCurves[(uint)gear.Gear] = IntersectFullLoadCurves(fullLoadCurves[0], maxTorque); + } + + retVal.FullLoadCurves = fullLoadCurves; + + var whr = CreateWHRData(mode.WasteHeatRecoveryData); + if (whr != null) { + whr.WHRCorrectionFactor = DeclarationData.WHTCCorrection.Lookup( + mission.MissionType.GetNonEMSMissionType(), whr.CFRural, whr.CFUrban, + whr.CFMotorway) * whr.CFColdHot * whr.CFRegPer; + } + retVal.WHRData = whr; + + return retVal; + } + + private static WHRData CreateWHRData(IWHRData whrInputData) + { + if (whrInputData == null || whrInputData.GeneratedElectricPower == null) { + return null; + } + + return new WHRData() { + CFUrban = whrInputData.UrbanCorrectionFactor, + CFRural = whrInputData.RuralCorrectionFactor, + CFMotorway = whrInputData.MotorwayCorrectionFactor, + CFColdHot = whrInputData.BFColdHot, + CFRegPer = whrInputData.CFRegPer, + WHRMap = WHRPowerReader.Create(whrInputData.GeneratedElectricPower) + }; + } + + private static NewtonMeter VehMaxTorque( + ITransmissionInputData gear, int numGears, + Dictionary<int, ITorqueLimitInputData> limits, + NewtonMeter maxEngineTorque) + { + if (gear.Gear - 1 >= numGears / 2) { + // only upper half of gears can limit if max-torque <= 0.95 of engine max torque + if (limits.ContainsKey(gear.Gear) && + limits[gear.Gear].MaxTorque <= DeclarationData.Engine.TorqueLimitVehicleFactor * maxEngineTorque) { + return limits[gear.Gear].MaxTorque; + } + } + + return null; + } + + private static NewtonMeter GbxMaxTorque( + ITransmissionInputData gear, int numGears, NewtonMeter maxEngineTorque + ) + { + if (gear.Gear - 1 < numGears / 2) { + // gears count from 1 to n, -> n entries, lower half can always limit + if (gear.MaxTorque != null) { + return gear.MaxTorque; + } + } else { + // upper half can only limit if max-torque <= 90% of engine max torque + if (gear.MaxTorque != null && gear.MaxTorque <= DeclarationData.Engine.TorqueLimitGearboxFactor * maxEngineTorque) { + return gear.MaxTorque; + } + } + + return null; + } + + public virtual GearboxData CreateGearboxData( + IGearboxDeclarationInputData gearbox, CombustionEngineData engine, double axlegearRatio, Meter dynamicTyreRadius, + VehicleCategory vehicleCategory, ITorqueConverterDeclarationInputData torqueConverter) + { + if (!gearbox.SavedInDeclarationMode) { + WarnDeclarationMode("GearboxData"); + } + var retVal = SetCommonGearboxData(gearbox); + + if (!SupportedGearboxTypes.Contains(gearbox.Type)) { + throw new VectoSimulationException("Unsupported gearbox type: {0}!", retVal.Type); + } + + var gearsInput = gearbox.Gears; + if (gearsInput.Count < 1) { + throw new VectoSimulationException( + "At least one Gear-Entry must be defined in Gearbox!"); + } + + SetDeclarationData(retVal); + + var gearDifferenceRatio = gearbox.Type.AutomaticTransmission() && gearbox.Gears.Count > 2 + ? gearbox.Gears[0].Ratio / gearbox.Gears[1].Ratio + : 1.0; + + var gears = new Dictionary<uint, GearData>(); + var tcShiftPolygon = DeclarationData.TorqueConverter.ComputeShiftPolygon(engine.FullLoadCurves[0]); + for (uint i = 0; i < gearsInput.Count; i++) { + var gear = gearsInput[(int)i]; + var lossMap = CreateGearLossMap(gear, i, false); + + var shiftPolygon = DeclarationData.Gearbox.ComputeShiftPolygon( + gearbox.Type, (int)i, engine.FullLoadCurves[i + 1], + gearsInput, engine, + axlegearRatio, dynamicTyreRadius); + + var gearData = new GearData { + ShiftPolygon = shiftPolygon, + MaxSpeed = gear.MaxInputSpeed, + Ratio = gear.Ratio, + LossMap = lossMap, + }; + + CreateATGearData(gearbox, i, gearData, tcShiftPolygon, gearDifferenceRatio, gears, vehicleCategory); + gears.Add(i + 1, gearData); + } + + retVal.Gears = gears; + if (retVal.Type.AutomaticTransmission()) { + var ratio = double.IsNaN(retVal.Gears[1].Ratio) ? 1 : retVal.Gears[1].TorqueConverterRatio / retVal.Gears[1].Ratio; + retVal.PowershiftShiftTime = DeclarationData.Gearbox.PowershiftShiftTime; + retVal.TorqueConverterData = TorqueConverterDataReader.Create( + torqueConverter.TCData, + DeclarationData.TorqueConverter.ReferenceRPM, DeclarationData.TorqueConverter.MaxInputSpeed, + ExecutionMode.Declaration, ratio, + DeclarationData.TorqueConverter.CLUpshiftMinAcceleration, + DeclarationData.TorqueConverter.CCUpshiftMinAcceleration); + retVal.TorqueConverterData.ModelName = torqueConverter.Model; + retVal.TorqueConverterData.DigestValueInput = torqueConverter.DigestValue?.DigestValue; + retVal.TorqueConverterData.CertificationMethod = torqueConverter.CertificationMethod; + retVal.TorqueConverterData.CertificationNumber = torqueConverter.CertificationNumber; + } + + return retVal; + } + + private static void CreateATGearData( + IGearboxDeclarationInputData gearbox, uint i, GearData gearData, + 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 + CretateTCFirstGearATPowerSplit(gearData, i, tcShiftPolygon); + } + if (gearbox.Type == GearboxType.ATSerial) { + if (i == 0) { + // torqueconverter is active in first gear - duplicate ratio and lossmap for torque converter mode + CreateTCFirstGearATSerial(gearData, tcShiftPolygon); + } + if (i == 1 && gearDifferenceRatio >= DeclarationData.Gearbox.TorqueConverterSecondGearThreshold(vehicleCategory)) { + // ratio between first and second gear is above threshold, torqueconverter is active in second gear as well + // -> duplicate ratio and lossmap for torque converter mode, remove locked transmission for previous gear + CreateTCSecondGearATSerial(gearData, tcShiftPolygon); + + // NOTE: the lower gear in 'gears' dictionary has index i !! + gears[i].Ratio = double.NaN; + gears[i].LossMap = null; + } + } + } + + private static void SetDeclarationData(GearboxData retVal) + { + retVal.Inertia = DeclarationData.Gearbox.Inertia; + retVal.TractionInterruption = retVal.Type.TractionInterruption(); + retVal.TorqueReserve = DeclarationData.Gearbox.TorqueReserve; + retVal.StartTorqueReserve = DeclarationData.Gearbox.TorqueReserveStart; + retVal.ShiftTime = DeclarationData.Gearbox.MinTimeBetweenGearshifts; + retVal.StartSpeed = DeclarationData.Gearbox.StartSpeed; + retVal.StartAcceleration = DeclarationData.Gearbox.StartAcceleration; + retVal.DownshiftAfterUpshiftDelay = DeclarationData.Gearbox.DownshiftAfterUpshiftDelay; + retVal.UpshiftAfterDownshiftDelay = DeclarationData.Gearbox.UpshiftAfterDownshiftDelay; + retVal.UpshiftMinAcceleration = DeclarationData.Gearbox.UpshiftMinAcceleration; + } + + public virtual AxleGearData CreateAxleGearData(IAxleGearInputData data) + { + var retVal = SetCommonAxleGearData(data); + retVal.AxleGear.LossMap = ReadAxleLossMap(data, false); + return retVal; + } + + public virtual AngledriveData CreateAngledriveData(IAngledriveInputData data) + { + return DoCreateAngledriveData(data, false); + } + + + public virtual IList<VectoRunData.AuxData> CreateAuxiliaryData( + IAuxiliariesDeclarationInputData auxInputData, + MissionType mission, VehicleClass hvdClass) + { + if (!auxInputData.SavedInDeclarationMode) { + WarnDeclarationMode("AuxiliariesData"); + } + var retVal = new List<VectoRunData.AuxData>(); + + if (auxInputData.Auxiliaries.Count != 5) { + Log.Error( + "In Declaration Mode exactly 5 Auxiliaries must be defined: Fan, Steering pump, HVAC, Electric System, Pneumatic System."); + throw new VectoException( + "In Declaration Mode exactly 5 Auxiliaries must be defined: Fan, Steering pump, HVAC, Electric System, Pneumatic System."); + } + + foreach (var auxType in EnumHelper.GetValues<AuxiliaryType>()) { + var auxData = auxInputData.Auxiliaries.FirstOrDefault(a => a.Type == auxType); + if (auxData == null) { + throw new VectoException("Auxiliary {0} not found.", auxType); + } + + var aux = new VectoRunData.AuxData { + DemandType = AuxiliaryDemandType.Constant, + Technology = auxData.Technology + }; + + mission = mission.GetNonEMSMissionType(); + switch (auxType) { + case AuxiliaryType.Fan: + aux.PowerDemand = DeclarationData.Fan.Lookup(mission, auxData.Technology.FirstOrDefault()).PowerDemand; + aux.ID = Constants.Auxiliaries.IDs.Fan; + break; + case AuxiliaryType.SteeringPump: + aux.PowerDemand = DeclarationData.SteeringPump.Lookup(mission, hvdClass, auxData.Technology); + aux.ID = Constants.Auxiliaries.IDs.SteeringPump; + break; + case AuxiliaryType.HVAC: + aux.PowerDemand = DeclarationData.HeatingVentilationAirConditioning.Lookup( + mission, + auxData.Technology.FirstOrDefault(), hvdClass).PowerDemand; + aux.ID = Constants.Auxiliaries.IDs.HeatingVentilationAirCondition; + break; + case AuxiliaryType.PneumaticSystem: + 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()).PowerDemand; + aux.ID = Constants.Auxiliaries.IDs.ElectricSystem; + break; + default: continue; + } + + retVal.Add(aux); + } + + return retVal; + } + + private void WarnDeclarationMode(string inputData) + { + Log.Warn("{0} not in Declaration Mode!", inputData); + } + + public virtual RetarderData CreateRetarderData(IRetarderInputData retarder) + { + return SetCommonRetarderData(retarder); + } + + public static List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> GetDeclarationAirResistanceCurve( + string crosswindCorrectionParameters, SquareMeter aerodynamicDragAera, Meter vehicleHeight) + { + var startSpeed = Constants.SimulationSettings.CrosswindCorrection.MinVehicleSpeed; + var maxSpeed = Constants.SimulationSettings.CrosswindCorrection.MaxVehicleSpeed; + var speedStep = Constants.SimulationSettings.CrosswindCorrection.VehicleSpeedStep; + + var maxAlpha = Constants.SimulationSettings.CrosswindCorrection.MaxAlpha; + var alphaStep = Constants.SimulationSettings.CrosswindCorrection.AlphaStep; + + var startHeightPercent = Constants.SimulationSettings.CrosswindCorrection.MinHeight; + var maxHeightPercent = Constants.SimulationSettings.CrosswindCorrection.MaxHeight; + var heightPercentStep = Constants.SimulationSettings.CrosswindCorrection.HeightStep; + var heightShare = (double)heightPercentStep / maxHeightPercent; + + var values = DeclarationData.AirDrag.Lookup(crosswindCorrectionParameters); + + // first entry (0m/s) will get CdxA of second entry. + var points = new List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> { + new CrossWindCorrectionCurveReader.CrossWindCorrectionEntry { + Velocity = 0.SI<MeterPerSecond>(), + EffectiveCrossSectionArea = 0.SI<SquareMeter>() + } + }; + + for (var speed = startSpeed; speed <= maxSpeed; speed += speedStep) { + var vVeh = speed.KMPHtoMeterPerSecond(); + + var cdASum = 0.SI<SquareMeter>(); + + for (var heightPercent = startHeightPercent; heightPercent < maxHeightPercent; heightPercent += heightPercentStep) { + var height = heightPercent / 100.0 * vehicleHeight; + var vWind = Physics.BaseWindSpeed * Math.Pow(height / Physics.BaseWindHeight, Physics.HellmannExponent); + + for (var alpha = 0; alpha <= maxAlpha; alpha += alphaStep) { + var vAirX = vVeh + vWind * Math.Cos(alpha.ToRadian()); + var vAirY = vWind * Math.Sin(alpha.ToRadian()); + + var beta = Math.Atan(vAirY / vAirX).ToDegree(); + + // ΔCdxA = A1β + A2β² + A3β³ + var deltaCdA = values.A1 * beta + values.A2 * beta * beta + values.A3 * beta * beta * beta; + + // CdxA(β) = CdxA(0) + ΔCdxA(β) + var cdA = aerodynamicDragAera + deltaCdA; + + var share = (alpha == 0 || alpha == maxAlpha ? alphaStep / 2.0 : alphaStep) / maxAlpha; + + // v_air = sqrt(v_airX²+vAirY²) + // cdASum = CdxA(β) * v_air²/v_veh² + cdASum += heightShare * share * cdA * (vAirX * vAirX + vAirY * vAirY) / (vVeh * vVeh); + } + } + + points.Add( + new CrossWindCorrectionCurveReader.CrossWindCorrectionEntry { + Velocity = vVeh, + EffectiveCrossSectionArea = cdASum + }); + } + + points[0].EffectiveCrossSectionArea = points[1].EffectiveCrossSectionArea; + return points; + } + + public virtual PTOData CreatePTOTransmissionData(IPTOTransmissionInputData pto) + { + if (pto.PTOTransmissionType != "None") { + return new PTOData { + TransmissionType = pto.PTOTransmissionType, + LossMap = PTOIdleLossMapReader.GetZeroLossMap(), + }; + } + + return null; + } + + public virtual AirdragData CreateAirdragData( + IAirdragDeclarationInputData airdragInputData, Mission mission, + Segment segment) + { + if (airdragInputData == null || airdragInputData.AirDragArea == null) { + return DefaultAirdragData(mission); + } + + var retVal = SetCommonAirdragData(airdragInputData); + + retVal.DeclaredAirdragArea = mission.MissionType == MissionType.Construction + ? mission.DefaultCDxA + : airdragInputData.AirDragArea; + + var aerodynamicDragArea = retVal.DeclaredAirdragArea + mission.Trailer.Sum(t => t.DeltaCdA).DefaultIfNull(0); + + retVal.CrossWindCorrectionCurve = + new CrosswindCorrectionCdxALookup( + aerodynamicDragArea, + GetDeclarationAirResistanceCurve( + mission.CrossWindCorrectionParameters, aerodynamicDragArea, mission.VehicleHeight), + CrossWindCorrectionMode.DeclarationModeCorrection); + return retVal; + } + + protected virtual AirdragData DefaultAirdragData(Mission mission) + { + var aerodynamicDragArea = mission.DefaultCDxA + mission.Trailer.Sum(t => t.DeltaCdA).DefaultIfNull(0); + + return new AirdragData() { + CertificationMethod = CertificationMethod.StandardValues, + DeclaredAirdragArea = mission.DefaultCDxA, + CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup( + aerodynamicDragArea, + GetDeclarationAirResistanceCurve( + mission.CrossWindCorrectionParameters, aerodynamicDragArea, mission.VehicleHeight), + CrossWindCorrectionMode.DeclarationModeCorrection) + }; + } + + public virtual ISSMInputs CreateSSMModelParameters(IVehicleData vehicleData, IFuelProperties heatingFuel) + { + return new SSMInputs(vehicleData, null, heatingFuel) { + Technologies = DeclarationData.BusAuxiliaries.SSMTechnologyList, + DefaultConditions = new EnvironmentalConditionMapEntry( + Constants.BusAuxiliaries.SteadyStateModel.DefaultTemperature, + Constants.BusAuxiliaries.SteadyStateModel.DefaultSolar, + 1.0), + EnvironmentalConditionsMap = DeclarationData.BusAuxiliaries.DefaultEnvironmentalConditions, + HeatingBoundaryTemperature = Constants.BusAuxiliaries.SteadyStateModel.HeatingBoundaryTemperature, + CoolingBoundaryTemperature = Constants.BusAuxiliaries.SteadyStateModel.CoolingBoundaryTemperature, + HighVentilation = Constants.BusAuxiliaries.SteadyStateModel.HighVentilation, + LowVentilation = Constants.BusAuxiliaries.SteadyStateModel.LowVentilation, + SpecificVentilationPower = Constants.BusAuxiliaries.SteadyStateModel.SpecificVentilationPower, + + // TODO! MQ 2019-19-29 Compressor Type and CompressorCapacity from input data? + CompressorType = ACCompressorType.TwoStage, // "2-stage", + CompressorCapacity = 18.SI(Unit.SI.Kilo.Watt).Cast<Watt>(), + + AuxHeaterEfficiency = Constants.BusAuxiliaries.SteadyStateModel.AuxHeaterEfficiency, + FuelFiredHeaterPower = Constants.BusAuxiliaries.SteadyStateModel.FuelFiredHeaterPower, + FuelEnergyToHeatToCoolant = Constants.BusAuxiliaries.Heater.FuelEnergyToHeatToCoolant, + CoolantHeatTransferredToAirCabinHeater = Constants.BusAuxiliaries.Heater.CoolantHeatTransferredToAirCabinHeater, + GFactor = Constants.BusAuxiliaries.SteadyStateModel.GFactor, + VentilationOnDuringHeating = true, + VentilationWhenBothHeatingAndACInactive = true, + VentilationDuringAC = true, + VentilationDuringHeating = VentilationLevel.High, + VentilationDuringCooling = VentilationLevel.High, + VentilationFlowSettingWhenHeatingAndACInactive = VentilationLevel.High, + MaxPossibleBenefitFromTechnologyList = + Constants.BusAuxiliaries.SteadyStateModel.MaxPossibleBenefitFromTechnologyList, + }; + } + + public virtual IPneumaticsConsumersDemand CreatePneumaticAuxConfig(RetarderType retarderType) + { + return new PneumaticsConsumersDemand() { + AdBlueInjection = Constants.BusAuxiliaries.PneumaticConsumersDemands.AdBlueInjection, + AirControlledSuspension = Constants.BusAuxiliaries.PneumaticConsumersDemands.AirControlledSuspension, + Braking = retarderType == RetarderType.None ? + Constants.BusAuxiliaries.PneumaticConsumersDemands.BrakingNoRetarder : + Constants.BusAuxiliaries.PneumaticConsumersDemands.BrakingWithRetarder, + BreakingWithKneeling = Constants.BusAuxiliaries.PneumaticConsumersDemands.BreakingAndKneeling, + DeadVolBlowOuts = Constants.BusAuxiliaries.PneumaticConsumersDemands.DeadVolBlowOuts, + DeadVolume = Constants.BusAuxiliaries.PneumaticConsumersDemands.DeadVolume, + NonSmartRegenFractionTotalAirDemand = Constants.BusAuxiliaries.PneumaticConsumersDemands.NonSmartRegenFractionTotalAirDemand, + SmartRegenFractionTotalAirDemand = Constants.BusAuxiliaries.PneumaticConsumersDemands.SmartRegenFractionTotalAirDemand, + OverrunUtilisationForCompressionFraction = Constants.BusAuxiliaries.PneumaticConsumersDemands.OverrunUtilisationForCompressionFraction, + DoorOpening = Constants.BusAuxiliaries.PneumaticConsumersDemands.DoorOpening, + StopBrakeActuation = Constants.BusAuxiliaries.PneumaticConsumersDemands.StopBrakeActuation, + }; + } + } +} diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs index 9670c3d91e..a55c97e4d1 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs @@ -123,14 +123,14 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter break; case CrossWindCorrectionMode.DeclarationModeCorrection: var airDragArea = airdragData.AirDragArea ?? - DeclarationData.Segments.LookupCdA( + DeclarationData.TruckSegments.LookupCdA( data.VehicleCategory, data.AxleConfiguration, data.GrossVehicleMassRating, false); - var height = data.Height ?? DeclarationData.Segments.LookupHeight( + var height = data.Height ?? DeclarationData.TruckSegments.LookupHeight( data.VehicleCategory, data.AxleConfiguration, data.GrossVehicleMassRating, false); retVal.CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup( airDragArea, - DeclarationDataAdapter.GetDeclarationAirResistanceCurve( + DeclarationDataAdapterTruck.GetDeclarationAirResistanceCurve( GetAirdragParameterSet( data.VehicleCategory, data.AxleConfiguration, data.Components.AxleWheels.AxlesEngineering.Count), airDragArea, height), diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/IDeclarationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/IDeclarationDataAdapter.cs new file mode 100644 index 0000000000..0fdf585e6a --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/IDeclarationDataAdapter.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data; + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter { + public interface IDeclarationDataAdapter + { + DriverData CreateDriverData(); + VehicleData CreateVehicleData(IVehicleDeclarationInputData vehicle, Mission mission, Kilogram loading); + AirdragData CreateAirdragData(IAirdragDeclarationInputData airdragData, Mission mission, Segment segment); + AxleGearData CreateAxleGearData(IAxleGearInputData axlegearData); + AngledriveData CreateAngledriveData(IAngledriveInputData angledriveData); + CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, IEngineModeDeclarationInputData engineMode, Mission mission); + + GearboxData CreateGearboxData( + IGearboxDeclarationInputData gearboxData, CombustionEngineData engineData, double axleGearRatio, Meter rDyn, + VehicleCategory vehicleCategory, ITorqueConverterDeclarationInputData torqueConverterData); + + RetarderData CreateRetarderData(IRetarderInputData retarderData); + PTOData CreatePTOTransmissionData(IPTOTransmissionInputData ptoData); + IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxData, MissionType missionType, VehicleClass vehicleClass); + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/AbstractDeclarationVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/AbstractDeclarationVectoRunDataFactory.cs new file mode 100644 index 0000000000..177eae9994 --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/Impl/AbstractDeclarationVectoRunDataFactory.cs @@ -0,0 +1,146 @@ +using System.Collections.Generic; +using System.Linq; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCore.InputData.Reader.ComponentData; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.OutputData; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.Reader.Impl { + public abstract class AbstractDeclarationVectoRunDataFactory : LoggingObject, IVectoRunDataFactory + { + protected static readonly object CyclesCacheLock = new object(); + + protected static readonly Dictionary<MissionType, DrivingCycleData> CyclesCache = + new Dictionary<MissionType, DrivingCycleData>(); + + protected readonly IDeclarationInputDataProvider InputDataProvider; + + protected IDeclarationReport Report; + protected abstract IDeclarationDataAdapter DataAdapter { get; } + + protected Segment _segment; + protected DriverData _driverdata; + protected AirdragData _airdragData; + protected AxleGearData _axlegearData; + protected AngledriveData _angledriveData; + protected GearboxData _gearboxData; + protected RetarderData _retarderData; + protected PTOData _ptoTransmissionData; + protected PTOData _municipalPtoTransmissionData; + //protected Exception InitException; + + protected AbstractDeclarationVectoRunDataFactory( + IDeclarationInputDataProvider dataProvider, IDeclarationReport report) + { + InputDataProvider = dataProvider; + Report = report; + + //try { + // Initialize(); + // if (Report != null) { + // InitializeReport(); + // } + //} catch (Exception e) { + // InitException = e; + //} + } + + public IEnumerable<VectoRunData> NextRun() + { + + Initialize(); + if (Report != null) { + InitializeReport(); + } + + return GetNextRun(); + } + + protected abstract IEnumerable<VectoRunData> GetNextRun(); + + protected virtual void Initialize() + { + var vehicle = InputDataProvider.JobInputData.Vehicle; + if (vehicle.ExemptedVehicle) { + return; + } + + _segment = GetSegment(vehicle); + _driverdata = DataAdapter.CreateDriverData(); + _driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(_segment.AccelerationFile); + var tempVehicle = DataAdapter.CreateVehicleData(vehicle, _segment.Missions.First(), + _segment.Missions.First().Loadings.First().Value); + _airdragData = DataAdapter.CreateAirdragData(vehicle.Components.AirdragInputData, + _segment.Missions.First(), _segment); + _axlegearData = DataAdapter.CreateAxleGearData(InputDataProvider.JobInputData.Vehicle.Components.AxleGearInputData); + _angledriveData = DataAdapter.CreateAngledriveData(InputDataProvider.JobInputData.Vehicle.Components.AngledriveInputData); + var tmpEngine = DataAdapter.CreateEngineData( + vehicle, vehicle.Components.EngineInputData.EngineModes[0], _segment.Missions.First()); + _gearboxData = DataAdapter.CreateGearboxData(vehicle.Components.GearboxInputData, tmpEngine, + _axlegearData.AxleGear.Ratio, + tempVehicle.DynamicTyreRadius, tempVehicle.VehicleCategory, vehicle.Components.TorqueConverterInputData); + _retarderData = DataAdapter.CreateRetarderData(vehicle.Components.RetarderInputData); + + _ptoTransmissionData = DataAdapter.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData); + + _municipalPtoTransmissionData = CreateDefaultPTOData(); + } + + protected abstract Segment GetSegment(IVehicleDeclarationInputData vehicle); + + + protected virtual void InitializeReport() + { + VectoRunData powertrainConfig; + List<List<FuelData.Entry>> fuels; + if (InputDataProvider.JobInputData.Vehicle.ExemptedVehicle) { + powertrainConfig = new VectoRunData() { + Exempted = true, + VehicleData = DataAdapter.CreateVehicleData(InputDataProvider.JobInputData.Vehicle, null, null), + InputDataHash = InputDataProvider.XMLHash + }; + fuels = new List<List<FuelData.Entry>>(); + } else { + var vehicle = InputDataProvider.JobInputData.Vehicle; + powertrainConfig = new VectoRunData() { + VehicleData = + DataAdapter.CreateVehicleData( + InputDataProvider.JobInputData.Vehicle, _segment.Missions.First(), + _segment.Missions.First().Loadings.First().Value), + AirdragData = _airdragData, + EngineData = DataAdapter.CreateEngineData(vehicle, vehicle.Components.EngineInputData.EngineModes[0], _segment.Missions.First()), + GearboxData = _gearboxData, + AxleGearData = _axlegearData, + Retarder = _retarderData, + Aux = + DataAdapter.CreateAuxiliaryData( + InputDataProvider.JobInputData.Vehicle.Components.AuxiliaryInputData, + _segment.Missions.First().MissionType, + _segment.VehicleClass), + PTO = _ptoTransmissionData, + InputDataHash = InputDataProvider.XMLHash + }; + powertrainConfig.VehicleData.VehicleClass = _segment.VehicleClass; + fuels = vehicle.Components.EngineInputData.EngineModes.Select(x => x.Fuels.Select(f => DeclarationData.FuelData.Lookup(f.FuelType, vehicle.TankSystem)).ToList()) + .ToList(); + } + Report.InitializeReport(powertrainConfig, fuels); + } + + protected virtual PTOData CreateDefaultPTOData() + { + return new PTOData() { + TransmissionType = DeclarationData.PTO.DefaultPTOTechnology, + LossMap = PTOIdleLossMapReader.ReadFromStream(RessourceHelper.ReadStream(DeclarationData.PTO.DefaultPTOIdleLosses)), + PTOCycle = + DrivingCycleDataReader.ReadFromStream(RessourceHelper.ReadStream(DeclarationData.PTO.DefaultPTOActivationCycle), + CycleType.PTO, "PTO", false) + }; + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeBusVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeBusVectoRunDataFactory.cs new file mode 100644 index 0000000000..342dd7f715 --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeBusVectoRunDataFactory.cs @@ -0,0 +1,104 @@ +using System.Collections.Generic; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCore.InputData.Reader.ComponentData; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.OutputData; + +namespace TUGraz.VectoCore.InputData.Reader.Impl { + public class DeclarationModeBusVectoRunDataFactory : AbstractDeclarationVectoRunDataFactory + { + protected DeclarationDataAdapterPrimaryBus _dao = new DeclarationDataAdapterPrimaryBus(); + + public DeclarationModeBusVectoRunDataFactory(IDeclarationInputDataProvider dataProvider, IDeclarationReport report) : + base(dataProvider, report) + { + + } + + #region Overrides of AbstractDeclarationVectoRunDataFactory + + protected override IDeclarationDataAdapter DataAdapter { get { return _dao; } } + + #endregion + + protected override IEnumerable<VectoRunData> GetNextRun() + { + if (InputDataProvider.JobInputData.Vehicle.VehicleCategory == VehicleCategory.HeavyBusPrimaryVehicle) { + return VectoRunDataHeavyBusPrimary(); + } + return new List<VectoRunData>(); + } + + protected override Segment GetSegment(IVehicleDeclarationInputData vehicle) + { + if (vehicle.VehicleCategory != VehicleCategory.HeavyBusPrimaryVehicle) { + throw new VectoException("Invalid vehicle category for bus factory! {0}", vehicle.VehicleCategory.GetCategoryName()); + } + + var segment = DeclarationData.BusSegments.Lookup( + vehicle.VehicleCategory, vehicle.AxleConfiguration, vehicle.Articulated, vehicle.FloorType, false, true); + if (!segment.Found) { + throw new VectoException( + "no segment found for vehicle configruation: vehicle category: {0}, axle configuration: {1}, articulated: {2}, primary", + vehicle.VehicleCategory, vehicle.AxleConfiguration, + vehicle.Articulated); + } + + return segment; + } + + private IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary() + { + var vehicle = InputDataProvider.JobInputData.Vehicle; + var engine = vehicle.Components.EngineInputData; + var engineModes = engine.EngineModes; + + for (var modeIdx = 0; modeIdx < engineModes.Count; modeIdx++) { + var engineMode = engineModes[modeIdx]; + foreach (var mission in _segment.Missions) { + DrivingCycleData cycle; + lock (CyclesCacheLock) { + if (CyclesCache.ContainsKey(mission.MissionType)) { + cycle = CyclesCache[mission.MissionType]; + } else { + cycle = DrivingCycleDataReader.ReadFromStream(mission.CycleFile, CycleType.DistanceBased, "", false); + CyclesCache.Add(mission.MissionType, cycle); + } + } + + foreach (var loading in mission.Loadings) { + var simulationRunData = new VectoRunData { + Loading = loading.Key, + VehicleData = DataAdapter.CreateVehicleData(vehicle, mission, loading.Value), + AirdragData = _dao.CreateAirdragData(mission), + EngineData = DataAdapter.CreateEngineData(InputDataProvider.JobInputData.Vehicle, engineMode, mission), + GearboxData = _gearboxData, + AxleGearData = _axlegearData, + AngledriveData = _angledriveData, + Aux = _dao.CreateAuxiliaryData(), + Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), + Retarder = _retarderData, + DriverData = _driverdata, + ExecutionMode = ExecutionMode.Declaration, + JobName = InputDataProvider.JobInputData.JobName, + ModFileSuffix = (engineModes.Count > 1 ? string.Format("_EngineMode{0}_", modeIdx) : "") + loading.Key.ToString(), + Report = Report, + Mission = mission, + InputDataHash = InputDataProvider.XMLHash, + SimulationType = SimulationType.DistanceCycle + }; + simulationRunData.EngineData.FuelMode = modeIdx; + simulationRunData.VehicleData.VehicleClass = _segment.VehicleClass; + yield return simulationRunData; + } + } + } + } + + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeTruckVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeTruckVectoRunDataFactory.cs new file mode 100644 index 0000000000..0d5431f9e6 --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeTruckVectoRunDataFactory.cs @@ -0,0 +1,166 @@ +/* +* This file is part of VECTO. +* +* Copyright © 2012-2019 European Union +* +* Developed by Graz University of Technology, +* Institute of Internal Combustion Engines and Thermodynamics, +* Institute of Technical Informatics +* +* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved +* by the European Commission - subsequent versions of the EUPL (the "Licence"); +* You may not use VECTO except in compliance with the Licence. +* You may obtain a copy of the Licence at: +* +* https://joinup.ec.europa.eu/community/eupl/og_page/eupl +* +* Unless required by applicable law or agreed to in writing, VECTO +* distributed under the Licence is distributed on an "AS IS" basis, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the Licence for the specific language governing permissions and +* limitations under the Licence. +* +* Authors: +* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology +* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology +* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology +* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology +* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology +* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology +*/ + +using System; +using System.Collections.Generic; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.Reader.ComponentData; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.OutputData; + + +namespace TUGraz.VectoCore.InputData.Reader.Impl +{ + public class DeclarationModeTruckVectoRunDataFactory : AbstractDeclarationVectoRunDataFactory + { + DeclarationDataAdapterTruck _dao = new DeclarationDataAdapterTruck(); + + internal DeclarationModeTruckVectoRunDataFactory( + IDeclarationInputDataProvider dataProvider, IDeclarationReport report) : base(dataProvider, report) + { } + + #region Overrides of AbstractDeclarationVectoRunDataFactory + + protected override IDeclarationDataAdapter DataAdapter { get { return _dao; } } + + #endregion + + protected override Segment GetSegment(IVehicleDeclarationInputData vehicle) + { + if (!vehicle.VehicleCategory.IsTruck()) { + throw new VectoException("Invalid vehicle category for truck factory! {0}", vehicle.VehicleCategory.GetCategoryName()); + } + var segment = DeclarationData.TruckSegments.Lookup( + vehicle.VehicleCategory, vehicle.AxleConfiguration, vehicle.GrossVehicleMassRating, vehicle.CurbMassChassis, + vehicle.VocationalVehicle); + + if (!segment.Found) { + throw new VectoException( + "no segment found for vehicle configruation: vehicle category: {0}, axle configuration: {1}, GVMR: {2}", + vehicle.VehicleCategory, vehicle.AxleConfiguration, + vehicle.GrossVehicleMassRating); + } + + return segment; + } + + + protected override IEnumerable<VectoRunData> GetNextRun() + { + //if (InitException != null) { + // throw InitException; + //} + + if (InputDataProvider.JobInputData.Vehicle.ExemptedVehicle) { + yield return new VectoRunData { + Exempted = true, + Report = Report, + Mission = new Mission() { MissionType = MissionType.ExemptedMission}, + VehicleData = DataAdapter.CreateVehicleData(InputDataProvider.JobInputData.Vehicle, null, null), + InputDataHash = InputDataProvider.XMLHash + }; + } else { + foreach (var vectoRunData in VectoRunDataTruckNonExempted()) { + yield return vectoRunData; + } + } + } + + + + private IEnumerable<VectoRunData> VectoRunDataTruckNonExempted() + { + + var vehicle = InputDataProvider.JobInputData.Vehicle; + + var engine = InputDataProvider.JobInputData.Vehicle.Components.EngineInputData; + var engineModes = engine.EngineModes; + + //foreach (var engineMode in engineModes) { + for(var modeIdx = 0; modeIdx < engineModes.Count; modeIdx++) { + var engineMode = engineModes[modeIdx]; + foreach (var mission in _segment.Missions) { + if (mission.MissionType.IsEMS() && + engine.RatedPowerDeclared.IsSmaller(DeclarationData.MinEnginePowerForEMS)) { + continue; + } + + DrivingCycleData cycle; + lock (CyclesCacheLock) { + if (CyclesCache.ContainsKey(mission.MissionType)) { + cycle = CyclesCache[mission.MissionType]; + } else { + cycle = DrivingCycleDataReader.ReadFromStream(mission.CycleFile, CycleType.DistanceBased, "", false); + CyclesCache.Add(mission.MissionType, cycle); + } + } + foreach (var loading in mission.Loadings) { + var simulationRunData = new VectoRunData { + Loading = loading.Key, + VehicleData = DataAdapter.CreateVehicleData(vehicle, mission, loading.Value), + AirdragData = DataAdapter.CreateAirdragData(vehicle.Components.AirdragInputData, mission, _segment), + EngineData = DataAdapter.CreateEngineData(InputDataProvider.JobInputData.Vehicle, engineMode, mission), // _engineData.Copy(), // a copy is necessary because every run has a different correction factor! + GearboxData = _gearboxData, + AxleGearData = _axlegearData, + AngledriveData = _angledriveData, + Aux = DataAdapter.CreateAuxiliaryData( + vehicle.Components.AuxiliaryInputData, mission.MissionType, + _segment.VehicleClass), + Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), + Retarder = _retarderData, + DriverData = _driverdata, + ExecutionMode = ExecutionMode.Declaration, + JobName = InputDataProvider.JobInputData.JobName, + ModFileSuffix = (engineModes.Count > 1 ? string.Format("_EngineMode{0}_", modeIdx) : "") + loading.Key.ToString(), + Report = Report, + Mission = mission, + PTO = mission.MissionType == MissionType.MunicipalUtility + ? _municipalPtoTransmissionData + : _ptoTransmissionData, + InputDataHash = InputDataProvider.XMLHash, + SimulationType = SimulationType.DistanceCycle + }; + simulationRunData.EngineData.FuelMode = modeIdx; + simulationRunData.VehicleData.VehicleClass = _segment.VehicleClass; + yield return simulationRunData; + } + } + } + } + + } +} diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs deleted file mode 100644 index 53961372ca..0000000000 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs +++ /dev/null @@ -1,260 +0,0 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2019 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology -*/ - -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; -using TUGraz.VectoCore.InputData.Reader.ComponentData; -using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; -using TUGraz.VectoCore.Models.Declaration; -using TUGraz.VectoCore.Models.Simulation.Data; -using TUGraz.VectoCore.Models.SimulationComponent.Data; -using TUGraz.VectoCore.OutputData; -using TUGraz.VectoCore.Utils; - - -namespace TUGraz.VectoCore.InputData.Reader.Impl -{ - public class DeclarationModeVectoRunDataFactory : LoggingObject, IVectoRunDataFactory - { - private static readonly object CyclesCacheLock = new object(); - - private static readonly Dictionary<MissionType, DrivingCycleData> CyclesCache = - new Dictionary<MissionType, DrivingCycleData>(); - - protected readonly IDeclarationInputDataProvider InputDataProvider; - - protected IDeclarationReport Report; - private DeclarationDataAdapter _dao; - private Segment _segment; - private DriverData _driverdata; - private AirdragData _airdragData; - private AxleGearData _axlegearData; - private AngledriveData _angledriveData; - private GearboxData _gearboxData; - private RetarderData _retarderData; - private PTOData _ptoTransmissionData; - private PTOData _municipalPtoTransmissionData; - private Exception InitException; - - internal DeclarationModeVectoRunDataFactory(IDeclarationInputDataProvider dataProvider, IDeclarationReport report) - { - InputDataProvider = dataProvider; - Report = report; - - try { - Initialize(); - if (Report != null) { - InitializeReport(); - } - } catch (Exception e) { - InitException = e; - } - } - - private void Initialize() - { - _dao = new DeclarationDataAdapter(); - var vehicle = InputDataProvider.JobInputData.Vehicle; - if (vehicle.ExemptedVehicle) { - return; - } - _segment = GetVehicleClassification(vehicle.VehicleCategory, - vehicle.AxleConfiguration, - vehicle.GrossVehicleMassRating, - vehicle.CurbMassChassis, - vehicle.VocationalVehicle); - if (!_segment.Found) { - throw new VectoException( - "no segment found for vehicle configruation: vehicle category: {0}, axle configuration: {1}, GVMR: {2}", - vehicle.VehicleCategory, vehicle.AxleConfiguration, - vehicle.GrossVehicleMassRating); - } - _driverdata = _dao.CreateDriverData(); - _driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(_segment.AccelerationFile); - var tempVehicle = _dao.CreateVehicleData(vehicle, _segment.Missions.First(), - _segment.Missions.First().Loadings.First().Value); - _airdragData = _dao.CreateAirdragData(vehicle.Components.AirdragInputData, - _segment.Missions.First(), _segment); - _axlegearData = _dao.CreateAxleGearData(InputDataProvider.JobInputData.Vehicle.Components.AxleGearInputData); - _angledriveData = _dao.CreateAngledriveData(InputDataProvider.JobInputData.Vehicle.Components.AngledriveInputData); - var tmpEngine = _dao.CreateEngineData( - vehicle, vehicle.Components.EngineInputData.EngineModes[0], _segment.Missions.First()); - _gearboxData = _dao.CreateGearboxData(vehicle.Components.GearboxInputData, tmpEngine, - _axlegearData.AxleGear.Ratio, - tempVehicle.DynamicTyreRadius, tempVehicle.VehicleCategory, vehicle.Components.TorqueConverterInputData); - _retarderData = _dao.CreateRetarderData(vehicle.Components.RetarderInputData); - - _ptoTransmissionData = _dao.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData); - - _municipalPtoTransmissionData = CreateDefaultPTOData(); - } - - private void InitializeReport() - { - VectoRunData powertrainConfig; - List<List<FuelData.Entry>> fuels; - if (InputDataProvider.JobInputData.Vehicle.ExemptedVehicle) { - powertrainConfig = new VectoRunData() { - Exempted = true, - VehicleData = _dao.CreateVehicleData(InputDataProvider.JobInputData.Vehicle, null, null), - InputDataHash = InputDataProvider.XMLHash - }; - fuels = new List<List<FuelData.Entry>>(); - } else { - var vehicle = InputDataProvider.JobInputData.Vehicle; - powertrainConfig = new VectoRunData() { - VehicleData = - _dao.CreateVehicleData( - InputDataProvider.JobInputData.Vehicle, _segment.Missions.First(), - _segment.Missions.First().Loadings.First().Value), - AirdragData = _airdragData, - EngineData = _dao.CreateEngineData(vehicle, vehicle.Components.EngineInputData.EngineModes[0], _segment.Missions.First()), - GearboxData = _gearboxData, - AxleGearData = _axlegearData, - Retarder = _retarderData, - Aux = - _dao.CreateAuxiliaryData( - InputDataProvider.JobInputData.Vehicle.Components.AuxiliaryInputData, - _segment.Missions.First().MissionType, - _segment.VehicleClass), - PTO = _ptoTransmissionData, - InputDataHash = InputDataProvider.XMLHash - }; - powertrainConfig.VehicleData.VehicleClass = _segment.VehicleClass; - fuels = vehicle.Components.EngineInputData.EngineModes.Select(x => x.Fuels.Select(f => DeclarationData.FuelData.Lookup(f.FuelType, vehicle.TankSystem)).ToList()) - .ToList(); - } - Report.InitializeReport(powertrainConfig, fuels); - } - - public IEnumerable<VectoRunData> NextRun() - { - if (InitException != null) { - throw InitException; - } - - if (InputDataProvider.JobInputData.Vehicle.ExemptedVehicle) { - yield return new VectoRunData { - Exempted = true, - Report = Report, - Mission = new Mission() { MissionType = MissionType.ExemptedMission}, - VehicleData = _dao.CreateVehicleData(InputDataProvider.JobInputData.Vehicle, null, null), - InputDataHash = InputDataProvider.XMLHash - }; - } else { - foreach (var vectoRunData in VectoRunDataNonExempted()) - yield return vectoRunData; - } - } - - private IEnumerable<VectoRunData> VectoRunDataNonExempted() - { - - var vehicle = InputDataProvider.JobInputData.Vehicle; - - var engine = InputDataProvider.JobInputData.Vehicle.Components.EngineInputData; - var engineModes = engine.EngineModes; - - //foreach (var engineMode in engineModes) { - for(var modeIdx = 0; modeIdx < engineModes.Count; modeIdx++) { - var engineMode = engineModes[modeIdx]; - foreach (var mission in _segment.Missions) { - if (mission.MissionType.IsEMS() && - engine.RatedPowerDeclared.IsSmaller(DeclarationData.MinEnginePowerForEMS)) { - continue; - } - - DrivingCycleData cycle; - lock (CyclesCacheLock) { - if (CyclesCache.ContainsKey(mission.MissionType)) { - cycle = CyclesCache[mission.MissionType]; - } else { - cycle = DrivingCycleDataReader.ReadFromStream(mission.CycleFile, CycleType.DistanceBased, "", false); - CyclesCache.Add(mission.MissionType, cycle); - } - } - foreach (var loading in mission.Loadings) { - var simulationRunData = new VectoRunData { - Loading = loading.Key, - VehicleData = _dao.CreateVehicleData(vehicle, mission, loading.Value), - AirdragData = _dao.CreateAirdragData(vehicle.Components.AirdragInputData, mission, _segment), - EngineData = _dao.CreateEngineData(InputDataProvider.JobInputData.Vehicle, engineMode, mission), // _engineData.Copy(), // a copy is necessary because every run has a different correction factor! - GearboxData = _gearboxData, - AxleGearData = _axlegearData, - AngledriveData = _angledriveData, - Aux = _dao.CreateAuxiliaryData( - vehicle.Components.AuxiliaryInputData, mission.MissionType, - _segment.VehicleClass), - Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), - Retarder = _retarderData, - DriverData = _driverdata, - ExecutionMode = ExecutionMode.Declaration, - JobName = InputDataProvider.JobInputData.JobName, - ModFileSuffix = (engineModes.Count > 1 ? string.Format("_EngineMode{0}_", modeIdx) : "") + loading.Key.ToString(), - Report = Report, - Mission = mission, - PTO = mission.MissionType == MissionType.MunicipalUtility - ? _municipalPtoTransmissionData - : _ptoTransmissionData, - InputDataHash = InputDataProvider.XMLHash, - SimulationType = SimulationType.DistanceCycle - }; - simulationRunData.EngineData.FuelMode = modeIdx; - simulationRunData.VehicleData.VehicleClass = _segment.VehicleClass; - yield return simulationRunData; - } - } - } - } - - private PTOData CreateDefaultPTOData() - { - return new PTOData() { - TransmissionType = DeclarationData.PTO.DefaultPTOTechnology, - LossMap = PTOIdleLossMapReader.ReadFromStream(RessourceHelper.ReadStream(DeclarationData.PTO.DefaultPTOIdleLosses)), - PTOCycle = - DrivingCycleDataReader.ReadFromStream(RessourceHelper.ReadStream(DeclarationData.PTO.DefaultPTOActivationCycle), - CycleType.PTO, "PTO", false) - }; - } - - internal Segment GetVehicleClassification(VehicleCategory category, AxleConfiguration axles, Kilogram grossMassRating, - Kilogram curbWeight, bool vocational) - { - return DeclarationData.Segments.Lookup(category, axles, grossMassRating, curbWeight, vocational); - } - } -} diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactory.cs index 89be51f0da..6d3bfc2b07 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactory.cs @@ -59,7 +59,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl protected PTOData PTOTransmissionData; protected List<VectoRunData.AuxData> AuxVTP; protected Segment Segment; - protected DeclarationDataAdapter Dao; + protected DeclarationDataAdapterTruck Dao; protected Exception InitException; public IVTPReport Report; @@ -111,9 +111,9 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl protected void Initialize() { - Dao = new DeclarationDataAdapter(); + Dao = new DeclarationDataAdapterTruck(); var vehicle = JobInputData.Vehicle; - Segment = DeclarationData.Segments.Lookup( + Segment = DeclarationData.TruckSegments.Lookup( vehicle.VehicleCategory, vehicle.AxleConfiguration, vehicle.GrossVehicleMassRating, diff --git a/VectoCore/VectoCore/Models/Declaration/BusSegments.cs b/VectoCore/VectoCore/Models/Declaration/BusSegments.cs index 207efd2350..c8a8936ef0 100644 --- a/VectoCore/VectoCore/Models/Declaration/BusSegments.cs +++ b/VectoCore/VectoCore/Models/Declaration/BusSegments.cs @@ -1,13 +1,136 @@ using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; using TUGraz.VectoCommon.BusAuxiliaries; using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public sealed class BusSegments + public sealed class BusSegments : LookupData<VehicleCategory, AxleConfiguration, bool, FloorType, bool, bool, Segment> { - public Segment Lookup(VehicleCategory vehicleCategory, AxleConfiguration axleConfiguration, bool articulated, FloorType entrance, bool doubleDecker) + private DataTable _segmentTable; + + + #region Overrides of LookupData + + protected override string ResourceId + { + get { return DeclarationData.DeclarationDataResourcePrefix + ".HeavyBusSegmentationTable.csv"; } + } + + protected override string ErrorMessage { + get { + return + "ERROR: Could not find the declaration segment for vehicle. Category: {0}, AxleConfiguration: {1}, GrossVehicleWeight: {2}"; + } + } + protected override void ParseData(DataTable table) { - throw new NotImplementedException(); + _segmentTable = table.Copy(); + } + + public override Segment Lookup(VehicleCategory vehicleCategory, AxleConfiguration axleConfiguration, bool articulated, FloorType entrance, bool doubleDecker, bool primaryVehicle) + { + if (primaryVehicle) { + return LookupPrimaryVehicle(vehicleCategory, axleConfiguration, articulated); + } + throw new NotImplementedException("Completed Vechiles not implemented"); + } + + #endregion + + private Segment LookupPrimaryVehicle(VehicleCategory vehicleCategory, AxleConfiguration axleConfiguration, bool articulated) + { + var rows = _segmentTable.AsEnumerable().Where( + r => { + var productionState = r.Field<string>("productionstage").ToInt(0); + var articulatedStr = r.Field<string>("articulated"); + var articulatedB = articulatedStr == "-" ? (bool?)null : int.Parse(articulatedStr) != 0; + var numAxles = r.Field<string>("numaxles").ToInt(0); + return productionState == 1 && + (!articulatedB.HasValue || articulatedB == articulated) && + axleConfiguration.NumAxles() == numAxles; + }).ToList(); + if (rows.Count == 0) { + return new Segment() {Found = false}; + } + var firstRow = rows.First(); + var segment = new Segment { + Found = true, + GrossVehicleWeightMin = 0.SI<Kilogram>(), + GrossVehicleWeightMax = firstRow.ParseDouble("tpmlm_max").SI(Unit.SI.Ton).Cast<Kilogram>(), + VehicleCategory = vehicleCategory, + AxleConfiguration = axleConfiguration, + VehicleClass = VehicleClassHelper.Parse(firstRow.Field<string>("hdvsupergroup")), + AccelerationFile = + RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".VACC." + + firstRow.Field<string>(".vaccfile")), + Missions = CreateMissions(rows), + DesignSpeed = firstRow.ParseDouble("designspeed").KMPHtoMeterPerSecond(), + }; + + return segment; + } + + private Mission[] CreateMissions(List<DataRow> rows) + { + var missionTypes = Enum.GetValues(typeof(MissionType)).Cast<MissionType>().Where( + m => m.IsDeclarationMission() && m != MissionType.ExemptedMission && + rows.First().Table.Columns.Contains(m.ToString())).ToList(); + var missions = new List<Mission>(); + + foreach (var row in rows) { + foreach (var missionType in missionTypes) { + if (string.IsNullOrWhiteSpace(row.Field<string>(missionType.ToString()))) { + continue; + } + var busArea = (row.ParseDouble("length").SI<Meter>() - Constants.BusParameters.DriverCompartmentLength) * + row.ParseDouble("width").SI<Meter>(); + var passengerDensity = row.ParseDouble(missionType.ToString()).SI<PerSquareMeter>(); + var passengerCount = (busArea * passengerDensity).Value(); + var refLoad = passengerCount * missionType.GetAveragePassengerMass(); + var mission = new Mission { + MissionType = missionType, + CrossWindCorrectionParameters = row.Field<string>("crosswindcorrection"), + CycleFile = + RessourceHelper.ReadStream( + DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + + missionType.ToString().Replace("EMS", "") + + Constants.FileExtensions.CycleFile), + AxleWeightDistribution = GetAxleWeightDistribution(row), + CurbMass = row.ParseDouble("curbmass").SI<Kilogram>(), + NumberPassengersLowerDeck = row.ParseDouble("passengerslowerdeck"), + NumberPassengersUpperDeck = row.ParseDouble("passengersupperdeck"), + BodyCurbWeight = 0.SI<Kilogram>(), + Trailer = new List<MissionTrailer>(), + MinLoad = null, + MaxLoad = null, + LowLoad = refLoad * 0.2, + RefLoad = refLoad, + VehicleHeight = row.ParseDouble("height").SI<Meter>(), + VehicleLength = row.ParseDouble("length").SI<Meter>(), + VehicleWidth = row.ParseDouble("width").SI<Meter>(), + TotalCargoVolume = 0.SI<CubicMeter>(), + DefaultCDxA = row.ParseDouble("cdxastandard").SI<SquareMeter>() + }; + missions.Add(mission); + } + } + + return missions.ToArray(); + } + + private static double[] GetAxleWeightDistribution(DataRow row) + { + var axleDistribution = row.Field<string>("AxlesWeights"); + if (string.IsNullOrWhiteSpace(axleDistribution)) { + return new double[] { }; + } + + return axleDistribution.Split('/').ToDouble().Select(x => x / 100.0).ToArray(); } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index 10e361fa39..af52b5f0c5 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -63,7 +63,8 @@ namespace TUGraz.VectoCore.Models.Declaration public static readonly Watt MinEnginePowerForEMS = 300e3.SI<Watt>(); - public static readonly Segments Segments = new Segments(); + public static readonly TruckSegments TruckSegments = new TruckSegments(); + public static readonly BusSegments BusSegments = new BusSegments(); public static readonly Wheels Wheels = new Wheels(); public static readonly PT1 PT1 = new PT1(); public static readonly FuelData FuelData = FuelData.Instance(); diff --git a/VectoCore/VectoCore/Models/Declaration/LookupData.cs b/VectoCore/VectoCore/Models/Declaration/LookupData.cs index 5d310038c4..037107fe07 100644 --- a/VectoCore/VectoCore/Models/Declaration/LookupData.cs +++ b/VectoCore/VectoCore/Models/Declaration/LookupData.cs @@ -124,4 +124,8 @@ namespace TUGraz.VectoCore.Models.Declaration public abstract TValue Lookup(TKey1 key1, TKey2 key2, TKey3 key3, TKey4 key4, TKey5 key5); } + public abstract class LookupData<TKey1, TKey2, TKey3, TKey4, TKey5, TKey6, TValue> : LookupData where TValue : struct + { + public abstract TValue Lookup(TKey1 key1, TKey2 key2, TKey3 key3, TKey4 key4, TKey5 key5, TKey6 key6); + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Declaration/Mission.cs b/VectoCore/VectoCore/Models/Declaration/Mission.cs index 0b11fbd0d6..bc9fc1322f 100644 --- a/VectoCore/VectoCore/Models/Declaration/Mission.cs +++ b/VectoCore/VectoCore/Models/Declaration/Mission.cs @@ -32,6 +32,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using TUGraz.VectoCommon.Utils; namespace TUGraz.VectoCore.Models.Declaration @@ -46,45 +47,60 @@ namespace TUGraz.VectoCore.Models.Declaration public class Mission { - public MissionType MissionType; - public string CrossWindCorrectionParameters; - public double[] AxleWeightDistribution; + public Kilogram CurbMass { get; internal set; } + public MissionType MissionType { get; internal set; } + public string CrossWindCorrectionParameters { get; internal set; } + public double[] AxleWeightDistribution { get; internal set; } - public Kilogram BodyCurbWeight; + public Kilogram BodyCurbWeight { get; internal set; } - public Stream CycleFile; + public Stream CycleFile { get; internal set; } - public IList<MissionTrailer> Trailer; + public IList<MissionTrailer> Trailer { get; internal set; } - public Kilogram MinLoad; - public Kilogram LowLoad; - public Kilogram RefLoad; - public Kilogram MaxLoad; + public Kilogram MinLoad { get; internal set; } + public Kilogram LowLoad { get; internal set; } + public Kilogram RefLoad { get; internal set; } + public Kilogram MaxLoad { get; internal set; } - public SquareMeter DefaultCDxA; + public Kilogram MaxPayload { get; internal set; } - public CubicMeter TotalCargoVolume; + public SquareMeter DefaultCDxA { get; internal set; } + + public CubicMeter TotalCargoVolume { get; internal set; } + + public Meter VehicleHeight { get; internal set; } + + public Meter VehicleWidth { get; internal set; } + + public Meter VehicleLength { get; internal set; } public Dictionary<LoadingType, Kilogram> Loadings { get { - return new Dictionary<LoadingType, Kilogram> { + return new Dictionary<LoadingType, Kilogram> + { + {LoadingType.EmptyLoading, MinLoad }, { LoadingType.LowLoading, LowLoad }, { LoadingType.ReferenceLoad, RefLoad }, - }; + {LoadingType.FullLoading, MaxLoad } + }.Where(x => x.Value != null).ToDictionary(x => x.Key, x => x.Value); } } + + public double NumberPassengersLowerDeck { get; internal set; } + public double NumberPassengersUpperDeck { get; internal set; } } public class MissionTrailer { - public TrailerType TrailerType; - public Kilogram TrailerCurbWeight; - public Kilogram TrailerGrossVehicleWeight; - public List<Wheels.Entry> TrailerWheels; - public double TrailerAxleWeightShare; - public SquareMeter DeltaCdA; - public CubicMeter CargoVolume; + public TrailerType TrailerType { get; internal set; } + public Kilogram TrailerCurbWeight { get; internal set; } + public Kilogram TrailerGrossVehicleWeight { get; internal set; } + public List<Wheels.Entry> TrailerWheels { get; internal set; } + public double TrailerAxleWeightShare { get; internal set; } + public SquareMeter DeltaCdA { get; internal set; } + public CubicMeter CargoVolume { get; internal set; } } public enum TrailerType diff --git a/VectoCore/VectoCore/Models/Declaration/MissionType.cs b/VectoCore/VectoCore/Models/Declaration/MissionType.cs index 0a367d1989..e30ca49c21 100644 --- a/VectoCore/VectoCore/Models/Declaration/MissionType.cs +++ b/VectoCore/VectoCore/Models/Declaration/MissionType.cs @@ -30,6 +30,8 @@ */ using System; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; namespace TUGraz.VectoCore.Models.Declaration { @@ -110,5 +112,29 @@ namespace TUGraz.VectoCore.Models.Declaration throw new ArgumentOutOfRangeException("MissionType", self, null); } } + + public static Kilogram GetAveragePassengerMass(this MissionType self) + { + switch (self) { + case MissionType.LongHaul: + case MissionType.LongHaulEMS: + case MissionType.RegionalDelivery: + case MissionType.RegionalDeliveryEMS: + case MissionType.UrbanDelivery: + case MissionType.MunicipalUtility: + case MissionType.Construction: + case MissionType.VerificationTest: + case MissionType.ExemptedMission: + return 0.SI<Kilogram>(); + case MissionType.HeavyUrban: + case MissionType.Urban: + case MissionType.Suburban: + return Constants.BusParameters.PassengerWeightLow; + case MissionType.Interurban: + case MissionType.Coach: + return Constants.BusParameters.PassengerWeightHigh; + default: throw new ArgumentOutOfRangeException(nameof(self), self, null); + } + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Declaration/Segment.cs b/VectoCore/VectoCore/Models/Declaration/Segment.cs index 36eaa95196..af329bc63d 100644 --- a/VectoCore/VectoCore/Models/Declaration/Segment.cs +++ b/VectoCore/VectoCore/Models/Declaration/Segment.cs @@ -49,13 +49,13 @@ namespace TUGraz.VectoCore.Models.Declaration public Kilogram GrossVehicleWeightMax { get; set; } - public Kilogram GrossVehicleMassRating { get; set; } + //public Kilogram GrossVehicleMassRating { get; set; } public Stream AccelerationFile { get; internal set; } public Mission[] Missions { get; internal set; } - public Meter VehicleHeight { get; internal set; } + //public Meter VehicleHeight { get; internal set; } public MeterPerSecond DesignSpeed { get; internal set; } diff --git a/VectoCore/VectoCore/Models/Declaration/TruckSegments.cs b/VectoCore/VectoCore/Models/Declaration/TruckSegments.cs index 79ec6667b4..587c72d5c3 100644 --- a/VectoCore/VectoCore/Models/Declaration/TruckSegments.cs +++ b/VectoCore/VectoCore/Models/Declaration/TruckSegments.cs @@ -64,7 +64,8 @@ namespace TUGraz.VectoCore.Models.Declaration _segmentTable = table.Copy(); } - public override Segment Lookup(VehicleCategory vehicleCategory, AxleConfiguration axleConfiguration, + public override Segment Lookup( + VehicleCategory vehicleCategory, AxleConfiguration axleConfiguration, Kilogram grossVehicleMassRating, Kilogram curbWeight, bool vocational) { return Lookup(vehicleCategory, axleConfiguration, grossVehicleMassRating, curbWeight, vocational, false); @@ -72,72 +73,79 @@ namespace TUGraz.VectoCore.Models.Declaration public VehicleCategory[] GetVehicleCategories(bool declarationOnly = true) { - return _segmentTable.AsEnumerable().Where(r => !declarationOnly || r.Field<string>("valid") == "1").Select(r => EnumHelper.ParseEnum<VehicleCategory>(r.Field<string>("vehiclecategory"))).Distinct().ToArray(); + return _segmentTable.AsEnumerable().Where(r => !declarationOnly || r.Field<string>("valid") == "1") + .Select(r => EnumHelper.ParseEnum<VehicleCategory>(r.Field<string>("vehiclecategory"))).Distinct().ToArray(); } public IEnumerable<AxleConfiguration> GetAxleConfigurations() { return _segmentTable.AsEnumerable().Where(row => row.Field<string>("valid") == "1") - .Select(row => AxleConfigurationHelper.Parse(row.Field<string>("axleconf."))).Distinct(); + .Select(row => AxleConfigurationHelper.Parse(row.Field<string>("axleconf."))).Distinct(); } - public Segment Lookup(VehicleCategory vehicleCategory, AxleConfiguration axleConfiguration, + public Segment Lookup( + VehicleCategory vehicleCategory, AxleConfiguration axleConfiguration, Kilogram grossVehicleMassRating, Kilogram curbWeight, bool vocational, bool considerInvalid) { - var row = GetSegmentDataRow(vehicleCategory, axleConfiguration, grossVehicleMassRating, vocational, considerInvalid); if (row == null) { return new Segment() { Found = false }; } + var vehicleHeight = LookupHeight(vehicleCategory, axleConfiguration, grossVehicleMassRating, vocational); var segment = new Segment { Found = true, - GrossVehicleWeightMin = row.ParseDouble("tpmlm_min").SI(Unit.SI.Ton).Cast<Kilogram>(), - GrossVehicleWeightMax = row.ParseDouble("tpmlm_max").SI(Unit.SI.Ton).Cast<Kilogram>(), + GrossVehicleWeightMin = row.ParseDouble("tpmlm_min").SI(Unit.SI.Ton).Cast<Kilogram>(), + GrossVehicleWeightMax = row.ParseDouble("tpmlm_max").SI(Unit.SI.Ton).Cast<Kilogram>(), VehicleCategory = vehicleCategory, AxleConfiguration = axleConfiguration, VehicleClass = VehicleClassHelper.Parse(row.Field<string>("hdvgroup")), AccelerationFile = - RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".VACC." + - row.Field<string>(".vaccfile")), - Missions = CreateMissions(ref grossVehicleMassRating, curbWeight, row), - VehicleHeight = LookupHeight(vehicleCategory, axleConfiguration, grossVehicleMassRating, vocational), + RessourceHelper.ReadStream( + DeclarationData.DeclarationDataResourcePrefix + ".VACC." + + row.Field<string>(".vaccfile")), + Missions = CreateMissions(grossVehicleMassRating, curbWeight, row, vehicleHeight), DesignSpeed = row.ParseDouble("designspeed").KMPHtoMeterPerSecond(), - GrossVehicleMassRating = grossVehicleMassRating, + + //GrossVehicleMassRating = grossVehicleMassRating, }; return segment; } - private DataRow GetSegmentDataRow(VehicleCategory vehicleCategory, AxleConfiguration axleConfiguration, + private DataRow GetSegmentDataRow( + VehicleCategory vehicleCategory, AxleConfiguration axleConfiguration, Kilogram grossVehicleMassRating, bool vocational, bool considerInvalid) { DataRow row; try { - row = _segmentTable.AsEnumerable().First(r => { - var isValid = r.Field<string>("valid"); - var isVocational = r.Field<string>("vocational").ToBoolean(); - var category = r.Field<string>("vehiclecategory"); - var axleConf = r.Field<string>("axleconf."); - var massMin = r.ParseDouble("tpmlm_min").SI(Unit.SI.Ton); - var massMax = r.ParseDouble("tpmlm_max").SI(Unit.SI.Ton); - return (considerInvalid || isValid == "1") - && vocational == isVocational - && category == vehicleCategory.ToString() - && axleConf == axleConfiguration.GetName() - && grossVehicleMassRating > massMin && grossVehicleMassRating <= massMax; - - }); + row = _segmentTable.AsEnumerable().First( + r => { + var isValid = r.Field<string>("valid"); + var isVocational = r.Field<string>("vocational").ToBoolean(); + var category = r.Field<string>("vehiclecategory"); + var axleConf = r.Field<string>("axleconf."); + var massMin = r.ParseDouble("tpmlm_min").SI(Unit.SI.Ton); + var massMax = r.ParseDouble("tpmlm_max").SI(Unit.SI.Ton); + return (considerInvalid || isValid == "1") + && vocational == isVocational + && category == vehicleCategory.ToString() + && axleConf == axleConfiguration.GetName() + && grossVehicleMassRating > massMin && grossVehicleMassRating <= massMax; + }); } catch (InvalidOperationException e) { - var errorMessage = string.Format(ErrorMessage, vehicleCategory, axleConfiguration.GetName(), + var errorMessage = string.Format( + ErrorMessage, vehicleCategory, axleConfiguration.GetName(), grossVehicleMassRating); Log.Fatal(errorMessage); - throw new VectoException(errorMessage, e); + throw new VectoException(errorMessage, e); } + return row; } - public Meter LookupHeight(VehicleCategory vehicleCategory, AxleConfiguration axleConfiguration, + public Meter LookupHeight( + VehicleCategory vehicleCategory, AxleConfiguration axleConfiguration, Kilogram grossVehicleMassRating, bool vocational) { var row = GetSegmentDataRow(vehicleCategory, axleConfiguration, grossVehicleMassRating, vocational, true); @@ -147,12 +155,13 @@ namespace TUGraz.VectoCore.Models.Declaration if (vehicleClass == VehicleClass.Class9) { // VECTO-471: for class 9 take similar height than rigid with same maximum gross vehicle weight (class 1, 2, 3 or 4). - var rigidGVWrow = _segmentTable.AsEnumerable().FirstOrDefault(r => { - var massMin = r.ParseDouble("tpmlm_min").SI(Unit.SI.Ton); - var massMax = r.ParseDouble("tpmlm_max").SI(Unit.SI.Ton); - return new[] { "1", "2", "3", "4" }.Contains(r.Field<string>("hdvgroup")) - && massMin <= grossVehicleMassRating && grossVehicleMassRating <= massMax; - }); + var rigidGVWrow = _segmentTable.AsEnumerable().FirstOrDefault( + r => { + var massMin = r.ParseDouble("tpmlm_min").SI(Unit.SI.Ton); + var massMax = r.ParseDouble("tpmlm_max").SI(Unit.SI.Ton); + return new[] { "1", "2", "3", "4" }.Contains(r.Field<string>("hdvgroup")) + && massMin <= grossVehicleMassRating && grossVehicleMassRating <= massMax; + }); if (rigidGVWrow != null) { vehicleHeight = rigidGVWrow.ParseDouble("height").SI<Meter>(); } @@ -164,63 +173,72 @@ namespace TUGraz.VectoCore.Models.Declaration /// <summary> /// Looks up the default CdxA value for the cross wind correction. /// </summary> - public SquareMeter LookupCdA(VehicleCategory vehicleCategory, AxleConfiguration axleConfiguration, + public SquareMeter LookupCdA( + VehicleCategory vehicleCategory, AxleConfiguration axleConfiguration, Kilogram grossVehicleMassRating, bool vocational) { var row = GetSegmentDataRow(vehicleCategory, axleConfiguration, grossVehicleMassRating, vocational, true); return row.SI<SquareMeter>("cdxa_default"); } - private static Mission[] CreateMissions(ref Kilogram grossVehicleWeight, Kilogram curbWeight, DataRow row) + private static Mission[] CreateMissions( + Kilogram grossVehicleWeight, Kilogram curbWeight, DataRow row, Meter vehicleHeight) { var missionTypes = Enum.GetValues(typeof(MissionType)).Cast<MissionType>(); var missions = new List<Mission>(); - foreach (var missionType in missionTypes.Where(m => m.IsDeclarationMission() && m != MissionType.ExemptedMission && row.Field<string>(m.ToString()) != "-")) { - + foreach (var missionType in missionTypes.Where( + m => m.IsDeclarationMission() && m != MissionType.ExemptedMission && row.Field<string>(m.ToString()) != "-")) { var body = GetBody(row, missionType); var trailers = GetTrailers(row, missionType); - var maxGVW = missionType.IsEMS()? Constants.SimulationSettings.MaximumGrossVehicleWeightEMS : Constants.SimulationSettings.MaximumGrossVehicleWeight; - + var maxGVW = missionType.IsEMS() + ? Constants.SimulationSettings.MaximumGrossVehicleWeightEMS + : Constants.SimulationSettings.MaximumGrossVehicleWeight; + // limit gvw to MaxGVW (40t) var gvw = VectoMath.Min( - grossVehicleWeight + trailers.Sum(t => t.TrailerGrossVehicleWeight).DefaultIfNull(0), - maxGVW); + grossVehicleWeight + trailers.Sum(t => t.TrailerGrossVehicleWeight).DefaultIfNull(0), + maxGVW); var vehicleWeight = curbWeight + body.CurbWeight; var maxLoad = gvw - vehicleWeight - trailers.Sum(t => t.TrailerCurbWeight).DefaultIfNull(0); - var payloads = row.Field<string>(missionType.ToString()); Kilogram refLoad, lowLoad; var weight = grossVehicleWeight; - GetLoadings(out lowLoad, out refLoad, payloads, (p, l) => GetLoading(p, weight, vehicleWeight, trailers, l), maxLoad); + GetLoadings( + out lowLoad, out refLoad, payloads, (p, l) => GetLoading(p, weight, vehicleWeight, trailers, l), maxLoad); var mission = new Mission { MissionType = missionType, CrossWindCorrectionParameters = row.Field<string>("crosswindcorrection" + GetMissionSuffix(missionType, true)), CycleFile = - RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + - missionType.ToString().Replace("EMS", "") + - Constants.FileExtensions.CycleFile), + RessourceHelper.ReadStream( + DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + + missionType.ToString().Replace("EMS", "") + + Constants.FileExtensions.CycleFile), AxleWeightDistribution = GetAxleWeightDistribution(row, missionType), BodyCurbWeight = body.CurbWeight, Trailer = trailers, - MinLoad = 0.SI<Kilogram>(), - MaxLoad = maxLoad, + MaxPayload = maxLoad, + MinLoad = null, + MaxLoad = null, RefLoad = refLoad, LowLoad = lowLoad, + VehicleHeight = vehicleHeight, TotalCargoVolume = body.CargoVolume + trailers.Sum(t => t.CargoVolume).DefaultIfNull(0), DefaultCDxA = ReadDefaultAirDragValue(row, missionType) }; missions.Add(mission); } + return missions.ToArray(); } private static void GetLoadings( - out Kilogram lowLoad, out Kilogram refLoad, string payloadStr, Func<string, bool, Kilogram> loadingParser, Kilogram maxLoad) + out Kilogram lowLoad, out Kilogram refLoad, string payloadStr, Func<string, bool, Kilogram> loadingParser, + Kilogram maxLoad) { var payloads = payloadStr.Split('/'); if (payloads.Length == 2) { @@ -292,18 +310,21 @@ namespace TUGraz.VectoCore.Models.Declaration return cdxA; } - private static Kilogram GetLoading(string payloadStr, Kilogram grossVehicleWeight, Kilogram vehicleWeight, + private static Kilogram GetLoading( + string payloadStr, Kilogram grossVehicleWeight, Kilogram vehicleWeight, IEnumerable<MissionTrailer> trailers, bool lowLoading) { var refLoadValue = payloadStr.ToDouble(double.NaN); if (double.IsNaN(refLoadValue)) { var vehiclePayload = DeclarationData.GetPayloadForGrossVehicleWeight(grossVehicleWeight, payloadStr) - .LimitTo(0.SI<Kilogram>(), grossVehicleWeight - vehicleWeight); + .LimitTo(0.SI<Kilogram>(), grossVehicleWeight - vehicleWeight); var trailerPayload = trailers.Sum( - t => DeclarationData.GetPayloadForTrailerWeight(t.TrailerGrossVehicleWeight, t.TrailerCurbWeight, lowLoading)) - .DefaultIfNull(0); - return vehiclePayload + trailerPayload; + t => DeclarationData.GetPayloadForTrailerWeight( + t.TrailerGrossVehicleWeight, t.TrailerCurbWeight, lowLoading)) + .DefaultIfNull(0); + return vehiclePayload + trailerPayload; } + return refLoadValue.SI<Kilogram>(); } @@ -322,6 +343,7 @@ namespace TUGraz.VectoCore.Models.Declaration if (!string.IsNullOrWhiteSpace(trailerAxles)) { return trailerAxles.ToDouble() / 100.0; } + return 0; } @@ -329,8 +351,9 @@ namespace TUGraz.VectoCore.Models.Declaration { var axleDistribution = row.Field<string>("truckaxles" + GetMissionSuffix(missionType)); if (string.IsNullOrWhiteSpace(axleDistribution)) { - return new double[]{}; + return new double[] { }; } + return axleDistribution.Split('/').ToDouble().Select(x => x / 100.0).ToArray(); } @@ -358,4 +381,4 @@ namespace TUGraz.VectoCore.Models.Declaration }; } } -} \ No newline at end of file +} diff --git a/VectoCore/VectoCore/Models/Declaration/VehicleClass.cs b/VectoCore/VectoCore/Models/Declaration/VehicleClass.cs index f058a5d870..b9ddb2c894 100644 --- a/VectoCore/VectoCore/Models/Declaration/VehicleClass.cs +++ b/VectoCore/VectoCore/Models/Declaration/VehicleClass.cs @@ -53,12 +53,11 @@ namespace TUGraz.VectoCore.Models.Declaration Class15, Class16, Class17, - ClassB1, - ClassB2, - ClassB3, - ClassB4, - ClassB5, - ClassB6 + ClassPB41, + ClassPB42, + ClassPB43, + ClassPB44, + ClassPB45 } public static class VehicleClassHelper diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs index 4372ef880b..4cb7a43f3a 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs @@ -96,7 +96,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl if (dataProvider is IDeclarationInputDataProvider) { var declDataProvider = dataProvider as IDeclarationInputDataProvider; var report = declarationReport ?? new XMLDeclarationReport(ModWriter); - DataReader = new DeclarationModeVectoRunDataFactory(declDataProvider, report); + DataReader = declDataProvider.JobInputData.Vehicle.VehicleCategory.IsTruck() + ? (IVectoRunDataFactory)new DeclarationModeTruckVectoRunDataFactory(declDataProvider, report) + : new DeclarationModeBusVectoRunDataFactory(declDataProvider, report); return; } throw new VectoException("Unknown InputData for Declaration Mode!"); @@ -274,3 +276,4 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl } } } + diff --git a/VectoCore/VectoCore/Resources/Declaration/HeavyBusSegmentationTable.csv b/VectoCore/VectoCore/Resources/Declaration/HeavyBusSegmentationTable.csv index ce46d6bcb4..3e7d152203 100644 --- a/VectoCore/VectoCore/Resources/Declaration/HeavyBusSegmentationTable.csv +++ b/VectoCore/VectoCore/Resources/Declaration/HeavyBusSegmentationTable.csv @@ -1,26 +1,26 @@ -HDV group , Production Stage , Vehicle Category , Articulated , Num Axles , TPMLM_Min , TPMLM_Max , single/double deck , DesignSpeed , Body , .vacc file , Cross Wind Correction , AxlesWeights , Width , Length , Height , CdxA , Heavy Urban , Urban , Suburban , Interurban , Coach , External displays , Internal displays , Fridge , Kitchen Standard , +HDV group , Production Stage , Vehicle Category , HDV SuperGroup , Articulated , Num Axles , TPMLM_Min , TPMLM_Max , single/double deck , DesignSpeed , Body , .vacc file , Cross Wind Correction , CdxA Standard , AxlesWeights , Width , Length , Height , CurbMass , PassengersLowerDeck , PassengersUpperDeck , Heavy Urban , Urban , Suburban , Interurban , Coach , External displays , Internal displays , Fridge , Kitchen Standard , ## Heavy Bus Primary Vehicles -P31SD , 1 , HeavyBus , - , 2 , 7.4 , 999 , single , ?? , , Bus.vacc , BusRigid , 37.5/62/5 , 2.55 , 12 , ?? , ?? , 3 , 3 , 3 , , , 3 , 2 , 0 , 0 , -P31DD , 1 , HeavyBus , - , 2 , 7.4 , 999 , double , ?? , , Bus.vacc , BusRigid , 37.5/62/5 , 2.55 , 12 , ?? , ?? , 3.7 , 3.7 , 3.7 , , , 3 , 3 , 0 , 0 , -P32SD , 1 , HeavyBus , - , 2 , 7.4 , 999 , single , ?? , , Bus.vacc , BusRigid , 37.5/62/5 , 2.55 , 12 , ?? , ?? , , , , 2.2 , 1.4 , 2 , 2 , 0.5 , 0.5 , -P32SD , 1 , HeavyBus , - , 2 , 7.4 , 999 , double , ?? , , Bus.vacc , BusRigid , 37.5/62/5 , 2.55 , 12 , ?? , ?? , , , , 3 , 2 , 1 , 2 , 1 , 1 , +P31SD , 1 , HeavyBus , PB41 , - , 2 , 7.4 , 999 , single , 100 , , Bus.vacc , CoachBus , 4.9 , 37.5/62/5 , 2.55 , 12 , 2.7 , 10000 , 80 , 0 , 3 , 3 , 3 , , , 3 , 2 , 0 , 0 , +P31DD , 1 , HeavyBus , PB41 , - , 2 , 7.4 , 999 , double , 100 , , Bus.vacc , CoachBus , 6.2 , 37.5/62/5 , 2.55 , 12 , 3.7 , 10000 , 60 , 40 , 3.7 , 3.7 , 3.7 , , , 3 , 3 , 0 , 0 , +P32SD , 1 , HeavyBus , PB41 , - , 2 , 7.4 , 999 , single , 100 , , Bus.vacc , CoachBus , 4.6 , 37.5/62/5 , 2.55 , 12 , 3.0 , 10000 , 45 , 0 , , , , 2.2 , 1.4 , 2 , 2 , 0.5 , 0.5 , +P32SD , 1 , HeavyBus , PB41 , - , 2 , 7.4 , 999 , double , 100 , , Bus.vacc , CoachBus , 5.2 , 37.5/62/5 , 2.55 , 12 , 3.9 , 10000 , 25 , 35 , , , , 3 , 2 , 1 , 2 , 1 , 1 , ## -P33SD , 1 , HeavyBus , 0 , 3 , 7.4 , 999 , single , ?? , , Bus.vacc , BusRigid , 27.3/45.4/27.3 , 2.55 , 14 , ?? , ?? , 3 , 3 , 3 , , , 3 , 2 , 0 , 0 , -P33DD , 1 , HeavyBus , 0 , 3 , 7.4 , 999 , double , ?? , , Bus.vacc , BusRigid , 27.3/45.4/27.3 , 2.55 , 14 , ?? , ?? , 3.7 , 3.7 , 3.7 , , , 3 , 3 , 0 , 0 , -P34SD , 1 , HeavyBus , 0 , 3 , 7.4 , 999 , single , ?? , , Bus.vacc , BusRigid , 27.3/45.4/27.3 , 2.55 , 14 , ?? , ?? , , , , 2.2 , 1.4 , 2 , 2 , 0.5 , 0.5 , -P34SD , 1 , HeavyBus , 0 , 3 , 7.4 , 999 , double , ?? , , Bus.vacc , BusRigid , 27.3/45.4/27.3 , 2.55 , 14 , ?? , ?? , , , , 3 , 2 , 1 , 4 , 1 , 1.0 , +P33SD , 1 , HeavyBus , PB42 , 0 , 3 , 7.4 , 999 , single , 100 , , Bus.vacc , CoachBus , 5.0 , 27.3/45.4/27.3 , 2.55 , 14 , 2.7 , 12000 , 104 , 0 , 3 , 3 , 3 , , , 3 , 2 , 0 , 0 , +P33DD , 1 , HeavyBus , PB42 , 0 , 3 , 7.4 , 999 , double , 100 , , Bus.vacc , CoachBus , 6.3 , 27.3/45.4/27.3 , 2.55 , 14 , 3.7 , 12000 , 78 , 52 , 3.7 , 3.7 , 3.7 , , , 3 , 3 , 0 , 0 , +P34SD , 1 , HeavyBus , PB42 , 0 , 3 , 7.4 , 999 , single , 100 , , Bus.vacc , CoachBus , 4.7 , 27.3/45.4/27.3 , 2.55 , 14 , 3.0 , 12000 , 59 , 0 , , , , 2.2 , 1.4 , 2 , 2 , 0.5 , 0.5 , +P34SD , 1 , HeavyBus , PB42 , 0 , 3 , 7.4 , 999 , double , 100 , , Bus.vacc , CoachBus , 5.3 , 27.3/45.4/27.3 , 2.55 , 14 , 3.9 , 12000 , 33 , 46 , , , , 3 , 2 , 1 , 4 , 1 , 1.0 , # -P35SD , 1 , HeavyBus , 1 , 3 , 7.4 , 999 , single , ?? , , Bus.vacc , BusRigid , 24.3/35.2/40.5 , 2.55 , 18 , ?? , ?? , 3 , 3 , 3 , , , 3 , 3 , 0 , 0 , -P35DD , 1 , HeavyBus , 1 , 3 , 7.4 , 999 , double , ?? , , Bus.vacc , BusRigid , 24.3/35.2/40.5 , 2.55 , 18 , ?? , ?? , 3.7 , 3.7 , 3.7 , , , , , , , -P36SD , 1 , HeavyBus , 1 , 3 , 7.4 , 999 , single , ?? , , Bus.vacc , BusRigid , 24.3/35.2/40.5 , 2.55 , 18 , ?? , ?? , , , , 2.2 , 1.4 , , , , , -P36SD , 1 , HeavyBus , 1 , 3 , 7.4 , 999 , double , ?? , , Bus.vacc , BusRigid , 24.3/35.2/40.5 , 2.55 , 18 , ?? , ?? , , , , 3 , 2 , , , , , +P35SD , 1 , HeavyBus , PB43 , 1 , 3 , 7.4 , 999 , single , 100 , , Bus.vacc , CoachBus , 5.1 , 24.3/35.2/40.5 , 2.55 , 18 , 2.7 , 12000 , 104 , 0 , 3 , 3 , 3 , , , 3 , 3 , 0 , 0 , +P35DD , 1 , HeavyBus , PB43 , 1 , 3 , 7.4 , 999 , double , 100 , , Bus.vacc , CoachBus , 6.4 , 24.3/35.2/40.5 , 2.55 , 18 , 3.7 , 12000 , 78 , 52 , 3.7 , 3.7 , 3.7 , , , , , , , +P36SD , 1 , HeavyBus , PB43 , 1 , 3 , 7.4 , 999 , single , 100 , , Bus.vacc , CoachBus , 4.8 , 24.3/35.2/40.5 , 2.55 , 18 , 3.0 , 12000 , 59 , 0 , , , , 2.2 , 1.4 , , , , , +P36SD , 1 , HeavyBus , PB43 , 1 , 3 , 7.4 , 999 , double , 100 , , Bus.vacc , CoachBus , 5.4 , 24.3/35.2/40.5 , 2.55 , 18 , 3.9 , 12000 , 33 , 46 , , , , 3 , 2 , , , , , ## -P37SD , 1 , HeavyBus , 0 , 4 , 7.4 , 999 , single , ?? , , Bus.vacc , BusRigid , 21.4/21.4/35.8/21.4 , 2.55 , 15 , ?? , ?? , 3 , 3 , 3 , , , , , , , -P37DD , 1 , HeavyBus , 0 , 4 , 7.4 , 999 , double , ?? , , Bus.vacc , BusRigid , 21.4/21.4/35.8/21.4 , 2.55 , 15 , ?? , ?? , 3.7 , 3.7 , 3.7 , , , , , , , -P38SD , 1 , HeavyBus , 0 , 4 , 7.4 , 999 , single , ?? , , Bus.vacc , BusRigid , 21.4/21.4/35.8/21.4 , 2.55 , 15 , ?? , ?? , , , , 2.2 , 1.4 , , , , , -P38SD , 1 , HeavyBus , 0 , 4 , 7.4 , 999 , double , ?? , , Bus.vacc , BusRigid , 21.4/21.4/35.8/21.4 , 2.55 , 15 , ?? , ?? , , , , 3 , 2 , , , , , +P37SD , 1 , HeavyBus , PB44 , 0 , 4 , 7.4 , 999 , single , 100 , , Bus.vacc , CoachBus , 5.1 , 21.4/21.4/35.8/21.4 , 2.55 , 15 , 2.7 , 14000 , 125 , 0 , 3 , 3 , 3 , , , , , , , +P37DD , 1 , HeavyBus , PB44 , 0 , 4 , 7.4 , 999 , double , 100 , , Bus.vacc , CoachBus , 6.4 , 21.4/21.4/35.8/21.4 , 2.55 , 15 , 3.7 , 14000 , 94 , 62 , 3.7 , 3.7 , 3.7 , , , , , , , +P38SD , 1 , HeavyBus , PB44 , 0 , 4 , 7.4 , 999 , single , 100 , , Bus.vacc , CoachBus , 4.8 , 21.4/21.4/35.8/21.4 , 2.55 , 15 , 3.0 , 14000 , 70 , 0 , , , , 2.2 , 1.4 , , , , , +P38SD , 1 , HeavyBus , PB44 , 0 , 4 , 7.4 , 999 , double , 100 , , Bus.vacc , CoachBus , 5.4 , 21.4/21.4/35.8/21.4 , 2.55 , 15 , 3.9 , 14000 , 39 , 55 , , , , 3 , 2 , , , , , # -P39SD , 1 , HeavyBus , 1 , 4 , 7.4 , 999 , single , ?? , , Bus.vacc , BusRigid , 20.0/28.2/32.4/19.4 , 2.55 , 20 , ?? , ?? , 3 , 3 , 3 , , , 3 , 3 , 0 , 0 , -P39DD , 1 , HeavyBus , 1 , 4 , 7.4 , 999 , double , ?? , , Bus.vacc , BusRigid , 20.0/28.2/32.4/19.4 , 2.55 , 20 , ?? , ?? , 3.7 , 3.7 , 3.7 , , , , , , , -P40SD , 1 , HeavyBus , 1 , 4 , 7.4 , 999 , single , ?? , , Bus.vacc , BusRigid , 20.0/28.2/32.4/19.4 , 2.55 , 20 , ?? , ?? , , , , 2.2 , 1.4 , , , , , -P40SD , 1 , HeavyBus , 1 , 4 , 7.4 , 999 , double , ?? , , Bus.vacc , BusRigid , 20.0/28.2/32.4/19.4 , 2.55 , 20 , ?? , ?? , , , , 3 , 2 , , , , , +P39SD , 1 , HeavyBus , PB45 , 1 , 4 , 7.4 , 999 , single , 100 , , Bus.vacc , CoachBus , 5.2 , 20.0/28.2/32.4/19.4 , 2.55 , 20 , 2.7 , 14000 , 125 , 0 , 3 , 3 , 3 , , , 3 , 3 , 0 , 0 , +P39DD , 1 , HeavyBus , PB45 , 1 , 4 , 7.4 , 999 , double , 100 , , Bus.vacc , CoachBus , 6.5 , 20.0/28.2/32.4/19.4 , 2.55 , 20 , 3.7 , 14000 , 94 , 62 , 3.7 , 3.7 , 3.7 , , , , , , , +P40SD , 1 , HeavyBus , PB45 , 1 , 4 , 7.4 , 999 , single , 100 , , Bus.vacc , CoachBus , 4.9 , 20.0/28.2/32.4/19.4 , 2.55 , 20 , 3.0 , 14000 , 70 , 0 , , , , 2.2 , 1.4 , , , , , +P40SD , 1 , HeavyBus , PB45 , 1 , 4 , 7.4 , 999 , double , 100 , , Bus.vacc , CoachBus , 5.5 , 20.0/28.2/32.4/19.4 , 2.55 , 20 , 3.9 , 14000 , 39 , 55 , , , , 3 , 2 , , , , , diff --git a/VectoCore/VectoCore/Resources/Declaration/VACC/Bus.vacc b/VectoCore/VectoCore/Resources/Declaration/VACC/Bus.vacc new file mode 100644 index 0000000000..4e328c2014 --- /dev/null +++ b/VectoCore/VectoCore/Resources/Declaration/VACC/Bus.vacc @@ -0,0 +1,7 @@ +v [km/h],acc [m/s²],dec [m/s²] +0,0.1,-1 +7,1.1,-1 +25,1.1,-1 +50,0.6,-1 +60,0.6,-0.5 +120,0.6,-0.5 diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index 0bee8ab137..a0f427948d 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -269,6 +269,10 @@ <Compile Include="InputData\Reader\ComponentData\EnvironmentalContidionsMapReader.cs" /> <Compile Include="InputData\Reader\ComponentData\SSMTechnologiesReader.cs" /> <Compile Include="InputData\Reader\ComponentData\ActuationsMapReader.cs" /> + <Compile Include="InputData\Reader\DataObjectAdapter\DeclarationDataAdapterPrimaryBus.cs" /> + <Compile Include="InputData\Reader\DataObjectAdapter\IDeclarationDataAdapter.cs" /> + <Compile Include="InputData\Reader\Impl\AbstractDeclarationVectoRunDataFactory.cs" /> + <Compile Include="InputData\Reader\Impl\DeclarationModeBusVectoRunDataFactory.cs" /> <Compile Include="Models\BusAuxiliaries\AdvancedAuxiliaries.cs" /> <Compile Include="Models\BusAuxiliaries\AuxiliaryConfig.cs" /> <Compile Include="Models\BusAuxiliaries\DownstreamModules\Impl\AbstractModule.cs" /> @@ -338,6 +342,7 @@ <Compile Include="Models\BusAuxiliaries\Interfaces\IM12.cs" /> <Compile Include="Models\BusAuxiliaries\Interfaces\Signals.cs" /> <Compile Include="Models\BusAuxiliaries\Util\FilePathUtils.cs" /> + <Compile Include="Models\Declaration\BusSegments.cs" /> <Compile Include="Models\SimulationComponent\Data\Engine\WHRPowerMap.cs" /> <Compile Include="InputData\Reader\ComponentData\WHRPowerReader.cs" /> <Compile Include="Models\SimulationComponent\Impl\StopStartCombustionEngine.cs" /> @@ -401,11 +406,11 @@ <Compile Include="InputData\Reader\ComponentData\TorqueConverterDataReader.cs" /> <Compile Include="InputData\Reader\ComponentData\TransmissionLossMapReader.cs" /> <Compile Include="InputData\Reader\DataObjectAdapter\AbstractSimulationDataAdapter.cs" /> - <Compile Include="InputData\Reader\DataObjectAdapter\DeclarationDataAdapter.cs" /> + <Compile Include="InputData\Reader\DataObjectAdapter\DeclarationDataAdapterTruck.cs" /> <Compile Include="InputData\Reader\DataObjectAdapter\EngineeringDataAdapter.cs" /> <Compile Include="InputData\Reader\ComponentData\DrivingCycleDataReader.cs" /> <Compile Include="InputData\Reader\ComponentData\FullLoadCurveReader.cs" /> - <Compile Include="InputData\Reader\Impl\DeclarationModeVectoRunDataFactory.cs" /> + <Compile Include="InputData\Reader\Impl\DeclarationModeTruckVectoRunDataFactory.cs" /> <Compile Include="InputData\Reader\Impl\DeclarationVTPModeVectoRunDataFactory.cs" /> <Compile Include="InputData\Reader\Impl\DrivingCycleProxy.cs" /> <Compile Include="InputData\Reader\Impl\EngineeringModeVectoRunDataFactory.cs" /> @@ -469,7 +474,7 @@ <Compile Include="Models\Declaration\Payloads.cs" /> <Compile Include="Models\Declaration\PneumaticSystem.cs" /> <Compile Include="Models\Declaration\PT1.cs" /> - <Compile Include="Models\Declaration\Segments.cs" /> + <Compile Include="Models\Declaration\TruckSegments.cs" /> <Compile Include="Models\Declaration\StandardBodies.cs" /> <Compile Include="Models\Declaration\SteeringPump.cs" /> <Compile Include="Models\Declaration\VehicleClass.cs" /> @@ -794,6 +799,8 @@ <EmbeddedResource Include="Resources\Declaration\Buses\DEFAULT_2-Cylinder_1-Stage_650ccm.ACMP" /> <EmbeddedResource Include="Resources\Declaration\Buses\DEFAULT_2-Cylinder_2-Stage_398ccm.ACMP" /> <EmbeddedResource Include="Resources\Declaration\Buses\DEFAULT_3-Cylinder_2-Stage_598ccm.ACMP" /> + <EmbeddedResource Include="Resources\Declaration\HeavyBusSegmentationTable.csv" /> + <EmbeddedResource Include="Resources\Declaration\VACC\Bus.vacc" /> <None Include="Utils\VectoVersionCore.tt"> <Generator>TextTemplatingFileGenerator</Generator> <LastGenOutput>VectoVersionCore.cs</LastGenOutput> diff --git a/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs b/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs index 494bff0e7e..9b1acaa870 100644 --- a/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs +++ b/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs @@ -65,7 +65,7 @@ namespace TUGraz.VectoCore.Tests.FileIO if (declarationProvider == null) { throw new VectoException("Failed to cas to Engineering InputDataProvider"); } - var reader = new DeclarationModeVectoRunDataFactory(declarationProvider, null); + var reader = new DeclarationModeTruckVectoRunDataFactory(declarationProvider, null); //reader.SetJobFile(DeclarationJob); var runData = reader.NextRun().First(); diff --git a/VectoCore/VectoCoreTest/Models/Declaration/DataAdapter/DeclarationAdapterTestHelper.cs b/VectoCore/VectoCoreTest/Models/Declaration/DataAdapter/DeclarationAdapterTestHelper.cs index 97c09cedb2..87f866c682 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/DataAdapter/DeclarationAdapterTestHelper.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/DataAdapter/DeclarationAdapterTestHelper.cs @@ -46,7 +46,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration.DataAdapter public static VectoRunData[] CreateVectoRunData(string file) { var inputData = (IDeclarationInputDataProvider)JSONInputDataFactory.ReadJsonJob(file); - var dataReader = new DeclarationModeVectoRunDataFactory(inputData, null); + var dataReader = new DeclarationModeTruckVectoRunDataFactory(inputData, null); var runData = dataReader.NextRun().ToArray(); return runData; } diff --git a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs index beb51b205c..78e94ca6a5 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs @@ -212,7 +212,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration double expected) { var crossWindCorrectionCurve = new CrosswindCorrectionCdxALookup(crossSectionArea.SI<SquareMeter>(), - DeclarationDataAdapter.GetDeclarationAirResistanceCurve(parameterSet, crossSectionArea.SI<SquareMeter>(), + DeclarationDataAdapterTruck.GetDeclarationAirResistanceCurve(parameterSet, crossSectionArea.SI<SquareMeter>(), height.SI<Meter>()), CrossWindCorrectionMode.DeclarationModeCorrection); @@ -224,7 +224,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration public void CrossWindGetDeclarationAirResistance(string parameterSet, double cdxa0, double height) { var curve = - DeclarationDataAdapter.GetDeclarationAirResistanceCurve(parameterSet, cdxa0.SI<SquareMeter>(), height.SI<Meter>()); + DeclarationDataAdapterTruck.GetDeclarationAirResistanceCurve(parameterSet, cdxa0.SI<SquareMeter>(), height.SI<Meter>()); AssertHelper.AreRelativeEqual(60.KMPHtoMeterPerSecond(), curve[1].Velocity); AssertHelper.AreRelativeEqual(7.0418009.SI<SquareMeter>(), curve[1].EffectiveCrossSectionArea); @@ -251,7 +251,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration public void CrossWindCorrectionExceptionTest(string parameterSet, double crossSectionArea, double kmph, double height) { var crossWindCorrectionCurve = new CrosswindCorrectionCdxALookup(crossSectionArea.SI<SquareMeter>(), - DeclarationDataAdapter.GetDeclarationAirResistanceCurve(parameterSet, crossSectionArea.SI<SquareMeter>(), + DeclarationDataAdapterTruck.GetDeclarationAirResistanceCurve(parameterSet, crossSectionArea.SI<SquareMeter>(), height.SI<Meter>()), CrossWindCorrectionMode.DeclarationModeCorrection); @@ -558,7 +558,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration public void SegmentWeightOutOfRange4X2(double weight) { AssertHelper.Exception<VectoException>(() => - DeclarationData.Segments.Lookup( + DeclarationData.TruckSegments.Lookup( VehicleCategory.RigidTruck, AxleConfiguration.AxleConfig_4x2, weight.SI<Kilogram>(), @@ -576,7 +576,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration public void SegmentWeightOutOfRange4X4(double weight) { AssertHelper.Exception<VectoException>(() => - DeclarationData.Segments.Lookup( + DeclarationData.TruckSegments.Lookup( VehicleCategory.RigidTruck, AxleConfiguration.AxleConfig_4x4, weight.SI<Kilogram>(), @@ -634,7 +634,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration public void SegmentLookupTest(VehicleCategory category, AxleConfiguration axleConfiguration, double grossWeight, double curbWeight, bool vocational, VehicleClass expectedClass) { - var segment = DeclarationData.Segments.Lookup(category, axleConfiguration, grossWeight.SI<Kilogram>(), + var segment = DeclarationData.TruckSegments.Lookup(category, axleConfiguration, grossWeight.SI<Kilogram>(), curbWeight.SI<Kilogram>(), vocational); Assert.AreEqual(expectedClass, segment.VehicleClass); } @@ -657,7 +657,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration public void SegmentDesignSpeedTest(VehicleCategory category, AxleConfiguration axleConfiguration, double grossWeight, double curbWeight, bool vocational, VehicleClass expectedClass, double speed) { - var segment = DeclarationData.Segments.Lookup(category, axleConfiguration, grossWeight.SI<Kilogram>(), + var segment = DeclarationData.TruckSegments.Lookup(category, axleConfiguration, grossWeight.SI<Kilogram>(), curbWeight.SI<Kilogram>(), vocational); Assert.AreEqual(speed.KMPHtoMeterPerSecond(), segment.DesignSpeed); @@ -693,7 +693,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration public void SegmentLookupBodyTest(VehicleCategory category, AxleConfiguration axleConfiguration, double grossWeight, double curbWeight, bool vocational, VehicleClass expectedClass, int? expectedBodyWeight, int? expectedTrailerWeight) { - var segment = DeclarationData.Segments.Lookup(category, axleConfiguration, grossWeight.SI<Kilogram>(), + var segment = DeclarationData.TruckSegments.Lookup(category, axleConfiguration, grossWeight.SI<Kilogram>(), curbWeight.SI<Kilogram>(), vocational); Assert.AreEqual(expectedClass, segment.VehicleClass); @@ -754,10 +754,10 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration public void SegmentLookupHeightTest(VehicleCategory category, AxleConfiguration axleConfiguration, double grossWeight, double curbWeight, bool vocational, VehicleClass expectedClass, double expectedHeight) { - var segment = DeclarationData.Segments.Lookup(category, axleConfiguration, grossWeight.SI<Kilogram>(), + var segment = DeclarationData.TruckSegments.Lookup(category, axleConfiguration, grossWeight.SI<Kilogram>(), curbWeight.SI<Kilogram>(), vocational); Assert.AreEqual(expectedClass, segment.VehicleClass); - AssertHelper.AreRelativeEqual(expectedHeight, segment.VehicleHeight); + AssertHelper.AreRelativeEqual(expectedHeight, segment.Missions.First().VehicleHeight); } [Test, @@ -800,7 +800,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration double grossWeight, double curbWeight, bool vocational, VehicleClass expectedClass, double[] expectedCargoVolume) { - var segment = DeclarationData.Segments.Lookup(category, axleConfiguration, grossWeight.SI<Kilogram>(), + var segment = DeclarationData.TruckSegments.Lookup(category, axleConfiguration, grossWeight.SI<Kilogram>(), curbWeight.SI<Kilogram>(), vocational); Assert.AreEqual(expectedClass, segment.VehicleClass); Assert.AreEqual(expectedCargoVolume.Length, segment.Missions.Length); @@ -822,7 +822,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration CurbWeight = 5850.SI<Kilogram>() }; - var segment = DeclarationData.Segments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, + var segment = DeclarationData.TruckSegments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight, false); Assert.AreEqual(VehicleClass.Class2, segment.VehicleClass); @@ -895,7 +895,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration CurbWeight = 9500.SI<Kilogram>() }; - var segment = DeclarationData.Segments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, + var segment = DeclarationData.TruckSegments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight, false); Assert.AreEqual(VehicleClass.Class2, segment.VehicleClass); @@ -968,7 +968,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration CurbWeight = 5850.SI<Kilogram>() }; - var segment = DeclarationData.Segments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, + var segment = DeclarationData.TruckSegments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight, false); Assert.AreEqual(VehicleClass.Class3, segment.VehicleClass); @@ -1021,7 +1021,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration CurbWeight = 7500.SI<Kilogram>() }; - var segment = DeclarationData.Segments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, + var segment = DeclarationData.TruckSegments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight, false); Assert.AreEqual(VehicleClass.Class4, segment.VehicleClass); @@ -1109,7 +1109,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration CurbWeight = 7500.SI<Kilogram>() }; - var segment = DeclarationData.Segments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, + var segment = DeclarationData.TruckSegments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight, true); Assert.AreEqual(VehicleClass.Class4, segment.VehicleClass); @@ -1165,7 +1165,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration CurbWeight = 7500.SI<Kilogram>() }; - var segment = DeclarationData.Segments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, + var segment = DeclarationData.TruckSegments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight, false); Assert.AreEqual(VehicleClass.Class5, segment.VehicleClass); @@ -1253,7 +1253,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration CurbWeight = 7500.SI<Kilogram>() }; - var segment = DeclarationData.Segments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, + var segment = DeclarationData.TruckSegments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight, true); Assert.AreEqual(VehicleClass.Class5, segment.VehicleClass); @@ -1293,7 +1293,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration CurbWeight = 7500.SI<Kilogram>() }; - var segment = DeclarationData.Segments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, + var segment = DeclarationData.TruckSegments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight, false); Assert.AreEqual(VehicleClass.Class9, segment.VehicleClass); @@ -1399,7 +1399,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration CurbWeight = 7500.SI<Kilogram>() }; - var segment = DeclarationData.Segments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, + var segment = DeclarationData.TruckSegments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight, true); Assert.AreEqual(VehicleClass.Class9, segment.VehicleClass); @@ -1456,7 +1456,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration CurbWeight = 7500.SI<Kilogram>() }; - var segment = DeclarationData.Segments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, + var segment = DeclarationData.TruckSegments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight, false); Assert.AreEqual(VehicleClass.Class10, segment.VehicleClass); @@ -1546,7 +1546,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration CurbWeight = 7500.SI<Kilogram>() }; - var segment = DeclarationData.Segments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, + var segment = DeclarationData.TruckSegments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight, true); Assert.AreEqual(VehicleClass.Class10, segment.VehicleClass); @@ -1587,7 +1587,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration CurbWeight = 7500.SI<Kilogram>() }; - var segment = DeclarationData.Segments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, + var segment = DeclarationData.TruckSegments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight, false); Assert.AreEqual(VehicleClass.Class11, segment.VehicleClass); @@ -1708,7 +1708,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration CurbWeight = 7500.SI<Kilogram>() }; - var segment = DeclarationData.Segments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, + var segment = DeclarationData.TruckSegments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight, false); Assert.AreEqual(VehicleClass.Class12, segment.VehicleClass); @@ -1815,7 +1815,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration CurbWeight = 7500.SI<Kilogram>() }; - var segment = DeclarationData.Segments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, + var segment = DeclarationData.TruckSegments.Lookup(vehicleData.VehicleCategory, vehicleData.AxleConfiguration, vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight, false); Assert.AreEqual(VehicleClass.Class16, segment.VehicleClass); @@ -1912,7 +1912,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration { var dataProvider = JSONInputDataFactory.ReadJsonJob(@"TestData\Jobs\12t Delivery Truck.vecto") as IDeclarationInputDataProvider; - var dataReader = new DeclarationModeVectoRunDataFactory(dataProvider, null); + var dataReader = new DeclarationModeTruckVectoRunDataFactory(dataProvider, null); var runs = dataReader.NextRun().ToList(); Assert.AreEqual(6, runs.Count); @@ -1936,7 +1936,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration var dataProvider = JSONInputDataFactory.ReadJsonJob( @"TestData\Jobs\Class4_40t_Long_Haul_Truck.vecto") as IDeclarationInputDataProvider; - var dataReader = new DeclarationModeVectoRunDataFactory(dataProvider, null); + var dataReader = new DeclarationModeTruckVectoRunDataFactory(dataProvider, null); var runs = dataReader.NextRun().ToList(); Assert.AreEqual(8, runs.Count); @@ -1960,7 +1960,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration { var dataProvider = JSONInputDataFactory.ReadJsonJob(@"TestData\Jobs\40t_Long_Haul_Truck.vecto") as IDeclarationInputDataProvider; - var dataReader = new DeclarationModeVectoRunDataFactory(dataProvider, null); + var dataReader = new DeclarationModeTruckVectoRunDataFactory(dataProvider, null); var runs = dataReader.NextRun().ToList(); diff --git a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationSegmentHeavyBusesTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationSegmentHeavyBusesTest.cs index 27013f56c8..9c80351f70 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationSegmentHeavyBusesTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationSegmentHeavyBusesTest.cs @@ -1,7 +1,47 @@ -namespace TUGraz.VectoCore.Tests.Models.Declaration +using NUnit.Framework; +using TUGraz.VectoCommon.BusAuxiliaries; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.Declaration; + +namespace TUGraz.VectoCore.Tests.Models.Declaration { + [TestFixture] public class DeclarationSegmentHeavyBusesTest { - + + [ + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_4x2, FloorType.LowFloor, false, false, VehicleClass.ClassPB41), + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_4x2, FloorType.HighFloor, true, false, VehicleClass.ClassPB41), + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_4x2, FloorType.LowFloor, false, true, VehicleClass.ClassPB41), + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_4x2, FloorType.HighFloor, true, true, VehicleClass.ClassPB41), + + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_6x2, FloorType.LowFloor, false, false, VehicleClass.ClassPB42), + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_6x2, FloorType.HighFloor, true, false, VehicleClass.ClassPB42), + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_6x4, FloorType.LowFloor, false, false, VehicleClass.ClassPB42), + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_6x4, FloorType.HighFloor, true, false, VehicleClass.ClassPB42), + + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_6x2, FloorType.LowFloor, false, true, VehicleClass.ClassPB43), + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_6x2, FloorType.HighFloor, true, true, VehicleClass.ClassPB43), + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_6x4, FloorType.LowFloor, false, true, VehicleClass.ClassPB43), + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_6x4, FloorType.HighFloor, true, true, VehicleClass.ClassPB43), + + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_8x2, FloorType.LowFloor, false, false, VehicleClass.ClassPB44), + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_8x2, FloorType.HighFloor, true, false, VehicleClass.ClassPB44), + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_8x4, FloorType.LowFloor, false, false, VehicleClass.ClassPB44), + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_8x4, FloorType.HighFloor, true, false, VehicleClass.ClassPB44), + + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_8x2, FloorType.LowFloor, false, true, VehicleClass.ClassPB45), + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_8x2, FloorType.HighFloor, true, true, VehicleClass.ClassPB45), + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_8x4, FloorType.LowFloor, false, true, VehicleClass.ClassPB45), + TestCase(VehicleCategory.HeavyBusPrimaryVehicle, AxleConfiguration.AxleConfig_8x4, FloorType.HighFloor, true, true, VehicleClass.ClassPB45), + ] + public void SegmentLookupTest(VehicleCategory category, AxleConfiguration axleConfiguration, FloorType floorType, bool doubleDecker, bool articulated, VehicleClass expectedClass) + { + var segment = DeclarationData.BusSegments.Lookup(category, axleConfiguration, articulated, floorType, doubleDecker, true); + + Assert.AreEqual(10, segment.Missions.Length); + Assert.AreEqual(expectedClass, segment.VehicleClass); + } } } diff --git a/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs index 58432d42c6..ed1431e051 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs @@ -447,7 +447,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration }, }; - var dao = new DeclarationDataAdapter(); + var dao = new DeclarationDataAdapterTruck(); var gearboxData = new JSONGearboxDataV5(JSONInputDataFactory.ReadFile(gearboxFile), gearboxFile); var engineInput = new JSONEngineDataV3(JSONInputDataFactory.ReadFile(engineFile), engineFile); var vehicle = new MockDeclarationVehicleInputData() { @@ -499,7 +499,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration new Point(123.0457, 2530), }; - var dao = new DeclarationDataAdapter(); + var dao = new DeclarationDataAdapterTruck(); var gearboxData = new JSONGearboxDataV5(JSONInputDataFactory.ReadFile(gearboxFile), gearboxFile); var engineInput = new JSONEngineDataV3(JSONInputDataFactory.ReadFile(engineFile), engineFile); var vehicle = new MockDeclarationVehicleInputData() { @@ -617,7 +617,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration var gearboxData = job.JobInputData.Vehicle.Components.GearboxInputData; var idlespeed = VectoMath.Max( job.JobInputData.Vehicle.EngineIdleSpeed, job.JobInputData.Vehicle.Components.EngineInputData.EngineModes.First().IdleSpeed); - var dao = new DeclarationDataAdapter(); + var dao = new DeclarationDataAdapterTruck(); var engineData = dao.CreateEngineData(job.JobInputData.Vehicle, job.JobInputData.Vehicle.Components.EngineInputData.EngineModes.First(), new Mission() {MissionType = MissionType.LongHaul}); var axlegearRatio = job.JobInputData.Vehicle.Components.AxleGearInputData.Ratio; var rdyn = job.JobInputData.Vehicle.Components.AxleWheels.AxlesDeclaration.Where(x => x.AxleType == AxleType.VehicleDriven) @@ -871,7 +871,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration public void ComputeShiftPolygonXML(string xmlJob) { var inputData = xmlInputReader.CreateDeclaration(xmlJob); - var dao = new DeclarationDataAdapter(); + var dao = new DeclarationDataAdapterTruck(); var gearboxData = inputData.JobInputData.Vehicle.Components.GearboxInputData; var engineData = dao.CreateEngineData(inputData.JobInputData.Vehicle, inputData.JobInputData.Vehicle.Components.EngineInputData.EngineModes.First(), new Mission() {MissionType = MissionType.LongHaul}); @@ -880,7 +880,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration var axlegearRatio = inputData.JobInputData.Vehicle.Components.AxleGearInputData.Ratio; var vehicle = inputData.JobInputData.Vehicle; - var segment = DeclarationData.Segments.Lookup( + var segment = DeclarationData.TruckSegments.Lookup( vehicle.VehicleCategory, vehicle.AxleConfiguration, vehicle.GrossVehicleMassRating, vehicle.CurbMassChassis, false); var vehicleData = dao.CreateVehicleData(inputData.JobInputData.Vehicle, segment.Missions.First(), 0.SI<Kilogram>()); diff --git a/VectoCore/VectoCoreTest/Models/Simulation/PowerTrainBuilderTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/PowerTrainBuilderTest.cs index 8ce9760e71..3e00325456 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/PowerTrainBuilderTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/PowerTrainBuilderTest.cs @@ -101,7 +101,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation if (provider == null) { throw new VectoException("Failed to cast to Declaration InputDataProvider"); } - var reader = new DeclarationModeVectoRunDataFactory(provider, null); + var reader = new DeclarationModeTruckVectoRunDataFactory(provider, null); if (!shouldFail) { var runData = reader.NextRun().First(); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs index 9a3729bedc..5a93340cb3 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs @@ -29,29 +29,29 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System; -using System.IO; -using NUnit.Framework; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.InputData.Reader.ComponentData; -using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; -using TUGraz.VectoCore.Models.Simulation.Data; -using TUGraz.VectoCore.Models.Simulation.DataBus; -using TUGraz.VectoCore.Models.Simulation.Impl; -using TUGraz.VectoCore.Models.SimulationComponent.Data; -using TUGraz.VectoCore.Models.SimulationComponent.Impl; -using TUGraz.VectoCore.Tests.Utils; - -namespace TUGraz.VectoCore.Tests.Models.SimulationComponent -{ - [TestFixture] - public class VehicleTest - { - private const string VehicleDataFileCoach = @"TestData\Components\24t Coach.vveh"; - private const string VehicleDataFileTruck = @"TestData\Components\40t_Long_Haul_Truck.vveh"; - public static readonly double Tolerance = 0.001; - +using System; +using System.IO; +using NUnit.Framework; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.Reader.ComponentData; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.Simulation.DataBus; +using TUGraz.VectoCore.Models.Simulation.Impl; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Impl; +using TUGraz.VectoCore.Tests.Utils; + +namespace TUGraz.VectoCore.Tests.Models.SimulationComponent +{ + [TestFixture] + public class VehicleTest + { + private const string VehicleDataFileCoach = @"TestData\Components\24t Coach.vveh"; + private const string VehicleDataFileTruck = @"TestData\Components\40t_Long_Haul_Truck.vveh"; + public static readonly double Tolerance = 0.001; + [OneTimeSetUp] public void RunBeforeAnyTests() { @@ -59,153 +59,153 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent } - [Test] - public void VehiclePortTest() - { - var container = new VehicleContainer(ExecutionMode.Engineering); - - //var reader = new EngineeringModeSimulationDataReader(); - var vehicleData = MockSimulationDataFactory.CreateVehicleDataFromFile(VehicleDataFileCoach); - var airdragData = MockSimulationDataFactory.CreateAirdragDataFromFile(VehicleDataFileCoach); - //VehicleData.ReadFromFile(VehicleDataFile); - //vehicleData.CrossWindCorrectionMode = CrossWindCorrectionMode.NoCorrection; - var vehicle = new Vehicle(container, vehicleData, airdragData); - var driver = new MockDriver(container) { DriverBehavior = DrivingBehavior.Driving }; - var mockPort = new MockFvOutPort(); - vehicle.InPort().Connect(mockPort); - - vehicle.Initialize(17.210535.SI<MeterPerSecond>(), 0.SI<Radian>()); - - var requestPort = vehicle.OutPort(); - - var absTime = 0.SI<Second>(); - var dt = 1.SI<Second>(); - - var accell = -0.256231159.SI<MeterPerSquareSecond>(); - var gradient = Math.Atan(0.00366547048).SI<Radian>(); - - requestPort.Request(absTime, dt, accell, gradient); - - Assert.AreEqual(-2332.5362, mockPort.Force.Value(), 0.0001); - Assert.AreEqual(16.954303841, mockPort.Velocity.Value(), 0.0001); - } - - [ - TestCase(0, 0, 0.5, 3.0, 0), - TestCase(0, 1, 0.5, 3.0, 0.5657), - TestCase(60, 0, 0.5, 3.0, 1257.2212), - TestCase(60, 1, 0.5, 3.0, 1291.6202), - TestCase(60, 0.5, 0.5, 3.0, 1274.3082), - TestCase(72, 0.5, 0.5, 3.0, 1765.8214), - TestCase(72, 1, 3, 3.0, 2001.6463) - ] - public void VehicleAirResistanceTest(double vehicleSpeed, double acceleration, double dt, double height, - double expected) - { - var container = new VehicleContainer(ExecutionMode.Declaration); - - var vehicleData = MockSimulationDataFactory.CreateVehicleDataFromFile(VehicleDataFileTruck); - var airdragData = MockSimulationDataFactory.CreateAirdragDataFromFile(VehicleDataFileTruck); - airdragData.CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup(6.46.SI<SquareMeter>(), - DeclarationDataAdapter.GetDeclarationAirResistanceCurve("TractorSemitrailer", - 6.46.SI<SquareMeter>(), height.SI<Meter>()), CrossWindCorrectionMode.DeclarationModeCorrection); - var vehicle = new Vehicle(container, vehicleData,airdragData); - - var mockPort = new MockFvOutPort(); - vehicle.InPort().Connect(mockPort); - - // ==================== - - vehicle.Initialize(vehicleSpeed.KMPHtoMeterPerSecond(), 0.SI<Radian>()); - - var nextSpeed = vehicleSpeed.KMPHtoMeterPerSecond() + acceleration.SI<MeterPerSquareSecond>() * dt.SI<Second>(); - var avgForce = vehicle.AirDragResistance(vehicleSpeed.KMPHtoMeterPerSecond(), nextSpeed); - Assert.AreEqual(expected, avgForce.Value(), Tolerance); - } - - [Test] - public void VehicleAirDragPowerLossDeclarationTest() - { - var container = new VehicleContainer(ExecutionMode.Declaration); - - var vehicleData = MockSimulationDataFactory.CreateVehicleDataFromFile(VehicleDataFileTruck); - var airdragData = MockSimulationDataFactory.CreateAirdragDataFromFile(VehicleDataFileTruck); - airdragData.CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup(6.2985.SI<SquareMeter>(), - DeclarationDataAdapter.GetDeclarationAirResistanceCurve("TractorSemitrailer", - 6.2985.SI<SquareMeter>(), 3.SI<Meter>()), CrossWindCorrectionMode.DeclarationModeCorrection); - - var vehicle = new Vehicle(container, vehicleData,airdragData); - var driver = new MockDriver(container) { DriverBehavior = DrivingBehavior.Driving }; - var mockPort = new MockFvOutPort(); - vehicle.InPort().Connect(mockPort); - - var writer = new MockModalDataContainer(); - - vehicle.Initialize(80.KMPHtoMeterPerSecond(), 0.SI<Radian>()); - - var absTime = 0.SI<Second>(); - var dt = 0.5.SI<Second>(); - - vehicle.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), 0.SI<Radian>()); - vehicle.CommitSimulationStep(writer); - - Assert.AreEqual(45956.3024, ((SI)writer[ModalResultField.P_air]).Value(), 0.1); - - vehicle.Request(absTime, dt, 1.SI<MeterPerSquareSecond>(), 0.SI<Radian>()); - vehicle.CommitSimulationStep(writer); - Assert.AreEqual(47448.0989, ((SI)writer[ModalResultField.P_air]).Value(), 0.1); - } - - [Test, - TestCase(5.19, 0, 1.173), - TestCase(5.19, 40, 1.173), - TestCase(5.19, 60, 1.173), - TestCase(5.19, 80, 1.109), - TestCase(5.19, 100, 1.075), - TestCase(5.19, 62.5, 1.163), - ] - public void VehicleAirDragSpeedDependentTest(double crossSectionArea, double velocity, double expectedFactor) - { - var data = new[] { - "v_veh in km/h,Cd factor in -", - "0,1.173 ", - "5,1.173 ", - "10,1.173", - "15,1.173", - "20,1.173", - "25,1.173", - "30,1.173", - "35,1.173", - "40,1.173", - "45,1.173", - "50,1.173", - "55,1.173", - "60,1.173", - "65,1.153", - "70,1.136", - "75,1.121", - "80,1.109", - "85,1.099", - "90,1.090", - "95,1.082", - "100,1.075" - }; - var correctionData = new MemoryStream(); - var writer = new StreamWriter(correctionData); - foreach (var entry in data) { - writer.WriteLine(entry); - } - writer.Flush(); - correctionData.Seek(0, SeekOrigin.Begin); - - var cwcc = - new CrosswindCorrectionCdxALookup(crossSectionArea.SI<SquareMeter>(), - CrossWindCorrectionCurveReader.ReadSpeedDependentCorrectionCurveFromStream(correctionData, - crossSectionArea.SI<SquareMeter>()), CrossWindCorrectionMode.SpeedDependentCorrectionFactor); - - Assert.AreEqual(crossSectionArea * expectedFactor, - cwcc.EffectiveAirDragArea(velocity.KMPHtoMeterPerSecond()).Value(), - Tolerance); - } - } + [Test] + public void VehiclePortTest() + { + var container = new VehicleContainer(ExecutionMode.Engineering); + + //var reader = new EngineeringModeSimulationDataReader(); + var vehicleData = MockSimulationDataFactory.CreateVehicleDataFromFile(VehicleDataFileCoach); + var airdragData = MockSimulationDataFactory.CreateAirdragDataFromFile(VehicleDataFileCoach); + //VehicleData.ReadFromFile(VehicleDataFile); + //vehicleData.CrossWindCorrectionMode = CrossWindCorrectionMode.NoCorrection; + var vehicle = new Vehicle(container, vehicleData, airdragData); + var driver = new MockDriver(container) { DriverBehavior = DrivingBehavior.Driving }; + var mockPort = new MockFvOutPort(); + vehicle.InPort().Connect(mockPort); + + vehicle.Initialize(17.210535.SI<MeterPerSecond>(), 0.SI<Radian>()); + + var requestPort = vehicle.OutPort(); + + var absTime = 0.SI<Second>(); + var dt = 1.SI<Second>(); + + var accell = -0.256231159.SI<MeterPerSquareSecond>(); + var gradient = Math.Atan(0.00366547048).SI<Radian>(); + + requestPort.Request(absTime, dt, accell, gradient); + + Assert.AreEqual(-2332.5362, mockPort.Force.Value(), 0.0001); + Assert.AreEqual(16.954303841, mockPort.Velocity.Value(), 0.0001); + } + + [ + TestCase(0, 0, 0.5, 3.0, 0), + TestCase(0, 1, 0.5, 3.0, 0.5657), + TestCase(60, 0, 0.5, 3.0, 1257.2212), + TestCase(60, 1, 0.5, 3.0, 1291.6202), + TestCase(60, 0.5, 0.5, 3.0, 1274.3082), + TestCase(72, 0.5, 0.5, 3.0, 1765.8214), + TestCase(72, 1, 3, 3.0, 2001.6463) + ] + public void VehicleAirResistanceTest(double vehicleSpeed, double acceleration, double dt, double height, + double expected) + { + var container = new VehicleContainer(ExecutionMode.Declaration); + + var vehicleData = MockSimulationDataFactory.CreateVehicleDataFromFile(VehicleDataFileTruck); + var airdragData = MockSimulationDataFactory.CreateAirdragDataFromFile(VehicleDataFileTruck); + airdragData.CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup(6.46.SI<SquareMeter>(), + DeclarationDataAdapterTruck.GetDeclarationAirResistanceCurve("TractorSemitrailer", + 6.46.SI<SquareMeter>(), height.SI<Meter>()), CrossWindCorrectionMode.DeclarationModeCorrection); + var vehicle = new Vehicle(container, vehicleData,airdragData); + + var mockPort = new MockFvOutPort(); + vehicle.InPort().Connect(mockPort); + + // ==================== + + vehicle.Initialize(vehicleSpeed.KMPHtoMeterPerSecond(), 0.SI<Radian>()); + + var nextSpeed = vehicleSpeed.KMPHtoMeterPerSecond() + acceleration.SI<MeterPerSquareSecond>() * dt.SI<Second>(); + var avgForce = vehicle.AirDragResistance(vehicleSpeed.KMPHtoMeterPerSecond(), nextSpeed); + Assert.AreEqual(expected, avgForce.Value(), Tolerance); + } + + [Test] + public void VehicleAirDragPowerLossDeclarationTest() + { + var container = new VehicleContainer(ExecutionMode.Declaration); + + var vehicleData = MockSimulationDataFactory.CreateVehicleDataFromFile(VehicleDataFileTruck); + var airdragData = MockSimulationDataFactory.CreateAirdragDataFromFile(VehicleDataFileTruck); + airdragData.CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup(6.2985.SI<SquareMeter>(), + DeclarationDataAdapterTruck.GetDeclarationAirResistanceCurve("TractorSemitrailer", + 6.2985.SI<SquareMeter>(), 3.SI<Meter>()), CrossWindCorrectionMode.DeclarationModeCorrection); + + var vehicle = new Vehicle(container, vehicleData,airdragData); + var driver = new MockDriver(container) { DriverBehavior = DrivingBehavior.Driving }; + var mockPort = new MockFvOutPort(); + vehicle.InPort().Connect(mockPort); + + var writer = new MockModalDataContainer(); + + vehicle.Initialize(80.KMPHtoMeterPerSecond(), 0.SI<Radian>()); + + var absTime = 0.SI<Second>(); + var dt = 0.5.SI<Second>(); + + vehicle.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), 0.SI<Radian>()); + vehicle.CommitSimulationStep(writer); + + Assert.AreEqual(45956.3024, ((SI)writer[ModalResultField.P_air]).Value(), 0.1); + + vehicle.Request(absTime, dt, 1.SI<MeterPerSquareSecond>(), 0.SI<Radian>()); + vehicle.CommitSimulationStep(writer); + Assert.AreEqual(47448.0989, ((SI)writer[ModalResultField.P_air]).Value(), 0.1); + } + + [Test, + TestCase(5.19, 0, 1.173), + TestCase(5.19, 40, 1.173), + TestCase(5.19, 60, 1.173), + TestCase(5.19, 80, 1.109), + TestCase(5.19, 100, 1.075), + TestCase(5.19, 62.5, 1.163), + ] + public void VehicleAirDragSpeedDependentTest(double crossSectionArea, double velocity, double expectedFactor) + { + var data = new[] { + "v_veh in km/h,Cd factor in -", + "0,1.173 ", + "5,1.173 ", + "10,1.173", + "15,1.173", + "20,1.173", + "25,1.173", + "30,1.173", + "35,1.173", + "40,1.173", + "45,1.173", + "50,1.173", + "55,1.173", + "60,1.173", + "65,1.153", + "70,1.136", + "75,1.121", + "80,1.109", + "85,1.099", + "90,1.090", + "95,1.082", + "100,1.075" + }; + var correctionData = new MemoryStream(); + var writer = new StreamWriter(correctionData); + foreach (var entry in data) { + writer.WriteLine(entry); + } + writer.Flush(); + correctionData.Seek(0, SeekOrigin.Begin); + + var cwcc = + new CrosswindCorrectionCdxALookup(crossSectionArea.SI<SquareMeter>(), + CrossWindCorrectionCurveReader.ReadSpeedDependentCorrectionCurveFromStream(correctionData, + crossSectionArea.SI<SquareMeter>()), CrossWindCorrectionMode.SpeedDependentCorrectionFactor); + + Assert.AreEqual(crossSectionArea * expectedFactor, + cwcc.EffectiveAirDragArea(velocity.KMPHtoMeterPerSecond()).Value(), + Tolerance); + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs index ddc28ba6b8..c159c808c1 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs @@ -169,7 +169,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData WHTCRural = 1.1, WHTCUrban = 1.1 }; - var dao = new DeclarationDataAdapter(); + var dao = new DeclarationDataAdapterTruck(); var dummyGearbox = new DummyGearboxData() { Type = GearboxType.AMT, diff --git a/VectoCore/VectoCoreTest/Models/WHRMapReaderTest.cs b/VectoCore/VectoCoreTest/Models/WHRMapReaderTest.cs index c44e15800f..e158522a24 100644 --- a/VectoCore/VectoCoreTest/Models/WHRMapReaderTest.cs +++ b/VectoCore/VectoCoreTest/Models/WHRMapReaderTest.cs @@ -60,7 +60,7 @@ namespace TUGraz.VectoCore.Tests.Models { var reader = XmlReader.Create(SingleFuelWHRVehicle); var inputDataProvider = xmlInputReader.Create(reader) as IDeclarationInputDataProvider; - var dao = new DeclarationModeVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); var runs = dao.NextRun().ToArray(); Assert.AreEqual(10, runs.Length); @@ -84,7 +84,7 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - var dao = new DeclarationModeVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); var runs = dao.NextRun().ToArray(); Assert.IsTrue(runs.All(x => x.EngineData.WHRData == null)); @@ -107,7 +107,7 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - var dao = new DeclarationModeVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); var runs = dao.NextRun().ToArray(); Assert.IsTrue(runs.All(x => x.EngineData.WHRData == null)); @@ -131,7 +131,7 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - var dao = new DeclarationModeVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); AssertHelper.Exception<VectoException>( () => { var runs = dao.NextRun().ToArray(); @@ -143,7 +143,7 @@ namespace TUGraz.VectoCore.Tests.Models { var reader = XmlReader.Create(DualFuelWHRVehicle); var inputDataProvider = xmlInputReader.Create(reader) as IDeclarationInputDataProvider; - var dao = new DeclarationModeVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); var runs = dao.NextRun().ToArray(); Assert.AreEqual(10, runs.Length); @@ -166,7 +166,7 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - var dao = new DeclarationModeVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); AssertHelper.Exception<VectoException>( () => { var runs = dao.NextRun().ToArray(); @@ -189,7 +189,7 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - var dao = new DeclarationModeVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); AssertHelper.Exception<VectoException>( () => { var runs = dao.NextRun().ToArray(); @@ -217,7 +217,7 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - var dao = new DeclarationModeVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); AssertHelper.Exception<VectoException>( () => { var runs = dao.NextRun().ToArray(); @@ -242,7 +242,7 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - var dao = new DeclarationModeVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); AssertHelper.Exception<VectoException>( () => { var runs = dao.NextRun().ToArray(); @@ -263,7 +263,7 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - var dao = new DeclarationModeVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); var runs = dao.NextRun().ToArray(); Assert.IsTrue(runs.All(x => x.EngineData.WHRData == null)); @@ -286,7 +286,7 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - var dao = new DeclarationModeVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); var runs = dao.NextRun().ToArray(); Assert.IsTrue(runs.All(x => x.EngineData.WHRData == null)); diff --git a/VectoCore/VectoCoreTest/Utils/MockDeclarationVehicleInputData.cs b/VectoCore/VectoCoreTest/Utils/MockDeclarationVehicleInputData.cs index 21aae3a076..e34587f93a 100644 --- a/VectoCore/VectoCoreTest/Utils/MockDeclarationVehicleInputData.cs +++ b/VectoCore/VectoCoreTest/Utils/MockDeclarationVehicleInputData.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using TUGraz.VectoCommon.BusAuxiliaries; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -45,7 +46,8 @@ namespace TUGraz.VectoCore.Tests.Utils { public int NuberOfPassengersUpperDeck { get; set; } public int NumberOfPassengersLowerDeck { get; set; } public VehicleCode VehicleCode { get; set; } - public bool LowEntry { get; set; } + public FloorType FloorType { get; } + public bool Articulated { get; } public Meter Height { get; set; } public Meter Length { get; set; } public Meter Width { get; set; } @@ -93,7 +95,7 @@ namespace TUGraz.VectoCore.Tests.Utils { public Kilogram CurbMassExtra { get; } public Kilogram Loading { get; } public Meter DynamicTyreRadius { get; } - public bool LowEntry { get; set; } + public bool Articulated { get; } public Meter Height { get; } public Meter Length { get; set; } public Meter Width { get; set; } @@ -102,6 +104,7 @@ namespace TUGraz.VectoCore.Tests.Utils { public int NuberOfPassengersUpperDeck { get; set; } public int NumberOfPassengersLowerDeck { get; set; } public VehicleCode VehicleCode { get; set; } + public FloorType FloorType { get; } IVehicleComponentsDeclaration IVehicleDeclarationInputData.Components { diff --git a/VectoCore/VectoCoreTest/Utils/MockSimulationDataFactory.cs b/VectoCore/VectoCoreTest/Utils/MockSimulationDataFactory.cs index 72f668e951..8ca17a0a90 100644 --- a/VectoCore/VectoCoreTest/Utils/MockSimulationDataFactory.cs +++ b/VectoCore/VectoCoreTest/Utils/MockSimulationDataFactory.cs @@ -56,7 +56,7 @@ namespace TUGraz.VectoCore.Tests.Utils var gearboxInput = JSONInputDataFactory.ReadGearbox(gearBoxFile); var engineInput = JSONInputDataFactory.ReadEngine(engineFile); if (declarationMode) { - var dao = new DeclarationDataAdapter(); + var dao = new DeclarationDataAdapterTruck(); var vehicleInput = new MockDeclarationVehicleInputData() { EngineInputData = engineInput, GearboxInputData = gearboxInput @@ -85,7 +85,7 @@ namespace TUGraz.VectoCore.Tests.Utils public static AxleGearData CreateAxleGearDataFromFile(string axleGearFile, bool declarationMode = true) { if (declarationMode) { - var dao = new DeclarationDataAdapter(); + var dao = new DeclarationDataAdapterTruck(); var axleGearInput = JSONInputDataFactory.ReadGearbox(axleGearFile); return dao.CreateAxleGearData((IAxleGearInputData)axleGearInput); } else { diff --git a/VectoCore/VectoCoreTest/VectoCoreTest.csproj b/VectoCore/VectoCoreTest/VectoCoreTest.csproj index cfb697dc16..3c038dbd55 100644 --- a/VectoCore/VectoCoreTest/VectoCoreTest.csproj +++ b/VectoCore/VectoCoreTest/VectoCoreTest.csproj @@ -122,6 +122,7 @@ <Compile Include="Models\Declaration\DataAdapter\DeclarationDataAdapterTest_Class5.cs" /> <Compile Include="Models\Declaration\DataAdapter\DeclarationDataAdapterTest_Class2.cs" /> <Compile Include="Models\Declaration\DataAdapter\DeclarationDataAdapterTest_Class9.cs" /> + <Compile Include="Models\Declaration\DeclarationSegmentHeavyBusesTest.cs" /> <Compile Include="Models\Declaration\ShiftPolygonTest.cs" /> <Compile Include="Models\SimulationComponentData\TorqueConverterDataTest.cs" /> <Compile Include="Models\SimulationComponentData\ValidationTest.cs" /> diff --git a/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs b/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs index 29841b7c68..daafc780a5 100644 --- a/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs +++ b/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs @@ -644,7 +644,7 @@ namespace TUGraz.VectoCore.Tests.XML public void TestVehicleCategoryTypes() { var vehicleCategories = GetEnumOptions("VehicleCategoryDeclarationType", "1.0"); - var allowedCategories = DeclarationData.Segments.GetVehicleCategories(); + var allowedCategories = DeclarationData.TruckSegments.GetVehicleCategories(); foreach (var vehicleCategory in vehicleCategories) { if (vehicleCategory.Equals("Rigid Truck")) { continue; // Rigid Truck has been renamed to Rigid Lorry. The XML contains this entry for backward compatibility (separate testcase) @@ -835,7 +835,7 @@ namespace TUGraz.VectoCore.Tests.XML var gbxType = inputDataProvider.JobInputData.Vehicle.Components.GearboxInputData.Type; Assert.AreEqual(gearboxType, gbxType.ToXMLFormat()); - Assert.IsTrue(DeclarationDataAdapter.SupportedGearboxTypes.Contains(gbxType)); + Assert.IsTrue(DeclarationDataAdapterTruck.SupportedGearboxTypes.Contains(gbxType)); } } -- GitLab