Cleaned automatic tests

This commit is contained in:
Etienne Chassaing 2025-08-28 14:28:28 +02:00
parent fcab8ac473
commit 41323eb016

25
main.py
View File

@ -271,9 +271,6 @@ def is_connected():
# PU CONTROL # PU CONTROL
# --- helpers.py (or in the same file if you want) ---
def validate_state(state: str) -> str: def validate_state(state: str) -> str:
"""Normalize and validate the requested state.""" """Normalize and validate the requested state."""
state = state.upper() state = state.upper()
@ -543,7 +540,8 @@ async def stop_auto_test(pu: int):
async def run_auto_test_1(pu: int = 1): async def run_auto_test_1(pu: int = 1):
try: try:
await send_command_with_delay("PRE-PRODUCTION", pu = pu, delay_s=0, ploop_setpoint=2.5, qperm_setpoint=1200.0) await send_command_with_delay("PRE-PRODUCTION", pu = pu, delay_s=0, ploop_setpoint=2.5, qperm_setpoint=1200.0)
await set_patients_with_delay(5, delay_s=190) await asyncio.sleep(180) # Starting time of the machine
await set_patients_with_delay(5, delay_s=10)
await set_patients_with_delay(10, delay_s=20) await set_patients_with_delay(10, delay_s=20)
await set_patients_with_delay(0, delay_s=20) await set_patients_with_delay(0, delay_s=20)
await send_command_with_delay("IDLE", pu =pu, delay_s=20, ploop_setpoint=2.5, qperm_setpoint=1200.0) await send_command_with_delay("IDLE", pu =pu, delay_s=20, ploop_setpoint=2.5, qperm_setpoint=1200.0)
@ -559,31 +557,18 @@ async def run_auto_test_2():
try: try:
# Step 1: Run PU1 test # Step 1: Run PU1 test
# await run_auto_test_1(1, ploop_setpoint) # await run_auto_test_1(1, ploop_setpoint)
# TODO : TODO
# Step 2: PU2 sequence
await send_command_with_delay("PRE-PRODUCTION", pu=2, delay_s=0, ploop_setpoint=ploop_setpoint, qperm_setpoint=1200.0)
# await send_command_with_delay("PRODUCTION", 2, delay_s=180, ploop_setpoint=ploop_setpoint)
await set_patients_with_delay(15, delay_s=60)
await set_patients_with_delay(0, delay_s=60)
await send_command_with_delay("IDLE", pu=2, delay_s=60, ploop_setpoint=ploop_setpoint, qperm_setpoint=1200.0)
await send_command_with_delay("IDLE", pu=1, delay_s=60, ploop_setpoint=ploop_setpoint, qperm_setpoint=1200.0)
logging.info("[AUTO TEST] Finished PU1 + PU2 test") logging.info("[AUTO TEST] Finished PU1 + PU2 test")
except asyncio.CancelledError: except asyncio.CancelledError:
logging.info(f"[AUTO TEST] PU 2 task cancelled") logging.info(f"[AUTO TEST] PU 2 task cancelled")
# optional cleanup # optional cleanup
raise raise
async def run_auto_test_3(ploop_setpoint: float): async def run_auto_test_3():
try: try:
# Step 1: Run PU1 test # Step 1: Run PU1 test
# await run_auto_test_1() # await run_auto_test_1()
# TODO : TODO
# Step 2: PU2 sequence
await send_command_with_delay("PRE-PRODUCTION", pu=2, delay_s=0, ploop_setpoint=ploop_setpoint, qperm_setpoint=1200.0)
await set_patients_with_delay(15, delay_s=60)
await set_patients_with_delay(0, delay_s=60)
await send_command_with_delay("IDLE", pu=2, delay_s=60, ploop_setpoint=ploop_setpoint, qperm_setpoint=1200.0)
await send_command_with_delay("IDLE", pu=1, delay_s=60, ploop_setpoint=ploop_setpoint, qperm_setpoint=1200.0)
logging.info("[AUTO TEST] Finished PU1 + PU2 test") logging.info("[AUTO TEST] Finished PU1 + PU2 test")
except asyncio.CancelledError: except asyncio.CancelledError:
logging.info(f"[AUTO TEST] PU 2 task cancelled") logging.info(f"[AUTO TEST] PU 2 task cancelled")