MainCode/adalm1000_logger.py aktualisiert

Initialization Order:

        Moved all attribute initializations to the start of __init__

        Specifically initialized self.test_phase = "Idle" before it's used

    UI Setup:

        Now safely sets the phase label text after self.test_phase is initialized

        Ensures all attributes exist before they're accessed

    Error Prevention:

        The QStandardPaths warning is still suppressed

        All UI elements are properly initialized before use
(D)
This commit is contained in:
Jan 2025-06-27 16:28:40 +02:00
parent 0b3177ead4
commit ed99c29fa0

View File

@ -80,12 +80,19 @@ class BatteryTester(QMainWindow):
def __init__(self):
super().__init__()
# Initialize data structures first
# Initialize all attributes first
self.time_data = deque()
self.voltage_data = deque()
self.current_data = deque()
self.phase_data = deque()
# Test state variables
self.test_phase = "Idle"
self.capacity_ah = 0.0
self.charge_capacity = 0.0
self.coulomb_efficiency = 0.0
self.cycle_count = 0
# Color scheme
self.bg_color = QColor(46, 52, 64)
self.fg_color = QColor(216, 222, 233)
@ -113,13 +120,6 @@ class BatteryTester(QMainWindow):
# Track test thread
self.test_thread = None
# Initialize test phase and values
self.test_phase = "Idle"
self.capacity_ah = 0.0
self.charge_capacity = 0.0
self.coulomb_efficiency = 0.0
self.cycle_count = 0
# Initialize device after UI is set up
QTimer.singleShot(100, self.init_device)
@ -209,6 +209,7 @@ class BatteryTester(QMainWindow):
self.current_label = value_label
elif i == 2:
self.phase_label = value_label
self.phase_label.setText(self.test_phase) # Now safe to access test_phase
elif i == 3:
self.time_label = value_label
elif i == 4: