Model Railroad System 2.2.2
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
TTSupport::TimeTableSystem Class Reference

This is the main Time Table Class. More...

#include <TimeTableSystem.h>

Public Member Functions

 TimeTableSystem (const string filename, char **outmessage=NULL)
 The constructor that creates a time table system from an existing file. More...
 
 TimeTableSystem (const string name, int timescale, int timeinterval)
 The constructor that creates a new, empty time table system from stratch, given a set of esentual parameters. More...
 
 ~TimeTableSystem ()
 Destructor. More...
 
int AddStation (string name, double smile)
 Add a new station to the system. More...
 
int FindStationByName (string name)
 Find a station by name. More...
 
int NumberOfStations () const
 Number of stations. More...
 
TTSupport::StationIthStation (int i)
 Return Ith station object. More...
 
const char * StationName (int i) const
 Return the Ith station name. More...
 
double SMile (int i) const
 Return the Ith station's scale mile location. More...
 
double TotalLength () const
 The total length of the route in scale miles. More...
 
int DuplicateStationIndex (int i) const
 The duplicate station index for a given station. More...
 
void SetDuplicateStationIndex (int i, int dup)
 Set the duplicate station index for a given station. More...
 
StorageTrackAddStorageTrack (int i, string name)
 Add a storage track to a station. More...
 
StorageTrackFindStorageTrack (int i, string name)
 Find a storage track at a station. More...
 
CabAddCab (string name, string color)
 Add a new cab to the system. More...
 
int NumberOfCabs () const
 The nymber of cabs. More...
 
TrainAddTrain (string name, string number, int speed, int classnumber, int departure, int start=0, int end=-1)
 Add a train to the system, short version. More...
 
TrainAddTrainLongVersion (string name, string number, int speed, int classnumber, int departure, int start, int end, const doubleVector *layoverVector, const stringVector *cabnameVector, const stringVector *storageTrackVector, char **outmessage=NULL)
 Add a train to the system, long version (includes storage track checking). More...
 
bool DeleteTrain (string number, char **outmessage=NULL)
 Delete a train. More...
 
CabFindCab (string name) const
 Find a cab (by name). More...
 
TrainFindTrainByName (string name) const
 Find a train by name. More...
 
TrainFindTrainByNumber (string number) const
 Find a train by number (or symbol). More...
 
int NumberOfTrains () const
 Return the number of trains. More...
 
int NumberOfNotes () const
 Return the number of notes. More...
 
const char * Note (int i)
 Return the ith note (1-based!) as a string. More...
 
int AddNote (string newnote)
 Add a note to the notes vector. More...
 
bool SetNote (int i, string note)
 Set the ith note (1-based!). More...
 
const char * GetPrintOption (const char *key) const
 Fetch a print option. More...
 
void SetPrintOption (const char *key, string value)
 Set a print option. More...
 
bool WriteNewTimeTableFile (string filename="TimeTableFile.tt", bool setfilename=false, char **outmessage=NULL)
 Write out a Time Table System to a new file. More...
 
bool WriteOldTimeTableFile (char **outmessage=NULL)
 Write an old time table file. More...
 
int TimeScale () const
 Return time scale. More...
 
int TimeInterval () const
 Return time interval. More...
 
const char * Name () const
 Return the name of the system. More...
 
const char * Filename () const
 Return file pathname. More...
 
bool CreateLaTeXTimetable (string filename, char **outmessage=NULL)
 Create a LaTeX file for generating a (hard copy) Employee Timetable. More...
 
CabNameMap::const_iterator FirstCab () const
 First cab. More...
 
CabNameMap::const_iterator LastCab () const
 Last cab. More...
 
TrainNumberMap::const_iterator FirstTrain () const
 First train. More...
 
TrainNumberMap::const_iterator LastTrain () const
 Last train. More...
 
OptionHashMap::const_iterator FirstPrintOption () const
 First Print option. More...
 
OptionHashMap::const_iterator LastPrintOption () const
 Last Print option. More...
 

Protected Member Functions

 TimeTableSystem ()
 The default constructor. More...
 

Private Member Functions

string ReadNote (istream &in) const
 Read in a note. More...
 
ostream & WriteNote (ostream &out, string note) const
 Write out a note. More...
 
