SlotForum banner

Live(ish) race data to any mobile device

9538 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
101 - 105 of 105 Posts
So is the data accesible yet to those wanting to run their own external systems?
Sometimes it takes a while for people 'catch on' to how useful a new feature is. Others just aren't so tech savy.

What you guys are doing is great!

Drifter2
3
Mod Note

Guys I have just read this entire thread and it all sounds great I'd love to see it all up and running.

However will you please do me a favour "avoid the quote button"
There is no need at all to quote the post you are following a simple "reply" is all it takes, OK the quote is there and you can use it to relate to posts further up the chain.

Now dare I switch over to the "live" thread or is that going to be the same
I will because I'm really enjoying the subject and I think it could be great for events especially if we could get the data running live on the forum......

See less See more
No I can understand not being able or wanting to setup networks and app servers (this will always be a problem) Marc has spent some time getting it running on his netbook, although most problems seemed to be permission issues on his cut down windows version.

Real surprise is how few people use it when it is setup. Maybe slotcar racers want to race, not look at mobile devices!!!!
I'm seriously going to give this a try, now that I have RC running again in the way I want it too.
There are several techies in the clubs I attend and I think this will go down very well.

I'm also going to try to put together a demo for Slot Rally GB and pilot it at a round in the summer. I can see great benefits here, particularly as every car on every stage has to be transposed from a written time sheet into the Excel master workbook. Hard slog and prone to mistakes.
101 - 105 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