Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

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

Improved DebugData and DebuggerDisplay Output

parent 4adfc30b
Branches
Tags
No related merge requests found
...@@ -18,6 +18,7 @@ namespace TUGraz.VectoCommon.Models { ...@@ -18,6 +18,7 @@ namespace TUGraz.VectoCommon.Models {
public GearboxResponse GearboxResponse { get; set; } public GearboxResponse GearboxResponse { get; set; }
} }
[DebuggerDisplay("HybridStrategyResponse(Gear: {NextGear})")]
public class HybridStrategyResponse : AbstractComponentResponse, IHybridStrategyResponse public class HybridStrategyResponse : AbstractComponentResponse, IHybridStrategyResponse
{ {
public Dictionary<PowertrainPosition, Tuple<PerSecond, NewtonMeter>> MechanicalAssistPower; public Dictionary<PowertrainPosition, Tuple<PerSecond, NewtonMeter>> MechanicalAssistPower;
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
*/ */
using System; using System;
using System.Diagnostics;
using System.Linq; using System.Linq;
using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils; using TUGraz.VectoCommon.Utils;
...@@ -38,8 +39,6 @@ using TUGraz.VectoCore.Models.SimulationComponent.Impl; ...@@ -38,8 +39,6 @@ using TUGraz.VectoCore.Models.SimulationComponent.Impl;
namespace TUGraz.VectoCore.Models.Connector.Ports.Impl namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
{ {
public abstract class AbstractResponse : IResponse public abstract class AbstractResponse : IResponse
{ {
public AbstractResponse(object source) public AbstractResponse(object source)
...@@ -106,17 +105,17 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl ...@@ -106,17 +105,17 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
public HybridControllerResponse HybridController { get; set; } public HybridControllerResponse HybridController { get; set; }
//public override string ToString()
public override string ToString() //{
{ // var t = GetType();
var t = GetType(); // return $"{t.Name}{{{t.GetProperties().Select(p => $"{p.Name}: {p.GetValue(this)}").Join()}}}";
return $"{t.Name}{{{t.GetProperties().Select(p => $"{p.Name}: {p.GetValue(this)}").Join()}}}"; //}
}
} }
/// <summary> /// <summary>
/// Response when the Cycle is finished. /// Response when the Cycle is finished.
/// </summary> /// </summary>
[DebuggerDisplay("CycleFinished")]
public class ResponseCycleFinished : AbstractResponse { public class ResponseCycleFinished : AbstractResponse {
public ResponseCycleFinished(object source) : base(source) { } public ResponseCycleFinished(object source) : base(source) { }
} }
...@@ -124,10 +123,12 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl ...@@ -124,10 +123,12 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
/// <summary> /// <summary>
/// Response when a request was successful. /// Response when a request was successful.
/// </summary> /// </summary>
[DebuggerDisplay("Success({AbsTime,nq}, {Driver.OperatingPoint,nq})")]
public class ResponseSuccess : AbstractResponse { public class ResponseSuccess : AbstractResponse {
public ResponseSuccess(object source) : base(source) { } public ResponseSuccess(object source) : base(source) { }
} }
[DebuggerDisplay("BatteryEmpty")]
public class ResponseBatteryEmpty : AbstractResponse public class ResponseBatteryEmpty : AbstractResponse
{ {
public ResponseBatteryEmpty(object source, IElectricSystemResponse electricSupplyResponse) : base(source) { } public ResponseBatteryEmpty(object source, IElectricSystemResponse electricSupplyResponse) : base(source) { }
...@@ -136,6 +137,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl ...@@ -136,6 +137,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
/// <summary> /// <summary>
/// Response when the request resulted in an engine or gearbox overload. /// Response when the request resulted in an engine or gearbox overload.
/// </summary> /// </summary>
[DebuggerDisplay("Overload({Delta,nq})")]
public class ResponseOverload : AbstractResponse public class ResponseOverload : AbstractResponse
{ {
public Watt Delta { get; set; } public Watt Delta { get; set; }
...@@ -145,6 +147,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl ...@@ -145,6 +147,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
/// <summary> /// <summary>
/// Response when the request resulted in an engine under-load. /// Response when the request resulted in an engine under-load.
/// </summary> /// </summary>
[DebuggerDisplay("Underload({Delta,nq})")]
public class ResponseUnderload : AbstractResponse public class ResponseUnderload : AbstractResponse
{ {
public Watt Delta { get; set; } public Watt Delta { get; set; }
...@@ -154,6 +157,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl ...@@ -154,6 +157,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
/// <summary> /// <summary>
/// Response when the Speed Limit was exceeded. /// Response when the Speed Limit was exceeded.
/// </summary> /// </summary>
[DebuggerDisplay("SpeedLimitExceeded")]
public class ResponseSpeedLimitExceeded : AbstractResponse public class ResponseSpeedLimitExceeded : AbstractResponse
{ {
public ResponseSpeedLimitExceeded(object source) : base(source) { } public ResponseSpeedLimitExceeded(object source) : base(source) { }
...@@ -162,6 +166,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl ...@@ -162,6 +166,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
/// <summary> /// <summary>
/// Response when the request should have another time interval. /// Response when the request should have another time interval.
/// </summary> /// </summary>
[DebuggerDisplay("FailTimeInterval({DeltaT,nq})")]
public class ResponseFailTimeInterval : AbstractResponse public class ResponseFailTimeInterval : AbstractResponse
{ {
public ResponseFailTimeInterval(object source) : base(source) { } public ResponseFailTimeInterval(object source) : base(source) { }
...@@ -169,12 +174,14 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl ...@@ -169,12 +174,14 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
public Second DeltaT { get; set; } public Second DeltaT { get; set; }
} }
[DebuggerDisplay("DistanceExceeded({MaxDistance,nq})")]
public class ResponseDrivingCycleDistanceExceeded : AbstractResponse public class ResponseDrivingCycleDistanceExceeded : AbstractResponse
{ {
public ResponseDrivingCycleDistanceExceeded(object source) : base(source) { } public ResponseDrivingCycleDistanceExceeded(object source) : base(source) { }
public Meter MaxDistance { get; set; } public Meter MaxDistance { get; set; }
} }
[DebuggerDisplay("DryRun({DeltaFullLoad,nq}, {DeltaDragLoad,nq}, {DeltaEngineSpeed,nq})")]
public class ResponseDryRun : AbstractResponse public class ResponseDryRun : AbstractResponse
{ {
public ResponseDryRun(object source) : base(source) { } public ResponseDryRun(object source) : base(source) { }
...@@ -191,6 +198,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl ...@@ -191,6 +198,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
public PerSecond DeltaEngineSpeed { get; set; } public PerSecond DeltaEngineSpeed { get; set; }
} }
[DebuggerDisplay("GearShift")]
internal class ResponseGearShift : AbstractResponse internal class ResponseGearShift : AbstractResponse
{ {
public ResponseGearShift(object source) : base(source) { } public ResponseGearShift(object source) : base(source) { }
...@@ -198,11 +206,13 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl ...@@ -198,11 +206,13 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
public ResponseGearShift(object source, IResponse subResponse) : base(source, subResponse) { } public ResponseGearShift(object source, IResponse subResponse) : base(source, subResponse) { }
} }
[DebuggerDisplay("DifferentGearEngaged")]
internal class ResponseDifferentGearEngaged : AbstractResponse internal class ResponseDifferentGearEngaged : AbstractResponse
{ {
public ResponseDifferentGearEngaged(object source) : base(source) { } public ResponseDifferentGearEngaged(object source) : base(source) { }
} }
[DebuggerDisplay("InvalidOperatingPoint")]
internal class ResponseInvalidOperatingPoint : AbstractResponse internal class ResponseInvalidOperatingPoint : AbstractResponse
{ {
public ResponseInvalidOperatingPoint(object source) : base(source) { } public ResponseInvalidOperatingPoint(object source) : base(source) { }
...@@ -212,6 +222,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl ...@@ -212,6 +222,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
internal class ResponseEngineSpeedTooLow : ResponseDryRun {} internal class ResponseEngineSpeedTooLow : ResponseDryRun {}
*/ */
[DebuggerDisplay("EngineSpeedTooHigh({DeltaEngineSpeed,nq})")]
internal class ResponseEngineSpeedTooHigh : AbstractResponse internal class ResponseEngineSpeedTooHigh : AbstractResponse
{ {
public ResponseEngineSpeedTooHigh(object source) : base(source) { } public ResponseEngineSpeedTooHigh(object source) : base(source) { }
......
...@@ -85,7 +85,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -85,7 +85,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
if (loopCount++ > Constants.SimulationSettings.MaximumIterationCountForSimulationStep) { if (loopCount++ > Constants.SimulationSettings.MaximumIterationCountForSimulationStep) {
throw new VectoSimulationException("Maximum iteration count for a single simulation interval reached! Aborting!"); throw new VectoSimulationException("Maximum iteration count for a single simulation interval reached! Aborting!");
} }
debug.Add(new {Response = response}); debug.Add(response);
} while (!(response is ResponseSuccess || response is ResponseCycleFinished || response is ResponseBatteryEmpty)); } while (!(response is ResponseSuccess || response is ResponseCycleFinished || response is ResponseBatteryEmpty));
IterationStatistics.Increment(this, "Distance", Container.MileageCounter.Distance.Value()); IterationStatistics.Increment(this, "Distance", Container.MileageCounter.Distance.Value());
......
...@@ -105,6 +105,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -105,6 +105,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
do { do {
response = DoSimulationStep(); response = DoSimulationStep();
debug.Trim();
debug.Add(response); debug.Add(response);
if (response is ResponseSuccess) { if (response is ResponseSuccess) {
Container.CommitSimulationStep(AbsTime, dt); Container.CommitSimulationStep(AbsTime, dt);
......
...@@ -255,7 +255,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -255,7 +255,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var loop = false; var loop = false;
SetPowershiftLossEnergy(absTime, dt, outTorque, outAngularVelocity); SetPowershiftLossEnergy(absTime, dt, outTorque, outAngularVelocity);
do { do {
if (CurrentState.Disengaged || (DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Halted) || (DisengageGearbox && !ModelData.ATEcoRollReleaseLockupClutch)) { if (CurrentState.Disengaged
|| DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Halted
|| DisengageGearbox && !ModelData.ATEcoRollReleaseLockupClutch) {
// only when vehicle is halted or close before halting or during eco-roll events // only when vehicle is halted or close before halting or during eco-roll events
retVal = RequestDisengaged(absTime, dt, outTorque, outAngularVelocity, dryRun); retVal = RequestDisengaged(absTime, dt, outTorque, outAngularVelocity, dryRun);
} else { } else {
......
...@@ -911,18 +911,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -911,18 +911,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
} }
var response = Driver.DrivingActionRoll(absTime, ds, velocity, gradient); var response = Driver.DrivingActionRoll(absTime, ds, velocity, gradient);
debug.Add(new { a = "[HRD-0] ClutchOpen -> Roll", response }); debug.Add("[HRD-0] ClutchOpen -> Roll", response);
switch (response) { switch (response) {
case ResponseUnderload _ when DataBus.ClutchInfo.ClutchClosed(absTime): case ResponseUnderload _ when DataBus.ClutchInfo.ClutchClosed(absTime):
response = HandleRequestEngaged(absTime, ds, velocity, gradient, false, velocity, debug); response = HandleRequestEngaged(absTime, ds, velocity, gradient, false, velocity, debug);
break; break;
case ResponseUnderload _ when !DataBus.ClutchInfo.ClutchClosed(absTime): case ResponseUnderload _ when !DataBus.ClutchInfo.ClutchClosed(absTime):
response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient, response); response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient, response);
debug.Add(new { a = "[HRD-1] Roll:Underload -> Brake", response }); debug.Add("[HRD-1] Roll:Underload -> Brake", response);
break; break;
case ResponseSpeedLimitExceeded _: case ResponseSpeedLimitExceeded _:
response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient); response = Driver.DrivingActionBrake(absTime, ds, velocity, gradient);
debug.Add(new { a = "[HRD-2] Roll:SpeedLimitExceeded -> Brake", response }); debug.Add("[HRD-2] Roll:SpeedLimitExceeded -> Brake", response);
break; break;
} }
return response; return response;
...@@ -941,12 +941,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -941,12 +941,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && !DataBus.ClutchInfo.ClutchClosed(absTime)) { if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && !DataBus.ClutchInfo.ClutchClosed(absTime)) {
//TODO mk20210616 the whole statement could be de-nested to switch-pattern matching (with "where") if this first "if" would not be here. //TODO mk20210616 the whole statement could be de-nested to switch-pattern matching (with "where") if this first "if" would not be here.
var debugResponse = Driver.DrivingActionRoll(absTime, ds, velocityWithOverspeed, gradient); var debugResponse = Driver.DrivingActionRoll(absTime, ds, velocityWithOverspeed, gradient);
debug.Add(new { a = "[HRE-0] (Underload&Overspeed)->Roll", second }); debug.Add("[HRE-0] (Underload&Overspeed)->Roll", second);
} }
if (DataBus.VehicleInfo.VehicleSpeed.IsGreater(0) && DriverStrategy.IsOverspeedAllowed(targetVelocity, prohibitOverspeed)) { if (DataBus.VehicleInfo.VehicleSpeed.IsGreater(0) && DriverStrategy.IsOverspeedAllowed(targetVelocity, prohibitOverspeed)) {
second = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); second = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient);
debug.Add(new { a = "[HRE-1] (Underload&Overspeed)->Coast", second }); debug.Add("[HRE-1] (Underload&Overspeed)->Coast", second);
second = HandleCoastAfterUnderloadWithOverspeed(absTime, ds, gradient, velocityWithOverspeed, debug, second); second = HandleCoastAfterUnderloadWithOverspeed(absTime, ds, gradient, velocityWithOverspeed, debug, second);
} else { } else {
// overrideAction: in case of hybrids with an AT gearbox after an underload we search for braking power because the torque converter // overrideAction: in case of hybrids with an AT gearbox after an underload we search for braking power because the torque converter
...@@ -964,7 +964,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -964,7 +964,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
: (DrivingAction?)null; : (DrivingAction?)null;
second = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient, second = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient,
overrideAction: overrideAction); overrideAction: overrideAction);
debug.Add(new { a = "[HRE-2] (Underload&!Overspeed)->Brake", second }); debug.Add("[HRE-2] (Underload&!Overspeed)->Brake", second);
} }
break; break;
case ResponseEngineSpeedTooHigh _: case ResponseEngineSpeedTooHigh _:
...@@ -972,7 +972,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -972,7 +972,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
break; break;
case ResponseSpeedLimitExceeded _: case ResponseSpeedLimitExceeded _:
second = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient); second = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient);
debug.Add(new { a = "[HRE-3] SpeedLimitExceeded->Brake", second }); debug.Add("[HRE-3] SpeedLimitExceeded->Brake", second);
break; break;
} }
...@@ -985,40 +985,40 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -985,40 +985,40 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
switch (second) { switch (second) {
case ResponseGearShift _: case ResponseGearShift _:
third = Driver.DrivingActionRoll(absTime, ds, velocityWithOverspeed, gradient); third = Driver.DrivingActionRoll(absTime, ds, velocityWithOverspeed, gradient);
debug.Add(new { a = "[HRE-4] second: GearShift -> Roll", third }); debug.Add("[HRE-4] second: GearShift -> Roll", third);
switch (third) { switch (third) {
case ResponseOverload _: case ResponseOverload _:
third = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); third = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient);
debug.Add(new { a = "[HRE-5] third:Overload -> try again Coast", third }); debug.Add("[HRE-5] third:Overload -> try again Coast", third);
break; break;
case ResponseUnderload _: case ResponseUnderload _:
// underload may happen if driver limits acceleration when rolling downhill // underload may happen if driver limits acceleration when rolling downhill
third = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient); third = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient);
debug.Add(new { a = "[HRE-6] third:Underload -> Brake", third }); debug.Add("[HRE-6] third:Underload -> Brake", third);
break; break;
case ResponseSpeedLimitExceeded _: case ResponseSpeedLimitExceeded _:
third = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient); third = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient);
debug.Add(new { a = "[HRE-7] third:SpeedLimitExceeded -> Brake", third }); debug.Add("[HRE-7] third:SpeedLimitExceeded -> Brake", third);
break; break;
} }
break; break;
case ResponseOverload _ when DataBus.VehicleInfo.VehicleSpeed.IsGreater(0): case ResponseOverload _ when DataBus.VehicleInfo.VehicleSpeed.IsGreater(0):
third = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); third = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient);
debug.Add(new { a = "[HRE-8] second:Overload -> Coast", third }); debug.Add("[HRE-8] second:Overload -> Coast", third);
switch (third) { switch (third) {
case ResponseGearShift _: case ResponseGearShift _:
third = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); third = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient);
debug.Add(new { a = "[HRE-9] third:GearShift -> try again Coast", third }); debug.Add("[HRE-9] third:GearShift -> try again Coast", third);
break; break;
case ResponseSpeedLimitExceeded _: case ResponseSpeedLimitExceeded _:
if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() &&
!DataBus.GearboxInfo.Gear.IsLockedGear()) { !DataBus.GearboxInfo.Gear.IsLockedGear()) {
third = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed + 1.KMPHtoMeterPerSecond(), gradient); third = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed + 1.KMPHtoMeterPerSecond(), gradient);
debug.Add(new { a = "[HRE-10] third:Overload (AT, Converter gear) -> Coast", third }); debug.Add("[HRE-10] third:Overload (AT, Converter gear) -> Coast", third);
} else { } else {
third = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient); third = Driver.DrivingActionBrake(absTime, ds, velocityWithOverspeed, gradient);
debug.Add(new { a = "[HRE-11] third:SpeedLimitExceeded -> Brake", third }); debug.Add("[HRE-11] third:SpeedLimitExceeded -> Brake", third);
} }
break; break;
...@@ -1034,11 +1034,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -1034,11 +1034,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{ {
if (second is ResponseUnderload || second is ResponseSpeedLimitExceeded) { if (second is ResponseUnderload || second is ResponseSpeedLimitExceeded) {
second = Driver.DrivingActionBrake(absTime, ds, velocity, gradient); second = Driver.DrivingActionBrake(absTime, ds, velocity, gradient);
debug.Add(new { a = "[HCAUWO-0] second:(Underload|SpeedLimitExceeded) -> Brake", second }); debug.Add("[HCAUWO-0] second:(Underload|SpeedLimitExceeded) -> Brake", second);
} }
if (second is ResponseEngineSpeedTooHigh) { if (second is ResponseEngineSpeedTooHigh) {
second = Driver.DrivingActionBrake(absTime, ds, velocity, gradient, second); second = Driver.DrivingActionBrake(absTime, ds, velocity, gradient, second);
debug.Add(new { a = "[HCAUWO-1] second:(EngineSpeedTooHigh|SpeedLimitExceeded) -> Brake with reduced acceleration", second }); debug.Add("[HCAUWO-1] second:(EngineSpeedTooHigh|SpeedLimitExceeded) -> Brake with reduced acceleration", second);
} }
return second; return second;
} }
...@@ -1048,7 +1048,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -1048,7 +1048,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{ {
if (DriverStrategy.pccState == PCCStates.UseCase1 || DriverStrategy.pccState == PCCStates.UseCase2) { if (DriverStrategy.pccState == PCCStates.UseCase1 || DriverStrategy.pccState == PCCStates.UseCase2) {
var response = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); var response = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient);
debug.Add(new { a = "[FAOC-0] Coast", response }); debug.Add("[FAOC-0] Coast", response);
if (response is ResponseSuccess) { if (response is ResponseSuccess) {
return response; return response;
} }
...@@ -1060,27 +1060,27 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -1060,27 +1060,27 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
//we are driving in overspeed (VehicleSpeed >= targetVelocity) //we are driving in overspeed (VehicleSpeed >= targetVelocity)
var response = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); var response = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient);
debug.Add(new { a = "[FAOC-1] Coast", response }); debug.Add("[FAOC-1] Coast", response);
if (response is ResponseSuccess if (response is ResponseSuccess
&& response.Driver.Acceleration < 0 && response.Vehicle.VehicleSpeed <= targetVelocity) { && response.Driver.Acceleration < 0 && response.Vehicle.VehicleSpeed <= targetVelocity) {
//do accelerate action if we would come below targetVelocity due to coasting //do accelerate action if we would come below targetVelocity due to coasting
response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient); response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient);
debug.Add(new { a = "[FAOC-2] Accelerate(Success && Acc<0 && VehSpeed <= targetVelocity)", response }); debug.Add("[FAOC-2] Accelerate(Success && Acc<0 && VehSpeed <= targetVelocity)", response);
} }
if (response is ResponseOverload if (response is ResponseOverload
&& DataBus.PowertrainInfo.HasCombustionEngine && !DataBus.EngineInfo.EngineOn) { && DataBus.PowertrainInfo.HasCombustionEngine && !DataBus.EngineInfo.EngineOn) {
response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient); response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient);
debug.Add(new { a = "[FAOC-3] Accelerate(Overload && ICE off)", response }); debug.Add("[FAOC-3] Accelerate(Overload && ICE off)", response);
} }
if (response is ResponseOverload if (response is ResponseOverload
&& !DataBus.PowertrainInfo.HasCombustionEngine) { && !DataBus.PowertrainInfo.HasCombustionEngine) {
response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient); response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient);
debug.Add(new { a = "[FAOC-4] Accelerate(Overload && BEV)", response }); debug.Add("[FAOC-4] Accelerate(Overload && BEV)", response);
} }
if (response is ResponseOverload) { if (response is ResponseOverload) {
response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient); response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient);
debug.Add(new { a = "[FAOC-5] Accelerate(Overload)", response }); debug.Add("[FAOC-5] Accelerate(Overload)", response);
} }
return response; return response;
} else { } else {
...@@ -1088,11 +1088,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -1088,11 +1088,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && DataBus.GearboxInfo.DisengageGearbox) { if (DataBus.GearboxInfo.GearboxType.AutomaticTransmission() && DataBus.GearboxInfo.DisengageGearbox) {
var response = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient); var response = Driver.DrivingActionCoast(absTime, ds, velocityWithOverspeed, gradient);
debug.Add(new { a = "[FAOC-6] Coast", response }); debug.Add("[FAOC-6] Coast", response);
return response; return response;
} else { } else {
var response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient); var response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient);
debug.Add(new { a = "[FAOC-7] Accelerate", response }); debug.Add("[FAOC-7] Accelerate", response);
return response; return response;
} }
} }
...@@ -1244,17 +1244,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -1244,17 +1244,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
} }
response = Driver.DrivingActionAccelerate(absTime, ds, 1.KMPHtoMeterPerSecond(), gradient); response = Driver.DrivingActionAccelerate(absTime, ds, 1.KMPHtoMeterPerSecond(), gradient);
debug.Add(new { a = "[DB-] Accelerate", response }); debug.Add("[DB-] Accelerate", response);
if (response is ResponseUnderload) { if (response is ResponseUnderload) {
response = Driver.DrivingActionBrake(absTime, ds, 1.KMPHtoMeterPerSecond(), gradient, response, response = Driver.DrivingActionBrake(absTime, ds, 1.KMPHtoMeterPerSecond(), gradient, response,
overrideAction: DrivingAction.Accelerate); overrideAction: DrivingAction.Accelerate);
debug.Add(new { a = "[DB-2] Brake", response }); debug.Add("[DB-2] Brake", response);
} }
} else { } else {
response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed,
gradient, targetDistance: targetDistance); gradient, targetDistance: targetDistance);
debug.Add(new { a = "[DB-3] Brake", response }); debug.Add("[DB-3] Brake", response);
} }
if ((DataBus.GearboxInfo.GearboxType.AutomaticTransmission() || DataBus.HybridControllerInfo != null) if ((DataBus.GearboxInfo.GearboxType.AutomaticTransmission() || DataBus.HybridControllerInfo != null)
...@@ -1263,7 +1263,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -1263,7 +1263,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
DataBus.Brakes.BrakePower = 0.SI<Watt>(); DataBus.Brakes.BrakePower = 0.SI<Watt>();
response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed,
gradient, targetDistance: targetDistance); gradient, targetDistance: targetDistance);
debug.Add(new { a = "[DB-4] Brake", response }); debug.Add("[DB-4] Brake", response);
} }
if (response == null) { if (response == null) {
...@@ -1276,10 +1276,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -1276,10 +1276,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
if (!DataBus.ClutchInfo.ClutchClosed(absTime)) { if (!DataBus.ClutchInfo.ClutchClosed(absTime)) {
Log.Info("Brake -> Overload -> Clutch is open - Trying roll action"); Log.Info("Brake -> Overload -> Clutch is open - Trying roll action");
response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient);
debug.Add(new { a = "[DB-5] Roll", response }); debug.Add("[DB-5] Roll", response);
if (response is ResponseSpeedLimitExceeded) { if (response is ResponseSpeedLimitExceeded) {
response = Driver.DrivingActionBrake(absTime, ds, targetVelocity, gradient); response = Driver.DrivingActionBrake(absTime, ds, targetVelocity, gradient);
debug.Add(new { a = "[DB-6] Brake", response }); debug.Add("[DB-6] Brake", response);
} }
} else { } else {
Log.Info("Brake -> Overload -> Clutch is closed - Trying brake action again"); Log.Info("Brake -> Overload -> Clutch is closed - Trying brake action again");
...@@ -1287,16 +1287,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -1287,16 +1287,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
DataBus.HybridControllerCtl?.RepeatDrivingAction(absTime); DataBus.HybridControllerCtl?.RepeatDrivingAction(absTime);
response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed,
gradient, targetDistance: targetDistance); gradient, targetDistance: targetDistance);
debug.Add(new { a = "[DB-7] Brake", response }); debug.Add("[DB-7] Brake", response);
if (response is ResponseOverload) { if (response is ResponseOverload) {
Log.Info("Brake -> Overload -> 2nd Brake -> Overload -> Trying accelerate action"); Log.Info("Brake -> Overload -> 2nd Brake -> Overload -> Trying accelerate action");
var gear = DataBus.GearboxInfo.Gear; var gear = DataBus.GearboxInfo.Gear;
if (DataBus.GearboxInfo.GearEngaged(absTime)) { if (DataBus.GearboxInfo.GearEngaged(absTime)) {
response = Driver.DrivingActionAccelerate(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); response = Driver.DrivingActionAccelerate(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient);
debug.Add(new { a = "[DB-8] Accelerate", response }); debug.Add("[DB-8] Accelerate", response);
} else { } else {
response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient);
debug.Add(new { a = "[DB-9] Roll", response }); debug.Add("[DB-9] Roll", response);
} }
switch (response) { switch (response) {
...@@ -1304,14 +1304,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -1304,14 +1304,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Log.Info("Brake -> Overload -> 2nd Brake -> Accelerate or Roll -> Got GearShift response, performing roll action"); Log.Info("Brake -> Overload -> 2nd Brake -> Accelerate or Roll -> Got GearShift response, performing roll action");
response = Driver.DrivingActionRoll(absTime, ds, response = Driver.DrivingActionRoll(absTime, ds,
DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient);
debug.Add(new { a = "[DB-12] Roll", response }); debug.Add("[DB-12] Roll", response);
break; break;
case ResponseUnderload _: case ResponseUnderload _:
if (gear.Gear != DataBus.GearboxInfo.Gear.Gear) { if (gear.Gear != DataBus.GearboxInfo.Gear.Gear) {
// AT Gearbox switched gears, shift losses are no longer applied, try once more... // AT Gearbox switched gears, shift losses are no longer applied, try once more...
response = Driver.DrivingActionAccelerate(absTime, ds, response = Driver.DrivingActionAccelerate(absTime, ds,
DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient);
debug.Add(new { a = "[DB-13] Accelerate", response }); debug.Add("[DB-13] Accelerate", response);
} }
break; break;
} }
...@@ -1325,11 +1325,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -1325,11 +1325,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
DataBus.Brakes.BrakePower = 0.SI<Watt>(); DataBus.Brakes.BrakePower = 0.SI<Watt>();
response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, response = Driver.DrivingActionBrake(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed,
gradient, targetDistance: targetDistance); gradient, targetDistance: targetDistance);
debug.Add(new { a = "[DB-14] Brake", response }); debug.Add("[DB-14] Brake", response);
if (response is ResponseOverload) { if (response is ResponseOverload) {
Log.Info("Brake -> Gearshift -> Overload -> trying roll action (no gear engaged)"); Log.Info("Brake -> Gearshift -> Overload -> trying roll action (no gear engaged)");
response = Driver.DrivingActionRoll(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient); response = Driver.DrivingActionRoll(absTime, ds, DriverStrategy.BrakeTrigger.NextTargetSpeed, gradient);
debug.Add(new { a = "[DB-15] Roll", response }); debug.Add("[DB-15] Roll", response);
} }
break; break;
} }
......
...@@ -1045,6 +1045,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies ...@@ -1045,6 +1045,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies
return; return;
} }
var debug = new DebugData();
var emPos = ModelData.ElectricMachinesData.First().Item1; var emPos = ModelData.ElectricMachinesData.First().Item1;
var disengageSpeedThreshold = ModelData.GearboxData.DisengageWhenHaltingSpeed; var disengageSpeedThreshold = ModelData.GearboxData.DisengageWhenHaltingSpeed;
var vehiclespeedBelowThreshold = DataBus.VehicleInfo.VehicleSpeed.IsSmaller(disengageSpeedThreshold); var vehiclespeedBelowThreshold = DataBus.VehicleInfo.VehicleSpeed.IsSmaller(disengageSpeedThreshold);
...@@ -1091,7 +1093,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies ...@@ -1091,7 +1093,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies
MechanicalAssistPower = ElectricMotorsOff MechanicalAssistPower = ElectricMotorsOff
}; };
var firstResponse = RequestDryRun(absTime, dt, outTorque, outAngularVelocity, nextGear, tmp); var firstResponse = RequestDryRun(absTime, dt, outTorque, outAngularVelocity, nextGear, tmp);
debug.Add("[HBA-0] DryRun", firstResponse);
var engineSpeedTooLow = EngineSpeedTooLow(firstResponse); var engineSpeedTooLow = EngineSpeedTooLow(firstResponse);
var endSpeed = DataBus.VehicleInfo.VehicleSpeed + var endSpeed = DataBus.VehicleInfo.VehicleSpeed +
...@@ -1122,6 +1124,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies ...@@ -1122,6 +1124,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies
do { do {
nextGear = GearList.Predecessor(nextGear); nextGear = GearList.Predecessor(nextGear);
firstResponse = RequestDryRun(absTime, dt, outTorque, outAngularVelocity, nextGear, tmp); firstResponse = RequestDryRun(absTime, dt, outTorque, outAngularVelocity, nextGear, tmp);
debug.Add("[HBA-1] DryRun", firstResponse);
} while (GearList.HasPredecessor(nextGear) && firstResponse == null); } while (GearList.HasPredecessor(nextGear) && firstResponse == null);
} }
...@@ -1219,9 +1222,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies ...@@ -1219,9 +1222,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Strategies
{ emPos, Tuple.Create(firstResponse.ElectricMotor.AngularVelocity, VectoMath.Max(firstResponse.ElectricMotor.MaxRecuperationTorque, 0.SI<NewtonMeter>())) } { emPos, Tuple.Create(firstResponse.ElectricMotor.AngularVelocity, VectoMath.Max(firstResponse.ElectricMotor.MaxRecuperationTorque, 0.SI<NewtonMeter>())) }
} }
}; };
var maxRecuperationResponse = RequestDryRun( var maxRecuperationResponse = RequestDryRun(absTime, dt, outTorque, outAngularVelocity, nextGear, maxRecuperation);
absTime, dt, outTorque, outAngularVelocity, nextGear, maxRecuperation); debug.Add("[HBA-2] DryRun maxRecuperationResponse", maxRecuperationResponse);
var deltaDragTqMaxRecuperation = disengaged var deltaDragTqMaxRecuperation = disengaged
? (maxRecuperationResponse as ResponseDryRun).DeltaDragLoadTorque ? (maxRecuperationResponse as ResponseDryRun).DeltaDragLoadTorque
: maxRecuperationResponse.Engine.TotalTorqueDemand - maxRecuperationResponse.Engine.DragTorque; : maxRecuperationResponse.Engine.TotalTorqueDemand - maxRecuperationResponse.Engine.DragTorque;
......
...@@ -31,34 +31,38 @@ ...@@ -31,34 +31,38 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using TUGraz.VectoCommon.Utils;
namespace TUGraz.VectoCore.Utils namespace TUGraz.VectoCore.Utils
{ {
public class DebugData public class DebugData
{ {
internal readonly List<dynamic> Data; internal readonly Queue<dynamic> Data;
private const int defaultCapacity = 16;
public DebugData() public DebugData()
{ {
#if DEBUG #if DEBUG
Data = new List<dynamic>(); Data = new Queue<dynamic>(defaultCapacity);
#else
Data = new Queue<dynamic>(0);
#endif #endif
} }
[Conditional("DEBUG")] [Conditional("DEBUG")]
public void Add(dynamic value) public void Trim(int maxCount = defaultCapacity)
{ {
Data.Add(value); while (Data.Count > maxCount) {
Data.Dequeue();
} }
public override string ToString()
{
#if DEBUG
return Data.Join("\n");
#else
return "-";
#endif
} }
[Conditional("DEBUG")]
public void Add(object value) => Data.Enqueue(value);
[Conditional("DEBUG")]
public void Add(object value1, object value2) => Data.Enqueue((value1, value2));
[Conditional("DEBUG")]
public void Add(object value1, object value2, object value3) => Data.Enqueue((value1, value2, value3));
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment