From 6e0a8d9acf9d1d6f054cce1a52db4fb8582ecbb4 Mon Sep 17 00:00:00 2001
From: "VKMTHD\\haraldmartini" <harald.martini@student.tugraz.at>
Date: Wed, 23 Nov 2022 09:46:07 +0100
Subject: [PATCH] added SerialHybridStrategyParameterDataAdapter

---
 .../HybridStrategyParameterDataAdapter.cs     | 75 ++++++++++++++++++-
 1 file changed, 73 insertions(+), 2 deletions(-)

diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/StrategyDataAdapter/HybridStrategyParameterDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/StrategyDataAdapter/HybridStrategyParameterDataAdapter.cs
index 63b4e6b7eb..fe39ffc971 100644
--- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/StrategyDataAdapter/HybridStrategyParameterDataAdapter.cs
+++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/StrategyDataAdapter/HybridStrategyParameterDataAdapter.cs
@@ -1,8 +1,10 @@
 using System;
+using System.Collections.Generic;
 using System.ComponentModel;
 using TUGraz.VectoCommon.Exceptions;
 using TUGraz.VectoCommon.Utils;
 using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.HeavyLorry;
+using TUGraz.VectoCore.Models.Simulation.Data;
 using TUGraz.VectoCore.Models.SimulationComponent.Data;
 using TUGraz.VectoCore.Models.SimulationComponent.Data.Battery;
 using TUGraz.VectoCore.Models.SimulationComponent.Impl;
@@ -54,9 +56,78 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen
 	public class SerialHybridStrategyParameterDataAdapter : HybridStrategyParameters
 	{
 		public HybridStrategyParameters CreateHybridStrategyParameters(BatterySystemData batterySystemData,
-			SuperCapData superCap)
+			SuperCapData superCapData, Kilogram vehicleMass, VectoRunData.OvcHevMode ovcMode)
 		{
-			return new HybridStrategyParameters();
+
+			
+			if (batterySystemData == null && superCapData == null) {
+				return null;
+			}
+
+			if (superCapData != null) {
+				throw new VectoException("Super cap for serial hybrid is not implemented");
+			}
+
+
+		
+			var result = new HybridStrategyParameters();
+			
+			result.AuxReserveTime = null;
+			result.AuxReserveChargeTime = null;
+			result.MinICEOnTime = null;
+			result.GensetMinOptPowerFactor = 0;
+			result.ICEStartPenaltyFactor = double.NaN;
+			result.MaxPropulsionTorque = new Dictionary<GearshiftPosition, VehicleMaxPropulsionTorque>();
+			result.EquivalenceFactorCharge = double.NaN;
+			result.EquivalenceFactorDischarge = double.NaN;
+			result.CostFactorSOCExponent = 5;
+
+			switch (ovcMode) {
+				case VectoRunData.OvcHevMode.NotApplicable:
+					SetGenericParameters(result, batterySystemData, superCapData, vehicleMass);
+					break;
+				case VectoRunData.OvcHevMode.ChargeSustaining:
+					break;
+				case VectoRunData.OvcHevMode.ChargeDepleting:
+					break;
+				default:
+					throw new ArgumentOutOfRangeException(nameof(ovcMode), ovcMode, null);
+			}
+
+			//TODO Move to DeclarationData.Hybridstrategy.Parallel
+
+
+
+			return result;
+
 		}
+
+		private void SetGenericParameters(HybridStrategyParameters result, BatterySystemData batterySystemData,
+			SuperCapData superCapData, Kilogram vehicleMass){
+			var tmpSystem = new BatterySystem(null, batterySystemData);
+			var deltaSoc = CalculatedDeltaSocSHev(vehicleMass, batterySystemData, tmpSystem);
+
+
+			result.MinSoC = tmpSystem.MinSoC + 2 * deltaSoc;
+			result.TargetSoC = tmpSystem.MaxSoC - 5 * deltaSoc;
+			result.MaxSoC = tmpSystem.MaxSoC;
+
+		}
+
+		private double CalculatedDeltaSocSHev(Kilogram vehicleMass, BatterySystemData batterySystemData, BatterySystem tmpSystem)
+		{
+			
+			
+
+			var v_nom = tmpSystem.NominalVoltage;
+			var c_nom = tmpSystem.Capacity;
+			double speedInkmph = 100;
+
+			var result = vehicleMass * speedInkmph.KMPHtoMeterPerSecond() * speedInkmph.KMPHtoMeterPerSecond() / v_nom / c_nom;
+
+			
+			return result.Value();
+		}
+
 	}
 }
\ No newline at end of file
-- 
GitLab