@@ -404,6 +404,49 @@ def _make_analog_input_table(self, inputs):
404404
405405 return acquisition_table
406406
407+ def _check_wait_monitor_timeout_device_config (self ):
408+ """Check that if we are the wait monitor acquisition device and another device
409+ is the wait monitor timeout device, that a) the other device is a DAQmx device
410+ and b) the other device has a start_order lower than us and a stop_order higher
411+ than us."""
412+ acquisition_device = compiler .wait_monitor .acquisition_device
413+ timeout_device = compiler .wait_monitor .timeout_device
414+ if acquisition_device is not self or timeout_device is None :
415+ return
416+ if timeout_device is self :
417+ return
418+ if not isinstance (timeout_device , NI_DAQmx ):
419+ msg = """If using an NI DAQmx device as a wait monitor acquisition device,
420+ then the wait monitor timeout device must also be an NI DAQmx device,
421+ not {}."""
422+ raise TypeError (dedent (msg ).format (type (timeout_device )))
423+ timeout_start = timeout_device .start_order
424+ if timeout_start is None :
425+ timeout_start = 0
426+ timeout_stop = timeout_device .stop_order
427+ if timeout_stop is None :
428+ timeout_stop = 0
429+ self_start = self .start_order
430+ if self_start is None :
431+ self_start = 0
432+ self_stop = self .stop_order
433+ if self_stop is None :
434+ self_stop = 0
435+ if timeout_start >= self_start or timeout_stop <= self_stop :
436+ msg = """If using different DAQmx devices as the wait monitor acquisition
437+ and timeout devices, the timeout device must transition_to_buffered
438+ before the acquisition device, and transition_to_manual after it, in
439+ order to ensure the output port for timeout pulses is not in use (by the
440+ manual mode DO task) when the wait monitor subprocess attempts to use
441+ it. To achieve this, pass the start_order and stop_order keyword
442+ arguments to the devices in your connection table, ensuring that the
443+ timeout device has a lower start_order and a higher stop_order than the
444+ acquisition device. The default start_order and stop_order is zero, so
445+ if you are not otherwise controlling the order that devices are
446+ programmed, you can set start_order=-1, stop_order=1 on the timeout
447+ device only."""
448+ raise RuntimeError (dedent (msg ))
449+
407450 def generate_code (self , hdf5_file ):
408451 IntermediateDevice .generate_code (self , hdf5_file )
409452 analogs = {}
@@ -438,6 +481,7 @@ def generate_code(self, hdf5_file):
438481 AI_table = self ._make_analog_input_table (inputs )
439482
440483 self ._check_AI_not_too_fast (AI_table )
484+ self ._check_wait_monitor_timeout_device_config ()
441485
442486 grp = self .init_device_group (hdf5_file )
443487 if AO_table is not None :
0 commit comments