Connect button auto switch
This commit is contained in:
parent
9e79f343a5
commit
c25a387e8b
7
main.py
7
main.py
|
|
@ -86,7 +86,7 @@ def format_data(data):
|
||||||
"MV02_sp": np.round(data.get("MV02_sp", 0.0), 1),
|
"MV02_sp": np.round(data.get("MV02_sp", 0.0), 1),
|
||||||
"MV03": np.round(data.get("MV03", 0.0), 1),
|
"MV03": np.round(data.get("MV03", 0.0), 1),
|
||||||
"MV03_sp": np.round(data.get("MV03_sp", 0.0), 1),
|
"MV03_sp": np.round(data.get("MV03_sp", 0.0), 1),
|
||||||
"MV04": np.round(data.get("MV05", 0.0), 1),
|
"MV04": np.round(data.get("MV04", 0.0), 1),
|
||||||
"MV04_sp": np.round(data.get("MV04_sp", 0.0), 1),
|
"MV04_sp": np.round(data.get("MV04_sp", 0.0), 1),
|
||||||
"MV05": np.round(data.get("MV05", 0.0), 1),
|
"MV05": np.round(data.get("MV05", 0.0), 1),
|
||||||
"MV05_sp": np.round(data.get("MV05_sp", 0.0), 1),
|
"MV05_sp": np.round(data.get("MV05_sp", 0.0), 1),
|
||||||
|
|
@ -182,9 +182,6 @@ def connect_toggle():
|
||||||
|
|
||||||
@app.post("/is_connected")
|
@app.post("/is_connected")
|
||||||
def is_can_connected():
|
def is_can_connected():
|
||||||
""""
|
|
||||||
|
|
||||||
"""
|
|
||||||
return {"connected": can_backend.connected}
|
return {"connected": can_backend.connected}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -427,7 +424,7 @@ if __name__ == "__main__":
|
||||||
uvicorn.run(
|
uvicorn.run(
|
||||||
"main:app",
|
"main:app",
|
||||||
host="127.0.0.1",
|
host="127.0.0.1",
|
||||||
port=8081,
|
port=8080,
|
||||||
reload=True,
|
reload=True,
|
||||||
reload_dirs=["."],
|
reload_dirs=["."],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -343,10 +343,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getConnectionStatus() {
|
async function getConnectionStatus() {
|
||||||
const response = await fetch('/connect_toggle', { method: 'GET' });
|
const response = await fetch('/is_connected', { method: 'GET' });
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
const connectButton = document.getElementById('connectButton');
|
const connectButton = document.getElementById('connectButton');
|
||||||
connectButton.classList.toggle('connected', data.connected);
|
if (data.connected) {
|
||||||
|
connectButton.classList.add('connected');
|
||||||
|
connectButton.innerHTML = '<i class="fas fa-power-off"></i> Disconnect';
|
||||||
|
} else {
|
||||||
|
connectButton.classList.remove('connected');
|
||||||
|
connectButton.innerHTML = '<i class="fas fa-power-off"></i> Connect';
|
||||||
|
}
|
||||||
connectButton.innerHTML = `<i class="fas fa-power-off"></i> ${data.connected ? 'Disconnect' : 'Connect'}`;
|
connectButton.innerHTML = `<i class="fas fa-power-off"></i> ${data.connected ? 'Disconnect' : 'Connect'}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user