Skip to content

Commit

Permalink
Default output channel to last one, polish prompts
Browse files Browse the repository at this point in the history
If output channel is last, then there is one ports movement less

Signed-off-by: Egor Savkin <[email protected]>
  • Loading branch information
thomasfire committed Aug 9, 2024
1 parent a0347f1 commit 758c0ed
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions artiq/frontend/artiq_sinara_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def build(self):
self.leds = dict()
self.ttl_outs = dict()
self.ttl_ins = dict()
self.ttl_lvds_outs = dict()
self.ttl_lvds = dict()
self.ttl_lvds_ins = dict()
self.urukul_cplds = dict()
self.urukuls = dict()
Expand All @@ -76,7 +76,7 @@ def build(self):
if "led" in name: # guess
self.leds[name] = dev
elif "board" in desc and desc["board"] == "dio_lvds":
self.ttl_lvds_outs[name] = self.get_device(name)
self.ttl_lvds[name] = self.get_device(name)
else:
self.ttl_outs[name] = dev
elif (module, cls) == ("artiq.coredevice.ttl", "TTLInOut"):
Expand Down Expand Up @@ -163,7 +163,7 @@ def build(self):
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)
self.ttl_lvds_ins = sorted(self.ttl_lvds_ins.items(), key=lambda x: x[1].channel)
self.ttl_lvds_outs = sorted(self.ttl_lvds_outs.items(), key=lambda x: x[1].channel)
self.ttl_lvds = sorted(self.ttl_lvds.items(), key=lambda x: x[1].channel)
self.urukuls = sorted(self.urukuls.items(), key=lambda x: (x[1].cpld.bus.channel, x[1].chip_select))
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)
Expand Down Expand Up @@ -268,7 +268,7 @@ def devices_to_string(chunk):
else:
print("FAILED")

def test_ttl_lvds_outs(self):
def test_ttl_lvds(self):
def lower_bound_of_device_chunk(dev_list, dev_name, N):
dev_index = next(i for i, v in enumerate(dev_list) if v[0] == dev_name)
return dev_index - (dev_index % N)
Expand All @@ -279,10 +279,12 @@ def lower_bound_of_device_chunk(dev_list, dev_name, N):
print(f"No available input channels for testing. Skipping...")
return

ttl_in_index, ttl_out_index = 0, 0
ttl_in_index, ttl_out_index = 0, -1
default_ttl_in_name, _ = self.ttl_lvds_ins[ttl_in_index]
default_ttl_out_name, _ = self.ttl_lvds_outs[ttl_out_index]
default_ttl_out_name, _ = self.ttl_lvds[ttl_out_index]

print("LVDS TTL channels are tested in groups of 4.")
print("You can choose any channel within the group.")
ttl_in_name = input(f"TTL device to use as an input (default: {default_ttl_in_name}): ")
ttl_out_name = input(f"TTL device to use as an output (default: {default_ttl_out_name}): ")

Expand All @@ -292,18 +294,18 @@ def lower_bound_of_device_chunk(dev_list, dev_name, N):
ttl_out_name = default_ttl_out_name

ttl_in_index = lower_bound_of_device_chunk(self.ttl_lvds_ins, ttl_in_name, 4)
ttl_out_index = lower_bound_of_device_chunk(self.ttl_lvds_outs, ttl_out_name, 4)
ttl_out_index = lower_bound_of_device_chunk(self.ttl_lvds, ttl_out_name, 4)
ttl_in_static_chunk = self.ttl_lvds_ins[ttl_in_index: ttl_in_index + 4]
ttl_out_static_chunk = self.ttl_lvds_outs[ttl_out_index: ttl_out_index + 4]

print("LVDS TTL channels are tested in groups of 4.")
print("\nTesting output channels. Keep input group connected in the same slot, and cycle through all outputs.")
ttl_out_static_chunk = self.ttl_lvds[ttl_out_index: ttl_out_index + 4]

for ttl_out_moving_chunk in chunker(self.ttl_lvds_outs, 4):
print("\nTesting output channels. Keep input group connected in the same port, and cycle through all outputs.")
for ttl_out_moving_chunk in chunker(self.ttl_lvds, 4):
self.test_lvds_group(ttl_out_moving_chunk, ttl_in_static_chunk)

print("\nTesting input channels. Keep output group connected in the same slot, and cycle through all inputs.")
if len(self.ttl_lvds_ins) == 4:
return

print("\nTesting input channels. Keep output group connected in the same port, and cycle through all inputs.")
for ttl_in_moving_chunk in chunker(self.ttl_lvds_ins, 4):
if not ttl_in_moving_chunk == ttl_in_static_chunk:
self.test_lvds_group(ttl_out_static_chunk, ttl_in_moving_chunk)
Expand Down

0 comments on commit 758c0ed

Please sign in to comment.