The OSGi IoT Trains SDK is a way to write software for a Lego® train track used in the OSGi IoT Contest. The SDK is an OSGi enRoute workspace with a number of projects. The SDK is a self contained environment that contains everything to run an emulator with custom or example bundles.
On the highest level the architecture is about a role play between a Track Manager and a number of Train Managers.
The track manager runs somewhere in the cloud and controls the overall track. It receives the RFID events from passing trains, it gets requests from trains to access certain track segments, it controls the signals, and it tells the trains to go to destinations.
These actors play on a Lego® track. The actual track is defined in a configuration so can vary. However, a typical track looks like the following:
The service model of the OSGi IoT Trains SDK is depicted in the following figure:
TrackInfo— The Track Info service provides the general information that is needed by all actors. The application uses it to visualize the track, the train uses it to find out where it is by listening to the events. A primary function of this service is to provide the track layout. The track layout is configurable and can change.
TrackForTrain— A service specifically targeted at the Train Managers. It provides access to the assignments of the train and it allows a Train Manager to register itself.
TrackForSegment— A service targeted at the segment controller. The track controller manages the hardware for the signals, switches, and RFIDs.
Train Controller— This service allows the Train Manager to control the train by setting the speed.
Track Controller— A track controller manages a number of segment controllers. The Track Controller interface is the interface for the Track Manager to tell what switches and signals should be set.
Segment Controller— Low level service to control the hardware directly that manages the RFID, signals, and switches.
osgi.enroute.trains.api— Provides the service specifications for the infrastructure. The software architecture of this API is later explained.
osgi.enroute.trains.application— The application project contains a web based graphic user interface. It can be used to run the emulator with the example Track and Train manager or a custom implementation.
osgi.enroute.trains.emulator.provider— This is an emulator of the track. It provides a Train Controller service and a number of Segment Controller services so that the Train Manager and Track Manager can work as if they operate against the real world.
osgi.enroute.trains.segment.controller.provider— Low level hardware controller.
osgi.enroute.trains.track.controller.provider— Manages a number of segment controllers
osgi.enroute.trains.track.manager.example.provider— Example Track Manager. This project can act as template for an entry in the contest.
osgi.enroute.trains.train.controller.provider— Implements the hardware interface (Infrared control) for the Lego® train.
osgi.enroute.trains.train.manager.example.provider— Example Train Manager. This project can act as template for an entry in the contest.
osgi.enroute.trains.util— Utility classes for the trains. Contestants are free to write their code in any way they want. However, this project simplifies some of the track calculations. Among others, it provides a helper class that makes it easy to use the track, which is defined with DTOs, in an object oriented way.