Esempio n. 1
0
    def test_run_program(self):
        wf = DummyWaveform(duration=1.1, defined_channels={'A', 'B'})

        block = InstructionBlock()
        block.add_instruction_meas([('m1', 0., 1.)])
        block.add_instruction_exec(wf)

        awg1 = DummyAWG()
        awg2 = DummyAWG()
        awg3 = DummyAWG()

        dac1 = DummyDAC()
        dac2 = DummyDAC()

        setup = HardwareSetup()

        setup.set_channel('A', PlaybackChannel(awg1, 0))
        setup.set_channel('B', MarkerChannel(awg2, 0))
        setup.set_channel('C', MarkerChannel(awg3, 0))

        setup.set_measurement('m1', MeasurementMask(dac1, 'DAC_1'))
        setup.set_measurement('m2', MeasurementMask(dac2, 'DAC_2'))

        class ProgStart:
            def __init__(self):
                self.was_started = False

            def __call__(self):
                self.was_started = True

        program_started = ProgStart()

        setup.register_program('test', block, run_callback=program_started)

        self.assertIsNone(awg1._armed)
        self.assertIsNone(awg2._armed)
        self.assertIsNone(awg3._armed)
        self.assertIsNone(dac1._armed_program)
        self.assertIsNone(dac2._armed_program)

        setup.run_program('test')

        self.assertEqual(awg1._armed, 'test')
        self.assertEqual(awg2._armed, 'test')
        self.assertIsNone(awg3._armed)
        self.assertEqual(dac1._armed_program, 'test')
        self.assertIsNone(dac2._armed_program)

        self.assertTrue(program_started.was_started)
Esempio n. 2
0
    def test_remove_program(self):
        wf_1 = DummyWaveform(duration=1.1, defined_channels={'A', 'B'})
        wf_2 = DummyWaveform(duration=1.1, defined_channels={'A', 'C'})

        block_1 = InstructionBlock()
        block_2 = InstructionBlock()

        block_1.add_instruction_meas([('m1', 0., 1.)])
        block_1.add_instruction_exec(wf_1)

        block_2.add_instruction_meas([('m2', 0., 1.)])
        block_2.add_instruction_exec(wf_2)

        awg1 = DummyAWG()
        awg2 = DummyAWG()
        awg3 = DummyAWG()

        dac1 = DummyDAC()
        dac2 = DummyDAC()

        setup = HardwareSetup()

        setup.set_channel('A', PlaybackChannel(awg1, 0))
        setup.set_channel('B', MarkerChannel(awg2, 0))
        setup.set_channel('C', MarkerChannel(awg3, 0))

        setup.set_measurement('m1', MeasurementMask(dac1, 'DAC_1'))
        setup.set_measurement('m2', MeasurementMask(dac2, 'DAC_2'))

        setup.register_program('test_1', block_1)

        setup.register_program('test_2', block_2)

        setup.arm_program('test_1')

        setup.remove_program('test_1')

        self.assertEqual(setup.registered_programs.keys(), {'test_2'})

        self.assertIsNone(awg1._armed)
        self.assertIsNone(awg2._armed)