irrad_control/gui/widgets/daq_info_widget.py
def _init_ui(self):
        """Init the user interface of the widget. Use one tab per ADC"""

        # Main layout of the widget
        self.main_layout = QtWidgets.QVBoxLayout()
        self.setLayout(self.main_layout)

        # Main widget
        self.tabs = QtWidgets.QTabWidget()

        # Info labels for all ADCs
        self.data_rate_labels = {}
        self.sampling_rate_labels = {}
        self.num_avg_labels = {}
        self.full_scale_labels = {}
        self.beam_current_labels = {}

        # Loop over all servers and check whether we have an ADC
        for server in self.servers:

            if 'adc' not in self.setup[server]['devices']:
                continue

            info_widget = GridContainer(name='Info')

            # Fill info layout with labels and widgets
            # Check info in daq_setup
            _cnfg = self.setup[server]['devices']['adc']
            _srate_lbl = '' if 'sampling_rate' not in _cnfg else _cnfg['sampling_rate']
            _avgs_lbl = '' if 'sampling_rate' not in _cnfg else ads1256['avgs'][_cnfg['sampling_rate']]

            # Set labels
            self.data_rate_labels[server] = QtWidgets.QLabel('Data rate :' + '\t' + 'Hz ')
            self.sampling_rate_labels[server] = QtWidgets.QLabel('Sampling rate: %s sps' % _srate_lbl)
            self.num_avg_labels[server] = QtWidgets.QLabel('Averages: %s' % _avgs_lbl)
            self.beam_current_labels[server] = QtWidgets.QLabel('Beam current:' + '\t' + 'nA')

            # Tooltips of labels
            self.data_rate_labels[server].setToolTip('Rate of incoming data of respective ADC')
            self.sampling_rate_labels[server].setToolTip('Samples per second of the ADS1256')
            self.num_avg_labels[server].setToolTip('Number of averages done by the ADS1256 for respective sampling rate')

            # Helper widgets to change display of raw data
            # Spinbox to select refresh rate of data
            interval_spinbox = QtWidgets.QDoubleSpinBox()
            interval_spinbox.setPrefix('Refresh every ')
            interval_spinbox.setSuffix(' s')
            interval_spinbox.setDecimals(1)
            interval_spinbox.setRange(0, 10)  # max 10 s
            interval_spinbox.setValue(self.refresh_interval[server])
            interval_spinbox.valueChanged.connect(lambda v, x=server: self.update_interval(x, v))

            # Spinbox to adjust number of digits
            digit_spinbox = QtWidgets.QSpinBox()
            digit_spinbox.setPrefix('Digits: ')
            digit_spinbox.setRange(1, 10)  # max 10 decimals
            digit_spinbox.setValue(self.n_digits[server])
            digit_spinbox.valueChanged.connect(lambda v, x=server: self.update_digits(x, v))

            # Radio buttons in order to set unit in which raw data should be displayed
            unit_label = QtWidgets.QLabel('Unit:')
            volt_rb = QtWidgets.QRadioButton('V')
            volt_rb.setChecked(True)
            ampere_rb = QtWidgets.QRadioButton('nA')
            volt_rb.toggled.connect(lambda v, x=server: self.update_unit(v, x, volt_rb.text()))
            ampere_rb.toggled.connect(lambda v, x=server: self.update_unit(v, x, ampere_rb.text()))

            unit_widget = QtWidgets.QWidget()
            unit_widget.setLayout(QtWidgets.QHBoxLayout())
            unit_widget.layout().addWidget(volt_rb)
            unit_widget.layout().addWidget(ampere_rb)

            # Add to layout
            info_widget.add_widget(widget=[self.data_rate_labels[server], self.beam_current_labels[server], interval_spinbox, digit_spinbox])
            info_widget.add_widget(widget=[self.sampling_rate_labels[server], self.num_avg_labels[server], unit_label, unit_widget])

            # Layout for table area
            table_widget = QtWidgets.QWidget()
            table_layout = QtWidgets.QVBoxLayout()
            table_widget.setLayout(table_layout)

            # Make table for ADC
            self.tables[server] = self._setup_table(server)

            all_tables = GridContainer(name='Raw data')
            for table in self.tables[server]:
                all_tables.add_widget(table)

            # Add to layout
            table_layout.addWidget(info_widget)
            table_layout.addWidget(all_tables)

            scroll_area = QtWidgets.QScrollArea()
            scroll_area.setWidgetResizable(True)
            scroll_area.setWidget(table_widget)

            self.tabs.addTab(scroll_area, self.setup[server]['name'])

        self.main_layout.addWidget(self.tabs)
