Connectivity Software User's Guide and Reference
SparkplugDataType Enumeration
Example Example 



OpcLabs.EasySparkplug Assembly > OpcLabs.EasySparkplug Namespace : SparkplugDataType Enumeration
Data types used in Sparkplug payloads.
Syntax
'Declaration
 
<DisplayName2Attribute("Sparkplug Data Type")>
Public Enum SparkplugDataType 
   Inherits System.Enum
   Implements System.IComparable, System.IConvertible, System.IFormattable 
'Usage
 
Dim instance As SparkplugDataType
[DisplayName2("Sparkplug Data Type")]
public enum SparkplugDataType : System.Enum, System.IComparable, System.IConvertible, System.IFormattable  
[DisplayName2("Sparkplug Data Type")]
public enum class SparkplugDataType : public System.Enum, System.IComparable, System.IConvertible, System.IFormattable  
Members
MemberValueDescription
Boolean11Boolean value. A basic type.

Google Protocol Buffer Type: bool.

This data type is available since Sparkplug A (in so-called Kura Metric).

The value of this enum member is 11.

BooleanArray32BooleanArray as an array of bit-packed bytes preceded by a 4-byte integer that represents the total number of boolean values. An array type.

Google Protocol Buffer Type: bytes.

All array types use the bytes_value field of the Metric value field. They are simply little-endian packed byte arrays.

This data type is not available in Sparkplug A.

The value of this enum member is 32.

Bytes17Array of bytes. An additional metric type.

Google Protocol Buffer Type: bytes.

This data type is available since Sparkplug A (in so-called Kura Metric).

The value of this enum member is 17.

DataSet16A DataSet object used to encode matrices of data. An additional metric type.

Google Protocol Buffer Type: none – defined in Sparkplug.

This data type is not available in Sparkplug A.

The value of this enum member is 16.

DateTime13Date time value as uint64 value representing milliseconds since epoch (Jan 1, 1970). A basic type.

Google Protocol Buffer Type: uint64.

This data type is not available in Sparkplug A.

The value of this enum member is 13.

DateTimeArray34DateTimeArray as an array of packed little endian bytes where each Datetime value is an 8-byte value representing the number of milliseconds since epoch in UTC. An array type.

Google Protocol Buffer Type: bytes.

All array types use the bytes_value field of the Metric value field. They are simply little-endian packed byte arrays.

This data type is not available in Sparkplug A.

The value of this enum member is 34.

Double1064-bit floating point number. A basic type.

Google Protocol Buffer Type: double.

This data type is available since Sparkplug A (in so-called Kura Metric).

The value of this enum member is 10.

DoubleArray31DoubleArray as an array of packed little endian 64-bit float bytes. An array type.

Google Protocol Buffer Type: bytes.

All array types use the bytes_value field of the Metric value field. They are simply little-endian packed byte arrays.

This data type is not available in Sparkplug A.

The value of this enum member is 31.

File18Array of bytes representing a file. An additional metric type.

Google Protocol Buffer Type: bytes.

This data type is not available in Sparkplug A.

The value of this enum member is 18.

Float932-bit floating point number. A basic type.

Google Protocol Buffer Type: float.

This data type is available since Sparkplug A (in so-called Kura Metric).

The value of this enum member is 9.

FloatArray30FloatArray as an array of packed little endian 32-bit float bytes. An array type.

Google Protocol Buffer Type: bytes.

All array types use the bytes_value field of the Metric value field. They are simply little-endian packed byte arrays.

This data type is not available in Sparkplug A.

The value of this enum member is 30.

Int162Signed 16-bit integer. A basic type.

Google Protocol Buffer Type: uint32.

This data type is not available in Sparkplug A.

The value of this enum member is 2.

Int16Array23Int16Array as an array of packed little endian int16 bytes. An array type.

Google Protocol Buffer Type: bytes.

All array types use the bytes_value field of the Metric value field. They are simply little-endian packed byte arrays.

This data type is not available in Sparkplug A.

The value of this enum member is 23.

Int323Signed 32-bit integer. A basic type.

Google Protocol Buffer Type: uint32.

This data type is available since Sparkplug A (in so-called Kura Metric).

The value of this enum member is 3.

