22 Commits e0f5cc24a2 ... dcf2891c32

Author SHA1 Message Date
  Patrick Schreiber e0f5cc24a2 Update README.md 6 years ago
  Patrick Schreiber 809c20623e Merge branch 'follow_plot' 6 years ago
  Patrick Schreiber ffd09b6923 Introduce 50ohm background subtraction for timescan 6 years ago
  Patrick Schreiber 72f317da15 implement Follow plot 6 years ago
  Patrick Schreiber 94cc266862 Optionally include Singleread in LeftBar 6 years ago
  Patrick Schreiber 9d694d303b Update Version 6 years ago
  Patrick Schreiber 37736dbf55 Fix continous read interval 6 years ago
  Patrick Schreiber c4941a4118 Remove Bug when aborting to save config 6 years ago
  Patrick Schreiber 3451bf3485 Introduce Threshold for Timescan Averaging 6 years ago
  Miriam Brosi e2e8478961 Removed possible usage of reikna fft 6 years ago
  Patrick Schreiber dd9a11916c Fix Save/Load Config 7 years ago
  Miriam Brosi ae9b0e7d39 single read tick for board_id 0 if on by default now 7 years ago
  Miriam Brosi 24e2187807 fixed bug: acquisition with ext. trigger was running in main thread, now fixed, now also stop acquisition working 7 years ago
  Miriam Brosi 0f4f391f60 implemented workaround: acquisition with ext. trigger method2 now working; but stop acquisition signal still delayed 7 years ago
  Miriam Brosi 8614b94f1f fixed board.flush_dma function and added calls at begining of acquisition and begining and end of external trigger function 7 years ago
  Lorenzo Rota bdf94a2b17 added logging info that initialisation was skipped and the configuration and status was read from KAPTURE 7 years ago
  Miriam Brosi 598af59917 improved update of statusbar after message 'Data is inconsistent' 7 years ago
  Miriam Brosi ba62421d91 added feature: in time scan possibility to average only over one bunch (if and which can be selected in time scan widget) 7 years ago
  Miriam Brosi e4923697d1 fixed bugs: time scan now displays (and returns for click) the correct numbers for coarse and fine delay also in partial scans, enabled auto range for switching between color and line plot. 7 years ago
  Miriam Brosi a05e83f3a5 replace all 184 by bunches_per_turns from the config file 7 years ago
  Miriam Brosi a022288e67 fixed bug: turn board off is now working 7 years ago
  Miriam Brosi 6e0c51bad0 fixed bug: bitsTable.py was still using old write_pci command instead of pci.write 7 years ago

+ 1 - 1
KCG/VERSION

@@ -1 +1 @@
-0.3.2.197.0704-beta
+0.3.2.180.0414-beta

+ 1 - 4
KCG/base/backend/board/actions.py

@@ -18,7 +18,6 @@ def acquire_data(board_id, filename, simulate=False):
     if simulate:
         start_pilot_bunch_emulator(board_id)
 
-    flush_dma(board_id)
     start_acquisition(board_id)
     wait_for_revolutions(board_id)
     stop_acquisition(board_id)
@@ -48,8 +47,6 @@ def flush_dma(board_id, dma='dma0'):
     """
     log.vinfo('Flushing DMA Pipeline')
     pci.write(board_id, '03f0', hex_mask='CF0')
-    time.sleep(0.05)
-    pci.write(board_id, '007f0', hex_mask='CF0')
     pci.read(board_id, dma=dma, destination='/dev/null')
 
 
@@ -90,7 +87,7 @@ def start_acquisition(board_id):
     :param board_id: the id to acquire with
     """
     log.vinfo('Start acquisition')
-    pci.write(board_id, '1', '4', hex_mask='1')  # Start DMA?
+    pci.write(board_id, '1', '4', hex_mask='1')  # what's this? write value 1 to register 4???
     time.sleep(0.005)
     pci.write(board_id, '00bf0', hex_mask='CF0')
 

+ 1 - 4
KCG/base/backend/board/boards_connected.py

@@ -67,10 +67,7 @@ class BoardsConnected(object):
             self._device_files = {int(i.replace(searchstring, '')): i for i in device_list}
 
         elif config.board_detection_method == 'dummy':
-            if config.num_dummy_boards:
-                num = int(config.num_dummy_boards)
-            else:
-                num = 5
+            num = 5
             self._board_ids = {i: get(config.device_names, 'test'+str(i)) for i in range(num)}
             self._device_files = {i: '/dev/fpga0' for i in self.board_ids}
 

+ 43 - 50
KCG/base/backend/dataset.py

@@ -17,49 +17,48 @@ def _pad_array(array):
     padded[:, :width] = array[:, :pwidth]
     return padded
 
-#try:
-    #import reikna.cluda
-    #import reikna.fft
-
-    #_plans = {}
-    #_in_buffers = {}
-    #_out_buffers = {}
-
-    #_api = reikna.cluda.ocl_api()
-    #_thr = _api.Thread.create()
-
-    #def _fft(array):
-        #start = time.time()
-        #padded = _pad_array(array).astype(np.complex64)
-        #height, width = padded.shape
-
-        #if width in _plans:
-            #fft = _plans[width]
-            #in_dev = _in_buffers[width]
-            #out_dev = _out_buffers[width]
-        #else:
-            #fft = reikna.fft.FFT(padded, axes=(1,)).compile(_thr)
-            #in_dev = _thr.to_device(padded)
-            #out_dev = _thr.empty_like(in_dev)
-            #_plans[width] = fft
-            #_in_buffers[width] = in_dev
-            #_out_buffers[width] = out_dev
-
-        #fft(out_dev, in_dev)
-        #logging.debug("GPU fft: {} s".format(time.time() - start))
-        #return out_dev.get()[:, :width / 2 + 1]
-    #logging.info("Using GPU based FFT!")
-
-#except ImportError:
-    #logging.debug("Failed to import reikna package. Falling back to Numpy FFT.")
-def _fft(array):
-    start = time.time()
-    freqs = np.fft.rfft(_pad_array(array))
-    logging.debug("np fft: {} s".format(time.time() - start))
-    return freqs
-
-
-BUNCHES_PER_TURN = config.bunches_per_turn
+try:
+    import reikna.cluda
+    import reikna.fft
+
+    _plans = {}
+    _in_buffers = {}
+    _out_buffers = {}
+
+    _api = reikna.cluda.ocl_api()
+    _thr = _api.Thread.create()
+
+    def _fft(array):
+        start = time.time()
+        padded = _pad_array(array).astype(np.complex64)
+        height, width = padded.shape
+
+        if width in _plans:
+            fft = _plans[width]
+            in_dev = _in_buffers[width]
+            out_dev = _out_buffers[width]
+        else:
+            fft = reikna.fft.FFT(padded, axes=(1,)).compile(_thr)
+            in_dev = _thr.to_device(padded)
+            out_dev = _thr.empty_like(in_dev)
+            _plans[width] = fft
+            _in_buffers[width] = in_dev
+            _out_buffers[width] = out_dev
+
+        fft(out_dev, in_dev)
+        logging.debug("GPU fft: {} s".format(time.time() - start))
+        return out_dev.get()[:, :width / 2 + 1]
+
+except ImportError:
+    logging.debug("Failed to import reikna package. Falling back to Numpy FFT.")
+    def _fft(array):
+        start = time.time()
+        freqs = np.fft.rfft(_pad_array(array))
+        logging.debug("np fft: {} s".format(time.time() - start))
+        return freqs
+
+
+BUNCHES_PER_TURN = 184
 HEADER_SIZE_BYTES = 32
 
 
@@ -121,13 +120,6 @@ class DataSet(object):
         pdata = self.array[frm:to, :-1]
         return pdata[:,adc-1]
 
