@@ -18,7 +18,7 @@ This section is divided into these parts.
1818* :ref: `command_file_register `
1919* :ref: `command_file_testing `
2020* :ref: `command_file_running `
21- * :ref: `command_file_other_spreadsheets `
21+ * :ref: `command_file_appendix `
2222
2323.. _command_file :
2424
@@ -263,28 +263,83 @@ and the last few lines:
263263Running the command file
264264++++++++++++++++++++++++
265265
266+ Prepare the RE
267+ ^^^^^^^^^^^^^^^
268+
269+ These steps were used to prepare our bluesky ipython session to run the plan:
270+
271+ .. code-block :: python
272+ :linenos:
273+
274+ from bluesky import RunEngine
275+ from bluesky.utils import get_history
276+ RE = RunEngine(get_history())
277+
278+ # Import matplotlib and put it in interactive mode.
279+ import matplotlib.pyplot as plt
280+ plt.ion()
281+
282+ # load config from ~/.config/databroker/mongodb_config.yml
283+ from databroker import Broker
284+ db = Broker.named(" mongodb_config" )
285+
286+ # Subscribe metadatastore to documents.
287+ # If this is removed, data is not saved to metadatastore.
288+ RE .subscribe(db.insert)
289+
290+ # Set up SupplementalData.
291+ from bluesky import SupplementalData
292+ sd = SupplementalData()
293+ RE .preprocessors.append(sd)
294+
295+ # Add a progress bar.
296+ from bluesky.utils import ProgressBarManager
297+ pbar_manager = ProgressBarManager()
298+ RE .waiting_hook = pbar_manager
299+
300+ # Register bluesky IPython magics.
301+ from bluesky.magics import BlueskyMagics
302+ get_ipython().register_magics(BlueskyMagics)
303+
304+ # Set up the BestEffortCallback.
305+ from bluesky.callbacks.best_effort import BestEffortCallback
306+ bec = BestEffortCallback()
307+ RE .subscribe(bec)
308+
309+ Also, since we are using an EPICS area detector (ADSimDetector) and have just
310+ started its IOC, we must process at least one image from the CAM to each of the
311+ file writing plugins we'll use (just the HDF1 for us). A procedure has been added
312+ to the ``ophyd.areadetector `` code for this. Here is the command we used
313+ for this procedure:
314+
315+ areadetector.hdf1.warmup()
316+
317+ Run the command file
318+ ^^^^^^^^^^^^^^^^^^^^^
319+
266320To run the command file, you need to pass this to an instance of the
267- :class: `bluesky.RunEngine `, usually defined as ``RE ``, such as ::
321+ :class: `bluesky.RunEngine `, defined as ``RE `` above ::
268322
269323 RE(apstools.plans.run_command_file("sample_example.txt"))
270324
271- The output will be rather lengthy, if there are no errors.
272- Here are the first few lines:
325+ The output will be rather lengthy.
326+ Here are the first few lines of the output on my system (your hardware
327+ may be different so the exact data columns and values will vary):
328+
329+ .. literalinclude :: ../resources/sample_example_run.txt
330+ :tab-width: 4
331+ :language: guess
332+ :lines: 1-25
333+
334+ and the last few lines:
335+
336+ .. literalinclude :: ../resources/sample_example_run.txt
337+ :tab-width: 4
338+ :language: guess
339+ :lines: 390-
273340
274- .. TODO:
275- .. literalinclude:: ../resources/sample_example_run.txt
276- :tab-width: 4
277- :language: guess
278- :lines: 1-20
279-
280- and the last few lines:
281-
282- .. literalinclude:: ../resources/sample_example_run.txt
283- :tab-width: 4
284- :language: guess
285- :lines: ???
286341
287- .. _ command_file_other_spreadsheets :
342+ .. _ command_file_appendix :
288343
289344Appendix: Other spreadsheet examples
290345++++++++++++++++++++++++++++++++++++
0 commit comments