diff --git a/main.py b/main.py index 70a6f68..fec2f61 100644 --- a/main.py +++ b/main.py @@ -293,6 +293,25 @@ def feedvalve_control(MV01_opening: int = Query(...)): logging.info(f"Feed valve opening to {MV01_opening}") return {"status": "ok"} +# AUTOMATIC TESTING + +@router.post("/test/auto/1") +async def auto_test_pu1(): + # Call the function for PU1 auto test + logging.info("Start auto test of 1 PU") + return {"status": "started", "pu": 1} + +@router.post("/test/auto/2") +async def auto_test_pu2(): + # Call the function for PU2 auto test + logging.info("Start auto test of 2 PU") + return {"status": "started", "pu": 2} + +@router.post("/test/auto/3") +async def auto_test_pu3(): + # Call the function for PU3 auto test + logging.info("Start auto test of 3 PU") + return {"status": "started", "pu": 3} # LOCAL RECORDER @app.post("/start_recording") diff --git a/templates/control.html b/templates/control.html index 4632d0a..5c745db 100644 --- a/templates/control.html +++ b/templates/control.html @@ -225,6 +225,23 @@ .monitor-pu-buttons a:hover { background-color: #0056b3; } + .button-group { + margin-top: 10px; + display: flex; + justify-content: space-around; + } + .button-group button { + padding: 8px 16px; + font-size: 1rem; + border-radius: 8px; + background-color: #008CBA; + color: white; + border: none; + cursor: pointer; + } + .button-group button:hover { + background-color: #005f6b; + } @@ -301,6 +318,11 @@ +
+ + + +
@@ -431,6 +453,28 @@ } } } + function runAutoTest(puNumber) { + const endpoint = `/test/auto/${puNumber}`; // Example: /test/auto/1 + + fetch(endpoint, { + method: 'POST' + }) + .then(response => { + if (!response.ok) { + throw new Error(`Test PU${puNumber} failed`); + } + return response.json(); + }) + // .then(data => { + // alert(`Automatic Test PU${puNumber} started successfully.`); + // console.log(data); + // }) + // .catch(error => { + // alert(`Error starting test for PU${puNumber}: ${error.message}`); + // console.error(error); + // }); + } + async function setFeedValve(opening, buttonEl) { await fetch(`/command/feed_valve?MV01_opening=${opening}`, {method: 'POST'});