diff --git a/VectoCore/Models/Connector/Ports/Impl/Response.cs b/VectoCore/Models/Connector/Ports/Impl/Response.cs index d3e8bb679843a30e4b99f6a90dd5b494a58166c9..5fd4f08d5a90b5fb9d30195d2aec7ec55e7fc76b 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 3474aa5549ea2c8679b6e44ca5c42f8344a1c046..8cd6767aa4c52e027ff3da5f779c471525f87ad5 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 aa7d1633784e3802a36a9790238f47ca705516b7..2c1601c98112b64122d098f5f0d1a8de9cc24615 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 0b9a7efba6ec5093b3499944cf054500599b3072..c339dcca799acbe48cc788928e51194dad417c78 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