From c40bebca98edb016dac99c1fecec0b0c1b41cf79 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Tue, 17 Nov 2026 14:56:17 +0100 Subject: [PATCH] Broker without hardware runs on MockAcquisitionDevice A configuration without a pcie entry gets the mock of the card (AcquisitionDeviceGroup::AddMockDevice) instead of the HLS simulation. The local run of docs/JFJOCH_BROKER.md works as before: the images uploaded as the internal generator's images are streamed and written (checked end to end with jfjoch_broker_test.py: 18 images collected, written and equal to the uploaded image outside the pixel mask); the card's spot finding, ROI and azimuthal results are zero in this mode, as the mock computes nothing. The docs and CLAUDE.md say so. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01UqXYdHHZ4cogS1mrGUtfN7 --- CLAUDE.md | 18 +++++++++++------- acquisition_device/AcquisitionDeviceGroup.cpp | 6 +++--- acquisition_device/AcquisitionDeviceGroup.h | 3 ++- broker/JFJochBrokerParser.cpp | 2 +- docs/JFJOCH_BROKER.md | 8 +++++--- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index d3ecfc9d2..f2a4ff472 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -317,9 +317,12 @@ Check first and do not duplicate a credit an adjacent comment already carries. ## Local end-to-end run (no detector / no FPGA) -The FPGA HLS logic can be simulated on the CPU (`HLSSimulatedDevice`), so the full software -stack runs without hardware (slowly — fixed-point math on CPU). See -`docs/JFJOCH_BROKER.md` for the canonical walkthrough. +Without a `pcie` entry in its config the broker runs on `MockAcquisitionDevice` +(`acquisition_device/`), a black-box mock of the FPGA card: it reproduces the card's interface +towards the host (frames, completions, counters, start/stop/cancel, internal frame generator, the +error and timeout paths) but computes nothing — the images are the uploaded generator images as +given, and the card's spot-finding/ROI/azimuthal results are zero. The same mock carries the +receiver, state-machine and writer tests. See `docs/JFJOCH_BROKER.md` for the canonical walkthrough. ``` cd build/broker @@ -400,10 +403,11 @@ with cuFFT on a GPU and with pocketfft without one (or under `--no-gpu`), while implementation each. Only rugnux's CLI spells it this way: internally (and in the broker's OpenAPI) `FFT` is the GPU implementation, which the CLI's `cufft` maps onto. -**FPGA** (`fpga/`): `hls/` is the Vitis HLS source (image-analysis kernels), `hls_simulation/` -runs that same HLS on CPU for hardware-free testing, `hdl/` is the Verilog RTL, `host_library/` is -the host-side driver, `pcie_driver/` is the kernel module. The HLS algorithms are documented in -`docs/FPGA_DATA_ANALYSIS.md`. +**FPGA** (`fpga/`): `hls/` is the Vitis HLS source (image-analysis kernels; its CPU library +`JFJochHLSCores` and the Xilinx headers in `fpga/include/` are no longer part of the software +build), `hdl/` is the Verilog RTL, `host_library/` is the host-side driver, `pcie_driver/` is the +kernel module. The HLS algorithms are documented in `docs/FPGA_DATA_ANALYSIS.md`. The software is +tested without hardware on `MockAcquisitionDevice`, not on a simulation of the firmware. **Detector control** (`detector_control/`): wrappers for SLS (JUNGFRAU) and DECTRIS SIMPLON (EIGER). **`jungfrau/`**: JUNGFRAU ADU→energy gain/pedestal calibration. diff --git a/acquisition_device/AcquisitionDeviceGroup.cpp b/acquisition_device/AcquisitionDeviceGroup.cpp index 9decc8da4..64c7a3ab2 100644 --- a/acquisition_device/AcquisitionDeviceGroup.cpp +++ b/acquisition_device/AcquisitionDeviceGroup.cpp @@ -3,7 +3,7 @@ #include "AcquisitionDeviceGroup.h" #include "PCIExpressDevice.h" -#include "HLSSimulatedDevice.h" +#include "MockAcquisitionDevice.h" AcquisitionDevice &AcquisitionDeviceGroup::operator[](int idx) { if ((idx < 0) || (idx >= aq_devices.size())) @@ -28,8 +28,8 @@ void AcquisitionDeviceGroup::AddPCIeDevice(const std::string &device_name, std:: aq_devices.emplace_back(std::move(tmp)); } -void AcquisitionDeviceGroup::AddHLSDevice(int64_t buffer_size_modules) { - aq_devices.emplace_back(std::make_unique(aq_devices.size(), buffer_size_modules)); +void AcquisitionDeviceGroup::AddMockDevice(int64_t buffer_size_modules) { + aq_devices.emplace_back(std::make_unique(aq_devices.size(), buffer_size_modules)); } std::vector AcquisitionDeviceGroup::GetNetworkConfig() { diff --git a/acquisition_device/AcquisitionDeviceGroup.h b/acquisition_device/AcquisitionDeviceGroup.h index 7044936a5..318d16917 100644 --- a/acquisition_device/AcquisitionDeviceGroup.h +++ b/acquisition_device/AcquisitionDeviceGroup.h @@ -14,7 +14,8 @@ public: size_t size(); void Add(std::unique_ptr &&device); void AddPCIeDevice(const std::string &device_name, std::optional ipv4_addr = {}); - void AddHLSDevice(int64_t buffer_size_modules); + // The mock of the card, for the broker without hardware + void AddMockDevice(int64_t buffer_size_modules); std::vector GetNetworkConfig(); std::vector GetDeviceStatus() const; void EnableLogging(Logger *logger); diff --git a/broker/JFJochBrokerParser.cpp b/broker/JFJochBrokerParser.cpp index ffbd460fa..d03ba5387 100644 --- a/broker/JFJochBrokerParser.cpp +++ b/broker/JFJochBrokerParser.cpp @@ -252,7 +252,7 @@ std::unique_ptr ParseImagePusher(const org::openapitools::server::m void ParseAcquisitionDeviceGroup(const org::openapitools::server::model::Jfjoch_settings &input, AcquisitionDeviceGroup &aq_devices) { if (!input.pcieIsSet()) - aq_devices.AddHLSDevice(256); + aq_devices.AddMockDevice(256); else for (auto &p: input.getPcie()) { std::optional ipv4_addr = {}; if (p.ipv4IsSet()) diff --git a/docs/JFJOCH_BROKER.md b/docs/JFJOCH_BROKER.md index bdcf241aa..4ff231d9a 100644 --- a/docs/JFJOCH_BROKER.md +++ b/docs/JFJOCH_BROKER.md @@ -429,9 +429,11 @@ For development, it is possible to set up a local installation of Jungfraujoch. This will work without FPGA installed in the computer and allows testing the Jungfraujoch software layer, including ZeroMQ streaming and file writing. -The workflow simulates FPGA behavior, by running high-level synthesis code on the CPU - the performance is therefore -very low, as fixed-point calculations have a large performance penalty on the CPU. In the CPU simulation mode, one can simulate -using only a single FPGA device. +Without a `pcie` entry in the configuration, the broker runs on a mock of the FPGA card (`MockAcquisitionDevice`): +it behaves like the card towards the host - frames, completions, counters, start/stop/cancel, the internal frame +generator - but computes nothing. The images streamed and written are the ones uploaded as the internal generator's +images, unconverted; the card's spot finding, ROI and azimuthal results are zero in this mode (with rugnux live on, +the GPU analysis finds its own spots). To run the test: