2020-01-21 16:13:04 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2018-05-18 22:52:53 +08:00
|
|
|
import sys
|
2018-12-05 21:06:45 +08:00
|
|
|
import os
|
2018-05-18 22:52:53 +08:00
|
|
|
import select
|
|
|
|
|
|
|
|
from artiq.experiment import *
|
2019-11-05 18:56:10 +08:00
|
|
|
from artiq.coredevice.ad9910 import AD9910, SyncDataEeprom
|
2020-01-21 16:13:04 +08:00
|
|
|
from artiq.master.databases import DeviceDB
|
|
|
|
from artiq.master.worker_db import DeviceManager
|
|
|
|
|
2018-05-18 22:52:53 +08:00
|
|
|
|
2018-12-05 21:06:45 +08:00
|
|
|
if os.name == "nt":
|
|
|
|
import msvcrt
|
|
|
|
|
2018-05-18 22:52:53 +08:00
|
|
|
|
|
|
|
def chunker(seq, size):
|
|
|
|
res = []
|
|
|
|
for el in seq:
|
|
|
|
res.append(el)
|
|
|
|
if len(res) == size:
|
|
|
|
yield res
|
|
|
|
res = []
|
|
|
|
if res:
|
|
|
|
yield res
|
|
|
|
|
|
|
|
|
|
|
|
def is_enter_pressed() -> TBool:
|
2018-12-05 21:06:45 +08:00
|
|
|
if os.name == "nt":
|
|
|
|
if msvcrt.kbhit() and msvcrt.getch() == b"\r":
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
2018-05-18 22:52:53 +08:00
|
|
|
else:
|
2018-12-05 21:06:45 +08:00
|
|
|
if select.select([sys.stdin, ], [], [], 0.0)[0]:
|
|
|
|
sys.stdin.read(1)
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
2018-05-18 22:52:53 +08:00
|
|
|
|
|
|
|
|
2020-01-21 16:13:04 +08:00
|
|
|
class SinaraTester(EnvExperiment):
|
2018-05-18 22:52:53 +08:00
|
|
|
def build(self):
|
|
|
|
self.setattr_device("core")
|
|
|
|
|
|
|
|
self.leds = dict()
|
|
|
|
self.ttl_outs = dict()
|
|
|
|
self.ttl_ins = dict()
|
2018-05-18 23:18:03 +08:00
|
|
|
self.urukul_cplds = dict()
|
|
|
|
self.urukuls = dict()
|
2018-05-29 22:36:42 +08:00
|
|
|
self.samplers = dict()
|
|
|
|
self.zotinos = dict()
|
2020-06-11 13:44:40 +08:00
|
|
|
self.fastinos = dict()
|
2018-08-08 18:43:44 +08:00
|
|
|
self.grabbers = dict()
|
2018-05-18 22:52:53 +08:00
|
|
|
|
|
|
|
ddb = self.get_device_db()
|
|
|
|
for name, desc in ddb.items():
|
|
|
|
if isinstance(desc, dict) and desc["type"] == "local":
|
|
|
|
module, cls = desc["module"], desc["class"]
|
|
|
|
if (module, cls) == ("artiq.coredevice.ttl", "TTLOut"):
|
|
|
|
dev = self.get_device(name)
|
|
|
|
if "led" in name: # guess
|
|
|
|
self.leds[name] = dev
|
|
|
|
else:
|
|
|
|
self.ttl_outs[name] = dev
|
|
|
|
elif (module, cls) == ("artiq.coredevice.ttl", "TTLInOut"):
|
|
|
|
self.ttl_ins[name] = self.get_device(name)
|
2018-05-18 23:18:03 +08:00
|
|
|
elif (module, cls) == ("artiq.coredevice.urukul", "CPLD"):
|
|
|
|
self.urukul_cplds[name] = self.get_device(name)
|
|
|
|
elif (module, cls) == ("artiq.coredevice.ad9910", "AD9910"):
|
|
|
|
self.urukuls[name] = self.get_device(name)
|
2018-07-06 15:43:25 +08:00
|
|
|
elif (module, cls) == ("artiq.coredevice.ad9912", "AD9912"):
|
|
|
|
self.urukuls[name] = self.get_device(name)
|
2018-05-29 22:36:42 +08:00
|
|
|
elif (module, cls) == ("artiq.coredevice.sampler", "Sampler"):
|
|
|
|
self.samplers[name] = self.get_device(name)
|
|
|
|
elif (module, cls) == ("artiq.coredevice.zotino", "Zotino"):
|
|
|
|
self.zotinos[name] = self.get_device(name)
|
2020-06-11 13:44:40 +08:00
|
|
|
elif (module, cls) == ("artiq.coredevice.fastino", "Fastino"):
|
|
|
|
self.fastinos[name] = self.get_device(name)
|
2018-08-08 18:43:44 +08:00
|
|
|
elif (module, cls) == ("artiq.coredevice.grabber", "Grabber"):
|
|
|
|
self.grabbers[name] = self.get_device(name)
|
2018-05-18 22:52:53 +08:00
|
|
|
|
2018-05-29 22:36:42 +08:00
|
|
|
# Remove Urukul, Sampler and Zotino control signals
|
|
|
|
# from TTL outs (tested separately)
|
2018-05-18 22:52:53 +08:00
|
|
|
ddb = self.get_device_db()
|
|
|
|
for name, desc in ddb.items():
|
|
|
|
if isinstance(desc, dict) and desc["type"] == "local":
|
|
|
|
module, cls = desc["module"], desc["class"]
|
|
|
|
if ((module, cls) == ("artiq.coredevice.ad9910", "AD9910")
|
|
|
|
or (module, cls) == ("artiq.coredevice.ad9912", "AD9912")):
|
2019-06-13 20:19:24 +08:00
|
|
|
if "sw_device" in desc["arguments"]:
|
|
|
|
sw_device = desc["arguments"]["sw_device"]
|
|
|
|
del self.ttl_outs[sw_device]
|
2018-05-29 22:36:42 +08:00
|
|
|
elif (module, cls) == ("artiq.coredevice.urukul", "CPLD"):
|
2018-05-18 22:52:53 +08:00
|
|
|
io_update_device = desc["arguments"]["io_update_device"]
|
|
|
|
del self.ttl_outs[io_update_device]
|
2018-05-29 22:36:42 +08:00
|
|
|
elif (module, cls) == ("artiq.coredevice.sampler", "Sampler"):
|
|
|
|
cnv_device = desc["arguments"]["cnv_device"]
|
|
|
|
del self.ttl_outs[cnv_device]
|
|
|
|
elif (module, cls) == ("artiq.coredevice.zotino", "Zotino"):
|
|
|
|
ldac_device = desc["arguments"]["ldac_device"]
|
|
|
|
clr_device = desc["arguments"]["clr_device"]
|
|
|
|
del self.ttl_outs[ldac_device]
|
|
|
|
del self.ttl_outs[clr_device]
|
2018-05-18 22:52:53 +08:00
|
|
|
|
|
|
|
# Sort everything by RTIO channel number
|
|
|
|
self.leds = sorted(self.leds.items(), key=lambda x: x[1].channel)
|
|
|
|
self.ttl_outs = sorted(self.ttl_outs.items(), key=lambda x: x[1].channel)
|
|
|
|
self.ttl_ins = sorted(self.ttl_ins.items(), key=lambda x: x[1].channel)
|
2019-06-13 20:19:24 +08:00
|
|
|
self.urukuls = sorted(self.urukuls.items(), key=lambda x: (x[1].cpld.bus.channel, x[1].chip_select))
|
2018-05-29 22:36:42 +08:00
|
|
|
self.samplers = sorted(self.samplers.items(), key=lambda x: x[1].cnv.channel)
|
|
|
|
self.zotinos = sorted(self.zotinos.items(), key=lambda x: x[1].bus.channel)
|
2020-06-11 13:44:40 +08:00
|
|
|
self.fastinos = sorted(self.fastinos.items(), key=lambda x: x[1].channel)
|
2018-08-08 18:43:44 +08:00
|
|
|
self.grabbers = sorted(self.grabbers.items(), key=lambda x: x[1].channel_base)
|
2018-05-18 22:52:53 +08:00
|
|
|
|
|
|
|
@kernel
|
|
|
|
def test_led(self, led):
|
|
|
|
while not is_enter_pressed():
|
|
|
|
self.core.break_realtime()
|
|
|
|
# do not fill the FIFOs too much to avoid long response times
|
|
|
|
t = now_mu() - self.core.seconds_to_mu(0.2)
|
|
|
|
while self.core.get_rtio_counter_mu() < t:
|
|
|
|
pass
|
|
|
|
for i in range(3):
|
|
|
|
led.pulse(100*ms)
|
|
|
|
delay(100*ms)
|
|
|
|
|
|
|
|
def test_leds(self):
|
|
|
|
print("*** Testing LEDs.")
|
|
|
|
print("Check for blinking. Press ENTER when done.")
|
|
|
|
|
|
|
|
for led_name, led_dev in self.leds:
|
|
|
|
print("Testing LED: {}".format(led_name))
|
|
|
|
self.test_led(led_dev)
|
|
|
|
|
|
|
|
@kernel
|
|
|
|
def test_ttl_out_chunk(self, ttl_chunk):
|
|
|
|
while not is_enter_pressed():
|
|
|
|
self.core.break_realtime()
|
|
|
|
for _ in range(50000):
|
|
|
|
i = 0
|
|
|
|
for ttl in ttl_chunk:
|
|
|
|
i += 1
|
|
|
|
for _ in range(i):
|
|
|
|
ttl.pulse(1*us)
|
|
|
|
delay(1*us)
|
|
|
|
delay(10*us)
|
|
|
|
|
|
|
|
def test_ttl_outs(self):
|
|
|
|
print("*** Testing TTL outputs.")
|
|
|
|
print("Outputs are tested in groups of 4. Touch each TTL connector")
|
|
|
|
print("with the oscilloscope probe tip, and check that the number of")
|
|
|
|
print("pulses corresponds to its number in the group.")
|
|
|
|
print("Press ENTER when done.")
|
|
|
|
|
2018-05-18 23:18:03 +08:00
|
|
|
for ttl_chunk in chunker(self.ttl_outs, 4):
|
2018-05-18 22:52:53 +08:00
|
|
|
print("Testing TTL outputs: {}.".format(", ".join(name for name, dev in ttl_chunk)))
|
|
|
|
self.test_ttl_out_chunk([dev for name, dev in ttl_chunk])
|
|
|
|
|
|
|
|
@kernel
|
|
|
|
def test_ttl_in(self, ttl_out, ttl_in):
|
|
|
|
n = 42
|
|
|
|
self.core.break_realtime()
|
|
|
|
with parallel:
|
|
|
|
ttl_in.gate_rising(1*ms)
|
|
|
|
with sequential:
|
|
|
|
delay(50*us)
|
|
|
|
for _ in range(n):
|
|
|
|
ttl_out.pulse(2*us)
|
|
|
|
delay(2*us)
|
2018-07-23 22:34:18 +08:00
|
|
|
return ttl_in.count(now_mu()) == n
|
2018-05-18 22:52:53 +08:00
|
|
|
|
|
|
|
def test_ttl_ins(self):
|
|
|
|
print("*** Testing TTL inputs.")
|
2018-09-24 17:19:28 +08:00
|
|
|
if not self.ttl_outs:
|
|
|
|
print("No TTL output channel available to use as stimulus.")
|
|
|
|
return
|
2019-05-07 16:58:00 +08:00
|
|
|
default_ttl_out_name, default_ttl_out_dev = next(iter(self.ttl_outs))
|
|
|
|
ttl_out_name = input("TTL device to use as stimulus (default: {}): ".format(default_ttl_out_name))
|
|
|
|
if ttl_out_name:
|
|
|
|
ttl_out_dev = self.get_device(ttl_out_name)
|
|
|
|
else:
|
|
|
|
ttl_out_name = default_ttl_out_name
|
|
|
|
ttl_out_dev = default_ttl_out_dev
|
2018-05-18 22:52:53 +08:00
|
|
|
for ttl_in_name, ttl_in_dev in self.ttl_ins:
|
|
|
|
print("Connect {} to {}. Press ENTER when done."
|
|
|
|
.format(ttl_out_name, ttl_in_name))
|
|
|
|
input()
|
|
|
|
if self.test_ttl_in(ttl_out_dev, ttl_in_dev):
|
|
|
|
print("PASSED")
|
|
|
|
else:
|
|
|
|
print("FAILED")
|
|
|
|
|
2018-05-18 23:18:03 +08:00
|
|
|
@kernel
|
|
|
|
def init_urukul(self, cpld):
|
|
|
|
self.core.break_realtime()
|
|
|
|
cpld.init()
|
|
|
|
|
2019-03-13 15:36:05 +08:00
|
|
|
@kernel
|
|
|
|
def calibrate_urukul(self, channel):
|
2019-09-11 15:15:07 +08:00
|
|
|
self.core.break_realtime()
|
|
|
|
channel.init()
|
2019-03-13 15:36:05 +08:00
|
|
|
self.core.break_realtime()
|
|
|
|
sync_delay_seed, _ = channel.tune_sync_delay()
|
|
|
|
self.core.break_realtime()
|
|
|
|
io_update_delay = channel.tune_io_update_delay()
|
|
|
|
return sync_delay_seed, io_update_delay
|
|
|
|
|
2018-05-18 23:18:03 +08:00
|
|
|
@kernel
|
|
|
|
def setup_urukul(self, channel, frequency):
|
|
|
|
self.core.break_realtime()
|
2018-05-28 14:22:06 +08:00
|
|
|
channel.init()
|
2018-05-18 23:18:03 +08:00
|
|
|
channel.set(frequency*MHz)
|
2019-06-13 20:19:24 +08:00
|
|
|
channel.cfg_sw(1)
|
2018-05-18 23:18:03 +08:00
|
|
|
channel.set_att(6.)
|
|
|
|
|
2018-05-18 23:48:29 +08:00
|
|
|
@kernel
|
2019-06-14 18:54:00 +08:00
|
|
|
def cfg_sw_off_urukul(self, channel):
|
2019-06-13 20:19:24 +08:00
|
|
|
self.core.break_realtime()
|
2019-06-14 18:54:00 +08:00
|
|
|
channel.cfg_sw(0)
|
|
|
|
|
|
|
|
@kernel
|
|
|
|
def rf_switch_wave(self, channels):
|
2018-05-18 23:48:29 +08:00
|
|
|
while not is_enter_pressed():
|
|
|
|
self.core.break_realtime()
|
|
|
|
# do not fill the FIFOs too much to avoid long response times
|
|
|
|
t = now_mu() - self.core.seconds_to_mu(0.2)
|
|
|
|
while self.core.get_rtio_counter_mu() < t:
|
|
|
|
pass
|
|
|
|
for channel in channels:
|
2018-07-06 15:43:38 +08:00
|
|
|
channel.pulse(100*ms)
|
2018-05-18 23:48:29 +08:00
|
|
|
delay(100*ms)
|
|
|
|
|
2018-05-18 23:18:03 +08:00
|
|
|
# We assume that RTIO channels for switches are grouped by card.
|
|
|
|
def test_urukuls(self):
|
|
|
|
print("*** Testing Urukul DDSes.")
|
2018-05-18 23:48:29 +08:00
|
|
|
|
2018-05-18 23:18:03 +08:00
|
|
|
print("Initializing CPLDs...")
|
|
|
|
for name, cpld in sorted(self.urukul_cplds.items(), key=lambda x: x[0]):
|
|
|
|
print(name + "...")
|
|
|
|
self.init_urukul(cpld)
|
|
|
|
print("...done")
|
2018-05-18 23:48:29 +08:00
|
|
|
|
2019-03-13 15:36:05 +08:00
|
|
|
print("Calibrating inter-device synchronization...")
|
|
|
|
for channel_name, channel_dev in self.urukuls:
|
2019-03-15 17:13:29 +08:00
|
|
|
if (not isinstance(channel_dev, AD9910) or
|
2019-11-05 18:56:10 +08:00
|
|
|
not isinstance(channel_dev.sync_data, SyncDataEeprom)):
|
|
|
|
print("{}\tno EEPROM synchronization".format(channel_name))
|
2019-03-13 15:36:05 +08:00
|
|
|
else:
|
2019-11-05 18:56:10 +08:00
|
|
|
eeprom = channel_dev.sync_data.eeprom_device
|
|
|
|
offset = channel_dev.sync_data.eeprom_offset
|
2019-03-13 15:36:05 +08:00
|
|
|
sync_delay_seed, io_update_delay = self.calibrate_urukul(channel_dev)
|
|
|
|
print("{}\t{} {}".format(channel_name, sync_delay_seed, io_update_delay))
|
|
|
|
eeprom_word = (sync_delay_seed << 24) | (io_update_delay << 16)
|
|
|
|
eeprom.write_i32(offset, eeprom_word)
|
|
|
|
print("...done")
|
|
|
|
|
2018-05-18 23:18:03 +08:00
|
|
|
print("Frequencies:")
|
|
|
|
for card_n, channels in enumerate(chunker(self.urukuls, 4)):
|
|
|
|
for channel_n, (channel_name, channel_dev) in enumerate(channels):
|
|
|
|
frequency = 10*(card_n + 1) + channel_n
|
|
|
|
print("{}\t{}MHz".format(channel_name, frequency))
|
|
|
|
self.setup_urukul(channel_dev, frequency)
|
|
|
|
print("Press ENTER when done.")
|
|
|
|
input()
|
|
|
|
|
2019-06-14 18:54:00 +08:00
|
|
|
sw = [channel_dev for channel_name, channel_dev in self.urukuls if hasattr(channel_dev, "sw")]
|
2019-06-13 20:19:24 +08:00
|
|
|
if sw:
|
|
|
|
print("Testing RF switch control. Press ENTER when done.")
|
2019-06-14 18:54:00 +08:00
|
|
|
for swi in sw:
|
|
|
|
self.cfg_sw_off_urukul(swi)
|
|
|
|
self.rf_switch_wave([swi.sw for swi in sw])
|
2018-05-18 23:48:29 +08:00
|
|
|
|
2018-05-29 22:36:42 +08:00
|
|
|
@kernel
|
|
|
|
def get_sampler_voltages(self, sampler, cb):
|
|
|
|
self.core.break_realtime()
|
|
|
|
sampler.init()
|
|
|
|
delay(5*ms)
|
|
|
|
for i in range(8):
|
|
|
|
sampler.set_gain_mu(i, 0)
|
|
|
|
delay(100*us)
|
|
|
|
smp = [0.0]*8
|
|
|
|
sampler.sample(smp)
|
|
|
|
cb(smp)
|
|
|
|
|
|
|
|
def test_samplers(self):
|
|
|
|
print("*** Testing Sampler ADCs.")
|
|
|
|
for card_name, card_dev in self.samplers:
|
|
|
|
print("Testing: ", card_name)
|
|
|
|
|
|
|
|
for channel in range(8):
|
|
|
|
print("Apply 1.5V to channel {}. Press ENTER when done.".format(channel))
|
|
|
|
input()
|
|
|
|
|
|
|
|
voltages = []
|
|
|
|
def setv(x):
|
|
|
|
nonlocal voltages
|
|
|
|
voltages = x
|
|
|
|
self.get_sampler_voltages(card_dev, setv)
|
|
|
|
|
|
|
|
passed = True
|
|
|
|
for n, voltage in enumerate(voltages):
|
|
|
|
if n == channel:
|
|
|
|
if abs(voltage - 1.5) > 0.2:
|
|
|
|
passed = False
|
|
|
|
else:
|
|
|
|
if abs(voltage) > 0.2:
|
|
|
|
passed = False
|
|
|
|
if passed:
|
|
|
|
print("PASSED")
|
|
|
|
else:
|
|
|
|
print("FAILED")
|
|
|
|
print(" ".join(["{:.1f}".format(x) for x in voltages]))
|
|
|
|
|
|
|
|
@kernel
|
|
|
|
def set_zotino_voltages(self, zotino, voltages):
|
|
|
|
self.core.break_realtime()
|
|
|
|
zotino.init()
|
2018-06-01 21:06:52 +08:00
|
|
|
delay(200*us)
|
2018-05-29 22:36:42 +08:00
|
|
|
i = 0
|
|
|
|
for voltage in voltages:
|
|
|
|
zotino.write_dac(i, voltage)
|
|
|
|
delay(100*us)
|
|
|
|
i += 1
|
|
|
|
zotino.load()
|
|
|
|
|
2020-06-11 15:48:21 +08:00
|
|
|
@kernel
|
|
|
|
def zotinos_led_wave(self, zotinos):
|
|
|
|
while not is_enter_pressed():
|
|
|
|
self.core.break_realtime()
|
|
|
|
# do not fill the FIFOs too much to avoid long response times
|
|
|
|
t = now_mu() - self.core.seconds_to_mu(0.2)
|
|
|
|
while self.core.get_rtio_counter_mu() < t:
|
|
|
|
pass
|
|
|
|
for zotino in zotinos:
|
|
|
|
for i in range(8):
|
|
|
|
zotino.set_leds(1 << i)
|
|
|
|
delay(100*ms)
|
|
|
|
zotino.set_leds(0)
|
|
|
|
delay(100*ms)
|
|
|
|
|
2018-05-29 22:36:42 +08:00
|
|
|
def test_zotinos(self):
|
2020-06-11 15:48:21 +08:00
|
|
|
print("*** Testing Zotino DACs and USER LEDs.")
|
2019-06-21 16:00:10 +08:00
|
|
|
print("Voltages:")
|
|
|
|
for card_n, (card_name, card_dev) in enumerate(self.zotinos):
|
kasli_tester/zotino: always alternate voltage sign
Before the voltages on a second Zotino would start 2.1, 1.9, 2.2, 1.8
..., 3.6, 0.4 and overlap with the voltages on the first.
Now the voltages are 2.1, -2.1, 2.2, -2.2, ..., 3.6, -3.6 which allows
quick identification of card/channel and easy prediction when deploying.
2019-08-06 23:37:46 +08:00
|
|
|
voltages = [(-1)**i*(2.*card_n + .1*(i//2 + 1)) for i in range(32)]
|
2019-06-21 16:00:10 +08:00
|
|
|
print(card_name, " ".join(["{:.1f}".format(x) for x in voltages]))
|
|
|
|
self.set_zotino_voltages(card_dev, voltages)
|
|
|
|
print("Press ENTER when done.")
|
2020-06-11 15:48:21 +08:00
|
|
|
# Test switching on/off USR_LEDs at the same time
|
|
|
|
self.zotinos_led_wave(
|
|
|
|
[card_dev for _, (__, card_dev) in enumerate(self.zotinos)]
|
|
|
|
)
|
2018-05-29 22:36:42 +08:00
|
|
|
|
2020-06-11 13:44:40 +08:00
|
|
|
@kernel
|
|
|
|
def set_fastino_voltages(self, fastino, voltages):
|
|
|
|
self.core.break_realtime()
|
|
|
|
fastino.init()
|
|
|
|
delay(200*us)
|
|
|
|
i = 0
|
|
|
|
for voltage in voltages:
|
|
|
|
fastino.set_dac(i, voltage)
|
|
|
|
delay(100*us)
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
@kernel
|
|
|
|
def fastinos_led_wave(self, fastinos):
|
|
|
|
while not is_enter_pressed():
|
|
|
|
self.core.break_realtime()
|
|
|
|
# do not fill the FIFOs too much to avoid long response times
|
|
|
|
t = now_mu() - self.core.seconds_to_mu(0.2)
|
|
|
|
while self.core.get_rtio_counter_mu() < t:
|
|
|
|
pass
|
|
|
|
for fastino in fastinos:
|
|
|
|
for i in range(8):
|
|
|
|
fastino.set_leds(1 << i)
|
|
|
|
delay(100*ms)
|
|
|
|
fastino.set_leds(0)
|
|
|
|
delay(100*ms)
|
|
|
|
|
|
|
|
def test_fastinos(self):
|
|
|
|
print("*** Testing Fastino DACs and USER LEDs.")
|
|
|
|
print("Voltages:")
|
|
|
|
for card_n, (card_name, card_dev) in enumerate(self.fastinos):
|
|
|
|
voltages = [(-1)**i*(2.*card_n + .1*(i//2 + 1)) for i in range(32)]
|
|
|
|
print(card_name, " ".join(["{:.1f}".format(x) for x in voltages]))
|
|
|
|
self.set_fastino_voltages(card_dev, voltages)
|
|
|
|
print("Press ENTER when done.")
|
|
|
|
# Test switching on/off USR_LEDs at the same time
|
|
|
|
self.fastinos_led_wave(
|
|
|
|
[card_dev for _, (__, card_dev) in enumerate(self.fastinos)]
|
|
|
|
)
|
|
|
|
|
2018-08-08 18:43:44 +08:00
|
|
|
@kernel
|
|
|
|
def grabber_capture(self, card_dev, rois):
|
|
|
|
self.core.break_realtime()
|
2018-09-04 18:59:19 +08:00
|
|
|
delay(100*us)
|
2018-08-08 18:43:44 +08:00
|
|
|
mask = 0
|
|
|
|
for i in range(len(rois)):
|
|
|
|
i = rois[i][0]
|
|
|
|
x0 = rois[i][1]
|
|
|
|
y0 = rois[i][2]
|
|
|
|
x1 = rois[i][3]
|
|
|
|
y1 = rois[i][4]
|
|
|
|
mask |= 1 << i
|
|
|
|
card_dev.setup_roi(i, x0, y0, x1, y1)
|
|
|
|
card_dev.gate_roi(mask)
|
|
|
|
n = [0]*len(rois)
|
|
|
|
card_dev.input_mu(n)
|
|
|
|
self.core.break_realtime()
|
|
|
|
card_dev.gate_roi(0)
|
2019-01-23 17:59:25 +08:00
|
|
|
print("ROI sums:", n)
|
2018-09-04 18:59:19 +08:00
|
|
|
|
|
|
|
def test_grabbers(self):
|
2019-06-21 16:00:10 +08:00
|
|
|
print("*** Testing Grabber Frame Grabbers.")
|
|
|
|
print("Activate the camera's frame grabber output, type 'g', press "
|
|
|
|
"ENTER, and trigger the camera.")
|
|
|
|
print("Just press ENTER to skip the test.")
|
|
|
|
if input().strip().lower() != "g":
|
|
|
|
print("skipping...")
|
|
|
|
return
|
|
|
|
rois = [[0, 0, 0, 2, 2], [1, 0, 0, 2048, 2048]]
|
|
|
|
print("ROIs:", rois)
|
|
|
|
for card_n, (card_name, card_dev) in enumerate(self.grabbers):
|
|
|
|
print(card_name)
|
|
|
|
self.grabber_capture(card_dev, rois)
|
2018-08-08 18:43:44 +08:00
|
|
|
|
2018-05-18 22:52:53 +08:00
|
|
|
def run(self):
|
2020-01-21 16:13:04 +08:00
|
|
|
print("****** Sinara system tester ******")
|
2018-05-18 22:52:53 +08:00
|
|
|
print("")
|
2018-05-21 15:35:29 +08:00
|
|
|
self.core.reset()
|
2019-06-21 16:00:10 +08:00
|
|
|
if self.leds:
|
|
|
|
self.test_leds()
|
|
|
|
if self.ttl_outs:
|
|
|
|
self.test_ttl_outs()
|
|
|
|
if self.ttl_ins:
|
|
|
|
self.test_ttl_ins()
|
|
|
|
if self.urukuls:
|
|
|
|
self.test_urukuls()
|
|
|
|
if self.samplers:
|
|
|
|
self.test_samplers()
|
|
|
|
if self.zotinos:
|
|
|
|
self.test_zotinos()
|
2020-06-11 13:44:40 +08:00
|
|
|
if self.fastinos:
|
|
|
|
self.test_fastinos()
|
2019-06-21 16:00:10 +08:00
|
|
|
if self.grabbers:
|
|
|
|
self.test_grabbers()
|
2020-01-21 16:13:04 +08:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2020-01-31 10:26:58 +08:00
|
|
|
device_mgr = DeviceManager(DeviceDB("device_db.py"))
|
2020-01-21 16:13:04 +08:00
|
|
|
try:
|
|
|
|
experiment = SinaraTester((device_mgr, None, None, None))
|
|
|
|
experiment.prepare()
|
|
|
|
experiment.run()
|
|
|
|
experiment.analyze()
|
|
|
|
finally:
|
|
|
|
device_mgr.close_devices()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|