conductivity reading update and logging of uvicorn set to warning
This commit is contained in:
parent
9b0daf2d06
commit
81353c8b1f
|
|
@ -132,7 +132,7 @@ class CANBackend:
|
||||||
"MV08": 100 * data[6] / 255,
|
"MV08": 100 * data[6] / 255,
|
||||||
})
|
})
|
||||||
|
|
||||||
elif cob_id == 0x2AB and len(data) >= 7:
|
elif cob_id == 0x2B2 and len(data) >= 7:
|
||||||
self.latest_data[2].update({
|
self.latest_data[2].update({
|
||||||
"PU2_STATE" : data[0],
|
"PU2_STATE" : data[0],
|
||||||
"Conductivity_Feed" : int.from_bytes(data[1:3], 'little') / 100.0,
|
"Conductivity_Feed" : int.from_bytes(data[1:3], 'little') / 100.0,
|
||||||
|
|
|
||||||
9
main.py
9
main.py
|
|
@ -31,7 +31,9 @@ if platform.system() in ["Darwin"]: # macOS or Windows
|
||||||
else:
|
else:
|
||||||
from classCAN import CANBackend # Your real backend
|
from classCAN import CANBackend # Your real backend
|
||||||
|
|
||||||
logging.basicConfig(level=logging.ERROR)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
logging.getLogger("uvicorn.access").setLevel(logging.WARNING)
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
app.add_middleware(SessionMiddleware, secret_key="your_super_secret_key")
|
app.add_middleware(SessionMiddleware, secret_key="your_super_secret_key")
|
||||||
|
|
@ -169,10 +171,10 @@ def monitor_page(request: Request):
|
||||||
|
|
||||||
@app.post("/connect_toggle")
|
@app.post("/connect_toggle")
|
||||||
def connect_toggle():
|
def connect_toggle():
|
||||||
logging.info("Toggling CAN connection...")
|
logging.info(f"Toggling CAN connection, CAN is {can_backend.connected}")
|
||||||
print("CONNECTING")
|
|
||||||
if can_backend.connected:
|
if can_backend.connected:
|
||||||
can_backend.shutdown()
|
can_backend.shutdown()
|
||||||
|
logging.info("Shutting down CAN connection...")
|
||||||
return {"connected": False}
|
return {"connected": False}
|
||||||
else:
|
else:
|
||||||
success = can_backend.connect()
|
success = can_backend.connect()
|
||||||
|
|
@ -250,7 +252,6 @@ async def update_latest_data():
|
||||||
|
|
||||||
@app.get("/monitor")
|
@app.get("/monitor")
|
||||||
async def get_monitor_data(pu_number: Optional[float] = Query(None)):
|
async def get_monitor_data(pu_number: Optional[float] = Query(None)):
|
||||||
print(f"pu_number is {pu_number}")
|
|
||||||
if pu_number is not None:
|
if pu_number is not None:
|
||||||
return latest_data.get(f"PU_{pu_number}", {})
|
return latest_data.get(f"PU_{pu_number}", {})
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
@ -17,6 +18,7 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
background-color: #1e1e1e;
|
background-color: #1e1e1e;
|
||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
|
|
@ -24,6 +26,7 @@
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.connect-button {
|
.connect-button {
|
||||||
background-color: #ff4444;
|
background-color: #ff4444;
|
||||||
color: white;
|
color: white;
|
||||||
|
|
@ -36,9 +39,11 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.connected {
|
.connected {
|
||||||
background-color: #00C851;
|
background-color: #00C851;
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|
@ -46,17 +51,21 @@
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
.left-panel, .right-panel {
|
|
||||||
|
.left-panel,
|
||||||
|
.right-panel {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.left-panel {
|
.left-panel {
|
||||||
background-color: #1e1e1e;
|
background-color: #1e1e1e;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mode-block {
|
.mode-block {
|
||||||
background-color: #333;
|
background-color: #333;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
|
|
@ -65,10 +74,12 @@
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pu-buttons {
|
.pu-buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mode-block button {
|
.mode-block button {
|
||||||
background-color: #4285F4;
|
background-color: #4285F4;
|
||||||
color: white;
|
color: white;
|
||||||
|
|
@ -80,39 +91,49 @@
|
||||||
transition: background-color 0.3s;
|
transition: background-color 0.3s;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mode-block button:hover {
|
.mode-block button:hover {
|
||||||
background-color: #3367d6;
|
background-color: #3367d6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mode-block button.active {
|
.mode-block button.active {
|
||||||
background-color: #00C851;
|
background-color: #00C851;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mode-block button.in-progress {
|
.mode-block button.in-progress {
|
||||||
background-color: #ffcc00;
|
background-color: #ffcc00;
|
||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mode-block button.ready {
|
.mode-block button.ready {
|
||||||
background-color: #00C851;
|
background-color: #00C851;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mode-block button.disabled {
|
.mode-block button.disabled {
|
||||||
background-color: #777;
|
background-color: #777;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
.in-progress {
|
.in-progress {
|
||||||
background-color: yellow !important;
|
background-color: yellow !important;
|
||||||
color: black !important;
|
color: black !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ready {
|
.ready {
|
||||||
background-color: orange !important;
|
background-color: orange !important;
|
||||||
color: black !important;
|
color: black !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.production {
|
.production {
|
||||||
background-color: green !important;
|
background-color: green !important;
|
||||||
color: white !important;
|
color: white !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pu-status {
|
.pu-status {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pu-item {
|
.pu-item {
|
||||||
background-color: #333;
|
background-color: #333;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|
@ -122,24 +143,28 @@
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.monitor-block {
|
.monitor-block {
|
||||||
background-color: #333;
|
background-color: #333;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.monitor-values {
|
.monitor-values {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(3, 1fr);
|
grid-template-columns: repeat(3, 1fr);
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.monitor-value {
|
.monitor-value {
|
||||||
background-color: #444;
|
background-color: #444;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.slider-container {
|
.slider-container {
|
||||||
background-color: #1e1e1e;
|
background-color: #1e1e1e;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|
@ -147,12 +172,14 @@
|
||||||
color: #fff;
|
color: #fff;
|
||||||
width: 95%;
|
width: 95%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.slider-container label {
|
.slider-container label {
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.slider-values {
|
.slider-values {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
@ -161,10 +188,12 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.slider-values span#currentValue {
|
.slider-values span#currentValue {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #00bfff;
|
color: #00bfff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.slider {
|
.slider {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 8px;
|
height: 8px;
|
||||||
|
|
@ -174,13 +203,16 @@
|
||||||
appearance: none;
|
appearance: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
.slider::-webkit-slider-thumb, .slider::-moz-range-thumb {
|
|
||||||
|
.slider::-webkit-slider-thumb,
|
||||||
|
.slider::-moz-range-thumb {
|
||||||
height: 18px;
|
height: 18px;
|
||||||
width: 18px;
|
width: 18px;
|
||||||
background: #007bff;
|
background: #007bff;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.monitor-link {
|
.monitor-link {
|
||||||
color: white;
|
color: white;
|
||||||
background-color: #007bff;
|
background-color: #007bff;
|
||||||
|
|
@ -189,14 +221,17 @@
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.monitor-link:hover {
|
.monitor-link:hover {
|
||||||
background-color: #0056b3;
|
background-color: #0056b3;
|
||||||
}
|
}
|
||||||
|
|
||||||
.monitor-pu-buttons {
|
.monitor-pu-buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.monitor-pu-buttons a {
|
.monitor-pu-buttons a {
|
||||||
color: white;
|
color: white;
|
||||||
background-color: #007bff;
|
background-color: #007bff;
|
||||||
|
|
@ -205,14 +240,17 @@
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.monitor-pu-buttons a:hover {
|
.monitor-pu-buttons a:hover {
|
||||||
background-color: #0056b3;
|
background-color: #0056b3;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button-group {
|
.button-group {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button-group button {
|
.button-group button {
|
||||||
padding: 8px 16px;
|
padding: 8px 16px;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
|
|
@ -222,11 +260,13 @@
|
||||||
border: none;
|
border: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button-group button:hover {
|
.button-group button:hover {
|
||||||
background-color: #005f6b;
|
background-color: #005f6b;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h1>Hydraulic Machine Control</h1>
|
<h1>Hydraulic Machine Control</h1>
|
||||||
|
|
@ -260,23 +300,32 @@
|
||||||
<div class="left-panel">
|
<div class="left-panel">
|
||||||
<div class="mode-block">
|
<div class="mode-block">
|
||||||
<div class="pu-buttons">
|
<div class="pu-buttons">
|
||||||
<button onclick="sendCommand('IDLE', 1, this)" data-action="IDLE" data-pu="1"><i class="fas fa-power-off"></i> IDLE PU 1</button>
|
<button onclick="sendCommand('IDLE', 1, this)" data-action="IDLE" data-pu="1"><i
|
||||||
<button onclick="sendCommand('IDLE', 2, this)" data-action="IDLE" data-pu="2"><i class="fas fa-power-off"></i> IDLE PU 2</button>
|
class="fas fa-power-off"></i> IDLE PU 1</button>
|
||||||
<button onclick="sendCommand('IDLE', 3, this)" data-action="IDLE" data-pu="3"><i class="fas fa-power-off"></i> IDLE PU 3</button>
|
<button onclick="sendCommand('IDLE', 2, this)" data-action="IDLE" data-pu="2"><i
|
||||||
|
class="fas fa-power-off"></i> IDLE PU 2</button>
|
||||||
|
<button onclick="sendCommand('IDLE', 3, this)" data-action="IDLE" data-pu="3"><i
|
||||||
|
class="fas fa-power-off"></i> IDLE PU 3</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mode-block">
|
<div class="mode-block">
|
||||||
<div class="pu-buttons">
|
<div class="pu-buttons">
|
||||||
<button onclick="sendCommand('PRE-PRODUCTION', 1, this)" data-action="PRE-PRODUCTION" data-pu="1"><i class="fas fa-play"></i> PRE-PROD PU 1</button>
|
<button onclick="sendCommand('PRE-PRODUCTION', 1, this)" data-action="PRE-PRODUCTION" data-pu="1"><i
|
||||||
<button onclick="sendCommand('PRE-PRODUCTION', 2, this)" data-action="PRE-PRODUCTION" data-pu="2"><i class="fas fa-play"></i> PRE-PROD PU 2</button>
|
class="fas fa-play"></i> PRE-PROD PU 1</button>
|
||||||
<button onclick="sendCommand('PRE-PRODUCTION', 3, this)" data-action="PRE-PRODUCTION" data-pu="3"><i class="fas fa-play"></i> PRE-PROD PU 3</button>
|
<button onclick="sendCommand('PRE-PRODUCTION', 2, this)" data-action="PRE-PRODUCTION" data-pu="2"><i
|
||||||
|
class="fas fa-play"></i> PRE-PROD PU 2</button>
|
||||||
|
<button onclick="sendCommand('PRE-PRODUCTION', 3, this)" data-action="PRE-PRODUCTION" data-pu="3"><i
|
||||||
|
class="fas fa-play"></i> PRE-PROD PU 3</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mode-block">
|
<div class="mode-block">
|
||||||
<div class="pu-buttons">
|
<div class="pu-buttons">
|
||||||
<button onclick="sendCommand('FIRST_START', 1, this)" data-action="FIRST_START" data-pu="1"><i class="fas fa-power-off"></i> FIRST START PU 1</button>
|
<button onclick="sendCommand('FIRST_START', 1, this)" data-action="FIRST_START" data-pu="1"><i
|
||||||
<button onclick="sendCommand('FIRST_START', 2, this)" data-action="FIRST_START" data-pu="2"><i class="fas fa-power-off"></i> FIRST START PU 2</button>
|
class="fas fa-power-off"></i> FIRST START PU 1</button>
|
||||||
<button onclick="sendCommand('FIRST_START', 3, this)" data-action="FIRST_START" data-pu="3"><i class="fas fa-power-off"></i> FIRST START PU 3</button>
|
<button onclick="sendCommand('FIRST_START', 2, this)" data-action="FIRST_START" data-pu="2"><i
|
||||||
|
class="fas fa-power-off"></i> FIRST START PU 2</button>
|
||||||
|
<button onclick="sendCommand('FIRST_START', 3, this)" data-action="FIRST_START" data-pu="3"><i
|
||||||
|
class="fas fa-power-off"></i> FIRST START PU 3</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="slider-container">
|
<div class="slider-container">
|
||||||
|
|
@ -286,10 +335,12 @@
|
||||||
<span id="currentValue">2.5</span>
|
<span id="currentValue">2.5</span>
|
||||||
<span id="maxValue">3.5</span>
|
<span id="maxValue">3.5</span>
|
||||||
</div>
|
</div>
|
||||||
<input type="range" min="0.5" max="3.5" step="0.1" value="2.5" id="ploopSetpoint" class="slider" oninput="updatePloopSetpoint(this.value)">
|
<input type="range" min="0.5" max="3.5" step="0.1" value="2.5" id="ploopSetpoint" class="slider"
|
||||||
|
oninput="updatePloopSetpoint(this.value)">
|
||||||
</div>
|
</div>
|
||||||
<div class="mode-block">
|
<div class="mode-block">
|
||||||
<button onclick="sendCommand('ThermalLoopCleaning', 0, this)"><i class="fas fa-fire"></i> Thermal Loop Cleaning</button>
|
<button onclick="sendCommand('ThermalLoopCleaning', 0, this)"><i class="fas fa-fire"></i> Thermal Loop
|
||||||
|
Cleaning</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="pu-status">
|
<div class="pu-status">
|
||||||
<div class="pu-item"><span>PU 1: </span><span id="pu1-status">Offline</span></div>
|
<div class="pu-item"><span>PU 1: </span><span id="pu1-status">Offline</span></div>
|
||||||
|
|
@ -541,11 +592,12 @@ async function fetchMonitorData() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setInterval(getConnectionStatus, 1000);
|
||||||
getConnectionStatus();
|
getConnectionStatus();
|
||||||
ssetInterval(getConnectionStatus, 1000);
|
|
||||||
|
|
||||||
setInterval(fetchMonitorData, 1000);
|
setInterval(fetchMonitorData, 1000);
|
||||||
fetchMonitorData();
|
fetchMonitorData();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Loading…
Reference in New Issue
Block a user