Seite 2 von 3

Re: Zusi Display with Train Simulator 2015??

Verfasst: 29.11.2014 20:09:53
von <Bernd>
F. Schn. hat geschrieben: And I'm stil confused, how the brake variables are working, so I skiped them too.

Code: Alles auswählen

ThrottleType:ThrottleAndBrake
ThrottleMin:0
ThrottleMax:1
ThrottleType:ThrottleAndBrake
ThrottleMin:0
ThrottleMax:1
Throttle:78
TrainBrakeControl:0
TrainBrakeControlMin:0
TrainBrakeControlMax:1
DynamicBrake :0
DynamicBrakeMin:0
DynamicBrakeMax:1
EmergencyBrake:0
Reverser:100
ReverserMin:-1
ReverserMax:1
I still do not understand why these Min/Max values are there. The other settings reflect the INPUT setting of the user controls.
Reverser 100 for diesel and electric loco means direction set to forward, -100 for reverse.
Throttle ranges from 0 (off) to 100 (%) traction. if throttle type is trottle and brake the values will range from 0 to 100 (%traction) and 0 to -100 (%train brake applied) as far as I remember.
Train Brake and Dynamic Brake are also settings of the input levers.

brake status in the sim is reported with the BAR- or PSI- values.

I will try to test something tomorrow.
I'm stil missing PZB-Values in your text file
@gazz: have you got a loco that supports PZB ? which one ? I would like to build an example of what to do to get these values.

Re: Zusi Display with Train Simulator 2015??

Verfasst: 29.11.2014 21:25:36
von gazz
i too am unsure why the data extractor is displaying the min and max values of the controls, i think in CobraOnes data extraction tutorial he said it could display the positions of the control levers, maybe that's why it needs those min and max value entries... personally i can't see why you would want to display the control position when you have them in real life on the drivers desk you are using to control the sim with.

BUT, in Havners train sim helper, his code uses the input lever settings like those (ThrottleType:ThrottleAndBrake, min 0, max 1) to set how the joystick works with the game, maybe they are in the data extractor program for a planned joystick control feature?


A train with PZB and LZB working in railworks is the Br423,


I am still working to build the latest solution from F. Schn. i did it once, but messed it up and had to delete it and start again, and now i can't remember how i got it to work, the result was a command line based window that was sending the data to the TCP server,

Re: Zusi Display with Train Simulator 2015??

Verfasst: 30.11.2014 02:19:39
von gazz
it's almost working,

i am probably doing this wrong, so here is what i did... please don't laugh too hard if i am totally messing things up :)

First i clock the link to F Schn.'s git hub page, i click the 'ZusiTCP.NET' link at the top (home directory) that gives me a 'Download ZIP' option, which i click and get a copy of everything on that page on my computer,
I unzip it, then open the 'ZusiTCP.NET-featuer-tcp-server' folder,
Then i open 'examples' 'cs' and 'simpleDemo'

Next i open 'CsSimpleDemo.csproj' and it opens the project in visual studio express 2013, and there are 2 projects 'CsSimpleDemo' and 'Zusi-Datenausgabe'
I click 'Build Solution' and magic stuff happens, and i end up with a 'Release' folder, and in it the 'CsSimpleDemo.exe' file amongst others.

and i have found out that i should have used 'DeBug' instead of build? as without using DeBug, the KompilierBefehl.bat' does not work.

But once i compiled it in DeBug mode, starting the TCP server then clicking the KompilierBefehl.bat in 'RailworksMaster' does what it is supposed to.

So if i now start ZusiDisplay, a get 66kmh registering on the speedo,

I think the problem is with the path the program is set to get it's data from, the command prompt window says 'Path: dat' and i notice that is in the 'railworksmaster' folder, 'dat/plugins/GetData.txt'

I think it is supposed to have done something to read from the railworks plugin folder where the GetData.txt file that gets updated all the time is located, but for some reason it's not done so?

if i change any of the numbers in the dat/plugins/GetData.txt file, it updates zusidisplay, so it's nearly working, just need to figure out what i have done wrong so it reads or writes to the correct GetData file.

Re: Zusi Display with Train Simulator 2015??

Verfasst: 30.11.2014 03:55:44
von gazz
And it's working :applaus

I changed the text that is added to the trains engine script to call the data extractor, it was pointing to plugins/GetData.txt, so i changed it to point to /plugins/dat/plugins/GetData.txt, and it worked.

