Automatic test route setting
This commit is contained in:
parent
b472eee637
commit
9da4d347e6
19
main.py
19
main.py
|
|
@ -293,6 +293,25 @@ def feedvalve_control(MV01_opening: int = Query(...)):
|
||||||
logging.info(f"Feed valve opening to {MV01_opening}")
|
logging.info(f"Feed valve opening to {MV01_opening}")
|
||||||
return {"status": "ok"}
|
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
|
# LOCAL RECORDER
|
||||||
@app.post("/start_recording")
|
@app.post("/start_recording")
|
||||||
|
|
|
||||||
|
|
@ -225,6 +225,23 @@
|
||||||
.monitor-pu-buttons a:hover {
|
.monitor-pu-buttons a:hover {
|
||||||
background-color: #0056b3;
|
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;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
@ -301,6 +318,11 @@
|
||||||
<button onclick="setFeedValve(50, this)">Feed Valve 50%</button>
|
<button onclick="setFeedValve(50, this)">Feed Valve 50%</button>
|
||||||
<button onclick="setFeedValve(100, this)">Feed Valve 100%</button>
|
<button onclick="setFeedValve(100, this)">Feed Valve 100%</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="button-group">
|
||||||
|
<button onclick="runAutoTest(1)">Automatic Test PU1</button>
|
||||||
|
<button onclick="runAutoTest(2)">Automatic Test PU2</button>
|
||||||
|
<button onclick="runAutoTest(3)">Automatic Test PU3</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="right-panel">
|
<div class="right-panel">
|
||||||
<div class="monitor-block">
|
<div class="monitor-block">
|
||||||
|
|
@ -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) {
|
async function setFeedValve(opening, buttonEl) {
|
||||||
await fetch(`/command/feed_valve?MV01_opening=${opening}`, {method: 'POST'});
|
await fetch(`/command/feed_valve?MV01_opening=${opening}`, {method: 'POST'});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user