Int32Array24Int32Array as an array of packed little endian int32 bytes. An array type.

Google Protocol Buffer Type: bytes.

All array types use the bytes_value field of the Metric value field. They are simply little-endian packed byte arrays.

This data type is not available in Sparkplug A.

The value of this enum member is 24.

Int644Signed 64-bit integer. A basic type.

Google Protocol Buffer Type: uint64.

This data type is available since Sparkplug A (in so-called Kura Metric).

The value of this enum member is 4.

Int64Array25Int64Array as an array of packed little endian int64 bytes. An array type.

Google Protocol Buffer Type: bytes.

All array types use the bytes_value field of the Metric value field. They are simply little-endian packed byte arrays.

This data type is not available in Sparkplug A.

The value of this enum member is 25.

Int81Signed 8-bit integer. A basic type.

Google Protocol Buffer Type: uint32.

This data type is not available in Sparkplug A.

The value of this enum member is 1.

Int8Array22Int8 Array as an array of packed little endian int8 bytes. An array type.

Google Protocol Buffer Type: bytes.

All array types use the bytes_value field of the Metric value field. They are simply little-endian packed byte arrays.

This data type is not available in Sparkplug A.

The value of this enum member is 22.

PropertySet20PropertySet object used with a metric to add custom properties to the object. This is an additional PropertyValue type.

The PropertySet is a map expressed as two arrays of equal size, one containing the keys and one containing the values. It includes the following components.

  • This is an array of UTF-8 strings representing the names of the properties in this PropertySet.
  • This is an array of PropertyValue objects representing the values of the properties in the PropertySet.

Google Protocol Buffer Type: none – defined in Sparkplug.

This data type is not available in Sparkplug A.

The value of this enum member is 20.

PropertySetList21PropertySetList object, an array of PropertySet objects. This is an additional PropertyValue type.

Google Protocol Buffer Type: none – defined in Sparkplug.

This data type is not available in Sparkplug A.

The value of this enum member is 21.

String12String value (UTF-8). A basic type.

Google Protocol Buffer Type: string.

Physically, String and Text are the same. If you do not specify the data type explicitly, String is chosen for string values. For strings that need to be represented as Sparkplug Text, specify the Text data type explicitly.

This data type is available since Sparkplug A (in so-called Kura Metric).

The value of this enum member is 12.

StringArray33StringArray as an array of null terminated strings. An array type.

Google Protocol Buffer Type: bytes.

All array types use the bytes_value field of the Metric value field. They are simply little-endian packed byte arrays.

This data type is not available in Sparkplug A.

The value of this enum member is 33.

Template19A Template, used for encoding complex datatypes in a payload. An additional metric type.

Google Protocol Buffer Type: none – defined in Sparkplug.

Template is a type of metric and can be used to create custom datatype definitions and instances. These are also sometimes referred to as User Defined Types or UDTs. There are two types of Templates.

  • This is the definition of a Sparkplug Template.
  • This is an instance of a Sparkplug Template

This data type is not available in Sparkplug A.

The value of this enum member is 19.

Text14String value (UTF-8). A basic type.

Google Protocol Buffer Type: string.

Physically, String and Text are the same. If you do not specify the data type explicitly, String is chosen for string values. For strings that need to be represented as Sparkplug Text, specify the Text data type explicitly.

This data type is not available in Sparkplug A.

The value of this enum member is 14.

UInt166Unsigned 16-bit integer. A basic type.

Google Protocol Buffer Type: uint32.

This data type is not available in Sparkplug A.

The value of this enum member is 6.

UInt16Array27UInt16Array as an array of packed little endian uint16 bytes. An array type.

Google Protocol Buffer Type: bytes.

All array types use the bytes_value field of the Metric value field. They are simply little-endian packed byte arrays.

This data type is not available in Sparkplug A.

The value of this enum member is 27.

UInt327Unsigned 32-bit integer. A basic type.

Google Protocol Buffer Type: uint32.

This data type is not available in Sparkplug A.

The value of this enum member is 7.

UInt32Array28UInt32Array as an array of packed little endian uint32 bytes. An array type.

Google Protocol Buffer Type: bytes.

All array types use the bytes_value field of the Metric value field. They are simply little-endian packed byte arrays.

