mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-17 15:27:13 +02:00
Compare commits
71 Commits
dacnames
...
2022.05.22
Author | SHA1 | Date | |
---|---|---|---|
88649a00b6 | |||
b122c2fbdf | |||
7d574375b4 | |||
466d431081 | |||
cd4520b051 | |||
0129c2c686 | |||
f55bdd6eae | |||
36a1159f38 | |||
98e2ddbb74 | |||
fa12ab2858 | |||
afeee5501c | |||
b7153fe3e0 | |||
2db2694660 | |||
e1642cf37c | |||
086d22f1a3 | |||
52882cba20 | |||
27c7fd9a97 | |||
5d16ba7e16 | |||
d8c6f9141d | |||
e9dc3d8c38 | |||
62418c1316 | |||
835aa575b0 | |||
b42d65c5e2 | |||
150d27cf95 | |||
95ed9551c0 | |||
0f2ec47b5f | |||
fe895cd782 | |||
11bf6a5c58 | |||
8bce87c082 | |||
61f38bf5a9 | |||
cbc7066620 | |||
509ed9101f | |||
191cfa0abe | |||
f712847061 | |||
b875a95bd5 | |||
45f57ebeb7 | |||
0309eba3c6 | |||
f0448b3cec | |||
a18af0b726 | |||
6aa5cb8d3e | |||
479906a9eb | |||
28a503ed5a | |||
b3c5a431d0 | |||
43cde3609a | |||
9d2d8fe1d7 | |||
1826dd46cb | |||
cf6423dbbe | |||
8b1851e652 | |||
5913864cbb | |||
c2ef6d700e | |||
76296507ff | |||
03d2158472 | |||
bb7b676ca2 | |||
e1988bf088 | |||
8ef1a209c9 | |||
28572af3ab | |||
c57e528447 | |||
74e325edb4 | |||
e68499bb09 | |||
8ce6868e46 | |||
f5cca7a98f | |||
b9aa0f46e4 | |||
6cd780ae99 | |||
f2be834d55 | |||
e55e18d5e9 | |||
66900da476 | |||
1ff35edb99 | |||
9a969c1549 | |||
cbed2e88c6 | |||
0f02ffdc9a | |||
90d1d0f8b8 |
@ -19,6 +19,7 @@ Checks: '*,
|
|||||||
-google-readability-braces-around-statements,
|
-google-readability-braces-around-statements,
|
||||||
-modernize-use-trailing-return-type,
|
-modernize-use-trailing-return-type,
|
||||||
-readability-isolate-declaration,
|
-readability-isolate-declaration,
|
||||||
|
-readability-implicit-bool-conversion,
|
||||||
-llvmlibc-*'
|
-llvmlibc-*'
|
||||||
|
|
||||||
HeaderFilterRegex: \.h
|
HeaderFilterRegex: \.h
|
||||||
|
143
CMakeLists.txt
143
CMakeLists.txt
@ -8,11 +8,8 @@ set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
|||||||
|
|
||||||
cmake_policy(SET CMP0074 NEW)
|
cmake_policy(SET CMP0074 NEW)
|
||||||
include(cmake/project_version.cmake)
|
include(cmake/project_version.cmake)
|
||||||
|
|
||||||
#functions to add compiler flags
|
|
||||||
include(cmake/SlsAddFlag.cmake)
|
include(cmake/SlsAddFlag.cmake)
|
||||||
|
include(cmake/SlsFindZeroMQ.cmake)
|
||||||
# Include additional modules that are used unconditionally
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
# If conda build, always set lib dir to 'lib'
|
# If conda build, always set lib dir to 'lib'
|
||||||
@ -26,7 +23,7 @@ string(TOLOWER "${PROJECT_NAME}" PROJECT_NAME_LOWER)
|
|||||||
|
|
||||||
# Set targets export name (used by slsDetectorPackage and dependencies)
|
# Set targets export name (used by slsDetectorPackage and dependencies)
|
||||||
set(TARGETS_EXPORT_NAME "${PROJECT_NAME_LOWER}-targets")
|
set(TARGETS_EXPORT_NAME "${PROJECT_NAME_LOWER}-targets")
|
||||||
#set(namespace "${PROJECT_NAME}::")
|
set(namespace "sls::")
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
@ -37,6 +34,8 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
|||||||
set(SLS_MASTER_PROJECT ON)
|
set(SLS_MASTER_PROJECT ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
option(SLS_USE_HDF5 "HDF5 File format" OFF)
|
option(SLS_USE_HDF5 "HDF5 File format" OFF)
|
||||||
option(SLS_BUILD_SHARED_LIBRARIES "Build shared libaries" ON)
|
option(SLS_BUILD_SHARED_LIBRARIES "Build shared libaries" ON)
|
||||||
option(SLS_USE_TEXTCLIENT "Text Client" ON)
|
option(SLS_USE_TEXTCLIENT "Text Client" ON)
|
||||||
@ -69,6 +68,20 @@ if(SLS_BUILD_ONLY_MOENCH)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
option(SLS_EXT_BUILD "external build of part of the project" OFF)
|
||||||
|
if(SLS_EXT_BUILD)
|
||||||
|
message(STATUS "External build using already installed libraries")
|
||||||
|
set(SLS_BUILD_SHARED_LIBRARIES OFF CACHE BOOL "Should already exist" FORCE)
|
||||||
|
set(SLS_USE_TEXTCLIENT OFF CACHE BOOL "Should already exist" FORCE)
|
||||||
|
set(SLS_USE_DETECTOR OFF CACHE BOOL "Should already exist" FORCE)
|
||||||
|
set(SLS_USE_RECEIVER OFF CACHE BOOL "Should already exist" FORCE)
|
||||||
|
set(SLS_USE_RECEIVER_BINARIES OFF CACHE BOOL "Should already exist" FORCE)
|
||||||
|
set(SLS_MASTER_PROJECT OFF CACHE BOOL "No master proj in case of extbuild" FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#Maybe have an option guarding this?
|
||||||
|
set(SLS_INTERNAL_RAPIDJSON_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs/rapidjson)
|
||||||
|
|
||||||
set(ClangFormat_EXCLUDE_PATTERNS "build/"
|
set(ClangFormat_EXCLUDE_PATTERNS "build/"
|
||||||
"libs/"
|
"libs/"
|
||||||
"slsDetectorCalibration/"
|
"slsDetectorCalibration/"
|
||||||
@ -79,9 +92,6 @@ set(ClangFormat_EXCLUDE_PATTERNS "build/"
|
|||||||
${CMAKE_BINARY_DIR})
|
${CMAKE_BINARY_DIR})
|
||||||
find_package(ClangFormat)
|
find_package(ClangFormat)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||||
@ -100,11 +110,23 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
#Add two fake libraries to manage options
|
if(SLS_EXT_BUILD)
|
||||||
add_library(slsProjectOptions INTERFACE)
|
# Find ourself in case of external build
|
||||||
add_library(slsProjectWarnings INTERFACE)
|
find_package(slsDetectorPackage ${PROJECT_VERSION} REQUIRED)
|
||||||
target_compile_features(slsProjectOptions INTERFACE cxx_std_11)
|
endif()
|
||||||
target_compile_options(slsProjectWarnings INTERFACE
|
|
||||||
|
|
||||||
|
|
||||||
|
# slsProjectOptions and slsProjectWarnings are used
|
||||||
|
# to control options for the libraries
|
||||||
|
if(NOT TARGET slsProjectOptions)
|
||||||
|
add_library(slsProjectOptions INTERFACE)
|
||||||
|
target_compile_features(slsProjectOptions INTERFACE cxx_std_11)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT TARGET slsProjectWarnings)
|
||||||
|
add_library(slsProjectWarnings INTERFACE)
|
||||||
|
target_compile_options(slsProjectWarnings INTERFACE
|
||||||
-Wall
|
-Wall
|
||||||
-Wextra
|
-Wextra
|
||||||
-Wno-unused-parameter
|
-Wno-unused-parameter
|
||||||
@ -119,10 +141,25 @@ target_compile_options(slsProjectWarnings INTERFACE
|
|||||||
-Wdouble-promotion
|
-Wdouble-promotion
|
||||||
-Werror=return-type
|
-Werror=return-type
|
||||||
)
|
)
|
||||||
|
# Add or disable warnings depending on if the compiler supports them
|
||||||
|
# The function checks internally and sets HAS_warning-name
|
||||||
|
sls_enable_cxx_warning("-Wnull-dereference")
|
||||||
|
sls_enable_cxx_warning("-Wduplicated-cond")
|
||||||
|
sls_disable_cxx_warning("-Wclass-memaccess")
|
||||||
|
|
||||||
#Settings for C code
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
add_library(slsProjectCSettings INTERFACE)
|
target_compile_options(slsProjectWarnings INTERFACE
|
||||||
target_compile_options(slsProjectCSettings INTERFACE
|
-Wno-missing-field-initializers)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
if (NOT TARGET slsProjectCSettings)
|
||||||
|
#Settings for C code
|
||||||
|
add_library(slsProjectCSettings INTERFACE)
|
||||||
|
target_compile_options(slsProjectCSettings INTERFACE
|
||||||
-std=gnu99 #fixed
|
-std=gnu99 #fixed
|
||||||
-Wall
|
-Wall
|
||||||
-Wextra
|
-Wextra
|
||||||
@ -133,30 +170,9 @@ target_compile_options(slsProjectCSettings INTERFACE
|
|||||||
-Wdouble-promotion
|
-Wdouble-promotion
|
||||||
-Werror=return-type
|
-Werror=return-type
|
||||||
)
|
)
|
||||||
|
sls_disable_c_warning("-Wstringop-truncation")
|
||||||
|
|
||||||
#Testing for minimum version for compilers
|
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
|
||||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.2)
|
|
||||||
message(FATAL_ERROR "Clang version must be at least 3.2!")
|
|
||||||
endif()
|
|
||||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
||||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
|
|
||||||
message(FATAL_ERROR "GCC version must be at least 4.8!")
|
|
||||||
endif()
|
|
||||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5)
|
|
||||||
target_compile_options(slsProjectWarnings INTERFACE
|
|
||||||
-Wno-missing-field-initializers)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Add or disable warnings depending on if the compiler supports them
|
|
||||||
# The function checks internally and sets HAS_warning-name
|
|
||||||
sls_enable_cxx_warning("-Wnull-dereference")
|
|
||||||
sls_enable_cxx_warning("-Wduplicated-cond")
|
|
||||||
sls_disable_cxx_warning("-Wclass-memaccess")
|
|
||||||
sls_disable_c_warning("-Wstringop-truncation")
|
|
||||||
|
|
||||||
|
|
||||||
if(SLS_USE_SANITIZER)
|
if(SLS_USE_SANITIZER)
|
||||||
target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer)
|
target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer)
|
||||||
@ -170,58 +186,22 @@ if(SLS_TUNE_LOCAL)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
#rapidjson
|
if(SLS_MASTER_PROJECT)
|
||||||
add_library(rapidjson INTERFACE)
|
install(TARGETS slsProjectOptions slsProjectWarnings
|
||||||
target_include_directories(rapidjson INTERFACE
|
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/libs/rapidjson>
|
|
||||||
)
|
|
||||||
|
|
||||||
# Install fake the libraries
|
|
||||||
install(TARGETS slsProjectOptions slsProjectWarnings rapidjson
|
|
||||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
set(CMAKE_INSTALL_RPATH $ORIGIN)
|
set(CMAKE_INSTALL_RPATH $ORIGIN)
|
||||||
# set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
|
||||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||||
|
|
||||||
|
|
||||||
set(ZeroMQ_HINT "" CACHE STRING "Hint where ZeroMQ could be found")
|
custom_find_zmq()
|
||||||
#Adapted from: https://github.com/zeromq/cppzmq/
|
|
||||||
if (NOT TARGET libzmq)
|
|
||||||
if(ZeroMQ_HINT)
|
|
||||||
message(STATUS "Looking for ZeroMQ in: ${ZeroMQ_HINT}")
|
|
||||||
find_package(ZeroMQ 4
|
|
||||||
NO_DEFAULT_PATH
|
|
||||||
HINTS ${ZeroMQ_DIR}
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
find_package(ZeroMQ 4 QUIET)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# libzmq autotools install: fallback to pkg-config
|
|
||||||
if(NOT ZeroMQ_FOUND)
|
|
||||||
message(STATUS "CMake libzmq package not found, trying again with pkg-config (normal install of zeromq)")
|
|
||||||
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/libzmq-pkg-config)
|
|
||||||
find_package(ZeroMQ 4 REQUIRED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# TODO "REQUIRED" above should already cause a fatal failure if not found, but this doesn't seem to work
|
|
||||||
if(NOT ZeroMQ_FOUND)
|
|
||||||
message(FATAL_ERROR "ZeroMQ was not found, neither as a CMake package nor via pkg-config")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (ZeroMQ_FOUND AND NOT TARGET libzmq)
|
|
||||||
message(FATAL_ERROR "ZeroMQ version not supported!")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
get_target_property(VAR libzmq INTERFACE_INCLUDE_DIRECTORIES)
|
|
||||||
message(STATUS "zmq: ${VAR}")
|
|
||||||
|
|
||||||
if (SLS_USE_TESTS)
|
if (SLS_USE_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
@ -229,8 +209,9 @@ if (SLS_USE_TESTS)
|
|||||||
endif(SLS_USE_TESTS)
|
endif(SLS_USE_TESTS)
|
||||||
|
|
||||||
|
|
||||||
# Common functionallity to detector and receiver
|
if(NOT SLS_EXT_BUILD)
|
||||||
add_subdirectory(slsSupportLib)
|
add_subdirectory(slsSupportLib)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (SLS_USE_DETECTOR OR SLS_USE_TEXTCLIENT)
|
if (SLS_USE_DETECTOR OR SLS_USE_TEXTCLIENT)
|
||||||
add_subdirectory(slsDetectorSoftware)
|
add_subdirectory(slsDetectorSoftware)
|
||||||
@ -254,7 +235,7 @@ endif (SLS_USE_INTEGRATION_TESTS)
|
|||||||
|
|
||||||
if (SLS_USE_PYTHON)
|
if (SLS_USE_PYTHON)
|
||||||
find_package (Python 3.6 COMPONENTS Interpreter Development)
|
find_package (Python 3.6 COMPONENTS Interpreter Development)
|
||||||
add_subdirectory(libs/pybind11)
|
add_subdirectory(libs/pybind11 ${CMAKE_BINARY_DIR}/bin/)
|
||||||
add_subdirectory(python)
|
add_subdirectory(python)
|
||||||
endif(SLS_USE_PYTHON)
|
endif(SLS_USE_PYTHON)
|
||||||
|
|
||||||
|
12
RELEASE.txt
12
RELEASE.txt
@ -57,6 +57,18 @@ This document describes the differences between v7.0.0 and v6.x.x
|
|||||||
- ctb: can set names for all the dacs
|
- ctb: can set names for all the dacs
|
||||||
- fpga/kernel programming, checks if drive is a special file and not a normal file
|
- fpga/kernel programming, checks if drive is a special file and not a normal file
|
||||||
- gotthard 25 um image reconstructed in gui and virtual hdf5 (firmware updated for slave to reverse channels)
|
- gotthard 25 um image reconstructed in gui and virtual hdf5 (firmware updated for slave to reverse channels)
|
||||||
|
- master binary file in json format now
|
||||||
|
- fixed bug introduced in 6.0.0: hdf5 files created 1 file per frame after the initial file which had maxframesperfile
|
||||||
|
- m3 polarity, interpolation (enables all counters when enabled), pump probe, analog pulsing, digital pulsing
|
||||||
|
- updatedetectorserver - removes old server current binary pointing to for blackfin
|
||||||
|
- removing copydetectorserver using tftp
|
||||||
|
- registerCallBackRawDataReady and registerCallBackRawDataModifyReady now gives a sls_receiver_header* instead of a char*, and uint32_t to size_t
|
||||||
|
- registerCallBackStartAcquisition gave incorrect imagesize (+120 bytes). corrected.
|
||||||
|
- registerCallBackStartAcquisition parameter is a const string reference
|
||||||
|
- m3 (runnig config second time with tengiga 0, dr !=32, counters !=0x7) calculated incorrect image size expected
|
||||||
|
- fixed row column indexing (mainly for multi module Jungfrau 2 interfaces )
|
||||||
|
- eiger gui row indices not flipped anymore (fix in config)
|
||||||
|
- m3 (settings dac check disabled temporarily?)
|
||||||
|
|
||||||
2. Resolved Issues
|
2. Resolved Issues
|
||||||
==================
|
==================
|
||||||
|
38
cmake/SlsFindZeroMQ.cmake
Normal file
38
cmake/SlsFindZeroMQ.cmake
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
function(custom_find_zmq)
|
||||||
|
set(ZeroMQ_HINT "" CACHE STRING "Hint where ZeroMQ could be found")
|
||||||
|
#Adapted from: https://github.com/zeromq/cppzmq/
|
||||||
|
if (NOT TARGET libzmq)
|
||||||
|
if(ZeroMQ_HINT)
|
||||||
|
message(STATUS "Looking for ZeroMQ in: ${ZeroMQ_HINT}")
|
||||||
|
find_package(ZeroMQ 4
|
||||||
|
NO_DEFAULT_PATH
|
||||||
|
HINTS ${ZeroMQ_HINT}
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
find_package(ZeroMQ 4 QUIET)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# libzmq autotools install: fallback to pkg-config
|
||||||
|
if(ZeroMQ_FOUND)
|
||||||
|
message(STATUS "Found libzmq using find_package")
|
||||||
|
else()
|
||||||
|
message(STATUS "CMake libzmq package not found, trying again with pkg-config (normal install of zeromq)")
|
||||||
|
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake/libzmq-pkg-config)
|
||||||
|
find_package(ZeroMQ 4 REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# TODO "REQUIRED" above should already cause a fatal failure if not found, but this doesn't seem to work
|
||||||
|
if(NOT ZeroMQ_FOUND)
|
||||||
|
message(FATAL_ERROR "ZeroMQ was not found, neither as a CMake package nor via pkg-config")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (ZeroMQ_FOUND AND NOT TARGET libzmq)
|
||||||
|
message(FATAL_ERROR "ZeroMQ version not supported!")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_target_property(VAR libzmq IMPORTED_LOCATION)
|
||||||
|
message(STATUS "Using libzmq: ${VAR}")
|
||||||
|
|
||||||
|
|
||||||
|
endfunction()
|
36
cmake/libzmq-pkg-config/FindZeroMQ.cmake
Executable file
36
cmake/libzmq-pkg-config/FindZeroMQ.cmake
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
#From: https://github.com/zeromq/cppzmq/
|
||||||
|
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
|
||||||
|
find_package(PkgConfig)
|
||||||
|
pkg_check_modules(PC_LIBZMQ QUIET libzmq)
|
||||||
|
|
||||||
|
set(ZeroMQ_VERSION ${PC_LIBZMQ_VERSION})
|
||||||
|
|
||||||
|
find_path(ZeroMQ_INCLUDE_DIR zmq.h
|
||||||
|
PATHS ${ZeroMQ_DIR}/include
|
||||||
|
${PC_LIBZMQ_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(ZeroMQ_LIBRARY
|
||||||
|
NAMES zmq
|
||||||
|
PATHS ${ZeroMQ_DIR}/lib
|
||||||
|
${PC_LIBZMQ_LIBDIR}
|
||||||
|
${PC_LIBZMQ_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(ZeroMQ_LIBRARY OR ZeroMQ_STATIC_LIBRARY)
|
||||||
|
set(ZeroMQ_FOUND ON)
|
||||||
|
message(STATUS "Found libzmq using PkgConfig")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set ( ZeroMQ_LIBRARIES ${ZeroMQ_LIBRARY} )
|
||||||
|
set ( ZeroMQ_INCLUDE_DIRS ${ZeroMQ_INCLUDE_DIR} )
|
||||||
|
|
||||||
|
if (NOT TARGET libzmq)
|
||||||
|
add_library(libzmq UNKNOWN IMPORTED)
|
||||||
|
set_target_properties(libzmq PROPERTIES
|
||||||
|
IMPORTED_LOCATION ${ZeroMQ_LIBRARIES}
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES ${ZeroMQ_INCLUDE_DIRS})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include ( FindPackageHandleStandardArgs )
|
||||||
|
find_package_handle_standard_args ( ZeroMQ DEFAULT_MSG ZeroMQ_LIBRARIES ZeroMQ_INCLUDE_DIRS )
|
@ -26,7 +26,7 @@ install(FILES
|
|||||||
)
|
)
|
||||||
|
|
||||||
install(FILES
|
install(FILES
|
||||||
"${CMAKE_SOURCE_DIR}/libzmq-pkg-config/FindZeroMQ.cmake"
|
"${CMAKE_SOURCE_DIR}/cmake/libzmq-pkg-config/FindZeroMQ.cmake"
|
||||||
COMPONENT devel
|
COMPONENT devel
|
||||||
DESTINATION ${CMAKE_INSTALL_DIR}/libzmq-pkg-config
|
DESTINATION ${CMAKE_INSTALL_DIR}/libzmq-pkg-config
|
||||||
)
|
)
|
||||||
|
@ -19,4 +19,4 @@ cp build/install/bin/slsMultiReceiver $PREFIX/bin/.
|
|||||||
|
|
||||||
|
|
||||||
cp build/install/include/sls/* $PREFIX/include/sls
|
cp build/install/include/sls/* $PREFIX/include/sls
|
||||||
cp -r build/install/share/ $PREFIX/share
|
cp -rv build/install/share $PREFIX
|
||||||
|
@ -45,6 +45,7 @@ int main() {
|
|||||||
|
|
||||||
for (const auto &cmd : commands) {
|
for (const auto &cmd : commands) {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
|
std::cout << cmd << '\n';
|
||||||
proxy.Call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os);
|
proxy.Call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os);
|
||||||
|
|
||||||
auto tmp = os.str().erase(0, cmd.size());
|
auto tmp = os.str().erase(0, cmd.size());
|
||||||
|
@ -136,7 +136,7 @@ can use dir()
|
|||||||
'__str__', '__subclasshook__', '_adc_register', '_frozen',
|
'__str__', '__subclasshook__', '_adc_register', '_frozen',
|
||||||
'_register', 'acquire', 'adcclk', 'adcphase', 'adcpipeline',
|
'_register', 'acquire', 'adcclk', 'adcphase', 'adcpipeline',
|
||||||
'adcreg', 'asamples', 'auto_comp_disable', 'clearAcquiringFlag',
|
'adcreg', 'asamples', 'auto_comp_disable', 'clearAcquiringFlag',
|
||||||
'clearBit', 'clearROI', 'client_version', 'config', 'copyDetectorServer',
|
'clearBit', 'clearROI', 'client_version', 'config',
|
||||||
'counters', 'daclist', 'dacvalues', 'dbitclk', 'dbitphase' ...
|
'counters', 'daclist', 'dacvalues', 'dbitclk', 'dbitphase' ...
|
||||||
|
|
||||||
Since the list for Detector is rather long it's an good idea to filter it.
|
Since the list for Detector is rather long it's an good idea to filter it.
|
||||||
|
@ -5,17 +5,42 @@ Detector Server Upgrade
|
|||||||
|
|
||||||
**Location:** slsDetectorPackage/serverBin/ folder for every release.
|
**Location:** slsDetectorPackage/serverBin/ folder for every release.
|
||||||
|
|
||||||
|
.. note ::
|
||||||
|
|
||||||
|
For Mythen3, Gotthard2 and Eiger, you need to add scripts to automatically start detector server upon power on. See :ref:`Automatic start<Automatic start servers>` for more details.
|
||||||
|
|
||||||
|
.. note ::
|
||||||
|
|
||||||
|
Eiger requires a manual reboot. Or killall the servers and restart the new linked one. If you are in the process of updating firmware, then don't reboot yet.
|
||||||
|
|
||||||
|
|
||||||
|
From 6.1.1 and above (no tftp required)
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
|
#. Program from console
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
# the following command copies new server, creates a soft link to xxxDetectorServerxxx
|
||||||
|
# [Jungfrau][CTB][Moench] also deletes the old server binary and edits initttab to respawn server on reboot
|
||||||
|
# Then, the detector controller will reboot (except Eiger)
|
||||||
|
sls_detector_put updatedetectorserver /complete-path-to-binary/xxxDetectorServerxxx
|
||||||
|
|
||||||
|
#. Copy the detector server specific config files or any others required to the detector:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sls_detector_put execcommand "tftp pcxxx -r configxxx -g"
|
||||||
|
|
||||||
|
5.0.0 - 6.1.1
|
||||||
|
--------------
|
||||||
|
|
||||||
#. Install tftp and copy detector server binary to tftp folder
|
#. Install tftp and copy detector server binary to tftp folder
|
||||||
#. Program from console
|
#. Program from console
|
||||||
|
|
||||||
.. note ::
|
|
||||||
|
|
||||||
These instructions are for upgrades from v5.0.0. For earlier versions, contact us.
|
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
# copies new server from pc tftp folder, creates a soft link to xxxDetectorServerxxx
|
# the following command copies new server from pc tftp folder, creates a soft link to xxxDetectorServerxxx
|
||||||
# [Jungfrau][CTB][Moench] also edits initttab to respawn server on reboot
|
# [Jungfrau][CTB][Moench] also edits initttab to respawn server on reboot
|
||||||
# Then, the detector controller will reboot (except Eiger)
|
# Then, the detector controller will reboot (except Eiger)
|
||||||
sls_detector_put copydetectorserver xxxDetectorServerxxx pcxxx
|
sls_detector_put copydetectorserver xxxDetectorServerxxx pcxxx
|
||||||
@ -27,18 +52,15 @@ Detector Server Upgrade
|
|||||||
sls_detector_put execcommand "tftp pcxxx -r configxxx -g"
|
sls_detector_put execcommand "tftp pcxxx -r configxxx -g"
|
||||||
|
|
||||||
|
|
||||||
.. note ::
|
Troubleshooting with tftp
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
For Mythen3, Gotthard2 and Eiger, you need to add scripts to automatically start detector server upon power on. See :ref:`Automatic start<Automatic start servers>` for more details.
|
|
||||||
|
|
||||||
.. note ::
|
|
||||||
|
|
||||||
Eiger requires a manual reboot. Or killall the servers and restart the new linked one. If you are in the process of updating firmware, then don't reboot yet.
|
|
||||||
|
|
||||||
|
|
||||||
Errors
|
|
||||||
------
|
|
||||||
|
|
||||||
#. tftp write error: There is no space left. Please delete some old binaries and try again.
|
#. tftp write error: There is no space left. Please delete some old binaries and try again.
|
||||||
|
|
||||||
#. text file busy: You are trying to copy the same server.
|
#. text file busy: You are trying to copy the same server.
|
||||||
|
|
||||||
|
|
||||||
|
Older than 5.0.0
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
Please contact us.
|
Submodule libs/pybind11 updated: 8de7772cc7...914c06fb25
@ -1,27 +0,0 @@
|
|||||||
#From: https://github.com/zeromq/cppzmq/
|
|
||||||
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
|
|
||||||
find_package(PkgConfig)
|
|
||||||
pkg_check_modules(PC_LIBZMQ QUIET libzmq)
|
|
||||||
|
|
||||||
set(ZeroMQ_VERSION ${PC_LIBZMQ_VERSION})
|
|
||||||
find_library(ZeroMQ_LIBRARY NAMES libzmq.so libzmq.dylib libzmq.dll
|
|
||||||
PATHS ${PC_LIBZMQ_LIBDIR} ${PC_LIBZMQ_LIBRARY_DIRS})
|
|
||||||
find_library(ZeroMQ_STATIC_LIBRARY NAMES libzmq-static.a libzmq.a libzmq.dll.a
|
|
||||||
PATHS ${PC_LIBZMQ_LIBDIR} ${PC_LIBZMQ_LIBRARY_DIRS})
|
|
||||||
|
|
||||||
if(ZeroMQ_LIBRARY OR ZeroMQ_STATIC_LIBRARY)
|
|
||||||
set(ZeroMQ_FOUND ON)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (TARGET libzmq)
|
|
||||||
# avoid errors defining targets twice
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(libzmq SHARED IMPORTED)
|
|
||||||
set_property(TARGET libzmq PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PC_LIBZMQ_INCLUDE_DIRS})
|
|
||||||
set_property(TARGET libzmq PROPERTY IMPORTED_LOCATION ${ZeroMQ_LIBRARY})
|
|
||||||
|
|
||||||
add_library(libzmq-static STATIC IMPORTED ${PC_LIBZMQ_INCLUDE_DIRS})
|
|
||||||
set_property(TARGET libzmq-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PC_LIBZMQ_INCLUDE_DIRS})
|
|
||||||
set_property(TARGET libzmq-static PROPERTY IMPORTED_LOCATION ${ZeroMQ_STATIC_LIBRARY})
|
|
@ -3498,10 +3498,60 @@ class Detector(CppDetectorApi):
|
|||||||
|
|
||||||
def readout(self):
|
def readout(self):
|
||||||
"""
|
"""
|
||||||
Mythen3] Starts detector readout. Status changes to TRANSMITTING and automatically returns to idle at the end of readout.
|
[Mythen3] Starts detector readout. Status changes to TRANSMITTING and automatically returns to idle at the end of readout.
|
||||||
"""
|
"""
|
||||||
self.startDetectorReadout()
|
self.startDetectorReadout()
|
||||||
|
|
||||||
|
@property
|
||||||
|
@element
|
||||||
|
def polarity(self):
|
||||||
|
"""[Mythen3] Set positive or negative polarity. Enum: polarity"""
|
||||||
|
return self.getPolarity()
|
||||||
|
|
||||||
|
@polarity.setter
|
||||||
|
def polarity(self, value):
|
||||||
|
ut.set_using_dict(self.setPolarity, value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
@element
|
||||||
|
def interpolation(self):
|
||||||
|
"""[Mythen3] Enable or disable interpolation. Enabling also enables all counters """
|
||||||
|
return self.getInterpolation()
|
||||||
|
|
||||||
|
@interpolation.setter
|
||||||
|
def interpolation(self, value):
|
||||||
|
ut.set_using_dict(self.setInterpolation, value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
@element
|
||||||
|
def pumpprobe(self):
|
||||||
|
"""[Mythen3] Enable or disable pump probe mode. """
|
||||||
|
return self.getPumpProbe()
|
||||||
|
|
||||||
|
@pumpprobe.setter
|
||||||
|
def pumpprobe(self, value):
|
||||||
|
ut.set_using_dict(self.setPumpProbe, value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
@element
|
||||||
|
def apulse(self):
|
||||||
|
"""[Mythen3] Enable or disable analog pulsing. """
|
||||||
|
return self.getAnalogPulsing()
|
||||||
|
|
||||||
|
@apulse.setter
|
||||||
|
def apulse(self, value):
|
||||||
|
ut.set_using_dict(self.setAnalogPulsing, value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
@element
|
||||||
|
def dpulse(self):
|
||||||
|
"""[Mythen3] Enable or disable digital pulsing. """
|
||||||
|
return self.getDigitalPulsing()
|
||||||
|
|
||||||
|
@dpulse.setter
|
||||||
|
def dpulse(self, value):
|
||||||
|
ut.set_using_dict(self.setDigitalPulsing, value)
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
---------------------------<<<Debug>>>---------------------------
|
---------------------------<<<Debug>>>---------------------------
|
||||||
|
@ -1290,6 +1290,46 @@ void init_det(py::module &m) {
|
|||||||
.def("getGainCaps",
|
.def("getGainCaps",
|
||||||
(Result<int>(Detector::*)(sls::Positions)) & Detector::getGainCaps,
|
(Result<int>(Detector::*)(sls::Positions)) & Detector::getGainCaps,
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
|
.def("getPolarity",
|
||||||
|
(Result<defs::polarity>(Detector::*)(sls::Positions) const) &
|
||||||
|
Detector::getPolarity,
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("setPolarity",
|
||||||
|
(void (Detector::*)(defs::polarity, sls::Positions)) &
|
||||||
|
Detector::setPolarity,
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
|
.def("getInterpolation",
|
||||||
|
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||||
|
Detector::getInterpolation,
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("setInterpolation",
|
||||||
|
(void (Detector::*)(bool, sls::Positions)) &
|
||||||
|
Detector::setInterpolation,
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
|
.def("getPumpProbe",
|
||||||
|
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||||
|
Detector::getPumpProbe,
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("setPumpProbe",
|
||||||
|
(void (Detector::*)(bool, sls::Positions)) &
|
||||||
|
Detector::setPumpProbe,
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
|
.def("getAnalogPulsing",
|
||||||
|
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||||
|
Detector::getAnalogPulsing,
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("setAnalogPulsing",
|
||||||
|
(void (Detector::*)(bool, sls::Positions)) &
|
||||||
|
Detector::setAnalogPulsing,
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
|
.def("getDigitalPulsing",
|
||||||
|
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||||
|
Detector::getDigitalPulsing,
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("setDigitalPulsing",
|
||||||
|
(void (Detector::*)(bool, sls::Positions)) &
|
||||||
|
Detector::setDigitalPulsing,
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
.def("getNumberOfAnalogSamples",
|
.def("getNumberOfAnalogSamples",
|
||||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
(Result<int>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getNumberOfAnalogSamples,
|
Detector::getNumberOfAnalogSamples,
|
||||||
@ -1551,11 +1591,6 @@ void init_det(py::module &m) {
|
|||||||
.def("resetFPGA",
|
.def("resetFPGA",
|
||||||
(void (Detector::*)(sls::Positions)) & Detector::resetFPGA,
|
(void (Detector::*)(sls::Positions)) & Detector::resetFPGA,
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
.def("copyDetectorServer",
|
|
||||||
(void (Detector::*)(const std::string &, const std::string &,
|
|
||||||
sls::Positions)) &
|
|
||||||
Detector::copyDetectorServer,
|
|
||||||
py::arg(), py::arg(), py::arg() = Positions{})
|
|
||||||
.def("updateDetectorServer",
|
.def("updateDetectorServer",
|
||||||
(void (Detector::*)(const std::string &, sls::Positions)) &
|
(void (Detector::*)(const std::string &, sls::Positions)) &
|
||||||
Detector::updateDetectorServer,
|
Detector::updateDetectorServer,
|
||||||
|
@ -315,4 +315,9 @@ void init_enums(py::module &m) {
|
|||||||
.value("FIX_G2", slsDetectorDefs::gainMode::FIX_G2)
|
.value("FIX_G2", slsDetectorDefs::gainMode::FIX_G2)
|
||||||
.value("FIX_G0", slsDetectorDefs::gainMode::FIX_G0)
|
.value("FIX_G0", slsDetectorDefs::gainMode::FIX_G0)
|
||||||
.export_values();
|
.export_values();
|
||||||
|
|
||||||
|
py::enum_<slsDetectorDefs::polarity>(Defs, "polarity")
|
||||||
|
.value("POSITIVE", slsDetectorDefs::polarity::POSITIVE)
|
||||||
|
.value("NEGATIVE", slsDetectorDefs::polarity::NEGATIVE)
|
||||||
|
.export_values();
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ foreach(exe ${MOENCH_EXECUTABLES})
|
|||||||
../interpolations
|
../interpolations
|
||||||
../../slsReceiverSoftware/include/
|
../../slsReceiverSoftware/include/
|
||||||
../../slsSupportLib/include/
|
../../slsSupportLib/include/
|
||||||
|
${SLS_INTERNAL_RAPIDJSON_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${exe}
|
target_link_libraries(${exe}
|
||||||
|
Binary file not shown.
@ -2060,8 +2060,8 @@ void *start_timer(void *arg) {
|
|||||||
header->frameNumber = frameNr + iframes;
|
header->frameNumber = frameNr + iframes;
|
||||||
header->packetNumber = i;
|
header->packetNumber = i;
|
||||||
header->modId = 0;
|
header->modId = 0;
|
||||||
header->row = detPos[X];
|
header->row = detPos[Y];
|
||||||
header->column = detPos[Y];
|
header->column = detPos[X];
|
||||||
|
|
||||||
// fill data
|
// fill data
|
||||||
memcpy(packetData + sizeof(sls_detector_header),
|
memcpy(packetData + sizeof(sls_detector_header),
|
||||||
|
@ -1095,19 +1095,19 @@ int *Beb_GetDetectorPosition() { return Beb_positions; }
|
|||||||
int Beb_SetDetectorPosition(int pos[]) {
|
int Beb_SetDetectorPosition(int pos[]) {
|
||||||
if (!Beb_activated)
|
if (!Beb_activated)
|
||||||
return OK;
|
return OK;
|
||||||
LOG(logINFO, ("Got Position values %d %d...\n", pos[0], pos[1]));
|
LOG(logINFO, ("Setting Position: (%d, %d)\n", pos[X], pos[Y]));
|
||||||
|
|
||||||
// save positions
|
// save positions
|
||||||
Beb_positions[0] = pos[0];
|
Beb_positions[Y] = pos[Y];
|
||||||
Beb_positions[1] = pos[1];
|
Beb_positions[X] = pos[X];
|
||||||
|
|
||||||
// get left and right
|
// get left and right
|
||||||
int posLeft[2] = {pos[0], Beb_top ? pos[1] : pos[1] + 1};
|
int posLeft[2] = {Beb_top ? pos[X] : pos[X] + 1, pos[Y]};
|
||||||
int posRight[2] = {pos[0], Beb_top ? pos[1] + 1 : pos[1]};
|
int posRight[2] = {Beb_top ? pos[X] + 1 : pos[X], pos[Y]};
|
||||||
|
|
||||||
if (Beb_quadEnable) {
|
if (Beb_quadEnable) {
|
||||||
posRight[0] = 1; // right is next row
|
posRight[Y] = 1; // right is next row
|
||||||
posRight[1] = 0; // right same first column
|
posRight[X] = 0; // right same first column
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
@ -1122,7 +1122,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
|||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
ret = OK;
|
ret = OK;
|
||||||
// x left
|
// x left
|
||||||
int posval = Beb_swap_uint16(posLeft[0]);
|
int posval = Beb_swap_uint16(posLeft[Y]);
|
||||||
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
|
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
|
||||||
value &= UDP_HEADER_ID_MSK; // to keep previous id value
|
value &= UDP_HEADER_ID_MSK; // to keep previous id value
|
||||||
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST,
|
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST,
|
||||||
@ -1134,7 +1134,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
|||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
}
|
}
|
||||||
// x right
|
// x right
|
||||||
posval = Beb_swap_uint16(posRight[0]);
|
posval = Beb_swap_uint16(posRight[Y]);
|
||||||
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
|
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
|
||||||
value &= UDP_HEADER_ID_MSK; // to keep previous id value
|
value &= UDP_HEADER_ID_MSK; // to keep previous id value
|
||||||
Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST,
|
Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST,
|
||||||
@ -1147,7 +1147,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// y left (column)
|
// y left (column)
|
||||||
posval = Beb_swap_uint16(posLeft[1]);
|
posval = Beb_swap_uint16(posLeft[X]);
|
||||||
value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST);
|
value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST);
|
||||||
value &= UDP_HEADER_Z_MSK; // to keep previous z value
|
value &= UDP_HEADER_Z_MSK; // to keep previous z value
|
||||||
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST,
|
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST,
|
||||||
@ -1160,7 +1160,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// y right
|
// y right
|
||||||
posval = Beb_swap_uint16(posRight[1]);
|
posval = Beb_swap_uint16(posRight[X]);
|
||||||
value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST);
|
value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST);
|
||||||
value &= UDP_HEADER_Z_MSK; // to keep previous z value
|
value &= UDP_HEADER_Z_MSK; // to keep previous z value
|
||||||
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST,
|
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST,
|
||||||
@ -1176,10 +1176,10 @@ int Beb_SetDetectorPosition(int pos[]) {
|
|||||||
Beb_close(fd, csp0base);
|
Beb_close(fd, csp0base);
|
||||||
}
|
}
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
LOG(logINFO, ("Position set to...\n"
|
LOG(logINFO, ("Position set to (col, row):\n"
|
||||||
"\tLeft: [%d, %d]\n"
|
"\tLeft: [%d, %d]\n"
|
||||||
"\tRight:[%d, %d]\n",
|
"\tRight:[%d, %d]\n",
|
||||||
posLeft[0], posLeft[1], posRight[0], posRight[1]));
|
posLeft[X], posLeft[Y], posRight[X], posRight[Y]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Binary file not shown.
@ -19,7 +19,7 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
extern int portno;
|
||||||
// Global variable from slsDetectorServer_funcs
|
// Global variable from slsDetectorServer_funcs
|
||||||
extern int debugflag;
|
extern int debugflag;
|
||||||
extern int updateFlag;
|
extern int updateFlag;
|
||||||
@ -2473,9 +2473,9 @@ void *start_timer(void *arg) {
|
|||||||
int maxPacketsPerFrame = (tgEnable ? 4 : 16) * dr;
|
int maxPacketsPerFrame = (tgEnable ? 4 : 16) * dr;
|
||||||
int npixelsx = 256 * 2 * bytesPerPixel;
|
int npixelsx = 256 * 2 * bytesPerPixel;
|
||||||
int databytes = 256 * 256 * 2 * bytesPerPixel;
|
int databytes = 256 * 256 * 2 * bytesPerPixel;
|
||||||
int row = eiger_virtual_detPos[0];
|
int row = eiger_virtual_detPos[Y];
|
||||||
int colLeft = top ? eiger_virtual_detPos[1] : eiger_virtual_detPos[1] + 1;
|
int colLeft = top ? eiger_virtual_detPos[X] : eiger_virtual_detPos[X] + 1;
|
||||||
int colRight = top ? eiger_virtual_detPos[1] + 1 : eiger_virtual_detPos[1];
|
int colRight = top ? eiger_virtual_detPos[X] + 1 : eiger_virtual_detPos[X];
|
||||||
|
|
||||||
int readNRows = getReadNRows();
|
int readNRows = getReadNRows();
|
||||||
if (readNRows == -1) {
|
if (readNRows == -1) {
|
||||||
@ -2548,8 +2548,20 @@ void *start_timer(void *arg) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
|
// to debug multi module geometry (row, column) in virtual servers (all pixels
|
||||||
|
// in a module set to particular value)
|
||||||
|
#ifdef TEST_MOD_GEOMETRY
|
||||||
|
if ((i % 1024) < 512) {
|
||||||
|
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
|
||||||
|
top ? (portno % 1900) : ((portno % 1900) + 1);
|
||||||
|
} else {
|
||||||
|
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
|
||||||
|
top ? ((portno % 1900) + 1) : (portno % 1900);
|
||||||
|
}
|
||||||
|
#else
|
||||||
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
|
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
|
||||||
eiger_virtual_test_mode ? 0xFFE : (uint16_t)pixelVal;
|
eiger_virtual_test_mode ? 0xFFE : (uint16_t)pixelVal;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
*((uint32_t *)(imageData + i * sizeof(uint32_t))) =
|
*((uint32_t *)(imageData + i * sizeof(uint32_t))) =
|
||||||
|
Binary file not shown.
@ -1917,7 +1917,7 @@ int setDetectorPosition(int pos[]) {
|
|||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
// row
|
// row
|
||||||
value = detPos[X];
|
value = detPos[Y];
|
||||||
bus_w(addr, (bus_r(addr) & ~COORD_ROW_MSK) |
|
bus_w(addr, (bus_r(addr) & ~COORD_ROW_MSK) |
|
||||||
((value << COORD_ROW_OFST) & COORD_ROW_MSK));
|
((value << COORD_ROW_OFST) & COORD_ROW_MSK));
|
||||||
valueRead = ((bus_r(addr) & COORD_ROW_MSK) >> COORD_ROW_OFST);
|
valueRead = ((bus_r(addr) & COORD_ROW_MSK) >> COORD_ROW_OFST);
|
||||||
@ -1928,7 +1928,7 @@ int setDetectorPosition(int pos[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// col
|
// col
|
||||||
value = detPos[Y];
|
value = detPos[X];
|
||||||
bus_w(addr, (bus_r(addr) & ~COORD_COL_MSK) |
|
bus_w(addr, (bus_r(addr) & ~COORD_COL_MSK) |
|
||||||
((value << COORD_COL_OFST) & COORD_COL_MSK));
|
((value << COORD_COL_OFST) & COORD_COL_MSK));
|
||||||
valueRead = ((bus_r(addr) & COORD_COL_MSK) >> COORD_COL_OFST);
|
valueRead = ((bus_r(addr) & COORD_COL_MSK) >> COORD_COL_OFST);
|
||||||
@ -1939,7 +1939,8 @@ int setDetectorPosition(int pos[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
LOG(logINFO, ("\tPosition set to [%d, %d]\n", detPos[X], detPos[Y]));
|
LOG(logINFO,
|
||||||
|
("\tPosition set to [%d, %d] #(col, row)\n", detPos[X], detPos[Y]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -3095,8 +3096,8 @@ void *start_timer(void *arg) {
|
|||||||
header->frameNumber = virtual_currentFrameNumber;
|
header->frameNumber = virtual_currentFrameNumber;
|
||||||
header->packetNumber = 0;
|
header->packetNumber = 0;
|
||||||
header->modId = virtual_moduleid;
|
header->modId = virtual_moduleid;
|
||||||
header->row = detPos[X];
|
header->row = detPos[Y];
|
||||||
header->column = detPos[Y];
|
header->column = detPos[X];
|
||||||
// fill data
|
// fill data
|
||||||
memcpy(packetData + sizeof(sls_detector_header), imageData,
|
memcpy(packetData + sizeof(sls_detector_header), imageData,
|
||||||
datasize);
|
datasize);
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -21,7 +21,7 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
extern int portno;
|
||||||
// Global variable from slsDetectorServer_funcs
|
// Global variable from slsDetectorServer_funcs
|
||||||
extern int debugflag;
|
extern int debugflag;
|
||||||
extern int updateFlag;
|
extern int updateFlag;
|
||||||
@ -1621,6 +1621,7 @@ int configureMAC() {
|
|||||||
|
|
||||||
int setDetectorPosition(int pos[]) {
|
int setDetectorPosition(int pos[]) {
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
// row, col
|
||||||
uint32_t innerPos[2] = {pos[X], pos[Y]};
|
uint32_t innerPos[2] = {pos[X], pos[Y]};
|
||||||
uint32_t outerPos[2] = {pos[X], pos[Y]};
|
uint32_t outerPos[2] = {pos[X], pos[Y]};
|
||||||
int selInterface = getPrimaryInterface();
|
int selInterface = getPrimaryInterface();
|
||||||
@ -1630,15 +1631,16 @@ int setDetectorPosition(int pos[]) {
|
|||||||
("Setting detector position: 1 Interface %s \n(%d, %d)\n",
|
("Setting detector position: 1 Interface %s \n(%d, %d)\n",
|
||||||
(selInterface ? "Inner" : "Outer"), innerPos[X], innerPos[Y]));
|
(selInterface ? "Inner" : "Outer"), innerPos[X], innerPos[Y]));
|
||||||
} else {
|
} else {
|
||||||
++outerPos[X];
|
// top has row incremented by 1
|
||||||
|
++innerPos[Y];
|
||||||
LOG(logDEBUG, ("Setting detector position: 2 Interfaces \n"
|
LOG(logDEBUG, ("Setting detector position: 2 Interfaces \n"
|
||||||
" inner top(%d, %d), outer bottom(%d, %d)\n",
|
" inner top(%d, %d), outer bottom(%d, %d)\n",
|
||||||
innerPos[X], innerPos[Y], outerPos[X], outerPos[Y]));
|
innerPos[X], innerPos[Y], outerPos[X], outerPos[Y]));
|
||||||
}
|
}
|
||||||
detPos[0] = innerPos[0];
|
detPos[0] = innerPos[X];
|
||||||
detPos[1] = innerPos[1];
|
detPos[1] = innerPos[Y];
|
||||||
detPos[2] = outerPos[0];
|
detPos[2] = outerPos[X];
|
||||||
detPos[3] = outerPos[1];
|
detPos[3] = outerPos[Y];
|
||||||
|
|
||||||
// row
|
// row
|
||||||
// outer
|
// outer
|
||||||
@ -1676,8 +1678,8 @@ int setDetectorPosition(int pos[]) {
|
|||||||
|
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
if (getNumberofUDPInterfaces() == 1) {
|
if (getNumberofUDPInterfaces() == 1) {
|
||||||
LOG(logINFOBLUE,
|
LOG(logINFOBLUE, ("Position set to [%d, %d] #(col, row)\n",
|
||||||
("Position set to [%d, %d]\n", innerPos[X], innerPos[Y]));
|
innerPos[X], innerPos[Y]));
|
||||||
} else {
|
} else {
|
||||||
LOG(logINFOBLUE, (" Inner (top) position set to [%d, %d]\n",
|
LOG(logINFOBLUE, (" Inner (top) position set to [%d, %d]\n",
|
||||||
innerPos[X], innerPos[Y]));
|
innerPos[X], innerPos[Y]));
|
||||||
@ -2531,8 +2533,16 @@ void *start_timer(void *arg) {
|
|||||||
if (i > 0 && i % pixelsPerPacket == 0) {
|
if (i > 0 && i % pixelsPerPacket == 0) {
|
||||||
++pixelVal;
|
++pixelVal;
|
||||||
}
|
}
|
||||||
|
// to debug multi module geometry (row, column) in virtual servers (all pixels
|
||||||
|
// in a module set to particular value)
|
||||||
|
#ifdef TEST_MOD_GEOMETRY
|
||||||
|
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
|
||||||
|
portno % 1900 + (i >= npixels / 2 ? 1 : 0);
|
||||||
|
#else
|
||||||
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
|
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
|
||||||
virtual_image_test_mode ? 0x0FFE : (uint16_t)pixelVal;
|
virtual_image_test_mode ? 0x0FFE : (uint16_t)pixelVal;
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2557,6 +2567,10 @@ void *start_timer(void *arg) {
|
|||||||
|
|
||||||
int srcOffset = 0;
|
int srcOffset = 0;
|
||||||
int srcOffset2 = DATA_BYTES / 2;
|
int srcOffset2 = DATA_BYTES / 2;
|
||||||
|
int row0 = (numInterfaces == 1 ? detPos[1] : detPos[3]);
|
||||||
|
int col0 = (numInterfaces == 1 ? detPos[0] : detPos[2]);
|
||||||
|
int row1 = detPos[1];
|
||||||
|
int col1 = detPos[0];
|
||||||
// loop packet (128 packets)
|
// loop packet (128 packets)
|
||||||
for (int i = 0; i != maxPacketsPerFrame; ++i) {
|
for (int i = 0; i != maxPacketsPerFrame; ++i) {
|
||||||
|
|
||||||
@ -2576,8 +2590,8 @@ void *start_timer(void *arg) {
|
|||||||
header->frameNumber = frameNr + iframes;
|
header->frameNumber = frameNr + iframes;
|
||||||
header->packetNumber = pnum;
|
header->packetNumber = pnum;
|
||||||
header->modId = 0;
|
header->modId = 0;
|
||||||
header->row = detPos[0];
|
header->row = row0;
|
||||||
header->column = detPos[1];
|
header->column = col0;
|
||||||
|
|
||||||
// fill data
|
// fill data
|
||||||
memcpy(packetData + sizeof(sls_detector_header),
|
memcpy(packetData + sizeof(sls_detector_header),
|
||||||
@ -2603,8 +2617,8 @@ void *start_timer(void *arg) {
|
|||||||
header->frameNumber = frameNr + iframes;
|
header->frameNumber = frameNr + iframes;
|
||||||
header->packetNumber = pnum;
|
header->packetNumber = pnum;
|
||||||
header->modId = 0;
|
header->modId = 0;
|
||||||
header->row = detPos[2];
|
header->row = row1;
|
||||||
header->column = detPos[3];
|
header->column = col1;
|
||||||
|
|
||||||
// fill data
|
// fill data
|
||||||
memcpy(packetData2 + sizeof(sls_detector_header),
|
memcpy(packetData2 + sizeof(sls_detector_header),
|
||||||
|
Binary file not shown.
@ -1731,8 +1731,8 @@ void *start_timer(void *arg) {
|
|||||||
header->frameNumber = frameNr + iframes;
|
header->frameNumber = frameNr + iframes;
|
||||||
header->packetNumber = i;
|
header->packetNumber = i;
|
||||||
header->modId = 0;
|
header->modId = 0;
|
||||||
header->row = detPos[X];
|
header->row = detPos[Y];
|
||||||
header->column = detPos[Y];
|
header->column = detPos[X];
|
||||||
|
|
||||||
// fill data
|
// fill data
|
||||||
memcpy(packetData + sizeof(sls_detector_header),
|
memcpy(packetData + sizeof(sls_detector_header),
|
||||||
|
Binary file not shown.
@ -10,20 +10,6 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/*
|
|
||||||
// Common C/C++ structure to handle pattern data
|
|
||||||
typedef struct __attribute__((packed)) {
|
|
||||||
uint64_t word[MAX_PATTERN_LENGTH];
|
|
||||||
uint64_t ioctrl;
|
|
||||||
uint32_t limits[2];
|
|
||||||
// loop0 start, loop0 stop .. loop2 start, loop2 stop
|
|
||||||
uint32_t loop[6];
|
|
||||||
uint32_t nloop[3];
|
|
||||||
uint32_t wait[3];
|
|
||||||
uint64_t waittime[3];
|
|
||||||
} patternParameters;
|
|
||||||
*/
|
|
||||||
|
|
||||||
int chipStatusRegister = 0;
|
int chipStatusRegister = 0;
|
||||||
|
|
||||||
int setBit(int ibit, int patword) { return patword |= (1 << ibit); }
|
int setBit(int ibit, int patword) { return patword |= (1 << ibit); }
|
||||||
@ -32,44 +18,6 @@ int clearBit(int ibit, int patword) { return patword &= ~(1 << ibit); }
|
|||||||
|
|
||||||
int getChipStatusRegister() { return chipStatusRegister; }
|
int getChipStatusRegister() { return chipStatusRegister; }
|
||||||
|
|
||||||
int gainCapsToCsr(int caps) {
|
|
||||||
// Translates bit representation
|
|
||||||
int csr = 0;
|
|
||||||
if (!(caps & M3_C10pre))
|
|
||||||
csr |= 1 << _CSR_C10pre;
|
|
||||||
if (caps & M3_C15sh)
|
|
||||||
csr |= 1 << CSR_C15sh;
|
|
||||||
if (caps & M3_C30sh)
|
|
||||||
csr |= 1 << CSR_C30sh;
|
|
||||||
if (caps & M3_C50sh)
|
|
||||||
csr |= 1 << CSR_C50sh;
|
|
||||||
if (caps & M3_C225ACsh)
|
|
||||||
csr |= 1 << CSR_C225ACsh;
|
|
||||||
if (!(caps & M3_C15pre))
|
|
||||||
csr |= 1 << _CSR_C15pre;
|
|
||||||
|
|
||||||
return csr;
|
|
||||||
}
|
|
||||||
|
|
||||||
int csrToGainCaps(int csr) {
|
|
||||||
// Translates bit representation
|
|
||||||
int caps = 0;
|
|
||||||
if (!(csr & (1 << _CSR_C10pre)))
|
|
||||||
caps |= M3_C10pre;
|
|
||||||
if (csr & (1 << CSR_C15sh))
|
|
||||||
caps |= M3_C15sh;
|
|
||||||
if (csr & (1 << CSR_C30sh))
|
|
||||||
caps |= M3_C30sh;
|
|
||||||
if (csr & (1 << CSR_C50sh))
|
|
||||||
caps |= M3_C50sh;
|
|
||||||
if (csr & (1 << CSR_C225ACsh))
|
|
||||||
caps |= M3_C225ACsh;
|
|
||||||
if (!(csr & (1 << _CSR_C15pre)))
|
|
||||||
caps |= M3_C15pre;
|
|
||||||
|
|
||||||
return caps;
|
|
||||||
}
|
|
||||||
|
|
||||||
patternParameters *setChipStatusRegisterPattern(int csr) {
|
patternParameters *setChipStatusRegisterPattern(int csr) {
|
||||||
int iaddr = 0;
|
int iaddr = 0;
|
||||||
int nbits = 18;
|
int nbits = 18;
|
||||||
@ -149,54 +97,116 @@ patternParameters *setChipStatusRegisterPattern(int csr) {
|
|||||||
return pat;
|
return pat;
|
||||||
}
|
}
|
||||||
|
|
||||||
patternParameters *setInterpolation(int mask) {
|
int getGainCaps() {
|
||||||
int csr;
|
int csr = chipStatusRegister;
|
||||||
if (mask)
|
// Translates bit representation
|
||||||
csr = chipStatusRegister | (1 << CSR_interp);
|
int caps = 0;
|
||||||
else
|
if (!(csr & (1 << _CSR_C10pre)))
|
||||||
csr = chipStatusRegister & ~(1 << CSR_interp);
|
caps |= M3_C10pre;
|
||||||
|
if (csr & (1 << CSR_C15sh))
|
||||||
|
caps |= M3_C15sh;
|
||||||
|
if (csr & (1 << CSR_C30sh))
|
||||||
|
caps |= M3_C30sh;
|
||||||
|
if (csr & (1 << CSR_C50sh))
|
||||||
|
caps |= M3_C50sh;
|
||||||
|
if (csr & (1 << CSR_C225ACsh))
|
||||||
|
caps |= M3_C225ACsh;
|
||||||
|
if (!(csr & (1 << _CSR_C15pre)))
|
||||||
|
caps |= M3_C15pre;
|
||||||
|
|
||||||
return setChipStatusRegisterPattern(csr);
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
patternParameters *setPumpProbe(int mask) {
|
int M3SetGainCaps(int caps) {
|
||||||
int csr;
|
int csr = chipStatusRegister & ~GAIN_MASK;
|
||||||
if (mask)
|
|
||||||
csr = chipStatusRegister | (1 << CSR_pumprobe);
|
|
||||||
else
|
|
||||||
csr = chipStatusRegister & ~(1 << CSR_pumprobe);
|
|
||||||
|
|
||||||
return setChipStatusRegisterPattern(csr);
|
// Translates bit representation
|
||||||
|
if (!(caps & M3_C10pre))
|
||||||
|
csr |= 1 << _CSR_C10pre;
|
||||||
|
if (caps & M3_C15sh)
|
||||||
|
csr |= 1 << CSR_C15sh;
|
||||||
|
if (caps & M3_C30sh)
|
||||||
|
csr |= 1 << CSR_C30sh;
|
||||||
|
if (caps & M3_C50sh)
|
||||||
|
csr |= 1 << CSR_C50sh;
|
||||||
|
if (caps & M3_C225ACsh)
|
||||||
|
csr |= 1 << CSR_C225ACsh;
|
||||||
|
if (!(caps & M3_C15pre))
|
||||||
|
csr |= 1 << _CSR_C15pre;
|
||||||
|
|
||||||
|
return csr;
|
||||||
}
|
}
|
||||||
patternParameters *setDigitalPulsing(int mask) {
|
|
||||||
|
|
||||||
int csr;
|
int getInterpolation() {
|
||||||
if (mask)
|
return ((chipStatusRegister & CSR_interp_MSK) >> CSR_interp);
|
||||||
csr = chipStatusRegister | (1 << CSR_dpulse);
|
|
||||||
else
|
|
||||||
csr = chipStatusRegister & ~(1 << CSR_dpulse);
|
|
||||||
|
|
||||||
return setChipStatusRegisterPattern(csr);
|
|
||||||
}
|
}
|
||||||
patternParameters *setAnalogPulsing(int mask) {
|
|
||||||
|
|
||||||
int csr;
|
int M3SetInterpolation(int enable) {
|
||||||
if (mask)
|
int csr = 0;
|
||||||
csr = chipStatusRegister | (1 << CSR_apulse);
|
if (enable)
|
||||||
|
csr = chipStatusRegister | CSR_interp_MSK;
|
||||||
else
|
else
|
||||||
csr = chipStatusRegister & ~(1 << CSR_apulse);
|
csr = chipStatusRegister & ~CSR_interp_MSK;
|
||||||
|
return csr;
|
||||||
return setChipStatusRegisterPattern(csr);
|
|
||||||
}
|
}
|
||||||
patternParameters *setNegativePolarity(int mask) {
|
|
||||||
|
|
||||||
int csr;
|
int getPumpProbe() {
|
||||||
if (mask)
|
return ((chipStatusRegister & CSR_pumprobe_MSK) >> CSR_pumprobe);
|
||||||
csr = chipStatusRegister | (1 << CSR_invpol);
|
}
|
||||||
|
|
||||||
|
int M3SetPumpProbe(int enable) {
|
||||||
|
LOG(logINFO, ("%s Pump Probe\n", enable == 0 ? "Disabling" : "Enabling"));
|
||||||
|
int csr = 0;
|
||||||
|
if (enable)
|
||||||
|
csr = chipStatusRegister | CSR_pumprobe_MSK;
|
||||||
else
|
else
|
||||||
csr = chipStatusRegister & ~(1 << CSR_invpol);
|
csr = chipStatusRegister & ~CSR_pumprobe_MSK;
|
||||||
|
return csr;
|
||||||
|
}
|
||||||
|
|
||||||
return setChipStatusRegisterPattern(csr);
|
int getDigitalPulsing() {
|
||||||
|
return ((chipStatusRegister & CSR_dpulse_MSK) >> CSR_dpulse);
|
||||||
|
}
|
||||||
|
|
||||||
|
int M3SetDigitalPulsing(int enable) {
|
||||||
|
LOG(logINFO,
|
||||||
|
("%s Digital Pulsing\n", enable == 0 ? "Disabling" : "Enabling"));
|
||||||
|
int csr = 0;
|
||||||
|
if (enable)
|
||||||
|
csr = chipStatusRegister | CSR_dpulse_MSK;
|
||||||
|
else
|
||||||
|
csr = chipStatusRegister & ~CSR_dpulse_MSK;
|
||||||
|
return csr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getAnalogPulsing() {
|
||||||
|
return ((chipStatusRegister & CSR_apulse_MSK) >> CSR_apulse);
|
||||||
|
}
|
||||||
|
|
||||||
|
int M3SetAnalogPulsing(int enable) {
|
||||||
|
LOG(logINFO,
|
||||||
|
("%s Analog Pulsing\n", enable == 0 ? "Disabling" : "Enabling"));
|
||||||
|
int csr = 0;
|
||||||
|
if (enable)
|
||||||
|
csr = chipStatusRegister | CSR_apulse_MSK;
|
||||||
|
else
|
||||||
|
csr = chipStatusRegister & ~CSR_apulse_MSK;
|
||||||
|
return csr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getNegativePolarity() {
|
||||||
|
return ((chipStatusRegister & CSR_invpol_MSK) >> CSR_invpol);
|
||||||
|
}
|
||||||
|
|
||||||
|
int M3SetNegativePolarity(int enable) {
|
||||||
|
LOG(logINFO,
|
||||||
|
("%s Negative Polarity\n", enable == 0 ? "Disabling" : "Enabling"));
|
||||||
|
int csr = 0;
|
||||||
|
if (enable)
|
||||||
|
csr = chipStatusRegister | CSR_invpol_MSK;
|
||||||
|
else
|
||||||
|
csr = chipStatusRegister & ~CSR_invpol_MSK;
|
||||||
|
return csr;
|
||||||
}
|
}
|
||||||
|
|
||||||
patternParameters *setChannelRegisterChip(int ichip, int *mask, int *trimbits) {
|
patternParameters *setChannelRegisterChip(int ichip, int *mask, int *trimbits) {
|
||||||
|
@ -49,6 +49,12 @@
|
|||||||
// shaper)
|
// shaper)
|
||||||
#define _CSR_C15pre 14 // negative polarity
|
#define _CSR_C15pre 14 // negative polarity
|
||||||
|
|
||||||
|
#define CSR_invpol_MSK (0x1 << CSR_invpol)
|
||||||
|
#define CSR_dpulse_MSK (0x1 << CSR_dpulse)
|
||||||
|
#define CSR_interp_MSK (0x1 << CSR_interp)
|
||||||
|
#define CSR_pumprobe_MSK (0x1 << CSR_pumprobe)
|
||||||
|
#define CSR_apulse_MSK (0x1 << CSR_apulse)
|
||||||
|
|
||||||
#define CSR_default (1 << _CSR_C10pre) | (1 << CSR_C30sh)
|
#define CSR_default (1 << _CSR_C10pre) | (1 << CSR_C30sh)
|
||||||
|
|
||||||
#define GAIN_MASK \
|
#define GAIN_MASK \
|
||||||
@ -58,15 +64,20 @@
|
|||||||
int setBit(int ibit, int patword);
|
int setBit(int ibit, int patword);
|
||||||
int clearBit(int ibit, int patword);
|
int clearBit(int ibit, int patword);
|
||||||
int getChipStatusRegister();
|
int getChipStatusRegister();
|
||||||
int gainCapsToCsr(int caps);
|
|
||||||
int csrToGainCaps(int csr);
|
|
||||||
|
|
||||||
patternParameters *setChipStatusRegisterPattern(int csr);
|
patternParameters *setChipStatusRegisterPattern(int csr);
|
||||||
patternParameters *setChannelRegisterChip(int ichip, int *mask, int *trimbits);
|
patternParameters *setChannelRegisterChip(int ichip, int *mask, int *trimbits);
|
||||||
patternParameters *setInterpolation(int mask);
|
int getGainCaps();
|
||||||
patternParameters *setPumpProbe(int mask);
|
int M3SetGainCaps(int caps);
|
||||||
patternParameters *setDigitalPulsing(int mask);
|
int getInterpolation();
|
||||||
patternParameters *setAnalogPulsing(int mask);
|
int M3SetInterpolation(int enable);
|
||||||
patternParameters *setNegativePolarity(int mask);
|
int getPumpProbe();
|
||||||
|
int M3SetPumpProbe(int enable);
|
||||||
|
int getDigitalPulsing();
|
||||||
|
int M3SetDigitalPulsing(int enable);
|
||||||
|
int getAnalogPulsing();
|
||||||
|
int M3SetAnalogPulsing(int enable);
|
||||||
|
int getNegativePolarity();
|
||||||
|
int M3SetNegativePolarity(int enable);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1411,6 +1411,9 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void validateSettings() {
|
void validateSettings() {
|
||||||
|
LOG(logWARNING, ("Not validating dac settings temporarily"));
|
||||||
|
return;
|
||||||
|
|
||||||
// if any special dac value is changed individually => undefined
|
// if any special dac value is changed individually => undefined
|
||||||
const int specialDacs[NSPECIALDACS] = SPECIALDACINDEX;
|
const int specialDacs[NSPECIALDACS] = SPECIALDACINDEX;
|
||||||
int *specialDacValues[] = {defaultDacValue_standard, defaultDacValue_fast,
|
int *specialDacValues[] = {defaultDacValue_standard, defaultDacValue_fast,
|
||||||
@ -1603,7 +1606,7 @@ void setTiming(enum timingMode arg) {
|
|||||||
|
|
||||||
int master = 0;
|
int master = 0;
|
||||||
isMaster(&master);
|
isMaster(&master);
|
||||||
if (master && arg == AUTO_TIMING)
|
if (!master && arg == AUTO_TIMING)
|
||||||
arg = TRIGGER_EXPOSURE;
|
arg = TRIGGER_EXPOSURE;
|
||||||
|
|
||||||
uint32_t addr = CONFIG_REG;
|
uint32_t addr = CONFIG_REG;
|
||||||
@ -1689,6 +1692,55 @@ void setInitialExtSignals() {
|
|||||||
DOUTIF_RISING_LNGTH_PORT_1_MSK));
|
DOUTIF_RISING_LNGTH_PORT_1_MSK));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int setGainCaps(int caps) {
|
||||||
|
LOG(logINFO, ("Setting gain caps to: %u\n", caps));
|
||||||
|
int csr = M3SetGainCaps(caps);
|
||||||
|
return setChipStatusRegister(csr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int setInterpolation(int enable) {
|
||||||
|
LOG(logINFO,
|
||||||
|
("%s Interpolation\n", enable == 0 ? "Disabling" : "Enabling"));
|
||||||
|
if (enable) {
|
||||||
|
setCounterMask(MAX_COUNTER_MSK);
|
||||||
|
if (getCounterMask() != MAX_COUNTER_MSK) {
|
||||||
|
LOG(logERROR,
|
||||||
|
("Could not set interpolation. Could not enable all counters"));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
LOG(logINFO, ("\tEnabled all counters\n"));
|
||||||
|
}
|
||||||
|
int csr = M3SetInterpolation(enable);
|
||||||
|
return setChipStatusRegister(csr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int setPumpProbe(int enable) {
|
||||||
|
LOG(logINFO, ("%s Pump Probe\n", enable == 0 ? "Disabling" : "Enabling"));
|
||||||
|
int csr = M3SetPumpProbe(enable);
|
||||||
|
return setChipStatusRegister(csr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int setDigitalPulsing(int enable) {
|
||||||
|
LOG(logINFO,
|
||||||
|
("%s Digital Pulsing\n", enable == 0 ? "Disabling" : "Enabling"));
|
||||||
|
int csr = M3SetDigitalPulsing(enable);
|
||||||
|
return setChipStatusRegister(csr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int setAnalogPulsing(int enable) {
|
||||||
|
LOG(logINFO,
|
||||||
|
("%s Analog Pulsing\n", enable == 0 ? "Disabling" : "Enabling"));
|
||||||
|
int csr = M3SetAnalogPulsing(enable);
|
||||||
|
return setChipStatusRegister(csr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int setNegativePolarity(int enable) {
|
||||||
|
LOG(logINFO,
|
||||||
|
("%s Negative Polarity\n", enable == 0 ? "Disabling" : "Enabling"));
|
||||||
|
int csr = M3SetNegativePolarity(enable);
|
||||||
|
return setChipStatusRegister(csr);
|
||||||
|
}
|
||||||
|
|
||||||
void setExtSignal(int signalIndex, enum externalSignalFlag mode) {
|
void setExtSignal(int signalIndex, enum externalSignalFlag mode) {
|
||||||
LOG(logDEBUG1, ("Setting signal flag[%d] to %d\n", signalIndex, mode));
|
LOG(logDEBUG1, ("Setting signal flag[%d] to %d\n", signalIndex, mode));
|
||||||
|
|
||||||
@ -1892,7 +1944,7 @@ int setDetectorPosition(int pos[]) {
|
|||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
// row
|
// row
|
||||||
value = detPos[X];
|
value = detPos[Y];
|
||||||
bus_w(addr, (bus_r(addr) & ~COORD_ROW_MSK) |
|
bus_w(addr, (bus_r(addr) & ~COORD_ROW_MSK) |
|
||||||
((value << COORD_ROW_OFST) & COORD_ROW_MSK));
|
((value << COORD_ROW_OFST) & COORD_ROW_MSK));
|
||||||
valueRead = ((bus_r(addr) & COORD_ROW_MSK) >> COORD_ROW_OFST);
|
valueRead = ((bus_r(addr) & COORD_ROW_MSK) >> COORD_ROW_OFST);
|
||||||
@ -1903,7 +1955,7 @@ int setDetectorPosition(int pos[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// col
|
// col
|
||||||
value = detPos[Y];
|
value = detPos[X];
|
||||||
bus_w(addr, (bus_r(addr) & ~COORD_COL_MSK) |
|
bus_w(addr, (bus_r(addr) & ~COORD_COL_MSK) |
|
||||||
((value << COORD_COL_OFST) & COORD_COL_MSK));
|
((value << COORD_COL_OFST) & COORD_COL_MSK));
|
||||||
valueRead = ((bus_r(addr) & COORD_COL_MSK) >> COORD_COL_OFST);
|
valueRead = ((bus_r(addr) & COORD_COL_MSK) >> COORD_COL_OFST);
|
||||||
@ -1914,7 +1966,8 @@ int setDetectorPosition(int pos[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
LOG(logINFO, ("\tPosition set to [%d, %d]\n", detPos[X], detPos[Y]));
|
LOG(logINFO,
|
||||||
|
("\tPosition set to [%d, %d] #(col, row)\n", detPos[X], detPos[Y]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -2336,8 +2389,8 @@ void *start_timer(void *arg) {
|
|||||||
header->frameNumber = virtual_currentFrameNumber;
|
header->frameNumber = virtual_currentFrameNumber;
|
||||||
header->packetNumber = i;
|
header->packetNumber = i;
|
||||||
header->modId = virtual_moduleid;
|
header->modId = virtual_moduleid;
|
||||||
header->row = detPos[X];
|
header->row = detPos[Y];
|
||||||
header->column = detPos[Y];
|
header->column = detPos[X];
|
||||||
|
|
||||||
// fill data
|
// fill data
|
||||||
memcpy(packetData + sizeof(sls_detector_header),
|
memcpy(packetData + sizeof(sls_detector_header),
|
||||||
@ -2623,21 +2676,3 @@ int setChipStatusRegister(int csr) {
|
|||||||
|
|
||||||
return iret;
|
return iret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int setGainCaps(int caps) {
|
|
||||||
LOG(logINFO, ("Setting gain caps to: %u\n", caps));
|
|
||||||
// Update only gain caps, leave the rest of the CSR unchanged
|
|
||||||
int csr = getChipStatusRegister();
|
|
||||||
csr &= ~GAIN_MASK;
|
|
||||||
|
|
||||||
caps = gainCapsToCsr(caps);
|
|
||||||
// caps &= GAIN_MASK;
|
|
||||||
csr |= caps;
|
|
||||||
return setChipStatusRegister(csr);
|
|
||||||
}
|
|
||||||
|
|
||||||
int getGainCaps() {
|
|
||||||
int csr = getChipStatusRegister();
|
|
||||||
int caps = csrToGainCaps(csr);
|
|
||||||
return caps;
|
|
||||||
}
|
|
||||||
|
@ -66,3 +66,5 @@ int moveBinaryFile(char *mess, char *dest, char *src, char *errorPrefix);
|
|||||||
|
|
||||||
int createEmptyFile(char *mess, char *fname, char *errorPrefix);
|
int createEmptyFile(char *mess, char *fname, char *errorPrefix);
|
||||||
int deleteFile(char *mess, char *fname, char *errorPrefix);
|
int deleteFile(char *mess, char *fname, char *errorPrefix);
|
||||||
|
|
||||||
|
int deleteOldServers(char *mess, char *newServerPath, char *errorPrefix);
|
||||||
|
@ -391,9 +391,13 @@ void setTiming(enum timingMode arg);
|
|||||||
enum timingMode getTiming();
|
enum timingMode getTiming();
|
||||||
#ifdef MYTHEN3D
|
#ifdef MYTHEN3D
|
||||||
void setInitialExtSignals();
|
void setInitialExtSignals();
|
||||||
int setGainCaps(int caps);
|
|
||||||
int getGainCaps();
|
|
||||||
int setChipStatusRegister(int csr);
|
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);
|
int setDACS(int *dacs);
|
||||||
#endif
|
#endif
|
||||||
#if defined(GOTTHARDD) || defined(MYTHEN3D)
|
#if defined(GOTTHARDD) || defined(MYTHEN3D)
|
||||||
|
@ -132,7 +132,6 @@ int check_version(int);
|
|||||||
int software_trigger(int);
|
int software_trigger(int);
|
||||||
int led(int);
|
int led(int);
|
||||||
int digital_io_delay(int);
|
int digital_io_delay(int);
|
||||||
int copy_detector_server(int);
|
|
||||||
int reboot_controller(int);
|
int reboot_controller(int);
|
||||||
int set_adc_enable_mask(int);
|
int set_adc_enable_mask(int);
|
||||||
int get_adc_enable_mask(int);
|
int get_adc_enable_mask(int);
|
||||||
@ -294,3 +293,13 @@ int get_update_mode(int);
|
|||||||
int set_update_mode(int);
|
int set_update_mode(int);
|
||||||
int get_top(int);
|
int get_top(int);
|
||||||
int set_top(int);
|
int set_top(int);
|
||||||
|
int get_polarity(int);
|
||||||
|
int set_polarity(int);
|
||||||
|
int get_interpolation(int);
|
||||||
|
int set_interpolation(int);
|
||||||
|
int get_pump_probe(int);
|
||||||
|
int set_pump_probe(int);
|
||||||
|
int get_analog_pulsing(int);
|
||||||
|
int set_analog_pulsing(int);
|
||||||
|
int get_digital_pulsing(int);
|
||||||
|
int set_digital_pulsing(int);
|
||||||
|
@ -50,6 +50,10 @@ int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int getAbsPath(char *buf, size_t bufSize, char *fname) {
|
int getAbsPath(char *buf, size_t bufSize, char *fname) {
|
||||||
|
if (fname[0] == '/') {
|
||||||
|
strcpy(buf, fname);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
// get path of current binary
|
// get path of current binary
|
||||||
char path[bufSize];
|
char path[bufSize];
|
||||||
memset(path, 0, bufSize);
|
memset(path, 0, bufSize);
|
||||||
@ -60,10 +64,14 @@ int getAbsPath(char *buf, size_t bufSize, char *fname) {
|
|||||||
}
|
}
|
||||||
path[len] = '\0';
|
path[len] = '\0';
|
||||||
|
|
||||||
// get dir path and attach config file name
|
// get dir path and attach file name
|
||||||
char *dir = dirname(path);
|
char *dir = dirname(path);
|
||||||
memset(buf, 0, bufSize);
|
memset(buf, 0, bufSize);
|
||||||
|
if (!strcmp(dir, "/")) {
|
||||||
|
sprintf(buf, "/%s", fname);
|
||||||
|
} else {
|
||||||
sprintf(buf, "%s/%s", dir, fname);
|
sprintf(buf, "%s/%s", dir, fname);
|
||||||
|
}
|
||||||
LOG(logDEBUG1, ("full path for %s: %s\n", fname, buf));
|
LOG(logDEBUG1, ("full path for %s: %s\n", fname, buf));
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -466,7 +474,7 @@ int setupDetectorServer(char *mess, char *sname) {
|
|||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFO, ("\tSymbolic link created\n"));
|
LOG(logINFO, ("\tSymbolic link created %s -> %s\n", linkname, sname));
|
||||||
|
|
||||||
// blackfin boards (respawn) (only kept for backwards compatibility)
|
// blackfin boards (respawn) (only kept for backwards compatibility)
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
@ -485,7 +493,7 @@ int setupDetectorServer(char *mess, char *sname) {
|
|||||||
|
|
||||||
// add new link name to /etc/inittab
|
// add new link name to /etc/inittab
|
||||||
if (snprintf(cmd, MAX_STR_LENGTH,
|
if (snprintf(cmd, MAX_STR_LENGTH,
|
||||||
"echo 'ttyS0::respawn:/./%s' >> /etc/inittab",
|
"echo 'ttyS0::respawn:%s' >> /etc/inittab",
|
||||||
linkname) >= MAX_STR_LENGTH) {
|
linkname) >= MAX_STR_LENGTH) {
|
||||||
strcpy(mess, "Could not copy detector server. Command "
|
strcpy(mess, "Could not copy detector server. Command "
|
||||||
"to add new server for spawning is too long\n");
|
"to add new server for spawning is too long\n");
|
||||||
@ -670,3 +678,26 @@ int deleteFile(char *mess, char *fname, char *errorPrefix) {
|
|||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int deleteOldServers(char *mess, char *newServerPath, char *errorPrefix) {
|
||||||
|
LOG(logINFO, ("\tChecking if current binary is to be deleted ...\n"))
|
||||||
|
// get path of current binary (get file name if link)
|
||||||
|
char currentBinary[MAX_STR_LENGTH];
|
||||||
|
memset(currentBinary, 0, MAX_STR_LENGTH);
|
||||||
|
ssize_t len = readlink("/proc/self/exe", currentBinary, MAX_STR_LENGTH - 1);
|
||||||
|
if (len < 0) {
|
||||||
|
LOG(logWARNING, ("(%s): Could not delete old servers. Could not "
|
||||||
|
"readlink current binary\n",
|
||||||
|
errorPrefix));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
currentBinary[len] = '\0';
|
||||||
|
LOG(logDEBUG1, ("Current binary:%s\n", currentBinary));
|
||||||
|
|
||||||
|
// delete file
|
||||||
|
if (deleteFile(mess, currentBinary, errorPrefix) == FAIL) {
|
||||||
|
LOG(logWARNING, ("(%s). Could not delete old servers\n", errorPrefix));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
@ -39,6 +39,7 @@ extern int masterCommandLine;
|
|||||||
#ifdef EIGERD
|
#ifdef EIGERD
|
||||||
extern int topCommandLine;
|
extern int topCommandLine;
|
||||||
#endif
|
#endif
|
||||||
|
int portno = DEFAULT_PORTNO;
|
||||||
|
|
||||||
void error(char *msg) { perror(msg); }
|
void error(char *msg) { perror(msg); }
|
||||||
|
|
||||||
@ -50,7 +51,6 @@ void sigInterruptHandler(int p) {
|
|||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
// options
|
// options
|
||||||
int portno = DEFAULT_PORTNO;
|
|
||||||
isControlServer = 1;
|
isControlServer = 1;
|
||||||
debugflag = 0;
|
debugflag = 0;
|
||||||
updateFlag = 0;
|
updateFlag = 0;
|
||||||
|
@ -62,8 +62,8 @@ int firstUDPDestination = 0;
|
|||||||
|
|
||||||
int configured = FAIL;
|
int configured = FAIL;
|
||||||
char configureMessage[MAX_STR_LENGTH] = "udp parameters not configured yet";
|
char configureMessage[MAX_STR_LENGTH] = "udp parameters not configured yet";
|
||||||
int maxydet = -1;
|
int maxYMods = -1;
|
||||||
int detectorId = -1;
|
int moduleIndex = -1;
|
||||||
|
|
||||||
// Local variables
|
// Local variables
|
||||||
int (*flist[NUM_DET_FUNCTIONS])(int);
|
int (*flist[NUM_DET_FUNCTIONS])(int);
|
||||||
@ -81,28 +81,14 @@ char scanErrMessage[MAX_STR_LENGTH] = "";
|
|||||||
/* initialization functions */
|
/* initialization functions */
|
||||||
|
|
||||||
int updateModeAllowedFunction(int file_des) {
|
int updateModeAllowedFunction(int file_des) {
|
||||||
enum detFuncs allowedFuncs[] = {F_EXEC_COMMAND,
|
enum detFuncs allowedFuncs[] = {
|
||||||
F_GET_DETECTOR_TYPE,
|
F_EXEC_COMMAND, F_GET_DETECTOR_TYPE, F_GET_FIRMWARE_VERSION,
|
||||||
F_GET_FIRMWARE_VERSION,
|
F_GET_SERVER_VERSION, F_GET_SERIAL_NUMBER, F_WRITE_REGISTER,
|
||||||
F_GET_SERVER_VERSION,
|
F_READ_REGISTER, F_LOCK_SERVER, F_GET_LAST_CLIENT_IP,
|
||||||
F_GET_SERIAL_NUMBER,
|
F_PROGRAM_FPGA, F_RESET_FPGA, F_CHECK_VERSION,
|
||||||
F_WRITE_REGISTER,
|
F_REBOOT_CONTROLLER, F_GET_KERNEL_VERSION, F_UPDATE_KERNEL,
|
||||||
F_READ_REGISTER,
|
F_UPDATE_DETECTOR_SERVER, F_GET_UPDATE_MODE, F_SET_UPDATE_MODE,
|
||||||
F_LOCK_SERVER,
|
F_GET_NUM_CHANNELS, F_GET_NUM_INTERFACES, F_ACTIVATE};
|
||||||
F_GET_LAST_CLIENT_IP,
|
|
||||||
F_PROGRAM_FPGA,
|
|
||||||
F_RESET_FPGA,
|
|
||||||
F_CHECK_VERSION,
|
|
||||||
F_COPY_DET_SERVER,
|
|
||||||
F_REBOOT_CONTROLLER,
|
|
||||||
F_GET_KERNEL_VERSION,
|
|
||||||
F_UPDATE_KERNEL,
|
|
||||||
F_UPDATE_DETECTOR_SERVER,
|
|
||||||
F_GET_UPDATE_MODE,
|
|
||||||
F_SET_UPDATE_MODE,
|
|
||||||
F_GET_NUM_CHANNELS,
|
|
||||||
F_GET_NUM_INTERFACES,
|
|
||||||
F_ACTIVATE};
|
|
||||||
size_t allowedFuncsSize = sizeof(allowedFuncs) / sizeof(enum detFuncs);
|
size_t allowedFuncsSize = sizeof(allowedFuncs) / sizeof(enum detFuncs);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < allowedFuncsSize; ++i) {
|
for (unsigned int i = 0; i < allowedFuncsSize; ++i) {
|
||||||
@ -130,6 +116,7 @@ void init_detector() {
|
|||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
LOG(logINFO, ("This is a VIRTUAL detector\n"));
|
LOG(logINFO, ("This is a VIRTUAL detector\n"));
|
||||||
udpDetails[0].srcip = LOCALHOSTIP_INT;
|
udpDetails[0].srcip = LOCALHOSTIP_INT;
|
||||||
|
udpDetails[0].srcip2 = LOCALHOSTIP_INT;
|
||||||
#endif
|
#endif
|
||||||
udpDetails[0].srcport = DEFAULT_UDP_SRC_PORTNO;
|
udpDetails[0].srcport = DEFAULT_UDP_SRC_PORTNO;
|
||||||
udpDetails[0].dstport = DEFAULT_UDP_DST_PORTNO;
|
udpDetails[0].dstport = DEFAULT_UDP_DST_PORTNO;
|
||||||
@ -322,7 +309,6 @@ void function_table() {
|
|||||||
flist[F_SOFTWARE_TRIGGER] = &software_trigger;
|
flist[F_SOFTWARE_TRIGGER] = &software_trigger;
|
||||||
flist[F_LED] = &led;
|
flist[F_LED] = &led;
|
||||||
flist[F_DIGITAL_IO_DELAY] = &digital_io_delay;
|
flist[F_DIGITAL_IO_DELAY] = &digital_io_delay;
|
||||||
flist[F_COPY_DET_SERVER] = ©_detector_server;
|
|
||||||
flist[F_REBOOT_CONTROLLER] = &reboot_controller;
|
flist[F_REBOOT_CONTROLLER] = &reboot_controller;
|
||||||
flist[F_SET_ADC_ENABLE_MASK] = &set_adc_enable_mask;
|
flist[F_SET_ADC_ENABLE_MASK] = &set_adc_enable_mask;
|
||||||
flist[F_GET_ADC_ENABLE_MASK] = &get_adc_enable_mask;
|
flist[F_GET_ADC_ENABLE_MASK] = &get_adc_enable_mask;
|
||||||
@ -472,6 +458,16 @@ void function_table() {
|
|||||||
flist[F_SET_MASTER] = &set_master;
|
flist[F_SET_MASTER] = &set_master;
|
||||||
flist[F_GET_TOP] = &get_top;
|
flist[F_GET_TOP] = &get_top;
|
||||||
flist[F_SET_TOP] = &set_top;
|
flist[F_SET_TOP] = &set_top;
|
||||||
|
flist[F_GET_POLARITY] = &get_polarity;
|
||||||
|
flist[F_SET_POLARITY] = &set_polarity;
|
||||||
|
flist[F_GET_INTERPOLATION] = &get_interpolation;
|
||||||
|
flist[F_SET_INTERPOLATION] = &set_interpolation;
|
||||||
|
flist[F_GET_PUMP_PROBE] = &get_pump_probe;
|
||||||
|
flist[F_SET_PUMP_PROBE] = &set_pump_probe;
|
||||||
|
flist[F_GET_ANALOG_PULSING] = &get_analog_pulsing;
|
||||||
|
flist[F_SET_ANALOG_PULSING] = &set_analog_pulsing;
|
||||||
|
flist[F_GET_DIGITAL_PULSING] = &get_digital_pulsing;
|
||||||
|
flist[F_SET_DIGITAL_PULSING] = &set_digital_pulsing;
|
||||||
|
|
||||||
// check
|
// check
|
||||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||||
@ -4143,65 +4139,15 @@ int digital_io_delay(int file_des) {
|
|||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int copy_detector_server(int file_des) {
|
|
||||||
ret = OK;
|
|
||||||
memset(mess, 0, sizeof(mess));
|
|
||||||
char args[2][MAX_STR_LENGTH];
|
|
||||||
char retvals[MAX_STR_LENGTH] = {0};
|
|
||||||
|
|
||||||
memset(args, 0, sizeof(args));
|
|
||||||
memset(retvals, 0, sizeof(retvals));
|
|
||||||
|
|
||||||
if (receiveData(file_des, args, sizeof(args), OTHER) < 0)
|
|
||||||
return printSocketReadError();
|
|
||||||
|
|
||||||
#ifdef VIRTUAL
|
|
||||||
functionNotImplemented();
|
|
||||||
#else
|
|
||||||
|
|
||||||
// only set
|
|
||||||
if (Server_VerifyLock() == OK) {
|
|
||||||
char *sname = args[0];
|
|
||||||
char *hostname = args[1];
|
|
||||||
LOG(logINFOBLUE, ("Copying server %s from host %s\n", sname, hostname));
|
|
||||||
char cmd[MAX_STR_LENGTH] = {0};
|
|
||||||
|
|
||||||
#ifdef BLACKFIN_DEFINED
|
|
||||||
// check update is allowed (Non Amd OR AMD + current kernel)
|
|
||||||
ret = allowUpdate(mess, "copy detector server");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// tftp server
|
|
||||||
if (ret == OK) {
|
|
||||||
if (snprintf(cmd, MAX_STR_LENGTH, "tftp %s -r %s -g", hostname,
|
|
||||||
sname) >= MAX_STR_LENGTH) {
|
|
||||||
ret = FAIL;
|
|
||||||
strcpy(mess, "Could not copy detector server. Command to copy "
|
|
||||||
"server too long\n");
|
|
||||||
LOG(logERROR, (mess));
|
|
||||||
} else if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
|
||||||
ret = FAIL;
|
|
||||||
snprintf(mess, MAX_STR_LENGTH,
|
|
||||||
"Could not copy detector server (tftp). %s\n",
|
|
||||||
retvals);
|
|
||||||
// LOG(logERROR, (mess)); already printed in executecommand
|
|
||||||
} else {
|
|
||||||
LOG(logINFO, ("\tServer copied\n"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret == OK) {
|
|
||||||
ret = setupDetectorServer(mess, sname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
|
|
||||||
}
|
|
||||||
|
|
||||||
int reboot_controller(int file_des) {
|
int reboot_controller(int file_des) {
|
||||||
ret = OK;
|
ret = OK;
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
|
|
||||||
|
#ifdef EIGERD
|
||||||
|
functionNotImplemented();
|
||||||
|
#elif VIRTUAL
|
||||||
|
ret = GOODBYE;
|
||||||
|
#elif defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||||
if (getHardwareVersionNumber() == 0) {
|
if (getHardwareVersionNumber() == 0) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
strcpy(mess, "Old board version, reboot by yourself please!\n");
|
strcpy(mess, "Old board version, reboot by yourself please!\n");
|
||||||
@ -4209,20 +4155,11 @@ int reboot_controller(int file_des) {
|
|||||||
Server_SendResult(file_des, INT32, NULL, 0);
|
Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
return GOODBYE;
|
return GOODBYE;
|
||||||
}
|
}
|
||||||
#ifdef VIRTUAL
|
ret = REBOOT;
|
||||||
ret = GOODBYE;
|
|
||||||
#else
|
#else
|
||||||
ret = REBOOT;
|
ret = REBOOT;
|
||||||
#endif
|
#endif
|
||||||
#elif EIGERD
|
|
||||||
functionNotImplemented();
|
|
||||||
#else
|
|
||||||
#ifdef VIRTUAL
|
|
||||||
ret = GOODBYE;
|
|
||||||
#else
|
|
||||||
ret = REBOOT;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
Server_SendResult(file_des, INT32, NULL, 0);
|
Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -4751,7 +4688,7 @@ int get_read_n_rows(int file_des) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void calculate_and_set_position() {
|
void calculate_and_set_position() {
|
||||||
if (maxydet == -1 || detectorId == -1) {
|
if (maxYMods == -1 || moduleIndex == -1) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess,
|
sprintf(mess,
|
||||||
"Could not set detector position (did not get multi size).\n");
|
"Could not set detector position (did not get multi size).\n");
|
||||||
@ -4760,21 +4697,20 @@ void calculate_and_set_position() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// calculating new position
|
// calculating new position
|
||||||
int modulePorts[2] = {1, 1};
|
int pos[2] = {0, 0};
|
||||||
|
|
||||||
|
int portGeometry[2] = {1, 1};
|
||||||
// position does change for eiger and jungfrau (2 interfaces)
|
// position does change for eiger and jungfrau (2 interfaces)
|
||||||
#if defined(EIGERD)
|
#if defined(EIGERD)
|
||||||
modulePorts[1] = getNumberofUDPInterfaces(); // horz
|
portGeometry[X] = getNumberofUDPInterfaces(); // horz
|
||||||
#elif defined(JUNGFRAUD)
|
#elif defined(JUNGFRAUD)
|
||||||
modulePorts[0] = getNumberofUDPInterfaces(); // vert
|
portGeometry[Y] = getNumberofUDPInterfaces(); // vert
|
||||||
#endif
|
#endif
|
||||||
int maxy = maxydet * modulePorts[0];
|
LOG(logDEBUG1, ("moduleIndex:%d maxymods:%d portGeo.x:%d portgeo.y:%d\n",
|
||||||
int pos[2] = {0, 0};
|
moduleIndex, maxYMods, portGeometry[X], portGeometry[Y]));
|
||||||
// row
|
pos[Y] = (moduleIndex % maxYMods) * portGeometry[Y];
|
||||||
pos[0] = (detectorId % maxy);
|
pos[X] = (moduleIndex / maxYMods) * portGeometry[X];
|
||||||
// col for horiz. udp ports
|
LOG(logINFO, ("Setting Positions (%d,%d) #(col, row)\n", pos[X], pos[Y]));
|
||||||
pos[1] = (detectorId / maxy) * modulePorts[1];
|
|
||||||
|
|
||||||
LOG(logDEBUG, ("Setting Positions (%d,%d)\n", pos[0], pos[1]));
|
|
||||||
if (setDetectorPosition(pos) == FAIL) {
|
if (setDetectorPosition(pos) == FAIL) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess, "Could not set detector position.\n");
|
sprintf(mess, "Could not set detector position.\n");
|
||||||
@ -4786,8 +4722,8 @@ void calculate_and_set_position() {
|
|||||||
if (udpDetails[0].srcmac == 0) {
|
if (udpDetails[0].srcmac == 0) {
|
||||||
char dmac[MAC_ADDRESS_SIZE];
|
char dmac[MAC_ADDRESS_SIZE];
|
||||||
memset(dmac, 0, MAC_ADDRESS_SIZE);
|
memset(dmac, 0, MAC_ADDRESS_SIZE);
|
||||||
sprintf(dmac, "aa:bb:cc:dd:%02x:%02x", pos[0] & 0xFF,
|
sprintf(dmac, "aa:bb:cc:dd:%02x:%02x", pos[X] & 0xFF,
|
||||||
pos[1] & 0xFF);
|
pos[Y] & 0xFF);
|
||||||
LOG(logINFO, ("Udp source mac address created: %s\n", dmac));
|
LOG(logINFO, ("Udp source mac address created: %s\n", dmac));
|
||||||
unsigned char a[6];
|
unsigned char a[6];
|
||||||
sscanf(dmac, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &a[0], &a[1], &a[2],
|
sscanf(dmac, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &a[0], &a[1], &a[2],
|
||||||
@ -4806,8 +4742,8 @@ void calculate_and_set_position() {
|
|||||||
if (udpDetails[0].srcmac2 == 0) {
|
if (udpDetails[0].srcmac2 == 0) {
|
||||||
char dmac2[MAC_ADDRESS_SIZE];
|
char dmac2[MAC_ADDRESS_SIZE];
|
||||||
memset(dmac2, 0, MAC_ADDRESS_SIZE);
|
memset(dmac2, 0, MAC_ADDRESS_SIZE);
|
||||||
sprintf(dmac2, "aa:bb:cc:dd:%02x:%02x", (pos[0] + 1) & 0xFF,
|
sprintf(dmac2, "aa:bb:cc:dd:%02x:%02x", (pos[X] + 1) & 0xFF,
|
||||||
pos[1] & 0xFF);
|
pos[Y] & 0xFF);
|
||||||
LOG(logINFO, ("Udp source mac address2 created: %s\n", dmac2));
|
LOG(logINFO, ("Udp source mac address2 created: %s\n", dmac2));
|
||||||
unsigned char a[6];
|
unsigned char a[6];
|
||||||
sscanf(dmac2, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &a[0], &a[1],
|
sscanf(dmac2, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &a[0], &a[1],
|
||||||
@ -4835,15 +4771,16 @@ int set_detector_position(int file_des) {
|
|||||||
|
|
||||||
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
LOG(logINFO, ("Setting detector positions: [%u, %u]\n", args[0], args[1]));
|
LOG(logDEBUG, ("Setting detector positions: [maxy:%u, modIndex:%u]\n",
|
||||||
|
args[0], args[1]));
|
||||||
|
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
// if in update mode, there is no need to do this (also detector not set
|
// if in update mode, there is no need to do this (also detector not set
|
||||||
// up)
|
// up)
|
||||||
if (!updateFlag && check_detector_idle("configure mac") == OK) {
|
if (!updateFlag && check_detector_idle("configure mac") == OK) {
|
||||||
maxydet = args[0];
|
maxYMods = args[0];
|
||||||
detectorId = args[1];
|
moduleIndex = args[1];
|
||||||
calculate_and_set_position();
|
calculate_and_set_position();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8297,33 +8234,35 @@ int set_gain_caps(int file_des) {
|
|||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
LOG(logDEBUG1, ("Setting gain caps to: %u\n", arg));
|
LOG(logDEBUG1, ("Setting gain caps to: %u\n", arg));
|
||||||
|
|
||||||
int retval = -1;
|
|
||||||
|
|
||||||
#ifndef MYTHEN3D
|
#ifndef MYTHEN3D
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
#else
|
#else
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
setGainCaps(arg);
|
ret = setGainCaps(arg);
|
||||||
retval = getChipStatusRegister(); // TODO! fix
|
if (ret == FAIL) {
|
||||||
|
strcpy(mess, "Could not set gain caps.\n");
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
} else {
|
||||||
|
int retval = getGainCaps();
|
||||||
|
validate(&ret, mess, (int)arg, (int)retval, "set gain caps", DEC);
|
||||||
LOG(logDEBUG1, ("gain caps retval: %u\n", retval));
|
LOG(logDEBUG1, ("gain caps retval: %u\n", retval));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_gain_caps(int file_des) {
|
int get_gain_caps(int file_des) {
|
||||||
ret = OK;
|
ret = OK;
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
LOG(logINFO, ("Getting gain caps\n"));
|
LOG(logDEBUG1, ("Getting gain caps\n"));
|
||||||
|
|
||||||
#ifndef MYTHEN3D
|
#ifndef MYTHEN3D
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
#else
|
#else
|
||||||
if (Server_VerifyLock() == OK) {
|
|
||||||
retval = getGainCaps();
|
retval = getGainCaps();
|
||||||
LOG(logDEBUG1, ("Gain caps: %u\n", retval));
|
LOG(logDEBUG1, ("Gain caps: %u\n", retval));
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
@ -9449,10 +9388,18 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
|
|||||||
if (receiveData(file_des, &forceDeleteNormalFile,
|
if (receiveData(file_des, &forceDeleteNormalFile,
|
||||||
sizeof(forceDeleteNormalFile), INT32) < 0)
|
sizeof(forceDeleteNormalFile), INT32) < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
LOG(logINFO,
|
LOG(logINFO, ("\tForce Delete Normal File flag? %s\n",
|
||||||
("\tForce Delete Normal File flag? %s\n", (forceDeleteNormalFile ? "Y" : "N")));
|
(forceDeleteNormalFile ? "Y" : "N")));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ensure the name is not the same as the linked name
|
||||||
|
if (!strcmp(serverName, LINKED_SERVER_NAME)) {
|
||||||
|
ret = FAIL;
|
||||||
|
strcpy(mess, "Server name is the same as the symbolic link. Please "
|
||||||
|
"use a different server name\n");
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
}
|
||||||
|
|
||||||
// in same folder as current process (will also work for virtual then
|
// in same folder as current process (will also work for virtual then
|
||||||
// with write permissions)
|
// with write permissions)
|
||||||
{
|
{
|
||||||
@ -9477,7 +9424,8 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
|
|||||||
checksum, serverName);
|
checksum, serverName);
|
||||||
#else
|
#else
|
||||||
receive_program_via_blackfin(file_des, index, functionType,
|
receive_program_via_blackfin(file_des, index, functionType,
|
||||||
filesize, checksum, serverName, forceDeleteNormalFile);
|
filesize, checksum, serverName,
|
||||||
|
forceDeleteNormalFile);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9493,7 +9441,8 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
|
|||||||
|
|
||||||
void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
|
void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
|
||||||
char *functionType, uint64_t filesize,
|
char *functionType, uint64_t filesize,
|
||||||
char *checksum, char *serverName, int forceDeleteNormalFile) {
|
char *checksum, char *serverName,
|
||||||
|
int forceDeleteNormalFile) {
|
||||||
|
|
||||||
#if !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && \
|
#if !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && \
|
||||||
!defined(GOTTHARDD)
|
!defined(GOTTHARDD)
|
||||||
@ -9595,6 +9544,8 @@ void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
|
|||||||
totalsize, forceDeleteNormalFile);
|
totalsize, forceDeleteNormalFile);
|
||||||
break;
|
break;
|
||||||
case PROGRAM_SERVER:
|
case PROGRAM_SERVER:
|
||||||
|
// a fail here is not a show stopper (just for memory)
|
||||||
|
deleteOldServers(mess, serverName, "update detector server");
|
||||||
ret = moveBinaryFile(mess, serverName, TEMP_PROG_FILE_NAME,
|
ret = moveBinaryFile(mess, serverName, TEMP_PROG_FILE_NAME,
|
||||||
"update detector server");
|
"update detector server");
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
@ -9822,3 +9773,245 @@ int set_top(int file_des) {
|
|||||||
#endif
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_polarity(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
enum polarity retval = POSITIVE;
|
||||||
|
|
||||||
|
LOG(logDEBUG1, ("Getting negativepolarity\n"));
|
||||||
|
|
||||||
|
#ifndef MYTHEN3D
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// get only
|
||||||
|
retval = getNegativePolarity() ? NEGATIVE : POSITIVE;
|
||||||
|
LOG(logDEBUG1, ("negative polarity retval: %u\n", retval));
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
|
}
|
||||||
|
|
||||||
|
int set_polarity(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
enum polarity arg = POSITIVE;
|
||||||
|
|
||||||
|
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
LOG(logDEBUG1, ("Setting negative polarity: %u\n", (int)arg));
|
||||||
|
|
||||||
|
#ifndef MYTHEN3D
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// only set
|
||||||
|
if (Server_VerifyLock() == OK) {
|
||||||
|
switch (arg) {
|
||||||
|
case POSITIVE:
|
||||||
|
ret = setNegativePolarity(0);
|
||||||
|
break;
|
||||||
|
case NEGATIVE:
|
||||||
|
ret = setNegativePolarity(1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
modeNotImplemented("Polarity index", (int)arg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ret == FAIL) {
|
||||||
|
sprintf(mess, "Could not set polarity\n");
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
} else {
|
||||||
|
enum polarity retval = getNegativePolarity() ? NEGATIVE : POSITIVE;
|
||||||
|
validate(&ret, mess, (int)arg, (int)retval, "set polarity", DEC);
|
||||||
|
LOG(logDEBUG1, ("negative polarity retval: %u\n", retval));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_interpolation(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int retval = -1;
|
||||||
|
|
||||||
|
LOG(logDEBUG1, ("Getting interpolation\n"));
|
||||||
|
|
||||||
|
#ifndef MYTHEN3D
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// get only
|
||||||
|
retval = getInterpolation();
|
||||||
|
LOG(logDEBUG1, ("interpolation retval: %u\n", retval));
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
|
}
|
||||||
|
|
||||||
|
int set_interpolation(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int arg = 0;
|
||||||
|
|
||||||
|
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
LOG(logINFO, ("Setting interpolation: %u\n", arg));
|
||||||
|
|
||||||
|
#ifndef MYTHEN3D
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// only set
|
||||||
|
if (Server_VerifyLock() == OK) {
|
||||||
|
ret = setInterpolation(arg);
|
||||||
|
if (ret == FAIL) {
|
||||||
|
if (arg)
|
||||||
|
sprintf(mess, "Could not set interpolation or enable all "
|
||||||
|
"counters for it.\n");
|
||||||
|
else
|
||||||
|
sprintf(mess, "Could not set interpolation\n");
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
} else {
|
||||||
|
int retval = getInterpolation();
|
||||||
|
validate(&ret, mess, (int)arg, (int)retval, "set interpolation",
|
||||||
|
DEC);
|
||||||
|
LOG(logDEBUG1, ("interpolation retval: %u\n", retval));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_pump_probe(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int retval = -1;
|
||||||
|
|
||||||
|
LOG(logDEBUG1, ("Getting pump probe\n"));
|
||||||
|
|
||||||
|
#ifndef MYTHEN3D
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// get only
|
||||||
|
retval = getPumpProbe();
|
||||||
|
LOG(logDEBUG1, ("pump probe retval: %u\n", retval));
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
|
}
|
||||||
|
|
||||||
|
int set_pump_probe(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int arg = 0;
|
||||||
|
|
||||||
|
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
LOG(logINFO, ("Setting pump probe: %u\n", arg));
|
||||||
|
|
||||||
|
#ifndef MYTHEN3D
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// only set
|
||||||
|
if (Server_VerifyLock() == OK) {
|
||||||
|
ret = setPumpProbe(arg);
|
||||||
|
if (ret == FAIL) {
|
||||||
|
sprintf(mess, "Could not set pump probe\n");
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
} else {
|
||||||
|
int retval = getPumpProbe();
|
||||||
|
validate(&ret, mess, (int)arg, (int)retval, "set pump probe", DEC);
|
||||||
|
LOG(logDEBUG1, ("pump probe retval: %u\n", retval));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_analog_pulsing(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int retval = -1;
|
||||||
|
|
||||||
|
LOG(logDEBUG1, ("Getting analog pulsing\n"));
|
||||||
|
|
||||||
|
#ifndef MYTHEN3D
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// get only
|
||||||
|
retval = getAnalogPulsing();
|
||||||
|
LOG(logDEBUG1, ("analog pulsing retval: %u\n", retval));
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
|
}
|
||||||
|
|
||||||
|
int set_analog_pulsing(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int arg = 0;
|
||||||
|
|
||||||
|
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
LOG(logINFO, ("Setting analog pulsing: %u\n", arg));
|
||||||
|
|
||||||
|
#ifndef MYTHEN3D
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// only set
|
||||||
|
if (Server_VerifyLock() == OK) {
|
||||||
|
ret = setAnalogPulsing(arg);
|
||||||
|
if (ret == FAIL) {
|
||||||
|
sprintf(mess, "Could not set analog pulsing\n");
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
} else {
|
||||||
|
int retval = getAnalogPulsing();
|
||||||
|
validate(&ret, mess, (int)arg, (int)retval, "set analog pulsing",
|
||||||
|
DEC);
|
||||||
|
LOG(logDEBUG1, ("analog pulsing retval: %u\n", retval));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_digital_pulsing(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int retval = -1;
|
||||||
|
|
||||||
|
LOG(logDEBUG1, ("Getting digital pulsing\n"));
|
||||||
|
|
||||||
|
#ifndef MYTHEN3D
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// get only
|
||||||
|
retval = getDigitalPulsing();
|
||||||
|
LOG(logDEBUG1, ("digital pulsing retval: %u\n", retval));
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
|
}
|
||||||
|
|
||||||
|
int set_digital_pulsing(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int arg = 0;
|
||||||
|
|
||||||
|
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
LOG(logINFO, ("Setting digital pulsing: %u\n", arg));
|
||||||
|
|
||||||
|
#ifndef MYTHEN3D
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// only set
|
||||||
|
if (Server_VerifyLock() == OK) {
|
||||||
|
ret = setDigitalPulsing(arg);
|
||||||
|
if (ret == FAIL) {
|
||||||
|
sprintf(mess, "Could not set digital pulsing\n");
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
} else {
|
||||||
|
int retval = getDigitalPulsing();
|
||||||
|
validate(&ret, mess, (int)arg, (int)retval, "set digital pulsing",
|
||||||
|
DEC);
|
||||||
|
LOG(logDEBUG1, ("digital pulsing retval: %u\n", retval));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
}
|
@ -17,6 +17,8 @@ add_library(slsDetectorObject OBJECT
|
|||||||
target_include_directories(slsDetectorObject PUBLIC
|
target_include_directories(slsDetectorObject PUBLIC
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||||
|
PRIVATE
|
||||||
|
${SLS_INTERNAL_RAPIDJSON_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(slsDetectorObject
|
target_link_libraries(slsDetectorObject
|
||||||
|
@ -1472,6 +1472,36 @@ class Detector {
|
|||||||
|
|
||||||
Result<int> getGainCaps(Positions pos = {});
|
Result<int> getGainCaps(Positions pos = {});
|
||||||
|
|
||||||
|
/** [Mythen3] */
|
||||||
|
Result<defs::polarity> getPolarity(Positions pos = {}) const;
|
||||||
|
|
||||||
|
/** [Mythen3] */
|
||||||
|
void setPolarity(defs::polarity value, Positions pos = {});
|
||||||
|
|
||||||
|
/** [Mythen3] */
|
||||||
|
Result<bool> getInterpolation(Positions pos = {}) const;
|
||||||
|
|
||||||
|
/** [Mythen3] Also enables all counters */
|
||||||
|
void setInterpolation(bool value, Positions pos = {});
|
||||||
|
|
||||||
|
/** [Mythen3] */
|
||||||
|
Result<bool> getPumpProbe(Positions pos = {}) const;
|
||||||
|
|
||||||
|
/** [Mythen3] */
|
||||||
|
void setPumpProbe(bool value, Positions pos = {});
|
||||||
|
|
||||||
|
/** [Mythen3] */
|
||||||
|
Result<bool> getAnalogPulsing(Positions pos = {}) const;
|
||||||
|
|
||||||
|
/** [Mythen3] */
|
||||||
|
void setAnalogPulsing(bool value, Positions pos = {});
|
||||||
|
|
||||||
|
/** [Mythen3] */
|
||||||
|
Result<bool> getDigitalPulsing(Positions pos = {}) const;
|
||||||
|
|
||||||
|
/** [Mythen3] */
|
||||||
|
void setDigitalPulsing(bool value, Positions pos = {});
|
||||||
|
|
||||||
///@}
|
///@}
|
||||||
|
|
||||||
/** @name CTB / Moench Specific */
|
/** @name CTB / Moench Specific */
|
||||||
@ -1614,12 +1644,11 @@ class Detector {
|
|||||||
/** [CTB] Default is enabled. */
|
/** [CTB] Default is enabled. */
|
||||||
void setLEDEnable(bool enable, Positions pos = {});
|
void setLEDEnable(bool enable, Positions pos = {});
|
||||||
|
|
||||||
|
|
||||||
void setDacNames(const std::vector<std::string> names);
|
void setDacNames(const std::vector<std::string> names);
|
||||||
|
|
||||||
std::vector<std::string> getDacNames() const;
|
std::vector<std::string> getDacNames() const;
|
||||||
|
|
||||||
defs::dacIndex getDacIndex(const std::string& name);
|
defs::dacIndex getDacIndex(const std::string &name);
|
||||||
std::string getDacName(defs::dacIndex i);
|
std::string getDacName(defs::dacIndex i);
|
||||||
///@}
|
///@}
|
||||||
|
|
||||||
@ -1766,23 +1795,11 @@ class Detector {
|
|||||||
/** [Jungfrau][CTB][Moench] Advanced user Function! */
|
/** [Jungfrau][CTB][Moench] Advanced user Function! */
|
||||||
void resetFPGA(Positions pos = {});
|
void resetFPGA(Positions pos = {});
|
||||||
|
|
||||||
/** [[deprecated ("Replaced by updateDetectorServer, which does not require
|
|
||||||
* tftp")]] [Jungfrau][Eiger][Gotthard][CTB][Moench][Mythen3][Gotthard2]
|
|
||||||
* Advanced user Function! \n
|
|
||||||
* Copy detector server fname from tftp folder of hostname to detector. Also
|
|
||||||
* creates a symbolic link to a shorter name (without vx.x.x). Then the
|
|
||||||
* detector controller reboots (except eiger) \n
|
|
||||||
* [Jungfrau][Gotthard][CTB][Moench] Also changes respawn server (to the
|
|
||||||
* link), which is effective after a reboot.
|
|
||||||
*/
|
|
||||||
void copyDetectorServer(const std::string &fname,
|
|
||||||
const std::string &hostname, Positions pos = {});
|
|
||||||
|
|
||||||
/** [Jungfrau][Eiger][Ctb][Moench][Mythen3][Gotthard2] Copies detector
|
/** [Jungfrau][Eiger][Ctb][Moench][Mythen3][Gotthard2] Copies detector
|
||||||
* server via TCP (without tftp).\nMakes a symbolic link with a shorter
|
* server via TCP (without tftp).\nMakes a symbolic link with a shorter
|
||||||
* name (without vx.x.x).\nThen, detector controller reboots (except
|
* name (without vx.x.x).\nThen, detector controller reboots (except
|
||||||
* Eiger).\n[Jungfrau][Ctb][Moench]Also changes respawn server to the
|
* Eiger).\n[Jungfrau][Ctb][Moench] Also deletes old server binary and
|
||||||
* link, which is effective after a reboot.
|
* changes respawn server to the link, which is effective after a reboot.
|
||||||
*/
|
*/
|
||||||
void updateDetectorServer(const std::string &fname, Positions pos = {});
|
void updateDetectorServer(const std::string &fname, Positions pos = {});
|
||||||
|
|
||||||
@ -1797,19 +1814,6 @@ class Detector {
|
|||||||
* Function! */
|
* Function! */
|
||||||
void rebootController(Positions pos = {});
|
void rebootController(Positions pos = {});
|
||||||
|
|
||||||
/** [[deprecated ("Replaced by overloaded updateDetectorServer, which does
|
|
||||||
* not require tftp and has one less argument")]] Advanced user Function!\n
|
|
||||||
* [Jungfrau][Gotthard][CTB][Moench] Updates the firmware, detector server,
|
|
||||||
* make a soft link and then reboots detector controller. \n
|
|
||||||
* [Mythen3][Gotthard2] Will require a script to start up the shorter named
|
|
||||||
* server link at start up \n sname is name of detector server binary found
|
|
||||||
* on tftp folder of host pc \n hostname is name of pc to tftp from \n fname
|
|
||||||
* is programming file name with full path to it
|
|
||||||
*/
|
|
||||||
void updateFirmwareAndServer(const std::string &sname,
|
|
||||||
const std::string &hostname,
|
|
||||||
const std::string &fname, Positions pos = {});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Advanced user Function!\n [Jungfrau][Gotthard][CTB][Moench] Updates the
|
* Advanced user Function!\n [Jungfrau][Gotthard][CTB][Moench] Updates the
|
||||||
* firmware, detector server, make a soft link and then reboots detector
|
* firmware, detector server, make a soft link and then reboots detector
|
||||||
|
@ -1056,7 +1056,18 @@ std::string CmdProxy::TemperatureValues(int action) {
|
|||||||
std::string CmdProxy::Dac(int action) {
|
std::string CmdProxy::Dac(int action) {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
|
|
||||||
|
if (action == defs::HELP_ACTION) {
|
||||||
|
if (args.size() == 0) {
|
||||||
|
os << GetHelpDac(std::to_string(0)) << '\n';
|
||||||
|
} else {
|
||||||
|
os << args[0] << ' ' << GetHelpDac(args[0]) << '\n';
|
||||||
|
}
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
|
|
||||||
auto type = det->getDetectorType().squash();
|
auto type = det->getDetectorType().squash();
|
||||||
|
|
||||||
// dac indices only for ctb
|
// dac indices only for ctb
|
||||||
if (args.size() > 0 && action != defs::HELP_ACTION) {
|
if (args.size() > 0 && action != defs::HELP_ACTION) {
|
||||||
if (is_int(args[0]) && type != defs::CHIPTESTBOARD) {
|
if (is_int(args[0]) && type != defs::CHIPTESTBOARD) {
|
||||||
@ -1066,13 +1077,7 @@ std::string CmdProxy::Dac(int action) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::GET_ACTION) {
|
||||||
if (args.size() == 0) {
|
|
||||||
os << GetHelpDac(std::to_string(0)) << '\n';
|
|
||||||
} else {
|
|
||||||
os << args[0] << ' ' << GetHelpDac(args[0]) << '\n';
|
|
||||||
}
|
|
||||||
} else if (action == defs::GET_ACTION) {
|
|
||||||
if (args.empty())
|
if (args.empty())
|
||||||
WrongNumberOfParameters(1); // This prints slightly wrong
|
WrongNumberOfParameters(1); // This prints slightly wrong
|
||||||
|
|
||||||
@ -2911,35 +2916,6 @@ std::string CmdProxy::ProgramFpga(int action) {
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CmdProxy::CopyDetectorServer(int action) {
|
|
||||||
std::ostringstream os;
|
|
||||||
os << cmd << ' ';
|
|
||||||
if (action == defs::HELP_ACTION) {
|
|
||||||
LOG(logWARNING) << "Deprecated! Replaced by updatedetectorserver that "
|
|
||||||
"requires no tftp.\n";
|
|
||||||
os << "[server_name (in tftp folder)] "
|
|
||||||
"[pc_host_name]\n\t[Jungfrau][Eiger][Ctb][Moench][Mythen3]["
|
|
||||||
"Gotthard2] Copies detector server via TFTP from pc. Ensure that "
|
|
||||||
"server is in the pc's tftp folder. Makes a symbolic link with a "
|
|
||||||
"shorter name (without vx.x.x). Then, detector controller "
|
|
||||||
"reboots (except "
|
|
||||||
"Eiger).\n\t[Jungfrau][Ctb][Moench]Also changes respawn server "
|
|
||||||
"to the link, which is effective after a reboot."
|
|
||||||
<< '\n';
|
|
||||||
} else if (action == defs::GET_ACTION) {
|
|
||||||
throw sls::RuntimeError("Cannot get");
|
|
||||||
} else if (action == defs::PUT_ACTION) {
|
|
||||||
if (args.size() != 2) {
|
|
||||||
WrongNumberOfParameters(2);
|
|
||||||
}
|
|
||||||
det->copyDetectorServer(args[0], args[1], std::vector<int>{det_id});
|
|
||||||
os << "successful\n";
|
|
||||||
} else {
|
|
||||||
throw sls::RuntimeError("Unknown action");
|
|
||||||
}
|
|
||||||
return os.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string CmdProxy::UpdateDetectorServer(int action) {
|
std::string CmdProxy::UpdateDetectorServer(int action) {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
@ -2996,23 +2972,21 @@ std::string CmdProxy::UpdateFirmwareAndDetectorServer(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "\n\tUsing tftp: Deprecated!! [server_name"
|
os << "\n\tWithout tftp: [server_name (incl fullpath)] "
|
||||||
" (in tftp folder)] [pc_host_name] [fname.pof (incl full path)]"
|
|
||||||
"\n\tWithout tftp: Recommended [server_name (incl fullpath)] "
|
|
||||||
"[fname.pof (incl full path)] "
|
"[fname.pof (incl full path)] "
|
||||||
"This does not use tftp."
|
"This does not use tftp."
|
||||||
"\n\t\t[Jungfrau][Gotthard][CTB][Moench] Updates the "
|
"\n\t\t[Jungfrau][Gotthard][CTB][Moench] Updates the "
|
||||||
"firmware, detector server, creates the symbolic link and then "
|
"firmware, detector server, deletes old server, creates the symbolic link and then "
|
||||||
"reboots detector controller. \n\t\t[Mythen3][Gotthard2] will "
|
"reboots detector controller. \n\t\t[Mythen3][Gotthard2] will "
|
||||||
"require a script to start up the shorter named server link at "
|
"require a script to start up the shorter named server link at "
|
||||||
"start up. \n\t\tsname is full path name of detector server "
|
"start up. \n\t\tserver_name is full path name of detector server "
|
||||||
"binary"
|
"binary"
|
||||||
"\n\t\tfname is full path of programming file"
|
"\n\t\tfname is full path of programming file"
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
throw sls::RuntimeError("Cannot get");
|
throw sls::RuntimeError("Cannot get");
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
if (args.size() != 3 && args.size() != 2) {
|
if (args.size() != 2) {
|
||||||
WrongNumberOfParameters(2);
|
WrongNumberOfParameters(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3021,17 +2995,8 @@ std::string CmdProxy::UpdateFirmwareAndDetectorServer(int action) {
|
|||||||
args[fpos].find(".rbf") == std::string::npos) {
|
args[fpos].find(".rbf") == std::string::npos) {
|
||||||
throw sls::RuntimeError("Programming file must be a pof/rbf file.");
|
throw sls::RuntimeError("Programming file must be a pof/rbf file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.size() == 3) {
|
|
||||||
LOG(logWARNING)
|
|
||||||
<< "Deprecated! Recommend to use same command without tftp (no "
|
|
||||||
"pc name) and using full path to the server binary";
|
|
||||||
det->updateFirmwareAndServer(args[0], args[1], args[2],
|
|
||||||
std::vector<int>{det_id});
|
|
||||||
} else {
|
|
||||||
det->updateFirmwareAndServer(args[0], args[1],
|
det->updateFirmwareAndServer(args[0], args[1],
|
||||||
std::vector<int>{det_id});
|
std::vector<int>{det_id});
|
||||||
}
|
|
||||||
os << "successful\n";
|
os << "successful\n";
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError("Unknown action");
|
throw sls::RuntimeError("Unknown action");
|
||||||
|
@ -743,7 +743,11 @@ class CmdProxy {
|
|||||||
|
|
||||||
/* Pattern */
|
/* Pattern */
|
||||||
/* Moench */
|
/* Moench */
|
||||||
|
|
||||||
/* Advanced */
|
/* Advanced */
|
||||||
|
{"copydetectorserver", "updatedetectorserver"},
|
||||||
|
|
||||||
|
|
||||||
/* Insignificant */
|
/* Insignificant */
|
||||||
{"nframes", "framecounter"},
|
{"nframes", "framecounter"},
|
||||||
{"now", "runtime"},
|
{"now", "runtime"},
|
||||||
@ -992,6 +996,11 @@ class CmdProxy {
|
|||||||
{"gatedelay2", &CmdProxy::GateDelay},
|
{"gatedelay2", &CmdProxy::GateDelay},
|
||||||
{"gatedelay3", &CmdProxy::GateDelay},
|
{"gatedelay3", &CmdProxy::GateDelay},
|
||||||
{"gaincaps", &CmdProxy::GainCaps},
|
{"gaincaps", &CmdProxy::GainCaps},
|
||||||
|
{"polarity", &CmdProxy::polarity},
|
||||||
|
{"interpolation", &CmdProxy::interpolation},
|
||||||
|
{"pumpprobe", &CmdProxy::pumpprobe},
|
||||||
|
{"apulse", &CmdProxy::apulse},
|
||||||
|
{"dpulse", &CmdProxy::dpulse},
|
||||||
|
|
||||||
/* CTB/ Moench Specific */
|
/* CTB/ Moench Specific */
|
||||||
{"samples", &CmdProxy::Samples},
|
{"samples", &CmdProxy::Samples},
|
||||||
@ -1062,7 +1071,6 @@ class CmdProxy {
|
|||||||
/* Advanced */
|
/* Advanced */
|
||||||
{"programfpga", &CmdProxy::ProgramFpga},
|
{"programfpga", &CmdProxy::ProgramFpga},
|
||||||
{"resetfpga", &CmdProxy::resetfpga},
|
{"resetfpga", &CmdProxy::resetfpga},
|
||||||
{"copydetectorserver", &CmdProxy::CopyDetectorServer},
|
|
||||||
{"updatedetectorserver", &CmdProxy::UpdateDetectorServer},
|
{"updatedetectorserver", &CmdProxy::UpdateDetectorServer},
|
||||||
{"updatekernel", &CmdProxy::UpdateKernel},
|
{"updatekernel", &CmdProxy::UpdateKernel},
|
||||||
{"rebootcontroller", &CmdProxy::rebootcontroller},
|
{"rebootcontroller", &CmdProxy::rebootcontroller},
|
||||||
@ -1189,7 +1197,6 @@ class CmdProxy {
|
|||||||
std::string JsonParameter(int action);
|
std::string JsonParameter(int action);
|
||||||
/* Advanced */
|
/* Advanced */
|
||||||
std::string ProgramFpga(int action);
|
std::string ProgramFpga(int action);
|
||||||
std::string CopyDetectorServer(int action);
|
|
||||||
std::string UpdateDetectorServer(int action);
|
std::string UpdateDetectorServer(int action);
|
||||||
std::string UpdateKernel(int action);
|
std::string UpdateKernel(int action);
|
||||||
std::string UpdateFirmwareAndDetectorServer(int action);
|
std::string UpdateFirmwareAndDetectorServer(int action);
|
||||||
@ -2032,6 +2039,31 @@ class CmdProxy {
|
|||||||
"[n_gates]\n\t[Mythen3] Number of external gates in gating "
|
"[n_gates]\n\t[Mythen3] Number of external gates in gating "
|
||||||
"or trigger_gating mode (external gating).");
|
"or trigger_gating mode (external gating).");
|
||||||
|
|
||||||
|
INTEGER_COMMAND_VEC_ID(polarity, getPolarity, setPolarity,
|
||||||
|
StringTo<defs::polarity>,
|
||||||
|
"[pos|neg]\n\t[Mythen3] Sets negative or positive "
|
||||||
|
"polarity. Default is positive");
|
||||||
|
|
||||||
|
INTEGER_COMMAND_VEC_ID(interpolation, getInterpolation, setInterpolation,
|
||||||
|
StringTo<int>,
|
||||||
|
"[0, 1]\n\t[Mythen3] Enables or disables "
|
||||||
|
"interpolation. Default is disabled. Enabling also "
|
||||||
|
"enables all counters. ");
|
||||||
|
|
||||||
|
INTEGER_COMMAND_VEC_ID(pumpprobe, getPumpProbe, setPumpProbe, StringTo<int>,
|
||||||
|
"[0, 1]\n\t[Mythen3] Enables or disables pump probe "
|
||||||
|
"mode. Default is disabled");
|
||||||
|
|
||||||
|
INTEGER_COMMAND_VEC_ID(apulse, getAnalogPulsing, setAnalogPulsing,
|
||||||
|
StringTo<int>,
|
||||||
|
"[0, 1]\n\t[Mythen3] Enables or disables analog "
|
||||||
|
"pulsing. Default is disabled");
|
||||||
|
|
||||||
|
INTEGER_COMMAND_VEC_ID(dpulse, getDigitalPulsing, setDigitalPulsing,
|
||||||
|
StringTo<int>,
|
||||||
|
"[0, 1]\n\t[Mythen3] Enables or disables digital "
|
||||||
|
"pulsing. Default is disabled");
|
||||||
|
|
||||||
/* CTB/ Moench Specific */
|
/* CTB/ Moench Specific */
|
||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID(
|
INTEGER_COMMAND_VEC_ID(
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
#include "CmdParser.h"
|
#include "CmdParser.h"
|
||||||
#include "CmdProxy.h"
|
#include "CmdProxy.h"
|
||||||
|
#include "CtbConfig.h"
|
||||||
#include "DetectorImpl.h"
|
#include "DetectorImpl.h"
|
||||||
#include "Module.h"
|
#include "Module.h"
|
||||||
#include "CtbConfig.h"
|
|
||||||
#include "sls/Pattern.h"
|
#include "sls/Pattern.h"
|
||||||
#include "sls/container_utils.h"
|
#include "sls/container_utils.h"
|
||||||
#include "sls/file_utils.h"
|
#include "sls/file_utils.h"
|
||||||
@ -26,8 +26,8 @@ void freeSharedMemory(int detectorIndex, int moduleIndex) {
|
|||||||
// single module
|
// single module
|
||||||
if (moduleIndex >= 0) {
|
if (moduleIndex >= 0) {
|
||||||
SharedMemory<sharedModule> moduleShm(detectorIndex, moduleIndex);
|
SharedMemory<sharedModule> moduleShm(detectorIndex, moduleIndex);
|
||||||
if (moduleShm.IsExisting()) {
|
if (moduleShm.exists()) {
|
||||||
moduleShm.RemoveSharedMemory();
|
moduleShm.removeSharedMemory();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -36,21 +36,21 @@ void freeSharedMemory(int detectorIndex, int moduleIndex) {
|
|||||||
SharedMemory<sharedDetector> detectorShm(detectorIndex, -1);
|
SharedMemory<sharedDetector> detectorShm(detectorIndex, -1);
|
||||||
int numDetectors = 0;
|
int numDetectors = 0;
|
||||||
|
|
||||||
if (detectorShm.IsExisting()) {
|
if (detectorShm.exists()) {
|
||||||
detectorShm.OpenSharedMemory();
|
detectorShm.openSharedMemory();
|
||||||
numDetectors = detectorShm()->numberOfModules;
|
numDetectors = detectorShm()->numberOfModules;
|
||||||
detectorShm.RemoveSharedMemory();
|
detectorShm.removeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < numDetectors; ++i) {
|
for (int i = 0; i < numDetectors; ++i) {
|
||||||
SharedMemory<sharedModule> moduleShm(detectorIndex, i);
|
SharedMemory<sharedModule> moduleShm(detectorIndex, i);
|
||||||
moduleShm.RemoveSharedMemory();
|
moduleShm.removeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ctb configuration
|
// Ctb configuration
|
||||||
SharedMemory<CtbConfig> ctbShm(detectorIndex, -1, CtbConfig::shm_tag());
|
SharedMemory<CtbConfig> ctbShm(detectorIndex, -1, CtbConfig::shm_tag());
|
||||||
if (ctbShm.IsExisting())
|
if (ctbShm.exists())
|
||||||
ctbShm.RemoveSharedMemory();
|
ctbShm.removeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
using defs = slsDetectorDefs;
|
using defs = slsDetectorDefs;
|
||||||
@ -781,24 +781,7 @@ void Detector::startReceiver() { pimpl->Parallel(&Module::startReceiver, {}); }
|
|||||||
void Detector::stopReceiver() { pimpl->Parallel(&Module::stopReceiver, {}); }
|
void Detector::stopReceiver() { pimpl->Parallel(&Module::stopReceiver, {}); }
|
||||||
|
|
||||||
void Detector::startDetector(Positions pos) {
|
void Detector::startDetector(Positions pos) {
|
||||||
auto detector_type = getDetectorType(pos).squash();
|
pimpl->startAcquisition(false, pos);
|
||||||
if (detector_type == defs::MYTHEN3 && size() > 1) {
|
|
||||||
std::vector<int> slaves(pos);
|
|
||||||
auto is_master = getMaster(pos);
|
|
||||||
int masterPosition = -1;
|
|
||||||
for (unsigned int i = 0; i < is_master.size(); ++i) {
|
|
||||||
if (is_master[i]) {
|
|
||||||
masterPosition = i;
|
|
||||||
slaves.erase(slaves.begin() + i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pimpl->Parallel(&Module::startAcquisition, pos);
|
|
||||||
if (masterPosition != -1) {
|
|
||||||
pimpl->Parallel(&Module::startAcquisition, {masterPosition});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pimpl->Parallel(&Module::startAcquisition, pos);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::startDetectorReadout() {
|
void Detector::startDetectorReadout() {
|
||||||
@ -1875,6 +1858,46 @@ Result<int> Detector::getGainCaps(Positions pos) {
|
|||||||
return pimpl->Parallel(&Module::getGainCaps, pos);
|
return pimpl->Parallel(&Module::getGainCaps, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result<defs::polarity> Detector::getPolarity(Positions pos) const {
|
||||||
|
return pimpl->Parallel(&Module::getPolarity, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Detector::setPolarity(defs::polarity value, Positions pos) {
|
||||||
|
pimpl->Parallel(&Module::setPolarity, pos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<bool> Detector::getInterpolation(Positions pos) const {
|
||||||
|
return pimpl->Parallel(&Module::getInterpolation, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Detector::setInterpolation(bool value, Positions pos) {
|
||||||
|
pimpl->Parallel(&Module::setInterpolation, pos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<bool> Detector::getPumpProbe(Positions pos) const {
|
||||||
|
return pimpl->Parallel(&Module::getPumpProbe, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Detector::setPumpProbe(bool value, Positions pos) {
|
||||||
|
pimpl->Parallel(&Module::setPumpProbe, pos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<bool> Detector::getAnalogPulsing(Positions pos) const {
|
||||||
|
return pimpl->Parallel(&Module::getAnalogPulsing, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Detector::setAnalogPulsing(bool value, Positions pos) {
|
||||||
|
pimpl->Parallel(&Module::setAnalogPulsing, pos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<bool> Detector::getDigitalPulsing(Positions pos) const {
|
||||||
|
return pimpl->Parallel(&Module::getDigitalPulsing, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Detector::setDigitalPulsing(bool value, Positions pos) {
|
||||||
|
pimpl->Parallel(&Module::setDigitalPulsing, pos, value);
|
||||||
|
}
|
||||||
|
|
||||||
// CTB/ Moench Specific
|
// CTB/ Moench Specific
|
||||||
|
|
||||||
Result<int> Detector::getNumberOfAnalogSamples(Positions pos) const {
|
Result<int> Detector::getNumberOfAnalogSamples(Positions pos) const {
|
||||||
@ -2242,15 +2265,6 @@ void Detector::resetFPGA(Positions pos) {
|
|||||||
pimpl->Parallel(&Module::resetFPGA, pos);
|
pimpl->Parallel(&Module::resetFPGA, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::copyDetectorServer(const std::string &fname,
|
|
||||||
const std::string &hostname, Positions pos) {
|
|
||||||
LOG(logINFO) << "Updating Detector Server (via tftp)...";
|
|
||||||
pimpl->Parallel(&Module::copyDetectorServer, pos, fname, hostname);
|
|
||||||
if (getDetectorType().squash() != defs::EIGER) {
|
|
||||||
rebootController(pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Detector::updateDetectorServer(const std::string &fname, Positions pos) {
|
void Detector::updateDetectorServer(const std::string &fname, Positions pos) {
|
||||||
LOG(logINFO) << "Updating Detector Server (no tftp)...";
|
LOG(logINFO) << "Updating Detector Server (no tftp)...";
|
||||||
std::vector<char> buffer = readBinaryFile(fname, "Update Detector Server");
|
std::vector<char> buffer = readBinaryFile(fname, "Update Detector Server");
|
||||||
@ -2272,16 +2286,6 @@ void Detector::rebootController(Positions pos) {
|
|||||||
pimpl->Parallel(&Module::rebootController, pos);
|
pimpl->Parallel(&Module::rebootController, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::updateFirmwareAndServer(const std::string &sname,
|
|
||||||
const std::string &hostname,
|
|
||||||
const std::string &fname,
|
|
||||||
Positions pos) {
|
|
||||||
LOG(logINFO) << "Updating Firmware and Detector Server (with tftp)...";
|
|
||||||
LOG(logINFO) << "Updating Detector Server (via tftp)...";
|
|
||||||
pimpl->Parallel(&Module::copyDetectorServer, pos, sname, hostname);
|
|
||||||
programFPGA(fname, false, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Detector::updateFirmwareAndServer(const std::string &sname,
|
void Detector::updateFirmwareAndServer(const std::string &sname,
|
||||||
const std::string &fname,
|
const std::string &fname,
|
||||||
Positions pos) {
|
Positions pos) {
|
||||||
|
@ -46,8 +46,8 @@ void DetectorImpl::setupDetector(bool verify, bool update) {
|
|||||||
updateUserdetails();
|
updateUserdetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctb_shm.IsExisting())
|
if (ctb_shm.exists())
|
||||||
ctb_shm.OpenSharedMemory();
|
ctb_shm.openSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::setAcquiringFlag(bool flag) { shm()->acquiringFlag = flag; }
|
void DetectorImpl::setAcquiringFlag(bool flag) { shm()->acquiringFlag = flag; }
|
||||||
@ -58,8 +58,8 @@ void DetectorImpl::freeSharedMemory(int detectorIndex, int detPos) {
|
|||||||
// single
|
// single
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
SharedMemory<sharedModule> moduleShm(detectorIndex, detPos);
|
SharedMemory<sharedModule> moduleShm(detectorIndex, detPos);
|
||||||
if (moduleShm.IsExisting()) {
|
if (moduleShm.exists()) {
|
||||||
moduleShm.RemoveSharedMemory();
|
moduleShm.removeSharedMemory();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -68,20 +68,20 @@ void DetectorImpl::freeSharedMemory(int detectorIndex, int detPos) {
|
|||||||
SharedMemory<sharedDetector> detectorShm(detectorIndex, -1);
|
SharedMemory<sharedDetector> detectorShm(detectorIndex, -1);
|
||||||
int numModules = 0;
|
int numModules = 0;
|
||||||
|
|
||||||
if (detectorShm.IsExisting()) {
|
if (detectorShm.exists()) {
|
||||||
detectorShm.OpenSharedMemory();
|
detectorShm.openSharedMemory();
|
||||||
numModules = detectorShm()->numberOfModules;
|
numModules = detectorShm()->numberOfModules;
|
||||||
detectorShm.RemoveSharedMemory();
|
detectorShm.removeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < numModules; ++i) {
|
for (int i = 0; i < numModules; ++i) {
|
||||||
SharedMemory<sharedModule> moduleShm(detectorIndex, i);
|
SharedMemory<sharedModule> moduleShm(detectorIndex, i);
|
||||||
moduleShm.RemoveSharedMemory();
|
moduleShm.removeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedMemory<CtbConfig> ctbShm(detectorIndex, -1, CtbConfig::shm_tag());
|
SharedMemory<CtbConfig> ctbShm(detectorIndex, -1, CtbConfig::shm_tag());
|
||||||
if (ctbShm.IsExisting())
|
if (ctbShm.exists())
|
||||||
ctbShm.RemoveSharedMemory();
|
ctbShm.removeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::freeSharedMemory() {
|
void DetectorImpl::freeSharedMemory() {
|
||||||
@ -92,11 +92,11 @@ void DetectorImpl::freeSharedMemory() {
|
|||||||
modules.clear();
|
modules.clear();
|
||||||
|
|
||||||
// clear detector shm
|
// clear detector shm
|
||||||
shm.RemoveSharedMemory();
|
shm.removeSharedMemory();
|
||||||
client_downstream = false;
|
client_downstream = false;
|
||||||
|
|
||||||
if (ctb_shm.IsExisting())
|
if (ctb_shm.exists())
|
||||||
ctb_shm.RemoveSharedMemory();
|
ctb_shm.removeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DetectorImpl::getUserDetails() {
|
std::string DetectorImpl::getUserDetails() {
|
||||||
@ -140,11 +140,11 @@ void DetectorImpl::setInitialChecks(const bool value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::initSharedMemory(bool verify) {
|
void DetectorImpl::initSharedMemory(bool verify) {
|
||||||
if (!shm.IsExisting()) {
|
if (!shm.exists()) {
|
||||||
shm.CreateSharedMemory();
|
shm.createSharedMemory();
|
||||||
initializeDetectorStructure();
|
initializeDetectorStructure();
|
||||||
} else {
|
} else {
|
||||||
shm.OpenSharedMemory();
|
shm.openSharedMemory();
|
||||||
if (verify && shm()->shmversion != DETECTOR_SHMVERSION) {
|
if (verify && shm()->shmversion != DETECTOR_SHMVERSION) {
|
||||||
LOG(logERROR) << "Detector shared memory (" << detectorIndex
|
LOG(logERROR) << "Detector shared memory (" << detectorIndex
|
||||||
<< ") version mismatch "
|
<< ") version mismatch "
|
||||||
@ -155,6 +155,8 @@ void DetectorImpl::initSharedMemory(bool verify) {
|
|||||||
throw SharedMemoryError("Shared memory version mismatch!");
|
throw SharedMemoryError("Shared memory version mismatch!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// std::cout <<
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::initializeDetectorStructure() {
|
void DetectorImpl::initializeDetectorStructure() {
|
||||||
@ -261,10 +263,10 @@ void DetectorImpl::setHostname(const std::vector<std::string> &name) {
|
|||||||
// if needed, CTB dac names are only on detector level
|
// if needed, CTB dac names are only on detector level
|
||||||
|
|
||||||
if (shm()->detType == defs::CHIPTESTBOARD) {
|
if (shm()->detType == defs::CHIPTESTBOARD) {
|
||||||
if (ctb_shm.IsExisting())
|
if (ctb_shm.exists())
|
||||||
ctb_shm.OpenSharedMemory();
|
ctb_shm.openSharedMemory();
|
||||||
else
|
else
|
||||||
ctb_shm.CreateSharedMemory();
|
ctb_shm.createSharedMemory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -600,14 +602,12 @@ void DetectorImpl::readFrameFromReceiver() {
|
|||||||
currentSubFrameIndex = zHeader.expLength;
|
currentSubFrameIndex = zHeader.expLength;
|
||||||
coordY = zHeader.row;
|
coordY = zHeader.row;
|
||||||
coordX = zHeader.column;
|
coordX = zHeader.column;
|
||||||
if (eiger) {
|
|
||||||
coordY = (nY - 1) - coordY;
|
|
||||||
}
|
|
||||||
flipRows = zHeader.flipRows;
|
flipRows = zHeader.flipRows;
|
||||||
if (zHeader.completeImage == 0) {
|
if (zHeader.completeImage == 0) {
|
||||||
completeImage = false;
|
completeImage = false;
|
||||||
}
|
}
|
||||||
LOG(logDEBUG1)
|
LOG(logDEBUG1)
|
||||||
|
<< zmqSocket[isocket]->GetPortNumber() << " "
|
||||||
<< "Header Info:"
|
<< "Header Info:"
|
||||||
"\n\tcurrentFileName: "
|
"\n\tcurrentFileName: "
|
||||||
<< currentFileName << "\n\tcurrentAcquisitionIndex: "
|
<< currentFileName << "\n\tcurrentAcquisitionIndex: "
|
||||||
@ -1124,25 +1124,7 @@ int DetectorImpl::acquire() {
|
|||||||
|
|
||||||
// start and read all
|
// start and read all
|
||||||
try {
|
try {
|
||||||
if (detector_type == defs::MYTHEN3 && modules.size() > 1) {
|
startAcquisition(true, {});
|
||||||
// Multi module mythen
|
|
||||||
std::vector<int> master;
|
|
||||||
std::vector<int> slaves;
|
|
||||||
auto is_master = Parallel(&Module::isMaster, {});
|
|
||||||
slaves.reserve(modules.size() - 1); // check this one!!
|
|
||||||
for (size_t i = 0; i < modules.size(); ++i) {
|
|
||||||
if (is_master[i])
|
|
||||||
master.push_back(i);
|
|
||||||
else
|
|
||||||
slaves.push_back(i);
|
|
||||||
}
|
|
||||||
Parallel(&Module::startAcquisition, slaves);
|
|
||||||
Parallel(&Module::startAndReadAll, master);
|
|
||||||
} else {
|
|
||||||
// Normal acquire
|
|
||||||
Parallel(&Module::startAndReadAll, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
if (receiver)
|
if (receiver)
|
||||||
Parallel(&Module::stopReceiver, {});
|
Parallel(&Module::stopReceiver, {});
|
||||||
@ -1191,6 +1173,44 @@ int DetectorImpl::acquire() {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DetectorImpl::startAcquisition(bool blocking, std::vector<int> positions) {
|
||||||
|
if (shm()->detType == defs::MYTHEN3 && size() > 1) {
|
||||||
|
std::vector<int> master;
|
||||||
|
std::vector<int> slaves;
|
||||||
|
if (positions.empty() ||
|
||||||
|
(positions.size() == 1 && positions[0] == -1)) {
|
||||||
|
positions.resize(modules.size());
|
||||||
|
std::iota(begin(positions), end(positions), 0);
|
||||||
|
}
|
||||||
|
// could be all slaves in positions
|
||||||
|
slaves.reserve(positions.size());
|
||||||
|
auto is_master = Parallel(&Module::isMaster, positions);
|
||||||
|
for (size_t i : positions) {
|
||||||
|
if (is_master[i])
|
||||||
|
master.push_back(i);
|
||||||
|
else
|
||||||
|
slaves.push_back(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!slaves.empty()) {
|
||||||
|
Parallel(&Module::startAcquisition, slaves);
|
||||||
|
}
|
||||||
|
if (!master.empty()) {
|
||||||
|
if (blocking) {
|
||||||
|
Parallel(&Module::startAndReadAll, master);
|
||||||
|
} else {
|
||||||
|
Parallel(&Module::startAcquisition, master);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (blocking) {
|
||||||
|
Parallel(&Module::startAndReadAll, positions);
|
||||||
|
} else {
|
||||||
|
Parallel(&Module::startAcquisition, positions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DetectorImpl::printProgress(double progress) {
|
void DetectorImpl::printProgress(double progress) {
|
||||||
// spaces for python printout
|
// spaces for python printout
|
||||||
std::cout << " " << std::fixed << std::setprecision(2) << std::setw(6)
|
std::cout << " " << std::fixed << std::setprecision(2) << std::setw(6)
|
||||||
@ -1286,8 +1306,13 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
|||||||
throw RuntimeError("Programming file must be an rbf file.");
|
throw RuntimeError("Programming file must be an rbf file.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
case EIGER:
|
||||||
|
case GOTTHARD:
|
||||||
throw RuntimeError("programfpga not implemented for this detector");
|
throw RuntimeError("programfpga not implemented for this detector");
|
||||||
|
default:
|
||||||
|
throw RuntimeError(
|
||||||
|
"Unknown detector type. Did the 'hostname' command execute "
|
||||||
|
"successfully? Or use update mode in the detector server side.");
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(logINFO) << "This can take awhile. Please be patient.";
|
LOG(logINFO) << "This can take awhile. Please be patient.";
|
||||||
|
@ -278,6 +278,9 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
int acquire();
|
int acquire();
|
||||||
|
|
||||||
|
/** also takes care of master and slave for multi module mythen */
|
||||||
|
void startAcquisition(bool blocking, std::vector<int> positions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Combines data from all readouts and gives it to the gui
|
* Combines data from all readouts and gives it to the gui
|
||||||
* or just gives progress of acquisition by polling receivers
|
* or just gives progress of acquisition by polling receivers
|
||||||
|
@ -33,11 +33,11 @@ Module::Module(detectorType type, int det_id, int module_index, bool verify)
|
|||||||
: moduleIndex(module_index), shm(det_id, module_index) {
|
: moduleIndex(module_index), shm(det_id, module_index) {
|
||||||
|
|
||||||
// ensure shared memory was not created before
|
// ensure shared memory was not created before
|
||||||
if (shm.IsExisting()) {
|
if (shm.exists()) {
|
||||||
LOG(logWARNING) << "This shared memory should have been "
|
LOG(logWARNING) << "This shared memory should have been "
|
||||||
"deleted before! "
|
"deleted before! "
|
||||||
<< shm.GetName() << ". Freeing it again";
|
<< shm.getName() << ". Freeing it again";
|
||||||
shm.RemoveSharedMemory();
|
shm.removeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
initSharedMemory(type, det_id, verify);
|
initSharedMemory(type, det_id, verify);
|
||||||
@ -55,8 +55,8 @@ Module::Module(int det_id, int module_index, bool verify)
|
|||||||
Module::~Module() = default;
|
Module::~Module() = default;
|
||||||
|
|
||||||
void Module::freeSharedMemory() {
|
void Module::freeSharedMemory() {
|
||||||
if (shm.IsExisting()) {
|
if (shm.exists()) {
|
||||||
shm.RemoveSharedMemory();
|
shm.removeSharedMemory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,12 +407,18 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
|
|||||||
|
|
||||||
// check dacs
|
// check dacs
|
||||||
out_of_range = false;
|
out_of_range = false;
|
||||||
for (auto dac : {M_VTRIM, M_VTH1, M_VTH2, M_VTH3}) {
|
for (int i = 0; i != myMod.ndac; ++i) {
|
||||||
if (myMod.dacs[dac] < 600) {
|
int dacMin = 0;
|
||||||
myMod.dacs[dac] = 600;
|
int dacMax = 2800;
|
||||||
|
if (i == M_VTH1 || i == M_VTH2 || i == M_VTH3) {
|
||||||
|
dacMin = 200;
|
||||||
|
dacMax = 2400;
|
||||||
|
}
|
||||||
|
if (myMod.dacs[i] < dacMin) {
|
||||||
|
myMod.dacs[i] = dacMin;
|
||||||
out_of_range = true;
|
out_of_range = true;
|
||||||
} else if (myMod.dacs[dac] > 2400) {
|
} else if (myMod.dacs[i] > dacMax) {
|
||||||
myMod.dacs[dac] = 2400;
|
myMod.dacs[i] = dacMax;
|
||||||
out_of_range = true;
|
out_of_range = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2256,11 +2262,52 @@ int Module::getChipStatusRegister() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Module::setGainCaps(int caps) {
|
void Module::setGainCaps(int caps) {
|
||||||
sendToDetector<int>(F_SET_GAIN_CAPS, caps);
|
sendToDetector(F_SET_GAIN_CAPS, caps, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Module::getGainCaps() { return sendToDetector<int>(F_GET_GAIN_CAPS); }
|
int Module::getGainCaps() { return sendToDetector<int>(F_GET_GAIN_CAPS); }
|
||||||
|
|
||||||
|
defs::polarity Module::getPolarity() const {
|
||||||
|
return sendToDetector<defs::polarity>(F_GET_POLARITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Module::setPolarity(const defs::polarity value) {
|
||||||
|
sendToDetector(F_SET_POLARITY, static_cast<int>(value), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Module::getInterpolation() const {
|
||||||
|
return sendToDetector<int>(F_GET_INTERPOLATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Module::setInterpolation(const bool enable) {
|
||||||
|
sendToDetector(F_SET_INTERPOLATION, static_cast<int>(enable), nullptr);
|
||||||
|
setCounterMask(getCounterMask());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Module::getPumpProbe() const {
|
||||||
|
return sendToDetector<int>(F_GET_PUMP_PROBE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Module::setPumpProbe(const bool enable) {
|
||||||
|
sendToDetector(F_SET_PUMP_PROBE, static_cast<int>(enable), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Module::getAnalogPulsing() const {
|
||||||
|
return sendToDetector<int>(F_GET_ANALOG_PULSING);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Module::setAnalogPulsing(const bool enable) {
|
||||||
|
sendToDetector(F_SET_ANALOG_PULSING, static_cast<int>(enable), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Module::getDigitalPulsing() const {
|
||||||
|
return sendToDetector<int>(F_GET_DIGITAL_PULSING);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Module::setDigitalPulsing(const bool enable) {
|
||||||
|
sendToDetector(F_SET_DIGITAL_PULSING, static_cast<int>(enable), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
// CTB / Moench Specific
|
// CTB / Moench Specific
|
||||||
int Module::getNumberOfAnalogSamples() const {
|
int Module::getNumberOfAnalogSamples() const {
|
||||||
return sendToDetector<int>(F_GET_NUM_ANALOG_SAMPLES);
|
return sendToDetector<int>(F_GET_NUM_ANALOG_SAMPLES);
|
||||||
@ -2611,28 +2658,6 @@ void Module::programFPGA(std::vector<char> buffer,
|
|||||||
|
|
||||||
void Module::resetFPGA() { sendToDetector(F_RESET_FPGA); }
|
void Module::resetFPGA() { sendToDetector(F_RESET_FPGA); }
|
||||||
|
|
||||||
void Module::copyDetectorServer(const std::string &fname,
|
|
||||||
const std::string &hostname) {
|
|
||||||
char args[2][MAX_STR_LENGTH]{};
|
|
||||||
sls::strcpy_safe(args[0], fname.c_str());
|
|
||||||
sls::strcpy_safe(args[1], hostname.c_str());
|
|
||||||
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
|
|
||||||
<< "): Sending detector server " << args[0] << " from host "
|
|
||||||
<< args[1];
|
|
||||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
|
||||||
client.Send(F_COPY_DET_SERVER);
|
|
||||||
client.Send(args);
|
|
||||||
if (client.Receive<int>() == FAIL) {
|
|
||||||
std::cout << '\n';
|
|
||||||
std::ostringstream os;
|
|
||||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
|
||||||
<< " returned error: " << client.readErrorMessage();
|
|
||||||
throw DetectorError(os.str());
|
|
||||||
}
|
|
||||||
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
|
|
||||||
<< "): Detector server copied";
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::updateDetectorServer(std::vector<char> buffer,
|
void Module::updateDetectorServer(std::vector<char> buffer,
|
||||||
const std::string &serverName) {
|
const std::string &serverName) {
|
||||||
switch (shm()->detType) {
|
switch (shm()->detType) {
|
||||||
@ -3171,20 +3196,20 @@ Ret Module::sendToReceiver(int fnum, const Arg &args) {
|
|||||||
|
|
||||||
slsDetectorDefs::detectorType Module::getDetectorTypeFromShm(int det_id,
|
slsDetectorDefs::detectorType Module::getDetectorTypeFromShm(int det_id,
|
||||||
bool verify) {
|
bool verify) {
|
||||||
if (!shm.IsExisting()) {
|
if (!shm.exists()) {
|
||||||
throw SharedMemoryError("Shared memory " + shm.GetName() +
|
throw SharedMemoryError("Shared memory " + shm.getName() +
|
||||||
"does not exist.\n Corrupted Multi Shared "
|
"does not exist.\n Corrupted Multi Shared "
|
||||||
"memory. Please free shared memory.");
|
"memory. Please free shared memory.");
|
||||||
}
|
}
|
||||||
|
|
||||||
shm.OpenSharedMemory();
|
shm.openSharedMemory();
|
||||||
if (verify && shm()->shmversion != MODULE_SHMVERSION) {
|
if (verify && shm()->shmversion != MODULE_SHMVERSION) {
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << "Single shared memory (" << det_id << "-" << moduleIndex
|
ss << "Single shared memory (" << det_id << "-" << moduleIndex
|
||||||
<< ":)version mismatch (expected 0x" << std::hex << MODULE_SHMVERSION
|
<< ":)version mismatch (expected 0x" << std::hex << MODULE_SHMVERSION
|
||||||
<< " but got 0x" << shm()->shmversion << ")" << std::dec
|
<< " but got 0x" << shm()->shmversion << ")" << std::dec
|
||||||
<< ". Clear Shared memory to continue.";
|
<< ". Clear Shared memory to continue.";
|
||||||
shm.UnmapSharedMemory();
|
shm.unmapSharedMemory();
|
||||||
throw SharedMemoryError(ss.str());
|
throw SharedMemoryError(ss.str());
|
||||||
}
|
}
|
||||||
return shm()->detType;
|
return shm()->detType;
|
||||||
@ -3192,11 +3217,11 @@ slsDetectorDefs::detectorType Module::getDetectorTypeFromShm(int det_id,
|
|||||||
|
|
||||||
void Module::initSharedMemory(detectorType type, int det_id, bool verify) {
|
void Module::initSharedMemory(detectorType type, int det_id, bool verify) {
|
||||||
shm = SharedMemory<sharedModule>(det_id, moduleIndex);
|
shm = SharedMemory<sharedModule>(det_id, moduleIndex);
|
||||||
if (!shm.IsExisting()) {
|
if (!shm.exists()) {
|
||||||
shm.CreateSharedMemory();
|
shm.createSharedMemory();
|
||||||
initializeModuleStructure(type);
|
initializeModuleStructure(type);
|
||||||
} else {
|
} else {
|
||||||
shm.OpenSharedMemory();
|
shm.openSharedMemory();
|
||||||
if (verify && shm()->shmversion != MODULE_SHMVERSION) {
|
if (verify && shm()->shmversion != MODULE_SHMVERSION) {
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << "Single shared memory (" << det_id << "-" << moduleIndex
|
ss << "Single shared memory (" << det_id << "-" << moduleIndex
|
||||||
|
@ -466,6 +466,16 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
int getChipStatusRegister() const;
|
int getChipStatusRegister() const;
|
||||||
void setGainCaps(int caps);
|
void setGainCaps(int caps);
|
||||||
int getGainCaps();
|
int getGainCaps();
|
||||||
|
defs::polarity getPolarity() const;
|
||||||
|
void setPolarity(const defs::polarity enable);
|
||||||
|
bool getInterpolation() const;
|
||||||
|
void setInterpolation(const bool enable);
|
||||||
|
bool getPumpProbe() const;
|
||||||
|
void setPumpProbe(const bool enable);
|
||||||
|
bool getAnalogPulsing() const;
|
||||||
|
void setAnalogPulsing(const bool enable);
|
||||||
|
bool getDigitalPulsing() const;
|
||||||
|
void setDigitalPulsing(const bool enable);
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* *
|
* *
|
||||||
@ -548,8 +558,6 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
void programFPGA(std::vector<char> buffer,
|
void programFPGA(std::vector<char> buffer,
|
||||||
const bool forceDeleteNormalFile);
|
const bool forceDeleteNormalFile);
|
||||||
void resetFPGA();
|
void resetFPGA();
|
||||||
void copyDetectorServer(const std::string &fname,
|
|
||||||
const std::string &hostname);
|
|
||||||
void updateDetectorServer(std::vector<char> buffer,
|
void updateDetectorServer(std::vector<char> buffer,
|
||||||
const std::string &serverName);
|
const std::string &serverName);
|
||||||
void updateKernel(std::vector<char> buffer);
|
void updateKernel(std::vector<char> buffer);
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
#include "sls/logger.h"
|
#include "sls/logger.h"
|
||||||
#include "sls/sls_detector_exceptions.h"
|
#include "sls/sls_detector_exceptions.h"
|
||||||
|
|
||||||
#include "stdlib.h"
|
// #include "stdlib.h"
|
||||||
|
#include <cstdlib>
|
||||||
#include <cerrno> // errno
|
#include <cerrno> // errno
|
||||||
#include <cstring> // strerror
|
#include <cstring> // strerror
|
||||||
#include <fcntl.h> // O_CREAT, O_TRUNC..
|
#include <fcntl.h> // O_CREAT, O_TRUNC..
|
||||||
@ -33,268 +34,178 @@
|
|||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
template <typename T> class SharedMemory {
|
template <typename T> class SharedMemory {
|
||||||
|
static constexpr int NAME_MAX_LENGTH = 255;
|
||||||
|
std::string name;
|
||||||
|
T *shared_struct{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//moduleid of -1 creates a detector only shared memory
|
// moduleid of -1 creates a detector only shared memory
|
||||||
SharedMemory(int detectorId, int moduleIndex, const std::string& tag = "") {
|
SharedMemory(int detectorId, int moduleIndex, const std::string &tag = "") {
|
||||||
name = ConstructSharedMemoryName(detectorId, moduleIndex, tag);
|
name = constructSharedMemoryName(detectorId, moduleIndex, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Disable copy, since we refer to a unique location
|
||||||
* Delete the copy constructor and copy assignment since we don't want two
|
|
||||||
* objects managing the same resource
|
|
||||||
*/
|
|
||||||
SharedMemory(const SharedMemory &) = delete;
|
SharedMemory(const SharedMemory &) = delete;
|
||||||
SharedMemory &operator=(const SharedMemory &other) = delete;
|
SharedMemory &operator=(const SharedMemory &other) = delete;
|
||||||
|
|
||||||
// Move constructor
|
|
||||||
SharedMemory(SharedMemory &&other)
|
SharedMemory(SharedMemory &&other)
|
||||||
: name(other.name), fd(other.fd), shmSize(other.shmSize),
|
: name(other.name), shared_struct(other.shared_struct) {
|
||||||
shared_struct(other.shared_struct) {
|
|
||||||
|
|
||||||
other.fd = -1;
|
|
||||||
other.shared_struct = nullptr;
|
other.shared_struct = nullptr;
|
||||||
other.shmSize = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move assignment
|
|
||||||
SharedMemory &operator=(SharedMemory &&other) {
|
SharedMemory &operator=(SharedMemory &&other) {
|
||||||
name = other.name;
|
name = other.name;
|
||||||
if (fd) {
|
if (shared_struct != nullptr)
|
||||||
close(fd);
|
unmapSharedMemory();
|
||||||
}
|
|
||||||
fd = other.fd;
|
|
||||||
other.fd = -1;
|
|
||||||
|
|
||||||
if (shared_struct != nullptr) {
|
|
||||||
UnmapSharedMemory();
|
|
||||||
}
|
|
||||||
shared_struct = other.shared_struct;
|
shared_struct = other.shared_struct;
|
||||||
other.shared_struct = nullptr;
|
other.shared_struct = nullptr;
|
||||||
|
|
||||||
shmSize = other.shmSize;
|
|
||||||
other.shmSize = 0;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
~SharedMemory() {
|
~SharedMemory() {
|
||||||
if (fd >= 0)
|
if (shared_struct)
|
||||||
close(fd);
|
unmapSharedMemory();
|
||||||
|
|
||||||
if (shared_struct) {
|
|
||||||
UnmapSharedMemory();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
T *operator()() { return shared_struct; }
|
||||||
* Verify if it exists
|
const T *operator()() const { return shared_struct; }
|
||||||
* @return true if exists, else false
|
std::string getName() const { return name; }
|
||||||
*/
|
|
||||||
bool IsExisting() {
|
bool exists() {
|
||||||
bool ret = true;
|
|
||||||
int tempfd = shm_open(name.c_str(), O_RDWR, 0);
|
int tempfd = shm_open(name.c_str(), O_RDWR, 0);
|
||||||
if ((tempfd < 0) && (errno == ENOENT)) {
|
if ((tempfd < 0) && (errno == ENOENT)) {
|
||||||
ret = false;
|
return false;
|
||||||
}
|
}
|
||||||
close(tempfd);
|
close(tempfd);
|
||||||
return ret;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetName() const { return name; }
|
void createSharedMemory() {
|
||||||
size_t size() const { return shmSize; }
|
int fd = shm_open(name.c_str(), O_CREAT | O_TRUNC | O_EXCL | O_RDWR,
|
||||||
|
|
||||||
/**
|
|
||||||
* Create Shared memory and call MapSharedMemory to map it to an address
|
|
||||||
* throws a SharedMemoryError exception on failure to create, ftruncate or
|
|
||||||
* map
|
|
||||||
*/
|
|
||||||
void CreateSharedMemory() {
|
|
||||||
fd = shm_open(name.c_str(), O_CREAT | O_TRUNC | O_EXCL | O_RDWR,
|
|
||||||
S_IRUSR | S_IWUSR);
|
S_IRUSR | S_IWUSR);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
std::string msg =
|
std::string msg =
|
||||||
"Create shared memory " + name + " failed: " + strerror(errno);
|
"Create shared memory " + name + " failed: " + strerror(errno);
|
||||||
LOG(logERROR) << msg;
|
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ftruncate(fd, sizeof(T)) < 0) {
|
if (ftruncate(fd, sizeof(T)) < 0) {
|
||||||
std::string msg = "Create shared memory " + name +
|
std::string msg = "Create shared memory " + name +
|
||||||
" failed at ftruncate: " + strerror(errno);
|
" failed at ftruncate: " + strerror(errno);
|
||||||
LOG(logERROR) << msg;
|
|
||||||
close(fd);
|
close(fd);
|
||||||
RemoveSharedMemory();
|
removeSharedMemory();
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
}
|
}
|
||||||
shared_struct = MapSharedMemory();
|
shared_struct = mapSharedMemory(fd);
|
||||||
new (shared_struct) T{};
|
new (shared_struct) T{};
|
||||||
LOG(logINFO) << "Shared memory created " << name;
|
LOG(logINFO) << "Shared memory created " << name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void openSharedMemory() {
|
||||||
* Open existing Shared memory and call MapSharedMemory to map it to an
|
int fd = shm_open(name.c_str(), O_RDWR, 0);
|
||||||
* address throws a SharedMemoryError exception on failure to open or map
|
|
||||||
*/
|
|
||||||
void OpenSharedMemory() {
|
|
||||||
fd = shm_open(name.c_str(), O_RDWR, 0);
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
std::string msg = "Open existing shared memory " + name +
|
std::string msg = "Open existing shared memory " + name +
|
||||||
" failed: " + strerror(errno);
|
" failed: " + strerror(errno);
|
||||||
LOG(logERROR) << msg;
|
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
}
|
}
|
||||||
|
checkSize(fd);
|
||||||
shared_struct = MapSharedMemory();
|
shared_struct = mapSharedMemory(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void unmapSharedMemory() {
|
||||||
* Unmap shared memory from an address
|
|
||||||
* throws a SharedMemoryError exception on failure
|
|
||||||
*/
|
|
||||||
void UnmapSharedMemory() {
|
|
||||||
if (shared_struct != nullptr) {
|
if (shared_struct != nullptr) {
|
||||||
if (munmap(shared_struct, shmSize) < 0) {
|
if (munmap(shared_struct, sizeof(T)) < 0) {
|
||||||
std::string msg = "Unmapping shared memory " + name +
|
std::string msg = "Unmapping shared memory " + name +
|
||||||
" failed: " + strerror(errno);
|
" failed: " + strerror(errno);
|
||||||
LOG(logERROR) << msg;
|
|
||||||
close(fd);
|
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
}
|
}
|
||||||
shared_struct = nullptr;
|
shared_struct = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void removeSharedMemory() {
|
||||||
* Remove existing Shared memory
|
unmapSharedMemory();
|
||||||
*/
|
|
||||||
void RemoveSharedMemory() {
|
|
||||||
UnmapSharedMemory();
|
|
||||||
if (shm_unlink(name.c_str()) < 0) {
|
if (shm_unlink(name.c_str()) < 0) {
|
||||||
// silent exit if shm did not exist anyway
|
// silent exit if shm did not exist anyway
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
return;
|
return;
|
||||||
std::string msg =
|
std::string msg =
|
||||||
"Free Shared Memory " + name + " Failed: " + strerror(errno);
|
"Free Shared Memory " + name + " Failed: " + strerror(errno);
|
||||||
LOG(logERROR) << msg;
|
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Shared memory deleted " << name;
|
LOG(logINFO) << "Shared memory deleted " << name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Maximum length of name as from man pages
|
|
||||||
*/
|
|
||||||
static const int NAME_MAX_LENGTH = 255;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*Using the call operator to access the pointer
|
|
||||||
*/
|
|
||||||
T *operator()() { return shared_struct; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
*Using the call operator to access the pointer, const overload
|
|
||||||
*/
|
|
||||||
const T *operator()() const { return shared_struct; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
std::string constructSharedMemoryName(int detectorId, int moduleIndex,
|
||||||
* Create Shared memory name
|
const std::string &tag) {
|
||||||
* throws exception if name created is longer than required 255(manpages)
|
|
||||||
* @param detectorId detector id
|
|
||||||
* @param moduleIndex module id, -1 if a detector shared memory
|
|
||||||
* @returns shared memory name
|
|
||||||
*/
|
|
||||||
std::string ConstructSharedMemoryName(int detectorId, int moduleIndex, const std::string& tag) {
|
|
||||||
|
|
||||||
// using environment path
|
// using environment variable
|
||||||
std::string sEnvPath;
|
std::string slsdetname;
|
||||||
char *envpath = getenv(SHM_ENV_NAME);
|
char *envpath = getenv(SHM_ENV_NAME);
|
||||||
if (envpath != nullptr) {
|
if (envpath != nullptr) {
|
||||||
sEnvPath.assign(envpath);
|
slsdetname = envpath;
|
||||||
sEnvPath.insert(0, "_");
|
slsdetname.insert(0, "_");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
if (moduleIndex < 0){
|
if (moduleIndex < 0) {
|
||||||
ss << SHM_DETECTOR_PREFIX << detectorId << sEnvPath;
|
ss << SHM_DETECTOR_PREFIX << detectorId << slsdetname;
|
||||||
if (!tag.empty())
|
if (!tag.empty())
|
||||||
ss << "_" << tag;
|
ss << "_" << tag;
|
||||||
|
} else {
|
||||||
|
ss << SHM_DETECTOR_PREFIX << detectorId << SHM_MODULE_PREFIX
|
||||||
|
<< moduleIndex << slsdetname;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
std::string shm_name = ss.str();
|
||||||
ss << SHM_DETECTOR_PREFIX << detectorId << SHM_MODULE_PREFIX
|
if (shm_name.length() > NAME_MAX_LENGTH) {
|
||||||
<< moduleIndex << sEnvPath;
|
|
||||||
|
|
||||||
std::string temp = ss.str();
|
|
||||||
if (temp.length() > NAME_MAX_LENGTH) {
|
|
||||||
std::string msg =
|
std::string msg =
|
||||||
"Shared memory initialization failed. " + temp + " has " +
|
"Shared memory initialization failed. " + shm_name + " has " +
|
||||||
std::to_string(temp.length()) + " characters. \n" +
|
std::to_string(shm_name.length()) + " characters. \n" +
|
||||||
"Maximum is " + std::to_string(NAME_MAX_LENGTH) +
|
"Maximum is " + std::to_string(NAME_MAX_LENGTH) +
|
||||||
". Change the environment variable " + SHM_ENV_NAME;
|
". Change the environment variable " + SHM_ENV_NAME;
|
||||||
LOG(logERROR) << msg;
|
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
}
|
}
|
||||||
return temp;
|
return shm_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// from the Linux manual:
|
||||||
* Map shared memory to an address
|
// After the mmap() call has returned, the file descriptor, fd, can
|
||||||
* throws a SharedMemoryException exception on failure
|
// be closed immediately without invalidating the mapping.
|
||||||
*/
|
T *mapSharedMemory(int fd) {
|
||||||
|
|
||||||
T *MapSharedMemory() {
|
|
||||||
void *addr =
|
void *addr =
|
||||||
mmap(nullptr, sizeof(T), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
mmap(nullptr, sizeof(T), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
|
close(fd);
|
||||||
if (addr == MAP_FAILED) {
|
if (addr == MAP_FAILED) {
|
||||||
std::string msg =
|
std::string msg =
|
||||||
"Mapping shared memory " + name + " failed: " + strerror(errno);
|
"Mapping shared memory " + name + " failed: " + strerror(errno);
|
||||||
LOG(logERROR) << msg;
|
|
||||||
close(fd);
|
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
}
|
}
|
||||||
shmSize = sizeof(T);
|
return static_cast<T *>(addr);
|
||||||
close(fd);
|
|
||||||
return (T *)addr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void checkSize(int fd) {
|
||||||
* Verify if existing shared memory size matches expected size
|
|
||||||
* @param expectedSize expected size of shared memory, replaced with smaller
|
|
||||||
* size if size does not match
|
|
||||||
* @return 0 for success, 1 for fail
|
|
||||||
*/
|
|
||||||
int VerifySizeMatch(size_t expectedSize) {
|
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
// could not fstat
|
|
||||||
if (fstat(fd, &sb) < 0) {
|
if (fstat(fd, &sb) < 0) {
|
||||||
std::string msg = "Could not verify existing shared memory " +
|
std::string msg = "Could not verify existing shared memory " +
|
||||||
name + " size match " +
|
name + " size match " +
|
||||||
"(could not fstat): " + strerror(errno);
|
"(could not fstat): " + strerror(errno);
|
||||||
LOG(logERROR) << msg;
|
|
||||||
close(fd);
|
close(fd);
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// size does not match
|
auto actual_size = static_cast<size_t>(sb.st_size);
|
||||||
auto sz = static_cast<size_t>(sb.st_size);
|
auto expected_size = sizeof(T);
|
||||||
if (sz != expectedSize) {
|
if (actual_size != expected_size) {
|
||||||
std::string msg = "Existing shared memory " + name +
|
std::string msg =
|
||||||
" size does not match" + "Expected " +
|
"Existing shared memory " + name + " size does not match. " +
|
||||||
std::to_string(expectedSize) + ", found " +
|
"Expected " + std::to_string(expected_size) + ", found " +
|
||||||
std::to_string(sz);
|
std::to_string(actual_size) +
|
||||||
LOG(logERROR) << msg;
|
". Detector software mismatch? Try freeing shared memory.";
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string name;
|
|
||||||
int fd{-1};
|
|
||||||
size_t shmSize{0};
|
|
||||||
T *shared_struct{nullptr};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -463,3 +463,151 @@ TEST_CASE("gatedelay3", "[.cmd]") {
|
|||||||
REQUIRE_THROWS(proxy.Call("gatedelay3", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("gatedelay3", {}, -1, GET));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("polarity", "[.cmd]") {
|
||||||
|
Detector det;
|
||||||
|
CmdProxy proxy(&det);
|
||||||
|
if (det.getDetectorType().squash() == defs::MYTHEN3) {
|
||||||
|
auto prev_val = det.getPolarity();
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("polarity", {"pos"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "polarity pos\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("polarity", {"neg"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "polarity neg\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("polarity", {}, -1, GET, oss);
|
||||||
|
REQUIRE(oss.str() == "polarity neg\n");
|
||||||
|
}
|
||||||
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
|
det.setPolarity(prev_val[i], {i});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
REQUIRE_THROWS(proxy.Call("polarity", {}, -1, GET));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("interpolation", "[.cmd]") {
|
||||||
|
Detector det;
|
||||||
|
CmdProxy proxy(&det);
|
||||||
|
if (det.getDetectorType().squash() == defs::MYTHEN3) {
|
||||||
|
auto prev_val = det.getInterpolation();
|
||||||
|
auto mask = det.getCounterMask();
|
||||||
|
{
|
||||||
|
proxy.Call("counters", {"0", "1"}, -1, PUT);
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("interpolation", {"1"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "interpolation 1\n");
|
||||||
|
REQUIRE(det.getCounterMask().tsquash("inconsistent counter mask") ==
|
||||||
|
7);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
proxy.Call("counters", {"0", "1"}, -1, PUT);
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("interpolation", {"0"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "interpolation 0\n");
|
||||||
|
REQUIRE(det.getCounterMask().tsquash("inconsistent counter mask") ==
|
||||||
|
3);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("interpolation", {}, -1, GET, oss);
|
||||||
|
REQUIRE(oss.str() == "interpolation 0\n");
|
||||||
|
}
|
||||||
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
|
det.setCounterMask(mask[i], {i});
|
||||||
|
det.setInterpolation(prev_val[i], {i});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
REQUIRE_THROWS(proxy.Call("interpolation", {}, -1, GET));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("pumpprobe", "[.cmd]") {
|
||||||
|
Detector det;
|
||||||
|
CmdProxy proxy(&det);
|
||||||
|
if (det.getDetectorType().squash() == defs::MYTHEN3) {
|
||||||
|
auto prev_val = det.getPumpProbe();
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("pumpprobe", {"1"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "pumpprobe 1\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("pumpprobe", {"0"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "pumpprobe 0\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("pumpprobe", {}, -1, GET, oss);
|
||||||
|
REQUIRE(oss.str() == "pumpprobe 0\n");
|
||||||
|
}
|
||||||
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
|
det.setPumpProbe(prev_val[i], {i});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
REQUIRE_THROWS(proxy.Call("pumpprobe", {}, -1, GET));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("apulse", "[.cmd]") {
|
||||||
|
Detector det;
|
||||||
|
CmdProxy proxy(&det);
|
||||||
|
if (det.getDetectorType().squash() == defs::MYTHEN3) {
|
||||||
|
auto prev_val = det.getAnalogPulsing();
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("apulse", {"1"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "apulse 1\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("apulse", {"0"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "apulse 0\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("apulse", {}, -1, GET, oss);
|
||||||
|
REQUIRE(oss.str() == "apulse 0\n");
|
||||||
|
}
|
||||||
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
|
det.setAnalogPulsing(prev_val[i], {i});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
REQUIRE_THROWS(proxy.Call("apulse", {}, -1, GET));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("dpulse", "[.cmd]") {
|
||||||
|
Detector det;
|
||||||
|
CmdProxy proxy(&det);
|
||||||
|
if (det.getDetectorType().squash() == defs::MYTHEN3) {
|
||||||
|
auto prev_val = det.getDigitalPulsing();
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("dpulse", {"1"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "dpulse 1\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("dpulse", {"0"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "dpulse 0\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("dpulse", {}, -1, GET, oss);
|
||||||
|
REQUIRE(oss.str() == "dpulse 0\n");
|
||||||
|
}
|
||||||
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
|
det.setDigitalPulsing(prev_val[i], {i});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
REQUIRE_THROWS(proxy.Call("dpulse", {}, -1, GET));
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,17 @@ using sls::Detector;
|
|||||||
using test::GET;
|
using test::GET;
|
||||||
using test::PUT;
|
using test::PUT;
|
||||||
|
|
||||||
|
TEST_CASE("Calling help doesn't throw or cause segfault"){
|
||||||
|
//Dont add [.cmd] tag this should run with normal tests
|
||||||
|
CmdProxy proxy(nullptr);
|
||||||
|
auto commands = proxy.GetProxyCommands();
|
||||||
|
std::ostringstream os;
|
||||||
|
for (const auto &cmd : commands)
|
||||||
|
REQUIRE_NOTHROW(proxy.Call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("Unknown command", "[.cmd]") {
|
TEST_CASE("Unknown command", "[.cmd]") {
|
||||||
|
|
||||||
Detector det;
|
Detector det;
|
||||||
@ -2776,25 +2787,6 @@ TEST_CASE("resetfpga", "[.cmd]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("copydetectorserver", "[.cmd]") {
|
|
||||||
Detector det;
|
|
||||||
CmdProxy proxy(&det);
|
|
||||||
auto det_type = det.getDetectorType().squash();
|
|
||||||
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD ||
|
|
||||||
det_type == defs::MOENCH || det_type == defs::MYTHEN3 ||
|
|
||||||
det_type == defs::GOTTHARD2) {
|
|
||||||
// TODO: send real server?
|
|
||||||
// std::ostringstream oss;
|
|
||||||
// proxy.Call("copydetectorserver",{"jungfrauDetectorServerv4.0.1.0",
|
|
||||||
// "pc13784"}, -1, PUT, oss);
|
|
||||||
// REQUIRE(oss.str() == "copydetectorserver successful\n");
|
|
||||||
REQUIRE_THROWS(proxy.Call("copydetectorserver", {}, -1, GET));
|
|
||||||
} else {
|
|
||||||
REQUIRE_THROWS(proxy.Call("copydetectorserver", {}, -1, GET));
|
|
||||||
REQUIRE_THROWS(proxy.Call("copydetectorserver", {}, -1, PUT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("updatekernel", "[.cmd]") {
|
TEST_CASE("updatekernel", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
|
@ -32,8 +32,8 @@ TEST_CASE("Is shm fixed pattern shm compatible") {
|
|||||||
|
|
||||||
// Set shm version to 0
|
// Set shm version to 0
|
||||||
sls::SharedMemory<sls::sharedModule> shm(0, 0);
|
sls::SharedMemory<sls::sharedModule> shm(0, 0);
|
||||||
REQUIRE(shm.IsExisting() == true);
|
REQUIRE(shm.exists() == true);
|
||||||
shm.OpenSharedMemory();
|
shm.openSharedMemory();
|
||||||
shm()->shmversion = 0;
|
shm()->shmversion = 0;
|
||||||
|
|
||||||
// Should fail since version is set to 0
|
// Should fail since version is set to 0
|
||||||
|
@ -20,8 +20,8 @@ constexpr int shm_id = 10;
|
|||||||
TEST_CASE("Create SharedMemory read and write", "[detector]") {
|
TEST_CASE("Create SharedMemory read and write", "[detector]") {
|
||||||
|
|
||||||
SharedMemory<Data> shm(shm_id, -1);
|
SharedMemory<Data> shm(shm_id, -1);
|
||||||
shm.CreateSharedMemory();
|
shm.createSharedMemory();
|
||||||
CHECK(shm.GetName() == std::string("/slsDetectorPackage_detector_") +
|
CHECK(shm.getName() == std::string("/slsDetectorPackage_detector_") +
|
||||||
std::to_string(shm_id));
|
std::to_string(shm_id));
|
||||||
|
|
||||||
shm()->x = 3;
|
shm()->x = 3;
|
||||||
@ -32,25 +32,25 @@ TEST_CASE("Create SharedMemory read and write", "[detector]") {
|
|||||||
CHECK(shm()->y == 5.7);
|
CHECK(shm()->y == 5.7);
|
||||||
CHECK(std::string(shm()->mess) == "Some string");
|
CHECK(std::string(shm()->mess) == "Some string");
|
||||||
|
|
||||||
shm.UnmapSharedMemory();
|
shm.unmapSharedMemory();
|
||||||
shm.RemoveSharedMemory();
|
shm.removeSharedMemory();
|
||||||
|
|
||||||
CHECK(shm.IsExisting() == false);
|
CHECK(shm.exists() == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Open existing SharedMemory and read", "[detector]") {
|
TEST_CASE("Open existing SharedMemory and read", "[detector]") {
|
||||||
|
|
||||||
{
|
{
|
||||||
SharedMemory<double> shm(shm_id, -1);
|
SharedMemory<double> shm(shm_id, -1);
|
||||||
shm.CreateSharedMemory();
|
shm.createSharedMemory();
|
||||||
*shm() = 5.3;
|
*shm() = 5.3;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedMemory<double> shm2(shm_id, -1);
|
SharedMemory<double> shm2(shm_id, -1);
|
||||||
shm2.OpenSharedMemory();
|
shm2.openSharedMemory();
|
||||||
CHECK(*shm2() == 5.3);
|
CHECK(*shm2() == 5.3);
|
||||||
|
|
||||||
shm2.RemoveSharedMemory();
|
shm2.removeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Creating a second shared memory with the same name throws",
|
TEST_CASE("Creating a second shared memory with the same name throws",
|
||||||
@ -59,24 +59,24 @@ TEST_CASE("Creating a second shared memory with the same name throws",
|
|||||||
SharedMemory<double> shm0(shm_id, -1);
|
SharedMemory<double> shm0(shm_id, -1);
|
||||||
SharedMemory<double> shm1(shm_id, -1);
|
SharedMemory<double> shm1(shm_id, -1);
|
||||||
|
|
||||||
shm0.CreateSharedMemory();
|
shm0.createSharedMemory();
|
||||||
CHECK_THROWS(shm1.CreateSharedMemory());
|
CHECK_THROWS(shm1.createSharedMemory());
|
||||||
shm0.RemoveSharedMemory();
|
shm0.removeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Open two shared memories to the same place", "[detector]") {
|
TEST_CASE("Open two shared memories to the same place", "[detector]") {
|
||||||
|
|
||||||
// Create the first shared memory
|
// Create the first shared memory
|
||||||
SharedMemory<Data> shm(shm_id, -1);
|
SharedMemory<Data> shm(shm_id, -1);
|
||||||
shm.CreateSharedMemory();
|
shm.createSharedMemory();
|
||||||
shm()->x = 5;
|
shm()->x = 5;
|
||||||
CHECK(shm()->x == 5);
|
CHECK(shm()->x == 5);
|
||||||
|
|
||||||
// Open the second shared memory with the same name
|
// Open the second shared memory with the same name
|
||||||
SharedMemory<Data> shm2(shm_id, -1);
|
SharedMemory<Data> shm2(shm_id, -1);
|
||||||
shm2.OpenSharedMemory();
|
shm2.openSharedMemory();
|
||||||
CHECK(shm2()->x == 5);
|
CHECK(shm2()->x == 5);
|
||||||
CHECK(shm.GetName() == shm2.GetName());
|
CHECK(shm.getName() == shm2.getName());
|
||||||
|
|
||||||
// Check that they still point to the same place
|
// Check that they still point to the same place
|
||||||
shm2()->x = 7;
|
shm2()->x = 7;
|
||||||
@ -84,31 +84,28 @@ TEST_CASE("Open two shared memories to the same place", "[detector]") {
|
|||||||
|
|
||||||
// Remove only needs to be done once since they refer
|
// Remove only needs to be done once since they refer
|
||||||
// to the same memory
|
// to the same memory
|
||||||
shm2.RemoveSharedMemory();
|
shm2.removeSharedMemory();
|
||||||
CHECK(shm.IsExisting() == false);
|
CHECK(shm.exists() == false);
|
||||||
CHECK(shm2.IsExisting() == false);
|
CHECK(shm2.exists() == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Move SharedMemory", "[detector]") {
|
TEST_CASE("Move SharedMemory", "[detector]") {
|
||||||
|
|
||||||
SharedMemory<Data> shm(shm_id, -1);
|
SharedMemory<Data> shm(shm_id, -1);
|
||||||
CHECK(shm.GetName() == std::string("/slsDetectorPackage_detector_") +
|
CHECK(shm.getName() == std::string("/slsDetectorPackage_detector_") +
|
||||||
std::to_string(shm_id));
|
std::to_string(shm_id));
|
||||||
shm.CreateSharedMemory();
|
shm.createSharedMemory();
|
||||||
shm()->x = 9;
|
shm()->x = 9;
|
||||||
|
|
||||||
CHECK(shm.size() == sizeof(Data));
|
|
||||||
|
|
||||||
SharedMemory<Data> shm2(shm_id + 1, -1);
|
SharedMemory<Data> shm2(shm_id + 1, -1);
|
||||||
shm2 = std::move(shm); // shm is now a moved from object!
|
shm2 = std::move(shm); // shm is now a moved from object!
|
||||||
|
|
||||||
CHECK(shm2()->x == 9);
|
CHECK(shm2()->x == 9);
|
||||||
CHECK(shm() == nullptr);
|
CHECK(shm() == nullptr);
|
||||||
CHECK(shm.size() == 0);
|
CHECK(shm2.getName() == std::string("/slsDetectorPackage_detector_") +
|
||||||
|
|
||||||
CHECK(shm2.GetName() == std::string("/slsDetectorPackage_detector_") +
|
|
||||||
std::to_string(shm_id));
|
std::to_string(shm_id));
|
||||||
shm2.RemoveSharedMemory();
|
shm2.removeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Create several shared memories", "[detector]") {
|
TEST_CASE("Create several shared memories", "[detector]") {
|
||||||
@ -117,27 +114,27 @@ TEST_CASE("Create several shared memories", "[detector]") {
|
|||||||
v.reserve(N);
|
v.reserve(N);
|
||||||
for (int i = 0; i != N; ++i) {
|
for (int i = 0; i != N; ++i) {
|
||||||
v.emplace_back(shm_id + i, -1);
|
v.emplace_back(shm_id + i, -1);
|
||||||
CHECK(v[i].IsExisting() == false);
|
CHECK(v[i].exists() == false);
|
||||||
v[i].CreateSharedMemory();
|
v[i].createSharedMemory();
|
||||||
*v[i]() = i;
|
*v[i]() = i;
|
||||||
CHECK(*v[i]() == i);
|
CHECK(*v[i]() == i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i != N; ++i) {
|
for (int i = 0; i != N; ++i) {
|
||||||
CHECK(*v[i]() == i);
|
CHECK(*v[i]() == i);
|
||||||
CHECK(v[i].GetName() == std::string("/slsDetectorPackage_detector_") +
|
CHECK(v[i].getName() == std::string("/slsDetectorPackage_detector_") +
|
||||||
std::to_string(i + shm_id));
|
std::to_string(i + shm_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i != N; ++i) {
|
for (int i = 0; i != N; ++i) {
|
||||||
v[i].RemoveSharedMemory();
|
v[i].removeSharedMemory();
|
||||||
CHECK(v[i].IsExisting() == false);
|
CHECK(v[i].exists() == false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Create create a shared memory with a tag"){
|
TEST_CASE("Create create a shared memory with a tag"){
|
||||||
SharedMemory<int> shm(0, -1, "ctbdacs");
|
SharedMemory<int> shm(0, -1, "ctbdacs");
|
||||||
REQUIRE(shm.GetName() == "/slsDetectorPackage_detector_0_ctbdacs");
|
REQUIRE(shm.getName() == "/slsDetectorPackage_detector_0_ctbdacs");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +149,7 @@ TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set"){
|
|||||||
setenv(SHM_ENV_NAME, "myprefix", 1);
|
setenv(SHM_ENV_NAME, "myprefix", 1);
|
||||||
|
|
||||||
SharedMemory<int> shm(0, -1, "ctbdacs");
|
SharedMemory<int> shm(0, -1, "ctbdacs");
|
||||||
REQUIRE(shm.GetName() == "/slsDetectorPackage_detector_0_myprefix_ctbdacs");
|
REQUIRE(shm.getName() == "/slsDetectorPackage_detector_0_myprefix_ctbdacs");
|
||||||
|
|
||||||
// Clean up after us
|
// Clean up after us
|
||||||
if (old_slsdetname.empty())
|
if (old_slsdetname.empty())
|
||||||
@ -162,3 +159,17 @@ TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set"){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("map int64 to int32 throws"){
|
||||||
|
SharedMemory<int32_t> shm(shm_id, -1);
|
||||||
|
shm.createSharedMemory();
|
||||||
|
*shm() = 7;
|
||||||
|
|
||||||
|
SharedMemory<int64_t> shm2(shm_id, -1);
|
||||||
|
REQUIRE_THROWS(shm2.openSharedMemory());
|
||||||
|
|
||||||
|
shm.removeSharedMemory();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -6,7 +6,6 @@ set(SOURCES
|
|||||||
src/Receiver.cpp
|
src/Receiver.cpp
|
||||||
src/File.cpp
|
src/File.cpp
|
||||||
src/BinaryDataFile.cpp
|
src/BinaryDataFile.cpp
|
||||||
src/BinaryMasterFile.cpp
|
|
||||||
src/ThreadObject.cpp
|
src/ThreadObject.cpp
|
||||||
src/Listener.cpp
|
src/Listener.cpp
|
||||||
src/DataProcessor.cpp
|
src/DataProcessor.cpp
|
||||||
@ -14,6 +13,7 @@ set(SOURCES
|
|||||||
src/Fifo.cpp
|
src/Fifo.cpp
|
||||||
src/Arping.cpp
|
src/Arping.cpp
|
||||||
src/MasterAttributes.cpp
|
src/MasterAttributes.cpp
|
||||||
|
src/MasterFileUtility.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(PUBLICHEADERS
|
set(PUBLICHEADERS
|
||||||
@ -28,8 +28,6 @@ if (SLS_USE_HDF5)
|
|||||||
)
|
)
|
||||||
list (APPEND SOURCES
|
list (APPEND SOURCES
|
||||||
src/HDF5DataFile.cpp
|
src/HDF5DataFile.cpp
|
||||||
src/HDF5MasterFile.cpp
|
|
||||||
src/HDF5VirtualFile.cpp
|
|
||||||
)
|
)
|
||||||
endif (SLS_USE_HDF5)
|
endif (SLS_USE_HDF5)
|
||||||
|
|
||||||
@ -42,6 +40,8 @@ add_library(slsReceiverObject OBJECT
|
|||||||
target_include_directories(slsReceiverObject PUBLIC
|
target_include_directories(slsReceiverObject PUBLIC
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||||
|
PRIVATE
|
||||||
|
${SLS_INTERNAL_RAPIDJSON_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(slsReceiverObject
|
target_link_libraries(slsReceiverObject
|
||||||
|
@ -39,52 +39,50 @@ class Receiver : private virtual slsDetectorDefs {
|
|||||||
int64_t getReceiverVersion();
|
int64_t getReceiverVersion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call back for start acquisition
|
* Start Acquisition Call back (slsMultiReceiver writes data if file write enabled)
|
||||||
* callback arguments are
|
* if registerCallBackRawDataReady or registerCallBackRawDataModifyReady registered,
|
||||||
* filepath
|
* users get data
|
||||||
* filename
|
* callback arguments are:
|
||||||
* fileindex
|
* - file path
|
||||||
* datasize
|
* - file name prefix
|
||||||
*
|
* - file index
|
||||||
* return value is undefined at the moment
|
* - image size in bytes
|
||||||
* we write depending on file write enable
|
|
||||||
* users get data to write depending on call backs registered
|
|
||||||
*/
|
*/
|
||||||
void registerCallBackStartAcquisition(int (*func)(std::string, std::string,
|
void registerCallBackStartAcquisition(int (*func)(const std::string &, const std::string &,
|
||||||
uint64_t, uint32_t,
|
uint64_t, size_t, void *),
|
||||||
void *),
|
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call back for acquisition finished
|
* Call back for acquisition finished
|
||||||
* callback argument is
|
* callback argument is:
|
||||||
* total frames caught
|
* - total frames caught
|
||||||
*/
|
*/
|
||||||
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *),
|
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call back for raw data
|
* Call back for raw data
|
||||||
* args to raw data ready callback are
|
* args to raw data ready callback are:
|
||||||
* sls_receiver_header frame metadata,
|
* - sls_receiver_header frame metadata,
|
||||||
* dataPointer is the pointer to the data,
|
* - pointer to data
|
||||||
* dataSize in bytes is the size of the data in bytes.
|
* - image size in bytes
|
||||||
*/
|
*/
|
||||||
void registerCallBackRawDataReady(void (*func)(char *, char *, uint32_t,
|
void registerCallBackRawDataReady(void (*func)(sls_receiver_header *,
|
||||||
void *),
|
char *, size_t, void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call back for raw data (modified)
|
* Call back for raw data (modified)
|
||||||
* args to raw data ready callback are
|
* args to raw data ready callback are:
|
||||||
* sls_receiver_header frame metadata,
|
* - sls_receiver_header frame metadata,
|
||||||
* dataPointer is the pointer to the data,
|
* - pointer to data
|
||||||
* revDatasize is the reference of data size in bytes.
|
* - revDatasize is the reference of data size in bytes.
|
||||||
* Can be modified to the new size to be written/streamed. (only smaller
|
* Can be modified to the new size to be written/streamed. (only smaller
|
||||||
* value).
|
* value allowed).
|
||||||
*/
|
*/
|
||||||
void registerCallBackRawDataModifyReady(void (*func)(char *, char *,
|
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
|
||||||
uint32_t &, void *),
|
char *, size_t &,
|
||||||
|
void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -72,7 +72,7 @@ void BinaryDataFile::WriteToFile(char *buffer, const int buffersize,
|
|||||||
++subFileIndex_;
|
++subFileIndex_;
|
||||||
CreateFile();
|
CreateFile();
|
||||||
}
|
}
|
||||||
numFramesInFile_++;
|
++numFramesInFile_;
|
||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
#include "BinaryMasterFile.h"
|
|
||||||
#include "MasterAttributes.h"
|
|
||||||
|
|
||||||
BinaryMasterFile::BinaryMasterFile() : File(BINARY) {}
|
|
||||||
|
|
||||||
BinaryMasterFile::~BinaryMasterFile() { CloseFile(); }
|
|
||||||
|
|
||||||
void BinaryMasterFile::CloseFile() {
|
|
||||||
if (fd_) {
|
|
||||||
fclose(fd_);
|
|
||||||
}
|
|
||||||
fd_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BinaryMasterFile::CreateMasterFile(const std::string filePath,
|
|
||||||
const std::string fileNamePrefix,
|
|
||||||
const uint64_t fileIndex,
|
|
||||||
const bool overWriteEnable,
|
|
||||||
const bool silentMode,
|
|
||||||
MasterAttributes *attr) {
|
|
||||||
// create file name
|
|
||||||
std::ostringstream os;
|
|
||||||
os << filePath << "/" << fileNamePrefix << "_master"
|
|
||||||
<< "_" << fileIndex << ".raw";
|
|
||||||
fileName_ = os.str();
|
|
||||||
|
|
||||||
// create file
|
|
||||||
if (!overWriteEnable) {
|
|
||||||
if (nullptr == (fd_ = fopen((const char *)fileName_.c_str(), "wx"))) {
|
|
||||||
fd_ = nullptr;
|
|
||||||
throw sls::RuntimeError("Could not create binary master file " +
|
|
||||||
fileName_);
|
|
||||||
}
|
|
||||||
} else if (nullptr == (fd_ = fopen((const char *)fileName_.c_str(), "w"))) {
|
|
||||||
fd_ = nullptr;
|
|
||||||
throw sls::RuntimeError(
|
|
||||||
"Could not create/overwrite binary master file " + fileName_);
|
|
||||||
}
|
|
||||||
if (!silentMode) {
|
|
||||||
LOG(logINFO) << "Master File: " << fileName_;
|
|
||||||
}
|
|
||||||
attr->WriteMasterBinaryAttributes(fd_);
|
|
||||||
CloseFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BinaryMasterFile::UpdateMasterFile(MasterAttributes *attr,
|
|
||||||
bool silentMode) {
|
|
||||||
if (nullptr == (fd_ = fopen((const char *)fileName_.c_str(), "a"))) {
|
|
||||||
fd_ = nullptr;
|
|
||||||
throw sls::RuntimeError("Could not append binary master file " +
|
|
||||||
fileName_);
|
|
||||||
}
|
|
||||||
attr->WriteFinalBinaryAttributes(fd_);
|
|
||||||
CloseFile();
|
|
||||||
if (!silentMode) {
|
|
||||||
LOG(logINFO) << "Updated Master File";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "File.h"
|
|
||||||
#include "MasterAttributes.h"
|
|
||||||
|
|
||||||
class BinaryMasterFile : private virtual slsDetectorDefs, public File {
|
|
||||||
|
|
||||||
public:
|
|
||||||
BinaryMasterFile();
|
|
||||||
~BinaryMasterFile();
|
|
||||||
|
|
||||||
void CloseFile() override;
|
|
||||||
void CreateMasterFile(const std::string filePath,
|
|
||||||
const std::string fileNamePrefix,
|
|
||||||
const uint64_t fileIndex, const bool overWriteEnable,
|
|
||||||
const bool silentMode,
|
|
||||||
MasterAttributes *attr) override;
|
|
||||||
void UpdateMasterFile(MasterAttributes *attr, bool silentMode) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
FILE *fd_{nullptr};
|
|
||||||
std::string fileName_;
|
|
||||||
};
|
|
@ -55,7 +55,7 @@ int64_t ClientInterface::getReceiverVersion() { return APIRECEIVER; }
|
|||||||
|
|
||||||
/***callback functions***/
|
/***callback functions***/
|
||||||
void ClientInterface::registerCallBackStartAcquisition(
|
void ClientInterface::registerCallBackStartAcquisition(
|
||||||
int (*func)(std::string, std::string, uint64_t, uint32_t, void *),
|
int (*func)(const std::string &, const std::string &, uint64_t, size_t, void *),
|
||||||
void *arg) {
|
void *arg) {
|
||||||
startAcquisitionCallBack = func;
|
startAcquisitionCallBack = func;
|
||||||
pStartAcquisition = arg;
|
pStartAcquisition = arg;
|
||||||
@ -69,13 +69,13 @@ void ClientInterface::registerCallBackAcquisitionFinished(void (*func)(uint64_t,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ClientInterface::registerCallBackRawDataReady(
|
void ClientInterface::registerCallBackRawDataReady(
|
||||||
void (*func)(char *, char *, uint32_t, void *), void *arg) {
|
void (*func)(sls_receiver_header *, char *, size_t, void *), void *arg) {
|
||||||
rawDataReadyCallBack = func;
|
rawDataReadyCallBack = func;
|
||||||
pRawDataReady = arg;
|
pRawDataReady = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientInterface::registerCallBackRawDataModifyReady(
|
void ClientInterface::registerCallBackRawDataModifyReady(
|
||||||
void (*func)(char *, char *, uint32_t &, void *), void *arg) {
|
void (*func)(sls_receiver_header *, char *, size_t &, void *), void *arg) {
|
||||||
rawDataModifyReadyCallBack = func;
|
rawDataModifyReadyCallBack = func;
|
||||||
pRawDataReady = arg;
|
pRawDataReady = arg;
|
||||||
}
|
}
|
||||||
|
@ -30,25 +30,24 @@ class ClientInterface : private virtual slsDetectorDefs {
|
|||||||
int64_t getReceiverVersion();
|
int64_t getReceiverVersion();
|
||||||
|
|
||||||
//***callback functions***
|
//***callback functions***
|
||||||
/** params: filepath, filename, fileindex, datasize */
|
/** params: file path, file name, file index, image size */
|
||||||
void registerCallBackStartAcquisition(int (*func)(std::string, std::string,
|
void registerCallBackStartAcquisition(int (*func)(const std::string &, const std::string &,
|
||||||
uint64_t, uint32_t,
|
uint64_t, size_t, void *),
|
||||||
void *),
|
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
/** params: total frames caught */
|
/** params: total frames caught */
|
||||||
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *),
|
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
/** params: sls_receiver_header frame metadata, dataPointer, dataSize */
|
/** params: sls_receiver_header pointer, pointer to data, image size */
|
||||||
void registerCallBackRawDataReady(void (*func)(char *, char *, uint32_t,
|
void registerCallBackRawDataReady(void (*func)(sls_receiver_header *,
|
||||||
void *),
|
char *, size_t, void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
/** params: sls_receiver_header frame metadata, dataPointer, modified size
|
/** params: sls_receiver_header pointer, pointer to data, reference to image size */
|
||||||
*/
|
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
|
||||||
void registerCallBackRawDataModifyReady(void (*func)(char *, char *,
|
char *, size_t &,
|
||||||
uint32_t &, void *),
|
void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -180,13 +179,14 @@ class ClientInterface : private virtual slsDetectorDefs {
|
|||||||
|
|
||||||
//***callback parameters***
|
//***callback parameters***
|
||||||
|
|
||||||
int (*startAcquisitionCallBack)(std::string, std::string, uint64_t,
|
int (*startAcquisitionCallBack)(const std::string &, const std::string &, uint64_t, size_t,
|
||||||
uint32_t, void *) = nullptr;
|
void *) = nullptr;
|
||||||
void *pStartAcquisition{nullptr};
|
void *pStartAcquisition{nullptr};
|
||||||
void (*acquisitionFinishedCallBack)(uint64_t, void *) = nullptr;
|
void (*acquisitionFinishedCallBack)(uint64_t, void *) = nullptr;
|
||||||
void *pAcquisitionFinished{nullptr};
|
void *pAcquisitionFinished{nullptr};
|
||||||
void (*rawDataReadyCallBack)(char *, char *, uint32_t, void *) = nullptr;
|
void (*rawDataReadyCallBack)(sls_receiver_header *, char *, size_t,
|
||||||
void (*rawDataModifyReadyCallBack)(char *, char *, uint32_t &,
|
void *) = nullptr;
|
||||||
|
void (*rawDataModifyReadyCallBack)(sls_receiver_header *, char *, size_t &,
|
||||||
void *) = nullptr;
|
void *) = nullptr;
|
||||||
void *pRawDataReady{nullptr};
|
void *pRawDataReady{nullptr};
|
||||||
|
|
||||||
|
@ -9,14 +9,12 @@
|
|||||||
|
|
||||||
#include "DataProcessor.h"
|
#include "DataProcessor.h"
|
||||||
#include "BinaryDataFile.h"
|
#include "BinaryDataFile.h"
|
||||||
#include "BinaryMasterFile.h"
|
|
||||||
#include "Fifo.h"
|
#include "Fifo.h"
|
||||||
#include "GeneralData.h"
|
#include "GeneralData.h"
|
||||||
#include "MasterAttributes.h"
|
#include "MasterAttributes.h"
|
||||||
|
#include "MasterFileUtility.h"
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
#include "HDF5DataFile.h"
|
#include "HDF5DataFile.h"
|
||||||
#include "HDF5MasterFile.h"
|
|
||||||
#include "HDF5VirtualFile.h"
|
|
||||||
#endif
|
#endif
|
||||||
#include "DataStreamer.h"
|
#include "DataStreamer.h"
|
||||||
#include "sls/container_utils.h"
|
#include "sls/container_utils.h"
|
||||||
@ -44,14 +42,10 @@ DataProcessor::DataProcessor(int index, detectorType detectorType, Fifo *fifo,
|
|||||||
ctbAnalogDataBytes_(ctbAnalogDataBytes), firstStreamerFrame_(false) {
|
ctbAnalogDataBytes_(ctbAnalogDataBytes), firstStreamerFrame_(false) {
|
||||||
|
|
||||||
LOG(logDEBUG) << "DataProcessor " << index << " created";
|
LOG(logDEBUG) << "DataProcessor " << index << " created";
|
||||||
|
|
||||||
memset((void *)&timerbegin_, 0, sizeof(timespec));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataProcessor::~DataProcessor() { DeleteFiles(); }
|
DataProcessor::~DataProcessor() { DeleteFiles(); }
|
||||||
|
|
||||||
/** getters */
|
|
||||||
|
|
||||||
bool DataProcessor::GetStartedFlag() const { return startedFlag_; }
|
bool DataProcessor::GetStartedFlag() const { return startedFlag_; }
|
||||||
|
|
||||||
void DataProcessor::SetFifo(Fifo *fifo) { fifo_ = fifo; }
|
void DataProcessor::SetFifo(Fifo *fifo) { fifo_ = fifo; }
|
||||||
@ -68,10 +62,8 @@ void DataProcessor::ResetParametersforNewAcquisition() {
|
|||||||
void DataProcessor::RecordFirstIndex(uint64_t fnum) {
|
void DataProcessor::RecordFirstIndex(uint64_t fnum) {
|
||||||
// listen to this fnum, later +1
|
// listen to this fnum, later +1
|
||||||
currentFrameIndex_ = fnum;
|
currentFrameIndex_ = fnum;
|
||||||
|
|
||||||
startedFlag_ = true;
|
startedFlag_ = true;
|
||||||
firstIndex_ = fnum;
|
firstIndex_ = fnum;
|
||||||
|
|
||||||
LOG(logDEBUG1) << index << " First Index:" << firstIndex_;
|
LOG(logDEBUG1) << index << " First Index:" << firstIndex_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,53 +74,26 @@ void DataProcessor::SetGeneralData(GeneralData *generalData) {
|
|||||||
void DataProcessor::CloseFiles() {
|
void DataProcessor::CloseFiles() {
|
||||||
if (dataFile_)
|
if (dataFile_)
|
||||||
dataFile_->CloseFile();
|
dataFile_->CloseFile();
|
||||||
if (masterFile_)
|
|
||||||
masterFile_->CloseFile();
|
|
||||||
#ifdef HDF5C
|
|
||||||
if (virtualFile_)
|
|
||||||
virtualFile_->CloseFile();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::DeleteFiles() {
|
void DataProcessor::DeleteFiles() {
|
||||||
CloseFiles();
|
CloseFiles();
|
||||||
if (dataFile_) {
|
|
||||||
delete dataFile_;
|
delete dataFile_;
|
||||||
dataFile_ = nullptr;
|
dataFile_ = nullptr;
|
||||||
}
|
|
||||||
if (masterFile_) {
|
|
||||||
delete masterFile_;
|
|
||||||
masterFile_ = nullptr;
|
|
||||||
}
|
|
||||||
#ifdef HDF5C
|
|
||||||
if (virtualFile_) {
|
|
||||||
delete virtualFile_;
|
|
||||||
virtualFile_ = nullptr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
void DataProcessor::SetupFileWriter(const bool filewriteEnable,
|
void DataProcessor::SetupFileWriter(const bool filewriteEnable,
|
||||||
const bool masterFilewriteEnable,
|
|
||||||
const fileFormat fileFormatType,
|
const fileFormat fileFormatType,
|
||||||
const int modulePos, std::mutex *hdf5Lib) {
|
std::mutex *hdf5LibMutex) {
|
||||||
DeleteFiles();
|
DeleteFiles();
|
||||||
if (filewriteEnable) {
|
if (filewriteEnable) {
|
||||||
switch (fileFormatType) {
|
switch (fileFormatType) {
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
case HDF5:
|
case HDF5:
|
||||||
dataFile_ = new HDF5DataFile(index, hdf5Lib);
|
dataFile_ = new HDF5DataFile(index, hdf5LibMutex);
|
||||||
if (modulePos == 0 && index == 0) {
|
|
||||||
if (masterFilewriteEnable) {
|
|
||||||
masterFile_ = new HDF5MasterFile(hdf5Lib);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case BINARY:
|
case BINARY:
|
||||||
dataFile_ = new BinaryDataFile(index);
|
dataFile_ = new BinaryDataFile(index);
|
||||||
if (modulePos == 0 && index == 0 && masterFilewriteEnable) {
|
|
||||||
masterFile_ = new BinaryMasterFile();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(
|
throw sls::RuntimeError(
|
||||||
@ -138,23 +103,17 @@ void DataProcessor::SetupFileWriter(const bool filewriteEnable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::CreateFirstFiles(
|
void DataProcessor::CreateFirstFiles(
|
||||||
MasterAttributes *attr, const std::string filePath,
|
const std::string &filePath, const std::string &fileNamePrefix,
|
||||||
const std::string fileNamePrefix, const uint64_t fileIndex,
|
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
||||||
const bool overWriteEnable, const bool silentMode, const int modulePos,
|
const int modulePos, const int numUnitsPerReadout,
|
||||||
const int numUnitsPerReadout, const uint32_t udpPortNumber,
|
const uint32_t udpPortNumber, const uint32_t maxFramesPerFile,
|
||||||
const uint32_t maxFramesPerFile, const uint64_t numImages,
|
const uint64_t numImages, const uint32_t dynamicRange,
|
||||||
const uint32_t dynamicRange, const bool detectorDataStream) {
|
const bool detectorDataStream) {
|
||||||
if (dataFile_ == nullptr) {
|
if (dataFile_ == nullptr) {
|
||||||
throw sls::RuntimeError("file object not contstructed");
|
throw sls::RuntimeError("file object not contstructed");
|
||||||
}
|
}
|
||||||
CloseFiles();
|
CloseFiles();
|
||||||
|
|
||||||
// master file write enabled
|
|
||||||
if (masterFile_) {
|
|
||||||
masterFile_->CreateMasterFile(filePath, fileNamePrefix, fileIndex,
|
|
||||||
overWriteEnable, silentMode, attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// deactivated (half module/ single port), dont write file
|
// deactivated (half module/ single port), dont write file
|
||||||
if ((!*activated_) || (!detectorDataStream)) {
|
if ((!*activated_) || (!detectorDataStream)) {
|
||||||
return;
|
return;
|
||||||
@ -189,21 +148,17 @@ uint32_t DataProcessor::GetFilesInAcquisition() const {
|
|||||||
return dataFile_->GetFilesInAcquisition();
|
return dataFile_->GetFilesInAcquisition();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::CreateVirtualFile(
|
std::array<std::string, 2> DataProcessor::CreateVirtualFile(
|
||||||
const std::string filePath, const std::string fileNamePrefix,
|
const std::string &filePath, const std::string &fileNamePrefix,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
||||||
const int modulePos, const int numUnitsPerReadout,
|
const int modulePos, const int numUnitsPerReadout,
|
||||||
const uint32_t maxFramesPerFile, const uint64_t numImages,
|
const uint32_t maxFramesPerFile, const uint64_t numImages,
|
||||||
const uint32_t dynamicRange, const int numModX, const int numModY,
|
const int numModX, const int numModY, const uint32_t dynamicRange,
|
||||||
std::mutex *hdf5Lib) {
|
std::mutex *hdf5LibMutex) {
|
||||||
|
|
||||||
if (virtualFile_) {
|
|
||||||
delete virtualFile_;
|
|
||||||
}
|
|
||||||
bool gotthard25um =
|
bool gotthard25um =
|
||||||
((detectorType_ == GOTTHARD || detectorType_ == GOTTHARD2) &&
|
((detectorType_ == GOTTHARD || detectorType_ == GOTTHARD2) &&
|
||||||
(numModX * numModY) == 2);
|
(numModX * numModY) == 2);
|
||||||
virtualFile_ = new HDF5VirtualFile(hdf5Lib, gotthard25um);
|
|
||||||
|
|
||||||
// maxframesperfile = 0 for infinite files
|
// maxframesperfile = 0 for infinite files
|
||||||
uint32_t framesPerFile =
|
uint32_t framesPerFile =
|
||||||
@ -213,76 +168,66 @@ void DataProcessor::CreateVirtualFile(
|
|||||||
// files (they exist anyway) assumption2: virtual file max frame index
|
// files (they exist anyway) assumption2: virtual file max frame index
|
||||||
// is from R0 P0 (difference from others when missing frames or for a
|
// is from R0 P0 (difference from others when missing frames or for a
|
||||||
// stop acquisition)
|
// stop acquisition)
|
||||||
virtualFile_->CreateVirtualFile(
|
return masterFileUtility::CreateVirtualHDF5File(
|
||||||
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
||||||
modulePos, numUnitsPerReadout, framesPerFile, numImages,
|
modulePos, numUnitsPerReadout, framesPerFile, numImages,
|
||||||
generalData_->nPixelsX, generalData_->nPixelsY, dynamicRange,
|
generalData_->nPixelsX, generalData_->nPixelsY, dynamicRange,
|
||||||
numFramesCaught_, numModX, numModY, dataFile_->GetPDataType(),
|
numFramesCaught_, numModX, numModY, dataFile_->GetPDataType(),
|
||||||
dataFile_->GetParameterNames(), dataFile_->GetParameterDataTypes());
|
dataFile_->GetParameterNames(), dataFile_->GetParameterDataTypes(),
|
||||||
|
hdf5LibMutex, gotthard25um);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::LinkDataInMasterFile(const bool silentMode) {
|
void DataProcessor::LinkFileInMaster(const std::string &masterFileName,
|
||||||
std::string fname, datasetName;
|
const std::string &virtualFileName,
|
||||||
if (virtualFile_) {
|
const std::string &virtualDatasetName,
|
||||||
auto res = virtualFile_->GetFileAndDatasetName();
|
const bool silentMode,
|
||||||
fname = res[0];
|
std::mutex *hdf5LibMutex) {
|
||||||
datasetName = res[1];
|
std::string fname{virtualFileName}, datasetName{virtualDatasetName};
|
||||||
} else {
|
// if no virtual file, link data file
|
||||||
|
if (virtualFileName.empty()) {
|
||||||
auto res = dataFile_->GetFileAndDatasetName();
|
auto res = dataFile_->GetFileAndDatasetName();
|
||||||
fname = res[0];
|
fname = res[0];
|
||||||
datasetName = res[1];
|
datasetName = res[1];
|
||||||
}
|
}
|
||||||
// link in master
|
masterFileUtility::LinkHDF5FileInMaster(masterFileName, fname, datasetName,
|
||||||
masterFile_->LinkDataFile(fname, datasetName,
|
dataFile_->GetParameterNames(),
|
||||||
dataFile_->GetParameterNames(), silentMode);
|
silentMode, hdf5LibMutex);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void DataProcessor::UpdateMasterFile(bool silentMode) {
|
std::string DataProcessor::CreateMasterFile(
|
||||||
if (masterFile_) {
|
const std::string &filePath, const std::string &fileNamePrefix,
|
||||||
// final attributes
|
const uint64_t fileIndex, const bool overWriteEnable, bool silentMode,
|
||||||
std::unique_ptr<MasterAttributes> masterAttributes;
|
const fileFormat fileFormatType, MasterAttributes *attr,
|
||||||
switch (detectorType_) {
|
std::mutex *hdf5LibMutex) {
|
||||||
case GOTTHARD:
|
|
||||||
masterAttributes = sls::make_unique<GotthardMasterAttributes>();
|
attr->framesInFile = numFramesCaught_;
|
||||||
break;
|
|
||||||
case JUNGFRAU:
|
std::unique_ptr<File> masterFile{nullptr};
|
||||||
masterAttributes = sls::make_unique<JungfrauMasterAttributes>();
|
switch (fileFormatType) {
|
||||||
break;
|
#ifdef HDF5C
|
||||||
case EIGER:
|
case HDF5:
|
||||||
masterAttributes = sls::make_unique<EigerMasterAttributes>();
|
return masterFileUtility::CreateMasterHDF5File(
|
||||||
break;
|
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
||||||
case MYTHEN3:
|
attr, hdf5LibMutex);
|
||||||
masterAttributes = sls::make_unique<Mythen3MasterAttributes>();
|
#endif
|
||||||
break;
|
case BINARY:
|
||||||
case GOTTHARD2:
|
return masterFileUtility::CreateMasterBinaryFile(
|
||||||
masterAttributes = sls::make_unique<Gotthard2MasterAttributes>();
|
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
||||||
break;
|
attr);
|
||||||
case MOENCH:
|
|
||||||
masterAttributes = sls::make_unique<MoenchMasterAttributes>();
|
|
||||||
break;
|
|
||||||
case CHIPTESTBOARD:
|
|
||||||
masterAttributes = sls::make_unique<CtbMasterAttributes>();
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(
|
throw sls::RuntimeError("Unknown file format (compile with hdf5 flags");
|
||||||
"Unknown detector type to set up master file attributes");
|
|
||||||
}
|
|
||||||
masterAttributes->framesInFile = numFramesCaught_;
|
|
||||||
masterFile_->UpdateMasterFile(masterAttributes.get(), silentMode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::ThreadExecution() {
|
void DataProcessor::ThreadExecution() {
|
||||||
char *buffer = nullptr;
|
char *buffer = nullptr;
|
||||||
fifo_->PopAddress(buffer);
|
fifo_->PopAddress(buffer);
|
||||||
LOG(logDEBUG5) << "DataProcessor " << index
|
LOG(logDEBUG5) << "DataProcessor " << index << ", " << std::hex
|
||||||
<< ", "
|
<< static_cast<void *>(buffer) << std::dec << ":" << buffer;
|
||||||
"pop 0x"
|
|
||||||
<< std::hex << (void *)(buffer) << std::dec << ":" << buffer;
|
|
||||||
|
|
||||||
// check dummy
|
// check dummy
|
||||||
auto numBytes = (uint32_t)(*((uint32_t *)buffer));
|
auto numBytes = *reinterpret_cast<uint32_t *>(buffer);
|
||||||
LOG(logDEBUG1) << "DataProcessor " << index << ", Numbytes:" << numBytes;
|
LOG(logDEBUG1) << "DataProcessor " << index << ", Numbytes:" << numBytes;
|
||||||
if (numBytes == DUMMY_PACKET_VALUE) {
|
if (numBytes == DUMMY_PACKET_VALUE) {
|
||||||
StopProcessing(buffer);
|
StopProcessing(buffer);
|
||||||
@ -327,7 +272,7 @@ void DataProcessor::StopProcessing(char *buf) {
|
|||||||
|
|
||||||
uint64_t DataProcessor::ProcessAnImage(char *buf) {
|
uint64_t DataProcessor::ProcessAnImage(char *buf) {
|
||||||
|
|
||||||
auto *rheader = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES);
|
auto *rheader = reinterpret_cast<sls_receiver_header *>(buf + FIFO_HEADER_NUMBYTES);
|
||||||
sls_detector_header header = rheader->detHeader;
|
sls_detector_header header = rheader->detHeader;
|
||||||
uint64_t fnum = header.frameNumber;
|
uint64_t fnum = header.frameNumber;
|
||||||
currentFrameIndex_ = fnum;
|
currentFrameIndex_ = fnum;
|
||||||
@ -361,16 +306,17 @@ uint64_t DataProcessor::ProcessAnImage(char *buf) {
|
|||||||
try {
|
try {
|
||||||
// normal call back
|
// normal call back
|
||||||
if (rawDataReadyCallBack != nullptr) {
|
if (rawDataReadyCallBack != nullptr) {
|
||||||
rawDataReadyCallBack((char *)rheader,
|
std::size_t dsize = *reinterpret_cast<uint32_t *>(buf);
|
||||||
|
rawDataReadyCallBack(rheader,
|
||||||
buf + FIFO_HEADER_NUMBYTES +
|
buf + FIFO_HEADER_NUMBYTES +
|
||||||
sizeof(sls_receiver_header),
|
sizeof(sls_receiver_header),
|
||||||
(uint32_t)(*((uint32_t *)buf)), pRawDataReady);
|
dsize, pRawDataReady);
|
||||||
}
|
}
|
||||||
|
|
||||||
// call back with modified size
|
// call back with modified size
|
||||||
else if (rawDataModifyReadyCallBack != nullptr) {
|
else if (rawDataModifyReadyCallBack != nullptr) {
|
||||||
auto revsize = (uint32_t)(*((uint32_t *)buf));
|
std::size_t revsize = *reinterpret_cast<uint32_t *>(buf);
|
||||||
rawDataModifyReadyCallBack((char *)rheader,
|
rawDataModifyReadyCallBack(rheader,
|
||||||
buf + FIFO_HEADER_NUMBYTES +
|
buf + FIFO_HEADER_NUMBYTES +
|
||||||
sizeof(sls_receiver_header),
|
sizeof(sls_receiver_header),
|
||||||
revsize, pRawDataReady);
|
revsize, pRawDataReady);
|
||||||
@ -414,14 +360,15 @@ bool DataProcessor::CheckTimer() {
|
|||||||
struct timespec end;
|
struct timespec end;
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
|
|
||||||
LOG(logDEBUG1) << index << " Timer elapsed time:"
|
auto elapsed_s = (end.tv_sec - timerbegin_.tv_sec) +
|
||||||
<< ((end.tv_sec - timerbegin_.tv_sec) +
|
(end.tv_nsec - timerbegin_.tv_nsec) / 1e9;
|
||||||
(end.tv_nsec - timerbegin_.tv_nsec) / 1000000000.0)
|
double timer_s = *streamingTimerInMs_ / 1e3;
|
||||||
|
|
||||||
|
LOG(logDEBUG1) << index << " Timer elapsed time:" << elapsed_s
|
||||||
<< " seconds";
|
<< " seconds";
|
||||||
|
|
||||||
// still less than streaming timer, keep waiting
|
// still less than streaming timer, keep waiting
|
||||||
if (((end.tv_sec - timerbegin_.tv_sec) +
|
if (elapsed_s < timer_s)
|
||||||
(end.tv_nsec - timerbegin_.tv_nsec) / 1000000000.0) <
|
|
||||||
((double)*streamingTimerInMs_ / 1000.00))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// restart timer
|
// restart timer
|
||||||
@ -438,15 +385,14 @@ bool DataProcessor::CheckCount() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::registerCallBackRawDataReady(void (*func)(char *, char *,
|
void DataProcessor::registerCallBackRawDataReady(
|
||||||
uint32_t, void *),
|
void (*func)(sls_receiver_header *, char *, size_t, void *), void *arg) {
|
||||||
void *arg) {
|
|
||||||
rawDataReadyCallBack = func;
|
rawDataReadyCallBack = func;
|
||||||
pRawDataReady = arg;
|
pRawDataReady = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::registerCallBackRawDataModifyReady(
|
void DataProcessor::registerCallBackRawDataModifyReady(
|
||||||
void (*func)(char *, char *, uint32_t &, void *), void *arg) {
|
void (*func)(sls_receiver_header *, char *, size_t &, void *), void *arg) {
|
||||||
rawDataModifyReadyCallBack = func;
|
rawDataModifyReadyCallBack = func;
|
||||||
pRawDataReady = arg;
|
pRawDataReady = arg;
|
||||||
}
|
}
|
||||||
@ -455,7 +401,8 @@ void DataProcessor::PadMissingPackets(char *buf) {
|
|||||||
LOG(logDEBUG) << index << ": Padding Missing Packets";
|
LOG(logDEBUG) << index << ": Padding Missing Packets";
|
||||||
|
|
||||||
uint32_t pperFrame = generalData_->packetsPerFrame;
|
uint32_t pperFrame = generalData_->packetsPerFrame;
|
||||||
auto *header = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES);
|
auto *header =
|
||||||
|
reinterpret_cast<sls_receiver_header *>(buf + FIFO_HEADER_NUMBYTES);
|
||||||
uint32_t nmissing = pperFrame - header->detHeader.packetNumber;
|
uint32_t nmissing = pperFrame - header->detHeader.packetNumber;
|
||||||
sls_bitset pmask = header->packetsMask;
|
sls_bitset pmask = header->packetsMask;
|
||||||
|
|
||||||
@ -528,7 +475,7 @@ void DataProcessor::RearrangeDbitData(char *buf) {
|
|||||||
|
|
||||||
// ceil as numResult8Bits could be decimal
|
// ceil as numResult8Bits could be decimal
|
||||||
const int numResult8Bits =
|
const int numResult8Bits =
|
||||||
ceil((double)(numSamples * (*ctbDbitList_).size()) / 8.00);
|
ceil((numSamples * (*ctbDbitList_).size()) / 8.00);
|
||||||
std::vector<uint8_t> result(numResult8Bits);
|
std::vector<uint8_t> result(numResult8Bits);
|
||||||
uint8_t *dest = &result[0];
|
uint8_t *dest = &result[0];
|
||||||
|
|
||||||
@ -544,7 +491,7 @@ void DataProcessor::RearrangeDbitData(char *buf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// loop through the frame digital data
|
// loop through the frame digital data
|
||||||
for (auto ptr = source; ptr < (source + numSamples);) {
|
for (auto *ptr = source; ptr < (source + numSamples);) {
|
||||||
// get selected bit from each 8 bit
|
// get selected bit from each 8 bit
|
||||||
uint8_t bit = (*ptr++ >> bi) & 1;
|
uint8_t bit = (*ptr++ >> bi) & 1;
|
||||||
*dest |= bit << bitoffset;
|
*dest |= bit << bitoffset;
|
||||||
|
@ -45,12 +45,11 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
void CloseFiles();
|
void CloseFiles();
|
||||||
void DeleteFiles();
|
void DeleteFiles();
|
||||||
void SetupFileWriter(const bool filewriteEnable,
|
void SetupFileWriter(const bool filewriteEnable,
|
||||||
const bool masterFilewriteEnable,
|
const fileFormat fileFormatType,
|
||||||
const fileFormat fileFormatType, const int modulePos,
|
std::mutex *hdf5LibMutex);
|
||||||
std::mutex *hdf5Lib);
|
|
||||||
|
|
||||||
void CreateFirstFiles(MasterAttributes *attr, const std::string filePath,
|
void CreateFirstFiles(const std::string &filePath,
|
||||||
const std::string fileNamePrefix,
|
const std::string &fileNamePrefix,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable,
|
const uint64_t fileIndex, const bool overWriteEnable,
|
||||||
const bool silentMode, const int modulePos,
|
const bool silentMode, const int modulePos,
|
||||||
const int numUnitsPerReadout,
|
const int numUnitsPerReadout,
|
||||||
@ -60,40 +59,36 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
const bool detectorDataStream);
|
const bool detectorDataStream);
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
uint32_t GetFilesInAcquisition() const;
|
uint32_t GetFilesInAcquisition() const;
|
||||||
void CreateVirtualFile(const std::string filePath,
|
std::array<std::string, 2> CreateVirtualFile(
|
||||||
const std::string fileNamePrefix,
|
const std::string &filePath, const std::string &fileNamePrefix,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable,
|
const uint64_t fileIndex, const bool overWriteEnable,
|
||||||
const bool silentMode, const int modulePos,
|
const bool silentMode, const int modulePos,
|
||||||
const int numUnitsPerReadout,
|
const int numUnitsPerReadout, const uint32_t maxFramesPerFile,
|
||||||
const uint32_t maxFramesPerFile,
|
const uint64_t numImages, const int numModX, const int numModY,
|
||||||
const uint64_t numImages,
|
const uint32_t dynamicRange, std::mutex *hdf5LibMutex);
|
||||||
const uint32_t dynamicRange, const int numModX,
|
void LinkFileInMaster(const std::string &masterFileName,
|
||||||
const int numModY, std::mutex *hdf5Lib);
|
const std::string &virtualFileName,
|
||||||
void LinkDataInMasterFile(const bool silentMode);
|
const std::string &virtualDatasetName,
|
||||||
|
const bool silentMode, std::mutex *hdf5LibMutex);
|
||||||
#endif
|
#endif
|
||||||
void UpdateMasterFile(bool silentMode);
|
|
||||||
/**
|
std::string CreateMasterFile(const std::string &filePath,
|
||||||
* Call back for raw data
|
const std::string &fileNamePrefix,
|
||||||
* args to raw data ready callback are
|
const uint64_t fileIndex,
|
||||||
* sls_receiver_header frame metadata
|
const bool overWriteEnable, bool silentMode,
|
||||||
* dataPointer is the pointer to the data
|
const fileFormat fileFormatType,
|
||||||
* dataSize in bytes is the size of the data in bytes.
|
MasterAttributes *attr,
|
||||||
*/
|
std::mutex *hdf5LibMutex);
|
||||||
void registerCallBackRawDataReady(void (*func)(char *, char *, uint32_t,
|
|
||||||
void *),
|
/** params: sls_receiver_header pointer, pointer to data, image size */
|
||||||
|
void registerCallBackRawDataReady(void (*func)(sls_receiver_header *,
|
||||||
|
char *, size_t, void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
/**
|
/** params: sls_receiver_header pointer, pointer to data, reference to image size */
|
||||||
* Call back for raw data (modified)
|
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
|
||||||
* args to raw data ready callback are
|
char *, size_t &,
|
||||||
* sls_receiver_header frame metadata
|
void *),
|
||||||
* dataPointer is the pointer to the data
|
|
||||||
* revDatasize is the reference of data size in bytes.
|
|
||||||
* Can be modified to the new size to be written/streamed. (only smaller
|
|
||||||
* value).
|
|
||||||
*/
|
|
||||||
void registerCallBackRawDataModifyReady(void (*func)(char *, char *,
|
|
||||||
uint32_t &, void *),
|
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -160,7 +155,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
uint32_t *streamingTimerInMs_;
|
uint32_t *streamingTimerInMs_;
|
||||||
uint32_t *streamingStartFnum_;
|
uint32_t *streamingStartFnum_;
|
||||||
uint32_t currentFreqCount_{0};
|
uint32_t currentFreqCount_{0};
|
||||||
struct timespec timerbegin_;
|
struct timespec timerbegin_{};
|
||||||
bool *framePadding_;
|
bool *framePadding_;
|
||||||
std::vector<int> *ctbDbitList_;
|
std::vector<int> *ctbDbitList_;
|
||||||
int *ctbDbitOffset_;
|
int *ctbDbitOffset_;
|
||||||
@ -179,10 +174,6 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
bool firstStreamerFrame_{false};
|
bool firstStreamerFrame_{false};
|
||||||
|
|
||||||
File *dataFile_{nullptr};
|
File *dataFile_{nullptr};
|
||||||
File *masterFile_{nullptr};
|
|
||||||
#ifdef HDF5C
|
|
||||||
File *virtualFile_{nullptr};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// call back
|
// call back
|
||||||
/**
|
/**
|
||||||
@ -192,7 +183,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* dataPointer is the pointer to the data
|
* dataPointer is the pointer to the data
|
||||||
* dataSize in bytes is the size of the data in bytes.
|
* dataSize in bytes is the size of the data in bytes.
|
||||||
*/
|
*/
|
||||||
void (*rawDataReadyCallBack)(char *, char *, uint32_t, void *) = nullptr;
|
void (*rawDataReadyCallBack)(sls_receiver_header *, char *, size_t,
|
||||||
|
void *) = nullptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call back for raw data (modified)
|
* Call back for raw data (modified)
|
||||||
@ -202,7 +194,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* revDatasize is the reference of data size in bytes. Can be modified to
|
* revDatasize is the reference of data size in bytes. Can be modified to
|
||||||
* the new size to be written/streamed. (only smaller value).
|
* the new size to be written/streamed. (only smaller value).
|
||||||
*/
|
*/
|
||||||
void (*rawDataModifyReadyCallBack)(char *, char *, uint32_t &,
|
void (*rawDataModifyReadyCallBack)(sls_receiver_header *, char *, size_t &,
|
||||||
void *) = nullptr;
|
void *) = nullptr;
|
||||||
|
|
||||||
void *pRawDataReady{nullptr};
|
void *pRawDataReady{nullptr};
|
||||||
|
@ -17,12 +17,11 @@
|
|||||||
const std::string DataStreamer::TypeName = "DataStreamer";
|
const std::string DataStreamer::TypeName = "DataStreamer";
|
||||||
|
|
||||||
DataStreamer::DataStreamer(int ind, Fifo *f, uint32_t *dr, ROI *r, uint64_t *fi,
|
DataStreamer::DataStreamer(int ind, Fifo *f, uint32_t *dr, ROI *r, uint64_t *fi,
|
||||||
bool fr, slsDetectorDefs::xy nm, bool *qe,
|
bool fr, slsDetectorDefs::xy np, bool *qe,
|
||||||
uint64_t *tot)
|
uint64_t *tot)
|
||||||
: ThreadObject(ind, TypeName), fifo(f), dynamicRange(dr), roi(r),
|
: ThreadObject(ind, TypeName), fifo(f), dynamicRange(dr), roi(r),
|
||||||
fileIndex(fi), flipRows(fr), quadEnable(qe), totalNumFrames(tot) {
|
fileIndex(fi), flipRows(fr), numPorts(np), quadEnable(qe),
|
||||||
numMods.x = nm.x;
|
totalNumFrames(tot) {
|
||||||
numMods.y = nm.y;
|
|
||||||
|
|
||||||
LOG(logDEBUG) << "DataStreamer " << ind << " created";
|
LOG(logDEBUG) << "DataStreamer " << ind << " created";
|
||||||
}
|
}
|
||||||
@ -63,10 +62,7 @@ void DataStreamer::RecordFirstIndex(uint64_t fnum, char *buf) {
|
|||||||
|
|
||||||
void DataStreamer::SetGeneralData(GeneralData *g) { generalData = g; }
|
void DataStreamer::SetGeneralData(GeneralData *g) { generalData = g; }
|
||||||
|
|
||||||
void DataStreamer::SetNumberofModules(xy nm) {
|
void DataStreamer::SetNumberofPorts(xy np) { numPorts = np; }
|
||||||
numMods.x = nm.x;
|
|
||||||
numMods.y = nm.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataStreamer::SetFlipRows(bool fd) { flipRows = fd; }
|
void DataStreamer::SetFlipRows(bool fd) { flipRows = fd; }
|
||||||
|
|
||||||
@ -220,8 +216,8 @@ int DataStreamer::SendHeader(sls_receiver_header *rheader, uint32_t size,
|
|||||||
|
|
||||||
zHeader.dynamicRange = *dynamicRange;
|
zHeader.dynamicRange = *dynamicRange;
|
||||||
zHeader.fileIndex = *fileIndex;
|
zHeader.fileIndex = *fileIndex;
|
||||||
zHeader.ndetx = numMods.x;
|
zHeader.ndetx = numPorts.x;
|
||||||
zHeader.ndety = numMods.y;
|
zHeader.ndety = numPorts.y;
|
||||||
zHeader.npixelsx = nx;
|
zHeader.npixelsx = nx;
|
||||||
zHeader.npixelsy = ny;
|
zHeader.npixelsy = ny;
|
||||||
zHeader.imageSize = size;
|
zHeader.imageSize = size;
|
||||||
|
@ -33,12 +33,12 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* @param r roi
|
* @param r roi
|
||||||
* @param fi pointer to file index
|
* @param fi pointer to file index
|
||||||
* @param fr flip rows
|
* @param fr flip rows
|
||||||
* @param nm number of modules in each dimension
|
* @param nm number of ports in each dimension
|
||||||
* @param qe pointer to quad Enable
|
* @param qe pointer to quad Enable
|
||||||
* @param tot pointer to total number of frames
|
* @param tot pointer to total number of frames
|
||||||
*/
|
*/
|
||||||
DataStreamer(int ind, Fifo *f, uint32_t *dr, ROI *r, uint64_t *fi, bool fr,
|
DataStreamer(int ind, Fifo *f, uint32_t *dr, ROI *r, uint64_t *fi, bool fr,
|
||||||
xy nm, bool *qe, uint64_t *tot);
|
xy np, bool *qe, uint64_t *tot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
@ -46,39 +46,11 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
*/
|
*/
|
||||||
~DataStreamer();
|
~DataStreamer();
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Fifo pointer to the one given
|
|
||||||
* @param f address of Fifo pointer
|
|
||||||
*/
|
|
||||||
void SetFifo(Fifo *f);
|
void SetFifo(Fifo *f);
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset parameters for new acquisition
|
|
||||||
*/
|
|
||||||
void ResetParametersforNewAcquisition(const std::string &fname);
|
void ResetParametersforNewAcquisition(const std::string &fname);
|
||||||
|
|
||||||
/**
|
|
||||||
* Set GeneralData pointer to the one given
|
|
||||||
* @param g address of GeneralData (Detector Data) pointer
|
|
||||||
*/
|
|
||||||
void SetGeneralData(GeneralData *g);
|
void SetGeneralData(GeneralData *g);
|
||||||
|
void SetNumberofPorts(xy np);
|
||||||
/**
|
|
||||||
* Set number of detectors
|
|
||||||
* @param nm number of modules/ports in both dimensions
|
|
||||||
*/
|
|
||||||
void SetNumberofModules(xy nm);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Flipped rows
|
|
||||||
* @param fd flip rows enable
|
|
||||||
*/
|
|
||||||
void SetFlipRows(bool fd);
|
void SetFlipRows(bool fd);
|
||||||
|
|
||||||
/**
|
|
||||||
* Set additional json header
|
|
||||||
* @param json additional json header
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
SetAdditionalJsonHeader(const std::map<std::string, std::string> &json);
|
SetAdditionalJsonHeader(const std::map<std::string, std::string> &json);
|
||||||
|
|
||||||
@ -143,34 +115,16 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
int SendHeader(sls_receiver_header *rheader, uint32_t size = 0,
|
int SendHeader(sls_receiver_header *rheader, uint32_t size = 0,
|
||||||
uint32_t nx = 0, uint32_t ny = 0, bool dummy = true);
|
uint32_t nx = 0, uint32_t ny = 0, bool dummy = true);
|
||||||
|
|
||||||
/** type of thread */
|
|
||||||
static const std::string TypeName;
|
static const std::string TypeName;
|
||||||
|
|
||||||
/** GeneralData (Detector Data) object */
|
|
||||||
const GeneralData *generalData{nullptr};
|
const GeneralData *generalData{nullptr};
|
||||||
|
|
||||||
/** Fifo structure */
|
|
||||||
Fifo *fifo;
|
Fifo *fifo;
|
||||||
|
|
||||||
/** ZMQ Socket - Receiver to Client */
|
|
||||||
ZmqSocket *zmqSocket{nullptr};
|
ZmqSocket *zmqSocket{nullptr};
|
||||||
|
|
||||||
/** Pointer to dynamic range */
|
|
||||||
uint32_t *dynamicRange;
|
uint32_t *dynamicRange;
|
||||||
|
|
||||||
/** ROI */
|
|
||||||
ROI *roi;
|
ROI *roi;
|
||||||
|
|
||||||
/** adc Configured */
|
|
||||||
int adcConfigured{-1};
|
int adcConfigured{-1};
|
||||||
|
|
||||||
/** Pointer to file index */
|
|
||||||
uint64_t *fileIndex;
|
uint64_t *fileIndex;
|
||||||
|
|
||||||
/** flip rows */
|
|
||||||
bool flipRows;
|
bool flipRows;
|
||||||
|
|
||||||
/** additional json header */
|
|
||||||
std::map<std::string, std::string> additionalJsonHeader;
|
std::map<std::string, std::string> additionalJsonHeader;
|
||||||
|
|
||||||
/** Used by streamer thread to update local copy (reduce number of locks
|
/** Used by streamer thread to update local copy (reduce number of locks
|
||||||
@ -189,18 +143,12 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
/** Frame Number of First Frame */
|
/** Frame Number of First Frame */
|
||||||
uint64_t firstIndex{0};
|
uint64_t firstIndex{0};
|
||||||
|
|
||||||
/* File name to stream */
|
|
||||||
std::string fileNametoStream;
|
std::string fileNametoStream;
|
||||||
|
|
||||||
/** Complete buffer used for roi, eg. shortGotthard */
|
/** Complete buffer used for roi, eg. shortGotthard */
|
||||||
char *completeBuffer{nullptr};
|
char *completeBuffer{nullptr};
|
||||||
|
|
||||||
/** Number of Modules in X and Y dimension */
|
xy numPorts{1, 1};
|
||||||
xy numMods{1, 1};
|
|
||||||
|
|
||||||
/** Quad Enable */
|
|
||||||
bool *quadEnable;
|
bool *quadEnable;
|
||||||
|
|
||||||
/** Total number of frames */
|
|
||||||
uint64_t *totalNumFrames;
|
uint64_t *totalNumFrames;
|
||||||
};
|
};
|
||||||
|
@ -60,20 +60,6 @@ class File : private virtual slsDetectorDefs {
|
|||||||
return std::vector<DataType>{};
|
return std::vector<DataType>{};
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void CreateVirtualFile(
|
|
||||||
const std::string 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 uint64_t numImages, const uint32_t nPixelsX,
|
|
||||||
const uint32_t nPixelsY, const uint32_t dynamicRange,
|
|
||||||
const uint64_t numImagesCaught, const int numModX, const int numModY,
|
|
||||||
const DataType dataType, const std::vector<std::string> parameterNames,
|
|
||||||
const std::vector<DataType> parameterDataTypes) {
|
|
||||||
LOG(logERROR) << "This is a generic function CreateVirtualFile that "
|
|
||||||
"should be overloaded by a derived class";
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void CreateFirstHDF5DataFile(
|
virtual void CreateFirstHDF5DataFile(
|
||||||
const std::string filePath, const std::string fileNamePrefix,
|
const std::string filePath, const std::string fileNamePrefix,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable,
|
const uint64_t fileIndex, const bool overWriteEnable,
|
||||||
@ -85,13 +71,6 @@ class File : private virtual slsDetectorDefs {
|
|||||||
LOG(logERROR) << "This is a generic function CreateFirstDataFile that "
|
LOG(logERROR) << "This is a generic function CreateFirstDataFile that "
|
||||||
"should be overloaded by a derived class";
|
"should be overloaded by a derived class";
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void LinkDataFile(std::string dataFilename, std::string dataSetname,
|
|
||||||
const std::vector<std::string> parameterNames,
|
|
||||||
const bool silentMode) {
|
|
||||||
LOG(logERROR) << "This is a generic function LinkDataFile that "
|
|
||||||
"should be overloaded by a derived class";
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
virtual void CreateFirstBinaryDataFile(
|
virtual void CreateFirstBinaryDataFile(
|
||||||
const std::string filePath, const std::string fileNamePrefix,
|
const std::string filePath, const std::string fileNamePrefix,
|
||||||
@ -103,27 +82,9 @@ class File : private virtual slsDetectorDefs {
|
|||||||
"should be overloaded by a derived class";
|
"should be overloaded by a derived class";
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void CreateMasterFile(const std::string filePath,
|
|
||||||
const std::string fileNamePrefix,
|
|
||||||
const uint64_t fileIndex,
|
|
||||||
const bool overWriteEnable,
|
|
||||||
const bool silentMode,
|
|
||||||
MasterAttributes *attr) {
|
|
||||||
LOG(logERROR) << "This is a generic function CreateMasterFile that "
|
|
||||||
"should be overloaded by a derived class";
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual void WriteToFile(char *buffer, const int buffersize,
|
virtual void WriteToFile(char *buffer, const int buffersize,
|
||||||
const uint64_t currentFrameNumber,
|
const uint64_t currentFrameNumber,
|
||||||
const uint32_t numPacketsCaught) {
|
const uint32_t numPacketsCaught) = 0;
|
||||||
LOG(logERROR) << "This is a generic function WriteToFile that "
|
|
||||||
"should be overloaded by a derived class";
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual void UpdateMasterFile(MasterAttributes *attr, bool silentMode) {
|
|
||||||
LOG(logERROR) << "This is a generic function UpdateMasterFile that "
|
|
||||||
"should be overloaded by a derived class";
|
|
||||||
};
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
slsDetectorDefs::fileFormat format_;
|
slsDetectorDefs::fileFormat format_;
|
||||||
|
@ -62,6 +62,7 @@ class GeneralData {
|
|||||||
uint32_t adcEnableMaskOneGiga{BIT32_MASK};
|
uint32_t adcEnableMaskOneGiga{BIT32_MASK};
|
||||||
uint32_t adcEnableMaskTenGiga{BIT32_MASK};
|
uint32_t adcEnableMaskTenGiga{BIT32_MASK};
|
||||||
slsDetectorDefs::ROI roi{};
|
slsDetectorDefs::ROI roi{};
|
||||||
|
uint32_t counterMask{0};
|
||||||
|
|
||||||
GeneralData(){};
|
GeneralData(){};
|
||||||
virtual ~GeneralData(){};
|
virtual ~GeneralData(){};
|
||||||
@ -122,8 +123,8 @@ class GeneralData {
|
|||||||
ThrowGenericError("SetNumberofInterfaces");
|
ThrowGenericError("SetNumberofInterfaces");
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void SetNumberofCounters(const int n) {
|
virtual void SetCounterMask(const int n) {
|
||||||
ThrowGenericError("SetNumberofCounters");
|
ThrowGenericError("setCounterMask");
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual int GetNumberOfAnalogDatabytes() {
|
virtual int GetNumberOfAnalogDatabytes() {
|
||||||
@ -359,13 +360,12 @@ class JungfrauData : public GeneralData {
|
|||||||
|
|
||||||
class Mythen3Data : public GeneralData {
|
class Mythen3Data : public GeneralData {
|
||||||
private:
|
private:
|
||||||
int ncounters;
|
int ncounters{0};
|
||||||
const int NCHAN = 1280;
|
const int NCHAN = 1280;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Mythen3Data() {
|
Mythen3Data() {
|
||||||
myDetectorType = slsDetectorDefs::MYTHEN3;
|
myDetectorType = slsDetectorDefs::MYTHEN3;
|
||||||
ncounters = 3;
|
|
||||||
nPixelsY = 1;
|
nPixelsY = 1;
|
||||||
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
||||||
maxFramesPerFile = MYTHEN3_MAX_FRAMES_PER_FILE;
|
maxFramesPerFile = MYTHEN3_MAX_FRAMES_PER_FILE;
|
||||||
@ -376,6 +376,7 @@ class Mythen3Data : public GeneralData {
|
|||||||
defaultUdpSocketBufferSize = (1000 * 1024 * 1024);
|
defaultUdpSocketBufferSize = (1000 * 1024 * 1024);
|
||||||
dynamicRange = 32;
|
dynamicRange = 32;
|
||||||
tengigaEnable = true;
|
tengigaEnable = true;
|
||||||
|
SetCounterMask(0x7);
|
||||||
UpdateImageSize();
|
UpdateImageSize();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -389,7 +390,13 @@ class Mythen3Data : public GeneralData {
|
|||||||
UpdateImageSize();
|
UpdateImageSize();
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void SetNumberofCounters(const int n) {
|
virtual void SetCounterMask(const int mask) {
|
||||||
|
int n = __builtin_popcount(mask);
|
||||||
|
if (n < 1 || n > 3) {
|
||||||
|
throw sls::RuntimeError("Invalid number of counters " +
|
||||||
|
std::to_string(n) + ". Expected 1-3.");
|
||||||
|
}
|
||||||
|
counterMask = mask;
|
||||||
ncounters = n;
|
ncounters = n;
|
||||||
UpdateImageSize();
|
UpdateImageSize();
|
||||||
};
|
};
|
||||||
|
@ -128,7 +128,7 @@ void HDF5DataFile::CreateFirstHDF5DataFile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HDF5DataFile::CreateFile() {
|
void HDF5DataFile::CreateFile() {
|
||||||
|
numFramesInFile_ = 0;
|
||||||
numFilesInAcquisition_++;
|
numFilesInAcquisition_++;
|
||||||
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
@ -237,7 +237,7 @@ void HDF5DataFile::WriteToFile(char *buffer, const int buffersize,
|
|||||||
++subFileIndex_;
|
++subFileIndex_;
|
||||||
CreateFile();
|
CreateFile();
|
||||||
}
|
}
|
||||||
numFramesInFile_++;
|
++numFramesInFile_;
|
||||||
|
|
||||||
// extend dataset (when receiver start followed by many status starts
|
// extend dataset (when receiver start followed by many status starts
|
||||||
// (jungfrau)))
|
// (jungfrau)))
|
||||||
|
@ -1,162 +0,0 @@
|
|||||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
#include "HDF5MasterFile.h"
|
|
||||||
#include "MasterAttributes.h"
|
|
||||||
|
|
||||||
HDF5MasterFile::HDF5MasterFile(std::mutex *hdf5Lib)
|
|
||||||
: File(HDF5), hdf5Lib_(hdf5Lib) {}
|
|
||||||
|
|
||||||
HDF5MasterFile::~HDF5MasterFile() { CloseFile(); }
|
|
||||||
|
|
||||||
void HDF5MasterFile::CloseFile() {
|
|
||||||
std::lock_guard<std::mutex> lock(*hdf5Lib_);
|
|
||||||
try {
|
|
||||||
Exception::dontPrint(); // to handle errors
|
|
||||||
if (fd_) {
|
|
||||||
fd_->close();
|
|
||||||
delete fd_;
|
|
||||||
fd_ = nullptr;
|
|
||||||
}
|
|
||||||
} catch (const Exception &error) {
|
|
||||||
LOG(logERROR) << "Could not close master HDF5 handles";
|
|
||||||
error.printErrorStack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HDF5MasterFile::LinkDataFile(std::string dataFilename,
|
|
||||||
std::string dataSetname,
|
|
||||||
const std::vector<std::string> parameterNames,
|
|
||||||
const bool silentMode) {
|
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(*hdf5Lib_);
|
|
||||||
try {
|
|
||||||
Exception::dontPrint(); // to handle errors
|
|
||||||
|
|
||||||
FileAccPropList flist;
|
|
||||||
flist.setFcloseDegree(H5F_CLOSE_STRONG);
|
|
||||||
|
|
||||||
// open master file
|
|
||||||
H5File masterfd(fileName_.c_str(), H5F_ACC_RDWR,
|
|
||||||
FileCreatPropList::DEFAULT, flist);
|
|
||||||
|
|
||||||
// open data file
|
|
||||||
H5File fd(dataFilename.c_str(), H5F_ACC_RDONLY,
|
|
||||||
FileCreatPropList::DEFAULT, flist);
|
|
||||||
|
|
||||||
// create link for data dataset
|
|
||||||
DataSet dset = fd.openDataSet(dataSetname.c_str());
|
|
||||||
std::string linkname = std::string("/entry/data/") + dataSetname;
|
|
||||||
if (H5Lcreate_external(dataFilename.c_str(), dataSetname.c_str(),
|
|
||||||
masterfd.getLocId(), linkname.c_str(),
|
|
||||||
H5P_DEFAULT, H5P_DEFAULT) < 0) {
|
|
||||||
throw sls::RuntimeError(
|
|
||||||
"Could not create link to data dataset in master");
|
|
||||||
}
|
|
||||||
|
|
||||||
// create link for parameter datasets
|
|
||||||
for (unsigned int i = 0; i < parameterNames.size(); ++i) {
|
|
||||||
DataSet pDset = fd.openDataSet(parameterNames[i].c_str());
|
|
||||||
linkname = std::string("/entry/data/") + parameterNames[i];
|
|
||||||
if (H5Lcreate_external(dataFilename.c_str(),
|
|
||||||
parameterNames[i].c_str(),
|
|
||||||
masterfd.getLocId(), linkname.c_str(),
|
|
||||||
H5P_DEFAULT, H5P_DEFAULT) < 0) {
|
|
||||||
throw sls::RuntimeError(
|
|
||||||
"Could not create link to parameter dataset in master");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fd.close();
|
|
||||||
masterfd.close();
|
|
||||||
} catch (const Exception &error) {
|
|
||||||
error.printErrorStack();
|
|
||||||
CloseFile();
|
|
||||||
throw sls::RuntimeError("Could not link in master hdf5 file");
|
|
||||||
}
|
|
||||||
if (!silentMode) {
|
|
||||||
LOG(logINFO) << "Linked in Master File: " << dataFilename;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HDF5MasterFile::CreateMasterFile(const std::string 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 << ".h5";
|
|
||||||
fileName_ = os.str();
|
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(*hdf5Lib_);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Exception::dontPrint(); // to handle errors
|
|
||||||
|
|
||||||
FileAccPropList flist;
|
|
||||||
flist.setFcloseDegree(H5F_CLOSE_STRONG);
|
|
||||||
fd_ = nullptr;
|
|
||||||
if (!(overWriteEnable))
|
|
||||||
fd_ = new H5File(fileName_.c_str(), H5F_ACC_EXCL,
|
|
||||||
FileCreatPropList::DEFAULT, flist);
|
|
||||||
else
|
|
||||||
fd_ = new H5File(fileName_.c_str(), H5F_ACC_TRUNC,
|
|
||||||
FileCreatPropList::DEFAULT, flist);
|
|
||||||
|
|
||||||
// attributes - version
|
|
||||||
double dValue = HDF5_WRITER_VERSION;
|
|
||||||
DataSpace dataspace_attr = DataSpace(H5S_SCALAR);
|
|
||||||
Attribute attribute = fd_->createAttribute(
|
|
||||||
"version", PredType::NATIVE_DOUBLE, dataspace_attr);
|
|
||||||
attribute.write(PredType::NATIVE_DOUBLE, &dValue);
|
|
||||||
|
|
||||||
// Create a group in the file
|
|
||||||
Group group1(fd_->createGroup("entry"));
|
|
||||||
Group group2(group1.createGroup("data"));
|
|
||||||
Group group3(group1.createGroup("instrument"));
|
|
||||||
Group group4(group3.createGroup("beam"));
|
|
||||||
Group group5(group3.createGroup("detector"));
|
|
||||||
Group group6(group1.createGroup("sample"));
|
|
||||||
|
|
||||||
// TODO find a way to get complete group link
|
|
||||||
attrGroupName_ = "/entry/instrument/detector";
|
|
||||||
|
|
||||||
attr->WriteMasterHDF5Attributes(fd_, &group5);
|
|
||||||
fd_->close();
|
|
||||||
|
|
||||||
} catch (const Exception &error) {
|
|
||||||
error.printErrorStack();
|
|
||||||
CloseFile();
|
|
||||||
throw sls::RuntimeError(
|
|
||||||
"Could not create/overwrite master HDF5 handles");
|
|
||||||
}
|
|
||||||
if (!silentMode) {
|
|
||||||
LOG(logINFO) << "Master File: " << fileName_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HDF5MasterFile::UpdateMasterFile(MasterAttributes *attr, bool silentMode) {
|
|
||||||
std::lock_guard<std::mutex> lock(*hdf5Lib_);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Exception::dontPrint(); // to handle errors
|
|
||||||
FileAccPropList flist;
|
|
||||||
flist.setFcloseDegree(H5F_CLOSE_STRONG);
|
|
||||||
fd_ = new H5File(fileName_.c_str(), H5F_ACC_RDWR,
|
|
||||||
FileCreatPropList::DEFAULT, flist);
|
|
||||||
|
|
||||||
Group group = fd_->openGroup(attrGroupName_.c_str());
|
|
||||||
attr->WriteFinalHDF5Attributes(fd_, &group);
|
|
||||||
fd_->close();
|
|
||||||
|
|
||||||
} catch (const Exception &error) {
|
|
||||||
error.printErrorStack();
|
|
||||||
CloseFile();
|
|
||||||
throw sls::RuntimeError(
|
|
||||||
"Could not create/overwrite master HDF5 handles");
|
|
||||||
}
|
|
||||||
if (!silentMode) {
|
|
||||||
LOG(logINFO) << "Updated Master File";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "File.h"
|
|
||||||
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
class HDF5MasterFile : private virtual slsDetectorDefs, public File {
|
|
||||||
|
|
||||||
public:
|
|
||||||
HDF5MasterFile(std::mutex *hdf5Lib);
|
|
||||||
~HDF5MasterFile();
|
|
||||||
|
|
||||||
void CloseFile() override;
|
|
||||||
void LinkDataFile(std::string dataFilename, std::string dataSetname,
|
|
||||||
const std::vector<std::string> parameterNames,
|
|
||||||
const bool silentMode) override;
|
|
||||||
void CreateMasterFile(const std::string filePath,
|
|
||||||
const std::string fileNamePrefix,
|
|
||||||
const uint64_t fileIndex, const bool overWriteEnable,
|
|
||||||
const bool silentMode,
|
|
||||||
MasterAttributes *attr) override;
|
|
||||||
void UpdateMasterFile(MasterAttributes *attr, bool silentMode) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::mutex *hdf5Lib_;
|
|
||||||
H5File *fd_{nullptr};
|
|
||||||
std::string fileName_;
|
|
||||||
std::string attrGroupName_;
|
|
||||||
};
|
|
@ -1,211 +0,0 @@
|
|||||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
#include "HDF5VirtualFile.h"
|
|
||||||
#include "receiver_defs.h"
|
|
||||||
|
|
||||||
#include <iomanip>
|
|
||||||
|
|
||||||
HDF5VirtualFile::HDF5VirtualFile(std::mutex *hdf5Lib, bool g25)
|
|
||||||
: File(HDF5), hdf5Lib_(hdf5Lib), gotthard25um(g25) {}
|
|
||||||
|
|
||||||
HDF5VirtualFile::~HDF5VirtualFile() { CloseFile(); }
|
|
||||||
|
|
||||||
std::array<std::string, 2> HDF5VirtualFile::GetFileAndDatasetName() const {
|
|
||||||
return std::array<std::string, 2>{fileName_, dataSetName_};
|
|
||||||
}
|
|
||||||
|
|
||||||
void HDF5VirtualFile::CloseFile() {
|
|
||||||
std::lock_guard<std::mutex> lock(*hdf5Lib_);
|
|
||||||
try {
|
|
||||||
Exception::dontPrint(); // to handle errors
|
|
||||||
if (fd_) {
|
|
||||||
fd_->close();
|
|
||||||
delete fd_;
|
|
||||||
fd_ = nullptr;
|
|
||||||
}
|
|
||||||
} catch (const Exception &error) {
|
|
||||||
LOG(logERROR) << "Could not close virtual HDF5 handles of index";
|
|
||||||
error.printErrorStack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HDF5VirtualFile::CreateVirtualFile(
|
|
||||||
const std::string 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 uint64_t numImages,
|
|
||||||
const uint32_t nPixelsX, const uint32_t nPixelsY,
|
|
||||||
const uint32_t dynamicRange, const uint64_t numImagesCaught,
|
|
||||||
const int numModX, const int numModY, const DataType dataType,
|
|
||||||
const std::vector<std::string> parameterNames,
|
|
||||||
const std::vector<DataType> parameterDataTypes) {
|
|
||||||
// virtual file name
|
|
||||||
std::ostringstream osfn;
|
|
||||||
osfn << filePath << "/" << fileNamePrefix << "_virtual"
|
|
||||||
<< "_" << fileIndex << ".h5";
|
|
||||||
fileName_ = osfn.str();
|
|
||||||
|
|
||||||
unsigned int paraSize = parameterNames.size();
|
|
||||||
uint64_t numModZ = numModX;
|
|
||||||
uint32_t nDimy = nPixelsY;
|
|
||||||
uint32_t nDimz = ((dynamicRange == 4) ? (nPixelsX / 2) : nPixelsX);
|
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(*hdf5Lib_);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Exception::dontPrint(); // to handle errors
|
|
||||||
|
|
||||||
// file
|
|
||||||
FileAccPropList fapl;
|
|
||||||
fapl.setFcloseDegree(H5F_CLOSE_STRONG);
|
|
||||||
fd_ = nullptr;
|
|
||||||
if (!overWriteEnable)
|
|
||||||
fd_ = new H5File(fileName_.c_str(), H5F_ACC_EXCL,
|
|
||||||
FileCreatPropList::DEFAULT, fapl);
|
|
||||||
else
|
|
||||||
fd_ = new H5File(fileName_.c_str(), H5F_ACC_TRUNC,
|
|
||||||
FileCreatPropList::DEFAULT, fapl);
|
|
||||||
|
|
||||||
// attributes - version
|
|
||||||
double dValue = HDF5_WRITER_VERSION;
|
|
||||||
DataSpace dataspace_attr = DataSpace(H5S_SCALAR);
|
|
||||||
Attribute attribute = fd_->createAttribute(
|
|
||||||
"version", PredType::NATIVE_DOUBLE, dataspace_attr);
|
|
||||||
attribute.write(PredType::NATIVE_DOUBLE, &dValue);
|
|
||||||
|
|
||||||
// virtual dataspace
|
|
||||||
hsize_t vdsDims[3] = {numImagesCaught, numModY * nDimy,
|
|
||||||
numModZ * nDimz};
|
|
||||||
DataSpace vdsDataSpace(3, vdsDims, nullptr);
|
|
||||||
hsize_t vdsDimsPara[2] = {numImagesCaught,
|
|
||||||
(unsigned int)numModY * numModZ};
|
|
||||||
DataSpace vdsDataSpacePara(2, vdsDimsPara, nullptr);
|
|
||||||
|
|
||||||
// property list (fill value and datatype)
|
|
||||||
int fill_value = -1;
|
|
||||||
DSetCreatPropList plist;
|
|
||||||
plist.setFillValue(dataType, &fill_value);
|
|
||||||
|
|
||||||
// property list for parameters (datatype)
|
|
||||||
std::vector<DSetCreatPropList> plistPara(paraSize);
|
|
||||||
|
|
||||||
// hyperslab (files)
|
|
||||||
int numFiles = numImagesCaught / maxFramesPerFile;
|
|
||||||
if (numImagesCaught % maxFramesPerFile)
|
|
||||||
++numFiles;
|
|
||||||
uint64_t framesSaved = 0;
|
|
||||||
for (int iFile = 0; iFile < numFiles; ++iFile) {
|
|
||||||
|
|
||||||
uint64_t nDimx =
|
|
||||||
((numImagesCaught - framesSaved) > maxFramesPerFile)
|
|
||||||
? maxFramesPerFile
|
|
||||||
: (numImagesCaught - framesSaved);
|
|
||||||
|
|
||||||
hsize_t startLocation[3] = {framesSaved, 0, 0};
|
|
||||||
hsize_t strideBetweenBlocks[3] = {1, 1, 1};
|
|
||||||
hsize_t numBlocks[3] = {nDimx, nDimy, nDimz};
|
|
||||||
hsize_t blockSize[3] = {1, 1, 1};
|
|
||||||
|
|
||||||
hsize_t startLocationPara[2] = {framesSaved, 0};
|
|
||||||
hsize_t strideBetweenBlocksPara[3] = {1, 1};
|
|
||||||
hsize_t numBlocksPara[2] = {1, 1};
|
|
||||||
hsize_t blockSizePara[3] = {nDimx, 1};
|
|
||||||
|
|
||||||
// interleaving for g2
|
|
||||||
if (gotthard25um) {
|
|
||||||
strideBetweenBlocks[2] = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned int iReadout = 0; iReadout < numModY * numModZ;
|
|
||||||
++iReadout) {
|
|
||||||
|
|
||||||
// interleaving for g2 (startLocation is 0 and 1)
|
|
||||||
if (gotthard25um) {
|
|
||||||
startLocation[2] = iReadout;
|
|
||||||
}
|
|
||||||
|
|
||||||
vdsDataSpace.selectHyperslab(H5S_SELECT_SET, numBlocks,
|
|
||||||
startLocation, strideBetweenBlocks,
|
|
||||||
blockSize);
|
|
||||||
|
|
||||||
vdsDataSpacePara.selectHyperslab(
|
|
||||||
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();
|
|
||||||
LOG(logDEBUG1) << srcFileName;
|
|
||||||
|
|
||||||
// find relative path
|
|
||||||
std::string relative_srcFileName = srcFileName;
|
|
||||||
{
|
|
||||||
size_t p = srcFileName.rfind('/', srcFileName.length());
|
|
||||||
if (p != std::string::npos)
|
|
||||||
relative_srcFileName = (srcFileName.substr(
|
|
||||||
p + 1, srcFileName.length() - p));
|
|
||||||
}
|
|
||||||
|
|
||||||
// source dataset name
|
|
||||||
std::ostringstream osfn;
|
|
||||||
osfn << "/data";
|
|
||||||
if (numImages > 1)
|
|
||||||
osfn << "_f" << std::setfill('0') << std::setw(12) << iFile;
|
|
||||||
std::string srcDatasetName = osfn.str();
|
|
||||||
|
|
||||||
// source dataspace
|
|
||||||
hsize_t srcDims[3] = {nDimx, nDimy, nDimz};
|
|
||||||
hsize_t srcDimsMax[3] = {H5S_UNLIMITED, nDimy, nDimz};
|
|
||||||
DataSpace srcDataSpace(3, srcDims, srcDimsMax);
|
|
||||||
hsize_t srcDimsPara[1] = {nDimx};
|
|
||||||
hsize_t srcDimsMaxPara[1] = {H5S_UNLIMITED};
|
|
||||||
DataSpace srcDataSpacePara(1, srcDimsPara, srcDimsMaxPara);
|
|
||||||
|
|
||||||
// mapping of property list
|
|
||||||
plist.setVirtual(vdsDataSpace, relative_srcFileName.c_str(),
|
|
||||||
srcDatasetName.c_str(), srcDataSpace);
|
|
||||||
for (unsigned int p = 0; p < paraSize; ++p) {
|
|
||||||
plistPara[p].setVirtual(
|
|
||||||
vdsDataSpacePara, relative_srcFileName.c_str(),
|
|
||||||
parameterNames[p].c_str(), srcDataSpacePara);
|
|
||||||
}
|
|
||||||
|
|
||||||
// H5Sclose(srcDataspace);
|
|
||||||
// H5Sclose(srcDataspace_para);
|
|
||||||
|
|
||||||
if (!gotthard25um) {
|
|
||||||
startLocation[2] += nDimz;
|
|
||||||
if (startLocation[2] >= (numModZ * nDimz)) {
|
|
||||||
startLocation[2] = 0;
|
|
||||||
startLocation[1] += nDimy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
startLocationPara[1]++;
|
|
||||||
}
|
|
||||||
framesSaved += nDimx;
|
|
||||||
}
|
|
||||||
// datasets
|
|
||||||
dataSetName_ = "data";
|
|
||||||
DataSet vdsDataSet(fd_->createDataSet(dataSetName_.c_str(), dataType,
|
|
||||||
vdsDataSpace, plist));
|
|
||||||
|
|
||||||
for (unsigned int p = 0; p < paraSize; ++p) {
|
|
||||||
DataSet vdsDataSetPara(fd_->createDataSet(
|
|
||||||
parameterNames[p].c_str(), parameterDataTypes[p],
|
|
||||||
vdsDataSpacePara, plistPara[p]));
|
|
||||||
}
|
|
||||||
|
|
||||||
fd_->close();
|
|
||||||
} catch (const Exception &error) {
|
|
||||||
error.printErrorStack();
|
|
||||||
CloseFile();
|
|
||||||
throw sls::RuntimeError(
|
|
||||||
"Could not create/overwrite virtual HDF5 handles");
|
|
||||||
}
|
|
||||||
if (!silentMode) {
|
|
||||||
LOG(logINFO) << "Virtual File: " << fileName_;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "File.h"
|
|
||||||
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
class HDF5VirtualFile : private virtual slsDetectorDefs, public File {
|
|
||||||
|
|
||||||
public:
|
|
||||||
HDF5VirtualFile(std::mutex *hdf5Lib, bool g25);
|
|
||||||
~HDF5VirtualFile();
|
|
||||||
|
|
||||||
std::array<std::string, 2> GetFileAndDatasetName() const override;
|
|
||||||
void CloseFile() override;
|
|
||||||
void CreateVirtualFile(
|
|
||||||
const std::string 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 uint64_t numImages, const uint32_t nPixelsX,
|
|
||||||
const uint32_t nPixelsY, const uint32_t dynamicRange,
|
|
||||||
const uint64_t numImagesCaught, const int numModX, const int numModY,
|
|
||||||
const DataType dataType, const std::vector<std::string> parameterNames,
|
|
||||||
const std::vector<DataType> parameterDataTypes) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::mutex *hdf5Lib_;
|
|
||||||
H5File *fd_{nullptr};
|
|
||||||
std::string fileName_;
|
|
||||||
std::string dataSetName_;
|
|
||||||
bool gotthard25um;
|
|
||||||
};
|
|
@ -153,10 +153,20 @@ void Implementation::setDetectorType(const detectorType d) {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
numUDPInterfaces = generalData->numUDPInterfaces;
|
|
||||||
fifoDepth = generalData->defaultFifoDepth;
|
|
||||||
udpSocketBufferSize = generalData->defaultUdpSocketBufferSize;
|
|
||||||
framesPerFile = generalData->maxFramesPerFile;
|
framesPerFile = generalData->maxFramesPerFile;
|
||||||
|
fifoDepth = generalData->defaultFifoDepth;
|
||||||
|
numUDPInterfaces = generalData->numUDPInterfaces;
|
||||||
|
udpSocketBufferSize = generalData->defaultUdpSocketBufferSize;
|
||||||
|
dynamicRange = generalData->dynamicRange;
|
||||||
|
tengigaEnable = generalData->tengigaEnable;
|
||||||
|
numberOfAnalogSamples = generalData->nAnalogSamples;
|
||||||
|
numberOfDigitalSamples = generalData->nDigitalSamples;
|
||||||
|
readoutType = generalData->readoutType;
|
||||||
|
adcEnableMaskOneGiga = generalData->adcEnableMaskOneGiga;
|
||||||
|
adcEnableMaskTenGiga = generalData->adcEnableMaskTenGiga;
|
||||||
|
roi = generalData->roi;
|
||||||
|
counterMask = generalData->counterMask;
|
||||||
|
|
||||||
SetLocalNetworkParameters();
|
SetLocalNetworkParameters();
|
||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
@ -207,7 +217,7 @@ slsDetectorDefs::xy Implementation::GetPortGeometry() {
|
|||||||
xy portGeometry{1, 1};
|
xy portGeometry{1, 1};
|
||||||
if (detType == EIGER)
|
if (detType == EIGER)
|
||||||
portGeometry.x = numUDPInterfaces;
|
portGeometry.x = numUDPInterfaces;
|
||||||
else // (jungfrau and gotthard2)
|
else if (detType == JUNGFRAU)
|
||||||
portGeometry.y = numUDPInterfaces;
|
portGeometry.y = numUDPInterfaces;
|
||||||
return portGeometry;
|
return portGeometry;
|
||||||
}
|
}
|
||||||
@ -216,18 +226,18 @@ void Implementation::setDetectorSize(const slsDetectorDefs::xy size) {
|
|||||||
xy portGeometry = GetPortGeometry();
|
xy portGeometry = GetPortGeometry();
|
||||||
|
|
||||||
std::string log_message = "Detector Size (ports): (";
|
std::string log_message = "Detector Size (ports): (";
|
||||||
numModules.x = portGeometry.x * size.x;
|
numModules = size;
|
||||||
numModules.y = portGeometry.y * size.y;
|
numPorts.x = portGeometry.x * size.x;
|
||||||
xy nm{numModules.x, numModules.y};
|
numPorts.y = portGeometry.y * size.y;
|
||||||
if (quadEnable) {
|
if (quadEnable) {
|
||||||
nm.x = 1;
|
numPorts.x = 1;
|
||||||
nm.y = 2;
|
numPorts.y = 2;
|
||||||
}
|
}
|
||||||
for (const auto &it : dataStreamer) {
|
for (const auto &it : dataStreamer) {
|
||||||
it->SetNumberofModules(nm);
|
it->SetNumberofPorts(numPorts);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(logINFO) << "Detector Size (ports): " << sls::ToString(numModules);
|
LOG(logINFO) << "Detector Size (ports): " << sls::ToString(numPorts);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Implementation::getModulePositionId() const { return modulePos; }
|
int Implementation::getModulePositionId() const { return modulePos; }
|
||||||
@ -240,15 +250,20 @@ void Implementation::setModulePositionId(const int id) {
|
|||||||
xy portGeometry = GetPortGeometry();
|
xy portGeometry = GetPortGeometry();
|
||||||
streamingPort = DEFAULT_ZMQ_RX_PORTNO + modulePos * portGeometry.x;
|
streamingPort = DEFAULT_ZMQ_RX_PORTNO + modulePos * portGeometry.x;
|
||||||
|
|
||||||
for (const auto &it : dataProcessor)
|
|
||||||
it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
|
|
||||||
fileFormatType, modulePos, &hdf5Lib);
|
|
||||||
assert(numModules.y != 0);
|
assert(numModules.y != 0);
|
||||||
for (unsigned int i = 0; i < listener.size(); ++i) {
|
for (unsigned int i = 0; i < listener.size(); ++i) {
|
||||||
uint16_t row = 0, col = 0;
|
uint16_t row = 0, col = 0;
|
||||||
row = (modulePos % numModules.y) * portGeometry.y;
|
row = (modulePos % numModules.y) * portGeometry.y;
|
||||||
col = (modulePos / numModules.y) * portGeometry.x + i;
|
col = (modulePos / numModules.y) * portGeometry.x;
|
||||||
|
if (portGeometry.y == 2) {
|
||||||
|
row += i;
|
||||||
|
}
|
||||||
|
if (portGeometry.x == 2) {
|
||||||
|
col += i;
|
||||||
|
}
|
||||||
|
LOG(logDEBUG1) << i << ":numModules:" << numModules.x << ","
|
||||||
|
<< numModules.y << " portGeometry:" << portGeometry.x
|
||||||
|
<< "," << portGeometry.y;
|
||||||
listener[i]->SetHardCodedPosition(row, col);
|
listener[i]->SetHardCodedPosition(row, col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -372,8 +387,7 @@ void Implementation::setFileFormat(const fileFormat f) {
|
|||||||
throw sls::RuntimeError("Unknown file format");
|
throw sls::RuntimeError("Unknown file format");
|
||||||
}
|
}
|
||||||
for (const auto &it : dataProcessor)
|
for (const auto &it : dataProcessor)
|
||||||
it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
|
it->SetupFileWriter(fileWriteEnable, fileFormatType, &hdf5LibMutex);
|
||||||
fileFormatType, modulePos, &hdf5Lib);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(logINFO) << "File Format: " << sls::ToString(fileFormatType);
|
LOG(logINFO) << "File Format: " << sls::ToString(fileFormatType);
|
||||||
@ -409,8 +423,7 @@ void Implementation::setFileWriteEnable(const bool b) {
|
|||||||
if (fileWriteEnable != b) {
|
if (fileWriteEnable != b) {
|
||||||
fileWriteEnable = b;
|
fileWriteEnable = b;
|
||||||
for (const auto &it : dataProcessor)
|
for (const auto &it : dataProcessor)
|
||||||
it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
|
it->SetupFileWriter(fileWriteEnable, fileFormatType, &hdf5LibMutex);
|
||||||
fileFormatType, modulePos, &hdf5Lib);
|
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "File Write Enable: "
|
LOG(logINFO) << "File Write Enable: "
|
||||||
<< (fileWriteEnable ? "enabled" : "disabled");
|
<< (fileWriteEnable ? "enabled" : "disabled");
|
||||||
@ -423,9 +436,6 @@ bool Implementation::getMasterFileWriteEnable() const {
|
|||||||
void Implementation::setMasterFileWriteEnable(const bool b) {
|
void Implementation::setMasterFileWriteEnable(const bool b) {
|
||||||
if (masterFileWriteEnable != b) {
|
if (masterFileWriteEnable != b) {
|
||||||
masterFileWriteEnable = b;
|
masterFileWriteEnable = b;
|
||||||
for (const auto &it : dataProcessor)
|
|
||||||
it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
|
|
||||||
fileFormatType, modulePos, &hdf5Lib);
|
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Master File Write Enable: "
|
LOG(logINFO) << "Master File Write Enable: "
|
||||||
<< (masterFileWriteEnable ? "enabled" : "disabled");
|
<< (masterFileWriteEnable ? "enabled" : "disabled");
|
||||||
@ -531,9 +541,9 @@ void Implementation::startReceiver() {
|
|||||||
// callbacks
|
// callbacks
|
||||||
if (startAcquisitionCallBack) {
|
if (startAcquisitionCallBack) {
|
||||||
try {
|
try {
|
||||||
startAcquisitionCallBack(filePath, fileName, fileIndex,
|
std::size_t imageSize =
|
||||||
(generalData->imageSize) +
|
static_cast<uint32_t>(generalData->imageSize);
|
||||||
(generalData->fifoBufferHeaderSize),
|
startAcquisitionCallBack(filePath, fileName, fileIndex, imageSize,
|
||||||
pStartAcquisition);
|
pStartAcquisition);
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
throw sls::RuntimeError("Start Acquisition Callback Error: " +
|
throw sls::RuntimeError("Start Acquisition Callback Error: " +
|
||||||
@ -584,29 +594,9 @@ void Implementation::stopReceiver() {
|
|||||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HDF5C
|
if (fileWriteEnable && modulePos == 0) {
|
||||||
if (fileWriteEnable && fileFormatType == HDF5) {
|
// master and virtual file (hdf5)
|
||||||
if (modulePos == 0) {
|
StartMasterWriter();
|
||||||
// more than 1 file, create virtual file
|
|
||||||
if (dataProcessor[0]->GetFilesInAcquisition() > 1 ||
|
|
||||||
(numModules.x * numModules.y) > 1) {
|
|
||||||
dataProcessor[0]->CreateVirtualFile(
|
|
||||||
filePath, fileName, fileIndex, overwriteEnable, silentMode,
|
|
||||||
modulePos, numUDPInterfaces, framesPerFile,
|
|
||||||
numberOfTotalFrames, dynamicRange, numModules.x,
|
|
||||||
numModules.y, &hdf5Lib);
|
|
||||||
}
|
|
||||||
// link file in master
|
|
||||||
dataProcessor[0]->LinkDataInMasterFile(silentMode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (fileWriteEnable && masterFileWriteEnable && modulePos == 0) {
|
|
||||||
try {
|
|
||||||
dataProcessor[0]->UpdateMasterFile(silentMode);
|
|
||||||
} catch (...) {
|
|
||||||
; // ignore it and just print it
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for the processes (dataStreamer) to be done
|
// wait for the processes (dataStreamer) to be done
|
||||||
@ -753,100 +743,12 @@ void Implementation::CreateUDPSockets() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::SetupWriter() {
|
void Implementation::SetupWriter() {
|
||||||
// master file
|
|
||||||
std::unique_ptr<MasterAttributes> masterAttributes;
|
|
||||||
if (masterFileWriteEnable && modulePos == 0) {
|
|
||||||
switch (detType) {
|
|
||||||
case GOTTHARD:
|
|
||||||
masterAttributes = sls::make_unique<GotthardMasterAttributes>();
|
|
||||||
break;
|
|
||||||
case JUNGFRAU:
|
|
||||||
masterAttributes = sls::make_unique<JungfrauMasterAttributes>();
|
|
||||||
break;
|
|
||||||
case EIGER:
|
|
||||||
masterAttributes = sls::make_unique<EigerMasterAttributes>();
|
|
||||||
break;
|
|
||||||
case MYTHEN3:
|
|
||||||
masterAttributes = sls::make_unique<Mythen3MasterAttributes>();
|
|
||||||
break;
|
|
||||||
case GOTTHARD2:
|
|
||||||
masterAttributes = sls::make_unique<Gotthard2MasterAttributes>();
|
|
||||||
break;
|
|
||||||
case MOENCH:
|
|
||||||
masterAttributes = sls::make_unique<MoenchMasterAttributes>();
|
|
||||||
break;
|
|
||||||
case CHIPTESTBOARD:
|
|
||||||
masterAttributes = sls::make_unique<CtbMasterAttributes>();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw sls::RuntimeError(
|
|
||||||
"Unknown detector type to set up master file attributes");
|
|
||||||
}
|
|
||||||
masterAttributes->detType = detType;
|
|
||||||
masterAttributes->timingMode = timingMode;
|
|
||||||
xy nm{numModules.x, numModules.y};
|
|
||||||
if (quadEnable) {
|
|
||||||
nm.x = 1;
|
|
||||||
nm.y = 2;
|
|
||||||
}
|
|
||||||
masterAttributes->geometry = xy(nm.x, nm.y);
|
|
||||||
masterAttributes->imageSize = generalData->imageSize;
|
|
||||||
masterAttributes->nPixels =
|
|
||||||
xy(generalData->nPixelsX, generalData->nPixelsY);
|
|
||||||
masterAttributes->maxFramesPerFile = framesPerFile;
|
|
||||||
masterAttributes->frameDiscardMode = frameDiscardMode;
|
|
||||||
masterAttributes->framePadding = framePadding;
|
|
||||||
masterAttributes->scanParams = scanParams;
|
|
||||||
masterAttributes->totalFrames = numberOfTotalFrames;
|
|
||||||
masterAttributes->exptime = acquisitionTime;
|
|
||||||
masterAttributes->period = acquisitionPeriod;
|
|
||||||
masterAttributes->burstMode = burstMode;
|
|
||||||
masterAttributes->numUDPInterfaces = numUDPInterfaces;
|
|
||||||
masterAttributes->dynamicRange = dynamicRange;
|
|
||||||
masterAttributes->tenGiga = tengigaEnable;
|
|
||||||
masterAttributes->thresholdEnergyeV = thresholdEnergyeV;
|
|
||||||
masterAttributes->thresholdAllEnergyeV = thresholdAllEnergyeV;
|
|
||||||
masterAttributes->subExptime = subExpTime;
|
|
||||||
masterAttributes->subPeriod = subPeriod;
|
|
||||||
masterAttributes->quad = quadEnable;
|
|
||||||
masterAttributes->readNRows = readNRows;
|
|
||||||
masterAttributes->ratecorr = rateCorrections;
|
|
||||||
masterAttributes->adcmask =
|
|
||||||
tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga;
|
|
||||||
masterAttributes->analog =
|
|
||||||
(readoutType == ANALOG_ONLY || readoutType == ANALOG_AND_DIGITAL)
|
|
||||||
? 1
|
|
||||||
: 0;
|
|
||||||
masterAttributes->analogSamples = numberOfAnalogSamples;
|
|
||||||
masterAttributes->digital =
|
|
||||||
(readoutType == DIGITAL_ONLY || readoutType == ANALOG_AND_DIGITAL)
|
|
||||||
? 1
|
|
||||||
: 0;
|
|
||||||
masterAttributes->digitalSamples = numberOfDigitalSamples;
|
|
||||||
masterAttributes->dbitoffset = ctbDbitOffset;
|
|
||||||
masterAttributes->dbitlist = 0;
|
|
||||||
for (auto &i : ctbDbitList) {
|
|
||||||
masterAttributes->dbitlist |= (1 << i);
|
|
||||||
}
|
|
||||||
masterAttributes->roi = roi;
|
|
||||||
masterAttributes->counterMask = counterMask;
|
|
||||||
masterAttributes->exptime1 = acquisitionTime1;
|
|
||||||
masterAttributes->exptime2 = acquisitionTime2;
|
|
||||||
masterAttributes->exptime3 = acquisitionTime3;
|
|
||||||
masterAttributes->gateDelay1 = gateDelay1;
|
|
||||||
masterAttributes->gateDelay2 = gateDelay2;
|
|
||||||
masterAttributes->gateDelay3 = gateDelay3;
|
|
||||||
masterAttributes->gates = numberOfGates;
|
|
||||||
masterAttributes->additionalJsonHeader = additionalJsonHeader;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
|
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
|
||||||
dataProcessor[i]->CreateFirstFiles(
|
dataProcessor[i]->CreateFirstFiles(
|
||||||
masterAttributes.get(), filePath, fileName, fileIndex,
|
filePath, fileName, fileIndex, overwriteEnable, silentMode,
|
||||||
overwriteEnable, silentMode, modulePos, numUDPInterfaces,
|
modulePos, numUDPInterfaces, udpPortNum[i], framesPerFile,
|
||||||
udpPortNum[i], framesPerFile, numberOfTotalFrames, dynamicRange,
|
numberOfTotalFrames, dynamicRange, detectorDataStream[i]);
|
||||||
detectorDataStream[i]);
|
|
||||||
}
|
}
|
||||||
} catch (const sls::RuntimeError &e) {
|
} catch (const sls::RuntimeError &e) {
|
||||||
shutDownUDPSockets();
|
shutDownUDPSockets();
|
||||||
@ -856,6 +758,95 @@ void Implementation::SetupWriter() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Implementation::StartMasterWriter() {
|
||||||
|
try {
|
||||||
|
std::string masterFileName;
|
||||||
|
// master file
|
||||||
|
if (masterFileWriteEnable) {
|
||||||
|
MasterAttributes masterAttributes;
|
||||||
|
masterAttributes.detType = detType;
|
||||||
|
masterAttributes.timingMode = timingMode;
|
||||||
|
masterAttributes.geometry = numPorts;
|
||||||
|
masterAttributes.imageSize = generalData->imageSize;
|
||||||
|
masterAttributes.nPixels =
|
||||||
|
xy(generalData->nPixelsX, generalData->nPixelsY);
|
||||||
|
masterAttributes.maxFramesPerFile = framesPerFile;
|
||||||
|
masterAttributes.frameDiscardMode = frameDiscardMode;
|
||||||
|
masterAttributes.framePadding = framePadding;
|
||||||
|
masterAttributes.scanParams = scanParams;
|
||||||
|
masterAttributes.totalFrames = numberOfTotalFrames;
|
||||||
|
masterAttributes.exptime = acquisitionTime;
|
||||||
|
masterAttributes.period = acquisitionPeriod;
|
||||||
|
masterAttributes.burstMode = burstMode;
|
||||||
|
masterAttributes.numUDPInterfaces = numUDPInterfaces;
|
||||||
|
masterAttributes.dynamicRange = dynamicRange;
|
||||||
|
masterAttributes.tenGiga = tengigaEnable;
|
||||||
|
masterAttributes.thresholdEnergyeV = thresholdEnergyeV;
|
||||||
|
masterAttributes.thresholdAllEnergyeV = thresholdAllEnergyeV;
|
||||||
|
masterAttributes.subExptime = subExpTime;
|
||||||
|
masterAttributes.subPeriod = subPeriod;
|
||||||
|
masterAttributes.quad = quadEnable;
|
||||||
|
masterAttributes.readNRows = readNRows;
|
||||||
|
masterAttributes.ratecorr = rateCorrections;
|
||||||
|
masterAttributes.adcmask =
|
||||||
|
tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga;
|
||||||
|
masterAttributes.analog = (readoutType == ANALOG_ONLY ||
|
||||||
|
readoutType == ANALOG_AND_DIGITAL)
|
||||||
|
? 1
|
||||||
|
: 0;
|
||||||
|
masterAttributes.analogSamples = numberOfAnalogSamples;
|
||||||
|
masterAttributes.digital = (readoutType == DIGITAL_ONLY ||
|
||||||
|
readoutType == ANALOG_AND_DIGITAL)
|
||||||
|
? 1
|
||||||
|
: 0;
|
||||||
|
masterAttributes.digitalSamples = numberOfDigitalSamples;
|
||||||
|
masterAttributes.dbitoffset = ctbDbitOffset;
|
||||||
|
masterAttributes.dbitlist = 0;
|
||||||
|
for (auto &i : ctbDbitList) {
|
||||||
|
masterAttributes.dbitlist |= (1 << i);
|
||||||
|
}
|
||||||
|
masterAttributes.roi = roi;
|
||||||
|
masterAttributes.counterMask = counterMask;
|
||||||
|
masterAttributes.exptimeArray[0] = acquisitionTime1;
|
||||||
|
masterAttributes.exptimeArray[1] = acquisitionTime2;
|
||||||
|
masterAttributes.exptimeArray[2] = acquisitionTime3;
|
||||||
|
masterAttributes.gateDelayArray[0] = gateDelay1;
|
||||||
|
masterAttributes.gateDelayArray[1] = gateDelay2;
|
||||||
|
masterAttributes.gateDelayArray[2] = gateDelay3;
|
||||||
|
masterAttributes.gates = numberOfGates;
|
||||||
|
masterAttributes.additionalJsonHeader = additionalJsonHeader;
|
||||||
|
|
||||||
|
// create master file
|
||||||
|
masterFileName = dataProcessor[0]->CreateMasterFile(
|
||||||
|
filePath, fileName, fileIndex, overwriteEnable, silentMode,
|
||||||
|
fileFormatType, &masterAttributes, &hdf5LibMutex);
|
||||||
|
}
|
||||||
|
#ifdef HDF5C
|
||||||
|
if (fileFormatType == HDF5) {
|
||||||
|
std::array<std::string, 2> virtualFileAndDatasetNames;
|
||||||
|
// create virtual hdf5 file (if multiple files)
|
||||||
|
if (dataProcessor[0]->GetFilesInAcquisition() > 1 ||
|
||||||
|
(numPorts.x * numPorts.y) > 1) {
|
||||||
|
virtualFileAndDatasetNames =
|
||||||
|
dataProcessor[0]->CreateVirtualFile(
|
||||||
|
filePath, fileName, fileIndex, overwriteEnable,
|
||||||
|
silentMode, modulePos, numUDPInterfaces, framesPerFile,
|
||||||
|
numberOfTotalFrames, numPorts.x, numPorts.y,
|
||||||
|
dynamicRange, &hdf5LibMutex);
|
||||||
|
}
|
||||||
|
// link file in master
|
||||||
|
if (masterFileWriteEnable) {
|
||||||
|
dataProcessor[0]->LinkFileInMaster(
|
||||||
|
masterFileName, virtualFileAndDatasetNames[0],
|
||||||
|
virtualFileAndDatasetNames[1], silentMode, &hdf5LibMutex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} catch (...) {
|
||||||
|
; // ignore it and just print it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Implementation::StartRunning() {
|
void Implementation::StartRunning() {
|
||||||
|
|
||||||
// set running mask and post semaphore to start the inner loop in execution
|
// set running mask and post semaphore to start the inner loop in execution
|
||||||
@ -891,12 +882,6 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (numUDPInterfaces != n) {
|
if (numUDPInterfaces != n) {
|
||||||
|
|
||||||
// reduce number of detectors to size with 1 interface
|
|
||||||
xy portGeometry = GetPortGeometry();
|
|
||||||
numModules.x /= portGeometry.x;
|
|
||||||
numModules.y /= portGeometry.y;
|
|
||||||
|
|
||||||
// clear all threads and fifos
|
// clear all threads and fifos
|
||||||
listener.clear();
|
listener.clear();
|
||||||
dataProcessor.clear();
|
dataProcessor.clear();
|
||||||
@ -945,15 +930,12 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
|
|||||||
if (dataStreamEnable) {
|
if (dataStreamEnable) {
|
||||||
try {
|
try {
|
||||||
bool flip = flipRows;
|
bool flip = flipRows;
|
||||||
xy nm{numModules.x, numModules.y};
|
|
||||||
if (quadEnable) {
|
if (quadEnable) {
|
||||||
flip = (i == 1 ? true : false);
|
flip = (i == 1 ? true : false);
|
||||||
nm.x = 1;
|
|
||||||
nm.y = 2;
|
|
||||||
}
|
}
|
||||||
dataStreamer.push_back(sls::make_unique<DataStreamer>(
|
dataStreamer.push_back(sls::make_unique<DataStreamer>(
|
||||||
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, flip,
|
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, flip,
|
||||||
nm, &quadEnable, &numberOfTotalFrames));
|
numPorts, &quadEnable, &numberOfTotalFrames));
|
||||||
dataStreamer[i]->SetGeneralData(generalData);
|
dataStreamer[i]->SetGeneralData(generalData);
|
||||||
dataStreamer[i]->CreateZmqSockets(
|
dataStreamer[i]->CreateZmqSockets(
|
||||||
&numUDPInterfaces, streamingPort, streamingSrcIP,
|
&numUDPInterfaces, streamingPort, streamingSrcIP,
|
||||||
@ -1075,15 +1057,12 @@ void Implementation::setDataStreamEnable(const bool enable) {
|
|||||||
for (int i = 0; i < numUDPInterfaces; ++i) {
|
for (int i = 0; i < numUDPInterfaces; ++i) {
|
||||||
try {
|
try {
|
||||||
bool flip = flipRows;
|
bool flip = flipRows;
|
||||||
xy nm{numModules.x, numModules.y};
|
|
||||||
if (quadEnable) {
|
if (quadEnable) {
|
||||||
flip = (i == 1 ? true : false);
|
flip = (i == 1 ? true : false);
|
||||||
nm.x = 1;
|
|
||||||
nm.y = 2;
|
|
||||||
}
|
}
|
||||||
dataStreamer.push_back(sls::make_unique<DataStreamer>(
|
dataStreamer.push_back(sls::make_unique<DataStreamer>(
|
||||||
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, flip,
|
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, flip,
|
||||||
nm, &quadEnable, &numberOfTotalFrames));
|
numPorts, &quadEnable, &numberOfTotalFrames));
|
||||||
dataStreamer[i]->SetGeneralData(generalData);
|
dataStreamer[i]->SetGeneralData(generalData);
|
||||||
dataStreamer[i]->CreateZmqSockets(
|
dataStreamer[i]->CreateZmqSockets(
|
||||||
&numUDPInterfaces, streamingPort, streamingSrcIP,
|
&numUDPInterfaces, streamingPort, streamingSrcIP,
|
||||||
@ -1417,14 +1396,8 @@ uint32_t Implementation::getCounterMask() const { return counterMask; }
|
|||||||
|
|
||||||
void Implementation::setCounterMask(const uint32_t i) {
|
void Implementation::setCounterMask(const uint32_t i) {
|
||||||
if (counterMask != i) {
|
if (counterMask != i) {
|
||||||
int ncounters = __builtin_popcount(i);
|
generalData->SetCounterMask(i);
|
||||||
if (ncounters < 1 || ncounters > 3) {
|
|
||||||
throw sls::RuntimeError("Invalid number of counters " +
|
|
||||||
std::to_string(ncounters) +
|
|
||||||
". Expected 1-3.");
|
|
||||||
}
|
|
||||||
counterMask = i;
|
counterMask = i;
|
||||||
generalData->SetNumberofCounters(ncounters);
|
|
||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Counter mask: " << sls::ToStringHex(counterMask);
|
LOG(logINFO) << "Counter mask: " << sls::ToStringHex(counterMask);
|
||||||
@ -1517,18 +1490,12 @@ bool Implementation::getQuad() const { return quadEnable; }
|
|||||||
void Implementation::setQuad(const bool b) {
|
void Implementation::setQuad(const bool b) {
|
||||||
if (quadEnable != b) {
|
if (quadEnable != b) {
|
||||||
quadEnable = b;
|
quadEnable = b;
|
||||||
|
setDetectorSize(numModules);
|
||||||
if (!quadEnable) {
|
if (!quadEnable) {
|
||||||
xy nm{numModules.x, numModules.y};
|
|
||||||
for (const auto &it : dataStreamer) {
|
for (const auto &it : dataStreamer) {
|
||||||
it->SetNumberofModules(nm);
|
|
||||||
it->SetFlipRows(flipRows);
|
it->SetFlipRows(flipRows);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
xy nm{1, 2};
|
|
||||||
for (const auto &it : dataStreamer) {
|
|
||||||
it->SetNumberofModules(nm);
|
|
||||||
}
|
|
||||||
if (dataStreamer.size() == 2) {
|
if (dataStreamer.size() == 2) {
|
||||||
dataStreamer[0]->SetFlipRows(false);
|
dataStreamer[0]->SetFlipRows(false);
|
||||||
dataStreamer[1]->SetFlipRows(true);
|
dataStreamer[1]->SetFlipRows(true);
|
||||||
@ -1649,7 +1616,8 @@ void Implementation::setDbitOffset(const int s) { ctbDbitOffset = s; }
|
|||||||
* *
|
* *
|
||||||
* ************************************************/
|
* ************************************************/
|
||||||
void Implementation::registerCallBackStartAcquisition(
|
void Implementation::registerCallBackStartAcquisition(
|
||||||
int (*func)(std::string, std::string, uint64_t, uint32_t, void *),
|
int (*func)(const std::string &, const std::string &, uint64_t, size_t,
|
||||||
|
void *),
|
||||||
void *arg) {
|
void *arg) {
|
||||||
startAcquisitionCallBack = func;
|
startAcquisitionCallBack = func;
|
||||||
pStartAcquisition = arg;
|
pStartAcquisition = arg;
|
||||||
@ -1663,7 +1631,7 @@ void Implementation::registerCallBackAcquisitionFinished(void (*func)(uint64_t,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::registerCallBackRawDataReady(
|
void Implementation::registerCallBackRawDataReady(
|
||||||
void (*func)(char *, char *, uint32_t, void *), void *arg) {
|
void (*func)(sls_receiver_header *, char *, size_t, void *), void *arg) {
|
||||||
rawDataReadyCallBack = func;
|
rawDataReadyCallBack = func;
|
||||||
pRawDataReady = arg;
|
pRawDataReady = arg;
|
||||||
for (const auto &it : dataProcessor)
|
for (const auto &it : dataProcessor)
|
||||||
@ -1671,7 +1639,7 @@ void Implementation::registerCallBackRawDataReady(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::registerCallBackRawDataModifyReady(
|
void Implementation::registerCallBackRawDataModifyReady(
|
||||||
void (*func)(char *, char *, uint32_t &, void *), void *arg) {
|
void (*func)(sls_receiver_header *, char *, size_t &, void *), void *arg) {
|
||||||
rawDataModifyReadyCallBack = func;
|
rawDataModifyReadyCallBack = func;
|
||||||
pRawDataReady = arg;
|
pRawDataReady = arg;
|
||||||
for (const auto &it : dataProcessor)
|
for (const auto &it : dataProcessor)
|
||||||
|
@ -252,17 +252,21 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
* Callbacks *
|
* Callbacks *
|
||||||
* *
|
* *
|
||||||
* ************************************************/
|
* ************************************************/
|
||||||
void registerCallBackStartAcquisition(int (*func)(std::string, std::string,
|
/** params: file path, file name, file index, image size */
|
||||||
uint64_t, uint32_t,
|
void registerCallBackStartAcquisition(int (*func)(const std::string &, const std::string &,
|
||||||
void *),
|
uint64_t, size_t, void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
/** params: total frames caught */
|
||||||
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *),
|
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
void registerCallBackRawDataReady(void (*func)(char *, char *, uint32_t,
|
/** params: sls_receiver_header pointer, pointer to data, image size */
|
||||||
void *),
|
void registerCallBackRawDataReady(void (*func)(sls_receiver_header *,
|
||||||
|
char *, size_t, void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
void registerCallBackRawDataModifyReady(void (*func)(char *, char *,
|
/** params: sls_receiver_header pointer, pointer to data, reference to image size */
|
||||||
uint32_t &, void *),
|
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
|
||||||
|
char *, size_t &,
|
||||||
|
void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -274,6 +278,7 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
void ResetParametersforNewAcquisition();
|
void ResetParametersforNewAcquisition();
|
||||||
void CreateUDPSockets();
|
void CreateUDPSockets();
|
||||||
void SetupWriter();
|
void SetupWriter();
|
||||||
|
void StartMasterWriter();
|
||||||
void StartRunning();
|
void StartRunning();
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
@ -285,6 +290,7 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
// config parameters
|
// config parameters
|
||||||
detectorType detType{GENERIC};
|
detectorType detType{GENERIC};
|
||||||
xy numModules{1, 1};
|
xy numModules{1, 1};
|
||||||
|
xy numPorts{1, 1};
|
||||||
int modulePos{0};
|
int modulePos{0};
|
||||||
std::string detHostname;
|
std::string detHostname;
|
||||||
bool silentMode{false};
|
bool silentMode{false};
|
||||||
@ -368,13 +374,14 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
int ctbDbitOffset{0};
|
int ctbDbitOffset{0};
|
||||||
|
|
||||||
// callbacks
|
// callbacks
|
||||||
int (*startAcquisitionCallBack)(std::string, std::string, uint64_t,
|
int (*startAcquisitionCallBack)(const std::string &, const std::string &, uint64_t, size_t,
|
||||||
uint32_t, void *){nullptr};
|
void *){nullptr};
|
||||||
void *pStartAcquisition{nullptr};
|
void *pStartAcquisition{nullptr};
|
||||||
void (*acquisitionFinishedCallBack)(uint64_t, void *){nullptr};
|
void (*acquisitionFinishedCallBack)(uint64_t, void *){nullptr};
|
||||||
void *pAcquisitionFinished{nullptr};
|
void *pAcquisitionFinished{nullptr};
|
||||||
void (*rawDataReadyCallBack)(char *, char *, uint32_t, void *){nullptr};
|
void (*rawDataReadyCallBack)(sls_receiver_header *, char *, size_t,
|
||||||
void (*rawDataModifyReadyCallBack)(char *, char *, uint32_t &,
|
void *){nullptr};
|
||||||
|
void (*rawDataModifyReadyCallBack)(sls_receiver_header *, char *, size_t &,
|
||||||
void *){nullptr};
|
void *){nullptr};
|
||||||
void *pRawDataReady{nullptr};
|
void *pRawDataReady{nullptr};
|
||||||
|
|
||||||
@ -386,5 +393,6 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
std::vector<std::unique_ptr<Fifo>> fifo;
|
std::vector<std::unique_ptr<Fifo>> fifo;
|
||||||
Arping arping;
|
Arping arping;
|
||||||
|
|
||||||
std::mutex hdf5Lib;
|
// mutex shared across all hdf5 virtual, master and data files
|
||||||
|
std::mutex hdf5LibMutex;
|
||||||
};
|
};
|
||||||
|
@ -210,6 +210,8 @@ void Listener::CreateDummySocketForUDPSocketBufferSize(int s) {
|
|||||||
void Listener::SetHardCodedPosition(uint16_t r, uint16_t c) {
|
void Listener::SetHardCodedPosition(uint16_t r, uint16_t c) {
|
||||||
row = r;
|
row = r;
|
||||||
column = c;
|
column = c;
|
||||||
|
LOG(logDEBUG1) << "Setting hardcoded position [" << index
|
||||||
|
<< "] (row: " << row << ", col: " << column << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Listener::ThreadExecution() {
|
void Listener::ThreadExecution() {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -7,6 +7,9 @@
|
|||||||
#include "sls/logger.h"
|
#include "sls/logger.h"
|
||||||
#include "sls/sls_detector_defs.h"
|
#include "sls/sls_detector_defs.h"
|
||||||
|
|
||||||
|
#include <rapidjson/stringbuffer.h>
|
||||||
|
#include <rapidjson/prettywriter.h>
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
#include "H5Cpp.h"
|
#include "H5Cpp.h"
|
||||||
#ifndef H5_NO_NAMESPACE
|
#ifndef H5_NO_NAMESPACE
|
||||||
@ -53,94 +56,92 @@ class MasterAttributes {
|
|||||||
uint64_t dbitlist{0};
|
uint64_t dbitlist{0};
|
||||||
slsDetectorDefs::ROI roi{};
|
slsDetectorDefs::ROI roi{};
|
||||||
uint32_t counterMask{0};
|
uint32_t counterMask{0};
|
||||||
ns exptime1{0};
|
std::array<ns, 3> exptimeArray{};
|
||||||
ns exptime2{0};
|
std::array<ns, 3> gateDelayArray{};
|
||||||
ns exptime3{0};
|
|
||||||
ns gateDelay1{0};
|
|
||||||
ns gateDelay2{0};
|
|
||||||
ns gateDelay3{0};
|
|
||||||
uint32_t gates;
|
uint32_t gates;
|
||||||
std::map<std::string, std::string> additionalJsonHeader;
|
std::map<std::string, std::string> additionalJsonHeader;
|
||||||
|
|
||||||
// Final Attributes (after acquisition)
|
|
||||||
uint64_t framesInFile{0};
|
uint64_t framesInFile{0};
|
||||||
|
|
||||||
MasterAttributes() = default;
|
MasterAttributes() = default;
|
||||||
virtual ~MasterAttributes() = default;
|
~MasterAttributes() = default;
|
||||||
virtual void WriteMasterBinaryAttributes(FILE *fd);
|
|
||||||
std::string GetBinaryMasterAttributes();
|
void GetBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
|
||||||
void WriteBinaryAttributes(FILE *fd, std::string message);
|
|
||||||
void WriteFinalBinaryAttributes(FILE *fd);
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
virtual void WriteMasterHDF5Attributes(H5File *fd, Group *group);
|
|
||||||
void WriteHDF5Attributes(H5File *fd, Group *group);
|
void WriteHDF5Attributes(H5File *fd, Group *group);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
GetCommonBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
|
||||||
|
void
|
||||||
|
GetFinalBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
|
||||||
|
#ifdef HDF5C
|
||||||
|
void WriteCommonHDF5Attributes(H5File *fd, Group *group);
|
||||||
void WriteFinalHDF5Attributes(H5File *fd, Group *group);
|
void WriteFinalHDF5Attributes(H5File *fd, Group *group);
|
||||||
void WriteHDF5Exptime(H5File *fd, Group *group);
|
void WriteHDF5Exptime(H5File *fd, Group *group);
|
||||||
void WriteHDF5Period(H5File *fd, Group *group);
|
void WriteHDF5Period(H5File *fd, Group *group);
|
||||||
void WriteHDF5DynamicRange(H5File *fd, Group *group);
|
void WriteHDF5DynamicRange(H5File *fd, Group *group);
|
||||||
void WriteHDF5TenGiga(H5File *fd, Group *group);
|
void WriteHDF5TenGiga(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5ROI(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5NumUDPInterfaces(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5ReadNRows(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5ThresholdEnergy(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5ThresholdEnergies(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5SubExpTime(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5SubPeriod(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5SubQuad(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5RateCorrections(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5CounterMask(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5ExptimeArray(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5GateDelayArray(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5Gates(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5BurstMode(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5AdcMask(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5AnalogFlag(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5AnalogSamples(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5DigitalFlag(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5DigitalSamples(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5DbitOffset(H5File *fd, Group *group);
|
||||||
|
void WriteHDF5DbitList(H5File *fd, Group *group);
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
|
||||||
class GotthardMasterAttributes : public MasterAttributes {
|
void
|
||||||
public:
|
GetGotthardBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
|
||||||
GotthardMasterAttributes() = default;
|
|
||||||
void WriteMasterBinaryAttributes(FILE *fd) override;
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
void WriteGotthardHDF5Attributes(H5File *fd, Group *group);
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
|
||||||
class JungfrauMasterAttributes : public MasterAttributes {
|
void
|
||||||
public:
|
GetJungfrauBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
|
||||||
JungfrauMasterAttributes() = default;
|
|
||||||
void WriteMasterBinaryAttributes(FILE *fd) override;
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
void WriteJungfrauHDF5Attributes(H5File *fd, Group *group);
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
|
||||||
class EigerMasterAttributes : public MasterAttributes {
|
void
|
||||||
public:
|
GetEigerBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
|
||||||
EigerMasterAttributes() = default;
|
|
||||||
void WriteMasterBinaryAttributes(FILE *fd) override;
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
void WriteEigerHDF5Attributes(H5File *fd, Group *group);
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
|
||||||
class Mythen3MasterAttributes : public MasterAttributes {
|
void
|
||||||
public:
|
GetMythen3BinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
|
||||||
Mythen3MasterAttributes() = default;
|
|
||||||
void WriteMasterBinaryAttributes(FILE *fd) override;
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
void WriteMythen3HDF5Attributes(H5File *fd, Group *group);
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
|
||||||
class Gotthard2MasterAttributes : public MasterAttributes {
|
void
|
||||||
public:
|
GetGotthard2BinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
|
||||||
Gotthard2MasterAttributes() = default;
|
|
||||||
void WriteMasterBinaryAttributes(FILE *fd) override;
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
void WriteGotthard2HDF5Attributes(H5File *fd, Group *group);
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
|
||||||
class MoenchMasterAttributes : public MasterAttributes {
|
void
|
||||||
public:
|
GetMoenchBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
|
||||||
MoenchMasterAttributes() = default;
|
|
||||||
void WriteMasterBinaryAttributes(FILE *fd) override;
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
void WriteMoenchHDF5Attributes(H5File *fd, Group *group);
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
|
||||||
class CtbMasterAttributes : public MasterAttributes {
|
void GetCtbBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
|
||||||
public:
|
|
||||||
CtbMasterAttributes() = default;
|
|
||||||
void WriteMasterBinaryAttributes(FILE *fd) override;
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
void WriteCtbHDF5Attributes(H5File *fd, Group *group);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
351
slsReceiverSoftware/src/MasterFileUtility.cpp
Normal file
351
slsReceiverSoftware/src/MasterFileUtility.cpp
Normal file
@ -0,0 +1,351 @@
|
|||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
|
#include "MasterFileUtility.h"
|
||||||
|
#include "sls/container_utils.h"
|
||||||
|
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
|
namespace masterFileUtility {
|
||||||
|
|
||||||
|
std::string CreateMasterBinaryFile(const std::string &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::string mode = "w";
|
||||||
|
if (!overWriteEnable)
|
||||||
|
mode = "wx";
|
||||||
|
FILE *fd = fopen(fileName.c_str(), mode.c_str());
|
||||||
|
if(!fd) {
|
||||||
|
throw sls::RuntimeError("Could not create/overwrite binary master file " +
|
||||||
|
fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
rapidjson::StringBuffer s;
|
||||||
|
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(s);
|
||||||
|
attr->GetBinaryAttributes(&writer);
|
||||||
|
if (fwrite(s.GetString(), 1, strlen(s.GetString()), fd) !=
|
||||||
|
strlen(s.GetString())) {
|
||||||
|
throw sls::RuntimeError(
|
||||||
|
"Master binary file incorrect number of bytes written to file");
|
||||||
|
}
|
||||||
|
if (fd) {
|
||||||
|
fclose(fd);
|
||||||
|
}
|
||||||
|
if (!silentMode) {
|
||||||
|
LOG(logINFO) << "Master File: " << fileName;
|
||||||
|
}
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HDF5C
|
||||||
|
void LinkHDF5FileInMaster(const std::string &masterFileName,
|
||||||
|
const std::string &dataFilename,
|
||||||
|
const std::string &dataSetname,
|
||||||
|
const std::vector<std::string> parameterNames,
|
||||||
|
const bool silentMode, std::mutex *hdf5LibMutex) {
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock(*hdf5LibMutex);
|
||||||
|
std::unique_ptr<H5File> fd{nullptr};
|
||||||
|
try {
|
||||||
|
Exception::dontPrint(); // to handle errors
|
||||||
|
|
||||||
|
FileAccPropList flist;
|
||||||
|
flist.setFcloseDegree(H5F_CLOSE_STRONG);
|
||||||
|
|
||||||
|
// open master file
|
||||||
|
H5File masterfd(masterFileName.c_str(), H5F_ACC_RDWR,
|
||||||
|
FileCreatPropList::DEFAULT, flist);
|
||||||
|
|
||||||
|
// open data file
|
||||||
|
fd = sls::make_unique<H5File>(dataFilename.c_str(), H5F_ACC_RDONLY,
|
||||||
|
FileCreatPropList::DEFAULT, flist);
|
||||||
|
|
||||||
|
// create link for data dataset
|
||||||
|
DataSet dset = fd->openDataSet(dataSetname.c_str());
|
||||||
|
std::string linkname = std::string("/entry/data/") + dataSetname;
|
||||||
|
if (H5Lcreate_external(dataFilename.c_str(), dataSetname.c_str(),
|
||||||
|
masterfd.getLocId(), linkname.c_str(),
|
||||||
|
H5P_DEFAULT, H5P_DEFAULT) < 0) {
|
||||||
|
throw sls::RuntimeError(
|
||||||
|
"Could not create link to data dataset in master");
|
||||||
|
}
|
||||||
|
|
||||||
|
// create link for parameter datasets
|
||||||
|
for (unsigned int i = 0; i < parameterNames.size(); ++i) {
|
||||||
|
DataSet pDset = fd->openDataSet(parameterNames[i].c_str());
|
||||||
|
linkname = std::string("/entry/data/") + parameterNames[i];
|
||||||
|
if (H5Lcreate_external(dataFilename.c_str(),
|
||||||
|
parameterNames[i].c_str(),
|
||||||
|
masterfd.getLocId(), linkname.c_str(),
|
||||||
|
H5P_DEFAULT, H5P_DEFAULT) < 0) {
|
||||||
|
throw sls::RuntimeError(
|
||||||
|
"Could not create link to parameter dataset in master");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fd->close();
|
||||||
|
masterfd.close();
|
||||||
|
} catch (const Exception &error) {
|
||||||
|
error.printErrorStack();
|
||||||
|
if (fd != nullptr)
|
||||||
|
fd->close();
|
||||||
|
throw sls::RuntimeError("Could not link in master hdf5 file");
|
||||||
|
}
|
||||||
|
if (!silentMode) {
|
||||||
|
LOG(logINFO) << "Linked in Master File: " << dataFilename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CreateMasterHDF5File(const std::string &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::lock_guard<std::mutex> lock(*hdf5LibMutex);
|
||||||
|
|
||||||
|
std::unique_ptr<H5File> fd{nullptr};
|
||||||
|
try {
|
||||||
|
Exception::dontPrint(); // to handle errors
|
||||||
|
|
||||||
|
FileAccPropList flist;
|
||||||
|
flist.setFcloseDegree(H5F_CLOSE_STRONG);
|
||||||
|
|
||||||
|
unsigned int createFlags = H5F_ACC_EXCL;
|
||||||
|
if (overWriteEnable) {
|
||||||
|
createFlags = H5F_ACC_TRUNC;
|
||||||
|
}
|
||||||
|
fd = sls::make_unique<H5File>(fileName.c_str(), createFlags,
|
||||||
|
FileCreatPropList::DEFAULT, flist);
|
||||||
|
|
||||||
|
// attributes - version
|
||||||
|
double dValue = HDF5_WRITER_VERSION;
|
||||||
|
DataSpace dataspace_attr = DataSpace(H5S_SCALAR);
|
||||||
|
Attribute attribute = fd->createAttribute(
|
||||||
|
"version", PredType::NATIVE_DOUBLE, dataspace_attr);
|
||||||
|
attribute.write(PredType::NATIVE_DOUBLE, &dValue);
|
||||||
|
|
||||||
|
// Create a group in the file
|
||||||
|
Group group1(fd->createGroup("entry"));
|
||||||
|
Group group2(group1.createGroup("data"));
|
||||||
|
Group group3(group1.createGroup("instrument"));
|
||||||
|
Group group4(group3.createGroup("beam"));
|
||||||
|
Group group5(group3.createGroup("detector"));
|
||||||
|
Group group6(group1.createGroup("sample"));
|
||||||
|
|
||||||
|
attr->WriteHDF5Attributes(fd.get(), &group5);
|
||||||
|
fd->close();
|
||||||
|
} catch (const Exception &error) {
|
||||||
|
error.printErrorStack();
|
||||||
|
if (fd != nullptr)
|
||||||
|
fd->close();
|
||||||
|
throw sls::RuntimeError(
|
||||||
|
"Could not create/overwrite master HDF5 handles");
|
||||||
|
}
|
||||||
|
if (!silentMode) {
|
||||||
|
LOG(logINFO) << "Master File: " << fileName;
|
||||||
|
}
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::array<std::string, 2> CreateVirtualHDF5File(
|
||||||
|
const std::string &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 uint64_t numImages,
|
||||||
|
const uint32_t nPixelsX, const uint32_t nPixelsY,
|
||||||
|
const uint32_t dynamicRange, const uint64_t numImagesCaught,
|
||||||
|
const int numModX, const int numModY, const DataType dataType,
|
||||||
|
const std::vector<std::string> parameterNames,
|
||||||
|
const std::vector<DataType> parameterDataTypes, std::mutex *hdf5LibMutex,
|
||||||
|
bool gotthard25um) {
|
||||||
|
|
||||||
|
// virtual file name
|
||||||
|
std::ostringstream osfn;
|
||||||
|
osfn << filePath << "/" << fileNamePrefix << "_virtual"
|
||||||
|
<< "_" << fileIndex << ".h5";
|
||||||
|
std::string fileName = osfn.str();
|
||||||
|
|
||||||
|
std::string dataSetName = "data";
|
||||||
|
|
||||||
|
unsigned int paraSize = parameterNames.size();
|
||||||
|
uint64_t numModZ = numModX;
|
||||||
|
uint32_t nDimy = nPixelsY;
|
||||||
|
uint32_t nDimz = ((dynamicRange == 4) ? (nPixelsX / 2) : nPixelsX);
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock(*hdf5LibMutex);
|
||||||
|
|
||||||
|
std::unique_ptr<H5File> fd{nullptr};
|
||||||
|
try {
|
||||||
|
Exception::dontPrint(); // to handle errors
|
||||||
|
|
||||||
|
// file
|
||||||
|
FileAccPropList fapl;
|
||||||
|
fapl.setFcloseDegree(H5F_CLOSE_STRONG);
|
||||||
|
if (!overWriteEnable)
|
||||||
|
fd = sls::make_unique<H5File>(fileName.c_str(), H5F_ACC_EXCL,
|
||||||
|
FileCreatPropList::DEFAULT, fapl);
|
||||||
|
else
|
||||||
|
fd = sls::make_unique<H5File>(fileName.c_str(), H5F_ACC_TRUNC,
|
||||||
|
FileCreatPropList::DEFAULT, fapl);
|
||||||
|
|
||||||
|
// attributes - version
|
||||||
|
double dValue = HDF5_WRITER_VERSION;
|
||||||
|
DataSpace dataspace_attr = DataSpace(H5S_SCALAR);
|
||||||
|
Attribute attribute = fd->createAttribute(
|
||||||
|
"version", PredType::NATIVE_DOUBLE, dataspace_attr);
|
||||||
|
attribute.write(PredType::NATIVE_DOUBLE, &dValue);
|
||||||
|
|
||||||
|
// virtual dataspace
|
||||||
|
hsize_t vdsDims[3] = {numImagesCaught, numModY * nDimy,
|
||||||
|
numModZ * nDimz};
|
||||||
|
DataSpace vdsDataSpace(3, vdsDims, nullptr);
|
||||||
|
hsize_t vdsDimsPara[2] = {numImagesCaught,
|
||||||
|
(unsigned int)numModY * numModZ};
|
||||||
|
DataSpace vdsDataSpacePara(2, vdsDimsPara, nullptr);
|
||||||
|
|
||||||
|
// property list (fill value and datatype)
|
||||||
|
int fill_value = -1;
|
||||||
|
DSetCreatPropList plist;
|
||||||
|
plist.setFillValue(dataType, &fill_value);
|
||||||
|
|
||||||
|
// property list for parameters (datatype)
|
||||||
|
std::vector<DSetCreatPropList> plistPara(paraSize);
|
||||||
|
|
||||||
|
// hyperslab (files)
|
||||||
|
int numFiles = numImagesCaught / maxFramesPerFile;
|
||||||
|
if (numImagesCaught % maxFramesPerFile)
|
||||||
|
++numFiles;
|
||||||
|
uint64_t framesSaved = 0;
|
||||||
|
for (int iFile = 0; iFile < numFiles; ++iFile) {
|
||||||
|
|
||||||
|
uint64_t nDimx =
|
||||||
|
((numImagesCaught - framesSaved) > maxFramesPerFile)
|
||||||
|
? maxFramesPerFile
|
||||||
|
: (numImagesCaught - framesSaved);
|
||||||
|
|
||||||
|
hsize_t startLocation[3] = {framesSaved, 0, 0};
|
||||||
|
hsize_t strideBetweenBlocks[3] = {1, 1, 1};
|
||||||
|
hsize_t numBlocks[3] = {nDimx, nDimy, nDimz};
|
||||||
|
hsize_t blockSize[3] = {1, 1, 1};
|
||||||
|
|
||||||
|
hsize_t startLocationPara[2] = {framesSaved, 0};
|
||||||
|
hsize_t strideBetweenBlocksPara[3] = {1, 1};
|
||||||
|
hsize_t numBlocksPara[2] = {1, 1};
|
||||||
|
hsize_t blockSizePara[3] = {nDimx, 1};
|
||||||
|
|
||||||
|
// interleaving for g2
|
||||||
|
if (gotthard25um) {
|
||||||
|
strideBetweenBlocks[2] = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int iReadout = 0; iReadout < numModY * numModZ;
|
||||||
|
++iReadout) {
|
||||||
|
|
||||||
|
// interleaving for g2 (startLocation is 0 and 1)
|
||||||
|
if (gotthard25um) {
|
||||||
|
startLocation[2] = iReadout;
|
||||||
|
}
|
||||||
|
|
||||||
|
vdsDataSpace.selectHyperslab(H5S_SELECT_SET, numBlocks,
|
||||||
|
startLocation, strideBetweenBlocks,
|
||||||
|
blockSize);
|
||||||
|
|
||||||
|
vdsDataSpacePara.selectHyperslab(
|
||||||
|
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();
|
||||||
|
LOG(logDEBUG1) << srcFileName;
|
||||||
|
|
||||||
|
// find relative path
|
||||||
|
std::string relative_srcFileName = srcFileName;
|
||||||
|
{
|
||||||
|
size_t p = srcFileName.rfind('/', srcFileName.length());
|
||||||
|
if (p != std::string::npos)
|
||||||
|
relative_srcFileName = (srcFileName.substr(
|
||||||
|
p + 1, srcFileName.length() - p));
|
||||||
|
}
|
||||||
|
|
||||||
|
// source dataset name
|
||||||
|
std::ostringstream osfn;
|
||||||
|
osfn << "/data";
|
||||||
|
if (numImages > 1)
|
||||||
|
osfn << "_f" << std::setfill('0') << std::setw(12) << iFile;
|
||||||
|
std::string srcDatasetName = osfn.str();
|
||||||
|
|
||||||
|
// source dataspace
|
||||||
|
hsize_t srcDims[3] = {nDimx, nDimy, nDimz};
|
||||||
|
hsize_t srcDimsMax[3] = {H5S_UNLIMITED, nDimy, nDimz};
|
||||||
|
DataSpace srcDataSpace(3, srcDims, srcDimsMax);
|
||||||
|
hsize_t srcDimsPara[1] = {nDimx};
|
||||||
|
hsize_t srcDimsMaxPara[1] = {H5S_UNLIMITED};
|
||||||
|
DataSpace srcDataSpacePara(1, srcDimsPara, srcDimsMaxPara);
|
||||||
|
|
||||||
|
// mapping of property list
|
||||||
|
plist.setVirtual(vdsDataSpace, relative_srcFileName.c_str(),
|
||||||
|
srcDatasetName.c_str(), srcDataSpace);
|
||||||
|
for (unsigned int p = 0; p < paraSize; ++p) {
|
||||||
|
plistPara[p].setVirtual(
|
||||||
|
vdsDataSpacePara, relative_srcFileName.c_str(),
|
||||||
|
parameterNames[p].c_str(), srcDataSpacePara);
|
||||||
|
}
|
||||||
|
|
||||||
|
// H5Sclose(srcDataspace);
|
||||||
|
// H5Sclose(srcDataspace_para);
|
||||||
|
|
||||||
|
if (!gotthard25um) {
|
||||||
|
startLocation[2] += nDimz;
|
||||||
|
if (startLocation[2] >= (numModZ * nDimz)) {
|
||||||
|
startLocation[2] = 0;
|
||||||
|
startLocation[1] += nDimy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
startLocationPara[1]++;
|
||||||
|
}
|
||||||
|
framesSaved += nDimx;
|
||||||
|
}
|
||||||
|
// datasets
|
||||||
|
DataSet vdsDataSet(fd->createDataSet(dataSetName.c_str(), dataType,
|
||||||
|
vdsDataSpace, plist));
|
||||||
|
|
||||||
|
for (unsigned int p = 0; p < paraSize; ++p) {
|
||||||
|
DataSet vdsDataSetPara(fd->createDataSet(
|
||||||
|
parameterNames[p].c_str(), parameterDataTypes[p],
|
||||||
|
vdsDataSpacePara, plistPara[p]));
|
||||||
|
}
|
||||||
|
|
||||||
|
fd->close();
|
||||||
|
} catch (const Exception &error) {
|
||||||
|
error.printErrorStack();
|
||||||
|
if (fd) {
|
||||||
|
fd->close();
|
||||||
|
}
|
||||||
|
throw sls::RuntimeError(
|
||||||
|
"Could not create/overwrite virtual HDF5 handles");
|
||||||
|
}
|
||||||
|
if (!silentMode) {
|
||||||
|
LOG(logINFO) << "Virtual File: " << fileName;
|
||||||
|
}
|
||||||
|
return std::array<std::string, 2>{fileName, dataSetName};
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace masterFileUtility
|
50
slsReceiverSoftware/src/MasterFileUtility.h
Normal file
50
slsReceiverSoftware/src/MasterFileUtility.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "MasterAttributes.h"
|
||||||
|
|
||||||
|
#ifdef HDF5C
|
||||||
|
#include "H5Cpp.h"
|
||||||
|
#include <mutex>
|
||||||
|
#ifndef H5_NO_NAMESPACE
|
||||||
|
using namespace H5;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace masterFileUtility {
|
||||||
|
|
||||||
|
std::string CreateMasterBinaryFile(const std::string &filePath,
|
||||||
|
const std::string &fileNamePrefix,
|
||||||
|
const uint64_t fileIndex,
|
||||||
|
const bool overWriteEnable,
|
||||||
|
const bool silentMode,
|
||||||
|
MasterAttributes *attr);
|
||||||
|
|
||||||
|
#ifdef HDF5C
|
||||||
|
void LinkHDF5FileInMaster(const std::string &masterFileName,
|
||||||
|
const std::string &dataFilename,
|
||||||
|
const std::string &dataSetname,
|
||||||
|
const std::vector<std::string> parameterNames,
|
||||||
|
const bool silentMode, std::mutex *hdf5LibMutex);
|
||||||
|
|
||||||
|
std::string CreateMasterHDF5File(const std::string &filePath,
|
||||||
|
const std::string &fileNamePrefix,
|
||||||
|
const uint64_t fileIndex,
|
||||||
|
const bool overWriteEnable,
|
||||||
|
const bool silentMode, MasterAttributes *attr,
|
||||||
|
std::mutex *hdf5LibMutex);
|
||||||
|
|
||||||
|
std::array<std::string, 2> CreateVirtualHDF5File(
|
||||||
|
const std::string &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 uint64_t numImages,
|
||||||
|
const uint32_t nPixelsX, const uint32_t nPixelsY,
|
||||||
|
const uint32_t dynamicRange, const uint64_t numImagesCaught,
|
||||||
|
const int numModX, const int numModY, const DataType dataType,
|
||||||
|
const std::vector<std::string> parameterNames,
|
||||||
|
const std::vector<DataType> parameterDataTypes, std::mutex *hdf5LibMutex,
|
||||||
|
bool gotthard25um);
|
||||||
|
#endif
|
||||||
|
} // namespace masterFileUtility
|
@ -47,83 +47,62 @@ void printHelp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start Acquisition Call back
|
* Start Acquisition Call back (slsMultiReceiver writes data if file write
|
||||||
* slsReceiver writes data if file write enabled.
|
* enabled) if registerCallBackRawDataReady or
|
||||||
* Users get data to write using call back if registerCallBackRawDataReady is
|
* registerCallBackRawDataModifyReady registered, users get data
|
||||||
* registered.
|
|
||||||
* @param filepath file path
|
|
||||||
* @param filename file name
|
|
||||||
* @param fileindex file index
|
|
||||||
* @param datasize data size in bytes
|
|
||||||
* @param p pointer to object
|
|
||||||
* \returns ignored
|
|
||||||
*/
|
*/
|
||||||
int StartAcq(std::string filepath, std::string filename, uint64_t fileindex,
|
int StartAcq(const std::string &filePath, const std::string &fileName,
|
||||||
uint32_t datasize, void *p) {
|
uint64_t fileIndex, size_t imageSize, void *objectPointer) {
|
||||||
LOG(logINFOBLUE) << "#### StartAcq: filepath:" << filepath
|
LOG(logINFOBLUE) << "#### StartAcq: filePath:" << filePath
|
||||||
<< " filename:" << filename << " fileindex:" << fileindex
|
<< " fileName:" << fileName << " fileIndex:" << fileIndex
|
||||||
<< " datasize:" << datasize << " ####";
|
<< " imageSize:" << imageSize << " ####";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Acquisition Finished Call back */
|
||||||
* Acquisition Finished Call back
|
void AcquisitionFinished(uint64_t framesCaught, void *objectPointer) {
|
||||||
* @param frames Number of frames caught
|
LOG(logINFOBLUE) << "#### AcquisitionFinished: framesCaught:"
|
||||||
* @param p pointer to object
|
<< framesCaught << " ####";
|
||||||
*/
|
|
||||||
void AcquisitionFinished(uint64_t frames, void *p) {
|
|
||||||
LOG(logINFOBLUE) << "#### AcquisitionFinished: frames:" << frames
|
|
||||||
<< " ####";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Receiver Data Call back
|
* Get Receiver Data Call back
|
||||||
* Prints in different colors(for each receiver process) the different headers
|
* Prints in different colors(for each receiver process) the different headers
|
||||||
* for each image call back.
|
* for each image call back.
|
||||||
* @param metadata sls_receiver_header metadata
|
|
||||||
* @param datapointer pointer to data
|
|
||||||
* @param datasize data size in bytes.
|
|
||||||
* @param p pointer to object
|
|
||||||
*/
|
*/
|
||||||
void GetData(char *metadata, char *datapointer, uint32_t datasize, void *p) {
|
void GetData(slsDetectorDefs::sls_receiver_header *header, char *dataPointer,
|
||||||
slsDetectorDefs::sls_receiver_header *header =
|
size_t imageSize, void *objectPointer) {
|
||||||
(slsDetectorDefs::sls_receiver_header *)metadata;
|
|
||||||
slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader;
|
slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader;
|
||||||
|
|
||||||
PRINT_IN_COLOR(
|
PRINT_IN_COLOR(
|
||||||
detectorHeader.modId ? detectorHeader.modId : detectorHeader.row,
|
detectorHeader.modId ? detectorHeader.modId : detectorHeader.row,
|
||||||
"#### %d GetData: ####\n"
|
"#### %d %d GetData: ####\n"
|
||||||
"frameNumber: %lu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %lu"
|
"frameNumber: %lu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %lu"
|
||||||
"\t\ttimestamp: %lu\t\tmodId: %u\t\t"
|
"\t\ttimestamp: %lu\t\tmodId: %u\t\t"
|
||||||
"row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u"
|
"row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u"
|
||||||
"\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u"
|
"\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u"
|
||||||
//"\t\tpacketsMask:%s"
|
//"\t\tpacketsMask:%s"
|
||||||
"\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n",
|
"\t\tfirstbytedata: 0x%x\t\tdatsize: %zu\n\n",
|
||||||
detectorHeader.row, (long unsigned int)detectorHeader.frameNumber,
|
detectorHeader.column, detectorHeader.row,
|
||||||
detectorHeader.expLength, detectorHeader.packetNumber,
|
(long unsigned int)detectorHeader.frameNumber, detectorHeader.expLength,
|
||||||
(long unsigned int)detectorHeader.bunchId,
|
detectorHeader.packetNumber, (long unsigned int)detectorHeader.bunchId,
|
||||||
(long unsigned int)detectorHeader.timestamp, detectorHeader.modId,
|
(long unsigned int)detectorHeader.timestamp, detectorHeader.modId,
|
||||||
detectorHeader.row, detectorHeader.column, detectorHeader.reserved,
|
detectorHeader.row, detectorHeader.column, detectorHeader.reserved,
|
||||||
detectorHeader.debug, detectorHeader.roundRNumber,
|
detectorHeader.debug, detectorHeader.roundRNumber,
|
||||||
detectorHeader.detType, detectorHeader.version,
|
detectorHeader.detType, detectorHeader.version,
|
||||||
// header->packetsMask.to_string().c_str(),
|
// header->packetsMask.to_string().c_str(),
|
||||||
((uint8_t)(*((uint8_t *)(datapointer)))), datasize);
|
((uint8_t)(*((uint8_t *)(dataPointer)))), imageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Receiver Data Call back (modified)
|
* Get Receiver Data Call back (modified)
|
||||||
* Prints in different colors(for each receiver process) the different headers
|
* Prints in different colors(for each receiver process) the different headers
|
||||||
* for each image call back.
|
* for each image call back.
|
||||||
* @param metadata sls_receiver_header metadata
|
* @param modifiedImageSize new data size in bytes after the callback.
|
||||||
* @param datapointer pointer to data
|
|
||||||
* @param revDatasize new data size in bytes after the callback.
|
|
||||||
* This will be the size written/streamed. (only smaller value is allowed).
|
* This will be the size written/streamed. (only smaller value is allowed).
|
||||||
* @param p pointer to object
|
|
||||||
*/
|
*/
|
||||||
void GetData(char *metadata, char *datapointer, uint32_t &revDatasize,
|
void GetData(slsDetectorDefs::sls_receiver_header *header, char *dataPointer,
|
||||||
void *p) {
|
size_t &modifiedImageSize, void *objectPointer) {
|
||||||
slsDetectorDefs::sls_receiver_header *header =
|
|
||||||
(slsDetectorDefs::sls_receiver_header *)metadata;
|
|
||||||
slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader;
|
slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader;
|
||||||
|
|
||||||
PRINT_IN_COLOR(
|
PRINT_IN_COLOR(
|
||||||
@ -135,7 +114,7 @@ void GetData(char *metadata, char *datapointer, uint32_t &revDatasize,
|
|||||||
"row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u"
|
"row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u"
|
||||||
"\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u"
|
"\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u"
|
||||||
//"\t\tpacketsMask:%s"
|
//"\t\tpacketsMask:%s"
|
||||||
"\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n",
|
"\t\tfirstbytedata: 0x%x\t\tdatsize: %zu\n\n",
|
||||||
detectorHeader.row, (long long unsigned int)detectorHeader.frameNumber,
|
detectorHeader.row, (long long unsigned int)detectorHeader.frameNumber,
|
||||||
detectorHeader.expLength, detectorHeader.packetNumber,
|
detectorHeader.expLength, detectorHeader.packetNumber,
|
||||||
(long long unsigned int)detectorHeader.bunchId,
|
(long long unsigned int)detectorHeader.bunchId,
|
||||||
@ -144,10 +123,10 @@ void GetData(char *metadata, char *datapointer, uint32_t &revDatasize,
|
|||||||
detectorHeader.debug, detectorHeader.roundRNumber,
|
detectorHeader.debug, detectorHeader.roundRNumber,
|
||||||
detectorHeader.detType, detectorHeader.version,
|
detectorHeader.detType, detectorHeader.version,
|
||||||
// header->packetsMask.to_string().c_str(),
|
// header->packetsMask.to_string().c_str(),
|
||||||
((uint8_t)(*((uint8_t *)(datapointer)))), revDatasize);
|
((uint8_t)(*((uint8_t *)(dataPointer)))), modifiedImageSize);
|
||||||
|
|
||||||
// if data is modified, eg ROI and size is reduced
|
// if data is modified, eg ROI and size is reduced
|
||||||
revDatasize = 26000;
|
modifiedImageSize = 26000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -129,7 +129,7 @@ int64_t Receiver::getReceiverVersion() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Receiver::registerCallBackStartAcquisition(
|
void Receiver::registerCallBackStartAcquisition(
|
||||||
int (*func)(std::string, std::string, uint64_t, uint32_t, void *),
|
int (*func)(const std::string &, const std::string &, uint64_t, size_t, void *),
|
||||||
void *arg) {
|
void *arg) {
|
||||||
tcpipInterface->registerCallBackStartAcquisition(func, arg);
|
tcpipInterface->registerCallBackStartAcquisition(func, arg);
|
||||||
}
|
}
|
||||||
@ -140,14 +140,13 @@ void Receiver::registerCallBackAcquisitionFinished(void (*func)(uint64_t,
|
|||||||
tcpipInterface->registerCallBackAcquisitionFinished(func, arg);
|
tcpipInterface->registerCallBackAcquisitionFinished(func, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Receiver::registerCallBackRawDataReady(void (*func)(char *, char *,
|
void Receiver::registerCallBackRawDataReady(
|
||||||
uint32_t, void *),
|
void (*func)(sls_receiver_header *, char *, size_t, void *), void *arg) {
|
||||||
void *arg) {
|
|
||||||
tcpipInterface->registerCallBackRawDataReady(func, arg);
|
tcpipInterface->registerCallBackRawDataReady(func, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Receiver::registerCallBackRawDataModifyReady(
|
void Receiver::registerCallBackRawDataModifyReady(
|
||||||
void (*func)(char *, char *, uint32_t &, void *), void *arg) {
|
void (*func)(sls_receiver_header *, char *, size_t &, void *), void *arg) {
|
||||||
tcpipInterface->registerCallBackRawDataModifyReady(func, arg);
|
tcpipInterface->registerCallBackRawDataModifyReady(func, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
// versions
|
// versions
|
||||||
#define HDF5_WRITER_VERSION (6.4) // 1 decimal places
|
#define HDF5_WRITER_VERSION (6.4) // 1 decimal places
|
||||||
#define BINARY_WRITER_VERSION (6.4) // 1 decimal places
|
#define BINARY_WRITER_VERSION (7.0) // 1 decimal places
|
||||||
|
|
||||||
#define MAX_FRAMES_PER_FILE 20000
|
#define MAX_FRAMES_PER_FILE 20000
|
||||||
#define SHORT_MAX_FRAMES_PER_FILE 100000
|
#define SHORT_MAX_FRAMES_PER_FILE 100000
|
||||||
|
@ -34,6 +34,8 @@ set(PUBLICHEADERS
|
|||||||
if(SLS_DEVEL_HEADERS)
|
if(SLS_DEVEL_HEADERS)
|
||||||
set(PUBLICHEADERS
|
set(PUBLICHEADERS
|
||||||
${PUBLICHEADERS}
|
${PUBLICHEADERS}
|
||||||
|
include/sls/ansi.h
|
||||||
|
include/sls/logger.h
|
||||||
include/sls/file_utils.h
|
include/sls/file_utils.h
|
||||||
include/sls/sls_detector_funcs.h
|
include/sls/sls_detector_funcs.h
|
||||||
include/sls/ClientSocket.h
|
include/sls/ClientSocket.h
|
||||||
@ -46,7 +48,7 @@ if(SLS_DEVEL_HEADERS)
|
|||||||
include/sls/versionAPI.h
|
include/sls/versionAPI.h
|
||||||
include/sls/ZmqSocket.h
|
include/sls/ZmqSocket.h
|
||||||
include/sls/bit_utils.h
|
include/sls/bit_utils.h
|
||||||
include/sls/mdf5.h
|
include/sls/md5.h
|
||||||
include/sls/md5_helper.h
|
include/sls/md5_helper.h
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
@ -75,13 +77,16 @@ target_include_directories(slsSupportObject
|
|||||||
PUBLIC
|
PUBLIC
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||||
|
PRIVATE
|
||||||
|
${SLS_INTERNAL_RAPIDJSON_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
message(STATUS "RAPID: ${SLS_INTERNAL_RAPIDJSON_DIR}")
|
||||||
|
|
||||||
target_link_libraries(slsSupportObject
|
target_link_libraries(slsSupportObject
|
||||||
PUBLIC
|
PUBLIC
|
||||||
slsProjectOptions
|
slsProjectOptions
|
||||||
libzmq
|
libzmq
|
||||||
rapidjson
|
|
||||||
PRIVATE
|
PRIVATE
|
||||||
slsProjectWarnings
|
slsProjectWarnings
|
||||||
md5sls
|
md5sls
|
||||||
|
@ -43,6 +43,7 @@ std::string ToString(const defs::portPosition s);
|
|||||||
std::string ToString(const defs::streamingInterface s);
|
std::string ToString(const defs::streamingInterface s);
|
||||||
std::string ToString(const defs::vetoAlgorithm s);
|
std::string ToString(const defs::vetoAlgorithm s);
|
||||||
std::string ToString(const defs::gainMode s);
|
std::string ToString(const defs::gainMode s);
|
||||||
|
std::string ToString(const defs::polarity s);
|
||||||
|
|
||||||
std::string ToString(const slsDetectorDefs::xy &coord);
|
std::string ToString(const slsDetectorDefs::xy &coord);
|
||||||
std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::xy &coord);
|
std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::xy &coord);
|
||||||
@ -313,6 +314,7 @@ template <> defs::portPosition StringTo(const std::string &s);
|
|||||||
template <> defs::streamingInterface StringTo(const std::string &s);
|
template <> defs::streamingInterface StringTo(const std::string &s);
|
||||||
template <> defs::vetoAlgorithm StringTo(const std::string &s);
|
template <> defs::vetoAlgorithm StringTo(const std::string &s);
|
||||||
template <> defs::gainMode StringTo(const std::string &s);
|
template <> defs::gainMode StringTo(const std::string &s);
|
||||||
|
template <> defs::polarity StringTo(const std::string &s);
|
||||||
|
|
||||||
template <> uint32_t StringTo(const std::string &s);
|
template <> uint32_t StringTo(const std::string &s);
|
||||||
template <> uint64_t StringTo(const std::string &s);
|
template <> uint64_t StringTo(const std::string &s);
|
||||||
|
@ -28,9 +28,9 @@ struct zmqHeader {
|
|||||||
uint32_t jsonversion{0};
|
uint32_t jsonversion{0};
|
||||||
uint32_t dynamicRange{0};
|
uint32_t dynamicRange{0};
|
||||||
uint64_t fileIndex{0};
|
uint64_t fileIndex{0};
|
||||||
/** number of detectors in x axis */
|
/** number of detectors/port in x axis */
|
||||||
uint32_t ndetx{0};
|
uint32_t ndetx{0};
|
||||||
/** number of detectors in y axis */
|
/** number of detectors/port in y axis */
|
||||||
uint32_t ndety{0};
|
uint32_t ndety{0};
|
||||||
/** number of pixels/channels in x axis for this zmq socket */
|
/** number of pixels/channels in x axis for this zmq socket */
|
||||||
uint32_t npixelsx{0};
|
uint32_t npixelsx{0};
|
||||||
|
@ -438,6 +438,8 @@ enum streamingInterface {
|
|||||||
FIX_G0
|
FIX_G0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum polarity { POSITIVE, NEGATIVE };
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
/** scan structure */
|
/** scan structure */
|
||||||
|
@ -111,7 +111,6 @@ enum detFuncs {
|
|||||||
F_SOFTWARE_TRIGGER,
|
F_SOFTWARE_TRIGGER,
|
||||||
F_LED,
|
F_LED,
|
||||||
F_DIGITAL_IO_DELAY,
|
F_DIGITAL_IO_DELAY,
|
||||||
F_COPY_DET_SERVER,
|
|
||||||
F_REBOOT_CONTROLLER,
|
F_REBOOT_CONTROLLER,
|
||||||
F_SET_ADC_ENABLE_MASK,
|
F_SET_ADC_ENABLE_MASK,
|
||||||
F_GET_ADC_ENABLE_MASK,
|
F_GET_ADC_ENABLE_MASK,
|
||||||
@ -261,9 +260,19 @@ enum detFuncs {
|
|||||||
F_SET_MASTER,
|
F_SET_MASTER,
|
||||||
F_GET_TOP,
|
F_GET_TOP,
|
||||||
F_SET_TOP,
|
F_SET_TOP,
|
||||||
|
F_GET_POLARITY,
|
||||||
|
F_SET_POLARITY,
|
||||||
|
F_GET_INTERPOLATION,
|
||||||
|
F_SET_INTERPOLATION,
|
||||||
|
F_GET_PUMP_PROBE,
|
||||||
|
F_SET_PUMP_PROBE,
|
||||||
|
F_GET_ANALOG_PULSING,
|
||||||
|
F_SET_ANALOG_PULSING,
|
||||||
|
F_GET_DIGITAL_PULSING,
|
||||||
|
F_SET_DIGITAL_PULSING,
|
||||||
|
|
||||||
NUM_DET_FUNCTIONS,
|
NUM_DET_FUNCTIONS,
|
||||||
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
RECEIVER_ENUM_START = 512, /**< detector function should not exceed this
|
||||||
(detector server should not compile anyway) */
|
(detector server should not compile anyway) */
|
||||||
|
|
||||||
F_EXEC_RECEIVER_COMMAND,
|
F_EXEC_RECEIVER_COMMAND,
|
||||||
@ -477,7 +486,6 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
|||||||
case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER";
|
case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER";
|
||||||
case F_LED: return "F_LED";
|
case F_LED: return "F_LED";
|
||||||
case F_DIGITAL_IO_DELAY: return "F_DIGITAL_IO_DELAY";
|
case F_DIGITAL_IO_DELAY: return "F_DIGITAL_IO_DELAY";
|
||||||
case F_COPY_DET_SERVER: return "F_COPY_DET_SERVER";
|
|
||||||
case F_REBOOT_CONTROLLER: return "F_REBOOT_CONTROLLER";
|
case F_REBOOT_CONTROLLER: return "F_REBOOT_CONTROLLER";
|
||||||
case F_SET_ADC_ENABLE_MASK: return "F_SET_ADC_ENABLE_MASK";
|
case F_SET_ADC_ENABLE_MASK: return "F_SET_ADC_ENABLE_MASK";
|
||||||
case F_GET_ADC_ENABLE_MASK: return "F_GET_ADC_ENABLE_MASK";
|
case F_GET_ADC_ENABLE_MASK: return "F_GET_ADC_ENABLE_MASK";
|
||||||
@ -625,6 +633,16 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
|||||||
case F_SET_MASTER: return "F_SET_MASTER";
|
case F_SET_MASTER: return "F_SET_MASTER";
|
||||||
case F_GET_TOP: return "F_GET_TOP";
|
case F_GET_TOP: return "F_GET_TOP";
|
||||||
case F_SET_TOP: return "F_SET_TOP";
|
case F_SET_TOP: return "F_SET_TOP";
|
||||||
|
case F_GET_POLARITY: return "F_GET_POLARITY";
|
||||||
|
case F_SET_POLARITY: return "F_SET_POLARITY";
|
||||||
|
case F_GET_INTERPOLATION: return "F_GET_INTERPOLATION";
|
||||||
|
case F_SET_INTERPOLATION: return "F_SET_INTERPOLATION";
|
||||||
|
case F_GET_PUMP_PROBE: return "F_GET_PUMP_PROBE";
|
||||||
|
case F_SET_PUMP_PROBE: return "F_SET_PUMP_PROBE";
|
||||||
|
case F_GET_ANALOG_PULSING: return "F_GET_ANALOG_PULSING";
|
||||||
|
case F_SET_ANALOG_PULSING: return "F_SET_ANALOG_PULSING";
|
||||||
|
case F_GET_DIGITAL_PULSING: return "F_GET_DIGITAL_PULSING";
|
||||||
|
case F_SET_DIGITAL_PULSING: return "F_SET_DIGITAL_PULSING";
|
||||||
|
|
||||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
/** API versions */
|
/** API versions */
|
||||||
#define GITBRANCH "developer"
|
#define GITBRANCH "developer"
|
||||||
#define APILIB 0x211125
|
#define APILIB 0x220408
|
||||||
#define APIRECEIVER 0x211124
|
#define APIRECEIVER 0x220408
|
||||||
#define APIGUI 0x211124
|
#define APIGUI 0x220328
|
||||||
|
|
||||||
#define APIEIGER 0x220324
|
#define APICTB 0x220428
|
||||||
#define APICTB 0x220328
|
#define APIGOTTHARD 0x220428
|
||||||
#define APIGOTTHARD 0x220328
|
#define APIGOTTHARD2 0x220428
|
||||||
#define APIGOTTHARD2 0x220328
|
#define APIJUNGFRAU 0x220428
|
||||||
#define APIJUNGFRAU 0x220328
|
#define APIMOENCH 0x220427
|
||||||
#define APIMYTHEN3 0x220328
|
#define APIEIGER 0x220428
|
||||||
#define APIMOENCH 0x220328
|
#define APIMYTHEN3 0x220510
|
||||||
|
@ -642,6 +642,17 @@ std::string ToString(const defs::gainMode s) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ToString(const defs::polarity s) {
|
||||||
|
switch (s) {
|
||||||
|
case defs::POSITIVE:
|
||||||
|
return std::string("pos");
|
||||||
|
case defs::NEGATIVE:
|
||||||
|
return std::string("neg");
|
||||||
|
default:
|
||||||
|
return std::string("Unknown");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const std::string &ToString(const std::string &s) { return s; }
|
const std::string &ToString(const std::string &s) { return s; }
|
||||||
|
|
||||||
template <> defs::detectorType StringTo(const std::string &s) {
|
template <> defs::detectorType StringTo(const std::string &s) {
|
||||||
@ -1055,6 +1066,14 @@ template <> defs::gainMode StringTo(const std::string &s) {
|
|||||||
throw sls::RuntimeError("Unknown gain mode " + s);
|
throw sls::RuntimeError("Unknown gain mode " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <> defs::polarity StringTo(const std::string &s) {
|
||||||
|
if (s == "pos")
|
||||||
|
return defs::POSITIVE;
|
||||||
|
if (s == "neg")
|
||||||
|
return defs::NEGATIVE;
|
||||||
|
throw sls::RuntimeError("Unknown polarity mode " + s);
|
||||||
|
}
|
||||||
|
|
||||||
template <> uint32_t StringTo(const std::string &s) {
|
template <> uint32_t StringTo(const std::string &s) {
|
||||||
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
||||||
return std::stoul(s, nullptr, base);
|
return std::stoul(s, nullptr, base);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
TEST_CASE("Time 1s restart then time 2s") {
|
TEST_CASE("Time 1s restart then time 2s", "[.timer]") {
|
||||||
auto sleep_duration = std::chrono::seconds(1);
|
auto sleep_duration = std::chrono::seconds(1);
|
||||||
auto t = sls::Timer();
|
auto t = sls::Timer();
|
||||||
std::this_thread::sleep_for(sleep_duration);
|
std::this_thread::sleep_for(sleep_duration);
|
||||||
@ -17,7 +17,7 @@ TEST_CASE("Time 1s restart then time 2s") {
|
|||||||
REQUIRE(t.elapsed_s() == Approx(2).epsilon(0.01));
|
REQUIRE(t.elapsed_s() == Approx(2).epsilon(0.01));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Return ms") {
|
TEST_CASE("Return ms", "[.timer]") {
|
||||||
auto sleep_duration = std::chrono::milliseconds(1300);
|
auto sleep_duration = std::chrono::milliseconds(1300);
|
||||||
auto t = sls::Timer();
|
auto t = sls::Timer();
|
||||||
std::this_thread::sleep_for(sleep_duration);
|
std::this_thread::sleep_for(sleep_duration);
|
||||||
|
Reference in New Issue
Block a user