瀏覽代碼

update ConfigSetup & changed Orbits to turns

Matze 6 年之前
父節點
當前提交
9740dee81d

+ 10 - 10
KCG/Documentation/source/Dev/code/base/backendinterface.rst

@@ -165,17 +165,17 @@ Functions only used internal in this module will be prefixed _bif_
     :param board_id: the id of the board  
     :return: the config instance  
 
-.. py:method:: bk_change_num_of_orbits(board_id, value, silent=False)
+.. py:method:: bk_change_num_of_turns(board_id, value, silent=False)
 
-    Send new number of orbits to board and update in config  
+    Send new number of turns to board and update in config  
 
     :param board_id: id of the board do manipulate  
     :param value: the value to send  
     :param silent: (bool) if True do not inform observers on update  
 
-.. py:method:: bk_change_num_of_skipped_orbits(board_id, value, silent=False)
+.. py:method:: bk_change_num_of_skipped_turns(board_id, value, silent=False)
 
-    Send new number of orbits to skip to board and update in config  
+    Send new number of turns to skip to board and update in config  
 
     :param board_id: id of the board do manipulate  
     :param value: the value to send  
@@ -319,7 +319,7 @@ Functions only used internal in this module will be prefixed _bif_
 
     :param board_id: id of the board do manipulate  
 
-.. py:method:: bk_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, orbits_observe=None, orbits_skip=None)
+.. py:method:: bk_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, turns_observe=None, turns_skip=None)
 
     Toggle Timescan.  
 
@@ -330,8 +330,8 @@ Functions only used internal in this module will be prefixed _bif_
     :param f_to: (int) To value for fine scan  
     :param ts_pbar: Handle to the Timescan Progressbar  
     :param plot_func: Function to plot when timescan ended.  
-    :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 skipfor the timescan (original values will be restored after timescan)  
+    :param turns_observe: Number of turns to observe for the timescan (original values will be restored after timescan)  
+    :param turns_skip: Number of turns to skipfor the timescan (original values will be restored after timescan)  
 
 .. py:method:: _bif_stop_time_scan(board_id, ts_pbar)
 
@@ -340,7 +340,7 @@ Functions only used internal in this module will be prefixed _bif_
     :param board_id: id of the board do manipulate  
     :param ts_pbar: Timescan Progressbar handle  
 
-.. py:method:: _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressbar, plot_func, orbits_observe, orbits_skip)
+.. py:method:: _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressbar, plot_func, turns_observe, turns_skip)
 
     Start the timscan. This starts the timer  
 
@@ -351,8 +351,8 @@ Functions only used internal in this module will be prefixed _bif_
     :param f_to: To value for fine scan  
     :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 skipfor the timescan (original values will be restored after timescan)  
+    :param turns_observe: Number of turns to observe for the timescan (original values will be restored after timescan)  
+    :param turns_skip: Number of turns to skipfor the timescan (original values will be restored after timescan)  
 
 .. py:method:: bk_check_for_board(board_id)
 

+ 4 - 4
KCG/Documentation/source/Dev/code/widgets/acquiresettings.rst

@@ -64,13 +64,13 @@ This Module Is the Acquiresettings subWindow.
         This will read the appropriate Values from the base.backend.board.BoardConfiguration instance used in the gui.  
 
 
-    .. py:method:: on_number_of_orbits_changed(self)
+    .. py:method:: on_number_of_turns_changed(self)
 
-        Handle the change of the number of orbits  
+        Handle the change of the number of turns  
 
-    .. py:method:: on_number_of_skipped_orbits_changed(self)
+    .. py:method:: on_number_of_skipped_turns_changed(self)
 
-        Handle the change of the number of skipped orbits  
+        Handle the change of the number of skipped turns  
 
     .. py:method:: on_count_changed(self)
 

+ 1 - 1
KCG/Documentation/source/Man/acquisition.rst

@@ -20,7 +20,7 @@ The acquisition settings subwindow looks as follows.
 .. figure:: _static/AcquireSettings.png
     :alt: Acquisition settings subwindow
 
-Here you can adjust how many orbits you want to observe, how many orbits you want to skip between each observed
+Here you can adjust how many turns you want to observe, how many turns you want to skip between each observed
 orbit, how many of those acquisitions you want to take and how long to wait between each acquisition.
 
 You can also enable or disable the pilot bunch generator.

+ 9 - 9
KCG/base/backend/board/board_config.py

@@ -60,10 +60,10 @@ class BoardConfiguration(QtGui.QWidget):
             'th_to_adc_cycles': 7,
             'adc_1_delay_individual': -1,
 
-            'orbits_observe': 100,
-            'orbits_skip': 2,
+            'turns_observe': 100,
+            'turns_skip': 2,
             'acquisition_count': 10,
-            'orbits_wait_time': 15,
+            'turns_wait_time': 15,
             'trigger_skip': 0,
             'trigger_timeout': 12,
             'trigger_method': 1,
@@ -78,8 +78,8 @@ class BoardConfiguration(QtGui.QWidget):
         Set observers that are always used
         """
         self.observe(None, self.update_header, 'header')
-        self.observe(None, lambda x: pci.write(self.identifier, hex(x), '0x9020'), 'orbits_observe')
-        self.observe(None, lambda x: pci.write(self.identifier, hex(x), '0x9028'), 'orbits_skip')
+        self.observe(None, lambda x: pci.write(self.identifier, hex(x), '0x9020'), 'turns_observe')
+        self.observe(None, lambda x: pci.write(self.identifier, hex(x), '0x9028'), 'turns_skip')
 
     def notify_all_observers(self):
         """
@@ -469,13 +469,13 @@ class BoardConfiguration(QtGui.QWidget):
             else:
                 self.update('adc_1_delay_individual', -1)
 
-            # --[ read and set number of orbits to acquire ]--
+            # --[ read and set number of turns to acquire ]--
             val = pci.read(self.identifier, reg='9020')[0]
-            self.update('orbits_observe', int(val, 16))
+            self.update('turns_observe', int(val, 16))
 
-            # --[ read and set number of orbits to skip ]--
+            # --[ read and set number of turns to skip ]--
             val = pci.read(self.identifier, reg='9028')[0]
-            self.update('orbits_skip', int(val, 16))
+            self.update('turns_skip', int(val, 16))
 
             # --[ read and update header ]--
             control = pci.read(self.identifier, 1, '0x9040')[0]

+ 2 - 2
KCG/base/backend/board/sequences.py

@@ -157,9 +157,9 @@ def write_value_sequence(board_id):
     get_board_config(board_id).set_adc_delay(3, get_board_config(board_id).get('adc_4_delay'))
     yield True
 
