Skip to content

Commit fb9b68f

Browse files
committed
Smaller changes.
1 parent f9593b5 commit fb9b68f

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

src/SparkplugNet.Examples/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,6 @@ private static async Task RunVersionBNode()
383383
Log.Information("Node started...");
384384

385385
// Publish node metrics.
386-
387-
VersionBMetricsNode[0].Name = "";
388386
await node.PublishMetrics(VersionBMetricsNode);
389387

390388
// Get the known node metrics from a node.

src/SparkplugNet/VersionB/Data/Metric.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public Metric(string name, VersionBDataTypeEnum dataType, object? value, DateTim
9393
public MetaData? MetaData { get; set; }
9494

9595
/// <summary>
96-
/// Gets or sets the Properties field.
96+
/// Gets or sets the properties.
9797
/// </summary>
9898
public PropertySet? Properties { get; set; }
9999

src/SparkplugNet/VersionB/PayloadConverter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ public static Metric ConvertVersionBMetric(VersionBProtoBuf.ProtoBufPayload.Metr
191191
/// Gets the version B ProtoBuf metric from the version B metric.
192192
/// </summary>
193193
/// <param name="metric">The <see cref="Metric"/>.</param>
194+
/// <exception cref="ArgumentException">Thrown if the property set data type is set for a metric.</exception>
194195
/// <exception cref="ArgumentOutOfRangeException">Thrown if the metric data type is unknown.</exception>
195196
/// <returns>The <see cref="VersionBProtoBuf.ProtoBufPayload.Metric"/>.</returns>
196197
public static VersionBProtoBuf.ProtoBufPayload.Metric ConvertVersionBMetric(Metric metric)
@@ -205,7 +206,7 @@ public static VersionBProtoBuf.ProtoBufPayload.Metric ConvertVersionBMetric(Metr
205206
MetaData = ConvertVersionBMetaData(metric.MetaData),
206207
Name = metric.Name,
207208
Timestamp = metric.Timestamp,
208-
PropertySetValue = !(metric.Properties is null) ? ConvertVersionBPropertySet(metric.Properties.ConvertOrDefaultTo<PropertySet>()) : null
209+
PropertySetValue = metric.Properties is not null ? ConvertVersionBPropertySet(metric.Properties.ConvertOrDefaultTo<PropertySet>()) : null
209210
};
210211

211212
switch (metric.DataType)
@@ -267,9 +268,8 @@ public static VersionBProtoBuf.ProtoBufPayload.Metric ConvertVersionBMetric(Metr
267268
case VersionBDataTypeEnum.Template:
268269
protoMetric.TemplateValue = ConvertVersionBTemplate(metric.Value.ConvertOrDefaultTo<Template>());
269270
break;
270-
//case VersionBDataTypeEnum.PropertySet:
271-
// protoMetric.PropertySetValue = ConvertVersionBPropertySet(metric.Value.ConvertOrDefaultTo<PropertySet>());
272-
// break;
271+
case VersionBDataTypeEnum.PropertySet:
272+
throw new ArgumentException("The property set data type is not valid for a metric");
273273
case VersionBDataTypeEnum.Int8Array:
274274
protoMetric.BytesValue = (byte[]?)metric.Value ?? [];
275275
break;

0 commit comments

Comments
 (0)