Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Select Git revision
  • 73ae2bb7c2262cfff5e9b904c333b72c8626984c
  • feat/1061_vtp
  • fix/1058_maxwindowsize
  • fix/1065_vehicle_co2_group
  • release/5_0_3
  • prepare/release_5_0_1
  • fix/1067_fchv_conditioning
  • fix/b100_density
  • fix/ngtank_reader_fchv
  • fix/1058_op_point_v5
  • fix/1047_g10_range
  • fix/fchv_adapter_develop
  • feat/1044_add_fuel_b100_single_july
  • feat/1044_add_fuel_b100_single
  • fix/h2_storage_tech
  • amdm3/develop
  • fix/aux_fchv
  • feat/1044_add_fuel_b100
  • fix/fchv_run
  • prepare/5_0_0_rc
  • fix/not_calculate_weights_fchv
  • Release/v4.2.1.3469
  • Release/v0.11.2.3456-DEV
  • Release/v4.2.0.3448-RC
  • Release/v4.1.3.3415
  • Release/v4.1.1.3413
  • Release/v4.1.0.3392-RC
  • Release/v4.0.3.3330
  • Release/v4.0.2.3275
  • Release/v4.0.2.3273
  • Release/v0.11.1.3228-DEV
  • Project_VECTO_FD_II/FMI/HybridController
  • Project_VECTO_FD_II/FMI/AMTShiftStrategy
  • Release/v4.0.1.3217
  • Release/v4.0.0.3211
  • Release/v0.11.0.3193-DEV
  • Release/v4.0.0.3161-RC
  • Release/v4.0.0.3106-RC
  • Release/v3.3.15.3102
  • Release/v4.0.0.3078-RC
  • Release/v3.3.15.3073-RC
41 results

VTPCycleValidationTest.cs

