2015-02-19 02:33:25 +08:00
|
|
|
import unittest
|
2017-05-22 00:26:05 +08:00
|
|
|
import sys
|
2015-02-19 02:34:00 +08:00
|
|
|
|
2016-01-28 05:24:32 +08:00
|
|
|
from artiq.devices.lda.driver import Ldasim
|
2015-02-19 02:33:25 +08:00
|
|
|
from artiq.language.units import dB
|
2017-05-22 00:26:05 +08:00
|
|
|
from artiq.test.hardware_testbench import GenericControllerCase, ControllerCase
|
2015-02-19 02:33:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
class GenericLdaTest:
|
|
|
|
def test_attenuation(self):
|
2015-06-26 22:20:13 +08:00
|
|
|
step = self.cont.get_att_step_size()
|
|
|
|
attmax = self.cont.get_att_max()
|
|
|
|
test_vector = [i*step*dB for i in range(0, int(attmax*int(1/step)+1))]
|
2015-02-19 02:33:25 +08:00
|
|
|
for i in test_vector:
|
|
|
|
with self.subTest(i=i):
|
|
|
|
self.cont.set_attenuation(i)
|
2016-01-27 06:22:45 +08:00
|
|
|
j = self.cont.get_attenuation()
|
|
|
|
self.assertEqual(i, j)
|
2015-02-19 02:33:25 +08:00
|
|
|
|
|
|
|
|
2016-01-28 05:24:32 +08:00
|
|
|
class TestLda(ControllerCase, GenericLdaTest):
|
2016-01-28 09:45:08 +08:00
|
|
|
def setUp(self):
|
|
|
|
ControllerCase.setUp(self)
|
2016-01-29 06:31:01 +08:00
|
|
|
self.start_controller("lda")
|
2016-01-28 05:24:32 +08:00
|
|
|
self.cont = self.device_mgr.get("lda")
|
2015-02-19 02:33:25 +08:00
|
|
|
|
|
|
|
|
2017-05-22 00:26:05 +08:00
|
|
|
class TestLdaSim(GenericControllerCase, GenericLdaTest):
|
|
|
|
def get_device_db(self):
|
|
|
|
return {
|
|
|
|
"lda": {
|
|
|
|
"type": "controller",
|
|
|
|
"host": "::1",
|
|
|
|
"port": 3253,
|
|
|
|
"command": (sys.executable.replace("\\", "\\\\")
|
|
|
|
+ " -m artiq.frontend.aqctl_lda "
|
|
|
|
+ "-p {port} --simulation")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-19 02:33:25 +08:00
|
|
|
def setUp(self):
|
2017-05-22 00:26:05 +08:00
|
|
|
GenericControllerCase.setUp(self)
|
|
|
|
self.start_controller("lda")
|
|
|
|
self.cont = self.device_mgr.get("lda")
|