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.