This blog will continue on with the REST example and show you one example on how to enter data into Maximo. For example, if you had a large tank and wanted to know the water level you could use a BeagleBone to read the water level and report it to Maximo. Imagine you have your BeagleBone Black setup to read a potentiometer that had an arm attached to a floating device in the tank. The potentiometer is now reading the angle of the arm and with this information you could calculate the water level. In my example however, I will just read the potentiometer and report a value between 0 and 1000 into Maximo.

First we need something in Maximo to report to, so let's add a Tank in the Asset application,

I then added a "WATERLEVEL" Meter to my Tank,

To register meter readings, I need to insert data into the MeasureMent object. This object is a little bit tricky to use since it requires an owner object. What this means is that I need to use an Object Structure to insert the data, I cannot use the Maximo Mbo object. In My case, I created the following "WATERLEVEL" Object Structure (OS),

The interesting part here is the path of the OS and how to refer to a specific Object in the OS via REST. I want to log data against my Tank Asset so that would be the root object, then the OS refer to the AssetMeter and then finally my Measurement object. To use children in an OS, Maximo uses a kind of "dot" notation, one example is found in the RESTAPI documentation. So in my case I would refer to the Measurement with something like, assetmeter.id1.measurement.id2.measurementvalue=My_Value. The full URL to insert a NEW_VALUE reading would be something like, /maxrest/rest/os/waterlevelos/ASSET_ID?_lid=wilson&_lpwd=wilson&_compact=true&_format=json&assetmeter.id1.metername=WATERLEVEL&assetmeter.id1.linearassetmeterid=0&assetmeter.id1.measurement.id2.measurementvalue=NEW_VALUE&assetmeter.id1.measurement.id2.siteid=MY_SITE

There are two unknown here, the Unique ID and Site for the Tank, so I will use another REST call to get the data for our tank asset,/maxrest/rest/mbo/asset?_lid=wilson&_lpwd=wilson&_compact=true&_format=json&assetnum=TANK42.

This will return the the information about the Asset from Maximo and I can now build the full URL in my code to insert values into Maximo. In My example I will read the potentiometer in 5 seconds interval and insert the data into Maximo so it can be viewed in the Manage Meter Reading History.

So if you have a BeagleBone, enter the Asset, Meter and OS above and give it a try. Create a new Java Script in your Cloud9 environment.

Paste in the following code after updating the Application Server IP and Port Number,

// Now that we have the data, read the potentiometer at specified intervals.
// The potentiometer is read and then the callback function logMeasurement is called.
setInterval(function() {bonescript.analogRead('P9_40', logMeasurement)},interval);