mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-02 19:00:05 +02:00
Merge branch 'developer' into jf_h5reader
This commit is contained in:
commit
ab2e290658
29
.gitea/workflows/rh8-native.yml
Normal file
29
.gitea/workflows/rh8-native.yml
Normal file
@ -0,0 +1,29 @@
|
||||
name: Build on RHEL8
|
||||
|
||||
on:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: "ubuntu-latest"
|
||||
container:
|
||||
image: gitea.psi.ch/detectors/rhel8-detectors-dev
|
||||
steps:
|
||||
- name: Clone repository
|
||||
run: |
|
||||
echo Cloning ${{ github.ref_name }}
|
||||
git clone https://${{secrets.GITHUB_TOKEN}}@gitea.psi.ch/${{ github.repository }}.git --branch=${{ github.ref_name }} .
|
||||
|
||||
- name: Build library
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake .. -DSLS_USE_PYTHON=ON -DSLS_USE_TESTS=ON
|
||||
make -j 2
|
||||
|
||||
- name: C++ unit tests
|
||||
working-directory: ${{gitea.workspace}}/build
|
||||
run: ctest
|
27
.gitea/workflows/rh9-native.yml
Normal file
27
.gitea/workflows/rh9-native.yml
Normal file
@ -0,0 +1,27 @@
|
||||
name: Build on RHEL9
|
||||
|
||||
on:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: "ubuntu-latest"
|
||||
container:
|
||||
image: gitea.psi.ch/detectors/rhel9-detectors-dev
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
|
||||
- name: Build library
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake .. -DSLS_USE_PYTHON=ON -DSLS_USE_TESTS=ON
|
||||
make -j 2
|
||||
|
||||
- name: C++ unit tests
|
||||
working-directory: ${{gitea.workspace}}/build
|
||||
run: ctest
|
@ -1,4 +1,4 @@
|
||||
name: CMake
|
||||
name: Native CMake Build
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
@ -14,7 +14,13 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Configure and build using cmake
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.12
|
||||
cache: 'pip'
|
||||
- run: pip install pytest numpy
|
||||
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: libhdf5-dev qtbase5-dev qt5-qmake libqt5svg5-dev libpng-dev libtiff-dev
|
||||
@ -27,12 +33,15 @@ jobs:
|
||||
|
||||
- name: Build
|
||||
# Build your program with the given configuration
|
||||
run: cmake --build ${{github.workspace}}/build -j2 --config ${{env.BUILD_TYPE}}
|
||||
run: cmake --build ${{github.workspace}}/build -j4 --config ${{env.BUILD_TYPE}}
|
||||
|
||||
- name: Test
|
||||
- name: C++ unit tests
|
||||
working-directory: ${{github.workspace}}/build
|
||||
# Execute tests defined by the CMake configuration.
|
||||
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
||||
run: ctest -C ${{env.BUILD_TYPE}} -j1
|
||||
|
||||
- name: Python unit tests
|
||||
working-directory: ${{github.workspace}}/build/bin
|
||||
run: |
|
||||
python -m pytest ${{github.workspace}}/python/tests
|
||||
|
||||
|
42
.github/workflows/conda_library.yaml
vendored
Normal file
42
.github/workflows/conda_library.yaml
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
name: Build slsdetlib
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [ubuntu-latest, ] # macos-12, windows-2019]
|
||||
python-version: ["3.12",]
|
||||
|
||||
runs-on: ${{ matrix.platform }}
|
||||
|
||||
# The setup-miniconda action needs this to activate miniconda
|
||||
defaults:
|
||||
run:
|
||||
shell: "bash -l {0}"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Get conda
|
||||
uses: conda-incubator/setup-miniconda@v3.0.4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
channels: conda-forge
|
||||
|
||||
- name: Prepare
|
||||
run: conda install conda-build conda-verify pytest anaconda-client
|
||||
|
||||
- name: Disable upload
|
||||
run: conda config --set anaconda_upload no
|
||||
|
||||
- name: Build
|
||||
run: conda build conda-recipes/main-library --output-folder build_output
|
||||
|
||||
- name: Upload all Conda packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: conda-packages
|
||||
path: build_output/** # Uploads all packages
|
42
.github/workflows/conda_python.yaml
vendored
Normal file
42
.github/workflows/conda_python.yaml
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
name: slsdet
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [ubuntu-latest, ] # macos-12, windows-2019]
|
||||
python-version: ["3.12",]
|
||||
|
||||
runs-on: ${{ matrix.platform }}
|
||||
|
||||
# The setup-miniconda action needs this to activate miniconda
|
||||
defaults:
|
||||
run:
|
||||
shell: "bash -l {0}"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Get conda
|
||||
uses: conda-incubator/setup-miniconda@v3.0.4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
channels: conda-forge
|
||||
|
||||
- name: Prepare
|
||||
run: conda install conda-build conda-verify pytest anaconda-client
|
||||
|
||||
- name: Disable upload
|
||||
run: conda config --set anaconda_upload no
|
||||
|
||||
- name: Build
|
||||
run: conda build conda-recipes/python-client --output-folder build_output
|
||||
|
||||
- name: Upload all Conda packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: conda-packages
|
||||
path: build_output/** # Uploads all packages
|
@ -1,6 +1,6 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(slsDetectorPackage)
|
||||
|
||||
# Read VERSION file into project version
|
||||
@ -29,20 +29,44 @@ include(FetchContent)
|
||||
option(SLS_FETCH_ZMQ_FROM_GITHUB "Fetch zmq from github" OFF)
|
||||
option(SLS_FETCH_PYBIND11_FROM_GITHUB "Fetch pybind11 from github" OFF)
|
||||
|
||||
|
||||
|
||||
# Allow FetchContent_Populate to be called with a single argument
|
||||
# otherwise deprecated warning is issued
|
||||
# Note: From cmake 3.28 we can pass EXCLUDE_FROM_ALL to FetchContent_Declare
|
||||
# and avoid direct use of Populate
|
||||
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.30")
|
||||
cmake_policy(SET CMP0169 OLD)
|
||||
endif()
|
||||
|
||||
# Patch libzmq to set minimum cmake version to 3.15 to avoid warnings
|
||||
# with newer cmake versions
|
||||
# Patch is applied in the FetchContent_Declare
|
||||
set(SLS_LIBZMQ_VERSION "4.3.4")
|
||||
|
||||
find_program(PATCH_EXECUTABLE patch)
|
||||
if(NOT PATCH_EXECUTABLE)
|
||||
message(FATAL_ERROR "The 'patch' tool is required for patching lib zeromq. Please install it.")
|
||||
endif()
|
||||
|
||||
if(SLS_FETCH_ZMQ_FROM_GITHUB)
|
||||
# Opt in to pull down a zmq version from github instead of
|
||||
# using the bundled verison
|
||||
# using the bundled version
|
||||
FetchContent_Declare(
|
||||
libzmq
|
||||
GIT_REPOSITORY https://github.com/zeromq/libzmq.git
|
||||
GIT_TAG v4.3.4
|
||||
GIT_TAG v${SLS_LIBZMQ_VERSION}
|
||||
PATCH_COMMAND ${CMAKE_COMMAND} -E chdir <SOURCE_DIR> patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/libs/libzmq/libzmq_cmake_version.patch
|
||||
UPDATE_DISCONNECTED 1
|
||||
)
|
||||
else()
|
||||
# Standard behaviour use libzmq included in this repo (libs/libzmq)
|
||||
FetchContent_Declare(
|
||||
libzmq
|
||||
URL ${CMAKE_CURRENT_SOURCE_DIR}/libs/libzmq/libzmq-4.3.4.tar.gz
|
||||
URL ${CMAKE_CURRENT_SOURCE_DIR}/libs/libzmq/libzmq-${SLS_LIBZMQ_VERSION}.tar.gz
|
||||
URL_HASH MD5=cc20b769ac10afa352e5ed2769bb23b3
|
||||
PATCH_COMMAND ${CMAKE_COMMAND} -E chdir <SOURCE_DIR> patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/libs/libzmq/libzmq_cmake_version.patch
|
||||
UPDATE_DISCONNECTED 1
|
||||
)
|
||||
endif()
|
||||
|
||||
@ -54,6 +78,11 @@ set(ENABLE_CPACK OFF CACHE BOOL "")
|
||||
set(ENABLE_CLANG OFF CACHE BOOL "")
|
||||
set(ENABLE_CURVE OFF CACHE BOOL "")
|
||||
set(ENABLE_DRAFTS OFF CACHE BOOL "")
|
||||
set(ENABLE_PRECOMPILED OFF CACHE BOOL "")
|
||||
set(WITH_DOC OFF CACHE BOOL "")
|
||||
set(WITH_DOCS OFF CACHE BOOL "")
|
||||
|
||||
|
||||
|
||||
# Using GetProperties and Populate to be able to exclude zmq
|
||||
# from install (not possible with FetchContent_MakeAvailable(libzmq))
|
||||
@ -191,7 +220,7 @@ endif()
|
||||
# to control options for the libraries
|
||||
if(NOT TARGET slsProjectOptions)
|
||||
add_library(slsProjectOptions INTERFACE)
|
||||
target_compile_features(slsProjectOptions INTERFACE cxx_std_17)
|
||||
target_compile_features(slsProjectOptions INTERFACE cxx_std_17)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET slsProjectWarnings)
|
||||
@ -304,7 +333,8 @@ if (SLS_USE_INTEGRATION_TESTS)
|
||||
endif (SLS_USE_INTEGRATION_TESTS)
|
||||
|
||||
if (SLS_USE_PYTHON)
|
||||
find_package (Python 3.8 COMPONENTS Interpreter Development)
|
||||
find_package (Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED)
|
||||
set(PYBIND11_FINDPYTHON ON) # Needed for RH8
|
||||
if(SLS_FETCH_PYBIND11_FROM_GITHUB)
|
||||
FetchContent_Declare(
|
||||
pybind11
|
||||
@ -329,9 +359,15 @@ if (SLS_USE_CTBGUI)
|
||||
add_subdirectory(pyctbgui)
|
||||
endif(SLS_USE_CTBGUI)
|
||||
|
||||
configure_file( .clang-tidy
|
||||
${CMAKE_BINARY_DIR}/.clang-tidy
|
||||
)
|
||||
# Workaround for file note being copied to build directory
|
||||
# when issuing a python -m build
|
||||
# TODO! Proper fix
|
||||
if(EXISTS ".clang-tidy")
|
||||
configure_file(.clang-tidy
|
||||
${CMAKE_BINARY_DIR}/.clang-tidy
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
if (SLS_BUILD_EXAMPLES)
|
||||
add_subdirectory(sample)
|
||||
|
@ -1,11 +0,0 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
echo "|<-------- starting python build"
|
||||
|
||||
cd python
|
||||
|
||||
# copy VERSION into slsdet for installation
|
||||
cp ../VERSION slsdet/VERSION
|
||||
|
||||
${PYTHON} setup.py install
|
@ -1,8 +0,0 @@
|
||||
python:
|
||||
- 3.8
|
||||
- 3.9
|
||||
- 3.10
|
||||
- 3.11
|
||||
- 3.12
|
||||
- 3.13
|
||||
|
@ -1,11 +0,0 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
mkdir $PREFIX/lib
|
||||
mkdir $PREFIX/bin
|
||||
mkdir $PREFIX/include
|
||||
|
||||
|
||||
|
||||
cp build/bin/ctbGui $PREFIX/bin/.
|
||||
cp build/bin/libctbRootLib.so $PREFIX/lib/.
|
||||
|
@ -1,125 +0,0 @@
|
||||
package:
|
||||
name: sls_detector_software
|
||||
version: {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
|
||||
|
||||
source:
|
||||
path: ..
|
||||
|
||||
build:
|
||||
number: 0
|
||||
binary_relocation: True
|
||||
rpaths:
|
||||
- lib/
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- cmake
|
||||
- qt 5.*
|
||||
- xorg-libx11
|
||||
- xorg-libice
|
||||
- xorg-libxext
|
||||
- xorg-libsm
|
||||
- xorg-libxau
|
||||
- xorg-libxrender
|
||||
- xorg-libxfixes
|
||||
- {{ cdt('mesa-libgl-devel') }} # [linux]
|
||||
- {{ cdt('mesa-libegl-devel') }} # [linux]
|
||||
- {{ cdt('mesa-dri-drivers') }} # [linux]
|
||||
- {{ cdt('libselinux') }} # [linux]
|
||||
- {{ cdt('libxdamage') }} # [linux]
|
||||
- {{ cdt('libxxf86vm') }} # [linux]
|
||||
- expat
|
||||
|
||||
host:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- xorg-libx11
|
||||
- xorg-libice
|
||||
- xorg-libxext
|
||||
- xorg-libsm
|
||||
- xorg-libxau
|
||||
- xorg-libxrender
|
||||
- xorg-libxfixes
|
||||
- expat
|
||||
|
||||
run:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
|
||||
|
||||
outputs:
|
||||
- name: slsdetlib
|
||||
script: copy_lib.sh
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
|
||||
run:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
|
||||
- name: slsdet
|
||||
script: build_pylib.sh
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- python
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
- setuptools
|
||||
- pybind11=2.13
|
||||
|
||||
host:
|
||||
- python
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
- setuptools
|
||||
- pybind11=2.13
|
||||
|
||||
|
||||
run:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- python
|
||||
- numpy
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
|
||||
test:
|
||||
imports:
|
||||
- slsdet
|
||||
|
||||
|
||||
- name: slsdetgui
|
||||
script: copy_gui.sh
|
||||
requirements:
|
||||
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
|
||||
run:
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
- qt 5.*
|
||||
- expat
|
||||
|
||||
- name: moenchzmq
|
||||
script: copy_moench.sh
|
||||
requirements:
|
||||
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
|
||||
|
||||
run:
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
- expat
|
@ -1,3 +0,0 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
ctest -j2
|
@ -8,7 +8,7 @@ if [ ! -d "install" ]; then
|
||||
mkdir install
|
||||
fi
|
||||
cd build
|
||||
cmake .. \
|
||||
cmake .. -G Ninja \
|
||||
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
-DSLS_USE_TEXTCLIENT=ON \
|
||||
@ -18,7 +18,7 @@ cmake .. \
|
||||
-DSLS_USE_TESTS=ON \
|
||||
-DSLS_USE_PYTHON=OFF \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DSLS_USE_HDF5=OFF\
|
||||
-DSLS_USE_HDF5=OFF \
|
||||
|
||||
NCORES=$(getconf _NPROCESSORS_ONLN)
|
||||
echo "Building using: ${NCORES} cores"
|
13
conda-recipes/main-library/conda_build_config.yaml
Normal file
13
conda-recipes/main-library/conda_build_config.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
c_compiler:
|
||||
- gcc # [linux]
|
||||
|
||||
c_stdlib:
|
||||
- sysroot # [linux]
|
||||
|
||||
cxx_compiler:
|
||||
- gxx # [linux]
|
||||
|
||||
|
||||
c_stdlib_version: # [linux]
|
||||
- 2.17 # [linux]
|
@ -4,7 +4,6 @@
|
||||
mkdir -p $PREFIX/lib
|
||||
mkdir -p $PREFIX/bin
|
||||
mkdir -p $PREFIX/include/sls
|
||||
# mkdir $PREFIX/include/slsDetectorPackage
|
||||
|
||||
#Shared and static libraries
|
||||
cp build/install/lib/* $PREFIX/lib/
|
||||
@ -15,8 +14,10 @@ cp build/install/bin/sls_detector_acquire_zmq $PREFIX/bin/.
|
||||
cp build/install/bin/sls_detector_get $PREFIX/bin/.
|
||||
cp build/install/bin/sls_detector_put $PREFIX/bin/.
|
||||
cp build/install/bin/sls_detector_help $PREFIX/bin/.
|
||||
cp build/install/bin/sls_detector $PREFIX/bin/.
|
||||
cp build/install/bin/slsReceiver $PREFIX/bin/.
|
||||
cp build/install/bin/slsMultiReceiver $PREFIX/bin/.
|
||||
cp build/install/bin/slsFrameSynchronizer $PREFIX/bin/.
|
||||
|
||||
|
||||
cp build/install/include/sls/* $PREFIX/include/sls
|
77
conda-recipes/main-library/meta.yaml
Executable file
77
conda-recipes/main-library/meta.yaml
Executable file
@ -0,0 +1,77 @@
|
||||
source:
|
||||
path: ../..
|
||||
|
||||
{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+(?:\.\d+)*(?:[\+\w\.]+))').group(1) %}
|
||||
package:
|
||||
name: sls_detector_software
|
||||
version: {{ version }}
|
||||
|
||||
build:
|
||||
number: 0
|
||||
binary_relocation: True
|
||||
rpaths:
|
||||
- lib/
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{ stdlib("c") }}
|
||||
- {{ compiler('cxx') }}
|
||||
- git
|
||||
- cmake
|
||||
- ninja
|
||||
- qt 5.*
|
||||
|
||||
host:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- libgl-devel # [linux]
|
||||
- libtiff
|
||||
- zlib
|
||||
|
||||
run:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
|
||||
|
||||
outputs:
|
||||
- name: slsdetlib
|
||||
script: copy_lib.sh
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{ stdlib("c") }}
|
||||
- {{ compiler('cxx') }}
|
||||
|
||||
run:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
|
||||
|
||||
- name: slsdetgui
|
||||
script: copy_gui.sh
|
||||
requirements:
|
||||
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
|
||||
run:
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
- qt 5.*
|
||||
|
||||
|
||||
- name: moenchzmq
|
||||
script: copy_moench.sh
|
||||
requirements:
|
||||
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
|
||||
|
||||
run:
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
16
conda-recipes/python-client/conda_build_config.yaml
Normal file
16
conda-recipes/python-client/conda_build_config.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
python:
|
||||
- 3.11
|
||||
- 3.12
|
||||
- 3.13
|
||||
|
||||
c_compiler:
|
||||
- gcc # [linux]
|
||||
|
||||
c_stdlib:
|
||||
- sysroot # [linux]
|
||||
|
||||
cxx_compiler:
|
||||
- gxx # [linux]
|
||||
|
||||
c_stdlib_version: # [linux]
|
||||
- 2.17 # [linux]
|
45
conda-recipes/python-client/meta.yaml
Normal file
45
conda-recipes/python-client/meta.yaml
Normal file
@ -0,0 +1,45 @@
|
||||
source:
|
||||
path: ../..
|
||||
|
||||
{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+(?:\.\d+)*(?:[\+\w\.]+))').group(1) %}
|
||||
package:
|
||||
name: slsdet
|
||||
version: {{ version }}
|
||||
|
||||
build:
|
||||
number: 0
|
||||
script:
|
||||
- unset CMAKE_GENERATOR && {{ PYTHON }} -m pip install . -vv # [not win]
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- python {{python}}
|
||||
- {{ compiler('c') }}
|
||||
- {{ stdlib("c") }}
|
||||
- {{ compiler('cxx') }}
|
||||
|
||||
host:
|
||||
- cmake
|
||||
- ninja
|
||||
- python {{python}}
|
||||
- pip
|
||||
- scikit-build-core
|
||||
- pybind11 >=2.13.0
|
||||
- fmt
|
||||
- zeromq
|
||||
- nlohmann_json
|
||||
- catch2
|
||||
|
||||
run:
|
||||
- python {{python}}
|
||||
- numpy
|
||||
|
||||
|
||||
test:
|
||||
imports:
|
||||
- slsdet
|
||||
|
||||
|
||||
about:
|
||||
summary: An example project built with pybind11 and scikit-build.
|
||||
# license_file: LICENSE
|
@ -54,6 +54,7 @@ set(SPHINX_SOURCE_FILES
|
||||
src/serverdefaults.rst
|
||||
src/quick_start_guide.rst
|
||||
src/troubleshooting.rst
|
||||
src/pattern.rst
|
||||
src/receivers.rst
|
||||
src/slsreceiver.rst
|
||||
src/udpheader.rst
|
||||
|
@ -359,6 +359,7 @@ Chip Test Board
|
||||
"Digital Flag": 0,
|
||||
"Digital Samples": 1000,
|
||||
"Dbit Offset": 0,
|
||||
"Dbit Reorder": 1,
|
||||
"Dbit Bitset": 0,
|
||||
"Transceiver Mask": "0x3",
|
||||
"Transceiver Flag": 0,
|
||||
|
@ -37,6 +37,7 @@ Welcome to slsDetectorPackage's documentation!
|
||||
pyenums
|
||||
pyexamples
|
||||
pyPatternGenerator
|
||||
pattern
|
||||
|
||||
.. toctree::
|
||||
:caption: Command line
|
||||
|
@ -345,6 +345,9 @@ Chip Test Board
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Dbit Offset | Digital offset of valid data in bytes |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Dbit Reorder | Reorder such that it groups each signal (0-63) |
|
||||
| | from all the different samples together |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Dbit Bitset | Digital 64 bit mask of bits enabled in receiver |
|
||||
+-----------------------+-------------------------------------------------+
|
||||
| Transceiver Mask | Mask of channels enabled in Transceiver |
|
||||
|
122
docs/src/pattern.rst
Normal file
122
docs/src/pattern.rst
Normal file
@ -0,0 +1,122 @@
|
||||
Pattern
|
||||
========================
|
||||
|
||||
This is a test and development feature implemented only for Ctb, Xilinx_Ctb and Mythen3.
|
||||
|
||||
A pattern is a sequence of 64-bit words which is executed using a clock on the FPGA. Each of the 64 bits is connected to a pin or internal signal of the FPGA. The purpose of a pattern is to provide a way to change these 64 signals with precise timing. Commands run by the detector server could manipulate the same signals as the pattern, but they cannot enforce a change in a specific clock cycle.
|
||||
|
||||
**Usage**
|
||||
|
||||
A pattern is written to memory on the FPGA using the patword command.
|
||||
|
||||
.. code-block::
|
||||
|
||||
patword 0x0000 0x000000000000000A
|
||||
patword 0x0001 0x000000000000000B
|
||||
patword 0x0002 0x000000000000000C
|
||||
patword 0x0003 0x000000000000000D
|
||||
patword 0x0004 0x000000000000000E
|
||||
|
||||
The example above writes a five-word pattern into FPGA memory. The first argument is the memory address, the second argument is the content to be written into this address. Before executing a pattern one has to set the address limits of the pattern:
|
||||
|
||||
.. code-block::
|
||||
|
||||
patlimits 0x0000 0x0004
|
||||
|
||||
This instructs the firmware to execute the commands from address 0 to 4 (including 0 and 4). The execution can be started from the pyctbgui or with the commands
|
||||
|
||||
.. code-block::
|
||||
|
||||
start [Ctb, Xilinx_Ctb]
|
||||
patternstart [Mythen3]
|
||||
|
||||
The maximal number of patword addresses is 8192. However, it is possible to extend the length of the pattern sequence using loops and wait commands. Loops can be configured with the following commands:
|
||||
|
||||
.. code-block::
|
||||
|
||||
patloop 0 0x0001 0x0003
|
||||
patnloop 0 7
|
||||
|
||||
The first argument of both commands is the ID of the loop. Ctb and Xilinx_Ctb can have 6 loops (ID 0-5), Mythen3 can have 4 loop definitions. The commands above configure the loop with ID 0 to run 7 times and jump from the patword with address 3 to the patword with address 1. Important: If patnloop is set to 1, the addresses 0x1-0x3 will execute exactly once; if it is set to 0, the pattern addresses will be skipped.
|
||||
|
||||
The same idea is used to introduce wait times. The example below causes the patword at address 0x0002 to be active for 9 clock cycles before the execution continues.
|
||||
|
||||
.. code-block::
|
||||
|
||||
patwait 0 0x0002
|
||||
patwaittime 0 9
|
||||
|
||||
Waits can be placed inside a loop and loops can be nested.
|
||||
|
||||
**patioctrl**
|
||||
|
||||
The function of each bit in the sequence of 64-bit words depends on the connected detector and firmware version. Some of the 64 bits might connect directly to pads of a chip. The patioctrl command is used to configure the direction of some of these signals (not all of them !! See tables below). Signals where the corresponding bit in the argument of patioctrl is set to 1 will be driven from the FPGA.
|
||||
|
||||
**patsetbit and patmask**
|
||||
|
||||
The functions patsetbit and patmask can be used to ignore a specific bit of the pattern.
|
||||
Example:
|
||||
|
||||
.. code-block::
|
||||
|
||||
patmask 0x0101
|
||||
patsetbit 0x0001
|
||||
|
||||
Patmask configures bit 0 and 8 of the pattern to be set to their value in patsetbit. These bits will be ignored during pattern execution and will always be 0 (bit 8) and 1 (bit 0).
|
||||
|
||||
The mappings of bit positions in the pattern word to signals/pads of the FPGA are listed below for the three detector types where patterns are used. In the case of the two CTB's, connections of the signals to actual pads of a chip depend on the layout of the used detector adapter board. Therefore, each type of detector adapter board adds an additional mapping layer.
|
||||
|
||||
**CTB Pattern Bit Mapping**
|
||||
|
||||
.. table::
|
||||
|
||||
+----+---+------+----+----------+-------------------+----------------+
|
||||
| 63 | 62| 61-57| 56 | 55-48 | 47-32 | 31-0 |
|
||||
+----+---+------+----+----------+-------------------+----------------+
|
||||
| A | D| --- | T | EXTIO | DO, stream source | DIO |
|
||||
+----+---+------+----+----------+-------------------+----------------+
|
||||
|
||||
DIO: Driving the 32 FPGA pins corresponding to the lowest 32 bits of the patioctrl command. If bits in patioctrl are 0, the same bit positions in DIO will switch to input pins and connect to dbit sampling. Additionally, some of these 32 bits have an automatic override by detector-specific statemachines which is active whenever one of these statemachines is running (currently bits 7,8,11,14 and 20).
|
||||
|
||||
DO: Directly connected to 16 FPGA pins. Output only. Not influenced by patioctrl. Also connected to bit 47-32 in all Ctb dbit samples. All of them can be used as dbit sample trigger. In addition, every bit of DO can be selected as trigger for sending out a udp packet with samples to the receiver.
|
||||
|
||||
EXTIO: Similar to DIO, but not used as input to the fpga. With the corresponding patioctrl bits set to 0 these pins will switch to a high impedance mode and be ignored by the firmware.
|
||||
|
||||
T: trigger output
|
||||
|
||||
D: enable signal for digital sampling
|
||||
|
||||
A: adc enable
|
||||
|
||||
**Xilinx_CTB Pattern Bit Mapping**
|
||||
|
||||
.. table::
|
||||
|
||||
+-------+----------------+
|
||||
| 63-32 | 31-0 |
|
||||
+-------+----------------+
|
||||
| --- | DIO |
|
||||
+-------+----------------+
|
||||
|
||||
DIO: Driving the 32 FPGA pins corresponding to the lowest 32 bits of the patioctrl command. If bits in patioctrl are 0, the same bit positions in DIO will switch to input pins and connect to dbit sampling. Additionally, some of these 32 bits have an automatic override by detector-specific statemachines which is active whenever these sm's are running (currently bits 7,8,11,14 and 20).
|
||||
|
||||
|
||||
**Mythen3 Pattern Bit Mapping**
|
||||
|
||||
.. table::
|
||||
|
||||
+-------+--------+-------+--------+------------+----------+----------+-----+-----+
|
||||
| 63-33 | 32 | 31-25 | 24 | 23 | 22 | 21 | 20 | 19 |
|
||||
+-------+--------+-------+--------+------------+----------+----------+-----+-----+
|
||||
| --- | signARD| --- | CHSclk | cnt_rst | sto_rst | STATLOAD | STO | SIN |
|
||||
+-------+--------+-------+--------+------------+----------+----------+-----+-----+
|
||||
|
||||
.. table::
|
||||
|
||||
+---------+-----+-------+-------+----+-------+---------+--------+
|
||||
| 18 | 17 | 16-14 | 13 | 12 | 11 | 10 | 9-0 |
|
||||
+---------+-----+-------+-------+----+-------+---------+--------+
|
||||
| SR_MODE | clk | EN | PULSE | RD | CHSIN | ANAMode | TBLOAD |
|
||||
+---------+-----+-------+-------+----+-------+---------+--------+
|
||||
|
||||
For Mythen3 the pattern word only connects to output pins of the FPGA when the pattern is running. Afterwards the signals will switch back to other logic in the FPGA. Both CTB's hold the last executed pattern word until a new pattern is started.
|
18
libs/libzmq/libzmq_cmake_version.patch
Normal file
18
libs/libzmq/libzmq_cmake_version.patch
Normal file
@ -0,0 +1,18 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index dd3d8eb9..c0187747 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -1,11 +1,8 @@
|
||||
# CMake build script for ZeroMQ
|
||||
project(ZeroMQ)
|
||||
|
||||
-if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
|
||||
- cmake_minimum_required(VERSION 3.0.2)
|
||||
-else()
|
||||
- cmake_minimum_required(VERSION 2.8.12)
|
||||
-endif()
|
||||
+cmake_minimum_required(VERSION 3.15)
|
||||
+message(STATUS "Patched cmake version")
|
||||
|
||||
include(CheckIncludeFiles)
|
||||
include(CheckCCompilerFlag)
|
@ -12,5 +12,6 @@ slsDetectorPackage/8.0.1_rh8 stable cmake/3.15.5 Qt/5.12.10
|
||||
slsDetectorPackage/8.0.2_rh7 stable cmake/3.15.5 Qt/5.12.10
|
||||
slsDetectorPackage/8.0.2_rh8 stable cmake/3.15.5 Qt/5.12.10
|
||||
slsDetectorPackage/9.0.0_rh8 stable cmake/3.15.5 Qt/5.12.10
|
||||
slsDetectorPackage/9.1.0_rh8 stable cmake/3.15.5 Qt/5.12.10
|
||||
|
||||
|
||||
|
@ -22,6 +22,7 @@ class SignalsTab(QtWidgets.QWidget):
|
||||
self.plotTab = None
|
||||
self.legend: LegendItem | None = None
|
||||
self.rx_dbitoffset = None
|
||||
self.rx_dbitreorder = None
|
||||
self.rx_dbitlist = None
|
||||
|
||||
def refresh(self):
|
||||
@ -29,6 +30,7 @@ class SignalsTab(QtWidgets.QWidget):
|
||||
self.updateDigitalBitEnable()
|
||||
self.updateIOOut()
|
||||
self.getDBitOffset()
|
||||
self.getDBitReorder()
|
||||
|
||||
def connect_ui(self):
|
||||
for i in range(Defines.signals.count):
|
||||
@ -49,6 +51,7 @@ class SignalsTab(QtWidgets.QWidget):
|
||||
partial(self.setIOOutRange, Defines.signals.half, Defines.signals.count))
|
||||
self.view.lineEditPatIOCtrl.editingFinished.connect(self.setIOOutReg)
|
||||
self.view.spinBoxDBitOffset.editingFinished.connect(self.setDbitOffset)
|
||||
self.view.checkBoxDBitReorder.stateChanged.connect(self.setDbitReorder)
|
||||
|
||||
def setup_ui(self):
|
||||
self.plotTab = self.mainWindow.plotTab
|
||||
@ -87,60 +90,79 @@ class SignalsTab(QtWidgets.QWidget):
|
||||
self.legend.addItem(plot, name)
|
||||
|
||||
@recordOrApplyPedestal
|
||||
def _processWaveformData(self, data, aSamples, dSamples, rx_dbitlist, isPlottedArray, rx_dbitoffset, romode,
|
||||
def _processWaveformData(self, data, aSamples, dSamples, rx_dbitreorder, rx_dbitlist, isPlottedArray, romode,
|
||||
nADCEnabled):
|
||||
"""
|
||||
transform raw waveform data into a processed numpy array
|
||||
@param data: raw waveform data
|
||||
"""
|
||||
dbitoffset = rx_dbitoffset
|
||||
|
||||
#transform raw waveform data into a processed numpy array
|
||||
#@param data: raw waveform data
|
||||
|
||||
start_digital_data = 0
|
||||
if romode == 2:
|
||||
dbitoffset += nADCEnabled * 2 * aSamples
|
||||
digital_array = np.array(np.frombuffer(data, offset=dbitoffset, dtype=np.uint8))
|
||||
nbitsPerDBit = dSamples
|
||||
if nbitsPerDBit % 8 != 0:
|
||||
nbitsPerDBit += (8 - (dSamples % 8))
|
||||
offset = 0
|
||||
arr = []
|
||||
for i in rx_dbitlist:
|
||||
# where numbits * numsamples is not a multiple of 8
|
||||
if offset % 8 != 0:
|
||||
offset += (8 - (offset % 8))
|
||||
if not isPlottedArray[i]:
|
||||
offset += nbitsPerDBit
|
||||
return None
|
||||
waveform = np.zeros(dSamples)
|
||||
for iSample in range(dSamples):
|
||||
# all samples for digital bit together from slsReceiver
|
||||
index = int(offset / 8)
|
||||
iBit = offset % 8
|
||||
bit = (digital_array[index] >> iBit) & 1
|
||||
waveform[iSample] = bit
|
||||
offset += 1
|
||||
arr.append(waveform)
|
||||
start_digital_data += nADCEnabled * 2 * aSamples
|
||||
digital_array = np.array(np.frombuffer(data, offset=start_digital_data, dtype=np.uint8))
|
||||
if rx_dbitreorder:
|
||||
samples_per_bit = np.empty((len(rx_dbitlist), dSamples), dtype=np.uint8) #stored per row all the corresponding signals of all samples
|
||||
nbitsPerDBit = dSamples
|
||||
if nbitsPerDBit % 8 != 0:
|
||||
nbitsPerDBit += (8 - (dSamples % 8))
|
||||
bit_index = 0
|
||||
for idx, i in enumerate(rx_dbitlist):
|
||||
# where numbits * numsamples is not a multiple of 8
|
||||
if bit_index % 8 != 0:
|
||||
bit_index += (8 - (bit_index % 8))
|
||||
if not isPlottedArray[i]:
|
||||
bit_index += nbitsPerDBit
|
||||
samples_per_bit[idx, :] = np.nan
|
||||
continue
|
||||
for iSample in range(dSamples):
|
||||
# all samples for digital bit together from slsReceiver
|
||||
index = int(bit_index / 8)
|
||||
iBit = bit_index % 8
|
||||
bit = (digital_array[index] >> iBit) & 1
|
||||
samples_per_bit[idx,iSample] = bit
|
||||
bit_index += 1
|
||||
return samples_per_bit
|
||||
else:
|
||||
nbitsPerSample = len(rx_dbitlist) if len(rx_dbitlist) % 8 == 0 else len(rx_dbitlist) + (8 - (len(rx_dbitlist) % 8))
|
||||
bits_per_sample = np.empty((dSamples, len(rx_dbitlist)), dtype=np.uint8) #store per row all selected bits of a sample
|
||||
for iSample in range(dSamples):
|
||||
bit_index = nbitsPerSample * iSample
|
||||
for idx, i in enumerate(rx_dbitlist):
|
||||
if not isPlottedArray[i]:
|
||||
bit_index += 1
|
||||
bits_per_sample[iSample, idx] = np.nan
|
||||
|
||||
return np.array(arr)
|
||||
index = int(bit_index/8)
|
||||
iBit = idx % 8
|
||||
bit = (digital_array[index] >> iBit) & 1
|
||||
bits_per_sample[iSample, idx] = bit
|
||||
bit_index += 1
|
||||
return bits_per_sample.T.copy()
|
||||
|
||||
|
||||
|
||||
def processWaveformData(self, data, aSamples, dSamples):
|
||||
"""
|
||||
view function
|
||||
plots processed waveform data
|
||||
data: raw waveform data
|
||||
dsamples: digital samples
|
||||
asamples: analog samples
|
||||
"""
|
||||
|
||||
#view function
|
||||
#plots processed waveform data
|
||||
#data: raw waveform data
|
||||
#dsamples: digital samples
|
||||
#asamples: analog samples
|
||||
|
||||
self.refresh()
|
||||
|
||||
waveforms = {}
|
||||
isPlottedArray = {i: getattr(self.view, f"checkBoxBIT{i}Plot").isChecked() for i in self.rx_dbitlist}
|
||||
|
||||
digital_array = self._processWaveformData(data, aSamples, dSamples, self.rx_dbitlist, isPlottedArray,
|
||||
self.rx_dbitoffset, self.mainWindow.romode.value,
|
||||
digital_array = self._processWaveformData(data, aSamples, dSamples, self.rx_dbitreorder, self.rx_dbitlist, isPlottedArray,
|
||||
self.mainWindow.romode.value,
|
||||
self.mainWindow.nADCEnabled)
|
||||
|
||||
irow = 0
|
||||
for idx, i in enumerate(self.rx_dbitlist):
|
||||
for idx, i in enumerate(self.rx_dbitlist):
|
||||
# bits enabled but not plotting
|
||||
waveform = digital_array[idx]
|
||||
if waveform is None:
|
||||
waveform = digital_array[idx, :]
|
||||
if np.isnan(waveform[0]):
|
||||
continue
|
||||
self.mainWindow.digitalPlots[i].setData(waveform)
|
||||
plotName = getattr(self.view, f"labelBIT{i}").text()
|
||||
@ -151,8 +173,10 @@ class SignalsTab(QtWidgets.QWidget):
|
||||
irow += 1
|
||||
else:
|
||||
self.mainWindow.digitalPlots[i].setY(0)
|
||||
|
||||
return waveforms
|
||||
|
||||
|
||||
def initializeAllDigitalPlots(self):
|
||||
self.mainWindow.plotDigitalWaveform = pg.plot()
|
||||
self.mainWindow.plotDigitalWaveform.addLegend(colCount=Defines.colCount)
|
||||
@ -360,14 +384,25 @@ class SignalsTab(QtWidgets.QWidget):
|
||||
self.view.spinBoxDBitOffset.setValue(self.rx_dbitoffset)
|
||||
self.view.spinBoxDBitOffset.editingFinished.connect(self.setDbitOffset)
|
||||
|
||||
def getDBitReorder(self):
|
||||
self.view.checkBoxDBitReorder.stateChanged.disconnect()
|
||||
self.rx_dbitreorder = self.det.rx_dbitreorder
|
||||
self.view.checkBoxDBitReorder.setChecked(self.rx_dbitreorder)
|
||||
self.view.checkBoxDBitReorder.stateChanged.connect(self.setDbitReorder)
|
||||
|
||||
|
||||
def setDbitOffset(self):
|
||||
self.det.rx_dbitoffset = self.view.spinBoxDBitOffset.value()
|
||||
|
||||
def setDbitReorder(self):
|
||||
self.det.rx_dbitreorder = self.view.checkBoxDBitReorder.isChecked()
|
||||
|
||||
def saveParameters(self) -> list:
|
||||
commands = []
|
||||
dblist = [str(i) for i in range(Defines.signals.count) if getattr(self.view, f"checkBoxBIT{i}DB").isChecked()]
|
||||
if len(dblist) > 0:
|
||||
commands.append(f"rx_dbitlist {', '.join(dblist)}")
|
||||
commands.append(f"rx_dbitoffset {self.view.spinBoxDBitOffset.value()}")
|
||||
commands.append(f"rx_dbitreorder {self.view.checkBoxDBitReorder.isChecked()}")
|
||||
commands.append(f"patioctrl {self.view.lineEditPatIOCtrl.text()}")
|
||||
return commands
|
||||
|
@ -6074,6 +6074,33 @@
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_17">
|
||||
<item row="0" column="4">
|
||||
<widget class="QSpinBox" name="spinBoxDBitOffset">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_66">
|
||||
<property name="font">
|
||||
@ -6086,6 +6113,36 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<widget class="QCheckBox" name="checkBoxDBitReorder">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>DBit Reorder</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_48">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>IO Control Register:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEditPatIOCtrl">
|
||||
<property name="sizePolicy">
|
||||
@ -6133,50 +6190,18 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QSpinBox" name="spinBoxDBitOffset">
|
||||
<property name="minimumSize">
|
||||
<item row="0" column="5">
|
||||
<spacer name="horizontalSpacer_22">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>32</height>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_48">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>IO Control Register:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
33
pyproject.toml
Normal file
33
pyproject.toml
Normal file
@ -0,0 +1,33 @@
|
||||
[tool.scikit-build.metadata.version]
|
||||
provider = "scikit_build_core.metadata.regex"
|
||||
input = "VERSION"
|
||||
regex = '^(?P<version>\d+(?:\.\d+)*(?:[\.\+\w]+)?)$'
|
||||
result = "{version}"
|
||||
|
||||
[build-system]
|
||||
requires = [ "scikit-build-core>=0.10", "pybind11", "numpy",]
|
||||
build-backend = "scikit_build_core.build"
|
||||
|
||||
[project]
|
||||
name = "slsdet"
|
||||
dynamic = ["version"]
|
||||
|
||||
[tool.cibuildwheel]
|
||||
before-all = "uname -a"
|
||||
|
||||
[tool.scikit-build.build]
|
||||
verbose = true
|
||||
|
||||
[tool.scikit-build.cmake]
|
||||
build-type = "Release"
|
||||
|
||||
[tool.scikit-build.install]
|
||||
components = [ "python",]
|
||||
|
||||
[tool.scikit-build.cmake.define]
|
||||
SLS_USE_RECEIVER = "OFF"
|
||||
SLS_USE_RECEIVER_BINARIES = "OFF"
|
||||
SLS_USE_TEXTCLIENT = "OFF"
|
||||
SLS_BUILD_SHARED_LIBRARIES = "OFF"
|
||||
SLS_USE_PYTHON = "ON"
|
||||
SLS_INSTALL_PYTHONEXT = "ON"
|
@ -20,7 +20,7 @@ target_link_libraries(_slsdet PUBLIC
|
||||
|
||||
|
||||
set_target_properties(_slsdet PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/slsdet
|
||||
)
|
||||
|
||||
#Copy Python code
|
||||
@ -72,9 +72,18 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/../VERSION
|
||||
if(SLS_INSTALL_PYTHONEXT)
|
||||
install(TARGETS _slsdet
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/python
|
||||
LIBRARY DESTINATION slsdet
|
||||
COMPONENT python
|
||||
)
|
||||
install(
|
||||
FILES ${PYTHON_FILES}
|
||||
DESTINATION slsdet
|
||||
COMPONENT python
|
||||
)
|
||||
install(
|
||||
FILES ../VERSION
|
||||
DESTINATION slsdet
|
||||
COMPONENT python
|
||||
)
|
||||
|
||||
install(FILES ${PYTHON_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/python/slsdet)
|
||||
install(FILES ../VERSION DESTINATION ${CMAKE_INSTALL_PREFIX}/python/slsdet)
|
||||
endif()
|
@ -1,77 +0,0 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
"""
|
||||
Setup file for slsdet
|
||||
Build upon the pybind11 example found here: https://github.com/pybind/python_example
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from setuptools import setup, find_packages
|
||||
from pybind11.setup_helpers import Pybind11Extension, build_ext
|
||||
|
||||
def read_version():
|
||||
try:
|
||||
version_file = os.path.join(os.path.dirname(__file__), 'slsdet', 'VERSION')
|
||||
with open(version_file, "r") as f:
|
||||
return f.read().strip()
|
||||
except:
|
||||
raise RuntimeError("VERSION file not found in slsdet package from setup.py.")
|
||||
|
||||
__version__ = read_version()
|
||||
|
||||
|
||||
def get_conda_path():
|
||||
"""
|
||||
Keep this a function if we need some fancier logic later
|
||||
"""
|
||||
print('Prefix: ', os.environ['CONDA_PREFIX'])
|
||||
return os.environ['CONDA_PREFIX']
|
||||
|
||||
|
||||
#TODO migrate to CMake build or fetch files from cmake?
|
||||
ext_modules = [
|
||||
Pybind11Extension(
|
||||
'_slsdet',
|
||||
['src/main.cpp',
|
||||
'src/enums.cpp',
|
||||
'src/current.cpp',
|
||||
'src/detector.cpp',
|
||||
'src/network.cpp',
|
||||
'src/pattern.cpp',
|
||||
'src/scan.cpp',
|
||||
'src/duration.cpp',
|
||||
'src/DurationWrapper.cpp',
|
||||
'src/pedestal.cpp',
|
||||
]
|
||||
|
||||
|
||||
,
|
||||
include_dirs=[
|
||||
os.path.join(get_conda_path(), 'include'),
|
||||
|
||||
],
|
||||
libraries=['SlsDetector', 'SlsSupport', 'SlsReceiver'],
|
||||
library_dirs=[
|
||||
os.path.join(get_conda_path(), 'lib'),
|
||||
],
|
||||
language='c++'
|
||||
),
|
||||
]
|
||||
|
||||
setup(
|
||||
name='slsdet',
|
||||
version=__version__,
|
||||
author='Erik Frojdh',
|
||||
author_email='erik.frojdh@psi.ch',
|
||||
url='https://github.com/slsdetectorgroup/slsDetectorPackage',
|
||||
description='Detector API for SLS Detector Group detectors',
|
||||
long_description='',
|
||||
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
|
||||
package_data={
|
||||
'slsdet': ['VERSION'],
|
||||
},
|
||||
ext_modules=ext_modules,
|
||||
cmdclass={"build_ext": build_ext},
|
||||
zip_safe=False,
|
||||
)
|
@ -14,7 +14,7 @@ from .pattern import Pattern, patternParameters
|
||||
from .gaincaps import Mythen3GainCapsWrapper
|
||||
from .PatternGenerator import PatternGenerator
|
||||
|
||||
import _slsdet
|
||||
from . import _slsdet
|
||||
xy = _slsdet.xy
|
||||
defs = _slsdet.slsDetectorDefs
|
||||
|
||||
@ -41,3 +41,6 @@ def read_version():
|
||||
|
||||
__version__ = read_version()
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ from .detector import Detector, freeze
|
||||
from .utils import element_if_equal
|
||||
from .dacs import DetectorDacs, NamedDacs
|
||||
from .powers import DetectorPowers, NamedPowers
|
||||
import _slsdet
|
||||
from . import _slsdet
|
||||
dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
||||
from .detector_property import DetectorProperty
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
from .detector_property import DetectorProperty
|
||||
from functools import partial
|
||||
import numpy as np
|
||||
import _slsdet
|
||||
from . import _slsdet
|
||||
from .detector import freeze
|
||||
dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
||||
class Dac(DetectorProperty):
|
||||
|
@ -1,8 +1,8 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
from _slsdet import CppDetectorApi
|
||||
from _slsdet import slsDetectorDefs
|
||||
from _slsdet import IpAddr, MacAddr
|
||||
from ._slsdet import CppDetectorApi
|
||||
from ._slsdet import slsDetectorDefs
|
||||
from ._slsdet import IpAddr, MacAddr
|
||||
|
||||
runStatus = slsDetectorDefs.runStatus
|
||||
timingMode = slsDetectorDefs.timingMode
|
||||
@ -15,7 +15,7 @@ defs = slsDetectorDefs
|
||||
|
||||
from .utils import element_if_equal, all_equal, get_set_bits, list_to_bitmask
|
||||
from .utils import Geometry, to_geo, element, reduce_time, is_iterable, hostname_list
|
||||
from _slsdet import xy
|
||||
from ._slsdet import xy
|
||||
from .gaincaps import Mythen3GainCapsWrapper
|
||||
from . import utils as ut
|
||||
from .proxy import JsonProxy, SlowAdcProxy, ClkDivProxy, MaxPhaseProxy, ClkFreqProxy, PatLoopProxy, PatNLoopProxy, PatWaitProxy, PatWaitTimeProxy
|
||||
@ -3463,6 +3463,16 @@ class Detector(CppDetectorApi):
|
||||
def rx_dbitoffset(self, value):
|
||||
ut.set_using_dict(self.setRxDbitOffset, value)
|
||||
|
||||
@property
|
||||
@element
|
||||
def rx_dbitreorder(self):
|
||||
"""[Ctb] Reorder digital data to group together all samples per signal. Default is 1. Setting to 0 means 'do not reorder' and to keep what the board spits out, which is that all signals in a sample are grouped together."""
|
||||
return self.getRxDbitReorder()
|
||||
|
||||
@rx_dbitreorder.setter
|
||||
def rx_dbitreorder(self, value):
|
||||
ut.set_using_dict(self.setRxDbitReorder, value)
|
||||
|
||||
@property
|
||||
@element
|
||||
def maxadcphaseshift(self):
|
||||
|
@ -11,7 +11,7 @@ Created on Wed Dec 6 11:51:18 2017
|
||||
from .detector import Detector
|
||||
from .temperature import Temperature, DetectorTemperature
|
||||
from .dacs import DetectorDacs
|
||||
import _slsdet
|
||||
from . import _slsdet
|
||||
dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
||||
from .detector_property import DetectorProperty
|
||||
|
||||
|
@ -15,8 +15,8 @@ if dt === detectorType.EIGER:
|
||||
"""
|
||||
|
||||
|
||||
import _slsdet
|
||||
from . import _slsdet
|
||||
for name, cls in _slsdet.slsDetectorDefs.__dict__.items():
|
||||
if isinstance(cls, type):
|
||||
exec(f'{name} = {cls.__module__}.{cls.__qualname__}')
|
||||
exec(f'{name} = _slsdet.{cls.__qualname__}')
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
import _slsdet
|
||||
from . import _slsdet
|
||||
gc = _slsdet.slsDetectorDefs.M3_GainCaps
|
||||
|
||||
|
||||
|
@ -11,7 +11,7 @@ from .detector import Detector, freeze
|
||||
|
||||
# from .adcs import Adc, DetectorAdcs
|
||||
from .dacs import DetectorDacs
|
||||
import _slsdet
|
||||
from . import _slsdet
|
||||
dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
||||
from .detector_property import DetectorProperty
|
||||
|
||||
|
@ -11,7 +11,7 @@ from .detector import Detector, freeze
|
||||
|
||||
# from .adcs import Adc, DetectorAdcs
|
||||
from .dacs import DetectorDacs
|
||||
import _slsdet
|
||||
from . import _slsdet
|
||||
dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
||||
from .detector_property import DetectorProperty
|
||||
|
||||
|
@ -9,7 +9,7 @@ This file contains the specialization for the Moench detector
|
||||
|
||||
from .detector import Detector, freeze
|
||||
from .dacs import DetectorDacs
|
||||
import _slsdet
|
||||
from . import _slsdet
|
||||
dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
||||
from .detector_property import DetectorProperty
|
||||
|
||||
|
@ -11,7 +11,7 @@ from .detector import Detector, freeze
|
||||
|
||||
# from .adcs import Adc, DetectorAdcs
|
||||
from .dacs import DetectorDacs
|
||||
import _slsdet
|
||||
from . import _slsdet
|
||||
dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
||||
gc_enums = _slsdet.slsDetectorDefs.M3_GainCaps
|
||||
from .detector_property import DetectorProperty
|
||||
|
@ -1,8 +1,8 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
import _slsdet
|
||||
from . import _slsdet
|
||||
|
||||
from _slsdet import Pattern
|
||||
from ._slsdet import Pattern
|
||||
|
||||
|
||||
class patternParameters(_slsdet.patternParameters):
|
||||
|
@ -3,7 +3,7 @@
|
||||
from .detector_property import DetectorProperty
|
||||
from functools import partial
|
||||
import numpy as np
|
||||
import _slsdet
|
||||
from . import _slsdet
|
||||
from .detector import freeze
|
||||
dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
||||
class Power(DetectorProperty):
|
||||
|
@ -3,7 +3,7 @@
|
||||
from .utils import element_if_equal
|
||||
from .enums import dacIndex
|
||||
from .defines import M3_MAX_PATTERN_LEVELS, MAX_PATTERN_LEVELS
|
||||
from _slsdet import slsDetectorDefs
|
||||
from ._slsdet import slsDetectorDefs
|
||||
detectorType = slsDetectorDefs.detectorType
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@ but not directly used in controlling the detector
|
||||
"""
|
||||
|
||||
from collections import namedtuple
|
||||
import _slsdet #C++ lib
|
||||
from . import _slsdet #C++ lib
|
||||
import functools
|
||||
import datetime as dt
|
||||
import pathlib
|
||||
|
@ -1664,6 +1664,14 @@ void init_det(py::module &m) {
|
||||
(void (Detector::*)(int, sls::Positions)) &
|
||||
Detector::setRxDbitOffset,
|
||||
py::arg(), py::arg() = Positions{});
|
||||
CppDetectorApi.def("getRxDbitReorder",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getRxDbitReorder,
|
||||
py::arg() = Positions{});
|
||||
CppDetectorApi.def("setRxDbitReorder",
|
||||
(void (Detector::*)(bool, sls::Positions)) &
|
||||
Detector::setRxDbitReorder,
|
||||
py::arg(), py::arg() = Positions{});
|
||||
CppDetectorApi.def("setDigitalIODelay",
|
||||
(void (Detector::*)(uint64_t, int, sls::Positions)) &
|
||||
Detector::setDigitalIODelay,
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include <chrono>
|
||||
#include "py_headers.h"
|
||||
|
||||
#include "DurationWrapper.h"
|
||||
@ -19,4 +20,25 @@ void init_duration(py::module &m) {
|
||||
<< " count: " << self.count() << ")";
|
||||
return ss.str();
|
||||
});
|
||||
|
||||
m.def(
|
||||
"test_return_DurationWrapper",
|
||||
[]() {
|
||||
DurationWrapper t(1.3);
|
||||
return t;
|
||||
},
|
||||
R"(
|
||||
Test function to return a DurationWrapper object. Ensures that the automatic conversion in typecaster.h works.
|
||||
)");
|
||||
|
||||
m.def(
|
||||
"test_duration_to_ns",
|
||||
[](const std::chrono::nanoseconds t) {
|
||||
//Duration wrapper is used to be able to convert from time in python to chrono::nanoseconds
|
||||
//return count to have something to test
|
||||
return t.count();
|
||||
},
|
||||
R"(
|
||||
Test function convert DurationWrapper or number to chrono::ns. Ensures that the automatic conversion in typecaster.h works.
|
||||
)"); // default value to test the default constructor
|
||||
}
|
||||
|
@ -54,11 +54,16 @@ template <> struct type_caster<std::chrono::nanoseconds> {
|
||||
value = duration_cast<nanoseconds>(duration<double>(PyFloat_AsDouble(src.ptr())));
|
||||
return true;
|
||||
}
|
||||
// If invoked with an int we assume it is nanoseconds and convert, same as in chrono.h
|
||||
if (PyLong_Check(src.ptr())) {
|
||||
value = duration_cast<nanoseconds>(duration<int64_t>(PyLong_AsLongLong(src.ptr())));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Lastly if we were actually called with a DurationWrapper object we get
|
||||
// the number of nanoseconds and create a std::chrono::nanoseconds from it
|
||||
py::object py_cls = py::module::import("_slsdet").attr("DurationWrapper");
|
||||
py::object py_cls = py::module::import("slsdet._slsdet").attr("DurationWrapper");
|
||||
if (py::isinstance(src, py_cls)){
|
||||
sls::DurationWrapper *cls = src.cast<sls::DurationWrapper *>();
|
||||
value = nanoseconds(cls->count());
|
||||
@ -77,7 +82,7 @@ template <> struct type_caster<std::chrono::nanoseconds> {
|
||||
* set the count from chrono::nanoseconds and return
|
||||
*/
|
||||
static handle cast(std::chrono::nanoseconds src, return_value_policy /* policy */, handle /* parent */) {
|
||||
py::object py_cls = py::module::import("_slsdet").attr("DurationWrapper");
|
||||
py::object py_cls = py::module::import("slsdet._slsdet").attr("DurationWrapper");
|
||||
py::object* obj = new py::object;
|
||||
*obj = py_cls();
|
||||
sls::DurationWrapper *dur = obj->cast<sls::DurationWrapper *>();
|
||||
|
58
python/tests/test_DurationWrapper.py
Normal file
58
python/tests/test_DurationWrapper.py
Normal file
@ -0,0 +1,58 @@
|
||||
import pytest
|
||||
|
||||
from slsdet import DurationWrapper
|
||||
|
||||
#import the compiled extension to use test functions for the automatic conversion
|
||||
from slsdet import _slsdet
|
||||
|
||||
|
||||
def test_default_construction_of_DurationWrapper():
|
||||
"""Test default construction of DurationWrapper"""
|
||||
t = DurationWrapper()
|
||||
assert t.count() == 0
|
||||
assert t.total_seconds() == 0
|
||||
|
||||
def test_construction_of_DurationWrapper():
|
||||
"""Test construction of DurationWrapper with total_seconds"""
|
||||
t = DurationWrapper(5)
|
||||
assert t.count() == 5e9
|
||||
assert t.total_seconds() == 5
|
||||
|
||||
def test_set_count_on_DurationWrapper():
|
||||
"""Test set_count on DurationWrapper"""
|
||||
t = DurationWrapper()
|
||||
t.set_count(10)
|
||||
assert t.count() == 10
|
||||
assert t.total_seconds() == 10e-9
|
||||
t.set_count(0)
|
||||
assert t.count() == 0
|
||||
assert t.total_seconds() == 0
|
||||
|
||||
|
||||
def test_return_a_DurationWrapper_from_cpp():
|
||||
"""Test returning a DurationWrapper from C++"""
|
||||
t = _slsdet.test_return_DurationWrapper()
|
||||
assert t.count() == 1.3e9
|
||||
assert t.total_seconds() == 1.3
|
||||
|
||||
def test_call_a_cpp_function_with_a_duration_wrapper():
|
||||
"""C++ functions can accept a DurationWrapper"""
|
||||
t = DurationWrapper(5)
|
||||
assert _slsdet.test_duration_to_ns(t) == 5e9
|
||||
|
||||
def test_call_a_cpp_function_converting_number_to_DurationWrapper():
|
||||
"""int and float can be converted to std::chrono::nanoseconds"""
|
||||
assert _slsdet.test_duration_to_ns(0) == 0
|
||||
assert _slsdet.test_duration_to_ns(3) == 3e9
|
||||
assert _slsdet.test_duration_to_ns(1.3) == 1.3e9
|
||||
assert _slsdet.test_duration_to_ns(10e-9) == 10
|
||||
|
||||
def test_call_a_cpp_function_with_datetime_timedelta():
|
||||
"""datetime.timedelta can be converted to std::chrono::nanoseconds"""
|
||||
import datetime
|
||||
t = datetime.timedelta(seconds=5)
|
||||
assert _slsdet.test_duration_to_ns(t) == 5e9
|
||||
t = datetime.timedelta(seconds=0)
|
||||
assert _slsdet.test_duration_to_ns(t) == 0
|
||||
t = datetime.timedelta(seconds=1.3)
|
||||
assert _slsdet.test_duration_to_ns(t) == 1.3e9
|
@ -15,6 +15,7 @@
|
||||
#include "loadPattern.h"
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h> // usleep
|
||||
#ifdef VIRTUAL
|
||||
@ -2258,11 +2259,23 @@ void *start_timer(void *arg) {
|
||||
int packetsPerFrame = ceil((double)imageSize / (double)dataSize);
|
||||
|
||||
// Generate Data
|
||||
char imageData[imageSize];
|
||||
char *imageData = (char *)malloc(imageSize);
|
||||
memset(imageData, 0, imageSize);
|
||||
|
||||
if (imageData == NULL) {
|
||||
LOG(logERROR, ("Can not allocate image Data RAM."
|
||||
"Probable cause: Memory Leak.\n"));
|
||||
return NULL;
|
||||
}
|
||||
/*
|
||||
for (int i = 0; i < imageSize; i += sizeof(uint16_t)) {
|
||||
*((uint16_t *)(imageData + i)) = i;
|
||||
}
|
||||
*/
|
||||
|
||||
for (int i = 0; i < imageSize; i += 2 * sizeof(uint64_t)) {
|
||||
*((uint64_t *)(imageData + i)) = 0xffffffffffffffff;
|
||||
}
|
||||
|
||||
// Send data
|
||||
uint64_t frameNr = 0;
|
||||
@ -2319,6 +2332,8 @@ void *start_timer(void *arg) {
|
||||
setNextFrameNumber(frameNr + numFrames);
|
||||
}
|
||||
|
||||
free(imageData);
|
||||
|
||||
closeUDPSocket(0);
|
||||
|
||||
sharedMemory_setStatus(IDLE);
|
||||
|
Binary file not shown.
@ -304,7 +304,7 @@ patternParameters *setChannelRegisterChip(int ichip, char *mask,
|
||||
chanReg |= (0x1 << (3 + icounter));
|
||||
}
|
||||
}
|
||||
|
||||
chanReg /= 2;
|
||||
// deserialize
|
||||
if (chanReg & CHAN_REG_BAD_CHANNEL_MSK) {
|
||||
LOG(logINFOBLUE,
|
||||
|
@ -80,7 +80,7 @@ _sd() {
|
||||
local IS_PATH=0
|
||||
|
||||
|
||||
local SLS_COMMANDS=" acquire activate adcclk adcenable adcenable10g adcindex adcinvert adclist adcname adcphase adcpipeline adcreg adcvpp apulse asamples autocompdisable badchannels blockingtrigger burstmode burstperiod bursts burstsl bustest cdsgain chipversion clearbit clearbusy clientversion clkdiv clkfreq clkphase collectionmode column compdisabletime confadc config configtransceiver counters currentsource dac dacindex daclist dacname dacvalues datastream dbitclk dbitphase dbitpipeline defaultdac defaultpattern delay delayl detectorserverversion detsize diodelay dpulse dr drlist dsamples execcommand exptime exptime1 exptime2 exptime3 extrastoragecells extsampling extsamplingsrc extsig fformat filtercells filterresistor findex firmwaretest firmwareversion fliprows flowcontrol10g fmaster fname foverwrite fpath framecounter frames framesl frametime free fwrite gaincaps gainmode gappixels gatedelay gatedelay1 gatedelay2 gatedelay3 gates getbit hardwareversion highvoltage hostname im_a im_b im_c im_d im_io imagetest initialchecks inj_ch interpolation interruptsubframe kernelversion lastclient led lock master maxadcphaseshift maxclkphaseshift maxdbitphaseshift measuredperiod measuredsubperiod moduleid nextframenumber nmod numinterfaces overflow packageversion parallel parameters partialreset patfname patioctrl patlimits patloop patloop0 patloop1 patloop2 patmask patnloop patnloop0 patnloop1 patnloop2 patsetbit pattern patternstart patwait patwait0 patwait1 patwait2 patwaittime patwaittime0 patwaittime1 patwaittime2 patword pedestalmode period periodl polarity port powerchip powerindex powerlist powername powervalues programfpga pulse pulsechip pulsenmove pumpprobe quad ratecorr readnrows readout readoutspeed readoutspeedlist rebootcontroller reg resetdacs resetfpga romode row runclk runtime rx_arping rx_clearroi rx_dbitlist rx_dbitoffset rx_discardpolicy rx_fifodepth rx_frameindex rx_framescaught rx_framesperfile rx_hostname rx_jsonaddheader rx_jsonpara rx_lastclient rx_lock rx_missingpackets rx_padding rx_printconfig rx_realudpsocksize rx_roi rx_silent rx_start rx_status rx_stop rx_tcpport rx_threads rx_udpsocksize rx_version rx_zmqfreq rx_zmqhwm rx_zmqip rx_zmqport rx_zmqstartfnum rx_zmqstream samples savepattern scan scanerrmsg selinterface serialnumber setbit settings settingslist settingspath signalindex signallist signalname sleep slowadc slowadcindex slowadclist slowadcname slowadcvalues start status stop stopport storagecell_delay storagecell_start subdeadtime subexptime sync syncclk temp_10ge temp_adc temp_control temp_dcdc temp_event temp_fpga temp_fpgaext temp_fpgafl temp_fpgafr temp_slowadc temp_sodl temp_sodr temp_threshold templist tempvalues tengiga threshold thresholdnotb timing timing_info_decoder timinglist timingsource top transceiverenable trigger triggers triggersl trimbits trimen trimval tsamples txdelay txdelay_frame txdelay_left txdelay_right type udp_cleardst udp_dstip udp_dstip2 udp_dstlist udp_dstmac udp_dstmac2 udp_dstport udp_dstport2 udp_firstdst udp_numdst udp_reconfigure udp_srcip udp_srcip2 udp_srcmac udp_srcmac2 udp_validate update updatedetectorserver updatekernel updatemode user v_a v_b v_c v_chip v_d v_io v_limit vchip_comp_adc vchip_comp_fe vchip_cs vchip_opa_1st vchip_opa_fd vchip_ref_comp_fe versions veto vetoalg vetofile vetophoton vetoref vetostream virtual vm_a vm_b vm_c vm_d vm_io zmqhwm zmqip zmqport "
|
||||
local SLS_COMMANDS=" acquire activate adcclk adcenable adcenable10g adcindex adcinvert adclist adcname adcphase adcpipeline adcreg adcvpp apulse asamples autocompdisable badchannels blockingtrigger burstmode burstperiod bursts burstsl bustest cdsgain chipversion clearbit clearbusy clientversion clkdiv clkfreq clkphase collectionmode column compdisabletime confadc config configtransceiver counters currentsource dac dacindex daclist dacname dacvalues datastream dbitclk dbitphase dbitpipeline defaultdac defaultpattern delay delayl detectorserverversion detsize diodelay dpulse dr drlist dsamples execcommand exptime exptime1 exptime2 exptime3 extrastoragecells extsampling extsamplingsrc extsig fformat filtercells filterresistor findex firmwaretest firmwareversion fliprows flowcontrol10g fmaster fname foverwrite fpath framecounter frames framesl frametime free fwrite gaincaps gainmode gappixels gatedelay gatedelay1 gatedelay2 gatedelay3 gates getbit hardwareversion highvoltage hostname im_a im_b im_c im_d im_io imagetest initialchecks inj_ch interpolation interruptsubframe kernelversion lastclient led lock master maxadcphaseshift maxclkphaseshift maxdbitphaseshift measuredperiod measuredsubperiod moduleid nextframenumber nmod numinterfaces overflow packageversion parallel parameters partialreset patfname patioctrl patlimits patloop patloop0 patloop1 patloop2 patmask patnloop patnloop0 patnloop1 patnloop2 patsetbit pattern patternstart patwait patwait0 patwait1 patwait2 patwaittime patwaittime0 patwaittime1 patwaittime2 patword pedestalmode period periodl polarity port powerchip powerindex powerlist powername powervalues programfpga pulse pulsechip pulsenmove pumpprobe quad ratecorr readnrows readout readoutspeed readoutspeedlist rebootcontroller reg resetdacs resetfpga romode row runclk runtime rx_arping rx_clearroi rx_dbitlist rx_dbitoffset rx_dbitreorder rx_discardpolicy rx_fifodepth rx_frameindex rx_framescaught rx_framesperfile rx_hostname rx_jsonaddheader rx_jsonpara rx_lastclient rx_lock rx_missingpackets rx_padding rx_printconfig rx_realudpsocksize rx_roi rx_silent rx_start rx_status rx_stop rx_tcpport rx_threads rx_udpsocksize rx_version rx_zmqfreq rx_zmqhwm rx_zmqip rx_zmqport rx_zmqstartfnum rx_zmqstream samples savepattern scan scanerrmsg selinterface serialnumber setbit settings settingslist settingspath signalindex signallist signalname sleep slowadc slowadcindex slowadclist slowadcname slowadcvalues start status stop stopport storagecell_delay storagecell_start subdeadtime subexptime sync syncclk temp_10ge temp_adc temp_control temp_dcdc temp_event temp_fpga temp_fpgaext temp_fpgafl temp_fpgafr temp_slowadc temp_sodl temp_sodr temp_threshold templist tempvalues tengiga threshold thresholdnotb timing timing_info_decoder timinglist timingsource top transceiverenable trigger triggers triggersl trimbits trimen trimval tsamples txdelay txdelay_frame txdelay_left txdelay_right type udp_cleardst udp_dstip udp_dstip2 udp_dstlist udp_dstmac udp_dstmac2 udp_dstport udp_dstport2 udp_firstdst udp_numdst udp_reconfigure udp_srcip udp_srcip2 udp_srcmac udp_srcmac2 udp_validate update updatedetectorserver updatekernel updatemode user v_a v_b v_c v_chip v_d v_io v_limit vchip_comp_adc vchip_comp_fe vchip_cs vchip_opa_1st vchip_opa_fd vchip_ref_comp_fe versions veto vetoalg vetofile vetophoton vetoref vetostream virtual vm_a vm_b vm_c vm_d vm_io zmqhwm zmqip zmqport "
|
||||
__acquire() {
|
||||
FCN_RETURN=""
|
||||
return 0
|
||||
@ -2088,6 +2088,15 @@ fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
__rx_dbitreorder() {
|
||||
FCN_RETURN=""
|
||||
if [[ ${IS_GET} -eq 0 ]]; then
|
||||
if [[ "${cword}" == "2" ]]; then
|
||||
FCN_RETURN="0 1"
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
__rx_discardpolicy() {
|
||||
FCN_RETURN=""
|
||||
if [[ ${IS_GET} -eq 0 ]]; then
|
||||
|
@ -4,7 +4,7 @@
|
||||
_sd() {
|
||||
|
||||
|
||||
local SLS_COMMANDS=" acquire activate adcclk adcenable adcenable10g adcindex adcinvert adclist adcname adcphase adcpipeline adcreg adcvpp apulse asamples autocompdisable badchannels blockingtrigger burstmode burstperiod bursts burstsl bustest cdsgain chipversion clearbit clearbusy clientversion clkdiv clkfreq clkphase collectionmode column compdisabletime confadc config configtransceiver counters currentsource dac dacindex daclist dacname dacvalues datastream dbitclk dbitphase dbitpipeline defaultdac defaultpattern delay delayl detectorserverversion detsize diodelay dpulse dr drlist dsamples execcommand exptime exptime1 exptime2 exptime3 extrastoragecells extsampling extsamplingsrc extsig fformat filtercells filterresistor findex firmwaretest firmwareversion fliprows flowcontrol10g fmaster fname foverwrite fpath framecounter frames framesl frametime free fwrite gaincaps gainmode gappixels gatedelay gatedelay1 gatedelay2 gatedelay3 gates getbit hardwareversion highvoltage hostname im_a im_b im_c im_d im_io imagetest initialchecks inj_ch interpolation interruptsubframe kernelversion lastclient led lock master maxadcphaseshift maxclkphaseshift maxdbitphaseshift measuredperiod measuredsubperiod moduleid nextframenumber nmod numinterfaces overflow packageversion parallel parameters partialreset patfname patioctrl patlimits patloop patloop0 patloop1 patloop2 patmask patnloop patnloop0 patnloop1 patnloop2 patsetbit pattern patternstart patwait patwait0 patwait1 patwait2 patwaittime patwaittime0 patwaittime1 patwaittime2 patword pedestalmode period periodl polarity port powerchip powerindex powerlist powername powervalues programfpga pulse pulsechip pulsenmove pumpprobe quad ratecorr readnrows readout readoutspeed readoutspeedlist rebootcontroller reg resetdacs resetfpga romode row runclk runtime rx_arping rx_clearroi rx_dbitlist rx_dbitoffset rx_discardpolicy rx_fifodepth rx_frameindex rx_framescaught rx_framesperfile rx_hostname rx_jsonaddheader rx_jsonpara rx_lastclient rx_lock rx_missingpackets rx_padding rx_printconfig rx_realudpsocksize rx_roi rx_silent rx_start rx_status rx_stop rx_tcpport rx_threads rx_udpsocksize rx_version rx_zmqfreq rx_zmqhwm rx_zmqip rx_zmqport rx_zmqstartfnum rx_zmqstream samples savepattern scan scanerrmsg selinterface serialnumber setbit settings settingslist settingspath signalindex signallist signalname sleep slowadc slowadcindex slowadclist slowadcname slowadcvalues start status stop stopport storagecell_delay storagecell_start subdeadtime subexptime sync syncclk temp_10ge temp_adc temp_control temp_dcdc temp_event temp_fpga temp_fpgaext temp_fpgafl temp_fpgafr temp_slowadc temp_sodl temp_sodr temp_threshold templist tempvalues tengiga threshold thresholdnotb timing timing_info_decoder timinglist timingsource top transceiverenable trigger triggers triggersl trimbits trimen trimval tsamples txdelay txdelay_frame txdelay_left txdelay_right type udp_cleardst udp_dstip udp_dstip2 udp_dstlist udp_dstmac udp_dstmac2 udp_dstport udp_dstport2 udp_firstdst udp_numdst udp_reconfigure udp_srcip udp_srcip2 udp_srcmac udp_srcmac2 udp_validate update updatedetectorserver updatekernel updatemode user v_a v_b v_c v_chip v_d v_io v_limit vchip_comp_adc vchip_comp_fe vchip_cs vchip_opa_1st vchip_opa_fd vchip_ref_comp_fe versions veto vetoalg vetofile vetophoton vetoref vetostream virtual vm_a vm_b vm_c vm_d vm_io zmqhwm zmqip zmqport "
|
||||
local SLS_COMMANDS=" acquire activate adcclk adcenable adcenable10g adcindex adcinvert adclist adcname adcphase adcpipeline adcreg adcvpp apulse asamples autocompdisable badchannels blockingtrigger burstmode burstperiod bursts burstsl bustest cdsgain chipversion clearbit clearbusy clientversion clkdiv clkfreq clkphase collectionmode column compdisabletime confadc config configtransceiver counters currentsource dac dacindex daclist dacname dacvalues datastream dbitclk dbitphase dbitpipeline defaultdac defaultpattern delay delayl detectorserverversion detsize diodelay dpulse dr drlist dsamples execcommand exptime exptime1 exptime2 exptime3 extrastoragecells extsampling extsamplingsrc extsig fformat filtercells filterresistor findex firmwaretest firmwareversion fliprows flowcontrol10g fmaster fname foverwrite fpath framecounter frames framesl frametime free fwrite gaincaps gainmode gappixels gatedelay gatedelay1 gatedelay2 gatedelay3 gates getbit hardwareversion highvoltage hostname im_a im_b im_c im_d im_io imagetest initialchecks inj_ch interpolation interruptsubframe kernelversion lastclient led lock master maxadcphaseshift maxclkphaseshift maxdbitphaseshift measuredperiod measuredsubperiod moduleid nextframenumber nmod numinterfaces overflow packageversion parallel parameters partialreset patfname patioctrl patlimits patloop patloop0 patloop1 patloop2 patmask patnloop patnloop0 patnloop1 patnloop2 patsetbit pattern patternstart patwait patwait0 patwait1 patwait2 patwaittime patwaittime0 patwaittime1 patwaittime2 patword pedestalmode period periodl polarity port powerchip powerindex powerlist powername powervalues programfpga pulse pulsechip pulsenmove pumpprobe quad ratecorr readnrows readout readoutspeed readoutspeedlist rebootcontroller reg resetdacs resetfpga romode row runclk runtime rx_arping rx_clearroi rx_dbitlist rx_dbitoffset rx_dbitreorder rx_discardpolicy rx_fifodepth rx_frameindex rx_framescaught rx_framesperfile rx_hostname rx_jsonaddheader rx_jsonpara rx_lastclient rx_lock rx_missingpackets rx_padding rx_printconfig rx_realudpsocksize rx_roi rx_silent rx_start rx_status rx_stop rx_tcpport rx_threads rx_udpsocksize rx_version rx_zmqfreq rx_zmqhwm rx_zmqip rx_zmqport rx_zmqstartfnum rx_zmqstream samples savepattern scan scanerrmsg selinterface serialnumber setbit settings settingslist settingspath signalindex signallist signalname sleep slowadc slowadcindex slowadclist slowadcname slowadcvalues start status stop stopport storagecell_delay storagecell_start subdeadtime subexptime sync syncclk temp_10ge temp_adc temp_control temp_dcdc temp_event temp_fpga temp_fpgaext temp_fpgafl temp_fpgafr temp_slowadc temp_sodl temp_sodr temp_threshold templist tempvalues tengiga threshold thresholdnotb timing timing_info_decoder timinglist timingsource top transceiverenable trigger triggers triggersl trimbits trimen trimval tsamples txdelay txdelay_frame txdelay_left txdelay_right type udp_cleardst udp_dstip udp_dstip2 udp_dstlist udp_dstmac udp_dstmac2 udp_dstport udp_dstport2 udp_firstdst udp_numdst udp_reconfigure udp_srcip udp_srcip2 udp_srcmac udp_srcmac2 udp_validate update updatedetectorserver updatekernel updatemode user v_a v_b v_c v_chip v_d v_io v_limit vchip_comp_adc vchip_comp_fe vchip_cs vchip_opa_1st vchip_opa_fd vchip_ref_comp_fe versions veto vetoalg vetofile vetophoton vetoref vetostream virtual vm_a vm_b vm_c vm_d vm_io zmqhwm zmqip zmqport "
|
||||
__acquire() {
|
||||
FCN_RETURN=""
|
||||
return 0
|
||||
@ -2012,6 +2012,15 @@ fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
__rx_dbitreorder() {
|
||||
FCN_RETURN=""
|
||||
if [[ ${IS_GET} -eq 0 ]]; then
|
||||
if [[ "${cword}" == "2" ]]; then
|
||||
FCN_RETURN="0 1"
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
__rx_discardpolicy() {
|
||||
FCN_RETURN=""
|
||||
if [[ ${IS_GET} -eq 0 ]]; then
|
||||
|
@ -1412,6 +1412,18 @@ lock:
|
||||
function: setDetectorLock
|
||||
input_types: [ bool ]
|
||||
|
||||
|
||||
rx_dbitreorder:
|
||||
help: "[0, 1]\n\t[Ctb] Reorder digital data such that it groups each signal (0-63) from all the different samples together . Default is 1. Setting to 0 means 'do not reorder' and to keep what the board spits out, which is that all signals in a sample are grouped together."
|
||||
inherit_actions: INTEGER_COMMAND_VEC_ID
|
||||
actions:
|
||||
GET:
|
||||
function: getRxDbitReorder
|
||||
PUT:
|
||||
function: setRxDbitReorder
|
||||
input_types: [ bool ]
|
||||
|
||||
|
||||
################# INTEGER_COMMAND_VEC_ID_GET #################
|
||||
|
||||
master:
|
||||
|
@ -8305,6 +8305,48 @@ rx_dbitoffset:
|
||||
help: "[n_bytes]\n\t[Ctb] Offset in bytes in digital data to skip in receiver."
|
||||
infer_action: true
|
||||
template: true
|
||||
rx_dbitreorder:
|
||||
actions:
|
||||
GET:
|
||||
args:
|
||||
- arg_types: []
|
||||
argc: 0
|
||||
cast_input: []
|
||||
check_det_id: false
|
||||
convert_det_id: true
|
||||
function: getRxDbitReorder
|
||||
input: []
|
||||
input_types: []
|
||||
output:
|
||||
- OutString(t)
|
||||
require_det_id: true
|
||||
store_result_in_t: true
|
||||
PUT:
|
||||
args:
|
||||
- arg_types:
|
||||
- bool
|
||||
argc: 1
|
||||
cast_input:
|
||||
- true
|
||||
check_det_id: false
|
||||
convert_det_id: true
|
||||
function: setRxDbitReorder
|
||||
input:
|
||||
- args[0]
|
||||
input_types:
|
||||
- bool
|
||||
output:
|
||||
- args.front()
|
||||
require_det_id: true
|
||||
store_result_in_t: false
|
||||
command_name: rx_dbitreorder
|
||||
function_alias: rx_dbitreorder
|
||||
help: "[0, 1]\n\t[Ctb] Reorder digital data such that it groups each signal (0-63)\
|
||||
\ from all the different samples together . Default is 1. Setting to 0 means 'do\
|
||||
\ not reorder' and to keep what the board spits out, which is that all signals\
|
||||
\ in a sample are grouped together."
|
||||
infer_action: true
|
||||
template: true
|
||||
rx_discardpolicy:
|
||||
actions:
|
||||
GET:
|
||||
|
@ -1729,6 +1729,16 @@ class Detector {
|
||||
/** [CTB] Set number of bytes of digital data to skip in the Receiver */
|
||||
void setRxDbitOffset(int value, Positions pos = {});
|
||||
|
||||
/** [CTB] */
|
||||
Result<bool> getRxDbitReorder(Positions pos = {}) const;
|
||||
|
||||
/** [CTB] Reorder digital data such that it groups each signal (0-63)
|
||||
* from all the different samples together.
|
||||
* Default is true. Setting to false means 'do not reorder' and to keep what
|
||||
* the board spits out, which is that all signals in a sample are grouped
|
||||
* together */
|
||||
void setRxDbitReorder(bool reorder, Positions pos = {});
|
||||
|
||||
/**
|
||||
* [CTB] Set Digital IO Delay
|
||||
* cannot get
|
||||
|
@ -23,7 +23,7 @@ typedef struct __attribute__((packed)) {
|
||||
#ifdef __cplusplus
|
||||
class Pattern {
|
||||
patternParameters *pat = new patternParameters{};
|
||||
std::ostream& stream(std::ostream &os) const;
|
||||
std::ostream &stream(std::ostream &os) const;
|
||||
|
||||
public:
|
||||
Pattern();
|
||||
|
@ -10700,6 +10700,68 @@ std::string Caller::rx_dbitoffset(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string Caller::rx_dbitreorder(int action) {
|
||||
|
||||
std::ostringstream os;
|
||||
// print help
|
||||
if (action == slsDetectorDefs::HELP_ACTION) {
|
||||
os << R"V0G0N([0, 1]
|
||||
[Ctb] Reorder digital data such that it groups each signal (0-63) from all the different samples together . Default is 1. Setting to 0 means 'do not reorder' and to keep what the board spits out, which is that all signals in a sample are grouped together. )V0G0N"
|
||||
<< std::endl;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
// check if action and arguments are valid
|
||||
if (action == slsDetectorDefs::GET_ACTION) {
|
||||
if (1 && args.size() != 0) {
|
||||
throw RuntimeError("Wrong number of arguments for action GET");
|
||||
}
|
||||
|
||||
if (args.size() == 0) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else if (action == slsDetectorDefs::PUT_ACTION) {
|
||||
if (1 && args.size() != 1) {
|
||||
throw RuntimeError("Wrong number of arguments for action PUT");
|
||||
}
|
||||
|
||||
if (args.size() == 1) {
|
||||
try {
|
||||
StringTo<bool>(args[0]);
|
||||
} catch (...) {
|
||||
throw RuntimeError("Could not convert argument 0 to bool");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
throw RuntimeError("INTERNAL ERROR: Invalid action: supported actions "
|
||||
"are ['GET', 'PUT']");
|
||||
}
|
||||
|
||||
// generate code for each action
|
||||
if (action == slsDetectorDefs::GET_ACTION) {
|
||||
if (args.size() == 0) {
|
||||
auto t = det->getRxDbitReorder(std::vector<int>{det_id});
|
||||
os << OutString(t) << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
if (action == slsDetectorDefs::PUT_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
auto arg0 = StringTo<bool>(args[0]);
|
||||
det->setRxDbitReorder(arg0, std::vector<int>{det_id});
|
||||
os << args.front() << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string Caller::rx_discardpolicy(int action) {
|
||||
|
||||
std::ostringstream os;
|
||||
|
@ -236,6 +236,7 @@ class Caller {
|
||||
std::string rx_clearroi(int action);
|
||||
std::string rx_dbitlist(int action);
|
||||
std::string rx_dbitoffset(int action);
|
||||
std::string rx_dbitreorder(int action);
|
||||
std::string rx_discardpolicy(int action);
|
||||
std::string rx_fifodepth(int action);
|
||||
std::string rx_frameindex(int action);
|
||||
@ -582,6 +583,7 @@ class Caller {
|
||||
{"rx_clearroi", &Caller::rx_clearroi},
|
||||
{"rx_dbitlist", &Caller::rx_dbitlist},
|
||||
{"rx_dbitoffset", &Caller::rx_dbitoffset},
|
||||
{"rx_dbitreorder", &Caller::rx_dbitreorder},
|
||||
{"rx_discardpolicy", &Caller::rx_discardpolicy},
|
||||
{"rx_fifodepth", &Caller::rx_fifodepth},
|
||||
{"rx_frameindex", &Caller::rx_frameindex},
|
||||
|
@ -2277,6 +2277,14 @@ void Detector::setRxDbitOffset(int value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setReceiverDbitOffset, pos, value);
|
||||
}
|
||||
|
||||
Result<bool> Detector::getRxDbitReorder(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getReceiverDbitReorder, pos);
|
||||
}
|
||||
|
||||
void Detector::setRxDbitReorder(bool reorder, Positions pos) {
|
||||
pimpl->Parallel(&Module::setReceiverDbitReorder, pos, reorder);
|
||||
}
|
||||
|
||||
void Detector::setDigitalIODelay(uint64_t pinMask, int delay, Positions pos) {
|
||||
pimpl->Parallel(&Module::setDigitalIODelay, pos, pinMask, delay);
|
||||
}
|
||||
|
@ -2509,6 +2509,15 @@ void Module::setReceiverDbitOffset(int value) {
|
||||
sendToReceiver(F_SET_RECEIVER_DBIT_OFFSET, value, nullptr);
|
||||
}
|
||||
|
||||
bool Module::getReceiverDbitReorder() const {
|
||||
return sendToReceiver<int>(F_GET_RECEIVER_DBIT_REORDER);
|
||||
}
|
||||
|
||||
void Module::setReceiverDbitReorder(bool reorder) {
|
||||
sendToReceiver(F_SET_RECEIVER_DBIT_REORDER, static_cast<int>(reorder),
|
||||
nullptr);
|
||||
}
|
||||
|
||||
void Module::setDigitalIODelay(uint64_t pinMask, int delay) {
|
||||
uint64_t args[]{pinMask, static_cast<uint64_t>(delay)};
|
||||
sendToDetector(F_DIGITAL_IO_DELAY, args, nullptr);
|
||||
|
@ -510,6 +510,8 @@ class Module : public virtual slsDetectorDefs {
|
||||
void setReceiverDbitList(std::vector<int> list);
|
||||
int getReceiverDbitOffset() const;
|
||||
void setReceiverDbitOffset(int value);
|
||||
bool getReceiverDbitReorder() const;
|
||||
void setReceiverDbitReorder(bool value);
|
||||
void setDigitalIODelay(uint64_t pinMask, int delay);
|
||||
bool getLEDEnable() const;
|
||||
void setLEDEnable(bool enable);
|
||||
|
@ -243,10 +243,10 @@ size_t Pattern::load(const std::string &fname) {
|
||||
return numPatWords;
|
||||
}
|
||||
|
||||
std::ostream& Pattern::stream(std::ostream &os) const{
|
||||
std::ostream &Pattern::stream(std::ostream &os) const {
|
||||
for (uint32_t i = pat->limits[0]; i <= pat->limits[1]; ++i) {
|
||||
os << "patword " << ToStringHex(i, 4) << " "
|
||||
<< ToStringHex(pat->word[i], 16) << std::endl;
|
||||
<< ToStringHex(pat->word[i], 16) << std::endl;
|
||||
}
|
||||
|
||||
// patioctrl
|
||||
@ -254,13 +254,12 @@ std::ostream& Pattern::stream(std::ostream &os) const{
|
||||
|
||||
// patlimits
|
||||
os << "patlimits " << ToStringHex(pat->limits[0], 4) << " "
|
||||
<< ToStringHex(pat->limits[1], 4) << std::endl;
|
||||
<< ToStringHex(pat->limits[1], 4) << std::endl;
|
||||
|
||||
for (size_t i = 0; i < MAX_PATTERN_LEVELS; ++i) {
|
||||
// patloop
|
||||
os << "patloop " << i << " "
|
||||
<< ToStringHex(pat->startloop[i], 4) << " "
|
||||
<< ToStringHex(pat->stoploop[i], 4) << std::endl;
|
||||
os << "patloop " << i << " " << ToStringHex(pat->startloop[i], 4) << " "
|
||||
<< ToStringHex(pat->stoploop[i], 4) << std::endl;
|
||||
// patnloop
|
||||
os << "patnloop " << i << " " << pat->nloop[i] << std::endl;
|
||||
}
|
||||
@ -268,10 +267,10 @@ std::ostream& Pattern::stream(std::ostream &os) const{
|
||||
for (size_t i = 0; i < MAX_PATTERN_LEVELS; ++i) {
|
||||
// patwait
|
||||
os << "patwait " << i << " " << ToStringHex(pat->wait[i], 4)
|
||||
<< std::endl;
|
||||
<< std::endl;
|
||||
// patwaittime
|
||||
os << "patwaittime " << i << " " << pat->waittime[i];
|
||||
if (i<MAX_PATTERN_LEVELS-1)
|
||||
if (i < MAX_PATTERN_LEVELS - 1)
|
||||
os << std::endl;
|
||||
}
|
||||
return os;
|
||||
|
@ -2568,6 +2568,22 @@ int InferAction::rx_dbitoffset() {
|
||||
}
|
||||
}
|
||||
|
||||
int InferAction::rx_dbitreorder() {
|
||||
|
||||
if (args.size() == 0) {
|
||||
return slsDetectorDefs::GET_ACTION;
|
||||
}
|
||||
|
||||
if (args.size() == 1) {
|
||||
return slsDetectorDefs::PUT_ACTION;
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
throw RuntimeError("Could not infer action: Wrong number of arguments");
|
||||
}
|
||||
}
|
||||
|
||||
int InferAction::rx_discardpolicy() {
|
||||
|
||||
if (args.size() == 0) {
|
||||
|
@ -193,6 +193,7 @@ class InferAction {
|
||||
int rx_clearroi();
|
||||
int rx_dbitlist();
|
||||
int rx_dbitoffset();
|
||||
int rx_dbitreorder();
|
||||
int rx_discardpolicy();
|
||||
int rx_fifodepth();
|
||||
int rx_frameindex();
|
||||
@ -527,6 +528,7 @@ class InferAction {
|
||||
{"rx_clearroi", &InferAction::rx_clearroi},
|
||||
{"rx_dbitlist", &InferAction::rx_dbitlist},
|
||||
{"rx_dbitoffset", &InferAction::rx_dbitoffset},
|
||||
{"rx_dbitreorder", &InferAction::rx_dbitreorder},
|
||||
{"rx_discardpolicy", &InferAction::rx_discardpolicy},
|
||||
{"rx_fifodepth", &InferAction::rx_fifodepth},
|
||||
{"rx_frameindex", &InferAction::rx_frameindex},
|
||||
|
@ -445,23 +445,25 @@ TEST_CASE("rx_arping", "[.cmdcall][.rx]") {
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
auto prev_val = det.getRxArping();
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_arping", {"1"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "rx_arping 1\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_arping", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "rx_arping 1\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_arping", {"0"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "rx_arping 0\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setRxArping(prev_val[i], {i});
|
||||
if (det.getDestinationUDPIP()[0].str() != "127.0.0.1") {
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_arping", {"1"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "rx_arping 1\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_arping", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "rx_arping 1\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_arping", {"0"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "rx_arping 0\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setRxArping(prev_val[i], {i});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -583,6 +585,9 @@ TEST_CASE("fpath", "[.cmdcall]") {
|
||||
REQUIRE(oss.str() == "fpath /tmp\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
if (prev_val[i].empty()) {
|
||||
continue;
|
||||
}
|
||||
det.setFilePath(prev_val[i], {i});
|
||||
}
|
||||
}
|
||||
@ -956,6 +961,37 @@ TEST_CASE("rx_dbitoffset", "[.cmdcall][.rx]") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("rx_dbitreorder", "[.cmdcall][.rx]") {
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::CHIPTESTBOARD ||
|
||||
det_type == defs::XILINX_CHIPTESTBOARD) {
|
||||
auto prev_val = det.getRxDbitReorder();
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_dbitreorder", {"0"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "rx_dbitreorder 0\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_dbitreorder", {"1"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "rx_dbitreorder 1\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
caller.call("rx_dbitreorder", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "rx_dbitreorder 1\n");
|
||||
}
|
||||
REQUIRE_THROWS(caller.call("rx_dbitreorder", {"15"}, -1, PUT));
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setRxDbitReorder(prev_val[i], {i});
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(caller.call("rx_dbitreorder", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("rx_jsonaddheader", "[.cmdcall][.rx]") {
|
||||
Detector det;
|
||||
Caller caller(&det);
|
||||
|
@ -3236,7 +3236,7 @@ TEST_CASE("reg", "[.cmdcall]") {
|
||||
addr = 0x80;
|
||||
}
|
||||
if (det_type == defs::GOTTHARD2) {
|
||||
addr = 0x20;
|
||||
addr = 0x298;
|
||||
}
|
||||
std::string saddr = ToStringHex(addr);
|
||||
auto prev_val = det.readRegister(addr);
|
||||
@ -3292,7 +3292,7 @@ TEST_CASE("setbit", "[.cmdcall]") {
|
||||
addr = 0x80;
|
||||
}
|
||||
if (det_type == defs::GOTTHARD2) {
|
||||
addr = 0x20;
|
||||
addr = 0x298;
|
||||
}
|
||||
std::string saddr = ToStringHex(addr);
|
||||
auto prev_val = det.readRegister(addr);
|
||||
@ -3322,7 +3322,7 @@ TEST_CASE("clearbit", "[.cmdcall]") {
|
||||
addr = 0x80;
|
||||
}
|
||||
if (det_type == defs::GOTTHARD2) {
|
||||
addr = 0x20;
|
||||
addr = 0x298;
|
||||
}
|
||||
std::string saddr = ToStringHex(addr);
|
||||
auto prev_val = det.readRegister(addr);
|
||||
@ -3352,7 +3352,7 @@ TEST_CASE("getbit", "[.cmdcall]") {
|
||||
addr = 0x80;
|
||||
}
|
||||
if (det_type == defs::GOTTHARD2) {
|
||||
addr = 0x20;
|
||||
addr = 0x298;
|
||||
}
|
||||
std::string saddr = ToStringHex(addr);
|
||||
auto prev_val = det.readRegister(addr);
|
||||
|
@ -18,11 +18,16 @@ struct Data {
|
||||
constexpr int shm_id = 10;
|
||||
|
||||
TEST_CASE("Create SharedMemory read and write", "[detector]") {
|
||||
const char *env_p = std::getenv("SLSDETNAME");
|
||||
std::string env_name = env_p ? ("_" + std::string(env_p)) : "";
|
||||
|
||||
SharedMemory<Data> shm(shm_id, -1);
|
||||
if (shm.exists()) {
|
||||
shm.removeSharedMemory();
|
||||
}
|
||||
shm.createSharedMemory();
|
||||
CHECK(shm.getName() == std::string("/slsDetectorPackage_detector_") +
|
||||
std::to_string(shm_id));
|
||||
std::to_string(shm_id) + env_name);
|
||||
|
||||
shm()->x = 3;
|
||||
shm()->y = 5.7;
|
||||
@ -90,10 +95,12 @@ TEST_CASE("Open two shared memories to the same place", "[detector]") {
|
||||
}
|
||||
|
||||
TEST_CASE("Move SharedMemory", "[detector]") {
|
||||
const char *env_p = std::getenv("SLSDETNAME");
|
||||
std::string env_name = env_p ? ("_" + std::string(env_p)) : "";
|
||||
|
||||
SharedMemory<Data> shm(shm_id, -1);
|
||||
CHECK(shm.getName() == std::string("/slsDetectorPackage_detector_") +
|
||||
std::to_string(shm_id));
|
||||
std::to_string(shm_id) + env_name);
|
||||
shm.createSharedMemory();
|
||||
shm()->x = 9;
|
||||
|
||||
@ -104,15 +111,19 @@ TEST_CASE("Move SharedMemory", "[detector]") {
|
||||
REQUIRE_THROWS(
|
||||
shm()); // trying to access should throw instead of returning a nullptr
|
||||
CHECK(shm2.getName() == std::string("/slsDetectorPackage_detector_") +
|
||||
std::to_string(shm_id));
|
||||
std::to_string(shm_id) + env_name);
|
||||
shm2.removeSharedMemory();
|
||||
}
|
||||
|
||||
TEST_CASE("Create several shared memories", "[detector]") {
|
||||
const char *env_p = std::getenv("SLSDETNAME");
|
||||
std::string env_name = env_p ? ("_" + std::string(env_p)) : "";
|
||||
|
||||
constexpr int N = 5;
|
||||
std::vector<SharedMemory<int>> v;
|
||||
v.reserve(N);
|
||||
for (int i = 0; i != N; ++i) {
|
||||
std::cout << "i:" << i << std::endl;
|
||||
v.emplace_back(shm_id + i, -1);
|
||||
CHECK(v[i].exists() == false);
|
||||
v[i].createSharedMemory();
|
||||
@ -123,7 +134,7 @@ TEST_CASE("Create several shared memories", "[detector]") {
|
||||
for (int i = 0; i != N; ++i) {
|
||||
CHECK(*v[i]() == i);
|
||||
CHECK(v[i].getName() == std::string("/slsDetectorPackage_detector_") +
|
||||
std::to_string(i + shm_id));
|
||||
std::to_string(i + shm_id) + env_name);
|
||||
}
|
||||
|
||||
for (int i = 0; i != N; ++i) {
|
||||
@ -133,8 +144,12 @@ TEST_CASE("Create several shared memories", "[detector]") {
|
||||
}
|
||||
|
||||
TEST_CASE("Create create a shared memory with a tag") {
|
||||
const char *env_p = std::getenv("SLSDETNAME");
|
||||
std::string env_name = env_p ? ("_" + std::string(env_p)) : "";
|
||||
|
||||
SharedMemory<int> shm(0, -1, "ctbdacs");
|
||||
REQUIRE(shm.getName() == "/slsDetectorPackage_detector_0_ctbdacs");
|
||||
REQUIRE(shm.getName() ==
|
||||
"/slsDetectorPackage_detector_0" + env_name + "_ctbdacs");
|
||||
}
|
||||
|
||||
TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set") {
|
||||
|
@ -218,6 +218,8 @@ int ClientInterface::functionTable(){
|
||||
flist[F_RECEIVER_SET_TRANSCEIVER_MASK] = &ClientInterface::set_transceiver_mask;
|
||||
flist[F_RECEIVER_SET_ROW] = &ClientInterface::set_row;
|
||||
flist[F_RECEIVER_SET_COLUMN] = &ClientInterface::set_column;
|
||||
flist[F_GET_RECEIVER_DBIT_REORDER] = &ClientInterface::get_dbit_reorder;
|
||||
flist[F_SET_RECEIVER_DBIT_REORDER] = &ClientInterface::set_dbit_reorder;
|
||||
|
||||
|
||||
for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) {
|
||||
@ -1789,4 +1791,25 @@ int ClientInterface::set_column(Interface &socket) {
|
||||
return socket.Send(OK);
|
||||
}
|
||||
|
||||
int ClientInterface::get_dbit_reorder(Interface &socket) {
|
||||
if (detType != CHIPTESTBOARD && detType != XILINX_CHIPTESTBOARD)
|
||||
functionNotImplemented();
|
||||
int retval = impl()->getDbitReorder();
|
||||
LOG(logDEBUG1) << "Dbit reorder retval: " << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int ClientInterface::set_dbit_reorder(Interface &socket) {
|
||||
auto arg = socket.Receive<int>();
|
||||
if (detType != CHIPTESTBOARD && detType != XILINX_CHIPTESTBOARD)
|
||||
functionNotImplemented();
|
||||
if (arg < 0) {
|
||||
throw RuntimeError("Invalid dbit reorder: " + std::to_string(arg));
|
||||
}
|
||||
verifyIdle(socket);
|
||||
LOG(logDEBUG1) << "Setting Dbit reorder: " << arg;
|
||||
impl()->setDbitReorder(arg);
|
||||
return socket.Send(OK);
|
||||
}
|
||||
|
||||
} // namespace sls
|
||||
|
@ -164,6 +164,8 @@ class ClientInterface : private virtual slsDetectorDefs {
|
||||
int set_transceiver_mask(ServerInterface &socket);
|
||||
int set_row(ServerInterface &socket);
|
||||
int set_column(ServerInterface &socket);
|
||||
int get_dbit_reorder(ServerInterface &socket);
|
||||
int set_dbit_reorder(ServerInterface &socket);
|
||||
|
||||
Implementation *impl() {
|
||||
if (receiver != nullptr) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
/************************************************
|
||||
* @file DataProcessor.cpp
|
||||
* @short creates data processor thread that
|
||||
* pulls pointers to memory addresses from fifos
|
||||
* pulls pointers to memory addresses from fifos
|
||||
* and processes data stored in them & writes them to file
|
||||
***********************************************/
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <numeric>
|
||||
|
||||
namespace sls {
|
||||
|
||||
@ -71,12 +72,6 @@ void DataProcessor::SetStreamingStartFnum(uint32_t value) {
|
||||
|
||||
void DataProcessor::SetFramePadding(bool enable) { framePadding = enable; }
|
||||
|
||||
void DataProcessor::SetCtbDbitList(std::vector<int> value) {
|
||||
ctbDbitList = value;
|
||||
}
|
||||
|
||||
void DataProcessor::SetCtbDbitOffset(int value) { ctbDbitOffset = value; }
|
||||
|
||||
void DataProcessor::SetQuadEnable(bool value) { quadEnable = value; }
|
||||
|
||||
void DataProcessor::SetFlipRows(bool fd) {
|
||||
@ -213,8 +208,9 @@ std::string DataProcessor::CreateVirtualFile(
|
||||
"Skipping virtual hdf5 file since rx_roi is enabled.");
|
||||
}
|
||||
|
||||
bool gotthard25um =
|
||||
(generalData->detType == GOTTHARD2 && (numModX * numModY) == 2);
|
||||
bool gotthard25um = ((generalData->detType == GOTTHARD ||
|
||||
generalData->detType == GOTTHARD2) &&
|
||||
(numModX * numModY) == 2);
|
||||
|
||||
// 0 for infinite files
|
||||
uint32_t framesPerFile =
|
||||
@ -299,7 +295,7 @@ void DataProcessor::ThreadExecution() {
|
||||
memImage->data);
|
||||
} catch (const std::exception &e) {
|
||||
fifo->FreeAddress(buffer);
|
||||
return;
|
||||
throw RuntimeError(e.what());
|
||||
}
|
||||
|
||||
// stream (if time/freq to stream) or free
|
||||
@ -332,6 +328,7 @@ void DataProcessor::StopProcessing(char *buf) {
|
||||
|
||||
void DataProcessor::ProcessAnImage(sls_receiver_header &header, size_t &size,
|
||||
size_t &firstImageIndex, char *data) {
|
||||
|
||||
uint64_t fnum = header.detHeader.frameNumber;
|
||||
LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum;
|
||||
currentFrameIndex = fnum;
|
||||
@ -355,9 +352,16 @@ void DataProcessor::ProcessAnImage(sls_receiver_header &header, size_t &size,
|
||||
if (framePadding && nump < generalData->packetsPerFrame)
|
||||
PadMissingPackets(header, data);
|
||||
|
||||
// rearrange ctb digital bits (if ctbDbitlist is not empty)
|
||||
if (!ctbDbitList.empty()) {
|
||||
RearrangeDbitData(size, data);
|
||||
// rearrange ctb digital bits
|
||||
if (!generalData->ctbDbitList.empty()) {
|
||||
ArrangeDbitData(size, data);
|
||||
} else if (generalData->ctbDbitReorder) {
|
||||
std::vector<int> ctbDbitList(64);
|
||||
std::iota(ctbDbitList.begin(), ctbDbitList.end(), 0);
|
||||
generalData->SetctbDbitList(ctbDbitList);
|
||||
ArrangeDbitData(size, data);
|
||||
} else if (generalData->ctbDbitOffset > 0) {
|
||||
RemoveTrailingBits(size, data);
|
||||
}
|
||||
|
||||
// 'stream Image' check has to be done here before crop image
|
||||
@ -519,11 +523,53 @@ void DataProcessor::PadMissingPackets(sls_receiver_header header, char *data) {
|
||||
}
|
||||
}
|
||||
|
||||
void DataProcessor::RemoveTrailingBits(size_t &size, char *data) {
|
||||
|
||||
if (!(generalData->detType == slsDetectorDefs::CHIPTESTBOARD ||
|
||||
generalData->detType == slsDetectorDefs::XILINX_CHIPTESTBOARD)) {
|
||||
throw std::runtime_error("behavior undefined for detector " +
|
||||
std::to_string(generalData->detType));
|
||||
}
|
||||
|
||||
const size_t nAnalogDataBytes = generalData->GetNumberOfAnalogDatabytes();
|
||||
const size_t nDigitalDataBytes = generalData->GetNumberOfDigitalDatabytes();
|
||||
const size_t nTransceiverDataBytes =
|
||||
generalData->GetNumberOfTransceiverDatabytes();
|
||||
const size_t ctbDbitOffset = generalData->ctbDbitOffset;
|
||||
|
||||
const size_t ctbDigitalDataBytes = nDigitalDataBytes - ctbDbitOffset;
|
||||
|
||||
// no digital data
|
||||
if (ctbDigitalDataBytes == 0) {
|
||||
LOG(logWARNING)
|
||||
<< "No digital data for call back, yet ctbDbitOffset is non zero.";
|
||||
return;
|
||||
}
|
||||
|
||||
// update size and copy data
|
||||
memmove(data + nAnalogDataBytes, data + nAnalogDataBytes + ctbDbitOffset,
|
||||
ctbDigitalDataBytes + nTransceiverDataBytes);
|
||||
|
||||
size = nAnalogDataBytes + ctbDigitalDataBytes + nTransceiverDataBytes;
|
||||
}
|
||||
|
||||
/** ctb specific */
|
||||
void DataProcessor::RearrangeDbitData(size_t &size, char *data) {
|
||||
int nAnalogDataBytes = generalData->GetNumberOfAnalogDatabytes();
|
||||
int nDigitalDataBytes = generalData->GetNumberOfDigitalDatabytes();
|
||||
int nTransceiverDataBytes = generalData->GetNumberOfTransceiverDatabytes();
|
||||
void DataProcessor::ArrangeDbitData(size_t &size, char *data) {
|
||||
|
||||
if (!(generalData->detType == slsDetectorDefs::CHIPTESTBOARD ||
|
||||
generalData->detType == slsDetectorDefs::XILINX_CHIPTESTBOARD)) {
|
||||
throw std::runtime_error("behavior undefined for detector " +
|
||||
std::to_string(generalData->detType));
|
||||
}
|
||||
|
||||
const size_t nAnalogDataBytes = generalData->GetNumberOfAnalogDatabytes();
|
||||
const size_t nDigitalDataBytes = generalData->GetNumberOfDigitalDatabytes();
|
||||
const size_t nTransceiverDataBytes =
|
||||
generalData->GetNumberOfTransceiverDatabytes();
|
||||
const size_t ctbDbitOffset = generalData->ctbDbitOffset;
|
||||
const bool ctbDbitReorder = generalData->ctbDbitReorder;
|
||||
const auto ctbDbitList = generalData->ctbDbitList;
|
||||
|
||||
// TODO! (Erik) Refactor and add tests
|
||||
int ctbDigitalDataBytes = nDigitalDataBytes - ctbDbitOffset;
|
||||
|
||||
@ -534,47 +580,101 @@ void DataProcessor::RearrangeDbitData(size_t &size, char *data) {
|
||||
return;
|
||||
}
|
||||
|
||||
char *source = (data + nAnalogDataBytes + ctbDbitOffset);
|
||||
|
||||
const int numDigitalSamples = (ctbDigitalDataBytes / sizeof(uint64_t));
|
||||
|
||||
// const int numResult8Bits = ceil((numDigitalSamples * ctbDbitList.size())
|
||||
// / 8.00);
|
||||
int numBitsPerDbit = numDigitalSamples;
|
||||
if ((numBitsPerDbit % 8) != 0)
|
||||
numBitsPerDbit += (8 - (numDigitalSamples % 8));
|
||||
const int totalNumBytes = (numBitsPerDbit / 8) * ctbDbitList.size();
|
||||
std::vector<uint8_t> result(totalNumBytes);
|
||||
int totalNumBytes =
|
||||
0; // number of bytes for selected digital data given by dtbDbitList
|
||||
|
||||
// store each selected bit from all samples consecutively
|
||||
if (ctbDbitReorder) {
|
||||
size_t numBitsPerDbit =
|
||||
numDigitalSamples; // num bits per selected digital
|
||||
// Bit for all samples
|
||||
if ((numBitsPerDbit % 8) != 0)
|
||||
numBitsPerDbit += (8 - (numDigitalSamples % 8));
|
||||
totalNumBytes = (numBitsPerDbit / 8) * ctbDbitList.size();
|
||||
}
|
||||
// store all selected bits from one sample consecutively
|
||||
else {
|
||||
size_t numBitsPerSample =
|
||||
ctbDbitList.size(); // num bits for all selected bits per sample
|
||||
if ((numBitsPerSample % 8) != 0)
|
||||
numBitsPerSample += (8 - (numBitsPerSample % 8));
|
||||
totalNumBytes = (numBitsPerSample / 8) * numDigitalSamples;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> result(totalNumBytes, 0);
|
||||
uint8_t *dest = &result[0];
|
||||
|
||||
auto *source = (uint64_t *)(data + nAnalogDataBytes + ctbDbitOffset);
|
||||
|
||||
// loop through digital bit enable vector
|
||||
int bitoffset = 0;
|
||||
for (auto bi : ctbDbitList) {
|
||||
// where numbits * numDigitalSamples is not a multiple of 8
|
||||
if (bitoffset != 0) {
|
||||
bitoffset = 0;
|
||||
++dest;
|
||||
}
|
||||
|
||||
// loop through the frame digital data
|
||||
for (auto *ptr = source; ptr < (source + numDigitalSamples);) {
|
||||
// get selected bit from each 8 bit
|
||||
uint8_t bit = (*ptr++ >> bi) & 1;
|
||||
*dest |= bit << bitoffset;
|
||||
++bitoffset;
|
||||
// extract destination in 8 bit batches
|
||||
if (bitoffset == 8) {
|
||||
if (ctbDbitReorder) {
|
||||
// loop through digital bit enable vector
|
||||
int bitoffset = 0;
|
||||
for (auto bi : ctbDbitList) {
|
||||
// where numbits * numDigitalSamples is not a multiple of 8
|
||||
if (bitoffset != 0) {
|
||||
bitoffset = 0;
|
||||
++dest;
|
||||
}
|
||||
|
||||
uint8_t byte_index = bi / 8;
|
||||
|
||||
// loop through the frame digital data
|
||||
for (auto *ptr = source + byte_index;
|
||||
ptr < (source + 8 * numDigitalSamples); ptr += 8) {
|
||||
// get selected bit from each 8 bit
|
||||
uint8_t bit = (*ptr >> bi % 8) & 1;
|
||||
*dest |= bit << bitoffset; // stored as least significant
|
||||
++bitoffset;
|
||||
// extract destination in 8 bit batches
|
||||
if (bitoffset == 8) {
|
||||
bitoffset = 0;
|
||||
++dest;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// loop through the digital data
|
||||
int bitoffset = 0;
|
||||
for (auto *ptr = source; ptr < (source + 8 * numDigitalSamples);
|
||||
ptr += 8) {
|
||||
// where bit enable vector size is not a multiple of 8
|
||||
if (bitoffset != 0) {
|
||||
bitoffset = 0;
|
||||
++dest;
|
||||
}
|
||||
|
||||
// loop through digital bit enable vector
|
||||
for (auto bi : ctbDbitList) {
|
||||
// get selected bit from each 64 bit
|
||||
uint8_t byte_index = bi / 8;
|
||||
|
||||
uint8_t bit = (*(ptr + byte_index) >> (bi % 8)) & 1;
|
||||
*dest |= bit << bitoffset;
|
||||
++bitoffset;
|
||||
// extract destination in 8 bit batches
|
||||
if (bitoffset == 8) {
|
||||
bitoffset = 0;
|
||||
++dest;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size = totalNumBytes * sizeof(uint8_t) + nAnalogDataBytes +
|
||||
nTransceiverDataBytes;
|
||||
|
||||
// check if size changed, if so move transceiver data to avoid gap in memory
|
||||
if (size != nAnalogDataBytes + nDigitalDataBytes + nTransceiverDataBytes)
|
||||
memmove(data + nAnalogDataBytes + totalNumBytes * sizeof(uint8_t),
|
||||
data + nAnalogDataBytes + nDigitalDataBytes,
|
||||
nTransceiverDataBytes);
|
||||
|
||||
// copy back to memory and update size
|
||||
memcpy(data + nAnalogDataBytes, result.data(),
|
||||
totalNumBytes * sizeof(uint8_t));
|
||||
size = totalNumBytes * sizeof(uint8_t) + nAnalogDataBytes + ctbDbitOffset +
|
||||
nTransceiverDataBytes;
|
||||
|
||||
LOG(logDEBUG1) << "totalNumBytes: " << totalNumBytes
|
||||
<< " nAnalogDataBytes:" << nAnalogDataBytes
|
||||
<< " ctbDbitOffset:" << ctbDbitOffset
|
||||
|
@ -45,8 +45,6 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
void SetStreamingTimerInMs(uint32_t value);
|
||||
void SetStreamingStartFnum(uint32_t value);
|
||||
void SetFramePadding(bool enable);
|
||||
void SetCtbDbitList(std::vector<int> value);
|
||||
void SetCtbDbitOffset(int value);
|
||||
void SetQuadEnable(bool value);
|
||||
void SetFlipRows(bool fd);
|
||||
void SetNumberofTotalFrames(uint64_t value);
|
||||
@ -91,6 +89,20 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
size_t &, void *),
|
||||
void *arg);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Align corresponding digital bits together (CTB only if ctbDbitlist is not
|
||||
* empty)
|
||||
* set variable reorder to true if data should be rearranged such that
|
||||
* it groups each signal (0-63) from all the different samples together
|
||||
*/
|
||||
void ArrangeDbitData(size_t &size, char *data);
|
||||
|
||||
/**
|
||||
* remove trailing bits in digital data stream
|
||||
*/
|
||||
void RemoveTrailingBits(size_t &size, char *data);
|
||||
|
||||
private:
|
||||
void RecordFirstIndex(uint64_t fnum);
|
||||
|
||||
@ -137,12 +149,6 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
|
||||
void PadMissingPackets(sls_receiver_header header, char *data);
|
||||
|
||||
/**
|
||||
* Align corresponding digital bits together (CTB only if ctbDbitlist is not
|
||||
* empty)
|
||||
*/
|
||||
void RearrangeDbitData(size_t &size, char *data);
|
||||
|
||||
void CropImage(size_t &size, char *data);
|
||||
|
||||
static const std::string typeName;
|
||||
@ -162,10 +168,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
uint32_t streamingTimerInMs;
|
||||
uint32_t streamingStartFnum;
|
||||
uint32_t currentFreqCount{0};
|
||||
struct timespec timerbegin {};
|
||||
struct timespec timerbegin{};
|
||||
bool framePadding;
|
||||
std::vector<int> ctbDbitList;
|
||||
int ctbDbitOffset;
|
||||
std::atomic<bool> startedFlag{false};
|
||||
std::atomic<uint64_t> firstIndex{0};
|
||||
bool quadEnable{false};
|
||||
|
@ -52,6 +52,9 @@ class GeneralData {
|
||||
uint32_t nAnalogSamples{0};
|
||||
uint32_t nDigitalSamples{0};
|
||||
uint32_t nTransceiverSamples{0};
|
||||
std::vector<int> ctbDbitList{};
|
||||
int ctbDbitOffset{0};
|
||||
bool ctbDbitReorder{false};
|
||||
slsDetectorDefs::readoutMode readoutType{slsDetectorDefs::ANALOG_ONLY};
|
||||
uint32_t adcEnableMaskOneGiga{BIT32_MASK};
|
||||
uint32_t adcEnableMaskTenGiga{BIT32_MASK};
|
||||
@ -60,8 +63,8 @@ class GeneralData {
|
||||
slsDetectorDefs::frameDiscardPolicy frameDiscardMode{
|
||||
slsDetectorDefs::NO_DISCARD};
|
||||
|
||||
GeneralData(){};
|
||||
virtual ~GeneralData(){};
|
||||
GeneralData() {};
|
||||
virtual ~GeneralData() {};
|
||||
|
||||
// Returns the pixel depth in byte, 4 bits being 0.5 byte
|
||||
float GetPixelDepth() { return float(dynamicRange) / 8; }
|
||||
@ -148,6 +151,18 @@ class GeneralData {
|
||||
virtual void SetTransceiverEnableMask(int n) {
|
||||
ThrowGenericError("SetTransceiverEnableMask");
|
||||
};
|
||||
|
||||
virtual void SetctbDbitOffset(const int n) {
|
||||
ThrowGenericError("SetctbDbitOffset");
|
||||
};
|
||||
|
||||
virtual void SetctbDbitList(const std::vector<int> &value) {
|
||||
ThrowGenericError("SetctbDbitList");
|
||||
};
|
||||
|
||||
virtual void SetctbDbitReorder(const bool reorder) {
|
||||
ThrowGenericError("SetctbDbitReorder");
|
||||
};
|
||||
};
|
||||
|
||||
class EigerData : public GeneralData {
|
||||
@ -387,6 +402,7 @@ class ChipTestBoardData : public GeneralData {
|
||||
framesPerFile = CTB_MAX_FRAMES_PER_FILE;
|
||||
fifoDepth = 2500;
|
||||
standardheader = true;
|
||||
ctbDbitReorder = true;
|
||||
UpdateImageSize();
|
||||
};
|
||||
|
||||
@ -412,6 +428,12 @@ class ChipTestBoardData : public GeneralData {
|
||||
UpdateImageSize();
|
||||
};
|
||||
|
||||
void SetctbDbitOffset(const int value) { ctbDbitOffset = value; }
|
||||
|
||||
void SetctbDbitList(const std::vector<int> &value) { ctbDbitList = value; }
|
||||
|
||||
void SetctbDbitReorder(const bool value) { ctbDbitReorder = value; }
|
||||
|
||||
void SetOneGigaAdcEnableMask(int n) {
|
||||
adcEnableMaskOneGiga = n;
|
||||
UpdateImageSize();
|
||||
@ -443,6 +465,7 @@ class ChipTestBoardData : public GeneralData {
|
||||
nDigitalBytes = 0;
|
||||
nTransceiverBytes = 0;
|
||||
int nAnalogChans = 0, nDigitalChans = 0, nTransceiverChans = 0;
|
||||
uint64_t digital_bytes_reserved = 0;
|
||||
|
||||
// analog channels (normal, analog/digital readout)
|
||||
if (readoutType == slsDetectorDefs::ANALOG_ONLY ||
|
||||
@ -461,7 +484,12 @@ class ChipTestBoardData : public GeneralData {
|
||||
readoutType == slsDetectorDefs::ANALOG_AND_DIGITAL ||
|
||||
readoutType == slsDetectorDefs::DIGITAL_AND_TRANSCEIVER) {
|
||||
nDigitalChans = NCHAN_DIGITAL;
|
||||
nDigitalBytes = (sizeof(uint64_t) * nDigitalSamples);
|
||||
// allocate enough memory to support reordering of digital bits
|
||||
uint32_t num_bytes_per_bit = (nDigitalSamples % 8 == 0)
|
||||
? nDigitalSamples / 8
|
||||
: nDigitalSamples / 8 + 1;
|
||||
digital_bytes_reserved = 64 * num_bytes_per_bit;
|
||||
nDigitalBytes = sizeof(uint64_t) * nDigitalSamples;
|
||||
LOG(logDEBUG1) << "Number of Digital Channels:" << nDigitalChans
|
||||
<< " Databytes: " << nDigitalBytes;
|
||||
}
|
||||
@ -480,7 +508,7 @@ class ChipTestBoardData : public GeneralData {
|
||||
nPixelsX = nAnalogChans + nDigitalChans + nTransceiverChans;
|
||||
dataSize = tengigaEnable ? 8144 : UDP_PACKET_DATA_BYTES;
|
||||
packetSize = headerSizeinPacket + dataSize;
|
||||
imageSize = nAnalogBytes + nDigitalBytes + nTransceiverBytes;
|
||||
imageSize = nAnalogBytes + digital_bytes_reserved + nTransceiverBytes;
|
||||
packetsPerFrame = ceil((double)imageSize / (double)dataSize);
|
||||
|
||||
LOG(logDEBUG1) << "Total Number of Channels:" << nPixelsX
|
||||
@ -512,6 +540,7 @@ class XilinxChipTestBoardData : public GeneralData {
|
||||
dataSize = 8144;
|
||||
packetSize = headerSizeinPacket + dataSize;
|
||||
tengigaEnable = true;
|
||||
ctbDbitReorder = true;
|
||||
UpdateImageSize();
|
||||
};
|
||||
|
||||
@ -537,6 +566,12 @@ class XilinxChipTestBoardData : public GeneralData {
|
||||
UpdateImageSize();
|
||||
};
|
||||
|
||||
void SetctbDbitOffset(const int value) { ctbDbitOffset = value; }
|
||||
|
||||
void SetctbDbitList(const std::vector<int> &value) { ctbDbitList = value; }
|
||||
|
||||
void SetctbDbitReorder(const bool value) { ctbDbitReorder = value; }
|
||||
|
||||
void SetOneGigaAdcEnableMask(int n) {
|
||||
adcEnableMaskOneGiga = n;
|
||||
UpdateImageSize();
|
||||
@ -563,6 +598,7 @@ class XilinxChipTestBoardData : public GeneralData {
|
||||
nDigitalBytes = 0;
|
||||
nTransceiverBytes = 0;
|
||||
int nAnalogChans = 0, nDigitalChans = 0, nTransceiverChans = 0;
|
||||
uint64_t digital_bytes_reserved = 0;
|
||||
|
||||
// analog channels (normal, analog/digital readout)
|
||||
if (readoutType == slsDetectorDefs::ANALOG_ONLY ||
|
||||
@ -580,7 +616,11 @@ class XilinxChipTestBoardData : public GeneralData {
|
||||
readoutType == slsDetectorDefs::ANALOG_AND_DIGITAL ||
|
||||
readoutType == slsDetectorDefs::DIGITAL_AND_TRANSCEIVER) {
|
||||
nDigitalChans = NCHAN_DIGITAL;
|
||||
nDigitalBytes = (sizeof(uint64_t) * nDigitalSamples);
|
||||
uint32_t num_bytes_per_bit = (nDigitalSamples % 8 == 0)
|
||||
? nDigitalSamples / 8
|
||||
: nDigitalSamples / 8 + 1;
|
||||
digital_bytes_reserved = 64 * num_bytes_per_bit;
|
||||
nDigitalBytes = sizeof(uint64_t) * nDigitalSamples;
|
||||
LOG(logDEBUG1) << "Number of Digital Channels:" << nDigitalChans
|
||||
<< " Databytes: " << nDigitalBytes;
|
||||
}
|
||||
@ -598,7 +638,7 @@ class XilinxChipTestBoardData : public GeneralData {
|
||||
}
|
||||
nPixelsX = nAnalogChans + nDigitalChans + nTransceiverChans;
|
||||
|
||||
imageSize = nAnalogBytes + nDigitalBytes + nTransceiverBytes;
|
||||
imageSize = nAnalogBytes + digital_bytes_reserved + nTransceiverBytes;
|
||||
packetsPerFrame = ceil((double)imageSize / (double)dataSize);
|
||||
|
||||
LOG(logDEBUG1) << "Total Number of Channels:" << nPixelsX
|
||||
|
@ -200,8 +200,6 @@ void Implementation::SetupDataProcessor(int i) {
|
||||
dataProcessor[i]->SetStreamingTimerInMs(streamingTimerInMs);
|
||||
dataProcessor[i]->SetStreamingStartFnum(streamingStartFnum);
|
||||
dataProcessor[i]->SetFramePadding(framePadding);
|
||||
dataProcessor[i]->SetCtbDbitList(ctbDbitList);
|
||||
dataProcessor[i]->SetCtbDbitOffset(ctbDbitOffset);
|
||||
dataProcessor[i]->SetQuadEnable(quadEnable);
|
||||
dataProcessor[i]->SetFlipRows(flipRows);
|
||||
dataProcessor[i]->SetNumberofTotalFrames(numberOfTotalFrames);
|
||||
@ -990,9 +988,11 @@ void Implementation::StartMasterWriter() {
|
||||
? 1
|
||||
: 0;
|
||||
masterAttributes.digitalSamples = generalData->nDigitalSamples;
|
||||
masterAttributes.dbitoffset = ctbDbitOffset;
|
||||
masterAttributes.dbitoffset = generalData->ctbDbitOffset;
|
||||
masterAttributes.dbitreorder = generalData->ctbDbitReorder;
|
||||
masterAttributes.dbitlist = 0;
|
||||
for (auto &i : ctbDbitList) {
|
||||
|
||||
for (auto &i : generalData->ctbDbitList) {
|
||||
masterAttributes.dbitlist |= (static_cast<uint64_t>(1) << i);
|
||||
}
|
||||
masterAttributes.transceiverSamples =
|
||||
@ -1748,22 +1748,29 @@ void Implementation::setTenGigaADCEnableMask(uint32_t mask) {
|
||||
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
||||
}
|
||||
|
||||
std::vector<int> Implementation::getDbitList() const { return ctbDbitList; }
|
||||
|
||||
void Implementation::setDbitList(const std::vector<int> &v) {
|
||||
ctbDbitList = v;
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetCtbDbitList(ctbDbitList);
|
||||
LOG(logINFO) << "Dbit list: " << ToString(ctbDbitList);
|
||||
std::vector<int> Implementation::getDbitList() const {
|
||||
return generalData->ctbDbitList;
|
||||
}
|
||||
|
||||
int Implementation::getDbitOffset() const { return ctbDbitOffset; }
|
||||
void Implementation::setDbitList(const std::vector<int> &v) {
|
||||
generalData->SetctbDbitList(v);
|
||||
LOG(logINFO) << "Dbit list: " << ToString(v);
|
||||
}
|
||||
|
||||
int Implementation::getDbitOffset() const { return generalData->ctbDbitOffset; }
|
||||
|
||||
void Implementation::setDbitOffset(const int s) {
|
||||
ctbDbitOffset = s;
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetCtbDbitOffset(ctbDbitOffset);
|
||||
LOG(logINFO) << "Dbit offset: " << ctbDbitOffset;
|
||||
generalData->SetctbDbitOffset(s);
|
||||
LOG(logINFO) << "Dbit offset: " << s;
|
||||
}
|
||||
|
||||
bool Implementation::getDbitReorder() const {
|
||||
return generalData->ctbDbitReorder;
|
||||
}
|
||||
|
||||
void Implementation::setDbitReorder(const bool reorder) {
|
||||
generalData->SetctbDbitReorder(reorder);
|
||||
LOG(logINFO) << "Dbit reorder: " << reorder;
|
||||
}
|
||||
|
||||
uint32_t Implementation::getTransceiverEnableMask() const {
|
||||
|
@ -252,6 +252,10 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
int getDbitOffset() const;
|
||||
/* [Ctb] */
|
||||
void setDbitOffset(const int s);
|
||||
bool getDbitReorder() const;
|
||||
/* [Ctb] */
|
||||
void setDbitReorder(const bool reorder);
|
||||
|
||||
uint32_t getTransceiverEnableMask() const;
|
||||
/* [Ctb] */
|
||||
void setTransceiverEnableMask(const uint32_t mask);
|
||||
@ -366,8 +370,6 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
int thresholdEnergyeV{-1};
|
||||
std::array<int, 3> thresholdAllEnergyeV = {{-1, -1, -1}};
|
||||
std::vector<int64_t> rateCorrections;
|
||||
std::vector<int> ctbDbitList;
|
||||
int ctbDbitOffset{0};
|
||||
|
||||
// callbacks
|
||||
void (*startAcquisitionCallBack)(const startCallbackHeader,
|
||||
|
@ -551,6 +551,13 @@ void MasterAttributes::WriteHDF5DbitOffset(H5::H5File *fd, H5::Group *group) {
|
||||
dataset.write(&dbitoffset, H5::PredType::NATIVE_INT);
|
||||
}
|
||||
|
||||
void MasterAttributes::WriteHDF5DbitReorder(H5::H5File *fd, H5::Group *group) {
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Dbit Reorder", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&dbitreorder, H5::PredType::NATIVE_INT);
|
||||
}
|
||||
|
||||
void MasterAttributes::WriteHDF5DbitList(H5::H5File *fd, H5::Group *group) {
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
@ -744,6 +751,8 @@ void MasterAttributes::GetCtbBinaryAttributes(
|
||||
w->Uint(digitalSamples);
|
||||
w->Key("Dbit Offset");
|
||||
w->Uint(dbitoffset);
|
||||
w->Key("Dbit Reorder");
|
||||
w->Uint(dbitreorder);
|
||||
w->Key("Dbit Bitset");
|
||||
w->Uint64(dbitlist);
|
||||
w->Key("Transceiver Mask");
|
||||
@ -766,6 +775,7 @@ void MasterAttributes::WriteCtbHDF5Attributes(H5::H5File *fd,
|
||||
MasterAttributes::WriteHDF5DigitalFlag(fd, group);
|
||||
MasterAttributes::WriteHDF5DigitalSamples(fd, group);
|
||||
MasterAttributes::WriteHDF5DbitOffset(fd, group);
|
||||
MasterAttributes::WriteHDF5DbitReorder(fd, group);
|
||||
MasterAttributes::WriteHDF5DbitList(fd, group);
|
||||
MasterAttributes::WriteHDF5TransceiverMask(fd, group);
|
||||
MasterAttributes::WriteHDF5TransceiverFlag(fd, group);
|
||||
@ -791,6 +801,8 @@ void MasterAttributes::GetXilinxCtbBinaryAttributes(
|
||||
w->Uint(digitalSamples);
|
||||
w->Key("Dbit Offset");
|
||||
w->Uint(dbitoffset);
|
||||
w->Key("Dbit Reorder");
|
||||
w->Uint(dbitreorder);
|
||||
w->Key("Dbit Bitset");
|
||||
w->Uint64(dbitlist);
|
||||
w->Key("Transceiver Mask");
|
||||
@ -812,6 +824,7 @@ void MasterAttributes::WriteXilinxCtbHDF5Attributes(H5::H5File *fd,
|
||||
MasterAttributes::WriteHDF5DigitalFlag(fd, group);
|
||||
MasterAttributes::WriteHDF5DigitalSamples(fd, group);
|
||||
MasterAttributes::WriteHDF5DbitOffset(fd, group);
|
||||
MasterAttributes::WriteHDF5DbitReorder(fd, group);
|
||||
MasterAttributes::WriteHDF5DbitList(fd, group);
|
||||
MasterAttributes::WriteHDF5TransceiverMask(fd, group);
|
||||
MasterAttributes::WriteHDF5TransceiverFlag(fd, group);
|
||||
|
@ -51,6 +51,7 @@ class MasterAttributes {
|
||||
uint32_t analogSamples{0};
|
||||
uint32_t digital{0};
|
||||
uint32_t digitalSamples{0};
|
||||
uint32_t dbitreorder{1};
|
||||
uint32_t dbitoffset{0};
|
||||
uint64_t dbitlist{0};
|
||||
uint32_t transceiverMask{0};
|
||||
@ -104,6 +105,7 @@ class MasterAttributes {
|
||||
void WriteHDF5DigitalSamples(H5::H5File *fd, H5::Group *group);
|
||||
void WriteHDF5DbitOffset(H5::H5File *fd, H5::Group *group);
|
||||
void WriteHDF5DbitList(H5::H5File *fd, H5::Group *group);
|
||||
void WriteHDF5DbitReorder(H5::H5File *fd, H5::Group *group);
|
||||
void WriteHDF5TransceiverMask(H5::H5File *fd, H5::Group *group);
|
||||
void WriteHDF5TransceiverFlag(H5::H5File *fd, H5::Group *group);
|
||||
void WriteHDF5TransceiverSamples(H5::H5File *fd, H5::Group *group);
|
||||
|
@ -146,8 +146,21 @@ void GetData(slsDetectorDefs::sls_receiver_header &header,
|
||||
// header->packetsMask.to_string().c_str(),
|
||||
((uint8_t)(*((uint8_t *)(dataPointer)))), imageSize);
|
||||
|
||||
// if data is modified, eg ROI and size is reduced
|
||||
imageSize = 26000;
|
||||
// // example of how to use roi or modify data that is later written to file
|
||||
// slsDetectorDefs::ROI roi{0, 10, 0, 20};
|
||||
// int width = roi.xmax - roi.xmin;
|
||||
// int height = roi.ymax - roi.ymin;
|
||||
// uint8_t *destPtr = (uint8_t *)dataPointer;
|
||||
// for (int irow = roi.ymin; irow < roi.ymax; ++irow) {
|
||||
// memcpy(destPtr,
|
||||
// ((uint8_t *)(dataPointer + irow * callbackHeader.shape.x +
|
||||
// roi.xmin)),
|
||||
// width);
|
||||
// destPtr += width;
|
||||
// }
|
||||
// memcpy((uint8_t*)dataPointer, (uint8_t*)dataPointer
|
||||
// // setting roi for eg. changes size
|
||||
// imageSize = width * height;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,8 +19,8 @@ namespace sls {
|
||||
// files
|
||||
|
||||
// versions
|
||||
#define HDF5_WRITER_VERSION (6.6) // 1 decimal places
|
||||
#define BINARY_WRITER_VERSION (7.2) // 1 decimal places
|
||||
#define HDF5_WRITER_VERSION (6.7) // 1 decimal places
|
||||
#define BINARY_WRITER_VERSION (7.3) // 1 decimal places
|
||||
|
||||
#define MAX_FRAMES_PER_FILE 20000
|
||||
#define SHORT_MAX_FRAMES_PER_FILE 100000
|
||||
|
@ -3,6 +3,9 @@
|
||||
target_sources(tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-GeneralData.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-CircularFifo.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-ArrangeDataBasedOnBitList.cpp
|
||||
)
|
||||
|
||||
target_include_directories(tests PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src>")
|
||||
|
||||
message(STATUS "Resolved path: ${CMAKE_CURRENT_SOURCE_DIR}/../src")
|
411
slsReceiverSoftware/tests/test-ArrangeDataBasedOnBitList.cpp
Normal file
411
slsReceiverSoftware/tests/test-ArrangeDataBasedOnBitList.cpp
Normal file
@ -0,0 +1,411 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2025 Contributors to the SLS Detector Package
|
||||
/************************************************
|
||||
* @file test-ArrangeDataBasedOnBitList.cpp
|
||||
* @short test case for DataProcessor rearrange functions,
|
||||
***********************************************/
|
||||
|
||||
#include "DataProcessor.h"
|
||||
#include "GeneralData.h"
|
||||
#include "catch.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace sls {
|
||||
|
||||
// dummy GeneralData class for testing
|
||||
class GeneralDataTest : public GeneralData {
|
||||
|
||||
public:
|
||||
GeneralDataTest() { detType = slsDetectorDefs::CHIPTESTBOARD; }
|
||||
|
||||
int GetNumberOfAnalogDatabytes() { return nAnalogBytes; };
|
||||
|
||||
int GetNumberOfDigitalDatabytes() { return nDigitalBytes; };
|
||||
|
||||
int GetNumberOfTransceiverDatabytes() { return nTransceiverBytes; };
|
||||
|
||||
void SetNumberOfAnalogDatabytes(int value) { nAnalogBytes = value; }
|
||||
|
||||
void SetNumberOfDigitalDatabytes(int value) { nDigitalBytes = value; }
|
||||
|
||||
void SetNumberOfTransceiverDatabytes(int value) {
|
||||
nTransceiverBytes = value;
|
||||
}
|
||||
|
||||
void SetCtbDbitOffset(const int value) { ctbDbitOffset = value; }
|
||||
|
||||
void SetCtbDbitList(const std::vector<int> &value) { ctbDbitList = value; }
|
||||
|
||||
void SetCtbDbitReorder(const bool value) { ctbDbitReorder = value; }
|
||||
|
||||
private:
|
||||
int nAnalogBytes{};
|
||||
int nDigitalBytes{};
|
||||
int nTransceiverBytes{};
|
||||
};
|
||||
|
||||
// dummy DataProcessor class for testing
|
||||
class DataProcessorTest : public DataProcessor {
|
||||
public:
|
||||
DataProcessorTest() : DataProcessor(0) {};
|
||||
~DataProcessorTest() {};
|
||||
void ArrangeDbitData(size_t &size, char *data) {
|
||||
DataProcessor::ArrangeDbitData(size, data);
|
||||
}
|
||||
|
||||
void RemoveTrailingBits(size_t &size, char *data) {
|
||||
DataProcessor::RemoveTrailingBits(size, data);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* test fixture for Testing,
|
||||
* num_analog_bytes = 1 byte has a value of 125
|
||||
* num_transceiver_bytes = 2 both bytes have a value of 125
|
||||
* num_digital_bytes is variable and is defined by number of samples
|
||||
* default num sample is 5
|
||||
* all bytes in digital data take a value of 255
|
||||
*/
|
||||
class DataProcessorTestFixture {
|
||||
public:
|
||||
DataProcessorTestFixture() {
|
||||
// setup Test Fixture
|
||||
dataprocessor = new DataProcessorTest;
|
||||
generaldata = new GeneralDataTest;
|
||||
|
||||
generaldata->SetNumberOfAnalogDatabytes(num_analog_bytes);
|
||||
generaldata->SetNumberOfTransceiverDatabytes(num_transceiver_bytes);
|
||||
generaldata->SetNumberOfDigitalDatabytes(num_digital_bytes +
|
||||
num_random_offset_bytes);
|
||||
|
||||
dataprocessor->SetGeneralData(generaldata);
|
||||
}
|
||||
|
||||
~DataProcessorTestFixture() {
|
||||
delete[] data;
|
||||
delete dataprocessor;
|
||||
delete generaldata;
|
||||
}
|
||||
|
||||
size_t get_size() const {
|
||||
return num_analog_bytes + num_digital_bytes + num_transceiver_bytes +
|
||||
num_random_offset_bytes;
|
||||
}
|
||||
|
||||
void set_num_samples(const size_t value) {
|
||||
num_samples = value;
|
||||
num_digital_bytes = num_samples * 8; // 64 (8 bytes) per sample
|
||||
|
||||
generaldata->SetNumberOfDigitalDatabytes(num_digital_bytes +
|
||||
num_random_offset_bytes);
|
||||
}
|
||||
|
||||
void set_random_offset_bytes(const size_t value) {
|
||||
num_random_offset_bytes = value;
|
||||
generaldata->SetNumberOfDigitalDatabytes(num_digital_bytes +
|
||||
num_random_offset_bytes);
|
||||
}
|
||||
|
||||
void set_data() {
|
||||
delete[] data;
|
||||
uint64_t max_bytes_per_bit =
|
||||
num_samples % 8 == 0 ? num_samples / 8 : num_samples / 8 + 1;
|
||||
uint64_t reserved_size =
|
||||
get_size() - num_digital_bytes + max_bytes_per_bit * 64;
|
||||
data = new char[reserved_size];
|
||||
|
||||
// set testing data
|
||||
memset(data, dummy_value, num_analog_bytes); // set to dummy value
|
||||
memset(data + num_analog_bytes, 0,
|
||||
num_random_offset_bytes); // set to zero
|
||||
memset(data + num_analog_bytes + num_random_offset_bytes, 0xFF,
|
||||
num_digital_bytes); // all digital bits are one
|
||||
memset(data + num_digital_bytes + num_analog_bytes +
|
||||
num_random_offset_bytes,
|
||||
dummy_value,
|
||||
num_transceiver_bytes); // set to dummy value
|
||||
}
|
||||
|
||||
DataProcessorTest *dataprocessor;
|
||||
GeneralDataTest *generaldata;
|
||||
const size_t num_analog_bytes = 1;
|
||||
const size_t num_transceiver_bytes = 2;
|
||||
const char dummy_value = static_cast<char>(125);
|
||||
size_t num_digital_bytes = 40; // num_samples * 8 = 5 * 8 = 40
|
||||
size_t num_random_offset_bytes = 0;
|
||||
size_t num_samples = 5;
|
||||
char *data = nullptr;
|
||||
};
|
||||
|
||||
TEST_CASE_METHOD(DataProcessorTestFixture, "Remove Trailing Bits",
|
||||
"[.dataprocessor][.bitoffset]") {
|
||||
|
||||
const size_t num_random_offset_bytes = 3;
|
||||
set_random_offset_bytes(num_random_offset_bytes);
|
||||
set_data();
|
||||
|
||||
generaldata->SetCtbDbitOffset(num_random_offset_bytes);
|
||||
|
||||
size_t expected_size = get_size() - num_random_offset_bytes;
|
||||
|
||||
char *expected_data = new char[expected_size];
|
||||
memset(expected_data, dummy_value, num_analog_bytes); // set to 125
|
||||
memset(expected_data + num_analog_bytes, 0xFF,
|
||||
num_digital_bytes); // set to 1
|
||||
memset(expected_data + num_digital_bytes + num_analog_bytes, dummy_value,
|
||||
num_transceiver_bytes); // set to 125
|
||||
|
||||
size_t size = get_size();
|
||||
dataprocessor->RemoveTrailingBits(size, data);
|
||||
|
||||
CHECK(size == expected_size);
|
||||
|
||||
CHECK(memcmp(data, expected_data, expected_size) == 0);
|
||||
|
||||
delete[] expected_data;
|
||||
}
|
||||
|
||||
// parametric test tested with num_samples = 5, num_samples = 10, num_samples =
|
||||
// 8
|
||||
TEST_CASE_METHOD(DataProcessorTestFixture, "Reorder all",
|
||||
"[.dataprocessor][.reorder]") {
|
||||
// parameters: num_samples, expected_num_digital_bytes,
|
||||
// expected_digital_part
|
||||
auto parameters = GENERATE(
|
||||
std::make_tuple(5, 64, std::vector<uint8_t>{0b00011111}),
|
||||
std::make_tuple(10, 2 * 64, std::vector<uint8_t>{0xFF, 0b00000011}),
|
||||
std::make_tuple(8, 64, std::vector<uint8_t>{0xFF}));
|
||||
|
||||
size_t num_samples, expected_num_digital_bytes;
|
||||
std::vector<uint8_t> expected_digital_part;
|
||||
std::tie(num_samples, expected_num_digital_bytes, expected_digital_part) =
|
||||
parameters;
|
||||
|
||||
// set number of samples for test fixture -> create data
|
||||
set_num_samples(num_samples);
|
||||
set_data();
|
||||
|
||||
std::vector<int> bitlist(64);
|
||||
std::iota(bitlist.begin(), bitlist.end(), 0);
|
||||
generaldata->SetCtbDbitList(bitlist);
|
||||
generaldata->SetCtbDbitReorder(true); // set reorder to true
|
||||
|
||||
const size_t expected_size =
|
||||
num_analog_bytes + num_transceiver_bytes + expected_num_digital_bytes;
|
||||
|
||||
// create expected data
|
||||
char *expected_data = new char[expected_size];
|
||||
|
||||
memset(expected_data, dummy_value, num_analog_bytes); // set to 125
|
||||
for (size_t bit = 0; bit < 64; ++bit) {
|
||||
memcpy(expected_data + num_analog_bytes +
|
||||
expected_digital_part.size() * bit,
|
||||
expected_digital_part.data(), expected_digital_part.size());
|
||||
}
|
||||
memset(expected_data + expected_num_digital_bytes + num_analog_bytes,
|
||||
dummy_value,
|
||||
num_transceiver_bytes); // set to 125
|
||||
|
||||
size_t size = get_size();
|
||||
dataprocessor->ArrangeDbitData(size, data); // call reorder
|
||||
|
||||
CHECK(size == expected_size);
|
||||
CHECK(memcmp(data, expected_data, expected_size) == 0);
|
||||
|
||||
delete[] expected_data;
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(DataProcessorTestFixture,
|
||||
"Reorder all and remove trailing bits",
|
||||
"[.dataprocessor][.reorder]") {
|
||||
|
||||
// set number of samples for test fixture -> create data
|
||||
const size_t num_random_offset_bytes = 3;
|
||||
set_random_offset_bytes(num_random_offset_bytes);
|
||||
set_data();
|
||||
|
||||
std::vector<int> bitlist(64);
|
||||
std::iota(bitlist.begin(), bitlist.end(), 0);
|
||||
generaldata->SetCtbDbitList(bitlist);
|
||||
generaldata->SetCtbDbitOffset(num_random_offset_bytes);
|
||||
generaldata->SetCtbDbitReorder(true); // set reorder to true
|
||||
|
||||
const size_t expected_num_digital_bytes = 64;
|
||||
std::vector<uint8_t> expected_digital_part{0b00011111};
|
||||
|
||||
const size_t expected_size =
|
||||
num_analog_bytes + num_transceiver_bytes + expected_num_digital_bytes;
|
||||
|
||||
// create expected data
|
||||
char *expected_data = new char[expected_size];
|
||||
|
||||
memset(expected_data, dummy_value, num_analog_bytes); // set to 125
|
||||
for (size_t bit = 0; bit < 64; ++bit) {
|
||||
memcpy(expected_data + num_analog_bytes +
|
||||
expected_digital_part.size() * bit,
|
||||
expected_digital_part.data(), expected_digital_part.size());
|
||||
}
|
||||
memset(expected_data + expected_num_digital_bytes + num_analog_bytes,
|
||||
dummy_value,
|
||||
num_transceiver_bytes); // set to 125
|
||||
|
||||
size_t size = get_size();
|
||||
dataprocessor->ArrangeDbitData(size, data); // call reorder
|
||||
|
||||
CHECK(size == expected_size);
|
||||
CHECK(memcmp(data, expected_data, expected_size) == 0);
|
||||
|
||||
delete[] expected_data;
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(DataProcessorTestFixture, "Arrange bitlist with reorder false",
|
||||
"[.dataprocessor][.retrievebitlist]") {
|
||||
// parameters: num_samples, bitlist, expected_num_digital_bytes,
|
||||
// expected_digital_part
|
||||
auto parameters = GENERATE(
|
||||
std::make_tuple(5, std::vector<int>{1, 4, 5}, 5,
|
||||
std::vector<uint8_t>{0b00000111}),
|
||||
std::make_tuple(5, std::vector<int>{1, 5, 3, 7, 8, 50, 42, 60, 39}, 10,
|
||||
std::vector<uint8_t>{0xFF, 0b00000001}),
|
||||
std::make_tuple(5, std::vector<int>{1, 5, 3, 7, 8, 50, 42, 60}, 5,
|
||||
std::vector<uint8_t>{0xFF}));
|
||||
|
||||
size_t num_samples, expected_num_digital_bytes;
|
||||
std::vector<uint8_t> expected_digital_part;
|
||||
std::vector<int> bitlist;
|
||||
std::tie(num_samples, bitlist, expected_num_digital_bytes,
|
||||
expected_digital_part) = parameters;
|
||||
|
||||
generaldata->SetCtbDbitList(bitlist);
|
||||
|
||||
generaldata->SetCtbDbitReorder(false);
|
||||
|
||||
set_num_samples(num_samples);
|
||||
set_data();
|
||||
|
||||
size_t expected_size =
|
||||
num_analog_bytes + num_transceiver_bytes + expected_num_digital_bytes;
|
||||
|
||||
// create expected data
|
||||
char *expected_data = new char[expected_size];
|
||||
|
||||
memset(expected_data, dummy_value, num_analog_bytes);
|
||||
|
||||
for (size_t sample = 0; sample < num_samples; ++sample) {
|
||||
memcpy(expected_data + num_analog_bytes +
|
||||
expected_digital_part.size() * sample,
|
||||
expected_digital_part.data(), expected_digital_part.size());
|
||||
}
|
||||
|
||||
memset(expected_data + expected_num_digital_bytes + num_analog_bytes,
|
||||
dummy_value, num_transceiver_bytes);
|
||||
|
||||
size_t size = get_size();
|
||||
dataprocessor->ArrangeDbitData(size, data);
|
||||
|
||||
CHECK(size == expected_size);
|
||||
|
||||
CHECK(memcmp(data, expected_data, expected_size) == 0);
|
||||
|
||||
delete[] expected_data;
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(DataProcessorTestFixture, "Arrange bitlist with reorder true",
|
||||
"[.dataprocessor][.retrievebitlist]") {
|
||||
// parameters: num_samples, bitlist, expected_num_digital_bytes,
|
||||
// expected_digital_part
|
||||
auto parameters = GENERATE(
|
||||
std::make_tuple(5, std::vector<int>{1, 4, 5}, 3,
|
||||
std::vector<uint8_t>{0b00011111}),
|
||||
std::make_tuple(10, std::vector<int>{1, 4, 5}, 6,
|
||||
std::vector<uint8_t>{0xFF, 0b00000011}),
|
||||
std::make_tuple(8, std::vector<int>{1, 5, 3, 7, 8, 50, 42, 60, 39}, 9,
|
||||
std::vector<uint8_t>{0xFF}));
|
||||
|
||||
size_t num_samples, expected_num_digital_bytes;
|
||||
std::vector<uint8_t> expected_digital_part;
|
||||
std::vector<int> bitlist;
|
||||
std::tie(num_samples, bitlist, expected_num_digital_bytes,
|
||||
expected_digital_part) = parameters;
|
||||
|
||||
generaldata->SetCtbDbitList(bitlist);
|
||||
|
||||
generaldata->SetCtbDbitReorder(true);
|
||||
|
||||
set_num_samples(num_samples);
|
||||
set_data();
|
||||
|
||||
size_t expected_size =
|
||||
num_analog_bytes + num_transceiver_bytes + expected_num_digital_bytes;
|
||||
|
||||
// create expected data
|
||||
char *expected_data = new char[expected_size];
|
||||
|
||||
memset(expected_data, dummy_value, num_analog_bytes);
|
||||
|
||||
for (size_t sample = 0; sample < bitlist.size(); ++sample) {
|
||||
memcpy(expected_data + num_analog_bytes +
|
||||
expected_digital_part.size() * sample,
|
||||
expected_digital_part.data(), expected_digital_part.size());
|
||||
}
|
||||
|
||||
memset(expected_data + expected_num_digital_bytes + num_analog_bytes,
|
||||
dummy_value, num_transceiver_bytes);
|
||||
|
||||
size_t size = get_size();
|
||||
dataprocessor->ArrangeDbitData(size, data);
|
||||
|
||||
CHECK(size == expected_size);
|
||||
|
||||
CHECK(memcmp(data, expected_data, expected_size) == 0);
|
||||
|
||||
delete[] expected_data;
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(DataProcessorTestFixture,
|
||||
"Arrange bitlist and remove trailing bits",
|
||||
"[.dataprocessor][.retrievebitlist]") {
|
||||
|
||||
size_t num_random_offset_bytes = 3;
|
||||
std::vector<int> bitlist{1, 4, 5};
|
||||
|
||||
set_random_offset_bytes(num_random_offset_bytes);
|
||||
set_data();
|
||||
|
||||
generaldata->SetCtbDbitList(bitlist);
|
||||
|
||||
generaldata->SetCtbDbitReorder(false);
|
||||
|
||||
generaldata->SetCtbDbitOffset(num_random_offset_bytes);
|
||||
|
||||
std::vector<uint8_t> expected_digital_part{0b00000111};
|
||||
const size_t expected_num_digital_bytes = 5;
|
||||
|
||||
size_t expected_size =
|
||||
num_analog_bytes + num_transceiver_bytes + expected_num_digital_bytes;
|
||||
|
||||
// create expected data
|
||||
char *expected_data = new char[expected_size];
|
||||
|
||||
memset(expected_data, dummy_value, num_analog_bytes);
|
||||
|
||||
for (size_t sample = 0; sample < num_samples; ++sample) {
|
||||
memcpy(expected_data + num_analog_bytes +
|
||||
expected_digital_part.size() * sample,
|
||||
expected_digital_part.data(), expected_digital_part.size());
|
||||
}
|
||||
|
||||
memset(expected_data + expected_num_digital_bytes + num_analog_bytes,
|
||||
dummy_value, num_transceiver_bytes);
|
||||
|
||||
size_t size = get_size();
|
||||
dataprocessor->ArrangeDbitData(size, data);
|
||||
|
||||
CHECK(size == expected_size);
|
||||
|
||||
CHECK(memcmp(data, expected_data, expected_size) == 0);
|
||||
|
||||
delete[] expected_data;
|
||||
}
|
||||
|
||||
} // namespace sls
|
@ -410,6 +410,8 @@ enum detFuncs {
|
||||
F_RECEIVER_SET_TRANSCEIVER_MASK,
|
||||
F_RECEIVER_SET_ROW,
|
||||
F_RECEIVER_SET_COLUMN,
|
||||
F_GET_RECEIVER_DBIT_REORDER,
|
||||
F_SET_RECEIVER_DBIT_REORDER,
|
||||
|
||||
NUM_REC_FUNCTIONS
|
||||
};
|
||||
@ -816,7 +818,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_RECEIVER_SET_TRANSCEIVER_MASK: return "F_RECEIVER_SET_TRANSCEIVER_MASK";
|
||||
case F_RECEIVER_SET_ROW: return "F_RECEIVER_SET_ROW";
|
||||
case F_RECEIVER_SET_COLUMN: return "F_RECEIVER_SET_COLUMN";
|
||||
|
||||
case F_GET_RECEIVER_DBIT_REORDER: return "F_GET_RECEIVER_DBIT_REORDER";
|
||||
case F_SET_RECEIVER_DBIT_REORDER: return "F_SET_RECEIVER_DBIT_REORDER";
|
||||
|
||||
case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS";
|
||||
default: return "Unknown Function";
|
||||
|
@ -5,8 +5,8 @@
|
||||
#define APIRECEIVER "developer 0x241122"
|
||||
#define APICTB "developer 0x250310"
|
||||
#define APIGOTTHARD2 "developer 0x250310"
|
||||
#define APIMYTHEN3 "developer 0x250310"
|
||||
#define APIMOENCH "developer 0x250310"
|
||||
#define APIEIGER "developer 0x250310"
|
||||
#define APIXILINXCTB "developer 0x250311"
|
||||
#define APIJUNGFRAU "developer 0x250318"
|
||||
#define APIJUNGFRAU "developer 0x250318"
|
||||
#define APIMYTHEN3 "developer 0x250409"
|
||||
|
@ -4,7 +4,7 @@
|
||||
This file is used to start up simulators, receivers and run all the tests on them and finally kill the simulators and receivers.
|
||||
'''
|
||||
import argparse
|
||||
import os, sys, subprocess, time, colorama, signal
|
||||
import os, sys, subprocess, time, colorama
|
||||
|
||||
from colorama import Fore
|
||||
from slsdet import Detector, detectorType, detectorSettings
|
||||
@ -23,23 +23,9 @@ def Log(color, message):
|
||||
|
||||
|
||||
def checkIfProcessRunning(processName):
|
||||
cmd = "ps -ef | grep " + processName
|
||||
print(cmd)
|
||||
res=subprocess.getoutput(cmd)
|
||||
print(res)
|
||||
# eg. of output
|
||||
#l_user 250506 243295 0 14:38 pts/5 00:00:00 /bin/sh -c ps -ef | grep slsReceiver
|
||||
#l_user 250508 250506 0 14:38 pts/5 00:00:00 grep slsReceiver
|
||||
|
||||
print('how many')
|
||||
cmd = "ps -ef | grep " + processName + " | wc -l"
|
||||
print(cmd)
|
||||
res=subprocess.getoutput(cmd)
|
||||
print(res)
|
||||
|
||||
if res == '2':
|
||||
return False
|
||||
return True
|
||||
cmd = f"pgrep -f {processName}"
|
||||
res = subprocess.getoutput(cmd)
|
||||
return bool(res.strip())
|
||||
|
||||
|
||||
def killProcess(name):
|
||||
@ -52,7 +38,7 @@ def killProcess(name):
|
||||
print('process not running : ' + name)
|
||||
|
||||
|
||||
def killAllStaleProcesses():
|
||||
def killAllStaleProcesses(fp):
|
||||
killProcess('eigerDetectorServer_virtual')
|
||||
killProcess('jungfrauDetectorServer_virtual')
|
||||
killProcess('mythen3DetectorServer_virtual')
|
||||
@ -62,9 +48,9 @@ def killAllStaleProcesses():
|
||||
killProcess('xilinx_ctbDetectorServer_virtual')
|
||||
killProcess('slsReceiver')
|
||||
killProcess('slsMultiReceiver')
|
||||
cleanSharedmemory()
|
||||
cleanSharedmemory(fp)
|
||||
|
||||
def cleanup(name):
|
||||
def cleanup(name, fp):
|
||||
'''
|
||||
kill both servers, receivers and clean shared memory
|
||||
'''
|
||||
@ -72,9 +58,9 @@ def cleanup(name):
|
||||
killProcess(name + 'DetectorServer_virtual')
|
||||
killProcess('slsReceiver')
|
||||
killProcess('slsMultiReceiver')
|
||||
cleanSharedmemory()
|
||||
cleanSharedmemory(fp)
|
||||
|
||||
def cleanSharedmemory():
|
||||
def cleanSharedmemory(fp):
|
||||
Log(Fore.GREEN, 'Cleaning up shared memory...')
|
||||
try:
|
||||
p = subprocess.run(['sls_detector_get', 'free'], stdout=fp, stderr=fp)
|
||||
@ -87,8 +73,8 @@ def startProcessInBackground(name):
|
||||
# in background and dont print output
|
||||
p = subprocess.Popen(name.split(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, restore_signals=False)
|
||||
Log(Fore.GREEN, 'Starting up ' + name + ' ...')
|
||||
except:
|
||||
Log(Fore.RED, 'Could not start ' + name)
|
||||
except Exception as e:
|
||||
Log(Fore.RED, f'Could not start {name}:{e}')
|
||||
raise
|
||||
|
||||
def startServer(name):
|
||||
@ -139,14 +125,19 @@ def loadConfig(name, rx_hostname, settingsdir):
|
||||
def startCmdTests(name, fp, fname):
|
||||
Log(Fore.GREEN, 'Cmd Tests for ' + name)
|
||||
cmd = 'tests --abort [.cmdcall] -s -o ' + fname
|
||||
p = subprocess.run(cmd.split(), stdout=fp, stderr=fp, check=True, text=True)
|
||||
p.check_returncode()
|
||||
try:
|
||||
subprocess.run(cmd.split(), stdout=fp, stderr=fp, check=True, text=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
pass
|
||||
|
||||
with open (fname, 'r') as f:
|
||||
for line in f:
|
||||
if "FAILED" in line:
|
||||
msg = 'Cmd tests failed for ' + name + '!!!'
|
||||
sys.stdout = original_stdout
|
||||
Log(Fore.RED, msg)
|
||||
Log(Fore.RED, line)
|
||||
sys.stdout = fp
|
||||
raise Exception(msg)
|
||||
|
||||
Log(Fore.GREEN, 'Cmd Tests successful for ' + name)
|
||||
@ -154,14 +145,18 @@ def startCmdTests(name, fp, fname):
|
||||
def startGeneralTests(fp, fname):
|
||||
Log(Fore.GREEN, 'General Tests')
|
||||
cmd = 'tests --abort -s -o ' + fname
|
||||
p = subprocess.run(cmd.split(), stdout=fp, stderr=fp, check=True, text=True)
|
||||
p.check_returncode()
|
||||
try:
|
||||
subprocess.run(cmd.split(), stdout=fp, stderr=fp, check=True, text=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
pass
|
||||
|
||||
with open (fname, 'r') as f:
|
||||
for line in f:
|
||||
if "FAILED" in line:
|
||||
msg = 'General tests failed !!!'
|
||||
Log(Fore.RED, msg)
|
||||
sys.stdout = original_stdout
|
||||
Log(Fore.RED, msg + '\n' + line)
|
||||
sys.stdout = fp
|
||||
raise Exception(msg)
|
||||
|
||||
Log(Fore.GREEN, 'General Tests successful')
|
||||
@ -170,12 +165,10 @@ def startGeneralTests(fp, fname):
|
||||
|
||||
# parse cmd line for rx_hostname and settingspath using the argparse library
|
||||
parser = argparse.ArgumentParser(description = 'automated tests with the virtual detector servers')
|
||||
parser.add_argument('rx_hostname', help = 'hostname/ip of the current machine')
|
||||
parser.add_argument('settingspath', help = 'Relative or absolut path to the settingspath')
|
||||
parser.add_argument('rx_hostname', nargs='?', default='localhost', help = 'hostname/ip of the current machine')
|
||||
parser.add_argument('settingspath', nargs='?', default='../../settingsdir', help = 'Relative or absolut path to the settingspath')
|
||||
parser.add_argument('-s', '--servers', help='Detector servers to run', nargs='*')
|
||||
args = parser.parse_args()
|
||||
if args.rx_hostname == 'localhost':
|
||||
raise RuntimeException('Cannot use localhost for rx_hostname for the tests (fails for rx_arping for eg.)')
|
||||
|
||||
if args.servers is None:
|
||||
servers = [
|
||||
@ -203,46 +196,59 @@ Log(Fore.BLUE, '\nLog File: ' + fname)
|
||||
|
||||
with open(fname, 'w') as fp:
|
||||
|
||||
|
||||
|
||||
# general tests
|
||||
file_results = prefix_fname + '_results_general.txt'
|
||||
Log(Fore.BLUE, 'General tests (results: ' + file_results + ')')
|
||||
sys.stdout = fp
|
||||
sys.stderr = fp
|
||||
Log(Fore.BLUE, 'General tests (results: ' + file_results + ')')
|
||||
startGeneralTests(fp, file_results)
|
||||
|
||||
killAllStaleProcesses()
|
||||
try:
|
||||
startGeneralTests(fp, file_results)
|
||||
killAllStaleProcesses(fp)
|
||||
|
||||
for server in servers:
|
||||
try:
|
||||
# print to terminal for progress
|
||||
sys.stdout = original_stdout
|
||||
sys.stderr = original_stderr
|
||||
file_results = prefix_fname + '_results_cmd_' + server + '.txt'
|
||||
Log(Fore.BLUE, 'Cmd tests for ' + server + ' (results: ' + file_results + ')')
|
||||
sys.stdout = fp
|
||||
sys.stderr = fp
|
||||
Log(Fore.BLUE, 'Cmd tests for ' + server + ' (results: ' + file_results + ')')
|
||||
|
||||
# cmd tests for det
|
||||
cleanup(server)
|
||||
startServer(server)
|
||||
startReceiver(server)
|
||||
loadConfig(server, args.rx_hostname, args.settingspath)
|
||||
startCmdTests(server, fp, file_results)
|
||||
cleanup(server)
|
||||
except:
|
||||
Log(Fore.RED, 'Exception caught. Cleaning up.')
|
||||
cleanup(server)
|
||||
sys.stdout = original_stdout
|
||||
sys.stderr = original_stderr
|
||||
Log(Fore.RED, 'Cmd tests failed for ' + server + '!!!')
|
||||
raise
|
||||
testError = False
|
||||
for server in servers:
|
||||
try:
|
||||
# print to terminal for progress
|
||||
sys.stdout = original_stdout
|
||||
sys.stderr = original_stderr
|
||||
file_results = prefix_fname + '_results_cmd_' + server + '.txt'
|
||||
Log(Fore.BLUE, 'Cmd tests for ' + server + ' (results: ' + file_results + ')')
|
||||
sys.stdout = fp
|
||||
sys.stderr = fp
|
||||
Log(Fore.BLUE, 'Cmd tests for ' + server + ' (results: ' + file_results + ')')
|
||||
|
||||
# cmd tests for det
|
||||
cleanup(server, fp)
|
||||
startServer(server)
|
||||
startReceiver(server)
|
||||
loadConfig(server, args.rx_hostname, args.settingspath)
|
||||
startCmdTests(server, fp, file_results)
|
||||
cleanup(server, fp)
|
||||
|
||||
except Exception as e:
|
||||
# redirect to terminal
|
||||
sys.stdout = original_stdout
|
||||
sys.stderr = original_stderr
|
||||
Log(Fore.RED, f'Exception caught while testing {server}. Cleaning up...')
|
||||
testError = True
|
||||
break
|
||||
|
||||
# redirect to terminal
|
||||
sys.stdout = original_stdout
|
||||
sys.stderr = original_stderr
|
||||
if not testError:
|
||||
Log(Fore.GREEN, 'Passed all tests for virtual detectors \n' + str(servers))
|
||||
|
||||
|
||||
Log(Fore.GREEN, 'Passed all tests for virtual detectors \n' + str(servers))
|
||||
except Exception as e:
|
||||
# redirect to terminal
|
||||
sys.stdout = original_stdout
|
||||
sys.stderr = original_stderr
|
||||
Log(Fore.RED, f'Exception caught with general testing. Cleaning up...')
|
||||
cleanSharedmemory(sys.stdout)
|
||||
|
||||
|
||||
# redirect to terminal
|
||||
sys.stdout = original_stdout
|
||||
sys.stderr = original_stderr
|
||||
Log(Fore.GREEN, 'Passed all tests for virtual detectors \n' + str(servers) + '\nYayyyy! :) ')
|
@ -5,7 +5,12 @@ Script to update VERSION file with semantic versioning if provided as an argumen
|
||||
"""
|
||||
|
||||
import sys
|
||||
import re
|
||||
import os
|
||||
|
||||
from packaging.version import Version, InvalidVersion
|
||||
|
||||
|
||||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
def get_version():
|
||||
|
||||
@ -14,23 +19,24 @@ def get_version():
|
||||
return "0.0.0"
|
||||
|
||||
version = sys.argv[1]
|
||||
|
||||
# Validate that the version argument matches semantic versioning format (X.Y.Z)
|
||||
if not re.match(r'^\d+\.\d+\.\d+$', version):
|
||||
print("Error: Version argument must be in semantic versioning format (X.Y.Z)")
|
||||
|
||||
try:
|
||||
v = Version(version) # normalizcheck if version follows PEP 440 specification
|
||||
#replace -
|
||||
return version.replace("-", ".")
|
||||
except InvalidVersion as e:
|
||||
print(f"Invalid version {version}. Version format must follow semantic versioning format of python PEP 440 version identification specification.")
|
||||
sys.exit(1)
|
||||
|
||||
return version
|
||||
|
||||
|
||||
def write_version_to_file(version):
|
||||
with open("VERSION", "w") as version_file:
|
||||
version_file_path = os.path.join(SCRIPT_DIR, "VERSION")
|
||||
with open(version_file_path, "w") as version_file:
|
||||
version_file.write(version)
|
||||
print(f"Version {version} written to VERSION file.")
|
||||
|
||||
|
||||
# Main script
|
||||
if __name__ == "__main__":
|
||||
|
||||
version = get_version()
|
||||
write_version_to_file(version)
|
||||
write_version_to_file(version)
|
||||
|
Loading…
x
Reference in New Issue
Block a user