Now i am pretty certain i am doing it wrong by putting the entire 'ZusiTCP.NET-feature-tcp-server' folder in the railworks plugins folder, but that's what i had to do to get it to work,
i imagine because it's running in debug mode, and when it's in release mode there will just be a couple of files to put in the plugins folder.


But i have just been driving the Br423 with the speed showing correctly on the MFA displayed in a 2nd monitor, the traction meter's 'bug' goes to max brake effort as soon as the train moves, and will slowly climb to around half way up the scale at around 100kph, so i imagine it is just reading the wrong bit of data.

Re: Zusi Display with Train Simulator 2015??

Verfasst: 30.11.2014 14:50:28
von F. Schn.
This programe expects railsim in the path, that is stored in the registry in "HKEY_LOCAL_MACHINE\\SOFTWARE\\railsimulator.com\\railworks\\" "Install_Path".
If the programe fails to get this value it will use the file in the "dat"-Directory. (So I can test the programe without having railworks instaled. ;) )

If TrainSimulator 2015 does not store it's installation path in this regitry key, you have to modify the following two lines:

Code: Alles auswählen

		if (master.RailworksPath == null) //comment this line to run it always it's sandbox.
				master.RailworksPath = "dat";
to

Code: Alles auswählen

		//if (master.RailworksPath == null) //comment this line to run it always it's sandbox.
				master.RailworksPath = "C:\\Program Files (x86)\\Path\\To\\Railworks";
But maybe I can find another reistry-Path for TS2015 - @<Bernd>: Is there another regristry key that may contain the path to TrainSimulator 2015?

Zusi sends the following brake datas:
Druck Hauptluftleitung
Druck Bremszylinder
Druck Hauptluftbehälter

I think normal Zusi programes will calculate brake effort using the first and the second preasures but maybe ZusiDisplay uses advanced datas. :) Well, I've not implented only a few datas, I guess I need to extend this to get ZusiDisplay working better.

Re: Zusi Display with Train Simulator 2015??

Verfasst: 30.11.2014 17:59:39
von gazz
Ahhh, that makes sense,

The default trainsim/railworks install path is "C:\Program Files (x86)\Steam\SteamApps\common\RailWorks" on a 64bit install of windows, the same path minus the (x86) part on 32 bit installs.



I am not sure if it is of any use, but here is a link to the DB BR 423 .xml file in railworks that runs the simulated items (brakes, power, switches, lights, levers and so on)
https://www.dropbox.com/s/5a143dfhwqnsc ... e.xml?dl=0
That is my favorite train, and one which has the PZB, LZB and Sifa functions fully functioning (well, functioning as well as railworks can make it :)

The file linked above lists that this particular train displays "MainReservoirPressure" and "BrakePipePressure" only. (Hauptbremsleitung and Hauptluftbehälter)
however i believe the needle on the tractive effort gauge is handled by:

Code: Alles auswählen

</cControlContainerBlueprint-cControlValue>
						<cControlContainerBlueprint-cControlValue d:id="35615968">
							<ControlName d:type="cDeltaString">TractiveEffort</ControlName>
							<DefaultValue d:type="sFloat32" d:alt_encoding="0000000000000000" d:precision="string">0</DefaultValue>
							<MinimumValue d:type="sFloat32" d:alt_encoding="0000000000408FC0" d:precision="string">-1000</MinimumValue>
							<MaximumValue d:type="sFloat32" d:alt_encoding="0000000000408F40" d:precision="string">1000</MaximumValue>
							<BriefDescription d:type="cDeltaString"></BriefDescription>
							<DetailedDescription d:type="cDeltaString"></DetailedDescription>
							<ApplyToConsist d:type="cDeltaString">eFalse</ApplyToConsist>
							<HUDControlID d:type="sUInt32">0</HUDControlID>
							<InterfaceElements/>
There is also one for 'acceleration' which has the same values (-1000 - 1000) but that could be used by railworks for part of the 'game' that records how you drive, i.e hard acceleration and braking loses you points as well as timekeeping and so on :rolleyes:

Re: Zusi Display with Train Simulator 2015??

Verfasst: 30.11.2014 23:36:48
von gazz
Got it working to read from the getdata.txt file in the plugins folder, thanks for telling me how to do it :)

I am now trying to see if i can figure out how to make the railworksmaster program read from a different data file, namely the 'trainsim-helper-overlay.txt' file that Havners train sim helper produces,

