C# Класс CTCOfficeGUI.Simulator

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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

Приватные методы

Метод Описание
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

Описание методов

GetSimulator() публичный статический Метод

Gets the singleton simulator instance
public static GetSimulator ( ) : Simulator
Результат Simulator

GetTrainController() публичный Метод

Gets a reference to the train controller of the train
public GetTrainController ( ITrain train ) : TrainControllerLib.TrainController
train ITrain
Результат TrainControllerLib.TrainController

PauseSimulation() публичный Метод

Pauses the simulation timer
public PauseSimulation ( ) : void
Результат void

SetSimulationSpeed() публичный Метод

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
Результат bool

SimulateBrakeFailure() публичный Метод

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
Результат void

SimulateBrokenRail() публичный Метод

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
Результат void

SimulateCircuitFailure() публичный Метод

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
Результат void

SimulateEngineFailure() публичный Метод

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
Результат void

SimulatePickupFailure() публичный Метод

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
Результат void

SimulatePowerFailure() публичный Метод

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
Результат void

SpawnNewTrain() публичный Метод

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
Результат void

StartSimulation() публичный Метод

Starts the simulation timer to update train positions
public StartSimulation ( ) : void
Результат void

StopSimulation() публичный Метод

Stops the simulation and clears the lists of components to update
public StopSimulation ( ) : void
Результат void