コード例 #1
0
 def _set_channel_input_frequency_max(self, index, value):
     value = float(value)
     index = ivi.get_index(self._channel_name, index)
     if not self._driver_operation_simulate:
         self._set_channel_bw_limit(index, value < 20e6)
     self._channel_input_frequency_max[index] = value
     self._set_cache_valid(index=index)
コード例 #2
0
 def _set_channel_offset(self, index, value):
     index = ivi.get_index(self._channel_name, index)
     value = float(value)
     if not self._driver_operation_simulate:
         self._write("%s:OFST %.5e" % (self._channel_command_name[index], value))
     self._channel_offset[index] = value
     self._set_cache_valid(index=index)
コード例 #3
0
 def _measurement_fetch_waveform_measurement(self, index, measurement_function, ref_channel = None):
     index = ivi.get_index(self._channel_name, index)
     if measurement_function not in MeasurementFunctionMapping:
         raise ivi.ValueNotSupportedException()
     measurement_function = MeasurementFunctionMapping[measurement_function]
     if not self._driver_operation_simulate:
         # Look for a measurement slot to use (preferrably one available or already measuring what we want so as not to require overriding an existing measurement)
         selected_slot = None
         must_configure = True
         for slot, value in self._measurement_slots.items():
             # If a slot is already configured for our exact measurement, use it and stop looking
             if value == (self._channel_name[index], measurement_function):
                 selected_slot = slot
                 must_configure = False
                 break
             # If a slot is available (not configured), we might use it, but keep looking for better
             elif value is None:
                 selected_slot = slot
             # If nothing better is found, we'll just have to use this one anyway...
             elif selected_slot is None:
                 selected_slot = slot
         # Configure the measurement slot if it wasn't already just as we need
         if must_configure:
             self._write("MDSP ON")
             self._write("MINMAX OFF")
             self._measurement_slots[selected_slot] = (self._channel_name[index], measurement_function)
             self._write("DIRM %s" % selected_slot)
             self._write("MSEL %s, %s" % self._measurement_slots[selected_slot])
             # Wait half a second so the measurement has at least a small chance to be computed
             time.sleep(0.5)
         value = float(self._ask("MSR%s?" % selected_slot).split(',')[0])
         if value == 9.91e37:
             return float('NaN')
         return value
     return 0
コード例 #4
0
 def _set_channel_enabled(self, index, value):
     value = bool(value)
     index = ivi.get_index(self._channel_command_name, index)
     if not self._driver_operation_simulate:
         self._write("%s:TRA %s" % (self._channel_command_name[index], self._bool_to_onoff(value)))
     self._channel_enabled[index] = value
     self._set_cache_valid(index=index)
コード例 #5
0
 def _set_channel_input_frequency_max(self, index, value):
     value = float(value)
     index = ivi.get_index(self._channel_name, index)
     if not self._driver_operation_simulate:
         self._set_channel_bw_limit(index, value < 20e6)
     self._channel_input_frequency_max[index] = value
     self._set_cache_valid(index=index)
コード例 #6
0
 def _get_channel_coupling(self, index):
     index = ivi.get_index(self._channel_name, index)
     if not self._driver_operation_simulate and not self._get_cache_valid(
             index=index):
         self._channel_coupling[index] = VerticalCouplingReverseMapping[
             self._ask("%s:CPL?" % self._channel_command_name[index])]
         self._set_cache_valid(index=index)
     return self._channel_coupling[index]
コード例 #7
0
 def _set_channel_offset(self, index, value):
     index = ivi.get_index(self._channel_name, index)
     value = float(value)
     if not self._driver_operation_simulate:
         self._write("%s:OFST %.5e" %
                     (self._channel_command_name[index], value))
     self._channel_offset[index] = value
     self._set_cache_valid(index=index)
コード例 #8
0
 def _set_channel_scale(self, index, value):
     index = ivi.get_index(self._channel_name, index)
     value = float(value)
     if not self._driver_operation_simulate:
         self._write("%s:VDIV %.5e" % (self._channel_command_name[index], value))
     # Coercion algorithm not implemented in driver, so not caching the value
     self._set_cache_valid(False, index=index)
     self._set_cache_valid(False, "channel_range", index)
コード例 #9
0
 def _set_channel_probe_attenuation(self, index, value):
     index = ivi.get_index(self._channel_name, index)
     value = int(value)
     if not self._driver_operation_simulate:
         self._write("%s:PROBE manual,%d" % (self._channel_command_name[index], value))
     self._channel_probe_attenuation[index] = value
     self._set_cache_valid(False, "channel_probe_attenuation_auto", index)
     self._set_cache_valid(index=index)
