Annex A OPC COM DA to UA mapping (Normative)

A.1 Introduction

This Annex provides details on mapping OPC COM Data Access (DA) information to OPC UA to help vendors migrate to OPC UA based systems while still being able to access information from existing OPC COM DA systems.

The OPC Foundation provides COM UA Wrapper and Proxy samples that act as a bridge between the OPC DA and the OPC UA systems.

The COM UA Wrapper is an OPC UA Server that wraps an OPC DA Server and with that enables an OPC UA Client to access information from the DA Server. The COM UA Proxy enables an OPC DA Client to access information from an OPC UA Server.

The mappings describe generic DA interoperability components. It is recommended that vendors use this mapping if they develop their own components, however, some applications can benefit from vendor specific mappings.

A.2 Security Considerations

COM DA relies on the Microsoft COM security infrastructure and does not specify any security parameters such as user identity. The developer of UA Wrapper and Proxy therefore has to consider the mapping of security aspects.

The COM UA Wrapper for instance can accept any Username/password and then try to impersonate this user by calling proper Windows services before connecting to the COM DA Server.

A.3 COM UA wrapper for OPC DA Server

A.3.1 Information Model mapping

A.3.1.1 General

OPC DA defines 3 elements in the address space: Branch, Item and Property. The COM UA Wrapper maps these types to the OPC UA types as described in Subclauses A.4.3.2 to A.4.3.4.

Figure A.13 – Sample OPC UA Information Model for OPC DA
A.3.1.2 Branch

DA Branches are represented in the COM UA Wrapper as Objects of FolderType.

The top-level branch (the root) should be represented by an Object where the BrowseName is the Server ProgId.

The OPC DA Address space hierarchy is discovered using the ChangeBrowsePosition from the Root and BrowseOPCItemIds to get the Branches, Items and Properties.

The name returned from the BrowseOPCItemIds enumString is used as the BrowseName and the DisplayName for each Branch. See also clause A.3.1.5.

The ItemId obtained using the GetItemID is used as a part of the NodeId for each Branch. See also clause A.3.1.5.

An OPC UA Folder representing a DA Branch uses the Organizes References to reference child DA Branches and uses HasComponent References for DA Leafs (Items). It is acceptable for customized wrappers to use a sub-type of these ReferenceTypes.

A.3.1.3 Item

DA items (leafs) are represented in the COM UA Wrapper as Variables. The VariableType depends on the existance of special DA properties as follows:

Below are mappings that are common for all item types

Any Properties added to a Node in the COM UA Wrapper are referenced using the HasProperty ReferenceType.

A.3.1.4 Property

A property in the DA server is represented in the COM UA Wrapper as a Variable with TypeDefinition as PropertyType.

The properties for an item are retrieved using the QueryAvailableProperties call in the DA server.

Below are mappings of the property details to the OPC UA Property:

Table A. shows the mapping between the common OPC COM DA properties to the OPC UA Node attributes/properties.

Table A.1 – OPC COM DA to OPC UA Properties mapping
Property Name (PropertyID) of OPC COM DAOPC UA Information ModelOPC UA DataType
Access Rights (5)AccessLevel AttributeInt32
EU Units (100)EngineeringUnits PropertyString
Item Description (101)Description AttributeString
High EU (102)EURange PropertyDouble
Low EU (103)EURange PropertyDouble
High Instrument Range (104)InstrumentRange PropertyDouble
Low Instrument Range (105)InstrumentRange PropertyDouble
Close Label (106)TrueState PropertyString
Open Label (107)FalseState PropertyString
Other Properties (include Vendor specific Properties)PropertyType Based on the DataType of the Property
A.3.1.5 BrowseName and DisplayName Mapping

As described above, both the OPC UA Browsename and Displayname for Nodes representing COM DA Branches and Leafs are derived from the name of the corresponding item in the COM DA Server.

This name can only be acquired by using the COM DA Browse Services. In OPC UA, however, the BrowseName and DisplayName are Attributes that Clients can ask for at any time. There are several options to support this in a Wrapper but all of them have pros and cons. Here are some popular implementation options:

Allow browsing the complete COM DA Address Space and then build and persist an offline copy of it. Resolve the BrowseName by scanning this offline copy.

Pro: The ItemID can be used as is for the OPC UA NodeId.

Con: The initial browse can take a while and can have to be repeated for COM DA Servers with a dynamic Address Space.

Create OPC UA NodeId values that include both the COM DA ItemID and the Item name. When the OPC UA Client passes such a NodeId to read the BrowseName or DisplayName Attribute, the wrapper can easily extract the name from the NodeId value.

