This commit is contained in:
gac-x05la
2025-03-24 13:41:56 +01:00
parent 5726b4349a
commit 8a2d9c3569

View File

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