Skip to content

Commit 18214cb

Browse files
zaberstage: Change connection string format to "device <n>"
1 parent c471703 commit 18214cb

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

ZaberStageController/blacs_tabs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#####################################################################
1313

1414
from blacs.device_base_class import DeviceTab
15-
from .utils import get_stage_number
15+
from .utils import get_device_number
1616

1717
class ZaberStageControllerTab(DeviceTab):
1818
def initialise_GUI(self):
@@ -39,7 +39,7 @@ def initialise_GUI(self):
3939
'decimals': self.base_decimals,
4040
}
4141
# Sort by stage number:
42-
ao_prop = {c: ao_prop[c] for c in sorted(ao_prop, key=get_stage_number)}
42+
ao_prop = {c: ao_prop[c] for c in sorted(ao_prop, key=get_device_number)}
4343
# Create the output objects
4444
self.create_analog_outputs(ao_prop)
4545
# Create widgets for output objects
@@ -48,8 +48,8 @@ def initialise_GUI(self):
4848
self.auto_place_widgets(("Zaber Stages", ao_widgets))
4949

5050
# Set the capabilities of this device
51-
self.supports_remote_value_check(False) # TODO: Implement this if supported by hardware
52-
self.supports_smart_programming(False) #TODO: Implement smart programming
51+
self.supports_remote_value_check(False) # TODO: Implement
52+
self.supports_smart_programming(False) #TODO: Implement
5353

5454
def initialise_workers(self):
5555
# Create and set the primary worker

ZaberStageController/blacs_workers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from labscript_utils import dedent
1717
import labscript_utils.h5_lock, h5py
1818

19-
from .utils import get_stage_number
19+
from .utils import get_device_number
2020

2121
class MockZaberInterface(object):
2222
def __init__(self, port):
@@ -65,7 +65,7 @@ def init(self):
6565

6666
def program_manual(self, values):
6767
for connection, value in values.items():
68-
stage_number = get_stage_number(connection)
68+
stage_number = get_device_number(connection)
6969
self.controller.move(stage_number, int(round(value)))
7070
#TODO: return actual position of the zaber stage. Are they readable? Check API
7171
return values

ZaberStageController/labscript_devices.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from labscript import StaticAnalogQuantity, IntermediateDevice, set_passed_properties
1414
import numpy as np
1515

16-
from .utils import get_stage_number
16+
from .utils import get_device_number
1717

1818
# Base class for stages:
1919
class ZaberStage(StaticAnalogQuantity):
@@ -58,13 +58,13 @@ def __init__(self, name, com_port="", mock=False):
5858

5959
def add_device(self, device):
6060
# Error-check the connection string:
61-
_ = get_stage_number(device.connection)
61+
_ = get_device_number(device.connection)
6262
IntermediateDevice.add_device(self, device)
6363

6464
def generate_code(self, hdf5_file):
6565
IntermediateDevice.generate_code(self, hdf5_file)
6666
stages = {stage.connection: stage for stage in self.child_devices}
67-
connections = sorted(stages, key=get_stage_number)
67+
connections = sorted(stages, key=get_device_number)
6868
dtypes = [(connection, int) for connection in connections]
6969
static_value_table = np.empty(1, dtype=dtypes)
7070
for connection, stage in stages.items():

ZaberStageController/utils.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,16 @@
1414
from labscript_utils import dedent
1515

1616

17-
def get_stage_number(connection_str):
18-
"""Return the integer stage number from the connection string or raise ValueError if
19-
the connection string is not in the format "stage <n>" with positive n."""
17+
def get_device_number(connection_str):
18+
"""Return the integer device number from the connection string or raise ValueError
19+
if the connection string is not in the format "device <n>" with positive n."""
2020
try:
2121
prefix, num = connection_str.split(' ')
2222
num = int(num)
23-
if prefix != 'stage' or num <= 0:
23+
if prefix != 'device' or num <= 0:
2424
raise ValueError
2525
except (TypeError, ValueError):
26-
msg = f"""Connection string '{connection_str}' not in required format 'stage
26+
msg = f"""Connection string '{connection_str}' not in required format 'device
2727
<n>' with n > 0"""
2828
raise ValueError(dedent(msg)) from None
2929
return num
30-
31-
32-
if __name__ == '__main__':
33-
assert get_stage_number('stage 1') == 1
34-
# get_stage_number('stage ')
35-
get_stage_number(None)

0 commit comments

Comments
 (0)