blob: 19aaf10a1e73f4375c960041305860df9b3d7ba4 [file] [log] [blame]
{"name":"grinding-machine-scenario","content":"<h2>Abstract</h2>\n<p>In this blog post we present a real world condition monitoring scenario used in<br>\nthe <a href=\"https://iot.eclipse.org/testbeds/production-performance-management/#\">Eclipse Production Performance Management Testbed</a>, where Unide and<br>\nPPMP plays a crucial role. Moreover, we also provide a code repository and<br>\ninstructions so that you can recreate the scenario in your own computer and<br>\nlearn about its components and the communication with each other.</p>\n<h2>Introduction</h2>\n<p>In the context of the <a href=\"https://iot.eclipse.org/testbeds/production-performance-management/#\">Eclipse Production Performance Management Testbed</a>, a<br>\nreal world condition monitoring scenario has been recreated, in which a<br>\ngrinding machine is being continuously monitored allowing to have real time<br>\nhealth checks and prevent unexpected failures.</p>\n<p>This scenario consists of the following building blocks: device, gateway,<br>\nbackend. The communication between them happens seamlessly thanks to the<br>\nProduction Performance management Protocol (PPMP).</p>\n<ul>\n<li>\n<p>The device, i.e. the grinding machine, has been retrofitted with an<br>\nacceleration sensor attached to one of its critical components. The data<br>\nprovided by this sensor is routed to the gateway in the form of a <a href=\"https://www.eclipse.org/unide/specification/measurement-message#messageDetail\">PPMP<br>\nMeasurement Message</a>.</p>\n</li>\n<li>\n<p>The gateway receives the raw acceleration measurements, calculates some<br>\nstatistical characteristics and and applies some machine learning techniques<br>\nto them in order to evaluate the condition of the grinding machine. Then both<br>\nthe statistical values and the condition are routed to the backend, again in<br>\nthe form of a PPMP Measurement Message.</p>\n</li>\n<li>\n<p>The backend, usually in the cloud, is any component that &quot;speaks PPMP&quot; and<br>\nperforms meaningful operations on the incoming messages. Most frequently it<br>\nis responsible for storing the arriving data and making it available to apps<br>\nthat want to consume it. Common responsibilities of these apps are the<br>\nrepresentation or display of the data (e.g. dashboards), or workflows<br>\nmanagement (e.g. the grinding machine is in bad condition and an inspection<br>\nmust be carried out).</p>\n<p>The backend can be swapped effortless with any entity adhering to PPMP standard.<br>\nIn the Eclipse PPM Testbed at least two different backends have been used:</p>\n<ul>\n<li>One directly based on <a href=\"https://github.com/eclipse/unide\">Unide</a></li>\n<li>One based on <a href=\"https://www.contact-software.com/en/products/elements-for-iot/\">CONTACT Elements for IoT</a>.</li>\n</ul>\n</li>\n</ul>\n<h2>Hands-on demonstration</h2>\n<p>In order to make this scenario more hands-on and interesting, within the<br>\n<a href=\"https://github.com/eclipselabs/eclipseiot-testbed-productionperformancemanagement\">Production Performance Management Testbed repository</a> project in Github, we<br>\nhave set up a <a href=\"https://github.com/eclipselabs/eclipseiot-testbed-productionperformancemanagement/tree/master/grinding-machine\">subproject for the grinding machine scenario</a>. There you can<br>\nfind a thorough description and code to simulate the device and the gateway,<br>\nand route messages to a given backend. The only requirements are git and conda<br>\n(the easiest way to get conda is to <a href=\"https://conda.io/miniconda.html\">install miniconda</a>).</p>\n<p>So, let's get started! First of all, open your terminal and clone the<br>\nrepository:</p>\n<pre class=\"language-bash\"><code class=\"language-bash\">$ <span class=\"token function\">git</span> clone https://github.com/eclipselabs/eclipseiot-testbed-productionperformancemanagement eclipse-testbed-ppm\n$ <span class=\"token function\">cd</span> eclipse-testbed-ppm/grinding-machine\n</code></pre>\n<p>Then move to the grinding machine subproject directory:</p>\n<pre class=\"language-bash\"><code class=\"language-bash\">$ <span class=\"token function\">cd</span> eclipse-testbed-ppm/grinding-machine\n</code></pre>\n<p>In that folder you will see two subfolders. The first one<br>\n<code>unide-grinding-machine</code> contains a Python program that simulates grinding<br>\nmachine and the second one <code>unide-grinding-machine-gateway</code> simulates the<br>\ngateway.</p>\n<h3>Grinding Machine simulator</h3>\n<p>Let's start with the first component. First <code>cd</code> to <code>unide-grinding-machine</code><br>\nand then create the conda environment:</p>\n<pre class=\"language-bash\"><code class=\"language-bash\">$ conda <span class=\"token function\">env</span> create --prefix<span class=\"token operator\">=</span>env\n</code></pre>\n<p>And then in order to use this environment, we need to activate it.</p>\n<pre class=\"language-bash\"><code class=\"language-bash\">$ <span class=\"token function\">source</span> activate <span class=\"token function\">env</span> <span class=\"token comment\"># or in windows: activate env </span>\n</code></pre>\n<p>Run <code>unide-grinding-machine -h</code> to get familiar with the CLI. With this<br>\nexecutable we can generate some machine grinding data, and (for the moment)<br>\nprint messages to the console. To do so, run <code>unide-grinding-machine send random</code> and you should get a large message on the console. This is the PPMP<br>\nmessage ought to be sent to the gateway.</p>\n<p>We don't have a gateway so far, but don't worry, we will get to that in a<br>\nminute. Don't close this console!</p>\n<h3>Gateway simulator</h3>\n<p>Open a new console, and similarly to the previous point, first <code>cd</code> to<br>\n<code>unide-grinding-machine-gateway</code>, create the environment (<code>conda env create --prefix=env</code>) and activate it (<code>source activate env</code>).</p>\n<p>The run the command <code>unide-grinding-machine-gateway -h</code> to test that everything<br>\nis in place. You should get the CLI documentation.</p>\n<p>Now, let's fire up the gateway by calling <code>unide-grinding-machine-gateway start_server</code>, and a message like this should show up:</p>\n<pre class=\"language-bash\"><code class=\"language-bash\">Running <span class=\"token operator\">&lt;</span>unide_grinding_machine_gateway.server.App object at 0x<span class=\"token punctuation\">..</span><span class=\"token punctuation\">..</span>.<span class=\"token operator\">></span>\nListening on http://127.0.0.1:5000\nPress Ctrl-C to stop<span class=\"token punctuation\">..</span>.\n</code></pre>\n<p>We are getting closer. Leave the gateway running.</p>\n<h3>Communication Device-Gateway</h3>\n<p>Let's go back to the previous console where we had the <code>unide-grinding-machine</code><br>\nenvironment and call again the <code>unide-grinding-machine</code> program, but this time<br>\npassing the as an argument where the gateway is listening to messages.</p>\n<pre class=\"language-bash\"><code class=\"language-bash\">$ unide-grinding-machine send random --endpoint<span class=\"token operator\">=</span>http://127.0.0.1:5000\n</code></pre>\n<p>If you take peek at the gateway output, you should see new information printed<br>\nout, which is a PPMP message containing the result of the classification<br>\nalgorithms applied to the device data we just sent to it.</p>\n<p>We are getting somewhere! But still, it is not extremely useful to print some<br>\ncharacters into a console, is it?</p>\n<h3>Communication Device-Gateway-Backend</h3>\n<p>There is only a small but relevant point missing: the routing from the gateway<br>\nto the backend. We need a backend and the Unide project provides a service that<br>\ncan be used as a playground for these purposes. So let's restart the gateway,<br>\nthis time passing the Unide endpoint:</p>\n<pre class=\"language-bash\"><code class=\"language-bash\">$ unide-grinding-machine-gateway start_server --endpoint<span class=\"token operator\">=</span>https://unide.eclipse.org/rest/v2\n</code></pre>\n<p>Now we can use the <code>unide-grinding-machine</code> to send raw data to the gateway<br>\nwhich in turn sends its results to the backend. In order to be able to<br>\nidentify this data later, we are going to define a proper device ID (argument<br>\n<code>--device-id</code>), and also tell it to send data once each 10 seconds (argument<br>\n<code>--period</code>):</p>\n<pre class=\"language-bash\"><code class=\"language-bash\">$ unide-grinding-machine send random --endpoint<span class=\"token operator\">=</span>http://127.0.0.1:5000 --device-id<span class=\"token operator\">=</span>IoT-000028--3 --period<span class=\"token operator\">=</span>10\n</code></pre>\n<p>Once started, a continuous flow of data is pumped through each component until<br>\nit reaches the backend, allowing us to use the applications that consume this<br>\ndata. For instance, the basic backend provided by Unide offers a <a href=\"https://grafana.com/\">Grafana</a> based<br>\ndashboard that offers live monitoring of the statistical values calculated in the<br>\ngateway:</p>\n<p><img src=\"/unide/images/blog/grinding-machine-grafana-dashboard.png\" alt=\"Grafana based dashboard monitoring grinding machine\"></p>\n<p>If instead of that we use the the <a href=\"https://www.contact-software.com/en/products/elements-for-iot/\">CONTACT Elements for IoT</a> based backend,<br>\nwe can see a different and richer dashboard: charts, 3D models, list of<br>\nmaintenance events, device master data and the Activity Stream, a place where<br>\ndifferent parties can exchange information related to the grinding machine:</p>\n<p><img src=\"/unide/images/blog/grinding-machine-ce4iot-dashboard.png\" alt=\"CONTACT Elements for IoT Dashboard\"></p>\n","url":"/blog/2018/2/13/grinding-machine-scenario","title":"PPMP Use Cases: Unide and the Eclipse Production Performance Management Testbed","date":"2018-02-13T00:00:00.000Z","tags":["use cases"],"prev":{"url":"/blog/2018/2/11/Transform-PPMP-with-camel","title":"PPMP Use Cases: Simple Transformation with Apache Camel"},"next":{"url":"/blog/2018/3/26/Release-0.2.0","title":"Unide 0.2.0 released"}}