OPC Server Development Toolkit

* * * Affordable, Reliable, Guaranteed * * *

Using WinTECH Software's OPC Server Rapid Development Toolkit, you can be up and running a fully functional OPC Server, integrated with your own data, in less than a day's time. All you have to do is download the toolkit below, link the dll in with your application, and pass your data points to the dll using the simple API as included with the documentation. The dll takes care of all the details necessary to interface to OPC Clients using either OPC 1.0, OPC 2.0 or OPC 3.0 Data Access Standards. All required OPC interfaces are supported by the dll, including the Browse functions. The demo version of the dll, (available below), allows you to create a complete working OPC Server solution for your custom application without cost or obligation. The API is fully documented and supported. After you have successfully integrated your application's data with the dll, and are satisfied that it works to your satisfaction, you may purchase a developer's license for the toolkit to remove the time limit. (The demo version of the dll will time-out after 30 minutes of operation.) The complete working source code for the dll is also available for those who want complete protection for their investment.

Why spend months of development time pouring over the OPC/DCOM specs before you begin developing? Why spend thousands more dollars to purchase a toolkit from one of the "Major Commercial Vendors"? We have over 20 years of software design experience in process-related industries. Our toolkits are robust, efficient, and field-proven in hundreds of locations through-out the world. Other vendors may sell toolkits that work equally as well, but there are none better, and certainly none as economical as those provided by WinTECH Software Design. Our Developer Toolkits are our main business. We were the first to provide fully functional, readily downloadable demos with an openly published API. This allows potential users to create and test server and client applications integrated with their own data without cost or obligation. Other vendors may sell their toolkits as a side-line and are often more interested in marketing their own OPC-based solutions than they are in supporting your development efforts. At WinTECH Software Design, your application is what's important to us. We stand behind the software with an unconditional guarantee. Technical support is without charge and licensed users have access to all future releases of the product. Please take the time to download and evaluate the demo toolkit(s) and if you have any comments or questions, please email us at: opc@win-tech.com

OPC Foundation Member

Download the Server Toolkit
WTOPCSvr.zip (413K)

WTOPCSvr User's Guide

The WinTECH Software Rapid Development DLL for OPC Servers, (WTOPCSvr), provides an easy to use API for integrating custom data with OPC. All the details of COM and OPC are handled by the DLL, which allows an application to present data points to OPC at a high-level, without having to be concerned with the actual implementation of the underlying interfaces. The DLL may be easily integrated with existing applications, or new ones. All required OPC Interfaces are supported for both OPC 1.0 and OPC 2.0 Data Access Standards as well as the Browse Interface.

WTOPCSvr basically operates as a data librarian. The controlling application creates Process Tags by passing a name and value to the DLL. The DLL records the data point and makes it available to any OPC Client application by name. The controlling application may change the value of the data at any time, and all attached clients would be automatically notified. Callback notification is provided for any Process Tag that is modified by an OPC Client connection. (The application has control over which tags are OPC_WRITEABLE.)

Creating a Custom OPC Server using WTOPCSvr.DLL

Installing the OPC Proxy DLLís

