- Installation of the PingPong application
Download or clone the repository source code to your workstation.
- Trough terminal:
git clone https://github.com/industrial-edge/pingpong-python.git
- Trough VSCode:
CTRL+↑ SHIFT+P or F1 to open VSCode's command pallette and typegit clone
:
- Navigate into
src
and find the file namedDockerfile.example
. TheDockerfile.example
is an example Dockerfile that can be used to build the docker image(s) of the service(s) that runs in this application example. If you choose to use these, rename them toDockerfile
before proceeding - Open a console in the root folder (where the
docker-compose
file is) - Use the
docker compose build
(replaces the olderdocker-compose build
) command to build the docker image of the service which is specified in the docker-compose.yml file. - These Docker images can now be used to build your app with the Industrial Edge App Publisher
docker images
can be used to check for the images
Please refer to Uploading App to IEM on how to upload the app to the IEM. For importing the configuration in the IE publisher use the docker-compose.prod.yml file please.
Before deploying to a Industrial Edge Device, a configuration for the application has to be created ans the Industrial Edge Databus has to be configured.
To configure the databus topics, username and password of the pingpong application, a new configuration for the application has to be created in the Industrial Edge Management. The following parameters are required by the application:
- "MQTT_USER": username of user in databus, must exist
- "MQTT_PASSWORD": password of user in databus
- "MQTT_IP": name of the databus service name (serve as DNS resolution)
- "TOPIC_1": databus topic to which the app subscribes to
- "TOPIC_2": databus topic to which the app publishes to
The configuration file has to be named mqtt-config.json
and has to be structured like the following example configuration:
{
"MQTT_USER":"edge",
"MQTT_PASSWORD":"edge",
"MQTT_IP":"ie-databus",
"TOPIC_1":"topic1",
"TOPIC_2":"topic1"
}
In the example above, the app will authenticate to the databus with the username edge
and password edge
. It will subscribe to topic1
and will publish to topic2
.
If no configuration is provided (e.g if the app is deployed as a standalone application), the application will use the corresponding environmental variables specified in the docker-compose.yml
file.
To create a configuration for the application follow these steps:
- Open the "Applications" -> "My Projects" Tab in the Industrial Edge Management web interface
- Click on your PingPong application
- Click on "Configurations" and "Add Configuration"
- Enter a Name and Description. Enter
./cfg-data
as host path. Check the "versioned" Checkbox and click "Add" - Click on the "+" Button to add a new version of the configuration
- Enter a Name and Description. Browse for the
mqtt-config.json
file in thecfg-data
folder of this repository. - Click on the pencil button next to the version to verify that all parameters are set correctly.
To be able to authenticate with the databus to publish and subscribe to the configured topics, the Industrial Edge Databus has to be configured appropriately.
- In the Industrial Edge Management Web interface, click on "Data Connections", select the Databus and choose the corresponding Industrial Edge device where the pingpong app is installed
- Create a new user with the username, password, and put topic as "topic1" as defined for the pingpong application
- Create the second topic needed by the pingpong application "topic2" by clicking on the + button beside "Topics" and give the user publish and subscribe permission
- Deploy the databus configuration and wait for the job to be finished successfully
As soon as a configuration for the application is created and the Industrial Edge Databus is configured, the app can be installed to an Industrial Edge Device.
Industrial Edge Management Web interface:
- Click on the application under the "Applications"->"My Projects" Tab
- Click on the install button of the version you want to deploy
- Select the application configuration and the version of the configuration
- Select the corresponding Industrial Edge Device
- Click "Install Now" and wait for the job to be finished successfully
When the pingpong application is deployed and running on the Industrial Edge Device, it can be tested using the Flow Creator.
- Open the web interface of the Flow Creator
- Connect a "inject" node with a "mqtt out" node
- Connect a "mqtt in" node with a "debug" node
- Configure the mqtt-nodes to connect to the databus. Enter the hostname, username and password
- Set the topics of the mqtt-nodes according to the configuration of the application. For example
topic1
as the topic to publish to andtopic2
as the topic to subscribe to. - Deploy the flow and test by injecting a string payload into the mqtt in node. If the string is "Ping", the app will answer with "Pong". If the string is "Pong" the app will answer with "Ping".
The finished flow is available here and can be imported into the simatic flow creator.