For a summation of N frames the card sums d, the largest divisor of N not above 256 (GetFPGASummation; 256 itself is now summed on the card), and the host the N/d card images of each image (GetHostSummation): 1000 = 250 x 4, a prime above 256 = 1 x N. CPUSummation(true) still puts all of it on the host. The card writes 32-bit where it sums and the host adds to it. FPGAImagePuller now takes summation on the host, so rugnux live runs on such collections. Each image thread keeps one int32 module accumulator per module (ModuleSummation, saturating, error pixels carried, as JFJochReceiverFPGA and the HLS do), takes the card's images of its image in order, all modules of each before the next, adds each into the accumulator and returns the card's buffer; the summed modules then go into the thread's image as before. A module missing from any card image is missing from the image. The card's per-frame spots and ROI sums were already not read on this path; the module statistics are those of the first card image with error, saturated, packet counts and pixel sum added (ModuleSummation now adds the pixel sum too). Packets expected per image and the not-blocking give-up distance are in card images (x N/d). JFJochReceiverFPGA follows the same split (it has to: the card's summation is set by the experiment), summing N/d card images instead of N frames; its end-of-run expected packets no longer multiply the run's total by the summation a second time. OpenAPI image_time_us and the broker docs describe the split; C++ model, frontend client and python client docs regenerated. Tests: the divisor rule, and N = 256 (card only), 1000 (250 x 4) and 257 (host only) on the mock through both receivers, pixels against a sum done in the test with error and saturated pixels and a 32-bit overflow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HVeDQrPqZ52Tp6rzzZGxf3
33 lines
994 B
C++
33 lines
994 B
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include "Definitions.h"
|
|
#include "DiffractionExperiment.h"
|
|
|
|
class ModuleSummation {
|
|
mutable std::mutex module_summation_mutex;
|
|
bool pixel_signed;
|
|
uint32_t output_depth_bytes;
|
|
uint32_t fpga_depth_bytes;
|
|
std::unique_ptr<DeviceOutput> output;
|
|
bool first;
|
|
bool is_empty;
|
|
public:
|
|
explicit ModuleSummation(bool pixel_signed, uint32_t fpga_depth_bytes = 2);
|
|
explicit ModuleSummation(const DiffractionExperiment &experiment);
|
|
|
|
void AddFPGAOutput(const DeviceOutput& input, const std::optional<uint32_t> &in_fpga_depth_bytes = {});
|
|
void AddEmptyOutput();
|
|
// Empty, for the next image
|
|
void Clear();
|
|
|
|
[[nodiscard]] const DeviceOutput& GetOutput() const;
|
|
[[nodiscard]] DeviceOutput& GetOutput();
|
|
[[nodiscard]] bool empty() const;
|
|
};
|