コード例 #1
0
	def OnAddDevice(self, evt=None):
		"""
		Add a blank variable to the OLV.
		"""

		# Ensure that we get a unique name.
		with self.global_store.devices.lock:
			num = 1
			done = False
			while not done:
				name = 'New device {0}'.format(num)
				dev_cfg = DeviceConfig(name=name)

				try:
					self.global_store.devices[name] = dev_cfg
				except KeyError:
					num += 1
				else:
					done = True

		self.olv.AddObject(dev_cfg)

		# OLV likes to select a random item at this point.
		self.olv.DeselectAll()
コード例 #2
0
ファイル: device_config.py プロジェクト: 0/SpanishAcquisition
	def GetValue(self):
		dev_cfg = DeviceConfig(name=self.name)

		# Address mode.
		dev_cfg.address_mode = self.get_address_mode()

		## Ethernet.
		possible_address = self.ip_address_input.GetAddress()
		if self.ip_address_input.IsValid() and len(possible_address) > 6:
			dev_cfg.ip_address = possible_address
		else:
			dev_cfg.ip_address = None

		## GPIB.
		dev_cfg.gpib_board = self.gpib_board_input.Value
		dev_cfg.gpib_pad = self.gpib_pad_input.Value
		dev_cfg.gpib_sad = self.gpib_sad_input.Value

		## USB.
		possible_resource = self.usb_resource_input.Value
		if possible_resource:
			dev_cfg.usb_resource = possible_resource
		else:
			dev_cfg.usb_resource = None

		# Implementation.
		dev_cfg.manufacturer = self.manufacturer
		dev_cfg.model = self.model
		dev_cfg.mock = self.mock_input.Value

		# Device.
		dev_cfg.device = self.device

		# Resource labels.
		dev_cfg.resource_labels = self.resource_labels

		return dev_cfg
コード例 #3
0
	def testPulseProgram(self):
		"""
		Iterate with a pulse program.
		"""

		res_buf = []

		def setter(value):
			res_buf.append(value)

		res = Resource(setter=setter)
		var1 = OutputVariable(name='Var 1', order=1, enabled=True)
		var1.config = LinSpaceConfig(1.0, 4.0, 4)

		p = Program.from_file(path.join(resource_dir, '01.pulse'))
		p.frequency = Quantity(1, 'GHz')
		p.set_value(('_acq_marker', 'marker_num'), 1)
		p.set_value(('_acq_marker', 'output'), 'f1')

		eq_(p.all_values, set([('_acq_marker', 'marker_num'), ('_acq_marker', 'output'), ('d',), ('i',),
				('p', 'amplitude'), ('p', 'length'), ('p', 'shape')]))

		parameters = [('i',), ('d',), ('p', 'amplitude'), ('p', 'length')]
		for parameter in parameters:
			p.resource_labels[parameter] = 'res_' + '.'.join(parameter)
			p.resources[parameter] = Resource()

		var2 = OutputVariable(name='Var 2', order=1, enabled=True)
		var2.config = LinSpaceConfig(1, 4, 4)
		var2.type = 'integer'

		awg_cfg = DeviceConfig('awg')
		awg_cfg.address_mode = awg_cfg.address_modes.gpib
		awg_cfg.manufacturer, awg_cfg.model = 'Tektronix', 'AWG5014B'
		awg_cfg.mock = True
		awg_cfg.connect()

		osc_cfg = DeviceConfig('osc')
		osc_cfg.address_mode = awg_cfg.address_modes.gpib
		osc_cfg.manufacturer, osc_cfg.model = 'Tektronix', 'DPO7104'
		osc_cfg.mock = True
		osc_cfg.connect()

		pulse_config = sweep.PulseConfiguration(p.with_resources, {'f1': 1}, awg_cfg.device, osc_cfg.device)

		vars, num_items = sort_output_variables([var1, var2])
		ress = [(('Res 1', res), ('Res 2', p.resources[('i',)]))]
		ctrl = sweep.SweepController(ress, vars, num_items, [], [],[],[],pulse_config)

		ctrl.run()

		eq_(res_buf, [1.0, 2.0, 3.0, 4.0])
コード例 #4
0
    def testPulseProgram(self):
        """
		Iterate with a pulse program.
		"""

        res_buf = []

        def setter(value):
            res_buf.append(value)

        res = Resource(setter=setter)
        var1 = OutputVariable(name='Var 1', order=1, enabled=True)
        var1.config = LinSpaceConfig(1.0, 4.0, 4)

        p = Program.from_file(path.join(resource_dir, '01.pulse'))
        p.frequency = Quantity(1, 'GHz')
        p.set_value(('_acq_marker', 'marker_num'), 1)
        p.set_value(('_acq_marker', 'output'), 'f1')

        eq_(
            p.all_values,
            set([('_acq_marker', 'marker_num'), ('_acq_marker', 'output'),
                 ('d', ), ('i', ), ('p', 'amplitude'), ('p', 'length'),
                 ('p', 'shape')]))

        parameters = [('i', ), ('d', ), ('p', 'amplitude'), ('p', 'length')]
        for parameter in parameters:
            p.resource_labels[parameter] = 'res_' + '.'.join(parameter)
            p.resources[parameter] = Resource()

        var2 = OutputVariable(name='Var 2', order=1, enabled=True)
        var2.config = LinSpaceConfig(1, 4, 4)
        var2.type = 'integer'

        awg_cfg = DeviceConfig('awg')
        awg_cfg.address_mode = awg_cfg.address_modes.gpib
        awg_cfg.manufacturer, awg_cfg.model = 'Tektronix', 'AWG5014B'
        awg_cfg.mock = True
        awg_cfg.connect()

        osc_cfg = DeviceConfig('osc')
        osc_cfg.address_mode = awg_cfg.address_modes.gpib
        osc_cfg.manufacturer, osc_cfg.model = 'Tektronix', 'DPO7104'
        osc_cfg.mock = True
        osc_cfg.connect()

        pulse_config = sweep.PulseConfiguration(p.with_resources, {'f1': 1},
                                                awg_cfg.device, osc_cfg.device)

        vars, num_items = sort_output_variables([var1, var2])
        ress = [(('Res 1', res), ('Res 2', p.resources[('i', )]))]
        ctrl = sweep.SweepController(ress, vars, num_items, [], [], [], [],
                                     pulse_config)

        ctrl.run()

        eq_(res_buf, [1.0, 2.0, 3.0, 4.0])
コード例 #5
0
    def GetValue(self):
        dev_cfg = DeviceConfig(name=self.name)

        # Address mode.
        dev_cfg.address_mode = self.get_address_mode()

        ## Ethernet.
        possible_address = self.ip_address_input.GetAddress()
        if self.ip_address_input.IsValid() and len(possible_address) > 6:
            dev_cfg.ip_address = possible_address
        else:
            dev_cfg.ip_address = None

        ## GPIB.
        dev_cfg.gpib_board = self.gpib_board_input.Value
        dev_cfg.gpib_pad = self.gpib_pad_input.Value
        dev_cfg.gpib_sad = self.gpib_sad_input.Value

        ## USB.
        possible_resource = self.usb_resource_input.Value
        if possible_resource:
            dev_cfg.usb_resource = possible_resource
        else:
            dev_cfg.usb_resource = None

        # Implementation.
        dev_cfg.manufacturer = self.manufacturer
        dev_cfg.model = self.model
        dev_cfg.mock = self.mock_input.Value

        # Device.
        dev_cfg.device = self.device

        # Resource labels.
        dev_cfg.resource_labels = self.resource_labels

        return dev_cfg