Skip to content

Commit 4b8d4ed

Browse files
committed
Merge pull request #90 from dihm/NIDAQ_bugfix
Fix recent AI termination changes to work with DAQs that don't have analog inputs
1 parent c7dfc13 commit 4b8d4ed

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

labscript_devices/NI_DAQmx/labscript_devices.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -216,30 +216,35 @@ def __init__(
216216
self.num_AI = num_AI
217217
# special handling for AI termination configurations
218218
self.AI_term = AI_term
219-
if AI_term_cfg == None:
220-
# assume legacy configuration if none provided
221-
AI_term_cfg = {f'ai{i:d}': ['RSE'] for i in range(num_AI)}
222-
# warn user to update their local model specs
223-
msg = """Model specifications for {} needs to be updated.
224-
Please run the `get_capabilites.py` and `generate_subclasses.py`
225-
scripts or define the `AI_Term_Cfg` kwarg for your device.
226-
"""
227-
warnings.warn(dedent(msg.format(self.description)), FutureWarning)
228-
self.AI_chans = [key for key,val in AI_term_cfg.items() if self.AI_term in val]
229-
if not len(self.AI_chans):
230-
msg = """AI termination {0} not supported by this device."""
231-
raise LabscriptError(dedent(msg.format(AI_term)))
232-
if AI_term == 'Diff':
233-
self.AI_range = AI_range_Diff
234-
if AI_start_delay is None:
235-
if AI_start_delay_ticks is not None:
236-
# Tell blacs_worker to use AI_start_delay_ticks to define delay
237-
self.start_delay_ticks = True
219+
if num_AI > 0:
220+
if AI_term_cfg == None:
221+
# assume legacy configuration if none provided
222+
AI_term_cfg = {f'ai{i:d}': ['RSE'] for i in range(num_AI)}
223+
# warn user to update their local model specs
224+
msg = """Model specifications for {} needs to be updated.
225+
Please run the `get_capabilites.py` and `generate_subclasses.py`
226+
scripts or define the `AI_Term_Cfg` kwarg for your device.
227+
"""
228+
warnings.warn(dedent(msg.format(self.description)), FutureWarning)
229+
self.AI_chans = [key for key,val in AI_term_cfg.items() if self.AI_term in val]
230+
if not len(self.AI_chans):
231+
msg = """AI termination {0} not supported for {1}."""
232+
raise LabscriptError(dedent(msg.format(AI_term,self.description)))
233+
if AI_term == 'Diff':
234+
self.AI_range = AI_range_Diff
235+
if AI_start_delay is None:
236+
if AI_start_delay_ticks is not None:
237+
# Tell blacs_worker to use AI_start_delay_ticks to define delay
238+
self.start_delay_ticks = True
239+
else:
240+
raise LabscriptError("You have specified `AI_start_delay = None` but have not provided `AI_start_delay_ticks`.")
238241
else:
239-
raise LabscriptError("You have specified `AI_start_delay = None` but have not provided `AI_start_delay_ticks`.")
242+
# Tells blacs_worker to use AI_start_delay to define delay
243+
self.start_delay_ticks = False
240244
else:
241-
# Tells blacs_worker to use AI_start_delay to define delay
242-
self.start_delay_ticks = False
245+
# no analog inputs
246+
self.AI_chans = []
247+
self.start_delay_ticks = None
243248
self.num_AO = num_AO
244249
self.num_CI = num_CI
245250
self.ports = ports if ports is not None else {}

0 commit comments

Comments
 (0)