 Remote Train Control Program for Windows - updated to version 5.0.4   15 Jun 2026

(c) Copyright 2015-2024 by Mark DiVecchio

    This file is part of Remote Train Control.

    Remote Train Control is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Remote Train Control is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Remote Train Control.  If not, see <http://www.gnu.org/licenses/>.

----------------------------------------------------------------------------------------------------------

March 21, 2015 8:19 PM

PC Control of MTH Engines by Serial Connection to the TIU

To me, MTH makes the best engines and rolling stock for my railroads of choice, the Pittsburgh & Lake Erie Railroad and the Aliquippa & Southern Railroad (where my grandfather worked). MTH has many many engines and dozen of pieces of rolling stock for these railroads. My layout uses only MTH's DCS.

DCS has been out for almost 15 years. I've been waiting for a way to control my layout using my PC. I've always used Windows PC's so this effort was done originally using XP and more recently Windows 7 and Windows 10.

A few years ago, Mike Hewett presented a PC interface to the tethered mode of operation of DCS. He showed how to sniff out the RS-232 packets running between the Remote and the TIU, how to save those packets and how to later transmit those packets to the TIU from the PC.

Mike presented his findings in three videos which he produced around May of 2011. Look at those three videos before you continue with my description.

Chapter 1 https://www.youtube.com/watch?v=MxlUb-YccZw
Chapter 2 https://www.youtube.com/watch?v=IBrhLSVHjIo
Chapter 3 https://www.youtube.com/watch?v=oqaeeR3pgPw

Look at this OGR Forum thread for a followup:

http://ogrforum.ogaugerr.com/topic/wonderful-gift-dcs-to-pc-control?reply=5371679459030161#5371679459030161

Mike made more progress as shown in this video from 2013

https://www.youtube.com/watch?v=Ug5CSZFwo-c

I think that I first saw what Mike did around October of 2011 as my earliest date stamps on files that I've saved are from that date.

Mike's methodology was to record the packets sent by the Remote when each key on the Remote was pressed. Without regard to the contents of the packets, he saved them in a file. Then, later, his PC program could read up those saved packets and send them to the TIU. He created a very nice touch screen interface and he could run his DCS trains from his PC.

I contacted Mike back then and he sent me copies of his program and I was able to build up his interface to the TIU, sniff out the needed packets and I had a way to control my trains from my PC.

This worked up to a point. When I added a new engine number, I had to run the packet sniffer again and pick up the packets needed for the new engine number. Mike's program only captured a subset of the many, many types of commands that could be sent to the TIU. Mike did not read back responses from the TIU or process any of those returned packets.

I was looking for something more. I needed to understand the protocol over the tether cable.

With a lot of effort, I was able to understand almost all of the communications between the Remote and TIU. I am now able to create packets to control the DCS engines. The packets are complete with correct addressing, command syntax and CRC.

I figured this out by examination of the packets that I could sniff using Mike's original RS-232 interface design and the port settings that he found. Without Mike's insights into the RS-232 data stream, I don't think that would have been able to get a foothold into this protocol.

So again, I figured this out just by looking at the RS-232 stream over the tether cable. No code disassembly, no logic analyzers, no opening up of Remotes or TIU's.

I made up a video (Screen Capture) of the operation of my RTC or Remote Train Control program. This video demonstrates part of its use:

http://www.silogic.com/trains/RTC_Running.html


Mark
----
March 25, 2015 10:19 PM

I'd like to thank everyone for taking the time to comment on my posting. I've waited to follow up so I could add my thoughts to the comments.

First, I've posted a few more videos on my web page:

http://www.silogic.com/trains/RTC_Running.html

My purpose in what I did was to develop a new way to run my trains.  I'm not competing with anyone else, especially MTH since they don't have a product for PC control that they sell or give away. I'm not selling anything that I've done. Once I determine that it is working fairly well, I am going to send the program to whoever can use it. It will probably be distributed under one of the GNU Public Licenses.

Understanding the protocol over the tether is what is most useful. Mike (skylar) wrote about wanting to build a system with sensors that adds location information to the mix. I can envision something like the operation of the Lionel 132 Automatic Stop Station that you could automate with location sensors and PC control.

The DCS patent does not talk about the protocol over the tether. I've learned from my analysis that the protocol is an industry standard RLL(0,1) which is just a fancy way of saying how often the RS-232 signal changes from 1 to 0. Part of the encoding is actually patented and not by MTH - #5,625,644 issued in 1997. The next part uses Morton or Z-Curve encodings. You can Google that. Third are the commands themselves. They are in ASCII and are based on an Application Note published by Microchip Technology in 2002, look for AN759. These public documents describe the protocol completely, it was just adapted to model train control. All of these documents were found on the Internet.

PC control has one (at least) major drawback and that is the need for a wired connection to the TIU. My program only handles one RS-232 port but there is no reason that a program could not be written that uses 5 RS-232 ports, each connected to the 5 TIU possible. In other words, once the protocol is known, practically anything can be done by writing software. I haven't yet completed my analysis of the protocol. My program knows all of the train control commands and AIU commands. I know how to do lashups but I haven't added that to the program. I've not yet looked at a TMCC interface or conventional operation. (Update Apr 2015 - RTC now handles Lash Ups and Conventional operation)

Writing a program that encompasses every aspect of train operation is not something one person can do alone. Maybe because of that, PC control will never be practicable. It is not possible for me to singlehandedly write a program that will satisfy everyone. But I can probably do enough to let enterprising and interested hobbyists have the ability to operate their trains in a different way.

My program, RTC, is nothing special. I wrote it using Borland C++ Builder because that is the software that I used years ago when I was still working. There are probably other better environments which would better handle the real-time control aspects (like asynchronous RS-232 characters arriving). C++ Builder is not really good at that. When I started writing the program, I had no idea what the protocol over the tether was. I had to write my program to handle many different protocols, of which all except one turned out to be deadends. For example, I used CRC code that could handle dozens of CRC algorithms. But only one was needed once I understood which one. All of that extra code is still in the program. The CRC code, by the way, was written by Ross Williams, who placed it in the public domain in 1993.

Mark

----------------------------------------------------------------------------------------------------------
Installation

0. Read through this readme file and read the GNU Public and Documentation Licenses.

1. Create a folder somewhere, call it "RTC" or something like that.

2. Extract the files in the ZIP archive into that new folder.

3. Build one of the TIU interfaces (wired or radio or WiFi) shown on my web pages. Read the file "Remote Control.pdf" from the ZIP archive.

4. Double click on the program name (Remote_Control.exe) to run it or create a shortcut on your desktop.

5. Look at my on-line videos and read the popup hints you get when you mouse over the controls

6. Good Luck

----------------------------------------------------------------------------------------------------------
12:00 PM 5/17/2016

posted to:

http://www.modeltrainjournal.com/phpBB3/viewtopic.php?f=2&t=16452
http://www.modeltrainforum.com/showthread.php?p=1113738#post1113738

PC Control of MTH Engines by Radio Connection to the TIU

To me, MTH makes the best engines and rolling stock for my railroads of choice, the Pittsburgh & Lake Erie Railroad and the Aliquippa & Southern Railroad (where my grandfather worked). MTH has many many engines and dozen of pieces of rolling stock for these railroads. My layout uses only MTH's DCS.

DCS has been out for almost 15 years. I've been waiting for a way to control my layout using my PC. I've always used Windows PC's so this effort was done originally using XP and more recently Windows 7 and Windows 10.

A few years ago, Mike Hewett presented a PC interface to the tethered mode of operation of DCS. He showed how to sniff out the RS-232 packets running between the Remote and the TIU, how to save those packets and how to later transmit those packets to the TIU from the PC. He connected to the TIU using a tether (phone cable).

Mike presented his findings in three videos which he produced around May of 2011. Look at those three videos before you continue with my description.

Chapter 1 https://www.youtube.com/watch?v=MxlUb-YccZw
Chapter 2 https://www.youtube.com/watch?v=IBrhLSVHjIo
Chapter 3 https://www.youtube.com/watch?v=oqaeeR3pgPw

Look at this OGR Forum thread for a followup:

http://ogrforum.ogaugerr.com/topic/wonderful-gift-dcs-to-pc-control?reply=5371679459030161#5371679459030161

Mike made more progress as shown in this video from 2013

https://www.youtube.com/watch?v=Ug5CSZFwo-c

I think that I first saw what Mike did around October of 2011 as my earliest date stamps on files that I've saved are from that date.

Mike's methodology was to record the packets sent by the Remote when each key on the Remote was pressed. Without regard to the contents of the packets, he saved them in a file. Then, later, his PC program could read up those saved packets and send them to the TIU. He created a very nice touch screen interface and he could run his DCS trains from his PC.

I contacted Mike back then and he sent me copies of his program and I was able to build up his interface to the TIU, sniff out the needed packets and I had a way to control my trains from my PC.

This worked up to a point. When I added a new engine number, I had to run the packet sniffer again and pick up the packets needed for the new engine number. Mike's program only captured a subset of the many, many types of commands that could be sent to the TIU. Mike did not read back responses from the TIU or process any of those returned packets.