-    def follow(self, adc=1, frm=0, to=-1, bunch=0, **kwargs):
-        """Follow one bunch through time"""
-        # pdata = self.array[frm:to, :-1]
-        pdata = self.array[bunch::BUNCHES_PER_TURN, adc-1]
-        pdata = pdata[frm:to]
-        return pdata
-
     def combined(self, frm=0, to=-1, show_reconstructed=True):
         array = self.array[frm:to, :]
 
@@ -170,3 +162,4 @@ class DataSet(object):
             # axis.plot(xs, ys, '.', alpha=0.3)
             ret.append(np.array([xs, ys]))
         return ret
+

+ 2 - 2
KCG/base/backend/io.py

@@ -42,7 +42,7 @@ def decode_data(data):
         data = data[np.where(data != 0xDEADDEAD)]  # This is the new filling
 
         # Make sure we read multiple of fours
-        data = data[:int(4 * (math.floor(data.size / 4)))]
+        data = data[:4 * (math.floor(data.size / 4))]
 
         bunch_low = data & 0xfff
         bunch_high = np.right_shift(data, 12) & 0xfff
@@ -57,7 +57,7 @@ def decode_data(data):
         result[0::2, 4] = bunch_number[::4]
         result[1::2, 4] = bunch_number[::4] + 1
 
-        result = result[:int(BUNCHES_PER_TURN * (math.floor(result.shape[0] / BUNCHES_PER_TURN))), :]
+        result = result[:184 * (math.floor(result.shape[0] / 184)), :]
         return result
 
 def data_has_header(data):

+ 26 - 55
KCG/base/backendinterface.py

@@ -42,7 +42,7 @@ def initStatus(st):
     st.defaults_set = False
     st.status_text = tr("sw", "Ready")
     st.time_scan = False
-    st.wait_on_trigger = False
+    st.wait = False
     st.last_file = None
     st.board_connected = True
     st.continuous_interval = 1000
@@ -457,7 +457,7 @@ def bk_stop_board(board_id):
 
     try:
         logging.info("Switching Off Board {}".format(board_id))
-        board.pci.write(board_id, '0x9040')
+        board.pci.write('0x01', '0x9040')
         board.pci.stop_dma(board_id)
         board.stop_board(board_id)
         time.sleep(0.5)
@@ -726,7 +726,6 @@ def _bif_read_and_update(board_id, read_func, *args):
                 logging.info("Data is inconsistent - file: " + args[0])
         else:
             callbacks.async_callback('update_consistency', True)
-            global_objects.get_global('statusbar').showMessage(tr("Dialog", ""))
 
         for plotwin in live_plot_windows.getWindows(board_id):
             plotwin.plot_live(data=data)
@@ -954,7 +953,7 @@ def bk_get_temperature(board_id):
 backup_get_temp = bk_get_temperature
 
 
-def bk_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, orbits_observe=None, orbits_skip=None, bucket_to_use=None, threshold_counts=None):
+def bk_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, orbits_observe=None, orbits_skip=None):
     """
     Toggle Timescan.
     :param board_id: id of the board do manipulate
@@ -971,7 +970,7 @@ def bk_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, orbits_
     if board.get_board_status(board_id).time_scan:
         _bif_stop_time_scan(board_id, ts_pbar)
     else:
-        _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, orbits_observe, orbits_skip, bucket_to_use, threshold_counts)
+        _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, orbits_observe, orbits_skip)
 
 
 def _bif_stop_time_scan(board_id, ts_pbar):
@@ -1000,7 +999,7 @@ def _bif_stop_time_scan(board_id, ts_pbar):
 # thread_ts = None
 
 
-def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressbar, plot_func, orbits_observe, orbits_skip, bucket_to_use=None, threshold_counts=None):
+def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressbar, plot_func, orbits_observe, orbits_skip):
     """
     Start the timscan. This starts the timer
     :param board_id: id of the board do manipulate
@@ -1008,12 +1007,10 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
     :param c_to: To value for coarse scan
     :param f_frm: From value for fine scan
     :param f_to: To value for fine scan
-    :param timescan_progressbar: Handle for the timescan progressbar
+    :param timescan_progressbar: Handle for the timescanprogressbar
     :param plot_func: Function to use to plot the data
     :param orbits_observe: Number of orbits to observe for the timescan (original values will be restored after timescan)
-    :param orbits_skip: Number of orbits to skip for the timescan (original values will be restored after timescan)
-    :param bucket_to_use: Number of the bucket whos data will be used to calculate the average signal at each timescan step (if None all bunches will be used)
-    :param threshold_counts: Skip buckets with adc counts between 2048 +- threshold_counts
+    :param orbits_skip: Number of orbits to skipfor the timescan (original values will be restored after timescan)
     :return: -
     """
     thread = storage.get_board_specific_storage(board_id).setdefault("TimeScanThread", storage.ThreadStorage())
@@ -1058,15 +1055,13 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
         stopSignal = QtCore.pyqtSignal()
         finished = QtCore.pyqtSignal()
 
-        def __init__(self, c_frm, c_to, f_frm, f_to, timescan_progressbar, bucket_to_use, threshold_counts):
+        def __init__(self, c_frm, c_to, f_frm, f_to, timescan_progressbar):
             super(thread_time_scan, self).__init__()
             self.c_frm = c_frm
             self.c_to = c_to
             self.f_frm = f_frm
             self.f_to = f_to
             self.timescan_progressbar = timescan_progressbar
-            self.bucket_to_use = bucket_to_use
-            self.threshold_counts = threshold_counts
 
         def time_scan(self):
             '''Method to run in the thread that does the timescan'''
@@ -1077,7 +1072,7 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
                 storage.storage.orbits_observe_before_timescan[board_id] = board.get_board_config(board_id).get("orbits_observe") # save old values to restore after timescan
                 board.get_board_config(board_id).update("orbits_observe", orbits_observe)
                 bk_change_num_of_orbits(board_id, orbits_observe)
-            if orbits_skip is not None:
+            if orbits_skip:
                 if not hasattr(storage.storage, 'orbits_skip_before_timescan'):
                     storage.storage.orbits_skip_before_timescan = {}
                 storage.storage.orbits_skip_before_timescan[board_id] = board.get_board_config(board_id).get("orbits_skip")
@@ -1133,25 +1128,14 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
                         return
 
                     for adc in range(4):
-                        if self.bucket_to_use is None:
-                            if self.threshold_counts is not None:
-                                indexes = np.where(np.logical_or(data.array[:, adc] > 2048+self.threshold_counts, data.array[:, adc] < 2048-self.threshold_counts))[0]
-                                if indexes.shape[0] == 0:
-                                    buckets = data.array[:, adc]
-                                else:
-                                    buckets = data.array[indexes, adc]
-                            else:
-                                buckets = data.array[:, adc]
-                        else:
-                            buckets = data.array[self.bucket_to_use::config.bunches_per_turn, adc]
+                        buckets = data.array[:, adc:adc + 1].reshape(-1)
                         heatmap[adc, f_step, c_step] = float(buckets.sum()) / buckets.shape[0]
-                        # Uncomment this to change back to the old (non functional) method of maxima determination
-                        # if heatmap[adc, f_step, c_step] > maximum[adc, 0]:
-                        #     maximum[adc, 0] = heatmap[adc, f_step, c_step]
-                        #     maximum[adc, 1] = coarse
-                        #     maximum[adc, 2] = fine
-                        # if minimum[adc] is None or minimum[adc] > heatmap[adc, f_step, c_step]:
-                        #     minimum[adc] = heatmap[adc, f_step, c_step]
+                        if heatmap[adc, f_step, c_step] > maximum[adc, 0]:
+                            maximum[adc, 0] = heatmap[adc, f_step, c_step]
+                            maximum[adc, 1] = coarse
+                            maximum[adc, 2] = fine
+                        if minimum[adc] is None or minimum[adc] > heatmap[adc, f_step, c_step]:
+                            minimum[adc] = heatmap[adc, f_step, c_step]
 
                     self.pbarSignal.emit(((c_step * (f_to - f_frm + 1)) + f_step) + 1)
 
@@ -1188,13 +1172,9 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
                 ]
         )
 
-#        maximum = []
-        for adc, a in enumerate(heatmap):
-            f, c = np.unravel_index(np.argmax(a), a.shape)
-	    maximum[adc] = [a[f, c], c+c_frm, f+f_frm]
 
         m = [np.min(heatmap[heatmap != 0]), np.max(heatmap)]  # this gives the same levels for all 4 adcs
-        plot_func(heatmap, levels=m, ranges=[c_frm,c_to,f_frm,f_to], newTitle=str(tr("sw", "Coarserange:{c_f}-{c_t} ; Finerange:{f_f}-{f_t}")).format(
+        plot_func(heatmap, levels=m, newTitle=str(tr("sw", "Coarserange:{c_f}-{c_t} ; Finerange:{f_f}-{f_t}")).format(
             c_f=c_frm,
             c_t=c_to,
             f_f=f_frm,
@@ -1229,7 +1209,7 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
 
         return
 
-    tst = thread_time_scan(c_frm, c_to, f_frm, f_to, timescan_progressbar, bucket_to_use, threshold_counts)
+    tst = thread_time_scan(c_frm, c_to, f_frm, f_to, timescan_progressbar)
     thread.register(tst)
     thread.connect('pbarSignal', timescan_progressbar.setValue)
     thread.connect('finished', lambda: finished(timescan_progressbar))
@@ -1286,11 +1266,10 @@ def bk_toggle_wait_on_trigger(board_id, num_of_acquisitions=None, skip=None, tim
             read sequentially
     :return:
     """
