diff options
author | Alois Zoitl | 2018-03-23 21:29:19 +0000 |
---|---|---|
committer | Alois Zoitl | 2018-03-23 21:29:19 +0000 |
commit | 591e57a2452d6b78badbb858cdfb0d0f6c42458e (patch) | |
tree | 75a66f0b5f7f1e660ea8ffd40118a3335345f595 | |
parent | 437d0a54af1a389c6f2b9cab7cd5d9caed969765 (diff) | |
parent | 09c797ea2a4e7b026e90d8f3b06bca69f686f754 (diff) | |
download | org.eclipse.4diac.forte-591e57a2452d6b78badbb858cdfb0d0f6c42458e.tar.gz org.eclipse.4diac.forte-591e57a2452d6b78badbb858cdfb0d0f6c42458e.tar.xz org.eclipse.4diac.forte-591e57a2452d6b78badbb858cdfb0d0f6c42458e.zip |
Merge branch '1.9.x' of ssh://azoitl@git.eclipse.org:29418/4diac/org.eclipse.4diac.forte.git into 1.9.x
-rw-r--r-- | src/modules/opc_ua/opcua_handler.cpp | 4 | ||||
-rw-r--r-- | src/modules/opc_ua/opcua_handler.h | 9 | ||||
-rw-r--r-- | src/modules/opc_ua/opcua_layer.cpp | 41 |
3 files changed, 39 insertions, 15 deletions
diff --git a/src/modules/opc_ua/opcua_handler.cpp b/src/modules/opc_ua/opcua_handler.cpp index 7f908c10b..ae3c403da 100644 --- a/src/modules/opc_ua/opcua_handler.cpp +++ b/src/modules/opc_ua/opcua_handler.cpp @@ -714,6 +714,10 @@ UA_StatusCode COPC_UA_Handler::createVariableNode(const UA_NodeId *parentNode, c return retVal; } +UA_StatusCode COPC_UA_Handler::updateNodeUserAccessLevel(const UA_NodeId *nodeId, UA_Byte newAccessLevel) { + return UA_Server_writeAccessLevel(uaServer, *nodeId, newAccessLevel); +} + UA_StatusCode COPC_UA_Handler::createMethodNode(const UA_NodeId *parentNode, UA_UInt16 namespaceIdx, const char *methodName, UA_MethodCallback callback, void *callbackHandle, unsigned int inputArgumentsSize, const UA_Argument *inputArguments, unsigned int outputArgumentsSize, const UA_Argument *outputArguments, UA_NodeId *returnNodeId) { diff --git a/src/modules/opc_ua/opcua_handler.h b/src/modules/opc_ua/opcua_handler.h index c12e0436b..fcd5e6d55 100644 --- a/src/modules/opc_ua/opcua_handler.h +++ b/src/modules/opc_ua/opcua_handler.h @@ -68,6 +68,15 @@ public: UA_NodeId *returnVarNodeId, bool allowWrite); /** + * Sets the user access level attribute of the node to the given new value. + * @param nodeId the node for which to update the access level + * @param newAccessLevel new access level of the node + * @return UA_STATUSCODE_GOOD on succes, the error code otherwise + */ + UA_StatusCode updateNodeUserAccessLevel(const UA_NodeId *nodeId, UA_Byte newAccessLevel); + + + /** * Create a new method node in the OPC UA information model. * * @param parentNode parent node where the method should be created diff --git a/src/modules/opc_ua/opcua_layer.cpp b/src/modules/opc_ua/opcua_layer.cpp index 661dd532b..be9af7ebf 100644 --- a/src/modules/opc_ua/opcua_layer.cpp +++ b/src/modules/opc_ua/opcua_layer.cpp @@ -351,21 +351,32 @@ forte::com_infra::EComResponse COPC_UA_Layer::createPubSubNodes(struct FB_NodeId retVal = GET_HANDLER_FROM_LAYER(*m_poFb, COPC_UA_Handler)->getNodeForPath(&(*nodeIds)[i].variableId, sourceVarBrowseName, false, (*nodeIds)[i].functionBlockId); forte_free(sourceVarBrowseName); - if (retVal == UA_STATUSCODE_GOOD && (*nodeIds)[i].variableId == NULL) { - // we need to create the variable - - (*nodeIds)[i].convert = conv; - void *varValue = UA_new(conv->type); - UA_init(varValue, conv->type); - (*nodeIds)[i].variableId = UA_NodeId_new(); - if (!conv->get(&initData[i], varValue)) { - DEVLOG_WARNING("OPC UA: Cannot convert value of port %d for initialization", i); - } - retVal = GET_HANDLER_FROM_LAYER(*m_poFb, COPC_UA_Handler)->createVariableNode((*nodeIds)[i].functionBlockId, connectedToName, conv->type, - varValue, (*nodeIds)[i].variableId, !isSD); - UA_delete(varValue, conv->type); - if (retVal == UA_STATUSCODE_GOOD && !isSD) { - GET_HANDLER_FROM_LAYER(*m_poFb, COPC_UA_Handler)->registerNodeCallBack((*nodeIds)[i].variableId, this, conv, i); + if (retVal == UA_STATUSCODE_GOOD) { + if ((*nodeIds)[i].variableId == NULL) { + // we need to create the variable + + (*nodeIds)[i].convert = conv; + void *varValue = UA_new(conv->type); + UA_init(varValue, conv->type); + (*nodeIds)[i].variableId = UA_NodeId_new(); + if (!conv->get(&initData[i], varValue)) { + DEVLOG_WARNING("OPC UA: Cannot convert value of port %d for initialization", i); + } + retVal = GET_HANDLER_FROM_LAYER(*m_poFb, COPC_UA_Handler)->createVariableNode((*nodeIds)[i].functionBlockId, connectedToName, conv->type, + varValue, (*nodeIds)[i].variableId, !isSD); + UA_delete(varValue, conv->type); + if (retVal == UA_STATUSCODE_GOOD && !isSD) { + GET_HANDLER_FROM_LAYER(*m_poFb, COPC_UA_Handler)->registerNodeCallBack((*nodeIds)[i].variableId, this, conv, i); + } + } else if (!isSD) { + // the node already exists. It could be the case that the node was previously created + // for a subscribe FB, which sets the access to read only. Since this is now a publish FB + // we need to change the access to read & write + if (UA_STATUSCODE_GOOD != GET_HANDLER_FROM_LAYER(*m_poFb, + COPC_UA_Handler)->updateNodeUserAccessLevel((*nodeIds)[i].variableId, + UA_ACCESSLEVELMASK_READ & UA_ACCESSLEVELMASK_WRITE)) { + DEVLOG_WARNING("OPC UA: Cannot set write permission of node for port %d", i); + } } } // else if retVal = UA_STATUSCODE_GOOD the node already exists |