Esempio n. 1
0
    def updateList(self):

        self.list.clear()

        if self.instr_name.value() == self.instr_name.value_def(): return
        if self.exp_name.value() == self.exp_name.value_def(): return

        # Get run records from RegDB
        self.dict_run_recs = ru.calibration_runs(self.instr_name.value(),
                                                 self.exp_name.value())
        #print 'self.dict_run_recs = ', self.dict_run_recs

        self.list_of_records = []
        self.list_of_run_strs_in_dir = fnm.get_list_of_xtc_runs(
        )  # ['0001', '0202', '0203',...]
        self.list_of_run_nums_in_dir = gu.list_of_int_from_list_of_str(
            self.list_of_run_strs_in_dir)  # [1, 202, 203, 204,...]
        self.list_of_run_nums_in_regdb = ru.list_of_runnums(
            self.instr_name.value(), self.exp_name.value())

        #print 'list_of_run_nums_in_dir:\n',   self.list_of_run_nums_in_dir
        #print 'list_of_run_nums_in_regdb:\n', self.list_of_run_nums_in_regdb

        if self.list_of_run_nums_in_regdb == []:
            self.list_of_runs = self.list_of_run_nums_in_dir
        else:
            self.list_of_runs = self.list_of_run_nums_in_regdb

        for run_num in self.list_of_runs:

            str_run_num = '%04d' % run_num
            self.str_run_number.setValue(str_run_num)

            if not self.isSelectedRun(run_num): continue
            if not self.hasSelectedDetectorsInRun(run_num): continue

            if not run_num in self.list_of_run_nums_in_dir:
                self.comment = 'NOT FOUND xtc file!'
                #self.type    = 'N/A'

            widg = GUIDarkListItem(self, str_run_num, self.type, self.comment)
            item = QtGui.QListWidgetItem('', self.list)
            #self.list.addItem(item)
            #item.setFlags (  QtCore.Qt.ItemIsEnabled ) #| QtCore.Qt.ItemIsSelectable  | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsTristate)
            #print 'item.flags(): %o' % item.flags()
            #item.setCheckState(0)
            item.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable
                          | QtCore.Qt.ItemIsUserCheckable)
            #item.setFlags ( QtCore.Qt.ItemIsEnabled )

            item.setSizeHint(widg.size())
            self.list.setItemWidget(item, widg)
            #self.list.setItemSelected(item, True)

            record = str_run_num, item, widg
            self.list_of_records.append(record)
