11from pathlib import Path
22from typing import Optional
3+ import time as ttime
34
45import numpy as np
56from bluesky .protocols import WritesStreamAssets , Readable
@@ -276,12 +277,6 @@ class SpectrumAnalyzer(Device, WritesStreamAssets, Readable):
276277
277278 def __init__ (self , * args , ** kwargs ):
278279 super ().__init__ (* args , ** kwargs )
279- self .stage_sigs .update (
280- [
281- (self .acquire , 0 ),
282- (self .file_capture , 1 ),
283- ]
284- )
285280 self ._status = None
286281 self ._index = 0
287282 self ._last_emitted_index = 0
@@ -294,6 +289,10 @@ def stage(self):
294289 "File capture must be off to stage the detector, otherwise the file will be corrupted"
295290 )
296291
292+ if self .acquire .get (as_string = True ) == "RUNNING" :
293+ self .stage_sigs .update ([(self .acquire , 0 )])
294+ self .stage_sigs .update ([(self .file_capture , 1 )])
295+
297296 path = _convert_path_to_posix (Path (self .file_path .get ()))
298297 file_name = Path (self .file_name .get ())
299298 self ._full_path = str (path / file_name )
@@ -307,6 +306,7 @@ def _stage_changed(self, value=None, old_value=None, **kwargs):
307306 if self ._status is None :
308307 return
309308 if value == "STANDBY" and old_value == "RUNNING" :
309+ ttime .sleep (1.0 )
310310 self ._status .set_finished ()
311311 self ._index += 1
312312 self ._status = None
0 commit comments