31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
import httpx
|
|
import logging
|
|
|
|
def handle_patient_skid_for_idle() -> None:
|
|
"""Send the special commands to patient skid when entering IDLE."""
|
|
try:
|
|
url = "http://192.168.1.28:8000/stop_test"
|
|
response = httpx.get(url, timeout=1.0)
|
|
logging.info(f"Stopping test on Patient Skid: {response.status_code}")
|
|
|
|
url = "http://192.168.1.28:8000/close_valves"
|
|
response = httpx.get(url, timeout=1.0)
|
|
logging.info(f"Closing valves on Patient Skid: {response.status_code}")
|
|
except Exception as e:
|
|
logging.error(f"Error handling patient skid for IDLE: {e}")
|
|
raise
|
|
|
|
def set_patient_skid_users(count: int = 0):
|
|
try:
|
|
url = f"http://192.168.1.28:8000/set_users/{count}"
|
|
response = httpx.get(url, timeout=5.0)
|
|
|
|
response_2 = httpx.get("http://192.168.1.28:8000/start_defined_test", timeout=5.0)
|
|
|
|
if response.status_code == 200:
|
|
return {"status": "success", "detail": response.json()}
|
|
else:
|
|
raise HTTPException(status_code=502, detail=f"Remote server error: {response.text}")
|
|
except httpx.RequestError as e:
|
|
raise HTTPException(status_code=500, detail=f"Request to external server failed: {str(e)}")
|