From e9c839131c978860c87b80883295cce84a9f55c9 Mon Sep 17 00:00:00 2001 From: "VKMTHD\\haraldmartini" <harald.martini@student.tugraz.at> Date: Thu, 8 Sep 2022 14:05:29 +0200 Subject: [PATCH] implemented Singlebus rundata factory and declaration adapter --- ...larationCompletedBusVehicleDataProvider.cs | 7 +- .../DeclarationDataAdapter.cd | 23 +- .../DeclarationDataAdapterNinjectModule.cs | 34 ++ .../DeclarationDataAdapterSingleBus.cs | 159 ------- .../IDeclarationDataAdapter.cs | 45 +- .../DeclarationDataAdapterPrimaryBus.cs | 7 +- .../AirdragDataAdapter.cs | 84 +++- .../AuxiliaryDataAdapter.cs | 6 +- .../SimulationComponents/DataAdapterBase.cs | 6 + .../SimulationComponents/PTODataAdapter.cs | 6 +- .../DeclarationDataAdapterSingleBus.cs | 164 +++++++ ...clarationModeCompletedBusRunDataFactory.cs | 2 + ...DeclarationModePrimaryBusRunDataFactory.cs | 2 + ...arationModeSingleBusVectoRunDataFactory.cs | 446 ++++++++++++++++++ ...tionModeCompletedBusVectoRunDataFactory.cs | 296 ------------ ...mpletedMultistageBusVectoRunDataFactory.cs | 328 ------------- ...rationModeHeavyLorryVectoRunDataFactory.cs | 232 --------- ...rationModePrimaryBusVectoRunDataFactory.cs | 178 ------- ...arationModeSingleBusVectoRunDataFactory.cs | 129 ----- .../Reader/VectoRunDataFactoryFactory.cs | 13 +- .../VectoRunDataFactoryNinjectModule.cs | 55 ++- .../XML/XMLDeclarationReportFactory.cs | 6 +- .../VehicleTypeAndArchitectureStringHelper.cs | 27 +- 23 files changed, 873 insertions(+), 1382 deletions(-) delete mode 100644 VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterSingleBus.cs create mode 100644 VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SingleBus/DeclarationDataAdapterSingleBus.cs create mode 100644 VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/SingleBus/DeclarationModeSingleBusVectoRunDataFactory.cs delete mode 100644 VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs delete mode 100644 VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedMultistageBusVectoRunDataFactory.cs delete mode 100644 VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs delete mode 100644 VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModePrimaryBusVectoRunDataFactory.cs delete mode 100644 VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeSingleBusVectoRunDataFactory.cs diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/v24/XMLDeclarationCompletedBusVehicleDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/v24/XMLDeclarationCompletedBusVehicleDataProvider.cs index f1fbdf90a1..fbc7128ea1 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/v24/XMLDeclarationCompletedBusVehicleDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/v24/XMLDeclarationCompletedBusVehicleDataProvider.cs @@ -190,6 +190,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider.v24 XMLHelper.CombineNamespace(NAMESPACE_URI.NamespaceName, XSD_TYPE); public XMLDeclarationConventionalCompletedBusDataProviderV24(IXMLDeclarationJobInputData jobData, XmlNode xmlNode, string sourceFile) : base(jobData, xmlNode, sourceFile) { } + public override VectoSimulationJobType VehicleType => VectoSimulationJobType.ConventionalVehicle; } // --------------------------------------------------------------------------------------- @@ -202,7 +203,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider.v24 XMLHelper.CombineNamespace(NAMESPACE_URI.NamespaceName, XSD_TYPE); public XMLDeclarationHevCompletedBusDataProviderV24(IXMLDeclarationJobInputData jobData, XmlNode xmlNode, string sourceFile) : base(jobData, xmlNode, sourceFile) { } - + public override VectoSimulationJobType VehicleType => ArchitectureID.ToString().StartsWith("S") ? VectoSimulationJobType.SerialHybridVehicle : VectoSimulationJobType.ParallelHybridVehicle; public override bool HybridElectricHDV => true; } @@ -217,7 +218,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider.v24 XMLHelper.CombineNamespace(NAMESPACE_URI.NamespaceName, XSD_TYPE); public XMLDeclarationPEVCompletedBusDataProviderV24(IXMLDeclarationJobInputData jobData, XmlNode xmlNode, string sourceFile) : base(jobData, xmlNode, sourceFile) { } - + public override VectoSimulationJobType VehicleType => VectoSimulationJobType.BatteryElectricVehicle; public override bool OvcHev => true; } @@ -236,7 +237,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider.v24 public override bool OvcHev => true; public override bool HybridElectricHDV => false; - + public override VectoSimulationJobType VehicleType => VectoSimulationJobType.BatteryElectricVehicle; } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cd b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cd index 933046ccfb..b29e6e1b9f 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cd +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cd @@ -3,37 +3,44 @@ <Interface Name="TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.IDeclarationDataAdapter"> <Position X="0.5" Y="1.5" Width="13" /> <TypeIdentifier> - <HashCode>AAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode> + <HashCode>AAAAAAgAgCAAAAAAAAAAAgAAAAAAAAAAAAAAQAABAAA=</HashCode> <FileName>InputData\Reader\DataObjectAdapter\IDeclarationDataAdapter.cs</FileName> </TypeIdentifier> </Interface> <Interface Name="TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.ILorryDeclarationDataAdapter"> - <Position X="0.5" Y="7.25" Width="13" /> + <Position X="0.5" Y="5.25" Width="13" /> <TypeIdentifier> - <HashCode>AAEAAAgAACAgAAAAAAEAAgIAAAAAAAAEAAAAQAABQAA=</HashCode> + <HashCode>AAEAAAAAACAgAAAAAAEAAAIAAAAAAAAEAAAAAAAAQAA=</HashCode> <FileName>InputData\Reader\DataObjectAdapter\IDeclarationDataAdapter.cs</FileName> </TypeIdentifier> </Interface> <Interface Name="TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.IPrimaryBusDeclarationDataAdapter"> - <Position X="0.5" Y="5.25" Width="13" /> + <Position X="14" Y="5.25" Width="13" /> <TypeIdentifier> - <HashCode>AAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAABQAA=</HashCode> + <HashCode>AAEAAAAAAAAgAAAAAAEAAAIAAAAAAAAEAAAAAAAAQAA=</HashCode> <FileName>InputData\Reader\DataObjectAdapter\IDeclarationDataAdapter.cs</FileName> </TypeIdentifier> </Interface> <Interface Name="TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.IGenericCompletedBusDeclarationDataAdapter"> - <Position X="1.25" Y="10.75" Width="12.25" /> + <Position X="0.5" Y="8.25" Width="13" /> <TypeIdentifier> - <HashCode>AAEAAAgAACAgAAAAAAEAAgAAAAAAAAAAAAAAQAABQAA=</HashCode> + <HashCode>AAEAAAgAACAgAAAAAAEAAgAAAAAAAAAAAAAAAAABQAA=</HashCode> <FileName>InputData\Reader\DataObjectAdapter\IDeclarationDataAdapter.cs</FileName> </TypeIdentifier> </Interface> <Interface Name="TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.ISpecificCompletedBusDeclarationDataAdapter"> - <Position X="2.75" Y="3" Width="10.75" /> + <Position X="14" Y="8.25" Width="10.75" /> <TypeIdentifier> <HashCode>AAEAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAQAABQAA=</HashCode> <FileName>InputData\Reader\DataObjectAdapter\IDeclarationDataAdapter.cs</FileName> </TypeIdentifier> </Interface> + <Interface Name="TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.ISingleBusDeclarationDataAdapter"> + <Position X="16.5" Y="1" Width="8.25" /> + <TypeIdentifier> + <HashCode>AAEAAAgAACAgAAAAAAEAAgIAAAAAAAAEAAAAQAABQAA=</HashCode> + <FileName>InputData\Reader\DataObjectAdapter\IDeclarationDataAdapter.cs</FileName> + </TypeIdentifier> + </Interface> <Font Name="Segoe UI" Size="9" /> </ClassDiagram> \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterNinjectModule.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterNinjectModule.cs index 09d8deba25..b2df453030 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterNinjectModule.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterNinjectModule.cs @@ -5,9 +5,11 @@ using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.CompletedBus.Generic; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.CompletedBus.Specific; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.HeavyLorry; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.PrimaryBus; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SingleBus; using TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.CompletedBusRunDataFactory; using TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDataFactory; using TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.PrimaryBusRunDataFactory; +using TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.SingleBus; using TUGraz.VectoCore.Utils.Ninject; namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter @@ -238,6 +240,38 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.PEV_E_IEPC>(); #endregion + #region SingleBus + + Bind<ISingleBusDeclarationDataAdapter>().To<DeclarationDataAdapterSingleBus.Conventional>() + .WhenInjectedExactlyInto<DeclarationModeSingleBusRunDataFactory.Conventional>(); + + Bind<ISingleBusDeclarationDataAdapter>().To<DeclarationDataAdapterSingleBus.HEV_S2>() + .WhenInjectedExactlyInto<DeclarationModeSingleBusRunDataFactory.HEV_S2>(); + Bind<ISingleBusDeclarationDataAdapter>().To<DeclarationDataAdapterSingleBus.HEV_S3>() + .WhenInjectedExactlyInto<DeclarationModeSingleBusRunDataFactory.HEV_S3>(); + Bind<ISingleBusDeclarationDataAdapter>().To<DeclarationDataAdapterSingleBus.HEV_S4>() + .WhenInjectedExactlyInto<DeclarationModeSingleBusRunDataFactory.HEV_S4>(); + Bind<ISingleBusDeclarationDataAdapter>().To<DeclarationDataAdapterSingleBus.HEV_S_IEPC>() + .WhenInjectedExactlyInto<DeclarationModeSingleBusRunDataFactory.HEV_S_IEPC>(); + Bind<ISingleBusDeclarationDataAdapter>().To<DeclarationDataAdapterSingleBus.HEV_P1>() + .WhenInjectedExactlyInto<DeclarationModeSingleBusRunDataFactory.HEV_P1>(); + Bind<ISingleBusDeclarationDataAdapter>().To<DeclarationDataAdapterSingleBus.HEV_P2>() + .WhenInjectedExactlyInto<DeclarationModeSingleBusRunDataFactory.HEV_P2>(); + Bind<ISingleBusDeclarationDataAdapter>().To<DeclarationDataAdapterSingleBus.HEV_P2_5>() + .WhenInjectedExactlyInto<DeclarationModeSingleBusRunDataFactory.HEV_P2_5>(); + Bind<ISingleBusDeclarationDataAdapter>().To<DeclarationDataAdapterSingleBus.HEV_P3>() + .WhenInjectedExactlyInto<DeclarationModeSingleBusRunDataFactory.HEV_P3>(); + Bind<ISingleBusDeclarationDataAdapter>().To<DeclarationDataAdapterSingleBus.HEV_P4>() + .WhenInjectedExactlyInto<DeclarationModeSingleBusRunDataFactory.HEV_P4>(); + Bind<ISingleBusDeclarationDataAdapter>().To<DeclarationDataAdapterSingleBus.PEV_E2>() + .WhenInjectedExactlyInto<DeclarationModeSingleBusRunDataFactory.PEV_E2>(); + Bind<ISingleBusDeclarationDataAdapter>().To<DeclarationDataAdapterSingleBus.PEV_E3>() + .WhenInjectedExactlyInto<DeclarationModeSingleBusRunDataFactory.PEV_E3>(); + Bind<ISingleBusDeclarationDataAdapter>().To<DeclarationDataAdapterSingleBus.PEV_E4>() + .WhenInjectedExactlyInto<DeclarationModeSingleBusRunDataFactory.PEV_E4>(); + Bind<ISingleBusDeclarationDataAdapter>().To<DeclarationDataAdapterSingleBus.PEV_E_IEPC>() + .WhenInjectedExactlyInto<DeclarationModeSingleBusRunDataFactory.PEV_E_IEPC>(); + #endregion #region Factory diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterSingleBus.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterSingleBus.cs deleted file mode 100644 index fab794882b..0000000000 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterSingleBus.cs +++ /dev/null @@ -1,159 +0,0 @@ -//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.InputData.Reader.Impl; -//using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics; -//using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC; -//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; - -//namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter -//{ -// public class DeclarationDataAdapterSingleBus : DeclarationDataAdapterCompletedBusSpecific -// { -// #region Implementation of IDeclarationDataAdapter - -// //public override VehicleData CreateVehicleData(IVehicleDeclarationInputData vehicle, Segment segment, Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) -// //{ -// // var busFloorArea = DeclarationData.BusAuxiliaries.CalculateBusFloorSurfaceArea( -// // CompletedVehicle.Length, -// // CompletedVehicle.Width); -// // var passengerCountRef = busFloorArea * (loading.Key == LoadingType.LowLoading -// // ? mission.BusParameter.PassengerDensityLow -// // : mission.BusParameter.PassengerDensityRef); -// // var passengerCountDecl = CompletedVehicle.NumberPassengerSeatsUpperDeck + -// // CompletedVehicle.NumberPassengerSeatsLowerDeck -// // + (mission.MissionType == MissionType.Coach -// // ? 0 -// // : CompletedVehicle.NumberPassengersStandingLowerDeck + -// // CompletedVehicle.NumberPassengersStandingUpperDeck); - -// // //var refLoad = passengerCount * mission.MissionType.GetAveragePassengerMass(); -// // if (loading.Key != LoadingType.ReferenceLoad && loading.Key != LoadingType.LowLoading) { -// // throw new VectoException("Unhandled loading type: {0}", loading.Key); -// // } - -// // var passengerCountCalc = loading.Key == LoadingType.ReferenceLoad -// // ? VectoMath.Min(passengerCountRef, (int)passengerCountDecl) -// // : passengerCountRef * mission.MissionType.GetLowLoadFactorBus(); -// // var payload = passengerCountCalc * mission.MissionType.GetAveragePassengerMass(); - -// // var retVal = CreateNonExemptedVehicleData(vehicle, segment, mission, payload, passengerCountCalc, allowVocational); -// // retVal.CurbMass = CompletedVehicle.CurbMassChassis; -// // return retVal; -// //} - -// #endregion - - -// //public override CombustionEngineData CreateEngineData( -// // IVehicleDeclarationInputData vehicle, IEngineModeDeclarationInputData mode, Mission mission) -// //{ -// // throw new NotImplementedException(); -// // var engine = vehicle.Components.EngineInputData; -// // var gearbox = vehicle.Components.GearboxInputData; - -// // if (!engine.SavedInDeclarationMode) { -// // WarnDeclarationMode("EngineData"); -// // } - -// // var retVal = SetCommonCombustionEngineData(engine, SingleBusInputData.CompletedVehicle.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, SingleBusInputData.CompletedVehicle.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); -// // 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 override TransmissionLossMap CreateGearLossMap(ITransmissionInputData gear, uint i, bool useEfficiencyFallback, VehicleCategory vehicleCategory, GearboxType gearboxType) -// { -// return TransmissionLossMapReader.Create(gear.LossMap, gear.Ratio, $"Gear {i + 1}", true); -// } - - -// protected override TorqueConverterData CreateTorqueConverterData(GearboxType gearboxType, -// ITorqueConverterDeclarationInputData torqueConverter, double ratio, CombustionEngineData engineData) -// { -// return TorqueConverterDataReader.Create( -// torqueConverter.TCData, -// DeclarationData.TorqueConverter.ReferenceRPM, DeclarationData.TorqueConverter.MaxInputSpeed, -// ExecutionMode.Declaration, ratio, -// DeclarationData.TorqueConverter.CLUpshiftMinAcceleration, -// DeclarationData.TorqueConverter.CCUpshiftMinAcceleration); -// } - - -// public override AxleGearData CreateAxleGearData(IAxleGearInputData data) -// { -// var retVal = SetCommonAxleGearData(data); -// retVal.AxleGear.LossMap = ReadAxleLossMap(data, false); -// return retVal; -// } - -// #region Overrides of DeclarationDataAdapterCompletedBusGeneric - -// //public override RetarderData CreateRetarderData(IRetarderInputData retarder) -// //{ -// // return SetCommonRetarderData(retarder); -// //} - -// #endregion - -// public ISingleBusInputDataProvider SingleBusInputData { get; set; } - -// protected IVehicleDeclarationInputData CompletedVehicle => SingleBusInputData?.CompletedVehicle; -// } -//} diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/IDeclarationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/IDeclarationDataAdapter.cs index f4535c9c89..ac355c2e70 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/IDeclarationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/IDeclarationDataAdapter.cs @@ -15,19 +15,19 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter { //DriverData CreateDriverData(); VehicleData CreateVehicleData(IVehicleDeclarationInputData vehicle, Segment segment, Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational); - //AirdragData CreateAirdragData(IAirdragDeclarationInputData airdragData, Mission mission, Segment segment); - //AxleGearData CreateAxleGearData(IAxleGearInputData axlegearData); - //AngledriveData CreateAngledriveData(IAngledriveInputData angledriveData); - //CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, IEngineModeDeclarationInputData engineMode, Mission mission); - //GearboxData CreateGearboxData( - // IVehicleDeclarationInputData inputData, VectoRunData runData, - // IShiftPolygonCalculator shiftPolygonCalc); - //ShiftStrategyParameters CreateGearshiftData(GearboxData gbx, double axleRatio, PerSecond engineIdlingSpeed); - //RetarderData CreateRetarderData(IRetarderInputData retarderData); - //PTOData CreatePTOTransmissionData(IPTOTransmissionInputData ptoData); - //IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxData, IBusAuxiliariesDeclarationData busAuxData, MissionType missionType, VehicleClass vehicleClass, Meter vehicleLength, int? numSteeredAxles); - //AxleGearData CreateDummyAxleGearData(IGearboxDeclarationInputData gbxData); - } + //AirdragData CreateAirdragData(IAirdragDeclarationInputData airdragData, Mission mission, Segment segment); + //AxleGearData CreateAxleGearData(IAxleGearInputData axlegearData); + //AngledriveData CreateAngledriveData(IAngledriveInputData angledriveData); + //CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, IEngineModeDeclarationInputData engineMode, Mission mission); + //GearboxData CreateGearboxData( + // IVehicleDeclarationInputData inputData, VectoRunData runData, + // IShiftPolygonCalculator shiftPolygonCalc); + //ShiftStrategyParameters CreateGearshiftData(GearboxData gbx, double axleRatio, PerSecond engineIdlingSpeed); + //RetarderData CreateRetarderData(IRetarderInputData retarderData); + //PTOData CreatePTOTransmissionData(IPTOTransmissionInputData ptoData); + //IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxData, IBusAuxiliariesDeclarationData busAuxData, MissionType missionType, VehicleClass vehicleClass, Meter vehicleLength, int? numSteeredAxles); + //AxleGearData CreateDummyAxleGearData(IGearboxDeclarationInputData gbxData); + } public interface ILorryDeclarationDataAdapter : IDeclarationDataAdapter { @@ -145,4 +145,23 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter CombustionEngineData CreateEngineData(IVehicleDeclarationInputData primaryVehicle, int modeIdx, Mission mission); } + + public interface ISingleBusDeclarationDataAdapter : IDeclarationDataAdapter + { + AirdragData CreateAirdragData(IVehicleDeclarationInputData completedVehicle, Mission mission); + CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, + IEngineModeDeclarationInputData engineMode, Mission mission); + DriverData CreateDriverData(); + AxleGearData CreateDummyAxleGearData(IGearboxDeclarationInputData gearboxInputData); + AxleGearData CreateAxleGearData(IAxleGearInputData axleGearInputData); + AngledriveData CreateAngledriveData(IAngledriveInputData angledriveData); + GearboxData CreateGearboxData(IVehicleDeclarationInputData inputData, + VectoRunData runData, + IShiftPolygonCalculator shiftPolygonCalc); + RetarderData CreateRetarderData(IRetarderInputData retarderData); + + ShiftStrategyParameters CreateGearshiftData(GearboxData gbx, double axleRatio, PerSecond engineIdlingSpeed); + IEnumerable<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxInputData, IBusAuxiliariesDeclarationData busAuxInput, MissionType mission, VehicleClass segment, Meter vehicleLength, int? numSteeredAxles); + IAuxiliaryConfig CreateBusAuxiliariesData(Mission mission, IVehicleDeclarationInputData primaryVehicle, IVehicleDeclarationInputData completedVehicle, VectoRunData simulationRunData); + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/PrimaryBus/DeclarationDataAdapterPrimaryBus.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/PrimaryBus/DeclarationDataAdapterPrimaryBus.cs index 97f956d34f..d051be2fe3 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/PrimaryBus/DeclarationDataAdapterPrimaryBus.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/PrimaryBus/DeclarationDataAdapterPrimaryBus.cs @@ -34,6 +34,9 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.PrimaryBus protected readonly IPTODataAdapter _ptoDataAdapter = new PTODataAdapterBus(); protected readonly IPrimaryBusAuxiliaryDataAdapter _auxDataAdapter = new PrimaryBusAuxiliaryDataAdapter(); protected readonly IRetarderDataAdapter _retarderDataAdapter = new RetarderDataAdapter(); + protected readonly IAirdragDataAdapter _airdragDataAdapter = new AirdragDataAdapter(); + private readonly IAngledriveDataAdapter _angledriveDataAdapter = new AngledriveDataAdapter(); + private readonly IEngineDataAdapter _engineDataAdapter = new CombustionEngineComponentDataAdapter(); public DriverData CreateDriverData() { @@ -49,7 +52,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.PrimaryBus public AirdragData CreateAirdragData(IAirdragDeclarationInputData airdragData, Mission mission, Segment segment) { - throw new NotImplementedException(); + return _airdragDataAdapter.CreateAirdragData(airdragData, mission, segment); } public AxleGearData CreateAxleGearData(IAxleGearInputData axlegearData) @@ -59,7 +62,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.PrimaryBus public AngledriveData CreateAngledriveData(IAngledriveInputData angledriveData) { - throw new NotImplementedException(); + return _angledriveDataAdapter.CreateAngledriveData(angledriveData); } public virtual CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, IEngineModeDeclarationInputData engineMode, diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AirdragDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AirdragDataAdapter.cs index 8e3afd76eb..9b13abe430 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AirdragDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AirdragDataAdapter.cs @@ -21,9 +21,9 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen Segment segment); } - public class AirdragDataAdapter : IAirdragDataAdapter + public static class AirdragDataAdapterHelper { - public List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> GetDeclarationAirResistanceCurve( + public static List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> GetDeclarationAirResistanceCurve( string crosswindCorrectionParameters, SquareMeter aerodynamicDragAera, Meter vehicleHeight) { var startSpeed = Constants.SimulationSettings.CrosswindCorrection.MinVehicleSpeed; @@ -94,7 +94,31 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen points[0].EffectiveCrossSectionArea = points[1].EffectiveCrossSectionArea; return points; } - protected virtual AirdragData DefaultAirdragData(Mission mission) + internal static AirdragData SetCommonAirdragData(IAirdragDeclarationInputData data) + { + var retVal = new AirdragData() + { + SavedInDeclarationMode = data.SavedInDeclarationMode, + Manufacturer = data.Manufacturer, + ModelName = data.Model, + Date = data.Date, + CertificationMethod = data.CertificationMethod, + CertificationNumber = data.CertificationNumber, + DigestValueInput = data.DigestValue != null ? data.DigestValue.DigestValue : "", + }; + return retVal; + } + } + + public class AirdragDataAdapter : IAirdragDataAdapter + { + public List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> GetDeclarationAirResistanceCurve( + string crosswindCorrectionParameters, SquareMeter aerodynamicDragAera, Meter vehicleHeight) + { + return AirdragDataAdapterHelper.GetDeclarationAirResistanceCurve(crosswindCorrectionParameters, + aerodynamicDragAera, vehicleHeight); + } + protected AirdragData DefaultAirdragData(Mission mission) { var aerodynamicDragArea = mission.DefaultCDxA + mission.Trailer.Sum(t => t.DeltaCdA).DefaultIfNull(0); @@ -112,19 +136,10 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen } internal AirdragData SetCommonAirdragData(IAirdragDeclarationInputData data) { - var retVal = new AirdragData() { - SavedInDeclarationMode = data.SavedInDeclarationMode, - Manufacturer = data.Manufacturer, - ModelName = data.Model, - Date = data.Date, - CertificationMethod = data.CertificationMethod, - CertificationNumber = data.CertificationNumber, - DigestValueInput = data.DigestValue != null ? data.DigestValue.DigestValue : "", - }; - return retVal; + return AirdragDataAdapterHelper.SetCommonAirdragData(data); } - public AirdragData CreateAirdragData( + public virtual AirdragData CreateAirdragData( IAirdragDeclarationInputData airdragInputData, Mission mission, Segment segment) { @@ -152,4 +167,45 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen } } + + public class SingleBusAirdragDataAdapter + { + #region Overrides of AirdragDataAdapter + public AirdragData CreateAirdragData(IVehicleDeclarationInputData completedVehicle, Mission mission) + { + if (!mission.BusParameter.AirDragMeasurementAllowed || + completedVehicle.Components.AirdragInputData?.AirDragArea == null) + { + return new AirdragData() + { + CertificationMethod = CertificationMethod.StandardValues, + DeclaredAirdragArea = mission.DefaultCDxA, + CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup( + mission.DefaultCDxA, + AirdragDataAdapterHelper.GetDeclarationAirResistanceCurve( + mission.CrossWindCorrectionParameters, mission.DefaultCDxA, completedVehicle.Height + mission.BusParameter.DeltaHeight), + CrossWindCorrectionMode.DeclarationModeCorrection), + CrossWindCorrectionMode = CrossWindCorrectionMode.DeclarationModeCorrection + }; + } + + var retVal = AirdragDataAdapterHelper.SetCommonAirdragData(completedVehicle.Components.AirdragInputData); + retVal.CrossWindCorrectionMode = CrossWindCorrectionMode.DeclarationModeCorrection; + var aerodynamicDragArea = completedVehicle.Components.AirdragInputData.AirDragArea; + + retVal.DeclaredAirdragArea = aerodynamicDragArea; + retVal.CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup( + aerodynamicDragArea, + AirdragDataAdapterHelper.GetDeclarationAirResistanceCurve( + mission.CrossWindCorrectionParameters, + aerodynamicDragArea, + completedVehicle.Height + mission.BusParameter.DeltaHeight), + CrossWindCorrectionMode.DeclarationModeCorrection); + + return retVal; + } + + + #endregion + } } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AuxiliaryDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AuxiliaryDataAdapter.cs index 1bfdece45d..388afe80d7 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AuxiliaryDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AuxiliaryDataAdapter.cs @@ -856,7 +856,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen return _primaryBusDataAdapter.SelectBenefitForFloorType(completedVehicle.VehicleCode.GetFloorType(), onVehicle); } - protected Dictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry> GetElectricAuxConsumers(Mission mission, IVehicleDeclarationInputData vehicleData, VehicleClass vehicleClass, IBusAuxiliariesDeclarationData busAux) + protected override Dictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry> GetElectricAuxConsumers(Mission mission, IVehicleDeclarationInputData vehicleData, VehicleClass vehicleClass, IBusAuxiliariesDeclarationData busAux) { return new Dictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry>(); } @@ -891,7 +891,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen protected virtual ElectricsUserInputsConfig CreateElectricsUserInputsConfig(IVehicleDeclarationInputData primaryVehicle, IVehicleDeclarationInputData completedVehicle, Mission mission, IActuations actuations, VehicleClass vehicleClass) { - var currentDemand = _primaryBusDataAdapter.GetElectricConsumers(mission, completedVehicle, actuations, vehicleClass); + var currentDemand = GetElectricConsumers(mission, completedVehicle, actuations, vehicleClass); // add electrical steering pump or electric fan defined in primary vehicle foreach (var entry in GetElectricAuxConsumersPrimary(mission, completedVehicle, vehicleClass, primaryVehicle.Components.BusAuxiliaries)) @@ -899,7 +899,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen currentDemand[entry.Key] = entry.Value; } - var retVal = _primaryBusDataAdapter.GetDefaultElectricalUserConfig(); + var retVal = GetDefaultElectricalUserConfig(); var primaryBusAuxiliaries = primaryVehicle.Components.BusAuxiliaries; retVal.AlternatorType = primaryBusAuxiliaries.ElectricSupply.AlternatorTechnology; diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/DataAdapterBase.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/DataAdapterBase.cs index abb20ce585..23206fafe8 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/DataAdapterBase.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/DataAdapterBase.cs @@ -7,6 +7,9 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen { protected void CheckDeclarationMode(IComponentInputData component, string componentName) { + if (component == null) { + return; + } if (!component.SavedInDeclarationMode) { Log.Warn("{0} not in Declaration Mode!", componentName); @@ -14,6 +17,9 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen } protected void CheckDeclarationMode(IAuxiliariesDeclarationInputData aux, string componentName) { + if (aux == null) { + return; + } if (!aux.SavedInDeclarationMode) { Log.Warn("{0} not in Declaration Mode!", componentName); diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/PTODataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/PTODataAdapter.cs index 10cc5407c7..3251019fa0 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/PTODataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/PTODataAdapter.cs @@ -46,6 +46,10 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen public class PTODataAdapterBus : IPTODataAdapter { + public static PTOData DefaultPTOData() + { + return null; + } #region Implementation of IPTODataAdapter public PTOData CreatePTOTransmissionData(IPTOTransmissionInputData pto) @@ -55,7 +59,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen public PTOData CreateDefaultPTOData() { - return null; + return DefaultPTOData(); } #endregion diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SingleBus/DeclarationDataAdapterSingleBus.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SingleBus/DeclarationDataAdapterSingleBus.cs new file mode 100644 index 0000000000..8fd3d1e7fd --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SingleBus/DeclarationDataAdapterSingleBus.cs @@ -0,0 +1,164 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TUGraz.VectoCommon.BusAuxiliaries; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponents; +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.SingleBus +{ + public abstract class DeclarationDataAdapterSingleBus + { + + + public abstract class SingleBusBase : ISingleBusDeclarationDataAdapter + { + public static readonly GearboxType[] SupportedGearboxTypes = + { GearboxType.MT, GearboxType.AMT, GearboxType.ATPowerSplit, GearboxType.ATSerial }; + + private SingleBusAirdragDataAdapter _airdragDataAdapter = new SingleBusAirdragDataAdapter(); + private IGearboxDataAdapter _gearboxDataAdapter = new GearboxDataAdapter(new TorqueConverterDataAdapter()); + + private ICompletedBusAuxiliaryDataAdapter _busAuxiliaryDataAdapter = + new SpecificCompletedBusAuxiliaryDataAdapter(new PrimaryBusAuxiliaryDataAdapter()); + + private IVehicleDataAdapter _vehicleDataAdapter = new PrimaryBusVehicleDataAdapter(); + private IAxleGearDataAdapter _axleGearDataAdapter = new AxleGearDataAdapter(); + private IDriverDataAdapter _driverDataAdapter = new PrimaryBusDriverDataAdapter(); + private IAngledriveDataAdapter _angledriveDataAdapter = new AngledriveDataAdapter(); + private IEngineDataAdapter _engineDataAdapter = new CombustionEngineComponentDataAdapter(); + private IRetarderDataAdapter _retarderDataAdapter = new RetarderDataAdapter(); + + #region Implementation of IDeclarationDataAdapter + + public VehicleData CreateVehicleData(IVehicleDeclarationInputData vehicle, Segment segment, Mission mission, + KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) + { + return _vehicleDataAdapter.CreateVehicleData(vehicle, segment, mission, loading.Value.Item1, + loading.Value.Item2, allowVocational); + } + + + #endregion + + #region Implementation of ISingleBusDeclarationDataAdapter + + public AirdragData CreateAirdragData(IVehicleDeclarationInputData completedVehicle, Mission mission) + { + return _airdragDataAdapter.CreateAirdragData(completedVehicle, mission); + } + + public CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, + IEngineModeDeclarationInputData engineMode, Mission mission) + { + return _engineDataAdapter.CreateEngineData(vehicle, engineMode, mission); + } + + public DriverData CreateDriverData() + { + return _driverDataAdapter.CreateDriverData(); + } + + public AxleGearData CreateDummyAxleGearData(IGearboxDeclarationInputData gearboxInputData) + { + return _axleGearDataAdapter.CreateDummyAxleGearData(gearboxInputData); + } + + public AxleGearData CreateAxleGearData(IAxleGearInputData axleGearInputData) + { + return _axleGearDataAdapter.CreateAxleGearData(axleGearInputData); + } + + public AngledriveData CreateAngledriveData(IAngledriveInputData angledriveData) + { + return _angledriveDataAdapter.CreateAngledriveData(angledriveData); + } + + public GearboxData CreateGearboxData(IVehicleDeclarationInputData inputData, VectoRunData runData, + IShiftPolygonCalculator shiftPolygonCalc) + { + return _gearboxDataAdapter.CreateGearboxData(inputData, runData, shiftPolygonCalc, + SupportedGearboxTypes); + } + + public RetarderData CreateRetarderData(IRetarderInputData retarderData) + { + return _retarderDataAdapter.CreateRetarderData(retarderData); + } + + public PTOData CreatePTOTransmissionData(IPTOTransmissionInputData ptoData) + { + throw new NotImplementedException(); + } + + public ShiftStrategyParameters CreateGearshiftData(GearboxData gbx, double axleRatio, + PerSecond engineIdlingSpeed) + { + return _gearboxDataAdapter.CreateGearshiftData(gbx, axleRatio, engineIdlingSpeed); + } + + public IEnumerable<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxInputData, + IBusAuxiliariesDeclarationData busAuxInput, MissionType mission, + VehicleClass segment, Meter vehicleLength, int? numSteeredAxles) + { + return _busAuxiliaryDataAdapter.CreateAuxiliaryData(auxInputData, busAuxInput, mission, segment, + vehicleLength, numSteeredAxles); + } + + public IAuxiliaryConfig CreateBusAuxiliariesData(Mission mission, + IVehicleDeclarationInputData primaryVehicle, + IVehicleDeclarationInputData completedVehicle, VectoRunData simulationRunData) + { + return _busAuxiliaryDataAdapter.CreateBusAuxiliariesData(mission, primaryVehicle, completedVehicle, + simulationRunData); + } + + #endregion + } + + public class Conventional : SingleBusBase { } + + public class Hybrid : SingleBusBase { } + + public class SerialHybrid : Hybrid { } + + public class HEV_S2 : SerialHybrid { } + + public class HEV_S3 : SerialHybrid { } + + public class HEV_S4 : SerialHybrid { } + + public class HEV_S_IEPC : SerialHybrid { } + + public class ParallelHybrid : Hybrid { } + + public class HEV_P1 : ParallelHybrid { } + + public class HEV_P2 : ParallelHybrid { } + + public class HEV_P2_5 : ParallelHybrid { } + + public class HEV_P3 : ParallelHybrid { } + + public class HEV_P4 : ParallelHybrid { } + + public class BatteryElectric : SingleBusBase { } + + public class PEV_E2 : BatteryElectric { } + + public class PEV_E3 : BatteryElectric { } + + public class PEV_E4 : BatteryElectric { } + + public class PEV_E_IEPC : BatteryElectric { } + + } +} diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/CompletedBusRunDataFactory/DeclarationModeCompletedBusRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/CompletedBusRunDataFactory/DeclarationModeCompletedBusRunDataFactory.cs index 9e3b7c9f97..13dcb8c9db 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/CompletedBusRunDataFactory/DeclarationModeCompletedBusRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/CompletedBusRunDataFactory/DeclarationModeCompletedBusRunDataFactory.cs @@ -114,6 +114,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.CompletedBusRun var simulationRunData = new VectoRunData { + InputData = DataProvider.MultistageJobInputData, Loading = loading.Key, VehicleData = DataAdapterGeneric.CreateVehicleData(PrimaryVehicle, primarySegment, mission, loading, false), AirdragData = DataAdapterGeneric.CreateAirdragData(null, mission, new Segment()), @@ -152,6 +153,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.CompletedBusRun var simulationRunData = new VectoRunData { + InputData = DataProvider.MultistageJobInputData, Loading = loading.Key, VehicleData = DataAdapterSpecific.CreateVehicleData(PrimaryVehicle, CompletedVehicle, _segmentCompletedBus, mission, loading), diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/PrimaryBusRunDataFactory/DeclarationModePrimaryBusRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/PrimaryBusRunDataFactory/DeclarationModePrimaryBusRunDataFactory.cs index db6a6a2316..0cb8590fc5 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/PrimaryBusRunDataFactory/DeclarationModePrimaryBusRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/PrimaryBusRunDataFactory/DeclarationModePrimaryBusRunDataFactory.cs @@ -140,6 +140,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.PrimaryBusRunDa { return new VectoRunData { + InputData = DataProvider, Exempted = true, Report = Report, Mission = new Mission { MissionType = MissionType.ExemptedMission }, @@ -159,6 +160,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.PrimaryBusRunDa var simulationRunData = new VectoRunData { + InputData = DataProvider, Loading = loading.Key, VehicleData = DataAdapter.CreateVehicleData(vehicle, _segment, mission, loading, _allowVocational), VehicleDesignSpeed = _segment.DesignSpeed, diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/SingleBus/DeclarationModeSingleBusVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/SingleBus/DeclarationModeSingleBusVectoRunDataFactory.cs new file mode 100644 index 0000000000..05559b092c --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/SingleBus/DeclarationModeSingleBusVectoRunDataFactory.cs @@ -0,0 +1,446 @@ +using System; +using System.Collections.Generic; +using System.Data.Common; +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.InputData.Reader.DataObjectAdapter.SimulationComponents; +using TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDataFactory; +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; + +namespace TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.SingleBus +{ + + public abstract class DeclarationModeSingleBusRunDataFactory + { + public abstract class SingleBusBase : IVectoRunDataFactory + { + private Segment _segment; + private DriverData _driverdata; + private bool _allowVocational = true; + private AirdragData _airdragData; + private AxleGearData _axlegearData; + private AngledriveData _angledriveData; + private GearboxData _gearboxData; + private ShiftStrategyParameters _gearshiftData; + private RetarderData _retarderData; + private PTOData _ptoTransmissionData; + protected ISingleBusDeclarationDataAdapter DataAdapter { get; } + protected IDeclarationReport Report { get; } + + public ISingleBusInputDataProvider DataProvider { get; } + + protected SingleBusBase(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, + ISingleBusDeclarationDataAdapter dataAdapter) + { + DataAdapter = dataAdapter; + Report = report; + DataProvider = dataProvider; + } + + + + + #region Overrides of AbstractDeclarationVectoRunDataFactory + + public IEnumerable<VectoRunData> NextRun() + { + + Initialize(); + if (Report != null) + { + InitializeReport(); + } + + return GetNextRun(); + } + + private IEnumerable<VectoRunData> GetNextRun() + { + + var vehicle = DataProvider.JobInputData.Vehicle; + if (vehicle.ExemptedVehicle) { + throw new NotImplementedException("Implement in derived class for exempted single buses"); + } + var engine = vehicle.Components.EngineInputData; + var engineModes = engine.EngineModes; + + for (var modeIdx = 0; modeIdx < engineModes.Count; modeIdx++) + { + foreach (var mission in _segment.Missions) + { + foreach (var loading in mission.Loadings) + { + var simulationRunData = CreateVectoRunData(DataProvider, modeIdx, mission, loading); + if (simulationRunData == null) + { + continue; + } + yield return simulationRunData; + } + } + } + } + + + protected void InitializeReport() + { + //Do nothing + } + + protected void Initialize() + { + var vehicle = DataProvider.JobInputData.Vehicle; + if (vehicle.ExemptedVehicle) + { + return; + } + + _segment = GetSegment(DataProvider); + _driverdata = DataAdapter.CreateDriverData(); //PrimaryBus + _driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(_segment.AccelerationFile); + var tempVehicle = DataAdapter.CreateVehicleData(vehicle, _segment, _segment.Missions.First(), + _segment.Missions.First().Loadings.First(), _allowVocational); + if (vehicle.AxleConfiguration.AxlegearIncludedInGearbox()) + { + _axlegearData = DataAdapter.CreateDummyAxleGearData(vehicle.Components.GearboxInputData); + } + else + { + _axlegearData = DataAdapter.CreateAxleGearData(vehicle.Components.AxleGearInputData); + } + _angledriveData = DataAdapter.CreateAngledriveData(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); + + _gearshiftData = DataAdapter.CreateGearshiftData( + _gearboxData, _axlegearData.AxleGear.Ratio * (_angledriveData?.Angledrive.Ratio ?? 1.0), tmpEngine.IdleSpeed); + } + + protected VectoRunData CreateVectoRunData(ISingleBusInputDataProvider singleBus, int modeIdx, Mission mission, + KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading) + { + var vehicle = singleBus.JobInputData.Vehicle; + var completedVehicle = singleBus.CompletedVehicle; + var primaryVehicle = singleBus.PrimaryVehicle; + var doubleDecker = completedVehicle.NumberPassengerSeatsUpperDeck > 0; + if (mission.BusParameter.DoubleDecker != doubleDecker) + { + return null; + } + + var engine = 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 + { + InputData = DataProvider, + Loading = loading.Key, + VehicleData = DataAdapter.CreateVehicleData(vehicle, _segment, mission, loading, _allowVocational), //Primary + AirdragData = DataAdapter.CreateAirdragData(completedVehicle, mission), //Single + EngineData = DataAdapter.CreateEngineData(vehicle, engineMode, mission), //Primary + 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 ?? mission.BusParameter.VehicleLength, + vehicle.Components.AxleWheels.NumSteeredAxles), + Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), + Retarder = _retarderData, + DriverData = _driverdata, + ExecutionMode = ExecutionMode.Declaration, + JobName = DataProvider.JobInputData.JobName, + ModFileSuffix = $"{(engineModes.Count > 1 ? $"_EngineMode{modeIdx}_" : "")}" + + $"_{mission.BusParameter.BusGroup.GetClassNumber()}-Single_{loading.Key}", + Report = Report, + Mission = mission, + InputDataHash = DataProvider.XMLHash, + SimulationType = SimulationType.DistanceCycle, + GearshiftParameters = _gearshiftData, + VehicleDesignSpeed = _segment.DesignSpeed, + //ShiftStrategy = InputDataProvider.JobInputData.ShiftStrategy + }; + simulationRunData.EngineData.FuelMode = modeIdx; + simulationRunData.VehicleData.VehicleClass = _segment.VehicleClass; + simulationRunData.BusAuxiliaries = DataAdapter.CreateBusAuxiliariesData(mission, primaryVehicle, completedVehicle, simulationRunData); + return simulationRunData; + } + + #endregion + protected Segment GetSegment(ISingleBusInputDataProvider singleBus) + { + var vehicle = singleBus.JobInputData.Vehicle; + var completedVehicle = singleBus.CompletedVehicle; + var primaryVehicle = singleBus.PrimaryVehicle; + + var segment = DeclarationData.CompletedBusSegments.Lookup( + primaryVehicle.AxleConfiguration.NumAxles(), completedVehicle.VehicleCode, completedVehicle.RegisteredClass, completedVehicle.NumberPassengerSeatsLowerDeck, + completedVehicle.Height, completedVehicle.LowEntry); + if (!segment.Found) + { + throw new VectoException( + "no segment found for vehicle configruation: vehicle category: {0}, axle configuration: {1}, articulated: {2}, vehicle code: {3}, registered class: {4}, passengersLowerDeck: {5}, height: {6}, lowfloor: {7}. completed", + vehicle.VehicleCategory, primaryVehicle.AxleConfiguration, + vehicle.Articulated, completedVehicle.VehicleCode, completedVehicle.RegisteredClass.GetLabel(), completedVehicle.NumberPassengerSeatsLowerDeck, + completedVehicle.Height, completedVehicle.LowEntry); + } + foreach (var mission in segment.Missions) + { + mission.VehicleHeight = completedVehicle.Height + mission.BusParameter.DeltaHeight; + mission.BusParameter.VehicleLength = completedVehicle.Length; + } + return segment; + } + } + + + + public class Conventional : SingleBusBase + { + public Conventional(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, + ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) + { + + } + + } + + public abstract class Hybrid : SingleBusBase + { + protected Hybrid(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) { } + } + + public class SerialHybrid : Hybrid + { + protected SerialHybrid(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) { } + } + public class HEV_S2 : SerialHybrid + { + protected HEV_S2(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) { } + } + + public class HEV_S3 : SerialHybrid + { + protected HEV_S3(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) { } + } + + public class HEV_S4 : SerialHybrid + { + protected HEV_S4(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) { } + } + + + public class HEV_S_IEPC : SerialHybrid + { + protected HEV_S_IEPC(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) { } + } + + public class ParallelHybrid : Hybrid + { + public ParallelHybrid(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) { } + } + + public class HEV_P1 : ParallelHybrid + { + public HEV_P1(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) { } + } + + public class HEV_P2 : ParallelHybrid + { + public HEV_P2(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) { } + } + + public class HEV_P2_5 : ParallelHybrid + { + public HEV_P2_5(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) { } + } + + public class HEV_P3 : ParallelHybrid + { + public HEV_P3(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) { } + } + + public class HEV_P4 : ParallelHybrid + { + public HEV_P4(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) { } + } + + public class BatteryElectric : SingleBusBase + { + public BatteryElectric(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) { } + } + + public class PEV_E2 : BatteryElectric + { + public PEV_E2(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) { } + } + + public class PEV_E3 : BatteryElectric + { + public PEV_E3(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) { } + } + + public class PEV_E4 : BatteryElectric + { + public PEV_E4(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) { } + } + + public class PEV_E_IEPC : BatteryElectric + { + public PEV_E_IEPC(ISingleBusInputDataProvider dataProvider, IDeclarationReport report, ISingleBusDeclarationDataAdapter dataAdapter) : base(dataProvider, report, dataAdapter) { } + } + + + + + + + + } + + //internal class DeclarationModeSingleBusVectoRunDataFactory : DeclarationModePrimaryBusVectoRunDataFactory + //{ + // protected new DeclarationDataAdapterSingleBus _dao = new DeclarationDataAdapterSingleBus(); + // private ISingleBusInputDataProvider _singleBusInputData; + + // public DeclarationModeSingleBusVectoRunDataFactory(ISingleBusInputDataProvider singleBusInputData, IDeclarationReport report) : base(singleBusInputData, report) + // { + // _singleBusInputData = singleBusInputData; + // _dao.SingleBusInputData = singleBusInputData; + // } + + + // protected override Segment GetSegment(IVehicleDeclarationInputData vehicle) + // { + // //if (vehicle.VehicleCategory != VehicleCategory.HeavyBusCompletedVehicle) { + // // throw new VectoException( + // // "Invalid vehicle category for bus factory! {0}", vehicle.VehicleCategory.GetCategoryName()); + // //} + + // var completedVehicle = _singleBusInputData.CompletedVehicle; + + // var segment = DeclarationData.CompletedBusSegments.Lookup( + // _singleBusInputData.PrimaryVehicle.AxleConfiguration.NumAxles(), completedVehicle.VehicleCode, completedVehicle.RegisteredClass, completedVehicle.NumberPassengerSeatsLowerDeck, + // completedVehicle.Height, completedVehicle.LowEntry); + // if (!segment.Found) + // { + // throw new VectoException( + // "no segment found for vehicle configruation: vehicle category: {0}, axle configuration: {1}, articulated: {2}, vehicle code: {3}, registered class: {4}, passengersLowerDeck: {5}, height: {6}, lowfloor: {7}. completed", + // vehicle.VehicleCategory, _singleBusInputData.PrimaryVehicle.AxleConfiguration, + // vehicle.Articulated, completedVehicle.VehicleCode, completedVehicle.RegisteredClass.GetLabel(), completedVehicle.NumberPassengerSeatsLowerDeck, + // completedVehicle.Height, completedVehicle.LowEntry); + // } + // foreach (var mission in segment.Missions) + // { + // mission.VehicleHeight = completedVehicle.Height + mission.BusParameter.DeltaHeight; + // mission.BusParameter.VehicleLength = completedVehicle.Length; + // } + + // return segment; + // } + + + // protected override ISingleBusDeclarationDataAdapter DataAdapter => _dao; + + + // protected override VectoRunData CreateVectoRunData(IVehicleDeclarationInputData vehicle, int modeIdx, Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading) + // { + // var doubleDecker = _singleBusInputData.CompletedVehicle.NumberPassengerSeatsUpperDeck > 0; + // if (mission.BusParameter.DoubleDecker != doubleDecker) + // { + // return null; + // } + + // var engine = 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), + // AirdragData = _dao.CreateAirdragData(_singleBusInputData.CompletedVehicle, mission), + // EngineData = DataAdapter.CreateEngineData(InputDataProvider.JobInputData.Vehicle, engineMode, mission), + // 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 ?? mission.BusParameter.VehicleLength, + // 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}_" : "")}" + + // $"_{mission.BusParameter.BusGroup.GetClassNumber()}-Single_{loading.Key}", + // Report = Report, + // Mission = mission, + // InputDataHash = InputDataProvider.XMLHash, + // SimulationType = SimulationType.DistanceCycle, + // GearshiftParameters = _gearshiftData, + // VehicleDesignSpeed = _segment.DesignSpeed, + // //ShiftStrategy = InputDataProvider.JobInputData.ShiftStrategy + // }; + // simulationRunData.EngineData.FuelMode = modeIdx; + // simulationRunData.VehicleData.VehicleClass = _segment.VehicleClass; + // simulationRunData.BusAuxiliaries = _dao.CreateBusAuxiliariesData(mission, _singleBusInputData.PrimaryVehicle, _singleBusInputData.CompletedVehicle, simulationRunData); + // return simulationRunData; + // } + + // protected override 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, _singleBusInputData.CompletedVehicle.TankSystem)).ToList()) + // .ToList(); + // } + // Report.InitializeReport(powertrainConfig, fuels); + // } + //} + + +} diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs deleted file mode 100644 index 9d73db9cb1..0000000000 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs +++ /dev/null @@ -1,296 +0,0 @@ -//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.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; - - -//namespace TUGraz.VectoCore.InputData.Reader.Impl -//{ -// public class DeclarationModeCompletedBusVectoRunDataFactory : LoggingObject, IVectoRunDataFactory -// { -// protected readonly IDeclarationInputDataProvider InputDataProvider; -// protected IDeclarationReport Report; - - -// protected Segment _segmentCompletedBus; - -// protected AxleGearData _axlegearData; -// protected AngledriveData _angledriveData; -// protected GearboxData _gearboxData; -// protected RetarderData _retarderData; - -// protected IAlternatorMap _alternatorMap; -// protected ICompressorMap _compressorMap; -// //protected IPneumaticsConsumersDemand _consumersDeclarationData; - -// //protected CombustionEngineData _combustionEngineData; - -// //protected Exception InitException; -// protected ShiftStrategyParameters _gearshiftData; - -// //private VehicleData _tmpVehicleData; -// private DriverData _driverData; - - - -// protected DeclarationDataAdapterCompletedBusSpecific DataAdapterSpecific = new DeclarationDataAdapterCompletedBusSpecific(); - -// protected DeclarationDataAdapterCompletedBusGeneric DataAdapterGeneric = new DeclarationDataAdapterCompletedBusGeneric(); - -// public DeclarationModeCompletedBusVectoRunDataFactory( -// IDeclarationInputDataProvider dataProvider, IDeclarationReport report) -// { -// InputDataProvider = dataProvider; -// Report = report; -// } - -// protected IVehicleDeclarationInputData PrimaryVehicle => InputDataProvider.PrimaryVehicleData.Vehicle; - -// protected IVehicleDeclarationInputData CompletedVehicle => InputDataProvider.JobInputData.Vehicle; - -// public IEnumerable<VectoRunData> NextRun() -// { -// Initialize(); -// if (Report != null) { -// InitializeReport(); -// } - -// return GetNextRun(); -// } - -// protected virtual void InitializeReport() -// { -// var powertrainConfig = _segmentCompletedBus.Missions.Select( -// mission => CreateVectoRunDataSpecific( -// mission, mission.Loadings.First(), 0)) -// .FirstOrDefault(x => x != null); - -// Report.InitializeReport(powertrainConfig, new List<List<FuelData.Entry>>()); -// } - - - -// protected virtual void Initialize() -// { -// if (CompletedVehicle.ExemptedVehicle || PrimaryVehicle.ExemptedVehicle) { -// return; -// } - -// _segmentCompletedBus = GetCompletedSegment(CompletedVehicle, PrimaryVehicle.AxleConfiguration); - -// var tmpVehicleData = DataAdapterSpecific.CreateVehicleData(PrimaryVehicle, CompletedVehicle, _segmentCompletedBus, _segmentCompletedBus.Missions.First(), -// _segmentCompletedBus.Missions.First().Loadings.First()); -// tmpVehicleData.VehicleCategory = VehicleCategory.GenericBusVehicle; - -// var combustionEngineData = DataAdapterGeneric.CreateEngineData(PrimaryVehicle, 0, _segmentCompletedBus.Missions.First()); - -// _axlegearData = DataAdapterGeneric.CreateAxleGearData(PrimaryVehicle.Components.AxleGearInputData); - -// _angledriveData = DataAdapterGeneric.CreateAngledriveData(PrimaryVehicle.Components.AngledriveInputData); - -// var tmpRunData = new VectoRunData() { -// GearboxData = new GearboxData() { -// Type = PrimaryVehicle.Components.GearboxInputData.Type, -// } -// }; -// var tmpStrategy = PowertrainBuilder.GetShiftStrategy(new SimplePowertrainContainer(tmpRunData)); - -// _gearboxData = DataAdapterGeneric.CreateGearboxData(PrimaryVehicle, new VectoRunData() { EngineData = combustionEngineData, AxleGearData = _axlegearData, VehicleData = tmpVehicleData }, -// tmpStrategy); - -// _gearshiftData = DataAdapterGeneric.CreateGearshiftData( -// _gearboxData, _axlegearData.AxleGear.Ratio * (_angledriveData?.Angledrive.Ratio ?? 1.0), combustionEngineData.IdleSpeed); - -// _retarderData = DataAdapterGeneric.CreateRetarderData(PrimaryVehicle.Components.RetarderInputData); - - -// _driverData = DataAdapterGeneric.CreateDriverData(); -// _driverData.AccelerationCurve = AccelerationCurveReader.ReadFromStream(_segmentCompletedBus.AccelerationFile); -// } - -// protected virtual IEnumerable<VectoRunData> GetNextRun() -// { -// if (InputDataProvider.JobInputData.Vehicle.VehicleCategory == VehicleCategory.HeavyBusCompletedVehicle) { -// return VectoRunDataHeavyBusCompleted(); -// } - -// return new List<VectoRunData>(); -// } - -// private IEnumerable<VectoRunData> VectoRunDataHeavyBusCompleted() -// { -// var engineModes = InputDataProvider.PrimaryVehicleData.Vehicle.Components.EngineInputData.EngineModes; - -// for (var modeIdx = 0; modeIdx < engineModes.Count; modeIdx++) { -// var fuelMode = "single fuel mode"; -// if (engineModes[modeIdx].Fuels.Count > 1) { -// fuelMode = "dual fuel mode"; -// } -// foreach (var mission in _segmentCompletedBus.Missions) { -// foreach (var loading in mission.Loadings) { -// var simulationRunData = CreateVectoRunDataSpecific(mission, loading, modeIdx); -// if (simulationRunData != null) { -// yield return simulationRunData; -// } - -// var primarySegment = GetPrimarySegment(PrimaryVehicle); -// var primaryMission = primarySegment.Missions.Where( -// m => { -// return m.BusParameter.DoubleDecker == -// CompletedVehicle.VehicleCode.IsDoubleDeckerBus() && -// m.MissionType == mission.MissionType && -// m.BusParameter.FloorType == CompletedVehicle.VehicleCode.GetFloorType(); -// }).First(); -// simulationRunData = CreateVectoRunDataGeneric( -// primaryMission, -// new KeyValuePair<LoadingType, Tuple<Kilogram, double?>>(loading.Key, primaryMission.Loadings[loading.Key]), -// primarySegment, modeIdx); - - -// var primaryResult = InputDataProvider.PrimaryVehicleData.GetResult( -// simulationRunData.Mission.BusParameter.BusGroup, simulationRunData.Mission.MissionType, fuelMode, -// simulationRunData.VehicleData.Loading); -// if (primaryResult == null || !primaryResult.ResultStatus.Equals("success")) { -// throw new VectoException( -// "Failed to find results in PrimaryVehicleReport for vehicle group: {0}, mission: {1}, fuel mode: '{2}', payload: {3}. Make sure PIF and completed vehicle data match!", -// simulationRunData.Mission.BusParameter.BusGroup, simulationRunData.Mission.MissionType, fuelMode, -// simulationRunData.VehicleData.Loading); -// } - -// if (primaryResult.ResultStatus != "success") { -// throw new VectoException( -// "Simulation results in PrimaryVehicleReport for vehicle group: {0}, mission: {1}, fuel mode: '{2}', payload: {3} not finished successfully.", -// simulationRunData.Mission.BusParameter.BusGroup, simulationRunData.Mission.MissionType, fuelMode, -// simulationRunData.VehicleData.Loading); -// } - -// simulationRunData.PrimaryResult = primaryResult; - -// yield return simulationRunData; -// } -// } -// } -// } - -// protected virtual Segment GetPrimarySegment(IVehicleDeclarationInputData primaryVehicle) -// { -// var primarySegment = DeclarationData.PrimaryBusSegments.Lookup( -// primaryVehicle.VehicleCategory, primaryVehicle.AxleConfiguration, primaryVehicle.Articulated); - -// return primarySegment; -// } - - -// protected virtual Segment GetCompletedSegment(IVehicleDeclarationInputData vehicle, AxleConfiguration axleConfiguration) -// { -// if (vehicle.VehicleCategory != VehicleCategory.HeavyBusCompletedVehicle) { -// throw new VectoException( -// "Invalid vehicle category for bus factory! {0}", vehicle.VehicleCategory.GetCategoryName()); -// } - -// var segment = DeclarationData.CompletedBusSegments.Lookup( -// axleConfiguration.NumAxles(), vehicle.VehicleCode, vehicle.RegisteredClass, vehicle.NumberPassengerSeatsLowerDeck, -// vehicle.Height, vehicle.LowEntry); -// if (!segment.Found) { -// throw new VectoException( -// "no segment found for vehicle configruation: vehicle category: {0}, axle configuration: {1}, articulated: {2}, vehicle code: {3}, registered class: {4}, passengersLowerDeck: {5}, height: {6}, lowEntry: {7}. completed", -// vehicle.VehicleCategory, axleConfiguration, -// vehicle.Articulated, vehicle.VehicleCode, vehicle.RegisteredClass.GetLabel(), vehicle.NumberPassengerSeatsLowerDeck, -// vehicle.Height, vehicle.LowEntry); -// } - -// return segment; -// } - - -// protected 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 numSteeredAxles = PrimaryVehicle.Components.AxleWheels.NumSteeredAxles; - -// var simulationRunData = new VectoRunData { -// Loading = loading.Key, -// VehicleData = DataAdapterSpecific.CreateVehicleData(PrimaryVehicle, CompletedVehicle, _segmentCompletedBus, -// mission, loading), -// 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, numSteeredAxles), -// Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), -// Retarder = _retarderData, -// DriverData = _driverData, -// ExecutionMode = ExecutionMode.Declaration, -// JobName = InputDataProvider.JobInputData.JobName, -// ModFileSuffix = "_" + _segmentCompletedBus.VehicleClass.GetClassNumber() + "-Specific_" + loading.Key, -// Report = Report, -// Mission = mission, -// InputDataHash = InputDataProvider.XMLHash, -// SimulationType = SimulationType.DistanceCycle, -// VehicleDesignSpeed = _segmentCompletedBus.DesignSpeed, -// GearshiftParameters = _gearshiftData, -// }; -// simulationRunData.EngineData.FuelMode = 0; -// simulationRunData.VehicleData.VehicleClass = _segmentCompletedBus.VehicleClass; -// simulationRunData.BusAuxiliaries = DataAdapterSpecific.CreateBusAuxiliariesData(mission, PrimaryVehicle, CompletedVehicle, simulationRunData); - -// return simulationRunData; -// } - - -// protected 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)); - -// var primaryBusAuxiliaries = PrimaryVehicle.Components.BusAuxiliaries; - -// var simulationRunData = new VectoRunData { -// Loading = loading.Key, -// VehicleData = DataAdapterGeneric.CreateVehicleData(PrimaryVehicle, primarySegment, mission, loading, false), -// AirdragData = DataAdapterGeneric.CreateAirdragData(null, mission, new Segment()), -// EngineData = DataAdapterGeneric.CreateEngineData(PrimaryVehicle, modeIdx, mission), -// ElectricMachinesData = new List<Tuple<PowertrainPosition, ElectricMotorData>>(), -// GearboxData = _gearboxData, -// AxleGearData = _axlegearData, -// AngledriveData = _angledriveData, -// Aux = DataAdapterGeneric.CreateAuxiliaryData(PrimaryVehicle.Components.AuxiliaryInputData, -// primaryBusAuxiliaries, mission.MissionType, primarySegment.VehicleClass, -// mission.BusParameter.VehicleLength, PrimaryVehicle.Components.AxleWheels.NumSteeredAxles), -// Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), -// Retarder = _retarderData, -// DriverData = _driverData, -// ExecutionMode = ExecutionMode.Declaration, -// JobName = InputDataProvider.JobInputData.JobName, -// ModFileSuffix = "_" + _segmentCompletedBus.VehicleClass.GetClassNumber() + "-Generic_" + loading.Key, -// Report = Report, -// Mission = mission, -// InputDataHash = InputDataProvider.XMLHash, -// SimulationType = SimulationType.DistanceCycle, -// VehicleDesignSpeed = _segmentCompletedBus.DesignSpeed, -// GearshiftParameters = _gearshiftData, -// }; -// simulationRunData.EngineData.FuelMode = 0; -// simulationRunData.VehicleData.VehicleClass = _segmentCompletedBus.VehicleClass; -// simulationRunData.BusAuxiliaries = -// DataAdapterGeneric.CreateBusAuxiliariesData(mission, PrimaryVehicle, simulationRunData); - -// return simulationRunData; -// } - - -// } -//} diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedMultistageBusVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedMultistageBusVectoRunDataFactory.cs deleted file mode 100644 index 013c6c91c7..0000000000 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedMultistageBusVectoRunDataFactory.cs +++ /dev/null @@ -1,328 +0,0 @@ -//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; - -//namespace TUGraz.VectoCore.InputData.Reader.Impl -//{ -// public class DeclarationModeCompletedMultistageBusVectoRunDataFactory : LoggingObject, IVectoRunDataFactory -// { -// protected readonly IMultistepBusInputDataProvider InputDataProvider; -// protected IDeclarationReport Report; - -// protected Segment _segmentCompletedBus; -// protected AxleGearData _axlegearData; -// protected AngledriveData _angledriveData; -// protected GearboxData _gearboxData; -// protected RetarderData _retarderData; -// protected ShiftStrategyParameters _gearshiftData; -// private DriverData _driverData; - -// protected DeclarationDataAdapterMultistageBus DataAdapterSpecific = new DeclarationDataAdapterMultistageBus(); - -// protected DeclarationDataAdapterCompletedBusGeneric DataAdapterGeneric = new DeclarationDataAdapterCompletedBusGeneric(); - -// public DeclarationModeCompletedMultistageBusVectoRunDataFactory( -// IMultistepBusInputDataProvider dataProvider, IDeclarationReport report) -// { - -// InputDataProvider = dataProvider; -// Report = report; -// } - - - -// protected IVehicleDeclarationInputData PrimaryVehicle => InputDataProvider.JobInputData.PrimaryVehicle.Vehicle; - -// protected IVehicleDeclarationInputData CompletedVehicle => InputDataProvider.JobInputData.ConsolidateManufacturingStage.Vehicle; - - -// public IEnumerable<VectoRunData> NextRun() -// { -// Initialize(); -// if (Report != null) -// { -// InitializeReport(); -// } - -// return GetNextRun(); -// } - -// protected virtual void InitializeReport() -// { -// var powertrainConfig = CompletedVehicle.ExemptedVehicle || PrimaryVehicle.ExemptedVehicle -// ? GetExemptedVectoRunData() -// :_segmentCompletedBus.Missions.Select( -// mission => CreateVectoRunDataSpecific( -// mission, mission.Loadings.First(), 0)) -// .FirstOrDefault(x => x != null); - -// Report.InitializeReport(powertrainConfig, new List<List<FuelData.Entry>>()); -// } - -// protected virtual VectoRunData GetExemptedVectoRunData() -// { -// return new VectoRunData() { -// Exempted = true, -// VehicleData = new VehicleData() { -// ModelName = CompletedVehicle.Model, -// Manufacturer = CompletedVehicle.Manufacturer, -// ManufacturerAddress = CompletedVehicle.ManufacturerAddress, -// VIN = CompletedVehicle.VIN, -// LegislativeClass = CompletedVehicle.LegislativeClass, -// RegisteredClass = CompletedVehicle.RegisteredClass, -// VehicleCode = CompletedVehicle.VehicleCode, -// CurbMass = CompletedVehicle.CurbMassChassis, -// GrossVehicleMass = CompletedVehicle.GrossVehicleMassRating, -// ZeroEmissionVehicle = PrimaryVehicle.ZeroEmissionVehicle, -// MaxNetPower1 = PrimaryVehicle.MaxNetPower1, -// InputData = CompletedVehicle -// }, -// Report = Report, -// Mission = new Mission() { -// MissionType = MissionType.ExemptedMission -// }, -// InputData = InputDataProvider -// }; -// } - - -// protected virtual void Initialize() -// { -// if (PrimaryVehicle.ExemptedVehicle || CompletedVehicle.ExemptedVehicle) -// { -// return; -// } - -// _segmentCompletedBus = GetCompletedSegment(CompletedVehicle, PrimaryVehicle.AxleConfiguration); - -// var tmpVehicleData = DataAdapterSpecific.CreateVehicleData(PrimaryVehicle, CompletedVehicle, _segmentCompletedBus, _segmentCompletedBus.Missions.First(), -// _segmentCompletedBus.Missions.First().Loadings.First()); -// tmpVehicleData.VehicleCategory = VehicleCategory.GenericBusVehicle; - -// var combustionEngineData = DataAdapterGeneric.CreateEngineData(PrimaryVehicle, 0, _segmentCompletedBus.Missions.First()); - -// _axlegearData = DataAdapterGeneric.CreateAxleGearData(PrimaryVehicle.Components.AxleGearInputData); - -// _angledriveData = DataAdapterGeneric.CreateAngledriveData(PrimaryVehicle.Components.AngledriveInputData); - -// var tmpRunData = new VectoRunData() -// { -// ShiftStrategy = null,//ToDo missing ShiftStrategy InputDataProvider.JobInputData.ShiftStrategy -// GearboxData = new GearboxData() -// { -// Type = PrimaryVehicle.Components.GearboxInputData.Type, -// } -// }; -// var tmpStrategy = PowertrainBuilder.GetShiftStrategy(new SimplePowertrainContainer(tmpRunData)); - -// _gearboxData = DataAdapterGeneric.CreateGearboxData(PrimaryVehicle, new VectoRunData() { EngineData = combustionEngineData, AxleGearData = _axlegearData, VehicleData = tmpVehicleData }, -// tmpStrategy); - -// _gearshiftData = DataAdapterGeneric.CreateGearshiftData( -// _gearboxData, _axlegearData.AxleGear.Ratio * (_angledriveData?.Angledrive.Ratio ?? 1.0), combustionEngineData.IdleSpeed); - -// _retarderData = DataAdapterGeneric.CreateRetarderData(PrimaryVehicle.Components.RetarderInputData); - -// _driverData = DataAdapterGeneric.CreateDriverData(); -// _driverData.AccelerationCurve = AccelerationCurveReader.ReadFromStream(_segmentCompletedBus.AccelerationFile); -// } - -// protected virtual IEnumerable<VectoRunData> GetNextRun() -// { -// if (InputDataProvider.JobInputData.PrimaryVehicle.Vehicle.ExemptedVehicle) { -// return new[] { GetExemptedVectoRunData() }; -// } -// return VectoRunDataHeavyBusCompleted(); -// } - - -// protected virtual IEnumerable<VectoRunData> VectoRunDataHeavyBusCompleted() -// { -// if (InputDataProvider.JobInputData.PrimaryVehicle.Vehicle.VehicleType == -// VectoSimulationJobType.BatteryElectricVehicle) { -// foreach (var vectoRunData in CreateVectoRunDataForMissions(0, "")) -// yield return vectoRunData; -// } else { -// var engineModes = InputDataProvider.JobInputData.PrimaryVehicle.Vehicle.Components.EngineInputData -// ?.EngineModes; - -// for (var modeIdx = 0; modeIdx < engineModes.Count; modeIdx++) { -// var fuelMode = "single fuel mode"; -// if (engineModes[modeIdx].Fuels.Count > 1) { -// fuelMode = "dual fuel mode"; -// } - -// foreach (var vectoRunData in CreateVectoRunDataForMissions(modeIdx, fuelMode)) -// yield return vectoRunData; -// } -// } -// } - -// private IEnumerable<VectoRunData> CreateVectoRunDataForMissions(int modeIdx, string fuelMode) -// { -// foreach (var mission in _segmentCompletedBus.Missions) { -// foreach (var loading in mission.Loadings) { -// var simulationRunData = CreateVectoRunDataSpecific(mission, loading, modeIdx); -// if (simulationRunData != null) { -// yield return simulationRunData; -// } - -// var primarySegment = GetPrimarySegment(PrimaryVehicle); -// var primaryMission = primarySegment.Missions.Where( -// m => { -// return m.BusParameter.DoubleDecker == -// CompletedVehicle.VehicleCode.IsDoubleDeckerBus() && -// m.MissionType == mission.MissionType && -// m.BusParameter.FloorType == CompletedVehicle.VehicleCode.GetFloorType(); -// }).First(); -// simulationRunData = CreateVectoRunDataGeneric( -// primaryMission, -// new KeyValuePair<LoadingType, Tuple<Kilogram, double?>>(loading.Key, -// primaryMission.Loadings[loading.Key]), -// primarySegment, modeIdx); - -// var primaryResult = InputDataProvider.JobInputData.PrimaryVehicle.GetResult( -// simulationRunData.Mission.BusParameter.BusGroup, simulationRunData.Mission.MissionType, fuelMode, -// simulationRunData.VehicleData.Loading); -// if (primaryResult == null || !primaryResult.ResultStatus.Equals("success")) { -// throw new VectoException( -// "Failed to find results in PrimaryVehicleReport for vehicle group: {0}, mission: {1}, fuel mode: '{2}', payload: {3}. Make sure PIF and completed vehicle data match!", -// simulationRunData.Mission.BusParameter.BusGroup, simulationRunData.Mission.MissionType, fuelMode, -// simulationRunData.VehicleData.Loading); -// } - -// if (primaryResult.ResultStatus != "success") { -// throw new VectoException( -// "Simulation results in PrimaryVehicleReport for vehicle group: {0}, mission: {1}, fuel mode: '{2}', payload: {3} not finished successfully.", -// simulationRunData.Mission.BusParameter.BusGroup, simulationRunData.Mission.MissionType, fuelMode, -// simulationRunData.VehicleData.Loading); -// } - -// simulationRunData.PrimaryResult = primaryResult; - -// yield return simulationRunData; -// } -// } -// } - -// protected virtual Segment GetPrimarySegment(IVehicleDeclarationInputData primaryVehicle) -// { -// var primarySegment = DeclarationData.PrimaryBusSegments.Lookup( -// primaryVehicle.VehicleCategory, primaryVehicle.AxleConfiguration, primaryVehicle.Articulated); - -// return primarySegment; -// } - - -// protected virtual Segment GetCompletedSegment(IVehicleDeclarationInputData vehicle, AxleConfiguration axleConfiguration) -// { -// var segment = DeclarationData.CompletedBusSegments.Lookup( -// axleConfiguration.NumAxles(), vehicle.VehicleCode, vehicle.RegisteredClass, vehicle.NumberPassengerSeatsLowerDeck, -// vehicle.Height, vehicle.LowEntry); -// if (!segment.Found) -// { -// throw new VectoException( -// "no segment found for vehicle configruation: vehicle category: {0}, axle configuration: {1}, articulated: {2}, vehicle code: {3}, registered class: {4}, passengersLowerDeck: {5}, height: {6}, lowEntry: {7}. completed", -// vehicle.VehicleCategory, axleConfiguration, -// vehicle.Articulated, vehicle.VehicleCode, vehicle.RegisteredClass.GetLabel(), vehicle.NumberPassengerSeatsLowerDeck, -// vehicle.Height, vehicle.LowEntry); -// } - -// return segment; -// } - - -// protected virtual 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), -// 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, -// }; -// simulationRunData.EngineData.FuelMode = 0; -// simulationRunData.VehicleData.VehicleClass = _segmentCompletedBus.VehicleClass; -// simulationRunData.BusAuxiliaries = DataAdapterSpecific.CreateBusAuxiliariesData(mission, PrimaryVehicle, CompletedVehicle, simulationRunData); - -// return simulationRunData; -// } - - -// protected virtual 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)); - -// var primaryBusAuxiliaries = PrimaryVehicle.Components.BusAuxiliaries; - -// var simulationRunData = new VectoRunData { -// Loading = loading.Key, -// VehicleData = DataAdapterGeneric.CreateVehicleData(PrimaryVehicle, primarySegment, mission, loading, false), -// AirdragData = DataAdapterGeneric.CreateAirdragData(null, mission, new Segment()), -// EngineData = DataAdapterGeneric.CreateEngineData(PrimaryVehicle, modeIdx, mission), -// ElectricMachinesData = new List<Tuple<PowertrainPosition, ElectricMotorData>>(), -// GearboxData = _gearboxData, -// AxleGearData = _axlegearData, -// AngledriveData = _angledriveData, -// Aux = DataAdapterGeneric.CreateAuxiliaryData(PrimaryVehicle.Components.AuxiliaryInputData, -// primaryBusAuxiliaries, mission.MissionType, primarySegment.VehicleClass, -// mission.BusParameter.VehicleLength, -// 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, -// ModFileSuffix = $"_{_segmentCompletedBus.VehicleClass.GetClassNumber()}-Generic_{loading.Key}", -// Report = Report, -// Mission = mission, -// InputDataHash = InputDataProvider.XMLHash, -// SimulationType = SimulationType.DistanceCycle, -// VehicleDesignSpeed = _segmentCompletedBus.DesignSpeed, -// GearshiftParameters = _gearshiftData, -// }; -// simulationRunData.EngineData.FuelMode = 0; -// simulationRunData.VehicleData.VehicleClass = _segmentCompletedBus.VehicleClass; -// simulationRunData.BusAuxiliaries = -// DataAdapterGeneric.CreateBusAuxiliariesData(mission, PrimaryVehicle, simulationRunData); - -// return simulationRunData; -// } - - -// } -//} diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs deleted file mode 100644 index 97a98862e8..0000000000 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs +++ /dev/null @@ -1,232 +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 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; -//using DeclarationDataAdapterHeavyLorry = TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.HeavyLorry.DeclarationDataAdapterHeavyLorry; - - -//namespace TUGraz.VectoCore.InputData.Reader.Impl -//{ - -// public class DeclarationModeTruckVectoRunDataFactory : AbstractDeclarationVectoRunDataFactory -// { -// DeclarationDataAdapterHeavyLorry _dao = new DeclarationDataAdapterHeavyLorry(); - -// internal DeclarationModeTruckVectoRunDataFactory( -// IDeclarationInputDataProvider dataProvider, IDeclarationReport report, bool checkJobType = true) : base(dataProvider, report, checkJobType) -// { } - -// #region Overrides of AbstractDeclarationVectoRunDataFactory - -// protected override IDeclarationDataAdapter DataAdapter => _dao; - -// #endregion - -// protected override Segment GetSegment(IVehicleDeclarationInputData vehicle) -// { -// if (!vehicle.VehicleCategory.IsLorry()) { -// throw new VectoException("Invalid vehicle category for truck factory! {0}", vehicle.VehicleCategory.GetCategoryName()); -// } - -// 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; -// } - - -// protected override IEnumerable<VectoRunData> GetNextRun() -// { -// //if (InitException != null) { -// // throw InitException; -// //} - - - - - - -// if (InputDataProvider.JobInputData.Vehicle.ExemptedVehicle) { -// yield return CreateVectoRunData(InputDataProvider.JobInputData.Vehicle, 0, null, new KeyValuePair<LoadingType, Tuple<Kilogram, double?>>()); -// } else { -// foreach (var vectoRunData in VectoRunDataTruckNonExempted()) { -// yield return vectoRunData; -// } -// } -// } - - - -// private IEnumerable<VectoRunData> VectoRunDataTruckNonExempted() -// { -// switch (InputDataProvider.JobInputData.JobType) { -// case VectoSimulationJobType.ConventionalVehicle: -// case VectoSimulationJobType.ParallelHybridVehicle: -// case VectoSimulationJobType.SerialHybridVehicle: -// return VectoRunDataConventionalTruckNonExempted(); -// case VectoSimulationJobType.BatteryElectricVehicle: -// return VectoRunDataBatteryElectricVehicle(); -// case VectoSimulationJobType.EngineOnlySimulation: -// break; -// default: -// throw new ArgumentOutOfRangeException(); -// } -// return VectoRunDataConventionalTruckNonExempted(); - -// } - -// private IEnumerable<VectoRunData> VectoRunDataBatteryElectricVehicle() -// { -// var vehicle = InputDataProvider.JobInputData.Vehicle; -// foreach (var mission in _segment.Missions) { -// foreach (var loading in mission.Loadings) -// { -// var simulationRunData = CreateVectoRunData(vehicle, 0, mission, loading); -// yield return simulationRunData; -// } - -// } -// } - -// private IEnumerable<VectoRunData> VectoRunDataConventionalTruckNonExempted() -// { -// 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); -// yield return simulationRunData; -// } -// } -// } -// } - - -// protected override VectoRunData CreateVectoRunData( -// IVehicleDeclarationInputData vehicle, int modeIdx, Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading) -// { -// if (InputDataProvider.JobInputData.Vehicle.ExemptedVehicle) { -// var runData = new VectoRunData { -// InputData = InputDataProvider, -// Exempted = true, -// Report = Report, -// Mission = new Mission() { MissionType = MissionType.ExemptedMission }, -// VehicleData = DataAdapter.CreateVehicleData(InputDataProvider.JobInputData.Vehicle, new Segment(), null, new KeyValuePair<LoadingType, Tuple<Kilogram, double?>>(LoadingType.ReferenceLoad, Tuple.Create<Kilogram, double?>(0.SI<Kilogram>(), null)), _allowVocational), -// InputDataHash = InputDataProvider.XMLHash -// }; -// runData.VehicleData.InputData = vehicle; -// return runData; -// } - -// 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; -// } - - -// } -//} diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModePrimaryBusVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModePrimaryBusVectoRunDataFactory.cs deleted file mode 100644 index 1e5f1ec35a..0000000000 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModePrimaryBusVectoRunDataFactory.cs +++ /dev/null @@ -1,178 +0,0 @@ -//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.InputData.Reader.DataObjectAdapter.PrimaryBus; -//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 -//{ -// public class DeclarationModePrimaryBusVectoRunDataFactory : AbstractDeclarationVectoRunDataFactory -// { -// protected DeclarationDataAdapterPrimaryBus _dao = new DeclarationDataAdapterPrimaryBus(); - -// public DeclarationModePrimaryBusVectoRunDataFactory(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, bool checkJobType = true) : -// base(dataProvider, report, checkJobType) -// { } - -// #region Overrides of AbstractDeclarationVectoRunDataFactory - -// protected override IDeclarationDataAdapter DataAdapter => _dao; - -// #endregion - -// protected override IEnumerable<VectoRunData> GetNextRun() -// { -// if (InputDataProvider.JobInputData.Vehicle.VehicleCategory == VehicleCategory.HeavyBusPrimaryVehicle) { -// if (InputDataProvider.JobInputData.Vehicle.ExemptedVehicle) { -// yield return CreateVectoRunData(InputDataProvider.JobInputData.Vehicle, 0, null, -// new KeyValuePair<LoadingType, Tuple<Kilogram, double?>>()); -// } else { -// foreach (var vectoRunData in VectoRunDataHeavyBusPrimary()) { -// yield return vectoRunData; -// } -// } -// } - -// foreach (var entry in new List<VectoRunData>()) { -// yield return entry; -// } -// } - -// protected override Segment GetSegment(IVehicleDeclarationInputData vehicle) -// { -// if (vehicle.VehicleCategory != VehicleCategory.HeavyBusPrimaryVehicle) { -// throw new VectoException( -// "Invalid vehicle category for bus factory! {0}", vehicle.VehicleCategory.GetCategoryName()); -// } - -// var segment = DeclarationData.PrimaryBusSegments.Lookup( -// vehicle.VehicleCategory, vehicle.AxleConfiguration, vehicle.Articulated); -// if (!segment.Found) { -// throw new VectoException( -// "no segment found for vehicle configruation: vehicle category: {0}, axle configuration: {1}, articulated: {2}, primary", -// vehicle.VehicleCategory, vehicle.AxleConfiguration, -// vehicle.Articulated); -// } - -// return segment; -// } - -// private IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary() -// { -// switch (InputDataProvider.JobInputData.JobType) { -// case VectoSimulationJobType.ConventionalVehicle: -// case VectoSimulationJobType.ParallelHybridVehicle: -// case VectoSimulationJobType.SerialHybridVehicle: -// return VectoRunDataConventionalHeavyBusPrimaryNonExempted(); -// case VectoSimulationJobType.BatteryElectricVehicle: -// return VectoRunDataBatteryElectricHeavyBusPrimaryNonExempted(); -// case VectoSimulationJobType.EngineOnlySimulation: -// break; -// default: -// throw new ArgumentOutOfRangeException(); -// } -// return VectoRunDataConventionalHeavyBusPrimaryNonExempted(); -// } - -// private IEnumerable<VectoRunData> VectoRunDataBatteryElectricHeavyBusPrimaryNonExempted() -// { -// var vehicle = InputDataProvider.JobInputData.Vehicle; -// foreach (var mission in _segment.Missions) { -// foreach (var loading in mission.Loadings) { -// var simulationRunData = CreateVectoRunData(vehicle, 0, mission, loading); -// if (simulationRunData == null) { -// continue; -// } -// yield return simulationRunData; -// } - -// } -// } - -// private IEnumerable<VectoRunData> VectoRunDataConventionalHeavyBusPrimaryNonExempted() -// { -// var vehicle = InputDataProvider.JobInputData.Vehicle; -// var engine = vehicle.Components.EngineInputData; -// var engineModes = engine.EngineModes; - -// for (var modeIdx = 0; modeIdx < engineModes.Count; modeIdx++) { -// foreach (var mission in _segment.Missions) { -// foreach (var loading in mission.Loadings) { -// var simulationRunData = CreateVectoRunData(vehicle, modeIdx, mission, loading); -// if (simulationRunData == null) { -// continue; -// } -// yield return simulationRunData; -// } -// } -// } -// } - - -// protected override VectoRunData CreateVectoRunData( -// IVehicleDeclarationInputData vehicle, int modeIdx, Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading) -// { -// if (InputDataProvider.JobInputData.Vehicle.ExemptedVehicle) { -// return new VectoRunData { -// Exempted = true, -// Report = Report, -// Mission = new Mission { MissionType = MissionType.ExemptedMission }, -// VehicleData = DataAdapter.CreateVehicleData(InputDataProvider.JobInputData.Vehicle, new Segment(), -// null, -// new KeyValuePair<LoadingType, Tuple<Kilogram, double?>>(LoadingType.ReferenceLoad, -// Tuple.Create<Kilogram, double?>(0.SI<Kilogram>(), null)), _allowVocational), -// InputDataHash = InputDataProvider.XMLHash -// }; -// } - -// var engine = 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 = _dao.CreateAirdragData(null, mission, new Segment()), -// EngineData = DataAdapter.CreateEngineData(InputDataProvider.JobInputData.Vehicle, engineMode, mission), -// 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 ?? mission.BusParameter.VehicleLength, -// 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}_" : "")}" + -// $"_{mission.BusParameter.BusGroup.GetClassNumber()}_{loading.Key}", -// Report = Report, -// Mission = mission, -// InputDataHash = InputDataProvider.XMLHash, -// SimulationType = SimulationType.DistanceCycle, -// GearshiftParameters = _gearshiftData, -// }; -// simulationRunData.EngineData.FuelMode = modeIdx; -// simulationRunData.VehicleData.VehicleClass = _segment.VehicleClass; -// simulationRunData.BusAuxiliaries = _dao.CreateBusAuxiliariesData( -// mission, InputDataProvider.JobInputData.Vehicle, simulationRunData); -// return simulationRunData; -// } -// } -//} diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeSingleBusVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeSingleBusVectoRunDataFactory.cs deleted file mode 100644 index 55d06dd334..0000000000 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeSingleBusVectoRunDataFactory.cs +++ /dev/null @@ -1,129 +0,0 @@ -//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.InputData.Reader.Impl; -//using TUGraz.VectoCore.Models.Declaration; -//using TUGraz.VectoCore.Models.Simulation.Data; -//using TUGraz.VectoCore.Models.SimulationComponent.Data; -//using TUGraz.VectoCore.OutputData; - -//namespace TUGraz.VectoCore.Models.Simulation.Impl -//{ -// internal class DeclarationModeSingleBusVectoRunDataFactory : DeclarationModePrimaryBusVectoRunDataFactory -// { -// protected new DeclarationDataAdapterSingleBus _dao = new DeclarationDataAdapterSingleBus(); -// private ISingleBusInputDataProvider _singleBusInputData; - -// public DeclarationModeSingleBusVectoRunDataFactory(ISingleBusInputDataProvider singleBusInputData, IDeclarationReport report) : base(singleBusInputData, report) -// { -// _singleBusInputData = singleBusInputData; -// _dao.SingleBusInputData = singleBusInputData; -// } - - -// protected override Segment GetSegment(IVehicleDeclarationInputData vehicle) -// { -// //if (vehicle.VehicleCategory != VehicleCategory.HeavyBusCompletedVehicle) { -// // throw new VectoException( -// // "Invalid vehicle category for bus factory! {0}", vehicle.VehicleCategory.GetCategoryName()); -// //} - -// var completedVehicle = _singleBusInputData.CompletedVehicle; - -// var segment = DeclarationData.CompletedBusSegments.Lookup( -// _singleBusInputData.PrimaryVehicle.AxleConfiguration.NumAxles(), completedVehicle.VehicleCode, completedVehicle.RegisteredClass, completedVehicle.NumberPassengerSeatsLowerDeck, -// completedVehicle.Height, completedVehicle.LowEntry); -// if (!segment.Found) { -// throw new VectoException( -// "no segment found for vehicle configruation: vehicle category: {0}, axle configuration: {1}, articulated: {2}, vehicle code: {3}, registered class: {4}, passengersLowerDeck: {5}, height: {6}, lowfloor: {7}. completed", -// vehicle.VehicleCategory, _singleBusInputData.PrimaryVehicle.AxleConfiguration, -// vehicle.Articulated, completedVehicle.VehicleCode, completedVehicle.RegisteredClass.GetLabel(), completedVehicle.NumberPassengerSeatsLowerDeck, -// completedVehicle.Height, completedVehicle.LowEntry); -// } -// foreach (var mission in segment.Missions) { -// mission.VehicleHeight = completedVehicle.Height + mission.BusParameter.DeltaHeight; -// mission.BusParameter.VehicleLength = completedVehicle.Length; -// } - -// return segment; -// } - - -// protected override IDeclarationDataAdapter DataAdapter => _dao; - - -// protected override VectoRunData CreateVectoRunData(IVehicleDeclarationInputData vehicle, int modeIdx, Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading) -// { -// var doubleDecker = _singleBusInputData.CompletedVehicle.NumberPassengerSeatsUpperDeck > 0; -// if (mission.BusParameter.DoubleDecker != doubleDecker) { -// return null; -// } - -// var engine = 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), -// AirdragData = _dao.CreateAirdragData(_singleBusInputData.CompletedVehicle, mission), -// EngineData = DataAdapter.CreateEngineData(InputDataProvider.JobInputData.Vehicle, engineMode, mission), -// 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 ?? mission.BusParameter.VehicleLength, -// 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}_" : "")}" + -// $"_{mission.BusParameter.BusGroup.GetClassNumber()}-Single_{loading.Key}", -// Report = Report, -// Mission = mission, -// InputDataHash = InputDataProvider.XMLHash, -// SimulationType = SimulationType.DistanceCycle, -// GearshiftParameters = _gearshiftData, -// VehicleDesignSpeed = _segment.DesignSpeed, -// //ShiftStrategy = InputDataProvider.JobInputData.ShiftStrategy -// }; -// simulationRunData.EngineData.FuelMode = modeIdx; -// simulationRunData.VehicleData.VehicleClass = _segment.VehicleClass; -// simulationRunData.BusAuxiliaries = _dao.CreateBusAuxiliariesData(mission, _singleBusInputData.PrimaryVehicle, _singleBusInputData.CompletedVehicle, simulationRunData); -// return simulationRunData; -// } - -// protected override 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, _singleBusInputData.CompletedVehicle.TankSystem)).ToList()) -// .ToList(); -// } -// Report.InitializeReport(powertrainConfig, fuels); -// } -// } - - -//} diff --git a/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryFactory.cs b/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryFactory.cs index d905c718d3..927e8c2e59 100644 --- a/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryFactory.cs @@ -16,7 +16,10 @@ namespace TUGraz.VectoCore.InputData.Reader { public interface IInternalRunDataFactoryFactory { - IVectoRunDataFactory CreateSingleBusRunDataFactory(); + IVectoRunDataFactory CreateSingleBusRunDataFactory(VehicleTypeAndArchitectureStringHelperRundata.VehicleClassification vehicleClassification, + ISingleBusInputDataProvider dataProvider, + IDeclarationReport report); + IVectoRunDataFactory CreateDeclarationRunDataFactory(VehicleTypeAndArchitectureStringHelperRundata.VehicleClassification vehicleClassification, IDeclarationInputDataProvider dataProvider, IDeclarationReport report); @@ -105,12 +108,12 @@ namespace TUGraz.VectoCore.InputData.Reader if (vtpProvider.JobInputData.Vehicle.VehicleCategory.IsLorry()) { - //return new DeclarationVTPModeVectoRunDataFactoryLorries(vtpProvider, vtpReport); + return new DeclarationVTPModeVectoRunDataFactoryLorries(vtpProvider, vtpReport); } if (vtpProvider.JobInputData.Vehicle.VehicleCategory.IsBus()) { - //return new DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary(vtpProvider, vtpReport); + return new DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary(vtpProvider, vtpReport); } @@ -120,8 +123,8 @@ namespace TUGraz.VectoCore.InputData.Reader private IVectoRunDataFactory CreateRunDataReader(ISingleBusInputDataProvider singleBusProvider, IDeclarationReport report) { - throw new NotImplementedException(); - //return new DeclarationModeSingleBusVectoRunDataFactory(singleBusProvider, report); + + return _internalFactory.CreateSingleBusRunDataFactory(new VehicleTypeAndArchitectureStringHelperRundata.VehicleClassification(singleBusProvider), singleBusProvider, report); } diff --git a/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryNinjectModule.cs b/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryNinjectModule.cs index c40b0149f0..4a90646899 100644 --- a/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryNinjectModule.cs +++ b/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryNinjectModule.cs @@ -11,6 +11,8 @@ using TUGraz.VectoCore.InputData.Reader.Impl; using TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.CompletedBusRunDataFactory; using TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDataFactory; using TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.PrimaryBusRunDataFactory; +using TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.SingleBus; +using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.Utils.Ninject; @@ -39,7 +41,10 @@ namespace TUGraz.VectoCore.InputData.Reader .CreateDeclarationRunDataFactory)), typeof(IInternalRunDataFactoryFactory) .GetMethod(nameof(IInternalRunDataFactoryFactory - .CreateDeclarationCompletedBusRunDataFactory)) + .CreateDeclarationCompletedBusRunDataFactory)), + typeof(IInternalRunDataFactoryFactory) + .GetMethod(nameof(IInternalRunDataFactoryFactory + .CreateSingleBusRunDataFactory)) }, skipArguments = 1, takeArguments = 1, @@ -210,11 +215,55 @@ namespace TUGraz.VectoCore.InputData.Reader Bind<IVectoRunDataFactory>().To<DeclarationModeCompletedBusRunDataFactory.PEV_E_IEPC>().Named( _vehicleStringHelper.GetName(VehicleCategoryHelper.CompletedBus, VectoSimulationJobType.BatteryElectricVehicle, ArchitectureID.E_IEPC)); - #endregion + #region SingleBus + Bind<IVectoRunDataFactory>().To<DeclarationModeSingleBusRunDataFactory.Conventional>().Named( + _vehicleStringHelper.GetSingleBusName(VectoSimulationJobType.ConventionalVehicle, + ArchitectureID.UNKNOWN)); + Bind<IVectoRunDataFactory>().To<DeclarationModeSingleBusRunDataFactory.HEV_S2>().Named( + _vehicleStringHelper.GetSingleBusName(VectoSimulationJobType.SerialHybridVehicle, + ArchitectureID.S2)); + Bind<IVectoRunDataFactory>().To<DeclarationModeSingleBusRunDataFactory.HEV_S3>().Named( + _vehicleStringHelper.GetSingleBusName(VectoSimulationJobType.SerialHybridVehicle, + ArchitectureID.S3)); + Bind<IVectoRunDataFactory>().To<DeclarationModeSingleBusRunDataFactory.HEV_S4>().Named( + _vehicleStringHelper.GetSingleBusName(VectoSimulationJobType.SerialHybridVehicle, + ArchitectureID.S4)); + Bind<IVectoRunDataFactory>().To<DeclarationModeSingleBusRunDataFactory.HEV_S_IEPC>().Named( + _vehicleStringHelper.GetSingleBusName(VectoSimulationJobType.SerialHybridVehicle, + ArchitectureID.S_IEPC)); + Bind<IVectoRunDataFactory>().To<DeclarationModeSingleBusRunDataFactory.HEV_P1>().Named( + _vehicleStringHelper.GetSingleBusName(VectoSimulationJobType.ParallelHybridVehicle, + ArchitectureID.P1)); + Bind<IVectoRunDataFactory>().To<DeclarationModeSingleBusRunDataFactory.HEV_P2>().Named( + _vehicleStringHelper.GetSingleBusName(VectoSimulationJobType.ParallelHybridVehicle, + ArchitectureID.P2)); + Bind<IVectoRunDataFactory>().To<DeclarationModeSingleBusRunDataFactory.HEV_P2_5>().Named( + _vehicleStringHelper.GetSingleBusName(VectoSimulationJobType.ParallelHybridVehicle, + ArchitectureID.P2_5)); + + Bind<IVectoRunDataFactory>().To<DeclarationModeSingleBusRunDataFactory.HEV_P3>().Named( + _vehicleStringHelper.GetSingleBusName(VectoSimulationJobType.ParallelHybridVehicle, + ArchitectureID.P3)); + Bind<IVectoRunDataFactory>().To<DeclarationModeSingleBusRunDataFactory.HEV_P4>().Named( + _vehicleStringHelper.GetSingleBusName(VectoSimulationJobType.ParallelHybridVehicle, + ArchitectureID.P4)); + Bind<IVectoRunDataFactory>().To<DeclarationModeSingleBusRunDataFactory.PEV_E2>().Named( + _vehicleStringHelper.GetSingleBusName(VectoSimulationJobType.BatteryElectricVehicle, + ArchitectureID.E2)); + Bind<IVectoRunDataFactory>().To<DeclarationModeSingleBusRunDataFactory.PEV_E3>().Named( + _vehicleStringHelper.GetSingleBusName(VectoSimulationJobType.BatteryElectricVehicle, + ArchitectureID.E3)); + Bind<IVectoRunDataFactory>().To<DeclarationModeSingleBusRunDataFactory.PEV_E4>().Named( + _vehicleStringHelper.GetSingleBusName(VectoSimulationJobType.BatteryElectricVehicle, + ArchitectureID.E4)); + Bind<IVectoRunDataFactory>().To<DeclarationModeSingleBusRunDataFactory.PEV_E_IEPC>().Named( + _vehicleStringHelper.GetSingleBusName(VectoSimulationJobType.BatteryElectricVehicle, + ArchitectureID.E_IEPC)); + #endregion } - #endregion + #endregion diff --git a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportFactory.cs b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportFactory.cs index 64cefe5516..45960ce7d6 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportFactory.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReportFactory.cs @@ -36,7 +36,7 @@ namespace TUGraz.VectoCore.OutputData.XML case IMultistepBusInputDataProvider multistageBusInputDataProvider: break; case ISingleBusInputDataProvider singleBusInputDataProvider: - return new XMLDeclarationReport(outputWriter); + return new XMLDeclarationReport09(outputWriter, _mrfFactory, _cifFactory); case IDeclarationInputDataProvider declarationInputDataProvider: return CreateDeclarationReport(declarationInputDataProvider, outputWriter); case IMultiStageTypeInputData multiStageTypeInputData: @@ -94,12 +94,12 @@ namespace TUGraz.VectoCore.OutputData.XML switch (declarationInputDataProvider.JobInputData.Vehicle.VehicleCategory) { case VehicleCategory.HeavyBusCompletedVehicle: - return new XMLDeclarationReportCompletedVehicle(outputDataWriter) + return new XMLDeclarationReportCompletedVehicle_09(outputDataWriter, _mrfFactory, _cifFactory, _vifFactory) { PrimaryVehicleReportInputData = declarationInputDataProvider.PrimaryVehicleData, }; case VehicleCategory.HeavyBusPrimaryVehicle: - return new XMLDeclarationReportPrimaryVehicle(outputDataWriter); + return new XMLDeclarationReportPrimaryVehicle_09(outputDataWriter, _mrfFactory, _cifFactory, _vifFactory); default: break; diff --git a/VectoCore/VectoCore/Utils/Ninject/VehicleTypeAndArchitectureStringHelper.cs b/VectoCore/VectoCore/Utils/Ninject/VehicleTypeAndArchitectureStringHelper.cs index 9b6e8adb78..ba319a1f6f 100644 --- a/VectoCore/VectoCore/Utils/Ninject/VehicleTypeAndArchitectureStringHelper.cs +++ b/VectoCore/VectoCore/Utils/Ninject/VehicleTypeAndArchitectureStringHelper.cs @@ -119,8 +119,12 @@ namespace TUGraz.VectoCore.Utils.Ninject return GetName(vehicleType, VectoSimulationJobType.ConventionalVehicle, exempted: exempted); } - #endregion + public string GetSingleBusName(VectoSimulationJobType jobType, ArchitectureID archId, bool exempted = false) + { + return GetName(new VehicleClassification(jobType, archId, null, exempted, false, false, true)); + } + #endregion public struct VehicleClassification { private readonly VectoSimulationJobType _jobType; @@ -171,14 +175,19 @@ namespace TUGraz.VectoCore.Utils.Ninject private bool Ihpc => _ihpc; - public VehicleClassification(VectoSimulationJobType jobType, ArchitectureID archId, string vehicleType, bool exempted, bool iepc, bool ihpc) + private readonly bool _isSingleBus; + private const string _singlebus = "SingleBus"; + private bool IsSingleBus => _isSingleBus; + + public VehicleClassification(VectoSimulationJobType jobType, ArchitectureID archId, string vehicleType, bool exempted, bool iepc, bool ihpc, bool singleBus = false) { _iepc = iepc; _ihpc = ihpc; _exempted = exempted; - _vehicleType = vehicleType; + _vehicleType = singleBus ? _singlebus : vehicleType; _archId = archId; _jobType = jobType; + _isSingleBus = singleBus; } public VehicleClassification(IVehicleDeclarationInputData inputData) : this() @@ -191,7 +200,7 @@ namespace TUGraz.VectoCore.Utils.Ninject _vehicleType = inputData.VehicleCategory.GetVehicleType(); _archId = inputData.ArchitectureID; _jobType = inputData.VehicleType; - + _isSingleBus = false; } @@ -205,10 +214,18 @@ namespace TUGraz.VectoCore.Utils.Ninject _vehicleType = inputData.MultistageJobInputData.JobInputData.ConsolidateManufacturingStage.Vehicle.VehicleCategory.GetVehicleType(); _archId = inputData.MultistageJobInputData.JobInputData.PrimaryVehicle.Vehicle.ArchitectureID; _jobType = inputData.MultistageJobInputData.JobInputData.PrimaryVehicle.Vehicle.VehicleType; - + _isSingleBus = false; //inputData.MultistageJobInputData.JobInputData.ConsolidateManufacturingStage. } + public VehicleClassification(ISingleBusInputDataProvider singleBus) : this() + { + _isSingleBus = true; + _vehicleType = _singlebus; + _archId = singleBus.PrimaryVehicle.ArchitectureID; + _jobType = singleBus.PrimaryVehicle.VehicleType; + } + public bool Equals(VehicleClassification other) { return JobType == other.JobType && ArchId == other.ArchId && VehicleType == other.VehicleType && Exempted == other.Exempted && Iepc == other.Iepc && Ihpc == other.Ihpc; -- GitLab