Esempio n. 2
0
    def updateList(self):

        self.list.clear()

        if self.instr_name.value() == self.instr_name.value_def() : return
        if self.exp_name  .value() == self.exp_name  .value_def() : return

        # Get run records from RegDB
        self.dict_run_recs = ru.calibration_runs (self.instr_name.value(), self.exp_name.value())
        #print 'self.dict_run_recs = ', self.dict_run_recs

        self.list_of_records = []
        self.list_of_run_strs_in_dir = fnm.get_list_of_xtc_runs()   # ['0001', '0202', '0203',...]
        self.list_of_run_nums_in_dir = gu.list_of_int_from_list_of_str(self.list_of_run_strs_in_dir) # [1, 202, 203, 204,...]
        self.list_of_run_nums_in_regdb = ru.list_of_runnums(self.instr_name.value(), self.exp_name.value())

        #print 'list_of_run_nums_in_dir:\n',   self.list_of_run_nums_in_dir
        #print 'list_of_run_nums_in_regdb:\n', self.list_of_run_nums_in_regdb
        
        if self.list_of_run_nums_in_regdb == [] : self.list_of_runs = self.list_of_run_nums_in_dir
        else                                    : self.list_of_runs = self.list_of_run_nums_in_regdb

        for run_num in self.list_of_runs :

            str_run_num = '%04d' % run_num
            self.str_run_number.setValue(str_run_num)

            if not self.isSelectedRun            (run_num) : continue
            if not self.hasSelectedDetectorsInRun(run_num) : continue
        
            if not run_num in self.list_of_run_nums_in_dir :
                self.comment = 'NOT FOUND xtc file!'
                #self.type    = 'N/A'


            widg = GUIDarkListItem ( self, str_run_num, self.type, self.comment)
            item = QtGui.QListWidgetItem('', self.list)
            #self.list.addItem(item)
            #item.setFlags (  QtCore.Qt.ItemIsEnabled ) #| QtCore.Qt.ItemIsSelectable  | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsTristate)
            #print 'item.flags(): %o' % item.flags()
            #item.setCheckState(0)
            item.setFlags (  QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable  | QtCore.Qt.ItemIsUserCheckable )
            #item.setFlags ( QtCore.Qt.ItemIsEnabled )

            item.setSizeHint(self.size)
            self.list.setItemWidget(item, widg)
            #self.list.setItemSelected(item, True)

            record = str_run_num, item, widg
            self.list_of_records.append(record)
    def list_of_types_and_sources_for_detector(self, det_name):

        if not self.scan_log_exists():  # Use RegDB
            ins, exp, run_number = cp.instr_name.value(), cp.exp_name.value(
            ), int(cp.str_run_number.value())
            lst_srcs = ru.list_of_sources_in_run_for_selected_detector(
                ins, exp, run_number, det_name)
            ctype = cp.dict_of_det_calib_types[det_name]
            lst_types = [ctype for src in lst_srcs]
            return lst_types, lst_srcs

        pattern_det = det_name.lower() + '.'
        pattern_type = self.dict_of_det_data_types[det_name]
        #print 'pattern_det, pattern_type', pattern_det, pattern_type

        list_of_types_for_det = []
        list_of_srcs_for_det = []
        for type, src in self.get_list_of_type_sources():
            #print '  type, src: %24s  %s' % (type,src)
            if type.find(pattern_type) == -1: continue
            if src.lower().find(pattern_det) == -1: continue
            list_of_types_for_det.append(type)
            list_of_srcs_for_det.append(src)
        #print 'list of types and sources for detector %s:\n  %s\n  %s' \
        #      % (det_name, str(list_of_types_for_det), str(list_of_srcs_for_det))
        return list_of_types_for_det, list_of_srcs_for_det
