Skip to content

Commit 1d050ff

Browse files
Provide warning for shutter task.
Found with @Johnhaug223 - It seems as if the port/sample size is too small, it throws an error. Not 100% if this is the source of the problem, but changing the port did fix it.
1 parent d33401d commit 1d050ff

File tree

1 file changed

+25
-5
lines changed
  • src/navigate/model/devices/shutter

1 file changed

+25
-5
lines changed

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

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __init__(self, microscope_name, device_connection, configuration):
7676
self.shutter_task.do_channels.add_do_chan(
7777
shutter_channel, line_grouping=LineGrouping.CHAN_FOR_ALL_LINES
7878
)
79-
self.shutter_task.write(self.shutter_state, auto_start=True)
79+
self.open_shutter()
8080

8181
def __del__(self):
8282
"""Close the ShutterTTL at exit."""
@@ -86,14 +86,34 @@ def open_shutter(self):
8686
"""Open the shutter"""
8787
#: bool: Shutter state
8888
self.shutter_state = True
89-
self.shutter_task.write(self.shutter_state, auto_start=True)
90-
logger.debug("ShutterTTL - Shutter opened")
89+
try:
90+
self.shutter_task.write(self.shutter_state, auto_start=True)
91+
logger.debug("ShutterTTL - Shutter opened")
92+
except nidaqmx.errors.DaqError as e:
93+
print(
94+
"Warning, the shutter did not open. Check the hardware "
95+
"specifications. Some NI devices (e.g.PCIe-6738) have "
96+
"port/sample size limitations. If the port/sample size is "
97+
"exceeded, the shutter will not open. We recommend trying a "
98+
"different port."
99+
)
100+
logger.debug(e)
91101

92102
def close_shutter(self):
93103
"""Close the shutter"""
94104
self.shutter_state = False
95-
self.shutter_task.write(self.shutter_state, auto_start=True)
96-
logger.debug("ShutterTTL - The shutter is closed")
105+
try:
106+
self.shutter_task.write(self.shutter_state, auto_start=True)
107+
logger.debug("ShutterTTL - The shutter is closed")
108+
except nidaqmx.errors.DaqError as e:
109+
print(
110+
"Warning, the shutter did not close. Check the hardware "
111+
"specifications. Some NI devices (e.g.PCIe-6738) have "
112+
"port/sample size limitations. If the port/sample size is "
113+
"exceeded, the shutter will not open. We recommend trying a "
114+
"different port."
115+
)
116+
logger.debug(e)
97117

98118
@property
99119
def state(self):

0 commit comments

Comments
 (0)