lordgamez commented on code in PR #2265:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2265#discussion_r4612253246


##########
extensions/opc/src/OPCCommon.cpp:
##########
@@ -493,107 +494,71 @@ template UA_StatusCode Client::add_node<const char 
*>(const UA_NodeId parent_nod
 template UA_StatusCode Client::add_node<std::string>(const UA_NodeId 
parent_node_id, const UA_NodeId target_node_id, const UA_UInt32 ref_type_id, 
std::string_view browse_name,
   std::string value, UA_NodeId *received_node_id);
 
-std::string nodeValue2String(const NodeData& nd) {
-  std::string ret_val;
-  switch (nd.data_type_id) {
+std::string variantToString(const UA_Variant& variant, BinaryEncoding 
binary_encoding) {
+  if (variant.type == nullptr || variant.data == nullptr) {
+    throw OPCException(GENERAL_EXCEPTION, "Cannot convert an empty variant to 
string");
+  }
+  switch (variant.type->typeKind) {
     case UA_DATATYPEKIND_STRING:
-    case UA_DATATYPEKIND_LOCALIZEDTEXT:
-    case UA_DATATYPEKIND_BYTESTRING: {
-      UA_String value = *reinterpret_cast<UA_String *>(nd.var_->data);
-      ret_val = std::string(reinterpret_cast<const char *>(value.data), 
value.length);
-      break;
-    }
-    case UA_DATATYPEKIND_BOOLEAN: {
-      bool b = false;
-      memcpy(&b, nd.data.data(), sizeof(bool));
-      ret_val = b ? "True" : "False";
-      break;
-    }
-    case UA_DATATYPEKIND_SBYTE: {
-      int8_t i8t = 0;
-      memcpy(&i8t, nd.data.data(), sizeof(i8t));
-      ret_val = std::to_string(i8t);
-      break;
-    }
-    case UA_DATATYPEKIND_BYTE: {
-      uint8_t ui8t = 0;
-      memcpy(&ui8t, nd.data.data(), sizeof(ui8t));
-      ret_val = std::to_string(ui8t);
-      break;
-    }
-    case UA_DATATYPEKIND_INT16: {
-      int16_t i16t = 0;
-      memcpy(&i16t, nd.data.data(), sizeof(i16t));
-      ret_val = std::to_string(i16t);
-      break;
+    case UA_DATATYPEKIND_LOCALIZEDTEXT: {
+      const auto *value = static_cast<const UA_String *>(variant.data);
+      return {reinterpret_cast<const char *>(value->data), value->length};

Review Comment:
   Updated in 
https://github.com/apache/nifi-minifi-cpp/pull/2265/commits/7bb255bd66733cfca669194b9df398aff15b2d82



##########
PROCESSORS.md:
##########
@@ -1089,6 +1090,53 @@ In the list below, the names of required properties 
appear in bold. Any other pr
 | failure | An error occurred processing |
 
 
+## FetchOPCHistory
+
+### Description
+
+Fetches OPC-UA node history between the start and end timestamps. A history 
entry is only fetched once, on every trigger only the not yet fetched entries 
are returned.
+
+### Properties
+
+In the list below, the names of required properties appear in bold. Any other 
properties (not in bold) are considered optional. The table also indicates any 
default values, and whether a property supports the NiFi Expression Language.
+
+| Name                            | Default Value | Allowable Values           
      | Description                                                             
                                                                                
                                                                                
                                                                           |
+|---------------------------------|---------------|----------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| **OPC server endpoint**         |               |                            
      | Specifies the address, port and relative path of an OPC endpoint        
                                                                                
                                                                                
                                                                           |
+| Application URI                 |               |                            
      | Application URI of the client in the format 
'urn:unconfigured:application'. Mandatory, if using Secure Channel and must 
match the URI included in the certificate's Subject Alternative Names.          
                                                                                
                           |
+| Username                        |               |                            
      | Username to log in with.                                                
                                                                                
                                                                                
                                                                           |
+| Password                        |               |                            
      | Password to log in with.<br/>**Sensitive Property: true**               
                                                                                
                                                                                
                                                                           |
+| Certificate path                |               |                            
      | Path to the DER-encoded cert file                                       
                                                                                
                                                                                
                                                                           |
+| Key path                        |               |                            
      | Path to the DER-encoded key file                                        
                                                                                
                                                                                
                                                                           |
+| Trusted server certificate path |               |                            
      | Comma separated list of paths to the DER-encoded trusted server 
certificates                                                                    
                                                                                
                                                                                
   |
+| Path reference types            |               |                            
      | Specify the reference types between nodes in the path if Path Node ID 
type is used. If not provided, all reference types are assumed to be Organizes. 
The format is 'referenceType1/referenceType2/.../referenceTypeN' and the 
supported reference types are Organizes, HasComponent, HasProperty, and 
HasSubtype. |
+| **Node ID type**                |               | 
Path<br/>Int<br/>String<br/>Guid | Specifies the type of the provided node ID   
                                                                                
                                                                                
                                                                                
                      |
+| **Node ID**                     |               |                            
      | Specifies the ID of the root node to fetch history for. In case of a 
Path Node ID Type, the path should be provided in the format of 'path/to/node'. 
                                                                                
                                                                              |
+| **Namespace index**             | 0             |                            
      | The index of the namespace.                                             
                                                                                
                                                                                
                                                                           |
+| Start timestamp                 |               |                            
      | Timestamp after which the events should be returned. If not specified 
entries are returned from the beginning of the history.                         
                                                                                
                                                                             |
+| End timestamp                   |               |                            
      | Timestamp before which the events should be returned. If not specified 
entries are returned until the current time.                                    
                                                                                
                                                                            |
+| Batch size                      |               |                            
      | Maximum number entries to read and return in a single batch. If set to 
zero or empty all available entries are returned.                               
                                                                                
                                                                            |
+| **History read type**           | Raw           | Raw<br/>Audit              
      | Whether to fetch raw historical values or the audit trail of 
modifications to historical values                                              
                                                                                
                                                                                
      |
+| Record set writer               |               |                            
      | Specifies the Controller Service to use for writing results to a 
FlowFile instead of using the default output format.                            
                                                                                
                                                                                
  |
+
+### Relationships
+
+| Name    | Description                                        |
+|---------|----------------------------------------------------|
+| success | Successfully retrieved OPC-UA node history entries |
+
+### Output Attributes
+
+| Attribute              | Relationship | Description                          
                                                   |
+|------------------------|--------------|-----------------------------------------------------------------------------------------|
+| NodeID                 | success      | ID of the node.                      
                                                   |
+| Namespace index        | success      | Namespace index of the node.         
                                                   |
+| Sourcetimestamp        | success      | The timestamp of when the node was 
created in the server as 'YYYY-MM-DDTHH:MM:SS.sssZ'. |
+| ModificationUsername   | success      | Username of the user who modified 
the node.                                             |
+| ModificationTime       | success      | Timestamp of when the node was 
modified.                                                |
+| ModificationUpdateType | success      | Type of modification performed on 
the node.                                             |

Review Comment:
   Updated in 
https://github.com/apache/nifi-minifi-cpp/pull/2265/commits/7bb255bd66733cfca669194b9df398aff15b2d82



-- 
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]

Reply via email to