32
32
using ORTS . Common ;
33
33
using ORTS . Scripting . Api ;
34
34
using ORTS . Settings ;
35
+ using SharpDX . MediaFoundation ;
35
36
using System ;
36
37
using System . Collections . Generic ;
37
38
using System . Diagnostics ;
38
39
using System . IO ;
40
+ using System . Runtime . Remoting . Messaging ;
39
41
using Event = Orts . Common . Event ;
40
42
41
43
namespace Orts . Simulation
@@ -58,6 +60,20 @@ namespace Orts.Simulation
58
60
/// </summary>
59
61
public class Simulator
60
62
{
63
+ /// <summary>
64
+ /// Sets the frame rate object so its value can be read from anywhere in the Simulator and used to tune simulation algorithms.
65
+ /// </summary>
66
+ /// <param name="frameRate"></param>
67
+ public static void SetFrameRate ( SmoothedData frameRate )
68
+ {
69
+ FrameRate = frameRate ;
70
+ }
71
+ public static float SmoothedFrameRate
72
+ {
73
+ get { return FrameRate . SmoothedValue ; }
74
+ }
75
+ private static SmoothedData FrameRate ;
76
+
61
77
public static GettextResourceManager Catalog { get ; private set ; }
62
78
public static Random Random { get ; private set ; }
63
79
public static double Resolution = 1000000 ; // resolution for calculation of random value with a pseudo-gaussian distribution
@@ -1355,8 +1371,8 @@ private Train InitializePlayerTrain()
1355
1371
train . AITrainBrakePercent = 100 ; //<CSComment> This seems a tricky way for the brake modules to test if it is an AI train or not
1356
1372
train . EqualReservoirPressurePSIorInHg = prevEQres ; // The previous command modifies EQ reservoir pressure, causing issues with EP brake systems, so restore to prev value
1357
1373
1358
- // if ((PlayerLocomotive as MSTSLocomotive).EOTEnabled != MSTSLocomotive.EOTenabled.no)
1359
- // train.EOT = new EOT((PlayerLocomotive as MSTSLocomotive).EOTEnabled, false, train);
1374
+ // if ((PlayerLocomotive as MSTSLocomotive).EOTEnabled != MSTSLocomotive.EOTenabled.no)
1375
+ // train.EOT = new EOT((PlayerLocomotive as MSTSLocomotive).EOTEnabled, false, train);
1360
1376
1361
1377
return ( train ) ;
1362
1378
}
@@ -1432,8 +1448,8 @@ private AITrain InitializeAPPlayerTrain()
1432
1448
1433
1449
if ( conFileName . Contains ( "tilted" ) ) train . IsTilting = true ;
1434
1450
1435
- // if ((PlayerLocomotive as MSTSLocomotive).EOTEnabled != MSTSLocomotive.EOTenabled.no)
1436
- // train.EOT = new EOT((PlayerLocomotive as MSTSLocomotive).EOTEnabled, false, train);
1451
+ // if ((PlayerLocomotive as MSTSLocomotive).EOTEnabled != MSTSLocomotive.EOTenabled.no)
1452
+ // train.EOT = new EOT((PlayerLocomotive as MSTSLocomotive).EOTEnabled, false, train);
1437
1453
1438
1454
return train ;
1439
1455
}
@@ -1487,7 +1503,7 @@ private void InitializeStaticConsists()
1487
1503
1488
1504
if ( ! File . Exists ( wagonFilePath ) )
1489
1505
{
1490
- Trace . TraceWarning ( $ "Ignored missing { ( wagon . IsEngine ? "engine" : "wagon" ) } { wagonFilePath } in activity definition { activityObject . Train_Config . TrainCfg . Name } ") ;
1506
+ Trace . TraceWarning ( $ "Ignored missing { ( wagon . IsEngine ? "engine" : "wagon" ) } { wagonFilePath } in activity definition { activityObject . Train_Config . TrainCfg . Name } ") ;
1491
1507
continue ;
1492
1508
}
1493
1509
@@ -1897,7 +1913,7 @@ private void StartSwitchPlayerTrain()
1897
1913
if ( playerTrain != null )
1898
1914
{
1899
1915
if ( playerTrain . ControlMode == Train . TRAIN_CONTROL . MANUAL ) TrainSwitcher . SuspendOldPlayer = true ; // force suspend state to avoid disappearing of train;
1900
- if ( TrainSwitcher . SuspendOldPlayer &&
1916
+ if ( TrainSwitcher . SuspendOldPlayer &&
1901
1917
( playerTrain . SpeedMpS < - 0.025 || playerTrain . SpeedMpS > 0.025 || playerTrain . PresentPosition [ 0 ] . TCOffset != playerTrain . PreviousPosition [ 0 ] . TCOffset ) )
1902
1918
{
1903
1919
Confirmer . Message ( ConfirmLevel . Warning , Catalog . GetString ( "Train can't be suspended with speed not equal 0" ) ) ;
@@ -2116,10 +2132,10 @@ public void RestartWaitingTrain(RestartWaitingTrain restartWaitingTrain)
2116
2132
}
2117
2133
}
2118
2134
if ( trainToRestart == null )
2119
- Trace . TraceWarning ( "Train {0} to restart not found" , restartWaitingTrain . WaitingTrainToRestart ) ;
2135
+ Trace . TraceWarning ( "Train {0} to restart not found" , restartWaitingTrain . WaitingTrainToRestart ) ;
2120
2136
}
2121
2137
2122
-
2138
+
2123
2139
2124
2140
/// <summary>
2125
2141
/// Derive log-file name from route path and activity name
0 commit comments