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
| Overload | Description |
| WriteFunction(SparkplugMetric,Type,Func<SparkplugData,Boolean>) | Makes a metric that consumes the Sparkplug data using the write function. Specify the value type. |
| WriteFunction(SparkplugMetric,TypeCode,Func<SparkplugData,Boolean>) | Makes a metric that consumes the Sparkplug data using the write function. Specify the value type code. |
| WriteFunction(SparkplugMetric,SparkplugDataType,Func<SparkplugData,Boolean>) | Makes a metric that consumes the Sparkplug data using the write function. Specify the Sparkplug data type. |
| WriteFunction<TValue>(SparkplugMetric,Func<SparkplugData<TValue>,Boolean>) | Makes a metric that consumes the Sparkplug data using the write function. |
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