|
@@ -126,7 +126,7 @@ class TimingPart(kcgw.KCGWidgets):
|
|
|
[
|
|
|
#self.coarseInputFpga,
|
|
|
#self.coarseInputAdc,
|
|
|
- #self.coarseInputTh_2,
|
|
|
+ self.coarseInputTh_2,
|
|
|
#self.coarse2InputAdc,
|
|
|
#self.coarse2InputFpga,
|
|
|
self.coarse2InputTh_2
|
|
@@ -159,7 +159,11 @@ class TimingPart(kcgw.KCGWidgets):
|
|
|
Elements.addItem(["timing_{}".format(self.board_id),
|
|
|
"no_board_{}".format(self.board_id),
|
|
|
"acquire_{}".format(self.board_id),
|
|
|
- "continuous_read_{}".format(board_id)], self.fineAdcInput)
|
|
|
+ "continuous_read_{}".format(board_id)],
|
|
|
+ [
|
|
|
+ self.fineAdcInput
|
|
|
+ ]
|
|
|
+ )
|
|
|
|
|
|
self.bunchShiftLabel = self.createLabel(tr("Label", "Bunch Shift"))
|
|
|
|
|
@@ -170,7 +174,11 @@ class TimingPart(kcgw.KCGWidgets):
|
|
|
Elements.addItem(["timing_{}".format(self.board_id),
|
|
|
"no_board_{}".format(self.board_id),
|
|
|
"acquire_{}".format(self.board_id),
|
|
|
- "continuous_read_{}".format(board_id)], self.bunchShiftInput)
|
|
|
+ "continuous_read_{}".format(board_id)],
|
|
|
+ [
|
|
|
+ self.bunchShiftInput
|
|
|
+ ]
|
|
|
+ )
|
|
|
|
|
|
|
|
|
#---------[ End ]---------
|
|
@@ -191,11 +199,12 @@ class TimingPart(kcgw.KCGWidgets):
|
|
|
#Bunch Shift values are encoded 0x0 - 0x4 in Hardware
|
|
|
#but displayed as -2 to +2 in the GUI, so we need to offset
|
|
|
#the received register value by -2 when receiving an update
|
|
|
- def setBunchShiftValuesSilent(values):
|
|
|
- for i, v in enumerate(values):
|
|
|
- self.bunchShiftInput[i].blockSignals(True)
|
|
|
- self.bunchShiftInput[i].setValue(v-2)
|
|
|
- self.bunchShiftInput[i].blockSignals(False)
|
|
|
+ #Values is passed in fro the callback and is expected to be
|
|
|
+ #a list with values for each ADC
|
|
|
+ def setBunchShiftValueSilent(values, adc):
|
|
|
+ self.bunchShiftInput[adc].blockSignals(True)
|
|
|
+ self.bunchShiftInput[adc].setValue(values[adc]-2)
|
|
|
+ self.bunchShiftInput[adc].blockSignals(False)
|
|
|
|
|
|
|
|
|
# --------[ Set observers ]------------
|
|
@@ -225,11 +234,16 @@ class TimingPart(kcgw.KCGWidgets):
|
|
|
obs(self.coarse25Adc_2, 'delay_25_adc_2')
|
|
|
|
|
|
|
|
|
- board.get_board_config(board_id).observe(
|
|
|
- self.bunchShiftInput,
|
|
|
- setBunchShiftValuesSilent,
|
|
|
- 'bunch_shift'
|
|
|
- )
|
|
|
+ #Observers need to be set on individual control elements
|
|
|
+ #But the callback will be fed with a list of values,
|
|
|
+ #one entry for each ADC
|
|
|
+ for i, item in enumerate(self.bunchShiftInput):
|
|
|
+ board.get_board_config(board_id).observe(
|
|
|
+ item,
|
|
|
+ lambda values: setBunchShiftValueSilent(values, i),
|
|
|
+ 'bunch_shift'
|
|
|
+ )
|
|
|
+
|
|
|
|
|
|
# -------[ Create outputs ]---------------
|
|
|
self.totalLabel = self.createLabel(tr("Label", "Total Delay"))
|
|
@@ -348,8 +362,16 @@ class TimingPart(kcgw.KCGWidgets):
|
|
|
self.board_config.get('chip_delay')[i] * self.board_config.get('chip_delay_factor')))
|
|
|
if self.board_config.is_KAPTURE2():
|
|
|
for i, item in enumerate(self.totalAdcBoxCalib):
|
|
|
- value = theCalibration.calibrateX(i, self.board_config.get('delay_330_th'), self.board_config.get('delay_25_th'), self.board_config.get('chip_delay')[i], self.board_config.get("delay_25_th_2"))
|
|
|
- item.setText('{}'.format(np.round(value*1e12,1)))
|
|
|
+
|
|
|
+ #Calibration throws errors when opening the Timing Widget
|
|
|
+ #without a calibration file existing.
|
|
|
+ #I am muting this error for now
|
|
|
+ try:
|
|
|
+ value = theCalibration.calibrateX(i, self.board_config.get('delay_330_th'), self.board_config.get('delay_25_th'), self.board_config.get('chip_delay')[i], self.board_config.get("delay_25_th_2"))
|
|
|
+ item.setText('{}'.format(np.round(value*1e12,1)))
|
|
|
+ except:
|
|
|
+ pass #TODO: Create an exception type for 'No Calibration File' and handle accordingly
|
|
|
+
|
|
|
"""
|
|
|
if self.fileHandle is not None:
|
|
|
for i, item in enumerate(self.totalAdcBoxCalib):
|
|
@@ -447,7 +469,8 @@ class TimingPart(kcgw.KCGWidgets):
|
|
|
for i, item in enumerate(self.fineAdcInput):
|
|
|
self.board_config.unobserve(item, 'chip_delay')
|
|
|
|
|
|
- self.board_config.unobserve(self.bunchShiftInput, 'bunch_shift')
|
|
|
+ for i, item in enumerate(self.bunchShiftInput):
|
|
|
+ self.board_config.unobserve(item,'bunch_shift')
|
|
|
|
|
|
|
|
|
self.board_config.unobserve(self.coarseInputTh, 'delay_330_th')
|
|
@@ -467,29 +490,29 @@ class TimingPart(kcgw.KCGWidgets):
|
|
|
|
|
|
|
|
|
Elements.emptyGroup('timing_{}'.format(self.board_id))
|
|
|
- Elements.removeItem(None, self.fineAdcInput)
|
|
|
- Elements.removeItem(None, self.bunchShiftInput)
|
|
|
+ Elements.removeItem(None, [self.fineAdcInput])
|
|
|
+ Elements.removeItem(None, [self.bunchShiftInput])
|
|
|
Elements.removeItem(None, [
|
|
|
self.coarseInputTh,
|
|
|
- self.coarseInputAdc,
|
|
|
- self.coarseInputFpga
|
|
|
+ #self.coarseInputAdc,
|
|
|
+ #self.coarseInputFpga
|
|
|
]
|
|
|
)
|
|
|
if self.board_config.is_KAPTURE2():
|
|
|
Elements.removeItem(None, [
|
|
|
self.coarse2InputTh,
|
|
|
- self.coarse2InputAdc,
|
|
|
- self.coarse2InputFpga
|
|
|
+ #self.coarse2InputAdc,
|
|
|
+ #self.coarse2InputFpga
|
|
|
]
|
|
|
)
|
|
|
if self.adc_number > 4:
|
|
|
Elements.removeItem(None, [
|
|
|
self.coarseInputTh_2,
|
|
|
- self.coarseInputAdc_2,
|
|
|
+ #self.coarseInputAdc_2,
|
|
|
#self.coarseInputFpga_2,
|
|
|
|
|
|
self.coarse2InputTh_2,
|
|
|
- self.coarse2InputAdc_2,
|
|
|
+ #self.coarse2InputAdc_2,
|
|
|
#self.coarse2InputFpga_2
|
|
|
]
|
|
|
)
|
|
@@ -613,3 +636,4 @@ def addTimingWidget():
|
|
|
global_objects.get_global('area').newWidget(w, tr("Heading", "Timing"), nid, widget_type=4, minSize=True) #TODO: proper type
|
|
|
|
|
|
kcgw.register_widget(QtGui.QIcon(config.icon_path(config.timingIcon)), tr("Heading", "Timing"), addTimingWidget, "Ctrl+T")
|
|
|
+kcgw.register_widget_creation_function(addTimingWidget)
|