One of the exciting parts of IoT is that you escape the boundaries of cyberspace and actually make things move in the real world. I find that few things are more gratifying than writing a program that has an impact on the world. (And I do not mean the ink in your printer.)
Last year the OSGi IoT contest for the OSGi Community Event, co-located with EclipseCon Europe, used the theme of wind farms (actually emulated windmills) to demonstrate the awesome power of OSGi. This year we decided to go back to our early childhood and do it with LEGO® trains!
We came up with this idea after some brainstorming amongst the team. We looked at building the largest Rube Goldberg contraption in the world but realized that building deliberately the largest overly complex device might create the wrong impression. So we looked at a Scalextric race track. Cool. But in the end the LEGO® trains won. Especially when we realized that we could use one of the key benefits of OSGi to have some fun. This benefit is, of course the portability of the OSGi bundles. If you write proper bundles that are connected through services then you know what we’re talking about.
So let's assume we specify an OSGi Train Manager service to control a train (move, stop, etc) and an OSGi Track Manager service to find out about the layout of the tracks, the overall state of the tracks, assign destinations to the trains, and control the signals and switches. Once these services are defined anybody can write a bundle controlling the train. That could be fun, but now we could also run multiple trains simultaneously. So a properly written Train Manager should be able to fulfill its assignments (go to a special segment) without crashing into another train. Since the Track Manager also has a rather important role we decided to also allow people to provide Track Manager bundles.
During the OSGi Community Event 2015 we will provide a complete track with switches, signals, RFID readers, and multiple trains. During the event, contestants can get time on the track to test their bundles in real life. However, writing your bundle blind is no fun. So we have also developed a software emulator for the tracks & trains. You can test your Track Manager bundle or Train Manager bundle right in the emulator. The emulator has a web based GUI, that runs in Eclipse/Bndtools, right in the debugger.
The fun is going to be to try out different combinations of Train Managers and Track Managers with multiple trains. Will they crash? Can’t wait to see this happening! We will of course provide some videos of the results (if you unfortunately can’t make it to the event).
The SDK is available now. We’re still finalizing the actual track with the switches, signals, and RFID readers. These hardware components are emulated in the SDK but we need, of course, the real stuff for the Community Event. The Train Manager bundle will actually run on a Raspberry Pi with the Lego train IR controller and will use Distributed OSGi to communicate with an OSGi Cloud where the Track Manager runs. The beauty of OSGi is that the bundles don’t care where they run as long as their services are provided.
So if you’ve been thinking of kicking the tires (or more appropriately wheels) on OSGi then this might be the right time to try it out. If you have some experience with Eclipse you can quickly get started since OSGi enRoute is Eclipse/Bndtools based. If you’re an experienced OSGi developer, well, can you really resist playing with trains? Though seeing your train run on the actual track is the most fun, you don’t even have to be there to participate so there really is no reason not to try it out!