From 861e61aa0cd974095c3283417359247f4927ff62 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Thu, 16 Oct 2025 17:26:07 +0200 Subject: [PATCH] switch bsread Sender mode to PUB and non-blocking; select specific channels to send; re-pack data before buffering; use the correct pulse ID --- dap/accumulator.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/dap/accumulator.py b/dap/accumulator.py index 7dd18b3..904fa24 100644 --- a/dap/accumulator.py +++ b/dap/accumulator.py @@ -1,6 +1,6 @@ import argparse -from bsread.sender import Sender +from bsread.sender import Sender, PUB from utils import FileHandler, Sorter from zmqsocks import ZMQSocketsAccumulator, make_address @@ -32,7 +32,7 @@ def accumulate(accumulator_addr, bsread_port): sorter = Sorter() if bsread_port: - sender = Sender(port=bsread_port) + sender = Sender(port=bsread_port, block=False, mode=PUB) sender.open() while True: @@ -60,11 +60,20 @@ def accumulate(accumulator_addr, bsread_port): if not bsread_port: continue - sorter.add(pulse_id, results) + to_copy = ( + "pulse_id", + "frame", + "is_good_frame", + "number_of_spots", + "saturated_pixels" + ) + + data = {f"{detector}:{k}": results[k] for k in to_copy} + + sorter.add(pulse_id, data) ready = sorter.flush_ready() - for i in ready: - data = {f"{detector}:{k}": v for k, v in i.items()} - sender.send(data=data, pulse_id=pulse_id) #TODO: is there a timestamp in the input? + for pulse_id, data in ready: + sender.send(pulse_id=pulse_id, data=data) #TODO: is there a timestamp in the input?