Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

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

formatting, adding AbsTime in response for easier debugging

parent a6bf95ca
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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
......
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