Delphi OPC Programming

Introduction

This document, and the ZIP archive of which it is part, are intended to help give a brief introduction to OPC (formerly OLE for Process Control) development using Embarcadero (formerly Borland) Delphi.

The ZIP file contains Delphi translations of the published OPC custom interfaces, i.e. OPC Common 1.1, Data Access 3.0 (and earlier), Alarms & Events 1.10, Historical Data Access 1.2 and Security 1.0.

The code has been confirmed to be compatible with with Delphi 3 to 7, and Delphi 2005 to 2010 for Win32.

The Delphi page at OPC Programmers' Connection also has Delphi source code for a demo OPC client and server.

Version History

September 2nd 2009: Confirmed compatibility with Delphi 2010 (no code changes).

October 5th 2008: Confirmed compatibility with Delphi 2009 (no code changes).

December 11th 2003: Added error codes for Complex Data 1.0. Added OPCHDA_PARTIAL quality for HDA 1.2.

March 10th 2003: Updated for Data Access 3.0.

October 31st 2002: Added support for new OPC Alarms & Events 1.10 interfaces: IOPCEventServer2 and IOPCEventSubscriptionMgt2.

October 22nd 2002: Added support for new OPC Common 1.1 interfaces: IOPCServerList2 and IOPCEnumGUID.

September 13th 2002: Added support for OPC Security 1.0 (unit contributed by Illya Kysil).

September 6th 2002: Corrected OPC_WRITABLE to OPC_WRITEABLE in OPCDA.pas.

September 3rd 2002: Minor changes for compatibility with Delphi 7.0.

August 6th 2002: Updated OPCHDA.pas to correct declaration of IOPCHDA_SyncRead.ReadAttribute (thanks to Arjan Lamaker for pointing out the error). Also updated Internet addresses in file header comments.

July 26th 2002: Updated OPCHDA.pas to explicitly declare const CATID_OPCHDAServer10 as a TGUID.

July 22nd 2002: Updated OPCDA.pas with corrected item property IDs (200 to 207) from Data Access 2.05A specification.

July 5th 2001: Confirmed compatibility with Delphi 6.0 (no code changes).

June 20th 2001: Added support for OPC Historical Data Access 1.1 (with help from Illya Kysil).

June 19th 2001: Removed unneeded IID_IEnumString declarations.

March 7th 2001: Pascal type definitions modified for all interface input parameters which are of array types. This is to more accurately indicate the required data. As a consequence, any client which implements the IOPCDataCallback interface will need minor code changes.

Factored out common type definitions into new file OPCtypes.pas; this should be added to the uses list of all source files which make use of OPC interfaces. This change is needed to avoid compilation errors when using the Data Access and Alarms & Events interfaces from the same unit.

Definition removed for type PWORDARRAY to prevent possible conflict with the Delphi SysUtils unit.

October 26th 1999: Extra type definitions added to OPCDA.pas, for use with connection points.

October 12th 1999: OPC interface files and sample client program now packaged separately.

September 11th 1999: Now works with Delphi 3, 4 and 5.

June 22nd 1999: Original version, compatible with Delphi 4.

File List

Inside the ZIP archive you will find the following files.

OPCCOMN.pas   OPC Common 1.1 interfaces
OPCDA.pas   OPC Data Access 3.0 (and earlier) interfaces
OPC_AE.pas   OPC Alarms & Events 1.10 custom interfaces
OPCerror.pas   OPC error and status codes
OPCHDA.pas   OPC Historical Data Access 1.1 custom interfaces
OPCSEC.pas   OPC Security 1.0 custom interfaces
OPCtypes.pas   Shared type definitions
readme.htm   This file

Converting the OPC Definitions

In each case, the initial conversion of the OPC interfaces was performed using Delphi's standard 'Import Type Library' function, specifying the relevant proxy/stub DLL as the type library file. This results in a set of definitions which works correctly for the most part, but is not entirely satisfactory. There are several reasons for this:

Acknowledgements

Some of the work of porting the OPC interfaces to Delphi was performed initially while working at Eurotherm Limited. Their cooperation in allowing this code to be published is gratefully acknowledged. The iTools suite of applications from Eurotherm includes several OPC client programs developed using Delphi.

Thanks are also due to the many Delphi OPC developers who have contributed ideas, suggestions, and corrections.

Disclaimer

Although every effort has been made to faithfully convert the original C and IDL declarations to Delphi, and the results have been used and tested extensively, I can't of course actually guarantee their correctness. Neither will I be held responsible for any loss or damage arising from their use.

I would be grateful to know of any problems with these files.

Mike Dillamore
OPC Programmers' Connection
http://www.opcconnect.com/
mailto:opc@opcconnect.com

September 2nd 2009