Well, actually i did get it to read that .txt file, but the data is not in the format it expects, but i did get the speedo needle moving on zusidisplay whilst running trainsim helper to allow my joysticks to work with the game,

I only have the source files to trainsim helper 0.3, but it looks like it's not too hard to add extra data items and change the format, and/or change what the railworksmaster is expecting.

If your interested, http://vega.livecd.pl/~havner/trainsim- ... 2a-src.zip is the souce file for Havners trainsim helper, which allows railworks to use joysticks (stupid isn't it, the makers of railworks refuse to impliment joystick use, expecting everyone to be happy driving trains with a keyboard!!) but trainsim helper also extracts data in a similar way to CobraOnes getdata script, just the data is displayed on the screen in text as an overlay,

Re: Zusi Display with Train Simulator 2015??

Verfasst: 01.12.2014 00:00:27
von Andreas Karg
So far I've only skimmed over this thread, but I'd still like to make some contribution.
Am I right in assuming that you are still going the Sim->Lua->Txt->F. Schn's tool->TCP-Client(s) way?

I'm pretty sure Lua supports some sort of TCP/IP communication. If that is the case with Railworks' runtime environment, would it therefore be an option to modify the Lua script so it connects to a TCP server and acts like a ZuSi instance? Would cut out the "middle man" of TXT files... (which I generally find a very VERY ugly solution - albeit seemingly unavoidable in the given context)

Edit: Clarified a few sentences

Re: Zusi Display with Train Simulator 2015??

Verfasst: 04.12.2014 13:03:52
von <Bernd>
@ F.Schn.
I do not know much about registry details...
what I found is install_path at the following location:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\railsimulator.com\railworks

thats probably running a 32bit software on a 64bit system -> programs and programs(x86) directory ...


@Andreas Karg
ugly txt-files
this is pure WYSIWYG :hat2

according to google there is a tcp/ip lib. unfortunately I do not have any experience with LUA yet, but the languyge seems to be less "complicated" then C++ :angst

@all
sorry no further news yet, did not have time to proceed...

Re: Zusi Display with Train Simulator 2015??

Verfasst: 04.12.2014 19:48:27
von gazz
i can't help either way as i know very little about programming, but i am working my way through some C# tutorials right now to try and understand it better,

I have been told that LUA is very unforgiving about errors, one misplaced character and everything just refuses to work, at least C will give you a clue to what's wrong.


But Re: the railworks - ZusiDisplay thing, i am slowly playing with the various bits of source code trying to figure things out,
the main thing i have done is switched over from using CobraOnes GetData utility, and am using Havners TrainSim-Helper instead,

Reason for this is that TrainSim Helper gives railworks joystick control ability at the same time as extracting the data, so it made sense to use the one program to do both items we need (as railworks has no native joystick support) so it seem'd silly to run one program to allow joystick support, and another to get the data out, especially as the joystick program gets the data out too.

The only thing is TrainSim Helper is written to display the data as an overlay on the screen, and to do this it requires RailWorks to be run in windowed mode,
But i am sure that if the bits of code that handle the text overlay are removed it will allow Railworks to run in fullscreen mode again.


So all i have done is change the bit of code in RWZusiConverter.cs that said
"if (File.Exists(RailworksPath + "\\plugins\\tGetData.txt"))" to
"if (File.Exists(RailworksPath + "\\plugins\\trainsim-helper-overlay.txt"))"

And of course i start up TrainSim Helper when i start Railworks to allow the joystick functions and get the data out, and patch the engine.lua files with the TrainSim Helper patcher instead of the GetData one.


Then i changed a little bit in the RailWorksMaster.cs,

Code: Alles auswählen

 master.RailworksPath = "C:/Program Files (x86)/Steam/SteamApps/common/Railworks";
		System.Console.WriteLine("Path: " + master.RailworksPath);
		master.SingleItems.Add("Speed", 2561); //Speed
        master.SingleItems.Add("Zugkraft gesamt", 2565); //traction gauge
        master.SingleItems.Add("Druck Hauptluftleitung", 2562); //main pipe pressure
        master.SingleItems.Add("Druck Hauptluftbehalter", 2564); //reservoir pressure
        master.SingleItems.Add("Druck Bremszylinder", 2563); //brake cylinder pressure
        master.SingleItems.Add("Strom", 2567); //Current 
        master.SingleItems.Add("Spannung", 2568); //Voltage
        master.SingleItems.Add("LM Turen", 2607); //Doors locked
        master.SingleItems.Add("LM Sifa", 2596); //Sifa light
		master.SingleItems.Add("Clock", 2610); //clock
		master.Start();