Init the user interface of the widget. Use one tab per ADC
Init the user interface of the widget. Use one tab per ADC
Init the user interface of the widget . Use one tab per ADC
def _init_ui(self):
        self.main_layout = QtWidgets.QVBoxLayout()
        self.setLayout(self.main_layout)
        self.tabs = QtWidgets.QTabWidget()
        self.data_rate_labels = {}
        self.sampling_rate_labels = {}
        self.num_avg_labels = {}
        self.full_scale_labels = {}
        self.beam_current_labels = {}
        for server in self.servers:
            if 'adc' not in self.setup[server]['devices']:
                continue
            info_widget = GridContainer(name='Info')
            _cnfg = self.setup[server]['devices']['adc']
            _srate_lbl = '' if 'sampling_rate' not in _cnfg else _cnfg['sampling_rate']
            _avgs_lbl = '' if 'sampling_rate' not in _cnfg else ads1256['avgs'][_cnfg['sampling_rate']]
            self.data_rate_labels[server] = QtWidgets.QLabel('Data rate :' + '\t' + 'Hz ')
            self.sampling_rate_labels[server] = QtWidgets.QLabel('Sampling rate: %s sps' % _srate_lbl)
            self.num_avg_labels[server] = QtWidgets.QLabel('Averages: %s' % _avgs_lbl)
            self.beam_current_labels[server] = QtWidgets.QLabel('Beam current:' + '\t' + 'nA')
            self.data_rate_labels[server].setToolTip('Rate of incoming data of respective ADC')
            self.sampling_rate_labels[server].setToolTip('Samples per second of the ADS1256')
            self.num_avg_labels[server].setToolTip('Number of averages done by the ADS1256 for respective sampling rate')
            interval_spinbox = QtWidgets.QDoubleSpinBox()
            interval_spinbox.setPrefix('Refresh every ')
            interval_spinbox.setSuffix(' s')
            interval_spinbox.setDecimals(1)
            interval_spinbox.setRange(0, 10)  
            interval_spinbox.setValue(self.refresh_interval[server])
            interval_spinbox.valueChanged.connect(lambda v, x=server: self.update_interval(x, v))
            digit_spinbox = QtWidgets.QSpinBox()
            digit_spinbox.setPrefix('Digits: ')
            digit_spinbox.setRange(1, 10)  
            digit_spinbox.setValue(self.n_digits[server])
            digit_spinbox.valueChanged.connect(lambda v, x=server: self.update_digits(x, v))
            unit_label = QtWidgets.QLabel('Unit:')
            volt_rb = QtWidgets.QRadioButton('V')
            volt_rb.setChecked(True)
            ampere_rb = QtWidgets.QRadioButton('nA')
            volt_rb.toggled.connect(lambda v, x=server: self.update_unit(v, x, volt_rb.text()))
            ampere_rb.toggled.connect(lambda v, x=server: self.update_unit(v, x, ampere_rb.text()))
            unit_widget = QtWidgets.QWidget()
            unit_widget.setLayout(QtWidgets.QHBoxLayout())
            unit_widget.layout().addWidget(volt_rb)
            unit_widget.layout().addWidget(ampere_rb)
            info_widget.add_widget(widget=[self.data_rate_labels[server], self.beam_current_labels[server], interval_spinbox, digit_spinbox])
            info_widget.add_widget(widget=[self.sampling_rate_labels[server], self.num_avg_labels[server], unit_label, unit_widget])
            table_widget = QtWidgets.QWidget()
            table_layout = QtWidgets.QVBoxLayout()
            table_widget.setLayout(table_layout)
            self.tables[server] = self._setup_table(server)
            all_tables = GridContainer(name='Raw data')
            for table in self.tables[server]:
                all_tables.add_widget(table)
            table_layout.addWidget(info_widget)
            table_layout.addWidget(all_tables)
            scroll_area = QtWidgets.QScrollArea()
            scroll_area.setWidgetResizable(True)
            scroll_area.setWidget(table_widget)
            self.tabs.addTab(scroll_area, self.setup[server]['name'])
        self.main_layout.addWidget(self.tabs)
