Compare commits

...

11 Commits

Author SHA1 Message Date
cd4520b051 not validating settings for dacs temporarily (#447) 2022-05-10 15:30:34 +02:00
0129c2c686 M3: master starts twice (non blocking) part 2 (#445)
* slaves and master vectors empty means all positions included: fixing double acquisition in masters

* debug print out
2022-05-10 15:23:39 +02:00
f55bdd6eae M3: master starts twice (non blocking) (#444)
* start acq for master m3 was sent twice (non blocking), removed redundant code, check that there is only one master

* m3 can have more than 1 master (when many master modules used independently)

* fix for singe mod m3 or other dets
2022-05-10 14:27:40 +02:00
36a1159f38 updated pybind11 from 2.6.2 to 2.9.2 2022-04-28 16:39:39 +02:00
98e2ddbb74 indent 2022-04-28 16:37:52 +02:00
fa12ab2858 Support external builds of python bindings, gui, ctbgui and moench stuff (#440)
Use already installed version of the slsDetectorPackage. Assumes that the library has already been built and installed either on a system wide location or pointed to by CMAKE_PREFIX_PATH
2022-04-28 16:35:29 +02:00
afeee5501c Fixpositions (#436)
* fix positions on server side

* wip

* numports wip

* wip

* jungfrau top inner interface row increment

* x, y detpos, wip

* removed eiger row indices flipping in gui (bottom flipping maintained)

* wip

* wip, jungfrau numinterfaces2

* jungfrau virtual works

* eiger, jungfrau, g2 virtual server works

* eiger positions fix, wip

* binaries in

* minor printout

* binaries in

* pointer bug

* comment to define test_mod_geometry define
2022-04-28 16:32:26 +02:00
b7153fe3e0 cmake fix 2022-04-27 11:29:04 +02:00
2db2694660 m3 rxr: inconsistent generaldata default (#435)
* inconsistent copy with generalData and implementation members, especially for m3 (non default rxr generic values), issue caught on second configure with non m3 default values, eg tengiga 0

* removing test
2022-04-22 16:02:10 +02:00
e1642cf37c bugfix cmake zeromq 2022-04-19 20:11:31 +02:00
086d22f1a3 Cleaning up the find zmq (#431) 2022-04-19 17:17:31 +02:00
40 changed files with 417 additions and 409 deletions

View File

@ -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,62 +110,68 @@ 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)
target_compile_options(slsProjectWarnings INTERFACE
-Wall
-Wextra
-Wno-unused-parameter
# -Wold-style-cast
-Wnon-virtual-dtor
-Woverloaded-virtual
-Wdouble-promotion
-Wformat=2
-Wredundant-decls
# -Wconversion
-Wvla
-Wdouble-promotion
-Werror=return-type
)
#Settings for C code
add_library(slsProjectCSettings INTERFACE)
target_compile_options(slsProjectCSettings INTERFACE
-std=gnu99 #fixed
-Wall
-Wextra
-Wno-unused-parameter
-Wdouble-promotion
-Wformat=2
-Wredundant-decls
-Wdouble-promotion
-Werror=return-type
)
#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") # slsProjectOptions and slsProjectWarnings are used
sls_enable_cxx_warning("-Wduplicated-cond") # to control options for the libraries
sls_disable_cxx_warning("-Wclass-memaccess") if(NOT TARGET slsProjectOptions)
sls_disable_c_warning("-Wstringop-truncation") 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
-Wextra
-Wno-unused-parameter
# -Wold-style-cast
-Wnon-virtual-dtor
-Woverloaded-virtual
-Wdouble-promotion
-Wformat=2
-Wredundant-decls
# -Wconversion
-Wvla
-Wdouble-promotion
-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")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(slsProjectWarnings 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
-Wall
-Wextra
-Wno-unused-parameter
-Wdouble-promotion
-Wformat=2
-Wredundant-decls
-Wdouble-promotion
-Werror=return-type
)
sls_disable_c_warning("-Wstringop-truncation")
endif()
if(SLS_USE_SANITIZER) if(SLS_USE_SANITIZER)
@ -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)

View File

@ -66,6 +66,9 @@ This document describes the differences between v7.0.0 and v6.x.x
- registerCallBackRawDataReady and registerCallBackRawDataModifyReady now gives a sls_receiver_header* instead of a char*, and uint32_t to size_t - 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 gave incorrect imagesize (+120 bytes). corrected.
- registerCallBackStartAcquisition parameter is a const string reference - 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)
2. Resolved Issues 2. Resolved Issues
================== ==================

38
cmake/SlsFindZeroMQ.cmake Normal file
View 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()

View 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 )

View File

@ -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
) )

View File

@ -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

View File

@ -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})

View File

@ -56,7 +56,8 @@ foreach(exe ${MOENCH_EXECUTABLES})
../dataStructures ../dataStructures
../interpolations ../interpolations
../../slsReceiverSoftware/include/ ../../slsReceiverSoftware/include/
../../slsSupportLib/include/ ../../slsSupportLib/include/
${SLS_INTERNAL_RAPIDJSON_DIR}
) )
target_link_libraries(${exe} target_link_libraries(${exe}

View File

@ -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),

View File

@ -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;

View File

@ -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))) =

View File

@ -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);

View File

@ -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),

View File

@ -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),

View File

@ -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,
@ -1941,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);
@ -1952,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);
@ -1963,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;
@ -2385,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),

View File

@ -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;

View File

@ -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,27 +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_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) {
@ -129,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;
@ -4700,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");
@ -4709,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");
@ -4735,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],
@ -4755,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],
@ -4784,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();
} }
} }

View File

@ -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

View File