コード例 #10
0
 def _set_channel_enabled(self, index, value):
     value = bool(value)
     index = ivi.get_index(self._channel_command_name, index)
     if not self._driver_operation_simulate:
         self._write("%s:TRA %s" % (self._channel_command_name[index],
                                    self._bool_to_onoff(value)))
     self._channel_enabled[index] = value
     self._set_cache_valid(index=index)
コード例 #11
0
 def _get_channel_scale(self, index):
     index = ivi.get_index(self._channel_name, index)
     if not self._driver_operation_simulate and not self._get_cache_valid(index=index):
         self._channel_scale[index] = float(self._ask("%s:VDIV?" % self._channel_command_name[index]))
         self._channel_range[index] = self._channel_scale[index] * self._vertical_divisions
         self._set_cache_valid(index=index)
         self._set_cache_valid(True, "channel_range", index)
     return self._channel_scale[index]
コード例 #12
0
 def _get_channel_offset(self, index):
     index = ivi.get_index(self._channel_name, index)
     if not self._driver_operation_simulate and not self._get_cache_valid(
             index=index):
         self._channel_offset[index] = float(
             self._ask("%s:OFST?" % self._channel_command_name[index]))
         self._set_cache_valid(index=index)
     return self._channel_offset[index]
コード例 #13
0
 def _set_channel_coupling(self, index, value):
     index = ivi.get_index(self._channel_name, index)
     if value not in VerticalCouplingMapping:
         raise ivi.ValueNotSupportedException()
     if not self._driver_operation_simulate:
         self._write("%s:CPL %s" % (self._channel_command_name[index], VerticalCouplingMapping[value]))
     self._channel_coupling[index] = value
     self._set_cache_valid(False, "channel_input_impedance", index)
     self._set_cache_valid(index=index)
コード例 #14
0
 def _get_channel_bw_limit(self, index):
     index = ivi.get_index(self._channel_name, index)
     if not self._driver_operation_simulate and not self._get_cache_valid(index=index):
         value = self._ask("%s:BWL?" % self._channel_command_name[index]).lower()
         if value == 'full':
             value = False
         self._channel_bw_limit[index] = value
         self._set_cache_valid(index=index)
     return self._channel_bw_limit[index]
コード例 #15
0
 def _set_channel_scale(self, index, value):
     index = ivi.get_index(self._channel_name, index)
     value = float(value)
     if not self._driver_operation_simulate:
         self._write("%s:VDIV %.5e" %
                     (self._channel_command_name[index], value))
     # Coercion algorithm not implemented in driver, so not caching the value
     self._set_cache_valid(False, index=index)
     self._set_cache_valid(False, "channel_range", index)
コード例 #16
0
 def _get_channel_input_impedance(self, index):
     index = ivi.get_index(self._channel_name, index)
     if not self._driver_operation_simulate and not self._get_cache_valid(index=index):
         if self._ask("%s:CPL?" % self._channel_command_name[index]).count("50") > 0:
             self._channel_input_impedance[index] = 50
         else:
             self._channel_input_impedance[index] = 1000000
         self._set_cache_valid(index=index)
     return self._channel_input_impedance[index]
コード例 #17
0
 def _get_channel_enabled(self, index):
     index = ivi.get_index(self._channel_name, index)
     if not self._driver_operation_simulate and not self._get_cache_valid(
             index=index):
         self._channel_enabled[index] = (self._ask(
             "%s:TRA?" %
             self._channel_command_name[index]).lower() == ('on'))
         self._set_cache_valid(index=index)
     return self._channel_enabled[index]
コード例 #18
0
 def _set_channel_probe_attenuation(self, index, value):
     index = ivi.get_index(self._channel_name, index)
     value = int(value)
     if not self._driver_operation_simulate:
         self._write("%s:PROBE manual,%d" %
                     (self._channel_command_name[index], value))
     self._channel_probe_attenuation[index] = value
     self._set_cache_valid(False, "channel_probe_attenuation_auto", index)
     self._set_cache_valid(index=index)
コード例 #19
0
 def _get_channel_probe_attenuation_auto(self, index):
     index = ivi.get_index(self._channel_name, index)
     if not self._driver_operation_simulate and not self._get_cache_valid(
             index=index):
         self._channel_probe_attenuation_auto[index] = (self._ask(
             "%s:PROBE?" % self._channel_command_name[index]).split(
                 ',')[0].lower() == 'auto')
         self._set_cache_valid(index=index)
     return self._channel_probe_attenuation_auto[index]
