diff --git a/.gitea/workflows/rh8-local-tests.yml b/.gitea/workflows/rh8-local-tests.yml new file mode 100644 index 000000000..8865e43ce --- /dev/null +++ b/.gitea/workflows/rh8-local-tests.yml @@ -0,0 +1,62 @@ +name: Run Simulator Tests on local RHEL8 + +on: + push: + branches: + - developer + - main + - 'dev/*' + - '*.*.*.rc' + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Debug + + +jobs: + build: + runs-on: "detectors-software-RH8" + steps: + - uses: actions/checkout@v4 + + - name: Configure CMake + run: | + source /home/gitea_runner/.bashrc + conda activate det + cmake -B build \ + -DCMAKE_BUILD_TYPE=Debug \ + -DSLS_USE_TESTS=ON \ + -DSLS_USE_SIMULATOR=ON \ + -DSLS_USE_PYTHON=On \ + -DSLS_USE_HDF5=ON + + - name: Build + # Build your program with the given configuration + run: | + source /home/gitea_runner/.bashrc + conda activate det + cmake --build build -j4 --config Debug + + - name: Python unit tests with simulators + run: | + source /home/gitea_runner/.bashrc + conda activate det + export PYTHONPATH=$PWD/build/bin:$PYTHONPATH + export SLSDETNAME=gitea_runner_tests + python -m pytest -m detectorintegration python/tests --detector-integration + python -m pytest python/tests + + + - name: Simulator unit tests + run: | + source /home/gitea_runner/.bashrc + conda activate det + cd build/bin + python test_simulators.py -g + + - name: Run frame synchronizer tests + run: | + source /home/gitea_runner/.bashrc + conda activate det + cd build/bin + python test_frame_synchronizer.py diff --git a/.gitea/workflows/rh8-local.yml b/.gitea/workflows/rh8-local.yml index 02067f5bb..b129e2768 100644 --- a/.gitea/workflows/rh8-local.yml +++ b/.gitea/workflows/rh8-local.yml @@ -30,4 +30,5 @@ jobs: if: gitea.ref == 'refs/heads/developer' run: | sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH8 <<< $'put build/bin' - sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH8 <<< $'put pyctbgui' \ No newline at end of file + sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH8 <<< $'put pyctbgui' + sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH8 <<< $'put slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer' \ No newline at end of file diff --git a/.gitea/workflows/rh9-local-tests.yml b/.gitea/workflows/rh9-local-tests.yml new file mode 100644 index 000000000..4aa1a9f98 --- /dev/null +++ b/.gitea/workflows/rh9-local-tests.yml @@ -0,0 +1,53 @@ +name: Run Simulator Tests on local RHEL9 + +on: + push: + branches: + - developer + - main + - 'dev/*' + - '*.*.*.rc' + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Debug + + +jobs: + build: + runs-on: "detectors-software-RH9" + steps: + - uses: actions/checkout@v4 + + - name: Configure CMake + run: | + cmake -B build \ + -DCMAKE_BUILD_TYPE=Debug \ + -DSLS_USE_TESTS=ON \ + -DSLS_USE_SIMULATOR=ON \ + -DSLS_USE_PYTHON=On \ + -DPython_EXECUTABLE=/usr/bin/python3.13 \ + -DPython_INCLUDE_DIR=/usr/include/python3.13 \ + -DPython_LIBRARY=/usr/lib64/libpython3.13.so \ + -DSLS_USE_HDF5=ON + + - name: Build + # Build your program with the given configuration + run: cmake --build build -j4 --config Debug + + - name: Python unit tests with simulators + run: | + export PYTHONPATH=$PWD/build/bin:$PYTHONPATH + export SLSDETNAME=gitea_runner_tests + python3.13 -m pytest -m detectorintegration python/tests --detector-integration + python3.13 -m pytest python/tests + + - name: Simulator unit tests + run: | + cd build/bin + python3.13 test_simulators.py -g + + - name: Run frame synchronizer tests + run: | + cd build/bin + python3.13 test_frame_synchronizer.py diff --git a/.gitea/workflows/rh9-local.yml b/.gitea/workflows/rh9-local.yml index c282e4228..817fa11af 100644 --- a/.gitea/workflows/rh9-local.yml +++ b/.gitea/workflows/rh9-local.yml @@ -27,4 +27,5 @@ jobs: if: gitea.ref == 'refs/heads/developer' run: | sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH9 <<< $'put build/bin' - sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH9 <<< $'put pyctbgui' \ No newline at end of file + sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH9 <<< $'put pyctbgui' + sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH9 <<< $'put slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer' \ No newline at end of file diff --git a/.github/workflows/cmake.yaml b/.github/workflows/cmake.yaml index 32aba389c..a7a161c56 100644 --- a/.github/workflows/cmake.yaml +++ b/.github/workflows/cmake.yaml @@ -29,19 +29,20 @@ jobs: - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DSLS_USE_TESTS=ON -DSLS_USE_HDF5=ON -DSLS_USE_GUI=ON -DSLS_USE_MOENCH=ON -DSLS_USE_PYTHON=ON + run: | + cmake -B ${{github.workspace}}/build \ + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + -DSLS_USE_TESTS=ON \ + -DSLS_USE_SIMULATOR=ON \ + -DSLS_USE_PYTHON=ON \ + -DSLS_USE_HDF5=ON \ + -DSLS_USE_GUI=ON \ + -DSLS_USE_MOENCH=ON - name: Build # Build your program with the given configuration run: cmake --build ${{github.workspace}}/build -j4 --config ${{env.BUILD_TYPE}} - - name: C++ unit tests - working-directory: ${{github.workspace}}/build - run: ctest -C ${{env.BUILD_TYPE}} -j1 --rerun-failed --output-on-failure - - - name: Python unit tests - working-directory: ${{github.workspace}}/build/bin - run: | - python -m pytest ${{github.workspace}}/python/tests + diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml new file mode 100644 index 000000000..215efb8a3 --- /dev/null +++ b/.github/workflows/run_tests.yaml @@ -0,0 +1,57 @@ +name: Run Simulator Tests + +on: + push: + + + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Debug + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.12 + cache: 'pip' + - run: pip install pytest numpy colorama + + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: libhdf5-dev + version: 1.0 + + - name: Configure CMake + run: | + cmake -B ${{github.workspace}}/build \ + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + -DSLS_USE_TESTS=ON \ + -DSLS_USE_SIMULATOR=ON \ + -DSLS_USE_PYTHON=ON \ + -DSLS_USE_HDF5=ON + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build -j4 --config ${{env.BUILD_TYPE}} + + - name: Simulator unit tests + working-directory: ${{github.workspace}}/build/bin + run: | + python test_simulators.py --no-log-file --quiet --tests "[detectorintegration]~[disable_check_data_file]" + #remove --quiet to see more prints from simulator, receiver and tests + python test_frame_synchronizer.py + + + - name: Python unit tests with simulators + working-directory: ${{github.workspace}}/build/bin + run: | + python -m pytest -m detectorintegration ${{github.workspace}}/python/tests --detector-integration + python -m pytest ${{github.workspace}}/python/tests + + - name: C++ unit tests + working-directory: ${{github.workspace}}/build + run: ctest -C ${{env.BUILD_TYPE}} -j1 --rerun-failed --output-on-failure diff --git a/CMakeLists.txt b/CMakeLists.txt index 194a2abad..daffa4b67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,8 +40,6 @@ 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 @@ -200,8 +198,8 @@ option(SLS_USE_RECEIVER_BINARIES "Receiver binaries" ON) option(SLS_USE_GUI "GUI" OFF) option(SLS_USE_SIMULATOR "Simulator" OFF) option(SLS_USE_TESTS "TESTS" OFF) -option(SLS_USE_INTEGRATION_TESTS "Integration Tests" OFF) option(SLS_USE_SANITIZER "Sanitizers for debugging" OFF) +option(SLS_USE_SANITIZER_IN_SERVER "Sanitizers for debugging" OFF) option(SLS_USE_PYTHON "Python bindings" OFF) option(SLS_INSTALL_PYTHONEXT "Install the python extension in the install tree under CMAKE_INSTALL_PREFIX/python/" OFF) option(SLS_USE_CTBGUI "ctb GUI" OFF) @@ -292,6 +290,11 @@ if(NOT TARGET slsProjectOptions) target_compile_features(slsProjectOptions INTERFACE cxx_std_17) endif() +set(LOG_MAX_REPORTING_LEVEL sls::logINFO CACHE STRING "set logging level") +target_compile_definitions(slsProjectOptions + INTERFACE LOG_MAX_REPORTING_LEVEL=${LOG_MAX_REPORTING_LEVEL} +) + if (NOT TARGET slsProjectWarnings) add_library(slsProjectWarnings INTERFACE) target_compile_options(slsProjectWarnings INTERFACE @@ -344,6 +347,11 @@ if (NOT TARGET slsProjectCSettings) target_link_libraries(slsProjectCSettings INTERFACE Threads::Threads ) + + if(SLS_USE_SANITIZER_IN_SERVER) + target_compile_options(slsProjectCSettings INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer) + target_link_libraries(slsProjectCSettings INTERFACE -fsanitize=address,undefined) + endif() endif() @@ -400,10 +408,6 @@ if (SLS_USE_SIMULATOR) add_subdirectory(slsDetectorServers) endif (SLS_USE_SIMULATOR) -if (SLS_USE_INTEGRATION_TESTS) - add_subdirectory(integrationTests) -endif (SLS_USE_INTEGRATION_TESTS) - if (SLS_USE_PYTHON) find_package (Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED) set(PYBIND11_FINDPYTHON ON) # Needed for RH8 diff --git a/cmk.sh b/cmk.sh index dd58a37e1..498d590bd 100755 --- a/cmk.sh +++ b/cmk.sh @@ -250,7 +250,7 @@ fi #Tests if [ $TESTS -eq 1 ]; then - CMAKE_POST+=" -DSLS_USE_TESTS=ON -DSLS_USE_INTEGRATION_TESTS=ON" + CMAKE_POST+=" -DSLS_USE_TESTS=ON " echo "Tests Option enabled" fi diff --git a/docs/src/Testing.rst b/docs/src/Testing.rst new file mode 100644 index 000000000..515571788 --- /dev/null +++ b/docs/src/Testing.rst @@ -0,0 +1,166 @@ +Testing +========== + +We use ``catch2`` and ``pytest`` for unit testing the C++ and Python code. + +CATCH2 Tests +---------------- + +To build and run the catch2 tests use the following commands: + +.. code-block:: console + + cd build + cmake -DSLS_USE_TESTS=ON ../ + bin/tests + +Note that this requires that you have catch2 installed on your system. + +Naming Policy: +----------------- + +Per default all tests should be visible to catch2. + +If a test fails in the github or gitea actions hide the test by adding the tag ``[.]`` to the test name. + +.. code-block:: cpp + + TEST_CASE("This test is hidden from default runs", "[.]") { + REQUIRE(1 == 2); + } + +You can run all tests requiring a detector by running the following command: + +.. code-block:: console + + tests "[.detectorintegration]" + + +.. note :: + + This only works if a configured simulator (or an actual configured detector) and receiver are already set up to run the tests. There is a script that automatically sets up virtual detectors and runs all integration tests. See Section :ref:`Simulator Script. ` below. + + +If you want to disable testing that involves a data file that require pc tuning optimizations, add the hidden tag ``[.disable_check_data_file]`` to the test case. Please note that only some specific disable tests have been implemented so far. + +.. code-block:: console + + tests "[detectorintegration]~[disable_check_data_file]" + +.. note :: + + Ensure that there are no spaces betweent the tags and no '.', else hardly any test will be matched. + +.. _python simulator script: + +Simulator Script: +----------------- + +One can also just run the following script, which will run your tests for all the detector types (simulators only) with a pre-determined configuration. + +.. code-block:: console + + cd build + python bin/test_simulators.py + +This runs all tests marked with the tag ``[.detectorintegration]`` for all detector simulators. +If you want to run them for a specific virtual detector or a specific test use the following command: + +.. code-block:: console + cd build + python bin/test_simulators.py --servers jungfrau --test "[.rx]" + +You can exclude specific tests by adding the option ``~[]``. Again, we assume that this marker is added to the tests that you want to exclude. + +.. code-block:: console + cd build + python bin/test_simulators.py --servers eiger jungfrau moench --test "[detectorintegration]~[disable_check_data_file]" + +You can additionally run all the tests not requiring detectors using the script ``bin/test_simulators.py`` by passing the option ``--general-tests``. + +One can use ``--no-log-file`` if you dont want to create a log files and instead print to console. If you prefer to not print to console either, add ``--quiet``. + + +Pytest Tests +----------------- + +To run the python tests use the following commands: + +.. code-block:: console + + cd build + cmake ../ -DSLS_USE_PYTHON=ON + export PYTHONPATH=$PWD/bin + python -m pytest ../python/tests/ + +If a test requires a detector mark them with the pytest marker ``@pytest.mark.detectorintegration``. + +To run only tests requiring virtual detectors use the following command: + +.. code-block:: console + #in build + python -m pytest -m detectorintegration ../python/tests/ + +There is a helper test fixture in ``slsDetectorSoftware/python/tests/conftest.py`` called ``test_with_simulators`` that sets up virtual detectors and yields the test for all detectors. The set up is done for every test automatically. + +Example usage: + +.. code-block:: python + + import pytest + + @pytest.mark.detectorintegration + def test_example_with_simulator(test_with_simulators): + # your test code here + +If you want to run the test only for a specific test use the parametrized test fixture: + +Example usage: + +.. code-block:: python + + import pytest + + @pytest.mark.detectorintegration + @pytest.mark.parametrize("setup_parameters", [([""], )], indirect=True) + def test_example_with_specific_simulators(test_with_simulators, setup_parameters): + # your test code here + + +There is another helper test fixture in ``slsDetectorSoftware/python/tests/conftest.py`` called ``session_simulator`` that sets up virtual detectors and yields the test for all detectors. The difference with the previous fixture ``test_with_simulators`` is that this fixture will set up one detector at a time and run all the tests using this fixture before cleaning up and moving on to the next detector. It saves time if the setup and cleanup is expensive. + +Example usage: + +.. code-block:: python + + import pytest + + @pytest.mark.detectorintegration + def test_define_reg(session_simulator, request): + """ Test setting define_reg for ctb and xilinx_ctb.""" + det_type, num_interfaces, num_mods, d = session_simulator + assert d is not None + + from slsdet import RegisterAddress + + if det_type in ['ctb', 'xilinx_ctb']: + # your test code here + +For more specific parameters, you can parametrize the fixture like below: + +.. code-block:: python + + import pytest + + @pytest.mark.detectorintegration + @pytest.mark.parametrize( + "session_simulator", + [ + ("ctb", 1, 1), + ("xilinx_ctb", 1, 1), + ], + indirect=True, + ) + def test_define_reg(session_simulator): + det_type, num_interfaces, num_mods, d = session_simulator + # your test code here diff --git a/docs/src/index.rst b/docs/src/index.rst index 4ba406a17..d62597601 100644 --- a/docs/src/index.rst +++ b/docs/src/index.rst @@ -66,6 +66,7 @@ slsDetectorPackage container_utils type_traits ToString + Testing .. toctree:: :caption: Firmware diff --git a/integrationTests/CMakeLists.txt b/integrationTests/CMakeLists.txt deleted file mode 100755 index a270593fe..000000000 --- a/integrationTests/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: LGPL-3.0-or-other -# Copyright (C) 2021 Contributors to the SLS Detector Package -# MESSAGE( STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR} ) -# MESSAGE( STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR} ) - - - -# include_directories( -# ${PROJECT_SOURCE_DIR}/catch -# ) - -# target_sources(tests PRIVATE -# ${CMAKE_CURRENT_SOURCE_DIR}/test-integrationMulti.cpp -# ${CMAKE_CURRENT_SOURCE_DIR}/test-integrationDectector.cpp -# ${CMAKE_CURRENT_SOURCE_DIR}/test-eigerIntegration.cpp -# ) - -# if(SLS_USE_TESTS) -# set(TEST_SOURCES -# src/test-slsDetector.cpp -# src/test.cpp -# ) -# add_executable(detector_test ${TEST_SOURCES}) - -# target_link_libraries(detector_test -# slsDetectorShared -# slsProjectOptions -# slsProjectWarnings -# slsSupportLib -# pthread -# rt -# ) -# set_target_properties(detector_test PROPERTIES -# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin -# ) - - - -# endif() - diff --git a/integrationTests/test-eigerIntegration.cpp b/integrationTests/test-eigerIntegration.cpp deleted file mode 100644 index 6fa4124d2..000000000 --- a/integrationTests/test-eigerIntegration.cpp +++ /dev/null @@ -1,204 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-other -// Copyright (C) 2021 Contributors to the SLS Detector Package -#include "DetectorImpl.h" -#include "catch.hpp" -#include "sls/string_utils.h" -#include "tests/globals.h" -#include - -namespace sls { - -class MultiDetectorFixture { - protected: - DetectorImpl d; - - public: - MultiDetectorFixture() : d(0, true, true) { - d.setHostname(test::hostname.c_str()); - if (test::my_ip != "undefined") - d.setReceiverHostname(test::my_ip); - } - ~MultiDetectorFixture() { d.freeSharedMemory(); } -}; - -TEST_CASE_METHOD(MultiDetectorFixture, "Set and get dacs", - "[.eigerintegration][cli]") { - auto th = 1000; - - // set and read back each individual dac of EIGER - d.setDAC(0, di::SVP, 0); - CHECK(d.setDAC(-1, di::SVP, 0) == 0); - d.setDAC(4000, di::SVN, 0); - CHECK(d.setDAC(-1, di::SVN, 0) == 4000); - d.setDAC(2000, di::VTR, 0); - CHECK(d.setDAC(-1, di::VTR, 0) == 2000); - d.setDAC(3500, di::VRF, 0); - CHECK(d.setDAC(-1, di::VRF, 0) == 3500); - d.setDAC(1400, di::VRS, 0); - CHECK(d.setDAC(-1, di::VRS, 0) == 1400); - d.setDAC(2556, di::VTGSTV, 0); - CHECK(d.setDAC(-1, di::VTGSTV, 0) == 2556); - d.setDAC(1500, di::VCMP_LL, 0); - CHECK(d.setDAC(-1, di::VCMP_LL, 0) == 1500); - d.setDAC(1400, di::VCMP_LR, 0); - CHECK(d.setDAC(-1, di::VCMP_LR, 0) == 1400); - d.setDAC(4000, di::CAL, 0); - CHECK(d.setDAC(-1, di::CAL, 0) == 4000); - d.setDAC(1300, di::VCMP_RL, 0); - CHECK(d.setDAC(-1, di::VCMP_RL, 0) == 1300); - d.setDAC(1200, di::VCMP_RR, 0); - CHECK(d.setDAC(-1, di::VCMP_RR, 0) == 1200); - d.setDAC(1100, di::RXB_RB, 0); - CHECK(d.setDAC(-1, di::RXB_RB, 0) == 1100); - d.setDAC(1100, di::RXB_LB, 0); - CHECK(d.setDAC(-1, di::RXB_LB, 0) == 1100); - d.setDAC(1500, di::VCP, 0); - CHECK(d.setDAC(-1, di::VCP, 0) == 1500); - d.setDAC(2000, di::VCN, 0); - CHECK(d.setDAC(-1, di::VCN, 0) == 2000); - d.setDAC(1550, di::VIS, 0); - CHECK(d.setDAC(-1, di::VIS, 0) == 1550); - d.setDAC(660, di::IO_DELAY, 0); - CHECK(d.setDAC(-1, di::IO_DELAY, 0) == 660); - - // setting threshold sets all individual vcmp - d.setDAC(th, di::THRESHOLD, 0); - CHECK(d.setDAC(-1, di::THRESHOLD, 0) == th); - CHECK(d.setDAC(-1, di::VCMP_LL, 0) == th); - CHECK(d.setDAC(-1, di::VCMP_LR, 0) == th); - CHECK(d.setDAC(-1, di::VCMP_RL, 0) == th); - CHECK(d.setDAC(-1, di::VCMP_RR, 0) == th); - - // different values gives -1 - if (d.getNumberOfDetectors() > 1) { - d.setDAC(1600, di::VCMP_LL, 0, 0); - d.setDAC(1700, di::VCMP_LL, 0, 1); - CHECK(d.setDAC(-1, di::VCMP_LL, 0, 0) == 1600); - CHECK(d.setDAC(-1, di::VCMP_LL, 0, 1) == 1700); - CHECK(d.setDAC(-1, di::VCMP_LL, 0) == -1); - CHECK(d.setDAC(-1, di::THRESHOLD, 0) == -1); - CHECK(d.setDAC(-1, di::THRESHOLD, 0, 0) == -1); - CHECK(d.setDAC(-1, di::THRESHOLD, 0, 1) == -1); - } -} - -TEST_CASE_METHOD(MultiDetectorFixture, "Read temperatures", - "[.eigerintegration][cli]") { - std::vector tempindex{di::TEMPERATURE_FPGA, di::TEMPERATURE_FPGA2, - di::TEMPERATURE_FPGA3}; - for (auto index : tempindex) { - for (int i = 0; i != d.getNumberOfDetectors(); ++i) { - double temp = static_cast(d.getADC(index, 0)) / 1000; - CHECK(temp > 20); - CHECK(temp < 60); - } - } -} - -int to_time(uint32_t reg) { - uint32_t clocks = reg >> 3; - uint32_t exponent = (reg & 0b111) + 1; - return clocks * pow(10, exponent); -} - -TEST_CASE_METHOD(MultiDetectorFixture, "Read/write register", - "[.eigerintegration][cli]") { - d.setNumberOfFrames(1); - d.setExposureTime(10000); - d.acquire(); - CHECK(to_time(d.readRegister(0x4, 0)) == 10000); - - d.writeRegister(0x4, 500); - CHECK(d.readRegister(0x4) == 500); -} - -TEST_CASE_METHOD(MultiDetectorFixture, "Set dynamic range", - "[.eigerintegration][cli][dr]") { - std::vector dynamic_range{4, 8, 16, 32}; - for (auto dr : dynamic_range) { - d.setDynamicRange(dr); - CHECK(d.setDynamicRange() == dr); - } -} - -TEST_CASE_METHOD(MultiDetectorFixture, "Set clock divider", - "[.eigerintegration][cli][this]") { - for (int i = 0; i != 3; ++i) { - d.setSpeed(sv::CLOCK_DIVIDER, i); - CHECK(d.setSpeed(sv::CLOCK_DIVIDER) == i); - } -} - -TEST_CASE_METHOD(MultiDetectorFixture, "Get time left", - "[.eigerintegration][cli]") { - CHECK_THROWS(d.getTimeLeft(ti::PROGRESS)); -} - -TEST_CASE_METHOD(MultiDetectorFixture, "Get ID", "[.eigerintegration][cli]") { - std::string hn = test::hostname; - hn.erase(std::remove(begin(hn), end(hn), 'b'), end(hn)); - hn.erase(std::remove(begin(hn), end(hn), 'e'), end(hn)); - auto hostnames = split(hn, '+'); - CHECK(hostnames.size() == d.getNumberOfDetectors()); - for (int i = 0; i != d.getNumberOfDetectors(); ++i) { - CHECK(d.getId(defs::DETECTOR_SERIAL_NUMBER, 0) == - std::stoi(hostnames[0])); - } -} - -TEST_CASE_METHOD(MultiDetectorFixture, "Lock server", - "[.eigerintegration][cli]") { - - d.lockServer(1); - CHECK(d.lockServer() == 1); - d.lockServer(0); - CHECK(d.lockServer() == 0); -} - -TEST_CASE_METHOD(MultiDetectorFixture, "Settings", "[.eigerintegration][cli]") { - CHECK(d.setSettings(defs::STANDARD) == defs::STANDARD); -} - -TEST_CASE_METHOD(MultiDetectorFixture, "Set readout flags", - "[.eigerintegration][cli]") { - d.setReadOutFlags(defs::PARALLEL); - CHECK((d.setReadOutFlags() & defs::PARALLEL)); - - d.setReadOutFlags(defs::NONPARALLEL); - CHECK_FALSE((d.setReadOutFlags() & defs::PARALLEL)); - CHECK((d.setReadOutFlags() & defs::NONPARALLEL)); -} - -// TEST_CASE_METHOD(MultiDetectorFixture, "Flow control and tengiga", -// "[.eigerintegration][cli]") { -// d.setFlowControl10G(1); -// CHECK(d.setFlowControl10G() == 1); -// d.setFlowControl10G(0); -// CHECK(d.setFlowControl10G() == 0); - -// d.enableTenGigabitEthernet(1); -// CHECK(d.enableTenGigabitEthernet() == 1); -// d.enableTenGigabitEthernet(0); -// CHECK(d.enableTenGigabitEthernet() == 0); -// } - -TEST_CASE_METHOD(MultiDetectorFixture, "activate", "[.eigerintegration][cli]") { - d.activate(0); - CHECK(d.activate() == 0); - d.activate(1); - CHECK(d.activate() == 1); -} - -TEST_CASE_METHOD(MultiDetectorFixture, "all trimbits", - "[.eigerintegration][cli]") { - d.setAllTrimbits(32); - CHECK(d.setAllTrimbits(-1) == 32); -} - -TEST_CASE_METHOD(MultiDetectorFixture, "rate correction", - "[.eigerintegration][cli]") { - d.setRateCorrection(200); - CHECK(d.getRateCorrection() == 200); -} - -} // namespace sls diff --git a/integrationTests/test-integrationDectector.cpp b/integrationTests/test-integrationDectector.cpp deleted file mode 100644 index c02066513..000000000 --- a/integrationTests/test-integrationDectector.cpp +++ /dev/null @@ -1,522 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-other -// Copyright (C) 2021 Contributors to the SLS Detector Package - -#include "catch.hpp" - -#include "DetectorImpl.h" -#include "Module.h" -#include "sls/ClientSocket.h" -#include "sls/logger.h" -#include "sls/sls_detector_defs.h" - -#include "sls/Timer.h" -#include "sls/sls_detector_funcs.h" -#include -#include -#define VERBOSE - -// Header holding all configurations for different detectors -#include "tests/config.h" -#include "tests/globals.h" -// using namespace test; -// using dt = slsDetectorDefs::detectorType; -// extern std::string hostname; -// extern std::string detector_type; -// extern dt type; - -namespace sls { - -TEST_CASE("Single detector no receiver", "[.integration][.single]") { - auto t = Module::getTypeFromDetector(test::hostname); - CHECK(t == test::type); - - Module d(t); - CHECK(d.getDetectorTypeAsEnum() == t); - CHECK(d.getDetectorTypeAsString() == test::detector_type); - - d.setHostname(test::hostname); - CHECK(d.getHostname() == test::hostname); - - CHECK(d.setDetectorType() == test::type); - - d.freeSharedMemory(); -} - -TEST_CASE("Set control port then create a new object with this control port", - "[.integration][.single]") { - /* - TODO! - Standard port but should not be hardcoded - Is this the best way to initialize the detectors - Using braces to make the object go out of scope - */ - int old_cport = DEFAULT_TCP_CNTRL_PORTNO; - int old_sport = DEFAULT_TCP_STOP_PORTNO; - int new_cport = 1993; - int new_sport = 2000; - { - Module d(test::type); - d.setHostname(test::hostname); - CHECK(d.getControlPort() == old_cport); - d.setControlPort(new_cport); - CHECK(d.getStopPort() == old_sport); - d.setStopPort(new_sport); - d.freeSharedMemory(); - } - { - Module d(test::type); - d.setHostname(test::hostname); - d.setControlPort(new_cport); - d.setStopPort(new_sport); - CHECK(d.getControlPort() == new_cport); - CHECK(d.getStopPort() == new_sport); - - // Reset standard ports - d.setControlPort(old_cport); - d.setStopPort(old_sport); - d.freeSharedMemory(); - } - - Module d(test::type); - d.setHostname(test::hostname); - CHECK(d.getStopPort() == DEFAULT_TCP_STOP_PORTNO); - d.freeSharedMemory(); -} - -TEST_CASE("single EIGER detector no receiver basic set and get", - "[.integration][eiger]") { - // TODO! this test should take command line arguments for config - SingleDetectorConfig c; - - // Read type by connecting to the detector - auto type = Module::getTypeFromDetector(c.hostname); - CHECK(type == c.type_enum); - - // Create Module of said type and set hostname and detector online - Module d(type); - CHECK(d.getDetectorTypeAsEnum() == type); - CHECK(d.getDetectorTypeAsString() == c.type_string); - - d.setHostname(c.hostname); - CHECK(d.getHostname() == c.hostname); - - CHECK(d.getUseReceiverFlag() == false); - CHECK_NOTHROW(d.checkDetectorVersionCompatibility()); - - // Setting and reading exposure time - auto t = 1000000000; - d.setExptime(t); - CHECK(d.getExptime() == t); - - // size of an eiger half module with and without gap pixels - CHECK(d.getTotalNumberOfChannels() == 256 * 256 * 4); - CHECK(d.getTotalNumberOfChannels(slsDetectorDefs::dimension::X) == 1024); - CHECK(d.getTotalNumberOfChannels(slsDetectorDefs::dimension::Y) == 256); - // CHECK(d.getTotalNumberOfChannels(slsDetectorDefs::dimension::Z) == 1); - CHECK(d.getTotalNumberOfChannelsInclGapPixels( - slsDetectorDefs::dimension::X) == 1024); - CHECK(d.getTotalNumberOfChannelsInclGapPixels( - slsDetectorDefs::dimension::Y) == 256); - // CHECK(d.getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::dimension::Z) - // == 1); - - CHECK(d.getNChans() == 256 * 256); - CHECK(d.getNChans(slsDetectorDefs::dimension::X) == 256); - CHECK(d.getNChans(slsDetectorDefs::dimension::Y) == 256); - // CHECK(d.getNChans(slsDetectorDefs::dimension::Z) == 1); - - CHECK(d.getNChips() == 4); - CHECK(d.getNChips(slsDetectorDefs::dimension::X) == 4); - CHECK(d.getNChips(slsDetectorDefs::dimension::Y) == 1); - // CHECK(d.getNChips(slsDetectorDefs::dimension::Z) == 1); - - d.freeSharedMemory(); -} - -TEST_CASE("Locking mechanism and last ip", "[.integration][.single]") { - Module d(test::type); - d.setHostname(test::hostname); - - // Check that detector server is unlocked then lock - CHECK(d.lockServer() == 0); - d.lockServer(1); - CHECK(d.lockServer() == 1); - - // Can we still access the detector while it's locked - auto t = 1300000000; - d.setExptime(t); - CHECK(d.getExptime() == t); - - // unlock again and free - d.lockServer(0); - CHECK(d.lockServer() == 0); - - CHECK(d.getLastClientIP() == test::my_ip); - d.freeSharedMemory(); -} - -TEST_CASE("Set settings", "[.integration][.single]") { - Module d(test::type); - d.setHostname(test::hostname); - CHECK(d.setSettings(defs::STANDARD) == defs::STANDARD); -} - -TEST_CASE("Timer functions", "[.integration][cli]") { - // FRAME_NUMBER, /**< number of real time frames: total number of - // acquisitions is number or frames*number of triggers */ ACQUISITION_TIME, - // /**< exposure time */ FRAME_PERIOD, /**< period between exposures */ - // DELAY_AFTER_TRIGGER, /**< delay between trigger and start of exposure or - // readout (in triggered mode) */ GATES_NUMBER, /**< number of gates per - // frame (in gated mode) */ TRIGGER_NUMBER, /**< number of triggers: total - // number of acquisitions is number or frames*number of triggers */ - // ACTUAL_TIME, /**< Actual time of the detector's internal timer */ - // MEASUREMENT_TIME, /**< Time of the measurement from the detector (fifo) - // */ - - // PROGRESS, /**< fraction of measurement elapsed - only get! */ - // MEASUREMENTS_NUMBER, - // FRAMES_FROM_START, - // FRAMES_FROM_START_PG, - // SAMPLES, - // SUBFRAME_ACQUISITION_TIME, /**< subframe exposure time */ - // STORAGE_CELL_NUMBER, /** list = m.getReceiverDbitList(); - list.clear(); - for (int i = 0; i < 10; ++i) - list.push_back(i); - m.setReceiverDbitList(list); - - CHECK(m.getReceiverDbitList().size() == 10); - - list.push_back(64); - CHECK_THROWS_AS(m.setReceiverDbitList(list), RuntimeError); - CHECK_THROWS_WITH(m.setReceiverDbitList(list), - Catch::Matchers::Contains("be between 0 and 63")); - - list.clear(); - for (int i = 0; i < 65; ++i) - list.push_back(i); - CHECK(list.size() == 65); - CHECK_THROWS_WITH(m.setReceiverDbitList(list), - Catch::Matchers::Contains("be greater than 64")); - - list.clear(); - m.setReceiverDbitList(list); - CHECK(m.getReceiverDbitList().empty()); - - // adcinvert - m.setADCInvert(0); - CHECK(m.getADCInvert() == 0); - m.setADCInvert(5); - CHECK(m.getADCInvert() == 5); - m.setADCInvert(-1); - CHECK(m.getADCInvert() == -1); - - // ext sampling reg - m.setExternalSamplingSource(0); - CHECK(m.getExternalSamplingSource() == 0); - m.setExternalSamplingSource(62); - CHECK(m.getExternalSamplingSource() == 62); - CHECK_THROWS_WITH(m.setExternalSamplingSource(64), - Catch::Matchers::Contains("be 0-63")); - CHECK(m.getExternalSamplingSource() == 62); - m.setExternalSampling(1); - CHECK(m.getExternalSampling() == 1); - m.setExternalSampling(0); - CHECK(m.getExternalSampling() == 0); - m.setExternalSampling(1); - CHECK(m.getExternalSampling() == 1); - CHECK(m.readRegister(0x7b) == 0x1003E); -} - -TEST_CASE("Eiger or Jungfrau nextframenumber", - "[.eigerintegration][.jungfrauintegration][nextframenumber]") { - SingleDetectorConfig c; - - // pick up multi detector from shm id 0 - DetectorImpl m(0); - - // ensure ctb detector type, hostname and online - REQUIRE( - ((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER) || - (m.getDetectorTypeAsEnum() == - slsDetectorDefs::detectorType::JUNGFRAU))); - REQUIRE(m.getHostname() == c.hostname); - - CHECK(m.setNumberOfFrames(1) == 1); - - // starting fnum - uint64_t val = 8; - - m.setNextFrameNumber(val); - CHECK(m.getNextFrameNumber() == val); - CHECK(m.acquire() == slsDetectorDefs::OK); - CHECK(m.getReceiverCurrentFrameIndex() == val); - - ++val; - CHECK(m.acquire() == slsDetectorDefs::OK); - CHECK(m.getReceiverCurrentFrameIndex() == val); - - CHECK_THROWS_AS(m.setNextFrameNumber(0), RuntimeError); - - if (m.getDetectorTypeAsString() == "Eiger") { - val = 281474976710655; - } else if (m.getDetectorTypeAsString() == "Jungfrau") { - val = 18446744073709551615; - } - m.setNextFrameNumber(val); - CHECK(m.getNextFrameNumber() == val); - CHECK(m.acquire() == slsDetectorDefs::OK); - CHECK(m.getReceiverCurrentFrameIndex() == val); - CHECK(m.getNextFrameNumber() == (val + 1)); -} - -TEST_CASE("Eiger partialread", "[.eigerintegration][partialread]") { - SingleDetectorConfig c; - - // pick up multi detector from shm id 0 - DetectorImpl m(0); - - // ensure detector type, hostname - REQUIRE( - (m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER)); - REQUIRE(m.getHostname() == c.hostname); - - m.setDynamicRange(16); - m.enableTenGigabitEthernet(0); - m.setPartialReadout(256); - CHECK(m.getPartialReadout() == 256); - m.setPartialReadout(1); - CHECK(m.getPartialReadout() == 1); - - m.setDynamicRange(8); - m.setPartialReadout(256); - CHECK(m.getPartialReadout() == 256); - CHECK_THROWS_AS(m.setPartialReadout(1), RuntimeError); - CHECK(m.getPartialReadout() == 256); - CHECK_THROWS_AS(m.setPartialReadout(0), RuntimeError); - m.setPartialReadout(256); -} - -} // namespace sls diff --git a/integrationTests/test-integrationMulti.cpp b/integrationTests/test-integrationMulti.cpp deleted file mode 100644 index 40f77c6dd..000000000 --- a/integrationTests/test-integrationMulti.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-other -// Copyright (C) 2021 Contributors to the SLS Detector Package -#include "DetectorImpl.h" -#include "catch.hpp" -#include "sls/string_utils.h" -#include "tests/globals.h" -#include - -namespace sls { - -using namespace Catch::literals; - -TEST_CASE("Initialize a multi detector", "[.integration][.multi]") { - auto hostnames = split(test::hostname, '+'); - - DetectorImpl d(0, true, true); - d.setHostname(test::hostname.c_str()); - - CHECK(d.getHostname() == test::hostname); - for (size_t i = 0; i != hostnames.size(); ++i) { - CHECK(d.getHostname(i) == hostnames[i]); - } - - CHECK(d.getDetectorTypeAsEnum() == test::type); - CHECK(d.getDetectorTypeAsString() == test::detector_type); - - CHECK(d.getNumberOfDetectors() == hostnames.size()); - d.freeSharedMemory(); -} - -TEST_CASE("Set and read timers", "[.integration][.multi]") { - - DetectorImpl d(0, true, true); - d.setHostname(test::hostname.c_str()); - - // FRAME_NUMBER - int n_frames = 3; - d.setNumberOfFrames(n_frames); - CHECK(d.setNumberOfFrames() == n_frames); - - // ACQUISITION_TIME - double exptime = 0.3; - d.setExposureTime(exptime, true); - CHECK(d.setExposureTime(-1, true) == Approx(exptime)); - CHECK(d.setExposureTime(-1) == Approx(exptime * 1E9)); - - // FRAME_PERIOD, - double period = 0.5; - d.setExposurePeriod(period, true); - CHECK(d.setExposurePeriod(-1, true) == Approx(period)); - CHECK(d.setExposurePeriod(-1) == Approx(period * 1E9)); - - // DELAY_AFTER_TRIGGER, - // GATES_NUMBER, - // TRIGGER_NUMBER, - // ACTUAL_TIME - // MEASUREMENT_TIME - - // PROGRESS, /**< fraction of measurement elapsed - only get! */ - // MEASUREMENTS_NUMBER, - - // FRAMES_FROM_START, - // FRAMES_FROM_START_PG, - // SAMPLES, - - // SUBFRAME_ACQUISITION_TIME, /**< subframe exposure time */ - double subframe_exposure = 2000000; // ns - if (test::type == dt::EIGER) { - d.setSubFrameExposureTime(subframe_exposure); - CHECK(d.setSubFrameExposureTime(-1) == Approx(subframe_exposure)); - } - - // STORAGE_CELL_NUMBER, /**> iBit) & 1 @@ -152,18 +150,14 @@ class SignalsTab(QtWidgets.QWidget): 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_dbitreorder, self.rx_dbitlist, isPlottedArray, + digital_array = self._processWaveformData(data, aSamples, dSamples, self.rx_dbitreorder, self.rx_dbitlist, self.mainWindow.romode.value, self.mainWindow.nADCEnabled) irow = 0 for idx, i in enumerate(self.rx_dbitlist): - # bits enabled but not plotting waveform = digital_array[idx, :] - if np.isnan(waveform[0]): - continue self.mainWindow.digitalPlots[i].setData(waveform) plotName = getattr(self.view, f"labelBIT{i}").text() waveforms[plotName] = waveform @@ -173,7 +167,9 @@ class SignalsTab(QtWidgets.QWidget): irow += 1 else: self.mainWindow.digitalPlots[i].setY(0) - + + self.updatePlotRange() # Call after all data is set + return waveforms @@ -215,11 +211,11 @@ class SignalsTab(QtWidgets.QWidget): self.mainWindow.nDBitEnabled = len(list(retval)) for i in range(Defines.signals.count): self.getDigitalBitEnable(i, retval) - self.getEnableBitPlot(i) + self.EnableBitPlot(i) self.getEnableBitColor(i) self.plotTab.addSelectedDigitalPlots(i) self.getDigitalBitEnableRange(retval) - self.getEnableBitPlotRange() + self.EnableBitPlotRange() def setDigitalBitEnable(self, i): bitList = self.det.rx_dbitlist @@ -257,21 +253,29 @@ class SignalsTab(QtWidgets.QWidget): self.updateDigitalBitEnable() - def getEnableBitPlot(self, i): + def EnableBitPlot(self, i): + """ enables plot check box if bit is enabled, otherwise unchecks and disables plot check box """ + checkBox = getattr(self.view, f"checkBoxBIT{i}DB") checkBoxPlot = getattr(self.view, f"checkBoxBIT{i}Plot") + if(checkBoxPlot.isChecked()): + checkBoxPlot.setChecked(checkBox.isChecked()) + checkBoxPlot.setEnabled(checkBox.isChecked()) - def setEnableBitPlot(self, i): + def setBitPlot(self, i): + """ sets plot check box e.g. adds plots to plot tab """ pushButton = getattr(self.view, f"pushButtonBIT{i}") checkBox = getattr(self.view, f"checkBoxBIT{i}Plot") pushButton.setEnabled(checkBox.isChecked()) - self.getEnableBitPlotRange() + self.EnableBitPlotRange() self.plotTab.addSelectedDigitalPlots(i) self.updateLegend() + self.updatePlotRange() + - def getEnableBitPlotRange(self): + def EnableBitPlotRange(self): self.view.checkBoxBIT0_31Plot.stateChanged.disconnect() self.view.checkBoxBIT32_63Plot.stateChanged.disconnect() self.view.checkBoxBIT0_31Plot.setEnabled( @@ -286,12 +290,12 @@ class SignalsTab(QtWidgets.QWidget): all( getattr(self.view, f"checkBoxBIT{i}Plot").isChecked() for i in range(Defines.signals.half, Defines.signals.count))) - self.view.checkBoxBIT0_31Plot.stateChanged.connect(partial(self.setEnableBitPlotRange, 0, + self.view.checkBoxBIT0_31Plot.stateChanged.connect(partial(self.setBitPlotRange, 0, Defines.signals.half)) self.view.checkBoxBIT32_63Plot.stateChanged.connect( - partial(self.setEnableBitPlotRange, Defines.signals.half, Defines.signals.count)) + partial(self.setBitPlotRange, Defines.signals.half, Defines.signals.count)) - def setEnableBitPlotRange(self, start_nr, end_nr): + def setBitPlotRange(self, start_nr, end_nr): checkBox = getattr(self.view, f"checkBoxBIT{start_nr}_{end_nr - 1}Plot") enable = checkBox.isChecked() for i in range(start_nr, end_nr): diff --git a/pyctbgui/pyctbgui/services/Transceiver.py b/pyctbgui/pyctbgui/services/Transceiver.py index 98c8fc541..ecaf64282 100644 --- a/pyctbgui/pyctbgui/services/Transceiver.py +++ b/pyctbgui/pyctbgui/services/Transceiver.py @@ -133,7 +133,8 @@ class TransceiverTab(QtWidgets.QWidget): nbitsPerDBit += (8 - (dSamples % 8)) transceiverOffset += nDBitEnabled * (nbitsPerDBit // 8) trans_array = np.array(np.frombuffer(data, offset=transceiverOffset, dtype=np.uint16)) - return decoder.decode(trans_array, pm.matterhorn_transceiver()) + tmp = np.take(trans_array, self.mainWindow.pixel_map) + return tmp def processImageData(self, data, dSamples): """ diff --git a/pyctbgui/pyctbgui/ui/plot.ui b/pyctbgui/pyctbgui/ui/plot.ui index b01bc3e71..edebb4548 100644 --- a/pyctbgui/pyctbgui/ui/plot.ui +++ b/pyctbgui/pyctbgui/ui/plot.ui @@ -165,7 +165,17 @@ - Matterhorn + Matterhorn02 + + + + + Matterhorn1_16bit_4_counters + + + + + Matterhorn1_16bit_1_counter diff --git a/pyctbgui/pyctbgui/utils/decoder.py b/pyctbgui/pyctbgui/utils/decoder.py index 6197f811c..ca254b175 100644 --- a/pyctbgui/pyctbgui/utils/decoder.py +++ b/pyctbgui/pyctbgui/utils/decoder.py @@ -49,3 +49,4 @@ def matterhorn(trans_buffer): offset += nSamples return transceiver_frame + diff --git a/pyctbgui/pyctbgui/utils/defines.py b/pyctbgui/pyctbgui/utils/defines.py index 51c6ac1cb..413285185 100644 --- a/pyctbgui/pyctbgui/utils/defines.py +++ b/pyctbgui/pyctbgui/utils/defines.py @@ -50,7 +50,7 @@ class Defines: Matterhorn = 0 Moench04 = 1 - class Matterhorn: + class Matterhorn02: nRows = 48 nHalfCols = 24 nCols = 48 @@ -58,6 +58,14 @@ class Defines: tranceiverEnable = 0x3 nPixelsPerTransceiver = 4 + class Matterhorn1: + nRows = 256 + nHalfCols = 24 + nCols = 256 + nTransceivers = 2 + tranceiverEnable = 0x3 + nPixelsPerTransceiver = 4 + class Moench04: nRows = 400 nCols = 400 diff --git a/pyctbgui/pyctbgui/utils/pixelmap.py b/pyctbgui/pyctbgui/utils/pixelmap.py index 6cfa28a14..72fbcc385 100644 --- a/pyctbgui/pyctbgui/utils/pixelmap.py +++ b/pyctbgui/pyctbgui/utils/pixelmap.py @@ -59,3 +59,34 @@ def matterhorn_transceiver(): offset += nSamples return out + + +def matterhorn1_transceiver_16bit_1_counter(): + pixel_map = np.zeros((256,256), np.uint32) + n_cols = 256 + n_rows = 256 + for row in range(n_rows): + col = 0 + for offset in range(0,64,4): + for pkg in range(offset,256,64): + for pixel in range(4): + pixel_map[row, col] = pixel+pkg+row*n_cols + col += 1 + + return pixel_map + +def matterhorn1_transceiver_16bit_4_counters(): + n_counters = 4 + n_cols = 256 + n_rows = 256 + pixel_map = np.zeros((n_rows*n_counters,n_cols), np.uint32) + + for row in range(n_rows): + for counter in range(n_counters): + col = 0 + for offset in range(0,64,4): + for pkg in range(offset,256,64): + for pixel in range(4): + pixel_map[row+n_rows*counter, col] = pixel+pkg+row*n_cols*n_counters+n_cols*counter + col += 1 + return pixel_map \ No newline at end of file diff --git a/python/src/detector.cpp b/python/src/detector.cpp index 070dac493..7bad555c0 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -2198,5 +2198,17 @@ void init_det(py::module &m) { (Result(Detector::*)(sls::Positions) const) & Detector::getMeasurementTime, py::arg() = Positions{}); + CppDetectorApi.def("readSpi", + (Result>(Detector::*)( + int, int, int, sls::Positions) const) & + Detector::readSpi, + py::arg(), py::arg(), py::arg(), + py::arg() = Positions{}); + CppDetectorApi.def( + "writeSpi", + (Result>(Detector::*)( + int, int, const std::vector &, sls::Positions)) & + Detector::writeSpi, + py::arg(), py::arg(), py::arg(), py::arg() = Positions{}); ; } diff --git a/python/tests/conftest.py b/python/tests/conftest.py index 18c6bf174..3b1d65f69 100644 --- a/python/tests/conftest.py +++ b/python/tests/conftest.py @@ -10,8 +10,6 @@ scripts_dir = current_dir / "tests" / "scripts" sys.path.append(str(scripts_dir)) -print(sys.path) - from utils_for_test import ( Log, LogLevel, @@ -20,66 +18,154 @@ from utils_for_test import ( startDetectorVirtualServer, loadConfig, loadBasicSettings, + connectToVirtualServers, + DEFAULT_UDP_DST_PORTNO, ) def pytest_addoption(parser): parser.addoption( - "--with-detector-simulators", action="store_true", default=False, help="Run tests that require detector simulators" + "--detector-integration", action="store_true", default=False, help="Run tests that require detectors" ) def pytest_configure(config): - config.addinivalue_line("markers", "withdetectorsimulators: mark test as needing detector simulators to run") + config.addinivalue_line("markers", "detectorintegration: mark test as needing detectors to run") def pytest_collection_modifyitems(config, items): - if config.getoption("--with-detector-simulators"): + if config.getoption("--detector-integration"): return - skip = pytest.mark.skip(reason="need --with-detector-simulators option to run") + skip = pytest.mark.skip(reason="need --detector-integration option to run") for item in items: - if "withdetectorsimulators" in item.keywords: + if "detectorintegration" in item.keywords: item.add_marker(skip) + +DEFAULT_SIMULATOR_CONFIGS = [ + ("eiger", 1, 1), + ("eiger", 1, 2), + ("jungfrau", 1, 1), + ("jungfrau", 1, 2), + ("jungfrau", 2, 1), + ("jungfrau", 2, 2), + ("mythen3", 1, 1), + ("mythen3", 1, 2), + ("gotthard2", 1, 1), + ("gotthard2", 1, 2), + ("moench", 1, 1), + ("moench", 1, 2), + ("ctb", 1, 1), + ("xilinx_ctb", 1, 1), +] + +SIMULATOR_IDS = [f"{det_type}_{num_interface}if_{num_mod}mod" for det_type, num_interface, num_mod in DEFAULT_SIMULATOR_CONFIGS] + +@pytest.fixture(scope="session") +def session_simulator(request): + """ + Fixture to start the detector server once and clean up at the end. + Expects request.param = (det_type, num_interfaces, num_mods) + """ + det_type, num_interfaces, num_mods = request.param + fp = sys.stdout + + # set up: once per server + Log(LogLevel.INFOBLUE, + f'---- {det_type} | interfaces={num_interfaces} | modules={num_mods} ----', fp) + + cleanup(fp) + startDetectorVirtualServer(det_type, num_mods, fp, True) + startReceiver(num_mods, fp, True) + + Log(LogLevel.INFOBLUE, f'Waiting for server to start up and connect', fp) + d = loadConfig( + name=det_type, + log_file_fp=fp, + num_mods=num_mods, + num_frames=1, + num_interfaces=num_interfaces, + ) + + loadBasicSettings(name=det_type, d=d, fp=fp) + + yield det_type, num_interfaces, num_mods, d + + cleanup(fp) + + + +def pytest_generate_tests(metafunc): + if "session_simulator" not in metafunc.fixturenames: + return # nothing to do + + # Check if session_simulator is already parametrized + markers = metafunc.definition.iter_markers(name="parametrize") + for m in markers: + if m.args and m.args[0] == "session_simulator": + return # already parametrized, skip defaults + + # Apply default configs only for session_simulator + metafunc.parametrize( + "session_simulator", + DEFAULT_SIMULATOR_CONFIGS, + ids=SIMULATOR_IDS, + indirect=True + ) + +''' +for more specific parameters +@pytest.mark.detectorintegration +@pytest.mark.parametrize( + "session_simulator", + [ + ("ctb", 1, 1), + ("xilinx_ctb", 1, 1), + ], + indirect=True, +) +def test_define_reg(session_simulator): + det_type, num_interfaces, num_mods, d = session_simulator +''' + #helper fixture for servers -@pytest.fixture -def servers(request): +@pytest.fixture(scope='module') +def setup_parameters(request): # only setup once per module if same parameters used for the scopes try: - return request.param # comes from @pytest.mark.parametrize(..., indirect=True) + servers, nmods = request.param # comes from @pytest.mark.parametrize(..., indirect=True) + return servers, nmods except AttributeError: # fallback default if the test did not parametrize - return ['eiger', 'jungfrau', 'mythen3', 'gotthard2', 'ctb', 'moench', 'xilinx_ctb'] - return request.param - -@pytest.fixture -def test_with_simulators(servers): + return (['eiger', 'jungfrau', 'mythen3', 'gotthard2', 'ctb', 'moench', 'xilinx_ctb'], 2) + +@pytest.fixture(scope='module') +def test_with_simulators(setup_parameters): """ Fixture to automatically setup virtual detector servers for testing. """ - LOG_PREFIX_FNAME = '/tmp/slsDetectorPackage_virtual_PythonAPI_test' - MAIN_LOG_FNAME = LOG_PREFIX_FNAME + '_log.txt' + fp = sys.stdout - with open(MAIN_LOG_FNAME, 'w') as fp: - try: - nmods = 2 - for server in servers: - for ninterfaces in range(1,2): - if ninterfaces == 2 and server != 'jungfrau' and server != 'moench': - continue + servers, nmods = setup_parameters + print("servers:", servers) + print("nmods:", nmods) + try: + for server in servers: + for ninterfaces in range(1,2): + if ninterfaces == 2 and server != 'jungfrau' and server != 'moench': + continue - msg = f'Starting Python API Tests for {server}' + msg = f'Starting Python API Tests for {server}' - if server == 'jungfrau' or server == 'moench': - msg += f' with {ninterfaces} interfaces' + if server == 'jungfrau' or server == 'moench': + msg += f' with {ninterfaces} interfaces' - Log(LogLevel.INFOBLUE, msg, fp) - cleanup(fp) - startDetectorVirtualServer(server, nmods, fp) - startReceiver(nmods, fp) - d = loadConfig(name=server, log_file_fp=fp, num_mods=nmods, num_frames=1, num_interfaces=ninterfaces) - loadBasicSettings(name=server, d=d, fp=fp) - yield # run test - cleanup(fp) # teardown - except Exception as e: - with open(MAIN_LOG_FNAME, 'a') as fp_error: - traceback.print_exc(file=fp_error) - Log(LogLevel.ERROR, f'Tests Failed.', fp) - cleanup(fp) + Log(LogLevel.INFOBLUE, msg, fp) + cleanup(fp) + startDetectorVirtualServer(server, nmods, fp) + startReceiver(nmods, fp) + d = loadConfig(name=server, log_file_fp=fp, num_mods=nmods, num_frames=1, num_interfaces=ninterfaces) + #loadBasicSettings(name=server, d=d, fp=fp) + yield # run test + cleanup(fp) # teardown + except Exception as e: + traceback.print_exc(file=fp) + Log(LogLevel.ERROR, f'Tests Failed.', fp) + cleanup(fp) diff --git a/python/tests/test_CtbAPI.py b/python/tests/test_det_api.py similarity index 82% rename from python/tests/test_CtbAPI.py rename to python/tests/test_det_api.py index 13730f345..6db456a34 100644 --- a/python/tests/test_CtbAPI.py +++ b/python/tests/test_det_api.py @@ -1,10 +1,3 @@ -''' -cd python/tests -Specific test: pytest -s -x test_CtbAPI.py::test_define_bit #-x=abort on first failure -Specific test with specific server: pytest -s -x test_CtbAPI.py::test_define_reg[ctb] - -''' - import pytest, sys, traceback from pathlib import Path @@ -16,48 +9,20 @@ print(sys.path) from utils_for_test import ( Log, LogLevel, - cleanup, - startDetectorVirtualServer, - connectToVirtualServers, - SERVER_START_PORTNO, ) - -from slsdet import Detector, detectorType +from slsdet import Detector -@pytest.fixture( - scope="session", - params=['ctb', 'xilinx_ctb', 'mythen3', 'jungfrau'] -) -def simulator(request): - """Fixture to start the detector server once and clean up at the end.""" - det_name = request.param - num_mods = 1 - fp = sys.stdout - # set up: once per server - Log(LogLevel.INFOBLUE, f'---- {det_name} ----') - cleanup(fp) - startDetectorVirtualServer(det_name, num_mods, fp) - - Log(LogLevel.INFOBLUE, f'Waiting for server to start up and connect') - connectToVirtualServers(det_name, num_mods) - - yield det_name # tests run here - - cleanup(fp) - - -@pytest.mark.withdetectorsimulators -def test_define_reg(simulator, request): +@pytest.mark.detectorintegration +def test_define_reg(session_simulator, request): """ Test setting define_reg for ctb and xilinx_ctb.""" - det_name = simulator + det_type, num_interfaces, num_mods, d = session_simulator + assert d is not None + from slsdet import RegisterAddress - d = Detector() - d.hostname = f"localhost:{SERVER_START_PORTNO}" - - if det_name in ['ctb', 'xilinx_ctb']: + if det_type in ['ctb', 'xilinx_ctb']: prev_reg_defs = d.getRegisterDefinitions() prev_bit_defs = d.getBitDefinitions() d.clearRegisterDefinitions() @@ -109,17 +74,15 @@ def test_define_reg(simulator, request): Log(LogLevel.INFOGREEN, f"✅ {request.node.name} passed") -@pytest.mark.withdetectorsimulators -def test_define_bit(simulator, request): +@pytest.mark.detectorintegration +def test_define_bit(session_simulator, request): """ Test setting define_bit for ctb and xilinx_ctb.""" - det_name = simulator + det_type, num_interfaces, num_mods, d = session_simulator + assert d is not None + from slsdet import RegisterAddress, BitAddress - # setup - d = Detector() - d.hostname = f"localhost:{SERVER_START_PORTNO}" - - if det_name in ['ctb', 'xilinx_ctb']: + if det_type in ['ctb', 'xilinx_ctb']: prev_reg_defs = d.getRegisterDefinitions() prev_bit_defs = d.getBitDefinitions() d.clearRegisterDefinitions() @@ -201,17 +164,15 @@ def test_define_bit(simulator, request): Log(LogLevel.INFOGREEN, f"✅ {request.node.name} passed") -@pytest.mark.withdetectorsimulators -def test_using_defined_reg_and_bit(simulator, request): +@pytest.mark.detectorintegration +def test_using_defined_reg_and_bit(session_simulator, request): """ Test using defined reg and bit define_bit for ctb and xilinx_ctb.""" - det_name = simulator + det_type, num_interfaces, num_mods, d = session_simulator + assert d is not None + from slsdet import RegisterAddress, BitAddress, RegisterValue - # setup - d = Detector() - d.hostname = f"localhost:{SERVER_START_PORTNO}" - - if det_name in ['ctb', 'xilinx_ctb']: + if det_type in ['ctb', 'xilinx_ctb']: prev_reg_defs = d.getRegisterDefinitions() prev_bit_defs = d.getBitDefinitions() d.clearRegisterDefinitions() @@ -287,17 +248,15 @@ def test_using_defined_reg_and_bit(simulator, request): Log(LogLevel.INFOGREEN, f"✅ {request.node.name} passed") -@pytest.mark.withdetectorsimulators -def test_definelist_reg(simulator, request): +@pytest.mark.detectorintegration +def test_definelist_reg(session_simulator, request): """ Test using definelist_reg for ctb and xilinx_ctb.""" - det_name = simulator + det_type, num_interfaces, num_mods, d = session_simulator + assert d is not None + from slsdet import RegisterAddress, BitAddress, RegisterValue - # setup - d = Detector() - d.hostname = f"localhost:{SERVER_START_PORTNO}" - - if det_name in ['ctb', 'xilinx_ctb']: + if det_type in ['ctb', 'xilinx_ctb']: prev_reg_defs = d.getRegisterDefinitions() prev_bit_defs = d.getBitDefinitions() d.clearRegisterDefinitions() @@ -332,17 +291,15 @@ def test_definelist_reg(simulator, request): Log(LogLevel.INFOGREEN, f"✅ {request.node.name} passed") -@pytest.mark.withdetectorsimulators -def test_definelist_bit(simulator, request): +@pytest.mark.detectorintegration +def test_definelist_bit(session_simulator, request): """ Test using definelist_bit for ctb and xilinx_ctb.""" - det_name = simulator + det_type, num_interfaces, num_mods, d = session_simulator + assert d is not None + from slsdet import RegisterAddress, BitAddress, RegisterValue - # setup - d = Detector() - d.hostname = f"localhost:{SERVER_START_PORTNO}" - - if det_name in ['ctb', 'xilinx_ctb']: + if det_type in ['ctb', 'xilinx_ctb']: prev_reg_defs = d.getRegisterDefinitions() prev_bit_defs = d.getBitDefinitions() d.clearRegisterDefinitions() @@ -385,19 +342,55 @@ def test_definelist_bit(simulator, request): Log(LogLevel.INFOGREEN, f"✅ {request.node.name} passed") -@pytest.mark.withdetectorsimulators -def test_patternstart(simulator, request): - """ Test using patternstart for ctb, xilinx_ctb and mythen3.""" - det_name = simulator - # setup - d = Detector() - d.hostname = f"localhost:{SERVER_START_PORTNO}" +@pytest.mark.detectorintegration +def test_parameters_file(session_simulator, request): + """ Test using test_parameters_file.""" + det_type, num_interfaces, num_mods, d = session_simulator + assert d is not None - if det_name in ['ctb', 'xilinx_ctb', 'mythen3']: + with open("/tmp/params.det", "w") as f: + f.write("frames 2\n") + f.write("fwrite 1\n") + + # this should not throw + d.parameters = "/tmp/params.det" + + assert d.frames == 2 + assert d.fwrite == 1 + + Log(LogLevel.INFOGREEN, f"✅ Test passed. Command: parameters") + + +@pytest.mark.detectorintegration +def test_include_file(session_simulator, request): + """ Test using test_include_file.""" + det_type, num_interfaces, num_mods, d = session_simulator + assert d is not None + + with open("/tmp/params.det", "w") as f: + f.write("frames 3\n") + f.write("fwrite 0\n") + + # this should not throw + d.include = "/tmp/params.det" + + assert d.frames == 3 + assert d.fwrite == 0 + + Log(LogLevel.INFOGREEN, f"✅ Test passed. Command: include") + + +@pytest.mark.detectorintegration +def test_patternstart(session_simulator, request): + """ Test using patternstart for ctb, xilinx_ctb and mythen3.""" + det_type, num_interfaces, num_mods, d = session_simulator + assert d is not None + + if det_type in ['ctb', 'xilinx_ctb', 'mythen3']: d.patternstart() else: with pytest.raises(Exception) as exc_info: d.patternstart() assert "not implemented" in str(exc_info.value) - Log(LogLevel.INFOGREEN, f"✅ {request.node.name} passed") \ No newline at end of file + Log(LogLevel.INFOGREEN, f"✅ {request.node.name} passed") diff --git a/tests/scripts/test_free.py b/python/tests/test_free.py similarity index 94% rename from tests/scripts/test_free.py rename to python/tests/test_free.py index a464871c6..4f5393ca9 100644 --- a/tests/scripts/test_free.py +++ b/python/tests/test_free.py @@ -7,6 +7,15 @@ Run this using: pytest -s test_free.py import pytest, sys +from pathlib import Path + +current_dir = Path(__file__).resolve().parents[2] + +scripts_dir = current_dir / "tests" / "scripts" + +sys.path.append(str(scripts_dir)) + + from slsdet import Detector, Ctb, freeSharedMemory from utils_for_test import ( Log, @@ -46,7 +55,7 @@ def setup_simulator(det_config): cleanup(fp) - +@pytest.mark.detectorintegration def test_exptime_after_free_should_raise(setup_simulator): Log(LogLevel.INFOBLUE, f'\nRunning test_exptime_after_free_should_raise') @@ -64,14 +73,11 @@ def test_exptime_after_free_should_raise(setup_simulator): assert str(exc_info.value) == "Shared memory is invalid or freed. Close resources before access." - - - def free_and_create_shm(): k = Ctb() # opens existing shm if it exists k.hostname = f"localhost:{SERVER_START_PORTNO}" # free and recreate shm, maps to local shm struct - +@pytest.mark.detectorintegration def test_exptime_after_not_passing_var_should_raise(setup_simulator): Log(LogLevel.INFOBLUE, f'\nRunning test_exptime_after_not_passing_var_should_raise') @@ -95,7 +101,7 @@ def free_and_create_shm_passing_ctb_var(k): k = Ctb() # opens existing shm if it exists (disregards k as its new Ctb only local to this function) k.hostname = f"localhost:{SERVER_START_PORTNO}" # free and recreate shm, maps to local shm struct - +@pytest.mark.detectorintegration def test_exptime_after_passing_ctb_var_should_raise(setup_simulator): Log(LogLevel.INFOBLUE, f'\nRunning test_exptime_after_passing_ctb_var_should_raise') @@ -118,7 +124,7 @@ def free_and_create_shm_returning_ctb(): k.hostname = f"localhost:{SERVER_START_PORTNO}" # free and recreate shm, maps to local shm struct return k - +@pytest.mark.detectorintegration def test_exptime_after_returning_ctb_should_raise(setup_simulator): Log(LogLevel.INFOBLUE, f'\nRunning test_exptime_after_returning_ctb_should_raise') @@ -141,11 +147,7 @@ def test_exptime_after_returning_ctb_should_raise(setup_simulator): Log(LogLevel.INFOGREEN, f"✅ Test passed, exception was: {exc_info.value}") assert str(exc_info.value) == "Shared memory is invalid or freed. Close resources before access." - - - - - +@pytest.mark.detectorintegration def test_hostname_twice_acess_old_should_raise(setup_simulator): Log(LogLevel.INFOBLUE, f'\nRunning test_hostname_twice_acess_old_should_raise') diff --git a/python/tests/test_pythonAPI.py b/python/tests/test_pythonAPI.py index 3c5d40d9b..9bcc4214b 100644 --- a/python/tests/test_pythonAPI.py +++ b/python/tests/test_pythonAPI.py @@ -5,9 +5,14 @@ from conftest import test_with_simulators from slsdet import Detector -@pytest.mark.withdetectorsimulators -@pytest.mark.parametrize("servers", [["moench"]], indirect=True) -def test_rx_ROI_moench(test_with_simulators, servers): +from utils_for_test import ( + Log, + LogLevel, +) + +@pytest.mark.detectorintegration +@pytest.mark.parametrize("setup_parameters", [(["moench"], 2)], indirect=True) +def test_rx_ROI_moench(test_with_simulators, setup_parameters): """ Test setting and getting rx_ROI property of Detector class for moench. """ d = Detector() @@ -28,9 +33,9 @@ def test_rx_ROI_moench(test_with_simulators, servers): roi = d.rx_roi assert roi == [(-1,-1,-1,-1)] -@pytest.mark.withdetectorsimulators -@pytest.mark.parametrize("servers", [["mythen3"]], indirect=True) -def test_rx_ROI_mythen(test_with_simulators, servers): +@pytest.mark.detectorintegration +@pytest.mark.parametrize("setup_parameters", [(["mythen3"], 1)], indirect=True) +def test_rx_ROI_mythen(test_with_simulators, setup_parameters): """ Test setting and getting rx_ROI property of Detector class for mythen. """ d = Detector() @@ -44,5 +49,3 @@ def test_rx_ROI_mythen(test_with_simulators, servers): assert d.rx_roi == [(0,10,-1,-1)] - - diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer index 34fc895ae..e1b0fb940 100755 Binary files a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.h new file mode 100644 index 000000000..369e71119 --- /dev/null +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.h @@ -0,0 +1,210 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package +#include "sls/sls_detector_defs.h" +#include "slsDetectorServer_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h + +#include "AD9257.h" // commonServerFunctions.h, blackfin.h, ansi.h +#include "blackfin.h" +#include "programViaBlackfin.h" + +#include // FILE +#include +#include + +/**************************************************** +This functions are used by the slsDetectroServer_funcs interface. +Here are the definitions, but the actual implementation should be done for each +single detector. + +****************************************************/ + +enum interfaceType { OUTER, INNER }; +typedef struct udpStruct_s { + uint16_t srcport; + uint16_t srcport2; + uint16_t dstport; + uint16_t dstport2; + uint64_t srcmac; + uint64_t srcmac2; + uint64_t dstmac; + uint64_t dstmac2; + uint32_t srcip; + uint32_t srcip2; + uint32_t dstip; + uint32_t dstip2; +} udpStruct; +#define MAC_ADDRESS_SIZE 18 + +// basic tests +int isInitCheckDone(); +int getInitResult(char **mess); +void basictests(); +int checkType(); +int testFpga(); +int testBus(); + +// Ids +void getServerVersion(char *version); +u_int64_t getFirmwareVersion(); +u_int64_t getFirmwareAPIVersion(); +void getHardwareVersion(char *version); +u_int16_t getHardwareVersionNumber(); +u_int16_t getHardwareSerialNumber(); +int isHardwareVersion_1_0(); +u_int32_t getDetectorNumber(); +u_int64_t getDetectorMAC(); +u_int32_t getDetectorIP(); +int enableBlackfinAMCExternalAccessExtension(char *mess); + +// initialization +void initControlServer(); +void initStopServer(); + +// set up detector +void setupDetector(); +int updateDatabytesandAllocateRAM(); +void updateDataBytes(); + +// firmware functions (resets) +void cleanFifos(); +void resetCore(); +void resetPeripheral(); + +// parameters - dr, roi +int setDynamicRange(int dr); +int getDynamicRange(int *retval); + +int setADCEnableMask(uint32_t mask); +uint32_t getADCEnableMask(); +void setADCEnableMask_10G(uint32_t mask); +uint32_t getADCEnableMask_10G(); +int setTransceiverEnableMask(uint32_t mask); +uint32_t getTransceiverEnableMask(); +void setADCInvertRegister(uint32_t val); +uint32_t getADCInvertRegister(); + +int setExternalSamplingSource(int val); +int setExternalSampling(int val); + +// parameters - readout +int setReadoutMode(enum readoutMode mode); +int getReadoutMode(); + +// parameters - timer +int setNextFrameNumber(uint64_t value); +int getNextFrameNumber(uint64_t *value); +void setNumFrames(int64_t val); +int64_t getNumFrames(); +void setNumTriggers(int64_t val); +int64_t getNumTriggers(); +int setExpTime(int64_t val); +int64_t getExpTime(); +int setPeriod(int64_t val); +int64_t getPeriod(); +int setNumAnalogSamples(int val); +int getNumAnalogSamples(); +int setNumDigitalSamples(int val); +int getNumDigitalSamples(); +int setNumTransceiverSamples(int val); +int getNumTransceiverSamples(); + +int64_t getNumFramesLeft(); +int64_t getNumTriggersLeft(); +int setDelayAfterTrigger(int64_t val); +int64_t getDelayAfterTrigger(); +int64_t getDelayAfterTriggerLeft(); +int64_t getPeriodLeft(); +int64_t getFramesFromStart(); +int64_t getActualTime(); +int64_t getMeasurementTime(); + +// parameters - module, settings +enum detectorSettings getSettings(); + +// parameters - threshold +// parameters - dac, adc, hv + +void setDAC(enum DACINDEX ind, int val, int mV); +int getDAC(enum DACINDEX ind, int mV); +int getMaxDacSteps(); +int dacToVoltage(int dac); +int checkVLimitCompliant(int mV); +int checkVLimitDacCompliant(int dac); +int getVLimit(); +void setVLimit(int l); + +int isVchipValid(int val); +int getVchip(); +void setVchip(int val); +int getVChipToSet(enum DACINDEX ind, int val); +int getDACIndexFromADCIndex(enum ADCINDEX ind); +int getADCIndexFromDACIndex(enum DACINDEX ind); +int isPowerValid(enum DACINDEX ind, int val); +int getPower(); +void setPower(enum DACINDEX ind, int val); +void powerOff(); + +int getADC(enum ADCINDEX ind); +int getSlowADC(int ichan); +int getSlowADCTemperature(); +int setHighVoltage(int val); + +// parameters - timing, extsig + +void setTiming(enum timingMode arg); +enum timingMode getTiming(); + +// configure mac +int getNumberofUDPInterfaces(); +void calcChecksum(udp_header *udp); + +int configureMAC(); +int setDetectorPosition(int pos[]); +int *getDetectorPosition(); + +int enableTenGigabitEthernet(int val); + +// very detector specific + +// chip test board specific - configure frequency, phase, pll, +// flashing firmware +int setPhase(enum CLKINDEX ind, int val, int degrees); +int getPhase(enum CLKINDEX ind, int degrees); +int getMaxPhase(enum CLKINDEX ind); +int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval); +void configureSyncFrequency(enum CLKINDEX ind); +void setADCPipeline(int val); +int getADCPipeline(); +void setDBITPipeline(int val); +int getDBITPipeline(); +int setLEDEnable(int enable); +void setDigitalIODelay(uint64_t pinMask, int delay); + +int setFrequency(enum CLKINDEX ind, int val); +int getFrequency(enum CLKINDEX ind); + +// aquisition +int startStateMachine(); +#ifdef VIRTUAL +void *start_timer(void *arg); +#endif +int stopStateMachine(); +int startReadOut(); +enum runStatus getRunStatus(); +void waitForAcquisitionEnd(); +int validateUDPSocket(); +void readandSendUDPFrames(); +void unsetFifoReadStrobes(); +int readSample(int ns); +uint32_t checkDataInFifo(); +int checkFifoForEndOfAcquisition(); +int readFrameFromFifo(); +u_int32_t runBusy(); + +// common +int calculateDataBytes(); +int getTotalNumberOfChannels(); +void getNumberOfChannels(int *nchanx, int *nchany); +int getNumberOfChips(); +int getNumberOfDACs(); +int getNumberOfChannelsPerChip(); \ No newline at end of file diff --git a/slsDetectorServers/eigerDetectorServer/FebControl.c b/slsDetectorServers/eigerDetectorServer/FebControl.c index f0b96d487..85a89f2d9 100644 --- a/slsDetectorServers/eigerDetectorServer/FebControl.c +++ b/slsDetectorServers/eigerDetectorServer/FebControl.c @@ -4,6 +4,7 @@ #include "Beb.h" #include "FebRegisterDefs.h" #include "clogger.h" +#include "common.h" #include "sharedMemory.h" #include "slsDetectorServer_defs.h" @@ -403,12 +404,13 @@ int Feb_Control_ReceiveHighVoltage(unsigned int *value) { // normal if (Feb_Control_normal) { + int retval = 0; if (readParameterFromFile(NORMAL_HIGHVOLTAGE_INPUTPORT, "high voltage", - value) == FAIL) { + &retval) == FAIL) { LOG(logERROR, ("Could not get high voltage\n")); return 0; } - *value /= 10; + *value = retval / 10; LOG(logINFO, ("High Voltage: %d\n", (*value))); } diff --git a/slsDetectorServers/eigerDetectorServer/FebControl.h b/slsDetectorServers/eigerDetectorServer/FebControl.h index 63025554f..52908e79f 100644 --- a/slsDetectorServers/eigerDetectorServer/FebControl.h +++ b/slsDetectorServers/eigerDetectorServer/FebControl.h @@ -119,6 +119,7 @@ int Feb_Control_PrintCorrectedValues(); // adcs int Feb_Control_GetLeftFPGATemp(); int Feb_Control_GetRightFPGATemp(); +int Feb_Control_GetFPGAHardwareVersion(int *retval); int64_t Feb_Control_GetFrontLeftFirmwareVersion(); int64_t Feb_Control_GetFrontRightFirmwareVersion(); int64_t Feb_Control_GetMeasuredPeriod(); diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer index 9ff6d5fa9..19a7c189b 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.h new file mode 100644 index 000000000..426c8fd7f --- /dev/null +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.h @@ -0,0 +1,209 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package +#include "sls/sls_detector_defs.h" +#include "slsDetectorServer_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h + +#include // FILE +#include +#include + +/**************************************************** +This functions are used by the slsDetectroServer_funcs interface. +Here are the definitions, but the actual implementation should be done for each +single detector. + +****************************************************/ + +enum interfaceType { OUTER, INNER }; +typedef struct udpStruct_s { + uint16_t srcport; + uint16_t srcport2; + uint16_t dstport; + uint16_t dstport2; + uint64_t srcmac; + uint64_t srcmac2; + uint64_t dstmac; + uint64_t dstmac2; + uint32_t srcip; + uint32_t srcip2; + uint32_t dstip; + uint32_t dstip2; +} udpStruct; +#define MAC_ADDRESS_SIZE 18 + +// basic tests +int isInitCheckDone(); +int getInitResult(char **mess); +void basictests(); + +#if defined(VIRTUAL) +void setTestImageMode(int ival); +int getTestImageMode(); +#endif + +// Ids +void getServerVersion(char *version); +u_int64_t getFirmwareVersion(); +uint64_t getFrontEndFirmwareVersion(enum fpgaPosition fpgaPosition); +u_int64_t getFirmwareAPIVersion(); +void getHardwareVersion(char *version); +int getHardwareVersionNumber(); +int getModuleId(int *ret, char *mess); +int updateModuleId(); +u_int64_t getDetectorMAC(); +u_int32_t getDetectorIP(); + +// initialization +void initControlServer(); +void initStopServer(); +int updateModuleConfiguration(); +int getModuleConfiguration(int *m, int *t, int *n); +#ifdef VIRTUAL +void checkVirtual9MFlag(); +#endif + +// set up detector +#if !defined(VIRTUAL) +void setupFebBeb(); +#endif +int allocateDetectorStructureMemory(); +void setupDetector(); + +int resetToDefaultDacs(int hardReset); +int getDefaultDac(enum DACINDEX index, enum detectorSettings sett, int *retval); +int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value); +int readConfigFile(); +int checkCommandLineConfiguration(); +void resetToHardwareSettings(); + +// advanced read/write reg +int writeRegister(uint32_t offset, uint32_t data, int validate); +int readRegister(uint32_t offset, uint32_t *retval); +int setBit(const uint32_t addr, const int nBit, int validate); +int clearBit(const uint32_t addr, const int nBit, int validate); +int getBit(const uint32_t addr, const int nBit, int *retval); + +// parameters - dr, roi +int setDynamicRange(int dr); +int getDynamicRange(int *retval); + +// parameters - readout +int setParallelMode(int mode); +int getParallelMode(); +int setOverFlowMode(int mode); +int getOverFlowMode(); + +// parameters - timer +int setNextFrameNumber(uint64_t value); +int getNextFrameNumber(uint64_t *value); +void setNumFrames(int64_t val); +int64_t getNumFrames(); +void setNumTriggers(int64_t val); +int64_t getNumTriggers(); +int setExpTime(int64_t val); +int64_t getExpTime(); +int setPeriod(int64_t val); +int64_t getPeriod(); +int setSubExpTime(int64_t val); +int64_t getSubExpTime(); +int setSubDeadTime(int64_t val); +int64_t getSubDeadTime(); +int64_t getMeasuredPeriod(); +int64_t getMeasuredSubPeriod(); + +// parameters - module, settings +void getModule(sls_detector_module *myMod); +int setModule(sls_detector_module myMod, char *mess); +int setTrimbits(int *chanregs, char *mess); +enum detectorSettings setSettings(enum detectorSettings sett); +enum detectorSettings getSettings(); + +// parameters - threshold +int getThresholdEnergy(); +int setThresholdEnergy(int ev); + +// parameters - dac, adc, hv +void setDAC(enum DACINDEX ind, int val, int mV); +int getDAC(enum DACINDEX ind, int mV); +int getMaxDacSteps(); + +int getADC(enum ADCINDEX ind); +int setHighVoltage(int val); + +// parameters - timing, extsig +int setMaster(enum MASTERINDEX m); +int setTop(enum TOPINDEX t); +int isTop(int *retval); +int isMaster(int *retval); + +void setTiming(enum timingMode arg); +enum timingMode getTiming(); + +// configure mac +int getNumberofUDPInterfaces(); +int getNumberofDestinations(int *retval); +int setNumberofDestinations(int value); +int configureMAC(); +int setDetectorPosition(int pos[]); +int *getDetectorPosition(); + +int setQuad(int value); +int getQuad(); +int setInterruptSubframe(int value); +int getInterruptSubframe(); +int setReadNRows(int value); +int getReadNRows(); +int enableTenGigabitEthernet(int val); + +// very detector specific + +// eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter +int setReadoutSpeed(int val); +int getReadoutSpeed(int *retval); +int setIODelay(int val); +int setCounterBit(int val); +int pulsePixel(int n, int x, int y); +int pulsePixelNMove(int n, int x, int y); +int pulseChip(int n); +int updateRateCorrection(char *mess); +int validateAndSetRateCorrection(int64_t tau_ns, char *mess); +int setRateCorrection(int64_t custom_tau_in_nsec); +int getRateCorrectionEnable(); +int getDefaultSettingsTau_in_nsec(); +void setDefaultSettingsTau_in_nsec(int t); +int64_t getCurrentTau(); +void setExternalGating(int enable[]); +int setAllTrimbits(int val); +int getAllTrimbits(); +int getBebFPGATemp(); +int setActivate(int enable); +int getActivate(int *retval); +int getDataStream(enum portPosition port, int *retval); +int setDataStream(enum portPosition port, int enable); + +int getTenGigaFlowControl(); +int setTenGigaFlowControl(int value); +int getTransmissionDelayFrame(); +int setTransmissionDelayFrame(int value); +int getTransmissionDelayLeft(); +int setTransmissionDelayLeft(int value); +int getTransmissionDelayRight(); +int setTransmissionDelayRight(int value); + +// aquisition +int startStateMachine(); +#ifdef VIRTUAL +void *start_timer(void *arg); +#endif +int stopStateMachine(); +int softwareTrigger(int block); +int startReadOut(); +enum runStatus getRunStatus(); +void waitForAcquisitionEnd(int *ret, char *mess); + +// common +int calculateDataBytes(); +int getTotalNumberOfChannels(); +int getNumberOfChips(); +int getNumberOfDACs(); +int getNumberOfChannelsPerChip(); \ No newline at end of file diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index 98bdbcde0..2732f13a7 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.h new file mode 100644 index 000000000..598a4e251 --- /dev/null +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.h @@ -0,0 +1,213 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package +#include "sls/sls_detector_defs.h" +#include "slsDetectorServer_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h + +#include "nios.h" +#include "programViaNios.h" + +#include // FILE +#include +#include + +/**************************************************** +This functions are used by the slsDetectroServer_funcs interface. +Here are the definitions, but the actual implementation should be done for each +single detector. + +****************************************************/ + +enum interfaceType { OUTER, INNER }; +typedef struct udpStruct_s { + uint16_t srcport; + uint16_t srcport2; + uint16_t dstport; + uint16_t dstport2; + uint64_t srcmac; + uint64_t srcmac2; + uint64_t dstmac; + uint64_t dstmac2; + uint32_t srcip; + uint32_t srcip2; + uint32_t dstip; + uint32_t dstip2; +} udpStruct; +#define MAC_ADDRESS_SIZE 18 + +// basic tests +int isInitCheckDone(); +int getInitResult(char **mess); +void basictests(); +int checkType(); +int testFpga(); +int testBus(); + +// Ids +void getServerVersion(char *version); +u_int64_t getFirmwareVersion(); +u_int64_t getFirmwareAPIVersion(); +void getHardwareVersion(char *version); +u_int16_t getHardwareVersionNumber(); +int isHardwareVersion_1_0(); +u_int32_t getDetectorNumber(); +int getModuleId(int *ret, char *mess); +int updateModuleId(); +void setModuleId(int modid); +u_int64_t getDetectorMAC(); +u_int32_t getDetectorIP(); + +// initialization +void initControlServer(); +void initStopServer(); + +// set up detector +void setupDetector(); +int resetToDefaultDacs(int hardReset); +int getDefaultDac(enum DACINDEX index, enum detectorSettings sett, int *retval); +int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value); +void setASICDefaults(); +int readConfigFile(); +int checkCommandLineConfiguration(); + +// firmware functions (resets) +void cleanFifos(); +void resetCore(); +void resetPeripheral(); + +// parameters - dr, roi +int setDynamicRange(int dr); +int getDynamicRange(int *retval); + +// parameters - readout +int setParallelMode(int mode); +int getParallelMode(); + +// parameters - timer +int setNextFrameNumber(uint64_t value); +int getNextFrameNumber(uint64_t *value); +void setNumFrames(int64_t val); +int64_t getNumFrames(); +void setNumTriggers(int64_t val); +int64_t getNumTriggers(); +int setExpTime(int64_t val); +int64_t getExpTime(); +int setPeriod(int64_t val); +int64_t getPeriod(); +void setNumBursts(int64_t val); +int64_t getNumBursts(); +int setBurstPeriod(int64_t val); +int64_t getBurstPeriod(); +int64_t getNumFramesLeft(); +int64_t getNumTriggersLeft(); +int setDelayAfterTrigger(int64_t val); +int64_t getDelayAfterTrigger(); +int64_t getDelayAfterTriggerLeft(); +int64_t getPeriodLeft(); +int64_t getNumBurstsLeft(); +int64_t getFramesFromStart(); +int64_t getActualTime(); +int64_t getMeasurementTime(); + +// parameters - module, settings +enum detectorSettings setSettings(enum detectorSettings sett); +enum detectorSettings getSettings(); + +// parameters - dac, adc, hv +int setOnChipDAC(enum ONCHIP_DACINDEX ind, int chipIndex, int val); +int getOnChipDAC(enum ONCHIP_DACINDEX ind, int chipIndex); +void setDAC(enum DACINDEX ind, int val, int mV); +int getDAC(enum DACINDEX ind, int mV); +int getMaxDacSteps(); + +int getADC(enum ADCINDEX ind, int *value); +int setHighVoltage(int val); +int getHighVoltage(int *retval); + +// parameters - timing, extsig +int setMaster(enum MASTERINDEX m); +int isMaster(int *retval); + +void updatingRegisters(); +int updateClockDivs(); +void setTiming(enum timingMode arg); +enum timingMode getTiming(); + +// configure mac +void setNumberofUDPInterfaces(int val); +int getNumberofUDPInterfaces(); +int getNumberofDestinations(int *retval); +int setNumberofDestinations(int value); +int getFirstUDPDestination(); +void setFirstUDPDestination(int value); +void calcChecksum(udp_header *udp); +int configureMAC(); +int setDetectorPosition(int pos[]); +int *getDetectorPosition(); + +// very detector specific +int checkDetectorType(char *mess); +int powerChip(int on, char *mess); +int getPowerChip(); +int isChipConfigured(); +int configureChip(char *mess); +void setDBITPipeline(int val); +int getDBITPipeline(); +int setPhase(enum CLKINDEX ind, int val, int degrees); +int getPhase(enum CLKINDEX ind, int degrees); +int getMaxPhase(enum CLKINDEX ind); +int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval); +// void setFrequency(enum CLKINDEX ind, int val); +int getFrequency(enum CLKINDEX ind); +int getVCOFrequency(enum CLKINDEX ind); +int setReadoutSpeed(int val); +int getReadoutSpeed(int *retval); +int getMaxClockDivider(); +int setClockDivider(enum CLKINDEX ind, int val); +int getClockDivider(enum CLKINDEX ind); +int setInjectChannel(int offset, int increment); +void getInjectedChannels(int *offset, int *increment); +int setVetoReference(int gainIndex, int value); +int setVetoPhoton(int chipIndex, int *gainIndices, int *values); +int configureASICVetoReference(int chipIndex, int *gainIndices, int *values); +int getVetoPhoton(int chipIndex, int *retvals, int *gainRetvals); +int setADCConfiguration(int chipIndex, int adcIndex, int value); +int getADCConfiguration(int chipIndex, int adcIndex); +int setBurstModeinFPGA(enum burstMode value); +int setBurstMode(enum burstMode burst); +int configureASICGlobalSettings(); +enum burstMode getBurstMode(); +int setCDSGain(int enable); +int getCDSGain(); +int setFilterResistor(int value); +int getFilterResistor(); +void setCurrentSource(int value); +int getCurrentSource(); +void setTimingSource(enum timingSourceType value); +enum timingSourceType getTimingSource(); +void setVeto(int enable); +int getVeto(); +void setVetoStream(int value); +int getVetoStream(); +enum vetoAlgorithm getVetoAlgorithm(enum streamingInterface interface); +void setVetoAlgorithm(enum vetoAlgorithm alg, + enum streamingInterface interface); + +int setBadChannels(int numChannels, int *channelList); +int *getBadChannels(int *numChannels); + +// aquisition +int startStateMachine(); +#ifdef VIRTUAL +void *start_timer(void *arg); +#endif +int stopStateMachine(); +enum runStatus getRunStatus(); +void waitForAcquisitionEnd(); +u_int32_t runBusy(); + +// common +int calculateDataBytes(); +int getTotalNumberOfChannels(); +int getNumberOfChips(); +int getNumberOfDACs(); +int getNumberOfChannelsPerChip(); \ No newline at end of file diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index bdcdb373f..a992aa229 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.h new file mode 100644 index 000000000..951098e2b --- /dev/null +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.h @@ -0,0 +1,221 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package +#include "sls/sls_detector_defs.h" +#include "slsDetectorServer_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h + +#include "AD9257.h" // commonServerFunctions.h, blackfin.h, ansi.h +#include "blackfin.h" +#include "programViaBlackfin.h" + +#include // FILE +#include +#include + +/**************************************************** +This functions are used by the slsDetectroServer_funcs interface. +Here are the definitions, but the actual implementation should be done for each +single detector. + +****************************************************/ + +enum interfaceType { OUTER, INNER }; +typedef struct udpStruct_s { + uint16_t srcport; + uint16_t srcport2; + uint16_t dstport; + uint16_t dstport2; + uint64_t srcmac; + uint64_t srcmac2; + uint64_t dstmac; + uint64_t dstmac2; + uint32_t srcip; + uint32_t srcip2; + uint32_t dstip; + uint32_t dstip2; +} udpStruct; +#define MAC_ADDRESS_SIZE 18 + +// basic tests +int isInitCheckDone(); +int getInitResult(char **mess); +void basictests(); +int checkType(); +int testFpga(); +int testBus(); + +#if defined(VIRTUAL) +void setTestImageMode(int ival); +int getTestImageMode(); +#endif + +// Ids +void getServerVersion(char *version); +u_int64_t getFirmwareVersion(); +u_int64_t getFirmwareAPIVersion(); +void getHardwareVersion(char *version); +u_int16_t getHardwareVersionNumber(); +u_int16_t getHardwareSerialNumber(); +int isHardwareVersion_1_0(); +int getChipVersion(); +void setChipVersion(int version); +u_int32_t getDetectorNumber(); +int getModuleId(int *ret, char *mess); +int updateModuleId(); +void setModuleId(int modid); +u_int64_t getDetectorMAC(); +u_int32_t getDetectorIP(); + +// initialization +void initControlServer(); +void initStopServer(); + +// set up detector +void setupDetector(); +int resetToDefaultDacs(int hardReset); +int getDefaultDac(enum DACINDEX index, enum detectorSettings sett, int *retval); +int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value); +int readConfigFile(); + +// firmware functions (resets) +void cleanFifos(); +void resetCore(); +void resetPeripheral(); + +// parameters - dr, roi +int setDynamicRange(int dr); +int getDynamicRange(int *retval); +void setADCInvertRegister(uint32_t val); +uint32_t getADCInvertRegister(); + +// parameters - timer +int selectStoragecellStart(int pos); +int getMaxStoragecellStart(); +int setNextFrameNumber(uint64_t value); +int getNextFrameNumber(uint64_t *value); +void setNumFrames(int64_t val); +int64_t getNumFrames(); +void setNumTriggers(int64_t val); +int64_t getNumTriggers(); +int setExpTime(int64_t val); +int64_t getExpTime(); +int setPeriod(int64_t val); +int64_t getPeriod(); +void setNumAdditionalStorageCells(int val); +int getNumAdditionalStorageCells(); +int setStorageCellDelay(int64_t val); +int64_t getStorageCellDelay(); +int64_t getNumFramesLeft(); +int64_t getNumTriggersLeft(); +int setDelayAfterTrigger(int64_t val); +int64_t getDelayAfterTrigger(); +int64_t getDelayAfterTriggerLeft(); +int64_t getPeriodLeft(); +int64_t getFramesFromStart(); +int64_t getActualTime(); +int64_t getMeasurementTime(); + +// parameters - module, settings +int setModule(sls_detector_module myMod, char *mess); +enum detectorSettings setSettings(enum detectorSettings sett); +enum detectorSettings getSettings(); +enum gainMode getGainMode(); +void setGainMode(enum gainMode mode); + +// parameters - dac, adc, hv +void setDAC(enum DACINDEX ind, int val, int mV); +int getDAC(enum DACINDEX ind, int mV); +int getMaxDacSteps(); +int getADC(enum ADCINDEX ind); +int setHighVoltage(int val); +int getHighVoltage(int *retval); + +// parameters - timing, extsig +int setMaster(enum MASTERINDEX m); +int isMaster(int *retval); +int getSynchronization(); +void setSynchronization(int enable); +void setTiming(enum timingMode arg); +enum timingMode getTiming(); + +// configure mac +void setNumberofUDPInterfaces(int val); +int getNumberofUDPInterfaces(); +int getNumberofDestinations(int *retval); +int setNumberofDestinations(int value); +int getFirstUDPDestination(); +void setFirstUDPDestination(int value); +void selectPrimaryInterface(int val); +int getPrimaryInterface(); +void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, + uint64_t destmac, uint16_t destport, uint64_t sourcemac, + uint32_t sourceip, uint16_t sourceport); +void calcChecksum(udp_header *udp); + +int configureMAC(); +int setDetectorPosition(int pos[]); +int *getDetectorPosition(); + +// very detector specific + +int setReadNRows(int value); +int getReadNRows(); +void initReadoutConfiguration(); +int powerChip(int on); +int isChipConfigured(); +void configureChip(); +int autoCompDisable(int on); +int setComparatorDisableTime(int64_t val); +int64_t getComparatorDisableTime(); +void configureASICTimer(); +int setReadoutSpeed(int val); +int getReadoutSpeed(int *retval); +int setPhase(enum CLKINDEX ind, int val, int degrees); +int getPhase(enum CLKINDEX ind, int degrees); +int getMaxPhase(enum CLKINDEX ind); +int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval); +int setThresholdTemperature(int val); +int setTemperatureControl(int val); +int setTemperatureEvent(int val); +void alignDeserializer(); +int getFlipRows(); +void setFlipRows(int arg); +int setFilterResistor(int value); +int getFilterResistor(); +int getNumberOfFilterCells(); +void setNumberOfFilterCells(int iCell); +void disableCurrentSource(); +void enableCurrentSource(int fix, uint64_t select, int normal); +int getCurrentSource(); +int getFixCurrentSource(); +int getNormalCurrentSource(); +uint64_t getSelectCurrentSource(); +int getPedestalMode(); +void getPedestalParameters(uint8_t *frames, uint16_t *loops); +void setPedestalMode(int enable, uint8_t frames, uint16_t loops); +int setTimingInfoDecoder(enum timingInfoDecoder val); +int getTimingInfoDecoder(enum timingInfoDecoder *retval); +int getElectronCollectionMode(); +void setElectronCollectionMode(int enable); + +int getTenGigaFlowControl(); +int setTenGigaFlowControl(int value); +int getTransmissionDelayFrame(); +int setTransmissionDelayFrame(int value); + +// aquisition +int startStateMachine(); +#ifdef VIRTUAL +void *start_timer(void *arg); +#endif +int stopStateMachine(); +int softwareTrigger(int block); +enum runStatus getRunStatus(); +void waitForAcquisitionEnd(); +u_int32_t runBusy(); + +// common +int calculateDataBytes(); +int getTotalNumberOfChannels(); +int getNumberOfChips(); +int getNumberOfDACs(); +int getNumberOfChannelsPerChip(); \ No newline at end of file diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer index dc962da2b..4b49971ca 100755 Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.h new file mode 100644 index 000000000..8ab13a49b --- /dev/null +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.h @@ -0,0 +1,193 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package +#include "sls/sls_detector_defs.h" +#include "slsDetectorServer_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h + +#include "AD9257.h" // commonServerFunctions.h, blackfin.h, ansi.h +#include "blackfin.h" +#include "programViaBlackfin.h" + +#include // FILE +#include +#include + +/**************************************************** +This functions are used by the slsDetectroServer_funcs interface. +Here are the definitions, but the actual implementation should be done for each +single detector. + +****************************************************/ + +enum interfaceType { OUTER, INNER }; +typedef struct udpStruct_s { + uint16_t srcport; + uint16_t srcport2; + uint16_t dstport; + uint16_t dstport2; + uint64_t srcmac; + uint64_t srcmac2; + uint64_t dstmac; + uint64_t dstmac2; + uint32_t srcip; + uint32_t srcip2; + uint32_t dstip; + uint32_t dstip2; +} udpStruct; +#define MAC_ADDRESS_SIZE 18 + +// basic tests +int isInitCheckDone(); +int getInitResult(char **mess); +void basictests(); +int checkType(); +int testFpga(); +int testBus(); + +#if defined(VIRTUAL) +void setTestImageMode(int ival); +int getTestImageMode(); +#endif + +// Ids +void getServerVersion(char *version); +u_int64_t getFirmwareVersion(); +u_int64_t getFirmwareAPIVersion(); +void getHardwareVersion(char *version); +u_int16_t getHardwareVersionNumber(); +u_int16_t getHardwareSerialNumber(); +int isHardwareVersion_1_0(); +u_int32_t getDetectorNumber(); +int getModuleId(int *ret, char *mess); +int updateModuleId(); +void setModuleId(int modid); +u_int64_t getDetectorMAC(); +u_int32_t getDetectorIP(); + +// initialization +void initControlServer(); +void initStopServer(); + +// set up detector +void setupDetector(); +int resetToDefaultDacs(int hardReset); +int getDefaultDac(enum DACINDEX index, enum detectorSettings sett, int *retval); +int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value); + +// firmware functions (resets) +void cleanFifos(); +void resetCore(); +void resetPeripheral(); + +// parameters - dr, roi +int setDynamicRange(int dr); +int getDynamicRange(int *retval); +void setADCInvertRegister(uint32_t val); +uint32_t getADCInvertRegister(); + +// parameters - readout +int setParallelMode(int mode); +int getParallelMode(); + +// parameters - timer +int setNextFrameNumber(uint64_t value); +int getNextFrameNumber(uint64_t *value); +void setNumFrames(int64_t val); +int64_t getNumFrames(); +void setNumTriggers(int64_t val); +int64_t getNumTriggers(); +int setExpTime(int64_t val); +int64_t getExpTime(); +int setPeriod(int64_t val); +int64_t getPeriod(); +int64_t getNumFramesLeft(); +int64_t getNumTriggersLeft(); +int setDelayAfterTrigger(int64_t val); +int64_t getDelayAfterTrigger(); +int64_t getDelayAfterTriggerLeft(); +int64_t getPeriodLeft(); +int64_t getFramesFromStart(); +int64_t getActualTime(); +int64_t getMeasurementTime(); + +// parameters - module, settings +int setModule(sls_detector_module myMod, char *mess); +enum detectorSettings setSettings(enum detectorSettings sett); +enum detectorSettings getSettings(); + +// parameters - dac, adc, hv +void setDAC(enum DACINDEX ind, int val, int mV); +int getDAC(enum DACINDEX ind, int mV); +int getMaxDacSteps(); +int getADC(enum ADCINDEX ind); +int setHighVoltage(int val); + +// parameters - timing, extsig +int setMaster(enum MASTERINDEX m); +int isMaster(int *retval); +int getSynchronization(); +void setSynchronization(int enable); +void setTiming(enum timingMode arg); +enum timingMode getTiming(); + +// configure mac +void setNumberofUDPInterfaces(int val); +int getNumberofUDPInterfaces(); +int getNumberofDestinations(int *retval); +int setNumberofDestinations(int value); +int getFirstUDPDestination(); +void setFirstUDPDestination(int value); +void selectPrimaryInterface(int val); +int getPrimaryInterface(); +void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, + uint64_t destmac, uint16_t destport, uint64_t sourcemac, + uint32_t sourceip, uint16_t sourceport); +void calcChecksum(udp_header *udp); +int configureMAC(); +int setDetectorPosition(int pos[]); +int *getDetectorPosition(); + +// very detector specific + +// jungfrau/moench specific - powerchip, autocompdisable, clockdiv, asictimer, +// clock, pll, flashing firmware +void setADCPipeline(int val); +int getADCPipeline(); +int setReadNRows(int value); +int getReadNRows(); +void initReadoutConfiguration(); +int powerChip(int on); +int setReadoutSpeed(int val); +int getReadoutSpeed(int *retval); +int setPhase(enum CLKINDEX ind, int val, int degrees); +int getPhase(enum CLKINDEX ind, int degrees); +int getMaxPhase(enum CLKINDEX ind); +int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval); +int setThresholdTemperature(int val); +int setTemperatureControl(int val); +int setTemperatureEvent(int val); +void alignDeserializer(); +int getFlipRows(); +void setFlipRows(int arg); + +int getTenGigaFlowControl(); +int setTenGigaFlowControl(int value); +int getTransmissionDelayFrame(); +int setTransmissionDelayFrame(int value); + +// aquisition +int startStateMachine(); +#ifdef VIRTUAL +void *start_timer(void *arg); +#endif +int stopStateMachine(); +int softwareTrigger(int block); +enum runStatus getRunStatus(); +void waitForAcquisitionEnd(); +u_int32_t runBusy(); + +// common +int calculateDataBytes(); +int getTotalNumberOfChannels(); +int getNumberOfChips(); +int getNumberOfDACs(); +int getNumberOfChannelsPerChip(); \ No newline at end of file diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index ffda96dac..e4f56bed2 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.h new file mode 100644 index 000000000..1032fcc32 --- /dev/null +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.h @@ -0,0 +1,214 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package +#include "sls/sls_detector_defs.h" +#include "slsDetectorServer_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h + +#include "mythen3.h" +#include "nios.h" +#include "programViaNios.h" + +#include // FILE +#include +#include + +/**************************************************** +This functions are used by the slsDetectroServer_funcs interface. +Here are the definitions, but the actual implementation should be done for each +single detector. + +****************************************************/ + +enum interfaceType { OUTER, INNER }; +typedef struct udpStruct_s { + uint16_t srcport; + uint16_t srcport2; + uint16_t dstport; + uint16_t dstport2; + uint64_t srcmac; + uint64_t srcmac2; + uint64_t dstmac; + uint64_t dstmac2; + uint32_t srcip; + uint32_t srcip2; + uint32_t dstip; + uint32_t dstip2; +} udpStruct; +#define MAC_ADDRESS_SIZE 18 + +// basic tests +int isInitCheckDone(); +int getInitResult(char **mess); +void basictests(); +int checkType(); +int testFpga(); +int testBus(); + +void setTestImageMode(int ival); +int getTestImageMode(); + +// Ids +void getServerVersion(char *version); +u_int64_t getFirmwareVersion(); +u_int64_t getFirmwareAPIVersion(); +void getHardwareVersion(char *version); +u_int16_t getHardwareVersionNumber(); +int isHardwareVersion_1_0(); +u_int32_t getDetectorNumber(); +int getModuleId(int *ret, char *mess); +int updateModuleId(); +void setModuleId(int modid); +u_int64_t getDetectorMAC(); +u_int32_t getDetectorIP(); + +// initialization +void initControlServer(); +void initStopServer(); + +// set up detector +int allocateDetectorStructureMemory(); +void setupDetector(); +int resetToDefaultDacs(int hardReset); +int getDefaultDac(enum DACINDEX index, enum detectorSettings sett, int *retval); +int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value); +void setASICDefaults(); +void setADIFDefaults(); +int checkCommandLineConfiguration(); + +// firmware functions (resets) +void cleanFifos(); +void resetCore(); +void resetPeripheral(); + +// parameters - dr, roi +int setDynamicRange(int dr); +int getDynamicRange(int *retval); + +// parameters - readout +int setParallelMode(int mode); +int getParallelMode(); + +// parameters - timer +void setNumFrames(int64_t val); +int64_t getNumFrames(); +void setNumTriggers(int64_t val); +int64_t getNumTriggers(); +int setPeriod(int64_t val); +int64_t getPeriod(); +void setNumIntGates(int val); +void setNumGates(int val); +int getNumGates(); +void updateGatePeriod(); +int64_t getGatePeriod(); +int setExpTime(int gateIndex, int64_t val); +int64_t getExpTime(int gateIndex); +int setGateDelay(int gateIndex, int64_t val); +int64_t getGateDelay(int gateIndex); + +void setCounterMask(uint32_t arg); +void setCounterMaskWithUpdateFlag(uint32_t arg, int updateMaskFlag); +uint32_t getCounterMask(); +void updatePacketizing(); + +int64_t getNumFramesLeft(); +int64_t getNumTriggersLeft(); +int setDelayAfterTrigger(int64_t val); +int64_t getDelayAfterTrigger(); +int64_t getDelayAfterTriggerLeft(); +int64_t getPeriodLeft(); +int64_t getFramesFromStart(); +int64_t getActualTime(); +int64_t getMeasurementTime(); + +// parameters - module, settings +void getModule(sls_detector_module *myMod); +int setModule(sls_detector_module myMod, char *mess); +int setTrimbits(int *trimbits); +int setAllTrimbits(int val); +int getAllTrimbits(); +enum detectorSettings setSettings(enum detectorSettings sett); +enum detectorSettings getSettings(); + +// parameters - threshold +int getThresholdEnergy(int counterIndex); +void setThresholdEnergy(int counterIndex, int eV); + +// parameters - dac, adc, hv +void setDAC(enum DACINDEX ind, int val, int mV, int counterEnableCheck); +void setGeneralDAC(enum DACINDEX ind, int val, int mV); +void setVthDac(int index, int enable); +int getDAC(enum DACINDEX ind, int mV); +int getMaxDacSteps(); + +int getADC(enum ADCINDEX ind, int *value); +int setHighVoltage(int val); +int getHighVoltage(int *retval); + +// parameters - timing, extsig +int isMaster(int *retval); +void setTiming(enum timingMode arg); +enum timingMode getTiming(); +void setInitialExtSignals(); +int setChipStatusRegister(int csr); +int setGainCaps(int caps); +int setInterpolation(int enable); +int setPumpProbe(int enable); +int setDigitalPulsing(int enable); +int setAnalogPulsing(int enable); +int setNegativePolarity(int enable); +int setDACS(int *dacs); +void setExtSignal(int signalIndex, enum externalSignalFlag mode); +int getExtSignal(int signalIndex); + +// configure mac +int getNumberofUDPInterfaces(); +int getNumberofDestinations(int *retval); +int setNumberofDestinations(int value); +int getFirstUDPDestination(); +void setFirstUDPDestination(int value); +void calcChecksum(udp_header *udp); +int configureMAC(); +int setDetectorPosition(int pos[]); +int *getDetectorPosition(); +int enableTenGigabitEthernet(int val); + +// very detector specific +int checkDetectorType(char *mess); +int powerChip(int on); +int setPhase(enum CLKINDEX ind, int val, int degrees); +int getPhase(enum CLKINDEX ind, int degrees); +int getMaxPhase(enum CLKINDEX ind); +int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval); +// void setFrequency(enum CLKINDEX ind, int val); +int getFrequency(enum CLKINDEX ind); +int getVCOFrequency(enum CLKINDEX ind); +int getMaxClockDivider(); +int setClockDivider(enum CLKINDEX ind, int val); +int setClockDividerWithTimeUpdateOption(enum CLKINDEX ind, int val, + int timeUpdate); +int getClockDivider(enum CLKINDEX ind); +int setReadoutSpeed(int val); +int getReadoutSpeed(int *retval); +int setBadChannels(int numChannels, int *channelList); +int *getBadChannels(int *numChannels); + +int getTransmissionDelayFrame(); +int setTransmissionDelayFrame(int value); + +// aquisition +int startStateMachine(); +#ifdef VIRTUAL +void *start_timer(void *arg); +#endif +int stopStateMachine(); +int softwareTrigger(); +int startReadOut(); +enum runStatus getRunStatus(); +void waitForAcquisitionEnd(); +u_int32_t runBusy(); + +// common +int calculateDataBytes(); +int getTotalNumberOfChannels(); +int getNumberOfChips(); +int getNumberOfDACs(); +int getNumberOfChannelsPerChip(); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h deleted file mode 100644 index 7114c7f4b..000000000 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ /dev/null @@ -1,742 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-other -// Copyright (C) 2021 Contributors to the SLS Detector Package -#include "sls/sls_detector_defs.h" -#include "slsDetectorServer_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h - -#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD) -#include "AD9257.h" // commonServerFunctions.h, blackfin.h, ansi.h -#endif - -#if defined(MYTHEN3D) || defined(GOTTHARD2D) -#include "nios.h" -#include "programViaNios.h" -#elif defined(CHIPTESTBOARDD) || defined(JUNGFRAUD) || defined(MOENCHD) -#include "blackfin.h" -#include "programViaBlackfin.h" -#endif - -#ifdef ARMPROCESSOR -#include "arm64.h" -#include "programViaArm.h" -#endif - -#ifdef MYTHEN3D -#include "mythen3.h" -#endif - -#include // FILE -#include -#include - -/**************************************************** -This functions are used by the slsDetectroServer_funcs interface. -Here are the definitions, but the actual implementation should be done for each -single detector. - -****************************************************/ - -enum interfaceType { OUTER, INNER }; -typedef struct udpStruct_s { - uint16_t srcport; - uint16_t srcport2; - uint16_t dstport; - uint16_t dstport2; - uint64_t srcmac; - uint64_t srcmac2; - uint64_t dstmac; - uint64_t dstmac2; - uint32_t srcip; - uint32_t srcip2; - uint32_t dstip; - uint32_t dstip2; -} udpStruct; -#define MAC_ADDRESS_SIZE 18 - -// basic tests -int isInitCheckDone(); -int getInitResult(char **mess); -void basictests(); -#if !defined(EIGERD) -int checkType(); -int testFpga(); -#ifdef XILINX_CHIPTESTBOARDD -int testFixedFPGAPattern(); -#else -int testBus(); -#endif -#endif - -#if ((defined(EIGERD) || defined(JUNGFRAUD) || defined(MOENCHD)) && \ - defined(VIRTUAL)) -void setTestImageMode(int ival); -int getTestImageMode(); -#endif - -// Ids -void getServerVersion(char *version); -u_int64_t getFirmwareVersion(); -#ifdef EIGERD -uint64_t getFrontEndFirmwareVersion(enum fpgaPosition fpgaPosition); -#endif -u_int64_t getFirmwareAPIVersion(); -void getHardwareVersion(char *version); -#ifdef EIGERD -int getHardwareVersionNumber(); -#else -#ifndef XILINX_CHIPTESTBOARDD -u_int16_t getHardwareVersionNumber(); -#endif -#endif -#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD) -u_int16_t getHardwareSerialNumber(); -#endif -#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARD2D) || \ - defined(MYTHEN3D) -int isHardwareVersion_1_0(); -#endif -#if defined(JUNGFRAUD) -int getChipVersion(); -void setChipVersion(int version); -#endif -#ifndef EIGERD -u_int32_t getDetectorNumber(); -#endif - -#if defined(GOTTHARD2D) || defined(EIGERD) || defined(MYTHEN3D) || \ - defined(JUNGFRAUD) || defined(MOENCHD) -int getModuleId(int *ret, char *mess); -int updateModuleId(); -#ifndef EIGERD -void setModuleId(int modid); -#endif -#endif -u_int64_t getDetectorMAC(); -u_int32_t getDetectorIP(); - -#if defined(CHIPTESTBOARDD) -int enableBlackfinAMCExternalAccessExtension(char *mess); -#endif - -// initialization -void initControlServer(); -void initStopServer(); -#ifdef EIGERD -int updateModuleConfiguration(); -int getModuleConfiguration(int *m, int *t, int *n); -#ifdef VIRTUAL -void checkVirtual9MFlag(); -#endif -#endif - -// set up detector -#if defined(EIGERD) && !defined(VIRTUAL) -void setupFebBeb(); -#endif -#if defined(EIGERD) || defined(MYTHEN3D) -int allocateDetectorStructureMemory(); -#endif -void setupDetector(); -#if defined(CHIPTESTBOARDD) -int updateDatabytesandAllocateRAM(); -void updateDataBytes(); -#endif - -#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) -int resetToDefaultDacs(int hardReset); -int getDefaultDac(enum DACINDEX index, enum detectorSettings sett, int *retval); -int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value); -#endif -#if defined(MYTHEN3D) || defined(GOTTHARD2D) -void setASICDefaults(); -#endif -#ifdef MYTHEN3D -void setADIFDefaults(); -#endif -#if defined(GOTTHARD2D) || defined(EIGERD) || defined(JUNGFRAUD) -int readConfigFile(); -#endif -#if defined(GOTTHARD2D) || defined(EIGERD) || defined(MYTHEN3D) -int checkCommandLineConfiguration(); -#endif -#ifdef EIGERD -void resetToHardwareSettings(); -#endif - -// advanced read/write reg -#ifdef EIGERD -int writeRegister(uint32_t offset, uint32_t data, int validate); -int readRegister(uint32_t offset, uint32_t *retval); -int setBit(const uint32_t addr, const int nBit, int validate); -int clearBit(const uint32_t addr, const int nBit, int validate); -int getBit(const uint32_t addr, const int nBit, int *retval); -#endif - -// firmware functions (resets) -#if defined(XILINX_CHIPTESTBOARDD) -void cleanFifos(); -void resetFlow(); -int waitTransceiverReset(char *mess); -#ifdef VIRTUAL -void setTransceiverAlignment(int align); -#endif -int isTransceiverAligned(); -int waitTransceiverAligned(char *mess); -int configureTransceiver(char *mess); -int isChipConfigured(); -int powerChip(int on, char *mess); -int getPowerChip(); -int configureChip(char *mess); -int readConfigFile(char *mess, char *fileName, char *fileType); -int resetChip(char *mess); -#endif -#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD) || \ - defined(MYTHEN3D) || defined(GOTTHARD2D) -void cleanFifos(); -void resetCore(); -void resetPeripheral(); -#endif - -// parameters - dr, roi -int setDynamicRange(int dr); -int getDynamicRange(int *retval); -#if defined(JUNGFRAUD) || defined(MOENCHD) -void setADCInvertRegister(uint32_t val); -uint32_t getADCInvertRegister(); -#endif -#if defined(CHIPTESTBOARDD) -int setADCEnableMask(uint32_t mask); -uint32_t getADCEnableMask(); -void setADCEnableMask_10G(uint32_t mask); -uint32_t getADCEnableMask_10G(); -int setTransceiverEnableMask(uint32_t mask); -uint32_t getTransceiverEnableMask(); -void setADCInvertRegister(uint32_t val); -uint32_t getADCInvertRegister(); -#endif -#ifdef XILINX_CHIPTESTBOARDD -void setADCEnableMask_10G(uint32_t mask); -uint32_t getADCEnableMask_10G(); -int setTransceiverEnableMask(uint32_t mask); -uint32_t getTransceiverEnableMask(); -#endif -#if defined(CHIPTESTBOARDD) -int setExternalSamplingSource(int val); -int setExternalSampling(int val); -#endif - -// parameters - readout -#if defined(EIGERD) || defined(MYTHEN3D) || defined(GOTTHARD2D) || \ - defined(MOENCHD) -int setParallelMode(int mode); -int getParallelMode(); -#endif -#ifdef EIGERD -int setOverFlowMode(int mode); -int getOverFlowMode(); -#endif -#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) -int setReadoutMode(enum readoutMode mode); -int getReadoutMode(); -#endif - -// parameters - timer -#if defined(JUNGFRAUD) -int selectStoragecellStart(int pos); -int getMaxStoragecellStart(); -#endif -#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(EIGERD) || \ - defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) || \ - defined(GOTTHARD2D) -int setNextFrameNumber(uint64_t value); -int getNextFrameNumber(uint64_t *value); -#endif -void setNumFrames(int64_t val); -int64_t getNumFrames(); -void setNumTriggers(int64_t val); -int64_t getNumTriggers(); -#ifndef MYTHEN3D -int setExpTime(int64_t val); -int64_t getExpTime(); -#endif -int setPeriod(int64_t val); -int64_t getPeriod(); -#ifdef MYTHEN3D -void setNumIntGates(int val); -void setNumGates(int val); -int getNumGates(); -void updateGatePeriod(); -int64_t getGatePeriod(); -int setExpTime(int gateIndex, int64_t val); -int64_t getExpTime(int gateIndex); -int setGateDelay(int gateIndex, int64_t val); -int64_t getGateDelay(int gateIndex); -#endif -#ifdef GOTTHARD2D -void setNumBursts(int64_t val); -int64_t getNumBursts(); -int setBurstPeriod(int64_t val); -int64_t getBurstPeriod(); -#endif -#ifdef EIGERD -int setSubExpTime(int64_t val); -int64_t getSubExpTime(); -int setSubDeadTime(int64_t val); -int64_t getSubDeadTime(); -int64_t getMeasuredPeriod(); -int64_t getMeasuredSubPeriod(); -#endif -#if defined(JUNGFRAUD) -void setNumAdditionalStorageCells(int val); -int getNumAdditionalStorageCells(); -int setStorageCellDelay(int64_t val); -int64_t getStorageCellDelay(); -#endif -#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) -int setNumAnalogSamples(int val); -int getNumAnalogSamples(); -int setNumDigitalSamples(int val); -int getNumDigitalSamples(); -int setNumTransceiverSamples(int val); -int getNumTransceiverSamples(); -#endif -#ifdef MYTHEN3D -void setCounterMask(uint32_t arg); -void setCounterMaskWithUpdateFlag(uint32_t arg, int updateMaskFlag); -uint32_t getCounterMask(); -void updatePacketizing(); -#endif - -#ifndef EIGERD -int64_t getNumFramesLeft(); -int64_t getNumTriggersLeft(); -#endif -#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD) || \ - defined(MYTHEN3D) || defined(GOTTHARD2D) || defined(XILINX_CHIPTESTBOARDD) -int setDelayAfterTrigger(int64_t val); -int64_t getDelayAfterTrigger(); -int64_t getDelayAfterTriggerLeft(); -int64_t getPeriodLeft(); -#endif -#ifdef GOTTHARD2D -int64_t getNumBurstsLeft(); -#endif -#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD) || \ - defined(MYTHEN3D) || defined(GOTTHARD2D) || defined(XILINX_CHIPTESTBOARDD) -int64_t getFramesFromStart(); -int64_t getActualTime(); -int64_t getMeasurementTime(); -#endif - -// parameters - module, settings -#if defined(MYTHEN3D) || defined(EIGERD) -void getModule(sls_detector_module *myMod); -#endif -#if (!defined(CHIPTESTBOARDD)) && (!defined(GOTTHARD2D)) -int setModule(sls_detector_module myMod, char *mess); -#endif - -#ifdef EIGERD -int setTrimbits(int *chanregs, char *mess); -#endif -#ifdef MYTHEN3D -int setTrimbits(int *trimbits); -int setAllTrimbits(int val); -int getAllTrimbits(); -#endif -#ifndef XILINX_CHIPTESTBOARDD -#ifndef CHIPTESTBOARDD -enum detectorSettings setSettings(enum detectorSettings sett); -#endif -enum detectorSettings getSettings(); -#endif -#if defined(JUNGFRAUD) -enum gainMode getGainMode(); -void setGainMode(enum gainMode mode); -#endif - -// parameters - threshold -#ifdef EIGERD -int getThresholdEnergy(); -int setThresholdEnergy(int ev); -#endif -#ifdef MYTHEN3D -int getThresholdEnergy(int counterIndex); -void setThresholdEnergy(int counterIndex, int eV); -#endif -// parameters - dac, adc, hv - -#ifdef GOTTHARD2D -int setOnChipDAC(enum ONCHIP_DACINDEX ind, int chipIndex, int val); -int getOnChipDAC(enum ONCHIP_DACINDEX ind, int chipIndex); -#endif -#ifdef MYTHEN3D -void setDAC(enum DACINDEX ind, int val, int mV, int counterEnableCheck); -void setGeneralDAC(enum DACINDEX ind, int val, int mV); -void setVthDac(int index, int enable); -#else -void setDAC(enum DACINDEX ind, int val, int mV); -#endif -int getDAC(enum DACINDEX ind, int mV); -int getMaxDacSteps(); -#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) -int dacToVoltage(int dac); -int checkVLimitCompliant(int mV); -int checkVLimitDacCompliant(int dac); -int getVLimit(); -void setVLimit(int l); -#endif - -#ifdef CHIPTESTBOARDD -int isVchipValid(int val); -int getVchip(); -void setVchip(int val); -int getVChipToSet(enum DACINDEX ind, int val); -int getDACIndexFromADCIndex(enum ADCINDEX ind); -int getADCIndexFromDACIndex(enum DACINDEX ind); -int isPowerValid(enum DACINDEX ind, int val); -int getPower(); -void setPower(enum DACINDEX ind, int val); -void powerOff(); -#elif XILINX_CHIPTESTBOARDD -int getBitOffsetFromDACIndex(enum DACINDEX ind); -int isPowerValid(enum DACINDEX ind, int val); -int getPower(); -void setPower(enum DACINDEX ind, int val); -#endif - -#if defined(MYTHEN3D) || defined(GOTTHARD2D) || defined(XILINX_CHIPTESTBOARDD) -int getADC(enum ADCINDEX ind, int *value); -#else -int getADC(enum ADCINDEX ind); -#endif -#ifdef CHIPTESTBOARDD -int getSlowADC(int ichan); -int getSlowADCTemperature(); -#endif -#ifdef XILINX_CHIPTESTBOARDD -int getSlowADC(int ichan, int *retval); -int getTemperature(int *retval); -#else -int setHighVoltage(int val); -#if defined(MYTHEN3D) || defined(GOTTHARD2D) -int getHighVoltage(int *retval); -#endif -#endif - -// parameters - timing, extsig -#if defined(EIGERD) || defined(GOTTHARD2D) || defined(JUNGFRAUD) || \ - defined(MOENCHD) -int setMaster(enum MASTERINDEX m); -#endif -#ifdef EIGERD -int setTop(enum TOPINDEX t); -int isTop(int *retval); -#endif -#if defined(MYTHEN3D) || defined(EIGERD) || defined(GOTTHARD2D) || \ - defined(JUNGFRAUD) || defined(MOENCHD) -int isMaster(int *retval); -#endif - -#if defined(JUNGFRAUD) || defined(MOENCHD) -int getSynchronization(); -void setSynchronization(int enable); -#endif - -#ifdef GOTTHARD2D -void updatingRegisters(); -int updateClockDivs(); -#endif -void setTiming(enum timingMode arg); -enum timingMode getTiming(); -#ifdef MYTHEN3D -void setInitialExtSignals(); -int setChipStatusRegister(int csr); -int setGainCaps(int caps); -int setInterpolation(int enable); -int setPumpProbe(int enable); -int setDigitalPulsing(int enable); -int setAnalogPulsing(int enable); -int setNegativePolarity(int enable); -int setDACS(int *dacs); -#endif -#if defined(MYTHEN3D) -void setExtSignal(int signalIndex, enum externalSignalFlag mode); -int getExtSignal(int signalIndex); -#endif - -// configure mac -#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARD2D) -void setNumberofUDPInterfaces(int val); -#endif -int getNumberofUDPInterfaces(); - -#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(EIGERD) || \ - defined(MYTHEN3D) || defined(GOTTHARD2D) -int getNumberofDestinations(int *retval); -int setNumberofDestinations(int value); -#endif -#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(MYTHEN3D) || \ - defined(GOTTHARD2D) -int getFirstUDPDestination(); -void setFirstUDPDestination(int value); -#endif -#if defined(JUNGFRAUD) || defined(MOENCHD) -void selectPrimaryInterface(int val); -int getPrimaryInterface(); -void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, - uint64_t destmac, uint16_t destport, uint64_t sourcemac, - uint32_t sourceip, uint16_t sourceport); -#endif -#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARD2D) || \ - defined(MYTHEN3D) || defined(CHIPTESTBOARDD) || \ - defined(XILINX_CHIPTESTBOARDD) -void calcChecksum(udp_header *udp); -#endif - -int configureMAC(); -int setDetectorPosition(int pos[]); -int *getDetectorPosition(); - -#ifdef EIGERD -int setQuad(int value); -int getQuad(); -int setInterruptSubframe(int value); -int getInterruptSubframe(); -int setReadNRows(int value); -int getReadNRows(); -#endif -#if defined(CHIPTESTBOARDD) || defined(EIGERD) || defined(MYTHEN3D) -int enableTenGigabitEthernet(int val); -#endif - -// very detector specific - -// chip test board specific - configure frequency, phase, pll, -// flashing firmware -#if defined(CHIPTESTBOARDD) -int setPhase(enum CLKINDEX ind, int val, int degrees); -int getPhase(enum CLKINDEX ind, int degrees); -int getMaxPhase(enum CLKINDEX ind); -int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval); -void configureSyncFrequency(enum CLKINDEX ind); -void setADCPipeline(int val); -int getADCPipeline(); -void setDBITPipeline(int val); -int getDBITPipeline(); -int setLEDEnable(int enable); -void setDigitalIODelay(uint64_t pinMask, int delay); -#endif - -#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) -int setFrequency(enum CLKINDEX ind, int val); -int getFrequency(enum CLKINDEX ind); -#endif - -// jungfrau/moench specific - powerchip, autocompdisable, clockdiv, asictimer, -// clock, pll, flashing firmware -#if defined(MOENCHD) -void setADCPipeline(int val); -int getADCPipeline(); -#endif -#if defined(JUNGFRAUD) || defined(MOENCHD) -int setReadNRows(int value); -int getReadNRows(); -void initReadoutConfiguration(); -int powerChip(int on); -#ifndef MOENCHD -int isChipConfigured(); -void configureChip(); -int autoCompDisable(int on); -int setComparatorDisableTime(int64_t val); -int64_t getComparatorDisableTime(); -void configureASICTimer(); -#endif -int setReadoutSpeed(int val); -int getReadoutSpeed(int *retval); -int setPhase(enum CLKINDEX ind, int val, int degrees); -int getPhase(enum CLKINDEX ind, int degrees); -int getMaxPhase(enum CLKINDEX ind); -int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval); -int setThresholdTemperature(int val); -int setTemperatureControl(int val); -int setTemperatureEvent(int val); -void alignDeserializer(); -int getFlipRows(); -void setFlipRows(int arg); -#ifndef MOENCHD -int setFilterResistor(int value); -int getFilterResistor(); -int getNumberOfFilterCells(); -void setNumberOfFilterCells(int iCell); -void disableCurrentSource(); -void enableCurrentSource(int fix, uint64_t select, int normal); -int getCurrentSource(); -int getFixCurrentSource(); -int getNormalCurrentSource(); -uint64_t getSelectCurrentSource(); -int getPedestalMode(); -void getPedestalParameters(uint8_t *frames, uint16_t *loops); -void setPedestalMode(int enable, uint8_t frames, uint16_t loops); -int setTimingInfoDecoder(enum timingInfoDecoder val); -int getTimingInfoDecoder(enum timingInfoDecoder *retval); -int getElectronCollectionMode(); -void setElectronCollectionMode(int enable); -#endif - -// eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter -#elif EIGERD -int setReadoutSpeed(int val); -int getReadoutSpeed(int *retval); -int setIODelay(int val); -int setCounterBit(int val); -int pulsePixel(int n, int x, int y); -int pulsePixelNMove(int n, int x, int y); -int pulseChip(int n); -int updateRateCorrection(char *mess); -int validateAndSetRateCorrection(int64_t tau_ns, char *mess); -int setRateCorrection(int64_t custom_tau_in_nsec); -int getRateCorrectionEnable(); -int getDefaultSettingsTau_in_nsec(); -void setDefaultSettingsTau_in_nsec(int t); -int64_t getCurrentTau(); -void setExternalGating(int enable[]); -int setAllTrimbits(int val); -int getAllTrimbits(); -int getBebFPGATemp(); -int setActivate(int enable); -int getActivate(int *retval); -int getDataStream(enum portPosition port, int *retval); -int setDataStream(enum portPosition port, int enable); - -#elif MYTHEN3D -int checkDetectorType(char *mess); -int powerChip(int on); -int setPhase(enum CLKINDEX ind, int val, int degrees); -int getPhase(enum CLKINDEX ind, int degrees); -int getMaxPhase(enum CLKINDEX ind); -int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval); -// void setFrequency(enum CLKINDEX ind, int val); -int getFrequency(enum CLKINDEX ind); -int getVCOFrequency(enum CLKINDEX ind); -int getMaxClockDivider(); -int setClockDivider(enum CLKINDEX ind, int val); -int setClockDividerWithTimeUpdateOption(enum CLKINDEX ind, int val, - int timeUpdate); -int getClockDivider(enum CLKINDEX ind); -int setReadoutSpeed(int val); -int getReadoutSpeed(int *retval); -#elif GOTTHARD2D -int checkDetectorType(char *mess); -int powerChip(int on, char *mess); -int getPowerChip(); -int isChipConfigured(); -int configureChip(char *mess); -void setDBITPipeline(int val); -int getDBITPipeline(); -int setPhase(enum CLKINDEX ind, int val, int degrees); -int getPhase(enum CLKINDEX ind, int degrees); -int getMaxPhase(enum CLKINDEX ind); -int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval); -// void setFrequency(enum CLKINDEX ind, int val); -int getFrequency(enum CLKINDEX ind); -int getVCOFrequency(enum CLKINDEX ind); -int setReadoutSpeed(int val); -int getReadoutSpeed(int *retval); -int getMaxClockDivider(); -int setClockDivider(enum CLKINDEX ind, int val); -int getClockDivider(enum CLKINDEX ind); -int setInjectChannel(int offset, int increment); -void getInjectedChannels(int *offset, int *increment); -int setVetoReference(int gainIndex, int value); -int setVetoPhoton(int chipIndex, int *gainIndices, int *values); -int configureASICVetoReference(int chipIndex, int *gainIndices, int *values); -int getVetoPhoton(int chipIndex, int *retvals, int *gainRetvals); -int setADCConfiguration(int chipIndex, int adcIndex, int value); -int getADCConfiguration(int chipIndex, int adcIndex); -int setBurstModeinFPGA(enum burstMode value); -int setBurstMode(enum burstMode burst); -int configureASICGlobalSettings(); -enum burstMode getBurstMode(); -int setCDSGain(int enable); -int getCDSGain(); -int setFilterResistor(int value); -int getFilterResistor(); -void setCurrentSource(int value); -int getCurrentSource(); -void setTimingSource(enum timingSourceType value); -enum timingSourceType getTimingSource(); -void setVeto(int enable); -int getVeto(); -void setVetoStream(int value); -int getVetoStream(); -enum vetoAlgorithm getVetoAlgorithm(enum streamingInterface interface); -void setVetoAlgorithm(enum vetoAlgorithm alg, - enum streamingInterface interface); -#endif - -#if defined(GOTTHARD2D) || defined(MYTHEN3D) -int setBadChannels(int numChannels, int *channelList); -int *getBadChannels(int *numChannels); -#endif - -#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(EIGERD) -int getTenGigaFlowControl(); -int setTenGigaFlowControl(int value); -#endif -#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(EIGERD) || \ - defined(MYTHEN3D) -int getTransmissionDelayFrame(); -int setTransmissionDelayFrame(int value); -#endif -#ifdef EIGERD -int getTransmissionDelayLeft(); -int setTransmissionDelayLeft(int value); -int getTransmissionDelayRight(); -int setTransmissionDelayRight(int value); -#endif - -// aquisition -int startStateMachine(); -#ifdef VIRTUAL -void *start_timer(void *arg); -#endif -int stopStateMachine(); -#if defined(MYTHEN3D) || defined(XILINX_CHIPTESTBOARDD) -int softwareTrigger(); -#endif -#if defined(EIGERD) || defined(JUNGFRAUD) || defined(MOENCHD) -int softwareTrigger(int block); -#endif -#if defined(EIGERD) || defined(MYTHEN3D) || defined(CHIPTESTBOARDD) -int startReadOut(); -#endif -enum runStatus getRunStatus(); -#ifdef EIGERD -void waitForAcquisitionEnd(int *ret, char *mess); -#else -void waitForAcquisitionEnd(); -#endif -#if defined(CHIPTESTBOARDD) -int validateUDPSocket(); -void readandSendUDPFrames(); -void unsetFifoReadStrobes(); -int readSample(int ns); -uint32_t checkDataInFifo(); -int checkFifoForEndOfAcquisition(); -int readFrameFromFifo(); -#endif - -#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD) || \ - defined(MYTHEN3D) || defined(GOTTHARD2D) || defined(XILINX_CHIPTESTBOARDD) -u_int32_t runBusy(); -#endif - -// common -int calculateDataBytes(); -int getTotalNumberOfChannels(); -#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) -void getNumberOfChannels(int *nchanx, int *nchany); -#endif -int getNumberOfChips(); -int getNumberOfDACs(); -int getNumberOfChannelsPerChip(); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index 2c7e60ce9..e43148b83 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -338,3 +338,5 @@ int get_collection_mode(int); int set_collection_mode(int); int get_pattern_wait_interval(int); int set_pattern_wait_interval(int); +int spi_read(int); +int spi_write(int); diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 157daa377..af0f205ea 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -7,6 +7,10 @@ #include "sls/sls_detector_funcs.h" #include "slsDetectorFunctionList.h" +#include +#include +#include + #if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) || \ defined(MYTHEN3D) #include "Pattern.h" @@ -19,6 +23,8 @@ #include #include +#include + // defined in the detector specific Makefile #ifdef EIGERD const enum detectorType myDetectorType = EIGER; @@ -515,6 +521,8 @@ void function_table() { flist[F_SET_COLLECTION_MODE] = &set_collection_mode; flist[F_GET_PATTERN_WAIT_INTERVAL] = &get_pattern_wait_interval; flist[F_SET_PATTERN_WAIT_INTERVAL] = &set_pattern_wait_interval; + flist[F_SPI_READ] = &spi_read; + flist[F_SPI_WRITE] = &spi_write; // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { LOG(logERROR, ("The last detector function enum has reached its " @@ -11095,4 +11103,315 @@ int set_pattern_wait_interval(int file_des) { #endif return Server_SendResult(file_des, INT64, NULL, 0); +} + +/** + * Non destructive read from SPI register. Read n_bytes by shifting in dummy + * data while keeping csn 0 after the operation. Shift the read out data back + * in to restore the register. + */ + +int spi_read(int file_des) { +#if !defined(XILINX_CHIPTESTBOARDD) + functionNotImplemented(); + return sendError(file_des); +#endif + + int chip_id = 0; + if (receiveData(file_des, &chip_id, sizeof(chip_id), INT32) < 0) { + return printSocketReadError(); + } + if (chip_id < 0 || chip_id > 15) { + sprintf(mess, "Invalid chip_id %d. Must be 0-15\n", chip_id); + return sendError(file_des); + } + + int register_id = 0; + if (receiveData(file_des, ®ister_id, sizeof(register_id), INT32) < 0) { + return printSocketReadError(); + } + if (register_id < 0 || register_id > 15) { + sprintf(mess, "Invalid register_id %d. Must be 0-15\n", register_id); + return sendError(file_des); + } + + int n_bytes = 0; + if (receiveData(file_des, &n_bytes, sizeof(n_bytes), INT32) < 0) { + return printSocketReadError(); + } + if (n_bytes < 1) { + sprintf(mess, + "Invalid n_bytes %d. Must ask for a read of at least 1 byte\n", + n_bytes); + return sendError(file_des); + } + + LOG(logINFO, + ("SPI Read Requested: chip_id=%d, register_id=%d, n_bytes=%d\n", + chip_id, register_id, n_bytes)); + +#ifdef VIRTUAL + // For the virtual detector we create a fake register to read from + // and fill it with 0,2,4,6,... This way we can check that copying + // of the data works as expected + uint8_t *fake_register = malloc(n_bytes); + if (fake_register == NULL) { + LOG(logERROR, ("Could not allocate memory for fake register\n")); + exit(EXIT_FAILURE); + } + for (int i = 0; i < n_bytes; i++) { + fake_register[i] = (uint8_t)((i * 2) % 256); + } +#else + int spifd = open("/dev/spidev2.0", O_RDWR); + LOG(logINFO, ("SPI Read: opened spidev2.0 with fd=%d\n", spifd)); + if (spifd < 0) { + sprintf(mess, "Could not open /dev/spidev2.0\n"); + return sendError(file_des); + } +#endif + + // Allocate dummy data to shif in, we keep a copy of this + // to double check that we access a register of the correct size + uint8_t *dummy_data = malloc(n_bytes); + if (dummy_data == NULL) { + LOG(logERROR, ("Could not allocate memory for dummy data\n")); + exit(EXIT_FAILURE); + } + for (int i = 0; i < n_bytes; i++) { + dummy_data[i] = (uint8_t)(i % 256); + } + + // Allocate actual data buffer this holds the data we read out + // and that we need to write back to restore the register + uint8_t *actual_data = malloc(n_bytes); + if (actual_data == NULL) { + LOG(logERROR, ("Could not allocate memory for actual data\n")); + exit(EXIT_FAILURE); + } + memset(actual_data, 0, n_bytes); + + // Setup sending and receiving buffers and the spi_ioc_transfer struct. + // We need one more byte before the actual data to send chip_id and + // register_id + uint8_t *local_tx = malloc(n_bytes + 1); + if (local_tx == NULL) { + LOG(logERROR, ("Could not allocate memory for local_tx\n")); + exit(EXIT_FAILURE); + } + uint8_t *local_rx = malloc(n_bytes + 1); + if (local_rx == NULL) { + LOG(logERROR, ("Could not allocate memory for local_rx\n")); + exit(EXIT_FAILURE); + } + + struct spi_ioc_transfer send_cmd[1]; + memset(send_cmd, 0, sizeof(send_cmd)); + send_cmd[0].len = n_bytes + 1; + send_cmd[0].tx_buf = (unsigned long)local_tx; + send_cmd[0].rx_buf = (unsigned long)local_rx; + + // 0 - Normal operation, 1 - CSN remains zero after operation + // We use cs_change = 1 to not close the SPI transaction and + // allow for shifting the read out data back in to restore the + // regitster + send_cmd[0].cs_change = 1; + + // First byte of the message is 4 bits chip_id then 4 bits register_id + local_tx[0] = ((chip_id & 0xF) << 4) | (register_id & 0xF); + + // Then the data follows + for (int i = 0; i < n_bytes; i++) + local_tx[i + 1] = dummy_data[i]; + +#ifdef VIRTUAL + // For the virtual detector we have to copy the data + + // First byte shuuld be 0x00 + local_rx[0] = 0; + + // Then we copy the data from the fake register to the local_rx buffer + // and the local_tx data to the fake register to emulate the shifting in and + // out of the data + for (int i = 0; i < n_bytes; i++) { + local_rx[i + 1] = fake_register[i]; + fake_register[i] = local_tx[i + 1]; + } + +#else + // For the real detector we do the transfer here + if (ioctl(spifd, SPI_IOC_MESSAGE(1), &send_cmd) < 0) { + // cleanup since we return early + close(spifd); + free(local_tx); + free(local_rx); + free(dummy_data); + free(actual_data); + + // Send error message + sprintf(mess, "SPI write failed with %d:%s\n", errno, strerror(errno)); + return sendError(file_des); + } +#endif + + // Copy everything but the first received byte to the user. First byte + // should be 0x00 anyway + for (int i = 0; i < n_bytes; i++) + actual_data[i] = local_rx[i + 1]; + + // Set up for the second transfer to restore the register + send_cmd[0].cs_change = + 0; // we want to end the transaction after this transfer + local_tx[0] = ((chip_id & 0xF) << 4) | (register_id & 0xF); + for (int i = 0; i < n_bytes; i++) + local_tx[i + 1] = actual_data[i]; + +#ifdef VIRTUAL + // Copy the data from the fake register to the local_rx buffer + for (int i = 0; i < n_bytes; i++) { + local_rx[i + 1] = fake_register[i]; + } + free(fake_register); // we are done with the fake register +#else + if (ioctl(spifd, SPI_IOC_MESSAGE(1), &send_cmd) < 0) { + // cleanup since we return early + close(spifd); + free(local_tx); + free(local_rx); + free(dummy_data); + free(actual_data); + + // Send error message + sprintf(mess, "SPI write failed with %d:%s\n", errno, strerror(errno)); + return sendError(file_des); + } + close(spifd); +#endif + ret = OK; + LOG(logDEBUG1, ("SPI Read Complete\n")); + Server_SendResult(file_des, INT32, NULL, 0); + sendData(file_des, actual_data, n_bytes, OTHER); + + free(local_tx); + free(local_rx); + free(dummy_data); + free(actual_data); + return ret; +} + +/** + * Write to SPI register. + */ +int spi_write(int file_des) { +#if !defined(XILINX_CHIPTESTBOARDD) + functionNotImplemented(); + return Server_SendResult(file_des, INT32, NULL, 0); +#endif + + int chip_id = 0; + if (receiveData(file_des, &chip_id, sizeof(chip_id), INT32) < 0) { + return printSocketReadError(); + } + if (chip_id < 0 || chip_id > 15) { + ret = FAIL; + sprintf(mess, "Invalid chip_id %d. Must be 0-15\n", chip_id); + LOG(logERROR, (mess)); + return Server_SendResult(file_des, INT32, NULL, 0); + } + + int register_id = 0; + if (receiveData(file_des, ®ister_id, sizeof(register_id), INT32) < 0) { + return printSocketReadError(); + } + if (register_id < 0 || register_id > 15) { + ret = FAIL; + sprintf(mess, "Invalid register_id %d. Must be 0-15\n", register_id); + LOG(logERROR, (mess)); + return Server_SendResult(file_des, INT32, NULL, 0); + } + + int n_bytes = 0; + if (receiveData(file_des, &n_bytes, sizeof(n_bytes), INT32) < 0) { + return printSocketReadError(); + } + if (n_bytes < 1) { + sprintf(mess, + "Invalid n_bytes %d. Must ask for a write of at least 1 byte\n", + n_bytes); + return sendError(file_des); + } + + LOG(logINFO, + ("SPI Write Requested: chip_id=%d, register_id=%d, n_bytes=%d\n", + chip_id, register_id, n_bytes)); + + uint8_t *data = malloc(n_bytes); + if (data == NULL) { + LOG(logERROR, ("Could not allocate memory for SPI write data\n")); + exit(EXIT_FAILURE); + } + memset(data, 0, n_bytes); + if (receiveData(file_des, data, n_bytes, OTHER) < 0) { + free(data); + return printSocketReadError(); + } + + uint8_t *local_tx = malloc(n_bytes + 1); + if (local_tx == NULL) { + LOG(logERROR, ("Could not allocate memory for local_tx\n")); + exit(EXIT_FAILURE); + } + uint8_t *local_rx = malloc(n_bytes + 1); + if (local_rx == NULL) { + LOG(logERROR, ("Could not allocate memory for local_rx\n")); + exit(EXIT_FAILURE); + } + + struct spi_ioc_transfer send_cmd[1]; + memset(send_cmd, 0, sizeof(send_cmd)); + send_cmd[0].len = n_bytes + 1; + send_cmd[0].tx_buf = (unsigned long)local_tx; + send_cmd[0].rx_buf = (unsigned long)local_rx; + + // 0 - Normal operation, 1 - CSn remains zero after operation + send_cmd[0].cs_change = 0; + local_tx[0] = ((chip_id & 0xF) << 4) | (register_id & 0xF); + for (int i = 0; i < n_bytes; i++) + local_tx[i + 1] = data[i]; + +#ifdef VIRTUAL + // For the virtual detector copy the data from local_tx to local_rx + for (int i = 0; i < n_bytes + 1; i++) { + local_rx[i] = local_tx[i]; + } +#else + int spifd = open("/dev/spidev2.0", O_RDWR); + LOG(logINFO, ("SPI Read: opened spidev2.0 with fd=%d\n", spifd)); + if (spifd < 0) { + free(data); + free(local_tx); + free(local_rx); + sprintf(mess, "Could not open /dev/spidev2.0\n"); + return sendError(file_des); + } + if (ioctl(spifd, SPI_IOC_MESSAGE(1), &send_cmd) < 0) { + close(spifd); + free(data); + free(local_tx); + free(local_rx); + sprintf(mess, "SPI write failed with %d:%s\n", errno, strerror(errno)); + return sendError(file_des); + } + close(spifd); +#endif + + ret = OK; + LOG(logDEBUG1, ("SPI Write Complete\n")); + Server_SendResult(file_des, INT32, NULL, 0); + sendData(file_des, local_rx + 1, n_bytes, OTHER); + + free(data); + free(local_tx); + free(local_rx); + return ret; } \ No newline at end of file diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/RegisterDefs.h b/slsDetectorServers/xilinx_ctbDetectorServer/RegisterDefs.h index 438355c46..d0a6e8bdb 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/RegisterDefs.h +++ b/slsDetectorServers/xilinx_ctbDetectorServer/RegisterDefs.h @@ -131,7 +131,7 @@ /* REG no_Samples_X_Reg */ #define NO_SAMPLES_X_REG 0xa00cUL -#define NO_SAMPLES_X_MSK 0x7FFFFFFFUL +#define NO_SAMPLES_X_MSK 0xffffUL #define NO_SAMPLES_X_OFST 0 /* REG count_Frames_From_Reg_1 */ @@ -150,6 +150,39 @@ #define LOCAL_FRAME_NUMBER_REG_2 0xa01cUL #define LOCAL_FRAME_NUMBER_REG_2_PRESET 0x0UL +/* REG X0_FIFO_read */ +#define X0_FIFO_READ 0xa020UL +#define X0_FIFO_READ_PRESET 0x0UL + +/* REG X1_FIFO_read */ +#define X1_FIFO_READ 0xa024UL +#define X1_FIFO_READ_PRESET 0x0UL + +/* REG X2_FIFO_read */ +#define X2_FIFO_READ 0xa028UL +#define X2_FIFO_READ_PRESET 0x0UL + +/* REG X3_FIFO_read */ +#define X3_FIFO_READ 0xa02cUL +#define X3_FIFO_READ_PRESET 0x0UL + +/* REG D_FIFO_read */ +#define D_FIFO_READ 0xa030UL +#define D_FIFO_READ_PRESET 0x0UL + +/* REG A_FIFO_select */ +#define A_FIFO_SELECT 0xa034UL +#define A_FIFO_SELECT_PRESET 0x0UL + +/* REG A_FIFO_read */ +#define A_FIFO_READ 0xa038UL +#define A_FIFO_READ_PRESET 0x0UL + +/* REG enable_1G */ +#define ENABLE_1G 0xa03cUL +#define ENABLE_1G_MSK 0x1UL +#define ENABLE_1G_OFST 0 + /* REG TransceiverRXCTRL0Reg1 */ #define TRANSCEIVERRXCTRL0REG1 0xc100UL #define TRANSCEIVERRXCTRL0REG1_PRESET 0x0UL @@ -301,21 +334,21 @@ #define RXDATACH3_OFST 0 /* REG PktPacketLengthReg */ -#define PKTPACKETLENGTHREG 0xa020UL +#define PKTPACKETLENGTHREG 0xa100UL #define PACKETLENGTH1G_MSK 0xffffUL #define PACKETLENGTH1G_OFST 0 #define PACKETLENGTH10G_MSK 0xffff0000UL #define PACKETLENGTH10G_OFST 16 /* REG PktNoPacketsReg */ -#define PKTNOPACKETSREG 0xa024UL +#define PKTNOPACKETSREG 0xa104UL #define NOPACKETS1G_MSK 0x3fUL #define NOPACKETS1G_OFST 0 #define NOPACKETS10G_MSK 0x3f0000UL #define NOPACKETS10G_OFST 16 /* REG PktCtrlReg */ -#define PKTCTRLREG 0xa028UL +#define PKTCTRLREG 0xa108UL #define NOSERVERS_MSK 0x3fUL #define NOSERVERS_OFST 0 #define SERVERSTART_MSK 0x1f00UL @@ -325,14 +358,14 @@ #define ETHINTERF_OFST 16 /* REG PktCoordReg1 */ -#define PKTCOORDREG1 0xa02cUL +#define PKTCOORDREG1 0xa10cUL #define COORDX_MSK 0xffffUL #define COORDX_OFST 0 #define COORDY_MSK 0xffff0000UL #define COORDY_OFST 16 /* REG PktCoordReg2 */ -#define PKTCOORDREG2 0xa030UL +#define PKTCOORDREG2 0xa110UL #define COORDZ_MSK 0xffffUL #define COORDZ_OFST 0 @@ -639,6 +672,11 @@ #define MISO_SELECT 0xc018UL #define MISO_SELECT_PRESET 0x0UL +/* REG OBUFDTS_ena */ +#define OBUFDTS_ENA 0xc01cUL +#define OBUFDTS_ENA_MSK 0xffffUL +#define OBUFDTS_ENA_OFST 0 + /* REG A_FIFO_Overflow_Status_Reg */ #define A_FIFO_OVERFLOW_STATUS_REG 0x9000UL #define A_FIFO_OVERFLOW_STATUS_REG_PRESET 0x0UL diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer b/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer index b3a23d9f5..614960290 100755 Binary files a/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer and b/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer differ diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c index af5804c82..4c98ea216 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c @@ -413,9 +413,16 @@ void setupDetector() { } LOG(logINFOBLUE, ("Powering down all dacs\n")); - for (int idac = 0; idac < NDAC; ++idac) { + for (int idac = 0; idac < NDAC_ONLY; ++idac) { setDAC(idac, LTC2620_D_GetPowerDownValue(), 0); } + for (int idac = NDAC_ONLY; idac < NDAC; ++idac) { + if (idac == D_PWR_EMPTY) + continue; + int min = (idac == D_PWR_IO) ? VIO_MIN_MV : POWER_RGLTR_MIN; + // will not enable power at startup (dacValues = -1) + setPower(idac, min); + } resetFlow(); cleanFifos(); @@ -1296,6 +1303,9 @@ int getPower(enum DACINDEX ind) { } void setPower(enum DACINDEX ind, int val) { + if (val < 0) + return; + // validate index and get bit offset in ctrl register int bitOffset = getBitOffsetFromDACIndex(ind); if (bitOffset == -1) { @@ -1303,10 +1313,6 @@ void setPower(enum DACINDEX ind, int val) { } uint32_t addr = CTRL_REG; uint32_t mask = (1 << bitOffset); - - if (val == -1) - return; - char *powerNames[] = {PWR_NAMES}; int pwrIndex = (int)(ind - D_PWR_D); LOG(logINFO, ("Setting Power V%s to %d mV\n", powerNames[pwrIndex], val)); @@ -1322,16 +1328,10 @@ void setPower(enum DACINDEX ind, int val) { LOG(logDEBUG1, ("Switching off power enable\n")); bus_w(addr, bus_r(addr) & ~(mask)); - // power down dac - LOG(logINFO, ("\tPowering down V%d\n", powerNames[pwrIndex])); - setDAC(ind, LTC2620_D_GetPowerDownValue(), 0); - - //(power off is anyway done with power enable) - if (val == 0) - val = LTC2620_D_GetPowerDownValue(); + int startup = dacValues[ind] == -1 ? 1 : 0; // convert voltage to dac (power off is anyway done with power enable) - if (val != LTC2620_D_GetPowerDownValue()) { + if (val > 0) { int dacval = -1; if (ConvertToDifferentRange( @@ -1339,9 +1339,8 @@ void setPower(enum DACINDEX ind, int val) { LTC2620_D_GetMinInput(), val, &dacval) == FAIL) { LOG(logERROR, ("\tCannot convert Power V%s to dac value. Invalid value of %d " - "mV. Is not between " - "%d and %d mV\n", - powerNames[pwrIndex], val, POWER_RGLTR_MIN, POWER_RGLTR_MAX)); + "mV.n", + powerNames[pwrIndex], val)); return; } @@ -1351,7 +1350,7 @@ void setPower(enum DACINDEX ind, int val) { setDAC(ind, dacval, 0); // if valid, enable power - if (dacval >= 0) { + if (dacval >= 0 && startup == 0) { LOG(logDEBUG1, ("Switching on power enable\n")); bus_w(addr, bus_r(addr) | mask); } @@ -1885,4 +1884,4 @@ int getFrequency(enum CLKINDEX ind) { clkFrequency[ind] = XILINX_PLL_getFrequency(ind); #endif return clkFrequency[ind]; -} \ No newline at end of file +} diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.h new file mode 100644 index 000000000..8d76bf57b --- /dev/null +++ b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.h @@ -0,0 +1,174 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package +#include "sls/sls_detector_defs.h" +#include "slsDetectorServer_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h + +#include "arm64.h" +#include "programViaArm.h" + +#include // FILE +#include +#include + +/**************************************************** +This functions are used by the slsDetectroServer_funcs interface. +Here are the definitions, but the actual implementation should be done for each +single detector. + +****************************************************/ + +enum interfaceType { OUTER, INNER }; +typedef struct udpStruct_s { + uint16_t srcport; + uint16_t srcport2; + uint16_t dstport; + uint16_t dstport2; + uint64_t srcmac; + uint64_t srcmac2; + uint64_t dstmac; + uint64_t dstmac2; + uint32_t srcip; + uint32_t srcip2; + uint32_t dstip; + uint32_t dstip2; +} udpStruct; +#define MAC_ADDRESS_SIZE 18 + +// basic tests +int isInitCheckDone(); +int getInitResult(char **mess); +void basictests(); +int checkType(); +int testFpga(); +int testFixedFPGAPattern(); + +// Ids +void getServerVersion(char *version); +u_int64_t getFirmwareVersion(); +u_int64_t getFirmwareAPIVersion(); +void getHardwareVersion(char *version); +u_int32_t getDetectorNumber(); +u_int64_t getDetectorMAC(); +u_int32_t getDetectorIP(); + +// initialization +void initControlServer(); +void initStopServer(); + +// set up detector +void setupDetector(); + +// firmware functions (resets) +void cleanFifos(); +void resetFlow(); +int waitTransceiverReset(char *mess); +#ifdef VIRTUAL +void setTransceiverAlignment(int align); +#endif +int isTransceiverAligned(); +int waitTransceiverAligned(char *mess); +int configureTransceiver(char *mess); +int isChipConfigured(); +int powerChip(int on, char *mess); +int getPowerChip(); +int configureChip(char *mess); +int readConfigFile(char *mess, char *fileName, char *fileType); +int resetChip(char *mess); + +// parameters - dr, roi +int setDynamicRange(int dr); +int getDynamicRange(int *retval); +void setADCEnableMask_10G(uint32_t mask); +uint32_t getADCEnableMask_10G(); +int setTransceiverEnableMask(uint32_t mask); +uint32_t getTransceiverEnableMask(); + +// parameters - readout +int setReadoutMode(enum readoutMode mode); +int getReadoutMode(); + +// parameters - timer +int setNextFrameNumber(uint64_t value); +int getNextFrameNumber(uint64_t *value); +void setNumFrames(int64_t val); +int64_t getNumFrames(); +void setNumTriggers(int64_t val); +int64_t getNumTriggers(); +int setExpTime(int64_t val); +int64_t getExpTime(); +int setPeriod(int64_t val); +int64_t getPeriod(); +int setNumAnalogSamples(int val); +int getNumAnalogSamples(); +int setNumDigitalSamples(int val); +int getNumDigitalSamples(); +int setNumTransceiverSamples(int val); +int getNumTransceiverSamples(); + +int64_t getNumFramesLeft(); +int64_t getNumTriggersLeft(); +int setDelayAfterTrigger(int64_t val); +int64_t getDelayAfterTrigger(); +int64_t getDelayAfterTriggerLeft(); +int64_t getPeriodLeft(); +int64_t getFramesFromStart(); +int64_t getActualTime(); +int64_t getMeasurementTime(); + +// parameters - module, settings +int setModule(sls_detector_module myMod, char *mess); + +// parameters - dac, adc, hv +void setDAC(enum DACINDEX ind, int val, int mV); +int getDAC(enum DACINDEX ind, int mV); +int getMaxDacSteps(); +int dacToVoltage(int dac); +int checkVLimitCompliant(int mV); +int checkVLimitDacCompliant(int dac); +int getVLimit(); +void setVLimit(int l); +int getBitOffsetFromDACIndex(enum DACINDEX ind); +int isPowerValid(enum DACINDEX ind, int val); +int getPower(); +void setPower(enum DACINDEX ind, int val); +int getADC(enum ADCINDEX ind, int *value); +int getSlowADC(int ichan, int *retval); +int getTemperature(int *retval); +int setHighVoltage(int val); + +// parameters - timing, extsig +void setTiming(enum timingMode arg); +enum timingMode getTiming(); + +// configure mac +int getNumberofUDPInterfaces(); +void calcChecksum(udp_header *udp); +int configureMAC(); +int setDetectorPosition(int pos[]); +int *getDetectorPosition(); + +// very detector specific + +// chip test board specific - configure frequency, phase, pll, +// flashing firmware +int setFrequency(enum CLKINDEX ind, int val); +int getFrequency(enum CLKINDEX ind); + +// aquisition +int startStateMachine(); +#ifdef VIRTUAL +void *start_timer(void *arg); +#endif +int stopStateMachine(); +int softwareTrigger(); +enum runStatus getRunStatus(); +void waitForAcquisitionEnd(); +u_int32_t runBusy(); + +// common +int calculateDataBytes(); +int getTotalNumberOfChannels(); +void getNumberOfChannels(int *nchanx, int *nchany); +int getNumberOfChips(); +int getNumberOfDACs(); +int getNumberOfChannelsPerChip(); diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index a200c99c7..c4d5b670f 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -2247,6 +2247,13 @@ class Detector { ///@} + Result> readSpi(int chip_id, int register_id, + int n_bytes, Positions pos = {}) const; + + Result> writeSpi(int chip_id, int register_id, + const std::vector &data, + Positions pos = {}); + private: std::vector getValidPortNumbers(uint16_t start_port); void updateRxRateCorrections(); diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 30d387f92..39706ec56 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -2954,4 +2954,17 @@ std::vector Detector::getValidPortNumbers(uint16_t start_port) { return res; } +Result> Detector::readSpi(int chip_id, int register_id, + int n_bytes, + Positions pos) const { + return pimpl->Parallel(&Module::readSpi, pos, chip_id, register_id, + n_bytes); +} + +Result> +Detector::writeSpi(int chip_id, int register_id, + const std::vector &data, Positions pos) { + return pimpl->Parallel(&Module::writeSpi, pos, chip_id, register_id, data); +} + } // namespace sls diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 6167f585d..8a97afb89 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -4074,4 +4074,50 @@ void Module::simulatingActivityinDetector(const std::string &functionType, } printf("\n"); } + +std::vector Module::readSpi(int chip_id, int register_id, + int n_bytes) const { + auto client = DetectorSocket(shm()->hostname, shm()->controlPort); + client.Send(F_SPI_READ); + client.setFnum(F_SPI_READ); + client.Send(chip_id); + client.Send(register_id); + client.Send(n_bytes); + + if (client.Receive() == FAIL) { + std::ostringstream os; + os << "Module " << moduleIndex << " (" << shm()->hostname << ")" + << " returned error: " << client.readErrorMessage(); + throw DetectorError(os.str()); + } + + std::vector data(n_bytes); + client.Receive(data); + return data; +} + +std::vector Module::writeSpi(int chip_id, int register_id, + const std::vector &data) { + auto client = DetectorSocket(shm()->hostname, shm()->controlPort); + client.Send(F_SPI_WRITE); + client.setFnum(F_SPI_WRITE); + client.Send(chip_id); + client.Send(register_id); + client.Send(static_cast(data.size())); + client.Send(data); + + if (client.Receive() == FAIL) { + std::ostringstream os; + os << "Module " << moduleIndex << " (" << shm()->hostname << ")" + << " returned error: " << client.readErrorMessage(); + throw DetectorError(os.str()); + } + + // Read the output from the SPI write. This contains the data before the + // write. + std::vector ret(data.size()); + client.Receive(ret); + return ret; +} + } // namespace sls diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index d23cc095e..9f75f1765 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -607,6 +607,11 @@ class Module : public virtual slsDetectorDefs { int64_t getNumberOfFramesFromStart() const; int64_t getActualTime() const; int64_t getMeasurementTime() const; + std::vector readSpi(int chip_id, int register_id, + int n_bytes) const; + + std::vector writeSpi(int chip_id, int register_id, + const std::vector &data); private: std::string getReceiverLongVersion() const; diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-acquire.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-acquire.cpp index 299125b99..44ae67c14 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-acquire.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-acquire.cpp @@ -16,8 +16,11 @@ namespace sls { using test::GET; using test::PUT; +// disable for jungfrau as it requires higher maximum receive buffer size +// sysctl net.core.rmem_max=$((100*1024*1024)) +// sysctl net.core.rmem_default=$((100*1024*1024)) TEST_CASE("jungfrau_or_moench_acquire_check_file_size", - "[.cmdcall][.cmdacquire]") { + "[.detectorintegration][.cmdacquire][.disable_check_data_file]") { Detector det; Caller caller(&det); @@ -47,7 +50,8 @@ TEST_CASE("jungfrau_or_moench_acquire_check_file_size", } } -TEST_CASE("eiger_acquire_check_file_size", "[.cmdcall][.cmdacquire]") { +TEST_CASE("eiger_acquire_check_file_size", + "[.detectorintegration][.cmdacquire][.disable_check_data_file]") { Detector det; Caller caller(&det); auto det_type = @@ -78,7 +82,8 @@ TEST_CASE("eiger_acquire_check_file_size", "[.cmdcall][.cmdacquire]") { } } -TEST_CASE("mythen3_acquire_check_file_size", "[.cmdcall][.cmdacquire]") { +TEST_CASE("mythen3_acquire_check_file_size", + "[.detectorintegration][.cmdacquire][.disable_check_data_file]") { Detector det; Caller caller(&det); auto det_type = @@ -111,7 +116,8 @@ TEST_CASE("mythen3_acquire_check_file_size", "[.cmdcall][.cmdacquire]") { } } -TEST_CASE("gotthard2_acquire_check_file_size", "[.cmdcall][.cmdacquire]") { +TEST_CASE("gotthard2_acquire_check_file_size", + "[.detectorintegration][.cmdacquire][.disable_check_data_file]") { Detector det; Caller caller(&det); auto det_type = @@ -150,7 +156,11 @@ void test_ctb_file_size_with_acquire(Detector &det, Caller &caller, expected_image_size)); } -TEST_CASE("ctb_acquire_check_file_size", "[.cmdcall][.cmdacquire]") { +// disable for xilinx_ctb as it requires higher maximum receive buffer size +// sysctl net.core.rmem_max=$((100*1024*1024)) +// sysctl net.core.rmem_default=$((100*1024*1024)) +TEST_CASE("ctb_acquire_check_file_size", + "[.detectorintegration][.cmdacquire][.disable_check_data_file]") { Detector det; Caller caller(&det); auto det_type = diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp index e557363aa..ca6e4aa85 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp @@ -19,7 +19,7 @@ using test::PUT; /* dacs */ -TEST_CASE("dacname", "[.cmdcall]") { +TEST_CASE("dacname", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -54,7 +54,7 @@ TEST_CASE("dacname", "[.cmdcall]") { } } -TEST_CASE("dacindex", "[.cmdcall]") { +TEST_CASE("dacindex", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -80,7 +80,7 @@ TEST_CASE("dacindex", "[.cmdcall]") { } } -TEST_CASE("adclist", "[.cmdcall]") { +TEST_CASE("adclist", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -113,7 +113,7 @@ TEST_CASE("adclist", "[.cmdcall]") { } } -TEST_CASE("adcname", "[.cmdcall]") { +TEST_CASE("adcname", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -148,7 +148,7 @@ TEST_CASE("adcname", "[.cmdcall]") { } } -TEST_CASE("adcindex", "[.cmdcall]") { +TEST_CASE("adcindex", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -174,7 +174,7 @@ TEST_CASE("adcindex", "[.cmdcall]") { } } -TEST_CASE("signallist", "[.cmdcall]") { +TEST_CASE("signallist", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -207,7 +207,7 @@ TEST_CASE("signallist", "[.cmdcall]") { } } -TEST_CASE("signalname", "[.cmdcall]") { +TEST_CASE("signalname", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -242,7 +242,7 @@ TEST_CASE("signalname", "[.cmdcall]") { } } -TEST_CASE("signalindex", "[.cmdcall]") { +TEST_CASE("signalindex", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -269,7 +269,7 @@ TEST_CASE("signalindex", "[.cmdcall]") { } } -TEST_CASE("powerlist", "[.cmdcall]") { +TEST_CASE("powerlist", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -302,7 +302,7 @@ TEST_CASE("powerlist", "[.cmdcall]") { } } -TEST_CASE("powername", "[.cmdcall]") { +TEST_CASE("powername", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -337,7 +337,7 @@ TEST_CASE("powername", "[.cmdcall]") { } } -TEST_CASE("powerindex", "[.cmdcall]") { +TEST_CASE("powerindex", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -364,7 +364,7 @@ TEST_CASE("powerindex", "[.cmdcall]") { } } -TEST_CASE("powervalues", "[.cmdcall]") { +TEST_CASE("powervalues", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -377,7 +377,7 @@ TEST_CASE("powervalues", "[.cmdcall]") { } } -TEST_CASE("slowadcvalues", "[.cmdcall]") { +TEST_CASE("slowadcvalues", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -390,7 +390,7 @@ TEST_CASE("slowadcvalues", "[.cmdcall]") { } } -TEST_CASE("slowadclist", "[.cmdcall]") { +TEST_CASE("slowadclist", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -423,7 +423,7 @@ TEST_CASE("slowadclist", "[.cmdcall]") { } } -TEST_CASE("slowadcname", "[.cmdcall]") { +TEST_CASE("slowadcname", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -459,7 +459,7 @@ TEST_CASE("slowadcname", "[.cmdcall]") { } } -TEST_CASE("slowadcindex", "[.cmdcall]") { +TEST_CASE("slowadcindex", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -488,7 +488,7 @@ TEST_CASE("slowadcindex", "[.cmdcall]") { /* dacs */ -TEST_CASE("dac", "[.cmdcall][.dacs]") { +TEST_CASE("dac", "[.detectorintegration][.dacs]") { // dac 0 to dac 17 Detector det; @@ -564,7 +564,7 @@ TEST_CASE("dac", "[.cmdcall][.dacs]") { } } -TEST_CASE("adcvpp", "[.cmdcall]") { +TEST_CASE("adcvpp", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -596,7 +596,7 @@ TEST_CASE("adcvpp", "[.cmdcall]") { /* CTB Specific */ -TEST_CASE("samples", "[.cmdcall]") { +TEST_CASE("samples", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -640,7 +640,7 @@ TEST_CASE("samples", "[.cmdcall]") { } } -TEST_CASE("asamples", "[.cmdcall]") { +TEST_CASE("asamples", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -671,7 +671,7 @@ TEST_CASE("asamples", "[.cmdcall]") { } } -TEST_CASE("adcclk", "[.cmdcall]") { +TEST_CASE("adcclk", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -702,7 +702,7 @@ TEST_CASE("adcclk", "[.cmdcall]") { } } -TEST_CASE("runclk", "[.cmdcall]") { +TEST_CASE("runclk", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -733,7 +733,7 @@ TEST_CASE("runclk", "[.cmdcall]") { } } -TEST_CASE("syncclk", "[.cmdcall]") { +TEST_CASE("syncclk", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -745,7 +745,7 @@ TEST_CASE("syncclk", "[.cmdcall]") { } } -TEST_CASE("v_limit", "[.cmdcall]") { +TEST_CASE("v_limit", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -784,7 +784,7 @@ TEST_CASE("v_limit", "[.cmdcall]") { } } -TEST_CASE("adcenable", "[.cmdcall]") { +TEST_CASE("adcenable", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -814,7 +814,7 @@ TEST_CASE("adcenable", "[.cmdcall]") { } } -TEST_CASE("adcenable10g", "[.cmdcall]") { +TEST_CASE("adcenable10g", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -845,7 +845,7 @@ TEST_CASE("adcenable10g", "[.cmdcall]") { } } -TEST_CASE("transceiverenable", "[.cmdcall]") { +TEST_CASE("transceiverenable", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -878,7 +878,7 @@ TEST_CASE("transceiverenable", "[.cmdcall]") { /* CTB Specific */ -TEST_CASE("dsamples", "[.cmdcall]") { +TEST_CASE("dsamples", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -909,7 +909,7 @@ TEST_CASE("dsamples", "[.cmdcall]") { } } -TEST_CASE("tsamples", "[.cmdcall]") { +TEST_CASE("tsamples", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -934,8 +934,8 @@ TEST_CASE("tsamples", "[.cmdcall]") { } if (det_type == defs::XILINX_CHIPTESTBOARD) { std::ostringstream oss; - caller.call("tsamples", {"2147483647"}, -1, PUT, oss); - REQUIRE(oss.str() == "tsamples 2147483647\n"); + caller.call("tsamples", {"10000"}, -1, PUT, oss); + REQUIRE(oss.str() == "tsamples 10000\n"); } for (int i = 0; i != det.size(); ++i) { det.setNumberOfTransceiverSamples(prev_val[i], {i}); @@ -945,7 +945,7 @@ TEST_CASE("tsamples", "[.cmdcall]") { } } -TEST_CASE("romode", "[.cmdcall]") { +TEST_CASE("romode", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -999,7 +999,7 @@ TEST_CASE("romode", "[.cmdcall]") { } } -TEST_CASE("dbitclk", "[.cmdcall]") { +TEST_CASE("dbitclk", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1030,51 +1030,57 @@ TEST_CASE("dbitclk", "[.cmdcall]") { } } -TEST_CASE("v_abcd", "[.cmdcall]") { +TEST_CASE("v_abcd", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); + std::vector cmds{"v_a", "v_b", "v_c", "v_d"}; + std::vector indices{defs::V_POWER_A, defs::V_POWER_B, + defs::V_POWER_C, defs::V_POWER_D}; + if (det.isVirtualDetectorServer().tsquash("Inconsistent virtual servers")) { + cmds.push_back("v_io"); + indices.push_back(defs::V_POWER_IO); + } - std::vector cmds{"v_a", "v_b", "v_c", "v_d", "v_io"}; - std::vector indices{defs::V_POWER_A, defs::V_POWER_B, - defs::V_POWER_C, defs::V_POWER_D, - defs::V_POWER_IO}; - - for (size_t i = 0; i < cmds.size(); ++i) { - if (det_type == defs::CHIPTESTBOARD || - det_type == defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getPower(indices[i]); - { - std::ostringstream oss; - caller.call(cmds[i], {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == cmds[i] + " 0\n"); - } - { - std::ostringstream oss1, oss2; - caller.call(cmds[i], {"1200"}, -1, PUT, oss1); - REQUIRE(oss1.str() == cmds[i] + " 1200\n"); - caller.call(cmds[i], {}, -1, GET, oss2); - REQUIRE(oss2.str() == cmds[i] + " 1200\n"); - } - for (int i = 0; i != det.size(); ++i) { - if (det_type == defs::XILINX_CHIPTESTBOARD && - prev_val[i] == -100) { - prev_val[i] = 0; - continue; - } - det.setPower(indices[i], prev_val[i], {i}); - } - - } else { - REQUIRE_THROWS(caller.call(cmds[i], {}, -1, GET)); + for (size_t i = 0; i < cmds.size(); ++i) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { + auto prev_val = det.getPower(indices[i]); + // this is the first command touching power dacs, should not be + // -100 + if (det_type == defs::XILINX_CHIPTESTBOARD) { + REQUIRE(prev_val.any(-100) == false); + REQUIRE(prev_val.any(-1) == false); } + { + std::ostringstream oss; + caller.call(cmds[i], {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == cmds[i] + " 0\n"); + } + { + std::ostringstream oss1, oss2; + caller.call(cmds[i], {"1200"}, -1, PUT, oss1); + REQUIRE(oss1.str() == cmds[i] + " 1200\n"); + caller.call(cmds[i], {}, -1, GET, oss2); + REQUIRE(oss2.str() == cmds[i] + " 1200\n"); + } + for (int imod = 0; imod != det.size(); ++imod) { + if (det_type == defs::XILINX_CHIPTESTBOARD && + prev_val[imod] == -100) { + prev_val[imod] = 0; + } + det.setPower(indices[i], prev_val[imod], {imod}); + } + + } else { + REQUIRE_THROWS(caller.call(cmds[i], {}, -1, GET)); } } } -TEST_CASE("v_io", "[.cmdcall]") { +TEST_CASE("v_io", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1087,7 +1093,7 @@ TEST_CASE("v_io", "[.cmdcall]") { } } -TEST_CASE("v_chip", "[.cmdcall]") { +TEST_CASE("v_chip", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1099,7 +1105,7 @@ TEST_CASE("v_chip", "[.cmdcall]") { } } -TEST_CASE("vm_a", "[.cmdcall]") { +TEST_CASE("vm_a", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1110,7 +1116,7 @@ TEST_CASE("vm_a", "[.cmdcall]") { } } -TEST_CASE("vm_b", "[.cmdcall]") { +TEST_CASE("vm_b", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1121,7 +1127,7 @@ TEST_CASE("vm_b", "[.cmdcall]") { } } -TEST_CASE("vm_c", "[.cmdcall]") { +TEST_CASE("vm_c", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1132,7 +1138,7 @@ TEST_CASE("vm_c", "[.cmdcall]") { } } -TEST_CASE("vm_d", "[.cmdcall]") { +TEST_CASE("vm_d", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1143,7 +1149,7 @@ TEST_CASE("vm_d", "[.cmdcall]") { } } -TEST_CASE("vm_io", "[.cmdcall]") { +TEST_CASE("vm_io", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1154,7 +1160,7 @@ TEST_CASE("vm_io", "[.cmdcall]") { } } -TEST_CASE("im_a", "[.cmdcall]") { +TEST_CASE("im_a", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1165,7 +1171,7 @@ TEST_CASE("im_a", "[.cmdcall]") { } } -TEST_CASE("im_b", "[.cmdcall]") { +TEST_CASE("im_b", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1176,7 +1182,7 @@ TEST_CASE("im_b", "[.cmdcall]") { } } -TEST_CASE("im_c", "[.cmdcall]") { +TEST_CASE("im_c", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1187,7 +1193,7 @@ TEST_CASE("im_c", "[.cmdcall]") { } } -TEST_CASE("im_d", "[.cmdcall]") { +TEST_CASE("im_d", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1198,7 +1204,7 @@ TEST_CASE("im_d", "[.cmdcall]") { } } -TEST_CASE("im_io", "[.cmdcall]") { +TEST_CASE("im_io", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1209,7 +1215,7 @@ TEST_CASE("im_io", "[.cmdcall]") { } } -TEST_CASE("slowadc", "[.cmdcall]") { +TEST_CASE("slowadc", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1225,7 +1231,7 @@ TEST_CASE("slowadc", "[.cmdcall]") { } } -TEST_CASE("extsampling", "[.cmdcall]") { +TEST_CASE("extsampling", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1255,7 +1261,7 @@ TEST_CASE("extsampling", "[.cmdcall]") { } } -TEST_CASE("extsamplingsrc", "[.cmdcall]") { +TEST_CASE("extsamplingsrc", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1286,7 +1292,7 @@ TEST_CASE("extsamplingsrc", "[.cmdcall]") { } } -TEST_CASE("diodelay", "[.cmdcall]") { +TEST_CASE("diodelay", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1309,7 +1315,7 @@ TEST_CASE("diodelay", "[.cmdcall]") { } } -TEST_CASE("led", "[.cmdcall]") { +TEST_CASE("led", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-eiger.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-eiger.cpp index ae6a6c824..4f05256fa 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-eiger.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-eiger.cpp @@ -19,7 +19,7 @@ using test::PUT; /** temperature */ -TEST_CASE("temp_fpgaext", "[.cmdcall]") { +TEST_CASE("temp_fpgaext", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -34,7 +34,7 @@ TEST_CASE("temp_fpgaext", "[.cmdcall]") { } } -TEST_CASE("temp_10ge", "[.cmdcall]") { +TEST_CASE("temp_10ge", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -49,7 +49,7 @@ TEST_CASE("temp_10ge", "[.cmdcall]") { } } -TEST_CASE("temp_dcdc", "[.cmdcall]") { +TEST_CASE("temp_dcdc", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -64,7 +64,7 @@ TEST_CASE("temp_dcdc", "[.cmdcall]") { } } -TEST_CASE("temp_sodl", "[.cmdcall]") { +TEST_CASE("temp_sodl", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -79,7 +79,7 @@ TEST_CASE("temp_sodl", "[.cmdcall]") { } } -TEST_CASE("temp_sodr", "[.cmdcall]") { +TEST_CASE("temp_sodr", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -94,7 +94,7 @@ TEST_CASE("temp_sodr", "[.cmdcall]") { } } -TEST_CASE("temp_fpgafl", "[.cmdcall]") { +TEST_CASE("temp_fpgafl", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -109,7 +109,7 @@ TEST_CASE("temp_fpgafl", "[.cmdcall]") { } } -TEST_CASE("temp_fpgafr", "[.cmdcall]") { +TEST_CASE("temp_fpgafr", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -126,7 +126,8 @@ TEST_CASE("temp_fpgafr", "[.cmdcall]") { /* dacs */ -TEST_CASE("Setting and reading back EIGER dacs", "[.cmdcall][.dacs]") { +TEST_CASE("Setting and reading back EIGER dacs", + "[.detectorintegration][.dacs]") { // vsvp, vtr, vrf, vrs, vsvn, vtgstv, vcmp_ll, vcmp_lr, vcal, vcmp_rl, // rxb_rb, rxb_lb, vcmp_rr, vcp, vcn, vis, vthreshold Detector det; @@ -232,7 +233,7 @@ TEST_CASE("Setting and reading back EIGER dacs", "[.cmdcall][.dacs]") { /* Network Configuration (Detector<->Receiver) */ -TEST_CASE("txdelay_left", "[.cmdcall]") { +TEST_CASE("txdelay_left", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -253,7 +254,7 @@ TEST_CASE("txdelay_left", "[.cmdcall]") { } } -TEST_CASE("txdelay_right", "[.cmdcall]") { +TEST_CASE("txdelay_right", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -276,7 +277,7 @@ TEST_CASE("txdelay_right", "[.cmdcall]") { /* Eiger Specific */ -TEST_CASE("subexptime", "[.cmdcall]") { +TEST_CASE("subexptime", "[.detectorintegration]") { Detector det; Caller caller(&det); @@ -297,7 +298,7 @@ TEST_CASE("subexptime", "[.cmdcall]") { } } -TEST_CASE("subdeadtime", "[.cmdcall]") { +TEST_CASE("subdeadtime", "[.detectorintegration]") { Detector det; Caller caller(&det); @@ -318,7 +319,7 @@ TEST_CASE("subdeadtime", "[.cmdcall]") { } } -TEST_CASE("overflow", "[.cmdcall]") { +TEST_CASE("overflow", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -339,7 +340,7 @@ TEST_CASE("overflow", "[.cmdcall]") { } } -TEST_CASE("ratecorr", "[.cmdcall]") { +TEST_CASE("ratecorr", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -373,7 +374,7 @@ TEST_CASE("ratecorr", "[.cmdcall]") { } } -TEST_CASE("interruptsubframe", "[.cmdcall]") { +TEST_CASE("interruptsubframe", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -397,7 +398,7 @@ TEST_CASE("interruptsubframe", "[.cmdcall]") { } } -TEST_CASE("measuredperiod", "[.cmdcall]") { +TEST_CASE("measuredperiod", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -434,7 +435,7 @@ TEST_CASE("measuredperiod", "[.cmdcall]") { } } -TEST_CASE("measuredsubperiod", "[.cmdcall]") { +TEST_CASE("measuredsubperiod", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -474,7 +475,7 @@ TEST_CASE("measuredsubperiod", "[.cmdcall]") { } } -TEST_CASE("activate", "[.cmdcall]") { +TEST_CASE("activate", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -505,7 +506,7 @@ TEST_CASE("activate", "[.cmdcall]") { } } -TEST_CASE("partialreset", "[.cmdcall]") { +TEST_CASE("partialreset", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -527,7 +528,7 @@ TEST_CASE("partialreset", "[.cmdcall]") { } } -TEST_CASE("pulse", "[.cmdcall]") { +TEST_CASE("pulse", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -542,7 +543,7 @@ TEST_CASE("pulse", "[.cmdcall]") { } } -TEST_CASE("pulsenmove", "[.cmdcall]") { +TEST_CASE("pulsenmove", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -557,7 +558,7 @@ TEST_CASE("pulsenmove", "[.cmdcall]") { } } -TEST_CASE("pulsechip", "[.cmdcall]") { +TEST_CASE("pulsechip", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -572,7 +573,7 @@ TEST_CASE("pulsechip", "[.cmdcall]") { } } -TEST_CASE("quad", "[.cmdcall]") { +TEST_CASE("quad", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -588,7 +589,7 @@ TEST_CASE("quad", "[.cmdcall]") { } } -TEST_CASE("datastream", "[.cmdcall]") { +TEST_CASE("datastream", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -628,7 +629,7 @@ TEST_CASE("datastream", "[.cmdcall]") { } } -TEST_CASE("top", "[.cmdcall]") { +TEST_CASE("top", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-global.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-global.cpp index c27ff05d5..0dfc527ac 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-global.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-global.cpp @@ -125,12 +125,6 @@ void test_acquire_binary_file_size(const testFileInfo &file_info, REQUIRE(actual_file_size == expected_file_size); } -void test_frames_caught(const Detector &det, int num_frames_to_acquire) { - auto frames_caught = det.getFramesCaught().tsquash( - "Inconsistent number of frames caught")[0]; - REQUIRE(frames_caught == num_frames_to_acquire); -} - void test_acquire_with_receiver(Caller &caller, const Detector &det) { REQUIRE_NOTHROW(caller.call("rx_start", {}, -1, PUT)); REQUIRE_NOTHROW(caller.call("start", {}, -1, PUT)); @@ -172,9 +166,12 @@ void create_files_for_acquire( // acquire and get num frames caught REQUIRE_NOTHROW(test_acquire_with_receiver(caller, det)); - auto frames_caught = det.getFramesCaught().tsquash( - "Inconsistent number of frames caught")[0]; - REQUIRE(frames_caught == num_frames); + // TODO: maybe there should not be REQUIRE statements in void function at + // all, but traceback should be handled + { + auto frames_caught = det.getFramesCaught()[0][0]; + REQUIRE(frames_caught == num_frames); + } // hdf5 #ifdef HDF5C @@ -184,9 +181,10 @@ void create_files_for_acquire( // acquire and get num frames caught test_acquire_with_receiver(caller, det); - frames_caught = det.getFramesCaught().tsquash( - "Inconsistent number of frames caught")[0]; - REQUIRE(frames_caught == num_frames); + { + auto frames_caught = det.getFramesCaught()[0][0]; + REQUIRE(frames_caught == num_frames); + } #endif // restore previous state diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-global.h b/slsDetectorSoftware/tests/Caller/test-Caller-global.h index f93fc3cdd..3042b91cd 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-global.h +++ b/slsDetectorSoftware/tests/Caller/test-Caller-global.h @@ -88,8 +88,6 @@ void test_acquire_binary_file_size(const testFileInfo &file_info, uint64_t num_frames_to_acquire, uint64_t expected_image_size); -void test_frames_caught(const Detector &det, int num_frames_to_acquire); - void test_acquire_with_receiver(Caller &caller, const Detector &det); void create_files_for_acquire( diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-gotthard2.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-gotthard2.cpp index 54bba5ce2..b5264f5b7 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-gotthard2.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-gotthard2.cpp @@ -18,7 +18,7 @@ using test::GET; using test::PUT; // time specific measurements for gotthard2 -TEST_CASE("timegotthard2", "[.cmdcall]") { +TEST_CASE("timegotthard2", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -106,7 +106,8 @@ TEST_CASE("timegotthard2", "[.cmdcall]") { } /* dacs */ -TEST_CASE("Setting and reading back GOTTHARD2 dacs", "[.cmdcall][.dacs]") { +TEST_CASE("Setting and reading back GOTTHARD2 dacs", + "[.detectorintegration][.dacs]") { // vref_h_adc, vb_comp_fe, vb_comp_adc, vcom_cds, // vref_restore, vb_opa_1st, vref_comp_fe, vcom_adc1, // vref_prech, vref_l_adc, vref_cds, vb_cs, @@ -215,7 +216,7 @@ TEST_CASE("Setting and reading back GOTTHARD2 dacs", "[.cmdcall][.dacs]") { /* on chip dacs */ -TEST_CASE("vchip_comp_fe", "[.cmdcall][.onchipdacs]") { +TEST_CASE("vchip_comp_fe", "[.detectorintegration][.onchipdacs]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -228,7 +229,7 @@ TEST_CASE("vchip_comp_fe", "[.cmdcall][.onchipdacs]") { } } -TEST_CASE("vchip_opa_1st", "[.cmdcall][.onchipdacs]") { +TEST_CASE("vchip_opa_1st", "[.detectorintegration][.onchipdacs]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -241,7 +242,7 @@ TEST_CASE("vchip_opa_1st", "[.cmdcall][.onchipdacs]") { } } -TEST_CASE("vchip_opa_fd", "[.cmdcall][.onchipdacs]") { +TEST_CASE("vchip_opa_fd", "[.detectorintegration][.onchipdacs]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -254,7 +255,7 @@ TEST_CASE("vchip_opa_fd", "[.cmdcall][.onchipdacs]") { } } -TEST_CASE("vchip_comp_adc", "[.cmdcall][.onchipdacs]") { +TEST_CASE("vchip_comp_adc", "[.detectorintegration][.onchipdacs]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -267,7 +268,7 @@ TEST_CASE("vchip_comp_adc", "[.cmdcall][.onchipdacs]") { } } -TEST_CASE("vchip_ref_comp_fe", "[.cmdcall][.onchipdacs]") { +TEST_CASE("vchip_ref_comp_fe", "[.detectorintegration][.onchipdacs]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -281,7 +282,7 @@ TEST_CASE("vchip_ref_comp_fe", "[.cmdcall][.onchipdacs]") { } } -TEST_CASE("vchip_cs", "[.cmdcall][.onchipdacs]") { +TEST_CASE("vchip_cs", "[.detectorintegration][.onchipdacs]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -296,7 +297,7 @@ TEST_CASE("vchip_cs", "[.cmdcall][.onchipdacs]") { /* Gotthard2 Specific */ -TEST_CASE("bursts", "[.cmdcall]") { +TEST_CASE("bursts", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -370,7 +371,7 @@ TEST_CASE("bursts", "[.cmdcall]") { } } -TEST_CASE("burstperiod", "[.cmdcall]") { +TEST_CASE("burstperiod", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -392,7 +393,7 @@ TEST_CASE("burstperiod", "[.cmdcall]") { } } -TEST_CASE("burstsl", "[.cmdcall]") { +TEST_CASE("burstsl", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -403,7 +404,7 @@ TEST_CASE("burstsl", "[.cmdcall]") { } } -TEST_CASE("inj_ch", "[.cmdcall]") { +TEST_CASE("inj_ch", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -428,7 +429,7 @@ TEST_CASE("inj_ch", "[.cmdcall]") { } } -TEST_CASE("vetophoton", "[.cmdcall]") { +TEST_CASE("vetophoton", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -450,7 +451,7 @@ TEST_CASE("vetophoton", "[.cmdcall]") { } } -TEST_CASE("vetoref", "[.cmdcall]") { +TEST_CASE("vetoref", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -465,7 +466,7 @@ TEST_CASE("vetoref", "[.cmdcall]") { } } -TEST_CASE("vetofile", "[.cmdcall]") { +TEST_CASE("vetofile", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -479,7 +480,7 @@ TEST_CASE("vetofile", "[.cmdcall]") { } } -TEST_CASE("burstmode", "[.cmdcall]") { +TEST_CASE("burstmode", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -510,7 +511,7 @@ TEST_CASE("burstmode", "[.cmdcall]") { } } -TEST_CASE("cdsgain", "[.cmdcall]") { +TEST_CASE("cdsgain", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -540,7 +541,7 @@ TEST_CASE("cdsgain", "[.cmdcall]") { } } -TEST_CASE("timingsource", "[.cmdcall]") { +TEST_CASE("timingsource", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -570,7 +571,7 @@ TEST_CASE("timingsource", "[.cmdcall]") { } } -TEST_CASE("veto", "[.cmdcall]") { +TEST_CASE("veto", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -600,7 +601,7 @@ TEST_CASE("veto", "[.cmdcall]") { } } -TEST_CASE("vetostream", "[.cmdcall]") { +TEST_CASE("vetostream", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -646,7 +647,7 @@ TEST_CASE("vetostream", "[.cmdcall]") { REQUIRE_THROWS(caller.call("vetostream", {"dfgd"}, -1, GET)); } -TEST_CASE("vetoalg", "[.cmdcall]") { +TEST_CASE("vetoalg", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -702,7 +703,7 @@ TEST_CASE("vetoalg", "[.cmdcall]") { REQUIRE_THROWS(caller.call("vetoalg", {"dfgd"}, -1, GET)); } -TEST_CASE("confadc", "[.cmdcall]") { +TEST_CASE("confadc", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-jungfrau.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-jungfrau.cpp index 4563cd32f..02334f40f 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-jungfrau.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-jungfrau.cpp @@ -17,7 +17,8 @@ using test::PUT; /* dacs */ -TEST_CASE("Setting and reading back Jungfrau dacs", "[.cmdcall][.dacs]") { +TEST_CASE("Setting and reading back Jungfrau dacs", + "[.detectorintegration][.dacs]") { // vb_comp, vdd_prot, vin_com, vref_prech, vb_pixbuf, vb_ds, vref_ds, // vref_comp Detector det; @@ -95,7 +96,7 @@ TEST_CASE("Setting and reading back Jungfrau dacs", "[.cmdcall][.dacs]") { /* Network Configuration (Detector<->Receiver) */ -TEST_CASE("selinterface", "[.cmdcall]") { +TEST_CASE("selinterface", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -126,7 +127,7 @@ TEST_CASE("selinterface", "[.cmdcall]") { /* Jungfrau/moench Specific */ -TEST_CASE("temp_threshold", "[.cmdcall]") { +TEST_CASE("temp_threshold", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -156,7 +157,7 @@ TEST_CASE("temp_threshold", "[.cmdcall]") { } } -TEST_CASE("chipversion", "[.cmdcall]") { +TEST_CASE("chipversion", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -168,7 +169,7 @@ TEST_CASE("chipversion", "[.cmdcall]") { REQUIRE_THROWS(caller.call("chipversion", {"0"}, -1, PUT)); } -TEST_CASE("temp_control", "[.cmdcall]") { +TEST_CASE("temp_control", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -198,7 +199,7 @@ TEST_CASE("temp_control", "[.cmdcall]") { } } -TEST_CASE("temp_event", "[.cmdcall]") { +TEST_CASE("temp_event", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -219,7 +220,7 @@ TEST_CASE("temp_event", "[.cmdcall]") { } } -TEST_CASE("autocompdisable", "[.cmdcall]") { +TEST_CASE("autocompdisable", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -249,7 +250,7 @@ TEST_CASE("autocompdisable", "[.cmdcall]") { } } -TEST_CASE("compdisabletime", "[.cmdcall]") { +TEST_CASE("compdisabletime", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -279,7 +280,7 @@ TEST_CASE("compdisabletime", "[.cmdcall]") { } } -TEST_CASE("extrastoragecells", "[.cmdcall]") { +TEST_CASE("extrastoragecells", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -322,7 +323,7 @@ TEST_CASE("extrastoragecells", "[.cmdcall]") { } } -TEST_CASE("storagecell_start", "[.cmdcall]") { +TEST_CASE("storagecell_start", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -367,7 +368,7 @@ TEST_CASE("storagecell_start", "[.cmdcall]") { } } -TEST_CASE("storagecell_delay", "[.cmdcall]") { +TEST_CASE("storagecell_delay", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -408,7 +409,7 @@ TEST_CASE("storagecell_delay", "[.cmdcall]") { } } -TEST_CASE("gainmode", "[.cmdcall]") { +TEST_CASE("gainmode", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -457,7 +458,7 @@ TEST_CASE("gainmode", "[.cmdcall]") { } } -TEST_CASE("filtercells", "[.cmdcall]") { +TEST_CASE("filtercells", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -501,7 +502,7 @@ TEST_CASE("filtercells", "[.cmdcall]") { REQUIRE_THROWS(caller.call("filtercells", {"0"}, -1, PUT)); } } -TEST_CASE("pedestalmode", "[.cmdcall]") { +TEST_CASE("pedestalmode", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -657,7 +658,7 @@ TEST_CASE("pedestalmode", "[.cmdcall]") { } } -TEST_CASE("timing_info_decoder", "[.cmdcall]") { +TEST_CASE("timing_info_decoder", "[.detectorintegration]") { Detector det; Caller caller(&det); if (det.getDetectorType().squash() == defs::JUNGFRAU && @@ -686,7 +687,7 @@ TEST_CASE("timing_info_decoder", "[.cmdcall]") { } } -TEST_CASE("collectionmode", "[.cmdcall]") { +TEST_CASE("collectionmode", "[.detectorintegration]") { Detector det; Caller caller(&det); if (det.getDetectorType().squash() == defs::JUNGFRAU) { @@ -714,7 +715,7 @@ TEST_CASE("collectionmode", "[.cmdcall]") { } } -TEST_CASE("sync", "[.cmdcall]") { +TEST_CASE("sync", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-master-attributes.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-master-attributes.cpp index bf4cf9bac..e2ef3c9d0 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-master-attributes.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-master-attributes.cpp @@ -1032,7 +1032,9 @@ void open_hdf5_file(const std::string &file_path) { } #endif -TEST_CASE("check_master_file_attributes", "[.cmdcall][.cmdacquire][.cmdattr]") { +TEST_CASE( + "check_master_file_attributes", + "[.detectorintegration][.cmdacquire][.cmdattr][.disable_check_data_file]") { Detector det; Caller caller(&det); @@ -1041,8 +1043,8 @@ TEST_CASE("check_master_file_attributes", "[.cmdcall][.cmdacquire][.cmdattr]") { int64_t num_frames = 1; switch (det_type) { - case defs::EIGER: case defs::JUNGFRAU: + case defs::EIGER: case defs::MOENCH: case defs::MYTHEN3: case defs::GOTTHARD2: diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-moench.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-moench.cpp index 56353f44b..17ee3be1a 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-moench.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-moench.cpp @@ -17,7 +17,8 @@ using test::PUT; /* dacs */ -TEST_CASE("Setting and reading back moench dacs", "[.cmdcall][.dacs]") { +TEST_CASE("Setting and reading back moench dacs", + "[.detectorintegration][.dacs]") { // vbp_colbuf, vipre, vin_cm, vb_sda, vcasc_sfp, vout_cm, vipre_cds, // ibias_sfp Detector det; diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-mythen3.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-mythen3.cpp index 16295a3e1..602d0b2db 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-mythen3.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-mythen3.cpp @@ -19,7 +19,8 @@ using test::PUT; /* dacs */ -TEST_CASE("Setting and reading back MYTHEN3 dacs", "[.cmdcall][.dacs]") { +TEST_CASE("Setting and reading back MYTHEN3 dacs", + "[.detectorintegration][.dacs]") { // vcassh, vth2, vshaper, vshaperneg, vipre_out, vth3, vth1, // vicin, vcas, vpreamp, vpl, vipre, viinsh, vph, vtrim, vdcsh, @@ -184,7 +185,7 @@ TEST_CASE("Setting and reading back MYTHEN3 dacs", "[.cmdcall][.dacs]") { /* acquisition */ -TEST_CASE("readout", "[.cmdcall]") { +TEST_CASE("readout", "[.detectorintegration]") { Detector det; Caller caller(&det); // PUT only command @@ -201,7 +202,7 @@ TEST_CASE("readout", "[.cmdcall]") { /* Mythen3 Specific */ -TEST_CASE("counters", "[.cmdcall]") { +TEST_CASE("counters", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -233,7 +234,7 @@ TEST_CASE("counters", "[.cmdcall]") { } } -TEST_CASE("gates", "[.cmdcall]") { +TEST_CASE("gates", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -263,7 +264,7 @@ TEST_CASE("gates", "[.cmdcall]") { } } -TEST_CASE("exptime1", "[.cmdcall]") { +TEST_CASE("exptime1", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -292,7 +293,7 @@ TEST_CASE("exptime1", "[.cmdcall]") { } } -TEST_CASE("exptime2", "[.cmdcall]") { +TEST_CASE("exptime2", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -321,7 +322,7 @@ TEST_CASE("exptime2", "[.cmdcall]") { } } -TEST_CASE("exptime3", "[.cmdcall]") { +TEST_CASE("exptime3", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -350,7 +351,7 @@ TEST_CASE("exptime3", "[.cmdcall]") { } } -TEST_CASE("gatedelay", "[.cmdcall]") { +TEST_CASE("gatedelay", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -386,7 +387,7 @@ TEST_CASE("gatedelay", "[.cmdcall]") { } } -TEST_CASE("gatedelay1", "[.cmdcall]") { +TEST_CASE("gatedelay1", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -415,7 +416,7 @@ TEST_CASE("gatedelay1", "[.cmdcall]") { } } -TEST_CASE("gatedelay2", "[.cmdcall]") { +TEST_CASE("gatedelay2", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -444,7 +445,7 @@ TEST_CASE("gatedelay2", "[.cmdcall]") { } } -TEST_CASE("gatedelay3", "[.cmdcall]") { +TEST_CASE("gatedelay3", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -473,7 +474,7 @@ TEST_CASE("gatedelay3", "[.cmdcall]") { } } -TEST_CASE("polarity", "[.cmdcall]") { +TEST_CASE("polarity", "[.detectorintegration]") { Detector det; Caller caller(&det); if (det.getDetectorType().squash() == defs::MYTHEN3) { @@ -501,7 +502,7 @@ TEST_CASE("polarity", "[.cmdcall]") { } } -TEST_CASE("interpolation", "[.cmdcall]") { +TEST_CASE("interpolation", "[.detectorintegration]") { Detector det; Caller caller(&det); if (det.getDetectorType().squash() == defs::MYTHEN3) { @@ -555,7 +556,7 @@ TEST_CASE("interpolation", "[.cmdcall]") { } } -TEST_CASE("pumpprobe", "[.cmdcall]") { +TEST_CASE("pumpprobe", "[.detectorintegration]") { Detector det; Caller caller(&det); if (det.getDetectorType().squash() == defs::MYTHEN3) { @@ -632,7 +633,7 @@ TEST_CASE("pumpprobe", "[.cmdcall]") { } } -TEST_CASE("apulse", "[.cmdcall]") { +TEST_CASE("apulse", "[.detectorintegration]") { Detector det; Caller caller(&det); if (det.getDetectorType().squash() == defs::MYTHEN3) { @@ -660,7 +661,7 @@ TEST_CASE("apulse", "[.cmdcall]") { } } -TEST_CASE("dpulse", "[.cmdcall]") { +TEST_CASE("dpulse", "[.detectorintegration]") { Detector det; Caller caller(&det); if (det.getDetectorType().squash() == defs::MYTHEN3) { diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-pattern.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-pattern.cpp index 60dafd4f4..cd49c5ae4 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-pattern.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-pattern.cpp @@ -19,7 +19,7 @@ using test::PUT; /* Pattern */ -TEST_CASE("patfname", "[.cmdcall]") { +TEST_CASE("patfname", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -32,7 +32,7 @@ TEST_CASE("patfname", "[.cmdcall]") { } } -TEST_CASE("pattern", "[.cmdcall]") { +TEST_CASE("pattern", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -45,7 +45,7 @@ TEST_CASE("pattern", "[.cmdcall]") { } } -TEST_CASE("savepattern", "[.cmdcall]") { +TEST_CASE("savepattern", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -63,7 +63,7 @@ TEST_CASE("savepattern", "[.cmdcall]") { } } -TEST_CASE("defaultpattern", "[.cmdcall]") { +TEST_CASE("defaultpattern", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -76,7 +76,7 @@ TEST_CASE("defaultpattern", "[.cmdcall]") { } } -TEST_CASE("patioctrl", "[.cmdcall]") { +TEST_CASE("patioctrl", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -107,7 +107,7 @@ TEST_CASE("patioctrl", "[.cmdcall]") { } } -TEST_CASE("patword", "[.cmdcall]") { +TEST_CASE("patword", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -149,7 +149,7 @@ TEST_CASE("patword", "[.cmdcall]") { } } -TEST_CASE("patlimits", "[.cmdcall]") { +TEST_CASE("patlimits", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -176,7 +176,7 @@ TEST_CASE("patlimits", "[.cmdcall]") { } } -TEST_CASE("patloop", "[.cmdcall]") { +TEST_CASE("patloop", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -225,7 +225,7 @@ TEST_CASE("patloop", "[.cmdcall]") { } } -TEST_CASE("patnloop", "[.cmdcall]") { +TEST_CASE("patnloop", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -271,7 +271,7 @@ TEST_CASE("patnloop", "[.cmdcall]") { } } -TEST_CASE("patwait", "[.cmdcall]") { +TEST_CASE("patwait", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -317,7 +317,7 @@ TEST_CASE("patwait", "[.cmdcall]") { } } -TEST_CASE("patwaittime", "[.cmdcall]") { +TEST_CASE("patwaittime", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -379,7 +379,7 @@ TEST_CASE("patwaittime", "[.cmdcall]") { } } -TEST_CASE("patmask", "[.cmdcall]") { +TEST_CASE("patmask", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -405,7 +405,7 @@ TEST_CASE("patmask", "[.cmdcall]") { } } -TEST_CASE("patsetbit", "[.cmdcall]") { +TEST_CASE("patsetbit", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -431,7 +431,7 @@ TEST_CASE("patsetbit", "[.cmdcall]") { } } -TEST_CASE("patternstart", "[.cmdcall]") { +TEST_CASE("patternstart", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_THROWS(caller.call("patternstart", {}, -1, GET)); diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-rx-running.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-rx-running.cpp index 844df6419..dc736e27a 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-rx-running.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-rx-running.cpp @@ -12,7 +12,7 @@ namespace sls { using test::PUT; TEST_CASE("Ctb and xilinx - cant put if receiver is not idle", - "[.cmdcall][.rx]") { + "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); @@ -60,7 +60,8 @@ TEST_CASE("Ctb and xilinx - cant put if receiver is not idle", } } -TEST_CASE("adcenable - cant put if receiver is not idle", "[.cmdcall][.rx]") { +TEST_CASE("adcenable - cant put if receiver is not idle", + "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); @@ -83,7 +84,8 @@ TEST_CASE("adcenable - cant put if receiver is not idle", "[.cmdcall][.rx]") { } } -TEST_CASE("bursts - cant put if receiver is not idle", "[.cmdcall][.rx]") { +TEST_CASE("bursts - cant put if receiver is not idle", + "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); @@ -105,7 +107,8 @@ TEST_CASE("bursts - cant put if receiver is not idle", "[.cmdcall][.rx]") { } } -TEST_CASE("counters - cant put if receiver is not idle", "[.cmdcall][.rx]") { +TEST_CASE("counters - cant put if receiver is not idle", + "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); @@ -129,30 +132,30 @@ TEST_CASE("counters - cant put if receiver is not idle", "[.cmdcall][.rx]") { } TEST_CASE("numinterfaces - cant put if receiver is not idle", - "[.cmdcall][.rx]") { + "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) { - auto prev_numinterfaces = det.getNumberofUDPInterfaces(); + auto prev_numinterfaces = det.getNumberofUDPInterfaces().tsquash( + "Number of UDP Interfaces is not consistent among modules"); // start receiver REQUIRE_NOTHROW(caller.call("rx_start", {}, -1, PUT)); - REQUIRE_THROWS(caller.call("numinterafaces", {"2"}, -1, PUT)); + REQUIRE_THROWS(caller.call("numinterfaces", {"2"}, -1, PUT)); // stop receiver REQUIRE_NOTHROW(caller.call("rx_stop", {}, -1, PUT)); - for (int i = 0; i != det.size(); ++i) { - det.setNumberofUDPInterfaces(prev_numinterfaces[i], {i}); - } + det.setNumberofUDPInterfaces(prev_numinterfaces); } } -TEST_CASE("dr - cant put if receiver is not idle", "[.cmdcall][.rx]") { +TEST_CASE("dr - cant put if receiver is not idle", + "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); @@ -174,7 +177,8 @@ TEST_CASE("dr - cant put if receiver is not idle", "[.cmdcall][.rx]") { } } -TEST_CASE("tengiga - cant put if receiver is not idle", "[.cmdcall][.rx]") { +TEST_CASE("tengiga - cant put if receiver is not idle", + "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); @@ -198,7 +202,8 @@ TEST_CASE("tengiga - cant put if receiver is not idle", "[.cmdcall][.rx]") { } } -TEST_CASE("general - cant put if receiver is not idle", "[.cmdcall][.rx]") { +TEST_CASE("general - cant put if receiver is not idle", + "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp index a82c086ce..1e489b0b0 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp @@ -25,7 +25,7 @@ python/scripts/list_tested_cmd.py to check if all commands are covered /* configuration */ -TEST_CASE("rx_version", "[.cmdcall][.rx]") { +TEST_CASE("rx_version", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); std::ostringstream oss; @@ -39,7 +39,7 @@ TEST_CASE("rx_version", "[.cmdcall][.rx]") { } /* acquisition */ -TEST_CASE("rx_start", "[.cmdcall][.rx]") { +TEST_CASE("rx_start", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); det.setFileWrite(false); // avoid writing or error on file creation @@ -57,7 +57,7 @@ TEST_CASE("rx_start", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_stop", "[.cmdcall][.rx]") { +TEST_CASE("rx_stop", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); // PUT only command @@ -74,7 +74,7 @@ TEST_CASE("rx_stop", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_status", "[.cmdcall][.rx]") { +TEST_CASE("rx_status", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); det.setFileWrite(false); // avoid writing or error on file creation @@ -92,7 +92,7 @@ TEST_CASE("rx_status", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_framescaught", "[.cmdcall][.rx]") { +TEST_CASE("rx_framescaught", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); // This ensures 0 caught frames @@ -126,7 +126,7 @@ TEST_CASE("rx_framescaught", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_missingpackets", "[.cmdcall][.rx]") { +TEST_CASE("rx_missingpackets", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto prev_val = det.getFileWrite(); @@ -171,7 +171,7 @@ TEST_CASE("rx_missingpackets", "[.cmdcall][.rx]") { det.setNumberOfFrames(prev_frames); } -TEST_CASE("rx_frameindex", "[.cmdcall][.rx]") { +TEST_CASE("rx_frameindex", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); caller.call("rx_frameindex", {}, -1, GET); @@ -182,7 +182,7 @@ TEST_CASE("rx_frameindex", "[.cmdcall][.rx]") { /* Network Configuration (Detector<->Receiver) */ -TEST_CASE("rx_printconfig", "[.cmdcall][.rx]") { +TEST_CASE("rx_printconfig", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("rx_printconfig", {}, -1, GET)); @@ -190,7 +190,7 @@ TEST_CASE("rx_printconfig", "[.cmdcall][.rx]") { /* Receiver Config */ -TEST_CASE("rx_hostname", "[.cmdcall][.rx]") { +TEST_CASE("rx_hostname", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto prev_val = det.getRxHostname(); @@ -222,7 +222,7 @@ TEST_CASE("rx_hostname", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_tcpport", "[.cmdcall][.rx]") { +TEST_CASE("rx_tcpport", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto prev_val = det.getRxPort(); @@ -261,7 +261,7 @@ TEST_CASE("rx_tcpport", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_fifodepth", "[.cmdcall][.rx]") { +TEST_CASE("rx_fifodepth", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto prev_val = det.getRxFifoDepth(); @@ -285,7 +285,7 @@ TEST_CASE("rx_fifodepth", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_silent", "[.cmdcall][.rx]") { +TEST_CASE("rx_silent", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto prev_val = det.getRxSilentMode(); @@ -309,7 +309,7 @@ TEST_CASE("rx_silent", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_discardpolicy", "[.cmdcall][.rx]") { +TEST_CASE("rx_discardpolicy", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto prev_val = det.getRxFrameDiscardPolicy(); @@ -338,7 +338,7 @@ TEST_CASE("rx_discardpolicy", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_padding", "[.cmdcall][.rx]") { +TEST_CASE("rx_padding", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto prev_val = det.getPartialFramesPadding(); @@ -362,7 +362,7 @@ TEST_CASE("rx_padding", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_udpsocksize", "[.cmdcall][.rx]") { +TEST_CASE("rx_udpsocksize", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); int64_t prev_val = det.getRxUDPSocketBufferSize().tsquash( @@ -382,7 +382,7 @@ TEST_CASE("rx_udpsocksize", "[.cmdcall][.rx]") { det.setRxUDPSocketBufferSize(prev_val); } -TEST_CASE("rx_realudpsocksize", "[.cmdcall][.rx]") { +TEST_CASE("rx_realudpsocksize", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); uint64_t val = 0; @@ -401,7 +401,7 @@ TEST_CASE("rx_realudpsocksize", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_lock", "[.cmdcall][.rx]") { +TEST_CASE("rx_lock", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto prev_val = det.getRxLock(); @@ -425,7 +425,7 @@ TEST_CASE("rx_lock", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_lastclient", "[.cmdcall][.rx]") { +TEST_CASE("rx_lastclient", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); std::ostringstream oss; @@ -435,14 +435,14 @@ TEST_CASE("rx_lastclient", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_threads", "[.cmdcall][.rx]") { +TEST_CASE("rx_threads", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); std::ostringstream oss; REQUIRE_NOTHROW(caller.call("rx_threads", {}, -1, GET, oss)); } -TEST_CASE("rx_arping", "[.cmdcall][.rx]") { +TEST_CASE("rx_arping", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto prev_val = det.getRxArping(); @@ -467,7 +467,7 @@ TEST_CASE("rx_arping", "[.cmdcall][.rx]") { } } } -TEST_CASE("rx_roi", "[.cmdcall]") { +TEST_CASE("rx_roi", "[.detectorintegration][.disable_check_data_file]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -861,7 +861,7 @@ TEST_CASE("rx_roi", "[.cmdcall]") { } } -TEST_CASE("rx_clearroi", "[.cmdcall]") { +TEST_CASE("rx_clearroi", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -887,7 +887,7 @@ TEST_CASE("rx_clearroi", "[.cmdcall]") { /* File */ -TEST_CASE("fformat", "[.cmdcall]") { +TEST_CASE("fformat", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getFileFormat(); @@ -906,7 +906,7 @@ TEST_CASE("fformat", "[.cmdcall]") { } } -TEST_CASE("fpath", "[.cmdcall]") { +TEST_CASE("fpath", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getFilePath(); @@ -928,7 +928,7 @@ TEST_CASE("fpath", "[.cmdcall]") { } } -TEST_CASE("fname", "[.cmdcall]") { +TEST_CASE("fname", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getFileNamePrefix(); @@ -955,7 +955,7 @@ TEST_CASE("fname", "[.cmdcall]") { } } -TEST_CASE("findex", "[.cmdcall]") { +TEST_CASE("findex", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getAcquisitionIndex(); @@ -979,7 +979,7 @@ TEST_CASE("findex", "[.cmdcall]") { } } -TEST_CASE("fwrite", "[.cmdcall]") { +TEST_CASE("fwrite", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getFileWrite(); @@ -1003,7 +1003,7 @@ TEST_CASE("fwrite", "[.cmdcall]") { } } -TEST_CASE("fmaster", "[.cmdcall]") { +TEST_CASE("fmaster", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getMasterFileWrite(); @@ -1025,7 +1025,7 @@ TEST_CASE("fmaster", "[.cmdcall]") { det.setMasterFileWrite(prev_val); } -TEST_CASE("foverwrite", "[.cmdcall]") { +TEST_CASE("foverwrite", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getFileOverWrite(); @@ -1049,7 +1049,7 @@ TEST_CASE("foverwrite", "[.cmdcall]") { } } -TEST_CASE("rx_framesperfile", "[.cmdcall][.rx]") { +TEST_CASE("rx_framesperfile", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto prev_val = det.getFramesPerFile(); @@ -1080,7 +1080,7 @@ TEST_CASE("rx_framesperfile", "[.cmdcall][.rx]") { /* ZMQ Streaming Parameters (Receiver<->Client) */ -TEST_CASE("rx_zmqstream", "[.cmdcall][.rx]") { +TEST_CASE("rx_zmqstream", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto prev_val = det.getRxZmqDataStream(); @@ -1106,7 +1106,7 @@ TEST_CASE("rx_zmqstream", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_zmqfreq", "[.cmdcall][.rx]") { +TEST_CASE("rx_zmqfreq", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto prev_val = det.getRxZmqFrequency(); @@ -1130,7 +1130,7 @@ TEST_CASE("rx_zmqfreq", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_zmqstartfnum", "[.cmdcall][.rx]") { +TEST_CASE("rx_zmqstartfnum", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto prev_val = det.getRxZmqStartingFrame(); @@ -1154,7 +1154,7 @@ TEST_CASE("rx_zmqstartfnum", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_zmqport", "[.cmdcall][.rx]") { +TEST_CASE("rx_zmqport", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto prev_val_zmqport = det.getRxZmqPort(); @@ -1202,7 +1202,7 @@ TEST_CASE("rx_zmqport", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_zmqhwm", "[.cmdcall]") { +TEST_CASE("rx_zmqhwm", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = @@ -1232,7 +1232,7 @@ TEST_CASE("rx_zmqhwm", "[.cmdcall]") { /* CTB Specific */ -TEST_CASE("rx_dbitlist", "[.cmdcall][.rx]") { +TEST_CASE("rx_dbitlist", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1262,7 +1262,7 @@ TEST_CASE("rx_dbitlist", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_dbitoffset", "[.cmdcall][.rx]") { +TEST_CASE("rx_dbitoffset", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1297,7 +1297,7 @@ TEST_CASE("rx_dbitoffset", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_dbitreorder", "[.cmdcall][.rx]") { +TEST_CASE("rx_dbitreorder", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1328,7 +1328,7 @@ TEST_CASE("rx_dbitreorder", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_jsonaddheader", "[.cmdcall][.rx]") { +TEST_CASE("rx_jsonaddheader", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto prev_val = det.getAdditionalJsonHeader(); @@ -1354,7 +1354,7 @@ TEST_CASE("rx_jsonaddheader", "[.cmdcall][.rx]") { } } -TEST_CASE("rx_jsonpara", "[.cmdcall][.rx]") { +TEST_CASE("rx_jsonpara", "[.detectorintegration][.rx]") { Detector det; Caller caller(&det); auto prev_val = det.getAdditionalJsonHeader(); diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-xilinx-chiptestboard.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-xilinx-chiptestboard.cpp index 6133962f4..3849be6fb 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-xilinx-chiptestboard.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-xilinx-chiptestboard.cpp @@ -19,7 +19,7 @@ using test::PUT; /* dacs */ -TEST_CASE("configtransceiver", "[.cmdcall]") { +TEST_CASE("configtransceiver", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); diff --git a/slsDetectorSoftware/tests/Caller/test-Caller.cpp b/slsDetectorSoftware/tests/Caller/test-Caller.cpp index 65fd764fa..93c88713e 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller.cpp @@ -21,7 +21,7 @@ using test::GET; using test::PUT; TEST_CASE("Calling help doesn't throw or cause segfault") { - // Dont add [.cmdcall] tag this should run with normal tests + // Dont add [.detectorintegration] tag this should run with normal tests Caller caller(nullptr); std::ostringstream os; for (std::string cmd : caller.getAllCommands()) @@ -29,7 +29,7 @@ TEST_CASE("Calling help doesn't throw or cause segfault") { caller.call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os)); } -TEST_CASE("Unknown command", "[.cmdcall]") { +TEST_CASE("Unknown command", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_THROWS(caller.call("vsaevrreavv", {}, -1, PUT)); @@ -37,7 +37,7 @@ TEST_CASE("Unknown command", "[.cmdcall]") { /* configuration */ -TEST_CASE("config", "[.cmdcall]") { +TEST_CASE("config", "[.detectorintegration]") { Detector det; Caller caller(&det); // put only @@ -59,7 +59,11 @@ void test_include_file(const std::string &cmd) { det.getFileWrite().tsquash("File write enable has to be same to test"); { - system("echo -e 'frames 2\nfwrite 1' > /tmp/tempsetup.det "); + std::ofstream f("/tmp/tempsetup.det", std::ios::trunc); + f << "frames 2\n"; + f << "fwrite 1\n"; + } + { std::ostringstream oss; caller.call(cmd, {"/tmp/tempsetup.det"}, -1, PUT, oss); REQUIRE(oss.str() == cmd + " /tmp/tempsetup.det\n"); @@ -69,7 +73,11 @@ void test_include_file(const std::string &cmd) { 1); } { - system("echo -e 'frames 3\nfwrite 0' > /tmp/tempsetup.det "); + std::ofstream f("/tmp/tempsetup.det", std::ios::trunc); + f << "frames 3\n"; + f << "fwrite 0\n"; + } + { std::ostringstream oss; caller.call(cmd, {"/tmp/tempsetup.det"}, -1, PUT, oss); REQUIRE(oss.str() == cmd + " /tmp/tempsetup.det\n"); @@ -82,17 +90,19 @@ void test_include_file(const std::string &cmd) { det.setFileWrite(prev_fwrite); } -TEST_CASE("parameters", "[.cmdcall]") { test_include_file("parameters"); } +TEST_CASE("parameters", "[.detectorintegration]") { + test_include_file("parameters"); +} -TEST_CASE("include", "[.cmdcall]") { test_include_file("include"); } +TEST_CASE("include", "[.detectorintegration]") { test_include_file("include"); } -TEST_CASE("hostname", "[.cmdcall]") { +TEST_CASE("hostname", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("hostname", {}, -1, GET)); } -TEST_CASE("virtual", "[.cmdcall]") { +TEST_CASE("virtual", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_THROWS(caller.call("virtual", {}, -1, GET)); @@ -100,56 +110,56 @@ TEST_CASE("virtual", "[.cmdcall]") { REQUIRE_THROWS(caller.call("virtual", {"3", "65534"}, -1, PUT)); } -TEST_CASE("versions", "[.cmdcall]") { +TEST_CASE("versions", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("versions", {}, -1, GET)); REQUIRE_THROWS(caller.call("versions", {"0"}, -1, PUT)); } -TEST_CASE("packageversion", "[.cmdcall]") { +TEST_CASE("packageversion", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("packageversion", {}, -1, GET)); REQUIRE_THROWS(caller.call("packageversion", {"0"}, -1, PUT)); } -TEST_CASE("clientversion", "[.cmdcall]") { +TEST_CASE("clientversion", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("clientversion", {}, -1, GET)); REQUIRE_THROWS(caller.call("clientversion", {"0"}, -1, PUT)); } -TEST_CASE("firmwareversion", "[.cmdcall]") { +TEST_CASE("firmwareversion", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("firmwareversion", {}, -1, GET)); REQUIRE_THROWS(caller.call("firmwareversion", {"0"}, -1, PUT)); } -TEST_CASE("detectorserverversion", "[.cmdcall]") { +TEST_CASE("detectorserverversion", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("detectorserverversion", {}, -1, GET)); REQUIRE_THROWS(caller.call("detectorserverversion", {"0"}, -1, PUT)); } -TEST_CASE("hardwareversion", "[.cmdcall]") { +TEST_CASE("hardwareversion", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("hardwareversion", {}, -1, GET)); REQUIRE_THROWS(caller.call("hardwareversion", {"0"}, -1, PUT)); } -TEST_CASE("kernelversion", "[.cmdcall]") { +TEST_CASE("kernelversion", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("kernelversion", {}, -1, GET)); REQUIRE_THROWS(caller.call("kernelversion", {"0"}, -1, PUT)); } -TEST_CASE("serialnumber", "[.cmdcall]") { +TEST_CASE("serialnumber", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -160,7 +170,7 @@ TEST_CASE("serialnumber", "[.cmdcall]") { } } -TEST_CASE("moduleid", "[.cmdcall]") { +TEST_CASE("moduleid", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -173,7 +183,7 @@ TEST_CASE("moduleid", "[.cmdcall]") { } } -TEST_CASE("type", "[.cmdcall]") { +TEST_CASE("type", "[.detectorintegration]") { Detector det; Caller caller(&det); auto dt = det.getDetectorType().squash(); @@ -185,13 +195,13 @@ TEST_CASE("type", "[.cmdcall]") { // REQUIRE(dt == test::type); } -TEST_CASE("detsize", "[.cmdcall]") { +TEST_CASE("detsize", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("detsize", {}, -1, GET)); } -TEST_CASE("settingslist", "[.cmdcall]") { +TEST_CASE("settingslist", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -204,7 +214,7 @@ TEST_CASE("settingslist", "[.cmdcall]") { } } -TEST_CASE("settings", "[.cmdcall]") { +TEST_CASE("settings", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -295,7 +305,7 @@ TEST_CASE("settings", "[.cmdcall]") { } } -TEST_CASE("threshold", "[.cmdcall]") { +TEST_CASE("threshold", "[.detectorintegration]") { Detector det; Caller caller(&det); @@ -374,7 +384,7 @@ TEST_CASE("threshold", "[.cmdcall]") { } } -TEST_CASE("thresholdnotb", "[.cmdcall]") { +TEST_CASE("thresholdnotb", "[.detectorintegration]") { Detector det; Caller caller(&det); @@ -454,7 +464,7 @@ TEST_CASE("thresholdnotb", "[.cmdcall]") { } } -TEST_CASE("settingspath", "[.cmdcall]") { +TEST_CASE("settingspath", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getSettingsPath(); @@ -470,13 +480,13 @@ TEST_CASE("settingspath", "[.cmdcall]") { } } -TEST_CASE("trimbits", "[.cmdcall]") { +TEST_CASE("trimbits", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_THROWS(caller.call("trimbits", {}, -1, GET)); } -TEST_CASE("trimval", "[.cmdcall]") { +TEST_CASE("trimval", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -510,7 +520,7 @@ TEST_CASE("trimval", "[.cmdcall]") { } } -TEST_CASE("trimen", "[.cmdcall][.this]") { +TEST_CASE("trimen", "[.detectorintegration][.this]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -532,7 +542,7 @@ TEST_CASE("trimen", "[.cmdcall][.this]") { } } -TEST_CASE("gappixels", "[.cmdcall]") { +TEST_CASE("gappixels", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -582,7 +592,7 @@ TEST_CASE("gappixels", "[.cmdcall]") { } } -TEST_CASE("fliprows", "[.cmdcall]") { +TEST_CASE("fliprows", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -617,7 +627,7 @@ TEST_CASE("fliprows", "[.cmdcall]") { } } -TEST_CASE("master", "[.cmdcall]") { +TEST_CASE("master", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -662,7 +672,7 @@ TEST_CASE("master", "[.cmdcall]") { } } -TEST_CASE("badchannels", "[.cmdcall]") { +TEST_CASE("badchannels", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -732,7 +742,7 @@ TEST_CASE("badchannels", "[.cmdcall]") { } } -TEST_CASE("row", "[.cmdcall]") { +TEST_CASE("row", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getRow()[0]; @@ -755,7 +765,7 @@ TEST_CASE("row", "[.cmdcall]") { det.setRow(prev_val, {0}); } -TEST_CASE("column", "[.cmdcall]") { +TEST_CASE("column", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getColumn()[0]; @@ -782,7 +792,7 @@ TEST_CASE("column", "[.cmdcall]") { // acquire: not testing -TEST_CASE("frames", "[.cmdcall]") { +TEST_CASE("frames", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = @@ -806,7 +816,7 @@ TEST_CASE("frames", "[.cmdcall]") { det.setNumberOfFrames(prev_val); } -TEST_CASE("triggers", "[.cmdcall]") { +TEST_CASE("triggers", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = @@ -830,7 +840,7 @@ TEST_CASE("triggers", "[.cmdcall]") { det.setNumberOfTriggers(prev_val); } -TEST_CASE("exptime", "[.cmdcall][.time]") { +TEST_CASE("exptime", "[.detectorintegration][.time]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -880,7 +890,7 @@ TEST_CASE("exptime", "[.cmdcall][.time]") { det.setExptime(-1, prev_val); } -TEST_CASE("period", "[.cmdcall]") { +TEST_CASE("period", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getPeriod(); @@ -904,7 +914,7 @@ TEST_CASE("period", "[.cmdcall]") { } } -TEST_CASE("delay", "[.cmdcall]") { +TEST_CASE("delay", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -934,7 +944,7 @@ TEST_CASE("delay", "[.cmdcall]") { } } -TEST_CASE("framesl", "[.cmdcall]") { +TEST_CASE("framesl", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -945,7 +955,7 @@ TEST_CASE("framesl", "[.cmdcall]") { } } -TEST_CASE("triggersl", "[.cmdcall]") { +TEST_CASE("triggersl", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -956,7 +966,7 @@ TEST_CASE("triggersl", "[.cmdcall]") { } } -TEST_CASE("delayl", "[.cmdcall]") { +TEST_CASE("delayl", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -970,7 +980,7 @@ TEST_CASE("delayl", "[.cmdcall]") { } } -TEST_CASE("periodl", "[.cmdcall]") { +TEST_CASE("periodl", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -984,7 +994,7 @@ TEST_CASE("periodl", "[.cmdcall]") { } } -TEST_CASE("dr", "[.cmdcall]") { +TEST_CASE("dr", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1026,14 +1036,14 @@ TEST_CASE("dr", "[.cmdcall]") { } } -TEST_CASE("drlist", "[.cmdcall]") { +TEST_CASE("drlist", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("drlist", {}, -1, GET)); REQUIRE_THROWS(caller.call("drlist", {}, -1, PUT)); } -TEST_CASE("timing", "[.cmdcall]") { +TEST_CASE("timing", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1095,14 +1105,14 @@ TEST_CASE("timing", "[.cmdcall]") { } } -TEST_CASE("timinglist", "[.cmdcall]") { +TEST_CASE("timinglist", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("timinglist", {}, -1, GET)); REQUIRE_THROWS(caller.call("timinglist", {}, -1, PUT)); } -TEST_CASE("readoutspeed", "[.cmdcall]") { +TEST_CASE("readoutspeed", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1192,7 +1202,7 @@ TEST_CASE("readoutspeed", "[.cmdcall]") { } } -TEST_CASE("readoutspeedlist", "[.cmdcall]") { +TEST_CASE("readoutspeedlist", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1206,7 +1216,7 @@ TEST_CASE("readoutspeedlist", "[.cmdcall]") { } } -TEST_CASE("adcphase", "[.cmdcall]") { +TEST_CASE("adcphase", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1236,7 +1246,7 @@ TEST_CASE("adcphase", "[.cmdcall]") { } } -TEST_CASE("maxadcphaseshift", "[.cmdcall]") { +TEST_CASE("maxadcphaseshift", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1250,7 +1260,7 @@ TEST_CASE("maxadcphaseshift", "[.cmdcall]") { } } -TEST_CASE("dbitphase", "[.cmdcall]") { +TEST_CASE("dbitphase", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1279,7 +1289,7 @@ TEST_CASE("dbitphase", "[.cmdcall]") { } } -TEST_CASE("maxdbitphaseshift", "[.cmdcall]") { +TEST_CASE("maxdbitphaseshift", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1292,7 +1302,7 @@ TEST_CASE("maxdbitphaseshift", "[.cmdcall]") { } } -TEST_CASE("clkfreq", "[.cmdcall]") { +TEST_CASE("clkfreq", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1312,7 +1322,7 @@ TEST_CASE("clkfreq", "[.cmdcall]") { } } -TEST_CASE("clkphase", "[.cmdcall]") { +TEST_CASE("clkphase", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1362,7 +1372,7 @@ TEST_CASE("clkphase", "[.cmdcall]") { } } -TEST_CASE("clkdiv", "[.cmdcall]") { +TEST_CASE("clkdiv", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1426,7 +1436,7 @@ TEST_CASE("clkdiv", "[.cmdcall]") { } } -TEST_CASE("maxclkphaseshift", "[.cmdcall]") { +TEST_CASE("maxclkphaseshift", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1446,7 +1456,7 @@ TEST_CASE("maxclkphaseshift", "[.cmdcall]") { } } -TEST_CASE("highvoltage", "[.cmdcall]") { +TEST_CASE("highvoltage", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1531,7 +1541,7 @@ TEST_CASE("highvoltage", "[.cmdcall]") { } } -TEST_CASE("powerchip", "[.cmdcall]") { +TEST_CASE("powerchip", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1583,7 +1593,7 @@ TEST_CASE("powerchip", "[.cmdcall]") { } } -TEST_CASE("imagetest", "[.cmdcall]") { +TEST_CASE("imagetest", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1595,7 +1605,7 @@ TEST_CASE("imagetest", "[.cmdcall]") { } } -TEST_CASE("extsig", "[.cmdcall]") { +TEST_CASE("extsig", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1649,7 +1659,7 @@ TEST_CASE("extsig", "[.cmdcall]") { } } -TEST_CASE("parallel", "[.cmdcall]") { +TEST_CASE("parallel", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1680,7 +1690,7 @@ TEST_CASE("parallel", "[.cmdcall]") { } } -TEST_CASE("filterresistor", "[.cmdcall]") { +TEST_CASE("filterresistor", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1724,7 +1734,7 @@ TEST_CASE("filterresistor", "[.cmdcall]") { } } -TEST_CASE("dbitpipeline", "[.cmdcall]") { +TEST_CASE("dbitpipeline", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1774,7 +1784,7 @@ TEST_CASE("dbitpipeline", "[.cmdcall]") { } } -TEST_CASE("readnrows", "[.cmdcall]") { +TEST_CASE("readnrows", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1826,7 +1836,7 @@ TEST_CASE("readnrows", "[.cmdcall]") { } } -TEST_CASE("currentsource", "[.cmdcall]") { +TEST_CASE("currentsource", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1968,21 +1978,21 @@ TEST_CASE("currentsource", "[.cmdcall]") { /** temperature */ -TEST_CASE("templist", "[.cmdcall]") { +TEST_CASE("templist", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("templist", {}, -1, GET)); REQUIRE_THROWS(caller.call("templist", {}, -1, PUT)); } -TEST_CASE("tempvalues", "[.cmdcall]") { +TEST_CASE("tempvalues", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("tempvalues", {}, -1, GET)); REQUIRE_THROWS(caller.call("tempvalues", {}, -1, PUT)); } -TEST_CASE("temp_adc", "[.cmdcall]") { +TEST_CASE("temp_adc", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -1997,7 +2007,7 @@ TEST_CASE("temp_adc", "[.cmdcall]") { } } -TEST_CASE("temp_fpga", "[.cmdcall]") { +TEST_CASE("temp_fpga", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -2014,7 +2024,7 @@ TEST_CASE("temp_fpga", "[.cmdcall]") { /* list */ -TEST_CASE("daclist", "[.cmdcall]") { +TEST_CASE("daclist", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -2050,14 +2060,14 @@ TEST_CASE("daclist", "[.cmdcall]") { /* dacs */ -TEST_CASE("dacvalues", "[.cmdcall]") { +TEST_CASE("dacvalues", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("dacvalues", {}, -1, GET)); REQUIRE_THROWS(caller.call("dacvalues", {}, -1, PUT)); } -TEST_CASE("defaultdac", "[.cmdcall]") { +TEST_CASE("defaultdac", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -2117,7 +2127,7 @@ TEST_CASE("defaultdac", "[.cmdcall]") { } } -TEST_CASE("resetdacs", "[.cmdcall]") { +TEST_CASE("resetdacs", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -2142,7 +2152,7 @@ TEST_CASE("resetdacs", "[.cmdcall]") { /* acquisition */ -TEST_CASE("trigger", "[.cmdcall]") { +TEST_CASE("trigger", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_THROWS(caller.call("trigger", {}, -1, GET)); @@ -2185,7 +2195,7 @@ TEST_CASE("trigger", "[.cmdcall]") { } } -TEST_CASE("blockingtrigger", "[.cmdcall]") { +TEST_CASE("blockingtrigger", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_THROWS(caller.call("blockingtrigger", {}, -1, GET)); @@ -2229,7 +2239,7 @@ TEST_CASE("blockingtrigger", "[.cmdcall]") { } } -TEST_CASE("clearbusy", "[.cmdcall]") { +TEST_CASE("clearbusy", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("clearbusy", {}, -1, PUT)); @@ -2237,7 +2247,7 @@ TEST_CASE("clearbusy", "[.cmdcall]") { REQUIRE_THROWS(caller.call("clearbusy", {}, -1, GET)); } -TEST_CASE("start", "[.cmdcall]") { +TEST_CASE("start", "[.detectorintegration]") { Detector det; Caller caller(&det); // PUT only command @@ -2276,7 +2286,7 @@ TEST_CASE("start", "[.cmdcall]") { det.setNumberOfFrames(prev_frames); } -TEST_CASE("stop", "[.cmdcall]") { +TEST_CASE("stop", "[.detectorintegration]") { Detector det; Caller caller(&det); // PUT only command @@ -2321,7 +2331,7 @@ TEST_CASE("stop", "[.cmdcall]") { det.setNumberOfFrames(prev_frames); } -TEST_CASE("status", "[.cmdcall]") { +TEST_CASE("status", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -2360,7 +2370,7 @@ TEST_CASE("status", "[.cmdcall]") { det.setNumberOfFrames(prev_frames); } -TEST_CASE("nextframenumber", "[.cmdcall]") { +TEST_CASE("nextframenumber", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -2467,7 +2477,7 @@ TEST_CASE("nextframenumber", "[.cmdcall]") { } } -TEST_CASE("scan", "[.cmdcall]") { +TEST_CASE("scan", "[.detectorintegration]") { Detector det; Caller caller(&det); defs::dacIndex ind = defs::DAC_0; @@ -2593,7 +2603,7 @@ TEST_CASE("scan", "[.cmdcall]") { } } -TEST_CASE("scanerrmsg", "[.cmdcall]") { +TEST_CASE("scanerrmsg", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("scanerrmsg", {}, -1, GET)); @@ -2602,17 +2612,17 @@ TEST_CASE("scanerrmsg", "[.cmdcall]") { /* Network Configuration (Detector<->Receiver) */ -TEST_CASE("numinterfaces", "[.cmdcall]") { +TEST_CASE("numinterfaces", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) { auto prev_val = det.getNumberofUDPInterfaces().tsquash( "inconsistent numinterfaces to test"); - UdpDestination prev_udp_dest{}; + Result prev_udp_dest; IpAddr prev_src_ip2{}; if (prev_val == 2 && det_type != defs::EIGER) { - prev_udp_dest = det.getDestinationUDPList(0)[0]; + prev_udp_dest = det.getDestinationUDPList(0); prev_src_ip2 = det.getSourceUDPIP2()[0]; } { @@ -2631,8 +2641,10 @@ TEST_CASE("numinterfaces", "[.cmdcall]") { REQUIRE(oss.str() == "numinterfaces 1\n"); } if (prev_val == 2 && det_type != defs::EIGER) { - det.setDestinationUDPList({prev_udp_dest}, 0); - det.setSourceUDPIP2({prev_src_ip2}, {0}); + for (int i = 0; i != det.size(); ++i) { + det.setDestinationUDPList({prev_udp_dest[i]}, {i}); + } + det.setSourceUDPIP2({prev_src_ip2}); } det.setNumberofUDPInterfaces(prev_val); } else if (det_type == defs::EIGER) { @@ -2652,7 +2664,7 @@ TEST_CASE("numinterfaces", "[.cmdcall]") { REQUIRE_THROWS(caller.call("numinterfaces", {"0"}, -1, PUT)); } -TEST_CASE("udp_srcip", "[.cmdcall]") { +TEST_CASE("udp_srcip", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getSourceUDPIP(); @@ -2667,7 +2679,7 @@ TEST_CASE("udp_srcip", "[.cmdcall]") { } } -TEST_CASE("udp_dstlist", "[.cmdcall]") { +TEST_CASE("udp_dstlist", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -2683,7 +2695,7 @@ TEST_CASE("udp_dstlist", "[.cmdcall]") { } } -TEST_CASE("udp_numdst", "[.cmdcall]") { +TEST_CASE("udp_numdst", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -2696,7 +2708,7 @@ TEST_CASE("udp_numdst", "[.cmdcall]") { } } -TEST_CASE("udp_cleardst", "[.cmdcall]") { +TEST_CASE("udp_cleardst", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_THROWS(caller.call("udp_cleardst", {}, -1, GET)); @@ -2704,7 +2716,7 @@ TEST_CASE("udp_cleardst", "[.cmdcall]") { /*REQUIRE_NOTHROW(caller.call("udp_cleardst", {}, -1, PUT));*/ } -TEST_CASE("udp_firstdst", "[.cmdcall]") { +TEST_CASE("udp_firstdst", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -2738,13 +2750,13 @@ TEST_CASE("udp_firstdst", "[.cmdcall]") { } } -TEST_CASE("udp_dstip", "[.cmdcall]") { +TEST_CASE("udp_dstip", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_THROWS(caller.call("udp_dstip", {"0.0.0.0"}, -1, PUT)); } -TEST_CASE("udp_srcmac", "[.cmdcall]") { +TEST_CASE("udp_srcmac", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getSourceUDPMAC(); @@ -2761,13 +2773,13 @@ TEST_CASE("udp_srcmac", "[.cmdcall]") { } } -TEST_CASE("udp_dstmac", "[.cmdcall]") { +TEST_CASE("udp_dstmac", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_THROWS(caller.call("udp_dstmac", {"00:00:00:00:00:00"}, -1, PUT)); } -TEST_CASE("udp_dstport", "[.cmdcall]") { +TEST_CASE("udp_dstport", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getDestinationUDPPort(); @@ -2788,7 +2800,7 @@ TEST_CASE("udp_dstport", "[.cmdcall]") { } } -TEST_CASE("udp_srcip2", "[.cmdcall]") { +TEST_CASE("udp_srcip2", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -2810,7 +2822,7 @@ TEST_CASE("udp_srcip2", "[.cmdcall]") { } } -TEST_CASE("udp_dstip2", "[.cmdcall]") { +TEST_CASE("udp_dstip2", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -2822,7 +2834,7 @@ TEST_CASE("udp_dstip2", "[.cmdcall]") { } } -TEST_CASE("udp_srcmac2", "[.cmdcall]") { +TEST_CASE("udp_srcmac2", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -2846,7 +2858,7 @@ TEST_CASE("udp_srcmac2", "[.cmdcall]") { } } -TEST_CASE("udp_dstmac2", "[.cmdcall]") { +TEST_CASE("udp_dstmac2", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -2859,7 +2871,7 @@ TEST_CASE("udp_dstmac2", "[.cmdcall]") { } } -TEST_CASE("udp_dstport2", "[.cmdcall]") { +TEST_CASE("udp_dstport2", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -2888,21 +2900,21 @@ TEST_CASE("udp_dstport2", "[.cmdcall]") { } } -TEST_CASE("udp_reconfigure", "[.cmdcall]") { +TEST_CASE("udp_reconfigure", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_THROWS(caller.call("udp_reconfigure", {}, -1, GET)); REQUIRE_NOTHROW(caller.call("udp_reconfigure", {}, -1, PUT)); } -TEST_CASE("udp_validate", "[.cmdcall]") { +TEST_CASE("udp_validate", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_THROWS(caller.call("udp_validate", {}, -1, GET)); REQUIRE_NOTHROW(caller.call("udp_validate", {}, -1, PUT)); } -TEST_CASE("tengiga", "[.cmdcall]") { +TEST_CASE("tengiga", "[.detectorintegration]") { Detector det; Caller caller(&det); @@ -2926,7 +2938,7 @@ TEST_CASE("tengiga", "[.cmdcall]") { } } -TEST_CASE("flowcontrol10g", "[.cmdcall]") { +TEST_CASE("flowcontrol10g", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -2957,7 +2969,7 @@ TEST_CASE("flowcontrol10g", "[.cmdcall]") { } } -TEST_CASE("txdelay_frame", "[.cmdcall]") { +TEST_CASE("txdelay_frame", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -2985,7 +2997,7 @@ TEST_CASE("txdelay_frame", "[.cmdcall]") { } } -TEST_CASE("txdelay", "[.cmdcall]") { +TEST_CASE("txdelay", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -3061,7 +3073,7 @@ TEST_CASE("txdelay", "[.cmdcall]") { /* ZMQ Streaming Parameters (Receiver<->Client) */ -TEST_CASE("zmqport", "[.cmdcall]") { +TEST_CASE("zmqport", "[.detectorintegration]") { Detector det; Caller caller(&det); @@ -3116,7 +3128,7 @@ TEST_CASE("zmqport", "[.cmdcall]") { } } -TEST_CASE("zmqip", "[.cmdcall]") { +TEST_CASE("zmqip", "[.detectorintegration]") { Detector det; Caller caller(&det); std::ostringstream oss1, oss2; @@ -3132,7 +3144,7 @@ TEST_CASE("zmqip", "[.cmdcall]") { } } -TEST_CASE("zmqhwm", "[.cmdcall]") { +TEST_CASE("zmqhwm", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getClientZmqHwm(); @@ -3161,7 +3173,7 @@ TEST_CASE("zmqhwm", "[.cmdcall]") { /* Advanced */ -TEST_CASE("adcpipeline", "[.cmdcall]") { +TEST_CASE("adcpipeline", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -3196,7 +3208,7 @@ TEST_CASE("adcpipeline", "[.cmdcall]") { } } -TEST_CASE("programfpga", "[.cmdcall]") { +TEST_CASE("programfpga", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -3212,7 +3224,7 @@ TEST_CASE("programfpga", "[.cmdcall]") { } } -TEST_CASE("resetfpga", "[.cmdcall]") { +TEST_CASE("resetfpga", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -3228,7 +3240,7 @@ TEST_CASE("resetfpga", "[.cmdcall]") { } } -TEST_CASE("updatekernel", "[.cmdcall]") { +TEST_CASE("updatekernel", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -3247,7 +3259,7 @@ TEST_CASE("updatekernel", "[.cmdcall]") { } } -TEST_CASE("rebootcontroller", "[.cmdcall]") { +TEST_CASE("rebootcontroller", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -3263,7 +3275,7 @@ TEST_CASE("rebootcontroller", "[.cmdcall]") { } } -TEST_CASE("update", "[.cmdcall]") { +TEST_CASE("update", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -3281,7 +3293,7 @@ TEST_CASE("update", "[.cmdcall]") { } } -TEST_CASE("reg", "[.cmdcall][.definecmds]") { +TEST_CASE("reg", "[.detectorintegration][.definecmds]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -3319,7 +3331,7 @@ TEST_CASE("reg", "[.cmdcall][.definecmds]") { } } -TEST_CASE("adcreg", "[.cmdcall]") { +TEST_CASE("adcreg", "[.detectorintegration]") { // TODO! what is a safe value to use? Detector det; Caller caller(&det); @@ -3340,7 +3352,7 @@ TEST_CASE("adcreg", "[.cmdcall]") { } } -TEST_CASE("setbit", "[.cmdcall][.definecmds]") { +TEST_CASE("setbit", "[.detectorintegration][.definecmds]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -3370,7 +3382,7 @@ TEST_CASE("setbit", "[.cmdcall][.definecmds]") { } } -TEST_CASE("clearbit", "[.cmdcall][.definecmds]") { +TEST_CASE("clearbit", "[.detectorintegration][.definecmds]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -3400,7 +3412,7 @@ TEST_CASE("clearbit", "[.cmdcall][.definecmds]") { } } -TEST_CASE("getbit", "[.cmdcall][.definecmds]") { +TEST_CASE("getbit", "[.detectorintegration][.definecmds]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -3430,7 +3442,7 @@ TEST_CASE("getbit", "[.cmdcall][.definecmds]") { } } -TEST_CASE("firmwaretest", "[.cmdcall]") { +TEST_CASE("firmwaretest", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -3447,7 +3459,7 @@ TEST_CASE("firmwaretest", "[.cmdcall]") { } } -TEST_CASE("bustest", "[.cmdcall]") { +TEST_CASE("bustest", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -3464,7 +3476,7 @@ TEST_CASE("bustest", "[.cmdcall]") { } } -TEST_CASE("initialchecks", "[.cmdcall]") { +TEST_CASE("initialchecks", "[.detectorintegration]") { Detector det; Caller caller(&det); auto check = det.getInitialChecks(); @@ -3486,7 +3498,7 @@ TEST_CASE("initialchecks", "[.cmdcall]") { det.setInitialChecks(check); } -TEST_CASE("adcinvert", "[.cmdcall]") { +TEST_CASE("adcinvert", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -3514,7 +3526,7 @@ TEST_CASE("adcinvert", "[.cmdcall]") { /* Insignificant */ -TEST_CASE("port", "[.cmdcall]") { +TEST_CASE("port", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getControlPort({0}).squash(); @@ -3538,7 +3550,7 @@ TEST_CASE("port", "[.cmdcall]") { det.setControlPort(prev_val, {0}); } -TEST_CASE("stopport", "[.cmdcall]") { +TEST_CASE("stopport", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getStopPort({0}).squash(); @@ -3562,7 +3574,7 @@ TEST_CASE("stopport", "[.cmdcall]") { det.setStopPort(prev_val, {0}); } -TEST_CASE("lock", "[.cmdcall]") { +TEST_CASE("lock", "[.detectorintegration]") { Detector det; Caller caller(&det); auto prev_val = det.getDetectorLock(); @@ -3586,13 +3598,13 @@ TEST_CASE("lock", "[.cmdcall]") { } } -TEST_CASE("execcommand", "[.cmdcall]") { +TEST_CASE("execcommand", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("execcommand", {"ls *.txt"}, -1, PUT)); } -TEST_CASE("framecounter", "[.cmdcall]") { +TEST_CASE("framecounter", "[.detectorintegration]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); @@ -3610,7 +3622,7 @@ TEST_CASE("framecounter", "[.cmdcall]") { } } -TEST_CASE("runtime", "[.cmdcall]") { +TEST_CASE("runtime", "[.detectorintegration]") { // TODO! can we test this? Detector det; Caller caller(&det); @@ -3628,7 +3640,7 @@ TEST_CASE("runtime", "[.cmdcall]") { } } -TEST_CASE("frametime", "[.cmdcall]") { +TEST_CASE("frametime", "[.detectorintegration]") { // TODO! can we test this? Detector det; Caller caller(&det); @@ -3646,14 +3658,14 @@ TEST_CASE("frametime", "[.cmdcall]") { } } -TEST_CASE("user", "[.cmdcall]") { +TEST_CASE("user", "[.detectorintegration]") { Detector det; Caller caller(&det); // caller only has help. cmdApp takes care of put and get REQUIRE_NOTHROW(caller.call("user", {}, -1, defs::HELP_ACTION)); } -TEST_CASE("sleep", "[.cmdcall]") { +TEST_CASE("sleep", "[.detectorintegration]") { Detector det; Caller caller(&det); REQUIRE_NOTHROW(caller.call("sleep", {"1"}, -1, PUT)); diff --git a/slsReceiverSoftware/src/BinaryDataFile.cpp b/slsReceiverSoftware/src/BinaryDataFile.cpp index 4f5b90f4d..bc8438277 100644 --- a/slsReceiverSoftware/src/BinaryDataFile.cpp +++ b/slsReceiverSoftware/src/BinaryDataFile.cpp @@ -19,16 +19,15 @@ void BinaryDataFile::CloseFile() { fd = nullptr; } -void BinaryDataFile::CreateFirstBinaryDataFile(const std::string &fNamePrefix, - const uint64_t fIndex, - const bool ovEnable, - const bool sMode, - const uint16_t uPortNumber, - const uint32_t mFramesPerFile) { +void BinaryDataFile::CreateFirstBinaryDataFile( + const std::filesystem::path &filePath, const std::string &fNamePrefix, + const uint64_t fIndex, const bool ovEnable, const bool sMode, + const uint16_t uPortNumber, const uint32_t mFramesPerFile) { subFileIndex = 0; numFramesInFile = 0; + m_filePath = filePath; fileNamePrefix = fNamePrefix; fileIndex = fIndex; overWriteEnable = ovEnable; @@ -42,9 +41,10 @@ void BinaryDataFile::CreateFirstBinaryDataFile(const std::string &fNamePrefix, void BinaryDataFile::CreateFile() { numFramesInFile = 0; - std::ostringstream os; - os << fileNamePrefix << "_f" << subFileIndex << '_' << fileIndex << ".raw"; - fileName = os.str(); + std::filesystem::path p = + m_filePath / (fileNamePrefix + "_f" + std::to_string(subFileIndex) + + '_' + std::to_string(fileIndex) + ".raw"); + fileName = p.string(); if (!overWriteEnable) { if (nullptr == (fd = fopen(fileName.c_str(), "wx"))) { diff --git a/slsReceiverSoftware/src/BinaryDataFile.h b/slsReceiverSoftware/src/BinaryDataFile.h index 79daffa61..5fc43f4cb 100644 --- a/slsReceiverSoftware/src/BinaryDataFile.h +++ b/slsReceiverSoftware/src/BinaryDataFile.h @@ -14,7 +14,8 @@ class BinaryDataFile : private virtual slsDetectorDefs, public File { fileFormat GetFileFormat() const override; void CloseFile() override; - void CreateFirstBinaryDataFile(const std::string &fNamePrefix, + void CreateFirstBinaryDataFile(const std::filesystem::path &filePath, + const std::string &fNamePrefix, const uint64_t fIndex, const bool ovEnable, const bool sMode, const uint16_t uPortNumber, const uint32_t mFramesPerFile) override; @@ -29,6 +30,7 @@ class BinaryDataFile : private virtual slsDetectorDefs, public File { uint32_t index; FILE *fd{nullptr}; std::string fileName; + std::filesystem::path m_filePath; uint32_t numFramesInFile{0}; uint32_t subFileIndex{0}; diff --git a/slsReceiverSoftware/src/DataProcessor.cpp b/slsReceiverSoftware/src/DataProcessor.cpp index 8631af36c..e6303c188 100644 --- a/slsReceiverSoftware/src/DataProcessor.cpp +++ b/slsReceiverSoftware/src/DataProcessor.cpp @@ -148,7 +148,8 @@ void DataProcessor::SetupFileWriter(const bool filewriteEnable, } } -void DataProcessor::CreateFirstFiles(const std::string &fileNamePrefix, +void DataProcessor::CreateFirstFiles(const std::filesystem::path &filePath, + const std::string &fileNamePrefix, const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode, @@ -178,14 +179,14 @@ void DataProcessor::CreateFirstFiles(const std::string &fileNamePrefix, #ifdef HDF5C case HDF5: dataFile->CreateFirstHDF5DataFile( - fileNamePrefix, fileIndex, overWriteEnable, silentMode, + filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode, udpPortNumber, generalData->framesPerFile, nTotalFrames, nx, ny, generalData->dynamicRange); break; #endif case BINARY: dataFile->CreateFirstBinaryDataFile( - fileNamePrefix, fileIndex, overWriteEnable, silentMode, + filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode, udpPortNumber, generalData->framesPerFile); break; default: @@ -203,7 +204,7 @@ uint32_t DataProcessor::GetFilesInAcquisition() const { } std::string DataProcessor::CreateVirtualFile( - const std::string &filePath, const std::string &fileNamePrefix, + const std::filesystem::path &filePath, const std::string &fileNamePrefix, const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode, const int modulePos, const int numModX, const int numModY, std::mutex *hdf5LibMutex, bool gotthard25um) { @@ -247,7 +248,7 @@ void DataProcessor::LinkFileInMaster(const std::string &masterFileName, #endif std::string DataProcessor::CreateMasterFile( - const std::string &filePath, const std::string &fileNamePrefix, + const std::filesystem::path &filePath, const std::string &fileNamePrefix, const uint64_t fileIndex, const bool overWriteEnable, bool silentMode, const fileFormat fileFormatType, MasterAttributes *attr, std::mutex *hdf5LibMutex) { diff --git a/slsReceiverSoftware/src/DataProcessor.h b/slsReceiverSoftware/src/DataProcessor.h index dfed87819..9aef85445 100644 --- a/slsReceiverSoftware/src/DataProcessor.h +++ b/slsReceiverSoftware/src/DataProcessor.h @@ -15,6 +15,7 @@ #include "receiver_defs.h" #include +#include #include #include @@ -59,12 +60,13 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject { const fileFormat fileFormatType, std::mutex *hdf5LibMutex); - void CreateFirstFiles(const std::string &fileNamePrefix, + void CreateFirstFiles(const std::filesystem::path &filePath, + const std::string &fileNamePrefix, const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode, const bool detectorDataStream); #ifdef HDF5C uint32_t GetFilesInAcquisition() const; - std::string CreateVirtualFile(const std::string &filePath, + std::string CreateVirtualFile(const std::filesystem::path &filePath, const std::string &fileNamePrefix, const uint64_t fileIndex, const bool overWriteEnable, @@ -76,7 +78,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject { const bool silentMode, std::mutex *hdf5LibMutex); #endif - std::string CreateMasterFile(const std::string &filePath, + std::string CreateMasterFile(const std::filesystem::path &filePath, const std::string &fileNamePrefix, const uint64_t fileIndex, const bool overWriteEnable, bool silentMode, diff --git a/slsReceiverSoftware/src/File.h b/slsReceiverSoftware/src/File.h index c30a86238..18bc32496 100644 --- a/slsReceiverSoftware/src/File.h +++ b/slsReceiverSoftware/src/File.h @@ -6,6 +6,7 @@ #include "sls/sls_detector_defs.h" #include +#include #ifdef HDF5C #include "H5Cpp.h" @@ -56,6 +57,7 @@ class File : private virtual slsDetectorDefs { }; virtual void CreateFirstHDF5DataFile( + const std::filesystem::path &filePath, const std::string &fileNamePrefix, const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode, const uint16_t udpPortNumber, const uint32_t maxFramesPerFile, @@ -66,12 +68,11 @@ class File : private virtual slsDetectorDefs { "should be overloaded by a derived class"; }; #endif - virtual void CreateFirstBinaryDataFile(const std::string &fileNamePrefix, - const uint64_t fileIndex, - const bool overWriteEnable, - const bool silentMode, - const uint16_t udpPortNumber, - const uint32_t maxFramesPerFile) { + virtual void CreateFirstBinaryDataFile( + const std::filesystem::path &filePath, + const std::string &fileNamePrefix, const uint64_t fileIndex, + const bool overWriteEnable, const bool silentMode, + const uint16_t udpPortNumber, const uint32_t maxFramesPerFile) { LOG(logERROR) << "This is a generic function CreateFirstBinaryDataFile that " "should be overloaded by a derived class"; diff --git a/slsReceiverSoftware/src/HDF5DataFile.cpp b/slsReceiverSoftware/src/HDF5DataFile.cpp index 2b267f474..8dc2f4598 100644 --- a/slsReceiverSoftware/src/HDF5DataFile.cpp +++ b/slsReceiverSoftware/src/HDF5DataFile.cpp @@ -87,8 +87,9 @@ void HDF5DataFile::CloseFile() { } void HDF5DataFile::CreateFirstHDF5DataFile( - const std::string &fNamePrefix, const uint64_t fIndex, const bool owEnable, - const bool sMode, const uint16_t uPortNumber, const uint32_t mFramesPerFile, + const std::filesystem::path &filePath, const std::string &fNamePrefix, + const uint64_t fIndex, const bool owEnable, const bool sMode, + const uint16_t uPortNumber, const uint32_t mFramesPerFile, const uint64_t nImages, const uint32_t nX, const uint32_t nY, const uint32_t dr) { @@ -103,6 +104,7 @@ void HDF5DataFile::CreateFirstHDF5DataFile( nPixelsY = nY; dynamicRange = dr; + m_filePath = filePath; fileNamePrefix = fNamePrefix; fileIndex = fIndex; overWriteEnable = owEnable; @@ -129,9 +131,10 @@ void HDF5DataFile::CreateFile() { numFramesInFile = 0; numFilesInAcquisition++; - std::ostringstream os; - os << fileNamePrefix << "_f" << subFileIndex << '_' << fileIndex << ".h5"; - fileName = os.str(); + std::filesystem::path p = + m_filePath / (fileNamePrefix + "_f" + std::to_string(subFileIndex) + + '_' + std::to_string(fileIndex) + ".h5"); + fileName = p.string(); std::lock_guard lock(*hdf5Lib); diff --git a/slsReceiverSoftware/src/HDF5DataFile.h b/slsReceiverSoftware/src/HDF5DataFile.h index e3a7b19b3..06dabe2d2 100644 --- a/slsReceiverSoftware/src/HDF5DataFile.h +++ b/slsReceiverSoftware/src/HDF5DataFile.h @@ -3,7 +3,6 @@ #pragma once #include "File.h" - #include namespace sls { @@ -23,7 +22,8 @@ class HDF5DataFile : private virtual slsDetectorDefs, public File { void CloseFile() override; - void CreateFirstHDF5DataFile(const std::string &fNamePrefix, + void CreateFirstHDF5DataFile(const std::filesystem::path &filePath, + const std::string &fNamePrefix, const uint64_t fIndex, const bool owEnable, const bool sMode, const uint16_t uPortNumber, const uint32_t mFramesPerFile, @@ -65,7 +65,8 @@ class HDF5DataFile : private virtual slsDetectorDefs, public File { uint32_t nPixelsY{0}; uint32_t dynamicRange{0}; - std::string fileNamePrefix; + std::filesystem::path m_filePath{}; + std::string fileNamePrefix{}; uint64_t fileIndex{0}; bool overWriteEnable{false}; bool silentMode{false}; diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index afffb317d..292c5df29 100644 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -483,10 +483,14 @@ void Implementation::setFileFormat(const fileFormat f) { LOG(logINFO) << "File Format: " << ToString(fileFormatType); } -std::string Implementation::getFilePath() const { return filePath; } +std::string Implementation::getFilePath() const { return filePath.string(); } void Implementation::setFilePath(const std::string &c) { - filePath = c; + // check if filePath empty and throw error + if (c.empty()) { + throw ReceiverError("File path cannot be empty"); + } + filePath = std::filesystem::path(c); LOG(logINFO) << "File path: " << filePath; } @@ -651,7 +655,7 @@ void Implementation::startReceiver() { generalData->dynamicRange, numPorts, static_cast(generalData->imageSize), - filePath, + filePath.string(), fileName, fileIndex, quadEnable, @@ -813,7 +817,8 @@ void Implementation::startReadout() { << "waiting for all packets, previousValue:" << previousValue << " totalPacketsReceived: " << totalPacketsReceived; - /* TODO! Need to find optimal time **/ + /* TODO! Need to find optimal time - xilinx and jungfrau need + * more time */ std::this_thread::sleep_for(std::chrono::milliseconds(5)); previousValue = totalPacketsReceived; totalPacketsReceived = 0; @@ -850,9 +855,7 @@ void Implementation::ResetParametersforNewAcquisition() { it->ResetParametersforNewAcquisition(); if (dataStreamEnable) { - std::ostringstream os; - os << filePath << '/' << fileName; - std::string fnametostream = os.str(); + std::string fnametostream = (filePath / fileName).string(); for (const auto &it : dataStreamer) it->ResetParametersforNewAcquisition(fnametostream); } @@ -873,21 +876,28 @@ void Implementation::CreateUDPSockets() { void Implementation::SetupWriter() { try { - // check if filePath empty and throw error - if (filePath.empty()) { - throw ReceiverError("File path cannot be empty"); - } // check if folder exists and throw if it cant create - mkdir_p(filePath); + if (filePath.empty()) { + throw RuntimeError("File path cannot be empty. Please set file " + "path before starting acquisition."); + } + if (!std::filesystem::exists(filePath)) { + try { + std::filesystem::create_directories(filePath); + } catch (const std::filesystem::filesystem_error &e) { + throw RuntimeError("Could not create directory: " + + filePath.string() + ". Error: " + e.what()); + } + } // create first files for (unsigned int i = 0; i < dataProcessor.size(); ++i) { - std::ostringstream os; - os << filePath << "/" << fileName << "_d" - << (modulePos * generalData->numUDPInterfaces + i); - std::string fileNamePrefix = os.str(); - dataProcessor[i]->CreateFirstFiles(fileNamePrefix, fileIndex, - overwriteEnable, silentMode, - detectorDataStream[i]); + + std::string fileNamePrefix = + fileName + "_d" + + std::to_string(modulePos * generalData->numUDPInterfaces + i); + dataProcessor[i]->CreateFirstFiles( + filePath, fileNamePrefix, fileIndex, overwriteEnable, + silentMode, detectorDataStream[i]); } } catch (const RuntimeError &e) { shutDownUDPSockets(); diff --git a/slsReceiverSoftware/src/Implementation.h b/slsReceiverSoftware/src/Implementation.h index 2699bbfc4..3680cb84e 100644 --- a/slsReceiverSoftware/src/Implementation.h +++ b/slsReceiverSoftware/src/Implementation.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -316,7 +317,7 @@ class Implementation : private virtual slsDetectorDefs { // file parameters fileFormat fileFormatType{BINARY}; - std::string filePath{}; + std::filesystem::path filePath{}; std::string fileName{"run"}; uint64_t fileIndex{0}; bool fileWriteEnable{false}; diff --git a/slsReceiverSoftware/src/MasterFileUtility.cpp b/slsReceiverSoftware/src/MasterFileUtility.cpp index a4e782744..ffead18a9 100644 --- a/slsReceiverSoftware/src/MasterFileUtility.cpp +++ b/slsReceiverSoftware/src/MasterFileUtility.cpp @@ -9,16 +9,17 @@ namespace sls { namespace masterFileUtility { -std::string CreateMasterBinaryFile(const std::string &filePath, +std::string CreateMasterBinaryFile(const std::filesystem::path &filePath, const std::string &fileNamePrefix, const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode, MasterAttributes *attr) { - std::ostringstream os; - os << filePath << "/" << fileNamePrefix << "_master" - << "_" << fileIndex << ".json"; - std::string fileName = os.str(); + + std::filesystem::path p = filePath / (fileNamePrefix + "_master_" + + std::to_string(fileIndex) + ".json"); + + std::string fileName = p.string(); std::string mode = "w"; if (!overWriteEnable) @@ -112,17 +113,16 @@ void LinkHDF5FileInMaster(std::string &masterFileName, } } -std::string CreateMasterHDF5File(const std::string &filePath, +std::string CreateMasterHDF5File(const std::filesystem::path &filePath, const std::string &fileNamePrefix, const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode, MasterAttributes *attr, std::mutex *hdf5LibMutex) { - std::ostringstream os; - os << filePath << "/" << fileNamePrefix << "_master" - << "_" << fileIndex << ".h5"; - std::string fileName = os.str(); + std::filesystem::path p = filePath / (fileNamePrefix + "_master_" + + std::to_string(fileIndex) + ".json"); + std::string fileName = p.string(); std::lock_guard lock(*hdf5LibMutex); @@ -185,7 +185,7 @@ int GetNumPortsInRoi(const defs::ROI roi, const defs::xy portSize) { /** Will not be called if dynamic range is 4 and roi enabled */ std::string CreateVirtualHDF5File( - const std::string &filePath, const std::string &fileNamePrefix, + const std::filesystem::path &filePath, const std::string &fileNamePrefix, const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode, const int modulePos, const int numUnitsPerReadout, const uint32_t maxFramesPerFile, const int nPixelsX, const int nPixelsY, @@ -202,10 +202,11 @@ std::string CreateVirtualHDF5File( } // virtual file name - std::ostringstream osfn; - osfn << filePath << "/" << fileNamePrefix << "_virtual" - << "_" << fileIndex << ".h5"; - std::string fileName = osfn.str(); + std::filesystem::path p = filePath / (fileNamePrefix + "_virtual_" + + std::to_string(fileIndex) + ".h5"); + + std::string fileName = p.string(); + unsigned int paraSize = parameterNames.size(); std::lock_guard lock(*hdf5LibMutex); std::unique_ptr fd{nullptr}; @@ -331,12 +332,15 @@ std::string CreateVirtualHDF5File( H5S_SELECT_SET, numBlocksPara, startLocationPara, strideBetweenBlocksPara, blockSizePara); - // source file name - std::ostringstream os; - os << filePath << "/" << fileNamePrefix << "_d" - << (modulePos * numUnitsPerReadout + iReadout) << "_f" - << iFile << '_' << fileIndex << ".h5"; - std::string srcFileName = os.str(); + std::filesystem::path p = + filePath / + (fileNamePrefix + "_d" + + std::to_string(modulePos * numUnitsPerReadout + + iReadout) + + "_f" + std::to_string(iFile) + '_' + + std::to_string(fileIndex) + ".h5"); + + std::string srcFileName = p.string(); LOG(logDEBUG1) << srcFileName; // find relative path diff --git a/slsReceiverSoftware/src/MasterFileUtility.h b/slsReceiverSoftware/src/MasterFileUtility.h index cbf68be39..795607079 100644 --- a/slsReceiverSoftware/src/MasterFileUtility.h +++ b/slsReceiverSoftware/src/MasterFileUtility.h @@ -4,13 +4,14 @@ #include "MasterAttributes.h" +#include #include namespace sls { namespace masterFileUtility { -std::string CreateMasterBinaryFile(const std::string &filePath, +std::string CreateMasterBinaryFile(const std::filesystem::path &filePath, const std::string &fileNamePrefix, const uint64_t fileIndex, const bool overWriteEnable, @@ -24,7 +25,7 @@ void LinkHDF5FileInMaster(std::string &masterFileName, const bool silentMode, std::mutex *hdf5LibMutex, size_t multiRoiSize); -std::string CreateMasterHDF5File(const std::string &filePath, +std::string CreateMasterHDF5File(const std::filesystem::path &filePath, const std::string &fileNamePrefix, const uint64_t fileIndex, const bool overWriteEnable, @@ -35,7 +36,7 @@ defs::ROI GetGlobalPortRoi(const int iPort, const defs::xy portSize, int GetNumPortsInRoi(const defs::ROI roi, const defs::xy portSize); std::string CreateVirtualHDF5File( - const std::string &filePath, const std::string &fileNamePrefix, + const std::filesystem::path &filePath, const std::string &fileNamePrefix, const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode, const int modulePos, const int numUnitsPerReadout, const uint32_t maxFramesPerFile, const int nPixelsX, const int nPixelsY, diff --git a/slsReceiverSoftware/tests/test-ArrangeDataBasedOnBitList.cpp b/slsReceiverSoftware/tests/test-ArrangeDataBasedOnBitList.cpp index db278658e..54f60d0cb 100644 --- a/slsReceiverSoftware/tests/test-ArrangeDataBasedOnBitList.cpp +++ b/slsReceiverSoftware/tests/test-ArrangeDataBasedOnBitList.cpp @@ -140,7 +140,7 @@ class DataProcessorTestFixture { }; TEST_CASE_METHOD(DataProcessorTestFixture, "Remove Trailing Bits", - "[.dataprocessor][.bitoffset]") { + "[dataprocessor][bitoffset]") { const size_t num_random_offset_bytes = 3; set_random_offset_bytes(num_random_offset_bytes); @@ -170,7 +170,7 @@ TEST_CASE_METHOD(DataProcessorTestFixture, "Remove Trailing Bits", // parametric test tested with num_samples = 5, num_samples = 10, num_samples = // 8 TEST_CASE_METHOD(DataProcessorTestFixture, "Reorder all", - "[.dataprocessor][.reorder]") { + "[dataprocessor][reorder]") { // parameters: num_samples, expected_num_digital_bytes, // expected_digital_part_for_each_bit auto parameters = GENERATE( @@ -219,7 +219,7 @@ TEST_CASE_METHOD(DataProcessorTestFixture, "Reorder all", TEST_CASE_METHOD(DataProcessorTestFixture, "Reorder all and remove trailing bits", - "[.dataprocessor][.reorder]") { + "[dataprocessor][reorder]") { // set number of samples for test fixture -> create data const size_t num_random_offset_bytes = 3; @@ -261,7 +261,7 @@ TEST_CASE_METHOD(DataProcessorTestFixture, } TEST_CASE_METHOD(DataProcessorTestFixture, "Arrange bitlist with reorder false", - "[.dataprocessor][.retrievebitlist]") { + "[dataprocessor][retrievebitlist]") { // parameters: num_samples, bitlist, expected_num_digital_bytes, // expected_digital_part auto parameters = GENERATE( @@ -315,7 +315,7 @@ TEST_CASE_METHOD(DataProcessorTestFixture, "Arrange bitlist with reorder false", } TEST_CASE_METHOD(DataProcessorTestFixture, "Arrange bitlist with reorder true", - "[.dataprocessor][.retrievebitlist]") { + "[dataprocessor][retrievebitlist]") { // parameters: num_samples, bitlist, expected_num_digital_bytes, // expected_digital_part auto parameters = GENERATE( @@ -369,7 +369,7 @@ TEST_CASE_METHOD(DataProcessorTestFixture, "Arrange bitlist with reorder true", TEST_CASE_METHOD(DataProcessorTestFixture, "Arrange bitlist and remove trailing bits", - "[.dataprocessor][.retrievebitlist]") { + "[dataprocessor][retrievebitlist]") { size_t num_random_offset_bytes = 3; std::vector bitlist{1, 4, 5}; diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index 6d49fee7e..9296547de 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -299,6 +299,8 @@ enum detFuncs { F_SET_COLLECTION_MODE, F_GET_PATTERN_WAIT_INTERVAL, F_SET_PATTERN_WAIT_INTERVAL, + F_SPI_READ, + F_SPI_WRITE, NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 512, /**< detector function should not exceed this @@ -709,6 +711,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_SET_COLLECTION_MODE: return "F_SET_COLLECTION_MODE"; case F_GET_PATTERN_WAIT_INTERVAL: return "F_GET_PATTERN_WAIT_INTERVAL"; case F_SET_PATTERN_WAIT_INTERVAL: return "F_SET_PATTERN_WAIT_INTERVAL"; + case F_SPI_READ: return "F_SPI_READ"; + case F_SPI_WRITE: return "F_SPI_WRITE"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index 8e7c2d493..245acb823 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -7,6 +7,6 @@ #define APIGOTTHARD2 "0.0.0 0x250909" #define APIMOENCH "0.0.0 0x250909" #define APIEIGER "0.0.0 0x250909" -#define APIXILINXCTB "0.0.0 0x260122" +#define APIXILINXCTB "0.0.0 0x260128" #define APIJUNGFRAU "0.0.0 0x250909" #define APIMYTHEN3 "0.0.0 0x250922" diff --git a/slsSupportLib/tests/test-Timer.cpp b/slsSupportLib/tests/test-Timer.cpp index 6d94f1f7b..a4e768334 100644 --- a/slsSupportLib/tests/test-Timer.cpp +++ b/slsSupportLib/tests/test-Timer.cpp @@ -8,7 +8,7 @@ namespace sls { -TEST_CASE("Time 1s restart then time 2s", "[.timer]") { +TEST_CASE("Time 1s restart then time 2s", "[timer]") { auto sleep_duration = std::chrono::seconds(1); auto t = Timer(); std::this_thread::sleep_for(sleep_duration); @@ -19,7 +19,7 @@ TEST_CASE("Time 1s restart then time 2s", "[.timer]") { REQUIRE(t.elapsed_s() == Approx(2).epsilon(0.01)); } -TEST_CASE("Return ms", "[.timer]") { +TEST_CASE("Return ms", "[timer]") { auto sleep_duration = std::chrono::milliseconds(1300); auto t = Timer(); std::this_thread::sleep_for(sleep_duration); diff --git a/slsSupportLib/tests/test-Version.cpp b/slsSupportLib/tests/test-Version.cpp index 9c1f1d3f8..5870c9b56 100644 --- a/slsSupportLib/tests/test-Version.cpp +++ b/slsSupportLib/tests/test-Version.cpp @@ -5,7 +5,7 @@ namespace sls { -TEST_CASE("check if version is semantic", "[.version]") { +TEST_CASE("check if version is semantic", "[version]") { auto [version_string, has_semantic_version] = GENERATE(std::make_tuple("developer 0x250512", false), diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9f3d1b7c9..84e727629 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -60,7 +60,3 @@ catch_discover_tests(tests) configure_file(scripts/test_simulators.py ${CMAKE_BINARY_DIR}/bin/test_simulators.py COPYONLY) configure_file(scripts/test_frame_synchronizer.py ${CMAKE_BINARY_DIR}/bin/test_frame_synchronizer.py COPYONLY) configure_file(scripts/utils_for_test.py ${CMAKE_BINARY_DIR}/bin/utils_for_test.py COPYONLY) -configure_file(scripts/test_roi.py ${CMAKE_BINARY_DIR}/bin/test_roi.py COPYONLY) -configure_file(scripts/test_free.py ${CMAKE_BINARY_DIR}/bin/test_free.py COPYONLY) -configure_file(scripts/test_commands.py ${CMAKE_BINARY_DIR}/bin/test_commands.py COPYONLY) - diff --git a/tests/scripts/test_commands.py b/tests/scripts/test_commands.py deleted file mode 100644 index 73d28442e..000000000 --- a/tests/scripts/test_commands.py +++ /dev/null @@ -1,100 +0,0 @@ -# SPDX-License-Identifier: LGPL-3.0-or-other -# Copyright (C) 2021 Contributors to the SLS Detector Package -''' -This file is used to start up simulators and test for freeing shm and accessing it from python. -Run this using: pytest -s test_free.py -''' - -from time import time -import pytest, sys, time - -from slsdet import Detector, Ctb, freeSharedMemory -from slsdet.defines import DEFAULT_TCP_RX_PORTNO -from utils_for_test import ( - Log, - LogLevel, - cleanup, - startDetectorVirtualServer, - startProcessInBackground, - loadConfig, - loadBasicSettings -) - -def startReceiver(num_mods, fp): - if num_mods == 1: - cmd = ['slsReceiver'] - else: - cmd = ['slsMultiReceiver', str(DEFAULT_TCP_RX_PORTNO), str(num_mods)] - # in 10.0.0 - #cmd = ['slsMultiReceiver', '-p', str(DEFAULT_TCP_RX_PORTNO), '-n', str(num_mods)] - startProcessInBackground(cmd, fp) - time.sleep(1) - -''' -scope = module =>Once per test file/module -to share expensive setup like startDetectorVirtualServer -''' -@pytest.fixture(scope="module") -def det_config(): - return { - "name": "ctb", - "num_mods": 1 - } - -# autouse is false to pass explictly -@pytest.fixture(scope="module", autouse=False) -def setup_simulator(det_config): - """Fixture to start the detector server once and clean up at the end.""" - fp = sys.stdout - - cleanup(fp) - # server - startDetectorVirtualServer(det_config["name"], det_config["num_mods"], fp) - # receiver - startReceiver(det_config["num_mods"], fp) - # config and basic settings - d = loadConfig(name=det_config["name"], rx_hostname="localhost", settingsdir="", fp=fp, num_mods=det_config["num_mods"]) - loadBasicSettings(name=det_config["name"], d=d, fp=fp) - - yield d # tests run here - - cleanup(fp) - - - -def test_parameters_file(setup_simulator): - d = setup_simulator - Log(LogLevel.INFOBLUE, f'\nRunning test_parameters_file') - - assert isinstance(d, Detector) - - with open("/tmp/params.det", "w") as f: - f.write("frames 2\n") - f.write("fwrite 1\n") - - # this should not throw - d.parameters = "/tmp/params.det" - - assert d.frames == 2 - assert d.fwrite == 1 - - Log(LogLevel.INFOGREEN, f"✅ Test passed. Command: parameters") - - -def test_include_file(setup_simulator): - d = setup_simulator - Log(LogLevel.INFOBLUE, f'\test_include_file test_parameters_file') - - assert isinstance(d, Detector) - - with open("/tmp/params.det", "w") as f: - f.write("frames 3\n") - f.write("fwrite 0\n") - - # this should not throw - d.include = "/tmp/params.det" - - assert d.frames == 3 - assert d.fwrite == 0 - - Log(LogLevel.INFOGREEN, f"✅ Test passed. Command: include") diff --git a/tests/scripts/test_frame_synchronizer.py b/tests/scripts/test_frame_synchronizer.py index 6653c96cb..0f25b02a4 100644 --- a/tests/scripts/test_frame_synchronizer.py +++ b/tests/scripts/test_frame_synchronizer.py @@ -14,44 +14,43 @@ from utils_for_test import ( Log, LogLevel, RuntimeException, - checkIfProcessRunning, - killProcess, cleanup, - cleanSharedmemory, startProcessInBackground, - startProcessInBackgroundWithLogFile, checkLogForErrors, startDetectorVirtualServer, loadConfig, loadBasicSettings, - ParseArguments + ParseArguments, + build_dir, + optional_file ) LOG_PREFIX_FNAME = '/tmp/slsFrameSynchronizer_test' MAIN_LOG_FNAME = LOG_PREFIX_FNAME + '_log.txt' PULL_SOCKET_PREFIX_FNAME = LOG_PREFIX_FNAME + '_pull_socket_' +SYNCHRONIZER_SUFFIX_FNAME = LOG_PREFIX_FNAME + '_synchronizer.txt' -def startFrameSynchronizerPullSocket(name, fp): - fname = PULL_SOCKET_PREFIX_FNAME + name + '.txt' +def startFrameSynchronizerPullSocket(name, fp, quiet_mode=False): cmd = ['python', '-u', 'frameSynchronizerPullSocket.py'] - startProcessInBackgroundWithLogFile(cmd, fp, fname) + fname = PULL_SOCKET_PREFIX_FNAME + name + '.txt' + startProcessInBackground(cmd, fp, fname, quiet_mode) time.sleep(1) checkLogForErrors(fp, fname) -def startFrameSynchronizer(num_mods, fp): - cmd = ['slsFrameSynchronizer', str(DEFAULT_TCP_RX_PORTNO), str(num_mods)] +def startFrameSynchronizer(num_mods, fp, quiet_mode=False): + cmd = [str(build_dir / 'slsFrameSynchronizer'), str(DEFAULT_TCP_RX_PORTNO), str(num_mods)] # in 10.0.0 #cmd = ['slsFrameSynchronizer', '-p', str(DEFAULT_TCP_RX_PORTNO), '-n', str(num_mods)] - startProcessInBackground(cmd, fp) + fname = SYNCHRONIZER_SUFFIX_FNAME + startProcessInBackground(cmd, fp, fname, quiet_mode) time.sleep(1) def acquire(fp, det): - Log(LogLevel.INFO, 'Acquiring') - Log(LogLevel.INFO, 'Acquiring', fp) + Log(LogLevel.INFO, 'Acquiring', fp, True) det.acquire() @@ -60,14 +59,12 @@ def testFramesCaught(name, det, num_frames): if fnum != num_frames: raise RuntimeException(f"{name} caught only {fnum}. Expected {num_frames}") - Log(LogLevel.INFOGREEN, f'Frames caught test passed for {name}') - Log(LogLevel.INFOGREEN, f'Frames caught test passed for {name}', fp) + Log(LogLevel.INFOGREEN, f'Frames caught test passed for {name}', fp, True) def testZmqHeadetTypeCount(name, det, num_mods, num_frames, fp): - Log(LogLevel.INFO, f"Testing Zmq Header type count for {name}") - Log(LogLevel.INFO, f"Testing Zmq Header type count for {name}", fp) + Log(LogLevel.INFO, f"Testing Zmq Header type count for {name}", fp, True) htype_counts = { "header": 0, "series_end": 0, @@ -89,7 +86,6 @@ def testZmqHeadetTypeCount(name, det, num_mods, num_frames, fp): htype_counts[htype] += 1 except json.JSONDecodeError: continue - # test if file contents matches expected counts num_ports_per_module = 1 if name == "gotthard2" else det.numinterfaces total_num_frame_parts = num_ports_per_module * num_mods * num_frames @@ -100,19 +96,17 @@ def testZmqHeadetTypeCount(name, det, num_mods, num_frames, fp): except Exception as e: raise RuntimeException(f'Failed to get zmq header count type. Error:{str(e)}') from e - Log(LogLevel.INFOGREEN, f"Zmq Header type count test passed for {name}") - Log(LogLevel.INFOGREEN, f"Zmq Header type count test passed for {name}", fp) + Log(LogLevel.INFOGREEN, f"Zmq Header type count test passed for {name}", fp, True) def startTestsForAll(args, fp): for server in args.servers: try: - Log(LogLevel.INFOBLUE, f'Synchronizer Tests for {server}') - Log(LogLevel.INFOBLUE, f'Synchronizer Tests for {server}', fp) + Log(LogLevel.INFOBLUE, f'Synchronizer Tests for {server}', fp, True) cleanup(fp) - startDetectorVirtualServer(server, args.num_mods, fp) - startFrameSynchronizerPullSocket(server, fp) - startFrameSynchronizer(args.num_mods, fp) + startDetectorVirtualServer(server, args.num_mods, fp, args.quiet) + startFrameSynchronizerPullSocket(server, fp, args.quiet) + startFrameSynchronizer(args.num_mods, f, args.quiet_modep) d = loadConfig(name=server, rx_hostname=args.rx_hostname, settingsdir=args.settingspath, log_file_fp=fp, num_mods=args.num_mods, num_frames=args.num_frames) loadBasicSettings(name=server, d=d, fp=fp) acquire(fp, d) @@ -128,6 +122,9 @@ def startTestsForAll(args, fp): if __name__ == '__main__': args = ParseArguments(description='Automated tests to test frame synchronizer', default_num_mods=2) + if args.no_log_file: + raise RuntimeException("Cannot run frame synchronizer test without files") + Log(LogLevel.INFOBLUE, '\nLog File: ' + MAIN_LOG_FNAME + '\n') with open(MAIN_LOG_FNAME, 'w') as fp: diff --git a/tests/scripts/test_roi.py b/tests/scripts/test_roi.py deleted file mode 100644 index 17d35c56d..000000000 --- a/tests/scripts/test_roi.py +++ /dev/null @@ -1,82 +0,0 @@ -# SPDX-License-Identifier: LGPL-3.0-or-other -# Copyright (C) 2021 Contributors to the SLS Detector Package -''' -This file is used to start up simulators, receivers and test roi for every detector in many configurations. -''' - -import sys, time -import traceback - -from slsdet import Detector, burstMode -from slsdet.defines import DEFAULT_TCP_RX_PORTNO, DEFAULT_UDP_DST_PORTNO -from datetime import timedelta - - -from utils_for_test import ( - Log, - LogLevel, - RuntimeException, - cleanup, - startProcessInBackground, - startReceiver, - startDetectorVirtualServer, - connectToVirtualServers, - loadBasicSettings, - loadConfig, - runProcessWithLogFile -) - -LOG_PREFIX_FNAME = '/tmp/slsDetectorPackage_virtual_roi_test' -MAIN_LOG_FNAME = LOG_PREFIX_FNAME + '_log.txt' -ROI_TEST_FNAME = LOG_PREFIX_FNAME + '_results_' - -def startTestsForAll(fp): - servers = [ - 'eiger', - 'jungfrau', - 'mythen3', - 'gotthard2', - 'moench', - ] - nmods = 2 - for server in servers: - for ninterfaces in range(1, 2): - if ninterfaces == 2 and server != 'jungfrau' and server != 'moench': - continue - try: - msg = f'Starting Roi Tests for {server}' - if server == 'jungfrau' or server == 'moench': - msg += f' with {ninterfaces} interfaces' - Log(LogLevel.INFOBLUE, msg) - Log(LogLevel.INFOBLUE, msg, fp) - cleanup(fp) - startDetectorVirtualServer(server, nmods, fp) - startReceiver(nmods, fp) - d = loadConfig(name=server, log_file_fp = fp, num_mods=nmods, num_frames=5, num_interfaces=ninterfaces) - loadBasicSettings(name=server, d=d, fp=fp) - - fname = ROI_TEST_FNAME + server + '.txt' - cmd = ['tests', 'rx_roi', '--abort', '-s'] - runProcessWithLogFile('Roi Tests for ' + server, cmd, fp, fname) - Log(LogLevel.INFO, '\n') - except Exception as e: - raise RuntimeException(f'Roi Tests failed') from e - - Log(LogLevel.INFOGREEN, 'Passed all Roi tests for all detectors \n' + str(servers)) - - -if __name__ == '__main__': - Log(LogLevel.INFOBLUE, '\nLog File: ' + MAIN_LOG_FNAME + '\n') - - with open(MAIN_LOG_FNAME, 'w') as fp: - try: - startTestsForAll(fp) - #TODO: check master file as well for both json and hdf5 as well - cleanup(fp) - except Exception as e: - with open(MAIN_LOG_FNAME, 'a') as fp_error: - traceback.print_exc(file=fp_error) - cleanup(fp) - Log(LogLevel.ERROR, f'Tests Failed.') - - diff --git a/tests/scripts/test_simulators.py b/tests/scripts/test_simulators.py index 7aab1d958..a7f211d12 100644 --- a/tests/scripts/test_simulators.py +++ b/tests/scripts/test_simulators.py @@ -2,91 +2,98 @@ # Copyright (C) 2021 Contributors to the SLS Detector Package ''' This file is used to start up simulators, receivers and run all the tests on them and finally kill the simulators and receivers. + +It can be used to run all catch tests with tag [.detectorintegration]. + +Pass --tests to run specific tests only or --tests to run all tests with that specific tag. + +Pass --servers ... to run tests only for specific detector servers. ''' import argparse import sys, subprocess, time, traceback +from contextlib import contextmanager from slsdet import Detector from slsdet.defines import DEFAULT_TCP_RX_PORTNO + from utils_for_test import ( Log, LogLevel, RuntimeException, - checkIfProcessRunning, - killProcess, cleanup, - cleanSharedmemory, - startProcessInBackground, - runProcessWithLogFile, + runProcess, + startReceiver, + runProcess, startDetectorVirtualServer, loadConfig, loadBasicSettings, - ParseArguments + ParseArguments, + build_dir, + optional_file ) - LOG_PREFIX_FNAME = '/tmp/slsDetectorPackage_virtual_test' MAIN_LOG_FNAME = LOG_PREFIX_FNAME + '_log.txt' GENERAL_TESTS_LOG_FNAME = LOG_PREFIX_FNAME + '_results_general.txt' -CMD_TEST_LOG_PREFIX_FNAME = LOG_PREFIX_FNAME + '_results_cmd_' - - -def startReceiver(num_mods, fp): - if num_mods == 1: - cmd = ['slsReceiver'] - else: - cmd = ['slsMultiReceiver', str(DEFAULT_TCP_RX_PORTNO), str(num_mods)] - # in 10.0.0 - #cmd = ['slsMultiReceiver', '-p', str(DEFAULT_TCP_RX_PORTNO), '-n', str(num_mods)] - startProcessInBackground(cmd, fp) - time.sleep(1) def startGeneralTests(fp): fname = GENERAL_TESTS_LOG_FNAME - cmd = ['tests', '--abort', '-s'] + cmd = [str(build_dir / 'tests'), '--abort', '-s'] try: cleanup(fp) - runProcessWithLogFile('General Tests', cmd, fp, fname) + runProcess('General Tests', cmd, fp, fname) except Exception as e: raise RuntimeException(f'General tests failed.') from e +def startTestsForAll(args, fp): + + fname_template = LOG_PREFIX_FNAME + "_{}_{}.txt" + + + test_filter = args.tests + cmd = [str(build_dir / 'tests'), '--abort', test_filter, '-s'] + + num_mods = args.num_mods -def startCmdTestsForAll(args, fp): for server in args.servers: - try: - num_mods = 2 if server == 'eiger' else 1 - fname = CMD_TEST_LOG_PREFIX_FNAME + server + '.txt' - cmd = ['tests', '--abort', args.markers, '-s'] + for curMods in range(1, num_mods + 1): + if curMods == 2 and server in ['ctb', 'xilinx_ctb']: + continue + for ninterfaces in [1,2]: # always test both + if ninterfaces == 2 and server != 'jungfrau' and server != 'moench': + continue - Log(LogLevel.INFOBLUE, f'Starting Cmd Tests for {server}') - cleanup(fp) - startDetectorVirtualServer(name=server, num_mods=num_mods, fp=fp) - startReceiver(num_mods, fp) - d = loadConfig(name=server, rx_hostname=args.rx_hostname, settingsdir=args.settingspath, log_file_fp=fp, num_mods=num_mods) - loadBasicSettings(name=server, d=d, fp=fp) - runProcessWithLogFile('Cmd Tests (' + args.markers + ') for ' + server, cmd, fp, fname) - except Exception as e: - raise RuntimeException(f'Cmd Tests failed for {server}.') from e + if server == "eiger": + curMods *= 2 # top and bottom half module + try: + fname = fname_template.format(args.tests, server) if not args.no_log_file else None + + Log(LogLevel.INFOBLUE, f'Starting {args.tests} Tests for {server}, {ninterfaces} interfaces, {curMods} modules', fp, True) + cleanup(fp) + startDetectorVirtualServer(name=server, num_mods=curMods, fp=fp, no_log_file=args.no_log_file, quiet_mode=args.quiet) + startReceiver(curMods, fp, args.no_log_file, args.quiet) + d = loadConfig(name=server, rx_hostname=args.rx_hostname, settingsdir=args.settingspath, log_file_fp=fp, num_mods=curMods, num_interfaces=ninterfaces) + loadBasicSettings(name=server, d=d, fp=fp) + runProcess('Tests (' + args.tests + ') for ' + server, cmd, fp, fname, args.quiet) + except Exception as e: + raise RuntimeException(f'Tests (' + args.tests + ') failed for ' + server + '.') from e Log(LogLevel.INFOGREEN, 'Passed all tests for all detectors \n' + str(args.servers)) if __name__ == '__main__': - args = ParseArguments(description='Automated tests with the virtual detector servers', default_num_mods=1, markers=True, general_tests_option=True) - if args.num_mods > 1: - raise RuntimeException(f'Cannot support multiple modules at the moment (except Eiger).') + args = ParseArguments(description='Automated tests with the virtual detector servers', default_num_mods=2, specific_tests=True, general_tests_option=True) - Log(LogLevel.INFOBLUE, '\nLog File: ' + MAIN_LOG_FNAME + '\n') - - with open(MAIN_LOG_FNAME, 'w') as fp: + with optional_file(MAIN_LOG_FNAME if not args.no_log_file else None, 'w', args.quiet) as fp: try: if args.general_tests: startGeneralTests(fp) - startCmdTestsForAll(args, fp) + startTestsForAll(args, fp) cleanup(fp) except Exception as e: - with open(MAIN_LOG_FNAME, 'a') as fp_error: - traceback.print_exc(file=fp_error) + traceback.print_exc(file=fp) cleanup(fp) Log(LogLevel.ERROR, f'Tests Failed.') + raise e + diff --git a/tests/scripts/utils_for_test.py b/tests/scripts/utils_for_test.py index bff86f886..66c43fb38 100644 --- a/tests/scripts/utils_for_test.py +++ b/tests/scripts/utils_for_test.py @@ -3,19 +3,24 @@ ''' This file is used for common utils used for integration tests between simulators and receivers. ''' - +import os from pathlib import Path import sys, subprocess, time, argparse from enum import Enum from colorama import Fore, Style, init from datetime import timedelta +from contextlib import contextmanager from slsdet import Detector, Ctb, detectorSettings, burstMode from slsdet.defines import DEFAULT_TCP_RX_PORTNO, DEFAULT_UDP_DST_PORTNO SERVER_START_PORTNO=1900 +LOG_PREFIX_FNAME = "/tmp/slsDetectorPackage_" + init(autoreset=True) +build_dir = Path(__file__).resolve().parents[2] / "build" / "bin" + class LogLevel(Enum): INFO = 0 INFORED = 1 @@ -44,10 +49,13 @@ LOG_COLORS = { } -def Log(level: LogLevel, message: str, stream=sys.stdout): +def Log(level: LogLevel, message: str, stream=sys.stdout, both=False): color = LOG_COLORS.get(level, Fore.WHITE) label = LOG_LABELS.get(level, "") print(f"{color}{label}{message}{Style.RESET_ALL}", file=stream, flush=True) + if both and stream != sys.stdout: + print(f"{color}{label}{message}{Style.RESET_ALL}", file=sys.stdout, flush=True) + class RuntimeException (Exception): @@ -56,9 +64,27 @@ class RuntimeException (Exception): super().__init__(message) +@contextmanager +def optional_file(file_path=None, mode='w', quiet_mode=False): + if file_path: + f = open(file_path, mode) + try: + yield f + finally: + f.close() + else: + if quiet_mode: + f = open(os.devnull, mode) + try: + yield f + finally: + f.close() + else: + yield sys.stdout + + def checkIfProcessRunning(processName): - cmd = f"pgrep -f {processName}" - res = subprocess.getoutput(cmd) + res = subprocess.getoutput(f"pgrep -f {processName}") return res.strip().splitlines() @@ -80,18 +106,13 @@ def killProcess(name, fp): def cleanSharedmemory(fp): Log(LogLevel.INFO, 'Cleaning up shared memory', fp) try: - p = subprocess.run(['sls_detector_get', 'free'], stdout=fp, stderr=fp, check = False) - except FileNotFoundError: - # Binary not available (e.g. on CI) → ignore - Log(LogLevel.INFO, 'sls_detector_get not found, skipping shared memory cleanup', fp) + p = subprocess.run([build_dir / 'sls_detector_get', 'free'], stdout=fp, stderr=fp) except Exception as e: - # Any other cleanup failure should NEVER fail tests - Log(LogLevel.WARN, f'Ignoring shared memory cleanup error: {e}', fp) + raise RuntimeException(f'Could not free shared memory: {str(e)}') def cleanup(fp): - Log(LogLevel.INFO, 'Cleaning up') - Log(LogLevel.INFO, 'Cleaning up', fp) + Log(LogLevel.INFO, 'Cleaning up', fp, True) killProcess('DetectorServer_virtual', fp) killProcess('slsReceiver', fp) killProcess('slsMultiReceiver', fp) @@ -100,20 +121,15 @@ def cleanup(fp): cleanSharedmemory(fp) -def startProcessInBackground(cmd, fp): - Log(LogLevel.INFO, 'Starting up ' + ' '.join(cmd)) - Log(LogLevel.INFO, 'Starting up ' + ' '.join(cmd), fp) - try: - p = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, restore_signals=False) - except Exception as e: - raise RuntimeException(f'Failed to start {cmd}:{str(e)}') from e +def startProcessInBackground(cmd, fp, log_file_name: str, quiet_mode=False): + info_text = 'Starting up ' + ' '.join(cmd) + if log_file_name: + info_text += '. Log: ' + log_file_name + Log(LogLevel.INFO, f'{info_text}', fp, True) -def startProcessInBackgroundWithLogFile(cmd, fp, log_file_name: str): - Log(LogLevel.INFOBLUE, 'Starting up ' + ' '.join(cmd) + '. Log: ' + log_file_name) - Log(LogLevel.INFOBLUE, 'Starting up ' + ' '.join(cmd) + '. Log: ' + log_file_name, fp) try: - with open(log_file_name, 'w') as log_fp: + with optional_file(log_file_name, 'w', quiet_mode) as log_fp: subprocess.Popen(cmd, stdout=log_fp, stderr=log_fp, text=True) except Exception as e: raise RuntimeException(f'Failed to start {cmd}:{str(e)}') from e @@ -124,8 +140,7 @@ def checkLogForErrors(fp, log_file_path: str): with open(log_file_path, 'r') as log_file: for line in log_file: if 'Error' in line: - Log(LogLevel.ERROR, f"Error found in log: {line.strip()}") - Log(LogLevel.ERROR, f"Error found in log: {line.strip()}", fp) + Log(LogLevel.ERROR, f"Error found in log: {line.strip()}", fp, True) raise RuntimeException("Error found in log file") except FileNotFoundError: print(f"Log file not found: {log_file_path}") @@ -135,33 +150,92 @@ def checkLogForErrors(fp, log_file_path: str): raise -def runProcessWithLogFile(name, cmd, fp, log_file_name): - Log(LogLevel.INFOBLUE, 'Running ' + name + '. Log: ' + log_file_name) - Log(LogLevel.INFOBLUE, 'Running ' + name + '. Log: ' + log_file_name, fp) - Log(LogLevel.INFOBLUE, 'Cmd: ' + ' '.join(cmd), fp) +def checkLogForErrorsOrSummary(fp, lines, source_name=""): + failed = False # if it found "failed" or "FAILED" in file + failed_msg = "" + printing_error = False # print every line in file after failure + printing_summary = False # print summary if no failure + + + for line in lines: + line_stripped = line.rstrip() + + # Detect failure (case-insensitive) + if not failed and (": FAILED:" in line or " failed\nassertions" in line): + failed = True + failed_msg = line_stripped + printing_error = True + Log(LogLevel.ERROR, line_stripped, fp) + if source_name: + Log(LogLevel.ERROR, f"Error log from file: {source_name}") + Log(LogLevel.ERROR, "="*79) + + # After failure, log everything as ERROR + if printing_error: + print(f"{line_stripped}") + continue + + # Summary delimiter + if line_stripped.startswith("====="): + printing_summary = True + + # No failure - print summary lines + if printing_summary: + print(f"{line_stripped}") + + + if failed: + Log(LogLevel.ERROR, "="*79) + raise RuntimeException(f'Test failed: {failed_msg}') + else: + print("="*79) + + + +def runProcess(name, cmd, fp, log_file_name = None, quiet_mode=False): + + info_text = 'Running ' + name + '.' + if log_file_name: + info_text += ' Log: ' + log_file_name + Log(LogLevel.INFOBLUE, info_text, fp, True) + Log(LogLevel.INFOBLUE, 'Cmd: ' + ' '.join(cmd), fp, True) + + error_log = None + try: - with open(log_file_name, 'w') as log_fp: - subprocess.run(cmd, stdout=log_fp, stderr=log_fp, check=True, text=True) + if log_file_name: + with optional_file(log_file_name, 'w', quiet_mode) as log_fp: + subprocess.run(cmd, stdout=log_fp, stderr=log_fp, check=True, text=True) + else: + capture = subprocess.run(cmd, check=True, text=True, capture_output=True) + captured_log = capture.stdout.splitlines() + except subprocess.CalledProcessError as e: - pass + print("error: ", str(e)) + captured_log = e.stdout.splitlines() + pass except Exception as e: + print("something else failed") Log(LogLevel.ERROR, f'Failed to run {name}:{str(e)}', fp) raise RuntimeException(f'Failed to run {name}:{str(e)}') - with open (log_file_name, 'r') as f: - for line in f: - if "FAILED" in line: - raise RuntimeException(f'{line}') + if log_file_name: + with optional_file(log_file_name, 'r') as log_fp: + checkLogForErrorsOrSummary(fp, log_fp, log_file_name) + else: + checkLogForErrorsOrSummary(fp, captured_log) - Log(LogLevel.INFOGREEN, name + ' successful!\n') - Log(LogLevel.INFOGREEN, name + ' successful!\n', fp) + Log(LogLevel.INFOGREEN, name + ' successful!\n', fp, True) -def startDetectorVirtualServer(name :str, num_mods, fp): +def startDetectorVirtualServer(name :str, num_mods, fp, no_log_file = False, quiet_mode=False): for i in range(num_mods): port_no = SERVER_START_PORTNO + (i * 2) - cmd = [name + 'DetectorServer_virtual', '-p', str(port_no)] - startProcessInBackgroundWithLogFile(cmd, fp, "/tmp/virtual_det_" + name + "_" + str(i) + ".txt") + cmd = [str(build_dir / (name + 'DetectorServer_virtual')), '-p', str(port_no)] + fname = LOG_PREFIX_FNAME + "virtual_det_" + name + "_" + str(SERVER_START_PORTNO) + ".txt" + if no_log_file: + fname = None + startProcessInBackground(cmd, fp, fname, quiet_mode) match name: case 'jungfrau': time.sleep(7) @@ -196,20 +270,23 @@ def connectToVirtualServers(name, num_mods, ctb_object=False): return d -def startReceiver(num_mods, fp): +def startReceiver(num_mods, fp, no_log_file = False, quiet_mode=False): if num_mods == 1: - cmd = ['slsReceiver'] + cmd = [str(build_dir / 'slsReceiver')] + fname = LOG_PREFIX_FNAME + "slsReceiver.txt" else: - cmd = ['slsMultiReceiver', str(DEFAULT_TCP_RX_PORTNO), str(num_mods)] + cmd = [str(build_dir / 'slsMultiReceiver'), str(DEFAULT_TCP_RX_PORTNO), str(num_mods)] + fname = LOG_PREFIX_FNAME + "slsMultiReceiver.txt" # in 10.0.0 #cmd = ['slsMultiReceiver', '-p', str(DEFAULT_TCP_RX_PORTNO), '-n', str(num_mods)] - startProcessInBackground(cmd, fp) + + if no_log_file: + fname = None + startProcessInBackground(cmd, fp, fname, quiet_mode) time.sleep(1) - def loadConfig(name, rx_hostname = 'localhost', settingsdir = None, log_file_fp = None, num_mods = 1, num_frames = 1, num_interfaces = 1): - Log(LogLevel.INFO, 'Loading config') - Log(LogLevel.INFO, 'Loading config', log_file_fp) + Log(LogLevel.INFO, 'Loading config', log_file_fp, True) try: d = connectToVirtualServers(name, num_mods) @@ -217,17 +294,15 @@ def loadConfig(name, rx_hostname = 'localhost', settingsdir = None, log_file_fp d.numinterfaces = num_interfaces d.udp_dstport = DEFAULT_UDP_DST_PORTNO - if name == 'eiger' or name == 'jungfrau' or name == 'moench': + if name == 'eiger' or num_interfaces == 2: d.udp_dstport2 = DEFAULT_UDP_DST_PORTNO + 1 d.rx_hostname = rx_hostname - d.udp_dstip = 'auto' - if name != "eiger": d.udp_srcip = 'auto' - if name == "jungfrau" or name == "moench": + if num_interfaces == 2: d.udp_dstip2 = 'auto' if name == "jungfrau" or name == "moench" or name == "xilinx_ctb": @@ -241,6 +316,7 @@ def loadConfig(name, rx_hostname = 'localhost', settingsdir = None, log_file_fp d.trimen = [4500, 5400, 6400] if name == 'eiger' else [4000, 6000, 8000, 12000] d.setThresholdEnergy(4500, detectorSettings.STANDARD) + d.frames = num_frames except Exception as e: @@ -248,10 +324,11 @@ def loadConfig(name, rx_hostname = 'localhost', settingsdir = None, log_file_fp return d + + # for easy acquire def loadBasicSettings(name, d, fp): - Log(LogLevel.INFO, 'Loading basic settings for ' + name) - Log(LogLevel.INFO, 'Loading basic settings for ' + name, fp) + Log(LogLevel.INFO, 'Loading basic settings for ' + name, fp, True) try: # basic settings for easy acquire if name == "jungfrau": @@ -278,7 +355,7 @@ def loadBasicSettings(name, d, fp): except Exception as e: raise RuntimeException(f'Could not load config for {name}. Error: {str(e)}') from e -def ParseArguments(description, default_num_mods=1, markers=False, general_tests_option=False): +def ParseArguments(description, default_num_mods=2, specific_tests=False, general_tests_option=False): parser = argparse.ArgumentParser(description) default_settings_path = Path(__file__).resolve().parents[2] / "settingsdir" @@ -293,16 +370,21 @@ def ParseArguments(description, default_num_mods=1, markers=False, general_tests help='Number of frames to test with') parser.add_argument('-s', '--servers', nargs='*', help='Detector servers to run') - if markers: - parser.add_argument('-m', '--markers', nargs='?', default ='[.cmdcall]', - help = 'Markers to use for cmd tests, default: [.cmdcall]') - + parser.add_argument('-nlf', '--no-log-file', action='store_true', + help='Dont write output to log file') + parser.add_argument('-q', '--quiet', action='store_true', + help='Dont write to stdout when possible.') + if specific_tests: + parser.add_argument('-t', '--tests', nargs='?', default ='[.detectorintegration]', + help = 'Test markers or specific test name to use for tests, default: [.detectorintegration]') + if general_tests_option: - parser.add_argument('-g', '--general_tests', action='store_true', + parser.add_argument('-g', '--general-tests', action='store_true', help = 'Enable general tests (no value needed)') args = parser.parse_args() + # Set default server list if not provided if args.servers is None: args.servers = [ @@ -323,8 +405,19 @@ def ParseArguments(description, default_num_mods=1, markers=False, general_tests f"num_mods: '{args.num_mods}'\n" f"num_frames: '{args.num_frames}'" ) - if markers: - msg += f"\nmarkers: '{args.markers}'" + + if args.no_log_file: + msg += f"\nLog File: Disabled" + else: + msg += f"\nLog File: Enabled" + + if args.quiet: + msg += f"\nQuiet mode: Enabled" + else: + msg += f"\nQuiet mode: Disabled" + + if specific_tests: + msg += f"\ntests: '{args.tests}'" if general_tests_option: msg += f"\ngeneral_tests: '{args.general_tests}'"