Trains may be tagged with barcodes, labels, RFID tags or similar devices so that a controller can know where each train is. Tcc currently supports RFID tags read with ID-12 readers. Other device readers may be supported later, and will probably share the same script interface (Tag Reader methods and elements, described below).
ID-12 RFID readers may be connected directly to a serial port, or as this consumes serial ports excessively, through a MERG 8 to 1 reader multiplexer. Multiple serial ports will be handled simultaneously. The ID-12 readers output a 40 bit code, unique to each tag.
Each reader is a separate object within the tcl script, and they are declared by:
TagReaders: r1, r2, r3 { declare 3 tag readers } |
The readers are identified as being RFID readers by adding an RFID interface in the Network Configuration window, and selecting which serial port it is using.
Once a code has been received from a reader that code string is looked up in the database, and translated into a stock type and stock id. The stock type identifies whether the item is a loco, wagon, coach or whatever. Only stock type zero (meaning loco) has any special meaning to the tag reader software but other values can take whatever meaning you wish, and can be used in the tcl script normally. The stock id should be a value that is unique within that stock type, so if stock type is zero then stock id is loco id.
Each tag reader maintains a list of locos and a list of all rolling stock detected by that reader. These lists are cumulative - that is each time a tag is read then that item of rolling stock is added to the list of stock, and possibly to the list of locos if not already in those lists. Thus the tagged elements in a train are remembered. The script can monitor how many items are in each list, and extract the stock types and ids from the lists. It is the responsibility of the script to clear the lists when the train is deemed to have passed, otherwise the lists will simply grow as all the trains you are running get added to the lists!
In addition to the stock and loco lists, there is a shared unknown codes list. When a code is received that is not stored in the database it is added to the list of unknown codes. This allows the script to prompt the user to take action, or even to simply assume it is a loco and automatically allocate a loco id and add it to the database.
A tcl script could do many things, but some suggestions include:
Check that the train has not split.
Put a picture of the loco (or train) in the correct place of a CTC panel as the train progresses past the readers.
Display a text notice that the train has departed a station.
Calculate the length of the train (if a length column were added to the database).
The following methods are available:
Method |
Description |
r1.clear () |
Clear the stock and loco lists. The unknown codes list is not cleared. |
r1.getStockType (n) |
Return the type of the n-th tag read. Type zero is reserved to mean loco. Other types can be defined as you wish. 'n' may be any value from 1 to stockCount (see below) |
r1.getStockId (n) |
Return the unique id of the n-th tag read. 'n' may be any value from 1 to stockCount (see below) |
r1.getLocoId (n) |
Return the unique id of the n-th loco read (codes where the stock type was zero). 'n' may be any value from 1 to locoCount (see below) |
r1.getUnknownCode (n) |
Return the string value of the n-th code which was not present in the database. If action is taken to add that code to the database then next time it is read by a reader it will be removed from the unknown codes list. 'n' may be any value from 1 to unknownCount. All readers share this list. |
The following elements are available:
stockCount |
The number of successfully translated (ie, present in the database) unique tags read since this tag reader object was last cleared using clear (). |
locoCount |
The number of unique locos scanned since last cleared. |
unknownCount |
The number of codes read that were not in the database when last read. |
Last updated 6 Mar 2008
© Howard Amos 2007-2008