bool MakeTimeTableGroupByClass (ostream &out, TrainList &allTrains, TrainList &forwardTrains, TrainList &backwardTrains, char **outmessage=NULL)
 Make a time table grouped by class. More...
 
bool MakeTimeTableGroupManually (ostream &out, int maxTrains, TrainList &allTrains, TrainList &forwardTrains, TrainList &backwardTrains, char **outmessage=NULL)
 Make a time table grouped manually. More...
 
bool MakeTimeTableOneTable (ostream &out, TrainList &allTrains, TrainList &forwardTrains, TrainList &backwardTrains, string header, string sectionTOP, char **outmessage=NULL)
 Make a time table as a single table. More...
 
bool MakeTimeTableOneTableStationsLeft (ostream &out, TrainList &trains, string header, string sectionTOP, char **outmessage=NULL)
 Make a time table as a single table, with the stations on the left (single direction trains). More...
 
bool MakeTimeTableOneTableStationsCenter (ostream &out, TrainList &forwardTrains, TrainList &backwardTrains, string header, string sectionTOP, char **outmessage=NULL)
 Make a time table as a single table, with the stations in the center (bi-directional trains). More...
 
void ComputeTimes (TrainTimesAtStation &timesAtStations, TrainList &trains)
 Precompute station times, given a list of trains. More...
 

Private Attributes

string name
 The name of the time table system. More...
 
PathName filepath
 The pathname of the file the system was loaded from. More...
 
int timescale
 Time scale. More...
 
int timeinterval
 Time interval. More...
 
StationVector stations
 Station stop vector. More...
 
CabNameMap cabs
 Cap name map. More...
 
TrainNumberMap trains
 Train number/symbol map. More...
 
vector< string > notes
 Notes. More...
 
OptionHashMap printOptions
 Print option hash table. More...
 
bool TOCP
 Table Of Contents?
More...
 
string DirectionName
 Direction Name. More...
 

Detailed Description

This is the main Time Table Class.

It implements all of the basic data and algorithms used in the Time Table program.

This class includes code to load a set of stations and the trains that run between these stations, along with code to read and write a time table file and code to create a formatted time table, suitable for printing (by way of LaTeX).

Author
Robert Heller <heller@deepsoft.com>

Constructor & Destructor Documentation

◆ TimeTableSystem() [1/3]

TTSupport::TimeTableSystem::TimeTableSystem ( )
inlineprotected

The default constructor.

This is protected to prevent the creation of an uninitialized class instance, which would be an error. Making the default constructor a protected method will cause a compiler error when application code attempts to create a TimeTableSystem instance without using one of the parameterized constructor. There is no meaningful way to create a proper TimeTableSystem without supplying some parameters.

◆ TimeTableSystem() [2/3]

TTSupport::TimeTableSystem::TimeTableSystem ( const string  filename,
char **  outmessage = NULL 
)

The constructor that creates a time table system from an existing file.

The file is read in and the class is properly initialized from the data in the file.

Parameters
filenameThe name of the file to load.
outmessagePointer to a pointer to receive any error messages for any errors that might occur.

◆ TimeTableSystem() [3/3]

TTSupport::TimeTableSystem::TimeTableSystem ( const string  name,
int  timescale,
int  timeinterval 
)

The constructor that creates a new, empty time table system from stratch, given a set of esentual parameters.

Parameters
nameThe name of the time table system.
timescaleNumber of time units per 24 hours. There are 1440 minutes in 24 hours.
timeintervalThe tick frequency in time units.

◆ ~TimeTableSystem()

TTSupport::TimeTableSystem::~TimeTableSystem ( )

Destructor.

Properly clean up and free up all used space.

Member Function Documentation

◆ AddCab()

Cab * TTSupport::TimeTableSystem::AddCab ( string  name,
string  color 
)

Add a new cab to the system.

With DC systems this would be an actual cab. With DCC systems, this can be used to define a logical operator for the train. The color is used for visual distintion. A pointer to the new cab object is returned.

Parameters
nameThe name of the cab.
colorThe color of the cab.

◆ AddNote()

int TTSupport::TimeTableSystem::AddNote ( string  newnote)
inline

Add a note to the notes vector.

Parameters
newnoteThe text of the new note.

References notes.

◆ AddStation()

int TTSupport::TimeTableSystem::AddStation ( string  name,
double  smile 
)