Esempio n. 4
0
    def list_of_types_and_sources_for_detector (self, det_name) :

        if not self.scan_log_exists() : # Use RegDB
            ins, exp, run_number = cp.instr_name.value(), cp.exp_name.value(), int(cp.str_run_number.value())
            lst_srcs = ru.list_of_sources_in_run_for_selected_detector(ins, exp, run_number, det_name)
            dtype = cp.dict_of_det_data_types[det_name]
            ctype = cp.dict_of_det_calib_types[det_name]
            lst_dtypes = [dtype for src in lst_srcs]
            lst_ctypes = [ctype for src in lst_srcs]
            #print 'lst_ctypes ::: ', lst_ctypes
            #print 'lst_dtypes ::: ', lst_dtypes
            #print 'lst_srcs   ::: ', lst_srcs
            return lst_dtypes, lst_srcs, lst_ctypes

        pattern_det = det_name.lower() + '.'
        pattern_type = self.dict_of_det_data_types[det_name]
        #print 'pattern_det, pattern_type', pattern_det, pattern_type

        list_of_ctypes_for_det=[]
        list_of_dtypes_for_det=[]
        list_of_srcs_for_det=[]
        for type,src in self.get_list_of_type_sources() :
            #print '  type, src: %24s  %s' % (type,src)
            if type.find(pattern_type)       == -1 : continue
            if src.lower().find(pattern_det) == -1 : continue
            list_of_ctypes_for_det.append(cp.dict_of_det_calib_types[det_name])
            list_of_dtypes_for_det.append(type)
            list_of_srcs_for_det.append(src)
        #print 'list of types and sources for detector %s:\n  %s\n  %s' \
        #      % (det_name, str(list_of_types_for_det), str(list_of_srcs_for_det))  
        return list_of_dtypes_for_det, list_of_srcs_for_det, list_of_ctypes_for_det
 def get_list_of_sources(self):
     if self.scan_log_exists():
         self.parse_batch_log_peds_scan()
         return self.list_of_sources
     # Use RegDB
     return ru.list_of_sources_in_run(cp.instr_name.value(),
                                      cp.exp_name.value(),
                                      int(cp.str_run_number.value()))
    def onButSrc(self):
        logger.debug('onButSrc', __name__ )

        det = self.get_detector_selected()
        if det is None : return

        try    :
            lst = ru.list_of_sources_for_det(det)
        except :
            lst = cp.dict_of_det_sources[det]

        selected = gu.selectFromListInPopupMenu(lst)

        if selected is None : return            # selection is cancelled

        txt = str(selected)
        self.source_name = txt
        self.but_src.setText( txt + self.char_expand )
        logger.info('Source selected: ' + txt, __name__)

        self.setStyleButtons()
    def onButSrc(self):
        logger.debug('onButSrc', __name__)

        det = self.get_detector_selected()
        if det is None: return

        try:
            lst = ru.list_of_sources_for_det(det)
        except:
            lst = cp.dict_of_det_sources[det]

        selected = gu.selectFromListInPopupMenu(lst)

        if selected is None: return  # selection is cancelled

        txt = str(selected)
        self.source_name = txt
        self.but_src.setText(txt + self.char_expand)
        logger.info('Source selected: ' + txt, __name__)

        self.setStyleButtons()
 def txt_of_sources_in_run(self):
     return ru.txt_of_sources_in_run(cp.instr_name.value(),
                                     cp.exp_name.value(),
                                     int(cp.str_run_number.value()))
Esempio n. 9
0
    def updateList(self, clearList=False) :

        self.update_counter += 1

        self.t0_sec = time()

        if clearList :
            self.removeItemWidgets()            
            self.list.clear()
            self.dict_guidarklistitem.clear()
            #msg = 'Consumed time to clean list (sec) = %7.3f' % (time()-self.t0_sec)        
            #print msg

        self.setItemsHidden()

        self.list_of_visible_records = []

        if self.instr_name.value() == self.instr_name.value_def() : return
        if self.exp_name  .value() == self.exp_name  .value_def() : return

        msg = 'Begin to update the list of runs. It is slow procedure that takes ~0.1s/run, stay calm and wait.'
        logger.info(msg, __name__)
        #print msg
        # Get run records from RegDB
        self.dict_run_recs = ru.calibration_runs (self.instr_name.value(), self.exp_name.value())
        #print 'self.dict_run_recs = ', self.dict_run_recs

        self.list_of_run_strs_in_dir = fnm.get_list_of_xtc_runs()   # ['0001', '0202', '0203',...]
        self.list_of_run_nums_in_dir = gu.list_of_int_from_list_of_str(self.list_of_run_strs_in_dir) # [1, 202, 203, 204,...]
        self.list_of_run_nums_in_regdb = ru.list_of_runnums(self.instr_name.value(), self.exp_name.value())

        #print 'list_of_run_nums_in_dir  :', self.list_of_run_nums_in_dir
        #print 'list_of_run_nums_in_regdb:', self.list_of_run_nums_in_regdb
        #print '\nA. Consumed time (sec) =', time()-self.t0_sec
        #print 'Begin to construct the list of items for %s' % self.exp_name.value()

        
        if self.list_of_run_nums_in_regdb == [] : self.list_of_runs = self.list_of_run_nums_in_dir
        else                                    : self.list_of_runs = self.list_of_run_nums_in_regdb


        for run_num in self.list_of_runs :

            str_run_num = '%04d' % run_num
            self.str_run_number.setValue(str_run_num)

            if not self.isSelectedRun            (run_num) :
                print 'not self.isSelectedRun', run_num 
                continue

            if not self.hasSelectedDetectorsInRun(run_num) :
                print 'not self.hasSelectedDetectorsInRun', run_num 
                continue

            if not run_num in self.list_of_run_nums_in_dir :
                self.comment = 'xtc file IS NOT on disk!'
                self.xtc_in_dir = False
            else :
                self.xtc_in_dir = True
                #self.type    = 'N/A'

            item, widg = self.create_or_use_guidarklistitem(run_num)

            self.list.setItemHidden (item, False)

            record = run_num, item, widg
            self.list_of_visible_records.append(record)


        self.list.sortItems(QtCore.Qt.AscendingOrder)

        msg = 'Consumed time to generate list of files (sec) = %7.3f' % (time()-self.t0_sec)        
        logger.info(msg, __name__)