コード例 #20
0
 def _set_channel_coupling(self, index, value):
     index = ivi.get_index(self._channel_name, index)
     if value not in VerticalCouplingMapping:
         raise ivi.ValueNotSupportedException()
     if not self._driver_operation_simulate:
         self._write("%s:CPL %s" % (self._channel_command_name[index],
                                    VerticalCouplingMapping[value]))
     self._channel_coupling[index] = value
     self._set_cache_valid(False, "channel_input_impedance", index)
     self._set_cache_valid(index=index)
コード例 #21
0
 def _get_channel_bw_limit(self, index):
     index = ivi.get_index(self._channel_name, index)
     if not self._driver_operation_simulate and not self._get_cache_valid(
             index=index):
         value = self._ask("%s:BWL?" %
                           self._channel_command_name[index]).lower()
         if value == 'full':
             value = False
         self._channel_bw_limit[index] = value
         self._set_cache_valid(index=index)
     return self._channel_bw_limit[index]
コード例 #22
0
 def _get_channel_input_impedance(self, index):
     index = ivi.get_index(self._channel_name, index)
     if not self._driver_operation_simulate and not self._get_cache_valid(
             index=index):
         if self._ask("%s:CPL?" %
                      self._channel_command_name[index]).count("50") > 0:
             self._channel_input_impedance[index] = 50
         else:
             self._channel_input_impedance[index] = 1000000
         self._set_cache_valid(index=index)
     return self._channel_input_impedance[index]
コード例 #23
0
 def _set_channel_probe_attenuation_auto(self, index, value):
     index = ivi.get_index(self._channel_name, index)
     if bool(value):
         value = 'auto'
     else:
         value = 'manual'
     if not self._driver_operation_simulate:
         self._write("%s:PROBE %s,1" % (self._channel_command_name[index], value))
     self._channel_probe_attenuation_auto[index] = value
     self._set_cache_valid(False, "channel_probe_attenuation", index)
     self._set_cache_valid(index=index)
コード例 #24
0
 def _get_channel_scale(self, index):
     index = ivi.get_index(self._channel_name, index)
     if not self._driver_operation_simulate and not self._get_cache_valid(
             index=index):
         self._channel_scale[index] = float(
             self._ask("%s:VDIV?" % self._channel_command_name[index]))
         self._channel_range[
             index] = self._channel_scale[index] * self._vertical_divisions
         self._set_cache_valid(index=index)
         self._set_cache_valid(True, "channel_range", index)
     return self._channel_scale[index]
コード例 #25
0
 def _set_channel_probe_attenuation_auto(self, index, value):
     index = ivi.get_index(self._channel_name, index)
     if bool(value):
         value = 'auto'
     else:
         value = 'manual'
     if not self._driver_operation_simulate:
         self._write("%s:PROBE %s,1" %
                     (self._channel_command_name[index], value))
     self._channel_probe_attenuation_auto[index] = value
     self._set_cache_valid(False, "channel_probe_attenuation", index)
     self._set_cache_valid(index=index)
コード例 #26
0
 def _set_channel_input_impedance(self, index, value):
     value = float(value)
     index = ivi.get_index(self._channel_name, index)
     if not (value == 1000000 or (value == 50 and self._channel_coupling[index] == 'dc')):
         raise Exception('Invalid impedance selection')
     if not self._driver_operation_simulate:
         if self._channel_coupling[index] == 'dc':
             if value == 1000000:
                 self._write("%s:CPL DC1M" % self._channel_command_name[index])
             elif value == 50:
                 self._write("%s:CPL DC50" % self._channel_command_name[index])
     self._channel_input_impedance[index] = value
     self._set_cache_valid(index=index)
コード例 #27
0
 def _set_channel_bw_limit(self, index, value):
     index = ivi.get_index(self._channel_name, index)
     if type(value) == bool:
         if value:
             value = '20m'
         else:
             value = 'full'
     if value.lower() not in ['full', '20m', '100m']:
         raise ivi.ValueNotSupportedException()
     if not self._driver_operation_simulate:
         self._write("%s:BWL %s" % (self._channel_command_name[index], value))
     self._channel_bw_limit[index] = value
     self._set_cache_valid(index=index)
コード例 #28
0
 def _set_channel_bw_limit(self, index, value):
     index = ivi.get_index(self._channel_name, index)
     if type(value) == bool:
         if value:
             value = '20m'
         else:
             value = 'full'
     if value.lower() not in ['full', '20m', '100m']:
         raise ivi.ValueNotSupportedException()
     if not self._driver_operation_simulate:
         self._write("%s:BWL %s" %
                     (self._channel_command_name[index], value))
     self._channel_bw_limit[index] = value
     self._set_cache_valid(index=index)
