From 0195919bc82e7890cb81fa6637ed7b19d9b258b7 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Mon, 23 Apr 2018 09:33:47 +0200
Subject: [PATCH] fix validating & saving engin-only mode jobs

---
 VECTO/Input Files/VectoJob.vb      |  2 +-
 VECTO/OutputData/JSONFileWriter.vb | 21 +++++++++++----------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/VECTO/Input Files/VectoJob.vb b/VECTO/Input Files/VectoJob.vb
index ed64feae2d..2fac5e484f 100644
--- a/VECTO/Input Files/VectoJob.vb	
+++ b/VECTO/Input Files/VectoJob.vb	
@@ -306,7 +306,7 @@ Public Class VectoJob
 
         'vectoJob._engineInputData = New JSONComponentInputData(vectoJob._engineFile.FullPath)
 
-        If vectoJob.Vehicle.EngineInputData Is Nothing Then _
+        If vectoJob.JobInputData.EngineOnly Is Nothing Then _
             result.Add(New ValidationResult("Engine File is missing or invalid"))
         If result.Any() Then
             Return _
diff --git a/VECTO/OutputData/JSONFileWriter.vb b/VECTO/OutputData/JSONFileWriter.vb
index af4be0deb7..778458c593 100644
--- a/VECTO/OutputData/JSONFileWriter.vb
+++ b/VECTO/OutputData/JSONFileWriter.vb
@@ -253,15 +253,12 @@ Public Class JSONFileWriter
 		'SavedInDeclMode = Cfg.DeclMode
 
 		Dim job As IEngineeringJobInputData = input.JobInputData()
-		Dim aux As IAuxiliariesEngineeringInputData = input.JobInputData.Vehicle.AuxiliaryInputData()
-		Dim driver As IDriverEngineeringInputData = input.DriverInputData
 
-		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(input.JobInputData.Vehicle.EngineInputData.Source, basePath))
+			body.Add("EngineFile", GetRelativePath(job.EngineOnly.Source, basePath))
 			body.Add("Cycles",
 					job.Cycles.Select(Function(x) GetRelativePath(x.CycleData.Source, Path.GetDirectoryName(filename))).ToArray())
 			WriteFile(header, body, filename)
@@ -273,6 +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()
 		'AA-TB
 		'ADVANCED AUXILIARIES 
 		body.Add("AuxiliaryAssembly", aux.AuxiliaryAssembly.GetName())
@@ -302,10 +301,12 @@ Public Class JSONFileWriter
 		Next
 
 		body.Add("Aux", auxList)
-
-		If Not job.SavedInDeclarationMode Then
-			body.Add("Padd", pAdd)
-		End If
+        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
-- 
GitLab