Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
MNT #46 checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
gwbischof committed Feb 5, 2020
1 parent b23279e commit 35f0a20
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 9 deletions.
19 changes: 19 additions & 0 deletions profile_bluesky/startup/26-lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class Lambda750kCamLocal(Device):
image_mode = Component(EpicsSignalWithRBV, 'ImageMode', kind='config')
operating_mode = Component(EpicsSignalWithRBV, 'OperatingMode', kind='config')
serial_number = Component(EpicsSignalRO, 'SerialNumber_RBV', string=True, kind='config')
detector_state = Component(EpicsSignalRO, 'DetectorState_RBV', kind='config', string=True)
state = Component(EpicsSignalRO, 'LambdaState', kind='config', string=True)
status_msg = Component(EpicsSignalRO, 'StatusMessage_RBV', kind='config', string=True)
temperature = Component(EpicsSignalWithRBV, 'Temperature', kind='config')
trigger_mode = Component(EpicsSignal, 'TriggerMode', kind='config')

Expand Down Expand Up @@ -550,6 +553,18 @@ def trigger(self):

status = DeviceStatus(self)

def watch_state(value, old_value, **kwargs):
"""
close the shutter once self.cam.state != "RECEIVING_IMAGES"
"""
logger.debug(f"lambdadet.cam.state={value}")
logger.debug(f"old value={old_value}")
logger.debug(f"capture={self.immout.capture.get()}")
if (value in (5, "FINISHED", 6, "PROCESSING_IMAGES") and old_value in (4, "RECEIVING_IMAGES")):
shutter.close()
self.cam.state.clear_sub(watch_state)
logger.debug("closed shutter")

def closure(value, old_value, **kwargs):
if value == done_value and old_value != value:
watch_signal.clear_sub(closure)
Expand All @@ -558,8 +573,12 @@ def closure(value, old_value, **kwargs):
print(f"immout.capture.get()={self.immout.capture.get()}")
print(f"immout.num_captured.get()={self.immout.num_captured.get()}")
status._finished()
shutter.close()
print(f"status={status}")

shutter.open()
time.sleep(0.005) # wait for the shutter to move out of the way
self.cam.state.subscribe(watch_state)
watch_signal.subscribe(closure)
self.immout.capture.put(1, wait=False)
acquire_signal.put(start_value, wait=False)
Expand Down
3 changes: 3 additions & 0 deletions profile_bluesky/startup/26-rigaku.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,13 @@ def trigger(self):
def closure(value,old_value,**kwargs):
if value == 1 and old_value == 0:
self.acquire_start.put(0)
self.acquire_complete.clear_sub(closure)
status._finished()

self.acquire_complete.subscribe(closure)
self.acquire_start.put(1)
time.sleep(0.1) # could be shorter, this works now
self.acquire_start.put(0)
return status

@property
Expand Down
7 changes: 5 additions & 2 deletions profile_bluesky/startup/50-controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,8 @@ def select_RIGAKU():
# def xpcs_pre_start \'xpcs_pre_start_RIGAKU\';
# def user_xpcs_loop \'user_xpcs_loop_RIGAKU\';

dm_workflow.transfer = "xpcs8-01"
dm_workflow.analysis = "xpcs8-02-Rigaku-bin"
dm_workflow.transfer = "xpcs8-01-stage"
dm_workflow.analysis = "xpcs8-02-Rigaku-bin-stage"
yield from bps.mv(
dm_pars.burst_mode_state, 0, # 2019-05, set default status
dm_pars.transfer, dm_workflow.transfer,
Expand Down Expand Up @@ -832,6 +832,7 @@ def AD_Acquire(areadet,

md["ARun_number"] = file_name
md["full_sample_name"] = f"{file_name} {md.get('sample_name','')}"
logging.info(f"md={md}")

atten = atten or Atten1
assert atten in (Atten1, Atten2)
Expand Down Expand Up @@ -981,6 +982,7 @@ def update_metadata_postscan():
# logger.debug("dm_pars.datafilename")

def inner_count(devices, md={}):
logging.info(f"md={md}")
yield from bps.open_run(md=md)
for obj in devices:
yield from bps.stage(obj)
Expand Down Expand Up @@ -1010,6 +1012,7 @@ def inner_count(devices, md={}):
@bpp.stage_decorator([scaler1])
@bpp.monitor_during_decorator(monitored_things)
def full_acquire_procedure(md={}):
logging.info(f"md={md}")
logger.debug("before update_metadata_prescan()")
yield from update_metadata_prescan()
logger.debug("after update_metadata_prescan()")
Expand Down
6 changes: 5 additions & 1 deletion user/Rigaku_Loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def rigaku_test(num_iter=2, sample_name="test", sample_prefix="A", analysis_true

file_name = f"{sample_prefix}{dm_pars.ARun_number.get():03.0f}_{sample_name}_{i+1:05.0f}"

rigaku.qmap_file='qzhang202002_Rq0_Log_S270_D27.h5'
rigaku.qmap_file='qzhang202002b_Rq0_Log_S270_D27.h5'

# yield from bps.mv(
# detu.x, 213.9,
# detu.z, 36.8)

yield from AD_Acquire(rigaku,
acquire_time=0.1, acquire_period=0.11,
Expand Down
23 changes: 17 additions & 6 deletions user/lambda_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
test that we can run user ops continuously - use Lambda detector
"""

def lambda_test(num_iter=10, sample_name="test", sample_prefix="A"):
def lambda_test(num_iter=10, sample_name="test", sample_prefix="A", analysis_true_false=True):
bec.disable_plots()
bec.disable_table()
bec.disable_baseline()

lambdadet.cam.EXT_TRIGGER = 0
lambdadet.cam.LAMBDA_OPERATING_MODE = 0


# increment the run number
yield from bps.mvr(dm_pars.ARun_number, 1)

Expand All @@ -22,13 +26,20 @@ def lambda_test(num_iter=10, sample_name="test", sample_prefix="A"):
yield from bps.mv(dm_pars.stop_before_next_scan, 0)
break

file_name = f"{sample_prefix}{dm_pars.ARun_number.get():03.0f}"
file_name = f"{sample_prefix}{dm_pars.ARun_number.get():03.0f}_{sample_name}_{i+1:05.0f}"

lambdadet.qmap_file='qzhang202002_qmap_Aerogel_Lq0_S270_D54.h5'

yield from bps.mv(
detu.x, 213.8,
detu.z, 36.85)

yield from AD_Acquire(lambdadet,
acquire_time=0.1, acquire_period=0.11,
num_images=100, file_name=file_name,
submit_xpcs_job=True,
atten=None, path=None)
acquire_time=0.001, acquire_period=0.1,
num_images=5000, file_name=file_name,
submit_xpcs_job=analysis_true_false,
atten=None, path='/home/8-id-i/2020-1/richards202002/',
md={"sample_name": sample_name})
logger.info("-"*20 + " end of acquire")

bec.enable_baseline()
Expand Down

0 comments on commit 35f0a20

Please sign in to comment.