Connectivity Software User's Guide and Reference
WriteFunction Method (SparkplugMetricExtension)



OpcLabs.EasySparkplug Assembly > OpcLabs.EasySparkplug Namespace > SparkplugMetricExtension Class : WriteFunction Method
Modifies the metric for consuming Sparkplug data by a specified function, for the push data consumption model.

This method always makes the metric writable, including its timestamp, i.e. Sparkplug host applications will be able to modify them. If you need a different behavior, call the Writable(SparkplugMetric,Boolean) method subsequently, with desired parameter, or modify the WritableTimestamp accordingly (set it to true).

This method does not change the readability access of the metric. By default, metrics are readable. If you need a metric that is writable but non-readable, combine this method with calling Readable(SparkplugMetric,Boolean) method with the 'readable' parameter set to false.

The write function returns a boolean value that indicates the outcome of the Sparkplug write operation. The WriteFunction(SparkplugMetric,Type,Func<SparkplugData,Boolean>) method overloads are the most generic extensions methods for writing. If you only need to deal with the metric value (and not its timestamp), consider using one of the WriteValueFunction<TValue>(SparkplugMetric,Type,Func<TValue,Boolean>) or WriteValueAction<TValue>(SparkplugMetric,Type,Action<TValue>) method overloads, for shorter code and easier programming.

Overload List
OverloadDescription
Makes a metric that consumes the Sparkplug data using the write function. Specify the value type.  
Makes a metric that consumes the Sparkplug data using the write function. Specify the value type code.  
Makes a metric that consumes the Sparkplug data using the write function. Specify the Sparkplug data type.  
Makes a metric that consumes the Sparkplug data using the write function.  
Remarks

 

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.

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