-    pci.write(board_id, '{0:08x}'.format(get_board_config(board_id).get('orbits_observe')), '0x9020')
+    pci.write(board_id, '{0:08x}'.format(get_board_config(board_id).get('turns_observe')), '0x9020')
     yield True
 
-    pci.write(board_id, '{0:08x}'.format(get_board_config(board_id).get('orbits_skip')), '0x9028')
+    pci.write(board_id, '{0:08x}'.format(get_board_config(board_id).get('turns_skip')), '0x9028')
     yield True
 

+ 1 - 1
KCG/base/backend/board/utils.py

@@ -140,7 +140,7 @@ def wait_for_revolutions(board_id):
     :param board_id: the board to wait for?
     :return:
     """
-    n = pci.read(board_id, 1, '0x9020', decimal=True)[0]  # Get the amount of orbits to observe
+    n = pci.read(board_id, 1, '0x9020', decimal=True)[0]  # Get the amount of turns to observe
     # n = 1 # Use this for debugging purposes if no board is connected
     spin_time_ns = kcg_config.tRev * n
     time.sleep(spin_time_ns * 1.1)  # 10% Safety margin

+ 52 - 59
KCG/base/backendinterface.py

@@ -556,26 +556,26 @@ def bk_get_board_config(board_id):
     """
     return board.get_board_config(board_id)
 
-def bk_change_num_of_orbits(board_id, value, silent=False):
+def bk_change_num_of_turns(board_id, value, silent=False):
     """
-    Send new number of orbits to board and update in config
+    Send new number of turns to board and update in config
     :param board_id: id of the board do manipulate
     :param value: the value to send
     :param silent: (bool) if True do not inform observers on update
     :return: -
     """
-    bk_update_config(board_id, "orbits_observe", value, silent=silent)
+    bk_update_config(board_id, "turns_observe", value, silent=silent)
 
 
-def bk_change_num_of_skipped_orbits(board_id, value, silent=False):
+def bk_change_num_of_skipped_turns(board_id, value, silent=False):
     """
-    Send new number of orbits to skip to board and update in config
+    Send new number of turns to skip to board and update in config
     :param board_id: id of the board do manipulate
     :param value: the value to send
     :param silent: (bool) if True do not inform observers on update
     :return: -
     """
-    bk_update_config(board_id, "orbits_skip", value, silent=silent)
+    bk_update_config(board_id, "turns_skip", value, silent=silent)
 
 
 def bk_change_count(board_id, value, silent=False):
@@ -597,7 +597,7 @@ def bk_change_wait(board_id, value, silent=False):
     :param silent: (bool) if True do not inform observers on update
     :return: -
     """
-    bk_update_config(board_id, "orbits_wait_time", value, silent=silent)
+    bk_update_config(board_id, "turns_wait_time", value, silent=silent)
 
 
 def bk_change_build_spectrograms(board_id, value, silent=False):
@@ -644,7 +644,7 @@ def _bif_iterate_spectrograms(board_id, path):
         f = open(filename, 'ab')
         if write_header:
             f.write("#hsp\n")  # heb spectrogram magic number
-            f.write("#"+str(board.get_board_config(board_id).get("orbits_skip")))
+            f.write("#"+str(board.get_board_config(board_id).get("turns_skip")))
             f.write("\n")
         line = transform[i, :]
         f.write('{:0.3f} '.format(time.time()))
@@ -662,9 +662,9 @@ def _bif_read_data_and_save(board_id):
     :return:
     """
     now = time.time()
-    if not os.path.isdir(str(storage.storage.save_location + '/' + storage.storage.subdirname)):
-        os.makedirs(str(storage.storage.save_location + '/' + storage.storage.subdirname))
-    filename = storage.storage.save_location + '/' + storage.storage.subdirname+'/{:0.3f}.out'.format(now)
+    if not os.path.isdir(str(os.path.join(storage.storage.save_location, storage.storage.subdirname))):
+        os.makedirs(str(os.path.join(storage.storage.save_location, storage.storage.subdirname)))
+    filename = os.path.join(storage.storage.save_location, storage.storage.subdirname,'{:0.3f}.out'.format(now))
     board.get_board_status(board_id).last_file = filename
 
     try:
@@ -674,7 +674,7 @@ def _bif_read_data_and_save(board_id):
             if not os.path.isfile(filename):
                     error(0x001, "No File Created")
         except IndexError:
-            error(0x002, "Unexpected output of pci for number of orbits to observe. Returning")
+            error(0x002, "Unexpected output of pci for number of turns to observe. Returning")
             return
         _bif_read_and_update_data_from_file(board_id, filename)
     except board.BoardError as e:
@@ -807,7 +807,7 @@ def _bif_start_acquisition(board_id):
     _bif_read_data_and_save(board_id)
 
     if board.get_board_config(board_id).get("build_spectrograms"):
-        spectrogram_dir = storage.storage.save_location + '/' + storage.storage.subdirname+"/spectrograms_{:0.3f}".format(time.time())
+        spectrogram_dir = os.path.join(storage.storage.save_location, storage.storage.subdirname, "spectrograms_{:0.3f}".format(time.time()))
         os.makedirs(spectrogram_dir)
         _bif_iterate_spectrograms(board_id, spectrogram_dir) # TODO: not here?
 
@@ -827,7 +827,7 @@ def _bif_start_acquisition(board_id):
             storage.get_board_specific_storage(board_id).acquisition_progressbar.remove(0)
 
     storage.get_board_specific_storage(board_id).acquisition_timer.timeout.connect(on_timeout)
-    storage.get_board_specific_storage(board_id).acquisition_timer.start(board.get_board_config(board_id).get('orbits_wait_time') * 1000)
+    storage.get_board_specific_storage(board_id).acquisition_timer.start(board.get_board_config(board_id).get('turns_wait_time') * 1000)
 
 
 def bk_single_read(board_id):
@@ -915,7 +915,7 @@ def _bif_read_data(board_id):
         try:
             board.wait_for_revolutions(board_id)
         except IndexError:
-            error(0x002, "Unexpected output of pci for number of orbits to observe. Returning")
+            error(0x002, "Unexpected output of pci for number of turns to observe. Returning")
             return
         board.stop_acquisition(board_id)
         board.enable_transfer(board_id)
@@ -954,7 +954,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):
+def bk_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, turns_observe=None, turns_skip=None):
     """
     Toggle Timescan.
     :param board_id: id of the board do manipulate
@@ -964,14 +964,14 @@ def bk_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, orbits_
     :param f_to: (int) To value for fine scan
     :param ts_pbar: Handle to the Timescan Progressbar
     :param plot_func: Function to plot when timescan ended.
-    :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 skipfor the timescan (original values will be restored after timescan)
+    :param turns_observe: Number of turns to observe for the timescan (original values will be restored after timescan)
+    :param turns_skip: Number of turns to skipfor the timescan (original values will be restored after timescan)
     :return: -
     """
     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)
