updates to html page

This commit is contained in:
aniketSaha 2025-08-05 13:23:03 +02:00
parent 79b9f2d95d
commit efd44dbf3e
2 changed files with 178 additions and 166 deletions

View File

@ -31,7 +31,7 @@ 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.INFO) logging.basicConfig(level=logging.DEBUG)
logging.getLogger("uvicorn.access").setLevel(logging.WARNING) logging.getLogger("uvicorn.access").setLevel(logging.WARNING)
@ -392,6 +392,7 @@ async def auto_test_pu3():
# PATIENT SKID HELPERS # PATIENT SKID HELPERS
async def update_latest_flow(): async def update_latest_flow():
global active_PUs
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
while True: while True:
try: try:
@ -400,6 +401,9 @@ async def update_latest_flow():
latest_flow = int(data["log"]["flow"]) latest_flow = int(data["log"]["flow"])
logging.debug(f"Updated flow: {latest_flow}") logging.debug(f"Updated flow: {latest_flow}")
latest_data["PatientSkid"]["QSkid"] = latest_flow latest_data["PatientSkid"]["QSkid"] = latest_flow
# for index in active_PUs :
# logging.debug("PU_"+str(index))
# latest_data["PU_"+str(index)]["QSkid"] = latest_flow # Adding the data to all actives PUs
except Exception as e: except Exception as e:
logging.error(f"Error fetching flow: {e}") logging.error(f"Error fetching flow: {e}")

View File