コード例 #29
0
    def _measurement_fetch_waveform(self, index):
        index = ivi.get_index(self._channel_name, index)

        if self._driver_operation_simulate:
            return list()

        self._write("DTFORM WORD")
        self._write("DTBORD H/L")
        self._write("DTSTART 0")
        self._write("DTPOINTS 500K")
        self._write("WAVESRC %s" % self._channel_name[index])

        # Read preamble
        pre = self._ask("DTINF?").split(',')
        points = int(pre[2 + 4 * self._channel_count +
                         5].split('=')[1].lstrip())
        xincrement = self._suffixed_string_to_float(
            pre[2 + 4 * self._channel_count +
                2].split('=')[1].lstrip().rstrip('s'))
        tdiv = self._suffixed_string_to_float(
            pre[2 + 4 * self._channel_count +
                2].split('=')[1].lstrip().rstrip('s'))
        trigdelay = self._suffixed_string_to_float(
            pre[2 + 4 * self._channel_count +
                3].split('=')[1].lstrip().rstrip('s'))
        xorigin = -(tdiv * self._horizontal_divisions / 2 + trigdelay)
        yincrement = self._suffixed_string_to_float(
            pre[2 + 4 * index + 2].split('=')[1].lstrip().rstrip('V'))
        yorigin = self._suffixed_string_to_float(
            pre[2 + 4 * index + 3].split('=')[1].lstrip().rstrip('V'))
        # Probe ratio is not taken into account in the info from DTINF, so do it ourselves (dirty, the ratio might have changed since acquisition...)
        yincrement /= self._get_channel_probe_attenuation(index)
        yorigin /= self._get_channel_probe_attenuation(index)

        self._write("DTWAVE?")

        # Read waveform data
        raw_data = self._read_ieee_block()

        # Split out points and convert to time and voltage pairs
        data = list()
        for i in range(points):
            x = (i * xincrement) + xorigin
            # Convert big-endian unsigned word to Python integer
            yval = struct.unpack(">H", raw_data[i * 2:i * 2 + 2])[0]
            y = (yval * yincrement) + yorigin
            data.append((x, y))

        return data
コード例 #30
0
 def _set_channel_input_impedance(self, index, value):
     value = float(value)
     index = ivi.get_index(self._channel_name, index)
     if not (value == 1000000 or
             (value == 50 and self._channel_coupling[index] == 'dc')):
         raise Exception('Invalid impedance selection')
     if not self._driver_operation_simulate:
         if self._channel_coupling[index] == 'dc':
             if value == 1000000:
                 self._write("%s:CPL DC1M" %
                             self._channel_command_name[index])
             elif value == 50:
                 self._write("%s:CPL DC50" %
                             self._channel_command_name[index])
     self._channel_input_impedance[index] = value
     self._set_cache_valid(index=index)
コード例 #31
0
    def _measurement_fetch_waveform(self, index):
        index = ivi.get_index(self._channel_name, index)
        
        if self._driver_operation_simulate:
            return list()

        self._write("DTFORM WORD")
        self._write("DTBORD H/L")
        self._write("DTSTART 0")
        self._write("DTPOINTS 500K")
        self._write("WAVESRC %s" % self._channel_name[index])
        
        # Read preamble
        pre = self._ask("DTINF?").split(',')
        points = int(pre[2+4*self._channel_count+5].split('=')[1].lstrip())
        xincrement = self._suffixed_string_to_float(pre[2+4*self._channel_count+2].split('=')[1].lstrip().rstrip('s'))
        tdiv = self._suffixed_string_to_float(pre[2+4*self._channel_count+2].split('=')[1].lstrip().rstrip('s'))
        trigdelay = self._suffixed_string_to_float(pre[2+4*self._channel_count+3].split('=')[1].lstrip().rstrip('s'))
        xorigin = - (tdiv * self._horizontal_divisions / 2 + trigdelay)
        yincrement = self._suffixed_string_to_float(pre[2+4*index+2].split('=')[1].lstrip().rstrip('V'))
        yorigin = self._suffixed_string_to_float(pre[2+4*index+3].split('=')[1].lstrip().rstrip('V'))
        # Probe ratio is not taken into account in the info from DTINF, so do it ourselves (dirty, the ratio might have changed since acquisition...)
        yincrement /= self._get_channel_probe_attenuation(index)
        yorigin /= self._get_channel_probe_attenuation(index)

        self._write("DTWAVE?")

        # Read waveform data
        raw_data = self._read_ieee_block()
        
        # Split out points and convert to time and voltage pairs
        data = list()
        for i in range(points):
            x = (i * xincrement) + xorigin
            # Convert big-endian unsigned word to Python integer
            yval = struct.unpack(">H", raw_data[i*2:i*2+2])[0]
            y = (yval * yincrement) + yorigin            
            data.append((x, y))
        
        return data
