GUI #70

Open
topquark12 wants to merge 17 commits from GUI into master
1 changed files with 11 additions and 10 deletions
Showing only changes of commit da415e6da6 - Show all commits

View File

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