Added changes related to Pre production mode and auto switch when ready for Production- need to be tested
This commit is contained in:
parent
7bdb841021
commit
5a910e0705
28
classCAN.py
28
classCAN.py
|
|
@ -23,8 +23,8 @@ class CANBackend:
|
|||
# PU mapping: PU1->0x02, PU2->0x03, PU3->0x04
|
||||
node_map = {
|
||||
1: 0x02,
|
||||
2: 0x03,
|
||||
3: 0x04
|
||||
2: 0x04,
|
||||
3: 0x127
|
||||
}
|
||||
|
||||
for pu_number, node_id in node_map.items():
|
||||
|
|
@ -61,11 +61,30 @@ class CANBackend:
|
|||
# Poll only PU1 (node ID 0x02) for live monitor values
|
||||
node = self.nodes.get(1)
|
||||
if node:
|
||||
fm1 = node.sdo[0x2004][1].raw
|
||||
fm2 = node.sdo[0x2004][2].raw
|
||||
fm3 = node.sdo[0x2004][3].raw
|
||||
fm4 = node.sdo[0x2004][4].raw
|
||||
|
||||
ps1 = node.sdo[0x2005][1].raw
|
||||
ps2 = node.sdo[0x2005][2].raw
|
||||
ps3 = node.sdo[0x2005][3].raw
|
||||
ps4 = node.sdo[0x2005][4].raw
|
||||
|
||||
self.latest_data["FM1"] = fm1 / 100.0
|
||||
self.latest_data["FM2"] = fm2 / 100.0
|
||||
self.latest_data["FM3"] = fm3 / 100.0
|
||||
self.latest_data["FM4"] = fm4 / 100.0
|
||||
|
||||
self.latest_data["PS1"] = ps1 / 1000.0
|
||||
print(f"[SDO POLL] FM2: {fm2}, PS1: {ps1}")
|
||||
self.latest_data["PS2"] = ps2 / 1000.0
|
||||
self.latest_data["PS3"] = ps3 / 1000.0
|
||||
self.latest_data["PS4"] = ps4 / 1000.0
|
||||
|
||||
print(f"[SDO POLL] FM1: {fm1}, PS1: {ps1}")
|
||||
print(f"[SDO POLL] FM2: {fm2}, PS2: {ps2}")
|
||||
print(f"[SDO POLL] FM3: {fm3}, PS3: {ps3}")
|
||||
print(f"[SDO POLL] FM4: {fm4}, PS4: {ps4}")
|
||||
except Exception as e:
|
||||
print(f"[SDO POLL ERROR] {e}")
|
||||
time.sleep(1.0)
|
||||
|
|
@ -112,7 +131,8 @@ class CANBackend:
|
|||
|
||||
state_map = {
|
||||
"IDLE": 1,
|
||||
"PRODUCTION": 2,
|
||||
"PRE-PRODUCTION": 2,
|
||||
"PRODUCTION" : 3,
|
||||
"MAINTENANCE": 8,
|
||||
"EMERGENCY_STOP": 9,
|
||||
"FIRST_START": 10
|
||||
|
|
|
|||
23
main.py
23
main.py
|
|
@ -108,11 +108,28 @@ def connect_toggle():
|
|||
|
||||
@app.post("/command/{state}/pu/{pu_number}")
|
||||
def send_command(state: str, pu_number: int, ploop_setpoint: float = Query(...)):
|
||||
"""Send a state command to a specific PU."""
|
||||
VALID_STATES = {
|
||||
"IDLE", "PRE-PRODUCTION", "PRODUCTION", "FIRST_START",
|
||||
"THERMALLOOPCLEANING", "DISINFECTION", "SLEEP"
|
||||
}
|
||||
|
||||
state = state.upper()
|
||||
|
||||
if state not in VALID_STATES:
|
||||
raise HTTPException(status_code=400, detail=f"Invalid state '{state}'")
|
||||
|
||||
logging.info(f"Sending state '{state}' to PU {pu_number}")
|
||||
|
||||
try:
|
||||
can_backend.send_state_command(state.upper(), pu_number, ploop_setpoint)
|
||||
return {"status": "success", "command": state.upper(), "pu": pu_number, "ploop_setpoint": ploop_setpoint}
|
||||
can_backend.send_state_command(state, pu_number, ploop_setpoint)
|
||||
current_state = can_backend.read_current_state(pu_number)
|
||||
return {
|
||||
"status": "success",
|
||||
"command": state,
|
||||
"pu": pu_number,
|
||||
"ploop_setpoint": ploop_setpoint,
|
||||
"current_state": current_state
|
||||
}
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
|
|
|||
|
|
@ -10,12 +10,14 @@
|
|||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow-x: hidden; /* ✅ prevent horizontal scroll */
|
||||
height: 100vh;
|
||||
background-color: #121212;
|
||||
color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.header {
|
||||
background-color: #1e1e1e;
|
||||
padding: 10px 20px;
|
||||
|
|
@ -35,13 +37,15 @@
|
|||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.connected {
|
||||
background-color: #00C851;
|
||||
}
|
||||
.connected { background-color: #00C851; }
|
||||
.container {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
max-width: 100vw;
|
||||
overflow-x: hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.left-panel, .right-panel {
|
||||
flex: 1;
|
||||
padding: 20px;
|
||||
|
|
@ -61,10 +65,7 @@
|
|||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
.pu-buttons {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.pu-buttons { display: flex; gap: 10px; }
|
||||
.mode-block button {
|
||||
background-color: #4285F4;
|
||||
color: white;
|
||||
|
|
@ -76,15 +77,14 @@
|
|||
transition: background-color 0.3s;
|
||||
flex: 1;
|
||||
}
|
||||
.mode-block button:hover {
|
||||
background-color: #3367d6;
|
||||
}
|
||||
.mode-block button.active {
|
||||
background-color: #00C851;
|
||||
}
|
||||
.pu-status {
|
||||
margin-top: 20px;
|
||||
.mode-block button:hover {
|
||||
background-color: #3367d6;
|
||||
}
|
||||
.mode-block button.active { background-color: #00C851; }
|
||||
.mode-block button.in-progress { background-color: #ffcc00; color: #000; }
|
||||
.mode-block button.ready { background-color: #00C851; color: #fff; }
|
||||
.mode-block button.disabled { background-color: #777; cursor: not-allowed; }
|
||||
.pu-status { margin-top: 20px; }
|
||||
.pu-item {
|
||||
background-color: #333;
|
||||
padding: 10px;
|
||||
|
|
@ -100,12 +100,6 @@
|
|||
border-radius: 5px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.monitor-block h2 {
|
||||
margin-top: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.monitor-values {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
|
|
@ -118,6 +112,48 @@
|
|||
text-align: center;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.slider-container {
|
||||
background-color: #1e1e1e;
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
color: #fff;
|
||||
width: 95%;
|
||||
}
|
||||
.slider-container label {
|
||||
font-size: 1.2rem;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;
|
||||
display: block;
|
||||
}
|
||||
.slider-values {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 1rem;
|
||||
margin-bottom: 8px;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.slider-values span#currentValue {
|
||||
font-weight: bold;
|
||||
color: #00bfff;
|
||||
}
|
||||
.slider {
|
||||
width: 100%;
|
||||
height: 8px;
|
||||
border-radius: 5px;
|
||||
background: #444;
|
||||
outline: none;
|
||||
appearance: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.slider::-webkit-slider-thumb, .slider::-moz-range-thumb {
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
background: #007bff;
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
}
|
||||
.monitor-link {
|
||||
color: white;
|
||||
background-color: #007bff;
|
||||
|
|
@ -125,216 +161,173 @@
|
|||
border-radius: 5px;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
.monitor-link:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
.slider-container {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.slider-container label {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.slider-container input {
|
||||
width: 100%;
|
||||
}
|
||||
.monitor-link:hover { background-color: #0056b3; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h1>Hydraulic Machine Control</h1>
|
||||
<a href="/monitor-page" target="_blank" rel="noopener noreferrer" class="monitor-link">
|
||||
<i class="fas fa-chart-line"></i> Monitor
|
||||
</a>
|
||||
<button id="connectButton" class="connect-button" onclick="toggleConnection()">
|
||||
<i class="fas fa-power-off"></i> Connect
|
||||
</button>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="left-panel">
|
||||
<div class="mode-block">
|
||||
<div class="pu-buttons">
|
||||
<button onclick="sendCommand('IDLE', 1, this)"><i class="fas fa-power-off"></i> IDLE PU 1</button>
|
||||
<button onclick="sendCommand('IDLE', 2, this)"><i class="fas fa-power-off"></i> IDLE PU 2</button>
|
||||
<button onclick="sendCommand('IDLE', 3, this)"><i class="fas fa-power-off"></i> IDLE PU 3</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mode-block">
|
||||
<div class="pu-buttons">
|
||||
<button onclick="sendCommand('PRODUCTION', 1, this)"><i class="fas fa-power-off"></i> PROD PU 1</button>
|
||||
<button onclick="sendCommand('PRODUCTION', 2, this)"><i class="fas fa-power-off"></i> PROD PU 2</button>
|
||||
<button onclick="sendCommand('PRODUCTION', 3, this)"><i class="fas fa-power-off"></i> PROD PU 3</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mode-block">
|
||||
<div class="pu-buttons">
|
||||
<button onclick="sendCommand('FIRST_START', 1, this)"><i class="fas fa-power-off"></i> FIRST START PU 1</button>
|
||||
<button onclick="sendCommand('FIRST_START', 2, this)"><i class="fas fa-power-off"></i> FIRST START PU 2</button>
|
||||
<button onclick="sendCommand('FIRST_START', 3, this)"><i class="fas fa-power-off"></i> FIRST START PU 3</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="slider-container">
|
||||
<label for="ploopSetpoint">P-loop Setpoint (bars):</label>
|
||||
<div class="slider-values">
|
||||
<span id="minValue">0.5</span>
|
||||
<span id="currentValue">1.0</span>
|
||||
<span id="maxValue">3.5</span>
|
||||
</div>
|
||||
<input type="range" min="0.5" max="3.5" step="0.1" value="1.0" id="ploopSetpoint" class="slider" oninput="updatePloopSetpoint(this.value)">
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function updatePloopSetpoint(value) {
|
||||
document.getElementById('currentValue').textContent = value;
|
||||
}
|
||||
</script>
|
||||
<div class="mode-block">
|
||||
<button onclick="sendCommand('ThermalLoopCleaning', 0, this)"><i class="fas fa-fire"></i> Thermal Loop Cleaning</button>
|
||||
</div>
|
||||
<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 2: </span><span id="pu2-status">Offline</span>
|
||||
</div>
|
||||
<div class="pu-item">
|
||||
<span>PU 3: </span><span id="pu3-status">Offline</span>
|
||||
</div>
|
||||
<div class="header">
|
||||
<h1>Hydraulic Machine Control</h1>
|
||||
<a href="/monitor-page" target="_blank" rel="noopener noreferrer" class="monitor-link">
|
||||
<i class="fas fa-chart-line"></i> Monitor
|
||||
</a>
|
||||
<button id="connectButton" class="connect-button" onclick="toggleConnection()">
|
||||
<i class="fas fa-power-off"></i> Connect
|
||||
</button>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="left-panel">
|
||||
<div class="mode-block">
|
||||
<div class="pu-buttons">
|
||||
<button onclick="sendCommand('IDLE', 1, this)"><i class="fas fa-power-off"></i> IDLE PU 1</button>
|
||||
<button onclick="sendCommand('IDLE', 2, this)"><i class="fas fa-power-off"></i> IDLE PU 2</button>
|
||||
<button onclick="sendCommand('IDLE', 3, this)"><i class="fas fa-power-off"></i> IDLE PU 3</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right-panel">
|
||||
<div class="monitor-block">
|
||||
<h2><i class="fas fa-tint"></i> Q Perm</h2>
|
||||
<div class="monitor-values" id="Qperm">
|
||||
<div class="monitor-value">#1<br>0.0 L/h</div>
|
||||
<div class="monitor-value">#2<br>0.0 L/h</div>
|
||||
<div class="monitor-value">#3<br>0.0 L/h</div>
|
||||
</div>
|
||||
<div class="mode-block">
|
||||
<div class="pu-buttons">
|
||||
<button data-action="PRE-PRODUCTION" data-pu="1"><i class="fas fa-play"></i> PRE-PROD PU 1</button>
|
||||
<button data-action="PRE-PRODUCTION" data-pu="2"><i class="fas fa-play"></i> PRE-PROD PU 2</button>
|
||||
<button data-action="PRE-PRODUCTION" data-pu="3"><i class="fas fa-play"></i> PRE-PROD PU 3</button>
|
||||
</div>
|
||||
<div class="monitor-block">
|
||||
<h2><i class="fas fa-water"></i> P Dilute</h2>
|
||||
<div class="monitor-values" id="Pdilute">
|
||||
<div class="monitor-value">#1<br>0.0 bar</div>
|
||||
<div class="monitor-value">#2<br>0.0 bar</div>
|
||||
<div class="monitor-value">#3<br>0.0 bar</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mode-block">
|
||||
<div class="pu-buttons">
|
||||
<button onclick="sendCommand('FIRST_START', 1, this)"><i class="fas fa-power-off"></i> FIRST START PU 1</button>
|
||||
<button onclick="sendCommand('FIRST_START', 2, this)"><i class="fas fa-power-off"></i> FIRST START PU 2</button>
|
||||
<button onclick="sendCommand('FIRST_START', 3, this)"><i class="fas fa-power-off"></i> FIRST START PU 3</button>
|
||||
</div>
|
||||
<div class="monitor-block">
|
||||
<h2><i class="fas fa-bolt"></i> Conductivity</h2>
|
||||
<div class="monitor-values" id="Conductivity">
|
||||
<div class="monitor-value">#1<br>0.0 µS/cm</div>
|
||||
<div class="monitor-value">#2<br>0.0 µS/cm</div>
|
||||
<div class="monitor-value">#3<br>0.0 µS/cm</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="slider-container">
|
||||
<label for="ploopSetpoint">P-loop Setpoint (bars):</label>
|
||||
<div class="slider-values">
|
||||
<span id="minValue">0.5</span>
|
||||
<span id="currentValue">1.0</span>
|
||||
<span id="maxValue">3.5</span>
|
||||
</div>
|
||||
<div class="monitor-block">
|
||||
<h2><i class="fas fa-thermometer-half"></i> Pro</h2>
|
||||
<div class="monitor-values" id="Pro">
|
||||
<div class="monitor-value">#1<br>0.0 units</div>
|
||||
<div class="monitor-value">#2<br>0.0 units</div>
|
||||
<div class="monitor-value">#3<br>0.0 units</div>
|
||||
</div>
|
||||
<input type="range" min="0.5" max="3.5" step="0.1" value="1.0" id="ploopSetpoint" class="slider" oninput="updatePloopSetpoint(this.value)">
|
||||
</div>
|
||||
<div class="mode-block">
|
||||
<button onclick="sendCommand('ThermalLoopCleaning', 0, this)"><i class="fas fa-fire"></i> Thermal Loop Cleaning</button>
|
||||
</div>
|
||||
<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 2: </span><span id="pu2-status">Offline</span></div>
|
||||
<div class="pu-item"><span>PU 3: </span><span id="pu3-status">Offline</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right-panel">
|
||||
<div class="monitor-block">
|
||||
<h2><i class="fas fa-tint"></i> Q Perm</h2>
|
||||
<div class="monitor-values" id="Qperm">
|
||||
<div class="monitor-value">#1<br>0.0 L/h</div>
|
||||
<div class="monitor-value">#2<br>0.0 L/h</div>
|
||||
<div class="monitor-value">#3<br>0.0 L/h</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="monitor-block">
|
||||
<h2><i class="fas fa-water"></i> P Dilute</h2>
|
||||
<div class="monitor-values" id="Pdilute">
|
||||
<div class="monitor-value">#1<br>0.0 bar</div>
|
||||
<div class="monitor-value">#2<br>0.0 bar</div>
|
||||
<div class="monitor-value">#3<br>0.0 bar</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="monitor-block">
|
||||
<h2><i class="fas fa-bolt"></i> Conductivity</h2>
|
||||
<div class="monitor-values" id="Conductivity">
|
||||
<div class="monitor-value">#1<br>0.0 µS/cm</div>
|
||||
<div class="monitor-value">#2<br>0.0 µS/cm</div>
|
||||
<div class="monitor-value">#3<br>0.0 µS/cm</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="monitor-block">
|
||||
<h2><i class="fas fa-thermometer-half"></i> Pro</h2>
|
||||
<div class="monitor-values" id="Pro">
|
||||
<div class="monitor-value">#1<br>0.0 units</div>
|
||||
<div class="monitor-value">#2<br>0.0 units</div>
|
||||
<div class="monitor-value">#3<br>0.0 units</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
async function toggleConnection() {
|
||||
const response = await fetch('/connect_toggle', {
|
||||
method: 'POST'
|
||||
});
|
||||
const data = await response.json();
|
||||
const connectButton = document.getElementById('connectButton');
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
async function sendCommand(state, puNumber, buttonEl) {
|
||||
const ploopSetpoint = document.getElementById('ploopSetpoint').value;
|
||||
const response = await fetch(`/command/${state}/pu/${puNumber}?ploop_setpoint=${ploopSetpoint}`, {
|
||||
method: 'POST'
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
console.error('Failed to send command');
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
console.log(data);
|
||||
|
||||
// Reset all buttons
|
||||
document.querySelectorAll('.mode-block button').forEach(button => {
|
||||
button.classList.remove('active');
|
||||
});
|
||||
|
||||
async function fetchPUStatus() {
|
||||
try {
|
||||
const response = await fetch("/api/pu_status"); // Replace with your actual endpoint
|
||||
const data = await response.json();
|
||||
|
||||
// Assume response is like:
|
||||
// { "PU1": "Online", "PU2": "Offline", "PU3": "Online" }
|
||||
|
||||
document.getElementById("pu1-status").textContent = data.PU1 || "Unknown";
|
||||
document.getElementById("pu2-status").textContent = data.PU2 || "Unknown";
|
||||
document.getElementById("pu3-status").textContent = data.PU3 || "Unknown";
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch PU status:", error);
|
||||
}
|
||||
}
|
||||
|
||||
// Call it on load and then every 5 seconds
|
||||
fetchPUStatus();
|
||||
setInterval(fetchPUStatus, 5000);
|
||||
|
||||
|
||||
// Set the clicked button to active
|
||||
buttonEl.classList.add('active');
|
||||
|
||||
<script>
|
||||
function updatePloopSetpoint(value) {
|
||||
document.getElementById('currentValue').textContent = value;
|
||||
}
|
||||
|
||||
async function toggleConnection() {
|
||||
const response = await fetch('/connect_toggle', { method: 'POST' });
|
||||
const data = await response.json();
|
||||
const connectButton = document.getElementById('connectButton');
|
||||
connectButton.classList.toggle('connected', data.connected);
|
||||
connectButton.innerHTML = `<i class="fas fa-power-off"></i> ${data.connected ? 'Disconnect' : 'Connect'}`;
|
||||
}
|
||||
|
||||
async function sendCommand(state, puNumber, buttonEl) {
|
||||
const ploopSetpoint = document.getElementById('ploopSetpoint').value;
|
||||
const response = await fetch(`/command/${state}/pu/${puNumber}?ploop_setpoint=${ploopSetpoint}`, { method: 'POST' });
|
||||
if (!response.ok) return;
|
||||
buttonEl.classList.add('in-progress');
|
||||
buttonEl.textContent = `Waiting... PU ${puNumber}`;
|
||||
|
||||
async function checkReady() {
|
||||
const res = await fetch(`/api/pu_status`);
|
||||
const states = await res.json();
|
||||
const currentState = states[`PU${puNumber}`];
|
||||
if (currentState === 'SYSTEM_MODE_READY') {
|
||||
buttonEl.classList.remove('in-progress');
|
||||
buttonEl.classList.add('ready');
|
||||
buttonEl.textContent = `START PRODUCTION PU ${puNumber}`;
|
||||
buttonEl.onclick = () => sendCommand("PRODUCTION", puNumber, buttonEl);
|
||||
} else {
|
||||
setTimeout(checkReady, 1000);
|
||||
}
|
||||
}
|
||||
checkReady();
|
||||
}
|
||||
|
||||
async function fetchPUStatus() {
|
||||
const response = await fetch("/api/pu_status");
|
||||
const data = await response.json();
|
||||
document.getElementById("pu1-status").textContent = data.PU1 || "Unknown";
|
||||
document.getElementById("pu2-status").textContent = data.PU2 || "Unknown";
|
||||
document.getElementById("pu3-status").textContent = data.PU3 || "Unknown";
|
||||
}
|
||||
fetchPUStatus();
|
||||
setInterval(fetchPUStatus, 5000);
|
||||
|
||||
async function updateMonitorData() {
|
||||
const response = await fetch('/monitor');
|
||||
const data = await response.json(); // data = { PU_1: {...}, PU_2: {...}, PU_3: {...} }
|
||||
const response = await fetch('/monitor');
|
||||
const data = await response.json(); // data = { PU_1: {...}, PU_2: {...}, PU_3: {...} }
|
||||
|
||||
for (const [puId, puData] of Object.entries(data)) {
|
||||
const container = document.getElementById(puId);
|
||||
if (!container) continue;
|
||||
for (const [puId, puData] of Object.entries(data)) {
|
||||
const container = document.getElementById(puId);
|
||||
if (!container) continue;
|
||||
|
||||
container.innerHTML = `
|
||||
<h3>${puId}</h3>
|
||||
<div class="monitor-value">Q_perm<br>${puData.Qperm.toFixed(1)} L/h</div>
|
||||
<div class="monitor-value">Q_dilute<br>${puData.Qdilute.toFixed(1)} L/h</div>
|
||||
<div class="monitor-value">Q_drain<br>${puData.Qdrain.toFixed(1)} L/h</div>
|
||||
<div class="monitor-value">Q_recirc<br>${puData.Qrecirc.toFixed(1)} L/h</div>
|
||||
container.innerHTML = `
|
||||
<h3>${puId}</h3>
|
||||
<div class="monitor-value">Q_perm<br>${puData.Qperm.toFixed(1)} L/h</div>
|
||||
<div class="monitor-value">Q_dilute<br>${puData.Qdilute.toFixed(1)} L/h</div>
|
||||
<div class="monitor-value">Q_drain<br>${puData.Qdrain.toFixed(1)} L/h</div>
|
||||
<div class="monitor-value">Q_recirc<br>${puData.Qrecirc.toFixed(1)} L/h</div>
|
||||
|
||||
<div class="monitor-value">P_ro<br>${puData.Pro.toFixed(1)} bar</div>
|
||||
<div class="monitor-value">P_dilute<br>${puData.Pdilute.toFixed(1)} bar</div>
|
||||
<div class="monitor-value">P_rentate<br>${puData.Prentate.toFixed(1)} bar</div>
|
||||
<div class="monitor-value">P_ro<br>${puData.Pro.toFixed(1)} bar</div>
|
||||
<div class="monitor-value">P_dilute<br>${puData.Pdilute.toFixed(1)} bar</div>
|
||||
<div class="monitor-value">P_rentate<br>${puData.Prentate.toFixed(1)} bar</div>
|
||||
|
||||
<div class="monitor-value">Conductivity<br>${puData.Conductivity.toFixed(1)} µS/cm</div>
|
||||
<div class="monitor-value">Conductivity<br>${puData.Conductivity.toFixed(1)} µS/cm</div>
|
||||
|
||||
<div class="monitor-value">MV02<br>${puData.MV02.toFixed(1)} % (sp: ${puData.MV02_sp.toFixed(1)})</div>
|
||||
<div class="monitor-value">MV03<br>${puData.MV03.toFixed(1)} % (sp: ${puData.MV03_sp.toFixed(1)})</div>
|
||||
<div class="monitor-value">MV05<br>${puData.MV05.toFixed(1)} % (sp: ${puData.MV05_sp.toFixed(1)})</div>
|
||||
<div class="monitor-value">MV06<br>${puData.MV06.toFixed(1)} % (sp: ${puData.MV06_sp.toFixed(1)})</div>
|
||||
<div class="monitor-value">MV07<br>${puData.MV07.toFixed(1)} % (sp: ${puData.MV07_sp.toFixed(1)})</div>
|
||||
<div class="monitor-value">MV08<br>${puData.MV08.toFixed(1)} % (sp: ${puData.MV08_sp.toFixed(1)})</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
<div class="monitor-value">MV02<br>${puData.MV02.toFixed(1)} % (sp: ${puData.MV02_sp.toFixed(1)})</div>
|
||||
<div class="monitor-value">MV03<br>${puData.MV03.toFixed(1)} % (sp: ${puData.MV03_sp.toFixed(1)})</div>
|
||||
<div class="monitor-value">MV05<br>${puData.MV05.toFixed(1)} % (sp: ${puData.MV05_sp.toFixed(1)})</div>
|
||||
<div class="monitor-value">MV06<br>${puData.MV06.toFixed(1)} % (sp: ${puData.MV06_sp.toFixed(1)})</div>
|
||||
<div class="monitor-value">MV07<br>${puData.MV07.toFixed(1)} % (sp: ${puData.MV07_sp.toFixed(1)})</div>
|
||||
<div class="monitor-value">MV08<br>${puData.MV08.toFixed(1)} % (sp: ${puData.MV08_sp.toFixed(1)})</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
function updateMonitorValues(id, values, unit) {
|
||||
const container = document.getElementById(id);
|
||||
|
|
@ -350,7 +343,6 @@
|
|||
setInterval(updateMonitorData, 1000);
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
async function fetchMonitorData() {
|
||||
try {
|
||||
|
|
@ -383,6 +375,6 @@
|
|||
setInterval(fetchMonitorData, 1000);
|
||||
fetchMonitorData(); // Premier appel immédiat
|
||||
</script>
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user