diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterHeavyLorry.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterHeavyLorry.cs deleted file mode 100644 index 9c5ebee30829752db8069630e472d3ef5250cb3c..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterHeavyLorry.cs +++ /dev/null @@ -1,779 +0,0 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2019 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* 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. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology -*/ - -using System; -using System.Collections.Generic; -using System.Linq; -using TUGraz.VectoCommon.BusAuxiliaries; -using TUGraz.VectoCommon.Exceptions; -using TUGraz.VectoCommon.InputData; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Configuration; -using TUGraz.VectoCore.InputData.Reader.ComponentData; -using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC; -using TUGraz.VectoCore.InputData.Reader.ShiftStrategy; -using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumatics; -using TUGraz.VectoCore.Models.Declaration; -using TUGraz.VectoCore.Models.Simulation.Data; -using TUGraz.VectoCore.Models.SimulationComponent; -using TUGraz.VectoCore.Models.SimulationComponent.Data; -using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; -using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; -using TUGraz.VectoCore.Utils; - -namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter -{ - - public class DeclarationDataAdapterHeavyLorry : AbstractSimulationDataAdapter, IDeclarationDataAdapter - { - public static readonly GearboxType[] SupportedGearboxTypes = - { GearboxType.MT, GearboxType.AMT, GearboxType.ATPowerSplit, GearboxType.ATSerial }; - - public virtual DriverData CreateDriverData() - { - var lookAheadData = new DriverData.LACData { - Enabled = DeclarationData.Driver.LookAhead.Enabled, - - //Deceleration = DeclarationData.Driver.LookAhead.Deceleration, - MinSpeed = DeclarationData.Driver.LookAhead.MinimumSpeed, - LookAheadDecisionFactor = new LACDecisionFactor(), - LookAheadDistanceFactor = DeclarationData.Driver.LookAhead.LookAheadDistanceFactor, - }; - var overspeedData = new DriverData.OverSpeedData { - Enabled = true, - MinSpeed = DeclarationData.Driver.OverSpeed.MinSpeed, - OverSpeed = DeclarationData.Driver.OverSpeed.AllowedOverSpeed, - }; - - var retVal = new DriverData { - LookAheadCoasting = lookAheadData, - OverSpeed = overspeedData, - EngineStopStart = new DriverData.EngineStopStartData() { - EngineOffStandStillActivationDelay = DeclarationData.Driver.EngineStopStart.ActivationDelay, - MaxEngineOffTimespan = DeclarationData.Driver.EngineStopStart.MaxEngineOffTimespan, - UtilityFactorStandstill = DeclarationData.Driver.EngineStopStart.UtilityFactor, - UtilityFactorDriving = DeclarationData.Driver.EngineStopStart.UtilityFactor, - }, - EcoRoll = new DriverData.EcoRollData() { - UnderspeedThreshold = DeclarationData.Driver.EcoRoll.UnderspeedThreshold, - MinSpeed = DeclarationData.Driver.EcoRoll.MinSpeed, - ActivationPhaseDuration = DeclarationData.Driver.EcoRoll.ActivationDelay, - AccelerationLowerLimit = DeclarationData.Driver.EcoRoll.AccelerationLowerLimit, - AccelerationUpperLimit = DeclarationData.Driver.EcoRoll.AccelerationUpperLimit, - }, - PCC = new DriverData.PCCData() { - PCCEnableSpeed = DeclarationData.Driver.PCC.PCCEnableSpeed, - MinSpeed = DeclarationData.Driver.PCC.MinSpeed, - PreviewDistanceUseCase1 = DeclarationData.Driver.PCC.PreviewDistanceUseCase1, - PreviewDistanceUseCase2 = DeclarationData.Driver.PCC.PreviewDistanceUseCase2, - UnderSpeed = DeclarationData.Driver.PCC.Underspeed, - OverspeedUseCase3 = DeclarationData.Driver.PCC.OverspeedUseCase3 - } - }; - return retVal; - } - - public virtual VehicleData CreateVehicleData(IVehicleDeclarationInputData data, Segment segment, Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) - { - if (!data.SavedInDeclarationMode) { - WarnDeclarationMode("VehicleData"); - } - return data.ExemptedVehicle - ? CreateExemptedVehicleData(data) - : CreateNonExemptedVehicleData(data, segment, mission, loading.Value.Item1, loading.Value.Item2, allowVocational); - } - - protected virtual VehicleData CreateNonExemptedVehicleData(IVehicleDeclarationInputData data, Segment segment, Mission mission, Kilogram loading, double? passengerCount, bool allowVocational) - { - var retVal = SetCommonVehicleData(data); - retVal.LegislativeClass = data.LegislativeClass; - retVal.AxleConfiguration = data.AxleConfiguration; - retVal.AirDensity = DeclarationData.AirDensity; - retVal.VIN = data.VIN; - retVal.ManufacturerAddress = data.ManufacturerAddress; -// retVal.LegislativeClass = data.LegislativeClass; - retVal.ZeroEmissionVehicle = data.ZeroEmissionVehicle; - retVal.VehicleClass = segment.VehicleClass; - retVal.SleeperCab = retVal.VehicleClass.IsMediumLorry() ? false : data.SleeperCab; - retVal.TrailerGrossVehicleMass = mission.Trailer.Sum(t => t.TrailerGrossVehicleWeight).DefaultIfNull(0); - - retVal.BodyAndTrailerMass = - mission.BodyCurbWeight + mission.Trailer.Sum(t => t.TrailerCurbWeight).DefaultIfNull(0); - - retVal.Loading = loading; - retVal.PassengerCount = passengerCount; - retVal.DynamicTyreRadius = - data.Components.AxleWheels.AxlesDeclaration.Where(axle => axle.AxleType == AxleType.VehicleDriven) - .Select(da => DeclarationData.Wheels.Lookup(da.Tyre.Dimension).DynamicTyreRadius) - .Average(); - if (segment.VehicleClass.IsMediumLorry() && segment.VehicleClass.IsVan()) { - retVal.CargoVolume = data.CargoVolume; - } else { - retVal.CargoVolume = mission.MissionType != MissionType.Construction - ? mission.TotalCargoVolume - : 0.SI<CubicMeter>(); - } - - retVal.VocationalVehicle = allowVocational && data.VocationalVehicle; - retVal.ADAS = CreateADAS(data.ADAS); - - var axles = data.Components.AxleWheels.AxlesDeclaration; - if (axles.Count < mission.AxleWeightDistribution.Length) { - throw new VectoException( - "Vehicle does not contain sufficient axles. {0} axles defined, {1} axles required", - axles.Count, mission.AxleWeightDistribution.Length); - } - - var axleData = new List<Axle>(); - for (var i = 0; i < mission.AxleWeightDistribution.Length; i++) { - var axleInput = axles[i]; - var axle = new Axle { - WheelsDimension = axleInput.Tyre.Dimension, - AxleType = axleInput.AxleType, - AxleWeightShare = mission.AxleWeightDistribution[i], - TwinTyres = axleInput.TwinTyres, - RollResistanceCoefficient = axleInput.Tyre.RollResistanceCoefficient, - TyreTestLoad = axleInput.Tyre.TyreTestLoad, - FuelEfficiencyClass = axleInput.Tyre.FuelEfficiencyClass, - Inertia = DeclarationData.Wheels.Lookup(axleInput.Tyre.Dimension.RemoveWhitespace()).Inertia, - CertificationNumber = axleInput.Tyre.CertificationNumber, - DigestValueInput = axleInput.Tyre.DigestValue == null ? "" : axleInput.Tyre.DigestValue.DigestValue, - }; - axleData.Add(axle); - } - - foreach (var trailer in mission.Trailer) { - axleData.AddRange( - trailer.TrailerWheels.Select( - trailerWheel => new Axle { - AxleType = AxleType.Trailer, - AxleWeightShare = trailer.TrailerAxleWeightShare / trailer.TrailerWheels.Count, - TwinTyres = DeclarationData.Trailer.TwinTyres, - RollResistanceCoefficient = DeclarationData.Trailer.RollResistanceCoefficient, - TyreTestLoad = DeclarationData.Trailer.TyreTestLoad.SI<Newton>(), - FuelEfficiencyClass = DeclarationData.Trailer.FuelEfficiencyClass, - Inertia = trailerWheel.Inertia, - WheelsDimension = trailerWheel.WheelType - })); - } - - retVal.AxleData = axleData; - return retVal; - } - - - protected virtual VehicleData CreateExemptedVehicleData(IVehicleDeclarationInputData data) - { - var exempted = SetCommonVehicleData(data); - exempted.VIN = data.VIN; - exempted.ManufacturerAddress = data.ManufacturerAddress; - exempted.LegislativeClass = data.LegislativeClass; - exempted.ZeroEmissionVehicle = data.ZeroEmissionVehicle; - exempted.HybridElectricHDV = data.HybridElectricHDV; - exempted.DualFuelVehicle = data.DualFuelVehicle; - exempted.MaxNetPower1 = data.MaxNetPower1; - exempted.MaxNetPower2 = data.MaxNetPower2; - return exempted; - } - - - public virtual CombustionEngineData CreateEngineData( - IVehicleDeclarationInputData vehicle, IEngineModeDeclarationInputData mode, Mission mission) - { - var engine = vehicle.Components.EngineInputData; - var gearbox = vehicle.Components.GearboxInputData; - - if (!engine.SavedInDeclarationMode) { - WarnDeclarationMode("EngineData"); - } - - var retVal = SetCommonCombustionEngineData(engine, vehicle.TankSystem); - retVal.IdleSpeed = VectoMath.Max(mode.IdleSpeed, vehicle.EngineIdleSpeed); - - retVal.Fuels = new List<CombustionEngineFuelData>(); - foreach (var fuel in mode.Fuels) { - retVal.Fuels.Add( - new CombustionEngineFuelData() { - WHTCUrban = fuel.WHTCUrban, - WHTCRural = fuel.WHTCRural, - WHTCMotorway = fuel.WHTCMotorway, - ColdHotCorrectionFactor = fuel.ColdHotBalancingFactor, - CorrectionFactorRegPer = fuel.CorrectionFactorRegPer, - FuelData = DeclarationData.FuelData.Lookup(fuel.FuelType, vehicle.TankSystem), - ConsumptionMap = FuelConsumptionMapReader.Create(fuel.FuelConsumptionMap), - FuelConsumptionCorrectionFactor = DeclarationData.WHTCCorrection.Lookup( - mission.MissionType.GetNonEMSMissionType(), fuel.WHTCRural, fuel.WHTCUrban, - fuel.WHTCMotorway) * fuel.ColdHotBalancingFactor * fuel.CorrectionFactorRegPer, - }); - } - - retVal.Inertia = DeclarationData.Engine.EngineInertia(retVal.Displacement, gearbox.Type); - retVal.EngineStartTime = DeclarationData.Engine.DefaultEngineStartTime; - var limits = vehicle.TorqueLimits?.ToDictionary(e => e.Gear) ?? new Dictionary<int, ITorqueLimitInputData>(); - var numGears = gearbox.Gears.Count; - var fullLoadCurves = new Dictionary<uint, EngineFullLoadCurve>(numGears + 1); - fullLoadCurves[0] = FullLoadCurveReader.Create(mode.FullLoadCurve, true); - fullLoadCurves[0].EngineData = retVal; - foreach (var gear in gearbox.Gears) { - var maxTorque = VectoMath.Min( - GbxMaxTorque(gear, numGears, fullLoadCurves[0].MaxTorque), - VehMaxTorque(gear, numGears, limits, fullLoadCurves[0].MaxTorque)); - fullLoadCurves[(uint)gear.Gear] = IntersectFullLoadCurves(fullLoadCurves[0], maxTorque); - } - - retVal.FullLoadCurves = fullLoadCurves; - - retVal.WHRType = engine.WHRType; - if ((retVal.WHRType & WHRType.ElectricalOutput) != 0) { - retVal.ElectricalWHR = CreateWHRData( - mode.WasteHeatRecoveryDataElectrical, mission.MissionType, WHRType.ElectricalOutput); - } - if ((retVal.WHRType & WHRType.MechanicalOutputDrivetrain) != 0) { - retVal.MechanicalWHR = CreateWHRData( - mode.WasteHeatRecoveryDataMechanical, mission.MissionType, WHRType.MechanicalOutputDrivetrain); - } - - return retVal; - } - - protected static WHRData CreateWHRData(IWHRData whrInputData, MissionType missionType, WHRType type) - { - if (whrInputData == null || whrInputData.GeneratedPower == null) { - throw new VectoException("Missing WHR Data"); - } - - var whr = new WHRData() { - CFUrban = whrInputData.UrbanCorrectionFactor, - CFRural = whrInputData.RuralCorrectionFactor, - CFMotorway = whrInputData.MotorwayCorrectionFactor, - CFColdHot = whrInputData.BFColdHot, - CFRegPer = whrInputData.CFRegPer, - WHRMap = WHRPowerReader.Create(whrInputData.GeneratedPower, type) - }; - whr.WHRCorrectionFactor = DeclarationData.WHTCCorrection.Lookup( - missionType.GetNonEMSMissionType(), whr.CFRural, whr.CFUrban, - whr.CFMotorway) * whr.CFColdHot * whr.CFRegPer; - return whr; - } - - protected internal static NewtonMeter VehMaxTorque( - ITransmissionInputData gear, int numGears, - Dictionary<int, ITorqueLimitInputData> limits, - NewtonMeter maxEngineTorque) - { - if (gear.Gear - 1 >= numGears / 2) { - // only upper half of gears can limit if max-torque <= 0.95 of engine max torque - if (limits.TryGetValue(gear.Gear, out var limit) && limit.MaxTorque <= DeclarationData.Engine.TorqueLimitVehicleFactor * maxEngineTorque) { - return limit.MaxTorque; - } - } - - return null; - } - - protected internal static NewtonMeter GbxMaxTorque( - ITransmissionInputData gear, int numGears, NewtonMeter maxEngineTorque - ) - { - if (gear.Gear - 1 < numGears / 2) { - // gears count from 1 to n, -> n entries, lower half can always limit - if (gear.MaxTorque != null) { - return gear.MaxTorque; - } - } else { - // upper half can only limit if max-torque <= 90% of engine max torque - if (gear.MaxTorque != null && gear.MaxTorque <= DeclarationData.Engine.TorqueLimitGearboxFactor * maxEngineTorque) { - return gear.MaxTorque; - } - } - - return null; - } - - public virtual GearboxData CreateGearboxData(IVehicleDeclarationInputData inputData, VectoRunData runData, - IShiftPolygonCalculator shiftPolygonCalc) - { - if (!inputData.Components.GearboxInputData.SavedInDeclarationMode) { - WarnDeclarationMode("GearboxData"); - } - return DoCreateGearboxData(inputData, runData, shiftPolygonCalc); - } - - public virtual GearboxData DoCreateGearboxData(IVehicleDeclarationInputData inputData, VectoRunData runData, - IShiftPolygonCalculator shiftPolygonCalc) - { - var gearbox = inputData.Components.GearboxInputData; - - var adas = inputData.ADAS; - var torqueConverter = inputData.Components.TorqueConverterInputData; - - var engine = runData.EngineData; - var axlegearRatio = runData.AxleGearData.AxleGear.Ratio; - var dynamicTyreRadius = runData.VehicleData.DynamicTyreRadius; - - var retVal = SetCommonGearboxData(gearbox); - - //if (adas != null && retVal.Type.AutomaticTransmission() && adas.EcoRoll != EcoRollType.None && - // !adas.ATEcoRollReleaseLockupClutch.HasValue) { - // throw new VectoException("Input parameter ATEcoRollReleaseLockupClutch required for AT transmission"); - //} - - retVal.ATEcoRollReleaseLockupClutch = - adas != null && adas.EcoRoll != EcoRollType.None && retVal.Type.AutomaticTransmission() - ? (adas.ATEcoRollReleaseLockupClutch.HasValue ? adas.ATEcoRollReleaseLockupClutch.Value : false) - : false; - - if (!SupportedGearboxTypes.Contains(gearbox.Type)) { - throw new VectoSimulationException("Unsupported gearbox type: {0}!", retVal.Type); - } - - var gearsInput = gearbox.Gears; - if (gearsInput.Count < 1) { - throw new VectoSimulationException( - "At least one Gear-Entry must be defined in Gearbox!"); - } - - SetDeclarationData(retVal); - - var gearDifferenceRatio = gearbox.Type.AutomaticTransmission() && gearbox.Gears.Count > 2 - ? gearbox.Gears[0].Ratio / gearbox.Gears[1].Ratio - : 1.0; - - var gears = new Dictionary<uint, GearData>(); - var tcShiftPolygon = DeclarationData.TorqueConverter.ComputeShiftPolygon(engine.FullLoadCurves[0]); - var vehicleCategory = runData.VehicleData.VehicleCategory == VehicleCategory.GenericBusVehicle - ? VehicleCategory.GenericBusVehicle - : inputData.VehicleCategory; - for (uint i = 0; i < gearsInput.Count; i++) { - var gear = gearsInput[(int)i]; - var lossMap = CreateGearLossMap(gear, i, false, vehicleCategory, gearbox.Type); - - var shiftPolygon = shiftPolygonCalc != null - ? shiftPolygonCalc.ComputeDeclarationShiftPolygon( - gearbox.Type, (int)i, engine.FullLoadCurves[i + 1], gearbox.Gears, engine, axlegearRatio, dynamicTyreRadius) - : DeclarationData.Gearbox.ComputeShiftPolygon( - gearbox.Type, (int)i, engine.FullLoadCurves[i + 1], - gearsInput, engine, - axlegearRatio, dynamicTyreRadius, null); - - var gearData = new GearData { - ShiftPolygon = shiftPolygon, - MaxSpeed = gear.MaxInputSpeed, - MaxTorque = gear.MaxTorque, - Ratio = gear.Ratio, - LossMap = lossMap, - }; - - CreateATGearData(gearbox, i, gearData, tcShiftPolygon, gearDifferenceRatio, gears, runData.VehicleData.VehicleCategory); - gears.Add(i + 1, gearData); - } - - // remove disabled gears (only the last or last two gears may be removed) - if (inputData.TorqueLimits != null) { - var toRemove = (from tqLimit in inputData.TorqueLimits where tqLimit.Gear >= gears.Keys.Max() - 1 && tqLimit.MaxTorque.IsEqual(0) select (uint)tqLimit.Gear).ToList(); - if (toRemove.Count > 0 && toRemove.Min() <= gears.Count - toRemove.Count) { - throw new VectoException("Only the last 1 or 2 gears can be disabled. Disabling gear {0} for a {1}-speed gearbox is not allowed.", toRemove.Min(), gears.Count); - } - - foreach (var entry in toRemove) { - gears.Remove(entry); - } - } - - retVal.Gears = gears; - if (retVal.Type.AutomaticTransmission()) { - var ratio = double.IsNaN(retVal.Gears[1].Ratio) ? 1 : retVal.Gears[1].TorqueConverterRatio / retVal.Gears[1].Ratio; - retVal.PowershiftShiftTime = DeclarationData.Gearbox.PowershiftShiftTime; - - retVal.TorqueConverterData = CreateTorqueConverterData(gearbox.Type, torqueConverter, ratio, engine); - - if (torqueConverter != null) { - retVal.TorqueConverterData.Manufacturer = torqueConverter.Manufacturer; - retVal.TorqueConverterData.ModelName = torqueConverter.Model; - retVal.TorqueConverterData.DigestValueInput = torqueConverter.DigestValue?.DigestValue; - retVal.TorqueConverterData.CertificationMethod = torqueConverter.CertificationMethod; - retVal.TorqueConverterData.CertificationNumber = torqueConverter.CertificationNumber; - retVal.TorqueConverterData.Date = torqueConverter.Date; - retVal.TorqueConverterData.AppVersion = torqueConverter.AppVersion; - } - } - - // update disengageWhenHaltingSpeed - if (retVal.Type.AutomaticTransmission()) { - var firstGear = retVal.GearList.First(x => x.IsLockedGear()); - if (retVal.Gears[firstGear.Gear].ShiftPolygon.Downshift.Any()) { - var downshiftSpeedInc = retVal.Gears[firstGear.Gear].ShiftPolygon - .InterpolateDownshiftSpeed(0.SI<NewtonMeter>()) * 1.05; - var vehicleSpeedDisengage = downshiftSpeedInc / axlegearRatio / retVal.Gears[firstGear.Gear].Ratio * - dynamicTyreRadius; - retVal.DisengageWhenHaltingSpeed = vehicleSpeedDisengage; - } - } - - return retVal; - } - - protected virtual TorqueConverterData CreateTorqueConverterData(GearboxType gearboxType, - ITorqueConverterDeclarationInputData torqueConverter, double ratio, - CombustionEngineData componentsEngineInputData) - { - return TorqueConverterDataReader.Create( - torqueConverter.TCData, - DeclarationData.TorqueConverter.ReferenceRPM, DeclarationData.TorqueConverter.MaxInputSpeed, - ExecutionMode.Declaration, ratio, - DeclarationData.TorqueConverter.CLUpshiftMinAcceleration, - DeclarationData.TorqueConverter.CCUpshiftMinAcceleration); - } - - protected virtual void CreateATGearData( - IGearboxDeclarationInputData gearbox, uint i, GearData gearData, - ShiftPolygon tcShiftPolygon, double gearDifferenceRatio, Dictionary<uint, GearData> gears, - VehicleCategory vehicleCategory) - { - if (gearbox.Type == GearboxType.ATPowerSplit && i == 0) { - // powersplit transmission: torque converter already contains ratio and losses - CretateTCFirstGearATPowerSplit(gearData, i, tcShiftPolygon); - } - if (gearbox.Type == GearboxType.ATSerial) { - if (i == 0) { - // torqueconverter is active in first gear - duplicate ratio and lossmap for torque converter mode - CreateTCFirstGearATSerial(gearData, tcShiftPolygon); - } - if (i == 1 && gearDifferenceRatio >= DeclarationData.Gearbox.TorqueConverterSecondGearThreshold(vehicleCategory)) { - // ratio between first and second gear is above threshold, torqueconverter is active in second gear as well - // -> duplicate ratio and lossmap for torque converter mode, remove locked transmission for previous gear - CreateTCSecondGearATSerial(gearData, tcShiftPolygon); - - // NOTE: the lower gear in 'gears' dictionary has index i !! - gears[i].Ratio = double.NaN; - gears[i].LossMap = null; - } - } - } - - private static void SetDeclarationData(GearboxData retVal) - { - retVal.Inertia = DeclarationData.Gearbox.Inertia; - retVal.TractionInterruption = retVal.Type.TractionInterruption(); - - } - - public virtual AxleGearData CreateAxleGearData(IAxleGearInputData data) - { - var retVal = SetCommonAxleGearData(data); - retVal.AxleGear.LossMap = ReadAxleLossMap(data, false); - return retVal; - } - - public virtual AngledriveData CreateAngledriveData(IAngledriveInputData data) - { - return DoCreateAngledriveData(data, false); - } - - - public virtual IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxInputData, - IBusAuxiliariesDeclarationData busAuxData, MissionType mission, VehicleClass hvdClass, Meter vehicleLength, int? numSteeredAxles) - { - if (!auxInputData.SavedInDeclarationMode) { - WarnDeclarationMode("AuxiliariesData"); - } - var retVal = new List<VectoRunData.AuxData>(); - - if (auxInputData.Auxiliaries.Count != 5) { - Log.Error( - "In Declaration Mode exactly 5 Auxiliaries must be defined: Fan, Steering pump, HVAC, Electric System, Pneumatic System."); - throw new VectoException( - "In Declaration Mode exactly 5 Auxiliaries must be defined: Fan, Steering pump, HVAC, Electric System, Pneumatic System."); - } - - foreach (var auxType in EnumHelper.GetValues<AuxiliaryType>()) { - var auxData = auxInputData.Auxiliaries.FirstOrDefault(a => a.Type == auxType); - if (auxData == null) { - throw new VectoException("Auxiliary {0} not found.", auxType); - } - - var aux = new VectoRunData.AuxData { - DemandType = AuxiliaryDemandType.Constant, - Technology = auxData.Technology - }; - - mission = mission.GetNonEMSMissionType(); - switch (auxType) { - case AuxiliaryType.Fan: - aux.PowerDemand = DeclarationData.Fan.LookupPowerDemand(hvdClass, mission, auxData.Technology.FirstOrDefault()); - aux.ID = Constants.Auxiliaries.IDs.Fan; - break; - case AuxiliaryType.SteeringPump: - if (numSteeredAxles.HasValue && auxData.Technology.Count != numSteeredAxles.Value) { - throw new VectoException($"Number of steering pump technologies does not match number of steered axles ({numSteeredAxles.Value}, {auxData.Technology.Count})"); - } - aux.PowerDemand = DeclarationData.SteeringPump.Lookup(mission, hvdClass, auxData.Technology); - aux.ID = Constants.Auxiliaries.IDs.SteeringPump; - break; - case AuxiliaryType.HVAC: - aux.PowerDemand = DeclarationData.HeatingVentilationAirConditioning.Lookup( - mission, - auxData.Technology.FirstOrDefault(), hvdClass).PowerDemand; - aux.ID = Constants.Auxiliaries.IDs.HeatingVentilationAirCondition; - break; - case AuxiliaryType.PneumaticSystem: - aux.PowerDemand = DeclarationData.PneumaticSystem.Lookup(mission, auxData.Technology.FirstOrDefault()) - .PowerDemand; - aux.ID = Constants.Auxiliaries.IDs.PneumaticSystem; - break; - case AuxiliaryType.ElectricSystem: - aux.PowerDemand = DeclarationData.ElectricSystem.Lookup(mission, auxData.Technology.FirstOrDefault()).PowerDemand; - aux.ID = Constants.Auxiliaries.IDs.ElectricSystem; - break; - default: continue; - } - - retVal.Add(aux); - } - - return retVal; - } - - public AxleGearData CreateDummyAxleGearData(IGearboxDeclarationInputData gbxData) - { - if (double.IsNaN(gbxData.AxlegearRatio)) { - throw new VectoException("Axlegear ratio required in gearbox data for gearboxes with included axlegear"); - } - return new AxleGearData() { - AxleGear = new TransmissionData() { - Ratio = gbxData.AxlegearRatio, - LossMap = TransmissionLossMapReader.Create(1.0, gbxData.AxlegearRatio, "Axlegear") - } - }; - } - - protected void WarnDeclarationMode(string inputData) - { - Log.Warn("{0} not in Declaration Mode!", inputData); - } - - public virtual RetarderData CreateRetarderData(IRetarderInputData retarder) - { - return SetCommonRetarderData(retarder); - } - - public static List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> GetDeclarationAirResistanceCurve( - string crosswindCorrectionParameters, SquareMeter aerodynamicDragAera, Meter vehicleHeight) - { - var startSpeed = Constants.SimulationSettings.CrosswindCorrection.MinVehicleSpeed; - var maxSpeed = Constants.SimulationSettings.CrosswindCorrection.MaxVehicleSpeed; - var speedStep = Constants.SimulationSettings.CrosswindCorrection.VehicleSpeedStep; - - var maxAlpha = Constants.SimulationSettings.CrosswindCorrection.MaxAlpha; - var alphaStep = Constants.SimulationSettings.CrosswindCorrection.AlphaStep; - - var startHeightPercent = Constants.SimulationSettings.CrosswindCorrection.MinHeight; - var maxHeightPercent = Constants.SimulationSettings.CrosswindCorrection.MaxHeight; - var heightPercentStep = Constants.SimulationSettings.CrosswindCorrection.HeightStep; - var heightShare = (double)heightPercentStep / maxHeightPercent; - - var values = DeclarationData.AirDrag.Lookup(crosswindCorrectionParameters); - - // first entry (0m/s) will get CdxA of second entry. - var points = new List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> { - new CrossWindCorrectionCurveReader.CrossWindCorrectionEntry { - Velocity = 0.SI<MeterPerSecond>(), - EffectiveCrossSectionArea = 0.SI<SquareMeter>() - } - }; - - for (var speed = startSpeed; speed <= maxSpeed; speed += speedStep) { - var vVeh = speed.KMPHtoMeterPerSecond(); - - var cdASum = 0.SI<SquareMeter>(); - - for (var heightPercent = startHeightPercent; heightPercent < maxHeightPercent; heightPercent += heightPercentStep) { - var height = heightPercent / 100.0 * vehicleHeight; - var vWind = Physics.BaseWindSpeed * Math.Pow(height / Physics.BaseWindHeight, Physics.HellmannExponent); - - for (var alpha = 0; alpha <= maxAlpha; alpha += alphaStep) { - var vAirX = vVeh + vWind * Math.Cos(alpha.ToRadian()); - var vAirY = vWind * Math.Sin(alpha.ToRadian()); - - var beta = Math.Atan(vAirY / vAirX).ToDegree(); - - // ΔCdxA = A1β + A2β² + A3β³ - var deltaCdA = values.A1 * beta + values.A2 * beta * beta + values.A3 * beta * beta * beta; - - // CdxA(β) = CdxA(0) + ΔCdxA(β) - var cdA = aerodynamicDragAera + deltaCdA; - - var share = (alpha == 0 || alpha == maxAlpha ? alphaStep / 2.0 : alphaStep) / maxAlpha; - - // v_air = sqrt(v_airX²+vAirY²) - // cdASum = CdxA(β) * v_air²/v_veh² - cdASum += heightShare * share * cdA * (vAirX * vAirX + vAirY * vAirY) / (vVeh * vVeh); - } - } - - points.Add( - new CrossWindCorrectionCurveReader.CrossWindCorrectionEntry { - Velocity = vVeh, - EffectiveCrossSectionArea = cdASum - }); - } - - points[0].EffectiveCrossSectionArea = points[1].EffectiveCrossSectionArea; - return points; - } - - public virtual PTOData CreatePTOTransmissionData(IPTOTransmissionInputData pto) - { - if (pto != null && pto.PTOTransmissionType != "None") { - return new PTOData { - TransmissionType = pto.PTOTransmissionType, - LossMap = PTOIdleLossMapReader.GetZeroLossMap(), - }; - } - - return null; - } - - public virtual AirdragData CreateAirdragData( - IAirdragDeclarationInputData airdragInputData, Mission mission, - Segment segment) - { - if (airdragInputData == null || airdragInputData.AirDragArea == null) { - return DefaultAirdragData(mission); - } - - var retVal = SetCommonAirdragData(airdragInputData); - retVal.CrossWindCorrectionMode = CrossWindCorrectionMode.DeclarationModeCorrection; - retVal.DeclaredAirdragArea = mission.MissionType == MissionType.Construction - ? mission.DefaultCDxA - : airdragInputData.AirDragArea; - - var aerodynamicDragArea = retVal.DeclaredAirdragArea + mission.Trailer.Sum(t => t.DeltaCdA).DefaultIfNull(0); - - retVal.CrossWindCorrectionCurve = - new CrosswindCorrectionCdxALookup( - aerodynamicDragArea, - GetDeclarationAirResistanceCurve( - mission.CrossWindCorrectionParameters, aerodynamicDragArea, mission.VehicleHeight), - CrossWindCorrectionMode.DeclarationModeCorrection); - return retVal; - } - - protected virtual AirdragData DefaultAirdragData(Mission mission) - { - var aerodynamicDragArea = mission.DefaultCDxA + mission.Trailer.Sum(t => t.DeltaCdA).DefaultIfNull(0); - - return new AirdragData() { - CertificationMethod = CertificationMethod.StandardValues, - CrossWindCorrectionMode = CrossWindCorrectionMode.DeclarationModeCorrection, - DeclaredAirdragArea = mission.DefaultCDxA, - CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup( - aerodynamicDragArea, - GetDeclarationAirResistanceCurve( - mission.CrossWindCorrectionParameters, aerodynamicDragArea, mission.VehicleHeight), - CrossWindCorrectionMode.DeclarationModeCorrection) - }; - } - - public virtual ShiftStrategyParameters CreateGearshiftData(GearboxData gbx, double axleRatio, PerSecond engineIdlingSpeed) - { - var retVal = new ShiftStrategyParameters { - TorqueReserve = DeclarationData.GearboxTCU.TorqueReserve, - StartTorqueReserve = DeclarationData.GearboxTCU.TorqueReserveStart, - TimeBetweenGearshifts = DeclarationData.Gearbox.MinTimeBetweenGearshifts, - StartSpeed = DeclarationData.GearboxTCU.StartSpeed, - StartAcceleration = DeclarationData.GearboxTCU.StartAcceleration, - DownshiftAfterUpshiftDelay = DeclarationData.Gearbox.DownshiftAfterUpshiftDelay, - UpshiftAfterDownshiftDelay = DeclarationData.Gearbox.UpshiftAfterDownshiftDelay, - UpshiftMinAcceleration = DeclarationData.Gearbox.UpshiftMinAcceleration, - - StartVelocity = DeclarationData.GearboxTCU.StartSpeed, - GearResidenceTime = DeclarationData.GearboxTCU.GearResidenceTime, - DnT99L_highMin1 = DeclarationData.GearboxTCU.DnT99L_highMin1, - DnT99L_highMin2 = DeclarationData.GearboxTCU.DnT99L_highMin2, - AllowedGearRangeUp = DeclarationData.GearboxTCU.AllowedGearRangeUp, - AllowedGearRangeDown = DeclarationData.GearboxTCU.AllowedGearRangeDown, - LookBackInterval = DeclarationData.GearboxTCU.LookBackInterval, - DriverAccelerationLookBackInterval = DeclarationData.GearboxTCU.DriverAccelerationLookBackInterval, - DriverAccelerationThresholdLow = DeclarationData.GearboxTCU.DriverAccelerationThresholdLow, - AverageCardanPowerThresholdPropulsion = DeclarationData.GearboxTCU.AverageCardanPowerThresholdPropulsion, - CurrentCardanPowerThresholdPropulsion = DeclarationData.GearboxTCU.CurrentCardanPowerThresholdPropulsion, - TargetSpeedDeviationFactor = DeclarationData.GearboxTCU.TargetSpeedDeviationFactor, - EngineSpeedHighDriveOffFactor = DeclarationData.GearboxTCU.EngineSpeedHighDriveOffFactor, - RatingFactorCurrentGear = gbx.Type.AutomaticTransmission() - ? DeclarationData.GearboxTCU.RatingFactorCurrentGearAT - : DeclarationData.GearboxTCU.RatingFactorCurrentGear, - AccelerationReserveLookup = AccelerationReserveLookupReader.ReadFromStream( - RessourceHelper.ReadStream( - DeclarationData.DeclarationDataResourcePrefix + ".GearshiftParameters.AccelerationReserveLookup.csv")), - ShareTorque99L = ShareTorque99lLookupReader.ReadFromStream( - RessourceHelper.ReadStream( - DeclarationData.DeclarationDataResourcePrefix + ".GearshiftParameters.ShareTq99L.csv") - ), - PredictionDurationLookup = PredictionDurationLookupReader.ReadFromStream( - RessourceHelper.ReadStream( - DeclarationData.DeclarationDataResourcePrefix + ".GearshiftParameters.PredictionTimeLookup.csv") - ), - ShareIdleLow = ShareIdleLowReader.ReadFromStream( - RessourceHelper.ReadStream( - DeclarationData.DeclarationDataResourcePrefix + ".GearshiftParameters.ShareIdleLow.csv") - ), - ShareEngineHigh = EngineSpeedHighLookupReader.ReadFromStream( - RessourceHelper.ReadStream( - DeclarationData.DeclarationDataResourcePrefix + ".GearshiftParameters.ShareEngineSpeedHigh.csv") - ), - - //-------------------- - RatioEarlyUpshiftFC = DeclarationData.GearboxTCU.RatioEarlyUpshiftFC / axleRatio, - RatioEarlyDownshiftFC = DeclarationData.GearboxTCU.RatioEarlyDownshiftFC / axleRatio, - AllowedGearRangeFC = gbx.Type.AutomaticTransmission() - ? (gbx.Gears.Count > DeclarationData.GearboxTCU.ATSkipGearsThreshold - ? DeclarationData.GearboxTCU.AllowedGearRangeFCATSkipGear - : DeclarationData.GearboxTCU.AllowedGearRangeFCAT) - : DeclarationData.GearboxTCU.AllowedGearRangeFCAMT, - VelocityDropFactor = DeclarationData.GearboxTCU.VelocityDropFactor, - AccelerationFactor = DeclarationData.GearboxTCU.AccelerationFactor, - MinEngineSpeedPostUpshift = 0.RPMtoRad(), - ATLookAheadTime = DeclarationData.GearboxTCU.ATLookAheadTime, - - LoadStageThresoldsUp = DeclarationData.GearboxTCU.LoadStageThresholdsUp, - LoadStageThresoldsDown = DeclarationData.GearboxTCU.LoadStageThresoldsDown, - ShiftSpeedsTCToLocked = DeclarationData.GearboxTCU.ShiftSpeedsTCToLocked - .Select(x => x.Select(y => y + engineIdlingSpeed.AsRPM).ToArray()).ToArray(), - }; - - return retVal; - } - - - } -} diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterNinjectModule.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterNinjectModule.cs new file mode 100644 index 0000000000000000000000000000000000000000..08425cda422aa686f17033bbcac53cc397d33b81 --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterNinjectModule.cs @@ -0,0 +1,60 @@ +using TUGraz.VectoCore.InputData.Reader.Impl; +using TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDataFactory; + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public class DeclarationDataAdapterNinjectModule : AbstractNinjectModule + { + #region Overrides of NinjectModule + + public override void Load() + { + #region HeavyLorry + Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.Conventional>() + .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.Conventional>(); + + Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_S2>() + .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_S2>(); + + Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_S3>() + .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_S3>(); + + Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_S4>() + .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_S4>(); + + Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_S_IEPC>() + .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_S_IEPC>(); + + Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_P1>() + .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_P1>(); + + Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_P2>() + .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_P2>(); + + Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_P2_5>() + .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_P2_5>(); + + Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_P3>() + .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_P3>(); + + Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_P4>() + .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_P4>(); + + Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.PEV_E2>() + .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.PEV_E2>(); + + Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.PEV_E3>() + .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.PEV_E3>(); + + Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.PEV_E4>() + .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.PEV_E4>(); + + Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.PEV_E_IEPC>() + .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.PEV_E_IEPC>(); + #endregion HeavyLorry + } + + #endregion + } +} + diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs index 395d9e9d5bc8f29fea0e097e2302c7f905f57cb0..9067d8cca2f8b3c1afafdb6efd0ec35dbf48957b 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs @@ -19,7 +19,7 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter { - public class DeclarationDataAdapterPrimaryBus : DeclarationDataAdapterHeavyLorry + public class DeclarationDataAdapterPrimaryBus : DeclarationDataAdapterHeavyLorry.Conventional { #region Overrides of DeclarationDataAdapterHeavyLorry diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs index cc5641aa7a050e65bff2fffad14d9d7564a23dff..e5fb7b2d7584413d9cc16359757577620d62bde8 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs @@ -145,7 +145,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter : 4.SI<Meter>()); retVal.CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup( airDragArea, - DeclarationDataAdapterHeavyLorry.GetDeclarationAirResistanceCurve( + DeclarationDataAdapterHeavyLorry.Conventional.GetDeclarationAirResistanceCurve( GetAirdragParameterSet( data.VehicleCategory, data.AxleConfiguration, data.Components.AxleWheels.AxlesEngineering.Count, data.GrossVehicleMassRating), airDragArea, height), diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/Conventional.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/Conventional.cs new file mode 100644 index 0000000000000000000000000000000000000000..0b8b2a0ac553040762fe09ffc6179222efc8a4fc --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/Conventional.cs @@ -0,0 +1,790 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.InputData.Reader.ComponentData; +using TUGraz.VectoCore.InputData.Reader.ShiftStrategy; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.SimulationComponent; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public partial class DeclarationDataAdapterHeavyLorry + { + public class Conventional : LorryBase + { + public static readonly GearboxType[] SupportedGearboxTypes = + { GearboxType.MT, GearboxType.AMT, GearboxType.ATPowerSplit, GearboxType.ATSerial }; + + public override DriverData CreateDriverData() + { + var lookAheadData = new DriverData.LACData { + Enabled = DeclarationData.Driver.LookAhead.Enabled, + + //Deceleration = DeclarationData.Driver.LookAhead.Deceleration, + MinSpeed = DeclarationData.Driver.LookAhead.MinimumSpeed, + LookAheadDecisionFactor = new LACDecisionFactor(), + LookAheadDistanceFactor = DeclarationData.Driver.LookAhead.LookAheadDistanceFactor, + }; + var overspeedData = new DriverData.OverSpeedData { + Enabled = true, + MinSpeed = DeclarationData.Driver.OverSpeed.MinSpeed, + OverSpeed = DeclarationData.Driver.OverSpeed.AllowedOverSpeed, + }; + + var retVal = new DriverData { + LookAheadCoasting = lookAheadData, + OverSpeed = overspeedData, + EngineStopStart = new DriverData.EngineStopStartData() { + EngineOffStandStillActivationDelay = DeclarationData.Driver.EngineStopStart.ActivationDelay, + MaxEngineOffTimespan = DeclarationData.Driver.EngineStopStart.MaxEngineOffTimespan, + UtilityFactorStandstill = DeclarationData.Driver.EngineStopStart.UtilityFactor, + UtilityFactorDriving = DeclarationData.Driver.EngineStopStart.UtilityFactor, + }, + EcoRoll = new DriverData.EcoRollData() { + UnderspeedThreshold = DeclarationData.Driver.EcoRoll.UnderspeedThreshold, + MinSpeed = DeclarationData.Driver.EcoRoll.MinSpeed, + ActivationPhaseDuration = DeclarationData.Driver.EcoRoll.ActivationDelay, + AccelerationLowerLimit = DeclarationData.Driver.EcoRoll.AccelerationLowerLimit, + AccelerationUpperLimit = DeclarationData.Driver.EcoRoll.AccelerationUpperLimit, + }, + PCC = new DriverData.PCCData() { + PCCEnableSpeed = DeclarationData.Driver.PCC.PCCEnableSpeed, + MinSpeed = DeclarationData.Driver.PCC.MinSpeed, + PreviewDistanceUseCase1 = DeclarationData.Driver.PCC.PreviewDistanceUseCase1, + PreviewDistanceUseCase2 = DeclarationData.Driver.PCC.PreviewDistanceUseCase2, + UnderSpeed = DeclarationData.Driver.PCC.Underspeed, + OverspeedUseCase3 = DeclarationData.Driver.PCC.OverspeedUseCase3 + } + }; + return retVal; + } + + public override VehicleData CreateVehicleData(IVehicleDeclarationInputData data, Segment segment, + Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) + { + if (!data.SavedInDeclarationMode) { + WarnDeclarationMode("VehicleData"); + } + + return data.ExemptedVehicle + ? CreateExemptedVehicleData(data) + : CreateNonExemptedVehicleData(data, segment, mission, loading.Value.Item1, loading.Value.Item2, + allowVocational); + } + + protected virtual VehicleData CreateNonExemptedVehicleData(IVehicleDeclarationInputData data, + Segment segment, Mission mission, Kilogram loading, double? passengerCount, bool allowVocational) + { + var retVal = SetCommonVehicleData(data); + retVal.LegislativeClass = data.LegislativeClass; + retVal.AxleConfiguration = data.AxleConfiguration; + retVal.AirDensity = DeclarationData.AirDensity; + retVal.VIN = data.VIN; + retVal.ManufacturerAddress = data.ManufacturerAddress; + // retVal.LegislativeClass = data.LegislativeClass; + retVal.ZeroEmissionVehicle = data.ZeroEmissionVehicle; + retVal.VehicleClass = segment.VehicleClass; + retVal.SleeperCab = retVal.VehicleClass.IsMediumLorry() ? false : data.SleeperCab; + retVal.TrailerGrossVehicleMass = mission.Trailer.Sum(t => t.TrailerGrossVehicleWeight).DefaultIfNull(0); + + retVal.BodyAndTrailerMass = + mission.BodyCurbWeight + mission.Trailer.Sum(t => t.TrailerCurbWeight).DefaultIfNull(0); + + retVal.Loading = loading; + retVal.PassengerCount = passengerCount; + retVal.DynamicTyreRadius = + data.Components.AxleWheels.AxlesDeclaration.Where(axle => axle.AxleType == AxleType.VehicleDriven) + .Select(da => DeclarationData.Wheels.Lookup(da.Tyre.Dimension).DynamicTyreRadius) + .Average(); + if (segment.VehicleClass.IsMediumLorry() && segment.VehicleClass.IsVan()) { + retVal.CargoVolume = data.CargoVolume; + } else { + retVal.CargoVolume = mission.MissionType != MissionType.Construction + ? mission.TotalCargoVolume + : 0.SI<CubicMeter>(); + } + + retVal.VocationalVehicle = allowVocational && data.VocationalVehicle; + retVal.ADAS = CreateADAS(data.ADAS); + + var axles = data.Components.AxleWheels.AxlesDeclaration; + if (axles.Count < mission.AxleWeightDistribution.Length) { + throw new VectoException( + "Vehicle does not contain sufficient axles. {0} axles defined, {1} axles required", + axles.Count, mission.AxleWeightDistribution.Length); + } + + var axleData = new List<Axle>(); + for (var i = 0; i < mission.AxleWeightDistribution.Length; i++) { + var axleInput = axles[i]; + var axle = new Axle { + WheelsDimension = axleInput.Tyre.Dimension, + AxleType = axleInput.AxleType, + AxleWeightShare = mission.AxleWeightDistribution[i], + TwinTyres = axleInput.TwinTyres, + RollResistanceCoefficient = axleInput.Tyre.RollResistanceCoefficient, + TyreTestLoad = axleInput.Tyre.TyreTestLoad, + FuelEfficiencyClass = axleInput.Tyre.FuelEfficiencyClass, + Inertia = DeclarationData.Wheels.Lookup(axleInput.Tyre.Dimension.RemoveWhitespace()).Inertia, + CertificationNumber = axleInput.Tyre.CertificationNumber, + DigestValueInput = axleInput.Tyre.DigestValue == null + ? "" + : axleInput.Tyre.DigestValue.DigestValue, + }; + axleData.Add(axle); + } + + foreach (var trailer in mission.Trailer) { + axleData.AddRange( + trailer.TrailerWheels.Select( + trailerWheel => new Axle { + AxleType = AxleType.Trailer, + AxleWeightShare = trailer.TrailerAxleWeightShare / trailer.TrailerWheels.Count, + TwinTyres = DeclarationData.Trailer.TwinTyres, + RollResistanceCoefficient = DeclarationData.Trailer.RollResistanceCoefficient, + TyreTestLoad = DeclarationData.Trailer.TyreTestLoad.SI<Newton>(), + FuelEfficiencyClass = DeclarationData.Trailer.FuelEfficiencyClass, + Inertia = trailerWheel.Inertia, + WheelsDimension = trailerWheel.WheelType + })); + } + + retVal.AxleData = axleData; + return retVal; + } + + + protected virtual VehicleData CreateExemptedVehicleData(IVehicleDeclarationInputData data) + { + var exempted = SetCommonVehicleData(data); + exempted.VIN = data.VIN; + exempted.ManufacturerAddress = data.ManufacturerAddress; + exempted.LegislativeClass = data.LegislativeClass; + exempted.ZeroEmissionVehicle = data.ZeroEmissionVehicle; + exempted.HybridElectricHDV = data.HybridElectricHDV; + exempted.DualFuelVehicle = data.DualFuelVehicle; + exempted.MaxNetPower1 = data.MaxNetPower1; + exempted.MaxNetPower2 = data.MaxNetPower2; + return exempted; + } + + + public override CombustionEngineData CreateEngineData( + IVehicleDeclarationInputData vehicle, IEngineModeDeclarationInputData mode, Mission mission) + { + var engine = vehicle.Components.EngineInputData; + var gearbox = vehicle.Components.GearboxInputData; + + if (!engine.SavedInDeclarationMode) { + WarnDeclarationMode("EngineData"); + } + + var retVal = SetCommonCombustionEngineData(engine, vehicle.TankSystem); + retVal.IdleSpeed = VectoMath.Max(mode.IdleSpeed, vehicle.EngineIdleSpeed); + + retVal.Fuels = new List<CombustionEngineFuelData>(); + foreach (var fuel in mode.Fuels) { + retVal.Fuels.Add( + new CombustionEngineFuelData() { + WHTCUrban = fuel.WHTCUrban, + WHTCRural = fuel.WHTCRural, + WHTCMotorway = fuel.WHTCMotorway, + ColdHotCorrectionFactor = fuel.ColdHotBalancingFactor, + CorrectionFactorRegPer = fuel.CorrectionFactorRegPer, + FuelData = DeclarationData.FuelData.Lookup(fuel.FuelType, vehicle.TankSystem), + ConsumptionMap = FuelConsumptionMapReader.Create(fuel.FuelConsumptionMap), + FuelConsumptionCorrectionFactor = DeclarationData.WHTCCorrection.Lookup( + mission.MissionType.GetNonEMSMissionType(), fuel.WHTCRural, fuel.WHTCUrban, + fuel.WHTCMotorway) * fuel.ColdHotBalancingFactor * fuel.CorrectionFactorRegPer, + }); + } + + retVal.Inertia = DeclarationData.Engine.EngineInertia(retVal.Displacement, gearbox.Type); + retVal.EngineStartTime = DeclarationData.Engine.DefaultEngineStartTime; + var limits = vehicle.TorqueLimits?.ToDictionary(e => e.Gear) ?? + new Dictionary<int, ITorqueLimitInputData>(); + var numGears = gearbox.Gears.Count; + var fullLoadCurves = new Dictionary<uint, EngineFullLoadCurve>(numGears + 1); + fullLoadCurves[0] = FullLoadCurveReader.Create(mode.FullLoadCurve, true); + fullLoadCurves[0].EngineData = retVal; + foreach (var gear in gearbox.Gears) { + var maxTorque = VectoMath.Min( + GbxMaxTorque(gear, numGears, fullLoadCurves[0].MaxTorque), + VehMaxTorque(gear, numGears, limits, fullLoadCurves[0].MaxTorque)); + fullLoadCurves[(uint)gear.Gear] = IntersectFullLoadCurves(fullLoadCurves[0], maxTorque); + } + + retVal.FullLoadCurves = fullLoadCurves; + + retVal.WHRType = engine.WHRType; + if ((retVal.WHRType & WHRType.ElectricalOutput) != 0) { + retVal.ElectricalWHR = CreateWHRData( + mode.WasteHeatRecoveryDataElectrical, mission.MissionType, WHRType.ElectricalOutput); + } + + if ((retVal.WHRType & WHRType.MechanicalOutputDrivetrain) != 0) { + retVal.MechanicalWHR = CreateWHRData( + mode.WasteHeatRecoveryDataMechanical, mission.MissionType, WHRType.MechanicalOutputDrivetrain); + } + + return retVal; + } + + protected static WHRData CreateWHRData(IWHRData whrInputData, MissionType missionType, WHRType type) + { + if (whrInputData == null || whrInputData.GeneratedPower == null) { + throw new VectoException("Missing WHR Data"); + } + + var whr = new WHRData() { + CFUrban = whrInputData.UrbanCorrectionFactor, + CFRural = whrInputData.RuralCorrectionFactor, + CFMotorway = whrInputData.MotorwayCorrectionFactor, + CFColdHot = whrInputData.BFColdHot, + CFRegPer = whrInputData.CFRegPer, + WHRMap = WHRPowerReader.Create(whrInputData.GeneratedPower, type) + }; + whr.WHRCorrectionFactor = DeclarationData.WHTCCorrection.Lookup( + missionType.GetNonEMSMissionType(), whr.CFRural, whr.CFUrban, + whr.CFMotorway) * whr.CFColdHot * whr.CFRegPer; + return whr; + } + + protected internal static NewtonMeter VehMaxTorque( + ITransmissionInputData gear, int numGears, + Dictionary<int, ITorqueLimitInputData> limits, + NewtonMeter maxEngineTorque) + { + if (gear.Gear - 1 >= numGears / 2) { + // only upper half of gears can limit if max-torque <= 0.95 of engine max torque + if (limits.TryGetValue(gear.Gear, out var limit) && limit.MaxTorque <= + DeclarationData.Engine.TorqueLimitVehicleFactor * maxEngineTorque) { + return limit.MaxTorque; + } + } + + return null; + } + + protected internal static NewtonMeter GbxMaxTorque( + ITransmissionInputData gear, int numGears, NewtonMeter maxEngineTorque + ) + { + if (gear.Gear - 1 < numGears / 2) { + // gears count from 1 to n, -> n entries, lower half can always limit + if (gear.MaxTorque != null) { + return gear.MaxTorque; + } + } else { + // upper half can only limit if max-torque <= 90% of engine max torque + if (gear.MaxTorque != null && + gear.MaxTorque <= DeclarationData.Engine.TorqueLimitGearboxFactor * maxEngineTorque) { + return gear.MaxTorque; + } + } + + return null; + } + + public override GearboxData CreateGearboxData(IVehicleDeclarationInputData inputData, VectoRunData runData, + IShiftPolygonCalculator shiftPolygonCalc) + { + if (!inputData.Components.GearboxInputData.SavedInDeclarationMode) { + WarnDeclarationMode("GearboxData"); + } + + return DoCreateGearboxData(inputData, runData, shiftPolygonCalc); + } + + public virtual GearboxData DoCreateGearboxData(IVehicleDeclarationInputData inputData, VectoRunData runData, + IShiftPolygonCalculator shiftPolygonCalc) + { + var gearbox = inputData.Components.GearboxInputData; + + var adas = inputData.ADAS; + var torqueConverter = inputData.Components.TorqueConverterInputData; + + var engine = runData.EngineData; + var axlegearRatio = runData.AxleGearData.AxleGear.Ratio; + var dynamicTyreRadius = runData.VehicleData.DynamicTyreRadius; + + var retVal = SetCommonGearboxData(gearbox); + + //if (adas != null && retVal.Type.AutomaticTransmission() && adas.EcoRoll != EcoRollType.None && + // !adas.ATEcoRollReleaseLockupClutch.HasValue) { + // throw new VectoException("Input parameter ATEcoRollReleaseLockupClutch required for AT transmission"); + //} + + retVal.ATEcoRollReleaseLockupClutch = + adas != null && adas.EcoRoll != EcoRollType.None && retVal.Type.AutomaticTransmission() + ? (adas.ATEcoRollReleaseLockupClutch.HasValue ? adas.ATEcoRollReleaseLockupClutch.Value : false) + : false; + + if (!SupportedGearboxTypes.Contains(gearbox.Type)) { + throw new VectoSimulationException("Unsupported gearbox type: {0}!", retVal.Type); + } + + var gearsInput = gearbox.Gears; + if (gearsInput.Count < 1) { + throw new VectoSimulationException( + "At least one Gear-Entry must be defined in Gearbox!"); + } + + SetDeclarationData(retVal); + + var gearDifferenceRatio = gearbox.Type.AutomaticTransmission() && gearbox.Gears.Count > 2 + ? gearbox.Gears[0].Ratio / gearbox.Gears[1].Ratio + : 1.0; + + var gears = new Dictionary<uint, GearData>(); + var tcShiftPolygon = DeclarationData.TorqueConverter.ComputeShiftPolygon(engine.FullLoadCurves[0]); + var vehicleCategory = runData.VehicleData.VehicleCategory == VehicleCategory.GenericBusVehicle + ? VehicleCategory.GenericBusVehicle + : inputData.VehicleCategory; + for (uint i = 0; i < gearsInput.Count; i++) { + var gear = gearsInput[(int)i]; + var lossMap = CreateGearLossMap(gear, i, false, vehicleCategory, gearbox.Type); + + var shiftPolygon = shiftPolygonCalc != null + ? shiftPolygonCalc.ComputeDeclarationShiftPolygon( + gearbox.Type, (int)i, engine.FullLoadCurves[i + 1], gearbox.Gears, engine, axlegearRatio, + dynamicTyreRadius) + : DeclarationData.Gearbox.ComputeShiftPolygon( + gearbox.Type, (int)i, engine.FullLoadCurves[i + 1], + gearsInput, engine, + axlegearRatio, dynamicTyreRadius, null); + + var gearData = new GearData { + ShiftPolygon = shiftPolygon, + MaxSpeed = gear.MaxInputSpeed, + MaxTorque = gear.MaxTorque, + Ratio = gear.Ratio, + LossMap = lossMap, + }; + + CreateATGearData(gearbox, i, gearData, tcShiftPolygon, gearDifferenceRatio, gears, + runData.VehicleData.VehicleCategory); + gears.Add(i + 1, gearData); + } + + // remove disabled gears (only the last or last two gears may be removed) + if (inputData.TorqueLimits != null) { + var toRemove = (from tqLimit in inputData.TorqueLimits + where tqLimit.Gear >= gears.Keys.Max() - 1 && tqLimit.MaxTorque.IsEqual(0) + select (uint)tqLimit.Gear).ToList(); + if (toRemove.Count > 0 && toRemove.Min() <= gears.Count - toRemove.Count) { + throw new VectoException( + "Only the last 1 or 2 gears can be disabled. Disabling gear {0} for a {1}-speed gearbox is not allowed.", + toRemove.Min(), gears.Count); + } + + foreach (var entry in toRemove) { + gears.Remove(entry); + } + } + + retVal.Gears = gears; + if (retVal.Type.AutomaticTransmission()) { + var ratio = double.IsNaN(retVal.Gears[1].Ratio) + ? 1 + : retVal.Gears[1].TorqueConverterRatio / retVal.Gears[1].Ratio; + retVal.PowershiftShiftTime = DeclarationData.Gearbox.PowershiftShiftTime; + + retVal.TorqueConverterData = + CreateTorqueConverterData(gearbox.Type, torqueConverter, ratio, engine); + + if (torqueConverter != null) { + retVal.TorqueConverterData.Manufacturer = torqueConverter.Manufacturer; + retVal.TorqueConverterData.ModelName = torqueConverter.Model; + retVal.TorqueConverterData.DigestValueInput = torqueConverter.DigestValue?.DigestValue; + retVal.TorqueConverterData.CertificationMethod = torqueConverter.CertificationMethod; + retVal.TorqueConverterData.CertificationNumber = torqueConverter.CertificationNumber; + retVal.TorqueConverterData.Date = torqueConverter.Date; + retVal.TorqueConverterData.AppVersion = torqueConverter.AppVersion; + } + } + + // update disengageWhenHaltingSpeed + if (retVal.Type.AutomaticTransmission()) { + var firstGear = retVal.GearList.First(x => x.IsLockedGear()); + if (retVal.Gears[firstGear.Gear].ShiftPolygon.Downshift.Any()) { + var downshiftSpeedInc = retVal.Gears[firstGear.Gear].ShiftPolygon + .InterpolateDownshiftSpeed(0.SI<NewtonMeter>()) * 1.05; + var vehicleSpeedDisengage = + downshiftSpeedInc / axlegearRatio / retVal.Gears[firstGear.Gear].Ratio * + dynamicTyreRadius; + retVal.DisengageWhenHaltingSpeed = vehicleSpeedDisengage; + } + } + + return retVal; + } + + protected virtual TorqueConverterData CreateTorqueConverterData(GearboxType gearboxType, + ITorqueConverterDeclarationInputData torqueConverter, double ratio, + CombustionEngineData componentsEngineInputData) + { + return TorqueConverterDataReader.Create( + torqueConverter.TCData, + DeclarationData.TorqueConverter.ReferenceRPM, DeclarationData.TorqueConverter.MaxInputSpeed, + ExecutionMode.Declaration, ratio, + DeclarationData.TorqueConverter.CLUpshiftMinAcceleration, + DeclarationData.TorqueConverter.CCUpshiftMinAcceleration); + } + + protected virtual void CreateATGearData( + IGearboxDeclarationInputData gearbox, uint i, GearData gearData, + ShiftPolygon tcShiftPolygon, double gearDifferenceRatio, Dictionary<uint, GearData> gears, + VehicleCategory vehicleCategory) + { + if (gearbox.Type == GearboxType.ATPowerSplit && i == 0) { + // powersplit transmission: torque converter already contains ratio and losses + CretateTCFirstGearATPowerSplit(gearData, i, tcShiftPolygon); + } + + if (gearbox.Type == GearboxType.ATSerial) { + if (i == 0) { + // torqueconverter is active in first gear - duplicate ratio and lossmap for torque converter mode + CreateTCFirstGearATSerial(gearData, tcShiftPolygon); + } + + if (i == 1 && gearDifferenceRatio >= + DeclarationData.Gearbox.TorqueConverterSecondGearThreshold(vehicleCategory)) { + // ratio between first and second gear is above threshold, torqueconverter is active in second gear as well + // -> duplicate ratio and lossmap for torque converter mode, remove locked transmission for previous gear + CreateTCSecondGearATSerial(gearData, tcShiftPolygon); + + // NOTE: the lower gear in 'gears' dictionary has index i !! + gears[i].Ratio = double.NaN; + gears[i].LossMap = null; + } + } + } + + private static void SetDeclarationData(GearboxData retVal) + { + retVal.Inertia = DeclarationData.Gearbox.Inertia; + retVal.TractionInterruption = retVal.Type.TractionInterruption(); + } + + public override AxleGearData CreateAxleGearData(IAxleGearInputData data) + { + var retVal = SetCommonAxleGearData(data); + retVal.AxleGear.LossMap = ReadAxleLossMap(data, false); + return retVal; + } + + public override AngledriveData CreateAngledriveData(IAngledriveInputData data) + { + return DoCreateAngledriveData(data, false); + } + + + public override IList<VectoRunData.AuxData> CreateAuxiliaryData( + IAuxiliariesDeclarationInputData auxInputData, + IBusAuxiliariesDeclarationData busAuxData, MissionType mission, VehicleClass hvdClass, + Meter vehicleLength, int? numSteeredAxles) + { + if (!auxInputData.SavedInDeclarationMode) { + WarnDeclarationMode("AuxiliariesData"); + } + + var retVal = new List<VectoRunData.AuxData>(); + + if (auxInputData.Auxiliaries.Count != 5) { + Log.Error( + "In Declaration Mode exactly 5 Auxiliaries must be defined: Fan, Steering pump, HVAC, Electric System, Pneumatic System."); + throw new VectoException( + "In Declaration Mode exactly 5 Auxiliaries must be defined: Fan, Steering pump, HVAC, Electric System, Pneumatic System."); + } + + foreach (var auxType in EnumHelper.GetValues<AuxiliaryType>()) { + var auxData = auxInputData.Auxiliaries.FirstOrDefault(a => a.Type == auxType); + if (auxData == null) { + throw new VectoException("Auxiliary {0} not found.", auxType); + } + + var aux = new VectoRunData.AuxData { + DemandType = AuxiliaryDemandType.Constant, + Technology = auxData.Technology + }; + + mission = mission.GetNonEMSMissionType(); + switch (auxType) { + case AuxiliaryType.Fan: + aux.PowerDemand = DeclarationData.Fan.LookupPowerDemand(hvdClass, mission, + auxData.Technology.FirstOrDefault()); + aux.ID = Constants.Auxiliaries.IDs.Fan; + break; + case AuxiliaryType.SteeringPump: + if (numSteeredAxles.HasValue && auxData.Technology.Count != numSteeredAxles.Value) { + throw new VectoException( + $"Number of steering pump technologies does not match number of steered axles ({numSteeredAxles.Value}, {auxData.Technology.Count})"); + } + + aux.PowerDemand = + DeclarationData.SteeringPump.Lookup(mission, hvdClass, auxData.Technology); + aux.ID = Constants.Auxiliaries.IDs.SteeringPump; + break; + case AuxiliaryType.HVAC: + aux.PowerDemand = DeclarationData.HeatingVentilationAirConditioning.Lookup( + mission, + auxData.Technology.FirstOrDefault(), hvdClass).PowerDemand; + aux.ID = Constants.Auxiliaries.IDs.HeatingVentilationAirCondition; + break; + case AuxiliaryType.PneumaticSystem: + aux.PowerDemand = DeclarationData.PneumaticSystem + .Lookup(mission, auxData.Technology.FirstOrDefault()) + .PowerDemand; + aux.ID = Constants.Auxiliaries.IDs.PneumaticSystem; + break; + case AuxiliaryType.ElectricSystem: + aux.PowerDemand = DeclarationData.ElectricSystem + .Lookup(mission, auxData.Technology.FirstOrDefault()).PowerDemand; + aux.ID = Constants.Auxiliaries.IDs.ElectricSystem; + break; + default: continue; + } + + retVal.Add(aux); + } + + return retVal; + } + + public override AxleGearData CreateDummyAxleGearData(IGearboxDeclarationInputData gbxData) + { + if (double.IsNaN(gbxData.AxlegearRatio)) { + throw new VectoException( + "Axlegear ratio required in gearbox data for gearboxes with included axlegear"); + } + + return new AxleGearData() { + AxleGear = new TransmissionData() { + Ratio = gbxData.AxlegearRatio, + LossMap = TransmissionLossMapReader.Create(1.0, gbxData.AxlegearRatio, "Axlegear") + } + }; + } + + protected void WarnDeclarationMode(string inputData) + { + Log.Warn("{0} not in Declaration Mode!", inputData); + } + + public override RetarderData CreateRetarderData(IRetarderInputData retarder) + { + return SetCommonRetarderData(retarder); + } + + public static List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> + GetDeclarationAirResistanceCurve( + string crosswindCorrectionParameters, SquareMeter aerodynamicDragAera, Meter vehicleHeight) + { + var startSpeed = Constants.SimulationSettings.CrosswindCorrection.MinVehicleSpeed; + var maxSpeed = Constants.SimulationSettings.CrosswindCorrection.MaxVehicleSpeed; + var speedStep = Constants.SimulationSettings.CrosswindCorrection.VehicleSpeedStep; + + var maxAlpha = Constants.SimulationSettings.CrosswindCorrection.MaxAlpha; + var alphaStep = Constants.SimulationSettings.CrosswindCorrection.AlphaStep; + + var startHeightPercent = Constants.SimulationSettings.CrosswindCorrection.MinHeight; + var maxHeightPercent = Constants.SimulationSettings.CrosswindCorrection.MaxHeight; + var heightPercentStep = Constants.SimulationSettings.CrosswindCorrection.HeightStep; + var heightShare = (double)heightPercentStep / maxHeightPercent; + + var values = DeclarationData.AirDrag.Lookup(crosswindCorrectionParameters); + + // first entry (0m/s) will get CdxA of second entry. + var points = new List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> { + new CrossWindCorrectionCurveReader.CrossWindCorrectionEntry { + Velocity = 0.SI<MeterPerSecond>(), + EffectiveCrossSectionArea = 0.SI<SquareMeter>() + } + }; + + for (var speed = startSpeed; speed <= maxSpeed; speed += speedStep) { + var vVeh = speed.KMPHtoMeterPerSecond(); + + var cdASum = 0.SI<SquareMeter>(); + + for (var heightPercent = startHeightPercent; + heightPercent < maxHeightPercent; + heightPercent += heightPercentStep) { + var height = heightPercent / 100.0 * vehicleHeight; + var vWind = Physics.BaseWindSpeed * + Math.Pow(height / Physics.BaseWindHeight, Physics.HellmannExponent); + + for (var alpha = 0; alpha <= maxAlpha; alpha += alphaStep) { + var vAirX = vVeh + vWind * Math.Cos(alpha.ToRadian()); + var vAirY = vWind * Math.Sin(alpha.ToRadian()); + + var beta = Math.Atan(vAirY / vAirX).ToDegree(); + + // ΔCdxA = A1β + A2β² + A3β³ + var deltaCdA = values.A1 * beta + values.A2 * beta * beta + values.A3 * beta * beta * beta; + + // CdxA(β) = CdxA(0) + ΔCdxA(β) + var cdA = aerodynamicDragAera + deltaCdA; + + var share = (alpha == 0 || alpha == maxAlpha ? alphaStep / 2.0 : alphaStep) / maxAlpha; + + // v_air = sqrt(v_airX²+vAirY²) + // cdASum = CdxA(β) * v_air²/v_veh² + cdASum += heightShare * share * cdA * (vAirX * vAirX + vAirY * vAirY) / (vVeh * vVeh); + } + } + + points.Add( + new CrossWindCorrectionCurveReader.CrossWindCorrectionEntry { + Velocity = vVeh, + EffectiveCrossSectionArea = cdASum + }); + } + + points[0].EffectiveCrossSectionArea = points[1].EffectiveCrossSectionArea; + return points; + } + + public override PTOData CreatePTOTransmissionData(IPTOTransmissionInputData pto) + { + if (pto != null && pto.PTOTransmissionType != "None") { + return new PTOData { + TransmissionType = pto.PTOTransmissionType, + LossMap = PTOIdleLossMapReader.GetZeroLossMap(), + }; + } + + return null; + } + + public override AirdragData CreateAirdragData( + IAirdragDeclarationInputData airdragInputData, Mission mission, + Segment segment) + { + if (airdragInputData == null || airdragInputData.AirDragArea == null) { + return DefaultAirdragData(mission); + } + + var retVal = SetCommonAirdragData(airdragInputData); + retVal.CrossWindCorrectionMode = CrossWindCorrectionMode.DeclarationModeCorrection; + retVal.DeclaredAirdragArea = mission.MissionType == MissionType.Construction + ? mission.DefaultCDxA + : airdragInputData.AirDragArea; + + var aerodynamicDragArea = + retVal.DeclaredAirdragArea + mission.Trailer.Sum(t => t.DeltaCdA).DefaultIfNull(0); + + retVal.CrossWindCorrectionCurve = + new CrosswindCorrectionCdxALookup( + aerodynamicDragArea, + GetDeclarationAirResistanceCurve( + mission.CrossWindCorrectionParameters, aerodynamicDragArea, mission.VehicleHeight), + CrossWindCorrectionMode.DeclarationModeCorrection); + return retVal; + } + + protected virtual AirdragData DefaultAirdragData(Mission mission) + { + var aerodynamicDragArea = mission.DefaultCDxA + mission.Trailer.Sum(t => t.DeltaCdA).DefaultIfNull(0); + + return new AirdragData() { + CertificationMethod = CertificationMethod.StandardValues, + CrossWindCorrectionMode = CrossWindCorrectionMode.DeclarationModeCorrection, + DeclaredAirdragArea = mission.DefaultCDxA, + CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup( + aerodynamicDragArea, + GetDeclarationAirResistanceCurve( + mission.CrossWindCorrectionParameters, aerodynamicDragArea, mission.VehicleHeight), + CrossWindCorrectionMode.DeclarationModeCorrection) + }; + } + + public override ShiftStrategyParameters CreateGearshiftData(GearboxData gbx, double axleRatio, + PerSecond engineIdlingSpeed) + { + var retVal = new ShiftStrategyParameters { + TorqueReserve = DeclarationData.GearboxTCU.TorqueReserve, + StartTorqueReserve = DeclarationData.GearboxTCU.TorqueReserveStart, + TimeBetweenGearshifts = DeclarationData.Gearbox.MinTimeBetweenGearshifts, + StartSpeed = DeclarationData.GearboxTCU.StartSpeed, + StartAcceleration = DeclarationData.GearboxTCU.StartAcceleration, + DownshiftAfterUpshiftDelay = DeclarationData.Gearbox.DownshiftAfterUpshiftDelay, + UpshiftAfterDownshiftDelay = DeclarationData.Gearbox.UpshiftAfterDownshiftDelay, + UpshiftMinAcceleration = DeclarationData.Gearbox.UpshiftMinAcceleration, + + StartVelocity = DeclarationData.GearboxTCU.StartSpeed, + GearResidenceTime = DeclarationData.GearboxTCU.GearResidenceTime, + DnT99L_highMin1 = DeclarationData.GearboxTCU.DnT99L_highMin1, + DnT99L_highMin2 = DeclarationData.GearboxTCU.DnT99L_highMin2, + AllowedGearRangeUp = DeclarationData.GearboxTCU.AllowedGearRangeUp, + AllowedGearRangeDown = DeclarationData.GearboxTCU.AllowedGearRangeDown, + LookBackInterval = DeclarationData.GearboxTCU.LookBackInterval, + DriverAccelerationLookBackInterval = DeclarationData.GearboxTCU.DriverAccelerationLookBackInterval, + DriverAccelerationThresholdLow = DeclarationData.GearboxTCU.DriverAccelerationThresholdLow, + AverageCardanPowerThresholdPropulsion = + DeclarationData.GearboxTCU.AverageCardanPowerThresholdPropulsion, + CurrentCardanPowerThresholdPropulsion = + DeclarationData.GearboxTCU.CurrentCardanPowerThresholdPropulsion, + TargetSpeedDeviationFactor = DeclarationData.GearboxTCU.TargetSpeedDeviationFactor, + EngineSpeedHighDriveOffFactor = DeclarationData.GearboxTCU.EngineSpeedHighDriveOffFactor, + RatingFactorCurrentGear = gbx.Type.AutomaticTransmission() + ? DeclarationData.GearboxTCU.RatingFactorCurrentGearAT + : DeclarationData.GearboxTCU.RatingFactorCurrentGear, + AccelerationReserveLookup = AccelerationReserveLookupReader.ReadFromStream( + RessourceHelper.ReadStream( + DeclarationData.DeclarationDataResourcePrefix + + ".GearshiftParameters.AccelerationReserveLookup.csv")), + ShareTorque99L = ShareTorque99lLookupReader.ReadFromStream( + RessourceHelper.ReadStream( + DeclarationData.DeclarationDataResourcePrefix + ".GearshiftParameters.ShareTq99L.csv") + ), + PredictionDurationLookup = PredictionDurationLookupReader.ReadFromStream( + RessourceHelper.ReadStream( + DeclarationData.DeclarationDataResourcePrefix + + ".GearshiftParameters.PredictionTimeLookup.csv") + ), + ShareIdleLow = ShareIdleLowReader.ReadFromStream( + RessourceHelper.ReadStream( + DeclarationData.DeclarationDataResourcePrefix + ".GearshiftParameters.ShareIdleLow.csv") + ), + ShareEngineHigh = EngineSpeedHighLookupReader.ReadFromStream( + RessourceHelper.ReadStream( + DeclarationData.DeclarationDataResourcePrefix + + ".GearshiftParameters.ShareEngineSpeedHigh.csv") + ), + + //-------------------- + RatioEarlyUpshiftFC = DeclarationData.GearboxTCU.RatioEarlyUpshiftFC / axleRatio, + RatioEarlyDownshiftFC = DeclarationData.GearboxTCU.RatioEarlyDownshiftFC / axleRatio, + AllowedGearRangeFC = gbx.Type.AutomaticTransmission() + ? (gbx.Gears.Count > DeclarationData.GearboxTCU.ATSkipGearsThreshold + ? DeclarationData.GearboxTCU.AllowedGearRangeFCATSkipGear + : DeclarationData.GearboxTCU.AllowedGearRangeFCAT) + : DeclarationData.GearboxTCU.AllowedGearRangeFCAMT, + VelocityDropFactor = DeclarationData.GearboxTCU.VelocityDropFactor, + AccelerationFactor = DeclarationData.GearboxTCU.AccelerationFactor, + MinEngineSpeedPostUpshift = 0.RPMtoRad(), + ATLookAheadTime = DeclarationData.GearboxTCU.ATLookAheadTime, + + LoadStageThresoldsUp = DeclarationData.GearboxTCU.LoadStageThresholdsUp, + LoadStageThresoldsDown = DeclarationData.GearboxTCU.LoadStageThresoldsDown, + ShiftSpeedsTCToLocked = DeclarationData.GearboxTCU.ShiftSpeedsTCToLocked + .Select(x => x.Select(y => y + engineIdlingSpeed.AsRPM).ToArray()).ToArray(), + }; + + return retVal; + } + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/DeclarationDataAdapterHeavyLorry.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/DeclarationDataAdapterHeavyLorry.cs new file mode 100644 index 0000000000000000000000000000000000000000..573b15b7d3bc6d7585c62803f1ed7a6f049f8dce --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/DeclarationDataAdapterHeavyLorry.cs @@ -0,0 +1,139 @@ +/* +* This file is part of VECTO. +* +* Copyright © 2012-2019 European Union +* +* Developed by Graz University of Technology, +* Institute of Internal Combustion Engines and Thermodynamics, +* Institute of Technical Informatics +* +* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved +* by the European Commission - subsequent versions of the EUPL (the "Licence"); +* You may not use VECTO except in compliance with the Licence. +* You may obtain a copy of the Licence at: +* +* https://joinup.ec.europa.eu/community/eupl/og_page/eupl +* +* Unless required by applicable law or agreed to in writing, VECTO +* 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. +* +* Authors: +* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology +* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology +* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology +* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology +* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology +* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using TUGraz.VectoCommon.BusAuxiliaries; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.InputData.Reader.ComponentData; +using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC; +using TUGraz.VectoCore.InputData.Reader.ShiftStrategy; +using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumatics; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.SimulationComponent; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + + public partial class DeclarationDataAdapterHeavyLorry : AbstractSimulationDataAdapter, IDeclarationDataAdapter + { + [Obsolete("Use DeclarationDataAdapterHeavyLorry.Conventional instead, created automatically with NInject")] + public DeclarationDataAdapterHeavyLorry() + { + + } + private IDeclarationDataAdapter _declarationDataAdapterImplementation = new DeclarationDataAdapterHeavyLorry.Conventional(); + public static readonly GearboxType[] SupportedGearboxTypes = Conventional.SupportedGearboxTypes; + public static List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> GetDeclarationAirResistanceCurve(string parameterSet, SquareMeter si, Meter meter) + { + return Conventional.GetDeclarationAirResistanceCurve(parameterSet, si, meter); + } + #region Implementation of IDeclarationDataAdapter + + public DriverData CreateDriverData() + { + return _declarationDataAdapterImplementation.CreateDriverData(); + } + + public VehicleData CreateVehicleData(IVehicleDeclarationInputData vehicle, Segment segment, Mission mission, + KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) + { + return _declarationDataAdapterImplementation.CreateVehicleData(vehicle, segment, mission, loading, allowVocational); + } + + public AirdragData CreateAirdragData(IAirdragDeclarationInputData airdragData, Mission mission, Segment segment) + { + return _declarationDataAdapterImplementation.CreateAirdragData(airdragData, mission, segment); + } + + public AxleGearData CreateAxleGearData(IAxleGearInputData axlegearData) + { + return _declarationDataAdapterImplementation.CreateAxleGearData(axlegearData); + } + + public AngledriveData CreateAngledriveData(IAngledriveInputData angledriveData) + { + return _declarationDataAdapterImplementation.CreateAngledriveData(angledriveData); + } + + public CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, IEngineModeDeclarationInputData engineMode, + Mission mission) + { + return _declarationDataAdapterImplementation.CreateEngineData(vehicle, engineMode, mission); + } + + public GearboxData CreateGearboxData(IVehicleDeclarationInputData inputData, VectoRunData runData, + IShiftPolygonCalculator shiftPolygonCalc) + { + return _declarationDataAdapterImplementation.CreateGearboxData(inputData, runData, shiftPolygonCalc); + } + + public ShiftStrategyParameters CreateGearshiftData(GearboxData gbx, double axleRatio, PerSecond engineIdlingSpeed) + { + return _declarationDataAdapterImplementation.CreateGearshiftData(gbx, axleRatio, engineIdlingSpeed); + } + + public RetarderData CreateRetarderData(IRetarderInputData retarderData) + { + return _declarationDataAdapterImplementation.CreateRetarderData(retarderData); + } + + public PTOData CreatePTOTransmissionData(IPTOTransmissionInputData ptoData) + { + return _declarationDataAdapterImplementation.CreatePTOTransmissionData(ptoData); + } + + public IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxData, IBusAuxiliariesDeclarationData busAuxData, + MissionType missionType, VehicleClass vehicleClass, Meter vehicleLength, int? numSteeredAxles) + { + return _declarationDataAdapterImplementation.CreateAuxiliaryData(auxData, busAuxData, missionType, vehicleClass, vehicleLength, numSteeredAxles); + } + + public AxleGearData CreateDummyAxleGearData(IGearboxDeclarationInputData gbxData) + { + return _declarationDataAdapterImplementation.CreateDummyAxleGearData(gbxData); + } + + #endregion + + + } +} diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_P1.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_P1.cs new file mode 100644 index 0000000000000000000000000000000000000000..d9ebb4ca1fc13fe212d469498b27ecf1c9161a22 --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_P1.cs @@ -0,0 +1,10 @@ +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public partial class DeclarationDataAdapterHeavyLorry + { + public class HEV_P1 : LorryBase + { + + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_P2.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_P2.cs new file mode 100644 index 0000000000000000000000000000000000000000..89991f09b9af4ce6cf01296c35bd1a1e47e91b6a --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_P2.cs @@ -0,0 +1,11 @@ + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public partial class DeclarationDataAdapterHeavyLorry + { + public class HEV_P2 : LorryBase + { + + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_P2_5.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_P2_5.cs new file mode 100644 index 0000000000000000000000000000000000000000..18b36227b4341e9bd3f493f03c2b0177780be933 --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_P2_5.cs @@ -0,0 +1,12 @@ + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public partial class DeclarationDataAdapterHeavyLorry + { + public class HEV_P2_5 : DataObjectAdapter.DeclarationDataAdapterHeavyLorry.LorryBase + { + + } + + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_P3.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_P3.cs new file mode 100644 index 0000000000000000000000000000000000000000..3b12407d168680061ce8469a8453fde6b886f6ff --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_P3.cs @@ -0,0 +1,12 @@ + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public partial class DeclarationDataAdapterHeavyLorry + { + public class HEV_P3 : LorryBase + { + + } + + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_P4.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_P4.cs new file mode 100644 index 0000000000000000000000000000000000000000..3fbaf1b7a66a14d7d423507f59ab7d1089509b9b --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_P4.cs @@ -0,0 +1,12 @@ + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public partial class DeclarationDataAdapterHeavyLorry + { + public class HEV_P4 : DataObjectAdapter.DeclarationDataAdapterHeavyLorry.LorryBase + { + + } + + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_S2.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_S2.cs new file mode 100644 index 0000000000000000000000000000000000000000..ea97ab174ca4e6ae9cf9ccb8ad33aa9bffe0914c --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_S2.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.SimulationComponent; +using TUGraz.VectoCore.Models.SimulationComponent.Data; + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public partial class DeclarationDataAdapterHeavyLorry + { + public class HEV_S2 : LorryBase + { + #region Overrides of LorryBase + + public override DriverData CreateDriverData() + { + throw new NotImplementedException(); + } + + public override VehicleData CreateVehicleData(IVehicleDeclarationInputData vehicle, Segment segment, + Mission mission, + KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) + { + throw new NotImplementedException(); + } + + public override AirdragData CreateAirdragData(IAirdragDeclarationInputData airdragData, Mission mission, + Segment segment) + { + throw new NotImplementedException(); + } + + public override AxleGearData CreateAxleGearData(IAxleGearInputData axlegearData) + { + throw new NotImplementedException(); + } + + public override AngledriveData CreateAngledriveData(IAngledriveInputData angledriveData) + { + throw new NotImplementedException(); + } + + public override CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, + IEngineModeDeclarationInputData engineMode, + Mission mission) + { + throw new NotImplementedException(); + } + + public override GearboxData CreateGearboxData(IVehicleDeclarationInputData inputData, VectoRunData runData, + IShiftPolygonCalculator shiftPolygonCalc) + { + throw new NotImplementedException(); + } + + public override ShiftStrategyParameters CreateGearshiftData(GearboxData gbx, double axleRatio, + PerSecond engineIdlingSpeed) + { + throw new NotImplementedException(); + } + + public override RetarderData CreateRetarderData(IRetarderInputData retarderData) + { + throw new NotImplementedException(); + } + + public override PTOData CreatePTOTransmissionData(IPTOTransmissionInputData ptoData) + { + throw new NotImplementedException(); + } + + public override IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxData, + IBusAuxiliariesDeclarationData busAuxData, + MissionType missionType, VehicleClass vehicleClass, Meter vehicleLength, int? numSteeredAxles) + { + throw new NotImplementedException(); + } + + public override AxleGearData CreateDummyAxleGearData(IGearboxDeclarationInputData gbxData) + { + throw new NotImplementedException(); + } + + #endregion + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_S3.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_S3.cs new file mode 100644 index 0000000000000000000000000000000000000000..d02d80057cbc3bbf0d28254be21fa2e82bfcee57 --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_S3.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TUGraz.VectoCore.InputData.Reader.Impl; + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public partial class DeclarationDataAdapterHeavyLorry + { + public class HEV_S3 : LorryBase + { + + } + } +} diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_S4.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_S4.cs new file mode 100644 index 0000000000000000000000000000000000000000..ffa4b4975ec31f48a899f7b51d7feef73e1f81b7 --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_S4.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TUGraz.VectoCore.InputData.Reader.Impl; + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public partial class DeclarationDataAdapterHeavyLorry + { + public class HEV_S4 : LorryBase + { + + } + } +} diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_S_IEPC.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_S_IEPC.cs new file mode 100644 index 0000000000000000000000000000000000000000..0917520f49f053b79815b2b5e12ce0233994e801 --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/HEV_S_IEPC.cs @@ -0,0 +1,10 @@ +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public partial class DeclarationDataAdapterHeavyLorry + { + public class HEV_S_IEPC : DataObjectAdapter.DeclarationDataAdapterHeavyLorry.LorryBase + { + + } + } +} diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/LorryBase.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/LorryBase.cs new file mode 100644 index 0000000000000000000000000000000000000000..198243eef9d89e8d3cd51d97888c4c150243d0eb --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/LorryBase.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.SimulationComponent; +using TUGraz.VectoCore.Models.SimulationComponent.Data; + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public partial class DeclarationDataAdapterHeavyLorry + { + public abstract class LorryBase : AbstractSimulationDataAdapter, IDeclarationDataAdapter + { + #region Implementation of IDeclarationDataAdapter + + public virtual DriverData CreateDriverData() + { + throw new NotImplementedException(); + } + + public virtual VehicleData CreateVehicleData(IVehicleDeclarationInputData vehicle, Segment segment, + Mission mission, + KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) + { + throw new NotImplementedException(); + } + + public virtual AirdragData CreateAirdragData(IAirdragDeclarationInputData airdragData, Mission mission, + Segment segment) + { + throw new NotImplementedException(); + } + + public virtual AxleGearData CreateAxleGearData(IAxleGearInputData axlegearData) + { + throw new NotImplementedException(); + } + + public virtual AngledriveData CreateAngledriveData(IAngledriveInputData angledriveData) + { + throw new NotImplementedException(); + } + + public virtual CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, + IEngineModeDeclarationInputData engineMode, + Mission mission) + { + throw new NotImplementedException(); + } + + public virtual GearboxData CreateGearboxData(IVehicleDeclarationInputData inputData, VectoRunData runData, + IShiftPolygonCalculator shiftPolygonCalc) + { + throw new NotImplementedException(); + } + + public virtual ShiftStrategyParameters CreateGearshiftData(GearboxData gbx, double axleRatio, + PerSecond engineIdlingSpeed) + { + throw new NotImplementedException(); + } + + public virtual RetarderData CreateRetarderData(IRetarderInputData retarderData) + { + throw new NotImplementedException(); + } + + public virtual PTOData CreatePTOTransmissionData(IPTOTransmissionInputData ptoData) + { + throw new NotImplementedException(); + } + + public virtual IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxData, + IBusAuxiliariesDeclarationData busAuxData, + MissionType missionType, VehicleClass vehicleClass, Meter vehicleLength, int? numSteeredAxles) + { + throw new NotImplementedException(); + } + + public virtual AxleGearData CreateDummyAxleGearData(IGearboxDeclarationInputData gbxData) + { + throw new NotImplementedException(); + } + + #endregion + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/PEV_E2.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/PEV_E2.cs new file mode 100644 index 0000000000000000000000000000000000000000..366d6ac6b4fcba36652d32f113b2c660828ec1dd --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/PEV_E2.cs @@ -0,0 +1,11 @@ + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public partial class DeclarationDataAdapterHeavyLorry + { + public class PEV_E2 : DataObjectAdapter.DeclarationDataAdapterHeavyLorry.LorryBase + { + + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/PEV_E3.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/PEV_E3.cs new file mode 100644 index 0000000000000000000000000000000000000000..91528a457140bed8027a7f6f969bf9a7c78da9bc --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/PEV_E3.cs @@ -0,0 +1,11 @@ + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public partial class DeclarationDataAdapterHeavyLorry + { + public class PEV_E3 : DataObjectAdapter.DeclarationDataAdapterHeavyLorry.LorryBase + { + + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/PEV_E4.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/PEV_E4.cs new file mode 100644 index 0000000000000000000000000000000000000000..4dac3f87fc7bb3d2c84fcc82468654270adbf42a --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/PEV_E4.cs @@ -0,0 +1,11 @@ + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public partial class DeclarationDataAdapterHeavyLorry + { + public class PEV_E4 : DataObjectAdapter.DeclarationDataAdapterHeavyLorry.LorryBase + { + + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/PEV_E_IEPC.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/PEV_E_IEPC.cs new file mode 100644 index 0000000000000000000000000000000000000000..61f904f99874244f3131d602c6928e7b05363181 --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/PEV_E_IEPC.cs @@ -0,0 +1,11 @@ + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public partial class DeclarationDataAdapterHeavyLorry + { + public class PEV_E_IEPC : DataObjectAdapter.DeclarationDataAdapterHeavyLorry.LorryBase + { + + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/AbstractDeclarationVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/AbstractDeclarationVectoRunDataFactory.cs index dbf110ae2245df035c2951433021b0d21131f1dd..d138beed0a31644ce709185ff8864306c5dfbf7c 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/AbstractDeclarationVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/AbstractDeclarationVectoRunDataFactory.cs @@ -84,38 +84,6 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl { return; } - _segment = GetSegment(vehicle); - _driverdata = DataAdapter.CreateDriverData(); - _driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(_segment.AccelerationFile); - var tempVehicle = DataAdapter.CreateVehicleData(vehicle, _segment, _segment.Missions.First(), - _segment.Missions.First().Loadings.First(), _allowVocational); - _airdragData = DataAdapter.CreateAirdragData(vehicle.Components.AirdragInputData, - _segment.Missions.First(), _segment); - if (InputDataProvider.JobInputData.Vehicle.AxleConfiguration.AxlegearIncludedInGearbox()) { - _axlegearData = DataAdapter.CreateDummyAxleGearData(InputDataProvider.JobInputData.Vehicle.Components.GearboxInputData); - } else { - _axlegearData = DataAdapter.CreateAxleGearData(InputDataProvider.JobInputData.Vehicle.Components.AxleGearInputData); - } - _angledriveData = DataAdapter.CreateAngledriveData(InputDataProvider.JobInputData.Vehicle.Components.AngledriveInputData); - var tmpRunData = new VectoRunData() { - GearboxData = new GearboxData() { - Type = vehicle.Components.GearboxInputData.Type, - } - }; - var tmpStrategy = PowertrainBuilder.GetShiftStrategy(new SimplePowertrainContainer(tmpRunData)); - var tmpEngine = DataAdapter.CreateEngineData( - vehicle, vehicle.Components.EngineInputData.EngineModes[0], _segment.Missions.First()); - _gearboxData = DataAdapter.CreateGearboxData( - vehicle, new VectoRunData() { EngineData = tmpEngine, AxleGearData = _axlegearData, VehicleData = tempVehicle }, - tmpStrategy); - - _retarderData = DataAdapter.CreateRetarderData(vehicle.Components.RetarderInputData); - - _ptoTransmissionData = DataAdapter.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData); - - _municipalPtoTransmissionData = CreateDefaultPTOData(); - _gearshiftData = DataAdapter.CreateGearshiftData( - _gearboxData, _axlegearData.AxleGear.Ratio * (_angledriveData?.Angledrive.Ratio ?? 1.0), tmpEngine.IdleSpeed); } diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/HeavyLorryRunDataFactory/Conventional.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/HeavyLorryRunDataFactory/Conventional.cs new file mode 100644 index 0000000000000000000000000000000000000000..e27fd01ee567ec9bbcea25db279dffa84b61d881 --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/HeavyLorryRunDataFactory/Conventional.cs @@ -0,0 +1,164 @@ +using System; +using System.Collections.Generic; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.Reader.ComponentData; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.OutputData; + +namespace TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDataFactory +{ + public abstract partial class DeclarationModeHeavyLorryRunDataFactory + { + public class Conventional : LorryBase + { + public Conventional(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + + #region Overrides of LorryBase + + protected override IEnumerable<VectoRunData> GetNextRun() + { + var vehicle = InputDataProvider.JobInputData.Vehicle; + + var engine = InputDataProvider.JobInputData.Vehicle.Components.EngineInputData; + var engineModes = engine.EngineModes; + + for (var modeIdx = 0; modeIdx < engineModes.Count; modeIdx++) { + foreach (var mission in _segment.Missions) { + if (mission.MissionType.IsEMS() && + engine.RatedPowerDeclared.IsSmaller(DeclarationData.MinEnginePowerForEMS)) { + continue; + } + + foreach (var loading in mission.Loadings) { + var simulationRunData = CreateVectoRunData(vehicle, modeIdx, mission, loading, true); + yield return simulationRunData; + } + } + } + } + + private VectoRunData CreateVectoRunData(IVehicleDeclarationInputData vehicle, int modeIdx, Mission mission, + KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) + { + var engine = InputDataProvider.JobInputData.Vehicle.Components.EngineInputData; + var engineModes = engine.EngineModes; + var engineMode = engineModes[modeIdx]; + + var cycle = DeclarationData.CyclesCache.GetOrAdd(mission.MissionType, + _ => DrivingCycleDataReader.ReadFromStream(mission.CycleFile, CycleType.DistanceBased, "", false)); + + var simulationRunData = new VectoRunData { + Loading = loading.Key, + VehicleData = DataAdapter.CreateVehicleData(vehicle, _segment, mission, loading, allowVocational), + VehicleDesignSpeed = _segment.DesignSpeed, + AirdragData = DataAdapter.CreateAirdragData(vehicle.Components.AirdragInputData, mission, _segment), + EngineData = + DataAdapter.CreateEngineData(InputDataProvider.JobInputData.Vehicle, engineMode, + mission), // _engineData.Copy(), // a copy is necessary because every run has a different correction factor! + ElectricMachinesData = new List<Tuple<PowertrainPosition, ElectricMotorData>>(), + GearboxData = _gearboxData, + AxleGearData = _axlegearData, + AngledriveData = _angledriveData, + Aux = DataAdapter.CreateAuxiliaryData( + vehicle.Components.AuxiliaryInputData, + vehicle.Components.BusAuxiliaries, mission.MissionType, + _segment.VehicleClass, vehicle.Length, + vehicle.Components.AxleWheels.NumSteeredAxles), + Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), + Retarder = _retarderData, + DriverData = _driverdata, + ExecutionMode = ExecutionMode.Declaration, + JobName = InputDataProvider.JobInputData.JobName, + ModFileSuffix = (engineModes.Count > 1 ? $"_EngineMode{modeIdx}_" : "") + loading.Key, + Report = Report, + Mission = mission, + PTO = mission.MissionType == MissionType.MunicipalUtility + ? _municipalPtoTransmissionData + : _ptoTransmissionData, + InputDataHash = InputDataProvider.XMLHash, + SimulationType = SimulationType.DistanceCycle, + GearshiftParameters = _gearshiftData, + InputData = InputDataProvider + }; + simulationRunData.EngineData.FuelMode = modeIdx; + simulationRunData.VehicleData.VehicleClass = _segment.VehicleClass; + simulationRunData.VehicleData.InputData = vehicle; + return simulationRunData; + } + #endregion + } + + public class HEV_S4 : LorryBase + { + public HEV_S4(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + } + + public class HEV_S_IEPC : LorryBase + { + public HEV_S_IEPC(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + } + + public class HEV_P1 : LorryBase + { + public HEV_P1(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + } + + public class HEV_P2 : LorryBase + { + public HEV_P2(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + } + + public class HEV_P2_5 : LorryBase + { + public HEV_P2_5(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + } + + public class HEV_P3 : LorryBase + { + public HEV_P3(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + } + + public class HEV_P4 : LorryBase + { + public HEV_P4(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + } + + public class PEV_E2 : LorryBase + { + public PEV_E2(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + } + + public class PEV_E3 : LorryBase + { + public PEV_E3(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + } + + public class PEV_E4 : LorryBase + { + public PEV_E4(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + } + + public class PEV_E_IEPC : LorryBase + { + public PEV_E_IEPC(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/HeavyLorryRunDataFactory/DeclarationModeHeavyLorryRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/HeavyLorryRunDataFactory/DeclarationModeHeavyLorryRunDataFactory.cs new file mode 100644 index 0000000000000000000000000000000000000000..cbdb049b6a5975728e6090b58e679e67427040a8 --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/HeavyLorryRunDataFactory/DeclarationModeHeavyLorryRunDataFactory.cs @@ -0,0 +1,192 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.Reader.ComponentData; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.Simulation.Impl; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Impl; +using TUGraz.VectoCore.OutputData; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDataFactory +{ + + + + /// <summary> + /// This class is just used to improve the readability + /// </summary> + public abstract partial class DeclarationModeHeavyLorryRunDataFactory + { + public abstract class LorryBase : IVectoRunDataFactory + { + + public IDeclarationDataAdapter DataAdapter { get; } + public IDeclarationInputDataProvider InputDataProvider { get; } + + public IDeclarationReport Report { get; } + + protected Segment _segment; + protected DriverData _driverdata; + protected AirdragData _airdragData; + protected AxleGearData _axlegearData; + protected AngledriveData _angledriveData; + protected GearboxData _gearboxData; + protected RetarderData _retarderData; + protected PTOData _ptoTransmissionData; + protected PTOData _municipalPtoTransmissionData; + protected ShiftStrategyParameters _gearshiftData; + + + protected LorryBase(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + IDeclarationDataAdapter declarationDataAdapter) + { + DataAdapter = declarationDataAdapter; + InputDataProvider = dataProvider; + Report = report; + } + + + + + #region Implementation of IVectoRunDataFactory + + public IEnumerable<VectoRunData> NextRun() + { + Initialize(); + if (Report != null) { + InitializeReport(); + } + + return GetNextRun(); + } + + public Segment GetSegment(IVehicleDeclarationInputData vehicle, out bool allowVocational) + { + allowVocational = true; + Segment segment; + try { + segment = DeclarationData.TruckSegments.Lookup( + vehicle.VehicleCategory, vehicle.AxleConfiguration, vehicle.GrossVehicleMassRating, + vehicle.CurbMassChassis, + vehicle.VocationalVehicle); + } catch (VectoException) { + allowVocational = false; + segment = DeclarationData.TruckSegments.Lookup( + vehicle.VehicleCategory, vehicle.AxleConfiguration, vehicle.GrossVehicleMassRating, + vehicle.CurbMassChassis, + false); + } + + if (!segment.Found) { + throw new VectoException( + "no segment found for vehicle configuration: vehicle category: {0}, axle configuration: {1}, GVMR: {2}", + vehicle.VehicleCategory, vehicle.AxleConfiguration, + vehicle.GrossVehicleMassRating); + } + + return segment; + } + + public void Initialize() + { + var vehicle = InputDataProvider.JobInputData.Vehicle; + _segment = GetSegment(vehicle, out var allowVocational); + _driverdata = DataAdapter.CreateDriverData(); + _driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(_segment.AccelerationFile); + var tempVehicle = DataAdapter.CreateVehicleData(vehicle, _segment, _segment.Missions.First(), + _segment.Missions.First().Loadings.First(), allowVocational); + _airdragData = DataAdapter.CreateAirdragData(vehicle.Components.AirdragInputData, + _segment.Missions.First(), _segment); + if (InputDataProvider.JobInputData.Vehicle.AxleConfiguration.AxlegearIncludedInGearbox()) { + _axlegearData = + DataAdapter.CreateDummyAxleGearData(InputDataProvider.JobInputData.Vehicle.Components + .GearboxInputData); + } else { + _axlegearData = + DataAdapter.CreateAxleGearData(InputDataProvider.JobInputData.Vehicle.Components + .AxleGearInputData); + } + + _angledriveData = + DataAdapter.CreateAngledriveData(InputDataProvider.JobInputData.Vehicle.Components + .AngledriveInputData); + var tmpRunData = new VectoRunData() { + GearboxData = new GearboxData() { + Type = vehicle.Components.GearboxInputData.Type, + } + }; + var tmpStrategy = PowertrainBuilder.GetShiftStrategy(new SimplePowertrainContainer(tmpRunData)); + var tmpEngine = DataAdapter.CreateEngineData( + vehicle, vehicle.Components.EngineInputData.EngineModes[0], _segment.Missions.First()); + _gearboxData = DataAdapter.CreateGearboxData( + vehicle, + new VectoRunData() + { EngineData = tmpEngine, AxleGearData = _axlegearData, VehicleData = tempVehicle }, + tmpStrategy); + + _retarderData = DataAdapter.CreateRetarderData(vehicle.Components.RetarderInputData); + + _ptoTransmissionData = + DataAdapter.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData); + + _municipalPtoTransmissionData = CreateDefaultPTOData(); + _gearshiftData = DataAdapter.CreateGearshiftData( + _gearboxData, _axlegearData.AxleGear.Ratio * (_angledriveData?.Angledrive.Ratio ?? 1.0), + tmpEngine.IdleSpeed); + + } + + + protected PTOData CreateDefaultPTOData() + { + return new PTOData() { + TransmissionType = DeclarationData.PTO.DefaultPTOTechnology, + LossMap = PTOIdleLossMapReader.ReadFromStream( + RessourceHelper.ReadStream(DeclarationData.PTO.DefaultPTOIdleLosses)), + PTOCycle = + DrivingCycleDataReader.ReadFromStream( + RessourceHelper.ReadStream(DeclarationData.PTO.DefaultPTOActivationCycle), + CycleType.PTO, "PTO", false) + }; + } + protected abstract VectoRunData CreateVectoRunData(IVehicleDeclarationInputData vehicle, int modeIdx, Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational); + + public virtual void InitializeReport() + { + VectoRunData powertrainConfig; + List<List<FuelData.Entry>> fuels; + var vehicle = InputDataProvider.JobInputData.Vehicle; + if (vehicle.ExemptedVehicle) + { + powertrainConfig = CreateVectoRunData(vehicle, 0, null, new KeyValuePair<LoadingType, Tuple<Kilogram, double?>>()); + fuels = new List<List<FuelData.Entry>>(); + } + else + { + powertrainConfig = _segment.Missions.Select( + mission => CreateVectoRunData( + vehicle, 0, mission, mission.Loadings.First())) + .FirstOrDefault(x => x != null); + fuels = vehicle.Components.EngineInputData.EngineModes.Select(x => x.Fuels.Select(f => DeclarationData.FuelData.Lookup(f.FuelType, vehicle.TankSystem)).ToList()) + .ToList(); + } + Report.InitializeReport(powertrainConfig, fuels); + } + + protected virtual IEnumerable<VectoRunData> GetNextRun() + { + throw new NotImplementedException(); + } + + #endregion + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/HeavyLorryRunDataFactory/HEV_S2.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/HeavyLorryRunDataFactory/HEV_S2.cs new file mode 100644 index 0000000000000000000000000000000000000000..7745e08daba74a263f2facdde66d1beb26c26ec4 --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/HeavyLorryRunDataFactory/HEV_S2.cs @@ -0,0 +1,15 @@ +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; +using TUGraz.VectoCore.OutputData; + +namespace TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDataFactory +{ + public abstract partial class DeclarationModeHeavyLorryRunDataFactory + { + public class HEV_S2 : LorryBase + { + public HEV_S2(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/HeavyLorryRunDataFactory/HEV_S3.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/HeavyLorryRunDataFactory/HEV_S3.cs new file mode 100644 index 0000000000000000000000000000000000000000..01e76adefa16a9d62181f181f65ef6ff892d07ed --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/HeavyLorryRunDataFactory/HEV_S3.cs @@ -0,0 +1,15 @@ +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; +using TUGraz.VectoCore.OutputData; + +namespace TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDataFactory +{ + public abstract partial class DeclarationModeHeavyLorryRunDataFactory + { + public class HEV_S3 : LorryBase + { + public HEV_S3(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs index 8d7d6267cd64254360f5ed896a34664daeb41225..4f39aff811299608d9de51e83a8b133e9daaee59 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs @@ -228,99 +228,4 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl } - - - - - - /// <summary> - /// This class is just used to improve the readability - /// </summary> - public abstract class DeclarationModeHeavyLorryRunDataFactory - { - - - public abstract class LorryBase : IVectoRunDataFactory - { - #region Implementation of IVectoRunDataFactory - - public IEnumerable<VectoRunData> NextRun() - { - throw new NotImplementedException(); - } - - #endregion - } - - public class Conventional : LorryBase - { - - } - - public class HEV_S2 : LorryBase - { - - } - - public class HEV_S3 : LorryBase - { - - } - - public class HEV_S4 : LorryBase - { - - } - - public class HEV_S_IEPC : LorryBase - { - - } - - public class HEV_P1 : LorryBase - { - - } - - public class HEV_P2 : LorryBase - { - - } - - public class HEV_P2_5 : LorryBase - { - - } - - public class HEV_P3 : LorryBase - { - - } - - public class HEV_P4 : LorryBase - { - - } - - public class PEV_E2 : LorryBase - { - - } - - public class PEV_E3 : LorryBase - { - - } - - public class PEV_E4 : LorryBase - { - } - - public class PEV_E_IEPC : LorryBase - { - - } - } - - } diff --git a/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryFactory.cs b/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryFactory.cs index 85bba6467b023443f3214935116d8d84fabe843e..bc242068089772b3b28c0b16a2f019cf9e944ad5 100644 --- a/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryFactory.cs @@ -16,15 +16,15 @@ namespace TUGraz.VectoCore.InputData.Reader { public interface IInternalRunDataFactoryFactory { - IVectoRunDataFactory CreateDeclarationCompletedBusRunDataFactory(VehicleCategory vehicleType, VectoSimulationJobType jobType, - ArchitectureID archId, bool exempted, bool iepc, bool ihpc); - IVectoRunDataFactory CreateDeclarationRunDataFactory(VehicleCategory vehicleType, VectoSimulationJobType jobType, - ArchitectureID archId, bool exempted, bool iepc, bool ihpc); IVectoRunDataFactory CreateDeclarationRunDataFactory(VehicleTypeAndArchitectureStringHelperRundata.VehicleClassification vehicleClassification, IDeclarationInputDataProvider dataProvider, IDeclarationReport report); + IVectoRunDataFactory CreateDeclarationCompletedBusRunDataFactory(VehicleTypeAndArchitectureStringHelperRundata.VehicleClassification vehicleClassification, + IMultistageVIFInputData dataProvider, + IDeclarationReport report); + } @@ -67,19 +67,10 @@ namespace TUGraz.VectoCore.InputData.Reader private IVectoRunDataFactory CreateRunDataReader(IMultistageVIFInputData multistageVifInputData, IDeclarationReport report) { - var vehicle = multistageVifInputData.MultistageJobInputData.PrimaryVehicleData.Vehicle; if (multistageVifInputData.VehicleInputData == null) { - var ihpc = (vehicle.Components?.ElectricMachines?.Entries)?.Count(electric => electric.ElectricMachine.IHPCType != "None") > 0; - var iepc = (vehicle.Components?.IEPC != null); - return _internalFactory.CreateDeclarationRunDataFactory(vehicle.VehicleCategory, - vehicle.VehicleType, - vehicle.ArchitectureID, - vehicle.ExemptedVehicle, iepc, ihpc); - - - //return new DeclarationModeCompletedMultistageBusVectoRunDataFactory( - // multistageVifInputData.MultistageJobInputData, - // report); + return _internalFactory.CreateDeclarationCompletedBusRunDataFactory( + new VehicleTypeAndArchitectureStringHelperRundata.VehicleClassification( + multistageVifInputData), multistageVifInputData, report); } else { return new DeclarationModeMultistageBusVectoRunDataFactory(multistageVifInputData, report); diff --git a/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryNinjectModule.cs b/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryNinjectModule.cs index 730ef216264225ed998b900deba41f1e8c979ffe..fbd6e0359c33fd61aed011fdd031618fe1820e24 100644 --- a/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryNinjectModule.cs +++ b/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryNinjectModule.cs @@ -8,6 +8,7 @@ using Ninject.Modules; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCore.InputData.Reader.Impl; +using TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDataFactory; using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.Utils.Ninject; diff --git a/VectoCore/VectoCore/Models/GenericModelData/GenericBusEngineData.cs b/VectoCore/VectoCore/Models/GenericModelData/GenericBusEngineData.cs index f8356328e0ba18d8bfceb155b7750c0f5db54ed8..b0e5b91229de2228381bd7a4627db88262f5a08f 100644 --- a/VectoCore/VectoCore/Models/GenericModelData/GenericBusEngineData.cs +++ b/VectoCore/VectoCore/Models/GenericModelData/GenericBusEngineData.cs @@ -70,8 +70,8 @@ namespace TUGraz.VectoCore.Models.Declaration foreach (var gear in gearbox.Gears) { var maxTorque = VectoMath.Min( - DeclarationDataAdapterHeavyLorry.GbxMaxTorque(gear, numGears, fullLoadCurves[0].MaxTorque), - DeclarationDataAdapterHeavyLorry.VehMaxTorque(gear, numGears, limits, fullLoadCurves[0].MaxTorque)); + DeclarationDataAdapterHeavyLorry.Conventional.GbxMaxTorque(gear, numGears, fullLoadCurves[0].MaxTorque), + DeclarationDataAdapterHeavyLorry.Conventional.VehMaxTorque(gear, numGears, limits, fullLoadCurves[0].MaxTorque)); fullLoadCurves[(uint)gear.Gear] = AbstractSimulationDataAdapter.IntersectFullLoadCurves(fullLoadCurves[0], maxTorque); } diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory/SimulatorFactoryDeclaration.cs b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory/SimulatorFactoryDeclaration.cs index 503c1aae973845b91d4fe498e948264abe40b0bf..57130ddcfa7d59abcb6ad4e12d9fb9aa9049c1f3 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory/SimulatorFactoryDeclaration.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory/SimulatorFactoryDeclaration.cs @@ -141,114 +141,5 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory } return null; } - - private void CreateDeclarationDataReader(IInputDataProvider dataProvider, IDeclarationReport declarationReport, IVTPReport vtpReport) - { - switch (dataProvider) { - case IVTPDeclarationInputDataProvider vtpProvider: { - RunDataFactory = CreateRunDataReader(vtpProvider, vtpReport); - return; - } - case ISingleBusInputDataProvider singleBusProvider: { - RunDataFactory = CreateRunDataReader(singleBusProvider, declarationReport); - return; - } - case IDeclarationInputDataProvider declDataProvider: { - RunDataFactory = CreateRunDataReader(declDataProvider, declarationReport); - return; - } - case IMultistageVIFInputData multistageVifInputData: { - RunDataFactory = CreateRunDataReader(multistageVifInputData, declarationReport); - return; - } - case IMultistagePrimaryAndStageInputDataProvider multiStagePrimaryAndStageInputData: { - - throw new VectoException("Simulation should be split up in separate steps"); - } - default: - throw new VectoException("Unknown InputData for Declaration Mode!"); - } - } - - private IVectoRunDataFactory CreateRunDataReader(IMultistageVIFInputData multistageVifInputData, IDeclarationReport declarationReport) - { - if (multistageVifInputData.VehicleInputData == null) - { - //THIS DOESN'T WORK :/ - var reportCompleted = declarationReport; //; new XMLDeclarationReportCompletedVehicle(ReportWriter, true) - //{ - // PrimaryVehicleReportInputData = multistageVifInputData.MultistageJobInputData.JobInputData.PrimaryVehicle, - //}; - return new DeclarationModeCompletedMultistageBusVectoRunDataFactory( - multistageVifInputData.MultistageJobInputData, - reportCompleted); - } else { - var report = declarationReport;// ?? new XMLDeclarationReportMultistageBusVehicle(ReportWriter); - return new DeclarationModeMultistageBusVectoRunDataFactory(multistageVifInputData, report); - - - } - } - - private IVectoRunDataFactory CreateRunDataReader(IDeclarationInputDataProvider declDataProvider, - IDeclarationReport declarationReport) - { - var vehicleCategory = declDataProvider.JobInputData.Vehicle.VehicleCategory; - if(vehicleCategory.IsLorry()) { - var report = declarationReport ?? new XMLDeclarationReport(ReportWriter); - return new DeclarationModeTruckVectoRunDataFactory(declDataProvider, report); - } - - if(vehicleCategory.IsBus()) - switch (declDataProvider.JobInputData.Vehicle.VehicleCategory) - { - case VehicleCategory.HeavyBusCompletedVehicle: - var reportCompleted = declarationReport; - //?? - //new XMLDeclarationReportCompletedVehicle(ReportWriter, - // declDataProvider.JobInputData.Vehicle.VehicleCategory == VehicleCategory.HeavyBusPrimaryVehicle) - //{ - // PrimaryVehicleReportInputData = declDataProvider.PrimaryVehicleData, - //}; - return new DeclarationModeCompletedBusVectoRunDataFactory(declDataProvider, reportCompleted); - case VehicleCategory.HeavyBusPrimaryVehicle: - var reportPrimary = declarationReport; - //?? - // new XMLDeclarationReportPrimaryVehicle(ReportWriter, - // declDataProvider.JobInputData.Vehicle.VehicleCategory == VehicleCategory.HeavyBusPrimaryVehicle); - return new DeclarationModePrimaryBusVectoRunDataFactory(declDataProvider, reportPrimary); - - default: - - break; - } - - throw new Exception( - $"Could not create RunDataFactory for Vehicle Category{vehicleCategory}"); - } - - private IVectoRunDataFactory CreateRunDataReader(ISingleBusInputDataProvider singleBusProvider, - IDeclarationReport declarationReport) - { - var report = declarationReport ?? new XMLDeclarationReport(ReportWriter); - return new DeclarationModeSingleBusVectoRunDataFactory(singleBusProvider, report); - } - - private IVectoRunDataFactory CreateRunDataReader(IVTPDeclarationInputDataProvider vtpProvider, - IVTPReport vtpReport) - { - var report = vtpReport ?? new XMLVTPReport(ReportWriter); - if (vtpProvider.JobInputData.Vehicle.VehicleCategory.IsLorry()) { - return new DeclarationVTPModeVectoRunDataFactoryLorries(vtpProvider, report); - } - - if (vtpProvider.JobInputData.Vehicle.VehicleCategory.IsBus()) { - return new DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary(vtpProvider, report); - } - - throw new Exception( - $"Could not create RunDataFactory for Vehicle Category{vtpProvider.JobInputData.Vehicle.VehicleCategory}"); - } - } } diff --git a/VectoCore/VectoCore/Ninject/NinjectModules.cd b/VectoCore/VectoCore/Ninject/NinjectModules.cd index a735967b9cedb31d287bb0efe8784afb99633102..8a544d423fcc997a3b59f46ac66accfae4269ce2 100644 --- a/VectoCore/VectoCore/Ninject/NinjectModules.cd +++ b/VectoCore/VectoCore/Ninject/NinjectModules.cd @@ -1,56 +1,56 @@ <?xml version="1.0" encoding="utf-8"?> <ClassDiagram MajorVersion="1" MinorVersion="1"> <Class Name="TUGraz.VectoCore.AbstractNinjectModule" Collapsed="true"> - <Position X="1.75" Y="2.25" Width="1.5" /> + <Position X="1.75" Y="2.25" Width="1.75" /> <TypeIdentifier> <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAA=</HashCode> <FileName>Ninject\VectoNinjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.VectoNinjectModule" Collapsed="true"> - <Position X="9.75" Y="3.5" Width="1.5" /> + <Position X="9.75" Y="3.5" Width="1.75" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAA=</HashCode> <FileName>Ninject\VectoNinjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.Models.Simulation.SimulatorFactoryNinjectModule" Collapsed="true"> - <Position X="4.5" Y="5.5" Width="1.5" /> + <Position X="4.5" Y="5.5" Width="2.5" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>Models\Simulation\SimulationFactoryNinjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.InputData.FileIO.XML.XMLInputDataNinjectModule" Collapsed="true"> - <Position X="12" Y="3.5" Width="1.5" /> + <Position X="12" Y="3.5" Width="2.25" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>InputData\FileIO\XML\XMLInputDataNinjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.OutputData.XML.ComponentWriter.ComponentWriterNinjectModule" Collapsed="true"> - <Position X="14.25" Y="3.5" Width="1.5" /> + <Position X="14.25" Y="3.5" Width="2.5" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAA=</HashCode> <FileName>OutputData\XML\ComponentWriter\ComponentWriterNinjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport.ManufacturerReport_0_9.MRFNinjectModule" Collapsed="true"> - <Position X="16.5" Y="3.5" Width="1.5" /> + <Position X="16.5" Y="3.5" Width="1.75" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAQAABAAAAAAAABAAAAAAAAA=</HashCode> <FileName>OutputData\XML\DeclarationReports\ManufacturerReport\ManufacturerReport_0_9\MRFNinjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.OutputData.XML.GroupWriter.GroupWriterNinjectModule" Collapsed="true"> - <Position X="18.75" Y="3.5" Width="1.5" /> + <Position X="18.75" Y="3.5" Width="2.25" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAA=</HashCode> <FileName>OutputData\XML\GroupWriter\XMLGroupWriterNinjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.OutputData.XML.XMLDeclarationReportFactoryNinjectModule" Collapsed="true"> - <Position X="21" Y="3.5" Width="1.5" /> + <Position X="21" Y="3.5" Width="3.25" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>OutputData\XML\XMLDeclarationReportFactoryNinjectModule.cs</FileName> @@ -71,9 +71,9 @@ </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.InputData.Reader.VectoRunDataFactoryNinjectModule" Collapsed="true"> - <Position X="7.5" Y="3.5" Width="1.5" /> + <Position X="7.5" Y="3.5" Width="2.75" /> <TypeIdentifier> - <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAA=</HashCode> + <HashCode>AAAAgAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>InputData\Reader\VectoRunDataFactoryNinjectModule.cs</FileName> </TypeIdentifier> </Class> @@ -83,105 +83,105 @@ <Lollipop Position="0.2" /> </Class> <Class Name="TUGraz.VectoCore.InputData.FileIO.XML.Declaration.NinjectModules.XMLDeclarationInputDataMultistageV01InjectModule" Collapsed="true"> - <Position X="4.5" Y="2.25" Width="1.5" /> + <Position X="4.5" Y="2.25" Width="3.75" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>InputData\FileIO\XML\Declaration\NinjectModules\XMLDeclarationInputDataMultistageV01InjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.InputData.FileIO.XML.Declaration.NinjectModules.XMLDeclarationInputDataV10InjectModule" Collapsed="true"> - <Position X="24" Y="2.25" Width="1.5" /> + <Position X="24" Y="2.25" Width="3" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>InputData\FileIO\XML\Declaration\NinjectModules\XMLDeclarationInputDataV10InjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.InputData.FileIO.XML.Declaration.NinjectModules.XMLDeclarationInputDataV20InjectModule" Collapsed="true"> - <Position X="26.25" Y="2.25" Width="1.5" /> + <Position X="26.25" Y="2.25" Width="3" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>InputData\FileIO\XML\Declaration\NinjectModules\XMLDeclarationInputDataV20InjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.InputData.FileIO.XML.Declaration.NinjectModules.XMLDeclarationInputDataV21InjectModule" Collapsed="true"> - <Position X="28.5" Y="2.25" Width="1.5" /> + <Position X="28.5" Y="2.25" Width="3" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>InputData\FileIO\XML\Declaration\NinjectModules\XMLDeclarationInputDataV21InjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.InputData.FileIO.XML.Declaration.NinjectModules.XMLDeclarationInputDataV221InjectModule" Collapsed="true"> - <Position X="30.75" Y="2.25" Width="1.5" /> + <Position X="30.75" Y="2.25" Width="3.25" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>InputData\FileIO\XML\Declaration\NinjectModules\XMLDeclarationInputDataV221InjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.InputData.FileIO.XML.Declaration.NinjectModules.XMLDeclarationInputDataV22InjectModule" Collapsed="true"> - <Position X="33" Y="2.25" Width="1.5" /> + <Position X="33" Y="2.25" Width="3" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>InputData\FileIO\XML\Declaration\NinjectModules\XMLDeclarationInputDataV22InjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.InputData.FileIO.XML.Declaration.NinjectModules.XMLDeclarationInputDataV23InjectModule" Collapsed="true"> - <Position X="35.25" Y="2.25" Width="1.5" /> + <Position X="35.25" Y="2.25" Width="3" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>InputData\FileIO\XML\Declaration\NinjectModules\XMLDeclarationInputDataV23InjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.InputData.FileIO.XML.Declaration.NinjectModules.XMLDeclarationInputDataV24InjectModule" Collapsed="true"> - <Position X="37.5" Y="2.25" Width="1.5" /> + <Position X="37.5" Y="2.25" Width="3" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>InputData\FileIO\XML\Declaration\NinjectModules\XMLDeclarationInputDataV24InjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.InputData.FileIO.XML.Declaration.XMLDeclarationReaderInjectModule" Collapsed="true"> - <Position X="39.75" Y="2.25" Width="1.5" /> + <Position X="39.75" Y="2.25" Width="2.75" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>InputData\FileIO\XML\Declaration\NinjectModules\XMLDeclarationReaderInjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.InputData.FileIO.XML.Engineering.XMLEngineeringReaderInjectModule" Collapsed="true"> - <Position X="42" Y="2.25" Width="1.5" /> + <Position X="42" Y="2.25" Width="2.75" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>InputData\FileIO\XML\Engineering\NinjectModules\XMLEngineeringReaderInjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.InputData.FileIO.XML.Engineering.NinjectModules.XMLEngineeringReaderTestOverrides" Collapsed="true"> - <Position X="44.25" Y="2.25" Width="1.5" /> + <Position X="44.25" Y="2.25" Width="2.75" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>InputData\FileIO\XML\Engineering\NinjectModules\XMLEngineeringReaderTestOverrides.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.InputData.FileIO.XML.Engineering.NinjectModules.XMLEngineeringReaderV07InjectModule" Collapsed="true"> - <Position X="46.5" Y="2.25" Width="1.5" /> + <Position X="46.5" Y="2.25" Width="3" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>InputData\FileIO\XML\Engineering\NinjectModules\XMLEngineeringReaderV07InjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.InputData.FileIO.XML.Engineering.NinjectModules.XMLEngineeringReaderV10InjectModule" Collapsed="true"> - <Position X="48.75" Y="2.25" Width="1.5" /> + <Position X="48.75" Y="2.25" Width="3" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>InputData\FileIO\XML\Engineering\NinjectModules\XMLEngineeringReaderV10InjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.InputData.FileIO.XML.Engineering.NinjectModules.XMLEngineeringReaderV11InjectModule" Collapsed="true"> - <Position X="51" Y="2.25" Width="1.5" /> + <Position X="51" Y="2.25" Width="3" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>InputData\FileIO\XML\Engineering\NinjectModules\XMLEngineeringReaderV10InjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.InputData.Reader.VectoRunDataFactoryFactory"> - <Position X="2.75" Y="4" Width="1.5" /> + <Position X="2.75" Y="4" Width="3" /> <Compartments> <Compartment Name="Nested Types" Collapsed="false" /> </Compartments> @@ -192,21 +192,21 @@ <Lollipop Position="0.2" /> </Class> <Class Name="TUGraz.VectoCore.OutputData.XML.NinjectModules.XMLEngineeringWriterTestOverrides" Collapsed="true"> - <Position X="53.25" Y="2.25" Width="1.5" /> + <Position X="53.25" Y="2.25" Width="2.75" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>OutputData\XML\Engineering\NinjectModules\XMLEngineeringWriterTestOverrides.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.OutputData.XML.NinjectModules.XMLEngineeringWriterV10InjectModule" Collapsed="true"> - <Position X="55.5" Y="2.25" Width="1.5" /> + <Position X="55.5" Y="2.25" Width="3" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>OutputData\XML\Engineering\NinjectModules\XMLEngineeringWriterV10InjectModule.cs</FileName> </TypeIdentifier> </Class> <Class Name="TUGraz.VectoCore.OutputData.XML.Engineering.XMLEngineeringWriterInjectModule" Collapsed="true"> - <Position X="57.75" Y="2.25" Width="1.5" /> + <Position X="57.75" Y="2.25" Width="2.75" /> <TypeIdentifier> <HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> <FileName>OutputData\XML\Engineering\XMLEngineeringWriterInjectModule.cs</FileName> diff --git a/VectoCore/VectoCore/Ninject/VectoNinjectModule.cs b/VectoCore/VectoCore/Ninject/VectoNinjectModule.cs index aa699476a03a38eb67927183aa39a35c2ac7ec89..60e712a330bbd6b274a9b7a43fecb1f11025a87c 100644 --- a/VectoCore/VectoCore/Ninject/VectoNinjectModule.cs +++ b/VectoCore/VectoCore/Ninject/VectoNinjectModule.cs @@ -36,6 +36,7 @@ using System.Reflection; using Ninject.Modules; using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.Reader; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.OutputData.XML; using TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformationFile.CustomerInformationFile_0_9; @@ -86,6 +87,8 @@ namespace TUGraz.VectoCore LoadModule<VectoRunDataFactoryNinjectModule>(); + LoadModule<DeclarationDataAdapterNinjectModule>(); + LoadModule<GroupWriterNinjectModule>(); LoadModule<ComponentWriterNinjectModule>(); @@ -93,7 +96,9 @@ namespace TUGraz.VectoCore LoadModule<SimulatorFactoryNinjectModule>(); LoadModule<MRFNinjectModule>(); + LoadModule<CIFNinjectModule>(); + LoadModule<VIFNinjectModule>(); diff --git a/VectoCore/VectoCore/Utils/Ninject/VehicleTypeAndArchitectureStringHelper.cs b/VectoCore/VectoCore/Utils/Ninject/VehicleTypeAndArchitectureStringHelper.cs index 1ffc336f72caf52273d0eaf8c1c6d090df951fbe..99bf7c53dce67edf8448a70cd0abe3e7dbc988f0 100644 --- a/VectoCore/VectoCore/Utils/Ninject/VehicleTypeAndArchitectureStringHelper.cs +++ b/VectoCore/VectoCore/Utils/Ninject/VehicleTypeAndArchitectureStringHelper.cs @@ -136,10 +136,12 @@ namespace TUGraz.VectoCore.Utils.Ninject JobType = jobType; } - public VehicleClassification(IVehicleDeclarationInputData inputData) + public VehicleClassification(IVehicleDeclarationInputData inputData) : this() { - Iepc = (inputData.Components?.ElectricMachines?.Entries)?.Count(electric => electric.ElectricMachine.IHPCType != "None") > 0; - Ihpc = (inputData.Components?.IEPC != null); + //Iepc = (inputData.Components?.ElectricMachines?.Entries)?.Count(electric => electric.ElectricMachine.IHPCType != "None") > 0; + //Ihpc = (inputData.Components?.IEPC != null); + Iepc = false; + Ihpc = false; Exempted = inputData.ExemptedVehicle; VehicleType = inputData.VehicleCategory.GetVehicleType(); ArchId = inputData.ArchitectureID; @@ -147,6 +149,21 @@ namespace TUGraz.VectoCore.Utils.Ninject } + + public VehicleClassification(IMultistageVIFInputData inputData) : this() + { + //Iepc = (inputData.MultistageJobInputData..Components?.ElectricMachines?.Entries)?.Count(electric => electric.ElectricMachine.IHPCType != "None") > 0; + //Ihpc = (inputData.Components?.IEPC != null); + Iepc = false; + Ihpc = false; + Exempted = inputData.MultistageJobInputData.JobInputData.PrimaryVehicle.Vehicle.ExemptedVehicle; + VehicleType = inputData.MultistageJobInputData.JobInputData.ConsolidateManufacturingStage.Vehicle.VehicleCategory.GetVehicleType(); + ArchId = inputData.MultistageJobInputData.JobInputData.PrimaryVehicle.Vehicle.ArchitectureID; + JobType = inputData.MultistageJobInputData.JobInputData.PrimaryVehicle.Vehicle.VehicleType; + + //inputData.MultistageJobInputData.JobInputData.ConsolidateManufacturingStage. + } + public bool Equals(VehicleClassification other) { return JobType == other.JobType && ArchId == other.ArchId && VehicleType == other.VehicleType && Exempted == other.Exempted && Iepc == other.Iepc && Ihpc == other.Ihpc; diff --git a/VectoCore/VectoCoreTest/InputData/RunDataFactory/RunDataFactoryFactoryTest.cs b/VectoCore/VectoCoreTest/InputData/RunDataFactory/RunDataFactoryFactoryTest.cs index dea19217bc50ea8761876908a5f73fe505f0dc67..b4444c669ff787cd81e0a1351ed46aa895e711ab 100644 --- a/VectoCore/VectoCoreTest/InputData/RunDataFactory/RunDataFactoryFactoryTest.cs +++ b/VectoCore/VectoCoreTest/InputData/RunDataFactory/RunDataFactoryFactoryTest.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Xml.XPath; using Moq; using Ninject; using NUnit.Framework; @@ -10,7 +11,9 @@ using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCore.InputData; using TUGraz.VectoCore.InputData.Reader; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; using TUGraz.VectoCore.InputData.Reader.Impl; +using TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDataFactory; namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory { @@ -28,141 +31,169 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory Assert.Ignore("Tests not meaningful in mockup mode"); #endif var kernel = new StandardKernel(new VectoNinjectModule()) { - }; + + kernel.Bind<IDeclarationDataAdapter>().ToMethod( + x => { + var mock = new Mock<IDeclarationDataAdapter>(); + return mock.Object; + }); _runDataFactoryFactory = kernel.Get<IVectoRunDataFactoryFactory>(); + Assert.IsTrue(_runDataFactoryFactory.GetType() == typeof(VectoRunDataFactoryFactory)); } - private void CreateRunDataFactory(Mock<IDeclarationInputDataProvider> inputMock, Type expectedType) + private void CreateRunDataFactory(Mock inputMock, Type expectedRunDataType, Type expectedDeclarationDataAdapterType = null) { - var result = _runDataFactoryFactory.CreateDeclarationRunDataFactory(inputMock.Object, null, + var s = inputMock.Object; + var result = _runDataFactoryFactory.CreateDeclarationRunDataFactory((IInputDataProvider)inputMock.Object, null, null); - Assert.IsTrue(result.GetType() == expectedType); + Assert.IsTrue(result.GetType() == expectedRunDataType, $"Invalid type of RunDataFactory! Expected {expectedRunDataType} got {result.GetType()}"); + if (expectedDeclarationDataAdapterType != null) { + dynamic concreteResult = result; + Assert.IsTrue(concreteResult.DeclarationDataAdapter.GetType() == expectedDeclarationDataAdapterType, $"Invalid type of DeclarationDataAdapter! Expected {expectedDeclarationDataAdapterType} got {concreteResult.DeclarationDataAdapter.GetType()}"); + } } #region HeavyLorry [TestCase()] - public void ConventionalHeavyLorryTest() + [TestCase(typeof(DeclarationDataAdapterHeavyLorry.Conventional))] + public void ConventionalHeavyLorryTest(Type expectedDataAdapter = null) { var input = new Mock<IDeclarationInputDataProvider>() .Conventional() .Lorry(); - CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.Conventional)); + CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.Conventional), expectedDataAdapter); } [TestCase()] - public void HEV_S2_HeavyLorryTest() + [TestCase(typeof(DeclarationDataAdapterHeavyLorry.HEV_S2))] + public void HEV_S2_HeavyLorryTest(Type expectedDataAdapter = null) { var input = new Mock<IDeclarationInputDataProvider>() .HEV(ArchitectureID.S2) .Lorry(); - CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_S2)); + CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_S2), expectedDataAdapter); } [TestCase()] - public void HEV_S3_HeavyLorryTest() + [TestCase(typeof(DeclarationDataAdapterHeavyLorry.HEV_S3))] + + public void HEV_S3_HeavyLorryTest(Type expectedDataAdapter = null) { var input = new Mock<IDeclarationInputDataProvider>() .HEV(ArchitectureID.S3) .Lorry(); - CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_S3)); + CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_S3), expectedDataAdapter); } [TestCase()] - public void HEV_S4_HeavyLorryTest() + [TestCase(typeof(DeclarationDataAdapterHeavyLorry.HEV_S4))] + public void HEV_S4_HeavyLorryTest(Type expectedDataAdapter = null) { var input = new Mock<IDeclarationInputDataProvider>() .HEV(ArchitectureID.S4) .Lorry(); - CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_S4)); + CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_S4), expectedDataAdapter); } [TestCase()] - public void HEV_S_IEPC_HeavyLorryTest() + [TestCase(typeof(DeclarationDataAdapterHeavyLorry.HEV_S_IEPC))] + public void HEV_S_IEPC_HeavyLorryTest(Type expectedDataAdapter = null) { var input = new Mock<IDeclarationInputDataProvider>() .HEV(ArchitectureID.S_IEPC) .Lorry(); - CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_S_IEPC)); + CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_S_IEPC), expectedDataAdapter); } + [TestCase()] - public void HEV_P1_HeavyLorryTest() + [TestCase(typeof(DeclarationDataAdapterHeavyLorry.HEV_P1))] + public void HEV_P1_HeavyLorryTest(Type expectedDataAdapter = null) { var input = new Mock<IDeclarationInputDataProvider>() .HEV(ArchitectureID.P1) .Lorry(); - CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_P1)); + CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_P1), expectedDataAdapter); } [TestCase()] - public void HEV_P2_HeavyLorryTest() + [TestCase(typeof(DeclarationDataAdapterHeavyLorry.HEV_P2))] + public void HEV_P2_HeavyLorryTest(Type expectedDataAdapter = null) { var input = new Mock<IDeclarationInputDataProvider>() .HEV(ArchitectureID.P2) .Lorry(); - CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_P2)); + CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_P2), expectedDataAdapter); } [TestCase()] - public void HEV_P2_5_HeavyLorryTest() + [TestCase(typeof(DeclarationDataAdapterHeavyLorry.HEV_P2_5))] + public void HEV_P2_5_HeavyLorryTest(Type expectedDataAdapter = null) { var input = new Mock<IDeclarationInputDataProvider>() .HEV(ArchitectureID.P2_5) .Lorry(); - CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_P2_5)); + CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_P2_5), expectedDataAdapter); } [TestCase()] - public void HEV_P3_HeavyLorryTest() + [TestCase(typeof(DeclarationDataAdapterHeavyLorry.HEV_P3))] + public void HEV_P3_HeavyLorryTest(Type expectedDataAdapter = null) { var input = new Mock<IDeclarationInputDataProvider>() .HEV(ArchitectureID.P3) .Lorry(); - CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_P3)); + CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_P3), expectedDataAdapter); } [TestCase()] - public void HEV_P4_HeavyLorryTest() + [TestCase(typeof(DeclarationDataAdapterHeavyLorry.HEV_P4))] + public void HEV_P4_HeavyLorryTest(Type expectedDataAdapter = null) { var input = new Mock<IDeclarationInputDataProvider>() .HEV(ArchitectureID.P4) .Lorry(); - CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_P4)); + CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.HEV_P4), expectedDataAdapter); } [TestCase()] - public void PEV_E2_HeavyLorryTest() + [TestCase(typeof(DeclarationDataAdapterHeavyLorry.PEV_E2))] + public void PEV_E2_HeavyLorryTest(Type expectedDataAdapter = null) { var input = new Mock<IDeclarationInputDataProvider>() .PEV(ArchitectureID.E2) .Lorry(); - CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.PEV_E2)); + CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.PEV_E2), expectedDataAdapter); } [TestCase()] - public void PEV_E3_HeavyLorryTest() + [TestCase(typeof(DeclarationDataAdapterHeavyLorry.PEV_E3))] + public void PEV_E3_HeavyLorryTest(Type expectedDataAdapter = null) { var input = new Mock<IDeclarationInputDataProvider>() .PEV(ArchitectureID.E3) .Lorry(); - CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.PEV_E3)); + CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.PEV_E3), expectedDataAdapter); } [TestCase()] - public void PEV_E4_HeavyLorryTest() + [TestCase(typeof(DeclarationDataAdapterHeavyLorry.PEV_E4))] + public void PEV_E4_HeavyLorryTest(Type expectedDataAdapter = null) { var input = new Mock<IDeclarationInputDataProvider>() .PEV(ArchitectureID.E4) .Lorry(); - CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.PEV_E4)); + CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.PEV_E4), expectedDataAdapter); } [TestCase()] - public void PEV_E_IEPC_HeavyLorryTest() + [TestCase(typeof(DeclarationDataAdapterHeavyLorry.PEV_E_IEPC))] + public void PEV_E_IEPC_HeavyLorryTest(Type expectedDataAdapter = null) { var input = new Mock<IDeclarationInputDataProvider>() .PEV(ArchitectureID.E_IEPC) .Lorry(); - CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.PEV_E_IEPC)); + CreateRunDataFactory(input, typeof(DeclarationModeHeavyLorryRunDataFactory.PEV_E_IEPC), expectedDataAdapter); + } @@ -299,139 +330,140 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory CreateRunDataFactory(input, typeof(DeclarationModePrimaryBusRunDataFactory.PEV_E_IEPC)); } -#endregion PrimaryBus - - [TestCase()] - public void ConventionalCompletedBus() - { - var input = new Mock<IDeclarationInputDataProvider>() - .Conventional() - .CompletedBus(); - CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.Conventional)); - } - - [TestCase()] - public void HEV_S2_CompletedBus() - { - var input = new Mock<IDeclarationInputDataProvider>() - .HEV(ArchitectureID.S2) - .CompletedBus(); - CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_S2)); - } - - [TestCase()] - public void HEV_S3_CompletedBus() - { - var input = new Mock<IDeclarationInputDataProvider>() - .HEV(ArchitectureID.S3) - .CompletedBus(); - CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_S3)); - } - - [TestCase()] - public void HEV_S4_CompletedBus() - { - var input = new Mock<IDeclarationInputDataProvider>() - .HEV(ArchitectureID.S4) - .CompletedBus(); - CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_S4)); - } - - [TestCase()] - public void HEV_S_IEPC_CompletedBus() - { - var input = new Mock<IDeclarationInputDataProvider>() - .HEV(ArchitectureID.S_IEPC) - .CompletedBus(); - CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_S_IEPC)); - } - - [TestCase()] - public void HEV_P1_CompletedBus() - { - var input = new Mock<IDeclarationInputDataProvider>() - .HEV(ArchitectureID.P1) - .CompletedBus(); - CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_P1)); - } - - - [TestCase()] - public void HEV_P2_CompletedBus() - { - var input = new Mock<IDeclarationInputDataProvider>() - .HEV(ArchitectureID.S2) - .CompletedBus(); - CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_S2)); - } - - - [TestCase()] - public void HEV_P3_CompletedBus() - { - var input = new Mock<IDeclarationInputDataProvider>() - .HEV(ArchitectureID.P3) - .CompletedBus(); - CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_P3)); - } - - - [TestCase()] - public void HEV_P2_5_CompletedBus() - { - var input = new Mock<IDeclarationInputDataProvider>() - .HEV(ArchitectureID.P2_5) - .CompletedBus(); - CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_P2_5)); - } - - - [TestCase()] - public void HEV_P4_CompletedBus() - { - var input = new Mock<IDeclarationInputDataProvider>() - .HEV(ArchitectureID.P4) - .CompletedBus(); - CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_P4)); - } - - - [TestCase()] - public void PEV_E2_CompletedBus() - { - var input = new Mock<IDeclarationInputDataProvider>() - .PEV(ArchitectureID.E2) - .CompletedBus(); - CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.PEV_E2)); - } - - - [TestCase()] - public void PEV_E3_CompletedBus() - { - var input = new Mock<IDeclarationInputDataProvider>() - .PEV(ArchitectureID.E3) - .CompletedBus(); - CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.PEV_E3)); - } - [TestCase()] - public void PEV_E4_CompletedBus() - { - var input = new Mock<IDeclarationInputDataProvider>() - .PEV(ArchitectureID.E4) - .CompletedBus(); - CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.PEV_E4)); - } - - [TestCase()] - public void PEV_E_IEPC_CompletedBus() - { - var input = new Mock<IDeclarationInputDataProvider>() - .PEV(ArchitectureID.E_IEPC) - .CompletedBus(); - CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.PEV_E_IEPC)); - } - } + #endregion PrimaryBus + #region CompletedBus + [TestCase()] + public void ConventionalCompletedBus() + { + var input = new Mock<IMultistageVIFInputData>() + .Conventional() + .CompletedBus(); + CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.Conventional)); + } + + [TestCase()] + public void HEV_S2_CompletedBus() + { + var input = new Mock<IMultistageVIFInputData>() + .HEV(ArchitectureID.S2) + .CompletedBus(); + CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_S2)); + } + + [TestCase()] + public void HEV_S3_CompletedBus() + { + var input = new Mock<IMultistageVIFInputData>() + .HEV(ArchitectureID.S3) + .CompletedBus(); + CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_S3)); + } + + [TestCase()] + public void HEV_S4_CompletedBus() + { + var input = new Mock<IMultistageVIFInputData>() + .HEV(ArchitectureID.S4) + .CompletedBus(); + CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_S4)); + } + + [TestCase()] + public void HEV_S_IEPC_CompletedBus() + { + var input = new Mock<IMultistageVIFInputData>() + .HEV(ArchitectureID.S_IEPC) + .CompletedBus(); + CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_S_IEPC)); + } + + [TestCase()] + public void HEV_P1_CompletedBus() + { + var input = new Mock<IMultistageVIFInputData>() + .HEV(ArchitectureID.P1) + .CompletedBus(); + CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_P1)); + } + + + [TestCase()] + public void HEV_P2_CompletedBus() + { + var input = new Mock<IMultistageVIFInputData>() + .HEV(ArchitectureID.S2) + .CompletedBus(); + CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_S2)); + } + + + [TestCase()] + public void HEV_P3_CompletedBus() + { + var input = new Mock<IMultistageVIFInputData>() + .HEV(ArchitectureID.P3) + .CompletedBus(); + CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_P3)); + } + + + [TestCase()] + public void HEV_P2_5_CompletedBus() + { + var input = new Mock<IMultistageVIFInputData>() + .HEV(ArchitectureID.P2_5) + .CompletedBus(); + CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_P2_5)); + } + + + [TestCase()] + public void HEV_P4_CompletedBus() + { + var input = new Mock<IMultistageVIFInputData>() + .HEV(ArchitectureID.P4) + .CompletedBus(); + CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_P4)); + } + + + [TestCase()] + public void PEV_E2_CompletedBus() + { + var input = new Mock<IMultistageVIFInputData>() + .PEV(ArchitectureID.E2) + .CompletedBus(); + CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.PEV_E2)); + } + + + [TestCase()] + public void PEV_E3_CompletedBus() + { + var input = new Mock<IMultistageVIFInputData>() + .PEV(ArchitectureID.E3) + .CompletedBus(); + CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.PEV_E3)); + } + [TestCase()] + public void PEV_E4_CompletedBus() + { + var input = new Mock<IMultistageVIFInputData>() + .PEV(ArchitectureID.E4) + .CompletedBus(); + CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.PEV_E4)); + } + + [TestCase()] + public void PEV_E_IEPC_CompletedBus() + { + var input = new Mock<IMultistageVIFInputData>() + .PEV(ArchitectureID.E_IEPC) + .CompletedBus(); + CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.PEV_E_IEPC)); + } + #endregion CompletedBus + } internal static class InputDataProviderMockExtension { @@ -489,13 +521,51 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory return mock; } - internal static Mock<IDeclarationInputDataProvider> CompletedBus(this Mock<IDeclarationInputDataProvider> mock) + internal static Mock<IMultistageVIFInputData> Conventional(this Mock<IMultistageVIFInputData> mock) { - mock.Setup(p => p.JobInputData.Vehicle.VehicleCategory). - Returns(VehicleCategory.HeavyBusCompletedVehicle); + mock.Setup(p => p.MultistageJobInputData.JobInputData.PrimaryVehicle.Vehicle.VehicleType) + .Returns(VectoSimulationJobType.ConventionalVehicle); + mock.Setup(p => p.MultistageJobInputData.JobInputData.JobType) + .Returns(VectoSimulationJobType.ConventionalVehicle); + mock.Setup(p => p.MultistageJobInputData.JobInputData.PrimaryVehicle.Vehicle.ArchitectureID) + .Returns(ArchitectureID.UNKNOWN); + return mock; + } + internal static Mock<IMultistageVIFInputData> CompletedBus(this Mock<IMultistageVIFInputData> mock) + { + mock.Setup(p => p.MultistageJobInputData.JobInputData.ConsolidateManufacturingStage.Vehicle.VehicleCategory) + .Returns(VehicleCategory.HeavyBusCompletedVehicle); + return mock; + } + + internal static Mock<IMultistageVIFInputData> HEV(this Mock<IMultistageVIFInputData> mock, ArchitectureID arch) + { + var type = arch.ToString().StartsWith("P") + ? VectoSimulationJobType.ParallelHybridVehicle + : VectoSimulationJobType.SerialHybridVehicle; + mock.Setup(p => p.MultistageJobInputData.JobInputData.PrimaryVehicle.Vehicle.ArchitectureID). + Returns(arch); + mock.Setup(p => p.MultistageJobInputData.JobInputData.JobType). + Returns(type); + mock.Setup(p => p.MultistageJobInputData.JobInputData.PrimaryVehicle.Vehicle.VehicleType). + Returns(type); return mock; } + internal static Mock<IMultistageVIFInputData> PEV(this Mock<IMultistageVIFInputData> mock, ArchitectureID arch) + { + var type = VectoSimulationJobType.BatteryElectricVehicle; + mock.Setup(p => p.MultistageJobInputData.JobInputData.PrimaryVehicle.Vehicle.ArchitectureID). + Returns(arch); + mock.Setup(p => p.MultistageJobInputData.JobInputData.JobType). + Returns(type); + mock.Setup(p => p.MultistageJobInputData.JobInputData.PrimaryVehicle.Vehicle.VehicleType). + Returns(type); + return mock; + } + + + } } diff --git a/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs b/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs index 89d4ec1ba88ee917619b4da93016e88f5f48ba8b..6334fd4bd787a59c547b77626e184749e5ec5646 100644 --- a/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs +++ b/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs @@ -929,7 +929,7 @@ namespace TUGraz.VectoCore.Tests.Integration.CompletedBus { return new CrosswindCorrectionCdxALookup( aerodynamicDragArea, - DeclarationDataAdapterHeavyLorry.GetDeclarationAirResistanceCurve( + DeclarationDataAdapterHeavyLorry.Conventional.GetDeclarationAirResistanceCurve( crossWindCorrectionParams, aerodynamicDragArea, vehicleHeight), diff --git a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs index 9693e144ff62a8a0d1bd9a5a3e7256eeaa8c7bdc..4fb62f6219cb6e058cdeb67c4448d55a9fa16d92 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs @@ -266,7 +266,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration public void CrossWindCorrectionExceptionTest(string parameterSet, double crossSectionArea, double kmph, double height) { var crossWindCorrectionCurve = new CrosswindCorrectionCdxALookup(crossSectionArea.SI<SquareMeter>(), - DeclarationDataAdapterHeavyLorry.GetDeclarationAirResistanceCurve(parameterSet, crossSectionArea.SI<SquareMeter>(), + DeclarationDataAdapterHeavyLorry.Conventional.GetDeclarationAirResistanceCurve(parameterSet, crossSectionArea.SI<SquareMeter>(), height.SI<Meter>()), CrossWindCorrectionMode.DeclarationModeCorrection); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs index 55ea5a53bdd9f6819199a48c7d3baf1e8c0697fc..6381bb3e3ac7f164571b98c0bcf55a9f576d6467 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs @@ -124,7 +124,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var vehicleData = MockSimulationDataFactory.CreateVehicleDataFromFile(VehicleDataFileTruck); var airdragData = MockSimulationDataFactory.CreateAirdragDataFromFile(VehicleDataFileTruck); airdragData.CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup(6.46.SI<SquareMeter>(), - DeclarationDataAdapterHeavyLorry.GetDeclarationAirResistanceCurve("TractorSemitrailer", + DeclarationDataAdapterHeavyLorry.Conventional.GetDeclarationAirResistanceCurve("TractorSemitrailer", 6.46.SI<SquareMeter>(), height.SI<Meter>()), CrossWindCorrectionMode.DeclarationModeCorrection); var vehicle = new Vehicle(container, vehicleData,airdragData); new DummyCycle(container); diff --git a/VectoMockup/VectoMockup/Simulation/RundataFactories/CompletedBusRunDataFactory.cs b/VectoMockup/VectoMockup/Simulation/RundataFactories/CompletedBusRunDataFactory.cs index 7161fc9579b3d10c2cb120312dec81554615c79d..3fd4107e1a9e405277d2d239dec9d20f9f464058 100644 --- a/VectoMockup/VectoMockup/Simulation/RundataFactories/CompletedBusRunDataFactory.cs +++ b/VectoMockup/VectoMockup/Simulation/RundataFactories/CompletedBusRunDataFactory.cs @@ -15,110 +15,113 @@ using TUGraz.VectoCore.OutputData; namespace TUGraz.VectoMockup.Simulation.RundataFactories { - internal class MockupMultistageCompletedBusRunDataFactory : DeclarationModeCompletedMultistageBusVectoRunDataFactory - { - public MockupMultistageCompletedBusRunDataFactory(IMultistepBusInputDataProvider dataProvider, - IDeclarationReport report) : base(dataProvider, report) - { - - } - - - #region Overrides of DeclarationModeCompletedMultistageBusVectoRunDataFactory - - protected override void Initialize() - { - - _segmentCompletedBus = GetCompletedSegment(CompletedVehicle, PrimaryVehicle.AxleConfiguration); - - //base.Initialize(); - } - - protected override IEnumerable<VectoRunData> VectoRunDataHeavyBusCompleted() - { - - return base.VectoRunDataHeavyBusCompleted(); - } - - protected override VectoRunData CreateVectoRunDataSpecific(Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, int modeIdx) - { - var cycle = DeclarationData.CyclesCache.GetOrAdd(mission.MissionType, _ => DrivingCycleDataReader.ReadFromStream(mission.CycleFile, CycleType.DistanceBased, "", false)); - - var simulationRunData = new VectoRunData - { - Loading = loading.Key, - VehicleData = DataAdapterSpecific.CreateVehicleData(PrimaryVehicle, CompletedVehicle, _segmentCompletedBus, - mission, loading), - Retarder = PrimaryBusMockupRunDataFactory.CreateMockupRetarder(PrimaryVehicle), - AirdragData = PrimaryBusMockupRunDataFactory.CreateMockupAirdragData(CompletedVehicle), - EngineData = PrimaryBusMockupRunDataFactory.CreateMockupEngineData(PrimaryVehicle, modeIdx, CompletedVehicle.TankSystem), - //ElectricMachinesData = PrimaryBusMockupRunDataFactory.CreateMockupElectricMachineData() - AngledriveData = PrimaryBusMockupRunDataFactory.CreateMockupAngleDriveData(PrimaryVehicle), - AxleGearData = PrimaryBusMockupRunDataFactory.CreateMockupAxleGearData(PrimaryVehicle), - Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), - Mission = mission, - GearboxData = PrimaryBusMockupRunDataFactory.CreateMockupGearboxData(PrimaryVehicle), - InputData = InputDataProvider, - SimulationType = SimulationType.DistanceCycle, - ExecutionMode = ExecutionMode.Declaration, - JobName = InputDataProvider.JobInputData.ManufacturingStages.Last().Vehicle.Identifier, - Report = Report, - //Aux = PrimaryBusMockupRunDataFactory.CreateMockupBusAux(CompletedVehicle), - - // //AirdragData = DataAdapterSpecific.CreateAirdragData(CompletedVehicle, mission), - // //EngineData = DataAdapterSpecific.CreateEngineData(PrimaryVehicle, modeIdx, mission), - // //ElectricMachinesData = new List<Tuple<PowertrainPosition, ElectricMotorData>>(), - // //GearboxData = _gearboxData, - // //AxleGearData = _axlegearData, - // //AngledriveData = _angledriveData, - // Aux = DataAdapterSpecific.CreateAuxiliaryData(PrimaryVehicle.Components.AuxiliaryInputData, - // PrimaryVehicle.Components.BusAuxiliaries, mission.MissionType, _segmentCompletedBus.VehicleClass, CompletedVehicle.Length, - // PrimaryVehicle.Components.AxleWheels.NumSteeredAxles), - //Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), - //Retarder = _retarderData, - ////DriverData = _driverData, - //ExecutionMode = ExecutionMode.Declaration, - //JobName = InputDataProvider.JobInputData.ManufacturingStages.Last().Vehicle.Identifier,//?!? Jobname - ModFileSuffix = $"_{_segmentCompletedBus.VehicleClass.GetClassNumber()}-Specific_{loading.Key}", - //Report = Report, - //Mission = mission, - //InputDataHash = InputDataProvider.XMLHash,// right hash?!? - //SimulationType = SimulationType.DistanceCycle, - //VehicleDesignSpeed = _segmentCompletedBus.DesignSpeed, - //GearshiftParameters = _gearshiftData, - }; - if (simulationRunData.EngineData != null) { - simulationRunData.EngineData.FuelMode = 0; - } - simulationRunData.VehicleData.VehicleClass = _segmentCompletedBus.VehicleClass; - simulationRunData.BusAuxiliaries = DataAdapterSpecific.CreateBusAuxiliariesData(mission, PrimaryVehicle, CompletedVehicle, simulationRunData); - - return simulationRunData; - - //return base.CreateVectoRunDataSpecific(mission, loading, modeIdx); - } - - protected override VectoRunData CreateVectoRunDataGeneric(Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, Segment primarySegment, int modeIdx) - { - var cycle = DeclarationData.CyclesCache.GetOrAdd(mission.MissionType, _ => DrivingCycleDataReader.ReadFromStream(mission.CycleFile, CycleType.DistanceBased, "", false)); - return new VectoRunData() { - Mission = mission, - Loading = loading.Key, - VehicleData = new VehicleData() { - Loading = loading.Value.Item1, - - }, - EngineData = PrimaryBusMockupRunDataFactory.CreateMockupEngineData(PrimaryVehicle, modeIdx, CompletedVehicle.TankSystem), - JobName = InputDataProvider.JobInputData.ManufacturingStages.Last().Vehicle.Identifier, - ExecutionMode = ExecutionMode.Declaration, - SimulationType = SimulationType.DistanceCycle, - Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), - Report = Report, - ModFileSuffix = $"_{_segmentCompletedBus.VehicleClass.GetClassNumber()}-Generic_{loading.Key}", - }; - return base.CreateVectoRunDataGeneric(mission, loading, primarySegment, modeIdx); - } - - #endregion + internal class MockupMultistageCompletedBusRunDataFactory + { + // DeclarationModeCompletedMultistageBusVectoRunDataFactory + // { + //public MockupMultistageCompletedBusRunDataFactory(IMultistepBusInputDataProvider dataProvider, + // IDeclarationReport report) : base(dataProvider, report) + //{ + + //} + + + //#region Overrides of DeclarationModeCompletedMultistageBusVectoRunDataFactory + + //protected override void Initialize() + //{ + + // _segmentCompletedBus = GetCompletedSegment(CompletedVehicle, PrimaryVehicle.AxleConfiguration); + + // //base.Initialize(); + //} + + //protected override IEnumerable<VectoRunData> VectoRunDataHeavyBusCompleted() + //{ + + // return base.VectoRunDataHeavyBusCompleted(); + //} + + //protected override VectoRunData CreateVectoRunDataSpecific(Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, int modeIdx) + //{ + // var cycle = DeclarationData.CyclesCache.GetOrAdd(mission.MissionType, _ => DrivingCycleDataReader.ReadFromStream(mission.CycleFile, CycleType.DistanceBased, "", false)); + + // var simulationRunData = new VectoRunData + // { + // Loading = loading.Key, + // VehicleData = DataAdapterSpecific.CreateVehicleData(PrimaryVehicle, CompletedVehicle, _segmentCompletedBus, + // mission, loading), + // Retarder = PrimaryBusMockupRunDataFactory.CreateMockupRetarder(PrimaryVehicle), + // AirdragData = PrimaryBusMockupRunDataFactory.CreateMockupAirdragData(CompletedVehicle), + // EngineData = PrimaryBusMockupRunDataFactory.CreateMockupEngineData(PrimaryVehicle, modeIdx, CompletedVehicle.TankSystem), + // //ElectricMachinesData = PrimaryBusMockupRunDataFactory.CreateMockupElectricMachineData() + // AngledriveData = PrimaryBusMockupRunDataFactory.CreateMockupAngleDriveData(PrimaryVehicle), + // AxleGearData = PrimaryBusMockupRunDataFactory.CreateMockupAxleGearData(PrimaryVehicle), + // Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), + // Mission = mission, + // GearboxData = PrimaryBusMockupRunDataFactory.CreateMockupGearboxData(PrimaryVehicle), + // InputData = InputDataProvider, + // SimulationType = SimulationType.DistanceCycle, + // ExecutionMode = ExecutionMode.Declaration, + // JobName = InputDataProvider.JobInputData.ManufacturingStages.Last().Vehicle.Identifier, + // Report = Report, + // //Aux = PrimaryBusMockupRunDataFactory.CreateMockupBusAux(CompletedVehicle), + + // // //AirdragData = DataAdapterSpecific.CreateAirdragData(CompletedVehicle, mission), + // // //EngineData = DataAdapterSpecific.CreateEngineData(PrimaryVehicle, modeIdx, mission), + // // //ElectricMachinesData = new List<Tuple<PowertrainPosition, ElectricMotorData>>(), + // // //GearboxData = _gearboxData, + // // //AxleGearData = _axlegearData, + // // //AngledriveData = _angledriveData, + // // Aux = DataAdapterSpecific.CreateAuxiliaryData(PrimaryVehicle.Components.AuxiliaryInputData, + // // PrimaryVehicle.Components.BusAuxiliaries, mission.MissionType, _segmentCompletedBus.VehicleClass, CompletedVehicle.Length, + // // PrimaryVehicle.Components.AxleWheels.NumSteeredAxles), + // //Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), + // //Retarder = _retarderData, + // ////DriverData = _driverData, + // //ExecutionMode = ExecutionMode.Declaration, + // //JobName = InputDataProvider.JobInputData.ManufacturingStages.Last().Vehicle.Identifier,//?!? Jobname + // ModFileSuffix = $"_{_segmentCompletedBus.VehicleClass.GetClassNumber()}-Specific_{loading.Key}", + // //Report = Report, + // //Mission = mission, + // //InputDataHash = InputDataProvider.XMLHash,// right hash?!? + // //SimulationType = SimulationType.DistanceCycle, + // //VehicleDesignSpeed = _segmentCompletedBus.DesignSpeed, + // //GearshiftParameters = _gearshiftData, + // }; + // if (simulationRunData.EngineData != null) { + // simulationRunData.EngineData.FuelMode = 0; + // } + // simulationRunData.VehicleData.VehicleClass = _segmentCompletedBus.VehicleClass; + // simulationRunData.BusAuxiliaries = DataAdapterSpecific.CreateBusAuxiliariesData(mission, PrimaryVehicle, CompletedVehicle, simulationRunData); + + // return simulationRunData; + + // //return base.CreateVectoRunDataSpecific(mission, loading, modeIdx); + //} + + //protected override VectoRunData CreateVectoRunDataGeneric(Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, Segment primarySegment, int modeIdx) + //{ + // var cycle = DeclarationData.CyclesCache.GetOrAdd(mission.MissionType, _ => DrivingCycleDataReader.ReadFromStream(mission.CycleFile, CycleType.DistanceBased, "", false)); + // return new VectoRunData() { + // Mission = mission, + // Loading = loading.Key, + // VehicleData = new VehicleData() { + // Loading = loading.Value.Item1, + + // }, + // EngineData = PrimaryBusMockupRunDataFactory.CreateMockupEngineData(PrimaryVehicle, modeIdx, CompletedVehicle.TankSystem), + // JobName = InputDataProvider.JobInputData.ManufacturingStages.Last().Vehicle.Identifier, + // ExecutionMode = ExecutionMode.Declaration, + // SimulationType = SimulationType.DistanceCycle, + // Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), + // Report = Report, + // ModFileSuffix = $"_{_segmentCompletedBus.VehicleClass.GetClassNumber()}-Generic_{loading.Key}", + // }; + // return base.CreateVectoRunDataGeneric(mission, loading, primarySegment, modeIdx); + //} + + // //#endregion + //} } }