diff --git a/tomcat_bec/devices/gigafrost/gigafrostcamera.py b/tomcat_bec/devices/gigafrost/gigafrostcamera.py index 731fb9f..9ab1f92 100644 --- a/tomcat_bec/devices/gigafrost/gigafrostcamera.py +++ b/tomcat_bec/devices/gigafrost/gigafrostcamera.py @@ -88,12 +88,12 @@ class GigaFrostCameraMixin(CustomDetectorMixin): return udp_header_table - # def on_init(self) -> None: - # """ Initialize the camera, set channel values""" - # # ToDo: Not sure if it's a good idea to change camera settings upon - # # ophyd device startup, i.e. each deviceserver restart. - # self._init_gigafrost() - # self.parent._initialized = True + def on_init(self) -> None: + """ Initialize the camera, set channel values""" + # ToDo: Not sure if it's a good idea to change camera settings upon + # ophyd device startup, i.e. each deviceserver restart. + self._init_gigafrost() + self.parent._initialized = True def _init_gigafrost(self) -> None: """ Initialize the camera, set channel values""" @@ -385,7 +385,7 @@ class GigaFrostCamera(PSIDetectorBase): cfgInputPolarity2 = Component(EpicsSignalRO, "BNC5_RBV", auto_monitor=True, kind=Kind.config) infoBoardTemp = Component(EpicsSignalRO, "T_BOARD", auto_monitor=True) - USER_ACCESS = ["exposure_mode", "fix_nframes_mode", "trigger_mode", "enable_mode"] + USER_ACCESS = ["exposure_mode", "fix_nframes_mode", "trigger_mode", "enable_mode", "initialize"] autoSoftEnable = Component(Signal, kind=Kind.config) backendUrl = Component(Signal, kind=Kind.config) @@ -433,7 +433,7 @@ class GigaFrostCamera(PSIDetectorBase): status = DeviceStatus(self) sleep_time = self.cfgExposure.value*self.cfgCntNum.value*0.001+0.050 sleep(sleep_time) - logger.info("[%s] Slept for %f seconds", self.name, sleep_time) + logger.debug(f"[{self.name}] Slept for {sleep_time} seconds") status.set_finished() return status diff --git a/tomcat_bec/devices/gigafrost/stddaq_client.py b/tomcat_bec/devices/gigafrost/stddaq_client.py index 730957a..9eb7772 100644 --- a/tomcat_bec/devices/gigafrost/stddaq_client.py +++ b/tomcat_bec/devices/gigafrost/stddaq_client.py @@ -151,16 +151,26 @@ class StdDaqClient(Device): n_total = self.n_total.get() message = {"command": "start", "path": file_path, "n_image": n_total} - reply = self.message(message) - if reply is not None: - reply = json.loads(reply) - if reply["status"] in ("creating_file"): + ii = 0 + while True: + reply = self.message(message) + + if reply is not None: + reply = json.loads(reply) self.status.put(reply["status"], force=True) - elif reply["status"] in ("rejected"): - raise RuntimeError( - f"Start StdDAQ command rejected (might be already running): {reply['reason']}" - ) + # Give it more time to reconfigure + if reply["status"] in ("rejected"): + sleep(2) + else: + break + ii+=1 + if ii==5: + break + if reply is not None and reply["status"] in ("rejected"): + raise RuntimeError( + f"Start StdDAQ command rejected (might be already running): {reply['reason']}" + ) self._mon = Thread(target=self.poll, daemon=True) self._mon.start() diff --git a/tomcat_bec/devices/gigafrost/stddaq_preview.py b/tomcat_bec/devices/gigafrost/stddaq_preview.py index ce554a6..c2bd69b 100644 --- a/tomcat_bec/devices/gigafrost/stddaq_preview.py +++ b/tomcat_bec/devices/gigafrost/stddaq_preview.py @@ -75,12 +75,14 @@ class StdDaqPreviewMixin(CustomDetectorMixin): # pylint: disable=no-member r = self.parent._socket.recv_multipart(flags=zmq.NOBLOCK) + + # Length and throtling checks if len(r)!=2: - continue + logger.warning(f"[{self.parent.name}] Received malformed array of length {len(r)}") t_curr = time() t_elapsed = t_curr - t_last - if t_elapsed > self.parent.throttle.get(): + if t_elapsed < self.parent.throttle.get(): sleep(0.1) continue @@ -139,7 +141,7 @@ class StdDaqPreviewDetector(PSIDetectorBase): # Status attributes url = Component(Signal, kind=Kind.config) - throttle = Component(Signal, value=0.1, kind=Kind.config) + throttle = Component(Signal, value=0.25, kind=Kind.config) status = Component(Signal, value=StdDaqPreviewState.UNKNOWN, kind=Kind.omitted) image = Component(Signal, kind=Kind.normal) frame = Component(Signal, kind=Kind.hinted) @@ -180,5 +182,5 @@ class StdDaqPreviewDetector(PSIDetectorBase): # Automatically connect to MicroSAXS testbench if directly invoked if __name__ == "__main__": - daq = StdDaqPreviewDetector(url="tcp://129.129.95.38:20000", name="preview") + daq = StdDaqPreviewDetector(url="tcp://129.129.95.111:20000", name="preview") daq.wait_for_connection() diff --git a/tomcat_bec/scans/tomcat_scanbase.py b/tomcat_bec/scans/tomcat_scanbase.py index 3b790b6..33cb49c 100644 --- a/tomcat_bec/scans/tomcat_scanbase.py +++ b/tomcat_bec/scans/tomcat_scanbase.py @@ -71,7 +71,7 @@ class TemplatedScanBase(AsyncFlyScanBase): self.taskindex = self.caller_kwargs.get("taskindex", 4) self.camera = self.caller_kwargs.get("camera", 'gfclient') self.camcfg = self.caller_kwargs.get("camcfg", {}) - self.preview = self.caller_kwargs.get("preview", 'daq_stream0') + self.preview = self.caller_kwargs.get("preview", 'daq_stream1') self.daqname = self.caller_kwargs.get("daqname", None) self.daqcfg = self.caller_kwargs.get("daqcfg", {}) self.daqmode = self.caller_kwargs.get("daqmode", 'collect')