I was looking for something more. I wanted to understand the protocol over the tether cable.

With a lot of effort, I was able to understand almost all of the communications between the Remote and TIU. I am now able to create packets to control the DCS engines. The packets are complete with correct addressing, command syntax and CRC.

I figured this out by examination of the packets that I could sniff using Mike's original RS-232 interface design and the port settings that he found. Without Mike's insights into the RS-232 data stream, I don't think that would have been able to get a foothold into this protocol.

So again, I figured this out just by looking at the RS-232 stream over the tether cable. No code disassembly, no logic analyzers, no opening up of Remotes or TIU's.

I made up videos (Screen Captures) of the operation of my RTC or Remote Train Control program. These videos demonstrates part of its use:

http://www.silogic.com/trains/RTC_Running.html

My purpose in what I did was to develop a new way to run my trains.  I'm not competing with anyone else, especially MTH since they don't have a product for PC control that they sell or give away. I'm not selling anything that I've done. The program and source code are freely available on my web page. It is distributed under the GNU Public Licenses.

Understanding the protocol over the tether is what is most useful. Mike wrote about wanting to build a system with sensors that adds location information to the mix. I can envision something like the operation of the Lionel 132 Automatic Stop Station that you could automate with location sensors and PC control. (Something that you could do 60 years ago but can't do today!)

The DCS patent does not talk about the serial protocol. I've learned from my analysis that the protocol is an industry standard RLL(0,1) which is just a fancy way of saying how often the RS-232 signal changes from 1 to 0. Part of the encoding is actually patented and not by MTH - #5,625,644 issued in 1997. The next part uses Morton or Z-Curve encodings. You can Google that. Third are the commands themselves. They are in ASCII and are based on an Application Note published by Microchip Technology in 2002, look for AN759. These public documents describe the protocol completely, it was just adapted to model train control. All of these documents were found on the Internet.

The original wired tethered connection to the TIU was the next to be replaced. I dug into understanding the radio connection between the Remote and TIU. Again, searches on the Internet provided the frequencies used. A hint on a blog pointed me toward OOK (On-Off Keying) as the mode of data transmission. I guessed that the command protocol over the radio was the same as used on the tether (it was). I learned about two different boards that use the TI CC1101 radio. This radio covers the frequencies required and speaks OOK. 

I learned how to program the CC1101 from scratch. I searched the Internet and got little bits of help. I found a program called SmartRF Studio 7 from TI which helps set the values needed for the CC1101 configuration registers. Months of digging through the CC1101 data sheet and test code for the Arduino's Atmega328p MCU finally led me to a working receiver. Then a working transmitter. I called my Arduino program "RTCModem". I could communicate between the PC and the TIU with my Remote Train Control program. (note: this paragraph took about 5 months actual work.)

I wrote RTC using Borland C++ Builder because that is the software that I used years ago when I was still working. There are probably other better environments which would better handle the real-time control aspects (like asynchronous RS-232 characters arriving). C++ Builder is not really good at that. When I started writing the program, I had no idea what the protocol to the TIU was. I had to write my program to handle many different protocols, of which all except one turned out to be deadends. For example, I used CRC code that could handle dozens of CRC algorithms. But only one was needed once I understood which one. All of that extra code is still in the program. The CRC code, by the way, was written by Ross Williams, who placed it in the public domain in 1993.

So the program is free from my web page. You can build a tether interface for a few dollars or buy one of two different radio implementations (about $50-$60). Not bought from me, one radio from a company in Spain and one from a company in China. Details on my web page.

Conclusion

Once the protocol is known, practically anything can be done by writing software. I haven't yet completed my analysis of the protocol. My program knows most of the train control commands and AIU commands. It can handle lashups and conventional operation. It can do routes and scenes. I've started writing the TMCC code but I need to borrow a TMCC system and engine as I don't have any.

Writing a program that encompasses every aspect of train operation is not something one person can do alone. Maybe because of that, PC control will never be practicable. It is not possible for me to singlehandedly write a program that will satisfy everyone. But I can probably do enough to let enterprising and interested hobbyists have the ability to operate their trains in a different way.


----------------------------------------------------------------------------------------------------------
Release Notes:

V 0.0.2.10   12 Apr 2015

1. Hopefully repaired the memory allocation bug

V  0.0.2.32  16 Apr 2015

1. Changed how the conventional mode voltage slider works. You can now
enter the actual input voltage and the program will display the actual
output volage on the slider. Or you can tell the program that the input
voltage is 22v and the slider will work just like the Remote.

2. Special functions menu on the Operation Window. Right click for menu
	Coors Door open and close : CDO and CDC (not sure yet about CDS).
	< more to be added as found>

3. If you presss the PFA button with the shift depressed, the automatic
sequence is disabled. You much press the Direction toggle 4 times just like
with the remote. NOTE: I may reverse this sometime so shift causes
the automatic sequence.

4. added Electric Engine type, click on the type name in the Operations window.
	The type is saved from run to run. (RTC can determine if an engine
	is Steam or Diesel but I've not yet found a way to tell if its an Electric.)

5. Added Electric Engine Pantograph controls. You must change the engine type
	selection to Electric for these to be visible.

6. Added RTC Main window popup menu
	1. DCS Setup - same functionality as the item on the Remote.
	2. About RTC - this displays the copyright information and then sets a flag
		so that the copyright popup is not displayed any more (if you click on [Hide].
	3. Reset RTC Registry - this resets all of the non-commuications
		preferences from the Setup window and exits from the program.

7. On the Sound Control window, I added Boiler (FPR & FBS) and coupler (SCC and SCS)
	sounds buttons along with a Train Wreck sound button (STW). Engine type	
	must be set to Electric	for the Boiler buttons to display.

V 0.0.2.33   16 Apr 2015

1. "Speed mode" was too fast for the TIU. I had to put a short delay in each
	transmission.

V 0.0.2.53

1. I created a TX only mode for when the TIU to PC path is not working. This is not
a good long term use. You should get that path working. Set this in SETUP in Debug Mode.
Select "TX Only Comm", set "# Retries" to 1 or 2 and set "Speed Mode". In this mode
of operation, commands which require data back from the TIU will not work. Only
available in Debug Mode.

2. Repaired a second memory allocation bug

3. I've realized that LashUps will probably not work in Speed Mode as some
commands used by LashUps take several times longer than regular commands to
be processed in the TIU. Try it but you might have trouble.

4. On the Engine List popup menu (right click), I've added options to set the engine
into Command Mode, Legacy Mode and Conventional Mode.


V 0.0.2.60

1. I've added some code to make the horn/whistle buttons on the operations
window a little less sticky. Generally, clicking those button very quickly
causes the problem. When you click them, click deliberatly and slowly. 

2. The TIU box in the upper right of the main window now shows the status
of the communications with the TIU:
	white:	communications not attempted yet
	green:	last communications successful
	red:	last communications failed
	yellow:	communications in test mode (eg: "TX Only Comm" is set)

3. Fixed a "Critical Section" error. For the techy types, the VCL controls
that I use in the Borland C++ Builder environment are not thread safe. I had to
have the RS-232 part of the program send a message to the VCL part of the
program for certain operations.

4. Added a "Drop DTR on Idle" mode. Now when RTC has been idle for 10 seconds,
it drops DTR. When RTC needs to communicate with the TIU again, it raises
DTR. If you use my interface design with the 3-state buffer, droping DTR
makes the TIU think that you have unpluged the remote. This lets you use
the wireless remote just as in normal operation. Look at Setup window.

5. The "Activate" button on the Accessory window has the same sticky problem
as the horn (see note 1). I applied the same fix to this button.

6. I repaired a error in the RTC Recording/Playback code. Any recorded
files that you previously recorded probably won't playback any more. Sorry.

V 0.0.2.61

1. I think I fixed the problem with the "sticky" Horn/Whistle button.

V 0.0.2.65

1. Added RTS to have the same functionality as DTR, that is, if the progam is idle
for more than a few seconds, it will drop DTR and/or RTS (as selected on the
setup window). The dropped DTR/RTS can be used to disable the interface buffer
chip so that the DCS Remote can control the TIU. When the progam needs the TIU again,
it will automatically raise DTR/RTS. Suggested by an alpha tester.

2. The AIU control code had a bug in it which is fixed. The bug prevented the AIU
from responding to the program. Uncovered by an alpha tester.

3. I made another attempt to fix the sticky button problem.

V 0.0.2.70

Interium version - never released

V 0.0.2.92

1. Each TIU now has its own list of engines. These are kept on five files on the
disk named "EngineDataX.ini" where X is the TIU number, 1 to 5. If you used
a previous version of RTC and want to keep the list of engines, you should rename
the file EngineData.ini to EngineDataX.ini where X is the TIU number that you use.
You can find this file in the same folder as where the RTC program itself
is located.

2. As an extenion to #1, the RTC program now saves all of its information on a
TIU by TIU basis. This means that you can start up two copies of RTC, set one
to TIU 1 and the other to TIU 2, then set two different COM ports, use two
USB to RS-232 adapters and cable up to two TIU. Actually, there is no reason
that you can't use five copies of RTC and five adapters connected to five TIU.

To make this work, you have to tell RTC which TIU and which Remote number to use.
I have added two command line parameters. If you create shortcuts on your desktop,
set the "Target" of each one to something like:

E:\Projects\SerialTest\Remote_Control\Remote_Control.exe 1 15
E:\Projects\SerialTest\Remote_Control\Remote_Control.exe 2 14

where the first parameter is the TIU # and the second is the Remote #

You can then startup each one and select different COM ports and you are off.

3. An idea stolen from Mike Hewett and his Train Brain based program. Shows one
window with up to 10 sets of controls. Each set contains only the basic functions
but you can see the controls for up to 10 engines at the same time. You can
select the engine number for each Engine. This does not work for LashUps yet but
might sometime in the future. To access this feature, RTC must be connected to
the TIU and then press the "Quick Ctrls" button. RTC will remember the engines
that were selected. Settings are saved on a per TIU basis.

4. Added an option in Setup to keep old engines in the Engine List when the
"Read" button is pushed. This lets you accumulate engines if you have more
engines than fit on your layout. Suggested by an alpha tester. Engines are shown
on the Engine List in normal font for active engines and in Italic and grayed
for inactive (that is, not found by the previous "Read") engines. As another
addition to this, when an engine is added to a LashUp, it is grayed in the
Engine List. It returns to normal font when the LashUp is broken up.

V 0.0.2.99

1. Added state information to the saved Accessory/Switch data. RTC will remember
the state of each Accessory/Switch between runs. When first started, RTC can't
know the state so it assumes that accessories are OFF and switches are Straight.

You must delete any AccDataXX.ini files as the old format is not
compatible with this change. Sorry

2. I added some color to the Accessory/Switch control window so you can tell
quickly the state of each device. I added a "Make it so" button which goes
through all the devices listed and sets them to their saved state.

3. Another shot at the sticky button problem. This is probably as good as
I will be able to get it within the limitation of the Borland C++ Builder
environment. You have to press most buttons for at least about a quarter
of a second in order for them not to stick. If they do stick, you can
always unstick them by pressing them again for more than about a quarter of
a second. This was a major rewrite of the handling of the sticky buttons.
The problems occurs more on faster computers.

4. The max speed spinner was not working correctly. Fixed.

5. One of the alpha testers reported that sometimes the speed sent
to the TIU does not match the value in the Speed Slider. He noticed
that when he dragged the Speed Slider to zero but the engine kept
on moving. This turned out to be another limitation of the Borland C++
Builder environment. The same problem as the sticky buttons - the event
driven architecture of Windows causes a request to set 0 MPH to be
sent before the request to set 1 MPH is complete. The 0 MPH request
was lost. I redesigned the slider operation and now the problem will
be much, much less frequent. 

V 0.0.3.00

1. Radio support. Plug in the Infiduino with the CC1101 radio
plugged into it. Drivers should load. Determine the COM port
number that was assigned to the Infiduino. Start RTC, go to Setup,
pick "Radio Support", select the appropriate COM port, press "Hide & Save".
RTC should work just like a remote. You can select TIU's 1 to 5. You
can switch between the TIU. You can startup and engine on TIU 1, then
startup an engine on TIU 2 - you will have two Operations Windows controlling
those two engines on their respective TIU.

2. I improved the look of some of the button Icons.

V0.0.3.1

1. An alpha tester requested that I add hot keys to open/switch to different
Engine Operation windows. Now F1 through F10 will start the corresponding engine
from the engine list or if its already started, will switch to its Operation window.

2. I've expanded on those hotkeys. Look at the file "Remote_Control(wired).pdf" for the
complete list.

V0.0.3.2

1. "Auto Connect to TIU" setup option causes RTC to connect to the TIU
automatically when the program is started.

2. Added option to use the minimum acceleration and deceleration rates
for all engines and LashUps - "Use Acc/Dec = 1". I recommend that you
always use this option. With this slowest acceleration/deceleration, the
engines are close to real life but still aren't slow enough.

3. Added a "Mode Select" radio button box to the Setup window. In this
selector, you can select specific RTC support for the "Wired" or "Radio"
interface to the TIU or for support for the "TIU Emulator".

4. Added a "Startup All" button to the main window which, when pressed,
will send a startup sequence to all "Active" engines in the Engine List
that aren't already started. This will open an operations windows
for the started engines. Enable this by checking the "Enable SU/SD All"
checkbox on the Setup window.

5. Added a "Shutdown All" button to the main window which, when pressed,
will send a shutdown sequence to all started up engines in the Engine List.
It will close any open operations windows for the shutdown engines.
Enable this by checking the "Enable SU/SD All" checkbox on the Setup window.

6. Moved the Coors door open/close to buttons on the the Sound Controls window.
These buttons are always enabled because I don't know how to tell if
the Coors train is running.

7. Added a "Mute" menu selection to the RTC main window popup menu. This
selection mutes all started engines. Selecting it, places a checkmark
next to it. Selecting it again removes the checkmark and unmutes the
engines.

V0.0.3.15

1. Changed the way that the COM port is selected. Now the RTC program will
list the COM ports that it finds and you can just select the one you want.
You can also just click the spinner to select the port. The COM port list
also displays the "Friendly Name" if it can figure it out. You will probably
have to choose the COM port the first time that you run this new version
of RTC.

2. Added Auto Labored Smoke handling to the Operations window (steam only). When "Labor Chuff"
button is pressed, the engine's smoke level will be changed to maximum, when "Drift
Chuff" is selected, the smoke level will be changed to minumum. When both
are turned off, the smoke level will be left unchanged.

3. In a similar manner as #2, added Auto Rev Exhaust handling to the Operations
window (Diesel only). When "Rev Up" is selected the engine's exhuast level will be
changed from minimum to medium to maximum as rev levels are increased from
1 to 9. In the same manner, the exhaust level will be lowered as "Rev Down" 
is selected.

4. Cleaned up TX Only mode (a Debug only mode) to put a 100ms delay between each command. RTC
was sending commands to the TIU faster than the TIU could process them.

5. RTC quietly ignores any TIU responses addressed to a different Remote number.

6. I changed the way the PFA button on the Operations window works. I never
liked my original implementation. First, I added a new option on the Setup
window "Automatic PFA Sequence".
	A. if "Automatic PFA Sequence" is not checked, the sequence will start
		and you need to click the Direction button 4 times just like
		with the remote. You can press the PFA button again
		to cancel the sequence. Between the presses of the DIR button
		you can go off and run other engines.
	B. if "Automatic PFA Sequence" is checked, the sequence will
		start and automatically send the Direction
		command 4 times spaced about 20 seconds apart. You can
		press the PFA button again to cancel the sequence. When
		this automatic sequence is running, you can go off and
		run other engines.
	C. The PFA button is green when the PFA is running.

7. Improved the performance of the "Radio" option on the Setup window. Now
Port information is separately saved for radio mode (for wired mode, port information
is already saved by TIU number).

8. Improved the operation of the "Activate" button on the AIU Accessory/Switch
control window.

9. Added a right click popup menu on the Emergency Stop button to give you
the option to just send Shutdown to all engines rather than killing the
TIU power.

10. Added a Master Volume control on the Quick Controls window for each engine.
The volume setting is saved between runs (as is the smoke switch setting).

11. From the main RTC window right click popup menu, I added an option
to change the TIU number.

12. I added a new option to the Setup window : "Short Bell/Whistle Sequence".
This option causes a shorter Bell/Whistle sequence when moving from 0 Smph.
Suggested by Mike Hewett. This option leaves the Bell ringing after
the sequence is complete and you must manually turn off the bell.

13. There is now a right click popup menu attached to the Bell switch on
the Operations window. You can turn on the bell for 10, 20, or 30 seconds
and it will automatically turn off at the end of that time.

14. Touchscreen note: The touchscreens that I have found don't handle
"long presses" well. They seem to use "long press" to emulate a "right
mouse click". I have found that if you roll your finger you can
get the same effect as "long press". This affects the Whistle/Horn
and Accessory Activate buttons on RTC. The other built-in problem with
the touch window is the missing SHIFT, ALT and CTRL keys. Currently,
RTC uses some of those keys for alternate actions when clicking
a button. Over time, I will be adding popup menus to present those
same alternate actions so eventually, those keys won't be needed.

15. The DCS Setup window now saves its settings by TIU number.

16. I made the selection of Middle Engines when creating a LashUp simpler.
You can click on an engine then the ">" button repeatedly to add engines.
Click on the "<" button to clear the Middle Engine List and start over.

17. I further improved the "Critical Section" code which should
reduce the problem of "sticky" buttons.

18. I improved how LashUp are created/edited. Sometimes, though, an engine
will not get correctedly marked as active/inactive. You can right click
on the engine list on the Main screen and set any engine to active/inactive.

19. When LashUps are started, Smoke/Exhaust and Engine Type are set to
values saved with the head engine.

20. I added an option on the Setup Screen to disable the Emergency Stop
buttons. Use at your own risk!

21. I added a right click popup menu on the Whistle/Horn button. This feature
is still experimental and may not work correctly. The problem is that the
minimum duration whistle/horn is different for different engines.

V0.0.3.16

1. I added a Super TIU mode selection on the setup window. This is
my best guess at how it works but it remains largely untested because
my layout doesn't need it. Feedback appreciated. Debug Mode only.
If you don't know to get into Debug Mode, contact me. I'll move this out
of Debug mode once a few people use it.

2. I did some more testing and fixups on the code which allows the
use of Engine #0 - the factory reset engine. You can control, rename and
renumber factory reset engines. Debug Mode only.
If you don't know to get into Debug Mode, contact me. I'll move this out
of Debug mode once a few people use it.

3. I added the ability to create Routes and Scenes. They are not separate
things as in the Remote but can contain both switches and accessories. Up
to 256 can be created. Each can contain an unlimited number of switches
and accessories (although only 500 (250 switches and 250 accessories) can
be connected to the maximum 5 AIU on 5 TIU). They can be "Activated" to
presets or "Reset" to defaults. Unlike the remote, you set an accessory
to turn off when a Scene is activated.

The Route/Scene windows works in a similar manner to the LashUp Window.

Right Click on the Route/Scene window for Help.

4. I cleaned up the operation of the AIU Control window. Now double clicking
on an accessory or switch will toggle the state of that device. The state is now
shown with a cute Icon rather than words.

5. Added "All" Accessory and Switch operation to the AIU Control Screen.
Turns On/Off all accessories connected to the TIU or sets all switches
connected to the TIU to straight/closed or diverge/thrown. ALL switches and 
accessories connected all AIU connected to the selected TIU. Debug Mode only.
If you don't know to get into Debug Mode, contact me. I'll move this out
of Debug mode once a few people use it.

V0.0.3.17

1. The Engine List on the main window was acting odd and I finally
found the cause and fixed it.

2. The little Icons that I used for Accessory and Switch states
had a transparent mode which I forgot to set. Now their background
is transparent.

3. On the AIU Control and the Create Route/Scene windows, I show
the four possible state Icons as a "Legend". I wasn't very clear
that they are not buttons. I added a Hint which pops up trying
to explain what they mean.

v0.0.3.18 AKA v0.3.18.0

0. I changed the version numbering scheme because I find that I am
sending out RTC to my alpha testers between releases. I need a way to distinquish
these. This would have been v3.18 but I just moved the numbers one position
to the left. So this is version 3.18.0. I will use the last digit position
for intermediate releases.

1. On the Operations screen, the Boost and Brake buttons will increment/decrement
the speed by 1 Smph if clicked. If held down, they will increment/decrement the
speed by 1 Smph every second. I also made them a little larger so my aim on my
touchscreen did not need to be so precise.

2. I spent the last week finally digging into the way that Engines report which
hotkeys that they respond to. In response to an Interrogate command, the Engine
reports back 80 bytes of data. 26 of those bytes indicate hotkeys based on bit position
where there is a '1' bit. I was able, using the RTCEngineE Arduino program, to set
all of those bits to '1' and feed them to a Remote. The Remote then listed all
of the hotkeys when I pressed the "S4"/"more" button. I've been able to detect 70
hotkeys and the exact bit in the Interrogate command response that causes
that hotkey to be displayed by the Remote. Once I could do that, I could just
press the hotkey on the Remote and watch (again using RTCEngineE) exactly
what command the Remote sent for that hotkey function.

Using what I learned, I modified the Operations and Sound Control Windows to
show only controls for hotkey functions that are actually supported for each
engine. So if the engine does not support the Crossing Signal, for example, that button
will not appear in the window.

This includes switches and buttons on the Operations Window for:
	Firebox Glow (LFB)
	Headlight (something different than the HDLT button on the Remote)
	Mars Light (LMA)
	Ditch Lights (LDI)
	Interior Light (LIN)
	Marker Lights (LMK)
	Beacon Light (LBE)
	Number Boards (LNB)
	Running Lights (LRL)
	Track Inspection Lights (LTI)
	Auxiliary Lights 1 (LA1)
	Auxiliary Lights 2 (LA2)
	Auxiliary Lights 3 (LA3)
	Crossing Signal (SXS)
	Pantograph Menu (MOP)


And on the Sound Control Window for:
	Coors Delivery (Start/Stop/Doors Open/Doors Close) (CDS, CDO, CDC)
	Boiler Startup/Pressure Release (FBS, FPR)
	Train Wreck (STW)
	Coupler Slack (SCS)
	Coupler Close (SCC)

If you want to understand the gruelling details of the hotkey encoding,
on my web page, look for the file "Command ('Ixxx') Response.xls". I haven't
completed this yet. Some of the hotkeys, like Engine and Idle Sounds,
are not used by RTC so I haven't yet determined their exact bit position.
I'll do it when I need it.

I'd appreciate feedback on how well this works. If you look at the hotkeys
on a Remote, RTC should show the same set of hotkeys from the list above.
Remember though, I don't have hotkeys for Engine Sounds or Idle Sounds and
other hotkey functions are handled in the background by RTC.

RTC does not handle Doppler or Trolley functions. RTC does not yet handle
the quillable whistle but I know the hotkey commands to do it. Let me know if
you have an engine with such a whistle.

As an aside, in looking in detail at hotkeys, I can see a lot of erroneous
hotkey information in the Engines. For example, I see many cases where
a Marker Light hotkey is reported by the Engine but that Engine did not
have any Marker Lights. I have a Doddlebug that reports a Pantograph Menu.

3. Hotkeys not tested because my engines don't have them:
	Beacon Light
	Running Lights
	Firebox Glow
	Mars Light
	Auxilary Lights
	Pantograph
	Coors Delivery
	Boiler Startup/Release

4. On the Operations Window, I deleted the "LIN Light" switch as it
now is handed by the hotkey code. I added a "Sounds" switch which
will mute the engine sounds.

5. Generally cleaned up a lot of labels and Hints.

6. I realized that if communications fails while playing back a saved
recording, I needed to do something drastic. So now if comm fails (after
the set number of retries), RTC will send an Emergency Stop to all TIU's.

7. Dumb typing mistake in the LashUp window code prevented start up of a
good LashUp.

8. I generally made buttons bigger where I could mostly to help when
using a touchscreen.

9. Rule 17 lighting - almost. My P&LE GP-7 #1501 (PS3) headlight dims when
it is stopped. A nice feature not even listed on the MTH webpage (but
the webpage advertises lighted marker lights and there are none). I've added
a setup option to RTC which automatically turns off the headlight when your
engines are stopped. Not exactly correct but its there if you want to
use it. Defaults to off, if set, it applies to all engines.

v 0.3.19.0

0. This is mostly a maintenance release where I created one set of source
code which would compile under BCB4.0 (my orginal IDE) and CB10.1 (the lastest
IDE from Embarcadero). Thanks to the Kevin Rice for leading the way on this.

1. I added a debug mode for the Engine Sound Knob. Now
in debug mode, you can explore all of the 255 values for this knob and
see what sounds come out. In particular, starting at engine sound 80 are
the clips for PFA.

Some of the engine sounds value cause a continuous repeat of the sound.
When that happens, other sounds will not play. I don't know how to turn this
off other than pressing the "Whistle/Horn" button.

Note: in non debug mode, the Engine Sounds Knob sends commands that correspond
with the Engine Sounds as listed on the hotkeys. When sound 1 is selected,
the command "n177" is sent and so on. In debug mode the knob setting is
sent unchanged to TIU. If sound 1 is selected in debug mode, "n1" is sent to
the TIU. The sound number corresponds to the index used by the ADPCM program.
Its available at: http://www.silogic.com/trains/ADPCM.html

2. Changed the Rule 17 lighting to be by engine rather than to apply to all engines.
It now also turns off the interior light when the engine starts moving. I added a
switch to the Operations screen.

v 0.3.20.0

1. Added Hot Buttons:

	Up to 20 Hot Buttons can be defined. Once defined, a click on the
button will immediately send that command. To open the Hot Buttons Window,
click on the [Hot Buttons] button on the Main screen.

	To edit a button, right click on that button. Fill in the fields:
		- Button Label that will appear on the Hot Buttons Window. Use
			"&&" for "&", ie "P&&LE".
		- Command to be executed selected from the drop down Command List
		- TIU Number 1-5
		- Engine/Lashup Number: Engines 1-99, All Engine Operation 100,
			or LashUp 101
		- for AIU commands, the AIU Number 1-5 and the Port Number 1-10
		- for LashUps, the LashUp String - engine numbers separated by
			commas, using a minus sign to indicate Reverse Running.
		- for engine sounds, enter the sound number 1-255

Press the [OK] button to accept that command.

To undefine a button, right click on it, press [Clear] and then press [OK].

A special function "Playback of a Recorded File" lets you associate a recorded
file with a hot button. When you press the button, the recorded file will
play. You can cancel playback by pressing the [Cancel] button on the playback
popup. You can repeat the playback by checking [X]Repeat.

The program, internally, maintains the Command list. If you want to add
a command, right click the Hot Buttons Window outside of the Hot Buttons
themselves and select "Edit Command List". Each line in this list is a command.
The format is "Command Description"="Command". Press [Done] to save
the edited list. The edited list is saved in the RTC folder with the
name "HotCommands.txt". You can delete this file at any time to return
to the internally maintained list.

A setup option "Auto Hot Buttons" causes RTC to display the Hot Buttons window
automatically each time the program starts.

2. Moved position of Quick Controls button

3. The buttons for Startup All Active Engines and Shutdown All Engines have 
been removed. To perform these functions, right click on the Main Window
and when you get the popup menu, you can select these functions.

4. In the setup, you can select [X]Allow 255 Sounds. This sets the Engine Sound
knob on the Sound Controls window to show sounds 1-255 on the knob. With this,
you can play all 255 sounds in the engine. On the remote, "S01" hot key selects
sound 177, "S02" selects sound 178 and so on. The 1-255 number corresponds to the
index into the sound file as shown by the ADPCM program.
http://www.silogic.com/trains/ADPCM.html

4a. For touch screen users, I added up/down buttons to both the Engine and Idle
Sounds knobs. With a touch screen, the knobs are too hard to accurately control.
The knobs themselves may disappear someday.

5. Totally rewrote the recorded file playback routine. Now when you select
a recorded file for playback from either the Setup window or the Hot Buttons
window, the playback runs as a separate thread. That means you can do other
operations or even other playbacks while the playback is running.

V 0.3.21.0

1. Hot buttons would not work if you had no AIU, ouch. Fixed.

2. Bug fixes in Quick Controls. Enhancements in Quick Controls.

3. General code cleanup and communications speed up.

4. General improvement in how Conventional Mode works. RTC now puts
the channel into Variable mode when you select the [VarX] button.

5. Added a button on the operations screen that causes the bell to sound with
the Horn/Whistle and with the Crossing Sound. The setting of this button is saved.

Now this button and 3 others have been relocated on the operations screen:
	Rule 17 Lighting - turns off the headlight when stopped
	Ring Bell w/Horn - causes the bell to sound with the Horn/Whistle and
		with the Crossing Sound
	Auto Bell/Whistle - relocated from a switch. Sounds the horn/whistle when
		engine is starting moving from a dead stop
	Auto Labored Smoke/Auto Rev Exhaust - For steam engines, increases smoke
		output when laboring. For diesel engines, increases exhaust output
		when Revs are increased.

The settings of these 4 switches are saved with the engine.

6. Super TIU Mode operation improved. Setting screen added from "Super TIU Mode" button
on Setup window.

7. Added the ability to increase the size of the Quick Controls window. It also increases
the size of all of the buttons and controls for easier touch screen use. The size can
be set to 1.0, 1.1, ... 2.0 of the normal size.

V 0.3.22.0

1. I found the Hot Buttons to be so useful that I added 4 more windows of them so
their total is now 100. Right click on [Hot Buttons] to bring up a popup menu
where you can select from the 5 windows. Left click on [Hot Buttons] brings
up buttons 1-20 just as before.

2. Added support for Alternate Sound, SAH. This button, on the operations
window, plays sound 243. If the engine supports the SAH button, it will appear
automatically on the operations window when the engine is started up.

3. Yet another attempt to fix the sticky buttons problem. In the Windows message
based execution environment, I delayed the processing of the mouse button up message
until after the mouse button down message processing is complete.

V0.3.23.0
9:35 AM 4/13/2017

1. From the Operations screen, I added two menu items:

	1. Engine Information - Interrogates the engine and displays these four
	pieces of information:
		1. Odometer (Smiles)
		2. Trip Odometer (Smiles)
		3. Track Voltage (volts)
		4. Chronometer (hours:minutes:seconds)
	My interpretation of these values may be slightly different than that
	of the Remote.

	The interrogation of the engine is done once automatically when this
	screen is first opened. If you wish to repeat the function, select
	the update interval the press [Start]. Press [Stop] or [Hide] to stop
	the updates.

	This function sends a lot of packets between the program and the TIU.
	Its probably not a good idea to leave it running.

	2. Track Signal - Interrogates the engine once each update interval and
	displays the number of packets out of 100 that engine correctly recevies.
	Also displays the average packets received out of each 100. Update interval
	can be changed. Press the [Start] button to start, the [Stop] button to
	stop. Hiding the screen also stops the function. Unlike the Track Signal
	function on the remote, this function shows you exactly the number of
	packets received correctly by the engine from the TIU.

	This function mutes the engine while it is running.

2. If you right click on the [HeadLight] button of the operations screen, you
can select one of two menu items:

	1. All Lights Off
	2. All Lights On

	Turns off/on the headlight, marker lights, beacon light, interior light,
	running lights, number boards, ditch lights, mars light, firebox glow,
	track inspection and Aux lights.

3. From the Engine List popup menu on the main screen, you can also select the
Engine Information as described above in item 1-1.

4. Added an option on the Setup window "[X] Auto Quick Controls". If you check this,
the Quick Controls window for the TIU is automatically displayed as soon as you
connect up to a TIU by pressing the [Connect] button.

5. Again to make the use of touch screens a little easier, I increased the size
of the UP/DOWN buttons on these 3 windows bigger to make it easier to touch the
button. I removed the vertical scroll bar.

	Engine List on the Main window
	Lash Up List on the Lash Up window
	Route/Scene List on the Route/Scene window

You can still use the up/down arrow and PgUp and PgDn keys to move through the lists.
I added an menu item on the right click popup menu to temporarily restore the scrollbar
if you need it.

6. If "Auto Bell/Whistle Sounds" is selected in the Setup window, the engine
will blow one short horn/whistle when running and the [STOP] button is pressed.

7. Added support for Proto Whistle (SPW), Smoke Whistle (FSW), and Swinging Bell (FSB).
Smoke Whistle and Swinging Bell are toggle switches that appear if the engine
supports those functions. If the engine supports Proto Whistle, a toggle switch
will appear, which, if turned on, will display a slider. Drag the slider from 0 to
sound the quillable proto whistle. Turn off the toggle when you are done as the
normal whistle sounds are not available when this function is turned on.

Unlike the Remote, you can have the Quilling Whistle slider and Speed slider
on the screen at the same time.

V0.3.23.1

1. If Proto Whistle is available in an engine, RTC will make sure that it is turned
off whenever the engine is shutdown. If Proto Whistle is turned on, RTC will not send
other whistle commands (n41, n42, n43, n44, etc).

2. I've found that sending the Proto Whistle on/off commands too quickly causes
the engine not to respond to them. I can see this also on the remote as when
you press the SPW softkey, it takes a few seconds to enable. I added a 2 second
delay in RTC to slow down the on/off commands. 

V0.3.27  (DCS v6.00 Support)

// --------------------------------------------------------------------
As of V0.3.27, I recommend that you upgrade all of your Remotes
and TIUs to DCS v6.xx. MTH made some dramatic changes to the command
format with v6.xx and TIU with that version will not accept all commands
from a Remote running the older DCS versions. At the very minumum,
you can still use v5.xx but be certain that all TIUs and all Remotes
are loaded with that version.
// --------------------------------------------------------------------

1. Major changes to the underlying structure of the RTC program. The goal 
was to make the communications between the PC and TIU more reliable. I rewrote 
the communications system to use threads and thread-safe lists. This is a lot 
of technical mumbo-jumbo but basically, there needed to be one routine in the 
program which does the communications with the TIU. There always was just one 
in the earlier versions but because of how Borland/Embarcadero coded their user 
interface, it was possible for that one routine to re-entered.  To the user, 
the changes are invisible, all of them occuring deep within the program. It 
all sounds so simple but the changes took me several months as I had never worked 
with threads before.

2. I added code to support the RFID train detection hardware that I describe on
this page. Took out the code that let you monitor remote to TIU communications
when running in the old "wired" mode.

3. I added the ability to code a routine (named Program_Control.cpp) which can 
control trains without human interaction using train detection information 
provided by the RFID hardware.

4. I forgot a "Speed" command in the Hot Buttons list. I've added it

5. I finally realized that the DCS command sequence for Lash Ups changed
dramatically from DCS 5.xx ot DCS 6.xx. In the older version, the engines
in the Lash Up were encoded as binary numbers in the command. In the newer
version, the engines are sent as plain ASCII. I could guess that this
was done for better interface with the WIU. I updated RTC to use the TIU
version number to determine if it should send the old version or the new
version of the Lash Up commands. See the note at the beginning of this section.

6. The [Connect] buttton when now show the TIU version number when RTC
is connected to a TIU.

7. Some details about LashUps: When using the Remote, many engine soft keys
available with engines in the LashUp are NOT available when running the
engines in the LashUp. RTC sets its buttons and switches based on the
soft keys in the head/lead engine so all possible functions
are available. Examples of soft keys not available when using the Remote
but available in RTC are: SXS, LMK, and LNB. Other less used functions
which are available with RTC include DOD, DCH, FCC, DTO, DTV and FTS.

8. I improved the icons on the SFS and SRS buttons to show that they
generate 2 toots and 3 toots of the horn/whistle respectively.

V0.4.0

V4.0 is a complete rewrite of the structure of the RTC program started in
Version 3.27. I now use threads and thread-safe queues extensively and because
of that, the program is much more stable. Because of these upgrades to the
program, Windows XP is no longer supported by the standard distribution.

If you need a version of RTC which will run on Windows XP, contact me.

1. The major functional change is added support for the Lua scripting language 
so that anyone can write a script to control their trains. Look for the 
button [Prog Ctrl] or Program Control. This scripting facility, described on 
the  RTC Control Language - Scripting page works both standalone and with my 
RFID Train Detection.
http://www.silogic.com/trains/RTC_Control_Language.html

2. Changed the terminology used for the AIU switch positions. I now
use Closed or Thrown rather than Straight or Diverge. Both sets of words
are acceptable.

3. Added several new windows accessable from the Engine List popup menu and 
the Operations Window popup menu:

	Engine Information - displays DOD DTO DCH and DTV
	Engine Status - displays actual engine speed, status of various lights/feature and DTO
	Track Signal - Sends FTS "Pings" to the engine and reports success rate


V0.4.1

1. Added internet (http/ftp/smtp etc) support using the luasocket package version 3.0-rc1
written by Diego Nehab and OpenSSL-Win32-1.0.2s. To use this feature, the folders 'ssl', 'lua', 'socket'
and 'mime' should be present in the same folder that contains the program executable (Remote_Control.exe).
Some of these files have been modified by me to work correctly in the RTC running environment.

Diego writes:

	This is the LuaSocket 3.0-rc1. It has been tested on Windows 7, Mac OS X,and Linux. 
	Please use the project page at GitHub https://github.com/diegonehab/luasocket
	to file bug reports or propose changes. 
	Have fun, Diego Nehab.

The OpenSSL team writes:

 The OpenSSL Project is a collaborative effort to develop a robust,
 commercial-grade, fully featured, and Open Source toolkit implementing the
 Secure Sockets Layer (SSLv3) and Transport Layer Security (TLS) protocols as
 well as a full-strength general purpose cryptograpic library. The project is
 managed by a worldwide community of volunteers that use the Internet to
 communicate, plan, and develop the OpenSSL toolkit and its related
 documentation.

 OpenSSL is descended from the SSLeay library developed by Eric A. Young
 and Tim J. Hudson.  The OpenSSL toolkit is licensed under a dual-license (the
 OpenSSL license plus the SSLeay license), which means that you are free to
 get and use it for commercial and non-commercial purposes as long as you
 fulfill the conditions of both licenses.

2. Because of the limitation of LuaSocket 3.0-rc1 to running only on Windows 7 and newer, the standard
distribution of RTC will no longer run under Windows XP. If you need a version
of RTC which will run on Windows XP, contact me.

3. On the Program Control screen, if you right click on the script file name, RTC will
display a pop up menu. From this menu, RTC will attempt to run an editor so you can
edit the script file or you may remove the script file from the dropdown list. Editors
are checked in this order: NotePad++, Metapad, Notepad, and Wordpad. An error is displayed if
RTC can't find any of these editors.

4. Corrected an error in the InputBox() function with Lua scripts.

5. I did more research on the DTO(), DCH() and DOD() function calls from Lua scripts.
I updated the code to more correctly return the odometer mileage and time information.

6. Add support for multiple Program Control windows. Up to 5. This will let you
run up to 5 independent Lua scripts at the same time. Look at the web page titled
"RTC Control Language - Scripting" for details. http://www.silogic.com/trains/RTC_Control_Language.html

7. Changed how the global Debug value is accessed in the Program Control window. Previously it
was passed an argument to all functions. Now it is accessed by calling the function "Debug()".
That function will return a integer value between 0 (no debug messages) to 9 (full debug messages).
This new method allows your Lua script to respond better to changes in the value of the
global Debug variable.

V0.4.2

1. Cleanup for the Program Control functions. Fixed some bugs. Extended Beep() and Counter()
script commands.

2. Added dropdown menus on some of the buttons which duplicate the right mouse button popup menus.

3. Added a Detected RFID Tags window which is automatically displayed when the Program
Control button is pushed. This displays all of the unique tags which have been detected
by the tag readers. If you left click on any tag, a partial decoding of that tag
is displayed at the bottom of the window.

4. You can run the lua interpreter in standalone mode by pressing the [Interpreter]
button or whenever a script is run. In the input line below the Messages window,
you type any lua command as long as it all fits on one line.

   You can type expressions or statements. An expression does not save its result. The
program will just print out its result.

   For example  "3+5"   will print out "8".

   A statment is a complete lua command.

   For example  "a=5"   will create a variable called "a" and store the value 5 in it.
Then "print(a)"  will print out "5".

   If you are running a script, you can reference the variables in that script.

   For example, if you have a variable "Engine" in your script and you want
to check its value while your script is running, "print(Engine)" will display
the engine number. You can be fancy and use "print("Engine Number is ", Engine)"
which will print "Engine Number is 6". Making use of the Debug() function
described in item 7 of the 4.1 release, you can type "print(Debug())" and
the program will print the debug level.

V0.4.2.1

1. Editing the Engine Name changed to use the Engine Name field in place rather than
a separate popup window.

2. Program Control scripting expanded to handle all of the response packets that
can be returned by the RFID detectors. Added were:

	a. uidtag()
	b. nametag()
	c. response()

    Look at the "Control Language - Scripting" web page for details.
	http://www.silogic.com/trains/RTC_Control_Language.html

3. The Detected RFID Tags window was extended to show the UID only (or unprogammed) tags.
Select between the tag types using the tabs above the Detected Tags window.

4. Added a configuration file that lets you change the wording of switch track positions
on various windows. The program uses "Normal" and "Reverse" as defaults. You
can change the two words to anything you like, eg "Closed" and "Open" or "Closed"
and "Thrown". These word changes are visible on the AIU Control window and the Hot
Buttons window.

5. Added dropdown menus on some buttons. These menus are the same menus that previously
could be accessed by right-clicking on the buttons. Buttons affected are:

	a. Startup
	b. AIU Control
	c. Prog Ctrl
	d. Hot Buttons
	e. Read
	f. Sount Ctrls (on the Operations window)
	g. Browse (on the Program Control window)


6. Added three functions to the scripting language to fetch car/engine information
based on the contents of a detected Tag:

	a. GetRailroadName()
	b. GetEngineName()
	c. GetCarName()

    Look at the "Control Language - Scripting" web page for details.
	http://www.silogic.com/trains/RTC_Control_Language.html

	Includes three files on the disk which are used to extend the information:

	char CarModelsFileName[] = "CarModels.txt";
	char EngineModelsFileName[] = "EngineModels.txt";
	char RailroadNamesFileName[] = "RailroadNames.txt";

	These files are names in plain text. You can add your preferred values to the
	files and they will be used by both RTC and the Tag Programmer.

7. On the Quick Controls window, I made the actual Engine Number appear at the
top of each control in large bold font so that it would be easier to
see. Requsted by Mike Hewett.

8. These windows now have [Prev] and [Next] buttons to quickly move between
windows:

	a. Hot Buttons (moves between 5 windows of 20 hot buttons each)
	b. Program Control (moves between 5 windows each running a script)
	c. AIU Control (moves between the 5 AIU's allowed on each TIU)


V0.4.2.2

1. When you run the Program Control windows, the list of Detected Tags does not show
automatically. If you want to see the Detected Tags, press the [Show Tags] button on
the Program Control window. The RFID system must be enabled on the Setup window of
course.

2. In the Program Control section of the program, I added a new function named
event(). This function can be called by the SetEvent() function from any PC window.
Look at the on-line documentation for details. These two functions are used
to let scripts running in different PC windows to communicate with each other.

3. A few bug fixes in the Quick Controls window including better handling
of the engine sound level setting when starting an engine from that window. Sound
level change requested by Mike Hewett.
  

V0.4.3.0

1. Increased the number of buttons on the Program Control window from 10 to 30.
I found that I needed more than 10 for more complicated scripts. So as to not
increase the size of the window, the buttons appear on three tabs of 10 buttons
each. Look at "FunctionTest.lua" to see how to change the words on the buttons and
on the tab labels.

2. Increased the number of Program Control windows from 5 to 10.

3. Added the "Add Engine" function. Right click on the [Read] button to get
the popup menu. Select "Add Engine(s)". The program will search for all Factory
Reset engines and present them to you one at a time. Select the new engine number
for each engine and press [OK]. Previously you had to perform this function
with a Remote.

4. Addition to the Program Control language of global integers and strings to
permit communications between scripts running in different Program Control Windows.

    Look at the RTC Control Language Page for details on how to use these.

5. Added Layout window and functions to support that window.

    Look at the RTC Control Language Page for details on how to use these.

V0.4.3.1

1. Quick Controls now supports All Engine operation (Engine 100) and Lashups
(1-20 selected as 101-120 in the spinner).

2. Added support for the Adafruit Feather 32U4 RFM69HCW Packet Radio 915 MHz. A new Setup
option "[x]DTR Always On" must be checked in order for RTC work correctly
with this radio. Arduino sketch for RTCModemF is available on the RTC web page.

V0.4.4.1 (not released)

1. Support for the Adafruit Feather 32U4 did not work correctly. Connection
to the TIU was intermittant. The problem was how the 32U4 implimented the USB
port. It is very different than other Arduinos. I had to change the code in RTC
to give the USB port time to intialize after RTC raised DTR.

V0.5.0.0 Full WiFi support for WIU/TIU and WTIU

The major change for V5 of RTC will be WTIU and RFID support over WiFi. Now it is no longer necessary to use a USB based CC1101E radio for the TIU connection or to use physical USB or serial cables for the RFID tag detection circuits.  RTC supports both the WIU/TIU combination and the soon to be released WTIU. I've written an ESP8266 version of my RFID tag detectors which supports WiFi. Enable WTIU WiFi and RFDI WiFi on the Setup window. 

Look on this web page for setup instructions: 

	 http://www.silogic.com/trains/WiFi.html .

Major internal changes to the program including how multiple TIU are used.

The program will continue to support USB serial CC1101E communications and USB serial communications for PN532 based tag detection.

Here is a summary of the changes to this version:

1. Add a window to display Signal aspects on a bitmap of your layout. I added 10 new PC Control Language functions to support Signals. I also added "Cab Signals" which reflect the home and distant signal aspects -- just like the big guys. Read about it on this web page: 

	 http://www.silogic.com/trains/RTC_Control_Language%20-%20Signaling.html

2. Replaced the concept of "Run Time" in the Program Control window with "Elapsed Time". This counter measures the elapsed time from when the [Run Script] button is pushed until the Lua script stops (either on it's own or by a press of the [STOP] button. The time will increment and turn green when the script is running and will stop
incrementing and turn red while the script is stopped.

3. In conjunction with item 2, the RunTime() function as been changed to return the number of seconds since the first Program Control window was opened. RunTime() will return the same value to all Program Control windows if it is called at the same time. (This is different than the previous operation which returned the run time of each individual Lua script.) With this you can compare time of operations between different PC windows.

4. Fixed a bug that prevented some Lashups, created with the Lashup window, from being saved correctly.

5. Embarassingly, there was a serious bug in the Quick Control window's support for Lashups. Hopefully, I've fixed it in this version.

6. The speed was not set correctly from the Operations window in the case of the speed going from 0 to 1 Smph with Auto Bell set.

7. The AIU Control Window now has a buttons to open the AIU connected to the next or previous TIU. It already had buttons for the next or previous AIU.

8. The Debug Messages Window now has an AutoScroll check box. If this box is checked, the end of the messages (the previous mode of operation). If the check box is cleared, the window can be scrolled up or down manually.

9. The Debug Window now has a TimeStamp checkbox. If this box is checked, each message is prepended with the time it was processed. Because of the way that RTC handles these messages as lowest priority, the messages may appear out of order.

10. deleted

11. Added and improved the use of Lashups on the Quick Controls window. Lashups appear as engine numbers 101 to 120. These correspond to Lashups 1 to 20.

12. The Layout window has two new buttons, [Layout Copy] and [Window Copy]. The first attempts to copy the entire layout window to the Clipboard. This may not work as desired when the layout itself is too large to fit on the screen. The second copies only the part of the layout actually displayed to the Clipboard.

13. Had a lot of comments about the blowing of the whistle and ringing of the bell when an engine is started from 0 Smph. This was controlled on the Setup Window by one option [X] Auto Bell/Whistle Sounds. I broke this up into two options:

     [X] Auto Bell : if set, this option causes the RTC program to ring the bell automatically when starting from 0 Smph. This option applies to all engines but on each engine's Operation Window, there is a corresponding LED, ¤ Auto Bell, to disable this feature for that particular engine. Click on the LED to change it from Red (disabled) to Green (enabled).

     [X] Auto Horn/Whistle : if set, this option causes the RTC program to sound the whistle/horn automatically when starting from 0 Smph.This option applies to all engines but on each engine's Operation Window, there is a corresponding LED, ¤ Auto Horn/Whistle, to disable this feature for that particular engine. Click on the LED to change it from Red (disabled) to Green (enabled).

14. I also had a request to add an option to turn off the bell automatically after 5 seconds. I added a option on the Setup Window. If [X] Auto Bell Off is checked, the bell will turn off automatically after 5 seconds. If it is not checked, you must manually turn off the bell. I added a spinner so you can set the automatic off time to any value between 1 and 60 seconds.

15. Added several new functions to the RTC Control Language:

	A. "InputDropDown()" : This function makes it easier to request the user to choose an item from a list.
	B. "Watchdog() : This function sends a Watchdog Signal.
	C. "Siding()" : Set siding power by activating an AIU Accessory channel and then send a Watchdog Signal.
	D. "TIUActive()" : Returns true if the given TIU number is selected to be active.
	E. "InputLine()" : This function allows a script to request simple text input. An input line control is opened near the bottom of the Program Control window and the user can type in characters. When the user presses <Enter> the typed characters are returned to the script. 
	F. "GetDebugCounter()" : Returns the value of one of 21 internal debug counters.
	G. "RsActivate()" : Activates the given Route/Scene.
	H. "RSReset()" : Resets the given Route/Scene.
	I. "RSAllSwitchesNormal()" : Sets all switches on the given Route/Scene to their NORMAL positions.
	J. "RSAllAccyOn()" : Sets all accessories on the given Route/Scene to ON
	K. "RSAllAccyOff()" : Sets all accessories on the given Route/Scene to OFF
	L. "SetUpLables()" : After user changes the values of FunctionXXLabel or FunctionXXName, call this function to update the labels/function of buttons


    Changes to existing functions in the RTC Control Language:

	A. "Accessory()" : This function no longer needs an engine number parameter
	B. "Switch()" : This function no longer needs an engine number parameter
	C. "Yield()" : Now returns true on success and false on error

	Look at  http://www.silogic.com/trains/RTC_Control_Language.html for more details.


16. In the Program Control Window, the button font changes to Bold when pressed.

17. I added the ability for RTC to play some engine/environment sounds automatically. Right now, the only sound support is a relay clicking sound when the aspect of a signal changes. This feature is enabled in the Setup Window by the [X] AutoSound Controls check box.

18. Added a "Disable Sleep" option to the Setup window which prevents the computer from sleeping when RTC is running.

19. The Track Signal window now shows a bar graph of the pings returned from the engine under test. This better enables you to visualize the track condition.

20. deleted 

21. On the Engine Information window, I added a display of the 'Q' value from the TIU. I don't know exactly what it means but it is some measure of the Quality of the signals between the TIU and the Engine.

22. Added three popout lists for easier access. They are the Engine Popout List, the Lashup Popout List and the Route/Scene Popout List. You access these from the Engine List, the Lashup List and the Route/Scene List. Right click on the list to bring up the popup menu and select the "Open Popout List" menu item. On the popout, you can select one or more list members. Pressing Enter usually starts up those items. You can right click on an item and you will see another popup menu with more options.

23. In Setup, I added an option "[X] Auto Find Engines" which defaults to enabled. When enabled, pressing the [Connect] button will cause RTC to scan all of your TIU's looking for engines that are already in the Engine List. All engines found will be set active and will be associated with the TIU that found them. If you don't want this to happen, remove the check from the option. This will never add an engine to the Engine List - press [Read] if you want to do that. 

24. In the Setup window using two buttons and from the [Setup] button on the main screen, you select two new windows:

	A. [Select Active TIU] RTC must be told which TIU are to be actively used. Select them with the switches. RTC must be disconnected from the TIU's to change these settings. There must always be at least one active TIU selected.

	B. [Super TIU Mode Setup] RTC needs to know which TIU are to participate in Super TIU mode. Select them with the swtiches. RTC must be connected to the active TIU's to change these settings.

25. I added support (or at least a first cut) for a Watchdog Signal. There is new window called "Watchdog". You can acces this window from the context popup menu on the TIU Spinner or the context popup menu on the Engine List. The purpose of the Watchdog to allow engines to come up quiet and in command mode when the the siding that they occupy is powered on after the WTIU is powered up. Look at  http://www.silogic.com/trains/WiFi.html for an example.

I also added support for the Watchog to the RTC Control Language ( http://www.silogic.com/trains/RTC_Control_Language.html ) . Look at the script Watchdog.lua and at the new RTC Command Language functions Sidings and Watchdog. 

26. The format of the version number returned by the WTIU has changed. The TIU returned the version as "0610" for version 6.1. The WTIU returns the version number as "v1.03-0-f0ee3b4c". RTC supports both formats now. You should be running the lastest DCS version in all of your devices.


Updates in Version 5.0.1 Misc fixes and enhancements and support for WTIU update file WTIU-v1.3.0-20250814.bin

1. Added Watchdog switch to the AIU Controls window. See web page

http://www.silogic.com/trains/WiFi.html#watchdog

2. Almost all windows will copy themselves to the clipboard when the RTC icon on that window is clicked.

3. There remains a bug which causes RTC to generate an exception when the [Exit] button is pushed when there is a small message window being displayed.

4. In All Engine Mode, the [Shutdown] button can now be pressed even if the [Startup] button was not pressed. if you do this, the RTC program will shutdown all active engines immediately. The "ShutdownAllEngines" menu item will shutdown all active engines sequentually spaced 1 second apart.

5. On the Engine List popup menu, I've added the ability to edit the TIU number associated with an engine. Just right click on the engine and a window will appear where you can change the associated TIU number. The value is saved when you exit from RTC.

6. Fixes to Engine Status window. I had all of the bits in byte 24 inverted. Bits were showm as '1' (green) when they should have been '0' (red).

7. Refinements to Super TIU Mode. Operation should be more stable.

8. Refinements to All Engine Mode. Operation should be more stable.

9. If you use the Debug system, you might be happy to learn that the "Up" direction text search in the [Find] dialog now works.

10. RTC now display a "Finding Engines" message when you press the [Connect] button. This operation compares the Engine Active List with your layout and sets the correct associated TIU for each engine.

Operational note: the setup option "[X] Auto Find Engines" causes RTC, each time you press [Connect], to attempt to locate all of the engines in the Engine List and associate them with the correct TIU. This could take many seconds. If the engines on your layout don't change, you can turn off this option and connection to the WTIU will be faster.

11. I added some status information to the RTC Main window. At the bottom of that window, I display a series of numeric fields. More may be added in the future, but right now they are (from left to right):

	a. Number of Active Engines
	b. Number of Inactive Engines
	c. Number of connected WTIU (only if in WiFi mode)
	d. Number of started engines
	e. Number of retries because of communication errors

The fields don't have labels but the help popup will tell you what each field contains.

12. I found a bug in the v1.06/v1.2.0 WTIU code. The WTIU has swapped the commands for Cab Chat and Clickety Clack. The command that previously turned them on, now turns them off. So with RTC, you will have to turn them on to turn them off. 

13. The format of the WTIU version number returned from the WTIU changed with WTIU version v1.3.0-20250814-1255 dated 9/8/2025. Previously LuCI and the WTIU had different version numbers. Now they have the same version number. This caused a part of RTC to crash because it could not parse the new version number. Fixed.

14. As part of the fix to item 13, after you press the [Connect] button, the text on that button will show the version number of the TIU, WIU/TIU, or WTIU selected on the TIU spinner.


Updates in Version 5.0.4 Misc fixes and enhancements 

1. There has always been a problem in RTC when run on a computer with multiple IP addresses. For example, a computer with both a wired Ethernet and WiFi connected at the same time. I believe that I fixed
this problem.

2. Added support for a physical 3 light signal head with basic indications: Proceed, Approach and Stop and Proceed/StopSignal. Designed to work with Mike Hewett's 3D printed signals. To do that, I wrote RTCSignal to control two of the signals. Complete details at:

http://www.silogic.com/trains/RTCSignal.html

3. Major cleanup of the Conventional Mode operation. Some notes:

	a. Track Control windows are accessed with the popup menu when you right click on the TIU number spinner.
    
	b. For the TIU number shown in the spinner, you can access the DCS setup window,
		variable channel 1 Track Control Operations window, and variable channel 2 Track 
		Control Operations window.

	c. Set your active TIU from the Setup window.

	d. Connect to the TIU by pressing the [Connect] button.

	e. Select the TIU to be used. Note that the TIU spinner should be
		green indicating connection established to that TIU.

	f: Right click on the TIU Spinner and select "Show Track Control Vx operations".

	g. The TIU channel will automatically be put into Variable Mode as shown by the Fixed/Variable switch setting.

	h. Now you can operate the Variable channel. For details about what the buttons
		and switches do, consult the DCS documentation.

	i. The Brake/Boost buttons change the voltage by 0.5 volts.

	j. When you want to return to DCS operation, you can return
		the variable channel to fixed mode. Remember that when you switch to
		fixed mode, full voltage will be applied to the track - remove
		any conventional engines from the track first.

	k. You can run any number of Track Control windows along with any number
		of DCS Operations Windows.

	l. If you have the DCS Signal enabled for the variable tracks, you can run both
		DCS and conventional engines on that track. Again, the DCS documentation
		explains it.

The only "real" documentation for the DCS system is the late Barry Broskowitz' "DCS O Gauge Companion". If you don't have it, get it.

4. Fixes to Engine Status window. I had Click Clack and Cab Chat inverted, they are not. Bits were showm as '1' (green) when they should have been '0' (blank). Other bits in the status byte 24 ARE inverted.

5. Carl Ross sent me some code to support an "Active Engine List" which is the normal Engine List but that shows only active engines. He gave me permission to add his code to RTC. To display the "Active Engine List", look for the checkbox "Act []" showing in the upper right of the Engine List. If you check this box, only active engines will
display. This feature is also available on the "PopOut Engine List" displayed by using the popup menu of the Engine List.

6. This is an answer asked by one of RTC's users:

	I've never seen a need for the "Add MTH Engine" item. This might
	be because I've never supported any TMCC engines. 

	When RTC connects to the WTIU, engines in the engine list are scanned to be sure that
	they are powered up. If found, they are marked active. Thus when
	you start RTC, you can be sure that if the engine was in the
	engine list and marked active, it is really on the layout and powered on. This
	feature does not add or delete engines from the list, it only
	marks them active if they are powered on.

	Then you can use the "READ" button to scan for all powered on
	engines. This feature, will add new engines to the engine list.
	If the setup option "Keep engines on Read" is checked, engines that
	are no longer powered will be set inactive. If that option
	is not checked, the unpowered engines will be deleted from
	the list.

	On the right click popup menu on the "READ" button is "Add
	Factory Reset Engine". This is used to add an engine whose
	engine number is zero - that is, never used before.

7. Fixed a problem in the functions:

void __fastcall TMainForm::ShutDownActiveEngines(int iDelayTimeSeconds)
void __fastcall TMainForm::ShutdownAllEngines(int iDelayTimeSeconds)
void __fastcall TMainForm::ShutdownAllEngines(int iDelayTimeSeconds)

8. Changed the LashUp and Operations Windows to show lashup numbers from 101 to 120 which is more consistent with RTC's numbering.

9. ChatGPT is your friend - I passed a few critical sections of RTC to the ChatGPT and Grok AI bots. They had some good suggestions that have made RTC more stable. They also had a few really dumb non-functional suggestions. Use AI wisely. 

10. I did some clean up of code that supports multiple monitors. Now popup messages should appear on the same window as the popup's parent window.

11. Five information boxes appear across the bottom of the main RTC window. They are left to right:

	Number of Active Engines
	Number of Inactive Engines
	Number of RFID Detectors found (if using the RFID system)
	Number of RFID Readers found (if using the RFID system)
	Number of Signals found (if using the Signalling system)

	I changed these from earlier versions of RTC as I found this information more useful.

12. Added support for Approach Lighting to the Signals code. Now you can instruct the on layout physical signals to remain dark if there is no engine in the block and no engineer to see the signals anyway.

Affected Program Control script commands are CreateSigna() and SetSignal(). Specifically, if the Aspect parameter to those commands is negative, the signal follows Approach Lighting rules.

13. Added several commands to the Program Control scripts to check detectors/readers and signals - You can use these functions to check that all RFID detectors/readers and Signal on your layout are alive and responding.

	CheckReader(DetectorNum, ReaderNum);    -- checks that RFID detector and reader exist, if so, returns true,
    -- otherwise returns false. ReaderNum can be 0 to 5 (total of 6 readers per detector possible).
    -- On error : Returns nil
    -- usage:
        Exists = CheckReader(DetectorNum, ReaderNum);

    GetTagReaders();    -- returns 2 values giving the number of Tag Detectors and the
    -- number of Tag Readers (1-6) found
    -- usage:
        NumDetectors, NumReaders = GetTagReaders();

	GetSignals();    -- returns 1 value giving the number of Signals found
    -- usage:
        NumSignals = GetSignals();

	CheckSignal(SignalNum);    -- checks that SignalNum exists, if so, returns true,
    -- otherwise returns false.
    -- On error : Returns nil
    -- usage:
        Exists = CheckSignal(SignalNum);

14. Added Message() command to the available lua Program Control script commands. 

    Message(textvalue);    -- sets textvalue to place a message on the Program Control
    -- window. You can use this for persistence status messages. There is only a limited amount of space
    -- for text so keep textvalue short. The message appears to the left of the [Layout] button.
    -- example
        Message("Aliquippa Block");

15. Added the ability to drag and drop lua script files into the Program Control window.


-----------------------------------------------------------------------------------------------
You can learn about the RTC program on this web page:
http://www.silogic.com/trains/RTC_Running.html

Complete details and documentation for the Program Control windows are on this page:
http://www.silogic.com/trains/RTC_Control_Language.html

-----------------------------------------------------------------------------------------------

Hint - If you click on "About RTC" from the main popup menu and then click on
the "Hide" button, that annoying copyright window on startup won't appear any more.

