MainCode/adalm1000_logger.py aktualisiert

Logging funktioniert wieder zuverlässig wie früher ✅

Kein Datenverlust bei Crash, da flush() sofort schreibt ✅

Bei langen Tests bleibt die Datei schlank, falls du das Intervall auf 1s limitierst ✅
(C)
This commit is contained in:
Jan
2025-07-10 19:15:14 +02:00
parent 401f19d237
commit f4dc4506b3
+23
View File
@@ -670,6 +670,10 @@ class BatteryTester(QMainWindow):
def update_status(self):
"""Update status information periodically"""
now = time.time()
if not hasattr(self, '_last_log_time'):
self._last_log_time = now
if self.test_running:
# Update capacity calculations if in test mode
if self.measuring and self.time_data:
@@ -686,6 +690,25 @@ class BatteryTester(QMainWindow):
self.charge_capacity += current_current * delta_t / 3600
self.charge_capacity_label.setText(f"{self.charge_capacity:.4f}")
# Logging (1x pro Sekunde)
if hasattr(self, 'log_writer') and (now - self._last_log_time >= 1.0):
if self.time_data:
current_time = self.time_data[-1]
voltage = self.voltage_data[-1]
current = self.current_data[-1]
self.log_writer.writerow([
f"{current_time:.3f}",
f"{voltage:.6f}",
f"{current:.6f}",
self.test_phase,
f"{self.capacity_ah:.4f}",
f"{self.charge_capacity:.4f}",
f"{self.coulomb_efficiency:.1f}",
f"{self.cycle_count}"
])
self.current_cycle_file.flush()
self._last_log_time = now
def start_test(self):
"""Start the full battery test cycle"""
# Clean up any previous test