• Welcome, Guest. Please login.
 
October 03, 2024, 06:57:21 PM

News:

MX Bikes beta19 available! :)


Live Timing

Started by PiBoSo, October 04, 2014, 10:46:03 AM

Previous topic - Next topic

PiBoSo

October 04, 2014, 10:46:03 AM Last Edit: August 23, 2023, 11:52:37 AM by PiBoSo
It is possible to connect to a dedicated server to receive live race data.
The feature is off by default and must be enabled:
http://forum.mx-bikes.com/index.php?topic=197.0
Only 1 client can connect to the server.

Communication is made with UDP sockets and strings terminated with "\n".

Send "CONNECT" followed by the connection password ( empty string if no password ).
Reply:
OK -> connected
FULL -> another client is already connected
WRONGPASSWORD -> wrong password

Send "START", followed by two parameter strings to start receiving data.
First parameter: "0" or "1". If set to "1", the track centerline and the track position of the bikes are sent, too.
Second Parameter: "0", "1" or "2". If set to "1", contacts between bikes are sent. If set to "2", then contacts with walls are sent, too.

Data format is "MSG" followed by the message ID and then a stream of strings.
Send "ACK" followed by the message ID after each MSG.

Send "KEEPALIVE" every 15 seconds to keep the connection active.
The server sends "ALIVE" to report that the connection is active.

Send "DISCONNECT" to correctly close the connection.

Example source code can be downloaded at this link: http://www.kartracing-pro.com/downloads/livetiming.c


Messages data format

EVENT
Type
- OPENPRACTICE
- RACE
- STRAIGHTRHYTHM
Name
Track
Track Length ( meters )
Allowed Categories and Bikes
Empty string

ENTRY
Race Number
Name
Bike Name
Bike Short Name
Categories
GUID
Extra Data
Empty string

ENTRYREMOVE
Race Number
Empty string

Open Practice:
SESSION
Session
- WAITING
- OPENPRACTICE
State
Length
Empty string

Race:
SESSION
Session
- WAITING
- PRACTICE
- PRE-QUALIFY
- QUALIFYPRACTICE
- QUALIFY
- WARMUP
- RACE1
- RACE2
State
if session = practice ( PRACTICE, PRE-QUALIFY, QUALIFYPRACTICE, WARMUP )
- INPROGRESS
- COMPLETE
else if session = race ( QUALIFY, RACE1, RACE2 )
- SIGHTINGLAP
- PRESTART
- STARTSEQUENCE
- INPROGRESS
- RACEOVER
- COMPLETE
endif
Length ( minutes if practice, minutes + laps or L laps if race )
Empty string

WEATHER
Conditions
- CLEAR
- CLOUDY
- RAINY
Air Temperature
Empty string

DRIVERSTATUS
Race Number
State
- DNS
- RET
- DSQ
Reason ( empty if state is not DSQ )
- JUMPSTART
- TOOMANYOFFENCES
- DIRECTOR
Empty string

BESTLAP
Race Number
Session Time ( milliseconds )
Lap Time ( milliseconds )
Lap Number
Split 1 ( milliseconds )
Split 2 ( milliseconds )
Average Speed ( meters/s )
Empty string

LASTLAP
Race Number
Session Time ( milliseconds )
Lap Time ( milliseconds )
Lap Number
Split 1 ( milliseconds )
Split 2 ( milliseconds )
Average Speed ( meters/s )
Empty string

PENALTY
Race Number
Penalty Number
Type
- TIME
Penalty Time ( seconds )
Offence
- JUMPSTART
- CUTTING
Empty string

LAP
Race Number
Lap Invalid
Session Time ( milliseconds )
Lap Time ( milliseconds )
Split 1 ( milliseconds )
Split 2 ( milliseconds )
Average Speed ( meters/s )
Empty string

SPLIT
Race Number
Split Number
Split Time ( milliseconds )
Empty string

HOLESHOT
Race Number
Holeshot Time ( milliseconds )
Empty string

CLASSIFICATION
Session
Status
Session Timer ( milliseconds )
Session Length ( minutes )
Session Lap
Number of Laps
Classification Type ( 0 -> none; 1 -> practice; 2 -> race )
if "Classification Type" is 1 or 2
Start Entry
Number of Entries
for each entry:
Race Number
if "Classification Type" is 1
Best Lap ( milliseconds )
Lap Number
Total Laps
Gap ( milliseconds, -- if zero )
Average Speed ( meters/s )
else
Race Time ( milliseconds ) or Status
- DNS
- DSQ
Lap Number
Gap ( milliseconds or L if lapped )
endelse
Bike Status
- TRK: on track
- PIT: in the pits
endfor
endif
Empty string after the last entry

TRACKDATA
Start / Finish Longitudinal Position
Split 1 Longitudinal Position
Split 2 Longitudinal Position
Holeshot Longitudinal Position ( -1 if missing )
Number of Segments
Empty string

