TS2015 Raildriver Interface

General discussion about Train Simulator, your thoughts, questions, news and views!

Moderator: Moderators

Post Reply
CobraOne
Well Established Forum Member
Posts: 505
Joined: Fri Aug 02, 2013 10:28 am
Location: Kent, England

TS2015 Raildriver Interface

Post by CobraOne »

I have spent the last year writing a program to enable me to extract data from TS2015, then read data from a Raildriver console and finally pass the data back to TS2015. This enables the controlling of the virtual cab controls that the supplied driver for the Raildriver controller can't operate such as Cab Reverser, Virtual Reverser, Cab Throttle, Virtual Train Brake and many others. You can also assign different values to the Wiper & Lights switches instead of the default ones, and although you still have only 3 positions, they can be 0, 2, 3 for off, fast intermittent and continous for example for the wipers. You can also setup the reverser as a 4 position reverser such as off, forward, neutral and reverse or off, reverse, neutral and forward, the choice is yours.
I have also designed the interface for assigning the buttons in a way that allows you to add new commands as new trains are added and you can assign the same command to two buttons as I have done with the Bell being assigned to the Bell button and the Horn Down.

I am not a professional programmer although I did do an introductory course in Visual Basic 3 (yes that long ago) but nothing since.
My first task was to learn the basics of lua scripting which enabled me to produce the enclosed ‘Railworks_GetData_Script.lua’ file which is the file that will extract all the data you need regarding the throttle, reverser, brakes, gauges and many others. It is also used to pass data back to TS2015.
Then I taught myself the basics of Visual C# and, with much hair pulling and nearly abandonimg the project on many occassions, I produced the main program, TS2015 Raildriver Interface, along with three supporting programs.

I have tested all this software as best I can on my machine and all works well and I can see no reason why it shouldn't on other machines. The one thing I did notice was a drop in frame rate in TS2015 on some routes going from 74 fps to 62 fps but that is because there is a lot of data passing between my program and TS2015. To try and overcome this drop in framerate I have included a delay in the Railworks_GetData_Script.lua file that you can edit yourself and adjust this delay by altering the value of the 'delay' variable near the top of the file just before the GetData() function.
The default I have set it to is 10 which means on my machine a (i7 with GTX760) I only drop from 74fps to 69fps running the Portsmouth direct route. If I set the delay to 0 so in effect there is no delay my framerate drops to 58fps. Increasing the delay to say 15 did not show any improvement but I did start to notice a delay from the game in responce to control input from the Raildriver.
What I suggest you do is edit one or two train files and try them first, and if need be, alter the delay variable in the script file.

In this zip file you should find the following folders:-
1. CalculateNotchValues - This is used to calculate values to enable a lever to become a lever with notches
2. Engine Script Editor - This program replaces the default engine script with a version that call the ‘Railworks_GetData_Script.lua’ file and then the original renamed file.
3. TS2015 Data Extractor - This will extract data from the engine.bin and inputmapper.bin files into a readable format and saved in a text file.
4. TS2015 Raildriver Interface (Program) - This is the main program for the Raildriver to communicate with TS2015.

And the following files:-
1. TS2015 Interface Readme.doc or pdf - 12 page tutorial with pictures on how to use these programs
2. Engine Script Locations.pdf or xls - Lists the locations of the engine script files on my machine that I had to edit
3. Railworks_GetData_Script.lua - The script that communicates with TS2015 and should be placed in your plugins folder.

I am not releasing the code for any of the programs yet as I want to confirm with other users all is well with the programs. Also the code needs tidying up and commenting first. This will take some time as there are just under 7000 lines of code between them.
The files can be downloaded from here: https://www.dropbox.com/sh/cbwyvjrt3x6g ... -rBqa?dl=0

Have a play and let me know how you get on

Chris (CobraOne)
Latest version always available from
https://www.dropbox.com/sh/cbwyvjrt3x6g ... -rBqa?dl=0

Discussion on latest version starts on page 48
Works with all versions from 2017 to 2021
User avatar
holzroller
Very Active Forum Member
Posts: 4310
Joined: Sat Jun 13, 2009 11:00 am
Location: NE Scotland

Re: TS2015 Raildriver Interface

Post by holzroller »

I'll have a little play with it, but probably not until the weekend.
User avatar
jp4712
Petulant Princess
Posts: 4798
Joined: Mon Jul 01, 2002 6:09 pm
Location: Lichfield, Staffordshire
Contact:

Re: TS2015 Raildriver Interface

Post by jp4712 »

I shall have a go tomorrow morning and let you know how I get on.

Paul
Visit the Manchester Museum of Transport, the UK's premier bus museum
nobkins
Very Active Forum Member
Posts: 4421
Joined: Fri Jun 12, 2009 11:51 pm
Location: Leeds