Pro: Efficient and reliable.

Con: The NodeId will not represent the ItemId. It becomes difficult for human users to match the two IDs.

A number of COM DA Servers use ItemIDs that consist of a path where the path elements are separated with a delimiter and the last element is the item name. Wrappers can provide ways to configure the delimiter so that they can easily extract the item name.

Pro: Efficient and reliable. The ItemID can be used as is for the OPC UA NodeId.

Con: Not a generic solution. Only works for specific COM-DA Servers.

For wrappers that are custom to a specific Server, knowledge of the COM DA server address space can result in other optimizations or short cuts (i.e. the server will always have a certain schema / naming sequence etc.).

A.3.2 Data and error mapping

A.3.2.1 General

In a DA server, Automation Data is represented by Value, Quality and Time Stamp for a Tag.

The COM UA Wrapper maps the VQT data to the Data Value and Diagnostic Info structures.

The Error codes returned by the DA server are based on the HRESULT type. The COM UA Wrapper maps this error code to an OPC UA Status Code. Figure A.14 illustrates this mapping.

Figure A.14 – OPC COM DA to OPC UA data and error mapping
A.3.2.2 Value

The data values in the DA server are represented as Variant data type. The COM UA Wrapper converts them to the corresponding OPC UA DataType. The mapping is shown in Table A.2:

Table A.2 – DataTypes and mapping

Variant Data Type

(In DA server)

OPC UA Data type Mapping in COM UA Server

(DataValue structure)

VT_I2Int16
VT_I4Int32
VT_R4 Float
VT_R8Double
VT_BSTRString
VT_BOOLBoolean
VT_UI1Byte
VT_I1SByte
VT_UI2UInt16
VT_UI4UInt32
VT_I8Int64
VT_UI8UInt64
VT_DATEDouble
VT_DECIMALDecimal
VT_ARRAYArray of OPC UA types

.

A.3.2.3 Quality

The Quality of a Data Value in the DA server is represented as a 16 bit value where the lower 8 bits is of the form QQSSSSLL (Q: Main Quality, S: Sub Status, L: Limit) and higher 8 bits is vendor specific.

The COM UA Wrapper maps the DA server to the OPC UA Status code as shown in Figure A.15:

Figure A.15 – Status Code mapping

The primary quality is mapped to the Severity field of the Status code. The Sub Status is mapped to the SubCode and the Limit is mapped to the Limit Bits of the Status Code.

Please note that the Vendor quality is currently discarded.

Table A.3 shows a mapping of the OPC COM DA primary quality mapping to OPC UA status code

Table A.3 – Quality mapping
OPC DA Primary Quality (Quality & Sub status QQSSSS)OPC UA Status Code
GOODGood
LOCAL_OVERRIDE Good_LocalOverride
UNCERTAINUncertain
SUB_NORMALUncertain_SubNormal
SENSOR_CALUncertain_SensorNotAccurate
EGU_EXCEEDEDUncertain_EngineeringUnitsExceeded
LAST_USABLEUncertain_LastUsableValue
BADBad
CONFIG_ERRORBad_ConfigurationError
NOT_CONNECTEDBad_NotConnected
COMM_FAILUREBad_NoCommunication
DEVICE_FAILUREBad_DeviceFailure
SENSOR_FAILUREBad_SensorFailure
LAST_KNOWNBad_OutOfService
OUT_OF_SERVICEBad_OutOfService
WAITING_FOR_INITIAL_DATABad_WaitingForInitialData
A.3.2.4 Timestamp

The Timestamp provided for a value in the DA server is assigned to the SourceTimeStamp of the DataValue in the COM UA Wrapper.

The ServerTimeStamp in the DataValue is set to the current time by the COM UA Wrapper at the start of the Read Operation.

A.3.3 Read data

The COM UA Wrapper supports performing Read operations to DA servers of versions 2.05a and 3.

For version 2.05a, the COM UA wrapper creates a Group using the IOPCServer::AddGroup method and adds the items whose data is to be read to the Group using IOPCItemMgmt::AddItems method. The Data is retrieved for the items using the IOPCSyncIO::Read method. The VQT for each item is mapped to the DataValue structure as shown in Figure A.14. Please note that only Read from Device is supported for this version. The “maxAge” parameter is ignored.

For version 3, the COM UA Wrapper uses the IOPCItemIO::Read to retrieve the data. The VQT for each item is mapped to the DataValue structure as shown in Figure A.14. The Read supports both the Read from Device and Cache and uses the “maxAge” parameter.