+        _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, turns_observe, turns_skip)
 
 
 def _bif_stop_time_scan(board_id, ts_pbar):
@@ -1000,7 +1000,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):
+def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressbar, plot_func, turns_observe, turns_skip):
     """
     Start the timscan. This starts the timer
     :param board_id: id of the board do manipulate
@@ -1010,9 +1010,8 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
     :param f_to: To value for fine scan
     :param timescan_progressbar: Handle for the timescan progressbar
     :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 turns_observe: Number of turns to observe for the timescan (original values will be restored after timescan)
+    :param turns_skip: Number of turns to skip for the timescan (original values will be restored after timescan)
     :return: -
     """
     thread = storage.get_board_specific_storage(board_id).setdefault("TimeScanThread", storage.ThreadStorage())
@@ -1057,30 +1056,29 @@ 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):
+        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
 
         def time_scan(self):
             '''Method to run in the thread that does the timescan'''
             Elements.setEnabled('acquire_{}'.format(board_id), False, exclude=Elements.getElements('start_time_scan_{}'.format(board_id)))
-            if orbits_observe:
-                if not hasattr(storage.storage, 'orbits_observe_before_timescan'):
-                    storage.storage.orbits_observe_before_timescan = {}
-                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 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")
-                board.get_board_config(board_id).update("orbits_skip", orbits_skip)
-                bk_change_num_of_skipped_orbits(board_id, orbits_skip)
+            if turns_observe:
+                if not hasattr(storage.storage, 'turns_observe_before_timescan'):
+                    storage.storage.turns_observe_before_timescan = {}
+                storage.storage.turns_observe_before_timescan[board_id] = board.get_board_config(board_id).get("turns_observe") # save old values to restore after timescan
+                board.get_board_config(board_id).update("turns_observe", turns_observe)
+                bk_change_num_of_turns(board_id, turns_observe)
+            if turns_skip is not None:
+                if not hasattr(storage.storage, 'turns_skip_before_timescan'):
+                    storage.storage.turns_skip_before_timescan = {}
+                storage.storage.turns_skip_before_timescan[board_id] = board.get_board_config(board_id).get("turns_skip")
+                board.get_board_config(board_id).update("turns_skip", turns_skip)
+                bk_change_num_of_skipped_turns(board_id, turns_skip)
 
             c_step = 0
             for coarse in range(self.c_frm, self.c_to + 1):
@@ -1103,7 +1101,7 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
                         try:
                             board.wait_for_revolutions(board_id)  # Wait before asking for data
                         except IndexError:
-                            error(0x002, "Unexpected output of pci for number of orbits to observe. Stopping Timescan")
+                            error(0x002, "Unexpected output of pci for number of turns to observe. Stopping Timescan")
                             self.stopSignal.emit()
                             return
                         board.stop_acquisition(board_id)
@@ -1131,10 +1129,7 @@ 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:
-                            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]:
@@ -1161,12 +1156,12 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
         thread.stop()
         _bif_stop_time_scan(board_id, timescan_progressbar)
         Elements.setEnabled('acquire_{}'.format(board_id), True, exclude=Elements.getElements('start_time_scan_{}'.format(board_id)))
