OpenOPC for Python is a free, open source and easy to use OPC (OLE for Process Control) library designed to be used with the popular Python programming language. The project also includes a Windows gateway service that enable non-Windows clients to also access OPC-DA calls.
The files within this repository allow us to work with recent versions of Python (v3.7+) and Pyro4 (v4.80+).
If you are interested in the original version from Barry Barnreiter, you can go here. However, if you want to try a different fork that also works with Python 3.4+ (if you make some minor changes to the Python source code that affects Pyro4), go to the GitHub version of Anton D. Kachalov by clicking here.
This repository offers the following files:
Follow these steps to prepare your work environment:
pip install Pyro4
or
pip install Pyro4==4.80
OPC_CLASS=Matrikon.OPC.Automation;Graybox.OPC.DAWrapper;HSCOPC.Automation;RSI.OPCAutomation;OPC.Automation
OPC_CLIENT=OpenOPC
OPC_GATE_HOST=192.168.1.96 # IMPORTANT: Replace with your IP address
OPC_GATE_PORT=7766
OPC_HOST=localhost
OPC_MODE=dcom
OPC_SERVER=Hci.TPNServer;HwHsc.OPCServer;opc.deltav.1;AIM.OPC.1;Yokogawa.ExaopcDAEXQ.1;OSI.DA.1;OPC.PHDServerDA.1;Aspen.Infoplus21_DA.1;National Instruments.OPCLabVIEW;RSLinx OPC Server;KEPware.KEPServerEx.V4;Matrikon.OPC.Simulation;Prosys.OPC.Simulation
C:\>set ENV_VAR=VALUE
C:\>set OPC_GATE_HOST=172.16.4.22 # this is an example
1. Win32 platform, using the OpenOPC Gateway Service
Pywin32: optional
Pyro4: required
2. Win32 platform, talking to OPC Servers directly using COM/DCOM
Pywin32: required
Pyro4: optional
3. Non-Windows platform (use of Gateway Service is mandatory)
Pywin32: not applicable
Pyro4: required
Begin to work with this project by doing this:
.zip
file.C:\OpenOPC37
).C:\OpenOPC37
).lib
folder.gbda_aut.dll
) by typing this
in the command line:C:\OpenOPC37\lib>regsvr32 gbda_aut.dll
C:\OpenOPC37\lib>regsvr32 gbda_aut.dll -u
This goal can be achieved by running the "OpenOPCService.py" script with the Python interpreter and the "install" argument (remember to do it as administrator):
C:\OpenOPC37
).src
folder.C:\OpenOPC37\src>python OpenOPCService.py install
Installing service zzzOpenOPCService
Service installed
This task can be completed from one of two ways (make sure to have it installed first):
Start
link on the "OpenOPC Gateway Service" from the
"Services" window (Start -> Control Panel -> System and Security ->
Administrative Tools).net start SERVICE
command like this:C:\OpenOPC37\bin>net start zzzOpenOPCService
C:\OpenOPC37\src>python OpenOPCService.py debug
This task can be completed from one of two ways:
Stop
link on the "OpenOPC Gateway Service" from the
"Services" window (Stop -> Control Panel -> System and Security ->
Administrative Tools).net stop SERVICE
command like this:C:\OpenOPC37\bin>net stop zzzOpenOPCService
If you are going to use this service frequently, it would be better to configure it to start in "automatic" mode. To do this:
Go here for the basic implementation of the library. But, if you want updated procedures using Python 3.4+, see the wiki pages.
A PDF manual for OpenOPC is included in this repository inside the doc
folder, written by the original author. Users are encouraged to also
look at the OpenOPC web site for
additional usage examples that may not be contained in the manual.
The authors of this package are:
Copyright (c) 2008-2012 by Barry Barnreiter (barry_b@users.sourceforge.net)
Copyright (c) 2014 by Anton D. Kachalov (mouse@yandex.ru)
Copyright (c) 2017 by José A. Maita (jose.a.maita@gmail.com)
If you need technical assistance to implement this in a larger project, go to the main site here or here for more detailed information.
This software is licensed under the terms of the GNU GPL v2 license plus
a special linking exception for portions of the package. This license is
available in the LICENSE.txt
file.