SlotForum banner

Live(ish) race data to any mobile device

9540 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 - 19 of 105 Posts
You could either take my example and recode in Java or python which will process json and save as csv, or maybe simpler write a VB macro that imports the json output and creates an object.

Not sure about triggers, sounds good in theory, but what lightweight technology would you use? I'm guessing JMS would work but seems a little overkill, using windows sendkey style trigger would work, but you'd want a payload containing the changed data.

Anyway lots of options.

Slingshot
On a local web server, running on the same machine as the race management software, so only accessible from your local network, although if you want provide the data to an external web server for the world to see it would be fairly easy.

I envisage an unencrypted wifi point so anyone in the club room can access data, but no Internet hookup.

Hope that makes sense.
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 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
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
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
I think it unlikely due to the development costs to create multiple platform apps. From a user point of view it's very straight forward, you simply connect your device to a WiFi hotspot and the enter a specific URL exactly how you would browse a web page, once done you can bookmark the web page as you do any other web page and connect directly to the live results.

To make it clear to everyone, once someone techie has set the hardware and software up, all users should be able to simply select a bookmark and load the results into their favorite browser. Even if I'm not around now the system should start and work automatically.

QUOTE Are you limited by range in any way? Can you save the data?

Limited in the same way as any WiFi hotspot i.e. depends on building, hardware, other WiFi spots in the area. But I'd expect our version to work anywhere in the FLBT building (uses my old broken Tiscali broadband router), and probably a far distance outside too. Do you fancy iPad timing screens in the toilets?
See less See more
Hi Deane, you have absolutely nothing to do to either RC or Trackmate. Have a look at post 1 if you have an old wireless router (or your pc is already connected to a wireless network) you should have enough to get it up and running.

If you want the latest scripts to copy into your web server let me know and I'll email them, I probably can't help much with setting up your wifi since there's 100's of different routers you can use, FLBT's is my old tiscali broadband router. Hopefully Marc/Andy were going to produce a video showing it in operation which may make things a little easier.
You aren't connecting it to an ISP so no account required, you will just configure the wireless portion of the router, you will need to enable DHCP. Alternatively google will give you some ideas to try this esp. if your PC has wifi built in http://www.labnol.org/software/wireless-ne...t-router/11494/
QUOTE (montoya1 @ 25 Sep 2012, 12:38) <{POST_SNAPBACK}>Now that we are finally cracking on with using RC at HONK I'm keen to be able to build up driver profiles down there.

By saving the different EAHORC classes as 'races', one would be able to keep data for, say, Open Wheel and Nascar, seperated.

Once that is done it would be very cool to be able to access the performance of every driver on each lane etc, over several meetings.

I know there is a stats tab, but that shows stuff in the current race, right?

Not sure if I've misunderstood this, but I think you can already do what you want by exporting stats as excel. Simply select the race you are interested in and export it. Examples of which are on FLBT web site under the racesheets link at http://www.slingshotx.byethost17.com/RaceSheets-Main.php

We just export the stats and publish to the web, main reason is so that I can take the results home and update the leader boards, but a few racers also find them useful.
QUOTE (montoya1 @ 25 Sep 2012, 15:05) <{POST_SNAPBACK}>Right, but that is only stats for one meeting per sheet.

I'm more talking about stats per driver, across multiple meetings. In your case Marc's (for example) file for rally would show his best lap times/reaction times/scores etc by date
True but you could write some scripts or Excel that will merge multiple sheets together based on your requirments. As Diesel says if Dave produces the raw data, you will still need to manipulate it into the format you want it in.

You may also be able to get the results out in a more usable format if you change the template xls file that is used to export. I think ours was changed by Brian at Mussell Bay to get rid of stuff like car etc. that was of no use to us.

Just some ideas for you to play around with.
Sounds like a good idea, but from Deanes point of view he would still need to manipulate this data to produce his bespoke report (or ask you to produce the report for him?), although in this scenario he would be writting SQL rather than Excel macros.

Guess what I'm trying to make clear is that getting the data out of RC is part of the solution, manipulating that raw data and presenting it in the format a user may want is still going to provide some challenges.
Just an update, the system has been in use for a couple of weeks, Marc had a couple of ideas that make it really usable. First up he's generated some QR codes that mean you simply photo the QR code on your mobile or tablet and it takes you straight to the results page.

He also suggested a way of producing graphs so we have a couple of dynamically generated graphs for each heat showing position throughout the heat, similar to Deans example in a previous post, and a chart showing lap times throughout the heat.

We also have a simple mode for public events so that the system will give simple info when we run with no names, so as long as a racer knows which heat/lane they were in they can view their results and compare them with the best so far.

Currently it's biggest benefit is definitely help when choosing lane for the final. The lap time graph is good to show consistency since any offs appear as spikes. There's a few bugs in it but as a proof of concept it looks pretty reasonable, and for anyone prepared to learn PHP is pretty straight forward to modify.

I'll try and get some images/video posted, if anyone is interested in the latest scripts let me know, if you don't have a wireless setup then you can test it out locally on the same machine as you run RC.

Kevin
See less See more
Yes its in use now, if you mean in use for HO then I don't see how you can use it, EAHORC uses it's own timing system with your own hardware, software and spreadsheets doesn't it?

If you are going to try and get RC and scripts running on your own hardware then you should be able to use our WiFi.

Regards

Kevin
The charts are generated at the end of each heat using some free software called libchart and cached.
libchart is a fairly basic charting package for php. It could be used for realtime but I'm not sure how quick it would be since the chart is saved to a png file which you can then display on a we page.

If it's any help here's a link to it:-

http://naku.dohcrew.com/libchart/pages/introduction/

The other good thing is since it's all done in php you can modify the base classes for your own use.
It was compact, free and using GPL means I can roll it up with my scripts without others having to buy/install extra software. Most the other packages I looked at generated images for display.
After chatting with Dave, I thought id post on here how the liveish system is going.

Well first up its been running flawlessly for the last 3 months, people point their mobile at a backside qr code and it takes them to the current results. Dissapointingly to my knowledge only 1 other club has got the sw running. Weve used it for public events and a national championship round there seems some initial interest, but ultimatley is only of use to 1 or 2 racers.
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!!!!
1 - 19 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