From 48d4ae57346a403282f0c8f0fef0d38660b18d51 Mon Sep 17 00:00:00 2001
From: Matthias Bodenbenner <m.bodenbenner@wzl-mq.rwth-aachen.de>
Date: Fri, 22 Mar 2024 08:06:31 +0100
Subject: [PATCH] bug fix in streaming

---
 README.md          |  7 +++++--
 setup.py           |  2 +-
 src/soil/stream.py | 13 +++++++++----
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index f293c15..eeab6ca 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
 [![Build](https://git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/lava/unified-device-interface/python/badges/master/pipeline.svg)](https://git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/lava/unified-device-interface/python/commits/master)
 
 # Python Unified Device Interface
-Current stable version: 10.0.4
+Current stable version: 10.0.5
 
 ## Installation
 1. Install the WZL-UDI package via pip
@@ -69,7 +69,10 @@ Funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation)
 
 ## Recent changes
 
-**10.0.4** - 2024-03-21
+**10.0.5** - 2024-03-22
+  - bug fix in streaming
+
+  - **10.0.4** - 2024-03-22
   - increased logging verbosity of streaming class
   - fixed streaming of semantic measurements
 
diff --git a/setup.py b/setup.py
index a1029db..7470647 100644
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
     long_description = fh.read()
 
 setup(name='wzl-udi',
-      version='10.0.4',
+      version='10.0.5',
       url='https://git-ce.rwth-aachen.de/wzl-mq-public/soil/python',
       project_urls={
           "Bug Tracker": "https://git-ce.rwth-aachen.de/wzl-mq-public/soil/python/-/issues",
diff --git a/src/soil/stream.py b/src/soil/stream.py
index 12ab43e..793608e 100644
--- a/src/soil/stream.py
+++ b/src/soil/stream.py
@@ -184,18 +184,20 @@ class UpdateJob(FixedJob):
     def __init__(self, topic: str, callback: Callable):
         FixedJob.__init__(self, topic, 0.01, callback)
         self._last_value = None
+        self._last_covariance = None
 
     def _is_triggered(self) -> bool:
-        value = self._callback()
+        value, covariance = self._callback()
         updated = self._last_value != value
         self._last_value = value
+        self._last_covariance = covariance
         if isinstance(updated, list):
             updated = any(updated)
         return updated
 
     @property
-    def value(self) -> Any:
-        return self._last_value
+    def value(self) -> Tuple[Any, Any]:
+        return self._last_value, self._last_covariance
 
 
 class EventJob(FixedJob):
@@ -211,8 +213,11 @@ class EventJob(FixedJob):
 
     def _is_triggered(self) -> bool:
         value = self._callback()
+        if isinstance(value, tuple):
+            assert len(value) == 2
+            value, covariance = value
+
         updated = self._event.is_triggered(value)
-        self._last_value = value
         if isinstance(updated, list):
             updated = any(updated)
         return updated
-- 
GitLab