Engee documentation
Notebook

Example of data exchange between Engee and Prosys OPC Simulation Server over OPC UA

Introduction

This example shows how to organize data exchange over the OPC UA protocol between a model in Engee and an external OPC UA server using the example of Prosys OPC UA Simulation Server.\ The
scenario demonstrates two-way operation:

  • reading values from the OPC UA server in Engee;
  • writing values from the Engee model back to the server.

The standard Prosys simulation server is used as the test data source, and Engee uses the OPCUA Client block, which connects to the server and reads the variable Triangle and writes the value to a variable MyVar.

This example is useful as a basic template for integrating the Engee model with industrial systems, controllers, SCADA, and other OPC UA-enabled data sources/receivers.


A brief reference

What is OPC UA?

OPC UA (Open Platform Communications Unified Architecture) is an industrial data exchange protocol designed for reliable and standardized interaction between various programs and devices.

Main Features of OPC UA:

  • platform independence;
  • client-server architecture;
  • the presence of an address space with nodes (nodes);
  • support for reading, writing, subscribing to changes;
  • built-in security mechanisms.

How the exchange works in this example

In the example under consideration:

  • Prosys OPC UA Simulation Server acts as a server;
  • Engee acts as client of OPC UA;
  • the OPCUA Client block in Engee:
  • receives data from the server node Triangle;
  • sends data to the server node MyVar.

Nodes and NodeID

Each variable on the OPC UA server has a node identifier NodeID.
The example uses the following nodes:

  • for reading:
    • Triangle
    • ns=3;i=1006
  • for the record:
    • MyVar
    • ns=3;i=2

Here:

  • ns — namespace index;
  • i — the numeric ID of the node.

The logic of the model

The Engee model implements a typical scheme:

  1. An input data bus is being formed for writing to the OPC UA;
  2. in the field MyVar A test signal is being recorded;
  3. The OPCUA Client block sends this value to the server;
  4. The variable read from the server is extracted from the output bus of the block Triangle;
  5. The result is displayed further according to the scheme for observation.

Prosys OPC UA Simulation Server

A test OPC UA server that provides a set of simulated variables.
At startup, the server generates and uses a connection address like:

opc.tcp://alexevs:53530/OPCUA/SimulationServer

The host name and port may differ on a particular system.
For your own startup, you need to use the address displayed in the Prosys OPC UA Simulation Server window.


Description of the setting

1. Configuring Prosys OPC UA Simulation Server

First, the Prosys OPC UA Simulation Server is started and its status is checked.

After the launch, it can be seen that:

  • the server is in the Running state;
  • The UA TCP protocol is used for connection;
  • connection address:
opc.tcp://alexevs:53530/OPCUA/SimulationServer.
image.png

You can also see the test variables in the folder in the server object tree. Simulation, among which are available, for example:

  • Constant
  • Counter
  • MyVar
  • Random
  • Sawtooth
  • Sinusoid
  • Square
  • Triangle

For a variable Triangle It's visible:

  • NodeId = ns=3;i=1006
  • data type: Double

For a variable MyVar It's visible:

  • NodeId = ns=3;i=2

In the parameters tab Triangle It can be seen that the signal is of the Triangle type, and its range and period are set on the side of the simulation server.

image.png

2. Configuring the OPCUA Client block in Engee

The OPCUA Client block is added to the Engee model and its parameters are opened.

For correct operation, the following basic block settings must be set:

Connection parameters

  • Server address: opc.tcp://alexevs:53530/OPCUA/SimulationServer
  • Security policy: None
  • Message security: None
  • Timeout, s: 2.0

Setting up Reading

A dictionary is set for reading Read variables, to which the variable is added:

  • Triangle("ns=3;i=1006", Float64)

That is, the block should read the node value. Triangle as a number type Float64.

Recording Settings

A dictionary is set for recording Write variables, where it is specified:

  • MyVar("ns=3;i=2", Float64)

This means that the node MyVar the value from the model will be transmitted to the server.

Tire Names

Bus names are also used in the block parameters.:

  • Output Bus Name: OPCOutputBus
  • Input Bus Name: OPCInputBus

This allows you to conveniently organize the exchange of a set of variables through structured buses.