Add a new station to the system.

Creates a new Station class instance and adds it to the station vector. Stations must be added in order of their scale mile location. If the new station is out of order, -1 is returned and the station is not added!

Parameters
nameThe name of the station.
smileThe scale mile along the route where the station is located.

◆ AddStorageTrack()

StorageTrack * TTSupport::TimeTableSystem::AddStorageTrack ( int  i,
string  name 
)
inline

Add a storage track to a station.


Sometimes stations, especially major terminals, have extra tracks for storing terminating and originating trains. Returns the NULL pointer if the index is out of range. Otherwise returns the pointer to the new StorageTrack object.

Parameters
iThe index of the station to be updated.
nameThe name for the new storage track.

References i, name, and stations.

◆ AddTrain()

Train * TTSupport::TimeTableSystem::AddTrain ( string  name,
string  number,
int  speed,
int  classnumber,
int  departure,
int  start = 0,
int  end = -1 
)

Add a train to the system, short version.


Creates a new Train opject and adds it to the train map. The short version assumes that the train does not layover at any of the stops. Layover times can be added later. Returns a pointer to the new Train object.

Parameters
nameThe name of the train.
numberThe number (or symbol) of the train.
speedThe trains maximum speed.
classnumberThe class (inverse priority) of the train.
departureThe train's departure time.
startThe train's origin station index. Defaults to the first station.
endThe train's destination station index. Defaults to the last station.

◆ AddTrainLongVersion()

Train * TTSupport::TimeTableSystem::AddTrainLongVersion ( string  name,
string  number,
int  speed,
int  classnumber,
int  departure,
int  start,
int  end,
const doubleVector layoverVector,
const stringVector cabnameVector,
const stringVector storageTrackVector,
char **  outmessage = NULL 
)

Add a train to the system, long version (includes storage track checking).


This version includes layover times, cabnames, and storage track assignments. Returns a pointer to the new Train object or the NULL pointer if there was an error, in which case the error message will be stored in the pointer provided.

Parameters
nameThe name of the train.
numberThe number (or symbol) of the train.
speedThe trains maximum speed.
classnumberThe class (inverse priority) of the train.
departureThe train's departure time.
startThe train's origin station index.
endThe train's destination station index.
layoverVectorThe train's layover vector.
cabnameVectorThe train's departure cab name vector.
storageTrackVectorThe train's storage track name vector.
outmessagePointer to a pointer to receive any error messages for any errors that might occur.

◆ ComputeTimes()

void TTSupport::TimeTableSystem::ComputeTimes ( TrainTimesAtStation timesAtStations,
TrainList trains 
)
private

Precompute station times, given a list of trains.

This helper function creates the table cell information for a time table.

Parameters
timesAtStationsThe time table matrix to be filled in.
trainsA list of trains to process.

◆ CreateLaTeXTimetable()

bool TTSupport::TimeTableSystem::CreateLaTeXTimetable ( string  filename,
char **  outmessage = NULL 
)

Create a LaTeX file for generating a (hard copy) Employee Timetable.

This method create a LaTeX source file from the information in the time table structure. It access various print options to control how the LaTeX file is generated.

Parameters
filenameThe name of the LaTeX file to create.
outmessagePointer to a pointer to receive any error messages for any errors that might occur.

◆ DeleteTrain()

bool TTSupport::TimeTableSystem::DeleteTrain ( string  number,
char **  outmessage = NULL 
)

Delete a train.


Returns true if the train was successfully deleted and false if not. If the train was not deleted, an error message will be provided in the pointer provided.

Parameters
numberThe train number or symbol.
outmessagePointer to a pointer to receive any error messages for any errors that might occur.

◆ DuplicateStationIndex()

int TTSupport::TimeTableSystem::DuplicateStationIndex ( int  i) const
inline

The duplicate station index for a given station.


Only meaningful for out and back type layouts or layouts that have shared trackage. This would be stations along shared trackage. Returns -1 if the index is out of range or if there is not a duplicate station for the ith station.

Parameters
iThe index of the station.

References i, and stations.

◆ Filename()

const char * TTSupport::TimeTableSystem::Filename ( ) const
inline

Return file pathname.

References filepath, and TTSupport::PathName::FullPath().

◆ FindCab()

Cab * TTSupport::TimeTableSystem::FindCab ( string  name) const