TrainSimHelper writes the speed and distance data to the txt file in KMH or MPH, so no need to convert from meters per second as with the GetData.txt,

I am now working on getting the correct data from the sim to the text file in the TrainSimHelper code,


Can someone tell me what format zusi display wants the (Digital) Clock data as? as all combinations i tried don't work.... 21:20,00 21:20:00 21h 20,00 etc.


I also don't understand why the "HKEY_LOCAL_MACHINE\\SOFTWARE\\railsimulator.com\\railworks\\" bit is not working, as it seems to work in the getdata and trainsimhelper code,

I have noticed that to get it to work i have to put my railworks path with forward slashes /, instead of back slashes \,
i.e : C:/Program Files (x86)/Steam/SteamApps/common/Railworks
but i don't know enough to understand when forward of back slash should be used.

Re: Zusi Display with Train Simulator 2015??

Verfasst: 04.12.2014 21:37:23
von F. Schn.
"\" vs "/":
C# uses escape sequenzes. This means, you can use a combination of chars to represent chars, that are normally reserved by C# (i.e. the chars for a new line). This combination always starts with "\", so if you want to write a "normal" "\" you have to use "\\" instead of "\".

"master.SingleItems.Add(...)":
SingleItems is not inteted to be used for non-float data types. LM Tueren and LM Sifa are bool-Data types, for these types "BoolItems" shuld be used. It may work with "SingleItems" too, but it is not intented to do so.

Digital Clock:
Clock is a special data type - DateTime - and was not implemented yet, because I did not know, how dates may be represented in this text file. I can suggest the following format:

Code: Alles auswählen

		System.DateTime.Now.ToString("yyyy-MM-ddTHH.mm.ss.FFFFFFF")	"2014-12-04T20.51.14.6970377"
.Net uses this format (but with ":" ) in its XML-Flies.
I've updated the example so it should work now (but I did not test it).

Lua and TCP:
It is possible to use the .Net-dll with Lua without the need to write datas in a text file, using NLua. But I've not tried to use it, because I have no Railworks.

Re: Zusi Display with Train Simulator 2015??

Verfasst: 04.12.2014 22:47:15
von gazz
ahh right, thanks, i am learning slowly :)

i've just been playing really, changing the Zusi 4 digit codes to figure out what kind of data is needed to operate a feature,
SingleItems did work for the LM items, but i'll change them to use BoolItems now i know about it,

Re: Zusi Display with Train Simulator 2015??

Verfasst: 04.12.2014 22:49:53
von <Bernd>
Digital Clock
clock in railworks is in seconds (since midnight), no date
simulation time
time a scenario is running from start (in seconds)

Re: Zusi Display with Train Simulator 2015??

Verfasst: 04.12.2014 23:00:42
von gazz
ahhh, i knew i'd read about railworks clock being in seconds past midnight,

that explains this bit of code in trainsimhelper

Code: Alles auswählen

#define GETHOURS(nClock)		((nClock) / 3600)
#define GETMINUTES(nClock)		(((nClock) % 3600) / 60)
#define GETSECONDS(nClock)		((nClock) % 60)
Whick i presume takes the clock data from railworks and splits it into hours, minutes and seconds that are called later on to display the time,

Re: Zusi Display with Train Simulator 2015??

Verfasst: 04.12.2014 23:07:46
von <Bernd>
exactly gazz :]
clock is stored in a floating point variable. if you read the variable from the .txt file it is of type double if you are using c#

Re: Zusi Display with Train Simulator 2015??

Verfasst: 04.12.2014 23:22:32
von <Bernd>
@gazz
The only thing is TrainSim Helper is written to display the data as an overlay on the screen, and to do this it requires RailWorks to be run in windowed mode,
But i am sure that if the bits of code that handle the text overlay are removed it will allow Railworks to run in fullscreen mode again.
if you run rw in fullscreen mode your data is still written to the .txt file and can be extracted for further use. it is just not written as overlayed data. thus you will not have to change the code ! please try ...

Re: Zusi Display with Train Simulator 2015??

