diff --git a/tomcat_bec/devices/gigafrost/pco_datasink.py b/tomcat_bec/devices/gigafrost/pco_datasink.py index 4e7c8c9..214dc8c 100644 --- a/tomcat_bec/devices/gigafrost/pco_datasink.py +++ b/tomcat_bec/devices/gigafrost/pco_datasink.py @@ -9,6 +9,7 @@ Created on Thu Jun 27 17:28:43 2024 from time import sleep, time from threading import Thread import zmq +import json from ophyd import Device, Signal, Component, Kind from ophyd_devices.interfaces.base_classes.psi_detector_base import ( CustomDetectorMixin, @@ -55,6 +56,7 @@ class PcoTestConsumerMixin(CustomDetectorMixin): """Collect streamed updates""" try: t_last = time() + print("Starting monitor") while True: try: # Exit loop and finish monitoring @@ -63,7 +65,7 @@ class PcoTestConsumerMixin(CustomDetectorMixin): break # pylint: disable=no-member - r = self.parent._socket.recv() + r = self.parent._socket.recv_multipart(flags=zmq.NOBLOCK) # Length and throtling checks t_curr = time() @@ -71,11 +73,11 @@ class PcoTestConsumerMixin(CustomDetectorMixin): if t_elapsed < self.parent.throttle.get(): continue # # Unpack the Array V1 reply to metadata and array data - # meta, data = r - # print(meta) + meta, data = r - # # Update image and update subscribers - # header = json.loads(meta) + # Update image and update subscribers + header = json.loads(meta) + self.parent.header = header # if header["type"] == "uint16": # image = np.frombuffer(data, dtype=np.uint16) # if image.size != np.prod(header['shape']): @@ -128,6 +130,8 @@ class PcoTestConsumer(PSIDetectorBase): SUB_MONITOR = "device_monitor_2d" _default_sub = SUB_MONITOR + header = None + custom_prepare_cls = PcoTestConsumerMixin # Status attributes