+
     thread = storage.get_board_specific_storage(board_id).setdefault('TriggerThread', storage.ThreadStorage())
     if thread.running:
-        Elements.getElements("acquireTrigger_{}".format(board_id))[0].setText(tr("Button", "Stopping Acquisition"))
-        # FIXME: Button not updated otherwise:
-        QtGui.qApp.processEvents()
+        # Elements.getElements("acquireTrigger_{}".format(board_id))[0].setText(tr("Button", "Start Acquisition"))
         log(board_id=board_id, additional="Stop wait on trigger on board {}".format(board_id))
         thread.quit()
         thread.stop()
@@ -1323,11 +1302,6 @@ def _bif_start_wait_on_trigger(board_id, num_of_acquisitions=None, skip=None, ti
             read sequentially
     :return: -
     """
-
-    # FIXme: This is a work around, for method 2 to work everytime a standard single read needs to be perform before acquisition is started
-    board.acquire_data(board_id, '/dev/null')
-    #with workaround no flush dema need, because it is done at end of board.acquire_data() anyway.
-    #board.flush_dma(board_id) # TODO: really at begining and end of function necessary?
     thread = storage.get_board_specific_storage(board_id).setdefault('TriggerThread', storage.ThreadStorage())
     if thread.running:
         logging.info("Wait already running on board {}".format(board_id))
@@ -1385,17 +1359,17 @@ def _bif_start_wait_on_trigger(board_id, num_of_acquisitions=None, skip=None, ti
 
             # Elements.setEnabled('acquireTrigger_{}'.format(board_id), False) # exclude=Elements.getElements('wait_on_trigger_{}'.format(board_id)))
 
-        def wait_rw_simul(self): # Method 1
+        def wait_rw_simul(self):
             '''Wait simultaniously (with the pci command) for a trigger signal'''
             board.pci.write(board_id, 'ff0', hex_mask='ff0')  # TODO: This writes t/h 3/4 but enable_transfer etc do not
             for num_of_acq in xrange(self.noa):
                 # def step():
-                if self._quit:
-                    break
                 filename = self.path +'/{:0.3f}.out'.format(time.time())
                 board.pci.read_data_to_file(board_id, filename=filename, timeout=(self.timeout*1000000))
                 # rename with correct timestamp - last modified time
                 self.countUpdate.emit(num_of_acq + 1)
+                if self._quit:
+                    break
 
                 # file operations
                 if not os.path.isfile(filename):
@@ -1416,7 +1390,7 @@ def _bif_start_wait_on_trigger(board_id, num_of_acquisitions=None, skip=None, ti
 
             self.finished.emit()
 
-        def wait_rw_seq(self): # Method 2
+        def wait_rw_seq(self):
             '''Wait sequentially (in the gui) for a trigger signal'''
             for num_of_acq in xrange(self.noa):
                 board.pci.write(board_id, '00bf0', hex_mask='CF0')  # enable readout
@@ -1437,8 +1411,7 @@ def _bif_start_wait_on_trigger(board_id, num_of_acquisitions=None, skip=None, ti
                     board.pci.read_data_to_file(board_id, filename=filename, timeout=(self.timeout*1000000))
                     # board.pci.write(board_id, '000f0', hex_mask='4F0') # disable transfer
                     self.countUpdate.emit(copy.deepcopy(num_of_acq+1))
-                    if self._quit:  # is this really the correct position? file is taken but not renamed!
-                        self.finished.emit()
+                    if self._quit:
                         break
 
                     if not os.path.isfile(filename):
@@ -1470,7 +1443,6 @@ def _bif_start_wait_on_trigger(board_id, num_of_acquisitions=None, skip=None, ti
             board.pci.write(board_id, '0', '902C')
             time.sleep(0.1)
             board.pci.write(board_id, '3f0', hex_mask='ff0')  # TODO: This writes t/h 3/4 but enable_transfer etc do not
-            board.flush_dma(board_id)
 
     def finished():
         '''Handle the end of the thread'''
@@ -1479,10 +1451,9 @@ def _bif_start_wait_on_trigger(board_id, num_of_acquisitions=None, skip=None, ti
         board.pci.write(board_id, '0', '902C')
         time.sleep(0.1)
         board.pci.write(board_id, '3f0', hex_mask='ff0')  # TODO: This writes t/h 3/4 but enable_transfer etc do not
-        board.flush_dma(board_id)
 
         thread.stop()
-        board.get_board_status(board_id).wait_on_trigger = False
+        board.get_board_status(board_id).wait = False
         storage.get_board_specific_storage(board_id).trigger_progressbar.remove(0)
         log(board_id=board_id, additional="Stop wait on trigger")
         Elements.setEnabled('acquire_{}'.format(board_id), True)

+ 1 - 1
KCG/base/bitsTable.py

@@ -317,7 +317,7 @@ class AdvancedBoardInterface(QtGui.QWidget):
         # self.parent.text_area.write("Writing to board Register 0x9040: %s" % ('0x{0:08x}'.format(dec_val_bits)))
         logging.info("Writing to board Register 0x9040: %s" % ('0x{0:08x}'.format(dec_val_bits)))
         try:
-            board.pci.write(self.board_id, hex(dec_val_bits), '0x9040')
+            board.write_pci(self.board_id, hex(dec_val_bits), '0x9040')
         except board.BoardError as e:
             QtGui.QMessageBox.critical(self, "Board communication",
                                        "Was unable to write value to board!\nReason: "+str(e)+"\nBoard: "+str(self.board_id))

+ 0 - 1
KCG/base/controlwidget.py

@@ -300,7 +300,6 @@ class BoardControl(kcgw.KCGWidgets):
         board.get_board_status(self.board_id).synced = True
         board.get_board_status(self.board_id).defaults_set = True
         bif.bk_status_readout()
-        logging.info("Initialisation skipped, configuration and status was read from KAPTURE.")
 
     def on_check(self):
         """

+ 12 - 63
KCG/base/kcg.py

@@ -109,8 +109,6 @@ def readconfig(parent):
         config.save_location = os.getcwd()
     else:
         config.save_location = config.default_save_location
-    
-    storage.storage.offset_correction = config.fifty_ohm_timescan_datafile
 
 
 _MultiView_Name_ = "MultiView"
@@ -278,63 +276,23 @@ class Gui(QtGui.QMainWindow):
         self.help.addAction(tr("Button", "Open Manual"), lambda: webbrowser.open(config.install_path + "Documentation/build/html/index.html"))
         self.help.addAction(tr("Button", "About"), self.showAbout)
 
-    def _show_board_chooser(self):
-        selected_boards = []
-        if len(available_boards.board_ids) == 1:
-            return [available_boards.board_ids[0]]
-        chooser = QtGui.QDialog(self)
-        chooser.setWindowTitle("KCG - Choose Boards")
-
-        
-        chooser_layout = QtGui.QVBoxLayout()
-        chooser.setLayout(chooser_layout)
-        chooser_layout.addWidget(QtGui.QLabel("Choose Boards"))
-        boards = {}
-        for bid in available_boards.board_ids:
-            boards[bid] = QtGui.QCheckBox(str(bid), chooser)
-            chooser_layout.addWidget(boards[bid])
-        button = QtGui.QPushButton("OK", chooser)
-        def ok():
-            for bi, box in boards.items():
-                if box.isChecked():
-                    selected_boards.append(bi)
-            chooser.close()
-        button.clicked.connect(ok)
-        chooser_layout.addWidget(button)
-        chooser.exec_()
-        return selected_boards
-
-
-    def saveConfig(self, board_id=None):
+    def saveConfig(self, board_id):
         """
         Save the current configuration to a configuration file
         :param board_id: the board to save the configuration for
         """
-
         filenameDialog = QtGui.QFileDialog(self, tr("Heading", "Save Configuration"), '', 'KAPTURE Configuration File (*.kcf)')
         filenameDialog.setDefaultSuffix("kcf")
         filenameDialog.setAcceptMode(filenameDialog.AcceptSave)
         filenameDialog.exec_()
         filename = filenameDialog.selectedFiles()
-        if not filename:
-            return
-
-        if board_id is None:
-            board_id = self._show_board_chooser()
-        elif not isinstance(board_id, list):
-            board_id = [board_id]
-
-
-        fname = filename[0].split(".")
-        for bid in board_id:
-            if len(board_id) == 1:
-                fname_board = filename[0]
-            else:
-                fname_board = ".".join(map(str, fname[:-1]))+"_"+str(bid)+"."+fname[-1]
-            if not board.get_board_config(bid).save_config(fname_board):
+        if filename[0]:
+            if not board.get_board_config(board_id).save_config(filename[0]):
                 QtGui.QMessageBox.critical(self, tr("Heading", "Error Saving Config"), tr("Dialog", "There was an error saving to a config file."))
+        else:
+            QtGui.QMessageBox.critical(self, tr("Heading", "Error Saving Config"), tr("Dialog", "There was an error saving to a config file."))
 
-    def loadConfig(self, board_id=None):
+    def loadConfig(self, board_id):
         """
         Load the configuration for the given board from a file
         :param board_id: the board to read the configuration for
@@ -342,18 +300,10 @@ class Gui(QtGui.QMainWindow):
         filename = QtGui.QFileDialog.getOpenFileName(self, 'Open Configuration', '', 'KAPTURE Configuration File (*.kcf)')
         if not filename:
             return
-
-
-        if board_id is None:
-            board_id = self._show_board_chooser()
-        elif not isinstance(board_id, list):
-            board_id = [board_id]
-
-        for bid in board_id:
-            if board.get_board_config(bid).load_config(filename):
-                bif.bk_write_values(bid, defaults=False)
-            else:
-                QtGui.QMessageBox.critical(self, tr("Heading", "Error Loading Config"), tr("Dialog", "There was an error loading the config file, make sure it is valid and try again."))
+        if board.get_board_config(board_id).load_config(filename):
+            bif.bk_write_values(board_id, defaults=False)
+        else:
+            QtGui.QMessageBox.critical(self, tr("Heading", "Error Loading Config"), tr("Dialog", "There was an error loading the config file, make sure it is valid and try again."))
 
     def rerunConfig(self):
         """
@@ -458,8 +408,7 @@ class Gui(QtGui.QMainWindow):
                 QtGui.QMessageBox.information(self, "Change Language", "Language change takes effect after Gui restart", 1)
             if setting == 'advanced_control':
                 self.showAdvancedControl(getattr(self.storage, setting))
-#	    if setting == 'offset_correction':
-#		config.fifty_ohm_timescan_datafile = getattr(self.storage, setting)
+
             for bid in available_boards.board_ids:
                 try:
                     if bif.bk_get_config(bid, setting) != None:
@@ -539,7 +488,7 @@ class Gui(QtGui.QMainWindow):
         """
         extra = ""
         for b in available_boards:
-            if board.get_board_status(b).wait_on_trigger:
+            if board.get_board_status(b).wait:
                 extra += '\n'+tr('Dialog', 'Waiting on external trigger is still enabled.')
             if board.get_board_status(b).continuous_read:
                 extra += '\n'+tr('Dialog', 'Continuous read is still enabled.')

+ 2 - 9
KCG/base/leftbar.py

@@ -10,7 +10,6 @@ import storage
 from ..widgets import acquiresettings as acqs
 from groupedelements import Elements
 import backendinterface as bif
-from ..widgets import singleread
 import log
 
 
@@ -317,7 +316,7 @@ class LeftBar(kcgw.KCGWidgets):
     # uid = unique_id
     # usid = unique_sub_id
     # upid = unique_parent_id
-    possiblePlots = ["Heatmap", "FFT", "Trains", "Combined", "Compare", "Follow"]
+    possiblePlots = ["Heatmap", "FFT", "Trains", "Combined", "Compare"]
 
     def __init__(self, parent):
         super(LeftBar, self).__init__("LeftBar")
@@ -336,9 +335,7 @@ class LeftBar(kcgw.KCGWidgets):
         Initialise the UI
         """
         self.layout = QtGui.QVBoxLayout()
-        self.layout.setContentsMargins(0, 0, 0, 0)
-
-
+        self.layout.setContentsMargins(0, 0, 5, 0)
         self.setMinimumWidth(230)
 
         self.treeWidget = QtGui.QTreeWidget()
@@ -352,12 +349,8 @@ class LeftBar(kcgw.KCGWidgets):
         self.rootItem = self.treeWidget.invisibleRootItem()
 
         self.infoAndAcquisitionWidget = AcquisitionAndInfo()
-        if config.integrate_single_read:
-            self.singleReadWidget = singleread.SingleReadWidget(0, self)
 
         self.layout.addWidget(self.treeWidget)
-        if config.integrate_single_read:
-            self.layout.addWidget(self.singleReadWidget)
         self.layout.addWidget(self.infoAndAcquisitionWidget)
 
         self.setLayout(self.layout)

+ 6 - 28
KCG/base/plotWidget.py

@@ -2,10 +2,7 @@
 This Module implements the Plot Windows used in KCG
 """
 import pyqtgraph as pg
-try:  # on some versions of pyqtgraph useOpenGl is no valid option
-    pg.setConfigOption('useOpenGl', True)
-except:
-    pass
+pg.setConfigOption('useOpenGl', True)
 pg.setConfigOption('background', 'w')
 pg.setConfigOption('foreground', 'k')
 import numpy as np
@@ -15,7 +12,6 @@ from backend import io
 from backend import board
 from backend.board import available_boards
 import kcgwidget as kcgw
-from .. import config
 
 tr = kcgw.tr
 
@@ -35,7 +31,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"), tr("Label", "Follow")]
+plotList = [tr("Label", "Heatmap"), tr("Label", "FFT"), tr("Label", "Trains"), tr("Label", "Combined"), tr("Label", "Compare")]
 PlotType = Enum(*[str(i) for i in plotList])
 
 # gradient = {'mode': 'rgb',
@@ -337,8 +333,6 @@ 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)
@@ -447,7 +441,7 @@ class SubPlotWidget(pg.GraphicsLayoutWidget):
             self._disableCustomAutoRange()
             self.plotItem.setClipToView(True)
 
-        if self.plotType == PlotType.Trains or self.plotType == PlotType.Follow:
+        if self.plotType == PlotType.Trains:
             self.img.clear()
             self.plotItemPlot.show()
             self.gradient_legend.hide()
@@ -513,7 +507,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 or self.plotType == PlotType.Follow:
+        elif self.plotType == PlotType.Trains:
             self.plotItem.setLabel('left', '', '')
             self.plotItem.setLabel('bottom', 'Sample Point', '')
         elif self.plotType == PlotType.Combined:
@@ -609,10 +603,9 @@ 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.Follow:self.follow_button}
+                             PlotType.Compare:self.compare_button}
         self.defaultButtonStyleSheet = self.heatmap_button.styleSheet()
 
         self.adc1 = self.createCheckbox(text="ADC 1", connect=self.change_adc)
@@ -626,7 +619,6 @@ 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)
@@ -677,16 +669,9 @@ 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:")))
@@ -763,10 +748,6 @@ 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
@@ -801,7 +782,7 @@ class PlotWidget(kcgw.KCGWidgets):
                     type = self._old_type
                 else:
                     type = self.theType
-            if type == PlotType.Trains or type == PlotType.Combined or type == PlotType.Follow:
+            if type == PlotType.Trains or type == PlotType.Combined:
                 self.do_plot(type, autorange=True)
             else:
                 self.do_plot(type, autorange=False)
@@ -850,7 +831,6 @@ 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,
@@ -861,8 +841,6 @@ 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)
 

+ 3 - 6
KCG/base/settings.py

@@ -28,7 +28,6 @@ class Settings(kcgw.KCGWidgets):
         self.headerTick = self.build_new_setting(QtGui.QCheckBox(tr("Button", "Header")), 'header')
         self.subDirName = self.build_new_setting(self.createInput(self.storage_handler.subdirname, width=320), 'subdirname')
         self.dirName = self.build_new_setting(self.createInput(self.storage_handler.save_location, width=320), 'save_location')
-        self.timescan_offset_correction = self.build_new_setting(self.createInput(self.storage_handler.offset_correction, width=320), 'offset_correction')
         self.language = self.build_new_setting(QtGui.QComboBox(), 'language')
         self.advanced_control = self.build_new_setting(self.createCheckbox(tr("Label", "Enable Advanced Table View")), 'advanced_control')
         for lang in self.langlist:
@@ -63,11 +62,9 @@ class Settings(kcgw.KCGWidgets):
         self.grid.addWidget(self.subDirName, 1, 1)
         self.grid.addWidget(self.createLabel(tr("Label", "Save location:")), 2, 0)
         self.grid.addWidget(self.dirName, 2, 1)
-        self.grid.addWidget(self.createLabel(tr("Label", "Timescan Offset Correction:")), 3, 0)
-        self.grid.addWidget(self.timescan_offset_correction, 3, 1)
-        self.grid.addWidget(self.createLabel(tr("Label", "Language")), 4, 0)
-        self.grid.addWidget(self.language, 4, 1)
-        self.grid.addWidget(self.advanced_control, 5, 0)
+        self.grid.addWidget(self.createLabel(tr("Label", "Language")), 3, 0)
+        self.grid.addWidget(self.language, 3, 1)
+        self.grid.addWidget(self.advanced_control, 4, 0)
         self.hbox = QtGui.QHBoxLayout()
         self.layout.addLayout(self.hbox)
         self.hbox.addStretch(1)

+ 2 - 11
KCG/base/storage.py

@@ -62,14 +62,6 @@ class ThreadStorage(object):
     """
     Wrapper for QThreads
     """
-    #FixMe: I am a workaround, because before the acquisition thread was not used and the acquisition accidentally run in the main thread
-    class TThread(QtCore.QThread):
-        def run(self):
-            self.m()
-
-        def set_run_method(self, m):
-            self.m=m
-
     def __init__(self):
         self._q_thread = None
         self._threaded_object = None
@@ -82,8 +74,8 @@ class ThreadStorage(object):
         :return:
         """
         del self._q_thread  # start over
-        self._q_thread = ThreadStorage.TThread()
-        #self._q_thread.started.connect(self.__start)
+        self._q_thread = QtCore.QThread()
+        self._q_thread.started.connect(self.__start)
         self._threaded_object = threaded_object
 
     def is_registered(self):
@@ -114,7 +106,6 @@ class ThreadStorage(object):
         else:
             self._start_method = method_to_run_in_thread
             # self._q_thread.started.connect(method_to_run_in_thread)
-        self._q_thread.set_run_method(self._start_method)
         self._q_thread.start()
         self.running = True
 

+ 0 - 8
KCG/config.cfg

@@ -48,9 +48,6 @@ force_ask = False
 # Show advanced table view per default? (boolean value)
 show_advanced_control = False
 
-# Integrate the single read functionality into the left bar above the general acquisition widget
-integrate_single_read = False
-
 [Logging]
 # These are PVs that will be possible to insert into log files
 # This variable is to be a list consisting of touples of two entries,
@@ -122,8 +119,3 @@ device_list = []
 # format is: device_names = {'device id': 'device name', ...}
 # if this is an empty dict it won't be used
 device_names = {'test0': 'ich_bin_toll', 'test1': 'ne'}
-# num_dummy_boards is the number of dummy boards to create
-num_dummy_boards = 5
-
-# Datafile whith Timescandata for 50ohm termination
-fifty_ohm_timescan_datafile = "Put 'fifty_ohm_timescan_datafile = path_to_50_ohm_termination_timescanfile' into ~/.kcg/config.cfg"

+ 2 - 3
KCG/config.py

@@ -134,12 +134,11 @@ class Configuration(object):
         defaultConfig.read(os.path.join(os.path.dirname(__file__), "config.cfg"))
 
         Machine_conf = ["bunches_per_turn", "save_header", "tRev"]
-        Ui_conf = ["language", "default_save_location", "default_subdirectory_name", "force_ask", "show_advanced_control", "integrate_single_read"]
+        Ui_conf = ["language", "default_save_location", "default_subdirectory_name", "force_ask", "show_advanced_control"]
         Logging_conf = ["epics_test_pv", "epics_base_path", "epics_log_entry_pvs", "default_log_entries"]
         Misc_conf = ['newPlotLiveIcon', 'newPlotDataIcon', 'timingIcon', 'singleReadIcon',
                      'acquireSettingsIcon', 'startIcon', 'stopIcon', 'logIcon', 'logCommentIcon', 'guiIcon', 'style',
-                     'board_detection_method', 'device_list', 'device_names',
-                     'num_dummy_boards', 'fifty_ohm_timescan_datafile']
+                     'board_detection_method', 'device_list', 'device_names']
 
         try:
             machine_c = ConfSection('Machine', Machine_conf, config, log_level=self._log_level)

