forked from M-Labs/thermostat
add more graphs in 2x2 grid
This commit is contained in:
parent
2cfd162498
commit
ea9b9a7a90
|
@ -19,7 +19,6 @@ channel_data = [{
|
|||
'tec_i': np.zeros(rec_len),
|
||||
'tec_u_meas': np.zeros(rec_len),
|
||||
'interval': np.zeros(rec_len),
|
||||
'temp_set': np.zeros(rec_len),
|
||||
} for _ in range(2)]
|
||||
|
||||
tec = Client()
|
||||
|
@ -31,22 +30,38 @@ mw.resize(800,800)
|
|||
cw = QtGui.QWidget()
|
||||
mw.setCentralWidget(cw)
|
||||
l = QtGui.QVBoxLayout()
|
||||
layout = pg.LayoutWidget()
|
||||
l.addWidget(layout)
|
||||
cw.setLayout(l)
|
||||
|
||||
pg.setConfigOptions(antialias=True)
|
||||
|
||||
pw0= pg.PlotWidget(name='Channel 0')
|
||||
l.addWidget(pw0)
|
||||
pw1 = pg.PlotWidget(name='Channel 1')
|
||||
l.addWidget(pw1)
|
||||
temp0plot= pg.PlotWidget(title='Channel 0 Temperature')
|
||||
layout.addWidget(temp0plot, 1, 1)
|
||||
temp1plot = pg.PlotWidget(title='Channel 1 Temperature')
|
||||
layout.addWidget(temp1plot, 2, 1)
|
||||
current0plot = pg.PlotWidget(title='Channel 0 Current')
|
||||
layout.addWidget(current0plot, 1, 2)
|
||||
current1plot = pg.PlotWidget(title='Channel 1 Current')
|
||||
layout.addWidget(current1plot, 2, 2)
|
||||
|
||||
temp0curve = pg.PlotCurveItem(pen=({'color': 'r', 'width': 1}))
|
||||
temp1curve = pg.PlotCurveItem(pen=({'color': 'r', 'width': 1}))
|
||||
tecI0curve = pg.PlotCurveItem(pen=({'color': 'r', 'width': 1}))
|
||||
tecI1curve = pg.PlotCurveItem(pen=({'color': 'r', 'width': 1}))
|
||||
Iset0curve = pg.PlotCurveItem(pen=({'color': 'g', 'width': 1}))
|
||||
Iset1curve = pg.PlotCurveItem(pen=({'color': 'g', 'width': 1}))
|
||||
temp0plot.addItem(temp0curve)
|
||||
temp1plot.addItem(temp1curve)
|
||||
current0plot.addItem(tecI0curve)
|
||||
current0plot.addItem(Iset0curve)
|
||||
current1plot.addItem(tecI1curve)
|
||||
current1plot.addItem(Iset1curve)
|
||||
|
||||
curve0 = pw0.plot()
|
||||
curve1 = pw1.plot()
|
||||
|
||||
cnt = 0
|
||||
time_stamp = np.zeros(rec_len)
|
||||
def update(n):
|
||||
global cnt
|
||||
for data in tec.report_mode():
|
||||
ch = data[n]
|
||||
for tag, seq in channel_data[n].items():
|
||||
|
@ -69,10 +84,16 @@ def updateData():
|
|||
cnt += 1
|
||||
time_stamp[:-1] = time_stamp[1:]
|
||||
time_stamp[-1] = cnt * refresh_period / 1000
|
||||
pw0.setRange(xRange=[cnt * refresh_period / 1000 - 20.0, cnt * refresh_period / 1000])
|
||||
pw1.setRange(xRange=[cnt * refresh_period / 1000 - 20.0, cnt * refresh_period / 1000])
|
||||
curve0.setData(x = time_stamp, y = channel_data[0]['temperature'])
|
||||
curve1.setData(x = time_stamp, y = channel_data[1]['temperature'])
|
||||
temp0plot.setRange(xRange=[(cnt - rec_len) * refresh_period / 1000, cnt * refresh_period / 1000])
|
||||
temp1plot.setRange(xRange=[(cnt - rec_len) * refresh_period / 1000, cnt * refresh_period / 1000])
|
||||
current0plot.setRange(xRange=[(cnt - rec_len) * refresh_period / 1000, cnt * refresh_period / 1000])
|
||||
current1plot.setRange(xRange=[(cnt - rec_len) * refresh_period / 1000, cnt * refresh_period / 1000])
|
||||
temp0curve.setData(x = time_stamp, y = channel_data[0]['temperature'])
|
||||
temp1curve.setData(x = time_stamp, y = channel_data[1]['temperature'])
|
||||
tecI0curve.setData(x = time_stamp, y = channel_data[0]['tec_i'])
|
||||
tecI1curve.setData(x = time_stamp, y = channel_data[1]['tec_i'])
|
||||
Iset0curve.setData(x = time_stamp, y = channel_data[0]['i_set'])
|
||||
Iset1curve.setData(x = time_stamp, y = channel_data[1]['i_set'])
|
||||
|
||||
|
||||
## Start a timer to rapidly update the plot in pw
|
||||
|
|
Loading…
Reference in New Issue