diff --git a/src/SparkplugNet/VersionB/SparkplugApplication.cs b/src/SparkplugNet/VersionB/SparkplugApplication.cs index 76f896b..f4f6d8e 100644 --- a/src/SparkplugNet/VersionB/SparkplugApplication.cs +++ b/src/SparkplugNet/VersionB/SparkplugApplication.cs @@ -149,12 +149,12 @@ private async Task HandleMessagesForVersionB(SparkplugMessageTopic topic, Payloa { // Filter out session number metric. var sessionNumberMetric = payload.Metrics.FirstOrDefault(m => m.Name == Constants.SessionNumberMetricName); - var metricsWithoutSequenceMetric = payload.Metrics.Where(m => m.Name != Constants.SessionNumberMetricName); - var filteredMetrics = this.KnownMetricsStorage.FilterMetrics(metricsWithoutSequenceMetric, topic.MessageType).ToList(); + var metrics = payload.Metrics.Where(m => m.Name != Constants.SessionNumberMetricName).ToList(); + // var filteredMetrics = this.KnownMetricsStorage.FilterMetrics(metricsWithoutSequenceMetric, topic.MessageType).ToList(); if (sessionNumberMetric is not null) { - filteredMetrics.Add(sessionNumberMetric); + metrics.Add(sessionNumberMetric); } // Handle messages. @@ -162,19 +162,19 @@ private async Task HandleMessagesForVersionB(SparkplugMessageTopic topic, Payloa { case SparkplugMessageType.NodeBirth: await this.FireNodeBirthReceived(topic.GroupIdentifier, topic.EdgeNodeIdentifier, - this.ProcessPayload(topic, filteredMetrics, SparkplugMetricStatus.Online)); + this.ProcessPayload(topic, metrics, SparkplugMetricStatus.Online)); break; case SparkplugMessageType.DeviceBirth: if (string.IsNullOrWhiteSpace(topic.DeviceIdentifier)) { throw new InvalidOperationException($"The device identifier is invalid!"); } - + await this.FireDeviceBirthReceived(topic.GroupIdentifier, topic.EdgeNodeIdentifier, topic.DeviceIdentifier, - this.ProcessPayload(topic, filteredMetrics, SparkplugMetricStatus.Online)); + this.ProcessPayload(topic, metrics, SparkplugMetricStatus.Online)); break; case SparkplugMessageType.NodeData: - var nodeDataMetrics = this.ProcessPayload(topic, filteredMetrics, SparkplugMetricStatus.Online); + var nodeDataMetrics = this.ProcessPayload(topic, metrics, SparkplugMetricStatus.Online); await this.FireNodeDataReceived(topic.GroupIdentifier, topic.EdgeNodeIdentifier, nodeDataMetrics); break; case SparkplugMessageType.DeviceData: @@ -183,20 +183,20 @@ await this.FireDeviceBirthReceived(topic.GroupIdentifier, topic.EdgeNodeIdentifi throw new InvalidOperationException($"Topic {topic} is invalid!"); } - var deviceDataMetrics = this.ProcessPayload(topic, filteredMetrics, SparkplugMetricStatus.Online); + var deviceDataMetrics = this.ProcessPayload(topic, metrics, SparkplugMetricStatus.Online); await this.FireDeviceDataReceived(topic.GroupIdentifier, topic.EdgeNodeIdentifier, topic.DeviceIdentifier, deviceDataMetrics); break; case SparkplugMessageType.NodeDeath: - this.ProcessPayload(topic, filteredMetrics, SparkplugMetricStatus.Offline); + this.ProcessPayload(topic, metrics, SparkplugMetricStatus.Offline); await this.FireNodeDeathReceived(topic.GroupIdentifier, topic.EdgeNodeIdentifier, sessionNumberMetric); - break; + break; case SparkplugMessageType.DeviceDeath: if (string.IsNullOrWhiteSpace(topic.DeviceIdentifier)) { throw new InvalidOperationException($"Topic {topic} is invalid!"); } - this.ProcessPayload(topic, filteredMetrics, SparkplugMetricStatus.Offline); + this.ProcessPayload(topic, metrics, SparkplugMetricStatus.Offline); await this.FireDeviceDeathReceived(topic.GroupIdentifier, topic.EdgeNodeIdentifier, topic.DeviceIdentifier); break; } diff --git a/src/SparkplugNet/VersionB/SparkplugNode.cs b/src/SparkplugNet/VersionB/SparkplugNode.cs index 58ed39f..3ad52cb 100644 --- a/src/SparkplugNet/VersionB/SparkplugNode.cs +++ b/src/SparkplugNet/VersionB/SparkplugNode.cs @@ -114,12 +114,12 @@ private async Task HandleMessagesForVersionB(SparkplugMessageTopic topic, Payloa { // Filter out session number metric. var sessionNumberMetric = payload.Metrics.FirstOrDefault(m => m.Name == Constants.SessionNumberMetricName); - var metricsWithoutSequenceMetric = payload.Metrics.Where(m => m.Name != Constants.SessionNumberMetricName); - var filteredMetrics = this.KnownMetricsStorage.FilterMetrics(metricsWithoutSequenceMetric, topic.MessageType).ToList(); + var metrics = payload.Metrics.Where(m => m.Name != Constants.SessionNumberMetricName).ToList(); + // var filteredMetrics = this.KnownMetricsStorage.FilterMetrics(metricsWithoutSequenceMetric, topic.MessageType).ToList(); if (sessionNumberMetric is not null) { - filteredMetrics.Add(sessionNumberMetric); + metrics.Add(sessionNumberMetric); } // Handle messages. @@ -131,11 +131,11 @@ private async Task HandleMessagesForVersionB(SparkplugMessageTopic topic, Payloa throw new InvalidOperationException($"Topic {topic} is invalid!"); } - await this.FireDeviceCommandReceived(topic.DeviceIdentifier, filteredMetrics); + await this.FireDeviceCommandReceived(topic.DeviceIdentifier, metrics); break; case SparkplugMessageType.NodeCommand: - await this.FireNodeCommandReceived(filteredMetrics); + await this.FireNodeCommandReceived(metrics); break; } }