diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs index b5703a3c91ca1712a5a19e40af798bf450689ed3..209a5667f2b5667599067ca166fb6ad19259cbdc 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterPrimaryBus.cs @@ -21,23 +21,80 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter { public class DeclarationDataAdapterPrimaryBus : DeclarationDataAdapterHeavyLorry { + //public AirdragData CreateAirdragData(Mission mission) //{ // return DefaultAirdragData(mission); //} + #region Overrides of DeclarationDataAdapterTruck - public override VehicleData CreateVehicleData(IVehicleDeclarationInputData data, Mission mission, KeyValuePair<LoadingType, Kilogram> loading) + //Generic + + public override VehicleData CreateVehicleData(IVehicleDeclarationInputData pifVehicle, Mission mission, KeyValuePair<LoadingType, Kilogram> loading) { - var retVal = base.CreateVehicleData(data, mission, loading); - retVal.CurbMass = mission.CurbMass; - //retVal.Length = mission.BusParameter.VehicleLength; - //retVal.Width = mission.BusParameter.VehicleWidth; - //retVal.Height = mission.VehicleHeight; - return retVal; + var vehicleData = new VehicleData { + AxleData = GetAxles(pifVehicle.Components.AxleWheels.AxlesDeclaration, mission.AxleWeightDistribution), + DynamicTyreRadius = GetDynamicTyreRadius(pifVehicle.Components.AxleWheels.AxlesDeclaration), + AxleConfiguration = pifVehicle.AxleConfiguration, + CurbMass = mission.CurbMass, + BodyAndTrailerMass = 0.SI<Kilogram>(), + Loading = mission.RefLoad + }; + + + var adas = new VehicleData.ADASData { + EngineStopStart = pifVehicle.ADAS.EngineStopStart, + EcoRoll = pifVehicle.ADAS.EcoRoll, + PredictiveCruiseControl = pifVehicle.ADAS.PredictiveCruiseControl + }; + + vehicleData.ADAS = adas; + + return vehicleData; + } + + public override AirdragData CreateAirdragData(IAirdragDeclarationInputData airdragInputData, Mission mission, + Segment segment) + { + + + var airdragData = new AirdragData(); + + airdragData.CrossWindCorrectionMode = CrossWindCorrectionMode.DeclarationModeCorrection; + + //Corsswind correction curve + + airdragData.DeclaredAirdragArea = mission.DefaultCDxA; + + + return airdragData; } + + + //public override AirdragData CreateAirdragData( + // IAirdragDeclarationInputData airdragData, Mission mission, Segment segment) + //{ + // if (CompletedVehicle.Components.AirdragInputData == null || + // CompletedVehicle.Components.AirdragInputData.AirDragArea == null) + // { + // return DefaultAirdragData(mission); + // } + + // var aerodynamicDragArea = CompletedVehicle.Components.AirdragInputData.AirDragArea; + // var retVal = SetCommonAirdragData(CompletedVehicle.Components.AirdragInputData); + // retVal.CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup( + // aerodynamicDragArea, + // GetDeclarationAirResistanceCurve(mission.CrossWindCorrectionParameters, aerodynamicDragArea, mission.VehicleHeight), + // CrossWindCorrectionMode.DeclarationModeCorrection); + + // return retVal; + //} + + + public override PTOData CreatePTOTransmissionData(IPTOTransmissionInputData pto) { return null; @@ -71,8 +128,50 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter return retVal; } + + + private List<Axle> GetAxles(IList<IAxleDeclarationInputData> axleWheels, double[] axlesDistribution) + { + var axles = new List<Axle>(); + for (int i = 0; i < axleWheels.Count; i++) + { + var axle = new Axle + { + WheelsDimension = axleWheels[i].Tyre.Dimension, + Inertia = DeclarationData.Wheels + .Lookup(axleWheels[i].Tyre.Dimension.RemoveWhitespace()).Inertia, + TyreTestLoad = axleWheels[i].Tyre.TyreTestLoad, + AxleWeightShare = axlesDistribution[i], + TwinTyres = axleWheels[i].TwinTyres, + AxleType = axleWheels[i].AxleType + }; + axles.Add(axle); + } + + return axles; + } + + private Meter GetDynamicTyreRadius(IList<IAxleDeclarationInputData> axleWheels) + { + Meter dynamicTyreRadius = null; + + for (int i = 0; i < axleWheels.Count; i++) + { + if (axleWheels[i].AxleType == AxleType.VehicleDriven) + { + dynamicTyreRadius = DeclarationData.Wheels.Lookup(axleWheels[i].Tyre.Dimension.RemoveWhitespace()).DynamicTyreRadius; + break; + } + } + + return dynamicTyreRadius; + } + #endregion + + #region Overrides + public virtual IAuxiliaryConfig CreateBusAuxiliariesData( Mission mission, IVehicleDeclarationInputData vehicleData, VectoRunData runData) { @@ -383,5 +482,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter StopBrakeActuation = Constants.BusAuxiliaries.PneumaticConsumersDemands.StopBrakeActuation, }; } + #endregion + } } diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationDataAdapterCompletedBus.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationDataAdapterCompletedBus.cs index d585572d10068a613c375f534d3ab34b18e63b03..ab8b1349be1c493829ee0e651e9c2324531643c1 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationDataAdapterCompletedBus.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationDataAdapterCompletedBus.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -10,6 +11,8 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl { public class DeclarationDataAdapterCompletedBus { + //Specific + public DriverData CreateDriverData() { throw new System.NotImplementedException(); @@ -30,10 +33,30 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl throw new System.NotImplementedException(); } - public VehicleData CreateVehicleData( - IVehicleDeclarationInputData vehicle, Mission mission, KeyValuePair<LoadingType, Kilogram> loading) + public VehicleData CreateVehicleData(IVehicleDeclarationInputData pifVehicle, + IVehicleDeclarationInputData completedVehicle, Mission mission, KeyValuePair<LoadingType, Kilogram> loading) { - throw new System.NotImplementedException(); + var vehicleData = new VehicleData + { + AxleConfiguration = pifVehicle.AxleConfiguration, + CurbMass = completedVehicle.CurbMassChassis, + BodyAndTrailerMass = 0.SI<Kilogram>(), + Loading = GetLoading(completedVehicle, mission, loading), + GrossVehicleMass = completedVehicle.GrossVehicleMassRating, + DynamicTyreRadius = GetDynamicTyreRadius(pifVehicle.Components.AxleWheels.AxlesDeclaration), + AxleData = GetAxles(pifVehicle.Components.AxleWheels.AxlesDeclaration, mission.AxleWeightDistribution) + }; + + var adas = new VehicleData.ADASData + { + EngineStopStart = pifVehicle.ADAS.EngineStopStart, + EcoRoll = pifVehicle.ADAS.EcoRoll, + PredictiveCruiseControl = pifVehicle.ADAS.PredictiveCruiseControl + }; + + vehicleData.ADAS = adas; + + return vehicleData; } public IEnumerable<VectoRunData.AuxData> CreateAuxiliaryData( @@ -42,5 +65,65 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl { throw new System.NotImplementedException(); } + + #region Vehicle Data Getter + + private List<Axle> GetAxles(IList<IAxleDeclarationInputData> axleWheels, double[] axlesDistribution) + { + var axles = new List<Axle>(); + for (int i = 0; i < axleWheels.Count; i++) + { + var axle = new Axle + { + WheelsDimension = axleWheels[i].Tyre.Dimension, + Inertia = DeclarationData.Wheels + .Lookup(axleWheels[i].Tyre.Dimension.RemoveWhitespace()).Inertia, + TyreTestLoad = axleWheels[i].Tyre.TyreTestLoad, + AxleWeightShare = axlesDistribution[i], + TwinTyres = axleWheels[i].TwinTyres, + AxleType = axleWheels[i].AxleType + }; + axles.Add(axle); + } + + return axles; + } + + private Meter GetDynamicTyreRadius(IList<IAxleDeclarationInputData> axleWheels) + { + Meter dynamicTyreRadius = null; + + for (int i = 0; i < axleWheels.Count; i++) + { + if (axleWheels[i].AxleType == AxleType.VehicleDriven) + { + dynamicTyreRadius = DeclarationData.Wheels.Lookup(axleWheels[i].Tyre.Dimension.RemoveWhitespace()).DynamicTyreRadius; + break; + } + } + + return dynamicTyreRadius; + } + + private Kilogram GetLoading(IVehicleDeclarationInputData completedVehicle, Mission mission, KeyValuePair<LoadingType, Kilogram> loading) + { + var busFloorArea = DeclarationData.BusAuxiliaries.CalculateBusFloorSurfaceArea(completedVehicle.Length, + completedVehicle.Width); + var passengerCountRef = busFloorArea * mission.BusParameter.PassengerDensity; + var passengerCountDecl = completedVehicle.NuberOfPassengersUpperDeck + completedVehicle.NumberOfPassengersLowerDeck; + + if (loading.Key != LoadingType.ReferenceLoad && loading.Key != LoadingType.LowLoading) + { + throw new VectoException("Unhandled loading type: {0}", loading.Key); + } + + + return + (loading.Key == LoadingType.ReferenceLoad + ? VectoMath.Min(passengerCountRef, passengerCountDecl) + : passengerCountRef * mission.MissionType.GetLowLoadFactorBus()) * mission.MissionType.GetAveragePassengerMass(); + } + + #endregion } } diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs index 513fef661560b532d1c3c7a102c1abcc93ceeae7..51982e043d00216bc4a18679f1c6a8e21b69a330 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs @@ -56,7 +56,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl { Initialize(); if (Report != null) { - InitializeReport(); + //InitializeReport(); } return GetNextRun(); @@ -85,36 +85,36 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl } _segment = GetSegment(vehicle, primaryVehicle.AxleConfiguration); - _driverdata = DataAdapterCompleted.CreateDriverData(); - _driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(_segment.AccelerationFile); - //var tempVehicle = DataAdapter.CreateVehicleData( - // vehicle, _segment.Missions.First(), - // _segment.Missions.First().Loadings.First()); - _airdragData = DataAdapterCompleted.CreateAirdragData( - vehicle.Components.AirdragInputData, - _segment.Missions.First(), _segment); - - _axlegearData = DeclarationData.FactorMethodBus.CreateAxlegearData(primaryVehicle.Components.AxleGearInputData); - - _angledriveData = null; - var tmpRunData = new VectoRunData() { - ShiftStrategy = InputDataProvider.JobInputData.ShiftStrategy, - GearboxData = new GearboxData() { - Type = vehicle.Components.GearboxInputData.Type, - } - }; - - //var tmpStrategy = PowertrainBuilder.GetShiftStrategy(tmpRunData, new SimplePowertrainContainer(tmpRunData)); - var tmpEngine = DeclarationData.FactorMethodBus.CreateBusEngineData(primaryVehicle.Components.EngineInputData); - _gearboxData = DeclarationData.FactorMethodBus.CreateGearboxData(primaryVehicle.Components.GearboxInputData); - - _retarderData = DataAdapterCompleted.CreateRetarderData(vehicle.Components.RetarderInputData); - - _ptoTransmissionData = null; - - _municipalPtoTransmissionData = null; - _gearshiftData = DataAdapterCompleted.CreateGearshiftData( - _gearboxData, _axlegearData.AxleGear.Ratio * (_angledriveData?.Angledrive.Ratio ?? 1.0), tmpEngine.IdleSpeed); + //_driverdata = DataAdapterCompleted.CreateDriverData(); + //_driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(_segment.AccelerationFile); + ////var tempVehicle = DataAdapter.CreateVehicleData( + //// vehicle, _segment.Missions.First(), + //// _segment.Missions.First().Loadings.First()); + //_airdragData = DataAdapterCompleted.CreateAirdragData( + // vehicle.Components.AirdragInputData, + // _segment.Missions.First(), _segment); + + //_axlegearData = DeclarationData.FactorMethodBus.CreateAxlegearData(primaryVehicle.Components.AxleGearInputData); + + //_angledriveData = null; + //var tmpRunData = new VectoRunData() { + // ShiftStrategy = InputDataProvider.JobInputData.ShiftStrategy, + // GearboxData = new GearboxData() { + // Type = vehicle.Components.GearboxInputData.Type, + // } + //}; + + ////var tmpStrategy = PowertrainBuilder.GetShiftStrategy(tmpRunData, new SimplePowertrainContainer(tmpRunData)); + //var tmpEngine = DeclarationData.FactorMethodBus.CreateBusEngineData(primaryVehicle.Components.EngineInputData); + //_gearboxData = DeclarationData.FactorMethodBus.CreateGearboxData(primaryVehicle.Components.GearboxInputData); + + //_retarderData = DataAdapterCompleted.CreateRetarderData(vehicle.Components.RetarderInputData); + + //_ptoTransmissionData = null; + + //_municipalPtoTransmissionData = null; + //_gearshiftData = DataAdapterCompleted.CreateGearshiftData( + //_gearboxData, _axlegearData.AxleGear.Ratio * (_angledriveData?.Angledrive.Ratio ?? 1.0), tmpEngine.IdleSpeed); } protected virtual IEnumerable<VectoRunData> GetNextRun() @@ -184,38 +184,48 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl CyclesCache.Add(mission.MissionType, cycle); } } - var mergedBusAux = new CombinedBusAuxiliaries( - primaryVehicle.Components.BusAuxiliaries, completedVehicle.Components.BusAuxiliaries); - - var simulationRunData = new VectoRunData { - Loading = loading.Key, - VehicleData = DataAdapterCompleted.CreateVehicleData(primaryVehicle, mission, loading), - AirdragData = DataAdapterCompleted.CreateAirdragData(null, mission, new Segment()), - EngineData = DeclarationData.FactorMethodBus.CreateBusEngineData(primaryVehicle.Components.EngineInputData), - GearboxData = _gearboxData, - AxleGearData = _axlegearData, - AngledriveData = _angledriveData, - Aux = DataAdapterCompleted.CreateAuxiliaryData( - primaryVehicle.Components.AuxiliaryInputData, - mergedBusAux, mission.MissionType, _segment.VehicleClass, - primaryVehicle.Length ?? mission.BusParameter.VehicleLength), - Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), - Retarder = _retarderData, - DriverData = _driverdata, - ExecutionMode = ExecutionMode.Declaration, - JobName = InputDataProvider.JobInputData.JobName, - ModFileSuffix = "_specific_" + mission.BusParameter.BusGroup.GetClassNumber() + "_" + loading.Key.ToString(), - Report = Report, - Mission = mission, - InputDataHash = InputDataProvider.XMLHash, - SimulationType = SimulationType.DistanceCycle, - GearshiftParameters = _gearshiftData, - ShiftStrategy = InputDataProvider.JobInputData.ShiftStrategy - }; - simulationRunData.EngineData.FuelMode = 0; - simulationRunData.VehicleData.VehicleClass = _segment.VehicleClass; - simulationRunData.BusAuxiliaries = DataAdapterPrimary.CreateBusAuxiliariesData( - mission, InputDataProvider.JobInputData.Vehicle, simulationRunData); + //var mergedBusAux = new CombinedBusAuxiliaries( + // primaryVehicle.Components.BusAuxiliaries, completedVehicle.Components.BusAuxiliaries); + + //var simulationRunData = new VectoRunData { + // Loading = loading.Key, + // VehicleData = DataAdapterCompleted.CreateVehicleData(primaryVehicle, mission, loading), + // AirdragData = DataAdapterCompleted.CreateAirdragData(null, mission, new Segment()), + // EngineData = DeclarationData.FactorMethodBus.CreateBusEngineData(primaryVehicle.Components.EngineInputData), + // GearboxData = _gearboxData, + // AxleGearData = _axlegearData, + // AngledriveData = _angledriveData, + // Aux = DataAdapterCompleted.CreateAuxiliaryData( + // primaryVehicle.Components.AuxiliaryInputData, + // mergedBusAux, mission.MissionType, _segment.VehicleClass, + // primaryVehicle.Length ?? mission.BusParameter.VehicleLength), + // Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), + // Retarder = _retarderData, + // DriverData = _driverdata, + // ExecutionMode = ExecutionMode.Declaration, + // JobName = InputDataProvider.JobInputData.JobName, + // ModFileSuffix = "_specific_" + mission.BusParameter.BusGroup.GetClassNumber() + "_" + loading.Key.ToString(), + // Report = Report, + // Mission = mission, + // InputDataHash = InputDataProvider.XMLHash, + // SimulationType = SimulationType.DistanceCycle, + // GearshiftParameters = _gearshiftData, + // ShiftStrategy = InputDataProvider.JobInputData.ShiftStrategy + //}; + //simulationRunData.EngineData.FuelMode = 0; + //simulationRunData.VehicleData.VehicleClass = _segment.VehicleClass; + //simulationRunData.BusAuxiliaries = DataAdapterPrimary.CreateBusAuxiliariesData( + // mission, InputDataProvider.JobInputData.Vehicle, simulationRunData); + //return simulationRunData; + + var simulationRunData = new VectoRunData(); + simulationRunData.Loading = loading.Key; + simulationRunData.VehicleData = DataAdapterCompleted.CreateVehicleData(primaryVehicle, completedVehicle, mission, loading); + //simulationRunData.AirdragData = DataAdapterCompleted.CreateAirdragData(, mission) + + simulationRunData.Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()); + + return simulationRunData; } @@ -233,36 +243,47 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl CyclesCache.Add(mission.MissionType, cycle); } } - var simulationRunData = new VectoRunData { - Loading = loading.Key, - VehicleData = DataAdapterPrimary.CreateVehicleData(primaryVehicle, mission, loading), - AirdragData = DataAdapterPrimary.CreateAirdragData(null, mission, new Segment()), - EngineData = DeclarationData.FactorMethodBus.CreateBusEngineData(primaryVehicle.Components.EngineInputData), - GearboxData = _gearboxData, - AxleGearData = _axlegearData, - AngledriveData = _angledriveData, - Aux = DataAdapterPrimary.CreateAuxiliaryData( - primaryVehicle.Components.AuxiliaryInputData, - completedVehicle.Components.BusAuxiliaries, mission.MissionType, _segment.VehicleClass, - primaryVehicle.Length ?? mission.BusParameter.VehicleLength), - Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), - Retarder = _retarderData, - DriverData = _driverdata, - ExecutionMode = ExecutionMode.Declaration, - JobName = InputDataProvider.JobInputData.JobName, - ModFileSuffix = "_generic_" + mission.BusParameter.BusGroup.GetClassNumber() + "_" + loading.Key.ToString(), - Report = Report, - Mission = mission, - InputDataHash = InputDataProvider.XMLHash, - SimulationType = SimulationType.DistanceCycle, - GearshiftParameters = _gearshiftData, - ShiftStrategy = InputDataProvider.JobInputData.ShiftStrategy - }; - simulationRunData.EngineData.FuelMode = 0; - simulationRunData.VehicleData.VehicleClass = _segment.VehicleClass; - simulationRunData.BusAuxiliaries = DataAdapterPrimary.CreateBusAuxiliariesData( - mission, InputDataProvider.JobInputData.Vehicle, simulationRunData); + //var simulationRunData = new VectoRunData { + // Loading = loading.Key, + // VehicleData = DataAdapterPrimary.CreateVehicleData(primaryVehicle, mission, loading), + // AirdragData = DataAdapterPrimary.CreateAirdragData(null, mission, new Segment()), + // EngineData = DeclarationData.FactorMethodBus.CreateBusEngineData(primaryVehicle.Components.EngineInputData), + // GearboxData = _gearboxData, + // AxleGearData = _axlegearData, + // AngledriveData = _angledriveData, + // Aux = DataAdapterPrimary.CreateAuxiliaryData( + // primaryVehicle.Components.AuxiliaryInputData, + // completedVehicle.Components.BusAuxiliaries, mission.MissionType, _segment.VehicleClass, + // primaryVehicle.Length ?? mission.BusParameter.VehicleLength), + // Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), + // Retarder = _retarderData, + // DriverData = _driverdata, + // ExecutionMode = ExecutionMode.Declaration, + // JobName = InputDataProvider.JobInputData.JobName, + // ModFileSuffix = "_generic_" + mission.BusParameter.BusGroup.GetClassNumber() + "_" + loading.Key.ToString(), + // Report = Report, + // Mission = mission, + // InputDataHash = InputDataProvider.XMLHash, + // SimulationType = SimulationType.DistanceCycle, + // GearshiftParameters = _gearshiftData, + // ShiftStrategy = InputDataProvider.JobInputData.ShiftStrategy + //}; + //simulationRunData.EngineData.FuelMode = 0; + //simulationRunData.VehicleData.VehicleClass = _segment.VehicleClass; + //simulationRunData.BusAuxiliaries = DataAdapterPrimary.CreateBusAuxiliariesData( + // mission, InputDataProvider.JobInputData.Vehicle, simulationRunData); + //return simulationRunData; + + var simulationRunData = new VectoRunData(); + simulationRunData.Loading = loading.Key; + simulationRunData.VehicleData = DataAdapterPrimary.CreateVehicleData(primaryVehicle, mission, loading); + //simulationRunData.AirdragData = DataAdapterPrimary.CreateAirdragData(pri) + + simulationRunData.Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()); + + return simulationRunData; + } } } diff --git a/VectoCore/VectoCore/Models/Declaration/CompletedBusSegments.cs b/VectoCore/VectoCore/Models/Declaration/CompletedBusSegments.cs index dff4919200a7d5faf9481e17ff50d1c10ab25dd0..a776fdd60b8e4b72b1824cf56c08323260ded58c 100644 --- a/VectoCore/VectoCore/Models/Declaration/CompletedBusSegments.cs +++ b/VectoCore/VectoCore/Models/Declaration/CompletedBusSegments.cs @@ -7,6 +7,7 @@ using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Utils; +using TUGraz.VectoCore.Configuration; namespace TUGraz.VectoCore.Models.Declaration { @@ -126,6 +127,11 @@ namespace TUGraz.VectoCore.Models.Declaration LowLoad = 10.SI<Kilogram>(), // dummy value to trigger simulation with low load AxleWeightDistribution = GetAxleWeightDistribution(row), DefaultCDxA = row.ParseDouble("cdxastandard").SI<SquareMeter>(), + CycleFile = + RessourceHelper.ReadStream( + DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + + missionType.ToString().Replace("EMS", "") + + Constants.FileExtensions.CycleFile), BusParameter = new BusParameters { PassengerDensity = row.ParseDouble(missionType.ToString()).SI<PerSquareMeter>(), AirDragMeasurementAllowed = row.ParseBoolean("airdragmeasurement"), diff --git a/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs b/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs index 66554b17ac7376af6ca5731679e73d00ad2d1e49..bbc8130691fcb478320954b0b8e264bbb64ee71d 100644 --- a/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs +++ b/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs @@ -1,14 +1,20 @@ using System; +using System.Collections.Generic; using System.IO; using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; using Ninject; +using Ninject.Planning.Bindings.Resolvers; using NUnit.Framework; -using NUnit.Framework.Internal; +using TUGraz.VectoCommon.BusAuxiliaries; +using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.FileIO.JSON; -using TUGraz.VectoCore.InputData.FileIO.XML; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; -using TUGraz.VectoCore.OutputData; +using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.OutputData.FileIO; namespace TUGraz.VectoCore.Tests.Integration.CompletedBus @@ -17,13 +23,56 @@ namespace TUGraz.VectoCore.Tests.Integration.CompletedBus [TestFixture()] public class CompletedBusFactorMethodTest { + class RelatedRun + { + public VectoRunData VectoRunDataSpezificBody { get; set; } + public VectoRunData VectoRunDataGenericBody { get; set; } + + } + + private List<RelatedRun> relatedRuns; + private Segment primarySegment; + private Segment completedSegment; + + [OneTimeSetUp] public void RunBeforeAnyTests() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + relatedRuns = new List<RelatedRun>(); + + //SetBusSegments(); + } + + + private void SetBusSegments() + { + PrimaryBusSegment(); + CompletedBusSegment(); + } + + private void PrimaryBusSegment() + { + var category = VehicleCategory.HeavyBusPrimaryVehicle; + var axleConfiguration = AxleConfiguration.AxleConfig_4x2; + var floorType = FloorType.HighFloor; + var articulated = false; + var doubleDecker = true; + primarySegment = DeclarationData.PrimaryBusSegments.Lookup(category, axleConfiguration, articulated, floorType, doubleDecker); + } + + private void CompletedBusSegment() + { + var numberOfAxles = 2; + var vehicleCode = VehicleCode.CB; + var registrationClass = RegistrationClass.II_III; + var passengersLowerDeck = 30; + var bodyHeight = 3.SI<Meter>(); + var lowEntry = false; + completedSegment = DeclarationData.CompletedBusSegments.Lookup(numberOfAxles, vehicleCode, registrationClass, passengersLowerDeck, bodyHeight, lowEntry); } [TestCase()] @@ -33,21 +82,133 @@ namespace TUGraz.VectoCore.Tests.Integration.CompletedBus var writer = new FileOutputWriter(Path.Combine(Path.GetDirectoryName(relativeJobPath), Path.GetFileName(relativeJobPath))); var inputData = JSONInputDataFactory.ReadJsonJob(relativeJobPath); + var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, writer) { WriteModalResults = true, //ActualModalData = true, Validate = false }; - var sumContainer = new SummaryDataContainer(writer); - var jobContainer = new JobContainer(sumContainer); - jobContainer.AddRuns(factory); - jobContainer.Execute(); - jobContainer.WaitFinished(); - var progress = jobContainer.GetProgress(); + //var sumContainer = new SummaryDataContainer(writer); + //var jobContainer = new JobContainer(sumContainer); + - Assert.IsTrue(progress.All(r => r.Value.Success), string.Concat<Exception>(progress.Select(r => r.Value.Error))); + var runs = factory.DataReader.NextRun().ToList(); + Assert.IsTrue(runs.Count == 8 || runs.Count == 12); - //return jobContainer; + SetRelatedVehicleParts(runs); + + var index = 0; + for (int i = 0; i < relatedRuns.Count; i++) { + AssertVehicleData(relatedRuns[i], ref index); + } + + } + + #region Vehicle Data Asserts + + private void AssertVehicleData(RelatedRun relatedRun, ref int index) + { + var genericVehicleData = relatedRun.VectoRunDataGenericBody.VehicleData; + var specificVehicleData = relatedRun.VectoRunDataSpezificBody.VehicleData; + + Assert.AreEqual(AxleConfiguration.AxleConfig_4x2, genericVehicleData.AxleConfiguration); + Assert.AreEqual(genericVehicleData.AxleConfiguration, specificVehicleData.AxleConfiguration); + + Assert.AreEqual(10000, genericVehicleData.CurbMass.Value()); + Assert.AreEqual(8300, specificVehicleData.CurbMass.Value()); + + Assert.AreEqual(0, genericVehicleData.BodyAndTrailerMass.Value()); + Assert.AreEqual(genericVehicleData.BodyAndTrailerMass, specificVehicleData.BodyAndTrailerMass); + + AssertLoading(genericVehicleData.Loading, specificVehicleData.Loading, ref index); + + Assert.AreEqual(0.4992, genericVehicleData.DynamicTyreRadius.Value(), 1e-0); + Assert.AreEqual(genericVehicleData.DynamicTyreRadius, specificVehicleData.DynamicTyreRadius); + + AssertADASData(genericVehicleData.ADAS, specificVehicleData.ADAS); + + AssertAxles(genericVehicleData.AxleData, specificVehicleData.AxleData); + } + + private void AssertLoading(Kilogram genericLoading, Kilogram specificLoading, ref int index) + { + switch (index) { + case 0: + Assert.AreEqual(5051.2950, genericLoading.Value(), 1e-0); + Assert.AreEqual(2309.4738, specificLoading.Value(), 1e-0);//lowLoading + break; + case 1: + Assert.AreEqual(5051.2950, genericLoading.Value(),1e-0); + Assert.AreEqual(2130, specificLoading.Value(), 1e-0); + break; + case 2: + Assert.AreEqual(3367.53, genericLoading.Value(), 1e-0); + Assert.AreEqual(1539.6492, specificLoading.Value(), 1e-0); + break; + case 3: + Assert.AreEqual(3367.53, genericLoading.Value(), 1e-0); + Assert.AreEqual(2130.0, specificLoading.Value(), 1e-0); + break; + } + index++; + } + + private void AssertADASData(VehicleData.ADASData genericAdasData, VehicleData.ADASData specificAdasData) + { + Assert.AreEqual(false, genericAdasData.EngineStopStart); + Assert.AreEqual(genericAdasData.EngineStopStart, specificAdasData.EngineStopStart); + Assert.AreEqual(EcoRollType.None, genericAdasData.EcoRoll); + Assert.AreEqual(genericAdasData.EcoRoll, specificAdasData.EcoRoll); + Assert.AreEqual(PredictiveCruiseControlType.None, genericAdasData.PredictiveCruiseControl); + Assert.AreEqual(genericAdasData.PredictiveCruiseControl, specificAdasData.PredictiveCruiseControl); + } + + private void AssertAxles(List<Axle> genericAxles, List<Axle> specificAxles) + { + Assert.AreEqual(2, genericAxles.Count); + Assert.AreEqual(genericAxles.Count, specificAxles.Count); + + for (int i = 0; i < genericAxles.Count; i++) + { + Assert.AreEqual("315/70 R22.5", genericAxles[i].WheelsDimension); + Assert.AreEqual(genericAxles[i].WheelsDimension, specificAxles[i].WheelsDimension); + + Assert.AreEqual(14.9, genericAxles[i].Inertia.Value()); + Assert.AreEqual(genericAxles[i].Inertia, specificAxles[i].Inertia); + + Assert.AreEqual(31300, genericAxles[i].TyreTestLoad.Value()); + Assert.AreEqual(genericAxles[i].TyreTestLoad, specificAxles[i].TyreTestLoad); + if (i == 0) + { + Assert.AreEqual(0.375, genericAxles[i].AxleWeightShare); + Assert.AreEqual(genericAxles[i].AxleWeightShare, specificAxles[i].AxleWeightShare); + Assert.AreEqual(AxleType.VehicleNonDriven, genericAxles[i].AxleType); + Assert.AreEqual(false, genericAxles[i].TwinTyres); + } + else if (i == 1) + { + Assert.AreEqual(0.625, genericAxles[i].AxleWeightShare); + Assert.AreEqual(genericAxles[i].AxleWeightShare, specificAxles[i].AxleWeightShare); + Assert.AreEqual(AxleType.VehicleDriven, genericAxles[i].AxleType); + Assert.AreEqual(true, genericAxles[i].TwinTyres); + } + Assert.AreEqual(genericAxles[i].TwinTyres, specificAxles[i].TwinTyres); + Assert.AreEqual(genericAxles[i].AxleType, specificAxles[i].AxleType); + } + } + #endregion + + + private void SetRelatedVehicleParts(List<VectoRunData> runs) + { + for (int i = 0; i < runs.Count; i++) { + var relatedRun = new RelatedRun { + VectoRunDataSpezificBody = runs[i], + VectoRunDataGenericBody = runs[i+1] + }; + relatedRuns.Add(relatedRun); + i++; + } } } }