Elvas Tower: OpenRails TCS - Elvas Tower

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

OpenRails TCS TCS by external Software? Rate Topic: -----

#1 User is offline   Citarofahrer 

  • Apprentice
  • Group: Status: Dispatcher
  • Posts: 29
  • Joined: 14-July 14
  • Gender:Male
  • Simulator:MSTS, OR
  • Country:

Posted 23 December 2018 - 09:21 AM

Hi guys

i am actually developing a Software witch simulates the ETCS Display of a modern Siemens Loco (ETCS DMI by Siemens). As far i can read the speed and ingame time and visualize it on my vb.net Application.

But for ETCS Level 2 (witch i want to implement it) and other TCS i would need some more functtions to read out the game.

for example the Pre-Signal State. I actually get the Mainsignal State (Stop; Apporach etc). Then i need a way to write into the game if the external TCS have to brake into the Game (Emergencybrake by TCS).
Actually i can't upload the .cs Scriptfile so i post the code into the message:

// COPYRIGHT 2014 by the Open Rails project.
// 
// This file is part of Open Rails.
// 
// Open Rails 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.
// 
// Open Rails 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 Open Rails.  If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using ORTS.Common;
using ORTS.Scripting;
using ORTS.Scripting.Api;
using System.IO;
using System.Text;
using System.Runtime.InteropServices;

namespace ORTS.Scripting.Script
{

    public class ORTSZs : TrainControlSystem
    {
	
        private DateTime NextUpdate = DateTime.Now;
		
        [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
        static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

        [DllImport("user32.dll", SetLastError = true)]
        static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
        struct COPYDATASTRUCT
        {
            public uint dwData;
            public int cbData;
            public IntPtr lpData;
        }

        public static uint WM_COPYDATA = 74;

        public override void Initialize()
        {
			
        }
		

        public override void Update()
        {
			
			if (NextUpdate <= DateTime.Now) {
				string text = SpeedMpS() + ";" + ClockTime() + ";" + NextSignalAspect(0) + ";" + NextSignalAspect(1) + ";" + NextSignalAspect(2) + ";" + NextSignalAspect(3) + ";" + NextSignalAspect(4) + ";" + NextSignalDistanceM(0) + ";" + NextSignalDistanceM(1) + ";" + NextSignalDistanceM(2) + ";" + NextSignalDistanceM(3) + ";" + NextSignalDistanceM(4) + ";" + NextSignalSpeedLimitMpS(0) + ";" + NextSignalSpeedLimitMpS(1) + ";" + NextSignalSpeedLimitMpS(2) + ";" + NextSignalSpeedLimitMpS(3) + ";" + NextSignalSpeedLimitMpS(4) + ";" + NextPostDistanceM(0) + ";" + NextPostDistanceM(1) + ";" + NextPostDistanceM(2) + ";" + NextPostDistanceM(3) + ";" + NextPostDistanceM(4) + ";" + NextPostSpeedLimitMpS(0) + ";" + NextPostSpeedLimitMpS(1) + ";" + NextPostSpeedLimitMpS(2) + ";" + NextPostSpeedLimitMpS(3) + ";" + NextPostSpeedLimitMpS(4) + ";" + CurrentSignalSpeedLimitMpS() + ";" + CurrentPostSpeedLimitMpS();
				
				//Message(Orts.Simulation.ConfirmLevel.MSG, "Mööp");
				
				IntPtr windowHandle = FindWindow(null, "ORTSZs Settings");

				COPYDATASTRUCT cd = new COPYDATASTRUCT();
				cd.dwData = 2;

				cd.cbData = text.Length + 1;
				cd.lpData = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(text);

				IntPtr cdBuffer = System.Runtime.InteropServices.Marshal.AllocHGlobal(System.Runtime.InteropServices.Marshal.SizeOf(cd));
				System.Runtime.InteropServices.Marshal.StructureToPtr(cd, cdBuffer, false);

				SendMessage(windowHandle, WM_COPYDATA, IntPtr.Zero, cdBuffer);
				
				
				System.Runtime.InteropServices.Marshal.FreeHGlobal(cdBuffer);

				NextUpdate = DateTime.Now.AddMilliseconds(250);
			}
        }
		
		public override void SetEmergency(bool emergency)
        {
            
		}
		
		public override void HandleEvent(TCSEvent evt, string message)
		{
			
		}
    }

}

Attached thumbnail(s)