コード例 #32
0
 def _measurement_fetch_waveform_measurement(self,
                                             index,
                                             measurement_function,
                                             ref_channel=None):
     index = ivi.get_index(self._channel_name, index)
     if measurement_function not in MeasurementFunctionMapping:
         raise ivi.ValueNotSupportedException()
     measurement_function = MeasurementFunctionMapping[measurement_function]
     if not self._driver_operation_simulate:
         # Look for a measurement slot to use (preferrably one available or already measuring what we want so as not to require overriding an existing measurement)
         selected_slot = None
         must_configure = True
         for slot, value in self._measurement_slots.items():
             # If a slot is already configured for our exact measurement, use it and stop looking
             if value == (self._channel_name[index], measurement_function):
                 selected_slot = slot
                 must_configure = False
                 break
             # If a slot is available (not configured), we might use it, but keep looking for better
             elif value is None:
                 selected_slot = slot
             # If nothing better is found, we'll just have to use this one anyway...
             elif selected_slot is None:
                 selected_slot = slot
         # Configure the measurement slot if it wasn't already just as we need
         if must_configure:
             self._write("MDSP ON")
             self._write("MINMAX OFF")
             self._measurement_slots[selected_slot] = (
                 self._channel_name[index], measurement_function)
             self._write("DIRM %s" % selected_slot)
             self._write("MSEL %s, %s" %
                         self._measurement_slots[selected_slot])
             # Wait half a second so the measurement has at least a small chance to be computed
             time.sleep(0.5)
         value = float(self._ask("MSR%s?" % selected_slot).split(',')[0])
         if value == 9.91e37:
             return float('NaN')
         return value
     return 0
コード例 #33
0
 def _get_channel_enabled(self, index):
     index = ivi.get_index(self._channel_name, index)
     if not self._driver_operation_simulate and not self._get_cache_valid(index=index):
         self._channel_enabled[index] = (self._ask("%s:TRA?" % self._channel_command_name[index]).lower() == ('on'))
         self._set_cache_valid(index=index)
     return self._channel_enabled[index]
コード例 #34
0
 def _get_channel_probe_attenuation_auto(self, index):
     index = ivi.get_index(self._channel_name, index)
     if not self._driver_operation_simulate and not self._get_cache_valid(index=index):
         self._channel_probe_attenuation_auto[index] = (self._ask("%s:PROBE?" % self._channel_command_name[index]).split(',')[0].lower() == 'auto')
         self._set_cache_valid(index=index)
     return self._channel_probe_attenuation_auto[index]
コード例 #35
0
 def _get_channel_input_frequency_max(self, index):
     index = ivi.get_index(self._channel_name, index)
     return self._channel_input_frequency_max[index]
コード例 #36
0
 def _get_channel_coupling(self, index):
     index = ivi.get_index(self._channel_name, index)
     if not self._driver_operation_simulate and not self._get_cache_valid(index=index):
         self._channel_coupling[index] = VerticalCouplingReverseMapping[self._ask("%s:CPL?" % self._channel_command_name[index])]
         self._set_cache_valid(index=index)
     return self._channel_coupling[index]
コード例 #37
0
 def _get_channel_range(self, index):
     index = ivi.get_index(self._channel_name, index)
     self._get_channel_scale(index)
     return self._channel_range[index]
コード例 #38
0
 def _get_channel_offset(self, index):
     index = ivi.get_index(self._channel_name, index)
     if not self._driver_operation_simulate and not self._get_cache_valid(index=index):
         self._channel_offset[index] = float(self._ask("%s:OFST?" % self._channel_command_name[index]))
         self._set_cache_valid(index=index)
     return self._channel_offset[index]
コード例 #39
0
 def _get_channel_range(self, index):
     index = ivi.get_index(self._channel_name, index)
     self._get_channel_scale(index)
     return self._channel_range[index]
コード例 #40
0
 def _get_channel_input_frequency_max(self, index):
     index = ivi.get_index(self._channel_name, index)
     return self._channel_input_frequency_max[index]