Can anybody get telemetry output available for this game for simtools?
here is example
First, let’s make the game a settings file to hold the Telemetry settings for the game.I’m suggesting a ‘Telemetry.cfg’ file that holds the motion configuration for the game.You may already have a configuration file for the game that you want to put these settings in, this is just an example. (This also gives SimTools a file to patch for motion, and allows the telemetry outputting to be on or off as needed.)The Telemetry.cfg file holds these 4 settings:- Enable_Telemitry = False- IpAddress = 127.0.0.1- Port = 4123- MS_OutputRate = 10I wrote the following example code in VB.net, as its dead simple to read and see what I’m doing.Basically thou, I’m creating a looping background thread that builds and sends the needed output with UDP.Once you have ‘something like’ this code in the game, all you have to do is:Call ‘Start_Telemetry_Output()’ when the game starts up.And ‘Stop_Telemety_Output()’ when the game shuts down.Ok, now some code:Private Telemetry_Sender As New UdpClientPrivate Telemetry_Loop_ms As Integer
Private Telemetry_Running As Boolean = False
Private Telemetry_Thread As Threading.Thread'Starts up the Telemetry Sender.Private Sub Start_Telemetry_Output()
'only startup if not already started. If Telemetry_Running = False Then
'read from Telemtry cfg file. Dim Telemitry_Enabled AsString = "Get Enabled_Telemetry value from the Telemetry.cfg file" Dim IpAddress AsString = "Get IpAddress value from the Telemetry.cfg file" Dim Port AsString = "Get Port value from the Telemetry.cfg file" Dim MS_OutputRate AsString = "Get MS_OutputRate value from the Telemetry.cfg file" If CBool(Telemitry_Enabled) = True Then
Try 'startup a new client.
Telemetry_Sender = New UdpClient
Telemetry_Sender.Connect(IpAddress, CInt(Port))
'set loop speed & start sending data.
Telemetry_Loop_ms = CInt(MS_OutputRate)
Telemetry_Running = True
Telemetry_Thread = New Threading.Thread(AddressOf Telemetry_Loop)
Telemetry_Thread.IsBackground = True
Telemetry_Thread.Start() Catch ex As Exception
'Could not create the UDP sender, no need to do anything.
End Try
End If
End If
End Sub'Send TelemetryPublic Sub SendTelemetry()
Try
'Collect the data. Dim Roll As String = "" Dim Pitch As String = "" Dim Yaw As String = "" Dim RollSpeed As String = "" Dim PitchSpeed As String = "" Dim YawSpeed As String = "" Dim Vertical As String = "" Dim Lateral As String = "" Dim Longitudinal As String = "" 'add anything else you want to add, its easy now!
'Dim Rpm As String = ""
'Dim Speed As String = "" 'check the status to see if the game is being played (In Game, In Menus, Paused). Dim Game_Is_Playing As Boolean = 'Get if the game is being played) 'game is actually being played check. If Game_Is_Playing = True Then
'If game is actually being played (not in menus or paused).
Roll = "Get value from your game" 'in degrees - (-180 to 180)
Pitch = "Get value from your game" 'in degrees - (-180 to 180)
Yaw = "Get value from your game" 'in degrees - (-180 to 180)
RollSpeed = "Get value from your game" 'in (rad/sec)
PitchSpeed = "Get value from your game" 'in (rad/sec)
YawSpeed = "Get value from your game" 'in (rad/sec)
Vertical = "Get value from your game" 'in g's acceleration
Lateral = "Get value from your game" 'in g's acceleration
Longitudinal = "Get value from your game" 'in g's acceleration
Else
'If the game is paused or in the menus. (not actually being played)
Roll = "0" 'in degrees - (-180 to 180)
Pitch = "0" 'in degrees - (-180 to 180)
Yaw = "0" 'in degrees - (-180 to 180)
RollSpeed = "0" 'in (rad/sec)
PitchSpeed = "0" 'in (rad/sec)
YawSpeed = "0" 'in (rad/sec)
Vertical = "0" 'in g's acceleration
Lateral = "0" 'in g's acceleration
Longitudinal = "0" 'in g's acceleration
End If 'Build the output string. (The 'S~' and the '~E' is so the user can see if they have a complete string of inputs) Dim WhatToSend As String = "S~Roll:" & Roll & "Pitch:" & Pitch & ":Yaw:" & Yaw & "RollSpeed:" & RollSpeed & "PitchSpeed:" & PitchSpeed & ":YawSpeed:" & YawSpeed & "Vertical:" & Vertical & ":Lateral:" & Lateral & ":Longitudinal:" & Longitudinal & "~E" 'Send the string Dim bytCommand As Byte() = NewByte() {}
bytCommand = Encoding.UFT8.GetBytes(WhatToSend)
Telemetry_Sender.Send(bytCommand, bytCommand.Length)
Catch ex As Exception
'something went wrong, turn off telemetry output.
Stop_Telemity_Output()
End Try
End Sub'Stop Telemetry OutputPublic Sub Stop_Telemetry_Output()
'only shutdown if already started. If Telemetry_Running = True Then
'turn output off.
Telemetry_Running = False 'let it finish what its doing.
Threading.Thread.Sleep(100) 'Close Client.
Telemetry_Sender.Close()
End If
End Sub'Send Telemetry LoopPrivate Sub Telemetry_Loop()
'Send Telemetry.
SendTelemetry() 'pause till next packet is needed.
Threading.Thread.Sleep(Telemetry_Loop_ms) 'loop again if needed. If Telemetry_Running = True Then
Telemetry_Thread = New Threading.Thread(AddressOf Telemetry_Loop)
Telemetry_Thread.IsBackground = True
Telemetry_Thread.Start()
End If
End Sub
I really don't know how to do this.
if it is too hard to get it worked, sorry for asking :D
kindly forgive me.