2015-02-19 02:33:25 +08:00
|
|
|
import unittest
|
|
|
|
import os
|
2015-02-19 02:34:00 +08:00
|
|
|
|
2015-02-19 02:33:25 +08:00
|
|
|
from artiq.devices.lda.driver import Lda, Ldasim
|
|
|
|
from artiq.language.units import dB
|
|
|
|
|
|
|
|
|
2015-04-02 16:20:02 +08:00
|
|
|
lda_serial = os.getenv("ARTIQ_LDA_SERIAL")
|
2015-02-19 02:33:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
class GenericLdaTest:
|
|
|
|
def test_attenuation(self):
|
|
|
|
step = self.cont.get_att_step_size().amount
|
|
|
|
max = self.cont.get_att_max().amount
|
|
|
|
test_vector = [i*step*dB for i in range(0, int(max*int(1/step)+1))]
|
|
|
|
for i in test_vector:
|
|
|
|
with self.subTest(i=i):
|
|
|
|
self.cont.set_attenuation(i)
|
|
|
|
self.assertEqual(i, self.cont.get_attenuation())
|
|
|
|
|
|
|
|
|
2015-04-02 16:20:02 +08:00
|
|
|
@unittest.skipUnless(lda_serial, "no hardware")
|
2015-02-19 02:33:25 +08:00
|
|
|
class TestLda(GenericLdaTest, unittest.TestCase):
|
|
|
|
def setUp(self):
|
2015-04-02 16:20:02 +08:00
|
|
|
product = os.getenv("ARTIQ_LDA_PRODUCT")
|
|
|
|
self.cont = Lda(serial=lda_serial, product=product)
|
2015-02-19 02:33:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
class TestLdaSim(GenericLdaTest, unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
self.cont = Ldasim()
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|