def _usb_init_connection(self, model): if model not in _OOModelConfig.keys(): raise _OOError('Unkown OceanOptics spectrometer model: %s' % model) # Add model self.model = model vendorId, productId = _OOVendorId, _OOModelConfig[model]['ProductId'] self._EPout = _OOModelConfig[model]['EPout'] self._EPin0 = _OOModelConfig[model]['EPin0'] self._EPin1 = _OOModelConfig[model]['EPin1'] self._EPin0_size = _OOModelConfig[model]['EPin0_size'] self._EPin1_size = _OOModelConfig[model]['EPin1_size'] self._min_integration_time, self._max_integration_time = _OOMinMaxIT[model] devices = usb.core.find(find_all=True, custom_match=lambda d: (d.idVendor==vendorId and d.idProduct in productId)) # FIXME: generator fix devices = list(devices) try: self._dev = devices.pop(0) except (AttributeError, IndexError): raise _OOError('No OceanOptics %s spectrometer found!' % model) else: if devices: warnings.warn('Currently the first device matching the ' 'Vendor/Product id is used') self._dev.set_configuration() self._USBTIMEOUT = self._dev.default_timeout * 1e-3
def _usb_init_connection(self, model): if model not in _OOModelConfig.keys(): raise _OOError('Unkown OceanOptics spectrometer model: %s' % model) vendorId, productId = _OOVendorId, _OOModelConfig[model]['ProductId'] self._EPout = _OOModelConfig[model]['EPout'] self._EPin0 = _OOModelConfig[model]['EPin0'] self._EPin1 = _OOModelConfig[model]['EPin1'] self._EPin0_size = _OOModelConfig[model]['EPin0_size'] self._EPin1_size = _OOModelConfig[model]['EPin1_size'] devices = usb.core.find(find_all=True, custom_match=lambda d: (d.idVendor==vendorId and d.idProduct in productId)) # FIXME: generator fix devices = list(devices) try: self._dev = devices.pop(0) except (AttributeError, IndexError): raise _OOError('No OceanOptics %s spectrometer found!' % model) else: if devices: warnings.warn('Currently the first device matching the ' 'Vendor/Product id is used') self._dev.set_configuration() self._USBTIMEOUT = self._dev.default_timeout * 1e-3