Predix – Steam Locomotive NodeJS Simulation
This Topcoder challenge was focused on creating a generic device in node.js and to use it to simulate a steam locomotive. Check out the original challenge and dive into the winning Asset details below.
Congratulations to dcp for taking first place in the challenge and providing us a description of his solution below.
Winner's Asset Details & Description
This application simulates a steam locomotive tracking system. It is part of the Predix Industrial Internet of Things (IoT) suite of applications. In real-world usage, there would be many more variables tracked about the locomotive, but the point of this application was to illustrate the possibilities and provide a general proof of concept.
Predix time series and asset services
By sending data to the Predix cloud from sensors (simulated in this application), we can provide a centralized tracking location, which offers a plethora of real-world benefits, such as allowing a company to monitor a fleet of trains for potential problems, etc. Predix time series service is used to track data points about the locomotive, such as fuel mass in tender, pressure, speed, etc. The Predix asset service is used to store messages when some value falls out of an acceptable range (e.g., maximum speed of the locomotive exceeded).
Running the simulator
As the simulator generates data about the locomotive, it is queued and then sent to Predix in batches. These data batches are sent to Predix in an asynchronous manner, and if the data fails to be sent — due to temporary network glitch, etc. — then it will be sent again, ensuring that no data is ever lost.
Problem-solving for the challenge
The hardest part of the challenge was coding the solution such that it could handle network failures without losing any data, and also queuing the data to be sent to Predix so that the main simulator loop could run without any delays. The approach used to solve both of those problems was to use node.js promises. The application should run on any platform that node.js will run on.