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

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

Initialise Gear now searches for gear again

parent 040ffe79
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,7 @@ namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
public Watt BrakePower { get; set; }
public VectoSimulationComponent Source { get; set; }
public object Source { get; set; }
public override string ToString()
{
......
......@@ -61,9 +61,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
Log.Debug("==== DRIVER Request ====");
Log.Debug(
"Request: absTime: {0}, ds: {1}, targetVelocity: {2}, gradient: {3} | distance: {4}, velocity: {5} gear: {6}",
"Request: absTime: {0}, ds: {1}, targetVelocity: {2}, gradient: {3} | distance: {4}, velocity: {5}",
absTime, ds,
targetVelocity, gradient, DataBus.Distance, DataBus.VehicleSpeed, DataBus.Gear);
targetVelocity, gradient, DataBus.Distance, DataBus.VehicleSpeed);
var retVal = DriverStrategy.Request(absTime, ds, targetVelocity, gradient);
//DoHandleRequest(absTime, ds, targetVelocity, gradient);
......@@ -516,8 +516,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var actionRoll = !DataBus.ClutchClosed(absTime);
var searchInterval = Constants.SimulationSettings.OperatingPointInitialSearchIntervalAccelerating;
var curve = DriverData.AccelerationCurve.Lookup(DataBus.VehicleSpeed);
var intervalFactor = 1.0;
Watt origDelta = null;
......
......@@ -98,14 +98,29 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
#region ITnOutPort
public IResponse Initialize(NewtonMeter torque, PerSecond engineSpeed)
public IResponse Initialize(NewtonMeter outTorque, PerSecond outEngineSpeed)
{
var response = NextComponent.Initialize(torque, engineSpeed);
_shiftTime = double.NegativeInfinity.SI<Second>();
Gear = 0; //_strategy.InitGear(torque, engineSpeed);
_disengaged = true;
// for initializing the engine:
var absTime = 0.SI<Second>();
var dt = Constants.SimulationSettings.TargetTimeInterval;
Gear = _strategy.InitGear(absTime, dt, outTorque, outEngineSpeed);
var inEngineSpeed = outEngineSpeed * Data.Gears[Gear].Ratio;
var inTorque = Data.Gears[Gear].LossMap.GearboxInTorque(inEngineSpeed, outTorque);
_powerLoss = inTorque * inEngineSpeed - outTorque * outEngineSpeed;
var torqueLossInertia = !inEngineSpeed.IsEqual(0)
? Formulas.InertiaPower(inEngineSpeed, _previousInEnginespeed, Data.Inertia, dt) / inEngineSpeed
: 0.SI<NewtonMeter>();
_previousInEnginespeed = inEngineSpeed;
inTorque += torqueLossInertia;
var response = NextComponent.Initialize(inTorque, inEngineSpeed);
return response;
}
......@@ -202,7 +217,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
private IResponse RequestGearEngaged(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed,
bool dryRun)
{
// Set a Gear if no gear was set
// Set a Gear if no gear was set and engineSpeed is not zero
if (_disengaged && !outEngineSpeed.IsEqual(0)) {
_disengaged = false;
if (DataBus.VehicleSpeed.IsEqual(0)) {
......@@ -214,10 +229,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Log.Debug("Gearbox engaged gear {0}", Gear);
}
var inEngineSpeed = outEngineSpeed;
var inTorque = outTorque;
PerSecond inEngineSpeed;
NewtonMeter inTorque;
if (!outEngineSpeed.IsEqual(0)) {
if (outEngineSpeed.IsEqual(0)) {
inEngineSpeed = outEngineSpeed;
inTorque = outTorque;
} else {
inEngineSpeed = outEngineSpeed * Data.Gears[Gear].Ratio;
inTorque = Data.Gears[Gear].LossMap.GearboxInTorque(inEngineSpeed, outTorque);
......@@ -227,9 +245,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
: 0.SI<NewtonMeter>();
_previousInEnginespeed = inEngineSpeed;
inTorque += torqueLossInertia;
_powerLossInertia = torqueLossInertia * inEngineSpeed;
}
......
......@@ -76,6 +76,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public class AMTShiftStrategy : ShiftStrategy
{
/// <summary>
/// The previous gear before the disengagement. Used for GetGear() when skipGears is false.
/// </summary>
protected uint PreviousGear;
public AMTShiftStrategy(GearboxData data) : base(data)
......@@ -89,6 +92,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var maxGear = (uint)(skipGears ? Data.Gears.Count : Math.Min(PreviousGear + 1, Data.Gears.Count));
var minGear = skipGears ? 1 : Math.Max(PreviousGear - 1, 1);
if (outEngineSpeed.IsEqual(0)) {
return minGear;
}
for (var gear = maxGear; gear > minGear; gear--) {
Gearbox.Gear = gear;
var response = (ResponseDryRun)Gearbox.Request(absTime, dt, outTorque, outEngineSpeed, true);
......@@ -121,10 +128,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return IsBelowDownShiftCurve(gear, torque, angularSpeed) || IsAboveUpShiftCurve(gear, torque, angularSpeed);
}
public override uint InitGear(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed)
{
return GetGear(absTime, dt, outTorque, outEngineSpeed, true, Data.StartTorqueReserve);
return GetGear(absTime, dt, outTorque, outEngineSpeed, skipGears: true, torqueReserve: Data.StartTorqueReserve);
}
}
......
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