diff --git a/VectoCore/Models/SimulationComponent/Impl/Clutch.cs b/VectoCore/Models/SimulationComponent/Impl/Clutch.cs index c507bede2f1507c118b6fc6df71d5605d3b8484c..e977fe1c6ff13fa1596e099ab0723780176c79fd 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Clutch.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Clutch.cs @@ -101,7 +101,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl //} else { var engineSpeedNorm = (angularVelocity - _idleSpeed) / (_ratedSpeed - _idleSpeed); - if (engineSpeedNorm < Constants.SimulationSettings.CluchNormSpeed) { + if (DataBus.Gear == 1 && engineSpeedNorm < Constants.SimulationSettings.CluchNormSpeed) { _clutchState = SimulationComponent.ClutchState.ClutchSlipping; var engineSpeed0 = VectoMath.Max(_idleSpeed, angularVelocity); diff --git a/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index c2bd91d43a77273763161d042d40f16e36518c97..d1208a2748f229191f58e1358f16c488316e1d55 100644 --- a/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -147,7 +147,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl //===================================== - public class DriverModeDrive : IDriverMode + public class DriverModeDrive : LoggingObject, IDriverMode { public DefaultDriverStrategy DriverStrategy { get; set; } @@ -184,7 +184,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl //===================================== - public class DriverModeBrake : IDriverMode + public class DriverModeBrake : LoggingObject, IDriverMode { protected enum BrakingPhase { @@ -221,6 +221,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var currentDistance = DriverStrategy.Driver.DataBus.Distance; if (Phase == BrakingPhase.Coast) { var breakingDistance = DriverStrategy.Driver.ComputeDecelerationDistance(DriverStrategy.BrakeTrigger.NextTargetSpeed); + Log.Info("breaking distance: {0}", breakingDistance); if (currentDistance + ds > DriverStrategy.BrakeTrigger.TriggerDistance - breakingDistance) { return new ResponseDrivingCycleDistanceExceeded() { MaxDistance = DriverStrategy.BrakeTrigger.TriggerDistance - breakingDistance - currentDistance @@ -250,7 +251,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl gradient); break; } - // todo: @@@quam: add resonse.switch to indicate expected responses? + return response; } diff --git a/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs index 114986066c3e654bb8af969c12bb513915847251..9743d5a03c8b79d474071dddda7b02441fed4dad 100644 --- a/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs +++ b/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs @@ -206,8 +206,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } // separately test for equality and greater than to have tolerance for equality comparison - if (CurrentState.Distance.IsEqual(CycleIntervalIterator.RightSample.Distance) || - CurrentState.Distance > CycleIntervalIterator.RightSample.Distance) { + if (CurrentState.Distance.IsGreaterOrEqual(CycleIntervalIterator.RightSample.Distance)) { // we have reached the end of the current interval in the cycle, move on... CycleIntervalIterator.MoveNext(); } @@ -295,6 +294,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { // cycleIndex has to be max. next to last (so that rightSample is still valid. if (CurrentCycleIndex >= Data.Entries.Count - 2) { + LastEntry = true; return false; } CurrentCycleIndex++; diff --git a/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/Models/SimulationComponent/Impl/Driver.cs index 6657405b07b072d08a380dff57c4edaa98267ed9..abff49fabbe6fd29968a1424feb852fadc117fc9 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -163,12 +163,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var retVal = CoastOrRollAction(absTime, ds, maxVelocity, gradient); retVal.Switch(). - //Case<ResponseFailTimeInterval>(r => { - // retVal = new ResponseDrivingCycleDistanceExceeded() { - // Source = r.Source, - // MaxDistance = - // }; - //}). Case<ResponseGearShift>(() => { throw new UnexpectedResponseException("DrivingAction Roll: Gearshift during Roll action", retVal); }); @@ -267,6 +261,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Case<ResponseOverload>(r => retVal = r). Case<ResponseUnderload>(). // will be handled in SearchBrakingPower Case<ResponseGearShift>(). // will be handled in SearchBrakingPower + Case<ResponseFailTimeInterval>(r => retVal = new ResponseDrivingCycleDistanceExceeded() { + Source = this, + MaxDistance = DataBus.VehicleSpeed() * r.DeltaT + operatingPoint.Acceleration / 2 * r.DeltaT * r.DeltaT + }). Default(r => { throw new UnexpectedResponseException("DrivingAction Brake: first request", r); }); @@ -453,8 +451,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl searchInterval *= intervalFactor; retVal.Acceleration += searchInterval * -delta.Sign(); - if (retVal.Acceleration < (curve.Deceleration - Constants.SimulationSettings.MinimumAcceleration) - || retVal.Acceleration > (curve.Acceleration + Constants.SimulationSettings.MinimumAcceleration)) { + if (retVal.Acceleration < (DriverData.AccelerationCurve.MaxDeceleration() - searchInterval) + || retVal.Acceleration > (DriverData.AccelerationCurve.MaxAcceleration() + searchInterval)) { throw new VectoSimulationException( "Could not find an operating point: operating point outside of driver acceleration limits."); } diff --git a/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index 028719789135433a94cfbe19f2d0154fec099970..972893a7bab311094b29ff1886770fd8b910001d 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -117,12 +117,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } if (!outTorque.IsEqual(0, Constants.SimulationSettings.EngineFLDPowerTolerance)) { + if (outTorque > 0) { return new ResponseOverload { Delta = outTorque * outEngineSpeed, Source = this, GearboxPowerRequest = outTorque * outEngineSpeed }; } + return new ResponseUnderload { + Delta = outTorque * outEngineSpeed, + Source = this, + GearboxPowerRequest = outTorque * outEngineSpeed + }; + } var neutralResponse = Next.Request(absTime, dt, 0.SI<NewtonMeter>(), null); neutralResponse.GearboxPowerRequest = outTorque * outEngineSpeed; diff --git a/VectoCoreTest/Integration/DriverStrategy/DriverStrategyTest.cs b/VectoCoreTest/Integration/DriverStrategy/DriverStrategyTest.cs index 8ae5fd713db1b86b995d1551e1afad4c063521e2..a51beb17cb182e49b7e0cfa267412f691aaddb60 100644 --- a/VectoCoreTest/Integration/DriverStrategy/DriverStrategyTest.cs +++ b/VectoCoreTest/Integration/DriverStrategy/DriverStrategyTest.cs @@ -20,7 +20,7 @@ namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy [TestClass] public class DriverStrategyTest { - public const string AccelerationFile = @"TestData\Components\Coach.vacc"; + public const string AccelerationFile = @"TestData\Components\Truck.vacc"; public const string EngineFile = @"TestData\Components\24t Coach.veng"; @@ -39,7 +39,7 @@ namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy "900, 85, 0, 0", }); - var run = CreatePowerTrain(cycle, "DriverStrategy_Accelerate_0_80_level.vmod"); + var run = CreatePowerTrain(cycle, "DriverStrategy_Accelerate_0_85_level.vmod"); run.Run(); } @@ -50,11 +50,11 @@ namespace TUGraz.VectoCore.Tests.Integration.DriverStrategy { var cycle = CreateCycleData(new[] { // <s>,<v>,<grad>,<stop> - " 0, 80, 0, 0", - "900, 0, 0, 0", + " 0, 10, 0, 0", + "500, 0, 0, 0", }); - var run = CreatePowerTrain(cycle, "DriverStrategy_Accelerate_0_80_level.vmod"); + var run = CreatePowerTrain(cycle, "DriverStrategy_Accelerate_80_0_level.vmod"); run.Run(); }