Verfasst: 04.12.2014 23:45:33
von gazz
Just confirming the install path Bernd found works for me,

RailworksPath = (string)Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\railsimulator.com\\railworks\\", "Install_Path", "");

I'm using windows 8, 64 bit version,

Re: Zusi Display with Train Simulator 2015??

Verfasst: 05.12.2014 01:58:39
von gazz
i've just had a little drive of a BR 423, i had Max Strobel's BR 423-426 zusi MFA running as well as one of the ZusiDisplay's Diagnostic panels, both on the second monitor,

I only have Speed, Current, all Brake pressures, and the Sifa light working so far, but at least i'm getting somewhere,

had no luck with the Clock data, beyond my non existant skills to do that bit... needs something to take the seconds past midnight number and split it into hours minutes and seconds, then be able to call them in the forma zusi would output so zusidisplay can understand.
i listed the code to do in another post, but not sure how to implement it.

This is the RailworksMaster.cs code i am running at the moment that works with the unedited data coming out of TrainSim Helper:

Code: Alles auswählen

class ServertTest1
{

	public static void Main()
	{
		System.Console.WriteLine("Railworks <-> Zusi Master");
		var master = new Railworks_GetData.RwZusiConverter();
		master.ErrorReceived += TCPConnection_ErrorReceived;
		 //if no Railworks is installed run the application in it's sandbox.
       if (master.RailworksPath == null) //comment this line to run it always it's sandbox.
            master.RailworksPath = "Dat";
		System.Console.WriteLine("Path: " + master.RailworksPath);
		master.SingleItems.Add("Speed", 2561); //Speed - Working
        master.SingleItems.Add("Acceleration", 2565); //traction gauge -Not working, wrong data
        master.SingleItems.Add("AirBrakePipePressure", 2562); //main pipe pressure -Working
        master.SingleItems.Add("MainReservoirPressure", 2564); //resovoir pressure -Working
        master.SingleItems.Add("TrainBrakeCylinderPressure", 2563); //brake cylinder pressure -Working
        master.SingleItems.Add("EqReservoirPressure", 2579); //brake cylinder pressure -Working
        master.SingleItems.Add("Ammeter", 2567); //Current -working
        master.SingleItems.Add("Spannung", 2568); //Voltage -Not working need to find data in LUA
        master.SingleItems.Add("LM Turen", 2607); //Doors locked -Not working, need to find data in LUA
        master.SingleItems.Add("VigilAlarm", 2596); //Sifa light -working
        master.SingleItems.Add("LM PZB 500hz", 2581); //500hz pzb light -not working, need to find data in LUA
        master.SingleItems.Add("AWS", 2580); //1000hz pzb light -Semi working, only on some trains
		master.SingleItems.Add("Clockh", 2570); //Hours -Not working
        master.SingleItems.Add("Clockm", 2571); //Mins -Not working
        master.SingleItems.Add("Clocks", 2572); //secs -Not working .... need to transform railworks seconds 
        //past midnight clock into H, M, S data and feed it to zusidisplay in the correct format.
		    master.Start();
	}
	private static void TCPConnection_ErrorReceived(object sender, Zusi_Datenausgabe.ZusiTcpException ex)
	{
		System.Console.WriteLine(ex.ToString());
	}
}

Re: Zusi Display with Train Simulator 2015??

Verfasst: 05.12.2014 18:12:57
von F. Schn.
You can update to the current example: https://github.com/FSchn/ZusiTCP.NET/tr ... orksMaster" target="_blank

I've implented a "Clock", to use it you can pass the seconds since midnight or the date formated as "yyyy-MM-ddTHH.mm.ss.FFFFFFF".

Re: Zusi Display with Train Simulator 2015??

Verfasst: 05.12.2014 23:29:45
von gazz
Cool,
i was wary of wanting to change anything on the github files, as i am sort of working these things out for my particular set up, i.e. as i use TrainSim-Helper to get the data out now, there is no need to multiply the speed data as it is done in the TrianSim-Helper LUA, hence the data is in KPH or MPH already depending on if you are driving an English/american train or european train,

As what data is written the text file by the game is governed by the TrainSim-Helpers LUA and .exe files, they will need to be updated too, so far i have only added the Tractive Effort data, but it's not quite right, will not go negative to show dynamic braking effort, so i'm still playing with that bit of data to figure it out.

I'll have a play with the clock too and try and get that working,