This data type is not available in Sparkplug A.

The value of this enum member is 28.

UInt648Unsigned 64-bit integer. A basic type.

Google Protocol Buffer Type: uint64.

This data type is not available in Sparkplug A.

The value of this enum member is 8.

UInt64Array29UInt64Array as an array of packed little endian uint64 bytes. An array type.

Google Protocol Buffer Type: bytes.

All array types use the bytes_value field of the Metric value field. They are simply little-endian packed byte arrays.

This data type is not available in Sparkplug A.

The value of this enum member is 29.

UInt85Unsigned 8-bit integer. A basic type.

Google Protocol Buffer Type: uint32.

This data type is not available in Sparkplug A.

The value of this enum member is 5.

UInt8Array26UInt8Array as an array of packed little endian uint8 bytes. An array type.

Google Protocol Buffer Type: bytes.

All array types use the bytes_value field of the Metric value field. They are simply little-endian packed byte arrays.

This data type is not available in Sparkplug A.

The value of this enum member is 26.

Unknown0Unknown placeholder for future expansion.

The value of this enum member is 0.

Uuid15UUID value as a UTF-8 string. An additional metric type.

Google Protocol Buffer Type: string.

This data type is not available in Sparkplug A.

The value of this enum member is 15.

Remarks

Sparkplug defines the valid data types used for various Sparkplug constructs including Metric datatypes, Property Value types, DataSet types, and Template Parameter types.

 

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 how to publish a command with single metric for a given device, specifying the data type.
//
// In order to publish or observe messages for this example, start the SparkplugEdgeNodeConsoleDemo program first.
//
// 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;
using OpcLabs.EasySparkplug.OperationModel;

namespace SparkplugDocExamples.Consumer._EasySparkplugConsumer
{
    partial class PublishDeviceMetric
    {
        public static void DataType()
        {
            // Note that the default port for the "mqtt" scheme is 1883.
            var hostDescriptor = new SparkplugHostDescriptor("mqtt://localhost");

            // Instantiate the consumer object.
            var consumer = new EasySparkplugConsumer();

            Console.WriteLine("Publishing...");
            try
            {
                // Create the command metric data, specifying the value and data type.
                // Note that without the explicitly specified data type, SparkplugDataType.String would be used here.
                var metricData = new SparkplugMetricData("abc", SparkplugDataType.Text);
                
                consumer.PublishDeviceMetric(hostDescriptor,
                    "easyGroup", "easySparkplugDemo", "data", "Static/TextValue",
                    metricData);   
            }
            catch (SparkplugException sparkplugException)
            {
                Console.WriteLine($"*** Failure: {sparkplugException.GetBaseException().Message}");
                return;
            }

            Console.WriteLine("Finished.");
        }
    }
}
' This example shows how to publish a command with single metric for a given device, specifying the data type.
'
' In order to publish or observe messages for this example, start the SparkplugEdgeNodeConsoleDemo program first.
'
' 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
Imports OpcLabs.EasySparkplug.OperationModel

Namespace Global.SparkplugDocExamples.Consumer._EasySparkplugConsumer
    Partial Class PublishDeviceMetric
        Public Shared Sub DataType()
            ' Note that the default port for the "mqtt" scheme is 1883.
            Dim hostDescriptor = New SparkplugHostDescriptor("mqtt://localhost")

            ' Instantiate the consumer object.
            Dim consumer = New EasySparkplugConsumer()

            Console.WriteLine("Publishing...")
            Try
                ' Create the command metric data, specifying the value and data type.
                ' Note that without the explicitly specified data type, SparkplugDataType.String would be used here.
                Dim metricData = New SparkplugMetricData("abc", SparkplugDataType.Text)

                consumer.PublishDeviceMetric(hostDescriptor,
                    "easyGroup", "easySparkplugDemo", "data", "Static/TextValue",
                    metricData)
            Catch sparkplugException As SparkplugException
                Console.WriteLine($"*** Failure: {sparkplugException.GetBaseException().Message}")
                Return
            End Try

            Console.WriteLine("Finished.")
        End Sub
    End Class
End Namespace
Inheritance Hierarchy

System.Object
   System.ValueType
      System.Enum
         OpcLabs.EasySparkplug.SparkplugDataType

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