Esempio n. 10
0
    def updateList(self, clearList=False) :

        self.t0_sec = time()

        if clearList :
            self.list.clear()
            self.dict_guidarklistitem = {}

        self.setItemsHidden()

        self.list_of_visible_records = []

        if self.instr_name.value() == self.instr_name.value_def() : return
        if self.exp_name  .value() == self.exp_name  .value_def() : return

        msg = 'Begin to update the list of runs. It is slow procedure that takes ~0.1s/run, stay calm and wait.'
        logger.info(msg, __name__)
        #print msg
        # Get run records from RegDB
        self.dict_run_recs = ru.calibration_runs (self.instr_name.value(), self.exp_name.value())
        #print 'self.dict_run_recs = ', self.dict_run_recs

        self.list_of_run_strs_in_dir = fnm.get_list_of_xtc_runs()   # ['0001', '0202', '0203',...]
        self.list_of_run_nums_in_dir = gu.list_of_int_from_list_of_str(self.list_of_run_strs_in_dir) # [1, 202, 203, 204,...]
        self.list_of_run_nums_in_regdb = ru.list_of_runnums(self.instr_name.value(), self.exp_name.value())

        #print 'list_of_run_nums_in_dir:\n',   self.list_of_run_nums_in_dir
        #print 'list_of_run_nums_in_regdb:\n', self.list_of_run_nums_in_regdb
        #print '\nA. Consumed time (sec) =', time()-self.t0_sec
        #print 'Begin to construct the list of items for %s' % self.exp_name.value()

        
        if self.list_of_run_nums_in_regdb == [] : self.list_of_runs = self.list_of_run_nums_in_dir
        else                                    : self.list_of_runs = self.list_of_run_nums_in_regdb


        for run_num in self.list_of_runs :

            str_run_num = '%04d' % run_num
            self.str_run_number.setValue(str_run_num)

            if not self.isSelectedRun            (run_num) : continue
            if not self.hasSelectedDetectorsInRun(run_num) : continue

            if not run_num in self.list_of_run_nums_in_dir :
                self.comment = 'NOT FOUND xtc file!'
                #self.type    = 'N/A'

            #item = QtGui.QListWidgetItem('', self.list)
            #widg = GUIDarkListItem(self, str_run_num, self.type, self.comment) # THIS GUY CONSUMES ~90ms !
            item, widg = self.create_or_use_guidarklistitem(run_num)

            self.list.setItemHidden (item, False)

            record = run_num, item, widg
            self.list_of_visible_records.append(record)

            #self.list.addItem(item)
            #item.setFlags (  QtCore.Qt.ItemIsEnabled ) #| QtCore.Qt.ItemIsSelectable  | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsTristate)
            #print 'item.flags(): %o' % item.flags()
            #item.setCheckState(0) 
            #item.setFlags ( QtCore.Qt.ItemIsEnabled )

            #item.setFlags (  QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable  | QtCore.Qt.ItemIsUserCheckable )
            #item.setSizeHint(widg.size())
            #self.list.setItemWidget(item, widg)

            #self.list.setItemSelected(item, True)

        self.list.sortItems(QtCore.Qt.AscendingOrder)

        msg = 'Consumed time to generate list of files (sec) = %7.3f' % (time()-self.t0_sec)        
        logger.info(msg, __name__)
