def add_device(self, device): if isinstance(device, WaitMonitor): IntermediateDevice.add_device(self, device) else: raise LabscriptError( 'You can only connect an instance of WaitMonitor to the device %s.internal_wait_monitor_outputs' % (self.pseudoclock_device.name))
def add_device(self, device): if isinstance(device, DigitalOut): IntermediateDevice.add_device(self, device) else: raise LabscriptError( f'You have connected {device.name} to {self.name} (the IntermediateDevice ' + f'embedded in {self.parent_device.parent_device.name}), but {self.name} only ' + f'supports DigitalOut children.')
def add_device(self, device): try: prefix, number = device.connection.split() assert int(number) in range(2) assert prefix == 'dds' except Exception: raise LabscriptError('invalid connection string. Please use the format \'dds n\' with n 0 or 1') if isinstance(device, DDS): # Check that the user has not specified another digital line as the gate for this DDS, that doesn't make sense. if device.gate is not None: raise LabscriptError('You cannot specify a digital gate ' + 'for a DDS connected to %s. '% (self.name)) IntermediateDevice.add_device(self, device)
def add_device(self, device): """Error checking for adding a child device""" # Verify static/dynamic outputs compatible with configuration: if isinstance(device, StaticAnalogOut) and not self.static_AO: msg = """Cannot add StaticAnalogOut to NI_DAQmx device configured for dynamic analog output. Pass static_AO=True for static analog output""" raise LabscriptError(dedent(msg)) if isinstance(device, StaticDigitalOut) and not self.static_DO: msg = """Cannot add StaticDigitalOut to NI_DAQmx device configured for dynamic digital output. Pass static_DO=True for static digital output""" raise LabscriptError(dedent(msg)) if isinstance(device, AnalogOut) and self.static_AO: msg = """Cannot add AnalogOut to NI_DAQmx device configured for static analog output. Pass static_AO=False for dynamic analog output""" raise LabscriptError(dedent(msg)) if isinstance(device, DigitalOut) and self.static_DO: msg = """Cannot add DigitalOut to NI_DAQmx device configured for static digital output. Pass static_DO=False for dynamic digital output""" raise LabscriptError(dedent(msg)) # Verify connection string is OK: if isinstance(device, (AnalogOut, StaticAnalogOut)): ao_num = split_conn_AO(device.connection) if ao_num >= self.num_AO: msg = """Cannot add output with connection string '%s' to device with num_AO=%d""" raise ValueError( dedent(msg) % (device.connection, self.num_AO)) elif isinstance(device, (DigitalOut, StaticDigitalOut)): port, line = split_conn_DO(device.connection) port_str = 'port%d' % port if port_str not in self.ports: msg = "Parent device has no such DO port '%s'" % port_str raise ValueError(msg) nlines = self.ports[port_str]['num_lines'] if line >= nlines: msg = """Canot add output with connection string '%s' to port '%s' with only %d lines""" raise ValueError( dedent(msg) % (device.connection, port_str, nlines)) supports_buffered = self.ports[port_str]['supports_buffered'] if isinstance(device, DigitalOut) and not supports_buffered: msg = """Cannot add DigitalOut port '%s', which does not support buffered output""" raise ValueError(dedent(msg) % port_str) elif isinstance(device, AnalogIn): ai_num = split_conn_AI(device.connection) if ai_num >= self.num_AI: msg = """Cannot add analog input with connection string '%s' to device with num_AI=%d""" raise ValueError( dedent(msg) % (device.connection, self.num_AI)) if self.acquisition_rate is None: msg = """Cannot add analog input to NI_DAQmx device with acquisition_rate=None. Please set acquisition_rate as an instantiation argument to the parent NI_DAQmx device.""" raise ValueError(dedent(msg)) if self.parent_device is None: msg = """Cannot add analog input to device with no parent pseudoclock. Even if there is no buffered output, a pseudoclock is still required to trigger the start of acquisition. Please specify a parent_device and clock_terminal for device %s""" raise ValueError(dedent(msg) % self.name) IntermediateDevice.add_device(self, device)
def add_device(self, device): # Error-check the connection string: _ = get_device_number(device.connection) IntermediateDevice.add_device(self, device)
def add_device(self, output): # TODO: check there are no duplicates, check that connection # string is formatted correctly. IntermediateDevice.add_device(self, output)