From 5a5a0be2fb012fd93ee78f0d106e29e9fd7eb107 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Mon, 23 Apr 2018 16:58:05 +0200 Subject: [PATCH] implementing declaration mode for vecto --- VECTO/GUI/MainForm.vb | 5 +- VECTO/GUI/VectoVTPJobForm.vb | 15 +- VECTO/Input Files/VectoEPTPJob.vb | 222 ++++++++++-------- VECTO/OutputData/JSONFileWriter.vb | 59 +++-- .../InputData/IInputDataProvider.cs | 15 -- .../InputData/VTPDeclarationInputData.cs | 54 +++++ .../InputData/VTPEngineeringInputData.cs | 40 ++++ .../OutputData/IOutputFileWriter.cs | 4 +- VectoCommon/VectoCommon/VectoCommon.csproj | 2 + .../ModelbasedTests/ModelbasedTests.csproj | 2 +- .../InputData/FileIO/JSON/JSONInputData.cs | 13 +- .../DeclarationModeVectoRunDataFactory.cs | 2 +- .../DeclarationVTPModeVectoRunDataFactory.cs | 184 +++++++++++++++ .../EngineeringVTPModeVectoRunDataFactory.cs | 117 +++------ .../Simulation/Impl/SimulatorFactory.cs | 35 +-- VectoCore/VectoCore/VectoCore.csproj | 1 + .../VectoCoreTest/Integration/VTP/VTPTest.cs | 28 +++ .../VectoCoreTest/Reports/ModDataTest.cs | 2 +- .../class_5_generic vehicle_DECL.vecto | 21 ++ VectoCore/VectoCoreTest/VectoCoreTest.csproj | 3 + 20 files changed, 559 insertions(+), 265 deletions(-) create mode 100644 VectoCommon/VectoCommon/InputData/VTPDeclarationInputData.cs create mode 100644 VectoCommon/VectoCommon/InputData/VTPEngineeringInputData.cs create mode 100644 VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactory.cs create mode 100644 VectoCore/VectoCoreTest/TestData/Integration/VTPMode/GenericVehicle/class_5_generic vehicle_DECL.vecto diff --git a/VECTO/GUI/MainForm.vb b/VECTO/GUI/MainForm.vb index 46fe44d371..0568209c72 100644 --- a/VECTO/GUI/MainForm.vb +++ b/VECTO/GUI/MainForm.vb @@ -1276,8 +1276,9 @@ lbFound: VectoVTPJobForm.VectoNew() Else Try - Dim job As IVTPInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(x), IVTPInputDataProvider) - If job Is Nothing Then + Dim engJob As IVTPEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(x), IVTPEngineeringInputDataProvider) + Dim declJob As IVTPDeclarationInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(x), IVTPDeclarationInputDataProvider) + If engJob Is Nothing AndAlso declJob is Nothing Then ShowVectoJobForm() VectoJobForm.VECTOload2Form(x) Else diff --git a/VECTO/GUI/VectoVTPJobForm.vb b/VECTO/GUI/VectoVTPJobForm.vb index 3f54094b6b..505917bc9e 100644 --- a/VECTO/GUI/VectoVTPJobForm.vb +++ b/VECTO/GUI/VectoVTPJobForm.vb @@ -162,11 +162,11 @@ Public Class VectoVTPJobForm VectoNew() 'Read GEN - Dim vectoJob As IVTPJobInputData = Nothing - Dim inputData As IVTPInputDataProvider = Nothing + Dim vectoJob As IVTPEngineeringJobInputData = Nothing + Dim inputData As IVTPEngineeringInputDataProvider = Nothing Try inputData = TryCast(JSONInputDataFactory.ReadComponentData(file), - IVTPInputDataProvider) + IVTPEngineeringInputDataProvider) vectoJob = inputData.JobInputData() Catch ex As Exception MsgBox("Failed to read Job-File" + Environment.NewLine + ex.Message) @@ -638,15 +638,6 @@ Public Class VectoVTPJobForm HDVclass = "-" Else HDVclass = s0.VehicleClass.GetClassNumber() - - If Cfg.DeclMode Then - LvCycles.Items.Clear() - Dim m0 As Mission - For Each m0 In s0.Missions - LvCycles.Items.Add(m0.MissionType.ToString()) - Next - End If - End If PicVehicle.Image = ConvPicPath(If(Not s0.Found, -1, HDVclass.ToInt()), False) _ diff --git a/VECTO/Input Files/VectoEPTPJob.vb b/VECTO/Input Files/VectoEPTPJob.vb index 9028c62091..f0e35fd2d4 100644 --- a/VECTO/Input Files/VectoEPTPJob.vb +++ b/VECTO/Input Files/VectoEPTPJob.vb @@ -17,10 +17,11 @@ Imports TUGraz.VectoCore.Utils <CustomValidation(GetType(VectoVTPJob), "ValidateJob")> Public Class VectoVTPJob - Implements IVTPInputDataProvider, IVTPJobInputData + Implements IVTPEngineeringInputDataProvider, IVTPEngineeringJobInputData, IVTPDeclarationInputDataProvider, + IVTPDeclarationJobInputData - Private _sFilePath As String - Private _myPath As String + Private _sFilePath As String + Private _myPath As String Private ReadOnly _vehicleFile As SubPath @@ -35,122 +36,129 @@ Public Class VectoVTPJob End Sub Public Property FilePath As String - Get - Return _sFilePath - End Get - Set(value As String) - _sFilePath = value - If _sFilePath = "" Then - _myPath = "" - Else - _myPath = Path.GetDirectoryName(_sFilePath) & "\" - End If - End Set - End Property - - - Public Property PathVeh(Optional ByVal original As Boolean = False) As String - Get - If original Then - Return _vehicleFile.OriginalPath - Else - Return _vehicleFile.FullPath - End If - End Get - Set(value As String) - _vehicleFile.Init(_myPath, value) - End Set - End Property - - - Public Function SaveFile() As Boolean - Dim validationResults As IList(Of ValidationResult) = - Validate(ExecutionMode.Declaration, Nothing, False) - - If validationResults.Count > 0 Then - Dim messages As IEnumerable(Of String) = - validationResults.Select(Function(r) r.ErrorMessage + String.Join(", ", r.MemberNames.Distinct())) - MsgBox("Invalid input." + Environment.NewLine + String.Join(Environment.NewLine, messages), MsgBoxStyle.OkOnly, - "Failed to save Vecto Job") - Return False - End If - - Try - Dim writer As JSONFileWriter = JSONFileWriter.Instance - writer.SaveJob(Me, _sFilePath) - Catch ex As Exception - MsgBox("Failed to save Job file: " + ex.Message) - Return False - End Try - Return True - End Function - - ' ReSharper disable once UnusedMember.Global -- used by Validation - Public Shared Function ValidateJob(vectoJob As VectoVTPJob, validationContext As ValidationContext) As ValidationResult - Dim modeService As VectoValidationModeServiceContainer = - TryCast(validationContext.GetService(GetType(VectoValidationModeServiceContainer)), - VectoValidationModeServiceContainer) - Dim mode As ExecutionMode = If(modeService Is Nothing, ExecutionMode.Declaration, modeService.Mode) - - Return ValidateVehicleJob(vectoJob, mode) - End Function - - Private Shared Function ValidateVehicleJob(vectoJob As VectoVTPJob, mode As ExecutionMode) As ValidationResult + Get + Return _sFilePath + End Get + Set(value As String) + _sFilePath = value + If _sFilePath = "" Then + _myPath = "" + Else + _myPath = Path.GetDirectoryName(_sFilePath) & "\" + End If + End Set + End Property - ' TODO!! + Public Property PathVeh(Optional ByVal original As Boolean = False) As String + Get + If original Then + Return _vehicleFile.OriginalPath + Else + Return _vehicleFile.FullPath + End If + End Get + Set(value As String) + _vehicleFile.Init(_myPath, value) + End Set + End Property + + + Public Function SaveFile() As Boolean + Dim validationResults As IList(Of ValidationResult) = + Validate(ExecutionMode.Declaration, Nothing, False) + + If validationResults.Count > 0 Then + Dim messages As IEnumerable(Of String) = + validationResults.Select(Function(r) r.ErrorMessage + String.Join(", ", r.MemberNames.Distinct())) + MsgBox("Invalid input." + Environment.NewLine + String.Join(Environment.NewLine, messages), + MsgBoxStyle.OkOnly, + "Failed to save Vecto Job") + Return False + End If + + Try + Dim writer As JSONFileWriter = JSONFileWriter.Instance + if Cfg.DeclMode Then + writer.SaveJob(CType(Me, IVTPDeclarationInputDataProvider), _sFilePath) + else + writer.SaveJob(CType(Me, IVTPEngineeringInputDataProvider), _sFilePath) + End If + Catch ex As Exception + MsgBox("Failed to save Job file: " + ex.Message) + Return False + End Try + Return True End Function - Public ReadOnly Property Vehicle As IVehicleDeclarationInputData Implements IVTPJobInputData.Vehicle - Get - If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing + ' ReSharper disable once UnusedMember.Global -- used by Validation + Public Shared Function ValidateJob(vectoJob As VectoVTPJob, validationContext As ValidationContext) _ + As ValidationResult + Dim modeService As VectoValidationModeServiceContainer = + TryCast(validationContext.GetService(GetType(VectoValidationModeServiceContainer)), + VectoValidationModeServiceContainer) + Dim mode As ExecutionMode = If(modeService Is Nothing, ExecutionMode.Declaration, modeService.Mode) + + Return ValidateVehicleJob(vectoJob, mode) + End Function + + Private Shared Function ValidateVehicleJob(vectoJob As VectoVTPJob, mode As ExecutionMode) As ValidationResult + + ' TODO!! + End Function + + Public ReadOnly Property Vehicle As IVehicleDeclarationInputData Implements IVTPEngineeringJobInputData.Vehicle + Get + If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing 'Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle Return New XMLDeclarationInputDataProvider(_vehicleFile.FullPath, True).JobInputData.Vehicle End Get - End Property - - Public ReadOnly Property Cycles As IList(Of ICycleData) Implements IVTPJobInputData.Cycles - Get - Dim retVal As ICycleData() = New ICycleData(CycleFiles.Count - 1) {} - Dim i As Integer = 0 - For Each cycleFile As SubPath In CycleFiles - Dim cycleData As TableData - If (File.Exists(cycleFile.FullPath)) Then - cycleData = VectoCSVFile.Read(cycleFile.FullPath) - Else - Try - 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 - End If - retVal(i) = New CycleInputData With { - .Name = Path.GetFileNameWithoutExtension(cycleFile.FullPath), - .CycleData = cycleData - } - i += 1 - Next - Return retVal - - End Get - End Property - - Public ReadOnly Property FanPowerCoefficents As IEnumerable(Of Double) Implements IVTPJobInputData.FanPowerCoefficents + End Property + + Public ReadOnly Property Cycles As IList(Of ICycleData) Implements IVTPEngineeringJobInputData.Cycles + Get + Dim retVal As ICycleData() = New ICycleData(CycleFiles.Count - 1) {} + Dim i As Integer = 0 + For Each cycleFile As SubPath In CycleFiles + Dim cycleData As TableData + If (File.Exists(cycleFile.FullPath)) Then + cycleData = VectoCSVFile.Read(cycleFile.FullPath) + Else + Try + 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 + End If + retVal(i) = New CycleInputData With { + .Name = Path.GetFileNameWithoutExtension(cycleFile.FullPath), + .CycleData = cycleData + } + i += 1 + Next + Return retVal + End Get + End Property + + Public ReadOnly Property FanPowerCoefficents As IEnumerable(Of Double) _ + Implements IVTPEngineeringJobInputData.FanPowerCoefficents Get Return FanCoefficients End Get End Property - Public ReadOnly Property SavedInDeclarationMode As Boolean Implements IVTPJobInputData.SavedInDeclarationMode + Public ReadOnly Property SavedInDeclarationMode As Boolean _ + Implements IVTPEngineeringJobInputData.SavedInDeclarationMode Get Return False End Get End Property - Public Property FanDiameter As Meter Implements IVTPJobInputData.FanDiameter + Public Property FanDiameter As Meter Implements IVTPEngineeringJobInputData.FanDiameter Get Return _fanDiameter End Get @@ -159,9 +167,17 @@ Public Class VectoVTPJob End Set End Property - Public ReadOnly Property JobInputData As IVTPJobInputData Implements IVTPInputDataProvider.JobInputData + Public ReadOnly Property JobInputData As IVTPEngineeringJobInputData _ + Implements IVTPEngineeringInputDataProvider.JobInputData Get Return Me End Get End Property + + Public ReadOnly Property IVTPDeclarationInputDataProvider_JobInputData As IVTPDeclarationJobInputData _ + Implements IVTPDeclarationInputDataProvider.JobInputData + get + return Me + End Get + End Property End Class diff --git a/VECTO/OutputData/JSONFileWriter.vb b/VECTO/OutputData/JSONFileWriter.vb index 778458c593..ba8c7151d4 100644 --- a/VECTO/OutputData/JSONFileWriter.vb +++ b/VECTO/OutputData/JSONFileWriter.vb @@ -42,7 +42,7 @@ Public Class JSONFileWriter body.Add("ModelName", eng.Model) - body.Add("Displacement", eng.Displacement.ConvertToCubicCentiMeter().ToString()) + body.Add("Displacement", eng.Displacement.ConvertToCubicCentiMeter().ToString()) body.Add("IdlingSpeed", eng.IdleSpeed.AsRPM) body.Add("Inertia", eng.Inertia.Value()) @@ -206,8 +206,8 @@ Public Class JSONFileWriter {"CurbWeight", vehicle.CurbMassChassis.Value()}, {"CurbWeightExtra", vehicle.CurbMassExtra.Value()}, {"Loading", vehicle.Loading.Value()}, - {"MassMax", vehicle.GrossVehicleMassRating.ConvertToTon().Value}, - {"rdyn", vehicle.DynamicTyreRadius.ConvertToMilliMeter().Value}, + {"MassMax", vehicle.GrossVehicleMassRating.ConvertToTon().Value}, + {"rdyn", vehicle.DynamicTyreRadius.ConvertToMilliMeter().Value}, {"CdCorrMode", airdrag.CrossWindCorrectionMode.GetName()}, {"CdCorrFile", If((airdrag.CrossWindCorrectionMode = CrossWindCorrectionMode.SpeedDependentCorrectionFactor OrElse @@ -254,8 +254,8 @@ Public Class JSONFileWriter Dim job As IEngineeringJobInputData = input.JobInputData() - body.Add("SavedInDeclMode", job.SavedInDeclarationMode) - body.Add("EngineOnlyMode", job.EngineOnlyMode) + body.Add("SavedInDeclMode", job.SavedInDeclarationMode) + body.Add("EngineOnlyMode", job.EngineOnlyMode) If job.EngineOnlyMode Then body.Add("EngineFile", GetRelativePath(job.EngineOnly.Source, basePath)) @@ -270,8 +270,8 @@ Public Class JSONFileWriter body.Add("EngineFile", GetRelativePath(input.JobInputData.Vehicle.EngineInputData.Source, basePath)) body.Add("GearboxFile", GetRelativePath(input.JobInputData.Vehicle.GearboxInputData.Source, basePath)) - - Dim aux As IAuxiliariesEngineeringInputData = job.Vehicle.AuxiliaryInputData() + + Dim aux As IAuxiliariesEngineeringInputData = job.Vehicle.AuxiliaryInputData() 'AA-TB 'ADVANCED AUXILIARIES body.Add("AuxiliaryAssembly", aux.AuxiliaryAssembly.GetName()) @@ -301,12 +301,12 @@ Public Class JSONFileWriter Next body.Add("Aux", auxList) - If Not job.SavedInDeclarationMode Then - body.Add("Padd", pAdd) - End If - - Dim driver As IDriverEngineeringInputData = input.DriverInputData - + If Not job.SavedInDeclarationMode Then + body.Add("Padd", pAdd) + End If + + Dim driver As IDriverEngineeringInputData = input.DriverInputData + If Not job.SavedInDeclarationMode Then body.Add("VACC", GetRelativePath(driver.AccelerationCurve.Source, basePath)) End If @@ -353,23 +353,29 @@ Public Class JSONFileWriter WriteFile(header, body, filename) End Sub - Public Sub SaveJob(input As IVTPInputDataProvider, filename As String) Implements IOutputFileWriter.SaveJob - Dim basePath As String = Path.GetDirectoryName(filename) - 'Header + Public Sub SaveJob(input As IVTPDeclarationInputDataProvider, filename As String) Implements IOutputFileWriter.SaveJob + Dim header As Dictionary(Of String, Object) = GetHeader(VectoJobFormatVersion) + Dim body As Dictionary(Of string, Object) = SaveVTPJob(input.JobInputData, filename, true) + WriteFile(header, body, filename) + end Sub + Public Sub SaveJob(input As IVTPEngineeringInputDataProvider, filename As String) Implements IOutputFileWriter.SaveJob Dim header As Dictionary(Of String, Object) = GetHeader(VectoJobFormatVersion) + Dim body As Dictionary(Of string, Object) = SaveVTPJob(input.JobInputData, filename, False) + WriteFile(header, body, filename) + End Sub + Private Function SaveVTPJob(job As IVTPDeclarationJobInputData, filename As String, declarationmode As Boolean) As Dictionary(Of String,Object) + 'Body Dim body As Dictionary(Of String, Object) = New Dictionary(Of String, Object) - Dim job As IVTPJobInputData = input.JobInputData - body.Add("SavedInDeclMode", False) - body.Add("DeclarationVehicle", GetRelativePath(job.Vehicle.Source, Path.GetDirectoryName(filename))) - body.Add("FanPowerCoefficients", job.FanPowerCoefficents) - body.Add("FanDiameter", job.FanDiameter.Value()) - body.Add("Cycles", - job.Cycles.Select(Function(x) GetRelativePath(x.CycleData.Source, Path.GetDirectoryName(filename))).ToArray()) - - WriteFile(header, body, filename) - End Sub + body.Add("SavedInDeclMode", declarationmode) + body.Add("DeclarationVehicle", GetRelativePath(job.Vehicle.Source, Path.GetDirectoryName(filename))) + body.Add("FanPowerCoefficients", job.FanPowerCoefficents) + body.Add("FanDiameter", job.FanDiameter.Value()) + body.Add("Cycles", + job.Cycles.Select(Function(x) GetRelativePath(x.CycleData.Source, Path.GetDirectoryName(filename))).ToArray()) + return body + End Function Public Sub ExportJob(input As IEngineeringInputDataProvider, filename As String, separateFiles As Boolean) _ Implements IOutputFileWriter.ExportJob @@ -409,3 +415,4 @@ Public Class JSONFileWriter WriteFile(JToken.FromObject(New Dictionary(Of String, Object) From {{"Header", header}, {"Body", body}}), path) End Sub End Class + diff --git a/VectoCommon/VectoCommon/InputData/IInputDataProvider.cs b/VectoCommon/VectoCommon/InputData/IInputDataProvider.cs index eff5db7421..2f3bbdd57c 100644 --- a/VectoCommon/VectoCommon/InputData/IInputDataProvider.cs +++ b/VectoCommon/VectoCommon/InputData/IInputDataProvider.cs @@ -51,19 +51,4 @@ namespace TUGraz.VectoCommon.InputData IDriverEngineeringInputData DriverInputData { get; } } - public interface IVTPInputDataProvider : IInputDataProvider - { - IVTPJobInputData JobInputData { get; } - } - - public interface IVTPJobInputData - { - IVehicleDeclarationInputData Vehicle { get; } - - IList<ICycleData> Cycles { get; } - - IEnumerable<double> FanPowerCoefficents { get; } - bool SavedInDeclarationMode { get; } - Meter FanDiameter { get; } - } } diff --git a/VectoCommon/VectoCommon/InputData/VTPDeclarationInputData.cs b/VectoCommon/VectoCommon/InputData/VTPDeclarationInputData.cs new file mode 100644 index 0000000000..530be45d71 --- /dev/null +++ b/VectoCommon/VectoCommon/InputData/VTPDeclarationInputData.cs @@ -0,0 +1,54 @@ +/* +* This file is part of VECTO. +* +* Copyright © 2012-2017 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.Collections.Generic; +using TUGraz.VectoCommon.Utils; + +namespace TUGraz.VectoCommon.InputData +{ + public interface IVTPDeclarationInputDataProvider : IInputDataProvider + { + IVTPDeclarationJobInputData JobInputData { get; } + } + + public interface IVTPDeclarationJobInputData + { + IVehicleDeclarationInputData Vehicle { get; } + + IList<ICycleData> Cycles { get; } + + IEnumerable<double> FanPowerCoefficents { get; } + + bool SavedInDeclarationMode { get; } + + Meter FanDiameter { get; } + } +} diff --git a/VectoCommon/VectoCommon/InputData/VTPEngineeringInputData.cs b/VectoCommon/VectoCommon/InputData/VTPEngineeringInputData.cs new file mode 100644 index 0000000000..a16d4bfc6f --- /dev/null +++ b/VectoCommon/VectoCommon/InputData/VTPEngineeringInputData.cs @@ -0,0 +1,40 @@ +/* +* This file is part of VECTO. +* +* Copyright © 2012-2017 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 +*/ + +namespace TUGraz.VectoCommon.InputData +{ + public interface IVTPEngineeringInputDataProvider : IInputDataProvider + { + IVTPEngineeringJobInputData JobInputData { get; } + } + + public interface IVTPEngineeringJobInputData : IVTPDeclarationJobInputData { } +} diff --git a/VectoCommon/VectoCommon/OutputData/IOutputFileWriter.cs b/VectoCommon/VectoCommon/OutputData/IOutputFileWriter.cs index b98e453798..f4bad8501d 100644 --- a/VectoCommon/VectoCommon/OutputData/IOutputFileWriter.cs +++ b/VectoCommon/VectoCommon/OutputData/IOutputFileWriter.cs @@ -45,7 +45,9 @@ namespace TUGraz.VectoCommon.OutputData void SaveJob(IEngineeringInputDataProvider input, string filename); - void SaveJob(IVTPInputDataProvider input, string filename); + void SaveJob(IVTPEngineeringInputDataProvider input, string filename); + + void SaveJob(IVTPDeclarationInputDataProvider input, string filename); void ExportJob(IEngineeringInputDataProvider input, string filename, bool separateFiles); } diff --git a/VectoCommon/VectoCommon/VectoCommon.csproj b/VectoCommon/VectoCommon/VectoCommon.csproj index d719873531..863d09c76a 100644 --- a/VectoCommon/VectoCommon/VectoCommon.csproj +++ b/VectoCommon/VectoCommon/VectoCommon.csproj @@ -48,6 +48,8 @@ <Compile Include="InputData\TableData.cs"> <SubType>Component</SubType> </Compile> + <Compile Include="InputData\VTPDeclarationInputData.cs" /> + <Compile Include="InputData\VTPEngineeringInputData.cs" /> <Compile Include="Models\AuxiliaryType.cs" /> <Compile Include="Exceptions\VectoExceptions.cs" /> <Compile Include="Exceptions\VectoSimulationException.cs" /> diff --git a/VectoCore/ModelbasedTests/ModelbasedTests.csproj b/VectoCore/ModelbasedTests/ModelbasedTests.csproj index 83f6d3c5f9..7d87d2f1fa 100644 --- a/VectoCore/ModelbasedTests/ModelbasedTests.csproj +++ b/VectoCore/ModelbasedTests/ModelbasedTests.csproj @@ -42,7 +42,7 @@ </Reference> <Reference Include="System" /> <Reference Include="VectoCore"> - <HintPath>..\VectoCore\bin\Debug\VectoCore.dll</HintPath> + <HintPath>..\VectoCore\obj\Debug\VectoCore.dll</HintPath> </Reference> </ItemGroup> <Choose> diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs index 349a5fc15f..9f5a5f9005 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs @@ -622,12 +622,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON : base(data, filename, tolerateMissing) { } } - public class JSONVTPInputDataV4 : JSONFile, IVTPInputDataProvider, IVTPJobInputData + public class JSONVTPInputDataV4 : JSONFile, IVTPEngineeringInputDataProvider, IVTPEngineeringJobInputData, IVTPDeclarationInputDataProvider { public JSONVTPInputDataV4(JObject data, string filename, bool tolerateMissing = false) : base(data, filename, tolerateMissing) { } - public IVTPJobInputData JobInputData + public IVTPEngineeringJobInputData JobInputData { get { return this; } } @@ -673,5 +673,14 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON { get { return Body.GetEx<double>("FanDiameter").SI<Meter>(); } } + + #region Implementation of IVTPDeclarationInputDataProvider + + IVTPDeclarationJobInputData IVTPDeclarationInputDataProvider.JobInputData + { + get { return JobInputData; } + } + + #endregion } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs index 03f10e3002..b397690b28 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs @@ -167,7 +167,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl _dao.CreateVehicleData(InputDataProvider.JobInputData.Vehicle, mission, loading.Value, _segment.MunicipalBodyWeight), AirdragData = _dao.CreateAirdragData(InputDataProvider.JobInputData.Vehicle.AirdragInputData, mission, _segment), - EngineData = _engineData.Copy(), + EngineData = _engineData.Copy(), // TODO: MQ 2018-04-23: Why copy EngineData? GearboxData = _gearboxData, AxleGearData = _axlegearData, AngledriveData = _angledriveData, diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactory.cs new file mode 100644 index 0000000000..f2a65b0b79 --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactory.cs @@ -0,0 +1,184 @@ +using System; +using System.Collections.Generic; +using System.Linq; +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.InputData.Reader.DataObjectAdapter; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data; + +namespace TUGraz.VectoCore.InputData.Reader.Impl +{ + internal class DeclarationVTPModeVectoRunDataFactory : IVectoRunDataFactory + { + + protected IVTPDeclarationJobInputData JobInputData; + private DriverData _driverdata; + private AirdragData _airdragData; + private CombustionEngineData _engineData; + private AxleGearData _axlegearData; + private AngledriveData _angledriveData; + private GearboxData _gearboxData; + private RetarderData _retarderData; + private PTOData _ptoTransmissionData; + protected List<VectoRunData.AuxData> _auxVTP; + protected Segment _segment; + private DeclarationDataAdapter _dao; + protected Exception _initException; + + public DeclarationVTPModeVectoRunDataFactory(IVTPDeclarationInputDataProvider ivtpProvider) : this(ivtpProvider.JobInputData) + {} + + protected DeclarationVTPModeVectoRunDataFactory(IVTPDeclarationJobInputData job) + { + JobInputData = job; + try { + Initialize(); + } catch (Exception e) { + _initException = e; + } + } + + + protected virtual void Initialize() + { + _dao = new DeclarationDataAdapter(); + var vehicle = JobInputData.Vehicle; + _segment = DeclarationData.Segments.Lookup( + vehicle.VehicleCategory, + vehicle.AxleConfiguration, + vehicle.GrossVehicleMassRating, + vehicle.CurbMassChassis); + _driverdata = _dao.CreateDriverData(); + _driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(_segment.AccelerationFile); + var tempVehicle = _dao.CreateVehicleData( + vehicle, _segment.Missions.First(), + _segment.Missions.First().Loadings.First().Value, _segment.MunicipalBodyWeight); + _airdragData = _dao.CreateAirdragData( + vehicle.AirdragInputData, + _segment.Missions.First(), _segment); + _engineData = _dao.CreateEngineData( + vehicle.EngineInputData, + vehicle.EngineIdleSpeed, + vehicle.GearboxInputData, vehicle.TorqueLimits); + _axlegearData = _dao.CreateAxleGearData(vehicle.AxleGearInputData, false); + _angledriveData = _dao.CreateAngledriveData(vehicle.AngledriveInputData, false); + _gearboxData = _dao.CreateGearboxData( + vehicle.GearboxInputData, _engineData, + _axlegearData.AxleGear.Ratio, + tempVehicle.DynamicTyreRadius, tempVehicle.VehicleCategory, false); + _retarderData = _dao.CreateRetarderData(vehicle.RetarderInputData); + + _ptoTransmissionData = + _dao.CreatePTOTransmissionData(vehicle.PTOTransmissionInputData); + + _auxVTP = CreateVTPAuxData(_dao, vehicle, _segment); + } + + #region Implementation of IVectoRunDataFactory + + public virtual IEnumerable<VectoRunData> NextRun() + { + if (_initException != null) { + throw _initException; + } + + // simulate the LongHaul cycle with RefLoad + foreach (var mission in _segment.Missions.Where(m => m.MissionType == MissionType.LongHaul)) { + foreach (var loading in mission.Loadings.Where(l => l.Key == LoadingType.ReferenceLoad)) { + var runData = CreateVectoRunData(_segment, mission, loading.Value); + runData.ModFileSuffix = loading.Key.ToString(); + var cycle = DrivingCycleDataReader.ReadFromStream(mission.CycleFile, CycleType.DistanceBased, "", false); + runData.Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()); + runData.DriverData = _driverdata; + runData.Aux = _dao.CreateAuxiliaryData( + JobInputData.Vehicle.AuxiliaryInputData(), mission.MissionType, _segment.VehicleClass); + runData.ExecutionMode = ExecutionMode.Declaration; + runData.SimulationType = SimulationType.DistanceCycle; + yield return runData; + } + } + + // simulate the Measured cycle + foreach (var cycle in JobInputData.Cycles) { + var drivingCycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, cycle.Name, false); + // TODO: MQ 2018-04-23: use correct loading here? + var runData = CreateVectoRunData(_segment, _segment.Missions.First(), 0.SI<Kilogram>()); + runData.Cycle = new DrivingCycleProxy(drivingCycle, cycle.Name); + runData.Aux = _auxVTP; + runData.FanData = new AuxFanData() { + FanCoefficients = JobInputData.FanPowerCoefficents.ToArray(), + FanDiameter = JobInputData.FanDiameter, + }; + runData.ExecutionMode = ExecutionMode.Declaration; + runData.SimulationType = SimulationType.VerificationTest; + yield return runData; + } + + } + + protected VectoRunData CreateVectoRunData(Segment segment, Mission mission, Kilogram loading) + { + + return new VectoRunData { + JobName = JobInputData.Vehicle.VIN, + EngineData = _engineData, + GearboxData = _gearboxData, + AxleGearData = _axlegearData, + AngledriveData = _angledriveData, + VehicleData = _dao.CreateVehicleData( + JobInputData.Vehicle, mission, + loading, segment.MunicipalBodyWeight), + AirdragData = _airdragData, + DriverData = null, + + AdvancedAux = null, + Retarder = _retarderData, + PTO = _ptoTransmissionData, + }; + } + + protected virtual List<VectoRunData.AuxData> CreateVTPAuxData(DeclarationDataAdapter dao, IVehicleDeclarationInputData vehicle, Segment segment) + { + var auxRD = dao.CreateAuxiliaryData( + vehicle.AuxiliaryInputData(), MissionType.RegionalDelivery, segment.VehicleClass) + .ToList(); + foreach (var entry in auxRD) { + entry.MissionType = MissionType.RegionalDelivery; + } + + var auxLH = dao.CreateAuxiliaryData( + vehicle.AuxiliaryInputData(), MissionType.LongHaul, segment.VehicleClass) + .ToList(); + foreach (var entry in auxLH) { + entry.MissionType = MissionType.LongHaul; + } + + var auxUD = dao.CreateAuxiliaryData( + vehicle.AuxiliaryInputData(), MissionType.UrbanDelivery, segment.VehicleClass) + .ToList(); + foreach (var entry in auxUD) { + entry.MissionType = MissionType.UrbanDelivery; + } + + var aux = new List<VectoRunData.AuxData>(); + aux.AddRange(auxRD); + aux.AddRange(auxLH); + aux.AddRange(auxUD); + + aux.RemoveAll(x => x.ID == Constants.Auxiliaries.IDs.Fan); + aux.Add( + new VectoRunData.AuxData { + DemandType = AuxiliaryDemandType.Direct, + ID = DrivingCycleDataReader.Fields.AdditionalAuxPowerDemand + }); + return aux; + } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringVTPModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringVTPModeVectoRunDataFactory.cs index af3ecc3d94..5d56a5ce61 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringVTPModeVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringVTPModeVectoRunDataFactory.cs @@ -41,91 +41,36 @@ using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; -namespace TUGraz.VectoCore.InputData.Reader.Impl { - internal class EngineeringVTPModeVectoRunDataFactory : IVectoRunDataFactory - { - protected IVTPInputDataProvider InputDataProvider; +namespace TUGraz.VectoCore.InputData.Reader.Impl +{ + internal class EngineeringVTPModeVectoRunDataFactory : DeclarationVTPModeVectoRunDataFactory + { + + public EngineeringVTPModeVectoRunDataFactory(IVTPEngineeringInputDataProvider ivtpProvider) : base(ivtpProvider.JobInputData) + { + + } - public EngineeringVTPModeVectoRunDataFactory(IVTPInputDataProvider ivtpProvider) - { - InputDataProvider = ivtpProvider; - } - - public IEnumerable<VectoRunData> NextRun() - { - var dao = new DeclarationDataAdapter(); - var segment = DeclarationData.Segments.Lookup(InputDataProvider.JobInputData.Vehicle.VehicleCategory, - InputDataProvider.JobInputData.Vehicle.AxleConfiguration, - InputDataProvider.JobInputData.Vehicle.GrossVehicleMassRating, - InputDataProvider.JobInputData.Vehicle.CurbMassChassis); - var driverdata = dao.CreateDriverData(); - driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(segment.AccelerationFile); - var tempVehicle = dao.CreateVehicleData(InputDataProvider.JobInputData.Vehicle, segment.Missions.First(), - segment.Missions.First().Loadings.First().Value, segment.MunicipalBodyWeight); - var airdragData = dao.CreateAirdragData(InputDataProvider.JobInputData.Vehicle.AirdragInputData, - segment.Missions.First(), segment); - var engineData = dao.CreateEngineData(InputDataProvider.JobInputData.Vehicle.EngineInputData, - InputDataProvider.JobInputData.Vehicle.EngineIdleSpeed, - InputDataProvider.JobInputData.Vehicle.GearboxInputData, InputDataProvider.JobInputData.Vehicle.TorqueLimits); - var axlegearData = dao.CreateAxleGearData(InputDataProvider.JobInputData.Vehicle.AxleGearInputData, false); - var angledriveData = dao.CreateAngledriveData(InputDataProvider.JobInputData.Vehicle.AngledriveInputData, false); - var gearboxData = dao.CreateGearboxData(InputDataProvider.JobInputData.Vehicle.GearboxInputData, engineData, - axlegearData.AxleGear.Ratio, - tempVehicle.DynamicTyreRadius, tempVehicle.VehicleCategory, false); - var retarderData = dao.CreateRetarderData(InputDataProvider.JobInputData.Vehicle.RetarderInputData); - - var ptoTransmissionData = dao.CreatePTOTransmissionData(InputDataProvider.JobInputData.Vehicle.PTOTransmissionInputData); - - - var auxRD = dao.CreateAuxiliaryData(InputDataProvider.JobInputData.Vehicle.AuxiliaryInputData(), MissionType.RegionalDelivery, segment.VehicleClass).ToList(); - foreach (var entry in auxRD) { - entry.MissionType = MissionType.RegionalDelivery; - } - var auxLH = dao.CreateAuxiliaryData(InputDataProvider.JobInputData.Vehicle.AuxiliaryInputData(), MissionType.LongHaul, segment.VehicleClass).ToList(); - foreach (var entry in auxLH) { - entry.MissionType = MissionType.LongHaul; + public override IEnumerable<VectoRunData> NextRun() + { + if (_initException != null) { + throw _initException; } - var auxUD = dao.CreateAuxiliaryData(InputDataProvider.JobInputData.Vehicle.AuxiliaryInputData(), MissionType.UrbanDelivery, segment.VehicleClass).ToList(); - foreach (var entry in auxUD) { - entry.MissionType = MissionType.UrbanDelivery; - } - - var aux = new List<VectoRunData.AuxData>(); - aux.AddRange(auxRD); - aux.AddRange(auxLH); - aux.AddRange(auxUD); - - aux.RemoveAll(x => x.ID == Constants.Auxiliaries.IDs.Fan); - aux.Add(new VectoRunData.AuxData { - DemandType = AuxiliaryDemandType.Direct, - ID = DrivingCycleDataReader.Fields.AdditionalAuxPowerDemand - }); - - return InputDataProvider.JobInputData.Cycles.Select(cycle => { - var drivingCycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, cycle.Name, false); - return new VectoRunData { - JobName = InputDataProvider.JobInputData.Vehicle.VIN, - EngineData = engineData, - GearboxData = gearboxData, - AxleGearData = axlegearData, - AngledriveData = angledriveData, - VehicleData = dao.CreateVehicleData(InputDataProvider.JobInputData.Vehicle, segment.Missions.First(), - 0.SI<Kilogram>(), segment.MunicipalBodyWeight), - AirdragData =airdragData, - DriverData = null, - Aux = aux, - AdvancedAux = null, - Retarder = retarderData, - PTO = ptoTransmissionData, - Cycle = new DrivingCycleProxy(drivingCycle, cycle.Name), - ExecutionMode = ExecutionMode.Engineering, - FanData = new AuxFanData() { - FanCoefficients = InputDataProvider.JobInputData.FanPowerCoefficents.ToArray(), - FanDiameter = InputDataProvider.JobInputData.FanDiameter, - }, - SimulationType = SimulationType.VerificationTest - }; - }); - } - } -} \ No newline at end of file + return JobInputData.Cycles.Select( + cycle => { + var drivingCycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, cycle.Name, false); + // TODO: MQ 2018-04-23: use correct loading here!? + var runData = CreateVectoRunData(_segment, _segment.Missions.First(), 0.SI<Kilogram>()); + runData.Cycle = new DrivingCycleProxy(drivingCycle, cycle.Name); + runData.Aux = _auxVTP; + runData.FanData = new AuxFanData() { + FanCoefficients = JobInputData.FanPowerCoefficents.ToArray(), + FanDiameter = JobInputData.FanDiameter, + }; + runData.ExecutionMode = ExecutionMode.Engineering; + runData.SimulationType = SimulationType.VerificationTest; + return runData; + }); + } + } +} diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs index 05657c87f1..4d5a032282 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs @@ -75,9 +75,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl switch (mode) { case ExecutionMode.Declaration: - var declDataProvider = ToDeclarationInputDataProvider(dataProvider); - var report = declarationReport ?? new XMLDeclarationReport(writer); - DataReader = new DeclarationModeVectoRunDataFactory(declDataProvider, report); + CreateDeclarationDataReader(dataProvider, declarationReport); break; case ExecutionMode.Engineering: CreateEngineeringDataReader(dataProvider); @@ -87,11 +85,27 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl } } + private void CreateDeclarationDataReader(IInputDataProvider dataProvider, IDeclarationReport declarationReport) + { + if (dataProvider is IVTPDeclarationInputDataProvider) { + var vtpProvider = dataProvider as IVTPDeclarationInputDataProvider; + DataReader = new DeclarationVTPModeVectoRunDataFactory(vtpProvider); + return; + } + if (dataProvider is IDeclarationInputDataProvider) { + var declDataProvider = dataProvider as IDeclarationInputDataProvider; + var report = declarationReport ?? new XMLDeclarationReport(ModWriter); + DataReader = new DeclarationModeVectoRunDataFactory(declDataProvider, report); + return; + } + throw new VectoException("Unknown InputData for Declaration Mode!"); + } + private void CreateEngineeringDataReader(IInputDataProvider dataProvider) { - if (dataProvider is IVTPInputDataProvider) { - var eptpProvider = dataProvider as IVTPInputDataProvider; - DataReader = new EngineeringVTPModeVectoRunDataFactory(eptpProvider); + if (dataProvider is IVTPEngineeringInputDataProvider) { + var vtpProvider = dataProvider as IVTPEngineeringInputDataProvider; + DataReader = new EngineeringVTPModeVectoRunDataFactory(vtpProvider); return; } if (dataProvider is IEngineeringInputDataProvider) { @@ -107,15 +121,6 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl throw new VectoException("Unknown InputData for Engineering Mode!"); } - private static IDeclarationInputDataProvider ToDeclarationInputDataProvider(IInputDataProvider dataProvider) - { - var declDataProvider = dataProvider as IDeclarationInputDataProvider; - if (declDataProvider == null) { - throw new VectoException("InputDataProvider does not implement DeclarationData interface"); - } - return declDataProvider; - } - public bool Validate { get; set; } public IVectoRunDataFactory DataReader { get; private set; } diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index c34c5b71c3..a5c08a9f4a 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -157,6 +157,7 @@ <Compile Include="InputData\Reader\DrivingCycleDataReader.cs" /> <Compile Include="InputData\Reader\FullLoadCurveReader.cs" /> <Compile Include="InputData\Reader\Impl\DeclarationModeVectoRunDataFactory.cs" /> + <Compile Include="InputData\Reader\Impl\DeclarationVTPModeVectoRunDataFactory.cs" /> <Compile Include="InputData\Reader\Impl\DrivingCycleProxy.cs" /> <Compile Include="InputData\Reader\Impl\EngineeringModeVectoRunDataFactory.cs" /> <Compile Include="InputData\Reader\Impl\EngineOnlyVectoRunDataFactory.cs" /> diff --git a/VectoCore/VectoCoreTest/Integration/VTP/VTPTest.cs b/VectoCore/VectoCoreTest/Integration/VTP/VTPTest.cs index 7583608b9a..5bb9aaf70f 100644 --- a/VectoCore/VectoCoreTest/Integration/VTP/VTPTest.cs +++ b/VectoCore/VectoCoreTest/Integration/VTP/VTPTest.cs @@ -65,6 +65,7 @@ namespace TUGraz.VectoCore.Tests.Integration.VTP jobContainer.AddRuns(runsFactory); + Assert.AreEqual(1, jobContainer.Runs.Count); //var i = 0; //jobContainer.Runs[i].Run.Run(); //Assert.IsTrue(jobContainer.Runs[i].Run.FinishedWithoutErrors); @@ -76,5 +77,32 @@ namespace TUGraz.VectoCore.Tests.Integration.VTP } + [TestCase(@"TestData\Integration\VTPMode\GenericVehicle\class_5_generic vehicle_DECL.vecto")] + public void RunVTP_Declaration(string jobFile) + { + var fileWriter = new FileOutputWriter(jobFile); + var sumWriter = new SummaryDataContainer(fileWriter); + var jobContainer = new JobContainer(sumWriter); + var dataProvider = JSONInputDataFactory.ReadJsonJob(jobFile); + var runsFactory = new SimulatorFactory(ExecutionMode.Declaration, dataProvider, fileWriter) { + ModalResults1Hz = false, + WriteModalResults = true, + ActualModalData = false, + Validate = false, + }; + + jobContainer.AddRuns(runsFactory); + + Assert.AreEqual(2, jobContainer.Runs.Count); + //var i = 0; + //jobContainer.Runs[i].Run.Run(); + //Assert.IsTrue(jobContainer.Runs[i].Run.FinishedWithoutErrors); + + jobContainer.Execute(); + jobContainer.WaitFinished(); + + Assert.AreEqual(true, jobContainer.AllCompleted); + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Reports/ModDataTest.cs b/VectoCore/VectoCoreTest/Reports/ModDataTest.cs index aa4ac83fd6..a5b564cd66 100644 --- a/VectoCore/VectoCoreTest/Reports/ModDataTest.cs +++ b/VectoCore/VectoCoreTest/Reports/ModDataTest.cs @@ -236,7 +236,7 @@ namespace TUGraz.VectoCore.Tests.Reports fcMap = FuelConsumptionMapReader.Create(engInput.JobInputData.Vehicle .EngineInputData.FuelConsumptionMap); } - var vtpInput = inputData as IVTPInputDataProvider; + var vtpInput = inputData as IVTPEngineeringInputDataProvider; if (vtpInput != null ) { fcMap = FuelConsumptionMapReader.Create(vtpInput.JobInputData.Vehicle .EngineInputData.FuelConsumptionMap); diff --git a/VectoCore/VectoCoreTest/TestData/Integration/VTPMode/GenericVehicle/class_5_generic vehicle_DECL.vecto b/VectoCore/VectoCoreTest/TestData/Integration/VTPMode/GenericVehicle/class_5_generic vehicle_DECL.vecto new file mode 100644 index 0000000000..4d6d7b6a60 --- /dev/null +++ b/VectoCore/VectoCoreTest/TestData/Integration/VTPMode/GenericVehicle/class_5_generic vehicle_DECL.vecto @@ -0,0 +1,21 @@ +{ + "Header": { + "CreatedBy": "", + "Date": "2017-11-20T13:22:33.6138904Z", + "AppVersion": "3", + "FileVersion": 4 + }, + "Body": { + "SavedInDeclMode": true, + "DeclarationVehicle": "Tractor_4x2_vehicle-class-5_Generic vehicle.xml", + "FanPowerCoefficients": [ + 5.5E-07, + 15.0, + 108.5 + ], + "FanDiameter": 0.225, + "Cycles": [ + "VTP_rural_2Hz.vdri" + ] + } +} \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/VectoCoreTest.csproj b/VectoCore/VectoCoreTest/VectoCoreTest.csproj index fd7ee6d64a..2dce6c1448 100644 --- a/VectoCore/VectoCoreTest/VectoCoreTest.csproj +++ b/VectoCore/VectoCoreTest/VectoCoreTest.csproj @@ -1733,6 +1733,9 @@ <None Include="TestData\Integration\FullPowerTrain\unlimited.vacc"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="TestData\Integration\VTPMode\GenericVehicle\class_5_generic vehicle_DECL.vecto"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> <None Include="TestData\Integration\VTPMode\GenericVehicle\class_5_generic vehicle_noGear.vecto"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> -- GitLab