If there are errors for the items in the Read from the DA server, then these are mapped to the StatusCode of the DataValue in the COM UA Wrapper.

The mapping of the OPC COM DA Read Errors code to OPC UA Status code (in the COM UA Wrapper) is shown in Table A.4:

Table A.4 – OPC DA Read error mapping
OPC DA Error IDOPC UA Status Code
OPC_E_BADRIGHTSBad_NotReadable
E_OUTOFMEMORYBad_OutOfMemory
OPC_E_INVALIDHANDLEBad_NodeIdUnknown
OPC_E_UNKNOWNITEMIDBad_NodeIdUnknown
E_INVALIDITEMIDBad_NodeIdInvalid
E_INVALID_PIDBad_AttributeIdInvalid
E_ACCESSDENIEDBad_OutOfService
OthersBad_UnexpectedError

A.3.4 Write Data

The COM UA Wrapper supports performing Write operations to DA servers of versions 2.05a and 3.

For version 2.05a, the COM UA wrapper creates a Group using the IOPCServer::AddGroup method and adds the items whose data is to be written using IOPCItemMgmt::AddItems method. The value is written for the items using the IOPCSyncIO::Write method. Note that if the StatusCode or TimeStamps (Source or Server) is specified to be written for the item then the COM UA Wrapper returns a BadWriteNotSupported Status code for the item.

For version 3, the COM UA Wrapper uses the IOPCItemIO::WriteVQT data including StatusCode and TimeStamp. If a SourceTimeStamp is provided, this timestamp is used for the Write else the ServerTimeStamp is used.

If there are errors for the items in the Write from the DA server, then these are mapped to the StatusCode for the corresponding item.

The mapping of the OPC COM DA Write Errors code to OPC UA Status code (in the COM UA Wrapper) is shown in Table A.5:

Table A.5 – OPC DA Write error code mapping
OPC DA Error IDOPC UA Status Code
E_BADRIGHTSBad_NotWritable
DISP_E_TYPEMISMATCHBad_TypeMismatch
E_BADTYPEBad_TypeMismatch
E_RANGEBad_OutOfRange
DISP_E_OVERFLOWBad_OutOfRange
E_OUTOFMEMORYBad_OutOfMemory
E_INVALIDHANDLEBad_NodeIdUnknown
E_UNKNOWNITEMIDBad_NodeIdUnknown
E_INVALIDITEMIDBad_NodeIdInvalid
E_INVALID_PIDBad_NodeIdInvalid
E_NOTSUPPORTEDBad_WriteNotSupported
S_CLAMPGood_Clamped
OthersBad_UnexpectedError

A.3.5 Subscriptions

A subscription is created in the DA server when a MonitoredItem is created in the COM UA Wrapper.

The SamplingInterval and the Deadband value are used for the subscription to setup a periodic data change call back on the COM UA Wrapper. Note that only the PercentDeadbandType is supported by the COM UA Wrapper.

The VQT for each item is mapped to the DataValue structure as shown in Figure A.14 and published to the client by the COM UA Wrapper periodically.

The mapping of the OPC COM DA Read Errors code to OPC UA Status code (in the COM UA Wrapper) is the same as the Read mapping in Figure A.14.

A.4 COM UA proxy for DA Client

A.4.1 Guidelines

The Data Access COM UA Proxy is a COM Server combined with a UA Client. It maps the Data Access address space of UA Data Access Server into the appropriate COM Data Access objects.

Clauses A.4.1 through A.4.6 identify the design guidelines and constraints used to develop the Data Access COM UA Proxy provided by the OPC Foundation. In order to maintain a high degree of consistency and interoperability, it is strongly recommended that vendors, who choose to implement their own version of the Data Access COM UA Proxy, follow these same guidelines and constraints.

The Data Access COM Client simply chooses how to connect to the UA Data Access Server. Connectivity approaches include the one where Data Access COM Clients connect to a UA Data Access Server with a CLSID just as if the target Server were a Data Access COM Server. However, the CLSID can be considered virtual since it is defined to connect to intermediary components that ultimately connect to the UA Data Access Server. Using this approach, the Data Access COM Client calls co-create instance with a virtual CLSID as described above. This connects to the Data Access COM UA Proxy components. The Data Access COM UA Proxy then establishes a secure channel and session with the UA Data Access Server. As a result, the Data Access COM Client gets a COM Data Access Server interface pointer.

