OpenOPC and Python Tutorial

My boss gave me a challenge to create a simulation for the field devices our PLC will be talking to. We need to simulate the devices for the factory acceptance testing. Originally I though I would use C#, but ran into a pay wall with the OPC Foundation. They want $15,000 before I can download the source code. A lesser entry fee will get me some of the wrappers, but since I can't see the documentation before I pay I don't know if the wrappers will be sufficient. That price was ok before the connected world, but now community supported projects need to be open and collaborative. Instead I found OpenOPC for Python. The great thing about a Python solution is that I can run it on just about any computer and easily share my code with the community. To get started I installed Python on my Windows 7 machine using the Python for Windows extensions installer. The installer is tricky to download. You need to navigate through the files on sourceforge to the Build 217 and download one of the installers in that folder. The directions on the home page appear to be incorrect. I downloaded the pywin32-217.win32-py2.7.exe and ran it. This will install python and the GUI for Windows. One extra step was needed and that is to open the command prompt and add python to your path. Run this code in the Window's command prompt.
set path=%path%;C:\Python27\
Next I installed OpenOPC from http://sourceforge.net/projects/openopc/files/. I chose the 2.7 version, which corresponds to the version of Python I installed earlier. I ran the .exe and everything installed nicely. Great job OpenOPC on the installer! At this point I started going through the tutorial on OpenOPC and ran into some errors. The error basically said that the module Pyro could not be found. First I tried installing Pyro4 and when that didn't work I installed Pyro3. Installing Pyro3 fixed the problem and now my OpenOPC is working. To install Pyro3 I download the tar.gz from the Python Package Index. Then with 7-zip I untarred it. Then in the Window's command prompt I navigated to the Pyro3 folder and found setup.py.
python setup.py install
This command added the module to python. I went back to the python GUI and started the OpenOPC tutorial over. This time everything worked perfectly and I was able to read tags from the Matrikon demo server that the OpenOPC tutorial suggested I use.

Read More