Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 3baeac16 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

finally found solution for full powertrain test

parent 98eef69e
No related branches found
No related tags found
No related merge requests found
......@@ -96,7 +96,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var currentDistance = DataBus.Distance();
var nextDrivingActions = GetNextDrivingActions(currentDistance);
Log.DebugFormat(", ".Join(nextDrivingActions.Select(x => string.Format("[{0}]: {1}", x.ActionDistance, x.Action))));
Log.DebugFormat(", ".Join(nextDrivingActions.Select(x => string.Format("({0}: {1})", x.ActionDistance, x.Action))));
if (CurrentState.DrivingAction.Action == DrivingBehavior.Stopped && targetVelocity >= DataBus.VehicleSpeed()) {
......@@ -196,6 +196,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var searchInterval = Constants.SimulationSettings.BreakingPowerInitialSearchInterval;
var originalDs = ds;
Watt previousDelta = null;
do {
ds = originalDs;
......@@ -203,6 +204,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
? -response.DeltaDragLoad
: -response.AxlegearPowerRequest;
if (previousDelta == null) {
previousDelta = 2 * delta;
}
exceeded.Add(delta);
if (delta.IsEqual(0, Constants.SimulationSettings.EngineFLDPowerTolerance)) {
Log.DebugFormat("found operating point in {0} iterations, delta: {1}", exceeded.Count, delta);
......@@ -210,7 +215,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
breakingPower += searchInterval * (delta > 0 ? -1 : 1);
searchInterval /= 2.0;
searchInterval /= VectoMath.Limit((previousDelta / delta).Cast<Scalar>(), 1.1, 2.0);
previousDelta = delta;
CurrentState.dt = ComputeTimeInterval(CurrentState.Acceleration, ref ds);
DataBus.BreakPower = breakingPower;
......@@ -358,7 +365,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Log.DebugFormat("Limiting coasting deceleration from {0} to {1}", CurrentState.Acceleration,
DeclarationData.Driver.LookAhead.Deceleration);
CurrentState.Acceleration = DeclarationData.Driver.LookAhead.Deceleration;
CurrentState.dt = ComputeTimeInterval(CurrentState.Acceleration, ref ds);
//CurrentState.dt = ComputeTimeInterval(CurrentState.Acceleration, ref ds);
Log.DebugFormat("Changed dt due to limited coasting deceleration. dt: {0}", CurrentState.dt);
}
......@@ -430,6 +437,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
throw new VectoSimulationException("Could not achieve minimum acceleration");
}
searchInterval /= 2.0;
CurrentState.dt = ComputeTimeInterval(CurrentState.Acceleration, ref ds);
response = Next.Request(absTime, CurrentState.dt, CurrentState.Acceleration, gradient, true);
} while (CurrentState.RetryCount++ < Constants.SimulationSettings.DriverSearchLoopThreshold);
......
......@@ -73,16 +73,16 @@ namespace TUGraz.VectoCore.Utils
return c1.CompareTo(c2) >= 0 ? c1 : c2;
}
public static T Limit<T>(T value, T lowerBound, T upperBound) where T : SIBase<T>
public static T Limit<T>(T value, T lowerBound, T upperBound) where T : IComparable
{
if (lowerBound > upperBound) {
if (lowerBound.CompareTo(upperBound) > 0) {
throw new VectoException("VectoMath.Limit: lowerBound must not be greater than upperBound");
}
if (value > upperBound) {
if (value.CompareTo(upperBound) > 0) {
return upperBound;
}
if (value < lowerBound) {
if (value.CompareTo(lowerBound) < 0) {
return lowerBound;
}
return value;
......
......@@ -89,10 +89,8 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns
}).
Default(r => Assert.Fail("Unexpected Response: {0}", r));
}
Assert.IsInstanceOfType(response, typeof(ResponseCycleFinished));
modalWriter.Finish();
Assert.IsInstanceOfType(response, typeof(ResponseCycleFinished));
}
[TestMethod]
......@@ -135,7 +133,12 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns
var cnt = 0;
while (!(response is ResponseCycleFinished) && container.Distance().Value() < 17000) {
Log.InfoFormat("Test New Request absTime: {0}, ds: {1}", absTime, ds);
response = cyclePort.Request(absTime, ds);
try {
response = cyclePort.Request(absTime, ds);
} catch (Exception) {
modalWriter.Finish();
throw;
}
Log.InfoFormat("Test Got Response: {0},", response);
response.Switch().
......@@ -156,10 +159,8 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns
}).
Default(r => Assert.Fail("Unexpected Response: {0}", r));
}
Assert.IsInstanceOfType(response, typeof(ResponseCycleFinished));
modalWriter.Finish();
Assert.IsInstanceOfType(response, typeof(ResponseCycleFinished));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment