|
@@ -12,6 +12,7 @@ from backend import io
|
|
|
from backend import board
|
|
|
from backend.board import available_boards
|
|
|
import kcgwidget as kcgw
|
|
|
+from .. import config
|
|
|
|
|
|
tr = kcgw.tr
|
|
|
|
|
@@ -31,7 +32,7 @@ class Enum():
|
|
|
setattr(self, i, self.idx)
|
|
|
self.idx += 1
|
|
|
|
|
|
-plotList = [tr("Label", "Heatmap"), tr("Label", "FFT"), tr("Label", "Trains"), tr("Label", "Combined"), tr("Label", "Compare")]
|
|
|
+plotList = [tr("Label", "Heatmap"), tr("Label", "FFT"), tr("Label", "Trains"), tr("Label", "Combined"), tr("Label", "Compare"), tr("Label", "Follow")]
|
|
|
PlotType = Enum(*[str(i) for i in plotList])
|
|
|
|
|
|
# gradient = {'mode': 'rgb',
|
|
@@ -333,6 +334,8 @@ class SubPlotWidget(pg.GraphicsLayoutWidget):
|
|
|
"""
|
|
|
def newAutoRange(*args, **kwargs):
|
|
|
''' function to handle the new autorange '''
|
|
|
+ if len(data) == 0:
|
|
|
+ return
|
|
|
bounds = [np.min(data), np.max(data)]
|
|
|
self.plotItem.vb.setRange(xRange=[0, len(data)],
|
|
|
yRange=[bounds[0]-0.1*(bounds[1]-bounds[0])-1, bounds[1]+0.1*(bounds[1]-bounds[0])+1], update=True)
|
|
@@ -441,7 +444,7 @@ class SubPlotWidget(pg.GraphicsLayoutWidget):
|
|
|
self._disableCustomAutoRange()
|
|
|
self.plotItem.setClipToView(True)
|
|
|
|
|
|
- if self.plotType == PlotType.Trains:
|
|
|
+ if self.plotType == PlotType.Trains or self.plotType == PlotType.Follow:
|
|
|
self.img.clear()
|
|
|
self.plotItemPlot.show()
|
|
|
self.gradient_legend.hide()
|
|
@@ -507,7 +510,7 @@ class SubPlotWidget(pg.GraphicsLayoutWidget):
|
|
|
elif self.plotType == PlotType.FFT:
|
|
|
self.plotItem.setLabel('left', 'Bunch Position', '')
|
|
|
self.plotItem.setLabel('bottom', 'Frequency', 'Hz')
|
|
|
- elif self.plotType == PlotType.Trains:
|
|
|
+ elif self.plotType == PlotType.Trains or self.plotType == PlotType.Follow:
|
|
|
self.plotItem.setLabel('left', '', '')
|
|
|
self.plotItem.setLabel('bottom', 'Sample Point', '')
|
|
|
elif self.plotType == PlotType.Combined:
|
|
@@ -603,9 +606,10 @@ class PlotWidget(kcgw.KCGWidgets):
|
|
|
self.trains_button = self.createButton(text=tr("Button", "Trains"), connect=lambda: self.plot(type=PlotType.Trains))
|
|
|
self.combined_button = self.createButton(text=tr("Button", "Combined"), connect=lambda: self.plot(type=PlotType.Combined))
|
|
|
self.compare_button = self.createButton(text=tr("Button", "Compare"), connect=lambda: self.plot(type=PlotType.Compare))
|
|
|
+ self.follow_button = self.createButton(text=tr("Button", "Follow"), connect=lambda: self.plot(type=PlotType.Follow))
|
|
|
self.type_buttons = {PlotType.Heatmap:self.heatmap_button, PlotType.FFT:self.fft_button,
|
|
|
PlotType.Trains:self.trains_button, PlotType.Combined:self.combined_button,
|
|
|
- PlotType.Compare:self.compare_button}
|
|
|
+ PlotType.Compare:self.compare_button, PlotType.Follow:self.follow_button}
|
|
|
self.defaultButtonStyleSheet = self.heatmap_button.styleSheet()
|
|
|
|
|
|
self.adc1 = self.createCheckbox(text="ADC 1", connect=self.change_adc)
|
|
@@ -619,6 +623,7 @@ class PlotWidget(kcgw.KCGWidgets):
|
|
|
self.plot_buttons_layout.addWidget(self.trains_button)
|
|
|
self.plot_buttons_layout.addWidget(self.combined_button)
|
|
|
self.plot_buttons_layout.addWidget(self.compare_button)
|
|
|
+ self.plot_buttons_layout.addWidget(self.follow_button)
|
|
|
|
|
|
self.adc_checkbox_layout = QtGui.QHBoxLayout()
|
|
|
self.adc_checkbox_layout.addWidget(self.adc1)
|
|
@@ -669,9 +674,16 @@ class PlotWidget(kcgw.KCGWidgets):
|
|
|
self.groupWidgetCompare.hide()
|
|
|
|
|
|
self.from_to_layout = QtGui.QHBoxLayout()
|
|
|
+ self.bucket_part = QtGui.QWidget()
|
|
|
+ self.bucket_layout = QtGui.QHBoxLayout()
|
|
|
+ self.bucket_layout.addWidget(self.createLabel(tr("Label", "Bucket:")))
|
|
|
+ self.bucket_spinbox = self.createSpinbox(0, config.bunches_per_turn-1, interval=1, connect=lambda: self.plot(self.theType))
|
|
|
+ self.bucket_layout.addWidget(self.bucket_spinbox)
|
|
|
+ self.bucket_part.setLayout(self.bucket_layout)
|
|
|
self.from_spinbox = self.createSpinbox(0, 100000000, interval=100, connect=lambda: self.plot(self.theType))
|
|
|
self.to_spinbox = self.createSpinbox(0, 100000000, start_value=1000, interval=100, connect=lambda: self.plot(self.theType))
|
|
|
self.from_to_layout.addStretch()
|
|
|
+ self.from_to_layout.addWidget(self.bucket_part)
|
|
|
self.from_to_layout.addWidget(self.createLabel(tr("Label", "From:")))
|
|
|
self.from_to_layout.addWidget(self.from_spinbox)
|
|
|
self.from_to_layout.addWidget(self.createLabel(tr("Label", "To:")))
|
|
@@ -748,6 +760,10 @@ class PlotWidget(kcgw.KCGWidgets):
|
|
|
style += self.defaultButtonStyleSheet
|
|
|
style += "QPushButton:focus{background-color: lightgrey!important; border-color: lightblue;}" # Note: this does not work
|
|
|
button.setStyleSheet(style)
|
|
|
+ if self.theType == PlotType.Follow:
|
|
|
+ self.bucket_part.show()
|
|
|
+ else:
|
|
|
+ self.bucket_part.hide()
|
|
|
def plot(self, type=None):
|
|
|
"""
|
|
|
Wrapper function to call the correct plot function depending on type
|
|
@@ -782,7 +798,7 @@ class PlotWidget(kcgw.KCGWidgets):
|
|
|
type = self._old_type
|
|
|
else:
|
|
|
type = self.theType
|
|
|
- if type == PlotType.Trains or type == PlotType.Combined:
|
|
|
+ if type == PlotType.Trains or type == PlotType.Combined or type == PlotType.Follow:
|
|
|
self.do_plot(type, autorange=True)
|
|
|
else:
|
|
|
self.do_plot(type, autorange=False)
|
|
@@ -831,6 +847,7 @@ class PlotWidget(kcgw.KCGWidgets):
|
|
|
|
|
|
f = self.from_spinbox.value()
|
|
|
t = self.to_spinbox.value() if self.to_spinbox.value() > f else f+1
|
|
|
+ b = self.bucket_spinbox.value()
|
|
|
if type == PlotType.FFT:
|
|
|
self.plot_widget.plot(np.abs(self.data.fft(adc=self.adc, frm=f, to=t+1, drop_first_bin=True)).transpose(),
|
|
|
autorange=autorange,
|
|
@@ -841,6 +858,8 @@ class PlotWidget(kcgw.KCGWidgets):
|
|
|
self.plot_widget.plot([self.data.heatmap(adc=self.adc, frm=f, to=t).transpose(),self.data.heatmap(adc=self.secadc, frm=f, to=t).transpose()], autorange=autorange)
|
|
|
if type == PlotType.Trains:
|
|
|
self.plot_widget.plot(self.data.train(adc=self.adc, frm=f, to=t), autorange=autorange)
|
|
|
+ if type == PlotType.Follow:
|
|
|
+ self.plot_widget.plot(self.data.follow(adc=self.adc, frm=f, to=t, bunch=b), autorange=autorange)
|
|
|
if type == PlotType.Combined:
|
|
|
self.plot_widget.plot(self.data.combined(frm=f, to=t), autorange=autorange)
|
|
|
|