SlotForum banner

Live(ish) race data to any mobile device

9552 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.
http://www.slingshotx.byethost17.com/zenph...bupdate.JPG.php

So here's what you need.
A network enabled PC running Race Coordinator http://racecoordinator.net/
A Lightweight Web Server that is able to run PHP scripts, there are plenty of free ones available I used something called Resin http://www.caucho.com/download/resin-4.0.30.zip
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.

CODE

Results

<?php

// 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;
print("

$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 - 20 of 105 Posts
Sounds cool. I wasn't aware you could get at the raw data in RC that easily and was cursing at the lack of easy exporting.

This should be quite straigtforward to get running with my existing Scoreboard software. I would just need to convert this data to the CSV format I require. I will need to invesitgate.
Currently at WHO the data is exported from Excel into this:

http://www.slotforum.com/forums/index.php?...st&p=623089

and then uploaded as an XML file to this:

www.whoracing.org.uk/racelive/

I'd still love RC to expose lap triggers so that you could generate real-time lap graphs. It would be so easy for Dave to do but he doesn't see the demand unfortunately.
See less See more
Not looking for anything fancy for lap triggers. All RC would need to do is output a data string that resets at the start of each heat. Could be as simple as a reg key where everytime a lap is triggered the lane number is appended to the string value. You'd end up with something like 12433214312 which any third party program could poll and know which lanes where triggered in which order.
I'm happy to work with anyone Deane, but what I'm trying to do is pretty much the last link in the race control line. If the writers of the timing systems make their data available then I can work with it. Dave didn't seem too fussed when I emailed him with my requirements (I guess as I was the only person asking for them), so there's little I can do unless other people contact him and say wouldn't it be great if third parties could access your data... Reading the RC json files seems a bit of a bodge, as I think Dave is just using them for temporary internal use. Cool that slingshotx has noticed them and run with it, but as it is, they could vanish/move/reformat in the next version and leave all our work broken. They also don't contain all the info I'd like, especially who's racing now/next which is a big disadvantage over the current Excel system.

The minute you think Al's software is race ready then I'll give him a list of my requirements. There's no point me working on anything until we hit that stage.

For anyone building a timing system
, in an ideal world this is what I'd like:

1. All previous heat/driver/lane/score details - To show race results, best laps/times and predict final places
2. Current/future heat/driver/lane details - To keep people aware of who's up now and next
3. Current race lane trigger sequence - To provide real time race positioning and graphs
See less See more
I think the json files provide all the historic data that is currently needed. Are leaderboards required to be generated? Surely this is all just dervied data and better compiled outside of RC? So long as the race data is updated after every heat then that will do nicely.

Heat rotation details would be essential. At the moment we could only remotely see what has happened. Being able to show who's racing now/next in what lane is so useful. This info would need exporting after every change, but that wouldn't be too often.

I still love the idea of logging every lap so that pseudo-realtime race detail/lap graphs could be generated. Of course if you wanted to go to town you could add lap times to this too.
QUOTE (montoya1 @ 4 Sep 2012, 12:17) <{POST_SNAPBACK}>Andrew - I'm just looking at this from and end-user's point of view, so a lot of technical stuff goes over my head.

But I do know, from that point of view, that the current RC leaderboard is one of it's very best features. This updates every time a car crosses the line, and when you get down to the last few heats that is awesome to watch. On a big screen at HONK I think it will be something else.

If Dave could export the lap triggers, then a leaderboard could be generated from this, as well as lap graphs.
See less See more
I remember them from an F1 mag when I was a kid. Couldn't tell you the name though.

Generating those graphs in real time for every heat on a big screen would be cool. I've done it with dummy data.
QUOTE (-Sy- @ 4 Sep 2012, 18:18) <{POST_SNAPBACK}>There are plenty of good graphs around, I've used these recently HTML5 and free:
http://www.humblesoftware.com/envision/demos/realtime

I looked into the feasibility of real(ish) time graphs on web pages a while back. Something like this and a bit a ajax polling can do a pretty good job.
QUOTE (Slingshotx @ 4 Sep 2012, 20:55) <{POST_SNAPBACK}>Just been away for a few days too catch up some good ideas here, but ideas are easy implementation is difficult. I think with Daves help I can get at all data RC holds (as Dave said it's all in the json files) proccessing json is quick and easy, I believe the only thing needed would be to add configurable write periods, anything can then poll the file.

Let's keep it simple I've seen to many projects fail due to trying to fulfill too many requirements. Some peopl maybe need to look at their requirements and if they can change the way they race rather than make the software be what they want.

Kevin

What?

By your admission in post 1 you've spent 4 hours looking at your solution.

If you take a look at the links in post 2 you'll see my system has been being used at my local club since June 2011. That adds up to a year and a half of development. These are not grand designs, pipe dreams or unatainable wishlists being discussed. RC's current json files do not cover everything I am pulling and using from our current Excel based system. If RC exported the minimum data I need it would be trivial to swap my system over to parse that data. The thought that RC could export more than I currently get to make our systems truly exciting is not something to be dismissed because you feel it's a bit ambitious!
See less See more
QUOTE (Race Coordinator @ 5 Sep 2012, 02:08) <{POST_SNAPBACK}>Kevin,

If you're interested I'll work on this with you. I think in the long run the best thing to do is to NOT use the auto save files like you're doing. For one thing they could change every single release. For another there's just too much junk in them.

Really we want to keep the json file(s) really simple and let your php scripts do all the work. I'm thinking I would generate a json object for everything we're trying to accomplish. One for a heat list, one for the on deck list, one for heat laps, one for race laps, one for heat standings, one for overall standings, one for anything else we find we need/want. Once the format of the json object is figured out your script just needs to find the latest files and present the data...

Anyway those are my initial thoughts, I pretty up the data with out losing any needed information and to minimize the amount of data written real time, and the php script manipulates it. If we do something like this we shouldn't do it on the forums... I much more interested in hearing what features people want here, and then working offline with people implementing them on the details.

-Dave

This probably the most exciting post I've seen on here! Can't wait.

On the subject of heat rotations and you saying they are difficult, I can appreciate without a crystal ball it's impossible to know who's running in what future heats. All I'm really interested on the heat front is who's running now and next - so drivers can easily tell where they should be or prepare for their heat. That's the one bit of info currently not available to a third party. Does anyone else need more? I guess this can be provided from RC pretty easily.
See less See more
Would it be better for Dave to start working on the data export side, so that all interested parties can take a look and see if it meets their needs in what it contains/parsing? Waiting for prototype screens from one app doesn't help the rest of us who only need the data.
I thinnk every club has different requirements. What some consider pointless can be very useful.

Live graphs? What about people visiting and not racing/marshalling or people following at home because they can't be there?

Leaderboards? Ours acts like a water cooler, especially for the younger racers. Lots of tactical talk takes place here!

That why I think it's important for Dave to sort out export format for the data he has, instead of working backwards to fit any one person's specific needs. That's also why it's important to expose as much data as possible.

Would XML suit everyone as a suitable output format to work with?
Once there's a means to officially export/access the data then it can be archived and accessed any way you like for analysis Deane.
Once the export format is sorted then my plan at least is to access the data as the race happens to update scoreboards and web. If this is being done then all the data is already there and can be stuck straight in a season database. There shouldn't be any need to export excel files.
I only really see a database being used for accessing historical stats on the website, so there would be no direct connection with RC on race nights, other than writing to the db with the latest stats. Nothing that would impact on RCs performance.
Nice!

They are exactly the sort of graphs I want to do, but in real time during a race, rather than historically. Interesting showing the 'off' spikes. I guess with a bit of statistical juggling it would be possible to discard the extreme laps and provide a hypothetical 'what if I didn't crash' score.
I'm looking at doing it more on a big screen. Written software that will draw the graphs already in VB.Net, but just need to get at that live data. Works a treat as a demo.

There seems to be quite few libraries for actually drawing graphs on the web. Is there any particular reason you went the image generation route?
1 - 20 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.
Top