def _init_ui ( self ) : self . main_layout = QtWidgets . QVBoxLayout ( ) self . setLayout ( self . main_layout ) self . tabs = QtWidgets . QTabWidget ( ) self . data_rate_labels = { } self . sampling_rate_labels = { } self . num_avg_labels = { } self . full_scale_labels = { } self . beam_current_labels = { } for server in self . servers : if 'adc' not in self . setup [ server ] [ 'devices' ] : continue info_widget = GridContainer ( name = 'Info' ) _cnfg = self . setup [ server ] [ 'devices' ] [ 'adc' ] _srate_lbl = '' if 'sampling_rate' not in _cnfg else _cnfg [ 'sampling_rate' ] _avgs_lbl = '' if 'sampling_rate' not in _cnfg else ads1256 [ 'avgs' ] [ _cnfg [ 'sampling_rate' ] ] self . data_rate_labels [ server ] = QtWidgets . QLabel ( 'Data rate :' + '\t' + 'Hz ' ) self . sampling_rate_labels [ server ] = QtWidgets . QLabel ( 'Sampling rate: %s sps' % _srate_lbl ) self . num_avg_labels [ server ] = QtWidgets . QLabel ( 'Averages: %s' % _avgs_lbl ) self . beam_current_labels [ server ] = QtWidgets . QLabel ( 'Beam current:' + '\t' + 'nA' ) self . data_rate_labels [ server ] . setToolTip ( 'Rate of incoming data of respective ADC' ) self . sampling_rate_labels [ server ] . setToolTip ( 'Samples per second of the ADS1256' ) self . num_avg_labels [ server ] . setToolTip ( 'Number of averages done by the ADS1256 for respective sampling rate' ) interval_spinbox = QtWidgets . QDoubleSpinBox ( ) interval_spinbox . setPrefix ( 'Refresh every ' ) interval_spinbox . setSuffix ( ' s' ) interval_spinbox . setDecimals ( 1 ) interval_spinbox . setRange ( 0 , 10 ) interval_spinbox . setValue ( self . refresh_interval [ server ] ) interval_spinbox . valueChanged . connect ( lambda v , x = server : self . update_interval ( x , v ) ) digit_spinbox = QtWidgets . QSpinBox ( ) digit_spinbox . setPrefix ( 'Digits: ' ) digit_spinbox . setRange ( 1 , 10 ) digit_spinbox . setValue ( self . n_digits [ server ] ) digit_spinbox . valueChanged . connect ( lambda v , x = server : self . update_digits ( x , v ) ) unit_label = QtWidgets . QLabel ( 'Unit:' ) volt_rb = QtWidgets . QRadioButton ( 'V' ) volt_rb . setChecked ( True ) ampere_rb = QtWidgets . QRadioButton ( 'nA' ) volt_rb . toggled . connect ( lambda v , x = server : self . update_unit ( v , x , volt_rb . text ( ) ) ) ampere_rb . toggled . connect ( lambda v , x = server : self . update_unit ( v , x , ampere_rb . text ( ) ) ) unit_widget = QtWidgets . QWidget ( ) unit_widget . setLayout ( QtWidgets . QHBoxLayout ( ) ) unit_widget . layout ( ) . addWidget ( volt_rb ) unit_widget . layout ( ) . addWidget ( ampere_rb ) info_widget . add_widget ( widget = [ self . data_rate_labels [ server ] , self . beam_current_labels [ server ] , interval_spinbox , digit_spinbox ] ) info_widget . add_widget ( widget = [ self . sampling_rate_labels [ server ] , self . num_avg_labels [ server ] , unit_label , unit_widget ] ) table_widget = QtWidgets . QWidget ( ) table_layout = QtWidgets . QVBoxLayout ( ) table_widget . setLayout ( table_layout ) self . tables [ server ] = self . _setup_table ( server ) all_tables = GridContainer ( name = 'Raw data' ) for table in self . tables [ server ] : all_tables . add_widget ( table ) table_layout . addWidget ( info_widget ) table_layout . addWidget ( all_tables ) scroll_area = QtWidgets . QScrollArea ( ) scroll_area . setWidgetResizable ( True ) scroll_area . setWidget ( table_widget ) self . tabs . addTab ( scroll_area , self . setup [ server ] [ 'name' ] ) self . main_layout . addWidget ( self . tabs )
Init the user interface of the widget.
Init the user interface of the widget .
"""Init the user interface of the widget. Use one tab per ADC""" # Main layout of the widget # Main widget # Info labels for all ADCs # Loop over all servers and check whether we have an ADC # Fill info layout with labels and widgets # Check info in daq_setup # Set labels # Tooltips of labels # Helper widgets to change display of raw data # Spinbox to select refresh rate of data # max 10 s # Spinbox to adjust number of digits # max 10 decimals # Radio buttons in order to set unit in which raw data should be displayed # Add to layout # Layout for table area # Make table for ADC # Add to layout
self