SlotForum banner

Live(ish) race data to any mobile device

9554 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
21 - 40 of 105 Posts
Yep, thats how I used them, AJAX polling the server, JSON response sent back to client and rendered on iPAD they worked really well.
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
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
Ok Ive been thinking about this one. What benefit can an iPhone have over a PC and wall mounted monitor?
Am I going to look at my iPhone while I race? No.
Am I going to look at it after the race....yes. And its handy to have your own copy handy.

Wouldnt it be just as easy to SMS (via PC, multiples at once) or email the results after the meeting so they come up on your iPhone anyway?
Im just trying to weigh up any advantages over the effort.
Rick
The json files are literally a serialization of the entire apps state. That's why I can re-load it later. So yes, everything you could ever need is in there (including every lap counted), but there are two main issues. First, this file is currently only written out as an auto save at the end of the heat. I'm not sure if the older computers used to run races could handle writing those files every time something significant happened and besides it would be more ideal to write something a little cleaner and easier to use. I know at least the EACHORC guys want to see laps updated in some way that they can then graph the current heat progress. With dynamic file updates the php script could very easily do something like that.

I also think there are things that are harder to derive from the data than you'd think. Even something like the heat list is "hard" to derive because you have to understand RC's definition of "round robin" (or whatever rotation you're using). Even just deriving the final standings would be a pain in my opinion. Again you have to understand the intricacies of all the race settings, understand tie breakers, etc...

What you really want is a json format that leaves nothing to chance. Everything is spelled out so all the webserver has to do is pick and chose what data it wants to serve up. I think what we've seen so far is fantastic. The next step is to start thinking about how to apply it and have somebody work with me to do just that. Personally I thought this would be most useful for per driver displays. Maybe you have an ipad at every driver station that is showing relevant information for that driver. Maybe you have a page served up that is a "detail" view for each driver in the race. This detail view gives information like when their next heat is, and other lap information... RC already basically stores every stat possible, so the sky is more or less the limit.

QUOTE (diesel @ 4 Sep 2012, 07:02) <{POST_SNAPBACK}>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.
See less See more
Rick, for me the point of this is much more the real time application. In a very "web friendly" way you can setup screens to display pretty much anything you want. Heck, you could probably have it call or text your smart phone. The point is you're breaking away from the confines of what the application can do and you can basically do whatever you want with out updating the RMS. In the long run I see this as a PC-less system that serves up the race data to the internet. Any PC, Mac, tablet, or smartphone can then display the data any way it wants. If nothing else analog racers would finally have an out of the box one stop solution for a track interface. And the best part would be that if their "device" has a webrowser, it can display the race data.

Of course this same technology can be used to post race results after the fact as well.

QUOTE (injectorman @ 4 Sep 2012, 20:29) <{POST_SNAPBACK}>Ok Ive been thinking about this one. What benefit can an iPhone have over a PC and wall mounted monitor?
Am I going to look at my iPhone while I race? No.
Am I going to look at it after the race....yes. And its handy to have your own copy handy.

Wouldnt it be just as easy to SMS (via PC, multiples at once) or email the results after the meeting so they come up on your iPhone anyway?
Im just trying to weigh up any advantages over the effort.
Rick
See less See more
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

QUOTE (Slingshotx @ 4 Sep 2012, 16: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
See less See more
QUOTE (diesel @ 3 Sep 2012, 13:08) <{POST_SNAPBACK}>.

The minute you think Al's software is race ready then I'll give him a list of my requirements.

We just used it at national level for the first time, instead of Trackmate.
QUOTE (Race Coordinator @ 5 Sep 2012, 11:54) <{POST_SNAPBACK}>Rick, for me the point of this is much more the real time application. In a very "web friendly" way you can setup screens to display pretty much anything you want. Heck, you could probably have it call or text your smart phone. The point is you're breaking away from the confines of what the application can do and you can basically do whatever you want with out updating the RMS. In the long run I see this as a PC-less system that serves up the race data to the internet. Any PC, Mac, tablet, or smartphone can then display the data any way it wants. If nothing else analog racers would finally have an out of the box one stop solution for a track interface. And the best part would be that if their "device" has a webrowser, it can display the race data.

Of course this same technology can be used to post race results after the fact as well.

Wiethout a PC you're going to need a wireless lap counter to send data to the smartphone directly, which doesn't exist yet. For a race meet you will always need a monitor and to run a monitor you need a PC.

Of course you need Internet connection to send email or SMS, if you don't have Internet then I can see a benefit. But that's the benefit I can see so far.

Rick
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
QUOTE 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

Sounds good we should start talking via Email. What I'm hoping we could achieve is the following:-

1 - A very basic system for all users to be able to install and use easily (download from RC site?)
2 - At present post heat data, so when a racer finishes they can review the race.
3 - Commented scripts that will act as an example to help other developers customize their own screens and data.
4 - Have this done within a month or two.

I'll try and knock up some prototype screens but would probably look at something like the following details:-

Results screen showing probably the same info that the current race screen in RC shows. From this hyperlinks to individual driver stats for all heats driven showing the usual stuff such as best/worst/avg lap, position, gap to next etc.

Look at historic data, one of the main drivers for this is if you run heats and finals it's difficult for racers to view heat data to enable them to decide on which lane for the final.

I like the current system, because the script has only 1 file to process for all data, the same script can process historical race data since it's in the same format. Obviously you have pointed out some of the drawbacks with this method.

Things I can't currently work out is:-
1 - Which lane the driver data is pertaining to.
2 - Overall standings, I can make a guess (calculate) but wouldn't know how to decide if position is based on time/points/laps completed and if we need to drop any scores

Anyway on hols at moment so will Email you start of next week.

Cheers

Kevin
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.
Now if I could wear an earplug from my iPhone in one ear and hear my lap times, best lap, pitstop warning or position I might be interested as this is the only info i need so i dont have to look at the monitor. (This is something planned for Scorpius via a wireless ear piece and dongle). That means the app would have to have an ID or the rms issues a code that the user enters into the app so I only get my data and no one else can. This means the RMS would need additional coding. Of course with digital you could simply use your ID number but analogue only has a name.

Whatever data I might get between heats by looking at my iPhone wont help me go faster though, therefore no advantage for me personally unless someone can sell me other reasons I haven't considered yet:) Getting useful info during the race I feel is what is really required.
I agree with most of what you say, live data is not what I was trying to do, i dont want to be watching a live graph instead of the race (or marshalling).

Post heat data I think is useful for a couple of reasons (in my order of importance)
1 - you can look at heat data to help you choose a lane in the final.
2 - for larger club events it's easier to have several devices display the data than have 20 - 30 people crowding around 1 pc.
3 - if you make setup changes or car changes between heats you can easily see what effect they've had.

Seems there are 2 sets of requirements here.

Kevin
.....Every club is different. If we did need to run a final it would be lane rotation as per normal, you don't get a choice. Most clubs now use large wall mounted monitors and between heats we have 60 seconds, no
time for tuning.
But if the results could go directly to my phone at the end of the night that would be very cool.
Kevin

While live lap times in your ear to help understand what is happening and a graphical lapchart to understand what happened would both be nice, speaking purely as an analogue racer where the lane you are in is hugely significant, I think you have identified the most pressing requirements.

Really excited about the project and I guess it will make all the things other people want possible too.

Good stuff
See less See more
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?
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.
QUOTE (marctownsend @ 5 Sep 2012, 12:04) <{POST_SNAPBACK}>Kevin

While live lap times in your ear to help understand what is happening and a graphical lapchart to understand what happened would both be nice, speaking purely as an analogue racer where the lane you are in is hugely significant, I think you have identified the most pressing requirements.

Really excited about the project and I guess it will make all the things other people want possible too.

Good stuff

Bring you phone/laptop/iPad in a couple of weeks time and I'll try and get the prototype running by then.

It's going to cost the club literally nothing to trial I have the hw at home, so well give it a try, if it's of no use to us then we can simply go back to using what we have (which I think is pretty good anyway).

I like the idea of live timing in my ear, but really I think I'd prefer the in race banter we normally have.

See you next week, oh any results from last night?
See less See more
QUOTE (injectorman @ 5 Sep 2012, 11:58) <{POST_SNAPBACK}>.....Every club is different. If we did need to run a final it would be lane rotation as per normal, you don't get a choice.

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?
21 - 40 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