Re: TS2015 Raildriver Interface

Post by nobkins »

Congratulations to Chris on the dedication and persistence he has shown. I know from learning a new language to write RWDecal that it is often a frustrating process and for me involved a lot of Googling for examples of how to do things.

Chris has also uploaded his files to TrainSimDev.com if anybody needs an alternative to the dropbox link he has given above:
http://www.trainsimdev.com/forum/downlo ... &df_id=124

Well done Chris.
TrainSimDev.com The community dedicated to those who create content for any Train Simulator.
Includes: Free downloads via torrent or browser, forum browsable by all, membership by invitation (any member can invite someone)
mojo12012
Established Forum Member
Posts: 344
Joined: Sat Nov 12, 2011 9:11 pm

Re: TS2015 Raildriver Interface

Post by mojo12012 »

Thanks Chris. Look forward to seeing if the later locos will respond fully.
nnndoh
Getting the hang of things now
Posts: 36
Joined: Wed Feb 20, 2008 9:17 pm

Re: TS2015 Raildriver Interface

Post by nnndoh »

Dust-wiping my raildriver as we speak...thank you,thank you , thank you!
only thing when calibrating. when i push a button ,it ask if i pushed the right one,and when i click yes, it closes the calibrating window.
CobraOne
Well Established Forum Member
Posts: 505
Joined: Fri Aug 02, 2013 10:28 am
Location: Kent, England

Re: TS2015 Raildriver Interface

Post by CobraOne »

nnndoh wrote:Dust-wiping my raildriver as we speak...thank you,thank you , thank you!
only thing when calibrating. when i push a button ,it ask if i pushed the right one,and when i click yes, it closes the calibrating window.
Sorry, I should have made it clear in the instructions, you only need to calibrate the levers, (Reverser, Throttle, Auto Brake, Ind Brake, Bail off) and the switches for the wipers and lights which are all indicated by the sliders. You basically do the same as you did with the Raildriver calibration software that came with the Raildriver, but with my system you move the lever to the relevant position and then click the button to the right of the slider with the < and a number as in <240 for the reverser in reverse.
The buttons 1 to 44 do not need calibrating and are assigned their functions using the Edit Key Map button on the main form.

Chris
Latest version always available from
https://www.dropbox.com/sh/cbwyvjrt3x6g ... -rBqa?dl=0

Discussion on latest version starts on page 48
Works with all versions from 2017 to 2021
atpyatt
Getting the hang of things now
Posts: 23
Joined: Thu Oct 11, 2007 4:35 pm

Re: TS2015 Raildriver Interface

Post by atpyatt »

I've just enjoyed driving the 143 with my raildriver for the first time, worked very well, thanks for all your hard work.
User avatar
dick8299
Established Forum Member
Posts: 308
Joined: Thu Mar 13, 2008 3:25 pm

Re: TS2015 Raildriver Interface

Post by dick8299 »

I installed the files and updated the simulation file in the default SD40 engine from Kuju. When I ran a long scenario from Ohio Steel II, I was disappointed to discover that your program did not fix my problem with RailDriver. That is the dropping out of the raildriver commands. I set the engine throttle to 23% and let the train run. After a while, without touching the raildriver lever, the throttle on the F4 display dropped to zero on its own. It seems that the Train Sim program is not constantly reading the lever position from the Raildriver.

If there is something I missed in the installation, or am doing wrong, please advise me what to do to get TS2015 to reliably read the lever position from the raildriver.
CobraOne
Well Established Forum Member
Posts: 505
Joined: Fri Aug 02, 2013 10:28 am
Location: Kent, England

Re: TS2015 Raildriver Interface

Post by CobraOne »

dick8299 wrote:I installed the files and updated the simulation file in the default SD40 engine from Kuju. When I ran a long scenario from Ohio Steel II, I was disappointed to discover that your program did not fix my problem with RailDriver. That is the dropping out of the raildriver commands. I set the engine throttle to 23% and let the train run. After a while, without touching the raildriver lever, the throttle on the F4 display dropped to zero on its own. It seems that the Train Sim program is not constantly reading the lever position from the Raildriver.

If there is something I missed in the installation, or am doing wrong, please advise me what to do to get TS2015 to reliably read the lever position from the raildriver.
Hi Dick
I have just run a 35 minute quick drive with the sd40 with the throttle set at 22% and that's where it stayed the whole trip. My software does read the raildriver continually, the only thing I can suggest is that your PC is powering down the usb port you Raildriver is connected to. If you goto:-
Control Panel
Power Options
(whatever plan you have selected choose) change plan settings
Change advanced power settings
usb settings
Usb selective suspend settings
settings = disable

