Adds Qskid in multi pu dashboard and set frequency to 20 Hz
This commit is contained in:
parent
d2c3a11ce2
commit
27d1d33f5d
4
main.py
4
main.py
|
|
@ -247,7 +247,7 @@ async def update_latest_data():
|
||||||
current_data = latest_data[f"PU_{pu}"]
|
current_data = latest_data[f"PU_{pu}"]
|
||||||
logging.debug(f"[MONITOR BUFFER] PU{pu}: {current_data}")
|
logging.debug(f"[MONITOR BUFFER] PU{pu}: {current_data}")
|
||||||
# logging.info(f"[MONITOR BUFFER] latest_data: {latest_data}")
|
# logging.info(f"[MONITOR BUFFER] latest_data: {latest_data}")
|
||||||
await asyncio.sleep(0.1)
|
await asyncio.sleep(0.05)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/monitor")
|
@app.get("/monitor")
|
||||||
|
|
@ -348,7 +348,7 @@ async def record_data_loop():
|
||||||
recording_file.flush()
|
recording_file.flush()
|
||||||
last_flush_time = datetime.datetime.now()
|
last_flush_time = datetime.datetime.now()
|
||||||
|
|
||||||
await asyncio.sleep(0.1) # 10 Hz
|
await asyncio.sleep(0.05) # 10 Hz
|
||||||
|
|
||||||
## AUTOMATIC TESTING
|
## AUTOMATIC TESTING
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,8 @@ function initAllPlots() {
|
||||||
xaxis: { title: 'Time', type: 'date' },
|
xaxis: { title: 'Time', type: 'date' },
|
||||||
yaxis: { title: plot.id.includes('P') ? 'Pressure (bar)' : 'Flow (L/h)' },
|
yaxis: { title: plot.id.includes('P') ? 'Pressure (bar)' : 'Flow (L/h)' },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Add ref line if present
|
||||||
if (plot.ref !== undefined) {
|
if (plot.ref !== undefined) {
|
||||||
data.push({
|
data.push({
|
||||||
x: [time0[0], time0[0]],
|
x: [time0[0], time0[0]],
|
||||||
|
|
@ -77,9 +79,23 @@ function initAllPlots() {
|
||||||
showlegend: true
|
showlegend: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add QSkid trace only for Qperm plot
|
||||||
|
if (plot.id === 'Qperm-plot') {
|
||||||
|
data.push({
|
||||||
|
x: time0.slice(),
|
||||||
|
y: zero.slice(),
|
||||||
|
name: 'QSkid',
|
||||||
|
mode: 'lines',
|
||||||
|
line: { color: 'black', width: 2, dash: 'dot' },
|
||||||
|
legendgroup: 'PatientSkid'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Plotly.newPlot(plot.id, data, layout);
|
Plotly.newPlot(plot.id, data, layout);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateAllPlots() {
|
async function updateAllPlots() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/monitor');
|
const res = await fetch('/monitor');
|
||||||
|
|
@ -110,6 +126,16 @@ async function updateAllPlots() {
|
||||||
y: [[plot.ref]]
|
y: [[plot.ref]]
|
||||||
}, [puList.length], maxPoints); // the ref line is always the last trace
|
}, [puList.length], maxPoints); // the ref line is always the last trace
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extend PatientSkid.QSkid only for Qperm plot
|
||||||
|
if (plot.id === 'Qperm-plot') {
|
||||||
|
const qSkid = SkidData["QSkid"];
|
||||||
|
const skidX = [[timestamp]];
|
||||||
|
const skidY = [[qSkid !== undefined ? qSkid : null]];
|
||||||
|
const qSkidTraceIndex = puList.length + (plot.ref !== undefined ? 1 : 0); // last trace index
|
||||||
|
Plotly.extendTraces(plot.id, { x: skidX, y: skidY }, [qSkidTraceIndex], maxPoints);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Failed to update plots:", err);
|
console.error("Failed to update plots:", err);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user