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 ("
-----------------
");
}
?>