Connectivity Software User's Guide and Reference
SparkplugSystemDescriptor Class
Members  Example 



OpcLabs.EasySparkplug Assembly > OpcLabs.EasySparkplug Namespace : SparkplugSystemDescriptor Class
Descriptor for a Sparkplug system.
Object Model
SparkplugSystemDescriptor ClassSparkplugConnectionDescriptor ClassSparkplugSystemDescriptor Class
Syntax
'Declaration
 
<ExceptionContractAnnotationAttribute(True)>
<CLSCompliantAttribute(True)>
<TypeConverterAttribute(System.ComponentModel.ExpandableObjectConverter)>
<ValueControlAttribute("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.83.473.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   DefaultReadWrite=False, 
   Export=True, 
   PageId=10001)>
<SerializableAttribute()>
Public Class SparkplugSystemDescriptor 
   Inherits OpcLabs.BaseLib.Info
   Implements LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable 
'Usage
 
Dim instance As SparkplugSystemDescriptor
[ExceptionContractAnnotation(true)]
[CLSCompliant(true)]
[TypeConverter(System.ComponentModel.ExpandableObjectConverter)]
[ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.83.473.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   DefaultReadWrite=false, 
   Export=true, 
   PageId=10001)]
[Serializable()]
public class SparkplugSystemDescriptor : OpcLabs.BaseLib.Info, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable  
[ExceptionContractAnnotation(true)]
[CLSCompliant(true)]
[TypeConverter(System.ComponentModel.ExpandableObjectConverter)]
[ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.83.473.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   DefaultReadWrite=false, 
   Export=true, 
   PageId=10001)]
[Serializable()]
public ref class SparkplugSystemDescriptor : public OpcLabs.BaseLib.Info, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable  
Remarks

Sparkplug system descriptor is used both with the Sparkplug consumer model (EasySparkplugConsumerCore) and with the Sparkplug provider model ().

Sparkplug system is a set of interconnected Sparkplug components (i.e. a Sparkplug broker, and Sparkplug edge nodes and Sparkplug host applications), which uses a common variant of Sparkplug protocol for the communication (i.e. the same or compatible Sparkplug version).

The Sparkplug system descriptor uses either the Sparkplug connection descriptor, or a Sparkplug system ID, or both, to specify the Sparkplug system to connect to. The OpcLabs.EasySparkplug.System.EasySparkplugInfrastructure component keeps track of and maintains the set of Sparkplug systems in use.

In most concrete practical scenarios, you will use the Sparkplug connection descriptor (ConnectionDescriptor property) to identify the Sparkplug system, and the Sparkplug system ID (SystemId property) will be empty. The Sparkplug system ID is useful when a Sparkplug system reference needs to be distinguished from others and possibly persisted, but its actual connection data might change over time.

 

Sparkplug is a trademark of Eclipse Foundation, Inc. "MQTT" is a trademark of the OASIS Open standards consortium. Other related terms are trademarks of their respective owners. Any use of these terms on this site is for descriptive purposes only and does not imply any sponsorship, endorsement or affiliation.

Example
// This example shows different ways of constructing the EasySparkplugEdgeNode object.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
// Sparkplug examples in C# on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using OpcLabs.EasySparkplug;

namespace SparkplugDocExamples.EdgeNode._EasySparkplugEdgeNode
{
    class Construction
    {
        static public void Main1()
        {
            // The toolkit provides a ready-made shared instance of the edge node object which you can use without even
            // having to construct it. Not recommended for use in library code, because it is a shared instance, and its
            // usage may therefore conflict with other code using the same instance.
            var edgeNode0 = EasySparkplugEdgeNode.SharedInstance;

            
            // The simplest way to construct the edge node object is to use the default constructor. The edge node will
            // connect to the default broker URL "mqtt://localhost". Group ID is "easyGroup", edge node ID and primary host
            // ID will be auto-generated.
            var edgeNode1 = new EasySparkplugEdgeNode();


            // The edge node object can be constructed with a specific broker URL string passed as an argument to the
            // constructor. This relies on the implicit conversion from string to SparkplugBrokerDescriptor.
            var edgeNode2 = new EasySparkplugEdgeNode("mqtt://localhost:1883");


            // The broker URL can also be specified using the Uri object.
            var edgeNode3 = new EasySparkplugEdgeNode(new Uri("mqtt://localhost:1883"));


            // You can construct the edge node object with a specific broker descriptor, which allows you to set all its
            // parameters;
            var edgeNode4 = new EasySparkplugEdgeNode(
                new SparkplugBrokerDescriptor
                {
                    Host = "localhost",
                    Password = "password",
                    Port = 1883,
                    UserName = "admin",
                });


            // The sparkplug group ID and edge node ID can be specified as additional arguments to the constructor.
            var edgeNode5 = new EasySparkplugEdgeNode("mqtt://localhost:1883", "myGroup", "myEdgeNode");


            // The primary host ID of the application can also be specified, using a different constructor overload (when
            // not specified, i.e. left empty, the component will not use the primary host application logic).
            var edgeNode6 = new EasySparkplugEdgeNode("mqtt://localhost:1883", "myPrimaryHost", "myGroup", "myEdgeNode");


            // You do not have to specify everything in the constructor. The basic properties can be set later - but before
            // the edge node is started.
            var edgeNode7 = new EasySparkplugEdgeNode();
            edgeNode7.SystemDescriptor = new SparkplugSystemDescriptor("mqtt://localhost:1883");
            edgeNode7.GroupId = "myGroup";
            edgeNode7.EdgeNodeId = "myEdgeNode";


            // If the language supports property initializers (such as C# or VB.NET), the above code can be written more
            // concisely.
            var edgeNode8 = new EasySparkplugEdgeNode
            {
                GroupId = "myGroup",
                EdgeNodeId = "myEdgeNode",
                SystemDescriptor = new SparkplugSystemDescriptor("mqtt://localhost:1883"),
            };


            // For more advanced scenarios, a SparkplugSystemDescriptor can be passed to the constructor instead of the 
            // SparkplugBrokerDescriptor. In the example below, this allows you to specify the Sparkplug version.
            var edgeNode9 = new EasySparkplugEdgeNode(
                new SparkplugSystemDescriptor("mqtt://localhost:1883", SparkplugVersions.PayloadA), 
                "myPrimaryHost", 
                "myGroup", 
                "myEdgeNode");


            // If the language supports collection initializers (such as C# or VB.NET), the edge node object can be
            // constructed with its metrics (the contents of the Metrics collection), in a single statement.
            var edgeNode10 = new EasySparkplugEdgeNode("myPrimaryHost", "myGroup", "myEdgeNode")
            {
                new SparkplugMetric("Constant1").ConstantValue(42),
                new SparkplugMetric("Constant2").ConstantValue("abc")
            };
        }
    }
}
' This example shows different ways of constructing the EasySparkplugEdgeNode object.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
' Sparkplug examples in C# on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-CSharp .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports OpcLabs.EasySparkplug

