SlotForum banner

Live(ish) race data to any mobile device

9555 Views 104 Replies 11 Participants Last post by  Martyn_
Following on from a discussion on a HO thread (and talking with Dave who produces RC) about people having to crowd round a single screen, I thought it should be trivial to publish the data so that everyone can look at a web page on their iPad, iPhone etc. So it wasn't trivial (and there is someway to go to tidy up the screens) but it only took 3 or 4 hours to get the prototype working with Race Coordinator.

Here's a bad photo of it working, the photo shows a race in progress, while the iPod shows data for all run heats upto that point.

So here's what you need.
A network enabled PC running Race Coordinator
A Lightweight Web Server that is able to run PHP scripts, there are plenty of free ones available I used something called Resin
My prototype php script below.

Edit the couple of lines at the top of the script for the location of your RC files.
Copy the script below called results.php to webapps directory of resin i.e. C:\Program Files\resin-4.0.30\webapps\ROOT
Start a race and browse to http://129.168.?.?:8080/results.php and at the end of every hit if you hit refresh you'll see basic data for all racers.

Couple of things:-
if you can't browse to http://129.168.?.?:8080 then it may be you need to open 8080 on your firewall (especiall Windows 7 users).
Some of the data I've grabbed is wrong.
The data is only updated once a heat has been completed (I don't see this as a problem, you want to checkyour lap times & result after your heat)
It's pretty basic, I'm hoping someone will take on the task of building some nice screens.
If there is no ongoing race it defaults to viewing the most recent race completed.

If people want this functionality then we can tidy it up make it configurable, maybe RC can optionally pubish live data i.e. after every lap for real live race data to your own device (anyone for live callouts into your own headphones of laptime, gap etc?).

It's pretty easy to setup, whilst I'm a software engineer I've never installed a Web Server before or written php, so shouldn't take a genuis to get it working, I'll help where I can.

Let me know what you think.




// Things that may need changing at the top
// This is the RC folder to search for json files, it will vary depending on Windows 7 / xp
// Windows 7 it will be something like C:\ProgramData\Race Coordinator\saves on xp it will be
// C:\Documents and Settings\All Users\Application Data\Race Coordinator
$RCDataDir = findLatestFile("C:/Documents and Settings/All Users/Application Data/Race Coordinator");

// Setup an array of lane colours so each driver can tell what lane they were in rather than a number
$lane = array (1=>"Red", 2=>"Blue", 3=>"Green", 4=>"Yellow");

// Searches for the latest file in a directory
function findLatestFile($dirName)
$lastTime = 0;
$latestFileName = "";
foreach (glob($dirName) as $f)
if (filemtime($f) > $lastTime)
$lastTime = filemtime($f);
$latestFileName = $f;
return $latestFileName;

$latestFile = findLatestFile($RCDataDir . "/saves/*/*.json");

// If we didn't find anything in saves then use the stats and look for the last race completed
if ($latestFile == null)
$latestFile = findLatestFile($RCDataDir . "/stats/*/*.json");

// Load the json file up, and decode it into a PHP object
$Vdata = file_get_contents($latestFile);
$JsonObject = json_decode($Vdata);

// Loop around each driver that has raced
foreach ($JsonObject->config_->driverList_ as &$driver)
print("Driver ".$driver->driver_->name_."

printf("Best Lap %.2f

", $driver->bestLapTime_);
printf("Worst Lap %.2f

", $driver->worstLapTime_);

// Now get each heat the driver has been entered in
$ctr = 0;
foreach ($driver->heats_ as &$heat)
$ctr = $ctr + 1;
$position = $heat->finalPosition_ + 1;

$lane[$ctr] - ");
printf ("Position %s - Laps %d - Avg Lap %.2f - Lap Times ", $position, $heat->finalValue_, $heat->avgLapTime_);

// Now get the time for every lap in this heat
foreach ($heat->lapTimes_ as &$lap)
printf("%.2f, ", $lap);

print ("


See less See more
1 - 11 of 105 Posts
This is something I started to do over a year ago on Android. Unfortunately I had several other projects on the go too and I'm not great at managing multiple projects so it got shelved. My own race management software produced XML race reports which with a style sheet could be adapted for display on any platform that supports web-pages.

Right now I'm working on a series of embedded modules that I hope will make it much easier to have remove sensors on a track and send all the results back to an RMS.

I would suggest modifying the output of the PHP script to be XML with reference to an external style sheet, this keeps the content and presentation seperate and is highly customisable. The XML file just contains data, the style sheet defines how that data is to be displayed, the browser transforms the XML and XLS documents into a presentation.
There are plenty of good graphs around, I've used these recently HTML5 and free:
Yep, thats how I used them, AJAX polling the server, JSON response sent back to client and rendered on iPAD they worked really well.
I would strongly recommend going the XML root as it means the content is unchanged, but the style and format in which the data is presented can be different for each club and each device.
This post is from my iPad to quote, same as pc...wrap up text to quote in [ quote ] and [ / quote ], like so...

QUOTE hello world
I know I keep on banging on about XML, but JSON for those that don't know what it is, its a method for encoding data and objects in Javascript. The downside of using it for this type of thing is that you need some intelligence on the receiving end capable of translating the JSON into something presentable.

Where-as almost all browsers will support and tranlates XML and XSL into a document for you. You create the payload once in XML, and the users could design there own XSL which displays the XML in a form they want.

XML has the added bonus in that its supported by a lot of off the shelf applications such as EXCEL. JSON isn't.

XML isn't just supported on Windows, because its a plain text format it will work on virtually any platform. Android devices use XML extensively.
If you modify the server end to look at the PHP array $_SERVER, specifically the HTTP_USER_AGENT element, then you can deliver content formatted specifically targetted at the device the user is using, so for example if they are using a mobile phone, then you could format the display accordingly.

This is pretty simple stuff on the server, to detect an apple device use:
CODE$strAppleDev = "";
if ( isset($_SERVER) && isset($_SERVER['HTTP_USER_AGENT']) ) {
$aryAppleDevices = array( "iPad", "iPhone", "iPod" );
foreach( $aryAppleDevices as $strDev ) {
if ( stristr($_SERVER['HTTP_USER_AGENT'], $strDev) != false ) {
$strAppleDev = $strDev;

In the above code the variable '$strAppleDev' will be empty if no apple device is detected or one of iPad, iPhone or iPod if present. You can modify the logic to look for other devices easy enough.
See less See more
If you implement a database backend, there is no reason why you can't export from the database into either an CSV or JSON file format.
You might want to consider implementing a layer of abstraction between the end user and the database that your race software is interacting with. This would mean that remote users of the data couldn't take down or handicap the function of the race software. Without this, any third party could effect the performance of the database by asking it to do something requiring lots of CPU time, meaning it wouldn't be available for the race software.
I'm good with HTML, CSS, Javascript and PHP, including XML and XSL. I'd be willing to help out, just need some instruction on what you want.
1 - 11 of 105 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.