From 6e65c85c0711e438c99959ca6b5e8adc7daac3d2 Mon Sep 17 00:00:00 2001 From: david rice Date: Tue, 7 Apr 2026 15:48:40 +0100 Subject: [PATCH] Chnages --- __pycache__/ai_mgmt.cpython-312.pyc | Bin 0 -> 2159 bytes mipi_test.py | 53 ++++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 __pycache__/ai_mgmt.cpython-312.pyc diff --git a/__pycache__/ai_mgmt.cpython-312.pyc b/__pycache__/ai_mgmt.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2cd571fe2e3eef88ee30580cd6f5d12e83010c4d GIT binary patch literal 2159 zcmah~-A@!(6u)=pV`sm20TGbO6s2V&3}DsRhFVZiX%q?TN8H*>*PROt&hFBg0lFKs z`(WZ?Fk)H*i80wewGDmnALxV6eOUy;GPMa!nK zxp#i@c$^5vrND~%2ZzvabWWw*snDsq<;){ZUtlykm4XLQ0GH#0T+!h0;!WQ zge4r|7uX^<>>(b#sbJ><>Ls4CK3KaSGUXjc#M6U5^&k}X6|_CX_W(V#?Z{_*EK1^n z%)7%);v^3G|D?hCgV^$f&K^IJh{s9PR1@)(yW{4yhUu$0Fv4A)OD}EZ4X}S+c1rMfdM#t12p^mABlM%2` zL^B~qi}28;IYNr@r090BAt_qmO87QwfP0^vqv^aVFXcVWPoZ*Quj45U?V}@f-8N+# z-3F_q3X_5-kd9|6rVupVf9OENG1nQe--dX{UUvW#_NiAIcIN1tBfY5!$^eaS!@uJh z+M|@6foHBxb8iCpwYboMNfc!JgSIU!rEHS4h1*gr#U;pFf~Feg03c%t6r^}0Ml6?V z^b`O|=t+yy5|c!?1QJ(_Nfq??$k-Tcf`Y|TL@hgso4QI2i=&IAS~m<4J6HxM7-^+I-ttuiD9-y zR5>;rGo`VlUJItFdU|wu+qu-KC880{I3`i=dqBhZ63ELm%2!m+wccyZa#?e!q9tR` z@2Y=}?2eX9Z{AmR_r~;%?4CtmOWt3T-_tPvP8MgIzLma_a&LF!Y7S=lKxfq_KJkfb z{;Ju__kH<5_1xZjdshQZi-D%4z`Lt~_QgQ^qw1Bw(Y(KQ)h{mk#cb`0|G+aJ#Mp!* zAf4X9Ag|MB!*ZQC(+97L+~0k+*K&n=2QT&x7B}`%uUp)huEtG^i)smj1nm}Y5PgE^ zdJVM~;PU7NoP@E6VN51;MX#noc2hztW6)6V?%dvx{zY*3A|4hOI^8|k zYY7)%UjRxN=njQ0og3`2T*Cw!(=aIndOh|17A3T#G#AR2WxauJxnkEdaIY*p^gYsP zR~8W25;|iEWn3f2^!I>AFSPLp$OeNk{uz0GK?l~o^=Uru-JRz0UVmCB5iv8g>J=Bg z;*z&9?aF(r(ymRu0q@%A!H9KdQcsxLHP(^opFc9+oNdfr$ezj_IF@sMw9Iy`x$EYS zWDkGW{OI(O`@?kauXgvE;F;y`8S{s~O3iB7)||I}S?GWUe~z%DKGVJC4$K~({d_h$ c+kEHTGX{9ic;xWry!%#!{Tr2ttt({oFHfrp1^@s6 literal 0 HcmV?d00001 diff --git a/mipi_test.py b/mipi_test.py index c472eaf..5cd3f13 100644 --- a/mipi_test.py +++ b/mipi_test.py @@ -13,11 +13,13 @@ import sys import requests import threading from datetime import datetime +import ai_mgmt # --- Configuration --- -URL = "http://192.168.45.8:5000/display" -SCOPE_IP = "192.168.45.4" -PSU_IP = "192.168.45.3" +URL = "http://192.168.45.8:5000/display" +SCOPE_IP = "192.168.45.4" +PSU_IP = "192.168.45.3" +MGMT_INTERVAL = 60 # seconds between management runs (set to 3600 for hourly) # --- Capture settings --- # Pass 1 — signal quality: resolves individual bits at 140 Mbit/s (7.1 ns/bit) @@ -30,7 +32,9 @@ 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 +test_running = False # controls both worker threads +resume_event = threading.Event() # cleared to pause test_worker, set to resume +capture_done = threading.Event() # set when a full dual_capture (all 4 files) completes # --- Instrument Connection --- try: @@ -218,6 +222,7 @@ def dual_capture(iteration): Pass 2 — frame structure (PROTO_SCALE / PROTO_POINTS) Restores the original 5 ns/div timebase when done. """ + capture_done.clear() ts = datetime.now().strftime("%Y%m%d_%H%M%S") print(f"DUAL CAPTURE #{iteration:04d} [{ts}]") @@ -240,11 +245,41 @@ def dual_capture(iteration): # ── Restore original timebase ───────────────────────────────────────── _set_timebase(5e-9, 500_000) scope.write(":RUN") + capture_done.set() + + +def mgmt_worker(): + """ + Fires every MGMT_INTERVAL seconds while a test is running: + - Pauses test_worker via resume_event + - Runs ai_mgmt CSV scan + - Resumes test_worker + """ + while test_running: + time.sleep(MGMT_INTERVAL) + if not test_running: + break + + print("\n[MGMT] WAITING FOR CURRENT CAPTURE TO COMPLETE...") + capture_done.wait() + print("[MGMT] PAUSING TEST — RUNNING MANAGEMENT TASKS...") + resume_event.clear() + try: + files = ai_mgmt.list_csv_files(ai_mgmt.SERVER, ai_mgmt.SHARE) + print(f"[MGMT] FOUND {len(files)} CSV FILE(S) ON SCOPE DRIVE.") + for f in files: + print(f" {f}") + except Exception as e: + print(f"[MGMT] ERROR: {e}") + finally: + resume_event.set() + print("[MGMT] RESUMING TEST.\n") def test_worker(): """ Background loop: + - Waits if mgmt_worker has paused via resume_event - Turns display ON, waits DISPLAY_SETTLE_S for it to stabilise - Runs dual_capture (signal quality + frame structure) - Turns display OFF for 1 second @@ -254,6 +289,9 @@ def test_worker(): count = 1 while test_running: + resume_event.wait() # block here while mgmt_worker is running + if not test_running: + break requests.put(URL, json={"state": "on"}, timeout=2) time.sleep(DISPLAY_SETTLE_S) dual_capture(count) @@ -300,9 +338,10 @@ def main_menu(): elif choice == '5': if not test_running: test_running = True - t = threading.Thread(target=test_worker, daemon=True) - t.start() - print("TEST STARTED.") + resume_event.set() + threading.Thread(target=test_worker, daemon=True).start() + threading.Thread(target=mgmt_worker, daemon=True).start() + print(f"TEST STARTED. MANAGEMENT INTERVAL: {MGMT_INTERVAL}s.") else: print("TEST IS ALREADY RUNNING!")