Slot Cars Forum banner

1 - 20 of 105 Posts

·
Registered
Joined
·
538 Posts
Discussion Starter · #1 ·
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 ("

-----------------

");
}
?>
 

·
Registered
Joined
·
550 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.
 

·
Registered
Joined
·
538 Posts
Discussion Starter · #3 ·
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
 

·
Registered
Joined
·
550 Posts
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.
 

·
Registered
Joined
·
538 Posts
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.
 

·
WRP World Champ 2015/2016
Joined
·
4,278 Posts
Perfect sense and exactly what I would have to do - zero mobile signal and no internet in our clubhouse.

Was thinking I'd need to dig out one of the old BT Homehubs I've got knocking about to connect the race system Pc to the mobiles.

Just making a rod for my own back! thanks for the inspiration.
 

·
Registered
Joined
·
9,719 Posts
Guys, a lot of this goes over my head, but it does highlight something I have half-joked about before.

OK, locking all the HO guys good at this stuff in a room would be extreme, but it would be great if Al, Andrew and slotx could actively work together, perhaps with Dave from Race Coordinator - because the end result could be something truly amazing.

Each of you has a lot to offer, but perhaps not the time or comprehensive knowledge needed alone. But in a pool?......
 

·
Registered
Joined
·
550 Posts
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
 

·
Premium Member
Joined
·
1,626 Posts
First off I have to say I think where this is going is the future of RMS development. It's a "headless" management system in which any third party can simply write whatever display they want. I wanted to do something like this right out of the gate but decided there weren't going to be enough people interested in this to justify the fairly large development cost. Now that things are VERY stable for RC, this is a good time to start thinking about it again.

So far, Slingshot has done something that in my opinion is very clever. He's accessed RC's auto save file format and realized that although its a bit cumbersome, it's actually a very easy format to parse. There are off the shelf libraries to do so and when he calls "json_decode" that's what he's doing. From there he just needs to know what is what. That's where I can help tremendously since it's my data he's parsing. The other clever thing he's done is to find and use the newest .json file he finds. What this means is that you can actually save the race at anytime to get the data out. I'm not sure if he realizes it or not, but he has access to every single stat the RMS tracks up to the moment the auto save (or manual save occurs).

To take this to the next level, what we need to do is identify the minimum set of data that would be useful and then sort it by static vs. dynamic data. So for example, RC could very easily write out a "heat rotation" file. Now anybody that wants it can display the heats any way they want. We could do something similar, automatically every time a lap occurred, or every time a second of time went by. We can write out the leader board information as it changes as well... Whatever. The hard part is figuring out what to write out and when it's useful to do so. I'd be more than happy to work with somebody on this, but it's not enough for me to write the data out. Somebody has to really go to town with the php scripts and demonstrate this features power.

For those of you who have emailed me in the past, you probably know that I'm happy to help. It just takes a few conditions to be met for me to get involved. First, I have to deem it valuable to my entire RC user base. Second I have to deem it worth the effort. If I got 1000 requests to do a mac version I still wouldn't because of the effort, but if I get simple enough requests that benefit the software, even if just a few people request it, I'm happy to donate my time. This particular feature is cool enough that as long as people work with me to do it right, I'll throw down. But I'd need to see the end results. Otherwise it's just more code I have to maintain which in the end just makes my life harder.

-Dave
 

·
Simon Platten
Joined
·
1,060 Posts
This is something I started to do over a year ago on Android. Unfortunately I had several other projects on the go too and I'm not great at managing multiple projects so it got shelved. My own race management software produced XML race reports which with a style sheet could be adapted for display on any platform that supports web-pages.

Right now I'm working on a series of embedded modules that I hope will make it much easier to have remove sensors on a track and send all the results back to an RMS.

I would suggest modifying the output of the PHP script to be XML with reference to an external style sheet, this keeps the content and presentation seperate and is highly customisable. The XML file just contains data, the style sheet defines how that data is to be displayed, the browser transforms the XML and XLS documents into a presentation.
 

·
Registered
Joined
·
9,719 Posts
Dave - that is just the response I was hoping for, the bits I can understand anyway


We finally have a copy of RC installed where it will remain set-up all the time, as part of the huge track down in Kent, so as soon as possible we will be using it. Right now we are looking at live starts, so I'm trying to remember how RC applies them. Does it support one relay per lane for example?

In terms of the HONK room:



What we would love to be able to have is a small screen directly in front of the drivers with just the start lights showing. If we do go to live starts then this could even be placed right by the start line, which is directly below the rostrum and a little to the right. Why small? So far we place traditional monitors where we need them, but their size means we can't always do that exactly where we would like and/or end up blocking the view of part of the track.

To continue the HONK bucket list we would want two large monitors on the back wall, where the union flag is in the picture, one showing the race in progress, one showing the overall leaderboard. Further screens would be cool, but we are already up against the practical limit of what we can do with cables and extended desktops, which is why marrying what Diesel does to Race Coordinator would be so awesome for us.

If the data could also be sent to people phones and laptops etc, that too would be fantastic. From a purely selfish point of view I would love not to have to upload results to, and update points tables on, the EAHORC website. To go home and see all that has been done would be very nice.

Whilst we are throwing everything out there, a speed trap and sector timing would be brilliant, if the data can be gathered and added to the other data for each driver. The end result of all this would be a fully immersive experience for those who want it to be, but non-invasive for those who are not fussed by such things.

Diesel - That is your picture above, I hope you don't mind me using it?
 

·
Registered
Joined
·
9,719 Posts
QUOTE (-Sy- @ 4 Sep 2012, 07:42) <{POST_SNAPBACK}>Unfortunately I had several other projects on the go too and I'm not great at managing multiple projects so it got shelved.

This is something the prevalence of which I have only recently come to comprehend. It seems to be a DNA thing, people who have the talent for stuff the rest of us have no idea about and the imagination to envisage really cool ways to use said stuff also seem to be unable to think in a linear way and focus accordingly.

It is not universal, but it is common.

One sees this all the time with resin casters in HO. Really mad skills, passion for a body which fades, a messy work area covered in started projects, and so on. End result? Two finished masters per year. If you are lucky.
 

·
Registered
Joined
·
550 Posts
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.
 

·
Registered
Joined
·
9,719 Posts
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.
 

·
Registered
Joined
·
550 Posts
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.
 

·
Registered
Joined
·
9,719 Posts
The graphs would be of interest to me as well.

In the 80s I used to love the ones published in Grand Prix International (remember that?), with sparkplug graphics and whatnot.

I did once create this:



From the Trackmate laptime data, using a online graph maker and some photoshop touches. It took way too long to make a habit of it though
 
1 - 20 of 105 Posts
Top