Overview

Skill Level: Beginner

Beginner

Architecture Overview Logical components of Machine Condition MonitoringThe Machine Condition Monitoring application can be divided into the following logical components:Machine Condition Monitoring runtime environmentMachine Condition Monitoring UIMachine Condition Monitoring databaseThe Machine Condition Monitoring application interacts with the following external systems:IBM Watson IoT PlatformIBM Maximo Asset Management Physical components of Machine Condition MonitoringThe Machine Condition Monitoring […]

Ingredients

Hardware Requirements

  1. IBM Internet of Things registered devices

Software Requirements

  1. IBM Bluemix account
  2. Java Cloudant Web Starter boilerplate package
  3. Business Rules service (add this to the Java Cloudant Web Starter boilerplate package)
  4. Internet of Things service (add this to the Java Cloudant Web Starter boilerplate package)
  5. Node.js runtime application (Bind the exact services which have been added to the Java Cloudant Web Starter package – namely Business Rules service, Internet of Things service and also bind the Cloudant service.)
  6. Access to the ReST service of the Maximo instance

Service fee may apply - Estimated Costs: Monthly Estimated Costs vary

Information

More than 256MB RAM might be required to deploy this application. If the memory usage exceeds 256MB in the free trial accounts (Bluemix Trial Account and Standard Account), the application might not work as expected.

We suggest that you upgrade to Pay-as-You-Go or Subscription account to enjoy the full-range Bluemix services.