  • Attached Image: WhatsApp Image 2018-12-18 at 07.13.25.jpeg


#2 User is offline   Citarofahrer 

  • Apprentice
  • Group: Status: Dispatcher
  • Posts: 29
  • Joined: 14-July 14
  • Gender:Male
  • Simulator:MSTS, OR
  • Country:

Posted 25 January 2019 - 10:02 PM

As i created the TCS by External Software here is a little Preview:

https://youtu.be/euFwPJn7Hew

#3 User is offline   Aldarion 

  • Engineer
  • PipPipPipPipPip
  • Group: ET Owner
  • Posts: 619
  • Joined: 11-February 13
  • Gender:Male
  • Location:Lisbon, Portugal
  • Simulator:Open Rails
  • Country:

Posted 09 February 2019 - 07:40 AM

Wow. looks nice.

A little off topic but since you seem confortable at scripting (wich I am not) can you tell me if the following is possible:

There was one locomotive in a series of electric locos that had a defect in the tachografer, allowing it to run at about 8kph above the actual speed limit (her top speed was 160kph and it could run at 168 without triggering the overspeed alarm). Is this possible to implement?

#4 User is offline   Citarofahrer 

  • Apprentice
  • Group: Status: Dispatcher
  • Posts: 29
  • Joined: 14-July 14
  • Gender:Male
  • Simulator:MSTS, OR
  • Country:

Posted 10 October 2019 - 10:50 AM

Hi, long time ago since the lst Update but here is a little ETCS Preview:

https://www.youtube....LPyx5EcM&t=165s

#5 User is offline   Stijn D.C. 

  • Engineer
  • Group: Status: Contributing Member
  • Posts: 515
  • Joined: 20-August 16
  • Gender:Male
  • Simulator:Open Rails
  • Country:

Posted 12 October 2019 - 06:17 AM

It wil be nice must you can add this in cabview, for moment there is a ETCS gauche:

Attached Image: ETCS-GAUCHE.jpg


I have ES64U4 cabview too, with some mods of me too, like you see. And with the ORTS ETCS gauche.

This gauche moves not with that typical ETCS/TELOC interval, like you have.

#6 User is offline   Howky 

  • Fireman
  • Group: Status: Active Member
  • Posts: 247
  • Joined: 14-February 13
  • Gender:Male
  • Location:Czech Republic
  • Simulator:Open Rails
  • Country:

Posted 12 October 2019 - 07:23 AM

You couldn't write a little more than you joined TCS on Open Rails?

#7 User is offline   Citarofahrer 

  • Apprentice
  • Group: Status: Dispatcher
  • Posts: 29
  • Joined: 14-July 14
  • Gender:Male
  • Simulator:MSTS, OR
  • Country:

Posted 12 October 2019 - 03:37 PM

What you wanna know? It's writen in vb.net and actually implementet is ETCS L2, ZUB262ct and Euro-Signum. Next Step's are PZB and LZB. After that ETCS Level 1 LS (Swiss Type). If you have any Questions just ask ^^ I'll try to explain more Functions in with Youtube Videos ;)

#8 User is offline   Howky 

  • Fireman
  • Group: Status: Active Member
  • Posts: 247
  • Joined: 14-February 13
  • Gender:Male
  • Location:Czech Republic
  • Simulator:Open Rails
  • Country:

Posted 12 October 2019 - 10:47 PM

How does communication between your program and Open Rails work?

How you get data.

#9 User is offline   Citarofahrer 

  • Apprentice
  • Group: Status: Dispatcher
  • Posts: 29
  • Joined: 14-July 14
  • Gender:Male
  • Simulator:MSTS, OR
  • Country:

Posted 15 October 2019 - 04:25 AM

With the ORTS Scripting API for TCS. VB.net get the Data with the modifiede .cs file in the first Post.

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users