From 96396423cb6742e1060229b4b05a27ebb4798af8 Mon Sep 17 00:00:00 2001
From: "VKMTHD\\haraldmartini" <harald.martini@student.tugraz.at>
Date: Wed, 23 Nov 2022 09:45:10 +0100
Subject: [PATCH] throw exception if pto transmission is specified but the
 vehicle has no gearbox

---
 .../SimulationComponents/PTODataAdapter.cs                | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/PTODataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/PTODataAdapter.cs
index 41fadc4a5c..32aeb3d276 100644
--- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/PTODataAdapter.cs
+++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/PTODataAdapter.cs
@@ -1,4 +1,5 @@
-using TUGraz.VectoCommon.InputData;
+using TUGraz.VectoCommon.Exceptions;
+using TUGraz.VectoCommon.InputData;
 using TUGraz.VectoCommon.Utils;
 using TUGraz.VectoCore.InputData.Reader.ComponentData;
 using TUGraz.VectoCore.Models.Declaration;
@@ -71,6 +72,10 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen
 		public override PTOData CreatePTOTransmissionData(IPTOTransmissionInputData pto, IGearboxDeclarationInputData gbx)
 		{
 
+			if (gbx == null && pto != null && (pto.PTOTransmissionType != "None")) {
+				throw new VectoException("PTO specified but the vehicle has no gearbox");
+			} 
+				
 			if ((gbx != null) && (pto != null) && (pto.PTOTransmissionType != "None"))
 			{
 				var powerDemand = DeclarationData.PTOTransmission.Lookup(pto.PTOTransmissionType).PowerDemand;
@@ -81,6 +86,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen
 					LossMap = PTOIdleLossMapReader.GetZeroLossMap(),
 				};
 			}
+
 			return null;
 		}
 	}
-- 
GitLab