Commit 12a4d4a0 authored by Peter Švihra's avatar Peter Švihra

added debug plotting

parent 690de648
...@@ -38,6 +38,7 @@ class ClientPlots(QtWidgets.QMainWindow): ...@@ -38,6 +38,7 @@ class ClientPlots(QtWidgets.QMainWindow):
self.timestamp = list(el*(-1) for el in range(self.history_length))[::-1] self.timestamp = list(el*(-1) for el in range(self.history_length))[::-1]
self.PID_P = list(0 for _ in range(self.history_length)) self.PID_P = list(0 for _ in range(self.history_length))
self.flow_calc = list(0 for _ in range(self.history_length))
self.PID_I = list(0 for _ in range(self.history_length)) self.PID_I = list(0 for _ in range(self.history_length))
self.PID_D = list(0 for _ in range(self.history_length)) self.PID_D = list(0 for _ in range(self.history_length))
...@@ -61,6 +62,7 @@ class ClientPlots(QtWidgets.QMainWindow): ...@@ -61,6 +62,7 @@ class ClientPlots(QtWidgets.QMainWindow):
self.pressurePlot.enableAutoRange('y', True) self.pressurePlot.enableAutoRange('y', True)
# Plot styles # Plot styles
self.line1 = self.plot(self.flowPlot, self.timestamp, self.PID_D, "Flow", "00F") self.line1 = self.plot(self.flowPlot, self.timestamp, self.PID_D, "Flow", "00F")
self.line1b = self.plot(self.flowPlot, self.timestamp, self.PID_D, "Flow Calculated", "F00")
self.line2 = self.plot(self.volumePlot, self.timestamp, self.PID_I, "Volume", "707") self.line2 = self.plot(self.volumePlot, self.timestamp, self.PID_I, "Volume", "707")
self.line3 = self.plot(self.pressurePlot, self.timestamp, self.PID_P, "Airway Pressure", "077") self.line3 = self.plot(self.pressurePlot, self.timestamp, self.PID_P, "Airway Pressure", "077")
...@@ -87,8 +89,8 @@ class ClientPlots(QtWidgets.QMainWindow): ...@@ -87,8 +89,8 @@ class ClientPlots(QtWidgets.QMainWindow):
loop.close() loop.close()
def plot(self, canvas, x, y, plotname, color): def plot(self, canvas, x, y, plotname, color):
pen = pg.mkPen(color=color, width=3) pen = pg.mkPen(color=color, width=3)
return canvas.plot(x, y, name=plotname, pen=pen) return canvas.plot(x, y, name=plotname, pen=pen)
async def redraw(self): async def redraw(self):
while True: while True:
...@@ -110,13 +112,16 @@ class ClientPlots(QtWidgets.QMainWindow): ...@@ -110,13 +112,16 @@ class ClientPlots(QtWidgets.QMainWindow):
self.statusBar().showMessage(f"Got data for timestamp {payload['timestamp']}") self.statusBar().showMessage(f"Got data for timestamp {payload['timestamp']}")
logging.info("data acquired") logging.info("data acquired")
self.PID_D.append(payload["flow"]) self.PID_D.append(payload["flow"])
self.flow_calc.append(payload["flow_calc"])
self.PID_I.append(payload["volume"]) self.PID_I.append(payload["volume"])
self.PID_P.append(payload["pressure_patient"]) self.PID_P.append(payload["pressure_patient"])
if len(self.PID_D) > self.history_length: if len(self.PID_D) > self.history_length:
self.PID_D = self.PID_D[1:] self.PID_D = self.PID_D[1:]
self.flow_calc = self.flow_calc[1:]
self.PID_I = self.PID_I[1:] self.PID_I = self.PID_I[1:]
self.PID_P = self.PID_P[1:] self.PID_P = self.PID_P[1:]
self.line1.setData(self.timestamp, self.PID_D) self.line1.setData(self.timestamp, self.PID_D)
self.line1b.setData(self.timestamp, self.flow_calc)
self.line2.setData(self.timestamp, self.PID_I) self.line2.setData(self.timestamp, self.PID_I)
self.line3.setData(self.timestamp, self.PID_P) self.line3.setData(self.timestamp, self.PID_P)
elif brtype == "READBACK": elif brtype == "READBACK":
...@@ -131,11 +136,13 @@ class ClientPlots(QtWidgets.QMainWindow): ...@@ -131,11 +136,13 @@ class ClientPlots(QtWidgets.QMainWindow):
logging.info("personal data acquired") logging.info("personal data acquired")
pass pass
elif brtype == "ALARM": elif brtype == "ALARM":
logging.error(f"received ALARM {payload}") logging.debug(f"received ALARM {payload}")
elif brtype == "IVT": elif brtype == "IVT":
pass pass
elif brtype == "DEBUG": elif brtype == "DEBUG":
pass pass
elif brtype == "BATTERY":
pass
else: else:
raise KeyError raise KeyError
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment