453 lines
18 KiB
HTML
453 lines
18 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Hydraulic Machine Control</title>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
margin: 0;
|
|
padding: 0;
|
|
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;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
.connect-button {
|
|
background-color: #ff4444;
|
|
color: white;
|
|
border: none;
|
|
padding: 10px 20px;
|
|
font-size: 16px;
|
|
cursor: pointer;
|
|
border-radius: 5px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
.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;
|
|
overflow-y: auto;
|
|
}
|
|
.left-panel {
|
|
background-color: #1e1e1e;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
}
|
|
.mode-block {
|
|
background-color: #333;
|
|
padding: 15px;
|
|
border-radius: 5px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
}
|
|
.pu-buttons { display: flex; gap: 10px; }
|
|
.mode-block button {
|
|
background-color: #4285F4;
|
|
color: white;
|
|
border: none;
|
|
padding: 10px;
|
|
cursor: pointer;
|
|
border-radius: 5px;
|
|
font-size: 14px;
|
|
transition: background-color 0.3s;
|
|
flex: 1;
|
|
}
|
|
.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; }
|
|
.in-progress {
|
|
background-color: yellow !important;
|
|
color: black !important;
|
|
}
|
|
|
|
.ready {
|
|
background-color: orange !important;
|
|
color: black !important;
|
|
}
|
|
|
|
.production {
|
|
background-color: green !important;
|
|
color: white !important;
|
|
}
|
|
|
|
.pu-status { margin-top: 20px; }
|
|
.pu-item {
|
|
background-color: #333;
|
|
padding: 10px;
|
|
border-radius: 5px;
|
|
margin-bottom: 10px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
.monitor-block {
|
|
background-color: #333;
|
|
padding: 15px;
|
|
border-radius: 5px;
|
|
margin-bottom: 15px;
|
|
}
|
|
.monitor-values {
|
|
display: grid;
|
|
grid-template-columns: repeat(3, 1fr);
|
|
gap: 10px;
|
|
margin-top: 10px;
|
|
}
|
|
.monitor-value {
|
|
background-color: #444;
|
|
padding: 10px;
|
|
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;
|
|
padding: 10px 15px;
|
|
border-radius: 5px;
|
|
text-decoration: none;
|
|
font-weight: bold;
|
|
}
|
|
.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)" data-action="IDLE" data-pu="1"><i class="fas fa-power-off"></i> IDLE PU 1</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 class="mode-block">
|
|
<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', 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 class="mode-block">
|
|
<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', 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 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>
|
|
<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>
|
|
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;
|
|
|
|
// Send command to backend
|
|
await fetch(`/command/${state}/pu/${puNumber}?ploop_setpoint=${ploopSetpoint}`, { method: 'POST' });
|
|
|
|
// Reset button styles
|
|
document.querySelectorAll('button').forEach(btn => {
|
|
btn.classList.remove('in-progress', 'ready', 'production');
|
|
});
|
|
|
|
// Handle PRE-PRODUCTION sequence
|
|
if (state === 'PRE-PRODUCTION') {
|
|
buttonEl.classList.add('in-progress');
|
|
buttonEl.textContent = `Waiting... PU ${puNumber}`;
|
|
buttonEl.disabled = true;
|
|
|
|
const checkReady = async () => {
|
|
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.disabled = false;
|
|
|
|
buttonEl.onclick = async () => {
|
|
await sendCommand("PRODUCTION", puNumber, buttonEl);
|
|
buttonEl.classList.remove('ready');
|
|
buttonEl.classList.add('production');
|
|
buttonEl.textContent = `PRODUCTION ON PU ${puNumber}`;
|
|
buttonEl.disabled = true;
|
|
};
|
|
} else {
|
|
setTimeout(checkReady, 1000);
|
|
}
|
|
};
|
|
|
|
checkReady();
|
|
|
|
} else if (state === 'PRODUCTION') {
|
|
buttonEl.classList.add('production');
|
|
buttonEl.textContent = `PRODUCTION ON PU ${puNumber}`;
|
|
|
|
} else if (state === 'IDLE' || state === 'FIRST_START') {
|
|
buttonEl.classList.remove('in-progress', 'ready', 'production');
|
|
buttonEl.classList.add('production');
|
|
buttonEl.textContent = `${state.replace('_', ' ')} PU ${puNumber}`;
|
|
|
|
// === Reset PRE-PROD button ===
|
|
const preProdBtn = document.querySelector(`button[data-action="PRE-PRODUCTION"][data-pu="${puNumber}"]`);
|
|
if (preProdBtn) {
|
|
preProdBtn.classList.remove('in-progress', 'ready', 'production');
|
|
preProdBtn.innerHTML = `<i class="fas fa-play"></i> PRE-PROD PU ${puNumber}`;
|
|
preProdBtn.disabled = false;
|
|
preProdBtn.onclick = () => sendCommand("PRE-PRODUCTION", puNumber, preProdBtn);
|
|
}
|
|
|
|
// === Reset IDLE button ===
|
|
const idleBtn = document.querySelector(`button[data-action="IDLE"][data-pu="${puNumber}"]`);
|
|
if (idleBtn && idleBtn !== buttonEl) {
|
|
idleBtn.classList.remove('in-progress', 'ready', 'production');
|
|
idleBtn.innerHTML = `<i class="fas fa-power-off"></i> IDLE PU ${puNumber}`;
|
|
idleBtn.disabled = false;
|
|
idleBtn.onclick = () => sendCommand("IDLE", puNumber, idleBtn);
|
|
}
|
|
|
|
// === Reset FIRST START button ===
|
|
const firstStartBtn = document.querySelector(`button[data-action="FIRST_START"][data-pu="${puNumber}"]`);
|
|
if (firstStartBtn && firstStartBtn !== buttonEl) {
|
|
firstStartBtn.classList.remove('in-progress', 'ready', 'production');
|
|
firstStartBtn.innerHTML = `<i class="fas fa-power-off"></i> FIRST START PU ${puNumber}`;
|
|
firstStartBtn.disabled = false;
|
|
firstStartBtn.onclick = () => sendCommand("FIRST_START", puNumber, firstStartBtn);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
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: {...} }
|
|
|
|
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>
|
|
|
|
<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">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);
|
|
const valueElements = container.querySelectorAll('.monitor-value');
|
|
valueElements.forEach((element, index) => {
|
|
if (index < values.length) {
|
|
element.innerHTML = `#${index + 1}<br>${values[index]} ${unit}`;
|
|
}
|
|
});
|
|
}
|
|
|
|
// Update monitor data every second
|
|
setInterval(updateMonitorData, 1000);
|
|
</script>
|
|
|
|
<script>
|
|
async function fetchMonitorData() {
|
|
try {
|
|
const response = await fetch('/monitor');
|
|
const data = await response.json();
|
|
|
|
const keys = ["PU_1", "PU_2", "PU_3"];
|
|
const fields = {
|
|
"Qperm": "L/h",
|
|
"Pdilute": "bar",
|
|
"Conductivity": "µS/cm",
|
|
"Pro": "bar"
|
|
};
|
|
|
|
for (const field in fields) {
|
|
const container = document.getElementById(field);
|
|
if (!container) continue;
|
|
|
|
container.innerHTML = keys.map((pu, i) => {
|
|
const value = data[pu]?.[field] ?? 0.0;
|
|
return `<div class="monitor-value">#${i + 1}<br>${value.toFixed(1)} ${fields[field]}</div>`;
|
|
}).join('');
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('Erreur lors de la récupération des données de /monitor :', error);
|
|
}
|
|
}
|
|
|
|
setInterval(fetchMonitorData, 1000);
|
|
fetchMonitorData(); // First call
|
|
</script>
|
|
</body>
|
|
</html>
|