Blame
  • Forked from VECTO / VECTO Sim
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    EngineeringDataAdapter.cs 7.10 KiB
    /*
    * Copyright 2015, 2016 Graz University of Technology,
    * Institute of Internal Combustion Engines and Thermodynamics,
    * Institute of Technical Informatics
    *
    * Licensed under the EUPL (the "Licence");
    * You may not use this work except in compliance with the Licence.
    * You may obtain a copy of the Licence at:
    *
    * http://ec.europa.eu/idabc/eupl
    *
    * Unless required by applicable law or agreed to in writing, software 
    * distributed under the Licence is distributed on an "AS IS" basis,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the Licence for the specific language governing permissions and 
    * limitations under the Licence.
    */
    
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using TUGraz.VectoCore.Exceptions;
    using TUGraz.VectoCore.Models.Declaration;
    using TUGraz.VectoCore.Models.Simulation.Data;
    using TUGraz.VectoCore.Models.SimulationComponent.Data;
    using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine;
    using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox;
    using TUGraz.VectoCore.OutputData;
    using TUGraz.VectoCore.Utils;
    
    namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper
    {
    	public class EngineeringDataAdapter : AbstractSimulationDataAdapter
    	{
    		internal VehicleData CreateVehicleData(IVehicleInputData data)
    		{
    			if (data.SavedInDeclarationMode) {
    				WarnEngineeringMode("VehicleData");
    			}
    
    			var retVal = SetCommonVehicleData(data);
    
    			retVal.CurbWeigthExtra = data.CurbWeightExtra;
    			retVal.Loading = data.Loading;
    			retVal.DynamicTyreRadius = data.DynamicTyreRadius;
    			switch (data.CrossWindCorrectionMode) {
    				case CrossWindCorrectionMode.NoCorrection:
    					retVal.CrossWindCorrectionCurve = CrossWindCorrectionCurve.GetNoCorrectionCurve(data.AirDragArea);
    					break;
    				case CrossWindCorrectionMode.SpeedDependentCorrectionFactor:
    					retVal.CrossWindCorrectionCurve =
    						CrossWindCorrectionCurve.ReadSpeedDependentCorrectionCurve(data.CrosswindCorrectionMap,
    							data.AirDragArea);
    					break;
    				case CrossWindCorrectionMode.VAirBetaLookupTable:
    					throw new VectoException("CrosswindCorrection mode {0} not implemented", data.CrossWindCorrectionMode);
    				case CrossWindCorrectionMode.DeclarationModeCorrection:
    					retVal.CrossWindCorrectionCurve = DeclarationDataAdapter.GetDeclarationAirResistanceCurve(retVal.VehicleCategory,
    						data.AirDragArea);
    					break;
    				default:
    					throw new ArgumentOutOfRangeException();
    			}
    
    
    			var axles = data.Axles;
    			retVal.AxleData = axles.Select(axle => new Axle {
    				WheelsDimension = axle.Wheels,
    				Inertia = axle.Inertia,
    				TwinTyres = axle.TwinTyres,
    				RollResistanceCoefficient = axle.RollResistanceCoefficient,
    				AxleWeightShare = axle.AxleWeightShare,
    				TyreTestLoad = axle.TyreTestLoad,
    				//Wheels = axle.WheelsStr
    			}).ToList();
    			return retVal;
    		}
    
    		private void WarnEngineeringMode(string msg)
    		{
    			Log.Warn("{0} is in Declaration Mode but is used for Engineering Mode!", msg);
    		}
    
    		internal CombustionEngineData CreateEngineData(IEngineInputData engine)
    		{
    			if (engine.SavedInDeclarationMode) {
    				WarnEngineeringMode("EngineData");
    			}
    
    			var retVal = SetCommonCombustionEngineData(engine);
    			retVal.Inertia = engine.Inertia;
    			retVal.FullLoadCurve = EngineFullLoadCurve.Create(engine.FullLoadCurve);
    			retVal.FullLoadCurve.EngineData = retVal;
    			return retVal;
    		}
    
    		internal GearboxData CreateGearboxData(IGearboxInputData gearbox, CombustionEngineData engineData)
    		{
    			if (gearbox.SavedInDeclarationMode) {
    				WarnEngineeringMode("GearboxData");
    			}
    
    			var retVal = SetCommonGearboxData(gearbox);
    
    			var gears = gearbox.Gears;
    			if (gears.Count < 1) {
    				throw new VectoSimulationException(
    					"At least one Gear-Entry must be defined in Gearbox!");
    			}
    
    			retVal.Inertia = gearbox.Inertia;
    			retVal.TractionInterruption = gearbox.TractionInterruption;
    			retVal.SkipGears = gearbox.SkipGears;
    			retVal.EarlyShiftUp = gearbox.EarlyShiftUp;
    			retVal.TorqueReserve = gearbox.TorqueReserve;
    			retVal.StartTorqueReserve = gearbox.StartTorqueReserve;
    			retVal.ShiftTime = gearbox.ShiftTime;
    			retVal.StartSpeed = gearbox.StartSpeed;
    			retVal.StartAcceleration = gearbox.StartAcceleration;
    
    			retVal.HasTorqueConverter = gearbox.TorqueConverter.Enabled;
    
    			//var engineFullLoadCurve = (engineData != null) ? engineData.FullLoadCurve : null;
    
    			retVal.Gears = gears.Select((gear, i) => {
    				var lossMap = TransmissionLossMap.Create(gear.LossMap, gear.Ratio, string.Format("Gear {0}", i + 1));
    				var gearFullLoad = gear.FullLoadCurve != null
    					? FullLoadCurve.Create(gear.FullLoadCurve)
    					: null;
    				var fullLoadCurve = IntersectFullLoadCurves(engineData.FullLoadCurve, gearFullLoad);
    				var shiftPolygon = gear.ShiftPolygon != null
    					? ShiftPolygon.Create(gear.ShiftPolygon)
    					: DeclarationData.Gearbox.ComputeShiftPolygon(fullLoadCurve, engineData.IdleSpeed);
    
    				return new KeyValuePair<uint, GearData>((uint)(i + 1), new GearData {
    					LossMap = lossMap,
    					ShiftPolygon = shiftPolygon,
    					FullLoadCurve = gearFullLoad,
    					Ratio = gear.Ratio,
    					TorqueConverterActive = gear.TorqueConverterActive
    				});
    			}).ToDictionary(kv => kv.Key, kv => kv.Value);
    			return retVal;
    		}
    
    		public IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesInputData auxInputData)
    		{
    			if (auxInputData.SavedInDeclarationMode) {
    				WarnEngineeringMode("AuxData");
    			}
    
    			return auxInputData.Auxiliaries.Select(a => new VectoRunData.AuxData {
    				ID = a.ID,
    				Technology = a.Technology,
    				TechList = a.TechList.DefaultIfNull(Enumerable.Empty<string>()).ToArray(),
    				DemandType = AuxiliaryDemandType.Mapping,
    				Data = new AuxiliaryData(a) //AuxiliaryData.Create(a.DemandMap)
    			}).Concat(new VectoRunData.AuxData { ID = "", DemandType = AuxiliaryDemandType.Direct }.ToEnumerable()).ToList();
    		}
    
    		internal DriverData CreateDriverData(IDriverInputData driver)
    		{
    			if (driver.SavedInDeclarationMode) {
    				WarnEngineeringMode("DriverData");
    			}
    
    			AccelerationCurveData accelerationData = null;
    			if (driver.AccelerationCurve != null) {
    				accelerationData = AccelerationCurveData.Create(driver.AccelerationCurve);
    			}
    
    			var lookAheadData = new DriverData.LACData {
    				Enabled = driver.Lookahead.Enabled,
    				Deceleration = driver.Lookahead.Deceleration,
    				MinSpeed = driver.Lookahead.MinSpeed,
    			};
    			var overspeedData = new DriverData.OverSpeedEcoRollData {
    				Mode = driver.OverSpeedEcoRoll.Mode,
    				MinSpeed = driver.OverSpeedEcoRoll.MinSpeed,
    				OverSpeed = driver.OverSpeedEcoRoll.OverSpeed,
    				UnderSpeed = driver.OverSpeedEcoRoll.UnderSpeed,
    			};
    			var startstopData = new VectoRunData.StartStopData {
    				Enabled = driver.StartStop.Enabled,
    				Delay = driver.StartStop.Delay,
    				MinTime = driver.StartStop.MinTime,
    				MaxSpeed = driver.StartStop.MaxSpeed,
    			};
    			var retVal = new DriverData {
    				AccelerationCurve = accelerationData,
    				LookAheadCoasting = lookAheadData,
    				OverSpeedEcoRoll = overspeedData,
    				StartStop = startstopData,
    			};
    			return retVal;
    		}
    
    		//=================================
    		public RetarderData CreateRetarderData(IRetarderInputData retarder)
    		{
    			return SetCommonRetarderData(retarder);
    		}
    	}
    }