TsUtil Class Reference
Uses class : Trackside
Is final : Yes
Handles class types : Signal, Junction, Trigger, TrackMark, Vehicle.
Accepts : string, bool
Returns : string, bool, float
Public Methods
public string GetNextSignalNameFacing(string tsObjName)
Parameters :
tsObjName - the name of a valid Trackside class object to search from
Returns :
The name of the next signal in front of the given object on the current track path
which is aligned in the same direction as the track, (i.e. the signal faces towards you looking ahead).
Default :
One of the message constants as below
public string GetNextSignalNameOpposing(string tsObjName)
Parameters :
tsObjName - the name of a valid Trackside class object to search from
Returns :
The name of the next signal in front of the given object on the current track path
which is not aligned in the same direction as the track, (i.e. the signal faces away from you looking ahead).
Default :
One of the message constants as below
public string GetPreviousSignalNameFacing(string tsObjName)
Parameters :
tsObjName - the name of a valid Trackside class object to search from
Returns :
The name of the previous signal behind the given object on the current track path
which is aligned in the same direction as the track
(i.e. is the next signal facing away from you looking backwards).
Default :
One of the message constants as below
public string GetPreviousSignalNameOpposing(string tsObjName)
Parameters :
tsObjName - the name of a valid Trackside class object to search from
Returns :
The name of the previous signal behind the given object on the current track path
which is aligned in the opposite direction to the track
(i.e. is the next signal facing towards you looking backwards).
Default :
One of the message constants as below
public bool GetSignalHasStop(string sigName)
Parameters :
sigName - the name of a valid Signal class object to test
Returns :
True if the signal has a STOP aspect, false otherwise.
Default :
False if no valid signal name given or signal has no STOP aspect.
public bool IsLastSignalFacing(string sigName)
Parameters :
sigName - the name of a valid Signal class object to test
Returns :
True if the signal is the last facing one on the current track path, false otherwise.
Default :
False if no valid signal name given or signal is not the last.
public string GetSignalRGB(string sigName)
Parameters :
sigName - the name of a valid Signal class object to get the aspect colour of
Returns :
A hexadecimal colour code for use in HTML windows which corresponds to the signal's current aspect.
Default :
Light blue colour code if no valid signal (see colour code constants below).
public string GetNextJunctionName(string tsObjName, bool direction)
Parameters :
tsObjName - the name of a valid Trackside class object to search from
direction - direction of search relative to given object
Returns :
The name of the next junction from the given object on the current track path
in the specified direction, true to search ahead, false to search behind.
Note: This direction depends on the alignment of the object being searched from.
Default :
One of the message constants as below
public string GetNextTriggerName(string tsObjName, bool direction)
Parameters :
tsObjName - the name of a valid Trackside class object to search from
direction - direction of search relative to given object
Returns :
The name of the next trigger from the given object on the current track path
in the specified direction, true to search ahead, false to search behind.
Note: This direction depends on the alignment of the object being searched from.
Default :
One of the message constants as below
public string GetNextTrackMarkName(string tsObjName, bool direction)
Parameters :
tsObjName - the name of a valid Trackside class object to search from
direction - direction of search relative to given object
Returns :
The name of the next trackmark from the given object on the current track path
in the specified direction, true to search ahead, false to search behind.
Note: This direction depends on the alignment of the object being searched from.
Default :
One of the message constants as below
public string GetNextVehicleName(string tsObjName, bool direction)
Parameters :
tsObjName - the name of a valid Trackside class object to search from
direction - direction of search relative to given object
Returns :
The name of the next vehicle (traincar) from the given object on the current track path
in the specified direction, true to search ahead, false to search behind.
Note: This direction depends on the alignment of the object being searched from.
Default :
One of the message constants as below
public float GetNextVehicleDistance(string tsObjName, bool direction)
Parameters :
tsObjName - the name of a valid Trackside class object to search from
direction - direction of search relative to given object
Returns :
The distance in metres to the next vehicle (traincar) from the given object on the current track path
in the specified direction, true to search ahead, false to search behind.
Note: This direction depends on the alignment of the object being searched from.
Default :
100000.0 (100 km) if no valid search object or no vehicle found.
Public Attributes
Signal RGB Colour Constants
(the prefix letters 'lc' mean 'link colour')
lcRED = #FF2332
lcYELLOW = #EBC823
lcGREEN = #32C832
lcBLUE = #00CDFF
Message Return Constants
NSF = "No Signal found"
USF = "Un-named Signal found"
NJF = "No Junction found"
UJF = "Un-named Junction found"
NTRF = "No Trigger found"
UTRF = "Un-named Trigger found"
NTMF = "No TrackMark found"
UTMF = "Un-named TrackMark found"
NVF = "No Vehicle found"
UVF = "Un-named Vehicle found"
SDU = "Search direction unspecified"
ITO = "Invalid Trackside object name parameter"
How to Use
Place a copy of the utilities script in your project folder,
then include it like any other file.
You can then declare an instance of it and use it by reference like any other script object.
--------------------------------------------------------------------------------------------
include "TracksideUtils.gs"
// other includes go here
class myClass isclass someClass {
TsUtil tsu = new TsUtil();
string nextSig = tsu.GetNextSignalNameFacing(currentObjName);
if (nextSig and (nextSig != tsu.NSF) and (nextSig != tsu.USF)) // we have a signal with a name
// You can nest the commands for a more sophisticated search pattern, e.g.
string nextSigFromJunction = tsu.GetNextSignalNameFacing(tsu.GetNextJunctionName(currentObjName, true));
};
--------------------------------------------------------------------------------------------
So long as you use your 'tsu' object you can refer to all the methods and attributes in the normal way.
I've enjoyed writing this as it fulfilled a need I had for a project, however
I hope you get some interesting and useful results with it in your own work too |:)
All material is ©Wulf, January 31st, 2005