ソースを参照

fixed bug: acquisition with ext. trigger was running in main thread, now fixed, now also stop acquisition working

Miriam Brosi 7 年 前
コミット
24e2187807
3 ファイル変更16 行追加8 行削除
  1. 1 1
      KCG/base/backend/board/actions.py
  2. 4 5
      KCG/base/backendinterface.py
  3. 11 2
      KCG/base/storage.py

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

@@ -90,7 +90,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')  # what's this? write value 1 to register 4???
+    pci.write(board_id, '1', '4', hex_mask='1')  # Start DMA?
     time.sleep(0.005)
     pci.write(board_id, '00bf0', hex_mask='CF0')
 

+ 4 - 5
KCG/base/backendinterface.py

@@ -1272,10 +1272,11 @@ def bk_toggle_wait_on_trigger(board_id, num_of_acquisitions=None, skip=None, tim
             read sequentially
     :return:
     """
-    # FIXME: stops acquisition with external trigger after the next acquisition; signal to toggle function is not delivered instantly, but only after next acquisition?
     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", "Start Acquisition"))
+        Elements.getElements("acquireTrigger_{}".format(board_id))[0].setText(tr("Button", "Stopping Acquisition"))
+        # FIXME: Button not updated otherwise:
+        QtGui.qApp.processEvents()
         log(board_id=board_id, additional="Stop wait on trigger on board {}".format(board_id))
         thread.quit()
         thread.stop()
@@ -1413,7 +1414,6 @@ def _bif_start_wait_on_trigger(board_id, num_of_acquisitions=None, skip=None, ti
                         timeout = True
                         break
                     if self._quit:
-                        print('1')
                         self.finished.emit()
                         return
                 if not timeout:
@@ -1423,8 +1423,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! and in tests only '1' occurs
-                        print('2')
+                    if self._quit:  # is this really the correct position? file is taken but not renamed!
                         self.finished.emit()
                         break
 

+ 11 - 2
KCG/base/storage.py

@@ -62,6 +62,14 @@ 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
@@ -74,8 +82,8 @@ class ThreadStorage(object):
         :return:
         """
         del self._q_thread  # start over
-        self._q_thread = QtCore.QThread()
-        self._q_thread.started.connect(self.__start)
+        self._q_thread = ThreadStorage.TThread()
+        #self._q_thread.started.connect(self.__start)
         self._threaded_object = threaded_object
 
     def is_registered(self):
@@ -106,6 +114,7 @@ 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