0.01
No commit activity in last 3 years
No release in over 3 years
A simple DCOM OPC library for ruby that allows simple access to OPC servers but with poor efficiency
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 1.2.9
 Project Readme

PicOpc¶ ↑

Description¶ ↑

Pico OPC is a small library for Ruby 1.9 on Windows that can communicate with OPC (OLE for Process control) servers. OPC is frequently used for process control applications (eg. PLC programming, factory systems). Using this library it is possible to automate testing of such systems.

Since the library is based on an inefficient command set (only reads/writes one value at a time, without callbacks), and is still in an early version, don’t use this library for mission critical applications.

For a more full featured OPC library i recommend OpenOPC written in Python (openopc.sourceforge.net/). This package also has some very useful command line tools that work well with PicOpc.

PicOpc supports ‘Classic’ OPC - ie DCOM based. All commands are blocking (ie. program halts until operation has completed)

To run the tests, you must install the rspec gem and the free Matrikon OPC Simulation application.

Examples¶ ↑

Simple example¶ ↑

This simple example covers most functionality:

require ‘picopc’

PicOpc.connect ‘Matrikon.OPC.Simulation’ do |opc| # Read a variable puts opc.read(‘Random.Int1’) # write a variable opc.write(‘Bucket Brigade.String’, ‘PicOpc Rules!’)

# Alternate syntax puts opc opc[‘Bucket Brigade.String’] = ‘PicOpc Rules!’

# Defining tags with shortcuts opc.tag ‘Random.Int1’, :ri opc.tag ‘Bucket Brigade.String’, :bbs puts opc.ri opc.bbs = ‘PicOpc Rules!’ end

Note that all exceptions thrown are of the class PicOpcException.

Without a block¶ ↑

If you don’t want to use a block you can do this:

opc = PicOpc::Client.new ‘Matrikon.OPC.Simulation’ puts opc.read(‘Random.Int1’) opc.cleanup

Cache option¶ ↑

Sometimes you may want to tweak the :cache option PicOpc.connect ‘Matrikon.OPC.Simulation’, :cache => true { |opc| … }

Using cached reads is a lot faster, but depends on your OPC server to update the values from it’s source (usually the PLC). Default behaviour is to read from the device.

Adding a common tag prefix¶ ↑

The :prefix options allows you to add a common prefix to all tags added to the PicOpc client object

PicOpc.connect ‘Matrikon.OPC.Simulation’, :prefix => ‘Bucket Brigade.’ do |opc|

# prefix is added to tagname

opc.write(‘String’, ‘PicOpc Rules!’) opc = ‘PicOpc Rules!’

opc.tag ‘String’, :bbs opc.bbs = ‘PicOpc Rules!’ end

Install¶ ↑

If you have not yet converted to gemcutter, first perform:

[sudo] gem install gemcutter
[sudo] gem tumble

Then:

[sudo] gem install tallakt-picopc