fix: online changes in e20639 for mcs card operating full 2D grid

This commit is contained in:
e20639 2023-09-13 17:28:39 +02:00
parent 0bf308a13d
commit 67115a0658
5 changed files with 63 additions and 29 deletions

View File

@ -263,6 +263,13 @@ class DelayGeneratorDG645(Device):
config_storage_name="ddg_config",
)
fixed_ttl_width = Component(
bec_utils.ConfigSignal,
name="fixed_ttl_width",
kind="config",
config_storage_name="ddg_config",
)
amplitude = Component(
bec_utils.ConfigSignal,
name="amplitude",
@ -337,7 +344,8 @@ class DelayGeneratorDG645(Device):
parent (_type_, optional): _description_. Defaults to None.
device_manager (_type_, optional): _description_. Defaults to None.
Signals:
polarity (_type_, optional): _description_. Defaults to None.
polarity (_list_, optional): _description_. Defaults to None.
fixed_ttl_width (_list_, optional): _description_. Defaults to None.
amplitude (_type_, optional): _description_. Defaults to None.
offset (_type_, optional): _description_. Defaults to None.
thres_trig_level (_type_, optional): _description_. Defaults to None.
@ -347,19 +355,21 @@ class DelayGeneratorDG645(Device):
set_high_on_exposure
set_high_on_stage
set_trigger_source
"""
self.ddg_config = {
f"{name}_delay_burst": 0,
f"{name}_delta_width": 0,
f"{name}_additional_triggers": 0,
f"{name}_polarity": [1, 1, 1, 1, 1],
f"{name}_fixed_ttl_width": [0, 0, 0, 0, 0],
f"{name}_amplitude": 4.5,
f"{name}_offset": 0,
f"{name}_thres_trig_level": 2.5,
f"{name}_set_high_on_exposure": False,
f"{name}_set_high_on_stage": False,
f"{name}_set_trigger_source": "SINGLE_SHOT",
f"{name}_trigger_width": None,
f"{name}_trigger_width": None, # This somehow duplicates the logic of fixed_ttl_width
}
if ddg_config is not None:
[self.ddg_config.update({f"{name}_{key}": value}) for key, value in ddg_config.items()]
@ -504,6 +514,11 @@ class DelayGeneratorDG645(Device):
self.set_channels("width", exp_time)
else:
self.set_channels("width", self.trigger_width.get())
for value, channel in zip(self.fixed_ttl_width.get(), self._all_channels):
logger.info(f'{value}')
if value !=0:
logger.info(f'Setting {value}')
self.set_channels("width", value, channels=[channel])
else:
self._set_trigger(getattr(TriggerSource, self.set_trigger_source.get()))
exp_time = self.delta_width.get() + self.scaninfo.exp_time
@ -539,6 +554,11 @@ class DelayGeneratorDG645(Device):
self.set_channels("width", exp_time)
else:
self.set_channels("width", self.trigger_width.get())
for value, channel in zip(self.fixed_ttl_width.get(), self._all_channels):
logger.info(f'{value}')
if value !=0:
logger.info(f'Setting {value}')
self.set_channels("width", value, channels=[channel])
else:
# define parameters
self._set_trigger(getattr(TriggerSource, self.set_trigger_source.get()))

View File

@ -194,8 +194,8 @@ class Eiger9mCsaxs(DetectorBase):
self.std_client.stop_writer()
timeout = 0
#TODO put back change of e-account!
#self._update_std_cfg("writer_user_id", int(self.scaninfo.username.strip(" e")))
#time.sleep(5)
# self._update_std_cfg("writer_user_id", int(self.scaninfo.username.strip(" e")))
# time.sleep(5)
while not self.std_client.get_status()["state"] == "READY":
time.sleep(0.1)
timeout = timeout + 0.1
@ -354,7 +354,7 @@ class Eiger9mCsaxs(DetectorBase):
break
time.sleep(0.1)
timer += 0.1
if timer > 8:
if timer > 5:
self._stopped == True
self._close_file_writer()
raise EigerTimeoutError(

View File

@ -223,7 +223,7 @@ class McsCsaxs(SIS38XX):
self._set_trigger(TriggerSource.MODE3)
self.input_polarity.set(0)
self.output_polarity.set(1)
self.count_on_start.set(1)
self.count_on_start.set(0)
self.stop_all.set(1)
def _progress_update(self, value, **kwargs) -> None:
@ -231,7 +231,7 @@ class McsCsaxs(SIS38XX):
max_value = self.scaninfo.num_points
self._run_subs(
sub_type=self.SUB_PROGRESS,
value=self.counter * int(self.scaninfo.num_points / num_lines) + max(value - 1, 0),
value=self.counter * int(self.scaninfo.num_points / num_lines) + value ,
max_value=max_value,
done=bool(max_value == self.counter),
)
@ -240,27 +240,31 @@ class McsCsaxs(SIS38XX):
def _on_mca_data(self, *args, obj=None, **kwargs) -> None:
if not isinstance(kwargs["value"], (list, np.ndarray)):
return
self.mca_data[obj.attr_name] = kwargs["value"][1:]
#self.mca_data[obj.attr_name] = kwargs["value"][1:]
self.mca_data[obj.attr_name] = kwargs["value"]
if len(self.mca_names) != len(self.mca_data):
return
#logger.info("Entered _on_mca_data")
self._updated = True
self.counter += 1
# self._updated = True
# self.counter += 1
#logger.info(f'data from mca {self.mca_data["mca1"]} and {self.mca_data["mca4"]}')
if (self.scaninfo.scan_type == "fly" and self.counter == self.num_lines.get()) or (
self.scaninfo.scan_type == "step" and self.counter == self.scaninfo.num_points
):
self._acquisition_done = True
self.stop_all.put(1, use_complete=False)
self._send_data_to_bec()
self.erase_all.put(1)
#logger.info("Entered _on_mca_data, acquisition finished")
# Require wait for
# time.sleep(0.01)
self.mca_data = defaultdict(lambda: [])
self.counter = 0
return
self.erase_start.set(1)
# if (self.scaninfo.scan_type == "fly" and self.counter == self.num_lines.get()) or (
# self.scaninfo.scan_type == "step" and self.counter == self.scaninfo.num_points
# ):
# self._acquisition_done = True
# self.stop_all.put(1, use_complete=False)
# self._send_data_to_bec()
# self.erase_all.put(1)
# #logger.info("Entered _on_mca_data, acquisition finished")
# # Require wait for
# # time.sleep(0.01)
# self.mca_data = defaultdict(lambda: [])
# self.counter = 0
# return
# self.erase_start.set(1)
# self._send_data_to_bec()
# self.mca_data = defaultdict(lambda: [])
self._acquisition_done = True
self._send_data_to_bec()
self.mca_data = defaultdict(lambda: [])
@ -292,9 +296,9 @@ class McsCsaxs(SIS38XX):
def _set_acquisition_params(self) -> None:
if self.scaninfo.scan_type == "step":
self.n_points = int(self.scaninfo.frames_per_trigger + 1)
self.n_points = int(self.scaninfo.frames_per_trigger)
elif self.scaninfo.scan_type == "fly":
self.n_points = int(self.scaninfo.num_points / int(self.num_lines.get()) + 1)
self.n_points = int(self.scaninfo.num_points)# / int(self.num_lines.get()))
else:
raise McsError(f"Scantype {self.scaninfo} not implemented for MCS card")
if self.n_points > 10000:
@ -377,7 +381,7 @@ class McsCsaxs(SIS38XX):
if timer > 8:
total_frames = self.counter * int(
self.scaninfo.num_points / self.num_lines.get()
) + max(self.current_channel.get() - 1, 0)
) + max(self.current_channel.get(), 0)
raise McsTimeoutError(
f"Reached timeout with mcs in state {self.acquiring.get()} and {total_frames} frames arriving at the mcs card"
)

View File

@ -210,10 +210,16 @@ class PilatusCsaxs(DetectorBase):
a zmq service is running on xbl-daq-34 that is waiting
for a zmq message to start the writer for the pilatus_2 x12sa-pd-2
"""
#TODO worked reliable with time.sleep(2)
# self._close_file_writer()
# time.sleep(2)
# self._stop_file_writer()
# time.sleep(2)
self._close_file_writer()
time.sleep(2)
time.sleep(.1)
self._stop_file_writer()
time.sleep(2)
time.sleep(.1)
self.filepath_h5 = self.filewriter.compile_full_filename(
self.scaninfo.scan_number, "pilatus_2.h5", 1000, 5, True
)

View File

@ -689,6 +689,10 @@ class SGalilMotor(Device, PositionerBase):
def stop(self, *, success=False):
self.controller.stop_all_axes()
#last_speed = self.controller.socket_put_and_receive("MG")
rtr = self.controller.socket_put_and_receive(f'SPC={2*10000}')
logger.info(f"{rtr}")
#logger.info(f'Motor stopped, restored speed for samy from {last_speed}mm/s to 2mm/s')
return super().stop(success=success)
def kickoff(self) -> DeviceStatus: