diff --git a/VECTO/Input Files/Gearbox.vb b/VECTO/Input Files/Gearbox.vb index 3e4a270c9235a31a8f1d3be953983f0de336c158..3b9b02216ca954729ff8d4559eab1a4f1d996e33 100644 --- a/VECTO/Input Files/Gearbox.vb +++ b/VECTO/Input Files/Gearbox.vb @@ -27,7 +27,7 @@ Imports TUGraz.VectoCore.Utils <CustomValidation(GetType(Gearbox), "ValidateGearbox")> Public Class Gearbox - Implements IGearboxEngineeringInputData, IGearboxDeclarationInputData, IAxleGearInputData, + Implements IGearboxEngineeringInputData, IGearboxDeclarationInputData, IAxleGearInputData, ITorqueConverterEngineeringInputData, ITorqueConverterDeclarationInputData Private _myPath As String @@ -186,7 +186,7 @@ Public Class Gearbox ' ReSharper disable once UnusedMember.Global -- used by Validation Public Shared Function ValidateGearbox(gearbox As Gearbox, validationContext As ValidationContext) As ValidationResult - Dim modeService As ExecutionModeServiceContainer = TryCast(validationContext.GetService(GetType(ExecutionMode)), + Dim modeService As ExecutionModeServiceContainer = TryCast(validationContext.GetService(GetType(ExecutionMode)), ExecutionModeServiceContainer) Dim mode As ExecutionMode = If(modeService Is Nothing, ExecutionMode.Declaration, modeService.Mode) @@ -197,11 +197,11 @@ Public Class Gearbox 'Dim vectoJob As VectoJob = New VectoJob() With {.FilePath = VectoJobForm.VECTOfile} Dim vectoFile As String = VectoJobForm.VectoFile Dim inputData As IEngineeringInputDataProvider = - TryCast(JSONInputDataFactory.ReadComponentData(vectoFile), + TryCast(JSONInputDataFactory.ReadComponentData(vectoFile), IEngineeringInputDataProvider) 'Dim vehicle As IVehicleEngineeringInputData = inputData.VehicleInputData Dim engine As CombustionEngineData - Dim rdyn As Meter = 0.5.SI (Of Meter)() + Dim rdyn As Meter = 0.5.SI(Of Meter)() If mode = ExecutionMode.Declaration Then Dim doa As DeclarationDataAdapter = New DeclarationDataAdapter() @@ -342,7 +342,7 @@ Public Class Gearbox gearDict.ShiftPolygon = VectoCSVFile.Read(GearshiftFiles(i).FullPath) End If If Not String.IsNullOrWhiteSpace(MaxTorque(i)) AndAlso IsNumeric(MaxTorque(i)) Then - gearDict.MaxTorque = MaxTorque(i).ToDouble().SI (Of NewtonMeter)() + gearDict.MaxTorque = MaxTorque(i).ToDouble().SI(Of NewtonMeter)() End If If IsNumeric(GearLossMap(i, True)) Then gearDict.Efficiency = GearLossMap(i, True).ToDouble() @@ -365,13 +365,13 @@ Public Class Gearbox Public ReadOnly Property ITorqueConverterEngineeringInputData_Inertia As KilogramSquareMeter _ Implements ITorqueConverterEngineeringInputData.Inertia Get - Return TorqueConverterInertia.SI (Of KilogramSquareMeter)() + Return TorqueConverterInertia.SI(Of KilogramSquareMeter)() End Get End Property Public ReadOnly Property Inertia As KilogramSquareMeter Implements IGearboxEngineeringInputData.Inertia Get - Return GbxInertia.SI (Of KilogramSquareMeter)() + Return GbxInertia.SI(Of KilogramSquareMeter)() End Get End Property @@ -391,41 +391,41 @@ Public Class Gearbox Public ReadOnly Property CLUpshiftMinAcceleration As MeterPerSquareSecond _ Implements ITorqueConverterEngineeringInputData.CLUpshiftMinAcceleration Get - Return TCLUpshiftMinAcceleration.SI (Of MeterPerSquareSecond)() + Return TCLUpshiftMinAcceleration.SI(Of MeterPerSquareSecond)() End Get End Property Public ReadOnly Property CCUpshiftMinAcceleration As MeterPerSquareSecond _ Implements ITorqueConverterEngineeringInputData.CCUpshiftMinAcceleration Get - Return TCCUpshiftMinAcceleration.SI (Of MeterPerSquareSecond)() + Return TCCUpshiftMinAcceleration.SI(Of MeterPerSquareSecond)() End Get End Property Public ReadOnly Property TractionInterruption As Second Implements IGearboxEngineeringInputData.TractionInterruption Get - Return TracIntrSi.SI (Of Second)() + Return TracIntrSi.SI(Of Second)() End Get End Property Public ReadOnly Property TorqueReserve As Double Implements IGearboxEngineeringInputData.TorqueReserve Get - Return TorqueResv/100 + Return TorqueResv / 100 End Get End Property Public ReadOnly Property StartAcceleration As MeterPerSquareSecond _ Implements IGearboxEngineeringInputData.StartAcceleration Get - Return StartAcc.SI (Of MeterPerSquareSecond)() + Return StartAcc.SI(Of MeterPerSquareSecond)() End Get End Property Public ReadOnly Property StartTorqueReserve As Double Implements IGearboxEngineeringInputData.StartTorqueReserve Get - Return TorqueResvStart/100 + Return TorqueResvStart / 100 End Get End Property @@ -439,20 +439,20 @@ Public Class Gearbox Public ReadOnly Property DownshiftAferUpshiftDelay As Second _ Implements IGearboxEngineeringInputData.DownshiftAfterUpshiftDelay Get - Return DownshiftAfterUpshift.SI (Of Second)() + Return DownshiftAfterUpshift.SI(Of Second)() End Get End Property Public ReadOnly Property UpshiftAfterDownshiftDelay As Second _ Implements IGearboxEngineeringInputData.UpshiftAfterDownshiftDelay Get - Return UpshiftAfterDownshift.SI (Of Second)() + Return UpshiftAfterDownshift.SI(Of Second)() End Get End Property Public ReadOnly Property PowershiftShiftTime As Second Implements IGearboxEngineeringInputData.PowershiftShiftTime Get - Return PSShiftTime.SI (Of Second)() + Return PSShiftTime.SI(Of Second)() End Get End Property @@ -466,7 +466,7 @@ Public Class Gearbox Public ReadOnly Property IGearboxEngineeringInputData_UpshiftMinAcceleration As MeterPerSquareSecond _ Implements IGearboxEngineeringInputData.UpshiftMinAcceleration Get - Return UpshiftMinAcceleration.SI (Of MeterPerSquareSecond)() + Return UpshiftMinAcceleration.SI(Of MeterPerSquareSecond)() End Get End Property @@ -474,14 +474,14 @@ Public Class Gearbox Public ReadOnly Property IGearboxEngineeringInputData_StartSpeed As MeterPerSecond _ Implements IGearboxEngineeringInputData.StartSpeed Get - Return StartSpeed.SI (Of MeterPerSecond)() + Return StartSpeed.SI(Of MeterPerSecond)() End Get End Property Public ReadOnly Property MinTimeBetweenGearshift As Second _ Implements IGearboxEngineeringInputData.MinTimeBetweenGearshift Get - Return ShiftTime.SI (Of Second)() + Return ShiftTime.SI(Of Second)() End Get End Property diff --git a/VECTO/Input Files/VectoJob.vb b/VECTO/Input Files/VectoJob.vb index cd5afa53abc5ba6f55d1af7eeb9551d0765063b4..69c8d1520097d1390d39db9985b7f0ca46aea8ef 100644 --- a/VECTO/Input Files/VectoJob.vb +++ b/VECTO/Input Files/VectoJob.vb @@ -253,7 +253,10 @@ Public Class VectoJob RessourceHelper.ReadStream( DeclarationData.DeclarationDataResourcePrefix + ".VACC." + _driverAccelerationFile.OriginalPath + VectoCore.Configuration.Constants.FileExtensions.DriverAccelerationCurve) - Return VectoCSVFile.ReadStream(cycleDataRes) + Return _ + VectoCSVFile.ReadStream(cycleDataRes, + source:=DeclarationData.DeclarationDataResourcePrefix + ".VACC." + _driverAccelerationFile.OriginalPath + + VectoCore.Configuration.Constants.FileExtensions.DriverAccelerationCurve) Catch ex As Exception Return Nothing End Try @@ -305,7 +308,7 @@ Public Class VectoJob ' ReSharper disable once UnusedMember.Global -- used by Validation Public Shared Function ValidateJob(vectoJob As VectoJob, validationContext As ValidationContext) As ValidationResult - Dim modeService As ExecutionModeServiceContainer = TryCast(validationContext.GetService(GetType(ExecutionMode)), + Dim modeService As ExecutionModeServiceContainer = TryCast(validationContext.GetService(GetType(ExecutionMode)), ExecutionModeServiceContainer) Dim mode As ExecutionMode = If(modeService Is Nothing, ExecutionMode.Declaration, modeService.Mode) @@ -617,10 +620,10 @@ Public Class VectoJob cycleData = VectoCSVFile.Read(cycleFile.FullPath) Else Try - Dim cycleDataRes As Stream = - RessourceHelper.ReadStream( - DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + cycleFile.OriginalPath + ".vdri") - cycleData = VectoCSVFile.ReadStream(cycleDataRes) + Dim resourceName As String = DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + + cycleFile.OriginalPath + TUGraz.VectoCore.Configuration.Constants.FileExtensions.CycleFile + Dim cycleDataRes As Stream = RessourceHelper.ReadStream(resourceName) + cycleData = VectoCSVFile.ReadStream(cycleDataRes, source:=resourceName) Catch ex As Exception Throw New VectoException("Driving Cycle could not be read: " + cycleFile.OriginalPath) End Try @@ -659,7 +662,7 @@ Public Class VectoJob Public ReadOnly Property Auxiliaries As IList(Of IAuxiliaryEngineeringInputData) _ Implements IAuxiliariesEngineeringInputData.Auxiliaries Get - Return AuxData().Cast (Of IAuxiliaryEngineeringInputData).ToList() + Return AuxData().Cast(Of IAuxiliaryEngineeringInputData).ToList() End Get End Property @@ -687,7 +690,7 @@ Public Class VectoJob Public ReadOnly Property IAuxiliariesDeclarationInputData_Auxiliaries As IList(Of IAuxiliaryDeclarationInputData) _ Implements IAuxiliariesDeclarationInputData.Auxiliaries Get - Return AuxData().Cast (Of IAuxiliaryDeclarationInputData).ToList() + Return AuxData().Cast(Of IAuxiliaryDeclarationInputData).ToList() End Get End Property @@ -698,7 +701,7 @@ Public Class VectoJob retVal.Add(New AuxiliaryDataInputData() With { .ID = "ConstantAux", .AuxiliaryType = AuxiliaryDemandType.Constant, - .ConstantPowerDemand = AuxPAdd.SI (Of Watt)() + .ConstantPowerDemand = AuxPAdd.SI(Of Watt)() }) End If For Each auxEntry As KeyValuePair(Of String, AuxEntry) In AuxPaths @@ -718,7 +721,7 @@ Public Class VectoJob stream.ReadLine() ' skip header "Efficiency auxiliary to supply [-]" theAuxData.EfficiencyToSupply = stream.ReadLine().IndulgentParse() theAuxData.DemandMap = VectoCSVFile.ReadStream(New MemoryStream(Encoding.UTF8.GetBytes(stream.ReadToEnd())), - source := auxEntry.Value.Path.FullPath) + source:=auxEntry.Value.Path.FullPath) Next Return retVal diff --git a/VectoCommon/VectoCommon/InputData/TableData.cs b/VectoCommon/VectoCommon/InputData/TableData.cs index dab06bf240029617e7ad756ff0f0fd94397aebcb..d39590a29b8ea78ad69dc816962f4a3796a8c9d9 100644 --- a/VectoCommon/VectoCommon/InputData/TableData.cs +++ b/VectoCommon/VectoCommon/InputData/TableData.cs @@ -35,9 +35,9 @@ namespace TUGraz.VectoCommon.InputData { public class TableData : DataTable { - public TableData(string fileName) + public TableData(string fileName, DataSourceType sourceType = DataSourceType.CSVFile) { - SourceType = DataSourceType.CSVFile; + SourceType = sourceType; Source = fileName; } diff --git a/VectoConsole/Program.cs b/VectoConsole/Program.cs index c43997ec13c342d25fb95df27432b90e51832ec9..1b13c111ea95ecb4a84e449e621e10cf677053d2 100644 --- a/VectoConsole/Program.cs +++ b/VectoConsole/Program.cs @@ -277,10 +277,10 @@ Examples: Environment.ExitCode = Environment.ExitCode != 0 ? Environment.ExitCode : 1; } -#if DEBUG +//#if DEBUG Console.WriteLine("done."); Console.ReadKey(); -#endif +//#endif return Environment.ExitCode; } diff --git a/VectoConsole/Properties/Version.cs b/VectoConsole/Properties/Version.cs index 461621495045f78e762413307cc730cf30f5e90a..07af2f56d19940c162c83c521439e5a74ed764f4 100644 --- a/VectoConsole/Properties/Version.cs +++ b/VectoConsole/Properties/Version.cs @@ -30,5 +30,5 @@ */ using System.Reflection; -[assembly: AssemblyVersion("3.1.0.683")] -[assembly: AssemblyFileVersion("3.1.0.683")] +[assembly: AssemblyVersion("3.1.0.718")] +[assembly: AssemblyFileVersion("3.1.0.718")] diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs index 58e71ebfde573b2db5f0f09dc38600ea042496f6..f711212925ed0badb00bf78eaea61f52ea88df17 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs @@ -343,10 +343,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON cycleData = VectoCSVFile.Read(cycleFile); } else { try { - var cycleDataRes = - RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + - cycle.Value<string>() + ".vdri"); - cycleData = VectoCSVFile.ReadStream(cycleDataRes); + var resourceName = DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + + cycle.Value<string>() + Constants.FileExtensions.CycleFile; + cycleData = VectoCSVFile.ReadStream(RessourceHelper.ReadStream(resourceName), source: resourceName); } catch { Log.Debug("Driving Cycle could not be read: " + cycleFile); throw new VectoException("Driving Cycle could not be read: " + cycleFile); @@ -483,11 +482,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } catch (VectoException e) { Log.Warn("Could not find file for acceleration curve. Trying lookup in declaration data."); try { - var cycleDataRes = - RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".VACC." + - acceleration.Value<string>() + - Constants.FileExtensions.DriverAccelerationCurve); - return VectoCSVFile.ReadStream(cycleDataRes); + var resourceName = DeclarationData.DeclarationDataResourcePrefix + ".VACC." + + acceleration.Value<string>() + + Constants.FileExtensions.DriverAccelerationCurve; + return VectoCSVFile.ReadStream(RessourceHelper.ReadStream(resourceName), source: resourceName); } catch (Exception) { throw new VectoException("Failed to read Driver Acceleration Curve: " + e.Message, e); } diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs index feaf5c113c3339164fccce36a56af61452e11686..09a63d5cbc9981403704f7d68597a8dea79c7278 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs @@ -52,9 +52,9 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl protected IDeclarationInputDataProvider InputDataProvider; - protected DeclarationReport Report; + protected IDeclarationReport Report; - internal DeclarationModeVectoRunDataFactory(IDeclarationInputDataProvider dataProvider, DeclarationReport report) + internal DeclarationModeVectoRunDataFactory(IDeclarationInputDataProvider dataProvider, IDeclarationReport report) { InputDataProvider = dataProvider; Report = report; @@ -112,7 +112,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl AngledriveData = angledriveData, Aux = dao.CreateAuxiliaryData(InputDataProvider.AuxiliaryInputData(), mission.MissionType, segment.VehicleClass), - Cycle = cycle, + Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), Retarder = retarderData, DriverData = driverdata, ExecutionMode = ExecutionMode.Declaration, @@ -123,7 +123,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl }; simulationRunData.EngineData.WHTCCorrectionFactor = DeclarationData.WHTCCorrection.Lookup(mission.MissionType, engineData.WHTCRural, engineData.WHTCUrban, engineData.WHTCMotorway) * engineData.ColdHotCorrectionFactor; - simulationRunData.Cycle.Name = mission.MissionType.ToString(); + //simulationRunData.Cycle.Name = mission.MissionType.ToString(); simulationRunData.VehicleData.VehicleClass = segment.VehicleClass; yield return simulationRunData; } diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DrivingCycleProxy.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DrivingCycleProxy.cs new file mode 100644 index 0000000000000000000000000000000000000000..b96bf885f8413ee8898aace4f2124525c5ec22cd --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DrivingCycleProxy.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using System.Linq; +using TUGraz.VectoCore.Models.SimulationComponent.Data; + +namespace TUGraz.VectoCore.InputData.Reader.Impl +{ + public class DrivingCycleProxy : IDrivingCycleData + { + public DrivingCycleProxy(DrivingCycleData cycle, string name) + { + Name = name; + CycleType = cycle.CycleType; + Entries = cycle.Entries; + } + + public List<DrivingCycleData.DrivingCycleEntry> Entries { get; private set; } + + public string Name { get; private set; } + + public CycleType CycleType { get; private set; } + + public void Finish() + { + Entries = new List<DrivingCycleData.DrivingCycleEntry>() { + Entries.First(), + Entries.Last() + }; + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/EngineOnlyVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/EngineOnlyVectoRunDataFactory.cs index 2fdaf732bb9976c59219ad8bc9dbeb7252c4404d..7ffdd8c59a029e1c73004a092c498c308c1e904d 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/EngineOnlyVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/EngineOnlyVectoRunDataFactory.cs @@ -53,7 +53,9 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl var simulationRunData = new VectoRunData { JobName = InputDataProvider.JobInputData().JobName, EngineData = dao.CreateEngineData(InputDataProvider.EngineInputData, null), - Cycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, CycleType.EngineOnly, cycle.Name, false), + Cycle = + new DrivingCycleProxy( + DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, CycleType.EngineOnly, cycle.Name, false), cycle.Name), ExecutionMode = ExecutionMode.Engineering }; yield return simulationRunData; diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs index c659faea84303e3bd151fb823dcdc2aec4824740..821c566c140be8500abaec5d2843cc70118aad4b 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs @@ -36,6 +36,7 @@ using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data; [assembly: InternalsVisibleTo("VectoCoreTest")] @@ -43,6 +44,8 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl { public class EngineeringModeVectoRunDataFactory : LoggingObject, IVectoRunDataFactory { + private static readonly Dictionary<string, DrivingCycleData> CyclesCache = new Dictionary<string, DrivingCycleData>(); + protected readonly IEngineeringInputDataProvider InputDataProvider; internal EngineeringModeVectoRunDataFactory(IEngineeringInputDataProvider dataProvider) @@ -70,20 +73,29 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl var angledriveData = dao.CreateAngledriveData(InputDataProvider.AngledriveInputData, useEfficiencyFallback: true); var ptoTransmissionData = dao.CreatePTOTransmissionData(InputDataProvider.PTOTransmissionInputData); - return InputDataProvider.JobInputData().Cycles.Select(cycle => new VectoRunData { - JobName = InputDataProvider.JobInputData().JobName, - EngineData = engineData, - GearboxData = gearboxData, - AxleGearData = axlegearData, - AngledriveData = angledriveData, - VehicleData = dao.CreateVehicleData(vehicleInputData), - DriverData = driver, - Aux = dao.CreateAuxiliaryData(InputDataProvider.AuxiliaryInputData()), - AdvancedAux = dao.CreateAdvancedAuxData(InputDataProvider.AuxiliaryInputData()), - Retarder = dao.CreateRetarderData(InputDataProvider.RetarderInputData), - PTO = ptoTransmissionData, - Cycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, cycle.Name, crossWindRequired), - ExecutionMode = ExecutionMode.Engineering + return InputDataProvider.JobInputData().Cycles.Select(cycle => { + DrivingCycleData drivingCycle; + if (CyclesCache.ContainsKey(cycle.CycleData.Source)) { + drivingCycle = CyclesCache[cycle.CycleData.Source]; + } else { + drivingCycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, cycle.Name, crossWindRequired); + CyclesCache.Add(cycle.CycleData.Source, drivingCycle); + } + return new VectoRunData { + JobName = InputDataProvider.JobInputData().JobName, + EngineData = engineData, + GearboxData = gearboxData, + AxleGearData = axlegearData, + AngledriveData = angledriveData, + VehicleData = dao.CreateVehicleData(vehicleInputData), + DriverData = driver, + Aux = dao.CreateAuxiliaryData(InputDataProvider.AuxiliaryInputData()), + AdvancedAux = dao.CreateAdvancedAuxData(InputDataProvider.AuxiliaryInputData()), + Retarder = dao.CreateRetarderData(InputDataProvider.RetarderInputData), + PTO = ptoTransmissionData, + Cycle = new DrivingCycleProxy(drivingCycle, cycle.Name), + ExecutionMode = ExecutionMode.Engineering + }; }); } } diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index 7f07aa894ef18c1b05d5e6be31fd227e0e9994b8..fab524d0b2b11e63baebfe5c0e9c0f76adf71f4a 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -449,7 +449,7 @@ namespace TUGraz.VectoCore.Models.Declaration public static IEnumerable<TorqueConverterEntry> GetTorqueConverterDragCurve(double ratio) { var resourceId = DeclarationData.DeclarationDataResourcePrefix + ".TorqueConverter.csv"; - var data = VectoCSVFile.ReadStream(RessourceHelper.ReadStream(resourceId)); + var data = VectoCSVFile.ReadStream(RessourceHelper.ReadStream(resourceId), source: resourceId); var characteristicTorque = (from DataRow row in data.Rows select new TorqueConverterEntry() { diff --git a/VectoCore/VectoCore/Models/Declaration/LookupData.cs b/VectoCore/VectoCore/Models/Declaration/LookupData.cs index ef4c938336fff7a134d783c03a2c82e7f4d43422..5a1543ca639ed759a1e56de19919d65141aa0497 100644 --- a/VectoCore/VectoCore/Models/Declaration/LookupData.cs +++ b/VectoCore/VectoCore/Models/Declaration/LookupData.cs @@ -56,7 +56,7 @@ namespace TUGraz.VectoCore.Models.Declaration protected static DataTable ReadCsvResource(string resourceId) { - return VectoCSVFile.ReadStream(RessourceHelper.ReadStream(resourceId)); + return VectoCSVFile.ReadStream(RessourceHelper.ReadStream(resourceId), source: resourceId); } protected static void NormalizeTable(DataTable table) diff --git a/VectoCore/VectoCore/Models/Declaration/Segments.cs b/VectoCore/VectoCore/Models/Declaration/Segments.cs index 88fa836a691137a38eddd2c344ac572b556bd337..8606f7a12cf3cb44d7d4135c02e1731f12864dc3 100644 --- a/VectoCore/VectoCore/Models/Declaration/Segments.cs +++ b/VectoCore/VectoCore/Models/Declaration/Segments.cs @@ -48,7 +48,7 @@ namespace TUGraz.VectoCore.Models.Declaration protected override string ResourceId { - get { return DeclarationData.DeclarationDataResourcePrefix +".SegmentTable.csv"; } + get { return DeclarationData.DeclarationDataResourcePrefix + ".SegmentTable.csv"; } } protected override string ErrorMessage @@ -105,7 +105,9 @@ namespace TUGraz.VectoCore.Models.Declaration VehicleCategory = vehicleCategory, AxleConfiguration = axleConfiguration, VehicleClass = VehicleClassHelper.Parse(row.Field<string>("hdvclass")), - AccelerationFile = RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".VACC." + row.Field<string>(".vaccfile")), + AccelerationFile = + RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".VACC." + + row.Field<string>(".vaccfile")), Missions = CreateMissions(ref grossVehicleMassRating, curbWeight, row), GrossVehicleMassRating = grossVehicleMassRating }; @@ -155,7 +157,9 @@ namespace TUGraz.VectoCore.Models.Declaration var mission = new Mission { MissionType = missionType, CrossWindCorrection = row.Field<string>("crosswindcorrection" + GetMissionSuffix(missionType)), - CycleFile = RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + missionType + ".vdri"), + CycleFile = + RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + missionType + + Constants.FileExtensions.CycleFile), AxleWeightDistribution = GetAxleWeightDistribution(row, missionType), CurbWeight = curbWeight, BodyCurbWeight = body.CurbWeight, diff --git a/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs b/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs index 278104a6800979444f6f3f712573682d286b09f2..45554f3d5e8f957ac8eb56883be707eefa00e6a5 100644 --- a/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs +++ b/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs @@ -62,7 +62,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Data public AngledriveData AngledriveData { get; internal set; } [Required, ValidateObject] - public DrivingCycleData Cycle { get; internal set; } + public IDrivingCycleData Cycle { get; internal set; } [ValidateObject] public IEnumerable<AuxData> Aux { get; internal set; } @@ -86,7 +86,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Data public string ModFileSuffix { get; set; } [ValidateObject] - public DeclarationReport Report { get; set; } + public IDeclarationReport Report { get; set; } [Required, ValidateObject] public LoadingType Loading { get; set; } @@ -137,8 +137,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Data for (var angularVelocity = engineData.IdleSpeed; angularVelocity < engineData.FullLoadCurve.RatedSpeed; angularVelocity += 2.0 / 3.0 * (engineData.FullLoadCurve.RatedSpeed - engineData.IdleSpeed) / 10.0) { - if (!gear.Value.HasLockedGear) + if (!gear.Value.HasLockedGear) { continue; + } var velocity = angularVelocity / gear.Value.Ratio / angledriveRatio / axlegearRatio * dynamicTyreRadius; @@ -191,8 +192,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Data } if (runData.Cycle != null && runData.Cycle.Entries.Any(e => e.PTOActive)) { - if (runData.PTO == null || runData.PTO.PTOCycle == null) + if (runData.PTO == null || runData.PTO.PTOCycle == null) { return new ValidationResult("PTOCycle is used in DrivingCycle, but is not defined in Vehicle-Data."); + } } return ValidationResult.Success; diff --git a/VectoCore/VectoCore/Models/Simulation/IVehicleContainer.cs b/VectoCore/VectoCore/Models/Simulation/IVehicleContainer.cs index 7e6718f20c21b75659be6af6002af1bb7dae0202..2daff398d3236d13893b6cd391da4820d98549cd 100644 --- a/VectoCore/VectoCore/Models/Simulation/IVehicleContainer.cs +++ b/VectoCore/VectoCore/Models/Simulation/IVehicleContainer.cs @@ -71,6 +71,6 @@ namespace TUGraz.VectoCore.Models.Simulation /// <summary> /// Finishes the simulation. /// </summary> - void FinishSimulation(); + new void FinishSimulation(); } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index 046cec3062e92922488c384a1764cd73898336f5..4a7cddb69c5d4704cf7d070d2e969b5beb527393 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -111,7 +111,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl // PWheelCycle --> AxleGear --> CycleClutch --> Engine <-- Aux var powertrain = new PWheelCycle(container, data.Cycle, data.AxleGearData.AxleGear.Ratio, - gearbox.ModelData.Gears.ToDictionary(g => g.Key, g => g.Value.Ratio)) + gearbox.ModelData.Gears.ToDictionary(g => g.Key, g => g.Value.Ratio)) .AddComponent(new AxleGear(container, data.AxleGearData)) .AddComponent(data.AngledriveData != null ? new Angledrive(container, data.AngledriveData) : null) .AddComponent(gearbox, data.Retarder, container) @@ -294,7 +294,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl default: throw new VectoSimulationException("Unknown Gearbox Type: {0}", data.Type); } - return new Gearbox(container, data, strategy); + return new Gearbox(container, data, strategy, engineInertia); } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs index b6472931c07fc21d3d7d7447dcb643a574b4909e..998ae37ac35eb54fbbe18fcf24215026bba6a16a 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs @@ -57,7 +57,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl private readonly bool _engineOnlyMode; public SimulatorFactory(ExecutionMode mode, IInputDataProvider dataProvider, IOutputDataWriter writer, - DeclarationReport declarationReport = null) + IDeclarationReport declarationReport = null) { Log.Info("########## VectoCore Version {0} ##########", Assembly.GetExecutingAssembly().GetName().Version); JobNumber = Interlocked.Increment(ref _jobNumberCounter); @@ -125,6 +125,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl foreach (var data in DataReader.NextRun()) { var d = data; + if (d.Report != null) { + d.Report.PrepareResult(d.Loading, d.Mission); + } Action<ModalDataContainer> addReportResult = writer => { if (d.Report != null) { d.Report.AddResult(d.Loading, d.Mission, writer); @@ -174,7 +177,5 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl yield return run; } } - - } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs index 52d9aee6dcbf948bc1bbf29a77e269140700c9cf..9f002eee046869203c60ae8d428f85d7428d3383 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs @@ -318,6 +318,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ModData.Finish(RunStatus); WriteSumData(ModData, VehicleMass, VehicleLoading); + + ModData.FinishSimulation(); + DrivingCycle.FinishSimulation(); } public VectoRun.Status RunStatus { get; set; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs index 6224c73025a1a90360f0d2196865b6f50800b44f..be235259e15e25899382ee675bd7ade159208603 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs @@ -58,8 +58,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data } } + public interface IDrivingCycleData + { + List<DrivingCycleData.DrivingCycleEntry> Entries { get; } + string Name { get; } + CycleType CycleType { get; } + void Finish(); + } + [CustomValidation(typeof(DrivingCycleData), "ValidateCycleData")] - public class DrivingCycleData : SimulationComponentData + public class DrivingCycleData : SimulationComponentData, IDrivingCycleData { internal DrivingCycleData() {} @@ -69,6 +77,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public CycleType CycleType { get; internal set; } + public void Finish() {} + // ReSharper disable once UnusedMember.Global -- used by Validation public static ValidationResult ValidateCycleData(DrivingCycleData cycleData, ValidationContext validationContext) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/IDrivingCycleInfo.cs b/VectoCore/VectoCore/Models/SimulationComponent/IDrivingCycleInfo.cs index 412603402262683f035d0ab35d45b544751b1e38..5c5d33f124be1016bd3658cd861853252614d74f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/IDrivingCycleInfo.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/IDrivingCycleInfo.cs @@ -61,5 +61,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Meter lookaheadDistance); IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Second time); + + void FinishSimulation(); } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/IShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/IShiftStrategy.cs index 1bf8086e6865bebef0f60274e6406d2e74c37d5b..609afcc9cdb53c3fcbcff111f968b74640e4451a 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/IShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/IShiftStrategy.cs @@ -90,12 +90,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent /// </value> IGearbox Gearbox { get; set; } - GearInfo NextGear { get; } + GearInfo NextGear { get; } } - public class GearInfo - { - public uint Gear; - public bool TorqueConverterLocked; - } + public class GearInfo + { + public GearInfo(uint gear, bool tcLocked) + { + Gear = gear; + TorqueConverterLocked = tcLocked; + } + + public uint Gear { get; private set; } + public bool TorqueConverterLocked { get; private set; } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs index 3b514f143f608dc53e7becd32016e0ce304a1cc3..c0ba1ce3a45dcc9b2942d5e6dbda5dabb7be6e57 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs @@ -63,7 +63,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override GearInfo NextGear { - get { return new GearInfo() { Gear = _nextGear, TorqueConverterLocked = false }; } + get { return new GearInfo(_nextGear, false); } } public override uint Engage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs index c310894596c667c1e0cc1ec82b6caa6c3dad59ad..9974b8d7dfa0682ee5d76a7c39e0b6d3397e368f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs @@ -49,8 +49,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private readonly IShiftStrategy _strategy; protected internal readonly TorqueConverter TorqueConverter; private IIdleController _idleController; - private bool _requestAfterGearshift; - private readonly KilogramSquareMeter _engineInertia; + protected bool _requestAfterGearshift; public bool TorqueConverterLocked { @@ -60,12 +59,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public ATGearbox(IVehicleContainer container, GearboxData gearboxModelData, IShiftStrategy strategy, KilogramSquareMeter engineInertia) - : base(container, gearboxModelData) + : base(container, gearboxModelData, engineInertia) { _strategy = strategy; _strategy.Gearbox = this; - LastShift = double.MinValue.SI<Second>(); - _engineInertia = engineInertia; + LastShift = -double.MaxValue.SI<Second>(); TorqueConverter = new TorqueConverter(this, _strategy, container, gearboxModelData.TorqueConverterData, engineInertia); } @@ -234,32 +232,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return retVal; } - protected internal NewtonMeter ComputeShiftLosses(Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) - { - var torqueGbxIn = outTorque / ModelData.Gears[Gear].Ratio; - var deltaEngineSpeed = DataBus.EngineSpeed - outAngularVelocity * ModelData.Gears[Gear].Ratio; - var deltaClutchSpeed = (DataBus.EngineSpeed - PreviousState.OutAngularVelocity * ModelData.Gears[Gear].Ratio) / 2; - var torqueInertia = _engineInertia * deltaEngineSpeed / dt; - var averageEngineSpeed = (DataBus.EngineSpeed + outAngularVelocity * ModelData.Gears[Gear].Ratio) / 2; - var torqueLoss = (torqueGbxIn + torqueInertia) * deltaClutchSpeed / averageEngineSpeed; - - return torqueLoss.Abs(); - } - - private bool ConsiderShiftLosses(GearInfo nextGear, NewtonMeter torqueOut) - { - if (torqueOut.IsSmaller(0)) { - return false; - } - if (nextGear.Gear == 0) { - return false; - } - if (ModelData.Gears[2].HasTorqueConverter) { - return false; // nextGear.TorqueConverterLocked || nextGear.Gear == 2; - } - return nextGear.TorqueConverterLocked; - } - private IResponse RequestEngaged(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs index 695a3fb716c607cf7bb82360a1eebca2989c1057..3b525c878100ce523ec1ed921699db4b7d41fdf3 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs @@ -58,7 +58,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override GearInfo NextGear { - get { return new GearInfo { Gear = _nextGear.Gear, TorqueConverterLocked = _nextGear.TorqueConverterLocked }; } + get { return new GearInfo(_nextGear.Gear, _nextGear.TorqueConverterLocked); } } public ATShiftStrategy(GearboxData data, IDataBus dataBus) : base(data, dataBus) {} @@ -191,7 +191,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (_gearbox.TorqueConverterLocked || currentGear.HasLockedGear) { // UPSHIFT - General Rule - // L -> L+1 + // L -> L+1 // C -> L var nextGear = _gearbox.TorqueConverterLocked ? gear + 1 : gear; if (!ModelData.Gears.ContainsKey(nextGear)) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs index cbd54cf6086d345ad16b1471edb6cab289f62b35..3c5065a01872a9d6a3d00ba78493219e6e4f26d5 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs @@ -42,8 +42,8 @@ using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public abstract class AbstractGearbox<TStateType> : - StatefulProviderComponent<TStateType, ITnOutPort, ITnInPort, ITnOutPort>, ITnOutPort, ITnInPort, IGearbox, - IClutchInfo + StatefulProviderComponent<TStateType, ITnOutPort, ITnInPort, ITnOutPort>, ITnOutPort, ITnInPort, IGearbox, + IClutchInfo where TStateType : GearboxState, new() { /// <summary> @@ -51,9 +51,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// </summary> [Required, ValidateObject] internal readonly GearboxData ModelData; - protected AbstractGearbox(IVehicleContainer container, GearboxData gearboxModelData) : base(container) + protected KilogramSquareMeter EngineInertia; + + protected AbstractGearbox(IVehicleContainer container, GearboxData gearboxModelData, KilogramSquareMeter engineInertia) + : base(container) { ModelData = gearboxModelData; + EngineInertia = engineInertia; } #region ITnOutPort @@ -121,6 +125,35 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #endregion public abstract bool ClutchClosed(Second absTime); + + protected bool ConsiderShiftLosses(GearInfo nextGear, NewtonMeter torqueOut) + { + if (ModelData.Type.ManualTransmission()) { + return false; + } + if (torqueOut.IsSmaller(0)) { + return false; + } + if (nextGear.Gear == 0) { + return false; + } + if (ModelData.Gears[2].HasTorqueConverter) { + return false; // nextGear.TorqueConverterLocked || nextGear.Gear == 2; + } + return nextGear.TorqueConverterLocked; + } + + protected internal NewtonMeter ComputeShiftLosses(Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) + { + var torqueGbxIn = outTorque / ModelData.Gears[Gear].Ratio; + var deltaEngineSpeed = DataBus.EngineSpeed - outAngularVelocity * ModelData.Gears[Gear].Ratio; + var deltaClutchSpeed = (DataBus.EngineSpeed - PreviousState.OutAngularVelocity * ModelData.Gears[Gear].Ratio) / 2; + var torqueInertia = EngineInertia * deltaEngineSpeed / dt; + var averageEngineSpeed = (DataBus.EngineSpeed + outAngularVelocity * ModelData.Gears[Gear].Ratio) / 2; + var torqueLoss = (torqueGbxIn + torqueInertia) * deltaClutchSpeed / averageEngineSpeed; + + return torqueLoss.Abs(); + } } public class GearboxState : SimpleComponentState diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 381123158ec4b3f393e1bad32cd2459cfe8e5663..d4e0793639458abecf9e7674ba07d3f0006d085d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -430,7 +430,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CurrentState.StationaryFullLoadTorque = ModelData.FullLoadCurve.FullLoadStationaryTorque(angularVelocity); var stationaryFullLoadPower = CurrentState.StationaryFullLoadTorque * angularVelocity; - Watt dynFullPowerCalculated; + Watt dynFullPowerCalculated = 0.SI<Watt>(); // disable pt1 behaviour if PT1Disabled is true, or if the previous enginepower is greater than the current stationary fullload power (in this case the pt1 calculation fails) if (PT1Disabled || PreviousState.EnginePower.IsGreaterOrEqual(stationaryFullLoadPower)) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs index f888f90cf49c3c7d1fd9235efd441fa8b658176a..bfa80c81408007af7677e8064ebb39c0ea56446b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs @@ -51,7 +51,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected internal readonly TorqueConverter TorqueConverter; public CycleGearbox(IVehicleContainer container, GearboxData gearboxModelData, KilogramSquareMeter engineInertia) - : base(container, gearboxModelData) + : base(container, gearboxModelData, engineInertia) { if (!gearboxModelData.Type.AutomaticTransmission()) { return; @@ -102,13 +102,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl response = (TorqueConverterActive != null && TorqueConverterActive.Value) ? TorqueConverter.Initialize(inTorque, inAngularVelocity) : NextComponent.Initialize(inTorque, inAngularVelocity); + } else { + response = NextComponent.Initialize(inTorque, inAngularVelocity); } CurrentState.SetState(inTorque, inAngularVelocity, outTorque, outAngularVelocity); PreviousState.SetState(inTorque, inAngularVelocity, outTorque, outAngularVelocity); PreviousState.InertiaTorqueLossOut = 0.SI<NewtonMeter>(); PreviousState.Gear = Gear; - response = NextComponent.Initialize(inTorque, inAngularVelocity); response.GearboxPowerRequest = inTorque * inAngularVelocity; return response; } @@ -174,6 +175,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl effectiveLossMap = ModelData.Gears[Gear].TorqueConverterGearLossMap; } + if (effectiveLossMap == null || double.IsNaN(effectiveRatio)) { + throw new VectoSimulationException("Ratio or loss-map for gear {0}{1} invalid. Please check input data", Gear, + torqueConverterLocked ? "L" : "C"); + } + var avgOutAngularVelocity = (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0; var inTorqueLossResult = effectiveLossMap.GetTorqueLoss(avgOutAngularVelocity, outTorque); CurrentState.TorqueLossResult = inTorqueLossResult; @@ -220,10 +226,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return dryRunResponse; } - // this code has to be _after_ the check for a potential gear-shift! - // (the above block issues dry-run requests and thus may update the CurrentState!) CurrentState.TransmissionTorqueLoss = inTorque - (outTorque / effectiveRatio); + if (Gear != PreviousState.Gear && + ConsiderShiftLosses(new GearInfo(Gear, torqueConverterLocked), outTorque)) { + CurrentState.PowershiftLosses = ComputeShiftLosses(dt, outTorque, outAngularVelocity); + } + inTorque += CurrentState.PowershiftLosses ?? 0.SI<NewtonMeter>(); CurrentState.SetState(inTorque, inAngularVelocity, outTorque, outAngularVelocity); CurrentState.Gear = Gear; // end critical section @@ -330,6 +339,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (ModelData.Type.AutomaticTransmission()) { container[ModalResultField.TC_Locked] = !CurrentState.TorqueConverterActive; + container[ModalResultField.P_gbx_shift_loss] = CurrentState.PowershiftLosses == null + ? 0.SI<Watt>() + : CurrentState.PowershiftLosses * avgInAngularSpeed; } // torque converter fields are written by TorqueConverter (if present), called from Vehicle container } @@ -357,10 +369,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { get { - return new GearInfo() { - Gear = DataBus.CycleData.RightSample.Gear, - TorqueConverterLocked = !DataBus.CycleData.RightSample.TorqueConverterActive ?? true - }; + return new GearInfo(DataBus.CycleData.RightSample.Gear, !DataBus.CycleData.RightSample.TorqueConverterActive ?? true); } } @@ -376,6 +385,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public class CycleGearboxState : GearboxState { public bool TorqueConverterActive; + public NewtonMeter PowershiftLosses { get; set; } } public class CycleShiftStrategy : BaseShiftStrategy diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs index 58c429fe8d74007c983b6905a6e738c01149193b..9b04cfa5a974e19cac13a16e0ecea31c22266147 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs @@ -54,7 +54,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl IDrivingCycle, ISimulationOutPort, IDrivingCycleInPort, IDisposable { private const double LookaheadTimeSafetyMargin = 1.5; - private readonly DrivingCycleData _data; + private readonly IDrivingCycleData _data; internal readonly DrivingCycleEnumerator CycleIntervalIterator; private bool _intervalProlonged; internal IdleControllerSwitcher IdleController; @@ -69,7 +69,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl get { return CycleIntervalIterator.RightSample; } } - public DistanceBasedDrivingCycle(IVehicleContainer container, DrivingCycleData cycle) : base(container) + public DistanceBasedDrivingCycle(IVehicleContainer container, IDrivingCycleData cycle) : base(container) { _data = cycle; CycleIntervalIterator = new DrivingCycleEnumerator(_data); @@ -282,8 +282,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (!stopTime.IsEqual(0) && stopTime.IsEqual(PreviousState.WaitTime)) { // we needed to stop at the current interval in the cycle and have already waited enough time, move on.. - if (IdleController != null) + if (IdleController != null) { IdleController.ActivateIdle(); + } CycleIntervalIterator.MoveNext(); } @@ -303,8 +304,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } else { if (stopTime.IsEqual(PreviousState.WaitTime)) { // we needed to stop at the current interval in the cycle and have already waited enough time, move on.. - if (IdleController != null) + if (IdleController != null) { IdleController.ActivateIdle(); + } CycleIntervalIterator.MoveNext(); } } @@ -408,6 +410,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return LookAhead(LookaheadTimeSafetyMargin * DataBus.VehicleSpeed * time); } + public void FinishSimulation() + { + _data.Finish(); + } + public CycleData CycleData { get @@ -480,9 +487,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public sealed class DrivingCycleEnumerator : IEnumerator<DrivingCycleData.DrivingCycleEntry> { private int _currentCycleIndex; - private readonly DrivingCycleData _data; + private readonly IDrivingCycleData _data; - public DrivingCycleEnumerator(DrivingCycleData data) + public DrivingCycleEnumerator(IDrivingCycleData data) { _currentCycleIndex = 0; _data = data; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index b77fcb16961b7e34844681aecaa3393f1e820f82..93b7b417988f7f0438781e1acf3d128f7fa0af34 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -74,8 +74,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return _engageTime.IsSmallerOrEqual(absTime); } - public Gearbox(IVehicleContainer container, GearboxData gearboxModelData, IShiftStrategy strategy) - : base(container, gearboxModelData) + public Gearbox(IVehicleContainer container, GearboxData gearboxModelData, IShiftStrategy strategy, KilogramSquareMeter engineInertia) + : base(container, gearboxModelData, engineInertia) { _strategy = strategy; _strategy.Gearbox = this; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs index 329e953bb8020bc771916911b548cfdcf632ef77..8b3b5726a89af2c39fbfd202a47396967482b790 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs @@ -52,7 +52,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// </summary> public class MeasuredSpeedDrivingCycle : StatefulProviderComponent - <MeasuredSpeedDrivingCycle.DrivingCycleState, ISimulationOutPort, IDriverDemandInPort, IDriverDemandOutPort>, + <MeasuredSpeedDrivingCycle.DrivingCycleState, ISimulationOutPort, IDriverDemandInPort, IDriverDemandOutPort>, IDriverInfo, IDrivingCycleInfo, IMileageCounter, IDriverDemandInProvider, IDriverDemandInPort, ISimulationOutProvider, ISimulationOutPort { @@ -70,7 +70,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public MeterPerSquareSecond Acceleration; } - protected readonly DrivingCycleData Data; + protected readonly IDrivingCycleData Data; private bool _isInitializing; protected IEnumerator<DrivingCycleData.DrivingCycleEntry> RightSample { get; set; } protected IEnumerator<DrivingCycleData.DrivingCycleEntry> LeftSample { get; set; } @@ -82,7 +82,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// </summary> /// <param name="container">The container.</param> /// <param name="cycle">The cycle.</param> - public MeasuredSpeedDrivingCycle(IVehicleContainer container, DrivingCycleData cycle) + public MeasuredSpeedDrivingCycle(IVehicleContainer container, IDrivingCycleData cycle) : base(container) { Data = cycle; @@ -207,7 +207,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl getYValue: result => ((ResponseDryRun)result).DeltaFullLoad, evaluateFunction: x => NextComponent.Request(absTime, dt, x, gradient, true), criterion: - y => ((ResponseDryRun)y).DeltaFullLoad.Value()); + y => ((ResponseDryRun)y).DeltaFullLoad.Value()); Log.Info( "Found operating point for driver acceleration. absTime: {0}, dt: {1}, acceleration: {2}, gradient: {3}", absTime, @@ -227,9 +227,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl debug.Add(response); CurrentState.SimulationDistance = acceleration / 2 * dt * dt + DataBus.VehicleSpeed * dt; - if (CurrentState.SimulationDistance.IsSmaller(0)) + if (CurrentState.SimulationDistance.IsSmaller(0)) { throw new VectoSimulationException( "MeasuredSpeed: Simulation Distance must not be negative. Driving Backward is not allowed."); + } CurrentState.Distance = CurrentState.SimulationDistance + PreviousState.Distance; CurrentState.Acceleration = acceleration; @@ -307,6 +308,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl throw new NotImplementedException(); } + public void FinishSimulation() + { + Data.Finish(); + } + public bool VehicleStopped { get { return !_isInitializing && LeftSample.Current.VehicleTargetSpeed.IsEqual(0); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs index d453f58cf5249d85875841bd700bdbc1b665a8e3..1e81e876ab0d76371bdb613e4f50082f2a9af930 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PWheelCycle.cs @@ -53,7 +53,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <param name="cycle">The cycle.</param> /// <param name="axleRatio">The axle ratio.</param> /// <param name="gearRatios"></param> - public PWheelCycle(IVehicleContainer container, DrivingCycleData cycle, double axleRatio, + public PWheelCycle(IVehicleContainer container, IDrivingCycleData cycle, double axleRatio, IDictionary<uint, double> gearRatios) : base(container, cycle) { // just to ensure that null-gear has ratio 1 diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs index fb37c50311356d17fb09e8027ec407d248e5f64a..7b0cc4c5a2d7d96259c1f73c03070f4243703c6b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs @@ -51,7 +51,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl StatefulProviderComponent<SimpleComponentState, ISimulationOutPort, ITnInPort, ITnOutPort>, IDrivingCycleInfo, ISimulationOutPort, ITnInProvider, ITnInPort { - protected readonly DrivingCycleData Data; + protected readonly IDrivingCycleData Data; protected IEnumerator<DrivingCycleData.DrivingCycleEntry> RightSample { get; set; } protected IEnumerator<DrivingCycleData.DrivingCycleEntry> LeftSample { get; set; } @@ -62,7 +62,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// </summary> /// <param name="container">The container.</param> /// <param name="cycle">The cycle.</param> - public PowertrainDrivingCycle(IVehicleContainer container, DrivingCycleData cycle) : base(container) + public PowertrainDrivingCycle(IVehicleContainer container, IDrivingCycleData cycle) : base(container) { Data = cycle; LeftSample = Data.Entries.GetEnumerator(); @@ -218,5 +218,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { throw new NotImplementedException(); } + + public void FinishSimulation() + { + Data.Finish(); + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/OutputData/DeclarationReport.cs b/VectoCore/VectoCore/OutputData/DeclarationReport.cs index 3154a87b4201a298efd3b52dbeb34c8035a9e426..afe1d98050f1db20b6d2115b930ef8740e0ae4c0 100644 --- a/VectoCore/VectoCore/OutputData/DeclarationReport.cs +++ b/VectoCore/VectoCore/OutputData/DeclarationReport.cs @@ -32,38 +32,75 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.OutputData.PDF; namespace TUGraz.VectoCore.OutputData { + public interface IDeclarationReport + { + void PrepareResult(LoadingType loading, Mission mission); + void AddResult(LoadingType loadingType, Mission mission, IModalDataContainer modData); + void InitializeReport(VectoRunData modelData, Segment segment); + string Creator { get; set; } + string JobName { get; set; } + } + /// <summary> /// Class for creating a declaration report. /// </summary> - public abstract class DeclarationReport + public abstract class DeclarationReport<T> : IDeclarationReport where T : new() { - /// <summary> - /// Container class for one mission and the modData for the different loadings. - /// </summary> - protected class ResultContainer + ///// <summary> + ///// Container class for one mission and the modData for the different loadings. + ///// </summary> + //protected class ResultContainer<TResultEntry> + //{ + // /// <summary> + // /// The mission + // /// </summary> + // public Mission Mission; + + // /// <summary> + // /// Dictionary of LoadingTypes and DeclarationResults + // /// </summary> + // public Dictionary<LoadingType, TResultEntry> ModData; + //} + public class ResultContainer<TEntry> { - /// <summary> - /// The mission - /// </summary> + //public Stream PDFPage; public Mission Mission; - /// <summary> - /// Dictionary of LoadingTypes and their resulting Modal Data - /// </summary> - public Dictionary<LoadingType, IModalDataContainer> ModData; + public MissionProfile MissionProfile; + + public Dictionary<LoadingType, TEntry> ModData; + } + + public class MissionProfile + { + public readonly IList<double> DistanceKm; + public readonly IList<double> TargetSpeed; + public readonly IList<double> Altitude; + + public MissionProfile(IModalDataContainer m) + { + DistanceKm = m.GetValues<Meter>(ModalResultField.dist).Select(v => v.ConvertTo().Kilo.Meter).ToDouble(); + TargetSpeed = + m.GetValues<MeterPerSecond>(ModalResultField.v_targ).Select(v => v.ConvertTo().Kilo.Meter.Per.Hour).ToDouble(); + Altitude = m.GetValues<Meter>(ModalResultField.altitude).ToDouble(); + } } /// <summary> /// Dictionary of MissionTypes and their corresponding results. /// </summary> - protected readonly Dictionary<MissionType, ResultContainer> Missions = new Dictionary<MissionType, ResultContainer>(); + protected readonly Dictionary<MissionType, ResultContainer<T>> Missions = + new Dictionary<MissionType, ResultContainer<T>>(); /// <summary> /// The full load curve. @@ -78,7 +115,7 @@ namespace TUGraz.VectoCore.OutputData /// <summary> /// The creator name for the report. /// </summary> - public string Creator { get; internal set; } + public string Creator { get; set; } /// <summary> /// The name of the job file (report name will be the same) @@ -88,44 +125,66 @@ namespace TUGraz.VectoCore.OutputData /// <summary> /// The result count determines how many results must be given before the report gets written. /// </summary> - public int ResultCount { get; set; } + private int _resultCount; + + [MethodImpl(MethodImplOptions.Synchronized)] + public void PrepareResult(LoadingType loading, Mission mission) + { + if (!Missions.ContainsKey(mission.MissionType)) { + Missions[mission.MissionType] = new ResultContainer<T>() { + Mission = mission, + ModData = new Dictionary<LoadingType, T>() + }; + } + Missions[mission.MissionType].ModData[loading] = new T(); + } + - /// <summary> - /// Adds the result of one run for the specific mission and loading. If all runs finished (given by the resultCount) the report will be written. - /// </summary> - /// <param name="loadingType">Type of the loading.</param> - /// <param name="mission">The mission.</param> - /// <param name="modData">The mod data.</param> [MethodImpl(MethodImplOptions.Synchronized)] public void AddResult(LoadingType loadingType, Mission mission, IModalDataContainer modData) { if (modData.RunStatus != VectoRun.Status.Success) { - Missions.Clear(); + //Missions.Clear(); return; } - if (!Missions.ContainsKey(mission.MissionType)) { - Missions[mission.MissionType] = new ResultContainer { - Mission = mission, - ModData = new Dictionary<LoadingType, IModalDataContainer>() - }; + throw new VectoException("Unknown mission type {0} for generating declaration report", mission.MissionType); + } + if (!Missions[mission.MissionType].ModData.ContainsKey(loadingType)) { + throw new VectoException("Unknown loading type {0} for mission {1}", loadingType, mission.MissionType); } - Missions[mission.MissionType].ModData[loadingType] = modData; + if (Missions[mission.MissionType].MissionProfile == null) { + Missions[mission.MissionType].MissionProfile = new MissionProfile(modData); + } + _resultCount--; + + DoAddResult(Missions[mission.MissionType].ModData[loadingType], loadingType, mission, modData); - if (ResultCount == Missions.Sum(v => v.Value.ModData.Count)) { + if (_resultCount == 0) { DoWriteReport(); - Missions.Clear(); Flc = null; Segment = null; } } + /// <summary> + /// Adds the result of one run for the specific mission and loading. If all runs finished (given by the resultCount) the report will be written. + /// </summary> + /// <param name="entry"></param> + /// <param name="loadingType">Type of the loading.</param> + /// <param name="mission">The mission.</param> + /// <param name="modData">The mod data.</param> + [MethodImpl(MethodImplOptions.Synchronized)] + protected abstract void DoAddResult(T entry, LoadingType loadingType, Mission mission, IModalDataContainer modData); + + protected internal abstract void DoWriteReport(); + public void InitializeReport(VectoRunData modelData, Segment segment) { Segment = segment; - ResultCount = segment.Missions.Sum(m => m.Loadings.Count); + _resultCount = segment.Missions.Sum(m => m.Loadings.Count); DoInitializeReport(modelData, segment); } diff --git a/VectoCore/VectoCore/OutputData/IModalDataContainer.cs b/VectoCore/VectoCore/OutputData/IModalDataContainer.cs index af9e8f4a02b284756bf0efac6c8b0fc238a43d95..fcbbaedf01af0dc3f5377b8d0d33be9bafe87518 100644 --- a/VectoCore/VectoCore/OutputData/IModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/IModalDataContainer.cs @@ -86,6 +86,12 @@ namespace TUGraz.VectoCore.OutputData void SetDataValue(string fieldName, object value); void AddAuxiliary(string id, string columnName = null); + + /// <summary> + /// clear the modal data after the simulation + /// called after the simulation is finished and the sum-entries have been written + /// </summary> + void FinishSimulation(); } public static class ModalDataContainerExtensions @@ -167,8 +173,8 @@ namespace TUGraz.VectoCore.OutputData public static Scalar StopTimeShare(this IModalDataContainer data) { var stopTime = data.GetValues<MeterPerSecond>(ModalResultField.v_act) - .Zip(data.SimulationIntervals(), (v, dt) => new { v, dt }) - .Where(x => x.v < 0.1).Sum(x => x.dt) ?? 0.SI<Second>(); + .Zip(data.SimulationIntervals(), (v, dt) => new { v, dt }) + .Where(x => x.v < 0.1).Sum(x => x.dt) ?? 0.SI<Second>(); return 100 * (stopTime / data.Duration()).Cast<Scalar>(); } @@ -440,8 +446,9 @@ namespace TUGraz.VectoCore.OutputData var auxValues = data.GetValues<Watt>(auxCol).ToArray(); var sum = 0.SI<WattSecond>(); for (var i = 0; i < simulationIntervals.Length; i++) { - if (auxValues[i] != null && simulationIntervals[i] != null) + if (auxValues[i] != null && simulationIntervals[i] != null) { sum += auxValues[i] * simulationIntervals[i]; + } } return sum; } diff --git a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs index ce494c943b4f28945509e193c7597d95cd36e7a6..67017b0c09c48f807628cb449ff61ce704b40cdb 100644 --- a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs @@ -46,7 +46,7 @@ namespace TUGraz.VectoCore.OutputData private readonly bool _writeEngineOnly; private readonly IModalDataFilter[] _filters; private readonly Action<ModalDataContainer> _addReportResult; - internal ModalResults Data { get; set; } + protected internal ModalResults Data { get; set; } private DataRow CurrentRow { get; set; } private readonly IModalDataWriter _writer; @@ -301,5 +301,13 @@ namespace TUGraz.VectoCore.OutputData Auxiliaries[id] = col; } } + + public void FinishSimulation() + { + Data.Clear(); //.Rows.Clear(); + Data = null; + CurrentRow = null; + Auxiliaries.Clear(); + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/OutputData/PDF/PDFDeclarationReport.cs b/VectoCore/VectoCore/OutputData/PDF/PDFDeclarationReport.cs index fde7538824f468e37dedbc76ee31be1fbf454b0d..7ec70b93e499ff48df8fd12b3c0462a333c634b2 100644 --- a/VectoCore/VectoCore/OutputData/PDF/PDFDeclarationReport.cs +++ b/VectoCore/VectoCore/OutputData/PDF/PDFDeclarationReport.cs @@ -36,10 +36,11 @@ using System.Drawing.Imaging; using System.Globalization; using System.IO; using System.Linq; -using System.Threading.Tasks; +using System.Runtime.CompilerServices; using System.Windows.Forms.DataVisualization.Charting; using iTextSharp.text; using iTextSharp.text.pdf; +using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.Declaration; @@ -55,8 +56,41 @@ namespace TUGraz.VectoCore.OutputData.PDF /// <summary> /// Class for writing a PDF Declaration report. /// </summary> - public class PDFDeclarationReport : DeclarationReport + public class PDFDeclarationReport : DeclarationReport<PDFDeclarationReport.ResultEntry> { + public class ResultEntry + { + public IList<double> DistanceKm; + public IList<double> Speed; + + public IList<double> EngineSpeedAvg; + public IList<double> EngineTorqueAvg; + + public MeterPerSecond AverageSpeed; + public SI FcLiterPer100Km; + + public SI Co2GramPerKilometer; + + public void SetResultData(IModalDataContainer data) + { + DistanceKm = + data.GetValues<Meter>(ModalResultField.dist).Select(v => v.ConvertTo().Kilo.Meter).ToDouble(); + Speed = + data.GetValues<MeterPerSecond>(ModalResultField.v_act).Select(v => v.ConvertTo().Kilo.Meter.Per.Hour).ToDouble(); + + EngineSpeedAvg = + data.GetValues<PerSecond>(ModalResultField.n_eng_avg).Select(x => x.ConvertTo().Rounds.Per.Minute).ToDouble(); + EngineTorqueAvg = data.GetValues<NewtonMeter>(ModalResultField.T_eng_fcmap).ToDouble(); + + AverageSpeed = data.Speed(); + FcLiterPer100Km = data.FuelConsumptionFinalLiterPer100Kilometer() ?? 0.SI(); + + + Co2GramPerKilometer = (data.CO2PerMeter() ?? 0.SI<KilogramPerMeter>()).ConvertTo().Gramm.Per.Kilo.Meter; + } + } + + /// <summary> /// the writer which actually persists the stream (either to file or somewhere else). /// </summary> @@ -92,6 +126,21 @@ namespace TUGraz.VectoCore.OutputData.PDF _writer = writer; } + + /// <summary> + /// Adds the result of one run for the specific mission and loading. If all runs finished (given by the resultCount) the report will be written. + /// </summary> + /// <param name="entry"></param> + /// <param name="loadingType">Type of the loading.</param> + /// <param name="mission">The mission.</param> + /// <param name="modData">The mod data.</param> + [MethodImpl(MethodImplOptions.Synchronized)] + protected override void DoAddResult(ResultEntry entry, LoadingType loadingType, Mission mission, + IModalDataContainer modData) + { + entry.SetResultData(modData); + } + /// <summary> /// Creates the report and writes it to a pdf file. /// </summary> @@ -99,13 +148,15 @@ namespace TUGraz.VectoCore.OutputData.PDF { ReportDate = DateTime.Now.ToUniversalTime().ToString(CultureInfo.InvariantCulture); - var tasks = new List<Task<Stream>> { Task.Run(() => CreateTitlePage(Missions)) }; - tasks.AddRange(Missions - .OrderBy(m => m.Key) - .Select((m, i) => Task.Run(() => CreateCyclePage(m.Value, i + 2, Missions.Count + 1)))); + var pages = new List<Stream>() { + CreateTitlePage(Missions) + }; + //tasks.AddRange( + pages.AddRange(Missions.OrderBy(m => m.Key) + .Select((m, i) => CreateCyclePage(m.Value, i + 2, Missions.Count + 1))); - Task.WaitAll(tasks.Cast<Task>().ToArray()); - var pages = tasks.Select(t => t.Result); + //Task.WaitAll(tasks.Cast<Task>().ToArray()); + // = tasks.Select(t => t.Result); MergeDocuments(pages, _writer.WriteStream(ReportType.DeclarationReportPdf)); } @@ -131,7 +182,7 @@ namespace TUGraz.VectoCore.OutputData.PDF /// </summary> /// <param name="missions">The missions.</param> /// <returns>the out stream of the pdf stamper with the title page.</returns> - private Stream CreateTitlePage(Dictionary<MissionType, ResultContainer> missions) + private Stream CreateTitlePage(Dictionary<MissionType, ResultContainer<ResultEntry>> missions) { var stream = new MemoryStream(); var resourceName = string.Format("{0}.Report.title{1}CyclesTemplate.pdf", @@ -166,19 +217,17 @@ namespace TUGraz.VectoCore.OutputData.PDF var data = results.ModData[LoadingType.ReferenceLoad]; pdfFields.SetField("Loading" + i, results.Mission.RefLoad.ConvertTo().Ton.ToOutputFormat(1) + " t"); - pdfFields.SetField("Speed" + i, data.Speed().ConvertTo().Kilo.Meter.Per.Hour.ToOutputFormat(1) + " km/h"); + pdfFields.SetField("Speed" + i, data.AverageSpeed.ConvertTo().Kilo.Meter.Per.Hour.ToOutputFormat(1) + " km/h"); - var fcLiterPer100Km = data.FuelConsumptionFinalLiterPer100Kilometer() ?? 0.SI(); - pdfFields.SetField("FC" + i, fcLiterPer100Km.ToOutputFormat(1)); + pdfFields.SetField("FC" + i, data.FcLiterPer100Km.ToOutputFormat(1)); var loadingTon = results.Mission.RefLoad.ConvertTo().Ton; - var fcLiterPer100Tonkm = fcLiterPer100Km / loadingTon; + var fcLiterPer100Tonkm = data.FcLiterPer100Km / loadingTon; pdfFields.SetField("FCt" + i, fcLiterPer100Tonkm.ToOutputFormat(1)); - var co2GrammPerKm = (data.CO2PerMeter() ?? 0.SI<KilogramPerMeter>()).ConvertTo().Gramm.Per.Kilo.Meter; - var co2GrammPerTonKm = co2GrammPerKm / loadingTon; + var co2GrammPerTonKm = data.Co2GramPerKilometer / loadingTon; - pdfFields.SetField("CO2" + i, co2GrammPerKm.ToOutputFormat(1)); + pdfFields.SetField("CO2" + i, data.Co2GramPerKilometer.ToOutputFormat(1)); pdfFields.SetField("CO2t" + i, co2GrammPerTonKm.ToOutputFormat(1)); i++; } @@ -215,7 +264,7 @@ namespace TUGraz.VectoCore.OutputData.PDF /// <param name="currentPageNr">The current page nr.</param> /// <param name="pageCount">The page count.</param> /// <returns>the out stream of the pdfstamper for a single cycle page</returns> - private Stream CreateCyclePage(ResultContainer results, int currentPageNr, int pageCount) + private Stream CreateCyclePage(ResultContainer<ResultEntry> results, int currentPageNr, int pageCount) { var stream = new MemoryStream(); @@ -248,17 +297,15 @@ namespace TUGraz.VectoCore.OutputData.PDF var loadAppendix = loadingType.GetShortName(); pdfFields.SetField("Load" + loadAppendix, loadingTon.ToOutputFormat(1) + " t"); - pdfFields.SetField("Speed" + loadAppendix, data.Speed().ConvertTo().Kilo.Meter.Per.Hour.ToOutputFormat(1)); + pdfFields.SetField("Speed" + loadAppendix, data.AverageSpeed.ConvertTo().Kilo.Meter.Per.Hour.ToOutputFormat(1)); - var fcLiterPer100Km = data.FuelConsumptionFinalLiterPer100Kilometer() ?? 0.SI(); - pdfFields.SetField("FCkm" + loadAppendix, fcLiterPer100Km.ToOutputFormat(1)); + pdfFields.SetField("FCkm" + loadAppendix, data.FcLiterPer100Km.ToOutputFormat(1)); pdfFields.SetField("FCtkm" + loadAppendix, - loadingTon.IsEqual(0) ? "-" : (fcLiterPer100Km / loadingTon).ToOutputFormat(1)); + loadingTon.IsEqual(0) ? "-" : (data.FcLiterPer100Km / loadingTon).ToOutputFormat(1)); - var co2GrammPerKm = (data.CO2PerMeter() ?? 0.SI<KilogramPerMeter>()).ConvertTo().Gramm.Per.Kilo.Meter; - pdfFields.SetField("CO2km" + loadAppendix, co2GrammPerKm.ToOutputFormat(1)); + pdfFields.SetField("CO2km" + loadAppendix, data.Co2GramPerKilometer.ToOutputFormat(1)); pdfFields.SetField("CO2tkm" + loadAppendix, - loadingTon.IsEqual(0) ? "-" : (co2GrammPerKm / loadingTon).ToOutputFormat(1)); + loadingTon.IsEqual(0) ? "-" : (data.Co2GramPerKilometer / loadingTon).ToOutputFormat(1)); } var content = stamper.GetOverContent(1); @@ -268,7 +315,7 @@ namespace TUGraz.VectoCore.OutputData.PDF img.SetAbsolutePosition(600, 475); content.AddImage(img); - img = Image.GetInstance(DrawCycleChart(results), BaseColor.WHITE); + img = Image.GetInstance(DrawCycleChart(results.MissionProfile, results.ModData), BaseColor.WHITE); img.ScaleAbsolute(780, 156); img.SetAbsolutePosition(17, 270); content.AddImage(img); @@ -311,7 +358,7 @@ namespace TUGraz.VectoCore.OutputData.PDF /// </summary> /// <param name="missions">The missions.</param> /// <returns></returns> - private static Bitmap DrawCo2MissionsChart(Dictionary<MissionType, ResultContainer> missions) + private static Bitmap DrawCo2MissionsChart(Dictionary<MissionType, ResultContainer<ResultEntry>> missions) { var co2Chart = new Chart { Width = 1500, Height = 700 }; co2Chart.Legends.Add(new Legend("main") { @@ -340,8 +387,7 @@ namespace TUGraz.VectoCore.OutputData.PDF var data = missionResult.Value.ModData[LoadingType.ReferenceLoad]; var loadingTon = missionResult.Value.Mission.Loadings[LoadingType.ReferenceLoad].ConvertTo().Ton; - var co2GrammPerTonKm = (data.CO2PerMeter() ?? 0.SI<KilogramPerMeter>()).ConvertTo().Gramm.Per.Kilo.Meter / - loadingTon; + var co2GrammPerTonKm = data.Co2GramPerKilometer / loadingTon; var series = new Series(missionResult.Key + " (Ref. load.)"); var dataPoint = new DataPoint { @@ -367,7 +413,7 @@ namespace TUGraz.VectoCore.OutputData.PDF /// </summary> /// <param name="missions">The missions.</param> /// <returns></returns> - private static Bitmap DrawCo2SpeedChart(Dictionary<MissionType, ResultContainer> missions) + private static Bitmap DrawCo2SpeedChart(Dictionary<MissionType, ResultContainer<ResultEntry>> missions) { var co2SpeedChart = new Chart { Width = 1500, Height = 700 }; co2SpeedChart.Legends.Add(new Legend("main") { @@ -404,14 +450,14 @@ namespace TUGraz.VectoCore.OutputData.PDF foreach (var pair in missionResult.Value.ModData) { var data = missionResult.Value.ModData[pair.Key]; - var co2GramPerKilometer = (data.CO2PerMeter() ?? 0.SI<KilogramPerMeter>()).ConvertTo().Gramm.Per.Kilo.Meter; var loadingTon = missionResult.Value.Mission.Loadings[pair.Key].ConvertTo().Ton; - var point = new DataPoint(data.Speed().ConvertTo().Kilo.Meter.Per.Hour.Value(), co2GramPerKilometer.Value()) { - Label = string.Format(CultureInfo.InvariantCulture, "{0:0.0} t", loadingTon.Value()), - Font = new Font("Helvetica", 16), - LabelBackColor = Color.White - }; + var point = new DataPoint(data.AverageSpeed.ConvertTo().Kilo.Meter.Per.Hour.Value(), + data.Co2GramPerKilometer.Value()) { + Label = string.Format(CultureInfo.InvariantCulture, "{0:0.0} t", loadingTon.Value()), + Font = new Font("Helvetica", 16), + LabelBackColor = Color.White + }; if (pair.Key != LoadingType.ReferenceLoad) { point.MarkerSize = 10; @@ -432,9 +478,10 @@ namespace TUGraz.VectoCore.OutputData.PDF /// <summary> /// Draws the cycle chart for a cycle page. /// </summary> - /// <param name="results">The results.</param> + /// <param name="profile">The speed/altitude profile of the mission</param> + /// <param name="results">results for different loadings</param> /// <returns></returns> - private static Bitmap DrawCycleChart(ResultContainer results) + private static Bitmap DrawCycleChart(MissionProfile profile, Dictionary<LoadingType, ResultEntry> results) { var missionCycleChart = new Chart { Width = 2000, Height = 400 }; missionCycleChart.Legends.Add(new Legend("main") { @@ -479,24 +526,17 @@ namespace TUGraz.VectoCore.OutputData.PDF YAxisType = AxisType.Secondary }; - var m = results.ModData.First().Value; - var distanceKm = m.GetValues<Meter>(ModalResultField.dist).Select(v => v.ConvertTo().Kilo.Meter).ToDouble(); - - altitude.Points.DataBindXY(distanceKm, m.GetValues<Meter>(ModalResultField.altitude).ToDouble()); + altitude.Points.DataBindXY(profile.DistanceKm, profile.Altitude); missionCycleChart.Series.Add(altitude); var targetSpeed = new Series { ChartType = SeriesChartType.FastLine, BorderWidth = 3, Name = "Target speed" }; - targetSpeed.Points.DataBindXY(distanceKm, - m.GetValues<MeterPerSecond>(ModalResultField.v_targ).Select(v => v.ConvertTo().Kilo.Meter.Per.Hour).ToDouble()); + targetSpeed.Points.DataBindXY(profile.DistanceKm, profile.TargetSpeed); missionCycleChart.Series.Add(targetSpeed); - foreach (var result in results.ModData) { + foreach (var result in results) { var name = result.Key.ToString(); - var values = result.Value; var series = new Series { ChartType = SeriesChartType.FastLine, Name = name }; - series.Points.DataBindXY( - values.GetValues<Meter>(ModalResultField.dist).Select(v => v.ConvertTo().Kilo.Meter).ToDouble(), - values.GetValues<MeterPerSecond>(ModalResultField.v_act).Select(v => v.ConvertTo().Kilo.Meter.Per.Hour).ToDouble()); + series.Points.DataBindXY(result.Value.DistanceKm, result.Value.Speed); missionCycleChart.Series.Add(series); } missionCycleChart.Update(); @@ -512,7 +552,7 @@ namespace TUGraz.VectoCore.OutputData.PDF /// <param name="modData">The mod data.</param> /// <param name="flc">The FLC.</param> /// <returns></returns> - private static Bitmap DrawOperatingPointsChart(IModalDataContainer modData, FullLoadCurve flc) + private static Bitmap DrawOperatingPointsChart(ResultEntry modData, FullLoadCurve flc) { var operatingPointsChart = new Chart { Width = 1000, Height = 427 }; operatingPointsChart.Legends.Add(new Legend("main") { @@ -560,9 +600,7 @@ namespace TUGraz.VectoCore.OutputData.PDF operatingPointsChart.Series.Add(dragLoadCurve); var dataPoints = new Series("load points (Ref. load.)") { ChartType = SeriesChartType.Point, Color = Color.Red }; - dataPoints.Points.DataBindXY( - modData.GetValues<PerSecond>(ModalResultField.n_eng_avg).Select(x => x.ConvertTo().Rounds.Per.Minute).ToDouble(), - modData.GetValues<NewtonMeter>(ModalResultField.T_eng_fcmap).ToDouble()); + dataPoints.Points.DataBindXY(modData.EngineSpeedAvg, modData.EngineTorqueAvg); operatingPointsChart.Series.Add(dataPoints); operatingPointsChart.Update(); diff --git a/VectoCore/VectoCore/Properties/Version.cs b/VectoCore/VectoCore/Properties/Version.cs index 73b9ecba332c38db4000cbdb0ad93c0c1c5dbd3b..0d26cb08f0a6b92225d3ee59442ea66c40918c13 100644 --- a/VectoCore/VectoCore/Properties/Version.cs +++ b/VectoCore/VectoCore/Properties/Version.cs @@ -30,5 +30,5 @@ */ using System.Reflection; -[assembly: AssemblyVersion("3.1.0.683")] -[assembly: AssemblyFileVersion("3.1.0.683")] +[assembly: AssemblyVersion("3.1.0.718")] +[assembly: AssemblyFileVersion("3.1.0.718")] diff --git a/VectoCore/VectoCore/Utils/VectoCSVFile.cs b/VectoCore/VectoCore/Utils/VectoCSVFile.cs index 0e5b17ff5e7225e775a86f9ad437baa15a682433..9fe3760be8d039ab2691ad241c3276641c561501 100644 --- a/VectoCore/VectoCore/Utils/VectoCSVFile.cs +++ b/VectoCore/VectoCore/Utils/VectoCSVFile.cs @@ -95,7 +95,7 @@ namespace TUGraz.VectoCore.Utils public static TableData ReadStream(Stream stream, bool ignoreEmptyColumns = false, bool fullHeader = false, string source = null) { - var retVal = new TableData(source); + var retVal = new TableData(source, DataSourceType.Embedded); ReadCSV(retVal, stream, ignoreEmptyColumns, fullHeader); return retVal; } diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index 23f4b2a9801e5b0ccc2dc2710d1c77098d1eecb3..f71f94b031693c6c7bca8843a8c44d10166d5741 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -127,6 +127,7 @@ <Compile Include="InputData\Reader\FullLoadCurveReader.cs" /> <Compile Include="InputData\Reader\Impl\AbstractVectoRunDataFactory.cs" /> <Compile Include="InputData\Reader\Impl\DeclarationModeVectoRunDataFactory.cs" /> + <Compile Include="InputData\Reader\Impl\DrivingCycleProxy.cs" /> <Compile Include="InputData\Reader\Impl\EngineeringModeVectoRunDataFactory.cs" /> <Compile Include="InputData\Reader\Impl\EngineOnlyVectoRunDataFactory.cs" /> <Compile Include="InputData\Reader\ShiftPolygonReader.cs" /> diff --git a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs index 837732b7a11c49c72e49623ddecff57786eff00d..f797490a05be21dfd9ae0c0b4d565e4f93cde4ee 100644 --- a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs @@ -94,7 +94,7 @@ namespace TUGraz.VectoCore.Tests.Integration .AddComponent(new Brakes(container)) .AddComponent(new AxleGear(container, axleGearData)) .AddComponent(new DummyRetarder(container)) - .AddComponent(new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container))) + .AddComponent(new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container), engineData.Inertia)) .AddComponent(new Clutch(container, engineData)) .AddComponent(engine); diff --git a/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs index 8f63065bfe1093bc11337acb1da8a4454ded2cdf..7e4aac905d1b8a766195b9758449d76db01242e6 100644 --- a/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs +++ b/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs @@ -98,7 +98,7 @@ namespace TUGraz.VectoCore.Tests.Integration .AddComponent(new Brakes(container)) .AddComponent(new AxleGear(container, axleGearData)) .AddComponent(new DummyRetarder(container)) - .AddComponent(new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container))) + .AddComponent(new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container), engineData.Inertia)) .AddComponent(clutch) .AddComponent(engine); diff --git a/VectoCore/VectoCoreTest/Integration/SimpleDrivingCycles.cs b/VectoCore/VectoCoreTest/Integration/SimpleDrivingCycles.cs index 814541986a7086f15dc3d7e90627ee83c993efd8..145eb9cc26a81fae50a1947ae33853de301ffbb1 100644 --- a/VectoCore/VectoCoreTest/Integration/SimpleDrivingCycles.cs +++ b/VectoCore/VectoCoreTest/Integration/SimpleDrivingCycles.cs @@ -30,6 +30,7 @@ */ using System.Diagnostics.CodeAnalysis; +using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.Reader; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.SimulationComponent.Data; @@ -279,7 +280,8 @@ namespace TUGraz.VectoCore.Tests.Integration public static DrivingCycleData ReadDeclarationCycle(string missionType) { var cycleData = - RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + missionType + ".vdri"); + RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + missionType + + Constants.FileExtensions.CycleFile); var cycle = DrivingCycleDataReader.ReadFromStream(cycleData, CycleType.DistanceBased, "", false); return cycle; } diff --git a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs index 38b651ec3a658ddc3548e224585c9fc840ebc182..2fa438bb5363002694dc270c676ded1cca00bf10 100644 --- a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs @@ -89,7 +89,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns .AddComponent(new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)) .AddComponent(new Brakes(container)) .AddComponent(new AxleGear(container, axleGearData)) - .AddComponent(new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container))) + .AddComponent(new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container), engineData.Inertia)) .AddComponent(new Clutch(container, engineData)) .AddComponent(new CombustionEngine(container, engineData)); @@ -145,7 +145,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns .AddComponent(new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)) .AddComponent(new Brakes(container)) .AddComponent(new AxleGear(container, axleGearData)) - .AddComponent(new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container))) + .AddComponent(new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container), engineData.Inertia)) .AddComponent(new Clutch(container, engineData)) .AddComponent(new CombustionEngine(container, engineData)); @@ -215,7 +215,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns .AddComponent(new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia)) .AddComponent(new Brakes(container)) .AddComponent(new AxleGear(container, axleGearData)) - .AddComponent(new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container))) + .AddComponent(new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container), engineData.Inertia)) .AddComponent(new Clutch(container, engineData)) .AddComponent(new CombustionEngine(container, engineData)); diff --git a/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs index 872c1b435994a159b190f8160b37a9b64042c754..e138525b8b6a9ff7e0539096b41e8f8e442e6b5b 100644 --- a/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs +++ b/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs @@ -118,7 +118,7 @@ namespace TUGraz.VectoCore.Tests.Integration .AddComponent(new Brakes(container)) .AddComponent(new AxleGear(container, axleGearData)) .AddComponent(new DummyRetarder(container)) - .AddComponent(new Gearbox(container, gearboxData, gbxStrategy)) + .AddComponent(new Gearbox(container, gearboxData, gbxStrategy, engineData.Inertia)) .AddComponent(clutch) .AddComponent(engine); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs index 0cd5c2858be25d84c8a5b490636fcb2a1ecb985f..33ee80a0dc2780b385c619039ae39dc26b2cd217 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs @@ -198,7 +198,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent { var gearboxData = MockSimulationDataFactory.CreateGearboxDataFromFile(gbxFile, engineFile); var container = new VehicleContainer(ExecutionMode.Engineering); - var gearbox = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container)); + var gearbox = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container), 0.SI<KilogramSquareMeter>()); var driver = new MockDriver(container); var vehicle = new MockVehicle(container) { MyVehicleSpeed = 0.KMPHtoMeterPerSecond() }; @@ -231,7 +231,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent { var gearboxData = MockSimulationDataFactory.CreateGearboxDataFromFile(gbxFile, engineFile); var container = new VehicleContainer(ExecutionMode.Declaration); - var gearbox = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container)); + var gearbox = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container), 0.SI<KilogramSquareMeter>()); var driver = new MockDriver(container); var vehicle = new MockVehicle(container) { MyVehicleSpeed = 0.KMPHtoMeterPerSecond() }; @@ -264,7 +264,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent { var gearboxData = MockSimulationDataFactory.CreateGearboxDataFromFile(GearboxDataFile, EngineDataFile); var container = new VehicleContainer(executionMode: ExecutionMode.Engineering); - var gearbox = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container)); + var gearbox = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container), 0.SI<KilogramSquareMeter>()); var driver = new MockDriver(container); var vehicle = new MockVehicle(container) { MyVehicleSpeed = 0.KMPHtoMeterPerSecond() }; @@ -298,7 +298,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent { var gearboxData = MockSimulationDataFactory.CreateGearboxDataFromFile(GearboxDataFile, EngineDataFile); var container = new VehicleContainer(ExecutionMode.Engineering); - var gearbox = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container)); + var gearbox = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container), 0.SI<KilogramSquareMeter>()); var driver = new MockDriver(container); var vehicle = new MockVehicle(container) { MyVehicleSpeed = 0.KMPHtoMeterPerSecond() }; @@ -329,7 +329,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent { var container = new VehicleContainer(ExecutionMode.Engineering); var gearboxData = MockSimulationDataFactory.CreateGearboxDataFromFile(GearboxDataFile, EngineDataFile); - var gearbox = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container)); + var gearbox = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container), 0.SI<KilogramSquareMeter>()); var vehicle = new MockVehicle(container) { MyVehicleSpeed = 0.KMPHtoMeterPerSecond() }; var driver = new MockDriver(container); @@ -391,7 +391,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent { var container = new VehicleContainer(ExecutionMode.Engineering); var gearboxData = CreateGearboxData(); - var gearbox = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container)); + var gearbox = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container), 0.SI<KilogramSquareMeter>()); var driver = new MockDriver(container); var vehicle = new MockVehicle(container) { MyVehicleSpeed = 0.KMPHtoMeterPerSecond() }; @@ -439,7 +439,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent { var container = new VehicleContainer(ExecutionMode.Engineering); var gearboxData = MockSimulationDataFactory.CreateGearboxDataFromFile(GearboxDataFile, EngineDataFile); - var gearbox = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container)); + var gearbox = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container), 0.SI<KilogramSquareMeter>()); var driver = new MockDriver(container); var port = new MockTnOutPort() { EngineN95hSpeed = 2000.RPMtoRad() }; @@ -490,7 +490,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent TotalMass = 19000.SI<Kilogram>() }; var gearboxData = MockSimulationDataFactory.CreateGearboxDataFromFile(GearboxDataFile, EngineDataFile); - var gearbox = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container)); + var gearbox = new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container), 0.SI<KilogramSquareMeter>()); var port = new MockTnOutPort() { EngineN95hSpeed = 2000.RPMtoRad() }; container.Engine = port; gearbox.InPort().Connect(port); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/DistanceCycleDataTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/DistanceCycleDataTest.cs index 8983bfcca8c8e8200f34283a7b7cdfad9b735566..894dfe71f6e959d891515fef56a1a5f52bf3be74 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/DistanceCycleDataTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/DistanceCycleDataTest.cs @@ -31,6 +31,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.Reader; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Tests.Integration; @@ -125,7 +126,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData public void CycleAltitudeTest() { var missionType = "LongHaul"; - var stream = RessourceHelper.ReadStream(ResourceNamespace + "MissionCycles." + missionType + ".vdri"); + var stream = + RessourceHelper.ReadStream(ResourceNamespace + "MissionCycles." + missionType + Constants.FileExtensions.CycleFile); var cycleData = DrivingCycleDataReader.ReadFromStream(stream, CycleType.DistanceBased, "", false); foreach (var entry in cycleData.Entries) { diff --git a/VectoCore/VectoCoreTest/Utils/MockAuxiliaryDemand.cs b/VectoCore/VectoCoreTest/Utils/MockAuxiliaryDemand.cs index 82476b41f076ad5e42dc97af31cdc472226ef65b..b74dd43c8624c43af046873cbdf7d2c1f12a0c17 100644 --- a/VectoCore/VectoCoreTest/Utils/MockAuxiliaryDemand.cs +++ b/VectoCore/VectoCoreTest/Utils/MockAuxiliaryDemand.cs @@ -115,5 +115,7 @@ namespace TUGraz.VectoCore.Tests.Utils { return new List<DrivingCycleData.DrivingCycleEntry>(); } + + public void FinishSimulation() {} } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Utils/MockModalDataContainer.cs b/VectoCore/VectoCoreTest/Utils/MockModalDataContainer.cs index e88c6e1ed20236fa0dcf488ec5030a93866ebc91..f0a08e3fbeb543b0c1734f503aac1bd7266f4e99 100644 --- a/VectoCore/VectoCoreTest/Utils/MockModalDataContainer.cs +++ b/VectoCore/VectoCoreTest/Utils/MockModalDataContainer.cs @@ -114,6 +114,16 @@ namespace TUGraz.VectoCore.Tests.Utils Auxiliaries[id] = Data.Columns[auxColName]; } + public void Dispose() + { + throw new NotImplementedException(); + } + + public void FinishSimulation() + { + Data.Rows.Clear(); + } + public string RunName { get; set; } public string CycleName { get; set; } public string RunSuffix { get; set; }