fgerlits commented on code in PR #2266:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2266#discussion_r4626903710
##########
extensions/opc/include/OPCCommon.h:
##########
Review Comment:
Should we change the parameter type of `namespace_index` in
`translateBrowsePathsToNodeIdsRequest` to `UA_UInt16`? That is the type we use
for the namespace index everywhere else.
##########
extensions/opc/src/OPCCommon.cpp:
##########
@@ -224,7 +235,20 @@ NodeData Client::getNodeData(const UA_ReferenceDescription
*ref, const std::stri
} else if (ref->nodeId.nodeId.identifierType == UA_NODEIDTYPE_NUMERIC) {
nodedata.attributes["node.id"] =
std::to_string(ref->nodeId.nodeId.identifier.numeric); //
NOLINT(cppcoreguidelines-pro-type-union-access)
nodedata.attributes["node.id.type"] = "numeric";
+ } else if (ref->nodeId.nodeId.identifierType == UA_NODEIDTYPE_GUID) {
+ const auto& guid = ref->nodeId.nodeId.identifier.guid; //
NOLINT(cppcoreguidelines-pro-type-union-access)
+ std::array<char, 37> guid_str_array{};
+ auto res = snprintf(guid_str_array.data(), guid_str_array.size(),
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ guid.data1, guid.data2, guid.data3, guid.data4[0],
guid.data4[1], guid.data4[2],
+ guid.data4[3], guid.data4[4], guid.data4[5],
guid.data4[6], guid.data4[7]);
+ if (res < 0) {
+ nodedata.attributes["node.id"] = "";
+ } else {
+ nodedata.attributes["node.id"] = std::string(guid_str_array.data());
+ }
Review Comment:
Could we use `printToString(UA_Guid_print, ...)` instead of this `snprintf`?
##########
extensions/opc/src/BaseOPCProcessor.cpp:
##########
@@ -92,37 +93,40 @@ bool BaseOPCProcessor::reconnect() {
return false;
}
logger_->log_debug("Successfully connected.");
+
+ // A new or re-established connection may be to a restarted server that can
reassign node ids,
+ // so if path is used to identify node id, the cached node id should be
invalidated
+ path_node_id_resolved_ = false;
Review Comment:
I find `path_node_id_resolved_` confusing. It seems to signal if a valid
value is cached in `node_`, but that is not clear from its name, or even from
this comment.
Could we connect the cached object and the "cache is valid" flag in some
way? For example, maybe we could change `node_` to an optional, and replace
`path_node_id_resolved_ = false` with clearing this optional.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]