From e075ab4d37d10bc7b64ca7549ce0ef1870b2225d Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Mon, 13 Jun 2022 10:50:30 +0200
Subject: [PATCH] bugfix saving IHPC transmissions in GUI

---
 Documentation/User Manual/1-user-interface/O_IHPC.md  |  3 +--
 VECTO/GUI/GearboxForm.vb                              | 11 +++++++----
 VECTO/GUI/MainForm.vb                                 |  2 +-
 VECTO/GUI/VectoJobForm.vb                             |  7 +++++--
 VECTO/GUI/VehicleForm.vb                              |  2 +-
 VectoCommon/VectoCommon/Models/GearboxType.cs         |  1 +
 .../VectoCore/Models/Declaration/DeclarationData.cs   |  1 +
 7 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/Documentation/User Manual/1-user-interface/O_IHPC.md b/Documentation/User Manual/1-user-interface/O_IHPC.md
index 10c4093aaf..e7969a7d5e 100644
--- a/Documentation/User Manual/1-user-interface/O_IHPC.md	
+++ b/Documentation/User Manual/1-user-interface/O_IHPC.md	
@@ -7,7 +7,6 @@
 
 Integrated hybrid electric vehicle powertrain component (IHPC) means a combined system of multiple electric machine systems together with the functionality of a multi-speed gearbox.
 
-For an IHPC the 
 
 ### Relative File Paths
 
@@ -22,7 +21,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 defined at the output shaft of the EM. (Engineering mode only)
 
 Gears
 :   Gear ratios of the transmission steps of the IEPC
diff --git a/VECTO/GUI/GearboxForm.vb b/VECTO/GUI/GearboxForm.vb
index 1b87e30a38..3d9d82cfbe 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()) _
+                .Where(Function(type) type.ManualTransmission() OrElse type.AutomaticTransmission() OrElse type = GearboxType.IHPC) _
                 .Select(Function(type) New With {Key .Value = type, .Label = type.GetLabel()}).ToList()
         End If
         DeclInit()
@@ -140,7 +140,7 @@ Public Class GearboxForm
     Private Sub ToolStripBtOpen_Click(sender As Object, e As EventArgs) Handles ToolStripBtOpen.Click
         If GearboxFileBrowser.OpenDialog(_gbxFile) Then
             Try
-                OpenGbx(GearboxFileBrowser.Files(0), VehicleCategory.RigidTruck)
+                OpenGbx(GearboxFileBrowser.Files(0), VehicleCategory.RigidTruck, VectoSimulationJobType.ConventionalVehicle)
             Catch ex As Exception
                 MsgBox("Failed to open Gearbox File: " + ex.Message)
             End Try
@@ -242,7 +242,7 @@ Public Class GearboxForm
     End Sub
 
     'Open file
-    Public Sub OpenGbx(file As String, vehicleCategory As VehicleCategory)
+    Public Sub OpenGbx(file As String, vehicleCategory As VehicleCategory, vehicleJobType As VectoSimulationJobType)
 
         If ChangeCheckCancel() Then Exit Sub
 
@@ -254,6 +254,7 @@ Public Class GearboxForm
 		Dim axlegear As IAxleGearInputData = vehicle.Components.AxleGearInputData
 
         _vehicleCategory = vehicleCategory
+        _vehicleJobType = vehicleJobType
 
         If Cfg.DeclMode <> gearbox.SavedInDeclarationMode Then
             Select Case WrongMode()
@@ -713,6 +714,7 @@ Public Class GearboxForm
 
     Private _contextMenuFiles As String()
     Private _vehicleCategory As VehicleCategory
+    private _vehicleJobType as VectoSimulationJobType
 
     Private Sub OpenFiles(ParamArray files() As String)
 
@@ -1075,7 +1077,8 @@ Public Class GearboxForm
         Dim tmpRunData as VectoRunData = New VectoRunData() With {
             .GearboxData = New GearboxData() with {
                 .Type = CType(CbGStype.SelectedValue, GearboxType)
-            }
+            },
+            .JobType = _vehicleJobType
         }
         Dim tmpStrategy as IShiftPolygonCalculator = PowertrainBuilder.GetShiftStrategy(new SimplePowertrainContainer(tmpRunData))
             
