@@ -102,6 +102,8 @@ public class MSTSSteamLocomotive : MSTSLocomotive
102102 public MSTSNotchController SmallEjectorController = new MSTSNotchController ( 0 , 1 , 0.1f ) ;
103103 public MSTSNotchController LargeEjectorController = new MSTSNotchController ( 0 , 1 , 0.1f ) ;
104104
105+ float DebugTimerS ;
106+
105107 public bool Injector1IsOn ;
106108 bool Injector1SoundIsOn = false ;
107109 public bool Injector2IsOn ;
@@ -142,8 +144,6 @@ public class MSTSSteamLocomotive : MSTSLocomotive
142144 bool AIFireOverride = false ; // Flag to show ai fire has has been overriden
143145 bool InjectorLockedOut = false ; // Flag to lock injectors from changing within a fixed period of time
144146
145- float DebugTimerS ;
146-
147147 // Aux Tender Parameters
148148 public bool AuxTenderMoveFlag = false ; // Flag to indicate whether train has moved
149149 bool SteamIsAuxTenderCoupled = false ;
@@ -5150,12 +5150,6 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
51505150 crankCylinderPressure = 0 ;
51515151 }
51525152
5153- #if DEBUG_STEAM_SLIP
5154- if ( throttle > 0.01 && ( absSpeedMpS < 0.2 || absSpeedMpS > 17.9 && absSpeedMpS < 18.1 || absSpeedMpS > 35.5 && absSpeedMpS < 35.9 ) )
5155- {
5156- Trace . TraceInformation ( "Cylinder {0} CrankAngle {1} FwdCylPosition {2} FwdCylPressure {3} BwdCylPosition {4} BwdCylPressure {5} CrankPressure {6} ForwardStroke {7} Speed {8}" , i , MathHelper . ToDegrees ( crankAngleRad ) , forwardCylinderPosition , forwardCylinderPressure , backwardCylinderPosition , backwardCylinderPressure , crankCylinderPressure , forwardStroke , MpS . ToMpH ( absSpeedMpS ) ) ;
5157- }
5158- #endif
51595153 // Calculate wheel tangential forces = Force applied to wheels
51605154
51615155 float pistonForceLbf = Me2 . ToIn2 ( Me2 . FromFt2 ( CylinderPistonAreaFt2 ) ) * crankCylinderPressure ;
@@ -5183,7 +5177,8 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
51835177 float connectRodInertiaForcelbf = inertiaSpeedCorrectionFactor * connectRodInertiaAngleFactor * ConnectingRodWeightLb ;
51845178
51855179 // Account for the position of the crosshead position. In other words it depends upon whether the Rods and Reciporating gear is above or below the axle.
5186- if ( axlePostionRad < 0 )
5180+ // The crosshead will be -ve for normalised angles between 0 - 180, and +ve for normalised angles between 180 - 360
5181+ if ( normalisedCrankAngleRad > 0 && normalisedCrankAngleRad < Math . PI )
51875182 {
51885183 reciprocatingInertiaForcelbf *= - 1 ;
51895184 connectRodInertiaForcelbf *= - 1 ;
@@ -5208,6 +5203,21 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
52085203 // should be deducted from this as well.
52095204 float tangentialWheelTreadForceLbf = tangentialCrankWheelForceLbf * Me . ToIn ( CylinderStrokeM ) / Me . ToIn ( DrvWheelDiaM ) ;
52105205
5206+ #if DEBUG_STEAM_SLIP
5207+ if ( SpeedMpS > 17.88 && SpeedMpS < 18.5 || SpeedMpS > 34.0 && throttle == 0 )
5208+ {
5209+ Trace . TraceInformation ( "Adhesion Debug - Cyl {0} Time {1} Speed {2} WheelRpM {3} CrankAngle {4} TotalTangForce {5} TangForce {6} TotalInertiaForce {7} TotalTangInertiaForce {8} RecipForce {9} RecipANgleFactor {10} RecipWeight {11} SpeedFactor {12} RodForce {13} RodAngleFactor {14} ForwardCyLPos {15} BackCylPos {16} CrankCylPos {17} NormCrankAngle {18} AxlePosnRad {19}" , i + 1 , DebugTimerS , MpS . ToMpH ( SpeedMpS ) , DrvWheelRevRpS * 60.0f , MathHelper . ToDegrees ( crankAngleRad ) , tangentialWheelTreadForceLbf , tangentialForcelbf , totalInertiaForcelbf , totalTangentialInertiaForcelbf , reciprocatingInertiaForcelbf , reciprocatingInertiaAngleFactor , ReciprocatingWeightLb , inertiaSpeedCorrectionFactor , connectRodInertiaForcelbf , connectRodInertiaAngleFactor , forwardCylinderPosition , backwardCylinderPosition , crankCylinderPosition , normalisedCrankAngleRad , axlePostionRad ) ;
5210+
5211+ DebugTimerS += elapsedClockSeconds ;
5212+ }
5213+
5214+ if ( SpeedMpS > 18.5 && SpeedMpS < 19 )
5215+ {
5216+ DebugTimerS = 0 ;
5217+ }
5218+
5219+ #endif
5220+
52115221 DisplayTangentialWheelTreadForceLbf += tangentialWheelTreadForceLbf ;
52125222 TractiveForceN += N . FromLbf ( tangentialWheelTreadForceLbf ) ;
52135223
@@ -5227,7 +5237,8 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
52275237 float excessBalanceForcelbf = inertiaSpeedCorrectionFactor * excessBalanceWeightLb * sin ;
52285238
52295239 // Account for the position of the crosshead position. In other words it depends upon whether the ExcessBalance is above or below the axle.
5230- if ( axlePostionRad < 0 )
5240+ // The crosshead will be -ve for normalised angles between 0 - 180, and +ve for normalised angles between 180 - 360
5241+ if ( normalisedCrankAngleRad > 0 && normalisedCrankAngleRad < Math . PI )
52315242 {
52325243 excessBalanceForcelbf *= - 1 ;
52335244 }
@@ -5250,37 +5261,10 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
52505261 {
52515262 totalDrvWeightN += N . FromLbf ( excessBalanceForcelbf - verticalThrustForcelbf ) ;
52525263 }
5253-
5254- #if DEBUG_STEAM_SLIP
5255- if ( throttle > 0.01 && ( absSpeedMpS < 0.2 || absSpeedMpS > 17.7 && absSpeedMpS < 18.2 ) )
5256- {
5257- // Trace.TraceInformation("MaxSpeed {0}", MaxLocoSpeedMpH);
5258-
5259- Trace . TraceInformation ( "Crank Angle {0} Cylinder Position {1} AxlePosition {2} Cylinder {3} CylArea {4} CylPress {5}" , MathHelper . ToDegrees ( crankAngleRad ) , crankCylinderPosition , MathHelper . ToDegrees ( LocomotiveAxle . AxlePositionRad ) , i , Me2 . ToIn2 ( Me2 . FromFt2 ( CylinderPistonAreaFt2 ) ) , crankCylinderPressure ) ;
5260-
5261- Trace . TraceInformation ( "Tang.CrankFactor {0} RecInertiaFactor {1}, ConInertiaFactor {2} VerticalForceFactor {3} InertiaSpeedFactor {4}" , tangentialCrankForceFactor , reciprocatingInertiaFactor , connectRodInertiaFactor , verticalThrustFactor , inertiaSpeedCorrectionFactor ) ;
5262-
5263- Trace . TraceInformation ( "PistonForce {0} RodForce {1} RecForce {2}" , pistonForceLbf , connectRodInertiaForce , reciprocatingInertiaForce ) ;
5264-
5265- Trace . TraceInformation ( "VerticalThrustForce {0} ExcessBalanceForce {1}" , verticalThrustForce , excessBalanceForce ) ;
5266-
5267- }
5268- #endif
52695264 }
52705265
52715266 LocomotiveAxles [ 0 ] . AxleWeightN = totalDrvWeightN + 9.81f * DrvWheelWeightKg ;
52725267 SteamStaticWheelForce = N . ToLbf ( totalDrvWeightN + 9.81f * DrvWheelWeightKg ) * LocomotiveCoefficientFrictionHUD ;
5273-
5274- #if DEBUG_STEAM_SLIP
5275- if ( throttle > 0.01 && ( absSpeedMpS < 0.2 || absSpeedMpS > 17.7 && absSpeedMpS < 18.2 ) )
5276- {
5277- Trace . TraceInformation ( "RotationalForce {0} AdhesiveForce {1}" , N . ToLbf ( TractiveForceN ) , SteamStaticWheelForce ) ;
5278-
5279-
5280- }
5281- #endif
5282-
5283-
52845268 }
52855269 else // Set wheel speed if "simple" friction is used
52865270 {
0 commit comments