@ -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() {

View File

@ -602,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: "
@ -1126,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, {});
@ -1193,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)

View File

@ -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

View File

@ -40,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

View File

@ -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;

View File

@ -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;
}; };

View File

@ -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();
}; };

View File

@ -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; }
@ -244,8 +254,16 @@ void Implementation::setModulePositionId(const int id) {
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);
} }
} }
@ -523,10 +541,10 @@ void Implementation::startReceiver() {
// callbacks // callbacks
if (startAcquisitionCallBack) { if (startAcquisitionCallBack) {
try { try {
std::size_t imageSize = static_cast<uint32_t>(generalData->imageSize); std::size_t imageSize =
startAcquisitionCallBack( static_cast<uint32_t>(generalData->imageSize);
filePath, fileName, fileIndex, imageSize, 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: " +
std::string(e.what())); std::string(e.what()));
@ -748,12 +766,7 @@ void Implementation::StartMasterWriter() {
MasterAttributes masterAttributes; MasterAttributes masterAttributes;
masterAttributes.detType = detType; masterAttributes.detType = detType;
masterAttributes.timingMode = timingMode; masterAttributes.timingMode = timingMode;
xy nm{numModules.x, numModules.y}; masterAttributes.geometry = numPorts;
if (quadEnable) {
nm.x = 1;
nm.y = 2;
}
masterAttributes.geometry = xy(nm.x, nm.y);
masterAttributes.imageSize = generalData->imageSize; masterAttributes.imageSize = generalData->imageSize;
masterAttributes.nPixels = masterAttributes.nPixels =
xy(generalData->nPixelsX, generalData->nPixelsY); xy(generalData->nPixelsX, generalData->nPixelsY);
@ -813,12 +826,12 @@ void Implementation::StartMasterWriter() {
std::array<std::string, 2> virtualFileAndDatasetNames; std::array<std::string, 2> virtualFileAndDatasetNames;
// create virtual hdf5 file (if multiple files) // create virtual hdf5 file (if multiple files)
if (dataProcessor[0]->GetFilesInAcquisition() > 1 || if (dataProcessor[0]->GetFilesInAcquisition() > 1 ||
(numModules.x * numModules.y) > 1) { (numPorts.x * numPorts.y) > 1) {
virtualFileAndDatasetNames = virtualFileAndDatasetNames =
dataProcessor[0]->CreateVirtualFile( dataProcessor[0]->CreateVirtualFile(
filePath, fileName, fileIndex, overwriteEnable, filePath, fileName, fileIndex, overwriteEnable,
silentMode, modulePos, numUDPInterfaces, framesPerFile, silentMode, modulePos, numUDPInterfaces, framesPerFile,
numberOfTotalFrames, numModules.x, numModules.y, numberOfTotalFrames, numPorts.x, numPorts.y,
dynamicRange, &hdf5LibMutex); dynamicRange, &hdf5LibMutex);
} }
// link file in master // link file in master
@ -869,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();
@ -923,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,
@ -1053,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,
@ -1395,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);
@ -1495,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);
@ -1627,7 +1616,8 @@ void Implementation::setDbitOffset(const int s) { ctbDbitOffset = s; }
* * * *
* ************************************************/ * ************************************************/
void Implementation::registerCallBackStartAcquisition( void Implementation::registerCallBackStartAcquisition(
int (*func)(const std::string &, const std::string &, uint64_t, size_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;

View File

@ -290,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};

View File

@ -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() {

View File

@ -47,12 +47,12 @@ void printHelp() {
} }
/** /**
* Start Acquisition Call back (slsMultiReceiver writes data if file write enabled) * Start Acquisition Call back (slsMultiReceiver writes data if file write
* if registerCallBackRawDataReady or registerCallBackRawDataModifyReady registered, * enabled) if registerCallBackRawDataReady or
* users get data * registerCallBackRawDataModifyReady registered, users get data
*/ */
int StartAcq(const std::string & filePath, const std::string & fileName, uint64_t fileIndex, int StartAcq(const std::string &filePath, const std::string &fileName,
size_t imageSize, void *objectPointer) { 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
<< " imageSize:" << imageSize << " ####"; << " imageSize:" << imageSize << " ####";
@ -61,8 +61,8 @@ int StartAcq(const std::string & filePath, const std::string & fileName, uint64_
/** Acquisition Finished Call back */ /** Acquisition Finished Call back */
void AcquisitionFinished(uint64_t framesCaught, void *objectPointer) { void AcquisitionFinished(uint64_t framesCaught, void *objectPointer) {
LOG(logINFOBLUE) << "#### AcquisitionFinished: framesCaught:" << framesCaught LOG(logINFOBLUE) << "#### AcquisitionFinished: framesCaught:"
<< " ####"; << framesCaught << " ####";
} }
/** /**
@ -76,16 +76,16 @@ void GetData(slsDetectorDefs::sls_receiver_header *header, char *dataPointer,
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: %zu\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,

View File

@ -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

View File

@ -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};

View File

@ -6,10 +6,10 @@
#define APIRECEIVER 0x220408 #define APIRECEIVER 0x220408
#define APIGUI 0x220328 #define APIGUI 0x220328
#define APICTB 0x220408 #define APICTB 0x220428
#define APIGOTTHARD 0x220408 #define APIGOTTHARD 0x220428
#define APIGOTTHARD2 0x220408 #define APIGOTTHARD2 0x220428
#define APIJUNGFRAU 0x220408 #define APIJUNGFRAU 0x220428
#define APIMYTHEN3 0x220408 #define APIMOENCH 0x220427
#define APIMOENCH 0x220408 #define APIEIGER 0x220428
#define APIEIGER 0x220408 #define APIMYTHEN3 0x220510