This project contains a Lablink setup for connecting an OPC UA server with a data source and a plotter:
- A CSV client acts as a data source, reading CSV data and sending it to the OPC UA client.
- The OPC UA client is connected to a OPC UA server, and has 2 purposes:
- Whenever new input data arrives, the client updates the values of the associated variables on the server
- At the same time, the client is subscribed to certain variables on the server. Whenever they change their values, it sends these values to the plotter.
- The plotter displays all incoming data on the screen.
NOTE: In this specific example, the variables that are updated by the UPC UA client and the variables it listens to are identical. In a real-world setup this would not make a lot of sense, but it is good enough for the purpose of this example.
NOTE:
All following instructions are for Windows, using either the command prompt (cmd.exe
) or by double-clicking batch scripts (files of type *.cmd
).
Running the setup on Linux works analogously, using the correspondig commands from a command shell.
You need to have the following software installed for running this setup:
- Java Development Kit: for instance the Oracle Java SE Development Kit 13 or the OpenJDK
- MQTT broker: for instance Eclipse Mosquitto or EMQ
- Python: tested with Python 3.8.5
Make sure that the JAVA_HOME
environment variable is set and points to your JDK installation:
- open the system properties (
WinKey
+Pause
or go to Settings => System => About => System Info => Advanced System Settings) - select the Advanced tab, then the Environment Variables button
- select and edit the
JAVA_HOME
variable in the user variables, e.g., adding C:\Program Files\Java\jdk-13.0.2.
All required Lablink packages are listed as dependencies in file pom.xml
(a Maven project configuration file).
To download all required Lablink packages, open the command prompt, change to the project's root directory and type:
mvnw package
This setup uses a simple OPC UA server, implemented using the FreeOpcUa Python library.
To install all required Python dependencies, open the command prompt, change to the project subdirectory setup\1_opcua_server
and type:
pip install -r requirements.txt
To start the OPC UA server, open the command prompt, change to the project subdirectory setup\1_opcua_server
and type:
python test-opcua-server.py
The configuration for all Lablink clients (incl. the CSV data for the CSV client) is contained in file setup\2_lablink_config\opcua-client-test-config.db
.
To start the Lablink config server, simply double-click batch script setup\2_lablink_config\run_config.cmd
.
Alternatively, you can open a new command prompt, change to the project subdirectory setup\2_lablink_config
and type:
NOTE: Once the server is running, you can view the available configurations in a web browser via http://localhost:10101.
NOTE: A convenient tool for viewing the content of the database file (and editing it for experimenting with the setup) is DB Browser for SQLite.
All batch scripts for running the Lablink clients can be found in project subdirectory setup\3_run_test
:
- OPC UA client:
opcua-client.cmd
- CSV client:
csv-client.cmd
- Plotter:
plot.cmd
- Data point bridge:
dpb.cmd
To start the Lablink clients, simply double-click the corresponding batch scripts.
Alternatively, you can open a new command prompt for each, change to the project subdirectory setup\3_run_test
and type the script name.
NOTE: You can start the Lablink clients in arbitrary order.
After running the clients for some time, the plotter output should look similar to this: