def __init__(self, path): self.path = path # Store list of traces self._traces = None # store list of channels self._channels = None # TODO: Get this dynamically device_list = ['PulseBlaster', 'NI_PCIe_6363', 'NI_PCI_6733'] # Load connection table self.connection_table = ConnectionTable(path) # open h5 file with h5py.File(path, 'r') as file: # Get master pseudoclock self.master_pseudoclock_name = file['connection table'].attrs[ 'master_pseudoclock'] # get stop time self.stop_time = file[ 'devices/%s' % self.master_pseudoclock_name].attrs['stop_time'] self.device_names = file['devices'].keys()
def __init__(self, path): self.path = path # Store list of traces self._traces = None # store list of channels self._channels = None # TODO: Get this dynamically device_list = ['PulseBlaster', 'NI_PCIe_6363', 'NI_PCI_6733'] # Load connection table self.connection_table = ConnectionTable(path) # open h5 file with h5py.File(path, 'r') as file: # Get master pseudoclock self.master_pseudoclock_name = file['connection table'].attrs['master_pseudoclock'] # get stop time self.stop_time = file['devices/%s'%self.master_pseudoclock_name].attrs['stop_time'] self.device_names = file['devices'].keys()
QTimer.singleShot(1000, self.close) else: if not self.my_tab.destroy_complete: QTimer.singleShot(1000, self.close) else: event.accept() def add_my_tab(self, tab): self.my_tab = tab app = QApplication(sys.argv) window = MyWindow() layout = QVBoxLayout(window) notebook = DragDropTabWidget() layout.addWidget(notebook) connection_table = ConnectionTable( os.path.join(os.path.dirname(os.path.realpath(__file__)), r'../example_connection_table.h5')) tab1 = ni_pcie_6363(notebook, settings={ 'device_name': 'ni_pcie_6363_0', 'connection_table': connection_table }) window.add_my_tab(tab1) window.show() def run(): app.exec_() sys.exit(run())
class Shot(object): def __init__(self, path): self.path = path # Store list of traces self._traces = None # store list of channels self._channels = None # TODO: Get this dynamically device_list = ['PulseBlaster', 'NI_PCIe_6363', 'NI_PCI_6733'] # Load connection table self.connection_table = ConnectionTable(path) # open h5 file with h5py.File(path, 'r') as file: # Get master pseudoclock self.master_pseudoclock_name = file['connection table'].attrs[ 'master_pseudoclock'] # get stop time self.stop_time = file[ 'devices/%s' % self.master_pseudoclock_name].attrs['stop_time'] self.device_names = file['devices'].keys() def delete_cache(self): self._channels = None self._traces = None def _load(self): if self._channels is None: self._channels = {} if self._traces is None: self._traces = {} # Let's walk the connection table, starting with the master pseudoclock master_pseudoclock_device = self.connection_table.find_by_name( self.master_pseudoclock_name) self._load_device(master_pseudoclock_device) def add_trace(self, name, trace, parent_device_name, connection): name = unicode(name) self._channels[name] = { 'device_name': parent_device_name, 'port': connection } self._traces[name] = trace def _load_device(self, device, clock=None): try: print 'loading %s' % device.name module = device.device_class # Load the master pseudoclock class # labscript_devices.import_device(module) device_class = labscript_devices.get_runviewer_parser(module) device_instance = device_class(self.path, device) clocklines_and_triggers = device_instance.get_traces( self.add_trace, clock) for name, trace in clocklines_and_triggers.items(): child_device = self.connection_table.find_by_name(name) for grandchild_device_name, grandchild_device in child_device.child_list.items( ): self._load_device(grandchild_device, trace) except Exception: #TODO: print/log exception traceback # if device.name == 'ni_card_0' or device.name == 'pulseblaster_0' or device.name == 'pineblaster_0' or device.name == 'ni_card_1' or device.name == 'novatechdds9m_0': # raise # raise if hasattr(device, 'name'): print 'Failed to load device %s' % device.name else: print 'Failed to load device (unknown name, device object does not have attribute name)' @property def channels(self): if self._channels is None: self._load() return self._channels.keys() def clear_cache(self): # clear cache variables to cut down on memory usage pass @property def traces(self): # if traces cached: # return cached traces and waits if self._traces is None: self._load() return self._traces
class Shot(object): def __init__(self, path): self.path = path # Store list of traces self._traces = None # store list of channels self._channels = None # TODO: Get this dynamically device_list = ['PulseBlaster', 'NI_PCIe_6363', 'NI_PCI_6733'] # Load connection table self.connection_table = ConnectionTable(path) # open h5 file with h5py.File(path, 'r') as file: # Get master pseudoclock self.master_pseudoclock_name = file['connection table'].attrs['master_pseudoclock'] # get stop time self.stop_time = file['devices/%s'%self.master_pseudoclock_name].attrs['stop_time'] self.device_names = file['devices'].keys() def delete_cache(self): self._channels = None self._traces = None def _load(self): if self._channels is None: self._channels = {} if self._traces is None: self._traces = {} # Let's walk the connection table, starting with the master pseudoclock master_pseudoclock_device = self.connection_table.find_by_name(self.master_pseudoclock_name) self._load_device(master_pseudoclock_device) def add_trace(self, name, trace, parent_device_name, connection): name = unicode(name) self._channels[name] = {'device_name':parent_device_name, 'port':connection} self._traces[name] = trace def _load_device(self, device, clock=None): try: print 'loading %s'%device.name module = device.device_class # Load the master pseudoclock class # labscript_devices.import_device(module) device_class = labscript_devices.get_runviewer_parser(module) device_instance = device_class(self.path, device) clocklines_and_triggers = device_instance.get_traces(self.add_trace, clock) for name, trace in clocklines_and_triggers.items(): child_device = self.connection_table.find_by_name(name) for grandchild_device_name, grandchild_device in child_device.child_list.items(): self._load_device(grandchild_device, trace) except Exception: #TODO: print/log exception traceback # if device.name == 'ni_card_0' or device.name == 'pulseblaster_0' or device.name == 'pineblaster_0' or device.name == 'ni_card_1' or device.name == 'novatechdds9m_0': # raise # raise if hasattr(device, 'name'): print 'Failed to load device %s'%device.name else: print 'Failed to load device (unknown name, device object does not have attribute name)' @property def channels(self): if self._channels is None: self._load() return self._channels.keys() def clear_cache(self): # clear cache variables to cut down on memory usage pass @property def traces(self): # if traces cached: # return cached traces and waits if self._traces is None: self._load() return self._traces