Skip to content

Commit c6d188d

Browse files
Raises numpydoc.
Raising numpydoc and code formatter...
1 parent 92995fc commit c6d188d

File tree

2 files changed

+77
-46
lines changed

2 files changed

+77
-46
lines changed

src/navigate/model/devices/APIs/asi/asi_tiger_controller.py

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,9 @@ def set_speed_as_percent_max(self, pct: float) -> None:
666666
Percentage of the maximum speed
667667
"""
668668
if self.default_axes_sequence is None:
669-
logger.error(f"{str(self)}, Default axes sequence is not set. "
670-
f"Cannot set speed.")
669+
logger.error(
670+
f"{str(self)}, Default axes sequence is not set. " f"Cannot set speed."
671+
)
671672
raise ASIException(
672673
"Unable to query system for axis sequence. Cannot set speed."
673674
)
@@ -860,8 +861,8 @@ def send_filter_wheel_command(self, cmd: str) -> None:
860861
self.send_command(f"{cmd}\n")
861862
# print(f"Sent Command: {command.decode(encoding='ascii')}")
862863

863-
def select_filter_wheel(self, filter_wheel_number: int=0) -> None:
864-
""" Select the filter wheel, e.g., 0, 1...
864+
def select_filter_wheel(self, filter_wheel_number: int = 0) -> None:
865+
"""Select the filter wheel, e.g., 0, 1...
865866
866867
Sets the current filter wheel for later commands. Prompt shows the currently
867868
selected wheel, e.g., 0> is a result of FW 0 command. If the selected wheel is
@@ -882,7 +883,7 @@ def select_filter_wheel(self, filter_wheel_number: int=0) -> None:
882883
self.send_filter_wheel_command(f"FW {filter_wheel_number}")
883884
self.read_response()
884885

885-
def move_filter_wheel(self, filter_wheel_position: int=0) -> None:
886+
def move_filter_wheel(self, filter_wheel_position: int = 0) -> None:
886887
"""Move Filter Wheel
887888
888889
Move to filter position n , where n is a valid filter position.
@@ -904,7 +905,7 @@ def move_filter_wheel_to_home(self) -> None:
904905
self.send_filter_wheel_command("HO")
905906
self.read_response()
906907

907-
def change_filter_wheel_speed(self, speed: int=0) -> None:
908+
def change_filter_wheel_speed(self, speed: int = 0) -> None:
908909
"""Change the Filter-Wheel Speed
909910
910911
Selects a consistent set of preset acceleration and speed parameters.
@@ -925,7 +926,7 @@ def halt_filter_wheel(self) -> None:
925926
self.send_filter_wheel_command("HA")
926927
self.read_response()
927928

928-
def move_dichroic(self, dichroic_id: str, dichroic_position: int=0) -> None:
929+
def move_dichroic(self, dichroic_id: str, dichroic_position: int = 0) -> None:
929930
"""Move Dichroic Slider.
930931
931932
Move to dichroic position n , where n is a valid filter position.
@@ -952,36 +953,33 @@ def square_wave(self, on_time: int, delay_time: int) -> None:
952953
Delay time in quarter milliseconds
953954
"""
954955

955-
commands = ['CCA X=0',
956-
957-
'M E=2',
958-
'CCA Y=15',
959-
f'CCA Z={delay_time}',
960-
'CCB X=68 Y=192 Z=0',
961-
962-
'M E=3',
963-
'CCA Y=5',
964-
'CCB X=1 Y=66',
965-
966-
'M E=4',
967-
'CCA Y=14',
968-
f'CCA Z={on_time}',
969-
'CCB X=3 Y=192 Z=0',
970-
971-
'M E=33',
972-
'CCA Z=1',
973-
'M E=34',
974-
'CCA Z=2',
975-
'M E=35',
976-
'CCA Z=3',
977-
'M E=36',
978-
'CCA Z=4',
979-
980-
'M E=1',
981-
'CCA Z=1']
956+
commands = [
957+
"CCA X=0",
958+
"M E=2",
959+
"CCA Y=15",
960+
f"CCA Z={delay_time}",
961+
"CCB X=68 Y=192 Z=0",
962+
"M E=3",
963+
"CCA Y=5",
964+
"CCB X=1 Y=66",
965+
"M E=4",
966+
"CCA Y=14",
967+
f"CCA Z={on_time}",
968+
"CCB X=3 Y=192 Z=0",
969+
"M E=33",
970+
"CCA Z=1",
971+
"M E=34",
972+
"CCA Z=2",
973+
"M E=35",
974+
"CCA Z=3",
975+
"M E=36",
976+
"CCA Z=4",
977+
"M E=1",
978+
"CCA Z=1",
979+
]
982980
for command in commands:
983981
# Send data
984-
self.send_command(f'{command}\r')
982+
self.send_command(f"{command}\r")
985983
self.read_response()
986984

987985
def logic_card_on(self, axis: str) -> None:
@@ -994,9 +992,9 @@ def logic_card_on(self, axis: str) -> None:
994992
"""
995993