The first step in creating an OPC Server is to obtain and install the OPC Proxy/Stub DLLís from OPCFoundation. Theses are available from the OPC Foundation's public download web page located at: (http://www.opcfoundation.org). Just follow the links through "Technical Information", "Common Downloads for Programmers".

  • Download and upzip the proxy/stub files.
  • Copy opccomn_ps.dll, opcproxy.dll, opcae_ps.dll, opchda_ps.dll to the SYSTEM32 Directory. *Be sure not to overwrite any newer versions*
  • Type REGSVR32 opccomn_ps.dll
  • Type REGSVR32 opcproxy.dll
  • Type REGSVR32 opc_aeps.dll
  • Type REGSVR32 opchda_ps.dll

    Link WTOPCSvr.lib with the Application

    WTOPCSvr.lib contains the export definitions for the DLLís API. Include this file with the project files for the custom application and include WTOPCSvrAPI.h with those modules which will be making calls into the DLL.

    Generate a new CLSID

    Each OPC Server is identified by a unique CLSID. The GUIDGen.exe utility supplied by Microsoft may be used to generate a unique identifier for the new server application. Run GUIDGen.exe, (located in the Visual C++\Bin directory). Generate a new CLSID and copy to the clipboard to be pasted in to your server application as described below.

    Registry Entries

    The WTOPCSvr.DLL exports two API functions that make modifications to the Windows Registry for installation of the custom server.

    UpdateRegistry (GUID CLSID_Svr, CString Name, CString Descr, CString ExePath);

    UnregisterServer (GUID CLSID_Svr, CString Name);

    These functions take as arguments the CLSID generated above, (as well as text strings to identify and describe the new server). While the UpdateRegistry and UnregisterServer functions may be called from the controlling application at any time, it is generally preferred to implement the registry functions based on command-line entries during start-up of the application. A self-registering server would process the \RegServer and \UnregServer command line options similar to the code below, (extracted from OPCSimSvr Application):

    const GUID 
    CLSID_OPCSimSvr = {0x99b8f471, 0xc027, 0x11d2, {0x80, 0xb8, 0x0, 0x60, 0x97, 0x58, 0x58, 0xbe}};
    BOOL COPCSimSvrApp::InitInstance()
    	TCHAR	szTokens[] = _T("-/ ");
    	CString HelpPath;
    	CString	SvrName, SvrDescrip;
    	int	i;
    	HelpPath = AfxGetApp()->m_pszHelpFilePath;
    	i = HelpPath.ReverseFind('\\');
    	HelpPath = HelpPath.Left(i+1);
    	HelpPath += "OPCSIMSVR.EXE";              
    	// Self-Registration code
    	// (look for cmdline options to register & unregister server)
    	SvrName = "WinTECH.OPCServer";
    	SvrDescrip = "WinTECH Software OPC Server Simulator";
    	CString tempCmdLine(m_lpCmdLine);
    	LPTSTR lpszToken = _tcstok(tempCmdLine.GetBuffer(1), szTokens);
    	while (lpszToken != NULL)
    		if (_tcsicmp(lpszToken, _T("UnregServer"))==0)
    			UnregisterServer(CLSID_OPCSimSvr, SvrName);
    			return (FALSE);
    		else if (_tcsicmp(lpszToken, _T("RegServer"))==0)
    			UpdateRegistry (CLSID_OPCSimSvr,
    			return (FALSE);
    		lpszToken = _tcstok(NULL, szTokens);

    Initialization of WTOPCSvr.DLL

    The Windows Registration functions described above may be called prior to the initialization of the WTOPCSvr.DLL. During the self-registration process, the focus is on making the necessary changes to the Registry and then exiting the application. There is no need at this point to go through the effort of initializing DCOM and loading up the OPC Server support. The exported function:

    InitWTOPCsvr (GUID CLSID_Svr, UINT ServerRate);

    does just that. When this function is executed, the DLL performs all necessary initialization of COM/DCOM and creates the OPCServer Interface object to be used for client connections. The specified ServerRate defines how fast the OPC Client data connections are refreshed.

    Creating Process Tags

    After initialization, the WTOPCSvr.DLL is now ready to accept data points from the custom application. Three exported functions are provided:

    CreateTag (CString Name, VARIANT Value, WORD InitialQuality, BOOL IsWriteable);

    UpdateTag (HANDLE TagHandle, VARIANT Value, WORD Quality);

    UpdateTagByName (CString Name, VARIANT Value, WORD Quality);

    As each process tag is created, the DLL returns a HANDLE to identify the point for future references, (updates), from the application. The naming convention used by WTOPCSvr.DLL for browsing operations, (OPC_NS_FLAT or OPC_NS_HIERARCHIAL), is a function of how the names are assigned by the controlling application. If segmented names are used to create the tags, (strings containing the delimiter Ď.í, such as "PLANT A.PROCESS1.TAG17"), WTOPCsvr.DLL will automatically configure the name space as hierarchial, otherwise a flat name space is used.

    Callback Notification

    If process tags are created as OPC_WRITEABLE, attached client applications may change the value of data points contained within WTOPCSvr.DLL. In this scenario, the controlling application needs to know that a particular tag has been changed and the new value. WTOPCSvr.DLL provides the ability for the controlling application to define a callback routine for notification of client writes.

    EnableNotification (NOTIFYPROC lpCallback);

    If enabled, the callback function will receive the HANDLE of any data point written by an attached OPC Client. The application may then read the new value via the exported function:

    ReadTag (HANDLE TagHandle, VARIANT *pValue);

    Clean-up Functions

    The only remaining functions exported from WTOPCSvr.DLL provide the mechanism for gracefully closing the custom server.

    int NumbrClientConnections ();

    void RequestDisconnect ();

    RemoveTag (HANDLE TagHandle);

    Generally, the server logic sould check to see if any OPC Clients are connected before allowing the application to close. OPC 2.0 clients may be requested to disconnect. Any tags created by the application should be removed using the defined function.

    Last Updated: Jan 20, 2004
    Copyright © 2000, WinTECH Software Design
    Return to WinTECH Automation Apps..