Find a cab (by name).


Returns the pointer to the named cab or NULL if the cab was not found.

Parameters
nameThe cab name to look for.

◆ FindStationByName()

int TTSupport::TimeTableSystem::FindStationByName ( string  name)

Find a station by name.

Returns the index of the station or -1 if the station cannot be found.

Parameters
nameThe name of the station.

◆ FindStorageTrack()

StorageTrack * TTSupport::TimeTableSystem::FindStorageTrack ( int  i,
string  name 
)
inline

Find a storage track at a station.

Sometimes stations, especially major terminals, have extra tracks for storing terminating and originating trains. Returns the NULL pointer if the index is out of range or if there is no storage track with the specified name. Otherwise the StorageTrack object pointer is returned.

Parameters
iThe index of the station to be updated.
nameThe name of the storage track.

References i, name, and stations.

◆ FindTrainByName()

Train * TTSupport::TimeTableSystem::FindTrainByName ( string  name) const

Find a train by name.

Returns the pointer to the named train or NULL if the train was not found.

Parameters
nameThe train name to look for.

◆ FindTrainByNumber()

Train * TTSupport::TimeTableSystem::FindTrainByNumber ( string  number) const

Find a train by number (or symbol).

Returns the pointer to the train or NULL if the train was not found.

Parameters
numberThe train number (or symbol) to look for.

◆ FirstCab()

CabNameMap::const_iterator TTSupport::TimeTableSystem::FirstCab ( ) const
inline

First cab.

Return a const iterator for the first cab.

References cabs.

◆ FirstPrintOption()

OptionHashMap::const_iterator TTSupport::TimeTableSystem::FirstPrintOption ( ) const
inline

First Print option.

Return a const iterator for the first print option.

References printOptions.

◆ FirstTrain()

TrainNumberMap::const_iterator TTSupport::TimeTableSystem::FirstTrain ( ) const
inline

First train.

Return a const iterator for the first train.

References trains.

◆ GetPrintOption()

const char * TTSupport::TimeTableSystem::GetPrintOption ( const char *  key) const
inline

Fetch a print option.


Returns the value of a specified print option or the empty string if the print option was not found.

Parameters
keyThe name of the print option.

References printOptions.

◆ IthStation()

TTSupport::Station * TTSupport::TimeTableSystem::IthStation ( int  i)
inline

Return Ith station object.

Returns the NULL pointer if the index is out of range.

Parameters
iThe index of the station.

References i, and stations.

◆ LastCab()

CabNameMap::const_iterator TTSupport::TimeTableSystem::LastCab ( ) const
inline

Last cab.

Return a const iterator for the last cab.

References cabs.

◆ LastPrintOption()

OptionHashMap::const_iterator TTSupport::TimeTableSystem::LastPrintOption ( ) const
inline

Last Print option.

Return a const iterator for the last print option.

References printOptions.

◆ LastTrain()

TrainNumberMap::const_iterator TTSupport::TimeTableSystem::LastTrain ( ) const
inline

Last train.

Return a const iterator for the last train.

References trains.

◆ MakeTimeTableGroupByClass()

bool TTSupport::TimeTableSystem::MakeTimeTableGroupByClass ( ostream &  out,
TrainList allTrains,
TrainList forwardTrains,
TrainList backwardTrains,
char **  outmessage = NULL 
)
private

Make a time table grouped by class.

Writes a time table LaTeX file grouped by train class. Each class will have its own table in its own section. Returns true if successfull and false if there were problems (errors).

Parameters
outThe LaTeX output stream.
allTrainsA list of all of the trains.
forwardTrainsA list of all forward moving trains.
backwardTrainsA list of all backward moving trains.
outmessagePointer to a pointer to receive any error messages for any errors that might occur.

◆ MakeTimeTableGroupManually()

bool TTSupport::TimeTableSystem::MakeTimeTableGroupManually ( ostream &  out,
int  maxTrains,
TrainList allTrains,
TrainList forwardTrains,
TrainList backwardTrains,
char **  outmessage = NULL 
)
private

Make a time table grouped manually.

Writes a time table LaTeX file grouped manually. Returns true if successfull and false if there were problems (errors).