@ -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" />
@ -11,23 +12,28 @@
margin: 0; margin: 0;
padding: 20px; padding: 20px;
} }
.plot-container { .plot-container {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: center; justify-content: center;
gap: 20px; gap: 20px;
} }
.large-plot { .large-plot {
width: 45%; width: 45%;
height: 300px; height: 300px;
} }
.small-plot { .small-plot {
width: 30%; width: 30%;
height: 250px; height: 250px;
} }
h1 { h1 {
text-align: center; text-align: center;
} }
.status-container { .status-container {
background-color: #f0f0f0; background-color: #f0f0f0;
padding: 10px; padding: 10px;
@ -38,6 +44,7 @@
} }
</style> </style>
</head> </head>
<body> <body>
<h1 id="pageTitle">Live Monitoring Dashboard</h1> <h1 id="pageTitle">Live Monitoring Dashboard</h1>
<div class="status-container"> <div class="status-container">
@ -50,12 +57,12 @@
<div id="flow-plot-2" class="large-plot"></div> <div id="flow-plot-2" class="large-plot"></div>
<div id="pressure-plot-2" class="large-plot"></div> <div id="pressure-plot-2" class="large-plot"></div>
<div id="conductivity-plot" class="large-plot"></div> <div id="conductivity-plot" class="large-plot"></div>
<div id="MV02_sp-plot" class="small-plot"></div> <div id="MV07-plot" class="small-plot"></div>
<div id="MV03_sp-plot" class="small-plot"></div> <div id="MV02-plot" class="small-plot"></div>
<div id="MV03-plot" class="small-plot"></div>
<div id="MV04_sp-05-plot" class="small-plot"></div> <div id="MV04_sp-05-plot" class="small-plot"></div>
<div id="MV06_sp-plot" class="small-plot"></div> <div id="MV06-plot" class="small-plot"></div>
<div id="MV07_sp-plot" class="small-plot"></div> <div id="MV08-plot" class="small-plot"></div>
<div id="MV08_sp-plot" class="small-plot"></div>
</div> </div>
<script> <script>
@ -63,7 +70,7 @@
const puNumber = urlParams.get('pu_number') || '1'; const puNumber = urlParams.get('pu_number') || '1';
document.getElementById('pageTitle').textContent = `Live Monitoring Dashboard - PU ${puNumber}`; document.getElementById('pageTitle').textContent = `Live Monitoring Dashboard - PU ${puNumber}`;
const maxPoints = 100; const maxPoints = 50;
async function updatePlots() { async function updatePlots() {
try { try {
@ -99,13 +106,17 @@
y: [[puData.Cfeed], [puData.Cperm], [puData.Cdilute]] y: [[puData.Cfeed], [puData.Cperm], [puData.Cdilute]]
}, [0, 1, 2], maxPoints); }, [0, 1, 2], maxPoints);
Plotly.extendTraces('MV07-plot', {
x: [[t], [t]],
y: [[puData.MV07_sp], [puData.MV07]]
}, [0, 1], maxPoints);
Plotly.extendTraces('MV02_sp-plot', { Plotly.extendTraces('MV02-plot', {
x: [[t], [t]], x: [[t], [t]],
y: [[puData.MV02_sp], [puData.MV02]] y: [[puData.MV02_sp], [puData.MV02]]
}, [0, 1], maxPoints); }, [0, 1], maxPoints);
Plotly.extendTraces('MV03_sp-plot', { Plotly.extendTraces('MV03-plot', {
x: [[t], [t]], x: [[t], [t]],
y: [[puData.MV03_sp], [puData.MV03]] y: [[puData.MV03_sp], [puData.MV03]]
}, [0, 1], maxPoints); }, [0, 1], maxPoints);
@ -115,17 +126,13 @@
y: [[puData.MV04_sp], [puData.MV04], [puData.MV05_sp], [puData.MV05]] y: [[puData.MV04_sp], [puData.MV04], [puData.MV05_sp], [puData.MV05]]
}, [0, 1, 2, 3], maxPoints); }, [0, 1, 2, 3], maxPoints);
Plotly.extendTraces('MV06_sp-plot', { Plotly.extendTraces('MV06-plot', {
x: [[t], [t]], x: [[t], [t]],
y: [[puData.MV06_sp], [puData.MV06]] y: [[puData.MV06_sp], [puData.MV06]]
}, [0, 1], maxPoints); }, [0, 1], maxPoints);
Plotly.extendTraces('MV07_sp-plot', {
x: [[t], [t]],
y: [[puData.MV07_sp], [puData.MV07]]
}, [0, 1], maxPoints);
Plotly.extendTraces('MV08_sp-plot', { Plotly.extendTraces('MV08-plot', {
x: [[t], [t]], x: [[t], [t]],
y: [[puData.MV08_sp], [puData.MV08]] y: [[puData.MV08_sp], [puData.MV08]]
}, [0, 1], maxPoints); }, [0, 1], maxPoints);
@ -190,18 +197,18 @@
}); });
Plotly.newPlot('MV02_sp-plot', [ Plotly.newPlot('MV02-plot', [
{ x: time0, y: [0], name: 'MV02_sp', mode: 'lines' }, { x: time0, y: [0], name: 'MV02_sp', mode: 'lines' },
{ x: time0, y: [0], name: 'MV02', mode: 'lines' } { x: time0, y: [0], name: 'MV02', mode: 'lines' }
], { ], {
title: 'MV02: Setpoint vs Actual', xaxis: { type: 'date' }, yaxis: { range: [0, 100] } title: 'MV02: Setpoint vs Actual', xaxis: { type: 'date' }, yaxis: {}
}); });
Plotly.newPlot('MV03_sp-plot', [ Plotly.newPlot('MV03-plot', [
{ x: time0, y: [0], name: 'MV03_sp', mode: 'lines' }, { x: time0, y: [0], name: 'MV03_sp', mode: 'lines' },
{ x: time0, y: [0], name: 'MV03', mode: 'lines' } { x: time0, y: [0], name: 'MV03', mode: 'lines' }
], { ], {
title: 'MV03: Setpoint vs Actual', xaxis: { type: 'date' }, yaxis: { range: [0, 100] } title: 'MV03: Setpoint vs Actual', xaxis: { type: 'date' }, yaxis: {}
}); });
Plotly.newPlot('MV04_sp-05-plot', [ Plotly.newPlot('MV04_sp-05-plot', [
@ -213,21 +220,21 @@
title: 'MV04 & MV05: Setpoints and Actuals', xaxis: { type: 'date' }, yaxis: { range: [0, 100] } title: 'MV04 & MV05: Setpoints and Actuals', xaxis: { type: 'date' }, yaxis: { range: [0, 100] }
}); });
Plotly.newPlot('MV06_sp-plot', [ Plotly.newPlot('MV06-plot', [
{ x: time0, y: [0], name: 'MV06_sp', mode: 'lines' }, { x: time0, y: [0], name: 'MV06_sp', mode: 'lines' },
{ x: time0, y: [0], name: 'MV06', mode: 'lines' } { x: time0, y: [0], name: 'MV06', mode: 'lines' }
], { ], {
title: 'MV06: Setpoint vs Actual', xaxis: { type: 'date' }, yaxis: { range: [0, 100] } title: 'MV06: Setpoint vs Actual', xaxis: { type: 'date' }, yaxis: {}
}); });
Plotly.newPlot('MV07_sp-plot', [ Plotly.newPlot('MV07-plot', [
{ x: time0, y: [0], name: 'MV07_sp', mode: 'lines' }, { x: time0, y: [0], name: 'MV07_sp', mode: 'lines' },
{ x: time0, y: [0], name: 'MV07', mode: 'lines' } { x: time0, y: [0], name: 'MV07', mode: 'lines' }
], { ], {
title: 'MV07: Setpoint vs Actual', xaxis: { type: 'date' }, yaxis: { range: [0, 100] } title: 'MV07: Setpoint vs Actual', xaxis: { type: 'date' }, yaxis: {}
}); });
Plotly.newPlot('MV08_sp-plot', [ Plotly.newPlot('MV08-plot', [
{ x: time0, y: [0], name: 'MV08_sp', mode: 'lines' }, { x: time0, y: [0], name: 'MV08_sp', mode: 'lines' },
{ x: time0, y: [0], name: 'MV08', mode: 'lines' } { x: time0, y: [0], name: 'MV08', mode: 'lines' }
], { ], {
@ -244,4 +251,5 @@
}; };
</script> </script>
</body> </body>
</html> </html>