Ejemplo n.º 1
0
    def OnMenuFileOpen(self, evt=None):
        wildcard = determine_wildcard('pulse', 'Pulse program')
        dlg = wx.FileDialog(parent=self,
                            message='Load...',
                            wildcard=wildcard,
                            style=wx.FD_OPEN)

        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()

            try:
                prog = Program.from_file(path)
            except PulseSyntaxError as e:
                MessageDialog(self,
                              '\n'.join(e[0]),
                              'Compilation error',
                              monospace=True).Show()

                return

            # Only purge the previous file if this one has been opened successfully.
            self.OnMenuFileClose()

            self.load_program(prog)

            self.global_store.pulse_program = prog
    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])
Ejemplo n.º 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])
Ejemplo n.º 4
0
	def OnMenuFileOpen(self, evt=None):
		wildcard = determine_wildcard('pulse', 'Pulse program')
		dlg = wx.FileDialog(parent=self, message='Load...', wildcard=wildcard,
				style=wx.FD_OPEN)

		if dlg.ShowModal() == wx.ID_OK:
			path = dlg.GetPath()

			try:
				prog = Program.from_file(path)
			except PulseSyntaxError as e:
				MessageDialog(self, '\n'.join(e[0]), 'Compilation error', monospace=True).Show()

				return

			# Only purge the previous file if this one has been opened successfully.
			self.OnMenuFileClose()

			self.load_program(prog)

			self.global_store.pulse_program = prog