Parameters
outThe LaTeX output stream.
maxTrainsThe maximum number of trains per table.
allTrainsA list of all of the trains.
forwardTrainsA list of all forward moving trains.
backwardTrainsA list of all backward moving trains.
outmessagePointer to a pointer to receive any error messages for any errors that might occur.

◆ MakeTimeTableOneTable()

bool TTSupport::TimeTableSystem::MakeTimeTableOneTable ( ostream &  out,
TrainList allTrains,
TrainList forwardTrains,
TrainList backwardTrains,
string  header,
string  sectionTOP,
char **  outmessage = NULL 
)
private

Make a time table as a single table.

Writes a time table LaTeX file with all trains in a single table. This only makes sense if the total number of trains is small.

Parameters
outThe LaTeX output stream.
allTrainsA list of all of the trains.
forwardTrainsA list of all forward moving trains.
backwardTrainsA list of all backward moving trains.
headerString (LaTeX code) to use for the time table header.
sectionTOPString (LaTeX code) to use for the section start.
outmessagePointer to a pointer to receive any error messages for any errors that might occur.

◆ MakeTimeTableOneTableStationsCenter()

bool TTSupport::TimeTableSystem::MakeTimeTableOneTableStationsCenter ( ostream &  out,
TrainList forwardTrains,
TrainList backwardTrains,
string  header,
string  sectionTOP,
char **  outmessage = NULL 
)
private

Make a time table as a single table, with the stations in the center (bi-directional trains).

Parameters
outThe LaTeX output stream.
forwardTrainsA list of all forward moving trains.
backwardTrainsA list of all backward moving trains.
headerString (LaTeX code) to use for the time table header.
sectionTOPString (LaTeX code) to use for the section start.
outmessagePointer to a pointer to receive any error messages for any errors that might occur.

◆ MakeTimeTableOneTableStationsLeft()

bool TTSupport::TimeTableSystem::MakeTimeTableOneTableStationsLeft ( ostream &  out,
TrainList trains,
string  header,
string  sectionTOP,
char **  outmessage = NULL 
)
private

Make a time table as a single table, with the stations on the left (single direction trains).

Parameters
outThe LaTeX output stream.
trainsA list of the trains.
headerString (LaTeX code) to use for the time table header.
sectionTOPString (LaTeX code) to use for the section start.
outmessagePointer to a pointer to receive any error messages for any errors that might occur.

◆ Name()

const char * TTSupport::TimeTableSystem::Name ( ) const
inline

Return the name of the system.

References name.

◆ Note()

const char * TTSupport::TimeTableSystem::Note ( int  i)
inline

Return the ith note (1-based!) as a string.


Returns the NULL pointer if the index is out of range.

Parameters
iThe note index. The first note is at index 1, not 0!.

References i, and notes.

◆ NumberOfCabs()

int TTSupport::TimeTableSystem::NumberOfCabs ( ) const
inline

The nymber of cabs.

References cabs.

◆ NumberOfNotes()

int TTSupport::TimeTableSystem::NumberOfNotes ( ) const
inline

Return the number of notes.

References notes.

◆ NumberOfStations()

int TTSupport::TimeTableSystem::NumberOfStations ( ) const
inline

Number of stations.

Returns the number of stations in the system.

References stations.

◆ NumberOfTrains()

int TTSupport::TimeTableSystem::NumberOfTrains ( ) const
inline

Return the number of trains.

References trains.

◆ ReadNote()

string TTSupport::TimeTableSystem::ReadNote ( istream &  in) const
private

Read in a note.

Reads a note from a stream. Returns the note text.

Parameters
inStream to read from.

◆ SetDuplicateStationIndex()

void TTSupport::TimeTableSystem::SetDuplicateStationIndex ( int  i,
int  dup 
)
inline

Set the duplicate station index for a given station.

Only meaningful for out and back type layouts or layouts that have shared trackage. This would be stations along shared trackage. setting the duplicate station index indicates there is no duplicate station

Parameters
iThe index of the station to be updated.
dupThe other station index sharing this station location.

References i, and stations.

◆ SetNote()

bool TTSupport::TimeTableSystem::SetNote ( int  i,
string  note 
)
inline

Set the ith note (1-based!).


Updates the text of the specificed note. Returns true if the note was updated or false if the index was out of range.

Parameters
iThe note index. The first note is at index 1, not 0!.
noteThe new text for the note.

References i, and notes.

