diff --git a/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs b/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs index 0af594c38a642e32f14a1957840e997b6b05732a..0cd09fa66105cd7e4137c8a95830cdae75ff8c1e 100644 --- a/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs +++ b/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs @@ -39,15 +39,42 @@ namespace TUGraz.VectoCore.Models.Simulation.DataBus /// <summary> /// Defines interfaces for all different cockpits to access shared data of the powertrain. /// </summary> - public interface IDataBus : IGearboxInfo, IAxlegearInfo, IEngineInfo, IVehicleInfo, IMileageCounter, IClutchInfo, - IBrakes, IWheelsInfo, IDriverInfo, IDrivingCycleInfo, IEngineControl, IGearboxControl + public interface IDataBus { ExecutionMode ExecutionMode { get; } Second AbsTime { get; set; } - IElectricMotorInfo ElectricMotor(PowertrainPosition pos); - ITorqueConverterControl TorqueConverter { get; } + IMileageCounter MileageCounter { get; } + + IGearboxInfo GearboxInfo { get; } + + IGearboxControl GearboxCtl { get; } + + IAxlegearInfo AxlegearInfo { get; } + + IEngineInfo EngineInfo { get; } + + IEngineControl EngineCtl { get; } + + IVehicleInfo VehicleInfo { get; } + + + IClutchInfo ClutchInfo { get; } + + IBrakes Brakes { get; } + + IWheelsInfo WheelsInfo { get; } + + IDriverInfo DriverInfo { get; } + + IDrivingCycleInfo DrivingCycleInfo { get; } + + + + IElectricMotorInfo ElectricMotorInfo(PowertrainPosition pos); + + ITorqueConverterControl TorqueConverterCtl { get; } } diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/DistanceRun.cs b/VectoCore/VectoCore/Models/Simulation/Impl/DistanceRun.cs index 0792d46c205e22e8e9b1cdfdb5609e046f847805..08523584bc4416cc1c00911ad98ea5df5cd5bcd7 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/DistanceRun.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/DistanceRun.cs @@ -47,9 +47,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl IterationStatistics.StartIteration(); // estimate distance to be traveled within the next TargetTimeInterval - var ds = Container.VehicleSpeed.IsEqual(0) + var ds = Container.VehicleInfo.VehicleSpeed.IsEqual(0) ? Constants.SimulationSettings.DriveOffDistance - : Constants.SimulationSettings.TargetTimeInterval * Container.VehicleSpeed; + : Constants.SimulationSettings.TargetTimeInterval * Container.VehicleInfo.VehicleSpeed; var loopCount = 0; IResponse response; @@ -57,7 +57,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl do { IterationStatistics.Increment(this, "Iterations"); - Container.BrakePower = 0.SI<Watt>(); + Container.Brakes.BrakePower = 0.SI<Watt>(); response = CyclePort.Request(AbsTime, ds); response.Switch(). Case<ResponseSuccess>(r => { dt = r.SimulationInterval; }). @@ -78,7 +78,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl debug.Add(new {Response = response}); } while (!(response is ResponseSuccess || response is ResponseCycleFinished)); - IterationStatistics.Increment(this, "Distance", Container.Distance.Value()); + IterationStatistics.Increment(this, "Distance", Container.MileageCounter.Distance.Value()); IterationStatistics.Increment(this, "Time", AbsTime.Value()); IterationStatistics.FinishIteration(AbsTime); response.AbsTime = AbsTime; diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PCCEcoRollEngineStopPreprocessor.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PCCEcoRollEngineStopPreprocessor.cs index 88c8e5a8b6b8af06fba0f925ce9f32f6f5d58964..b1ccbeccef04a0b99c7afc56c5c389591d94a363 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PCCEcoRollEngineStopPreprocessor.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PCCEcoRollEngineStopPreprocessor.cs @@ -33,18 +33,18 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public void RunPreprocessing() { - var vehicle = Container?.Vehicle as Vehicle; + var vehicle = Container?.VehicleInfo as Vehicle; if (vehicle == null) { throw new VectoException("no vehicle found..."); } - var gearbox = Container.Gearbox as Gearbox; + var gearbox = Container.GearboxInfo as Gearbox; if (gearbox != null) { RunPreprocessingAMTGearbox(gearbox, vehicle); return; } - var atGearbox = Container.Gearbox as ATGearbox; + var atGearbox = Container.GearboxInfo as ATGearbox; if (atGearbox != null) { RunPreprocessingATGearbox(atGearbox, vehicle); return; diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PCCSegmentPreprocessor.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PCCSegmentPreprocessor.cs index 5f548631e549b476b82da662fc04e07235639924..390dbb66e1d008c229a1b69bec5da3288bce75a4 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PCCSegmentPreprocessor.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PCCSegmentPreprocessor.cs @@ -31,7 +31,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl var slopes = new Dictionary<MeterPerSecond, Radian>(); new PCCEcoRollEngineStopPreprocessor( Container, slopes, PCCDriverData.MinSpeed, - VectoMath.Min(Container.MaxVehicleSpeed, Container.RunData.Cycle.Entries.Max(x => x.VehicleTargetSpeed))) + VectoMath.Min(Container.VehicleInfo.MaxVehicleSpeed, Container.RunData.Cycle.Entries.Max(x => x.VehicleTargetSpeed))) .RunPreprocessing(); var runData = Container.RunData; diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index 15df5e12f5f8532e5ea7fca32d5dda0e15f67f22..a759363b83c16d472ef524f1941d43d46c5426f3 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -533,7 +533,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl Constants.Auxiliaries.PowerPrefix + Constants.Auxiliaries.IDs.PTOTransmission); aux.Add(Constants.Auxiliaries.IDs.PTOConsumer, - n => container.PTOActive ? null : data.PTO.LossMap.GetTorqueLoss(n) * n); + n => container.DrivingCycleInfo.PTOActive ? null : data.PTO.LossMap.GetTorqueLoss(n) * n); container.ModalData?.AddAuxiliary(Constants.Auxiliaries.IDs.PTOConsumer, Constants.Auxiliaries.PowerPrefix + Constants.Auxiliaries.IDs.PTOConsumer); } diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/VectoRun.cs b/VectoCore/VectoCore/Models/Simulation/Impl/VectoRun.cs index fb60f506b3c50835a26230823d5deb74226b4a29..eec59a0ec317bc64aed52f9ec00ff41a59be6d02 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/VectoRun.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/VectoRun.cs @@ -152,7 +152,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl Log.Error(vse); Container.RunStatus = Status.Aborted; var ex = new VectoSimulationException("{6} ({7} {8}) - absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4} | {5}", - vse, AbsTime, Container.Distance, dt, Container.VehicleSpeed, TryCatch(() => Container.Gear), + vse, AbsTime, Container.MileageCounter.Distance, dt, Container.VehicleInfo.VehicleSpeed, TryCatch(() => Container.GearboxInfo.Gear), vse.Message, RunIdentifier, CycleName, RunSuffix); Container.FinishSimulationRun(ex); throw ex; @@ -162,7 +162,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl Container.RunStatus = Status.Aborted; var ex = new VectoSimulationException("{6} ({7} {8}) - absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4} | {5}", ve, - AbsTime, Container.Distance, dt, Container.VehicleSpeed, TryCatch(() => Container.Gear), ve.Message, + AbsTime, Container.MileageCounter.Distance, dt, Container.VehicleInfo.VehicleSpeed, TryCatch(() => Container.GearboxInfo.Gear), ve.Message, RunIdentifier, CycleName, RunSuffix); try { Container.FinishSimulationRun(ex); @@ -179,7 +179,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl var ex = new VectoSimulationException("{6} ({7} {8}) - absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4} | {5}", e, AbsTime, - Container.Distance, dt, Container.VehicleSpeed, TryCatch(() => Container.Gear), e.Message, + Container.MileageCounter.Distance, dt, Container.VehicleInfo.VehicleSpeed, TryCatch(() => Container.GearboxInfo.Gear), e.Message, RunIdentifier, CycleName, RunSuffix); Container.FinishSimulationRun(ex); throw ex; @@ -195,7 +195,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl if (Progress.IsSmaller(1, 1e-9)) { throw new VectoSimulationException( "{5} ({6} {7}) Progress: {8} - absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4}", - AbsTime, Container.Distance, dt, Container.VehicleSpeed, TryCatch(() => Container.Gear), RunIdentifier, CycleName, + AbsTime, Container.MileageCounter.Distance, dt, Container.VehicleInfo.VehicleSpeed, TryCatch(() => Container.GearboxInfo.Gear), RunIdentifier, CycleName, RunSuffix, Progress); } IterationStatistics.FinishSimulation(RunName + CycleName + RunSuffix + RunIdentifier); diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs index b93f94af8314a9faf98c8182db6a1b98d0cc8f14..8a90391b03a8339b15d9167c2e4003dbdca16ea0 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs @@ -55,22 +55,22 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl private List<Tuple<int, VectoSimulationComponent>> _components = new List<Tuple<int, VectoSimulationComponent>>(); - internal IEngineInfo Engine; - internal IEngineControl EngineCtl; - internal IGearboxInfo Gearbox; - internal IGearboxControl GearboxCtl; - internal IAxlegearInfo Axlegear; - internal IVehicleInfo Vehicle; - internal IBrakes Brakes; - internal IWheelsInfo Wheels; - internal IDriverInfo Driver; - internal IHybridController HybridController; + public IEngineInfo EngineInfo { get; protected internal set; } + public IEngineControl EngineCtl { get; protected set; } + public IGearboxInfo GearboxInfo { get; protected set; } + public IGearboxControl GearboxCtl { get; protected set; } + public IAxlegearInfo AxlegearInfo { get; protected set; } + public IVehicleInfo VehicleInfo { get; protected set; } + public IBrakes Brakes { get; protected set; } + public IWheelsInfo WheelsInfo { get; protected set; } + public IDriverInfo DriverInfo { get; protected set; } + public IHybridController HybridController { get; protected set; } - internal IMileageCounter MilageCounter; + public IMileageCounter MileageCounter { get; protected set; } - internal IClutchInfo Clutch; + public IClutchInfo ClutchInfo { get; protected set; } - internal IDrivingCycleInfo DrivingCycle; + public IDrivingCycleInfo DrivingCycleInfo { get; protected set; } internal ISimulationOutPort Cycle; @@ -83,211 +83,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl internal readonly Dictionary<PowertrainPosition, IElectricMotorInfo> ElectricMotors = new Dictionary<PowertrainPosition, IElectricMotorInfo>(); - #region IGearCockpit - - public GearboxType GearboxType - { - get { return Gearbox == null ? GearboxType.MT : Gearbox.GearboxType; } - } - - public uint Gear - { - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", - "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] - get - { - if (Gearbox == null) { - return 0; // throw new VectoException("no gearbox available!"); - } - - return Gearbox.Gear; - } - } - - public bool TCLocked - { - get - { - if (Gearbox == null) { - return true; - } - - return Gearbox.TCLocked; - } - } - - public MeterPerSecond StartSpeed - { - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", - "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] - get - { - if (Gearbox == null) { - throw new VectoException("No Gearbox available. StartSpeed unkown"); - } - - return Gearbox.StartSpeed; - } - } - - public MeterPerSquareSecond StartAcceleration - { - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", - "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] - get - { - if (Gearbox == null) { - throw new VectoException("No Gearbox available. StartAcceleration unknown."); - } - - return Gearbox.StartAcceleration; - } - } - - public Watt GearboxLoss() - { - return Gearbox.GearboxLoss(); - } - - public Second LastShift - { - get { return Gearbox.LastShift; } - } - - public GearData GetGearData(uint gear) - { - return Gearbox.GetGearData(gear); - } - - public GearInfo NextGear - { - get { return Gearbox.NextGear; } - } - - public Second TractionInterruption - { - get { return Gearbox.TractionInterruption; } - } - - public uint NumGears - { - get { return Gearbox.NumGears; } - } - - #endregion - - #region IEngineCockpit - - public PerSecond EngineSpeed - { - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", - "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] - get - { - if (Engine == null) { - throw new VectoException("no engine available!"); - } - - return Engine.EngineSpeed; - } - } - - public NewtonMeter EngineTorque - { - get { return Engine.EngineTorque; } - } - - public Watt EngineStationaryFullPower(PerSecond angularSpeed) - { - return Engine.EngineStationaryFullPower(angularSpeed); - } - - public Watt EngineDynamicFullLoadPower(PerSecond avgEngineSpeed, Second dt) - { - return Engine.EngineDynamicFullLoadPower(avgEngineSpeed, dt); - } - - public Watt EngineDragPower(PerSecond angularSpeed) - { - return Engine.EngineDragPower(angularSpeed); - } - - public Watt EngineAuxDemand(PerSecond avgEngineSpeed, Second dt) - { - return Engine.EngineAuxDemand(avgEngineSpeed, dt); - } - - public PerSecond EngineIdleSpeed - { - get { return Engine.EngineIdleSpeed; } - } - - public PerSecond EngineRatedSpeed - { - get { return Engine.EngineRatedSpeed; } - } - - public PerSecond EngineN95hSpeed - { - get { return Engine.EngineN95hSpeed; } - } - - public PerSecond EngineN80hSpeed - { - get { return Engine.EngineN80hSpeed; } - } - - #endregion - - #region IVehicleCockpit - - public MeterPerSecond VehicleSpeed - { - get { return Vehicle != null ? Vehicle.VehicleSpeed : 0.SI<MeterPerSecond>(); } - } - - public Kilogram VehicleMass - { - get { return Vehicle != null ? Vehicle.VehicleMass : 0.SI<Kilogram>(); } - } - - public Kilogram VehicleLoading - { - get { return Vehicle != null ? Vehicle.VehicleLoading : 0.SI<Kilogram>(); } - } - - public Kilogram TotalMass - { - get { return Vehicle != null ? Vehicle.TotalMass : 0.SI<Kilogram>(); } - } - - public CubicMeter CargoVolume - { - get { return Vehicle != null ? Vehicle.CargoVolume : 0.SI<CubicMeter>(); } - } - - public Newton AirDragResistance(MeterPerSecond previousVelocity, MeterPerSecond nextVelocity) - { - return Vehicle.AirDragResistance(previousVelocity, nextVelocity); - } - - public Newton RollingResistance(Radian gradient) - { - return Vehicle.RollingResistance(gradient); - } - - public Newton SlopeResistance(Radian gradient) - { - return Vehicle.SlopeResistance(gradient); - } - - public MeterPerSecond MaxVehicleSpeed - { - get { return Vehicle.MaxVehicleSpeed; } - } - - #endregion - + public VehicleContainer(ExecutionMode executionMode, IModalDataContainer modData = null, WriteSumData writeSumData = null) { @@ -310,12 +106,12 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public virtual Second AbsTime { get; set; } - public IElectricMotorInfo ElectricMotor(PowertrainPosition pos) + public IElectricMotorInfo ElectricMotorInfo(PowertrainPosition pos) { return ElectricMotors[pos]; } - public ITorqueConverterControl TorqueConverter { get; private set; } + public ITorqueConverterControl TorqueConverterCtl { get; private set; } public void AddComponent(VectoSimulationComponent component) { @@ -323,31 +119,31 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl component.Switch() .If<IEngineInfo>(c => { - Engine = c; + EngineInfo = c; commitPriority = 2; HasCombustionEngine = true; }) .If<IEngineControl>(c => { EngineCtl = c; }) - .If<IDriverInfo>(c => Driver = c) + .If<IDriverInfo>(c => DriverInfo = c) .If<IGearboxInfo>(c => { - Gearbox = c; + GearboxInfo = c; commitPriority = 4; HasGearbox = true; }) .If<IGearboxControl>(c => GearboxCtl = c) - .If<ITorqueConverterControl>(c => TorqueConverter = c) - .If<IAxlegearInfo>(c => Axlegear = c) - .If<IWheelsInfo>(c => Wheels = c) + .If<ITorqueConverterControl>(c => TorqueConverterCtl = c) + .If<IAxlegearInfo>(c => AxlegearInfo = c) + .If<IWheelsInfo>(c => WheelsInfo = c) .If<IVehicleInfo>(c => { - Vehicle = c; + VehicleInfo = c; commitPriority = 5; }) .If<ISimulationOutPort>(c => Cycle = c) - .If<IMileageCounter>(c => MilageCounter = c) + .If<IMileageCounter>(c => MileageCounter = c) .If<IBrakes>(c => Brakes = c) - .If<IClutchInfo>(c => Clutch = c) + .If<IClutchInfo>(c => ClutchInfo = c) .If<IDrivingCycleInfo>(c => { - DrivingCycle = c; + DrivingCycleInfo = c; commitPriority = 6; }) .If<PTOCycleController>(c => { commitPriority = 99; }) @@ -375,7 +171,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public void CommitSimulationStep(Second time, Second simulationInterval) { Log.Info("VehicleContainer committing simulation. time: {0}, dist: {1}, speed: {2}", time, - Distance, VehicleSpeed); + MileageCounter.Distance, VehicleInfo?.VehicleSpeed ?? 0.KMPHtoMeterPerSecond()); foreach (var component in _components) { @@ -383,7 +179,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl } if (ModData != null) { - ModData[ModalResultField.drivingBehavior] = DriverBehavior; + ModData[ModalResultField.drivingBehavior] = DriverInfo.DriverBehavior; ModData[ModalResultField.time] = time + simulationInterval / 2; ModData[ModalResultField.simulationInterval] = simulationInterval; ModData.CommitSimulationStep(); @@ -398,13 +194,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl WriteSumData(ModData); ModData?.FinishSimulation(); - DrivingCycle?.FinishSimulation(); - } - - - public void FinishSimulation() - { - throw new NotImplementedException(); + DrivingCycleInfo?.FinishSimulation(); } public IEnumerable<ISimulationPreprocessor> GetPreprocessingRuns @@ -431,163 +221,17 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl return new ReadOnlyCollection<VectoSimulationComponent>(_components.Select(x => x.Item2).ToList()); } - public Meter Distance - { - get - { - if (RunData == null || (RunData.SimulationType & SimulationType.DistanceCycle) == 0) { - return 0.SI<Meter>(); - } - - if (MilageCounter != null) { - return MilageCounter.Distance; - } - - Log.Warn("No MileageCounter in VehicleContainer. Distance cannot be measured."); - return 0.SI<Meter>(); - } - } - public bool HasElectricMotor { get; private set; } public bool HasCombustionEngine { get; private set; } public bool HasGearbox { get; private set; } - public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Meter lookaheadDistance) - { - return DrivingCycle.LookAhead(lookaheadDistance); - } - - public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Second time) - { - return DrivingCycle.LookAhead(time); - } - - - public Watt BrakePower - { - get { return Brakes.BrakePower; } - set { Brakes.BrakePower = value; } - } - - public bool ClutchClosed(Second absTime) - { - if (Clutch == null) { - Log.Warn("No Clutch in VehicleContainer. ClutchClosed set to constant true!"); - return true; - } - - return Clutch.ClutchClosed(absTime); - } - - public bool VehicleStopped - { - get { return Vehicle.VehicleStopped; } - } - - public DrivingBehavior DriverBehavior - { - get { return Driver?.DriverBehavior ?? DrivingBehavior.Driving; } - } - - public DrivingAction DrivingAction - { - get { return Driver?.DrivingAction ?? DrivingAction.Accelerate; } - } - - public MeterPerSquareSecond DriverAcceleration - { - get { return Driver != null ? Driver.DriverAcceleration : 0.SI<MeterPerSquareSecond>(); } - } - - public Radian RoadGradient - { - get { return DrivingCycle.RoadGradient; } - } - - public MeterPerSecond TargetSpeed - { - get { return DrivingCycle.TargetSpeed; } - } - - public Second StopTime - { - get { return DrivingCycle.StopTime; } - } - - public SpeedChangeEntry LastTargetspeedChange - { - get { return DrivingCycle.LastTargetspeedChange; } - } - - public Meter CycleStartDistance - { - get { return DrivingCycle == null ? 0.SI<Meter>() : DrivingCycle.CycleStartDistance; } - } - + public VectoRunData RunData { get; set; } public ExecutionMode ExecutionMode { get; } - public CycleData CycleData - { - get { return DrivingCycle.CycleData; } - } - - public bool PTOActive - { - get { return DrivingCycle?.PTOActive ?? false; } - } - - public DrivingCycleData.DrivingCycleEntry CycleLookAhead(Meter distance) - { - return DrivingCycle.CycleLookAhead(distance); - } - - public Meter Altitude - { - get { return DrivingCycle.Altitude; } - } - - public Watt AxlegearLoss() - { - return Axlegear.AxlegearLoss(); - } - - public Tuple<PerSecond, NewtonMeter> CurrentAxleDemand - { - get { return Axlegear.CurrentAxleDemand; } - } - - public Kilogram ReducedMassWheels - { - get { return Wheels.ReducedMassWheels; } - } - - #region Implementation of IEngineControl - - public bool CombustionEngineOn - { - get { return EngineCtl.CombustionEngineOn; } - set { EngineCtl.CombustionEngineOn = value; } - } - - #endregion - - #region Implementation of IGearboxControl - - public bool DisengageGearbox - { - get { return Gearbox.DisengageGearbox; } - set { GearboxCtl.DisengageGearbox = value; } - } - - public bool GearEngaged(Second absTime) - { - return Gearbox.GearEngaged(absTime); - } - - #endregion + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs index acfaed14293378cf6e6f28ce1003fa36619f50e0..6d5983615d94447127e863e78c55d0406d234d34 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs @@ -70,8 +70,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data if (DataBus == null) { throw new VectoException("Databus is not set - can't access vAir, beta!"); } - var vAir = DataBus.CycleData.LeftSample.AirSpeedRelativeToVehicle; - var beta = DataBus.CycleData.LeftSample.WindYawAngle; + var vAir = DataBus.DrivingCycleInfo.CycleData.LeftSample.AirSpeedRelativeToVehicle; + var beta = DataBus.DrivingCycleInfo.CycleData.LeftSample.WindYawAngle; // F_air(t) = k * CdA_korr * v_air^2 // assumption: v_air = const for the current interval // P(t) = F_air(t) * v(t) , v(t) = v1 + a * t diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs index bbcb6157d1186e9b7514fe96048709be35655ac8..515ab13e536e2678be4b5906fcbb58d38caa6c15 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs @@ -75,14 +75,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private bool SpeedTooLowForEngine(uint gear, PerSecond outAngularSpeed) { - return (outAngularSpeed * ModelData.Gears[gear].Ratio).IsSmaller(DataBus.EngineIdleSpeed); + return (outAngularSpeed * ModelData.Gears[gear].Ratio).IsSmaller(DataBus.EngineInfo.EngineIdleSpeed); } private bool SpeedTooHighForEngine(uint gear, PerSecond outAngularSpeed) { return (outAngularSpeed * ModelData.Gears[gear].Ratio).IsGreaterOrEqual(VectoMath.Min(ModelData.Gears[gear].MaxSpeed, - DataBus.EngineN95hSpeed)); + DataBus.EngineInfo.EngineN95hSpeed)); } public override GearInfo NextGear @@ -116,7 +116,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override uint InitGear(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) { - if (DataBus.VehicleSpeed.IsEqual(0)) { + if (DataBus.VehicleInfo.VehicleSpeed.IsEqual(0)) { return InitStartGear(outTorque, outAngularVelocity); } for (var gear = (uint)ModelData.Gears.Count; gear > 1; gear--) { @@ -130,7 +130,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // if in shift curve and torque reserve is provided: return the current gear if (!IsBelowDownShiftCurve(gear, inTorque, inAngularSpeed) && !IsAboveUpShiftCurve(gear, inTorque, inAngularSpeed) && reserve >= ModelData.StartTorqueReserve) { - if ((inAngularSpeed - DataBus.EngineIdleSpeed) / (DataBus.EngineRatedSpeed - DataBus.EngineIdleSpeed) < + if ((inAngularSpeed - DataBus.EngineInfo.EngineIdleSpeed) / (DataBus.EngineInfo.EngineRatedSpeed - DataBus.EngineInfo.EngineIdleSpeed) < Constants.SimulationSettings.ClutchClosingSpeedNorm && gear > 1) { gear--; } @@ -155,7 +155,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl for (var gear = MaxStartGear; gear > 1; gear--) { var inAngularSpeed = outAngularVelocity * ModelData.Gears[gear].Ratio; - var ratedSpeed = DataBus.EngineRatedSpeed; + var ratedSpeed = DataBus.EngineInfo.EngineRatedSpeed; if (inAngularSpeed > ratedSpeed || inAngularSpeed.IsEqual(0)) { continue; } @@ -165,7 +165,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var fullLoadPower = response.Engine.DynamicFullLoadPower; //EnginePowerRequest - response.DeltaFullLoad; var reserve = 1 - response.Engine.PowerRequest / fullLoadPower; - if (response.Engine.EngineSpeed > DataBus.EngineIdleSpeed && reserve >= ModelData.StartTorqueReserve) { + if (response.Engine.EngineSpeed > DataBus.EngineInfo.EngineIdleSpeed && reserve >= ModelData.StartTorqueReserve) { _nextGear = gear; return gear; } @@ -177,7 +177,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected override bool DoCheckShiftRequired(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, NewtonMeter inTorque, PerSecond inAngularVelocity, uint gear, Second lastShiftTime, IResponse response) { // no shift when vehicle stands - if (DataBus.VehicleStopped) { + if (DataBus.VehicleInfo.VehicleStopped) { return false; } @@ -222,7 +222,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected virtual uint CheckUpshift(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, NewtonMeter inTorque, PerSecond inAngularVelocity, uint currentGear, IResponse response) { // if the driver's intention is _not_ to accelerate or drive along then don't upshift - if (DataBus.DriverBehavior != DrivingBehavior.Accelerating && DataBus.DriverBehavior != DrivingBehavior.Driving) { + if (DataBus.DriverInfo.DriverBehavior != DrivingBehavior.Accelerating && DataBus.DriverInfo.DriverBehavior != DrivingBehavior.Driving) { return currentGear; } if ((absTime - _gearbox.LastDownshift).IsSmaller(_gearbox.ModelData.UpshiftAfterDownshiftDelay)) { @@ -272,7 +272,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl inAngularVelocity = response.Engine.EngineSpeed; //ModelData.Gears[currentGear].Ratio * outAngularVelocity; inTorque = response.Clutch.PowerRequest / inAngularVelocity; - var maxTorque = VectoMath.Min(response.Engine.DynamicFullLoadPower / ((DataBus.EngineSpeed + response.Engine.EngineSpeed) / 2), + var maxTorque = VectoMath.Min(response.Engine.DynamicFullLoadPower / ((DataBus.EngineInfo.EngineSpeed + response.Engine.EngineSpeed) / 2), currentGear > 1 ? ModelData.Gears[currentGear].ShiftPolygon.InterpolateDownshift(response.Engine.EngineSpeed) : double.MaxValue.SI<NewtonMeter>()); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyACEA.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyACEA.cs index 734e12cdace8aafd22b914f9c22325c49e1947f4..ff7c068bf8b35459240dbd0f7b4cf18d39ccae5b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyACEA.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyACEA.cs @@ -112,7 +112,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private bool SpeedTooLowForEngine(uint gear, PerSecond outAngularSpeed) { - return (outAngularSpeed * ModelData.Gears[gear].Ratio).IsSmaller(DataBus.EngineIdleSpeed); + return (outAngularSpeed * ModelData.Gears[gear].Ratio).IsSmaller(DataBus.EngineInfo.EngineIdleSpeed); } private bool SpeedTooHighForEngine(uint gear, PerSecond outAngularSpeed) @@ -121,7 +121,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl (outAngularSpeed * ModelData.Gears[gear].Ratio).IsGreaterOrEqual( VectoMath.Min( ModelData.Gears[gear].MaxSpeed, - DataBus.EngineN95hSpeed)); + DataBus.EngineInfo.EngineN95hSpeed)); } #region Overrides of BaseShiftStrategy @@ -129,13 +129,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override void Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) { // update own history - var velocity = DataBus.VehicleSpeed + DataBus.DriverAcceleration * dt / 2.0; - var cardanDemand = DataBus.CurrentAxleDemand; + var velocity = DataBus.VehicleInfo.VehicleSpeed + DataBus.DriverInfo.DriverAcceleration * dt / 2.0; + var cardanDemand = DataBus.AxlegearInfo.CurrentAxleDemand; var currentCardanPower = cardanDemand.Item1 * cardanDemand.Item2; UpdateHistoryBuffer(absTime, dt, currentCardanPower, velocity); - var currentVelocity = DataBus.VehicleSpeed; + var currentVelocity = DataBus.VehicleInfo.VehicleSpeed; accRsv = CalcAccelerationReserve(currentVelocity, absTime + dt); driverAccelerationAvg = GetAverageAcceleration(absTime + dt); @@ -147,11 +147,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected override bool DoCheckShiftRequired(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, NewtonMeter inTorque, PerSecond inAngularVelocity, uint gear, Second lastShiftTime, IResponse response) { - var cardanDemand = DataBus.CurrentAxleDemand; + var cardanDemand = DataBus.AxlegearInfo.CurrentAxleDemand; var currentCardanPower = cardanDemand.Item1 * cardanDemand.Item2; // no shift when vehicle stands - if (DataBus.VehicleStopped) { + if (DataBus.VehicleInfo.VehicleStopped) { return false; } @@ -174,7 +174,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } // TEST - var currentVelocity = DataBus.VehicleSpeed; + var currentVelocity = DataBus.VehicleInfo.VehicleSpeed; accRsv = CalcAccelerationReserve(currentVelocity, absTime + dt); var minimumShiftTimePassed = (lastShiftTime + ModelData.ShiftTime).IsSmallerOrEqual(absTime); @@ -212,10 +212,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl PerSecond inAngularVelocity, uint gear, Second lastShiftTime) { var lookAheadDistance = - DataBus.VehicleSpeed * ModelData.TractionInterruption; //ShiftStrategyParameters.GearResidenceTime; - var roadGradient = DataBus.CycleLookAhead(lookAheadDistance).RoadGradient; + DataBus.VehicleInfo.VehicleSpeed * ModelData.TractionInterruption; //ShiftStrategyParameters.GearResidenceTime; + var roadGradient = DataBus.DrivingCycleInfo.CycleLookAhead(lookAheadDistance).RoadGradient; - var currentVelocity = DataBus.VehicleSpeed; + var currentVelocity = DataBus.VehicleInfo.VehicleSpeed; gradient = CalcGradientDuringGearshift(false, dt, currentVelocity); var estimatedVelocityPostShift = VelocityDropData.Interpolate(currentVelocity, gradient); var predictionVelocity = CalcPredictionVelocity(currentVelocity, estimatedVelocityPostShift); @@ -435,17 +435,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ShiftStrategyParameters.StartAcceleration / 2.0 * ShiftStrategyParameters.StartVelocity : currentVelocity * dt / 2.0; if (lookaheadMidShift.IsEqual(0)) { - return DataBus.RoadGradient; + return DataBus.DrivingCycleInfo.RoadGradient; } - var currentAltitude = DataBus.Altitude; - var lookAheadPos = DataBus.CycleLookAhead(lookaheadMidShift); + var currentAltitude = DataBus.DrivingCycleInfo.Altitude; + var lookAheadPos = DataBus.DrivingCycleInfo.CycleLookAhead(lookaheadMidShift); var gradient = VectoMath.InclinationToAngle((lookAheadPos.Altitude - currentAltitude) / lookaheadMidShift); return lookAheadPos.RoadGradient; } private MeterPerSquareSecond CalcAccelerationReserve(MeterPerSecond currentVelocity, Second absTime) { - var lastTargetspeedChange = DataBus.LastTargetspeedChange; + var lastTargetspeedChange = DataBus.DrivingCycleInfo.LastTargetspeedChange; demandedSpeed = ComputeDemandedSpeed(lastTargetspeedChange, absTime); var accRsvLow = ShiftStrategyParameters.AccelerationReserveLookup.LookupLow(currentVelocity); var accRsvHigh = ShiftStrategyParameters.AccelerationReserveLookup.LookupHigh(currentVelocity); @@ -465,7 +465,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return VectoMath.Min( PowertrainConfig.DriverData.AccelerationCurve.ComputeEndVelocityAccelerate( lastTargetspeedChange.PreviousTargetSpeed, accelerationTime), - DataBus.CycleData.LeftSample.VehicleTargetSpeed); + DataBus.DrivingCycleInfo.CycleData.LeftSample.VehicleTargetSpeed); } private MeterPerSecond CalcPredictionVelocity( @@ -499,10 +499,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var upperEngineSpeedLimit = (PowertrainConfig.EngineData.FullLoadCurves[0].NTq99lSpeed + PowertrainConfig.EngineData.FullLoadCurves[0].NTq99hSpeed) / 2.0; - var currentVelocity = DataBus.VehicleSpeed; + var currentVelocity = DataBus.VehicleInfo.VehicleSpeed; var gradient = CalcGradientDuringGearshift(false, dt, currentVelocity); var estimatedVelocityPostShift = VelocityDropData.Interpolate(currentVelocity, gradient); - var predictedVelocity = DataBus.DriverBehavior == DrivingBehavior.Braking + var predictedVelocity = DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Braking ? currentVelocity + PowertrainConfig.DriverData.AccelerationCurve.Lookup(currentVelocity).Deceleration * ModelData.TractionInterruption : CalcPredictionVelocity(currentVelocity, estimatedVelocityPostShift); @@ -568,7 +568,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl AccelerationBuffer[absTime] = new AccelerationEntry() { dt = dt, //Acceleration = VectoMath.Max(aDemanded, 0.SI<MeterPerSquareSecond>()) - Acceleration = DataBus.DriverAcceleration + Acceleration = DataBus.DriverInfo.DriverAcceleration }; var outdated = AccelerationBuffer @@ -582,13 +582,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override uint InitGear(Second absTime, Second dt, NewtonMeter torque, PerSecond outAngularVelocity) { - if (DataBus.VehicleSpeed.IsEqual(0)) { + if (DataBus.VehicleInfo.VehicleSpeed.IsEqual(0)) { return InitStartGear(torque, outAngularVelocity); } for (var gear = (uint)ModelData.Gears.Count; gear > 1; gear--) { var inAngularVelocity = outAngularVelocity * ModelData.Gears[gear].Ratio; - if (DataBus.EngineSpeed < inAngularVelocity && inAngularVelocity < DataBus.EngineRatedSpeed) { + if (DataBus.EngineInfo.EngineSpeed < inAngularVelocity && inAngularVelocity < DataBus.EngineInfo.EngineRatedSpeed) { _nextGear = gear; return gear; } @@ -601,7 +601,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { var maxStartGear = (int)Math.Round(ModelData.Gears.Count / 2.0, MidpointRounding.AwayFromZero); - var currentVelocity = DataBus.VehicleSpeed; + var currentVelocity = DataBus.VehicleInfo.VehicleSpeed; var gradient = CalcGradientDuringGearshift(true, null, null); var estimatedVelocityPostShift = VelocityDropData.Interpolate(currentVelocity, gradient); var predictionVelocity = ShiftStrategyParameters.StartVelocity; @@ -609,7 +609,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var startGear = 1u; var minRating = new GearRating(GearRatingCase.E, double.MaxValue, 0.RPMtoRad()); - var roadGradient = DataBus.CycleData.LeftSample.RoadGradient; //CycleLookAhead(0.SI<Meter>()).RoadGradient; + var roadGradient = DataBus.DrivingCycleInfo.CycleData.LeftSample.RoadGradient; //CycleLookAhead(0.SI<Meter>()).RoadGradient; GearRatings.Clear(); for (uint i = (uint)maxStartGear; i > 0; i--) { var gradientBelowMaxGrad = roadGradient < MaxGradability.GradabilityLimitedTorque(i); @@ -640,7 +640,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { var shareIdleLowMax = driveOff ? ShiftStrategyParameters.ShareIdleLow.MaxValue - : ShiftStrategyParameters.ShareIdleLow.Lookup(DataBus.VehicleSpeed); + : ShiftStrategyParameters.ShareIdleLow.Lookup(DataBus.VehicleInfo.VehicleSpeed); return PowertrainConfig.EngineData.IdleSpeed + shareIdleLowMax * (PowertrainConfig.EngineData.FullLoadCurves[0].NP99hSpeed - PowertrainConfig.EngineData.IdleSpeed); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyOptimized.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyOptimized.cs index aa00c5134a68b90546384dc75e41ca3b575e160c..6bc1808f1c0da1033e880a934a39264447082aae 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyOptimized.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyOptimized.cs @@ -90,15 +90,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return currentGear; } - var estimatedVelocityPostShift = VelocityDropData.Interpolate(DataBus.VehicleSpeed, DataBus.RoadGradient ?? 0.SI<Radian>()); + var estimatedVelocityPostShift = VelocityDropData.Interpolate(DataBus.VehicleInfo.VehicleSpeed, DataBus.DrivingCycleInfo.RoadGradient ?? 0.SI<Radian>()); if (!estimatedVelocityPostShift.IsGreater(MIN_SPEED_AFTER_TRACTION_INTERRUPTION)) { return currentGear; } - var vDrop = DataBus.VehicleSpeed - estimatedVelocityPostShift; - var vehicleSpeedPostShift = DataBus.VehicleSpeed - vDrop * shiftStrategyParameters.VelocityDropFactor; + var vDrop = DataBus.VehicleInfo.VehicleSpeed - estimatedVelocityPostShift; + var vehicleSpeedPostShift = DataBus.VehicleInfo.VehicleSpeed - vDrop * shiftStrategyParameters.VelocityDropFactor; - var totalTransmissionRatio = DataBus.EngineSpeed / DataBus.VehicleSpeed; + var totalTransmissionRatio = DataBus.EngineInfo.EngineSpeed / DataBus.VehicleInfo.VehicleSpeed; //var totalTransmissionRatio = outAngularVelocity / DataBus.VehicleSpeed; for (var i = 1; i <= shiftStrategyParameters.AllowedGearRangeFC; i++) { @@ -128,7 +128,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl continue; } - var pNextGearMax = DataBus.EngineStationaryFullPower(estimatedEngineSpeed); + var pNextGearMax = DataBus.EngineInfo.EngineStationaryFullPower(estimatedEngineSpeed); if (!response.Engine.PowerRequest.IsSmaller(pNextGearMax)) { continue; @@ -153,7 +153,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl //var minAcc = VectoMath.Min(DataBus.DriverAcceleration, accCurve.Lookup(DataBus.VehicleSpeed).Acceleration * accelerationFactor); //var minAcc = DataBus.DriverAcceleration * accelerationFactor; //response = RequestDryRunWithGear(absTime, dt, vehicleSpeedPostShift, minAcc, tryNextGear); - var accelerationTorque = vehicleMass * DataBus.DriverAcceleration * DataBus.VehicleSpeed / outAngularVelocity; + var accelerationTorque = vehicleMass * DataBus.DriverInfo.DriverAcceleration * DataBus.VehicleInfo.VehicleSpeed / outAngularVelocity; var reducedTorque = outTorque - accelerationTorque * (1 - accelerationFactor); response = RequestDryRunWithGear(absTime, dt, reducedTorque, outAngularVelocity, tryNextGear); @@ -233,7 +233,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var minFc = double.MaxValue; var fcCurrent = double.NaN; - var estimatedVelocityPostShift = VelocityDropData.Interpolate(DataBus.VehicleSpeed, DataBus.RoadGradient ?? 0.SI<Radian>()); + var estimatedVelocityPostShift = VelocityDropData.Interpolate(DataBus.VehicleInfo.VehicleSpeed, DataBus.DrivingCycleInfo.RoadGradient ?? 0.SI<Radian>()); if (!estimatedVelocityPostShift.IsGreater(MIN_SPEED_AFTER_TRACTION_INTERRUPTION)) { return currentGear; } @@ -294,9 +294,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl TestContainerGbx.Gear = tryNextGear; //TestContainer.GearboxOutPort.Initialize(outTorque, outAngularVelocity); - TestContainer.VehiclePort.Initialize(vehicleSpeed, DataBus.RoadGradient); + TestContainer.VehiclePort.Initialize(vehicleSpeed, DataBus.DrivingCycleInfo.RoadGradient); var response = (ResponseDryRun)TestContainer.VehiclePort.Request( - 0.SI<Second>(), dt, acceleration, DataBus.RoadGradient, true); + 0.SI<Second>(), dt, acceleration, DataBus.DrivingCycleInfo.RoadGradient, true); //var response = (ResponseDryRun)TestContainer.GearboxOutPort.Request( // 0.SI<Second>(), dt, outTorque, outAngularVelocity, true); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs index a57d9372f74e43cd2a3296d0b6e36d760f0cb418..6d288959d743d0ed86e522834f3c7d7a2bb37e7e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs @@ -121,7 +121,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override bool GearEngaged(Second absTime) { return absTime.IsGreater(DataBus.AbsTime) || - !(CurrentState.Disengaged || (DataBus.DriverBehavior == DrivingBehavior.Halted || (DisengageGearbox && !ModelData.ATEcoRollReleaseLockupClutch))); + !(CurrentState.Disengaged || (DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Halted || (DisengageGearbox && !ModelData.ATEcoRollReleaseLockupClutch))); } public override bool DisengageGearbox { get; set; } @@ -140,7 +140,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl effectiveRatio = ModelData.Gears[Gear].TorqueConverterRatio; effectiveLossMap = ModelData.Gears[Gear].TorqueConverterGearLossMap; } - if (!DataBus.VehicleStopped) { + if (!DataBus.VehicleInfo.VehicleStopped) { inAngularVelocity = outAngularVelocity * effectiveRatio; var torqueLossResult = effectiveLossMap.GetTorqueLoss(outAngularVelocity, outTorque); CurrentState.TorqueLossResult = torqueLossResult; @@ -225,7 +225,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl _strategy?.Request(absTime, dt, outTorque, outAngularVelocity); - var driveOffSpeed = DataBus.VehicleStopped && outAngularVelocity > 0; + var driveOffSpeed = DataBus.VehicleInfo.VehicleStopped && outAngularVelocity > 0; var driveOffTorque = CurrentState.Disengaged && outTorque.IsGreater(0, 1e-1); if (!dryRun && (driveOffSpeed || driveOffTorque)) { Gear = 1; @@ -239,7 +239,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var loop = false; SetPowershiftLossEnergy(absTime, dt, outTorque, outAngularVelocity); do { - if (CurrentState.Disengaged || (DataBus.DriverBehavior == DrivingBehavior.Halted) || (DisengageGearbox && !ModelData.ATEcoRollReleaseLockupClutch)) { + if (CurrentState.Disengaged || (DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Halted) || (DisengageGearbox && !ModelData.ATEcoRollReleaseLockupClutch)) { // only when vehicle is halted or close before halting or during eco-roll events retVal = RequestDisengaged(absTime, dt, outTorque, outAngularVelocity, dryRun); } else { @@ -318,7 +318,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var remainingShiftLossLime = ModelData.PowershiftShiftTime - (absTime - LastShift); if (remainingShiftLossLime.IsGreater(0)) { aliquotEnergyLoss = _powershiftLossEnergy * VectoMath.Min(1.0, VectoMath.Min(dt, remainingShiftLossLime) / ModelData.PowershiftShiftTime); - var avgEngineSpeed = (DataBus.EngineSpeed + outAngularVelocity * effectiveRatio) / 2; + var avgEngineSpeed = (DataBus.EngineInfo.EngineSpeed + outAngularVelocity * effectiveRatio) / 2; powershiftLoss = aliquotEnergyLoss / dt / avgEngineSpeed; inTorque += powershiftLoss; @@ -413,7 +413,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Extrapolated = false, Value = 0.SI<NewtonMeter>() }; - TorqueConverter.Locked(DataBus.VehicleStopped ? 0.SI<NewtonMeter>() : CurrentState.InTorque, retval.Engine.EngineSpeed, + TorqueConverter.Locked(DataBus.VehicleInfo.VehicleStopped ? 0.SI<NewtonMeter>() : CurrentState.InTorque, retval.Engine.EngineSpeed, CurrentState.InTorque, outAngularVelocity * effectiveRatio); @@ -426,7 +426,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var avgInAngularSpeed = (PreviousState.InAngularVelocity + CurrentState.InAngularVelocity) / 2.0; var avgOutAngularSpeed = (PreviousState.OutAngularVelocity + CurrentState.OutAngularVelocity) / 2.0; - container[ModalResultField.Gear] = CurrentState.Disengaged || DataBus.VehicleStopped || + container[ModalResultField.Gear] = CurrentState.Disengaged || DataBus.VehicleInfo.VehicleStopped || (DisengageGearbox && !ModelData.ATEcoRollReleaseLockupClutch) ? 0 : Gear; @@ -459,7 +459,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } RequestAfterGearshift = false; - if (DataBus.VehicleStopped) { + if (DataBus.VehicleInfo.VehicleStopped) { CurrentState.Disengaged = true; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs index 968000af4f7ce7a0309442713e394754763b5217..9783694270b0582b2db1bde41404bbcdd0af3be4 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs @@ -91,7 +91,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override uint InitGear(Second absTime, Second dt, NewtonMeter torque, PerSecond outAngularVelocity) { - if (DataBus.VehicleSpeed.IsEqual(0)) { + if (DataBus.VehicleInfo.VehicleSpeed.IsEqual(0)) { // AT always starts in first gear and TC active! _gearbox.TorqueConverterLocked = false; _gearbox.Disengaged = true; @@ -105,7 +105,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var response = _gearbox.Initialize(gear, torqueConverterLocked, torque, outAngularVelocity); - if (response.Engine.EngineSpeed > DataBus.EngineRatedSpeed || response.Engine.EngineSpeed < DataBus.EngineIdleSpeed) { + if (response.Engine.EngineSpeed > DataBus.EngineInfo.EngineRatedSpeed || response.Engine.EngineSpeed < DataBus.EngineInfo.EngineIdleSpeed) { continue; } @@ -154,10 +154,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // DISENGAGE ------------------------------------------------------ // 1) _ -> 0: disengage before halting - var braking = DataBus.DriverBehavior == DrivingBehavior.Braking; + var braking = DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Braking; var torqueNegative = outTorque.IsSmaller(0); var slowerThanDisengageSpeed = - DataBus.VehicleSpeed.IsSmaller(Constants.SimulationSettings.ATGearboxDisengageWhenHaltingSpeed); + DataBus.VehicleInfo.VehicleSpeed.IsSmaller(Constants.SimulationSettings.ATGearboxDisengageWhenHaltingSpeed); var disengageBeforeHalting = braking && torqueNegative && slowerThanDisengageSpeed; // 2) L -> 0: disengage if inAngularVelocity == 0 @@ -165,11 +165,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // 3) 1C -> 0: disengange when negative T_out and positive T_in var gear1C = gear == 1 && !_gearbox.TorqueConverterLocked; - var disengageTOutNegativeAndTInPositive = DataBus.DriverAcceleration <= 0 && gear1C && outTorque.IsSmaller(0) && + var disengageTOutNegativeAndTInPositive = DataBus.DriverInfo.DriverAcceleration <= 0 && gear1C && outTorque.IsSmaller(0) && inTorque.IsGreater(0); var disengageTCEngineSpeedLowerIdle = braking && torqueNegative && gear1C && - inAngularVelocity.IsSmallerOrEqual(DataBus.EngineIdleSpeed); + inAngularVelocity.IsSmallerOrEqual(DataBus.EngineInfo.EngineIdleSpeed); if (disengageBeforeHalting || disengageTCEngineSpeedLowerIdle || disengageAngularVelocityZero || disengageTOutNegativeAndTInPositive) { @@ -203,14 +203,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Second absTime, NewtonMeter outTorque, PerSecond outAngularVelocity, PerSecond inAngularVelocity, uint gear) { // Emergency Downshift: if lower than engine idle speed - if (inAngularVelocity.IsSmaller(DataBus.EngineIdleSpeed)) { + if (inAngularVelocity.IsSmaller(DataBus.EngineInfo.EngineIdleSpeed)) { Log.Debug("engine speed would fall below idle speed - shift down"); Downshift(absTime, gear); return true; } // Emergency Upshift: if higher than engine rated speed - if (inAngularVelocity.IsGreaterOrEqual(VectoMath.Min(ModelData.Gears[gear].MaxSpeed, DataBus.EngineN95hSpeed))) { + if (inAngularVelocity.IsGreaterOrEqual(VectoMath.Min(ModelData.Gears[gear].MaxSpeed, DataBus.EngineInfo.EngineN95hSpeed))) { // check if upshift is possible if (!ModelData.Gears.ContainsKey(gear + 1)) { return false; @@ -290,7 +290,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // C -> C+1 var nextGear = ModelData.Gears[gear + 1]; var gearRatio = nextGear.TorqueConverterRatio / currentGear.TorqueConverterRatio; - var minEngineSpeed = VectoMath.Min(700.RPMtoRad(), gearRatio * (DataBus.EngineN80hSpeed - 150.RPMtoRad())); + var minEngineSpeed = VectoMath.Min(700.RPMtoRad(), gearRatio * (DataBus.EngineInfo.EngineN80hSpeed - 150.RPMtoRad())); var nextGearboxInSpeed = outAngularVelocity * nextGear.TorqueConverterRatio; var nextGearboxInTorque = outTorque / nextGear.TorqueConverterRatio; @@ -301,10 +301,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl _gearbox.TorqueConverter.FindOperatingPoint(absTime, dt, nextGearboxInTorque, nextGearboxInSpeed); var engineSpeedOverMin = tcOperatingPoint.InAngularVelocity.IsGreater(minEngineSpeed); - var avgSpeed = (DataBus.EngineSpeed + tcOperatingPoint.InAngularVelocity) / 2; - var engineMaxTorque = DataBus.EngineStationaryFullPower(avgSpeed) / avgSpeed; + var avgSpeed = (DataBus.EngineInfo.EngineSpeed + tcOperatingPoint.InAngularVelocity) / 2; + var engineMaxTorque = DataBus.EngineInfo.EngineStationaryFullPower(avgSpeed) / avgSpeed; var engineInertiaTorque = Formulas.InertiaPower( - DataBus.EngineSpeed, tcOperatingPoint.InAngularVelocity, _gearbox.EngineInertia, dt) / avgSpeed; + DataBus.EngineInfo.EngineSpeed, tcOperatingPoint.InAngularVelocity, _gearbox.EngineInertia, dt) / avgSpeed; var engineTorqueBelowMax = tcOperatingPoint.InTorque.IsSmallerOrEqual(engineMaxTorque - engineInertiaTorque); @@ -313,7 +313,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl outAngularVelocity, outTorque, inAngularVelocity, inTorque, gear, response); // EstimateAccelerationForGear(gear + 1, outAngularVelocity); var minAcceleration = VectoMath.Min( ModelData.TorqueConverterData.CCUpshiftMinAcceleration, - DataBus.DriverAcceleration); + DataBus.DriverInfo.DriverAcceleration); var minAccelerationReachable = reachableAcceleration.IsGreaterOrEqual(minAcceleration); if (engineSpeedOverMin && engineTorqueBelowMax && minAccelerationReachable) { @@ -346,13 +346,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var isAboveUpShift = IsAboveUpShiftCurve(gear, nextEngineTorque, nextEngineSpeed, _gearbox.TorqueConverterLocked); var minAccelerationReachable = true; - if (!DataBus.VehicleSpeed.IsEqual(0)) { + if (!DataBus.VehicleInfo.VehicleSpeed.IsEqual(0)) { var reachableAcceleration = EstimateAccelerationForGear(nextGear, outAngularVelocity); var minAcceleration = _gearbox.TorqueConverterLocked ? ModelData.UpshiftMinAcceleration : ModelData.TorqueConverterData.CLUpshiftMinAcceleration; minAcceleration = VectoMath.Min( - minAcceleration, VectoMath.Max(0.SI<MeterPerSquareSecond>(), DataBus.DriverAcceleration)); + minAcceleration, VectoMath.Max(0.SI<MeterPerSquareSecond>(), DataBus.DriverInfo.DriverAcceleration)); minAccelerationReachable = reachableAcceleration.IsGreaterOrEqual(minAcceleration); } @@ -415,9 +415,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return true; } - if (shiftTimeReached && DataBus.DrivingAction == DrivingAction.Accelerate) { - if (DataBus.VehicleSpeed < DataBus.CycleData.LeftSample.VehicleTargetSpeed - 10.KMPHtoMeterPerSecond() && - DataBus.DriverAcceleration < 0.SI<MeterPerSquareSecond>()) { + if (shiftTimeReached && DataBus.DriverInfo.DrivingAction == DrivingAction.Accelerate) { + if (DataBus.VehicleInfo.VehicleSpeed < DataBus.DrivingCycleInfo.CycleData.LeftSample.VehicleTargetSpeed - 10.KMPHtoMeterPerSecond() && + DataBus.DriverInfo.DriverAcceleration < 0.SI<MeterPerSquareSecond>()) { var tmpResponseCurr = (ResponseDryRun)_gearbox.Request(absTime, dt, outTorque, outAngularVelocity, true); if (_gearbox.Gear > 1 || _gearbox.Gear == 1 && _gearbox.TorqueConverterLocked) { var tmpCurr = _nextGear.Clone(); @@ -429,7 +429,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl _nextGear.SetState(tmpCurr); SetGear(tmpGbxState); if (tmpResponseDs.DeltaFullLoad - Formulas.InertiaPower( - tmpResponseDs.Engine.EngineSpeed, DataBus.EngineSpeed, EngineInertia, dt) < tmpResponseCurr.DeltaFullLoad) { + tmpResponseDs.Engine.EngineSpeed, DataBus.EngineInfo.EngineSpeed, EngineInertia, dt) < tmpResponseCurr.DeltaFullLoad) { Downshift(absTime, gear); return true; } @@ -497,17 +497,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected MeterPerSquareSecond EstimateAcceleration( PerSecond gbxOutSpeed, NewtonMeter gbxOutTorque, PerSecond tcInSpeed, NewtonMeter tcInTorque, uint currentGear, IResponse response) { - var vehicleSpeed = DataBus.VehicleSpeed; + var vehicleSpeed = DataBus.VehicleInfo.VehicleSpeed; var avgSlope = - ((DataBus.CycleLookAhead(Constants.SimulationSettings.GearboxLookaheadForAccelerationEstimation).Altitude - - DataBus.Altitude) / Constants.SimulationSettings.GearboxLookaheadForAccelerationEstimation).Value().SI<Radian>(); + ((DataBus.DrivingCycleInfo.CycleLookAhead(Constants.SimulationSettings.GearboxLookaheadForAccelerationEstimation).Altitude - + DataBus.DrivingCycleInfo.Altitude) / Constants.SimulationSettings.GearboxLookaheadForAccelerationEstimation).Value().SI<Radian>(); - var airDragLoss = DataBus.AirDragResistance(vehicleSpeed, vehicleSpeed) * DataBus.VehicleSpeed; - var rollResistanceLoss = DataBus.RollingResistance(avgSlope) * DataBus.VehicleSpeed; + var airDragLoss = DataBus.VehicleInfo.AirDragResistance(vehicleSpeed, vehicleSpeed) * DataBus.VehicleInfo.VehicleSpeed; + var rollResistanceLoss = DataBus.VehicleInfo.RollingResistance(avgSlope) * DataBus.VehicleInfo.VehicleSpeed; //DataBus.GearboxLoss(); - var slopeLoss = DataBus.SlopeResistance(avgSlope) * DataBus.VehicleSpeed; - var axleLoss = DataBus.AxlegearLoss(); + var slopeLoss = DataBus.VehicleInfo.SlopeResistance(avgSlope) * DataBus.VehicleInfo.VehicleSpeed; + var axleLoss = DataBus.AxlegearInfo.AxlegearLoss(); var tcLossesCurrentGear = tcInSpeed * tcInTorque - gbxOutSpeed * gbxOutTorque; @@ -520,7 +520,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var accelerationPower = gbxOutSpeed * gbxOutTorque - deltaTcLosses - axleLoss - airDragLoss - rollResistanceLoss - slopeLoss; - var acceleration = accelerationPower / DataBus.VehicleSpeed / (DataBus.TotalMass + DataBus.ReducedMassWheels); + var acceleration = accelerationPower / DataBus.VehicleInfo.VehicleSpeed / (DataBus.VehicleInfo.TotalMass + DataBus.WheelsInfo.ReducedMassWheels); return acceleration.Cast<MeterPerSquareSecond>(); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategyOptimized.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategyOptimized.cs index 7432e9f7cd51c0959aa377821a1fe37bcdb05e77..83e0781c998277cb267c0034f14ffd3725a49d24 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategyOptimized.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategyOptimized.cs @@ -184,14 +184,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { var accPower = EstimateAccelerrationPower(outAngularVelocity, outTorque); - var _accMin = (accPower / DataBus.VehicleSpeed / (MaxMass + DataBus.ReducedMassWheels)).Cast<MeterPerSquareSecond>(); - var _accMax = (accPower / DataBus.VehicleSpeed / (MinMass + DataBus.ReducedMassWheels)).Cast<MeterPerSquareSecond>(); + var _accMin = (accPower / DataBus.VehicleInfo.VehicleSpeed / (MaxMass + DataBus.WheelsInfo.ReducedMassWheels)).Cast<MeterPerSquareSecond>(); + var _accMax = (accPower / DataBus.VehicleInfo.VehicleSpeed / (MinMass + DataBus.WheelsInfo.ReducedMassWheels)).Cast<MeterPerSquareSecond>(); var engineLoadPercent = inTorque / response.Engine.EngineDynamicFullLoadTorque; var _loadStage = GetLoadStage(engineLoadPercent); var shiftSpeed = UpshiftLineTCLocked.LookupShiftSpeed( - _loadStage, DataBus.RoadGradient, DataBus.DriverAcceleration, _accMin, _accMax); + _loadStage, DataBus.DrivingCycleInfo.RoadGradient, DataBus.DriverInfo.DriverAcceleration, _accMin, _accMax); var shiftSpeedGbxOut = shiftSpeed / ModelData.Gears[currentGear].Ratio; if (outAngularVelocity > shiftSpeedGbxOut) { Upshift(absTime, currentGear); @@ -203,17 +203,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected Watt EstimateAccelerrationPower(PerSecond gbxOutSpeed, NewtonMeter gbxOutTorque) { - var vehicleSpeed = DataBus.VehicleSpeed; + var vehicleSpeed = DataBus.VehicleInfo.VehicleSpeed; var avgSlope = - ((DataBus.CycleLookAhead(Constants.SimulationSettings.GearboxLookaheadForAccelerationEstimation).Altitude - - DataBus.Altitude) / Constants.SimulationSettings.GearboxLookaheadForAccelerationEstimation).Value().SI<Radian>(); + ((DataBus.DrivingCycleInfo.CycleLookAhead(Constants.SimulationSettings.GearboxLookaheadForAccelerationEstimation).Altitude - + DataBus.DrivingCycleInfo.Altitude) / Constants.SimulationSettings.GearboxLookaheadForAccelerationEstimation).Value().SI<Radian>(); - var airDragLoss = DataBus.AirDragResistance(vehicleSpeed, vehicleSpeed) * DataBus.VehicleSpeed; - var rollResistanceLoss = DataBus.RollingResistance(avgSlope) * DataBus.VehicleSpeed; + var airDragLoss = DataBus.VehicleInfo.AirDragResistance(vehicleSpeed, vehicleSpeed) * DataBus.VehicleInfo.VehicleSpeed; + var rollResistanceLoss = DataBus.VehicleInfo.RollingResistance(avgSlope) * DataBus.VehicleInfo.VehicleSpeed; //DataBus.GearboxLoss(); - var slopeLoss = DataBus.SlopeResistance(avgSlope) * DataBus.VehicleSpeed; - var axleLoss = DataBus.AxlegearLoss(); + var slopeLoss = DataBus.VehicleInfo.SlopeResistance(avgSlope) * DataBus.VehicleInfo.VehicleSpeed; + var axleLoss = DataBus.AxlegearInfo.AxlegearLoss(); return gbxOutSpeed * gbxOutTorque - axleLoss - airDragLoss - rollResistanceLoss - slopeLoss; } @@ -236,7 +236,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return null; } - if (DataBus.DriverAcceleration < 0) { + if (DataBus.DriverInfo.DriverAcceleration < 0) { return null; } if (response1.Engine.EngineTorqueDemand.IsSmaller(DeclarationData.GearboxTCU.DragMarginFactor * fld[currentGear].DragLoadStationaryTorque(response1.Engine.EngineSpeed))) { @@ -250,12 +250,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var current = new GearshiftPosition(currentGear, _gearbox.TorqueConverterLocked); var currentIdx = GearList.IndexOf(current); - var vDrop = DataBus.DriverAcceleration * shiftStrategyParameters.ATLookAheadTime; - var vehicleSpeedPostShift = (DataBus.VehicleSpeed + vDrop * shiftStrategyParameters.VelocityDropFactor).LimitTo( - 0.KMPHtoMeterPerSecond(), DataBus.CycleData.LeftSample.VehicleTargetSpeed); + var vDrop = DataBus.DriverInfo.DriverAcceleration * shiftStrategyParameters.ATLookAheadTime; + var vehicleSpeedPostShift = (DataBus.VehicleInfo.VehicleSpeed + vDrop * shiftStrategyParameters.VelocityDropFactor).LimitTo( + 0.KMPHtoMeterPerSecond(), DataBus.DrivingCycleInfo.CycleData.LeftSample.VehicleTargetSpeed); var outAngularVelocityEst = - (outAngularVelocity * vehicleSpeedPostShift / (DataBus.VehicleSpeed + DataBus.DriverAcceleration * dt)) + (outAngularVelocity * vehicleSpeedPostShift / (DataBus.VehicleInfo.VehicleSpeed + DataBus.DriverInfo.DriverAcceleration * dt)) .Cast<PerSecond>(); var outTorqueEst = outTorque * outAngularVelocity / outAngularVelocityEst; @@ -276,13 +276,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var inAngularVelocity = ModelData.Gears[next.Gear].Ratio * outAngularVelocity; - var totalTransmissionRatio = inAngularVelocity / (DataBus.VehicleSpeed + DataBus.DriverAcceleration * dt); + var totalTransmissionRatio = inAngularVelocity / (DataBus.VehicleInfo.VehicleSpeed + DataBus.DriverInfo.DriverAcceleration * dt); var estimatedEngineSpeed = (vehicleSpeedPostShift * totalTransmissionRatio).Cast<PerSecond>(); if (estimatedEngineSpeed.IsSmaller(shiftStrategyParameters.MinEngineSpeedPostUpshift)) { continue; } - var pNextGearMax = DataBus.EngineStationaryFullPower(estimatedEngineSpeed); + var pNextGearMax = DataBus.EngineInfo.EngineStationaryFullPower(estimatedEngineSpeed); var response = RequestDryRunWithGear(absTime, dt, outTorqueEst, outAngularVelocityEst, next); @@ -313,7 +313,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl continue; } - var accelerationTorque = vehicleMass * DataBus.DriverAcceleration * DataBus.VehicleSpeed / outAngularVelocity; + var accelerationTorque = vehicleMass * DataBus.DriverInfo.DriverAcceleration * DataBus.VehicleInfo.VehicleSpeed / outAngularVelocity; var reducedTorque = outTorque - accelerationTorque * (1 - accelerationFactor); response = RequestDryRunWithGear(absTime, dt, reducedTorque, outAngularVelocity, next); @@ -472,9 +472,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl TestContainerGbx.Gear = gear.Gear; TestContainerGbx.TorqueConverterLocked = gear.TorqueConverterLocked.Value; - TestContainer.VehiclePort.Initialize(vehicleSpeed, DataBus.RoadGradient); + TestContainer.VehiclePort.Initialize(vehicleSpeed, DataBus.DrivingCycleInfo.RoadGradient); var response = (ResponseDryRun)TestContainer.VehiclePort.Request( - 0.SI<Second>(), dt, acceleration, DataBus.RoadGradient, true); + 0.SI<Second>(), dt, acceleration, DataBus.DrivingCycleInfo.RoadGradient, true); return response; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategyVoith.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategyVoith.cs index 324783f7abbfa6132215f889567ca469aab56a25..c5168205f8d84f87b8e1903a72b90d78213c34c9 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategyVoith.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategyVoith.cs @@ -139,17 +139,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected Watt EstimateAccelerrationPower(PerSecond gbxOutSpeed, NewtonMeter gbxOutTorque) { - var vehicleSpeed = DataBus.VehicleSpeed; + var vehicleSpeed = DataBus.VehicleInfo.VehicleSpeed; var avgSlope = - ((DataBus.CycleLookAhead(Constants.SimulationSettings.GearboxLookaheadForAccelerationEstimation).Altitude - - DataBus.Altitude) / Constants.SimulationSettings.GearboxLookaheadForAccelerationEstimation).Value().SI<Radian>(); + ((DataBus.DrivingCycleInfo.CycleLookAhead(Constants.SimulationSettings.GearboxLookaheadForAccelerationEstimation).Altitude - + DataBus.DrivingCycleInfo.Altitude) / Constants.SimulationSettings.GearboxLookaheadForAccelerationEstimation).Value().SI<Radian>(); - var airDragLoss = DataBus.AirDragResistance(vehicleSpeed, vehicleSpeed) * DataBus.VehicleSpeed; - var rollResistanceLoss = DataBus.RollingResistance(avgSlope) * DataBus.VehicleSpeed; + var airDragLoss = DataBus.VehicleInfo.AirDragResistance(vehicleSpeed, vehicleSpeed) * DataBus.VehicleInfo.VehicleSpeed; + var rollResistanceLoss = DataBus.VehicleInfo.RollingResistance(avgSlope) * DataBus.VehicleInfo.VehicleSpeed; //DataBus.GearboxLoss(); - var slopeLoss = DataBus.SlopeResistance(avgSlope) * DataBus.VehicleSpeed; - var axleLoss = DataBus.AxlegearLoss(); + var slopeLoss = DataBus.VehicleInfo.SlopeResistance(avgSlope) * DataBus.VehicleInfo.VehicleSpeed; + var axleLoss = DataBus.AxlegearInfo.AxlegearLoss(); return gbxOutSpeed * gbxOutTorque - axleLoss - airDragLoss - rollResistanceLoss - slopeLoss; } @@ -158,8 +158,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override void Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) { - driverAcceleration = DataBus.DriverAcceleration; - roadGradient = DataBus.RoadGradient; + driverAcceleration = DataBus.DriverInfo.DriverAcceleration; + roadGradient = DataBus.DrivingCycleInfo.RoadGradient; base.Request(absTime, dt, outTorque, outAngularVelocity); } @@ -169,8 +169,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { var accPower = EstimateAccelerrationPower(outAngularVelocity, outTorque); - _accMin = (accPower / DataBus.VehicleSpeed / (MaxMass + DataBus.ReducedMassWheels)).Cast<MeterPerSquareSecond>(); - _accMax = (accPower / DataBus.VehicleSpeed / (MinMass + DataBus.ReducedMassWheels)).Cast<MeterPerSquareSecond>(); + _accMin = (accPower / DataBus.VehicleInfo.VehicleSpeed / (MaxMass + DataBus.WheelsInfo.ReducedMassWheels)).Cast<MeterPerSquareSecond>(); + _accMax = (accPower / DataBus.VehicleInfo.VehicleSpeed / (MinMass + DataBus.WheelsInfo.ReducedMassWheels)).Cast<MeterPerSquareSecond>(); //var engineLoadPercent = inTorque / FullLoadCurve.FullLoadStationaryTorque(inAngularVelocity); var engineLoadPercent = inTorque / response.Engine.EngineDynamicFullLoadTorque; @@ -224,7 +224,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var shiftSpeed = UpshiftLines[gearIdx].LookupShiftSpeed( - _loadStage, DataBus.RoadGradient, DataBus.DriverAcceleration, _accMin, _accMax); + _loadStage, DataBus.DrivingCycleInfo.RoadGradient, DataBus.DriverInfo.DriverAcceleration, _accMin, _accMax); var shiftSpeedGbxOut = shiftSpeed / ModelData.Gears[nextGear].Ratio; if (outAngularVelocity > shiftSpeedGbxOut) { Upshift(absTime, gear); @@ -252,7 +252,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl gearIdx += 1; } var shiftSpeed = DownshiftLines[gearIdx].LookupShiftSpeed( - _loadStage, DataBus.RoadGradient, DataBus.DriverAcceleration, -0.4.SI<MeterPerSquareSecond>(), + _loadStage, DataBus.DrivingCycleInfo.RoadGradient, DataBus.DriverInfo.DriverAcceleration, -0.4.SI<MeterPerSquareSecond>(), -0.2.SI<MeterPerSquareSecond>()); if (inAngularVelocity < shiftSpeed) { Downshift(absTime, gear); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs index a8d2514eb0e41a49bbedc76bcaee11c26320e56b..b3031e03e6d49d202c2f5bb42b74d6ffed9e8e4f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AbstractGearbox.cs @@ -155,7 +155,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ratio = ModelData.Gears[gear].TorqueConverterRatio; } var torqueGbxIn = outTorque / ratio; - var deltaClutchSpeed = (DataBus.EngineSpeed - PreviousState.OutAngularVelocity * ratio) / 2; + var deltaClutchSpeed = (DataBus.EngineInfo.EngineSpeed - PreviousState.OutAngularVelocity * ratio) / 2; var shiftLossEnergy = torqueGbxIn * deltaClutchSpeed * ModelData.PowershiftShiftTime; return shiftLossEnergy.Abs(); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BaseShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BaseShiftStrategy.cs index e50937130856522e779ece74abe472ac9fa557b1..c7a0261593210e83c6e896c88a69da78264bc47f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BaseShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BaseShiftStrategy.cs @@ -93,26 +93,26 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl throw new VectoSimulationException("EstimateAccelerationForGear: invalid gear: {0}", gear); } - var vehicleSpeed = DataBus.VehicleSpeed; + var vehicleSpeed = DataBus.VehicleInfo.VehicleSpeed; var nextEngineSpeed = gbxAngularVelocityOut * ModelData.Gears[gear].Ratio; - var maxEnginePower = DataBus.EngineStationaryFullPower(nextEngineSpeed); + var maxEnginePower = DataBus.EngineInfo.EngineStationaryFullPower(nextEngineSpeed); var avgSlope = - ((DataBus.CycleLookAhead(Constants.SimulationSettings.GearboxLookaheadForAccelerationEstimation).Altitude - - DataBus.Altitude) / Constants.SimulationSettings.GearboxLookaheadForAccelerationEstimation).Value().SI<Radian>(); + ((DataBus.DrivingCycleInfo.CycleLookAhead(Constants.SimulationSettings.GearboxLookaheadForAccelerationEstimation).Altitude - + DataBus.DrivingCycleInfo.Altitude) / Constants.SimulationSettings.GearboxLookaheadForAccelerationEstimation).Value().SI<Radian>(); - var airDragLoss = DataBus.AirDragResistance(vehicleSpeed, vehicleSpeed) * DataBus.VehicleSpeed; - var rollResistanceLoss = DataBus.RollingResistance(avgSlope) * DataBus.VehicleSpeed; + var airDragLoss = DataBus.VehicleInfo.AirDragResistance(vehicleSpeed, vehicleSpeed) * DataBus.VehicleInfo.VehicleSpeed; + var rollResistanceLoss = DataBus.VehicleInfo.RollingResistance(avgSlope) * DataBus.VehicleInfo.VehicleSpeed; var gearboxLoss = ModelData.Gears[gear].LossMap.GetTorqueLoss(gbxAngularVelocityOut, maxEnginePower / nextEngineSpeed * ModelData.Gears[gear].Ratio).Value * nextEngineSpeed; //DataBus.GearboxLoss(); - var slopeLoss = DataBus.SlopeResistance(avgSlope) * DataBus.VehicleSpeed; - var axleLoss = DataBus.AxlegearLoss(); + var slopeLoss = DataBus.VehicleInfo.SlopeResistance(avgSlope) * DataBus.VehicleInfo.VehicleSpeed; + var axleLoss = DataBus.AxlegearInfo.AxlegearLoss(); var accelerationPower = maxEnginePower - gearboxLoss - axleLoss - airDragLoss - rollResistanceLoss - slopeLoss; - var acceleration = accelerationPower / DataBus.VehicleSpeed / (DataBus.TotalMass + DataBus.ReducedMassWheels); + var acceleration = accelerationPower / DataBus.VehicleInfo.VehicleSpeed / (DataBus.VehicleInfo.TotalMass + DataBus.WheelsInfo.ReducedMassWheels); return acceleration.Cast<MeterPerSquareSecond>(); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Brakes.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Brakes.cs index b78a56f26863a9300644033444c8351749a27038..d980bd3f71fdb5ff5102839e196c744c03e98772 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Brakes.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Brakes.cs @@ -52,7 +52,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { BrakePower = 0.SI<Watt>(); PreviousState.SetState(torque, angularVelocity, torque, angularVelocity); - return DataBus.DriverBehavior == DrivingBehavior.Halted && DataBus.VehicleStopped + return DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Halted && DataBus.VehicleInfo.VehicleStopped ? NextComponent.Initialize(0.SI<NewtonMeter>(), 0.SI<PerSecond>()) : NextComponent.Initialize(torque, angularVelocity); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs index 9294cff6420a8778642b8eab7fc0b6740da7de90..410ae53d8b8b1d2c509f21e6258f565025295c32 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs @@ -65,7 +65,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl EngineStopStartUtilityFactor = container.RunData?.DriverData?.EngineStopStart?.UtilityFactor ?? double.NaN; CurrentState = new BusAuxState(); - PreviousState = new BusAuxState { AngularSpeed = container.EngineIdleSpeed }; + PreviousState = new BusAuxState { AngularSpeed = container.EngineInfo.EngineIdleSpeed }; AdditionalAux = additionalAux; AuxCfg = auxiliaryConfig; @@ -74,7 +74,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var tmpAux = new BusAuxiliaries.BusAuxiliaries(container.ModalData); //'Set Signals - tmpAux.Signals.EngineIdleSpeed = container.EngineIdleSpeed; + tmpAux.Signals.EngineIdleSpeed = container.EngineInfo.EngineIdleSpeed; tmpAux.Initialise(auxiliaryConfig); SmartElectricSystem = auxiliaryConfig.ElectricalUserInputsConfig.SmartElectrical; @@ -142,7 +142,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { var conventionalAux = AdditionalAux; AdditionalAux = null; - CurrentState.AngularSpeed = DataBus.EngineIdleSpeed; + CurrentState.AngularSpeed = DataBus.EngineInfo.EngineIdleSpeed; CurrentState.dt = dt; var signals = Auxiliaries.Signals; @@ -152,19 +152,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl signals.VehicleStopped = false; var busAuxPowerDemand = GetBusAuxPowerDemand( - absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineIdleSpeed); + absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineInfo.EngineIdleSpeed); AdditionalAux = conventionalAux; - CurrentState.PowerDemand = ((AdditionalAux?.PowerDemandEngineOn(absTime, dt, DataBus.EngineIdleSpeed) ?? 0.SI<Watt>()) + + CurrentState.PowerDemand = ((AdditionalAux?.PowerDemandEngineOn(absTime, dt, DataBus.EngineInfo.EngineIdleSpeed) ?? 0.SI<Watt>()) + busAuxPowerDemand) * (1 - EngineStopStartUtilityFactor); //CurrentState.ESPowerGeneratedICE_On = Auxiliaries.ElectricPowerGenerated; //CurrentState.ESPowerMech = Auxiliaries.ElectricPowerDemandMech; // - signals.EngineStopped = !DataBus.CombustionEngineOn; - signals.VehicleStopped = DataBus.VehicleStopped; + signals.EngineStopped = !DataBus.EngineCtl.CombustionEngineOn; + signals.VehicleStopped = DataBus.VehicleInfo.VehicleStopped; busAuxPowerDemand = GetBusAuxPowerDemand( - absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineIdleSpeed); + absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineInfo.EngineIdleSpeed); AdditionalAux = conventionalAux; return EngineStopStartUtilityFactor * (busAuxPowerDemand + AdditionalAux?.PowerDemandEngineOff(absTime, dt)); @@ -174,7 +174,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected internal virtual void DoWriteModalResults(Second absTime, Second dt, IModalDataContainer container) { var essUtilityFactor = 1.0; - if (!DataBus.CombustionEngineOn) { + if (!DataBus.EngineCtl.CombustionEngineOn) { essUtilityFactor = 1 - EngineStopStartUtilityFactor; } @@ -184,7 +184,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // cycleStep has to be called here and not in DoCommit, write is called before Commit! var oldSOC = Auxiliaries.BatterySOC; - Auxiliaries.CycleStep(CurrentState.dt, DataBus.CombustionEngineOn ? 1.0 : EngineStopStartUtilityFactor); + Auxiliaries.CycleStep(CurrentState.dt, DataBus.EngineCtl.CombustionEngineOn ? 1.0 : EngineStopStartUtilityFactor); var newSOC = Auxiliaries.BatterySOC; //CurrentState.TotalFuelConsumption = Auxiliaries.TotalFuel; @@ -201,7 +201,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl container[ModalResultField.BatterySOC] = Auxiliaries.BatterySOC * 100.0; - container[ModalResultField.P_busAux_ES_generated] = essUtilityFactor * (DataBus.VehicleStopped && !DataBus.CombustionEngineOn ? Auxiliaries.ElectricPowerConsumerSum : Auxiliaries.ElectricPowerGenerated); + container[ModalResultField.P_busAux_ES_generated] = essUtilityFactor * (DataBus.VehicleInfo.VehicleStopped && !DataBus.EngineCtl.CombustionEngineOn ? Auxiliaries.ElectricPowerConsumerSum : Auxiliaries.ElectricPowerGenerated); container[ModalResultField.P_busAux_ES_sum_mech] = essUtilityFactor * (Auxiliaries.ElectricPowerConsumerSum - batteryPwr) / AuxCfg.ElectricalUserInputsConfig.AlternatorGearEfficiency / AuxCfg.ElectricalUserInputsConfig.AlternatorMap.GetEfficiency(0.RPMtoRad(), 0.SI<Ampere>()); @@ -236,7 +236,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var signals = Auxiliaries.Signals; signals.SimulationInterval = dt; - signals.ClutchEngaged = DataBus.ClutchClosed(absTime); + signals.ClutchEngaged = DataBus.ClutchInfo.ClutchClosed(absTime); signals.EngineDrivelineTorque = torquePowerTrain; signals.EngineSpeed = angularSpeed; @@ -248,18 +248,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl : 0.SI<Watt>(); var drivetrainPower = torquePowerTrain * avgAngularSpeed; - if (!dryRun && DataBus.DrivingAction == DrivingAction.Brake && CurrentState.ExcessiveDragPower.IsEqual(0)) { + if (!dryRun && DataBus.DriverInfo.DrivingAction == DrivingAction.Brake && CurrentState.ExcessiveDragPower.IsEqual(0)) { CurrentState.ExcessiveDragPower = drivetrainPower - - (DataBus.EngineDragPower(avgAngularSpeed) - signals.PreExistingAuxPower) - DataBus.BrakePower; + (DataBus.EngineInfo.EngineDragPower(avgAngularSpeed) - signals.PreExistingAuxPower) - DataBus.Brakes.BrakePower; } - if (!dryRun && DataBus.DrivingAction != DrivingAction.Brake) { + if (!dryRun && DataBus.DriverInfo.DrivingAction != DrivingAction.Brake) { CurrentState.ExcessiveDragPower = 0.SI<Watt>(); } signals.ExcessiveDragPower = CurrentState.ExcessiveDragPower; - signals.Idle = DataBus.VehicleStopped; - signals.InNeutral = DataBus.Gear == 0; + signals.Idle = DataBus.VehicleInfo.VehicleStopped; + signals.InNeutral = DataBus.GearboxInfo.Gear == 0; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs index 763fa6eb04a468dbaf95288cfb4308f7ec47985d..753aa41a6442ab48e61db485e8f8107f7746eb1d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs @@ -76,11 +76,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { NewtonMeter torqueIn; PerSecond engineSpeedIn; - if (DataBus.DriverBehavior == DrivingBehavior.Halted /*DataBus.VehicleStopped*/) { + if (DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Halted /*DataBus.VehicleStopped*/) { engineSpeedIn = _idleSpeed; torqueIn = 0.SI<NewtonMeter>(); } else { - AddClutchLoss(outTorque, outAngularVelocity, firstInitialize || DataBus.VehicleStopped, out torqueIn, out engineSpeedIn); + AddClutchLoss(outTorque, outAngularVelocity, firstInitialize || DataBus.VehicleInfo.VehicleStopped, out torqueIn, out engineSpeedIn); } PreviousState.SetState(torqueIn, engineSpeedIn, outTorque, outAngularVelocity); //if (!firstInitialize) { @@ -96,7 +96,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl bool dryRun = false) { firstInitialize = false; - if (!DataBus.ClutchClosed(absTime) && !dryRun) { + if (!DataBus.ClutchInfo.ClutchClosed(absTime) && !dryRun) { return HandleClutchOpen(absTime, dt, outTorque, outAngularVelocity, dryRun); } @@ -156,9 +156,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl NewtonMeter torqueIn; PerSecond angularVelocityIn; - var startClutch = DataBus.VehicleStopped || !PreviousState.ClutchLoss.IsEqual(0); - var slippingClutchWhenDriving = (DataBus.Gear <= 2 && DataBus.DriverBehavior != DrivingBehavior.Braking); - var slippingClutchDuringBraking = DataBus.Gear == 1 && DataBus.DriverBehavior == DrivingBehavior.Braking && outTorque > 0 && DataBus.BrakePower.IsEqual(0); + var startClutch = DataBus.VehicleInfo.VehicleStopped || !PreviousState.ClutchLoss.IsEqual(0); + var slippingClutchWhenDriving = (DataBus.GearboxInfo.Gear <= 2 && DataBus.DriverInfo.DriverBehavior != DrivingBehavior.Braking); + var slippingClutchDuringBraking = DataBus.GearboxInfo.Gear == 1 && DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Braking && outTorque > 0 && DataBus.Brakes.BrakePower.IsEqual(0); //var slippingClutchWhenDriving = (DataBus.Gear == 1 && outTorque > 0); AddClutchLoss(outTorque, outAngularVelocity, slippingClutchWhenDriving || slippingClutchDuringBraking || startClutch || outAngularVelocity.IsEqual(0), @@ -170,7 +170,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var avgOutAngularVelocity = (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0; var avgInAngularVelocity = (PreviousState.InAngularVelocity + angularVelocityIn) / 2.0; var clutchLoss = torqueIn * avgInAngularVelocity - outTorque * avgOutAngularVelocity; - if (!startClutch && !clutchLoss.IsEqual(0) && (DataBus.Gear != 1 || clutchLoss.IsSmaller(0))) { + if (!startClutch && !clutchLoss.IsEqual(0) && (DataBus.GearboxInfo.Gear != 1 || clutchLoss.IsSmaller(0))) { // we don't want to have negative clutch losses, so adapt input torque to match the average output power torqueIn = outTorque * avgOutAngularVelocity / avgInAngularVelocity; } @@ -188,7 +188,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected virtual void AddClutchLoss(NewtonMeter torque, PerSecond angularVelocity, bool allowSlipping, out NewtonMeter torqueIn, out PerSecond angularVelocityIn) { - if (DataBus.DriverBehavior == DrivingBehavior.Halted) { + if (DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Halted) { angularVelocityIn = _idleSpeed; torqueIn = 0.SI<NewtonMeter>(); return; @@ -220,7 +220,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public virtual bool ClutchClosed(Second absTime) { - return DataBus.GearEngaged(absTime); + return DataBus.GearboxInfo.GearEngaged(absTime); } public class ClutchState : SimpleComponentState diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 794640a0dfb0fcac476f70b43bf6a081c688ae92..0cd4e085de1fd0a9493d705c557d8fdc54feebb7 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -97,18 +97,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public Watt EngineStationaryFullPower(PerSecond angularSpeed) { - return ModelData.FullLoadCurves[DataBus.Gear].FullLoadStationaryTorque(angularSpeed) * angularSpeed; + return ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear].FullLoadStationaryTorque(angularSpeed) * angularSpeed; } public Watt EngineDynamicFullLoadPower(PerSecond avgEngineSpeed, Second dt) { return ComputeFullLoadPower( - avgEngineSpeed, ModelData.FullLoadCurves[DataBus.Gear].FullLoadStationaryTorque(avgEngineSpeed), dt, true); + avgEngineSpeed, ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear].FullLoadStationaryTorque(avgEngineSpeed), dt, true); } public Watt EngineDragPower(PerSecond angularSpeed) { - return ModelData.FullLoadCurves[DataBus.Gear].DragLoadStationaryPower(angularSpeed); + return ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear].DragLoadStationaryPower(angularSpeed); } public Watt EngineAuxDemand(PerSecond avgEngineSpeed, Second dt) @@ -198,8 +198,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }; } - var fullDragTorque = ModelData.FullLoadCurves[DataBus.Gear].DragLoadStationaryTorque(avgEngineSpeed); - var stationaryFullLoadTorque = ModelData.FullLoadCurves[DataBus.Gear].FullLoadStationaryTorque(avgEngineSpeed); + var fullDragTorque = ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear].DragLoadStationaryTorque(avgEngineSpeed); + var stationaryFullLoadTorque = ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear].FullLoadStationaryTorque(avgEngineSpeed); var dynamicFullLoadPower = ComputeFullLoadPower(avgEngineSpeed, stationaryFullLoadTorque, dt, dryRun); var dynamicFullLoadTorque = dynamicFullLoadPower / avgEngineSpeed; @@ -337,11 +337,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected virtual PerSecond GetEngineSpeedLimit(Second absTime) { - if (DataBus.Gear == 0 || !DataBus.ClutchClosed(absTime) || !DataBus.TCLocked) { + if (DataBus.GearboxInfo.Gear == 0 || !DataBus.ClutchInfo.ClutchClosed(absTime) || !DataBus.GearboxInfo.TCLocked) { return ModelData.FullLoadCurves[0].N95hSpeed; } - return VectoMath.Min(DataBus.GetGearData(DataBus.Gear).MaxSpeed, ModelData.FullLoadCurves[0].N95hSpeed); + return VectoMath.Min(DataBus.GearboxInfo.GetGearData(DataBus.GearboxInfo.Gear).MaxSpeed, ModelData.FullLoadCurves[0].N95hSpeed); } public virtual IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) @@ -354,8 +354,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl EngineSpeed = outAngularVelocity, dt = 1.SI<Second>(), InertiaTorqueLoss = 0.SI<NewtonMeter>(), - StationaryFullLoadTorque = ModelData.FullLoadCurves[DataBus.Gear].FullLoadStationaryTorque(outAngularVelocity), - FullDragTorque = ModelData.FullLoadCurves[DataBus.Gear].DragLoadStationaryTorque(outAngularVelocity), + StationaryFullLoadTorque = ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear].FullLoadStationaryTorque(outAngularVelocity), + FullDragTorque = ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear].DragLoadStationaryTorque(outAngularVelocity), EngineTorque = outTorque + auxDemand, EnginePower = (outTorque + auxDemand) * outAngularVelocity, }; @@ -430,7 +430,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl "FuelConsumptionMap for fuel {2} was extrapolated: range for FC-Map is not sufficient: n: {0}, torque: {1}", avgEngineSpeed.Value(), CurrentState.EngineTorque.Value(), fuelData.FuelType.GetLabel()); } - var pt1 = ModelData.FullLoadCurves[DataBus.Gear].PT1(avgEngineSpeed); + var pt1 = ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear].PT1(avgEngineSpeed); if (DataBus.ExecutionMode == ExecutionMode.Declaration && pt1.Extrapolated) { Log.Error( "requested rpm below minimum rpm in pt1 - extrapolating. n_eng_avg: {0}", @@ -530,7 +530,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl dynFullPowerCalculated = stationaryFullLoadPower; } else { try { - var pt1 = ModelData.FullLoadCurves[DataBus.Gear].PT1(avgAngularVelocity).Value.Value(); + var pt1 = ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear].PT1(avgAngularVelocity).Value.Value(); var powerRatio = (PreviousState.EnginePower / stationaryFullLoadPower).Value(); var tStarPrev = pt1 * Math.Log(1.0 / (1 - powerRatio), Math.E).SI<Second>(); var tStar = tStarPrev + PreviousState.dt; @@ -558,7 +558,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (dynFullPowerCalculated < 0) { return 0.SI<Watt>(); } - var atGbx = (DataBus as VehicleContainer)?.Gearbox as ATGearbox; + var atGbx = (DataBus as VehicleContainer)?.GearboxInfo as ATGearbox; if (atGbx != null && atGbx.ShiftToLocked && PreviousState.EngineTorque.IsGreater(0)) { return VectoMath.Min(PreviousState.EngineTorque * avgAngularVelocity, dynFullPowerCalculated); @@ -648,8 +648,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } protected virtual IResponse DoHandleRequest(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) { - if (!_dataBus.VehicleStopped && _dataBus.Gear != 0 &&_dataBus.Gear != _dataBus.NextGear.Gear && - _dataBus.NextGear.Gear != 0) { + if (!_dataBus.VehicleInfo.VehicleStopped && _dataBus.GearboxInfo.Gear != 0 &&_dataBus.GearboxInfo.Gear != _dataBus.GearboxInfo.NextGear.Gear && + _dataBus.GearboxInfo.NextGear.Gear != 0) { return RequestDoubleClutch(absTime, dt, outTorque, outAngularVelocity); } return RequestIdling(absTime, dt, outTorque, outAngularVelocity); @@ -659,18 +659,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { if (_idleStart == null) { _idleStart = absTime; - _engineTargetSpeed = _engine.PreviousState.EngineSpeed / _dataBus.GetGearData(_dataBus.Gear).Ratio * - _dataBus.GetGearData(_dataBus.NextGear.Gear).Ratio; + _engineTargetSpeed = _engine.PreviousState.EngineSpeed / _dataBus.GearboxInfo.GetGearData(_dataBus.GearboxInfo.Gear).Ratio * + _dataBus.GearboxInfo.GetGearData(_dataBus.GearboxInfo.NextGear.Gear).Ratio; } - var velocitySlope = (_dataBus.TractionInterruption - (absTime - _idleStart)).IsEqual(0) + var velocitySlope = (_dataBus.GearboxInfo.TractionInterruption - (absTime - _idleStart)).IsEqual(0) ? 0.SI<PerSquareSecond>() : (_engineTargetSpeed - _engine.PreviousState.EngineSpeed) / - (_dataBus.TractionInterruption - (absTime - _idleStart)); + (_dataBus.GearboxInfo.TractionInterruption - (absTime - _idleStart)); var nextAngularSpeed = velocitySlope * dt + _engine.PreviousState.EngineSpeed; - var engineMaxSpeed = VectoMath.Min(_dataBus.GetGearData(_dataBus.NextGear.Gear).MaxSpeed, + var engineMaxSpeed = VectoMath.Min(_dataBus.GearboxInfo.GetGearData(_dataBus.GearboxInfo.NextGear.Gear).MaxSpeed, _engine.ModelData.FullLoadCurves[0].N95hSpeed); nextAngularSpeed = velocitySlope < 0 ? VectoMath.Max(_engineTargetSpeed, nextAngularSpeed).LimitTo(_engine.EngineIdleSpeed, engineMaxSpeed) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs index 38bf3ebcf074cf975a064b75a3c13fc23b61739c..c99064a4d536e066528492e5c86db6d7fa6b81f8 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs @@ -91,13 +91,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var dt = Constants.SimulationSettings.TargetTimeInterval; Gear = GetGearFromCycle(); - TorqueConverterActive = DataBus.CycleData.LeftSample.TorqueConverterActive; + TorqueConverterActive = DataBus.DrivingCycleInfo.CycleData.LeftSample.TorqueConverterActive; if (TorqueConverter != null && TorqueConverterActive == null) { throw new VectoSimulationException("Driving cycle does not contain information about TorqueConverter!"); } - var inAngularVelocity = DataBus.EngineIdleSpeed; + var inAngularVelocity = DataBus.EngineInfo.EngineIdleSpeed; var inTorque = 0.SI<NewtonMeter>(); IResponse response; @@ -148,9 +148,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Log.Debug("Gearbox Power Request: torque: {0}, angularVelocity: {1}", outTorque, outAngularVelocity); var gear = GetGearFromCycle(); - TorqueConverterActive = DataBus.DriverBehavior == DrivingBehavior.Braking - ? DataBus.CycleData.LeftSample.TorqueConverterActive - : DataBus.CycleData.RightSample.TorqueConverterActive; + TorqueConverterActive = DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Braking + ? DataBus.DrivingCycleInfo.CycleData.LeftSample.TorqueConverterActive + : DataBus.DrivingCycleInfo.CycleData.RightSample.TorqueConverterActive; if (TorqueConverter != null && TorqueConverterActive == null) { throw new VectoSimulationException("Driving cycle does not contain information about TorqueConverter!"); @@ -161,7 +161,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // mk 2016-11-30: added additional check for outAngularVelocity due to failing test: MeasuredSpeed_Gear_AT_PS_Run // mq 2016-12-16: changed check to vehicle halted due to failing test: MeasuredSpeed_Gear_AT_* - var retVal = gear == 0 || DataBus.DriverBehavior == DrivingBehavior.Halted + var retVal = gear == 0 || DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Halted //|| (outAngularVelocity.IsSmallerOrEqual(0, 1) && outTorque.IsSmallerOrEqual(0, 1)) ? RequestDisengaged(absTime, dt, outTorque, outAngularVelocity, dryRun) @@ -173,16 +173,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected virtual uint GetGearFromCycle() { - return DataBus.DriverBehavior == DrivingBehavior.Braking - ? DataBus.CycleData.LeftSample.Gear - : DataBus.CycleData.RightSample.Gear; + return DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Braking + ? DataBus.DrivingCycleInfo.CycleData.LeftSample.Gear + : DataBus.DrivingCycleInfo.CycleData.RightSample.Gear; } protected virtual PerSecond GetEngineSpeedFromCycle() { - return DataBus.DriverBehavior == DrivingBehavior.Braking - ? DataBus.CycleData.LeftSample.EngineSpeed - : DataBus.CycleData.RightSample.EngineSpeed; + return DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Braking + ? DataBus.DrivingCycleInfo.CycleData.LeftSample.EngineSpeed + : DataBus.DrivingCycleInfo.CycleData.RightSample.EngineSpeed; } /// <summary> @@ -230,7 +230,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CurrentState.PowershiftLosses = ComputeShiftLosses(outTorque, outAngularVelocity, Gear); } if (CurrentState.PowershiftLosses != null) { - var averageEngineSpeed = (DataBus.EngineSpeed + outAngularVelocity * ModelData.Gears[Gear].Ratio) / 2; + var averageEngineSpeed = (DataBus.EngineInfo.EngineSpeed + outAngularVelocity * ModelData.Gears[Gear].Ratio) / 2; inTorque += CurrentState.PowershiftLosses / dt / averageEngineSpeed; } if (dryRun) { @@ -350,7 +350,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl : EngineIdleRequest(absTime, dt); } if (TorqueConverter != null) { - if (DataBus.VehicleStopped) { + if (DataBus.VehicleInfo.VehicleStopped) { TorqueConverter.Locked( 0.SI<NewtonMeter>(), disengagedResponse.Engine.EngineSpeed, CurrentState.InTorque, outAngularVelocity); @@ -369,13 +369,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private IResponse EngineIdleRequest(Second absTime, Second dt) { - var disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineIdleSpeed); + var disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), DataBus.EngineInfo.EngineIdleSpeed); if (disengagedResponse is ResponseSuccess) { return disengagedResponse; } - var motoringSpeed = DataBus.EngineSpeed; - if (motoringSpeed.IsGreater(DataBus.EngineIdleSpeed)) { + var motoringSpeed = DataBus.EngineInfo.EngineSpeed; + if (motoringSpeed.IsGreater(DataBus.EngineInfo.EngineIdleSpeed)) { var first = (ResponseDryRun)NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), motoringSpeed, true); try { motoringSpeed = SearchAlgorithm.Search( @@ -387,7 +387,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } catch (VectoException) { Log.Warn("CycleGearbox could not find motoring speed for disengaged state."); } - motoringSpeed = motoringSpeed.LimitTo(DataBus.EngineIdleSpeed, DataBus.EngineSpeed); + motoringSpeed = motoringSpeed.LimitTo(DataBus.EngineInfo.EngineIdleSpeed, DataBus.EngineInfo.EngineSpeed); } disengagedResponse = NextComponent.Request(absTime, dt, 0.SI<NewtonMeter>(), motoringSpeed); return disengagedResponse; @@ -444,7 +444,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return new GearInfo(Gear, !TorqueConverterActive ?? true); } - var future = DataBus.LookAhead(ModelData.TractionInterruption * 5); + var future = DataBus.DrivingCycleInfo.LookAhead(ModelData.TractionInterruption * 5); var nextGear = 0u; var torqueConverterLocked = false; foreach (var entry in future) { @@ -477,7 +477,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return ModelData.TractionInterruption; } - var future = DataBus.LookAhead(ModelData.TractionInterruption * 5); + var future = DataBus.DrivingCycleInfo.LookAhead(ModelData.TractionInterruption * 5); foreach (var entry in future) { if (entry.VehicleTargetSpeed != null && entry.VehicleTargetSpeed.IsEqual(0)) { // vehicle is stopped, no next gear, engine should go to idle @@ -501,9 +501,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override bool GearEngaged(Second absTime) { - return (DataBus.DriverBehavior == DrivingBehavior.Braking - ? DataBus.CycleData.LeftSample.Gear - : DataBus.CycleData.RightSample.Gear) != 0; + return (DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Braking + ? DataBus.DrivingCycleInfo.CycleData.LeftSample.Gear + : DataBus.DrivingCycleInfo.CycleData.RightSample.Gear) != 0; } public override bool DisengageGearbox diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index 0b7e2179ac2f85cda2c2803edbe55e427ce230c6..59bf83c3dfaff933a9aab70adcb6dcf5dac88b2b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -130,10 +130,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { var retVal = DoHandleRequest(absTime, ds, targetVelocity, gradient); if (retVal is ResponseSuccess) { - EcoRollState.PreviousBrakePower = Driver.DataBus.BrakePower; + EcoRollState.PreviousBrakePower = Driver.DataBus.Brakes.BrakePower; if (retVal.Source is ICombustionEngine) { var success = retVal as ResponseSuccess; - var avgEngineSpeed = (success.Engine.EngineSpeed + Driver.DataBus.EngineSpeed) / 2.0; + var avgEngineSpeed = (success.Engine.EngineSpeed + Driver.DataBus.EngineInfo.EngineSpeed) / 2.0; EcoRollState.AcceleratorPedalIdle = success.Engine.DragPower.IsEqual(success.Engine.EngineTorqueDemandTotal * avgEngineSpeed, 10.SI<Watt>()); } else { EcoRollState.AcceleratorPedalIdle = false; @@ -152,8 +152,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var retVal = Driver.DrivingActionHalt( - absTime, dt, VectoMath.Min(Driver.DataBus.MaxVehicleSpeed, targetVelocity), gradient); - EcoRollState.PreviousBrakePower = Driver.DataBus.BrakePower; + absTime, dt, VectoMath.Min(Driver.DataBus.VehicleInfo.MaxVehicleSpeed, targetVelocity), gradient); + EcoRollState.PreviousBrakePower = Driver.DataBus.Brakes.BrakePower; return retVal; } @@ -162,11 +162,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl container.SetDataValue("EcoRollConditionsMet", EcoRollState.AllConditionsMet ? 1 : 0); if (PCCSegments.Count > 0) { var val = 0; - if (Driver.DataBus.Distance > PCCSegments.Current.EndDistance) { + if (Driver.DataBus.MileageCounter.Distance > PCCSegments.Current.EndDistance) { val = 0; - } else if (Driver.DataBus.Distance > PCCSegments.Current.DistanceMinSpeed) { + } else if (Driver.DataBus.MileageCounter.Distance > PCCSegments.Current.DistanceMinSpeed) { val = 5; - } else if (Driver.DataBus.Distance > PCCSegments.Current.StartDistance) { + } else if (Driver.DataBus.MileageCounter.Distance > PCCSegments.Current.StartDistance) { val = -5; } container.SetDataValue("PCCSegment", val); @@ -180,7 +180,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public void CommitSimulationStep() { if (PCCSegments.Count > 0) { - if (Driver.DataBus.Distance > PCCSegments.Current.EndDistance) { + if (Driver.DataBus.MileageCounter.Distance > PCCSegments.Current.EndDistance) { PCCSegments.MoveNext(); PCCState = PCCStates.OutsideSegment; } @@ -203,11 +203,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (EcoRollState.State != EcoRollStates.EcoRollOn && PCCState != PCCStates.UseCase1 && PCCState != PCCStates.UseCase2) { EngineOffTimestamp = null; - Driver.DataBus.CombustionEngineOn = true; + Driver.DataBus.EngineCtl.CombustionEngineOn = true; } if (CurrentDrivingMode == DrivingMode.DrivingModeBrake) { - if (Driver.DataBus.Distance.IsGreaterOrEqual(BrakeTrigger.TriggerDistance, 1e-3.SI<Meter>())) { + if (Driver.DataBus.MileageCounter.Distance.IsGreaterOrEqual(BrakeTrigger.TriggerDistance, 1e-3.SI<Meter>())) { CurrentDrivingMode = DrivingMode.DrivingModeDrive; NextDrivingAction = null; DrivingModes[CurrentDrivingMode].ResetMode(); @@ -215,22 +215,22 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } if (CurrentDrivingMode == DrivingMode.DrivingModeDrive) { - var currentDistance = Driver.DataBus.Distance; + var currentDistance = Driver.DataBus.MileageCounter.Distance; //var coasting = LookAheadCoasting(ds); UpdateDrivingAction(currentDistance, ds); if (NextDrivingAction != null) { var remainingDistance = NextDrivingAction.ActionDistance - currentDistance; - var estimatedTimestep = remainingDistance / Driver.DataBus.VehicleSpeed; + var estimatedTimestep = remainingDistance / Driver.DataBus.VehicleInfo.VehicleSpeed; var atTriggerTistance = remainingDistance.IsEqual( 0.SI<Meter>(), Constants.SimulationSettings.DriverActionDistanceTolerance); var closeBeforeBraking = estimatedTimestep.IsSmaller(Constants.SimulationSettings.LowerBoundTimeInterval); var brakingIntervalTooShort = NextDrivingAction.Action == DrivingBehavior.Braking && - ((NextDrivingAction.TriggerDistance - NextDrivingAction.ActionDistance) / Driver.DataBus.VehicleSpeed) + ((NextDrivingAction.TriggerDistance - NextDrivingAction.ActionDistance) / Driver.DataBus.VehicleInfo.VehicleSpeed) .IsSmaller( - Constants.SimulationSettings.LowerBoundTimeInterval / 20) && !Driver.DataBus.ClutchClosed(absTime); + Constants.SimulationSettings.LowerBoundTimeInterval / 20) && !Driver.DataBus.ClutchInfo.ClutchClosed(absTime); if (atTriggerTistance || closeBeforeBraking || brakingIntervalTooShort) { CurrentDrivingMode = DrivingMode.DrivingModeBrake; DrivingModes[CurrentDrivingMode].ResetMode(); @@ -251,7 +251,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var retVal = DrivingModes[CurrentDrivingMode].Request( - absTime, ds, VectoMath.Min(Driver.DataBus.MaxVehicleSpeed, targetVelocity), gradient); + absTime, ds, VectoMath.Min(Driver.DataBus.VehicleInfo.MaxVehicleSpeed, targetVelocity), gradient); return retVal; } @@ -259,7 +259,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private void HandlePCC(Second absTime, MeterPerSecond targetVelocity) { var dataBus = Driver.DataBus; - var vehicleSpeed = dataBus.VehicleSpeed; + var vehicleSpeed = dataBus.VehicleInfo.VehicleSpeed; UpdatePCCState(targetVelocity); @@ -294,7 +294,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl break; case EcoRollType.WithEngineStop: (dataBus as IGearboxControl).DisengageGearbox = true; - dataBus.CombustionEngineOn = false; + dataBus.EngineCtl.CombustionEngineOn = false; break; default: throw new ArgumentOutOfRangeException(); } @@ -304,7 +304,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl case PCCStates.WithinSegment: case PCCStates.PCCinterrupt: (dataBus as IGearboxControl).DisengageGearbox = false; - dataBus.CombustionEngineOn = true; + dataBus.EngineCtl.CombustionEngineOn = true; break; default: throw new ArgumentOutOfRangeException(); } @@ -313,20 +313,20 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private void UpdatePCCState(MeterPerSecond targetVelocity) { var dataBus = Driver.DataBus; - var distance = dataBus.Distance; + var distance = dataBus.MileageCounter.Distance; var withinPCCSegment = PCCSegments.Current != null && PCCSegments.Current.StartDistance < distance && PCCSegments.Current.EndDistance > distance; - var vehicleSpeed = dataBus.VehicleSpeed; + var vehicleSpeed = dataBus.VehicleInfo.VehicleSpeed; if (withinPCCSegment) { - var currentEnergy = CalculateEnergy(dataBus.Altitude, vehicleSpeed, dataBus.TotalMass); + var currentEnergy = CalculateEnergy(dataBus.DrivingCycleInfo.Altitude, vehicleSpeed, dataBus.VehicleInfo.TotalMass); var endUseCase1 = PCCSegments.Current.EndDistance; var endEnergyUseCase1 = PCCSegments.Current.EnergyEnd; if ((distance + Driver.DriverData.PCC.PreviewDistanceUseCase1).IsSmallerOrEqual(endUseCase1)) { endUseCase1 = distance + Driver.DriverData.PCC.PreviewDistanceUseCase1; - var endCycleEntry = dataBus.CycleLookAhead(Driver.DriverData.PCC.PreviewDistanceUseCase1); - endEnergyUseCase1 = CalculateEnergy(endCycleEntry.Altitude, endCycleEntry.VehicleTargetSpeed, dataBus.TotalMass); + var endCycleEntry = dataBus.DrivingCycleInfo.CycleLookAhead(Driver.DriverData.PCC.PreviewDistanceUseCase1); + endEnergyUseCase1 = CalculateEnergy(endCycleEntry.Altitude, endCycleEntry.VehicleTargetSpeed, dataBus.VehicleInfo.TotalMass); } var coastingForce = CoastingForce(targetVelocity, vehicleSpeed); @@ -344,8 +344,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var endEnergyUseCase2 = PCCSegments.Current.EnergyEnd; if ((distance + Driver.DriverData.PCC.PreviewDistanceUseCase2).IsSmallerOrEqual(endUseCase1)) { endUseCase2 = distance + Driver.DriverData.PCC.PreviewDistanceUseCase2; - var endCycleEntry = dataBus.CycleLookAhead(Driver.DriverData.PCC.PreviewDistanceUseCase2); - endEnergyUseCase2 = CalculateEnergy(endCycleEntry.Altitude, endCycleEntry.VehicleTargetSpeed, dataBus.TotalMass); + var endCycleEntry = dataBus.DrivingCycleInfo.CycleLookAhead(Driver.DriverData.PCC.PreviewDistanceUseCase2); + endEnergyUseCase2 = CalculateEnergy(endCycleEntry.Altitude, endCycleEntry.VehicleTargetSpeed, dataBus.VehicleInfo.TotalMass); } var energyCoastingEndUseCase2 = (coastingForce * (endUseCase2 - distance)).Cast<Joule>(); @@ -377,25 +377,25 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private Newton CoastingForce(MeterPerSecond targetVelocity, MeterPerSecond vehicleSpeed) { var dataBus = Driver.DataBus; - var airDragForce = Driver.DataBus.AirDragResistance(vehicleSpeed, targetVelocity); + var airDragForce = Driver.DataBus.VehicleInfo.AirDragResistance(vehicleSpeed, targetVelocity); //var rollResistanceForce = Driver.DataBus.RollingResistance( // ((targetAltitude - vehicleAltitude) / (actionEntry.Distance - Driver.DataBus.Distance)) // .Value().SI<Radian>()); - var rollResistanceForce = Driver.DataBus.RollingResistance(dataBus.RoadGradient); + var rollResistanceForce = Driver.DataBus.VehicleInfo.RollingResistance(dataBus.DrivingCycleInfo.RoadGradient); var engineDragLoss = 0.SI<Watt>(); - if (dataBus.GearboxType.AutomaticTransmission()) { + if (dataBus.GearboxInfo.GearboxType.AutomaticTransmission()) { if (ADAS.EcoRoll == EcoRollType.None && ATEcoRollReleaseLockupClutch) { - engineDragLoss = Driver.DataBus.EngineDragPower(Driver.DataBus.EngineSpeed); + engineDragLoss = Driver.DataBus.EngineInfo.EngineDragPower(Driver.DataBus.EngineInfo.EngineSpeed); } } else { if (ADAS.EcoRoll == EcoRollType.None) { - engineDragLoss = Driver.DataBus.EngineDragPower(Driver.DataBus.EngineSpeed); + engineDragLoss = Driver.DataBus.EngineInfo.EngineDragPower(Driver.DataBus.EngineInfo.EngineSpeed); } } - var gearboxLoss = Driver.DataBus.GearboxLoss(); - var axleLoss = Driver.DataBus.AxlegearLoss(); + var gearboxLoss = Driver.DataBus.GearboxInfo.GearboxLoss(); + var axleLoss = Driver.DataBus.AxlegearInfo.AxlegearLoss(); var coastingForce = airDragForce + rollResistanceForce + (gearboxLoss + axleLoss - engineDragLoss) / vehicleSpeed; @@ -410,32 +410,32 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private void HandleEcoRoll(Second absTime, MeterPerSecond targetVelocity) { var dBus = Driver.DataBus; - var vehicleSpeedAboveLowerThreshold = dBus.VehicleSpeed >= Driver.DriverData.EcoRoll.MinSpeed; - var slopeNegative = dBus.RoadGradient.IsSmaller(0); + var vehicleSpeedAboveLowerThreshold = dBus.VehicleInfo.VehicleSpeed >= Driver.DriverData.EcoRoll.MinSpeed; + var slopeNegative = dBus.DrivingCycleInfo.RoadGradient.IsSmaller(0); // potential optimization... //if (EcoRollState.State != EcoRollStates.EcoRollOn && !slopeNegative) { // EcoRollState.State = EcoRollStates.EcoRollOff; // return; //} - var forces = dBus.SlopeResistance(dBus.RoadGradient) + dBus.RollingResistance(dBus.RoadGradient) + - dBus.AirDragResistance(dBus.VehicleSpeed, dBus.VehicleSpeed); + var forces = dBus.VehicleInfo.SlopeResistance(dBus.DrivingCycleInfo.RoadGradient) + dBus.VehicleInfo.RollingResistance(dBus.DrivingCycleInfo.RoadGradient) + + dBus.VehicleInfo.AirDragResistance(dBus.VehicleInfo.VehicleSpeed, dBus.VehicleInfo.VehicleSpeed); - if (dBus.GearboxType.AutomaticTransmission() && ATEcoRollReleaseLockupClutch && dBus.VehicleSpeed.IsGreater(0)) { + if (dBus.GearboxInfo.GearboxType.AutomaticTransmission() && ATEcoRollReleaseLockupClutch && dBus.VehicleInfo.VehicleSpeed.IsGreater(0)) { // for AT transmissions consider engine drag losses during eco-roll events - forces -= dBus.EngineDragPower(dBus.EngineSpeed) / dBus.VehicleSpeed; - forces += (dBus.GearboxLoss() + dBus.AxlegearLoss()) / dBus.VehicleSpeed; + forces -= dBus.EngineInfo.EngineDragPower(dBus.EngineInfo.EngineSpeed) / dBus.VehicleInfo.VehicleSpeed; + forces += (dBus.GearboxInfo.GearboxLoss() + dBus.AxlegearInfo.AxlegearLoss()) / dBus.VehicleInfo.VehicleSpeed; } - var accelerationWithinLimits = (-forces / dBus.TotalMass).IsBetween( + var accelerationWithinLimits = (-forces / dBus.VehicleInfo.TotalMass).IsBetween( Driver.DriverData.EcoRoll.AccelerationLowerLimit, Driver.DriverData.EcoRoll.AccelerationUpperLimit); var accelerationPedalIdle = EcoRollState.AcceleratorPedalIdle; var brakeActive = !EcoRollState.PreviousBrakePower.IsEqual(0); - var vehcleSpeedBelowMax = dBus.VehicleSpeed <= - (ApplyOverspeed(dBus.CycleData.LeftSample.VehicleTargetSpeed) - 2.KMPHtoMeterPerSecond()); + var vehcleSpeedBelowMax = dBus.VehicleInfo.VehicleSpeed <= + (ApplyOverspeed(dBus.DrivingCycleInfo.CycleData.LeftSample.VehicleTargetSpeed) - 2.KMPHtoMeterPerSecond()); EcoRollState.AllConditionsMet = vehicleSpeedAboveLowerThreshold && vehcleSpeedBelowMax && slopeNegative && accelerationWithinLimits && accelerationPedalIdle && !brakeActive; - EcoRollState.Gear = dBus.Gear; + EcoRollState.Gear = dBus.GearboxInfo.Gear; switch (EcoRollState.State) { case EcoRollStates.EcoRollOff: if (EcoRollState.AllConditionsMet) { @@ -456,7 +456,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } break; case EcoRollStates.EcoRollOn: - var belowTargetSpeed = dBus.VehicleSpeed.IsSmaller(targetVelocity - Driver.DriverData.EcoRoll.UnderspeedThreshold); + var belowTargetSpeed = dBus.VehicleInfo.VehicleSpeed.IsSmaller(targetVelocity - Driver.DriverData.EcoRoll.UnderspeedThreshold); if (belowTargetSpeed || brakeActive) { EcoRollState.State = EcoRollStates.EcoRollOff; } @@ -468,25 +468,25 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl case EcoRollStates.EcoRollOn: (dBus as IGearboxControl).DisengageGearbox = true; if (ADAS.EcoRoll == EcoRollType.WithEngineStop) { - dBus.CombustionEngineOn = false; + dBus.EngineCtl.CombustionEngineOn = false; } return; case EcoRollStates.EcoRollOff: (dBus as IGearboxControl).DisengageGearbox = false; if (ADAS.EcoRoll == EcoRollType.WithEngineStop) { - dBus.CombustionEngineOn = true; + dBus.EngineCtl.CombustionEngineOn = true; } return; } EngineOffTimestamp = null; - dBus.CombustionEngineOn = true; + dBus.EngineCtl.CombustionEngineOn = true; } private void HandleEngineStopStartDuringVehicleStop(Second absTime) { - if (Driver.DataBus.CycleData.LeftSample.PTOActive) { + if (Driver.DataBus.DrivingCycleInfo.CycleData.LeftSample.PTOActive) { // engine stop start is disabled for stops where the PTO is activated return; } @@ -499,12 +499,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Driver.DriverData.EngineStopStart.EngineOffStandStillActivationDelay)) { if (EngineOffTimestamp == null) { EngineOffTimestamp = absTime; - Driver.DataBus.CombustionEngineOn = false; + Driver.DataBus.EngineCtl.CombustionEngineOn = false; } } if (EngineOffTimestamp != null && (absTime - EngineOffTimestamp).IsGreaterOrEqual(Driver.DriverData.EngineStopStart.MaxEngineOffTimespan)) { - Driver.DataBus.CombustionEngineOn = true; + Driver.DataBus.EngineCtl.CombustionEngineOn = true; } } @@ -547,13 +547,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private void UpdateDistancesForCurrentNextAction() { - if (Driver.DataBus.VehicleSpeed > NextDrivingAction.NextTargetSpeed) { + if (Driver.DataBus.VehicleInfo.VehicleSpeed > NextDrivingAction.NextTargetSpeed) { var brakingDistance = Driver.ComputeDecelerationDistance(NextDrivingAction.NextTargetSpeed) + BrakingSafetyMargin; switch (NextDrivingAction.Action) { case DrivingBehavior.Coasting: //var coastingDistance = ComputeCoastingDistance(Driver.DataBus.VehicleSpeed, NextDrivingAction.NextTargetSpeed); - var coastingDistance = ComputeCoastingDistance(Driver.DataBus.VehicleSpeed, NextDrivingAction.CycleEntry); + var coastingDistance = ComputeCoastingDistance(Driver.DataBus.VehicleInfo.VehicleSpeed, NextDrivingAction.CycleEntry); NextDrivingAction.CoastingStartDistance = NextDrivingAction.TriggerDistance - coastingDistance; NextDrivingAction.BrakingStartDistance = NextDrivingAction.TriggerDistance - brakingDistance; break; @@ -575,20 +575,20 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected internal MeterPerSecond GetOverspeed() { - return ADAS.PredictiveCruiseControl == PredictiveCruiseControlType.Option_1_2_3 && Driver.DataBus.CycleData.LeftSample.Highway + return ADAS.PredictiveCruiseControl == PredictiveCruiseControlType.Option_1_2_3 && Driver.DataBus.DrivingCycleInfo.CycleData.LeftSample.Highway ? Driver.DriverData.PCC.OverspeedUseCase3 : Driver.DriverData.OverSpeed.OverSpeed; } protected internal DrivingBehaviorEntry GetNextDrivingAction(Meter ds) { - var currentSpeed = Driver.DataBus.VehicleSpeed; + var currentSpeed = Driver.DataBus.VehicleInfo.VehicleSpeed; var lookaheadDistance = (currentSpeed.Value() * 3.6 * Driver.DriverData.LookAheadCoasting.LookAheadDistanceFactor).SI<Meter>(); var stopDistance = Driver.ComputeDecelerationDistance(0.SI<MeterPerSecond>()); lookaheadDistance = VectoMath.Max(2 * ds, lookaheadDistance, 1.2 * stopDistance + ds); - var lookaheadData = Driver.DataBus.LookAhead(lookaheadDistance); + var lookaheadData = Driver.DataBus.DrivingCycleInfo.LookAhead(lookaheadDistance); Log.Debug("Lookahead distance: {0} @ current speed {1}", lookaheadDistance, currentSpeed); var nextActions = new List<DrivingBehaviorEntry>(); @@ -662,10 +662,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ? actionEntry.VehicleTargetSpeed + Driver.DriverData.OverSpeed.OverSpeed : actionEntry.VehicleTargetSpeed; - var vehicleMass = Driver.DataBus.TotalMass + Driver.DataBus.ReducedMassWheels; + var vehicleMass = Driver.DataBus.VehicleInfo.TotalMass + Driver.DataBus.WheelsInfo.ReducedMassWheels; var targetAltitude = actionEntry.Altitude; //dec.Altitude; - var vehicleAltitude = Driver.DataBus.Altitude; + var vehicleAltitude = Driver.DataBus.DrivingCycleInfo.Altitude; var targetEnergy = vehicleMass * Physics.GravityAccelleration * targetAltitude + vehicleMass * targetSpeed * targetSpeed / 2; @@ -674,13 +674,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var energyDifference = vehicleEnergy - targetEnergy; - var airDragForce = Driver.DataBus.AirDragResistance(vehicleSpeed, targetSpeed); - var rollResistanceForce = Driver.DataBus.RollingResistance( - ((targetAltitude - vehicleAltitude) / (actionEntry.Distance - Driver.DataBus.Distance)) + var airDragForce = Driver.DataBus.VehicleInfo.AirDragResistance(vehicleSpeed, targetSpeed); + var rollResistanceForce = Driver.DataBus.VehicleInfo.RollingResistance( + ((targetAltitude - vehicleAltitude) / (actionEntry.Distance - Driver.DataBus.MileageCounter.Distance)) .Value().SI<Radian>()); - var engineDragLoss = Driver.DataBus.EngineDragPower(Driver.DataBus.EngineSpeed); - var gearboxLoss = Driver.DataBus.GearboxLoss(); - var axleLoss = Driver.DataBus.AxlegearLoss(); + var engineDragLoss = Driver.DataBus.EngineInfo.EngineDragPower(Driver.DataBus.EngineInfo.EngineSpeed); + var gearboxLoss = Driver.DataBus.GearboxInfo.GearboxLoss(); + var axleLoss = Driver.DataBus.AxlegearInfo.AxlegearLoss(); var coastingResistanceForce = airDragForce + rollResistanceForce + (gearboxLoss + axleLoss - engineDragLoss) / vehicleSpeed; @@ -701,7 +701,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return Driver.DriverData.OverSpeed.Enabled && velocity > Driver.DriverData.OverSpeed.MinSpeed && ApplyOverspeed(velocity) < - (Driver.DataBus.MaxVehicleSpeed ?? 500.KMPHtoMeterPerSecond()); + (Driver.DataBus.VehicleInfo.MaxVehicleSpeed ?? 500.KMPHtoMeterPerSecond()); } } @@ -777,7 +777,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // if the speed at the end of the simulation interval is below the next target speed // we are fine (no need to brake right now) - var v2 = Driver.DataBus.VehicleSpeed + response.Driver.Acceleration * response.SimulationInterval; + var v2 = Driver.DataBus.VehicleInfo.VehicleSpeed + response.Driver.Acceleration * response.SimulationInterval; if (v2 <= DriverStrategy.NextDrivingAction.NextTargetSpeed) { return response; } @@ -797,12 +797,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var newOperatingPoint = VectoMath.ComputeTimeInterval( - DataBus.VehicleSpeed, response.Driver.Acceleration, DataBus.Distance, + DataBus.VehicleInfo.VehicleSpeed, response.Driver.Acceleration, DataBus.MileageCounter.Distance, newds); if (newOperatingPoint.SimulationInterval.IsSmaller(Constants.SimulationSettings.LowerBoundTimeInterval)) { // the next time interval will be too short, this may lead to issues with inertia etc. // instead of accelerating, drive at constant speed. - response = DoHandleRequest(absTime, ds, Driver.DataBus.VehicleSpeed, gradient, true); + response = DoHandleRequest(absTime, ds, Driver.DataBus.VehicleInfo.VehicleSpeed, gradient, true); return response; } @@ -841,7 +841,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl velocityWithOverspeed = DriverStrategy.ApplyOverspeed(velocityWithOverspeed); } - if (DataBus.GearboxType.AutomaticTransmission() || DataBus.ClutchClosed(absTime)) { + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() || DataBus.ClutchInfo.ClutchClosed(absTime)) { for (var i = 0; i < 3; i++) { var retVal = HandleRequestEngaged( absTime, ds, targetVelocity, gradient, prohibitOverspeed, velocityWithOverspeed, debug); @@ -854,7 +854,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var response = HandleRequestDisengaged(absTime, ds, gradient, velocityWithOverspeed, debug); - if (!(response is ResponseSuccess) && DataBus.ClutchClosed(absTime)) { + if (!(response is ResponseSuccess) && DataBus.ClutchInfo.ClutchClosed(absTime)) { response = HandleRequestEngaged( absTime, ds, targetVelocity, gradient, prohibitOverspeed, velocityWithOverspeed, debug); } @@ -866,11 +866,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Second absTime, Meter ds, Radian gradient, MeterPerSecond velocity, DebugData debug) { - if (DataBus.VehicleSpeed.IsSmallerOrEqual(0.SI<MeterPerSecond>())) { + if (DataBus.VehicleInfo.VehicleSpeed.IsSmallerOrEqual(0.SI<MeterPerSecond>())) { // the clutch is disengaged, and the vehicle stopped - we can't perform a roll action. wait for the clutch to be engaged // todo mk 2016-08-23: is this still needed? var remainingShiftTime = Constants.SimulationSettings.TargetTimeInterval; - while (!DataBus.ClutchClosed(absTime + remainingShiftTime)) { + while (!DataBus.ClutchInfo.ClutchClosed(absTime + remainingShiftTime)) { remainingShiftTime += Constants.SimulationSettings.TargetTimeInterval; } @@ -906,10 +906,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl first.Switch() .Case<ResponseUnderload>( r => { - if (DataBus.GearboxType.AutomaticTransmission() && !DataBus.ClutchClosed(absTime)) { + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && !DataBus.ClutchInfo.ClutchClosed(absTime)) { second = Driver.DrivingActionRoll(absTime, ds, velocityWithOverspeed, gradient); } - if (DataBus.VehicleSpeed.IsGreater(0) && DriverStrategy.OverspeedAllowed(targetVelocity, prohibitOverspeed)) { + if (DataBus.VehicleInfo.VehicleSpeed.IsGreater(0) && DriverStrategy.OverspeedAllowed(targetVelocity, prohibitOverspeed)) { second = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); debug.Add(new { action = "first:(Underload & Overspeed)-> Coast", second }); second = HandleCoastAfterUnderloadWithOverspeed(absTime, ds, gradient, velocityWithOverspeed, debug, second); @@ -949,7 +949,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }); }).Case<ResponseOverload>( r => { - if (DataBus.VehicleSpeed.IsGreater(0)) { + if (DataBus.VehicleInfo.VehicleSpeed.IsGreater(0)) { third = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); debug.Add(new { action = "second:Overload -> Coast", third }); } @@ -992,7 +992,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl IResponse first; if (DriverStrategy.OverspeedAllowed(targetVelocity, prohibitOverspeed) && - DataBus.VehicleSpeed.IsEqual(targetVelocity)) { + DataBus.VehicleInfo.VehicleSpeed.IsEqual(targetVelocity)) { first = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); debug.Add(new { action = "Coast", first }); if (first is ResponseSuccess && first.Driver.Acceleration < 0) { @@ -1000,7 +1000,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl debug.Add(new { action = "Coast:(Success & Acc<0) -> Accelerate", first }); } } else { - if (DataBus.GearboxType.AutomaticTransmission() && (DataBus as IGearboxInfo).DisengageGearbox) { + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && (DataBus as IGearboxInfo).DisengageGearbox) { first = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); } else { first = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient); @@ -1020,7 +1020,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return response; } - var v2 = Driver.DataBus.VehicleSpeed + response.Driver.Acceleration * response.SimulationInterval; + var v2 = Driver.DataBus.VehicleInfo.VehicleSpeed + response.Driver.Acceleration * response.SimulationInterval; var newBrakingDistance = Driver.DriverData.AccelerationCurve.ComputeDecelerationDistance(v2, nextAction.NextTargetSpeed) + DefaultDriverStrategy.BrakingSafetyMargin; switch (DriverStrategy.NextDrivingAction.Action) { @@ -1035,21 +1035,21 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // if the distance at the end of the simulation interval is smaller than the new ActionDistance // we are safe - go ahead... - if ((Driver.DataBus.Distance + ds).IsSmallerOrEqual( + if ((Driver.DataBus.MileageCounter.Distance + ds).IsSmallerOrEqual( nextAction.TriggerDistance - newActionDistance, Constants.SimulationSettings.DriverActionDistanceTolerance * safetyFactor) && - (Driver.DataBus.Distance + ds).IsSmallerOrEqual(nextAction.TriggerDistance - newBrakingDistance)) { + (Driver.DataBus.MileageCounter.Distance + ds).IsSmallerOrEqual(nextAction.TriggerDistance - newBrakingDistance)) { return response; } newds = ds / 2; //EstimateAccelerationDistanceBeforeBrake(response, nextAction) ?? ds; break; case DrivingBehavior.Braking: - if ((Driver.DataBus.Distance + ds).IsSmaller(nextAction.TriggerDistance - newBrakingDistance)) { + if ((Driver.DataBus.MileageCounter.Distance + ds).IsSmaller(nextAction.TriggerDistance - newBrakingDistance)) { return response; } - newds = nextAction.TriggerDistance - newBrakingDistance - Driver.DataBus.Distance - + newds = nextAction.TriggerDistance - newBrakingDistance - Driver.DataBus.MileageCounter.Distance - Constants.SimulationSettings.DriverActionDistanceTolerance / 2; break; default: return response; @@ -1078,7 +1078,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Second absTime, Meter ds, MeterPerSecond targetVelocity, Radian gradient, bool prohibitOverspeed = false) { - if (DataBus.VehicleSpeed <= DriverStrategy.BrakeTrigger.NextTargetSpeed && !DataBus.VehicleStopped) { + if (DataBus.VehicleInfo.VehicleSpeed <= DriverStrategy.BrakeTrigger.NextTargetSpeed && !DataBus.VehicleInfo.VehicleStopped) { var retVal = HandleTargetspeedReached(absTime, ds, targetVelocity, gradient); for (var i = 0; i < 3 && retVal == null; i++) { retVal = HandleTargetspeedReached(absTime, ds, targetVelocity, gradient); @@ -1091,7 +1091,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return retVal; } - var currentDistance = DataBus.Distance; + var currentDistance = DataBus.MileageCounter.Distance; var brakingDistance = Driver.ComputeDecelerationDistance(DriverStrategy.BrakeTrigger.NextTargetSpeed) + DefaultDriverStrategy.BrakingSafetyMargin; @@ -1136,7 +1136,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl "Expected Braking Deceleration could not be reached! {0}", DriverStrategy.BrakeTrigger.BrakingStartDistance - currentDistance); } - var targetDistance = DataBus.VehicleSpeed < Constants.SimulationSettings.MinVelocityForCoast + var targetDistance = DataBus.VehicleInfo.VehicleSpeed < Constants.SimulationSettings.MinVelocityForCoast ? DriverStrategy.BrakeTrigger.TriggerDistance : null; if (targetDistance == null && DriverStrategy.BrakeTrigger.NextTargetSpeed.IsEqual(0.SI<MeterPerSecond>())) { @@ -1144,7 +1144,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } Driver.DriverBehavior = DrivingBehavior.Braking; - if (DataBus.VehicleSpeed.IsEqual(0) && DriverStrategy.BrakeTrigger.NextTargetSpeed.IsEqual(0)) { + if (DataBus.VehicleInfo.VehicleSpeed.IsEqual(0) && DriverStrategy.BrakeTrigger.NextTargetSpeed.IsEqual(0)) { if (ds.IsEqual(targetDistance - currentDistance)) { return new ResponseDrivingCycleDistanceExceeded(this) { MaxDistance = ds / 2 @@ -1162,9 +1162,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl gradient, targetDistance: targetDistance); } - if (DataBus.GearboxType.AutomaticTransmission() && response == null) { + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && response == null) { for (var i = 0; i < 3 && response == null; i++) { - DataBus.BrakePower = 0.SI<Watt>(); + DataBus.Brakes.BrakePower = 0.SI<Watt>(); response = Driver.DrivingActionBrake( absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient, targetDistance: targetDistance); @@ -1180,7 +1180,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Log.Info( "Brake -> Got OverloadResponse during brake action - desired deceleration could not be reached! response: {0}", r); - if (!DataBus.ClutchClosed(absTime)) { + if (!DataBus.ClutchInfo.ClutchClosed(absTime)) { Log.Info("Brake -> Overload -> Clutch is open - Trying roll action"); response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); response.Switch().Case<ResponseSpeedLimitExceeded>( @@ -1188,14 +1188,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ); } else { Log.Info("Brake -> Overload -> Clutch is closed - Trying brake action again"); - DataBus.BrakePower = 0.SI<Watt>(); + DataBus.Brakes.BrakePower = 0.SI<Watt>(); response = Driver.DrivingActionBrake( absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient, targetDistance: targetDistance); response.Switch().Case<ResponseOverload>( r1 => { Log.Info("Brake -> Overload -> 2nd Brake -> Overload -> Trying accelerate action"); - var gear = DataBus.Gear; + var gear = DataBus.GearboxInfo.Gear; response = Driver.DrivingActionAccelerate( absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); response.Switch().Case<ResponseGearShift>( @@ -1206,7 +1206,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }) .Case<ResponseUnderload>( rs => { - if (gear != DataBus.Gear) { + if (gear != DataBus.GearboxInfo.Gear) { // AT Gearbox switched gears, shift losses are no longer applied, try once more... response = Driver.DrivingActionAccelerate(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); } @@ -1218,7 +1218,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Log.Info("Brake -> Got GearShift response, performing roll action + brakes"); //response = Driver.DrivingActionRoll(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); - DataBus.BrakePower = 0.SI<Watt>(); + DataBus.Brakes.BrakePower = 0.SI<Watt>(); response = Driver.DrivingActionBrake( absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient, targetDistance: targetDistance); @@ -1237,9 +1237,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { IResponse response; Driver.DriverBehavior = DrivingBehavior.Coasting; - response = DataBus.ClutchClosed(absTime) - ? Driver.DrivingActionCoast(absTime, ds, VectoMath.Max(targetVelocity, DataBus.VehicleSpeed), gradient) - : Driver.DrivingActionRoll(absTime, ds, VectoMath.Max(targetVelocity, DataBus.VehicleSpeed), gradient); + response = DataBus.ClutchInfo.ClutchClosed(absTime) + ? Driver.DrivingActionCoast(absTime, ds, VectoMath.Max(targetVelocity, DataBus.VehicleInfo.VehicleSpeed), gradient) + : Driver.DrivingActionRoll(absTime, ds, VectoMath.Max(targetVelocity, DataBus.VehicleInfo.VehicleSpeed), gradient); response.Switch().Case<ResponseUnderload>( r => { // coast would decelerate more than driver's max deceleration => issue brakes to decelerate with driver's max deceleration @@ -1253,7 +1253,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }).Case<ResponseOverload>( r => { // limiting deceleration while coast may result in an overload => issue brakes to decelerate with driver's max deceleration - response = DataBus.ClutchClosed(absTime) + response = DataBus.ClutchInfo.ClutchClosed(absTime) ? Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient) : Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); @@ -1279,13 +1279,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl .Case<ResponseSpeedLimitExceeded>( () => { response = Driver.DrivingActionBrake( - absTime, ds, DataBus.VehicleSpeed, + absTime, ds, DataBus.VehicleInfo.VehicleSpeed, gradient); - if (response is ResponseOverload && !DataBus.ClutchClosed(absTime)) { - response = Driver.DrivingActionRoll(absTime, ds, DataBus.VehicleSpeed, gradient); + if (response is ResponseOverload && !DataBus.ClutchInfo.ClutchClosed(absTime)) { + response = Driver.DrivingActionRoll(absTime, ds, DataBus.VehicleInfo.VehicleSpeed, gradient); } if (response is ResponseGearShift) { - response = Driver.DrivingActionBrake(absTime, ds, DataBus.VehicleSpeed, + response = Driver.DrivingActionBrake(absTime, ds, DataBus.VehicleInfo.VehicleSpeed, gradient); } }); @@ -1308,7 +1308,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Log.Debug("start braking @ {0}", DriverStrategy.BrakeTrigger.BrakingStartDistance); var remainingDistanceToBrake = DriverStrategy.BrakeTrigger.BrakingStartDistance - currentDistance; - var estimatedTimeInterval = remainingDistanceToBrake / DataBus.VehicleSpeed; + var estimatedTimeInterval = remainingDistanceToBrake / DataBus.VehicleInfo.VehicleSpeed; if (estimatedTimeInterval.IsSmaller(Constants.SimulationSettings.LowerBoundTimeInterval) || currentDistance + Constants.SimulationSettings.DriverActionDistanceTolerance > DriverStrategy.BrakeTrigger.BrakingStartDistance) { @@ -1322,11 +1322,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } - if (DataBus.VehicleSpeed < Constants.SimulationSettings.MinVelocityForCoast) { + if (DataBus.VehicleInfo.VehicleSpeed < Constants.SimulationSettings.MinVelocityForCoast) { Phase = BrakingPhase.Brake; Log.Debug( "Switching to BRAKE Phase. currentDistance: {0} v: {1}", currentDistance, - DataBus.VehicleSpeed); + DataBus.VehicleInfo.VehicleSpeed); } return null; } @@ -1349,33 +1349,33 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }).Case<ResponseSpeedLimitExceeded>( () => { response = Driver.DrivingActionBrake( - absTime, ds, DataBus.VehicleSpeed, + absTime, ds, DataBus.VehicleInfo.VehicleSpeed, gradient); }); }).Case<ResponseSpeedLimitExceeded>( () => { response = Driver.DrivingActionBrake( - absTime, ds, DataBus.VehicleSpeed, + absTime, ds, DataBus.VehicleInfo.VehicleSpeed, gradient); }).Case<ResponseUnderload>( r => { //response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, // gradient, r); response = Driver.DrivingActionBrake( - absTime, ds, DataBus.VehicleSpeed + r.Driver.Acceleration * r.SimulationInterval, + absTime, ds, DataBus.VehicleInfo.VehicleSpeed + r.Driver.Acceleration * r.SimulationInterval, gradient, r); if (response != null) { response.Switch().Case<ResponseGearShift>( () => { - DataBus.BrakePower = 0.SI<Watt>(); + DataBus.Brakes.BrakePower = 0.SI<Watt>(); response = Driver.DrivingActionBrake( absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient, r); }).Case<ResponseOverload>( () => { - DataBus.BrakePower = 0.SI<Watt>(); - if (DataBus.GearboxType.AutomaticTransmission() || DataBus.ClutchClosed(absTime)) { - if (DataBus.VehicleSpeed.IsGreater(0)) { + DataBus.Brakes.BrakePower = 0.SI<Watt>(); + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() || DataBus.ClutchInfo.ClutchClosed(absTime)) { + if (DataBus.VehicleInfo.VehicleSpeed.IsGreater(0)) { response = Driver.DrivingActionAccelerate( absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); } else { @@ -1402,8 +1402,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Radian gradient) { IResponse response; - if (DataBus.GearboxType.AutomaticTransmission() || DataBus.ClutchClosed(absTime)) { - if (DataBus.VehicleSpeed.IsGreater(0)) { + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() || DataBus.ClutchInfo.ClutchClosed(absTime)) { + if (DataBus.VehicleInfo.VehicleSpeed.IsGreater(0)) { response = Driver.DrivingActionAccelerate(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); } else { if (RetryDistanceExceeded) { @@ -1431,15 +1431,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl switch (nextAction.Action) { case DrivingBehavior.Coasting: - var v2 = Driver.DataBus.VehicleSpeed + response.Driver.Acceleration * response.SimulationInterval; + var v2 = Driver.DataBus.VehicleInfo.VehicleSpeed + response.Driver.Acceleration * response.SimulationInterval; var newBrakingDistance = Driver.DriverData.AccelerationCurve.ComputeDecelerationDistance( v2, nextAction.NextTargetSpeed); - if ((Driver.DataBus.Distance + ds).IsSmaller(nextAction.TriggerDistance - newBrakingDistance)) { + if ((Driver.DataBus.MileageCounter.Distance + ds).IsSmaller(nextAction.TriggerDistance - newBrakingDistance)) { return response; } - newds = nextAction.TriggerDistance - newBrakingDistance - Driver.DataBus.Distance - + newds = nextAction.TriggerDistance - newBrakingDistance - Driver.DataBus.MileageCounter.Distance - Constants.SimulationSettings.DriverActionDistanceTolerance / 2; break; default: return response; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs index f5e7db55b25ff1681bc9432f2efdf9356691506a..2817448d0c2ec857a1f8e3666be5136956b3774e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs @@ -95,8 +95,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IResponse Initialize() { if (Left.VehicleTargetSpeed.IsEqual(0)) { - var retVal = NextComponent.Initialize(DataBus.StartSpeed, - Left.RoadGradient, DataBus.StartAcceleration); + var retVal = NextComponent.Initialize(DataBus.GearboxInfo.StartSpeed, + Left.RoadGradient, DataBus.GearboxInfo.StartAcceleration); if (!(retVal is ResponseSuccess)) { throw new UnexpectedResponseException("DistanceBasedDrivingCycle.Initialize: Couldn't find start gear.", retVal); } @@ -129,12 +129,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var nextSpeedChange = GetSpeedChangeWithinSimulationInterval(ds); if (nextSpeedChange == null || ds.IsSmallerOrEqual(nextSpeedChange - PreviousState.Distance)) { - if (nextSpeedChange == null || DataBus.VehicleSpeed.IsEqual(0.SI<MeterPerSecond>())) { + if (nextSpeedChange == null || DataBus.VehicleInfo.VehicleSpeed.IsEqual(0.SI<MeterPerSecond>())) { CurrentState.Response = DriveDistance(absTime, ds); return CurrentState.Response; } var remainingDistance = nextSpeedChange - PreviousState.Distance - ds; - var estimatedRemainingTime = remainingDistance / DataBus.VehicleSpeed; + var estimatedRemainingTime = remainingDistance / DataBus.VehicleInfo.VehicleSpeed; if (_intervalProlonged || remainingDistance.IsEqual(0.SI<Meter>()) || estimatedRemainingTime.IsGreater(Constants.SimulationSettings.LowerBoundTimeInterval)) { CurrentState.Response = DriveDistance(absTime, ds); @@ -453,7 +453,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Second time) { - return LookAhead(LookaheadTimeSafetyMargin * DataBus.VehicleSpeed * time); + return LookAhead(LookaheadTimeSafetyMargin * DataBus.VehicleInfo.VehicleSpeed * time); } public SpeedChangeEntry LastTargetspeedChange { get; private set; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs index 2f9a8c3c1a8701744f30a7954f73bef63106cb06..307d8453059c23522c3575edb3e3b5543d4ff620 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -100,7 +100,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Log.Debug("==== DRIVER Request (distance) ===="); Log.Debug( "Request: absTime: {0}, ds: {1}, targetVelocity: {2}, gradient: {3} | distance: {4}, velocity: {5}, vehicle stopped: {6}", - absTime, ds, targetVelocity, gradient, DataBus.Distance, DataBus.VehicleSpeed, DataBus.VehicleStopped); + absTime, ds, targetVelocity, gradient, DataBus.MileageCounter.Distance, DataBus.VehicleInfo.VehicleSpeed, DataBus.VehicleInfo.VehicleStopped); var retVal = DriverStrategy.Request(absTime, ds, targetVelocity, gradient); @@ -118,8 +118,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Log.Debug("==== DRIVER Request (time) ===="); Log.Debug( "Request: absTime: {0}, dt: {1}, targetVelocity: {2}, gradient: {3} | distance: {4}, velocity: {5} gear: {6}: vehicle stopped: {7}", - absTime, dt, targetVelocity, gradient, DataBus.Distance, DataBus.VehicleSpeed, DataBus.Gear, - DataBus.VehicleStopped); + absTime, dt, targetVelocity, gradient, DataBus.MileageCounter.Distance, DataBus.VehicleInfo.VehicleSpeed, DataBus.GearboxInfo.Gear, + DataBus.VehicleInfo.VehicleStopped); var retVal = DriverStrategy.Request(absTime, dt, targetVelocity, gradient); @@ -173,7 +173,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Case<ResponseFailTimeInterval>(r => { // occurs only with AT gearboxes - extend time interval after gearshift! retVal = new ResponseDrivingCycleDistanceExceeded(this) { - MaxDistance = r.Driver.Acceleration / 2 * r.DeltaT * r.DeltaT + DataBus.VehicleSpeed * r.DeltaT + MaxDistance = r.Driver.Acceleration / 2 * r.DeltaT * r.DeltaT + DataBus.VehicleInfo.VehicleSpeed * r.DeltaT }; }). Case<ResponseGearShift>(r => { @@ -196,10 +196,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl response); } - if (nextOperatingPoint == null && absTime > 0 && DataBus.VehicleStopped) { + if (nextOperatingPoint == null && absTime > 0 && DataBus.VehicleInfo.VehicleStopped) { Log.Info( "No operating point found! Vehicle stopped! trying HALT action"); - DataBus.BrakePower = 1.SI<Watt>(); + DataBus.Brakes.BrakePower = 1.SI<Watt>(); retVal = DrivingActionHalt(absTime, operatingPoint.SimulationInterval, 0.SI<MeterPerSecond>(), gradient); retVal.SimulationDistance = 0.SI<Meter>(); @@ -214,7 +214,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var limitedOperatingPoint = nextOperatingPoint; - if (!(retVal is ResponseEngineSpeedTooHigh || DataBus.ClutchClosed(absTime))) { + if (!(retVal is ResponseEngineSpeedTooHigh || DataBus.ClutchInfo.ClutchClosed(absTime))) { limitedOperatingPoint = LimitAccelerationByDriverModel(nextOperatingPoint, LimitationMode.LimitDecelerationDriver); Log.Debug("Found operating point for Drive/Accelerate. dt: {0}, acceleration: {1}", @@ -236,7 +236,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Case<ResponseOverload>(() => { // deceleration is limited by driver model, operating point moves above full load (e.g., steep uphill) // the vehicle/driver can't achieve an acceleration higher than deceleration curve, try again with higher deceleration - if (DataBus.GearboxType.AutomaticTransmission()) { + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission()) { Log.Info("AT Gearbox - Operating point resulted in an overload, searching again..."); // search again for operating point, transmission may have shifted inbetween nextOperatingPoint = SearchOperatingPoint(absTime, ds, gradient, operatingPoint.Acceleration, @@ -251,15 +251,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl rt => { // occurs only with AT gearboxes - extend time interval after gearshift! retVal = new ResponseDrivingCycleDistanceExceeded(this) { - MaxDistance = DriverAcceleration / 2 * rt.DeltaT * rt.DeltaT + DataBus.VehicleSpeed * rt.DeltaT + MaxDistance = DriverAcceleration / 2 * rt.DeltaT * rt.DeltaT + DataBus.VehicleInfo.VehicleSpeed * rt.DeltaT }; }); } else { - if (absTime > 0 && DataBus.VehicleStopped) { + if (absTime > 0 && DataBus.VehicleInfo.VehicleStopped) { Log.Info( "Operating point with limited acceleration resulted in an overload! Vehicle stopped! trying HALT action {0}", nextOperatingPoint.Acceleration); - DataBus.BrakePower = 1.SI<Watt>(); + DataBus.Brakes.BrakePower = 1.SI<Watt>(); retVal = DrivingActionHalt(absTime, nextOperatingPoint.SimulationInterval, 0.SI<MeterPerSecond>(), gradient); ds = 0.SI<Meter>(); //retVal.Acceleration = 0.SI<MeterPerSquareSecond>(); @@ -299,14 +299,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl rt => { // occurs only with AT gearboxes - extend time interval after gearshift! retVal = new ResponseDrivingCycleDistanceExceeded(this) { - MaxDistance = DriverAcceleration / 2 * rt.DeltaT * rt.DeltaT + DataBus.VehicleSpeed * rt.DeltaT + MaxDistance = DriverAcceleration / 2 * rt.DeltaT * rt.DeltaT + DataBus.VehicleInfo.VehicleSpeed * rt.DeltaT }; }); }). Case<ResponseFailTimeInterval>(r => { // occurs only with AT gearboxes - extend time interval after gearshift! retVal = new ResponseDrivingCycleDistanceExceeded(this) { - MaxDistance = r.Driver.Acceleration / 2 * r.DeltaT * r.DeltaT + DataBus.VehicleSpeed * r.DeltaT + MaxDistance = r.Driver.Acceleration / 2 * r.DeltaT * r.DeltaT + DataBus.VehicleInfo.VehicleSpeed * r.DeltaT }; }). Default( @@ -318,7 +318,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Case<ResponseFailTimeInterval>(r => { // occurs only with AT gearboxes - extend time interval after gearshift! retVal = new ResponseDrivingCycleDistanceExceeded(this) { - MaxDistance = r.Driver.Acceleration / 2 * r.DeltaT * r.DeltaT + DataBus.VehicleSpeed * r.DeltaT + MaxDistance = r.Driver.Acceleration / 2 * r.DeltaT * r.DeltaT + DataBus.VehicleInfo.VehicleSpeed * r.DeltaT }; }). Case<ResponseSuccess>(() => operatingPoint = limitedOperatingPoint). @@ -354,11 +354,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl IterationStatistics.Increment(this, "Coast"); Log.Debug("DrivingAction Coast"); - var gear = DataBus.Gear; - var tcLocked = DataBus.TCLocked; + var gear = DataBus.GearboxInfo.Gear; + var tcLocked = DataBus.GearboxInfo.TCLocked; var retVal = CoastOrRollAction(absTime, ds, maxVelocity, gradient, false); - var gearChanged = !(DataBus.Gear == gear && DataBus.TCLocked == tcLocked); - if (DataBus.GearboxType.AutomaticTransmission() && gearChanged && (retVal is ResponseOverload || retVal is ResponseUnderload)) { + var gearChanged = !(DataBus.GearboxInfo.Gear == gear && DataBus.GearboxInfo.TCLocked == tcLocked); + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && gearChanged && (retVal is ResponseOverload || retVal is ResponseUnderload)) { Log.Debug("Gear changed after a valid operating point was found - re-try coasting!"); retVal = CoastOrRollAction(absTime, ds, maxVelocity, gradient, false); } @@ -411,7 +411,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected IResponse CoastOrRollAction(Second absTime, Meter ds, MeterPerSecond maxVelocity, Radian gradient, bool rollAction) { - var requestedOperatingPoint = ComputeAcceleration(ds, DataBus.VehicleSpeed); + var requestedOperatingPoint = ComputeAcceleration(ds, DataBus.VehicleInfo.VehicleSpeed); DriverAcceleration = requestedOperatingPoint.Acceleration; var initialResponse = NextComponent.Request(absTime, requestedOperatingPoint.SimulationInterval, requestedOperatingPoint.Acceleration, gradient, dryRun: true); @@ -430,7 +430,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl requestedOperatingPoint.Acceleration, initialResponse, coastingOrRoll: true); } - if (searchedOperatingPoint == null && DataBus.GearboxType.AutomaticTransmission()) { + if (searchedOperatingPoint == null && DataBus.GearboxInfo.GearboxType.AutomaticTransmission()) { // we end up here if no valid operating point for the engine and torque converter can be found. // a likely reason is that the torque converter opereating point 'jumps' between two different operating points // or that no valid operating point can be found by reverse calcualtion. This method is a kind of fal-back @@ -463,7 +463,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl rollAction ? LimitationMode.NoLimitation : LimitationMode.LimitDecelerationDriver); // compute speed at the end of the simulation interval. if it exceeds the limit -> return - var v2 = DataBus.VehicleSpeed + + var v2 = DataBus.VehicleInfo.VehicleSpeed + limitedOperatingPoint.Acceleration * limitedOperatingPoint.SimulationInterval; if (v2 > maxVelocity && limitedOperatingPoint.Acceleration.IsGreaterOrEqual(0)) { Log.Debug("vehicle's velocity would exceed given max speed. v2: {0}, max speed: {1}", v2, maxVelocity); @@ -488,7 +488,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Case<ResponseGearShift>(). Case<ResponseFailTimeInterval>(r => { response = new ResponseDrivingCycleDistanceExceeded(this) { - MaxDistance = r.Driver.Acceleration / 2 * r.DeltaT * r.DeltaT + DataBus.VehicleSpeed * r.DeltaT + MaxDistance = r.Driver.Acceleration / 2 * r.DeltaT * r.DeltaT + DataBus.VehicleInfo.VehicleSpeed * r.DeltaT }; }). Default( @@ -506,7 +506,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // Fallback solution for calculating operating point with TC in semi-forward way. private OperatingPoint SetTCOperatingPointATGbxCoastOrRoll(Second absTime, Radian gradient, OperatingPoint operatingPoint, ResponseDryRun dryRunResp) { - var tc = DataBus.TorqueConverter; + var tc = DataBus.TorqueConverterCtl; if (tc == null) { throw new VectoException("NO TorqueConverter Available!"); } @@ -520,7 +520,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // calculate TC opPt using n_in and n_out, estimate ICE max and drag torque. // if ICE torque is within valid range, search an acceleration that results in the required // out-torque at the torque converter - var engineSpeed = DataBus.EngineIdleSpeed * 1.01; + var engineSpeed = DataBus.EngineInfo.EngineIdleSpeed * 1.01; var tcOp = EstimateTCOpPoint(operatingPoint, dryRunResp, engineSpeed, tc); if (tcOp.Item1.Item2.IsBetween(tcOp.Item2, tcOp.Item3)) { @@ -537,7 +537,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } // try again without changing the engine speed to 'spare' inertia torque - engineSpeed = DataBus.EngineSpeed; + engineSpeed = DataBus.EngineInfo.EngineSpeed; tcOp = EstimateTCOpPoint(operatingPoint, dryRunResp, engineSpeed, tc); if (tcOp.Item1.Item2.IsBetween(tcOp.Item2, tcOp.Item3)) { @@ -574,7 +574,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // if no engine speed can be found that results in an operating point on the TC curve, set the TC in-torque to the maximum // available from the engine. reverse-calc TC-in-torque from average engine torque - var tcInPwrPrev = (DataBus.EngineSpeed + tcOp.Item1.Item1.InAngularVelocity) * tcOp.Item1.Item2 - + var tcInPwrPrev = (DataBus.EngineInfo.EngineSpeed + tcOp.Item1.Item1.InAngularVelocity) * tcOp.Item1.Item2 - (tcOp.Item1.Item1.InAngularVelocity * tcOp.Item1.Item1.InTorque); tcOp.Item1.Item1.InTorque = (2 * tcOp.Item3 * tcOp.Item1.Item1.InAngularVelocity - tcInPwrPrev) / tcOp.Item1.Item1.InAngularVelocity; @@ -605,15 +605,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private Tuple<Tuple<TorqueConverterOperatingPoint, NewtonMeter>, NewtonMeter, NewtonMeter> EstimateTCOpPoint( OperatingPoint operatingPoint, IResponse response, PerSecond engSpeed, ITorqueConverterControl tc) { - var avgICDSpeed = (DataBus.EngineSpeed + engSpeed) / 2.0; - var drTq = (DataBus.EngineDragPower(avgICDSpeed)) / avgICDSpeed; - var maxTq = DataBus.EngineDynamicFullLoadPower(avgICDSpeed, operatingPoint.SimulationInterval) / + var avgICDSpeed = (DataBus.EngineInfo.EngineSpeed + engSpeed) / 2.0; + var drTq = (DataBus.EngineInfo.EngineDragPower(avgICDSpeed)) / avgICDSpeed; + var maxTq = DataBus.EngineInfo.EngineDynamicFullLoadPower(avgICDSpeed, operatingPoint.SimulationInterval) / avgICDSpeed; var inTq = Formulas.InertiaPower( - engSpeed, DataBus.EngineSpeed, + engSpeed, DataBus.EngineInfo.EngineSpeed, (DataBus as VehicleContainer)?.RunData.EngineData.Inertia ?? 0.SI<KilogramSquareMeter>(), operatingPoint.SimulationInterval) / avgICDSpeed; - var auxTq = DataBus.EngineAuxDemand(avgICDSpeed, operatingPoint.SimulationInterval) / avgICDSpeed; + var auxTq = DataBus.EngineInfo.EngineAuxDemand(avgICDSpeed, operatingPoint.SimulationInterval) / avgICDSpeed; return Tuple.Create( tc.CalculateOperatingPoint(engSpeed, response.Gearbox.GearboxInputSpeed), drTq - inTq - auxTq, maxTq - inTq - auxTq); @@ -637,7 +637,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (tmp.SimulationInterval.IsEqual(0.SI<Second>(), 1e-9.SI<Second>())) { throw new VectoSearchAbortedException( "next TimeInterval is 0. a: {0}, v: {1}, dt: {2}", acc, - DataBus.VehicleSpeed, tmp.SimulationInterval); + DataBus.VehicleInfo.VehicleSpeed, tmp.SimulationInterval); } DriverAcceleration = acc; @@ -656,8 +656,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private NewtonMeter GetTCDelta(Tuple<TorqueConverterOperatingPoint, NewtonMeter> tqOp, NewtonMeter dragTorque, NewtonMeter maxTorque) { - var deltaSpeed = VectoMath.Min(0.RPMtoRad(), tqOp.Item1.InAngularVelocity - DataBus.EngineIdleSpeed) + - VectoMath.Max(0.RPMtoRad(), tqOp.Item1.InAngularVelocity - DataBus.EngineRatedSpeed); + var deltaSpeed = VectoMath.Min(0.RPMtoRad(), tqOp.Item1.InAngularVelocity - DataBus.EngineInfo.EngineIdleSpeed) + + VectoMath.Max(0.RPMtoRad(), tqOp.Item1.InAngularVelocity - DataBus.EngineInfo.EngineRatedSpeed); var tqDiff = 0.SI<NewtonMeter>(); if (tqOp.Item2.IsSmaller(dragTorque)) { tqDiff = tqOp.Item2 - dragTorque; @@ -709,7 +709,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Case<ResponseGearShift>(). // will be handled in SearchBrakingPower Case<ResponseFailTimeInterval>(r => retVal = new ResponseDrivingCycleDistanceExceeded(this) { - MaxDistance = DataBus.VehicleSpeed * r.DeltaT + point.Acceleration / 2 * r.DeltaT * r.DeltaT + MaxDistance = DataBus.VehicleInfo.VehicleSpeed * r.DeltaT + point.Acceleration / 2 * r.DeltaT * r.DeltaT }). Default(r => { throw new UnexpectedResponseException("DrivingAction Brake: first request.", r); @@ -733,7 +733,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl operatingPoint.Acceleration, response); } catch (VectoSearchAbortedException vsa) { Log.Warn("Search braking power aborted {0}", vsa); - if (DataBus.GearboxType.AutomaticTransmission()) { + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission()) { operatingPoint = SetTCOperatingPointATGbxBraking(absTime, gradient, operatingPoint, response); } } @@ -748,23 +748,23 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Log.Debug("Found operating point for braking. dt: {0}, acceleration: {1} brakingPower: {2}", operatingPoint.SimulationInterval, - operatingPoint.Acceleration, DataBus.BrakePower); - if (DataBus.BrakePower < 0) { + operatingPoint.Acceleration, DataBus.Brakes.BrakePower); + if (DataBus.Brakes.BrakePower < 0) { var overload = new ResponseOverload(this) { - Brakes = { BrakePower = DataBus.BrakePower, }, + Brakes = { BrakePower = DataBus.Brakes.BrakePower, }, Driver = { Acceleration = operatingPoint.Acceleration } }; - DataBus.BrakePower = 0.SI<Watt>(); + DataBus.Brakes.BrakePower = 0.SI<Watt>(); return overload; } DriverAcceleration = operatingPoint.Acceleration; - var gear = DataBus.Gear; - var tcLocked = DataBus.TCLocked; + var gear = DataBus.GearboxInfo.Gear; + var tcLocked = DataBus.GearboxInfo.TCLocked; retVal = NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient); - var gearChanged = !(DataBus.Gear == gear && DataBus.TCLocked == tcLocked); - if (DataBus.GearboxType.AutomaticTransmission() && gearChanged && (retVal is ResponseOverload || retVal is ResponseUnderload)) { + var gearChanged = !(DataBus.GearboxInfo.Gear == gear && DataBus.GearboxInfo.TCLocked == tcLocked); + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && gearChanged && (retVal is ResponseOverload || retVal is ResponseUnderload)) { Log.Debug("Gear changed after a valid operating point was found - braking is no longer applicable due to overload"); return null; } @@ -774,10 +774,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Case<ResponseFailTimeInterval>(r => retVal = new ResponseDrivingCycleDistanceExceeded(this) { MaxDistance = - DataBus.VehicleSpeed * r.DeltaT + operatingPoint.Acceleration / 2 * r.DeltaT * r.DeltaT + DataBus.VehicleInfo.VehicleSpeed * r.DeltaT + operatingPoint.Acceleration / 2 * r.DeltaT * r.DeltaT }). Case<ResponseUnderload>(r => { - if (DataBus.GearboxType.AutomaticTransmission()) { + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission()) { operatingPoint = SearchBrakingPower(absTime, operatingPoint.SimulationDistance, gradient, operatingPoint.Acceleration, response); DriverAcceleration = operatingPoint.Acceleration; @@ -786,11 +786,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } }). Case<ResponseOverload>(r => { - if (DataBus.GearboxType.AutomaticTransmission()) { + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission()) { // overload may happen because of gearshift between search and actual request, search again var i = 5; while (i-- > 0 && !(retVal is ResponseSuccess)) { - DataBus.BrakePower = 0.SI<Watt>(); + DataBus.Brakes.BrakePower = 0.SI<Watt>(); retVal = NextComponent.Request( absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, @@ -802,8 +802,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl operatingPoint = SearchBrakingPower(absTime, operatingPoint.SimulationDistance, gradient, operatingPoint.Acceleration, retVal); DriverAcceleration = operatingPoint.Acceleration; - if (DataBus.BrakePower.IsSmaller(0)) { - DataBus.BrakePower = 0.SI<Watt>(); + if (DataBus.Brakes.BrakePower.IsSmaller(0)) { + DataBus.Brakes.BrakePower = 0.SI<Watt>(); operatingPoint = SearchOperatingPoint(absTime, ds, gradient, 0.SI<MeterPerSquareSecond>(), r); } @@ -829,7 +829,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl retVal.SimulationDistance = ds; retVal.Driver.OperatingPoint = operatingPoint; - if (DataBus.GearboxType.AutomaticTransmission() && engaged != (DataBus as IGearboxInfo).DisengageGearbox) { + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && engaged != (DataBus as IGearboxInfo).DisengageGearbox) { (DataBus as IGearboxControl).DisengageGearbox = engaged; } return retVal; @@ -838,21 +838,21 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private OperatingPoint SetTCOperatingPointATGbxBraking( Second absTime, Radian gradient, OperatingPoint operatingPoint, IResponse response) { - var tc = DataBus.TorqueConverter; + var tc = DataBus.TorqueConverterCtl; if (tc == null) { throw new VectoException("NO TorqueConverter Available!"); } - var avgEngineSpeed = (DataBus.EngineSpeed + DataBus.EngineIdleSpeed) / 2.0; - var dragTorque = (DataBus.EngineDragPower(avgEngineSpeed)) / avgEngineSpeed; - var maxTorque = DataBus.EngineDynamicFullLoadPower(avgEngineSpeed, operatingPoint.SimulationInterval) / avgEngineSpeed; + var avgEngineSpeed = (DataBus.EngineInfo.EngineSpeed + DataBus.EngineInfo.EngineIdleSpeed) / 2.0; + var dragTorque = (DataBus.EngineInfo.EngineDragPower(avgEngineSpeed)) / avgEngineSpeed; + var maxTorque = DataBus.EngineInfo.EngineDynamicFullLoadPower(avgEngineSpeed, operatingPoint.SimulationInterval) / avgEngineSpeed; var inertiaTq = Formulas.InertiaPower( - DataBus.EngineIdleSpeed, DataBus.EngineSpeed, + DataBus.EngineInfo.EngineIdleSpeed, DataBus.EngineInfo.EngineSpeed, (DataBus as VehicleContainer)?.RunData.EngineData.Inertia ?? 0.SI<KilogramSquareMeter>(), operatingPoint.SimulationInterval) / avgEngineSpeed; - var auxTqDemand = DataBus.EngineAuxDemand(avgEngineSpeed, operatingPoint.SimulationInterval) / avgEngineSpeed; + var auxTqDemand = DataBus.EngineInfo.EngineAuxDemand(avgEngineSpeed, operatingPoint.SimulationInterval) / avgEngineSpeed; //var maxTorque = DataBus.e - var tcOp = tc.CalculateOperatingPoint(DataBus.EngineIdleSpeed * 1.01, response.Gearbox.GearboxInputSpeed); + var tcOp = tc.CalculateOperatingPoint(DataBus.EngineInfo.EngineIdleSpeed * 1.01, response.Gearbox.GearboxInputSpeed); if (!tcOp.Item2.IsBetween(dragTorque - inertiaTq - auxTqDemand, maxTorque - inertiaTq - auxTqDemand)) { @@ -869,14 +869,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private OperatingPoint AdaptDecelerationToTargetDistance(Meter ds, MeterPerSecond nextTargetSpeed, Meter targetDistance, MeterPerSquareSecond acceleration) { - if (targetDistance != null && targetDistance > DataBus.Distance) { - var tmp = ComputeAcceleration(targetDistance - DataBus.Distance, nextTargetSpeed, false); + if (targetDistance != null && targetDistance > DataBus.MileageCounter.Distance) { + var tmp = ComputeAcceleration(targetDistance - DataBus.MileageCounter.Distance, nextTargetSpeed, false); if (tmp.Acceleration.IsGreater(acceleration)) { var operatingPoint = ComputeTimeInterval(tmp.Acceleration, ds); if (!ds.IsEqual(operatingPoint.SimulationDistance)) { Log.Error( "Unexpected Condition: Distance has been adjusted from {0} to {1}, currentVelocity: {2} acceleration: {3}, targetVelocity: {4}", - operatingPoint.SimulationDistance, ds, DataBus.VehicleSpeed, operatingPoint.Acceleration, + operatingPoint.SimulationDistance, ds, DataBus.VehicleInfo.VehicleSpeed, operatingPoint.Acceleration, nextTargetSpeed); throw new VectoSimulationException("Simulation distance unexpectedly adjusted! {0} -> {1}", ds, operatingPoint.SimulationDistance); @@ -892,8 +892,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // if we should brake with the max. deceleration and the deceleration changes within the current interval, take the larger deceleration... if ( operatingPoint.Acceleration.IsEqual( - DriverData.AccelerationCurve.Lookup(DataBus.VehicleSpeed).Deceleration)) { - var v2 = DataBus.VehicleSpeed + operatingPoint.Acceleration * operatingPoint.SimulationInterval; + DriverData.AccelerationCurve.Lookup(DataBus.VehicleInfo.VehicleSpeed).Deceleration)) { + var v2 = DataBus.VehicleInfo.VehicleSpeed + operatingPoint.Acceleration * operatingPoint.SimulationInterval; var nextAcceleration = DriverData.AccelerationCurve.Lookup(v2).Deceleration; var tmp = ComputeTimeInterval(VectoMath.Min(operatingPoint.Acceleration, nextAcceleration), operatingPoint.SimulationDistance); @@ -927,7 +927,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // operatingPoint.Acceleration = DriverData.LookAheadCoasting.Deceleration; // limitApplied = true; //} - var accelerationLimits = DriverData.AccelerationCurve.Lookup(DataBus.VehicleSpeed); + var accelerationLimits = DriverData.AccelerationCurve.Lookup(DataBus.VehicleInfo.VehicleSpeed); if (operatingPoint.Acceleration > accelerationLimits.Acceleration) { operatingPoint.Acceleration = accelerationLimits.Acceleration; limitApplied = true; @@ -978,21 +978,21 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl deltaPower = nextResp.Gearbox.PowerRequest; }). Case<ResponseUnderload>(r => - deltaPower = DataBus.ClutchClosed(absTime) ? r.Delta : r.Gearbox.PowerRequest). + deltaPower = DataBus.ClutchInfo.ClutchClosed(absTime) ? r.Delta : r.Gearbox.PowerRequest). Default( r => { throw new UnexpectedResponseException("cannot use response for searching braking power!", r); }); try { - DataBus.BrakePower = SearchAlgorithm.Search(DataBus.BrakePower, deltaPower, - deltaPower.Abs() * (DataBus.GearboxType.AutomaticTransmission() ? 0.5 : 1), + DataBus.Brakes.BrakePower = SearchAlgorithm.Search(DataBus.Brakes.BrakePower, deltaPower, + deltaPower.Abs() * (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() ? 0.5 : 1), getYValue: result => { var response = (ResponseDryRun)result; - return DataBus.ClutchClosed(absTime) ? response.DeltaDragLoad : response.Gearbox.PowerRequest; + return DataBus.ClutchInfo.ClutchClosed(absTime) ? response.DeltaDragLoad : response.Gearbox.PowerRequest; }, evaluateFunction: x => { - DataBus.BrakePower = x; + DataBus.Brakes.BrakePower = x; operatingPoint = ComputeTimeInterval(operatingPoint.Acceleration, ds); IterationStatistics.Increment(this, "SearchBrakingPower"); @@ -1003,7 +1003,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }, criterion: result => { var response = (ResponseDryRun)result; - var delta = DataBus.ClutchClosed(absTime) + var delta = DataBus.ClutchInfo.ClutchClosed(absTime) ? response.DeltaDragLoad : response.Gearbox.PowerRequest; return delta.Value(); @@ -1017,9 +1017,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return false; } - return DataBus.GearboxType.AutomaticTransmission() && response.DeltaDragLoad.Value().IsSmallerOrEqual(-double.MaxValue / 20); + return DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && response.DeltaDragLoad.Value().IsSmallerOrEqual(-double.MaxValue / 20); }, - forceLineSearch: DataBus.GearboxType.AutomaticTransmission() && !DataBus.TCLocked); + forceLineSearch: DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && !DataBus.GearboxInfo.TCLocked); return operatingPoint; } catch (Exception) { @@ -1035,7 +1035,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var retVal = new OperatingPoint { Acceleration = acceleration, SimulationDistance = ds }; - var actionRoll = !DataBus.ClutchClosed(absTime); + var actionRoll = !DataBus.ClutchInfo.ClutchClosed(absTime); var origDelta = GetOrigDelta(initialResponse, coastingOrRoll, actionRoll); @@ -1057,13 +1057,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl acc => { // calculate new time interval only when vehiclespeed and acceleration are != 0 // else: use same timeinterval as before. - var vehicleDrivesAndAccelerates = !(acc.IsEqual(0) && DataBus.VehicleSpeed.IsEqual(0)); + var vehicleDrivesAndAccelerates = !(acc.IsEqual(0) && DataBus.VehicleInfo.VehicleSpeed.IsEqual(0)); if (vehicleDrivesAndAccelerates) { var tmp = ComputeTimeInterval(acc, ds); if (tmp.SimulationInterval.IsEqual(0.SI<Second>(), 1e-9.SI<Second>())) { throw new VectoSearchAbortedException( "next TimeInterval is 0. a: {0}, v: {1}, dt: {2}", acc, - DataBus.VehicleSpeed, tmp.SimulationInterval); + DataBus.VehicleInfo.VehicleSpeed, tmp.SimulationInterval); } retVal.Acceleration = tmp.Acceleration; retVal.SimulationInterval = tmp.SimulationInterval; @@ -1094,7 +1094,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl abortCriterion: (response, cnt) => { var r = (ResponseDryRun)response; - if (DataBus.GearboxType.AutomaticTransmission() && + if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && r.DeltaDragLoad.Value().IsSmallerOrEqual(-double.MaxValue / 20)) { nanCount++; } @@ -1156,7 +1156,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public OperatingPoint ComputeAcceleration(Meter ds, MeterPerSecond targetVelocity, bool limitByDriverModel = true) { - var currentSpeed = DataBus.VehicleSpeed; + var currentSpeed = DataBus.VehicleInfo.VehicleSpeed; var retVal = new OperatingPoint() { SimulationDistance = ds }; // Δx = (v0+v1)/2 * Δt @@ -1203,7 +1203,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <returns></returns> public Meter ComputeDecelerationDistance(MeterPerSecond targetSpeed) { - return DriverData.AccelerationCurve.ComputeDecelerationDistance(DataBus.VehicleSpeed, targetSpeed); + return DriverData.AccelerationCurve.ComputeDecelerationDistance(DataBus.VehicleInfo.VehicleSpeed, targetSpeed); } /// <summary> @@ -1216,7 +1216,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <returns>Operating point (a, ds, dt)</returns> private OperatingPoint ComputeTimeInterval(MeterPerSquareSecond acceleration, Meter ds) { - return VectoMath.ComputeTimeInterval(DataBus.VehicleSpeed, acceleration, DataBus.Distance, ds); + return VectoMath.ComputeTimeInterval(DataBus.VehicleInfo.VehicleSpeed, acceleration, DataBus.MileageCounter.Distance, ds); } /// <summary> @@ -1230,14 +1230,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IResponse DrivingActionHalt(Second absTime, Second dt, MeterPerSecond targetVelocity, Radian gradient) { DrivingAction = DrivingAction.Halt; - if (!targetVelocity.IsEqual(0) || !DataBus.VehicleStopped) { + if (!targetVelocity.IsEqual(0) || !DataBus.VehicleInfo.VehicleStopped) { Log.Error("TargetVelocity ({0}) and VehicleVelocity ({1}) must be zero when vehicle is halting!", targetVelocity, - DataBus.VehicleSpeed); + DataBus.VehicleInfo.VehicleSpeed); throw new VectoSimulationException( "TargetVelocity ({0}) and VehicleVelocity ({1}) must be zero when vehicle is halting!", targetVelocity, - DataBus.VehicleSpeed); + DataBus.VehicleInfo.VehicleSpeed); } DriverAcceleration = 0.SI<MeterPerSquareSecond>(); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricAuxiliary.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricAuxiliary.cs index 8d25516c3d824267be8a72421db2abd716e43489..26d86e811feb6e228b0493c1b524ed64f1f24abf 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricAuxiliary.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricAuxiliary.cs @@ -45,7 +45,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl internal void AddConstant(string auxId, Watt powerDemand, Watt powerdemandStandstill) { - Add(auxId, () => DataBus.VehicleStopped && DataBus.StopTime.IsGreater(Constants.SimulationSettings.ThresholdStandstillOff) && DataBus.TargetSpeed.IsEqual(0) ? powerdemandStandstill : powerDemand); + Add(auxId, () => DataBus.VehicleInfo.VehicleStopped && DataBus.DrivingCycleInfo.StopTime.IsGreater(Constants.SimulationSettings.ThresholdStandstillOff) && DataBus.DrivingCycleInfo.TargetSpeed.IsEqual(0) ? powerdemandStandstill : powerDemand); } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs index c0fd928a9b51dceff7783001eb506cbc20f01d77..f5a1fb298dfe18047c8355c263e64e3604848451 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs @@ -45,7 +45,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } }; } - if (!DataBus.CombustionEngineOn) + if (!DataBus.EngineCtl.CombustionEngineOn) { PreviousState.InTorque = 0.SI<NewtonMeter>(); PreviousState.InAngularVelocity = outAngularVelocity; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs index 0a160dfd956329150fccafd44720862e232b2b35..0018488f83805ef3e9c0e20fb929fac98826bce2 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineAuxiliary.cs @@ -79,12 +79,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <param name="auxId"></param> public void AddCycle(string auxId) { - Add(auxId, _ => DataBus.CycleData.LeftSample.AdditionalAuxPowerDemand); + Add(auxId, _ => DataBus.DrivingCycleInfo.CycleData.LeftSample.AdditionalAuxPowerDemand); } public void AddCycle(string auxId, Func<DrivingCycleData.DrivingCycleEntry, Watt> powerLossFunc) { - Add(auxId, _ => powerLossFunc(DataBus.CycleData.LeftSample)); + Add(auxId, _ => powerLossFunc(DataBus.DrivingCycleInfo.CycleData.LeftSample)); } /// <summary> @@ -94,7 +94,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <param name="data"></param> public void AddMapping(string auxId, AuxiliaryData data) { - if (!DataBus.CycleData.LeftSample.AuxiliarySupplyPower.ContainsKey(auxId)) { + if (!DataBus.DrivingCycleInfo.CycleData.LeftSample.AuxiliarySupplyPower.ContainsKey(auxId)) { var error = string.Format("driving cycle does not contain column for auxiliary: {0}", Constants.Auxiliaries.Prefix + auxId); Log.Error(error); @@ -102,7 +102,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } Add(auxId, speed => { - var powerSupply = DataBus.CycleData.LeftSample.AuxiliarySupplyPower[auxId]; + var powerSupply = DataBus.DrivingCycleInfo.CycleData.LeftSample.AuxiliarySupplyPower[auxId]; var nAuxiliary = speed * data.TransmissionRatio; var powerAuxOut = powerSupply / data.EfficiencyToSupply; var powerAuxIn = data.GetPowerDemand(nAuxiliary, powerAuxOut); @@ -167,13 +167,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var engineOffDemand = 0.SI<Watt>(); foreach (var item in Auxiliaries) { - var value = item.Value(DataBus.EngineIdleSpeed) ; + var value = item.Value(DataBus.EngineInfo.EngineIdleSpeed) ; if (value == null) { continue; } powerDemands[item.Key] = value * (1-EngineStopStartUtilityFactor); - if (DataBus.VehicleStopped) { + if (DataBus.VehicleInfo.VehicleStopped) { engineOffDemand += auxiliarieIgnoredDuringVehicleStop.Contains(item.Key) ? 0.SI<Watt>() : value * EngineStopStartUtilityFactor; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineOnlyCombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineOnlyCombustionEngine.cs index 01e307740a9263d012a93063df097c0687edc7d6..3cd8fd3b8a124a6c7ef740f553dc824ceab9c75b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineOnlyCombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineOnlyCombustionEngine.cs @@ -67,7 +67,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CurrentState.EngineTorque = totalTorqueDemand; CurrentState.FullDragTorque = ModelData.FullLoadCurves[0].DragLoadStationaryTorque(avgEngineSpeed); - var stationaryFullLoadTorque = ModelData.FullLoadCurves[DataBus.Gear].FullLoadStationaryTorque(avgEngineSpeed); + var stationaryFullLoadTorque = ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear].FullLoadStationaryTorque(avgEngineSpeed); var dynamicFullLoadPower = ComputeFullLoadPower(avgEngineSpeed, stationaryFullLoadTorque, dt, dryRun); CurrentState.StationaryFullLoadTorque = stationaryFullLoadTorque; CurrentState.DynamicFullLoadTorque = dynamicFullLoadPower / avgEngineSpeed; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineSpeedDriveOffPreprocessor.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineSpeedDriveOffPreprocessor.cs index 9cb93de83cd97e31b20df729d09bfe4efeed8ed2..18599681ac007ff5e232cfc26996fff18442c4b5 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineSpeedDriveOffPreprocessor.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/EngineSpeedDriveOffPreprocessor.cs @@ -22,13 +22,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public void RunPreprocessing() { - var vehicle = Container.Vehicle as Vehicle; + var vehicle = Container.VehicleInfo as Vehicle; if (vehicle == null) { throw new VectoException("no vehicle found..."); } - var gearbox = Container.Gearbox as Gearbox; + var gearbox = Container.GearboxInfo as Gearbox; if (gearbox == null) { throw new VectoException("no gearbox found..."); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index 2a771fa945f9aa0ae291a37f936167694d281b98..18484ddcd831a4dc4c722c22d79b47aad0f3e5c8 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -155,7 +155,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // Case<ResponseUnderload>(). // Default(r => { throw new UnexpectedResponseException("Gearbox.Initialize", r); }); - var fullLoad = DataBus.EngineStationaryFullPower(inAngularVelocity); + var fullLoad = DataBus.EngineInfo.EngineStationaryFullPower(inAngularVelocity); Gear = oldGear; return new ResponseDryRun(this) { @@ -193,13 +193,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl _strategy?.Request(absTime, dt, outTorque, outAngularVelocity); Log.Debug("Gearbox Power Request: torque: {0}, angularVelocity: {1}", outTorque, outAngularVelocity); - if (DataBus.VehicleStopped) { + if (DataBus.VehicleInfo.VehicleStopped) { EngageTime = absTime; LastDownshift = -double.MaxValue.SI<Second>(); LastUpshift = -double.MaxValue.SI<Second>(); } - if (DataBus.DriverBehavior == DrivingBehavior.Halted) { + if (DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Halted) { EngageTime = absTime + dt; } @@ -239,14 +239,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl : 0.SI<NewtonMeter>(); inTorque += inertiaTorqueLossOut / ModelData.Gears[gear].Ratio; - var halted = DataBus.DrivingAction == DrivingAction.Halt; - var driverDeceleratingNegTorque = DataBus.DriverBehavior == DrivingBehavior.Braking && - DataBus.DrivingAction == DrivingAction.Brake && - (DataBus.RoadGradient.IsSmaller(0) || - inAngularVelocity.IsSmaller(DataBus.EngineIdleSpeed)) && - (DataBus.BrakePower.IsGreater(0) || inTorque.IsSmaller(0)); + var halted = DataBus.DriverInfo.DrivingAction == DrivingAction.Halt; + var driverDeceleratingNegTorque = DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Braking && + DataBus.DriverInfo.DrivingAction == DrivingAction.Brake && + (DataBus.DrivingCycleInfo.RoadGradient.IsSmaller(0) || + inAngularVelocity.IsSmaller(DataBus.EngineInfo.EngineIdleSpeed)) && + (DataBus.Brakes.BrakePower.IsGreater(0) || inTorque.IsSmaller(0)); var vehiclespeedBelowThreshold = - DataBus.VehicleSpeed.IsSmaller(Constants.SimulationSettings.ClutchDisengageWhenHaltingSpeed); + DataBus.VehicleInfo.VehicleSpeed.IsSmaller(Constants.SimulationSettings.ClutchDisengageWhenHaltingSpeed); if (halted || (driverDeceleratingNegTorque && vehiclespeedBelowThreshold)) { EngageTime = VectoMath.Max(EngageTime, absTime + dt); @@ -369,7 +369,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var response = NextComponent.Request(absTime, dt, inTorque, inAngularVelocity); - var shiftAllowed = !inAngularVelocity.IsEqual(0) && !DataBus.VehicleSpeed.IsEqual(0); + var shiftAllowed = !inAngularVelocity.IsEqual(0) && !DataBus.VehicleInfo.VehicleSpeed.IsEqual(0); if (response is ResponseSuccess && shiftAllowed) { var shiftRequired = _strategy?.ShiftRequired(absTime, dt, outTorque, outAngularVelocity, inTorque, @@ -433,11 +433,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { Disengaged = false; var lastGear = Gear; - Gear = DataBus.VehicleStopped + Gear = DataBus.VehicleInfo.VehicleStopped ? _strategy.InitGear(absTime, dt, outTorque, outAngularVelocity) : _strategy.Engage(absTime, dt, outTorque, VectoMath.Min(PreviousState.OutAngularVelocity, outAngularVelocity)); - if (!DataBus.VehicleStopped) { + if (!DataBus.VehicleInfo.VehicleStopped) { if (Gear > lastGear) { LastUpshift = absTime; } @@ -455,7 +455,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var avgOutAngularSpeed = (PreviousState.OutAngularVelocity + CurrentState.OutAngularVelocity) / 2.0; var inPower = CurrentState.InTorque * avgInAngularSpeed; var outPower = CurrentState.OutTorque * avgOutAngularSpeed; - container[ModalResultField.Gear] = Disengaged || DataBus.VehicleStopped ? 0 : Gear; + container[ModalResultField.Gear] = Disengaged || DataBus.VehicleInfo.VehicleStopped ? 0 : Gear; container[ModalResultField.P_gbx_loss] = inPower - outPower; container[ModalResultField.P_gbx_inertia] = CurrentState.InertiaTorqueLossOut * avgOutAngularSpeed; container[ModalResultField.P_gbx_in] = inPower; @@ -482,7 +482,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } - if (DataBus.VehicleStopped) { + if (DataBus.VehicleInfo.VehicleStopped) { Disengaged = true; EngageTime = -double.MaxValue.SI<Second>(); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs index 97502be9bc0fba6f424faa8c5ad4c48a265468c3..9937237ef219c5eda7e9fc6be586f26fd2bb1033 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/HybridController.cs @@ -208,7 +208,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override uint InitGear(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) { - if (DataBus.VehicleSpeed.IsEqual(0)) { + if (DataBus.VehicleInfo.VehicleSpeed.IsEqual(0)) { return InitStartGear(outTorque, outAngularVelocity); } @@ -224,8 +224,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (!IsBelowDownShiftCurve(gear, inTorque, inAngularSpeed) && !IsAboveUpShiftCurve(gear, inTorque, inAngularSpeed) && reserve >= ModelData.StartTorqueReserve) { - if ((inAngularSpeed - DataBus.EngineIdleSpeed) / - (DataBus.EngineRatedSpeed - DataBus.EngineIdleSpeed) < + if ((inAngularSpeed - DataBus.EngineInfo.EngineIdleSpeed) / + (DataBus.EngineInfo.EngineRatedSpeed - DataBus.EngineInfo.EngineIdleSpeed) < Constants.SimulationSettings.ClutchClosingSpeedNorm && gear > 1) { gear--; } @@ -251,7 +251,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl for (var gear = MaxStartGear; gear > 1; gear--) { var inAngularSpeed = outAngularVelocity * ModelData.Gears[gear].Ratio; - var ratedSpeed = DataBus.EngineRatedSpeed; + var ratedSpeed = DataBus.EngineInfo.EngineRatedSpeed; if (inAngularSpeed > ratedSpeed || inAngularSpeed.IsEqual(0)) { continue; } @@ -262,7 +262,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl response.Engine.DynamicFullLoadPower; //EnginePowerRequest - response.DeltaFullLoad; var reserve = 1 - response.Engine.PowerRequest / fullLoadPower; - if (response.Engine.EngineSpeed > DataBus.EngineIdleSpeed && + if (response.Engine.EngineSpeed > DataBus.EngineInfo.EngineIdleSpeed && reserve >= ModelData.StartTorqueReserve) { _nextGear = gear; return gear; @@ -276,7 +276,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private bool SpeedTooLowForEngine(uint gear, PerSecond outAngularSpeed) { - return (outAngularSpeed * ModelData.Gears[gear].Ratio).IsSmaller(DataBus.EngineIdleSpeed); + return (outAngularSpeed * ModelData.Gears[gear].Ratio).IsSmaller(DataBus.EngineInfo.EngineIdleSpeed); } private bool SpeedTooHighForEngine(uint gear, PerSecond outAngularSpeed) @@ -284,7 +284,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return (outAngularSpeed * ModelData.Gears[gear].Ratio).IsGreaterOrEqual(VectoMath.Min( ModelData.Gears[gear].MaxSpeed, - DataBus.EngineN95hSpeed)); + DataBus.EngineInfo.EngineN95hSpeed)); } public override uint Engage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity) diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MaxGradabilityPreprocessor.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MaxGradabilityPreprocessor.cs index 116bfd5728a573784c27dd8bd04b0b7ab947ae08..ed40c84ee4968a2f8354acb69ca48da97b59fcf6 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MaxGradabilityPreprocessor.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MaxGradabilityPreprocessor.cs @@ -33,12 +33,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { private Dictionary<uint, Tuple<Radian, Radian>> SearchMaxRoadGradient() { - var vehicle = Container?.Vehicle as Vehicle; + var vehicle = Container?.VehicleInfo as Vehicle; if (vehicle == null) { throw new VectoException("no vehicle found..."); } - var gearbox = Container.Gearbox as Gearbox; + var gearbox = Container.GearboxInfo as Gearbox; if (gearbox == null) { throw new VectoException("no gearbox found..."); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs index 5203de343ae70b8448c16b04ee743fec7ed62dfb..a7d6aa09ec544376c2ef84d8e2acaa96d3814b3b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MeasuredSpeedDrivingCycle.cs @@ -150,10 +150,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (targetSpeed.IsEqual(0.KMPHtoMeterPerSecond(), 0.5.KMPHtoMeterPerSecond())) { targetSpeed = 0.KMPHtoMeterPerSecond(); } - var deltaV = targetSpeed - DataBus.VehicleSpeed; + var deltaV = targetSpeed - DataBus.VehicleInfo.VehicleSpeed; var deltaT = CycleIterator.RightSample.Time - absTime; - if (DataBus.VehicleSpeed.IsSmaller(0)) { + if (DataBus.VehicleInfo.VehicleSpeed.IsSmaller(0)) { throw new VectoSimulationException("vehicle velocity is smaller than zero"); } @@ -167,7 +167,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl DriverBehavior = acceleration < 0 ? DriverBehavior = DrivingBehavior.Braking : DriverBehavior = DrivingBehavior.Driving; - if (DataBus.VehicleStopped && acceleration.IsEqual(0)) { + if (DataBus.VehicleInfo.VehicleStopped && acceleration.IsEqual(0)) { DriverBehavior = DrivingBehavior.Halted; } @@ -211,7 +211,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl response.Driver.Acceleration = acceleration; debug.Add(response); - CurrentState.SimulationDistance = acceleration / 2 * dt * dt + DataBus.VehicleSpeed * dt; + CurrentState.SimulationDistance = acceleration / 2 * dt * dt + DataBus.VehicleInfo.VehicleSpeed * dt; if (CurrentState.SimulationDistance.IsSmaller(0)) { throw new VectoSimulationException( "MeasuredSpeed: Simulation Distance must not be negative. Driving Backward is not allowed."); @@ -227,26 +227,26 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Radian gradient, ref MeterPerSquareSecond acceleration) { MeterPerSquareSecond acc = acceleration; - DataBus.BrakePower = SearchAlgorithm.Search(DataBus.BrakePower, r.Delta, -r.Delta, - getYValue: result => DataBus.ClutchClosed(absTime) + DataBus.Brakes.BrakePower = SearchAlgorithm.Search(DataBus.Brakes.BrakePower, r.Delta, -r.Delta, + getYValue: result => DataBus.ClutchInfo.ClutchClosed(absTime) ? ((ResponseDryRun)result).DeltaDragLoad : ((ResponseDryRun)result).Gearbox.PowerRequest, evaluateFunction: x => { - DataBus.BrakePower = x; + DataBus.Brakes.BrakePower = x; return NextComponent.Request(absTime, dt, acc, gradient, true); }, - criterion: y => DataBus.ClutchClosed(absTime) + criterion: y => DataBus.ClutchInfo.ClutchClosed(absTime) ? ((ResponseDryRun)y).DeltaDragLoad.Value() : ((ResponseDryRun)y).Gearbox.PowerRequest.Value()); Log.Info( "Found operating point for braking. absTime: {0}, dt: {1}, acceleration: {2}, gradient: {3}, BrakePower: {4}", - absTime, dt, acceleration, gradient, DataBus.BrakePower); + absTime, dt, acceleration, gradient, DataBus.Brakes.BrakePower); - if (DataBus.BrakePower.IsSmaller(0)) { + if (DataBus.Brakes.BrakePower.IsSmaller(0)) { Log.Info( "BrakePower was negative: {4}. Setting to 0 and searching for acceleration operating point. absTime: {0}, dt: {1}, acceleration: {2}, gradient: {3}", - absTime, dt, acceleration, gradient, DataBus.BrakePower); - DataBus.BrakePower = 0.SI<Watt>(); + absTime, dt, acceleration, gradient, DataBus.Brakes.BrakePower); + DataBus.Brakes.BrakePower = 0.SI<Watt>(); acceleration = SearchAlgorithm.Search(acceleration, r.Delta, Constants.SimulationSettings.OperatingPointInitialSearchIntervalAccelerating, getYValue: result => ((ResponseDryRun)result).DeltaFullLoad, @@ -262,7 +262,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ref MeterPerSquareSecond acceleration) { IResponse response; - if (DataBus.ClutchClosed(absTime)) { + if (DataBus.ClutchInfo.ClutchClosed(absTime)) { acceleration = SearchAlgorithm.Search(acceleration, r.Delta, Constants.SimulationSettings.OperatingPointInitialSearchIntervalAccelerating, getYValue: result => ((ResponseDryRun)result).DeltaFullLoad, @@ -274,26 +274,26 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl absTime, dt, acceleration, gradient); } else { var acc = acceleration; - DataBus.BrakePower = SearchAlgorithm.Search(DataBus.BrakePower, r.Delta, -r.Delta, - getYValue: result => DataBus.ClutchClosed(absTime) + DataBus.Brakes.BrakePower = SearchAlgorithm.Search(DataBus.Brakes.BrakePower, r.Delta, -r.Delta, + getYValue: result => DataBus.ClutchInfo.ClutchClosed(absTime) ? ((ResponseDryRun)result).DeltaDragLoad : ((ResponseDryRun)result).Gearbox.PowerRequest, evaluateFunction: x => { - DataBus.BrakePower = x; + DataBus.Brakes.BrakePower = x; return NextComponent.Request(absTime, dt, acc, gradient, true); }, - criterion: y => DataBus.ClutchClosed(absTime) + criterion: y => DataBus.ClutchInfo.ClutchClosed(absTime) ? ((ResponseDryRun)y).DeltaDragLoad.Value() : ((ResponseDryRun)y).Gearbox.PowerRequest.Value()); Log.Info( "Found operating point for braking. absTime: {0}, dt: {1}, acceleration: {2}, gradient: {3}, BrakePower: {4}", - absTime, dt, acceleration, gradient, DataBus.BrakePower); + absTime, dt, acceleration, gradient, DataBus.Brakes.BrakePower); - if (DataBus.BrakePower.IsSmaller(0)) { + if (DataBus.Brakes.BrakePower.IsSmaller(0)) { Log.Info( "BrakePower was negative: {4}. Setting to 0 and searching for acceleration operating point. absTime: {0}, dt: {1}, acceleration: {2}, gradient: {3}", - absTime, dt, acceleration, gradient, DataBus.BrakePower); - DataBus.BrakePower = 0.SI<Watt>(); + absTime, dt, acceleration, gradient, DataBus.Brakes.BrakePower); + DataBus.Brakes.BrakePower = 0.SI<Watt>(); acceleration = SearchAlgorithm.Search(acceleration, r.Delta, Constants.SimulationSettings.OperatingPointInitialSearchIntervalAccelerating, getYValue: result => ((ResponseDryRun)result).DeltaFullLoad, diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs index 22c6c0ea6c46596025d794e496fd873da9ec6e57..24cb6dc355707ec475b3fce02d6784c3c0850f8b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTOCycleController.cs @@ -73,7 +73,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } if (IdleStart == null) { IdleStart = absTime; - PreviousState.InAngularVelocity = DataBus.EngineSpeed; + PreviousState.InAngularVelocity = DataBus.EngineInfo.EngineSpeed; } return base.Request(absTime - IdleStart, dt); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Retarder.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Retarder.cs index f4e0ec07cc09bf8f85197d5eacd8ba6219ffc275..1fcb4f63a0d3398b92239d39f67f6ed4d4247fe8 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Retarder.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Retarder.cs @@ -72,7 +72,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IResponse Request(Second absTime, Second dt, NewtonMeter torque, PerSecond angularVelocity, bool dryRun = false) { - if (angularVelocity == null || (_primaryRetarder && !DataBus.ClutchClosed(absTime))) { + if (angularVelocity == null || (_primaryRetarder && !DataBus.ClutchInfo.ClutchClosed(absTime))) { return NextComponent.Request(absTime, dt, torque, angularVelocity, dryRun); } var avgAngularSpeed = (PreviousState.InAngularVelocity + angularVelocity) / 2.0; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs index ffb70f9e1dd573e048a6df9d0d01a1f52cfcb2b6..e8225c417908b6b16f72b9e0a88246857bd29c68 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/SimplePowertrainContainer.cs @@ -14,17 +14,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public IDriverDemandOutPort VehiclePort { - get { return (Vehicle as Vehicle)?.OutPort(); } + get { return (VehicleInfo as Vehicle)?.OutPort(); } } public ITnOutPort GearboxOutPort { - get { return (Gearbox as IGearbox)?.OutPort(); } + get { return (GearboxInfo as IGearbox)?.OutPort(); } } public IGearbox GearboxCtlTest { - get { return Gearbox as IGearbox; } + get { return GearboxInfo as IGearbox; } } public override Second AbsTime { get { return 0.SI<Second>(); } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs index 27668a2e44d2e6ab7f4ba452c68ff47962109a29..90e56500fbc1aee4f16c55d5ab2f9ad069f31214 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs @@ -75,14 +75,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) { - var operatingPointList = ModelData.FindOperatingPoint(outTorque, outAngularVelocity, DataBus.EngineIdleSpeed); + var operatingPointList = ModelData.FindOperatingPoint(outTorque, outAngularVelocity, DataBus.EngineInfo.EngineIdleSpeed); TorqueConverterOperatingPoint operatingPoint; if (operatingPointList.Count > 0) { operatingPoint = SelectOperatingPoint(operatingPointList); } else { Log.Warn( "TorqueConverter Initialize: No operating point found. Using output as input values as fallback for initialize."); - var inAngularVelocity = outAngularVelocity.LimitTo(DataBus.EngineIdleSpeed, DataBus.EngineN95hSpeed); + var inAngularVelocity = outAngularVelocity.LimitTo(DataBus.EngineInfo.EngineIdleSpeed, DataBus.EngineInfo.EngineN95hSpeed); operatingPoint = new TorqueConverterOperatingPoint { OutAngularVelocity = outAngularVelocity, OutTorque = outTorque, @@ -126,13 +126,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CurrentState.SetState(inTorque, operatingPoint.InAngularVelocity, outTorque, outAngularVelocity); CurrentState.OperatingPoint = operatingPoint; - CurrentState.IgnitionOn = DataBus.CombustionEngineOn; + CurrentState.IgnitionOn = DataBus.EngineCtl.CombustionEngineOn; var retVal = NextComponent.Request(absTime, dt, inTorque, operatingPoint.InAngularVelocity); //retVal.TorqueConverterOperatingPoint = operatingPoint; // check if shift is required var ratio = Gearbox.GetGearData(Gearbox.Gear).TorqueConverterRatio; - if (!Gearbox.DisengageGearbox && absTime > DataBus.LastShift && retVal is ResponseSuccess) { + if (!Gearbox.DisengageGearbox && absTime > DataBus.GearboxInfo.LastShift && retVal is ResponseSuccess) { var shiftRequired = ShiftStrategy?.ShiftRequired( absTime, dt, outTorque * ratio, outAngularVelocity / ratio, inTorque, operatingPoint.InAngularVelocity, Gearbox.Gear, Gearbox.LastShift, retVal) ?? false; @@ -144,7 +144,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private NewtonMeter CalculateAverageInTorque(TorqueConverterOperatingPoint operatingPoint) { - var prevInSpeed = PreviousState.IgnitionOn ? PreviousState.InAngularVelocity : DataBus.EngineIdleSpeed; + var prevInSpeed = PreviousState.IgnitionOn ? PreviousState.InAngularVelocity : DataBus.EngineInfo.EngineIdleSpeed; var avgEngineSpeed = (prevInSpeed + operatingPoint.InAngularVelocity) / 2; //var avgEngineSpeed = (PreviousState.InAngularVelocity + operatingPoint.InAngularVelocity) / 2; //var prevInSpeed = PreviousState.InAngularVelocity; @@ -165,10 +165,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // dry run request var engineResponse = (ResponseDryRun) NextComponent.Request(absTime, dt, inTorque, operatingPoint.InAngularVelocity, true); - var maxEngineSpeed = DataBus.EngineN95hSpeed; + var maxEngineSpeed = DataBus.EngineInfo.EngineN95hSpeed; var engineOK = engineResponse.DeltaDragLoad.IsGreaterOrEqual(0) && engineResponse.DeltaFullLoad.IsSmallerOrEqual(0); - if (DataBus.DriverBehavior != DrivingBehavior.Braking && engineOK && operatingPoint.Creeping) { + if (DataBus.DriverInfo.DriverBehavior != DrivingBehavior.Braking && engineOK && operatingPoint.Creeping) { var delta = (outTorque - operatingPoint.OutTorque) * (PreviousState.OutAngularVelocity + operatingPoint.OutAngularVelocity) / 2.0; return new ResponseDryRun(this) { @@ -223,15 +223,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl try { var operatingPoint = ModelData.FindOperatingPointForPowerDemand( engineResponse.Engine.DragPower - engineResponse.Engine.AuxiliariesPowerDemand, - DataBus.EngineSpeed, outAngularVelocity, _engineInertia, dt, previousPower); - var maxInputSpeed = VectoMath.Min(ModelData.TorqueConverterSpeedLimit, DataBus.EngineN95hSpeed); - var lowerInputSpeed = DataBus.EngineIdleSpeed * 1.001; // VectoMath.Max(DataBus.EngineIdleSpeed * 1.001, 0.8 * DataBus.EngineSpeed); + DataBus.EngineInfo.EngineSpeed, outAngularVelocity, _engineInertia, dt, previousPower); + var maxInputSpeed = VectoMath.Min(ModelData.TorqueConverterSpeedLimit, DataBus.EngineInfo.EngineN95hSpeed); + var lowerInputSpeed = DataBus.EngineInfo.EngineIdleSpeed * 1.001; // VectoMath.Max(DataBus.EngineIdleSpeed * 1.001, 0.8 * DataBus.EngineSpeed); var corrected = false; if (operatingPoint.InAngularVelocity.IsGreater(maxInputSpeed, 1e-2)) { operatingPoint = ModelData.FindOperatingPoint(maxInputSpeed, outAngularVelocity); corrected = true; } - if (operatingPoint.InAngularVelocity.IsSmaller(DataBus.EngineIdleSpeed * 1.001, 1e-2)) { + if (operatingPoint.InAngularVelocity.IsSmaller(DataBus.EngineInfo.EngineIdleSpeed * 1.001, 1e-2)) { operatingPoint = ModelData.FindOperatingPoint(lowerInputSpeed, outAngularVelocity); corrected = true; } @@ -242,19 +242,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl operatingPoint = FindValidTorqueConverterOperatingPoint( absTime, dt, outAngularVelocity, operatingPoint.InAngularVelocity, x => x.DeltaDragLoad.IsGreater(0), - x => VectoMath.Abs(DataBus.EngineSpeed - x.Engine.EngineSpeed).Value()); + x => VectoMath.Abs(DataBus.EngineInfo.EngineSpeed - x.Engine.EngineSpeed).Value()); return operatingPoint; } catch (VectoException ve) { Log.Warn(ve, "TorqueConverter: Failed to find operating point for DragPower {0}", engineResponse.Engine.DragPower); //var engineSpeed = VectoMath.Max(DataBus.EngineIdleSpeed * 1.001, 0.8 * DataBus.EngineSpeed); - var engineSpeed = DataBus.DrivingAction == DrivingAction.Brake - ? DataBus.EngineIdleSpeed * 1.001 - : VectoMath.Max(DataBus.EngineIdleSpeed * 1.001, 0.8 * DataBus.EngineSpeed); + var engineSpeed = DataBus.DriverInfo.DrivingAction == DrivingAction.Brake + ? DataBus.EngineInfo.EngineIdleSpeed * 1.001 + : VectoMath.Max(DataBus.EngineInfo.EngineIdleSpeed * 1.001, 0.8 * DataBus.EngineInfo.EngineSpeed); var retVal = FindValidTorqueConverterOperatingPoint( absTime, dt, outAngularVelocity, engineSpeed, x => x.DeltaDragLoad.IsGreater(0), - x => VectoMath.Abs(DataBus.EngineSpeed - x.Engine.EngineSpeed).Value()); + x => VectoMath.Abs(DataBus.EngineInfo.EngineSpeed - x.Engine.EngineSpeed).Value()); if (retVal != null) retVal.Creeping = true; return retVal; @@ -270,26 +270,26 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl try { var operatingPoint = ModelData.FindOperatingPointForPowerDemand( (engineResponse.Engine.DynamicFullLoadPower - engineResponse.Engine.AuxiliariesPowerDemand), - DataBus.EngineSpeed, outAngularVelocity, _engineInertia, dt, previousPower); - var maxInputSpeed = VectoMath.Min(ModelData.TorqueConverterSpeedLimit, DataBus.EngineN95hSpeed); + DataBus.EngineInfo.EngineSpeed, outAngularVelocity, _engineInertia, dt, previousPower); + var maxInputSpeed = VectoMath.Min(ModelData.TorqueConverterSpeedLimit, DataBus.EngineInfo.EngineN95hSpeed); if (operatingPoint.InAngularVelocity.IsGreater(maxInputSpeed)) { //operatingPoint = ModelData.FindOperatingPoint(maxInputSpeed, outAngularVelocity); operatingPoint = FindValidTorqueConverterOperatingPoint( absTime, dt, outAngularVelocity, maxInputSpeed, x => x.DeltaFullLoad.IsSmaller(0), - x => VectoMath.Abs(DataBus.EngineSpeed - x.Engine.EngineSpeed).Value()); + x => VectoMath.Abs(DataBus.EngineInfo.EngineSpeed - x.Engine.EngineSpeed).Value()); } return operatingPoint; } catch (VectoException ve) { Log.Warn( ve, "TorqueConverter: Failed to find operating point for MaxPower {0}", engineResponse.Engine.DynamicFullLoadPower); - var engineSpeed = VectoMath.Max(DataBus.EngineSpeed, VectoMath.Min(DataBus.EngineRatedSpeed, DataBus.EngineSpeed)); + var engineSpeed = VectoMath.Max(DataBus.EngineInfo.EngineSpeed, VectoMath.Min(DataBus.EngineInfo.EngineRatedSpeed, DataBus.EngineInfo.EngineSpeed)); var tqOperatingPoint = FindValidTorqueConverterOperatingPoint( absTime, dt, outAngularVelocity, engineSpeed, x => x.DeltaFullLoad.IsSmaller(0), - x => VectoMath.Abs(DataBus.EngineSpeed - x.Engine.EngineSpeed).Value()); + x => VectoMath.Abs(DataBus.EngineInfo.EngineSpeed - x.Engine.EngineSpeed).Value()); if (tqOperatingPoint == null) { return null; } @@ -312,8 +312,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var search = new List<ResponseDryRun>(); - var maxSpeed = VectoMath.Min(ModelData.TorqueConverterSpeedLimit, DataBus.EngineN95hSpeed); - for (var n = DataBus.EngineIdleSpeed; + var maxSpeed = VectoMath.Min(ModelData.TorqueConverterSpeedLimit, DataBus.EngineInfo.EngineN95hSpeed); + for (var n = DataBus.EngineInfo.EngineIdleSpeed; n <= maxSpeed; n += maxSpeed / 100) { var tcOp = ModelData.FindOperatingPoint(n, outAngularVelocity); @@ -342,17 +342,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (SetOperatingPoint != null) { return SetOperatingPoint; } - var operatingPointList = ModelData.FindOperatingPoint(outTorque, outAngularVelocity, DataBus.EngineIdleSpeed); + var operatingPointList = ModelData.FindOperatingPoint(outTorque, outAngularVelocity, DataBus.EngineInfo.EngineIdleSpeed); if (operatingPointList.Count == 0) { Log.Debug("TorqueConverter: Failed to find torque converter operating point, fallback: creeping"); - var tqOperatingPoint = ModelData.FindOperatingPoint(DataBus.EngineIdleSpeed, outAngularVelocity); + var tqOperatingPoint = ModelData.FindOperatingPoint(DataBus.EngineInfo.EngineIdleSpeed, outAngularVelocity); var engineResponse = (ResponseDryRun) NextComponent.Request(absTime, dt, tqOperatingPoint.InTorque, tqOperatingPoint.InAngularVelocity, true); var engineOK = engineResponse.DeltaDragLoad.IsGreaterOrEqual(0) && engineResponse.DeltaFullLoad.IsSmallerOrEqual(0); if (!engineOK) { - tqOperatingPoint = ModelData.FindOperatingPoint(VectoMath.Max(DataBus.EngineIdleSpeed, DataBus.EngineSpeed * 0.9), outAngularVelocity); + tqOperatingPoint = ModelData.FindOperatingPoint(VectoMath.Max(DataBus.EngineInfo.EngineIdleSpeed, DataBus.EngineInfo.EngineSpeed * 0.9), outAngularVelocity); } tqOperatingPoint.Creeping = true; @@ -360,13 +360,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var operatingPoint = SelectOperatingPoint(operatingPointList); - if (operatingPoint.InAngularVelocity.IsSmaller(DataBus.EngineIdleSpeed)) { + if (operatingPoint.InAngularVelocity.IsSmaller(DataBus.EngineInfo.EngineIdleSpeed)) { throw new VectoException( "TorqueConverter: Invalid operating point, inAngularVelocity would be below engine's idle speed: {0}", operatingPoint.InAngularVelocity); } - var maxInputSpeed = VectoMath.Min(ModelData.TorqueConverterSpeedLimit, DataBus.EngineN95hSpeed); + var maxInputSpeed = VectoMath.Min(ModelData.TorqueConverterSpeedLimit, DataBus.EngineInfo.EngineN95hSpeed); if (operatingPoint.InAngularVelocity.IsGreater(maxInputSpeed)) { operatingPoint = ModelData.FindOperatingPoint(maxInputSpeed, outAngularVelocity); } @@ -381,10 +381,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl foreach (var x in operatingPointList) { if ((x.InTorque * x.InAngularVelocity).IsSmallerOrEqual( - DataBus.EngineStationaryFullPower(x.InAngularVelocity), + DataBus.EngineInfo.EngineStationaryFullPower(x.InAngularVelocity), Constants.SimulationSettings.LineSearchTolerance.SI<Watt>()) && (x.InTorque * x.InAngularVelocity).IsGreaterOrEqual( - DataBus.EngineDragPower(x.InAngularVelocity), + DataBus.EngineInfo.EngineDragPower(x.InAngularVelocity), Constants.SimulationSettings.LineSearchTolerance.SI<Watt>())) { return x; } @@ -426,7 +426,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl PerSecond outAngularVelocity) { CurrentState.SetState(inTorque, inAngularVelocity, outTorque, outAngularVelocity); - CurrentState.IgnitionOn = DataBus.CombustionEngineOn; + CurrentState.IgnitionOn = DataBus.EngineCtl.CombustionEngineOn; } public class TorqueConverterComponentState : SimpleComponentState diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCombustionEngine.cs index 700d53c943f43a63e34de34fbe173952b168c5e2..91904e161d4781abd8ad170e835b87a337c1f8ac 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCombustionEngine.cs @@ -60,8 +60,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl EngineSpeed = outAngularVelocity, dt = 1.SI<Second>(), InertiaTorqueLoss = 0.SI<NewtonMeter>(), - StationaryFullLoadTorque = ModelData.FullLoadCurves[DataBus.Gear].FullLoadStationaryTorque(outAngularVelocity), - FullDragTorque = ModelData.FullLoadCurves[DataBus.Gear].DragLoadStationaryTorque(outAngularVelocity), + StationaryFullLoadTorque = ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear].FullLoadStationaryTorque(outAngularVelocity), + FullDragTorque = ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear].DragLoadStationaryTorque(outAngularVelocity), EngineTorque = outTorque + auxDemand, EnginePower = (outTorque + auxDemand) * outAngularVelocity, }; @@ -86,8 +86,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var torqueOut = powerDemand / avgEngineSpeed; - var fullDragTorque = ModelData.FullLoadCurves[DataBus.Gear].DragLoadStationaryTorque(avgEngineSpeed); - var fullLoadTorque = ModelData.FullLoadCurves[DataBus.Gear].FullLoadStationaryTorque(avgEngineSpeed); + var fullDragTorque = ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear].DragLoadStationaryTorque(avgEngineSpeed); + var fullLoadTorque = ModelData.FullLoadCurves[DataBus.GearboxInfo.Gear].FullLoadStationaryTorque(avgEngineSpeed); var inertiaTorqueLoss = Formulas.InertiaPower(angularVelocity, PreviousState.EngineSpeed, ModelData.Inertia, dt) / @@ -198,7 +198,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected override PerSecond GetEngineSpeed(PerSecond angularSpeed) { - return DataBus.CycleData.LeftSample.EngineSpeed; + return DataBus.DrivingCycleInfo.CycleData.LeftSample.EngineSpeed; } @@ -207,10 +207,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { var selected = ModelData.Fuels.First(x => x.FuelData.FuelType == fuel.FuelType); - if (DataBus.CycleData.LeftSample.VehicleTargetSpeed >= Constants.SimulationSettings.HighwaySpeedThreshold) { + if (DataBus.DrivingCycleInfo.CycleData.LeftSample.VehicleTargetSpeed >= Constants.SimulationSettings.HighwaySpeedThreshold) { return selected.WHTCMotorway; } - if (DataBus.CycleData.LeftSample.VehicleTargetSpeed >= Constants.SimulationSettings.RuralSpeedThreshold) { + if (DataBus.DrivingCycleInfo.CycleData.LeftSample.VehicleTargetSpeed >= Constants.SimulationSettings.RuralSpeedThreshold) { return selected.WHTCRural; } return selected.WHTCUrban; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs index 710dfcd8de9f911924f412e3280ff413720ace2d..423f1d600bb120be9a4f347318f341c5520f0d04 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs @@ -191,7 +191,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl for (var gear = maxStartGear; gear > 1; gear--) { var inAngularSpeed = cardanStartSpeed * RunData.GearboxData.Gears[gear].Ratio; - var ratedSpeed = DataBus.EngineRatedSpeed; + var ratedSpeed = DataBus.EngineInfo.EngineRatedSpeed; if (inAngularSpeed > ratedSpeed || inAngularSpeed.IsEqual(0)) continue; @@ -200,7 +200,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var fullLoadPower = response.Engine.DynamicFullLoadPower; //EnginePowerRequest - response.DeltaFullLoad; var reserve = 1 - response.Engine.PowerRequest / fullLoadPower; - if (response.Engine.EngineSpeed > DataBus.EngineIdleSpeed && reserve >= RunData.GearboxData.StartTorqueReserve) { + if (response.Engine.EngineSpeed > DataBus.EngineInfo.EngineIdleSpeed && reserve >= RunData.GearboxData.StartTorqueReserve) { StartGear = gear; return; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPGearbox.cs index 24fa947cb45714ed307d4786ff899a53613d57e1..4ea9841684d750585a53f06f09e812c2581f0450 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPGearbox.cs @@ -41,12 +41,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected override uint GetGearFromCycle() { - return DataBus.CycleData.LeftSample.Gear; + return DataBus.DrivingCycleInfo.CycleData.LeftSample.Gear; } public override bool GearEngaged(Second absTime) { - return DataBus.CycleData.LeftSample.Gear != 0; + return DataBus.DrivingCycleInfo.CycleData.LeftSample.Gear != 0; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs index 853f925eb7696a88af145014008be497ba1d13f7..ec468055d9f2041c6fa22100233642c0a98c96ca 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs @@ -74,7 +74,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IResponse Initialize(MeterPerSecond vehicleSpeed, Radian roadGradient) { PreviousState = new VehicleState { - Distance = DataBus.CycleStartDistance, + Distance = DataBus.DrivingCycleInfo.CycleStartDistance, Velocity = vehicleSpeed, RollingResistance = RollingResistance(roadGradient), SlopeResistance = SlopeResistance(roadGradient), diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VelocitySpeedGearshiftPreprocessor.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VelocitySpeedGearshiftPreprocessor.cs index a7d3338dd4f0f3f159e4fe7350a70712a0a3648c..09c691b37406f344ad5895532f701b49a850e939 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VelocitySpeedGearshiftPreprocessor.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VelocitySpeedGearshiftPreprocessor.cs @@ -52,13 +52,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected Entry[] IterateVehicleSpeedAndGradient() { var container = Container; - var vehicle = container?.Vehicle as Vehicle; + var vehicle = container?.VehicleInfo as Vehicle; if (vehicle == null) { throw new VectoException("no vehicle found..."); } - var gearbox = container.Gearbox as Gearbox; + var gearbox = container.GearboxInfo as Gearbox; if (gearbox == null) { throw new VectoException("no gearbox found..."); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/SwitchableClutch.cs b/VectoCore/VectoCore/Models/SimulationComponent/SwitchableClutch.cs index edd1d71e4e79367048b70fc0671370da7e4e6994..df0832475cdde33956e450a3bda5b8933f6e81d6 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/SwitchableClutch.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/SwitchableClutch.cs @@ -36,7 +36,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent } return response; } - if (DataBus.CombustionEngineOn) + if (DataBus.EngineCtl.CombustionEngineOn) return base.Initialize(outTorque, outAngularVelocity); PreviousState.SetState(outTorque, outAngularVelocity, outTorque, outAngularVelocity); return NextComponent.Initialize(outTorque, outAngularVelocity); @@ -73,9 +73,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent return response; } - if (DataBus.CombustionEngineOn) + if (DataBus.EngineCtl.CombustionEngineOn) { - if (DataBus.DriverBehavior == DrivingBehavior.Halted && !ClutchOpen) + if (DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Halted && !ClutchOpen) { return HandleClutchClosed(absTime, dt, outTorque, outAngularVelocity, dryRun); } diff --git a/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs b/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs index b633a88af389e8b31ef5758cf989b7e0bcc74eee..6896b4b732255cc8997d29cecf2e54e9085f040e 100644 --- a/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs +++ b/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs @@ -76,18 +76,18 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid strategy.RequestFunc = (absTime, b, c, d, dryRun) => { var shiftAllowed = absTime > currentState.lastGearShift + 2.SI<Second>(); var dBus = run.GetContainer(); - var triggerGearshift = shiftAllowed && (dBus.EngineSpeed > 1600.RPMtoRad() || - dBus.EngineSpeed < 625.RPMtoRad()); + var triggerGearshift = shiftAllowed && (dBus.EngineInfo.EngineSpeed > 1600.RPMtoRad() || + dBus.EngineInfo.EngineSpeed < 625.RPMtoRad()); //var nextGear = run.GetContainer().Gear; if (!dryRun && triggerGearshift) { nextState.lastGearShift = absTime; - nextState.nextGear = (uint)(dBus.Gear + (dBus.EngineSpeed > 1600.RPMtoRad() + nextState.nextGear = (uint)(dBus.GearboxInfo.Gear + (dBus.EngineInfo.EngineSpeed > 1600.RPMtoRad() ? 1 - : (dBus.EngineSpeed < 625.RPMtoRad() ? -1 : 0))); + : (dBus.EngineInfo.EngineSpeed < 625.RPMtoRad() ? -1 : 0))); } var assistTorque = electricTq; - if (electricTorque < 0 && dBus.VehicleSpeed > dBus.TargetSpeed - 3.KMPHtoMeterPerSecond()) { + if (electricTorque < 0 && dBus.VehicleInfo.VehicleSpeed > dBus.DrivingCycleInfo.TargetSpeed - 3.KMPHtoMeterPerSecond()) { assistTorque = 0.SI<NewtonMeter>(); } @@ -147,7 +147,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid strategy.RequestFunc = (absTime, dt, outTorque, outSpeed, dryRun) => { var dBus = run.GetContainer(); - var rpm = dBus.ElectricMotor(pos).ElectricMotorSpeed; + var rpm = dBus.ElectricMotorInfo(pos).ElectricMotorSpeed; var minTorque = -hybridController.ElectricMotorControl(pos).MaxDragTorque(rpm, dt); var maxTorque = -hybridController.ElectricMotorControl(pos).MaxDriveTorque(rpm, dt); return new HybridStrategyResponse() { @@ -160,7 +160,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid }; strategy.InitializeFunc = (outTorque, outSpeed) => { var dBus = run.GetContainer(); - var rpm = dBus.ElectricMotor(pos).ElectricMotorSpeed; + var rpm = dBus.ElectricMotorInfo(pos).ElectricMotorSpeed; var minTorque = -hybridController.ElectricMotorControl(pos).MaxDragTorque(rpm, 0.5.SI<Second>()); var maxTorque = -hybridController.ElectricMotorControl(pos).MaxDriveTorque(rpm, 0.5.SI<Second>()); return new HybridStrategyResponse { diff --git a/VectoCore/VectoCoreTest/Integration/ShiftStrategy/ShiftStrategyTest.cs b/VectoCore/VectoCoreTest/Integration/ShiftStrategy/ShiftStrategyTest.cs index 6e9002a2845d7be9d0d5ce0cda3a92ea1ef8c2fd..1bd79f2b21c8ef11880f698273b84617cc251010 100644 --- a/VectoCore/VectoCoreTest/Integration/ShiftStrategy/ShiftStrategyTest.cs +++ b/VectoCore/VectoCoreTest/Integration/ShiftStrategy/ShiftStrategyTest.cs @@ -126,7 +126,7 @@ namespace TUGraz.VectoCore.Tests.Integration.ShiftStrategy var run = runs[0]; var container = run.GetContainer() as VehicleContainer; - var vehicle = container?.Vehicle as Vehicle; + var vehicle = container?.VehicleInfo as Vehicle; Assert.NotNull(container); Assert.NotNull(vehicle); @@ -139,13 +139,13 @@ namespace TUGraz.VectoCore.Tests.Integration.ShiftStrategy for (var v = 15.0; v < 20; v += 0.1) { vehicle.Initialize(v.KMPHtoMeterPerSecond(), 0.SI<Radian>()); container.AbsTime = 0.SI<Second>(); - (container.Gearbox as Gearbox).Gear = 2; + (container.GearboxInfo as Gearbox).Gear = 2; //(container.Gearbox as ATGearbox)._strategy.NextGear.Gear = 0; - (container.Driver as Driver).DrivingAction = DrivingAction.Accelerate; - (container.Driver as Driver).DriverBehavior = DrivingBehavior.Accelerating; + (container.DriverInfo as Driver).DrivingAction = DrivingAction.Accelerate; + (container.DriverInfo as Driver).DriverBehavior = DrivingBehavior.Accelerating; var response = vehicle.Request( 0.SI<Second>(), 0.5.SI<Second>(), 0.5.SI<MeterPerSquareSecond>(), 0.SI<Radian>(), false); - decision.Add(Tuple.Create(v, response, ((container.Gearbox as Gearbox)._strategy as AMTShiftStrategyOptimized).minFCResponse)); + decision.Add(Tuple.Create(v, response, ((container.GearboxInfo as Gearbox)._strategy as AMTShiftStrategyOptimized).minFCResponse)); } foreach (var tuple in decision) { diff --git a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs index c8d4c07e8f835f91543533a3e3136fc73c5c7f25..d33d0c61fd5032a49805e934897f8247c4f1150a 100644 --- a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs @@ -128,9 +128,9 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns container.CommitSimulationStep(absTime, r.SimulationInterval); absTime += r.SimulationInterval; - ds = container.VehicleSpeed.IsEqual(0) + ds = container.VehicleInfo.VehicleSpeed.IsEqual(0) ? Constants.SimulationSettings.DriveOffDistance - : Constants.SimulationSettings.TargetTimeInterval * container.VehicleSpeed; + : Constants.SimulationSettings.TargetTimeInterval * container.VehicleInfo.VehicleSpeed; if (cnt++ % 100 == 0) { modData.Finish(VectoRun.Status.Success); @@ -194,7 +194,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns //gbx.Gear = 1; var cnt = 0; - while (!(response is ResponseCycleFinished) && container.Distance < 17000) { + while (!(response is ResponseCycleFinished) && container.MileageCounter.Distance < 17000) { Log.Info("Test New Request absTime: {0}, ds: {1}", absTime, ds); try { response = cyclePort.Request(absTime, ds); @@ -212,9 +212,9 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns container.CommitSimulationStep(absTime, r.SimulationInterval); absTime += r.SimulationInterval; - ds = container.VehicleSpeed.IsEqual(0) + ds = container.VehicleInfo.VehicleSpeed.IsEqual(0) ? Constants.SimulationSettings.DriveOffDistance - : Constants.SimulationSettings.TargetTimeInterval * container.VehicleSpeed; + : Constants.SimulationSettings.TargetTimeInterval * container.VehicleInfo.VehicleSpeed; if (cnt++ % 100 == 0) { modData.Finish(VectoRun.Status.Success); @@ -273,7 +273,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns //container.Gear = 1; var cnt = 0; - while (!(response is ResponseCycleFinished) && container.Distance < 17000) { + while (!(response is ResponseCycleFinished) && container.MileageCounter.Distance < 17000) { Log.Info("Test New Request absTime: {0}, ds: {1}", absTime, ds); try { response = cyclePort.Request(absTime, ds); @@ -291,9 +291,9 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns container.CommitSimulationStep(absTime, r.SimulationInterval); absTime += r.SimulationInterval; - ds = container.VehicleSpeed.IsEqual(0) + ds = container.VehicleInfo.VehicleSpeed.IsEqual(0) ? Constants.SimulationSettings.DriveOffDistance - : Constants.SimulationSettings.TargetTimeInterval * container.VehicleSpeed; + : Constants.SimulationSettings.TargetTimeInterval * container.VehicleInfo.VehicleSpeed; if (cnt++ % 100 == 0) { modData.Finish(VectoRun.Status.Success); diff --git a/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs b/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs index 040eb28039b3ce434e58342aaaa821e5cb46c4a7..7e9408b1756664c2e7851c293c6d30ab4deb5b97 100644 --- a/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs @@ -111,7 +111,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns // time [s] , dist [m] , v_act [km/h] , v_targ [km/h] , acc [m/s²] , grad [%] , n_eng_avg [1/min] , T_eng_fcmap [Nm] , Tq_clutch [Nm] , Tq_full [Nm] , Tq_drag [Nm] , P_eng_out [kW] , P_eng_full [kW] , P_eng_drag [kW] , P_clutch_out [kW] , Pa Eng [kW] , P_aux_mech [kW] , Gear [-] , Ploss GB [kW] , Ploss Diff [kW] , Ploss Retarder [kW] , Pa GB [kW] , Pa Veh [kW] , P_roll [kW] , P_air [kW] , P_slope [kW] , P_wheel_in [kW] , P_brake_loss [kW] , FC-Map [g/h] , FC-AUXc [g/h] , FC-WHTCc [g/h] // 1.5 , 5 , 18 , 18 , 0 , 2.842372 , 964.1117 , 323.7562 , 323.7562 , 2208.664 , -158.0261 , 32.68693 , 222.9902 , -15.95456 , 32.68693 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 5.965827 , 0.2423075 , 26.47879 , 32.68693 , 0 , 7574.113 , - , - - AssertHelper.AreRelativeEqual(964.1117.RPMtoRad().Value(), container.Engine.EngineSpeed.Value()); + AssertHelper.AreRelativeEqual(964.1117.RPMtoRad().Value(), container.EngineInfo.EngineSpeed.Value()); Assert.AreEqual(2208.664, engine.PreviousState.StationaryFullLoadTorque.Value(), Tolerance); Assert.AreEqual(-158.0261, engine.PreviousState.FullDragTorque.Value(), Tolerance); @@ -165,7 +165,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns gbx.Gear = 1; var cnt = 0; - while (!(response is ResponseCycleFinished) && container.Distance < 17000) { + while (!(response is ResponseCycleFinished) && container.MileageCounter.Distance < 17000) { response = cyclePort.Request(absTime, ds); response.Switch(). Case<ResponseDrivingCycleDistanceExceeded>(r => ds = r.MaxDistance). @@ -174,9 +174,9 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns container.CommitSimulationStep(absTime, r.SimulationInterval); absTime += r.SimulationInterval; - ds = container.VehicleSpeed.IsEqual(0) + ds = container.VehicleInfo.VehicleSpeed.IsEqual(0) ? Constants.SimulationSettings.DriveOffDistance - : (Constants.SimulationSettings.TargetTimeInterval * container.VehicleSpeed) + : (Constants.SimulationSettings.TargetTimeInterval * container.VehicleInfo.VehicleSpeed) .Cast<Meter>(); if (cnt++ % 100 == 0) { @@ -236,7 +236,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns gbx.Gear = 1; var ds = Constants.SimulationSettings.DriveOffDistance; - while (container.Distance < 100) { + while (container.MileageCounter.Distance < 100) { var response = cyclePort.Request(absTime, ds); response.Switch(). Case<ResponseDrivingCycleDistanceExceeded>(r => ds = r.MaxDistance). @@ -244,9 +244,9 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns container.CommitSimulationStep(absTime, r.SimulationInterval); absTime += r.SimulationInterval; - ds = container.VehicleSpeed.IsEqual(0) + ds = container.VehicleInfo.VehicleSpeed.IsEqual(0) ? Constants.SimulationSettings.DriveOffDistance - : (Constants.SimulationSettings.TargetTimeInterval * container.VehicleSpeed) + : (Constants.SimulationSettings.TargetTimeInterval * container.VehicleInfo.VehicleSpeed) .Cast<Meter>(); modData.Finish(VectoRun.Status.Success); diff --git a/VectoCore/VectoCoreTest/Models/Simulation/FactoryTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/FactoryTest.cs index 234fc30a53208956c9451a98b4e0a6d1ad7f7441..61d38fb1e65736752430596846f8cde1a5233cc2 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/FactoryTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/FactoryTest.cs @@ -72,11 +72,11 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation Assert.AreEqual(11, vehicleContainer.SimulationComponents().Count); - Assert.IsInstanceOf<Gearbox>(vehicleContainer.Gearbox, "gearbox not installed"); - Assert.IsInstanceOf<CombustionEngine>(vehicleContainer.Engine, "engine not installed"); - Assert.IsInstanceOf<Vehicle>(vehicleContainer.Vehicle, "vehicle not installed"); + Assert.IsInstanceOf<Gearbox>(vehicleContainer.GearboxInfo, "gearbox not installed"); + Assert.IsInstanceOf<CombustionEngine>(vehicleContainer.EngineInfo, "engine not installed"); + Assert.IsInstanceOf<Vehicle>(vehicleContainer.VehicleInfo, "vehicle not installed"); - var gearbox = vehicleContainer.Gearbox as Gearbox; + var gearbox = vehicleContainer.GearboxInfo as Gearbox; Assert.IsNotNull(gearbox); // -- shiftpolygon downshift @@ -121,9 +121,9 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var vehicleContainer = (VehicleContainer)run.GetContainer(); Assert.AreEqual(12, vehicleContainer.SimulationComponents().Count); - Assert.IsInstanceOf<Gearbox>(vehicleContainer.Gearbox, "gearbox not installed"); - Assert.IsInstanceOf<CombustionEngine>(vehicleContainer.Engine, "engine not installed"); - Assert.IsInstanceOf<Vehicle>(vehicleContainer.Vehicle, "vehicle not installed"); + Assert.IsInstanceOf<Gearbox>(vehicleContainer.GearboxInfo, "gearbox not installed"); + Assert.IsInstanceOf<CombustionEngine>(vehicleContainer.EngineInfo, "engine not installed"); + Assert.IsInstanceOf<Vehicle>(vehicleContainer.VehicleInfo, "vehicle not installed"); } [Category("LongRunning")] diff --git a/VectoCore/VectoCoreTest/Models/Simulation/PowerTrainBuilderTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/PowerTrainBuilderTest.cs index e0ece69a32aacca09a23d9f731d971423d9ac0bd..9afb99ee10946716e67dd1a6a2af1a5b0acfa699 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/PowerTrainBuilderTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/PowerTrainBuilderTest.cs @@ -86,10 +86,10 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation Assert.IsInstanceOf<IVehicleContainer>(powerTrain); Assert.AreEqual(componentCount, powerTrain.SimulationComponents().Count); - Assert.IsInstanceOf<CombustionEngine>(powerTrain.Engine); - Assert.IsInstanceOf<Gearbox>(powerTrain.Gearbox); + Assert.IsInstanceOf<CombustionEngine>(powerTrain.EngineInfo); + Assert.IsInstanceOf<Gearbox>(powerTrain.GearboxInfo); Assert.IsInstanceOf<ISimulationOutPort>(powerTrain.Cycle); - Assert.IsInstanceOf<Vehicle>(powerTrain.Vehicle); + Assert.IsInstanceOf<Vehicle>(powerTrain.VehicleInfo); } [TestCase(JobFileDeclNoAngular, 11, false), @@ -116,10 +116,10 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation Assert.IsInstanceOf<IVehicleContainer>(powerTrain); Assert.AreEqual(componentCount, powerTrain.SimulationComponents().Count); - Assert.IsInstanceOf<CombustionEngine>(powerTrain.Engine); - Assert.IsInstanceOf<Gearbox>(powerTrain.Gearbox); + Assert.IsInstanceOf<CombustionEngine>(powerTrain.EngineInfo); + Assert.IsInstanceOf<Gearbox>(powerTrain.GearboxInfo); Assert.IsInstanceOf<ISimulationOutPort>(powerTrain.Cycle); - Assert.IsInstanceOf<Vehicle>(powerTrain.Vehicle); + Assert.IsInstanceOf<Vehicle>(powerTrain.VehicleInfo); } else { AssertHelper.Exception<VectoException>(() => { reader.NextRun().ToList(); }); } diff --git a/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs index 31c426c2397b1f510510b1fd54d29a01a4e467ff..b3589cfe19888be700b83d05451a0c03c463bd7a 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/PwheelModeTests.cs @@ -104,23 +104,23 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation cycle.Initialize(); - Assert.AreEqual(container.CycleData.LeftSample.Time, 1.SI<Second>()); - Assert.AreEqual(container.CycleData.RightSample.Time, 2.SI<Second>()); + Assert.AreEqual(container.DrivingCycleInfo.CycleData.LeftSample.Time, 1.SI<Second>()); + Assert.AreEqual(container.DrivingCycleInfo.CycleData.RightSample.Time, 2.SI<Second>()); - Assert.AreEqual(1748.RPMtoRad() / (2.3 * 3.5), container.CycleData.LeftSample.WheelAngularVelocity); - Assert.AreEqual(1400.RPMtoRad() / (2.3 * 3.5), container.CycleData.RightSample.WheelAngularVelocity); + Assert.AreEqual(1748.RPMtoRad() / (2.3 * 3.5), container.DrivingCycleInfo.CycleData.LeftSample.WheelAngularVelocity); + Assert.AreEqual(1400.RPMtoRad() / (2.3 * 3.5), container.DrivingCycleInfo.CycleData.RightSample.WheelAngularVelocity); - Assert.AreEqual(89.SI(Unit.SI.Kilo.Watt), container.CycleData.LeftSample.PWheel); - Assert.AreEqual(120.SI(Unit.SI.Kilo.Watt), container.CycleData.RightSample.PWheel); + Assert.AreEqual(89.SI(Unit.SI.Kilo.Watt), container.DrivingCycleInfo.CycleData.LeftSample.PWheel); + Assert.AreEqual(120.SI(Unit.SI.Kilo.Watt), container.DrivingCycleInfo.CycleData.RightSample.PWheel); - Assert.AreEqual(2u, container.CycleData.LeftSample.Gear); - Assert.AreEqual(2u, container.CycleData.RightSample.Gear); + Assert.AreEqual(2u, container.DrivingCycleInfo.CycleData.LeftSample.Gear); + Assert.AreEqual(2u, container.DrivingCycleInfo.CycleData.RightSample.Gear); - Assert.AreEqual(1300.SI<Watt>(), container.CycleData.LeftSample.AdditionalAuxPowerDemand); - Assert.AreEqual(400.SI<Watt>(), container.CycleData.RightSample.AdditionalAuxPowerDemand); + Assert.AreEqual(1300.SI<Watt>(), container.DrivingCycleInfo.CycleData.LeftSample.AdditionalAuxPowerDemand); + Assert.AreEqual(400.SI<Watt>(), container.DrivingCycleInfo.CycleData.RightSample.AdditionalAuxPowerDemand); - Assert.AreEqual(89.SI(Unit.SI.Kilo.Watt) / (1748.RPMtoRad() / (2.3 * 3.5)), container.CycleData.LeftSample.Torque); - Assert.AreEqual(120.SI(Unit.SI.Kilo.Watt) / (1400.RPMtoRad() / (2.3 * 3.5)), container.CycleData.RightSample.Torque); + Assert.AreEqual(89.SI(Unit.SI.Kilo.Watt) / (1748.RPMtoRad() / (2.3 * 3.5)), container.DrivingCycleInfo.CycleData.LeftSample.Torque); + Assert.AreEqual(120.SI(Unit.SI.Kilo.Watt) / (1400.RPMtoRad() / (2.3 * 3.5)), container.DrivingCycleInfo.CycleData.RightSample.Torque); } /// <summary> diff --git a/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs index 30711da6acc036ce80fd7f427dc1c48dfa4bd5c6..02a0418fbbad4f8850f23f52349ec687bdf35b96 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/SimulationTests.cs @@ -64,7 +64,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var container = job.GetContainer(); - Assert.AreEqual(560.RPMtoRad(), container.EngineSpeed); + Assert.AreEqual(560.RPMtoRad(), container.EngineInfo.EngineSpeed); } [TestCase] diff --git a/VectoCore/VectoCoreTest/Models/Simulation/VechicleContainerTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/VechicleContainerTests.cs index 701dd92ee2dcbad6802171da74166f43d2b504a5..c116d607b9b3597bcb28c44e6956521613b50eb3 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/VechicleContainerTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/VechicleContainerTests.cs @@ -49,7 +49,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(EngineFile, 0); var engine = new CombustionEngine(vehicle, engineData); - Assert.IsNotNull(vehicle.EngineSpeed); + Assert.IsNotNull(vehicle.EngineInfo.EngineSpeed); } } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs index 42325275656518e31980ff190b6607278f0c4338..37f0cb6be171e5d8e1439253ad2f30d79657a006 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/ATGearboxTest.cs @@ -91,7 +91,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var gearboxData = MockSimulationDataFactory.CreateGearboxDataFromFile(GearboxDataFile, EngineDataFile, false); var vehicleContainer = new MockVehicleContainer(); //(ExecutionMode.Engineering); var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(EngineDataFile, gearboxData.Gears.Count); - vehicleContainer.Engine = new CombustionEngine(vehicleContainer, engineData); + vehicleContainer.EngineInfo = new CombustionEngine(vehicleContainer, engineData); var runData = new VectoRunData() { GearboxData = gearboxData, EngineData = new CombustionEngineData() { Inertia = 0.SI<KilogramSquareMeter>() } diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs index 2eea15546389b4109620971dd32edb179ff3c24d..20ed6af003d31bba7b024a8649336874327c2776 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/DistanceBasedDrivingCycleTest.cs @@ -168,7 +168,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent // just in test mock driver driver.VehicleStopped = false; - var startDistance = container.CycleStartDistance.Value(); + var startDistance = container.DrivingCycleInfo.CycleStartDistance.Value(); var absTime = 0.SI<Second>(); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs index dcab28d7f32df87ab0d9f77cf4d04f000fe58427..b101df6b156797101fd0be94f19dfba993561b53 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs @@ -115,12 +115,12 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent vehicleContainer.CommitSimulationStep(absTime, response.SimulationInterval); absTime += response.SimulationInterval; - Assert.AreEqual(4.9877, vehicleContainer.VehicleSpeed.Value(), Tolerance); + Assert.AreEqual(4.9877, vehicleContainer.VehicleInfo.VehicleSpeed.Value(), Tolerance); Assert.AreEqual(0.2004, response.SimulationInterval.Value(), Tolerance); Assert.AreEqual(engine.PreviousState.FullDragTorque.Value(), engine.PreviousState.EngineTorque.Value(), Constants.SimulationSettings.LineSearchTolerance); - while (vehicleContainer.VehicleSpeed > 1.7) { + while (vehicleContainer.VehicleInfo.VehicleSpeed > 1.7) { response = driver.DrivingActionCoast(absTime, 1.SI<Meter>(), velocity, 0.SI<Radian>()); Assert.IsInstanceOf<ResponseSuccess>(response); @@ -181,12 +181,12 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent vehicleContainer.CommitSimulationStep(absTime, response.SimulationInterval); absTime += response.SimulationInterval; - Assert.AreEqual(4.9878, vehicleContainer.VehicleSpeed.Value(), Tolerance); + Assert.AreEqual(4.9878, vehicleContainer.VehicleInfo.VehicleSpeed.Value(), Tolerance); Assert.AreEqual(0.2004, response.SimulationInterval.Value(), Tolerance); Assert.AreEqual(engine.PreviousState.FullDragTorque.Value(), engine.PreviousState.EngineTorque.Value(), Constants.SimulationSettings.LineSearchTolerance); - while (vehicleContainer.VehicleSpeed > 1.7) { + while (vehicleContainer.VehicleInfo.VehicleSpeed > 1.7) { response = driver.DrivingActionCoast(absTime, 1.SI<Meter>(), velocity, gradient); Assert.IsInstanceOf<ResponseSuccess>(response); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs index d695e60687830385e9130e07926c4fc1c158a156..48536307476bae851ae474364ee3ff99218d72ec 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxPowertrainTest.cs @@ -59,10 +59,10 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var container = Truck40tPowerTrain.CreatePowerTrain(cycle, "Gearbox_Initialize", 7500.0.SI<Kilogram>(), 0.SI<Kilogram>()); var retVal = container.Cycle.Initialize(); - Assert.AreEqual(4u, container.Gear); + Assert.AreEqual(4u, container.GearboxInfo.Gear); Assert.IsInstanceOf<ResponseSuccess>(retVal); - AssertHelper.AreRelativeEqual(560.RPMtoRad(), container.EngineSpeed); + AssertHelper.AreRelativeEqual(560.RPMtoRad(), container.EngineInfo.EngineSpeed); var absTime = 0.SI<Second>(); var ds = 1.SI<Meter>(); @@ -71,12 +71,12 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent container.CommitSimulationStep(absTime, retVal.SimulationInterval); absTime += retVal.SimulationInterval; - AssertHelper.AreRelativeEqual(560.RPMtoRad(), container.EngineSpeed); + AssertHelper.AreRelativeEqual(560.RPMtoRad(), container.EngineInfo.EngineSpeed); container.Cycle.Request(absTime, ds); container.CommitSimulationStep(absTime, retVal.SimulationInterval); - Assert.AreEqual(4u, container.Gear); - AssertHelper.AreRelativeEqual(65.6890, container.EngineSpeed); + Assert.AreEqual(4u, container.GearboxInfo); + AssertHelper.AreRelativeEqual(65.6890, container.EngineInfo.EngineSpeed); } [TestCase] @@ -90,10 +90,10 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var container = Truck40tPowerTrain.CreatePowerTrain(cycle, "Gearbox_Initialize", 7500.0.SI<Kilogram>(), 19300.SI<Kilogram>()); var retVal = container.Cycle.Initialize(); - Assert.AreEqual(4u, container.Gear); + Assert.AreEqual(4u, container.GearboxInfo); Assert.IsInstanceOf<ResponseSuccess>(retVal); - AssertHelper.AreRelativeEqual(560.RPMtoRad(), container.EngineSpeed); + AssertHelper.AreRelativeEqual(560.RPMtoRad(), container.EngineInfo.EngineSpeed); var absTime = 0.SI<Second>(); var ds = 1.SI<Meter>(); @@ -102,12 +102,12 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent container.CommitSimulationStep(absTime, retVal.SimulationInterval); absTime += retVal.SimulationInterval; - AssertHelper.AreRelativeEqual(560.RPMtoRad(), container.EngineSpeed); + AssertHelper.AreRelativeEqual(560.RPMtoRad(), container.EngineInfo.EngineSpeed); container.Cycle.Request(absTime, ds); container.CommitSimulationStep(absTime, retVal.SimulationInterval); - AssertHelper.AreRelativeEqual(87.3192, container.EngineSpeed); + AssertHelper.AreRelativeEqual(87.3192, container.EngineInfo.EngineSpeed); } [TestCase] @@ -121,10 +121,10 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var container = Truck40tPowerTrain.CreatePowerTrain(cycle, "Gearbox_Initialize", 7500.0.SI<Kilogram>(), 19300.SI<Kilogram>()); var retVal = container.Cycle.Initialize(); - Assert.AreEqual(12u, container.Gear); + Assert.AreEqual(12u, container.GearboxInfo); Assert.IsInstanceOf<ResponseSuccess>(retVal); - AssertHelper.AreRelativeEqual(1195.996.RPMtoRad(), container.EngineSpeed, toleranceFactor: 1e-3); + AssertHelper.AreRelativeEqual(1195.996.RPMtoRad(), container.EngineInfo.EngineSpeed, toleranceFactor: 1e-3); var absTime = 0.SI<Second>(); var ds = 1.SI<Meter>(); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxShiftLossesTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxShiftLossesTest.cs index e140897371e07e7246fd09aee5744b99259f3880..4efc971e29a155be43b6e268374806a84ccd6a95 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxShiftLossesTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxShiftLossesTest.cs @@ -216,7 +216,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent engine = new CombustionEngine( container, MockSimulationDataFactory.CreateEngineDataFromFile(ATPowerTrain.EngineFile, gearboxData.Gears.Count)); - container.Engine = engine; + container.EngineInfo = engine; var runData = new VectoRunData() { GearboxData = gearboxData, EngineData = new CombustionEngineData() { Inertia = 5.SI<KilogramSquareMeter>() } diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs index 17f3926cda80ec3980ed448141406e9be3f4ee65..7dc576a73800a13562c2dff7dc880796042f82a6 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs @@ -219,7 +219,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var port = new MockTnOutPort(); gearbox.InPort().Connect(port); - container.Engine = port; + container.EngineInfo = port; gearbox.Initialize(0.SI<NewtonMeter>(), 0.RPMtoRad()); @@ -298,7 +298,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var port = new MockTnOutPort(); gearbox.InPort().Connect(port); - container.Engine = port; + container.EngineInfo = port; gearbox.Initialize(0.SI<NewtonMeter>(), 0.RPMtoRad()); @@ -333,7 +333,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var port = new MockTnOutPort(); gearbox.InPort().Connect(port); - container.Engine = port; + container.EngineInfo = port; gearbox.Initialize(0.SI<NewtonMeter>(), 0.RPMtoRad()); @@ -371,7 +371,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var port = new MockTnOutPort(); gearbox.InPort().Connect(port); - container.Engine = port; + container.EngineInfo = port; gearbox.Initialize(0.SI<NewtonMeter>(), 0.RPMtoRad()); @@ -404,7 +404,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var port = new MockTnOutPort(); gearbox.InPort().Connect(port); - container.Engine = port; + container.EngineInfo = port; gearbox.Initialize(0.SI<NewtonMeter>(), 0.RPMtoRad()); @@ -463,7 +463,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var port = new MockTnOutPort(); gearbox.InPort().Connect(port); - container.Engine = port; + container.EngineInfo = port; var ratios = new[] { 0.0, 6.38, 4.63, 3.44, 2.59, 1.86, 1.35, 1, 0.76 }; // the first element 0.0 is just a placeholder for axlegear, not used in this test @@ -513,7 +513,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var port = new MockTnOutPort() { EngineN95hSpeed = 2000.RPMtoRad() }; gearbox.InPort().Connect(port); var vehicle = new MockVehicle(container) { MyVehicleSpeed = 10.SI<MeterPerSecond>() }; - container.Engine = port; + container.EngineInfo = port; var ratios = new[] { 0.0, 6.38, 4.63, 3.44, 2.59, 1.86, 1.35, 1, 0.76 }; // the first element 0.0 is just a placeholder for axlegear, not used in this test @@ -537,7 +537,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent absTime += dt; var successResponse = (ResponseSuccess)gearbox.OutPort().Request(absTime, dt, torque, angularVelocity); - Assert.AreEqual((uint)newGear, container.Gear); + Assert.AreEqual((uint)newGear, container.GearboxInfo.Gear); } [TestCase(7, 8, 1000, 1400, typeof(ResponseGearShift)), @@ -566,7 +566,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var gearbox = new Gearbox(container, new AMTShiftStrategy(runData, container), runData); var port = new MockTnOutPort() { EngineN95hSpeed = 2000.RPMtoRad() }; - container.Engine = port; + container.EngineInfo = port; gearbox.InPort().Connect(port); var ratios = new[] { 0.0, 6.38, 4.63, 3.44, 2.59, 1.86, 1.35, 1, 0.76 }; diff --git a/VectoCore/VectoCoreTest/Reports/ModDataTest.cs b/VectoCore/VectoCoreTest/Reports/ModDataTest.cs index 14eb20975037a67ec15707a2b22f6ba0b163fdc9..8227ea66bbe5fa3ab889da3043dd290b08b40336 100644 --- a/VectoCore/VectoCoreTest/Reports/ModDataTest.cs +++ b/VectoCore/VectoCoreTest/Reports/ModDataTest.cs @@ -314,12 +314,12 @@ namespace TUGraz.VectoCore.Tests.Reports jobContainer.AddRuns(runsFactory); var modData = new List<Tuple<ModalResults, double>>(); foreach (var run in jobContainer.Runs) { - var distanceCycle = ((VehicleContainer)run.Run.GetContainer()).DrivingCycle as DistanceBasedDrivingCycle; + var distanceCycle = ((VehicleContainer)run.Run.GetContainer()).DrivingCycleInfo as DistanceBasedDrivingCycle; if (distanceCycle != null) { modData.Add(Tuple.Create(((ModalDataContainer)run.Run.GetContainer().ModalData).Data, distanceCycle.Data.Entries.Last().Distance.Value())); } - var cycle = ((VehicleContainer)run.Run.GetContainer()).DrivingCycle as PowertrainDrivingCycle; + var cycle = ((VehicleContainer)run.Run.GetContainer()).DrivingCycleInfo as PowertrainDrivingCycle; if (cycle != null) modData.Add(Tuple.Create(((ModalDataContainer)run.Run.GetContainer().ModalData).Data, cycle.Data.Entries.Last().Time.Value())); @@ -347,7 +347,7 @@ namespace TUGraz.VectoCore.Tests.Reports .Components.EngineInputData.EngineModes.First().Fuels.First().FuelConsumptionMap); } var disatanceBased = - ((VehicleContainer)(jobContainer.Runs.First().Run.GetContainer())).DrivingCycle is DistanceBasedDrivingCycle; + ((VehicleContainer)(jobContainer.Runs.First().Run.GetContainer())).DrivingCycleInfo is DistanceBasedDrivingCycle; foreach (var modalResults in modData) { AssertModDataIntegrity(modalResults.Item1, auxKeys, modalResults.Item2,fcMap, disatanceBased); } @@ -617,7 +617,7 @@ namespace TUGraz.VectoCore.Tests.Reports var modData = new List<Tuple<ModalResults, Meter>>(); foreach (var run in jobContainer.Runs) { modData.Add(Tuple.Create(((ModalDataContainer)run.Run.GetContainer().ModalData).Data, - ((DistanceBasedDrivingCycle)((VehicleContainer)run.Run.GetContainer()).DrivingCycle).Data.Entries.Last() + ((DistanceBasedDrivingCycle)((VehicleContainer)run.Run.GetContainer()).DrivingCycleInfo).Data.Entries.Last() .Distance)); } var auxKeys = diff --git a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs index acd4d29167a67f36bebb865c8a1a297a1b7add27..b1ff74007917817c35de45dbb7593fc2a9aa7fcb 100644 --- a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs +++ b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs @@ -47,7 +47,8 @@ using TUGraz.VectoCore.OutputData; namespace TUGraz.VectoCore.Tests.Utils { - public class MockVehicleContainer : IVehicleContainer + + public class MockVehicleContainer : IVehicleContainer, IEngineInfo, IEngineControl, IVehicleInfo, IClutchInfo, IBrakes, IAxlegearInfo, IWheelsInfo, IDriverInfo, IDrivingCycleInfo, IMileageCounter, IGearboxInfo, IGearboxControl { // only CycleData Lookup is set / accessed... @@ -56,7 +57,47 @@ namespace TUGraz.VectoCore.Tests.Utils private bool _clutchClosed = true; private ITorqueConverterControl _torqueConverter; - public IEngineInfo Engine { get; set; } + public IAxlegearInfo AxlegearInfo + { + get { return this; } + } + + public IEngineInfo EngineInfo { get; set; } + + public IEngineControl EngineCtl + { + get { return this; } + } + + public IVehicleInfo VehicleInfo + { + get { return this; } + } + + public IClutchInfo ClutchInfo + { + get { return this; } + } + + public IBrakes Brakes + { + get { return this; } + } + + public IWheelsInfo WheelsInfo + { + get { return this; } + } + + public IDriverInfo DriverInfo + { + get { return this; } + } + + public IDrivingCycleInfo DrivingCycleInfo + { + get { return this; } + } public GearboxType GearboxType { get; set; } @@ -81,12 +122,28 @@ namespace TUGraz.VectoCore.Tests.Utils } public Second AbsTime { get; set; } - public IElectricMotorInfo ElectricMotor(PowertrainPosition pos) + + public IMileageCounter MileageCounter + { + get { return this; } + } + + public IGearboxInfo GearboxInfo + { + get { return this; } + } + + public IGearboxControl GearboxCtl + { + get { return this; } + } + + public IElectricMotorInfo ElectricMotorInfo(PowertrainPosition pos) { return null; } - public ITorqueConverterControl TorqueConverter + public ITorqueConverterControl TorqueConverterCtl { get { return _torqueConverter; } } @@ -108,7 +165,7 @@ namespace TUGraz.VectoCore.Tests.Utils public Watt EngineStationaryFullPower(PerSecond angularSpeed) { - return Engine.EngineStationaryFullPower(angularSpeed); + return EngineInfo.EngineStationaryFullPower(angularSpeed); } public Watt EngineDynamicFullLoadPower(PerSecond avgEngineSpeed, Second dt) @@ -118,7 +175,7 @@ namespace TUGraz.VectoCore.Tests.Utils public Watt EngineDragPower(PerSecond angularSpeed) { - return Engine.EngineStationaryFullPower(angularSpeed); + return EngineInfo.EngineStationaryFullPower(angularSpeed); } public Watt EngineAuxDemand(PerSecond avgEngineSpeed, Second dt) @@ -128,22 +185,22 @@ namespace TUGraz.VectoCore.Tests.Utils public PerSecond EngineIdleSpeed { - get { return Engine.EngineIdleSpeed; } + get { return EngineInfo.EngineIdleSpeed; } } public PerSecond EngineRatedSpeed { - get { return Engine.EngineRatedSpeed; } + get { return EngineInfo.EngineRatedSpeed; } } public PerSecond EngineN95hSpeed { - get { return Engine.EngineN95hSpeed; } + get { return EngineInfo.EngineN95hSpeed; } } public PerSecond EngineN80hSpeed { - get { return Engine.EngineN80hSpeed; } + get { return EngineInfo.EngineN80hSpeed; } } public MeterPerSecond VehicleSpeed { get; set; }