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

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

GearshiftPosition: Minor refactoring (expression bodies)

parent 46b09120
No related branches found
No related tags found
No related merge requests found
......@@ -18,28 +18,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
TorqueConverterLocked = torqueConverterLocked;
}
public override string ToString()
{
return Name;
}
public override string ToString() => Name;
public string Name => $"{Gear}{(Gear == 0 ? "" : (TorqueConverterLocked.HasValue ? (TorqueConverterLocked.Value ? "L" : "C") : ""))}";
public string Name =>
$"{Gear}{(Gear == 0 || TorqueConverterLocked is null ? "" : (TorqueConverterLocked.Value ? "L" : "C"))}";
public bool Engaged => Gear != 0;
public override bool Equals(object x)
{
var other = x as GearshiftPosition;
if (other == null)
return false;
return other.Gear == Gear && other.TorqueConverterLocked == TorqueConverterLocked;
}
public override bool Equals(object x) =>
x is GearshiftPosition other && other.Gear == Gear && other.TorqueConverterLocked == TorqueConverterLocked;
public override int GetHashCode()
{
return Name.GetHashCode();
}
public override int GetHashCode() => Name.GetHashCode();
public static bool operator >(GearshiftPosition p1, GearshiftPosition p2)
{
......@@ -76,10 +65,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
public bool IsLockedGear()
{
return !TorqueConverterLocked.HasValue || TorqueConverterLocked.Value;
}
public bool IsLockedGear() => !TorqueConverterLocked.HasValue || TorqueConverterLocked.Value;
}
public class GearList : IEnumerable<GearshiftPosition>
......
......@@ -256,8 +256,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
SetPowershiftLossEnergy(absTime, dt, outTorque, outAngularVelocity);
do {
if (CurrentState.Disengaged
|| DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Halted
|| DisengageGearbox && !ModelData.ATEcoRollReleaseLockupClutch) {
|| (DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Halted)
|| (DisengageGearbox && !ModelData.ATEcoRollReleaseLockupClutch)) {
// only when vehicle is halted or close before halting or during eco-roll events
retVal = RequestDisengaged(absTime, dt, outTorque, outAngularVelocity, dryRun);
} else {
......
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