1+
12"""
23user-facing scans
34"""
1718from bluesky import preprocessors as bpp
1819from bluesky .utils import plan
1920
20- from usaxs .callbacks .spec_data_file_writer import specwriter
21- from usaxs .utils .override import user_override
22- from usaxs .utils .user_sample_title import getSampleTitle
23- from usaxs .utils .utils import techniqueSubdirectory
24-
21+ from ..callbacks .spec_data_file_writer import specwriter
2522from ..utils .a2q_q2a import q2angle
2623from ..utils .global_suspenders import get_suspend_BeamInHutch
2724from ..utils .global_suspenders import get_suspend_FE_shutter
25+ from ..utils .override import user_override
26+ from ..utils .user_sample_title import getSampleTitle
27+ from ..utils .utils import techniqueSubdirectory
2828from .amplifiers_plan import autoscale_amplifiers
2929from .command_list import after_plan
3030from .command_list import before_plan
6666suspend_FE_shutter = get_suspend_FE_shutter
6767suspend_BeamInHutch = get_suspend_BeamInHutch
6868
69+
6970@bpp .suspend_decorator (suspend_FE_shutter )
7071@bpp .suspend_decorator (suspend_BeamInHutch )
7172@plan
@@ -145,9 +146,6 @@ def USAXSscanStep(
145146 USAGE: ``RE(USAXSscanStep(pos_X, pos_Y, thickness, scan_title))``
146147 """
147148
148- from ..startup import RE
149- from ..startup import bec
150-
151149 if md is None :
152150 md = {}
153151
@@ -192,7 +190,7 @@ def USAXSscanStep(
192190 scan_title_clean = cleanupText (scan_title )
193191
194192 # SPEC-compatibility
195- SCAN_N = RE . md [ "scan_id" ] + 1 # update with next number
193+ SCAN_N = user_data . spec_scan . get () + 1 # update with next number
196194
197195 ts = str (datetime .datetime .now ())
198196 yield from bps .mv (
@@ -262,7 +260,7 @@ def USAXSscanStep(
262260 yield from user_data .set_state_plan ("Running USAXS step scan" )
263261
264262 # SPEC-compatibility
265- SCAN_N = RE . md [ "scan_id" ] + 1 # update with next number
263+ SCAN_N = user_data . spec_scan . get () + 1 # update with next number
266264 yield from bps .mv (
267265 # fmt: off
268266 user_data .scanning ,
@@ -298,7 +296,6 @@ def USAXSscanStep(
298296 endAngle = terms .USAXS .ar_val_center .get () - q2angle (
299297 terms .USAXS .finish .get (), monochromator .dcm .wavelength .position
300298 )
301- bec .disable_plots ()
302299
303300 yield from record_sample_image_on_demand ("usaxs" , scan_title_clean , _md )
304301
@@ -320,7 +317,6 @@ def USAXSscanStep(
320317 useDynamicTime = use_dynamic_time ,
321318 md = _md ,
322319 )
323- bec .enable_plots ()
324320
325321 yield from bps .mv (
326322 # fmt: off
@@ -400,7 +396,6 @@ def Flyscan(
400396
401397 USAGE: ``RE(Flyscan(pos_X, pos_Y, thickness, scan_title))``
402398 """
403- from ..startup import RE
404399 if md is None :
405400 md = {}
406401
@@ -461,10 +456,10 @@ def Flyscan(
461456 # print("scan_title_clean:", scan_title_clean)
462457
463458 # SPEC-compatibility
464- SCAN_N = RE . md [ "scan_id" ] + 1
459+ SCAN_N = user_data . spec_scan . get () + 1
465460
466461 flyscan_path = techniqueSubdirectory ("usaxs" )
467- if not os .path .exists (flyscan_path ) and RE . state != "idle" :
462+ if not os .path .exists (flyscan_path ) and user_data . collection_in_progress . get () :
468463 os .mkdir (flyscan_path )
469464 flyscan_file_name = (
470465 f"{ scan_title_clean } " f"_{ terms .FlyScan .order_number .get ():04d} " ".h5"
@@ -580,7 +575,7 @@ def Flyscan(
580575 )
581576
582577 # SPEC-compatibility
583- SCAN_N = RE . md [ "scan_id" ] + 1
578+ SCAN_N = user_data . spec_scan . get () + 1
584579 yield from bps .mv (
585580 # fmt: off
586581 user_data .scanning ,
@@ -604,8 +599,6 @@ def Flyscan(
604599
605600 yield from record_sample_image_on_demand ("usaxs" , scan_title_clean , _md )
606601
607- # bec.disable_table()
608-
609602 yield from Flyscan_internal_plan (md = _md ) # flyscan proper
610603
611604 yield from bps .mv (
@@ -617,9 +610,11 @@ def Flyscan(
617610 timeout = MASTER_TIMEOUT ,
618611 # fmt: on
619612 )
620-
621- diff = flyscan_trajectories .num_pulse_positions .get () - struck .current_channel .get ()
622- if diff > 5 and RE .state != "idle" :
613+ diff = (
614+ flyscan_trajectories .num_pulse_positions .get ()
615+ - struck .current_channel .get ()
616+ )
617+ if diff > 5 and user_data .collection_in_progress .get ():
623618 msg = "WARNING: Flyscan finished with %g less points" % diff
624619 logger .info ("*" ) * 20
625620 logger .info (msg )
@@ -669,3 +664,4 @@ def Flyscan(
669664 yield from user_data .set_state_plan ("Flyscan finished" )
670665
671666 yield from after_plan (weight = 3 )
667+
0 commit comments