Skip to content

Commit

Permalink
Merge pull request #1 from industrial-edge/dev-updateto1.1 into main
Browse files Browse the repository at this point in the history
Update app example to 1.1.0 and align with IE 1.1
  • Loading branch information
EvaKaul authored Feb 18, 2021
2 parents 2442442 + 2b78e23 commit f8f519a
Show file tree
Hide file tree
Showing 15 changed files with 312 additions and 165 deletions.
65 changes: 29 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
# Ping Pong Edge application implemented in Python

Application example how to communicate over MQTT broker (called Databus in case of Industrial Edge) using IE Flow Creator ([NodeRED fork](https://nodered.org/)) and Python.
Application example how to communicate over MQTT broker (called Databus in case of Industrial Edge) using IE Flow Creator and Python.

- [Ping Pong Edge application implemented in Python](#ping-pong-edge-application-implemented-in-python)
- [QuickStart](#quickstart)
- [Description](#description)
- [Overview](#overview)
- [Requirements](#requirements)
- [Used components](#used-components)
- [Further requirements](#further-requirements)
- [Installation](#installation)
- [Direct Import steps](#direct-import-steps)
- [Manual Build](#manual-build)
- [Complete Installation](#complete-installation)
- [Usage](#usage)
- [Dependencies](#dependencies)
- [Playing ping pong](#playing-ping-pong)
- [Documentation](#documentation)
- [Contribution](#contribution)
- [Licence and Legal Information](#licence-and-legal-information)

## QuickStart

If you want to run everything locally with single command just run `docker-compose up -d` and open webpage on [localhost:1880](http://localhost:1880) and import [flows](SFC-flows/Pingpong-testing.json).

## Description

This application example demonstrates how Industrial Edge application can communicate with Databus using MQTT protocol. The goal is to send a string "Ping" message to Databus (MQTT broker) to a topic "topic1" and subscribe to MQTT topic "topic2" which should return "Pong python". The return message is generated by this python application. You can play virtual ping pong using this application!
Expand All @@ -35,40 +41,41 @@ A picture bellow shows the application data flow and architecture from the docke

## Requirements

In order for this use case to work the following apps needs to be present and configured on the Edge device

- IE Databus
- IE Flow Creator (Can be replaced by any app that can send, receive and display MQTT messages)
- IEM ready to deploy app
- One available onboarded IE Device with enough memory available
- Configured user and user rights on the Databus MQTT broker

### Used components

This application was created and tested using these components
This application version 1.1.x was created and tested using these components

- Industrial Edge App Publisher V1.0.8
- Docker Engine 19.03.8
- Industrial Edge App Publisher V1.1.5
- Docker Engine 20.10.2
- Docker Compose V2.4
- IE Databus V 1.0.11
- IE Flow Creator V 1.0.4
- Industrial Edge Management Version 1.0.11
- Industrial Edge Device V 1.0.0-34
- Industrial Edge Device V1.1.0-39
- IE Databus Configurator V1.1.44
- IE Databus V1.1.23
- IE Flow Creator V1.0.4
- IE Management System V1.1.0-48

### Further requirements

- IE Device is onboarded to a IE Management
- IE Databus Configurator is deployed to the IE Management
- IE Databus is deployed to the IE Device
- IE Flow Creator is deployed to the IE Device

## Installation

You have two options how to install this app into Industrial Edge Management system. You can either use the [Direct Import section](#direct-import) to use .app we build for you or you can follow the [Manual Build](#manual-build) section to build the .app yourself.
You have two options how to install this app into Industrial Edge Management system. You can either use the [Direct Import section](#direct-import) to reuse .app we build for you or you can follow the [Complete Installation](#complete-installation) section to create the .app yourself.

### Direct Import steps

1. Import .app application available at [GitHub](https://github.com/industrial-edge/ping-pong-python/releases) to your Industrial Edge Management using one of the two options
1. Industrial Edge App Publisher (recommended)
2. Catalog import functionality
2. Install the imported app to onboarded Industrial Edge Device
3. Follow the configuration steps in [Installation guide](docs/Installation.md).

### Manual Build
### Complete Installation

More comprehensive instructions for building and installing this application is available in the [Installation guide](docs/Instalation.md).
Comprehensive instructions for building and installing this application is available in the [Installation guide](docs/Installation.md).

## Usage

Expand All @@ -79,25 +86,11 @@ In order for this application to run properly on Industrial Edge Device (IED), t
- Databus application
- IE Flow Creator application

For detailed explanation have a look at the [Installation guide](docs/Instalation.md).
For detailed explanation have a look in the [Installation guide](docs/Installation.md) in the Testing section.

### Playing ping pong

1. Navigate to IED web interface home page
2. Open IE Flow Creator UI
3. Create MQTT Input node in Flow Creator
4. Configure MQTT Broker
1. IP address is "ie_databus", port is 1883, password and user must be configured by you in advance
5. As topic write "topic2" to node
6. Deploy the flow to check whether the connection is working. You should see green "connected" indicator after deploying
7. Repeat the same process for MQTT output node
8. Use Inject node as input to MQTT output node. Input text message should be "Ping"
9. Use Debug node as output to MQTT input node
10. Click on Inject to send message to broker. In the debug window you should see response.

The end flow should look like this.

![flow](docs/graphics/PingPongFlowCreator.png)
Have a look in the [Installation guide testing section](docs/Installation.md) on how to play ping pong in Industrial Edge. :D

## Documentation

Expand Down
143 changes: 143 additions & 0 deletions SFC-flows/Pingpong-testing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
[
{
"id": "cd02c1b1.e5539",
"type": "tab",
"label": "PingPong Test",
"disabled": false,
"info": ""
},
{
"id": "28f15183.6df22e",
"type": "inject",
"z": "cd02c1b1.e5539",
"name": "",
"props": [{ "p": "payload" }, { "p": "topic", "vt": "str" }],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "Ping",
"payloadType": "str",
"x": 450,
"y": 180,
"wires": [["a7b5026b.7018c"]]
},
{
"id": "5357c931.64e9d8",
"type": "inject",
"z": "cd02c1b1.e5539",
"name": "",
"props": [{ "p": "payload" }, { "p": "topic", "vt": "str" }],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "Pong",
"payloadType": "str",
"x": 450,
"y": 240,
"wires": [["a7b5026b.7018c"]]
},
{
"id": "d34cbaff.a45528",
"type": "inject",
"z": "cd02c1b1.e5539",
"name": "",
"props": [{ "p": "payload" }, { "p": "topic", "vt": "str" }],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "Something else",
"payloadType": "str",
"x": 420,
"y": 300,
"wires": [["a7b5026b.7018c"]]
},
{
"id": "a7b5026b.7018c",
"type": "mqtt out",
"z": "cd02c1b1.e5539",
"name": "",
"topic": "topic1",
"qos": "",
"retain": "",
"broker": "f9797e4b.7d9c9",
"x": 610,
"y": 240,
"wires": []
},
{
"id": "be36003a.4e936",
"type": "mqtt in",
"z": "cd02c1b1.e5539",
"name": "",
"topic": "topic2",
"qos": "2",
"datatype": "auto",
"broker": "f9797e4b.7d9c9",
"x": 390,
"y": 440,
"wires": [["9618c676.7e2158"]]
},
{
"id": "9618c676.7e2158",
"type": "debug",
"z": "cd02c1b1.e5539",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 590,
"y": 440,
"wires": []
},
{
"id": "23479def.67eba2",
"type": "comment",
"z": "cd02c1b1.e5539",
"name": "publish different data to topic on databus",
"info": "",
"x": 480,
"y": 120,
"wires": []
},
{
"id": "227e2d39.73b9e2",
"type": "comment",
"z": "cd02c1b1.e5539",
"name": "subscribe to topic on databus to receive answer",
"info": "",
"x": 500,
"y": 400,
"wires": []
},
{
"id": "f9797e4b.7d9c9",
"type": "mqtt-broker",
"name": "",
"broker": "ie-databus",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": false,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]
2 changes: 1 addition & 1 deletion cfg-data/mqtt-config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"MQTT_USER":"edge",
"MQTT_PASSWORD":"edge",
"MQTT_IP":"ie_databus",
"MQTT_IP":"ie-databus",
"TOPIC_1":"topic1",
"TOPIC_2":"topic2"
}
7 changes: 3 additions & 4 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Docker compose that can be imported to Industrial Edge App Publisher (IEAP)
# Docker compose that can be imported to Industrial Edge App Publisher (IEAP) but first build it with docker-compose.yml

version: "2.4"
services:
pingpong-python:
image: ping-pong-python:1.0.0
image: ping-pong-python:1.1.0
environment: # We recommend using cfg-data folder and load config from file rather than environment variables
- TOPIC_1=topic1
- TOPIC_2=topic2
# Databus service in network is called ie_databus but will be probably changed in Industrial Edge 1.1
- MQTT_IP=ie_databus
- MQTT_IP=ie-databus # Databus name has changed in Industrial Edge 1.1
- MQTT_USER=edge
- MQTT_PASSWORD=edge
mem_limit: 300mb
Expand Down
19 changes: 13 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
version: "2.4"
# Use this docker-compose as a one-click start for demo -> simply run "docker-compose up -d" and see logs of python container that it is connected

version: "2.4"
services:
pingpong-python:
build: ./src/
image: ping-pong-python:1.0.0
image: ping-pong-python:1.1.0
environment:
- TOPIC_1=topic1
- TOPIC_2=topic2
# Databus service in network is called ie_databus but will be probably changed in Industrial Edge 1.1
- MQTT_IP=ie_databus
- MQTT_IP=ie-databus
- MQTT_USER=edge
- MQTT_PASSWORD=edge
mem_limit: 300mb
Expand All @@ -18,8 +18,15 @@ services:
# Network of system apps
networks:
- proxy-redirect
ie_databus: # note that the underscore will be removed in the future
image: eclipse-mosquitto
ie-databus: # For local development purposes. Note that preffered databus name changed from 1.0 to 1.1. Legacy old name is "ie_databus".
image: eclipse-mosquitto:1.6
networks:
- proxy-redirect

nodered:
image: nodered/node-red
ports:
- 1880:1880
networks:
- proxy-redirect
networks:
Expand Down
Loading

0 comments on commit f8f519a

Please sign in to comment.