-        if orbits_observe:
-            board.get_board_config(board_id).update("orbits_observe", storage.storage.orbits_observe_before_timescan[board_id]) # restore values
-            bk_change_num_of_orbits(board_id, storage.storage.orbits_observe_before_timescan[board_id])
-        if orbits_skip:
-            board.get_board_config(board_id).update("orbits_skip", storage.storage.orbits_skip_before_timescan[board_id])
-            bk_change_num_of_skipped_orbits(board_id, storage.storage.orbits_skip_before_timescan[board_id])
+        if turns_observe:
+            board.get_board_config(board_id).update("turns_observe", storage.storage.turns_observe_before_timescan[board_id]) # restore values
+            bk_change_num_of_turns(board_id, storage.storage.turns_observe_before_timescan[board_id])
+        if turns_skip:
+            board.get_board_config(board_id).update("turns_skip", storage.storage.turns_skip_before_timescan[board_id])
+            bk_change_num_of_skipped_turns(board_id, storage.storage.turns_skip_before_timescan[board_id])
             board.get_board_config(board_id).set_delay(storage.storage.th_old[board_id])
 
         board.get_board_config(board_id).set_chip_delay(
@@ -1220,7 +1215,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)
+    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))
@@ -1383,7 +1378,7 @@ def _bif_start_wait_on_trigger(board_id, num_of_acquisitions=None, skip=None, ti
                 # def step():
                 if self._quit:
                     break
-                filename = self.path +'/{:0.3f}.out'.format(time.time())
+                filename = os.path.join(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)
@@ -1393,12 +1388,11 @@ def _bif_start_wait_on_trigger(board_id, num_of_acquisitions=None, skip=None, ti
                     error(0x001, "No File Created")
                     continue
 
-                newfile = '{path}/trigger_{num:05}_{htime}_{unixtime}.out'.format(
+                newfile = os.path.join(self.path, 'trigger_{num:05}_{htime}_{unixtime}.out'.format(
                     num=num_of_acq,
                     htime=dt.fromtimestamp(os.path.getmtime(filename)).strftime('%Y-%m-%dT%Hh%Mm%Ss%f'),
-                    unixtime=int(os.path.getmtime(filename)),
-                    path=self.path
-                )
+                    unixtime=int(os.path.getmtime(filename))
+                ))
                 os.rename(filename, newfile)
                 if os.path.getsize(newfile) > 0:
                     self.liveplot.emit(board_id, newfile)
@@ -1424,7 +1418,7 @@ def _bif_start_wait_on_trigger(board_id, num_of_acquisitions=None, skip=None, ti
                 if not timeout:
                     board.pci.write(board_id, '000f0', hex_mask='8F0')  # disable readout
                     board.pci.write(board_id, '007f0', hex_mask='CF0')  # enable transfer
-                    filename = self.path +'/{:0.3f}.out'.format(time.time())
+                    filename = os.path.join(self.path,'{:0.3f}.out'.format(time.time()))
                     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))
@@ -1436,12 +1430,11 @@ def _bif_start_wait_on_trigger(board_id, num_of_acquisitions=None, skip=None, ti
                         error(0x001, "No File Created")
                         continue
 
-                    newfile = '{path}/trigger_{num:05}_{htime}_{unixtime}.out'.format(
+                    newfile = os.path.join(self.path, 'trigger_{num:05}_{htime}_{unixtime}.out'.format(
                         num=num_of_acq,
                         htime=dt.fromtimestamp(os.path.getmtime(filename)).strftime('%Y-%m-%dT%Hh%Mm%Ss%f'),
-                        unixtime=int(os.path.getmtime(filename)),
-                        path=self.path
-                    )
+                        unixtime=int(os.path.getmtime(filename))
+                    ))
                     os.rename(filename, newfile)
                     self.liveplot.emit(board_id, newfile)
                 else:

+ 18 - 18
KCG/base/leftbar.py

@@ -49,50 +49,50 @@ class BoardSpecificInformation(kcgw.KCGWidgets):
         self.timer.start(30000)
 
         self.skipturns = self.createLabel(
-            tr("Label", "O_skip:") + " " + str(bif.bk_get_config(board_id, 'orbits_skip')),
-            tooltip=tr("Tooltip", "Skipped orbits\nKlick to open acquire settings"),
+            tr("Label", "O_skip:") + " " + str(bif.bk_get_config(board_id, 'turns_skip')),
+            tooltip=tr("Tooltip", "Skipped turns\nKlick to open acquire settings"),
             click=True,
             connect=lambda: acqs.add_acquire_settings_widget(board_id=board_id)
         )
         bif.bk_get_board_config(board_id).observe(self.skipturns,
                                                  lambda x: self.skipturns.setText(tr("Label", "O_skip:")+" "+str(x)),
-                                                 'orbits_skip')
-        self.orbitsobserved = self.createLabel(
-            tr("Label", "O_obs:") + " " + str(bif.bk_get_config(board_id, 'orbits_observe')),
-            tooltip=tr("Tooltip", "Number of observed Orbits\nKlick to open acquire settings"),
+                                                 'turns_skip')
+        self.turnsobserved = self.createLabel(
+            tr("Label", "O_obs:") + " " + str(bif.bk_get_config(board_id, 'turns_observe')),
+            tooltip=tr("Tooltip", "Number of observed Turns\nKlick to open acquire settings"),
             click=True,
             connect=lambda: acqs.add_acquire_settings_widget(board_id=board_id)
         )
         bif.bk_get_board_config(board_id).observe(
-                self.orbitsobserved,
-                lambda x: self.orbitsobserved.setText(tr("Label", "O_obs:") + " " + str(x)), 'orbits_observe')
-        self.orbitscount = self.createLabel(
+                self.turnsobserved,
+                lambda x: self.turnsobserved.setText(tr("Label", "O_obs:") + " " + str(x)), 'turns_observe')
+        self.turnscount = self.createLabel(
             tr("Label", "Count:") + " " + str(bif.bk_get_config(board_id, 'acquisition_count')),
             tooltip=tr("Tooltip", "Number of acquisitions\nKlick to open acquire settings"),
             click=True,
             connect=lambda: acqs.add_acquire_settings_widget(board_id=board_id)
         )
         bif.bk_get_board_config(board_id).observe(
-                self.orbitscount,
-                lambda x: self.orbitscount.setText(tr("Label", "Count:") + " " + str(x)), 'acquisition_count')
-        self.orbitswait = self.createLabel(
-            tr("Label", "T_wait:") + " " + str(bif.bk_get_config(board_id, 'orbits_wait_time')),
+                self.turnscount,
+                lambda x: self.turnscount.setText(tr("Label", "Count:") + " " + str(x)), 'acquisition_count')
+        self.turnswait = self.createLabel(
+            tr("Label", "T_wait:") + " " + str(bif.bk_get_config(board_id, 'turns_wait_time')),
             tooltip=tr("Tooltip", "Time in seconds to wait between acquisitions\nKlick to open acquire settings"),
             click=True,
             connect=lambda: acqs.add_acquire_settings_widget(board_id=board_id)
         )
         bif.bk_get_board_config(board_id).observe(
-                self.orbitswait,
-                lambda x: self.orbitswait.setText(tr("Label", "T_wait:") + " " + str(x)), 'orbits_wait_time')
+                self.turnswait,
+                lambda x: self.turnswait.setText(tr("Label", "T_wait:") + " " + str(x)), 'turns_wait_time')
 
         self.boardSpecificLayout = QtGui.QVBoxLayout()
         self.setLayout(self.boardSpecificLayout)
         self.layout = QtGui.QGridLayout()
         self.layout.addWidget(self.temperature, 0, 0)
         self.layout.addWidget(self.skipturns, 1, 1)
-        self.layout.addWidget(self.orbitsobserved, 1, 0)
-        self.layout.addWidget(self.orbitscount, 2, 0)
-        self.layout.addWidget(self.orbitswait, 2, 1)
+        self.layout.addWidget(self.turnsobserved, 1, 0)
+        self.layout.addWidget(self.turnscount, 2, 0)
+        self.layout.addWidget(self.turnswait, 2, 1)
         self.boardSpecificLayout.addLayout(self.layout)
 
 

+ 3 - 3
KCG/base/log.py

@@ -57,10 +57,10 @@ class MeasurementLogger(object):
         self.dumper = None
 
         self.predefined_parameters = [  # format: [logstring, [function (args,)]]
-            ["Number of Orbits", [bif.bk_get_config, (BOARDID, 'orbits_observe')]],
-            ["Number of Skipped Orbits", [bif.bk_get_config, (BOARDID, 'orbits_skip')]],
+            ["Number of Turns", [bif.bk_get_config, (BOARDID, 'turns_observe')]],
+            ["Number of Skipped Turns", [bif.bk_get_config, (BOARDID, 'turns_skip')]],
             ["Number of Acquisitions", [bif.bk_get_config, (BOARDID, 'acquisition_count')]],
-            ["Time between Acquisitions", [bif.bk_get_config, (BOARDID, 'orbits_wait_time')]],
+            ["Time between Acquisitions", [bif.bk_get_config, (BOARDID, 'turns_wait_time')]],
             ["Pilot Bunch Simulator", [bif.bk_get_config, (BOARDID, 'pilot_bunch')]],
             ["Header saved", [bif.bk_get_config, (BOARDID, 'header')]],
             ["T/H Delay", [bif.bk_get_config, (BOARDID, 'th_delay')]],

+ 1 - 1
KCG/base/loghandler.py

@@ -117,7 +117,7 @@ class LogArea(QtGui.QTextEdit):
         self.streamLogger.setLevel(config.log_level)
         self.streamLogger.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s: %(message)s'))
         logging.getLogger().addHandler(self.streamLogger)
-        self.fileLogHandler = handlers.RotatingFileHandler(os.path.expanduser("~")+"/.kcg/kcg.log", maxBytes=10**7, backupCount=5)
+        self.fileLogHandler = handlers.RotatingFileHandler(os.path.join(os.path.expanduser("~"),".kcg","kcg.log"), maxBytes=10**7, backupCount=5)
         self.fileLogHandler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s: %(message)s'))
         self.fileLogHandler.setLevel(config.log_level)
         logging.getLogger().addHandler(self.fileLogHandler)

+ 6 - 2
KCG/default_config.cfg

@@ -50,11 +50,15 @@ show_advanced_control = False
 # Integrate the single read functionality into the left bar above the general acquisition widget
 integrate_single_read = False
 
+# Activate Epics Widget
+# Epics settings need to be in epics.cfg
+use_epics = True
+
 [Logging]
 # List of Entries that are default to save in Log
 # Possible Values are:
-# "Number of Orbits"
-# "Number of Skipped Orbits"
+# "Number of Turns"
+# "Number of Skipped Turns"
 # "Number of Acquisitions"
 # "Time between Acquisitions"
 # "Pilot Bunch Simulator"

+ 8 - 8
KCG/kcg_de.ts

@@ -663,13 +663,13 @@ Sie verlieren den Status von offenen Plot Fenstern etc.</translation>
     </message>
     <message>
         <location filename="widgets/acquiresettings.py" line="33"/>
-        <source>Number of orbits to observe</source>
-        <translation>Anzahl beobachteter Orbits</translation>
+        <source>Number of turns to observe</source>
+        <translation>Anzahl beobachteter Turns</translation>
     </message>
     <message>
         <location filename="widgets/acquiresettings.py" line="34"/>
-        <source>Number os orbits to skip</source>
-        <translation>Anzahl übersprungener Orbits</translation>
+        <source>Number os turns to skip</source>
+        <translation>Anzahl übersprungener Turns</translation>
     </message>
     <message>
         <location filename="widgets/acquiresettings.py" line="37"/>
@@ -741,16 +741,16 @@ Sie verlieren den Status von offenen Plot Fenstern etc.</translation>
     <name>Tooltip</name>
     <message>
         <location filename="base/leftbar.py" line="38"/>
-        <source>Skipped orbits
+        <source>Skipped turns
 Klick to open acquire settings</source>
-        <translation>Übersprungene Orbits
+        <translation>Übersprungene Turns
 Klick um die Aufnahmeeinstellungen zu öffnen</translation>
     </message>
     <message>
         <location filename="base/leftbar.py" line="45"/>
-        <source>Number of observed Orbits
+        <source>Number of observed Turns
 Klick to open acquire settings</source>
-        <translation>Anzahl beobachteter Orbits
+        <translation>Anzahl beobachteter Turns
 Klick um die Aufnahmeeinstellungen zu öffnen</translation>
     </message>
     <message>

+ 37 - 37
KCG/widgets/acquiresettings.py

@@ -48,10 +48,10 @@ class AcquireSettingsTab(kcgw.KCGWidgets):
             self.sameAsLabel.hide()
 
         # ---------[ Create Labels and corresponding Fields ]---------
-        self.numOfOrbitsLabel       = self.createLabel(tr("Label", "Number of turns to observe"))
-        self.numOfSkipOrbitsLabel   = self.createLabel(tr("Label", "Number of turns to skip"))
-        self.numOfOrbitsSpinbox     = self.createSpinbox(1, 10000000, connect=self.on_number_of_orbits_changed)
-        self.numOfSkipOrbitsSpinbox = self.createSpinbox(0, 100, connect=self.on_number_of_skipped_orbits_changed)
+        self.numOfTurnsLabel       = self.createLabel(tr("Label", "Number of turns to observe"))
+        self.numOfSkipTurnsLabel   = self.createLabel(tr("Label", "Number of turns to skip"))
+        self.numOfTurnsSpinbox     = self.createSpinbox(1, 10000000, connect=self.on_number_of_turns_changed)
+        self.numOfSkipTurnsSpinbox = self.createSpinbox(0, 100, connect=self.on_number_of_skipped_turns_changed)
         self.fileSizeLabel          = self.createLabel(tr("Label", "Resulting file size"))
         self.fileSizeOutLabel       = self.createLabel(tr("Label", "??"))
         self.countLabel             = self.createLabel(tr("Label", "Number of acquisitions"))
@@ -82,18 +82,18 @@ class AcquireSettingsTab(kcgw.KCGWidgets):
         self.trigger_tick = self.createCheckbox(tr("Label", "Use External Trigger"), connect=self.use_external_trigger)
 
         # -------[ register observers ]------
-        board.get_board_config(board_id).observe(self.numOfOrbitsSpinbox,
-                                                 lambda x: self.set_value_silent(self.numOfOrbitsSpinbox, x),
-                                                 'orbits_observe')
-        board.get_board_config(board_id).observe(self.numOfSkipOrbitsSpinbox,
-                                                 lambda x: self.set_value_silent(self.numOfSkipOrbitsSpinbox, x),
-                                                 'orbits_skip')
+        board.get_board_config(board_id).observe(self.numOfTurnsSpinbox,
+                                                 lambda x: self.set_value_silent(self.numOfTurnsSpinbox, x),
+                                                 'turns_observe')
+        board.get_board_config(board_id).observe(self.numOfSkipTurnsSpinbox,
+                                                 lambda x: self.set_value_silent(self.numOfSkipTurnsSpinbox, x),
+                                                 'turns_skip')
         board.get_board_config(board_id).observe(self.countSpinbox,
                                                  lambda x: self.set_value_silent(self.countSpinbox, x),
                                                  'acquisition_count')
         board.get_board_config(board_id).observe(self.waitSpinbox,
                                                  lambda x: self.set_value_silent(self.waitSpinbox, x),
-                                                 'orbits_wait_time')
+                                                 'turns_wait_time')
         board.get_board_config(board_id).observe(self.simulatePilotBunch,
                                                  lambda x: self.tick_silent(self.simulatePilotBunch, x),
                                                  'pilot_bunch')
@@ -109,8 +109,8 @@ class AcquireSettingsTab(kcgw.KCGWidgets):
         # -------[ register elements ]-------
         Elements.addItem(["acquire", "no_board", "acquire_"+str(board_id)],
                          [
-                             self.numOfOrbitsSpinbox,
-                             self.numOfSkipOrbitsSpinbox,
+                             self.numOfTurnsSpinbox,
+                             self.numOfSkipTurnsSpinbox,
                              self.countSpinbox,
                              self.waitSpinbox,
                              self.buildSpectrogrammTickbox,
@@ -122,10 +122,10 @@ class AcquireSettingsTab(kcgw.KCGWidgets):
                          ])
 
         # -------[ Add to grid ]-------------
-        self.layout.addWidget(self.numOfOrbitsLabel, 1, 0)
-        self.layout.addWidget(self.numOfOrbitsSpinbox, 1, 1)
-        self.layout.addWidget(self.numOfSkipOrbitsLabel, 2, 0)
-        self.layout.addWidget(self.numOfSkipOrbitsSpinbox, 2, 1)
+        self.layout.addWidget(self.numOfTurnsLabel, 1, 0)
+        self.layout.addWidget(self.numOfTurnsSpinbox, 1, 1)
+        self.layout.addWidget(self.numOfSkipTurnsLabel, 2, 0)
+        self.layout.addWidget(self.numOfSkipTurnsSpinbox, 2, 1)
         self.layout.addWidget(self.fileSizeLabel, 3,0)
         self.layout.addWidget(self.fileSizeOutLabel, 3,1)
         line = QtGui.QFrame()
@@ -279,32 +279,32 @@ class AcquireSettingsTab(kcgw.KCGWidgets):
         :return: -
         """
         # bk_get_config has to be done for each widget seperately (get dientifier by widget.board_id)
-        self.set_value_silent(self.numOfOrbitsSpinbox, bif.bk_get_config(self.board_id, 'orbits_observe'))
-        self.set_value_silent(self.numOfSkipOrbitsSpinbox, bif.bk_get_config(self.board_id, 'orbits_skip'))
+        self.set_value_silent(self.numOfTurnsSpinbox, bif.bk_get_config(self.board_id, 'turns_observe'))
+        self.set_value_silent(self.numOfSkipTurnsSpinbox, bif.bk_get_config(self.board_id, 'turns_skip'))
         self.set_value_silent(self.countSpinbox, bif.bk_get_config(self.board_id, 'acquisition_count'))
-        self.set_value_silent(self.waitSpinbox, bif.bk_get_config(self.board_id, 'orbits_wait_time'))
+        self.set_value_silent(self.waitSpinbox, bif.bk_get_config(self.board_id, 'turns_wait_time'))
         self.tick_silent(self.buildSpectrogrammTickbox, bif.bk_get_config(self.board_id, 'build_spectrograms'))
         self.tick_silent(self.simulatePilotBunch, bif.bk_get_config(self.board_id, 'pilot_bunch'))
         self.update_external_trigger(bif.bk_get_config(self.board_id, 'use_trigger'))
 
     # -----------------[ Value Change Handlers ]---------------------------
-    def on_number_of_orbits_changed(self):
+    def on_number_of_turns_changed(self):
         """
-        Handle the change of the number of orbits
+        Handle the change of the number of turns
         """
-        bif.bk_change_num_of_orbits(self.board_id, self.numOfOrbitsSpinbox.value())
+        bif.bk_change_num_of_turns(self.board_id, self.numOfTurnsSpinbox.value())
         for b_id in self.same_as_widgets[self.board_id]:
             wid = self.widgets[b_id]
-            bif.bk_change_num_of_orbits(wid.board_id, wid.numOfOrbitsSpinbox.value())
+            bif.bk_change_num_of_turns(wid.board_id, wid.numOfTurnsSpinbox.value())
 
-    def on_number_of_skipped_orbits_changed(self):
+    def on_number_of_skipped_turns_changed(self):
         """
-        Handle the change of the number of skipped orbits
+        Handle the change of the number of skipped turns
         """
-        bif.bk_change_num_of_skipped_orbits(self.board_id, self.numOfSkipOrbitsSpinbox.value())
+        bif.bk_change_num_of_skipped_turns(self.board_id, self.numOfSkipTurnsSpinbox.value())
         for b_id in self.same_as_widgets[self.board_id]:
             wid = self.widgets[b_id]
-            bif.bk_change_num_of_skipped_orbits(wid.board_id, wid.numOfSkipOrbitsSpinbox.value())
+            bif.bk_change_num_of_skipped_turns(wid.board_id, wid.numOfSkipTurnsSpinbox.value())
 
     def on_count_changed(self):
         """
@@ -376,10 +376,10 @@ class AcquireSettingsTab(kcgw.KCGWidgets):
         Event handler to handle the event of closing this window and gracefully delete resources and such
         :param event: the event to handle (gets passed to by PyQt)
         """
-        board.get_board_config(self.board_id).unobserve(self.numOfOrbitsSpinbox, 'orbits_observe')
-        board.get_board_config(self.board_id).unobserve(self.numOfSkipOrbitsSpinbox, 'orbits_skip')
+        board.get_board_config(self.board_id).unobserve(self.numOfTurnsSpinbox, 'turns_observe')
+        board.get_board_config(self.board_id).unobserve(self.numOfSkipTurnsSpinbox, 'turns_skip')
         board.get_board_config(self.board_id).unobserve(self.countSpinbox, 'acquisition_count')
-        board.get_board_config(self.board_id).unobserve(self.waitSpinbox, 'orbits_wait_time')
+        board.get_board_config(self.board_id).unobserve(self.waitSpinbox, 'turns_wait_time')
         board.get_board_config(self.board_id).unobserve(self.simulatePilotBunch, 'pilot_bunch')
         board.get_board_config(self.board_id).unobserve(self.buildSpectrogrammTickbox, 'build_spectrograms')
         board.get_board_config(self.board_id).unobserve(self.trigger_skip_signals, 'trigger_skip')
@@ -387,8 +387,8 @@ class AcquireSettingsTab(kcgw.KCGWidgets):
         board.get_board_config(self.board_id).unobserve(self.trigger_tick, 'use_trigger')
         Elements.removeItem(["acquire_{}".format(self.board_id), "no_board_{}".format(self.board_id)],
                             [
-                                 self.numOfOrbitsSpinbox,
-                                 self.numOfSkipOrbitsSpinbox,
+                                 self.numOfTurnsSpinbox,
+                                 self.numOfSkipTurnsSpinbox,
                                  self.countSpinbox,
                                  self.waitSpinbox,
                                  self.buildSpectrogrammTickbox,
@@ -483,10 +483,10 @@ def setValueSilent(key, value):
     if not __widget_id__:
         return
     global_objects.get_global('area').widgets[__widget_id__].blockSignals(True)
-    if key == "orbits_observe":
-        global_objects.get_global('area').widgets[__widget_id__].numOfOrbitsSpinbox.setValue(value)
-    if key == "orbits_skip":
-        global_objects.get_global('area').widgets[__widget_id__].numOfSkipOrbitsSpinbox.setValue(value)
+    if key == "turns_observe":
+        global_objects.get_global('area').widgets[__widget_id__].numOfTurnsSpinbox.setValue(value)
+    if key == "turns_skip":
+        global_objects.get_global('area').widgets[__widget_id__].numOfSkipTurnsSpinbox.setValue(value)
     global_objects.get_global('area').widgets[__widget_id__].blockSignals(False)
 
 

+ 8 - 7
KCG/widgets/epics_widget.py

@@ -231,7 +231,7 @@ class EpicsWidget(kcgw.KCGWidgets):
         self.editHide = False
         self.toggleEdit()
        
-        self.addMonitor()
+        self.startMonitor()
 
        # self.resize(self.monitorLabel.frameGeometry().width()+50, self.monitorLabel.frameGeometry().height()+10)
         self.layout.addStretch(1)
@@ -241,7 +241,7 @@ class EpicsWidget(kcgw.KCGWidgets):
 
     def generateList(self, updateMonitor=True):
         if updateMonitor:
-            self.removeMonitor()
+            self.stopMonitor()
 
         if len(self.pvInputList):
             for item in self.pvInputList:
@@ -278,16 +278,17 @@ class EpicsWidget(kcgw.KCGWidgets):
         self.editInnerGroupBoxLayout.addWidget(self.pvInputAdd[4], i+1, 4)
 
         if updateMonitor:
-            self.addMonitor()
+            self.startMonitor()
 
         
 
     def closeEvent(self, event):
         global __widget_id__
         __widget_id__ = None
-        self.removeMonitor()
+        self.stopMonitor()
         del self.par.widgets[self.id]
 
+
     def toggleEdit(self):
         if self.editHide:            
         #   self.resize(800, 800)
@@ -358,9 +359,9 @@ class EpicsWidget(kcgw.KCGWidgets):
             string += str(self.monitorPVList[item][0]) + " = " + str(self.monitorPVList[item][1]) + "\n"
         self.monitorLabel.setText(string)
 
-    def addMonitor(self):
+    def startMonitor(self):
         if len(self.pvList):
-            self.removeMonitor()
+            self.stopMonitor()
         for item in epicsConfig.getKey('epics_log_entry_pvs'):
             if item[3] == 'True': 
                 try:
@@ -372,7 +373,7 @@ class EpicsWidget(kcgw.KCGWidgets):
                     print('add Failed', item[1])
                     pass
 
-    def removeMonitor(self):
+    def stopMonitor(self):
         for item in self.pvList:
             try:
                 epics.camonitor_clear(item)

+ 46 - 33
KCG/widgets/initialconfig.py

@@ -4,6 +4,7 @@ This defines the window for initial configuration
 from PyQt4 import QtGui, QtCore
 from ..base import kcgwidget as kcgw
 import os
+import configparser
 from .. import config
 try:
     from pprint import pformat
@@ -27,7 +28,7 @@ class ConfigEntry(kcgw.KCGWidgets):
     """
     Container for a single entry in the init config window
     """
-    def __init__(self, comm='', conf='', type=str, multiline=False):
+    def __init__(self, comm='', conf='', type=str, multiline=False, defaultValue=''):
         """
         Initialise an entry
         :param comm: comment
@@ -74,7 +75,7 @@ class ConfigEntry(kcgw.KCGWidgets):
         try:
             self.value.setText(pformat(getattr(config, conf), width=60, indent=4))
         except AttributeError:
-            pass
+            self.value.setText(pformat(config.leval(defaultValue), width=60, indent=4))
         self.layout.addWidget(self.comment)
         self.layout.addLayout(self.entryLayout)
         self.entryLayout.addWidget(self.config)
@@ -122,6 +123,7 @@ class ConfigEntry(kcgw.KCGWidgets):
                     self.value.setStyleSheet("background-color: #FFFFFF;")
                     return True
             except (ValueError, config.NoValueException, SyntaxError):
+                print('ValueError',v,e)
                 pass
         else:
             try:
@@ -132,6 +134,7 @@ class ConfigEntry(kcgw.KCGWidgets):
                     self.value.setStyleSheet("background-color: #FFFFFF;")
                     return True
             except (ValueError, config.NoValueException, SyntaxError):
+                print('ValueError',v,e)
                 pass
         if mark:
             self.value.setStyleSheet("background-color: #FFAAAA;")
@@ -143,11 +146,11 @@ class ConfigEntry(kcgw.KCGWidgets):
         :param val: the value to sanitise
         :return: sanitised value and errors
         """
-        print(val)
+        #print(val)
         err = False
         if self.type == str:
-
-            val.replace('"', '\'')
+            val = val.replace('"', '\'')
+            
             if len(val) == 0:
                 return "", False
             if val[0] == "'":
@@ -158,7 +161,7 @@ class ConfigEntry(kcgw.KCGWidgets):
                 val = "'" + val
                 err = True
             else:
-                val = '"' + val + '"'
+                val = "'" + val + "'"
                 err = False
         return val, err
 
@@ -208,10 +211,10 @@ class ConfigSetup(kcgw.KCGWidgets):
                         'possible languages:\n'
                         '"en_GB" - English\n'
                         '"de_DE" - German',
-                   'default_save_location: use "pwd" for current working\n'
+                   '\ndefault_save_location: use "pwd" for current working\n'
                         'directory KCG will always save in a subdirectory to\n'
                         'this given path and save files in this directory',
-                   'default_subdirectory_name_format: this is the\n'
+                   '\ndefault_subdirectory_name_format: this is the\n'
                         'naming scheme for the subdirectory in which the\n'
                         'files are saved. Format of this string:\n'
                         '"{tag1}text{tag2}text" etc.\n'
@@ -230,17 +233,14 @@ class ConfigSetup(kcgw.KCGWidgets):
                         '{timestamp} unix timestamp without msec\n'
                         '{user} the current logged in user\n'
                         '{sessionname} Ask for session name at startup\n'
-                        '{ask} always ask for a foldername',
-                   'reask on cancel in dialog or use {user}_{dateGd}-{timel} as default when cancel is pressed?',
-                   'Show advanced table view per default? (boolean value)'
+                        '{ask} always ask for a foldername\n'
+                        'default_subdirectory_name = "{user}_{dateGd}-{timel}_{sessionname}"',
+                   '\nreask on cancel in dialog or use {user}_{dateGd}-{timel} as default when cancel is pressed?',
+                   '\nShow advanced table view per default? (boolean value)',
+                   '\nActivate Epics Widget\n' 
+                   'Epics settings need to be in epics.cfg'
                 ]
-    logging_comments = ['These are PVs that will be possible to insert into log files\n'
-                            'This variable is to be a list consisting of touples of two entries,\n'
-                            'the first ist the Text that describes the value and the second is the EPICS PV that\n'
-                            'holds that value',
-                       'This pv is used to determine if epics pvs are accessible' ,
-                       'Path to your epics base installation',
-                       'List of Entries that are default to save in Log\n'
+    logging_comments = ['List of Entries that are default to save in Log\n'
                            'Possible Values are:\n'
                            '"Number of Turns" \n'
                            '"Number of Skipped Turns" \n'
@@ -253,7 +253,6 @@ class ConfigSetup(kcgw.KCGWidgets):
                            '"ADC 2 Delay" \n'
                            '"ADC 3 Delay" \n'
                            '"ADC 4 Delay" \n'
-                           'All of the description text entries in epics_log_entry_pvs, see above \n'
                            'NOTE: These entries have to match the aforementioned strings exactly'
                     ]
     machine_configs = ['bunches_per_turn',
@@ -263,14 +262,12 @@ class ConfigSetup(kcgw.KCGWidgets):
                   'default_save_location',
                   'default_subdirectory_name',
                   'force_ask',
-                  'show_advanced_control']
-    logging_configs = ['epics_log_entry_pvs',
-                       'epics_test_pv',
-                       'epics_base_path',
-                       'default_log_entries']
+                  'show_advanced_control',
+                  'use_epics']
+    logging_configs = ['default_log_entries']
     machine_types = [int, bool, float]
-    ui_types = [str, str, str, bool, bool]
-    logging_types = [list, str, str, list]
+    ui_types = [str, str, str, bool, bool,bool]
+    logging_types = [list]
 
     def __init__(self, restart=False):
         """
@@ -283,6 +280,10 @@ class ConfigSetup(kcgw.KCGWidgets):
         self.result = False
         self.resize(800, 600)
         self.mainlayout = QtGui.QVBoxLayout()
+
+        defaultConfig = configparser.ConfigParser()
+        defaultConfig.optionxform = str
+        defaultConfig.read(os.path.join(config.install_path, "default_config.cfg"))
         # self.textEdit = QtGui.QTextEdit()
         # self.layout.addWidget(self.textEdit)
         # with open(os.path.dirname(__file__)+'/../config.cfg', 'r') as f:
@@ -304,9 +305,13 @@ class ConfigSetup(kcgw.KCGWidgets):
         self.machine_label = self.createLabel("Machine")
         self.machine_label.setStyleSheet("font-size: 20pt;")
         self.layout.addWidget(self.machine_label)
-        self.configs.append("\n[Machine]")
+        self.configs.append("[Machine]")
         for comm, conf, type in zip(self.machine_comments, self.machine_configs, self.machine_types):
-            self.configs.append(ConfigEntry(comm, conf, type))
+            try:
+                val = defaultConfig['Machine'][conf]
+            except:
+                val = ""
+            self.configs.append(ConfigEntry(comm, conf, type, defaultValue=val))
             self.layout.addWidget(self.configs[-1])
 
 
@@ -315,7 +320,11 @@ class ConfigSetup(kcgw.KCGWidgets):
         self.layout.addWidget(self.ui_label)
         self.configs.append("\n[Ui]")
         for comm, conf, type in zip(self.ui_comments, self.ui_configs, self.ui_types):
-            self.configs.append(ConfigEntry(comm, conf, type))
+            try:
+                val = defaultConfig['Ui'][conf]
+            except:
+                val = ""
+            self.configs.append(ConfigEntry(comm, conf, type, defaultValue=val))
             self.layout.addWidget(self.configs[-1])
 
         self.logging_label = self.createLabel("Logging")
@@ -327,10 +336,14 @@ class ConfigSetup(kcgw.KCGWidgets):
         self.configs.append("\n[Logging]")
         self.logging_entries = []
         for comm, conf, type in zip(self.logging_comments, self.logging_configs, self.logging_types):
-            if conf == 'epics_log_entry_pvs' or conf == 'default_log_entries':
-                self.configs.append(ConfigEntry(comm, conf, type, multiline=True))
+            try:
+                val = defaultConfig['Logging'][conf]
+            except:
+                val = ""
+            if conf == 'default_log_entries':
+                self.configs.append(ConfigEntry(comm, conf, type, multiline=True, defaultValue=val))
             else:
-                self.configs.append(ConfigEntry(comm, conf, type))
+                self.configs.append(ConfigEntry(comm, conf, type, defaultValue=val))
             self.layout.addWidget(self.configs[-1])
             self.logging_entries.append(self.configs[-1])
 
@@ -364,7 +377,7 @@ class ConfigSetup(kcgw.KCGWidgets):
         if abort:
             return
 
-        with open(os.path.join(os.path.expanduser("~"),'.kcg','config.cfg', 'w+')) as f:
+        with open(os.path.join(os.path.expanduser("~"),'.kcg','config.cfg'), 'w+') as f:
             for item in self.configs:
                 f.write(str(item)+'\n')
         self.result = True

+ 8 - 8
KCG/widgets/timingWidget.py

@@ -394,8 +394,8 @@ 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.orbits_observe_spinbox = self.createSpinbox(1, 10000000, start_value=100)
-        self.orbits_skip_spinbox = self.createSpinbox(0, 100, start_value=2)
+        self.turns_observe_spinbox = self.createSpinbox(1, 10000000, start_value=100)
+        self.turns_skip_spinbox = self.createSpinbox(0, 100, start_value=2)
 
         self.time_scan_progressbar = QtGui.QProgressBar()
         self.time_scan_button = self.createButton(tr("Button", "Start time scan"), connect=self.time_scan)
@@ -416,10 +416,10 @@ class timingPart(kcgw.KCGWidgets):
         self.timeScanLayout.addWidget(self.fine_scan_range_label, 2, 0)
         self.timeScanLayout.addWidget(self.fine_scan_min_spinbox, 2, 1)
         self.timeScanLayout.addWidget(self.fine_scan_max_spinbox, 2, 2)
-        self.timeScanLayout.addWidget(self.createLabel("Orbits to Observe"), 3, 1)
-        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.createLabel("Turns to Observe"), 3, 1)
+        self.timeScanLayout.addWidget(self.turns_observe_spinbox, 3, 2)
+        self.timeScanLayout.addWidget(self.createLabel("Turns to Skip"), 4, 1)
+        self.timeScanLayout.addWidget(self.turns_skip_spinbox, 4, 2)
         self.timeScanLayout.addWidget(self.time_scan_button, 5, 2)
         self.setTabOrder(self.fine_scan_max_spinbox, self.time_scan_button)
 
@@ -628,8 +628,8 @@ class timingPart(kcgw.KCGWidgets):
             self.fine_scan_max_spinbox.value(),
             self.time_scan_progressbar,
             self.plotWidget.plot,
-            orbits_observe = self.orbits_observe_spinbox.value(),
-            orbits_skip = self.orbits_skip_spinbox.value()
+            turns_observe = self.turns_observe_spinbox.value(),
+            turns_skip = self.turns_skip_spinbox.value(),
         )
 
     def setValueSilent(self, element, value):