From b9c59515307625fd71336291d44f13faf9956f8d Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Mon, 13 Jun 2022 13:41:29 +0200
Subject: [PATCH] bugfix saving gearbox file for iepc, bugfix busaux parameters
 file fir iepc

---
 Documentation/User Manual/1-user-interface/N_IEPC.md   |  4 ++--
 VECTO/GUI/BusAuxiliariesEngParametersForm.vb           |  9 ++++++++-
 VECTO/GUI/GearboxForm.vb                               |  2 +-
 VECTO/Input Files/BusParamsEngineering.vb              |  2 +-
 VectoCommon/VectoCommon/Models/GearboxType.cs          |  2 ++
 .../VectoCore/InputData/FileIO/JSON/JSONInputData.cs   |  4 +++-
 .../Reader/DataObjectAdapter/EngineeringDataAdapter.cs | 10 ++++++++++
 7 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/Documentation/User Manual/1-user-interface/N_IEPC.md b/Documentation/User Manual/1-user-interface/N_IEPC.md
index 44a780d952..72de151a22 100644
--- a/Documentation/User Manual/1-user-interface/N_IEPC.md	
+++ b/Documentation/User Manual/1-user-interface/N_IEPC.md	
@@ -24,7 +24,7 @@ Make and Model
 :   Free text defining the gearbox model, type, etc.
 
 Inertia \[kgm²\]
-:   Rotational inertia of the gearbox (constant for all gears). (Engineering mode only)
+:   Rotational inertia of the electric machine at the output shaft of the EM. (Engineering mode only)
 
 Gears
 :   Gear ratios of the transmission steps of the IEPC
@@ -48,7 +48,7 @@ Thermal Overload Recovery Factor
 :    The accumulated overload energy has to be below the max. overload capacity multiplied by this factor so that the peak power is available again.
 
 Drag Torque Curve
