DeltaV OPC Data Access Server functional overview

Visual C++ tips

Creating a custom COM client in Visual C++ requires a knowledge of COM programming. The following is a very brief set of steps required to get started with an MFC-based OPC client application.

Adding OLE support to the project

In the pre-compiled header, add:

#include "afxole.h"

Adding OPC support to the project

In the pre-compiled header, add:

#include "opc.h"

In the main application CPP file, add:

#include "opc_i.c"

Opc.h and opc_i.c can be generated from files included at the OPC ftp site (zilker.net/pub/opc).

Adding UNICODE to the project

Change the preprocessor symbol _MBCS to _UNICODE to the preprocessor symbols. An unresolved external on _WinMain@16 will also occur if you fail to add wWinMainCRTStartup into the EntryPointSymbol section of the link output category after adding _UNICODE to the preprocessor symbols.

Adding DCOM support

If you plan to use DCOM, you will also need to define the symbol _WIN32_DCOM.

Handling messages

Any OLE thread must dispatch messages in order to function correctly. OLE threads that do not dispatch messages can cause message broadcasters to hang. For more details on this subject, refer to article Q136885 - OLE Threads Must Dispatch Messages in Microsoft's OLE knowledge base.

Writing a client for redundant DeltaV OPC Data Access Server

A redundant DeltaV OPC Data Access Server is an in-process server, implemented by a dynamic-link library (DLL) module. If the design of your OPC client explicitly excludes interfacing with an in-process server, the client will fail if it attempts to connect to a redundant DeltaV OPC Data Access Server.

In an OPC client that does not exclude interfacing with an in-process server, the third parameter of its call to CoCreateInstance or CoCreateInstanceEx must resolve to CLSCTX_INPROC_SERVER, by referencing CLSCTX_SERVER or CLSCTX_ALL, as in the following example:

CoCreateInstanceEx(CLSID_OPCServer, NULL, CLSCTX_SERVER, pServerInfo, cmq, queue);

where CLSCTX_SERVER and CLSCTX_ALL are defined as follows:

#define CLSCTX_SERVER (CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER)
#define CLSCTX_ALL (CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER)
Note

If you use an OPC client that you acquired from an outside vendor, you should contact the author to verify that the client is not written to exclude interfacing with an in-process server before using it with redundant DeltaV OPC Data Access Server.

For more information about interfacing with in-process servers, refer to the Microsoft Developer Network Library articles on Component Object Model (COM) programming at http://msdn2.microsoft.com/en-us/library/ms687205.aspx.