From 19b58aa89248b305bf50c11225150b23a6f92fa8 Mon Sep 17 00:00:00 2001 From: unknown <michaelkrisper@fvkmb037.vkmthd.tugraz.at> Date: Mon, 1 Feb 2016 15:52:02 +0100 Subject: [PATCH] formatting, adding AbsTime in response for easier debugging --- .../Models/Connector/Ports/Impl/Response.cs | 6 +-- .../Impl/CombustionEngine.cs | 16 +++--- .../Models/SimulationComponent/Impl/Driver.cs | 54 +++++++------------ .../SimulationComponent/Impl/Gearbox.cs | 1 + 4 files changed, 31 insertions(+), 46 deletions(-) diff --git a/VectoCore/Models/Connector/Ports/Impl/Response.cs b/VectoCore/Models/Connector/Ports/Impl/Response.cs index d3e8bb6798..5fd4f08d5a 100644 --- a/VectoCore/Models/Connector/Ports/Impl/Response.cs +++ b/VectoCore/Models/Connector/Ports/Impl/Response.cs @@ -14,9 +14,7 @@ * limitations under the Licence. */ -using System; using System.Linq; -using TUGraz.VectoCore.Models.SimulationComponent; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Connector.Ports.Impl @@ -81,7 +79,9 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl /// </summary> public class ResponseUnderload : ResponseOverload {} - + /// <summary> + /// Response when the Speed Limit was exceeded. + /// </summary> public class ResponseSpeedLimitExceeded : AbstractResponse {} /// <summary> diff --git a/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 3474aa5549..8cd6767aa4 100644 --- a/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -142,11 +142,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ValidatePowerDemand(requestedEnginePower); - if (dryRun) { return new ResponseDryRun { - DeltaFullLoad = (requestedEnginePower - CurrentState.DynamicFullLoadPower), - DeltaDragLoad = (requestedEnginePower - CurrentState.FullDragPower), + DeltaFullLoad = requestedEnginePower - CurrentState.DynamicFullLoadPower, + DeltaDragLoad = requestedEnginePower - CurrentState.FullDragPower, EnginePowerRequest = requestedEnginePower }; } @@ -156,7 +155,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (delta.IsGreater(0.SI<Watt>(), Constants.SimulationSettings.EnginePowerSearchTolerance)) { Log.Debug("requested engine power exceeds fullload power: delta: {0}", delta); - return new ResponseOverload { Delta = delta, EnginePowerRequest = requestedEnginePower, Source = this }; + return new ResponseOverload { + AbsTime = absTime, + Delta = delta, + EnginePowerRequest = requestedEnginePower, + Source = this + }; } if (delta.IsSmaller(0.SI<Watt>(), Constants.SimulationSettings.EnginePowerSearchTolerance)) { @@ -518,9 +522,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl retVal = RequestPort.Request(absTime, dt, torque, nextAngularSpeed); retVal = SearchIdlingSpeed(absTime, dt, torque, nextAngularSpeed, r); }). - Default(r => { - throw new UnexpectedResponseException("searching Idling point", r); - }); + Default(r => { throw new UnexpectedResponseException("searching Idling point", r); }); return retVal; } diff --git a/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/Models/SimulationComponent/Impl/Driver.cs index aa7d163378..2c1601c981 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -154,12 +154,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // Delta is negative we are already below the Drag-load curve. activate breaks retVal = r; // => return, strategy should brake }). - Case<ResponseGearShift>(r => { - retVal = r; - }). - Default(r => { - throw new UnexpectedResponseException("DrivingAction Accelerate.", r); - }); + Case<ResponseGearShift>(r => { retVal = r; }). + Default(r => { throw new UnexpectedResponseException("DrivingAction Accelerate.", r); }); if (retVal == null) { // unhandled response (overload, delta > 0) - we need to search for a valid operating point.. @@ -193,15 +189,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl retVal.Switch(). Case<ResponseSuccess>(() => operatingPoint = nextOperatingPoint). Case<ResponseGearShift>(() => operatingPoint = nextOperatingPoint). - Default(r => { - throw new UnexpectedResponseException("DrivingAction Accelerate after Overload", r); - }); + Default(r => { throw new UnexpectedResponseException("DrivingAction Accelerate after Overload", r); }); }). Case<ResponseGearShift>(() => operatingPoint = limitedOperatingPoint). Case<ResponseSuccess>(() => operatingPoint = limitedOperatingPoint). - Default(r => { - throw new UnexpectedResponseException("DrivingAction Accelerate after SearchOperatingPoint.", r); - }); + Default(r => { throw new UnexpectedResponseException("DrivingAction Accelerate after SearchOperatingPoint.", r); }); } CurrentState.Acceleration = operatingPoint.Acceleration; CurrentState.dt = operatingPoint.SimulationInterval; @@ -242,9 +234,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var retVal = CoastOrRollAction(absTime, ds, maxVelocity, gradient, true); retVal.Switch(). - Case<ResponseGearShift>(() => { - throw new UnexpectedResponseException("DrivingAction Roll: Gearshift during Roll action.", retVal); - }); + Case<ResponseGearShift>( + () => { throw new UnexpectedResponseException("DrivingAction Roll: Gearshift during Roll action.", retVal); }); return retVal; } @@ -327,9 +318,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl MaxDistance = DataBus.VehicleSpeed * r.DeltaT + CurrentState.Acceleration / 2 * r.DeltaT * r.DeltaT }; }). - Default(() => { - throw new UnexpectedResponseException("CoastOrRoll Action: unhandled response from powertrain.", retVal); - }); + Default( + () => { throw new UnexpectedResponseException("CoastOrRoll Action: unhandled response from powertrain.", retVal); }); return retVal; } @@ -384,9 +374,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Source = this, MaxDistance = DataBus.VehicleSpeed * r.DeltaT + operatingPoint.Acceleration / 2 * r.DeltaT * r.DeltaT }). - Default(r => { - throw new UnexpectedResponseException("DrivingAction Brake: first request.", r); - }); + Default(r => { throw new UnexpectedResponseException("DrivingAction Brake: first request.", r); }); if (retVal != null) { retVal.Acceleration = operatingPoint.Acceleration; @@ -424,9 +412,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Source = this, MaxDistance = DataBus.VehicleSpeed * r.DeltaT + operatingPoint.Acceleration / 2 * r.DeltaT * r.DeltaT }). - Default(r => { - throw new UnexpectedResponseException("DrivingAction Brake: request failed after braking power was found.", r); - }); + Default( + r => { + throw new UnexpectedResponseException("DrivingAction Brake: request failed after braking power was found.", r); + }); CurrentState.Acceleration = operatingPoint.Acceleration; CurrentState.dt = operatingPoint.SimulationInterval; CurrentState.Response = retVal; @@ -499,9 +488,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Case<ResponseUnderload>(r => origDelta = DataBus.ClutchClosed(absTime) ? r.Delta : r.GearboxPowerRequest). - Default(r => { - throw new UnexpectedResponseException("cannot use response for searching braking power!", r); - }); + Default(r => { throw new UnexpectedResponseException("cannot use response for searching braking power!", r); }); // braking power is in the range of the exceeding delta. set searching range to 2/3 so that // the target point is approximately in the center of the second interval @@ -589,16 +576,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl initialResponse.Switch(). Case<ResponseDryRun>(r => origDelta = r.GearboxPowerRequest). Case<ResponseFailTimeInterval>(r => origDelta = r.GearboxPowerRequest). - Default(r => { - throw new UnexpectedResponseException("Unknown response type.", r); - }); + Default(r => { throw new UnexpectedResponseException("Unknown response type.", r); }); } else { initialResponse.Switch(). Case<ResponseOverload>(r => origDelta = r.Delta). // search operating point in drive action after overload Case<ResponseDryRun>(r => origDelta = coasting ? r.DeltaDragLoad : r.DeltaFullLoad). - Default(r => { - throw new UnexpectedResponseException("Unknown response type.", r); - }); + Default(r => { throw new UnexpectedResponseException("Unknown response type.", r); }); } var delta = origDelta; @@ -791,9 +774,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var retVal = NextComponent.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), gradient); retVal.Switch(). - Case<ResponseGearShift>(r => { - retVal = NextComponent.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), gradient); - }); + Case<ResponseGearShift>( + r => { retVal = NextComponent.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), gradient); }); CurrentState.dt = dt; CurrentState.Acceleration = 0.SI<MeterPerSquareSecond>(); return retVal; diff --git a/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index 0b9a7efba6..c339dcca79 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -269,6 +269,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if ((outTorque * outAngularVelocity).IsGreater(0.SI<Watt>(), Constants.SimulationSettings.EnginePowerSearchTolerance)) { return new ResponseOverload { + AbsTime = absTime, Source = this, Delta = outTorque * outAngularVelocity, GearboxPowerRequest = outTorque * outAngularVelocity -- GitLab