-:   The motor's drag torque over engine speed when the motor is not energized. The torque values in the drag curve have to be negative. (see [IEPO Drag Curve File (.viepcd)](#iepc-drag-curve-file-.viepcd))
+:   The motor's drag torque over engine speed when the motor is not energized. The torque values in the drag curve have to be negative. (see [IEPC Drag Curve File (.viepcd)](#iepc-drag-curve-file-.viepcd))
 
 Max. Drive and Max. Generation Torque Curve
 :   Torque over engine speed the electric motor can apply on its output shaft. (see [IEPC Max Torque File (.vemp)](#iepc-max-torque-file-.viepcp)). The max drive and max generation torque have to be provided for two different voltage levels.
diff --git a/VECTO/GUI/BusAuxiliariesEngParametersForm.vb b/VECTO/GUI/BusAuxiliariesEngParametersForm.vb
index bfbd54f7b6..3f940a3a26 100644
--- a/VECTO/GUI/BusAuxiliariesEngParametersForm.vb
+++ b/VECTO/GUI/BusAuxiliariesEngParametersForm.vb
@@ -2,6 +2,7 @@
 
 Imports System.IO
 Imports System.Linq
+Imports TUGraz.VECTO.Input_Files
 Imports TUGraz.VectoCommon.InputData
 Imports TUGraz.VectoCommon.Models
 Imports TUGraz.VectoCommon.Utils
@@ -66,6 +67,7 @@ Public Class BusAuxiliariesEngParametersForm
 
         select case JobType
             case VectoSimulationJobType.BatteryElectricVehicle:
+            case VectoSimulationJobType.IEPC_E:
                 bgPneumaticSystem.Enabled = False
                 gbHVAC.Enabled = False
                 cbES_HEVREESS.Checked = True
@@ -262,7 +264,12 @@ Public Class BusAuxiliariesEngParametersForm
         busAuxParams.DCDCEfficiency = tbDCDCEff.Text.ToDouble(0)
         busAuxParams.SupplyESFromHEVREESS = cbES_HEVREESS.Checked
 
-        busAuxParams.PathCompressorMap = tbCompressorMap.Text
+        if (JobType = VectoSimulationJobType.IEPC_E OrElse JobType = VectoSimulationJobType.BatteryElectricVehicle) then
+            busAuxParams.CompressorMap = Nothing
+        Else 
+            busAuxParams.CompressorMap = new SubPath()
+            busAuxParams.PathCompressorMap = tbCompressorMap.Text
+        End If
         busAuxParams.AverageAirDemand = tbAverageAirDemand.Text.ToDouble(0)
         busAuxParams.GearRatio = tbCompressorRatio.Text.ToDouble(0)
         busAuxParams.SmartCompression = cbSmartCompressor.Checked
diff --git a/VECTO/GUI/GearboxForm.vb b/VECTO/GUI/GearboxForm.vb
index 3d9d82cfbe..6f2a770055 100644
--- a/VECTO/GUI/GearboxForm.vb
+++ b/VECTO/GUI/GearboxForm.vb
@@ -89,7 +89,7 @@ Public Class GearboxForm
         Else
             CbGStype.DataSource = [Enum].GetValues(GetType(GearboxType)) _
                 .Cast(Of GearboxType)() _
-                .Where(Function(type) type.ManualTransmission() OrElse type.AutomaticTransmission() OrElse type = GearboxType.IHPC) _
+                .Where(Function(type) type.ManualTransmission() OrElse type.AutomaticTransmission() OrElse type = GearboxType.IHPC OrElse type = GearboxType.IEPC) _
                 .Select(Function(type) New With {Key .Value = type, .Label = type.GetLabel()}).ToList()
         End If
         DeclInit()
diff --git a/VECTO/Input Files/BusParamsEngineering.vb b/VECTO/Input Files/BusParamsEngineering.vb
index cb53823f07..0bebd1d4f9 100644
--- a/VECTO/Input Files/BusParamsEngineering.vb	
+++ b/VECTO/Input Files/BusParamsEngineering.vb	
@@ -72,7 +72,7 @@ Public Class BusAuxEngineeringParams
             writer.SaveBusAuxEngineeringParameters(Me, _filePath, Cfg.DeclMode)
 
         Catch ex As Exception
-            MsgBox("Failed to write Strategy Parameters file: " + ex.Message)
+            MsgBox("Failed to write auxiliary parameters file: " + ex.Message)
             Return False
         End Try
         Return True
diff --git a/VectoCommon/VectoCommon/Models/GearboxType.cs b/VectoCommon/VectoCommon/Models/GearboxType.cs
index c00d2504d1..bedc03bf0a 100644
--- a/VectoCommon/VectoCommon/Models/GearboxType.cs
+++ b/VectoCommon/VectoCommon/Models/GearboxType.cs
@@ -43,6 +43,7 @@ namespace TUGraz.VectoCommon.Models
 		ATPowerSplit,
 		APTN, // Automatic Power Transmission - No Torque Converter
 		IHPC, // Integrated Hybrid Powertrain Component - Transmission part
+		IEPC, // not a real gearbox type, only used for GUI and validation
 		DrivingCycle,
 		NoGearbox
 	}
@@ -58,6 +59,7 @@ namespace TUGraz.VectoCommon.Models
 				case GearboxType.ATPowerSplit: return "Automatic Transmission - PowerSplit (AT-P)";//todo mk20211210 shouldn't we call it APT-P?
 				case GearboxType.APTN:         return "Automatic Transmission - No Torque Converter (APT-N)";
 				case GearboxType.IHPC:         return "IHPC Transmission";
+				case GearboxType.IEPC:         return "IEPC Transmission - dummy entry";
 				case GearboxType.DrivingCycle: return "Gear from Driving Cycle";
 				default: throw new ArgumentOutOfRangeException("GearboxType", type, null);
 			}
diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs
index 366537cc58..83a7e4610f 100644
--- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs
+++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs
@@ -1153,7 +1153,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
 			}
 
 			if (Body[JsonKeys.Vehicle_GearboxFile] != null && !string.IsNullOrWhiteSpace(Body[JsonKeys.Vehicle_GearboxFile].Value<string>())) {
-				AxleGear = ReadGearbox() as IAxleGearInputData;
+				//AxleGear = ReadGearbox() as IAxleGearInputData;
+				Gearbox = ReadGearbox();  // gearbox is not used, but required by GUI
+				AxleGear = Gearbox as IAxleGearInputData;
 			}
 		}
 
diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs
index 570e232cbe..b4099bce71 100644
--- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs
+++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs
@@ -316,6 +316,16 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
 			}
 			retVal.ATEcoRollReleaseLockupClutch = adas != null && adas.EcoRoll != EcoRollType.None && retVal.Type.AutomaticTransmission() ? adas.ATEcoRollReleaseLockupClutch.Value : false;
 
+			if (retVal.Type == GearboxType.IEPC) {
+				if (gearbox.Gears.Count > 0) {
+					throw new VectoSimulationException("No gears are allowed for IEPC gearbox.");
+				}
+
+				retVal.Inertia = 0.SI<KilogramSquareMeter>();
+				retVal.TractionInterruption = 0.SI<Second>();
+				return retVal;
+			}
+
 			//var gears = gearbox.Gears;
 			if (gearbox.Gears.Count < 2) {
 				throw new VectoSimulationException("At least two Gear-Entries must be defined in Gearbox!");
-- 
GitLab