diff options
Diffstat (limited to 'core/signal_processor.py')
| -rw-r--r-- | core/signal_processor.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/core/signal_processor.py b/core/signal_processor.py index 0d4ed39..417d142 100644 --- a/core/signal_processor.py +++ b/core/signal_processor.py @@ -359,6 +359,14 @@ class SignalProcessor(QObject): def all_virtual_channel_ids(self) -> List[str]: return list(self._derived_bufs.keys()) + def clear_history(self): + """Clear derived channel buffers and latest-value cache.""" + with self._lock: + for t_buf, v_buf in self._derived_bufs.values(): + t_buf.clear() + v_buf.clear() + self._latest.clear() + # ── Main data path ──────────────────────────────────────────────────── def on_raw_data(self, device_id: str, channel_id: str, @@ -401,6 +409,11 @@ class SignalProcessor(QObject): try: result = self._compute_derived(dc, inputs, timestamp, latest) if result is not None: + # Write back into local snapshot so downstream derived + # channels that depend on this one can see it this pass + latest[("derived", dc.channel_id)] = (timestamp, result) + with self._lock: + self._latest[("derived", dc.channel_id)] = (timestamp, result) bufs = self._derived_bufs.get(dc.channel_id) if bufs: bufs[0].append(timestamp) |