Always sent after TRACKDATA:
TRACKSEGMENT
Segment Number
Type ( 0 = straight, 1 = curve )
Length ( meters )
Radius ( meters )
Angle ( degrees )
Start Position X ( meters )
Start Position z ( meters )
Height ( meters )
Empty string

TRACKPOSITION
for each entry on track:
Race Number
Position X ( meters )
Position Y ( meters )
Position Z ( meters )
endfor
Empty string after the last entry

CONTACT
Time ( milliseconds )
Race Number 1 ( -1 for a wall )
Race Number 2 ( -1 for a wall )
Relative Impact Velocity ( meters/s )
Empty string

END
Empty string

Niko Mouk

This is a bit blur,
Do you have an exemple somewhere to allow me doing something like I did here : MXS LiveTiming
Owner of MyMXB and MXBikes-Shop

PizzaChet

March 16, 2016, 05:49:41 PM #2 Last Edit: March 16, 2016, 07:33:04 PM by PizzaChet
Speaking of timing, I ran a bunch of laps online on Holjes on the SM bike and I don't see my time up there. I've done several sessions, some alone. I do see my times for Forest and Practice Track Short however.
Quote from: YodaIf no mistake have you made, yet losing you are ... a different game you should play.

Steven

Quote from: Niko Mouk on March 16, 2016, 01:57:16 PM
This is a bit blur,
Do you have an exemple somewhere to allow me doing something like I did here : MXS LiveTiming

Could you be a bit more specific? I just started trying around with this, maybe I can help.
What have you tried so far? And what did you have to do to get your site to work with MXS? (By the way your link doesn't work as it is.)

Niko Mouk

Yep I inverted 2 letters, it's http://mxs-concept.com/livetiming/

I don't understand the way you can receive, for my livetiming on mxsimulator I think the strategy is totally different, the game server is writting a text file with all info as they come (rider 2 pass the second checkpoint for exemple) and I'm reading into that file.
Next at the end of the race a command send this file where I want to decode it and display championship results ie.
Owner of MyMXB and MXBikes-Shop

Steven

Ah ok, here you have to connect to the server that sends the information (track, players, split times and so on) to you. UDP is used for that.
I don't know about your "qualifications". Are you just looking for some example code or how to do it at all?

Niko Mouk

Maybe I have to understand if it will needed or not for the races and championships we will do. At the moment I think I'll focus myself on track making as the game is a bit poor at this level.  ;)
Owner of MyMXB and MXBikes-Shop

Umpossible

Can anybody help me with this? I'm looking to get live timing off of the Weekend Warriors FLCS2 server. Preferably, if it's possible I would love to be able to connect and download all the information from the server over the past week that it's been running but I doubt that's possible, or i could say that it's probably umpossible haha. 

iNsane

June 25, 2018, 01:26:42 PM #8 Last Edit: June 25, 2018, 01:31:01 PM by iNsane
Quote from: Umpossible on June 25, 2018, 12:26:14 PM
Can anybody help me with this? I'm looking to get live timing off of the Weekend Warriors FLCS2 server. Preferably, if it's possible I would love to be able to connect and download all the information from the server over the past week that it's been running but I doubt that's possible, or i could say that it's probably umpossible haha.

well I didn't even enabled live in my server config file tbh., never saw a reasonable point behind that

Edit // enabled it now but I can't even connect to the port i defined there, dunno


   🌐 MX Bikes Mods
MXB-Mods.com

   🌐 GP Bikes Mods
GPB-Mods.com

   💸 Feel free to donate
PayPal

PiBoSo

December 03, 2019, 02:27:20 PM #9 Last Edit: January 05, 2022, 11:01:34 PM by PiBoSo
First post updated to add a parameter to the "START" command, that allows to receive the track centerline and bikes' track position, too.

PiBoSo

First post updated to add the messages data format.

MxWayGamer

Thanks for the new informations about blocs.
Could you add Empty string after every blocs ? It will be easier to process them.
Owner of Mxb-servers.com

PiBoSo

Quote from: MxWayGamer on September 14, 2020, 10:17:56 AMThanks for the new informations about blocs.
Could you add Empty string after every blocs ? It will be easier to process them.

Thank you for the suggestion.
Empty strings will be added in the next MX Bikes update.

MxWayGamer

Quote from: PiBoSo on September 14, 2020, 10:57:53 AMThank you for the suggestion.
Empty strings will be added in the next MX Bikes update.

Thanks ! It will be clearer than testing every line if it's bloc names to know if it's new bloc or not.
Owner of Mxb-servers.com

MxWayGamer

Is it possible to add session informations (Number of lap and Duration) in the live timing bloc ?

Example :
SESSIONSETUP
Number of lap
Duration
Owner of Mxb-servers.com