-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e82a2b6
Showing
36 changed files
with
1,551 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# **Legal information** | ||
|
||
## **Use of application examples** | ||
|
||
Application examples illustrate the solution of automation tasks through an interaction of several components in the form of text, graphics and/or software modules. The application examples are a free service by Siemens AG and/or a subsidiary of Siemens AG (“Siemens”). They are non-binding and make no claim to completeness or functionality regarding configuration and equipment. The application examples merely offer help with typical tasks; they do not constitute customer-specific solutions. You yourself are responsible for the proper and safe operation of the products in accordance with applicable regulations and must also check the function of the respective application example and customize it for your system. | ||
|
||
Any change to the application examples is your responsibility. The application examples are not required to undergo the customary tests and quality inspections of a chargeable product; they may have functional and performance defects as well as errors. It is your responsibility to use them in such a manner that any malfunctions that may occur do not result in property damage or injury to persons. Siemens reserves the right to make changes to the application examples at any time without notice. The application examples of this repository are licensed under the MIT License (see below). | ||
|
||
## MIT License | ||
|
||
Copyright 2020 Siemens AG | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
## **Security information** | ||
|
||
Siemens provides products and solutions with industrial security functions that support the secure operation of plants, systems, machines and networks. In order to protect plants, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept. Siemens’ products and solutions constitute one element of such a concept. Customers are responsible for preventing unauthorized access to their plants, systems, machines and networks. Such systems, machines and components should only be connected to an enterprise network or the Internet if and to the extent such a connection is necessary and only when appropriate security measures (e.g. firewalls and/or network segmentation) are in place. | ||
For additional information on industrial security measures that may be implemented, please visit https://www.siemens.com/industrialsecurity. | ||
|
||
Siemens’ products and solutions undergo continuous development to make them more secure. Siemens strongly recommends that product updates are applied as soon as they are available and that the latest product versions are used. Use of product versions that are no longer supported, and failure to apply the latest updates may increase customer’s exposure to cyber threats. | ||
|
||
To stay informed about product updates, subscribe to the Siemens Industrial Security RSS Feed at: https://www.siemens.com/industrialsecurity. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Archiving & Visualization Demo | ||
|
||
Archiving and Visualization Panel demo application for Industrial Edge | ||
|
||
- [Archiving & Visualization Demo](#archiving--visualization-demo) | ||
- [Description](#description) | ||
- [Overview](#overview) | ||
- [General Task](#general-task) | ||
- [Requirements](#requirements) | ||
- [Components](#components) | ||
- [Helpful tools](#helpful-tools) | ||
- [Prerequisite](#prerequisite) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Information](#information) | ||
- [Documentation](#documentation) | ||
- [Contribution](#contribution) | ||
- [License & Legal Information](#license--legal-information) | ||
|
||
## Description | ||
|
||
### Overview | ||
|
||
The Industrial Edge Application "Archiving & Visualization Demo" is based on a bottle filling process application from which data values are collected, stored in an Influxdb database and visualized with a Grafana dashboard. | ||
|
||
 | ||
|
||
### General Task | ||
|
||
The Industrial Edge Application "Archiving & Visualization Demo" collects data from an S7-1500 PLC using the S7 Connector System Application. The collected data is automatically published to the IE Databus which is an internal MQTT broker of the Edge Runtime. The "Archiving & Visualization Demo" Application uses an MQTT Client (Datacollector) to subscribe to the IE Databus and write these values into an Influx-Database. The time series of the collected data can then be plotted with grafana. | ||
|
||
## Requirements | ||
|
||
### Components | ||
|
||
- OS: Windows or Linux | ||
- Docker minimum V18.09 | ||
- Docker Compose V2.0 – V2.4 | ||
- Industrial Edge App Publisher (IEAP) > V1.0.8 | ||
- Industrial Edge Management (IEM) > V1.0.10 | ||
- S7 Connector > V1.0.22 | ||
- S7 Connector Configurator > V1.0.9 | ||
- IE Databus > V1.0.11 | ||
- IE Databus Configurator > V1.0.44 | ||
- Industrial Edge Device (IED) > V1.0.0-43 | ||
- TIA Portal V16 | ||
- PLC: CPU 1511 FW 2.8.3 | ||
|
||
### Helpful tools | ||
|
||
- Any development environment (e.g. Visual Studio Code, Eclipse, …) | ||
- Docker Extension for your development environment e.g. Visual Studio Code Extension | ||
|
||
## Prerequisite | ||
|
||
Use SIMATIC S7 Connector in bulk publish mode to collect datapoints from the Demo project "Tank Application". Name the PLC "PLC_1" and select following Datapoints using the Browse functionality: | ||
- GDB_signals_tankSignals_actLevel (Read/100ms) | ||
- GDB_signals_tankSignals_actTemperature (Read/100ms) | ||
- GDB_process_numberProdued (Read/100ms) | ||
- GDB_process_numberFaulty (Read/100ms) | ||
- GDB_hmiSignals_HMI_Nextbottle (Read&Write/100ms) | ||
|
||
The IE Databus is configured with one topic: | ||
ie/# | ||
username: edge | ||
password: edge | ||
|
||
## Installation | ||
|
||
For a Step-by-Step guide on how to install this Industrial Edge Application, follow the **[installation instructions](docs/installation.md)** | ||
|
||
## Usage | ||
|
||
### Information | ||
|
||
> :warning: This application exposes accessible API endpoints protected by username and password. Protect your Industrial Edge Device from unauthorized access and don't share your API username and password. This application is only a How To and is not designed to be used in a production enviroment. | ||
## Documentation | ||
|
||
- You can find further documentation and help in the following links | ||
- [Industrial Edge Hub](https://iehub.eu1.edge.siemens.cloud/#/documentation) | ||
- [Industrial Edge Forum](https://www.siemens.com/industrial-edge-forum) | ||
- [Industrial Edge landing page](https://new.siemens.com/global/en/products/automation/topic-areas/industrial-edge/simatic-edge.html) | ||
|
||
## Contribution | ||
|
||
Thanks for your interest in contributing. Anybody is free to report bugs, unclear documentation, and other problems regarding this repository in the Issues section or, even better, is free to propose any changes to this repository using Merge Requests. | ||
|
||
## License & Legal Information | ||
|
||
Please read the [Legal information](Legal_information.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"env": { | ||
"MQTT_BROKER_SERVER": "ie-databus", | ||
"MQTT_TOPIC": "ie/d/j/simatic/v1/s7c1/dp/r/", | ||
"DATA_SOURCE_NAME": "PLC_1/default", | ||
"MQTT_USER": "edge", | ||
"MQTT_PASSWORD": "edge", | ||
"INFLUXDB_IP": "influxdb", | ||
"INFLUXDB_DATABASE": "databus_values" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
version: '2.4' | ||
#### Services #### | ||
services: | ||
#### Data-Collector #### | ||
datacollector: | ||
build: | ||
context: ./src/data-collector | ||
image: data-collector_edge:0.0.1 | ||
restart: always | ||
networks: | ||
- proxy-redirect | ||
- internal-network | ||
depends_on: | ||
- influxdb | ||
volumes: | ||
- './publish/:/publish/' | ||
- './cfg-data/:/cfg-data/' | ||
mem_limit: 100mb | ||
|
||
#### InfluxDB #### | ||
influxdb: | ||
build: | ||
context: ./src/influxdb | ||
image: influxdb_edge:0.0.1 | ||
restart: always | ||
networks: | ||
- internal-network | ||
volumes: | ||
- data:/var/lib/influxdb | ||
mem_limit: 250mb | ||
|
||
#### Grafana #### | ||
grafana: | ||
build: | ||
context: ./src/grafana | ||
image: grafana_edge:0.0.1 | ||
restart: always | ||
networks: | ||
- internal-network | ||
ports: | ||
- "33000:3000" | ||
mem_limit: 100mb | ||
|
||
|
||
#### Network #### | ||
networks: | ||
proxy-redirect: | ||
external: true | ||
name: proxy-redirect | ||
internal-network: | ||
name: internal-network | ||
|
||
volumes: | ||
data: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
1. Clone this repository | ||
|
||
 | ||
|
||
STRG+SHIFT+P in VSCode: | ||
|
||
 | ||
|
||
2. Enter application folder and build the application using the docker-compose build command: | ||
|
||
```bash | ||
docker-compose build | ||
``` | ||
|
||
3. Create new Project in the Industrial Edge Management under **"My Projects" -> "Create Project"** | ||
 | ||
|
||
4. Create an Application and specify the required information: | ||
 | ||
|
||
5. Go-To IE Publisher, and select newly created App. Then select **"+Configurations"** | ||
 | ||
|
||
6. Add a new Configuration and enter all required fields. In the final step, add the file contained in **/cfg-data/** as a template | ||
|
||
 | ||
|
||
 | ||
|
||
7. Now select **"Add New Version"** and select **docker-compose v2.4** | ||
 | ||
8. In the top right corner select **"Import YAML file"** and select the **docker-compose.yml** file from your directory. Click **"OK"** | ||
9. **Optional:** Configure a reverse proxy in the "Network"-section of the grafana service: | ||
 | ||
**Notice:** Port exposure must be removed in this case. To do this, simply select the trash-icon in the very bottom. | ||
**Save** changes. | ||
10. Select **"Review"** then **"Validate & Create"** on the top right. Then select **"Create"** | ||
 | ||
11. Afterwards, select **"Start Upload"**. | ||
 | ||
12. Once the App is successfully uploaded to your IEM, Go-To **"My Projects"** and select the newly created Application. Then select **"Install"** | ||
 | ||
13. In the **"Configurations"**-Tab click on the pencil to review your configuration file. Based on this config, you can configure the Application to use a different database-name, different credentials for the IE Databus or a different Datasource name. "DATA_SOURCE_NAME": "**PLC_1/default**" was selected here because our PLC-Name in SIMATIC S7-Connector is "PLC_1" and we are using Bulk-publish, so we need the keyword "default". | ||
 | ||
14. Install the Application on your Edge Device and remember to select this configuration file. | ||
15. Open Grafana and login with following credentials, afterwards change password if needed: | ||
username: **admin** | ||
password: **admin** | ||
 | ||
16. Go to **Data Sources** | ||
 | ||
17. add a new Datasource (InfluxDB), and enter the address **influxdb:8086**. | ||
 | ||
18. In the bottom of the Datasource configuration, enter the database name **databus_values**. Then select **Save & Test**. | ||
 | ||
You should receive a notification "Data source is working". If not, you might have selected a different name in the config file. | ||
19. Make sure the S7-Connector Project is started and your PLC is in Start Mode. Set "GDB".hmiSignals.HMI_Start to TRUE on your PLC. | ||
20. In Grafana, Add a new Panel in the Dashboard section. You will be able to select and configure your Datapoints. | ||
 | ||
21. Select the values you would like to plot and remove the **"Group By" options** and the **"SELECT mean(value)"** option. | ||
 | ||
22. When finished with the dashboard, save it, then select settings in the top section to export it as a JSON-file. | ||
 | ||
Save its content as **"operation-panel.json"**. To learn how to incorporate this dashboard into your application, Check out **"Archiving and Operation"**. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#start with a nodejs base-image | ||
FROM node:12.18.3-alpine | ||
|
||
WORKDIR /usr/src/app | ||
|
||
#install required nodejs packages | ||
RUN npm install influx | ||
RUN npm install mqtt | ||
|
||
#copy the nodejs script into the container | ||
COPY . . | ||
|
||
#set start command for container | ||
CMD [ "node", "app.js" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
Copyright 2020 Siemens AG | ||
This file is subject to the terms and conditions of the MIT License. | ||
See LICENSE file in the top-level directory. | ||
*/ | ||
|
||
const fs = require('fs'); | ||
const Influx = require('influx'); | ||
const mqtt = require('mqtt'); | ||
|
||
const pathConfig = '/cfg-data/env-config.json'; | ||
|
||
let configbuffer = fs.readFileSync(pathConfig); | ||
console.log("configbuffer: " + configbuffer); | ||
envconfig = JSON.parse(configbuffer); | ||
|
||
|
||
/* Init Env Variables */ | ||
const MQTT_IP = envconfig.env.MQTT_BROKER_SERVER || 'ie-databus'; | ||
const MQTT_TOPIC = envconfig.env.MQTT_TOPIC || 'ie/d/j/simatic/v1/s7c1/dp/r/'; | ||
const DATA_SOURCE_NAME = envconfig.env.DATA_SOURCE_NAME || 'PLC_1/default'; | ||
const MQTT_USER = envconfig.env.MQTT_USER || 'edge'; | ||
const MQTT_PASSWORD = envconfig.env.MQTT_PASSWORD || 'edge'; | ||
const INFLUXDB_IP = envconfig.env.INFLUXDB_IP || 'influxdb'; | ||
const INFLUXDB_DATABASE = envconfig.env.INFLUXDB_DATABASE || 'databus_values'; | ||
|
||
//read from databus | ||
/* MQTT Connection Option */ | ||
const options = { | ||
'clientId': 'mqttjs_' + Math.random().toString(16).substr(2, 8), | ||
'protocolId': 'MQTT', | ||
'username': MQTT_USER, | ||
'password': MQTT_PASSWORD | ||
} | ||
|
||
/* Connect MQTT-Client to Databus (MQTT-Broker) */ | ||
var client = mqtt.connect('mqtt://' + MQTT_IP, options); | ||
|
||
/* Subscribe to Topic after connection is established */ | ||
client.on('connect', () => { | ||
console.log('Connected to ' + MQTT_IP); | ||
client.subscribe(MQTT_TOPIC+DATA_SOURCE_NAME, () => { | ||
console.log('Subscribed to ' + MQTT_TOPIC+DATA_SOURCE_NAME); | ||
}); | ||
}); | ||
|
||
//define influxdb | ||
const influx = new Influx.InfluxDB({ | ||
host: INFLUXDB_IP, | ||
database: INFLUXDB_DATABASE, | ||
port: 8086, | ||
username: 'root', | ||
password: 'root', | ||
schema: [ | ||
{ | ||
measurement: "uihqiuwhe", | ||
fields: { | ||
value: Influx.FieldType.FLOAT | ||
}, | ||
tags: [ | ||
'host' | ||
] | ||
} | ||
] | ||
}) | ||
|
||
//create database | ||
function createDatabase() { | ||
influx.createDatabase(INFLUXDB_DATABASE) | ||
console.log("database created"); | ||
} | ||
|
||
//wait 12 seconds before creating database (influx container needs a while to initialize) | ||
setTimeout(createDatabase, 12000); | ||
|
||
/* Publish response after recieved message*/ | ||
client.on('message', function (topic, message) { | ||
msg = message.toString() | ||
console.log(`Recieved message ${msg} on MQTT-Topic ${MQTT_TOPIC+DATA_SOURCE_NAME} responding with corresponding answer`) | ||
//write msg to influx | ||
var jsonmsg = JSON.parse(msg); | ||
console.log("received objects: "); | ||
console.log(jsonmsg.vals); | ||
jsonmsg.vals.forEach(element => { | ||
influx.writePoints([ | ||
{ | ||
measurement: element.id, | ||
fields: { value: Number(element.val) }, | ||
} | ||
]) | ||
.catch(error => { | ||
console.error(`Error saving data to InfluxDB! ${error.stack}`) | ||
}) | ||
}) | ||
}); |
Oops, something went wrong.