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

Skip to content
Snippets Groups Projects
Commit c0c2a9f2 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

adding (desired driver -) acceleration to databus

parent 6343ab1b
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,6 @@
*/
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Models.SimulationComponent;
namespace TUGraz.VectoCore.Models.Simulation.DataBus
......
......@@ -29,6 +29,8 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using TUGraz.VectoCommon.Utils;
namespace TUGraz.VectoCore.Models.Simulation.DataBus
{
public enum DrivingBehavior
......@@ -43,5 +45,6 @@ namespace TUGraz.VectoCore.Models.Simulation.DataBus
public interface IDriverInfo
{
DrivingBehavior DriverBehavior { get; }
MeterPerSquareSecond DriverAcceleration { get; }
}
}
\ No newline at end of file
......@@ -31,6 +31,7 @@
using System;
using System.Linq;
using System.Windows.Forms.VisualStyles;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
......@@ -62,6 +63,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
DriverData = driverData;
DriverStrategy = strategy;
strategy.Driver = this;
DriverAcceleration = 0.SI<MeterPerSquareSecond>();
}
public IDriverDemandInPort InPort()
......@@ -146,6 +148,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var operatingPoint = ComputeAcceleration(ds, targetVelocity);
IResponse retVal = null;
DriverAcceleration = operatingPoint.Acceleration;
var response = previousResponse ??
NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient);
......@@ -177,6 +180,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Log.Debug("Found operating point for Drive/Accelerate. dt: {0}, acceleration: {1}",
limitedOperatingPoint.SimulationInterval, limitedOperatingPoint.Acceleration);
DriverAcceleration = limitedOperatingPoint.Acceleration;
retVal = NextComponent.Request(absTime, limitedOperatingPoint.SimulationInterval, limitedOperatingPoint.Acceleration,
gradient);
retVal.Switch().
......@@ -188,6 +192,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Log.Info(
"Operating point with limited acceleration resulted in an overload! trying again with original acceleration {0}",
nextOperatingPoint.Acceleration);
DriverAcceleration = nextOperatingPoint.Acceleration;
retVal = NextComponent.Request(absTime, nextOperatingPoint.SimulationInterval, nextOperatingPoint.Acceleration,
gradient);
retVal.Switch().
......@@ -267,6 +272,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
bool rollAction)
{
var requestedOperatingPoint = ComputeAcceleration(ds, DataBus.VehicleSpeed);
DriverAcceleration = requestedOperatingPoint.Acceleration;
var initialResponse = NextComponent.Request(absTime, requestedOperatingPoint.SimulationInterval,
requestedOperatingPoint.Acceleration, gradient, dryRun: true);
......@@ -307,6 +313,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return new ResponseSpeedLimitExceeded() { Source = this };
}
DriverAcceleration = limitedOperatingPoint.Acceleration;
var response = NextComponent.Request(absTime, limitedOperatingPoint.SimulationInterval,
limitedOperatingPoint.Acceleration, gradient);
......@@ -377,6 +384,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
}
DriverAcceleration = operatingPoint.Acceleration;
var response = previousResponse ??
NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient);
......@@ -425,6 +433,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return new ResponseOverload { Source = this };
}
DriverAcceleration = operatingPoint.Acceleration;
retVal = NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient);
retVal.Switch().
......@@ -502,6 +511,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
initialResponse.Switch().
Case<ResponseGearShift>(r => {
IterationStatistics.Increment(this, "SearchBrakingPower");
DriverAcceleration = operatingPoint.Acceleration;
var nextResp = NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration,
gradient, true);
deltaPower = nextResp.GearboxPowerRequest;
......@@ -521,6 +531,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
operatingPoint = ComputeTimeInterval(operatingPoint.Acceleration, ds);
IterationStatistics.Increment(this, "SearchBrakingPower");
DriverAcceleration = operatingPoint.Acceleration;
return NextComponent.Request(absTime, operatingPoint.SimulationInterval, operatingPoint.Acceleration, gradient,
true);
},
......@@ -581,6 +592,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
retVal.SimulationDistance = tmp.SimulationDistance;
}
IterationStatistics.Increment(this, "SearchOperatingPoint");
DriverAcceleration = acc;
var response = NextComponent.Request(absTime, retVal.SimulationInterval, acc, gradient, true);
response.OperatingPoint = retVal;
return response;
......@@ -710,11 +722,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
DataBus.VehicleSpeed);
}
DriverAcceleration = 0.SI<MeterPerSquareSecond>();
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 => {
DriverAcceleration = 0.SI<MeterPerSquareSecond>();
retVal = NextComponent.Request(absTime, dt, 0.SI<MeterPerSquareSecond>(), gradient);
});
CurrentState.dt = dt;
CurrentState.Acceleration = 0.SI<MeterPerSquareSecond>();
return retVal;
......@@ -755,5 +770,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
public DrivingBehavior DriverBehavior { get; set; }
public MeterPerSquareSecond DriverAcceleration { get; protected set; }
}
}
\ No newline at end of file
......@@ -313,6 +313,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
get { return DrivingBehavior.Driving; }
}
public MeterPerSquareSecond DriverAcceleration
{
get { return 0.SI<MeterPerSquareSecond>(); }
}
#endregion
}
......@@ -420,6 +425,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var deltaT = RightSample.Current.Time - LeftSample.Current.Time;
var acceleration = deltaV / deltaT;
var gradient = LeftSample.Current.RoadGradient;
DriverAcceleration = acceleration;
DriverBehavior = acceleration < 0
? DriverBehavior = DrivingBehavior.Braking
: DriverBehavior = DrivingBehavior.Driving;
......@@ -592,6 +598,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public DrivingBehavior DriverBehavior { get; internal set; }
public MeterPerSquareSecond DriverAcceleration { get; protected set; }
public Meter Distance
{
get { return CurrentState.Distance; }
......
......@@ -117,5 +117,6 @@ namespace TUGraz.VectoCore.Tests.Utils
public bool VehicleStopped { get; set; }
public DrivingBehavior DriverBehavior { get; set; }
public MeterPerSquareSecond DriverAcceleration { get; set; }
}
}
\ No newline at end of file
......@@ -137,7 +137,10 @@ namespace TUGraz.VectoCore.Tests.Utils
}
public bool VehicleStopped { get; set; }
public DrivingBehavior DriverBehavior { get; set; }
public MeterPerSquareSecond DriverAcceleration { get; set; }
public CycleData CycleData { get; set; }
public DrivingCycleData.DrivingCycleEntry CycleLookAhead(Meter distance)
......
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