996994
axis = int(axis) + 32
997-
self.send_command(f'6 M E = {axis}\r')
995+
self.send_command(f"6 M E = {axis}\r")
998996
self.read_response()
999-
self.send_command(f'6 CCA Z=64\r')
997+
self.send_command(f"6 CCA Z=64\r")
1000998
self.read_response()
1001999

10021000
def logic_card_off(self, axis: str) -> None:
@@ -1008,7 +1006,7 @@ def logic_card_off(self, axis: str) -> None:
10081006
The axis of the logic card
10091007
"""
10101008
axis = int(axis) + 32
1011-
self.send_command(f'6 M E = {axis}\r')
1009+
self.send_command(f"6 M E = {axis}\r")
1010+
self.read_response()
1011+
self.send_command(f"6 CCA Z=0\r")
10121012
self.read_response()
1013-
self.send_command(f'6 CCA Z=0\r')
1014-
self.read_response()

src/navigate/model/devices/shutter/asi.py

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
p = __name__.split(".")[1]
4646
logger = logging.getLogger(p)
4747

48+
4849
@log_initialization
4950
class ASIShutter(ShutterBase, SerialDevice):
5051
"""ShutterTTL Class
@@ -74,13 +75,21 @@ def __init__(
7475
"""
7576
super().__init__(microscope_name, device_connection, configuration)
7677

78+
#: str: Address of the shutter, if applicable.
7779
self.address = address
7880

81+
#: TigerController: ASI Tiger Controller object.
7982
self.shutter = device_connection
8083

81-
self.axis = configuration["configuration"]["microscopes"][microscope_name]["shutter"]["hardware"]["axis"]
84+
#: str: Axis of the shutter.
85+
self.axis = configuration["configuration"]["microscopes"][microscope_name][
86+
"shutter"
87+
]["hardware"]["axis"]
8288

83-
self.port = configuration["configuration"]["microscopes"][microscope_name]["shutter"]["hardware"]["port"]
89+
#: str: Port for communicating with the shutter.
90+
self.port = configuration["configuration"]["microscopes"][microscope_name][
91+
"shutter"
92+
]["hardware"]["port"]
8493

8594
@classmethod
8695
def connect(cls, port, baudrate=115200, timeout=0.25):
@@ -109,7 +118,13 @@ def connect(cls, port, baudrate=115200, timeout=0.25):
109118
return tiger_controller
110119

111120
def __del__(self) -> None:
112-
"""Disconnect from the serial port."""
121+
"""Disconnect from the serial port.
122+
123+
Raises
124+
-------
125+
Exception
126+
If there is an error during the cleanup process.
127+
"""
113128
try:
114129
if self.shutter:
115130
self.shutter.disconnect_from_serial()
@@ -118,15 +133,27 @@ def __del__(self) -> None:
118133
logger.exception(f"Error during cleanup: {traceback.format_exc()}")
119134

120135
def open_shutter(self) -> None:
121-
"""Opens the shutter."""
136+
"""Opens the shutter.
137+
138+
Raises
139+
-------
140+
Exception
141+
If there is an error while trying to open the shutter.
142+
"""
122143
try:
123144
self.shutter.logic_card_on(self.axis)
124145
logger.debug("ASIShutter opened")
125146
except Exception as e:
126147
logger.exception(f"Shutter not open: {traceback.format_exc()}")
127148

128149
def close_shutter(self) -> None:
129-
"""Closes the shutter."""
150+
"""Closes the shutter.
151+
152+
Raises
153+
-------
154+
Exception
155+
If there is an error while trying to close the shutter.
156+
"""
130157
try:
131158
self.shutter.logic_card_off(self.axis)
132159
logger.debug("ASIShutter closed")
@@ -135,5 +162,11 @@ def close_shutter(self) -> None:
135162

136163
@property
137164
def state(self) -> bool:
138-
"""Get the state of the shutter."""
165+
"""Get the state of the shutter.
166+
167+
Returns
168+
-------
169+
bool:
170+
True if the shutter is open, False if it is closed.
171+
"""
139172
return self.shutter.get_axis_position(self.axis)

0 commit comments

Comments
 (0)