Esempio n. 11
0
 def get_list_of_sources (self) :
     if self.scan_log_exists() :
         self.parse_batch_log_peds_scan()        
         return self.list_of_sources
     # Use RegDB
     return ru.list_of_sources_in_run(cp.instr_name.value(), cp.exp_name.value(), int(cp.str_run_number.value()))
Esempio n. 12
0
 def txt_of_sources_in_run(self) :
     return ru.txt_of_sources_in_run(cp.instr_name.value(), cp.exp_name.value(), int(cp.str_run_number.value()))
Esempio n. 13
0
    def updateList(self, clearList=False) :

        self.update_counter += 1

        self.t0_sec = time()

        if clearList :
            self.removeItemWidgets()            
            self.list.clear()
            self.dict_guidarklistitem.clear()
            #msg = 'Consumed time to clean list (sec) = %7.3f' % (time()-self.t0_sec)        
            #print msg

        self.setItemsHidden()

        self.list_of_visible_records = []

        if self.instr_name.value() == self.instr_name.value_def() : return
        if self.exp_name  .value() == self.exp_name  .value_def() : return

        msg = 'Begin to update the list of runs. It is slow procedure that takes ~0.1s/run, stay calm and wait.'
        logger.info(msg, __name__)
        #print msg
        # Get run records from RegDB
        self.dict_run_recs = ru.calibration_runs (self.instr_name.value(), self.exp_name.value())
        #print 'self.dict_run_recs = ', self.dict_run_recs

        self.list_of_run_strs_in_dir = fnm.get_list_of_xtc_runs()   # ['0001', '0202', '0203',...]
        self.list_of_run_nums_in_dir = gu.list_of_int_from_list_of_str(self.list_of_run_strs_in_dir) # [1, 202, 203, 204,...]
        self.list_of_run_nums_in_regdb = ru.list_of_runnums(self.instr_name.value(), self.exp_name.value())

        #print 'list_of_run_nums_in_dir  :', self.list_of_run_nums_in_dir
        #print 'list_of_run_nums_in_regdb:', self.list_of_run_nums_in_regdb
        #print '\nA. Consumed time (sec) =', time()-self.t0_sec
        #print 'Begin to construct the list of items for %s' % self.exp_name.value()

        
        if self.list_of_run_nums_in_regdb == [] : self.list_of_runs = self.list_of_run_nums_in_dir
        else                                    : self.list_of_runs = self.list_of_run_nums_in_regdb


        for run_num in self.list_of_runs :

            str_run_num = '%04d' % run_num
            self.str_run_number.setValue(str_run_num)

            if not self.isSelectedRun            (run_num) :
                #print 'not self.isSelectedRun', run_num 
                continue

            if not self.hasSelectedDetectorsInRun(run_num) :
                #print 'not self.hasSelectedDetectorsInRun', run_num 
                continue

            if not run_num in self.list_of_run_nums_in_dir :
                self.comment = 'xtc file IS NOT on disk!'
                self.xtc_in_dir = False
            else :
                self.xtc_in_dir = True
                #self.type    = 'N/A'

            item, widg = self.create_or_use_guidarklistitem(run_num)

            self.list.setItemHidden (item, False)

            record = run_num, item, widg
            self.list_of_visible_records.append(record)


        self.list.sortItems(QtCore.Qt.AscendingOrder)

        msg = 'Consumed time to generate list of files (sec) = %7.3f' % (time()-self.t0_sec)        
        logger.info(msg, __name__)