1
- // COPYRIGHT 2009 - 2022 by the Open Rails project.
1
+ // COPYRIGHT 2009 - 2022 by the Open Rails project.
2
2
//
3
3
// This file is part of Open Rails.
4
4
//
@@ -208,6 +208,7 @@ public static Interpolator SteamHeatBoilerFuelUsageGalukpH()
208
208
public bool DerailPossible = false ;
209
209
public bool DerailExpected = false ;
210
210
public float DerailElapsedTimeS ;
211
+ public bool HasDerailed = false ;
211
212
212
213
public float MaxHandbrakeForceN ;
213
214
public float MaxBrakeForceN = 89e3f ;
@@ -1735,8 +1736,18 @@ public void UpdateTrainDerailmentRisk(float elapsedClockSeconds)
1735
1736
{
1736
1737
DerailExpected = true ;
1737
1738
Simulator . Confirmer . Message ( ConfirmLevel . Warning , Simulator . Catalog . GetStringFmt ( "Car {0} has derailed on the curve." , CarID ) ) ;
1738
- // Trace.TraceInformation("Car Derail - CarID: {0}, Coupler: {1}, CouplerSmoothed {2}, Lateral {3}, Vertical {4}, Angle {5} Nadal {6} Coeff {7}", CarID, CouplerForceU, CouplerForceUSmoothed.SmoothedValue, TotalWagonLateralDerailForceN, TotalWagonVerticalDerailForceN, WagonCouplerAngleDerailRad, NadalDerailmentCoefficient, DerailmentCoefficient);
1739
- // Trace.TraceInformation("Car Ahead Derail - CarID: {0}, Coupler: {1}, CouplerSmoothed {2}, Lateral {3}, Vertical {4}, Angle {5}", CarAhead.CarID, CarAhead.CouplerForceU, CarAhead.CouplerForceUSmoothed.SmoothedValue, CarAhead.TotalWagonLateralDerailForceN, CarAhead.TotalWagonVerticalDerailForceN, CarAhead.WagonCouplerAngleDerailRad);
1739
+ if ( ! HasDerailed )
1740
+ {
1741
+ string derailReason = "defect" ;
1742
+ if ( CouplerForceU > 0 && CouplerSlackM < 0 ) { derailReason = "jackknifed" ; }
1743
+ else if ( CouplerForceU < 0 && CouplerSlackM > 0 ) { derailReason = "stringlined" ; }
1744
+ Trace . TraceInformation ( "Car {0} derailed ({1}), on {2} curve with radius {3}, at speed {4}, after traveling {5}" ,
1745
+ CarID , derailReason , GetCurveDirection ( ) , FormatStrings . FormatDistance ( CurrentCurveRadiusM , IsMetric ) , FormatStrings . FormatSpeed ( AbsSpeedMpS , IsMetric ) , FormatStrings . FormatDistance ( DistanceM , IsMetric ) ) ;
1746
+ // DistanceM is not a good location measure, as it is based on the train. Two railcars derailing at the same location have a different distance.
1747
+ }
1748
+ HasDerailed = true ;
1749
+ // Trace.TraceInformation("Car Derail - CarID: {0}, Coupler: {1}, CouplerSmoothed {2}, Lateral {3}, Vertical {4}, Angle {5} Nadal {6} Coeff {7}", CarID, CouplerForceU, CouplerForceUSmoothed.SmoothedValue, TotalWagonLateralDerailForceN, TotalWagonVerticalDerailForceN, WagonCouplerAngleDerailRad, NadalDerailmentCoefficient, DerailmentCoefficient);
1750
+ // Trace.TraceInformation("Car Ahead Derail - CarID: {0}, Coupler: {1}, CouplerSmoothed {2}, Lateral {3}, Vertical {4}, Angle {5}", CarAhead.CarID, CarAhead.CouplerForceU, CarAhead.CouplerForceUSmoothed.SmoothedValue, CarAhead.TotalWagonLateralDerailForceN, CarAhead.TotalWagonVerticalDerailForceN, CarAhead.WagonCouplerAngleDerailRad);
1740
1751
}
1741
1752
else if ( DerailPossible )
1742
1753
{
@@ -1746,12 +1757,15 @@ public void UpdateTrainDerailmentRisk(float elapsedClockSeconds)
1746
1757
else
1747
1758
{
1748
1759
DerailElapsedTimeS = 0 ; // Reset timer if derail is not possible
1760
+ HasDerailed = false ;
1749
1761
}
1750
1762
1751
1763
if ( AbsSpeedMpS < 0.01 )
1752
1764
{
1753
1765
DerailExpected = false ;
1754
1766
DerailPossible = false ;
1767
+ DerailElapsedTimeS = 0 ;
1768
+ HasDerailed = false ;
1755
1769
}
1756
1770
1757
1771
// if (CarID == "0 - 84" || CarID == "0 - 83" || CarID == "0 - 82" || CarID == "0 - 81" || CarID == "0 - 80" || CarID == "0 - 79")
@@ -1768,6 +1782,7 @@ public void UpdateTrainDerailmentRisk(float elapsedClockSeconds)
1768
1782
DerailExpected = false ;
1769
1783
DerailPossible = false ;
1770
1784
DerailElapsedTimeS = 0 ;
1785
+ HasDerailed = false ;
1771
1786
}
1772
1787
1773
1788
0 commit comments