SlotForum banner

Live(ish) race data to any mobile device

9529 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
41 - 60 of 105 Posts
At lots of what is being discussed here goes over my head, but I do think it is better to be ambitious and do as much as possible, and generate as much data as possible - just as with penicillin and elementary particles the applicable uses can come later.

I can testify that data in the ear can be fantastic. I have been coached via radio several times at the 24hr HO race, by the team captain, and found it very helpful. At HONK, where sector timing would be viable, it would be as close to real-time telemetry as we could get. For those who don't want it, simple, don't plug in.

As for data to phones, one has to think about the future. My oldest cousin is comfortable with email but struggles with everything newer, his grandchild does not even have an email address and if it does not come at her via some kind of app on her Android phone it may as well not exist. I'm not saying that this is good or bad, just that we need to be savvy to what is ahead. Again, if there are people who don't see the point of data-to-phone then they don't have to use it.

We have only recently had access to a permanent HO track, so we are still working through the potential of that. 95% of HO tracks ever built here last a day and a half. I have no trouble believeing that some of the guys would love to access all kinds of data for that track. At the moment what data there is has come from the EAHORC spreadsheets, and me going through those sheets to create bespoke ones by driver or by chassis etc. I'm not sure I would want to keep all that up-to-date forever, as I'm self-taught with excel and it all takes an age.

If each driver could access their own profile, with reams of data therein, I'm pretty confident many would do so.
See less See more
QUOTE (montoya1 @ 5 Sep 2012, 21:45) <{POST_SNAPBACK}>Sorry to go off on a tangent, I think we can all handle it, why would you only sometimes need a final, and why would the drivers not get a lane choice?
Its easy. You do a round robin and the guy with the most laps wins. So in essence you are straight into the final. Even with 20 racers that's how most races are run where I am.
Why do drivers get to pick a lane? Don't you rotate between lanes? What if all finalists want the same lane? I've never heard that one before anywhere. There's always one lane faster and everyone knows it so I don't get it. Sorry!
(I'm talking analogue if course)
It is fairly common to have finals where the person who did best in the heats gets first pick. Else why have qualifying? In our races, and again this is common, there are too many of us to do a round robin so in effect you are racing the lanes to start with. In our case your best three lane scores over three minutes is your qualifying score, and then come step-up finals.

With segmented races, another common format, the most common thing is to have qualifying to seed you only, and then all your lanes scores are added together - if you are seeded in group 2 but get more laps than all those in the top group, you beat them. If time is an issue, and some segmented meets have huge fields, there is no seeding, it is done some other way (past results for example), but there are no finals. Round robin you race everyone (right?), so again there is no need for finals.

Obviously your format makes sense to you, but I'd need more detail to comprehend why you follow a type of segmented racing with finals, and why only sometimes. Just as there is (nearly) always a best lane there is usually a turd, and your original description makes it sounds as if the top guy after all the RR stuff could end up in it.
See less See more
Thanks for the explanation
See less See more

I can bring along an iPad an iPod a windows 7 net book a vista laptop and if you think it would be useful I can borrow my Dad's Playbook as well. Neal and Andy both have Android phones so that's a fair few os's and browsers we can play with.
On that subject anybody know why I can't quote posts on my I pad?

Robin beat Mark B by about a foot last night but I know you mean the whole results, sorry don't know who has them.
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'm going to start putting serious thought into this. What I can tell you is that it won't be XML 100% for sure. Right now I'm leaning towards building a webserver into RC that will respond to HTTP Get/Post messages. Any response will have a JSON payload. This will require web designers to poll me for data, but by doing it this way there's no overhead to the software unless somebody actually does poll it. I suspect in the end we'll have a protocol that gets access to virtually everything. We'll start with simple things that make sense on the phone and go from there.

Oh, and for the non-technical, we're essentially turning the RC display into a web page (keeping the current display unchanged of course). This means a lot of things, but one thing it means is that you can do basically anything you want. If you want to play audio when a lap is detected, or when a drivers fastest times happen you can. In the long run, we'll be able to have "detail" pages specific to a driver. Really as long as the protocol we setup allows for the data retrieval any web designer can do anything they want with the data... You can more or less do this now in XAML, but it's cumbersome especially to do something like play audio. And the XAML is only supports windows, which this will clearly support any device with a web browser.

QUOTE (-Sy- @ 5 Sep 2012, 07:26) <{POST_SNAPBACK}>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.
See less See more
That sounds good to this non-technical person.

I assume these ''web pages'' can be generated on a network such as Diesel does now down at the Worthing Club? Even if there is no internet connection?

On another topic, but RC-related, does it support sector timing and speed traps, and one-relay per lane?
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.
I could throw myself into the middle of a JSON vs XML battle, but instead I'll put it this way, 100% for sure, with out a doubt, it's going to be JSON. We'll provide an example php script (hint hint, we've already see the start of it) and we'll support people writing there own. This feature is not intended to be plug and play. It's intended to empower a reasonably technical person to do really powerful things.
Without having any technical background I think it is important that Dave does it his way, and then we will see what others can make of it.

Andrew - if you are going to have a run at this, and it sounds as if you are, perhaps it could have a snappy project name, just as the live timing did?
Ok i'm going to let Slingshotx give you the details of how, because I don't know them
But here are some pics of what he had running at our clubnight this week. It worked a treat, was easy to use and personally was just what I was waiting for.

A new tool in the race box

The overall positions screen

You tap your name to see a personal stats screen

Tap the drivers tab at the top to scroll through everybodys

This was it running on an ipad, people were using other devices including BlackBerrys. Slight issue with Android on the night but I understand that has been resolved.
See less See more
Looks cracking.

How does one go about getting the data onto your phone or device?
Log on to the network

Enter a URL (I think this is changing to a static IP for the benefit of Android users)

Browse it like you do the 1:1 F1 timing
I'm getting a new Android phone on Monday, so the, hem hem, timing is good

Are you limited by range in any way? Can you save the data?
See less See more
Just so people know, what he is doing is available to anybody to do. He's discovered a little bit of techy information about RC's save files and he's taking full advantage of the knowledge. You can literally do anything you want with the data as long as you have somebody technical enough to do it. What he's got is a big of a hack in terms of how he has to access my save files. Now that I've see this in action, I'm working on a protocol that will formalize the support. This is significant only in that it means I'll support it 100%. As it is, I could do a new release and break his scripts. Right now there's nothing I can do about that and the only thing that could be done in that case is to update the scripts. Once I have a build with the protocol in place, people will be able to migrate over to it and know that unless there's a flaw in the protocol, they'll never have to touch their scripts again once its up and running...

For what it's worth, down the road I can see me going away from the XAML file race day screens and using this exact technology to driver screens. This would allow a much scriptable (dynamic) interface than we have now. For example, you'd be able to build your own Sections editor however you like, including editing the lap counts right in the column data. It's really very exciting. I just need the time to get to it.

And well done Slingshot et al... what you have currently is pretty amazing considering how very little I helped. In fact, I don't think I helped at all, so very well done...

See less See more
41 - 60 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.