3. Configuring simulation and connection parameters in Engee

The following modeling parameters are defined in the properties of the model:

  • a fixed pitch is used;
  • solver: Euler;
  • integration step: 1e-3 seconds;
  • simulation time: 30 seconds.

To establish a connection between Engee and servers, the PC is installed and Engee.Integration.


4. Assembling the circuit in Engee

The following structure is assembled in the model for testing communication.

image.png

Formation of the input bus for recording

First, a tire blank is created:

  • a transformation of the form is used convert(OPCInputBus, …) to form a tire of the desired type;
  • then the bus assignment block (BusAssignment) is applied, in which the field is selected:
    • MyVar

The test signal from the generator is recorded in this field.

OPCUA Client Block

Prepared tire OPCInputBus connects to the input of the OPCUA Client block.
The block performs two functions simultaneously:

  • accepts data for writing to the server;
  • forms the output bus OPCOutputBus with values read from the server.

Extracting the read value

After the OPCUA Client block, a BusSelector is installed, in which the signal is selected:

  • Triangle

This value is fed further along the circuit for display or analysis.


Description of the work process

Step 1. Launch the OPC UA Server

First, the Prosys OPC UA Simulation Server is started.
It checks that the server is active and the simulation variables are available in the object tree.

At this stage, it's convenient to look at it right away.:

  • server connection address;
  • necessary variables;
    "them NodeId;
  • data types.

The example uses nodes:

  • Triangle for reading;
  • MyVar for the record.

Step 2. Connecting Engee to the server

In Engee, the server address is specified in the OPCUA Client block parameters and security settings are configured.

Since the demo uses a local test server, the following options are selected:

  • Security policy = None
  • Message security = None

After that, the following are added to the block:

  • a readable variable Triangle;
  • a recordable variable MyVar.

Step 3. Generating data for recording

A test signal is created inside the model, which is recorded in the field. MyVar input bus OPCInputBus.

Thus, Engee starts transmitting its own calculated value to the OPC UA server.


Step 4. Reading data from the server

At the same time, the OPCUA Client block reads the value of the variable Triangle from the server and outputs it via the output bus OPCOutputBus.

Then the BusSelector block extracts the field Triangle to use it separately in the model.


Step 5. Launching the model

After running the simulation, Engee establishes a connection to the server.
In the Engee client program.The successful connection status is displayed for integration:

  • the connection to the server is established;
  • the client reconnects/connects to Engee;
  • after that, the model switches to execution mode.

Step 6. Verifying data exchange

After the simulation starts, the Prosys OPC UA Simulation Server window shows a change in variable values.

During the simulation, you can notice. what:

  • for the variable Triangle the current value changes according to the triangular signal;
  • for the variable MyVar the actual value written from Engee also appears.;
  • the operation status is successful.

This confirms that the exchange works both ways.:

  • server → Engee: read Triangle;
  • Engee → server: record MyVar.

In addition, the process supports the ability to change data on the fly - changing the parameters for generating a triangular signal on the server leads to a corresponding change in the displayed signal in Engee.


image.png

Conclusion

As a result of the configuration, a working two-way exchange between Engee and the OPC UA server has been implemented.:

  • Engee successfully connects to Prosys OPC UA Simulation Server;
  • reads the node value Triangle;
  • generates and writes the value to the node MyVar;
  • uses tires OPCInputBus and OPCOutputBus for structured exchange.

This example can be used as a basis for more complex tasks.:

  • connections to real OPC UA servers;
  • exchange of several variables at the same time;
  • integration of Engee models with external automation systems;
  • testing control algorithms on simulation data.

The example demonstrates a basic and visual scenario for integrating Engee with OPC UA.
Its key value is that it shows the full cycle.:

  1. Launching and checking the OPC UA server;
  2. search for the necessary variables and their NodeId;
  3. configuring the OPCUA Client block in Engee;
  4. Bus organization for reading and writing;
  5. Run the model and verify the actual exchange.

For training and demonstration tasks, this example is convenient because Prosys OPC Simulation Server already contains a ready-made set of test variables, which means you can focus on the mechanics of connecting and exchanging data over OPC UA.