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 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