A.4.2 Information Model and Address Space mapping

A.4.2.1 General

OPC UA defines 8 Node Class types in the address space Object, Variable, Method, ObjectType, VariableType, ReferenceType, DataType, View. The COM UA Proxy maps only the nodes of Node Class types Object, Variable to the OPC DA types as shown in the figure below. Only the nodes under the Objects node are considered for the COM UA Proxy address space and others such as Types, Views are not mapped.

Figure A.16 shows an example mapping of OPC DA to OPC UA information.

Figure A.16 – Sample OPC DA mapping of OPC UA Information Model and Address Space
A.4.2.2 Object Nodes

A node of Object Node class in the OPC UA server is represented in the Data Access COM UA Proxy as a Branch.

The root of the Data Access COM UA Proxy is the Objects folder of the OPC UA Server.

The OPC UA Address space hierarchy is discovered using the Browse Service for the Objects Node using the following filters:

The DisplayName of the OPC UA node is used as the Name for each Branch in the Data Access COM UA Proxy

Each Branch in the Data Access COM UA Proxy is assigned 3 properties:

NOTE COM DA Clients typically display the ItemID and the Item Description. Since the ItemID generated by the UA Proxy can be particularly difficult to read and understand, proxies can use the DisplayName as value for the Item Description Property as it will be easier to understand by a human user.

A.4.2.3 Variable Nodes

A node of Variable Node class in the OPC UA server is represented in the Data Access COM UA Proxy as an Item.

The DisplayName of the OPC UA node is used as the Name for each Item in the Data Access COM UA Proxy.

The NodeId of the OPC UA node is used as the ItemId for each Item in the Data Access COM UA Proxy. But the ‘=’ character is replaced with ‘-’ in the string. E.g. NodeId: ns=4,i=10, ItemID = “ns-4;i-10” or NodeId: ns=4,s=FL102, ItemID = “ns-4,s-FL102”

Each Item in the Data Access COM UA Proxy is assigned the following properties based on the node attributes or its references:

Standard Properties:

The other AccessLevel provided by OPC are ignored

New Properties:

A.4.2.4 Namespace Indices

For generating ItemIDs, the Proxy uses Namespace Indices. To assure that Clients can persist these ItemIDs, the Namespace Indices shall never change. To accomplish this the Proxy has to persist its Namespace Table and only append entries but never change existing ones.

The Proxy also has to provide a translation from the current Namespace Table in the Server to the persisted Namespace Table.

If you move or copy the Proxy to another machine, the Namespace Table has to be copied to this machine as well.

A.4.3 Data and error mapping

A.4.3.1 General

In an OPC UA Server, Automation Data is represented as a Data Value and and status, in addition additional error data can be provided via Diagnostic Info for a tag

The COM UA Proxy maps the Data Value structure into VQT data and error code.

For successful operations(StatusCode of Good and Uncertain), the COM UA Proxy maps the Status Code of the DataValue to the OPC DA Quality But in case of error(StatusCode of Bad), the Status Code is mapped to the OPC DA Error code.

The StatusCode in the Diagnostic Info returned by the OPC UA Server are mapped to OPC DA Error codes. Figure A.17 illustrates this mapping.

Figure A.17 – OPC UA to OPC DA data & error mapping
A.4.3.2 Value

The COM UA Proxy converts the OPC UA Data Value to the corresponding OPC DA Variant type. The mapping is shown in Table A.6. For DataTypes that are subtypes of an existing base DataType the conversion for the Base DataType is used.

Table A.6 – DataTypes and Mapping
OPC UA Data type (In UA Server)Variant Data Type (In DA server)
Int16VT_I2
Int32VT_I4
FloatVT_R4
DoubleVT_R8
DecimalVT_DECIMAL
StringVT_BSTR
BooleanVT_BOOL
ByteVT_UI1
SByteVT_I1
UInt16VT_UI2
UInt32VT_UI4
Int64VT_I8
UInt64VT_UI8
GuidVT_BSTR
DateTimeVT_DATE
NodeIdVT_BSTR
XmlElementVT_BSTR
ExpandedNodeIdVT_BSTR
QualifiedNameVT_BSTR
LocalizedTextVT_BSTR
StatusCodeVT_UI4
ExtensionObjectArray of VT_UI1
Array of above OPC UA typesArray of corresponding Variant type
A.4.3.3 Quality

The Quality of a Data Value in the OPC UA Server is represented as a StatusCode.

