Compare commits

..

42 Commits

Author SHA1 Message Date
7044f7b085 Logger: handle situation when git sha1 is empty 2024-05-14 22:22:15 +02:00
165fe1a432 FPGA: build script is safe for situations when git is absent 2024-05-14 22:21:58 +02:00
ad2bc91582 Remove .gitmodules file 2024-05-14 21:53:43 +02:00
c1e9cc5d3c Update spdlog (working on better integration) 2024-05-14 21:51:17 +02:00
eb0e5daf8f catch2: download with CMake + update to recent Catch2 2024-05-14 21:31:34 +02:00
9f1b6a6e96 fast-feedback-indexer: download with CMake 2024-05-14 20:57:29 +02:00
81db3af275 slsDetectorPackage: download with CMake 2024-05-14 20:54:42 +02:00
8cd5787848 bitshuffle_hperf: put directly into the repository 2024-05-14 20:50:12 +02:00
ebd3628eab bitshuffle_hperf: put directly into the repository 2024-05-14 20:48:15 +02:00
e02f8692f9 zstd: built via cmake 2024-05-14 20:42:34 +02:00
f27126fa1f pistache: built via cmake 2024-05-14 20:36:50 +02:00
d2c5b9c038 tinycbor: internal to repository 2024-05-14 20:30:19 +02:00
ff191c8490 tinycbor: remove submodule 2024-05-14 20:28:43 +02:00
ced40a7170 PreviewImage: Add resolution ring (experimental) 2024-05-14 18:53:11 +02:00
37e825a018 FPGA: Spot finder masks module edges, improve testing in this regard 2024-05-14 18:01:40 +02:00
36257d7009 CI: Create release as part of CI - should be working now 2024-05-14 17:39:58 +02:00
786b28ed78 CI: Create release as part of CI (another try) 2024-05-14 17:21:22 +02:00
bd86809bdd CI: Create release as part of CI (another try) 2024-05-14 17:05:39 +02:00
af366acb08 CI: Create release as part of CI (another try) 2024-05-14 16:40:42 +02:00
4fe2904b47 CI: Create release as part of CI (try again) 2024-05-14 15:12:39 +02:00
c97749c16a CI: Create release as part of CI 2024-05-14 14:54:47 +02:00
bd43b09b4c Revert "CI: More serious test of package registry"
This reverts commit dcd6088afe.
2024-05-14 14:45:26 +02:00
dcd6088afe CI: More serious test of package registry 2024-05-14 14:39:26 +02:00
b4c26b036f CI: Try release pipeline with runner tag 2024-05-14 14:29:02 +02:00
b2a7dadef7 CI: Try release pipeline 2024-05-14 14:21:00 +02:00
5808d2c5bc VERSION: Add package version to git 2024-05-14 14:05:14 +02:00
c71728e16f Dockerfile: add comment for MAX IV 2024-05-14 13:49:42 +02:00
10b8398bd0 CI: test 2024-05-14 13:29:55 +02:00
9c1796a9e6 CMake: Remove ZeroMQ CMake module 2024-05-07 15:27:34 +02:00
3cbf675120 CI: Building HLS is NOT requirement to build firmware (it will fail anyway 2024-05-07 15:12:58 +02:00
1aa1da92ff CI: Fix FPGA .mcs name and FPGA build is optional if not required 2024-05-07 15:11:53 +02:00
07a1659e94 CI: Fix FPGA .mcs name 2024-05-07 15:09:53 +02:00
bc1285acc6 CI: FPGA HLS is built in parallel with 4 threads 2024-05-07 14:45:35 +02:00
c330a0ed81 CI: FPGA images are called jfjoch_fpga_{FLOW}.mcs 2024-05-07 14:43:30 +02:00
cdba3000d2 README.md: Linkt to broker/writer subdirectories 2024-05-07 14:34:24 +02:00
db47da3b6d README.md: Remove part on .mcs naming 2024-05-07 14:33:22 +02:00
d3420d7f0c CI: Fix driver artifact 2024-05-07 14:13:58 +02:00
975442f452 README.md: Remove CompressionBenchmark 2024-05-07 14:13:28 +02:00
4c87554233 nextgendcu/broker/README.md: Updates 2024-05-07 14:12:15 +02:00
b5da66baf6 CompressionBenchmark: Remove 2024-05-07 14:11:21 +02:00
69d34e22f7 CI: Update 2024-05-07 14:05:51 +02:00
89cf520e52 FPGAIntegrationTest: Truncate number of test images 2024-05-07 14:00:15 +02:00
246 changed files with 5083 additions and 10659 deletions

3
.gitignore vendored
View File

@@ -1,3 +0,0 @@
cmake-build-debug/
cmake-build-release/
build*/

View File

@@ -7,6 +7,7 @@ stages:
build:x86:gcc:
stage: build
variables:
GIT_SUBMODULE_STRATEGY: recursive
CC: gcc
CXX: g++
tags:
@@ -23,6 +24,7 @@ build:x86:gcc:
build:x86:gcc_writer:
stage: build
variables:
GIT_SUBMODULE_STRATEGY: recursive
CC: gcc
CXX: g++
tags:
@@ -34,11 +36,12 @@ build:x86:gcc_writer:
- cd build
- source /opt/rh/gcc-toolset-12/enable
- cmake -DCMAKE_BUILD_TYPE=Release -DJFJOCH_WRITER_ONLY=ON ..
- make -j48
- make -j48 jfjoch
build:x86:driver:
stage: build
variables:
GIT_SUBMODULE_STRATEGY: recursive
CC: gcc
CXX: g++
tags:
@@ -57,6 +60,8 @@ build:x86:driver:
build:x86:vitis_hls:
stage: build
variables:
GIT_SUBMODULE_STRATEGY: recursive
tags:
- x86
needs: []
@@ -79,44 +84,27 @@ build:x86:vitis_hls:
build:x86:frontend:
stage: build
variables:
GIT_SUBMODULE_STRATEGY: recursive
tags:
- x86
needs: []
script:
- mkdir build
- cd frontend_ui
- npm install
- npm run build
- cd build
- /usr/bin/cmake ..
- make frontend
- cd ../frontend_ui/build
- tar czf ../../jfjoch_frontend.tar.gz *
artifacts:
paths:
- jfjoch_frontend.tar.gz
expire_in: 1 week
build:x86:rpm:
stage: build
tags:
- x86
needs: []
script:
- mkdir build
- cd build
- source /opt/rh/gcc-toolset-12/enable
- cmake -DCMAKE_BUILD_TYPE=Release ..
- make update_version
- make frontend
- make -j48 package
- mv *.rpm ..
artifacts:
paths:
- "*.rpm"
expire_in: 1 week
test:x86:gcc:
stage: test
timeout: 90m
variables:
GIT_SUBMODULE_STRATEGY: recursive
CTEST_OUTPUT_ON_FAILURE: 1
CC: gcc
CXX: g++
@@ -130,9 +118,9 @@ test:x86:gcc:
- mkdir -p build
- cd build
- cmake -DCMAKE_BUILD_TYPE=Release ..
- make -j48 jfjoch_test HDF5DatasetWriteTest
- make -j48 CatchTest HDF5DatasetWriteTest
- cd tests
- ./jfjoch_test -r junit -o report.xml
- ./CatchTest -r junit -o report.xml
- cd ../tools
- ./HDF5DatasetWriteTest ../../tests/test_data/compression_benchmark.h5
artifacts:
@@ -144,6 +132,7 @@ test:x86:crystfel:
stage: test
timeout: 90m
variables:
GIT_SUBMODULE_STRATEGY: recursive
CTEST_OUTPUT_ON_FAILURE: 1
CC: gcc
CXX: g++
@@ -167,6 +156,7 @@ test:x86:xds_durin:
stage: test
timeout: 90m
variables:
GIT_SUBMODULE_STRATEGY: recursive
CTEST_OUTPUT_ON_FAILURE: 1
CC: gcc
CXX: g++
@@ -190,6 +180,7 @@ test:x86:xds_neggia:
stage: test
timeout: 90m
variables:
GIT_SUBMODULE_STRATEGY: recursive
CTEST_OUTPUT_ON_FAILURE: 1
CC: gcc
CXX: g++
@@ -213,6 +204,7 @@ test:x86:xia2.ssx:
stage: test
timeout: 90m
variables:
GIT_SUBMODULE_STRATEGY: recursive
CTEST_OUTPUT_ON_FAILURE: 1
CC: gcc
CXX: g++
@@ -238,6 +230,7 @@ synthesis:vivado_pcie_100g:
stage: synthesis
dependencies: []
variables:
GIT_SUBMODULE_STRATEGY: recursive
CC: gcc
CXX: g++
rules:
@@ -250,9 +243,10 @@ synthesis:vivado_pcie_100g:
- fpga/scripts/*
- fpga/xdc/*
- fpga/pcie_driver/jfjoch_fpga.h
- when: manual
allow_failure: true
tags:
- vivado
retry: 1
artifacts:
paths:
- "jfjoch_fpga_pcie_100g.mcs"
@@ -272,6 +266,7 @@ synthesis:vivado_pcie_8x10g:
stage: synthesis
dependencies: []
variables:
GIT_SUBMODULE_STRATEGY: recursive
CC: gcc
CXX: g++
rules:
@@ -284,9 +279,10 @@ synthesis:vivado_pcie_8x10g:
- fpga/xdc/*
- fpga/pcie_driver/jfjoch_fpga.h
allow_failure: true
- when: manual
allow_failure: true
tags:
- vivado
retry: 1
artifacts:
paths:
- "jfjoch_fpga_pcie_8x10g.mcs"
@@ -304,9 +300,7 @@ synthesis:vivado_pcie_8x10g:
release:
stage: release
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: manual
when: manual
tags:
- x86
dependencies:
@@ -314,24 +308,16 @@ release:
- synthesis:vivado_pcie_100g
- build:x86:frontend
- build:x86:driver
- build:x86:rpm
script:
- export PACKAGE_VERSION_SEM=`head -n1 VERSION`
- export PACKAGE_VERSION=${PACKAGE_VERSION_SEM//-/_}
- export PACKAGE_REGISTRY_URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/jungfraujoch/${PACKAGE_VERSION_SEM}"
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file jfjoch-driver-dkms-${PACKAGE_VERSION}-1.el8.noarch.rpm "${PACKAGE_REGISTRY_URL}/jfjoch-driver-dkms-${PACKAGE_VERSION}-1.el8.noarch.rpm"'
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file jfjoch-writer-${PACKAGE_VERSION}-1.el8.x86_64.rpm "${PACKAGE_REGISTRY_URL}/jfjoch-writer-${PACKAGE_VERSION}-1.el8.x86_64.rpm"'
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file jfjoch-${PACKAGE_VERSION}-1.el8.x86_64.rpm "${PACKAGE_REGISTRY_URL}/jfjoch-${PACKAGE_VERSION}-1.el8.x86_64.rpm"'
- export PACKAGE_VERSION=`head -n1 VERSION`
- export PACKAGE_REGISTRY_URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/jungfraujoch/${PACKAGE_VERSION}"
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file jfjoch_driver.tar.gz "${PACKAGE_REGISTRY_URL}/jfjoch_driver.tar.gz"'
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file jfjoch_frontend.tar.gz "${PACKAGE_REGISTRY_URL}/jfjoch_frontend.tar.gz"'
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file jfjoch_fpga_pcie_100g.mcs "${PACKAGE_REGISTRY_URL}/jfjoch_fpga_pcie_100g.mcs"'
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file jfjoch_fpga_pcie_8x10g.mcs "${PACKAGE_REGISTRY_URL}/jfjoch_fpga_pcie_8x10g.mcs"'
- >
release-cli create --name "Release $PACKAGE_VERSION_SEM" --tag-name $PACKAGE_VERSION_SEM
release-cli create --name "Release $PACKAGE_VERSION" --tag-name $PACKAGE_VERSION
--assets-link "{\"name\":\"jfjoch_driver.tar.gz\",\"url\":\"${PACKAGE_REGISTRY_URL}/jfjoch_driver.tar.gz\"}"
--assets-link "{\"name\":\"jfjoch_frontend.tar.gz\",\"url\":\"${PACKAGE_REGISTRY_URL}/jfjoch_frontend.tar.gz\"}"
--assets-link "{\"name\":\"jfjoch_fpga_pcie_8x10g.mcs\",\"url\":\"${PACKAGE_REGISTRY_URL}/jfjoch_fpga_pcie_8x10g.mcs\"}"
--assets-link "{\"name\":\"jfjoch_fpga_pcie_100g.mcs\",\"url\":\"${PACKAGE_REGISTRY_URL}/jfjoch_fpga_pcie_100g.mcs\"}"
--assets-link "{\"name\":\"jfjoch-${PACKAGE_VERSION}-1.el8.x86_64.rpm\",\"url\":\"${PACKAGE_REGISTRY_URL}/jfjoch-${PACKAGE_VERSION}-1.el8.x86_64.rpm\",\"link_type\":\"package\"}"
--assets-link "{\"name\":\"jfjoch-writer-${PACKAGE_VERSION}-1.el8.x86_64.rpm\",\"url\":\"${PACKAGE_REGISTRY_URL}/jfjoch-writer-${PACKAGE_VERSION}-1.el8.x86_64.rpm\",\"link_type\":\"package\"}"
--assets-link "{\"name\":\"jfjoch-driver-dkms-${PACKAGE_VERSION}-1.el8.noarch.rpm\",\"url\":\"${PACKAGE_REGISTRY_URL}/jfjoch-driver-dkms-${PACKAGE_VERSION}-1.el8.noarch.rpm\",\"link_type\":\"package\"}"

View File

@@ -1,9 +1,7 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.19)
FILE(STRINGS VERSION JFJOCH_VERSION)
PROJECT(jfjoch VERSION 1.0.0 LANGUAGES C CXX)
SET(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
PROJECT(Jungfraujoch VERSION 1.0 LANGUAGES C CXX)
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
SET(CMAKE_CXX_STANDARD 20)
SET(CMAKE_CXX_STANDARD_REQUIRED True)
@@ -11,31 +9,8 @@ SET(CMAKE_CXX_STANDARD_REQUIRED True)
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -mtune=native -Wno-deprecated-enum-enum-conversion")
SET(CMAKE_C_FLAGS_RELEASE "-O3 -march=native -mtune=native")
SET(BUILD_SHARED_LIBS OFF)
SET(BUILD_TESTING OFF)
SET(ZSTD_LEGACY_SUPPORT OFF)
SET(ZSTD_MULTITHREAD_SUPPORT OFF)
SET(ZSTD_BUILD_PROGRAMS OFF)
SET(ZSTD_BUILD_SHARED OFF)
SET(SLS_USE_RECEIVER OFF)
SET(SLS_USE_RECEIVER_BINARIES OFF)
SET(SLS_BUILD_SHARED_LIBRARIES OFF)
SET(BUILD_FAST_INDEXER OFF)
SET(BUILD_FAST_INDEXER_STATIC ON)
SET(HDF5_ENABLE_SZIP_SUPPORT OFF)
SET(HDF5_ENABLE_SZIP_ENCODING OFF)
SET(HDF5_BUILD_EXAMPLES OFF)
SET(HDF5_BUILD_CPP_LIB OFF)
SET(HDF5_ENABLE_Z_LIB_SUPPORT OFF)
SET(HDF5_EXTERNALLY_CONFIGURED 1)
SET(jbig OFF)
SET(zstd OFF)
SET(lzma OFF)
INCLUDE(CheckLanguage)
CHECK_LANGUAGE(CUDA)
@@ -56,28 +31,23 @@ SET(JFJOCH_WRITER_ONLY OFF CACHE BOOL "Compile HDF5 writer only")
INCLUDE_DIRECTORIES(include)
INCLUDE(CheckIncludeFile)
#This is to supress error in TORCH
IF ((NOT EXISTS /usr/bin/python) AND (EXISTS /usr/bin/python3))
SET(PYTHON_EXECUTABLE /usr/bin/python3)
ENDIF()
FIND_PACKAGE(Torch HINTS /opt/libtorch/share/cmake/Torch/)
FIND_LIBRARY(NUMA_LIBRARY NAMES numa DOC "NUMA Library")
CHECK_INCLUDE_FILE(numaif.h HAS_NUMAIF)
CHECK_INCLUDE_FILE(numa.h HAS_NUMA_H)
include(FetchContent)
FetchContent_Declare(tiff
GIT_REPOSITORY https://github.com/fleon-psi/libtiff
GIT_TAG v4.6.0
EXCLUDE_FROM_ALL)
FetchContent_Declare(hdf5
GIT_REPOSITORY https://github.com/HDFGroup/hdf5/
GIT_TAG hdf5_1.14.4.2
GIT_SHALLOW 1
EXCLUDE_FROM_ALL)
FetchContent_Declare(
pistache_http
GIT_REPOSITORY https://github.com/fleon-psi/pistache
GIT_TAG 51553b92cc7bb25ac792462722ddd4fae33d14b1
EXCLUDE_FROM_ALL
)
FetchContent_Declare(
@@ -85,7 +55,6 @@ FetchContent_Declare(
GIT_REPOSITORY https://github.com/facebook/zstd
GIT_TAG 794ea1b0afca0f020f4e57b6732332231fb23c70
SOURCE_SUBDIR build/cmake
EXCLUDE_FROM_ALL
)
FetchContent_Declare(
@@ -98,10 +67,9 @@ FetchContent_Declare(
catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2
GIT_TAG 4e8d92b
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(pistache_http zstd sls_detector_package catch2 hdf5 tiff)
FetchContent_MakeAvailable(pistache_http zstd sls_detector_package catch2)
ADD_SUBDIRECTORY(jungfrau)
ADD_SUBDIRECTORY(compression)
@@ -112,6 +80,7 @@ ADD_SUBDIRECTORY(frame_serialize)
ADD_SUBDIRECTORY(detector_control)
IF (JFJOCH_WRITER_ONLY)
MESSAGE(STATUS "Compiling HDF5 writer only")
SET(jfjoch_executables jfjoch_writer)
ELSE()
ADD_SUBDIRECTORY(broker)
ADD_SUBDIRECTORY(fpga)
@@ -121,61 +90,17 @@ ELSE()
ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY(tools)
ADD_SUBDIRECTORY(preview)
ADD_SUBDIRECTORY(resonet)
SET(jfjoch_executables jfjoch_broker jfjoch_writer CatchTest CompressionBenchmark HDF5DatasetWriteTest jfjoch_udp_simulator sls_detector_put sls_detector_get)
ENDIF()
IF (NOT JFJOCH_WRITER_ONLY)
ADD_CUSTOM_COMMAND(OUTPUT frontend_ui/build/index.html
COMMAND npm install
COMMAND npm run build
COMMAND npm run redocly
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/frontend_ui)
ADD_CUSTOM_TARGET(frontend DEPENDS frontend_ui/build/index.html)
ADD_CUSTOM_COMMAND(OUTPUT frontend_ui/build/index.html
COMMAND npm run build
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/frontend_ui)
ADD_CUSTOM_TARGET(frontend DEPENDS frontend_ui/build/index.html)
ADD_CUSTOM_TARGET(update_version
COMMAND bash update_version.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/fpga/pcie_driver/
DESTINATION /usr/src/jfjoch-${JFJOCH_VERSION}
COMPONENT driver-dkms
FILES_MATCHING PATTERN "dkms.conf")
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/fpga/pcie_driver/
DESTINATION /usr/src/jfjoch-${JFJOCH_VERSION}/src
COMPONENT driver-dkms
FILES_MATCHING PATTERN "*.c" PATTERN "*.h" PATTERN "Makefile")
FILE(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/frontend_ui/build/)
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/frontend_ui/build/ DESTINATION share/jfjoch/frontend COMPONENT jfjoch )
ENDIF()
ADD_CUSTOM_TARGET(jfjoch DEPENDS ${jfjoch_executables})
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET(CMAKE_INSTALL_PREFIX /opt/jfjoch CACHE PATH "Default directory" FORCE)
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# Set Package Name
set(CPACK_PACKAGE_NAME "jfjoch")
SET(CPACK_COMPONENTS_ALL jfjoch writer driver-dkms)
SET(CPACK_GENERATOR RPM)
SET(CPACK_RPM_COMPONENT_INSTALL ON)
SET(CPACK_RPM_MAIN_COMPONENT jfjoch)
SET(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
SET(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
SET(CPACK_RPM_PACKAGE_VERSION ${JFJOCH_VERSION})
SET(CPACK_RPM_PACKAGE_RELEASE 1)
SET(CPACK_RPM_PACKAGE_SUMMARY "Jungfraujoch data acquisition system")
SET(CPACK_RPM_PACKAGE_DESCRIPTION "Jungfraujoch")
SET(CPACK_RPM_DRIVER-DKMS_PACKAGE_REQUIRES "dkms, gcc, bash, sed")
SET(CPACK_RPM_DRIVER-DKMS_PACKAGE_ARCHITECTURE "noarch")
SET(CPACK_RPM_DRIVER-DKMS_POST_INSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/fpga/pcie_driver/postinstall.sh)
SET(CPACK_RPM_DRIVER-DKMS_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/fpga/pcie_driver/preuninstall.sh)
SET(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /usr/src)
# Set The Vendor Name
SET(CPACK_PACKAGE_VENDOR "Paul Scherrer Institut")
# Set The License Information
SET(CPACK_RPM_PACKAGE_LICENSE "Proprietary")
INCLUDE(CPack)

View File

@@ -4,7 +4,7 @@ FROM harbor.maxiv.lu.se/dockerhub/library/ubuntu:22.04
RUN set -ex; \
apt-get update; \
apt-get install -y pkg-config git cmake make g++;\
apt-get install -y pkg-config git cmake make g++ libhdf5-dev libczmq-dev;\
rm -rf /var/lib/apt/lists/*

View File

@@ -7,7 +7,6 @@ Citation: F. Leonarski, M. Bruckner, C. Lopez-Cuenca, A. Mozzanica, H.-C. Stadle
The project is supported by :
* Innosuisse via Innovation Project "NextGenDCU high data rate acquisition system for X-ray detectors in structural biology applications" (101.535.1 IP-ENG; Apr 2023 - Sep 2025).
* ETH Domain via Open Research Data Contribute project (Jan - Dec 2023)
* AMD University Program with donation of licenses of Ethernet IP cores and Vivado software
## License
@@ -34,24 +33,25 @@ Other linux platforms should work, but no tests were done so far.
### Dependencies
Required:
* C++20 compiler and C++20 standard library; recommended GCC 11+ or clang 14+ (Intel OneAPI, AMD AOCC)
* CMake version 3.21 or newer + GNU make tool
* CMake version 3.21 or newer + GNU make tool
* HDF5 library version 1.10 or newer
* TIFF library (with C++ headers)
* JPEG library (turbo-jpeg is also OK)
Optional:
* CUDA compiler version 11 or newer - required for MX fast feedback indexer
* CUDA compiler version 11 or newer - required for MX indexing and ML resolution estimation
* NUMA library - to pin threads to nodes/CPUs
* Node.js - to make frontend
* libtorch - for resolution estimation using model from Stanford - see below
Automatically downloaded by CMake and statically linked:
Automatically downloaded by CMake:
* SLS Detector Package - see [github.com/slsdetectorgroup/slsDetectorPackage](https://github.com/slsdetectorgroup/slsDetectorPackage)
* Zstandard (Facebook) - see [github.com/facebook/zstd](https://github.com/facebook/zstd)
* Pistache webserver - see [github.com/pistacheio/pistache](https://github.com/pistacheio/pistache)
* Fast feedback indexer (Hans-Christian Stadler, PSI) - see [github.com/paulscherrerinstitute/fast-feedback-indexer](https://github.com/paulscherrerinstitute/fast-feedback-indexer)
* Catch2 testing library - see [github.com/catchorg/Catch2](https://github.com/catchorg/Catch2)
* HDF5 library - see [github.com/HDFGroup/hdf5](https://github.com/HDFGroup/hdf5)
* TIFF library - see [gitlab.com/libtiff/libtiff](https://gitlab.com/libtiff/libtiff)
Please follow the link provided above to check for LICENSE file. Building code with dependencies above requires access from the build system to github.com.
Please follow the link provided above to check for LICENSE file
Directly included in the repository:
* JSON parser/writer from N. Lohmann - see [github.com/nlohmann/json](https://github.com/nlohmann/json)
@@ -76,6 +76,7 @@ For license check LICENSE file in respective directory
Use the following commands:
```
git submodule update --init --recursive
mkdir build
cd build
cmake ..
@@ -87,6 +88,7 @@ In most use cases it is better to have a separate machine, with access to distri
Such machine needs only a HDF5 writer service with fewer dependencies. For compilation use the following commands:
```
git submodule update --init --recursive
mkdir build
cd build
cmake -DJFJOCH_WRITER_ONLY=ON ..
@@ -110,6 +112,7 @@ Frontend is written in TypeScript. For details see [frontend_ui/](frontend_ui) d
Jungfraujoch Cmake scripts have an option to start frontend build with the following command:
```
git submodule update --init --recursive
mkdir build
cd build
cmake ..
@@ -119,7 +122,7 @@ Contrary to standard CMake way, frontend will be built in "source" `frontend_ui/
## Tests
Automated test routine is then accessible as `tests/jfjoch_test`. There are also benchmark routines:
Automated test routine is then accessible as `tests/CatchTest`. There are also benchmark routines:
* `HDF5DatasetWriteTest` to measure HDF5 dataset writing speed (single threaded)
* `jfjoch_spot_finding_test` to apply spot finding and indexing routines in Jungfraujoch to an example dataset - this is equivalent to FPGA spot finding algorithm, but NOT performance equivalent as it is particularly not-efficient
@@ -127,3 +130,16 @@ Automated test routine is then accessible as `tests/jfjoch_test`. There are also
In addition, tests are executed to verify that datasets written by Jungfraujoch are readable with XDS Durin plugin, XDS Neggia plygin and CrystFEL.
Input files for these programs are placed in `xds_durin`, `xds_neggia` and `crystfel` folders. See `.gitlab-ci.yml` for details.
## Resolution estimation
Resolution estimation can be done with a recent deep learning model by D. Mendez et al.
(see [Acta Cryst D, 80, 26-43](https://doi.org/10.1107/S2059798323010586)), adapted to Jungfraujoch.
Model used in the original paper is located in the [resonet/](resonet) directory, after converting to TorchScript format.
To use the feature it is necessary to install [libtorch](https://pytorch.org/) library, preferably in `/opt/libtorch` location. The C++11 ABI version needs to be chosen.
For RHEL 8 systems, please download older version 2.1.0, as version 2.2.0 requires newer `glibc` library than available with the operating system.
Version 2.1.0 can be downloaded with the following command:
```
wget https://download.pytorch.org/libtorch/cu121/libtorch-cxx11-abi-shared-with-deps-2.1.0%2Bcu121.zip
```

View File

@@ -1 +1 @@
1.0.0-rc.12
1.0.0-test5

View File

@@ -247,11 +247,6 @@ void FPGAAcquisitionDevice::FillActionRegister(const DiffractionExperiment& x, D
if (x.GetPixelDepth() == 4)
job.mode |= MODE_32BIT;
if (x.GetLossyCompressionPoisson()) {
job.mode |= MODE_SQROOT;
job.sqrtmult = x.GetLossyCompressionPoisson().value();
}
}
void FPGAAcquisitionDevice::Start(const DiffractionExperiment &experiment, uint32_t flag) {

View File

@@ -2,29 +2,117 @@
#include "HLSSimulatedDevice.h"
#include <bitset>
#include <arpa/inet.h>
#include "../fpga/hls/datamover_model.h"
#include "../fpga/hls/hls_jfjoch.h"
uint16_t checksum(const uint16_t *addr, size_t count) {
/* Compute Internet Checksum for "count" bytes
* beginning at location "addr".
*/
long sum = 0;
for (int i = 0; i < count / 2; i++)
sum += addr[i];
/* Add left-over byte, if any */
if (count % 2 == 1)
sum += ((uint8_t *) addr)[count / 2];
/* Fold 32-bit sum to 16 bits */
while (sum>>16)
sum = (sum & 0xffff) + (sum >> 16);
return ~sum;
}
HLSSimulatedDevice::HLSSimulatedDevice(uint16_t data_stream, size_t in_frame_buffer_size_modules, int16_t numa_node)
: FPGAAcquisitionDevice(data_stream) {
: FPGAAcquisitionDevice(data_stream),
datamover_in(Direction::Input, nullptr),
datamover_out(Direction::Output, nullptr),
datamover_out_hbm_0(Direction::Output, (char *) hbm.data()),
datamover_out_hbm_1(Direction::Output, (char *) hbm.data()),
datamover_in_hbm_0(Direction::Input, (char *) hbm.data()),
datamover_in_hbm_1(Direction::Input, (char *) hbm.data()),
idle(true), hbm(hbm_if_size / 32 * hbm_if_count),
dma_address_table(65536) {
mac_addr = 0xCCAA11223344;
ipv4_addr = 0x0132010A;
max_modules = MAX_MODULES_FPGA;
if (data_stream != 0)
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"HLS simulation can only work with 1 data_stream, due to use of static variables");
MapBuffersStandard(in_frame_buffer_size_modules, numa_node);
auto in_mem_location32 = (uint32_t *) dma_address_table.data();
device = std::make_unique<HLSDevice>(buffer_device);
for (int i = 0; i < buffer_device.size(); i++) {
in_mem_location32[2 * i ] = ((uint64_t) buffer_device[i]) & UINT32_MAX;
in_mem_location32[2 * i + 1] = ((uint64_t) buffer_device[i]) >> 32;
}
}
void HLSSimulatedDevice::CreateFinalPacket(const DiffractionExperiment& experiment) {
device->CreateFinalPacket(experiment);
CreateJFPacket(experiment, UINT64_MAX, 0, 0, nullptr, false);
}
void HLSSimulatedDevice::SendPacket(char *buffer, int len, uint8_t user) {
auto obuff = (ap_uint<512> *)buffer;
for (int i = 0; i < (len + 63) / 64; i++) {
packet_512_t packet_in;
if (i == (len + 63) / 64 - 1) packet_in.last = 1;
else packet_in.last = 0;
packet_in.keep = 0xFFFFFFFFFFFFFFFF;
packet_in.user = user;
packet_in.data = obuff[i];
din_eth.write(packet_in);
}
}
void HLSSimulatedDevice::CreateJFPacket(const DiffractionExperiment& experiment, uint64_t frame_number, uint32_t eth_packet,
uint32_t module_number, const uint16_t *data, int8_t adjust_axis, uint8_t user) {
device->CreateJFPacket(experiment, frame_number, eth_packet, module_number, data, adjust_axis, user);
char buff[256*64];
memset(buff, 0, 256*64);
auto packet = (jf_raw_packet *)buff;
packet->ether_type = htons(0x0800);
packet->sour_mac[0] = 0x00; // module 0
uint64_t tmp_mac = mac_addr;
for (int i = 0; i < 6; i++)
packet->dest_mac[i] = (tmp_mac >> (8*i)) % 256;
uint32_t half_module = 2 * module_number | ((eth_packet >= 64) ? 1 : 0);
packet->ipv4_header_h = htons(0x4500); // Big endian in IP header!
packet->ipv4_header_total_length = htons(8268); // Big endian in IP header!
packet->ipv4_header_dest_ip = ipv4_addr;
packet->ipv4_header_sour_ip = experiment.GetSrcIPv4Address(data_stream, half_module);
packet->ipv4_header_ttl_protocol = htons(0x0011);
packet->ipv4_header_checksum = checksum( (uint16_t *) &packet->ipv4_header_h, 20); // checksum is already in network order
packet->udp_dest_port = htons(GetUDPPort()); // module number
packet->udp_sour_port = htons(0xDFAC);
packet->udp_length = htons(8248);
// JF headers are little endian
packet->jf.detectortype = SLS_DETECTOR_TYPE_JUNGFRAU;
packet->jf.timestamp = 0xABCDEF0000FEDCBAL;
packet->jf.bunchid = 0x1234567898765431L;
packet->jf.row = half_module;
packet->jf.column = 0;
packet->jf.framenum = frame_number;
packet->jf.packetnum = eth_packet % 64;
if (data != nullptr) {
for (int i = 0; i < 4096; i++)
packet->jf.data[i] = data[i];
}
packet->udp_checksum = htons(checksum( (uint16_t *) (buff+42), 8192+48));
SendPacket(buff, (130+adjust_axis)*64, user);
}
void HLSSimulatedDevice::CreateJFPackets(const DiffractionExperiment& experiment, uint64_t frame_number_0, uint64_t frames,
@@ -38,67 +126,635 @@ void HLSSimulatedDevice::CreateJFPackets(const DiffractionExperiment& experiment
void HLSSimulatedDevice::CreateEIGERPacket(const DiffractionExperiment &experiment, uint64_t frame_number,
uint32_t eth_packet, uint32_t module_number, uint32_t col, uint32_t row,
const uint16_t *data) {
device->CreateEIGERPacket(experiment, frame_number, eth_packet, module_number, col, row, data);
char buff[256*64];
memset(buff, 0, 256*64);
auto packet = (eiger_raw_packet *)buff;
packet->ether_type = htons(0x0800);
packet->sour_mac[0] = 0x00; // module 0
uint64_t tmp_mac = mac_addr;
for (int i = 0; i < 6; i++)
packet->dest_mac[i] = (tmp_mac >> (8*i)) % 256;
packet->ipv4_header_h = htons(0x4500); // Big endian in IP header!
packet->ipv4_header_total_length = htons(4172); // Big endian in IP header!
packet->ipv4_header_dest_ip = ipv4_addr;
packet->ipv4_header_sour_ip = experiment.GetSrcIPv4Address(data_stream, 0);
packet->ipv4_header_ttl_protocol = htons(0x0011);
packet->ipv4_header_checksum = checksum( (uint16_t *) &packet->ipv4_header_h, 20); // checksum is already in network order
packet->udp_dest_port = htons(GetUDPPort()); // module number
packet->udp_sour_port = htons(0xDFAC);
packet->udp_length = htons(4152);
// JF headers are little endian
packet->eiger.detectortype = SLS_DETECTOR_TYPE_EIGER;
packet->eiger.timestamp = 0xABCDEF0000FEDCBAL;
packet->eiger.bunchid = 0x1234567898765431L;
packet->eiger.row = (2 * module_number) | (row % 2);
packet->eiger.column = col % 2;
packet->eiger.framenum = frame_number;
packet->eiger.packetnum = eth_packet % 64;
if (data != nullptr) {
for (int i = 0; i < 2048; i++)
packet->eiger.data[i] = data[i];
}
packet->udp_checksum = htons(checksum( (uint16_t *) (buff+42), 4096+48));
SendPacket(buff, 66*64, 0);
}
AXI_STREAM & HLSSimulatedDevice::OutputStream() {
return dout_eth;
}
void HLSSimulatedDevice::HW_ReadActionRegister(DataCollectionConfig *job) {
device->HW_ReadActionRegister(job);
memcpy(job, &cfg, sizeof(DataCollectionConfig));
}
void HLSSimulatedDevice::HW_WriteActionRegister(const DataCollectionConfig *job) {
device->HW_WriteActionRegister(job);
memcpy(&cfg, job, sizeof(DataCollectionConfig));
}
void HLSSimulatedDevice::FPGA_StartAction(const DiffractionExperiment &experiment) {
device->FPGA_StartAction(experiment);
if (action_thread.joinable())
action_thread.join();
run_counter += 1;
run_data_collection = 1;
cancel_data_collection = 0;
idle = false;
while (!din_frame_generator.empty())
din_frame_generator.read();
datamover_out.ClearCompletedDescriptors();
action_thread = std::thread(&HLSSimulatedDevice::HLSMainThread, this );
}
void HLSSimulatedDevice::FrameGeneratorFuture(FrameGeneratorConfig config) {
frame_generator(din_frame_generator,
hbm.data(),
hbm.data(),
hbm_if_size,
mac_addr,
ipv4_addr,
cancel_data_collection,
config);
}
void HLSSimulatedDevice::HW_RunInternalGenerator(const FrameGeneratorConfig &config) {
device->HW_RunInternalGenerator(config);
frame_generator_future = std::async(std::launch::async, &HLSSimulatedDevice::FrameGeneratorFuture, this, config);
}
void HLSSimulatedDevice::FPGA_EndAction() {
device->FPGA_EndAction();
if (action_thread.joinable())
action_thread.join();
}
HLSSimulatedDevice::~HLSSimulatedDevice() {
if (action_thread.joinable())
action_thread.join();
}
bool HLSSimulatedDevice::HW_ReadMailbox(uint32_t *values) {
return device->HW_ReadMailbox(values);
std::unique_lock<std::mutex> ul(completion_mutex);
ap_uint<32> tmp;
bool ret = completion_stream.read_nb(tmp);
values[0] = tmp;
// equivalent to driver functionality
if (ret) {
uint32_t data_collection_id = (values[0] >> 16) & 0xFFFF;
uint32_t handle = values[0] & 0xFFFF;
if (handle == HANDLE_START)
completion_count = 0;
else if ((handle != HANDLE_END) && (data_collection_id != DATA_COLLECTION_ID_PURGE)) {
completion_count++;
while (completion_count * DMA_DESCRIPTORS_PER_MODULE > datamover_out.GetCompletedDescriptors())
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}
return ret;
}
void HLSSimulatedDevice::Cancel() {
device->Cancel();
cancel_data_collection = 1;
}
bool HLSSimulatedDevice::HW_IsIdle() const {
return device->HW_IsIdle();
return idle && datamover_out.IsIdle();
}
bool HLSSimulatedDevice::HW_SendWorkRequest(uint32_t handle) {
return device->HW_SendWorkRequest(handle);
work_request_stream.write(handle);
return true;
}
inline uint32_t float2uint(float f) {
float_uint32 fu;
fu.f = f;
return fu.u;
}
void HLSSimulatedDevice::HLSMainThread() {
ap_uint<1> clear_counters = 0;
uint64_t packets_processed;
std::vector<std::thread> hls_cores;
STREAM_512 ip1, udp1, udp2, icmp1, arp1;
STREAM_512 network0;
STREAM_768 stream_768_0;
STREAM_768 stream_768_1;
STREAM_768 stream_768_2;
STREAM_768 stream_768_3;
STREAM_768 stream_768_4;
STREAM_768 stream_768_5;
STREAM_512 data_0;
hls::stream<ap_axiu<512, 1, 1, 1>, 2> data_1;
hls::stream<ap_axiu<512, 1, 1, 1>, 2> data_2;
STREAM_512 data_3;
STREAM_512 data_4;
STREAM_512 data_5;
STREAM_512 data_6;
STREAM_512 data_7;
STREAM_512 data_8;
STREAM_512 data_9;
STREAM_512 data_10;
STREAM_512 data_12;
STREAM_512 data_13;
hls::stream<axis_addr> addr0;
hls::stream<axis_addr> addr1;
hls::stream<axis_addr> addr2;
hls::stream<axis_addr> addr3;
hls::stream<axis_completion> axi_compl[12];
hls::stream<ap_uint<16>> hbm_handles;
hls::stream<ap_uint<512>> adu_histo_result;
hls::stream<ap_axiu<64,1,1,1>> integration_result_0;
hls::stream<ap_uint<512>> integration_result_1;
hls::stream<ap_axiu<32,1,1,1>> spot_finder_result_0;
hls::stream<ap_axiu<32,1,1,1>> spot_finder_result_1;
hls::stream<ap_uint<32>> spot_finder_conn_0;
hls::stream<ap_axiu<32,1,1,1>> spot_finder_result_2;
hls::stream<ap_uint<512>> spot_finder_result_3;
hls::stream<ap_uint<32>> spot_finder_mask_0;
hls::stream<ap_uint<256>> roi_calc_result_0;
hls::stream<ap_uint<UDP_METADATA_STREAM_WIDTH> > udp_metadata;
volatile ap_uint<1> idle_data_collection = 1;
ap_uint<1> load_to_hbm_idle;
ap_uint<1> save_to_hbm_idle;
ap_uint<1> integration_idle;
ap_uint<1> stream_conv_idle;
ap_uint<1> frame_summation_idle;
volatile bool done = false;
volatile bool udp_done = false; // done AND udp_idle
volatile bool sls_done = false; // done AND sls_idle
// Sent gratuitous ARP message
arp(arp1, dout_eth, mac_addr, ipv4_addr, 1, 1);
Logger logger_hls("HLS");
volatile rcv_state_t state = RCV_INIT;
// Start data collection
data_collection_fsm(data_0, data_1,
addr0, addr1,
run_data_collection,
cancel_data_collection,
idle_data_collection,
cfg.mode,
float2uint(cfg.energy_kev),
cfg.nframes,
cfg.nmodules,
cfg.nstorage_cells,
cfg.nsummation , state);
run_data_collection = 0;
data_collection_fsm(data_0, data_1,
addr0, addr1,
run_data_collection,
cancel_data_collection,
idle_data_collection,
cfg.mode,
float2uint(cfg.energy_kev),
cfg.nframes,
cfg.nmodules,
cfg.nstorage_cells,
cfg.nsummation, state);
hls_cores.emplace_back([&] {
while (!udp_done) {
if (din_eth.empty() && din_frame_generator.empty())
std::this_thread::sleep_for(std::chrono::microseconds(10));
else
stream_merge(din_eth, din_frame_generator, network0, data_source);
}
logger_hls.Info("Stream_merge done");
});
hls_cores.emplace_back([&] {
while (!udp_done) {
if (network0.empty())
std::this_thread::sleep_for(std::chrono::microseconds(10));
else
ethernet(network0, ip1, arp1, mac_addr, eth_packets, clear_counters);
}
logger_hls.Info("ethernet done");
});
hls_cores.emplace_back([&] {
while (!udp_done) {
if (ip1.empty())
std::this_thread::sleep_for(std::chrono::microseconds(10));
else
ipv4(ip1, udp1, icmp1, ipv4_addr);
}
logger_hls.Info("ipv4 done");
});
hls_cores.emplace_back([&] {
ap_uint<1> udp_idle = 1;
while (!done || !udp_idle) {
if (udp1.empty())
std::this_thread::sleep_for(std::chrono::microseconds(10));
else
udp(udp1, udp2, udp_metadata, udp_packets, clear_counters, udp_idle);
}
udp_done = true;
logger_hls.Info("udp done");
});
hls_cores.emplace_back([&] {
ap_uint<1> sls_idle = 1;
while (!done || !sls_idle) {
if (udp2.empty())
std::this_thread::sleep_for(std::chrono::microseconds (10));
else
sls_detector(udp2, udp_metadata, data_0, addr0, sls_packets, udp_eth_err, udp_len_err, current_pulse_id,
clear_counters, sls_idle);
}
sls_done = true;
logger_hls.Info("sls_detector done");
});
// 1. Parse incoming UDP packets
hls_cores.emplace_back([&] {
while ((state != RCV_WAIT_FOR_START) || (idle_data_collection.read() == 0) || (!data_0.empty())) {
data_collection_fsm(data_0, data_1,
addr0, addr1,
run_data_collection,
cancel_data_collection,
idle_data_collection,
cfg.mode,
float2uint(cfg.energy_kev),
cfg.nframes,
cfg.nmodules,
cfg.nstorage_cells,
cfg.nsummation,
state);
}
done = true;
logger_hls.Info("data collection done");
});
// 2. Cache images in HBM
hls_cores.emplace_back([&] { save_to_hbm(addr1, axi_compl[0], hbm_handles,
datamover_out_hbm_0.GetCtrlStream(),
datamover_out_hbm_1.GetCtrlStream(),
save_to_hbm_idle,
hbm_if_size);});
hls_cores.emplace_back([&] { save_to_hbm_data(data_1,
data_3,
datamover_out_hbm_0.GetDataStream(),
datamover_out_hbm_1.GetDataStream());});
hls_cores.emplace_back([&] {frame_summation_reorder_compl(data_3, data_4, axi_compl[0], axi_compl[1]);});
hls_cores.emplace_back([&] { load_from_hbm(data_4, data_5, axi_compl[1], axi_compl[2], hbm_handles,
datamover_in_hbm_0.GetDataStream(), datamover_in_hbm_1.GetDataStream(),
datamover_in_hbm_0.GetCtrlStream(), datamover_in_hbm_1.GetCtrlStream(),
load_to_hbm_idle, hbm_if_size);});
hls_cores.emplace_back([&] { pedestal(data_5, data_6, axi_compl[2], axi_compl[3],
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm_if_size);});
// 3. Calculate histogram of ADU values
hls_cores.emplace_back([&] { adu_histo(data_6, data_7, adu_histo_result, axi_compl[3], axi_compl[4]);});
// 4. Mask missing pixels
hls_cores.emplace_back([&] { mask_missing(data_7, data_8, axi_compl[4], axi_compl[5]);});
// 5. Handle EIGER packets properly
hls_cores.emplace_back([&] { eiger_reorder(data_8, data_9, axi_compl[5], axi_compl[6]);});
// 6. Apply pedestal & gain corrections
hls_cores.emplace_back([&] { jf_conversion(data_9, stream_768_0,
axi_compl[6], axi_compl[7],
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm.data(),
hbm_if_size); });
// 7. Frame summation
hls_cores.emplace_back([&] { frame_summation(stream_768_0, stream_768_1, axi_compl[7], axi_compl[8], frame_summation_idle);});
// 8. Integration of pixels
hls_cores.emplace_back([&] { integration(stream_768_1, stream_768_2, integration_result_0, axi_compl[8], axi_compl[9],
hbm.data(), hbm.data(), hbm.data(), hbm.data(), integration_idle, hbm_if_size);});
hls_cores.emplace_back([&] { axis_64_to_512(integration_result_0, integration_result_1);});
// 9. Spot finding
ap_uint<32> tmp_snr_threshold = float2uint(spot_finder_parameters.snr_threshold);
ap_uint<32> min_d = float2uint(spot_finder_parameters.min_d);
ap_uint<32> max_d = float2uint(spot_finder_parameters.max_d);
ap_int<32> tmp_count_threshold = spot_finder_parameters.count_threshold;
ap_uint<32> min_pix_per_spot = spot_finder_parameters.min_pix_per_spot;
hls_cores.emplace_back([&] {
spot_finder_mask(stream_768_2,
stream_768_3,
spot_finder_mask_0,
axi_compl[9],
axi_compl[10],
hbm.data(),
hbm.data(),
min_d,
max_d,
hbm_if_size);
logger_hls.Info("spot_finder_mask done");
});
hls_cores.emplace_back([&] {
spot_finder(stream_768_3, spot_finder_mask_0, stream_768_4, spot_finder_result_0, tmp_count_threshold, tmp_snr_threshold);
logger_hls.Info("spot_finder done");
});
hls_cores.emplace_back([&] {
spot_finder_connectivity(spot_finder_result_0,
spot_finder_result_1,
spot_finder_conn_0);
logger_hls.Info("spot_finder_connectivity done");
});
hls_cores.emplace_back([&] {
spot_finder_merge(spot_finder_result_1,
spot_finder_conn_0,
spot_finder_result_2,
min_pix_per_spot);
logger_hls.Info("spot_finder_merge done");
});
hls_cores.emplace_back([&] {
axis_32_to_512(spot_finder_result_2, spot_finder_result_3);
logger_hls.Info("axis_32_to_512 done");
});
hls_cores.emplace_back([&] {
roi_calc(stream_768_4,
stream_768_5,
roi_calc_result_0,
axi_compl[10],
axi_compl[11],
hbm.data(),
hbm.data(),
hbm_if_size);
logger_hls.Info("roi_calc done");
});
// 10. Reduce/extend 24-bit stream
hls_cores.emplace_back([&] { stream_24bit_conv(stream_768_5, data_12, stream_conv_idle);});
// 11. Prepare data to write to host memory
hls_cores.emplace_back([&] {
ap_uint<3> state;
host_writer(data_12, adu_histo_result, integration_result_1, spot_finder_result_3, roi_calc_result_0,
axi_compl[11], datamover_out.GetDataStream(),
datamover_out.GetCtrlStream(), work_request_stream, completion_stream,
dma_address_table.data(), packets_processed, host_writer_idle, cancel_data_collection, state);
logger_hls.Info("host_writer done");
});
for (auto &i : hls_cores)
i.join();
if (frame_generator_future.valid())
frame_generator_future.get();
// reset static counter
arp(arp1, dout_eth, mac_addr, ipv4_addr, 0, 1);
try {
while (!din_eth.empty())
din_eth.read();
if (!addr1.empty())
throw std::runtime_error("Addr1 queue not empty");
if (!addr2.empty())
throw std::runtime_error("Addr2 queue not empty");
if (!addr3.empty())
throw std::runtime_error("Addr3 queue not empty");
if (!data_1.empty())
throw std::runtime_error("data_1 queue not empty");
if (!data_2.empty())
throw std::runtime_error("data_2 queue not empty");
if (!data_3.empty())
throw std::runtime_error("data_3 queue not empty");
if (!data_4.empty())
throw std::runtime_error("data_4 queue not empty");
if (!data_5.empty())
throw std::runtime_error("data_5 queue not empty");
if (!data_7.empty())
throw std::runtime_error("data_7 queue not empty");
if (!data_8.empty())
throw std::runtime_error("data_8 queue not empty");
if (!data_9.empty())
throw std::runtime_error("data_9 queue not empty");
if (!data_10.empty())
throw std::runtime_error("data_10 queue not empty");
if (!data_12.empty())
throw std::runtime_error("data_12 queue not empty");
if (!data_13.empty())
throw std::runtime_error("data_13 queue not empty");
for (auto &c: axi_compl) {
if (!c.empty())
throw std::runtime_error("Compl queue not empty");
}
if (!stream_768_0.empty())
throw std::runtime_error("stream_768_0 queue not empty");
if (!stream_768_1.empty())
throw std::runtime_error("stream_768_1 queue not empty");
if (!stream_768_2.empty())
throw std::runtime_error("stream_768_2 queue not empty");
if (!stream_768_3.empty())
throw std::runtime_error("stream_768_3 queue not empty");
if (!stream_768_4.empty())
throw std::runtime_error("stream_768_4 queue not empty");
if (!hbm_handles.empty())
throw std::runtime_error("Handles queue not empty");
if (!integration_result_0.empty())
throw std::runtime_error("Integration result queue not empty");
if (!integration_result_1.empty())
throw std::runtime_error("Integration result queue not empty");
if (!datamover_in.GetDataStream().empty())
throw std::runtime_error("Datamover queue is not empty");
while (!datamover_out.IsIdle())
std::this_thread::sleep_for(std::chrono::milliseconds(100));
} catch (const std::runtime_error &e) {
if (logger)
logger->ErrorException(e);
throw e;
}
if (logger)
logger->Info("Packets Eth {} UDP {} SLS {} Proc {}", eth_packets, udp_packets, sls_packets, packets_processed);
idle = true;
}
DataCollectionStatus HLSSimulatedDevice::GetDataCollectionStatus() const {
return device->GetDataCollectionStatus();
DataCollectionStatus status{};
union {
uint64_t u64;
double d;
} pulse_id_conv;
pulse_id_conv.u64 = current_pulse_id;
status.ctrl_reg = ap_uint<1>(host_writer_idle) ? (1 << 4) : 0;
status.max_modules = max_modules;
status.hbm_size_bytes = hbm_if_size;
status.run_counter = run_counter;
status.current_pulseid = pulse_id_conv.d;
status.packets_udp = udp_packets;
status.packets_eth = eth_packets;
status.packets_sls = sls_packets;
return status;
}
void HLSSimulatedDevice::HW_LoadCalibration(const LoadCalibrationConfig &config) {
device->HW_LoadCalibration(config);
int ret = load_calibration(hbm.data(), hbm.data(),
config,
hbm_if_size,
datamover_in.GetCtrlStream(),
datamover_in.GetDataStream(),
dma_address_table.data());
if (ret)
throw JFJochException(JFJochExceptionCategory::AcquisitionDeviceError,
"Error in loading calibration " + std::to_string(ret));
if (!datamover_in.GetDataStream().empty())
throw std::runtime_error("Datamover queue is not empty");
}
void HLSSimulatedDevice::HW_SetSpotFinderParameters(const SpotFinderParameters &params) {
device->HW_SetSpotFinderParameters(params);
spot_finder_parameters = params;
}
void HLSSimulatedDevice::HW_SetDataSource(uint32_t val) {
device->HW_SetDataSource(val);
data_source = val;
}
uint32_t HLSSimulatedDevice::HW_GetDataSource() {
return device->HW_GetDataSource();
return data_source;
}
void HLSSimulatedDevice::CreateXfelBunchIDPacket(double pulse_id, uint32_t event_code) {
device->CreateXfelBunchIDPacket(pulse_id, event_code);
union {
uint64_t u64;
double d;
} pulse_id_conv;
pulse_id_conv.d = pulse_id;
bunchid_raw_packet packet{};
packet.ether_type = htons(0x0800);
for (int i = 0; i < 6; i++)
packet.dest_mac[i] = 0xFF;
packet.ipv4_header_h = htons(0x4500); // Big endian in IP header!
packet.ipv4_header_total_length = htons(sizeof(bunchid_payload) + 8 + 20); // Big endian in IP header!
packet.ipv4_header_dest_ip = UINT32_MAX;
packet.ipv4_header_ttl_protocol = htons(0x0011);
packet.ipv4_header_checksum = checksum( (uint16_t *) &packet.ipv4_header_h, 20); // checksum is already in network order
packet.udp_length = htons(sizeof(bunchid_payload) + 8);
packet.payload.magicn[0] = BUNCHID_MAGICN;
packet.payload.magicn[1] = BUNCHID_MAGICN;
packet.payload.magicn[2] = BUNCHID_MAGICN;
packet.payload.bunchid_msb[0] = (pulse_id_conv.u64 >> 32) & UINT32_MAX;
packet.payload.bunchid_msb[1] = (pulse_id_conv.u64 >> 32) & UINT32_MAX;
packet.payload.bunchid_lsb[0] = pulse_id_conv.u64 & UINT32_MAX;
packet.payload.bunchid_lsb[1] = pulse_id_conv.u64 & UINT32_MAX;
packet.payload.montrig = event_code;
SendPacket((char *) &packet, sizeof(bunchid_raw_packet));
}

View File

@@ -5,13 +5,61 @@
#include <thread>
#include "../fpga/hls/hls_jfjoch.h"
#include "../fpga/hls/datamover_model.h"
#include "../common/DiffractionExperiment.h"
#include "../fpga/hls/HLSDevice.h"
#include "FPGAAcquisitionDevice.h"
#include "../jungfrau/sls_packet.h"
uint16_t checksum(const uint16_t *addr, size_t count);
class HLSSimulatedDevice : public FPGAAcquisitionDevice {
std::unique_ptr<HLSDevice> device;
AXI_STREAM din_eth;
AXI_STREAM din_frame_generator;
AXI_STREAM dout_eth;
uint32_t run_counter = 0;
ap_uint<2> data_source = STREAM_MERGE_SRC_NETWORK;
SpotFinderParameters spot_finder_parameters;
uint64_t current_pulse_id = 0;
DataCollectionConfig cfg;
volatile bool idle;
constexpr static const size_t hbm_if_count = 32;
constexpr static const size_t hbm_if_size = 32*1024*1024LU;
std::vector<ap_uint<256>> hbm;
hls::stream<ap_uint<32> > work_request_stream;
hls::stream<ap_uint<32> > completion_stream;
std::mutex completion_mutex;
uint32_t completion_count;
std::thread action_thread;
std::future<void> frame_generator_future;
Datamover<512> datamover_in;
Datamover<512> datamover_out;
Datamover<256> datamover_in_hbm_0;
Datamover<256> datamover_in_hbm_1;
Datamover<256, 16> datamover_out_hbm_0;
Datamover<256, 16> datamover_out_hbm_1;
ap_uint<1> run_data_collection;
ap_uint<1> cancel_data_collection;
volatile ap_uint<1> host_writer_idle;
std::vector<uint64_t> dma_address_table;
uint64_t eth_packets = 0;
uint64_t icmp_packets = 0;
uint64_t udp_packets = 0;
uint64_t sls_packets = 0;
uint32_t udp_len_err = 0;
uint32_t udp_eth_err = 0;
void HW_ReadActionRegister(DataCollectionConfig *job) override;
void HW_WriteActionRegister(const DataCollectionConfig *job) override;
@@ -26,9 +74,12 @@ class HLSSimulatedDevice : public FPGAAcquisitionDevice {
uint32_t HW_GetDataSource() override;
void HW_SetDataSource(uint32_t val) override;
void HW_RunInternalGenerator(const FrameGeneratorConfig &config) override;
void FrameGeneratorFuture(FrameGeneratorConfig config);
void HLSMainThread();
public:
HLSSimulatedDevice(uint16_t data_stream, size_t in_frame_buffer_size_modules, int16_t numa_node = -1);
~HLSSimulatedDevice() override = default;
~HLSSimulatedDevice() override;
void SendPacket(char *buffer, int len, uint8_t user = 0);
void CreateJFPacket(const DiffractionExperiment& experiment, uint64_t frame_number, uint32_t eth_packet,
uint32_t module_number, const uint16_t *data, int8_t adjust_axis = 0, uint8_t user = 0);
void CreateJFPackets(const DiffractionExperiment& experiment, uint64_t frame_number_0, uint64_t frames,
@@ -39,6 +90,7 @@ public:
void CreateXfelBunchIDPacket(double bunchid, uint32_t event_code);
void CreateFinalPacket(const DiffractionExperiment& experiment);
DataCollectionStatus GetDataCollectionStatus() const override;
AXI_STREAM &OutputStream();
void Cancel() override;
};

View File

@@ -15,6 +15,4 @@ TARGET_LINK_LIBRARIES(JFJochBroker JFJochReceiver JFJochDetector JFJochCommon JF
ADD_EXECUTABLE(jfjoch_broker jfjoch_broker.cpp)
TARGET_LINK_LIBRARIES(jfjoch_broker JFJochBroker)
INSTALL(TARGETS jfjoch_broker RUNTIME COMPONENT jfjoch)
INSTALL(FILES redoc-static.html DESTINATION jfjoch/frontend COMPONENT jfjoch )
INSTALL(TARGETS jfjoch_broker RUNTIME)

View File

@@ -4,8 +4,6 @@
#include <nlohmann/json.hpp>
#include "JFJochBrokerHttp.h"
#include "gen/model/Error_message.h"
#include "../preview/JFJochTIFF.h"
#include "../common/GitInfo.h"
// From https://en.cppreference.com/w/cpp/string/byte/tolower
inline std::string str_tolower(std::string s) {
@@ -24,10 +22,6 @@ inline SpotFindingSettings Convert(const org::openapitools::server::model::Spot_
ret.enable = input.isEnable();
ret.indexing = input.isIndexing();
ret.indexing_tolerance = input.getIndexingTolerance();
if (input.filterPowderRingsIsSet())
ret.filter_spots_powder_ring = input.isFilterPowderRings();
if (input.minSpotCountPowderRingIsSet())
ret.min_spot_count_powder_ring = input.getMinSpotCountPowderRing();
return ret;
}
@@ -42,8 +36,6 @@ inline org::openapitools::server::model::Spot_finding_settings Convert(const Spo
ret.setEnable(input.enable);
ret.setIndexing(input.indexing);
ret.setIndexingTolerance(input.indexing_tolerance);
ret.setFilterPowderRings(input.filter_spots_powder_ring);
ret.setMinSpotCountPowderRing(input.min_spot_count_powder_ring);
return ret;
}
@@ -53,7 +45,6 @@ inline org::openapitools::server::model::Measurement_statistics Convert(const Me
if (!input.file_prefix.empty())
ret.setFilePrefix(input.file_prefix);
ret.setExperimentGroup(input.experiment_group);
ret.setImagesExpected(input.images_expected);
ret.setImagesCollected(input.images_collected);
ret.setImagesSent(input.images_sent);
@@ -76,8 +67,7 @@ inline org::openapitools::server::model::Measurement_statistics Convert(const Me
if (input.bkg_estimate)
ret.setBkgEstimate(input.bkg_estimate.value());
ret.setUnitCell(input.unit_cell);
ret.setRunNumber(input.run_number);
return ret;
}
@@ -194,10 +184,10 @@ inline org::openapitools::server::model::Detector_status Convert(const DetectorS
output.setHighVoltageV(input.high_voltage_V);
switch (input.power_state) {
case DetectorPowerState::ON:
output.setPowerchip("PowerOn");
output.setPowerchip("On");
break;
case DetectorPowerState::OFF:
output.setPowerchip("PowerOff");
output.setPowerchip("Off");
break;
case DetectorPowerState::PARTIAL:
output.setPowerchip("Partial");
@@ -326,7 +316,6 @@ inline PreviewJPEGSettings Convert(const org::openapitools::server::model::Previ
ret.saturation_value = input.getSaturation();
ret.show_roi = input.isShowRoi();
ret.show_indexed = input.isShowIndexed();
ret.show_user_mask = input.isShowUserMask();
if (input.resolutionRingIsSet())
ret.resolution_ring = input.getResolutionRing();
return ret;
@@ -338,13 +327,6 @@ inline DatasetSettings Convert(const org::openapitools::server::model::Dataset_s
ret.ImagesPerTrigger(input.getImagesPerTrigger());
ret.NumTriggers(input.getNtrigger());
if (input.runNumberIsSet())
ret.RunNumber(input.getRunNumber());
if (input.runNameIsSet())
ret.RunName(input.getRunName());
ret.ExperimentGroup(input.getExperimentGroup());
if (!input.fpgaOutputIsSet())
ret.FPGAOutputMode(FPGAPixelOutput::Auto);
else {
@@ -363,13 +345,13 @@ inline DatasetSettings Convert(const org::openapitools::server::model::Dataset_s
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Unknown output format");
}
if (input.imageTimeUsIsSet())
ret.ImageTime(std::chrono::microseconds(input.getImageTimeUs()));
ret.Summation(input.getSummation());
ret.BeamX_pxl(input.getBeamXPxl());
ret.BeamY_pxl(input.getBeamYPxl());
ret.DetectorDistance_mm(input.getDetectorDistanceMm());
ret.PhotonEnergy_keV(input.getIncidentEnergyKeV());
ret.PhotonEnergyMultiplayer(input.getEnergyMultiplier());
ret.PhotonEnergy_keV(input.getPhotonEnergyKeV());
ret.PhotonEnergyMultiplayer(input.getPhotonEnergyMultiplier());
ret.FilePrefix(input.getFilePrefix());
@@ -388,8 +370,6 @@ inline DatasetSettings Convert(const org::openapitools::server::model::Dataset_s
else
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Unknown compression");
}
if (input.poissonCompressionIsSet())
ret.LossyCompressionPoisson(input.getPoissonCompression());
if (input.unitCellIsSet())
ret.SetUnitCell(UnitCell{
@@ -406,15 +386,12 @@ inline DatasetSettings Convert(const org::openapitools::server::model::Dataset_s
if (input.transmissionIsSet())
ret.AttenuatorTransmission(input.getTransmission());
if (input.goniometerIsSet()) {
ret.Goniometer(GoniometerAxis{
.name = input.getGoniometer().getName(),
.increment = input.getGoniometer().getStep(),
.start = input.getGoniometer().getStart()
});
if (input.getGoniometer().getVector().size() == 3) {
auto v = input.getGoniometer().getVector();
ret.RotationAxis(Coord(v[0], v[1], v[2]));
if (input.omegaIsSet()) {
ret.OmegaStep(input.getOmega().getStep());
ret.OmegaStart(input.getOmega().getStart());
if (input.getOmega().getVector().size() == 3) {
auto v = input.getOmega().getVector();
ret.OmegaAxis(Coord(v[0], v[1], v[2]));
}
}
@@ -425,7 +402,7 @@ inline DatasetSettings Convert(const org::openapitools::server::model::Dataset_s
ret.ImagesPerFile(input.getImagesPerFile());
if (input.dataReductionFactorSerialmxIsSet())
ret.LossyCompressionSerialMX(input.getDataReductionFactorSerialmx());
ret.DataReductionFactorSerialMX(input.getDataReductionFactorSerialmx());
return ret;
}
@@ -477,21 +454,8 @@ void JFJochBrokerHttp::status_get(Pistache::Http::ResponseWriter &response) {
ProcessOutput(Convert(state_machine.GetStatus()), response);
}
void JFJochBrokerHttp::wait_till_done_post(const std::optional<int32_t> &timeout,
Pistache::Http::ResponseWriter &response) {
JFJochState state;
if (!timeout)
state = state_machine.WaitTillMeasurementDone(std::chrono::minutes(1));
else if ((timeout.value() > 3600) || (timeout.value() < 0)) {
response.send(Pistache::Http::Code::Bad_Request);
return;
} else if (timeout.value() == 0)
state = state_machine.GetState();
else
state = state_machine.WaitTillMeasurementDone(std::chrono::seconds(timeout.value()));
void JFJochBrokerHttp::wait_till_done_post(Pistache::Http::ResponseWriter &response) {
auto state = state_machine.WaitTillMeasurementDone(std::chrono::seconds(5));
switch (state) {
case JFJochState::Idle:
response.send(Pistache::Http::Code::Ok);
@@ -687,36 +651,25 @@ void JFJochBrokerHttp::preview_image_tiff_get(Pistache::Http::ResponseWriter &re
response.send(Pistache::Http::Code::Not_Found);
}
void JFJochBrokerHttp::plot_resolution_estimate_histogram_get(Pistache::Http::ResponseWriter &response) {
GenericPlot(PlotType::ResEstimation, 0, response);
}
void JFJochBrokerHttp::config_internal_generator_image_put(const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter &response) {
int64_t image_number = 0;
auto number_query = request.query().get("id");
auto number_query = request.query().get("number");
if (number_query)
image_number = std::stoi(number_query.value());
if ((image_number < 0) || (image_number > 127))
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "id must be in range 0-127");
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "image_number must be in range 0-127");
state_machine.LoadInternalGeneratorImage(request.body().data(), request.body().size(), image_number);
logger.Info("Internal generator image #{} loaded", image_number);
response.send(Pistache::Http::Code::Ok);
}
void JFJochBrokerHttp::config_internal_generator_image_tiff_put(const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter &response) {
int64_t image_number = 0;
auto number_query = request.query().get("id");
if (number_query)
image_number = std::stoi(number_query.value());
if ((image_number < 0) || (image_number > 127))
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "id must be in range 0-127");
state_machine.LoadInternalGeneratorImageTIFF(request.body(), image_number);
response.send(Pistache::Http::Code::Ok);
}
void JFJochBrokerHttp::roi_box_get(Pistache::Http::ResponseWriter &response) {
ProcessOutput(Convert(state_machine.GetBoxROI()), response);
}
@@ -832,23 +785,3 @@ void JFJochBrokerHttp::plot_strong_pixel_get(const std::optional<int32_t> &binni
Pistache::Http::ResponseWriter &response) {
GenericPlot(PlotType::StrongPixels, binning, response);
}
void JFJochBrokerHttp::config_mask_tiff_get(Pistache::Http::ResponseWriter &response) {
std::string s = state_machine.GetFullPixelMaskTIFF();
response.send(Pistache::Http::Code::Ok, s, Pistache::Http::Mime::MediaType::fromString("image/tiff"));
}
void JFJochBrokerHttp::config_user_mask_tiff_get(Pistache::Http::ResponseWriter &response) {
std::string s = state_machine.GetUserPixelMaskTIFF();
response.send(Pistache::Http::Code::Ok, s, Pistache::Http::Mime::MediaType::fromString("image/tiff"));
}
void JFJochBrokerHttp::config_user_mask_tiff_put(const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter &response) {
state_machine.SetUserPixelMask(request.body());
response.send(Pistache::Http::Code::Ok);
}
void JFJochBrokerHttp::version_get(Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, jfjoch_version(), MIME(Text, Plain));
}

View File

@@ -75,6 +75,8 @@ class JFJochBrokerHttp : public org::openapitools::server::api::DefaultApi {
void plot_rad_int_per_file_get(Pistache::Http::ResponseWriter &response) override;
void plot_resolution_estimate_histogram_get(Pistache::Http::ResponseWriter &response) override;
void statistics_calibration_get(Pistache::Http::ResponseWriter &response) override;
void statistics_data_collection_get(Pistache::Http::ResponseWriter &response) override;
@@ -90,7 +92,7 @@ class JFJochBrokerHttp : public org::openapitools::server::api::DefaultApi {
void status_get(Pistache::Http::ResponseWriter &response) override;
void wait_till_done_post(const std::optional<int32_t> &timeoutMs, Pistache::Http::ResponseWriter &response) override;
void wait_till_done_post(Pistache::Http::ResponseWriter &response) override;
void trigger_post(Pistache::Http::ResponseWriter &response) override;
void pedestal_post(Pistache::Http::ResponseWriter &response) override;
@@ -118,16 +120,6 @@ class JFJochBrokerHttp : public org::openapitools::server::api::DefaultApi {
void xfel_event_code_get(Pistache::Http::ResponseWriter &response) override;
void xfel_pulse_id_get(Pistache::Http::ResponseWriter &response) override;
void config_mask_tiff_get(Pistache::Http::ResponseWriter &response) override;
void config_user_mask_tiff_get(Pistache::Http::ResponseWriter &response) override;
void config_user_mask_tiff_put(const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter &response) override;
void config_internal_generator_image_tiff_put(const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter &response) override;
void GetStaticFile(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
std::pair<Pistache::Http::Code, std::string> handleOperationException(const std::exception &ex) const noexcept override;
@@ -143,9 +135,6 @@ class JFJochBrokerHttp : public org::openapitools::server::api::DefaultApi {
to_json(j, output);
response.send(Pistache::Http::Code::Ok, j.dump(), MIME(Application, Json));
}
void version_get(Pistache::Http::ResponseWriter &response) override;
public:
JFJochBrokerHttp(const DiffractionExperiment& experiment, std::shared_ptr<Pistache::Rest::Router> &rtr);
void AddDetectorSetup(const DetectorSetup &setup);

View File

@@ -2,8 +2,6 @@
#include "JFJochBrokerParser.h"
#include "../common/NetworkAddressConvert.h"
#include "../frame_serialize/ZMQStream2Pusher.h"
#include "../frame_serialize/DumpCBORToFilePusher.h"
inline bool CHECK_ARRAY(const nlohmann::json &j, const std::string& tag) {
if (j.contains(tag)) {
@@ -185,7 +183,6 @@ inline int64_t TimeToUs(const std::string &unit) {
inline std::chrono::microseconds GET_TIME(const nlohmann::json &j, const std::string& tag) {
if (j.contains(tag)) {
// If no units provided for time, this is always microsecond
if (j[tag].is_number())
return std::chrono::microseconds (std::lround(j[tag].get<double>() * 1000.0 * 1000.0));
else if (j[tag].is_string()) {
@@ -286,8 +283,7 @@ DetectorSetup ParseDetectorSetup(const nlohmann::json &j) {
setup.UDPInterfaceCount(GET_I64(j, "udp_interface_count", 2))
.SensorThickness_um(GET_FLOAT(j, "sensor_thickness_um", 320.0f))
.PixelSize_um(GET_FLOAT(j, "pixel_size_um", 75.0f))
.SensorMaterial(GET_STR(j, "sensor_material", "Si"))
.SerialNumber(GET_STR(j, "serial_number",""));
.SensorMaterial(GET_STR(j, "sensor_material", "Si"));
if (j.contains("tx_delay"))
setup.TxDelay(GET_I64_ARR(j, "tx_delay"));
@@ -303,68 +299,39 @@ void ParseDetectorSetup(const nlohmann::json &j, const std::string& tag, JFJochB
throw JFJochException(JFJochExceptionCategory::JSON, "Detector setup not found");
}
void ParseImagePusher(const nlohmann::json &input, std::unique_ptr<ImagePusher> &image_pusher) {
std::string pusher_type = ParseString(input, "stream_type", "zmq");
if (pusher_type == "zmq") {
int32_t zmq_send_watermark = ParseInt32(input, "zmq_send_watermark", 100);
int32_t zmq_send_buffer_size = ParseInt32(input, "zmq_send_buffer_size", -1);
auto tmp = std::make_unique<ZMQStream2Pusher>(ParseStringArray(input, "zmq_image_addr"),
zmq_send_watermark,
zmq_send_buffer_size);
std::string preview_addr = ParseString(input, "zmq_preview_addr", "");
if (!preview_addr.empty())
tmp->PreviewSocket(preview_addr);
if (input.contains("zmq_preview_period"))
tmp->PreviewCounterPeriod(GET_TIME(input, "zmq_preview_period"));
std::string writer_notification_addr = ParseString(input, "zmq_writer_notification_addr", "");
if (!writer_notification_addr.empty())
tmp->WriterNotificationSocket(writer_notification_addr);
image_pusher = std::move(tmp);
} else if (pusher_type == "dump_cbor") {
image_pusher = std::make_unique<DumpCBORToFilePusher>();
} else
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"stream_type allowed: zmq (default), dump_cbor");
}
void ParseFacilityConfiguration(const nlohmann::json &input, const std::string& tag, DiffractionExperiment &experiment) {
if (CHECK_OBJECT(input, tag)) {
auto j = input[tag];
experiment.SourceName(GET_STR(j, "source_name"));
experiment.SourceNameShort(GET_STR(j, "source_name_short"));
experiment.SourceType(GET_STR(j, "source_type", ""));
experiment.InstrumentName(GET_STR(j, "instrument_name"));
experiment.InstrumentNameShort(GET_STR(j, "instrument_name_short"));
experiment.PulsedSource(GET_BOOL(j, "pulsed_source", false));
if (j.contains("rotation_axis")) {
if (j["rotation_axis"].is_array() && (j["rotation_axis"].size() == 3))
experiment.DefaultRotationAxis(Coord(j["rotation_axis"][0].get<float>(),
j["rotation_axis"][1].get<float>(),
j["rotation_axis"][2].get<float>()));
if (j.contains("omega_axis")) {
if (j["omega_axis"].is_array() && (j["omega_axis"].size() == 3))
experiment.DefaultOmegaAxis(Coord(j["omega_axis"][0].get<float>(),
j["omega_axis"][1].get<float>(),
j["omega_axis"][2].get<float>()));
else
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"rotation_axis must be float array of 3");
"omega_axis must be float array of 3");
}
experiment.NeuralNetModelPath(GET_STR(j, "neural_net_model", ""));
if (j.contains("pedestal_g0_frames"))
experiment.PedestalG0Frames(GET_I64(j, "pedestal_g0_frames"));
if (j.contains("pedestal_g1_frames"))
experiment.PedestalG1Frames(GET_I64(j, "pedestal_g1_frames"));
if (j.contains("pedestal_g2_frames"))
experiment.PedestalG2Frames(GET_I64(j, "pedestal_g2_frames"));
if (j.contains("detector_trigger_delay"))
experiment.DetectorDelay(GET_TIME(j, "detector_trigger_delay"));
experiment.FrameTime(GET_TIME(j, "frame_time"), GET_TIME(j, "count_time"));
if (j.contains("detector_trigger_delay_us"))
experiment.DetectorDelay(GET_TIME(j, "detector_trigger_delay_us"));
experiment.FrameTime(GET_TIME(j, "frame_time_us"), GET_TIME(j, "count_time_us"));
if (j.contains("preview_period_us"))
experiment.PreviewPeriod(GET_TIME(j, "preview_period_us"));
experiment.UseInternalPacketGenerator(GET_BOOL(j, "internal_frame_generator", false));
if (experiment.IsUsingInternalPacketGen())
experiment.ConversionOnFPGA(false);

View File

@@ -14,7 +14,6 @@ DetectorGeometry ParseDetectorGeometry(const nlohmann::json &j);
DetectorSetup ParseDetectorSetup(const nlohmann::json &j);
void ParseDetectorSetup(const nlohmann::json &j, const std::string& tag, JFJochBrokerHttp& broker);
void ParseFacilityConfiguration(const nlohmann::json &j, const std::string& tag, DiffractionExperiment &experiment);
void ParseImagePusher(const nlohmann::json &j, std::unique_ptr<ImagePusher> &image_pusher);
void ParseAcquisitionDeviceGroup(const nlohmann::json &input, const std::string& tag, AcquisitionDeviceGroup &aq_devices);
std::vector<std::string> ParseStringArray(const nlohmann::json &input, const std::string& tag);

View File

@@ -5,17 +5,15 @@
JFJochServices::JFJochServices(Logger &in_logger) : logger(in_logger) {}
void JFJochServices::Start(const DiffractionExperiment& experiment,
const PixelMask &pixel_mask,
const JFCalibration &calibration) {
void JFJochServices::Start(const DiffractionExperiment& experiment, const JFCalibration &calibration) {
logger.Info("Measurement start for: {}", experiment.GetFilePrefix());
if (receiver != nullptr) {
logger.Info(" ... receiver start");
if (experiment.GetDetectorMode() == DetectorMode::Conversion)
receiver->Start(experiment, pixel_mask, &calibration);
receiver->Start(experiment, &calibration);
else
receiver->Start(experiment, pixel_mask, nullptr);
receiver->Start(experiment, nullptr);
if (detector && !experiment.IsUsingInternalPacketGen()) {
logger.Info(" ... detector start");

View File

@@ -23,9 +23,7 @@ public:
void On(const DiffractionExperiment& experiment);
void Off();
void ConfigureDetector(const DiffractionExperiment& experiment);
void Start(const DiffractionExperiment& experiment,
const PixelMask &pixel_mask,
const JFCalibration &calibration);
void Start(const DiffractionExperiment& experiment, const JFCalibration &calibration);
JFJochServicesOutput Stop();
void Cancel();
void Trigger();

View File

@@ -3,7 +3,7 @@
#include <thread>
#include "JFJochStateMachine.h"
#include "../preview/JFJochTIFF.h"
#include "../preview/WriteTIFF.h"
void ApplyDetectorSettings(DiffractionExperiment& experiment, const DetectorSettings &settings) {
auto tmp = experiment;
@@ -66,10 +66,8 @@ void ApplyRadialIntegrationSettings(DiffractionExperiment& experiment, const Rad
}
JFJochStateMachine::JFJochStateMachine(JFJochServices &in_services, Logger &in_logger)
: services(in_services),
logger(in_logger),
data_processing_settings(DiffractionExperiment::DefaultDataProcessingSettings()),
pixel_mask(experiment) {
: services(in_services), logger(in_logger),
data_processing_settings(DiffractionExperiment::DefaultDataProcessingSettings()) {
}
@@ -128,7 +126,6 @@ void JFJochStateMachine::TakePedestalInternalAll(std::unique_lock<std::mutex> &u
}
}
services.ConfigureDetector(experiment);
pixel_mask.LoadDetectorBadPixelMask(calibration->CalculateMask());
} catch (const std::exception &e) {
logger.Error("Pedestal sequence error {}", e.what());
state = JFJochState::Error;
@@ -161,7 +158,7 @@ void JFJochStateMachine::TakePedestalInternalG0(std::unique_lock<std::mutex> &ul
state = JFJochState::Pedestal;
services.ConfigureDetector(local_experiment);
services.Start(local_experiment, pixel_mask, *calibration);
services.Start(local_experiment, *calibration);
services.Trigger();
@@ -200,7 +197,7 @@ void JFJochStateMachine::TakePedestalInternalG1(std::unique_lock<std::mutex> &ul
state = JFJochState::Pedestal;
services.ConfigureDetector(local_experiment);
services.Start(local_experiment, pixel_mask, *calibration);
services.Start(local_experiment, *calibration);
services.Trigger();
@@ -239,7 +236,7 @@ void JFJochStateMachine::TakePedestalInternalG2(std::unique_lock<std::mutex> &ul
state = JFJochState::Pedestal;
services.ConfigureDetector(local_experiment);
services.Start(local_experiment, pixel_mask, *calibration);
services.Start(local_experiment, *calibration);
services.Trigger();
@@ -324,12 +321,12 @@ void JFJochStateMachine::Start(const DatasetSettings& settings) {
else
experiment.StorageCellStart(0);
experiment.IncrementRunNumber();
experiment.IncrementSeriesID();
try {
state = JFJochState::Busy;
services.SetSpotFindingSettings(GetSpotFindingSettings());
services.Start(experiment, pixel_mask, *calibration);
services.Start(experiment, *calibration);
state = JFJochState::Measuring;
measurement = std::async(std::launch::async, &JFJochStateMachine::MeasurementThread, this);
@@ -340,6 +337,12 @@ void JFJochStateMachine::Start(const DatasetSettings& settings) {
}
}
void JFJochStateMachine::WaitTillMeasurementDone() {
std::unique_lock<std::mutex> ul(m);
c.wait(ul, [&] { return !IsRunning(); });
}
void JFJochStateMachine::MeasurementThread() {
try {
auto tmp_output = services.Stop();
@@ -395,15 +398,10 @@ void JFJochStateMachine::SetFullMeasurementOutput(const JFJochServicesOutput &ou
MeasurementStatistics tmp{}; // reset last measurement statistics
tmp.file_prefix = experiment.GetFilePrefix();
tmp.run_number = experiment.GetRunNumber();
tmp.experiment_group = experiment.GetExperimentGroup();
tmp.detector_width = experiment.GetXPixelsNum();
tmp.detector_height = experiment.GetYPixelsNum();
tmp.detector_pixel_depth = experiment.GetPixelDepth();
tmp.images_expected = experiment.GetImageNum();
tmp.unit_cell = experiment.GetUnitCellString();
tmp.compression_ratio = output.receiver_output.status.compressed_ratio;
tmp.collection_efficiency = output.receiver_output.efficiency;
@@ -424,15 +422,10 @@ void JFJochStateMachine::ClearAndSetMeasurementStatistics() {
MeasurementStatistics tmp{};
tmp.file_prefix = experiment.GetFilePrefix();
tmp.run_number = experiment.GetRunNumber();
tmp.experiment_group = experiment.GetExperimentGroup();
tmp.detector_height = experiment.GetXPixelsNum();
tmp.detector_width = experiment.GetYPixelsNum();
tmp.detector_pixel_depth = experiment.GetPixelDepth();
tmp.images_expected = experiment.GetImageNum();
tmp.unit_cell = experiment.GetUnitCellString();
measurement_statistics = tmp;
}
@@ -448,14 +441,10 @@ std::optional<MeasurementStatistics> JFJochStateMachine::GetMeasurementStatistic
MeasurementStatistics tmp;
tmp.file_prefix = experiment.GetFilePrefix();
tmp.run_number = experiment.GetRunNumber();
tmp.experiment_group = experiment.GetExperimentGroup();
tmp.detector_width = experiment.GetXPixelsNum();
tmp.detector_height = experiment.GetYPixelsNum();
tmp.detector_pixel_depth = experiment.GetPixelDepth();
tmp.images_expected = experiment.GetImageNum();
tmp.unit_cell = experiment.GetUnitCellString();
tmp.compression_ratio = rcv_status->compressed_ratio;
tmp.images_collected = rcv_status->images_collected;
@@ -568,7 +557,6 @@ void JFJochStateMachine::AddDetectorSetup(const DetectorSetup &setup) {
experiment.Detector(setup);
gain_calibration = setup.GetGainCalibration();
current_detector_setup = 0;
pixel_mask = PixelMask(setup);
}
detector_setup.emplace_back(setup);
}
@@ -606,7 +594,6 @@ void JFJochStateMachine::SelectDetector(int64_t id) {
try {
experiment.Detector(detector_setup[id]);
gain_calibration = detector_setup[id].GetGainCalibration();
pixel_mask = PixelMask(detector_setup[id]);
state = JFJochState::Inactive;
current_detector_setup = id;
} catch (JFJochException &e) {
@@ -653,14 +640,6 @@ bool JFJochStateMachine::IsRunning() const {
}
}
JFJochState JFJochStateMachine::WaitTillMeasurementDone() {
std::unique_lock<std::mutex> ul(m);
c.wait(ul, [&] { return !IsRunning(); });
return state;
}
JFJochState JFJochStateMachine::WaitTillMeasurementDone(std::chrono::milliseconds timeout) {
std::unique_lock<std::mutex> ul(m);
@@ -721,21 +700,6 @@ void JFJochStateMachine::LoadInternalGeneratorImage(const void *data, size_t siz
services.LoadInternalGeneratorImage(experiment, image, image_number);
}
void JFJochStateMachine::LoadInternalGeneratorImageTIFF(const std::string &s, uint64_t image_number) {
std::unique_lock<std::mutex> ul(m);
if (state != JFJochState::Idle)
throw WrongDAQStateException ("Can change internal generator image only when detector in Idle state");
uint32_t cols, lines;
auto v = ReadTIFFFromString16(s, cols, lines);
if (((cols == experiment.GetXPixelsNum()) && (lines == experiment.GetYPixelsNum()))
|| ((cols == RAW_MODULE_SIZE) && (lines == RAW_MODULE_LINES * experiment.GetModulesNum())))
services.LoadInternalGeneratorImage(experiment, v, image_number);
else
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Image size doesn't match current detector");
}
void JFJochStateMachine::SetBoxROI(const std::vector<ROIBox> &input) {
std::unique_lock<std::mutex> ul(m);
@@ -775,33 +739,3 @@ std::vector<uint64_t> JFJochStateMachine::GetXFELEventCode() const {
services.GetXFELEventCode(ret);
return ret;
}
std::string JFJochStateMachine::GetFullPixelMaskTIFF() const {
std::unique_lock<std::mutex> ul(m);
std::vector v = pixel_mask.GetMask(experiment);
return WriteTIFFToString(v.data(), experiment.GetXPixelsNum(), experiment.GetYPixelsNum(),
sizeof(uint32_t), false);
}
std::string JFJochStateMachine::GetUserPixelMaskTIFF() const {
std::unique_lock<std::mutex> ul(m);
std::vector v = pixel_mask.GetUserMask(experiment);
return WriteTIFFToString(v.data(), experiment.GetXPixelsNum(), experiment.GetYPixelsNum(),
sizeof(uint32_t), false);
}
void JFJochStateMachine::SetUserPixelMask(const std::string &s) {
std::unique_lock<std::mutex> ul(m);
if (state != JFJochState::Idle)
throw WrongDAQStateException ("User mask can be only modified in Idle state");
try {
uint32_t cols, lines;
auto v = ReadTIFFFromString32(s, cols, lines);
pixel_mask.LoadUserMask(experiment, v);
} catch (const JFJochException &e) {
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Problem handling user mask " + std::string(e.what()));
}
}

View File

@@ -37,9 +37,6 @@ struct DetectorList {
struct MeasurementStatistics {
std::string file_prefix;
std::string experiment_group;
int64_t run_number;
int64_t images_expected;
int64_t images_collected;
int64_t images_sent;
@@ -59,8 +56,6 @@ struct MeasurementStatistics {
std::optional<float> bkg_estimate;
std::optional<std::pair<float, float>> beam_center_drift_pxl;
std::string unit_cell;
};
struct DetectorSettings {
@@ -101,8 +96,6 @@ class JFJochStateMachine {
volatile JFJochState state = JFJochState::Inactive;
volatile bool cancel_sequence = false;
std::unique_ptr<JFCalibration> calibration;
PixelMask pixel_mask;
std::vector<JFModuleGainCalibration> gain_calibration;
std::vector<DetectorSetup> detector_setup;
int64_t current_detector_setup;
@@ -141,7 +134,7 @@ public:
void Pedestal();
void Deactivate();
void Start(const DatasetSettings& settings);
JFJochState WaitTillMeasurementDone();
void WaitTillMeasurementDone();
JFJochState WaitTillMeasurementDone(std::chrono::milliseconds timeout);
void Trigger();
@@ -177,7 +170,6 @@ public:
std::string GetPedestalTIFF(size_t gain_level, size_t sc) const;
void LoadInternalGeneratorImage(const void *data, size_t size, uint64_t image_number);
void LoadInternalGeneratorImageTIFF(const std::string &s, uint64_t image_number);
// Not thread safe - only for configuration in serial context
DiffractionExperiment& NotThreadSafe_Experiment();
@@ -193,10 +185,6 @@ public:
std::vector<uint64_t> GetXFELPulseID() const;
std::vector<uint64_t> GetXFELEventCode() const;
std::string GetFullPixelMaskTIFF() const;
std::string GetUserPixelMaskTIFF() const;
void SetUserPixelMask(const std::string &v);
};

View File

@@ -25,6 +25,7 @@ To run the test:
### Compile Jungfraujoch with frontend
```
git submodule update --init --recursive
mkdir build
cd build
cmake ..

View File

@@ -1,39 +0,0 @@
/**
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* ApiBase.h
*
* Generalization of the Api classes
*/
#ifndef ApiBase_H_
#define ApiBase_H_
#include <pistache/router.h>
#include <memory>
namespace org::openapitools::server::api
{
class ApiBase {
public:
explicit ApiBase(const std::shared_ptr<Pistache::Rest::Router>& rtr) : router(rtr) {};
virtual ~ApiBase() = default;
virtual void init() = 0;
protected:
const std::shared_ptr<Pistache::Rest::Router> router;
};
} // namespace org::openapitools::server::api
#endif /* ApiBase_H_ */

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -22,7 +22,7 @@ using namespace org::openapitools::server::model;
const std::string DefaultApi::base = "";
DefaultApi::DefaultApi(const std::shared_ptr<Pistache::Rest::Router>& rtr)
: ApiBase(rtr)
: router(rtr)
{
}
@@ -37,16 +37,12 @@ void DefaultApi::setupRoutes() {
Routes::Get(*router, base + "/config/detector", Routes::bind(&DefaultApi::config_detector_get_handler, this));
Routes::Put(*router, base + "/config/detector", Routes::bind(&DefaultApi::config_detector_put_handler, this));
Routes::Put(*router, base + "/config/internal_generator_image", Routes::bind(&DefaultApi::config_internal_generator_image_put_handler, this));
Routes::Put(*router, base + "/config/internal_generator_image.tiff", Routes::bind(&DefaultApi::config_internal_generator_image_tiff_put_handler, this));
Routes::Get(*router, base + "/config/mask.tiff", Routes::bind(&DefaultApi::config_mask_tiff_get_handler, this));
Routes::Get(*router, base + "/config/rad_int", Routes::bind(&DefaultApi::config_rad_int_get_handler, this));
Routes::Put(*router, base + "/config/rad_int", Routes::bind(&DefaultApi::config_rad_int_put_handler, this));
Routes::Get(*router, base + "/config/select_detector", Routes::bind(&DefaultApi::config_select_detector_get_handler, this));
Routes::Put(*router, base + "/config/select_detector", Routes::bind(&DefaultApi::config_select_detector_put_handler, this));
Routes::Get(*router, base + "/config/spot_finding", Routes::bind(&DefaultApi::config_spot_finding_get_handler, this));
Routes::Put(*router, base + "/config/spot_finding", Routes::bind(&DefaultApi::config_spot_finding_put_handler, this));
Routes::Get(*router, base + "/config/user_mask.tiff", Routes::bind(&DefaultApi::config_user_mask_tiff_get_handler, this));
Routes::Put(*router, base + "/config/user_mask.tiff", Routes::bind(&DefaultApi::config_user_mask_tiff_put_handler, this));
Routes::Post(*router, base + "/deactivate", Routes::bind(&DefaultApi::deactivate_post_handler, this));
Routes::Get(*router, base + "/detector/status", Routes::bind(&DefaultApi::detector_status_get_handler, this));
Routes::Post(*router, base + "/initialize", Routes::bind(&DefaultApi::initialize_post_handler, this));
@@ -60,6 +56,7 @@ void DefaultApi::setupRoutes() {
Routes::Get(*router, base + "/plot/rad_int_per_file", Routes::bind(&DefaultApi::plot_rad_int_per_file_get_handler, this));
Routes::Get(*router, base + "/plot/receiver_delay", Routes::bind(&DefaultApi::plot_receiver_delay_get_handler, this));
Routes::Get(*router, base + "/plot/receiver_free_send_buffers", Routes::bind(&DefaultApi::plot_receiver_free_send_buffers_get_handler, this));
Routes::Get(*router, base + "/plot/resolution_estimate_histogram", Routes::bind(&DefaultApi::plot_resolution_estimate_histogram_get_handler, this));
Routes::Get(*router, base + "/plot/roi_max_count", Routes::bind(&DefaultApi::plot_roi_max_count_get_handler, this));
Routes::Get(*router, base + "/plot/roi_sum", Routes::bind(&DefaultApi::plot_roi_sum_get_handler, this));
Routes::Get(*router, base + "/plot/roi_valid_pixels", Routes::bind(&DefaultApi::plot_roi_valid_pixels_get_handler, this));
@@ -79,7 +76,6 @@ void DefaultApi::setupRoutes() {
Routes::Get(*router, base + "/statistics/data_collection", Routes::bind(&DefaultApi::statistics_data_collection_get_handler, this));
Routes::Get(*router, base + "/status", Routes::bind(&DefaultApi::status_get_handler, this));
Routes::Post(*router, base + "/trigger", Routes::bind(&DefaultApi::trigger_post_handler, this));
Routes::Get(*router, base + "/version", Routes::bind(&DefaultApi::version_get_handler, this));
Routes::Post(*router, base + "/wait_till_done", Routes::bind(&DefaultApi::wait_till_done_post_handler, this));
Routes::Get(*router, base + "/xfel/event_code", Routes::bind(&DefaultApi::xfel_event_code_get_handler, this));
Routes::Get(*router, base + "/xfel/pulse_id", Routes::bind(&DefaultApi::xfel_pulse_id_get_handler, this));
@@ -197,45 +193,6 @@ void DefaultApi::config_internal_generator_image_put_handler(const Pistache::Res
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
}
}
void DefaultApi::config_internal_generator_image_tiff_put_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
try {
try {
this->config_internal_generator_image_tiff_put(request, response);
} catch (Pistache::Http::HttpError &e) {
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
return;
} catch (std::exception &e) {
const std::pair<Pistache::Http::Code, std::string> errorInfo = this->handleOperationException(e);
response.send(errorInfo.first, errorInfo.second);
return;
}
} catch (std::exception &e) {
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
}
}
void DefaultApi::config_mask_tiff_get_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) {
try {
try {
this->config_mask_tiff_get(response);
} catch (Pistache::Http::HttpError &e) {
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
return;
} catch (std::exception &e) {
const std::pair<Pistache::Http::Code, std::string> errorInfo = this->handleOperationException(e);
response.send(errorInfo.first, errorInfo.second);
return;
}
} catch (std::exception &e) {
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
}
}
void DefaultApi::config_rad_int_get_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) {
try {
@@ -395,45 +352,6 @@ void DefaultApi::config_spot_finding_put_handler(const Pistache::Rest::Request &
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
}
}
void DefaultApi::config_user_mask_tiff_get_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) {
try {
try {
this->config_user_mask_tiff_get(response);
} catch (Pistache::Http::HttpError &e) {
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
return;
} catch (std::exception &e) {
const std::pair<Pistache::Http::Code, std::string> errorInfo = this->handleOperationException(e);
response.send(errorInfo.first, errorInfo.second);
return;
}
} catch (std::exception &e) {
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
}
}
void DefaultApi::config_user_mask_tiff_put_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
try {
try {
this->config_user_mask_tiff_put(request, response);
} catch (Pistache::Http::HttpError &e) {
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
return;
} catch (std::exception &e) {
const std::pair<Pistache::Http::Code, std::string> errorInfo = this->handleOperationException(e);
response.send(errorInfo.first, errorInfo.second);
return;
}
} catch (std::exception &e) {
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
}
}
void DefaultApi::deactivate_post_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) {
try {
@@ -754,6 +672,26 @@ void DefaultApi::plot_receiver_free_send_buffers_get_handler(const Pistache::Res
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
}
}
void DefaultApi::plot_resolution_estimate_histogram_get_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) {
try {
try {
this->plot_resolution_estimate_histogram_get(response);
} catch (Pistache::Http::HttpError &e) {
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
return;
} catch (std::exception &e) {
const std::pair<Pistache::Http::Code, std::string> errorInfo = this->handleOperationException(e);
response.send(errorInfo.first, errorInfo.second);
return;
}
} catch (std::exception &e) {
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
}
}
void DefaultApi::plot_roi_max_count_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
try {
@@ -1255,42 +1193,12 @@ void DefaultApi::trigger_post_handler(const Pistache::Rest::Request &, Pistache:
}
}
void DefaultApi::version_get_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) {
void DefaultApi::wait_till_done_post_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) {
try {
try {
this->version_get(response);
} catch (Pistache::Http::HttpError &e) {
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
return;
} catch (std::exception &e) {
const std::pair<Pistache::Http::Code, std::string> errorInfo = this->handleOperationException(e);
response.send(errorInfo.first, errorInfo.second);
return;
}
} catch (std::exception &e) {
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
}
}
void DefaultApi::wait_till_done_post_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
try {
// Getting the query params
auto timeoutQuery = request.query().get("timeout");
std::optional<int32_t> timeout;
if(timeoutQuery.has_value()){
int32_t valueQuery_instance;
if(fromStringValue(timeoutQuery.value(), valueQuery_instance)){
timeout = valueQuery_instance;
}
}
try {
this->wait_till_done_post(timeout, response);
this->wait_till_done_post(response);
} catch (Pistache::Http::HttpError &e) {
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
return;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -19,8 +19,6 @@
#define DefaultApi_H_
#include "ApiBase.h"
#include <pistache/http.h>
#include <pistache/router.h>
#include <pistache/http_headers.h>
@@ -44,16 +42,15 @@
#include "Roi_circle_list.h"
#include "Spot_finding_settings.h"
#include <string>
#include <vector>
namespace org::openapitools::server::api
{
class DefaultApi : public ApiBase {
class DefaultApi {
public:
explicit DefaultApi(const std::shared_ptr<Pistache::Rest::Router>& rtr);
~DefaultApi() override = default;
void init() override;
virtual ~DefaultApi() = default;
void init();
static const std::string base;
@@ -64,16 +61,12 @@ private:
void config_detector_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void config_detector_put_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void config_internal_generator_image_put_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void config_internal_generator_image_tiff_put_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void config_mask_tiff_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void config_rad_int_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void config_rad_int_put_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void config_select_detector_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void config_select_detector_put_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void config_spot_finding_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void config_spot_finding_put_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void config_user_mask_tiff_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void config_user_mask_tiff_put_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void deactivate_post_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void detector_status_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void initialize_post_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
@@ -87,6 +80,7 @@ private:
void plot_rad_int_per_file_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void plot_receiver_delay_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void plot_receiver_free_send_buffers_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void plot_resolution_estimate_histogram_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void plot_roi_max_count_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void plot_roi_sum_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void plot_roi_valid_pixels_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
@@ -106,12 +100,13 @@ private:
void statistics_data_collection_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void status_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void trigger_post_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void version_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void wait_till_done_post_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void xfel_event_code_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void xfel_pulse_id_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void default_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
const std::shared_ptr<Pistache::Rest::Router> router;
/// <summary>
/// Helper function to handle unexpected Exceptions during Parameter parsing and validation.
/// May be overridden to return custom error formats. This is called inside a catch block.
@@ -156,20 +151,6 @@ private:
/// </remarks>
virtual void config_internal_generator_image_put(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Load TIFF image for internal FPGA generator
/// </summary>
/// <remarks>
/// Load image for internal FPGA generator. This can only happen in Idle state of the detector. Requires TIFF with 16-bit integer numbers of size of detector in raw/converted coordinates (depending on detector settings).
/// </remarks>
virtual void config_internal_generator_image_tiff_put(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Get mask of the detector
/// </summary>
/// <remarks>
/// Get full pixel mask of the detector See NXmx standard for meaning of pixel values
/// </remarks>
virtual void config_mask_tiff_get(Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Get radial integration configuration
/// </summary>
/// <remarks>
@@ -215,20 +196,6 @@ private:
/// <param name="spotFindingSettings"> (optional)</param>
virtual void config_spot_finding_put(const org::openapitools::server::model::Spot_finding_settings &spotFindingSettings, Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Get user mask of the detector
/// </summary>
/// <remarks>
/// Get user pixel mask of the detector in the actual detector coordinates: 0 - good pixel, 1 - masked
/// </remarks>
virtual void config_user_mask_tiff_get(Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Upload user mask of the detector
/// </summary>
/// <remarks>
/// Should be in &#x60;Idle&#x60; state. Upload user mask of the detector - this is for example to account for beam stop shadow or misbehaving regions. If detector is conversion mode the mask can be both in raw (1024x512; stacked modules) or converted coordinates. In the latter case - module gaps are ignored and don&#39;t need to be assigned value. Mask is expected as TIFF (4-byte; unsigned). 0 - good pixel, other value - masked User mask is stored in NXmx pixel mask (bit 8), as well as used in spot finding and azimuthal integration. User mask is not automatically applied - i.e. pixels with user mask will have a valid pixel value in the images.
/// </remarks>
virtual void config_user_mask_tiff_put(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Prepare detector to turn off
/// </summary>
/// <remarks>
@@ -326,6 +293,13 @@ private:
/// <param name="binning">Binning of frames for the plot (0 &#x3D; default binning) (optional, default to 0)</param>
virtual void plot_receiver_free_send_buffers_get(const std::optional<int32_t> &binning, Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Generate resolution estimate histogram
/// </summary>
/// <remarks>
/// Generate histogram of crystal resolutions from 1.0 to 5.0 A based on ML model
/// </remarks>
virtual void plot_resolution_estimate_histogram_get(Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Generate plot of ROI max count
/// </summary>
/// <remarks>
@@ -470,20 +444,12 @@ private:
/// </remarks>
virtual void trigger_post(Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
///
/// </summary>
/// <remarks>
///
/// </remarks>
virtual void version_get(Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Wait for acquisition done
/// </summary>
/// <remarks>
/// Block execution of external script till initialization, data collection or pedestal is finished. Running this command does not affect (cancel) running data collection, it is only to ensure synchronous execution of other software. To not block web server for a indefinite period of time, the procedure is provided with a timeout. Extending timeout is possible, but requires to ensure safety that client will not close the connection and retry the connection.
/// Block execution of external script till initialization, data collection or pedestal is finished. Running this command does not affect (cancel) running data collection, it is only to ensure synchronous execution of other software. To not block web server for a long period of time, the procedure is provided with a timeout of 5 seconds.
/// </remarks>
/// <param name="timeout">Timeout in seconds (0 &#x3D;&#x3D; immediate response) (optional, default to 60)</param>
virtual void wait_till_done_post(const std::optional<int32_t> &timeout, Pistache::Http::ResponseWriter &response) = 0;
virtual void wait_till_done_post(Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Return XFEL event codes for the current data acquisition
/// </summary>

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -114,7 +114,7 @@ bool Broker_status::operator!=(const Broker_status& rhs) const
void to_json(nlohmann::json& j, const Broker_status& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
j["state"] = o.m_State;
if(o.progressIsSet())
j["progress"] = o.m_Progress;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -78,8 +78,8 @@ public:
bool indexingRateIsSet() const;
void unsetIndexing_rate();
friend void to_json(nlohmann::json& j, const Broker_status& o);
friend void from_json(const nlohmann::json& j, Broker_status& o);
friend void to_json(nlohmann::json& j, const Broker_status& o);
friend void from_json(const nlohmann::json& j, Broker_status& o);
protected:
std::string m_State;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -98,7 +98,7 @@ bool Calibration_statistics_inner::operator!=(const Calibration_statistics_inner
void to_json(nlohmann::json& j, const Calibration_statistics_inner& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
j["module_number"] = o.m_Module_number;
j["storage_cell_number"] = o.m_Storage_cell_number;
j["pedestal_g0_mean"] = o.m_Pedestal_g0_mean;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -103,8 +103,8 @@ public:
int64_t getMaskedPixels() const;
void setMaskedPixels(int64_t const value);
friend void to_json(nlohmann::json& j, const Calibration_statistics_inner& o);
friend void from_json(const nlohmann::json& j, Calibration_statistics_inner& o);
friend void to_json(nlohmann::json& j, const Calibration_statistics_inner& o);
friend void from_json(const nlohmann::json& j, Calibration_statistics_inner& o);
protected:
int64_t m_Module_number;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -25,12 +25,12 @@ Dataset_settings::Dataset_settings()
m_Images_per_triggerIsSet = false;
m_Ntrigger = 1L;
m_NtriggerIsSet = false;
m_Image_time_us = 0L;
m_Image_time_usIsSet = false;
m_Summation = 1L;
m_SummationIsSet = false;
m_Beam_x_pxl = 0.0f;
m_Beam_y_pxl = 0.0f;
m_Detector_distance_mm = 0.0f;
m_Incident_energy_keV = 0.0f;
m_Photon_energy_keV = 0.0f;
m_File_prefix = "";
m_File_prefixIsSet = false;
m_Images_per_file = 1000L;
@@ -38,7 +38,6 @@ Dataset_settings::Dataset_settings()
m_Space_group_number = 0L;
m_Space_group_numberIsSet = false;
m_Sample_name = "";
m_Sample_nameIsSet = false;
m_Fpga_output = "auto";
m_Fpga_outputIsSet = false;
m_Compression = "bslz4";
@@ -47,21 +46,15 @@ Dataset_settings::Dataset_settings()
m_Total_fluxIsSet = false;
m_Transmission = 0.0f;
m_TransmissionIsSet = false;
m_GoniometerIsSet = false;
m_OmegaIsSet = false;
m_Header_appendix = "";
m_Header_appendixIsSet = false;
m_Image_appendix = "";
m_Image_appendixIsSet = false;
m_Energy_multiplier = 1.0f;
m_Energy_multiplierIsSet = false;
m_Photon_energy_multiplier = 1.0f;
m_Photon_energy_multiplierIsSet = false;
m_Data_reduction_factor_serialmx = 1.0f;
m_Data_reduction_factor_serialmxIsSet = false;
m_Run_number = 0L;
m_Run_numberIsSet = false;
m_Run_name = "";
m_Run_nameIsSet = false;
m_Experiment_group = "";
m_Experiment_groupIsSet = false;
m_Poisson_compression = 0L;
m_Poisson_compressionIsSet = false;
m_Unit_cellIsSet = false;
}
@@ -114,16 +107,21 @@ bool Dataset_settings::validate(std::stringstream& msg, const std::string& pathP
}
if (imageTimeUsIsSet())
if (summationIsSet())
{
const int64_t& value = m_Image_time_us;
const std::string currentValuePath = _pathPrefix + ".imageTimeUs";
const int64_t& value = m_Summation;
const std::string currentValuePath = _pathPrefix + ".summation";
if (value < 0ll)
if (value < 1ll)
{
success = false;
msg << currentValuePath << ": must be greater than or equal to 0;";
msg << currentValuePath << ": must be greater than or equal to 1;";
}
if (value > 256ll)
{
success = false;
msg << currentValuePath << ": must be less than or equal to 256;";
}
}
@@ -143,9 +141,9 @@ bool Dataset_settings::validate(std::stringstream& msg, const std::string& pathP
}
/* Incident_energy_keV */ {
const float& value = m_Incident_energy_keV;
const std::string currentValuePath = _pathPrefix + ".incidentEnergyKeV";
/* Photon_energy_keV */ {
const float& value = m_Photon_energy_keV;
const std::string currentValuePath = _pathPrefix + ".photonEnergyKeV";
if (value < static_cast<float>(0))
@@ -208,10 +206,10 @@ bool Dataset_settings::validate(std::stringstream& msg, const std::string& pathP
}
if (energyMultiplierIsSet())
if (photonEnergyMultiplierIsSet())
{
const float& value = m_Energy_multiplier;
const std::string currentValuePath = _pathPrefix + ".energyMultiplier";
const float& value = m_Photon_energy_multiplier;
const std::string currentValuePath = _pathPrefix + ".photonEnergyMultiplier";
if (value < static_cast<float>(0.015625))
@@ -245,39 +243,6 @@ bool Dataset_settings::validate(std::stringstream& msg, const std::string& pathP
}
}
if (runNumberIsSet())
{
const int64_t& value = m_Run_number;
const std::string currentValuePath = _pathPrefix + ".runNumber";
if (value < 0ll)
{
success = false;
msg << currentValuePath << ": must be greater than or equal to 0;";
}
}
if (poissonCompressionIsSet())
{
const int64_t& value = m_Poisson_compression;
const std::string currentValuePath = _pathPrefix + ".poissonCompression";
if (value < 0ll)
{
success = false;
msg << currentValuePath << ": must be greater than or equal to 0;";
}
if (value > 16ll)
{
success = false;
msg << currentValuePath << ": must be less than or equal to 16;";
}
}
return success;
}
@@ -294,7 +259,7 @@ bool Dataset_settings::operator==(const Dataset_settings& rhs) const
((!ntriggerIsSet() && !rhs.ntriggerIsSet()) || (ntriggerIsSet() && rhs.ntriggerIsSet() && getNtrigger() == rhs.getNtrigger())) &&
((!imageTimeUsIsSet() && !rhs.imageTimeUsIsSet()) || (imageTimeUsIsSet() && rhs.imageTimeUsIsSet() && getImageTimeUs() == rhs.getImageTimeUs())) &&
((!summationIsSet() && !rhs.summationIsSet()) || (summationIsSet() && rhs.summationIsSet() && getSummation() == rhs.getSummation())) &&
(getBeamXPxl() == rhs.getBeamXPxl())
&&
@@ -305,7 +270,7 @@ bool Dataset_settings::operator==(const Dataset_settings& rhs) const
(getDetectorDistanceMm() == rhs.getDetectorDistanceMm())
&&
(getIncidentEnergyKeV() == rhs.getIncidentEnergyKeV())
(getPhotonEnergyKeV() == rhs.getPhotonEnergyKeV())
&&
@@ -317,8 +282,8 @@ bool Dataset_settings::operator==(const Dataset_settings& rhs) const
((!spaceGroupNumberIsSet() && !rhs.spaceGroupNumberIsSet()) || (spaceGroupNumberIsSet() && rhs.spaceGroupNumberIsSet() && getSpaceGroupNumber() == rhs.getSpaceGroupNumber())) &&
((!sampleNameIsSet() && !rhs.sampleNameIsSet()) || (sampleNameIsSet() && rhs.sampleNameIsSet() && getSampleName() == rhs.getSampleName())) &&
(getSampleName() == rhs.getSampleName())
&&
((!fpgaOutputIsSet() && !rhs.fpgaOutputIsSet()) || (fpgaOutputIsSet() && rhs.fpgaOutputIsSet() && getFpgaOutput() == rhs.getFpgaOutput())) &&
@@ -333,7 +298,7 @@ bool Dataset_settings::operator==(const Dataset_settings& rhs) const
((!transmissionIsSet() && !rhs.transmissionIsSet()) || (transmissionIsSet() && rhs.transmissionIsSet() && getTransmission() == rhs.getTransmission())) &&
((!goniometerIsSet() && !rhs.goniometerIsSet()) || (goniometerIsSet() && rhs.goniometerIsSet() && getGoniometer() == rhs.getGoniometer())) &&
((!omegaIsSet() && !rhs.omegaIsSet()) || (omegaIsSet() && rhs.omegaIsSet() && getOmega() == rhs.getOmega())) &&
((!headerAppendixIsSet() && !rhs.headerAppendixIsSet()) || (headerAppendixIsSet() && rhs.headerAppendixIsSet() && getHeaderAppendix() == rhs.getHeaderAppendix())) &&
@@ -342,24 +307,12 @@ bool Dataset_settings::operator==(const Dataset_settings& rhs) const
((!imageAppendixIsSet() && !rhs.imageAppendixIsSet()) || (imageAppendixIsSet() && rhs.imageAppendixIsSet() && getImageAppendix() == rhs.getImageAppendix())) &&
((!energyMultiplierIsSet() && !rhs.energyMultiplierIsSet()) || (energyMultiplierIsSet() && rhs.energyMultiplierIsSet() && getEnergyMultiplier() == rhs.getEnergyMultiplier())) &&
((!photonEnergyMultiplierIsSet() && !rhs.photonEnergyMultiplierIsSet()) || (photonEnergyMultiplierIsSet() && rhs.photonEnergyMultiplierIsSet() && getPhotonEnergyMultiplier() == rhs.getPhotonEnergyMultiplier())) &&
((!dataReductionFactorSerialmxIsSet() && !rhs.dataReductionFactorSerialmxIsSet()) || (dataReductionFactorSerialmxIsSet() && rhs.dataReductionFactorSerialmxIsSet() && getDataReductionFactorSerialmx() == rhs.getDataReductionFactorSerialmx())) &&
((!runNumberIsSet() && !rhs.runNumberIsSet()) || (runNumberIsSet() && rhs.runNumberIsSet() && getRunNumber() == rhs.getRunNumber())) &&
((!runNameIsSet() && !rhs.runNameIsSet()) || (runNameIsSet() && rhs.runNameIsSet() && getRunName() == rhs.getRunName())) &&
((!experimentGroupIsSet() && !rhs.experimentGroupIsSet()) || (experimentGroupIsSet() && rhs.experimentGroupIsSet() && getExperimentGroup() == rhs.getExperimentGroup())) &&
((!poissonCompressionIsSet() && !rhs.poissonCompressionIsSet()) || (poissonCompressionIsSet() && rhs.poissonCompressionIsSet() && getPoissonCompression() == rhs.getPoissonCompression())) &&
((!unitCellIsSet() && !rhs.unitCellIsSet()) || (unitCellIsSet() && rhs.unitCellIsSet() && getUnitCell() == rhs.getUnitCell()))
;
@@ -372,25 +325,24 @@ bool Dataset_settings::operator!=(const Dataset_settings& rhs) const
void to_json(nlohmann::json& j, const Dataset_settings& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
if(o.imagesPerTriggerIsSet())
j["images_per_trigger"] = o.m_Images_per_trigger;
if(o.ntriggerIsSet())
j["ntrigger"] = o.m_Ntrigger;
if(o.imageTimeUsIsSet())
j["image_time_us"] = o.m_Image_time_us;
if(o.summationIsSet())
j["summation"] = o.m_Summation;
j["beam_x_pxl"] = o.m_Beam_x_pxl;
j["beam_y_pxl"] = o.m_Beam_y_pxl;
j["detector_distance_mm"] = o.m_Detector_distance_mm;
j["incident_energy_keV"] = o.m_Incident_energy_keV;
j["photon_energy_keV"] = o.m_Photon_energy_keV;
if(o.filePrefixIsSet())
j["file_prefix"] = o.m_File_prefix;
if(o.imagesPerFileIsSet())
j["images_per_file"] = o.m_Images_per_file;
if(o.spaceGroupNumberIsSet())
j["space_group_number"] = o.m_Space_group_number;
if(o.sampleNameIsSet())
j["sample_name"] = o.m_Sample_name;
j["sample_name"] = o.m_Sample_name;
if(o.fpgaOutputIsSet())
j["fpga_output"] = o.m_Fpga_output;
if(o.compressionIsSet())
@@ -399,24 +351,16 @@ void to_json(nlohmann::json& j, const Dataset_settings& o)
j["total_flux"] = o.m_Total_flux;
if(o.transmissionIsSet())
j["transmission"] = o.m_Transmission;
if(o.goniometerIsSet())
j["goniometer"] = o.m_Goniometer;
if(o.omegaIsSet())
j["omega"] = o.m_Omega;
if(o.headerAppendixIsSet())
j["header_appendix"] = o.m_Header_appendix;
if(o.imageAppendixIsSet())
j["image_appendix"] = o.m_Image_appendix;
if(o.energyMultiplierIsSet())
j["energy_multiplier"] = o.m_Energy_multiplier;
if(o.photonEnergyMultiplierIsSet())
j["photon_energy_multiplier"] = o.m_Photon_energy_multiplier;
if(o.dataReductionFactorSerialmxIsSet())
j["data_reduction_factor_serialmx"] = o.m_Data_reduction_factor_serialmx;
if(o.runNumberIsSet())
j["run_number"] = o.m_Run_number;
if(o.runNameIsSet())
j["run_name"] = o.m_Run_name;
if(o.experimentGroupIsSet())
j["experiment_group"] = o.m_Experiment_group;
if(o.poissonCompressionIsSet())
j["poisson_compression"] = o.m_Poisson_compression;
if(o.unitCellIsSet())
j["unit_cell"] = o.m_Unit_cell;
@@ -434,15 +378,15 @@ void from_json(const nlohmann::json& j, Dataset_settings& o)
j.at("ntrigger").get_to(o.m_Ntrigger);
o.m_NtriggerIsSet = true;
}
if(j.find("image_time_us") != j.end())
if(j.find("summation") != j.end())
{
j.at("image_time_us").get_to(o.m_Image_time_us);
o.m_Image_time_usIsSet = true;
j.at("summation").get_to(o.m_Summation);
o.m_SummationIsSet = true;
}
j.at("beam_x_pxl").get_to(o.m_Beam_x_pxl);
j.at("beam_y_pxl").get_to(o.m_Beam_y_pxl);
j.at("detector_distance_mm").get_to(o.m_Detector_distance_mm);
j.at("incident_energy_keV").get_to(o.m_Incident_energy_keV);
j.at("photon_energy_keV").get_to(o.m_Photon_energy_keV);
if(j.find("file_prefix") != j.end())
{
j.at("file_prefix").get_to(o.m_File_prefix);
@@ -458,11 +402,7 @@ void from_json(const nlohmann::json& j, Dataset_settings& o)
j.at("space_group_number").get_to(o.m_Space_group_number);
o.m_Space_group_numberIsSet = true;
}
if(j.find("sample_name") != j.end())
{
j.at("sample_name").get_to(o.m_Sample_name);
o.m_Sample_nameIsSet = true;
}
j.at("sample_name").get_to(o.m_Sample_name);
if(j.find("fpga_output") != j.end())
{
j.at("fpga_output").get_to(o.m_Fpga_output);
@@ -483,10 +423,10 @@ void from_json(const nlohmann::json& j, Dataset_settings& o)
j.at("transmission").get_to(o.m_Transmission);
o.m_TransmissionIsSet = true;
}
if(j.find("goniometer") != j.end())
if(j.find("omega") != j.end())
{
j.at("goniometer").get_to(o.m_Goniometer);
o.m_GoniometerIsSet = true;
j.at("omega").get_to(o.m_Omega);
o.m_OmegaIsSet = true;
}
if(j.find("header_appendix") != j.end())
{
@@ -498,36 +438,16 @@ void from_json(const nlohmann::json& j, Dataset_settings& o)
j.at("image_appendix").get_to(o.m_Image_appendix);
o.m_Image_appendixIsSet = true;
}
if(j.find("energy_multiplier") != j.end())
if(j.find("photon_energy_multiplier") != j.end())
{
j.at("energy_multiplier").get_to(o.m_Energy_multiplier);
o.m_Energy_multiplierIsSet = true;
j.at("photon_energy_multiplier").get_to(o.m_Photon_energy_multiplier);
o.m_Photon_energy_multiplierIsSet = true;
}
if(j.find("data_reduction_factor_serialmx") != j.end())
{
j.at("data_reduction_factor_serialmx").get_to(o.m_Data_reduction_factor_serialmx);
o.m_Data_reduction_factor_serialmxIsSet = true;
}
if(j.find("run_number") != j.end())
{
j.at("run_number").get_to(o.m_Run_number);
o.m_Run_numberIsSet = true;
}
if(j.find("run_name") != j.end())
{
j.at("run_name").get_to(o.m_Run_name);
o.m_Run_nameIsSet = true;
}
if(j.find("experiment_group") != j.end())
{
j.at("experiment_group").get_to(o.m_Experiment_group);
o.m_Experiment_groupIsSet = true;
}
if(j.find("poisson_compression") != j.end())
{
j.at("poisson_compression").get_to(o.m_Poisson_compression);
o.m_Poisson_compressionIsSet = true;
}
if(j.find("unit_cell") != j.end())
{
j.at("unit_cell").get_to(o.m_Unit_cell);
@@ -570,22 +490,22 @@ void Dataset_settings::unsetNtrigger()
{
m_NtriggerIsSet = false;
}
int64_t Dataset_settings::getImageTimeUs() const
int64_t Dataset_settings::getSummation() const
{
return m_Image_time_us;
return m_Summation;
}
void Dataset_settings::setImageTimeUs(int64_t const value)
void Dataset_settings::setSummation(int64_t const value)
{
m_Image_time_us = value;
m_Image_time_usIsSet = true;
m_Summation = value;
m_SummationIsSet = true;
}
bool Dataset_settings::imageTimeUsIsSet() const
bool Dataset_settings::summationIsSet() const
{
return m_Image_time_usIsSet;
return m_SummationIsSet;
}
void Dataset_settings::unsetImage_time_us()
void Dataset_settings::unsetSummation()
{
m_Image_time_usIsSet = false;
m_SummationIsSet = false;
}
float Dataset_settings::getBeamXPxl() const
{
@@ -611,13 +531,13 @@ void Dataset_settings::setDetectorDistanceMm(float const value)
{
m_Detector_distance_mm = value;
}
float Dataset_settings::getIncidentEnergyKeV() const
float Dataset_settings::getPhotonEnergyKeV() const
{
return m_Incident_energy_keV;
return m_Photon_energy_keV;
}
void Dataset_settings::setIncidentEnergyKeV(float const value)
void Dataset_settings::setPhotonEnergyKeV(float const value)
{
m_Incident_energy_keV = value;
m_Photon_energy_keV = value;
}
std::string Dataset_settings::getFilePrefix() const
{
@@ -677,15 +597,6 @@ std::string Dataset_settings::getSampleName() const
void Dataset_settings::setSampleName(std::string const& value)
{
m_Sample_name = value;
m_Sample_nameIsSet = true;
}
bool Dataset_settings::sampleNameIsSet() const
{
return m_Sample_nameIsSet;
}
void Dataset_settings::unsetSample_name()
{
m_Sample_nameIsSet = false;
}
std::string Dataset_settings::getFpgaOutput() const
{
@@ -755,28 +666,28 @@ void Dataset_settings::unsetTransmission()
{
m_TransmissionIsSet = false;
}
org::openapitools::server::model::Rotation_axis Dataset_settings::getGoniometer() const
org::openapitools::server::model::Rotation_axis Dataset_settings::getOmega() const
{
return m_Goniometer;
return m_Omega;
}
void Dataset_settings::setGoniometer(org::openapitools::server::model::Rotation_axis const& value)
void Dataset_settings::setOmega(org::openapitools::server::model::Rotation_axis const& value)
{
m_Goniometer = value;
m_GoniometerIsSet = true;
m_Omega = value;
m_OmegaIsSet = true;
}
bool Dataset_settings::goniometerIsSet() const
bool Dataset_settings::omegaIsSet() const
{
return m_GoniometerIsSet;
return m_OmegaIsSet;
}
void Dataset_settings::unsetGoniometer()
void Dataset_settings::unsetOmega()
{
m_GoniometerIsSet = false;
m_OmegaIsSet = false;
}
nlohmann::json Dataset_settings::getHeaderAppendix() const
std::string Dataset_settings::getHeaderAppendix() const
{
return m_Header_appendix;
}
void Dataset_settings::setHeaderAppendix(nlohmann::json const& value)
void Dataset_settings::setHeaderAppendix(std::string const& value)
{
m_Header_appendix = value;
m_Header_appendixIsSet = true;
@@ -789,11 +700,11 @@ void Dataset_settings::unsetHeader_appendix()
{
m_Header_appendixIsSet = false;
}
nlohmann::json Dataset_settings::getImageAppendix() const
std::string Dataset_settings::getImageAppendix() const
{
return m_Image_appendix;
}
void Dataset_settings::setImageAppendix(nlohmann::json const& value)
void Dataset_settings::setImageAppendix(std::string const& value)
{
m_Image_appendix = value;
m_Image_appendixIsSet = true;
@@ -806,22 +717,22 @@ void Dataset_settings::unsetImage_appendix()
{
m_Image_appendixIsSet = false;
}
float Dataset_settings::getEnergyMultiplier() const
float Dataset_settings::getPhotonEnergyMultiplier() const
{
return m_Energy_multiplier;
return m_Photon_energy_multiplier;
}
void Dataset_settings::setEnergyMultiplier(float const value)
void Dataset_settings::setPhotonEnergyMultiplier(float const value)
{
m_Energy_multiplier = value;
m_Energy_multiplierIsSet = true;
m_Photon_energy_multiplier = value;
m_Photon_energy_multiplierIsSet = true;
}
bool Dataset_settings::energyMultiplierIsSet() const
bool Dataset_settings::photonEnergyMultiplierIsSet() const
{
return m_Energy_multiplierIsSet;
return m_Photon_energy_multiplierIsSet;
}
void Dataset_settings::unsetEnergy_multiplier()
void Dataset_settings::unsetPhoton_energy_multiplier()
{
m_Energy_multiplierIsSet = false;
m_Photon_energy_multiplierIsSet = false;
}
float Dataset_settings::getDataReductionFactorSerialmx() const
{
@@ -840,74 +751,6 @@ void Dataset_settings::unsetData_reduction_factor_serialmx()
{
m_Data_reduction_factor_serialmxIsSet = false;
}
int64_t Dataset_settings::getRunNumber() const
{
return m_Run_number;
}
void Dataset_settings::setRunNumber(int64_t const value)
{
m_Run_number = value;
m_Run_numberIsSet = true;
}
bool Dataset_settings::runNumberIsSet() const
{
return m_Run_numberIsSet;
}
void Dataset_settings::unsetRun_number()
{
m_Run_numberIsSet = false;
}
std::string Dataset_settings::getRunName() const
{
return m_Run_name;
}
void Dataset_settings::setRunName(std::string const& value)
{
m_Run_name = value;
m_Run_nameIsSet = true;
}
bool Dataset_settings::runNameIsSet() const
{
return m_Run_nameIsSet;
}
void Dataset_settings::unsetRun_name()
{
m_Run_nameIsSet = false;
}
std::string Dataset_settings::getExperimentGroup() const
{
return m_Experiment_group;
}
void Dataset_settings::setExperimentGroup(std::string const& value)
{
m_Experiment_group = value;
m_Experiment_groupIsSet = true;
}
bool Dataset_settings::experimentGroupIsSet() const
{
return m_Experiment_groupIsSet;
}
void Dataset_settings::unsetExperiment_group()
{
m_Experiment_groupIsSet = false;
}
int64_t Dataset_settings::getPoissonCompression() const
{
return m_Poisson_compression;
}
void Dataset_settings::setPoissonCompression(int64_t const value)
{
m_Poisson_compression = value;
m_Poisson_compressionIsSet = true;
}
bool Dataset_settings::poissonCompressionIsSet() const
{
return m_Poisson_compressionIsSet;
}
void Dataset_settings::unsetPoisson_compression()
{
m_Poisson_compressionIsSet = false;
}
org::openapitools::server::model::Dataset_settings_unit_cell Dataset_settings::getUnitCell() const
{
return m_Unit_cell;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -19,7 +19,6 @@
#define Dataset_settings_H_
#include <nlohmann/json.hpp>
#include "Rotation_axis.h"
#include <string>
#include "Dataset_settings_unit_cell.h"
@@ -76,12 +75,12 @@ public:
bool ntriggerIsSet() const;
void unsetNtrigger();
/// <summary>
/// Image time. If not provided (or zero value) the frame time is assumed as default. Image time must be multiple of frame time; max value is 256 * frame_time. In XFEL mode: summation happens for frames collected with multiple triggers. Ignored for storage cells and if raw data are saved.
/// FPGA frame summation. For summation above two 32-bit pixel format will be used, unless explicitly specified. Frame summation factor applies only to conversion mode (assumed as 1 for raw data). In XFEL mode: summation happens for frames collected with multiple triggers. Ignored for storage cells (assumed as 1).
/// </summary>
int64_t getImageTimeUs() const;
void setImageTimeUs(int64_t const value);
bool imageTimeUsIsSet() const;
void unsetImage_time_us();
int64_t getSummation() const;
void setSummation(int64_t const value);
bool summationIsSet() const;
void unsetSummation();
/// <summary>
/// /entry/detector/beam_center_x in NXmx Beam center in X direction [pixels]
/// </summary>
@@ -98,10 +97,10 @@ public:
float getDetectorDistanceMm() const;
void setDetectorDistanceMm(float const value);
/// <summary>
/// Used to calculate /entry/beam/incident_wavelength in NXmx Incident particle (photon, electron) energy in keV
/// Used to calculate /entry/beam/incident_wavelength in NXmx Incident photon energy in keV
/// </summary>
float getIncidentEnergyKeV() const;
void setIncidentEnergyKeV(float const value);
float getPhotonEnergyKeV() const;
void setPhotonEnergyKeV(float const value);
/// <summary>
/// Prefix for filenames. If left empty, no file will be saved.
/// </summary>
@@ -128,8 +127,6 @@ public:
/// </summary>
std::string getSampleName() const;
void setSampleName(std::string const& value);
bool sampleNameIsSet() const;
void unsetSample_name();
/// <summary>
/// FPGA output data type
/// </summary>
@@ -161,31 +158,31 @@ public:
/// <summary>
///
/// </summary>
org::openapitools::server::model::Rotation_axis getGoniometer() const;
void setGoniometer(org::openapitools::server::model::Rotation_axis const& value);
bool goniometerIsSet() const;
void unsetGoniometer();
org::openapitools::server::model::Rotation_axis getOmega() const;
void setOmega(org::openapitools::server::model::Rotation_axis const& value);
bool omegaIsSet() const;
void unsetOmega();
/// <summary>
/// Header appendix, added as user_data/user to start message (can be any valid JSON)
/// Header appendix, added as user_data to start message
/// </summary>
nlohmann::json getHeaderAppendix() const;
void setHeaderAppendix(nlohmann::json const& value);
std::string getHeaderAppendix() const;
void setHeaderAppendix(std::string const& value);
bool headerAppendixIsSet() const;
void unsetHeader_appendix();
/// <summary>
/// Image appendix, added as user_data to image message (can be any valid JSON)
/// Image appendix, added as user_data to image message
/// </summary>
nlohmann::json getImageAppendix() const;
void setImageAppendix(nlohmann::json const& value);
std::string getImageAppendix() const;
void setImageAppendix(std::string const& value);
bool imageAppendixIsSet() const;
void unsetImage_appendix();
/// <summary>
/// For JUNGFRAU conversion it is possible to multiply incident energy by a given factor to get fractional/multiplied particle counts
/// For JUNGFRAU conversion it is possible to multiply energy by a given factor to get fractional/multiplied photon counts
/// </summary>
float getEnergyMultiplier() const;
void setEnergyMultiplier(float const value);
bool energyMultiplierIsSet() const;
void unsetEnergy_multiplier();
float getPhotonEnergyMultiplier() const;
void setPhotonEnergyMultiplier(float const value);
bool photonEnergyMultiplierIsSet() const;
void unsetPhoton_energy_multiplier();
/// <summary>
/// Rate at which non-indexed images are accepted to be forwarded to writer. Value of 1.0 (default) means that all images are written. Values below zero mean that non-indexed images will be accepted with a given probability.
/// </summary>
@@ -194,34 +191,6 @@ public:
bool dataReductionFactorSerialmxIsSet() const;
void unsetData_reduction_factor_serialmx();
/// <summary>
/// Number of run within an experimental session. Transferred over CBOR stream as \&quot;series ID\&quot;, though not saved in HDF5 file. It is highly recommended to keep this number unique for each data collection during experimental series. If not provided, the number will be automatically incremented.
/// </summary>
int64_t getRunNumber() const;
void setRunNumber(int64_t const value);
bool runNumberIsSet() const;
void unsetRun_number();
/// <summary>
/// Unique ID of run. Transferred over CBOR stream as \&quot;unique series ID\&quot;, though not saved in HDF5 file. It is highly recommended to keep this name unique for each data collection during experimental series. If not provided, the name will be automatically generated as number + colon + file_prefix.
/// </summary>
std::string getRunName() const;
void setRunName(std::string const& value);
bool runNameIsSet() const;
void unsetRun_name();
/// <summary>
/// Name of group owning the data (e.g. p-group or proposal number). Transferred over CBOR stream, though not saved in HDF5 file.
/// </summary>
std::string getExperimentGroup() const;
void setExperimentGroup(std::string const& value);
bool experimentGroupIsSet() const;
void unsetExperiment_group();
/// <summary>
/// Enable lossy compression of pixel values that preserves Poisson statistics. Requires to provide a numerical factor SQ. Pixel value P will be transformed to round(sqrt(P) * SQ), with rounding to the closest integer. Compression is turned off if the value is missing or it is set to zero.
/// </summary>
int64_t getPoissonCompression() const;
void setPoissonCompression(int64_t const value);
bool poissonCompressionIsSet() const;
void unsetPoisson_compression();
/// <summary>
///
/// </summary>
org::openapitools::server::model::Dataset_settings_unit_cell getUnitCell() const;
@@ -229,22 +198,22 @@ public:
bool unitCellIsSet() const;
void unsetUnit_cell();
friend void to_json(nlohmann::json& j, const Dataset_settings& o);
friend void from_json(const nlohmann::json& j, Dataset_settings& o);
friend void to_json(nlohmann::json& j, const Dataset_settings& o);
friend void from_json(const nlohmann::json& j, Dataset_settings& o);
protected:
int64_t m_Images_per_trigger;
bool m_Images_per_triggerIsSet;
int64_t m_Ntrigger;
bool m_NtriggerIsSet;
int64_t m_Image_time_us;
bool m_Image_time_usIsSet;
int64_t m_Summation;
bool m_SummationIsSet;
float m_Beam_x_pxl;
float m_Beam_y_pxl;
float m_Detector_distance_mm;
float m_Incident_energy_keV;
float m_Photon_energy_keV;
std::string m_File_prefix;
bool m_File_prefixIsSet;
@@ -253,7 +222,7 @@ protected:
int64_t m_Space_group_number;
bool m_Space_group_numberIsSet;
std::string m_Sample_name;
bool m_Sample_nameIsSet;
std::string m_Fpga_output;
bool m_Fpga_outputIsSet;
std::string m_Compression;
@@ -262,24 +231,16 @@ protected:
bool m_Total_fluxIsSet;
float m_Transmission;
bool m_TransmissionIsSet;
org::openapitools::server::model::Rotation_axis m_Goniometer;
bool m_GoniometerIsSet;
nlohmann::json m_Header_appendix;
org::openapitools::server::model::Rotation_axis m_Omega;
bool m_OmegaIsSet;
std::string m_Header_appendix;
bool m_Header_appendixIsSet;
nlohmann::json m_Image_appendix;
std::string m_Image_appendix;
bool m_Image_appendixIsSet;
float m_Energy_multiplier;
bool m_Energy_multiplierIsSet;
float m_Photon_energy_multiplier;
bool m_Photon_energy_multiplierIsSet;
float m_Data_reduction_factor_serialmx;
bool m_Data_reduction_factor_serialmxIsSet;
int64_t m_Run_number;
bool m_Run_numberIsSet;
std::string m_Run_name;
bool m_Run_nameIsSet;
std::string m_Experiment_group;
bool m_Experiment_groupIsSet;
int64_t m_Poisson_compression;
bool m_Poisson_compressionIsSet;
org::openapitools::server::model::Dataset_settings_unit_cell m_Unit_cell;
bool m_Unit_cellIsSet;

View File

@@ -0,0 +1,133 @@
/**
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "Dataset_settings_roi_sum_area.h"
#include "Helpers.h"
#include <sstream>
namespace org::openapitools::server::model
{
Dataset_settings_roi_sum_area::Dataset_settings_roi_sum_area()
{
m_X_min = 0L;
m_X_max = 0L;
m_Y_min = 0L;
m_Y_max = 0L;
}
void Dataset_settings_roi_sum_area::validate() const
{
std::stringstream msg;
if (!validate(msg))
{
throw org::openapitools::server::helpers::ValidationException(msg.str());
}
}
bool Dataset_settings_roi_sum_area::validate(std::stringstream& msg) const
{
return validate(msg, "");
}
bool Dataset_settings_roi_sum_area::validate(std::stringstream& msg, const std::string& pathPrefix) const
{
bool success = true;
const std::string _pathPrefix = pathPrefix.empty() ? "Dataset_settings_roi_sum_area" : pathPrefix;
return success;
}
bool Dataset_settings_roi_sum_area::operator==(const Dataset_settings_roi_sum_area& rhs) const
{
return
(getXMin() == rhs.getXMin())
&&
(getXMax() == rhs.getXMax())
&&
(getYMin() == rhs.getYMin())
&&
(getYMax() == rhs.getYMax())
;
}
bool Dataset_settings_roi_sum_area::operator!=(const Dataset_settings_roi_sum_area& rhs) const
{
return !(*this == rhs);
}
void to_json(nlohmann::json& j, const Dataset_settings_roi_sum_area& o)
{
j = nlohmann::json();
j["x_min"] = o.m_X_min;
j["x_max"] = o.m_X_max;
j["y_min"] = o.m_Y_min;
j["y_max"] = o.m_Y_max;
}
void from_json(const nlohmann::json& j, Dataset_settings_roi_sum_area& o)
{
j.at("x_min").get_to(o.m_X_min);
j.at("x_max").get_to(o.m_X_max);
j.at("y_min").get_to(o.m_Y_min);
j.at("y_max").get_to(o.m_Y_max);
}
int64_t Dataset_settings_roi_sum_area::getXMin() const
{
return m_X_min;
}
void Dataset_settings_roi_sum_area::setXMin(int64_t const value)
{
m_X_min = value;
}
int64_t Dataset_settings_roi_sum_area::getXMax() const
{
return m_X_max;
}
void Dataset_settings_roi_sum_area::setXMax(int64_t const value)
{
m_X_max = value;
}
int64_t Dataset_settings_roi_sum_area::getYMin() const
{
return m_Y_min;
}
void Dataset_settings_roi_sum_area::setYMin(int64_t const value)
{
m_Y_min = value;
}
int64_t Dataset_settings_roi_sum_area::getYMax() const
{
return m_Y_max;
}
void Dataset_settings_roi_sum_area::setYMax(int64_t const value)
{
m_Y_max = value;
}
} // namespace org::openapitools::server::model

View File

@@ -0,0 +1,97 @@
/**
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* Dataset_settings_roi_sum_area.h
*
* Rectangle for ROI summation
*/
#ifndef Dataset_settings_roi_sum_area_H_
#define Dataset_settings_roi_sum_area_H_
#include <nlohmann/json.hpp>
namespace org::openapitools::server::model
{
/// <summary>
/// Rectangle for ROI summation
/// </summary>
class Dataset_settings_roi_sum_area
{
public:
Dataset_settings_roi_sum_area();
virtual ~Dataset_settings_roi_sum_area() = default;
/// <summary>
/// Validate the current data in the model. Throws a ValidationException on failure.
/// </summary>
void validate() const;
/// <summary>
/// Validate the current data in the model. Returns false on error and writes an error
/// message into the given stringstream.
/// </summary>
bool validate(std::stringstream& msg) const;
/// <summary>
/// Helper overload for validate. Used when one model stores another model and calls it's validate.
/// Not meant to be called outside that case.
/// </summary>
bool validate(std::stringstream& msg, const std::string& pathPrefix) const;
bool operator==(const Dataset_settings_roi_sum_area& rhs) const;
bool operator!=(const Dataset_settings_roi_sum_area& rhs) const;
/////////////////////////////////////////////
/// Dataset_settings_roi_sum_area members
/// <summary>
///
/// </summary>
int64_t getXMin() const;
void setXMin(int64_t const value);
/// <summary>
///
/// </summary>
int64_t getXMax() const;
void setXMax(int64_t const value);
/// <summary>
///
/// </summary>
int64_t getYMin() const;
void setYMin(int64_t const value);
/// <summary>
///
/// </summary>
int64_t getYMax() const;
void setYMax(int64_t const value);
friend void to_json(nlohmann::json& j, const Dataset_settings_roi_sum_area& o);
friend void from_json(const nlohmann::json& j, Dataset_settings_roi_sum_area& o);
protected:
int64_t m_X_min;
int64_t m_X_max;
int64_t m_Y_min;
int64_t m_Y_max;
};
} // namespace org::openapitools::server::model
#endif /* Dataset_settings_roi_sum_area_H_ */

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -185,7 +185,7 @@ bool Dataset_settings_unit_cell::operator!=(const Dataset_settings_unit_cell& rh
void to_json(nlohmann::json& j, const Dataset_settings_unit_cell& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
j["a"] = o.m_a;
j["b"] = o.m_b;
j["c"] = o.m_c;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -88,8 +88,8 @@ public:
float getGamma() const;
void setGamma(float const value);
friend void to_json(nlohmann::json& j, const Dataset_settings_unit_cell& o);
friend void from_json(const nlohmann::json& j, Dataset_settings_unit_cell& o);
friend void to_json(nlohmann::json& j, const Dataset_settings_unit_cell& o);
friend void from_json(const nlohmann::json& j, Dataset_settings_unit_cell& o);
protected:
float m_a;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -90,7 +90,7 @@ bool Detector_list::operator!=(const Detector_list& rhs) const
void to_json(nlohmann::json& j, const Detector_list& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
j["detectors"] = o.m_Detectors;
j["current_id"] = o.m_Current_id;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -70,8 +70,8 @@ public:
int64_t getCurrentId() const;
void setCurrentId(int64_t const value);
friend void to_json(nlohmann::json& j, const Detector_list& o);
friend void from_json(const nlohmann::json& j, Detector_list& o);
friend void to_json(nlohmann::json& j, const Detector_list& o);
friend void from_json(const nlohmann::json& j, Detector_list& o);
protected:
std::vector<org::openapitools::server::model::Detector_list_detectors_inner> m_Detectors;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -96,7 +96,7 @@ bool Detector_list_detectors_inner::operator!=(const Detector_list_detectors_inn
void to_json(nlohmann::json& j, const Detector_list_detectors_inner& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
j["id"] = o.m_Id;
j["description"] = o.m_Description;
j["nmodules"] = o.m_Nmodules;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -84,8 +84,8 @@ public:
int64_t getHeight() const;
void setHeight(int64_t const value);
friend void to_json(nlohmann::json& j, const Detector_list_detectors_inner& o);
friend void from_json(const nlohmann::json& j, Detector_list_detectors_inner& o);
friend void to_json(nlohmann::json& j, const Detector_list_detectors_inner& o);
friend void from_json(const nlohmann::json& j, Detector_list_detectors_inner& o);
protected:
int64_t m_Id;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -66,7 +66,7 @@ bool Detector_selection::operator!=(const Detector_selection& rhs) const
void to_json(nlohmann::json& j, const Detector_selection& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
j["id"] = o.m_Id;
}

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -63,8 +63,8 @@ public:
int64_t getId() const;
void setId(int64_t const value);
friend void to_json(nlohmann::json& j, const Detector_selection& o);
friend void from_json(const nlohmann::json& j, Detector_selection& o);
friend void to_json(nlohmann::json& j, const Detector_selection& o);
friend void from_json(const nlohmann::json& j, Detector_selection& o);
protected:
int64_t m_Id;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -220,7 +220,7 @@ bool Detector_settings::operator!=(const Detector_settings& rhs) const
void to_json(nlohmann::json& j, const Detector_settings& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
j["frame_time_us"] = o.m_Frame_time_us;
if(o.countTimeUsIsSet())
j["count_time_us"] = o.m_Count_time_us;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -147,8 +147,8 @@ public:
bool useGainHg0IsSet() const;
void unsetUse_gain_hg0();
friend void to_json(nlohmann::json& j, const Detector_settings& o);
friend void from_json(const nlohmann::json& j, Detector_settings& o);
friend void to_json(nlohmann::json& j, const Detector_settings& o);
friend void from_json(const nlohmann::json& j, Detector_settings& o);
protected:
int64_t m_Frame_time_us;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -126,7 +126,7 @@ bool Detector_status::operator!=(const Detector_status& rhs) const
void to_json(nlohmann::json& j, const Detector_status& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
j["state"] = o.m_State;
j["powerchip"] = o.m_Powerchip;
j["server_version"] = o.m_Server_version;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -90,8 +90,8 @@ public:
std::vector<int64_t> getHighVoltageV() const;
void setHighVoltageV(std::vector<int64_t> const value);
friend void to_json(nlohmann::json& j, const Detector_status& o);
friend void from_json(const nlohmann::json& j, Detector_status& o);
friend void to_json(nlohmann::json& j, const Detector_status& o);
friend void from_json(const nlohmann::json& j, Detector_status& o);
protected:
std::string m_State;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -70,7 +70,7 @@ bool Error_message::operator!=(const Error_message& rhs) const
void to_json(nlohmann::json& j, const Error_message& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
j["msg"] = o.m_Msg;
j["reason"] = o.m_Reason;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -69,8 +69,8 @@ public:
std::string getReason() const;
void setReason(std::string const& value);
friend void to_json(nlohmann::json& j, const Error_message& o);
friend void from_json(const nlohmann::json& j, Error_message& o);
friend void to_json(nlohmann::json& j, const Error_message& o);
friend void from_json(const nlohmann::json& j, Error_message& o);
protected:
std::string m_Msg;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -23,10 +23,6 @@ Measurement_statistics::Measurement_statistics()
{
m_File_prefix = "";
m_File_prefixIsSet = false;
m_Run_number = 0L;
m_Run_numberIsSet = false;
m_Experiment_group = "";
m_Experiment_groupIsSet = false;
m_Images_expected = 0L;
m_Images_expectedIsSet = false;
m_Images_collected = 0L;
@@ -55,8 +51,6 @@ Measurement_statistics::Measurement_statistics()
m_Detector_pixel_depthIsSet = false;
m_Bkg_estimate = 0.0f;
m_Bkg_estimateIsSet = false;
m_Unit_cell = "";
m_Unit_cellIsSet = false;
}
@@ -79,7 +73,7 @@ bool Measurement_statistics::validate(std::stringstream& msg, const std::string&
bool success = true;
const std::string _pathPrefix = pathPrefix.empty() ? "Measurement_statistics" : pathPrefix;
if (collectionEfficiencyIsSet())
{
const float& value = m_Collection_efficiency;
@@ -112,7 +106,7 @@ bool Measurement_statistics::validate(std::stringstream& msg, const std::string&
}
}
return success;
}
@@ -125,12 +119,6 @@ bool Measurement_statistics::operator==(const Measurement_statistics& rhs) const
((!filePrefixIsSet() && !rhs.filePrefixIsSet()) || (filePrefixIsSet() && rhs.filePrefixIsSet() && getFilePrefix() == rhs.getFilePrefix())) &&
((!runNumberIsSet() && !rhs.runNumberIsSet()) || (runNumberIsSet() && rhs.runNumberIsSet() && getRunNumber() == rhs.getRunNumber())) &&
((!experimentGroupIsSet() && !rhs.experimentGroupIsSet()) || (experimentGroupIsSet() && rhs.experimentGroupIsSet() && getExperimentGroup() == rhs.getExperimentGroup())) &&
((!imagesExpectedIsSet() && !rhs.imagesExpectedIsSet()) || (imagesExpectedIsSet() && rhs.imagesExpectedIsSet() && getImagesExpected() == rhs.getImagesExpected())) &&
@@ -170,10 +158,7 @@ bool Measurement_statistics::operator==(const Measurement_statistics& rhs) const
((!detectorPixelDepthIsSet() && !rhs.detectorPixelDepthIsSet()) || (detectorPixelDepthIsSet() && rhs.detectorPixelDepthIsSet() && getDetectorPixelDepth() == rhs.getDetectorPixelDepth())) &&
((!bkgEstimateIsSet() && !rhs.bkgEstimateIsSet()) || (bkgEstimateIsSet() && rhs.bkgEstimateIsSet() && getBkgEstimate() == rhs.getBkgEstimate())) &&
((!unitCellIsSet() && !rhs.unitCellIsSet()) || (unitCellIsSet() && rhs.unitCellIsSet() && getUnitCell() == rhs.getUnitCell()))
((!bkgEstimateIsSet() && !rhs.bkgEstimateIsSet()) || (bkgEstimateIsSet() && rhs.bkgEstimateIsSet() && getBkgEstimate() == rhs.getBkgEstimate()))
;
}
@@ -185,13 +170,9 @@ bool Measurement_statistics::operator!=(const Measurement_statistics& rhs) const
void to_json(nlohmann::json& j, const Measurement_statistics& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
if(o.filePrefixIsSet())
j["file_prefix"] = o.m_File_prefix;
if(o.runNumberIsSet())
j["run_number"] = o.m_Run_number;
if(o.experimentGroupIsSet())
j["experiment_group"] = o.m_Experiment_group;
if(o.imagesExpectedIsSet())
j["images_expected"] = o.m_Images_expected;
if(o.imagesCollectedIsSet())
@@ -220,8 +201,6 @@ void to_json(nlohmann::json& j, const Measurement_statistics& o)
j["detector_pixel_depth"] = o.m_Detector_pixel_depth;
if(o.bkgEstimateIsSet())
j["bkg_estimate"] = o.m_Bkg_estimate;
if(o.unitCellIsSet())
j["unit_cell"] = o.m_Unit_cell;
}
@@ -232,16 +211,6 @@ void from_json(const nlohmann::json& j, Measurement_statistics& o)
j.at("file_prefix").get_to(o.m_File_prefix);
o.m_File_prefixIsSet = true;
}
if(j.find("run_number") != j.end())
{
j.at("run_number").get_to(o.m_Run_number);
o.m_Run_numberIsSet = true;
}
if(j.find("experiment_group") != j.end())
{
j.at("experiment_group").get_to(o.m_Experiment_group);
o.m_Experiment_groupIsSet = true;
}
if(j.find("images_expected") != j.end())
{
j.at("images_expected").get_to(o.m_Images_expected);
@@ -312,11 +281,6 @@ void from_json(const nlohmann::json& j, Measurement_statistics& o)
j.at("bkg_estimate").get_to(o.m_Bkg_estimate);
o.m_Bkg_estimateIsSet = true;
}
if(j.find("unit_cell") != j.end())
{
j.at("unit_cell").get_to(o.m_Unit_cell);
o.m_Unit_cellIsSet = true;
}
}
@@ -337,40 +301,6 @@ void Measurement_statistics::unsetFile_prefix()
{
m_File_prefixIsSet = false;
}
int64_t Measurement_statistics::getRunNumber() const
{
return m_Run_number;
}
void Measurement_statistics::setRunNumber(int64_t const value)
{
m_Run_number = value;
m_Run_numberIsSet = true;
}
bool Measurement_statistics::runNumberIsSet() const
{
return m_Run_numberIsSet;
}
void Measurement_statistics::unsetRun_number()
{
m_Run_numberIsSet = false;
}
std::string Measurement_statistics::getExperimentGroup() const
{
return m_Experiment_group;
}
void Measurement_statistics::setExperimentGroup(std::string const& value)
{
m_Experiment_group = value;
m_Experiment_groupIsSet = true;
}
bool Measurement_statistics::experimentGroupIsSet() const
{
return m_Experiment_groupIsSet;
}
void Measurement_statistics::unsetExperiment_group()
{
m_Experiment_groupIsSet = false;
}
int64_t Measurement_statistics::getImagesExpected() const
{
return m_Images_expected;
@@ -609,23 +539,6 @@ void Measurement_statistics::unsetBkg_estimate()
{
m_Bkg_estimateIsSet = false;
}
std::string Measurement_statistics::getUnitCell() const
{
return m_Unit_cell;
}
void Measurement_statistics::setUnitCell(std::string const& value)
{
m_Unit_cell = value;
m_Unit_cellIsSet = true;
}
bool Measurement_statistics::unitCellIsSet() const
{
return m_Unit_cellIsSet;
}
void Measurement_statistics::unsetUnit_cell()
{
m_Unit_cellIsSet = false;
}
} // namespace org::openapitools::server::model

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -66,20 +66,6 @@ public:
bool filePrefixIsSet() const;
void unsetFile_prefix();
/// <summary>
/// Number of data collection run. This can be either automatically incremented or provided externally for each data collection.
/// </summary>
int64_t getRunNumber() const;
void setRunNumber(int64_t const value);
bool runNumberIsSet() const;
void unsetRun_number();
/// <summary>
/// Name of group owning the data (e.g. p-group or proposal number).
/// </summary>
std::string getExperimentGroup() const;
void setExperimentGroup(std::string const& value);
bool experimentGroupIsSet() const;
void unsetExperiment_group();
/// <summary>
///
/// </summary>
int64_t getImagesExpected() const;
@@ -177,23 +163,12 @@ public:
void setBkgEstimate(float const value);
bool bkgEstimateIsSet() const;
void unsetBkg_estimate();
/// <summary>
///
/// </summary>
std::string getUnitCell() const;
void setUnitCell(std::string const& value);
bool unitCellIsSet() const;
void unsetUnit_cell();
friend void to_json(nlohmann::json& j, const Measurement_statistics& o);
friend void from_json(const nlohmann::json& j, Measurement_statistics& o);
friend void to_json(nlohmann::json& j, const Measurement_statistics& o);
friend void from_json(const nlohmann::json& j, Measurement_statistics& o);
protected:
std::string m_File_prefix;
bool m_File_prefixIsSet;
int64_t m_Run_number;
bool m_Run_numberIsSet;
std::string m_Experiment_group;
bool m_Experiment_groupIsSet;
int64_t m_Images_expected;
bool m_Images_expectedIsSet;
int64_t m_Images_collected;
@@ -222,8 +197,6 @@ protected:
bool m_Detector_pixel_depthIsSet;
float m_Bkg_estimate;
bool m_Bkg_estimateIsSet;
std::string m_Unit_cell;
bool m_Unit_cellIsSet;
};

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -114,7 +114,7 @@ bool Plot::operator!=(const Plot& rhs) const
void to_json(nlohmann::json& j, const Plot& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
j["title"] = o.m_Title;
j["x"] = o.m_x;
j["y"] = o.m_y;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -75,8 +75,8 @@ public:
std::vector<float> getY() const;
void setY(std::vector<float> const value);
friend void to_json(nlohmann::json& j, const Plot& o);
friend void from_json(const nlohmann::json& j, Plot& o);
friend void to_json(nlohmann::json& j, const Plot& o);
friend void from_json(const nlohmann::json& j, Plot& o);
protected:
std::string m_Title;

View File

@@ -0,0 +1,106 @@
/**
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "Plot_request.h"
#include "Helpers.h"
#include <sstream>
namespace org::openapitools::server::model
{
Plot_request::Plot_request()
{
m_Binning = 0L;
m_BinningIsSet = false;
}
void Plot_request::validate() const
{
std::stringstream msg;
if (!validate(msg))
{
throw org::openapitools::server::helpers::ValidationException(msg.str());
}
}
bool Plot_request::validate(std::stringstream& msg) const
{
return validate(msg, "");
}
bool Plot_request::validate(std::stringstream& msg, const std::string& pathPrefix) const
{
bool success = true;
const std::string _pathPrefix = pathPrefix.empty() ? "Plot_request" : pathPrefix;
return success;
}
bool Plot_request::operator==(const Plot_request& rhs) const
{
return
((!binningIsSet() && !rhs.binningIsSet()) || (binningIsSet() && rhs.binningIsSet() && getBinning() == rhs.getBinning()))
;
}
bool Plot_request::operator!=(const Plot_request& rhs) const
{
return !(*this == rhs);
}
void to_json(nlohmann::json& j, const Plot_request& o)
{
j = nlohmann::json();
if(o.binningIsSet())
j["binning"] = o.m_Binning;
}
void from_json(const nlohmann::json& j, Plot_request& o)
{
if(j.find("binning") != j.end())
{
j.at("binning").get_to(o.m_Binning);
o.m_BinningIsSet = true;
}
}
int64_t Plot_request::getBinning() const
{
return m_Binning;
}
void Plot_request::setBinning(int64_t const value)
{
m_Binning = value;
m_BinningIsSet = true;
}
bool Plot_request::binningIsSet() const
{
return m_BinningIsSet;
}
void Plot_request::unsetBinning()
{
m_BinningIsSet = false;
}
} // namespace org::openapitools::server::model

View File

@@ -0,0 +1,78 @@
/**
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* Plot_request.h
*
*
*/
#ifndef Plot_request_H_
#define Plot_request_H_
#include <nlohmann/json.hpp>
namespace org::openapitools::server::model
{
/// <summary>
///
/// </summary>
class Plot_request
{
public:
Plot_request();
virtual ~Plot_request() = default;
/// <summary>
/// Validate the current data in the model. Throws a ValidationException on failure.
/// </summary>
void validate() const;
/// <summary>
/// Validate the current data in the model. Returns false on error and writes an error
/// message into the given stringstream.
/// </summary>
bool validate(std::stringstream& msg) const;
/// <summary>
/// Helper overload for validate. Used when one model stores another model and calls it's validate.
/// Not meant to be called outside that case.
/// </summary>
bool validate(std::stringstream& msg, const std::string& pathPrefix) const;
bool operator==(const Plot_request& rhs) const;
bool operator!=(const Plot_request& rhs) const;
/////////////////////////////////////////////
/// Plot_request members
/// <summary>
///
/// </summary>
int64_t getBinning() const;
void setBinning(int64_t const value);
bool binningIsSet() const;
void unsetBinning();
friend void to_json(nlohmann::json& j, const Plot_request& o);
friend void from_json(const nlohmann::json& j, Plot_request& o);
protected:
int64_t m_Binning;
bool m_BinningIsSet;
};
} // namespace org::openapitools::server::model
#endif /* Plot_request_H_ */

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -91,7 +91,7 @@ bool Plots::operator!=(const Plots& rhs) const
void to_json(nlohmann::json& j, const Plots& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
if(o.titleIsSet())
j["title"] = o.m_Title;
j["plot"] = o.m_Plot;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -73,8 +73,8 @@ public:
std::vector<org::openapitools::server::model::Plot> getPlot() const;
void setPlot(std::vector<org::openapitools::server::model::Plot> const& value);
friend void to_json(nlohmann::json& j, const Plots& o);
friend void from_json(const nlohmann::json& j, Plots& o);
friend void to_json(nlohmann::json& j, const Plots& o);
friend void from_json(const nlohmann::json& j, Plots& o);
protected:
std::string m_Title;
bool m_TitleIsSet;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -26,13 +26,11 @@ Preview_settings::Preview_settings()
m_Show_spotsIsSet = false;
m_Show_roi = false;
m_Show_roiIsSet = false;
m_Jpeg_quality = 100L;
m_Jpeg_quality = 0L;
m_Jpeg_qualityIsSet = false;
m_Show_indexed = false;
m_Show_indexedIsSet = false;
m_Show_user_mask = false;
m_Show_user_maskIsSet = false;
m_Resolution_ring = 0.1f;
m_Resolution_ring = 0.0f;
m_Resolution_ringIsSet = false;
}
@@ -94,7 +92,7 @@ bool Preview_settings::validate(std::stringstream& msg, const std::string& pathP
}
}
if (resolutionRingIsSet())
{
const float& value = m_Resolution_ring;
@@ -138,9 +136,6 @@ bool Preview_settings::operator==(const Preview_settings& rhs) const
((!showIndexedIsSet() && !rhs.showIndexedIsSet()) || (showIndexedIsSet() && rhs.showIndexedIsSet() && isShowIndexed() == rhs.isShowIndexed())) &&
((!showUserMaskIsSet() && !rhs.showUserMaskIsSet()) || (showUserMaskIsSet() && rhs.showUserMaskIsSet() && isShowUserMask() == rhs.isShowUserMask())) &&
((!resolutionRingIsSet() && !rhs.resolutionRingIsSet()) || (resolutionRingIsSet() && rhs.resolutionRingIsSet() && getResolutionRing() == rhs.getResolutionRing()))
;
@@ -153,7 +148,7 @@ bool Preview_settings::operator!=(const Preview_settings& rhs) const
void to_json(nlohmann::json& j, const Preview_settings& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
j["saturation"] = o.m_Saturation;
if(o.showSpotsIsSet())
j["show_spots"] = o.m_Show_spots;
@@ -163,8 +158,6 @@ void to_json(nlohmann::json& j, const Preview_settings& o)
j["jpeg_quality"] = o.m_Jpeg_quality;
if(o.showIndexedIsSet())
j["show_indexed"] = o.m_Show_indexed;
if(o.showUserMaskIsSet())
j["show_user_mask"] = o.m_Show_user_mask;
if(o.resolutionRingIsSet())
j["resolution_ring"] = o.m_Resolution_ring;
@@ -193,11 +186,6 @@ void from_json(const nlohmann::json& j, Preview_settings& o)
j.at("show_indexed").get_to(o.m_Show_indexed);
o.m_Show_indexedIsSet = true;
}
if(j.find("show_user_mask") != j.end())
{
j.at("show_user_mask").get_to(o.m_Show_user_mask);
o.m_Show_user_maskIsSet = true;
}
if(j.find("resolution_ring") != j.end())
{
j.at("resolution_ring").get_to(o.m_Resolution_ring);
@@ -282,23 +270,6 @@ void Preview_settings::unsetShow_indexed()
{
m_Show_indexedIsSet = false;
}
bool Preview_settings::isShowUserMask() const
{
return m_Show_user_mask;
}
void Preview_settings::setShowUserMask(bool const value)
{
m_Show_user_mask = value;
m_Show_user_maskIsSet = true;
}
bool Preview_settings::showUserMaskIsSet() const
{
return m_Show_user_maskIsSet;
}
void Preview_settings::unsetShow_user_mask()
{
m_Show_user_maskIsSet = false;
}
float Preview_settings::getResolutionRing() const
{
return m_Resolution_ring;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -91,13 +91,6 @@ public:
bool showIndexedIsSet() const;
void unsetShow_indexed();
/// <summary>
/// Show user mask
/// </summary>
bool isShowUserMask() const;
void setShowUserMask(bool const value);
bool showUserMaskIsSet() const;
void unsetShow_user_mask();
/// <summary>
///
/// </summary>
float getResolutionRing() const;
@@ -105,8 +98,8 @@ public:
bool resolutionRingIsSet() const;
void unsetResolution_ring();
friend void to_json(nlohmann::json& j, const Preview_settings& o);
friend void from_json(const nlohmann::json& j, Preview_settings& o);
friend void to_json(nlohmann::json& j, const Preview_settings& o);
friend void from_json(const nlohmann::json& j, Preview_settings& o);
protected:
int64_t m_Saturation;
@@ -118,8 +111,6 @@ protected:
bool m_Jpeg_qualityIsSet;
bool m_Show_indexed;
bool m_Show_indexedIsSet;
bool m_Show_user_mask;
bool m_Show_user_maskIsSet;
float m_Resolution_ring;
bool m_Resolution_ringIsSet;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -102,7 +102,7 @@ bool Rad_int_settings::operator!=(const Rad_int_settings& rhs) const
void to_json(nlohmann::json& j, const Rad_int_settings& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
if(o.polarizationFactorIsSet())
j["polarization_factor"] = o.m_Polarization_factor;
j["solid_angle_corr"] = o.m_Solid_angle_corr;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -85,8 +85,8 @@ public:
float getQSpacing() const;
void setQSpacing(float const value);
friend void to_json(nlohmann::json& j, const Rad_int_settings& o);
friend void from_json(const nlohmann::json& j, Rad_int_settings& o);
friend void to_json(nlohmann::json& j, const Rad_int_settings& o);
friend void from_json(const nlohmann::json& j, Rad_int_settings& o);
protected:
float m_Polarization_factor;
bool m_Polarization_factorIsSet;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -152,7 +152,7 @@ bool Roi_box::operator!=(const Roi_box& rhs) const
void to_json(nlohmann::json& j, const Roi_box& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
j["name"] = o.m_Name;
j["min_x_pxl"] = o.m_Min_x_pxl;
j["max_x_pxl"] = o.m_Max_x_pxl;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -84,8 +84,8 @@ public:
int64_t getMaxYPxl() const;
void setMaxYPxl(int64_t const value);
friend void to_json(nlohmann::json& j, const Roi_box& o);
friend void from_json(const nlohmann::json& j, Roi_box& o);
friend void to_json(nlohmann::json& j, const Roi_box& o);
friend void from_json(const nlohmann::json& j, Roi_box& o);
protected:
std::string m_Name;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -92,7 +92,7 @@ bool Roi_box_list::operator!=(const Roi_box_list& rhs) const
void to_json(nlohmann::json& j, const Roi_box_list& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
if(o.roisIsSet() || !o.m_Rois.empty())
j["rois"] = o.m_Rois;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -67,8 +67,8 @@ public:
bool roisIsSet() const;
void unsetRois();
friend void to_json(nlohmann::json& j, const Roi_box_list& o);
friend void from_json(const nlohmann::json& j, Roi_box_list& o);
friend void to_json(nlohmann::json& j, const Roi_box_list& o);
friend void from_json(const nlohmann::json& j, Roi_box_list& o);
protected:
std::vector<org::openapitools::server::model::Roi_box> m_Rois;
bool m_RoisIsSet;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -106,7 +106,7 @@ bool Roi_circle::operator!=(const Roi_circle& rhs) const
void to_json(nlohmann::json& j, const Roi_circle& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
j["name"] = o.m_Name;
j["center_x_pxl"] = o.m_Center_x_pxl;
j["center_y_pxl"] = o.m_Center_y_pxl;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -79,8 +79,8 @@ public:
float getRadiusPxl() const;
void setRadiusPxl(float const value);
friend void to_json(nlohmann::json& j, const Roi_circle& o);
friend void from_json(const nlohmann::json& j, Roi_circle& o);
friend void to_json(nlohmann::json& j, const Roi_circle& o);
friend void from_json(const nlohmann::json& j, Roi_circle& o);
protected:
std::string m_Name;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -91,7 +91,7 @@ bool Roi_circle_list::operator!=(const Roi_circle_list& rhs) const
void to_json(nlohmann::json& j, const Roi_circle_list& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
j["rois"] = o.m_Rois;
}

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -65,8 +65,8 @@ public:
std::vector<org::openapitools::server::model::Roi_circle> getRois() const;
void setRois(std::vector<org::openapitools::server::model::Roi_circle> const& value);
friend void to_json(nlohmann::json& j, const Roi_circle_list& o);
friend void from_json(const nlohmann::json& j, Roi_circle_list& o);
friend void to_json(nlohmann::json& j, const Roi_circle_list& o);
friend void from_json(const nlohmann::json& j, Roi_circle_list& o);
protected:
std::vector<org::openapitools::server::model::Roi_circle> m_Rois;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -21,8 +21,6 @@ namespace org::openapitools::server::model
Rotation_axis::Rotation_axis()
{
m_Name = "omega";
m_NameIsSet = false;
m_Step = 0.0f;
m_Start = 0.0f;
m_StartIsSet = false;
@@ -49,20 +47,6 @@ bool Rotation_axis::validate(std::stringstream& msg, const std::string& pathPref
bool success = true;
const std::string _pathPrefix = pathPrefix.empty() ? "Rotation_axis" : pathPrefix;
if (nameIsSet())
{
const std::string& value = m_Name;
const std::string currentValuePath = _pathPrefix + ".name";
if (value.length() < 1)
{
success = false;
msg << currentValuePath << ": must be at least 1 characters long;";
}
}
if (vectorIsSet())
{
@@ -103,9 +87,6 @@ bool Rotation_axis::operator==(const Rotation_axis& rhs) const
return
((!nameIsSet() && !rhs.nameIsSet()) || (nameIsSet() && rhs.nameIsSet() && getName() == rhs.getName())) &&
(getStep() == rhs.getStep())
&&
@@ -125,9 +106,7 @@ bool Rotation_axis::operator!=(const Rotation_axis& rhs) const
void to_json(nlohmann::json& j, const Rotation_axis& o)
{
j = nlohmann::json::object();
if(o.nameIsSet())
j["name"] = o.m_Name;
j = nlohmann::json();
j["step"] = o.m_Step;
if(o.startIsSet())
j["start"] = o.m_Start;
@@ -138,11 +117,6 @@ void to_json(nlohmann::json& j, const Rotation_axis& o)
void from_json(const nlohmann::json& j, Rotation_axis& o)
{
if(j.find("name") != j.end())
{
j.at("name").get_to(o.m_Name);
o.m_NameIsSet = true;
}
j.at("step").get_to(o.m_Step);
if(j.find("start") != j.end())
{
@@ -157,23 +131,6 @@ void from_json(const nlohmann::json& j, Rotation_axis& o)
}
std::string Rotation_axis::getName() const
{
return m_Name;
}
void Rotation_axis::setName(std::string const& value)
{
m_Name = value;
m_NameIsSet = true;
}
bool Rotation_axis::nameIsSet() const
{
return m_NameIsSet;
}
void Rotation_axis::unsetName()
{
m_NameIsSet = false;
}
float Rotation_axis::getStep() const
{
return m_Step;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -19,7 +19,6 @@
#define Rotation_axis_H_
#include <string>
#include <vector>
#include <nlohmann/json.hpp>
@@ -59,13 +58,6 @@ public:
/////////////////////////////////////////////
/// Rotation_axis members
/// <summary>
/// Name of rotation axis (e.g., omega, phi)
/// </summary>
std::string getName() const;
void setName(std::string const& value);
bool nameIsSet() const;
void unsetName();
/// <summary>
/// Angle step in degrees
/// </summary>
@@ -86,11 +78,9 @@ public:
bool vectorIsSet() const;
void unsetVector();
friend void to_json(nlohmann::json& j, const Rotation_axis& o);
friend void from_json(const nlohmann::json& j, Rotation_axis& o);
friend void to_json(nlohmann::json& j, const Rotation_axis& o);
friend void from_json(const nlohmann::json& j, Rotation_axis& o);
protected:
std::string m_Name;
bool m_NameIsSet;
float m_Step;
float m_Start;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -23,10 +23,6 @@ Spot_finding_settings::Spot_finding_settings()
{
m_Enable = true;
m_Indexing = true;
m_Filter_powder_rings = false;
m_Filter_powder_ringsIsSet = false;
m_Min_spot_count_powder_ring = 0L;
m_Min_spot_count_powder_ringIsSet = false;
m_Signal_to_noise_threshold = 0.0f;
m_Photon_count_threshold = 0L;
m_Min_pix_per_spot = 0L;
@@ -56,21 +52,7 @@ bool Spot_finding_settings::validate(std::stringstream& msg, const std::string&
bool success = true;
const std::string _pathPrefix = pathPrefix.empty() ? "Spot_finding_settings" : pathPrefix;
if (minSpotCountPowderRingIsSet())
{
const int64_t& value = m_Min_spot_count_powder_ring;
const std::string currentValuePath = _pathPrefix + ".minSpotCountPowderRing";
if (value < 5ll)
{
success = false;
msg << currentValuePath << ": must be greater than or equal to 5;";
}
}
/* Signal_to_noise_threshold */ {
const float& value = m_Signal_to_noise_threshold;
@@ -160,12 +142,6 @@ bool Spot_finding_settings::operator==(const Spot_finding_settings& rhs) const
(isIndexing() == rhs.isIndexing())
&&
((!filterPowderRingsIsSet() && !rhs.filterPowderRingsIsSet()) || (filterPowderRingsIsSet() && rhs.filterPowderRingsIsSet() && isFilterPowderRings() == rhs.isFilterPowderRings())) &&
((!minSpotCountPowderRingIsSet() && !rhs.minSpotCountPowderRingIsSet()) || (minSpotCountPowderRingIsSet() && rhs.minSpotCountPowderRingIsSet() && getMinSpotCountPowderRing() == rhs.getMinSpotCountPowderRing())) &&
(getSignalToNoiseThreshold() == rhs.getSignalToNoiseThreshold())
&&
@@ -197,13 +173,9 @@ bool Spot_finding_settings::operator!=(const Spot_finding_settings& rhs) const
void to_json(nlohmann::json& j, const Spot_finding_settings& o)
{
j = nlohmann::json::object();
j = nlohmann::json();
j["enable"] = o.m_Enable;
j["indexing"] = o.m_Indexing;
if(o.filterPowderRingsIsSet())
j["filter_powder_rings"] = o.m_Filter_powder_rings;
if(o.minSpotCountPowderRingIsSet())
j["min_spot_count_powder_ring"] = o.m_Min_spot_count_powder_ring;
j["signal_to_noise_threshold"] = o.m_Signal_to_noise_threshold;
j["photon_count_threshold"] = o.m_Photon_count_threshold;
j["min_pix_per_spot"] = o.m_Min_pix_per_spot;
@@ -218,16 +190,6 @@ void from_json(const nlohmann::json& j, Spot_finding_settings& o)
{
j.at("enable").get_to(o.m_Enable);
j.at("indexing").get_to(o.m_Indexing);
if(j.find("filter_powder_rings") != j.end())
{
j.at("filter_powder_rings").get_to(o.m_Filter_powder_rings);
o.m_Filter_powder_ringsIsSet = true;
}
if(j.find("min_spot_count_powder_ring") != j.end())
{
j.at("min_spot_count_powder_ring").get_to(o.m_Min_spot_count_powder_ring);
o.m_Min_spot_count_powder_ringIsSet = true;
}
j.at("signal_to_noise_threshold").get_to(o.m_Signal_to_noise_threshold);
j.at("photon_count_threshold").get_to(o.m_Photon_count_threshold);
j.at("min_pix_per_spot").get_to(o.m_Min_pix_per_spot);
@@ -254,40 +216,6 @@ void Spot_finding_settings::setIndexing(bool const value)
{
m_Indexing = value;
}
bool Spot_finding_settings::isFilterPowderRings() const
{
return m_Filter_powder_rings;
}
void Spot_finding_settings::setFilterPowderRings(bool const value)
{
m_Filter_powder_rings = value;
m_Filter_powder_ringsIsSet = true;
}
bool Spot_finding_settings::filterPowderRingsIsSet() const
{
return m_Filter_powder_ringsIsSet;
}
void Spot_finding_settings::unsetFilter_powder_rings()
{
m_Filter_powder_ringsIsSet = false;
}
int64_t Spot_finding_settings::getMinSpotCountPowderRing() const
{
return m_Min_spot_count_powder_ring;
}
void Spot_finding_settings::setMinSpotCountPowderRing(int64_t const value)
{
m_Min_spot_count_powder_ring = value;
m_Min_spot_count_powder_ringIsSet = true;
}
bool Spot_finding_settings::minSpotCountPowderRingIsSet() const
{
return m_Min_spot_count_powder_ringIsSet;
}
void Spot_finding_settings::unsetMin_spot_count_powder_ring()
{
m_Min_spot_count_powder_ringIsSet = false;
}
float Spot_finding_settings::getSignalToNoiseThreshold() const
{
return m_Signal_to_noise_threshold;

View File

@@ -2,8 +2,8 @@
* Jungfraujoch
* Jungfraujoch Broker Web API
*
* The version of the OpenAPI document: 1.0.0-rc.12
* Contact: filip.leonarski@psi.ch
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -58,30 +58,16 @@ public:
/// Spot_finding_settings members
/// <summary>
/// Enable spot finding. This is temporary setting, i.e. can be changed anytime during data collection. Even if disabled spot finding information will still be send and written, though always with zero spots.
/// Enable spot finding
/// </summary>
bool isEnable() const;
void setEnable(bool const value);
/// <summary>
/// Enable indexing. This is temporary setting, i.e. can be changed anytime during data collection.
/// Enable indexing
/// </summary>
bool isIndexing() const;
void setIndexing(bool const value);
/// <summary>
/// Filter spots which form powder rings (e.g., ice rings)
/// </summary>
bool isFilterPowderRings() const;
void setFilterPowderRings(bool const value);
bool filterPowderRingsIsSet() const;
void unsetFilter_powder_rings();
/// <summary>
/// Minimum number of spots to consider a thin resolution shell (0.01 A^-1) a powder ring and filter out.
/// </summary>
int64_t getMinSpotCountPowderRing() const;
void setMinSpotCountPowderRing(int64_t const value);
bool minSpotCountPowderRingIsSet() const;
void unsetMin_spot_count_powder_ring();
/// <summary>
///
/// </summary>
float getSignalToNoiseThreshold() const;
@@ -117,17 +103,13 @@ public:
float getIndexingTolerance() const;
void setIndexingTolerance(float const value);
friend void to_json(nlohmann::json& j, const Spot_finding_settings& o);
friend void from_json(const nlohmann::json& j, Spot_finding_settings& o);
friend void to_json(nlohmann::json& j, const Spot_finding_settings& o);
friend void from_json(const nlohmann::json& j, Spot_finding_settings& o);
protected:
bool m_Enable;
bool m_Indexing;
bool m_Filter_powder_rings;
bool m_Filter_powder_ringsIsSet;
int64_t m_Min_spot_count_powder_ring;
bool m_Min_spot_count_powder_ringIsSet;
float m_Signal_to_noise_threshold;
int64_t m_Photon_count_threshold;

View File

@@ -2,9 +2,7 @@ openapi: 3.0.3
info:
title: Jungfraujoch
description: Jungfraujoch Broker Web API
version: 1.0.0-rc.12
contact:
email: filip.leonarski@psi.ch
version: 1.0.1
components:
schemas:
rotation_axis:
@@ -13,11 +11,6 @@ components:
required:
- step
properties:
name:
type: string
default: omega
minLength: 1
description: Name of rotation axis (e.g., omega, phi)
step:
type: number
format: float
@@ -44,7 +37,8 @@ components:
- beam_x_pxl
- beam_y_pxl
- detector_distance_mm
- incident_energy_keV
- photon_energy_keV
- sample_name
properties:
images_per_trigger:
type: integer
@@ -62,16 +56,17 @@ components:
minimum: 1
description: |
Number of TTL trigger that the detector is expected to receive during data collection
image_time_us:
summation:
type: integer
format: int64
minimum: 0
minimum: 1
maximum: 256
default: 1
description: |
Image time.
If not provided (or zero value) the frame time is assumed as default.
Image time must be multiple of frame time; max value is 256 * frame_time.
FPGA frame summation. For summation above two 32-bit pixel format will be used, unless explicitly specified.
Frame summation factor applies only to conversion mode (assumed as 1 for raw data).
In XFEL mode: summation happens for frames collected with multiple triggers.
Ignored for storage cells and if raw data are saved.
Ignored for storage cells (assumed as 1).
beam_x_pxl:
type: number
format: float
@@ -91,13 +86,13 @@ components:
description:
/entry/detector/distance in NXmx
Detector distance [mm]
incident_energy_keV:
photon_energy_keV:
type: number
format: float
minimum: 0
description: |
Used to calculate /entry/beam/incident_wavelength in NXmx
Incident particle (photon, electron) energy in keV
Incident photon energy in keV
file_prefix:
type: string
default: ""
@@ -116,7 +111,6 @@ components:
maximum: 194
sample_name:
type: string
default: ""
description: |
/entry/sample/name in NXmx
Sample name
@@ -154,19 +148,21 @@ components:
description: |
/entry/instrument/attenuator/attenuator_transmission
Transmission of attenuator (filter) [no units]
goniometer:
omega:
$ref: "#/components/schemas/rotation_axis"
header_appendix:
description: Header appendix, added as user_data/user to start message (can be any valid JSON)
type: string
description: Header appendix, added as user_data to start message
image_appendix:
description: Image appendix, added as user_data to image message (can be any valid JSON)
energy_multiplier:
type: string
description: Image appendix, added as user_data to image message
photon_energy_multiplier:
type: number
format: float
default: 1.0
minimum: 0.015625
maximum: 4.0
description: For JUNGFRAU conversion it is possible to multiply incident energy by a given factor to get fractional/multiplied particle counts
description: For JUNGFRAU conversion it is possible to multiply energy by a given factor to get fractional/multiplied photon counts
data_reduction_factor_serialmx:
type: number
format: float
@@ -177,37 +173,6 @@ components:
Rate at which non-indexed images are accepted to be forwarded to writer.
Value of 1.0 (default) means that all images are written.
Values below zero mean that non-indexed images will be accepted with a given probability.
run_number:
type: integer
format: int64
minimum: 0
description: |
Number of run within an experimental session.
Transferred over CBOR stream as "series ID", though not saved in HDF5 file.
It is highly recommended to keep this number unique for each data collection during experimental series.
If not provided, the number will be automatically incremented.
run_name:
type: string
description: |
Unique ID of run.
Transferred over CBOR stream as "unique series ID", though not saved in HDF5 file.
It is highly recommended to keep this name unique for each data collection during experimental series.
If not provided, the name will be automatically generated as number + colon + file_prefix.
experiment_group:
type: string
description: |
Name of group owning the data (e.g. p-group or proposal number).
Transferred over CBOR stream, though not saved in HDF5 file.
poisson_compression:
type: integer
format: int64
minimum: 0
maximum: 16
description: |
Enable lossy compression of pixel values that preserves Poisson statistics.
Requires to provide a numerical factor SQ.
Pixel value P will be transformed to round(sqrt(P) * SQ), with rounding to the closest integer.
Compression is turned off if the value is missing or it is set to zero.
unit_cell:
type: object
description: Units of angstrom and degree
@@ -270,7 +235,7 @@ components:
powerchip:
type: string
description: Power on of ASICs
enum: ["PowerOn", "PowerOff", "Partial"]
enum: ["On", "Off", "Partial"]
server_version:
type: string
description: Detector server (on read-out boards) version
@@ -368,23 +333,11 @@ components:
enable:
type: boolean
default: true
description: |
Enable spot finding. This is temporary setting, i.e. can be changed anytime during data collection.
Even if disabled spot finding information will still be send and written, though always with zero spots.
description: Enable spot finding
indexing:
type: boolean
default: true
description: |
Enable indexing. This is temporary setting, i.e. can be changed anytime during data collection.
filter_powder_rings:
type: boolean
default: false
description: Filter spots which form powder rings (e.g., ice rings)
min_spot_count_powder_ring:
type: integer
format: int64
minimum: 5
description: Minimum number of spots to consider a thin resolution shell (0.01 A^-1) a powder ring and filter out.
description: Enable indexing
signal_to_noise_threshold:
type: number
format: float
@@ -494,15 +447,6 @@ components:
properties:
file_prefix:
type: string
run_number:
type: integer
format: int64
description: |
Number of data collection run. This can be either automatically incremented or provided externally for each data collection.
experiment_group:
type: string
description: |
Name of group owning the data (e.g. p-group or proposal number).
images_expected:
type: integer
format: int64
@@ -556,8 +500,6 @@ components:
bkg_estimate:
type: number
format: float
unit_cell:
type: string
broker_status:
type: object
required:
@@ -676,21 +618,14 @@ components:
type: integer
description: "Quality of JPEG image (100 - highest; 0 - lowest)"
format: int64
default: 100
minimum: 0
maximum: 100
show_indexed:
type: boolean
description: "Preview indexed images only"
default: false
show_user_mask:
type: boolean
description: "Show user mask"
default: false
resolution_ring:
type: number
format: float
default: 0.1
minimum: 0.1
maximum: 100.0
error_message:
@@ -863,37 +798,22 @@ paths:
/wait_till_done:
post:
summary: Wait for acquisition done
parameters:
- in: query
name: timeout
required: false
schema:
type: integer
default: 60
minimum: 0
maximum: 3600
description: Timeout in seconds (0 == immediate response)
description: |
Block execution of external script till initialization, data collection or pedestal is finished.
Running this command does not affect (cancel) running data collection, it is only to ensure synchronous execution of other software.
To not block web server for a indefinite period of time, the procedure is provided with a timeout.
Extending timeout is possible, but requires to ensure safety that client will not close the connection and retry the connection.
To not block web server for a long period of time, the procedure is provided with a timeout of 5 seconds.
responses:
"200":
description: Detector in `Idle` state, another data collection can start immediately
"400":
description: Timeout parameter out of bounds
"500":
description: Error within Jungfraujoch code - see output message.
content:
application/json:
schema:
$ref: '#/components/schemas/error_message'
"502":
description: Detector is inactive mode
"504":
description: Timeout reached, need to restart operation
description: 5 second timeout reached, need to restart operation
/trigger:
post:
@@ -1045,9 +965,9 @@ paths:
Requires binary blob with 16-bit integer numbers of size of detector in raw/converted coordinates
(depending on detector settings).
parameters:
- name: id
- name: number
in: query
description: Image id to upload
description: Image number to upload
required: false
schema:
type: integer
@@ -1070,38 +990,6 @@ paths:
schema:
type: string
description: Exception error
/config/internal_generator_image.tiff:
put:
summary: Load TIFF image for internal FPGA generator
description: |
Load image for internal FPGA generator. This can only happen in Idle state of the detector.
Requires TIFF with 16-bit integer numbers of size of detector in raw/converted coordinates
(depending on detector settings).
parameters:
- in: query
name: id
description: Image ID to upload
required: false
schema:
type: integer
minimum: 0
maximum: 127
requestBody:
content:
image/tiff:
schema:
type: string
format: binary
responses:
"200":
description: Everything OK
"400":
description: Input parsing or validation error
content:
text/plain:
schema:
type: string
description: Exception error
/config/select_detector:
put:
summary: Select detector
@@ -1557,6 +1445,17 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/plots'
/plot/resolution_estimate_histogram:
get:
summary: Generate resolution estimate histogram
description: Generate histogram of crystal resolutions from 1.0 to 5.0 A based on ML model
responses:
"200":
description: Everything OK
content:
application/json:
schema:
$ref: '#/components/schemas/plots'
/plot/rad_int:
get:
summary: Generate radial integration profile
@@ -1674,63 +1573,6 @@ paths:
format: binary
"404":
description: No preview image recorded so far
/config/mask.tiff:
get:
summary: Get mask of the detector
description: |
Get full pixel mask of the detector
See NXmx standard for meaning of pixel values
responses:
"200":
description: Pixel mask in TIFF format (4 byte; unsigned)
content:
image/tiff:
schema:
type: string
format: binary
/config/user_mask.tiff:
get:
summary: Get user mask of the detector
description: "Get user pixel mask of the detector in the actual detector coordinates: 0 - good pixel, 1 - masked"
responses:
"200":
description: User mask in TIFF format (4 byte; unsigned)
content:
image/tiff:
schema:
type: string
format: binary
put:
summary: Upload user mask of the detector
description: |
Should be in `Idle` state.
Upload user mask of the detector - this is for example to account for beam stop shadow or misbehaving regions.
If detector is conversion mode the mask can be both in raw (1024x512; stacked modules) or converted coordinates.
In the latter case - module gaps are ignored and don't need to be assigned value.
Mask is expected as TIFF (4-byte; unsigned).
0 - good pixel, other value - masked
User mask is stored in NXmx pixel mask (bit 8), as well as used in spot finding and azimuthal integration.
User mask is not automatically applied - i.e. pixels with user mask will have a valid pixel value in the images.
requestBody:
content:
application/octet-stream:
schema:
type: string
format: binary
responses:
"200":
description: All good
content:
image/tiff:
schema:
type: string
format: binary
"500":
description: Error within Jungfraujoch code - see output message.
content:
application/json:
schema:
$ref: '#/components/schemas/error_message'
/preview/pedestal.tiff:
get:
parameters:
@@ -1755,14 +1597,4 @@ paths:
type: string
format: binary
"404":
description: No calibration recorded so far
/version:
get:
responses:
"200":
description: Release number of Jungfraujoch
content:
text/plain:
schema:
type: string
example: 1.0.0
description: No calibration recorded so far

View File

@@ -2,7 +2,7 @@
// Using OpenAPI licensed with Apache License 2.0
#include <vector>
#include <csignal>
#include <signal.h>
#include <fstream>
#include <nlohmann/json.hpp>
@@ -12,6 +12,8 @@
#include "JFJochBrokerHttp.h"
#include "JFJochBrokerParser.h"
#include "../frame_serialize/ZMQStream2PusherGroup.h"
#include "../frame_serialize/DumpCBORToFilePusher.h"
static Pistache::Http::Endpoint *httpEndpoint;
@@ -71,6 +73,8 @@ int main (int argc, char **argv) {
std::unique_ptr<JFJochReceiverService> receiver;
std::unique_ptr<ImagePusher> image_pusher;
ZMQContext context;
DiffractionExperiment experiment;
experiment.MaskChipEdges(true).MaskModuleEdges(true);
@@ -79,7 +83,19 @@ int main (int argc, char **argv) {
if (aq_devices.size() > 0) {
experiment.DataStreams(aq_devices.size());
ParseImagePusher(input, image_pusher);
std::string pusher_type = ParseString(input, "stream_type", "zmq");
if (pusher_type == "zmq") {
int32_t zmq_send_watermark = ParseInt32(input, "zmq_send_watermark", 100);
int32_t zmq_send_buffer_size = ParseInt32(input, "zmq_send_buffer_size", -1);
image_pusher = std::make_unique<ZMQStream2PusherGroup>(ParseStringArray(input, "zmq_image_addr"),
zmq_send_watermark,
zmq_send_buffer_size);
} else if (pusher_type == "dump_cbor") {
image_pusher = std::make_unique<DumpCBORToFilePusher>();
} else
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"stream_type allowed: zmq (default), dump_cbor");
int32_t send_buffer_size_MiB = ParseInt32(input, "send_buffer_size_MiB", 2048);
receiver = std::make_unique<JFJochReceiverService>(aq_devices, logger, *image_pusher, send_buffer_size_MiB);
@@ -95,9 +111,9 @@ int main (int argc, char **argv) {
logger.Info("Source {} Instrument {} Default rotation axis {:.2f},{:.2f},{:.2f}",
experiment.GetSourceName(), experiment.GetInstrumentName(),
experiment.GetDefaultRotationAxis().x,
experiment.GetDefaultRotationAxis().y,
experiment.GetDefaultRotationAxis().z);
experiment.GetDefaultOmegaAxis().x,
experiment.GetDefaultOmegaAxis().y,
experiment.GetDefaultOmegaAxis().z);
Pistache::Address addr(Pistache::Ipv4::any(), Pistache::Port(http_port));

File diff suppressed because one or more lines are too long

View File

@@ -23,19 +23,14 @@ MESSAGE(STATUS "Jungfraujoch version: ${PACKAGE_VERSION}")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/GitInfo.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/GitInfo.cpp" @ONLY)
ADD_LIBRARY(JFJochLogger STATIC
ADD_LIBRARY( JFJochCommon STATIC
Logger.cpp Logger.h
${CMAKE_CURRENT_BINARY_DIR}/GitInfo.cpp GitInfo.h
)
ADD_LIBRARY(JFJochZMQ STATIC ZMQWrappers.cpp ZMQWrappers.h)
ADD_LIBRARY(JFJochCommon STATIC
Coord.cpp Coord.h
DiffractionExperiment.cpp DiffractionExperiment.h
RawToConvertedGeometry.h
JFJochException.h
Definitions.h
${CMAKE_CURRENT_BINARY_DIR}/GitInfo.cpp GitInfo.h
ThreadSafeFIFO.h
DiffractionSpot.cpp DiffractionSpot.h
StatusVector.h
@@ -50,6 +45,7 @@ ADD_LIBRARY(JFJochCommon STATIC
RawToConvertedGeometryCore.h
Plot.h
../fpga/pcie_driver/jfjoch_fpga.h
ZMQWrappers.cpp ZMQWrappers.h
DatasetSettings.cpp DatasetSettings.h
ROIMap.cpp ROIMap.h
ROIElement.cpp ROIElement.h
@@ -61,9 +57,7 @@ ADD_LIBRARY(JFJochCommon STATIC
PixelMask.cpp PixelMask.h
)
TARGET_LINK_LIBRARIES(JFJochCommon JFJochLogger Compression JFCalibration -lrt)
TARGET_LINK_LIBRARIES(JFJochZMQ "$<BUILD_INTERFACE:libzmq-static>")
TARGET_LINK_LIBRARIES(JFJochCommon Compression JFCalibration "$<BUILD_INTERFACE:libzmq-static>" -lrt)
IF (CMAKE_CUDA_COMPILER)
TARGET_SOURCES(JFJochCommon PRIVATE CUDAWrapper.cu )

View File

@@ -17,11 +17,8 @@ int32_t get_gpu_count() {
void set_gpu(int32_t dev_id) {
auto dev_count = get_gpu_count();
// Ignore if no GPU present
if (dev_count > 0) {
if ((dev_id < 0) || (dev_id >= dev_count))
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Device ID cannot be negative");
if ((dev_id < 0) || (dev_id >= dev_count))
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Device ID cannot be negative");
cuda_err(cudaSetDevice(dev_id));
}
}
cuda_err(cudaSetDevice(dev_id));
}

View File

@@ -19,10 +19,12 @@ DatasetSettings::DatasetSettings() {
file_prefix = "test";
ntrigger = 1;
images_per_trigger = 1;
summation = 1;
fpga_pixel_output = FPGAPixelOutput::Auto;
space_group_number = 0; // not set
compression = CompressionAlgorithm::BSHUF_LZ4;
photon_energy_multiplier = 1.0f;
omega_start = 0.0f;
images_per_file = 1000;
data_reduction_factor_serialmx = 1.0;
}
@@ -149,34 +151,40 @@ DatasetSettings &DatasetSettings::TotalFlux(const std::optional<float> &input) {
return *this;
}
DatasetSettings &DatasetSettings::Goniometer(const std::optional<GoniometerAxis> &input) {
DatasetSettings &DatasetSettings::OmegaStep(const std::optional<float> &input) {
if (input) {
check_finite("Rotation angle increment", input->increment);
if (input->increment == 0.0f)
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Angle increment cannot be zero");
check_finite("Rotation angle start", input->start);
goniometer = input;
check_finite("Omega step", input.value());
}
if (input && (input == 0.0f))
omega_step.reset();
else
omega_step = input;
return *this;
}
DatasetSettings &DatasetSettings::RotationAxis(const std::optional<Coord> &c) {
DatasetSettings &DatasetSettings::OmegaStart(float input) {
check_finite("Omega start", input);
omega_start = input;
return *this;
}
DatasetSettings &DatasetSettings::OmegaAxis(const std::optional<Coord> &c) {
if (c) {
if (c->Length() == 0.0)
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Cannot use empty vector for omega");
rotation_axis = c->Normalize();
omega_rotation_axis = c->Normalize();
} else
rotation_axis = c;
omega_rotation_axis = c;
return *this;
}
DatasetSettings &DatasetSettings::HeaderAppendix(const nlohmann::json &input) {
DatasetSettings &DatasetSettings::HeaderAppendix(const std::string &input) {
header_appendix = input;
return *this;
}
DatasetSettings &DatasetSettings::ImageAppendix(const nlohmann::json &input) {
DatasetSettings &DatasetSettings::ImageAppendix(const std::string &input) {
image_appendix = input;
return *this;
}
@@ -190,6 +198,13 @@ DatasetSettings &DatasetSettings::PhotonEnergyMultiplayer(float input) {
return *this;
}
DatasetSettings &DatasetSettings::Summation(int64_t input) {
check_min("Summation", input, 1);
check_max("Summation", input, MAX_FPGA_SUMMATION);
summation = input;
return *this;
}
DatasetSettings &DatasetSettings::FPGAOutputMode(FPGAPixelOutput input) {
switch (input) {
case FPGAPixelOutput::Auto:
@@ -213,19 +228,23 @@ std::optional<float> DatasetSettings::GetTotalFlux() const {
return total_flux;
}
std::optional<GoniometerAxis> DatasetSettings::GetGoniometer() const {
return goniometer;
std::optional<float> DatasetSettings::GetOmegaStep() const {
return omega_step;
}
std::optional<Coord> DatasetSettings::GetRotationAxis() const {
return rotation_axis;
float DatasetSettings::GetOmegaStart() const {
return omega_start;
}
const nlohmann::json& DatasetSettings::GetHeaderAppendix() const {
std::optional<Coord> DatasetSettings::GetOmegaAxis() const {
return omega_rotation_axis;
}
std::string DatasetSettings::GetHeaderAppendix() const {
return header_appendix;
}
const nlohmann::json& DatasetSettings::GetImageAppendix() const {
std::string DatasetSettings::GetImageAppendix() const {
return image_appendix;
}
@@ -241,6 +260,10 @@ int64_t DatasetSettings::GetSpaceGroupNumber() const {
return space_group_number;
}
int64_t DatasetSettings::GetSummation() const {
return summation;
}
FPGAPixelOutput DatasetSettings::GetFPGAOutputMode() const {
return fpga_pixel_output;
}
@@ -299,74 +322,13 @@ int64_t DatasetSettings::GetImagesPerFile() const {
return images_per_file;
}
DatasetSettings &DatasetSettings::LossyCompressionSerialMX(float input) {
DatasetSettings &DatasetSettings::DataReductionFactorSerialMX(float input) {
check_min("Data reduction factor for serial MX", input, 0.0);
check_max("Data reduction factor for serial MX", input, 1.0);
data_reduction_factor_serialmx = input;
return *this;
}
float DatasetSettings::GetLossyCompressionSerialMX() const {
float DatasetSettings::GetDataReductionFactorSerialMX() const {
return data_reduction_factor_serialmx;
}
DatasetSettings &DatasetSettings::RunNumber(const std::optional<uint64_t> &input) {
if (input) {
check_min("Run number", input, 0);
check_max("Run number", input, INT64_MAX);
}
run_number = input;
return *this;
}
DatasetSettings & DatasetSettings::RunName(const std::optional<std::string> &input) {
if (input && input.value().empty())
run_name = {};
else
run_name = input;
return *this;
}
DatasetSettings &DatasetSettings::ExperimentGroup(const std::string &input) {
group = input;
return *this;
}
std::optional<uint64_t> DatasetSettings::GetRunNumber() const {
return run_number;
}
std::optional<std::string> DatasetSettings::GetRunName() const {
return run_name;
}
std::string DatasetSettings::GetExperimentGroup() const {
return group;
}
std::optional<std::chrono::microseconds> DatasetSettings::GetImageTime() const {
return image_time;
}
DatasetSettings &DatasetSettings::ImageTime(const std::optional<std::chrono::microseconds> input) {
if (input && (input.value().count() == 0))
image_time = {};
else
image_time = input;
return *this;
}
DatasetSettings &DatasetSettings::LossyCompressionPoisson(std::optional<int64_t> input) {
if (!input || (input == 0))
compression_poisson_factor = {};
else {
check_min("Poisson compression factor", input.value(), 1);
check_max("Poisson compression factor", input.value(), 16);
compression_poisson_factor = input;
}
return *this;
}
std::optional<int64_t> DatasetSettings::GetLossyCompressionPoisson() const {
return compression_poisson_factor;
}

View File

@@ -21,6 +21,7 @@ class DatasetSettings {
int64_t ntrigger;
FPGAPixelOutput fpga_pixel_output;
int64_t summation;
float beam_x_pxl;
float beam_y_pxl;
@@ -39,19 +40,14 @@ class DatasetSettings {
std::optional<float> total_flux;
std::optional<float> attenuator_transmission;
std::optional<GoniometerAxis> goniometer;
nlohmann::json image_appendix;
nlohmann::json header_appendix;
std::optional<float> omega_step;
float omega_start;
std::string image_appendix;
std::string header_appendix;
std::optional<Coord> rotation_axis;
std::optional<Coord> omega_rotation_axis;
float data_reduction_factor_serialmx;
std::optional<std::chrono::microseconds> image_time;
std::optional<uint64_t> run_number;
std::optional<std::string> run_name;
std::string group;
std::optional<int64_t> compression_poisson_factor;
public:
DatasetSettings();
@@ -69,30 +65,28 @@ public:
DatasetSettings& SampleName(std::string input);
DatasetSettings& AttenuatorTransmission(const std::optional<float> &input);
DatasetSettings& TotalFlux(const std::optional<float> &input);
DatasetSettings& Goniometer(const std::optional<GoniometerAxis>& input);
DatasetSettings& RotationAxis(const std::optional<Coord> &c);
DatasetSettings& HeaderAppendix(const nlohmann::json& input);
DatasetSettings& ImageAppendix(const nlohmann::json& input);
DatasetSettings& OmegaStep(const std::optional<float> &input);
DatasetSettings& OmegaStart(float input);
DatasetSettings& OmegaAxis(const std::optional<Coord> &c);
DatasetSettings& HeaderAppendix(const std::string& input);
DatasetSettings& ImageAppendix(const std::string& input);
DatasetSettings& PhotonEnergyMultiplayer(float input);
DatasetSettings& Summation(int64_t input);
DatasetSettings& FPGAOutputMode(FPGAPixelOutput input);
DatasetSettings& ImagesPerFile(int64_t input);
DatasetSettings& RunNumber(const std::optional<uint64_t> &run_number);
DatasetSettings& RunName(const std::optional<std::string> &input);
DatasetSettings& ExperimentGroup(const std::string &group);
DatasetSettings& ImageTime(const std::optional<std::chrono::microseconds> input);
DatasetSettings& LossyCompressionSerialMX(float input);
DatasetSettings& LossyCompressionPoisson(std::optional<int64_t> input);
DatasetSettings& DataReductionFactorSerialMX(float input);
std::optional<float> GetAttenuatorTransmission() const;
std::optional<float> GetTotalFlux() const;
std::optional<GoniometerAxis> GetGoniometer() const;
std::optional<Coord> GetRotationAxis() const;
const nlohmann::json& GetHeaderAppendix() const;
const nlohmann::json& GetImageAppendix() const;
std::optional<float> GetOmegaStep() const;
float GetOmegaStart() const;
std::optional<Coord> GetOmegaAxis() const;
std::string GetHeaderAppendix() const;
std::string GetImageAppendix() const;
float GetPhotonEnergyMultiplier() const;
std::optional<UnitCell> GetUnitCell() const;
int64_t GetSpaceGroupNumber() const;
int64_t GetSummation() const;
FPGAPixelOutput GetFPGAOutputMode() const;
std::string GetSampleName() const;
float GetPhotonEnergy_keV() const;
@@ -109,14 +103,7 @@ public:
int64_t GetNumTriggers() const;
int64_t GetImageNumPerTrigger() const;
int64_t GetImagesPerFile() const;
std::optional<uint64_t> GetRunNumber() const;
std::optional<std::string> GetRunName() const;
std::string GetExperimentGroup() const;
std::optional<std::chrono::microseconds> GetImageTime() const;
float GetLossyCompressionSerialMX() const;
std::optional<int64_t> GetLossyCompressionPoisson() const;
float GetDataReductionFactorSerialMX() const;
};
#endif //JUNGFRAUJOCH_DATASETSETTINGS_H

View File

@@ -12,12 +12,10 @@
#define CONVERTED_MODULE_SIZE (CONVERTED_MODULE_LINES * CONVERTED_MODULE_COLS)
#define JUNGFRAU_PACKET_SIZE_BYTES (8192)
#define MIN_COUNT_TIME_IN_US 5
#define MIN_FRAME_TIME_HALF_SPEED_IN_US 1000
#define MIN_FRAME_TIME_FULL_SPEED_IN_US 470
#define MAX_COUNT_TIME_IN_US 1980
#define MIN_COUNT_TIME_IN_US 3
#define MAX_FRAME_TIME 2000
#define MIN_STORAGE_CELL_DELAY_IN_NS 2100
#define READOUT_TIME_IN_US 20

View File

@@ -148,12 +148,3 @@ void DetectorSetup::SetTrimFiles(const std::vector<std::string> &filenames) {
const std::vector<std::string> &DetectorSetup::GetTrimFileNames() const {
return trim_file_names;
}
std::string DetectorSetup::GetSerialNumber() const {
return serial_number;
}
DetectorSetup &DetectorSetup::SerialNumber(const std::string &input) {
serial_number = input;
return *this;
}

View File

@@ -10,7 +10,6 @@ enum class DetectorType {EIGER, JUNGFRAU};
class DetectorSetup {
std::string description;
std::string serial_number;
DetectorGeometry geometry;
std::vector<std::string> det_modules_hostname;
std::vector<std::string> gain_file_names;
@@ -42,7 +41,6 @@ public:
DetectorSetup& SensorThickness_um(float input);
DetectorSetup& PixelSize_um(float input);
DetectorSetup& HighVoltage(int32_t input);
DetectorSetup& SerialNumber(const std::string &input);
[[nodiscard]] DetectorType GetDetectorType() const;
[[nodiscard]] const DetectorGeometry& GetGeometry() const;
@@ -58,7 +56,6 @@ public:
[[nodiscard]] const std::vector<std::string> &GetGainFileNames() const;
[[nodiscard]] const std::vector<std::string> &GetTrimFileNames() const;
[[nodiscard]] int32_t GetHighVoltage() const;
[[nodiscard]] std::string GetSerialNumber() const;
};

View File

@@ -9,8 +9,6 @@
#include "JFJochException.h"
#include "RawToConvertedGeometry.h"
#include "../fpga/pcie_driver/jfjoch_fpga.h"
#include "../include/spdlog/fmt/fmt.h"
#include "GitInfo.h"
using namespace std::literals::chrono_literals;
@@ -30,6 +28,8 @@ DiffractionExperiment::DiffractionExperiment(const DetectorSetup& det_setup)
internal_fpga_packet_generator = false;
internal_fpga_packet_generator_images = 1;
debug_pixel_mask = false;
ndatastreams = 1;
frame_time = std::chrono::microseconds(MIN_FRAME_TIME_HALF_SPEED_IN_US);
@@ -67,8 +67,6 @@ DiffractionExperiment::DiffractionExperiment(const DetectorSetup& det_setup)
mode = DetectorMode::Conversion;
max_spot_count = MAX_SPOT_COUNT;
summation = 1;
}
// setter functions
@@ -103,13 +101,10 @@ DiffractionExperiment &DiffractionExperiment::NumTriggers(int64_t input) {
DiffractionExperiment &DiffractionExperiment::FrameTime(std::chrono::microseconds in_frame_time,
std::chrono::microseconds in_count_time) {
check_min("Frame time (us)", in_frame_time.count(), MIN_FRAME_TIME_FULL_SPEED_IN_US);
check_max("Frame time (us)", in_frame_time.count(), MAX_FRAME_TIME);
check_max("Count time (us)", in_count_time.count(), in_frame_time.count() - READOUT_TIME_IN_US);
if (in_count_time.count() != 0) {
check_min("Count time (us)", in_count_time.count(), MIN_COUNT_TIME_IN_US);
check_max("Count time (us)", in_count_time.count(), MAX_COUNT_TIME_IN_US);
} else {
check_max("Count time (us)", in_frame_time.count() - READOUT_TIME_IN_US,
MAX_COUNT_TIME_IN_US);
}
frame_time = in_frame_time;
@@ -602,20 +597,6 @@ std::optional<UnitCell> DiffractionExperiment::GetUnitCell() const {
return dataset.GetUnitCell();
}
std::string DiffractionExperiment::GetUnitCellString() const {
auto uc = dataset.GetUnitCell();
if (uc.has_value()) {
return fmt::format("{:.1f}, {:.1f}, {:.1f}, {:.1f}, {:.1f} {:.1f}",
uc.value().a,
uc.value().b,
uc.value().c,
uc.value().alpha,
uc.value().beta,
uc.value().gamma);
} else
return "-";
}
Coord DiffractionExperiment::LabCoord(float detector_x, float detector_y) const {
// Assumes planar detector, 90 deg towards beam
return {(detector_x - GetBeamX_pxl()) * GetPixelSize_mm() ,
@@ -688,7 +669,6 @@ void DiffractionExperiment::CheckDataProcessingSettings(const SpotFindingSetting
check_min("Spot finding low resolution limit", settings.low_resolution_limit, 1.0);
check_max("Spot finding low resolution limit", settings.low_resolution_limit, 50.0);
}
check_min("min spot count for powder ring detection", settings.min_spot_count_powder_ring, 5);
check_min("indexing tolerance", settings.indexing_tolerance, 0.0);
check_max("indexing tolerance", settings.indexing_tolerance, 1.0);
}
@@ -735,7 +715,6 @@ void DiffractionExperiment::FillMessage(StartMessage &message) const {
message.source_name = GetSourceName();
message.source_name_short = GetSourceNameShort();
message.source_type = GetSourceType();
message.instrument_name = GetInstrumentName();
message.instrument_name_short = GetInstrumentNameShort();
@@ -745,26 +724,19 @@ void DiffractionExperiment::FillMessage(StartMessage &message) const {
message.countrate_correction_enabled = false;
message.flatfield_enabled = false;
auto goniometer = dataset.GetGoniometer();
if (goniometer) {
message.goniometer = goniometer;
message.rotation_axis[0] = GetRotationAxis().x;
message.rotation_axis[1] = GetRotationAxis().y;
message.rotation_axis[2] = GetRotationAxis().z;
}
if (GetOmegaStep())
message.omega = GoniometerAxis{.increment = GetOmegaStep().value(), .start = GetOmegaStart(),
.axis = {GetOmegaAxis().x, GetOmegaAxis().y, GetOmegaAxis().z}};
else
message.omega = GoniometerAxis{.increment = 0.0f};
message.run_number = GetRunNumber();
message.run_name = GetRunName();
message.series_id = GetSeriesID();
message.series_unique_id = GetSeriesIDString();
message.gain_file_names = detector.GetGainFileNames();
for (const auto &[x, y]: roi_mask.GetROINameMap())
message.roi_names.emplace_back(x);
message.data_reduction_factor_serialmx = GetLossyCompressionSerialMX();
message.experiment_group = dataset.GetExperimentGroup();
message.jfjoch_release = jfjoch_version();
message.detector_serial_number = detector.GetSerialNumber();
}
float DiffractionExperiment::GetPixelSize_mm() const {
@@ -781,11 +753,6 @@ DiffractionExperiment &DiffractionExperiment::SourceNameShort(std::string input)
return *this;
}
DiffractionExperiment &DiffractionExperiment::SourceType(std::string input) {
source_type = input;
return *this;
}
DiffractionExperiment &DiffractionExperiment::InstrumentName(std::string input) {
instrument_name = input;
return *this;
@@ -804,10 +771,6 @@ std::string DiffractionExperiment::GetSourceNameShort() const {
return source_name_short;
}
std::string DiffractionExperiment::GetSourceType() const {
return source_type;
}
std::string DiffractionExperiment::GetInstrumentName() const {
return instrument_name;
}
@@ -885,9 +848,7 @@ std::chrono::nanoseconds DiffractionExperiment::GetStorageCellDelay() const {
}
DiffractionExperiment &DiffractionExperiment::Summation(int64_t input) {
check_min("Summation factor", input, 1);
check_max("Summation factor", input, MAX_FPGA_SUMMATION);
summation = input;
dataset.Summation(input);
return *this;
}
@@ -903,7 +864,7 @@ int64_t DiffractionExperiment::GetSummation() const {
if (GetStorageCellNumber() > 1)
return 1;
else
return summation;
return dataset.GetSummation();
}
}
@@ -972,13 +933,22 @@ std::optional<float> DiffractionExperiment::GetTotalFlux() const {
return dataset.GetTotalFlux();
}
DiffractionExperiment &DiffractionExperiment::Goniometer(const std::optional<GoniometerAxis> &input) {
dataset.Goniometer(input);
DiffractionExperiment &DiffractionExperiment::OmegaStep(const std::optional<float> &input) {
dataset.OmegaStep(input);
return *this;
}
std::optional<GoniometerAxis> DiffractionExperiment::GetGoniometer() const {
return dataset.GetGoniometer();
DiffractionExperiment &DiffractionExperiment::OmegaStart(float input) {
dataset.OmegaStart(input);
return *this;
}
std::optional<float> DiffractionExperiment::GetOmegaStep() const {
return dataset.GetOmegaStep();
}
float DiffractionExperiment::GetOmegaStart() const {
return dataset.GetOmegaStart();
}
DiffractionExperiment &DiffractionExperiment::UsingGainHG0(bool input) {
@@ -999,64 +969,63 @@ bool DiffractionExperiment::IsUsingGainHG0() const {
return use_gain_hg0;
}
DiffractionExperiment &DiffractionExperiment::HeaderAppendix(const nlohmann::json &input) {
DiffractionExperiment &DiffractionExperiment::HeaderAppendix(const std::string &input) {
dataset.HeaderAppendix(input);
return *this;
}
DiffractionExperiment &DiffractionExperiment::ImageAppendix(const nlohmann::json &input) {
DiffractionExperiment &DiffractionExperiment::ImageAppendix(const std::string &input) {
dataset.ImageAppendix(input);
return *this;
}
const nlohmann::json& DiffractionExperiment::GetHeaderAppendix() const {
std::string DiffractionExperiment::GetHeaderAppendix() const {
return dataset.GetHeaderAppendix();
}
const nlohmann::json& DiffractionExperiment::GetImageAppendix() const {
std::string DiffractionExperiment::GetImageAppendix() const {
return dataset.GetImageAppendix();
}
DiffractionExperiment &DiffractionExperiment::RotationAxis(const std::optional<Coord> &c) {
dataset.RotationAxis(c);
DiffractionExperiment &DiffractionExperiment::OmegaAxis(const Coord &c) {
dataset.OmegaAxis(c);
return *this;
}
Coord DiffractionExperiment::GetRotationAxis() const {
auto tmp = dataset.GetRotationAxis();
DiffractionExperiment &DiffractionExperiment::OmegaAxis() {
dataset.OmegaAxis({});
return *this;
}
Coord DiffractionExperiment::GetOmegaAxis() const {
auto tmp = dataset.GetOmegaAxis();
if (tmp)
return tmp.value();
else
return default_omega_axis;
}
DiffractionExperiment &DiffractionExperiment::DefaultRotationAxis(const Coord &c) {
DiffractionExperiment &DiffractionExperiment::DefaultOmegaAxis(const Coord &c) {
if (c.Length() == 0.0)
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Cannot use empty vector for goniometer axis");
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Cannot use empty vector for omega axis");
default_omega_axis = c.Normalize();
return *this;
}
Coord DiffractionExperiment::GetDefaultRotationAxis() const {
Coord DiffractionExperiment::GetDefaultOmegaAxis() const {
return default_omega_axis;
}
uint64_t DiffractionExperiment::GetRunNumber() const {
if (dataset.GetRunNumber())
return dataset.GetRunNumber().value();
uint64_t DiffractionExperiment::GetSeriesID() const {
return series_id;
}
std::string DiffractionExperiment::GetRunName() const {
auto run_name = dataset.GetRunName();
if (run_name)
return run_name.value();
else
return std::to_string(series_id) + ":" + dataset.GetFilePrefix();
std::string DiffractionExperiment::GetSeriesIDString() const {
return std::to_string(series_id) + ": " + dataset.GetFilePrefix();
}
DiffractionExperiment &DiffractionExperiment::IncrementRunNumber() {
DiffractionExperiment &DiffractionExperiment::IncrementSeriesID() {
series_id++;
return *this;
}
@@ -1083,7 +1052,6 @@ bool DiffractionExperiment::IsConversionOnFPGA() const {
}
DiffractionExperiment &DiffractionExperiment::DetectorDelay(std::chrono::nanoseconds input) {
check_min("Detector delay (us)", input.count(), 0);
detector_delay = input;
return *this;
}
@@ -1096,6 +1064,15 @@ const DetectorSetup &DiffractionExperiment::GetDetectorSetup() const {
return detector;
}
DiffractionExperiment &DiffractionExperiment::NeuralNetModelPath(const std::string &input) {
neural_net_model_path = input;
return *this;
}
std::string DiffractionExperiment::GetNeuralNetModelPath() const {
return neural_net_model_path;
}
DiffractionExperiment &DiffractionExperiment::PulsedSource(bool input) {
pulsed_source = input;
return *this;
@@ -1143,19 +1120,6 @@ int64_t DiffractionExperiment::GetInternalPacketGeneratorImages() const {
DiffractionExperiment &DiffractionExperiment::ImportDatasetSettings(const DatasetSettings &input) {
auto tmp = dataset;
dataset = input;
auto image_time = input.GetImageTime();
if (image_time) {
if (image_time->count() % GetFrameTime().count() != 0)
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Image time must be multiple of frame time");
if (GetFrameTime().count() == 0)
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Frame time cannot be zero");
this->Summation(image_time.value() / GetFrameTime());
} else
summation = 1;
if (GetFrameNum() >= MAX_FRAMES) {
dataset = tmp;
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
@@ -1205,24 +1169,11 @@ int64_t DiffractionExperiment::GetSendBufferLocationSize() const {
return GetMaxCompressedSize() + 1024 * 1024;
}
float DiffractionExperiment::GetLossyCompressionSerialMX() const {
return dataset.GetLossyCompressionSerialMX();
float DiffractionExperiment::GetDataReductionFactorSerialMX() const {
return dataset.GetDataReductionFactorSerialMX();
}
DiffractionExperiment &DiffractionExperiment::LossyCompressionSerialMX(float input) {
dataset.LossyCompressionSerialMX(input);
DiffractionExperiment &DiffractionExperiment::DataReductionFactorSerialMX(float input) {
dataset.DataReductionFactorSerialMX(input);
return *this;
}
std::optional<int64_t> DiffractionExperiment::GetLossyCompressionPoisson() const {
return dataset.GetLossyCompressionPoisson();
}
DiffractionExperiment &DiffractionExperiment::LossyCompressionPoisson(std::optional<int64_t> input) {
dataset.LossyCompressionPoisson(input);
return *this;
}
std::string DiffractionExperiment::GetExperimentGroup() const {
return dataset.GetExperimentGroup();
}

View File

@@ -78,17 +78,19 @@ class DiffractionExperiment {
std::string source_name;
std::string source_name_short;
std::string source_type;
std::string instrument_name;
std::string instrument_name_short;
bool pulsed_source;
bool debug_pixel_mask;
Coord default_omega_axis;
bool conversion_on_fpga;
uint64_t series_id;
std::string neural_net_model_path;
bool rad_int_solid_angle_corr;
bool rad_int_polarization_corr;
float rad_int_polarization_factor{};
@@ -98,10 +100,6 @@ class DiffractionExperiment {
ROIMap roi_mask;
int64_t max_spot_count;
int64_t summation;
std::string detector_update_zmq_addr;
public:
// Public methods are atomic
DiffractionExperiment();
@@ -137,16 +135,16 @@ public:
DiffractionExperiment& StorageCellStart(int64_t input = 15);
DiffractionExperiment& SourceName(std::string input);
DiffractionExperiment& SourceType(std::string input);
DiffractionExperiment& SourceNameShort(std::string input);
DiffractionExperiment& InstrumentName(std::string input);
DiffractionExperiment& InstrumentNameShort(std::string input);
DiffractionExperiment& DefaultRotationAxis(const Coord &c);
DiffractionExperiment& DefaultOmegaAxis(const Coord &c);
DiffractionExperiment& UsingGainHG0(bool input);
DiffractionExperiment& FixedGainG1(bool input);
DiffractionExperiment& IncrementRunNumber();
DiffractionExperiment& IncrementSeriesID();
DiffractionExperiment& ConversionOnFPGA(bool input);
DiffractionExperiment& NeuralNetModelPath(const std::string& input);
DiffractionExperiment& PulsedSource(bool input);
DiffractionExperiment& ImagesPerTrigger(int64_t input);
@@ -162,17 +160,18 @@ public:
DiffractionExperiment& SampleName(std::string input);
DiffractionExperiment& AttenuatorTransmission(const std::optional<float> &input);
DiffractionExperiment& TotalFlux(const std::optional<float> &input);
DiffractionExperiment& Goniometer(const std::optional<GoniometerAxis> &input);
DiffractionExperiment& RotationAxis(const std::optional<Coord> &c);
DiffractionExperiment& HeaderAppendix(const nlohmann::json& input);
DiffractionExperiment& ImageAppendix(const nlohmann::json& input);
DiffractionExperiment& OmegaStep(const std::optional<float> &input);
DiffractionExperiment& OmegaStart(float input);
DiffractionExperiment& OmegaAxis(const Coord &c);
DiffractionExperiment& OmegaAxis();
DiffractionExperiment& HeaderAppendix(const std::string& input);
DiffractionExperiment& ImageAppendix(const std::string& input);
DiffractionExperiment& PhotonEnergyMultiplayer(float input);
DiffractionExperiment& Summation(int64_t input);
DiffractionExperiment& FPGAOutputMode(FPGAPixelOutput input);
DiffractionExperiment& MaxSpotCount(int64_t input);
DiffractionExperiment& ImagesPerFile(int64_t input);
DiffractionExperiment& LossyCompressionSerialMX(float input);
DiffractionExperiment& LossyCompressionPoisson(std::optional<int64_t> input);
DiffractionExperiment& DataReductionFactorSerialMX(float input);
DiffractionExperiment& ImportDatasetSettings(const DatasetSettings& input);
DatasetSettings GetDatasetSettings() const;
@@ -257,7 +256,6 @@ public:
float GetPixelSize_mm() const;
std::string GetSourceName() const;
std::string GetSourceType() const;
std::string GetSourceNameShort() const;
std::string GetInstrumentName() const;
std::string GetInstrumentNameShort() const;
@@ -274,16 +272,17 @@ public:
int64_t GetUDPInterfaceCount() const;
std::vector<DetectorModuleConfig> GetDetectorModuleConfig(const std::vector<AcquisitionDeviceNetConfig>& net_config) const;
Coord GetDefaultRotationAxis() const;
Coord GetDefaultOmegaAxis() const;
bool IsFixedGainG1() const;
bool IsUsingGainHG0() const;
uint64_t GetRunNumber() const;
std::string GetRunName() const;
uint64_t GetSeriesID() const;
std::string GetSeriesIDString() const;
bool IsConversionOnFPGA() const;
const DetectorSetup& GetDetectorSetup() const;
std::string GetNeuralNetModelPath() const;
bool IsPulsedSource() const;
@@ -293,14 +292,13 @@ public:
std::optional<float> GetAttenuatorTransmission() const;
std::optional<float> GetTotalFlux() const;
std::optional<GoniometerAxis> GetGoniometer() const;
Coord GetRotationAxis() const;
const nlohmann::json& GetHeaderAppendix() const;
const nlohmann::json& GetImageAppendix() const;
std::optional<float> GetOmegaStep() const;
float GetOmegaStart() const;
Coord GetOmegaAxis() const;
std::string GetHeaderAppendix() const;
std::string GetImageAppendix() const;
float GetPhotonEnergyMultiplier() const;
std::optional<UnitCell> GetUnitCell() const;
std::string GetUnitCellString() const;
int64_t GetSpaceGroupNumber() const;
bool GetSaveCalibration() const;
int64_t GetSummation() const;
@@ -325,9 +323,7 @@ public:
void ExportROIMap(uint16_t *v, size_t module_number) const;
int64_t GetImagesPerFile() const;
float GetLossyCompressionSerialMX() const;
std::optional<int64_t> GetLossyCompressionPoisson() const;
std::string GetExperimentGroup() const;
float GetDataReductionFactorSerialMX() const;
};
#endif //DIFFRACTIONEXPERIMENT_H

View File

@@ -46,6 +46,15 @@ NUMAHWPolicy::NUMAHWPolicy(const std::string &policy) : name(policy) {
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Unknown NUMA policy");
}
NUMAHWPolicy::NUMAHWPolicy(const NUMAHWPolicy &other) : bindings(other.bindings), name(other.name), curr_thread(0) {}
NUMAHWPolicy &NUMAHWPolicy::operator=(const NUMAHWPolicy &other) {
bindings = other.bindings;
name = other.name;
curr_thread = 0;
return *this;
}
NUMABinding NUMAHWPolicy::GetBinding(uint32_t thread) {
if (bindings.empty())
return NUMABinding{.cpu_node = -1, .mem_node = -1, .gpu = -1};
@@ -53,6 +62,14 @@ NUMABinding NUMAHWPolicy::GetBinding(uint32_t thread) {
return bindings.at(thread % bindings.size());
}
NUMABinding NUMAHWPolicy::GetBinding() {
return GetBinding(curr_thread++);
}
void NUMAHWPolicy::Bind() {
Bind(GetBinding());
}
void NUMAHWPolicy::Bind(uint32_t thread) {
Bind(GetBinding(thread));
}

View File

@@ -17,14 +17,19 @@ struct NUMABinding {
class NUMAHWPolicy {
std::string name;
std::vector<NUMABinding> bindings;
std::atomic<uint32_t> curr_thread = 0;
public:
NUMAHWPolicy() = default;
explicit NUMAHWPolicy(const std::string& policy);
NUMAHWPolicy(const NUMAHWPolicy& other);
NUMAHWPolicy& operator=(const NUMAHWPolicy& other);
NUMABinding GetBinding(uint32_t thread);
NUMABinding GetBinding(); // round-robin
const std::string &GetName() const;
void Bind(uint32_t thread);
void Bind(); // round-robin
static void Bind(const NUMABinding &binding);
static void RunOnNode(int32_t cpu_node);
static void MemOnNode(int32_t mem_node);

View File

@@ -12,7 +12,7 @@ PixelMask::PixelMask(const DetectorSetup &detector)
PixelMask::PixelMask(const DiffractionExperiment& experiment)
: PixelMask(experiment.GetDetectorSetup()) {}
void PixelMask::LoadMask(const std::vector<uint32_t> &input_mask, uint8_t bit) {
void PixelMask::LoadDetectorBadPixelMask(const std::vector<uint32_t> &input_mask, uint8_t bit) {
if (input_mask.size() != mask.size())
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Input match doesn't fit the detector ");
@@ -25,11 +25,7 @@ void PixelMask::LoadMask(const std::vector<uint32_t> &input_mask, uint8_t bit) {
}
}
void PixelMask::LoadDetectorBadPixelMask(const std::vector<uint32_t> &input_mask) {
LoadMask(input_mask, ErrorPixelBit);
}
std::vector<uint32_t> PixelMask::GetMask(const DiffractionExperiment &experiment, bool conv) const {
std::vector<uint32_t> PixelMask::GetMask(const DiffractionExperiment &experiment) {
std::vector<uint32_t> mask_out = mask;
// apply edge mask
@@ -43,7 +39,7 @@ std::vector<uint32_t> PixelMask::GetMask(const DiffractionExperiment &experiment
|| (line == RAW_MODULE_LINES - 1)
|| (col == 0)
|| (col == RAW_MODULE_COLS - 1))
mask_out[pixel] |= (1 << ModuleEdgePixelBit);
mask_out[pixel] |= (1 << 30);
}
if (experiment.GetMaskChipEdges()) {
@@ -51,39 +47,33 @@ std::vector<uint32_t> PixelMask::GetMask(const DiffractionExperiment &experiment
|| (col == 511) || (col == 512)
|| (col == 767) || (col == 768)
|| (line == 255) || (line== 256))
mask_out[pixel] |= (1 << ChipGapPixelBit);
mask_out[pixel] |= (1 << 31);
}
}
}
}
if (conv && (experiment.GetDetectorMode() == DetectorMode::Conversion)) {
std::vector<uint32_t> tmp(experiment.GetPixelsNum(), 1<<ModuleGapPixelBit); // nonfunctional areas (i.e. gaps) are filled with 1
if (experiment.GetDetectorMode() == DetectorMode::Conversion) {
std::vector<uint32_t> tmp(experiment.GetPixelsNum(), 1); // nonfuctional areas (i.e. gaps) are filled with 1
RawToConvertedGeometry<uint32_t, uint32_t>(experiment, tmp.data(), mask_out.data());
return tmp;
} else
return mask_out;
}
std::vector<uint32_t> PixelMask::GetUserMask(const DiffractionExperiment &experiment, bool conv) const {
std::vector<uint32_t> ret = GetMask(experiment, conv);
for (auto &i: ret)
i = ((i & (1 << UserMaskedPixelBit)) != 0) ? 1 : 0;
return ret;
}
void PixelMask::LoadUserMask(const DiffractionExperiment &experiment,
const std::vector<uint32_t> &in_mask) {
const std::vector<uint32_t> &in_mask,
uint8_t bit) {
if (experiment.GetModulesNum() != nmodules)
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Mismatch in module size");
if (in_mask.size() == nmodules * RAW_MODULE_SIZE) {
LoadMask(in_mask, UserMaskedPixelBit);
LoadDetectorBadPixelMask(in_mask, bit);
} else if (in_mask.size() == experiment.GetPixelsNum()) {
std::vector<uint32_t> raw_mask(nmodules * RAW_MODULE_SIZE);
ConvertedToRawGeometry(experiment, raw_mask.data(), in_mask.data());
LoadMask(raw_mask, UserMaskedPixelBit);
LoadDetectorBadPixelMask(in_mask, bit);
} else
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Size of input user mask invalid");

View File

@@ -9,21 +9,12 @@
class PixelMask {
size_t nmodules;
std::vector<uint32_t> mask;
void LoadMask(const std::vector<uint32_t>& mask, uint8_t bit);
public:
// NXmx bits
constexpr static const uint8_t ModuleGapPixelBit = 0;
constexpr static const uint8_t ErrorPixelBit = 1;
constexpr static const uint8_t UserMaskedPixelBit = 8;
constexpr static const uint8_t ChipGapPixelBit = 31;
constexpr static const uint8_t ModuleEdgePixelBit = 30;
PixelMask(const DetectorSetup& detector);
PixelMask(const DiffractionExperiment& experiment);
void LoadUserMask(const DiffractionExperiment& experiment, const std::vector<uint32_t>& mask);
void LoadDetectorBadPixelMask(const std::vector<uint32_t>& mask);
std::vector<uint32_t> GetMask(const DiffractionExperiment& experiment, bool conv = true) const;
std::vector<uint32_t> GetUserMask(const DiffractionExperiment& experiment, bool conv = true) const;
void LoadUserMask(const DiffractionExperiment& experiment, const std::vector<uint32_t>& mask, uint8_t bit);
void LoadDetectorBadPixelMask(const std::vector<uint32_t>& mask, uint8_t bit);
std::vector<uint32_t> GetMask(const DiffractionExperiment& experiment);
};

View File

@@ -7,12 +7,9 @@
#include <cstdint>
#include <string>
enum class PlotType {
BkgEstimate, RadInt, RadIntPerTimePoint, SpotCount, SpotCountInRings,
IndexingRate, IndexingRatePerTimePoint,
ErrorPixels, ImageCollectionEfficiency, ReceiverDelay, ReceiverFreeSendBuf, StrongPixels,
ROISum, ROIMaxCount, ROIPixels
};
enum class PlotType {BkgEstimate, RadInt, RadIntPerTimePoint, SpotCount, IndexingRate, IndexingRatePerTimePoint,
ErrorPixels, ImageCollectionEfficiency, ReceiverDelay, ReceiverFreeSendBuf, StrongPixels,
ROISum, ROIMaxCount, ROIPixels, ResEstimation};
struct PlotRequest {
PlotType type;

View File

@@ -7,7 +7,6 @@
#include <map>
#include <mutex>
#include <cmath>
#include <optional>
#include "Plot.h"
@@ -38,11 +37,6 @@ template <class T> class StatusVector {
return ret;
}
public:
void AddElement(uint32_t id, std::optional<T> val) {
if (val.has_value())
AddElement(id, val.value());
}
void AddElement(uint32_t id, T val) {
std::unique_lock<std::mutex> ul(m);
if (id >= content.size()) {

View File

@@ -8,7 +8,8 @@ ZMQContext::ZMQContext() {
// Default is to have 2 I/O threads per ZMQ context
if (zmq_ctx_set(context, ZMQ_IO_THREADS, 2) != 0)
throw JFJochException(JFJochExceptionCategory::ZeroMQ, "Cannot set number of I/O threads");
throw JFJochException(JFJochExceptionCategory::ZeroMQ,
"Cannot set number of I/O threads");
}
ZMQContext &ZMQContext::NumThreads(int32_t threads) {
@@ -26,7 +27,7 @@ void *ZMQContext::GetContext() const {
return context;
}
ZMQSocket::ZMQSocket(ZMQSocketType in_socket_type) : socket_type(in_socket_type) {
ZMQSocket::ZMQSocket(ZMQContext &context, ZMQSocketType in_socket_type) : socket_type(in_socket_type) {
socket = zmq_socket(context.GetContext(), static_cast<int>(socket_type));
if (socket == nullptr)

View File

@@ -42,15 +42,14 @@ public:
class ZMQSocket {
std::mutex m;
ZMQContext context;
ZMQSocketType socket_type;
void *socket;
void SetSocketOption(int32_t option_name, int32_t value);
public:
ZMQSocket(ZMQSocket &socket) = delete;
const ZMQSocket& operator=(ZMQSocket &socket) = delete;
explicit ZMQSocket(ZMQSocketType socket_type);
~ZMQSocket();
ZMQSocket(ZMQContext &context, ZMQSocketType socket_type);
~ZMQSocket();
void Connect(const std::string& addr);
void Disconnect(const std::string& addr);
void Bind(const std::string& addr);

View File

@@ -1,2 +1,6 @@
INSTALL(TARGETS sls_detector_put sls_detector_get RUNTIME)
ADD_LIBRARY(JFJochDetector STATIC DetectorWrapper.cpp DetectorWrapper.h)
TARGET_LINK_LIBRARIES(JFJochDetector JFJochCommon slsDetectorStatic slsSupportStatic)
TARGET_LINK_LIBRARIES(JFJochDetector JFJochCommon slsSupportShared slsDetectorShared)

View File

@@ -65,14 +65,14 @@ void DetectorWrapper::Initialize(const DiffractionExperiment& experiment,
det.setSourceUDPIP(sls::IpAddr(cfg.ipv4_src_addr_1), {i});
det.setSourceUDPMAC(sls::MacAddr(BASE_DETECTOR_MAC + i * 2), {i});
det.setDestinationUDPPort(cfg.udp_dest_port_1 + 2 * i, i);
det.setDestinationUDPPort(cfg.udp_dest_port_1, i);
det.setDestinationUDPIP(sls::IpAddr(cfg.ipv4_dest_addr_1), {i});
det.setDestinationUDPMAC(sls::MacAddr(cfg.mac_addr_dest_1), {i});
if (experiment.GetUDPInterfaceCount() == 2) {
det.setSourceUDPIP2(sls::IpAddr(cfg.ipv4_src_addr_2), {i});
det.setSourceUDPMAC2(sls::MacAddr(BASE_DETECTOR_MAC + i * 2 + 1), {i});
det.setDestinationUDPPort2(cfg.udp_dest_port_2 + 2 * i + 1, i);
det.setDestinationUDPPort2(cfg.udp_dest_port_2, i);
det.setDestinationUDPIP2(sls::IpAddr(cfg.ipv4_dest_addr_2), {i});
det.setDestinationUDPMAC2(sls::MacAddr(cfg.mac_addr_dest_2), {i});
}
@@ -91,7 +91,7 @@ void DetectorWrapper::Initialize(const DiffractionExperiment& experiment,
throw JFJochException(JFJochExceptionCategory::Detector,
"Discrepancy in module number between DAQ and detector");
}
det.setDynamicRange(16);
det.setTenGiga(true);
auto trim_files = experiment.GetDetectorSetup().GetTrimFileNames();
@@ -100,8 +100,8 @@ void DetectorWrapper::Initialize(const DiffractionExperiment& experiment,
auto &cfg = mod_cfg[i];
det.setDestinationUDPPort(cfg.udp_dest_port_1 + 2 * i, 2 * i);
det.setDestinationUDPPort2(cfg.udp_dest_port_1 + 2 * i + 1, 2 * i + 1);
det.setDestinationUDPPort(cfg.udp_dest_port_1, 2 * i);
det.setDestinationUDPPort2(cfg.udp_dest_port_1, 2 * i + 1);
det.setSourceUDPIP(sls::IpAddr(cfg.ipv4_src_addr_1), {2 * i, 2 * i + 1});
det.setDestinationUDPIP(sls::IpAddr(cfg.ipv4_dest_addr_1), {2 * i, 2 * i + 1});
det.setDestinationUDPMAC(sls::MacAddr(cfg.mac_addr_dest_1), {2 * i, 2 * i + 1});

View File

@@ -8,13 +8,13 @@
"pedestal_g0_frames": 2000,
"pedestal_g1_frames": 300,
"pedestal_g2_frames": 300,
"frame_time": "500 us",
"count_time": "480 us",
"frame_time_us": "500 us",
"count_time_us": "480 us",
"preview_period_us": "1 s",
"detector_ipv4": "10.10.85.0"
},
"frontend_directory":"/home/jungfrau/nextgendcu/frontend/build",
"numa_policy": "n2g2",
"zmq_preview_period": "1 s",
"zmq_image_addr": ["tcp://0.0.0.0:5500", "tcp://0.0.0.0:5501", "tcp://0.0.0.0:5502", "tcp://0.0.0.0:5503"],
"receiver_threads": 64,
"receiver": {

View File

@@ -8,16 +8,15 @@
"pedestal_g0_frames": 2000,
"pedestal_g1_frames": 300,
"pedestal_g2_frames": 300,
"frame_time": "10 ms",
"count_time": "10 us",
"frame_time_us": "10 ms",
"count_time_us": "10 us",
"preview_period_us": "1 s",
"detector_ipv4": "10.3.30.155",
"pulsed_source": true
},
"frontend_directory":"/home/jungfrau/nextgendcu/frontend/build",
"numa_policy": "n2g4",
"zmq_image_addr": ["tcp://0.0.0.0:5500"],
"zmq_preview_period": "1 s",
"receiver_threads": 64,
"receiver": {
"type": "pcie",

View File

@@ -8,8 +8,9 @@
"pedestal_g0_frames": 0,
"pedestal_g1_frames": 0,
"pedestal_g2_frames": 0,
"frame_time": "1000 us",
"count_time": "980 us",
"frame_time_us": "1000 us",
"count_time_us": "980 us",
"preview_period_us": "1 s",
"detector_ipv4": "10.10.85.20",
"internal_frame_generator": true
},
@@ -19,9 +20,6 @@
},
"frontend_directory": "../../frontend_ui/build/",
"zmq_image_addr": ["tcp://0.0.0.0:5500"],
"zmq_preview_addr": "tcp://0.0.0.0:5501",
"zmq_preview_period": "1 s",
"zmq_writer_notification_addr": "ipc://*",
"detectors": [
{
"standard_geometry": {

View File

@@ -12,6 +12,8 @@ ELSE()
MESSAGE(STATUS "Xilinx HLS compiler not found")
ENDIF()
INCLUDE_DIRECTORIES(include)
ADD_SUBDIRECTORY(hls)
ADD_SUBDIRECTORY(pcie_driver)
ADD_SUBDIRECTORY(host_library)

View File

@@ -75,9 +75,7 @@
`define ADDR_NSTORAGE_CELLS 16'h021C
`define ADDR_NSUMMATION 16'h0220
`define ADDR_SQRTMULT 16'h0224
`define ADDR_DATA_SOURCE 16'h0300
`define ADDR_DATA_SOURCE 16'h0224
module action_config
#(parameter C_S_AXI_ADDR_WIDTH = 16,
@@ -116,7 +114,6 @@ module action_config
output reg [4:0] nmodules ,
output reg [3:0] nstorage_cells ,
output reg [7:0] nsummation ,
output reg [7:0] sqrtmult ,
output reg [1:0] data_source ,
output wire [31:0] hbm_size_bytes ,
@@ -369,9 +366,6 @@ always @(posedge clk) begin
`ADDR_NSUMMATION: begin
rdata <= nsummation;
end
`ADDR_SQRTMULT: begin
rdata <= sqrtmult;
end
`ADDR_DATA_SOURCE: begin
rdata <= data_source;
end
@@ -645,15 +639,6 @@ always @(posedge clk) begin
end
end
always @(posedge clk) begin
if (!resetn)
sqrtmult <= 0;
else if (reg_data_collection_idle) begin
if (w_hs && waddr == `ADDR_SQRTMULT)
sqrtmult <= (s_axi_WDATA[7:0] & wmask[7:0]) | (sqrtmult & !wmask[7:0]);
end
end
always @(posedge clk) begin
if (!resetn)
data_source <= 0;

View File

@@ -31,15 +31,11 @@ ADD_LIBRARY( JFJochHLSSimulation STATIC
spot_finder_mask.cpp
save_to_hbm_data.cpp
eiger_reorder.cpp
roi_calc.cpp
pixel_sqrt.cpp
HLSDevice.cpp
HLSDevice.h)
roi_calc.cpp)
TARGET_INCLUDE_DIRECTORIES(JFJochHLSSimulation PUBLIC ../include)
TARGET_LINK_LIBRARIES(JFJochHLSSimulation JFJochCommon)
TARGET_COMPILE_DEFINITIONS(JFJochHLSSimulation PUBLIC -DJFJOCH_HLS_NOSYNTH)
TARGET_INCLUDE_DIRECTORIES(JFJochHLSSimulation PUBLIC ../include)
ADD_EXECUTABLE(frame_summation_tb frame_summation_tb.cpp)
TARGET_LINK_LIBRARIES(frame_summation_tb JFJochHLSSimulation)
@@ -58,69 +54,55 @@ TARGET_LINK_LIBRARIES(adu_histo_tb JFJochHLSSimulation)
IF(VIVADO_HLS)
GET_FILENAME_COMPONENT(VITIS_HLS_DIR ${VIVADO_HLS} DIRECTORY)
FIND_FILE(HLS_MATH_H hls_math.h HINT ${VITIS_HLS_DIR}/../include)
IF (HLS_MATH_H)
GET_FILENAME_COMPONENT(VITIS_HLS_INCLUDE_DIR ${HLS_MATH_H} DIRECTORY)
MESSAGE(STATUS "Xilinx HLS headers included")
IF(NOT HLS_SOLUTION_NAME)
SET(HLS_SOLUTION_NAME base1)
ENDIF()
#TARGET_INCLUDE_DIRECTORIES(JFJochHLSSimulation PUBLIC ${VITIS_HLS_INCLUDE_DIR})
#TARGET_COMPILE_DEFINITIONS(JFJochHLSSimulation PUBLIC JFJOCH_USE_HLS_HEADERS)
ELSE()
MESSAGE(WARNING "Xilinx HLS headers missing")
#TARGET_INCLUDE_DIRECTORIES(JFJochHLSSimulation PUBLIC ../include)
ENDIF()
SET (HLS_IPS "")
IF(NOT HLS_SOLUTION_NAME)
SET(HLS_SOLUTION_NAME base1)
ENDIF()
FUNCTION( MAKE_HLS_MODULE FUNCTION_NAME SRC_FILE TB_FILE)
ADD_CUSTOM_COMMAND(OUTPUT psi_ch_hls_${FUNCTION_NAME}_1_0.zip
COMMAND ${CMAKE_COMMAND} -E env SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR} HLS_FILE=${SRC_FILE} HLS_TOP_FUNCTION=${FUNCTION_NAME} HLS_TB_FILE=${TB_FILE} ${VIVADO_HLS} -f ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/synth_hls_function.tcl > hls_${FUNCTION_NAME}.log
COMMAND ${CMAKE_COMMAND} -E env HLS_DIR=${CMAKE_CURRENT_BINARY_DIR}/${FUNCTION_NAME}/solution1 CURR_DIR=${CMAKE_CURRENT_BINARY_DIR} bash ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/check_hls.sh ${FUNCTION_NAME}
COMMAND ${CMAKE_COMMAND} -E copy ${FUNCTION_NAME}/solution1/impl/ip/psi_ch_hls_${FUNCTION_NAME}_1_0.zip .
DEPENDS ${SRC_FILE} hls_jfjoch.h ../pcie_driver/jfjoch_fpga.h)
SET (HLS_IPS ${HLS_IPS} psi_ch_hls_${FUNCTION_NAME}_1_0.zip PARENT_SCOPE)
ENDFUNCTION(MAKE_HLS_MODULE)
SET (HLS_IPS "")
MAKE_HLS_MODULE(data_collection_fsm data_collection_fsm.cpp "")
MAKE_HLS_MODULE(timer_host timer.cpp "")
MAKE_HLS_MODULE(jf_conversion jf_conversion.cpp "")
MAKE_HLS_MODULE(load_calibration load_calibration.cpp "")
MAKE_HLS_MODULE(host_writer host_writer.cpp "")
MAKE_HLS_MODULE(icmp icmp.cpp "")
MAKE_HLS_MODULE(ipv4 ipv4.cpp "")
MAKE_HLS_MODULE(ethernet ethernet.cpp "")
MAKE_HLS_MODULE(arp arp.cpp "")
MAKE_HLS_MODULE(udp udp.cpp "")
MAKE_HLS_MODULE(sls_detector sls_detector.cpp "")
MAKE_HLS_MODULE(frame_generator frame_generator.cpp "")
MAKE_HLS_MODULE(stream_merge stream_merge.cpp "")
MAKE_HLS_MODULE(load_from_hbm load_from_hbm.cpp "")
MAKE_HLS_MODULE(save_to_hbm save_to_hbm.cpp "")
MAKE_HLS_MODULE(save_to_hbm_data save_to_hbm_data.cpp "")
MAKE_HLS_MODULE(mask_missing mask_missing.cpp "")
MAKE_HLS_MODULE(integration integration.cpp integration_tb.cpp)
MAKE_HLS_MODULE(spot_finder spot_finder.cpp spot_finder_tb.cpp)
MAKE_HLS_MODULE(axis_broadcast axis_broadcast.cpp "")
MAKE_HLS_MODULE(axis_64_to_512 axis_helpers.cpp "")
MAKE_HLS_MODULE(axis_32_to_512 axis_helpers.cpp "")
MAKE_HLS_MODULE(adu_histo adu_histo.cpp adu_histo_tb.cpp)
MAKE_HLS_MODULE(pedestal pedestal.cpp "")
MAKE_HLS_MODULE(frame_summation frame_summation.cpp frame_summation_tb_2.cpp)
MAKE_HLS_MODULE(frame_summation_reorder_compl frame_summation_reorder_compl.cpp "")
MAKE_HLS_MODULE(stream_24bit_conv stream_24bit_conv.cpp stream_24bit_conv_tb.cpp)
MAKE_HLS_MODULE(spot_finder_mask spot_finder_mask.cpp "")
MAKE_HLS_MODULE(spot_finder_merge spot_finder_merge.cpp "")
MAKE_HLS_MODULE(spot_finder_connectivity spot_finder_connectivity.cpp "")
MAKE_HLS_MODULE(eiger_reorder eiger_reorder.cpp "")
MAKE_HLS_MODULE(roi_calc roi_calc.cpp "")
FUNCTION( MAKE_HLS_MODULE FUNCTION_NAME SRC_FILE TB_FILE)
ADD_CUSTOM_COMMAND(OUTPUT psi_ch_hls_${FUNCTION_NAME}_1_0.zip
COMMAND ${CMAKE_COMMAND} -E env SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR} HLS_FILE=${SRC_FILE} HLS_TOP_FUNCTION=${FUNCTION_NAME} HLS_TB_FILE=${TB_FILE} ${VIVADO_HLS} -f ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/synth_hls_function.tcl > hls_${FUNCTION_NAME}.log
COMMAND ${CMAKE_COMMAND} -E env HLS_DIR=${CMAKE_CURRENT_BINARY_DIR}/${FUNCTION_NAME}/solution1 CURR_DIR=${CMAKE_CURRENT_BINARY_DIR} bash ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/check_hls.sh ${FUNCTION_NAME}
COMMAND ${CMAKE_COMMAND} -E copy ${FUNCTION_NAME}/solution1/impl/ip/psi_ch_hls_${FUNCTION_NAME}_1_0.zip .
DEPENDS ${SRC_FILE} hls_jfjoch.h ../pcie_driver/jfjoch_fpga.h)
SET (HLS_IPS ${HLS_IPS} psi_ch_hls_${FUNCTION_NAME}_1_0.zip PARENT_SCOPE)
ENDFUNCTION(MAKE_HLS_MODULE)
MAKE_HLS_MODULE(data_collection_fsm data_collection_fsm.cpp "")
MAKE_HLS_MODULE(timer_host timer.cpp "")
MAKE_HLS_MODULE(jf_conversion jf_conversion.cpp "")
MAKE_HLS_MODULE(load_calibration load_calibration.cpp "")
MAKE_HLS_MODULE(host_writer host_writer.cpp "")
MAKE_HLS_MODULE(pixel_sqrt pixel_sqrt.cpp pixel_sqrt_tb.cpp)
MAKE_HLS_MODULE(icmp icmp.cpp "")
MAKE_HLS_MODULE(ipv4 ipv4.cpp "")
MAKE_HLS_MODULE(ethernet ethernet.cpp "")
MAKE_HLS_MODULE(arp arp.cpp "")
MAKE_HLS_MODULE(udp udp.cpp "")
MAKE_HLS_MODULE(sls_detector sls_detector.cpp "")
MAKE_HLS_MODULE(frame_generator frame_generator.cpp "")
MAKE_HLS_MODULE(stream_merge stream_merge.cpp "")
MAKE_HLS_MODULE(load_from_hbm load_from_hbm.cpp "")
MAKE_HLS_MODULE(save_to_hbm save_to_hbm.cpp "")
MAKE_HLS_MODULE(save_to_hbm_data save_to_hbm_data.cpp "")
MAKE_HLS_MODULE(mask_missing mask_missing.cpp "")
MAKE_HLS_MODULE(integration integration.cpp integration_tb.cpp)
MAKE_HLS_MODULE(spot_finder spot_finder.cpp spot_finder_tb.cpp)
MAKE_HLS_MODULE(axis_broadcast axis_broadcast.cpp "")
MAKE_HLS_MODULE(axis_64_to_512 axis_helpers.cpp "")
MAKE_HLS_MODULE(axis_32_to_512 axis_helpers.cpp "")
MAKE_HLS_MODULE(adu_histo adu_histo.cpp adu_histo_tb.cpp)
MAKE_HLS_MODULE(pedestal pedestal.cpp "")
MAKE_HLS_MODULE(frame_summation frame_summation.cpp frame_summation_tb_2.cpp)
MAKE_HLS_MODULE(frame_summation_reorder_compl frame_summation_reorder_compl.cpp "")
MAKE_HLS_MODULE(stream_24bit_conv stream_24bit_conv.cpp stream_24bit_conv_tb.cpp)
MAKE_HLS_MODULE(spot_finder_mask spot_finder_mask.cpp "")
MAKE_HLS_MODULE(spot_finder_merge spot_finder_merge.cpp "")
MAKE_HLS_MODULE(spot_finder_connectivity spot_finder_connectivity.cpp "")
MAKE_HLS_MODULE(eiger_reorder eiger_reorder.cpp "")
MAKE_HLS_MODULE(roi_calc roi_calc.cpp "")
SET (HLS_IPS ${HLS_IPS} PARENT_SCOPE)
ADD_CUSTOM_TARGET(hls DEPENDS ${HLS_IPS})
SET (HLS_IPS ${HLS_IPS} PARENT_SCOPE)
ADD_CUSTOM_TARGET(hls DEPENDS ${HLS_IPS})
ENDIF()

View File

@@ -1,791 +0,0 @@
// Copyright (2019-2024) Paul Scherrer Institute
#include <future>
#include <bitset>
#include <arpa/inet.h>
#include "HLSDevice.h"
#include "hls_jfjoch.h"
#include "datamover_model.h"
#include "../../jungfrau/sls_packet.h"
#include "../../common/Logger.h"
#include "../../common/JFJochException.h"
struct HLSDeviceImpl {
AXI_STREAM din_eth;
AXI_STREAM din_frame_generator;
AXI_STREAM dout_eth;
constexpr static const size_t hbm_if_count = 32;
constexpr static const size_t hbm_if_size = 32 * 1024 * 1024LU;
ap_uint<2> data_source = STREAM_MERGE_SRC_NETWORK;
std::vector<ap_uint<256>> hbm;
hls::stream<ap_uint<32> > work_request_stream;
hls::stream<ap_uint<32> > completion_stream;
Datamover<512> datamover_in;
Datamover<512> datamover_out;
Datamover<256> datamover_in_hbm_0;
Datamover<256> datamover_in_hbm_1;
Datamover<256, 16> datamover_out_hbm_0;
Datamover<256, 16> datamover_out_hbm_1;
ap_uint<1> run_data_collection;
ap_uint<1> cancel_data_collection;
volatile ap_uint<1> host_writer_idle;
HLSDeviceImpl()
: hbm(hbm_if_size / 32 * hbm_if_count),
datamover_in(Direction::Input, nullptr),
datamover_out(Direction::Output, nullptr),
datamover_out_hbm_0(Direction::Output, (char *) hbm.data()),
datamover_out_hbm_1(Direction::Output, (char *) hbm.data()),
datamover_in_hbm_0(Direction::Input, (char *) hbm.data()),
datamover_in_hbm_1(Direction::Input, (char *) hbm.data()) {}
};
uint16_t checksum(const uint16_t *addr, size_t count) {
/* Compute Internet Checksum for "count" bytes
* beginning at location "addr".
*/
long sum = 0;
for (int i = 0; i < count / 2; i++)
sum += addr[i];
/* Add left-over byte, if any */
if (count % 2 == 1)
sum += ((uint8_t *) addr)[count / 2];
/* Fold 32-bit sum to 16 bits */
while (sum>>16)
sum = (sum & 0xffff) + (sum >> 16);
return ~sum;
}
HLSDevice::HLSDevice(std::vector<DeviceOutput *> &buffer_device) : idle(true), dma_address_table(65536) {
impl_ = std::make_unique<HLSDeviceImpl>();
auto in_mem_location32 = (uint32_t *) dma_address_table.data();
for (int i = 0; i < buffer_device.size(); i++) {
in_mem_location32[2 * i ] = ((uint64_t) buffer_device[i]) & UINT32_MAX;
in_mem_location32[2 * i + 1] = ((uint64_t) buffer_device[i]) >> 32;
}
}
HLSDevice::~HLSDevice() {
if (action_thread.joinable())
action_thread.join();
impl_.reset();
}
void HLSDevice::CreateFinalPacket(const DiffractionExperiment& experiment) {
CreateJFPacket(experiment, UINT64_MAX, 0, 0, nullptr, false);
}
void HLSDevice::SendPacket(char *buffer, int len, uint8_t user) {
auto obuff = (ap_uint<512> *)buffer;
for (int i = 0; i < (len + 63) / 64; i++) {
packet_512_t packet_in;
if (i == (len + 63) / 64 - 1) packet_in.last = 1;
else packet_in.last = 0;
packet_in.keep = 0xFFFFFFFFFFFFFFFF;
packet_in.user = user;
packet_in.data = obuff[i];
impl_->din_eth.write(packet_in);
}
}
void HLSDevice::CreateJFPacket(const DiffractionExperiment& experiment, uint64_t frame_number, uint32_t eth_packet,
uint32_t module_number, const uint16_t *data, int8_t adjust_axis, uint8_t user) {
char buff[256*64];
memset(buff, 0, 256*64);
auto packet = (jf_raw_packet *)buff;
packet->ether_type = htons(0x0800);
packet->sour_mac[0] = 0x00; // module 0
uint64_t tmp_mac = mac_addr;
for (int i = 0; i < 6; i++)
packet->dest_mac[i] = (tmp_mac >> (8*i)) % 256;
uint32_t half_module = 2 * module_number | ((eth_packet >= 64) ? 1 : 0);
packet->ipv4_header_h = htons(0x4500); // Big endian in IP header!
packet->ipv4_header_total_length = htons(8268); // Big endian in IP header!
packet->ipv4_header_dest_ip = ipv4_addr;
packet->ipv4_header_sour_ip = experiment.GetSrcIPv4Address(0, half_module);
packet->ipv4_header_ttl_protocol = htons(0x0011);
packet->ipv4_header_checksum = checksum( (uint16_t *) &packet->ipv4_header_h, 20); // checksum is already in network order
packet->udp_dest_port = htons(234); // port doesn't matter
packet->udp_sour_port = htons(0xDFAC);
packet->udp_length = htons(8248);
// JF headers are little endian
packet->jf.detectortype = SLS_DETECTOR_TYPE_JUNGFRAU;
packet->jf.timestamp = 0xABCDEF0000FEDCBAL;
packet->jf.bunchid = 0x1234567898765431L;
packet->jf.row = half_module;
packet->jf.column = 0;
packet->jf.framenum = frame_number;
packet->jf.packetnum = eth_packet % 64;
if (data != nullptr) {
for (int i = 0; i < 4096; i++)
packet->jf.data[i] = data[i];
}
packet->udp_checksum = htons(checksum( (uint16_t *) (buff+42), 8192+48));
SendPacket(buff, (130+adjust_axis)*64, user);
}
void HLSDevice::CreateJFPackets(const DiffractionExperiment& experiment, uint64_t frame_number_0, uint64_t frames,
uint32_t module_number, const uint16_t *data) {
for (uint64_t i = 0; i < frames; i++) {
for (int j = 0; j < 128; j++)
CreateJFPacket(experiment, frame_number_0 + i, j, module_number, data + (i * 128 + j) * 4096, 0, 0);
}
}
void HLSDevice::CreateEIGERPacket(const DiffractionExperiment &experiment, uint64_t frame_number,
uint32_t eth_packet, uint32_t module_number, uint32_t col, uint32_t row,
const uint16_t *data) {
char buff[256*64];
memset(buff, 0, 256*64);
auto packet = (eiger_raw_packet *)buff;
packet->ether_type = htons(0x0800);
packet->sour_mac[0] = 0x00; // module 0
uint64_t tmp_mac = mac_addr;
for (int i = 0; i < 6; i++)
packet->dest_mac[i] = (tmp_mac >> (8*i)) % 256;
packet->ipv4_header_h = htons(0x4500); // Big endian in IP header!
packet->ipv4_header_total_length = htons(4172); // Big endian in IP header!
packet->ipv4_header_dest_ip = ipv4_addr;
packet->ipv4_header_sour_ip = experiment.GetSrcIPv4Address(0, 0);
packet->ipv4_header_ttl_protocol = htons(0x0011);
packet->ipv4_header_checksum = checksum( (uint16_t *) &packet->ipv4_header_h, 20); // checksum is already in network order
packet->udp_dest_port = htons(234); // ignored
packet->udp_sour_port = htons(0xDFAC);
packet->udp_length = htons(4152);
// JF headers are little endian
packet->eiger.detectortype = SLS_DETECTOR_TYPE_EIGER;
packet->eiger.timestamp = 0xABCDEF0000FEDCBAL;
packet->eiger.bunchid = 0x1234567898765431L;
packet->eiger.row = (2 * module_number) | (row % 2);
packet->eiger.column = col % 2;
packet->eiger.framenum = frame_number;
packet->eiger.packetnum = eth_packet % 64;
if (data != nullptr) {
for (int i = 0; i < 2048; i++)
packet->eiger.data[i] = data[i];
}
packet->udp_checksum = htons(checksum( (uint16_t *) (buff+42), 4096+48));
SendPacket(buff, 66*64, 0);
}
void HLSDevice::HW_ReadActionRegister(DataCollectionConfig *job) {
memcpy(job, &cfg, sizeof(DataCollectionConfig));
}
void HLSDevice::HW_WriteActionRegister(const DataCollectionConfig *job) {
memcpy(&cfg, job, sizeof(DataCollectionConfig));
}
void HLSDevice::FPGA_StartAction(const DiffractionExperiment &experiment) {
if (action_thread.joinable())
action_thread.join();
run_counter += 1;
impl_->run_data_collection = 1;
impl_->cancel_data_collection = 0;
idle = false;
while (!impl_->din_frame_generator.empty())
impl_->din_frame_generator.read();
impl_->datamover_out.ClearCompletedDescriptors();
action_thread = std::thread(&HLSDevice::HLSMainThread, this );
}
void HLSDevice::FrameGeneratorFuture(FrameGeneratorConfig config) {
frame_generator(impl_->din_frame_generator,
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm_if_size,
mac_addr,
ipv4_addr,
impl_->cancel_data_collection,
config);
}
void HLSDevice::HW_RunInternalGenerator(const FrameGeneratorConfig &config) {
frame_generator_future = std::async(std::launch::async, &HLSDevice::FrameGeneratorFuture, this, config);
}
void HLSDevice::FPGA_EndAction() {
if (action_thread.joinable())
action_thread.join();
}
bool HLSDevice::HW_ReadMailbox(uint32_t *values) {
std::unique_lock<std::mutex> ul(completion_mutex);
ap_uint<32> tmp;
bool ret = impl_->completion_stream.read_nb(tmp);
values[0] = tmp;
// equivalent to driver functionality
if (ret) {
uint32_t data_collection_id = (values[0] >> 16) & 0xFFFF;
uint32_t handle = values[0] & 0xFFFF;
if (handle == HANDLE_START)
completion_count = 0;
else if ((handle != HANDLE_END) && (data_collection_id != DATA_COLLECTION_ID_PURGE)) {
completion_count++;
while (completion_count * DMA_DESCRIPTORS_PER_MODULE > impl_->datamover_out.GetCompletedDescriptors())
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}
return ret;
}
void HLSDevice::Cancel() {
impl_->cancel_data_collection = 1;
}
bool HLSDevice::HW_IsIdle() const {
return idle && impl_->datamover_out.IsIdle();
}
bool HLSDevice::HW_SendWorkRequest(uint32_t handle) {
impl_->work_request_stream.write(handle);
return true;
}
inline uint32_t float2uint(float f) {
float_uint32 fu;
fu.f = f;
return fu.u;
}
void HLSDevice::HLSMainThread() {
ap_uint<1> clear_counters = 0;
uint64_t packets_processed;
std::vector<std::thread> hls_cores;
STREAM_512 ip1, udp1, udp2, icmp1, arp1;
STREAM_512 network0;
STREAM_768 stream_768_0;
STREAM_768 stream_768_1;
STREAM_768 stream_768_2;
STREAM_768 stream_768_3;
STREAM_768 stream_768_4;
STREAM_768 stream_768_5;
STREAM_768 stream_768_6;
STREAM_512 data_0;
hls::stream<ap_axiu<512, 1, 1, 1>, 2> data_1;
hls::stream<ap_axiu<512, 1, 1, 1>, 2> data_2;
STREAM_512 data_3;
STREAM_512 data_4;
STREAM_512 data_5;
STREAM_512 data_6;
STREAM_512 data_7;
STREAM_512 data_8;
STREAM_512 data_9;
STREAM_512 data_10;
STREAM_512 data_12;
STREAM_512 data_13;
hls::stream<axis_addr> addr0;
hls::stream<axis_addr> addr1;
hls::stream<axis_addr> addr2;
hls::stream<axis_addr> addr3;
hls::stream<axis_completion> axi_compl[12];
hls::stream<ap_uint<16>> hbm_handles;
hls::stream<ap_uint<512>> adu_histo_result;
hls::stream<ap_axiu<64,1,1,1>> integration_result_0;
hls::stream<ap_uint<512>> integration_result_1;
hls::stream<ap_axiu<32,1,1,1>> spot_finder_result_0;
hls::stream<ap_axiu<32,1,1,1>> spot_finder_result_1;
hls::stream<ap_uint<32>> spot_finder_conn_0;
hls::stream<ap_axiu<32,1,1,1>> spot_finder_result_2;
hls::stream<ap_uint<512>> spot_finder_result_3;
hls::stream<ap_uint<32>> spot_finder_mask_0;
hls::stream<ap_uint<256>> roi_calc_result_0;
hls::stream<ap_uint<UDP_METADATA_STREAM_WIDTH> > udp_metadata;
volatile ap_uint<1> idle_data_collection = 1;
ap_uint<1> load_to_hbm_idle;
ap_uint<1> save_to_hbm_idle;
ap_uint<1> integration_idle;
ap_uint<1> stream_conv_idle;
ap_uint<1> frame_summation_idle;
volatile bool done = false;
volatile bool udp_done = false; // done AND udp_idle
volatile bool sls_done = false; // done AND sls_idle
// Sent gratuitous ARP message
arp(arp1, impl_->dout_eth, mac_addr, ipv4_addr, 1, 1);
Logger logger_hls("HLS");
volatile rcv_state_t state = RCV_INIT;
// Start data collection
data_collection_fsm(data_0, data_1,
addr0, addr1,
impl_->run_data_collection,
impl_->cancel_data_collection,
idle_data_collection,
cfg.mode,
float2uint(cfg.energy_kev),
cfg.nframes,
cfg.nmodules,
cfg.nstorage_cells,
cfg.nsummation ,
cfg.sqrtmult, state);
impl_->run_data_collection = 0;
data_collection_fsm(data_0, data_1,
addr0, addr1,
impl_->run_data_collection,
impl_->cancel_data_collection,
idle_data_collection,
cfg.mode,
float2uint(cfg.energy_kev),
cfg.nframes,
cfg.nmodules,
cfg.nstorage_cells,
cfg.nsummation,
cfg.sqrtmult,
state);
hls_cores.emplace_back([&] {
while (!udp_done) {
if (impl_->din_eth.empty() && impl_->din_frame_generator.empty())
std::this_thread::sleep_for(std::chrono::microseconds(10));
else
stream_merge(impl_->din_eth, impl_->din_frame_generator, network0, impl_->data_source);
}
logger_hls.Info("Stream_merge done");
});
hls_cores.emplace_back([&] {
while (!udp_done) {
if (network0.empty())
std::this_thread::sleep_for(std::chrono::microseconds(10));
else
ethernet(network0, ip1, arp1, mac_addr, eth_packets, clear_counters);
}
logger_hls.Info("ethernet done");
});
hls_cores.emplace_back([&] {
while (!udp_done) {
if (ip1.empty())
std::this_thread::sleep_for(std::chrono::microseconds(10));
else
ipv4(ip1, udp1, icmp1, ipv4_addr);
}
logger_hls.Info("ipv4 done");
});
hls_cores.emplace_back([&] {
ap_uint<1> udp_idle = 1;
while (!done || !udp_idle) {
if (udp1.empty())
std::this_thread::sleep_for(std::chrono::microseconds(10));
else
udp(udp1, udp2, udp_metadata, udp_packets, clear_counters, udp_idle);
}
udp_done = true;
logger_hls.Info("udp done");
});
hls_cores.emplace_back([&] {
ap_uint<1> sls_idle = 1;
while (!done || !sls_idle) {
if (udp2.empty())
std::this_thread::sleep_for(std::chrono::microseconds (10));
else
sls_detector(udp2, udp_metadata, data_0, addr0, sls_packets, udp_eth_err, udp_len_err, current_pulse_id,
clear_counters, sls_idle);
}
sls_done = true;
logger_hls.Info("sls_detector done");
});
// 1. Parse incoming UDP packets
hls_cores.emplace_back([&] {
while ((state != RCV_WAIT_FOR_START) || (idle_data_collection.read() == 0) || (!data_0.empty())) {
data_collection_fsm(data_0, data_1,
addr0, addr1,
impl_->run_data_collection,
impl_->cancel_data_collection,
idle_data_collection,
cfg.mode,
float2uint(cfg.energy_kev),
cfg.nframes,
cfg.nmodules,
cfg.nstorage_cells,
cfg.nsummation,
cfg.sqrtmult,
state);
}
done = true;
logger_hls.Info("data collection done");
});
// 2. Cache images in HBM
hls_cores.emplace_back([&] { save_to_hbm(addr1, axi_compl[0], hbm_handles,
impl_->datamover_out_hbm_0.GetCtrlStream(),
impl_->datamover_out_hbm_1.GetCtrlStream(),
save_to_hbm_idle,
impl_->hbm_if_size);});
hls_cores.emplace_back([&] { save_to_hbm_data(data_1,
data_3,
impl_->datamover_out_hbm_0.GetDataStream(),
impl_->datamover_out_hbm_1.GetDataStream());});
hls_cores.emplace_back([&] {frame_summation_reorder_compl(data_3, data_4, axi_compl[0], axi_compl[1]);});
hls_cores.emplace_back([&] { load_from_hbm(data_4, data_5, axi_compl[1], axi_compl[2], hbm_handles,
impl_->datamover_in_hbm_0.GetDataStream(), impl_->datamover_in_hbm_1.GetDataStream(),
impl_->datamover_in_hbm_0.GetCtrlStream(), impl_->datamover_in_hbm_1.GetCtrlStream(),
load_to_hbm_idle, impl_->hbm_if_size);});
hls_cores.emplace_back([&] { pedestal(data_5, data_6, axi_compl[2], axi_compl[3],
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm_if_size);});
// 3. Calculate histogram of ADU values
hls_cores.emplace_back([&] { adu_histo(data_6, data_7, adu_histo_result, axi_compl[3], axi_compl[4]);});
// 4. Mask missing pixels
hls_cores.emplace_back([&] { mask_missing(data_7, data_8, axi_compl[4], axi_compl[5]);});
// 5. Handle EIGER packets properly
hls_cores.emplace_back([&] { eiger_reorder(data_8, data_9, axi_compl[5], axi_compl[6]);});
// 6. Apply pedestal & gain corrections
hls_cores.emplace_back([&] { jf_conversion(data_9, stream_768_0,
axi_compl[6], axi_compl[7],
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm_if_size); });
// 7. Frame summation
hls_cores.emplace_back([&] { frame_summation(stream_768_0, stream_768_1, axi_compl[7], axi_compl[8], frame_summation_idle);});
// 8. Integration of pixels
hls_cores.emplace_back([&] { integration(stream_768_1, stream_768_2, integration_result_0, axi_compl[8], axi_compl[9],
impl_->hbm.data(), impl_->hbm.data(), impl_->hbm.data(), impl_->hbm.data(), integration_idle, impl_->hbm_if_size);});
hls_cores.emplace_back([&] { axis_64_to_512(integration_result_0, integration_result_1);});
// 9. Spot finding
ap_uint<32> tmp_snr_threshold = float2uint(spot_finder_parameters.snr_threshold);
ap_uint<32> min_d = float2uint(spot_finder_parameters.min_d);
ap_uint<32> max_d = float2uint(spot_finder_parameters.max_d);
ap_int<32> tmp_count_threshold = spot_finder_parameters.count_threshold;
ap_uint<32> min_pix_per_spot = spot_finder_parameters.min_pix_per_spot;
hls_cores.emplace_back([&] {
spot_finder_mask(stream_768_2,
stream_768_3,
spot_finder_mask_0,
axi_compl[9],
axi_compl[10],
impl_->hbm.data(),
impl_->hbm.data(),
min_d,
max_d,
impl_->hbm_if_size);
logger_hls.Info("spot_finder_mask done");
});
hls_cores.emplace_back([&] {
spot_finder(stream_768_3, spot_finder_mask_0, stream_768_4, spot_finder_result_0, tmp_count_threshold, tmp_snr_threshold);
logger_hls.Info("spot_finder done");
});
hls_cores.emplace_back([&] {
spot_finder_connectivity(spot_finder_result_0,
spot_finder_result_1,
spot_finder_conn_0);
logger_hls.Info("spot_finder_connectivity done");
});
hls_cores.emplace_back([&] {
spot_finder_merge(spot_finder_result_1,
spot_finder_conn_0,
spot_finder_result_2,
min_pix_per_spot);
logger_hls.Info("spot_finder_merge done");
});
hls_cores.emplace_back([&] {
axis_32_to_512(spot_finder_result_2, spot_finder_result_3);
logger_hls.Info("axis_32_to_512 done");
});
// 10. ROI calculation
hls_cores.emplace_back([&] {
roi_calc(stream_768_4,
stream_768_5,
roi_calc_result_0,
axi_compl[10],
axi_compl[11],
impl_->hbm.data(),
impl_->hbm.data(),
impl_->hbm_if_size);
logger_hls.Info("roi_calc done");
});
// 11. Pixel sq root
hls_cores.emplace_back([&] {
pixel_sqrt(stream_768_5,
stream_768_6);
logger_hls.Info("pixel_sqrt done");
});
// 12. Reduce/extend 24-bit stream
hls_cores.emplace_back([&] { stream_24bit_conv(stream_768_6, data_12, stream_conv_idle);});
// 13. Prepare data to write to host memory
hls_cores.emplace_back([&] {
ap_uint<3> state;
host_writer(data_12, adu_histo_result, integration_result_1, spot_finder_result_3, roi_calc_result_0,
axi_compl[11], impl_->datamover_out.GetDataStream(),
impl_->datamover_out.GetCtrlStream(), impl_->work_request_stream, impl_->completion_stream,
dma_address_table.data(), packets_processed, impl_->host_writer_idle, impl_->cancel_data_collection, state);
logger_hls.Info("host_writer done");
});
for (auto &i : hls_cores)
i.join();
if (frame_generator_future.valid())
frame_generator_future.get();
// reset static counter
arp(arp1, impl_->dout_eth, mac_addr, ipv4_addr, 0, 1);
try {
while (!impl_->din_eth.empty())
impl_->din_eth.read();
if (!addr1.empty())
throw std::runtime_error("Addr1 queue not empty");
if (!addr2.empty())
throw std::runtime_error("Addr2 queue not empty");
if (!addr3.empty())
throw std::runtime_error("Addr3 queue not empty");
if (!data_1.empty())
throw std::runtime_error("data_1 queue not empty");
if (!data_2.empty())
throw std::runtime_error("data_2 queue not empty");
if (!data_3.empty())
throw std::runtime_error("data_3 queue not empty");
if (!data_4.empty())
throw std::runtime_error("data_4 queue not empty");
if (!data_5.empty())
throw std::runtime_error("data_5 queue not empty");
if (!data_7.empty())
throw std::runtime_error("data_7 queue not empty");
if (!data_8.empty())
throw std::runtime_error("data_8 queue not empty");
if (!data_9.empty())
throw std::runtime_error("data_9 queue not empty");
if (!data_10.empty())
throw std::runtime_error("data_10 queue not empty");
if (!data_12.empty())
throw std::runtime_error("data_12 queue not empty");
if (!data_13.empty())
throw std::runtime_error("data_13 queue not empty");
for (auto &c: axi_compl) {
if (!c.empty())
throw std::runtime_error("Compl queue not empty");
}
if (!stream_768_0.empty())
throw std::runtime_error("stream_768_0 queue not empty");
if (!stream_768_1.empty())
throw std::runtime_error("stream_768_1 queue not empty");
if (!stream_768_2.empty())
throw std::runtime_error("stream_768_2 queue not empty");
if (!stream_768_3.empty())
throw std::runtime_error("stream_768_3 queue not empty");
if (!stream_768_4.empty())
throw std::runtime_error("stream_768_4 queue not empty");
if (!hbm_handles.empty())
throw std::runtime_error("Handles queue not empty");
if (!integration_result_0.empty())
throw std::runtime_error("Integration result queue not empty");
if (!integration_result_1.empty())
throw std::runtime_error("Integration result queue not empty");
if (!impl_->datamover_in.GetDataStream().empty())
throw std::runtime_error("Datamover queue is not empty");
while (!impl_->datamover_out.IsIdle())
std::this_thread::sleep_for(std::chrono::milliseconds(100));
} catch (const std::runtime_error &e) {
logger_hls.ErrorException(e);
throw e;
}
idle = true;
}
DataCollectionStatus HLSDevice::GetDataCollectionStatus() const {
DataCollectionStatus status{};
union {
uint64_t u64;
double d;
} pulse_id_conv;
pulse_id_conv.u64 = current_pulse_id;
status.ctrl_reg = ap_uint<1>(impl_->host_writer_idle) ? (1 << 4) : 0;
status.max_modules = MAX_MODULES_FPGA;
status.hbm_size_bytes = impl_->hbm_if_size;
status.run_counter = run_counter;
status.current_pulseid = pulse_id_conv.d;
status.packets_udp = udp_packets;
status.packets_eth = eth_packets;
status.packets_sls = sls_packets;
return status;
}
void HLSDevice::HW_LoadCalibration(const LoadCalibrationConfig &config) {
int ret = load_calibration(impl_->hbm.data(), impl_->hbm.data(),
config,
impl_->hbm_if_size,
impl_->datamover_in.GetCtrlStream(),
impl_->datamover_in.GetDataStream(),
dma_address_table.data());
if (ret)
throw JFJochException(JFJochExceptionCategory::AcquisitionDeviceError,
"Error in loading calibration " + std::to_string(ret));
if (!impl_->datamover_in.GetDataStream().empty())
throw std::runtime_error("Datamover queue is not empty");
}
void HLSDevice::HW_SetSpotFinderParameters(const SpotFinderParameters &params) {
spot_finder_parameters = params;
}
void HLSDevice::HW_SetDataSource(uint32_t val) {
impl_->data_source = val;
}
uint32_t HLSDevice::HW_GetDataSource() {
return impl_->data_source;
}
void HLSDevice::CreateXfelBunchIDPacket(double pulse_id, uint32_t event_code) {
union {
uint64_t u64;
double d;
} pulse_id_conv;
pulse_id_conv.d = pulse_id;
bunchid_raw_packet packet{};
packet.ether_type = htons(0x0800);
for (int i = 0; i < 6; i++)
packet.dest_mac[i] = 0xFF;
packet.ipv4_header_h = htons(0x4500); // Big endian in IP header!
packet.ipv4_header_total_length = htons(sizeof(bunchid_payload) + 8 + 20); // Big endian in IP header!
packet.ipv4_header_dest_ip = UINT32_MAX;
packet.ipv4_header_ttl_protocol = htons(0x0011);
packet.ipv4_header_checksum = checksum( (uint16_t *) &packet.ipv4_header_h, 20); // checksum is already in network order
packet.udp_length = htons(sizeof(bunchid_payload) + 8);
packet.payload.magicn[0] = BUNCHID_MAGICN;
packet.payload.magicn[1] = BUNCHID_MAGICN;
packet.payload.magicn[2] = BUNCHID_MAGICN;
packet.payload.bunchid_msb[0] = (pulse_id_conv.u64 >> 32) & UINT32_MAX;
packet.payload.bunchid_msb[1] = (pulse_id_conv.u64 >> 32) & UINT32_MAX;
packet.payload.bunchid_lsb[0] = pulse_id_conv.u64 & UINT32_MAX;
packet.payload.bunchid_lsb[1] = pulse_id_conv.u64 & UINT32_MAX;
packet.payload.montrig = event_code;
SendPacket((char *) &packet, sizeof(bunchid_raw_packet));
}

View File

@@ -1,75 +0,0 @@
// Copyright (2019-2024) Paul Scherrer Institute
#ifndef JFJOCH_HLSDEVICE_H
#define JFJOCH_HLSDEVICE_H
#include <future>
#include "../../common/DiffractionExperiment.h"
#include "../pcie_driver/jfjoch_fpga.h"
class HLSDeviceImpl;
class HLSDevice {
// Hide all HLS simulation structures here
std::unique_ptr<HLSDeviceImpl> impl_;
std::mutex completion_mutex;
uint32_t completion_count;
std::thread action_thread;
std::future<void> frame_generator_future;
std::vector<uint64_t> dma_address_table;
uint64_t eth_packets = 0;
uint64_t icmp_packets = 0;
uint64_t udp_packets = 0;
uint64_t sls_packets = 0;
uint32_t udp_len_err = 0;
uint32_t udp_eth_err = 0;
uint64_t current_pulse_id = 0;
uint32_t run_counter = 0;
DataCollectionConfig cfg;
SpotFinderParameters spot_finder_parameters;
const uint64_t mac_addr = 0xCCAA11223344;
const uint32_t ipv4_addr = 0x0132010A;
volatile bool idle;
void FrameGeneratorFuture(FrameGeneratorConfig config);
void HLSMainThread();
public:
explicit HLSDevice(std::vector<DeviceOutput *> &device_buffer);
~HLSDevice();
void SendPacket(char *buffer, int len, uint8_t user = 0);
void CreateJFPacket(const DiffractionExperiment& experiment, uint64_t frame_number, uint32_t eth_packet,
uint32_t module_number, const uint16_t *data, int8_t adjust_axis = 0, uint8_t user = 0);
void CreateJFPackets(const DiffractionExperiment& experiment, uint64_t frame_number_0, uint64_t frames,
uint32_t module_number, const uint16_t *data);
void CreateEIGERPacket(const DiffractionExperiment& experiment, uint64_t frame_number, uint32_t eth_packet,
uint32_t module_number, uint32_t col, uint32_t row,
const uint16_t *data);
void CreateFinalPacket(const DiffractionExperiment& experiment);
void CreateXfelBunchIDPacket(double bunchid, uint32_t event_code);
DataCollectionStatus GetDataCollectionStatus() const ;
void Cancel() ;
void HW_ReadActionRegister(DataCollectionConfig *job);
void HW_WriteActionRegister(const DataCollectionConfig *job);
void FPGA_StartAction(const DiffractionExperiment &experiment);
void FPGA_EndAction();
bool HW_IsIdle() const;
bool HW_ReadMailbox(uint32_t *values);
bool HW_SendWorkRequest(uint32_t handle);
void HW_LoadCalibration(const LoadCalibrationConfig &config);
void HW_SetSpotFinderParameters(const SpotFinderParameters &params);
uint32_t HW_GetDataSource();
void HW_SetDataSource(uint32_t val);
void HW_RunInternalGenerator(const FrameGeneratorConfig &config) ;
};
#endif //JFJOCH_HLSDEVICE_H

Some files were not shown because too many files have changed in this diff Show More