These are on a windows 8 machine but other windows versions should be similar See if that works and let me know

Chris
Latest version always available from
https://www.dropbox.com/sh/cbwyvjrt3x6g ... -rBqa?dl=0

Discussion on latest version starts on page 48
Works with all versions from 2017 to 2021
CobraOne
Well Established Forum Member
Posts: 505
Joined: Fri Aug 02, 2013 10:28 am
Location: Kent, England

Re: TS2015 Raildriver Interface

Post by CobraOne »

I have released v1.01 http://www.trainsimdev.com/forum/downlo ... &df_id=124 which fixes the following:
TS2015 Raildriver Interface
1. Added option to select the location of your Railworks folder due to an error in the railworks installation program not updating the registry properly. This can happen if you install Railworks anywhere other than the default location.
2. Hide the buttons in the calibrate Raildriver form to prevent users trying to calibrate the buttons as well as the levers when it's only necessary to do the levers and lighs/wiper switches..
3. Updated the engine script location documents in respect to the class 166 which due to yet another inconsistency in Railworks needs the engine simulation script and not the engine script edited with the Engine Script Editor.
4. Added the option to turn the Speaker on/off on the Raildriver (untested).

Engine Script Editor
1. On the wise suggestion of Jim (Nobkins) at TrainsimDev.com, I have ammended the Engine Script Editor to append .rdbak instead of .bak to the end of the renamed engine script files just in case there are other backup files in the railworks folder you wish to delete without deleting the original engine script files by mistake. Don't worry if you have edited your files already, they will still work, just be careful if deleteing .bak files.

Engine Script Locations pdf/doc
1. Again thanks to Jim (Nobkins) he found that the Class 166 does not work if you edit the engine script files I suggested in the pdf/doc.
Instead I found you need to edit the simulation files instead, pdf/doc updated with engine simulation file location. There is no need to undo the changes you made to the engine script files although you can if you want to. This is yet another example of the problems I faced in designing this software

TS2015 Interface Readme doc/pdf
1. Updated to V1.01 and tutorial updated to reflect the changes made in both programs. Changes highlighted in blue.


Hopefully that should solve most peoples problems but as always, let me know either way

Chris
Latest version always available from
https://www.dropbox.com/sh/cbwyvjrt3x6g ... -rBqa?dl=0

Discussion on latest version starts on page 48
Works with all versions from 2017 to 2021
User avatar
Havner
Been on the forums for a while
Posts: 293
Joined: Thu Sep 11, 2014 1:32 am

Re: TS2015 Raildriver Interface

Post by Havner »

CobraOne wrote:3. Updated the engine script location documents in respect to the class 166 which due to yet another inconsistency in Railworks needs the engine simulation script and not the engine script edited with the Engine Script Editor.
And why is that?
CobraOne
Well Established Forum Member
Posts: 505
Joined: Fri Aug 02, 2013 10:28 am
Location: Kent, England

Re: TS2015 Raildriver Interface

Post by CobraOne »

Hi Havner.

It appears that with the Class 166, if you edit the engine file then the throttle and brake lever won't release/apply the brakes, but if you edit the simulation script instead all works fine.
To be honest, at the moment I have too much to do and being as this appears to be the only train with this problem I can't be bothered to delve any further yet.
Chris
Latest version always available from
https://www.dropbox.com/sh/cbwyvjrt3x6g ... -rBqa?dl=0

Discussion on latest version starts on page 48
Works with all versions from 2017 to 2021
User avatar
Havner
Been on the forums for a while
Posts: 293
Joined: Thu Sep 11, 2014 1:32 am

Re: TS2015 Raildriver Interface

Post by Havner »

Can you send me the engine script for it? I'd be happy to look. I'm curious.

Or is it included in EU pack? In that case I have it ofc.
CobraOne
Well Established Forum Member
Posts: 505
Joined: Fri Aug 02, 2013 10:28 am
Location: Kent, England

Re: TS2015 Raildriver Interface

Post by CobraOne »

Havner wrote:Can you send me the engine script for it? I'd be happy to look. I'm curious.

Or is it included in EU pack? In that case I have it ofc.
I let curiosity get the better of me and decided to look in the engine.bin files and found that the engine script that needs editing is in the MOS folder and not the ones in the DMOS or DMOCL folders which are the usual locations. I may need to rewrite my engine data extractor to also extract the location of the engine script, but again as this is the only one that appears to have this problem, maybe not.

Chris
Latest version always available from
https://www.dropbox.com/sh/cbwyvjrt3x6g ... -rBqa?dl=0

Discussion on latest version starts on page 48
Works with all versions from 2017 to 2021
Post Reply

Return to “[TS] General Discussion”