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 ...@@ -18,28 +18,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
TorqueConverterLocked = torqueConverterLocked; TorqueConverterLocked = torqueConverterLocked;
} }
public override string ToString() public override string ToString() => Name;
{
return 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 bool Engaged => Gear != 0;
public override bool Equals(object x) public override bool Equals(object x) =>
{ x is GearshiftPosition other && other.Gear == Gear && other.TorqueConverterLocked == TorqueConverterLocked;
var other = x as GearshiftPosition;
if (other == null)
return false;
return other.Gear == Gear && other.TorqueConverterLocked == TorqueConverterLocked;
}
public override int GetHashCode() public override int GetHashCode() => Name.GetHashCode();
{
return Name.GetHashCode();
}
public static bool operator >(GearshiftPosition p1, GearshiftPosition p2) public static bool operator >(GearshiftPosition p1, GearshiftPosition p2)
{ {
...@@ -76,10 +65,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -76,10 +65,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
} }
public bool IsLockedGear() public bool IsLockedGear() => !TorqueConverterLocked.HasValue || TorqueConverterLocked.Value;
{
return !TorqueConverterLocked.HasValue || TorqueConverterLocked.Value;
}
} }
public class GearList : IEnumerable<GearshiftPosition> public class GearList : IEnumerable<GearshiftPosition>
......
...@@ -256,8 +256,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -256,8 +256,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
SetPowershiftLossEnergy(absTime, dt, outTorque, outAngularVelocity); SetPowershiftLossEnergy(absTime, dt, outTorque, outAngularVelocity);
do { do {
if (CurrentState.Disengaged if (CurrentState.Disengaged
|| DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Halted || (DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Halted)
|| DisengageGearbox && !ModelData.ATEcoRollReleaseLockupClutch) { || (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 {
......
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