From a44a226f4f2084c63eea28ddc4d70009e0ba3e23 Mon Sep 17 00:00:00 2001 From: Hannes Hansen Date: Mon, 15 Apr 2024 11:05:13 +0200 Subject: [PATCH] use multiple devices from one service topic --- algo/operator.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/algo/operator.py b/algo/operator.py index e51682b..9a90bbe 100644 --- a/algo/operator.py +++ b/algo/operator.py @@ -78,19 +78,21 @@ def setup_device_detectors(self): dep_config = util.DeploymentConfig() config_json = json.loads(dep_config.config) opr_config = util.OperatorConfig(config_json) + # Input can come from one/multiple service and one/multiple devices for input_topic in opr_config.inputTopics: - device_id = input_topic.filterValue - util.logger.info(f"Initialize Detector for Device: {device_id}") - self.device_detectors[device_id] = AnomalyDetector( - device_id, - self.config.check_receive_time_outlier, - self.config.check_data_schema, - self.config.check_data_anomalies, - self.config.check_data_extreme_outlier, - self.config.check_consumption, - self.config.data_path, - self.produce - ) + device_ids = input_topic.filterValue + for device_id in device_ids.split(','): + util.logger.info(f"Initialize Detector for Device: {device_id}") + self.device_detectors[device_id] = AnomalyDetector( + device_id, + self.config.check_receive_time_outlier, + self.config.check_data_schema, + self.config.check_data_anomalies, + self.config.check_data_extreme_outlier, + self.config.check_consumption, + self.config.data_path, + self.produce + ) def setup_operator_start(self, data_path): self.operator_start_time = utils.load_operator_start_time(data_path)