+ 0 - 1
KCG/kcg.py

@@ -139,7 +139,6 @@ def run():
         conf.doSetup()
     if args.testing:
         config.default_subdirectory_name = 't'
-        config.board_detection_method = 'dummy'
 
     import base.kcg as kcg
 

+ 2 - 4
KCG/widgets/singleread.py

@@ -41,9 +41,8 @@ class SingleReadWidget(kcgw.KCGWidgets):
         # ---------[ Create Labels and corresponding Fields ]---------
         self.single_read_button = self.createButton(tr("Button", "Single Read"), connect=self.on_single_read)
         self.interval_spinbox = self.createSpinbox(0, 100000, start_value=1000)
-        self.interval_spinbox.valueChanged.connect(self.set_interval)
 
-        self.board_ticks = {board_id: self.createCheckbox(str(board_id), checked=True if board_id==0 else False) for board_id in available_boards}
+        self.board_ticks = {i: self.createCheckbox(str(i)) for i in available_boards}
         self.board_ticks_continuous_read = {
             board_id: self.createCheckbox(str(board_id),
                                           connect=lambda state, b_id=board_id:
@@ -87,7 +86,7 @@ class SingleReadWidget(kcgw.KCGWidgets):
         self.outerLayout.addLayout(self.tickLayoutContinuousRead)
         self.outerLayout.addLayout(self.tickLayout)
         self.outerLayout.addLayout(self.layout)
-#        self.outerLayout.addStretch(1)
+        self.outerLayout.addStretch(1)
 
         self.set_interval()
 
@@ -108,7 +107,6 @@ class SingleReadWidget(kcgw.KCGWidgets):
         :return: -
         """
         # if self.board_ticks_continuous_read[id].isChecked():
-        self.set_interval()
         if state:
             # self.continuous_read_button.setText(tr("Button", "Stop Continuous Read"))
             # self.continuous_read[id] = True

+ 31 - 141
KCG/widgets/timingWidget.py

@@ -14,7 +14,6 @@ from ..base import backendinterface as bif
 from ..base.groupedelements import Elements
 from ..base.globals import glob as global_objects
 from .. import config
-from ..base import storage
 
 tr = kcgw.tr
 
@@ -22,8 +21,6 @@ __widget_id__ = None
 __timing_plot_widget_id__ = {}
 __timing_plot_widget__ = None
 
-BUNCHES_PER_TURN = config.bunches_per_turn
-
 class timingPlotWidget(kcgw.KCGWidgets):
     """
     The Timescan result plot subwindow.
@@ -43,8 +40,6 @@ class timingPlotWidget(kcgw.KCGWidgets):
 
         # ------[ Variable declaration ]------------
         self.plot_type = "colour"  # The Plot Type for this window (Changeable in this window)
-        self.xrange = (None, None)
-        self.yrange = (None, None)
         self.x = None  # Number of Ticks in the x-direction     This is set by the gui programmatically
         self.y = None  # Number of Ticks in the y-direction     This is set by the gui programmatically
         self.data = None  # Data to plot
@@ -69,22 +64,12 @@ class timingPlotWidget(kcgw.KCGWidgets):
         self.position_label = self.createLabel("")
         self.position_label.setAlignment(QtCore.Qt.AlignCenter)
         self.plot_type_switcher = self.createSwitch(connect=self.switch)
-        self.zero_correction_switcher = self.createSwitch(connect=self.zero_correction)
-        self.uses_zero_correction = False
-        self.zero_correction_values = None
 
         # ------[ Add Elements to various layouts ]--------------
         self.headerLayout.addWidget(self.position_label)
         self.headerLayout.addWidget(self.createLabel("Colour Plot"))
         self.headerLayout.addWidget(self.plot_type_switcher)
         self.headerLayout.addWidget(self.createLabel("Line Plot"))
-        t = QtGui.QFrame()
-        t.setFrameShape(QtGui.QFrame.VLine)
-        t.setFrameShadow(QtGui.QFrame.Sunken)
-        self.headerLayout.addWidget(t)
-        self.headerLayout.addWidget(self.createLabel("RawData"))
-        self.headerLayout.addWidget(self.zero_correction_switcher)
-        self.headerLayout.addWidget(self.createLabel("Corrected"))
         self.headerLayout.setAlignment(QtCore.Qt.AlignRight)
         self.layout.addWidget(self.adc1_plot_widget, 0, 0)
         self.layout.addWidget(self.adc2_plot_widget, 0, 1)
@@ -113,46 +98,6 @@ class timingPlotWidget(kcgw.KCGWidgets):
             self.colour_plot()
             self.plot()
 
-    def zero_correction(self):
-        """
-        Toggle Zero (50Ohm) Correction
-        """
-	# Note: when selecting a slice the upper bound has to be included since that's how the timescan works. Python array slicing does not include the upper bound => +1
-        if self.uses_zero_correction:
-            self.uses_zero_correction = False
-            self.data += self.zero_correction_values[:, self.xrange[0]:self.xrange[1]+1, self.yrange[0]:self.yrange[1]+1]
-
-        else:
-            self.uses_zero_correction = True
-            if self.zero_correction_values is None:
-                # Adjust for closed measurement of 0 (Measured using a 50 ohm impedance
-                # This will read the complete file into memory. Could be optimized to read only necessary values
-#                f = file(config.fifty_ohm_timescan_datafile)
-		f = file(storage.storage.offset_correction)
-                c_adc = -1  # -1 because first adc will have #ADC0 and this will increment c_adc
-                self.zero_correction_values = np.zeros((4, 32, 16))  # we know there are 4 adcs, 16 coarse delays and 32 fine delays
-		all_check = np.zeros((4, 32, 16), dtype=np.bool)
-                for line in f:
-                    line = line.strip()
-                    if line == "": continue  # skip empty lines
-                    if line.startswith("#"):
-                        c_adc += 1  # c_adc = int(line.split("_")[-1])
-                        continue
-                    coarse, fine, value = line.split(";")
-                    self.zero_correction_values[c_adc, int(fine), int(coarse)] = value
-		    all_check[c_adc, int(fine), int(coarse)] = True
-		if False in all_check:
-		    logging.warn("Read 50Ohm timescan for offset correction does not include all delay values")
-
-            self.data -= self.zero_correction_values[:, self.xrange[0]:self.xrange[1]+1, self.yrange[0]:self.yrange[1]+1]
-
-	maxima = np.zeros((4, 3))
-	for adc, a in enumerate(self.data):
-	    f, c = np.unravel_index(np.argmax(a), a.shape)
-	    maxima[adc] = [a[f, c], c+self.yrange[0], f+self.xrange[0]]
-
-        self.plot(maxima=maxima)
-
     def colour_plot(self):
         """
         Initialize Color Plot
@@ -169,33 +114,27 @@ class timingPlotWidget(kcgw.KCGWidgets):
         self.adc3.mouseClickEvent = lambda x: self.click("ADC 3", x)
         self.adc4.mouseClickEvent = lambda x: self.click("ADC 4", x)
 
-        def xtickStrings(values, scale, spacing):
-            """
-            Generate the strings for ticks
-            """
-            return [str(i + self.xrange[0]) for i in range(int(values[0]), int(values[-1]),int(spacing))]
-
-        def ytickStrings(values, scale, spacing):
+        def tickStrings(values, scale, spacing):
             """
             Generate the strings for ticks
             """
-            return [str(int(i) + self.yrange[0]) for i in values]
+            if len(values) > 20:
+                return [str(i) for i in range(int(values[0]), int(values[-1]), 2)]
+            else:
+                return [str(int(i)) for i in values]
 
         # ----------[ Configure and add color plots for ADC1 ]----------
 
         for i in range(1, 5):
-            getattr(self, "adc{}_plot_widget".format(i)).enableAutoRange() #axis=getattr(self, "adc{}_plot_widget".format(i)).getViewBox().YAxis)
             getattr(self, "adc{}_plot_widget".format(i)).getPlotItem().setLabel("left", tr("Heading", "Coarse delay"))
             getattr(self, "adc{}_plot_widget".format(i)).getPlotItem().setLabel("bottom", tr("Heading", "Fine delay"))
             getattr(self, "adc{}_plot_widget".format(i)).plotItem.addItem(getattr(self, "adc"+str(i)))
             bax = getattr(self, "adc{}_plot_widget".format(i)).plotItem.getAxis('bottom')
             lax = getattr(self, "adc{}_plot_widget".format(i)).plotItem.getAxis('left')
-
-            bax.tickSpacing = self.spacing
-            bax.tickStrings = xtickStrings
+            bax.setTickSpacing(levels=[(1, 2.5),])
+            bax.tickStrings = tickStrings
             lax.setTickSpacing(levels=[(1, 1.5),])
-            lax.tickStrings = ytickStrings
-
+            lax.tickStrings = tickStrings
 
         pos = np.array([0, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1])
         color = np.array([[0, 0, 255, 255], [0, 255, 255, 255], [0, 255, 0, 255], [130, 255, 0, 255], [255, 255, 0, 255], [255, 180, 0, 255], [255, 100, 0, 255], [255, 0, 0, 255]])
@@ -225,8 +164,8 @@ class timingPlotWidget(kcgw.KCGWidgets):
         :param spacing: See pyqtgraph.AxisItem.tickStrings
         :return: See pyqtgraph.AxisItem.tickStrings
         """
-        coarses = [self.yrange[0] + i//(self.x) for i in values]
-        fines = [self.xrange[0] + i%(self.x) for i in values]
+        coarses = [i//(self.x) for i in values]
+        fines = [i%(self.x) for i in values]
         return [str(int(c))+"\n"+str(int(f)) for c, f in zip(coarses, fines)]
 
     def spacing(self, minVal, maxVal, size):
@@ -238,10 +177,10 @@ class timingPlotWidget(kcgw.KCGWidgets):
         :param size: See pyqtgraph.AxisItem.tickSpacing
         :return: See pyqtgraph.AxisItem.tickSpacing
         """
-        if maxVal - minVal < 10.:
+        if maxVal - minVal < 20.:
             return [(1, 0),]
         else:
-            return [(round((maxVal-minVal)/10.), 0),]
+            return [(round((maxVal-minVal)/20.), 0),]
 
     def y_axis_strings(self, values, scale, spacing):
         """
@@ -251,9 +190,7 @@ class timingPlotWidget(kcgw.KCGWidgets):
         :param spacing:
         :return:
         """
-	if np.mean(values) > 3:
-	    return [str(int(v)) for v in values]
-        return [str(v) for v in values]
+        return [str(int(v)) for v in values]
 
     def line_plot(self):
         """
@@ -263,13 +200,10 @@ class timingPlotWidget(kcgw.KCGWidgets):
         self.plot_type = "line"
 
         for i in range(1, 5):
-            getattr(self, "adc{}_plot_widget".format(i)).enableAutoRange() #axis=getattr(self, "adc{}_plot_widget".format(i)).getViewBox().YAxis)
             getattr(self, "adc{}_plot_widget".format(i)).getPlotItem().setLabel("left", tr("Heading", "Intensity"))
             getattr(self, "adc{}_plot_widget".format(i)).getPlotItem().setLabel("bottom", tr("Heading", "Coarse over Fine"))
             bax = getattr(self, "adc{}_plot_widget".format(i)).plotItem.getAxis('bottom')
             lax = getattr(self, "adc{}_plot_widget".format(i)).plotItem.getAxis('left')
-
-            bax.setTickSpacing()
             bax.tickSpacing = self.spacing
             bax.tickStrings = self.line_plot_axis_strings
             lax.setTickSpacing()
@@ -298,26 +232,25 @@ class timingPlotWidget(kcgw.KCGWidgets):
         """
         event.accept()
         pos = event.pos()
-        self.position_label.setText(adc + " - " + str(int(pos.x())+self.xrange[0]) + ":"+str(int(pos.y())+self.yrange[0]))
+        self.position_label.setText(adc + " - " + str(int(pos.x())) + ":"+str(int(pos.y())))
         if not self.inputsSet:
             return
 
-        self.c_input.setValue(int(pos.y())+self.yrange[0])
+        self.c_input.setValue(int(pos.y()))
         if adc == "ADC 1":
-            self.adc1_f_input.setValue(int(pos.x())+self.xrange[0])
+            self.adc1_f_input.setValue(int(pos.x()))
         elif adc == "ADC 2":
-            self.adc2_f_input.setValue(int(pos.x())+self.xrange[0])
+            self.adc2_f_input.setValue(int(pos.x()))
         elif adc == "ADC 3":
-            self.adc3_f_input.setValue(int(pos.x())+self.xrange[0])
+            self.adc3_f_input.setValue(int(pos.x()))
         elif adc == "ADC 4":
-            self.adc4_f_input.setValue(int(pos.x())+self.xrange[0])
+            self.adc4_f_input.setValue(int(pos.x()))
 
-    def plot(self, data=None, levels=None, ranges=None, newTitle=None, maxima=None):
+    def plot(self, data=None, levels=None, newTitle=None, maxima=None):
         """
         Plot Data
         :param data: (numpy 4d array) data to plot
         :param levels: (tuple) Min and Max Values for color plot
-        :param ranges: (list) From to range of coarse (y) and fine (x) delay scan
         :param newTitle: (str) The title for the window
         :param maxima: (list) Maximum for each adc
         :return: -
@@ -330,10 +263,6 @@ class timingPlotWidget(kcgw.KCGWidgets):
             self.data = data # if called with no data a replot is performed (if data is set previously)
         if levels is not None:
             self.levels = levels
-        if ranges is not None:
-            self.yrange = ranges[0:2]
-            self.xrange = ranges[2:4]
-
         self.x = self.data.shape[1]
         self.y = self.data.shape[2]
         if self.plot_type == 'colour':
@@ -351,15 +280,15 @@ class timingPlotWidget(kcgw.KCGWidgets):
                 self.setWindowTitle(tr("Heading", "Timescan Result:") + " " + newTitle + " " +
                                     available_boards.get_board_name_from_id(self.board_id))
 
-        if maxima is not None:
-            self.adc1_plot_widget.getPlotItem().setTitle(str(tr("Heading", "ADC 1: Maximum C:{c} F:{f}")).format(
-	        c=int(maxima[0, 1]), f=int(maxima[0, 2])))
-	    self.adc2_plot_widget.getPlotItem().setTitle(str(tr("Heading", "ADC 2: Maximum C:{c} F:{f}")).format(
-	        c=int(maxima[1, 1]), f=int(maxima[1, 2])))
-	    self.adc3_plot_widget.getPlotItem().setTitle(str(tr("Heading", "ADC 3: Maximum C:{c} F:{f}")).format(
-	        c=int(maxima[2, 1]), f=int(maxima[2, 2])))
-	    self.adc4_plot_widget.getPlotItem().setTitle(str(tr("Heading", "ADC 4: Maximum C:{c} F:{f}")).format(
-	        c=int(maxima[3, 1]), f=int(maxima[3, 2])))
+            if maxima is not None:
+                self.adc1_plot_widget.getPlotItem().setTitle(str(tr("Heading", "ADC 1: Maximum C:{c} F:{f}")).format(
+                    c=int(maxima[0, 1]), f=int(maxima[0, 2])))
+                self.adc2_plot_widget.getPlotItem().setTitle(str(tr("Heading", "ADC 2: Maximum C:{c} F:{f}")).format(
+                    c=int(maxima[1, 1]), f=int(maxima[1, 2])))
+                self.adc3_plot_widget.getPlotItem().setTitle(str(tr("Heading", "ADC 3: Maximum C:{c} F:{f}")).format(
+                    c=int(maxima[2, 1]), f=int(maxima[2, 2])))
+                self.adc4_plot_widget.getPlotItem().setTitle(str(tr("Heading", "ADC 4: Maximum C:{c} F:{f}")).format(
+                    c=int(maxima[3, 1]), f=int(maxima[3, 2])))
         if self.plot_type == 'line':
             # self.line_plot()
             def reshape(data):
@@ -369,7 +298,6 @@ class timingPlotWidget(kcgw.KCGWidgets):
             self.adc2_plot_widget.plotItem.clear()
             self.adc3_plot_widget.plotItem.clear()
             self.adc4_plot_widget.plotItem.clear()
-
             self.adc1_plot_widget.plotItem.plot(reshape(self.data[0]))
             self.adc2_plot_widget.plotItem.plot(reshape(self.data[1]))
             self.adc3_plot_widget.plotItem.plot(reshape(self.data[2]))
@@ -423,18 +351,6 @@ class timingPart(kcgw.KCGWidgets):
         self.fine_scan_min_spinbox = self.createSpinbox(0, bif.bk_get_config(board_id, 'chip_delay_max'), start_value=0)
         self.fine_scan_max_spinbox = self.createSpinbox(0, bif.bk_get_config(board_id, 'chip_delay_max'), start_value=bif.bk_get_config(board_id, 'chip_delay_max'))
 
-        self.average_one_bunch_label = self.createLabel(tr("Label", "Average bunch number"))
-        self.average_all_bunches_checkbox = self.createCheckbox(tr("Button", "Average all bunches"), tr("Tooltip", "Average over signal from all bunches for timescan"),
-                                                         checked=True,connect=self.showAverageOneBunch)
-        self.average_one_bunch_spinbox = self.createSpinbox(0, BUNCHES_PER_TURN-1, start_value=0)
-        self.average_one_bunch_spinbox.setEnabled(False)
-
-        self.average_threshold_label = self.createLabel(tr("Label", "Averaging Threshold"))
-        self.average_threshold_checkbox = self.createCheckbox(tr("Button", "Use Threshold"), tr("Tooltip", "Average over signal from all bunches that are above/below the specified threshold for timescan"),
-                                                         checked=False,connect=self.considerThreshold)
-        self.average_threshold_spinbox = self.createSpinbox(0, 2048, start_value=0)
-        self.average_threshold_spinbox.setEnabled(False)
-
         self.orbits_observe_spinbox = self.createSpinbox(1, 10000000, start_value=100)
         self.orbits_skip_spinbox = self.createSpinbox(0, 100, start_value=2)
 
@@ -461,13 +377,7 @@ class timingPart(kcgw.KCGWidgets):
         self.timeScanLayout.addWidget(self.orbits_observe_spinbox, 3, 2)
         self.timeScanLayout.addWidget(self.createLabel("Orbits to Skip"), 4, 1)
         self.timeScanLayout.addWidget(self.orbits_skip_spinbox, 4, 2)
-        self.timeScanLayout.addWidget(self.average_all_bunches_checkbox, 5, 0)
-        self.timeScanLayout.addWidget(self.average_one_bunch_label, 5, 1)
-        self.timeScanLayout.addWidget(self.average_one_bunch_spinbox, 5, 2)
-        self.timeScanLayout.addWidget(self.average_threshold_checkbox, 6, 0)
-        self.timeScanLayout.addWidget(self.average_threshold_label, 6, 1)
-        self.timeScanLayout.addWidget(self.average_threshold_spinbox, 6, 2)
-        self.timeScanLayout.addWidget(self.time_scan_button, 7, 2)
+        self.timeScanLayout.addWidget(self.time_scan_button, 5, 2)
         self.setTabOrder(self.fine_scan_max_spinbox, self.time_scan_button)
 
         #  --------[ End Time Scan Part ]-------------
@@ -633,24 +543,6 @@ class timingPart(kcgw.KCGWidgets):
         if not self.adc1CoarseInput.isEnabled():
             board.get_board_config(self.board_id).update('adc_1_delay_individual', -1) # Be careful this does no silent update
 
-    def showAverageOneBunch(self):
-        """
-        Toggle to use an individual bunch for the averaging in the time delay scan or to use all bunches
-        :return: -
-        """
-        self.average_one_bunch_spinbox.setEnabled(not self.average_all_bunches_checkbox.checkState())
-        self.average_threshold_spinbox.setEnabled(self.average_all_bunches_checkbox.checkState() and self.average_threshold_checkbox.checkState())
-        self.average_threshold_checkbox.setEnabled(self.average_all_bunches_checkbox.checkState())
-        self.average_threshold_checkbox.setChecked(False)
-
-    def considerThreshold(self):
-        """
-        Toggle to consider the Threshold for the averaging in the time delay scan
-        :return: -
-        """
-        self.average_threshold_spinbox.setEnabled(self.average_threshold_checkbox.checkState() and self.average_all_bunches_checkbox.checkState())
-
-
     def showTimeScan(self):
         """
         Show the time scan part of this window
@@ -694,9 +586,7 @@ class timingPart(kcgw.KCGWidgets):
             self.time_scan_progressbar,
             self.plotWidget.plot,
             orbits_observe = self.orbits_observe_spinbox.value(),
-            orbits_skip = self.orbits_skip_spinbox.value(),
-            bucket_to_use = self.average_one_bunch_spinbox.value() if self.average_one_bunch_spinbox.isEnabled() else None,
-            threshold_counts = self.average_threshold_spinbox.value() if self.average_threshold_spinbox.isEnabled() else None
+            orbits_skip = self.orbits_skip_spinbox.value()
         )
 
     def setValueSilent(self, element, value):

+ 6 - 24
README.md

@@ -4,34 +4,16 @@ KCG is the Graphical Control Interface to the KAPTURE-Readout-Board.
 
 ## Prerequisites:
 
-(Windows support is not tested)
-
-### Must be installed by system packagemanager
-
 - python 2.7.x
-- PyQt4
-
-To install on debian e.g.:
-
-- sudo apt-get install python
-- sudo apt-get install python-qt4
-
-### Will be installed via installing of KCG (if will be installed else those have to be installed seperately)
-
+- PyQt4 (python-qt)
 - pyqtgraph
 - numpy
 
-To manually install them use e.g. pip:
-
-- pip install pyqtgraph
-- pip install numpy
-
 ## Download
 
 #### Stable Version
 
-To get the latest stable version get the latest release from [here](https://git.lycab.de/KIT/KCG/releases)
-
+To get the latest stable version get the latest release from [here](https://psraspi.no-ip.biz/gogs/calipp/KCG/releases)
 #### Development Version
 
 To get the latest development Version clone this repository 
@@ -47,8 +29,8 @@ You can install KCG or run without intstallation
 
 ### Install
 
-To install KCG (either system- or userwide) use (inside the repository) `pip install .` with optionally `--user` as flag to install 
-only for current user.  To start KCG after installation simply run `kcg` from whereever you are.  
+To install KCG (either system- or userwide) use `python setup.py install` with optionally `--user` as flag to install only for current user.  
+To start KCG after installation simply run `kcg` from whereever you are.  
 Upon first run you will be prompted to configure KCG this will set appropriate values and write them to ~/.kcg/config.cfg  
 
 #### NOTE: 
@@ -56,11 +38,11 @@ If you chose to install for current user only you need to have $HOME/.local/bin
 
 ### Run without installation
 
-You can run KCG directly without installation. To do so, simply run `./kcg` in the outer KCG directory.
+You can run KCG directly without installation. To do so, simply run kcg in the outer KCG directory.
     You will still be asked to configure KCG if it is the first run.
 
 
 ### Unintentional Features
-If you find any unintentional features (bugs) or have questions please let me know via [issues](https://git.lycab.de/KIT/KCG/issues).
+If you find any unintentional features (bugs) or have questions please let me know via [issues](https://psraspi.no-ip.biz/gogs/calipp/KCG/issues).
 
 

+ 2 - 8
setup.py

@@ -1,17 +1,11 @@
 #!/usr/bin/python
 from setuptools import setup, find_packages
-import time, subprocess
+
 DESCRIPTION = "KCG KAPTURE Control Gui"
-git_count = subprocess.check_output(["git", "rev-list", "--count", "HEAD"]).strip()
-version_time = time.strftime("%d%m%y")
-VERSION = "0.3.2."+git_count+"."+version_time+"-beta"
-with open("KCG/VERSION", 'w') as vfile:
-    vfile.write(VERSION)
 
 setup(
     name='KCG',
-#    version='0.3.2.197.0704-beta',
-    version=VERSION,
+    version='0.3.2.180.0414-beta',
     author='Patrick Schreiber',
     author_email='uldfk@student.kit.edu',
 #    license='GPL',