add voltage monitoring

This commit is contained in:
topquark12 2022-06-05 17:21:50 +08:00 committed by atse
parent d6a80c4f9b
commit d841cd2559
1 changed files with 11 additions and 10 deletions

View File

@ -3,6 +3,8 @@ import numpy as np
import pyqtgraph as pg
from pytec.client import Client
tec = Client(host="192.168.1.26", port=23, timeout=None)
rec_len = 1000
refresh_period = 20
@ -27,7 +29,6 @@ class Curves:
self.time_stamp[-1] = cnt * self.period / 1000
self.curveItem.setData(x = self.time_stamp, y = self.data_buf)
class Graph:
def __init__(self, parent: pg.LayoutWidget, title: str, row: int, col: int, curves: list[Curves]):
self.plotItem = pg.PlotWidget(title=title)
@ -44,12 +45,10 @@ class Graph:
curve.update(tec_data, cnt)
self.plotItem.setRange(xRange=[(cnt - self.curves[0].buffLen) * self.curves[0].period / 1000, cnt * self.curves[0].period / 1000])
tec = Client()
app = pg.mkQApp()
mw = QtGui.QMainWindow()
mw.setWindowTitle('Thermostat Control Panel')
mw.resize(1024,800)
mw.resize(1500,800)
cw = QtGui.QWidget()
mw.setCentralWidget(cw)
l = QtGui.QVBoxLayout()
@ -59,12 +58,14 @@ cw.setLayout(l)
pg.setConfigOptions(antialias=True)
ch0tempGraph = Graph(layout, 'Channel 0 Temperature', 1, 1, [Curves('Feedback', 'temperature', 0, 'r', rec_len, refresh_period)])
ch1tempGraph = Graph(layout, 'Channel 1 Temperature', 2, 1, [Curves('Feedback', 'temperature', 1, 'r', rec_len, refresh_period)])
ch0currentGraph = Graph(layout, 'Channel 0 Current', 1, 2, [Curves('Feedback', 'tec_i', 0, 'r', rec_len, refresh_period),
ch0tempGraph = Graph(layout, 'Channel 0 Temperature', 1, 2, [Curves('Feedback', 'temperature', 0, 'r', rec_len, refresh_period)])
ch1tempGraph = Graph(layout, 'Channel 1 Temperature', 2, 2, [Curves('Feedback', 'temperature', 1, 'r', rec_len, refresh_period)])
ch0currentGraph = Graph(layout, 'Channel 0 Current', 1, 3, [Curves('Feedback', 'tec_i', 0, 'r', rec_len, refresh_period),
Curves('Setpoint', 'i_set', 0, 'g', rec_len, refresh_period)])
ch1currentGraph = Graph(layout, 'Channel 1 Current', 2, 2, [Curves('Feedback', 'tec_i', 1, 'r', rec_len, refresh_period),
ch1currentGraph = Graph(layout, 'Channel 1 Current', 2, 3, [Curves('Feedback', 'tec_i', 1, 'r', rec_len, refresh_period),
Curves('Setpoint', 'i_set', 1, 'g', rec_len, refresh_period)])
ch0voltGraph = Graph(layout, 'Channel 0 Voltage', 1, 4, [Curves('Feedback', 'tec_u_meas', 0, 'r', rec_len, refresh_period)])
ch1voltGraph = Graph(layout, 'Channel 1 Voltage', 2, 4, [Curves('Feedback', 'tec_u_meas', 1, 'r', rec_len, refresh_period)])
cnt = 0
def updateData():
@ -75,13 +76,13 @@ def updateData():
ch1tempGraph.update(data, cnt)
ch0currentGraph.update(data, cnt)
ch1currentGraph.update(data, cnt)
ch0voltGraph.update(data, cnt)
ch1voltGraph.update(data, cnt)
if quit:
break
cnt += 1
## Start a timer to rapidly update the plot in pw
t = QtCore.QTimer()
t.timeout.connect(updateData)
t.start(refresh_period)