mikakaraila / node-red-contrib-opcua

A Node-RED node to communicate OPC UA. Uses node-opcua library.
Other
208 stars 191 forks source link

Initial support for Variant Array #695

Closed IW3IJQ closed 1 month ago

IW3IJQ commented 1 month ago

Initial support for Variant Array, partially fix #680

Injecting this into a write opca-client node:

{
   "_msgid":"5f93bc6d8a31233e",
   "payload":{
      "value":[
         {
            "dataType":"Variant",
            "arrayType":"Array",
            "value":[
               {
                  "dataType":"UInt16",
                  "arrayType":"Scalar",
                  "value":1
               },
               {
                  "dataType":"UInt32",
                  "arrayType":"Scalar",
                  "value":10
               },
               {
                  "dataType":"String",
                  "arrayType":"Scalar",
                  "value":"Order Des"
               },
               {
                  "dataType":"String",
                  "arrayType":"Scalar",
                  "value":"Program Des"
               },
               {
                  "dataType":"String",
                  "arrayType":"Scalar",
                  "value":"Mould Name"
               },
               {
                  "dataType":"String",
                  "arrayType":"Scalar",
                  "value":"Material Des"
               },
               {
                  "dataType":"String",
                  "arrayType":"Scalar",
                  "value":"07/05/2024"
               },
               {
                  "dataType":"String",
                  "arrayType":"Scalar",
                  "value":"Item"
               },
               {
                  "dataType":"String",
                  "arrayType":"Scalar",
                  "value":"Item Description"
               }
            ]
         },
         {
            "dataType":"Variant",
            "arrayType":"Array",
            "value":[
               {
                  "dataType":"UInt16",
                  "arrayType":"Scalar",
                  "value":2
               },
               {
                  "dataType":"UInt32",
                  "arrayType":"Scalar",
                  "value":20
               },
               {
                  "dataType":"String",
                  "arrayType":"Scalar",
                  "value":"Order Des 2"
               },
               {
                  "dataType":"String",
                  "arrayType":"Scalar",
                  "value":"Program Des 2"
               },
               {
                  "dataType":"String",
                  "arrayType":"Scalar",
                  "value":"Mould Name 2"
               },
               {
                  "dataType":"String",
                  "arrayType":"Scalar",
                  "value":"Material Des 2"
               },
               {
                  "dataType":"String",
                  "arrayType":"Scalar",
                  "value":"07/05/2024"
               },
               {
                  "dataType":"String",
                  "arrayType":"Scalar",
                  "value":"Item2"
               },
               {
                  "dataType":"String",
                  "arrayType":"Scalar",
                  "value":"Item Description 2"
               }
            ]
         }
      ]
   },
   "topic":"ns=2;i=115682",
   "datatype":"VariantArray",
   "browseName":"f078-Value"
}

is possible to see an almost correct object passed to node-opca component:

8 May 11:14:57 - [debug] [OpcUa-Client:ARB-25M] Action on input: write Item from Topic: ns=2;i=115682 session Id: ns=3;i=2500861593
8 May 11:14:57 - [debug] [OpcUa-Client:ARB-25M] { /*BrowsePath*/
 startingNode                  /*  NodeId                                    */: ns=2;i=115682
 relativePath                  /*  RelativePath                              */: {
   elements                    /*  RelativePathElement                   []  */: [
     { /* 0 - RelativePathElement*/
       referenceTypeId         /*  NodeId                                    */: Aggregates (ns=0;i=44)
       isInverse               /*  Boolean                                   */: false
       includeSubtypes         /*  Boolean                                   */: true
       targetName              /*  QualifiedName                             */: <null>
     }
   ]
 }
};
8 May 11:14:57 - [debug] [OpcUa-Client:ARB-25M] NodeId= ns=2;i=115682 type=VariantArray
8 May 11:14:57 - [debug] [OpcUa-Client:ARB-25M] VALUE TO WRITE: {"nodeId":"ns=2;i=115682","attributeId":13,"value":{"value":{"dataType":"Variant","arrayType":"Array","value":[{"dataType":"Variant","arrayType":"Array","value":[{"dataType":"UInt16","arrayType":"Scalar","value":1},{"dataType":"UInt32","arrayType":"Scalar","value":10},{"dataType":"String","arrayType":"Scalar","value":"Order Des"},{"dataType":"String","arrayType":"Scalar","value":"Program Des"},{"dataType":"String","arrayType":"Scalar","value":"Mould Name"},{"dataType":"String","arrayType":"Scalar","value":"Material Des"},{"dataType":"String","arrayType":"Scalar","value":"07/05/2024"},{"dataType":"String","arrayType":"Scalar","value":"Item"},{"dataType":"String","arrayType":"Scalar","value":"Item Description"}]},{"dataType":"Variant","arrayType":"Array","value":[{"dataType":"UInt16","arrayType":"Scalar","value":2},{"dataType":"UInt32","arrayType":"Scalar","value":20},{"dataType":"String","arrayType":"Scalar","value":"Order Des 2"},{"dataType":"String","arrayType":"Scalar","value":"Program Des 2"},{"dataType":"String","arrayType":"Scalar","value":"Mould Name 2"},{"dataType":"String","arrayType":"Scalar","value":"Material Des 2"},{"dataType":"String","arrayType":"Scalar","value":"07/05/2024"},{"dataType":"String","arrayType":"Scalar","value":"Item2"},{"dataType":"String","arrayType":"Scalar","value":"Item Description 2"}]}]},"statusCode":{"value":0},"sourcePicoseconds":0,"serverPicoseconds":0}}
8 May 11:14:57 - [debug] [OpcUa-Client:ARB-25M] Client status: writing
8 May 11:14:57 - [debug] [OpcUa-Client:ARB-25M] Client status: value written
8 May 11:14:57 - [debug] [OpcUa-Client:ARB-25M] Value written! Result:2155085824 The value supplied for the attribute is not of the same type as the attribute's value.
ARB-25M: StatusCode: BadTypeMismatch (0x80740000) The value supplied for the attribute is not of the same type as the attribute's value.
8 May 11:14:57 - [warn] [OpcUa-Client:ARB-25M] StatusCode: BadTypeMismatch (0x80740000) The value supplied for the attribute is not of the same type as the attribute's value.
8 May 11:14:57 - [debug] [OpcUa-Client:ARB-25M] Client status: error

But from Wireshark still showing a partial empty write request:

image

IW3IJQ commented 1 month ago

This PR is outdated by #696