Installing OpenOPC


OpenOPC for Python is a free, open source OPC (OLE for Process Control) toolkit designed for use with the popular Python programming language created by Barry Barnreiter on Windows environments. More information on http://openopc.sourceforge.net/about.html

I had a few issues getting it to work. Mostly related to the settings on the OPC Server which in my case was a Yokogawa system.

Install and use client

Download and install OpenOPC from sourceforge. I used 1.3.1: https://sourceforge.net/projects/openopc/files/openopc/

This link inlcude decent documentation as a pdf document as part of download. If you are using 64-bit Python then you will also have to update the 64-bit DLL. Graybox have released a free version on http://www.gray-box.net/download_daawrapper.php. Download zip/dll, unarchive and place dll in c:\windows\system32. Register the DLL with c:\windows\system32\regsvr32.exe gbda_aut.dll.

You can connect directly to a OPC if you are running client on a Windows box. If you are on a non-windows environment, you have to also install the OpenOPCGateway as a service. I could not make this gateway work with Linux clients so I developed a Python based Rest API which works fairly well. API is available on Git Hub. Usage documentation is here

Connection example using python without Gateway. Change into the OpenOPC src directory and:

import OpenOPC
opc = OpenOPC.client()
opc.servers()

As I was running the Matrikon Simulator, i got this back:

['Matrikon.OPC.Simulation.1']

I had setup a single Random.Real4 item on the simulator. Here are a few examples of queries:

opc.connect('Matrikon.OPC.Simulation')
opc.read('Random.Real4')

(5176.14501953125, 'Good', '03/07/16 09:07:49')

List item groups:

opc.list()
[u'Simulation Items', u'Configured Aliases']

opc.list('Simulation Items')
[u'Bucket Brigade', u'Random', u'Read Error', u'Saw-toothed Waves', u'Square Waves', u'Triang
u'Write Only']

opc.list('Simulation Items.Random')
[u'Random.ArrayOfReal8', u'Random.ArrayOfString', u'Random.Boolean', u'Random.Int1', u'Random
andom.Money', u'Random.Qualities', u'Random.Real4', u'Random.Real8', u'Random.String', u'Rand
u'Random.UInt2', u'Random.UInt4']

opc.info()
[('Protocol', 'OpenOPC'), ('Gateway Host', 'pc1400:7766'), ('Gateway Version', '1.3.1'), ('Cl
ion'), ('Client Name', u'OpenOPC'), ('OPC Host', 'pc1400'), ('OPC Server', u'Matrikon.OPC.Sim
ng'), ('Version', '1.5 (Build 0)'), ('Browser', 'Hierarchical'), ('Start Time', '03/07/16 08:
03/07/16 09:13:42'), ('Vendor', u'Matrikon Inc (780) 448-1010 http://www.matrikonopc.com')]

Interface with Yokogawa Exaquantum

Client OPC environment needs to be on a Windows client as it requires DCOM to communicate with the OPC server. To facilitate access for the Linux servers, i could not make the OpenOPCGateway work from a Linux environment (or windows). Instead, the approach is to write http2opc application to act as a shim between a Rest API call and the OPC server using OpenOPC python module as the opc client. API Code is available on Git Hub. Usage documentation is here

For the OPC client to work even on windows, several things have to be configured and installed.

Exaquantum requires specific client drivers installed. Follow these instructions to complete installation:

Open the Exaquantum Installation Guide (pdf is on the Exaquantum server under Start Menu -> Program Files -> Exaquantum -> Documentation folder
See chapter 2.10 “Exaquantum OPC Client Support

Follow the instructions to install this Exaquantum OPC Client on your PC that you are running OpenOPC and Python. You need to install it as the user that you are running the OpenOPC as – e.g. QuantumuserMatz. You also need the Exaquantum R2.85 installation disks for this. Don’t forget the DCOM config in appendix C that the manual mentions to do with the OPC_Process user account. Yup, its pretty messy.

It is very important that the client pc have the same Quantumuser set up on local pc as DCOM uses this to authenticate.

The OPC drivers are all 32-bit drivers. They will not work with a Python 64 bit environment. I installed Python 2.7 32-bit in a separate directory. No need to deinstall 64-bit, they can coexist but you have to change the PYTHONPATH and PATH directories. OpenOpc also needs pywin32 which is downloadable from https://sourceforge.net/projects/pywin32/files/. Make sure it is 32-bit.

Simple test to make sure your OPC environment is working is to run following command against the OPC server (in this case 128.100.1.21). Change to OpenOpc src directory and:

python opc.py -i -h 128.100.1.21

This should return connection variables for the server similar to these. If you get any errors here, the API will not work either:

Protocol DCOM
Class Matrikon.OPC.Automation
Client Name OpenOPC
OPC Host 128.100.1.21
OPC Server Yokogawa.ExaopcDAEXQ.1
State Running
Version 3.72 (Build 0)
Browser Flat
Start Time 02/17/16 11:55:59
Current Time 03/11/16 13:17:22
Vendor Yokogawa Electric Corporation Exaopc OPC Interface Package

If 32-bit environment is not working, it will look like this:

Connect to OPC server 'Yokogawa.ExaopcDARDSTS1' on '128.100.1.21' failed - Conne
ct: Class not registered