• Welcome to MX Bikes Official Forum. Please login or sign up.
 
October 16, 2021, 04:45:24 AM

News:

MX Bikes beta16b 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: May 26, 2021, 12:12:18 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 a parameters string, to start receiving data.
The parameters are set with bits. If the first bit is set, the track centerline and the track position of the bikes are sent.
If the second bit is set, the contacts between bikes are sent. If the third bit is set, then contacts between bikes and walls are sent, too.
So, for example, if the parameters string is "0", no extra data is send. If set to "3", then both the bike contacts and positions are sent.

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
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
Empty string

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

DRIVERSTATUS
State
- DNS
- RET
- DSQ
if state = DSQ
Reason
- JUMPSTART
- TOOMANYOFFENCES
- DIRECTOR
endif
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
for each entry:
Race Number
if the session is practice ( practice, pre-qualify, qualifypractice, warmup )
Best Lap ( milliseconds )
if best lap not zero
Lap Number
Total Laps
Gap ( milliseconds, -- if zero )
Average Speed ( meters/s )
endif
else
Race Time ( milliseconds ) or Status
- DNS
- DSQ
if Race Time not zero
Lap Number
Gap ( milliseconds or L if lapped )
endif
endelse
Bike Status
- TRK: on track
- PIT: in the pits
endfor
Empty string after the last entry

TRACKDATA
Start / Finish Longitudinal Position
Split 1 Longitudinal Position
Split 2 Longitudinal Position
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
Hey ! If you like my work, you can 💰 donate on Paypal, thank you !

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.
Hey ! If you like my work, you can 💰 donate on Paypal, thank you !

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.  ;)
Hey ! If you like my work, you can 💰 donate on Paypal, thank you !

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 custom content
MXB-Mods.com

   📚 MX Bikes User Wiki
MXB-Wiki.com

   💸 Feel free to donate
PayPal

PiBoSo

December 03, 2019, 02:27:20 PM #9 Last Edit: December 03, 2019, 02:33:55 PM by PiBoSo

First post updated to add a parameter to the "START" message, 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