In this notebook you will:
Recommended Prerequisites:
Below, we will connect to EPICS IOC(s) controlling simulated hardware in lieu of actual motors, detectors. The IOCs should already be running in the background. Run this command to verify that they are running: it should produce output with RUNNING on each line. In the event of a problem, edit this command to replace status with restart all and run again.
!supervisorctl -c supervisor/supervisord.conf status
%run scripts/beamline_configuration.py
# aliases for convenience/readability
motor = motor_ph
det = ph
# counts forever until interrupted -- press 'stop' button in the notebook (in the terminal, you would use Ctrl+C)
RE(count([det], delay=1, num=None))
The RunEngine is paused! Our choices:
Command | Outcome |
---|---|
RE.resume() |
Safely resume plan. |
RE.abort() |
Perform cleanup. Mark as aborted. |
RE.stop() |
Perform cleanup. Mark as success. |
RE.halt() |
Do not perform cleanup --- just stop. |
RE.state |
Check if 'paused' or 'idle'. |
While the RunEngine is paused, you have control of the prompt. You can check on things.
1 + 1
det.read()
# Again, we need to press 'stop' or this will run forever....
RE.resume()
Paused again. Once more, our choices:
Command | Outcome |
---|---|
RE.resume() |
Safely resume plan. |
RE.abort() |
Perform cleanup. Mark as aborted. |
RE.stop() |
Perform cleanup. Mark as success. |
RE.halt() |
Do not perform cleanup --- just stop. |
RE.state |
Check if 'paused' or 'idle'. |
RE.abort()
Compare 'abort' to 'stop' and 'halt':
RE(count([det], delay=1, num=None))
RE.stop()
RE(count([det], delay=1, num=None))
RE.halt()
RE(count([det], delay=1, num=None))
RE(count([det], delay=1, num=None))
RE.state
RE.abort()
RE.state
Suspenders are agents set up in advance to run in the background and pause/resume a scan in response to some condition (like a beam dump).
from bluesky.suspenders import SuspendFloor
import ophyd
current = ophyd.Signal(name='beam_current')
sus = SuspendFloor(current, 50, sleep=1)
RE.install_suspender(sus)
##### Simulate a beam dump and recovery after 3 seconds....
import threading
import time
def delay_dump_delay_recover():
time.sleep(3)
current.set(0)
time.sleep(5)
current.set(100)
current.set(100)
thread = threading.Thread(target=delay_dump_delay_recover)
thread.start()
#####
RE(count([det], num=10, delay=1))
count
with a delay (as we have done many times above) and practice pausing and resuming.