diff --git a/VECTO/Input Files/VectoJob.vb b/VECTO/Input Files/VectoJob.vb index 44659bd7edfb68991573d37152d86c99faae8b6f..271e2854394e786232ec0db8ee97debbb4d31111 100644 --- a/VECTO/Input Files/VectoJob.vb +++ b/VECTO/Input Files/VectoJob.vb @@ -15,6 +15,7 @@ Imports System.Collections.Generic Imports System.ComponentModel.DataAnnotations Imports System.IO Imports System.Linq +Imports System.Runtime.InteropServices Imports System.Runtime.Remoting.Messaging Imports System.Text Imports System.Xml.Linq @@ -33,710 +34,748 @@ Imports TUGraz.VectoCore.Utils <CustomValidation(GetType(VectoJob), "ValidateJob")> Public Class VectoJob - Implements IEngineeringInputDataProvider, IDeclarationInputDataProvider, IEngineeringJobInputData, - IDeclarationJobInputData, IDriverEngineeringInputData, IDriverDeclarationInputData, IAuxiliariesEngineeringInputData, - IAuxiliariesDeclarationInputData + Implements IEngineeringInputDataProvider, IDeclarationInputDataProvider, IEngineeringJobInputData, + IDeclarationJobInputData, IDriverEngineeringInputData, IDriverDeclarationInputData, IAuxiliariesEngineeringInputData, + IAuxiliariesDeclarationInputData, IJSONVehicleComponents - 'AA-TB - 'STORES THE Type and version of the chosen or default Auxiliary Type ( Classic/Original or other ) - Public AuxiliaryAssembly As String - Public AuxiliaryVersion As String - Public AdvancedAuxiliaryFilePath As String + 'AA-TB + 'STORES THE Type and version of the chosen or default Auxiliary Type ( Classic/Original or other ) + Public AuxiliaryAssembly As String + Public AuxiliaryVersion As String + Public AdvancedAuxiliaryFilePath As String - Private _sFilePath As String - Private _myPath As String + Private _sFilePath As String + Private _myPath As String - 'Input parameters - Private ReadOnly _vehicleFile As SubPath - Private ReadOnly _engineFile As SubPath - Private ReadOnly _gearboxFile As SubPath + 'Input parameters + Private ReadOnly _vehicleFile As SubPath + Private ReadOnly _engineFile As SubPath + Private ReadOnly _gearboxFile As SubPath - Private _startStop As Boolean - Public StartStopDelay As Double + Private _startStop As Boolean + Public StartStopDelay As Double - Private ReadOnly _driverAccelerationFile As SubPath + Private ReadOnly _driverAccelerationFile As SubPath - Public ReadOnly AuxPaths As Dictionary(Of String, AuxEntry) - 'Alle Nebenverbraucher die in der Veh-Datei UND im Zyklus definiert sind + Public ReadOnly AuxPaths As Dictionary(Of String, AuxEntry) + 'Alle Nebenverbraucher die in der Veh-Datei UND im Zyklus definiert sind - Public ReadOnly CycleFiles As List(Of SubPath) + Public ReadOnly CycleFiles As List(Of SubPath) - Public EngineOnly As Boolean + Public EngineOnly As Boolean - Public VMin As Double - Public LookAheadOn As Boolean - Public OverSpeedOn As Boolean - Public OverSpeed As Double - Public UnderSpeed As Double - Public EcoRollOn As Boolean + Public VMin As Double + Public LookAheadOn As Boolean + Public OverSpeedOn As Boolean + Public OverSpeed As Double + Public UnderSpeed As Double + Public EcoRollOn As Boolean - Public LookAheadMinSpeed As Double + Public LookAheadMinSpeed As Double - Public Property StartStopMaxSpeed As Double + Public Property StartStopMaxSpeed As Double - Public Property StartStopTime As Double + Public Property StartStopTime As Double - 'Private _vehicleInputData As JSONComponentInputData - 'Private _engineInputData As JSONComponentInputData - 'Private _gearboxInputData As JSONComponentInputData + 'Private _vehicleInputData As JSONComponentInputData + 'Private _engineInputData As JSONComponentInputData + 'Private _gearboxInputData As JSONComponentInputData - Public Class AuxEntry - Public Type As AuxiliaryType - Public ReadOnly Path As SubPath - Public ReadOnly TechnologyList As List(Of String) + Public Class AuxEntry + Public Type As AuxiliaryType + Public ReadOnly Path As SubPath + Public ReadOnly TechnologyList As List(Of String) - Public Sub New() - Path = New SubPath - TechnologyList = New List(Of String)() - End Sub - End Class + Public Sub New() + Path = New SubPath + TechnologyList = New List(Of String)() + End Sub + End Class - Public Sub New() + Public Sub New() - _myPath = "" - _sFilePath = "" + _myPath = "" + _sFilePath = "" - _vehicleFile = New SubPath - _engineFile = New SubPath - _gearboxFile = New SubPath + _vehicleFile = New SubPath + _engineFile = New SubPath + _gearboxFile = New SubPath - _driverAccelerationFile = New SubPath + _driverAccelerationFile = New SubPath - AuxPaths = New Dictionary(Of String, AuxEntry) + AuxPaths = New Dictionary(Of String, AuxEntry) - CycleFiles = New List(Of SubPath) - End Sub + CycleFiles = New List(Of SubPath) + End Sub - Public Function SaveFile() As Boolean - Dim validationResults As IList(Of ValidationResult) = - Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering), - Nothing, False) + Public Function SaveFile() As Boolean + Dim validationResults As IList(Of ValidationResult) = + Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering), + 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 + 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 + 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 - 'This Sub reads those Input-files that do not have their own class, etc. + 'This Sub reads those Input-files that do not have their own class, etc. #Region "Properties" - 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 Property PathEng(Optional ByVal original As Boolean = False) As String - Get - If original Then - Return _engineFile.OriginalPath - Else - Return _engineFile.FullPath - End If - End Get - Set(value As String) - _engineFile.Init(_myPath, value) - End Set - End Property - - Public Property PathGbx(Optional ByVal original As Boolean = False) As String - Get - If original Then - Return _gearboxFile.OriginalPath - Else - Return _gearboxFile.FullPath - End If - End Get - Set(value As String) - _gearboxFile.Init(_myPath, value) - End Set - End Property - - - Public ReadOnly Property IDriverDeclarationInputData_SavedInDeclarationMode As Boolean _ - Implements IDriverDeclarationInputData.SavedInDeclarationMode - Get - Return Cfg.DeclMode - End Get - End Property - - 'Public Property StartStop As Boolean - ' Get - ' Return _startStop - ' End Get - ' Set(value As Boolean) - ' _startStop = value - ' End Set - 'End Property - - Public ReadOnly Property IDriverEngineeringInputData_OverSpeedEcoRoll As IOverSpeedEcoRollEngineeringInputData _ - Implements IDriverEngineeringInputData.OverSpeedEcoRoll - Get - Dim mode As DriverMode = DriverMode.Off - If EcoRollOn Then - mode = DriverMode.EcoRoll - ElseIf OverSpeedOn Then - mode = DriverMode.Overspeed - End If - - Return New OverSpeedEcoRollInputData() With { - .Mode = mode, - .MinSpeed = VMin.KMPHtoMeterPerSecond(), - .OverSpeed = OverSpeed.KMPHtoMeterPerSecond(), - .UnderSpeed = UnderSpeed.KMPHtoMeterPerSecond() - } - End Get - End Property - - - Public ReadOnly Property AccelerationCurve As TableData Implements IDriverEngineeringInputData.AccelerationCurve - Get - If String.IsNullOrWhiteSpace(_driverAccelerationFile.FullPath) Then Return Nothing - If Not File.Exists(_driverAccelerationFile.FullPath) Then - Try - Dim cycleDataRes As Stream = - RessourceHelper.ReadStream( - DeclarationData.DeclarationDataResourcePrefix + ".VACC." + _driverAccelerationFile.OriginalPath + - VectoCore.Configuration.Constants.FileExtensions.DriverAccelerationCurve) - Return _ - VectoCSVFile.ReadStream(cycleDataRes, - source:=DeclarationData.DeclarationDataResourcePrefix + ".VACC." + _driverAccelerationFile.OriginalPath + - VectoCore.Configuration.Constants.FileExtensions.DriverAccelerationCurve) - Catch ex As Exception - Return Nothing - End Try - End If - Return VectoCSVFile.Read(_driverAccelerationFile.FullPath) - End Get - End Property - - Public ReadOnly Property Lookahead As ILookaheadCoastingInputData Implements IDriverEngineeringInputData.Lookahead - Get - Dim lacTargetLookup As TableData = - If(File.Exists(LacDfTargetSpeedFile), VectoCSVFile.Read(LacDfTargetSpeedFile), Nothing) - Dim lacVdropLookup As TableData = - If(File.Exists(LacDfVelocityDropFile), VectoCSVFile.Read(LacDfVelocityDropFile), Nothing) - Return New LookAheadCoastingInputData With { - .Enabled = LookAheadOn, - .MinSpeed = LookAheadMinSpeed.KMPHtoMeterPerSecond(), - .CoastingDecisionFactorScaling = LacDfScale, - .CoastingDecisionFactorOffset = LacDfOffset, - .LookaheadDistanceFactor = LacPreviewFactor, - .CoastingDecisionFactorTargetSpeedLookup = lacTargetLookup, - .CoastingDecisionFactorVelocityDropLookup = lacVdropLookup - } - End Get - End Property - - - Public Property DesMaxFile(Optional ByVal original As Boolean = False) As String - Get - If original Then - Return _driverAccelerationFile.OriginalPath - Else - Return _driverAccelerationFile.FullPath - End If - End Get - Set(value As String) - _driverAccelerationFile.Init(_myPath, value) - End Set - End Property - - Public Property LacPreviewFactor As Double - Public Property LacDfOffset As Double - Public Property LacDfScale As Double - Public Property LacDfTargetSpeedFile As String - Public Property LacDfVelocityDropFile As String + 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 Property PathEng(Optional ByVal original As Boolean = False) As String + Get + If original Then + Return _engineFile.OriginalPath + Else + Return _engineFile.FullPath + End If + End Get + Set(value As String) + _engineFile.Init(_myPath, value) + End Set + End Property + + Public Property PathGbx(Optional ByVal original As Boolean = False) As String + Get + If original Then + Return _gearboxFile.OriginalPath + Else + Return _gearboxFile.FullPath + End If + End Get + Set(value As String) + _gearboxFile.Init(_myPath, value) + End Set + End Property + + + Public ReadOnly Property IDriverDeclarationInputData_SavedInDeclarationMode As Boolean _ + Implements IDriverDeclarationInputData.SavedInDeclarationMode + Get + Return Cfg.DeclMode + End Get + End Property + + 'Public Property StartStop As Boolean + ' Get + ' Return _startStop + ' End Get + ' Set(value As Boolean) + ' _startStop = value + ' End Set + 'End Property + + Public ReadOnly Property IDriverEngineeringInputData_OverSpeedEcoRoll As IOverSpeedEcoRollEngineeringInputData _ + Implements IDriverEngineeringInputData.OverSpeedEcoRoll + Get + Dim mode As DriverMode = DriverMode.Off + If EcoRollOn Then + mode = DriverMode.EcoRoll + ElseIf OverSpeedOn Then + mode = DriverMode.Overspeed + End If + + Return New OverSpeedEcoRollInputData() With { + .Mode = mode, + .MinSpeed = VMin.KMPHtoMeterPerSecond(), + .OverSpeed = OverSpeed.KMPHtoMeterPerSecond(), + .UnderSpeed = UnderSpeed.KMPHtoMeterPerSecond() + } + End Get + End Property + + + Public ReadOnly Property AccelerationCurve As TableData Implements IDriverEngineeringInputData.AccelerationCurve + Get + If String.IsNullOrWhiteSpace(_driverAccelerationFile.FullPath) Then Return Nothing + If Not File.Exists(_driverAccelerationFile.FullPath) Then + Try + Dim cycleDataRes As Stream = + RessourceHelper.ReadStream( + DeclarationData.DeclarationDataResourcePrefix + ".VACC." + _driverAccelerationFile.OriginalPath + + VectoCore.Configuration.Constants.FileExtensions.DriverAccelerationCurve) + Return _ + VectoCSVFile.ReadStream(cycleDataRes, + source:=DeclarationData.DeclarationDataResourcePrefix + ".VACC." + _driverAccelerationFile.OriginalPath + + VectoCore.Configuration.Constants.FileExtensions.DriverAccelerationCurve) + Catch ex As Exception + Return Nothing + End Try + End If + Return VectoCSVFile.Read(_driverAccelerationFile.FullPath) + End Get + End Property + + Public ReadOnly Property Lookahead As ILookaheadCoastingInputData Implements IDriverEngineeringInputData.Lookahead + Get + Dim lacTargetLookup As TableData = + If(File.Exists(LacDfTargetSpeedFile), VectoCSVFile.Read(LacDfTargetSpeedFile), Nothing) + Dim lacVdropLookup As TableData = + If(File.Exists(LacDfVelocityDropFile), VectoCSVFile.Read(LacDfVelocityDropFile), Nothing) + Return New LookAheadCoastingInputData With { + .Enabled = LookAheadOn, + .MinSpeed = LookAheadMinSpeed.KMPHtoMeterPerSecond(), + .CoastingDecisionFactorScaling = LacDfScale, + .CoastingDecisionFactorOffset = LacDfOffset, + .LookaheadDistanceFactor = LacPreviewFactor, + .CoastingDecisionFactorTargetSpeedLookup = lacTargetLookup, + .CoastingDecisionFactorVelocityDropLookup = lacVdropLookup + } + End Get + End Property + + + Public Property DesMaxFile(Optional ByVal original As Boolean = False) As String + Get + If original Then + Return _driverAccelerationFile.OriginalPath + Else + Return _driverAccelerationFile.FullPath + End If + End Get + Set(value As String) + _driverAccelerationFile.Init(_myPath, value) + End Set + End Property + + Public Property LacPreviewFactor As Double + Public Property LacDfOffset As Double + Public Property LacDfScale As Double + Public Property LacDfTargetSpeedFile As String + Public Property LacDfVelocityDropFile As String #End Region - ' ReSharper disable once UnusedMember.Global -- used by Validation - Public Shared Function ValidateJob(vectoJob As VectoJob, 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) - - If mode = ExecutionMode.Engineering AndAlso vectoJob.EngineOnly Then - Return ValidateEngineOnlyJob(vectoJob, mode) - End If - - Return ValidateVehicleJob(vectoJob, mode) - End Function - - Private Shared Function ValidateEngineOnlyJob(vectoJob As VectoJob, executionMode As ExecutionMode) As ValidationResult - Dim result As IList(Of ValidationResult) = New List(Of ValidationResult) - - 'vectoJob._engineInputData = New JSONComponentInputData(vectoJob._engineFile.FullPath) - - If vectoJob.Vehicle.EngineInputData Is Nothing Then _ - result.Add(New ValidationResult("Engine File is missing or invalid")) - If result.Any() Then - Return _ - New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) - End If - - Return ValidationResult.Success - End Function - - Private Shared Function ValidateVehicleJob(vectoJob As VectoJob, mode As ExecutionMode) As ValidationResult - - Dim jobData As VectoRunData - - 'vectoJob._vehicleInputData = New JSONComponentInputData(vectoJob._vehicleFile.FullPath) - 'vectoJob._engineInputData = New JSONComponentInputData(vectoJob._engineFile.FullPath) - 'vectoJob._gearboxInputData = New JSONComponentInputData(vectoJob._gearboxFile.FullPath) - - - Dim result As IList(Of ValidationResult) = New List(Of ValidationResult) - - Dim vehicleInputData As IVehicleEngineeringInputData = vectoJob.JobInputData.Vehicle - Dim engineInputData As IEngineDeclarationInputData = vectoJob.Vehicle.EngineInputData - Dim gearboxInputData As IGearboxDeclarationInputData = vectoJob.Vehicle.GearboxInputData - - If vehicleInputData Is Nothing Then _ - result.Add(New ValidationResult("Vehicle File is missing or invalid")) - If engineInputData Is Nothing Then _ - result.Add(New ValidationResult("Engine File is missing or invalid")) - If gearboxInputData Is Nothing Then _ - result.Add(New ValidationResult("Gearbox File is missing or invalid")) - - If result.Any() Then - Return _ - New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) - End If - Try - If mode = ExecutionMode.Declaration Then - If Not vehicleInputData.SavedInDeclarationMode Then - result.Add(New ValidationResult("Vehicle File is not in Declaration Mode")) - End If - If Not engineInputData.SavedInDeclarationMode Then - result.Add(New ValidationResult("Engine File is not in Declaration Mode")) - End If - If Not gearboxInputData.SavedInDeclarationMode Then - result.Add(New ValidationResult("Gearbox File is not in Declaration Mode")) - End If - If result.Any() Then - Return _ - New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) - End If - - Dim dataFactory As DeclarationModeVectoRunDataFactory = New DeclarationModeVectoRunDataFactory(vectoJob, Nothing) - - jobData = dataFactory.NextRun().First() - Else - If vehicleInputData.SavedInDeclarationMode Then - result.Add(New ValidationResult("Vehicle File is not in Engineering Mode")) - End If - If engineInputData.SavedInDeclarationMode Then - result.Add(New ValidationResult("Engine File is not in Engineering Mode")) - End If - If gearboxInputData.SavedInDeclarationMode Then - result.Add(New ValidationResult("Gearbox File is not in Engineering Mode")) - End If - If result.Any() Then - Return _ - New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) - End If - Dim dataFactory As EngineeringModeVectoRunDataFactory = New EngineeringModeVectoRunDataFactory(vectoJob) - jobData = dataFactory.NextRun().FirstOrDefault() - If jobData Is Nothing Then - Return New ValidationResult("No cycles selected in Vecto Job.", result.Select(Function(r) r.ErrorMessage).ToList()) - End If - End If - - - result = jobData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering), - jobData.GearboxData.Type, False) - If result.Any() Then - Return _ - New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) - End If - - - Return ValidationResult.Success - - Catch ex As Exception - Return New ValidationResult(ex.Message) - 'Finally - ' vectoJob._vehicleInputData = Nothing - ' vectoJob._engineInputData = Nothing - ' vectoJob._gearboxInputData = Nothing - End Try - End Function + ' ReSharper disable once UnusedMember.Global -- used by Validation + Public Shared Function ValidateJob(vectoJob As VectoJob, 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) + + If mode = ExecutionMode.Engineering AndAlso vectoJob.EngineOnly Then + Return ValidateEngineOnlyJob(vectoJob, mode) + End If + + Return ValidateVehicleJob(vectoJob, mode) + End Function + + Private Shared Function ValidateEngineOnlyJob(vectoJob As VectoJob, executionMode As ExecutionMode) As ValidationResult + Dim result As IList(Of ValidationResult) = New List(Of ValidationResult) + + 'vectoJob._engineInputData = New JSONComponentInputData(vectoJob._engineFile.FullPath) + + If vectoJob.Vehicle.EngineInputData Is Nothing Then _ + result.Add(New ValidationResult("Engine File is missing or invalid")) + If result.Any() Then + Return _ + New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + + Return ValidationResult.Success + End Function + + Private Shared Function ValidateVehicleJob(vectoJob As VectoJob, mode As ExecutionMode) As ValidationResult + + Dim jobData As VectoRunData + + 'vectoJob._vehicleInputData = New JSONComponentInputData(vectoJob._vehicleFile.FullPath) + 'vectoJob._engineInputData = New JSONComponentInputData(vectoJob._engineFile.FullPath) + 'vectoJob._gearboxInputData = New JSONComponentInputData(vectoJob._gearboxFile.FullPath) + + + Dim result As IList(Of ValidationResult) = New List(Of ValidationResult) + + Dim vehicleInputData As IVehicleEngineeringInputData = vectoJob.JobInputData.Vehicle + Dim engineInputData As IEngineDeclarationInputData = vectoJob.JobInputData.Vehicle.EngineInputData + Dim gearboxInputData As IGearboxDeclarationInputData = vectoJob.Vehicle.GearboxInputData + + If vehicleInputData Is Nothing Then _ + result.Add(New ValidationResult("Vehicle File is missing or invalid")) + If engineInputData Is Nothing Then _ + result.Add(New ValidationResult("Engine File is missing or invalid")) + If gearboxInputData Is Nothing Then _ + result.Add(New ValidationResult("Gearbox File is missing or invalid")) + + If result.Any() Then + Return _ + New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + Try + If mode = ExecutionMode.Declaration Then + If Not vehicleInputData.SavedInDeclarationMode Then + result.Add(New ValidationResult("Vehicle File is not in Declaration Mode")) + End If + If Not engineInputData.SavedInDeclarationMode Then + result.Add(New ValidationResult("Engine File is not in Declaration Mode")) + End If + If Not gearboxInputData.SavedInDeclarationMode Then + result.Add(New ValidationResult("Gearbox File is not in Declaration Mode")) + End If + If result.Any() Then + Return _ + New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + + Dim dataFactory As DeclarationModeVectoRunDataFactory = New DeclarationModeVectoRunDataFactory(vectoJob, Nothing) + + jobData = dataFactory.NextRun().First() + Else + If vehicleInputData.SavedInDeclarationMode Then + result.Add(New ValidationResult("Vehicle File is not in Engineering Mode")) + End If + If engineInputData.SavedInDeclarationMode Then + result.Add(New ValidationResult("Engine File is not in Engineering Mode")) + End If + If gearboxInputData.SavedInDeclarationMode Then + result.Add(New ValidationResult("Gearbox File is not in Engineering Mode")) + End If + If result.Any() Then + Return _ + New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + Dim dataFactory As EngineeringModeVectoRunDataFactory = New EngineeringModeVectoRunDataFactory(vectoJob) + jobData = dataFactory.NextRun().FirstOrDefault() + If jobData Is Nothing Then + Return New ValidationResult("No cycles selected in Vecto Job.", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + End If + + + result = jobData.Validate(If(Cfg.DeclMode, ExecutionMode.Declaration, ExecutionMode.Engineering), + jobData.GearboxData.Type, False) + If result.Any() Then + Return _ + New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + + + Return ValidationResult.Success + + Catch ex As Exception + Return New ValidationResult(ex.Message) + 'Finally + ' vectoJob._vehicleInputData = Nothing + ' vectoJob._engineInputData = Nothing + ' vectoJob._gearboxInputData = Nothing + End Try + End Function #Region "IInputData" - Public ReadOnly Property JobInputData As IEngineeringJobInputData Implements IEngineeringInputDataProvider.JobInputData - Get - Return Me - End Get - End Property - - Public ReadOnly Property IDeclarationInputDataProvider_JobInputData As IDeclarationJobInputData _ - Implements IDeclarationInputDataProvider.JobInputData - Get - Return Me - End Get - End Property - - 'Public ReadOnly Property IDeclarationInputDataProvider_VehicleInputData As IVehicleDeclarationInputData _ - ' Implements IDeclarationInputDataProvider.VehicleInputData - ' Get - ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing - ' Return New JSONComponentInputData(_vehicleFile.FullPath).VehicleInputData - ' End Get - 'End Property - - 'Public ReadOnly Property VehicleInputData As IVehicleEngineeringInputData _ - ' Implements IEngineeringInputDataProvider.VehicleInputData - ' Get - ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing - ' Return New JSONComponentInputData(_vehicleFile.FullPath).VehicleInputData - ' End Get - 'End Property - - 'Public ReadOnly Property IDeclarationInputDataProvider_AirdragInputData As IAirdragDeclarationInputData _ - ' Implements IVehicleDeclarationInputData.AirdragInputData - ' Get - ' Return AirdragInputData - ' End Get - 'End Property - - 'Public ReadOnly Property AirdragInputData As IAirdragEngineeringInputData _ - ' Implements IVehicleEngineeringInputData.AirdragInputData - ' Get - ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing - ' Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle.AirdragInputData - ' End Get - 'End Property - - 'Public ReadOnly Property IDeclarationInputDataProvider_GearboxInputData As IGearboxDeclarationInputData _ - ' Implements IVehicleDeclarationInputData.GearboxInputData - ' Get - ' If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing - ' Return New JSONComponentInputData(_gearboxFile.FullPath).JobInputData.Vehicle.GearboxInputData - ' End Get - 'End Property - - 'Public ReadOnly Property GearboxInputData As IGearboxEngineeringInputData _ - ' Implements IVehicleEngineeringInputData.GearboxInputData - ' Get - ' If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing - ' Return New JSONComponentInputData(_gearboxFile.FullPath).JobInputData.Vehicle.GearboxInputData - ' End Get - 'End Property - - 'Public ReadOnly Property IDeclarationInputDataProvider_TorqueConverterInputData As ITorqueConverterDeclarationInputData _ - ' Implements IVehicleDeclarationInputData.TorqueConverterInputData - ' Get - ' If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing - ' Return New JSONComponentInputData(_gearboxFile.FullPath).JobInputData.Vehicle.TorqueConverterInputData - ' End Get - 'End Property - - 'Public ReadOnly Property TorqueConverterInputData As ITorqueConverterEngineeringInputData _ - ' Implements IVehicleEngineeringInputData.TorqueConverterInputData - ' Get - ' If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing - ' Return New JSONComponentInputData(_gearboxFile.FullPath).JobInputData.Vehicle.TorqueConverterInputData - ' End Get - 'End Property - - 'Public ReadOnly Property IDeclarationInputDataProvider_AxleGearInputData As IAxleGearInputData _ - ' Implements IVehicleDeclarationInputData.AxleGearInputData - ' Get - ' If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing - ' Return New JSONComponentInputData(_gearboxFile.FullPath).JobInputData.Vehicle.AxleGearInputData - ' End Get - 'End Property - - 'Public ReadOnly Property AxleGearInputData As IAxleGearInputData _ - ' Implements IVehicleEngineeringInputData.AxleGearInputData - ' Get - ' If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing - ' Return New JSONComponentInputData(_gearboxFile.FullPath).JobInputData.Vehicle.AxleGearInputData - ' End Get - 'End Property - - 'Public ReadOnly Property DeclarationInputDataProviderAngledriveInputData As IAngledriveInputData _ - ' Implements IVehicleDeclarationInputData.AngledriveInputData - ' Get - ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing - ' Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle.AngledriveInputData - ' End Get - 'End Property - - 'Public ReadOnly Property AngledriveInputData As IAngledriveInputData _ - ' Implements IVehicleEngineeringInputData.AngledriveInputData - ' Get - ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing - ' Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle.AngledriveInputData - ' End Get - 'End Property - - 'Public ReadOnly Property IDeclarationInputDataProvider_EngineInputData As IEngineDeclarationInputData _ - ' Implements IVehicleDeclarationInputData.EngineInputData - ' Get - ' If Not File.Exists(_engineFile.FullPath) Then Return Nothing - ' Return New JSONComponentInputData(_engineFile.FullPath).JobInputData.Vehicle.EngineInputData - ' End Get - 'End Property - - 'Public ReadOnly Property EngineInputData As IEngineEngineeringInputData _ - ' Implements IVehicleEngineeringInputData.EngineInputData - ' Get - ' If Not File.Exists(_engineFile.FullPath) Then Return Nothing - ' Return New JSONComponentInputData(_engineFile.FullPath).JobInputData.Vehicle.EngineInputData - ' End Get - 'End Property - - 'Public Function AuxiliaryInputData() As IAuxiliariesEngineeringInputData _ - ' Implements IVehicleEngineeringInputData.AuxiliaryInputData - - ' Return Me - 'End Function - - 'Public Function IDeclarationInputDataProvider_AuxiliaryInputData() As IAuxiliariesDeclarationInputData _ - ' Implements IVehicleDeclarationInputData.AuxiliaryInputData - - ' Return Me - 'End Function - - 'Public ReadOnly Property IDeclarationInputDataProvider_RetarderInputData As IRetarderInputData _ - ' Implements IVehicleDeclarationInputData.RetarderInputData - ' Get - ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing - ' Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle.RetarderInputData - ' End Get - 'End Property - - 'Public ReadOnly Property RetarderInputData As IRetarderInputData _ - ' Implements IVehicleEngineeringInputData.RetarderInputData - ' Get - ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing - ' Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle.RetarderInputData - ' End Get - 'End Property - - - Public ReadOnly Property DriverInputData As IDriverEngineeringInputData _ - Implements IEngineeringInputDataProvider.DriverInputData - Get - Return Me - End Get - End Property - - 'Public ReadOnly Property IDeclarationInputDataProvider_PTOTransmissionInputData As IPTOTransmissionInputData _ - ' Implements IVehicleDeclarationInputData.PTOTransmissionInputData - ' Get - ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing - ' Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle.PTOTransmissionInputData - ' End Get - 'End Property - - 'Public ReadOnly Property PTOTransmissionInputData As IPTOTransmissionInputData _ - ' Implements IVehicleEngineeringInputData.PTOTransmissionInputData - ' Get - ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing - ' Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle.PTOTransmissionInputData - ' End Get - 'End Property - - Public ReadOnly Property XMLHash As XElement Implements IDeclarationInputDataProvider.XMLHash - Get - Return Nothing - End Get - End Property - - - Public ReadOnly Property SavedInDeclarationMode As Boolean Implements IDeclarationJobInputData.SavedInDeclarationMode - Get - Return Cfg.DeclMode - End Get - End Property - - - Public ReadOnly Property IEngineeringJobInputData_Vehicle As IVehicleEngineeringInputData _ - Implements IEngineeringJobInputData.Vehicle - Get - If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing - Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle - End Get - End Property - - Public ReadOnly Property Vehicle As IVehicleDeclarationInputData Implements IDeclarationJobInputData.Vehicle - Get - If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing - Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle - End Get - End Property - - Public ReadOnly Property Cycles As IList(Of ICycleData) Implements IEngineeringJobInputData.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 EngineOnlyMode As Boolean Implements IEngineeringJobInputData.EngineOnlyMode - Get - Return EngineOnly - End Get - End Property - - Public ReadOnly Property IEngineeringJobInputData_EngineOnly As IEngineEngineeringInputData Implements IEngineeringJobInputData.EngineOnly - Get - If Not File.Exists(_engineFile.FullPath) Then Return Nothing - Return New JSONComponentInputData(_engineFile.FullPath).JobInputData.Vehicle.EngineInputData - End Get - End Property - - Public ReadOnly Property JobName As String Implements IDeclarationJobInputData.JobName - Get - Return Path.GetFileNameWithoutExtension(FilePath) - End Get - End Property - - Public Property AuxPAdd As Double - - Public ReadOnly Property IAuxiliariesDeclarationInputData_SavedInDeclarationMode As Boolean _ - Implements IAuxiliariesDeclarationInputData.SavedInDeclarationMode - Get - Return Cfg.DeclMode - End Get - End Property - - Public ReadOnly Property Auxiliaries As IList(Of IAuxiliaryEngineeringInputData) _ - Implements IAuxiliariesEngineeringInputData.Auxiliaries - Get - Return AuxData().Cast(Of IAuxiliaryEngineeringInputData).ToList() - End Get - End Property - - Public ReadOnly Property IAuxiliariesEngineeringInputData_AdvancedAuxiliaryFilePath As String _ - Implements IAuxiliariesEngineeringInputData.AdvancedAuxiliaryFilePath - Get - Return AdvancedAuxiliaryFilePath - End Get - End Property - - Public ReadOnly Property IAuxiliariesEngineeringInputData_AuxiliaryVersion As String _ - Implements IAuxiliariesEngineeringInputData.AuxiliaryVersion - Get - Return AuxiliaryVersion - End Get - End Property - - Public ReadOnly Property IAuxiliariesEngineeringInputData_AuxiliaryAssembly As AuxiliaryModel _ - Implements IAuxiliariesEngineeringInputData.AuxiliaryAssembly - Get - Return AuxiliaryModelHelper.Parse(AuxiliaryAssembly) - End Get - End Property - - Public ReadOnly Property IAuxiliariesDeclarationInputData_Auxiliaries As IList(Of IAuxiliaryDeclarationInputData) _ - Implements IAuxiliariesDeclarationInputData.Auxiliaries - Get - Return AuxData().Cast(Of IAuxiliaryDeclarationInputData).ToList() - End Get - End Property - - Protected Function AuxData() As IList(Of AuxiliaryDataInputData) - Dim retVal As List(Of AuxiliaryDataInputData) = New List(Of AuxiliaryDataInputData) - - If AuxPAdd > 0 Then - retVal.Add(New AuxiliaryDataInputData() With { - .ID = "ConstantAux", - .AuxiliaryType = AuxiliaryDemandType.Constant, - .ConstantPowerDemand = AuxPAdd.SI(Of Watt)() - }) - End If - For Each auxEntry As KeyValuePair(Of String, AuxEntry) In AuxPaths - Dim theAuxData As AuxiliaryDataInputData = New AuxiliaryDataInputData() With { - .Type = auxEntry.Value.Type, - .Technology = auxEntry.Value.TechnologyList, - .ID = auxEntry.Key - } - retVal.Add(theAuxData) - If Not File.Exists(auxEntry.Value.Path.FullPath) Then Continue For - - Dim stream As StreamReader = New StreamReader(auxEntry.Value.Path.FullPath) - stream.ReadLine() ' skip header "Transmission ration to engine rpm [-]" - theAuxData.TransmissionRatio = stream.ReadLine().IndulgentParse() - stream.ReadLine() ' skip header "Efficiency to engine [-]" - theAuxData.EfficiencyToEngine = stream.ReadLine().IndulgentParse() - 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) - Next - - Return retVal - End Function + Public ReadOnly Property JobInputData As IEngineeringJobInputData Implements IEngineeringInputDataProvider.JobInputData + Get + Return Me + End Get + End Property + + Public ReadOnly Property IDeclarationInputDataProvider_JobInputData As IDeclarationJobInputData _ + Implements IDeclarationInputDataProvider.JobInputData + Get + Return Me + End Get + End Property + + 'Public ReadOnly Property IDeclarationInputDataProvider_VehicleInputData As IVehicleDeclarationInputData _ + ' Implements IDeclarationInputDataProvider.VehicleInputData + ' Get + ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing + ' Return New JSONComponentInputData(_vehicleFile.FullPath).VehicleInputData + ' End Get + 'End Property + + 'Public ReadOnly Property VehicleInputData As IVehicleEngineeringInputData _ + ' Implements IEngineeringInputDataProvider.VehicleInputData + ' Get + ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing + ' Return New JSONComponentInputData(_vehicleFile.FullPath).VehicleInputData + ' End Get + 'End Property + + 'Public ReadOnly Property IDeclarationInputDataProvider_AirdragInputData As IAirdragDeclarationInputData _ + ' Implements IVehicleDeclarationInputData.AirdragInputData + ' Get + ' Return AirdragInputData + ' End Get + 'End Property + + 'Public ReadOnly Property AirdragInputData As IAirdragEngineeringInputData _ + ' Implements IVehicleEngineeringInputData.AirdragInputData + ' Get + ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing + ' Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle.AirdragInputData + ' End Get + 'End Property + + 'Public ReadOnly Property IDeclarationInputDataProvider_GearboxInputData As IGearboxDeclarationInputData _ + ' Implements IVehicleDeclarationInputData.GearboxInputData + ' Get + ' If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing + ' Return New JSONComponentInputData(_gearboxFile.FullPath).JobInputData.Vehicle.GearboxInputData + ' End Get + 'End Property + + 'Public ReadOnly Property GearboxInputData As IGearboxEngineeringInputData _ + ' Implements IVehicleEngineeringInputData.GearboxInputData + ' Get + ' If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing + ' Return New JSONComponentInputData(_gearboxFile.FullPath).JobInputData.Vehicle.GearboxInputData + ' End Get + 'End Property + + 'Public ReadOnly Property IDeclarationInputDataProvider_TorqueConverterInputData As ITorqueConverterDeclarationInputData _ + ' Implements IVehicleDeclarationInputData.TorqueConverterInputData + ' Get + ' If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing + ' Return New JSONComponentInputData(_gearboxFile.FullPath).JobInputData.Vehicle.TorqueConverterInputData + ' End Get + 'End Property + + 'Public ReadOnly Property TorqueConverterInputData As ITorqueConverterEngineeringInputData _ + ' Implements IVehicleEngineeringInputData.TorqueConverterInputData + ' Get + ' If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing + ' Return New JSONComponentInputData(_gearboxFile.FullPath).JobInputData.Vehicle.TorqueConverterInputData + ' End Get + 'End Property + + 'Public ReadOnly Property IDeclarationInputDataProvider_AxleGearInputData As IAxleGearInputData _ + ' Implements IVehicleDeclarationInputData.AxleGearInputData + ' Get + ' If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing + ' Return New JSONComponentInputData(_gearboxFile.FullPath).JobInputData.Vehicle.AxleGearInputData + ' End Get + 'End Property + + 'Public ReadOnly Property AxleGearInputData As IAxleGearInputData _ + ' Implements IVehicleEngineeringInputData.AxleGearInputData + ' Get + ' If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing + ' Return New JSONComponentInputData(_gearboxFile.FullPath).JobInputData.Vehicle.AxleGearInputData + ' End Get + 'End Property + + 'Public ReadOnly Property DeclarationInputDataProviderAngledriveInputData As IAngledriveInputData _ + ' Implements IVehicleDeclarationInputData.AngledriveInputData + ' Get + ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing + ' Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle.AngledriveInputData + ' End Get + 'End Property + + 'Public ReadOnly Property AngledriveInputData As IAngledriveInputData _ + ' Implements IVehicleEngineeringInputData.AngledriveInputData + ' Get + ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing + ' Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle.AngledriveInputData + ' End Get + 'End Property + + 'Public ReadOnly Property IDeclarationInputDataProvider_EngineInputData As IEngineDeclarationInputData _ + ' Implements IVehicleDeclarationInputData.EngineInputData + ' Get + ' If Not File.Exists(_engineFile.FullPath) Then Return Nothing + ' Return New JSONComponentInputData(_engineFile.FullPath).JobInputData.Vehicle.EngineInputData + ' End Get + 'End Property + + 'Public ReadOnly Property EngineInputData As IEngineEngineeringInputData _ + ' Implements IVehicleEngineeringInputData.EngineInputData + ' Get + ' If Not File.Exists(_engineFile.FullPath) Then Return Nothing + ' Return New JSONComponentInputData(_engineFile.FullPath).JobInputData.Vehicle.EngineInputData + ' End Get + 'End Property + + 'Public Function AuxiliaryInputData() As IAuxiliariesEngineeringInputData _ + ' Implements IVehicleEngineeringInputData.AuxiliaryInputData + + ' Return Me + 'End Function + + 'Public Function IDeclarationInputDataProvider_AuxiliaryInputData() As IAuxiliariesDeclarationInputData _ + ' Implements IVehicleDeclarationInputData.AuxiliaryInputData + + ' Return Me + 'End Function + + 'Public ReadOnly Property IDeclarationInputDataProvider_RetarderInputData As IRetarderInputData _ + ' Implements IVehicleDeclarationInputData.RetarderInputData + ' Get + ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing + ' Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle.RetarderInputData + ' End Get + 'End Property + + 'Public ReadOnly Property RetarderInputData As IRetarderInputData _ + ' Implements IVehicleEngineeringInputData.RetarderInputData + ' Get + ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing + ' Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle.RetarderInputData + ' End Get + 'End Property + + + Public ReadOnly Property DriverInputData As IDriverEngineeringInputData _ + Implements IEngineeringInputDataProvider.DriverInputData + Get + Return Me + End Get + End Property + + 'Public ReadOnly Property IDeclarationInputDataProvider_PTOTransmissionInputData As IPTOTransmissionInputData _ + ' Implements IVehicleDeclarationInputData.PTOTransmissionInputData + ' Get + ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing + ' Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle.PTOTransmissionInputData + ' End Get + 'End Property + + 'Public ReadOnly Property PTOTransmissionInputData As IPTOTransmissionInputData _ + ' Implements IVehicleEngineeringInputData.PTOTransmissionInputData + ' Get + ' If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing + ' Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle.PTOTransmissionInputData + ' End Get + 'End Property + + Public ReadOnly Property XMLHash As XElement Implements IDeclarationInputDataProvider.XMLHash + Get + Return Nothing + End Get + End Property + + + Public ReadOnly Property SavedInDeclarationMode As Boolean Implements IDeclarationJobInputData.SavedInDeclarationMode + Get + Return Cfg.DeclMode + End Get + End Property + + + Public ReadOnly Property IEngineeringJobInputData_Vehicle As IVehicleEngineeringInputData _ + Implements IEngineeringJobInputData.Vehicle + Get + If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing + Return New JSONComponentInputData(_vehicleFile.FullPath, Me).JobInputData.Vehicle + End Get + End Property + + Public ReadOnly Property Vehicle As IVehicleDeclarationInputData Implements IDeclarationJobInputData.Vehicle + Get + If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing + Return New JSONComponentInputData(_vehicleFile.FullPath, Me).JobInputData.Vehicle + End Get + End Property + + Public ReadOnly Property Cycles As IList(Of ICycleData) Implements IEngineeringJobInputData.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 EngineOnlyMode As Boolean Implements IEngineeringJobInputData.EngineOnlyMode + Get + Return EngineOnly + End Get + End Property + + Public ReadOnly Property IEngineeringJobInputData_EngineOnly As IEngineEngineeringInputData Implements IEngineeringJobInputData.EngineOnly + Get + If Not File.Exists(_engineFile.FullPath) Then Return Nothing + Return New JSONComponentInputData(_engineFile.FullPath, Me).JobInputData.Vehicle.EngineInputData + End Get + End Property + + Public ReadOnly Property JobName As String Implements IDeclarationJobInputData.JobName + Get + Return Path.GetFileNameWithoutExtension(FilePath) + End Get + End Property + + Public Property AuxPAdd As Double + + Public ReadOnly Property IAuxiliariesDeclarationInputData_SavedInDeclarationMode As Boolean _ + Implements IAuxiliariesDeclarationInputData.SavedInDeclarationMode + Get + Return Cfg.DeclMode + End Get + End Property + + Public ReadOnly Property Auxiliaries As IList(Of IAuxiliaryEngineeringInputData) _ + Implements IAuxiliariesEngineeringInputData.Auxiliaries + Get + Return AuxData().Cast(Of IAuxiliaryEngineeringInputData).ToList() + End Get + End Property + + Public ReadOnly Property IAuxiliariesEngineeringInputData_AdvancedAuxiliaryFilePath As String _ + Implements IAuxiliariesEngineeringInputData.AdvancedAuxiliaryFilePath + Get + Return AdvancedAuxiliaryFilePath + End Get + End Property + + Public ReadOnly Property IAuxiliariesEngineeringInputData_AuxiliaryVersion As String _ + Implements IAuxiliariesEngineeringInputData.AuxiliaryVersion + Get + Return AuxiliaryVersion + End Get + End Property + + Public ReadOnly Property IAuxiliariesEngineeringInputData_AuxiliaryAssembly As AuxiliaryModel _ + Implements IAuxiliariesEngineeringInputData.AuxiliaryAssembly + Get + Return AuxiliaryModelHelper.Parse(AuxiliaryAssembly) + End Get + End Property + + Public ReadOnly Property IAuxiliariesDeclarationInputData_Auxiliaries As IList(Of IAuxiliaryDeclarationInputData) _ + Implements IAuxiliariesDeclarationInputData.Auxiliaries + Get + Return AuxData().Cast(Of IAuxiliaryDeclarationInputData).ToList() + End Get + End Property + + Protected Function AuxData() As IList(Of AuxiliaryDataInputData) + Dim retVal As List(Of AuxiliaryDataInputData) = New List(Of AuxiliaryDataInputData) + + If AuxPAdd > 0 Then + retVal.Add(New AuxiliaryDataInputData() With { + .ID = "ConstantAux", + .AuxiliaryType = AuxiliaryDemandType.Constant, + .ConstantPowerDemand = AuxPAdd.SI(Of Watt)() + }) + End If + For Each auxEntry As KeyValuePair(Of String, AuxEntry) In AuxPaths + Dim theAuxData As AuxiliaryDataInputData = New AuxiliaryDataInputData() With { + .Type = auxEntry.Value.Type, + .Technology = auxEntry.Value.TechnologyList, + .ID = auxEntry.Key + } + retVal.Add(theAuxData) + If Not File.Exists(auxEntry.Value.Path.FullPath) Then Continue For + + Dim stream As StreamReader = New StreamReader(auxEntry.Value.Path.FullPath) + stream.ReadLine() ' skip header "Transmission ration to engine rpm [-]" + theAuxData.TransmissionRatio = stream.ReadLine().IndulgentParse() + stream.ReadLine() ' skip header "Efficiency to engine [-]" + theAuxData.EfficiencyToEngine = stream.ReadLine().IndulgentParse() + 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) + Next + + Return retVal + End Function #End Region + + Public ReadOnly Property Gearbox As IGearboxEngineeringInputData Implements IJSONVehicleComponents.Gearbox + Get + Return New JSONComponentInputData(_gearboxFile.FullPath, Me).JobInputData.Vehicle.GearboxInputData + End Get + End Property + + Public ReadOnly Property TorqueConverter As ITorqueConverterEngineeringInputData Implements IJSONVehicleComponents.TorqueConverter + Get + Return New JSONComponentInputData(_gearboxFile.FullPath, Me).JobInputData.Vehicle.TorqueConverterInputData + End Get + + End Property + + Public ReadOnly Property AxleGear As IAxleGearInputData Implements IJSONVehicleComponents.AxleGear + Get + Return New JSONComponentInputData(_gearboxFile.FullPath, Me).JobInputData.Vehicle.AxleGearInputData + End Get + + End Property + + Public ReadOnly Property Engine As IEngineEngineeringInputData Implements IJSONVehicleComponents.Engine + Get + Return New JSONComponentInputData(_engineFile.FullPath, Me).JobInputData.Vehicle.EngineInputData + End Get + End Property + + Public ReadOnly Property DeclarationAuxiliaries As IAuxiliariesDeclarationInputData Implements IJSONVehicleComponents.DeclarationAuxiliaries + Get + Return Me + End Get + End Property + + Public ReadOnly Property EngineeringAuxiliaries As IAuxiliariesEngineeringInputData Implements IJSONVehicleComponents.EngineeringAuxiliaries + Get + Return Me + End Get + End Property End Class diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/IJSONVehicleComponents.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/IJSONVehicleComponents.cs new file mode 100644 index 0000000000000000000000000000000000000000..c5b32d8cf456998afa0247ab559a0ce0b715af4d --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/IJSONVehicleComponents.cs @@ -0,0 +1,13 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.JSON { + public interface IJSONVehicleComponents { + + IGearboxEngineeringInputData Gearbox { get; } + ITorqueConverterEngineeringInputData TorqueConverter { get; } + IAxleGearInputData AxleGear { get; } + IEngineEngineeringInputData Engine { get; } + IAuxiliariesEngineeringInputData EngineeringAuxiliaries { get; } + IAuxiliariesDeclarationInputData DeclarationAuxiliaries { get; } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs index ad8bd0bfa3dfcd6473836dee33ad65cad6fa5379..47245ca263b79172af4204253e91176e3916d9a7 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs @@ -58,13 +58,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON private string _filename; - public JSONComponentInputData(string filename, bool tolerateMissing = false) + public JSONComponentInputData(string filename, IJSONVehicleComponents job, bool tolerateMissing = false) { var extension = Path.GetExtension(filename); object tmp = null; switch (extension) { case Constants.FileExtensions.VehicleDataFile: - tmp = JSONInputDataFactory.ReadJsonVehicle(filename, null, tolerateMissing); + tmp = JSONInputDataFactory.ReadJsonVehicle(filename, job, tolerateMissing); break; case Constants.FileExtensions.EngineDataFile: tmp = JSONInputDataFactory.ReadEngine(filename, tolerateMissing); diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs index 31209c93caa73197a2bcd5a8514773f3d64340c3..f50231f228b62cd01348a250258eba31d7b14acd 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs @@ -124,38 +124,50 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON /// </summary> public class JSONInputDataV2 : JSONFile, IEngineeringInputDataProvider, IDeclarationInputDataProvider, IEngineeringJobInputData, IDriverEngineeringInputData, IAuxiliariesEngineeringInputData, - IAuxiliariesDeclarationInputData + IAuxiliariesDeclarationInputData, IJSONVehicleComponents { - public IGearboxEngineeringInputData Gearbox { get; internal set; } + + public JSONInputDataV2(JObject data, string filename, bool tolerateMissing = false) + : base(data, filename, tolerateMissing) + { + _jobname = Path.GetFileNameWithoutExtension(filename); + + Engine = ReadEngine(); + + if (Body.GetEx(JsonKeys.Job_EngineOnlyMode).Value<bool>()) + { + return; + } + + Gearbox = ReadGearbox(); + AxleGear = Gearbox as IAxleGearInputData; + TorqueConverter = Gearbox as ITorqueConverterEngineeringInputData; + + VehicleData = ReadVehicle(); + } + + public IGearboxEngineeringInputData Gearbox { get; internal set; } public IAxleGearInputData AxleGear { get; internal set; } public ITorqueConverterEngineeringInputData TorqueConverter { get; internal set; } public IEngineEngineeringInputData Engine { get; internal set; } - protected readonly IVehicleEngineeringInputData VehicleData; + protected readonly IVehicleEngineeringInputData VehicleData; private readonly string _jobname; - public JSONInputDataV2(JObject data, string filename, bool tolerateMissing = false) - : base(data, filename, tolerateMissing) - { - _jobname = Path.GetFileNameWithoutExtension(filename); - - Engine = ReadEngine(); - - if (Body.GetEx(JsonKeys.Job_EngineOnlyMode).Value<bool>()) { - return; - } - - Gearbox = ReadGearbox(); - AxleGear = Gearbox as IAxleGearInputData; - TorqueConverter = Gearbox as ITorqueConverterEngineeringInputData; + public IAuxiliariesEngineeringInputData EngineeringAuxiliaries + { + get { return this; } + } - VehicleData = ReadVehicle(); - } + public IAuxiliariesDeclarationInputData DeclarationAuxiliaries + { + get { return this; } + } - private IVehicleEngineeringInputData ReadVehicle() + private IVehicleEngineeringInputData ReadVehicle() { try { var vehicleFile = Body.GetEx(JsonKeys.Vehicle_VehicleFile).Value<string>(); diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputDataFactory.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputDataFactory.cs index 43f42130cdc55c2faae84ada2b63520a188b71a7..4741c7fd594c3756bacb6a50a0a174ada5fef68b 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputDataFactory.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputDataFactory.cs @@ -57,7 +57,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON if (Constants.FileExtensions.VectoJobFile.Equals(Path.GetExtension(filename), StringComparison.OrdinalIgnoreCase)) { return ReadJsonJob(filename, true); } - return new JSONComponentInputData(filename, true); + return new JSONComponentInputData(filename, null, true); } public static IInputDataProvider ReadJsonJob(string filename, bool tolerateMissing = false) @@ -77,7 +77,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } - public static IVehicleEngineeringInputData ReadJsonVehicle(string filename, JSONInputDataV2 job, bool tolerateMissing = false) + public static IVehicleEngineeringInputData ReadJsonVehicle(string filename, IJSONVehicleComponents job, bool tolerateMissing = false) { var json = ReadFile(filename); var version = ReadVersion(json); diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs index 30b734744f688b112378bd19c6bd41d011c6fab3..9d2c7ef09077cadb4fbc1f8a1b0ac3e1cfa45787 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs @@ -45,13 +45,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public class JSONVehicleDataV7 : JSONFile, IVehicleEngineeringInputData, IRetarderInputData, IAngledriveInputData, IPTOTransmissionInputData, IAirdragEngineeringInputData { - public JSONVehicleDataV7(JObject data, string fileName, JSONInputDataV2 job, bool tolerateMissing = false) + public JSONVehicleDataV7(JObject data, string fileName, IJSONVehicleComponents job, bool tolerateMissing = false) : base(data, fileName, tolerateMissing) { Job = job; } - private JSONInputDataV2 Job; + private IJSONVehicleComponents Job; #region IVehicleInputData @@ -239,7 +239,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON IAuxiliariesDeclarationInputData IVehicleDeclarationInputData.AuxiliaryInputData() { - return Job; + return Job.DeclarationAuxiliaries; } IRetarderInputData IVehicleEngineeringInputData.RetarderInputData @@ -254,7 +254,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON IAuxiliariesEngineeringInputData IVehicleEngineeringInputData.AuxiliaryInputData() { - return Job; + return Job.EngineeringAuxiliaries; } IRetarderInputData IVehicleDeclarationInputData.RetarderInputData diff --git a/VectoCore/VectoCore/Utils/VectoCSVFile.cs b/VectoCore/VectoCore/Utils/VectoCSVFile.cs index e8f80acb30f780639f56d9ae6246bfe0a8ea99ed..0b8477558c073d8a439dca0df9cf70e0bb17c8f1 100644 --- a/VectoCore/VectoCore/Utils/VectoCSVFile.cs +++ b/VectoCore/VectoCore/Utils/VectoCSVFile.cs @@ -35,10 +35,8 @@ using System.Data; using System.Globalization; using System.IO; using System.Linq; -using System.Reflection; using System.Text; using System.Text.RegularExpressions; -using DocumentFormat.OpenXml.Spreadsheet; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index 5287618a7740a1d87572b08bd2672d8b40aca299..d705d3cab6d15894029e87dbee259834a51d2f7c 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -109,6 +109,7 @@ <ItemGroup> <Compile Include="Configuration\Constants.cs" /> <Compile Include="InputData\AuxiliaryFileHelper.cs" /> + <Compile Include="InputData\FileIO\JSON\IJSONVehicleComponents.cs" /> <Compile Include="InputData\FileIO\JSON\JSONComponentInputData.cs" /> <Compile Include="InputData\FileIO\JSON\JsonExtensionMethods.cs" /> <Compile Include="InputData\FileIO\XML\Declaration\AbstractDeclarationXMLComponentDataProvider.cs" /> @@ -312,9 +313,7 @@ <Compile Include="Models\SimulationComponent\IWheels.cs" /> <Compile Include="Models\SimulationComponent\VectoSimulationComponent.cs" /> <Compile Include="Models\SimulationComponent\Impl\PowertrainDrivingCycle.cs" /> - <Compile Include="Models\Simulation\Data\ModalResult.cs"> - <SubType>Component</SubType> - </Compile> + <Compile Include="Models\Simulation\Data\ModalResult.cs" /> <Compile Include="Models\Simulation\IVectoRun.cs" /> <Compile Include="Models\Simulation\Impl\SimulatorFactory.cs" /> <Compile Include="Models\Simulation\Impl\VectoRun.cs" /> @@ -337,11 +336,6 @@ </Compile> <Compile Include="Utils\XmlResourceResolver.cs" /> <Compile Include="Utils\XPathHelper.cs" /> - <Compile Include="VersionNumber1.cs"> - <AutoGen>True</AutoGen> - <DesignTime>True</DesignTime> - <DependentUpon>VersionNumber.t4</DependentUpon> - </Compile> </ItemGroup> <ItemGroup> <None Include="app.config" />