wip
This commit is contained in:
@@ -148,6 +148,7 @@ class Timepix(PSIDeviceBase, TimePixControl):
|
||||
self._troistep = 1
|
||||
self._troin = 5000
|
||||
self._pv_timeout = 3
|
||||
self._readout_time = 2e-3 # 2ms readout time
|
||||
super().__init__(
|
||||
name=name, prefix=prefix, scan_info=scan_info, device_manager=device_manager, **kwargs
|
||||
)
|
||||
@@ -227,13 +228,20 @@ class Timepix(PSIDeviceBase, TimePixControl):
|
||||
# TODO discuss if the acquire period should be equivalent to the exposure time,
|
||||
# and acquire time always 2ms shorter than the acquire period.
|
||||
# num_images is currently hardcoded, is this basically a burst frame at each point of a step scan?
|
||||
self.cam.acquire_time.set(0.998).wait(timeout=self._pv_timeout)
|
||||
self.cam.acquire_period.set(1.0).wait(timeout=self._pv_timeout)
|
||||
self.cam.num_images.set(10).wait(timeout=self._pv_timeout)
|
||||
exp_time = self.scan_info.msg.scan_parameters.get("exp_time", 1) # TODO remove hardcoded 1
|
||||
if exp_time - self._readout_time <= 0:
|
||||
raise ValueError(
|
||||
f"Exposure time {exp_time} must be greater than readout time {self._readout_time}."
|
||||
)
|
||||
num_images = self.scan_info.msg.scan_parameters.get(
|
||||
"frames_per_trigger", 1
|
||||
) # TODO remove hardcoded 1
|
||||
|
||||
self.cam.acquire_time.set(exp_time - self._readout_time).wait(timeout=self._pv_timeout)
|
||||
self.cam.acquire_period.set(exp_time).wait(timeout=self._pv_timeout)
|
||||
self.cam.num_images.set(num_images).wait(timeout=self._pv_timeout)
|
||||
self.cam.raw_enable.set(1).wait(timeout=self._pv_timeout)
|
||||
# TODO: can we inspect this from the backend instead!!
|
||||
self.cam.raw_file_template.set("").wait(timeout=self._pv_timeout)
|
||||
self.cam.raw_file_path.set(f"tcp://connect@127.0.0.1:8451").wait(timeout=self._pv_timeout)
|
||||
|
||||
# -------------------------
|
||||
# Prepare TimePixFly
|
||||
@@ -248,6 +256,12 @@ class Timepix(PSIDeviceBase, TimePixControl):
|
||||
pixel_map = self.pixel_map
|
||||
self.backend.on_stage(other_config=other_config, pixel_map=pixel_map)
|
||||
|
||||
# Fetch the backend socket info
|
||||
net_add = self.backend.timepix_fly_client.get_net_addresses()
|
||||
print(f"TimePixFly backend is listening on: {net_add.get('address', '')}")
|
||||
self.cam.raw_file_template.set("").wait(timeout=self._pv_timeout)
|
||||
self.cam.raw_file_path.set(f"tcp://connect@127.0.0.1:8451").wait(timeout=self._pv_timeout)
|
||||
|
||||
def on_unstage(self) -> None:
|
||||
"""Called while unstaging the device."""
|
||||
# Camera to do?
|
||||
@@ -332,10 +346,15 @@ if __name__ == "__main__": # pragma: no cover
|
||||
print("Timepix staged.")
|
||||
timepix.pre_scan()
|
||||
print("Timepix pre-scan completed.")
|
||||
timepix.scan_info.msg.scan_parameters.update(
|
||||
{
|
||||
"exp_time": 0.2, # Set exposure time to 0.2 seconds for testing
|
||||
"frames_per_trigger": 10, # Set frames per trigger to 10 for testing
|
||||
}
|
||||
)
|
||||
msgs = []
|
||||
for ii in range(5):
|
||||
print(f"Starting scan {ii + 1}...; sleeping for 1s before each trigger before start")
|
||||
time.sleep(1)
|
||||
status = timepix.trigger()
|
||||
print("Timepix trigger sent.")
|
||||
start_time = time.time()
|
||||
|
||||
Reference in New Issue
Block a user