Automatic PROD MODE html update
This commit is contained in:
parent
18c34a3334
commit
2ef90283d6
4
main.py
4
main.py
|
|
@ -81,7 +81,7 @@ def format_PU_data(data):
|
||||||
"timestamp": datetime.datetime.now().isoformat(),
|
"timestamp": datetime.datetime.now().isoformat(),
|
||||||
"Qperm": np.round(data.get("FM2", 0.0), 1),
|
"Qperm": np.round(data.get("FM2", 0.0), 1),
|
||||||
"Qdilute": np.round(data.get("FM1", 0.0), 1),
|
"Qdilute": np.round(data.get("FM1", 0.0), 1),
|
||||||
"Qdrain": max(np.round(data.get("FM4", 0.0), 1),350.0),
|
"Qdrain": np.round(data.get("FM4", 0.0), 1),
|
||||||
"Qrecirc": np.round(data.get("FM3", 0.0), 1),
|
"Qrecirc": np.round(data.get("FM3", 0.0), 1),
|
||||||
"QdrainEDI": np.round(data.get("FM2", 0.0), 1) - np.round(data.get("FM1", 0.0), 1),
|
"QdrainEDI": np.round(data.get("FM2", 0.0), 1) - np.round(data.get("FM1", 0.0), 1),
|
||||||
"Pro": np.round(data.get("PS2", 0.0), 2),
|
"Pro": np.round(data.get("PS2", 0.0), 2),
|
||||||
|
|
@ -104,7 +104,7 @@ def format_PU_data(data):
|
||||||
"MV07_sp": np.round(data.get("MV07_sp", 0.0), 1),
|
"MV07_sp": np.round(data.get("MV07_sp", 0.0), 1),
|
||||||
"MV08": np.round(data.get("MV08", 0.0), 1),
|
"MV08": np.round(data.get("MV08", 0.0), 1),
|
||||||
"MV08_sp": np.round(data.get("MV08_sp", 0.0), 1),
|
"MV08_sp": np.round(data.get("MV08_sp", 0.0), 1),
|
||||||
"Qdrain_sp" : 60*np.round(data.get("Qdrain_sp", 0.0), 2),
|
"Qdrain_sp" : max(60*np.round(data.get("Qdrain_sp", 0.0), 2),350.0),
|
||||||
}
|
}
|
||||||
|
|
||||||
def format_DS_data(data):
|
def format_DS_data(data):
|
||||||
|
|
|
||||||
|
|
@ -430,34 +430,48 @@
|
||||||
btn.classList.remove('in-progress', 'ready', 'production');
|
btn.classList.remove('in-progress', 'ready', 'production');
|
||||||
});
|
});
|
||||||
if (state === 'PRE-PRODUCTION') {
|
if (state === 'PRE-PRODUCTION') {
|
||||||
buttonEl.classList.add('in-progress');
|
buttonEl.classList.add('in-progress');
|
||||||
buttonEl.textContent = `Waiting... PU ${puNumber}`;
|
buttonEl.textContent = `Waiting... PU ${puNumber}`;
|
||||||
buttonEl.disabled = true;
|
buttonEl.disabled = true;
|
||||||
const checkReady = async () => {
|
|
||||||
const res = await fetch(`/api/pu_status`);
|
const checkReady = async () => {
|
||||||
const states = await res.json();
|
const res = await fetch(`/api/pu_status`);
|
||||||
const currentState = states[`PU${puNumber}`];
|
const states = await res.json();
|
||||||
if (currentState === 'SYSTEM_MODE_READY') {
|
const currentState = states[`PU${puNumber}`];
|
||||||
buttonEl.classList.remove('in-progress');
|
|
||||||
buttonEl.classList.add('ready');
|
if (currentState === 'SYSTEM_MODE_READY') {
|
||||||
buttonEl.textContent = `START PRODUCTION PU ${puNumber}`;
|
buttonEl.classList.remove('in-progress');
|
||||||
buttonEl.disabled = false;
|
buttonEl.classList.add('ready');
|
||||||
buttonEl.onclick = async () => {
|
buttonEl.textContent = `START PRODUCTION PU ${puNumber}`;
|
||||||
await sendCommand("PRODUCTION", puNumber, buttonEl);
|
buttonEl.disabled = false;
|
||||||
buttonEl.classList.remove('ready');
|
|
||||||
buttonEl.classList.add('production');
|
buttonEl.onclick = async () => {
|
||||||
buttonEl.textContent = `PRODUCTION ON PU ${puNumber}`;
|
await sendCommand("PRODUCTION", puNumber, buttonEl);
|
||||||
buttonEl.disabled = true;
|
buttonEl.classList.remove('ready');
|
||||||
};
|
|
||||||
} else {
|
|
||||||
setTimeout(checkReady, 1000);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
checkReady();
|
|
||||||
} else if (state === 'PRODUCTION') {
|
|
||||||
buttonEl.classList.add('production');
|
buttonEl.classList.add('production');
|
||||||
buttonEl.textContent = `PRODUCTION ON PU ${puNumber}`;
|
buttonEl.textContent = `PRODUCTION ON PU ${puNumber}`;
|
||||||
} else if (state === 'IDLE' || state === 'FIRST_START') {
|
buttonEl.disabled = true;
|
||||||
|
};
|
||||||
|
} else if (currentState === 'PRODUCTION') {
|
||||||
|
// ✅ Directly update if already in production
|
||||||
|
buttonEl.classList.remove('in-progress');
|
||||||
|
buttonEl.classList.add('production');
|
||||||
|
buttonEl.textContent = `PRODUCTION ON PU ${puNumber}`;
|
||||||
|
buttonEl.disabled = true;
|
||||||
|
} else {
|
||||||
|
setTimeout(checkReady, 1000);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
checkReady();
|
||||||
|
|
||||||
|
} else if (state === 'PRODUCTION') {
|
||||||
|
// ✅ Handles initial load case
|
||||||
|
buttonEl.classList.add('production');
|
||||||
|
buttonEl.textContent = `PRODUCTION ON PU ${puNumber}`;
|
||||||
|
buttonEl.disabled = true;
|
||||||
|
}
|
||||||
|
else if (state === 'IDLE' || state === 'FIRST_START') {
|
||||||
buttonEl.classList.remove('in-progress', 'ready', 'production');
|
buttonEl.classList.remove('in-progress', 'ready', 'production');
|
||||||
buttonEl.classList.add('production');
|
buttonEl.classList.add('production');
|
||||||
buttonEl.textContent = `${state.replace('_', ' ')} PU ${puNumber}`;
|
buttonEl.textContent = `${state.replace('_', ' ')} PU ${puNumber}`;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user