OPC DA 2.05a Specification
OPC DA 2.05a Specification
04
TM
Version 2.05A
June 28 2002
OPC Data Access Custom Interface Specification 2.05
Synopsis:
This specification is the specification of the interface for developers of OPC
Data Access clients and OPC servers.. The specification is a result of an
analysis and design process to develop a standard interface to facilitate the
development of servers and clients by multiple vendors that shall inter-operate
seamlessly together.
Trademarks:
Most computer and software brand names have trademarks or registered
trademarks. The individual trademarks have not been listed here.
Required Runtime Environment:
This specification requires Windows 95, Windows NT 4.0 or later
ii
OPC Data Access Custom Interface Specification 2.05
The OPC Foundation, a non-profit corporation (the “OPC Foundation”), has established a set of standard
OLE/COM interface protocols intended to foster greater interoperability between automation/control
applications, field systems/devices, and business/office applications in the process control industry.
The current OPC specifications, prototype software examples and related documentation (collectively, the
“OPC Materials”), form a set of standard OLE/COM interface protocols based upon the functional
requirements of Microsoft’s OLE/COM technology. Such technology defines standard objects, methods,
and properties for servers of real-time information like distributed process systems, programmable logic
controllers, smart field devices and analyzers in order to communicate the information that such servers
contain to standard OLE/COM compliant technologies enabled devices (e.g., servers, applications, etc.).
The OPC Foundation will grant to you (the “User”), whether an individual or legal entity, a license to use,
and provide User with a copy of, the current version of the OPC Materials so long as User abides by the
terms contained in this Non-Exclusive License Agreement (“Agreement”). If User does not agree to the
terms and conditions contained in this Agreement, the OPC Materials may not be used, and all copies (in
all formats) of such materials in User’s possession must either be destroyed or returned to the OPC
Foundation. By using the OPC Materials, User (including any employees and agents of User) agrees to be
bound by the terms of this Agreement.
LICENSE GRANT:
Subject to the terms and conditions of this Agreement, the OPC Foundation hereby grants to User a non-
exclusive, royalty-free, limited license to use, copy, display and distribute the OPC Materials in order to
make, use, sell or otherwise distribute any products and/or product literature that are compliant with the
standards included in the OPC Materials.
All copies of the OPC Materials made and/or distributed by User must include all copyright and other
proprietary rights notices include on or in the copy of such materials provided to User by the OPC
Foundation.
The OPC Foundation shall retain all right, title and interest (including, without limitation, the copyrights) in
the OPC Materials, subject to the limited license granted to User under this Agreement.
User acknowledges that the OPC Foundation has provided the OPC Materials for informational purposes
only in order to help User understand Microsoft’s OLE/COM technology. THE OPC MATERIALS ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF PERFORMANCE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. USER BEARS ALL RISK
RELATING TO QUALITY, DESIGN, USE AND PERFORMANCE OF THE OPC MATERIALS. The
OPC Foundation and its members do not warrant that the OPC Materials, their design or their use will meet
User’s requirements, operate without interruption or be error free.
IN NO EVENT SHALL THE OPC FOUNDATION, ITS MEMBERS, OR ANY THIRD PARTY BE
LIABLE FOR ANY COSTS, EXPENSES, LOSSES, DAMAGES (INCLUDING, BUT NOT LIMITED
TO, DIRECT, INDIRECT, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR PUNITIVE DAMAGES)
OR INJURIES INCURRED BY USER OR ANY THIRD PARTY AS A RESULT OF THIS
AGREEMENT OR ANY USE OF THE OPC MATERIALS.
iii
OPC Data Access Custom Interface Specification 2.05
GENERAL PROVISIONS:
This Agreement and User’s license to the OPC Materials shall be terminated (a) by User ceasing all use of
the OPC Materials, (b) by User obtaining a superseding version of the OPC Materials, or (c) by the OPC
Foundation, at its option, if User commits a material breach hereof. Upon any termination of this
Agreement, User shall immediately cease all use of the OPC Materials, destroy all copies thereof then in its
possession and take such other actions as the OPC Foundation may reasonably request to ensure that no
copies of the OPC Materials licensed under this Agreement remain in its possession.
User shall not export or re-export the OPC Materials or any product produced directly by the use thereof to
any person or destination that is not authorized to receive them under the export control laws and
regulations of the United States.
The Software and Documentation are provided with Restricted Rights. Use, duplication or disclosure by
the U.S. government is subject to restrictions as set forth in (a) this Agreement pursuant to DFARs
227.7202-3(a); (b) subparagraph (c)(1)(i) of the Rights in Technical Data and Computer Software clause at
DFARs 252.227-7013; or (c) the Commercial Computer Software Restricted Rights clause at FAR 52.227-
19 subdivision (c)(1) and (2), as applicable. Contractor/ manufacturer is the OPC Foundation, P.O. Box
140524, Austin, Texas 78714-0524.
Should any provision of this Agreement be held to be void, invalid, unenforceable or illegal by a court, the
validity and enforceability of the other provisions shall not be affected thereby.
This Agreement shall be governed by and construed under the laws of the State of Minnesota, excluding its
choice or law rules.
This Agreement embodies the entire understanding between the parties with respect to, and supersedes any
prior understanding or agreement (oral or written) relating to, the OPC Materials.
iv
OPC Data Access Custom Interface Specification 2.05
• This is now refered to as the OPC Data Access Specification as there are other OPC efforts underway.
• The Automation Interface specification has been separated into a separate document.
• All previous (1.0A) Custom Interfaces remain in place and unchanged except for minor clarifications.
• Async and exception based connections should now be done using ConnectionPoints rather than
IDataObject. The existing IOPCAsyncIO, IDataObject and Client side IAdviseSink interfaces support
‘old style’ (Version 1.0) connections. The new IOPCAsyncIO2, IConnectionPointContainer and Client
side IOPCDataCallback interfaces support the ‘new style’ Version 2.0 connections.
• The behavior of the existing IOPCAsyncIO, IDataObject and Client side IAdviseSink interfaces is
unchanged however their support is optional for OPC 2.0 complaint software. The new
v
OPC Data Access Custom Interface Specification 2.05
vi
OPC Data Access Custom Interface Specification 2.05
Table of Contents
1 INTRODUCTION .................................................................................................................................1
1.1 AUDIENCE ........................................................................................................................................1
1.2 DELIVERABLES .................................................................................................................................1
2 OPC DATA ACCESS FUNDAMENTALS .........................................................................................2
2.1 OPC OVERVIEW ...............................................................................................................................2
2.2 WHERE OPC FITS .............................................................................................................................3
2.3 GENERAL OPC ARCHITECTURE AND COMPONENTS .........................................................................4
2.4 OVERVIEW OF THE OBJECTS AND INTERFACES .................................................................................6
2.5 THE ADDRESS SPACE AND CONFIGURATION OF THE SERVER ...........................................................7
2.6 APPLICATION LEVEL SERVER AND NETWORK NODE SELECTION .....................................................8
2.7 SYNCHRONIZATION AND SERIALIZATION ISSUES ..............................................................................8
2.8 PUBLIC (AKA SHARED) GROUPS .......................................................................................................9
2.9 PERSISTENT STORAGE STORY ..........................................................................................................9
3 OPC DATA ACCESS QUICK REFERENCE..................................................................................10
3.1 CUSTOM INTERFACE .......................................................................................................................10
3.1.1 OPCServer Object .................................................................................................................11
3.1.2 OPCGroup Object..................................................................................................................13
3.1.3 EnumOPCItemAttributes Object ...........................................................................................14
3.2 CUSTOM INTERFACE/CLIENT SIDE .................................................................................................15
4 OPC CUSTOM INTERFACE............................................................................................................16
4.1 OVERVIEW OF THE OPC CUSTOM INTERFACE ................................................................................16
4.2 GENERAL INFORMATION ................................................................................................................17
4.2.1 Version Interoperability.........................................................................................................17
4.2.2 Ownership of memory ...........................................................................................................18
4.2.3 Standard Interfaces ................................................................................................................18
4.2.4 Null Strings and Null Pointers ...............................................................................................18
4.2.5 Returned Arrays.....................................................................................................................18
4.2.6 Public Groups ........................................................................................................................18
4.2.7 CACHE data, DEVICE data and TimeStamps ......................................................................19
4.2.8 Time Series Values................................................................................................................19
4.2.9 Asynchronous vs. Synchronous Interfaces ............................................................................19
4.2.10 The ACTIVE flags, Deadband and Update Rate ...................................................................19
4.2.11 Errors and return codes..........................................................................................................20
4.2.12 Startup Issues.........................................................................................................................20
4.2.13 VARIANT Data Types and Interoperability..........................................................................20
4.2.14 Localization and LocaleID ....................................................................................................23
4.3 DATA ACQUISITION AND ACTIVE STATE BEHAVIOR ......................................................................24
4.3.1 IOPCSyncIO..........................................................................................................................24
4.3.2 IOPCASyncIO2 .....................................................................................................................25
4.3.3 SUBSCRIPTION via IOPCDataCallback .............................................................................26
4.3.4 IOPCASyncIO (old) ..............................................................................................................27
4.3.5 SUBSCRIPTION via IDataObject (old)................................................................................28
4.4 OPCSERVER OBJECT......................................................................................................................29
4.4.1 Overview ...............................................................................................................................29
4.4.2 IUnknown ..............................................................................................................................30
4.4.3 IOPCCommon .......................................................................................................................30
4.4.4 IOPCServer............................................................................................................................31
4.4.5 IConnectionPointContainer (on OPCServer).........................................................................40
4.4.6 IOPCItemProperties...............................................................................................................43
4.4.7 IOPCServerPublicGroups (optional) .....................................................................................55
vii
OPC Data Access Custom Interface Specification 2.05
10 APPENDIX D - OPCPROPS.H....................................................................................................185
viii
OPC Data Access Custom Interface Specification 2.05
1 Introduction
A General Introduction to OPC is contained in a separate OPC Overview Document
(OPCOVW.DOC). This particular document deals specifically with the OPC Data Access Interfaces.
1.1 Audience
This specification is intended as reference material for developers of OPC compliant Clients and
Servers. It is assumed that the reader is familiar with Microsoft OLE/COM technology and the needs
of the Process Control industry.
This specification is intended to facilitate development of OPC Servers in C and C++, and of OPC
client applications in the language of choice. Therefore, the developer of the respective component is
expected to be fluent in the technology required for the specific component.
1.2 Deliverables
The deliverables from the OPC Foundation with respect to the OPC Data Access Specification 2.0
include the OPC Specification itself, OPC IDL files (included in this document as Appendices) and the
OPC Error header files (included in this document). As a convenience, standard proxystub DLLs and a
standard Data Access Header file for the OPC interfaces generated directly from the IDL will be
provided at the OPC Foundation Web Site.
This OPC Data Access specification contains design information for the following:
1. The OPC Data Access Custom Interface - This document will describe the Interfaces and
Methods of OPC Components and Objects.
2. The OPC Data Access Automation Interface - A Separate Document (The OPC Data Access
Automation Specification 2.0) will describe the OPC Automation Interfaces which facilitate the
use of Visual Basic, Delphi and other Automation enabled products to interface with OPC Servers.
1
OPC Data Access Custom Interface Specification 2.05
OPC
Server
Vendor A
OPC
OPC Client Server
Vendor B
OPC
Server
Vendor C
OPC
Server
Vendor A
OPC
OPC Client #1 Server OPC Client #2
Vendor B
OPC
Server
Vendor C
OPC Client #3
2
OPC Data Access Custom Interface Specification 2.05
connections can also be created between the client and the items in the group and can be enabled and
disabled as needed. An OPC client can configure the rate that an OPC server should provide the data
changes to the OPC cleint.
There are two types of groups, public and local (or ‘private’). Public is for sharing across multiple
clients, local is local to a client. Refer to the section on public groups for the intent, purpose, and
functionality and for further details. There are also specific optional interfaces for the public groups.
Within each Group the client can define one or more OPC Items.
Group
Item 1
Item 2
Item 3
SCADA Physical
OPC I/F Physical I/F
System I/O
OPC
Application OPC I/F
Server
Physical
Physical I/F
I/O
3
OPC Data Access Custom Interface Specification 2.05
OPC Server
Vendor Specific
(In-Proc, Local, Remote,
Logic
Handler)
C++
Application Server Data Cache
OPC Custom Interface
Physical
Device
Device Data
4
OPC Data Access Custom Interface Specification 2.05
It is also expected that the server will consolidate and optimize data accesses requested by the various
clients to promote efficient communications with the physical device. For inputs (Reads), data
returned by the device is buffered for asynchronous distribution or synchronous collection by various
OPC clients. For outputs (writes), the OPC Server updates the physical device data on behalf of OPC
Clients.
5
OPC Data Access Custom Interface Specification 2.05
IUnknown
IOPCCommon
IOPCServer
[IOPCServerPublicGroups] Standard
[IOPCBrowseServerAddressSpace] OPC Server
[IPersistFile] Object
IConnectionPointContainer
6
OPC Data Access Custom Interface Specification 2.05
IUnknown
IOPCItemMgt
IOPCGroupStateMgt
[IOPCPublicGroupStateMgt]
Standard
IOPCSyncIO
OPC Group
IOPCASyncIO2 Object
IConnectionPointContainer
[IOPCASyncIO] old
[IDataObject] old
This release of the OPC specification assumes that a server configuration address space may be
managed and persistently stored using the IPersistFile interface. Only the server specific information
is persistently stored. All client configuration information (Group and Item Definitions) must be
persistently stored by the respective client application. All Handles that are defined in the system are
not guaranteed to have the same value between sessions of the client and server conversation.
It is important to distinguish the address space of the server (also known as the server configuration)
from the small subsets of this space that a particular client may be interested in at a particular time
(also known as the ‘groups’ and ‘items’). The details of how these client specific groups are
maintained are discussed in detail in this specification. The persistent storage of groups is the
responsibility of the respective clients. The details of how the server address space is defined and
configured are intentionally left unspecified. For example the server address space might be:
• Entirely fixed (e.g. for a dedicated interface to a particular device such as a scale).
• Configured entirely outside of the OPC environment (e.g. for an interface to an
existing external DCS system).
• Automatically configured at startup by an ‘intelligent’ server which can poll the
existing system for installed hardware or interfaces.
• Automatically configured on the fly by an ‘intelligent’ server based on the names of
the data items the client applications are currently requesting.
7
OPC Data Access Custom Interface Specification 2.05
It is expected that this server address space is stable and is managed within the server. The clients will
define and manage the relatively small lists of items called ‘groups’ as needed from time to time. The
interfaces described here provide the client the ability to easily define, manage, and recreate these lists
as needed through the use of ‘OPCGroups’. The clients direct the server to create, manage and delete
these groups on their behalf (persistence of the groups is the responsibility of the client application).
Although it is possible, with the usage of public groups, that the server could provide persistent storage
of these type of groups, or treat them as server defined groups.
8
OPC Data Access Custom Interface Specification 2.05
3. Threading issues are always important but this is especially true on SMP systems.
By ‘Serialization’ we mean the ability of the client to control the order in which writes are performed.
1. It is STRONGLY RECOMMENDED that write requests to the same device be handled ‘in-order’
by any server implementation. For example, an application might use a ‘recipe download
complete’ flag which is set by the application after the individual recipe items are sent. In this
case, the data must be transmitted to the physical device in the same order it was output to insure
that the ‘complete’ flag is not set before all the data has actually arrived. Where the server buffers
the outgoing data and implements a separate communications manager thread to send these
outputs to the physical device (as is often the case), the server implementation must take extra care
to insure that the order of the outputs is preserved.
2. Where a client can both read values explicitly or receive updates via a callback attention must be
given to defining exactly when a callback will or will not occur. This is discussed in more detail
later.
Many of these issues will be clarified in the detailed descriptions of the methods below.
9
OPC Data Access Custom Interface Specification 2.05
10
OPC Data Access Custom Interface Specification 2.05
IOPCCommon
HRESULT SetLocaleID ( dwLcid )
HRESULT GetLocaleID ( pdwLcid )
HRESULT QueryAvailableLocaleIDs ( pdwCount, pdwLcid )
HRESULT GetErrorString ( dwError, ppString)
HRESULT SetClientName (szName)
IOPCServer
HRESULT AddGroup(szName, bActive, dwRequestedUpdateRate, hClientGroup, pTimeBias,
pPercentDeadband, dwLCID, phServerGroup, pRevisedUpdateRate, riid, ppUnk)
HRESULT GetErrorString(dwError, dwLocale, ppString)
HRESULT GetGroupByName(szName, riid, ppUnk)
HRESULT GetStatus(ppServerStatus)
HRESULT RemoveGroup(hServerGroup, bForce)
HRESULT CreateGroupEnumerator(dwScope, riid, ppUnk)
IConnectionPointContainer
HRESULT EnumConnectionPoints( IEnumConnectionPoints ppEnum);
HRESULT FindConnectionPoint( REFIID riid, IConnectionPoint ppCP);
IOPCItemProperties
HRESULT QueryAvailableProperties(szItemID, pdwCount,
ppPropertyIDs, ppDescriptions, ppvtDataTypes );
HRESULT GetItemProperties (szItemID, dwCount, pdwPropertyIDs,
ppvData, ppErrors );
HRESULT LookupItemIDs( szItemID, dwCount, pdwPropertyIDs,
ppszNewItemIDs, ppErrors );
11
OPC Data Access Custom Interface Specification 2.05
IOPCBrowseServerAddressSpace (optional)
HRESULT QueryOrganization(pNameSpaceType );
HRESULT ChangeBrowsePosition(dwBrowseDirection, szString );
HRESULT BrowseOPCItemIDs( dwBrowseFilterType, szFilterCriteria, vtDataTypeFilter,
dwAccessRightsFilter, ppIEnumString );
HRESULT GetItemID( szItemDataID, szItemID );
HRESULT BrowseAccessPaths( szItemID, ppIEnumString );
IOPCServerPublicGroups (optional)
HRESULT GetPublicGroupByName(szName, riid, ppUnk);
HRESULT RemovePublicGroup(hServerGroup, bForce);
IPersistFile (optional)
HRESULT IsDirty();
HRESULT Load(pszFileName, dwMode);
HRESULT Save(pszFileName, fRemember);
HRESULT SaveCompleted( pszFileName);
HRESULT GetCurFileName( ppszFileName);
12
OPC Data Access Custom Interface Specification 2.05
IOPCGroupStateMgt
HRESULT GetState(pUpdateRate, pActive, ppName, pTimeBias, pPercentDeadband, pLCID,
phClientGroup, phServerGroup)
HRESULT SetState(pRequestedUpdateRate, pRevisedUpdateRate, pActive, pTimeBias,
pPercentDeadband, pLCID, phClientGroup)
HRESULT SetName(szName);
HRESULT CloneGroup(szName, riid, ppUnk);
IOPCPublicGroupStateMgt (optional)
HRESULT GetState(pPublic);
HRESULT MoveToPublic(void);
IOPCSyncIO
HRESULT Read(dwSource, dwCount, phServer, ppItemValues, ppErrors)
HRESULT Write(dwCount, phServer, pItemValues, ppErrors)
IOPCAsyncIO2
HRESULT Read(dwCount, phServer, dwTransactionID, pdwCancelID, ppErrors,)
HRESULT Write(dwCount, phServer, pItemValues, dwTransactionID, pdwCancelID, ppErrors);
HRESULT Cancel2 (dwCancelID);
HRESULT Refresh2(dwSource, dwTransactionID, pdwCancelID);
HRESULT SetEnable(bEnable);
HRESULT GetEnable(pbEnable);
IOPCItemMgt
HRESULT AddItems(dwCount, pItemArray, ppAddResults, ppErrors)
HRESULT ValidateItems(dwCount, pItemArray, bBlobUpdate, ppValidationResults, ppErrors)
HRESULT RemoveItems(dwCount, phServer, ppErrors)
HRESULT SetActiveState(dwCount, phServer, bActive, ppErrors)
HRESULT SetClientHandles(dwCount, phServer, phClient, ppErrors)
HRESULT SetDatatypes(dwCount, phServer, pRequestedDatatypes, ppErrors)
HRESULT CreateEnumerator(riid, ppUnk)
IConnectionPointContainer
HRESULT EnumConnectionPoints( IEnumConnectionPoints ppEnum);
HRESULT FindConnectionPoint( REFIID riid, IConnectionPoint ppCP);
13
OPC Data Access Custom Interface Specification 2.05
IOPCAsyncIO (old)
HRESULT Read(dwConnection, dwSource, dwCount, phServer, pTransactionID, ppErrors,)
HRESULT Write(dwConnection, dwCount, phServer, pItemValues, pTransactionID, ppErrors);
HRESULT Cancel (dwTransactionID);
HRESULT Refresh(dwConnection, dwSource, pTransactionID);
IDataObject (old)
HRESULT Dadvise(pFmt, adv, pSnk, pConnection);
HRESULT Dunadvise(Connection);
Note: all other functions can be stubs which return E_NOTIMPL.
14
OPC Data Access Custom Interface Specification 2.05
IOPCDataCallback
HRESULT OnReadComplete(dwTransid, hGroup, hrMasterquality, hrMastererror, dwCount,
phClientItems, pvValues, pwQualities, pftTimeStamps, pErrors,);
HRESULT OnWriteComplete(dwTransid, hGroup, hrMastererr, dwCount, phClientItems,
pErrors);
HRESULT OnCancelComplete(dwTransid, hGroup);
HRESULT OnDataChange(dwTransid, hGroup, hrMasterquality, hrMastererror, dwCount,
phClientItems, pvValues, pwQualities, pftTimeStamps, pErrors,);
IOPCShutdown
void ShutdownRequest(szReason);
IAdviseSink (old)
void OnDataChange(pFE, pSTM);
15
OPC Data Access Custom Interface Specification 2.05
Also you will note that in some cases lists of things are returned via enumerators and in other cases as
simple lists of items. Our choice depends on the expected number of items returned. ‘Large’ lists are
best returned through enumerators while ‘small’ lists are more easily and efficiently returned via
explicit lists.
16
OPC Data Access Custom Interface Specification 2.05
OPCGroup
IUnknown Required Required
IOPCItemMgt Required Required
IOPCGroupStateMgt Required Required
IOPCPublicGroupStateMgt Optional Optional
IOPCSyncIO Required Required
IOPCAsyncIO2 N/A Required
IConnectionPointContainer N/A Required
IOPCAsyncIO Required N/A
IDataObject Required N/A
17
OPC Data Access Custom Interface Specification 2.05
18
OPC Data Access Custom Interface Specification 2.05
19
OPC Data Access Custom Interface Specification 2.05
20
OPC Data Access Custom Interface Specification 2.05
• Servers should be prepared to deal in an elegant way with requested types even when they are
unable to convert their data to this type. That is, they should not malfunction, return incorrect
results or lose memory. As mentioned elsewhere they may return a variety of errors including any
error returned by the Microsoft function: VariantChangeType.
• Clients should always be prepared to deal with servers which are unable to handle a requested
datatype. That is, they should not malfunction or lose memory when an error is returned.
• Clients which request VT_EMPTY (which by convention indiciates that the server should return
it's canonical type) should likewise be prepared to deal with any returned type. That is, even if
they find that they are not able to use or display the returned data, they should properly free the
data (using VariantClear) and should probably indicate to the user that a datatype was returned
which is not usable by this client.
Additional Rules regarding Data Conversion
OPC Servers must support at least the following conversions between Canonical and Requested
datatypes. Reading and Writing should be symmetric. Note that the easiest way for most server
implementers to provide this functionality is to use the VariantChangeTypeEx() function available in
the COM libraries. In the table below, conversions marked OK can be expected to always work. Other
conversions may or may not work depending on the specific value of the source.
As noted elsewhere in this specification the Client can specify a localeID to be used and the server
should pass this to VariantChangeTypeEx() for all conversions. Note that it is possible for the end user
to override some of the default Locale Settings in the Control Panel Regional Settings Dialog. For
example in English it is possible to select date formats of either MM/DD/YY or YY/MM/DD as well
other formats. Clearly a date of 03/02/01 is ambiguous in this case. It is the End User’s responsibility
to insure that the Regional Settings for a given localeID are compatible on different machines within
his network.
Notes:
(1) Conversion on ‘downcast’ e.g. from I4 to I2 or R8 to R4 is allowed although Overflow is possible.
If overflow occurs an error (DISP_E_OVERFLOW) is returned and in the case of Read the quality is
set to BAD. In the case of Write the target value is not changed.
(2) Note that the internal storage type of VT_BOOL is ‘short’ which must have the values
VARIANT_TRUE (0xFFFF – i.e. ‘-1’ when stored in a ‘short’) and VARIANT_FALSE (0). When
converting TO bool any non-zero value converts to VARIANT_TRUE. Converting FROM bool to any
signed numeric type, VARIANT_TRUE converts to ‘-1’ or ‘-1.0’. For unsigned types it converts to the
maximum value. The recommended OPC standard for conversion of bool to BSTR is “0” or “-1”
rather than ‘True” or “False”. If a server chooses to convert to “True” or “False” is must account for
21
OPC Data Access Custom Interface Specification 2.05
(3) Note that DATE is stored as a double where the integer part is the date and the fraction is the time.
For the DATE, 0.0 is midnight Dec 30, 1899 (i.e. midnight Jan 1, 1900 is 2.0 and Dec 4, 2001 is
37229.0). For the TIME the fraction represents the time of day moving ahead from midnight (e.g.
0.2500 is 6:00 AM, 0.400 is 9:36:00 AM). This fraction is not affected by the sign of the date and
always moves ‘ahead’ from midnight for both positive and negative values. For example –1.4 is Dec
29, 1899 9:36:00 AM. These conversions are supported by VariantChangeTypeEx(). Generally an
OVERFLOW will occur if the TO type is UI1, I1, UI2 or I2. In addition the TIME (being a fraction)
will be lost on any conversion of DATE to an Integer.
(4) BSTR conversions will give a DISP_E_TYPE error if the string does not make sense for
conversion to the target type. For example “1234” converts to any numeric type (except it generates
OVERFLOW for UI1), “12/04/2001” converts to DATE (depending on the Locale) but not to a
numeric type and “ABCD” does not convert to any other type.
(5) Conversions from non Integers to Integers must round up according to the sign if the factional part
exceeds 0.5. For example 1.6 would round up to 2 and -1.6 would round 'up' to -2. In addition, the
generally accepted convention is that round up will occur if the fraction equals or exceeds 0.5
HOWEVER client and server writers should be aware that VariantChange does not reliably adhere to
the 'equals' part of this rule. Experience has shown that some floats and doubles with a fraction exactly
equal to .5 will round up while others will round down. For purposes of compliance either round up or
round down is acceptable when the fraction exactly equals .5.
(6) Keep in mind that Currency (CY) is stored as a scaled (fixed point x 10,000) 8 byte integer (I.e. a
‘_huge’) With 4 digits of precision to the right of the decimal point. For example $12.34 is stored as
123400.
(7) Conversion between signed and unsigned integers should generate an overflow if the requested
type cannot hold the value (e.g. I1=-1 should overflow if converted to UI1 and UI1 of 255 should
overflow if converted to I1). However some of these conversions behave improperly when performed
by ChangeVariantTypeEx. Specifically, for conversions with the same number of bits the value is
NOT checked for overflow. So an I1 of –1 turns into a UI1 of 255. Similarly a UI1 value of 254 turns
into an I1 value of –2. The same applies for I2 and I4. This is an incorrect behavior by
ChangeVariantTypeEx. Client programs and users should be aware that most servers will exhibit this
behavior since most servers will use VariantChangeTypeEx. Correcting this is recommended but is
NOT required for OPC Compliance. Conversions between types with different numbers of bits (e.g. I1,
I2, I4) are properly checked for Overflow by VariantChangeTypeEx.
(8) Loss of Precision may occur when converting between various types (e.g. converting from R8 to
R4 or from R4 to I4 or I2). However no error is reported as long as there is no OVERFLOW and
Quality is returned as GOOD for Reads.
(9) Note that ChangeVariantTypeEx does not handle arrays. Servers which support arrays must
implement conversion logic using additional code. For arrays the required behavior is that if any
element of the array suffers a conversion error then the first error detected is returned (DISP_E_OVER
or DISP_E_TYPE). For Read the Quality is set to BAD and an empty Variant is returned. For Write, if
conversion of any element fails then none of the elements are written and the first error encountered is
returned.
22
OPC Data Access Custom Interface Specification 2.05
23
OPC Data Access Custom Interface Specification 2.05
4.3.1 IOPCSyncIO
IOPCSyncIO::Read Cache NA Active Active The Values and Quality for the requested items are
returned to the client as return values from the method.
The Value and Quality are the values that the server has
in cache.
IOPCSyncIO::Read Device NA NA NA The Values and Quality for the requested items are
returned to the client as return values from the method.
The Value and Quality are the values that the server
obtains from the device when this method is called. The
cache of the server should be updated with the acquired
value and quality.
24
OPC Data Access Custom Interface Specification 2.05
4.3.2 IOPCASyncIO2
IOPCAsyncIO2::Read NA NA NA NA The Values and Quality for the requested items are sent to
the client through the
IOPCDataCallback::OnReadComplete method. The
Value and Quality are the values that the server obtains
from the DEVICE when this method is called. The
CACHE of the server should be updated with the acquired
value and quality.
IOPCAsyncIO2::Refresh Cache NA Active Active The Values and Quality for all the Active items in the
group are sent to the client through the
IAdviseSink::OnDataChange method. The Value and
Quality are the values that the server has in cache.
IOPCAsyncIO2::Refresh Cache NA Active InActive The Values and Quality for all the InActive items in the
group are not provided to the client. If there are no
Active Items in the group then the server returns E_FAIL
as the return value from the call.
IOPCAsyncIO2::Refresh Cache NA InActive NA The server returns E_FAIL as the return value from the
call.
IOPCAsyncIO2::Refresh Device NA Active Active The Values and Quality for all items in the group are sent
to the client through the
IOPCDataCallback::OnDataChange method. The Value
and Quality are the values that the server obtains from the
device when this method is called. The cache of the
server should be updated with the acquired values and
qualities.
IOPCAsyncIO2::Refresh Device NA Active InActive The Values and Quality for all the InActive items in the
group are not provided to the client. If there are no
Active Items in the group then the server returns E_FAIL
as the return value from the call.
IOPCAsyncIO2::Refresh Device NA InActive NA The server returns E_FAIL as the return value from the
call.
25
OPC Data Access Custom Interface Specification 2.05
Subscription via NA TRUE Active Active The Value and Quality are the values that the server
IOPCDataCallback:: obtains from the device at a periodic rate sufficient to
OnDataChange accommodate the specified UpdateRate. If the Quality has
changed from the Quality last sent to the client, then the
new value and new quality will be sent to the client
through the IOPCDataCallback::OnDataChange method,
and the cache of the server should be updated with the
acquired value and quality. If the Quality has NOT
changed from the Quality last sent to the client, the
server should compare the acquired value for a change
that exceeds the Deadband criteria. If the change in value
exceeds the deadband criteria, , then the new value and
new quality will be sent to the client through the
IOPCDataCallback::OnDataChange method, and the
cache of the server should be updated with the acquired
value and quality.
Subscription via TRUE Active InActive Server only acquires values from physical data sources for
IOPCDataCallback:: active items.
OnDataChange
Subscription via TRUE InActive NA Server only acquires values from physical data sources for
IOPCDataCallback:: active items that are contained in active groups.
OnDataChange
Subscription via NA FALSE Active Active The Value and Quality are the values that the server
IOPCDataCallback:: obtains from the device at a periodic rate sufficient to
OnDataChange accommodate the specified UpdateRate. If the Quality has
changed from the Quality in the cache, then the cache of
the server should be updated with the acquired value and
quality. If the Quality has changed from the Quality in
the cache, the server should compare the acquired value
for a change that exceeds the Deadband criteria. If the
change in value exceeds the deadband criteria, , then the
cache of the server should be updated with the acquired
value and quality.
Subscription via NA FALSE Active InActive Server only acquires values from physical data sources for
IOPCDataCallback:: active items.
OnDataChange
Subscription via NA FALSE InActive NA Server only acquires values from physical data sources for
IOPCDataCallback:: active items that are contained in active groups.
OnDataChange
26
OPC Data Access Custom Interface Specification 2.05
IOPCAsyncIO::Read Cache NA Active Active The Values and Quality for the requested items are sent to
the client through the IAdviseSink::OnDataChange
method. The Value and Quality are the values that the
server has in cache.
IOPCAsyncIO::Read Device NA NA NA The Values and Quality for the requested items are sent to
the client through the IAdviseSink::OnDataChange
method. The Value and Quality are the values that the
server obtains from the device when this method is called.
The cache of the server should be updated with the
acquired value and quality.
IOPCAsyncIO::Refresh Cache NA Active Active The Values and Quality for all the Active items in the
group are sent to the client through the
IAdviseSink::OnDataChange method. The Value and
Quality are the values that the server has in cache.
IOPCAsyncIO::Refresh Cache NA Active InActive The Values and Quality for all the InActive items in the
group are not provided to the client. If there are no
Active Items in the group then the server returns E_FAIL
as the return value from the call.
IOPCAsyncIO::Refresh Cache NA InActive NA The server returns E_FAIL as the return value from the
call.
IOPCAsyncIO::Refresh Device NA Active Active The Values and Quality for all items in the group are sent
to the client through the IAdviseSink::OnDataChange
method. The Value and Quality are the values that the
server obtains from the device when this method is called.
The cache of the server should be updated with the
acquired values and qualities..
IOPCAsyncIO::Refresh Device NA Active InActive The Values and Quality for all the InActive items in the
group are not provided to the client. If there are no
Active Items in the group then the server returns E_FAIL
as the return value from the call.
IOPCAsyncIO::Refresh Device NA InActive NA The server returns E_FAIL as the return value from the
call.
27
OPC Data Access Custom Interface Specification 2.05
Subscription via NA NA Active Active The Value and Quality are the values that the server
(IDataObject::DAdvise) & obtains from the device at a periodic rate sufficient to
(IAdviseSink::OnDataCha accommodate the specified UpdateRate. If the Quality has
nge) changed from the Quality last sent to the client, then the
new value and new quality will be sent to the client
through the IAdviseSink::OnDataChange method, and the
cache of the server should be updated with the acquired
value and quality. If the Quality has NOT changed from
the Quality last sent to the client, the server should
compare the acquired value for a change that exceeds the
Deadband criteria. If the change in value exceeds the
deadband criteria, , then the new value and new quality
will be sent to the client through the
IAdviseSink::OnDataChange method, and the cache of
the server should be updated with the acquired value and
quality.
Subscription via NA NA Active InActive Server only acquires values from physical data sources for
(IDataObject::DAdvise) & active items.
(IAdviseSink::OnDataCha
nge)
Subscription via NA NA InActive NA Server only acquires values from physical data sources for
(IDataObject::DAdvise) & active items that are contained in active groups.
(IAdviseSink::OnDataCha
nge)
28
OPC Data Access Custom Interface Specification 2.05
4.4.1 Overview
The OPCServer object is the primary object that an OPC server exposes. The interfaces that this object
provides include:
• IUnknown
• IOPCServer
• IOPCServerPublicGroups (optional)
• IOPCBrowseServerAddressSpace (optional)
• IPersistFile (optional)
• IOPCItemProperties
• IConnectionPointContainer
The functionality provided by each of the above interfaces is defined in this section.
NOTE: Version 1.0 of this specification listed IEnumUnkown as an interface on the OPC Server. This
was an error and has been removed. The semantics of QueryInterface do not allow such an
implementation. The proper way to obtain a group enumerator is through
IOPCServer::CreateGroupEnumerator.
29
OPC Data Access Custom Interface Specification 2.05
4.4.2 IUnknown
The server must provide a standard IUnknown Interface. Since this is a well defined interface it is not
discussed in detail. See the OLE Programmer’s reference for additional information. This interface
must be provided, and all functions implemented as required by Microsoft..
4.4.3 IOPCCommon
Other OPC Servers such as alarms and events share this interface design. It provides the ability to set
and query a LocaleID which would be in effect for the particular client/server session. That is, as with
a Group definition, the actions of one client do not affect any other clients.
A quick reference for this interface is provided below. A more detailed discussion can be found in the
OPC Overview Document.
HRESULT SetLocaleID (
[in] LCID dwLcid
);
HRESULT GetLocaleID (
[out] LCID *pdwLcid
);
HRESULT QueryAvailableLocaleIDs (
[out] DWORD *pdwCount,
[out, sizeis(, *pdwCount)] LCID **ppdwLcid
);
HRESULT GetErrorString(
[in] HRESULT dwError,
[out, string] LPWSTR *ppString
);
HRESULT SetClientName (
[in, string] LPCWSTR szName
);
30
OPC Data Access Custom Interface Specification 2.05
4.4.4 IOPCServer
This is the main interface to an OPC server. The OPC server is registered with the operating system as
specified in the Installation and Registration Chapter of this specification.
This interface must be provided, and all functions implemented as specified.
4.4.4.1 IOPCServer::AddGroup
HRESULT AddGroup(
[in, string] LPCWSTR szName,
[in] BOOL bActive,
[in] DWORD dwRequestedUpdateRate,
[in] OPCHANDLE hClientGroup,
[unique, in] LONG *pTimeBias,
[in] FLOAT * pPercentDeadband,
[in] DWORD dwLCID,
[out] OPCHANDLE * phServerGroup,
[out] DWORD *pRevisedUpdateRate,
[in] REFIID riid,
[out, iid_is(riid)] LPUNKNOWN * ppUnk
);
Description
Add a Group to a Server.
Parameters Description
szName Name of the group. The name must be unique among the
other groups created by this client. If no name is provided
(szName is pointer to a NUL string) the server will generate
a unique name. The server generated name will also be
unique relative to any existing public groups.
bActive FALSE if the Group is to be created as inactive.
TRUE if the Group is to be created as active.
dwRequestedUpdateRate Client Specifies the fastest rate at which data changes may
be sent to OnDataChange for items in this group. This also
indicates the desired accuracy of Cached Data. This is
intended only to control the behavior of the interface. How
the server deals with the update rate and how often it
actually polls the hardware internally is an implementation
detail. Passing 0 indicates the server should use the fastest
practical rate. The rate is specified in milliseconds.
hClientGroup Client provided handle for this group. [refer to description of
data types, parameters, and structures for more information
about this parameter]
pTimeBias Pointer to Long containing the initial TimeBias (in minutes)
for the Group. Pass a NULL Pointer if you wish the group to
use the default system TimeBias. See discussion of
31
OPC Data Access Custom Interface Specification 2.05
Return Codes
Return Code Description
S_OK The operation succeeded.
E_FAIL The operation failed.
E_OUTOFMEMORY Not enough memory
E_INVALIDARG An argument to the function was
invalid.
OPC_E_DUPLICATENAME Duplicate name not allowed.
OPC_S_UNSUPPORTEDRATE Server does not support specified rate,
server returns the rate that it can
support in the revised update rate.
E_NOINTERFACE The interface(riid) asked for is not
supported by the server.
Behavior
A Group is a logical container for a client to organize and manipulate data items.
32
OPC Data Access Custom Interface Specification 2.05
The server will create a group object, and return a pointer to the interface requested by the client. If
the client requests an optional interface that the server does not support, the server is expected to
return an error indicating the interface is not supported.
The requested update rate / revised update rate behavior should be deterministic between client / server
sessions. The client expects that for the same server configuration or workspace; adding a group with
a requested update rate will always result in the same RevisedRate independent of the number of
clients or items that have been added.
Comments
The expected object lifetime behavior is as follows. Even if all the interfaces are released, the group
will not be deleted until RemoveGroup is called. One way for the server to implement this is to assign
the group an initial reference count of 2; one for the ‘Add’ and one for the Interface that was created.
However, clients should not make assumptions about the Group’s reference count.
The client should not call RemoveGroup without releasing all interfaces for the group. The client
should also not release the server without removing all private groups.
Since the server is the ‘container’ for the groups it is permissible for the server to forcibly remove any
remaining groups at the time all of the server interfaces are released. (This should not be necessary for
a well behaved client).
See also the CreateGroupEnumerator function.
The level of localization supported (dwLCID) is entirely server specific. Servers which do not support
dynamic localization can ignore this parameter.
See the MoveToPublic function for additional requirements related to public groups.
33
OPC Data Access Custom Interface Specification 2.05
4.4.4.2 IOPCServer::GetErrorString
HRESULT GetErrorString(
[in] HRESULT dwError,
[in] LCID dwLocale,
[out, string] LPWSTR *ppString
);
Description
Returns the error string for a server specific error code.
Parameters Description
dwError A server specific error code that the client application had
returned from an interface function from the server, and for
which the client application is requesting the server’s textual
representation.
dwLocale The locale for the returned string .
ppString Pointer to pointer where server supplied result will be saved
Return Codes
Return Code Description
E_FAIL The operation failed.
E_OUTOFMEMORY Not enough memory
E_INVALIDARG An argument to the function was invalid. (For
example, the error code specified is not valid.)
S_OK The operation succeeded.
Comments
This is essentially the same function as is found in the newer IOPCCommon.
Note that if this method is called on a remote server, an RPC error may result. For this reason it is
probably good practice for the client to attempt to call a local Win32 function if this function fails.
The expected behavior is that this will include handling of Win32 errors as well (such as RPC errors).
The Client must free the returned string.
It is recommended that the server put any OPC specific strings into an external resource to simplify
translation.
To get the default value for the system, the dwLocale should be LOCALE_SYSTEM_DEFAULT.
34
OPC Data Access Custom Interface Specification 2.05
4.4.4.3 IOPCServer::GetGroupByName
HRESULT GetGroupByName(
[in, string] LPCWSTR szName,
[in] REFIID riid,
[out, iid_is(riid)] LPUNKNOWN * ppUnk
);
Description
Given the name of a private group (created earlier by the same client), return an additional interface
pointer. Use GetPublicGroupByName to attach to public groups.
Parameters Description
szName The name of the group. That is the group must have been
created by the caller.
riid The type of interface desired for the group (e.g.
IOPCItemMgt)
ppUnk Pointer to where the group interface pointer should be
returned. NULL is returned for any HRESULT other than
S_OK.
Return Codes
Return Code Description
E_FAIL The operation failed.
E_OUTOFMEMORY Not enough memory
E_INVALIDARG An argument to the function was invalid.
S_OK The operation succeeded.
E_NOINTERFACE The interface(riid) asked for is not
supported by the server.
Comments
This function can be used to reconnect to a private group for which all interface pointers have been
released.
The client must release the returned interface when it is done with it.
If needed, the client can obtain the hServerGroup Handle via IOPCGroupStateMgt::GetState.
35
OPC Data Access Custom Interface Specification 2.05
4.4.4.4 IOPCServer::GetStatus
HRESULT GetStatus(
[out] OPCSERVERSTATUS ** ppServerStatus
);
Description
Returns current status information for the server.
Parameters Description
ppServerStatus Pointer to where the OPCSERVERSTATUS structure pointer
should be returned. The structure is allocated by the server.
Return Codes
Return Code Description
E_FAIL The operation failed.
E_OUTOFMEMORY Not enough memory
E_INVALIDARG An argument to the function was invalid.
S_OK The operation succeeded.
Comments
The OPCSERVERSTATUS is described later in this specification.
Client must free the structure as well as the VendorInfo string within the structure.
Periodic calls to GetStatus would be a good way for the client to determine that the server is still
connected and available.
36
OPC Data Access Custom Interface Specification 2.05
4.4.4.5 IOPCServer::RemoveGroup
HRESULT RemoveGroup(
[in] OPCHANDLE hServerGroup,
[in] BOOL bForce
);
Description
Parameters Description
hServerGroup Handle for the group to be removed
bForce Forces deletion of the group even if references are
outstanding
Return Codes
Return Code Description
E_FAIL The operation failed.
E_OUTOFMEMORY Not enough memory
E_INVALIDARG An argument to the function was invalid.
S_OK The operation succeeded.
OPC_S_INUSE Was not be removed because references exist.
Group will be marked as deleted, and will be
removed automatically by the server when all
references to this object are released.
Comments
A group is not deleted when all the client interfaces are released, since the server itself maintains a
reference to the group. The client may still call GetGroupByName after all the interfaces have been
released. RemoveGroup() causes the server to release it's `last' reference to the group, which results in
the group being truly deleted.
In general, a well behaved client will call this function only after releasing all interfaces.
If interfaces still exist, Remove group will mark the group as ‘deleted’. Any further calls to this group
via these interfaces will return E_FAIL. When all the interfaces are released, the group will actually be
deleted. If bForce is TRUE then the group is deleted unconditionally even if references (interfaces)
still exist. Subsequent use of such interfaces will result in an access violation.
This function should not be called for Public Groups.
37
OPC Data Access Custom Interface Specification 2.05
4.4.4.6 IOPCServer::CreateGroupEnumerator
HRESULT CreateGroupEnumerator(
[in] OPCENUMSCOPE dwScope,
[in] REFIID riid,
[out, iid_is(riid)] LPUNKNOWN* ppUnk
);
Description
Create various enumerators for the groups provided by the Server.
Parameters Description
dwScope Indicates the class of groups to be enumerated
OPC_ENUM_PRIVATE_CONNECTIONS or
OPC_ENUM_PRIVATE enumerates all of the private
groups created by the client
OPC_ENUM_PUBLIC_CONNECTIONS or
OPC_ENUM_PUBLIC enumerates all of the public
groups available in the server
OPC_ENUM_ALL_CONNECTIONS or
OPC_ENUM_ALL enumerates all private groups and
all public groups
riid The interface requested. This must be
IID_IEnumUnknown or IID_IEnumString.
ppUnk Where to return the interface. NULL is returned for
any HRESULT other than S_OK or S_FALSE.
NOTE: Version 1.0 of this specification described slightly different behavior for enumerating connected vs
non-connected groups. However this behavior has been found to be difficult or impossible to implement in
practice. The description here represents a simplification of this behavior. It is recommended that use of
OPC_ENUM_PRIVATE_CONNECTIONS, OPC_ENUM_PUBLIC_CONNECTIONS,
OPC_ENUM_ALL_CONNECTIONS be avoided by clients.
38
OPC Data Access Custom Interface Specification 2.05
Comments
Connected means an interface pointer exists.
Servers which do not support public groups will simply behave as if they had no public groups. That is
they will NOT return E_INVALIDARG if the scope includes public groups.
IEnumUnknown creates an additional interface pointer to each group in the enumeration (even if the
client already has a connection to the group). If the server has a large number of public groups
available then this may involve considerable overhead as well as requiring additional cleanup by the
client. In general, enumerating groups by name will be much faster.
In the case of IEnumUnknown (per the COM specification) the client must also release all of the
returned IUnknown pointers when he is done with them.
39
OPC Data Access Custom Interface Specification 2.05
40
OPC Data Access Custom Interface Specification 2.05
4.4.5.1 IConnectionPointContainer::EnumConnectionPoints
HRESULT EnumConnectionPoints(
IEnumConnectionPoints **ppEnum
);
Description
Create an enumerator for the Connection Points supported between the OPC Group and the Client.
Parameters Description
ppEnum Where to save the pointer to the connection point
enumerator. See the Microsoft documentation for a
discussion of IEnumConnectionPoints.
41
OPC Data Access Custom Interface Specification 2.05
Description
Find a particular connection point between the OPC Server and the Client.
Parameters Description
ppCP Where to store the Connection Point. See the Microsoft
documentation for a discussion of IConnectionPoint.
riid The IID of the Connection Point. (e.g.
IID_IOPCShutdown)
42
OPC Data Access Custom Interface Specification 2.05
4.4.6 IOPCItemProperties
Overview
This interface can be used by clients to browse the available properties (also refered to as attributes or
parameters) associated with an ITEMID and to read the current values of these properties. In some
respects the functionality is similar to that provided by BrowseServerAddressSpace, by
EnumItemAttributes and by the SyncIO Read function. It differs from these interfaces in two important
respects; (a) it is intended be much easier to use and (b) it is not optimized for efficient access to large
amounts of data. Rather it is intended to allow an application to easily browse and read small amounts
of additional information specific to a particular ITEMID.
The design of this interface is based upon the assumption is that many ITEMIDs are associated with
other ITEMIDs which represent related values such as Engineering Units range or Description or
perhaps Alarm Status. For example the system might be built internally of 'records' which represent
complex objects (like PID Controllers, Timers, Counters, Analog Inputs, etc). These record items
would have properties (like current value, setpoint, hi alarm limit, low alarm limit, description, etc).
As a result, this interface allows a flexible and convenient way to browse, locate and read this related
information without imposing any particular design structure on the underlying system.
It also allows such information to be read without the need to create and manage OPCGroups.
In most cases, a system like the one above (i.e. one composed internally of 'records') would also
expose a hierarchical address space to OPC in the form of A100 as a 'branch' and A100.CV, A100.SP,
A100.OUT, A100.DESC as 'leafs'. In other words, the properties of an item which happens to be a
record will generally map into lower level ITEMIDS. Another way to look at this is that things that
have properties like A100 are going to be things that show up as 'Branch' Nodes in the OPC Browser
and things that are properties are going to show up as 'Leaf' nodes in the OPC Browser.
Note that the A100 item could in fact be embedded in a higher level "Plant.Building.Line" hierarchy
however for the moment we will ignore this as it is not relevant to this discussion.
So, the general intent of this interface is to provide a way, given an ITEMID of any one of a number of
related its properties (like A100.CV or A100.DESC or even A100), to identify the other related
properties.
Before we begin however it should be noted that the first 6 properties (the OPC Specific Property Set
1) are 'special cases' in that they represent data that would exist within the OPC Server if this item were
added to an OPC Group and do not represent properties of the 'real' tag record in the underlying
system. As a result, these particular property IDs will generally behave differently in the methods on
this interface as described below.
The expected use of this is that you would pass it an ITEMID such as A100 which represents a 'record'
object although you can also pass it a fully qualified ITEMID such as A100.CV or A100.SP. In any
case you will get back a list of all of the other properties related to this item; typically, these are the
other properties of the record object. Except for properties 1-6 it is not relevant whether the starting
ITEMID reflects the record object or one of its property objects. Either way you will get back the same
result - i.e. the list of properties in the containing 'record' object.
As noted above properties 1-6 have special behavior. They will refer to the OPC Item Data within the
server for this particular item. If the passed ITEMID would not have made sense when passed to
AddItem then the special 1-6 properties will not be available. For example if adding A100 (rather than
A100.CV) would produce an error from AddItem then properties 1-6 are not available for A100.
43
OPC Data Access Custom Interface Specification 2.05
Note that a server could chose to assign a 'default' value to an unqualified tag such that for example
A100 becomes equivalent to A100.CV. Such a server might chose to return properties 1-6 when passed
an unqualified ITEMID such as A100..
The expected use is that you would pass the same ITEMID to this function as you passed to
QueryAvailableProperties since, logically, the Property ID list returned by QueryAvailableProperties is
valid only for exactly that ITEMID. Again note that except for properties 1-6 it does not matter
whether the ITEMID is A100, A100.CV or A100.DESC, the properties will still return the appropriate
properties of the container record.
Properties 1-6 have special behavior in that their behavior does vary based on the ITEMID. For
example, property 2 (Current Value) would return the value of A100.CV if that were the passed
ITEMID or the value or A100.SP if that were the passed ITEMID or might be invalid if the passed
ITEMID were simply A100.
The expected use is that you would pass the same ITEMID to this function as you passed to
QueryAvailableProperties since, logically, the Property ID list returned by QueryAvailableProperties is
valid only for exactly that ITEMID. Again note that except in the case of properties 1-6 it does not
matter whether the ITEMID is A100, A100.CV or A100.DESC, the returned ITEMIDs will still reflect
the ITEMIDs of the appropriate properties of the container record.
Because properties 1-6 reflect data stored within the server and are not really related to properties of
the item, there will never be any ITEMIDs returned for these properties and they should never be
passed to this function. Doing so will generate an OPC_E_INVALID_PID error for the passed
property.
Typical Use
Typical Client use of this interface would be to obtain an ITEMID either by obtaining a 'LEAF' via
BrowseServerAddress or via direct input to an edit box by the user. That ITEMID would be passed to
QueryAvailableProperties(). The resulting list would be presented to the user. He would select the
properties he wanted to see from the list. The client would pass this set to GetItemProperties () to get a
'snapshot' of the data. Optionally the client could pass the set to LookupItemIDs and use the resulting
set of ITEMIDs to create an OPCGroup to be used to repeatedly obtain the data.
Examples
This is just an example. It is not intended to impose any particular structure on any server
implementation.
A typical OPC ITEMID might be FIC101.CV. This could represent the current value of a tag or
function block called FIC101. This function block commonly has other properties associated with it
such as Engineering Units, a loop description, etc. This function block could also have alarm limits and
status, a setpoint, tuning parameters as well as documentation cross references, maintenance
information, help screens, default operator displays and a limitless set of other properties. All of these
properties are associated with each other by virtue of their common association with FIC101. This
interface provides a convenient shortcut to accessing those related properties.
An MMI package for example might use this interface to allow the user to indicate that the Hi and Lo
Engineering Units values should be used to scale a bargraph representation of the value.
44
OPC Data Access Custom Interface Specification 2.05
Note that because these associations can be 'many to many' and can also be circular, a client
application would not want to automatically investigate them all.
It is NOT intended that property browsing be hierarchical.
Another similar example could be a function block such as a TIMER or COUNTER in a high end PLC
where various Properties are associated with each object.
How ‘Properties’ relate to ItemIDs.
In most cases it is expected (but not required) that such properties can also be accessed via ItemIDs
such as FIC101.HI_EU, FIC101.DESC, FIC101.ALMSTAT, etc. These related ITEMIDs could be
used in an OPCGroup. This interface provides a way to easily determine if such an alternate method of
access can be used for the properties if large amounts of information need to be obtained more
efficiently.
Property IDs
The server will need to assign DWORD ID codes to the properties. This allows the client to more
easily manage the list of properties it wants to access. These properties are divided (somewhat
arbitrarily) into 3 ‘sets’. The OPC ‘Fixed’ set contains properties that are identical to some of those
returned by OPCITEMATTRIBUTES, the ‘recommended’ set is expected to be common to many
servers, the ‘vendor specific’ set contains additional properties as appropriate. The assigned IDs for the
first two sets are fixed. The vendor specific properties should use ID codes above 5000.
The OPC Property Sets
This is a set of property IDs that are common to many servers. Servers which provide the coresponding
properties must do so using the ID codes from this list. Symbolic equates for these properties are
provided in the OPCProps.H file. (See Appendix to this document).
ID Set 1 - OPC Specific Properties - This includes information directly related to the OPC Server for
the system.
45
OPC Data Access Custom Interface Specification 2.05
46
OPC Data Access Custom Interface Specification 2.05
47
OPC Data Access Custom Interface Specification 2.05
48
OPC Data Access Custom Interface Specification 2.05
400- Reserved for future OPC use. Additional IDs may be added without
4999 revising the interface ID.
NOTE the OPC Foundation reserves the right to expand this list from time to time. Clients
should be prepared to deal with this.
The client should take care dealing with these vendor specific IDs - i.e. not make assumptions about
them. Different vendors may not provide the same information for IDs of 5000 and above.
Note again that this interface is NOT intended to allow efficient access to large amounts of data.
The LocaleID of the server (as set by IOPCCommon::SetLocaleID) will be used by the server to
localize any data items returned as strings. The item descriptions are not localized.
49
OPC Data Access Custom Interface Specification 2.05
4.4.6.1 IOPCItemProperties::QueryAvailableProperties
HRESULT QueryAvailableProperties(
[in] LPWSTR szItemID,
[out] DWORD * pdwCount,
[out, size_is(,*pdwCount)] DWORD **ppPropertyIDs,
[out, size_is(,*pdwCount)] LPWSTR *ppDescriptions,
[out, size_is(,*pdwCount)] VARTYPE **ppvtDataTypes
);
Description
Return a list of ID codes and descriptions for the available properties for this ITEMID. This list may
differ for different ItemIDs. This list is expected to be relatively stable for a particular ItemID. That is,
it could be affected from time to time by changes to the underlying system’s configuration.
Parameters Description
szItemID The ItemID for which the caller wants to know the
available properties
pdwCount The number of properties returned
ppPropertyIDs DWORD IDs for the returned properties. These IDs
can be passed to GetItemProperties or LookupItemIDs
ppDescriptions A brief vendor supplied text description of each
property. NOTE LocaleID does not apply to
Descriptions. They are from the tables above.
ppvtDataTypes The datatype which will be returned for this property
by GetItemProperties.
Comments
The ItemID is passed to this function because servers are allowed to return different sets of properties
for different ItemIDs.
50
OPC Data Access Custom Interface Specification 2.05
4.4.6.2 IOPCItemProperties::GetItemProperties
HRESULT GetItemProperties(
[in] LPWSTR szItemID,
[in] DWORD dwCount,
[in, size_is(dwCount)] DWORD * pdwPropertyIDs,
[out, size_is(,dwCount)] VARIANT ** ppvData,
[out, size_is(,dwCount)] HRESULT **ppErrors
);
Description
Return a list of the current data values for the passed ID codes.
Parameters Description
szItemID The ItemID for which the caller wants to read the list
of properties.
dwCount The number of properties passed
ppPropertyIDs DWORD IDs for the requested properties. These IDs
were returned by QueryAvailableProperties or obtained
from the fixed list described earlier.
ppvData An array of count VARIANTS returned by the server
which contain the current values of the requested
properties.
ppErrors Error array indicating wether each property was
returned.
51
OPC Data Access Custom Interface Specification 2.05
Comments
The caller must Free the returned Variants and Errors array. The client must first do a VariantClear()
on each of the returned Variants.
Clients should not use this interface to obtain large amounts of data. Clearly each server vendor will
provide the best performace possible however as a practical matter it is expected that the design of this
interface will make it difficult for the server to optimize performace. See LookupItemIDs.
52
OPC Data Access Custom Interface Specification 2.05
4.4.6.3 IOPCItemProperties::LookupItemIDs
HRESULT LookupItemIDs(
[in] LPWSTR szItemID,
[in] DWORD dwCount,
[in, size_is(dwCount)] DWORD *pdwPropertyIDs,
[out, string, size_is(,dwCount)] LPWSTR ** ppszNewItemIDs,
[out, size_is(,dwCount)] HRESULT **ppErrors
);
Description
Return a list of ITEMIDs (if available) for each of the passed ID codes. These indicate the ITEMID
which could be added to an OPCGroup and used for more efficient access to the data corresponding to
the Item Properties.
Parameters Description
szItemID The ItemID for which the caller wants to lookup the
list of properties
dwCount The number of properties passed
pdwPropertyIDs DWORDIDs for the requested properties. These IDs
were returned by QueryAvailableProperties
ppszNewItemIDs The returned list of ItemIDs.
ppErrors Error array indicating wether each New ItemID was
returned.
53
OPC Data Access Custom Interface Specification 2.05
Comments
It is expected and recommended that servers will allow most or all item properties to be translated into
specific ItemIDs.
The caller must Free the returned NewItemIDs and Errors array.
54
OPC Data Access Custom Interface Specification 2.05
Public Groups
An application may be designed so that the same groups of data items are used by many clients. In
those cases the optional Public Group capability of the server provides a convenient mechanism for
both clients and servers to share these groups.
Public groups may be created by the server or they may be created by a client. When created by the
client, they are first created as private groups and then converted to public groups by MoveToPublic.
A client can enumerate the available public groups by name using
IOPCServer::CreateGroupEnumerator. He can ‘connect’ to a public group by calling
GetPublicGroupByName. He can examine the contents of the group via IEnumOPCItemAttributes. He
can assign client handles and datatypes that are meaningful for the particular client using various
IOPCItemMgt functions.
Once a client connects to a Public group, it behaves very much like a private group. He can activate
and deactivate the group or items in the group. He can set client handles for the group and items within
the group. He can set requested data type for the items in the group. All of these operations affect only
that particular client. They do not affect the behavior of other clients connected to that group. The
exception to this behavior is that he cannot add or remove items.
55
OPC Data Access Custom Interface Specification 2.05
Description
‘Connects’ the client to a public group. This returns an interface pointer to the group.
Parameters Description
szName Name of group to be connected
riid requested interface
ppUnk pointer to place to store interface. NULL is returned for
any HRESULT other than S_OK
Return Codes
Return Code Description
E_FAIL The operation failed.
E_OUTOFMEMORY Not enough memory
E_INVALIDARG An argument to the function was invalid.
S_OK The operation succeeded.
E_NOINTERFACE The interface(riid) asked for is not supported by the
server.
OPC_E_NOTFOUND Requested Public Group was not found.
Comments
If needed, the client can obtain the hServerGroup Handle via IOPCGroupStateMgt::GetState.
Note that when the client’s last interface for the public group is released, the client is effectively
disconnected from the group. At this point the server should release any resources or instance data
associated with this particular client’s connection to the public group. It is not necessary for the client
to call RemoveGroup or RemovePublicGroup to free these client specific resources.
56
OPC Data Access Custom Interface Specification 2.05
Description
Delete a public group.
Parameters Description
hServerGroup Handle of group to be removed.
bForce Forces deletion of the group even if references are
outstanding
Return Codes
Return Code Description
E_FAIL The operation failed.
E_OUTOFMEMORY Not enough memory
E_INVALIDARG An argument to the function was invalid.
S_OK The operation succeeded.
OPC_S_INUSE Was not be removed because references exist. Group
will be marked as deleted, and will be removed by the
server when all references to this object are released.
Comments
A public group is not deleted when all the client interfaces are released, since the server itself
maintains a reference to the group. The client may still call GetPublicGroupByName after all the
interfaces have been released. RemovePublicGroup() causes the server to release it's `last' reference to
the group, which results in the group being truly deleted.
It is permissible for a server to publish ‘hard coded’ groups which cannot be deleted. The server should
return E_FAIL in this case.
In general, a well behaved client will call this function only after releasing all interfaces.
If interfaces still exist, RemovePublicGroup will mark the group as ‘deleted’. Any further calls to this
group via these interfaces will return E_FAIL. When all the interfaces are released, the group will
actually be deleted. If bForce is TRUE then the group is deleted unconditionally even if references
(interfaces) still exist. Subsequent use of such interfaces will result in an access violation.
Note that any client can delete a public group. You can get the server handle of the group by calling
IOPCGroupStateMgt::GetState.
57
OPC Data Access Custom Interface Specification 2.05
58
OPC Data Access Custom Interface Specification 2.05
Example 2
<ROOT>
PLC_STATION_1 (branch)
ANALOG_VALUES (branch)
40001 (leaf)
40002
etc…
59
OPC Data Access Custom Interface Specification 2.05
Description
Provides a way to determine if the underlying system is inherently flat or hierarchical and how the
server may represent the information of the address space to the client.
Parameters Description
pNameSpaceType Place to put OPCNAMESPACE result which will be
OPC_NS_HIERARCHIAL or OPC_NS_FLAT
Return Codes
Return Code Description
E_FAIL The operation failed.
E_OUTOFMEMORY Not enough memory
E_INVALIDARG An argument to the function was invalid.
S_OK The operation succeeded.
Comments
FLAT and HIERARCHICAL spaces behave somewhat different. If the result is ‘FLAT’ then the
client knows that there is no need to pass the BRANCH or LEAF flags to BrowseOPCItemIDs or to
call ChangeBrowsePosition
60
OPC Data Access Custom Interface Specification 2.05
Description
Provides a way to move ‘up’ or ‘down’ or 'to' in a hierarchical space.
Parameters Description
dwBrowseDirection OPC_BROWSE_UP or OPC_BROWSE_DOWN or
OPC_BROWSE_TO.
szString For DOWN, the name of the branch to move into. This
would be one of the strings returned from
BrowseOPCItemIDs.
E.g. REACTOR10
For UP this parameter is ignored and should point to a
NUL string.
For TO a fully qualified name (e.g. as returned from
GetItemID) or a pointer to a NUL string to go to the
'root'.
E.g. AREA1.REACTOR10.TIC1001
Return Codes
Return Code Description
E_FAIL The operation failed.
E_OUTOFMEMORY Not enough memory
E_INVALIDARG An argument to the function was invalid.
S_OK The operation succeeded.
Comments
The function will return E_FAIL if called for a FLAT space.
An error is returned if the passed string does not represent a ‘branch’.
Moving UP from the ‘root’ will return E_FAIL.
Note OPC_BROWSE_TO is new for version 2.0. Clients should be prepared to handle
E_INVALIDARG if they pass this to a 1.0 server.
61
OPC Data Access Custom Interface Specification 2.05
HRESULT BrowseOPCItemIDs(
[in] OPCBROWSETYPE dwBrowseFilterType,
[in, string] LPCWSTR szFilterCriteria,
[in] VARTYPE vtDataTypeFilter,
[in] DWORD dwAccessRightsFilter,
[out] LPENUMSTRING * ppIEnumString
);
Description
Returns an IENUMString for a list of ItemIDs as determined by the passed parameters. The position
from the which the browse is done can be set via ChangeBrowsePosition.
Parameters Description
dwBrowseFilterType OPC_BRANCH - returns only items that have children
OPC_LEAF - returns only items that don’t have children
OPC_FLAT - returns everything at and below this level
including all children of children - basically ‘pretends’ that
the address space in actually FLAT
This parameter is ignored for FLAT address space.
szFilterCriteria A server specific filter string. This is entirely free format
and may be entered by the user via an EDIT field.
Although the valid criteria are vendor specific, source code
for a recommended filter function is included in an
Apppendix at the end of this document. This particular filter
function is commonly used by OPC interfaces and is very
similar in functionality to the LIKE function in visual basic.
A pointer to a NUL string indicates no filtering.
vtDataTypeFilter Filter the returned list based in the available datatypes
(those that would succeed if passed to AddItem).
VT_EMPTY indicates no filtering.
dwAccessRightsFilter Filter based on the AccessRights bit mask
(OPC_READABLE or OPC_WRITEABLE). The bits
passed in the bitmask are 'ANDed' with the bits that would
be returned for this Item by AddItem, ValidateItem or
EnumOPCItemAttributes. If the result is non-zero then the
item is returned. A 0 value in the bitmask indicates that the
AccessRights bits should be ignored during the filtering
process..
ppIEnumString Where to save the returned interface pointer. NULL if the
HRESULT is other than S_OK or S_FALSE
62
OPC Data Access Custom Interface Specification 2.05
Return Codes
Return Code Description
S_OK The operation succeeded.
S_FALSE There is nothing to enumerate. However an empty
Enumerator is still returned and must be released.
Note: In previous versions of the spec there has
been some ambiguity about the behavior in the
case of S_FALSE. For this reason, it is
recommended that when S_FALSE is returned by
the server, clients test the returned interface
pointer for NULL prior to calling Release on it.
E_FAIL The operation failed.
E_OUTOFMEMORY Not enough memory
E_INVALIDARG An argument to the function was invalid.
OPC_E_INVALIDFILTER The filter string was not valid
Comments
The returned enumerator may have nothing to enumerate if no ItemIDs satisfied the filter constraints.
The strings returned by the enumerator represent the BRANCHs and LEAFS contained in the current
level. They do NOT include any delimiters or ‘parent’ names. (See GetItemID).
Whenever possible the server should return strings which can be passed directly to AddItems.
However, it is allowed for the Server to return a ‘hint’ string rather than an actual legal Item ID. For
example a PLC with 32000 registers could return a single string of “0 to 31999” rather than return
32,000 individual strings from the enumerator. For this reason (as well as the fact that browser support
is optional) clients should always be prepared to allow manual entry of ITEM ID strings. In the case of
‘hint’ strings, there is no indication given as to whether the returned string will be acceptable by
AddItem or ValidateItem
Clients are allowed to get and hold Enumerators for more than one ‘browse position’ at a time.
Changing the browse position will not affect any String Enumerator the client already has.
The client must Release each Enumerator when he is done with it.
63
OPC Data Access Custom Interface Specification 2.05
Description
Provides a way to assemble a ‘fully qualified’ ITEM ID in a hierarchical space. This is required since
the browsing functions return only the components or tokens which make up an ITEMID and do NOT
return the delimiters used to separate those tokens. Also, at each point one is browsing just the names
‘below’ the current node (e.g. the ‘units’ in a ‘cell’).
Parameters Description
szItemDataID The name of a BRANCH or LEAF at the current level.
or a pointer to a NUL string. Passing in a NUL string
results in a return string which represents the current
position in the hierarchy.
szItemID Where to return the resulting ItemID.
Return Codes
Return Code Description
E_FAIL The function failed
E_INVALIDARG An argument to the function was invalid. (e.g. the
passed ItemDataID was invalid)
E_INVALIDARG An argument to the function was invalid.
E_OUTOFMEMORY Not enough memory
S_OK The function was successful
Comments
A client would browse down from AREA1 to REACTOR10 to TIC1001 to CURRENT_VALUE. As
noted earlier the client sees only the components, not the delimiters which are likely to be very server
specific. The function rebuilds the fully qualified name including the vendor specific delimiters for use
by ADDITEMs. An extreme example might be a server that returns:
\\AREA1:REACTOR10.TIC1001[CURRENT_VALUE]
It is also possible that a server could support hierarchical browsing of an address space that contains
globally unique tags. For example in the case above, the tag TIC1001.CURRENT_VALUE might still
be globally unique and might therefore be acceptable to AddItem. However the expected behavior is
that (a) GetItemID will always return the fully qualified name
(AREA1.REACTOR10.TIC1001.CURRENT_VALUE) and that (b) that the server will always accept
the fully qualified name in AddItems (even if it does not require it).
This function does not need to be called for a FLAT space. If it is called, then the server must return
the same string that was passed in.
It is valid to form an ItemID that represents a BRANCH (e.g. AREA1.REACTOR10). This could
happen if you pass a BRANCH (AREA1) rather than a LEAF (CURRENT_VALUE). The resulting
string might fail if passed to AddItem but could be passed to ChangeBrowsePosition using
OPC_BROWSE_TO.
The client must free the returned string.
64
OPC Data Access Custom Interface Specification 2.05
ItemID is the unique ‘key’ to the data, it is considered the ‘what’ or ‘where’ that allows the server to
connect to the data source.
65
OPC Data Access Custom Interface Specification 2.05
Description
Provides a way to browse the available AccessPaths for an ITEM ID.
Parameters Description
szItemID Fully Qualified ItemID
ppIEnumString Where to save the returned string enumerator. NULL if
the HRESULT is other than S_OK or S_FALSE.
Return Codes
Return Code Description
E_FAIL The function failed
E_INVALIDARG An argument to the function was invalid.
S_FALSE There is nothing to enumerate. However an empty
Enumerator is still returned and must be released. Note:
In previous versions of the spec there has been some
ambiguity about the behavior in the case of S_FALSE.
For this reason, it is recommended that when S_FALSE
is returned by the server, clients test the returned
interface pointer for NULL prior to calling Release on it.
E_OUTOFMEMORY Not enough memory
E_NOTIMPL The server does not require or support access paths.
S_OK The function was successful
Comments
Clients are allowed to get Access Path Enumerators for more than one item at a time.
Changing the browse position will not affect any enumerator the client already has.
The client must Release each Enumerator when he is done with it.
AccessPath is the “how” for the server to get the data specified by the itemID (the what). The client
uses this function to identify the possible access paths for the specified itemID.
66
OPC Data Access Custom Interface Specification 2.05
4.4.9.1 IPersistFile::IsDirty
HRESULT IsDirty(
void
);
Description
Returns whether or not there have been any configuration changes (by any client) since the last save
operation.
Parameters
Return Codes
Return Code Description
S_OK The server has configuration information that has been modified since
the last save operation.
S_FALSE The server does not have configuration information that has been
modified since the last save operation.
Comments
The client cannot change any of the configuration of the server address space through a standard OPC
interface. The client uses this function to determine if the configuration has been modified by a server
specific configuration tool or by a client using a server specific configuration interface. This function
could be used by the client before shutting the server down to determine if the server’s configuration
needs to be saved.
67
OPC Data Access Custom Interface Specification 2.05
4.4.9.2 IPersistFile::Load
HRESULT Load(
[in] LPCOLESTR pszFileName,
[in] DWORD dwMode
);
Description
Instructs the server to load the server’s configuration data from the file (pszFileName). The previous
configuration (if any) is replaced by the new configuration. OPC servers are assumed to support a
single (global) active configuration. That is, a load will affect all other OPC clients which are
accessing this server.
The exact effect of doing a load while groups and subscriptions are active is server specific. In
general, it is assumed that this will cause some or all of the items in the active groups to disappear
from the server address space. Such items would subsequently return a BAD Quality.
Parameters Description
pszFileName The filename from which the server configuration information is to be
loaded.
dwMode Access mode to be used on the file. See ‘Storage Access Mode Flags”
in the OLE programmer’s reference for more information.
Return Codes
Return Code Description
S_OK The server successfully loaded configuration information
from the file specified.
E_FAIL The server was unsuccessful in loading the configuration
information from the file specified.
E_OUTOFMEMORY Not enough memory to load configuration.
OPC_E_INVALIDCONFIGFILE The server's configuration file is an invalid format.
Comments
In most cases, an error during load will leave the server without a valid configuration.
A load will cause other clients connected to this server to be effectively disconnected, or the results of
the other clients subsequent interactions with the server to be unknown.
4.4.9.3 IPersistFile::Save
HRESULT Save(
[in, unique] LPCOLESTR pszFileName,
[in] BOOL fRemember
);
68
OPC Data Access Custom Interface Specification 2.05
Description
Parameters
Parameters Description
pszFileName The filename to which the server configuration information is to be
saved.
fRemember Determines of the logically associated filename for this configuration
should be changed (if TRUE) or not (if FALSE).
Return Codes
Return Code Description
S_OK The server successfully saved configuration information
E_FAIL The server was unsuccessful in saving the configuration
OPC_E_INVALIDCONFIGFILE The server's configuration file is an invalid format.
Comments
Save should clear the server’s configuration dirty flag (as returned from IsDirty interface).
4.4.9.4 IPersistFile::SaveCompleted
HRESULT SaveCompleted(
[in, unique] LPCOLESTR pszFileName
);
Description
Parameters Description
pszFileName The filename to which the configuration was previously saved using
IPersistFile::Save
Return Codes
Return Code Description
S_OK S_OK is always returned
OPC_E_INVALIDCONFIGFILE The server's configuration file is an invalid format.
Comments
69
OPC Data Access Custom Interface Specification 2.05
4.4.9.5 IPersistFile::GetCurFile
HRESULT GetCurFile(
[out] LPOLESTR *ppszFileName
);
Description
Instructs the server to return the name associated with the currently loaded configuration.
Parameters Description
ppszFileName The full filename (if any).
Return Codes
Return Code Description
S_OK The operation succeeded
S_FALSE There is not filename currently associated with the configuration
E_OUTOFMEMORY Not enough memory
E_FAIL operation failed
Comments
This may or may not match the last name passed to Load or Save since there can be other vendor
specific tasks that control the server configuration.
The client must free the returned string.
70
OPC Data Access Custom Interface Specification 2.05
71
OPC Data Access Custom Interface Specification 2.05
4.5.1.1 Name
Each group has a name. For private groups the name must be unique among the other private groups
that belong to that client. For public groups the name must be unique among all of the public groups.
While a client can change the name of a private group, the name of a public group cannot be changed.
A private Group and a public group may have the same name as long as the client is not connected to
the public group with the same name.
Group names are Case Sensitive. Group1 would be different from group1.
4.5.1.3 Active
Groups and Items within Groups have an Active Flag. The active state of the group is maintained
separately from the active state of the items. Changing the state of the group does not change the state
of the items.
For the most part the Active flag is treated as ‘abstract’ within this specification. The state of these
flags affects the described behavior of various interfaces in a well defined way. The implementation
details of these capabilities is not dictated by this specification.
In practice it is expected that most servers will make use of this flag to optimize their use of
communications and CPU resources. Items and Groups which are not active do not need to be
maintained in the CACHE.
It is also expected that clients will simply set and clear active flags of groups and items as a more
efficient alternative to adding and removing entire groups and items. For example if an operator
display is minimized, its items might be set to inactive.
Refer to the Data Acquisition and Active State Behavior summary earlier in this document for a
quick overview of the behavior of a client and server with respect to the active state of a group
and items.
OnDataChange within the client's address space can be called whenever any active item data in a
active group changes, where “change” is defined as a change in value (from the last value sent to this
client), or a change in the Quality of the value. The server can return values and quality flags for those
items within the group that changed.(this will be discussed more in later sections)
72
OPC Data Access Custom Interface Specification 2.05
73
OPC Data Access Custom Interface Specification 2.05
the server. If the client does not specify this value on a server that does support the behavior, the
default value of 0 (zero) will be assumed, and all value changes will update the CACHE. Note that the
timestamp will be updated regardless of wether the cached value is updated. A server which does not
support deadband should return an error (INVALID_PARAMETER) if the client requests a deadband
other than 0.0.
The UpdateRate for a group determines time between when a value is checked to see if the exception
limit has been exceeded. The PercentDeadband is used to keep noisy signals from updating the client
unnecessarily.
4.5.1.7 ClientHandle
This handle will be returned in the data stream to IAdviseSink. This allows the client to identify the
group to which the data packet belongs.
It is expected that a client will assign unique value to the client handle if it intends to use any of the
asynchronous functions of the OPC interfaces, including IOPCAsyncIO, IOPCAsyncIOs, and
IDataObject/IAdviseSink or IConnectionPoint/IOPCDataCallback interfaces.
74
OPC Data Access Custom Interface Specification 2.05
4.5.2 IOPCItemMgt
IOPCItemMgt allows a client to add, remove and control the behavior of items is a group.
4.5.2.1 IOPCItemMgt::AddItems
HRESULT AddItems(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCITEMDEF * pItemArray,
[out, size_is(,dwCount)] OPCITEMRESULT ** ppAddResults,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
Description
Add one or more items to a group.
Parameters Description
dwCount The number of items to be added
pItemArray Array of OPCITEMDEFs. These tell the server
everything it needs to know about the item including
the access path, definition and requested datatype
ppAddResults Array of OPCITEMRESULTs. This tells the client
additional information about the item including the
server assigned item handle and the canonical datatype.
ppErrors Array of HRESULTs. This tells the client which of the
items was successfully added. For any item which
failed it provides a reason.
75
OPC Data Access Custom Interface Specification 2.05
76
OPC Data Access Custom Interface Specification 2.05
4.5.2.2 IOPCItemMgt::ValidateItems
HRESULT ValidateItems(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCITEMDEF * pItemArray,
[in] BOOL bBlobUpdate,
[out, size_is(,dwCount)] OPCITEMRESULT ** ppValidationResults,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
Description
Determines if an item is valid (could it be added without error). Also returns information about the
item such as canonical datatype. Does not affect the group in any way.
Parameters Description
dwCount The number of items to be validated
pItemArray Array of OPCITEMDEFs. These tell the server
everything it needs to know about the item including
the access path, definition and requested datatype
bBlobUpdate If non-zero (and the server supports Blobs) the server
should return updated Blobs in OPCITEMRESULTs. If
zero (False) the server will not return Blobs in
OPCITEMRESULTs.
ppValidationResults Array of OPCITEMRESULTs. This tells the client
additional information about the item including the
canonical datatype.
ppErrors Array of HRESULTs. This tells the client which of the
items was successfully validated. For any item which
failed it provides a reason.
77
OPC Data Access Custom Interface Specification 2.05
ppErrors Codes
Return Code Description
S_OK The function was successful for this item.
OPC_E_INVALIDITEMID The ItemID is not syntactically valid
OPC_E_UNKNOWNITEMID The ItemID is not in the server address
space
OPC_E_BADTYPE The requested data type cannot be returned
for this item (See comment)
E_FAIL The function was unsuccessful for this
item.
OPC_E_UNKNOWNPATH The item's access path is not known to the
server.
Comments
The client needs to free all of the memory associated with the OPCITEMRESULTs including the
BLOB.
As an alternative to OPC_E_BADTPYE it is acceptable for the server to return any FAILED error
returned by VariantChangeType or VariantChangeTypeEx.
78
OPC Data Access Custom Interface Specification 2.05
4.5.2.3 IOPCItemMgt::RemoveItems
HRESULT RemoveItems(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
Description
Removes (deletes) items from a group. Basically this is the reverse of AddItems.
Parameters Description
dwCount Number of items to be removed
phServer Array of server items handles. These were returned
from AddItem.
ppErrors Array of HRESULTs. Indicates which items were
successfully removed.
ppError Codes
Return Code Description
S_OK The corresponding item was removed.
OPC_E_INVALIDHANDLE The corresponding Item handle was invalid.
Comments
Adding and removing items from a group does not affect the address space of the server or physical
device. It simply indicates whether or not the client is interested in those particular items.
Items are not really objects in the custom interface (do not have interfaces), and there is no concept of
a reference count for items. The client should insure that no further references are made to deleted
items.
Items cannot be removed from a public group.
79
OPC Data Access Custom Interface Specification 2.05
4.5.2.4 IOPCItemMgt::SetActiveState
HRESULT SetActiveState(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[in] BOOL bActive,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
Description
Sets one or more items in a group to active or inactive. This controls whether or not valid data can be
obtained from Read CACHE for those items and whether or not they are included in the IAdvise
subscription to the group.
Parameters Description
dwCount The number of items to be affected
phServer Array of Server items handles.
bActive TRUE if items are to be activated. FALSE if items are
to be deactivated.
ppErrors Array of HRESULTs. Indicates which items were
successfully affected.
80
OPC Data Access Custom Interface Specification 2.05
4.5.2.5 IOPCItemMgt::SetClientHandles
HRESULT SetClientHandles(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[in, size_is(dwCount)] OPCHANDLE * phClient,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
Description
Changes the client handle for one or more items in a group.
Parameters Description
dwCount The number of items to be affected
phServer Array of Server items handles.
phClient Array of new Client item handles to be stored. The
Client handles do not need to be unique.
ppErrors Array of HRESULTs. Indicates which items were
successfully affected.
81
OPC Data Access Custom Interface Specification 2.05
4.5.2.6 IOPCItemMgt::SetDatatypes
HRESULT SetDatatypes(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[in, size_is(dwCount)] VARTYPE * pRequestedDatatypes,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
Description
Changes the requested data type for one or more items in a group.
Parameters Description
dwCount The number of items to be affected
phServer Array of Server items handles.
pRequestedDatatypes Array of new Requested Datatypes to be stored.
ppErrors Array of HRESULT’s. Indicates which items were
successfully affected.
82
OPC Data Access Custom Interface Specification 2.05
4.5.2.7 IOPCItemMgt::CreateEnumerator
HRESULT CreateEnumerator(
[in] REFIID riid,
[out, iid_is(riid)] LPUNKNOWN* ppUnk
);
Description
Create an enumerator for the items in the group.
Parameters Description
riid The interface requested. At this time the only
supported OPC interface is
IID_IEnumOPCItemAttributes although vendors can
add their own extensions to this.
ppUnk Where to return the interface. NULL is returned for
any HRESULT other than S_OK
83
OPC Data Access Custom Interface Specification 2.05
4.5.3 IOPCGroupStateMgt
IOPCGroupStateMgt allows the client to manage the overall state of the group. Primarily this allows
changes to the update rate and active state of the group.
4.5.3.1 IOPCGroupStateMgt::GetState
HRESULT GetState(
[out] DWORD * pUpdateRate,
[out] BOOL * pActive,
[out, string] LPWSTR * ppName,
[out] LONG * pTimeBias,
[out] FLOAT * pPercentDeadband,
[out] DWORD * pLCID,
[out] OPCHANDLE * phClientGroup,
[out] OPCHANDLE * phServerGroup
);
Description
Get the current state of the group.
Parameters Description
pUpdateRate The current update rate. The Update Rate is in
milliseconds
pActive The current active state of the group.
ppName The current name of the group
pTimeBias The TimeZone Bias of the group (in minutes)
pPercentDeadband The percent change in an item value that will cause an
exception report of that value to a client. This
parameter only applies to items in the group that have
dwEUType of Analog. [See discussion of Percent
Deadband in General Properties Section]
pLCID The current LCID for the group.
phClientGroup The client supplied group handle
phServerGroup The server generated group handle
84
OPC Data Access Custom Interface Specification 2.05
Comments
This function is typically called to obtain the current values of this information prior to calling
SetState. This information was all supplied by or returned to the client when the group was created.
This function is also useful for debugging.
All out arguments must be valid pointers. The marshaling mechanism requires valid pointers for
proper behavior. NULL pointers will throw an RPC exception.
The client must free the returned ppName string.
85
OPC Data Access Custom Interface Specification 2.05
4.5.3.2 IOPCGroupStateMgt::SetState
HRESULT SetState(
[unique, in] DWORD * pRequestedUpdateRate,
[out] DWORD * pRevisedUpdateRate,
[unique, in] BOOL *pActive,
[unique, in] LONG * pTimeBias,
[unique, in] FLOAT * pPercentDeadband
[unique, in] DWORD * pLCID,
[unique, in] OPCHANDLE *phClientGroup
);
Description
Client can set various properties of the group. Pointers to ‘in’ items are used so that the client can omit
properties he does not want to change by passing a NULL pointer.
The pRevisedUpdateRate argument must contain a valid pointer.
Parameters Description
pRequestedUpdateRate New update rate requested for the group by the client
(milliseconds)
pRevisedUpdateRate Closest update rate the server is able to provide for
this group.
pActive TRUE (non-zero) to active the group. FALSE (0) to
deactivate the group.
pTimeBias TimeZone Bias if Group (in minutes). See
Comments under
).
pPercentDeadband The percent change in an item value that will cause
an exception report of that value to a client. This
parameter only applies to items in the group that
have dwEUType of Analog. See discussion of
Percent Deadband in the General Information
Section
pLCID The Localization ID to be used by the group.
phClientGroup New client supplied handle for the group. This
handle is returned in the data stream provided to the
client’s IAdvise by the Groups IDataObject.
86
OPC Data Access Custom Interface Specification 2.05
Comments
For public groups, the server maintains unique state information for each client for Active,
pUpdateRate, TimeZone. That is, the public groups behave as if each client had it’s own private copy.
Refer to Data Acquistion Section for details on the behavior of an OPC server with respect to the
Synchronous and Asynchronous interfaces and Active state of groups.
As noted in AddGroup the level of localization supported (dwLCID) is entirely server specific.
Servers which do not support dynamic localization can ignore this parameter.
87
OPC Data Access Custom Interface Specification 2.05
4.5.3.3 IOPCGroupStateMgt::SetName
HRESULT SetName(
[in, string] LPCWSTR szName,
);
Description
Change the name of a private group. The name must be unique. The name cannot be changed for
public groups.
Parameters Description
szName New name for group.
Comments
Group names are required to be unique with respect to an individual client to server connection.
88
OPC Data Access Custom Interface Specification 2.05
4.5.3.4 IOPCGroupStateMgt::CloneGroup
HRESULT CloneGroup(
[in, string] LPCWSTR szName,
[in] REFIID riid,
[out, iid_is(riid)] LPUNKNOWN * ppUnk
);
Description
Creates a second copy of a group with a unique name. This works for both public and private groups.
However, the new group is always a private group. All of the group and item properties are duplicated
(as if the same set of AddItems calls had been made for the new group). That is, the new group
contains the same update rate, items, group and item clienthandles, requested data types, etc as the
original group. Once the new group is created it is entirely independent of the old group. You can add
and delete items from it without affecting the old group.
Properties NOT copied to the new group are
• Active Status of the new group is initially set to FALSE
• A new ServerHandle for the group is produced.
• New Item SeverHandles may also be assigned by the server. The client should query for these if it
needs them.
• The new group will NOT be connected to any Advise or Connection point sinks. The client would
need to establish new connections for the new group.
Parameters Description
szName Name of the group. The name must be unique among the
other groups created by this client. If no name is provided
(szName is a pointer to a NUL string) the server will
generate a unique name. The server generated name will
also be unique relative to any existing public groups.
riid requested interface type
ppUnk place to return interface pointer. NULL is returned for
any HRESULT other than S_OK
89
OPC Data Access Custom Interface Specification 2.05
Comments
This represents a new group which is independent of the original group. See AddGroup for a
discussion of Group object lifetime issues. As with AddGroup the group must be deleted with
RemoveGroup when the client is done with it.
The client must also release the returned interface when it is no longer needed.
The primary use or intent of this function is to create a private duplicate of a public group which can
then be modified by the client.
90
OPC Data Access Custom Interface Specification 2.05
4.5.4 IOPCPublicGroupStateMgt
This optional interface is used to convert a private group to a public group. Servers optionally provide
this interface on group objects. A group created by a client is always created initially as a private
group. This interface can be obtained from that private group in order to convert the group to a public
group.
4.5.4.1 IOPCPublicGroupStateMgt::GetState
HRESULT GetState(
[out] BOOL * pPublic
);
Description
Used to determine if a particular group is public or not. If the interface is missing then all groups in the
server are private.
Parameters Description
pPublic TRUE if the group is public, FALSE if it is private
Comments
A server which supports public groups can provide this interface for any group (private or public). In
practice a client will generally know for each group whether it is private or public. However, this
method is useful for debugging.
91
OPC Data Access Custom Interface Specification 2.05
4.5.4.2 IOPCPublicGroupStateMgt::MoveToPublic
HRESULT MoveToPublic(
void
);
Description
Converts a private group to a public group. The group must have a name which must be unique among
all existing public groups. The state of the group (active, UpdateRate, IAdvise connections, etc.) for
the calling client is not affected.
Parameters Description
void
92
OPC Data Access Custom Interface Specification 2.05
4.5.5 IOPCSyncIO
IOPCSyncIO allows a client to perform synchronous read and write operations to a server. The
operations will run to completion.
Refer to the Data Acquisition and Active State Behavior table for an overview of the server data
acquisition behavior and it’s affect on functionality within this interface.
Also refer to the Serialization and Syncronization issues section earlier in this document.
4.5.5.1 IOPCSyncIO::Read
HRESULT Read(
[in] OPCDATASOURCE dwSource,
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[out, size_is(,dwCount)] OPCITEMSTATE ** ppItemValues,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
Description
This function reads the value, quality and timestamp information for one or more items in a group.
The function runs to completion before returning. The data can be read from CACHE in which case it
should be accurate to within the ‘UpdateRate’ and percent deadband of the group. The data can be read
from the DEVICE in which case an actual read of the physical device is to be performed. The exact
implementation of CACHE and DEVICE reads is not defined by this specification.
When reading from CACHE, the data is only valid if both the group and the item are active. If either
the group or the item is inactive, then the Quality will indicate out of service
(OPC_QUALITY_OUT_OF_SERVICE). Refer to the discussion of the quality bits later in this
document for further information.
DEVICE reads are not affected by the ACTIVE state of the group or item.
Refer to the Data Acquisition and Active State Behavior table earlier in this document for an overview
of the server data acquisition behavior and it’s affect on functionality within this interface.
Parameters Description
dwSource The ‘data source’; OPC_DS_CACHE or
OPC_DS_DEVICE
dwCount The number of items to be read.
phServer The list of server item handles for the items to be read
ppItemValues Array of structures in which the item values are
returned.
ppErrors Array of HRESULTs indicating the success of the
individual item reads. The errors correspond to the
handles passed in phServer. This indicates whether the
read succeeded in obtaining a defined value, quality
and timestamp. NOTE any FAILED error code
indicates that the corresponding Value, Quality and
Time stamp are UNDEFINED.
93
OPC Data Access Custom Interface Specification 2.05
ppError Codes
Return Code Description
S_OK Successful Read.
E_FAIL The Read failed for this item
OPC_E_BADRIGHTS The item is not readable
OPC_E_INVALIDHANDLE The passed item handle was invalid.
OPC_E_UNKNOWNITEMID The item is no longer available in the server
address space.
S_xxx S_xxx - Vendor specific information can be
E_xxx provided if this item quality is other than
GOOD.
E_xxx - Vendor specific error if this item
cannot be accessed.
These vendor specific codes can be passed to
GetErrorString().
Comments
If the HRESULT is S_OK, then ppError can be ignored (all results in it are guaranteed to be S_OK).
If the HRESULT is S_FALSE, then ppError will indicate which the status of each individual Item
Read.
If the HRESULT is any FAILED code then (as noted earlier) the server should return NULL pointers
for all OUT parameters including ppErrors.
For any S_xxx ppError code the client should assume the curresponding ITEMSTATE is well defined
although the Quality may be UNCERTAIN or BAD. It is recommended (but not required) that server
vendors provide additional information here regarding UNCERTAIN or BAD items.
For any FAILED ppError code the client should assume the curresponding ITEMSTATE is undefined.
In fact the Server must set the corresponding ITEMSTATE VARIANT to VT_EMPTY so that it can
be marshalled properly and so that the client can execute VariantClear on it.
Note that here (as in the OPCItemMgt methods) OPC_E_INVALIDHANDLE on one item will not
affect the processing of other items and will cause the main HRESULT to return as S_FALSE
Expected behavior is that a CACHE read should be completed very quickly (within milliseconds). A
DEVICE read may take a very long time (many seconds or more). Depending on the details of the
implementation (e.g. which threading model is used) the DEVICE read may also prevent any other
operations from being performed on the server by any other clients.
94
OPC Data Access Custom Interface Specification 2.05
For this reason Clients are expected to use CACHE reads in most cases. DEVICE reads are intended
for ‘special’ circumstances such as diagnostics.
The ppItemValues and ppErrors arrays are allocated by the server and must be freed by the client. Be
sure to call VariantClear() on the variant in the ITEMRESULT.
95
OPC Data Access Custom Interface Specification 2.05
4.5.5.2 IOPCSyncIO::Write
HRESULT Write(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[in, size_is(dwCount)] VARIANT * pItemValues,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
Description
Writes values to one or more items in a group. The function runs to completion. The values are written
to the DEVICE. That is, the function should not return until it verifies that the device has actually
accepted (or rejected) the data.
Writes are not affected by the ACTIVE state of the group or item.
Parameters Description
dwCount Number of items to be written
phServer The list of server item handles for the items to be read
pItemValues List of values to be written to the items. The datatypes
of the values do not need to match the datatypes of the
target items. However an error will be returned if a
conversion cannot be done.
ppErrors Array of HRESULTs indicating the success of the
individual item Writes. The errors correspond to the
handles passed in phServer. This indicates whether the
target device or system accepted the value. NOTE any
FAILED error code indicates that the value was
rejected by the device.
96
OPC Data Access Custom Interface Specification 2.05
ppError Codes
Return Code Description
S_OK The function was successful.
E_FAIL The function was unsuccessful.
OPC_S_CLAMP The value was accepted but was clamped.
OPC_E_RANGE The value was out of range.
OPC_E_BADTYPE The passed data type cannot be accepted for this
item (See comment)
OPC_E_BADRIGHTS The item is not writeable
OPC_E_INVALIDHANDLE The passed item handle was invalid.
OPC_E_UNKNOWNITEMID The item is no longer available in the server
address space
E_xxx Vendor specific errors may also be returned.
S_xxx Descriptive information for such errors can be
obtained from GetErrorString.
97
OPC Data Access Custom Interface Specification 2.05
Comments
If the HRESULT is S_OK, then ppError can be ignored (all results in it are guaranteed to be S_OK).
If the HRESULT is any FAILED code then (as noted earlier) the server should return NULL pointers
for all OUT parameters.
Note that here (as in the OPCItemMgt methods) OPC_E_INVALIDHANDLE on one item will not
affect the processing of other items and will cause the main HRESULT to return as S_FALSE
As an alternative to OPC_E_BADTPYE it is acceptable for the server to return any FAILED error
returned by VariantChangeType or VariantChangeTypeEx.
A DEVICE write may take a very long time (many seconds or more). Depending on the details of the
implementation (e.g. which threading model is used) the DEVICE write may also prevent any other
operations from being performed on the server by any other clients.
For this reason Clients are expected to use ASYNC write rather than SYNC write in most cases.
The ppErrors array is allocated by the server and must be freed by the client.
98
OPC Data Access Custom Interface Specification 2.05
4.5.6 IOPCAsyncIO2
This interface is similar to IOPCAsync. This interface is intended to replace IOPCAsyncIO.
It differs from AsyncIO as follows;
• It is used to control a connection established with IConnectionPoint rather than IDataObject.
ConnectionPoints have been found to be a much cleaner way to return data than IDataObject.
• Some of the error handling logic is enhanced. Read and Write are allowed to return additional
errors (other than Bad Handle).
• The transaction ID logic has been changed. The previous (IOPCAsync) implementation did not
work well in combination with COM marshalling.
• The async read from cache capability is removed. In practice this was just a slower and more
complex form of a sync read from cache. Server design is simplified by removing this.
IOPCAsyncIO2 allows a client to perform asynchronous read and write operations to a server. The
operations will be ‘queued’ and the function will return immediately so that the client can continue to
run. Each operation is treated as a ‘transaction’ and is associated with a transaction ID. As the
operations are completed, a callback will be made to the IOPCDataCallback in the client. The
information in the callback will indicate the transaction ID and the results of the operation.
Also the expected behavior is that for any one transaction to Async Read, Write and Refresh, ALL of
the results of that transaction will be returned in a single call to appropriate function in
IOPCDataCallback.
A server must be able to ‘queue’ at least one transaction of each type (read, write, refresh) for each
group. It is acceptable for a server to return an error (CONNECT_E_ADVISELIMIT) if more than one
transaction of the same type is performed on the same group by the same client. Server vendors may of
course support queueing of additional transactions if they wish.
All operations that are successfully started are expected to complete even if they complete with an
error. The concept of ‘time-out’ is not explicitly addressed in this specification however it is expected
that where appropriate the server will internally implement any needed time-out logic and return a
server specific error to the caller if this occurs.
Client Implementation Note:
The Unique Transaction ID passed to Read, Write and Refresh is generated by the Client and is
returned to the client in the callback as a way to identify the returned data. To insure proper client
operation, this ID should generally be non-zero and should be unique to this particular client/server
conversation. It does not need to be unique relative to other conversations by this or other clients. In
any case however the transactionID is completly client specific and must not be checked by the server.
Note that the Group's Clienthandle is also returned in the callback and is generally sufficient to identify
the returned data.
IMPORTANT NOTE: depending on the mix of client and server threading models used, it has been
found in practice that the IOPCDataCallback can occur within the same thread as the Refresh, Read or
Write and in fact can occur before the Read, Write or Refresh method returns to the caller.
Thus, if the client wants to save a record of the transaction in some list of ‘outstanding transactions’ in
order to verify completion of a transaction it will need to generate the Transaction ID and save it
BEFORE making the method call.
In practice most clients will probably not need to maintain such a list and so do not actually need to
record the transaction ID.
99
OPC Data Access Custom Interface Specification 2.05
4.5.6.1 IOPCAsyncIO2::Read
HRESULT Read(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[in] DWORD dwTransactionID,
[out] DWORD *pdwCancelID,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
Description
Read one or more items in a group. The results are returned via the client’s IOPCDataCallback
connection established through the server’s IConnectionPointContainer.
Reads are from ‘DEVICE’ and are not affected by the ACTIVE state of the group or item.
Parameters Description
dwCount Number of items to be read.
phServer Array of server item handles of the items to be read
dwTransactionID The Client generated transaction ID. This is included in
the ‘completion’ information provided to the
OnReadComplete.
pdwCancelID Place to return a Server generated ID to be used in case
the operation needs to be canceled.
ppErrors Array of errors for each item - returned by the server.
See below.
100
OPC Data Access Custom Interface Specification 2.05
ppError Codes
Return Code Description
S_OK The corresponding Item handle was valid
and the item information will be returned
on OnReadComplete.
E_FAIL The Read failed for this item
OPC_E_BADRIGHTS The item is not readable
OPC_E_INVALIDHANDLE The passed item handle was invalid.
OPC_E_UNKNOWNITEMID The item is no longer available in the
server address space.
E_xxx Vendor specific errors may also be
S_xxx returned. Descriptive information for such
errors can be obtained from
GetErrorString.
Comments
Some servers will be ‘smarter’ at read time and return ‘early’ errors, others may simply queue the
request with minimal checking and return ‘late’ errors in the callback. The client should be prepared to
deal with this.
If the HRESULT is S_OK, then ppError can be ignored (all results in it are guaranteed to be S_OK).
If the HRESULT is any FAILED code then (as noted earlier) the server should return NULL pointers
for all OUT parameters. Note that in this case no Callback will occur.
If ALL errors in ppError are Failure codes then No callback will take place.
Items for which ppError returns any success code (including S_xxx) will be returned in the
OnReadComplete callback. Note that the error result for an item returned in the callback may differ
from that returned from Read.
101
OPC Data Access Custom Interface Specification 2.05
NOTE: the server must return all of the results in a single callback. Thus, if the items in the group
require multiple physical transactions to one or more physical devices then the server must wait until
all of them are complete before invoking OnReadComplete.
The Client must free the returned ppError array.
102
OPC Data Access Custom Interface Specification 2.05
4.5.6.2 IOPCAsyncIO2::Write
HRESULT Write(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[in, size_is(dwCount)] VARIANT * pItemValues,
[in] DWORD dwTransactionID,
[out] DWORD *pdwCancelID,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
Description
Write one or more items in a group. The results are returned via the client’s IOPCDataCallback
connection established through the server’s IConnectionPointContainer.
Parameters Description
dwCount Number of items to be written
phServer List of server items handles for the items to be written
pItemValues List of values to be written. The value data types do not
match the requested or canonical item datatype but
must be ‘convertible’ to the canonical type.
dwTransactionID The Client generated transaction ID. This is included in
the ‘completion’ information provided to the
OnWriteComplete.
pdwCancelID Place to return a Server generated ID to be used in case
the operation needs to be canceled.
ppErrors Array of errors for each item - returned by the server.
See below.
103
OPC Data Access Custom Interface Specification 2.05
ppError Codes
Return Code Description
S_OK The corresponding Item handle was valid.
The write will be attempted and the results
will be returned on OnWriteComplete
E_FAIL The function was unsuccessful.
OPC_E_BADRIGHTS The item is not writeable
OPC_E_INVALIDHANDLE The passed item handle was invalid.
OPC_E_UNKNOWNITEMID The item is no longer available in the
server address space
E_xxx Vendor specific errors may also be
S_xxx returned. Descriptive information for such
errors can be obtained from
GetErrorString.
Comments
Some servers will be ‘smarter’ at write time and return ‘early’ errors, others may simply queue the
request with minimal checking and return ‘late’ errors in the callback. The client should be prepared to
deal with this.
If the HRESULT is S_OK, then ppError can be ignored (all results in it are guaranteed to be S_OK).
If the HRESULT is any FAILED code then (as noted earlier) the server should return NULL pointers
for all OUT parameters. Note that in this case no Callback will occur.
If ALL errors in ppError are Failure codes then No callback will take place.
Items for which ppError returns any success code (including S_xxx) will also have a result returned in
the OnWriteComplete callback. Note that the error result for an item returned in the callback may
differ from that returned from Write.
104
OPC Data Access Custom Interface Specification 2.05
NOTE: all of the results must be returned by the server in a single callback. Thus if the items in the
group require multiple physical transactions to one or more physical devices then the server must wait
until all of them are complete before invoking the callback.
Client must free the returned ppError array.
105
OPC Data Access Custom Interface Specification 2.05
4.5.6.3 IOPCAsyncIO2::Refresh2
HRESULT Refresh2(
[in] OPCDATASOURCE dwSource,
[in] DWORD dwTransactionID,
[out] DWORD *pdwCancelID
);
Description
Force a callback to IOPCDataCallback::OnDataChange for all active items in the group (whether they
have changed or not). Inactive items are not included in the callback.
Parameters Description
dwSource Data source CACHE or DEVICE. If the DEVICE, then
all active items in the CACHE are refreshed from the
device BEFORE the callback.
dwTransactionID The Client generated transaction ID. This is included in
the ‘completion’ information provided to the
OnDataChange.
pdwCancelID Place to return a Server generated ID to be used in case
the operation needs to be canceled.
Comments
If the HRESULT is any FAILED code then no Callback will occur.
Calling Refresh for an InActive Group will return E_FAIL. Calling refresh for an Active Group,
where all the items in the group are InActive also returns E_FAIL.
The behavior of this function is identical to what happens when Advise is called initially except that
the OnDataChange Callback will include the transaction ID specified here. (The initial OnDataChange
callback will contain a Transaction ID of 0). Thus if it is important to the client to distinguish between
OnDataChange callbacks resulting from changes to values and OnDataChange callbacks resulting
from a Refresh2 request then a non-zero ID should be passed to Refresh2().
106
OPC Data Access Custom Interface Specification 2.05
Functionally it is also similar to what could be achieved by doing a READ of all of the active items in
a group.
NOTE: all of the results must be returned in a single callback. Thus if the items in the group require
multiple physical transactions to one or more physical devices then the server must wait until all of
them are complete before invoking OnDataChange.
The expected behavior is that this Refresh will not affect the timing of normal OnDataChange
callbacks which are based on the UpdateRate. For example, if the update rate is 1 hour and this
method is called after 45 minutes then the server should still do its internal ‘checking’ at the end of the
hour (15 minutes after the Refresh call). Calling this method may affect the contents of that next
callback (15 minutes later) since only items where the value or status changed during that 15 minutes
would be included. Items which had changed during the 45 minutes preceding the Refresh will be sent
(along with all other values) as part of the Refresh Transaction. They would not be sent a second time
at the end of the hour. The value sent in response to the Refresh becomes the ‘last value sent’ to the
client when performing the normal subscription logic.
107
OPC Data Access Custom Interface Specification 2.05
4.5.6.4 IOPCAsyncIO2::Cancel2
HRESULT Cancel2(
[in] DWORD dwCancelID
);
Description
Request that the server cancel an outstanding transaction.
Parameters Description
dwCancelID The Server generated Cancel ID which was associated
with the operation when it was initiated.
Comments
The exact behavior (for example whether an operation that has actually started will be aborted) will be
server specific and will also depend on the timing of the cancel request. Also, depending on the
timing, a Callback for the transaction may or may not occur. This method is intended for use during
shutdown of a task.
In general, if this operation succeeds then a OnCancelComplete callback will occur. If this operation
fails then a read, write or datachange callback may occur (or may already have occurred).
108
OPC Data Access Custom Interface Specification 2.05
4.5.6.5 IOPCAsyncIO2::SetEnable
HRESULT SetEnable(
[in] BOOL bEnable
);
Description
Controls the operation of OnDataChange. Basically setting Enable to FALSE will disable any
OnDataChange callbacks with a transaction ID of 0 (those which are not the result of a Refresh).
Parameters Description
bEnable TRUE enables OnDataChange callbacks, FALSE
disables OnDataChange callbacks.
Comments
The initial value of this variable when the group is created is TRUE and thus OnDataChange callbacks
are enabled by default.
The purpose of this function is to allow a Connection to be established to an active group without
necessarily enabling the OnDataChange notifications. An example might be a client doing an
occasional Refresh from cache.
Even if a client does not intend to use the OnDataChange, it should still be prepared to deal with one or
more OnDataChange callbacks which might occur before the client has time to disable them (i.e. at
least free the memory associated with the 'out' parameters).
If the client really needs to prevent these initial unwanted callbacks then the following procedure can
be used. Client creates and populates the group. Client sets the group Active state to FALSE. Client
creates connection to group. Client uses this function to disable OnDataChange. sets the group Active
state back to TRUE.
This does NOT affect operation of Refresh2(). I.e. calling Refresh2 will still result in an
OnDataChange callback (with a non-zero transaction ID). Note that this allows Refresh to be used as
essentially an Async read from Cache.
109
OPC Data Access Custom Interface Specification 2.05
4.5.6.6 IOPCAsyncIO2::GetEnable
HRESULT GetEnable(
[out] BOOL *pbEnable
);
Description
Retrieves the last Callback Enable value set with SetEnable.
Parameters Description
pbEnable Where to save the returned result.
Comments
See IOPCAsyncIO2::SetEnable() for additional information.
110
OPC Data Access Custom Interface Specification 2.05
111
OPC Data Access Custom Interface Specification 2.05
4.5.7.1 IConnectionPointContainer::EnumConnectionPoints
HRESULT EnumConnectionPoints(
IEnumConnectionPoints **ppEnum
);
Description
Create an enumerator for the Connection Points supported between the OPC Group and the Client.
Parameters Description
ppEnum Where to save the pointer to the connection point
enumerator. See the Microsoft documentation for a
discussion of IEnumConnectionPoints.
112
OPC Data Access Custom Interface Specification 2.05
Description
Find a particular connection point between the OPC Group and the Client.
Parameters Description
ppCP Where to store the Connection Point. See the Microsoft
documentation for a discussion of IConnectionPoint.
riid The IID of the Connection Point. (e.g.
IID_IOPCDataCallBack)
113
OPC Data Access Custom Interface Specification 2.05
4.5.8 IEnumOPCItemAttributes
IEnumOPCItemAttributes allows a client to find out the contents (items) of a group and the attributes
of those items.
NOTE: most of the returned information was either supplied by or returned to the client at the time it
called AddItem.
The optional EU information (see the OPCITEMATTRIBUTES discussion) may be very useful to
some clients. This interface is also useful for debugging or for enumerating the contents of a public
group.
This interface is returned only by IOPCItemMgt::CreateEnumerator. It is not available through query
interface.
Since enumeration is a standard interface this is described only briefly.
See the OLE Programmer’s reference for Enumerators for a list and discussion of error codes.
4.5.8.1 IEnumOPCItemAttributes::Next
HRESULT Next(
[in] ULONG celt,
[out, size_is(,*pceltFetched)] OPCITEMATTRIBUTES ** ppItemArray,
[out] ULONG * pceltFetched
);
Description
Fetch the next ‘celt’ items from the group.
Parameters Description
celt number of items to be fetched.
ppItemArray Array of OPCITEMATTRIBUTES. Returned by the
server.
pceltFetched Number of items actually returned.
Comments
The client must free the returned OPCITEMATTRIBUTES structure including the contained items;
szItemID, szAccessPath, pBlob, vEUInfo.
114
OPC Data Access Custom Interface Specification 2.05
4.5.8.2 IEnumOPCItemAttributes::Skip
HRESULT Skip(
[in] ULONG celt
);
Description
Skip over the next ‘celt’ attributes.
Parameters Description
celt Number of items to skip
Comments
Skip is probably not useful in the context of OPC.
115
OPC Data Access Custom Interface Specification 2.05
4.5.8.3 IEnumOPCItemAttributes::Reset
HRESULT Reset(
void
);
Description
Reset the enumerator back to the first item.
Parameters Description
void
Comments
116
OPC Data Access Custom Interface Specification 2.05
4.5.8.4 IEnumOPCItemAttributes::Clone
HRESULT Clone(
[out] IEnumOPCItemAttributes** ppEnumItemAttributes
);
Description
Create a 2nd copy of the enumerator. The new enumerator will initially be in the same ‘state’ as the
current enumerator.
Parameters Description
ppEnumItemAttributes Place to return the new interface
Comments
The client must release the returned interface pointer when it is done with it.
117
OPC Data Access Custom Interface Specification 2.05
118
OPC Data Access Custom Interface Specification 2.05
Mainline Code
START CRITICAL SECTION
RECORD ALL NEEDED INFO ABOUT TRANSACTION EXCEPT TID.
CLEAR ‘TID COMPLETED’
SET A SPECIAL FLAG: ‘TID PENDING’
IOPCAsyncIO::Read or Write or Refresh
CHECK ‘TID COMPLETED’
IF SET AND EQUAL TO RETURNED TID THEN TRANSACTION IS COMPLETE
ELSE SAVE TRANSACTION ID IN LIST OF PENDING TRANSACTIONS
CLEAR ‘TID PENDING’
END CRITICAL SECTION
…
OnDataChange Code
START CRITICAL SECTION
READ DATA STREAM AND LOCATE TRANSACTION ID
LOCATE TRANSACTION ID IN LIST OF PENDING TRANSACTIONS
IF NOT FOUND, CHECK ‘TID PENDING’
IF ‘TID PENDING’ SET THEN RECORD THIS TID IN ‘TID COMPLETED’
END CRITICAL SECTION
…
119
OPC Data Access Custom Interface Specification 2.05
4.5.9.1 IOPCAsyncIO::Read
HRESULT Read(
[in] DWORD dwConnection,
[in] OPCDATASOURCE dwSource,
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[out] DWORD *pTransactionID,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
Description
Read one or more items in a group. The results are returned via the IAdvise Sink connection
established through the IDataObject.
For CACHE reads the data is only valid if both the group and the item are active.
DEVICE reads are not affected by the ACTIVE state of the group or item.
Parameters Description
dwConnection The OLE Connection number returned from
IDataObject::DAdvise. This is passed to help the server
determine which advise sink to call when the request
completes.
dwSource The data source; OPC_DS_CACHE or
OPC_DS_DEVICE
dwCount Number of items to be read.
phServer Array of server item handles of the items to be read
pTransactionID Place to return a Server generated transaction ID. This
is included in the ‘completion’ information provided to
the IAdvise.
ppErrors Array of errors for each item - returned by the server.
Indicates only if the corresponding server handle was
valid. Any other errors (communications time-out,
access rights, etc.) will be returned in the callback.
Note that at this time the only item level status
information available in the callback is the QUALITY
field.
120
OPC Data Access Custom Interface Specification 2.05
121
OPC Data Access Custom Interface Specification 2.05
4.5.9.2 IOPCAsyncIO::Write
HRESULT Write(
[in] DWORD dwConnection,
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[in, size_is(dwCount)] VARIANT * pItemValues,
[out] DWORD *pTransactionID,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
Description
Write one or more items in a group. The results are returned via the IAdviseSink connection
established through the IDataObject.
Parameters Description
dwConnection The OLE Connection number returned from
IDataObject::DAdvise. This is passed to help the server
determine which advise sink to call when the request
completes.
dwCount Number of items to be written
phServer List of server items handles for the items to be written
pItemValues List of values to be written. The value data types do not
match the requested or canonical item datatype but
must be ‘convertible’ to the canonical type.
pTransactionID Place to return a Server generated transaction ID. This
is included in the ‘completion’ information provided to
the IAdvise.
ppErrors Array of errors for each item - returned by the server.
Indicates only if the corresponding server handle was
valid. Any other errors (communications time-out,
access rights, etc.) will be returned in the callback.
122
OPC Data Access Custom Interface Specification 2.05
123
OPC Data Access Custom Interface Specification 2.05
4.5.9.3 IOPCAsyncIO::Refresh
HRESULT Refresh(
[in] DWORD dwConnection,
[in] OPCDATASOURCE dwSource,
[out] DWORD *pTransactionID
);
Description
Force a callback for all active items in the group (whether they have changed or not). Inactive items
are not included in the callback.
Parameters Description
dwConnection The OLE Connection number returned from
IDataObject::DAdvise. This is passed to help the server
determine which advise sync to call when the request
completes.
dwSource Data source CACHE or DEVICE
pTransactionID Place to return a Server generated transaction ID. This
is included in the ‘completion’ information provided to
the IAdvise.
124
OPC Data Access Custom Interface Specification 2.05
The expected behavior is that this Refresh will not affect the timing of normal OnDataChange
callbacks which are based on the UpdateRate. For example, if the update rate is 1 hour and this
method is called after 45 minutes then the server should still do its internal ‘checking’ at the end of the
hour (15 minutes after the Refresh call). Calling this method may affect the contents of that next
callback (15 minutes later) since only items where the value or status changed during that 15 minutes
would be included. Items which had changed during the 45 minutes preceding the Refresh will be sent
(along with all other values) as part of the Refresh Transaction. They would not be sent a second time
at the end of the hour. The value sent in response to the Refresh becomes the ‘last value sent’ to the
client when performing the normal subscription logic.
See the notes under ‘Read’ regarding the transaction ID.
125
OPC Data Access Custom Interface Specification 2.05
4.5.9.4 IOPCAsyncIO::Cancel
HRESULT Cancel(
[in] DWORD dwTransactionID
);
Description
Request that the server cancel an outstanding transaction.
Parameters Description
dwTransactionID The transaction ID which was associated with the
operation to be canceled.
Comments
The exact behavior (for example whether an operation that has actually started will be aborted) will be
server specific and will also depend on the timing of the cancel request. Also, depending on the
timing, a Callback for the transaction may or may not occur. This method is intended to be used
during shutdown of a task.
In general, if this operation succeeds then no callback will occur. If this operation fails then a callback
may occur (or may already have occured).
126
OPC Data Access Custom Interface Specification 2.05
The server vendor may chose to implement additional methods on the IDataObject. It is the intent of
this design that data items be transferred to applications primarily via the Advise connection or via the
Synchronous or Asynchronous Read methods.
The data returned to the Advise connection is returned via a IAdviseSink which receives data in a
Global Memory Section also referred to here as the ‘stream’. These streams can be in several formats.
They are used to provide exception data as well as completion information for Async Reads and
Writes. The stream formats are
“OPCSTMFORMATDATA”
“OPCSTMFORMATDATATIME”
“OPCSTMFORMATWRITECOMPLETE”
Use the function
RegisterClipboardFormat()
to obtain the format value (cfFormat) to be used for data transfers between OPC client applications and
OPC server applications.
The registered callback function (OnDataChange in the client’s IAdviseSink) may be specified by the
client application so that it spans multiple groups. Information about the group (the Group’s
ClientHandle) must be provided to the client application as part of the stream so that the client can
successfully interpret the items that are contained in the data stream. Each data stream will only
contain the items defined within the specified group.
Because of the nature of the asynchronous calls, OLE requires that no synchronous calls are made
from a method that has been called asynchronously (as all of the IAdviseSink methods are) which
would cause the asynchronous function to be blocked. It is very important that the methods that are
called asynchronously (the IAdviseSink methods) have limited processing, and return quickly.
Lengthy processing should be done outside of the context of the asynchronous method that has been
invoked.
It is the client application’s responsibility to keep up with the data changes that the server (configured
by the client app) sends. The client should assume that the server may send data at the update rate
specified in the group, and that for each group that identical throughput may occur. Various Windows
and OLE related internal errors can result if the server sends data faster than the client can receive it.
127
OPC Data Access Custom Interface Specification 2.05
The performance of the OPC servers and OPC clients is highly tied to the developers implementation
of these critical interfaces.
The server should be implemented to optimize the acquisition of the data items for multiple clients
wherever possible. This means that it is best for the server to read data from devices at the fastest rate
possible: (a) to support the needs of multiple clients configured for the same item or (b), if a single
client has configured the same item in different groups at different update rates.
Refer to the OLE programming manual for a tutorial and guide to implementing
the required functionality.
128
OPC Data Access Custom Interface Specification 2.05
4.5.10.1 IDataObject::DAdvise
HRESULT DAdvise(
FORMATETC *pFmt,
DWORD adv,
LPADVISESINK pSnk,
DWORD * pConnection
);
Description
Create a connection for a particular ‘stream’ format between the OPC Group and the Client.
Parameters Description
pFmt The format in which the client is interested. This will
always be one of the three supported OPC formats as
described below.
adv Data Advise Flags specifier. Not used by OPC.
pSnk Pointer to the Client’s IAdviseSink
pConnection OLE Connection key for use with IOPCAsyncIO and
UnAdvise
Since groups are specific to a client, it is sufficient for OPC Compliance that a group support only a
single ‘connection point’ for each stream format. A second attempt by the same client to subscribe to
the same stream format on the same group may return CONNECT_E_ADVISELIMIT.
The Advise Flags Parameter (adv) is not used by OPC. Servers should ignore this parameter and
should always send a copy of all data items when a connection is made. Note that this is equivalent to
the behavior associated with ADVF_PRIMEFIRST.
It is expected that a client will assign unique values to the group and item client handles if they intend
to use any of the asynchronous functions of the OPC interfaces, including IOPCAsyncIO, and
IDataObject/IAdviseSink interfaces, since this is the only key to the information that the server
provides back to the client with the OnDataChange stream.
129
OPC Data Access Custom Interface Specification 2.05
The ‘formats’ really represent different types of events rather than different formats for the same data.
The FORMATETC must be filled in as follows;
fe.cfFormat = OPCSTMFORMATDATA or
OPCSTMFORMATDATATIME or
OPCSTMFORMATWRITECOMPLETE.
(See RegisterClipboardFormat())
fe.dwAspect = DVASPECT_CONTENT;
fe.ptd = NULL;
fe.tymed = TYMED_HGLOBAL;
fe.lindex = -1;
The storage medium will always be TYMED_HGLOBAL (for computability with DCOM).
130
OPC Data Access Custom Interface Specification 2.05
4.5.10.2 IDataObject::DUnadvise
HRESULT DUnadvise(
DWORD Connection
);
Description
Terminate a connection between the OPC Group and the Client.
Parameters Description
Connection The connection to be terminated
131
OPC Data Access Custom Interface Specification 2.05
4.6.1 IOPCDataCallback
In order to use connection points, the client must create an object that supports both the IUnknown and
IOPCDataCallback Interface. The client would pass a pointer to the IUnknown interface (NOT the
IOPCDataCallback) to the Advise method of the proper IConnectionPoint in the server (as obtained
from IConnectionPointContainer:: FindConnectionPoint or EnumConnectionPoints). The Server will
call QueryInterface on the client object to obtain the IOPCDataCallback interface. Note that the
transaction must be performed in this way in order for the interface marshalling to work properly for
Local or Remote servers.
All of the methods below must be implemented by the client.
This Interface will be called as a result of changes in the data of the group (OnDataChange) and also as
a result of calls to the IOPCAsyncIO2 interface.
Note: although it is not recommended, the client could change the active status of the group or items
while an Async call is outstanding. The server should be able to deal with this in a reasonable fashion
(i.e. not crash) although the exact behavior is undefined.
Note: memory management follows the standard COM rules. That is, the server allocates 'in'
parameters and frees them after the client returns. The client only frees 'out' parameters. In the case of
these callbacks there are no 'out' parameters so all memory is owned by the server.
132
OPC Data Access Custom Interface Specification 2.05
4.6.1.1 IOPCDataCallback::OnDataChange
HRESULT OnDataChange(
[in] DWORD dwTransid,
[in] OPCHANDLE hGroup,
[in] HRESULT hrMasterquality,
[in] HRESULT hrMastererror,
[in] DWORD dwCount,
[in, sizeis(dwCount)] OPCHANDLE * phClientItems,
[in, sizeis(dwCount)] VARIANT * pvValues,
[in, sizeis(dwCount)] WORD * pwQualities,
[in, sizeis(dwCount)] FILETIME * pftTimeStamps,
[in, sizeis(dwCount)] HRESULT *pErrors
);
Description
This method is provided by the client to handle notifications from the OPC Group for exception based
data changes and Refreshes.
Parameters Description
dwTransid 0 if the call is the result of an ordinary subscription. If
the call is the result of a call to Refresh2 then this is the
value passed to Refresh2.
hGroup The Client handle of the group
hrMasterquality S_OK if OPC_QUALITY_MASK for all ‘qualities’
are OPC_QUALITY_GOOD, S_FALSE otherwise.
hrMastererror S_OK if all ‘errors are S_OK, S_FALSE otherwise.
dwCount The number of items in the client handle list
phClientItems The list of client handles for the items which have
changed.
pvValues A List of VARIANTS containing the values (in
RequestedDataType) for the items which have
changed.
pwQualities A List of Quality values for the items
pftTimeStamps A list of TimeStamps for the items
pErrors A list of HRESULTS for the items. If the quality of a
data item has changed to UNCERTAIN or BAD., this
field allows the server to return additional server
specific errors which provide more useful information
to the user. See below.
133
OPC Data Access Custom Interface Specification 2.05
134
OPC Data Access Custom Interface Specification 2.05
4.6.1.2 IOPCDataCallback::OnReadComplete
HRESULT OnReadComplete(
[in] DWORD dwTransid,
[in] OPCHANDLE hGroup,
[in] HRESULT hrMasterquality,
[in] HRESULT hrMastererror,
[in] DWORD dwCount,
[in, sizeis(dwCount)] OPCHANDLE * phClientItems,
[in, sizeis(dwCount)] VARIANT * pvValues,
[in, sizeis(dwCount)] WORD * pwQualities,
[in, sizeis(dwCount)] FILETIME * pftTimeStamps,
[in, sizeis(dwCount)] HRESULT *pErrors
);
Description
This method is provided by the client to handle notifications from the OPC Group on completion of
Async Reads.
Parameters Description
dwTransid The TransactionID returned to the client when the
Read was initiated.
hGroup The Client handle of the group
hrMasterquality S_OK if OPC_QUALITY_MASK for all ‘qualities’
are OPC_QUALITY_GOOD, S_FALSE otherwise.
hrMastererror S_OK if all ‘errors are S_OK, S_FALSE otherwise.
dwCount The number of items in the client handle, values,
qualities, times and errors lists. This may be less than
the number of items passed to Read. Items for whic
errors were detected and returned from Read are not
included in the callback.
phClientItems The list of client handles for the items which were read.
This is NOT guarenteed to be in any particular order
although it will match the values, qualities, times and
errors array.
pvValues A List of VARIANTS containing the values (in
RequestedDataType) for the items.
pwQualities A List of Quality values for the items
pftTimeStamps A list of TimeStamps for the items
pErrors A list of HRESULTS for the items. If the system is
unable to return data for an item, this field allows the
server to return additional server specific errors which
provide more useful information to the user.
135
OPC Data Access Custom Interface Specification 2.05
136
OPC Data Access Custom Interface Specification 2.05
4.6.1.3 IOPCDataCallback::OnWriteComplete
HRESULT OnWriteComplete(
[in] DWORD dwTransid,
[in] OPCHANDLE hGroup,
[in] HRESULT hrMasterError,
[in] DWORD dwCount,
[in, sizeis(dwCount)] OPCHANDLE * phClientItems,
[in, sizeis(dwCount)] HRESULT * pError
);
Description
This method is provided by the client to handle notifications from the OPC Group on completion of
AsyncIO2 Writes.
Parameters Description
dwTransid The TransactionID returned to the client when the
Write was initiated.
hGroup The Client handle of the group
hrMasterError S_OK if all ‘errors are S_OK, S_FALSE otherwise.
dwCount The number of items in the client handle and errors list.
This may be less than the number of items passed to
Write. . Items for which errors were detected and
returned from Write are not included in the callback.
phClientItems The list of client handles for the items which were
written. This is NOT guarenteed to be in any particular
order although it must match the ‘errors’ array.
pErrors A List of HRESULTs for the items. Note that Servers
are allowed to define vendor specific error codes here.
These codes can be passed to GetErrorString().
137
OPC Data Access Custom Interface Specification 2.05
138
OPC Data Access Custom Interface Specification 2.05
4.6.1.4 IOPCDataCallback::OnCancelComplete
HRESULT OnCancelComplete(
[in] DWORD dwTransid,
[in] OPCHANDLE hGroup
);
Description
This method is provided by the client to handle notifications from the OPC Group on completion of
Async Cancel.
Parameters Description
dwTransid The TransactionID provided by the client when the
Read, Write or Refresh was initiated.
hGroup The Client handle of the group
139
OPC Data Access Custom Interface Specification 2.05
4.6.2 IOPCShutdown
In order to use this connection point, the client must create an object that supports both the IUnknown
and IOPCShutdown Interface. The client would pass a pointer to the IUnknown interface (NOT the
IOPCShutdown) to the Advise method of the proper IConnectionPoint in the server (as obtained from
IConnectionPointContainer:: FindConnectionPoint or EnumConnectionPoints). The Server will call
QueryInterface on the client object to obtain the IOPCShutdown interface. Note that the transaction
must be performed in this way in order for the interface marshalling to work properly for Local or
Remote servers.
The ShutdownRequest method on this Interface will be called when the server needs to shutdown. The
client should release all connections and interfaces for this server.
A client which is connected to multiple OPCServers (for example Data access and/or other servers
such as Alarms and events servers from one or more vendors) should maintain separate shutdown
callbacks for each object since any server can shut down independently of the others.
4.6.2.1 IOPCShutdown::ShutdownRequest
HRESULT ShutdownRequest (
[in] LPWSTR szReason
);
Description
This method is provided by the client so that the server can request that the client disconnect from the
server. The client should UnAdvise all connections, Remove all groups and release all interfaces.
Parameters Description
szReason An optional text string provided by the server
indicating the reason for the shutdown. The server may
pass a pointer to a NUL string if no reason is provided.
140
OPC Data Access Custom Interface Specification 2.05
141
OPC Data Access Custom Interface Specification 2.05
4.6.3.1 IAdviseSink::OnDataChange
void OnDataChange (
[in] FORMATETC * pFE,
[in] STGMEDIUM * pSTM
);
Description
This method is provided by the client to handle notifications from the OPC Group for exception based
data changes, Async reads and Refreshes and Async Write Complete.
Parameters Description
pFE the format of the data being receive by the sink
pSTM the storage medium containing the data.
Comments
This section will discuss the reasons why the client may receive callbacks, the contents of
FORMATETC and the contents of the STGMEDIUM.
Note that the caller (the server) owns and will free the storage since the parameters are all 'in's.
The client should NOT free the STGMEDIUM. Also note that the storage is valid only for the
duration of the OnDataChange call.
Callbacks can occur for several reasons;
• One or more ‘data change’ events with timestamp (format will be
OPCSTMFORMATDATATIME and transaction ID will be 0). This format is also used in
response to a Refresh and ASYNC READ with a non-zero transaction ID.
• One or more ‘data change’ events without timestamp (format will be OPCSTMFORMATDATA
and transaction ID will be 0). This format is also used in response to a Refresh and ASYNC
READ with a non-zero transaction ID.
• Completion of an ASYNC WRITE. (format will be OPCSTMFORMATWRITECOMPLETE and
transaction ID will be non-0)
The FORMATETC will be filled in as follows;
fe.cfFormat = OPCSTMFORMATDATA or
OPCSTMFORMATDATATIME or
OPCSTMFORMATWRITECOMPLETE.
fe.ptd = NULL;
fe.dwAspect = DVASPECT_CONTENT;
fe.lindex = -1;
fe.tymed = TYMED_HGLOBAL;
142
OPC Data Access Custom Interface Specification 2.05
The storage medium will always be TYMED_HGLOBAL (for computability with DCOM). The global
memory handle can be found in pSTM.hGlobal. GlobalLock() can be used to convert this to a pointer.
The data stored in the global memory by the server will have one of several structures depending on
the Format (which depends on the event that generated the data). Although the data resides in this
structure in global memory, we refer to it as a ‘data stream’.
These three formats are summarized below and are described in detail later in the document.
Clients and servers must ‘Register’ these stream formats by calling the windows function
RegisterClipboardFormat();
143
OPC Data Access Custom Interface Specification 2.05
4.6.4.1 OPCGROUPHEADER
typedef struct {
DWORD dwSize;
DWORD dwItemCount;
OPCHANDLE hClientGroup;
DWORD dwTransactionID;
HRESULT hrStatus;
} OPCGROUPHEADER;
Member Description
dwSize The Total size of the data stream (the header, all item
headers and all data)
dwItemCount The number of Itemheaders which follow. This will vary
depending on the number of values being reported.
hClientGroup The client provided handle for the group for which data is
being reported. This allows a single OnDataChange handler
to identify which of many possible groups are reporting
data.
dwTransactionID For normal subscriptions this is 0
For Async operations Refresh or Read this is the transaction
ID returned by the method.
hrStatus The status of the asynchronous request (including
OnDataChange). This enables error codes (e.g.
E_OUTOFMEMORY) to be returned in the case of an
asynchronous request failing in the server. A status of
S_FALSE should be returned when the read operation was
successful, but one or more items has a quality status of
BAD or UNCERTAIN.
Comment
If the hrStatus is any FAILED code then the server must return dwItemCount as 0.
There are no ITEM level HRESULT error codes returned at this time. The only item level status
information available to the callback function is the Quality Field.
144
OPC Data Access Custom Interface Specification 2.05
4.6.4.2 OPCITEMHEADER1
typedef struct {
OPCHANDLE hClient;
DWORD dwValueOffset;
WORD wQuality;
WORD wReserved;
FILETIME ftTimeStampItem;
} OPCITEMHEADER1;
An array of these structures appears in the stream following the GROUPHEADER for
OPCSTMFORMATDATATIME. The serialized data (in the form of Variants) appears after this array.
Member Description
hClient The client provided handle associated with this item
dwValueOffset The offset in the data stream (the global memory section) of
the serialized variant which contains the data.
wQuality The Quality bits for the data.
ftTimeStampItem The TimeStamp for the data.
4.6.4.3 OPCITEMHEADER2
typedef struct {
OPCHANDLE hClient;
DWORD dwValueOffset;
WORD wQuality;
WORD wReserved;
} OPCITEMHEADER2;
An array of these structures appears in the stream following the GROUPHEADER for
OPCSTMFORMATDATA. The serialized data (in the form of Variants) appears after this array.
Member Description
hClient The client provided handle associated with this item
dwValueOffset The offset in the data stream (the global memory section) of
the serialized variant which contains the data.
wQuality The Quality bits for the data.
145
OPC Data Access Custom Interface Specification 2.05
4.6.4.4 OPCGROUPHEADERWRITE
typedef struct {
DWORD dwItemCount;
OPCHANDLE hClientGroup;
DWORD dwTransactionID;
HRESULT hrStatus;
} OPCGROUPHEADERWRITE;
This structure can appear at the head of the data stream. It is followed by an array of
OPCITEMHEADERWRITEs.
Member Description
dwItemCount The number of Itemheaders which follow. This will vary
depending on the number of values being reported.
hClientGroup The client provided handle for the group for which data is
being reported. This allows a single OnDataChange handler
to identify which of many possible groups are reporting
data.
dwTransactionID This is the transaction ID returned by the
IOPCAsyncIO::Write method.
hrStatus The status of the asynchronous write request. This enables
error codes (e.g. E_OUTOFMEMORY) to be returned in
the case of an asynchronous request failing in the server.
Comment
If the hrStatus is any FAILED code then the server must return dwItemCount as 0.
4.6.4.5 OPCITEMHEADERWRITE
typedef struct {
OPCHANDLE hClient;
HRESULT dwError;
} OPCITEMHEADERWRITE;
Member Description
hClient The client provided handle associated with this item
dwError The HRESULTs for each of the items that was written.
Comment
The item level HRESULTs for Write are the same as those returned for Sync Write.
146
OPC Data Access Custom Interface Specification 2.05
147
OPC Data Access Custom Interface Specification 2.05
5 Installation Issues
It is assumed that the server vendor will provide a SETUP.EXE to install the needed components for
their server. This will not be discussed further. Other than the actual components, the main issue
affecting OLE software is management of the Windows Registry and Component Catagories. The
issues here are (a) what entries need to be made and (b) how they can be made.
Again, certain common installation and registry topics including self registration, automatic proxy/stub
registration and registry reference counting are discussed in the OPC Overview Document
It is expected that a server will first create any category it uses and then will register for that category.
Unregistering a server should cause it to be removed from that category. See the ICatRegister
documentation for additional information.
1. This entry simply establishes your ProgID as a subkey of the ROOT under which other subkeys
can be entered. The description (the ‘value’ of this key) may be presented to the user as the name
of an available OPC server (See example below). It should match the description in line 6.
2. The CLSID line enables the CLSIDFromProgID function to work. I.e. allows the system to open
a key given the ProgID and obtain the CLSID as the value of that key. See the example below.
148
OPC Data Access Custom Interface Specification 2.05
3. The OPC line creates a ‘flag’ subkey that has no value. This was used for Data Access 1.0 to allow
the client to browse for the available OPC servers. As of verson 2.0, the prefered approach is for
clients and servers to use Component Catagories.
4. The Vendor line is optional. It is simply a means of identifying the vendor who supplied the
particular OPC server.
5. This line simply establishes your CLSID as a subkey off of ROOT\CLSID under which the other
subkeys can be entered. The description (the ‘value’ of this key) should be a User Friendly
description of the server. It should match Item 1 above.
6. The ProgID line enables the ProgIDFromCLSID function to work. I.e. allows the system to open
a key given the CLSID and obtain the ProgID as the value of that key. (This function is not
commonly used).
7. The InprocServer32 line or LocalServer32 line or InprocHandler32 line allows CoCreateInstance
to locate the DLL or EXE given the CLSID. The vendor should define at least one of these.
In general, self registration as described in the Microsoft documentation is recommended for both DLL
and EXE servers to simplify installation.
149
OPC Data Access Custom Interface Specification 2.05
Examples:
A server which supports access to an existing DCS might support a simple syntax such as
“TIC101.PV”
A server that supports low level access to a PLC might support a syntax such as
“COM1.STATION:42.REG:40001;0,4095,-100.0,+1234.0”
150
OPC Data Access Custom Interface Specification 2.05
6.2 AccessPath
The AccessPath is intended as a way for the client to provide to the server a suggested data path (e.g. a
particular modem or network interface). It indicates HOW to get the data.
The ITEM ID provides all of the information needed to locate and process a data item. The Access
Path is an optional piece of information that can be provided by the client. Its use is highly server
specific but it is intended to allow the client to provide a ‘recommendation’ to the server regarding
how to get to the data. As an analogy, if the ItemID represented a phone number, the access path might
represent a request to route the call via satellite (or transatlantic cable or microwave link). The call
will go through regardless of whether you specify an access path and also whether or not the server is
able to use that suggested path.
For example, suppose you wanted to access a value in an RTU and had a high speed modem on COM1
and a low speed modem on COM2. You might specify COM1 as the preferred access path. Either one
will work, but you would prefer to use COM1 if it is available for better performance.
In any case, the use of access path by both the server and the client is optional. Servers need not
provide the function and clients need not use it even if it is provided.
Servers which do not support access paths will completely ignore any passed access path (and will not
treat this as an error by the client). Also, when queried, such servers will always return a null access
path for all items (i.e. a NUL string).
151
OPC Data Access Custom Interface Specification 2.05
6.3 Blob
We will discuss why the Blob exists and how it behaves.
The Blob is basically a scratch area for the server to associate with items in order to speed up access to
or processing of those items. The exact way in which it is used is server specific.
The idea is that clients refer to items via ASCII strings while internally, to speed up access, the server
will probably need to resolve this string into some internal server specific address; a network address, a
pointer into a table, a set of indices or files or register numbers, etc. This address resolution could take
considerable time and the resulting internal address could take an arbitrary amount of space. This Blob
allows the server to return this internal address and allows the client to save it and to provide the Blob
back to the server for future references to this item. The server could use the ‘Blob’ as a ‘hint’ to help
find the item more quickly the next time; “The Blob says that last time I looked for this tag I found it
‘here’ - so lets see if its still in that location”. However, in all cases, the ITEM ID is still the ‘key’ to
the data. Regardless of the contents of the Blob, the server needs to insure that it is in fact referencing
the item referred to by the ITEM ID.
The behavior of the Blob is as follows.
Its use by both client and server is optional. Servers which can perform ‘AddItems’ quickly based just
on the item definition should generally not return a Blob. In cases where servers do return a Blob,
clients are free to ignore these Blobs (although this will probably affect the performance of that
server).
The Blob is passed to AddItems and ValidateItems and is also returned by the server any time an
AddItems or ValidateItems or EnumItemAttributes is done. The returned Blob may differ in size and
content from the one passed.
Note that the server can update the Blob for an item at any time entirely at the server’s discretion
(including, for example, whenever the client changes an attribute of an Item).
Proper behavior of a client that wishes to support the Blob is to Enumerate the item attributes to get a
fresh copy of the Blobs for each item prior to deleting an item or group and to save that updated copy
along with the other application data related to the items.
Comment:
The difference between the server handle and the Blob is that the server handle is fixed in size
(DWORD), should not be stored between sessions by the client and that it’s implementation is required
since it is the only way to identify items after they have been added. The Blob is variable in length, is
optional and may be stored by the client between sessions.
152
OPC Data Access Custom Interface Specification 2.05
NOTE
Real values in the variant (VT_R4, VT_R8) will contain IEEE floating point numbers. Note that the
IEEE standard allows certain non numeric values (called NANs) to be stored in this format. While use
of such values is rare, they are specifically allowed. If such a value is returned (in the
OPCITEMSTATE or in the DATA STREAM to the IAdviseSink) it is required that the QUALITY
flag be set to OPC_QUALITY_BAD.
153
OPC Data Access Custom Interface Specification 2.05
6.6 Constants
6.6.1 OPCHANDLE
OPCHANDLEs are used in conjunction with both groups and items within groups. The purpose of
handles in OPC is to allow faster access to various objects by both the client and the server.
The exact internal implementation of the server handles is entirely vendor specific. The client should
never make any assumptions about the server handles and the server should never make any
assumptions about the client handles.
154
OPC Data Access Custom Interface Specification 2.05
6.7.1 OPCITEMSTATE
This structure is used by IOPCSyncIO::Read
typedef struct {
OPCHANDLE hClient;
FILETIME ftTimeStamp;
WORD wQuality;
WORD wReserved;
VARIANT vDataValue;
} OPCITEMSTATE;
Member Description
hClient the client provided handle for this item
ftTimeStamp UTC TimeStamp for this item's value. If the device cannot
provide a timestamp then the server should provide one.
wQuality The quality of this item.
vDataValue The value itself as a variant.
Comments
The Client should call VariantClear() to free any memory associated with the Variant.
Real values in the variant (VT_R4, VT_R8) will contain IEEE floating point numbers. Note that the
IEEE standard allows certain non numeric values (called NANs) to be stored in this format. While use
of such values is rare, they are specifically allowed. If such a value is returned it is required that the
QUALITY flag be set to OPC_QUALITY_BAD.
155
OPC Data Access Custom Interface Specification 2.05
6.7.2 OPCITEMDEF
typedef struct {
[string] LPWSTR szAccessPath;
[string] LPWSTR szItemID;
BOOL bActive ;
OPCHANDLE hClient;
DWORD dwBlobSize;
[size_is(dwBlobSize)] BYTE * pBlob;
VARTYPE vtRequestedDataType;
WORD wReserved;
} OPCITEMDEF;
This structure is used by IOPCItemMgt::AddItems and ValidateItems. The ‘used by’ column below
indicates which of these two functions use each member.
156
OPC Data Access Custom Interface Specification 2.05
6.7.3 OPCITEMRESULT
typedef struct {
OPCHANDLE hServer;
VARTYPE vtCanonicalDataType;
WORD wReserved;
DWORD dwAccessRights;
DWORD dwBlobSize;
[size_is(dwBlobSize)] BYTE * pBlob;
} OPCITEMRESULT;
Comments
For AddItems pBlob will always be returned by servers which support this feature. For ValidateItems
it will only be returned if the dwBlobUpdate parameter to ValidateItems is TRUE.
The client software must free the memory for the Blob before freeing the OPCITEMRESULT
structure.
157
OPC Data Access Custom Interface Specification 2.05
6.7.4 OPCITEMATTRIBUTES
typedef struct {
[string] LPWSTR szAccessPath;
[string] LPWSTR szItemID;
BOOL bActive;
OPCHANDLE hClient;
OPCHANDLE hServer;
DWORD dwAccessRights;
DWORD dwBlobSize;
[size_is(dwBlobSize)] BYTE * pBlob;
VARTYPE vtRequestedDataType;
VARTYPE vtCanonicalDataType;
OPCEUTYPE dwEUType;
VARIANT vEUInfo;
} OPCITEMATTRIBUTES;
Member Description
szAccessPath The access path specified by the client. A pointer to a NUL
string is returned if the server does not support access paths.
szItemID The unique identifier for this item.
bActive FALSE if the item is not currently active, TRUE if the item
is currently active
hClient The handle the client has associated with this item.
hServer The handle the server uses to reference this item.
dwAccessRights Indicates if this item is read only, write only or read/write.
This is NOT related to security but rather to the nature of
the underlying hardware. See the Access Rights section
below.
dwBlobSize The size of the pBlob for this item. Note that this size may
be 0 for servers that do not support or require this feature.
pBlob Pointer to the Blob.
vtRequestedDataType The data type in which the item's value will be returned.
Note that if the requested data type was rejected then this
field will return the canonical data type.
vtCanonicalDataType The data type in which the item's value is maintained
within the server.
dwEUType Indicate the type of Engineering Units (EU) information (if
any) contained in vEUInfo.
0 - No EU information available (vEUInfo will be
VT_EMPTY)
1 - Analog - vEUInfo will contain a SAFEARRAY of
exactly two doubles (VT_ARRAY | VT_R8) corresponding
to the LOW and HI EU range.
2 - Enumerated - vEUInfo will contain a SAFEARRAY of
strings (VT_ARRAY | VT_BSTR) which contains a list of
strings (Example: “OPEN”, “CLOSE”, “IN TRANSIT”,
etc.) corresponding to sequential numeric values (0, 1, 2,
etc.)
vEUInfo The VARIANT containing the EU information. See
Comments below.
158
OPC Data Access Custom Interface Specification 2.05
Comment:
The EU support is optional. Servers which do not support this will always return EUType as 0 and
EUInfo as VT_EMPTY. EU information (analog or enumerated) can be returned for any value where
the canonical type is any of: VT_I2, I4, R4, R8, BOOL, UI1 although in practice some combinations
are clearly more likely than others. Where the item contains an array of values (VT_ARRAY) the EU
information will apply to all items in the array (just as the Requested and Canonical Data types apply
to all items in the array).
EU information is provided by the server to the client and is essentially Read Only. OPC Does not
provide the client with any control over the EU settings.
For analog EU the information returned represents the ‘usual’ range of the item value. Sensor or
instrument failure or deactivation can result in a returned item value which is actually outside this
range. Client software must be prepared to deal with this. Similarly a client may attempt to write a
value which is outside this range back to the server. The exact behavior (accept, reject, clamp, etc.) in
this case is server dependent however in general servers must be prepared to handle this.
For enumerated EU the information returned represents ‘string lookup table’ corresponding to
sequential integer values starting with 0. The number of values represented is determined by the size
of the SAFEARRAY. Again, robust clients should be prepared to handle item values outside the range
of the list and robust servers should be prepared to handle writes of illegal values.
Servers may optionally support Localization of the enumeration. In this case the server should use the
current locale ID of the group. See IOPCServer::AddGroup and IOPCGroupStateMgt::GetState and
SetState.
The client is responsible for freeing the VARIANTs in the OPCITEMATTRIBUTES structure
including all elements of any SAFEARRAYs.
Client writers may wish to create and use a common function such as
FreeOPCITEMATTRIBUTES(ptr) in order to minimize the chance of memory leaks.
159
OPC Data Access Custom Interface Specification 2.05
6.7.5 OPCSERVERSTATUS
typedef struct {
FILETIME ftStartTime;
FILETIME ftCurrentTime;
FILETIME ftLastUpdateTime;
OPCSERVERSTATE dwServerState;
DWORD dwGroupCount;
DWORD dwBandWidth;
WORD wMajorVersion;
WORD wMinorVersion;
WORD wBuildNumber;
WORD wReserved;
[string] LPWSTR szVendorInfo;
} OPCSERVERSTATUS;
This structure used to communicate the status of the server to the client. This information is provided by
the server in the IOPCServer::GetStatus() call.
Member Description
ftStartTime Time (UTC) the server was started. This is constant for the
server instance and is not reset when the server changes
states. Each instance of a server should keep the time when
the process started.
ftCurrentTime The current time (UTC) as known by the server.
ftLastUpdateTime The time (UTC) the server sent the last data value update to
this client. This value is maintained on an instance basis.
dwServerState The current status of the server. Refer to OPC Server
State values below.
dwGroupCount The total number of groups (all public and private) being
managed by the server. This is mainly for diagnostic
purposes.
dwBandWidth The behavior of this field is server specific. A suggested
use is that it return the approximate Percent of Bandwidth
currently in use by server. If multiple links are in use it
could return the ‘worst case’ link. Note that any value over
100% indicates that the aggregate combination of items and
UpdateRate is too high. The server may also return
0xFFFFFFFF if this value is unknown.
wMajorVersion The major version of the server software
wMinorVersion The minor version of the server software
wBuildNumber The ‘build number’ of the server software
szVendorInfo Vendor specific string providing additional information
about the server. It is recommended that this mention the
name of the company and the type of device(s) supported.
160
OPC Data Access Custom Interface Specification 2.05
161
OPC Data Access Custom Interface Specification 2.05
The low 8 bits of the Quality flags are currently defined in the form of three bit fields; Quality,
Substatus and Limit status. The 8 Quality bits are arranged as follows:
QQSSSSLL
The high 8 bits of the Quality Word are available for vendor specific use. If these bits are used, the
standard OPC Quality bits must still be set as accurately as possible to indicate what assumptions the
client can make about the returned data. In addition it is the responsibility of any client interpreting
vendor specific quality information to insure that the server providing it uses the same ‘rules’ as the
client. The details of such a negotiation are not specified in this standard although a QueryInterface
call to the server for a vendor specific interface such as IMyQualityDefinitions is a possible approach.
Details of the OPC standard quality bits follow:
Comment:
A server which supports no quality information must return 3 (Good). It is also acceptable for a server
to simply return Bad or Good (0x00 or 0xC0) and to always return 0 for Substatus and limit.
It is recommended that clients minimally check the Quality Bit field of all results (even if they do not
check the substatus or limit fields).
Even when a ‘BAD’ value is indicated, the contents of the value field must still be a well defined
VARIANT even though it does not contain an accurate value. This is to simplify error handling in
client applications. For example, clients are always expected to call VariantClear() on the results of a
Sychronous Read. Similarly the IAdviseSink needs to be able to interpret and ‘unpack’ the Value and
Data included in the Stream even if that data is BAD.
If the server has no known value to return then some reasonable default should be returned such as a
NUL string or a 0 numeric value.
162
OPC Data Access Custom Interface Specification 2.05
Comment
Servers which do not support Substatus should return 0. Note that an ‘old’ value may be returned with
the Quality set to BAD (0) and the Substatus set to 5. This is for consistency with the Fieldbus
Specification. This is the only case in which a client may assume that a ‘BAD’ value is still usable by
the application.
163
OPC Data Access Custom Interface Specification 2.05
Comment
Servers which do not support Substatus should return 0.
164
OPC Data Access Custom Interface Specification 2.05
Comment
Servers which do not support Substatus should return 0.
Comment
Servers which do not support Limit should return 0.
Symbolic Equates are defined for values and masks for these BitFields in the “QUALITY” section of
the OPC header files.
165
OPC Data Access Custom Interface Specification 2.05
We have attempted to minimize the number of unique errors by identifying common generic problems
and defining error codes that can be reused in many contexts. An OPC server should only return those
OPC errors that are listed for the various methods in this specification or are standard Microsoft errors.
Note that OLE itself will frequently return errors (such as RPC errors) in addition to those listed in this
specification.
The most important thing for a client is to check FAILED for any error return. Other than that, (the
statements above not withstanding) a robust, user friendly client should assume that the server may
return any error code and should call the GetErrorString function to provide user readable information
about those errors.
166
OPC Data Access Custom Interface Specification 2.05
OPC_S_CLAMP A value passed to WRITE was accepted but the output was
clamped.
OPC_S_INUSE The operation cannot be performed because the object is bering
referenced.
OPC_S_UNSUPPORTEDRATE The server does not support the requested data rate but will use the
closest available rate.
You will see in the appendix that these error codes use ITF_FACILITY. This means that they are context
specific (i.e. OPC specific). The calling application should check first with the server providing the error
(i.e. call GetErrorString).
Error codes (the low order word of the HRESULT) from 0000 to 0200 are reserved for Microsoft use
(although some were inadverdantly used for OPC 1.0 errors). Codes from 0200 through 7FFF are reserved
for future OPC use. Codes from 8000 through FFFF can be vendor specific.
167
OPC Data Access Custom Interface Specification 2.05
8 Appendix A - OPCError.h
/*++
Module Name:
OpcError.h
Author:
OPC Task Force
Revision History:
Release 1.0A
Removed Unused messages
Added OPC_S_INUSE, OPC_E_INVALIDCONFIGFILE, OPC_E_NOTFOUND
Release 2.0
Added OPC_E_INVALID_PID
--*/
/*
Code Assignements:
0000 to 0200 are reserved for Microsoft use
(although some were inadverdantly used for OPC 1.0 errors).
0200 to 7FFF are reserved for future OPC use.
8000 to FFFF can be vendor specific.
*/
#ifndef __OPCERROR_H
#define __OPCERROR_H
//
// Values are 32 bit values laid out as follows:
//
// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
// +---+-+-+-----------------------+-------------------------------+
// |Sev|C|R| Facility | Code |
// +---+-+-+-----------------------+-------------------------------+
//
// where
//
// Sev - is the severity code
//
// 00 - Success
// 01 - Informational
// 10 - Warning
// 11 - Error
//
// C - is the Customer code flag
//
// R - is a reserved bit
//
// Facility - is the facility code
//
// Code - is the facility's status code
//
//
168
OPC Data Access Custom Interface Specification 2.05
//
// MessageId: OPC_E_INVALIDHANDLE
//
// MessageText:
//
// The value of the handle is invalid.
//
#define OPC_E_INVALIDHANDLE ((HRESULT)0xC0040001L)
//
// MessageId: OPC_E_BADTYPE
//
// MessageText:
//
// The server cannot convert the data between the
// requested data type and the canonical data type.
//
#define OPC_E_BADTYPE ((HRESULT)0xC0040004L)
//
// MessageId: OPC_E_PUBLIC
//
// MessageText:
//
// The requested operation cannot be done on a public group.
//
//
#define OPC_E_PUBLIC ((HRESULT)0xC0040005L)
//
// MessageId: OPC_E_BADRIGHTS
//
// MessageText:
//
// The Items AccessRights do not allow the operation.
//
#define OPC_E_BADRIGHTS ((HRESULT)0xC0040006L)
//
// MessageId: OPC_E_UNKNOWNITEMID
//
// MessageText:
//
// The item is no longer available in the server address space
//
//
#define OPC_E_UNKNOWNITEMID ((HRESULT)0xC0040007L)
//
// MessageId: OPC_E_INVALIDITEMID
//
// MessageText:
//
// The item definition doesn't conform to the server's syntax.
//
#define OPC_E_INVALIDITEMID ((HRESULT)0xC0040008L)
169
OPC Data Access Custom Interface Specification 2.05
//
// MessageId: OPC_E_INVALIDFILTER
//
// MessageText:
//
// The filter string was not valid
//
#define OPC_E_INVALIDFILTER ((HRESULT)0xC0040009L)
//
// MessageId: OPC_E_UNKNOWNPATH
//
// MessageText:
//
// The item's access path is not known to the server.
//
//
#define OPC_E_UNKNOWNPATH ((HRESULT)0xC004000AL)
//
// MessageId: OPC_E_RANGE
//
// MessageText:
//
// The value was out of range.
//
//
#define OPC_E_RANGE ((HRESULT)0xC004000BL)
//
// MessageId: OPC_E_DUPLICATENAME
//
// MessageText:
//
// Duplicate name not allowed.
//
//
#define OPC_E_DUPLICATENAME ((HRESULT)0xC004000CL)
//
// MessageId: OPC_S_UNSUPPORTEDRATE
//
// MessageText:
//
// The server does not support the requested data rate
// but will use the closest available rate.
//
//
#define OPC_S_UNSUPPORTEDRATE ((HRESULT)0x0004000DL)
//
// MessageId: OPC_S_CLAMP
//
// MessageText:
//
170
OPC Data Access Custom Interface Specification 2.05
// A value passed to WRITE was accepted but the output was clamped.
//
#define OPC_S_CLAMP ((HRESULT)0x0004000EL)
//
// MessageId: OPC_S_INUSE
//
// MessageText:
//
// The operation cannot be completed because the
// object still has references that exist.
//
//
#define OPC_S_INUSE ((HRESULT)0x0004000FL)
//
// MessageId: OPC_E_INVALIDCONFIGFILE
//
// MessageText:
//
// The server's configuration file is an invalid format.
//
#define OPC_E_INVALIDCONFIGFILE ((HRESULT)0xC0040010L)
//
// MessageId: OPC_E_NOTFOUND
//
// MessageText:
//
// The server could not locate the requested object.
//
#define OPC_E_NOTFOUND ((HRESULT)0xC0040011L)
//
// MessageId: OPC_E_INVALID_PID
//
// MessageText:
//
// The server does not recognise the passed property ID.
//
#define OPC_E_INVALID_PID ((HRESULT)0xC0040203L)
#endif // OpcError
171
OPC Data Access Custom Interface Specification 2.05
NOTE: This IDL file and the Proxy/Stub generated from it should NEVER be
modified in any way. If you add vendor specific interfaces to your server (which
is allowed) you must generate a SEPARATE vendor specific IDL file to describe
only those interfaces and a separate vendor specific ProxyStub DLL to marshall
only those interfaces.
Note: See the OPC Overview document (OPCOVW.DOC) for a listing and disucssion of
OPCCOMN.IDL.
// OPCDA.IDL
// REVISION: 6/17/98 04:00 PM (EST)
// VERSIONINFO 2.0.0.0
// 12/05/97 acc fixed UNCERTAIN bits, add AsyncIO2, OPCDataCallback,
// OPCItemProperties, BROWSE_TO
// 06/19/98 acc change V2 uuids prior to final release
// to avoid conflict with 'old' OPCDA Automation uuids
// Change name of 3 methods on AsyncIO2 to
// Cancel2,SetEnable,GetEnable to eliminate conflicts
//
import "oaidl.idl" ;
172
OPC Data Access Custom Interface Specification 2.05
OPC_NOENUM = 0,
OPC_ANALOG,
OPC_ENUMERATED } OPCEUTYPE;
173
OPC Data Access Custom Interface Specification 2.05
FILETIME ftTimeStamp;
WORD wQuality;
WORD wReserved;
VARIANT vDataValue;
} OPCITEMSTATE;
//****************************************************
174
OPC Data Access Custom Interface Specification 2.05
//****************************************************
//Interface Definitions
//
//****************************************************
[
object,
uuid(39c13a4d-011e-11d0-9675-0020afd8adb3),
pointer_default(unique)
]
interface IOPCServer : IUnknown
{
HRESULT AddGroup(
[in, string] LPCWSTR szName,
175
OPC Data Access Custom Interface Specification 2.05
HRESULT GetErrorString(
[in] HRESULT dwError,
[in] LCID dwLocale,
[out, string] LPWSTR * ppString
);
HRESULT GetGroupByName(
[in, string] LPCWSTR szName,
[in] REFIID riid,
[out, iid_is(riid)] LPUNKNOWN * ppUnk
);
HRESULT GetStatus(
[out] OPCSERVERSTATUS ** ppServerStatus
);
HRESULT RemoveGroup(
[in] OPCHANDLE hServerGroup,
[in] BOOL bForce
);
HRESULT CreateGroupEnumerator(
[in] OPCENUMSCOPE dwScope,
[in] REFIID riid,
[out, iid_is(riid)] LPUNKNOWN* ppUnk
);
//****************************************************
[
object,
uuid(39c13a4e-011e-11d0-9675-0020afd8adb3),
pointer_default(unique)
]
interface IOPCServerPublicGroups : IUnknown
{
HRESULT GetPublicGroupByName(
[in, string] LPCWSTR szName,
[in] REFIID riid,
[out, iid_is(riid)] LPUNKNOWN * ppUnk
);
HRESULT RemovePublicGroup(
[in] OPCHANDLE hServerGroup,
176
OPC Data Access Custom Interface Specification 2.05
//****************************************************
[
object,
uuid(39c13a4f-011e-11d0-9675-0020afd8adb3),
pointer_default(unique)
]
interface IOPCBrowseServerAddressSpace: IUnknown
{
HRESULT QueryOrganization(
[out] OPCNAMESPACETYPE * pNameSpaceType
);
HRESULT ChangeBrowsePosition(
[in] OPCBROWSEDIRECTION dwBrowseDirection,
[in, string] LPCWSTR szString
);
HRESULT BrowseOPCItemIDs(
[in] OPCBROWSETYPE dwBrowseFilterType,
[in, string] LPCWSTR szFilterCriteria,
[in] VARTYPE vtDataTypeFilter,
[in] DWORD dwAccessRightsFilter,
[out] LPENUMSTRING * ppIEnumString
);
HRESULT GetItemID(
[in] LPWSTR szItemDataID,
[out, string] LPWSTR * szItemID
);
HRESULT BrowseAccessPaths(
[in, string] LPCWSTR szItemID,
[out] LPENUMSTRING * ppIEnumString
);
}
//****************************************************
[
object,
uuid(39c13a50-011e-11d0-9675-0020afd8adb3),
pointer_default(unique)
]
interface IOPCGroupStateMgt : IUnknown
{
HRESULT GetState(
[out] DWORD * pUpdateRate,
[out] BOOL * pActive,
[out, string] LPWSTR * ppName,
[out] LONG * pTimeBias,
[out] FLOAT * pPercentDeadband,
177
OPC Data Access Custom Interface Specification 2.05
HRESULT SetState(
[unique, in] DWORD * pRequestedUpdateRate,
[out] DWORD * pRevisedUpdateRate,
[unique, in] BOOL * pActive,
[unique, in] LONG * pTimeBias,
[unique, in] FLOAT * pPercentDeadband,
[unique, in] DWORD * pLCID,
[unique, in] OPCHANDLE * phClientGroup
);
HRESULT SetName(
[in, string] LPCWSTR szName
);
HRESULT CloneGroup(
[in, string] LPCWSTR szName,
[in] REFIID riid,
[out, iid_is(riid)] LPUNKNOWN * ppUnk
);
}
//****************************************************
[
object,
uuid(39c13a51-011e-11d0-9675-0020afd8adb3),
pointer_default(unique)
]
interface IOPCPublicGroupStateMgt : IUnknown
{
HRESULT GetState(
[out] BOOL * pPublic
);
HRESULT MoveToPublic(
void
);
}
//****************************************************
[
object,
uuid(39c13a52-011e-11d0-9675-0020afd8adb3),
pointer_default(unique)
]
interface IOPCSyncIO : IUnknown
{
HRESULT Read(
[in] OPCDATASOURCE dwSource,
178
OPC Data Access Custom Interface Specification 2.05
HRESULT Write(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[in, size_is(dwCount)] VARIANT * pItemValues,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
}
//****************************************************
[
object,
uuid(39c13a53-011e-11d0-9675-0020afd8adb3),
pointer_default(unique)
]
interface IOPCAsyncIO : IUnknown
{
HRESULT Read(
[in] DWORD dwConnection,
[in] OPCDATASOURCE dwSource,
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[out] DWORD * pTransactionID,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
HRESULT Write(
[in] DWORD dwConnection,
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[in, size_is(dwCount)] VARIANT * pItemValues,
[out] DWORD * pTransactionID,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
HRESULT Refresh(
[in] DWORD dwConnection,
[in] OPCDATASOURCE dwSource,
[out] DWORD * pTransactionID
);
HRESULT Cancel(
[in] DWORD dwTransactionID
);
//****************************************************
[
object,
179
OPC Data Access Custom Interface Specification 2.05
uuid(39c13a54-011e-11d0-9675-0020afd8adb3),
pointer_default(unique)
]
interface IOPCItemMgt: IUnknown
{
HRESULT AddItems(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCITEMDEF * pItemArray,
[out, size_is(,dwCount)] OPCITEMRESULT ** ppAddResults,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
HRESULT ValidateItems(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCITEMDEF * pItemArray,
[in] BOOL bBlobUpdate,
[out, size_is(,dwCount)] OPCITEMRESULT ** ppValidationResults,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
HRESULT RemoveItems(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
HRESULT SetActiveState(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[in] BOOL bActive,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
HRESULT SetClientHandles(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[in, size_is(dwCount)] OPCHANDLE * phClient,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
HRESULT SetDatatypes(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[in, size_is(dwCount)] VARTYPE * pRequestedDatatypes,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
HRESULT CreateEnumerator(
[in] REFIID riid,
[out, iid_is(riid)] LPUNKNOWN * ppUnk
);
}
//****************************************************
[
object,
180
OPC Data Access Custom Interface Specification 2.05
uuid(39c13a55-011e-11d0-9675-0020afd8adb3),
pointer_default(unique)
]
interface IEnumOPCItemAttributes : IUnknown
{
HRESULT Next(
[in] ULONG celt,
[out, size_is(,*pceltFetched)] OPCITEMATTRIBUTES ** ppItemArray,
[out] ULONG * pceltFetched
);
HRESULT Skip(
[in] ULONG celt
);
HRESULT Reset(
void
);
HRESULT Clone(
[out] IEnumOPCItemAttributes ** ppEnumItemAttributes
);
}
HRESULT OnReadComplete(
[in] DWORD dwTransid,
[in] OPCHANDLE hGroup,
[in] HRESULT hrMasterquality,
[in] HRESULT hrMastererror,
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phClientItems,
[in, size_is(dwCount)] VARIANT * pvValues,
[in, size_is(dwCount)] WORD * pwQualities,
[in, size_is(dwCount)] FILETIME * pftTimeStamps,
[in, size_is(dwCount)] HRESULT * pErrors
181
OPC Data Access Custom Interface Specification 2.05
);
HRESULT OnWriteComplete(
[in] DWORD dwTransid,
[in] OPCHANDLE hGroup,
[in] HRESULT hrMastererr,
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * pClienthandles,
[in, size_is(dwCount)] HRESULT * pErrors
);
HRESULT OnCancelComplete(
[in] DWORD dwTransid,
[in] OPCHANDLE hGroup
);
//****************************************************
[
object,
uuid(39c13a71-011e-11d0-9675-0020afd8adb3),
pointer_default(unique)
]
interface IOPCAsyncIO2 : IUnknown
{
HRESULT Read(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[in] DWORD dwTransactionID,
[out] DWORD * pdwCancelID,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
HRESULT Write(
[in] DWORD dwCount,
[in, size_is(dwCount)] OPCHANDLE * phServer,
[in, size_is(dwCount)] VARIANT * pItemValues,
[in] DWORD dwTransactionID,
[out] DWORD * pdwCancelID,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
HRESULT Refresh2(
[in] OPCDATASOURCE dwSource,
[in] DWORD dwTransactionID,
[out] DWORD * pdwCancelID
);
HRESULT Cancel2(
[in] DWORD dwCancelID
);
HRESULT SetEnable(
[in] BOOL bEnable
);
182
OPC Data Access Custom Interface Specification 2.05
HRESULT GetEnable(
[out] BOOL *pbEnable
);
//****************************************************
[
object,
uuid(39c13a72-011e-11d0-9675-0020afd8adb3),
pointer_default(unique)
]
interface IOPCItemProperties : IUnknown
{
HRESULT QueryAvailableProperties (
[in] LPWSTR szItemID,
[out] DWORD * pdwCount,
[out, size_is(,*pdwCount)] DWORD ** ppPropertyIDs,
[out, size_is(,*pdwCount)] LPWSTR ** ppDescriptions,
[out, size_is(,*pdwCount)] VARTYPE ** ppvtDataTypes
);
HRESULT GetItemProperties (
[in] LPWSTR szItemID,
[in] DWORD dwCount,
[in, size_is(dwCount)] DWORD * pdwPropertyIDs,
[out, size_is(,dwCount)] VARIANT ** ppvData,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
HRESULT LookupItemIDs(
[in] LPWSTR szItemID,
[in] DWORD dwCount,
[in, size_is(dwCount)] DWORD * pdwPropertyIDs,
[out, string, size_is(,dwCount)] LPWSTR ** ppszNewItemIDs,
[out, size_is(,dwCount)] HRESULT ** ppErrors
);
}
interface IOPCServer ;
183
OPC Data Access Custom Interface Specification 2.05
interface IOPCServerPublicGroups ;
interface IOPCBrowseServerAddressSpace;
interface IOPCGroupStateMgt ;
interface IOPCPublicGroupStateMgt ;
interface IOPCSyncIO ;
interface IOPCAsyncIO ;
interface IOPCItemMgt;
interface IEnumOPCItemAttributes ;
interface IOPCDataCallback ;
interface IOPCAsyncIO2 ;
interface IOPCItemProperties ;
};
184
OPC Data Access Custom Interface Specification 2.05
10 Appendix D - OPCProps.h
This file is provided as a convenience. It duplicates the information presented in the Specification in
the IOPCItemProperties Inteface discussion.
/*++
Module Name:
OPCProps.h
Author:
OPC Task Force
Revision History:
Release 2.0
Created
--*/
/*
Property ID Code Assignements:
0000 to 4999 are reserved for OPC use
*/
#ifndef __OPCPROPS_H
#define __OPCPROPS_H
#define OPC_PROP_CDT 1
#define OPC_PROP_VALUE 2
#define OPC_PROP_QUALITY 3
#define OPC_PROP_time 4
#define OPC_PROP_RIGHTS 5
#define OPC_PROP_SCANRATE 6
185
OPC Data Access Custom Interface Specification 2.05
186