Boring old black and white text scrolling down a screen isn’t very attractive, right? (Refer to my previous post). So with this on my conscience I set out to give my ruby program, which gets data from FlightGear, a nice pretty interface… well sort of pretty.

So… here it is!

Now when dealing with constant processing of input or output data and in my case it is data being received, as well as a graphical user interface you are asking ruby to do two things at once. In the general scheme of things it is not what simple old ruby does, all it knows is to run through a series of instructions and then either loop back over those instructions or terminate, that being said with exceptions. So let me now introduce threads.

Ruby threads, without going into to much detail, allow multiple processes to run parallel to each other. So I needed ruby to not only be managing the GUI but also receiving and processing I/O data and thus the use of threads.

Setting up a thread is quite simple:

And you can find more information about them in the ruby core libraries documentation, see here.

Like the rest of my programs featuring GUI’s I have a soft spot for FXRuby, and I really don’t know why but I think it is mainly because it works, strangely enough. To allow me to update each piece of information (speed, altitude, etc.) I used FXRuby’s Data Targets which I setup to be updated from within the threaded receiving process.

All in all it is a pretty straight forward program but there are still plenty of loose ends needing to be tied up before I can call it a completely finished. It doesn’t even fulfill its intended purpose yet so there is plenty more to do.

If anyone is interested in the complete ruby code post a comment (with your email address) or send me an email and I will forward it on to you.

Stay tuned for more!

Ruby, IronRuby and FlightGear; Three big subjects in their own rights but here I am mixing them all together and perhaps getting into things a little to much over my head.

The idea of using these three programs is to get real time data from a flight simulator program and then process and output it through ruby. Also a future goal is to be able to send data  to control different systems while in flight through external components.

The following post contains information on FlightGears .xml protocols and configuring the simulator to output data through a socket. Also two scripts in Ruby and IronRuby which gets data from FlightGear and displays it.

Please also note that you will find that some information I give is similar to what is given at http://linkslink.wordpress.com/takeoff/ as I used the information as a guide when I was learning about the .xml Protocol files and has led me to some handy .Net libraries when using IronRuby.

Read the rest of this entry »