def main(argv): print(__doc__) with gui_qt("Example App"): app = ExampleApp() # Optional: Receive live streaming data. if len(argv) > 1: from bluesky_widgets.qt.zmq_dispatcher import RemoteDispatcher from bluesky_widgets.utils.streaming import ( stream_documents_into_runs, ) address = argv[1] dispatcher = RemoteDispatcher(address) dispatcher.subscribe(stream_documents_into_runs( app.viewer.add_run)) dispatcher.start() # We can access and modify the model as in... len(app.searches) app.searches[0] app.searches.active # i.e. current tab app.searches.active.input.since # time range app.searches.active.input.until app.searches.active.results app.searches.active.selection_as_catalog app.searches.active.selected_uids
def main(): print(__doc__) with gui_qt("Example Application"): tree = RunTree(title="Example Application") # You can set your own catalog/run here or use this synthetic data. run = get_catalog()[-1] tree.run = run
def main(): print(__doc__) with gui_qt("Example App"): app = ExampleApp() # We can access and modify the model as in... len(app.searches) app.searches[0] app.searches.active # i.e. current tab app.searches.active.input.since # time range app.searches.active.input.until app.searches.active.results app.searches.active.selection_as_catalog app.searches.active.selected_uids
def main(): print(__doc__) with gui_qt("Example Application"): searches = Searches(title="Example Application") # We can access and modify the model as in... len(searches) searches[0] searches.active # i.e. current tab searches.active.input.since # time range searches.active.input.until = datetime(2040, 1, 1) searches.active.results searches.active.selection_as_catalog searches.active.selected_uids
def main(argv=None): print(__doc__) parser = argparse.ArgumentParser(description="bluesky-widgets demo") parser.add_argument("--zmq", help="0MQ address") parser.add_argument("--catalog", help="Databroker catalog") args = parser.parse_args(argv) with gui_qt("Demo App"): if args.catalog: import databroker SETTINGS.catalog = databroker.catalog[args.catalog] # Optional: Receive live streaming data. if args.zmq: SETTINGS.subscribe_to.append(args.zmq) viewer = Viewer() # noqa: 401
def main(argv=None): parser = argparse.ArgumentParser(description="BlueSky Queue Monitor") parser.add_argument( "--zmq-control-addr", default=None, help="Address of control socket of RE Manager. If the address " "is passed as a CLI parameter, it overrides the address specified with " "QSERVER_ZMQ_CONTROL_ADDRESS environment variable. Default address is " "used if the parameter or the environment variable are not specified.", ) parser.add_argument( "--zmq-control", default=None, help= "The parameter is deprecated and will be removed. Use --zmq-control-addr instead.", ) parser.add_argument( "--zmq-info-addr", default=None, help="Address of PUB-SUB socket of RE Manager. If the address " "is passed as a CLI parameter, it overrides the address specified with " "QSERVER_ZMQ_INFO_ADDRESS environment variable. Default address is " "used if the parameter or the environment variable are not specified.", ) parser.add_argument( "--zmq-publish", default=None, help= "The parameter is deprecated and will be removed. Use --zmq-info-addr instead.", ) args = parser.parse_args(argv) # The priority is first to check if an address is passed as a parameter and then # check if the environment variables are set. Otherwise use the default local addresses. # (The default addresses are typically used in demos.) zmq_control_addr = args.zmq_control_addr zmq_control_addr = zmq_control_addr or args.zmq_control if args.zmq_control is not None: print( "The parameter --zmq-control is deprecated and will be removed. Use --zmq-control-addr instead." ) zmq_control_addr = zmq_control_addr or os.environ.get( "QSERVER_ZMQ_CONTROL_ADDRESS", None) zmq_info_addr = args.zmq_info_addr if args.zmq_publish is not None: print( "The parameter --zmq-publish is deprecated and will be removed. Use --zmq-info-addr instead." ) zmq_info_addr = zmq_info_addr or args.zmq_publish zmq_info_addr = zmq_info_addr or os.environ.get("QSERVER_ZMQ_INFO_ADDRESS", None) if "QSERVER_ZMQ_PUBLISH_ADDRESS" in os.environ: print( "WARNING: Environment variable QSERVER_ZMQ_PUBLISH_ADDRESS is deprecated and will be removed." ) print(" Use QSERVER_ZMQ_INFO_ADDRESS environment variable instead.") zmq_info_addr = zmq_info_addr or os.environ.get( "QSERVER_ZMQ_PUBLISH_ADDRESS", None) SETTINGS.zmq_re_manager_control_addr = zmq_control_addr SETTINGS.zmq_re_manager_info_addr = zmq_info_addr with gui_qt("BlueSky Queue Monitor"): viewer = Viewer() # noqa: 401
def main(): print(__doc__) with gui_qt("Example Application"): views = Views(title="Example Application") views.show()
def main(): with gui_qt("Example App"): worker_address, message_bus_address = sys.argv[1:] dispatcher = RemoteDispatcher(message_bus_address) client = ZMQCommSendThreads(zmq_server_address=worker_address) # NOTE: this example starts only if RE Manager is idle and the queue is cleared. # Those are optional steps that ensure that the code in this example is executed correctly. # Check if RE Worker environment already exists and RE manager is idle. status = client.send_message(method="status") if status["manager_state"] != "idle": raise RuntimeError( f"RE Manager state must be 'idle': current state: {status['manager_state']}" ) # Clear the queue. response = client.send_message(method="queue_clear") if not response["success"]: raise RuntimeError( f"Failed to clear the plan queue: {response['msg']}") # Open the new environment only if it does not exist. if not status["worker_environment_exists"]: # Initiate opening of RE Worker environment response = client.send_message(method="environment_open") if not response["success"]: raise RuntimeError( f"Failed to open RE Worker environment: {response['msg']}") # Wait for the environment to be created. t_timeout = 10 t_stop = time.time() + t_timeout while True: status2 = client.send_message(method="status") if (status2["worker_environment_exists"] and status2["manager_state"] == "idle"): break if time.time() > t_stop: raise RuntimeError( "Failed to start RE Worker: timeout occurred") time.sleep(0.5) # Add plan to queue response = client.send_message( method="queue_item_add", params={ "plan": { "name": "scan", "args": [["det"], "motor", -5, 5, 11] }, "user": "", "user_group": "admin", }, ) if not response["success"]: raise RuntimeError( f"Failed to add plan to the queue: {response['msg']}") model = Lines("motor", ["det"], max_runs=3) dispatcher.subscribe(stream_documents_into_runs(model.add_run)) view = QtFigure(model.figure) view.show() dispatcher.start() response = client.send_message(method="queue_start") if not response["success"]: raise RuntimeError(f"Failed to start the queue: {response['msg']}")