Re: Live Train Departure Boards for the UK

The data source for this widget has changed, so the widget is currently offline. I will hopefully find time to bring it back online "soon".

Thanks for your patience.

Re: Live Train Departure Boards for the UK

Good luck - this has been a great widget so I hope you are able to get it working again soon.  I've done a little bit of yahoo piping in my time so if there's anything I could do to help, let me know.

Re: Live Train Departure Boards for the UK

The new version will be completely self sufficient, I think. No need for pipes any more after the data source rejig

Re: Live Train Departure Boards for the UK

Sorry to be a nuisance - just wondered when the new version is likely to be available?  The 'Under Construction' notice is depressing me! smile

30 (edited by gingerbeardman 2010-09-16 00:10:11)

Re: Live Train Departure Boards for the UK

Sorry, I am too busy with paid work at the moment to rebuild this widget. I don't catch the train any more myself since moving out of London.

For the record, I've only had one donation from one chumby user for this widget. That's the grand total of all donations to aid chumby development.

Cheers,
matt

Re: Live Train Departure Boards for the UK

Fair enough - perhaps you could indicate what level of donation would enable this do be done?  Feel free to PM me if this isn't appropriate for public consumption.

Re: Live Train Departure Boards for the UK

Let me have a think on that.

Re: Live Train Departure Boards for the UK

Thanks.

Alternatively, I was checking out how the boards work these days - I can see it's changed and here's an example of how it looks for my station departures

http://ojp.nationalrail.co.uk/en/s/ldb/ … Id=&f=

Could I write a new pipe that converted this in to the same format that the old one produced, so you wouldn't need to do anything beyond update the pipe URL?

34 (edited by gingerbeardman 2010-09-16 07:36:50)

Re: Live Train Departure Boards for the UK

Sure, if you wanted to do so.

I was intending to rewrite the widget to do away with the pipe and parse the JSON (shown in your link) in the widget itself. That seemed a much more future proof way to do it. And it would run quicker on the chumby, I think.

I used to give the old page to the pipe using Google App Engine, which also needs to be taken out of the equation.

If you'd like to help, then perhaps write some actionscript to parse the JSON and I can easily and quickly include that in the widget.

eg.
http://manishjethani.com/blog/2008/08/2 … tionscript

Re: Live Train Departure Boards for the UK

