Esempio n. 1
0
    def test_set_channel(self):
        awg1 = DummyAWG()
        awg2 = DummyAWG(num_channels=4)

        setup = HardwareSetup()

        setup.set_channel('A', PlaybackChannel(awg1, 0))
        setup.set_channel('B', PlaybackChannel(awg2, 0))
        self.assertEqual(
            setup.registered_channels(),
            dict(A={PlaybackChannel(awg1, 0)}, B={PlaybackChannel(awg2, 0)}))

        with self.assertRaises(ValueError):
            setup.set_channel('C', PlaybackChannel(awg1, 0))

        with self.assertWarns(DeprecationWarning):
            setup.set_channel('A', PlaybackChannel(awg2, 1), True)

        self.assertEqual(
            setup.registered_channels(),
            dict(A={PlaybackChannel(awg2, 1),
                    PlaybackChannel(awg1, 0)},
                 B={PlaybackChannel(awg2, 0)}))

        setup.set_channel('A',
                          {PlaybackChannel(awg2, 3),
                           PlaybackChannel(awg2, 2)})
        self.assertEqual(
            setup.registered_channels(),
            dict(A={PlaybackChannel(awg2, 3),
                    PlaybackChannel(awg2, 2)},
                 B={PlaybackChannel(awg2, 0)}))
Esempio n. 2
0
    def test_rm_channel(self):
        awg1 = DummyAWG()
        awg2 = DummyAWG(num_channels=2)

        setup = HardwareSetup()

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

        with self.assertRaises(KeyError):
            setup.rm_channel('b')
        setup.rm_channel('B')

        self.assertEqual(setup.registered_channels(),
                         dict(A={PlaybackChannel(awg1, 0)}))