◆ SetPrintOption()

void TTSupport::TimeTableSystem::SetPrintOption ( const char *  key,
string  value 
)
inline

Set a print option.


Sets the value of a print option. Creates a new hash table element if the specified print option does not already exist.

Parameters
keyThe name of the print option to be set.
valueThe value to set the print option to.

References printOptions.

◆ SMile()

double TTSupport::TimeTableSystem::SMile ( int  i) const
inline

Return the Ith station's scale mile location.

Returns -1.0 if the index is out of range.

Parameters
iThe index of the station.

References i, and stations.

◆ StationName()

const char * TTSupport::TimeTableSystem::StationName ( int  i) const
inline

Return the Ith station name.

Returns the NULL pointer if the index is out of range.

Parameters
iThe index of the station.

References i, and stations.

◆ TimeInterval()

int TTSupport::TimeTableSystem::TimeInterval ( ) const
inline

Return time interval.

References timeinterval.

◆ TimeScale()

int TTSupport::TimeTableSystem::TimeScale ( ) const
inline

Return time scale.

References timescale.

◆ TotalLength()

double TTSupport::TimeTableSystem::TotalLength ( ) const
inline

The total length of the route in scale miles.


This is just the scale mile location of the last station along the route.

References stations.

◆ WriteNewTimeTableFile()

bool TTSupport::TimeTableSystem::WriteNewTimeTableFile ( string  filename = "TimeTableFile.tt",
bool  setfilename = false,
char **  outmessage = NULL 
)

Write out a Time Table System to a new file.


The current contents of the time table is written to a new time table file. Returns true if successful and false if not.

Parameters
filenameThe name of the file to write (if empty, use existing name, if available).
setfilenameChange the filename if true.
outmessagePointer to a pointer to receive any error messages for any errors that might occur.

Referenced by WriteOldTimeTableFile().

◆ WriteNote()

ostream & TTSupport::TimeTableSystem::WriteNote ( ostream &  out,
string  note 
) const
private

Write out a note.


Writes the note text to a stream. Returns the stream.

Parameters
outStream to write to.
noteThe note text.

◆ WriteOldTimeTableFile()

bool TTSupport::TimeTableSystem::WriteOldTimeTableFile ( char **  outmessage = NULL)
inline

Write an old time table file.


The current contents of the time table is written to the file name stored in the time table object. This method just calls the WriteNewTimeTableFile method with the old file name. Returns true if successful and false if not.

Parameters
outmessagePointer to a pointer to receive any error messages for any errors that might occur.

References filepath, TTSupport::PathName::FullPath(), and WriteNewTimeTableFile().

Member Data Documentation

◆ cabs

CabNameMap TTSupport::TimeTableSystem::cabs
private

Cap name map.

Referenced by FirstCab(), LastCab(), and NumberOfCabs().

◆ DirectionName

string TTSupport::TimeTableSystem::DirectionName
private

Direction Name.


Used by print functions.

◆ filepath

PathName TTSupport::TimeTableSystem::filepath
private

The pathname of the file the system was loaded from.

Referenced by Filename(), and WriteOldTimeTableFile().

◆ name

string TTSupport::TimeTableSystem::name
private

The name of the time table system.

Referenced by AddStorageTrack(), FindStorageTrack(), and Name().

◆ notes

vector<string> TTSupport::TimeTableSystem::notes
private

Notes.

Referenced by AddNote(), Note(), NumberOfNotes(), and SetNote().

◆ printOptions

OptionHashMap TTSupport::TimeTableSystem::printOptions
private

Print option hash table.

Referenced by FirstPrintOption(), GetPrintOption(), LastPrintOption(), and SetPrintOption().

◆ stations

StationVector TTSupport::TimeTableSystem::stations
private

◆ timeinterval

int TTSupport::TimeTableSystem::timeinterval
private

Time interval.

Referenced by TimeInterval().

◆ timescale

int TTSupport::TimeTableSystem::timescale
private

Time scale.

Referenced by TimeScale().

◆ TOCP

bool TTSupport::TimeTableSystem::TOCP
private

Table Of Contents?

Used by print functions.

◆ trains

TrainNumberMap TTSupport::TimeTableSystem::trains
private

Train number/symbol map.

Referenced by FirstTrain(), LastTrain(), and NumberOfTrains().