예제 #1
0
 def get_state(self):
     if self.state != {}:
         magnitude, voltage = parse_units(self.state['voltage'],
                                          base_unit='V')
         return {self.channel: magnitude}
     else:
         return {}
예제 #2
0
 def get_state(self):
     ''' Returns a dictionary representing the event state with magnitude scaled
         to the base unit. For example, if the button reads '100 MHz', then this
         method will return {'frequency': 100e6}. '''
     if self.state != {}:
         if 'frequency' in self.state:
             self.state['frequency'], freq_string = parse_units(
                 self.state['frequency'], base_unit='Hz')
         return {self.channel: self.state}
     else:
         return {}
예제 #3
0
 def get_parameters(self):
     ''' Open a window, wait for user input, and return the result. '''
     result = self.exec_params()
     parameters = {}
     for key in self.edits:
         if self.edits[key].text() != '':
             parameters[key] = self.edits[key].text()
             if key in self.units:
                 magnitude, parameters[key] = parse_units(
                     parameters[key], self.units[key])
     return (parameters, result == QDialog.Accepted)
예제 #4
0
    def set_state(self, state):
        ''' Takes a float-valued delay and stores in a state dictionary '''
        string = ''
        if state == '':
            self.state = {}
            self.setProperty('active', False)
        else:
            self.state = {'delay': state}
            magnitude, delay = parse_units(self.state['delay'], base_unit='s')
            string += delay
            self.setProperty('active', True)

        self.setText(string)
        self.setStyle(self.style())
예제 #5
0
    def set_state(self, state):
        ''' Takes a float-valued voltage and stores in a state dictionary '''
        string = ''
        if state == '':
            self.state = {}
            self.setProperty('active', False)
        else:
            self.state = {'voltage': state}
            magnitude, voltage = parse_units(self.state['voltage'],
                                             base_unit='V')
            string += voltage
            self.setProperty('active', True)

        self.setText(string)
        self.setStyle(self.style())
예제 #6
0
    def get_sequence(self):
        ''' Retrieves subsequences from all child tables and aggregates into
            a master sequence. '''
        sequence = []
        for col in range(self.columnCount()):
            duration = self.horizontalHeaderItem(col).text().split('\n')[1]
            magnitude, duration = parse_units(duration, base_unit='s')

            name = self.horizontalHeaderItem(col).text().split('\n')[0]
            sequence.append({'duration': magnitude})
            if name != '':
                sequence[-1]['name'] = name
        for child in self.children:
            subsequence = child.get_sequence()
            for i, step in enumerate(subsequence):
                sequence[i].update(step)
        return sequence
예제 #7
0
    def set_sequence(self, sequence):
        ''' Applies a json-formatted sequence to all child tables. '''
        self.setColumnCount(len(sequence))
        labels = []
        for step in sequence:
            header = ''
            if 'name' in step:
                header += step['name']
            magnitude, step['duration'] = parse_units(step['duration'], base_unit='s')

            header += '\n' + str(step['duration'])
            labels.append(header)
        self.setHorizontalHeaderLabels(labels)

        for child in self.children:
            child.set_sequence(sequence)
        self.sequence = sequence
예제 #8
0
    def set_state(self, state):
        ''' Takes a state dictionary of the form {'frequency': 100e6, 'attenuation': 3}
            and displays a unitful string converted to the most compact representation -
            for example, 100e6 is converted to '100 MHz'. '''
        self.state = state
        string = ''
        if 'frequency' in state:
            magnitude, state['frequency'] = parse_units(state['frequency'],
                                                        base_unit='Hz')
            string += f"{state['frequency']}"
        if 'attenuation' in state:
            if 'frequency' in state:
                string += '\n'
            string += f"-{state['attenuation']} dB"
        self.setText(string)

        self.setProperty('active', string != '')
        self.setStyle(self.style())
예제 #9
0
 def get_state(self):
     if self.state != {}:
         magnitude, delay = parse_units(self.state['delay'], base_unit='s')
         return {self.channel: magnitude}
     else:
         return {}
예제 #10
0
 def convert_units(self):
     if self.text() == '':
         return
     magnitude, text = parse_units(self.text(), base_unit=self.base_unit)
     self._setText(text)
     self.magnitude = magnitude