wip fixes at the beamline
This commit is contained in:
@@ -5,7 +5,7 @@ falcon:
|
||||
prefix: 'X10DA-SITORO:'
|
||||
enabled: true
|
||||
onFailure: raise
|
||||
readoutPriority: monitored
|
||||
readoutPriority: async
|
||||
softwareTrigger: false
|
||||
manip_new_trx:
|
||||
description: Old Sample Manipulator X-Translation
|
||||
|
||||
@@ -44,7 +44,7 @@ class DXPControl(Device):
|
||||
class MCAControl(Device):
|
||||
"""MCA Control Device for Falcon detector"""
|
||||
|
||||
spectrum = Cpt(EpicsSignalRO, ".VAL", kind=Kind.omitted)
|
||||
spectrum = Cpt(EpicsSignalRO, ".VAL", kind=Kind.omitted, auto_monitor=True)
|
||||
roi_count = Cpt(EpicsSignalRO, ".R0", kind=Kind.omitted, auto_monitor=True)
|
||||
roi_label = Cpt(EpicsSignal, ".R0NM", kind=Kind.omitted)
|
||||
elapsed_real_time = Cpt(EpicsSignalRO, ".ERTM", kind=Kind.omitted, auto_monitor=True)
|
||||
@@ -75,7 +75,7 @@ class DeadTimeCorrectedCounts(Signal):
|
||||
ocr = dxp.output_count_rate.get()
|
||||
roi = mca.roi_count.get()
|
||||
ert = mca.elapsed_real_time.get()
|
||||
print(icr, ocr, roi, ert)
|
||||
# print(icr, ocr, roi, ert)
|
||||
|
||||
if icr == 0 or ocr == 0:
|
||||
return 0
|
||||
@@ -133,7 +133,7 @@ class FalconSuperXASDirect(PSIDeviceBase, FalconControlDirect):
|
||||
"""Falcon implementierung at SuperXAS. prefix: 'X10DA-SITORO:'"""
|
||||
|
||||
preview = Cpt(
|
||||
Signal, name="preview", kind=Kind.normal, doc="Preview signal for Falcon detector"
|
||||
Signal, name="preview", kind=Kind.omitted, doc="Preview signal for Falcon detector"
|
||||
)
|
||||
icr = Cpt(
|
||||
Signal, name="icr", kind=Kind.normal)
|
||||
@@ -172,13 +172,14 @@ class FalconSuperXASDirect(PSIDeviceBase, FalconControlDirect):
|
||||
name=name, prefix=prefix, scan_info=scan_info, device_manager=device_manager, **kwargs
|
||||
)
|
||||
self.dm = device_manager
|
||||
self._pv_timeout = 1
|
||||
self._pv_timeout = 5
|
||||
self._async_read_data = [
|
||||
"dxp_input_count_rate",
|
||||
"dxp_output_count_rate",
|
||||
"mca_elapsed_real_time",
|
||||
"mca_rois_roi0_count",
|
||||
]
|
||||
self._index = 0
|
||||
|
||||
def on_init(self) -> None:
|
||||
"""
|
||||
@@ -193,8 +194,8 @@ class FalconSuperXASDirect(PSIDeviceBase, FalconControlDirect):
|
||||
Called after the device is connected and its signals are connected.
|
||||
Default values for signals should be set here.
|
||||
"""
|
||||
self.stop_all.put(1)
|
||||
CompareStatus(self.acquiring, FalconAcquiringStatus.DONE).wait(5)
|
||||
# self.stop_all.put(1)
|
||||
# CompareStatus(self.acquiring, FalconAcquiringStatus.DONE).wait(5)
|
||||
# self.mca1.spectrum.subscribe(self._update_preview, run=False)
|
||||
|
||||
# TODO add again once PreviewSIgnal works with GUI
|
||||
@@ -209,10 +210,18 @@ class FalconSuperXASDirect(PSIDeviceBase, FalconControlDirect):
|
||||
|
||||
Information about the upcoming scan can be accessed from the scan_info (self.scan_info.msg) object.
|
||||
"""
|
||||
self.stop_all.put(1, use_complete=True)
|
||||
CompareStatus(self.acquiring, FalconAcquiringStatus.DONE).wait(self._pv_timeout)
|
||||
# self.stop_all.put(1, use_complete=True)
|
||||
if self.acquiring.get() == FalconAcquiringStatus.ACQUIRING:
|
||||
status = CompareStatus(self.acquiring, FalconAcquiringStatus.DONE)
|
||||
self.stop_all.put(1)
|
||||
try:
|
||||
status.wait(self._pv_timeout)
|
||||
except Exception as exc:
|
||||
logger.warning(f"Device {self.name} failed to reach state 'done', current state {FalconAcquiringStatus(self.acquiring.get())}")
|
||||
|
||||
self.collect_mode.set(0).wait()
|
||||
self.preset_real_time.set(0).wait()
|
||||
self._index = 0
|
||||
|
||||
def on_unstage(self) -> DeviceStatus | StatusBase | None:
|
||||
"""Called while unstaging the device."""
|
||||
@@ -244,17 +253,16 @@ class FalconSuperXASDirect(PSIDeviceBase, FalconControlDirect):
|
||||
# CompareStatus(self.acquiring, FalconAcquiringStatus.DONE).wait(self._pv_timeout)
|
||||
logger.info(f"Sending data for {self.name} at {time_started}")
|
||||
self.icr.put(self.dxp1.input_count_rate.get())
|
||||
logger.info(f"Data to plot {self.icr.get()}")
|
||||
self.ocr.put(self.dxp1.output_count_rate.get())
|
||||
self.elap_real_time.put(self.mca1.elapsed_real_time.get())
|
||||
self.roi0_count.put(self.mca1.roi_count.get())
|
||||
self.dead_cor_roi0_count.put(self.dead_time_cor_cnts1.get())
|
||||
self.preview.put(self.mca1.spectrum.get())
|
||||
# self._send_preview_async()
|
||||
self._send_preview_async()
|
||||
logger.info(f"Data sent for {self.name} at {time.time()- time_started}")
|
||||
|
||||
def _send_preview_async(self) -> None:
|
||||
metadata = self.scan_info.msg.metadata
|
||||
metadata.update({"async_update": {"type": "add", "max_shape": [None]}})
|
||||
metadata = {"async_update": {"type": "add", "max_shape": [None, 3000]}}
|
||||
data = {self.preview.name: {"value": self.mca1.spectrum.get(), "timestamp": time.time()}}
|
||||
msg = DeviceMessage(signals=data, metadata=metadata)
|
||||
self.dm.connector.xadd(
|
||||
@@ -262,6 +270,7 @@ class FalconSuperXASDirect(PSIDeviceBase, FalconControlDirect):
|
||||
scan_id=self.scan_info.msg.scan_id, device=self.name
|
||||
),
|
||||
msg_dict={"data": msg},
|
||||
max_size=10000,
|
||||
max_size=1000,
|
||||
expire=900,
|
||||
)
|
||||
self._index += 1
|
||||
|
||||
@@ -70,7 +70,7 @@ class Trigger(PSIDeviceBase, TriggerControl):
|
||||
):
|
||||
super().__init__(name=name, prefix=prefix, scan_info=scan_info, **kwargs)
|
||||
self.device_manager = device_manager
|
||||
self._pv_timeout = 1
|
||||
self._pv_timeout = 5
|
||||
self._falcon_ready_timeout = 5 # seconds
|
||||
|
||||
########################################
|
||||
@@ -124,6 +124,8 @@ class Trigger(PSIDeviceBase, TriggerControl):
|
||||
if falcon is not None:
|
||||
falcon: FalconSuperXASDirect
|
||||
falcon.erase_start.put(1)
|
||||
# falcon.erase_all.put(1)
|
||||
# falcon.start_all.put(1)
|
||||
time.sleep(0.4) # Wait for erase to complete
|
||||
logger.info(
|
||||
f"Erase and start acquiring for {falcon.name} at {time.time() - time_started}"
|
||||
@@ -131,14 +133,14 @@ class Trigger(PSIDeviceBase, TriggerControl):
|
||||
try:
|
||||
# pylint: disable=protected-access
|
||||
CompareStatus(falcon.acquiring, FalconAcquiringStatus.ACQUIRING).wait(
|
||||
timeout=self._falcon_ready_timeout
|
||||
timeout=self._pv_timeout
|
||||
)
|
||||
except Exception as exc:
|
||||
logger.error(
|
||||
f"Falcon did not start acquiring. Current state {falcon.acquiring.get()}. "
|
||||
f"Falcon did not start acquiring. Current state {FalconAcquiringStatus(falcon.acquiring.get())}. "
|
||||
)
|
||||
raise TimeoutError(
|
||||
f"Falcon did not start acquiring within {self._falcon_ready_timeout} seconds."
|
||||
f"Falcon did not start acquiring within {self._pv_timeout} seconds."
|
||||
) from exc
|
||||
|
||||
status_smpl = TransitionStatus(self.smpl_done, [SamplingDone.RUNNING, SamplingDone.DONE])
|
||||
@@ -157,6 +159,7 @@ class Trigger(PSIDeviceBase, TriggerControl):
|
||||
# timeout=self._falcon_ready_timeout
|
||||
# )
|
||||
falcon.send_data()
|
||||
# falcon.stop_all.put(1)
|
||||
return status_smpl
|
||||
|
||||
def on_complete(self) -> DeviceStatus | StatusBase | None:
|
||||
@@ -167,7 +170,6 @@ class Trigger(PSIDeviceBase, TriggerControl):
|
||||
|
||||
def on_stop(self) -> None:
|
||||
"""Called when the device is stopped."""
|
||||
self.task_handler.shutdown()
|
||||
|
||||
def set_exposure_time(self, value: float) -> DeviceStatus:
|
||||
"""Utility method to set exposure time complying to device logic with cycle of min 0.2s."""
|
||||
|
||||
Reference in New Issue
Block a user