OPC/en

Aus expecco Wiki (Version 2.x)
Zur Navigation springen Zur Suche springen

OPC is a wellknown communication framework used in manufactoring, factory automation and the IoT ("Internet of Things").

Traditionally, OPC used COM/DCOM as underlying transport and was therefore more or less bound to Windows architectures (or required expensive COM/DCOM frameworks under Unix/Linux). In contrast, the more recent OPC-UA ("OPC-Unified Architecture") uses standard TCP communication on top of which either binary data or XML-based HTTP requests are exchanged.

This plugin provides both a server and a client implementation of OPC-UA, by interfacing an open source (and license free) OPC-UA implementation written for NodeJS and/or Python.

Due to functional limitations of the NodeJS framework, the library is supplemented and replaced by an interface to a corresponding Python based library. This is ongoing work; for details, see the OPC-UA interface library for its current status.

NodeJS Version[Bearbeiten]

Node Installation[Bearbeiten]

NodeJS is mandatory to be installed on our machine.

Check if node is already present (by entering on the command line):

node --version

or open the expecco settings-dialog and navigate to "Execution" → "External Script Interpreters" → "Node". Click on the "?"-button to verify the installed version.
If NodeJS is not installed, download and install it from "https://nodejs.org/en/download".

Also make sure that the node package manager ("npm") is installed with

npm -v

More details on the NodeJS installation is found in the "Installing additional Frameworks" page.

Node-OPC-UA Installation[Bearbeiten]

"node-opcua" is an open source, license free and pure JavaScript implementation of OPC-UA for NodeJS. For more information, consult "https://github.com/node-opcua".

Using "npm", the node package manager, install the "node-opcua" package:
Disclaimer! using install in this way will install the files locally in your current directory. If you wish for a globally available module, add a -g at the end.

npm install node-opcua 

and optionally, the demo examples with:

npm install node-opcua-samples

Verify that the modules are present in your "~/node_modules" folder. (the OPC_UA_Interface library contains a action block named "Assert "node-opcua" module is present" to verify that the module is found.

If it is not found (typically, because the "node_modules" folder is not configured to be found by node), you can adjust the NODE_PATH setting in the "Extras" → "Settings" → "External Script Interpreters" dialog, or set it in the shell environment before starting expecco.

Launching a Demo Server[Bearbeiten]

The node-opcua Sample Server[Bearbeiten]

If you installed the samples (as above), a server can be started with:

node ~/node_modules/node-opcua-samples/bin/simple_server.js

If warning messages about missing modules are shown, you may restart it after installing additional packages:

npm install usage

Connecting to the Demo Server[Bearbeiten]

The node-opcua Sample Client[Bearbeiten]

For a quick smoke test, run the node sample client against the above sample server:

node ~/node_modules/node-opcua-samples/bin/simple_client.js 

Using the Library OPC_UA_Interface

First and foremost, you can find documentation as well as a working example for each action in the "Documentation" and "Test/Demo" Sections respectively.

Testsuite Samples[Bearbeiten]

You will find a server to test against in the library under "MenuActions" / "Start Sample Server in Background".
It runs the attached "opcuaDemoServerScript.js" script which you can change freely for your own testing purposes.
If you wish, you may also try the "Server" blocks (see the attached readme in that folder) which enable you to create a very basic server as well.

Python Version[Bearbeiten]

-- to be documented --

Troubleshooting[Bearbeiten]

The following errors may or may not occur, here is how you deal with them:

  • "node-opcua not found"
    may occur if the module path to opcua is not set correctly in the Expecco settings.
    This may also occur with a global opcua installation with Windows10; if this should apply to you, do a local installation instead.
  • "ERROR_write other"
    may occur if you manually shut down a node server which the still running bridge tries to access.
  • "port undefined" or "already in use"
    may occur if you are trying to start an opc server while another still holds the tcp socket you are trying to use.
    If your created session runs into a timeout, it may be that node still holds an expired session token.
    In that case (within expecco) navigate to "Plugins" → "Bridges" → "Node Bridge" → "Disconnect All Open Connections" and try again.



Copyright © 2014-2024 eXept Software AG