C# Class CTCOfficeGUI.Simulator

Datei anzeigen Open project: johnselker/Bazinga1186 Class Usage Examples

Public Methods

Method Description
GetSimulator ( ) : Simulator

Gets the singleton simulator instance

GetTrainController ( ITrain train ) : TrainControllerLib.TrainController

Gets a reference to the train controller of the train

PauseSimulation ( ) : void

Pauses the simulation timer

SetSimulationSpeed ( double scale ) : bool

Sets the simulation speed

Scale of 1 is real time, scale of 10 is 10x real time, etc.

SimulateBrakeFailure ( ITrain train, bool failure ) : void

Simulates a train brake failure

SimulateBrokenRail ( TrackBlock block, bool failure ) : void

Simulates a track broken rail

SimulateCircuitFailure ( TrackBlock block, bool failure ) : void

Simulates a track block circuit failure

SimulateEngineFailure ( ITrain train, bool failure ) : void

Simulates a train engine failure

SimulatePickupFailure ( ITrain train, bool failure ) : void

Simulates a train pickup failure

SimulatePowerFailure ( TrackBlock block, bool failure ) : void

Simulates a track block power failure

SpawnNewTrain ( TrackBlock initialBlock, string name ) : void

Creates a new train on the track

StartSimulation ( ) : void

Starts the simulation timer to update train positions

StopSimulation ( ) : void

Stops the simulation and clears the lists of components to update

Private Methods

Method Description
OnSimulationTimerElapsed ( object sender, System.Timers.ElapsedEventArgs e ) : void

Timer elapsed

OnTrainAtStation ( ITrainController train, string stationName ) : void

Train arrived at a station

OnTrainEnteredNewBlock ( TrackBlock previous, TrackBlock next ) : void

A train entered a new track block. Need to push an update to the track controllers

Simulator ( ) : System

Private constructor

Method Details

GetSimulator() public static method

Gets the singleton simulator instance
public static GetSimulator ( ) : Simulator
return Simulator

GetTrainController() public method

Gets a reference to the train controller of the train
public GetTrainController ( ITrain train ) : TrainControllerLib.TrainController
train ITrain
return TrainControllerLib.TrainController

PauseSimulation() public method

Pauses the simulation timer
public PauseSimulation ( ) : void
return void

SetSimulationSpeed() public method

Sets the simulation speed
Scale of 1 is real time, scale of 10 is 10x real time, etc.
public SetSimulationSpeed ( double scale ) : bool
scale double Simulation scale
return bool

SimulateBrakeFailure() public method

Simulates a train brake failure
public SimulateBrakeFailure ( ITrain train, bool failure ) : void
train ITrain Train to simulate on
failure bool True to invoke failure or false to clear it
return void

SimulateBrokenRail() public method

Simulates a track broken rail
public SimulateBrokenRail ( TrackBlock block, bool failure ) : void
block TrackBlock Block to simulate on
failure bool True to invoke failure or false to clear it
return void

SimulateCircuitFailure() public method

Simulates a track block circuit failure
public SimulateCircuitFailure ( TrackBlock block, bool failure ) : void
block TrackBlock Track block to simulate on
failure bool True to invoke failure or false to clear it
return void

SimulateEngineFailure() public method

Simulates a train engine failure
public SimulateEngineFailure ( ITrain train, bool failure ) : void
train ITrain Train to simulate on
failure bool True to invoke failure or false to clear it
return void

SimulatePickupFailure() public method

Simulates a train pickup failure
public SimulatePickupFailure ( ITrain train, bool failure ) : void
train ITrain Train to simulate on
failure bool True to invoke failure or false to clear it
return void

SimulatePowerFailure() public method

Simulates a track block power failure
public SimulatePowerFailure ( TrackBlock block, bool failure ) : void
block TrackBlock Track block to simulate on
failure bool True to invoke failure or false to clear it
return void

SpawnNewTrain() public method

Creates a new train on the track
public SpawnNewTrain ( TrackBlock initialBlock, string name ) : void
initialBlock TrackBlock Starting block of the train
name string Name of the train
return void

StartSimulation() public method

Starts the simulation timer to update train positions
public StartSimulation ( ) : void
return void

StopSimulation() public method

Stops the simulation and clears the lists of components to update
public StopSimulation ( ) : void
return void