From 92ab04cde90a02a754081fcf22db2a35c60a1fa2 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Fri, 10 Feb 2023 16:51:04 +0100 Subject: [PATCH] first try on a combined sensors class --- slic/core/sensor/combined.py | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 slic/core/sensor/combined.py diff --git a/slic/core/sensor/combined.py b/slic/core/sensor/combined.py new file mode 100644 index 00000000..cbe563f9 --- /dev/null +++ b/slic/core/sensor/combined.py @@ -0,0 +1,37 @@ +from .sensor import Sensor + + +class Combined(Sensor): + + def __init__(self, ID, sensors, combination, **kwargs): + super().__init__(ID, **kwargs) + self.sensors = sensors + self.combination = combination + #TODO: not sure how to handle the following + del self.aggregation + del self._cache + + + def start(self): + for s in self.sensors: + s.start() + + def stop(self): + for s in self.sensors: + s.stop() + + + def get_current_value(self): + values = (s.get_current_value() for s in self.sensors) + return self.combination(*values) + + def get_last_value(self): + values = (s.get_last_value() for s in self.sensors) + return self.combination(*values) + + def get_aggregate(self): + values = (s.get_aggregate() for s in self.sensors) + return self.combination(*values) + + +