eclipse-sparkplug / sparkplug

Sparkplug
Eclipse Public License 2.0
109 stars 39 forks source link

Question: How should publishers publish template metrics and is this in the spec? #526

Open aronsemle opened 3 months ago

aronsemle commented 3 months ago

What do you want to know?

Does the spec cover how metric templates should be sent over NDATA/DDATA? I couldn't find it, but maybe I missed it. There are a few options; send all metrics if any metric in the template changes, only send the changes. There are also options in how you structure the message.

Please let me know if this is in the spec, and if not, could it be included in C?


Say you have a template with two metrics temp & otherTag (example below).

This is from Ignition. NBIRTH looks like this. I removed the control metrics stuff, but you can see the first one is the instance, the second is the definition. Each contain a metrics[] of temp and otherTag.

    "timestamp": 1715964597469,
    "metrics": [
        {
            "value": {
                "version": "",
                "templateRef": "ignitionBearing",
                "isDefinition": false,
                "metrics": [
                    {
                        "value": 7,
                        "type": "Int32",
                        "name": "temp",
                        "timestamp": 1715964597469,
                        "isHistorical": false,
                        "isTransient": false,
                        "metadata": {
                            "isMultiPart": false,
                            "contentType": "",
                            "size": 0,
                            "seq": 0,
                            "fileName": "",
                            "fileType": "",
                            "md5": "",
                            "description": ""
                        },
                        "properties": {
                            "ConfiguredTagPath": {
                                "value": "[default]sparkplugout/portland/myBearing/temp",
                                "type": "String"
                            },
                            "opcItemPath": {
                                "value": "ns=1;s=[simulator]_Meta:Ramp/Ramp0",
                                "type": "String"
                            },
                            "opcServer": {
                                "value": "Ignition OPC UA Server",
                                "type": "String"
                            },
                            "valueSource": {
                                "value": "opc",
                                "type": "String"
                            }
                        }
                    },
                    {
                        "value": 7,
                        "type": "Int32",
                        "name": "otherTag",
                        "timestamp": 1715964597469,
                        "isHistorical": false,
                        "isTransient": false,
                        "metadata": {
                            "isMultiPart": false,
                            "contentType": "",
                            "size": 0,
                            "seq": 0,
                            "fileName": "",
                            "fileType": "",
                            "md5": "",
                            "description": ""
                        },
                        "properties": {
                            "ConfiguredTagPath": {
                                "value": "[default]sparkplugout/portland/myBearing/otherTag",
                                "type": "String"
                            },
                            "opcItemPath": {
                                "value": "ns=1;s=[simulator]_Meta:Ramp/Ramp0",
                                "type": "String"
                            },
                            "opcServer": {
                                "value": "Ignition OPC UA Server",
                                "type": "String"
                            },
                            "valueSource": {
                                "value": "opc",
                                "type": "String"
                            }
                        }
                    }
                ],
                "parameters": []
            },
            "type": "Template",
            "name": "myBearing",
            "timestamp": 1715964597471,
            "metadata": {
                "isMultiPart": false,
                "contentType": "",
                "size": 0,
                "seq": 0,
                "fileName": "",
                "fileType": "",
                "md5": "",
                "description": ""
            },
            "properties": {
                "ConfiguredTagPath": {
                    "value": "myBearing",
                    "type": "String"
                }
            }
        },
        {
            "value": {
                "version": "",
                "templateRef": "",
                "isDefinition": true,
                "metrics": [
                    {
                        "value": null,
                        "type": "Int32",
                        "name": "temp",
                        "timestamp": 1715964596445,
                        "metadata": {
                            "isMultiPart": false,
                            "contentType": "",
                            "size": 0,
                            "seq": 0,
                            "fileName": "",
                            "fileType": "",
                            "md5": "",
                            "description": ""
                        },
                        "properties": {
                            "opcItemPath": {
                                "value": "ns=1;s=[simulator]_Meta:Ramp/Ramp0",
                                "type": "String"
                            },
                            "opcServer": {
                                "value": "Ignition OPC UA Server",
                                "type": "String"
                            },
                            "valueSource": {
                                "value": "opc",
                                "type": "String"
                            }
                        }
                    },
                    {
                        "value": 0,
                        "type": "Int32",
                        "name": "otherTag",
                        "timestamp": 1715962110517,
                        "metadata": {
                            "isMultiPart": false,
                            "contentType": "",
                            "size": 0,
                            "seq": 0,
                            "fileName": "",
                            "fileType": "",
                            "md5": "",
                            "description": ""
                        },
                        "properties": {
                            "valueSource": {
                                "value": "memory",
                                "type": "String"
                            }
                        }
                    }
                ],
                "parameters": []
            },
            "type": "Template",
            "name": "ignitionBearing",
            "timestamp": 1715964596445,
            "metadata": {
                "isMultiPart": false,
                "contentType": "",
                "size": 0,
                "seq": 0,
                "fileName": "",
                "fileType": "",
                "md5": "c49b654a331bfb140ce800b3531f3141",
                "description": ""
            },
            "properties": {}
        }
    ],
    "seq": 0
}

When I get data changes over NDATA they look like this. I would have expected a similar structure to the instance in the NBIRTH OR for it to just send all metrics if any one metric changed. The templateRef and templateName are repeated. Both temp and otherTag are referencing the same OPC tag, so they should be in lock step although the timestamps are different.

    "timestamp": 1715964430089,
    "metrics": [
        {
            "value": {
                "version": "",
                "templateRef": "ignitionBearing",
                "isDefinition": false,
                "metrics": [
                    {
                        "value": 1,
                        "type": "Int32",
                        "name": "temp",
                        "timestamp": 1715964429088
                    }
                ],
                "parameters": []
            },
            "type": "Template",
            "name": "myBearing",
            "timestamp": 1715964429089
        },
        {
            "value": {
                "version": "",
                "templateRef": "ignitionBearing",
                "isDefinition": false,
                "metrics": [
                    {
                        "value": 1,
                        "type": "Int32",
                        "name": "otherTag",
                        "timestamp": 1715964429089
                    }
                ],
                "parameters": []
            },
            "type": "Template",
            "name": "myBearing",
            "timestamp": 1715964429089
        }
    ],
    "seq": 1
}

Is this related to a Sparkplug Listing request? If so, link the issue from https://github.com/eclipse-sparkplug/sparkplug.listings here.

No response

Version

3.0.0 (Default)

Accept EFTL Terms