From 2899547f9661ad965c589b2bbedae2e1ad99c021 Mon Sep 17 00:00:00 2001 From: Robert Lutes Date: Fri, 29 May 2020 17:12:58 -0700 Subject: [PATCH 1/4] Address issue when devices message is not list (all publish). --- .../core/ForwardHistorian/forwarder/agent.py | 21 ++++++++++++------- volttron/platform/agent/base_historian.py | 21 ++++++++++++------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/services/core/ForwardHistorian/forwarder/agent.py b/services/core/ForwardHistorian/forwarder/agent.py index 709996ad2b..ab2495fd65 100644 --- a/services/core/ForwardHistorian/forwarder/agent.py +++ b/services/core/ForwardHistorian/forwarder/agent.py @@ -219,18 +219,25 @@ def _capture_device_data(self, peer, sender, bus, topic, headers, message): if _filter in device: for point in point_list: # Only points in the point list will be added to the message payload - if point in message[0]: - msg[0][point] = message[0][point] - msg[1][point] = message[1][point] + if isinstance(message, list): + if point in message[0]: + msg[0][point] = message[0][point] + msg[1][point] = message[1][point] + else: + msg = None + if point in device: + msg = message + break + if (isinstance(msg, list) and not msg[0]) or \ + (isinstance(msg, (float, int, str)) and msg is None): + _log.debug("Topic: {} - is not in configured to be forwarded".format(topic)) + return else: msg = message except Exception as e: _log.debug("Error handling device_data_filter. {}".format(e)) msg = message - if not msg[0]: - _log.debug("Topic: {} - is not in configured to be forwarded".format(topic)) - else: - self.capture_data(peer, sender, bus, topic, headers, msg) + self.capture_data(peer, sender, bus, topic, headers, msg) def _capture_log_data(self, peer, sender, bus, topic, headers, message): self.capture_data(peer, sender, bus, topic, headers, message) diff --git a/volttron/platform/agent/base_historian.py b/volttron/platform/agent/base_historian.py index 5cba67807f..f75589ea72 100644 --- a/volttron/platform/agent/base_historian.py +++ b/volttron/platform/agent/base_historian.py @@ -853,18 +853,25 @@ def _capture_device_data(self, peer, sender, bus, topic, headers, if _filter in device: for point in point_list: # Only points in the point list will be added to the message payload - if point in message[0]: - msg[0][point] = message[0][point] - msg[1][point] = message[1][point] + if isinstance(message, list): + if point in message[0]: + msg[0][point] = message[0][point] + msg[1][point] = message[1][point] + else: + msg = None + if point in device: + msg = message + break + if (isinstance(msg, list) and not msg[0]) or \ + (isinstance(msg, (float, int, str)) and msg is None): + _log.debug("Topic: {} - is not in configured to be forwarded".format(topic)) + return else: msg = message except Exception as e: _log.debug("Error handling device_data_filter. {}".format(e)) msg = message - if not msg[0]: - _log.debug("Topic: {} - is not in configured to be stored in db".format(topic)) - else: - self._capture_data(peer, sender, bus, topic, headers, msg, device) + self._capture_data(peer, sender, bus, topic, headers, msg) def _capture_analysis_data(self, peer, sender, bus, topic, headers, message): From 02eedc3c17daf68d25516abfcebaef02e13a929a Mon Sep 17 00:00:00 2001 From: Robert Lutes Date: Fri, 29 May 2020 17:17:41 -0700 Subject: [PATCH 2/4] Add comments. --- services/core/ForwardHistorian/forwarder/agent.py | 5 ++++- volttron/platform/agent/base_historian.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/services/core/ForwardHistorian/forwarder/agent.py b/services/core/ForwardHistorian/forwarder/agent.py index ab2495fd65..1faebf22f5 100644 --- a/services/core/ForwardHistorian/forwarder/agent.py +++ b/services/core/ForwardHistorian/forwarder/agent.py @@ -218,15 +218,18 @@ def _capture_device_data(self, peer, sender, bus, topic, headers, message): # will be kept. if _filter in device: for point in point_list: - # Only points in the point list will be added to the message payload + # devices all publish if isinstance(message, list): + # Only points in the point list will be added to the message payload if point in message[0]: msg[0][point] = message[0][point] msg[1][point] = message[1][point] else: + # other devices publish (devices/campus/building/device/point) msg = None if point in device: msg = message + # if the point in in the parsed topic then exit for loop break if (isinstance(msg, list) and not msg[0]) or \ (isinstance(msg, (float, int, str)) and msg is None): diff --git a/volttron/platform/agent/base_historian.py b/volttron/platform/agent/base_historian.py index f75589ea72..3c90956e81 100644 --- a/volttron/platform/agent/base_historian.py +++ b/volttron/platform/agent/base_historian.py @@ -852,15 +852,18 @@ def _capture_device_data(self, peer, sender, bus, topic, headers, # will be kept. if _filter in device: for point in point_list: - # Only points in the point list will be added to the message payload + # devices all publish if isinstance(message, list): + # Only points in the point list will be added to the message payload if point in message[0]: msg[0][point] = message[0][point] msg[1][point] = message[1][point] else: + # other devices publish (devices/campus/building/device/point) msg = None if point in device: msg = message + # if the point in in the parsed topic then exit for loop break if (isinstance(msg, list) and not msg[0]) or \ (isinstance(msg, (float, int, str)) and msg is None): From 66b67e2cfba2c16ee66779e804abc1592c697019 Mon Sep 17 00:00:00 2001 From: Robert Lutes Date: Fri, 29 May 2020 18:23:19 -0700 Subject: [PATCH 3/4] Add device to call to _capture_data. --- volttron/platform/agent/base_historian.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/volttron/platform/agent/base_historian.py b/volttron/platform/agent/base_historian.py index 3c90956e81..5c13785022 100644 --- a/volttron/platform/agent/base_historian.py +++ b/volttron/platform/agent/base_historian.py @@ -874,7 +874,7 @@ def _capture_device_data(self, peer, sender, bus, topic, headers, except Exception as e: _log.debug("Error handling device_data_filter. {}".format(e)) msg = message - self._capture_data(peer, sender, bus, topic, headers, msg) + self._capture_data(peer, sender, bus, topic, headers, msg, device) def _capture_analysis_data(self, peer, sender, bus, topic, headers, message): From 0b349de4a2b13a8522f5aac44738484c2796e574 Mon Sep 17 00:00:00 2001 From: Robert Lutes Date: Fri, 29 May 2020 18:27:02 -0700 Subject: [PATCH 4/4] Update comment. --- volttron/platform/agent/base_historian.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/volttron/platform/agent/base_historian.py b/volttron/platform/agent/base_historian.py index 5c13785022..6595809d97 100644 --- a/volttron/platform/agent/base_historian.py +++ b/volttron/platform/agent/base_historian.py @@ -867,7 +867,7 @@ def _capture_device_data(self, peer, sender, bus, topic, headers, break if (isinstance(msg, list) and not msg[0]) or \ (isinstance(msg, (float, int, str)) and msg is None): - _log.debug("Topic: {} - is not in configured to be forwarded".format(topic)) + _log.debug("Topic: {} - is not in configured to be stored".format(topic)) return else: msg = message