Adalm1000_Logger/multi_logger.py
Vincent Hanewinkel dc5269e595 test
2025-08-14 23:01:45 +02:00

42 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import pysmu
from device_worker import DeviceWorker
class MultiLogger:
"""
Verwaltet eine Session und mehrere DeviceWorker.
Session wird EINMAL im Hauptthread gestartet wie beim Single-Logger.
"""
def __init__(self, outdir="./logs", filter_window_size=10, interval=0.1):
self.sess = pysmu.Session()
self.sess.add_all()
self.devices = list(self.sess.devices)
self.workers = [DeviceWorker(dev, outdir, filter_window_size, interval)
for dev in self.devices]
def set_default_modes(self):
for w in self.workers:
try:
w.set_mode("A", pysmu.Mode.SIMV)
w.set_mode("B", pysmu.Mode.HI_Z)
except Exception as e:
print(f"[{w.serial}] Mode-Set-Fehler: {e}")
# Session zentral steuern:
def start_session(self):
# WICHTIG: im Hauptthread aufrufen (vor den GUI-Events)
self.sess.start(0)
def end_session(self):
self.sess.end()
# Helfer:
def start_all(self):
for w in self.workers: w.start()
def stop_all(self):
for w in self.workers: w.stop()
def shutdown(self):
for w in self.workers: w.shutdown()
# Session am Ende schließen
self.end_session()