Last of day, might have working

This commit is contained in:
david rice
2026-04-02 16:08:50 +01:00
parent 73c10f8987
commit c61476e846

View File

@@ -28,6 +28,8 @@ SIG_POINTS = 500_000 # 500 k pts → ~25 GSa/s
PROTO_SCALE = 1e-6 # 1 µs/div → 10 µs window
PROTO_POINTS = 500_000 # 500 k pts → 50 MSa/s (enough to see burst structure)
DISPLAY_SETTLE_S = 1.0 # seconds to wait after display ON before arming scope
test_running = False # Global flag to control the background thread
# --- Instrument Connection ---
@@ -241,10 +243,10 @@ def dual_capture(iteration):
scope.write(":RUN")
def test_worker(on_time):
def test_worker():
"""
Background loop:
- Turns display ON, waits on_time seconds for it to stabilise
- Turns display ON, waits DISPLAY_SETTLE_S for it to stabilise
- Runs dual_capture (signal quality + frame structure)
- Turns display OFF for 1 second
- Repeats until test_running = False
@@ -254,7 +256,7 @@ def test_worker(on_time):
while test_running:
requests.put(URL, json={"state": "on"}, timeout=2)
time.sleep(on_time) # let display stabilise before arming
time.sleep(DISPLAY_SETTLE_S)
dual_capture(count)
count += 1
requests.put(URL, json={"state": "off"}, timeout=2)
@@ -298,14 +300,10 @@ def main_menu():
elif choice == '5':
if not test_running:
try:
sec = float(input("ON DURATION (seconds): "))
test_running = True
t = threading.Thread(target=test_worker, args=(sec,), daemon=True)
t.start()
print(f"TEST STARTED — ON TIME: {sec}s")
except ValueError:
print("INVALID TIME ENTERED.")
test_running = True
t = threading.Thread(target=test_worker, daemon=True)
t.start()
print("TEST STARTED.")
else:
print("TEST IS ALREADY RUNNING!")