I shall have a look at this ... I have never done any actionscript before though (I'm more of an HTML/perl/javascript developer), so we shall see!

Re: Live Train Departure Boards for the UK

It's very reminiscent of JavaScript

Re: Live Train Departure Boards for the UK

OK here's my first effort - sorry to post the whole thing but I can't see how to post an attachment.

One thing I was unable to work out is how to load the JSON data from the remote server as I would get security exceptions due to the JSON being on a different server from the SWF. 

I know this is possible in javascript:

http://docs.jquery.com/Release:jQuery_1 … g_JSONP.29

but haven't been able to find out how to do this in ActionScript.  So in this effort the JSON is embedded in the code.

package {
  import flash.display.*;
  import flash.text.*;
  import flash.net.URLRequest;
  import flash.net.URLLoader;
  import flash.events.*;
  import com.adobe.utils.*;
  import com.adobe.serialization.json.JSON;

  public class tt2 extends Sprite{
    public function tt2 (){
      var loader:URLLoader = new URLLoader() ;
      var request:URLRequest = new URLRequest() ;

      var data:String='{"error":"false","errorMsg":"Error message","errorField":"","time":"09:33","trains":[["d","09:23","London Bri
dge","09:32 <br/> 9 mins late","1","/en/s/ldbdetails/JmdCF4JhBmE03NyDEybQeQ%3D%3D"],["d","09:36","Horsham","09:40 <br/>
4 mins late","2","/en/s/ldbdetails/l08fLbW54fAfQ%235HX2Tuow%3D%3D"],["","09:41","London Bridge","On time","1","/en/s/ldbdetails/dW9R
G5Dj9PLR8zgIvLV7eA%3D%3D"],["d","09:45","Reigate","09:47 <br/> 2 mins late","2","/en/s/ldbdetails/5rhlobkS6jLajV5vuBWH1Q%3D%3D
"],["","10:06","Horsham","On time","2","/en/s/ldbdetails/WESa03DItX6zEnModsxJ6w%3D%3D"],["","10:11","London Bridge","On time","1","/
en/s/ldbdetails/jAsUzqO4Fvk5jLjq8KBAfA%3D%3D"],["","10:24","London Bridge","On time","1","/en/s/ldbdetails/AGBuiaPoit9kl2PB3%2BSkjw%
3D%3D"],["","10:36","Horsham","On time","","/en/s/ldbdetails/0q5bcfwe7juVdxLYdeyNYg%3D%3D"],["","10:41","London Bridge","On time",""
,"/en/s/ldbdetails/4X1l0e6OO11Y6lZ0ez5HAQ%3D%3D"],["","10:45","Reigate","On time","","/en/s/ldbdetails/DsrF8WugVMWbIjLVTKLDQA%3D%3D"
],["","11:06","Horsham","On time","","/en/s/ldbdetails/9i5yfUpAEoj4NXbtG39SIA%3D%3D"],["","11:11","London Bridge","On time","","/en/
s/ldbdetails/I8aUhO%2B1BRwha0yCkzmAVg%3D%3D"],["","11:23","London Bridge","On time","","/en/s/ldbdetails/PnpIezIB3Q%238LozihQ7Ktg%3D
%3D"]],"buses":[],"ferries":[],"updates":[]}';
       
      var Trains:Object=(JSON.decode(data));
      var trains:Object=Trains.trains;
      var y:Number=0;
      for (var key:Object in trains) {

        y=y+15;

        /* arrive or depart */
        var arrdep:TextField=new TextField();
        arrdep.width=50;
        arrdep.height=50;
        arrdep.x=50;
        arrdep.y=y;
        arrdep.text=trains[key][0]; /* arrive or depart */
        addChild(arrdep);

        /* time */
        var traintime:TextField=new TextField();
        traintime.width=50;
        traintime.height=50;
        traintime.x=100;
        traintime.y=y;
        traintime.text=trains[key][1];
        addChild(traintime);

        /* destination */
        var dest:TextField=new TextField();
        dest.width=50;
        dest.height=50;
        dest.x=150;
        dest.y=y;
        dest.text=trains[key][2];
        addChild(dest);

        /* expected */
    var expected:TextField=new TextField();
        expected.width=50;
        expected.height=50;
        expected.x=250;
        expected.y=y;
        expected.text=trains[key][3];
        addChild(expected);


     }
    }
  }
}

Re: Live Train Departure Boards for the UK

In that case, i think I might still need the Google App Engine instance to pass the JSON on with the correct permissions for the Flash app to read.

Re: Live Train Departure Boards for the UK

The crossdomain.xml restricts to National Rail domains only sad
http://ojp.nationalrail.co.uk/crossdomain.xml

Re: Live Train Departure Boards for the UK

That's why I use an App Engine, as then you're master of your own domain and whether or not you respect crossdomain.xml wink

Re: Live Train Departure Boards for the UK

I think that perhaps we don't need to use app engine - instead we can use a yahoo pipe which basically passes the data through, and benefits from a nice crossdomain.xml.

I changed my previous code basically with this:

      request.url='http://pipes.yahooapis.com/pipes/pipe.run?_id=b3dad3b8d00a0862da9ae816eff43c8e&_render=json&station=Merstham';
      loader.load(request);
      loader.addEventListener(Event.COMPLETE,decodeJSON);

      function decodeJSON(event:Event):void {


        var data:String=loader.data;
        var Trains:Object=JSON.decode(data);
        var trains:Object=Trains.value.items[0].trains;

and I think that solves the problem.  Also 'station' is a parameter so can be changed at will.

Does this help much, gingerbeardman?

Re: Live Train Departure Boards for the UK

Anything else I can do to help?

Re: Live Train Departure Boards for the UK

I tried to convert what I've done in to an app myself - but I've learned the hard way that the actionscript I wrote above is actionscript 3 and one can only use actionscript 2 to develop for the chumby.  I believe this will change when flash lite 4.0 comes to the chumby which should happen but there's no date for it.  I think when that happens I will give it a go.

Alternatively, if the existing app takes a format products from a yahoo pipe I could try and reproduce that?

Re: Live Train Departure Boards for the UK

Hi! has anything happened with this? its the only reason i got a Chumby, i wasnt aware it was run on donations, i'd happily donate to have it resurrected? Im fairly good at AS2 and have built a few games, web server code isnt so strong tho if I can help? Please bring it back.....

Re: Live Train Departure Boards for the UK

Hi AshTemple,

It's one of the main reasons I got a chumby too so I was very sad to see it go. 

My AS2 is sadly non-existent, although I do a lot of web development in other languages.

I don't think you would need to know any web server code.  I wrote a yahoo pipe which I think gives all the necessary information.  For example here's the data for the departures from Victoria:

http://pipes.yahooapis.com/pipes/pipe.r … tation=VIC

If there's a json reader for AS2 perhaps it wouldn't be that hard to build this in to a page?  I tried above but then found out I was using AS3 which isn't supported yet.

Michael

Re: Live Train Departure Boards for the UK

Thanks Michael, I've got the JSON to trace in as2, so now i'll try and display the data. i'll keep paying and keep you posted, i cna share the file as i go along if you want incase you want to jump in?

Re: Live Train Departure Boards for the UK

Hi,

ive worked on this for a few hours today, its no way near finished, but im getting times and on time etc into flash, it needs a few more hours of work, but it should be basic stuff with loops and tidying up. I'll try and have a play later, but if anyone else wants to have some fun: http://dl.dropbox.com/u/621066/train.zip

Re: Live Train Departure Boards for the UK

Good going Sir / Madam!

I'm really looking forward to having train times on the chumby again ... nice one.

Re: Live Train Departure Boards for the UK

Hey, im having trouble with the JSON feed and flash, for some reason using the json class its triplicating the feed... is there any way you can share your pipe? or can you export as something else like xml?

itching to get this working!

thanks
Mr AshTemple...

Re: Live Train Departure Boards for the UK

I've published the pipe here

http://pipes.yahoo.com/pipes/pipe.info? … 16eff43c8e

Hopefully this enables you to view the source, it's very very simple

Supposedly the output can be got in several different formats - but for reason I don't understand the rss version isn't working right now.  I believe if you just change json to rss in the URL you should get the same data by rss.