From d948c705cead527ac23a190fe74ee4cb5f89a541 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Tue, 2 Jun 2020 11:02:27 +0200 Subject: [PATCH] refactoring: move field from response to gearbox response; make code compile --- .../Adapter/Declaration/VehicleDeclarationAdapter.cs | 12 ++++++++++++ VectoCommon/VectoCommon/Models/IResponse.cs | 7 +++++-- .../Models/SimulationComponent/Impl/ATGearbox.cs | 4 ++-- .../Impl/BusAuxiliariesAdapter.cs | 6 +++--- .../Models/SimulationComponent/Impl/Driver.cs | 8 ++++---- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/VECTO3GUI/ViewModel/Adapter/Declaration/VehicleDeclarationAdapter.cs b/VECTO3GUI/ViewModel/Adapter/Declaration/VehicleDeclarationAdapter.cs index dc508f3a4f..7fe0e8b95f 100644 --- a/VECTO3GUI/ViewModel/Adapter/Declaration/VehicleDeclarationAdapter.cs +++ b/VECTO3GUI/ViewModel/Adapter/Declaration/VehicleDeclarationAdapter.cs @@ -19,6 +19,8 @@ namespace VECTO3GUI.ViewModel.Adapter.Declaration protected IVehicleViewModel ViewModel; private DateTime _date; private IAuxiliariesDeclarationInputData _auxiliaryInputData; + private IElectricStorageDeclarationInputData _electricStorage; + private IElectricMachinesDeclarationInputData _electricMachines; [Inject] public IAdapterFactory AdapterFactory { set; protected get; } @@ -159,6 +161,16 @@ namespace VECTO3GUI.ViewModel.Adapter.Declaration public IAxlesDeclarationInputData AxleWheels { get { return this; } } public IBusAuxiliariesDeclarationData BusAuxiliaries { get; } + public IElectricStorageDeclarationInputData ElectricStorage + { + get { return _electricStorage; } + } + + public IElectricMachinesDeclarationInputData ElectricMachines + { + get { return _electricMachines; } + } + #endregion private T GetComponentViewModel<T>(Component component) where T : class diff --git a/VectoCommon/VectoCommon/Models/IResponse.cs b/VectoCommon/VectoCommon/Models/IResponse.cs index 8bfe13a714..5555db436e 100644 --- a/VectoCommon/VectoCommon/Models/IResponse.cs +++ b/VectoCommon/VectoCommon/Models/IResponse.cs @@ -85,7 +85,11 @@ namespace TUGraz.VectoCommon.Models public class ClutchResponse : AbstractPowertrainComponentResponse { } [DebuggerDisplay("P_out: {PowerRequest}")] - public class GearboxResponse : AbstractPowertrainComponentResponse { } + public class GearboxResponse : AbstractPowertrainComponentResponse + { + public PerSecond GearboxInputSpeed { get; set; } + + } [DebuggerDisplay("P_out: {PowerRequest}; T_card: {CardanTorque}")] public class AxlegearResponse : AbstractPowertrainComponentResponse @@ -142,7 +146,6 @@ namespace TUGraz.VectoCommon.Models AxlegearResponse Axlegear { get; } AngledriveResponse Angledrive { get; } - PerSecond GearboxInputSpeed { get; set; } WheelsResponse Wheels { get; } VehicleResponse Vehicle { get; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs index dda6417a4f..a57d9372f7 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs @@ -345,7 +345,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (response is ResponseGearShift) { //RequestAfterGearshift = false; } - response.GearboxInputSpeed = inAngularVelocity; + response.Gearbox.GearboxInputSpeed = inAngularVelocity; return response; } @@ -356,7 +356,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl retVal = new ResponseGearShift(this); //RequestAfterGearshift = false; } - retVal.GearboxInputSpeed = inAngularVelocity; + retVal.Gearbox.GearboxInputSpeed = inAngularVelocity; return retVal; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs index 1d9477b866..9294cff642 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs @@ -160,7 +160,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl //CurrentState.ESPowerGeneratedICE_On = Auxiliaries.ElectricPowerGenerated; //CurrentState.ESPowerMech = Auxiliaries.ElectricPowerDemandMech; // - signals.EngineStopped = !DataBus.IgnitionOn; + signals.EngineStopped = !DataBus.CombustionEngineOn; signals.VehicleStopped = DataBus.VehicleStopped; busAuxPowerDemand = GetBusAuxPowerDemand( @@ -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.IgnitionOn ? 1.0 : EngineStopStartUtilityFactor); + Auxiliaries.CycleStep(CurrentState.dt, DataBus.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.IgnitionOn ? Auxiliaries.ElectricPowerConsumerSum : Auxiliaries.ElectricPowerGenerated); + container[ModalResultField.P_busAux_ES_generated] = essUtilityFactor * (DataBus.VehicleStopped && !DataBus.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>()); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs index d0db4288f0..2f9a8c3c1a 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -616,7 +616,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var auxTq = DataBus.EngineAuxDemand(avgICDSpeed, operatingPoint.SimulationInterval) / avgICDSpeed; return Tuple.Create( - tc.CalculateOperatingPoint(engSpeed, response.GearboxInputSpeed), drTq - inTq - auxTq, maxTq - inTq - auxTq); + tc.CalculateOperatingPoint(engSpeed, response.Gearbox.GearboxInputSpeed), drTq - inTq - auxTq, maxTq - inTq - auxTq); } @@ -642,7 +642,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl DriverAcceleration = acc; var tmpResponse = NextComponent.Request(absTime, tmp.SimulationInterval, acc, gradient, true); - tmpResponse.OperatingPoint = tmp; + tmpResponse.Driver.OperatingPoint = tmp; return tmpResponse; }, criterion: resp => { @@ -852,7 +852,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl operatingPoint.SimulationInterval) / avgEngineSpeed; var auxTqDemand = DataBus.EngineAuxDemand(avgEngineSpeed, operatingPoint.SimulationInterval) / avgEngineSpeed; //var maxTorque = DataBus.e - var tcOp = tc.CalculateOperatingPoint(DataBus.EngineIdleSpeed * 1.01, response.GearboxInputSpeed); + var tcOp = tc.CalculateOperatingPoint(DataBus.EngineIdleSpeed * 1.01, response.Gearbox.GearboxInputSpeed); if (!tcOp.Item2.IsBetween(dragTorque - inertiaTq - auxTqDemand, maxTorque - inertiaTq - auxTqDemand)) { @@ -1101,7 +1101,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (nanCount > 10) { return true; } - return r != null && !actionRoll && !ds.IsEqual(r.OperatingPoint.SimulationDistance); + return r != null && !actionRoll && !ds.IsEqual(r.Driver.OperatingPoint.SimulationDistance); }); return ComputeTimeInterval(retVal.Acceleration, retVal.SimulationDistance); } catch (VectoSearchAbortedException) { -- GitLab