Namespace Global.SparkplugDocExamples.EdgeNode._EasySparkplugEdgeNode
    Class Construction
        Public Shared Sub Main1()
            ' The toolkit provides a ready-made shared instance of the edge node object which you can use without even
            ' having to construct it. Not recommended for use in library code, because it is a shared instance, and its
            ' usage may therefore conflict with other code using the same instance.
            Dim edgeNode0 = EasySparkplugEdgeNode.SharedInstance


            ' The simplest way to construct the edge node object is to use the default constructor. The edge node will
            ' connect to the default broker URL "mqtt://localhost". Group ID is "easyGroup", edge node ID and primary host
            ' ID will be auto-generated.
            Dim edgeNode1 = New EasySparkplugEdgeNode()


            ' The edge node object can be constructed with a specific broker URL string passed as an argument to the
            ' constructor. This relies on the implicit conversion from string to SparkplugBrokerDescriptor.
            Dim edgeNode2 = New EasySparkplugEdgeNode("mqtt://localhost:1883")


            ' The broker URL can also be specified using the Uri object.
            Dim edgeNode3 = New EasySparkplugEdgeNode(New Uri("mqtt://localhost:1883"))


            ' You can construct the edge node object with a specific broker descriptor, which allows you to set all its
            ' parameters;
            Dim edgeNode4 = New EasySparkplugEdgeNode(
                New SparkplugBrokerDescriptor With
                {
                    .Host = "localhost",
                    .Password = "password",
                    .Port = 1883,
                    .UserName = "admin"
                })


            ' The sparkplug group ID and edge node ID can be specified as additional arguments to the constructor.
            Dim edgeNode5 = New EasySparkplugEdgeNode("mqtt://localhost:1883", "myGroup", "myEdgeNode")


            ' The primary host ID of the application can also be specified, using a different constructor overload (when
            ' not specified, i.e. left empty, the component will not use the primary host application logic).
            Dim edgeNode6 = New EasySparkplugEdgeNode("mqtt://localhost:1883", "myPrimaryHost", "myGroup", "myEdgeNode")


            ' You do not have to specify everything in the constructor. The basic properties can be set later - but before
            ' the edge node is started.
            Dim edgeNode7 = New EasySparkplugEdgeNode()
            edgeNode7.SystemDescriptor = New SparkplugSystemDescriptor("mqtt://localhost:1883")
            edgeNode7.GroupId = "myGroup"
            edgeNode7.EdgeNodeId = "myEdgeNode"


            ' If the language supports property initializers (such as C# or VB.NET), the above code can be written more
            ' concisely.
            Dim edgeNode8 = New EasySparkplugEdgeNode With
            {
                .GroupId = "myGroup",
                .EdgeNodeId = "myEdgeNode",
                .SystemDescriptor = New SparkplugSystemDescriptor("mqtt://localhost:1883")
            }


            ' For more advanced scenarios, a SparkplugSystemDescriptor can be passed to the constructor instead of the 
            ' SparkplugBrokerDescriptor. In the example below, this allows you to specify the Sparkplug version.
            Dim edgeNode9 = New EasySparkplugEdgeNode(
                New SparkplugSystemDescriptor("mqtt://localhost:1883", SparkplugVersions.PayloadA),
                "myPrimaryHost",
                "myGroup",
                "myEdgeNode")


            ' If the language supports collection initializers (such as C# or VB.NET), the edge node object can be
            ' constructed with its metrics (the contents of the Metrics collection), in a single statement.
            Dim edgeNode10 = New EasySparkplugEdgeNode("myPrimaryHost", "myGroup", "myEdgeNode") From
            {
                New SparkplugMetric("Constant1").ConstantValue(42),
                New SparkplugMetric("Constant2").ConstantValue("abc")
            }
        End Sub
    End Class
End Namespace
Inheritance Hierarchy

System.Object
   OpcLabs.BaseLib.Object2
      OpcLabs.BaseLib.Info
         OpcLabs.EasySparkplug.SparkplugSystemDescriptor
            OpcLabs.EasySparkplug.SparkplugHostDescriptor

Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also