diff --git a/VECTO/GUI/MainForm.vb b/VECTO/GUI/MainForm.vb
index bdfd5b7c74..dcd784a7af 100644
--- a/VECTO/GUI/MainForm.vb
+++ b/VECTO/GUI/MainForm.vb
@@ -405,7 +405,7 @@ Public Class MainForm
                         GearboxForm.BringToFront()
                     End If
                     Try
-                        GearboxForm.OpenGbx(file, VehicleCategory.RigidTruck)
+                        GearboxForm.OpenGbx(file, VehicleCategory.RigidTruck, VectoSimulationJobType.ConventionalVehicle)
                     Catch ex As Exception
                         MsgBox("Failed to open Gearbox File: " + ex.Message)
                     End Try
diff --git a/VECTO/GUI/VectoJobForm.vb b/VECTO/GUI/VectoJobForm.vb
index 667589cdfe..24f05e9953 100644
--- a/VECTO/GUI/VectoJobForm.vb
+++ b/VECTO/GUI/VectoJobForm.vb
@@ -330,19 +330,22 @@ Public Class VectoJobForm
             GearboxForm.BringToFront()
         End If
         Dim vehicleType As VehicleCategory
+        Dim jobType as VectoSimulationJobType
         Try
             If Not Trim(f) = "" Then
-                Dim vehInput As IVehicleDeclarationInputData =
+                Dim vehInput As IVehicleEngineeringInputData =
                         CType(JSONInputDataFactory.ReadComponentData(FileRepl(TbVEH.Text, GetPath(VectoFile))),
                             IEngineeringInputDataProvider).JobInputData.Vehicle
                 vehicleType = vehInput.VehicleCategory
+                jobType = vehInput.VehicleType
             End If
 
         Catch ex As Exception
             vehicleType = VehicleCategory.RigidTruck
+            jobType = VectoSimulationJobType.ConventionalVehicle
         End Try
         Try
-            If Not Trim(f) = "" Then GearboxForm.OpenGbx(f, vehicleType)
+            If Not Trim(f) = "" Then GearboxForm.OpenGbx(f, vehicleType, jobType)
         Catch ex As Exception
             MsgBox("Failed to open Gearbox File: " + ex.Message)
         End Try
diff --git a/VECTO/GUI/VehicleForm.vb b/VECTO/GUI/VehicleForm.vb
index fca9c419a0..f0eeab8f8b 100644
--- a/VECTO/GUI/VehicleForm.vb
+++ b/VECTO/GUI/VehicleForm.vb
@@ -722,7 +722,7 @@ Public Class VehicleForm
 				tcVehicleComponents.TabPages.Remove(tpIEPC)
 
 				gbEMTorqueLimits.Enabled = False
-				gbPropulsionTorque.Enabled = False
+				gbPropulsionTorque.Enabled = True
 
 			    'PTO
 			    gbPTO.Enabled = False
diff --git a/VectoCommon/VectoCommon/Models/GearboxType.cs b/VectoCommon/VectoCommon/Models/GearboxType.cs
index c426a29273..c00d2504d1 100644
--- a/VectoCommon/VectoCommon/Models/GearboxType.cs
+++ b/VectoCommon/VectoCommon/Models/GearboxType.cs
@@ -57,6 +57,7 @@ namespace TUGraz.VectoCommon.Models
 				case GearboxType.ATSerial:     return "Automatic Transmission - Serial (AT-S)"; //todo mk20211210 shouldn't we call it APT-S?
 				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.DrivingCycle: return "Gear from Driving Cycle";
 				default: throw new ArgumentOutOfRangeException("GearboxType", type, null);
 			}
diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs
index e1a1df6060..cebc43f320 100644
--- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs
+++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs
@@ -577,6 +577,7 @@ namespace TUGraz.VectoCore.Models.Declaration
 				switch (type) {
 					case GearboxType.AMT:
 					case GearboxType.APTN:
+					case GearboxType.IHPC:
 						// TODO MQ: 2020-10-14: compute for AMT with ICE and AMT with EM differently
 						return ComputeEfficiencyShiftPolygon(gearIdx, fullLoadCurve, gears, engine, axlegearRatio, dynamicTyreRadius);
 					case GearboxType.MT:
-- 
GitLab