@@ -7177,22 +7177,16 @@ private void UpdateWaterGauge()
7177
7177
// water variation is calculated as the opposite side of a triangle with half the boiler length as the reference length (Adjacent side)
7178
7178
var waterVariationLevelM = (float)Math.Tan(boilerangleRad) * (BoilerLengthM / 2.0f);
7179
7179
7180
- float glassLevelGradientM = 0;
7181
-
7182
7180
// Downslope - CurrentElevationPercent = +ve, level variation will be -ve
7183
7181
// Uphill - CurrentElevationPercent = -ve, level variation will be +ve
7184
7182
// So, for example, if the loco is on a 1 in 100 down slope, the water level at the front of the boiler will be lower than at the
7185
7183
// back by 0.5% of the boiler length
7186
7184
7187
7185
// gradient variation due to slope needs to be reversed
7188
- glassLevelGradientM = waterVariationLevelM * -1.0f;
7189
-
7190
- // Assume that reference glass height is 50% of glass
7191
- var maxWaterVariationIN = Me.ToIn(WaterGlassLengthM) / 2.0f;
7186
+ waterVariationLevelM *= -1.0f;
7192
7187
7193
7188
float currentglasslevelfraction = 0;
7194
- float glasslevelM = 0;
7195
-
7189
+
7196
7190
// Convert reference point to a reading on glass
7197
7191
if (BoilerWaterFractionAbs > referenceBoilerLevelFraction)
7198
7192
{
@@ -7204,9 +7198,9 @@ private void UpdateWaterGauge()
7204
7198
currentglasslevelfraction = -1.0f * waterGlassFractionLevel;
7205
7199
}
7206
7200
7207
- glasslevelM = currentglasslevelfraction * BoilerDiameterM;
7201
+ GradientBoilerLevelFraction = ((BoilerWaterFractionAbs + waterVariationLevelM / BoilerDiameterM) - WaterGlassMinLevel) / (WaterGlassMaxLevel - WaterGlassMinLevel); // Calculate water glass grade fraction
7208
7202
7209
- GradientBoilerLevelFraction = currentglasslevelfraction + (glassLevelGradientM / BoilerDiameterM );
7203
+ GradientBoilerLevelFraction = MathHelper.Clamp(GradientBoilerLevelFraction, 0.0f, 1.0f );
7210
7204
7211
7205
if (BoilerWaterFractionAbs < WaterMinLevel) // Blow fusible plugs if absolute boiler water drops below minimum level
7212
7206
{
0 commit comments