Professional OPC
Development Tools

logos

Get OPC data into Perl

With QuickOPC, you can create new OPC Perl solutions, or integrate OPC functionality into your Perl scripts.

How does QuickOPC allow integration of OPC data into Perl?

  • QuickOPC provides COM (OLE Automation) objects with easy interfaces to perform all kinds of OPC tasks
  • You instantiate one of the main QuickOPC objects.
  • You call methods that perform operations such as OPC reading or writing.

Read More

Useful links: Examples / Knowledge Base

OPC Perl Example

If you want see it for yourself, we have an example that shows how to read a value of an OPC item in Perl and print it out. It is just a few lines of code, and for OPC Data Access server, it looks like this:
use Win32::OLE;
# Create EasyOPC-DA component $client = Win32::OLE->new("OpcLabs.EasyOpc.DataAccess.EasyDAClient");
# Read item value and display it print $client->ReadItemValue("", "OPCLabs.KitServer.2", "Demo.Single");

The example connects to Simulation OPC Server, but you can quickly modify it to connect to your OPC server instead. Simply download the product and then open the project.

It is also possible to subscribe to OPC item changes in Perl. We have tested this example with ActivePerl v5.14.2.

With an OPC Unified Architecture (OPC UA), the code is just as simple:

use Win32::OLE;

# Create EasyOPC-UA component 
$client = Win32::OLE->new("OpcLabs.EasyOpc.UA.EasyUAClient");

# Read node value and display it
print $client->ReadValue("opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", 
   "nsu=http://test.org/UA/Data/;i=10853");

The PubSub variety of OPC UA (as opposed to client-server) uses message-oriented middleware to deliver the data. QuickOPC supports it as well. Code example is available in the documentation, and installed with the product.

 

Footnote & required disclosure: QuickOPC (including its Options) is a software development kit (SDK) for development of OPC clients and subscribers. Installing QuickOPC or its Options does not change system settings.