From 38979c8099a8805d9dc8d5673ed2e3f30a80ffd9 Mon Sep 17 00:00:00 2001 From: Michael Krisper <michael.krisper@tugraz.at> Date: Mon, 25 Apr 2022 18:00:46 +0200 Subject: [PATCH] VectoJob.vb: Added Validation that Vehicle File has to be in same JobType than jobFile, that cycles must be defined in engineering mode, and that ElectricMachines must be defined for HEVs and BEVs. --- VECTO/Input Files/VectoJob.vb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/VECTO/Input Files/VectoJob.vb b/VECTO/Input Files/VectoJob.vb index 0e21f7a16e..43fb7e27f3 100644 --- a/VECTO/Input Files/VectoJob.vb +++ b/VECTO/Input Files/VectoJob.vb @@ -506,12 +506,21 @@ Public Class VectoJob Dim result As IList(Of ValidationResult) = New List(Of ValidationResult) Dim vehicleInputData As IVehicleEngineeringInputData = vectoJob.JobInputData.Vehicle + If vehicleInputData Is Nothing Then + result.Add(New ValidationResult("Vehicle File is missing or invalid")) + Return New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) + End If + Dim engineInputData As IEngineDeclarationInputData = vectoJob.JobInputData.Vehicle.Components.EngineInputData Dim gearboxInputData As IGearboxDeclarationInputData = vectoJob.Vehicle.Components.GearboxInputData Dim gearshiftInputData As IGearshiftEngineeringInputData = vectoJob.DriverInputData.GearshiftInputData - If vehicleInputData Is Nothing Then _ - result.Add(New ValidationResult("Vehicle File is missing or invalid")) + If (vehicleInputData.VehicleType <> vectoJob.JobType) Then + result.Add(New ValidationResult($"Vehicle type ""{vehicleInputData.VehicleType}"" differs from job type ""{vectoJob.JobType}"".")) + End If + If vectoJob.JobType.IsOneOf(VectoSimulationJobType.BatteryElectricVehicle, VectoSimulationJobType.ParallelHybridVehicle, VectoSimulationJobType.SerialHybridVehicle) _ + AndAlso (vehicleInputData.Components.ElectricMachines Is Nothing OrElse vehicleInputData.Components.ElectricMachines.Entries.Count = 0) Then _ + result.Add(New ValidationResult("Electric machine is missing in vehicle")) If Not vectoJob.JobType = VectoSimulationJobType.BatteryElectricVehicle AndAlso engineInputData Is Nothing Then _ result.Add(New ValidationResult("Engine File is missing or invalid")) If (vectoJob.JobType = VectoSimulationJobType.ConventionalVehicle OrElse vectoJob.JobType = VectoSimulationJobType.ParallelHybridVehicle) _ @@ -555,6 +564,9 @@ Public Class VectoJob AndAlso gearboxInputData IsNot Nothing AndAlso gearboxInputData.SavedInDeclarationMode Then result.Add(New ValidationResult("Gearbox File is not in Engineering Mode")) End If + If vectoJob.CycleFiles.Count = 0 Then + result.Add(New ValidationResult("At least one cycle must be defined.")) + End If If result.Any() Then Return _ New ValidationResult("Vecto Job Configuration is invalid. ", result.Select(Function(r) r.ErrorMessage).ToList()) -- GitLab