Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscribing to complex datatypes #1334

Closed
MSasurinen opened this issue Aug 24, 2021 · 13 comments
Closed

Subscribing to complex datatypes #1334

MSasurinen opened this issue Aug 24, 2021 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@MSasurinen
Copy link

MSasurinen commented Aug 24, 2021

Currently, the OPC publisher IoT edge module is a great tool for simple data like a sensor value here and there. But if you try to subscribe to a complex data type such as a custom struct, the messages coming from the module are a mixture of json and uadb (or plain uadb depending on the cmd-line arguments). An example of such a message, containing two nodes, one bool, and one custom struct:

[
  {
    "NodeId": "urn:BeckhoffAutomation:Ua:PLC1#s=.gstSecLoadings.arstSecLd%5b1%5d.bLoadingReady",
    "ApplicationUri": "urn:BeckhoffAutomation:TcOpcUaServer",
    "DisplayName": "LoadingReady",
    "Value": {
      "Value": false,
      "SourceTimestamp": "2021-08-25T05:27:25.549262Z"
    }
  },
  {
    "NodeId": "urn:BeckhoffAutomation:Ua:PLC1#s=arrstTest%5b1%5d",
    "ApplicationUri": "urn:BeckhoffAutomation:TcOpcUaServer",
    "DisplayName": "arrstTest",
    "Value": {
      "Value": {
        "TypeId": "urn:BeckhoffAutomation:Ua:PLC1#s=%3cStructuredDataType%3e%3arrstTest_DefaultBinary",
        "Body": "BgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAe0VIFJjXASwAAABUaW1lb3V0IHdoZW4gd2FpdGluZyBjb25maWd1cmF0aW9uIGZyb20gQ09OTgAAAAACAAAAAQAAAACRAAA="
      },
      "SourceTimestamp": "2021-08-25T05:27:25.549262Z"
    }
  }
]

I am using version 2.7 in a standalone configuration. And the cmdl arguments go as follows:

  "Hostname": "OPCPublisher",
  "Cmd": [
    "--pf=/mount/pn.json",
    "--bs=2",
    "--aa",
    "--mm PubSub",
    "--me=Json"

Is there a way to decode the body of the second node in the cloud or in another iot edge module?
If not, could this be a feature? I'm thinking something on the lines of adding the reading of the DatatypeDictionary from the server at startup, which would bring the information of the DataTypes to the Publisher, and then while configuring the nodes the developer could set the type of the node in the pn.json file.

To reproduce the example message above:

  • Define the message encoding to json via the command-line arguments for the module
  • Create a struct-type variable at a PLC
  • Publish it at an OPC ua Server
  • Subscribe to it
  • Cause a change on it

Hope this is the right way to ask/suggest this kind of thing.
Br,
Markus

@koepalex
Copy link
Contributor

@Mkasakka which version of OPC Publisher are you using? Do you use it standalone (which I expect) or as part of Industrial IoT Platform?

Please try to use --mm PubSub and also paste the output

@MSasurinen
Copy link
Author

Hi, yes you are correct I am using the Publisher in standalone mode. The current version is 2.7 and the output in the initial post is now with the message mode "PubSub".

@koepalex
Copy link
Contributor

I've tested the OPC Publisher in standalone version 2.8.0 with the complexe data type of iot-edge-opc-plc (with --ctb) and the complexe data type is working:

{
      "MessageId": "379",
      "MessageType": "ua-data",
      "PublisherId": "opc.tcp://localhost:50000_39d40f4aae5f07696bc0737f6ba45a4d4bd63d79",
      "DataSetWriterGroup": "opc.tcp://localhost:50000_39d40f4aae5f07696bc0737f6ba45a4d4bd63d79",
      "Messages": [
        {
          "DataSetWriterId": "opc.tcp://localhost:50000_ad96df769e92a48dd17e03373f81ee07296dbfc4",
          "MetaDataVersion": {
            "MajorVersion": 1,
            "MinorVersion": 0
          },
          "Payload": {
            "http://microsoft.com/Opc/OpcPlc/Boiler#i=15013": {
              "Value": {
                "Temperature": {
                  "Top": 3360,
                  "Bottom": 3365
                },
                "Pressure": 103365,
                "HeaterState": "On_1"
              },
              "SourceTimestamp": "2021-08-25T09:14:05.416079Z"
            }
          }
        }
      ]
    }

So it could be that the OPC UA stack (complexe data type) can't decode your custom type. Would it be possible that you provide an public available endpoint of the OPC UA server, that we can connect and check the data type definitions?

@MSasurinen
Copy link
Author

MSasurinen commented Aug 25, 2021

Hi, sadly I can not provide access to the server. Maybe these help? The first is the description of the node that I try to subscribe to (the above output is was for a test node, the same problem though). And the second one is the definition of ST_Mess_Latest. If there is a problem with encoding custom data types, how would one address it?
image
image

@koepalex
Copy link
Contributor

@mregen is this information sufficient or do we require something else?

@mregen
Copy link
Contributor

mregen commented Aug 25, 2021

Hi @Mkasakka, what you get in the Body of the JSON message is the binary encoding of the structure.
Looks like the complex type decoder cannot specifically handle this Array of structures in a structure of complex type.
Please help by getting me the description of the DataTypeDefinition from the server for the missing type.
As a sample here is the BoilerType we used above:

Find the DataType in Types/DataTypes/Structure, e.g. like here:

image

then if possible, expand all fields of the DataTypeDefinition:

image

and copy the content. Then we can try to repro the case here and see why we cannot decode it.

@MSasurinen
Copy link
Author

Hi, sure thing!
Here is the structure of which the array is composed.
image

@mregen
Copy link
Contributor

mregen commented Sep 2, 2021

Hi @Mkasakka , based on the screenshot I cannot root cause the issue. By any chance, could you provide the Nodeset2 or other model files? Is this a custom model or companion spec?
As its a nested data structure its hard to tell for me where the code fails here.

@MSasurinen
Copy link
Author

Sure anything you need! As I understand it is a custom model, can you elaborate on what file you need?

@mregen
Copy link
Contributor

mregen commented Sep 21, 2021

Hi @Mkasakka , there might be files with extension *.nodeset2.xml in your plc project. Some are used for companion specs and are included by others, very likely there are some files which describe e.g. ST_MESSAGE_INFO.

@MSasurinen
Copy link
Author

Hi, sorry to say this but I do not find any files with that suffix. Could it have something to do with the fact that I am using the Opc ua server from Beckhoff?

@hansgschossmann
Copy link
Contributor

Hi @Mkasakka the *.nodeset2.xml file does describe the OPC UA namespace of the server. I am not familiar with the Beckhoff modeling tool. Can you check with the Beckhoff documentation (or the people who have configured the OPC UA servers address space) what would be the equivilant to the nodeset2.xml file?

@marcschier marcschier closed this as not planned Won't fix, can't repro, duplicate, stale Nov 24, 2022
@marcschier
Copy link
Collaborator

Close stale issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants