Terminal 1:
bluesky-0MQ-proxy 5567 5568
Terminal 2:
python publisher.py
# Prints a stready stream of documents
Terminal 3:
python dispathcer.py
# Prints a steady stream of documents and updates like:
Run list has 16 items
from bluesky_widgets.models.utils import RunList | |
from bluesky_widgets.utils.streaming import stream_documents_into_runs | |
from bluesky_widgets.qt.zmq_dispatcher import RemoteDispatcher | |
from bluesky_widgets.qt import gui_qt | |
rl = RunList() | |
def log(name, doc): | |
print(name, doc) | |
print(f"Run list has {len(rl)} items") | |
with gui_qt("Example"): | |
d = RemoteDispatcher("localhost:5568") | |
callback = stream_documents_into_runs(rl.append) | |
d.subscribe(callback) | |
d.subscribe(log) | |
d.start() |
from bluesky.plans import scan | |
from ophyd.sim import motor, det | |
from bluesky import RunEngine | |
from bluesky.callbacks.zmq import Publisher | |
motor.delay = 0.2 | |
def plan(): | |
while True: | |
yield from scan([det], motor, -5, 5, 1) | |
RE = RunEngine() | |
publisher = Publisher("localhost:5567") | |
RE.subscribe(publisher) | |
RE.subscribe(print) | |
RE(plan()) |