@@ -102,6 +102,8 @@ public class MSTSSteamLocomotive : MSTSLocomotive
102
102
public MSTSNotchController SmallEjectorController = new MSTSNotchController ( 0 , 1 , 0.1f ) ;
103
103
public MSTSNotchController LargeEjectorController = new MSTSNotchController ( 0 , 1 , 0.1f ) ;
104
104
105
+ float DebugTimerS ;
106
+
105
107
public bool Injector1IsOn ;
106
108
bool Injector1SoundIsOn = false ;
107
109
public bool Injector2IsOn ;
@@ -142,8 +144,6 @@ public class MSTSSteamLocomotive : MSTSLocomotive
142
144
bool AIFireOverride = false ; // Flag to show ai fire has has been overriden
143
145
bool InjectorLockedOut = false ; // Flag to lock injectors from changing within a fixed period of time
144
146
145
- float DebugTimerS ;
146
-
147
147
// Aux Tender Parameters
148
148
public bool AuxTenderMoveFlag = false ; // Flag to indicate whether train has moved
149
149
bool SteamIsAuxTenderCoupled = false ;
@@ -5150,12 +5150,6 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
5150
5150
crankCylinderPressure = 0 ;
5151
5151
}
5152
5152
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
5159
5153
// Calculate wheel tangential forces = Force applied to wheels
5160
5154
5161
5155
float pistonForceLbf = Me2 . ToIn2 ( Me2 . FromFt2 ( CylinderPistonAreaFt2 ) ) * crankCylinderPressure ;
@@ -5183,7 +5177,8 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
5183
5177
float connectRodInertiaForcelbf = inertiaSpeedCorrectionFactor * connectRodInertiaAngleFactor * ConnectingRodWeightLb ;
5184
5178
5185
5179
// 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 )
5187
5182
{
5188
5183
reciprocatingInertiaForcelbf *= - 1 ;
5189
5184
connectRodInertiaForcelbf *= - 1 ;
@@ -5208,6 +5203,21 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
5208
5203
// should be deducted from this as well.
5209
5204
float tangentialWheelTreadForceLbf = tangentialCrankWheelForceLbf * Me . ToIn ( CylinderStrokeM ) / Me . ToIn ( DrvWheelDiaM ) ;
5210
5205
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
+
5211
5221
DisplayTangentialWheelTreadForceLbf += tangentialWheelTreadForceLbf ;
5212
5222
TractiveForceN += N . FromLbf ( tangentialWheelTreadForceLbf ) ;
5213
5223
@@ -5227,7 +5237,8 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
5227
5237
float excessBalanceForcelbf = inertiaSpeedCorrectionFactor * excessBalanceWeightLb * sin ;
5228
5238
5229
5239
// 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 )
5231
5242
{
5232
5243
excessBalanceForcelbf *= - 1 ;
5233
5244
}
@@ -5250,37 +5261,10 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
5250
5261
{
5251
5262
totalDrvWeightN += N . FromLbf ( excessBalanceForcelbf - verticalThrustForcelbf ) ;
5252
5263
}
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
5269
5264
}
5270
5265
5271
5266
LocomotiveAxles [ 0 ] . AxleWeightN = totalDrvWeightN + 9.81f * DrvWheelWeightKg ;
5272
5267
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
-
5284
5268
}
5285
5269
else // Set wheel speed if "simple" friction is used
5286
5270
{
0 commit comments