Predix – Steam Locomotive NodeJS Simulation

Asset Details

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

The application uses node.js and is written entirely in JavaScript. There is a setup utility which will handle creating the Predix UAA, asset, and time series services, and will create a client bound against these services. You will need to have an existing Predix account before running this utility. Once you do, it can be invoked by using “npm run setup.” Then, to run the simulator, you can use “npm run app.” (Please refer to the file for more details on setup and 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.

Topcoder Winner

United States


JavaScript node.js Predix


Node.js Predix

Are you ready for Predix?