diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/BusAuxiliaryInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/BusAuxiliaryInputData.cs index 893f857e8a3ac4b1201d60d134a2b9a05a24e525..19fb8d9ff301357531b93914044bb152af64abab 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/BusAuxiliaryInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/BusAuxiliaryInputData.cs @@ -9,6 +9,7 @@ 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.InputData.Reader.DataObjectAdapter.SimulationComponents; using TUGraz.VectoCore.Models.BusAuxiliaries; using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics; using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC; @@ -80,12 +81,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON var averageCurrentDemandWithoutBaseLoad = elData["ElectricalConsumers"] .GetEx<double>("AverageCurrentDemandWithoutBaseLoad").SI<Ampere>(); - electricalUserInputsConfig.ElectricalConsumers = new Dictionary<string, ElectricConsumerEntry>(); - electricalUserInputsConfig.ElectricalConsumers["BaseLoad"] = new ElectricConsumerEntry() { + electricalUserInputsConfig.ElectricalConsumers = new Dictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry>(); + electricalUserInputsConfig.ElectricalConsumers["BaseLoad"] = new AuxiliaryDataAdapter.ElectricConsumerEntry() { BaseVehicle = true, Current = averageCurrentDemandInclBaseLoad - averageCurrentDemandWithoutBaseLoad }; - electricalUserInputsConfig.ElectricalConsumers["Consumers"] = new ElectricConsumerEntry() { + electricalUserInputsConfig.ElectricalConsumers["Consumers"] = new AuxiliaryDataAdapter.ElectricConsumerEntry() { BaseVehicle = false, Current = averageCurrentDemandWithoutBaseLoad }; diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/CompletedBus/Generic/DeclarationDataAdapterGenericCompletedBus.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/CompletedBus/Generic/DeclarationDataAdapterGenericCompletedBus.cs index fd8b7eb01286a98d3d7c7cc0f50734dd1c5c0a45..f338574db02eecadd5e13b1b28474edb361cf179 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/CompletedBus/Generic/DeclarationDataAdapterGenericCompletedBus.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/CompletedBus/Generic/DeclarationDataAdapterGenericCompletedBus.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using TUGraz.VectoCommon.BusAuxiliaries; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -11,93 +12,115 @@ using TUGraz.VectoCore.Models.SimulationComponent.Data; namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.CompletedBus.Generic { - public abstract class DeclarationDataAdapterGenericCompletedBus + public abstract class DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration { - public abstract class CompletedBusBase : IGenericCompletedBusDataAdapter + public abstract class CompletedBusDeclarationBase : IGenericCompletedBusDeclarationDataAdapter { - private readonly IRetarderDataAdapter _retarderDataAdapter = new GenericRetarderDataAdapter(); - #region Implementation of IDeclarationDataAdapter + private static readonly GearboxType[] SupportedGearboxTypes = + { GearboxType.MT, GearboxType.AMT, GearboxType.ATPowerSplit, GearboxType.ATSerial }; + #region ComponentDataAdapter + protected readonly IVehicleDataAdapter _vehicleDataAdapter = new CompletedBusGenericVehicleDataAdapter(); + private readonly IRetarderDataAdapter _retarderDataAdapter = new GenericRetarderDataAdapter(); + private readonly IEngineDataAdapter _engineDataAdapter = new GenericCombustionEngineComponentDataAdapter(); + private readonly IAirdragDataAdapter _airdragDataAdapter = new AirdragDataAdapter(); private readonly IDriverDataAdapter _driverDataAdapter = new CompletedBusGenericDriverDataAdapter(); - public DriverData CreateDriverData() - { - return _driverDataAdapter.CreateDriverData(); - } - - public VehicleData CreateVehicleData(IVehicleDeclarationInputData vehicle, Segment segment, Mission mission, - KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) - { - throw new NotImplementedException(); - } - - public AirdragData CreateAirdragData(IAirdragDeclarationInputData airdragData, Mission mission, Segment segment) - { - throw new NotImplementedException(); - } - - public AxleGearData CreateAxleGearData(IAxleGearInputData axlegearData) - { - throw new NotImplementedException(); - } - - public AngledriveData CreateAngledriveData(IAngledriveInputData angledriveData) - { - throw new NotImplementedException(); - } - - public CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, IEngineModeDeclarationInputData engineMode, - Mission mission) - { - throw new NotImplementedException(); - } - - public GearboxData CreateGearboxData(IVehicleDeclarationInputData inputData, VectoRunData runData, - IShiftPolygonCalculator shiftPolygonCalc) - { - throw new NotImplementedException(); - } - - public ShiftStrategyParameters CreateGearshiftData(GearboxData gbx, double axleRatio, PerSecond engineIdlingSpeed) - { - throw new NotImplementedException(); - } - - public RetarderData CreateRetarderData(IRetarderInputData retarderData) + private readonly IAxleGearDataAdapter _axleGearDataAdapter = new GenericCompletedBusAxleGearDataAdapter(); + private readonly IAngledriveDataAdapter _angledriveDataAdapter = new GenericAngledriveDataAdapter(); + private readonly IGearboxDataAdapter _gearboxDataAdapter = new GearboxDataAdapter(new GenericCompletedBusTorqueConverterDataAdapter()); + private readonly IPrimaryBusAuxiliaryDataAdapter _auxDataAdapter = new PrimaryBusAuxiliaryDataAdapter(); + #endregion + + #region Implementation of IGenericCompletedBusDeclarationDataAdapter + public virtual 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); + } + + public AirdragData CreateAirdragData(IAirdragDeclarationInputData airdragData, Mission mission, Segment segment) + { + return _airdragDataAdapter.CreateAirdragData(airdragData, mission, segment); + } + + public CombustionEngineData CreateEngineData(IVehicleDeclarationInputData primaryVehicle, int modeIdx, Mission mission) + { + return _engineDataAdapter.CreateEngineData(primaryVehicle, modeIdx, mission); + } + + public IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxData, IBusAuxiliariesDeclarationData busAuxData, + MissionType missionType, VehicleClass vehicleClass, Meter vehicleLength, int? numSteeredAxles) + { + return _auxDataAdapter.CreateAuxiliaryData(auxData, busAuxData, missionType, vehicleClass, vehicleLength, + numSteeredAxles); + } + + public AxleGearData CreateAxleGearData(IAxleGearInputData axlegearData) + { + return _axleGearDataAdapter.CreateAxleGearData(axlegearData); + } + + 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:SupportedGearboxTypes); + } + + public ShiftStrategyParameters CreateGearshiftData(GearboxData gbx, double axleRatio, PerSecond engineIdlingSpeed) + { + return _gearboxDataAdapter.CreateGearshiftData(gbx, axleRatio, engineIdlingSpeed); + } + + public RetarderData CreateRetarderData(IRetarderInputData retarderData) { return _retarderDataAdapter.CreateRetarderData(retarderData); } - public PTOData CreatePTOTransmissionData(IPTOTransmissionInputData ptoData) - { - throw new NotImplementedException(); - } + public DriverData CreateDriverData() + { + return _driverDataAdapter.CreateDriverData(); + } + + public IAuxiliaryConfig CreateBusAuxiliariesData(Mission mission, IVehicleDeclarationInputData vehicleData, + VectoRunData runData) + { + return _auxDataAdapter.CreateBusAuxiliariesData(mission, vehicleData, runData); + } + #endregion + } - public IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxData, IBusAuxiliariesDeclarationData busAuxData, - MissionType missionType, VehicleClass vehicleClass, Meter vehicleLength, int? numSteeredAxles) - { - throw new NotImplementedException(); - } + public class Conventional : CompletedBusDeclarationBase { } + public class HEV_S2 : CompletedBusDeclarationBase { } + public class HEV_S3 : CompletedBusDeclarationBase { } + public class HEV_S4 : CompletedBusDeclarationBase { } + public class HEV_S_IEPC : CompletedBusDeclarationBase { } + public class HEV_P1 : CompletedBusDeclarationBase { } + public class HEV_P2 : CompletedBusDeclarationBase { } + public class HEV_P2_5 : CompletedBusDeclarationBase { } + public class HEV_P3 : CompletedBusDeclarationBase { } + public class HEV_P4 : CompletedBusDeclarationBase { } + public class PEV_E2 : CompletedBusDeclarationBase { } + public class PEV_E3 : CompletedBusDeclarationBase { } + public class PEV_E4 : CompletedBusDeclarationBase { } + public class PEV_E_IEPC : CompletedBusDeclarationBase { } - public AxleGearData CreateDummyAxleGearData(IGearboxDeclarationInputData gbxData) - { - throw new NotImplementedException(); - } + public class Exempted : CompletedBusDeclarationBase + { + #region Overrides of CompletedBusBase + + public override VehicleData CreateVehicleData(IVehicleDeclarationInputData vehicle, Segment segment, Mission mission, + KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) + { + return _vehicleDataAdapter.CreateExemptedVehicleData(vehicle); + } - #endregion + #endregion } - public class Conventional : CompletedBusBase { } - public class HEV_S2 : CompletedBusBase { } - public class HEV_S3 : CompletedBusBase { } - public class HEV_S4 : CompletedBusBase { } - public class HEV_S_IEPC : CompletedBusBase { } - public class HEV_P1 : CompletedBusBase { } - public class HEV_P2 : CompletedBusBase { } - public class HEV_P2_5 : CompletedBusBase { } - public class HEV_P3 : CompletedBusBase { } - public class HEV_P4 : CompletedBusBase { } - public class PEV_E2 : CompletedBusBase { } - public class PEV_E3 : CompletedBusBase { } - public class PEV_E4 : CompletedBusBase { } - public class PEV_E_IEPC : CompletedBusBase { } - } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/CompletedBus/Specific/DeclarationDataAdapterSpecificCompletedBus.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/CompletedBus/Specific/DeclarationDataAdapterSpecificCompletedBus.cs index 1b7523b5f8c525f99b4909378e89a850dc107287..e2179f950aa7deef1b0c27eb21d38cdca4797de7 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/CompletedBus/Specific/DeclarationDataAdapterSpecificCompletedBus.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/CompletedBus/Specific/DeclarationDataAdapterSpecificCompletedBus.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using TUGraz.VectoCommon.BusAuxiliaries; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -13,93 +14,70 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.CompletedBus.Speci { public abstract class DeclarationDataAdapterSpecificCompletedBus { - public abstract class CompletedBusBase : ISpecificCompletedBusDataAdapter + public abstract class CompletedBusDeclarationBase : AbstractSimulationDataAdapter, ISpecificCompletedBusDeclarationDataAdapter { private readonly IDriverDataAdapter _driverDataAdapter = new CompletedBusSpecificDriverDataAdapter(); - #region Implementation of IDeclarationDataAdapter + private readonly ICompletedBusAuxiliaryDataAdapter _auxDataAdapter = + new SpecificCompletedBusAuxiliaryDataAdapter(new PrimaryBusAuxiliaryDataAdapter()); - public DriverData CreateDriverData() + #region Implementation of ISpecificCompletedBusDeclarationDataAdapter + + public IAuxiliaryConfig CreateBusAuxiliariesData(Mission mission, IVehicleDeclarationInputData primaryVehicle, + IVehicleDeclarationInputData completedVehicle, VectoRunData runData) { - return _driverDataAdapter.CreateDriverData(); + throw new NotImplementedException(); } - public VehicleData CreateVehicleData(IVehicleDeclarationInputData vehicle, Segment segment, Mission mission, - KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) - { - throw new NotImplementedException(); - } - - public AirdragData CreateAirdragData(IAirdragDeclarationInputData airdragData, Mission mission, Segment segment) - { - throw new NotImplementedException(); - } - - public AxleGearData CreateAxleGearData(IAxleGearInputData axlegearData) - { - throw new NotImplementedException(); - } - - public AngledriveData CreateAngledriveData(IAngledriveInputData angledriveData) - { - throw new NotImplementedException(); - } - - public CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, IEngineModeDeclarationInputData engineMode, - Mission mission) - { - throw new NotImplementedException(); - } - - public GearboxData CreateGearboxData(IVehicleDeclarationInputData inputData, VectoRunData runData, - IShiftPolygonCalculator shiftPolygonCalc) - { - throw new NotImplementedException(); - } - - public ShiftStrategyParameters CreateGearshiftData(GearboxData gbx, double axleRatio, PerSecond engineIdlingSpeed) - { - throw new NotImplementedException(); - } + public VehicleData CreateVehicleData(IVehicleDeclarationInputData primaryVehicle, + IVehicleDeclarationInputData completedVehicle, Segment segment, Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading) + { + throw new NotImplementedException(); + } - public RetarderData CreateRetarderData(IRetarderInputData retarderData) - { - throw new NotImplementedException(); - } + public IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxData, IBusAuxiliariesDeclarationData busAuxData, + MissionType missionType, VehicleClass vehicleClass, Meter vehicleLength, int? numSteeredAxles) + { + throw new NotImplementedException(); + } - public PTOData CreatePTOTransmissionData(IPTOTransmissionInputData ptoData) - { - throw new NotImplementedException(); - } + public AirdragData CreateAirdragData(IVehicleDeclarationInputData completedVehicle, Mission mission) + { + throw new NotImplementedException(); + } - public IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxData, IBusAuxiliariesDeclarationData busAuxData, - MissionType missionType, VehicleClass vehicleClass, Meter vehicleLength, int? numSteeredAxles) - { - throw new NotImplementedException(); - } + public CombustionEngineData CreateEngineData(IVehicleDeclarationInputData primaryVehicle, int modeIdx, Mission mission) + { + throw new NotImplementedException(); + } - public AxleGearData CreateDummyAxleGearData(IGearboxDeclarationInputData gbxData) - { - throw new NotImplementedException(); - } + #endregion - #endregion - } + #region Implementation of IDeclarationDataAdapter + public VehicleData CreateVehicleData(IVehicleDeclarationInputData vehicle, Segment segment, Mission mission, + KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) + { + throw new NotImplementedException(); + } - public class Conventional : CompletedBusBase { } - public class HEV_S2 : CompletedBusBase { } - public class HEV_S3 : CompletedBusBase { } - public class HEV_S4 : CompletedBusBase { } - public class HEV_S_IEPC : CompletedBusBase { } - public class HEV_P1 : CompletedBusBase { } - public class HEV_P2 : CompletedBusBase { } - public class HEV_P2_5 : CompletedBusBase { } - public class HEV_P3 : CompletedBusBase { } - public class HEV_P4 : CompletedBusBase { } - public class PEV_E2 : CompletedBusBase { } - public class PEV_E3 : CompletedBusBase { } - public class PEV_E4 : CompletedBusBase { } - public class PEV_E_IEPC : CompletedBusBase { } + #endregion + } + + + public class Conventional : CompletedBusDeclarationBase { } + public class HEV_S2 : CompletedBusDeclarationBase { } + public class HEV_S3 : CompletedBusDeclarationBase { } + public class HEV_S4 : CompletedBusDeclarationBase { } + public class HEV_S_IEPC : CompletedBusDeclarationBase { } + public class HEV_P1 : CompletedBusDeclarationBase { } + public class HEV_P2 : CompletedBusDeclarationBase { } + public class HEV_P2_5 : CompletedBusDeclarationBase { } + public class HEV_P3 : CompletedBusDeclarationBase { } + public class HEV_P4 : CompletedBusDeclarationBase { } + public class PEV_E2 : CompletedBusDeclarationBase { } + public class PEV_E3 : CompletedBusDeclarationBase { } + public class PEV_E4 : CompletedBusDeclarationBase { } + public class PEV_E_IEPC : CompletedBusDeclarationBase { } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cd b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cd new file mode 100644 index 0000000000000000000000000000000000000000..933046ccfb6cee86d8f448a8992e0686a0c6a8dc --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cd @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<ClassDiagram MajorVersion="1" MinorVersion="1" MembersFormat="FullSignature"> + <Interface Name="TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.IDeclarationDataAdapter"> + <Position X="0.5" Y="1.5" Width="13" /> + <TypeIdentifier> + <HashCode>AAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</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" /> + <TypeIdentifier> + <HashCode>AAEAAAgAACAgAAAAAAEAAgIAAAAAAAAEAAAAQAABQAA=</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" /> + <TypeIdentifier> + <HashCode>AAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAABQAA=</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" /> + <TypeIdentifier> + <HashCode>AAEAAAgAACAgAAAAAAEAAgAAAAAAAAAAAAAAQAABQAA=</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" /> + <TypeIdentifier> + <HashCode>AAEAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAQAABQAA=</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/DeclarationDataAdapterCompletedBusGeneric.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusGeneric.cs index 6968df3069fcf3490dfea32a2cb19b5bf9020f0b..45fa63cd12586f18c72b7178e73862ac0ebccc54 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusGeneric.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusGeneric.cs @@ -1,121 +1,121 @@ -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.PrimaryBus; -using TUGraz.VectoCore.Models.Declaration; -using TUGraz.VectoCore.Models.GenericModelData; -using TUGraz.VectoCore.Models.SimulationComponent.Data; -using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; - -namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter -{ - public class DeclarationDataAdapterCompletedBusGeneric : DeclarationDataAdapterPrimaryBus - { - private readonly GenericTransmissionComponentData _genericPowertrainData = new GenericTransmissionComponentData(); - private readonly GenericBusRetarderData _genericRetarderData = new GenericBusRetarderData(); - private readonly GenericTorqueConverterData _genericTorqueConverterData = new GenericTorqueConverterData(); - - public const double GearEfficiencyDirectGear = 0.98; - public const double GearEfficiencyIndirectGear = 0.96; - public const double GearEfficiencyAT = 0.925; - - - #region Overrides of DeclarationDataAdapterPrimaryBus - - public new DriverData CreateDriverData() - { - var retVal = base.CreateDriverData(); - retVal.LookAheadCoasting.Enabled = false; - retVal.OverSpeed.Enabled = false; - return retVal; - } - - public override VehicleData CreateVehicleData( - IVehicleDeclarationInputData data, Segment segment, Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) - { - var retVal = base.CreateVehicleData(data, segment, mission, loading, allowVocational); - retVal.GrossVehicleMass = data.GrossVehicleMassRating; - if (retVal.TotalVehicleMass.IsGreater(retVal.GrossVehicleMass)) { - throw new VectoException("Total Vehicle Mass exceeds Gross Vehicle Mass for completed bus generic ({0}/{1})", retVal.TotalVehicleMass, retVal.GrossVehicleMass); - } - return retVal; - } - - #endregion - - // The model parameters for the completed bus with generic power train and generic body is basically the same as the primary bus - // only powertrain components are different +//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.PrimaryBus; +//using TUGraz.VectoCore.Models.Declaration; +//using TUGraz.VectoCore.Models.GenericModelData; +//using TUGraz.VectoCore.Models.SimulationComponent.Data; +//using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; + +//namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +//{ + //public class DeclarationDataAdapterCompletedBusGeneric : DeclarationDataAdapterPrimaryBus + //{ + // private readonly GenericTransmissionComponentData _genericPowertrainData = new GenericTransmissionComponentData(); + // private readonly GenericBusRetarderData _genericRetarderData = new GenericBusRetarderData(); + // private readonly GenericTorqueConverterData _genericTorqueConverterData = new GenericTorqueConverterData(); + + // public const double GearEfficiencyDirectGear = 0.98; + // public const double GearEfficiencyIndirectGear = 0.96; + // public const double GearEfficiencyAT = 0.925; + + + // #region Overrides of DeclarationDataAdapterPrimaryBus + + // public new DriverData CreateDriverData() + // { + // var retVal = base.CreateDriverData(); + // retVal.LookAheadCoasting.Enabled = false; + // retVal.OverSpeed.Enabled = false; + // return retVal; + // } + + // public override VehicleData CreateVehicleData( + // IVehicleDeclarationInputData data, Segment segment, Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) + // { + // var retVal = base.CreateVehicleData(data, segment, mission, loading, allowVocational); + // retVal.GrossVehicleMass = data.GrossVehicleMassRating; + // if (retVal.TotalVehicleMass.IsGreater(retVal.GrossVehicleMass)) { + // throw new VectoException("Total Vehicle Mass exceeds Gross Vehicle Mass for completed bus generic ({0}/{1})", retVal.TotalVehicleMass, retVal.GrossVehicleMass); + // } + // return retVal; + // } + + // #endregion + + // // The model parameters for the completed bus with generic power train and generic body is basically the same as the primary bus + // // only powertrain components are different - public CombustionEngineData CreateEngineData(IVehicleDeclarationInputData primaryVehicle, int modeIdx, Mission mission) - { - return GenericBusEngineData.Instance.CreateGenericBusEngineData(primaryVehicle, modeIdx, mission); - } + // public CombustionEngineData CreateEngineData(IVehicleDeclarationInputData primaryVehicle, int modeIdx, Mission mission) + // { + // return GenericBusEngineData.Instance.CreateGenericBusEngineData(primaryVehicle, modeIdx, mission); + // } - #region Overrides of DeclarationDataAdapterHeavyLorry + // #region Overrides of DeclarationDataAdapterHeavyLorry - public AxleGearData CreateAxleGearData(IAxleGearInputData axlegearData) - { - return _genericPowertrainData.CreateGenericBusAxlegearData(axlegearData); - } + // public AxleGearData CreateAxleGearData(IAxleGearInputData axlegearData) + // { + // return _genericPowertrainData.CreateGenericBusAxlegearData(axlegearData); + // } - public AngledriveData CreateAngledriveData(IAngledriveInputData data) - { - return _genericPowertrainData.CreateGenericBusAngledriveData(data); - } + // public AngledriveData CreateAngledriveData(IAngledriveInputData data) + // { + // return _genericPowertrainData.CreateGenericBusAngledriveData(data); + // } - public RetarderData CreateRetarderData(IRetarderInputData retarder) - { - return _genericRetarderData.CreateGenericBusRetarderData(retarder); - } + // public RetarderData CreateRetarderData(IRetarderInputData retarder) + // { + // return _genericRetarderData.CreateGenericBusRetarderData(retarder); + // } - #endregion + // #endregion - #region Overrides of AbstractSimulationDataAdapter + // #region Overrides of AbstractSimulationDataAdapter - protected override TransmissionLossMap CreateGearLossMap(ITransmissionInputData gear, uint i, bool useEfficiencyFallback, VehicleCategory vehicleCategory, GearboxType gearboxType) - { - if (gearboxType.AutomaticTransmission()) { - return TransmissionLossMapReader.Create(GearEfficiencyAT, gear.Ratio, $"Gear {i + 1}"); - } - return TransmissionLossMapReader.Create( - gear.Ratio.IsEqual(1) ? GearEfficiencyDirectGear : GearEfficiencyIndirectGear, gear.Ratio, $"Gear {i + 1}"); - } + // protected override TransmissionLossMap CreateGearLossMap(ITransmissionInputData gear, uint i, bool useEfficiencyFallback, VehicleCategory vehicleCategory, GearboxType gearboxType) + // { + // if (gearboxType.AutomaticTransmission()) { + // return TransmissionLossMapReader.Create(GearEfficiencyAT, gear.Ratio, $"Gear {i + 1}"); + // } + // return TransmissionLossMapReader.Create( + // gear.Ratio.IsEqual(1) ? GearEfficiencyDirectGear : GearEfficiencyIndirectGear, gear.Ratio, $"Gear {i + 1}"); + // } - protected void CretateTCFirstGearATPowerSplit(GearData gearData, uint i, ShiftPolygon shiftPolygon) - { - gearData.TorqueConverterRatio = 1; - //gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(GearEfficiencyIndirectGear, 1, string.Format("TCGear {0}", i + 1)); - gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(1.0, 1, $"TCGear {i + 1}"); - gearData.TorqueConverterShiftPolygon = shiftPolygon; - } + // protected void CretateTCFirstGearATPowerSplit(GearData gearData, uint i, ShiftPolygon shiftPolygon) + // { + // gearData.TorqueConverterRatio = 1; + // //gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(GearEfficiencyIndirectGear, 1, string.Format("TCGear {0}", i + 1)); + // gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(1.0, 1, $"TCGear {i + 1}"); + // gearData.TorqueConverterShiftPolygon = shiftPolygon; + // } - #endregion + // #endregion - #region Overrides of DeclarationDataAdapterHeavyLorry + // #region Overrides of DeclarationDataAdapterHeavyLorry - protected override TorqueConverterData CreateTorqueConverterData(GearboxType gearboxType, - ITorqueConverterDeclarationInputData torqueConverter, double ratio, CombustionEngineData engineData) - { + // protected override TorqueConverterData CreateTorqueConverterData(GearboxType gearboxType, + // ITorqueConverterDeclarationInputData torqueConverter, double ratio, CombustionEngineData engineData) + // { - if (torqueConverter != null && torqueConverter.TCData != null) { - return TorqueConverterDataReader.Create( - torqueConverter.TCData, - DeclarationData.TorqueConverter.ReferenceRPM, DeclarationData.TorqueConverter.MaxInputSpeed, - ExecutionMode.Engineering, ratio, - DeclarationData.TorqueConverter.CLUpshiftMinAcceleration, - DeclarationData.TorqueConverter.CCUpshiftMinAcceleration); - } - return _genericTorqueConverterData.CreateTorqueConverterData(gearboxType, ratio, engineData); - } - - #endregion + // if (torqueConverter != null && torqueConverter.TCData != null) { + // return TorqueConverterDataReader.Create( + // torqueConverter.TCData, + // DeclarationData.TorqueConverter.ReferenceRPM, DeclarationData.TorqueConverter.MaxInputSpeed, + // ExecutionMode.Engineering, ratio, + // DeclarationData.TorqueConverter.CLUpshiftMinAcceleration, + // DeclarationData.TorqueConverter.CCUpshiftMinAcceleration); + // } + // return _genericTorqueConverterData.CreateTorqueConverterData(gearboxType, ratio, engineData); + // } + + // #endregion - } -} +// } +//} diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusSpecific.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusSpecific.cs index 7f948cc86115c05db86b710e53d625861908ef5b..61a7d11a3e74b54c8f6710a7782b5eb4ba2fe1e6 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusSpecific.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterCompletedBusSpecific.cs @@ -17,423 +17,423 @@ using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data; -namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter -{ - public class DeclarationDataAdapterCompletedBusSpecific : DeclarationDataAdapterCompletedBusGeneric - { - - public VehicleData CreateVehicleData(IVehicleDeclarationInputData primaryVehicle, - IVehicleDeclarationInputData completedVehicle, Segment segment, Mission mission, - KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading) - { - if (completedVehicle.NumberPassengerSeatsLowerDeck == null) { - throw new VectoException("NumberOfPassengerSeatsLowerDeck input parameter is required"); - } - if (completedVehicle.NumberPassengerSeatsUpperDeck == null) { - throw new VectoException("NumberOfPassengerSeatsUpperDeck input parameter is required"); - } - if (completedVehicle.NumberPassengersStandingLowerDeck == null) { - throw new VectoException("NumberOfPassengersStandingLowerDeck input parameter is required"); - } - if (completedVehicle.NumberPassengersStandingUpperDeck == null) { - throw new VectoException("NumberOfPassengersStandingUpperDeck input parameter is required"); - } - var passengers = GetNumberOfPassengers( - mission, completedVehicle.Length, completedVehicle.Width, - completedVehicle.NumberPassengerSeatsLowerDeck.Value + completedVehicle.NumberPassengerSeatsUpperDeck.Value, - completedVehicle.NumberPassengersStandingLowerDeck.Value + completedVehicle.NumberPassengersStandingUpperDeck.Value, - loading.Key); - - var vehicleData = base.CreateVehicleData(primaryVehicle, segment, mission, loading, false); - vehicleData.InputData = completedVehicle; - vehicleData.VIN = completedVehicle.VIN; - vehicleData.LegislativeClass = completedVehicle.LegislativeClass; - vehicleData.VehicleCategory = VehicleCategory.HeavyBusCompletedVehicle; - vehicleData.Manufacturer = completedVehicle.Manufacturer; - vehicleData.ModelName = completedVehicle.Model; - vehicleData.ManufacturerAddress = completedVehicle.ManufacturerAddress; - vehicleData.CurbMass = completedVehicle.CurbMassChassis; - - vehicleData.Loading = passengers * mission.MissionType.GetAveragePassengerMass(); - vehicleData.PassengerCount = passengers; - vehicleData.GrossVehicleMass = completedVehicle.GrossVehicleMassRating; - vehicleData.DigestValueInput = completedVehicle.DigestValue?.DigestValue ?? ""; - - vehicleData.RegisteredClass = completedVehicle.RegisteredClass; - - vehicleData.VehicleCode = completedVehicle.VehicleCode; - if (vehicleData.TotalVehicleMass.IsGreater(vehicleData.GrossVehicleMass)) { - throw new VectoException("Total Vehicle Mass exceeds Gross Vehicle Mass for completed bus specific ({0}/{1})", - vehicleData.TotalVehicleMass, vehicleData.GrossVehicleMass); - } - return vehicleData; - } - - 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, - GetDeclarationAirResistanceCurve( - mission.CrossWindCorrectionParameters, mission.DefaultCDxA, completedVehicle.Height + mission.BusParameter.DeltaHeight), - CrossWindCorrectionMode.DeclarationModeCorrection), - CrossWindCorrectionMode = CrossWindCorrectionMode.DeclarationModeCorrection - }; - } - - var retVal = SetCommonAirdragData(completedVehicle.Components.AirdragInputData); - retVal.CrossWindCorrectionMode = CrossWindCorrectionMode.DeclarationModeCorrection; - var aerodynamicDragArea = completedVehicle.Components.AirdragInputData.AirDragArea; - - retVal.DeclaredAirdragArea = aerodynamicDragArea; - retVal.CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup( - aerodynamicDragArea, - GetDeclarationAirResistanceCurve( - mission.CrossWindCorrectionParameters, - aerodynamicDragArea, - completedVehicle.Height + mission.BusParameter.DeltaHeight), - CrossWindCorrectionMode.DeclarationModeCorrection); - - return retVal; - } - - public virtual IAuxiliaryConfig CreateBusAuxiliariesData(Mission mission, IVehicleDeclarationInputData primaryVehicle, IVehicleDeclarationInputData completedVehicle, VectoRunData runData) - { - var actuations = DeclarationData.BusAuxiliaries.ActuationsMap.Lookup(runData.Mission.MissionType); - var primaryBusAuxiliaries = primaryVehicle.Components.BusAuxiliaries; - - return new AuxiliaryConfig { - InputData = completedVehicle.Components.BusAuxiliaries, - ElectricalUserInputsConfig = CreateElectricsUserInputsConfig( - primaryVehicle, completedVehicle, mission, actuations, runData.VehicleData.VehicleClass), - PneumaticUserInputsConfig = CreatePneumaticUserInputsConfig( - primaryBusAuxiliaries, completedVehicle), - PneumaticAuxillariesConfig = CreatePneumaticAuxConfig(runData.Retarder.Type), - Actuations = actuations, - SSMInputs = GetCompletedSSMInput(mission, completedVehicle, primaryVehicle, runData.Loading), - VehicleData = runData.VehicleData - }; - } - - protected virtual ElectricsUserInputsConfig CreateElectricsUserInputsConfig(IVehicleDeclarationInputData primaryVehicle, - IVehicleDeclarationInputData completedVehicle, Mission mission, IActuations actuations, VehicleClass 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)) { - currentDemand[entry.Key] = entry.Value; - } - - var retVal = GetDefaultElectricalUserConfig(); - - var primaryBusAuxiliaries = primaryVehicle.Components.BusAuxiliaries; - retVal.AlternatorType = primaryBusAuxiliaries.ElectricSupply.AlternatorTechnology; - retVal.ElectricalConsumers = currentDemand; - retVal.AlternatorMap = new SimpleAlternator( - CalculateAlternatorEfficiency( - primaryBusAuxiliaries.ElectricSupply.Alternators - .Concat(completedVehicle.Components.BusAuxiliaries.ElectricSupply?.Alternators ?? - new List<IAlternatorDeclarationInputData>()).ToList())); - switch (retVal.AlternatorType) { - case AlternatorType.Smart when primaryBusAuxiliaries.ElectricSupply.Alternators.Count == 0: - throw new VectoException("at least one alternator is required when specifying smart electrics!"); - case AlternatorType.Smart when primaryBusAuxiliaries.ElectricSupply.ElectricStorage.Count == 0: - throw new VectoException("at least one electric storage (battery or capacitor) is required when specifying smart electrics!"); - } - - retVal.MaxAlternatorPower = primaryBusAuxiliaries.ElectricSupply.Alternators.Sum(x => x.RatedVoltage * x.RatedCurrent); - retVal.ElectricStorageCapacity = primaryBusAuxiliaries.ElectricSupply.ElectricStorage.Sum(x => x.ElectricStorageCapacity) ?? 0.SI<WattSecond>(); +//namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +//{ +// public class DeclarationDataAdapterCompletedBusSpecific : DeclarationDataAdapterCompletedBusGeneric +// { + +// public VehicleData CreateVehicleData(IVehicleDeclarationInputData primaryVehicle, +// IVehicleDeclarationInputData completedVehicle, Segment segment, Mission mission, +// KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading) +// { +// if (completedVehicle.NumberPassengerSeatsLowerDeck == null) { +// throw new VectoException("NumberOfPassengerSeatsLowerDeck input parameter is required"); +// } +// if (completedVehicle.NumberPassengerSeatsUpperDeck == null) { +// throw new VectoException("NumberOfPassengerSeatsUpperDeck input parameter is required"); +// } +// if (completedVehicle.NumberPassengersStandingLowerDeck == null) { +// throw new VectoException("NumberOfPassengersStandingLowerDeck input parameter is required"); +// } +// if (completedVehicle.NumberPassengersStandingUpperDeck == null) { +// throw new VectoException("NumberOfPassengersStandingUpperDeck input parameter is required"); +// } +// var passengers = GetNumberOfPassengers( +// mission, completedVehicle.Length, completedVehicle.Width, +// completedVehicle.NumberPassengerSeatsLowerDeck.Value + completedVehicle.NumberPassengerSeatsUpperDeck.Value, +// completedVehicle.NumberPassengersStandingLowerDeck.Value + completedVehicle.NumberPassengersStandingUpperDeck.Value, +// loading.Key); + +// var vehicleData = base.CreateVehicleData(primaryVehicle, segment, mission, loading, false); +// vehicleData.InputData = completedVehicle; +// vehicleData.VIN = completedVehicle.VIN; +// vehicleData.LegislativeClass = completedVehicle.LegislativeClass; +// vehicleData.VehicleCategory = VehicleCategory.HeavyBusCompletedVehicle; +// vehicleData.Manufacturer = completedVehicle.Manufacturer; +// vehicleData.ModelName = completedVehicle.Model; +// vehicleData.ManufacturerAddress = completedVehicle.ManufacturerAddress; +// vehicleData.CurbMass = completedVehicle.CurbMassChassis; + +// vehicleData.Loading = passengers * mission.MissionType.GetAveragePassengerMass(); +// vehicleData.PassengerCount = passengers; +// vehicleData.GrossVehicleMass = completedVehicle.GrossVehicleMassRating; +// vehicleData.DigestValueInput = completedVehicle.DigestValue?.DigestValue ?? ""; + +// vehicleData.RegisteredClass = completedVehicle.RegisteredClass; + +// vehicleData.VehicleCode = completedVehicle.VehicleCode; +// if (vehicleData.TotalVehicleMass.IsGreater(vehicleData.GrossVehicleMass)) { +// throw new VectoException("Total Vehicle Mass exceeds Gross Vehicle Mass for completed bus specific ({0}/{1})", +// vehicleData.TotalVehicleMass, vehicleData.GrossVehicleMass); +// } +// return vehicleData; +// } + +// 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, +// GetDeclarationAirResistanceCurve( +// mission.CrossWindCorrectionParameters, mission.DefaultCDxA, completedVehicle.Height + mission.BusParameter.DeltaHeight), +// CrossWindCorrectionMode.DeclarationModeCorrection), +// CrossWindCorrectionMode = CrossWindCorrectionMode.DeclarationModeCorrection +// }; +// } + +// var retVal = SetCommonAirdragData(completedVehicle.Components.AirdragInputData); +// retVal.CrossWindCorrectionMode = CrossWindCorrectionMode.DeclarationModeCorrection; +// var aerodynamicDragArea = completedVehicle.Components.AirdragInputData.AirDragArea; + +// retVal.DeclaredAirdragArea = aerodynamicDragArea; +// retVal.CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup( +// aerodynamicDragArea, +// GetDeclarationAirResistanceCurve( +// mission.CrossWindCorrectionParameters, +// aerodynamicDragArea, +// completedVehicle.Height + mission.BusParameter.DeltaHeight), +// CrossWindCorrectionMode.DeclarationModeCorrection); + +// return retVal; +// } + +// public virtual IAuxiliaryConfig CreateBusAuxiliariesData(Mission mission, IVehicleDeclarationInputData primaryVehicle, IVehicleDeclarationInputData completedVehicle, VectoRunData runData) +// { +// var actuations = DeclarationData.BusAuxiliaries.ActuationsMap.Lookup(runData.Mission.MissionType); +// var primaryBusAuxiliaries = primaryVehicle.Components.BusAuxiliaries; + +// return new AuxiliaryConfig { +// InputData = completedVehicle.Components.BusAuxiliaries, +// ElectricalUserInputsConfig = CreateElectricsUserInputsConfig( +// primaryVehicle, completedVehicle, mission, actuations, runData.VehicleData.VehicleClass), +// PneumaticUserInputsConfig = CreatePneumaticUserInputsConfig( +// primaryBusAuxiliaries, completedVehicle), +// PneumaticAuxillariesConfig = CreatePneumaticAuxConfig(runData.Retarder.Type), +// Actuations = actuations, +// SSMInputs = GetCompletedSSMInput(mission, completedVehicle, primaryVehicle, runData.Loading), +// VehicleData = runData.VehicleData +// }; +// } + +// protected virtual ElectricsUserInputsConfig CreateElectricsUserInputsConfig(IVehicleDeclarationInputData primaryVehicle, +// IVehicleDeclarationInputData completedVehicle, Mission mission, IActuations actuations, VehicleClass 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)) { +// currentDemand[entry.Key] = entry.Value; +// } + +// var retVal = GetDefaultElectricalUserConfig(); + +// var primaryBusAuxiliaries = primaryVehicle.Components.BusAuxiliaries; +// retVal.AlternatorType = primaryBusAuxiliaries.ElectricSupply.AlternatorTechnology; +// retVal.ElectricalConsumers = currentDemand; +// retVal.AlternatorMap = new SimpleAlternator( +// CalculateAlternatorEfficiency( +// primaryBusAuxiliaries.ElectricSupply.Alternators +// .Concat(completedVehicle.Components.BusAuxiliaries.ElectricSupply?.Alternators ?? +// new List<IAlternatorDeclarationInputData>()).ToList())); +// switch (retVal.AlternatorType) { +// case AlternatorType.Smart when primaryBusAuxiliaries.ElectricSupply.Alternators.Count == 0: +// throw new VectoException("at least one alternator is required when specifying smart electrics!"); +// case AlternatorType.Smart when primaryBusAuxiliaries.ElectricSupply.ElectricStorage.Count == 0: +// throw new VectoException("at least one electric storage (battery or capacitor) is required when specifying smart electrics!"); +// } + +// retVal.MaxAlternatorPower = primaryBusAuxiliaries.ElectricSupply.Alternators.Sum(x => x.RatedVoltage * x.RatedCurrent); +// retVal.ElectricStorageCapacity = primaryBusAuxiliaries.ElectricSupply.ElectricStorage.Sum(x => x.ElectricStorageCapacity) ?? 0.SI<WattSecond>(); - return retVal; - } - - protected override Dictionary<string, ElectricConsumerEntry> GetElectricAuxConsumers(Mission mission, IVehicleDeclarationInputData vehicleData, VehicleClass vehicleClass, IBusAuxiliariesDeclarationData busAux) - { - return new Dictionary<string, ElectricConsumerEntry>(); - } - - protected virtual Dictionary<string, ElectricConsumerEntry> GetElectricAuxConsumersPrimary(Mission mission, IVehicleDeclarationInputData vehicleData, VehicleClass vehicleClass, IBusAuxiliariesDeclarationData busAuxPrimary) - { - var retVal = new Dictionary<string, ElectricConsumerEntry>(); - var spPower = DeclarationData.SteeringPumpBus.LookupElectricalPowerDemand( - mission.MissionType, busAuxPrimary.SteeringPumpTechnology, - vehicleData.Length ?? mission.BusParameter.VehicleLength); - retVal[Constants.Auxiliaries.IDs.SteeringPump] = new ElectricConsumerEntry { - ActiveDuringEngineStopStandstill = false, - BaseVehicle = false, - Current = spPower / Constants.BusAuxiliaries.ElectricSystem.PowernetVoltage - }; - - var fanPower = vehicleData.VehicleType == VectoSimulationJobType.BatteryElectricVehicle - ? 0.SI<Watt>() - : DeclarationData.Fan.LookupElectricalPowerDemand( - vehicleClass, mission.MissionType, busAuxPrimary.FanTechnology); - retVal[Constants.Auxiliaries.IDs.Fan] = new ElectricConsumerEntry { - ActiveDuringEngineStopStandstill = false, - ActiveDuringEngineStopDriving = false, - BaseVehicle = false, - Current = fanPower / Constants.BusAuxiliaries.ElectricSystem.PowernetVoltage - }; - return retVal; - } - - protected PneumaticUserInputsConfig CreatePneumaticUserInputsConfig(IBusAuxiliariesDeclarationData primaryBusAuxiliaries, - IVehicleDeclarationInputData completedVehicle) - { - return new PneumaticUserInputsConfig { - CompressorMap = completedVehicle.VehicleType == VectoSimulationJobType.BatteryElectricVehicle - ? null - : DeclarationData.BusAuxiliaries.GetCompressorMap( - primaryBusAuxiliaries.PneumaticSupply.CompressorSize, - primaryBusAuxiliaries.PneumaticSupply.Clutch), - CompressorGearEfficiency = Constants.BusAuxiliaries.PneumaticUserConfig.CompressorGearEfficiency, - CompressorGearRatio = completedVehicle.VehicleType == VectoSimulationJobType.BatteryElectricVehicle - ? 0 : primaryBusAuxiliaries.PneumaticSupply.Ratio, - SmartAirCompression = primaryBusAuxiliaries.PneumaticSupply.SmartAirCompression, - SmartRegeneration = primaryBusAuxiliaries.PneumaticSupply.SmartRegeneration, - KneelingHeight = VectoMath.Max(0.SI<Meter>(), - completedVehicle.EntranceHeight - Constants.BusParameters.EntranceHeight), - AirSuspensionControl = primaryBusAuxiliaries.PneumaticConsumers.AirsuspensionControl, - AdBlueDosing = primaryBusAuxiliaries.PneumaticConsumers.AdBlueDosing, - Doors = completedVehicle.DoorDriveTechnology - }; - } - - protected SSMInputs GetCompletedSSMInput(Mission mission, IVehicleDeclarationInputData completedVehicle, - IVehicleDeclarationInputData primaryVehicle, LoadingType loadingType) - { - var isDoubleDecker = completedVehicle.VehicleCode.IsDoubleDeckerBus(); - var hvacConfiguration = completedVehicle.Components.BusAuxiliaries.HVACAux.SystemConfiguration; - var busAux = completedVehicle.Components.BusAuxiliaries.HVACAux; +// return retVal; +// } + +// protected override Dictionary<string, ElectricConsumerEntry> GetElectricAuxConsumers(Mission mission, IVehicleDeclarationInputData vehicleData, VehicleClass vehicleClass, IBusAuxiliariesDeclarationData busAux) +// { +// return new Dictionary<string, ElectricConsumerEntry>(); +// } + +// protected virtual Dictionary<string, ElectricConsumerEntry> GetElectricAuxConsumersPrimary(Mission mission, IVehicleDeclarationInputData vehicleData, VehicleClass vehicleClass, IBusAuxiliariesDeclarationData busAuxPrimary) +// { +// var retVal = new Dictionary<string, ElectricConsumerEntry>(); +// var spPower = DeclarationData.SteeringPumpBus.LookupElectricalPowerDemand( +// mission.MissionType, busAuxPrimary.SteeringPumpTechnology, +// vehicleData.Length ?? mission.BusParameter.VehicleLength); +// retVal[Constants.Auxiliaries.IDs.SteeringPump] = new ElectricConsumerEntry { +// ActiveDuringEngineStopStandstill = false, +// BaseVehicle = false, +// Current = spPower / Constants.BusAuxiliaries.ElectricSystem.PowernetVoltage +// }; + +// var fanPower = vehicleData.VehicleType == VectoSimulationJobType.BatteryElectricVehicle +// ? 0.SI<Watt>() +// : DeclarationData.Fan.LookupElectricalPowerDemand( +// vehicleClass, mission.MissionType, busAuxPrimary.FanTechnology); +// retVal[Constants.Auxiliaries.IDs.Fan] = new ElectricConsumerEntry { +// ActiveDuringEngineStopStandstill = false, +// ActiveDuringEngineStopDriving = false, +// BaseVehicle = false, +// Current = fanPower / Constants.BusAuxiliaries.ElectricSystem.PowernetVoltage +// }; +// return retVal; +// } + +// protected PneumaticUserInputsConfig CreatePneumaticUserInputsConfig(IBusAuxiliariesDeclarationData primaryBusAuxiliaries, +// IVehicleDeclarationInputData completedVehicle) +// { +// return new PneumaticUserInputsConfig { +// CompressorMap = completedVehicle.VehicleType == VectoSimulationJobType.BatteryElectricVehicle +// ? null +// : DeclarationData.BusAuxiliaries.GetCompressorMap( +// primaryBusAuxiliaries.PneumaticSupply.CompressorSize, +// primaryBusAuxiliaries.PneumaticSupply.Clutch), +// CompressorGearEfficiency = Constants.BusAuxiliaries.PneumaticUserConfig.CompressorGearEfficiency, +// CompressorGearRatio = completedVehicle.VehicleType == VectoSimulationJobType.BatteryElectricVehicle +// ? 0 : primaryBusAuxiliaries.PneumaticSupply.Ratio, +// SmartAirCompression = primaryBusAuxiliaries.PneumaticSupply.SmartAirCompression, +// SmartRegeneration = primaryBusAuxiliaries.PneumaticSupply.SmartRegeneration, +// KneelingHeight = VectoMath.Max(0.SI<Meter>(), +// completedVehicle.EntranceHeight - Constants.BusParameters.EntranceHeight), +// AirSuspensionControl = primaryBusAuxiliaries.PneumaticConsumers.AirsuspensionControl, +// AdBlueDosing = primaryBusAuxiliaries.PneumaticConsumers.AdBlueDosing, +// Doors = completedVehicle.DoorDriveTechnology +// }; +// } + +// protected SSMInputs GetCompletedSSMInput(Mission mission, IVehicleDeclarationInputData completedVehicle, +// IVehicleDeclarationInputData primaryVehicle, LoadingType loadingType) +// { +// var isDoubleDecker = completedVehicle.VehicleCode.IsDoubleDeckerBus(); +// var hvacConfiguration = completedVehicle.Components.BusAuxiliaries.HVACAux.SystemConfiguration; +// var busAux = completedVehicle.Components.BusAuxiliaries.HVACAux; - if (mission.BusParameter.SeparateAirDistributionDuctsHVACCfg.Contains(hvacConfiguration) && - (busAux.SeparateAirDistributionDucts == null || !busAux.SeparateAirDistributionDucts.Value)) { - throw new VectoException("Input parameter 'separate air distribution ducts' has to be set to 'true' for vehicle group '{0}' and HVAC configuration '{1}'", - mission.BusParameter.BusGroup.GetClassNumber(), hvacConfiguration.GetName()); - } - - if (completedVehicle.NumberPassengerSeatsLowerDeck == null) { - throw new VectoException("NumberOfPassengerSeatsLowerDeck input parameter is required"); - } - if (completedVehicle.NumberPassengerSeatsUpperDeck == null) { - throw new VectoException("NumberOfPassengerSeatsUpperDeck input parameter is required"); - } - if (completedVehicle.NumberPassengersStandingLowerDeck == null) { - throw new VectoException("NumberOfPassengersStandingLowerDeck input parameter is required"); - } - if (completedVehicle.NumberPassengersStandingUpperDeck == null) { - throw new VectoException("NumberOfPassengersStandingUpperDeck input parameter is required"); - } - if (busAux.HeatPumpTypeCoolingDriverCompartment == null) { - throw new VectoException("HeatPumpTypeDriverCompartment Cooling input parameter is required"); - } - if (busAux.HeatPumpTypeHeatingDriverCompartment == null) { - throw new VectoException("HeatPumpTypeDriverCompartment Heating input parameter is required"); - } - if (busAux.HeatPumpTypeCoolingPassengerCompartment == null) { - throw new VectoException("HeatPumpTypePassengerCompartment Cooling input parameter is required"); - } - if (busAux.HeatPumpTypeHeatingPassengerCompartment == null) { - throw new VectoException("HeatPumpTypePassengerCompartment Heating input parameter is required"); - } - - - if (hvacConfiguration.RequiresDriverAC() && busAux.HeatPumpTypeCoolingDriverCompartment == HeatPumpType.none && busAux.HeatPumpTypeHeatingDriverCompartment == HeatPumpType.none) { - throw new VectoException("HVAC System Configuration {0} requires DriverAC Technology", hvacConfiguration); - } +// if (mission.BusParameter.SeparateAirDistributionDuctsHVACCfg.Contains(hvacConfiguration) && +// (busAux.SeparateAirDistributionDucts == null || !busAux.SeparateAirDistributionDucts.Value)) { +// throw new VectoException("Input parameter 'separate air distribution ducts' has to be set to 'true' for vehicle group '{0}' and HVAC configuration '{1}'", +// mission.BusParameter.BusGroup.GetClassNumber(), hvacConfiguration.GetName()); +// } + +// if (completedVehicle.NumberPassengerSeatsLowerDeck == null) { +// throw new VectoException("NumberOfPassengerSeatsLowerDeck input parameter is required"); +// } +// if (completedVehicle.NumberPassengerSeatsUpperDeck == null) { +// throw new VectoException("NumberOfPassengerSeatsUpperDeck input parameter is required"); +// } +// if (completedVehicle.NumberPassengersStandingLowerDeck == null) { +// throw new VectoException("NumberOfPassengersStandingLowerDeck input parameter is required"); +// } +// if (completedVehicle.NumberPassengersStandingUpperDeck == null) { +// throw new VectoException("NumberOfPassengersStandingUpperDeck input parameter is required"); +// } +// if (busAux.HeatPumpTypeCoolingDriverCompartment == null) { +// throw new VectoException("HeatPumpTypeDriverCompartment Cooling input parameter is required"); +// } +// if (busAux.HeatPumpTypeHeatingDriverCompartment == null) { +// throw new VectoException("HeatPumpTypeDriverCompartment Heating input parameter is required"); +// } +// if (busAux.HeatPumpTypeCoolingPassengerCompartment == null) { +// throw new VectoException("HeatPumpTypePassengerCompartment Cooling input parameter is required"); +// } +// if (busAux.HeatPumpTypeHeatingPassengerCompartment == null) { +// throw new VectoException("HeatPumpTypePassengerCompartment Heating input parameter is required"); +// } + + +// if (hvacConfiguration.RequiresDriverAC() && busAux.HeatPumpTypeCoolingDriverCompartment == HeatPumpType.none && busAux.HeatPumpTypeHeatingDriverCompartment == HeatPumpType.none) { +// throw new VectoException("HVAC System Configuration {0} requires DriverAC Technology", hvacConfiguration); +// } - if (hvacConfiguration.RequiresPassengerAC() && busAux.HeatPumpTypeCoolingPassengerCompartment == HeatPumpType.none && busAux.HeatPumpTypeHeatingPassengerCompartment == HeatPumpType.none) { - throw new VectoException("HVAC System Configuration {0} requires PassengerAC Technology", hvacConfiguration); - } +// if (hvacConfiguration.RequiresPassengerAC() && busAux.HeatPumpTypeCoolingPassengerCompartment == HeatPumpType.none && busAux.HeatPumpTypeHeatingPassengerCompartment == HeatPumpType.none) { +// throw new VectoException("HVAC System Configuration {0} requires PassengerAC Technology", hvacConfiguration); +// } - var heatPumpTypeDriverCompartment = busAux.HeatPumpTypeCoolingPassengerCompartment.Value; +// var heatPumpTypeDriverCompartment = busAux.HeatPumpTypeCoolingPassengerCompartment.Value; - var heatPumpTypePassengerCompartment = busAux.HeatPumpTypeCoolingPassengerCompartment.Value; +// var heatPumpTypePassengerCompartment = busAux.HeatPumpTypeCoolingPassengerCompartment.Value; - var internalLength = hvacConfiguration == BusHVACSystemConfiguration.Configuration2 - ? 2 * Constants.BusParameters.DriverCompartmentLength // OK - : DeclarationData.BusAuxiliaries.CalculateInternalLength( - completedVehicle.Length, completedVehicle.VehicleCode, - completedVehicle.NumberPassengerSeatsLowerDeck.Value); - var correctionLengthDrivetrainVolume = DeclarationData.BusAuxiliaries.CorrectionLengthDrivetrainVolume( - completedVehicle.VehicleCode, completedVehicle.LowEntry, primaryVehicle.AxleConfiguration.NumAxles(), - primaryVehicle.Articulated); +// var internalLength = hvacConfiguration == BusHVACSystemConfiguration.Configuration2 +// ? 2 * Constants.BusParameters.DriverCompartmentLength // OK +// : DeclarationData.BusAuxiliaries.CalculateInternalLength( +// completedVehicle.Length, completedVehicle.VehicleCode, +// completedVehicle.NumberPassengerSeatsLowerDeck.Value); +// var correctionLengthDrivetrainVolume = DeclarationData.BusAuxiliaries.CorrectionLengthDrivetrainVolume( +// completedVehicle.VehicleCode, completedVehicle.LowEntry, primaryVehicle.AxleConfiguration.NumAxles(), +// primaryVehicle.Articulated); - var internalHeight = DeclarationData.BusAuxiliaries.CalculateInternalHeight(completedVehicle.VehicleCode, completedVehicle.RegisteredClass, completedVehicle.Height); - var correctedBusWidth = DeclarationData.BusAuxiliaries.CorrectedBusWidth(completedVehicle.Width); +// var internalHeight = DeclarationData.BusAuxiliaries.CalculateInternalHeight(completedVehicle.VehicleCode, completedVehicle.RegisteredClass, completedVehicle.Height); +// var correctedBusWidth = DeclarationData.BusAuxiliaries.CorrectedBusWidth(completedVehicle.Width); - var coolingPower = CalculateMaxCoolingPower(completedVehicle, primaryVehicle, mission); +// var coolingPower = CalculateMaxCoolingPower(completedVehicle, primaryVehicle, mission); - var floorType = completedVehicle.VehicleCode.GetFloorType(); +// var floorType = completedVehicle.VehicleCode.GetFloorType(); - var ssmInputs =GetDefaulSSMInputs(FuelData.Diesel); +// var ssmInputs =GetDefaulSSMInputs(FuelData.Diesel); - ssmInputs.BusFloorType = completedVehicle.VehicleCode.GetFloorType(); - ssmInputs.Technologies = CreateTechnologyBenefits(completedVehicle, primaryVehicle.Components.BusAuxiliaries); - ssmInputs.FuelFiredHeaterPower = busAux.AuxHeaterPower; - ssmInputs.BusWindowSurface = DeclarationData.BusAuxiliaries.WindowHeight(isDoubleDecker) * internalLength + - DeclarationData.BusAuxiliaries.FrontAndRearWindowArea(isDoubleDecker); - ssmInputs.BusSurfaceArea = 2 * (completedVehicle.Length * correctedBusWidth + internalLength * - internalHeight + (isDoubleDecker ? 2.0 : 1.0) * correctedBusWidth * completedVehicle.Height); // use equations sent by Tobias - ssmInputs.BusVolume = (internalLength - correctionLengthDrivetrainVolume) * correctedBusWidth * internalHeight; - - ssmInputs.UValue = DeclarationData.BusAuxiliaries.UValue(completedVehicle.VehicleCode.GetFloorType()); - ssmInputs.NumberOfPassengers = GetNumberOfPassengers( - mission, internalLength, correctedBusWidth, - completedVehicle.NumberPassengerSeatsLowerDeck.Value + completedVehicle.NumberPassengerSeatsUpperDeck.Value, - completedVehicle.NumberPassengersStandingLowerDeck.Value + completedVehicle.NumberPassengersStandingUpperDeck.Value, - loadingType) + 1; // add driver for 'heat input' - ssmInputs.VentilationRate = DeclarationData.BusAuxiliaries.VentilationRate(hvacConfiguration, false); - ssmInputs.VentilationRateHeating = DeclarationData.BusAuxiliaries.VentilationRate(hvacConfiguration, true); - - ssmInputs.HVACMaxCoolingPower = coolingPower.Item1 + coolingPower.Item2; - - //ToDo FK COP calculation - ssmInputs.HVACCompressorType = heatPumpTypePassengerCompartment; // use passenger compartment - ssmInputs.HVACTechnology = $"{busAux.SystemConfiguration.GetName()} " + - $"({string.Join(", ", heatPumpTypePassengerCompartment.GetName(), heatPumpTypeDriverCompartment.GetName())})"; - ssmInputs.COP = DeclarationData.BusAuxiliaries.CalculateCOP( - coolingPower.Item1, heatPumpTypeDriverCompartment, coolingPower.Item2, heatPumpTypePassengerCompartment /* average */, - floorType); - - return ssmInputs; - } +// ssmInputs.BusFloorType = completedVehicle.VehicleCode.GetFloorType(); +// ssmInputs.Technologies = CreateTechnologyBenefits(completedVehicle, primaryVehicle.Components.BusAuxiliaries); +// ssmInputs.FuelFiredHeaterPower = busAux.AuxHeaterPower; +// ssmInputs.BusWindowSurface = DeclarationData.BusAuxiliaries.WindowHeight(isDoubleDecker) * internalLength + +// DeclarationData.BusAuxiliaries.FrontAndRearWindowArea(isDoubleDecker); +// ssmInputs.BusSurfaceArea = 2 * (completedVehicle.Length * correctedBusWidth + internalLength * +// internalHeight + (isDoubleDecker ? 2.0 : 1.0) * correctedBusWidth * completedVehicle.Height); // use equations sent by Tobias +// ssmInputs.BusVolume = (internalLength - correctionLengthDrivetrainVolume) * correctedBusWidth * internalHeight; + +// ssmInputs.UValue = DeclarationData.BusAuxiliaries.UValue(completedVehicle.VehicleCode.GetFloorType()); +// ssmInputs.NumberOfPassengers = GetNumberOfPassengers( +// mission, internalLength, correctedBusWidth, +// completedVehicle.NumberPassengerSeatsLowerDeck.Value + completedVehicle.NumberPassengerSeatsUpperDeck.Value, +// completedVehicle.NumberPassengersStandingLowerDeck.Value + completedVehicle.NumberPassengersStandingUpperDeck.Value, +// loadingType) + 1; // add driver for 'heat input' +// ssmInputs.VentilationRate = DeclarationData.BusAuxiliaries.VentilationRate(hvacConfiguration, false); +// ssmInputs.VentilationRateHeating = DeclarationData.BusAuxiliaries.VentilationRate(hvacConfiguration, true); + +// ssmInputs.HVACMaxCoolingPower = coolingPower.Item1 + coolingPower.Item2; + +// //ToDo FK COP calculation +// ssmInputs.HVACCompressorType = heatPumpTypePassengerCompartment; // use passenger compartment +// ssmInputs.HVACTechnology = $"{busAux.SystemConfiguration.GetName()} " + +// $"({string.Join(", ", heatPumpTypePassengerCompartment.GetName(), heatPumpTypeDriverCompartment.GetName())})"; +// ssmInputs.COP = DeclarationData.BusAuxiliaries.CalculateCOP( +// coolingPower.Item1, heatPumpTypeDriverCompartment, coolingPower.Item2, heatPumpTypePassengerCompartment /* average */, +// floorType); + +// return ssmInputs; +// } - public TechnologyBenefits CreateTechnologyBenefits(IVehicleDeclarationInputData completedVehicle, - IBusAuxiliariesDeclarationData primaryBusAux) - { - var onVehicle = new List<SSMTechnology>(); - var completedBuxAux = completedVehicle.Components.BusAuxiliaries; +// public TechnologyBenefits CreateTechnologyBenefits(IVehicleDeclarationInputData completedVehicle, +// IBusAuxiliariesDeclarationData primaryBusAux) +// { +// var onVehicle = new List<SSMTechnology>(); +// var completedBuxAux = completedVehicle.Components.BusAuxiliaries; - foreach (var item in DeclarationData.BusAuxiliaries.SSMTechnologyList) - { - if ("Double-glazing".Equals(item.BenefitName, StringComparison.InvariantCultureIgnoreCase) && - (completedBuxAux?.HVACAux.DoubleGlazing ?? false)) - { - onVehicle.Add(item); - } - if ("Adjustable auxiliary heater".Equals(item.BenefitName, StringComparison.InvariantCultureIgnoreCase) && - (completedBuxAux?.HVACAux.AdjustableAuxiliaryHeater ?? false)) - { - onVehicle.Add(item); - } - if ("Separate air distribution ducts".Equals(item.BenefitName, StringComparison.InvariantCultureIgnoreCase) && - (completedBuxAux?.HVACAux.SeparateAirDistributionDucts ?? false)) - { - onVehicle.Add(item); - } - if ("Adjustable coolant thermostat".Equals(item.BenefitName, StringComparison.InvariantCultureIgnoreCase) && - (primaryBusAux?.HVACAux.AdjustableCoolantThermostat ?? false)) - { - onVehicle.Add(item); - } - if ("Engine waste gas heat exchanger".Equals(item.BenefitName, StringComparison.InvariantCultureIgnoreCase) && - (primaryBusAux?.HVACAux.EngineWasteGasHeatExchanger ?? false)) - { - onVehicle.Add(item); - } - } - - return SelectBenefitForFloorType(completedVehicle.VehicleCode.GetFloorType(), onVehicle); - } +// foreach (var item in DeclarationData.BusAuxiliaries.SSMTechnologyList) +// { +// if ("Double-glazing".Equals(item.BenefitName, StringComparison.InvariantCultureIgnoreCase) && +// (completedBuxAux?.HVACAux.DoubleGlazing ?? false)) +// { +// onVehicle.Add(item); +// } +// if ("Adjustable auxiliary heater".Equals(item.BenefitName, StringComparison.InvariantCultureIgnoreCase) && +// (completedBuxAux?.HVACAux.AdjustableAuxiliaryHeater ?? false)) +// { +// onVehicle.Add(item); +// } +// if ("Separate air distribution ducts".Equals(item.BenefitName, StringComparison.InvariantCultureIgnoreCase) && +// (completedBuxAux?.HVACAux.SeparateAirDistributionDucts ?? false)) +// { +// onVehicle.Add(item); +// } +// if ("Adjustable coolant thermostat".Equals(item.BenefitName, StringComparison.InvariantCultureIgnoreCase) && +// (primaryBusAux?.HVACAux.AdjustableCoolantThermostat ?? false)) +// { +// onVehicle.Add(item); +// } +// if ("Engine waste gas heat exchanger".Equals(item.BenefitName, StringComparison.InvariantCultureIgnoreCase) && +// (primaryBusAux?.HVACAux.EngineWasteGasHeatExchanger ?? false)) +// { +// onVehicle.Add(item); +// } +// } + +// return SelectBenefitForFloorType(completedVehicle.VehicleCode.GetFloorType(), onVehicle); +// } - protected override Tuple<Watt, Watt> CalculateMaxCoolingPower(IVehicleDeclarationInputData completedVehicle, IVehicleDeclarationInputData primaryVehicle, - Mission mission) - { - var hvacConfiguration = completedVehicle.Components.BusAuxiliaries.HVACAux.SystemConfiguration; - if (!hvacConfiguration.HasValue || hvacConfiguration.IsOneOf(BusHVACSystemConfiguration.Configuration0, BusHVACSystemConfiguration.Unknown )) { - throw new VectoException( - $"HVAC Configuration {hvacConfiguration.ToXmlFormat()} is invalid for final step"); - } - - var correctionLengthDrivetrainVolume = DeclarationData.BusAuxiliaries.CorrectionLengthDrivetrainVolume( - completedVehicle.VehicleCode, completedVehicle.LowEntry, primaryVehicle.AxleConfiguration.NumAxles(), - primaryVehicle.Articulated); - - var pasengerCompartmentLength = DeclarationData.BusAuxiliaries.CalculateInternalLength( - completedVehicle.Length , completedVehicle.VehicleCode, - (int)completedVehicle.NumberPassengerSeatsLowerDeck) - Constants.BusParameters.DriverCompartmentLength - correctionLengthDrivetrainVolume; +// protected override Tuple<Watt, Watt> CalculateMaxCoolingPower(IVehicleDeclarationInputData completedVehicle, IVehicleDeclarationInputData primaryVehicle, +// Mission mission) +// { +// var hvacConfiguration = completedVehicle.Components.BusAuxiliaries.HVACAux.SystemConfiguration; +// if (!hvacConfiguration.HasValue || hvacConfiguration.IsOneOf(BusHVACSystemConfiguration.Configuration0, BusHVACSystemConfiguration.Unknown )) { +// throw new VectoException( +// $"HVAC Configuration {hvacConfiguration.ToXmlFormat()} is invalid for final step"); +// } + +// var correctionLengthDrivetrainVolume = DeclarationData.BusAuxiliaries.CorrectionLengthDrivetrainVolume( +// completedVehicle.VehicleCode, completedVehicle.LowEntry, primaryVehicle.AxleConfiguration.NumAxles(), +// primaryVehicle.Articulated); + +// var pasengerCompartmentLength = DeclarationData.BusAuxiliaries.CalculateInternalLength( +// completedVehicle.Length , completedVehicle.VehicleCode, +// (int)completedVehicle.NumberPassengerSeatsLowerDeck) - Constants.BusParameters.DriverCompartmentLength - correctionLengthDrivetrainVolume; - var internalHeight = DeclarationData.BusAuxiliaries.CalculateInternalHeight(completedVehicle.VehicleCode, completedVehicle.RegisteredClass, completedVehicle.Height); - var volume = pasengerCompartmentLength * internalHeight * completedVehicle.Width; +// var internalHeight = DeclarationData.BusAuxiliaries.CalculateInternalHeight(completedVehicle.VehicleCode, completedVehicle.RegisteredClass, completedVehicle.Height); +// var volume = pasengerCompartmentLength * internalHeight * completedVehicle.Width; - var driver = DeclarationData.BusAuxiliaries.HVACMaxCoolingPower.DriverMaxCoolingPower( - hvacConfiguration, mission.MissionType); - var passenger = DeclarationData.BusAuxiliaries.HVACMaxCoolingPower.PassengerMaxCoolingPower( - hvacConfiguration, mission.MissionType, volume); +// var driver = DeclarationData.BusAuxiliaries.HVACMaxCoolingPower.DriverMaxCoolingPower( +// hvacConfiguration, mission.MissionType); +// var passenger = DeclarationData.BusAuxiliaries.HVACMaxCoolingPower.PassengerMaxCoolingPower( +// hvacConfiguration, mission.MissionType, volume); - return Tuple.Create(driver, passenger); - } +// return Tuple.Create(driver, passenger); +// } - #region Avarage Current Demand Calculation +// #region Avarage Current Demand Calculation - protected override bool VehicleHasElectricalConsumer(string consumerName, IBusAuxiliariesDeclarationData busAux) - { - if (consumerName == "Day running lights LED bonus" && (bool)busAux.ElectricConsumers.DayrunninglightsLED) - return true; - if (consumerName == "Position lights LED bonus" && (bool)busAux.ElectricConsumers.PositionlightsLED) - return true; - if (consumerName == "Brake lights LED bonus" && (bool)busAux.ElectricConsumers.BrakelightsLED) - return true; - if (consumerName == "Interior lights LED bonus" && (bool)busAux.ElectricConsumers.InteriorLightsLED) - return true; - if (consumerName == "Headlights LED bonus" && (bool)busAux.ElectricConsumers.HeadlightsLED) - return true; +// protected override bool VehicleHasElectricalConsumer(string consumerName, IBusAuxiliariesDeclarationData busAux) +// { +// if (consumerName == "Day running lights LED bonus" && (bool)busAux.ElectricConsumers.DayrunninglightsLED) +// return true; +// if (consumerName == "Position lights LED bonus" && (bool)busAux.ElectricConsumers.PositionlightsLED) +// return true; +// if (consumerName == "Brake lights LED bonus" && (bool)busAux.ElectricConsumers.BrakelightsLED) +// return true; +// if (consumerName == "Interior lights LED bonus" && (bool)busAux.ElectricConsumers.InteriorLightsLED) +// return true; +// if (consumerName == "Headlights LED bonus" && (bool)busAux.ElectricConsumers.HeadlightsLED) +// return true; - return false; - } +// return false; +// } - protected override double CalculateLengthDependentElectricalConsumers(Mission mission, IVehicleDeclarationInputData vehicleData) - { - var busParams = mission.BusParameter; - return DeclarationData.BusAuxiliaries.CalculateLengthInteriorLights( - vehicleData.Length, vehicleData.VehicleCode, busParams.NumberPassengersLowerDeck) - .Value(); - } +// protected override double CalculateLengthDependentElectricalConsumers(Mission mission, IVehicleDeclarationInputData vehicleData) +// { +// var busParams = mission.BusParameter; +// return DeclarationData.BusAuxiliaries.CalculateLengthInteriorLights( +// vehicleData.Length, vehicleData.VehicleCode, busParams.NumberPassengersLowerDeck) +// .Value(); +// } - #endregion +// #endregion - protected double GetNumberOfPassengers(Mission mission, Meter length, Meter width, double registeredPassengerSeats, - double registeredPassengersStanding, LoadingType loading) - { - var busFloorArea = DeclarationData.BusAuxiliaries.CalculateBusFloorSurfaceArea(length, width); - var passengerCountRef = busFloorArea * (loading == LoadingType.LowLoading - ? mission.BusParameter.PassengerDensityLow - : mission.BusParameter.PassengerDensityRef); +// protected double GetNumberOfPassengers(Mission mission, Meter length, Meter width, double registeredPassengerSeats, +// double registeredPassengersStanding, LoadingType loading) +// { +// var busFloorArea = DeclarationData.BusAuxiliaries.CalculateBusFloorSurfaceArea(length, width); +// var passengerCountRef = busFloorArea * (loading == LoadingType.LowLoading +// ? mission.BusParameter.PassengerDensityLow +// : mission.BusParameter.PassengerDensityRef); - if (loading != LoadingType.ReferenceLoad && loading != LoadingType.LowLoading) { - throw new VectoException("Unhandled loading type: {0}", loading); - } +// if (loading != LoadingType.ReferenceLoad && loading != LoadingType.LowLoading) { +// throw new VectoException("Unhandled loading type: {0}", loading); +// } - var passengerCount = registeredPassengerSeats + - (mission.MissionType == MissionType.Coach ? 0 : registeredPassengersStanding); +// var passengerCount = registeredPassengerSeats + +// (mission.MissionType == MissionType.Coach ? 0 : registeredPassengersStanding); - return loading == LoadingType.ReferenceLoad - ? VectoMath.Min(passengerCountRef, passengerCount) - : VectoMath.Min(passengerCountRef * mission.MissionType.GetLowLoadFactorBus(), passengerCount); - } +// return loading == LoadingType.ReferenceLoad +// ? VectoMath.Min(passengerCountRef, passengerCount) +// : VectoMath.Min(passengerCountRef * mission.MissionType.GetLowLoadFactorBus(), passengerCount); +// } - } -} +// } +//} diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterMultistageBus.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterMultistageBus.cs index 45f045e6f4807422299308d2936e76e721fbe85e..b3e50f53b70d0b3aac9928978b51b0aeb2b3701d 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterMultistageBus.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterMultistageBus.cs @@ -1,74 +1,74 @@ -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.Models.BusAuxiliaries; -using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics; -using TUGraz.VectoCore.Models.Declaration; -using TUGraz.VectoCore.Models.Simulation.Data; +//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.Models.BusAuxiliaries; +//using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics; +//using TUGraz.VectoCore.Models.Declaration; +//using TUGraz.VectoCore.Models.Simulation.Data; -namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter -{ - public class DeclarationDataAdapterMultistageBus : DeclarationDataAdapterCompletedBusSpecific - { +//namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +//{ +// public class DeclarationDataAdapterMultistageBus : DeclarationDataAdapterCompletedBusSpecific +// { - public override IAuxiliaryConfig CreateBusAuxiliariesData(Mission mission, - IVehicleDeclarationInputData primaryVehicle, IVehicleDeclarationInputData completedVehicle, - VectoRunData runData) - { - var actuations = DeclarationData.BusAuxiliaries.ActuationsMap.Lookup(runData.Mission.MissionType); - var primaryBusAuxiliaries = primaryVehicle.Components.BusAuxiliaries; +// public override IAuxiliaryConfig CreateBusAuxiliariesData(Mission mission, +// IVehicleDeclarationInputData primaryVehicle, IVehicleDeclarationInputData completedVehicle, +// VectoRunData runData) +// { +// var actuations = DeclarationData.BusAuxiliaries.ActuationsMap.Lookup(runData.Mission.MissionType); +// var primaryBusAuxiliaries = primaryVehicle.Components.BusAuxiliaries; - return new AuxiliaryConfig - { - InputData = completedVehicle.Components.BusAuxiliaries, - ElectricalUserInputsConfig = CreateElectricsUserInputsConfig( - primaryVehicle, completedVehicle, mission, actuations, runData.VehicleData.VehicleClass), - PneumaticUserInputsConfig = CreatePneumaticUserInputsConfig( - primaryBusAuxiliaries, completedVehicle), - PneumaticAuxillariesConfig = CreatePneumaticAuxConfig(runData.Retarder.Type), - Actuations = actuations, - SSMInputs = GetCompletedSSMInput(mission, completedVehicle, primaryVehicle, runData.Loading), - VehicleData = runData.VehicleData - }; - } +// return new AuxiliaryConfig +// { +// InputData = completedVehicle.Components.BusAuxiliaries, +// ElectricalUserInputsConfig = CreateElectricsUserInputsConfig( +// primaryVehicle, completedVehicle, mission, actuations, runData.VehicleData.VehicleClass), +// PneumaticUserInputsConfig = CreatePneumaticUserInputsConfig( +// primaryBusAuxiliaries, completedVehicle), +// PneumaticAuxillariesConfig = CreatePneumaticAuxConfig(runData.Retarder.Type), +// Actuations = actuations, +// SSMInputs = GetCompletedSSMInput(mission, completedVehicle, primaryVehicle, runData.Loading), +// VehicleData = runData.VehicleData +// }; +// } - protected override ElectricsUserInputsConfig CreateElectricsUserInputsConfig(IVehicleDeclarationInputData primaryVehicle, - IVehicleDeclarationInputData completedVehicle, Mission mission, IActuations actuations, VehicleClass vehicleClass) - { - var currentDemand = GetElectricConsumers(mission, completedVehicle, actuations, vehicleClass); +// protected override ElectricsUserInputsConfig CreateElectricsUserInputsConfig(IVehicleDeclarationInputData primaryVehicle, +// IVehicleDeclarationInputData completedVehicle, Mission mission, IActuations actuations, VehicleClass 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)) - { - currentDemand[entry.Key] = entry.Value; - } +// // add electrical steering pump or electric fan defined in primary vehicle +// foreach (var entry in GetElectricAuxConsumersPrimary(mission, completedVehicle, vehicleClass, primaryVehicle.Components.BusAuxiliaries)) +// { +// currentDemand[entry.Key] = entry.Value; +// } - var retVal = GetDefaultElectricalUserConfig(); +// var retVal = GetDefaultElectricalUserConfig(); - var primaryBusAuxiliaries = primaryVehicle.Components.BusAuxiliaries; - retVal.AlternatorType = primaryVehicle.VehicleType == VectoSimulationJobType.BatteryElectricVehicle - ? AlternatorType.None - : primaryBusAuxiliaries.ElectricSupply.AlternatorTechnology; - retVal.ElectricalConsumers = currentDemand; +// var primaryBusAuxiliaries = primaryVehicle.Components.BusAuxiliaries; +// retVal.AlternatorType = primaryVehicle.VehicleType == VectoSimulationJobType.BatteryElectricVehicle +// ? AlternatorType.None +// : primaryBusAuxiliaries.ElectricSupply.AlternatorTechnology; +// retVal.ElectricalConsumers = currentDemand; - retVal.AlternatorMap = new SimpleAlternator( - CalculateAlternatorEfficiency(primaryBusAuxiliaries.ElectricSupply.Alternators)); +// retVal.AlternatorMap = new SimpleAlternator( +// CalculateAlternatorEfficiency(primaryBusAuxiliaries.ElectricSupply.Alternators)); - switch (retVal.AlternatorType) { - case AlternatorType.Smart when primaryBusAuxiliaries.ElectricSupply.Alternators.Count == 0: - throw new VectoException("at least one alternator is required when specifying smart electrics!"); - case AlternatorType.Smart when primaryBusAuxiliaries.ElectricSupply.ElectricStorage.Count == 0: - throw new VectoException("at least one electric storage (battery or capacitor) is required when specifying smart electrics!"); - } +// switch (retVal.AlternatorType) { +// case AlternatorType.Smart when primaryBusAuxiliaries.ElectricSupply.Alternators.Count == 0: +// throw new VectoException("at least one alternator is required when specifying smart electrics!"); +// case AlternatorType.Smart when primaryBusAuxiliaries.ElectricSupply.ElectricStorage.Count == 0: +// throw new VectoException("at least one electric storage (battery or capacitor) is required when specifying smart electrics!"); +// } - retVal.MaxAlternatorPower = primaryBusAuxiliaries.ElectricSupply.Alternators.Sum(x => x.RatedVoltage * x.RatedCurrent); - retVal.ElectricStorageCapacity = primaryBusAuxiliaries.ElectricSupply.ElectricStorage.Sum(x => x.ElectricStorageCapacity) ?? 0.SI<WattSecond>(); +// retVal.MaxAlternatorPower = primaryBusAuxiliaries.ElectricSupply.Alternators.Sum(x => x.RatedVoltage * x.RatedCurrent); +// retVal.ElectricStorageCapacity = primaryBusAuxiliaries.ElectricSupply.ElectricStorage.Sum(x => x.ElectricStorageCapacity) ?? 0.SI<WattSecond>(); - return retVal; - } - } -} +// return retVal; +// } +// } +//} diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterNinjectModule.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterNinjectModule.cs index b385e7f8271ea9655c089dae4bbcb70efafc0957..09d8deba2528ace64c77e267afad860d5129fb1d 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterNinjectModule.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterNinjectModule.cs @@ -1,9 +1,14 @@ -using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.CompletedBus.Generic; +using Ninject.Extensions.Factory; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +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.Impl.DeclarationMode.CompletedBusRunDataFactory; using TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDataFactory; using TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.PrimaryBusRunDataFactory; +using TUGraz.VectoCore.Utils.Ninject; namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter { @@ -11,228 +16,291 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter { #region Overrides of NinjectModule + private VehicleTypeAndArchitectureStringHelperRundata _vehicleStringHelper = + new VehicleTypeAndArchitectureStringHelperRundata(); public override void Load() { #region HeavyLorry - Bind<IDeclarationDataAdapter>().To<HeavyLorry.DeclarationDataAdapterHeavyLorry.Conventional>() + Bind<ILorryDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.Conventional>() .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.Conventional>(); - Bind<IDeclarationDataAdapter>().To<HeavyLorry.DeclarationDataAdapterHeavyLorry.HEV_S2>() + Bind<ILorryDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_S2>() .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_S2>(); - Bind<IDeclarationDataAdapter>().To<HeavyLorry.DeclarationDataAdapterHeavyLorry.HEV_S3>() + Bind<ILorryDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_S3>() .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_S3>(); - Bind<IDeclarationDataAdapter>().To<HeavyLorry.DeclarationDataAdapterHeavyLorry.HEV_S4>() + Bind<ILorryDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_S4>() .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_S4>(); - Bind<IDeclarationDataAdapter>().To<HeavyLorry.DeclarationDataAdapterHeavyLorry.HEV_S_IEPC>() + Bind<ILorryDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_S_IEPC>() .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_S_IEPC>(); - Bind<IDeclarationDataAdapter>().To<HeavyLorry.DeclarationDataAdapterHeavyLorry.HEV_P1>() + Bind<ILorryDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_P1>() .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_P1>(); - Bind<IDeclarationDataAdapter>().To<HeavyLorry.DeclarationDataAdapterHeavyLorry.HEV_P2>() + Bind<ILorryDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_P2>() .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_P2>(); - Bind<IDeclarationDataAdapter>().To<HeavyLorry.DeclarationDataAdapterHeavyLorry.HEV_P2_5>() + Bind<ILorryDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_P2_5>() .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_P2_5>(); - Bind<IDeclarationDataAdapter>().To<HeavyLorry.DeclarationDataAdapterHeavyLorry.HEV_P3>() + Bind<ILorryDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_P3>() .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_P3>(); - Bind<IDeclarationDataAdapter>().To<HeavyLorry.DeclarationDataAdapterHeavyLorry.HEV_P4>() + Bind<ILorryDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_P4>() .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.HEV_P4>(); - Bind<IDeclarationDataAdapter>().To<HeavyLorry.DeclarationDataAdapterHeavyLorry.PEV_E2>() + Bind<ILorryDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.PEV_E2>() .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.PEV_E2>(); - Bind<IDeclarationDataAdapter>().To<HeavyLorry.DeclarationDataAdapterHeavyLorry.PEV_E3>() + Bind<ILorryDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.PEV_E3>() .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.PEV_E3>(); - Bind<IDeclarationDataAdapter>().To<HeavyLorry.DeclarationDataAdapterHeavyLorry.PEV_E4>() + Bind<ILorryDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.PEV_E4>() .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.PEV_E4>(); - Bind<IDeclarationDataAdapter>().To<HeavyLorry.DeclarationDataAdapterHeavyLorry.PEV_E_IEPC>() + Bind<ILorryDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.PEV_E_IEPC>() .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.PEV_E_IEPC>(); - Bind<IDeclarationDataAdapter>().To<HeavyLorry.DeclarationDataAdapterHeavyLorry.Exempted>() + Bind<ILorryDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.Exempted>() .WhenInjectedExactlyInto<DeclarationModeHeavyLorryRunDataFactory.Exempted>(); #endregion HeavyLorry #region PrimaryBus - Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.Conventional>() + Bind<IPrimaryBusDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.Conventional>() .WhenInjectedExactlyInto<DeclarationModePrimaryBusRunDataFactory.Conventional>(); - Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_S2>() + Bind<IPrimaryBusDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_S2>() .WhenInjectedExactlyInto<DeclarationModePrimaryBusRunDataFactory.HEV_S2>(); - Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_S3>() + Bind<IPrimaryBusDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_S3>() .WhenInjectedExactlyInto<DeclarationModePrimaryBusRunDataFactory.HEV_S3>(); - Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_S4>() + Bind<IPrimaryBusDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_S4>() .WhenInjectedExactlyInto<DeclarationModePrimaryBusRunDataFactory.HEV_S4>(); - Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_S_IEPC>() + Bind<IPrimaryBusDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_S_IEPC>() .WhenInjectedExactlyInto<DeclarationModePrimaryBusRunDataFactory.HEV_S_IEPC>(); - Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_P1>() + Bind<IPrimaryBusDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_P1>() .WhenInjectedExactlyInto<DeclarationModePrimaryBusRunDataFactory.HEV_P1>(); - Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_P2>() + Bind<IPrimaryBusDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_P2>() .WhenInjectedExactlyInto<DeclarationModePrimaryBusRunDataFactory.HEV_P2>(); - Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_P2_5>() + Bind<IPrimaryBusDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_P2_5>() .WhenInjectedExactlyInto<DeclarationModePrimaryBusRunDataFactory.HEV_P2_5>(); - Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_P3>() + Bind<IPrimaryBusDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_P3>() .WhenInjectedExactlyInto<DeclarationModePrimaryBusRunDataFactory.HEV_P3>(); - Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_P4>() + Bind<IPrimaryBusDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.HEV_P4>() .WhenInjectedExactlyInto<DeclarationModePrimaryBusRunDataFactory.HEV_P4>(); - Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.PEV_E2>() + Bind<IPrimaryBusDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.PEV_E2>() .WhenInjectedExactlyInto<DeclarationModePrimaryBusRunDataFactory.PEV_E2>(); - Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.PEV_E3>() + Bind<IPrimaryBusDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.PEV_E3>() .WhenInjectedExactlyInto<DeclarationModePrimaryBusRunDataFactory.PEV_E3>(); - Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.PEV_E4>() + Bind<IPrimaryBusDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.PEV_E4>() .WhenInjectedExactlyInto<DeclarationModePrimaryBusRunDataFactory.PEV_E4>(); - Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.PEV_E_IEPC>() + Bind<IPrimaryBusDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.PEV_E_IEPC>() .WhenInjectedExactlyInto<DeclarationModePrimaryBusRunDataFactory.PEV_E_IEPC>(); - Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.Exempted>() + Bind<IPrimaryBusDeclarationDataAdapter>().To<DeclarationDataAdapterPrimaryBus.Exempted>() .WhenInjectedExactlyInto<DeclarationModePrimaryBusRunDataFactory.Exempted>(); #endregion #region CompletedBus Generic - Bind<IGenericCompletedBusDataAdapter>() - .To<DeclarationDataAdapterGenericCompletedBus.Conventional>() + Bind<IGenericCompletedBusDeclarationDataAdapter>() + .To<DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.Conventional>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.Conventional>(); - Bind<IGenericCompletedBusDataAdapter>() - .To<DeclarationDataAdapterGenericCompletedBus.HEV_S2>() + Bind<IGenericCompletedBusDeclarationDataAdapter>() + .To<DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_S2>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_S2>(); - Bind<IGenericCompletedBusDataAdapter>() - .To<DeclarationDataAdapterGenericCompletedBus.HEV_S3>() + Bind<IGenericCompletedBusDeclarationDataAdapter>() + .To<DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_S3>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_S3>(); - Bind<IGenericCompletedBusDataAdapter>() - .To<DeclarationDataAdapterGenericCompletedBus.HEV_S4>() + Bind<IGenericCompletedBusDeclarationDataAdapter>() + .To<DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_S4>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_S4>(); - Bind<IGenericCompletedBusDataAdapter>() - .To<DeclarationDataAdapterGenericCompletedBus.HEV_S_IEPC>() + Bind<IGenericCompletedBusDeclarationDataAdapter>() + .To<DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_S_IEPC>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_S4>(); - Bind<IGenericCompletedBusDataAdapter>() - .To<DeclarationDataAdapterGenericCompletedBus.HEV_P1>() + Bind<IGenericCompletedBusDeclarationDataAdapter>() + .To<DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_P1>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_P1>(); - Bind<IGenericCompletedBusDataAdapter>() - .To<DeclarationDataAdapterGenericCompletedBus.HEV_P2>() + Bind<IGenericCompletedBusDeclarationDataAdapter>() + .To<DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_P2>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_P2>(); - Bind<IGenericCompletedBusDataAdapter>() - .To<DeclarationDataAdapterGenericCompletedBus.HEV_P2_5>() + Bind<IGenericCompletedBusDeclarationDataAdapter>() + .To<DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_P2_5>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_P2_5>(); - Bind<IGenericCompletedBusDataAdapter>() - .To<DeclarationDataAdapterGenericCompletedBus.HEV_P3>() + Bind<IGenericCompletedBusDeclarationDataAdapter>() + .To<DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_P3>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_P3>(); - Bind<IGenericCompletedBusDataAdapter>() - .To<DeclarationDataAdapterGenericCompletedBus.HEV_P4>() + Bind<IGenericCompletedBusDeclarationDataAdapter>() + .To<DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_P4>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_P4>(); - Bind<IGenericCompletedBusDataAdapter>() - .To<DeclarationDataAdapterGenericCompletedBus.PEV_E2>() + Bind<IGenericCompletedBusDeclarationDataAdapter>() + .To<DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.PEV_E2>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.PEV_E2>(); - Bind<IGenericCompletedBusDataAdapter>() - .To<DeclarationDataAdapterGenericCompletedBus.PEV_E3>() + Bind<IGenericCompletedBusDeclarationDataAdapter>() + .To<DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.PEV_E3>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.PEV_E3>(); - Bind<IGenericCompletedBusDataAdapter>() - .To<DeclarationDataAdapterGenericCompletedBus.PEV_E4>() + Bind<IGenericCompletedBusDeclarationDataAdapter>() + .To<DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.PEV_E4>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.PEV_E4>(); - Bind<IGenericCompletedBusDataAdapter>() - .To<DeclarationDataAdapterGenericCompletedBus.PEV_E_IEPC>() + Bind<IGenericCompletedBusDeclarationDataAdapter>() + .To<DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.PEV_E_IEPC>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.PEV_E_IEPC>(); #endregion #region CompletedBus Specific - Bind<ISpecificCompletedBusDataAdapter>() + Bind<ISpecificCompletedBusDeclarationDataAdapter>() .To<DeclarationDataAdapterSpecificCompletedBus.Conventional>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.Conventional>(); - Bind<ISpecificCompletedBusDataAdapter>() + Bind<ISpecificCompletedBusDeclarationDataAdapter>() .To<DeclarationDataAdapterSpecificCompletedBus.HEV_S2>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_S2>(); - Bind<ISpecificCompletedBusDataAdapter>() + Bind<ISpecificCompletedBusDeclarationDataAdapter>() .To<DeclarationDataAdapterSpecificCompletedBus.HEV_S3>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_S3>(); - Bind<ISpecificCompletedBusDataAdapter>() + Bind<ISpecificCompletedBusDeclarationDataAdapter>() .To<DeclarationDataAdapterSpecificCompletedBus.HEV_S4>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_S4>(); - Bind<ISpecificCompletedBusDataAdapter>() + Bind<ISpecificCompletedBusDeclarationDataAdapter>() .To<DeclarationDataAdapterSpecificCompletedBus.HEV_S_IEPC>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_S4>(); - Bind<ISpecificCompletedBusDataAdapter>() + Bind<ISpecificCompletedBusDeclarationDataAdapter>() .To<DeclarationDataAdapterSpecificCompletedBus.HEV_P1>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_P1>(); - Bind<ISpecificCompletedBusDataAdapter>() + Bind<ISpecificCompletedBusDeclarationDataAdapter>() .To<DeclarationDataAdapterSpecificCompletedBus.HEV_P2>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_P2>(); - Bind<ISpecificCompletedBusDataAdapter>() + Bind<ISpecificCompletedBusDeclarationDataAdapter>() .To<DeclarationDataAdapterSpecificCompletedBus.HEV_P2_5>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_P2_5>(); - Bind<ISpecificCompletedBusDataAdapter>() + Bind<ISpecificCompletedBusDeclarationDataAdapter>() .To<DeclarationDataAdapterSpecificCompletedBus.HEV_P3>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_P3>(); - Bind<ISpecificCompletedBusDataAdapter>() + Bind<ISpecificCompletedBusDeclarationDataAdapter>() .To<DeclarationDataAdapterSpecificCompletedBus.HEV_P4>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.HEV_P4>(); - Bind<ISpecificCompletedBusDataAdapter>() + Bind<ISpecificCompletedBusDeclarationDataAdapter>() .To<DeclarationDataAdapterSpecificCompletedBus.PEV_E2>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.PEV_E2>(); - Bind<ISpecificCompletedBusDataAdapter>() + Bind<ISpecificCompletedBusDeclarationDataAdapter>() .To<DeclarationDataAdapterSpecificCompletedBus.PEV_E3>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.PEV_E3>(); - Bind<ISpecificCompletedBusDataAdapter>() + Bind<ISpecificCompletedBusDeclarationDataAdapter>() .To<DeclarationDataAdapterSpecificCompletedBus.PEV_E4>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.PEV_E4>(); - Bind<ISpecificCompletedBusDataAdapter>() + Bind<ISpecificCompletedBusDeclarationDataAdapter>() .To<DeclarationDataAdapterSpecificCompletedBus.PEV_E_IEPC>() .WhenInjectedExactlyInto<DeclarationModeCompletedBusRunDataFactory.PEV_E_IEPC>(); - #endregion - } + #endregion + + + #region Factory + + //Bind<IDeclarationDataAdapterFactory>().ToFactory(() => new CombineArgumentsToNameInstanceProvider( + // new CombineArgumentsToNameInstanceProvider.MethodSettings() { + // combineToNameDelegate = _vehicleStringHelper.CreateName, + // methods = new[] { + // typeof(IDeclarationDataAdapterFactory).GetMethod(nameof(IDeclarationDataAdapterFactory + // .CreateDataAdapter)) + // }, + // skipArguments = 1, + // takeArguments = 1, + // })).InSingletonScope(); + + //Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.Conventional>().Named( + // _vehicleStringHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobType.ConventionalVehicle, + // ArchitectureID.UNKNOWN)); + //Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_S2>().Named( + // _vehicleStringHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobType.SerialHybridVehicle, + // ArchitectureID.S2)); + //Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_S3>().Named( + // _vehicleStringHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobType.SerialHybridVehicle, + // ArchitectureID.S3)); + //Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_S4>().Named( + // _vehicleStringHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobType.SerialHybridVehicle, + // ArchitectureID.S4)); + //Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_S_IEPC>().Named( + // _vehicleStringHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobType.SerialHybridVehicle, + // ArchitectureID.S_IEPC)); + //Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_P1>().Named( + // _vehicleStringHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobType.ParallelHybridVehicle, + // ArchitectureID.P1)); + //Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_P2>().Named( + // _vehicleStringHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobType.ParallelHybridVehicle, + // ArchitectureID.P2)); + //Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_P2_5>().Named( + // _vehicleStringHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobType.ParallelHybridVehicle, + // ArchitectureID.P2_5)); + //Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_P3>().Named( + // _vehicleStringHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobType.ParallelHybridVehicle, + // ArchitectureID.P3)); + //Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.HEV_P4>().Named( + // _vehicleStringHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobType.ParallelHybridVehicle, + // ArchitectureID.P4)); + //Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.PEV_E2>().Named( + // _vehicleStringHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobType.BatteryElectricVehicle, + // ArchitectureID.E2)); + //Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.PEV_E3>().Named( + // _vehicleStringHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobType.BatteryElectricVehicle, + // ArchitectureID.E3)); + //Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.PEV_E4>().Named( + // _vehicleStringHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobType.BatteryElectricVehicle, + // ArchitectureID.E4)); + //Bind<IDeclarationDataAdapter>().To<DeclarationDataAdapterHeavyLorry.PEV_E_IEPC>().Named( + // _vehicleStringHelper.GetName(VehicleCategoryHelper.Lorry, VectoSimulationJobType.BatteryElectricVehicle, + // ArchitectureID.E_IEPC)); + + + + #endregion + } - #endregion - } + #endregion + } } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterSingleBus.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterSingleBus.cs index cfa10bb5d2d9e53cdb1f8a26363d5e3a2c5054e7..fab794882b7c911dc320c3f70f5897275d898560 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterSingleBus.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapterSingleBus.cs @@ -1,159 +1,159 @@ -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; - } -} +//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/HeavyLorry/DeclarationDataAdapterHeavyLorry.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/DeclarationDataAdapterHeavyLorry.cs index a7ce233f9a9bf2a141c94136233d08b37210a7da..2c4de96055426fa58bf4dbead952c23d7664247e 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/DeclarationDataAdapterHeavyLorry.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/DeclarationDataAdapterHeavyLorry.cs @@ -50,15 +50,15 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.HeavyLorry { - public partial class DeclarationDataAdapterHeavyLorry : AbstractSimulationDataAdapter, IDeclarationDataAdapter + public partial class DeclarationDataAdapterHeavyLorry { - public abstract class LorryBase : AbstractSimulationDataAdapter, IDeclarationDataAdapter + public abstract class LorryBase : AbstractSimulationDataAdapter, ILorryDeclarationDataAdapter { #region Implementation of IDeclarationDataAdapter private readonly IDriverDataAdapter _driverDataAdapter = new LorryDriverDataAdapter(); protected readonly IVehicleDataAdapter _vehicleDataAdapter = new LorryVehicleDataAdapter(); - private readonly IAxleGearDataAdapter _axleGearDataAdapter = new AxleGearDataAdapterBase(); + private readonly IAxleGearDataAdapter _axleGearDataAdapter = new AxleGearDataAdapter(); private readonly IRetarderDataAdapter _retarderDataAdapter = new RetarderDataAdapter(); private readonly IAirdragDataAdapter _airdragDataAdapter = new AirdragDataAdapter(); private readonly IPTODataAdapter _ptoDataAdapter = new PTODataAdapterLorry(); @@ -144,25 +144,12 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.HeavyLorry return _engineDataAdapter.CreateEngineData(vehicle, mode, mission); } - - - public GearboxData CreateGearboxData(IVehicleDeclarationInputData inputData, VectoRunData runData, + public override GearboxData CreateGearboxData(IVehicleDeclarationInputData inputData, VectoRunData runData, IShiftPolygonCalculator shiftPolygonCalc) { return _gearboxDataAdapter.CreateGearboxData(inputData, runData, shiftPolygonCalc, SupportedGearboxTypes); } - protected virtual TorqueConverterData CreateTorqueConverterData(GearboxType gearboxType, - ITorqueConverterDeclarationInputData torqueConverter, double ratio, - CombustionEngineData componentsEngineInputData) - { - return TorqueConverterDataReader.Create( - torqueConverter.TCData, - DeclarationData.TorqueConverter.ReferenceRPM, DeclarationData.TorqueConverter.MaxInputSpeed, - ExecutionMode.Declaration, ratio, - DeclarationData.TorqueConverter.CLUpshiftMinAcceleration, - DeclarationData.TorqueConverter.CCUpshiftMinAcceleration); - } #region Overrides of LorryBase diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/DeclarationDataAdapterHeavyLorry_old.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/DeclarationDataAdapterHeavyLorry_old.cs index b1e4a78062f81ac1c328edc7f1ab50cd40c19c22..feedd1a6239d64dc5dce515ba7ca4eb313afa269 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/DeclarationDataAdapterHeavyLorry_old.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/HeavyLorry/DeclarationDataAdapterHeavyLorry_old.cs @@ -1,104 +1,104 @@ -using System; -using System.Collections.Generic; -using TUGraz.VectoCommon.InputData; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.InputData.Reader.ComponentData; -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.HeavyLorry -{ - - - - public partial class DeclarationDataAdapterHeavyLorry - { - [Obsolete("Use DeclarationDataAdapterHeavyLorry.Conventional instead, created automatically with NInject")] - public DeclarationDataAdapterHeavyLorry() { } - - private IDeclarationDataAdapter _declarationDataAdapterImplementation = new Conventional(); - public static readonly GearboxType[] SupportedGearboxTypes = Conventional.SupportedGearboxTypes; - - //public static List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> GetDeclarationAirResistanceCurve( - // string parameterSet, SquareMeter si, Meter meter) - //{ - // //return Conventional.GetDeclarationAirResistanceCurve(parameterSet, si, meter); - //} - - #region Implementation of IDeclarationDataAdapter - - public DriverData CreateDriverData() - { - return _declarationDataAdapterImplementation.CreateDriverData(); - } - - public VehicleData CreateVehicleData(IVehicleDeclarationInputData vehicle, Segment segment, Mission mission, - KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) - { - return _declarationDataAdapterImplementation.CreateVehicleData(vehicle, segment, mission, loading, - allowVocational); - } - - public AirdragData CreateAirdragData(IAirdragDeclarationInputData airdragData, Mission mission, Segment segment) - { - return _declarationDataAdapterImplementation.CreateAirdragData(airdragData, mission, segment); - } - - public AxleGearData CreateAxleGearData(IAxleGearInputData axlegearData) - { - return _declarationDataAdapterImplementation.CreateAxleGearData(axlegearData); - } - - public AngledriveData CreateAngledriveData(IAngledriveInputData angledriveData) - { - return _declarationDataAdapterImplementation.CreateAngledriveData(angledriveData); - } - - public CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, - IEngineModeDeclarationInputData engineMode, - Mission mission) - { - return _declarationDataAdapterImplementation.CreateEngineData(vehicle, engineMode, mission); - } - - public GearboxData CreateGearboxData(IVehicleDeclarationInputData inputData, VectoRunData runData, - IShiftPolygonCalculator shiftPolygonCalc) - { - return _declarationDataAdapterImplementation.CreateGearboxData(inputData, runData, shiftPolygonCalc); - } - - public ShiftStrategyParameters CreateGearshiftData(GearboxData gbx, double axleRatio, - PerSecond engineIdlingSpeed) - { - return _declarationDataAdapterImplementation.CreateGearshiftData(gbx, axleRatio, engineIdlingSpeed); - } - - public RetarderData CreateRetarderData(IRetarderInputData retarderData) - { - return _declarationDataAdapterImplementation.CreateRetarderData(retarderData); - } - - public PTOData CreatePTOTransmissionData(IPTOTransmissionInputData ptoData) - { - return _declarationDataAdapterImplementation.CreatePTOTransmissionData(ptoData); - } - - public IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxData, - IBusAuxiliariesDeclarationData busAuxData, - MissionType missionType, VehicleClass vehicleClass, Meter vehicleLength, int? numSteeredAxles) - { - return _declarationDataAdapterImplementation.CreateAuxiliaryData(auxData, busAuxData, missionType, - vehicleClass, vehicleLength, numSteeredAxles); - } - - public AxleGearData CreateDummyAxleGearData(IGearboxDeclarationInputData gbxData) - { - return _declarationDataAdapterImplementation.CreateDummyAxleGearData(gbxData); - } - - #endregion - } -} \ No newline at end of file +//using System; +//using System.Collections.Generic; +//using TUGraz.VectoCommon.InputData; +//using TUGraz.VectoCommon.Models; +//using TUGraz.VectoCommon.Utils; +//using TUGraz.VectoCore.InputData.Reader.ComponentData; +//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.HeavyLorry +//{ + + + +// public partial class DeclarationDataAdapterHeavyLorry +// { +// [Obsolete("Use DeclarationDataAdapterHeavyLorry.Conventional instead, created automatically with NInject")] +// public DeclarationDataAdapterHeavyLorry() { } + +// private IDeclarationDataAdapter _declarationDataAdapterImplementation = new Conventional(); +// public static readonly GearboxType[] SupportedGearboxTypes = Conventional.SupportedGearboxTypes; + +// //public static List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> GetDeclarationAirResistanceCurve( +// // string parameterSet, SquareMeter si, Meter meter) +// //{ +// // //return Conventional.GetDeclarationAirResistanceCurve(parameterSet, si, meter); +// //} + +// #region Implementation of IDeclarationDataAdapter + +// public DriverData CreateDriverData() +// { +// return _declarationDataAdapterImplementation.CreateDriverData(); +// } + +// public VehicleData CreateVehicleData(IVehicleDeclarationInputData vehicle, Segment segment, Mission mission, +// KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) +// { +// return _declarationDataAdapterImplementation.CreateVehicleData(vehicle, segment, mission, loading, +// allowVocational); +// } + +// public AirdragData CreateAirdragData(IAirdragDeclarationInputData airdragData, Mission mission, Segment segment) +// { +// return _declarationDataAdapterImplementation.CreateAirdragData(airdragData, mission, segment); +// } + +// public AxleGearData CreateAxleGearData(IAxleGearInputData axlegearData) +// { +// return _declarationDataAdapterImplementation.CreateAxleGearData(axlegearData); +// } + +// public AngledriveData CreateAngledriveData(IAngledriveInputData angledriveData) +// { +// return _declarationDataAdapterImplementation.CreateAngledriveData(angledriveData); +// } + +// public CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, +// IEngineModeDeclarationInputData engineMode, +// Mission mission) +// { +// return _declarationDataAdapterImplementation.CreateEngineData(vehicle, engineMode, mission); +// } + +// public GearboxData CreateGearboxData(IVehicleDeclarationInputData inputData, VectoRunData runData, +// IShiftPolygonCalculator shiftPolygonCalc) +// { +// return _declarationDataAdapterImplementation.CreateGearboxData(inputData, runData, shiftPolygonCalc); +// } + +// public ShiftStrategyParameters CreateGearshiftData(GearboxData gbx, double axleRatio, +// PerSecond engineIdlingSpeed) +// { +// return _declarationDataAdapterImplementation.CreateGearshiftData(gbx, axleRatio, engineIdlingSpeed); +// } + +// public RetarderData CreateRetarderData(IRetarderInputData retarderData) +// { +// return _declarationDataAdapterImplementation.CreateRetarderData(retarderData); +// } + +// public PTOData CreatePTOTransmissionData(IPTOTransmissionInputData ptoData) +// { +// return _declarationDataAdapterImplementation.CreatePTOTransmissionData(ptoData); +// } + +// public IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxData, +// IBusAuxiliariesDeclarationData busAuxData, +// MissionType missionType, VehicleClass vehicleClass, Meter vehicleLength, int? numSteeredAxles) +// { +// return _declarationDataAdapterImplementation.CreateAuxiliaryData(auxData, busAuxData, missionType, +// vehicleClass, vehicleLength, numSteeredAxles); +// } + +// public AxleGearData CreateDummyAxleGearData(IGearboxDeclarationInputData gbxData) +// { +// return _declarationDataAdapterImplementation.CreateDummyAxleGearData(gbxData); +// } + +// #endregion +// } +//} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/IDeclarationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/IDeclarationDataAdapter.cs index ebd1f99eae2b6879dfc2950fcc87a0ec22a92e3d..f4535c9c8934e6682e6a738ce074e2a35b75c6db 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/IDeclarationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/IDeclarationDataAdapter.cs @@ -9,38 +9,140 @@ using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.SimulationComponent; using TUGraz.VectoCore.Models.SimulationComponent.Data; -namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter { +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ public interface IDeclarationDataAdapter { - DriverData CreateDriverData(); + //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); + //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 + { + DriverData CreateDriverData(); + AxleGearData CreateAxleGearData(IAxleGearInputData axlegearData); + AngledriveData CreateAngledriveData(IAngledriveInputData angledriveData); - CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, IEngineModeDeclarationInputData engineMode, Mission mission); - GearboxData CreateGearboxData( - IVehicleDeclarationInputData inputData, VectoRunData runData, + + AxleGearData CreateDummyAxleGearData(IGearboxDeclarationInputData gbxData); + + 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); + + RetarderData CreateRetarderData(IRetarderInputData retarderData); + + ShiftStrategyParameters CreateGearshiftData(GearboxData gbx, double axleRatio, PerSecond engineIdlingSpeed); + + //VehicleData CreateVehicleData(IVehicleDeclarationInputData vehicle, Segment segment, Mission mission, + // KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational); + + AirdragData CreateAirdragData(IAirdragDeclarationInputData airdragData, Mission mission, Segment segment); + + CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, + IEngineModeDeclarationInputData engineMode, Mission mission); + + IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxData, + IBusAuxiliariesDeclarationData busAuxData, MissionType missionType, VehicleClass vehicleClass, + Meter vehicleLength, int? numSteeredAxles); } public interface IPrimaryBusDeclarationDataAdapter : IDeclarationDataAdapter { IAuxiliaryConfig CreateBusAuxiliariesData( Mission mission, IVehicleDeclarationInputData vehicleData, VectoRunData runData); + + DriverData CreateDriverData(); + + AxleGearData CreateDummyAxleGearData(IGearboxDeclarationInputData gbxData); + AxleGearData CreateAxleGearData(IAxleGearInputData axlegearData); + AngledriveData CreateAngledriveData(IAngledriveInputData angledriveData); + + GearboxData CreateGearboxData(IVehicleDeclarationInputData inputData, + VectoRunData runData, + IShiftPolygonCalculator shiftPolygonCalc); + + RetarderData CreateRetarderData(IRetarderInputData retarderData); + PTOData CreatePTOTransmissionData(IPTOTransmissionInputData ptoData); + + ShiftStrategyParameters CreateGearshiftData(GearboxData gbx, double axleRatio, PerSecond engineIdlingSpeed); + + //VehicleData CreateVehicleData(IVehicleDeclarationInputData vehicle, Segment segment, Mission mission, + // KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational); + + CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, + IEngineModeDeclarationInputData engineMode, Mission mission); + + IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxData, + IBusAuxiliariesDeclarationData busAuxData, MissionType missionType, VehicleClass vehicleClass, + Meter vehicleLength, int? numSteeredAxles); + + AirdragData CreateAirdragData(IAirdragDeclarationInputData airdragData, Mission mission, Segment segment); } - public interface IGenericCompletedBusDataAdapter : IPrimaryBusDeclarationDataAdapter + public interface IGenericCompletedBusDeclarationDataAdapter : IDeclarationDataAdapter { + //VehicleData CreateVehicleData(IVehicleDeclarationInputData vehicle, Segment segment, Mission mission, + // KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational); + + AirdragData CreateAirdragData(IAirdragDeclarationInputData airdragData, Mission mission, Segment segment); + + CombustionEngineData CreateEngineData(IVehicleDeclarationInputData primaryVehicle, int modeIdx, + Mission mission); + + IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxData, + IBusAuxiliariesDeclarationData busAuxData, MissionType missionType, VehicleClass vehicleClass, + Meter vehicleLength, int? numSteeredAxles); + + AxleGearData CreateAxleGearData(IAxleGearInputData axlegearData); + AngledriveData CreateAngledriveData(IAngledriveInputData angledriveData); + + GearboxData CreateGearboxData(IVehicleDeclarationInputData inputData, + VectoRunData runData, + IShiftPolygonCalculator shiftPolygonCalc); + + ShiftStrategyParameters CreateGearshiftData(GearboxData gbx, double axleRatio, PerSecond engineIdlingSpeed); + + RetarderData CreateRetarderData(IRetarderInputData retarderData); + + DriverData CreateDriverData(); + + IAuxiliaryConfig CreateBusAuxiliariesData( + Mission mission, IVehicleDeclarationInputData vehicleData, VectoRunData runData); } - public interface ISpecificCompletedBusDataAdapter : IPrimaryBusDeclarationDataAdapter + public interface ISpecificCompletedBusDeclarationDataAdapter { + IAuxiliaryConfig CreateBusAuxiliariesData(Mission mission, IVehicleDeclarationInputData primaryVehicle, + IVehicleDeclarationInputData completedVehicle, VectoRunData runData); + + VehicleData CreateVehicleData(IVehicleDeclarationInputData primaryVehicle, + IVehicleDeclarationInputData completedVehicle, Segment segment, Mission mission, + KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading); + + IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxData, + IBusAuxiliariesDeclarationData busAuxData, MissionType missionType, VehicleClass vehicleClass, + Meter vehicleLength, int? numSteeredAxles); + + AirdragData CreateAirdragData(IVehicleDeclarationInputData completedVehicle, Mission mission); + CombustionEngineData CreateEngineData(IVehicleDeclarationInputData primaryVehicle, int modeIdx, + Mission mission); } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/IDeclarationDataAdapterFactory.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/IDeclarationDataAdapterFactory.cs new file mode 100644 index 0000000000000000000000000000000000000000..8598a7501d5e166d73e931b76d23ff91c4eb74e4 --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/IDeclarationDataAdapterFactory.cs @@ -0,0 +1,11 @@ +using TUGraz.VectoCore.Utils.Ninject; + +namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter +{ + public interface IDeclarationDataAdapterFactory + { + IDeclarationDataAdapter CreateDataAdapter( + VehicleTypeAndArchitectureStringHelperRundata.VehicleClassification vehicleClassification); + } +} + diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/PrimaryBus/DeclarationDataAdapterPrimaryBus.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/PrimaryBus/DeclarationDataAdapterPrimaryBus.cs index ce4e0f499c737962f29d3ed846844fa7d55679dc..97f956d34fc02fc4fe64bbf9edad7850a7a8eee5 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/PrimaryBus/DeclarationDataAdapterPrimaryBus.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/PrimaryBus/DeclarationDataAdapterPrimaryBus.cs @@ -20,444 +20,19 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.PrimaryBus { - public class DeclarationDataAdapterPrimaryBus : HeavyLorry.DeclarationDataAdapterHeavyLorry.Conventional + public abstract class DeclarationDataAdapterPrimaryBus { - #region Overrides of DeclarationDataAdapterHeavyLorry - - //public override DriverData CreateDriverData() - //{ - // var retVal = base.CreateDriverData(); - // retVal.LookAheadCoasting.Enabled = true; - // return retVal; - //} - - - public override VehicleData CreateVehicleData(IVehicleDeclarationInputData data, Segment segment, Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) - { - - var retVal = base.CreateVehicleData(data, segment, mission, loading, allowVocational); - if (data.ExemptedVehicle) { - return retVal; - } - retVal.CurbMass = mission.CurbMass; - retVal.GrossVehicleMass = 40000.SI<Kilogram>(); - return retVal; - } - - public override IList<VectoRunData.AuxData> CreateAuxiliaryData( - IAuxiliariesDeclarationInputData auxInputData, IBusAuxiliariesDeclarationData busAuxData, MissionType mission, - VehicleClass hdvClass, Meter vehicleLength, int? numSteeredAxles) - { - if (auxInputData != null) { - throw new VectoException("Only BusAuxiliaries can be provided as input!"); - } - - if (numSteeredAxles.HasValue && busAuxData.SteeringPumpTechnology.Count != numSteeredAxles.Value) { - throw new VectoException($"Number of steering pump technologies does not match number of steered axles ({numSteeredAxles.Value}, {busAuxData.SteeringPumpTechnology.Count})"); - } - var retVal = new List<VectoRunData.AuxData>(); - - retVal.Add( - new VectoRunData.AuxData() { - DemandType = AuxiliaryDemandType.Constant, - Technology = new List<string>() { busAuxData.FanTechnology }, - ID = Constants.Auxiliaries.IDs.Fan, - PowerDemand = DeclarationData.Fan.LookupMechanicalPowerDemand(hdvClass, mission, busAuxData.FanTechnology) - }); - retVal.Add( - new VectoRunData.AuxData() { - DemandType = AuxiliaryDemandType.Constant, - Technology = busAuxData.SteeringPumpTechnology, - ID = Constants.Auxiliaries.IDs.SteeringPump, - PowerDemand = DeclarationData.SteeringPumpBus.LookupMechanicalPowerDemand( - mission, busAuxData.SteeringPumpTechnology, vehicleLength) - }); - return retVal; - } - - #endregion - - public virtual IAuxiliaryConfig CreateBusAuxiliariesData( - Mission mission, IVehicleDeclarationInputData vehicleData, VectoRunData runData) - { - var actuations = DeclarationData.BusAuxiliaries.ActuationsMap.Lookup(runData.Mission.MissionType); - - var retVal = new AuxiliaryConfig { - InputData = vehicleData.Components.BusAuxiliaries, - ElectricalUserInputsConfig = GetElectricalUserConfig(mission, vehicleData, actuations, runData.VehicleData.VehicleClass), - PneumaticUserInputsConfig = GetPneumaticUserConfig(vehicleData, mission), - PneumaticAuxillariesConfig = CreatePneumaticAuxConfig(runData.Retarder.Type), - Actuations = actuations, - SSMInputs = CreateSSMModelParameters( - vehicleData.Components.BusAuxiliaries, mission, FuelData.Diesel, runData.Loading), - VehicleData = runData.VehicleData, - }; - - return retVal; - } - - protected virtual ElectricsUserInputsConfig GetElectricalUserConfig( - Mission mission, IVehicleDeclarationInputData vehicleData, IActuations actuations, VehicleClass vehicleClass) - { - var currentDemand = GetElectricConsumers(mission, vehicleData, actuations, vehicleClass); - var busAux = vehicleData.Components.BusAuxiliaries; - - var retVal = GetDefaultElectricalUserConfig(); - - retVal.AlternatorType = busAux.ElectricSupply.AlternatorTechnology; - retVal.ElectricalConsumers = currentDemand; - retVal.AlternatorMap = new SimpleAlternator(CalculateAlternatorEfficiency(busAux.ElectricSupply.Alternators)); - - switch (retVal.AlternatorType) { - case AlternatorType.Smart when busAux.ElectricSupply.Alternators.Count == 0: - throw new VectoException("at least one alternator is required when specifying smart electrics!"); - case AlternatorType.Smart when busAux.ElectricSupply.ElectricStorage.Count == 0: - throw new VectoException("at least one electric storage (battery or capacitor) is required when specifying smart electrics!"); - } - - retVal.MaxAlternatorPower = busAux.ElectricSupply.Alternators.Sum(x => x.RatedVoltage * x.RatedCurrent); - retVal.ElectricStorageCapacity = busAux.ElectricSupply.ElectricStorage.Sum(x => x.ElectricStorageCapacity) ?? 0.SI<WattSecond>(); - - return retVal; - } - - protected virtual ElectricsUserInputsConfig GetDefaultElectricalUserConfig() - { - return new ElectricsUserInputsConfig() { - PowerNetVoltage = Constants.BusAuxiliaries.ElectricSystem.PowernetVoltage, - StoredEnergyEfficiency = Constants.BusAuxiliaries.ElectricSystem.StoredEnergyEfficiency, - ResultCardIdle = new DummyResultCard(), - ResultCardOverrun = new DummyResultCard(), - ResultCardTraction = new DummyResultCard(), - AlternatorGearEfficiency = Constants.BusAuxiliaries.ElectricSystem.AlternatorGearEfficiency, - DoorActuationTimeSecond = Constants.BusAuxiliaries.ElectricalConsumers.DoorActuationTimeSecond, - }; - } - - protected virtual double CalculateAlternatorEfficiency(IList<IAlternatorDeclarationInputData> alternators) - { - return DeclarationData.BusAuxiliaries.AlternatorTechnologies.Lookup("default"); - } - - protected virtual Dictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry> GetElectricConsumers(Mission mission, IVehicleDeclarationInputData vehicleData, IActuations actuations, VehicleClass vehicleClass) - { - var retVal = GetDefaultElectricConsumers(mission, vehicleData, actuations); - - foreach (var entry in GetElectricAuxConsumers(mission, vehicleData, vehicleClass, vehicleData.Components.BusAuxiliaries)) { - retVal[entry.Key] = entry.Value; - } - - return retVal; - } - - protected virtual Dictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry> GetDefaultElectricConsumers( - Mission mission, IVehicleDeclarationInputData vehicleData, IActuations actuations) - { - var retVal = new Dictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry>(); - var doorDutyCycleFraction = - (actuations.ParkBrakeAndDoors * Constants.BusAuxiliaries.ElectricalConsumers.DoorActuationTimeSecond) / - actuations.CycleTime; - var busAux = vehicleData.Components.BusAuxiliaries; - var electricDoors = vehicleData.DoorDriveTechnology == ConsumerTechnology.Electrically || - vehicleData.DoorDriveTechnology == ConsumerTechnology.Mixed; - - foreach (var consumer in DeclarationData.BusAuxiliaries.DefaultElectricConsumerList.Items) { - var applied = consumer.DefaultConsumer || consumer.Bonus - ? 1.0 - : GetNumberOfElectricalConsumersForMission(mission, consumer, vehicleData); - var nbr = consumer.DefaultConsumer - ? GetNumberOfElectricalConsumersInVehicle(consumer.NumberInActualVehicle, mission, vehicleData) - : 1.0; - - var dutyCycle = electricDoors && consumer.ConsumerName.Equals( - Constants.BusAuxiliaries.ElectricalConsumers.DoorsPerVehicleConsumer, - StringComparison.CurrentCultureIgnoreCase) - ? doorDutyCycleFraction - : consumer.PhaseIdleTractionOn; - - var current = applied * consumer.NominalCurrent(mission.MissionType) * dutyCycle * nbr; - if (consumer.Bonus && !VehicleHasElectricalConsumer(consumer.ConsumerName, busAux)) { - current = 0.SI<Ampere>(); - } - - retVal[consumer.ConsumerName] = new AuxiliaryDataAdapter.ElectricConsumerEntry { - BaseVehicle = consumer.BaseVehicle, - Current = current - }; - } - - return retVal; - } - - private double GetNumberOfElectricalConsumersForMission(Mission mission, ElectricalConsumer consumer, - IVehicleDeclarationInputData vehicleData) - { - if (consumer.ConsumerName.Equals(Constants.BusAuxiliaries.ElectricalConsumers.DoorsPerVehicleConsumer, - StringComparison.CurrentCultureIgnoreCase)) { - var count = DeclarationData.BusAuxiliaries.DefaultElectricConsumerList.Items.First(x => - x.ConsumerName.Equals( - Constants.BusAuxiliaries.ElectricalConsumers.DoorsPerVehicleConsumer, - StringComparison.CurrentCultureIgnoreCase)).NumberInActualVehicle.ToDouble(); - - switch (vehicleData.DoorDriveTechnology) - { - case ConsumerTechnology.Electrically: - return count; - case ConsumerTechnology.Mixed: - return count * 0.5; - default: - return 0; - } - } - - return mission.BusParameter.ElectricalConsumers.GetVECTOValueOrDefault(consumer.ConsumerName, 0); - } - - protected virtual Dictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry> GetElectricAuxConsumers(Mission mission, IVehicleDeclarationInputData vehicleData, VehicleClass vehicleClass, IBusAuxiliariesDeclarationData busAux) - { - var retVal = new Dictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry>(); - var spPower = DeclarationData.SteeringPumpBus.LookupElectricalPowerDemand( - mission.MissionType, busAux.SteeringPumpTechnology, - vehicleData.Length ?? mission.BusParameter.VehicleLength); - retVal[Constants.Auxiliaries.IDs.SteeringPump] = new AuxiliaryDataAdapter.ElectricConsumerEntry { - ActiveDuringEngineStopStandstill = false, - BaseVehicle = false, - Current = spPower / Constants.BusAuxiliaries.ElectricSystem.PowernetVoltage - }; - - var fanPower = DeclarationData.Fan.LookupElectricalPowerDemand( - vehicleClass, mission.MissionType, busAux.FanTechnology); - retVal[Constants.Auxiliaries.IDs.Fan] = new AuxiliaryDataAdapter.ElectricConsumerEntry { - ActiveDuringEngineStopStandstill = false, - ActiveDuringEngineStopDriving = false, - BaseVehicle = false, - Current = fanPower / Constants.BusAuxiliaries.ElectricSystem.PowernetVoltage - }; - return retVal; - } - - protected virtual bool VehicleHasElectricalConsumer(string consumerName, IBusAuxiliariesDeclarationData busAux) - { - switch (consumerName) { - case "Day running lights LED bonus": - case "Position lights LED bonus": - case "Brake lights LED bonus": // return false; - case "Interior lights LED bonus": - case "Headlights LED bonus": return true; - default: return false; - } - } - - protected virtual double GetNumberOfElectricalConsumersInVehicle(string nbr, Mission mission, IVehicleDeclarationInputData vehicleData) - { - if ("f_IntLight(L_CoC)".Equals(nbr, StringComparison.InvariantCultureIgnoreCase)) { - return CalculateLengthDependentElectricalConsumers(mission, vehicleData); - } - - return nbr.ToDouble(); - } - - protected virtual double CalculateLengthDependentElectricalConsumers(Mission mission, IVehicleDeclarationInputData vehicleData) - { - var busParams = mission.BusParameter; - return DeclarationData.BusAuxiliaries.CalculateLengthInteriorLights( - busParams.VehicleLength, busParams.VehicleCode, busParams.NumberPassengersLowerDeck) - .Value(); - } - - protected virtual PneumaticUserInputsConfig GetPneumaticUserConfig(IVehicleDeclarationInputData vehicleData, Mission mission) - { - var busAux = vehicleData.Components.BusAuxiliaries; - - //throw new NotImplementedException(); - return new PneumaticUserInputsConfig() { - KneelingHeight = VectoMath.Max(0.SI<Meter>(), mission.BusParameter.EntranceHeight - Constants.BusParameters.EntranceHeight), - CompressorGearEfficiency = Constants.BusAuxiliaries.PneumaticUserConfig.CompressorGearEfficiency, - CompressorGearRatio = busAux.PneumaticSupply.Ratio, - CompressorMap = DeclarationData.BusAuxiliaries.GetCompressorMap(busAux.PneumaticSupply.CompressorSize, busAux.PneumaticSupply.Clutch), - SmartAirCompression = busAux.PneumaticSupply.SmartAirCompression, - SmartRegeneration = busAux.PneumaticSupply.SmartRegeneration, - AdBlueDosing = busAux.PneumaticConsumers.AdBlueDosing, - Doors = ConsumerTechnology.Pneumatically, - AirSuspensionControl = busAux.PneumaticConsumers.AirsuspensionControl, - }; - } - - - - public SSMInputs GetDefaulSSMInputs(IFuelProperties heatingFuel) - { - return new SSMInputs(null, heatingFuel) { - DefaultConditions = new EnvironmentalConditionMapEntry( - Constants.BusAuxiliaries.SteadyStateModel.DefaultTemperature, - Constants.BusAuxiliaries.SteadyStateModel.DefaultSolar, - 1.0), - EnvironmentalConditionsMap = DeclarationData.BusAuxiliaries.DefaultEnvironmentalConditions, - HeatingBoundaryTemperature = Constants.BusAuxiliaries.SteadyStateModel.HeatingBoundaryTemperature, - CoolingBoundaryTemperature = Constants.BusAuxiliaries.SteadyStateModel.CoolingBoundaryTemperature, - - SpecificVentilationPower = Constants.BusAuxiliaries.SteadyStateModel.SpecificVentilationPower, - - AuxHeaterEfficiency = Constants.BusAuxiliaries.SteadyStateModel.AuxHeaterEfficiency, - FuelEnergyToHeatToCoolant = Constants.BusAuxiliaries.Heater.FuelEnergyToHeatToCoolant, - CoolantHeatTransferredToAirCabinHeater = Constants.BusAuxiliaries.Heater.CoolantHeatTransferredToAirCabinHeater, - GFactor = Constants.BusAuxiliaries.SteadyStateModel.GFactor, - - VentilationOnDuringHeating = true, - VentilationWhenBothHeatingAndACInactive = true, - VentilationDuringAC = true, - - MaxPossibleBenefitFromTechnologyList = - Constants.BusAuxiliaries.SteadyStateModel.MaxPossibleBenefitFromTechnologyList, - }; - } - - public virtual ISSMDeclarationInputs CreateSSMModelParameters(IBusAuxiliariesDeclarationData busAuxInputData, Mission mission, IFuelProperties heatingFuel, LoadingType loadingType) - { - var busParams = mission.BusParameter; - - var isDoubleDecker = busParams.VehicleCode.IsDoubleDeckerBus(); - var internalLength = busParams.HVACConfiguration == BusHVACSystemConfiguration.Configuration2 - ? 2 * Constants.BusParameters.DriverCompartmentLength // OK - : DeclarationData.BusAuxiliaries.CalculateInternalLength(busParams.VehicleLength, - busParams.VehicleCode, 10); // missing: correction length for low floor buses - var internalHeight = DeclarationData.BusAuxiliaries.CalculateInternalHeight(mission.BusParameter.VehicleCode, RegistrationClass.II, busParams.BodyHeight); - var coolingPower = CalculateMaxCoolingPower(null, null, mission); - - var retVal = GetDefaulSSMInputs(heatingFuel); - retVal.BusFloorType = busParams.VehicleCode.GetFloorType(); - retVal.Technologies = GetSSMTechnologyBenefits(busAuxInputData, mission.BusParameter.VehicleCode.GetFloorType()); - - retVal.FuelFiredHeaterPower = busParams.HVACAuxHeaterPower; - retVal.BusWindowSurface = DeclarationData.BusAuxiliaries.WindowHeight(busParams.DoubleDecker) * internalLength + - DeclarationData.BusAuxiliaries.FrontAndRearWindowArea(busParams.DoubleDecker); - retVal.BusSurfaceArea = 2 * (internalLength * busParams.VehicleWidth + internalLength * internalHeight + - (isDoubleDecker ? 2.0 : 1.0) * busParams.VehicleWidth * busParams.BodyHeight); - retVal.BusVolume = internalLength * busParams.VehicleWidth * internalHeight; - - retVal.UValue = DeclarationData.BusAuxiliaries.UValue(busParams.VehicleCode.GetFloorType()); - retVal.NumberOfPassengers = - DeclarationData.BusAuxiliaries.CalculateBusFloorSurfaceArea(internalLength, busParams.VehicleWidth) * - (loadingType == LoadingType.LowLoading ? mission.BusParameter.PassengerDensityLow : mission.BusParameter.PassengerDensityRef) * - (loadingType == LoadingType.LowLoading ? mission.MissionType.GetLowLoadFactorBus() : 1.0) + 1; // add driver for 'heat input' - retVal.VentilationRate = DeclarationData.BusAuxiliaries.VentilationRate(busParams.HVACConfiguration, false); - retVal.VentilationRateHeating = DeclarationData.BusAuxiliaries.VentilationRate(busParams.HVACConfiguration, true); - - retVal.HVACMaxCoolingPower = coolingPower.Item1 + coolingPower.Item2; - retVal.HVACCompressorType = busParams.HVACCompressorType; // use passenger compartment - retVal.COP = DeclarationData.BusAuxiliaries.CalculateCOP( - - coolingPower.Item1, HeatPumpType.none, coolingPower.Item2, busParams.HVACCompressorType, - busParams.VehicleCode.GetFloorType()); - retVal.HVACTechnology = $"{busParams.HVACConfiguration.GetName()} " + - $"({string.Join(", ", busParams.HVACCompressorType.GetName(), HeatPumpType.none.GetName())})"; - - //SetHVACParameters(retVal, vehicleData, mission); - - return retVal; - } - - - protected virtual TechnologyBenefits GetSSMTechnologyBenefits(IBusAuxiliariesDeclarationData inputData, FloorType floorType) - { - var onVehicle = new List<SSMTechnology>(); - foreach (var item in DeclarationData.BusAuxiliaries.SSMTechnologyList) { - if ("Adjustable coolant thermostat".Equals(item.BenefitName, StringComparison.InvariantCultureIgnoreCase) && - (inputData?.HVACAux.AdjustableCoolantThermostat ?? false)) { - onVehicle.Add(item); - } - - if ("Engine waste gas heat exchanger".Equals(item.BenefitName, StringComparison.InvariantCultureIgnoreCase) && - (inputData?.HVACAux.EngineWasteGasHeatExchanger ?? false)) { - onVehicle.Add(item); - } - } - - return SelectBenefitForFloorType(floorType, onVehicle); - } - - protected virtual TechnologyBenefits SelectBenefitForFloorType(FloorType floorType, List<SSMTechnology> onVehicle) - { - var retVal = new TechnologyBenefits(); - - switch (floorType) { - case FloorType.LowFloor: - retVal.CValueVariation = onVehicle.Sum(x => x.LowFloorC); - retVal.HValueVariation = onVehicle.Sum(x => x.LowFloorH); - retVal.VCValueVariation = onVehicle.Sum(x => x.ActiveVC ? x.LowFloorV : 0); - retVal.VHValueVariation = onVehicle.Sum(x => x.ActiveVH ? x.LowFloorV : 0); - retVal.VVValueVariation = onVehicle.Sum(x => x.ActiveVV ? x.LowFloorV : 0); - break; - case FloorType.HighFloor: - retVal.CValueVariation = onVehicle.Sum(x => x.RaisedFloorC); - retVal.HValueVariation = onVehicle.Sum(x => x.RaisedFloorH); - retVal.VCValueVariation = onVehicle.Sum(x => x.ActiveVC ? x.RaisedFloorV : 0); - retVal.VHValueVariation = onVehicle.Sum(x => x.ActiveVH ? x.RaisedFloorV : 0); - retVal.VVValueVariation = onVehicle.Sum(x => x.ActiveVV ? x.RaisedFloorV : 0); - break; - case FloorType.SemiLowFloor: - retVal.CValueVariation = onVehicle.Sum(x => x.SemiLowFloorC); - retVal.HValueVariation = onVehicle.Sum(x => x.SemiLowFloorH); - retVal.VCValueVariation = onVehicle.Sum(x => x.ActiveVC ? x.SemiLowFloorV : 0); - retVal.VHValueVariation = onVehicle.Sum(x => x.ActiveVH ? x.SemiLowFloorV : 0); - retVal.VVValueVariation = onVehicle.Sum(x => x.ActiveVV ? x.SemiLowFloorV : 0); - break; - } - - return retVal; - } - - - protected virtual Tuple<Watt, Watt> CalculateMaxCoolingPower(IVehicleDeclarationInputData vehicleData, IVehicleDeclarationInputData primaryVehicle, Mission mission) - { - var busParams = mission.BusParameter; - - var length = DeclarationData.BusAuxiliaries.CalculateInternalLength( - busParams.VehicleLength, busParams.VehicleCode, - busParams.NumberPassengersLowerDeck); - var height = DeclarationData.BusAuxiliaries.CalculateInternalHeight(busParams.VehicleCode, RegistrationClass.II, busParams.BodyHeight); - var volume = length * height * busParams.VehicleWidth; - - var driver = DeclarationData.BusAuxiliaries.HVACMaxCoolingPower.DriverMaxCoolingPower( - busParams.HVACConfiguration, mission.MissionType); - var passenger = DeclarationData.BusAuxiliaries.HVACMaxCoolingPower.PassengerMaxCoolingPower( - busParams.HVACConfiguration, mission.MissionType, volume); - - return Tuple.Create(driver, passenger); - } - - protected internal virtual IPneumaticsConsumersDemand CreatePneumaticAuxConfig(RetarderType retarderType) - { - return new PneumaticsConsumersDemand() { - AdBlueInjection = Constants.BusAuxiliaries.PneumaticConsumersDemands.AdBlueInjection, - AirControlledSuspension = Constants.BusAuxiliaries.PneumaticConsumersDemands.AirControlledSuspension, - Braking = retarderType == RetarderType.None - ? Constants.BusAuxiliaries.PneumaticConsumersDemands.BrakingNoRetarder - : Constants.BusAuxiliaries.PneumaticConsumersDemands.BrakingWithRetarder, - BreakingWithKneeling = Constants.BusAuxiliaries.PneumaticConsumersDemands.BreakingAndKneeling, - DeadVolBlowOuts = Constants.BusAuxiliaries.PneumaticConsumersDemands.DeadVolBlowOuts, - DeadVolume = Constants.BusAuxiliaries.PneumaticConsumersDemands.DeadVolume, - NonSmartRegenFractionTotalAirDemand = - Constants.BusAuxiliaries.PneumaticConsumersDemands.NonSmartRegenFractionTotalAirDemand, - SmartRegenFractionTotalAirDemand = - Constants.BusAuxiliaries.PneumaticConsumersDemands.SmartRegenFractionTotalAirDemand, - OverrunUtilisationForCompressionFraction = - Constants.BusAuxiliaries.PneumaticConsumersDemands.OverrunUtilisationForCompressionFraction, - DoorOpening = Constants.BusAuxiliaries.PneumaticConsumersDemands.DoorOpening, - StopBrakeActuation = Constants.BusAuxiliaries.PneumaticConsumersDemands.StopBrakeActuation, - }; - } - - public abstract class PrimaryBusBase : IPrimaryBusDeclarationDataAdapter { + public static readonly GearboxType[] SupportedGearboxTypes = + { GearboxType.MT, GearboxType.AMT, GearboxType.ATPowerSplit, GearboxType.ATSerial }; #region Implementation of IDeclarationDataAdapter private readonly IDriverDataAdapter _driverDataAdapter = new PrimaryBusDriverDataAdapter(); protected readonly IVehicleDataAdapter _vehicleDataAdapter = new PrimaryBusVehicleDataAdapter(); - protected readonly IAxleGearDataAdapter _axleGearDataAdapter = new AxleGearDataAdapterBase(); + protected readonly IAxleGearDataAdapter _axleGearDataAdapter = new AxleGearDataAdapter(); protected readonly IPTODataAdapter _ptoDataAdapter = new PTODataAdapterBus(); - protected readonly IAuxiliaryDataAdapter _auxDataAdapter = new PrimaryBusAuxiliaryDataAdapter(); + protected readonly IPrimaryBusAuxiliaryDataAdapter _auxDataAdapter = new PrimaryBusAuxiliaryDataAdapter(); protected readonly IRetarderDataAdapter _retarderDataAdapter = new RetarderDataAdapter(); public DriverData CreateDriverData() @@ -643,20 +218,4 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.PrimaryBus #endregion } } - - //public class ElectricConsumerEntry { - - // public ElectricConsumerEntry() - // { - // ActiveDuringEngineStopStandstill = true; - // ActiveDuringEngineStopDriving = true; - // } - - // public bool ActiveDuringEngineStopDriving { get; set; } - - // public bool ActiveDuringEngineStopStandstill { get; set; } - - // public bool BaseVehicle { get; set; } - // public Ampere Current { get; set; } - //} } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AirdragDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AirdragDataAdapter.cs index 479d1fdc114bb0eaf4415d9b264cc3bb81c7b5fd..8e3afd76eb6bfa104b37ad466ce280b4594cc5cf 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AirdragDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AirdragDataAdapter.cs @@ -14,18 +14,17 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponents { - internal interface IAirdragDataAdapter + public interface IAirdragDataAdapter { AirdragData CreateAirdragData( IAirdragDeclarationInputData airdragInputData, Mission mission, Segment segment); } - internal class AirdragDataAdapter : IAirdragDataAdapter + public class AirdragDataAdapter : IAirdragDataAdapter { - public List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> - GetDeclarationAirResistanceCurve( - string crosswindCorrectionParameters, SquareMeter aerodynamicDragAera, Meter vehicleHeight) + public List<CrossWindCorrectionCurveReader.CrossWindCorrectionEntry> GetDeclarationAirResistanceCurve( + string crosswindCorrectionParameters, SquareMeter aerodynamicDragAera, Meter vehicleHeight) { var startSpeed = Constants.SimulationSettings.CrosswindCorrection.MinVehicleSpeed; var maxSpeed = Constants.SimulationSettings.CrosswindCorrection.MaxVehicleSpeed; diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AngledriveDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AngledriveDataAdapter.cs index f748c6cbe91b91e8cedc68d7c236d36a5af9e7e4..0f88899d1ebb70de1f22581140f573ae0b6b24b8 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AngledriveDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AngledriveDataAdapter.cs @@ -13,6 +13,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen public interface IAngledriveDataAdapter { AngledriveData CreateAngledriveData(IAngledriveInputData data, bool useEfficiencyFallback); + AngledriveData CreateAngledriveData(IAngledriveInputData data); } public class AngledriveDataAdapter : IAngledriveDataAdapter @@ -61,6 +62,11 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen throw new VectoException("Error while reading Angledrive data: {0}", e.Message, e); } } + + public AngledriveData CreateAngledriveData(IAngledriveInputData data) + { + return CreateAngledriveData(data, false); + } } public class GenericAngledriveDataAdapter : IAngledriveDataAdapter @@ -73,6 +79,11 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen return _genericPowertrainData.CreateGenericBusAngledriveData(data); } + public AngledriveData CreateAngledriveData(IAngledriveInputData data) + { + return CreateAngledriveData(data, false); + } + #endregion } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AuxiliaryDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AuxiliaryDataAdapter.cs index 8efb4c058f0e4cbd58e76e8b6c5639ceacb4df38..1bfdece45d46d06703730c7c791e3cf6e24023b1 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AuxiliaryDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AuxiliaryDataAdapter.cs @@ -23,10 +23,23 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen IList<VectoRunData.AuxData> CreateAuxiliaryData(IAuxiliariesDeclarationInputData auxInputData, IBusAuxiliariesDeclarationData busAuxData, MissionType mission, VehicleClass hvdClass, Meter vehicleLength, int? numSteeredAxles); + } - AuxiliaryConfig CreateBusAuxiliariesData(Mission mission, IVehicleDeclarationInputData vehicleData, VectoRunData runData); - + public interface ICompletedBusAuxiliaryDataAdapter : IPrimaryBusAuxiliaryDataAdapter + { + IAuxiliaryConfig CreateBusAuxiliariesData(Mission mission, IVehicleDeclarationInputData primaryVehicle, + IVehicleDeclarationInputData completedVehicle, VectoRunData runData); + } + public interface IPrimaryBusAuxiliaryDataAdapter : IAuxiliaryDataAdapter + { + AuxiliaryConfig CreateBusAuxiliariesData(Mission mission, IVehicleDeclarationInputData primaryVehicle, VectoRunData runData); + IDictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry> GetElectricConsumers(Mission mission, IVehicleDeclarationInputData completedVehicle, IActuations actuations, VehicleClass vehicleClass); + ElectricsUserInputsConfig GetDefaultElectricalUserConfig(); + double CalculateAlternatorEfficiency(IList<IAlternatorDeclarationInputData> alternators); + IPneumaticsConsumersDemand CreatePneumaticAuxConfig(RetarderType retarderType); + SSMInputs GetDefaulSSMInputs(IFuelProperties heatingFuel); + TechnologyBenefits SelectBenefitForFloorType(FloorType floorType, List<SSMTechnology> onVehicle); } public abstract class AuxiliaryDataAdapter : ComponentDataAdapterBase, IAuxiliaryDataAdapter @@ -55,7 +68,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen return DoCreateAuxiliaryData(auxInputData, busAuxData, mission, hvdClass, vehicleLength, numSteeredAxles); } - public abstract AuxiliaryConfig CreateBusAuxiliariesData(Mission mission, IVehicleDeclarationInputData vehicleData, VectoRunData runData); + public abstract AuxiliaryConfig CreateBusAuxiliariesData(Mission mission, IVehicleDeclarationInputData primaryVehicle, VectoRunData runData); protected abstract IList<VectoRunData.AuxData> DoCreateAuxiliaryData( IAuxiliariesDeclarationInputData auxInputData, @@ -69,7 +82,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen { #region Overrides of AuxiliaryDataAdapter - public override AuxiliaryConfig CreateBusAuxiliariesData(Mission mission, IVehicleDeclarationInputData vehicleData, VectoRunData runData) + public override AuxiliaryConfig CreateBusAuxiliariesData(Mission mission, IVehicleDeclarationInputData primaryVehicle, VectoRunData runData) { throw new System.NotImplementedException(); } @@ -143,9 +156,9 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen #endregion } - public class PrimaryBusAuxiliaryDataAdapter : AuxiliaryDataAdapter + public class PrimaryBusAuxiliaryDataAdapter : AuxiliaryDataAdapter, IPrimaryBusAuxiliaryDataAdapter { - private ElectricsUserInputsConfig GetDefaultElectricalUserConfig() + public ElectricsUserInputsConfig GetDefaultElectricalUserConfig() { return new ElectricsUserInputsConfig() { @@ -158,6 +171,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen DoorActuationTimeSecond = Constants.BusAuxiliaries.ElectricalConsumers.DoorActuationTimeSecond, }; } + private double GetNumberOfElectricalConsumersForMission(Mission mission, ElectricalConsumer consumer, IVehicleDeclarationInputData vehicleData) { @@ -255,7 +269,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen return nbr.ToDouble(); } - private Dictionary<string, ElectricConsumerEntry> GetElectricConsumers(Mission mission, IVehicleDeclarationInputData vehicleData, IActuations actuations, VehicleClass vehicleClass) + public IDictionary<string, ElectricConsumerEntry> GetElectricConsumers(Mission mission, IVehicleDeclarationInputData vehicleData, IActuations actuations, VehicleClass vehicleClass) { var retVal = GetDefaultElectricConsumers(mission, vehicleData, actuations); @@ -290,7 +304,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen }; return retVal; } - protected virtual double CalculateAlternatorEfficiency(IList<IAlternatorDeclarationInputData> alternators) + public double CalculateAlternatorEfficiency(IList<IAlternatorDeclarationInputData> alternators) { return DeclarationData.BusAuxiliaries.AlternatorTechnologies.Lookup("default"); } @@ -338,7 +352,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen AirSuspensionControl = busAux.PneumaticConsumers.AirsuspensionControl, }; } - protected internal virtual IPneumaticsConsumersDemand CreatePneumaticAuxConfig(RetarderType retarderType) + public IPneumaticsConsumersDemand CreatePneumaticAuxConfig(RetarderType retarderType) { return new PneumaticsConsumersDemand() { @@ -425,7 +439,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen return SelectBenefitForFloorType(floorType, onVehicle); } - protected virtual TechnologyBenefits SelectBenefitForFloorType(FloorType floorType, List<SSMTechnology> onVehicle) + public virtual TechnologyBenefits SelectBenefitForFloorType(FloorType floorType, List<SSMTechnology> onVehicle) { var retVal = new TechnologyBenefits(); @@ -505,19 +519,19 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen #region Overrides of AuxiliaryDataAdapter - public override AuxiliaryConfig CreateBusAuxiliariesData(Mission mission, IVehicleDeclarationInputData vehicleData, VectoRunData runData) + public override AuxiliaryConfig CreateBusAuxiliariesData(Mission mission, IVehicleDeclarationInputData primaryVehicle, VectoRunData runData) { var actuations = DeclarationData.BusAuxiliaries.ActuationsMap.Lookup(runData.Mission.MissionType); var retVal = new AuxiliaryConfig { - InputData = vehicleData.Components.BusAuxiliaries, - ElectricalUserInputsConfig = GetElectricalUserConfig(mission, vehicleData, actuations, runData.VehicleData.VehicleClass), - PneumaticUserInputsConfig = GetPneumaticUserConfig(vehicleData, mission), + InputData = primaryVehicle.Components.BusAuxiliaries, + ElectricalUserInputsConfig = GetElectricalUserConfig(mission, primaryVehicle, actuations, runData.VehicleData.VehicleClass), + PneumaticUserInputsConfig = GetPneumaticUserConfig(primaryVehicle, mission), PneumaticAuxillariesConfig = CreatePneumaticAuxConfig(runData.Retarder.Type), Actuations = actuations, SSMInputs = CreateSSMModelParameters( - vehicleData.Components.BusAuxiliaries, mission, FuelData.Diesel, runData.Loading), + primaryVehicle.Components.BusAuxiliaries, mission, FuelData.Diesel, runData.Loading), VehicleData = runData.VehicleData, }; @@ -561,5 +575,376 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen #endregion } + public class GenericCompletedBusAuxiliaryDataAdapter : PrimaryBusAuxiliaryDataAdapter, ICompletedBusAuxiliaryDataAdapter + { + #region Implementation of ICompletedBusAuxiliaryDataAdapter + + public IAuxiliaryConfig CreateBusAuxiliariesData(Mission mission, IVehicleDeclarationInputData primaryVehicle, + IVehicleDeclarationInputData completedVehicle, VectoRunData runData) + { + if (completedVehicle != null) { + throw new ArgumentException("Completed Vehicle must not be provided"); + } + return CreateBusAuxiliariesData(mission, primaryVehicle, runData); + } + + #endregion + } + + public class SpecificCompletedBusAuxiliaryDataAdapter : PrimaryBusAuxiliaryDataAdapter, ICompletedBusAuxiliaryDataAdapter + { + private readonly IPrimaryBusAuxiliaryDataAdapter _primaryBusDataAdapter; + + public SpecificCompletedBusAuxiliaryDataAdapter(IPrimaryBusAuxiliaryDataAdapter primaryBusDataAdapter) + { + _primaryBusDataAdapter = primaryBusDataAdapter; + } + private double GetNumberOfPassengers(Mission mission, Meter length, Meter width, double registeredPassengerSeats, + double registeredPassengersStanding, LoadingType loading) + { + var busFloorArea = DeclarationData.BusAuxiliaries.CalculateBusFloorSurfaceArea(length, width); + var passengerCountRef = busFloorArea * (loading == LoadingType.LowLoading + ? mission.BusParameter.PassengerDensityLow + : mission.BusParameter.PassengerDensityRef); + + if (loading != LoadingType.ReferenceLoad && loading != LoadingType.LowLoading) + { + throw new VectoException("Unhandled loading type: {0}", loading); + } + + var passengerCount = registeredPassengerSeats + + (mission.MissionType == MissionType.Coach ? 0 : registeredPassengersStanding); + + return loading == LoadingType.ReferenceLoad + ? VectoMath.Min(passengerCountRef, passengerCount) + : VectoMath.Min(passengerCountRef * mission.MissionType.GetLowLoadFactorBus(), passengerCount); + } + + #region Avarage Current Demand Calculation + + + protected bool VehicleHasElectricalConsumer(string consumerName, IBusAuxiliariesDeclarationData busAux) + { + if (consumerName == "Day running lights LED bonus" && (bool)busAux.ElectricConsumers.DayrunninglightsLED) + return true; + if (consumerName == "Position lights LED bonus" && (bool)busAux.ElectricConsumers.PositionlightsLED) + return true; + if (consumerName == "Brake lights LED bonus" && (bool)busAux.ElectricConsumers.BrakelightsLED) + return true; + if (consumerName == "Interior lights LED bonus" && (bool)busAux.ElectricConsumers.InteriorLightsLED) + return true; + if (consumerName == "Headlights LED bonus" && (bool)busAux.ElectricConsumers.HeadlightsLED) + return true; + + return false; + } + + protected double CalculateLengthDependentElectricalConsumers(Mission mission, IVehicleDeclarationInputData vehicleData) + { + var busParams = mission.BusParameter; + return DeclarationData.BusAuxiliaries.CalculateLengthInteriorLights( + vehicleData.Length, vehicleData.VehicleCode, busParams.NumberPassengersLowerDeck) + .Value(); + } + + + #endregion + + private Tuple<Watt, Watt> CalculateMaxCoolingPower(IVehicleDeclarationInputData completedVehicle, IVehicleDeclarationInputData primaryVehicle, + Mission mission) + { + var hvacConfiguration = completedVehicle.Components.BusAuxiliaries.HVACAux.SystemConfiguration; + if (!hvacConfiguration.HasValue || hvacConfiguration.IsOneOf(BusHVACSystemConfiguration.Configuration0, BusHVACSystemConfiguration.Unknown)) + { + throw new VectoException( + $"HVAC Configuration {hvacConfiguration.ToXmlFormat()} is invalid for final step"); + } + + var correctionLengthDrivetrainVolume = DeclarationData.BusAuxiliaries.CorrectionLengthDrivetrainVolume( + completedVehicle.VehicleCode, completedVehicle.LowEntry, primaryVehicle.AxleConfiguration.NumAxles(), + primaryVehicle.Articulated); + + var pasengerCompartmentLength = DeclarationData.BusAuxiliaries.CalculateInternalLength( + completedVehicle.Length, completedVehicle.VehicleCode, + (int)completedVehicle.NumberPassengerSeatsLowerDeck) - Constants.BusParameters.DriverCompartmentLength - correctionLengthDrivetrainVolume; + + var internalHeight = DeclarationData.BusAuxiliaries.CalculateInternalHeight(completedVehicle.VehicleCode, completedVehicle.RegisteredClass, completedVehicle.Height); + var volume = pasengerCompartmentLength * internalHeight * completedVehicle.Width; + + var driver = DeclarationData.BusAuxiliaries.HVACMaxCoolingPower.DriverMaxCoolingPower( + hvacConfiguration, mission.MissionType); + var passenger = DeclarationData.BusAuxiliaries.HVACMaxCoolingPower.PassengerMaxCoolingPower( + hvacConfiguration, mission.MissionType, volume); + + return Tuple.Create(driver, passenger); + } + + private PneumaticUserInputsConfig CreatePneumaticUserInputsConfig(IBusAuxiliariesDeclarationData primaryBusAuxiliaries, + IVehicleDeclarationInputData completedVehicle) + { + return new PneumaticUserInputsConfig + { + CompressorMap = completedVehicle.VehicleType == VectoSimulationJobType.BatteryElectricVehicle + ? null + : DeclarationData.BusAuxiliaries.GetCompressorMap( + primaryBusAuxiliaries.PneumaticSupply.CompressorSize, + primaryBusAuxiliaries.PneumaticSupply.Clutch), + CompressorGearEfficiency = Constants.BusAuxiliaries.PneumaticUserConfig.CompressorGearEfficiency, + CompressorGearRatio = completedVehicle.VehicleType == VectoSimulationJobType.BatteryElectricVehicle + ? 0 : primaryBusAuxiliaries.PneumaticSupply.Ratio, + SmartAirCompression = primaryBusAuxiliaries.PneumaticSupply.SmartAirCompression, + SmartRegeneration = primaryBusAuxiliaries.PneumaticSupply.SmartRegeneration, + KneelingHeight = VectoMath.Max(0.SI<Meter>(), + completedVehicle.EntranceHeight - Constants.BusParameters.EntranceHeight), + AirSuspensionControl = primaryBusAuxiliaries.PneumaticConsumers.AirsuspensionControl, + AdBlueDosing = primaryBusAuxiliaries.PneumaticConsumers.AdBlueDosing, + Doors = completedVehicle.DoorDriveTechnology + }; + } + + private SSMInputs GetCompletedSSMInput(Mission mission, IVehicleDeclarationInputData completedVehicle, + IVehicleDeclarationInputData primaryVehicle, LoadingType loadingType) + { + var isDoubleDecker = completedVehicle.VehicleCode.IsDoubleDeckerBus(); + var hvacConfiguration = completedVehicle.Components.BusAuxiliaries.HVACAux.SystemConfiguration; + var busAux = completedVehicle.Components.BusAuxiliaries.HVACAux; + + + if (mission.BusParameter.SeparateAirDistributionDuctsHVACCfg.Contains(hvacConfiguration) && + (busAux.SeparateAirDistributionDucts == null || !busAux.SeparateAirDistributionDucts.Value)) + { + throw new VectoException("Input parameter 'separate air distribution ducts' has to be set to 'true' for vehicle group '{0}' and HVAC configuration '{1}'", + mission.BusParameter.BusGroup.GetClassNumber(), hvacConfiguration.GetName()); + } + + if (completedVehicle.NumberPassengerSeatsLowerDeck == null) + { + throw new VectoException("NumberOfPassengerSeatsLowerDeck input parameter is required"); + } + if (completedVehicle.NumberPassengerSeatsUpperDeck == null) + { + throw new VectoException("NumberOfPassengerSeatsUpperDeck input parameter is required"); + } + if (completedVehicle.NumberPassengersStandingLowerDeck == null) + { + throw new VectoException("NumberOfPassengersStandingLowerDeck input parameter is required"); + } + if (completedVehicle.NumberPassengersStandingUpperDeck == null) + { + throw new VectoException("NumberOfPassengersStandingUpperDeck input parameter is required"); + } + if (busAux.HeatPumpTypeCoolingDriverCompartment == null) + { + throw new VectoException("HeatPumpTypeDriverCompartment Cooling input parameter is required"); + } + if (busAux.HeatPumpTypeHeatingDriverCompartment == null) + { + throw new VectoException("HeatPumpTypeDriverCompartment Heating input parameter is required"); + } + if (busAux.HeatPumpTypeCoolingPassengerCompartment == null) + { + throw new VectoException("HeatPumpTypePassengerCompartment Cooling input parameter is required"); + } + if (busAux.HeatPumpTypeHeatingPassengerCompartment == null) + { + throw new VectoException("HeatPumpTypePassengerCompartment Heating input parameter is required"); + } + + + if (hvacConfiguration.RequiresDriverAC() && busAux.HeatPumpTypeCoolingDriverCompartment == HeatPumpType.none && busAux.HeatPumpTypeHeatingDriverCompartment == HeatPumpType.none) + { + throw new VectoException("HVAC System Configuration {0} requires DriverAC Technology", hvacConfiguration); + } + + if (hvacConfiguration.RequiresPassengerAC() && busAux.HeatPumpTypeCoolingPassengerCompartment == HeatPumpType.none && busAux.HeatPumpTypeHeatingPassengerCompartment == HeatPumpType.none) + { + throw new VectoException("HVAC System Configuration {0} requires PassengerAC Technology", hvacConfiguration); + } + + + + var heatPumpTypeDriverCompartment = busAux.HeatPumpTypeCoolingPassengerCompartment.Value; + + var heatPumpTypePassengerCompartment = busAux.HeatPumpTypeCoolingPassengerCompartment.Value; + + var internalLength = hvacConfiguration == BusHVACSystemConfiguration.Configuration2 + ? 2 * Constants.BusParameters.DriverCompartmentLength // OK + : DeclarationData.BusAuxiliaries.CalculateInternalLength( + completedVehicle.Length, completedVehicle.VehicleCode, + completedVehicle.NumberPassengerSeatsLowerDeck.Value); + var correctionLengthDrivetrainVolume = DeclarationData.BusAuxiliaries.CorrectionLengthDrivetrainVolume( + completedVehicle.VehicleCode, completedVehicle.LowEntry, primaryVehicle.AxleConfiguration.NumAxles(), + primaryVehicle.Articulated); + + var internalHeight = DeclarationData.BusAuxiliaries.CalculateInternalHeight(completedVehicle.VehicleCode, completedVehicle.RegisteredClass, completedVehicle.Height); + var correctedBusWidth = DeclarationData.BusAuxiliaries.CorrectedBusWidth(completedVehicle.Width); + + var coolingPower = CalculateMaxCoolingPower(completedVehicle, primaryVehicle, mission); + + + var floorType = completedVehicle.VehicleCode.GetFloorType(); + + var ssmInputs = _primaryBusDataAdapter.GetDefaulSSMInputs(FuelData.Diesel); + + ssmInputs.BusFloorType = completedVehicle.VehicleCode.GetFloorType(); + ssmInputs.Technologies = CreateTechnologyBenefits(completedVehicle, primaryVehicle.Components.BusAuxiliaries); + ssmInputs.FuelFiredHeaterPower = busAux.AuxHeaterPower; + ssmInputs.BusWindowSurface = DeclarationData.BusAuxiliaries.WindowHeight(isDoubleDecker) * internalLength + + DeclarationData.BusAuxiliaries.FrontAndRearWindowArea(isDoubleDecker); + ssmInputs.BusSurfaceArea = 2 * (completedVehicle.Length * correctedBusWidth + internalLength * + internalHeight + (isDoubleDecker ? 2.0 : 1.0) * correctedBusWidth * completedVehicle.Height); // use equations sent by Tobias + ssmInputs.BusVolume = (internalLength - correctionLengthDrivetrainVolume) * correctedBusWidth * internalHeight; + + ssmInputs.UValue = DeclarationData.BusAuxiliaries.UValue(completedVehicle.VehicleCode.GetFloorType()); + ssmInputs.NumberOfPassengers = GetNumberOfPassengers( + mission, internalLength, correctedBusWidth, + completedVehicle.NumberPassengerSeatsLowerDeck.Value + completedVehicle.NumberPassengerSeatsUpperDeck.Value, + completedVehicle.NumberPassengersStandingLowerDeck.Value + completedVehicle.NumberPassengersStandingUpperDeck.Value, + loadingType) + 1; // add driver for 'heat input' + ssmInputs.VentilationRate = DeclarationData.BusAuxiliaries.VentilationRate(hvacConfiguration, false); + ssmInputs.VentilationRateHeating = DeclarationData.BusAuxiliaries.VentilationRate(hvacConfiguration, true); + + ssmInputs.HVACMaxCoolingPower = coolingPower.Item1 + coolingPower.Item2; + + //ToDo FK COP calculation + ssmInputs.HVACCompressorType = heatPumpTypePassengerCompartment; // use passenger compartment + ssmInputs.HVACTechnology = $"{busAux.SystemConfiguration.GetName()} " + + $"({string.Join(", ", heatPumpTypePassengerCompartment.GetName(), heatPumpTypeDriverCompartment.GetName())})"; + ssmInputs.COP = DeclarationData.BusAuxiliaries.CalculateCOP( + coolingPower.Item1, heatPumpTypeDriverCompartment, coolingPower.Item2, heatPumpTypePassengerCompartment /* average */, + floorType); + + return ssmInputs; + } + + + private TechnologyBenefits CreateTechnologyBenefits(IVehicleDeclarationInputData completedVehicle, + IBusAuxiliariesDeclarationData primaryBusAux) + { + var onVehicle = new List<SSMTechnology>(); + var completedBuxAux = completedVehicle.Components.BusAuxiliaries; + + foreach (var item in DeclarationData.BusAuxiliaries.SSMTechnologyList) + { + if ("Double-glazing".Equals(item.BenefitName, StringComparison.InvariantCultureIgnoreCase) && + (completedBuxAux?.HVACAux.DoubleGlazing ?? false)) + { + onVehicle.Add(item); + } + if ("Adjustable auxiliary heater".Equals(item.BenefitName, StringComparison.InvariantCultureIgnoreCase) && + (completedBuxAux?.HVACAux.AdjustableAuxiliaryHeater ?? false)) + { + onVehicle.Add(item); + } + if ("Separate air distribution ducts".Equals(item.BenefitName, StringComparison.InvariantCultureIgnoreCase) && + (completedBuxAux?.HVACAux.SeparateAirDistributionDucts ?? false)) + { + onVehicle.Add(item); + } + if ("Adjustable coolant thermostat".Equals(item.BenefitName, StringComparison.InvariantCultureIgnoreCase) && + (primaryBusAux?.HVACAux.AdjustableCoolantThermostat ?? false)) + { + onVehicle.Add(item); + } + if ("Engine waste gas heat exchanger".Equals(item.BenefitName, StringComparison.InvariantCultureIgnoreCase) && + (primaryBusAux?.HVACAux.EngineWasteGasHeatExchanger ?? false)) + { + onVehicle.Add(item); + } + } + + return _primaryBusDataAdapter.SelectBenefitForFloorType(completedVehicle.VehicleCode.GetFloorType(), onVehicle); + } + + protected Dictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry> GetElectricAuxConsumers(Mission mission, IVehicleDeclarationInputData vehicleData, VehicleClass vehicleClass, IBusAuxiliariesDeclarationData busAux) + { + return new Dictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry>(); + } + + protected virtual Dictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry> GetElectricAuxConsumersPrimary(Mission mission, IVehicleDeclarationInputData vehicleData, VehicleClass vehicleClass, IBusAuxiliariesDeclarationData busAuxPrimary) + { + var retVal = new Dictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry>(); + var spPower = DeclarationData.SteeringPumpBus.LookupElectricalPowerDemand( + mission.MissionType, busAuxPrimary.SteeringPumpTechnology, + vehicleData.Length ?? mission.BusParameter.VehicleLength); + retVal[Constants.Auxiliaries.IDs.SteeringPump] = new AuxiliaryDataAdapter.ElectricConsumerEntry + { + ActiveDuringEngineStopStandstill = false, + BaseVehicle = false, + Current = spPower / Constants.BusAuxiliaries.ElectricSystem.PowernetVoltage + }; + + var fanPower = vehicleData.VehicleType == VectoSimulationJobType.BatteryElectricVehicle + ? 0.SI<Watt>() + : DeclarationData.Fan.LookupElectricalPowerDemand( + vehicleClass, mission.MissionType, busAuxPrimary.FanTechnology); + retVal[Constants.Auxiliaries.IDs.Fan] = new AuxiliaryDataAdapter.ElectricConsumerEntry + { + ActiveDuringEngineStopStandstill = false, + ActiveDuringEngineStopDriving = false, + BaseVehicle = false, + Current = fanPower / Constants.BusAuxiliaries.ElectricSystem.PowernetVoltage + }; + return retVal; + } + + protected virtual ElectricsUserInputsConfig CreateElectricsUserInputsConfig(IVehicleDeclarationInputData primaryVehicle, + IVehicleDeclarationInputData completedVehicle, Mission mission, IActuations actuations, VehicleClass vehicleClass) + { + var currentDemand = _primaryBusDataAdapter.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)) + { + currentDemand[entry.Key] = entry.Value; + } + + var retVal = _primaryBusDataAdapter.GetDefaultElectricalUserConfig(); + + var primaryBusAuxiliaries = primaryVehicle.Components.BusAuxiliaries; + retVal.AlternatorType = primaryBusAuxiliaries.ElectricSupply.AlternatorTechnology; + retVal.ElectricalConsumers = (Dictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry>)currentDemand; + retVal.AlternatorMap = new SimpleAlternator( + _primaryBusDataAdapter.CalculateAlternatorEfficiency( + primaryBusAuxiliaries.ElectricSupply.Alternators + .Concat(completedVehicle.Components.BusAuxiliaries.ElectricSupply?.Alternators ?? + new List<IAlternatorDeclarationInputData>()).ToList())); + switch (retVal.AlternatorType) + { + case AlternatorType.Smart when primaryBusAuxiliaries.ElectricSupply.Alternators.Count == 0: + throw new VectoException("at least one alternator is required when specifying smart electrics!"); + case AlternatorType.Smart when primaryBusAuxiliaries.ElectricSupply.ElectricStorage.Count == 0: + throw new VectoException("at least one electric storage (battery or capacitor) is required when specifying smart electrics!"); + } + + retVal.MaxAlternatorPower = primaryBusAuxiliaries.ElectricSupply.Alternators.Sum(x => x.RatedVoltage * x.RatedCurrent); + retVal.ElectricStorageCapacity = primaryBusAuxiliaries.ElectricSupply.ElectricStorage.Sum(x => x.ElectricStorageCapacity) ?? 0.SI<WattSecond>(); + + return retVal; + } + #region Implementation of ICompletedBusAuxiliaryDataAdapter + + public IAuxiliaryConfig CreateBusAuxiliariesData(Mission mission, IVehicleDeclarationInputData primaryVehicle, + IVehicleDeclarationInputData completedVehicle, VectoRunData runData) + { + var actuations = DeclarationData.BusAuxiliaries.ActuationsMap.Lookup(runData.Mission.MissionType); + var primaryBusAuxiliaries = primaryVehicle.Components.BusAuxiliaries; + + return new AuxiliaryConfig + { + InputData = completedVehicle.Components.BusAuxiliaries, + ElectricalUserInputsConfig = CreateElectricsUserInputsConfig( + primaryVehicle, completedVehicle, mission, actuations, runData.VehicleData.VehicleClass), + PneumaticUserInputsConfig = CreatePneumaticUserInputsConfig( + primaryBusAuxiliaries, completedVehicle), + PneumaticAuxillariesConfig = _primaryBusDataAdapter.CreatePneumaticAuxConfig(runData.Retarder.Type), + Actuations = actuations, + SSMInputs = GetCompletedSSMInput(mission, completedVehicle, primaryVehicle, runData.Loading), + VehicleData = runData.VehicleData + }; + } + + #endregion + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AxleGearDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AxleGearDataAdapter.cs index 577e2922e0ee8f4957a16f1de6a453ecfce07012..de8a94b9f4c9557b4c0bfd61c89e9de19c84160e 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AxleGearDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/AxleGearDataAdapter.cs @@ -1,6 +1,7 @@ using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCore.InputData.Reader.ComponentData; +using TUGraz.VectoCore.Models.GenericModelData; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; @@ -12,7 +13,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen AxleGearData CreateDummyAxleGearData(IGearboxDeclarationInputData gbxData); } - public class AxleGearDataAdapterBase : IAxleGearDataAdapter + public class AxleGearDataAdapter : IAxleGearDataAdapter { public AxleGearData CreateDummyAxleGearData(IGearboxDeclarationInputData gbxData) { @@ -68,7 +69,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen AxleGear = new GearData { Ratio = data.Ratio } }; } - public AxleGearData CreateAxleGearData(IAxleGearInputData data) + public virtual AxleGearData CreateAxleGearData(IAxleGearInputData data) { var retVal = SetCommonAxleGearData(data); @@ -76,4 +77,16 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen return retVal; } } + + public class GenericCompletedBusAxleGearDataAdapter : AxleGearDataAdapter + { + #region Overrides of AxleGearDataAdapterBase + private readonly GenericTransmissionComponentData _genericPowertrainData = new GenericTransmissionComponentData(); + public override AxleGearData CreateAxleGearData(IAxleGearInputData data) + { + return _genericPowertrainData.CreateGenericBusAxlegearData(data); + } + + #endregion + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/EngineDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/EngineDataAdapter.cs index 7fdf303ac1c9a8f347782b627fa9e5d269f03421..c085e1e886544087db0923f6fb1a4275d4c7c66f 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/EngineDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/EngineDataAdapter.cs @@ -15,8 +15,10 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen { public interface IEngineDataAdapter { - CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, + CombustionEngineData CreateEngineData(IVehicleDeclarationInputData primaryVehicle, IEngineModeDeclarationInputData mode, Mission mission); + + CombustionEngineData CreateEngineData(IVehicleDeclarationInputData primaryVehicle, int modeIdx, Mission mission); } public abstract class EngineComponentDataAdapter : ComponentDataAdapterBase, IEngineDataAdapter { @@ -142,13 +144,16 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen #region Implementation of IEngineDataAdapter - public CombustionEngineData CreateEngineData(IVehicleDeclarationInputData vehicle, IEngineModeDeclarationInputData mode, + public CombustionEngineData CreateEngineData(IVehicleDeclarationInputData primaryVehicle, IEngineModeDeclarationInputData mode, Mission mission) { - CheckDeclarationMode(vehicle.Components.EngineInputData, "EngineData"); - return DoCreateEngineData(vehicle, mode, mission); + CheckDeclarationMode(primaryVehicle.Components.EngineInputData, "EngineData"); + return DoCreateEngineData(primaryVehicle, mode, mission); } + public abstract CombustionEngineData CreateEngineData(IVehicleDeclarationInputData primaryVehicle, int modeIdx, + Mission mission); + protected abstract CombustionEngineData DoCreateEngineData(IVehicleDeclarationInputData vehicle, IEngineModeDeclarationInputData mode, Mission mission); #endregion @@ -158,6 +163,11 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen { #region Overrides of EngineDataAdapter + public override CombustionEngineData CreateEngineData(IVehicleDeclarationInputData primaryVehicle, int modeIdx, Mission mission) + { + throw new NotImplementedException(); + } + protected override CombustionEngineData DoCreateEngineData(IVehicleDeclarationInputData vehicle, IEngineModeDeclarationInputData mode, Mission mission) { var engine = vehicle.Components.EngineInputData; @@ -219,6 +229,26 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen return retVal; } + + #endregion + } + + public class GenericCombustionEngineComponentDataAdapter : EngineComponentDataAdapter + { + GenericBusEngineData busEngineData = GenericBusEngineData.Instance; + #region Overrides of EngineComponentDataAdapter + + protected override CombustionEngineData DoCreateEngineData(IVehicleDeclarationInputData vehicle, IEngineModeDeclarationInputData mode, + Mission mission) + { + throw new NotImplementedException(); + } + + public override CombustionEngineData CreateEngineData(IVehicleDeclarationInputData primaryVehicle, int modeIdx, Mission mission) + { + return busEngineData.CreateGenericBusEngineData(primaryVehicle, modeIdx, mission); + } + #endregion } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/GearBoxDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/GearBoxDataAdapter.cs index 6a13d24eaa6cd217e3cc29017611d7e78bd10069..5c4165c7b91db733bad93fdf3a14eb51c3e4aa03 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/GearBoxDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/GearBoxDataAdapter.cs @@ -52,7 +52,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen return null; } - public static void CreateTCSecondGearATSerial(GearData gearData, + protected static void CreateTCSecondGearATSerial(GearData gearData, ShiftPolygon shiftPolygon) { gearData.TorqueConverterRatio = gearData.Ratio; @@ -60,7 +60,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen gearData.TorqueConverterShiftPolygon = shiftPolygon; } - public static void CreateTCFirstGearATSerial(GearData gearData, + protected static void CreateTCFirstGearATSerial(GearData gearData, ShiftPolygon shiftPolygon) { gearData.TorqueConverterRatio = gearData.Ratio; @@ -68,7 +68,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen gearData.TorqueConverterShiftPolygon = shiftPolygon; } - public static void CretateTCFirstGearATPowerSplit(GearData gearData, uint i, ShiftPolygon shiftPolygon) + protected virtual void CretateTCFirstGearATPowerSplit(GearData gearData, uint i, ShiftPolygon shiftPolygon) { gearData.TorqueConverterRatio = 1; gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(1, 1, $"TCGear {i + 1}"); @@ -108,7 +108,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen } } - public static TransmissionLossMap CreateGearLossMap(ITransmissionInputData gear, uint i, + protected virtual TransmissionLossMap CreateGearLossMap(ITransmissionInputData gear, uint i, bool useEfficiencyFallback, VehicleCategory vehicleCategory, GearboxType gearboxType) { if (gear.LossMap != null) @@ -380,4 +380,39 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen #endregion } + + public class GenericCompletedBusGearboxDataAdapter : GearboxDataAdapter + { + public const double GearEfficiencyDirectGear = 0.98; + public const double GearEfficiencyIndirectGear = 0.96; + public const double GearEfficiencyAT = 0.925; + public GenericCompletedBusGearboxDataAdapter(ITorqueConverterDataAdapter torqueConverterDataAdapter) : base( + torqueConverterDataAdapter) + { + + } + + #region Overrides of GearboxDataAdapterBase + + protected override TransmissionLossMap CreateGearLossMap(ITransmissionInputData gear, uint i, bool useEfficiencyFallback, + VehicleCategory vehicleCategory, GearboxType gearboxType) + { + if (gearboxType.AutomaticTransmission()) + { + return TransmissionLossMapReader.Create(GearEfficiencyAT, gear.Ratio, $"Gear {i + 1}"); + } + return TransmissionLossMapReader.Create( + gear.Ratio.IsEqual(1) ? GearEfficiencyDirectGear : GearEfficiencyIndirectGear, gear.Ratio, $"Gear {i + 1}"); + } + + protected override void CretateTCFirstGearATPowerSplit(GearData gearData, uint i, ShiftPolygon shiftPolygon) + { + gearData.TorqueConverterRatio = 1; + //gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(GearEfficiencyIndirectGear, 1, string.Format("TCGear {0}", i + 1)); + gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(1.0, 1, $"TCGear {i + 1}"); + gearData.TorqueConverterShiftPolygon = shiftPolygon; + } + + #endregion + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/PTODataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/PTODataAdapter.cs index 49f5ba37410120712c92993eebd23cf4262aee7d..10cc5407c7001af852cdc7d0ab1ec04b049cfa6f 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/PTODataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/PTODataAdapter.cs @@ -1,17 +1,35 @@ using TUGraz.VectoCommon.InputData; using TUGraz.VectoCore.InputData.Reader.ComponentData; +using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponents { public interface IPTODataAdapter { PTOData CreatePTOTransmissionData(IPTOTransmissionInputData pto); + PTOData CreateDefaultPTOData(); } public class PTODataAdapterLorry : IPTODataAdapter { - public PTOData CreatePTOTransmissionData(IPTOTransmissionInputData pto) + public static PTOData DefaultPTOData() + { + return new PTOData() + { + TransmissionType = DeclarationData.PTO.DefaultPTOTechnology, + LossMap = PTOIdleLossMapReader.ReadFromStream(RessourceHelper.ReadStream(DeclarationData.PTO.DefaultPTOIdleLosses)), + PTOCycle = + DrivingCycleDataReader.ReadFromStream(RessourceHelper.ReadStream(DeclarationData.PTO.DefaultPTOActivationCycle), + CycleType.PTO, "PTO", false) + }; + } + public PTOData CreateDefaultPTOData() + { + return DefaultPTOData(); + } + public PTOData CreatePTOTransmissionData(IPTOTransmissionInputData pto) { if (pto != null && pto.PTOTransmissionType != "None") { @@ -35,6 +53,11 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen return null; } + public PTOData CreateDefaultPTOData() + { + return null; + } + #endregion } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/VehicleDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/VehicleDataAdapter.cs index 669bdec7ec9fba448993f34aeb72515ce332e879..78187121ddbbfedbc79aef1b4cc0f9af87dba80a 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/VehicleDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/SimulationComponents/VehicleDataAdapter.cs @@ -1,4 +1,5 @@  +using System; using System.Collections.Generic; using System.Linq; using TUGraz.VectoCommon.Exceptions; @@ -70,6 +71,15 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen CheckDeclarationMode(data, "Vehicle"); return DoCreateVehicleData(data, segment, mission, loading, passengerCount, allowVocational); } + public VehicleData CreateVehicleData(IVehicleDeclarationInputData data, + Segment segment, + Mission mission, + KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, + bool allowVocational) + { + CheckDeclarationMode(data, "Vehicle"); + return DoCreateVehicleData(data, segment, mission, loading.Value.Item1, loading.Value.Item2, allowVocational); + } protected abstract VehicleData DoCreateVehicleData(IVehicleDeclarationInputData data, Segment segment, Mission mission, @@ -244,4 +254,34 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponen } } + + internal class CompletedBusGenericVehicleDataAdapter : PrimaryBusVehicleDataAdapter + { + #region Overrides of PrimaryBusVehicleDataAdapter + + protected override VehicleData DoCreateVehicleData(IVehicleDeclarationInputData data, Segment segment, Mission mission, Kilogram loading, + double? passengerCount, bool allowVocational) + { + var retVal = base.DoCreateVehicleData(data, segment, mission, loading, passengerCount, allowVocational); + retVal.GrossVehicleMass = data.GrossVehicleMassRating; + if (retVal.TotalVehicleMass.IsGreater(retVal.GrossVehicleMass)) + { + throw new VectoException("Total Vehicle Mass exceeds Gross Vehicle Mass for completed bus generic ({0}/{1})", retVal.TotalVehicleMass, retVal.GrossVehicleMass); + } + return retVal; + } + + protected override VehicleData DoCreateExemptedVehicleData(IVehicleDeclarationInputData data) + { + var retVal = base.DoCreateExemptedVehicleData(data); + retVal.GrossVehicleMass = data.GrossVehicleMassRating; + if (retVal.TotalVehicleMass.IsGreater(retVal.GrossVehicleMass)) + { + throw new VectoException("Total Vehicle Mass exceeds Gross Vehicle Mass for completed bus generic ({0}/{1})", retVal.TotalVehicleMass, retVal.GrossVehicleMass); + } + return retVal; + } + + #endregion + } } diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/AbstractDeclarationVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/AbstractDeclarationVectoRunDataFactory.cs index d138beed0a31644ce709185ff8864306c5dfbf7c..43805804f704a73881c7b70d11ba5b93480b529f 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/AbstractDeclarationVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/AbstractDeclarationVectoRunDataFactory.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data.Common; using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; @@ -22,7 +23,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl { protected readonly IDeclarationInputDataProvider InputDataProvider; protected IDeclarationReport Report; - protected abstract IDeclarationDataAdapter DataAdapter { get; } + //protected abstract IDeclarationDataAdapter DataAdapter { get; } protected Segment _segment; @@ -77,17 +78,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl { protected abstract IEnumerable<VectoRunData> GetNextRun(); - protected virtual void Initialize() - { - var vehicle = InputDataProvider.JobInputData.Vehicle; - if (vehicle.ExemptedVehicle) { - return; - } - - - } - - protected abstract Segment GetSegment(IVehicleDeclarationInputData vehicle); + protected abstract void Initialize(); protected abstract VectoRunData CreateVectoRunData(IVehicleDeclarationInputData vehicle, int modeIdx, Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading); @@ -110,15 +101,15 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl { Report.InitializeReport(powertrainConfig, fuels); } - protected virtual PTOData CreateDefaultPTOData() - { - return new PTOData() { - TransmissionType = DeclarationData.PTO.DefaultPTOTechnology, - LossMap = PTOIdleLossMapReader.ReadFromStream(RessourceHelper.ReadStream(DeclarationData.PTO.DefaultPTOIdleLosses)), - PTOCycle = - DrivingCycleDataReader.ReadFromStream(RessourceHelper.ReadStream(DeclarationData.PTO.DefaultPTOActivationCycle), - CycleType.PTO, "PTO", false) - }; - } + //protected virtual PTOData CreateDefaultPTOData() + //{ + // return new PTOData() { + // TransmissionType = DeclarationData.PTO.DefaultPTOTechnology, + // LossMap = PTOIdleLossMapReader.ReadFromStream(RessourceHelper.ReadStream(DeclarationData.PTO.DefaultPTOIdleLosses)), + // PTOCycle = + // DrivingCycleDataReader.ReadFromStream(RessourceHelper.ReadStream(DeclarationData.PTO.DefaultPTOActivationCycle), + // CycleType.PTO, "PTO", false) + // }; + //} } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/CompletedBusRunDataFactory/DeclarationModeCompletedBusRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/CompletedBusRunDataFactory/DeclarationModeCompletedBusRunDataFactory.cs index 0b0a945eddb7d2525b8c073d9819806e352e83da..9e3b7c9f97e7f2bbc59410e6b8086f872f8e5de5 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/CompletedBusRunDataFactory/DeclarationModeCompletedBusRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/CompletedBusRunDataFactory/DeclarationModeCompletedBusRunDataFactory.cs @@ -1,8 +1,17 @@ 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.DeclarationMode.CompletedBusRunDataFactory @@ -11,94 +20,358 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.CompletedBusRun { public abstract class CompletedBusBase : IVectoRunDataFactory { - public IDeclarationDataAdapter GenericDataAdapter { get; } - public IDeclarationDataAdapter SpecificDataAdapter { get; } - public IMultistageVIFInputData DataProvider { get; } + private Segment _segmentCompletedBus; + private AxleGearData _axlegearData; + private AngledriveData _angledriveData; + private GearboxData _gearboxData; + private ShiftStrategyParameters _gearshiftData; + private RetarderData _retarderData; + private DriverData _driverData + ; + public IGenericCompletedBusDeclarationDataAdapter DataAdapterGeneric { get; } + public ISpecificCompletedBusDeclarationDataAdapter DataAdapterSpecific { get; } + protected IMultistageVIFInputData DataProvider { get; } + protected IDeclarationReport Report { get; set; } + protected IVehicleDeclarationInputData PrimaryVehicle => DataProvider.MultistageJobInputData.JobInputData.PrimaryVehicle.Vehicle; + protected IVehicleDeclarationInputData CompletedVehicle => DataProvider.MultistageJobInputData.JobInputData.ConsolidateManufacturingStage.Vehicle; - public CompletedBusBase(IMultistageVIFInputData dataProvider, - ISpecificCompletedBusDataAdapter specificDataAdapter, - IGenericCompletedBusDataAdapter genericDataAdapter) + public CompletedBusBase(IMultistageVIFInputData dataProvider, IDeclarationReport report, + ISpecificCompletedBusDeclarationDataAdapter dataAdapterSpecific, + IGenericCompletedBusDeclarationDataAdapter dataAdapterGeneric) { - SpecificDataAdapter = specificDataAdapter; - GenericDataAdapter = genericDataAdapter; + DataAdapterSpecific = dataAdapterSpecific; + DataAdapterGeneric = dataAdapterGeneric; DataProvider = dataProvider; + Report = report; } - + #region Implementation of IVectoRunDataFactory + 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>>()); + } + + private VectoRunData GetExemptedVectoRunData() { throw new NotImplementedException(); } + protected virtual IEnumerable<VectoRunData> GetNextRun() + { + if (PrimaryVehicle.ExemptedVehicle) + { + //return new[] { GetExemptedVectoRunData() }; + } + + return VectoRunDataHeavyBusCompleted(); + } + protected virtual IEnumerable<VectoRunData> VectoRunDataHeavyBusCompleted() + { + + + var engineModes = PrimaryVehicle.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; + } + + } + 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 = DataProvider.MultistageJobInputData.JobInputData.ManufacturingStages.Last().Vehicle.Identifier, + ModFileSuffix = $"_{_segmentCompletedBus.VehicleClass.GetClassNumber()}-Generic_{loading.Key}", + Report = Report, + Mission = mission, + InputDataHash = DataProvider.MultistageJobInputData.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; + } + 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 = DataProvider.MultistageJobInputData.JobInputData.ManufacturingStages.Last().Vehicle.Identifier,//?!? Jobname + ModFileSuffix = $"_{_segmentCompletedBus.VehicleClass.GetClassNumber()}-Specific_{loading.Key}", + Report = Report, + Mission = mission, + InputDataHash = DataProvider.MultistageJobInputData.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 Segment GetPrimarySegment(IVehicleDeclarationInputData primaryVehicle) + { + var primarySegment = DeclarationData.PrimaryBusSegments.Lookup( + primaryVehicle.VehicleCategory, primaryVehicle.AxleConfiguration, primaryVehicle.Articulated); + + return primarySegment; + } + + + 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 = DataProvider.MultistageJobInputData.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 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; + } #endregion - } + 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); + } + + + } public class Conventional : CompletedBusBase { - public Conventional(IMultistageVIFInputData dataProvider, - ISpecificCompletedBusDataAdapter specificDataAdapter, - IGenericCompletedBusDataAdapter genericDataAdapter) : base(dataProvider, specificDataAdapter, - genericDataAdapter) { } + public Conventional(IMultistageVIFInputData dataProvider, IDeclarationReport report, + ISpecificCompletedBusDeclarationDataAdapter dataAdapterSpecific, + IGenericCompletedBusDeclarationDataAdapter dataAdapterGeneric) : base(dataProvider, report, dataAdapterSpecific, + dataAdapterGeneric) { } } public class HEV_S2 : CompletedBusBase { - public HEV_S2(IMultistageVIFInputData dataProvider, ISpecificCompletedBusDataAdapter specificDataAdapter, IGenericCompletedBusDataAdapter genericDataAdapter) : base(dataProvider, specificDataAdapter, genericDataAdapter) { } + public HEV_S2(IMultistageVIFInputData dataProvider, IDeclarationReport report, ISpecificCompletedBusDeclarationDataAdapter dataAdapterSpecific, IGenericCompletedBusDeclarationDataAdapter dataAdapterGeneric) : base(dataProvider, report, dataAdapterSpecific, dataAdapterGeneric) { } } public class HEV_S3 : CompletedBusBase { - public HEV_S3(IMultistageVIFInputData dataProvider, ISpecificCompletedBusDataAdapter specificDataAdapter, IGenericCompletedBusDataAdapter genericDataAdapter) : base(dataProvider, specificDataAdapter, genericDataAdapter) { } + public HEV_S3(IMultistageVIFInputData dataProvider, IDeclarationReport report, ISpecificCompletedBusDeclarationDataAdapter dataAdapterSpecific, IGenericCompletedBusDeclarationDataAdapter dataAdapterGeneric) : base(dataProvider, report, dataAdapterSpecific, dataAdapterGeneric) { } } public class HEV_S4 : CompletedBusBase { - public HEV_S4(IMultistageVIFInputData dataProvider, ISpecificCompletedBusDataAdapter specificDataAdapter, IGenericCompletedBusDataAdapter genericDataAdapter) : base(dataProvider, specificDataAdapter, genericDataAdapter) { } + public HEV_S4(IMultistageVIFInputData dataProvider, IDeclarationReport report, ISpecificCompletedBusDeclarationDataAdapter dataAdapterSpecific, IGenericCompletedBusDeclarationDataAdapter dataAdapterGeneric) : base(dataProvider, report, dataAdapterSpecific, dataAdapterGeneric) { } } public class HEV_S_IEPC : CompletedBusBase { - public HEV_S_IEPC(IMultistageVIFInputData dataProvider, ISpecificCompletedBusDataAdapter specificDataAdapter, IGenericCompletedBusDataAdapter genericDataAdapter) : base(dataProvider, specificDataAdapter, genericDataAdapter) { } + public HEV_S_IEPC(IMultistageVIFInputData dataProvider, IDeclarationReport report, ISpecificCompletedBusDeclarationDataAdapter dataAdapterSpecific, IGenericCompletedBusDeclarationDataAdapter dataAdapterGeneric) : base(dataProvider, report, dataAdapterSpecific, dataAdapterGeneric) { } } public class HEV_P1 : CompletedBusBase { - public HEV_P1(IMultistageVIFInputData dataProvider, ISpecificCompletedBusDataAdapter specificDataAdapter, IGenericCompletedBusDataAdapter genericDataAdapter) : base(dataProvider, specificDataAdapter, genericDataAdapter) { } + public HEV_P1(IMultistageVIFInputData dataProvider, IDeclarationReport report, ISpecificCompletedBusDeclarationDataAdapter dataAdapterSpecific, IGenericCompletedBusDeclarationDataAdapter dataAdapterGeneric) : base(dataProvider, report, dataAdapterSpecific, dataAdapterGeneric) { } } public class HEV_P2 : CompletedBusBase { - public HEV_P2(IMultistageVIFInputData dataProvider, ISpecificCompletedBusDataAdapter specificDataAdapter, IGenericCompletedBusDataAdapter genericDataAdapter) : base(dataProvider, specificDataAdapter, genericDataAdapter) { } + public HEV_P2(IMultistageVIFInputData dataProvider, IDeclarationReport report, ISpecificCompletedBusDeclarationDataAdapter dataAdapterSpecific, IGenericCompletedBusDeclarationDataAdapter dataAdapterGeneric) : base(dataProvider, report, dataAdapterSpecific, dataAdapterGeneric) { } } public class HEV_P2_5 : CompletedBusBase { - public HEV_P2_5(IMultistageVIFInputData dataProvider, ISpecificCompletedBusDataAdapter specificDataAdapter, IGenericCompletedBusDataAdapter genericDataAdapter) : base(dataProvider, specificDataAdapter, genericDataAdapter) { } + public HEV_P2_5(IMultistageVIFInputData dataProvider, IDeclarationReport report, ISpecificCompletedBusDeclarationDataAdapter dataAdapterSpecific, IGenericCompletedBusDeclarationDataAdapter dataAdapterGeneric) : base(dataProvider, report, dataAdapterSpecific, dataAdapterGeneric) { } } public class HEV_P3 : CompletedBusBase { - public HEV_P3(IMultistageVIFInputData dataProvider, ISpecificCompletedBusDataAdapter specificDataAdapter, IGenericCompletedBusDataAdapter genericDataAdapter) : base(dataProvider, specificDataAdapter, genericDataAdapter) { } + public HEV_P3(IMultistageVIFInputData dataProvider, IDeclarationReport report, ISpecificCompletedBusDeclarationDataAdapter dataAdapterSpecific, IGenericCompletedBusDeclarationDataAdapter dataAdapterGeneric) : base(dataProvider, report, dataAdapterSpecific, dataAdapterGeneric) { } } public class HEV_P4 : CompletedBusBase { - public HEV_P4(IMultistageVIFInputData dataProvider, ISpecificCompletedBusDataAdapter specificDataAdapter, IGenericCompletedBusDataAdapter genericDataAdapter) : base(dataProvider, specificDataAdapter, genericDataAdapter) { } + public HEV_P4(IMultistageVIFInputData dataProvider, IDeclarationReport report, ISpecificCompletedBusDeclarationDataAdapter dataAdapterSpecific, IGenericCompletedBusDeclarationDataAdapter dataAdapterGeneric) : base(dataProvider, report, dataAdapterSpecific, dataAdapterGeneric) { } } public class PEV_E1 : CompletedBusBase { - public PEV_E1(IMultistageVIFInputData dataProvider, ISpecificCompletedBusDataAdapter specificDataAdapter, IGenericCompletedBusDataAdapter genericDataAdapter) : base(dataProvider, specificDataAdapter, genericDataAdapter) { } + public PEV_E1(IMultistageVIFInputData dataProvider, IDeclarationReport report, ISpecificCompletedBusDeclarationDataAdapter dataAdapterSpecific, IGenericCompletedBusDeclarationDataAdapter dataAdapterGeneric) : base(dataProvider, report, dataAdapterSpecific, dataAdapterGeneric) { } } public class PEV_E2 : CompletedBusBase { - public PEV_E2(IMultistageVIFInputData dataProvider, ISpecificCompletedBusDataAdapter specificDataAdapter, IGenericCompletedBusDataAdapter genericDataAdapter) : base(dataProvider, specificDataAdapter, genericDataAdapter) { } + public PEV_E2(IMultistageVIFInputData dataProvider, IDeclarationReport report, ISpecificCompletedBusDeclarationDataAdapter dataAdapterSpecific, IGenericCompletedBusDeclarationDataAdapter dataAdapterGeneric) : base(dataProvider, report, dataAdapterSpecific, dataAdapterGeneric) { } } public class PEV_E3 : CompletedBusBase { - public PEV_E3(IMultistageVIFInputData dataProvider, ISpecificCompletedBusDataAdapter specificDataAdapter, IGenericCompletedBusDataAdapter genericDataAdapter) : base(dataProvider, specificDataAdapter, genericDataAdapter) { } + public PEV_E3(IMultistageVIFInputData dataProvider, IDeclarationReport report, ISpecificCompletedBusDeclarationDataAdapter dataAdapterSpecific, IGenericCompletedBusDeclarationDataAdapter dataAdapterGeneric) : base(dataProvider, report, dataAdapterSpecific, dataAdapterGeneric) { } } public class PEV_E4 : CompletedBusBase { - public PEV_E4(IMultistageVIFInputData dataProvider, ISpecificCompletedBusDataAdapter specificDataAdapter, IGenericCompletedBusDataAdapter genericDataAdapter) : base(dataProvider, specificDataAdapter, genericDataAdapter) { } + public PEV_E4(IMultistageVIFInputData dataProvider, IDeclarationReport report, ISpecificCompletedBusDeclarationDataAdapter dataAdapterSpecific, IGenericCompletedBusDeclarationDataAdapter dataAdapterGeneric) : base(dataProvider, report, dataAdapterSpecific, dataAdapterGeneric) { } } public class PEV_E_IEPC : CompletedBusBase { - public PEV_E_IEPC(IMultistageVIFInputData dataProvider, ISpecificCompletedBusDataAdapter specificDataAdapter, IGenericCompletedBusDataAdapter genericDataAdapter) : base(dataProvider, specificDataAdapter, genericDataAdapter) { } + public PEV_E_IEPC(IMultistageVIFInputData dataProvider, IDeclarationReport report, ISpecificCompletedBusDeclarationDataAdapter dataAdapterSpecific, IGenericCompletedBusDeclarationDataAdapter dataAdapterGeneric) : base(dataProvider, report, dataAdapterSpecific, dataAdapterGeneric) { } + } + + public class Exempted : CompletedBusBase + { + public Exempted(IMultistageVIFInputData dataProvider, IDeclarationReport report, ISpecificCompletedBusDeclarationDataAdapter dataAdapterSpecific, IGenericCompletedBusDeclarationDataAdapter dataAdapterGeneric) : base(dataProvider, report, dataAdapterSpecific, dataAdapterGeneric) { } } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/HeavyLorryRunDataFactory/DeclarationModeHeavyLorryRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/HeavyLorryRunDataFactory/DeclarationModeHeavyLorryRunDataFactory.cs index 306d54111588a4e67854b3be296b5f769744d713..214155f6d1ddb9f9f7e455c2b9396be656f79e32 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/HeavyLorryRunDataFactory/DeclarationModeHeavyLorryRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/HeavyLorryRunDataFactory/DeclarationModeHeavyLorryRunDataFactory.cs @@ -7,6 +7,7 @@ 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.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; @@ -19,14 +20,143 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDa { public abstract partial class DeclarationModeHeavyLorryRunDataFactory { - + public abstract class LorryBase : AbstractDeclarationVectoRunDataFactory + { + public ILorryDeclarationDataAdapter DataAdapter { get; } + public IDeclarationInputDataProvider InputDataProvider { get; } + public IDeclarationReport Report { get; } + + protected Segment _segment; + protected DriverData _driverdata; + protected AirdragData _airdragData; + protected AxleGearData _axlegearData; + protected AngledriveData _angledriveData; + protected GearboxData _gearboxData; + protected RetarderData _retarderData; + protected PTOData _ptoTransmissionData; + protected PTOData _municipalPtoTransmissionData; + protected ShiftStrategyParameters _gearshiftData; + private bool _allowVocational; + + + protected LorryBase(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + ILorryDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, false) + { + DataAdapter = declarationDataAdapter; + InputDataProvider = dataProvider; + Report = report; + } + + protected override void Initialize() + { + var vehicle = InputDataProvider.JobInputData.Vehicle; + if (vehicle.ExemptedVehicle) + { + return; + } + + _segment = GetSegment(vehicle); + _driverdata = DataAdapter.CreateDriverData(); + _driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(_segment.AccelerationFile); + var tempVehicle = DataAdapter.CreateVehicleData(vehicle, _segment, _segment.Missions.First(), + _segment.Missions.First().Loadings.First(), _allowVocational); + _airdragData = DataAdapter.CreateAirdragData(vehicle.Components.AirdragInputData, + _segment.Missions.First(), _segment); + if (InputDataProvider.JobInputData.Vehicle.AxleConfiguration.AxlegearIncludedInGearbox()) + { + _axlegearData = DataAdapter.CreateDummyAxleGearData(InputDataProvider.JobInputData.Vehicle.Components.GearboxInputData); + } + else + { + _axlegearData = DataAdapter.CreateAxleGearData(InputDataProvider.JobInputData.Vehicle.Components.AxleGearInputData); + } + _angledriveData = DataAdapter.CreateAngledriveData(InputDataProvider.JobInputData.Vehicle.Components.AngledriveInputData); + var tmpRunData = new VectoRunData() + { + GearboxData = new GearboxData() + { + Type = vehicle.Components.GearboxInputData.Type, + } + }; + var tmpStrategy = PowertrainBuilder.GetShiftStrategy(new SimplePowertrainContainer(tmpRunData)); + var tmpEngine = DataAdapter.CreateEngineData( + vehicle, vehicle.Components.EngineInputData.EngineModes[0], _segment.Missions.First()); + _gearboxData = DataAdapter.CreateGearboxData( + vehicle, new VectoRunData() { EngineData = tmpEngine, AxleGearData = _axlegearData, VehicleData = tempVehicle }, + tmpStrategy); + + _retarderData = DataAdapter.CreateRetarderData(vehicle.Components.RetarderInputData); + + _ptoTransmissionData = DataAdapter.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData); + + _municipalPtoTransmissionData = PTODataAdapterLorry.DefaultPTOData(); + _gearshiftData = DataAdapter.CreateGearshiftData( + _gearboxData, _axlegearData.AxleGear.Ratio * (_angledriveData?.Angledrive.Ratio ?? 1.0), tmpEngine.IdleSpeed); + + } + #region Implementation of IVectoRunDataFactory + + public IEnumerable<VectoRunData> NextRun() + { + Initialize(); + if (Report != null) + { + InitializeReport(); + } + + return GetNextRun(); + } + + protected Segment GetSegment(IVehicleDeclarationInputData vehicle) + { + _allowVocational = true; + Segment segment; + try + { + segment = DeclarationData.TruckSegments.Lookup( + vehicle.VehicleCategory, vehicle.AxleConfiguration, vehicle.GrossVehicleMassRating, + vehicle.CurbMassChassis, + vehicle.VocationalVehicle); + } + catch (VectoException) + { + _allowVocational = false; + segment = DeclarationData.TruckSegments.Lookup( + vehicle.VehicleCategory, vehicle.AxleConfiguration, vehicle.GrossVehicleMassRating, + vehicle.CurbMassChassis, + false); + } + + if (!segment.Found) + { + throw new VectoException( + "no segment found for vehicle configuration: vehicle category: {0}, axle configuration: {1}, GVMR: {2}", + vehicle.VehicleCategory, vehicle.AxleConfiguration, + vehicle.GrossVehicleMassRating); + } + return segment; + } + + protected override VectoRunData CreateVectoRunData(IVehicleDeclarationInputData vehicle, int modeIdx, + Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading) + { + throw new NotImplementedException(); + } + + + protected override IEnumerable<VectoRunData> GetNextRun() + { + throw new NotImplementedException(); + } + #endregion + } + public sealed class Conventional : LorryBase { public Conventional(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + ILorryDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } #region Overrides of LorryBase - protected override IEnumerable<VectoRunData> GetNextRun() { var vehicle = InputDataProvider.JobInputData.Vehicle; @@ -42,15 +172,16 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDa } foreach (var loading in mission.Loadings) { - var simulationRunData = CreateVectoRunData(vehicle, modeIdx, mission, loading, true); + 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, bool allowVocational) + KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading) { var engine = InputDataProvider.JobInputData.Vehicle.Components.EngineInputData; var engineModes = engine.EngineModes; @@ -61,7 +192,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDa var simulationRunData = new VectoRunData { Loading = loading.Key, - VehicleData = DataAdapter.CreateVehicleData(vehicle, _segment, mission, loading, allowVocational), + VehicleData = DataAdapter.CreateVehicleData(vehicle, _segment, mission, loading, _allowVocational), VehicleDesignSpeed = _segment.DesignSpeed, AirdragData = DataAdapter.CreateAirdragData(vehicle.Components.AirdragInputData, mission, _segment), EngineData = @@ -99,269 +230,89 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDa } #endregion } + public class HEV_S2 : LorryBase + { + public HEV_S2(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + ILorryDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + } + + public class HEV_S3 : LorryBase + { + public HEV_S3(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, + ILorryDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + } public class HEV_S4 : LorryBase { public HEV_S4(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + ILorryDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } } public class HEV_S_IEPC : LorryBase { public HEV_S_IEPC(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + ILorryDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } } public class HEV_P1 : LorryBase { public HEV_P1(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + ILorryDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } } public class HEV_P2 : LorryBase { public HEV_P2(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + ILorryDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } } public class HEV_P2_5 : LorryBase { public HEV_P2_5(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + ILorryDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } } public class HEV_P3 : LorryBase { public HEV_P3(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + ILorryDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } } public class HEV_P4 : LorryBase { public HEV_P4(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + ILorryDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } } public class PEV_E2 : LorryBase { public PEV_E2(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + ILorryDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } } public class PEV_E3 : LorryBase { public PEV_E3(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + ILorryDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } } public class PEV_E4 : LorryBase { public PEV_E4(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + ILorryDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } } public class PEV_E_IEPC : LorryBase { public PEV_E_IEPC(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + ILorryDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } } public class Exempted : LorryBase { public Exempted(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } - } - } - - public abstract partial class DeclarationModeHeavyLorryRunDataFactory - { - public class HEV_S3 : LorryBase - { - public HEV_S3(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } - } - } - - public abstract partial class DeclarationModeHeavyLorryRunDataFactory - { - public class HEV_S2 : LorryBase - { - public HEV_S2(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } - } - - } - - /// <summary> - /// This class is just used to improve the readability - /// </summary> - public abstract partial class DeclarationModeHeavyLorryRunDataFactory - { - public abstract class LorryBase : IVectoRunDataFactory - { - public IDeclarationDataAdapter DataAdapter { get; } - public IDeclarationInputDataProvider InputDataProvider { get; } - public IDeclarationReport Report { get; } - - protected Segment _segment; - protected DriverData _driverdata; - protected AirdragData _airdragData; - protected AxleGearData _axlegearData; - protected AngledriveData _angledriveData; - protected GearboxData _gearboxData; - protected RetarderData _retarderData; - protected PTOData _ptoTransmissionData; - protected PTOData _municipalPtoTransmissionData; - protected ShiftStrategyParameters _gearshiftData; - private bool _allowVocational; - - - protected LorryBase(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) - { - DataAdapter = declarationDataAdapter; - InputDataProvider = dataProvider; - Report = report; - } - - - #region Implementation of IVectoRunDataFactory - - public IEnumerable<VectoRunData> NextRun() - { - Initialize(); - if (Report != null) { - InitializeReport(); - } - - return GetNextRun(); - } - - public Segment GetSegment(IVehicleDeclarationInputData vehicle, out bool allowVocational) - { - allowVocational = true; - Segment segment; - try { - segment = DeclarationData.TruckSegments.Lookup( - vehicle.VehicleCategory, vehicle.AxleConfiguration, vehicle.GrossVehicleMassRating, - vehicle.CurbMassChassis, - vehicle.VocationalVehicle); - } catch (VectoException) { - allowVocational = false; - segment = DeclarationData.TruckSegments.Lookup( - vehicle.VehicleCategory, vehicle.AxleConfiguration, vehicle.GrossVehicleMassRating, - vehicle.CurbMassChassis, - false); - } - - if (!segment.Found) { - throw new VectoException( - "no segment found for vehicle configuration: vehicle category: {0}, axle configuration: {1}, GVMR: {2}", - vehicle.VehicleCategory, vehicle.AxleConfiguration, - vehicle.GrossVehicleMassRating); - } - - return segment; - } - - public void Initialize() - { - var vehicle = InputDataProvider.JobInputData.Vehicle; - _segment = GetSegment(vehicle, out var allowVocational); - _allowVocational = allowVocational; - _driverdata = DataAdapter.CreateDriverData(); - _driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(_segment.AccelerationFile); - var tempVehicle = DataAdapter.CreateVehicleData(vehicle, _segment, _segment.Missions.First(), - _segment.Missions.First().Loadings.First(), allowVocational); - _airdragData = DataAdapter.CreateAirdragData(vehicle.Components.AirdragInputData, - _segment.Missions.First(), _segment); - if (InputDataProvider.JobInputData.Vehicle.AxleConfiguration.AxlegearIncludedInGearbox()) { - _axlegearData = - DataAdapter.CreateDummyAxleGearData(InputDataProvider.JobInputData.Vehicle.Components - .GearboxInputData); - } else { - _axlegearData = - DataAdapter.CreateAxleGearData(InputDataProvider.JobInputData.Vehicle.Components - .AxleGearInputData); - } - - _angledriveData = - DataAdapter.CreateAngledriveData(InputDataProvider.JobInputData.Vehicle.Components - .AngledriveInputData); - var tmpRunData = new VectoRunData() { - GearboxData = new GearboxData() { - Type = vehicle.Components.GearboxInputData.Type, - } - }; - var tmpStrategy = PowertrainBuilder.GetShiftStrategy(new SimplePowertrainContainer(tmpRunData)); - var tmpEngine = DataAdapter.CreateEngineData( - vehicle, vehicle.Components.EngineInputData.EngineModes[0], _segment.Missions.First()); - _gearboxData = DataAdapter.CreateGearboxData( - vehicle, - new VectoRunData() - { EngineData = tmpEngine, AxleGearData = _axlegearData, VehicleData = tempVehicle }, - tmpStrategy); - - _retarderData = DataAdapter.CreateRetarderData(vehicle.Components.RetarderInputData); - - _ptoTransmissionData = - DataAdapter.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData); - - _municipalPtoTransmissionData = CreateDefaultPTOData(); - _gearshiftData = DataAdapter.CreateGearshiftData( - _gearboxData, _axlegearData.AxleGear.Ratio * (_angledriveData?.Angledrive.Ratio ?? 1.0), - tmpEngine.IdleSpeed); - } - - - protected PTOData CreateDefaultPTOData() - { - return new PTOData() { - TransmissionType = DeclarationData.PTO.DefaultPTOTechnology, - LossMap = PTOIdleLossMapReader.ReadFromStream( - RessourceHelper.ReadStream(DeclarationData.PTO.DefaultPTOIdleLosses)), - PTOCycle = - DrivingCycleDataReader.ReadFromStream( - RessourceHelper.ReadStream(DeclarationData.PTO.DefaultPTOActivationCycle), - CycleType.PTO, "PTO", false) - }; - } - - protected virtual VectoRunData CreateVectoRunData(IVehicleDeclarationInputData vehicle, int modeIdx, - Mission mission, KeyValuePair<LoadingType, Tuple<Kilogram, double?>> loading, bool allowVocational) - { - throw new NotImplementedException(); - } - - public virtual void InitializeReport() - { - VectoRunData powertrainConfig; - List<List<FuelData.Entry>> fuels; - var vehicle = InputDataProvider.JobInputData.Vehicle; - if (vehicle.ExemptedVehicle) { - powertrainConfig = CreateVectoRunData(vehicle, 0, null, - new KeyValuePair<LoadingType, Tuple<Kilogram, double?>>(), _allowVocational); - fuels = new List<List<FuelData.Entry>>(); - } else { - powertrainConfig = _segment.Missions.Select( - mission => CreateVectoRunData( - vehicle, 0, mission, mission.Loadings.First(), _allowVocational)) - .FirstOrDefault(x => x != null); - fuels = vehicle.Components.EngineInputData.EngineModes.Select(x => - x.Fuels.Select(f => DeclarationData.FuelData.Lookup(f.FuelType, vehicle.TankSystem)) - .ToList()) - .ToList(); - } - - Report.InitializeReport(powertrainConfig, fuels); - } - - protected virtual IEnumerable<VectoRunData> GetNextRun() - { - throw new NotImplementedException(); - } - - #endregion + ILorryDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/PrimaryBusRunDataFactory/DeclarationModePrimaryBusRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/PrimaryBusRunDataFactory/DeclarationModePrimaryBusRunDataFactory.cs index 1a868c744b566b6cb4883a52522d3fef76fa5ee6..db6a6a2316ebf8c8383dd6c191e95483f6a0af00 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/PrimaryBusRunDataFactory/DeclarationModePrimaryBusRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationMode/PrimaryBusRunDataFactory/DeclarationModePrimaryBusRunDataFactory.cs @@ -1,8 +1,17 @@ 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.DeclarationMode.PrimaryBusRunDataFactory @@ -11,17 +20,17 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.PrimaryBusRunDa { - public abstract class PrimaryBusBase : IVectoRunDataFactory + public abstract class PrimaryBusBase : AbstractDeclarationVectoRunDataFactory { #region Implementation of IVectoRunDataFactory - public IDeclarationDataAdapter DataAdapter { get; } + public IPrimaryBusDeclarationDataAdapter DataAdapter { get; } public IDeclarationInputDataProvider DataProvider { get; } public IDeclarationReport Report { get; } protected PrimaryBusBase(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) + IPrimaryBusDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, false) { DataAdapter = declarationDataAdapter; DataProvider = dataProvider; @@ -29,92 +38,398 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.PrimaryBusRunDa } + protected abstract IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary(); + 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; + } + } - public IEnumerable<VectoRunData> NextRun() + protected Segment GetSegment(IVehicleDeclarationInputData vehicle) { - throw new NotImplementedException(); + 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; + } + + protected override void Initialize() + { + var vehicle = InputDataProvider.JobInputData.Vehicle; + if (vehicle.ExemptedVehicle) + { + return; + } + + _segment = GetSegment(vehicle); + _driverdata = DataAdapter.CreateDriverData(); + _driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(_segment.AccelerationFile); + var tempVehicle = DataAdapter.CreateVehicleData(vehicle, _segment, _segment.Missions.First(), + _segment.Missions.First().Loadings.First(), _allowVocational); + _airdragData = DataAdapter.CreateAirdragData(vehicle.Components.AirdragInputData, + _segment.Missions.First(), _segment); + if (InputDataProvider.JobInputData.Vehicle.AxleConfiguration.AxlegearIncludedInGearbox()) + { + _axlegearData = DataAdapter.CreateDummyAxleGearData(InputDataProvider.JobInputData.Vehicle.Components.GearboxInputData); + } + else + { + _axlegearData = DataAdapter.CreateAxleGearData(InputDataProvider.JobInputData.Vehicle.Components.AxleGearInputData); + } + _angledriveData = DataAdapter.CreateAngledriveData(InputDataProvider.JobInputData.Vehicle.Components.AngledriveInputData); + var tmpRunData = new VectoRunData() + { + GearboxData = new GearboxData() + { + Type = vehicle.Components.GearboxInputData.Type, + } + }; + var tmpStrategy = PowertrainBuilder.GetShiftStrategy(new SimplePowertrainContainer(tmpRunData)); + var tmpEngine = DataAdapter.CreateEngineData( + vehicle, vehicle.Components.EngineInputData.EngineModes[0], _segment.Missions.First()); + _gearboxData = DataAdapter.CreateGearboxData( + vehicle, new VectoRunData() { EngineData = tmpEngine, AxleGearData = _axlegearData, VehicleData = tempVehicle }, + tmpStrategy); + + _retarderData = DataAdapter.CreateRetarderData(vehicle.Components.RetarderInputData); + + _ptoTransmissionData = DataAdapter.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData); + + //_municipalPtoTransmissionData = CreateDefaultPTOData(); + _gearshiftData = DataAdapter.CreateGearshiftData( + _gearboxData, _axlegearData.AxleGear.Ratio * (_angledriveData?.Angledrive.Ratio ?? 1.0), tmpEngine.IdleSpeed); + } #endregion + 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 = DataAdapter.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 = DataAdapter.CreateBusAuxiliariesData( + mission, InputDataProvider.JobInputData.Vehicle, simulationRunData); + return simulationRunData; + } } public class Conventional : PrimaryBusBase { public Conventional(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + IPrimaryBusDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + + #region Overrides of PrimaryBusBase + + protected override IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary() + { + var vehicle = DataProvider.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; + } + } + } + } + + #endregion + + #region Overrides of AbstractDeclarationVectoRunDataFactory + + + + #endregion } public class HEV_S2 : PrimaryBusBase { public HEV_S2(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + IPrimaryBusDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + + #region Overrides of PrimaryBusBase + + protected override IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary() + { + throw new NotImplementedException(); + } + + #endregion } public class HEV_S3 : PrimaryBusBase { public HEV_S3(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, - IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + IPrimaryBusDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + + #region Overrides of PrimaryBusBase + + protected override IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary() + { + throw new NotImplementedException(); + } + + #endregion } public class HEV_S4 : PrimaryBusBase { - public HEV_S4(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + public HEV_S4(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IPrimaryBusDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + + #region Overrides of PrimaryBusBase + + protected override IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary() + { + throw new NotImplementedException(); + } + + #endregion } public class HEV_S_IEPC : PrimaryBusBase { - public HEV_S_IEPC(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + public HEV_S_IEPC(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IPrimaryBusDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + + #region Overrides of PrimaryBusBase + + protected override IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary() + { + throw new NotImplementedException(); + } + + #endregion } public class HEV_P1 : PrimaryBusBase { - public HEV_P1(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + public HEV_P1(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IPrimaryBusDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + + #region Overrides of PrimaryBusBase + + protected override IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary() + { + throw new NotImplementedException(); + } + + #endregion } public class HEV_P2 : PrimaryBusBase { - public HEV_P2(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + public HEV_P2(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IPrimaryBusDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + + #region Overrides of PrimaryBusBase + + protected override IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary() + { + throw new NotImplementedException(); + } + + #endregion } public class HEV_P2_5 : PrimaryBusBase { - public HEV_P2_5(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + public HEV_P2_5(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IPrimaryBusDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + + #region Overrides of PrimaryBusBase + + protected override IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary() + { + throw new NotImplementedException(); + } + + #endregion } public class HEV_P3 : PrimaryBusBase { - public HEV_P3(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + public HEV_P3(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IPrimaryBusDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + + #region Overrides of PrimaryBusBase + + protected override IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary() + { + throw new NotImplementedException(); + } + + #endregion } public class HEV_P4 : PrimaryBusBase { - public HEV_P4(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + public HEV_P4(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IPrimaryBusDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + + #region Overrides of PrimaryBusBase + + protected override IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary() + { + throw new NotImplementedException(); + } + + #endregion } public class PEV_E2 : PrimaryBusBase { - public PEV_E2(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + public PEV_E2(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IPrimaryBusDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + + #region Overrides of PrimaryBusBase + + protected override IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary() + { + throw new NotImplementedException(); + } + + #endregion } public class PEV_E3 : PrimaryBusBase { - public PEV_E3(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + public PEV_E3(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IPrimaryBusDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + + #region Overrides of PrimaryBusBase + + protected override IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary() + { + throw new NotImplementedException(); + } + + #endregion } public class PEV_E4 : PrimaryBusBase { - public PEV_E4(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + public PEV_E4(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IPrimaryBusDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + + #region Overrides of PrimaryBusBase + + protected override IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary() + { + throw new NotImplementedException(); + } + + #endregion } public class PEV_E_IEPC : PrimaryBusBase { - public PEV_E_IEPC(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + public PEV_E_IEPC(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IPrimaryBusDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + + #region Overrides of PrimaryBusBase + + protected override IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary() + { + throw new NotImplementedException(); + } + + #endregion } public class Exempted : PrimaryBusBase { - public Exempted(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + public Exempted(IDeclarationInputDataProvider dataProvider, IDeclarationReport report, IPrimaryBusDeclarationDataAdapter declarationDataAdapter) : base(dataProvider, report, declarationDataAdapter) { } + + #region Overrides of PrimaryBusBase + + protected override IEnumerable<VectoRunData> VectoRunDataHeavyBusPrimary() + { + throw new NotImplementedException(); + } + + #endregion } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs index df3cbb3b3c317561fbabaad7ebc4efd0601c515e..9d73db9cb176aa7b3c083689ed180968f6f61ed4 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedBusVectoRunDataFactory.cs @@ -1,296 +1,296 @@ -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; +//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 AxleGearData _axlegearData; +// protected AngledriveData _angledriveData; +// protected GearboxData _gearboxData; +// protected RetarderData _retarderData; - protected IAlternatorMap _alternatorMap; - protected ICompressorMap _compressorMap; - //protected IPneumaticsConsumersDemand _consumersDeclarationData; +// protected IAlternatorMap _alternatorMap; +// protected ICompressorMap _compressorMap; +// //protected IPneumaticsConsumersDemand _consumersDeclarationData; - //protected CombustionEngineData _combustionEngineData; +// //protected CombustionEngineData _combustionEngineData; - //protected Exception InitException; - protected ShiftStrategyParameters _gearshiftData; +// //protected Exception InitException; +// protected ShiftStrategyParameters _gearshiftData; - //private VehicleData _tmpVehicleData; - private DriverData _driverData; +// //private VehicleData _tmpVehicleData; +// private DriverData _driverData; - protected DeclarationDataAdapterCompletedBusSpecific DataAdapterSpecific = new DeclarationDataAdapterCompletedBusSpecific(); +// protected DeclarationDataAdapterCompletedBusSpecific DataAdapterSpecific = new DeclarationDataAdapterCompletedBusSpecific(); - protected DeclarationDataAdapterCompletedBusGeneric DataAdapterGeneric = new DeclarationDataAdapterCompletedBusGeneric(); +// protected DeclarationDataAdapterCompletedBusGeneric DataAdapterGeneric = new DeclarationDataAdapterCompletedBusGeneric(); - public DeclarationModeCompletedBusVectoRunDataFactory( - IDeclarationInputDataProvider dataProvider, IDeclarationReport report) - { - InputDataProvider = dataProvider; - Report = report; - } +// public DeclarationModeCompletedBusVectoRunDataFactory( +// IDeclarationInputDataProvider dataProvider, IDeclarationReport report) +// { +// InputDataProvider = dataProvider; +// Report = report; +// } - protected IVehicleDeclarationInputData PrimaryVehicle => InputDataProvider.PrimaryVehicleData.Vehicle; +// protected IVehicleDeclarationInputData PrimaryVehicle => InputDataProvider.PrimaryVehicleData.Vehicle; - protected IVehicleDeclarationInputData CompletedVehicle => InputDataProvider.JobInputData.Vehicle; +// protected IVehicleDeclarationInputData CompletedVehicle => InputDataProvider.JobInputData.Vehicle; - public IEnumerable<VectoRunData> NextRun() - { - Initialize(); - if (Report != null) { - InitializeReport(); - } +// public IEnumerable<VectoRunData> NextRun() +// { +// Initialize(); +// if (Report != null) { +// InitializeReport(); +// } - return GetNextRun(); - } +// return GetNextRun(); +// } - protected virtual void InitializeReport() - { - var powertrainConfig = _segmentCompletedBus.Missions.Select( - mission => CreateVectoRunDataSpecific( - mission, mission.Loadings.First(), 0)) - .FirstOrDefault(x => x != null); +// 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>>()); - } +// Report.InitializeReport(powertrainConfig, new List<List<FuelData.Entry>>()); +// } - protected virtual void Initialize() - { - if (CompletedVehicle.ExemptedVehicle || PrimaryVehicle.ExemptedVehicle) { - return; - } +// protected virtual void Initialize() +// { +// if (CompletedVehicle.ExemptedVehicle || PrimaryVehicle.ExemptedVehicle) { +// return; +// } - _segmentCompletedBus = GetCompletedSegment(CompletedVehicle, PrimaryVehicle.AxleConfiguration); +// _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 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()); +// var combustionEngineData = DataAdapterGeneric.CreateEngineData(PrimaryVehicle, 0, _segmentCompletedBus.Missions.First()); - _axlegearData = DataAdapterGeneric.CreateAxleGearData(PrimaryVehicle.Components.AxleGearInputData); +// _axlegearData = DataAdapterGeneric.CreateAxleGearData(PrimaryVehicle.Components.AxleGearInputData); - _angledriveData = DataAdapterGeneric.CreateAngledriveData(PrimaryVehicle.Components.AngledriveInputData); +// _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)); +// 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); +// _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); +// _gearshiftData = DataAdapterGeneric.CreateGearshiftData( +// _gearboxData, _axlegearData.AxleGear.Ratio * (_angledriveData?.Angledrive.Ratio ?? 1.0), combustionEngineData.IdleSpeed); - _retarderData = DataAdapterGeneric.CreateRetarderData(PrimaryVehicle.Components.RetarderInputData); +// _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); +// _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; - } +// 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; - } - - - } -} +// 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 index 7d9a3523e5079a18b21af8309ed0bfc1b1f022fd..013c6c91c709cbb1898a3c93e5785de8d5f49a74 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedMultistageBusVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeCompletedMultistageBusVectoRunDataFactory.cs @@ -1,328 +1,328 @@ -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); +//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); - } +// _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)); +// 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; - } +// 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)); +// 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; - } - - - } -} +// 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 index f7c2ed89007975302e727c13d1c17a4f4fc83ffb..97a98862e8abeb026ed7aa72d4796775985af190 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeHeavyLorryVectoRunDataFactory.cs @@ -1,232 +1,232 @@ -/* -* 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; - //} +///* +//* 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; - } - } - } +// 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> 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)); +// } +// } + +// 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; - } +// 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 index 2e6dc575bdc02a5a1f18b6b0c9634c08a4d426cb..1e5f1ec35a6b832400a3c96186cff2ad189393ba 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModePrimaryBusVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModePrimaryBusVectoRunDataFactory.cs @@ -1,178 +1,178 @@ -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; - } - } -} +//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 index b397c4bc184f0312e47a4bee36ff52cb5302a49c..55d06dd334a4c83629a58c92752249a84f9e2e74 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeSingleBusVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeSingleBusVectoRunDataFactory.cs @@ -1,129 +1,129 @@ -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; +//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; +//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; - } +// 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()); - //} +// 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 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; - } +// 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; - } +// return segment; +// } - protected override IDeclarationDataAdapter DataAdapter => _dao; +// 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; - } +// 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 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 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; - } +// 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); - } - } +// 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/DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary.cs index e426f5a3507798143992da9f46c8bcfb900ec1ac..ed302d8e50e4cd8cfb9f5a08537b6db61c5396ed 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary.cs @@ -1,230 +1,230 @@ -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.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.Models.SimulationComponent.Impl; -using TUGraz.VectoCore.OutputData; - -namespace TUGraz.VectoCore.InputData.Reader.Impl { - internal class DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary : AbstractVTPModeVectoRunDataFactory - { - private DeclarationDataAdapterPrimaryBus _dao; - - public DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary( - IVTPDeclarationInputDataProvider ivtpProvider, IVTPReport report) : base(ivtpProvider.JobInputData, report) - { +//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.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.Models.SimulationComponent.Impl; +//using TUGraz.VectoCore.OutputData; + +//namespace TUGraz.VectoCore.InputData.Reader.Impl { +// internal class DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary : AbstractVTPModeVectoRunDataFactory +// { +// private DeclarationDataAdapterPrimaryBus _dao; + +// public DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary( +// IVTPDeclarationInputDataProvider ivtpProvider, IVTPReport report) : base(ivtpProvider.JobInputData, report) +// { - } - - protected DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary(IVTPDeclarationJobInputData vtpJob, IVTPReport report): base(vtpJob, report) { } - - - #region Implementation of IVectoRunDataFactory - - protected override IDeclarationDataAdapter Dao => _dao ?? (_dao = new DeclarationDataAdapterPrimaryBus()); - - #endregion - - protected override void Initialize() - { - var vehicle = JobInputData.Vehicle; - Segment = DeclarationData.PrimaryBusSegments.Lookup( - vehicle.VehicleCategory, vehicle.AxleConfiguration, vehicle.Articulated); - - Driverdata = Dao.CreateDriverData(); - Driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(Segment.AccelerationFile); - var tempVehicle = Dao.CreateVehicleData( - vehicle, Segment, Segment.Missions.First(), - Segment.Missions.First().Loadings.First(), _allowVocational); - tempVehicle.VehicleClass = JobInputData.ManufacturerReportInputData.VehicleClass; - tempVehicle.VehicleCode = JobInputData.ManufacturerReportInputData.VehicleCode; - - var vtpMission = tempVehicle.VehicleCode.GetFloorType() == FloorType.LowFloor - ? DeclarationData.VTPMode.SelectedMissionLowFloorBus - : DeclarationData.VTPMode.SelectedMissionHighFloorBus; - AirdragData = Dao.CreateAirdragData( - vehicle.Components.AirdragInputData, - Segment.Missions.First(), Segment); - EngineData = Dao.CreateEngineData( - vehicle, vehicle.Components.EngineInputData.EngineModes.First(), - new Mission() { MissionType = vtpMission }); - AxlegearData = JobInputData.Vehicle.Components.GearboxInputData.DifferentialIncluded - ? Dao.CreateDummyAxleGearData(JobInputData.Vehicle.Components.GearboxInputData) - : Dao.CreateAxleGearData(vehicle.Components.AxleGearInputData); - AngledriveData = Dao.CreateAngledriveData(vehicle.Components.AngledriveInputData); - - GearboxData = Dao.CreateGearboxData( - vehicle, new VectoRunData() { EngineData = EngineData, AxleGearData = AxlegearData, VehicleData = tempVehicle }, - null); - RetarderData = Dao.CreateRetarderData(vehicle.Components.RetarderInputData); - - PTOTransmissionData = - Dao.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData); - - GearshiftData = Dao.CreateGearshiftData( - GearboxData, AxlegearData.AxleGear.Ratio * (AngledriveData?.Angledrive.Ratio ?? 1.0), EngineData.IdleSpeed); - - AuxVTP = CreateVTPAuxData(vehicle); - } - - protected override void InitializeReport() - { - var vehicle = JobInputData.Vehicle; - var tempVehicle = Dao.CreateVehicleData( - vehicle, Segment, Segment.Missions.First(), - Segment.Missions.First().Loadings.First(), _allowVocational); - tempVehicle.VehicleClass = JobInputData.ManufacturerReportInputData.VehicleClass; - tempVehicle.VehicleCode = JobInputData.ManufacturerReportInputData.VehicleCode; - var powertrainConfig = new VectoRunData() { - VehicleData = tempVehicle, - AirdragData = AirdragData, - EngineData = EngineData, - GearboxData = GearboxData, - AxleGearData = AxlegearData, - Retarder = RetarderData, - Aux = GetAuxiliaryData(Segment.Missions.First().MissionType), - }; - //powertrainConfig.VehicleData.VehicleClass = Segment.VehicleClass; - Report.InputDataHash = JobInputData.VectoJobHash; - Report.ManufacturerRecord = JobInputData.ManufacturerReportInputData; - Report.ManufacturerRecordHash = JobInputData.VectoManufacturerReportHash; - var fuels = JobInputData.Vehicle.Components.EngineInputData.EngineModes.Select( - x => x.Fuels.Select(f => DeclarationData.FuelData.Lookup(f.FuelType, JobInputData.Vehicle.TankSystem)) - .ToList()) - .ToList(); - Report.InitializeReport(powertrainConfig, fuels); - } - - protected virtual List<VectoRunData.AuxData> CreateVTPAuxData(IVehicleDeclarationInputData vehicle) - { - // used to fill VECTO RunData for VTP mission. +// } + +// protected DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary(IVTPDeclarationJobInputData vtpJob, IVTPReport report): base(vtpJob, report) { } + + +// #region Implementation of IVectoRunDataFactory + +// protected override IDeclarationDataAdapter Dao => _dao ?? (_dao = new DeclarationDataAdapterPrimaryBus()); + +// #endregion + +// protected override void Initialize() +// { +// var vehicle = JobInputData.Vehicle; +// Segment = DeclarationData.PrimaryBusSegments.Lookup( +// vehicle.VehicleCategory, vehicle.AxleConfiguration, vehicle.Articulated); + +// Driverdata = Dao.CreateDriverData(); +// Driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(Segment.AccelerationFile); +// var tempVehicle = Dao.CreateVehicleData( +// vehicle, Segment, Segment.Missions.First(), +// Segment.Missions.First().Loadings.First(), _allowVocational); +// tempVehicle.VehicleClass = JobInputData.ManufacturerReportInputData.VehicleClass; +// tempVehicle.VehicleCode = JobInputData.ManufacturerReportInputData.VehicleCode; + +// var vtpMission = tempVehicle.VehicleCode.GetFloorType() == FloorType.LowFloor +// ? DeclarationData.VTPMode.SelectedMissionLowFloorBus +// : DeclarationData.VTPMode.SelectedMissionHighFloorBus; +// AirdragData = Dao.CreateAirdragData( +// vehicle.Components.AirdragInputData, +// Segment.Missions.First(), Segment); +// EngineData = Dao.CreateEngineData( +// vehicle, vehicle.Components.EngineInputData.EngineModes.First(), +// new Mission() { MissionType = vtpMission }); +// AxlegearData = JobInputData.Vehicle.Components.GearboxInputData.DifferentialIncluded +// ? Dao.CreateDummyAxleGearData(JobInputData.Vehicle.Components.GearboxInputData) +// : Dao.CreateAxleGearData(vehicle.Components.AxleGearInputData); +// AngledriveData = Dao.CreateAngledriveData(vehicle.Components.AngledriveInputData); + +// GearboxData = Dao.CreateGearboxData( +// vehicle, new VectoRunData() { EngineData = EngineData, AxleGearData = AxlegearData, VehicleData = tempVehicle }, +// null); +// RetarderData = Dao.CreateRetarderData(vehicle.Components.RetarderInputData); + +// PTOTransmissionData = +// Dao.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData); + +// GearshiftData = Dao.CreateGearshiftData( +// GearboxData, AxlegearData.AxleGear.Ratio * (AngledriveData?.Angledrive.Ratio ?? 1.0), EngineData.IdleSpeed); + +// AuxVTP = CreateVTPAuxData(vehicle); +// } + +// protected override void InitializeReport() +// { +// var vehicle = JobInputData.Vehicle; +// var tempVehicle = Dao.CreateVehicleData( +// vehicle, Segment, Segment.Missions.First(), +// Segment.Missions.First().Loadings.First(), _allowVocational); +// tempVehicle.VehicleClass = JobInputData.ManufacturerReportInputData.VehicleClass; +// tempVehicle.VehicleCode = JobInputData.ManufacturerReportInputData.VehicleCode; +// var powertrainConfig = new VectoRunData() { +// VehicleData = tempVehicle, +// AirdragData = AirdragData, +// EngineData = EngineData, +// GearboxData = GearboxData, +// AxleGearData = AxlegearData, +// Retarder = RetarderData, +// Aux = GetAuxiliaryData(Segment.Missions.First().MissionType), +// }; +// //powertrainConfig.VehicleData.VehicleClass = Segment.VehicleClass; +// Report.InputDataHash = JobInputData.VectoJobHash; +// Report.ManufacturerRecord = JobInputData.ManufacturerReportInputData; +// Report.ManufacturerRecordHash = JobInputData.VectoManufacturerReportHash; +// var fuels = JobInputData.Vehicle.Components.EngineInputData.EngineModes.Select( +// x => x.Fuels.Select(f => DeclarationData.FuelData.Lookup(f.FuelType, JobInputData.Vehicle.TankSystem)) +// .ToList()) +// .ToList(); +// Report.InitializeReport(powertrainConfig, fuels); +// } + +// protected virtual List<VectoRunData.AuxData> CreateVTPAuxData(IVehicleDeclarationInputData vehicle) +// { +// // used to fill VECTO RunData for VTP mission. - var retVal = new List<VectoRunData.AuxData>(); - - var electricEfficiency = - Constants.BusAuxiliaries.ElectricSystem.AlternatorGearEfficiency * - DeclarationData.BusAuxiliaries.AlternatorTechnologies.Lookup("default"); - - // TODO: vehicle length from MRF - - var spPowerDemand = DeclarationData.SteeringPumpBus.LookupMechanicalPowerDemand( - MissionType.VerificationTest, JobInputData.Vehicle.Components.BusAuxiliaries.SteeringPumpTechnology, - JobInputData.ManufacturerReportInputData.VehicleLength) - + - DeclarationData.SteeringPumpBus.LookupElectricalPowerDemand( - MissionType.VerificationTest, JobInputData.Vehicle.Components.BusAuxiliaries.SteeringPumpTechnology, - JobInputData.ManufacturerReportInputData.VehicleLength) / electricEfficiency; - - retVal.Add( - new VectoRunData.AuxData() { - DemandType = AuxiliaryDemandType.Constant, - Technology = JobInputData.Vehicle.Components.BusAuxiliaries.SteeringPumpTechnology, - ID = Constants.Auxiliaries.IDs.SteeringPump, - PowerDemand = spPowerDemand - }); - - retVal.Add( - new VectoRunData.AuxData() { - DemandType = AuxiliaryDemandType.Constant, - Technology = new List<string>() { "default"}, - ID = Constants.Auxiliaries.IDs.ElectricSystem, - PowerDemand = Constants.BusAuxiliaries.ElectricSystem.PowernetVoltage * 32.4.SI<Ampere>() / electricEfficiency - }); - retVal.Add(new VectoRunData.AuxData() { - DemandType = AuxiliaryDemandType.Constant, - Technology = new List<string>() { "default"}, - ID = Constants.Auxiliaries.IDs.HeatingVentilationAirCondition, - PowerDemand = 350.SI<Watt>() - }); - - var busAux = vehicle.Components.BusAuxiliaries; - var psCompressor = DeclarationData.BusAuxiliaries.GetCompressorMap(busAux.PneumaticSupply.CompressorSize, busAux.PneumaticSupply.Clutch); - retVal.Add(new VectoRunData.AuxData() { - DemandType = AuxiliaryDemandType.Direct, - Technology = new List<string>() { busAux.PneumaticSupply.CompressorSize + " / " + busAux.PneumaticSupply.Clutch}, - ID = Constants.Auxiliaries.IDs.PneumaticSystem, - PowerDemandFunc = cycleEntry => { - var cmp = psCompressor.Interpolate(cycleEntry.EngineSpeed * busAux.PneumaticSupply.Ratio); - return cycleEntry.VTPPSCompressorActive ? cmp.PowerOn : cmp.PowerOff; - } - }); - - var fanData = GetFanData(); - var engineFan = new EngineFanAuxiliary(fanData.FanCoefficients, fanData.FanDiameter); - retVal.Add( new VectoRunData.AuxData() { - DemandType = AuxiliaryDemandType.Direct, - Technology = new List<string>() { "default"}, - ID = Constants.Auxiliaries.IDs.Fan, - PowerDemandFunc = cycleEntry => engineFan.PowerDemand(cycleEntry.FanSpeed) - }); +// var retVal = new List<VectoRunData.AuxData>(); + +// var electricEfficiency = +// Constants.BusAuxiliaries.ElectricSystem.AlternatorGearEfficiency * +// DeclarationData.BusAuxiliaries.AlternatorTechnologies.Lookup("default"); + +// // TODO: vehicle length from MRF + +// var spPowerDemand = DeclarationData.SteeringPumpBus.LookupMechanicalPowerDemand( +// MissionType.VerificationTest, JobInputData.Vehicle.Components.BusAuxiliaries.SteeringPumpTechnology, +// JobInputData.ManufacturerReportInputData.VehicleLength) +// + +// DeclarationData.SteeringPumpBus.LookupElectricalPowerDemand( +// MissionType.VerificationTest, JobInputData.Vehicle.Components.BusAuxiliaries.SteeringPumpTechnology, +// JobInputData.ManufacturerReportInputData.VehicleLength) / electricEfficiency; + +// retVal.Add( +// new VectoRunData.AuxData() { +// DemandType = AuxiliaryDemandType.Constant, +// Technology = JobInputData.Vehicle.Components.BusAuxiliaries.SteeringPumpTechnology, +// ID = Constants.Auxiliaries.IDs.SteeringPump, +// PowerDemand = spPowerDemand +// }); + +// retVal.Add( +// new VectoRunData.AuxData() { +// DemandType = AuxiliaryDemandType.Constant, +// Technology = new List<string>() { "default"}, +// ID = Constants.Auxiliaries.IDs.ElectricSystem, +// PowerDemand = Constants.BusAuxiliaries.ElectricSystem.PowernetVoltage * 32.4.SI<Ampere>() / electricEfficiency +// }); +// retVal.Add(new VectoRunData.AuxData() { +// DemandType = AuxiliaryDemandType.Constant, +// Technology = new List<string>() { "default"}, +// ID = Constants.Auxiliaries.IDs.HeatingVentilationAirCondition, +// PowerDemand = 350.SI<Watt>() +// }); + +// var busAux = vehicle.Components.BusAuxiliaries; +// var psCompressor = DeclarationData.BusAuxiliaries.GetCompressorMap(busAux.PneumaticSupply.CompressorSize, busAux.PneumaticSupply.Clutch); +// retVal.Add(new VectoRunData.AuxData() { +// DemandType = AuxiliaryDemandType.Direct, +// Technology = new List<string>() { busAux.PneumaticSupply.CompressorSize + " / " + busAux.PneumaticSupply.Clutch}, +// ID = Constants.Auxiliaries.IDs.PneumaticSystem, +// PowerDemandFunc = cycleEntry => { +// var cmp = psCompressor.Interpolate(cycleEntry.EngineSpeed * busAux.PneumaticSupply.Ratio); +// return cycleEntry.VTPPSCompressorActive ? cmp.PowerOn : cmp.PowerOff; +// } +// }); + +// var fanData = GetFanData(); +// var engineFan = new EngineFanAuxiliary(fanData.FanCoefficients, fanData.FanDiameter); +// retVal.Add( new VectoRunData.AuxData() { +// DemandType = AuxiliaryDemandType.Direct, +// Technology = new List<string>() { "default"}, +// ID = Constants.Auxiliaries.IDs.Fan, +// PowerDemandFunc = cycleEntry => engineFan.PowerDemand(cycleEntry.FanSpeed) +// }); - return retVal; - } - - protected override IEnumerable<VectoRunData.AuxData> GetAuxiliaryData(MissionType missionType) - { - // used for initializing XML report, - return AuxVTP; - } - - protected override AuxFanData GetFanData() - { - return new AuxFanData() { - FanCoefficients = DeclarationData.VTPMode.FanParameters.Concat(JobInputData.FanPowerCoefficents.Skip(3).Take(1)).ToArray() , - FanDiameter = JobInputData.FanDiameter, - }; - } - - public override IEnumerable<VectoRunData> NextRun() - { - if (InitException != null) { - throw InitException; - } - - - // simulate the Measured cycle - var vtpCycle = JobInputData.Cycles.FirstOrDefault(); - if (vtpCycle == null) { - throw new VectoException("no VTP-Cycle provided!"); - } - - var drivingCycle = DrivingCycleDataReader.ReadFromDataTable(vtpCycle.CycleData, vtpCycle.Name, false); - - // Loading is not relevant as we use P_wheel - var vtpRunData = CreateVectoRunData(Segment, Segment.Missions.First(), Tuple.Create<Kilogram, double?>(0.SI<Kilogram>(), null)); - vtpRunData.Cycle = new DrivingCycleProxy(drivingCycle, vtpCycle.Name); - vtpRunData.Aux = AuxVTP; - vtpRunData.FanDataVTP = GetFanData(); - vtpRunData.ExecutionMode = ExecutionMode.Declaration; - vtpRunData.SimulationType = SimulationType.VerificationTest; - vtpRunData.Mission = new Mission() { - MissionType = MissionType.VerificationTest - }; - vtpRunData.VehicleData.VehicleClass = JobInputData.ManufacturerReportInputData.VehicleClass; //Segment.VehicleClass; - vtpRunData.VehicleData.VehicleCode = JobInputData.ManufacturerReportInputData.VehicleCode; - vtpRunData.VehicleData.LegislativeClass = JobInputData.Vehicle.LegislativeClass; - - //var ncvStd = DeclarationData.FuelData.Lookup(JobInputData.Vehicle.Components.EngineInputData.FuelType).LowerHeatingValueVecto; - //var ncvCorrection = ncvStd / JobInputData.NetCalorificValueTestFuel; - var mileageCorrection = GetMileagecorrectionFactor(JobInputData.Mileage); - vtpRunData.VTPData = new VTPData() { - CorrectionFactor = mileageCorrection, - }; - vtpRunData.DriverData = Driverdata; - yield return vtpRunData; - } +// return retVal; +// } + +// protected override IEnumerable<VectoRunData.AuxData> GetAuxiliaryData(MissionType missionType) +// { +// // used for initializing XML report, +// return AuxVTP; +// } + +// protected override AuxFanData GetFanData() +// { +// return new AuxFanData() { +// FanCoefficients = DeclarationData.VTPMode.FanParameters.Concat(JobInputData.FanPowerCoefficents.Skip(3).Take(1)).ToArray() , +// FanDiameter = JobInputData.FanDiameter, +// }; +// } + +// public override IEnumerable<VectoRunData> NextRun() +// { +// if (InitException != null) { +// throw InitException; +// } + + +// // simulate the Measured cycle +// var vtpCycle = JobInputData.Cycles.FirstOrDefault(); +// if (vtpCycle == null) { +// throw new VectoException("no VTP-Cycle provided!"); +// } + +// var drivingCycle = DrivingCycleDataReader.ReadFromDataTable(vtpCycle.CycleData, vtpCycle.Name, false); + +// // Loading is not relevant as we use P_wheel +// var vtpRunData = CreateVectoRunData(Segment, Segment.Missions.First(), Tuple.Create<Kilogram, double?>(0.SI<Kilogram>(), null)); +// vtpRunData.Cycle = new DrivingCycleProxy(drivingCycle, vtpCycle.Name); +// vtpRunData.Aux = AuxVTP; +// vtpRunData.FanDataVTP = GetFanData(); +// vtpRunData.ExecutionMode = ExecutionMode.Declaration; +// vtpRunData.SimulationType = SimulationType.VerificationTest; +// vtpRunData.Mission = new Mission() { +// MissionType = MissionType.VerificationTest +// }; +// vtpRunData.VehicleData.VehicleClass = JobInputData.ManufacturerReportInputData.VehicleClass; //Segment.VehicleClass; +// vtpRunData.VehicleData.VehicleCode = JobInputData.ManufacturerReportInputData.VehicleCode; +// vtpRunData.VehicleData.LegislativeClass = JobInputData.Vehicle.LegislativeClass; + +// //var ncvStd = DeclarationData.FuelData.Lookup(JobInputData.Vehicle.Components.EngineInputData.FuelType).LowerHeatingValueVecto; +// //var ncvCorrection = ncvStd / JobInputData.NetCalorificValueTestFuel; +// var mileageCorrection = GetMileagecorrectionFactor(JobInputData.Mileage); +// vtpRunData.VTPData = new VTPData() { +// CorrectionFactor = mileageCorrection, +// }; +// vtpRunData.DriverData = Driverdata; +// yield return vtpRunData; +// } - } -} \ No newline at end of file +// } +//} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactoryLorries.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactoryLorries.cs index a40581987bfd5ab3216ec7c78152270aa8f1d1b0..1f49199dc63526b70832b05a56cc4b453f24ee1c 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactoryLorries.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactoryLorries.cs @@ -1,202 +1,202 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2019 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology -*/ - -using System; -using System.Collections.Generic; -using System.Linq; -using TUGraz.VectoCommon.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.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 -{ - internal class DeclarationVTPModeVectoRunDataFactoryLorries : AbstractVTPModeVectoRunDataFactory - { - private DeclarationDataAdapterHeavyLorry _dao; - - public DeclarationVTPModeVectoRunDataFactoryLorries(IVTPDeclarationInputDataProvider ivtpProvider, IVTPReport report) : base( - ivtpProvider.JobInputData, report) - { } - - protected DeclarationVTPModeVectoRunDataFactoryLorries(IVTPDeclarationJobInputData job, IVTPReport report) : base(job, report) - { } - - protected override IDeclarationDataAdapter Dao => _dao ?? (_dao = new DeclarationDataAdapterHeavyLorry()); - - protected override void Initialize() - { - var vehicle = JobInputData.Vehicle; - 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); - } - Driverdata = Dao.CreateDriverData(); - Driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(Segment.AccelerationFile); - var tempVehicle = Dao.CreateVehicleData( - vehicle, Segment, Segment.Missions.First(), - Segment.Missions.First().Loadings.First(), _allowVocational); - - var vtpMission = Segment.VehicleClass.IsMediumLorry() - ? DeclarationData.VTPMode.SelectedMissionMediumLorry - : DeclarationData.VTPMode.SelectedMissionHeavyLorry; - - AirdragData = Dao.CreateAirdragData( - vehicle.Components.AirdragInputData, - Segment.Missions.First(), Segment); - EngineData = Dao.CreateEngineData( - vehicle, vehicle.Components.EngineInputData.EngineModes.First(), - new Mission() { MissionType = vtpMission }); - AxlegearData = JobInputData.Vehicle.Components.GearboxInputData.DifferentialIncluded - ? Dao.CreateDummyAxleGearData(JobInputData.Vehicle.Components.GearboxInputData) - : Dao.CreateAxleGearData(vehicle.Components.AxleGearInputData); - AngledriveData = Dao.CreateAngledriveData(vehicle.Components.AngledriveInputData); - - GearboxData = Dao.CreateGearboxData( - vehicle, new VectoRunData() { EngineData = EngineData, AxleGearData = AxlegearData, VehicleData = tempVehicle }, - null); - RetarderData = Dao.CreateRetarderData(vehicle.Components.RetarderInputData); - - PTOTransmissionData = - Dao.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData); - - GearshiftData = Dao.CreateGearshiftData( - GearboxData, AxlegearData.AxleGear.Ratio * (AngledriveData?.Angledrive.Ratio ?? 1.0), EngineData.IdleSpeed); - - AuxVTP = CreateVTPAuxData(vehicle); - } - - protected override IEnumerable<VectoRunData.AuxData> GetAuxiliaryData(MissionType missionType) - { - return Dao.CreateAuxiliaryData( - JobInputData.Vehicle.Components.AuxiliaryInputData, - JobInputData.Vehicle.Components.BusAuxiliaries, - missionType, - Segment.VehicleClass, JobInputData.Vehicle.Length, - JobInputData.Vehicle.Components.AxleWheels.NumSteeredAxles); - } - - protected virtual List<VectoRunData.AuxData> CreateVTPAuxData(IVehicleDeclarationInputData vehicle) - { - var numSteered = vehicle.Components.AxleWheels.NumSteeredAxles; - var auxRD = Dao.CreateAuxiliaryData( - vehicle.Components.AuxiliaryInputData, vehicle.Components.BusAuxiliaries, MissionType.RegionalDelivery, Segment.VehicleClass, vehicle.Length, numSteered) - .ToList(); - foreach (var entry in auxRD) { - entry.MissionType = MissionType.RegionalDelivery; - } - - var auxLH = Dao.CreateAuxiliaryData( - vehicle.Components.AuxiliaryInputData, vehicle.Components.BusAuxiliaries, MissionType.LongHaul, Segment.VehicleClass, vehicle.Length, numSteered) - .ToList(); - foreach (var entry in auxLH) { - entry.MissionType = MissionType.LongHaul; - } - - var auxUD = Dao.CreateAuxiliaryData( - vehicle.Components.AuxiliaryInputData, vehicle.Components.BusAuxiliaries, MissionType.UrbanDelivery, Segment.VehicleClass, vehicle.Length, numSteered) - .ToList(); - foreach (var entry in auxUD) { - entry.MissionType = MissionType.UrbanDelivery; - } - - var aux = new List<VectoRunData.AuxData>(); - aux.AddRange(auxRD); - aux.AddRange(auxLH); - aux.AddRange(auxUD); - - aux.RemoveAll(x => x.ID == Constants.Auxiliaries.IDs.Fan); - aux.Add( - new VectoRunData.AuxData { - DemandType = AuxiliaryDemandType.Direct, - ID = DrivingCycleDataReader.Fields.AdditionalAuxPowerDemand - }); - return aux; - } - - public override IEnumerable<VectoRunData> NextRun() - { - if (InitException != null) { - throw InitException; - } - - // simulate the Measured cycle - var vtpCycle = JobInputData.Cycles.FirstOrDefault(); - if (vtpCycle == null) { - throw new VectoException("no VTP-Cycle provided!"); - } - - var drivingCycle = DrivingCycleDataReader.ReadFromDataTable(vtpCycle.CycleData, vtpCycle.Name, false); - - // Loading is not relevant as we use P_wheel - var vtpRunData = CreateVectoRunData(Segment, Segment.Missions.First(), Tuple.Create<Kilogram, double?>(0.SI<Kilogram>(), null)); - vtpRunData.Cycle = new DrivingCycleProxy(drivingCycle, vtpCycle.Name); - vtpRunData.Aux = AuxVTP; - vtpRunData.FanDataVTP = GetFanData(); - vtpRunData.ExecutionMode = ExecutionMode.Declaration; - vtpRunData.SimulationType = SimulationType.VerificationTest; - vtpRunData.Mission = new Mission() { - MissionType = MissionType.VerificationTest - }; - vtpRunData.VehicleData.VehicleClass = Segment.VehicleClass; - vtpRunData.VehicleData.LegislativeClass = JobInputData.Vehicle.LegislativeClass; - vtpRunData.DriverData = Driverdata; - - //var ncvStd = DeclarationData.FuelData.Lookup(JobInputData.Vehicle.Components.EngineInputData.FuelType).LowerHeatingValueVecto; - //var ncvCorrection = ncvStd / JobInputData.NetCalorificValueTestFuel; - var mileageCorrection = GetMileagecorrectionFactor(JobInputData.Mileage); - vtpRunData.VTPData = new VTPData() { - CorrectionFactor = mileageCorrection, - }; - yield return vtpRunData; - } - } -} +///* +//* This file is part of VECTO. +//* +//* Copyright © 2012-2019 European Union +//* +//* Developed by Graz University of Technology, +//* Institute of Internal Combustion Engines and Thermodynamics, +//* Institute of Technical Informatics +//* +//* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved +//* by the European Commission - subsequent versions of the EUPL (the "Licence"); +//* You may not use VECTO except in compliance with the Licence. +//* You may obtain a copy of the Licence at: +//* +//* https://joinup.ec.europa.eu/community/eupl/og_page/eupl +//* +//* Unless required by applicable law or agreed to in writing, VECTO +//* distributed under the Licence is distributed on an "AS IS" basis, +//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +//* See the Licence for the specific language governing permissions and +//* limitations under the Licence. +//* +//* Authors: +//* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology +//* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology +//* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology +//* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology +//* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology +//* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology +//*/ + +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using TUGraz.VectoCommon.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.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 +//{ +// internal class DeclarationVTPModeVectoRunDataFactoryLorries : AbstractVTPModeVectoRunDataFactory +// { +// private DeclarationDataAdapterHeavyLorry _dao; + +// public DeclarationVTPModeVectoRunDataFactoryLorries(IVTPDeclarationInputDataProvider ivtpProvider, IVTPReport report) : base( +// ivtpProvider.JobInputData, report) +// { } + +// protected DeclarationVTPModeVectoRunDataFactoryLorries(IVTPDeclarationJobInputData job, IVTPReport report) : base(job, report) +// { } + +// protected override IDeclarationDataAdapter Dao => _dao ?? (_dao = new DeclarationDataAdapterHeavyLorry()); + +// protected override void Initialize() +// { +// var vehicle = JobInputData.Vehicle; +// 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); +// } +// Driverdata = Dao.CreateDriverData(); +// Driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(Segment.AccelerationFile); +// var tempVehicle = Dao.CreateVehicleData( +// vehicle, Segment, Segment.Missions.First(), +// Segment.Missions.First().Loadings.First(), _allowVocational); + +// var vtpMission = Segment.VehicleClass.IsMediumLorry() +// ? DeclarationData.VTPMode.SelectedMissionMediumLorry +// : DeclarationData.VTPMode.SelectedMissionHeavyLorry; + +// AirdragData = Dao.CreateAirdragData( +// vehicle.Components.AirdragInputData, +// Segment.Missions.First(), Segment); +// EngineData = Dao.CreateEngineData( +// vehicle, vehicle.Components.EngineInputData.EngineModes.First(), +// new Mission() { MissionType = vtpMission }); +// AxlegearData = JobInputData.Vehicle.Components.GearboxInputData.DifferentialIncluded +// ? Dao.CreateDummyAxleGearData(JobInputData.Vehicle.Components.GearboxInputData) +// : Dao.CreateAxleGearData(vehicle.Components.AxleGearInputData); +// AngledriveData = Dao.CreateAngledriveData(vehicle.Components.AngledriveInputData); + +// GearboxData = Dao.CreateGearboxData( +// vehicle, new VectoRunData() { EngineData = EngineData, AxleGearData = AxlegearData, VehicleData = tempVehicle }, +// null); +// RetarderData = Dao.CreateRetarderData(vehicle.Components.RetarderInputData); + +// PTOTransmissionData = +// Dao.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData); + +// GearshiftData = Dao.CreateGearshiftData( +// GearboxData, AxlegearData.AxleGear.Ratio * (AngledriveData?.Angledrive.Ratio ?? 1.0), EngineData.IdleSpeed); + +// AuxVTP = CreateVTPAuxData(vehicle); +// } + +// protected override IEnumerable<VectoRunData.AuxData> GetAuxiliaryData(MissionType missionType) +// { +// return Dao.CreateAuxiliaryData( +// JobInputData.Vehicle.Components.AuxiliaryInputData, +// JobInputData.Vehicle.Components.BusAuxiliaries, +// missionType, +// Segment.VehicleClass, JobInputData.Vehicle.Length, +// JobInputData.Vehicle.Components.AxleWheels.NumSteeredAxles); +// } + +// protected virtual List<VectoRunData.AuxData> CreateVTPAuxData(IVehicleDeclarationInputData vehicle) +// { +// var numSteered = vehicle.Components.AxleWheels.NumSteeredAxles; +// var auxRD = Dao.CreateAuxiliaryData( +// vehicle.Components.AuxiliaryInputData, vehicle.Components.BusAuxiliaries, MissionType.RegionalDelivery, Segment.VehicleClass, vehicle.Length, numSteered) +// .ToList(); +// foreach (var entry in auxRD) { +// entry.MissionType = MissionType.RegionalDelivery; +// } + +// var auxLH = Dao.CreateAuxiliaryData( +// vehicle.Components.AuxiliaryInputData, vehicle.Components.BusAuxiliaries, MissionType.LongHaul, Segment.VehicleClass, vehicle.Length, numSteered) +// .ToList(); +// foreach (var entry in auxLH) { +// entry.MissionType = MissionType.LongHaul; +// } + +// var auxUD = Dao.CreateAuxiliaryData( +// vehicle.Components.AuxiliaryInputData, vehicle.Components.BusAuxiliaries, MissionType.UrbanDelivery, Segment.VehicleClass, vehicle.Length, numSteered) +// .ToList(); +// foreach (var entry in auxUD) { +// entry.MissionType = MissionType.UrbanDelivery; +// } + +// var aux = new List<VectoRunData.AuxData>(); +// aux.AddRange(auxRD); +// aux.AddRange(auxLH); +// aux.AddRange(auxUD); + +// aux.RemoveAll(x => x.ID == Constants.Auxiliaries.IDs.Fan); +// aux.Add( +// new VectoRunData.AuxData { +// DemandType = AuxiliaryDemandType.Direct, +// ID = DrivingCycleDataReader.Fields.AdditionalAuxPowerDemand +// }); +// return aux; +// } + +// public override IEnumerable<VectoRunData> NextRun() +// { +// if (InitException != null) { +// throw InitException; +// } + +// // simulate the Measured cycle +// var vtpCycle = JobInputData.Cycles.FirstOrDefault(); +// if (vtpCycle == null) { +// throw new VectoException("no VTP-Cycle provided!"); +// } + +// var drivingCycle = DrivingCycleDataReader.ReadFromDataTable(vtpCycle.CycleData, vtpCycle.Name, false); + +// // Loading is not relevant as we use P_wheel +// var vtpRunData = CreateVectoRunData(Segment, Segment.Missions.First(), Tuple.Create<Kilogram, double?>(0.SI<Kilogram>(), null)); +// vtpRunData.Cycle = new DrivingCycleProxy(drivingCycle, vtpCycle.Name); +// vtpRunData.Aux = AuxVTP; +// vtpRunData.FanDataVTP = GetFanData(); +// vtpRunData.ExecutionMode = ExecutionMode.Declaration; +// vtpRunData.SimulationType = SimulationType.VerificationTest; +// vtpRunData.Mission = new Mission() { +// MissionType = MissionType.VerificationTest +// }; +// vtpRunData.VehicleData.VehicleClass = Segment.VehicleClass; +// vtpRunData.VehicleData.LegislativeClass = JobInputData.Vehicle.LegislativeClass; +// vtpRunData.DriverData = Driverdata; + +// //var ncvStd = DeclarationData.FuelData.Lookup(JobInputData.Vehicle.Components.EngineInputData.FuelType).LowerHeatingValueVecto; +// //var ncvCorrection = ncvStd / JobInputData.NetCalorificValueTestFuel; +// var mileageCorrection = GetMileagecorrectionFactor(JobInputData.Mileage); +// vtpRunData.VTPData = new VTPData() { +// CorrectionFactor = mileageCorrection, +// }; +// yield return vtpRunData; +// } +// } +//} diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringVTPModeVectoRunDataFactoryHeavyBusPrimary.cs b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringVTPModeVectoRunDataFactoryHeavyBusPrimary.cs index 934ea74c7e67be9d68cf07b84a7fadab9cc63fef..1fde68525ea304f0e42368a202c68ba2d85188b5 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringVTPModeVectoRunDataFactoryHeavyBusPrimary.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringVTPModeVectoRunDataFactoryHeavyBusPrimary.cs @@ -1,52 +1,52 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using TUGraz.VectoCommon.InputData; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.InputData.Reader.ComponentData; -using TUGraz.VectoCore.Models.Declaration; -using TUGraz.VectoCore.Models.Simulation.Data; -using TUGraz.VectoCore.OutputData; +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using TUGraz.VectoCommon.InputData; +//using TUGraz.VectoCommon.Models; +//using TUGraz.VectoCommon.Utils; +//using TUGraz.VectoCore.InputData.Reader.ComponentData; +//using TUGraz.VectoCore.Models.Declaration; +//using TUGraz.VectoCore.Models.Simulation.Data; +//using TUGraz.VectoCore.OutputData; -namespace TUGraz.VectoCore.InputData.Reader.Impl { - internal class EngineeringVTPModeVectoRunDataFactoryHeavyBusPrimary : DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary - { - public EngineeringVTPModeVectoRunDataFactoryHeavyBusPrimary(IVTPEngineeringInputDataProvider ivtpProvider) : base( - ivtpProvider.JobInputData, null) - { - throw new Exception("VTP Simulation in engineering mode for heavy buses not supported"); - } +//namespace TUGraz.VectoCore.InputData.Reader.Impl { +// internal class EngineeringVTPModeVectoRunDataFactoryHeavyBusPrimary : DeclarationVTPModeVectoRunDataFactoryHeavyBusPrimary +// { +// public EngineeringVTPModeVectoRunDataFactoryHeavyBusPrimary(IVTPEngineeringInputDataProvider ivtpProvider) : base( +// ivtpProvider.JobInputData, null) +// { +// throw new Exception("VTP Simulation in engineering mode for heavy buses not supported"); +// } - public override IEnumerable<VectoRunData> NextRun() - { - if (InitException != null) { - throw InitException; - } - return JobInputData.Cycles.Select( - cycle => { - var drivingCycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, cycle.Name, false); - // loading is not relevant as we use P_wheel - var runData = CreateVectoRunData(Segment, Segment.Missions.First(), new Tuple<Kilogram, double?>(0.SI<Kilogram>(), null)); - runData.Cycle = new DrivingCycleProxy(drivingCycle, cycle.Name); - runData.Aux = AuxVTP; - runData.FanDataVTP = GetFanData(); - runData.ExecutionMode = ExecutionMode.Engineering; - runData.SimulationType = SimulationType.VerificationTest; - runData.Mission = new Mission() { - MissionType = MissionType.VerificationTest - }; - runData.DriverData = Driverdata; - return runData; - }); - } +// public override IEnumerable<VectoRunData> NextRun() +// { +// if (InitException != null) { +// throw InitException; +// } +// return JobInputData.Cycles.Select( +// cycle => { +// var drivingCycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, cycle.Name, false); +// // loading is not relevant as we use P_wheel +// var runData = CreateVectoRunData(Segment, Segment.Missions.First(), new Tuple<Kilogram, double?>(0.SI<Kilogram>(), null)); +// runData.Cycle = new DrivingCycleProxy(drivingCycle, cycle.Name); +// runData.Aux = AuxVTP; +// runData.FanDataVTP = GetFanData(); +// runData.ExecutionMode = ExecutionMode.Engineering; +// runData.SimulationType = SimulationType.VerificationTest; +// runData.Mission = new Mission() { +// MissionType = MissionType.VerificationTest +// }; +// runData.DriverData = Driverdata; +// return runData; +// }); +// } - protected override AuxFanData GetFanData() - { - return new AuxFanData() { - FanCoefficients = JobInputData.FanPowerCoefficents.ToArray(), - FanDiameter = JobInputData.FanDiameter, - }; - } - } -} \ No newline at end of file +// protected override AuxFanData GetFanData() +// { +// return new AuxFanData() { +// FanCoefficients = JobInputData.FanPowerCoefficents.ToArray(), +// FanDiameter = JobInputData.FanDiameter, +// }; +// } +// } +//} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringVTPModeVectoRunDataFactoryLorries.cs b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringVTPModeVectoRunDataFactoryLorries.cs index cc9b43eaa0f8c72086cdc865be51b33f2411074e..1c3f8727320c2588cbf135ca2d397f65d690b172 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringVTPModeVectoRunDataFactoryLorries.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringVTPModeVectoRunDataFactoryLorries.cs @@ -1,86 +1,86 @@ -/* -* 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 -*/ +///* +//* This file is part of VECTO. +//* +//* Copyright © 2012-2019 European Union +//* +//* Developed by Graz University of Technology, +//* Institute of Internal Combustion Engines and Thermodynamics, +//* Institute of Technical Informatics +//* +//* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved +//* by the European Commission - subsequent versions of the EUPL (the "Licence"); +//* You may not use VECTO except in compliance with the Licence. +//* You may obtain a copy of the Licence at: +//* +//* https://joinup.ec.europa.eu/community/eupl/og_page/eupl +//* +//* Unless required by applicable law or agreed to in writing, VECTO +//* distributed under the Licence is distributed on an "AS IS" basis, +//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +//* See the Licence for the specific language governing permissions and +//* limitations under the Licence. +//* +//* Authors: +//* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology +//* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology +//* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology +//* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology +//* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology +//* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology +//*/ -using System; -using System.Collections.Generic; -using System.Linq; -using TUGraz.VectoCommon.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 System; +//using System.Collections.Generic; +//using System.Linq; +//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; -namespace TUGraz.VectoCore.InputData.Reader.Impl -{ - internal class EngineeringVTPModeVectoRunDataFactoryLorries : DeclarationVTPModeVectoRunDataFactoryLorries - { +//namespace TUGraz.VectoCore.InputData.Reader.Impl +//{ +// internal class EngineeringVTPModeVectoRunDataFactoryLorries : DeclarationVTPModeVectoRunDataFactoryLorries +// { - private EngineeringDataAdapter _engineeringDao = new EngineeringDataAdapter(); +// private EngineeringDataAdapter _engineeringDao = new EngineeringDataAdapter(); - public EngineeringVTPModeVectoRunDataFactoryLorries(IVTPEngineeringInputDataProvider ivtpProvider) : base(ivtpProvider.JobInputData, null) - { +// public EngineeringVTPModeVectoRunDataFactoryLorries(IVTPEngineeringInputDataProvider ivtpProvider) : base(ivtpProvider.JobInputData, null) +// { - } +// } - public override IEnumerable<VectoRunData> NextRun() - { - if (InitException != null) { - throw InitException; - } - return JobInputData.Cycles.Select( - cycle => { - var drivingCycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, cycle.Name, false); - // loading is not relevant as we use P_wheel - var runData = CreateVectoRunData(Segment, Segment.Missions.First(), new Tuple<Kilogram, double?>(0.SI<Kilogram>(), null)); - runData.Cycle = new DrivingCycleProxy(drivingCycle, cycle.Name); - runData.Aux = AuxVTP; - runData.FanDataVTP = GetFanData(); - runData.ExecutionMode = ExecutionMode.Engineering; - runData.SimulationType = SimulationType.VerificationTest; - runData.Mission = new Mission() { - MissionType = MissionType.VerificationTest - }; - runData.DriverData = Driverdata; - return runData; - }); - } +// public override IEnumerable<VectoRunData> NextRun() +// { +// if (InitException != null) { +// throw InitException; +// } +// return JobInputData.Cycles.Select( +// cycle => { +// var drivingCycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, cycle.Name, false); +// // loading is not relevant as we use P_wheel +// var runData = CreateVectoRunData(Segment, Segment.Missions.First(), new Tuple<Kilogram, double?>(0.SI<Kilogram>(), null)); +// runData.Cycle = new DrivingCycleProxy(drivingCycle, cycle.Name); +// runData.Aux = AuxVTP; +// runData.FanDataVTP = GetFanData(); +// runData.ExecutionMode = ExecutionMode.Engineering; +// runData.SimulationType = SimulationType.VerificationTest; +// runData.Mission = new Mission() { +// MissionType = MissionType.VerificationTest +// }; +// runData.DriverData = Driverdata; +// return runData; +// }); +// } - protected override AuxFanData GetFanData() - { - return new AuxFanData() { - FanCoefficients = JobInputData.FanPowerCoefficents.ToArray(), - FanDiameter = JobInputData.FanDiameter, - }; - } - } -} +// protected override AuxFanData GetFanData() +// { +// return new AuxFanData() { +// FanCoefficients = JobInputData.FanPowerCoefficents.ToArray(), +// FanDiameter = JobInputData.FanDiameter, +// }; +// } +// } +//} diff --git a/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryFactory.cs b/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryFactory.cs index 73e944e9c262fd4f9096f915b9eee054e194ff9f..d905c718d3995521febf7e3c69c3c587df763a44 100644 --- a/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/VectoRunDataFactoryFactory.cs @@ -100,16 +100,17 @@ namespace TUGraz.VectoCore.InputData.Reader private IVectoRunDataFactory CreateRunDataReader(IVTPDeclarationInputDataProvider vtpProvider, IDeclarationReport report) { + throw new NotImplementedException(); var vtpReport = CastReport<IVTPReport>(report); 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); } diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricsUserInputsConfig.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricsUserInputsConfig.cs index 86610f8f3fdd3a42db6b30049ddde0fa450b0e2e..0d6afbc0d6cefd9cccc69c5965998f8973ac8322 100644 --- a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricsUserInputsConfig.cs +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricsUserInputsConfig.cs @@ -39,7 +39,7 @@ namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electric public AlternatorType AlternatorType { get; set; } [JsonIgnore] - public Dictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry> ElectricalConsumers { get; set; } + public IDictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry> ElectricalConsumers { get; set; } public string[] ElectricalConsumersSerialized { diff --git a/VectoCore/VectoCore/Models/GenericModelData/GenericBusEngineData.cs b/VectoCore/VectoCore/Models/GenericModelData/GenericBusEngineData.cs index a6ac03e7afa17c3eeddd1e2d7a1651e645866eeb..79a3ff20049fe72e3959713e073d308d2cbadcb5 100644 --- a/VectoCore/VectoCore/Models/GenericModelData/GenericBusEngineData.cs +++ b/VectoCore/VectoCore/Models/GenericModelData/GenericBusEngineData.cs @@ -11,6 +11,7 @@ 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.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; using TUGraz.VectoCore.Utils; @@ -71,8 +72,8 @@ namespace TUGraz.VectoCore.Models.Declaration foreach (var gear in gearbox.Gears) { var maxTorque = VectoMath.Min( - DeclarationDataAdapterHeavyLorry.Conventional.GbxMaxTorque(gear, numGears, fullLoadCurves[0].MaxTorque), - DeclarationDataAdapterHeavyLorry.Conventional.VehMaxTorque(gear, numGears, limits, fullLoadCurves[0].MaxTorque)); + GearboxDataAdapter.GbxMaxTorque(gear, numGears, fullLoadCurves[0].MaxTorque), + VehicleDataAdapter.VehMaxTorque(gear, numGears, limits, fullLoadCurves[0].MaxTorque)); fullLoadCurves[(uint)gear.Gear] = AbstractSimulationDataAdapter.IntersectFullLoadCurves(fullLoadCurves[0], maxTorque); } diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory/SimulatorFactoryEngineering.cs b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory/SimulatorFactoryEngineering.cs index 6b195d204525f8720c805573138126a773a599cc..2be5184b7b1e5d2eff8d8b67a8dcd58dc0722f5a 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory/SimulatorFactoryEngineering.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory/SimulatorFactoryEngineering.cs @@ -1,4 +1,5 @@ -using TUGraz.VectoCommon.Exceptions; +using System; +using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCore.InputData.Reader.Impl; @@ -17,10 +18,12 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory { switch (dataProvider) { case IVTPEngineeringInputDataProvider vtpProvider when vtpProvider.JobInputData.Vehicle.VehicleCategory.IsLorry(): - RunDataFactory = new EngineeringVTPModeVectoRunDataFactoryLorries(vtpProvider); + throw new NotImplementedException(); + //RunDataFactory = new EngineeringVTPModeVectoRunDataFactoryLorries(vtpProvider); return; case IVTPEngineeringInputDataProvider vtpProvider when vtpProvider.JobInputData.Vehicle.VehicleCategory.IsBus(): - RunDataFactory = new EngineeringVTPModeVectoRunDataFactoryHeavyBusPrimary(vtpProvider); + throw new NotImplementedException(); + //RunDataFactory = new EngineeringVTPModeVectoRunDataFactoryHeavyBusPrimary(vtpProvider); return; case IEngineeringInputDataProvider engDataProvider when engDataProvider.JobInputData.JobType == VectoSimulationJobType.EngineOnlySimulation: RunDataFactory = new EngineOnlyVectoRunDataFactory(engDataProvider); diff --git a/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs b/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs index 034dc9a440a9871e7bd9e3f6b556b1f820a66133..3773a1dd533331268d8c5b3c9990834e40c88d88 100644 --- a/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs +++ b/VectoCore/VectoCoreTest/FileIO/SimulationDataReaderTest.cs @@ -38,7 +38,9 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.FileIO.JSON; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.HeavyLorry; using TUGraz.VectoCore.InputData.Reader.Impl; +using TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDataFactory; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Tests.Utils; @@ -66,7 +68,9 @@ namespace TUGraz.VectoCore.Tests.FileIO if (declarationProvider == null) { throw new VectoException("Failed to cas to Engineering InputDataProvider"); } - var reader = new DeclarationModeTruckVectoRunDataFactory(declarationProvider, null); + + var dataAdapter = new DeclarationDataAdapterHeavyLorry.Conventional(); + var reader = new DeclarationModeHeavyLorryRunDataFactory.Conventional(declarationProvider, null, dataAdapter); //reader.SetJobFile(DeclarationJob); var runData = reader.NextRun().First(); diff --git a/VectoCore/VectoCoreTest/InputData/DeclarationDataAdapterTest/DeclarationDataAdapterTest.cs b/VectoCore/VectoCoreTest/InputData/DeclarationDataAdapterTest/DeclarationDataAdapterTest.cs new file mode 100644 index 0000000000000000000000000000000000000000..f3a3a28eeed239980056ac60c2c8debd8775541b --- /dev/null +++ b/VectoCore/VectoCoreTest/InputData/DeclarationDataAdapterTest/DeclarationDataAdapterTest.cs @@ -0,0 +1,59 @@ +using System; +using Ninject; +using NUnit.Framework; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.HeavyLorry; +using TUGraz.VectoCore.Utils.Ninject; + +namespace TUGraz.VectoCore.Tests.InputData.DeclarationDataAdapterTest +{ + [TestFixture] + public class DeclarationDataAdapterTest + { + private IDeclarationDataAdapterFactory _declarationDataAdapterFactory; + + public void OneTimeSetup() + { + var kernel = new StandardKernel(new VectoNinjectModule()); + _declarationDataAdapterFactory = kernel.Get<IDeclarationDataAdapterFactory>(); + } + #region LorriesSerialHybridVehicle + + [TestCase(VectoSimulationJobType.ConventionalVehicle, ArchitectureID.UNKNOWN, VehicleCategoryHelper.Lorry, false, typeof(DeclarationDataAdapterHeavyLorry.Conventional))] + [TestCase(VectoSimulationJobType.SerialHybridVehicle, ArchitectureID.S2, VehicleCategoryHelper.Lorry, false, typeof(DeclarationDataAdapterHeavyLorry.HEV_S2))] + [TestCase(VectoSimulationJobType.SerialHybridVehicle, ArchitectureID.S3, VehicleCategoryHelper.Lorry, false, typeof(DeclarationDataAdapterHeavyLorry.HEV_S3))] + [TestCase(VectoSimulationJobType.SerialHybridVehicle, ArchitectureID.S4, VehicleCategoryHelper.Lorry, false, typeof(DeclarationDataAdapterHeavyLorry.HEV_S4))] + [TestCase(VectoSimulationJobType.SerialHybridVehicle, ArchitectureID.S_IEPC, VehicleCategoryHelper.Lorry, false, typeof(DeclarationDataAdapterHeavyLorry.HEV_S_IEPC))] + [TestCase(VectoSimulationJobType.ParallelHybridVehicle, ArchitectureID.P1, VehicleCategoryHelper.Lorry, false, typeof(DeclarationDataAdapterHeavyLorry.HEV_P1))] + [TestCase(VectoSimulationJobType.ParallelHybridVehicle, ArchitectureID.P2, VehicleCategoryHelper.Lorry, false, typeof(DeclarationDataAdapterHeavyLorry.HEV_P2))] + [TestCase(VectoSimulationJobType.ParallelHybridVehicle, ArchitectureID.P2_5, VehicleCategoryHelper.Lorry, false, typeof(DeclarationDataAdapterHeavyLorry.HEV_P2_5))] + [TestCase(VectoSimulationJobType.ParallelHybridVehicle, ArchitectureID.P3, VehicleCategoryHelper.Lorry, false, typeof(DeclarationDataAdapterHeavyLorry.HEV_P3))] + [TestCase(VectoSimulationJobType.ParallelHybridVehicle, ArchitectureID.P4, VehicleCategoryHelper.Lorry, false, typeof(DeclarationDataAdapterHeavyLorry.HEV_P4))] + [TestCase(VectoSimulationJobType.BatteryElectricVehicle, ArchitectureID.E2, VehicleCategoryHelper.Lorry, false, typeof(DeclarationDataAdapterHeavyLorry.PEV_E2))] + [TestCase(VectoSimulationJobType.BatteryElectricVehicle, ArchitectureID.E3, VehicleCategoryHelper.Lorry, false, typeof(DeclarationDataAdapterHeavyLorry.PEV_E3))] + [TestCase(VectoSimulationJobType.BatteryElectricVehicle, ArchitectureID.E4, VehicleCategoryHelper.Lorry, false, typeof(DeclarationDataAdapterHeavyLorry.PEV_E4))] + [TestCase(VectoSimulationJobType.BatteryElectricVehicle, ArchitectureID.E_IEPC, VehicleCategoryHelper.Lorry, false, typeof(DeclarationDataAdapterHeavyLorry.PEV_E_IEPC))] + + public void DeclarationDataAdapterFactoryTest(VectoSimulationJobType jobType, ArchitectureID archId, + string vehicleType, bool exempted, Type expectedType) + { + var iepc = false; + var ihpc = false; + var vehicleClassification = + new VehicleTypeAndArchitectureStringHelperRundata.VehicleClassification(jobType, archId, vehicleType, + exempted, iepc, ihpc); + var result =_declarationDataAdapterFactory.CreateDataAdapter(vehicleClassification); + Assert.AreEqual(expectedType, result.GetType()); + } + + + + #endregion + + + + + } +} \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/InputData/RunDataFactory/RunDataFactoryFactoryTest.cs b/VectoCore/VectoCoreTest/InputData/RunDataFactory/RunDataFactoryFactoryTest.cs index a48fe62e1d1a62080a7a702dda9aab75b5a23b25..e14359412fedd59dfe3d2a8ba5913f824b93150a 100644 --- a/VectoCore/VectoCoreTest/InputData/RunDataFactory/RunDataFactoryFactoryTest.cs +++ b/VectoCore/VectoCoreTest/InputData/RunDataFactory/RunDataFactoryFactoryTest.cs @@ -70,11 +70,11 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory Type specificDataAdapter) { - var genericPropertyInfo = runDataResult.GetType().GetProperty(nameof(DeclarationModeCompletedBusRunDataFactory.CompletedBusBase.GenericDataAdapter)); + var genericPropertyInfo = runDataResult.GetType().GetProperty(nameof(DeclarationModeCompletedBusRunDataFactory.CompletedBusBase.DataAdapterGeneric)); var generic = genericPropertyInfo.GetValue(runDataResult, null); - var specificPropertyInfo = runDataResult.GetType().GetProperty(nameof(DeclarationModeCompletedBusRunDataFactory.CompletedBusBase.SpecificDataAdapter)); + var specificPropertyInfo = runDataResult.GetType().GetProperty(nameof(DeclarationModeCompletedBusRunDataFactory.CompletedBusBase.DataAdapterSpecific)); var specific = specificPropertyInfo.GetValue(runDataResult, null); Assert.AreEqual(genericDataAdapter, generic.GetType()); @@ -406,7 +406,7 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory .CompletedBus(); var fact = CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.Conventional)); if(checkCompletedBusAdapters){ - CheckCompletedBusAdapters(fact, typeof(DeclarationDataAdapterGenericCompletedBus.Conventional), + CheckCompletedBusAdapters(fact, typeof(DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.Conventional), typeof(DeclarationDataAdapterSpecificCompletedBus.Conventional)); } @@ -422,7 +422,7 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory var fact = CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_S2)); if (checkCompletedBusAdapters) { - CheckCompletedBusAdapters(fact, typeof(DeclarationDataAdapterGenericCompletedBus.HEV_S2), + CheckCompletedBusAdapters(fact, typeof(DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_S2), typeof(DeclarationDataAdapterSpecificCompletedBus.HEV_S2)); } @@ -438,7 +438,7 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory var fact = CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_S3)); if (checkCompletedBusAdapters) { - CheckCompletedBusAdapters(fact, typeof(DeclarationDataAdapterGenericCompletedBus.HEV_S3), + CheckCompletedBusAdapters(fact, typeof(DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_S3), typeof(DeclarationDataAdapterSpecificCompletedBus.HEV_S3)); } } @@ -453,7 +453,7 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory var fact = CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_S4)); if (checkCompletedBusAdapters) { - CheckCompletedBusAdapters(fact, typeof(DeclarationDataAdapterGenericCompletedBus.HEV_S4), + CheckCompletedBusAdapters(fact, typeof(DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_S4), typeof(DeclarationDataAdapterSpecificCompletedBus.HEV_S4)); } } @@ -468,7 +468,7 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory var fact = CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_S_IEPC)); if (checkCompletedBusAdapters) { - CheckCompletedBusAdapters(fact, typeof(DeclarationDataAdapterGenericCompletedBus.HEV_S_IEPC), + CheckCompletedBusAdapters(fact, typeof(DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_S_IEPC), typeof(DeclarationDataAdapterSpecificCompletedBus.HEV_S_IEPC)); } } @@ -483,7 +483,7 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory var fact = CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_P1)); if (checkCompletedBusAdapters) { - CheckCompletedBusAdapters(fact, typeof(DeclarationDataAdapterGenericCompletedBus.HEV_P1), + CheckCompletedBusAdapters(fact, typeof(DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_P1), typeof(DeclarationDataAdapterSpecificCompletedBus.HEV_P1)); } } @@ -499,7 +499,7 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory var fact = CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_P2)); if (checkCompletedBusAdapters) { - CheckCompletedBusAdapters(fact, typeof(DeclarationDataAdapterGenericCompletedBus.HEV_P2), + CheckCompletedBusAdapters(fact, typeof(DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_P2), typeof(DeclarationDataAdapterSpecificCompletedBus.HEV_P2)); } } @@ -515,7 +515,7 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory var fact = CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_P3)); if (checkCompletedBusAdapters) { - CheckCompletedBusAdapters(fact, typeof(DeclarationDataAdapterGenericCompletedBus.HEV_P3), + CheckCompletedBusAdapters(fact, typeof(DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_P3), typeof(DeclarationDataAdapterSpecificCompletedBus.HEV_P3)); } } @@ -531,7 +531,7 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory var fact = CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_P2_5)); if (checkCompletedBusAdapters) { - CheckCompletedBusAdapters(fact, typeof(DeclarationDataAdapterGenericCompletedBus.HEV_P2_5), + CheckCompletedBusAdapters(fact, typeof(DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_P2_5), typeof(DeclarationDataAdapterSpecificCompletedBus.HEV_P2_5)); } } @@ -547,7 +547,7 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory var fact = CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.HEV_P4)); if (checkCompletedBusAdapters) { - CheckCompletedBusAdapters(fact, typeof(DeclarationDataAdapterGenericCompletedBus.HEV_P4), + CheckCompletedBusAdapters(fact, typeof(DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.HEV_P4), typeof(DeclarationDataAdapterSpecificCompletedBus.HEV_P4)); } } @@ -563,7 +563,7 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory var fact = CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.PEV_E2)); if (checkCompletedBusAdapters) { - CheckCompletedBusAdapters(fact, typeof(DeclarationDataAdapterGenericCompletedBus.PEV_E2), + CheckCompletedBusAdapters(fact, typeof(DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.PEV_E2), typeof(DeclarationDataAdapterSpecificCompletedBus.PEV_E2)); } } @@ -579,7 +579,7 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory var fact = CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.PEV_E3)); if (checkCompletedBusAdapters) { - CheckCompletedBusAdapters(fact, typeof(DeclarationDataAdapterGenericCompletedBus.PEV_E3), + CheckCompletedBusAdapters(fact, typeof(DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.PEV_E3), typeof(DeclarationDataAdapterSpecificCompletedBus.PEV_E3)); } } @@ -593,7 +593,7 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory var fact = CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.PEV_E4)); if (checkCompletedBusAdapters) { - CheckCompletedBusAdapters(fact, typeof(DeclarationDataAdapterGenericCompletedBus.PEV_E4), + CheckCompletedBusAdapters(fact, typeof(DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.PEV_E4), typeof(DeclarationDataAdapterSpecificCompletedBus.PEV_E4)); } } @@ -608,7 +608,7 @@ namespace TUGraz.VectoCore.Tests.InputData.RunDataFactory var fact = CreateRunDataFactory(input, typeof(DeclarationModeCompletedBusRunDataFactory.PEV_E_IEPC)); if (checkCompletedBusAdapters) { - CheckCompletedBusAdapters(fact, typeof(DeclarationDataAdapterGenericCompletedBus.PEV_E_IEPC), + CheckCompletedBusAdapters(fact, typeof(DeclarationDeclarationDataAdapterGenericCompletedBusDeclaration.PEV_E_IEPC), typeof(DeclarationDataAdapterSpecificCompletedBus.PEV_E_IEPC)); } diff --git a/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs b/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs index 4ae2f2680f9963e6261225fa4f2bf2316874c8b7..bdeffa321da5310bba1b1ade2143a557b0d495e2 100644 --- a/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs +++ b/VectoCore/VectoCoreTest/Integration/CompletedBus/CompletedBusFactorMethodTest.cs @@ -23,6 +23,7 @@ using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.OutputData.FileIO; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.HeavyLorry; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponents; using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC; using TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; @@ -930,7 +931,7 @@ namespace TUGraz.VectoCore.Tests.Integration.CompletedBus { return new CrosswindCorrectionCdxALookup( aerodynamicDragArea, - DeclarationDataAdapterHeavyLorry.Conventional.GetDeclarationAirResistanceCurve( + new AirdragDataAdapter().GetDeclarationAirResistanceCurve( crossWindCorrectionParams, aerodynamicDragArea, vehicleHeight), diff --git a/VectoCore/VectoCoreTest/Models/Declaration/DataAdapter/DeclarationAdapterTestHelper.cs b/VectoCore/VectoCoreTest/Models/Declaration/DataAdapter/DeclarationAdapterTestHelper.cs index 78816d37eab8a577c55fc24561fe264b56dbe2f1..eaac08280ffc2ddb5413821d0984eff6da63f70c 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/DataAdapter/DeclarationAdapterTestHelper.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/DataAdapter/DeclarationAdapterTestHelper.cs @@ -30,9 +30,11 @@ */ using System.Linq; +using Ninject; using NUnit.Framework; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; +using TUGraz.VectoCore.InputData; using TUGraz.VectoCore.InputData.FileIO.JSON; using TUGraz.VectoCore.InputData.Reader.Impl; using TUGraz.VectoCore.Models.Declaration; @@ -46,7 +48,10 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration.DataAdapter public static VectoRunData[] CreateVectoRunData(string file) { var inputData = (IDeclarationInputDataProvider)JSONInputDataFactory.ReadJsonJob(file); - var dataReader = new DeclarationModeTruckVectoRunDataFactory(inputData, null); + var kernel = new StandardKernel(new VectoNinjectModule()); + //var dataReader = new DeclarationModeTruckVectoRunDataFactory(inputData, null); + var dataReader = kernel.Get<IVectoRunDataFactoryFactory>() + .CreateDeclarationRunDataFactory(inputData, null, null); var runData = dataReader.NextRun().ToArray(); return runData; } diff --git a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs index 49685ca7fc07502c4a2c4f417a14091b31b30570..80366f628ca27a84940affa1846b73a10f9934dd 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs @@ -42,7 +42,9 @@ using TUGraz.VectoCore.InputData.FileIO.JSON; using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.HeavyLorry; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponents; using TUGraz.VectoCore.InputData.Reader.Impl; +using TUGraz.VectoCore.InputData.Reader.Impl.DeclarationMode.HeavyLorryRunDataFactory; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Tests.Utils; @@ -227,7 +229,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration double expected) { var crossWindCorrectionCurve = new CrosswindCorrectionCdxALookup(crossSectionArea.SI<SquareMeter>(), - DeclarationDataAdapterHeavyLorry.GetDeclarationAirResistanceCurve(parameterSet, crossSectionArea.SI<SquareMeter>(), + new AirdragDataAdapter().GetDeclarationAirResistanceCurve(parameterSet, crossSectionArea.SI<SquareMeter>(), height.SI<Meter>()), CrossWindCorrectionMode.DeclarationModeCorrection); @@ -239,7 +241,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration public void CrossWindGetDeclarationAirResistance(string parameterSet, double cdxa0, double height) { var curve = - DeclarationDataAdapterHeavyLorry.GetDeclarationAirResistanceCurve(parameterSet, cdxa0.SI<SquareMeter>(), height.SI<Meter>()); + new AirdragDataAdapter().GetDeclarationAirResistanceCurve(parameterSet, cdxa0.SI<SquareMeter>(), height.SI<Meter>()); AssertHelper.AreRelativeEqual(60.KMPHtoMeterPerSecond(), curve[1].Velocity); AssertHelper.AreRelativeEqual(7.0418009.SI<SquareMeter>(), curve[1].EffectiveCrossSectionArea); @@ -267,7 +269,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration public void CrossWindCorrectionExceptionTest(string parameterSet, double crossSectionArea, double kmph, double height) { var crossWindCorrectionCurve = new CrosswindCorrectionCdxALookup(crossSectionArea.SI<SquareMeter>(), - DeclarationDataAdapterHeavyLorry.Conventional.GetDeclarationAirResistanceCurve(parameterSet, crossSectionArea.SI<SquareMeter>(), + new AirdragDataAdapter().GetDeclarationAirResistanceCurve(parameterSet, crossSectionArea.SI<SquareMeter>(), height.SI<Meter>()), CrossWindCorrectionMode.DeclarationModeCorrection); @@ -2085,7 +2087,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration { var dataProvider = JSONInputDataFactory.ReadJsonJob(@"TestData\Jobs\12t Delivery Truck.vecto") as IDeclarationInputDataProvider; - var dataReader = new DeclarationModeTruckVectoRunDataFactory(dataProvider, null); + var dataReader = new DeclarationModeHeavyLorryRunDataFactory.Conventional(dataProvider, null, new DeclarationDataAdapterHeavyLorry.Conventional()); var runs = dataReader.NextRun().ToList(); Assert.AreEqual(6, runs.Count); @@ -2109,7 +2111,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration var dataProvider = JSONInputDataFactory.ReadJsonJob( @"TestData\Jobs\Class4_40t_Long_Haul_Truck.vecto") as IDeclarationInputDataProvider; - var dataReader = new DeclarationModeTruckVectoRunDataFactory(dataProvider, null); + var dataReader = new DeclarationModeHeavyLorryRunDataFactory.Conventional(dataProvider, null, new DeclarationDataAdapterHeavyLorry.Conventional()); var runs = dataReader.NextRun().ToList(); Assert.AreEqual(8, runs.Count); @@ -2133,7 +2135,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration { var dataProvider = JSONInputDataFactory.ReadJsonJob(@"TestData\Jobs\40t_Long_Haul_Truck.vecto") as IDeclarationInputDataProvider; - var dataReader = new DeclarationModeTruckVectoRunDataFactory(dataProvider, null); + var dataReader = new DeclarationModeHeavyLorryRunDataFactory.Conventional(dataProvider, null, new DeclarationDataAdapterHeavyLorry.Conventional()); var runs = dataReader.NextRun().ToList(); diff --git a/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs index defefa5236c1aa672fc6618c51a1a7381cfd4d40..b23dfb53e0b007a3772c35a899e710adedff2cab 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs @@ -453,7 +453,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration }, }; - var dao = new DeclarationDataAdapterHeavyLorry(); + var dao = new DeclarationDataAdapterHeavyLorry.Conventional(); var gearboxData = new JSONGearboxDataV5(JSONInputDataFactory.ReadFile(gearboxFile), gearboxFile); var engineInput = new JSONEngineDataV3(JSONInputDataFactory.ReadFile(engineFile), engineFile); var vehicle = new MockDeclarationVehicleInputData() { @@ -505,7 +505,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration new Point(123.0457, 2530), }; - var dao = new DeclarationDataAdapterHeavyLorry(); + var dao = new DeclarationDataAdapterHeavyLorry.Conventional(); var gearboxData = new JSONGearboxDataV5(JSONInputDataFactory.ReadFile(gearboxFile), gearboxFile); var engineInput = new JSONEngineDataV3(JSONInputDataFactory.ReadFile(engineFile), engineFile); var vehicle = new MockDeclarationVehicleInputData() { @@ -622,7 +622,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration var gearboxData = job.JobInputData.Vehicle.Components.GearboxInputData; var idlespeed = VectoMath.Max( job.JobInputData.Vehicle.EngineIdleSpeed, job.JobInputData.Vehicle.Components.EngineInputData.EngineModes.First().IdleSpeed); - var dao = new DeclarationDataAdapterHeavyLorry(); + var dao = new DeclarationDataAdapterHeavyLorry.Conventional(); var engineData = dao.CreateEngineData(job.JobInputData.Vehicle, job.JobInputData.Vehicle.Components.EngineInputData.EngineModes.First(), new Mission() {MissionType = MissionType.LongHaul}); var axlegearRatio = job.JobInputData.Vehicle.Components.AxleGearInputData.Ratio; var rdyn = job.JobInputData.Vehicle.Components.AxleWheels.AxlesDeclaration.Where(x => x.AxleType == AxleType.VehicleDriven) @@ -876,7 +876,7 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration Assert.Inconclusive("Confidential File not found. Test cannot run without file."); } var inputData = xmlInputReader.CreateDeclaration(xmlJob); - var dao = new DeclarationDataAdapterHeavyLorry(); + var dao = new DeclarationDataAdapterHeavyLorry.Conventional(); var gearboxData = inputData.JobInputData.Vehicle.Components.GearboxInputData; var engineData = dao.CreateEngineData(inputData.JobInputData.Vehicle, inputData.JobInputData.Vehicle.Components.EngineInputData.EngineModes.First(), new Mission() {MissionType = MissionType.LongHaul}); diff --git a/VectoCore/VectoCoreTest/Models/EngineeringMode/EngineeringModeBusAuxTest.cs b/VectoCore/VectoCoreTest/Models/EngineeringMode/EngineeringModeBusAuxTest.cs index 9018b6bc2fe7cfecb697ee3e20855c60b44cd8a3..5b6137b0edb6ce2995de4e0fad9c7a0c78c52bea 100644 --- a/VectoCore/VectoCoreTest/Models/EngineeringMode/EngineeringModeBusAuxTest.cs +++ b/VectoCore/VectoCoreTest/Models/EngineeringMode/EngineeringModeBusAuxTest.cs @@ -16,6 +16,7 @@ using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.PrimaryBus; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponents; using TUGraz.VectoCore.InputData.Reader.Impl; using TUGraz.VectoCore.Models.BusAuxiliaries; using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics; @@ -1051,24 +1052,24 @@ namespace TUGraz.VectoCore.Tests.Models.EngineeringMode return retVal; } - private static Dictionary<string, ElectricConsumerEntry> GetElectricConsumers(Ampere currentDemand, Ampere currentDemandEngineOffDriving, Ampere currentDemandEngineOffStandstill) + private static IDictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry> GetElectricConsumers(Ampere currentDemand, Ampere currentDemandEngineOffDriving, Ampere currentDemandEngineOffStandstill) { - var retVal = new Dictionary<string, ElectricConsumerEntry>(); + var retVal = new Dictionary<string, AuxiliaryDataAdapter.ElectricConsumerEntry>(); var iBase = currentDemandEngineOffStandstill; var iSP = currentDemandEngineOffDriving - currentDemandEngineOffStandstill; var iFan = currentDemand - currentDemandEngineOffDriving; - retVal["BaseLoad"] = new ElectricConsumerEntry() { + retVal["BaseLoad"] = new AuxiliaryDataAdapter.ElectricConsumerEntry() { Current = iBase, BaseVehicle = true }; - retVal[Constants.Auxiliaries.IDs.SteeringPump] = new ElectricConsumerEntry() { + retVal[Constants.Auxiliaries.IDs.SteeringPump] = new AuxiliaryDataAdapter.ElectricConsumerEntry() { Current = iSP, ActiveDuringEngineStopStandstill = false, }; - retVal[Constants.Auxiliaries.IDs.Fan] = new ElectricConsumerEntry() { + retVal[Constants.Auxiliaries.IDs.Fan] = new AuxiliaryDataAdapter.ElectricConsumerEntry() { Current = iFan, ActiveDuringEngineStopStandstill = false, ActiveDuringEngineStopDriving = false, diff --git a/VectoCore/VectoCoreTest/Models/Simulation/PowerTrainBuilderTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/PowerTrainBuilderTest.cs index b96aef018182cfa4c73e2b2fb20758362f1e9b8c..4c9bba1b4b69246dc3f426ccab7a84f00c6617cc 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/PowerTrainBuilderTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/PowerTrainBuilderTest.cs @@ -31,9 +31,11 @@ using System.IO; using System.Linq; +using Ninject; using NUnit.Framework; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.InputData; using TUGraz.VectoCore.InputData.FileIO.JSON; using TUGraz.VectoCore.InputData.Reader.Impl; using TUGraz.VectoCore.Models.Connector.Ports; @@ -100,7 +102,9 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation if (provider == null) { throw new VectoException("Failed to cast to Declaration InputDataProvider"); } - var reader = new DeclarationModeTruckVectoRunDataFactory(provider, null); + var kernel = new StandardKernel(new VectoNinjectModule()); + var reader = kernel.Get<IVectoRunDataFactoryFactory>() + .CreateDeclarationRunDataFactory(provider, null, null); if (!shouldFail) { var runData = reader.NextRun().First(); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs index 03b0b59ca1e9bf0044926750a1c79828896dc353..2143195ea919e60817824387c8d4905eea5a5cea 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs @@ -265,7 +265,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var gearboxInput = JSONInputDataFactory.ReadGearbox(gbxFile); var engineInput = JSONInputDataFactory.ReadEngine(EngineDataFile); - var dao = new DeclarationDataAdapterHeavyLorry(); + var dao = new DeclarationDataAdapterHeavyLorry.Conventional(); var vehicleInput = new MockDeclarationVehicleInputData() { EngineInputData = engineInput, GearboxInputData = gearboxInput diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs index 35435a494a35e1a6463182c6a7af47a036004c8e..211ad23649212d898f4d2d80f8fb50de867439c7 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs @@ -522,7 +522,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var gearboxInput = JSONInputDataFactory.ReadGearbox(GearboxDataFile); var engineInput = JSONInputDataFactory.ReadEngine(EngineDataFile); - var dao = new DeclarationDataAdapterHeavyLorry(); + var dao = new DeclarationDataAdapterHeavyLorry.Conventional(); var engineData = dao.CreateEngineData(new MockDeclarationVehicleInputData() { EngineInputData = engineInput, GearboxInputData = gearboxInput @@ -588,7 +588,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var gearboxInput = JSONInputDataFactory.ReadGearbox(GearboxDataFile); var engineInput = JSONInputDataFactory.ReadEngine(EngineDataFile); - var dao = new DeclarationDataAdapterHeavyLorry(); + var dao = new DeclarationDataAdapterHeavyLorry.Conventional(); var engineData = dao.CreateEngineData(new MockDeclarationVehicleInputData() { EngineInputData = engineInput, GearboxInputData = gearboxInput diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs index 7b0e6e6df52f43e7ddc9efee3c889f7691d87cde..e47c29e1c541aa9452ab8e9f295b0855d7f1a4e3 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs @@ -39,6 +39,7 @@ using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.HeavyLorry; +using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter.SimulationComponents; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Models.Simulation.Impl; @@ -58,6 +59,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent private const string VehicleDataFileTruck = @"TestData\Components\40t_Long_Haul_Truck.vveh"; public static readonly double Tolerance = 0.001; + private static AirdragDataAdapter _airdragDataAdapter = new AirdragDataAdapter(); [OneTimeSetUp] public void RunBeforeAnyTests() { @@ -125,7 +127,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var vehicleData = MockSimulationDataFactory.CreateVehicleDataFromFile(VehicleDataFileTruck); var airdragData = MockSimulationDataFactory.CreateAirdragDataFromFile(VehicleDataFileTruck); airdragData.CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup(6.46.SI<SquareMeter>(), - DeclarationDataAdapterHeavyLorry.Conventional.GetDeclarationAirResistanceCurve("TractorSemitrailer", + _airdragDataAdapter.GetDeclarationAirResistanceCurve("TractorSemitrailer", 6.46.SI<SquareMeter>(), height.SI<Meter>()), CrossWindCorrectionMode.DeclarationModeCorrection); var vehicle = new Vehicle(container, vehicleData,airdragData); new DummyCycle(container); @@ -150,7 +152,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var vehicleData = MockSimulationDataFactory.CreateVehicleDataFromFile(VehicleDataFileTruck); var airdragData = MockSimulationDataFactory.CreateAirdragDataFromFile(VehicleDataFileTruck); airdragData.CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup(6.2985.SI<SquareMeter>(), - DeclarationDataAdapterHeavyLorry.GetDeclarationAirResistanceCurve("TractorSemitrailer", + _airdragDataAdapter.GetDeclarationAirResistanceCurve("TractorSemitrailer", 6.2985.SI<SquareMeter>(), 3.SI<Meter>()), CrossWindCorrectionMode.DeclarationModeCorrection); container.RunData = new VectoRunData() { VehicleData = vehicleData, diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs index 9ce9851a6f46adfdaa558df76c3c8b44781d28e5..6685b6e5938943b49842566766a1a547b5511c34 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs @@ -178,7 +178,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData WHTCRural = 1.1, WHTCUrban = 1.1 }; - var dao = new DeclarationDataAdapterHeavyLorry(); + var dao = new DeclarationDataAdapterHeavyLorry.Conventional(); var dummyGearbox = new DummyGearboxData() { Type = GearboxType.AMT, diff --git a/VectoCore/VectoCoreTest/Models/WHRMapReaderTest.cs b/VectoCore/VectoCoreTest/Models/WHRMapReaderTest.cs index aab45e2209ee816bda70d84ff2a6a4a83c471c76..40e23061c8538f6afa7919c6d8ab25f5efb354f1 100644 --- a/VectoCore/VectoCoreTest/Models/WHRMapReaderTest.cs +++ b/VectoCore/VectoCoreTest/Models/WHRMapReaderTest.cs @@ -7,6 +7,7 @@ using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData; using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.InputData.Reader.Impl; @@ -31,6 +32,7 @@ namespace TUGraz.VectoCore.Tests.Models protected IXMLInputDataReader xmlInputReader; private IKernel _kernel; + private IVectoRunDataFactoryFactory _runDataFactory; [OneTimeSetUp] public void RunBeforeAnyTests() @@ -106,7 +108,9 @@ namespace TUGraz.VectoCore.Tests.Models { var reader = XmlReader.Create(SingleFuelWHRVehicle); var inputDataProvider = xmlInputReader.Create(reader) as IDeclarationInputDataProvider; - var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = _runDataFactory.CreateDeclarationRunDataFactory(inputDataProvider, new NullDeclarationReport(), + new NullVTPReport()); + //var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); var runs = dao.NextRun().ToArray(); Assert.AreEqual(10, runs.Length); @@ -129,8 +133,9 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - - var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + + var dao = _runDataFactory.CreateDeclarationRunDataFactory(inputDataProvider, new NullDeclarationReport(), + new NullVTPReport()); AssertHelper.Exception<VectoXMLException>( () => { var runs = dao.NextRun().ToArray(); @@ -154,7 +159,8 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = _runDataFactory.CreateDeclarationRunDataFactory(inputDataProvider, new NullDeclarationReport(), + new NullVTPReport()); AssertHelper.Exception<VectoXMLException>( () => { var runs = dao.NextRun().ToArray(); @@ -179,7 +185,8 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = _runDataFactory.CreateDeclarationRunDataFactory(inputDataProvider, new NullDeclarationReport(), + new NullVTPReport()); AssertHelper.Exception<VectoXMLException>( () => { var runs = dao.NextRun().ToArray(); @@ -191,7 +198,8 @@ namespace TUGraz.VectoCore.Tests.Models { var reader = XmlReader.Create(DualFuelWHRVehicle); var inputDataProvider = xmlInputReader.Create(reader) as IDeclarationInputDataProvider; - var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = _runDataFactory.CreateDeclarationRunDataFactory(inputDataProvider, new NullDeclarationReport(), + new NullVTPReport()); var runs = dao.NextRun().ToArray(); Assert.AreEqual(10, runs.Length); @@ -214,7 +222,8 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = _runDataFactory.CreateDeclarationRunDataFactory(inputDataProvider, new NullDeclarationReport(), + new NullVTPReport()); var runs = dao.NextRun().ToArray(); Assert.IsTrue(runs.All(x => x.EngineData.ElectricalWHR?.WHRMap != null)); @@ -236,7 +245,8 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = _runDataFactory.CreateDeclarationRunDataFactory(inputDataProvider, new NullDeclarationReport(), + new NullVTPReport()); AssertHelper.Exception<VectoException>( () => { var runs = dao.NextRun().ToArray(); @@ -264,7 +274,8 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = _runDataFactory.CreateDeclarationRunDataFactory(inputDataProvider, new NullDeclarationReport(), + new NullVTPReport()); AssertHelper.Exception<VectoXMLException>( () => { var runs = dao.NextRun().ToArray(); @@ -289,7 +300,8 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = _runDataFactory.CreateDeclarationRunDataFactory(inputDataProvider, new NullDeclarationReport(), + new NullVTPReport()); AssertHelper.Exception<VectoXMLException>( () => { var runs = dao.NextRun().ToArray(); @@ -310,7 +322,8 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = _runDataFactory.CreateDeclarationRunDataFactory(inputDataProvider, new NullDeclarationReport(), + new NullVTPReport()); //var runs = dao.NextRun().ToArray(); AssertHelper.Exception<VectoXMLException>(() => { var tmp = dao.NextRun().ToArray(); }); @@ -333,7 +346,8 @@ namespace TUGraz.VectoCore.Tests.Models var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var inputDataProvider = xmlInputReader.CreateDeclaration(modified); - var dao = new DeclarationModeTruckVectoRunDataFactory(inputDataProvider, new NullDeclarationReport()); + var dao = _runDataFactory.CreateDeclarationRunDataFactory(inputDataProvider, new NullDeclarationReport(), + new NullVTPReport()); //var runs = dao.NextRun().ToArray(); //Assert.IsTrue(runs.All(x => x.EngineData.ElectricalWHR == null)); AssertHelper.Exception<VectoXMLException>(() => { var tmp = dao.NextRun().ToArray(); }); diff --git a/VectoCore/VectoCoreTest/Utils/MockSimulationDataFactory.cs b/VectoCore/VectoCoreTest/Utils/MockSimulationDataFactory.cs index 5f6bcc6e0e02168211e788667e3e97f68f2fe3cf..140c9e06bf06f2d69b6e83961974d02096bb7843 100644 --- a/VectoCore/VectoCoreTest/Utils/MockSimulationDataFactory.cs +++ b/VectoCore/VectoCoreTest/Utils/MockSimulationDataFactory.cs @@ -65,7 +65,7 @@ namespace TUGraz.VectoCore.Tests.Utils var gearboxInput = JSONInputDataFactory.ReadGearbox(gearBoxFile); var engineInput = JSONInputDataFactory.ReadEngine(engineFile); if (declarationMode) { - var dao = new DeclarationDataAdapterHeavyLorry(); + var dao = new DeclarationDataAdapterHeavyLorry.Conventional(); var vehicleInput = new MockDeclarationVehicleInputData() { EngineInputData = engineInput, GearboxInputData = gearboxInput @@ -127,7 +127,7 @@ namespace TUGraz.VectoCore.Tests.Utils public static AxleGearData CreateAxleGearDataFromFile(string axleGearFile, bool declarationMode = true) { if (declarationMode) { - var dao = new DeclarationDataAdapterHeavyLorry(); + var dao = new DeclarationDataAdapterHeavyLorry.Conventional(); var axleGearInput = JSONInputDataFactory.ReadGearbox(axleGearFile); return dao.CreateAxleGearData((IAxleGearInputData)axleGearInput); } else { diff --git a/VectoCore/VectoCoreTest/VectoCoreTest.csproj b/VectoCore/VectoCoreTest/VectoCoreTest.csproj index 4b051af090f9ff16f7df4194df5060386bc84ebc..758a88223c70de3bd24bd05984388370826598fe 100644 --- a/VectoCore/VectoCoreTest/VectoCoreTest.csproj +++ b/VectoCore/VectoCoreTest/VectoCoreTest.csproj @@ -36,6 +36,10 @@ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> </ItemGroup> + + <ItemGroup> + <Folder Include="InputData\DeclarationDataAdapterTest\" /> + </ItemGroup> <Choose> <When Condition="$([System.Text.RegularExpressions.Regex]::IsMatch(
 $(DefineConstants), '^(.*;)*MOCKUP(;.*)*$'))"> <ItemGroup> diff --git a/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs b/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs index f0f570272d36c43bc48dac2c3138d9b5dfe4d5a1..e04dbb82032111018539a3cd16ce12b72bd9c449 100644 --- a/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs +++ b/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs @@ -835,7 +835,7 @@ namespace TUGraz.VectoCore.Tests.XML var gbxType = inputDataProvider.JobInputData.Vehicle.Components.GearboxInputData.Type; Assert.AreEqual(gearboxType, gbxType.ToXMLFormat()); - Assert.IsTrue(DeclarationDataAdapterHeavyLorry.SupportedGearboxTypes.Contains(gbxType)); + Assert.IsTrue(DeclarationDataAdapterHeavyLorry.Conventional.SupportedGearboxTypes.Contains(gbxType)); } }