def __init__(self, address, *, prefix=b"", deserializer=pickle.loads, parent=None): super().__init__(parent) if isinstance(prefix, str): raise ValueError("prefix must be bytes, not string") if b" " in prefix: raise ValueError("prefix {!r} may not contain b' '".format(prefix)) self._prefix = prefix if isinstance(address, str): address = address.split(":", maxsplit=1) self._deserializer = deserializer self.address = (address[0], int(address[1])) self._context = zmq.Context() self._socket = self._context.socket(zmq.SUB) url = "tcp://%s:%d" % self.address self._socket.connect(url) self._socket.setsockopt_string(zmq.SUBSCRIBE, "") self._task = None self.closed = False self._timer = QTimer(self) self._dispatcher = Dispatcher() self.subscribe = self._dispatcher.subscribe self._waiting_for_start = True
def __init__(self): # Public dispatcher for callbacks self.dispatcher = Dispatcher() # Local caches for internal use self.seq_count = 0 # Maintain our own sequence count for this stream self.raw_descriptors = dict() # Store raw descriptors for use later self._stream_start_uid = None # Generated start doc uid self._descriptors = dict() # Dictionary of sent descriptors
def __init__(self, queue, teleport, *scan_widgets, live_widget=None, **kwargs): super().__init__(**kwargs) self.label = label = StartLabel() self.queue = queue self.teleport = teleport self.md_parameters = MetaDataEntry(name='Metadata') self.md_widget = ParameterTree() self.md_widget.setParameters(self.md_parameters) outmost_layout = QtWidgets.QHBoxLayout() input_layout = QtWidgets.QVBoxLayout() outmost_layout.addLayout(input_layout) input_layout.addWidget(label) self.tabs = TabScanSelector(*scan_widgets) input_layout.addWidget(self.tabs) for sw in scan_widgets: sw.md_parameters = self.md_parameters self.go_button = QtWidgets.QPushButton('SCAN!') self.md_button = QtWidgets.QPushButton('edit metadata') input_layout.addWidget(self.md_button) input_layout.addWidget(self.go_button) self.teleport.name_doc.connect(label.doc_consumer) self.cbr = Dispatcher() self.bec = BestEffortCallback() self.teleport.name_doc.connect( lambda name, doc: self.cbr.process(DocumentNames(name), doc)) self.cbr.subscribe(self.bec) def runner(): self.queue.put(self.tabs.get_plan()) self.go_button.clicked.connect(runner) self.md_button.clicked.connect(self.md_widget.show) if live_widget is None: live_widget = LivePlaceholder() self.live_widget = live_widget self.teleport.name_doc.connect(live_widget.doc_consumer) outmost_layout.addWidget(live_widget) self.setLayout(outmost_layout)
def __init__(self, address, *, prefix=b"", deserializer=pickle.loads): if isinstance(prefix, str): raise ValueError("prefix must be bytes, not string") if b" " in prefix: raise ValueError("prefix {!r} may not contain b' '".format(prefix)) self._prefix = prefix if isinstance(address, str): address = address.split(":", maxsplit=1) self._deserializer = deserializer self.address = (address[0], int(address[1])) self.closed = False self._thread = None self._process = None self._result_queue = multiprocessing.Queue() self._kill_worker = multiprocessing.Queue() self._dispatcher = Dispatcher() self.subscribe = self._dispatcher.subscribe self._waiting_for_start = True