Exemplo n.º 1
0
    // Fill out an ExpandedNodeId
    // =============================================================================================
    Status NamespaceArray::fillExpandedNodeId(
            const OpcUa_ExpandedNodeId& opcUaExpandedNodeId,
            ExpandedNodeId&             expandedNodeId) const
    {
        Status ret;

        string namespaceUri;

        // according to the OPC UA specs, if the opcUaExpandedNodeId contains a namespaceUri,
        // then the namespaceIndex should be ignored.

        // So, if a non-empty namespace URI is already given, then we use that one.
        // Else, we try to find the namespace URI that corresponds to the given namespace index.
        if (!UaString(&opcUaExpandedNodeId.NamespaceUri).isEmpty())
        {
            // bugfix: added the following line: also in this situation the attributes from the SDK need to be copied!
            expandedNodeId.fromSdk(opcUaExpandedNodeId);

            NodeId nodeId = expandedNodeId.nodeId();
            nodeId.setNameSpaceUri(string(UaString(&opcUaExpandedNodeId.NamespaceUri).toUtf8()));
            expandedNodeId.setNodeId(nodeId);
            ret.isGood();
        }
        else if (findNamespaceUri(opcUaExpandedNodeId.NodeId.NamespaceIndex, namespaceUri))
        {
            ret = expandedNodeId.fromSdk(opcUaExpandedNodeId, namespaceUri);
        }
        else
        {
            ret = EmptyServerUriAndUnknownNamespaceIndexError(
                    opcUaExpandedNodeId.NodeId.NamespaceIndex);
        }

        return ret;
    }