Step-by-step

  1. Architecture Overview

     

     

    Logical components of Machine Condition Monitoring

    The Machine Condition Monitoring application can be divided into the following logical components:

    1. Machine Condition Monitoring runtime environment
    2. Machine Condition Monitoring UI
    3. Machine Condition Monitoring database

    The Machine Condition Monitoring application interacts with the following external systems:

    1. IBM Watson IoT Platform
    2. IBM Maximo Asset Management

     

    Physical components of Machine Condition Monitoring

    The Machine Condition Monitoring application runs on IBM Bluemix and is made up of the following components which are all available on IBM Bluemix:

    1. Liberty for Java
    2. Cloudant DB service
    3. Business Rules service
    4. Internet of Things service
    5. Node.js runtime environment
  2. Prerequisites for installing Machine Condition Monitoring

    Bluemix

    Create a web application in IBM Bluemix using the Java Cloudant Web Starter boilerplate.

    1. Add a Business Rules service to your application.
    2. Add an Internet of Things service to your application.

     

    After you have added these services, your application should look similar to the one shown in the following image:

     

    Make a note of all the VCAP credentials for every bound service. In this example the application has the following bound services:

    1. Cloudant
    2. Business Rules
    3. Internet of Things

    Therefore there are 3 sets of VCAP credentials (one for each service).

     

     

    Cloudant

    Machine Condition Monitoring needs the following instances of Cloudant databases in order to run:

    1. invokedrules
    2. thingsmaxactionmappings
    3. thingsmaxassetcentricmappings
    4. thingsmaxdevicecentricmappings
    5. thingsmaxrulecentricmappings

    These databases are created by Machine Condition Monitoring, after the application is started. However, in case the above databases are not created, create them manually.

  3. Business Rules Service

    Business Rules are created by using the Rules Designer. The Business Rules can then be deployed on the rules services and made available on Bluemix.

     

    1. Click the Business Rules service that is bound to your Machine Condition Monitoring application. Make a note of the, URL, username and password. You will need these for creating your Rule Execution Server in Eclipse IDE.
    2. Install eclipse with designer plugin.
    3. After installing, open the Rules perspective in Eclipse.
    4. Import the rules project from for Machine Condition Monitoring Rules from the following GitHub location
      1. Machine Condition Monitoring Rules
    5. Right click your RuleApp project, and select RuleApp > Deploy.
    6. After clicking on deploy, select Replace RuleApp version
    7. Select Create a temporary Rule Execution Server configuration and enter your Bluemix Business Rule Service credentials for URL, username and password
    8. .
    9. Click Finish.
    10. Make a note of the ReST service URL. (The URL can be obtained by selecting the application from Bluemix > Services > Business Rules > Decision Services tab. This provides hyperlinks for all the rules exposed as ReST URL. On clicking the hyperlink for the appropriate service deployed above, we get the ReST URL.)
    11. Test your deployment by logging onto the Business Rules Server web page using your userid and password.
    12. The sample rules project contains a simple rule – it checks if the temperature is above 250 degrees.
    13. To test your deployment, you can make a ReST POST request to the rule service, with a JSON payload as given below.
    14. The below stated POST request causes no action to be taken and can be considered as “safe event”.
      1. {
        “device”: {
        “myName”: “bearing01”,
        “temp”: 220
        },
        “asset”: {
        “assetID”: “wheel01”,
        “assetType”: “wheel wagon”
        },
        “org”: {
        “orgID”: “myorg”
        }
        }
    15. The below stated POST request demands an action to be taken. This action can be work order generation.
      1. {
        “device”: {
        “myName”: “bearing01”,
        “temp”: 280
        },
        “asset”: {
        “assetID”: “wheel01”,
        “assetType”: “wheel wagon”
        },
        “org”: {
        “orgID”: “myorg”
        }
        }
    16. Both the above requests return a JSON response, however, the “message” field of the lower temperature request has no content, whereas the event having a higher temperature has content similar to “The temperature is beyond acceptable range of 250 for device of “.
  4. Installing Machine Condition Monitoring Engine

    To install the Machine Condition Monitoring web application, you need to push the machineconditionmonitoring-web.war file to your Bluemix account.

     

    The minimum amount of disk space required on IBM Bluemix for this application, is 1GB. The minimum amount of memory required is 512MB although you might want to set the amount of memory higher than this for example 2GB. The value that you assign to disk space and memory will depend on your environment.

     

    You can change the values for disk space and memory by using the manifest.yml file.

     

    Ensure that you have the latest version of the cf tool installed. Complete the following steps to install the cf tool, in case you dont have the latest version.

    1. You can find the latest version on github.com at the following location – https://github.com/cloudfoundry/cli/releases.
    2. Choose the appropriate installer for your platform and download the installer.
    3. Unzip the installer and run the executable code.

     

    Complete the following steps to install the Machine Condition Monitoring application:

    1. Connect to Bluemix by using the following command, on the command prompt of your local system.
    cf api https://api.ng.bluemix.net


    1. Login to Bluemix by using the following command.
    cf login u {Bluemix userid} o {Bluemix organization} s {Bluemix-space}


    1. Download the source code for Machine Condition Monitoring Engine from the following GitHub location

    Machine Condition Monitor Engine

    1. Build a war file from the source code, in an eclipse IDE, and name it “machineconditionmonitor-web.war”.
    2. Push the web application to your IBM Bluemix account, by providing a unique application name (the example below uses an application name of “machineconditionmonitor-web”)
    cf push machineconditionmonitor-web


    1. In the Bluemix, click on Dashboard > select the application (this example uses the an application name of “machineconditionmonitor-web”) > Files and Logs and navigate to “server.xml” location. This file is located under “app/.liberty/usr/servers/defaultServer/server.xml”.
    2. Download the server.xml file from Bluemix.
    3. Create a folder called defaultServer in your local system.
    4. Add the server.xml file in this folder and add the following entry in the “server.xml” file.
     <webContainer deferServletLoad="false"/>

     

    Change the name of the app, in “server.xml”, to the one that you have provided.

    1. Create a folder called “apps” and add the “machineconditionmonitoring-web.war” file to that folder.
    2. Push the war file back to IBM Bluemix, by providing the unique application name that you used previously (the example below uses an application name of “machineconditionmonitor-web”)
    cf push machineconditionmonitor-web p defaultServer


     

    ReST services to create asset device mappings and create action mappings

    Machine Condition Monitoring application has exposed the following APIs. Using these APIs, you can

    1. Create asset device mappings.
    2. Create action mappings.

     

    Asset APIs

    HTTP Method Description

    Payload

    Return URL
    GET /assetMappings/assets Returns an array of assets JSON Array http://URL/assetMappings/assets
    GET /assetMappings/assets/{assetId} Returns a single asset JSONObject http://URL/assetMappings/assets/{assetId}

    POST /assetMappings/assets

    Persists an asset in Cloudant. Note that this asset should be present in Maximo JSONObject http://URL/assetMappings/assets
    DELETE /assetMappings/assets/{assetId} Deletes an asset from Cloudant http://URL/assetMappings/assets/{assetId}
             

     

    Action APIs

    HTTP Method Description

    Payload

    Return URL
    GET /actionMappings/action Returns an array of actions JSON Array http://URL/actionMappings/action
    GET /actionMappings/action/{actionId} Returns a single action JSONObject http://UEL/actionMappings/action/{actionId}

    POST /actionMappings/action

    Persists an action in Cloudant. Note that this action should point to a valid URL with a valid userid and password

    JSONObject http://URL/actionMappings/action
    DELETE /actionMappings/action/{assetId} Deletes an action from Cloudant http://URL/actionMappings/action/{actionId}
             
  5. Installing the Machine Condition Monitoring UI

    To install the Machine Condition Monitoring UI, you need to push the Machine Condition Monitoring Node.js application to your Bluemix account.

     

    Complete the following steps to install the Machine Condition Monitoring UI:

     

    This step assumes that you have already the cf tool, as documented in steps 1- 3 of Installing Machine Condition Monitoring

     

    1. From the Catalog section in IBM Bluemix, select SDK for Node.js in the Cloud Foundry Apps Section.
    2. Enter a unique application name, for example “ThingsMaxUI” and click Create
    3. After the application is created, bind(not add) the services that you created earlier:
      1. Business Rules service
      2. Cloudant NoSQL DB service
      3. Internet of Things service
    4. The following image shows the Node.js application with the services bound.

    5. Create a user-defined environment variable for the URL of the Machine Condition Monitoring-web application

      1. Select Environment Variables tab
      2. Click User-Defined
      3. Add an environmental variable called runtimeapp with the URL of your Machine Condition Monitoring-web application. The following link http://machineconditionmonitor-web.mybluemix.net is the URL for the Machine Condition Monitoring-web.

    6. Connect to Bluemix by using the following command, on the command prompt of your local system

      cf api https://api.ng.bluemix.net
    7. Login to Bluemix by using the following command
      cf login u {Bluemix userid} o {Bluemix organization} s {Bluemix-space}
    8. Download the Machine Condition Monitoring from the following GitHub location –

      Machine Condition Monitor UI

    9. Push your Node.js application to your Bluemix account, by providing a unique application name (in the below case I have provided the name as “machineconditionmonitor-GUI”).
    10. cf push machineconditionmonitoring-GUI
    11. Invoke ReST service, in your Machine Condition Monitor engine, to populate the Maximo specific data, in the cloudant database, by making a POST call. In this example, the ReST service is running on “machineconditionmonitor-web” and so the ReST service to be invoked is http://machineconditionmonitor-web.mybluemix.net/actionMappings/action.
    12. Payload to be used is given below.
    13. {
      “thingsActionPassword”: “maximopassword”,
      “thingsActionUserId”: “maximouser”,
      “actionId”: “maximo”,
      “thingsActionURL”: “https://maximoURL/maximo_b1dk”
      }
    14. Replace the payload content with the appropriate ones for your instance.
    15. Invoke ReST POST service (https://username-for-cloudant-on-bluemix:password-for-cloudant-on-bluemix@username-for-cloudant-on-bluemix.cloudant.com/invokedrules/_index), in the Cloudant database, bound to the Machine Condtion Monitoring engine and use the following payload.
    16. { “index”: {“fields”: [“deviceID”]}}
    17. Replace the username and password, in the ReST URL with the appropriate ones for your cloudant database.

       

  6. Flow Testing

    1. Browse the URL for the machine condition monitoring UI. Select the organization and the asset from the drop down.
    2. Initially no mapping exists between asset and device. Create the mapping, by clicking on “Add Device Mapping”.
    3. The above operation would display a list of devices, for the same organization, within the Bluemix environment, for Watson IoT. Select the device which needs to be mapped to the asset. This displays the rules link.
    4. Add the rules ReST URL, which was obtained in the Business Rules service.
    5. Send a device event from a registered device which has the event parameter set higher than the maximum permissible threshold so that a work order is generated.
    6. The work order is generated and can be seen in the Machine Condition Monitoring UI.
  7. Conclusion and some of other related recipes for reference

    In this recipe, we have showcased how to use Business Rules Service on Bluemix and update the rule to monitor machine condition without altering the application code. We also have other related recipes related to IoT Devices and Monitoring, here given are the some of links for reference:

Expected Outcome

On successful completion of the activities provided in this remix, you will have a Machine Condition Monitoring application deployed on your Bluemix account.

 

Introduction to Machine Condition Monitoring

IBM Maximo Asset Management is a comprehensive solution for managing enterprise assets on an extensible platform. It offers “built in” mobile access, out-of-the box mapping, crew management, extensive reporting and analytical insight.

IBM IoT Foundation is a fully managed, cloud-hosted service that is designed to simplify and derive value from IoT devices.

Assets, managed by IBM Maximo Asset Management,  can utilize sensor data from devices registered in IoT Foundation, for real-time monitoring. Machine Condition Monitoring makes leveraging this information easy.

The Machine Condition Monitoring application runs in a Bluemix environment and can be used to integrate IBM IoT Foundation with IBM Maximo Asset Management.

Use the Machine Condition Monitoring application to create mappings between:

  1. An organization in IBM IoT Foundation to and an organization in Maximo Asset Manager.
  2. A device in IBM IoT Foundation to and an asset in Maximo Asset Manager.

 

Use the Machine Condition Monitoring application to:

  1. Add business rules, in Machine Condition Monitoring, to set the threshold for work order generation.
  2. Generate a work order in Maximo, based on the information in a sensor event.

 

Use the ReST APIs that are provided with the Machine Condition Monitoring application to:

  1. Create, read and delete the mappings between devices and assets, for a given organization.
  2. Create, read and delete action items, such as work order generation, to be taken on receiving sensor events.

3 comments on"Machine Condition Monitoring"

  1. Amit M Mangalvedkar October 02, 2015

    Testing 123

  2. 9.Add the “server.xml” file in this folder and add the following entry in the “server.xml” file. But There is no code

Join The Discussion