0% found this document useful (0 votes)
1 views3 pages

C++ EIBA OPC Client development

The document is a guide for developing an OPC Client in C++ by EIBA s.c., detailing the use of COM interfaces and memory management. It outlines three main interfaces: OPC Common, OPC Data Access, and OPC Alarm & Event, providing insights into their usage and implementation. The document emphasizes the importance of understanding COM and offers references for further reading.

Uploaded by

Mohamed Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views3 pages

C++ EIBA OPC Client development

The document is a guide for developing an OPC Client in C++ by EIBA s.c., detailing the use of COM interfaces and memory management. It outlines three main interfaces: OPC Common, OPC Data Access, and OPC Alarm & Event, providing insights into their usage and implementation. The document emphasizes the importance of understanding COM and offers references for further reading.

Uploaded by

Mohamed Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Created by: Ruben

EIBA s.c.

Title
Category
Filename: EIBA C++ OPC Client development.doc

Version 1.0
Title– Category Version: 1.0
C++ EIBA OPC Client development.doc Date: 2006-02-14

Table of Contents
1 Introduction 3
1.1 C++ 3
1.2 General notes 3
1.3 3 Interfaces 3
1.4 OPCCommon Interface (opccomn-1.h / opccomn_i.c) 3
1.5 OPC Data Acces (opcda.h / opcda_i.c) 3
1.6 OPC Alarm & Event Interface (opc_ae.h / opc_ae_i.c // opcaedef.h) 3

2 Start of body Error! Bookmark not defined.


2.1 First Chapter Error! Bookmark not defined.
2.1.1 First subchapter Error! Bookmark not defined.

3 Index Error! Bookmark not defined.

Confidential. All rights reserved.  EIBA s.c., 2003 Page 2 of 3


Title– Category Version: 1.0
C++ EIBA OPC Client development.doc Date: 2006-02-14

1 Introduction
1.1 C++
Unlike VB, OPCFoundation recommends to develop OPC Clients in C++ without the automation
wrapper (opcdaauto.dll) (there is a way to use automation, but not yet used by EIBA).
This means a bigger degree of freedom since COM-Interfaces are directly accessed/programmed in C++
interface. But of course a down-side is that it might take longer to implement.
1.2 General notes
We are using COM here, so it is advised to read more and be customed with COM.

Client is responsible for memory management in COM programming. So don’t forget to clear memory
after using Interfaces with ‘out’ and ‘in/out’ parameters, including elements that is pointed to by them!

Adviced reference document: from OPC Foundation:


OPC (Data Acces-Common-Allarm & Events) Custom Interface Standard
1.3 3 Interfaces
We could distinguish 3 Interfaces in OPC (which are also available as 3 separate (C++)header files
from OPCFoundation):
• OPC Common Interface (Required by all OPCServers)
• OPC Data Acces Interface(Required by all OPC DA Servers)
• OPC Alarm / Event Interface (Required by all OPC AE Servers)
• (Am I correct here ? Ain’t I mixing 2 different things ?)

Check here (http://www.opcfoundation.org/04_tech/04_com_downloads.asp#c) for all C++ files


related to OPC
1.4 OPCCommon Interface (opccomn-1.h / opccomn_i.c)
Here we have some Interfaces from an OPC Client used by an OPCServer (e.g. So OPC Server shuts
down and notifies all clients about this).

Also an interface from an OPC Server (object) used by the client to list all available and registered OPC
servers is found within. Note, however, that this can be done by registry reading also without having to
use this interface (see examples for more info.)

1.5 OPC Data Acces (opcda.h / opcda_i.c)


This is were most action takes place.
Normally you would use a toolkit in C++ because the COM-programming is more complicated than the
Automation interface. However, this is free of choice. One can always copy and paste the source file
available at EIBA.

Anyway here is a little walk-through from a little EIBA-OPC Client.


1. Add these includes to your main header file of the application (e.g. “OPCTest.h”):
#include "opcda.h"
(#include "opcda_i.c")
and make sure that the development framwork (like Visual studio C++) knows where to find
those files (one can always copy them to the porject’s Application directory).
2. You might want to include AFXPRIV.H from which you can use some standard macro’s to
convert between UNICODE (used in COM!!) and general strings. (e.g. T2W, _T, …).
If you do this put USES_CONVERSION in your classes.
3. I had some problems with double IID definitions. I just commented all lines with
“EXTERN_C”
1.6 OPC Alarm & Event Interface (opc_ae.h / opc_ae_i.c // opcaedef.h)

Confidential. All rights reserved.  EIBA s.c., 2003 Page 3 of 3

You might also like