The COM UA Proxy maps the Severity, Subcode and the limit bits of the OPC UA Status code to the lower 8 bits of the OPC DA Quality structure (of the form QQSSSSLL). Figure A.18 illustrates this mapping.

Figure A.18 – OPC UA Status Code to OPC DA quality mapping

The Severity field of the Status code is mapped to the primary quality. The SubCode is mapped to the Sub Status and the Limit Bits are mapped to the Limit field.

Table A.7 shows a mapping of the OPC UA status code to OPC DA primary quality

Table A.7 – Quality mapping
OPC UA Status Code OPC DA Primary Quality (Quality & Sub status QQSSSS)
GoodGOOD
Good_LocalOverrideLOCAL_OVERRIDE
UncertainUNCERTAIN
Uncertain_SubNormalSUB_NORMAL
Uncertain_SensorNotAccurateSENSOR_CAL
Uncertain_EngineeringUnitsExceededEGU_EXCEEDED
Uncertain_LastUsableValueLAST_USABLE
BadBAD
Bad_ConfigurationErrorCONFIG_ERROR
Bad_NotConnectedNOT_CONNECTED
Bad_NoCommunicationCOMM_FAILURE
Bad_OutOfServiceOUT_OF_SERVICE
Bad_DeviceFailureDEVICE_FAILURE
Bad_SensorFailureSENSOR_FAILURE
Bad_WaitingForInitialDataWAITING_FOR_INITIAL_DATA
A.4.3.4 Timestamp

If available, the SourceTimestamp of the DataValue in the OPC UA Server is assigned to the Timestamp for the value in the COM UA Proxy. If SourceTimestamp is not available, then the ServerTimestamp is used.

A.4.4 Read data

The COM UA Proxy converts all the ItemIds in the Read into valid NodeIds by replacing the ‘-’ with ‘=’ and calls the OPC UA Read Service for the Value Attribute.

If the Read Service call is successful then DataValue for each node is mapped to the VQT for each item as shown in Figure A.17.

If the Read Service call fails or If there are errors for some of the Nodes, then the StatusCodes of these Nodes are mapped to the error code by the COM UA Proxy.

The mapping of the OPC UA Status code to OPC DA Read Error code (in the COM UA Proxy) is shown in Table A.8:

Table A.8 – OPC UA Read error mapping
OPC UA Status Code OPC DA Error ID
Bad_OutOfMemoryE_OUTOFMEMORY
Bad_NodeIdInvalidE_INVALIDITEMID
Bad_NodeIdUnknownE_UNKNOWNITEMID
Bad_NotReadableE_BADRIGHTS
Bad_UserAccessDenied E_ACCESSDENIED
Bad_AttributeIdInvalidE_INVALIDITEMID
Bad_UnexpectedErrorE_FAIL
Bad_InternalErrorE_FAIL
Bad_SessionClosedE_FAIL
Bad_TypeMismatchE_BADTYPE

A.4.5 Write data

The COM UA Proxy converts all the ItemIds in the Write into valid NodeIds by replacing the ‘-’ with ‘=’. It converts the Value, Quality and Timestamp (VQT) to a DataValue structure as per the mapping in Figure A.17. and calls the OPC UA Write Service for the Value Attribute.

If the Write Service call fails or if there are errors for some of the Nodes, then the StatusCodes of these Nodes are mapped to the error code by the COM UA Proxy.

The mapping of the OPC UA Status code to OPC DA Write Error code (in the COM UA Proxy) is shown in Table A.9:

Table A.9 – OPC UA Write error code mapping
OPC UA Status Code OPC DA Error ID
Bad_TypeMismatchE_BADTYPE
Bad_OutOfMemoryE_OUTOFMEMORY
Bad_NodeIdInvalidE_INVALIDITEMID
Bad_NodeIdUnknownE_UNKNOWNITEMID
Bad_NotWritableE_BADRIGHTS
Bad_UserAccessDeniedE_ACCESSDENIED
Bad_AttributeIdInvalidE_UNKNOWNITEMID
Bad_WriteNotSupported E_NOTSUPPORTED
Bad_OutOfRangeE_RANGE

A.4.6 Subscriptions

The COM UA Proxy creates a Subscription in the OPC UA Server when a Group is created. The Name, Active flag, UpdateRate parameters of the Group are used while creating the subscription.

The COM UA Proxy Creates Monitored Items in the OPC UA Server when items are added to the Group.

Following parameters and filters are used for creating the monitored items:

The COM UA Proxy calls the Publish Service of the OPC UA Server periodically and sends any data changes to the client.