Compare commits

..

1 Commits

Author SHA1 Message Date
e229cd0ba7 removed Makefile for moench and integrated the build in CMake 2022-01-24 16:09:18 +01:00
251 changed files with 9606 additions and 16899 deletions

View File

@ -19,7 +19,6 @@ 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

View File

@ -8,8 +8,11 @@ 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'
@ -23,7 +26,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 "sls::") #set(namespace "${PROJECT_NAME}::")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
@ -34,8 +37,6 @@ 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)
@ -68,20 +69,6 @@ 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/"
@ -92,6 +79,9 @@ 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)
@ -110,68 +100,62 @@ else()
endif() endif()
if(SLS_EXT_BUILD) #Add two fake libraries to manage options
# Find ourself in case of external build add_library(slsProjectOptions INTERFACE)
find_package(slsDetectorPackage ${PROJECT_VERSION} REQUIRED) add_library(slsProjectWarnings INTERFACE)
endif() 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
# slsProjectOptions and slsProjectWarnings are used if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# to control options for the libraries if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.2)
if(NOT TARGET slsProjectOptions) message(FATAL_ERROR "Clang version must be at least 3.2!")
add_library(slsProjectOptions INTERFACE) endif()
target_compile_features(slsProjectOptions INTERFACE cxx_std_11) elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
endif() if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
message(FATAL_ERROR "GCC version must be at least 4.8!")
if (NOT TARGET slsProjectWarnings) endif()
add_library(slsProjectWarnings INTERFACE) if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5)
target_compile_options(slsProjectWarnings INTERFACE target_compile_options(slsProjectWarnings INTERFACE
-Wall -Wno-missing-field-initializers)
-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()
endif() endif()
# Add or disable warnings depending on if the compiler supports them
if (NOT TARGET slsProjectCSettings) # The function checks internally and sets HAS_warning-name
#Settings for C code sls_enable_cxx_warning("-Wnull-dereference")
add_library(slsProjectCSettings INTERFACE) sls_enable_cxx_warning("-Wduplicated-cond")
target_compile_options(slsProjectCSettings INTERFACE sls_disable_cxx_warning("-Wclass-memaccess")
-std=gnu99 #fixed sls_disable_c_warning("-Wstringop-truncation")
-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)
@ -186,22 +170,58 @@ if(SLS_TUNE_LOCAL)
endif() endif()
if(SLS_MASTER_PROJECT) #rapidjson
install(TARGETS slsProjectOptions slsProjectWarnings add_library(rapidjson INTERFACE)
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)
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_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()
@ -209,9 +229,8 @@ if (SLS_USE_TESTS)
endif(SLS_USE_TESTS) endif(SLS_USE_TESTS)
if(NOT SLS_EXT_BUILD) # Common functionallity to detector and receiver
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)
@ -235,7 +254,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 ${CMAKE_BINARY_DIR}/bin/) add_subdirectory(libs/pybind11)
add_subdirectory(python) add_subdirectory(python)
endif(SLS_USE_PYTHON) endif(SLS_USE_PYTHON)
@ -256,7 +275,6 @@ if(SLS_BUILD_DOCS)
endif(SLS_BUILD_DOCS) endif(SLS_BUILD_DOCS)
if(SLS_USE_MOENCH) if(SLS_USE_MOENCH)
add_subdirectory(slsDetectorCalibration/tiffio)
add_subdirectory(slsDetectorCalibration/moenchExecutables) add_subdirectory(slsDetectorCalibration/moenchExecutables)
endif(SLS_USE_MOENCH) endif(SLS_USE_MOENCH)

View File

@ -1,7 +1,7 @@
SLS Detector Package Minor Release 7.0.0 released on 25.11.2021 SLS Detector Package Minor Release 6.1.0 released on 25.11.2021
=============================================================== ===============================================================
This document describes the differences between v7.0.0 and v6.x.x This document describes the differences between v6.1.0 and v6.0.0.
@ -21,69 +21,10 @@ This document describes the differences between v7.0.0 and v6.x.x
- Fixed minor warnings (will fix commandline print of excess packets for missing packets) - Fixed minor warnings (will fix commandline print of excess packets for missing packets)
- ctb slow adcs and any other adcs (other than temp) goes to the control Server - ctb slow adcs and any other adcs (other than temp) goes to the control Server
- number of udp interfaces is 2 for Eiger (CHANGE IN API??)
- added module id for virtual servers into the udp header
- refactoring (rxr)
- fixed patsetbit and patsetmask for moench - fixed patsetbit and patsetmask for moench
- changed default vref of adc9257 to 2V for moench (from 1.33V) - changed default vref of adc9257 to 2V for moench (from 1.33V)
- moench and ctb - can set the starting frame number of next acquisition
- mythen server kernel check incompatible (cet timezone)
- rx_arping
- rx_threadsids max is now 9 (breaking api)
- fixed datastream disabling for eiger. Its only available in 10g mode.
- m3 server crash (vthrehsold dac names were not provided)
- allow vtrim to be interpolated for Eiger settings
- m3 setThresholdEnergy and setAllThresholdEnergy was overwriting gaincaps with settings enum
- can set localhost with virtual server with minimum configuration: (hostname localhost, rx_hostname localhost, udp_dstip auto)
- increases the progress according to listened index. (not processed index)
- current frame index points to listened frame index (not processed index)
- when in discard partial frames or empty mode, the frame number doesnt increase by 1, it increases to that number (so its faster)
- file write disabled by default
- eiger 12 bit mode
- start non blocking acquisition at modular level
- connect master commands to api (allow set master for eiger)
--ignore-config command line
- command line argument 'master' mainly for virtual servers (also master/top for real eiger), only one virtual server for eiger, use command lines for master/top
- stop servers also check for errors at startup( in case it was running with an older version)
- hostname cmd failed when connecting to servers in update mode (ctb, moench, jungfrau, eiger)
- missingpackets signed (negative => extra packets)
- framescaught and frameindex now returns a vector for each port
- progress looks at activated or enabled ports, so progress does not stagnate
- (eiger) disable datastreaming also for virtual servers only for 10g
- missing packets also takes care of disabled ports
- added geometry to metadata
- 10g eiger nextframenumber get fixed.
- stop, able to set nextframenumber to a consistent (max + 1) for all modules if different (eiger/ctb/jungfrau/moench)
- ctb: can set names for all the dacs
- 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)
- 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
- rx_roi
- 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?)
- m3 virtual server sends the right pacets now
- gap pixels in gui enabled by default
- rxr src files and classes (detectordata, ZmqSocket, helpDacs) added to sls namespace, and macros (namely from logger (logINFO etc)), slsDetectorGui (make_unique in implemtnation requires sls nemspace (points to std otherwise) but not deectorImpl.cpp)
- blackfin programing made seamless (nCE fixed which helps)
-save settings file for m3 and eiger
- m3 threshold changes
- g2 and m3 clkdiv 2 (system clock) change should affect time settings (g2: exptime, period, delayaftertrigger, burstperiod, m3: exptime, gatedelay, gateperiod, period, delayaftertrigger)
- g2 system frequency is the same irrespective of timing source
- (apparently) rxr doesnt get stuck anymore from 6.1.1
-rx_bunchsize, (default fifodepth for g2 changed to 50)
- rxr mem size changed (fifo header size from 8 to 16) due to sls rxr header = 112.. 112+ 16=128 (reduces packet losss especially for g2)
-udp_srcip and udp_Srcip2: can set to auto (for virtual or 1g data networks)
- set dataset name for all hdf5 files to "data" only
- number of storage cells is not updated in teh receiver. done. and also allowing it to be modified in running status
2. Resolved Issues 2. Resolved Issues
================== ==================

View File

@ -1,38 +0,0 @@
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

@ -1,36 +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_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}/cmake/libzmq-pkg-config/FindZeroMQ.cmake" "${CMAKE_SOURCE_DIR}/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 -rv build/install/share $PREFIX cp -r build/install/share/ $PREFIX/share

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: LGPL-3.0-or-other # SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package # Copyright (C) 2021 Contributors to the SLS Detector Package
#Copy the Moench executables #Copy the Moench executables
mkdir -p $PREFIX/bin mkdir -p $PREFIX/bin
cp build/install/bin/moench* $PREFIX/bin/. cp build/install/bin/moench04ZmqProcess $PREFIX/bin/.
cp build/install/bin/moenchZmqProcess $PREFIX/bin/.

View File

@ -34,7 +34,7 @@ add_executable(ctbGui
ctbAdcs.cpp ctbAdcs.cpp
ctbPattern.cpp ctbPattern.cpp
ctbAcquisition.cpp ctbAcquisition.cpp
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/tiffio/src/tiffIO.cpp ${CMAKE_SOURCE_DIR}/slsDetectorCalibration/tiffIO.cpp
) )
@ -43,7 +43,6 @@ target_include_directories(ctbGui PRIVATE
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/dataStructures ${CMAKE_SOURCE_DIR}/slsDetectorCalibration/dataStructures
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/interpolations ${CMAKE_SOURCE_DIR}/slsDetectorCalibration/interpolations
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/ ${CMAKE_SOURCE_DIR}/slsDetectorCalibration/
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/tiffio/include/
) )
# Headders needed for ROOT dictionary generation # Headders needed for ROOT dictionary generation

View File

@ -21,10 +21,9 @@ fi
if [ -f "$infile" ] if [ -f "$infile" ]
then then
dir=$(dirname $infile) gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c ;
gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c -I$dir;
echo compiling echo compiling
echo gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c -I$dir; echo gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c ;
$exe ; $exe ;
echo cleaning echo cleaning
rm $exe rm $exe

View File

@ -45,7 +45,6 @@ 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());

View File

@ -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', 'clearBit', 'clearROI', 'client_version', 'config', 'copyDetectorServer',
'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.

View File

@ -5,42 +5,17 @@ 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
# the following command copies new server from pc tftp folder, creates a soft link to xxxDetectorServerxxx # 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
@ -52,15 +27,18 @@ From 6.1.1 and above (no tftp required)
sls_detector_put execcommand "tftp pcxxx -r configxxx -g" sls_detector_put execcommand "tftp pcxxx -r configxxx -g"
Troubleshooting with tftp .. 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.
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.

View File

@ -3,33 +3,33 @@
### edit with hostname or IP address of your detector ### edit with hostname or IP address of your detector
############################################ ############################################
#hostname bchip181+ #hostname bchip181+
hostname bchip119.psi.ch hostname bchip181+
############################################# #############################################
### edit with hostname or 1Gbs IP address of your server ### edit with hostname or 1Gbs IP address of your server
############################################ ############################################
rx_hostname mpc2011:1777 rx_hostname mpc2011
############################################# #############################################
### edit with 10 Gbs IP of your server ### edit with 10 Gbs IP of your server
############################################ ############################################
udp_dstip 10.1.2.102 udp_dstip 10.1.1.102
############################################# #############################################
### edit with any number in the subnet of your server (first 3 numbers as above) ### edit with any number in the subnet of your server (first 3 numbers as above)
############################################ ############################################
udp_srcip 10.1.2.19 udp_srcip 10.1.1.19
udp_dstport 32000 udp_dstport 32411
############################################# #############################################
### edit with 10 Gbs IP of your server ### edit with 10 Gbs IP of your server
############################################ ############################################
rx_zmqip 10.1.2.102 rx_zmqip 10.1.1.102
rx_zmqport 77000 rx_zmqport 50003
############################################# #############################################
### edit with 1 Gbs IP of PC where you will run the GUI ### edit with 1 Gbs IP of PC where you will run the GUI
############################################ ############################################
zmqip 129.129.202.132 zmqip 129.129.202.98
zmqport 77001 zmqport 50001
@ -38,7 +38,7 @@ rx_zmqstream 1
frames 1000 frames 100000
period 0.0006 period 0.0006
exptime 0.00035 exptime 0.00035
@ -62,9 +62,3 @@ highvoltage 90
#adcreg 0x14 0x40 #adcreg 0x14 0x40
frames 10
period 0.1
rx_jsonpara subframes 1
rx_jsonpara frameMode raw
rx_jsonpara detectorMode analog

View File

@ -6,8 +6,6 @@
#include "tests/globals.h" #include "tests/globals.h"
#include <iostream> #include <iostream>
namespace sls {
class MultiDetectorFixture { class MultiDetectorFixture {
protected: protected:
DetectorImpl d; DetectorImpl d;
@ -138,7 +136,7 @@ TEST_CASE_METHOD(MultiDetectorFixture, "Get ID", "[.eigerintegration][cli]") {
std::string hn = test::hostname; std::string hn = test::hostname;
hn.erase(std::remove(begin(hn), end(hn), 'b'), end(hn)); hn.erase(std::remove(begin(hn), end(hn), 'b'), end(hn));
hn.erase(std::remove(begin(hn), end(hn), 'e'), end(hn)); hn.erase(std::remove(begin(hn), end(hn), 'e'), end(hn));
auto hostnames = split(hn, '+'); auto hostnames = sls::split(hn, '+');
CHECK(hostnames.size() == d.getNumberOfDetectors()); CHECK(hostnames.size() == d.getNumberOfDetectors());
for (int i = 0; i != d.getNumberOfDetectors(); ++i) { for (int i = 0; i != d.getNumberOfDetectors(); ++i) {
CHECK(d.getId(defs::DETECTOR_SERIAL_NUMBER, 0) == CHECK(d.getId(defs::DETECTOR_SERIAL_NUMBER, 0) ==
@ -200,5 +198,3 @@ TEST_CASE_METHOD(MultiDetectorFixture, "rate correction",
d.setRateCorrection(200); d.setRateCorrection(200);
CHECK(d.getRateCorrection() == 200); CHECK(d.getRateCorrection() == 200);
} }
} // namespace sls

View File

@ -24,8 +24,6 @@
// extern std::string detector_type; // extern std::string detector_type;
// extern dt type; // extern dt type;
namespace sls {
TEST_CASE("Single detector no receiver", "[.integration][.single]") { TEST_CASE("Single detector no receiver", "[.integration][.single]") {
auto t = Module::getTypeFromDetector(test::hostname); auto t = Module::getTypeFromDetector(test::hostname);
CHECK(t == test::type); CHECK(t == test::type);
@ -285,14 +283,14 @@ TEST_CASE(
CHECK(m.getRateCorrection() == ratecorr); CHECK(m.getRateCorrection() == ratecorr);
// ratecorr fail with dr 4 or 8 // ratecorr fail with dr 4 or 8
CHECK_THROWS_AS(m.setDynamicRange(8), RuntimeError); CHECK_THROWS_AS(m.setDynamicRange(8), sls::RuntimeError);
CHECK(m.getRateCorrection() == 0); CHECK(m.getRateCorrection() == 0);
m.setDynamicRange(16); m.setDynamicRange(16);
m.setDynamicRange(16); m.setDynamicRange(16);
m.setRateCorrection(ratecorr); m.setRateCorrection(ratecorr);
m.setDynamicRange(16); m.setDynamicRange(16);
m.setRateCorrection(ratecorr); m.setRateCorrection(ratecorr);
CHECK_THROWS_AS(m.setDynamicRange(4), RuntimeError); CHECK_THROWS_AS(m.setDynamicRange(4), sls::RuntimeError);
CHECK(m.getRateCorrection() == 0); CHECK(m.getRateCorrection() == 0);
} }
@ -331,11 +329,11 @@ TEST_CASE("Chiptestboard Loading Patterns", "[.ctbintegration]") {
m.setPatternWord(addr, word); m.setPatternWord(addr, word);
CHECK(m.setPatternWord(addr, -1) == word); CHECK(m.setPatternWord(addr, -1) == word);
addr = MAX_ADDR; addr = MAX_ADDR;
CHECK_THROWS_AS(m.setPatternWord(addr, word), RuntimeError); CHECK_THROWS_AS(m.setPatternWord(addr, word), sls::RuntimeError);
CHECK_THROWS_WITH(m.setPatternWord(addr, word), CHECK_THROWS_WITH(m.setPatternWord(addr, word),
Catch::Matchers::Contains("be between 0 and")); Catch::Matchers::Contains("be between 0 and"));
addr = -1; addr = -1;
CHECK_THROWS_AS(m.setPatternWord(addr, word), RuntimeError); CHECK_THROWS_AS(m.setPatternWord(addr, word), sls::RuntimeError);
CHECK_THROWS_WITH(m.setPatternWord(addr, word), CHECK_THROWS_WITH(m.setPatternWord(addr, word),
Catch::Matchers::Contains("be between 0 and")); Catch::Matchers::Contains("be between 0 and"));
@ -410,7 +408,7 @@ TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert",
CHECK(m.getReceiverDbitList().size() == 10); CHECK(m.getReceiverDbitList().size() == 10);
list.push_back(64); list.push_back(64);
CHECK_THROWS_AS(m.setReceiverDbitList(list), RuntimeError); CHECK_THROWS_AS(m.setReceiverDbitList(list), sls::RuntimeError);
CHECK_THROWS_WITH(m.setReceiverDbitList(list), CHECK_THROWS_WITH(m.setReceiverDbitList(list),
Catch::Matchers::Contains("be between 0 and 63")); Catch::Matchers::Contains("be between 0 and 63"));
@ -478,7 +476,7 @@ TEST_CASE("Eiger or Jungfrau nextframenumber",
CHECK(m.acquire() == slsDetectorDefs::OK); CHECK(m.acquire() == slsDetectorDefs::OK);
CHECK(m.getReceiverCurrentFrameIndex() == val); CHECK(m.getReceiverCurrentFrameIndex() == val);
CHECK_THROWS_AS(m.setNextFrameNumber(0), RuntimeError); CHECK_THROWS_AS(m.setNextFrameNumber(0), sls::RuntimeError);
if (m.getDetectorTypeAsString() == "Eiger") { if (m.getDetectorTypeAsString() == "Eiger") {
val = 281474976710655; val = 281474976710655;
@ -513,10 +511,8 @@ TEST_CASE("Eiger partialread", "[.eigerintegration][partialread]") {
m.setDynamicRange(8); m.setDynamicRange(8);
m.setPartialReadout(256); m.setPartialReadout(256);
CHECK(m.getPartialReadout() == 256); CHECK(m.getPartialReadout() == 256);
CHECK_THROWS_AS(m.setPartialReadout(1), RuntimeError); CHECK_THROWS_AS(m.setPartialReadout(1), sls::RuntimeError);
CHECK(m.getPartialReadout() == 256); CHECK(m.getPartialReadout() == 256);
CHECK_THROWS_AS(m.setPartialReadout(0), RuntimeError); CHECK_THROWS_AS(m.setPartialReadout(0), sls::RuntimeError);
m.setPartialReadout(256); m.setPartialReadout(256);
} }
} // namespace sls

View File

@ -6,12 +6,10 @@
#include "tests/globals.h" #include "tests/globals.h"
#include <iostream> #include <iostream>
namespace sls {
using namespace Catch::literals; using namespace Catch::literals;
TEST_CASE("Initialize a multi detector", "[.integration][.multi]") { TEST_CASE("Initialize a multi detector", "[.integration][.multi]") {
auto hostnames = split(test::hostname, '+'); auto hostnames = sls::split(test::hostname, '+');
DetectorImpl d(0, true, true); DetectorImpl d(0, true, true);
d.setHostname(test::hostname.c_str()); d.setHostname(test::hostname.c_str());
@ -104,6 +102,3 @@ TEST_CASE("Set and read timers", "[.integration][.multi]") {
d.freeSharedMemory(); d.freeSharedMemory();
} }
} // namespace sls

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
#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

@ -13,8 +13,8 @@ import subprocess
from parse import remove_comments from parse import remove_comments
allow_bitwise_op = ["M3_GainCaps"]
allow_bitwise_op = ["streamingInterface", "M3_GainCaps"] allow_bitwise_op = ["streamingInterface"]
op_key = {"operator|": "|", op_key = {"operator|": "|",
"operator&" : "&"} "operator&" : "&"}

View File

@ -6,57 +6,49 @@ sls::Detector class. The tool needs the libclang bindings
to be installed. to be installed.
When the Detector API is updated this file should be run When the Detector API is updated this file should be run
manually. manually
""" """
from clang import cindex from clang import cindex
import subprocess import subprocess
import argparse import argparse
import sys
import time
from pathlib import Path
from parse import system_include_paths, clang_format_version
REDC = '\033[91m'
GREENC = '\033[92m'
ENDC = '\033[0m'
def red(msg):
return f'{REDC}{msg}{ENDC}'
def green(msg):
return f'{GREENC}{msg}{ENDC}'
def check_clang_format_version(required_version):
if (ver := clang_format_version()) != required_version:
msg = red(f'Clang format version {required_version} required, detected: {ver}. Bye!')
print(msg)
sys.exit(1)
else:
msg = green(f'Found clang-format version {ver}')
print(msg)
def check_for_compile_commands_json(path):
# print(f"Looking for compile data base in: {path}")
compile_data_base_file = path/'compile_commands.json'
if not compile_data_base_file.exists():
msg = red(f"No compile_commands.json file found in {path}. Bye!")
print(msg)
sys.exit(1)
else:
msg = green(f'Found: {compile_data_base_file}')
print(msg)
from parse import system_include_paths
default_build_path = "/home/l_frojdh/sls/build/" default_build_path = "/home/l_frojdh/sls/build/"
fpath = "../../slsDetectorSoftware/src/Detector.cpp" fpath = "../../slsDetectorSoftware/src/Detector.cpp"
parser = argparse.ArgumentParser()
parser.add_argument(
"-p",
"--build_path",
help="Path to the build database",
type=str,
default=default_build_path,
)
cargs = parser.parse_args()
db = cindex.CompilationDatabase.fromDirectory(cargs.build_path)
index = cindex.Index.create()
args = db.getCompileCommands(fpath)
args = list(iter(args).__next__().arguments)[0:-1]
args = args + "-x c++ --std=c++11".split()
syspath = system_include_paths("clang++")
incargs = ["-I" + inc for inc in syspath]
args = args + incargs
tu = index.parse(fpath, args=args)
m = [] m = []
ag = [] ag = []
lines = [] lines = []
ag2 = [] ag2 = []
cn = [] cn = []
def get_arguments(node): def get_arguments(node):
@ -74,7 +66,7 @@ def get_arguments_with_default(node):
args = [] args = []
for arg in node.get_arguments(): for arg in node.get_arguments():
tokens = [t.spelling for t in arg.get_tokens()] tokens = [t.spelling for t in arg.get_tokens()]
# print(tokens) print(tokens)
if '=' in tokens: if '=' in tokens:
if arg.type.spelling == "sls::Positions": #TODO! automate if arg.type.spelling == "sls::Positions": #TODO! automate
args.append("py::arg() = Positions{}") args.append("py::arg() = Positions{}")
@ -119,67 +111,33 @@ def visit(node):
lines.append( lines.append(
f'.def("{child.spelling}",{fs} &Detector::{child.spelling}{args})' f'.def("{child.spelling}",{fs} &Detector::{child.spelling}{args})'
) )
if cargs.verbose:
print(f'&Detector::{child.spelling}{args})')
cn.append(child) cn.append(child)
for child in node.get_children(): for child in node.get_children():
visit(child) visit(child)
# .def("setRxHostname",
# (void (Detector::*)(const std::string &, Positions)) &
# Detector::setRxHostname,
# py::arg(), py::arg() = Positions{})
# .def("setRxHostname",
# (void (Detector::*)(const std::vector<std::string> &)) &
# Detector::setRxHostname,
# py::arg())
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"-p",
"--build_path",
help="Path to the build database",
type=Path,
default=default_build_path,
)
parser.add_argument(
"-v",
"--verbose",
help="more output",
action='store_true',
)
cargs = parser.parse_args()
check_clang_format_version(12)
check_for_compile_commands_json(cargs.build_path)
print("Parsing functions in Detector.h - ", end = "", flush = True) visit(tu.cursor)
t0 = time.perf_counter()
#parse functions
db = cindex.CompilationDatabase.fromDirectory(cargs.build_path)
index = cindex.Index.create()
args = db.getCompileCommands(fpath)
args = list(iter(args).__next__().arguments)[0:-1]
args = args + "-x c++ --std=c++11".split()
syspath = system_include_paths("clang++")
incargs = ["-I" + inc for inc in syspath]
args = args + incargs
tu = index.parse(fpath, args=args)
visit(tu.cursor)
print(green('OK'))
print(f'Parsing took {time.perf_counter()-t0:.3f}s')
print("Read detector_in.cpp - ", end = "")
with open("../src/detector_in.cpp") as f:
data = f.read()
s = "".join(lines)
s += ";"
text = data.replace("[[FUNCTIONS]]", s)
warning = "/* WARINING This file is auto generated any edits might be overwritten without warning */\n\n"
print(green("OK"))
print("Writing to detector.cpp - ", end = "")
with open("../src/detector.cpp", "w") as f:
f.write(warning)
f.write(text)
print(green('OK'))
# run clang format on the output with open("../src/detector_in.cpp") as f:
print('Running clang format on generated source -', end = "") data = f.read()
subprocess.run(["clang-format", "../src/detector.cpp", "-i"]) s = "".join(lines)
print(green(" OK")) s += ";"
text = data.replace("[[FUNCTIONS]]", s)
warning = "/* WARINING This file is auto generated any edits might be overwritten without warning */\n\n"
with open("../src/detector.cpp", "w") as f:
f.write(warning)
f.write(text)
# run clang format on the output
subprocess.run(["clang-format", "../src/detector.cpp", "-i"])
print("Changes since last commit:")
subprocess.run(['git', 'diff', '../src/detector.cpp'])

View File

@ -5,12 +5,6 @@ import subprocess
from subprocess import PIPE from subprocess import PIPE
import os import os
def clang_format_version():
p = subprocess.run(['clang-format', '--version'], capture_output = True)
ver = p.stdout.decode().split()[2]
major = int(ver.split('.')[0])
return major
def remove_comments(text): def remove_comments(text):
def replacer(match): def replacer(match):

View File

@ -1,45 +1,43 @@
# SPDX-License-Identifier: LGPL-3.0-or-other # SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package # Copyright (C) 2021 Contributors to the SLS Detector Package
from .detector import Detector, freeze from .detector import Detector
from .utils import element_if_equal from .utils import element_if_equal
from .dacs import DetectorDacs, NamedDacs from .dacs import DetectorDacs
import _slsdet import _slsdet
dacIndex = _slsdet.slsDetectorDefs.dacIndex dacIndex = _slsdet.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty from .detector_property import DetectorProperty
# class CtbDacs(DetectorDacs): class CtbDacs(DetectorDacs):
# """ """
# Ctb dacs Ctb dacs
# """ """
# _dacs = [('dac0', dacIndex(0), 0, 4000, 1400), _dacs = [('dac0', dacIndex(0), 0, 4000, 1400),
# ('dac1', dacIndex(1), 0, 4000, 1200), ('dac1', dacIndex(1), 0, 4000, 1200),
# ('dac2', dacIndex(2), 0, 4000, 900), ('dac2', dacIndex(2), 0, 4000, 900),
# ('dac3', dacIndex(3), 0, 4000, 1050), ('dac3', dacIndex(3), 0, 4000, 1050),
# ('dac4', dacIndex(4), 0, 4000, 1400), ('dac4', dacIndex(4), 0, 4000, 1400),
# ('dac5', dacIndex(5), 0, 4000, 655), ('dac5', dacIndex(5), 0, 4000, 655),
# ('dac6', dacIndex(6), 0, 4000, 2000), ('dac6', dacIndex(6), 0, 4000, 2000),
# ('dac7', dacIndex(7), 0, 4000, 1400), ('dac7', dacIndex(7), 0, 4000, 1400),
# ('dac8', dacIndex(8), 0, 4000, 850), ('dac8', dacIndex(8), 0, 4000, 850),
# ('dac9', dacIndex(9), 0, 4000, 2000), ('dac9', dacIndex(9), 0, 4000, 2000),
# ('dac10', dacIndex(10), 0, 4000, 2294), ('dac10', dacIndex(10), 0, 4000, 2294),
# ('dac11', dacIndex(11), 0, 4000, 983), ('dac11', dacIndex(11), 0, 4000, 983),
# ('dac12', dacIndex(12), 0, 4000, 1475), ('dac12', dacIndex(12), 0, 4000, 1475),
# ('dac13', dacIndex(13), 0, 4000, 1200), ('dac13', dacIndex(13), 0, 4000, 1200),
# ('dac14', dacIndex(14), 0, 4000, 1600), ('dac14', dacIndex(14), 0, 4000, 1600),
# ('dac15', dacIndex(15), 0, 4000, 1455), ('dac15', dacIndex(15), 0, 4000, 1455),
# ('dac16', dacIndex(16), 0, 4000, 0), ('dac16', dacIndex(16), 0, 4000, 0),
# ('dac17', dacIndex(17), 0, 4000, 1000), ('dac17', dacIndex(17), 0, 4000, 1000),
# ] ]
# _dacnames = [_d[0] for _d in _dacs] _dacnames = [_d[0] for _d in _dacs]
from .utils import element from .utils import element
@freeze
class Ctb(Detector): class Ctb(Detector):
def __init__(self, id = 0): def __init__(self, id = 0):
super().__init__(id) super().__init__(id)
self._frozen = False self._frozen = False
# self._dacs = CtbDacs(self) self._dacs = CtbDacs(self)
self._dacs = NamedDacs(self)
@property @property
def dacs(self): def dacs(self):

View File

@ -36,79 +36,6 @@ class Dac(DetectorProperty):
dacstr = ''.join([f'{item:5d}' for item in self.get()]) dacstr = ''.join([f'{item:5d}' for item in self.get()])
return f'{self.__name__:15s}:{dacstr}' return f'{self.__name__:15s}:{dacstr}'
class NamedDacs:
"""
New implementation of the detector dacs. Used at the momen for
Ctb but should replace the old one for all detectors
"""
_frozen = False
_direct_access = ['_detector', '_current', '_dacnames']
def __init__(self, detector):
self._detector = detector
self._current = 0
self._dacnames = [n.replace(" ", "") for n in detector.getDacNames()]
# # Populate the dacs
for i,name in enumerate(self._dacnames):
#name, enum, low, high, default, detector
setattr(self, name, Dac(name, dacIndex(i), 0, 4000, 1000, detector))
self._frozen = True
# def __getattr__(self, name):
# return self.__getattribute__('_' + name)
def __setattr__(self, name, value):
if not self._frozen:
#durining init we need to be able to set up the class
super().__setattr__(name, value)
else:
#Later we restrict us to manipulate dacs and a few fields
if name in self._direct_access:
super().__setattr__(name, value)
elif name in self._dacnames:
return self.__getattribute__(name).__setitem__(slice(None, None, None), value)
else:
raise AttributeError(f'Dac not found: {name}')
def __next__(self):
if self._current >= len(self._dacnames):
self._current = 0
raise StopIteration
else:
self._current += 1
return self.__getattribute__(self._dacnames[self._current-1])
# return self.__getattr__(self._dacnames[self._current-1])
def __iter__(self):
return self
def __repr__(self):
r_str = ['========== DACS =========']
r_str += [repr(dac) for dac in self]
return '\n'.join(r_str)
def get_asarray(self):
"""
Read the dacs into a numpy array with dimensions [ndacs, nmodules]
"""
dac_array = np.zeros((len(self._dacnames), len(self._detector)))
for i, _d in enumerate(self):
dac_array[i,:] = _d[:]
return dac_array
def to_array(self):
return self.get_asarray()
def set_from_array(self, dac_array):
"""
Set the dacs from an numpy array with dac values. [ndacs, nmodules]
"""
dac_array = dac_array.astype(np.int)
for i, _d in enumerate(self):
_d[:] = dac_array[i]
def from_array(self, dac_array):
self.set_from_array(dac_array)
class DetectorDacs: class DetectorDacs:
_dacs = [] _dacs = []
@ -123,7 +50,7 @@ class DetectorDacs:
# Index to support iteration # Index to support iteration
self._current = 0 self._current = 0
# Name the attributes? # Populate the dacs
for _d in self._dacs: for _d in self._dacs:
setattr(self, '_'+_d[0], Dac(*_d, detector)) setattr(self, '_'+_d[0], Dac(*_d, detector))
@ -132,10 +59,7 @@ class DetectorDacs:
def __getattr__(self, name): def __getattr__(self, name):
return self.__getattribute__('_' + name) return self.__getattribute__('_' + name)
@property
def dacnames(self):
return [_d[0] for _d in _dacs]
def __setattr__(self, name, value): def __setattr__(self, name, value):
if name in self._dacnames: if name in self._dacnames:
return self.__getattribute__('_' + name).__setitem__(slice(None, None, None), value) return self.__getattribute__('_' + name).__setitem__(slice(None, None, None), value)

View File

@ -258,7 +258,7 @@ class Detector(CppDetectorApi):
@element @element
def rx_threads(self): def rx_threads(self):
""" """
Get thread ids from the receiver in order of [parent, tcp, listener 0, processor 0, streamer 0, listener 1, processor 1, streamer 1, arping]. Get thread ids from the receiver in order of [parent, tcp, listener 0, processor 0, streamer 0, listener 1, processor 1, streamer 1].
Note Note
----- -----
@ -268,17 +268,6 @@ class Detector(CppDetectorApi):
""" """
return self.getRxThreadIds() return self.getRxThreadIds()
@property
@element
def rx_arping(self):
"""Starts a thread in slsReceiver to arping the interface it is listening every minute. Useful in 10G mode. """
return self.getRxArping()
@rx_arping.setter
def rx_arping(self, value):
ut.set_using_dict(self.setRxArping, value)
@property @property
@element @element
def dr(self): def dr(self):
@ -287,7 +276,7 @@ class Detector(CppDetectorApi):
Note Note
----- -----
[Eiger] Options: 4, 8, 12, 16, 32. If set to 32, also sets clkdivider to 2 (quarter speed), else to 0 (full speed)\n [Eiger] Options: 4, 8, 16, 32. If set to 32, also sets clkdivider to 2 (quarter speed), else to 0 (full speed)\n
[Mythen3] Options: 8, 16, 32 \n [Mythen3] Options: 8, 16, 32 \n
[Jungfrau][Gotthard][Ctb][Moench][Mythen3][Gotthard2] 16 [Jungfrau][Gotthard][Ctb][Moench][Mythen3][Gotthard2] 16
""" """
@ -599,13 +588,13 @@ class Detector(CppDetectorApi):
@property @property
@element @element
def rx_framescaught(self): def rx_framescaught(self):
"""Number of frames caught by each port in receiver.""" """Number of frames caught by receiver."""
return self.getFramesCaught() return self.getFramesCaught()
@property @property
@element @element
def nextframenumber(self): def nextframenumber(self):
"""[Eiger][Jungfrau][Moench][CTB] Next frame number. Stopping acquisition might result in different frame numbers for different modules. """ """[Eiger][Jungfrau] Next frame number. Stopping acquisition might result in different frame numbers for different modules. """
return self.getNextFrameNumber() return self.getNextFrameNumber()
@nextframenumber.setter @nextframenumber.setter
@ -1442,21 +1431,20 @@ class Detector(CppDetectorApi):
@property @property
def trimbits(self): def trimbits(self):
""" """
[Eiger][Mythen3] Loads/Saves custom trimbit file to detector. [Eiger][Mythen3] Loads custom trimbit file to detector.
Note Note
----- -----
If no extension specified, serial number of each module is attached. If no extension specified, serial number of each module is attached.
:setter: Loads the trimbit file to detector :getter: Not implemented
:getter: Saves the trimbits from the detector to file. Not implemented with 'trimbits'. Use saveTrimbits().
Example Example
------- -------
>>> d.trimbits = '/path_to_file/noise' >>> d.trimbits = '/path_to_file/noise'
- 14:53:27.931 INFO: Settings file loaded: /path_to_file/noise.sn000 - 14:53:27.931 INFO: Settings file loaded: /path_to_file/noise.sn000
""" """
raise NotImplementedError('trimbits is set only. Use saveTrimbits()') return NotImplementedError("trimbits are set only")
@trimbits.setter @trimbits.setter
def trimbits(self, fname): def trimbits(self, fname):
@ -1475,19 +1463,6 @@ class Detector(CppDetectorApi):
def trimval(self, value): def trimval(self, value):
ut.set_using_dict(self.setAllTrimbits, value) ut.set_using_dict(self.setAllTrimbits, value)
@property
@element
def master(self):
"""
[Eiger] Sets half module to master and others to slaves.\n
[Gotthard][Gotthard2][Mythen3][Eiger] Gets if the current module/ half module is master.
"""
return self.getMaster()
@master.setter
def master(self, value):
ut.set_using_dict(self.setMaster, value)
@property @property
@element @element
def lock(self): def lock(self):
@ -1572,16 +1547,8 @@ class Detector(CppDetectorApi):
@property @property
def daclist(self): def daclist(self):
""" """Gets the list of enums for every dac for this detector."""
List of enums for every dac for this detector. return self.getDacList()
:setter: Only implemented for Chiptestboard
"""
return self.getDacNames()
@daclist.setter
def daclist(self, value):
self.setDacNames(value)
@property @property
def dacvalues(self): def dacvalues(self):
@ -1834,13 +1801,13 @@ class Detector(CppDetectorApi):
@property @property
@element @element
def threshold(self): def threshold(self):
"""[Eiger][Mythen3] Threshold in eV """[Eiger] Threshold in eV
Note Note
---- ----
To change settings as well or set threshold without trimbits, use setThresholdEnergy. To change settings as well or set threshold without trimbits, use setThresholdEnergy.
:setter: It loads trim files from settingspath.\n [Mythen3] An energy of -1 will pick up values from detector. :setter: It loads trim files from settingspath.
""" """
if self.type == detectorType.MYTHEN3: if self.type == detectorType.MYTHEN3:
return self.getAllThresholdEnergy() return self.getAllThresholdEnergy()
@ -1927,13 +1894,13 @@ class Detector(CppDetectorApi):
@property @property
@element @element
def rx_frameindex(self): def rx_frameindex(self):
"""Current frame index received for each port in receiver during acquisition.""" """Current frame index received in receiver during acquisition."""
return self.getRxCurrentFrameIndex() return self.getRxCurrentFrameIndex()
@property @property
@element @element
def rx_missingpackets(self): def rx_missingpackets(self):
"""Gets the number of missing packets for each port in receiver. Negative number denotes extra packets. """ """Gets the number of missing packets for each port in receiver."""
return self.getNumMissingPackets() return self.getNumMissingPackets()
""" """
@ -1946,7 +1913,7 @@ class Detector(CppDetectorApi):
def datastream(self): def datastream(self):
""" """
datastream [left|right] [0, 1] datastream [left|right] [0, 1]
[Eiger] Enables or disables data streaming from left or/and right side of detector for 10GbE mode. 1 (enabled) by default. [Eiger] Enables or disables data streaming from left or/and right side of detector. 1 (enabled) by default.
""" """
result = {} result = {}
for port in [defs.LEFT, defs.RIGHT]: for port in [defs.LEFT, defs.RIGHT]:
@ -2148,21 +2115,6 @@ class Detector(CppDetectorApi):
""" """
return ut.reduce_time(self.getMeasuredSubFramePeriod()) return ut.reduce_time(self.getMeasuredSubFramePeriod())
@property
@element
def top(self):
"""[Eiger] Sets half module to top (1), else bottom.
Note
-----
Advanced Function!
"""
return self.getTop()
@top.setter
def top(self, value):
ut.set_using_dict(self.setTop, value)
""" """
------------------<<<Jungfrau specific>>>------------------------- ------------------<<<Jungfrau specific>>>-------------------------
""" """
@ -2618,7 +2570,7 @@ class Detector(CppDetectorApi):
------- -------
>>> d.vetophoton = (2, 24, 2560, '/tmp/bla.txt') >>> d.vetophoton = (2, 24, 2560, '/tmp/bla.txt')
""" """
raise NotImplementedError('vetophoton is set only') raise NotImplementedError('vetofile is set only')
@vetophoton.setter @vetophoton.setter
def vetophoton(self, args): def vetophoton(self, args):
@ -3499,60 +3451,10 @@ 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. interpolation mode enables all counters and disables vth3. Disabling sets back counter mask and vth3. """
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. Pump probe mode only enables vth2. Disabling sets back to previous value """
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>>>---------------------------

View File

@ -1,8 +1,8 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
/* WARINING This file is auto generated any edits might be overwritten without /* WARINING This file is auto generated any edits might be overwritten without
* warning */ * warning */
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#include <pybind11/chrono.h> #include <pybind11/chrono.h>
#include <pybind11/operators.h> #include <pybind11/operators.h>
#include <pybind11/pybind11.h> #include <pybind11/pybind11.h>
@ -144,10 +144,6 @@ void init_det(py::module &m) {
(void (Detector::*)(const std::string &, sls::Positions)) & (void (Detector::*)(const std::string &, sls::Positions)) &
Detector::loadTrimbits, Detector::loadTrimbits,
py::arg(), py::arg() = Positions{}) py::arg(), py::arg() = Positions{})
.def("saveTrimbits",
(void (Detector::*)(const std::string &, sls::Positions)) &
Detector::saveTrimbits,
py::arg(), py::arg() = Positions{})
.def("getAllTrimbits", .def("getAllTrimbits",
(Result<int>(Detector::*)(sls::Positions) const) & (Result<int>(Detector::*)(sls::Positions) const) &
Detector::getAllTrimbits, Detector::getAllTrimbits,
@ -177,12 +173,6 @@ void init_det(py::module &m) {
.def("setFlipRows", .def("setFlipRows",
(void (Detector::*)(bool, sls::Positions)) & Detector::setFlipRows, (void (Detector::*)(bool, sls::Positions)) & Detector::setFlipRows,
py::arg(), py::arg() = Positions{}) py::arg(), py::arg() = Positions{})
.def("getMaster",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getMaster,
py::arg() = Positions{})
.def("setMaster", (void (Detector::*)(bool, int)) & Detector::setMaster,
py::arg(), py::arg())
.def("isVirtualDetectorServer", .def("isVirtualDetectorServer",
(Result<bool>(Detector::*)(sls::Positions) const) & (Result<bool>(Detector::*)(sls::Positions) const) &
Detector::isVirtualDetectorServer, Detector::isVirtualDetectorServer,
@ -191,12 +181,12 @@ void init_det(py::module &m) {
(void (Detector::*)(void (*)(double, int, void *), void *)) & (void (Detector::*)(void (*)(double, int, void *), void *)) &
Detector::registerAcquisitionFinishedCallback, Detector::registerAcquisitionFinishedCallback,
py::arg(), py::arg()) py::arg(), py::arg())
.def("registerDataCallback", .def(
(void (Detector::*)( "registerDataCallback",
void (*)(sls::detectorData *, uint64_t, uint32_t, void *), (void (Detector::*)(
void *)) & void (*)(detectorData *, uint64_t, uint32_t, void *), void *)) &
Detector::registerDataCallback, Detector::registerDataCallback,
py::arg(), py::arg()) py::arg(), py::arg())
.def("getNumberOfFrames", .def("getNumberOfFrames",
(Result<int64_t>(Detector::*)(sls::Positions) const) & (Result<int64_t>(Detector::*)(sls::Positions) const) &
Detector::getNumberOfFrames, Detector::getNumberOfFrames,
@ -480,9 +470,7 @@ void init_det(py::module &m) {
(void (Detector::*)()) & Detector::clearAcquiringFlag) (void (Detector::*)()) & Detector::clearAcquiringFlag)
.def("startReceiver", (void (Detector::*)()) & Detector::startReceiver) .def("startReceiver", (void (Detector::*)()) & Detector::startReceiver)
.def("stopReceiver", (void (Detector::*)()) & Detector::stopReceiver) .def("stopReceiver", (void (Detector::*)()) & Detector::stopReceiver)
.def("startDetector", .def("startDetector", (void (Detector::*)()) & Detector::startDetector)
(void (Detector::*)(sls::Positions)) & Detector::startDetector,
py::arg() = Positions{})
.def("startDetectorReadout", .def("startDetectorReadout",
(void (Detector::*)()) & Detector::startDetectorReadout) (void (Detector::*)()) & Detector::startDetectorReadout)
.def("stopDetector", .def("stopDetector",
@ -497,17 +485,14 @@ void init_det(py::module &m) {
Detector::getReceiverStatus, Detector::getReceiverStatus,
py::arg() = Positions{}) py::arg() = Positions{})
.def("getFramesCaught", .def("getFramesCaught",
(Result<std::vector<int64_t>>(Detector::*)(sls::Positions) const) & (Result<int64_t>(Detector::*)(sls::Positions) const) &
Detector::getFramesCaught, Detector::getFramesCaught,
py::arg() = Positions{}) py::arg() = Positions{})
.def("getNumMissingPackets", .def(
(Result<std::vector<int64_t>>(Detector::*)(sls::Positions) const) & "getNumMissingPackets",
Detector::getNumMissingPackets, (Result<std::vector<uint64_t>>(Detector::*)(sls::Positions) const) &
py::arg() = Positions{}) Detector::getNumMissingPackets,
.def("getRxCurrentFrameIndex", py::arg() = Positions{})
(Result<std::vector<int64_t>>(Detector::*)(sls::Positions) const) &
Detector::getRxCurrentFrameIndex,
py::arg() = Positions{})
.def("getNextFrameNumber", .def("getNextFrameNumber",
(Result<uint64_t>(Detector::*)(sls::Positions) const) & (Result<uint64_t>(Detector::*)(sls::Positions) const) &
Detector::getNextFrameNumber, Detector::getNextFrameNumber,
@ -780,25 +765,9 @@ void init_det(py::module &m) {
Detector::getRxLastClientIP, Detector::getRxLastClientIP,
py::arg() = Positions{}) py::arg() = Positions{})
.def("getRxThreadIds", .def("getRxThreadIds",
(Result<std::array<pid_t, 9>>(Detector::*)(sls::Positions) const) & (Result<std::array<pid_t, 8>>(Detector::*)(sls::Positions) const) &
Detector::getRxThreadIds, Detector::getRxThreadIds,
py::arg() = Positions{}) py::arg() = Positions{})
.def("getRxArping",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getRxArping,
py::arg() = Positions{})
.def("setRxArping",
(void (Detector::*)(bool, sls::Positions)) & Detector::setRxArping,
py::arg(), py::arg() = Positions{})
.def("getIndividualRxROIs",
(Result<defs::ROI>(Detector::*)(sls::Positions) const) &
Detector::getIndividualRxROIs,
py::arg())
.def("getRxROI", (defs::ROI(Detector::*)() const) & Detector::getRxROI)
.def("setRxROI",
(void (Detector::*)(const defs::ROI)) & Detector::setRxROI,
py::arg())
.def("clearRxROI", (void (Detector::*)()) & Detector::clearRxROI)
.def("getFileFormat", .def("getFileFormat",
(Result<defs::fileFormat>(Detector::*)(sls::Positions) const) & (Result<defs::fileFormat>(Detector::*)(sls::Positions) const) &
Detector::getFileFormat, Detector::getFileFormat,
@ -1028,13 +997,6 @@ void init_det(py::module &m) {
sls::Positions)) & sls::Positions)) &
Detector::setDataStream, Detector::setDataStream,
py::arg(), py::arg(), py::arg() = Positions{}) py::arg(), py::arg(), py::arg() = Positions{})
.def("getTop",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getTop,
py::arg() = Positions{})
.def("setTop",
(void (Detector::*)(bool, sls::Positions)) & Detector::setTop,
py::arg(), py::arg() = Positions{})
.def("getChipVersion", .def("getChipVersion",
(Result<double>(Detector::*)(sls::Positions) const) & (Result<double>(Detector::*)(sls::Positions) const) &
Detector::getChipVersion, Detector::getChipVersion,
@ -1293,6 +1255,10 @@ void init_det(py::module &m) {
(Result<std::array<ns, 3>>(Detector::*)(sls::Positions) const) & (Result<std::array<ns, 3>>(Detector::*)(sls::Positions) const) &
Detector::getGateDelayForAllGates, Detector::getGateDelayForAllGates,
py::arg() = Positions{}) py::arg() = Positions{})
.def("getMaster",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getMaster,
py::arg() = Positions{})
.def("getChipStatusRegister", .def("getChipStatusRegister",
(Result<int>(Detector::*)(sls::Positions) const) & (Result<int>(Detector::*)(sls::Positions) const) &
Detector::getChipStatusRegister, Detector::getChipStatusRegister,
@ -1303,46 +1269,6 @@ 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,
@ -1480,19 +1406,6 @@ void init_det(py::module &m) {
(void (Detector::*)(bool, sls::Positions)) & (void (Detector::*)(bool, sls::Positions)) &
Detector::setLEDEnable, Detector::setLEDEnable,
py::arg(), py::arg() = Positions{}) py::arg(), py::arg() = Positions{})
.def("setDacNames",
(void (Detector::*)(const std::vector<std::string>)) &
Detector::setDacNames,
py::arg())
.def("getDacNames", (std::vector<std::string>(Detector::*)() const) &
Detector::getDacNames)
.def("getDacIndex",
(defs::dacIndex(Detector::*)(const std::string &)) &
Detector::getDacIndex,
py::arg())
.def("getDacName",
(std::string(Detector::*)(defs::dacIndex)) & Detector::getDacName,
py::arg())
.def("setPattern", .def("setPattern",
(void (Detector::*)(const std::string &, sls::Positions)) & (void (Detector::*)(const std::string &, sls::Positions)) &
Detector::setPattern, Detector::setPattern,
@ -1597,13 +1510,17 @@ void init_det(py::module &m) {
Detector::setAdditionalJsonParameter, Detector::setAdditionalJsonParameter,
py::arg(), py::arg(), py::arg() = Positions{}) py::arg(), py::arg(), py::arg() = Positions{})
.def("programFPGA", .def("programFPGA",
(void (Detector::*)(const std::string &, const bool, (void (Detector::*)(const std::string &, sls::Positions)) &
sls::Positions)) &
Detector::programFPGA, Detector::programFPGA,
py::arg(), py::arg(), py::arg() = Positions{}) py::arg(), py::arg() = Positions{})
.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,
@ -1615,6 +1532,11 @@ void init_det(py::module &m) {
.def("rebootController", .def("rebootController",
(void (Detector::*)(sls::Positions)) & Detector::rebootController, (void (Detector::*)(sls::Positions)) & Detector::rebootController,
py::arg() = Positions{}) py::arg() = Positions{})
.def("updateFirmwareAndServer",
(void (Detector::*)(const std::string &, const std::string &,
const std::string &, sls::Positions)) &
Detector::updateFirmwareAndServer,
py::arg(), py::arg(), py::arg(), py::arg() = Positions{})
.def("updateFirmwareAndServer", .def("updateFirmwareAndServer",
(void (Detector::*)(const std::string &, const std::string &, (void (Detector::*)(const std::string &, const std::string &,
sls::Positions)) & sls::Positions)) &
@ -1625,7 +1547,7 @@ void init_det(py::module &m) {
Detector::getUpdateMode, Detector::getUpdateMode,
py::arg() = Positions{}) py::arg() = Positions{})
.def("setUpdateMode", .def("setUpdateMode",
(void (Detector::*)(const bool, sls::Positions)) & (void (Detector::*)(bool, sls::Positions)) &
Detector::setUpdateMode, Detector::setUpdateMode,
py::arg(), py::arg() = Positions{}) py::arg(), py::arg() = Positions{})
.def("readRegister", .def("readRegister",
@ -1717,5 +1639,9 @@ void init_det(py::module &m) {
Detector::getMeasurementTime, Detector::getMeasurementTime,
py::arg() = Positions{}) py::arg() = Positions{})
.def("getUserDetails", .def("getUserDetails",
(std::string(Detector::*)() const) & Detector::getUserDetails); (std::string(Detector::*)() const) & Detector::getUserDetails)
.def("getRxCurrentFrameIndex",
(Result<uint64_t>(Detector::*)(sls::Positions) const) &
Detector::getRxCurrentFrameIndex,
py::arg() = Positions{});
} }

View File

@ -273,8 +273,7 @@ void init_enums(py::module &m) {
slsDetectorDefs::timingSourceType::TIMING_EXTERNAL) slsDetectorDefs::timingSourceType::TIMING_EXTERNAL)
.export_values(); .export_values();
py::enum_<slsDetectorDefs::M3_GainCaps>(Defs, "M3_GainCaps", py::enum_<slsDetectorDefs::M3_GainCaps>(Defs, "M3_GainCaps")
py::arithmetic())
.value("M3_C10pre", slsDetectorDefs::M3_GainCaps::M3_C10pre) .value("M3_C10pre", slsDetectorDefs::M3_GainCaps::M3_C10pre)
.value("M3_C15sh", slsDetectorDefs::M3_GainCaps::M3_C15sh) .value("M3_C15sh", slsDetectorDefs::M3_GainCaps::M3_C15sh)
.value("M3_C30sh", slsDetectorDefs::M3_GainCaps::M3_C30sh) .value("M3_C30sh", slsDetectorDefs::M3_GainCaps::M3_C30sh)
@ -315,9 +314,4 @@ 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();
} }

View File

@ -10,7 +10,7 @@
#include "pedestalSubtraction.h" #include "pedestalSubtraction.h"
#include "slsDetectorData.h" #include "slsDetectorData.h"
#include "slsInterpolation.h" #include "slsInterpolation.h"
#include "sls/tiffIO.h" #include "tiffIO.h"
#include <pthread.h> #include <pthread.h>
#ifdef ROOTSPECTRUM #ifdef ROOTSPECTRUM

View File

@ -2,9 +2,49 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
#ifndef MOENCH03T1RECDATANEW_H #ifndef MOENCH03T1RECDATANEW_H
#define MOENCH03T1RECDATANEW_H #define MOENCH03T1RECDATANEW_H
#include "sls/sls_detector_defs.h"
#include "slsDetectorData.h" #include "slsDetectorData.h"
//#define VERSION_V2
/**
@short structure for a Detector Packet or Image Header
@li frameNumber is the frame number
@li expLength is the subframe number (32 bit eiger) or real time exposure
time in 100ns (others)
@li packetNumber is the packet number
@li bunchId is the bunch id from beamline
@li timestamp is the time stamp with 10 MHz clock
@li modId is the unique module id (unique even for left, right, top, bottom)
@li xCoord is the x coordinate in the complete detector system
@li yCoord is the y coordinate in the complete detector system
@li zCoord is the z coordinate in the complete detector system
@li debug is for debugging purposes
@li roundRNumber is the round robin set number
@li detType is the detector type see :: detectorType
@li version is the version number of this structure format
*/
typedef struct {
uint64_t frameNumber; /**< is the frame number */
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time
exposure time in 100ns (others) */
uint32_t packetNumber; /**< is the packet number */
uint64_t bunchId; /**< is the bunch id from beamline */
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
uint16_t modId; /**< is the unique module id (unique even for left, right,
top, bottom) */
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
uint32_t debug; /**< is for debugging purposes */
uint16_t roundRNumber; /**< is the round robin set number */
uint8_t detType; /**< is the detector type see :: detectorType */
uint8_t version; /**< is the version number of this structure format */
#ifndef VERSION_V1
uint64_t
packetCaught[8]; /**< is the version number of this structure format */
#endif
} sls_detector_header;
class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> { class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
private: private:
@ -16,9 +56,6 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
double ghost[200][25]; double ghost[200][25];
// Single point of definition if we need to customize
using header = sls::defs::sls_receiver_header;
public: public:
/** /**
Implements the slsReceiverData structure for the moench02 prototype read Implements the slsReceiverData structure for the moench02 prototype read
@ -27,7 +64,8 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
*/ */
moench03T1ReceiverDataNew(int ns = 5000) moench03T1ReceiverDataNew(int ns = 5000)
: slsDetectorData<uint16_t>(400, 400, ns * 2 * 32 + sizeof(header)), : slsDetectorData<uint16_t>(400, 400,
ns * 2 * 32 + sizeof(sls_detector_header)),
nSamples(ns) { nSamples(ns) {
int nadc = 32; int nadc = 32;
@ -62,15 +100,15 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
} else { } else {
row = 200 + i / sc_width; row = 200 + i / sc_width;
} }
dataMap[row][col] = sizeof(header) + dataMap[row][col] = sizeof(sls_detector_header) +
(nadc * i + iadc) * 2; //+16*(ip+1); (nadc * i + iadc) * 2; //+16*(ip+1);
#ifdef HIGHZ #ifdef HIGHZ
dataMask[row][col] = 0x3fff; // invert data dataMask[row][col] = 0x3fff; // invert data
#endif #endif
if (dataMap[row][col] < 0 || if (dataMap[row][col] < 0 ||
dataMap[row][col] >= nSamples * 2 * 32) dataMap[row][col] >= nSamples * 2 * 32)
std::cout << "Error: pointer " << dataMap[row][col] cout << "Error: pointer " << dataMap[row][col]
<< " out of range " << std::endl; << " out of range " << endl;
} }
} }
} }
@ -82,13 +120,13 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
ghost[iy][ix] = 0.; ghost[iy][ix] = 0.;
int ipacket; int ipacket;
uint ibyte; int ibyte;
int ii = 0; int ii = 0;
for (ibyte = 0; ibyte < sizeof(header) / 2; ibyte++) { for (ibyte = 0; ibyte < sizeof(sls_detector_header) / 2; ibyte++) {
xmap[ibyte] = -1; xmap[ibyte] = -1;
ymap[ibyte] = -1; ymap[ibyte] = -1;
} }
int off = sizeof(header) / 2; int off = sizeof(sls_detector_header) / 2;
for (ipacket = 0; ipacket < npackets; ipacket++) { for (ipacket = 0; ipacket < npackets; ipacket++) {
for (ibyte = 0; ibyte < 8192 / 2; ibyte++) { for (ibyte = 0; ibyte < 8192 / 2; ibyte++) {
i = ipacket * 8208 / 2 + ibyte; i = ipacket * 8208 / 2 + ibyte;
@ -123,7 +161,20 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
required as double required as double
*/ */
double getValue(char *data, int ix, int iy = 0) override { virtual double getValue(char *data, int ix, int iy = 0) {
/* cout << " x "<< ix << " y"<< iy << " val " << getChannel(data, ix,
* iy)<< endl;*/
/* double val=0, vout=getChannel(data, ix, iy); */
/* int x1=ix%25; */
/* for (int ix=0; ix<16; ix++) { */
/* for (int ii=0; ii<2; ii++) { */
/* val+=getChannel(data,x1+25*ix,iy); */
/* val+=getChannel(data,x1+25*ix,399-iy); */
/* } */
/* } */
/* vout+=0.0008*val-6224; */
/* return vout; //(double)getChannel(data, ix, iy);
*/
uint16_t val = getChannel(data, ix, iy) & 0x3fff; uint16_t val = getChannel(data, ix, iy) & 0x3fff;
return val; return val;
}; };
@ -174,9 +225,17 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
*/ */
/* class jfrau_packet_header_t { */
/* public: */
/* unsigned char reserved[4]; */
/* unsigned char packetNumber[1]; */
/* unsigned char frameNumber[3]; */
/* unsigned char bunchid[8]; */
/* }; */
int getFrameNumber(char *buff) { int getFrameNumber(char *buff) {
return ((header *)buff)->detHeader.frameNumber; return ((sls_detector_header *)buff)->frameNumber;
} }; //*((int*)(buff+5))&0xffffff;};
/** /**
@ -188,22 +247,68 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
*/ */
int getPacketNumber(char *buff) { int getPacketNumber(char *buff) {
return ((header *)buff)->detHeader.packetNumber; return ((sls_detector_header *)buff)->packetNumber;
} } //((*(((int*)(buff+4))))&0xff)+1;};
char *readNextFrame(std::ifstream &filebin) override { /* /\** */
/* Loops over a memory slot until a complete frame is found (i.e. all
* packets 0 to nPackets, same frame number). purely virtual func */
/* \param data pointer to the memory to be analyzed */
/* \param ndata reference to the amount of data found for the frame, in
* case the frame is incomplete at the end of the memory slot */
/* \param dsize size of the memory slot to be analyzed */
/* \returns pointer to the beginning of the last good frame (might be
* incomplete if ndata smaller than dataSize), or NULL if no frame is found
*/
/* *\/ */
/* virtual char *findNextFrame(char *data, int &ndata, int
* dsize){ndata=dsize; setDataSize(dsize); return data;}; */
/* /\** */
/* Loops over a file stream until a complete frame is found (i.e. all
* packets 0 to nPackets, same frame number). Can be overloaded for
* different kind of detectors! */
/* \param filebin input file stream (binary) */
/* \returns pointer to the begin of the last good frame, NULL if no
* frame is found or last frame is incomplete */
/* *\/ */
/* virtual char *readNextFrame(ifstream &filebin){ */
/* // int afifo_length=0; */
/* uint16_t *afifo_cont; */
/* int ib=0; */
/* if (filebin.is_open()) { */
/* afifo_cont=new uint16_t[dataSize/2]; */
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
/* ib+=2; */
/* if (ib==dataSize) break; */
/* } */
/* if (ib>0) { */
/* iframe++; */
/* // cout << ib << "-" << endl; */
/* return (char*)afifo_cont; */
/* } else { */
/* delete [] afifo_cont; */
/* return NULL; */
/* } */
/* } */
/* return NULL; */
/* }; */
virtual char *readNextFrame(ifstream &filebin) {
int ff = -1, np = -1; int ff = -1, np = -1;
return readNextFrame(filebin, ff, np); return readNextFrame(filebin, ff, np);
} };
// not present in base class virtual char *readNextFrame(ifstream &filebin, int &ff) {
virtual char *readNextFrame(std::ifstream &filebin, int &ff) {
int np = -1; int np = -1;
return readNextFrame(filebin, ff, np); return readNextFrame(filebin, ff, np);
}; };
// not present in base class virtual char *readNextFrame(ifstream &filebin, int &ff, int &np) {
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np) {
char *data = new char[dataSize]; char *data = new char[dataSize];
char *d = readNextFrame(filebin, ff, np, data); char *d = readNextFrame(filebin, ff, np, data);
if (d == NULL) { if (d == NULL) {
@ -213,10 +318,18 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
return data; return data;
} }
// not present in base class virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np,
char *data) { char *data) {
char *retval = 0;
int nd;
int fnum = -1;
np = 0; np = 0;
int pn;
// cout << dataSize << endl;
if (ff >= 0)
fnum = ff;
if (filebin.is_open()) { if (filebin.is_open()) {
if (filebin.read(data, dataSize)) { if (filebin.read(data, dataSize)) {
ff = getFrameNumber(data); ff = getFrameNumber(data);
@ -224,8 +337,8 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
return data; return data;
} }
} }
return nullptr; return NULL;
} };
/** /**
@ -239,7 +352,7 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
found found
*/ */
char *findNextFrame(char *data, int &ndata, int dsize) override { virtual char *findNextFrame(char *data, int &ndata, int dsize) {
if (dsize < dataSize) if (dsize < dataSize)
ndata = dsize; ndata = dsize;
else else

View File

@ -29,7 +29,7 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
moench03T1ZmqDataNew(int ns = 5000, int oo = 2 * 2) moench03T1ZmqDataNew(int ns = 5000, int oo = 2 * 2)
: slsDetectorData<uint16_t>(400, 400, ns * 32 * 2 + oo), nSamples(ns), : slsDetectorData<uint16_t>(400, 400, ns * 32 * 2 + oo), nSamples(ns),
offset(oo), xtalk(0.00021) { offset(oo), xtalk(0.00021) {
std::cout << "M0.3" << std::endl; cout << "M0.3" << endl;
int nadc = 32; int nadc = 32;
int sc_width = 25; int sc_width = 25;
int sc_height = 200; int sc_height = 200;
@ -70,8 +70,8 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
dataMap[row][col] = dataMap[row][col] =
(nadc * i + iadc) * 2 + offset; //+16*(ip+1); (nadc * i + iadc) * 2 + offset; //+16*(ip+1);
if (dataMap[row][col] < 0 || dataMap[row][col] >= dataSize) if (dataMap[row][col] < 0 || dataMap[row][col] >= dataSize)
std::cout << "Error: pointer " << dataMap[row][col] cout << "Error: pointer " << dataMap[row][col]
<< " out of range " << std::endl; << " out of range " << endl;
} }
} }
} }
@ -260,17 +260,17 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
/* return NULL; */ /* return NULL; */
/* }; */ /* }; */
virtual char *readNextFrame(std::ifstream &filebin) { virtual char *readNextFrame(ifstream &filebin) {
int ff = -1, np = -1; int ff = -1, np = -1;
return readNextFrame(filebin, ff, np); return readNextFrame(filebin, ff, np);
}; };
virtual char *readNextFrame(std::ifstream &filebin, int &ff) { virtual char *readNextFrame(ifstream &filebin, int &ff) {
int np = -1; int np = -1;
return readNextFrame(filebin, ff, np); return readNextFrame(filebin, ff, np);
}; };
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np) { virtual char *readNextFrame(ifstream &filebin, int &ff, int &np) {
char *data = new char[32 * 2 * nSamples]; char *data = new char[32 * 2 * nSamples];
char *d = readNextFrame(filebin, ff, np, data); char *d = readNextFrame(filebin, ff, np, data);
if (d == NULL) { if (d == NULL) {
@ -280,7 +280,7 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
return data; return data;
} }
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np, virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
char *data) { char *data) {
// char *retval=0; // char *retval=0;
// int nd; // int nd;

View File

@ -3,9 +3,50 @@
#ifndef MOENCH04ZMQ10GBDATA_H #ifndef MOENCH04ZMQ10GBDATA_H
#define MOENCH04ZMQ10GBDATA_H #define MOENCH04ZMQ10GBDATA_H
#include "slsDetectorData.h" #include "slsDetectorData.h"
#include "sls/sls_detector_defs.h"
using namespace std; #ifndef SLS_DETECTOR_HEADER
#define SLS_DETECTOR_HEADER
//#define VERSION_V2
/**
@short structure for a Detector Packet or Image Header
@li frameNumber is the frame number
@li expLength is the subframe number (32 bit eiger) or real time exposure
time in 100ns (others)
@li packetNumber is the packet number
@li bunchId is the bunch id from beamline
@li timestamp is the time stamp with 10 MHz clock
@li modId is the unique module id (unique even for left, right, top, bottom)
@li xCoord is the x coordinate in the complete detector system
@li yCoord is the y coordinate in the complete detector system
@li zCoord is the z coordinate in the complete detector system
@li debug is for debugging purposes
@li roundRNumber is the round robin set number
@li detType is the detector type see :: detectorType
@li version is the version number of this structure format
*/
typedef struct {
uint64_t frameNumber; /**< is the frame number */
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time
exposure time in 100ns (others) */
uint32_t packetNumber; /**< is the packet number */
uint64_t bunchId; /**< is the bunch id from beamline */
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
uint16_t modId; /**< is the unique module id (unique even for left, right,
top, bottom) */
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
uint32_t debug; /**< is for debugging purposes */
uint16_t roundRNumber; /**< is the round robin set number */
uint8_t detType; /**< is the detector type see :: detectorType */
uint8_t version; /**< is the version number of this structure format */
uint64_t
packetCaught[8]; /**< is the version number of this structure format */
} sls_detector_header;
#endif
class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> { class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
private: private:
@ -27,40 +68,67 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
// moench04CtbZmq10GbData(int nas=5000, int nds=0): // moench04CtbZmq10GbData(int nas=5000, int nds=0):
// slsDetectorData<uint16_t>(400, 400, nas*2*32+nds*8), aSamples(nas), // slsDetectorData<uint16_t>(400, 400, nas*2*32+nds*8), aSamples(nas),
// dSamples(nds), nadc(32), sc_width(25), sc_height(200) { // dSamples(nds), nadc(32), sc_width(25), sc_height(200) {
#ifndef RAWDATA
moench04CtbZmq10GbData(int nas = 5000, int nds = 0)
: slsDetectorData<uint16_t>(400, 400,
(nas > 0) && (nds > 0)
? max(nas, nds) * (32 * 2 + 8)
: nas * 32 * 2 + nds * 8),
nadc(32), sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) {
int off = 0;
#endif
#ifdef RAWDATA
moench04CtbZmq10GbData(int nas = 5000, int nds = 0) moench04CtbZmq10GbData(int nas = 5000, int nds = 0)
: slsDetectorData<uint16_t>(400, 400, : slsDetectorData<uint16_t>(400, 400,
#ifdef RAWDATA sizeof(sls_detector_header) +
sizeof(slsDetectorDefs::sls_receiver_header) +
#endif
((nas > 0) && (nds > 0) ((nas > 0) && (nds > 0)
? max(nas, nds) * (32 * 2 + 8) ? max(nas, nds) * (32 * 2 + 8)
: nas * 32 * 2 + nds * 8)), : nas * 32 * 2 + nds * 8)),
nadc(32), sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) { nadc(32), sc_width(25), sc_height(200), aSamples(nas),
#ifdef RAWDATA dSamples(nds) {
off=sizeof(slsDetectorDefs::sls_receiver_header); int off = sizeof(sls_detector_header);
#endif cout << "hh" << dataSize << endl;
#ifndef RAWDATA cout << sizeof(sls_detector_header) +
#ifndef CTB ((nas > 0) && (nds > 0) ? max(nas, nds) * (32 * 2 + 8)
off=sizeof(int); : nas * 32 * 2 + nds * 8)
#endif << endl;
#ifdef CTB
off=0;
#endif
#endif #endif
/* int ds; */
/* if (nas && nds) */
/* if (nds>nas) */
/* ds=nds*(32*2+8); */
/* else */
/* ds=nas*(32*2+8); */
/* else */
/* ds=nas*32*2+nds*8; */
/* new slsDetectorData<uint16_t>(400, 400, ds); */
cout << "off is " << off << endl;
if (off>0)
cout << "M04 RAW DATA NEW " << endl;
else
cout << "M04 ZMQ DATA NEW " << endl;
int adc_nr[32] = {9, 8, 11, 10, 13, 12, 15, 14, 1, 0, 3, int adc_nr[32] = {9, 8, 11, 10, 13, 12, 15, 14, 1, 0, 3,
2, 5, 4, 7, 6, 23, 22, 21, 20, 19, 18, 2, 5, 4, 7, 6, 23, 22, 21, 20, 19, 18,
17, 16, 31, 30, 29, 28, 27, 26, 25, 24}; 17, 16, 31, 30, 29, 28, 27, 26, 25, 24};
/*
iadc=ptr%32
isample=ptr/32
col=(adc_nr[iadc]%16)*25+isample%25
if (adc_nr[iadc]<16)
row=199-isample/25;
else
row=200+isample/25
adc0 col(9*25..10*25-1) row(199..0)
adc1 col(8*25..9*25-1) row(199..0)
adc2 col(11*25..12*25-1) row(199..0)
adc3 col(10*25..11*25-1) row(199..0)
adc4 col(13*25..14*25-1) row(199..0)
adc5 col(12*25..13*25-1) row(199..0)
adc6 col(15*25..16*25-1) row(199..0)
adc7 col(14*25..15*25-1) row(199..0)
adc8 col(1*25..2*25-1) row(199..0)
*/
int row, col; int row, col;
@ -100,11 +168,39 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
} }
} }
/* for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){ */
/* xmap[ibyte]=-1; */
/* ymap[ibyte]=-1; */
/* } */
/* int off=sizeof(sls_detector_header)/2; */
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
/* i=ipacket*8208/2+ibyte; */
/* isample=ii/nadc; */
/* if (isample<nSamples) { */
/* iadc=ii%nadc; */
/* adc4 = (int)iadc/4; */
/* ix=isample%sc_width; */
/* iy=isample/sc_width; */
/* if (adc4%2==0) { */
/* xmap[i+off]=adc_nr[iadc]+ix; */
/* ymap[i+off]=ny/2-1-iy; */
/* } else { */
/* xmap[i+off]=adc_nr[iadc]+ix; */
/* ymap[i+off]=ny/2+iy; */
/* } */
/* } */
/* ii++; */
/* // } */
/* } */
/* } */
iframe = 0; iframe = 0;
// cout << "data struct created" << endl; // cout << "data struct created" << endl;
} }
int getGain(char *data, int x, int y) { int getGain(char *data, int x, int y) {
// int aoff=aSamples*2*32; // int aoff=aSamples*2*32;
@ -157,12 +253,10 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
/* unsigned char bunchid[8]; */ /* unsigned char bunchid[8]; */
/* }; */ /* }; */
int getFrameNumber(char *buff) {
#ifdef RAWDATA #ifdef RAWDATA
return ((slsDetectorDefs::sls_receiver_header *)buff)->detHeader.frameNumber; int getFrameNumber(char *buff) {
#endif return ((sls_detector_header *)buff)->frameNumber;
return (int)(*buff); }; //*((int*)(buff+5))&0xffffff;};
};
/** /**
@ -174,15 +268,76 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
*/ */
int getPacketNumber(char *buff) { int getPacketNumber(char *buff) {
#ifdef RAWDATA return ((sls_detector_header *)buff)->packetNumber;
return ((slsDetectorDefs::sls_receiver_header *)buff)->detHeader.packetNumber; } //((*(((int*)(buff+4))))&0xff)+1;};
#endif #endif
return 0; #ifndef RAWDATA
} int getFrameNumber(char *buff) {
return iframe;
}; //((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
#endif
/**
Returns the packet number for the given dataset. purely virtual func
\param buff pointer to the dataset
\returns packet number number
*/
// int getPacketNumber(char *buff){return
// ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
/* /\** */
/* Loops over a memory slot until a complete frame is found (i.e.
* all packets 0 to nPackets, same frame number). purely virtual func */
/* \param data pointer to the memory to be analyzed */
/* \param ndata reference to the amount of data found for the
* frame, in case the frame is incomplete at the end of the memory slot
*/
/* \param dsize size of the memory slot to be analyzed */
/* \returns pointer to the beginning of the last good frame (might
* be incomplete if ndata smaller than dataSize), or NULL if no frame is
* found */
/* *\/ */
/* virtual char *findNextFrame(char *data, int &ndata, int
* dsize){ndata=dsize; setDataSize(dsize); return data;}; */
/* /\** */
/* Loops over a file stream until a complete frame is found (i.e.
* all packets 0 to nPackets, same frame number). Can be overloaded for
* different kind of detectors! */
/* \param filebin input file stream (binary) */
/* \returns pointer to the begin of the last good frame, NULL if no
* frame is found or last frame is incomplete */
/* *\/ */
/* virtual char *readNextFrame(ifstream &filebin){ */
/* // int afifo_length=0; */
/* uint16_t *afifo_cont; */
/* int ib=0; */
/* if (filebin.is_open()) { */
/* afifo_cont=new uint16_t[dataSize/2]; */
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
/* ib+=2; */
/* if (ib==dataSize) break; */
/* } */
/* if (ib>0) { */
/* iframe++; */
/* // cout << ib << "-" << endl; */
/* return (char*)afifo_cont; */
/* } else { */
/* delete [] afifo_cont; */
/* return NULL; */
/* } */
/* } */
/* return NULL; */
/* }; */
virtual char *readNextFrame(ifstream & filebin) { virtual char *readNextFrame(ifstream & filebin) {
int ff = -1, np = -1; int ff = -1, np = -1;
return readNextFrame(filebin, ff, np); return readNextFrame(filebin, ff, np);
@ -203,12 +358,11 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
return data; return data;
} }
#ifndef RAWDATA
virtual char *readNextFrame(ifstream & filebin, int &ff, int &np, virtual char *readNextFrame(ifstream & filebin, int &ff, int &np,
char *data) { char *data) {
// char *retval=0; // char *retval=0;
#ifndef RAWDATA
// int nd; // int nd;
// int fnum = -1; // int fnum = -1;
np = 0; np = 0;
@ -226,13 +380,19 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
} }
} }
return NULL; return NULL;
};
#endif #endif
#ifdef RAWDATA #ifdef RAWDATA
//int nd;
virtual char *readNextFrame(ifstream & filebin, int &ff, int &np,
char *data) {
char *retval = 0;
int nd;
int fnum = -1; int fnum = -1;
np = 0; np = 0;
//int pn; int pn;
// cout << dataSize << endl; // cout << dataSize << endl;
if (ff >= 0) if (ff >= 0)
@ -246,9 +406,9 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
} }
} }
return NULL; return NULL;
};
#endif #endif
};
/** /**
@ -273,4 +433,3 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
}; };
#endif #endif

View File

@ -1,216 +0,0 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#ifndef MOENCHDATA_H
#define MOENCHDATA_H
#include "slsDetectorData.h"
#include "sls/sls_detector_defs.h"
using namespace std;
class moenchData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
int sc_height;
const int aSamples;
const int dSamples;
int off;
int *adc_nr;
int *ibit;
public:
/**
Implements the slsReceiverData structure for the moench02 prototype read
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
1286 large etc.) \param c crosstalk parameter for the output buffer
*/
moenchData(int off, int nadc_i, int *adc_nr_in, int *ibit_in, int nas = 5000, int nds = 0, int nx_i=400, int ny_i=400)
: nadc(nadc_i), slsDetectorData<uint16_t>(nx_i, ny_i,off+((nas > 0) && (nds > 0)
? max(nas, nds) * (nadc_i * 2 + 8)
: nas * nadc_i * 2 + nds * 8)),
sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) {
adc_nr=new int[nadc];
if (ibit_in)
ibit=new int[nadc];
else
ibit=NULL;
for (iadc=0; iadc<nadc; iadc++) {
adc_nr[iadc]=adc_nr_in[iadc];
if (ibit)
ibit[iadc]=ibit_in[iadc];
}
int row, col;
int iadc;
int i;
for (int is = 0; is < aSamples; is++) {
for (iadc = 0; iadc < nadc; iadc++) {
i = is;
// adc4=(int)iadc/4;
if (i < sc_width * sc_height) {
// for (int i=0; i<sc_width*sc_height; i++) {
col = (adc_nr[iadc] % 16) * sc_width + (i % sc_width);
// if (adc4%2==0) {
if (iadc < 16) {
row = 199 - i / sc_width;
} else {
row = 200 + i / sc_width;
}
if (nds > 0)
dataMap[row][col] =
((nadc + 4) * i + iadc) * 2 + off; //+16*(ip+1);
else
dataMap[row][col] =
(nadc * i + iadc) * 2 + off; //+16*(ip+1);
if (dataMap[row][col] < 0 ||
dataMap[row][col] >= aSamples * 2 * 32 + off)
cout << "Error: pointer " << dataMap[row][col]
<< " out of range " << endl;
}
}
}
iframe = 0;
}
virtual int getGain(char *data, int x, int y) {
// int aoff=aSamples*2*32;
if (ibit) {
int irow;
int isc = x / sc_width;
int icol = x % sc_width;
if (y < 200)
irow = sc_height - 1 - y;
else {
irow = y - sc_height;
isc++;
}
int isample = irow * sc_width + icol;
uint64_t sample;
char *ptr;
if (isc < 0 || isc >= 32)
return 0;
if (ibit[isc] < 0 || ibit[isc] >= 64)
return 0;
if (dSamples > isample) {
ptr = data + 32 * (isample + 1) + 8 * isample;
sample = *((uint64_t *)ptr);
if (sample & (1 << ibit[isc]))
return 1;
}
}
return 0;
}
/**
Returns the frame number for the given dataset. Purely virtual func.
\param buff pointer to the dataset
\returns frame number
*/
int getFrameNumber(char *buff) {
return (int* buff)[0];
};
/**
Returns the packet number for the given dataset. purely virtual func
\param buff pointer to the dataset
\returns packet number number
*/
int getPacketNumber(char *buff) {
return 0;
}
virtual char *readNextFrame(ifstream & filebin) {
int ff = -1, np = -1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream & filebin, int &ff) {
int np = -1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream & filebin, int &ff, int &np) {
char *data = new char[dataSize];
char *d = readNextFrame(filebin, ff, np, data);
if (d == NULL) {
delete[] data;
data = NULL;
}
return data;
}
virtual char *readNextFrame(ifstream & filebin, int &ff, int &np,
char *data) {
char *retval = 0;
int nd;
int fnum = -1;
np = 0;
int pn;
// cout << dataSize << endl;
//if (ff >= 0)
// fnum = ff;
if (filebin.is_open()) {
if (filebin.read(data, dataSize)) {
ff = getFrameNumber(data);
np = getPacketNumber(data);
return data;
}
}
return NULL;
};
/**
Loops over a memory slot until a complete frame is found (i.e. all
packets 0 to nPackets, same frame number). purely virtual func \param
data pointer to the memory to be analyzed \param ndata reference to
the amount of data found for the frame, in case the frame is
incomplete at the end of the memory slot \param dsize size of the
memory slot to be analyzed \returns pointer to the beginning of the
last good frame (might be incomplete if ndata smaller than dataSize),
or NULL if no frame is found
*/
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
if (dsize < dataSize)
ndata = dsize;
else
ndata = dataSize;
return data;
}
};
#endif

View File

@ -4,8 +4,11 @@
#define SLSDETECTORDATA_H #define SLSDETECTORDATA_H
#include <fstream> #include <fstream>
#include <inttypes.h>
#include <iostream> #include <iostream>
using namespace std;
template <class dataType> class slsDetectorData { template <class dataType> class slsDetectorData {
protected: protected:
@ -26,11 +29,13 @@ template <class dataType> class slsDetectorData {
public: public:
/** /**
General slsDetectors data structure. Works for data acquired using the
General slsDetectors data structure. Works for data acquired using the
slsDetectorReceiver. Can be generalized to other detectors (many virtual slsDetectorReceiver. Can be generalized to other detectors (many virtual
funcs). funcs).
Constructor (no error checking if datasize and offsets are compatible!) Constructor (no error checking if datasize and offsets are compatible!)
\param npx number of pixels in the x direction \param npx number of pixels in the x direction
\param npy number of pixels in the y direction (1 for strips) \param npy number of pixels in the y direction (1 for strips)
\param dsize size of the data \param dsize size of the data
@ -40,26 +45,309 @@ template <class dataType> class slsDetectorData {
is inversion is required) \param dROI Array of size nx*ny. The elements are is inversion is required) \param dROI Array of size nx*ny. The elements are
1s if the channel is good or in the ROI, 0 is bad or out of the ROI. NULL 1s if the channel is good or in the ROI, 0 is bad or out of the ROI. NULL
(default) means all 1s. (default) means all 1s.
*/ */
slsDetectorData(int npx, int npy, int dsize, int **dMap = NULL, slsDetectorData(int npx, int npy, int dsize, int **dMap = NULL,
dataType **dMask = NULL, int **dROI = NULL); dataType **dMask = NULL, int **dROI = NULL)
: nx(npx), ny(npy), dataSize(dsize), orderedData(NULL), isOrdered(0) {
virtual ~slsDetectorData(); int el = dsize / sizeof(dataType);
xmap = new int[el];
ymap = new int[el];
orderedData = new dataType *[ny];
dataMap = new int *[ny];
dataMask = new dataType *[ny];
dataROIMask = new int *[ny];
for (int i = 0; i < ny; i++) {
dataMap[i] = new int[nx];
orderedData[i] = new dataType[nx];
dataMask[i] = new dataType[nx];
dataROIMask[i] = new int[nx];
for (int j = 0; j < nx; j++)
dataROIMask[i][j] = 1;
}
for (int ip = 0; ip < el; ip++) {
xmap[ip] = -1;
ymap[ip] = -1;
}
setDataMap(dMap);
setDataMask(dMask);
setDataROIMask(dROI);
}
virtual ~slsDetectorData() {
for (int i = 0; i < ny; i++) {
delete[] dataMap[i];
delete[] dataMask[i];
delete[] dataROIMask[i];
delete[] orderedData[i];
}
delete[] dataMap;
delete[] dataMask;
delete[] dataROIMask;
delete[] orderedData;
delete[] xmap;
delete[] ymap;
};
// Virtual functions
virtual int getPointer(int ix, int iy) { return dataMap[iy][ix]; }; virtual int getPointer(int ix, int iy) { return dataMap[iy][ix]; };
virtual void getPixel(int ip, int &x, int &y); /**
virtual dataType **getData(char *ptr, int dsize = -1); defines the data map (as offset) - no error checking if datasize and
virtual double **getImage(char *ptr, int dsize = -1); offsets are compatible! \param dMap array of size nx*ny storing the
virtual dataType getChannel(char *data, int ix, int iy = 0); pointers to the data in the dataset (as offset). If NULL (default),the
data are arranged as if read out row by row
(dataMap[iy][ix]=(iy*nx+ix)*sizeof(dataType);)
*/
void setDataMap(int **dMap = NULL) {
int ip = 0;
int ix, iy;
if (dMap == NULL) {
for (iy = 0; iy < ny; iy++) {
for (ix = 0; ix < nx; ix++) {
dataMap[iy][ix] = (iy * nx + ix) * sizeof(dataType);
}
}
} else {
// cout << "set dmap "<< dataMap << " " << dMap << endl;
for (iy = 0; iy < ny; iy++) {
// cout << iy << endl;
for (ix = 0; ix < nx; ix++) {
dataMap[iy][ix] = dMap[iy][ix];
// cout << ix << " " << iy << endl;
/*ip=dataMap[ix][iy]/sizeof(dataType);
xmap[ip]=ix;
ymap[ip]=iy;Annaa*/
}
}
}
for (iy = 0; iy < ny; iy++) {
for (ix = 0; ix < nx; ix++) {
ip = dataMap[iy][ix] / sizeof(dataType);
xmap[ip] = ix;
ymap[ip] = iy;
}
}
// cout << "nx:" <<nx << " ny:" << ny << endl;
};
/**
defines the data mask i.e. the polarity of the data
\param dMask Array of size nx*ny storing the polarity of the data in the
dataset (should be 0 if no inversion is required, 0xffffffff is inversion
is required)
*/
void setDataMask(dataType **dMask = NULL) {
if (dMask != NULL) {
for (int iy = 0; iy < ny; iy++)
for (int ix = 0; ix < nx; ix++)
dataMask[iy][ix] = dMask[iy][ix];
} else {
for (int iy = 0; iy < ny; iy++)
for (int ix = 0; ix < nx; ix++)
dataMask[iy][ix] = 0;
}
};
/**
defines the region of interest and/or the bad channels mask
\param dROI Array of size nx*ny. The lements are 1s if the channel is
good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all
1s.
*/
void setDataROIMask(int **dROI = NULL) {
if (dROI != NULL) {
for (int iy = 0; iy < ny; iy++)
for (int ix = 0; ix < nx; ix++)
dataROIMask[iy][ix] = dROI[iy][ix];
} else {
for (int iy = 0; iy < ny; iy++)
for (int ix = 0; ix < nx; ix++)
dataROIMask[iy][ix] = 1;
}
};
/**
Define bad channel or roi mask for a single channel
\param ix channel x coordinate
\param iy channel y coordinate (1 for strips)
\param i 1 if pixel is good (or in the roi), 0 if bad
\returns 1 if pixel is good, 0 if it's bad, -1 if pixel is out of range
*/
int setGood(int ix, int iy, int i = 1) {
if (ix >= 0 && ix < nx && iy >= 0 && iy < ny)
dataROIMask[iy][ix] = i;
return isGood(ix, iy);
};
/**
Define bad channel or roi mask for a single channel
\param ix channel x coordinate
\param iy channel y coordinate (1 for strips)
\returns 1 if pixel is good, 0 if it's bad, -1 if pixel is out of range
*/
int isGood(int ix, int iy) {
if (ix >= 0 && ix < nx && iy >= 0 && iy < ny)
return dataROIMask[iy][ix];
else
return -1;
};
/**
Returns detector size in x,y
\param npx reference to number of channels in x
\param npy reference to number of channels in y (will be 1 for strips)
\returns total number of channels
*/
int getDetectorSize(int &npx, int &npy) {
npx = nx;
npy = ny;
return nx * ny;
};
/** Returns the size of the data frame */
int getDataSize() { return dataSize; };
/** changes the size of the data frame */
int setDataSize(int d) {
dataSize = d;
return dataSize;
};
virtual void getPixel(int ip, int &x, int &y) {
x = xmap[ip];
y = ymap[ip];
};
virtual dataType **getData(char *ptr, int dsize = -1) {
int el = dsize / sizeof(dataType);
// dataType **data;
int ix, iy;
// data=new dataType*[ny];
// for(int i = 0; i < ny; i++) {
// data[i]=new dataType[nx];
// }
isOrdered = 0;
if (dsize <= 0 || dsize > dataSize)
dsize = dataSize;
for (int ip = 0; ip < (el); ip++) {
getPixel(ip, ix, iy);
if (ix >= 0 && ix < nx && iy >= 0 && iy < ny) {
// data[iy][ix]=getChannel(ptr,ix,iy);
orderedData[iy][ix] = *(ptr + ip); // getChannel(ptr,ix,iy);
}
}
isOrdered = 1;
return orderedData;
}
void newFrame() { isOrdered = 0; };
virtual double **getImage(char *ptr, int dsize = -1) {
double **data;
int ix, iy;
data = new double *[ny];
for (int i = 0; i < ny; i++) {
data[i] = new double[nx];
}
int el = dsize / sizeof(dataType);
if (dsize <= 0 || dsize > dataSize)
dsize = dataSize;
for (int ip = 0; ip < el; ip++) {
getPixel(ip, ix, iy);
if (ix >= 0 && ix < nx && iy >= 0 && iy < ny) {
data[iy][ix] = getValue(ptr, ix, iy);
}
}
return data;
};
/**
Returns the value of the selected channel for the given dataset. Virtual
function, can be overloaded. \param data pointer to the dataset
(including headers etc) \param ix pixel number in the x direction \param
iy pixel number in the y direction \returns data for the selected
channel, with inversion if required
*/
virtual dataType getChannel(char *data, int ix, int iy = 0) {
dataType m = 0, d = 0;
if (ix >= 0 && ix < nx && iy >= 0 && iy < ny && dataMap[iy][ix] >= 0 &&
dataMap[iy][ix] < dataSize) {
// cout << ix << " " << iy << " " ;
// cout << dataMap[ix][iy] << " " << (void*)data << " " <<
// dataSize<< endl;
m = dataMask[iy][ix];
if (isOrdered == 0)
d = *((dataType *)(data + getPointer(ix, iy)));
else
d = orderedData[iy][ix];
}
return d ^ m;
};
virtual int getGain(char *data, int ix, int iy = 0) { return 0; }; virtual int getGain(char *data, int ix, int iy = 0) { return 0; };
/**
Returns the value of the selected channel for the given dataset. Virtual
function, can be overloaded. \param data pointer to the dataset
(including headers etc) \param ix pixel number in the x direction \param
iy pixel number in the y direction \returns data for the selected
channel, with inversion if required or -1 if its a missing packet
*/
virtual int getChannelwithMissingPackets(char *data, int ix, int iy) {
return 0;
};
/**
Returns the value of the selected channel for the given dataset as
double. \param data pointer to the dataset (including headers etc) \param
ix pixel number in the x direction \param iy pixel number in the y
direction \returns data for the selected channel, with inversion if
required as double
*/
virtual double getValue(char *data, int ix, int iy = 0) { virtual double getValue(char *data, int ix, int iy = 0) {
/* cout << " x "<< ix << " y"<< iy << " val " << getChannel(data, ix,
* iy)<< endl;*/
return (double)getChannel(data, ix, iy); return (double)getChannel(data, ix, iy);
}; };
virtual int getFrameNumber(char *buff) = 0;
/** /**
Returns the frame number for the given dataset. Purely virtual func.
\param buff pointer to the dataset
\returns frame number
*/
virtual int getFrameNumber(char *buff) = 0;
/**
Returns the packet number for the given dataset. purely virtual func
\param buff pointer to the dataset
\returns packet number number
virtual int getPacketNumber(char *buff)=0;
*/
/**
Loops over a memory slot until a complete frame is found (i.e. all Loops over a memory slot until a complete frame is found (i.e. all
packets 0 to nPackets, same frame number). purely virtual func \param packets 0 to nPackets, same frame number). purely virtual func \param
data pointer to the memory to be analyzed \param ndata reference to the data pointer to the memory to be analyzed \param ndata reference to the
@ -72,276 +360,16 @@ template <class dataType> class slsDetectorData {
*/ */
virtual char *findNextFrame(char *data, int &ndata, int dsize) = 0; virtual char *findNextFrame(char *data, int &ndata, int dsize) = 0;
//Returns a pointer to the next complete frame, if none found nullptr
//data needs to be deallocated by caller
virtual char *readNextFrame(std::ifstream &filebin) = 0;
//END Virtual functions
/** /**
defines the data map (as offset) - no error checking if datasize and
offsets are compatible! \param dMap array of size nx*ny storing the
pointers to the data in the dataset (as offset). If NULL (default),the
data are arranged as if read out row by row
(dataMap[iy][ix]=(iy*nx+ix)*sizeof(dataType);)
*/
void setDataMap(int **dMap = NULL);
/** Loops over a file stream until a complete frame is found (i.e. all packets
defines the data mask i.e. the polarity of the data 0 to nPackets, same frame number). Can be overloaded for different kind of
\param dMask Array of size nx*ny storing the polarity of the data in the detectors! \param filebin input file stream (binary) \returns pointer to
dataset (should be 0 if no inversion is required, 0xffffffff is inversion the begin of the last good frame, NULL if no frame is found or last frame
is required) is incomplete
*/ */
void setDataMask(dataType **dMask = NULL); virtual char *readNextFrame(ifstream &filebin) = 0;
/**
defines the region of interest and/or the bad channels mask
\param dROI Array of size nx*ny. The ements are 1s if the channel is
good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all
1s.
*/
void setDataROIMask(int **dROI = NULL);
/**
Define bad channel or roi mask for a single channel
\param ix channel x coordinate
\param iy channel y coordinate (1 for strips)
\param i 1 if pixel is good (or in the roi), 0 if bad
\returns 1 if pixel is good, 0 if it's bad, -1 if pixel is out of range
*/
int setGood(int ix, int iy, int i = 1);
// returns 1 if pixel is good, 0 if it's bad, -1 if pixel is out of range
int isGood(int ix, int iy);
// returns total number of channels, outparam npx and npy x,y dimensions
int getDetectorSize(int &npx, int &npy);
/** Returns the size of the data frame */
int getDataSize() { return dataSize; };
/** changes the size of the data frame */
int setDataSize(int d) {
dataSize = d;
return dataSize;
};
void newFrame() { isOrdered = 0; };
/**
Returns the value of the selected channel for the given dataset. Virtual
function, can be overloaded. \param data pointer to the dataset
(including headers etc) \param ix pixel number in the x direction \param
iy pixel number in the y direction \returns data for the selected
channel, with inversion if required
*/
};
template <typename dataType>
slsDetectorData<dataType>::slsDetectorData(int npx, int npy, int dsize,
int **dMap, dataType **dMask,
int **dROI)
: nx(npx), ny(npy), dataSize(dsize), orderedData(NULL), isOrdered(0) {
int el = dsize / sizeof(dataType);
xmap = new int[el];
ymap = new int[el];
orderedData = new dataType *[ny];
dataMap = new int *[ny];
dataMask = new dataType *[ny];
dataROIMask = new int *[ny];
for (int i = 0; i < ny; i++) {
dataMap[i] = new int[nx];
orderedData[i] = new dataType[nx];
dataMask[i] = new dataType[nx];
dataROIMask[i] = new int[nx];
for (int j = 0; j < nx; j++)
dataROIMask[i][j] = 1;
}
for (int ip = 0; ip < el; ip++) {
xmap[ip] = -1;
ymap[ip] = -1;
}
setDataMap(dMap);
setDataMask(dMask);
setDataROIMask(dROI);
}
template <typename dataType> slsDetectorData<dataType>::~slsDetectorData() {
for (int i = 0; i < ny; i++) {
delete[] dataMap[i];
delete[] dataMask[i];
delete[] dataROIMask[i];
delete[] orderedData[i];
}
delete[] dataMap;
delete[] dataMask;
delete[] dataROIMask;
delete[] orderedData;
delete[] xmap;
delete[] ymap;
}
template <typename dataType>
void slsDetectorData<dataType>::setDataMap(int **dMap) {
int ip = 0;
int ix, iy;
if (dMap == NULL) {
for (iy = 0; iy < ny; iy++) {
for (ix = 0; ix < nx; ix++) {
dataMap[iy][ix] = (iy * nx + ix) * sizeof(dataType);
}
}
} else {
// cout << "set dmap "<< dataMap << " " << dMap << endl;
for (iy = 0; iy < ny; iy++) {
// cout << iy << endl;
for (ix = 0; ix < nx; ix++) {
dataMap[iy][ix] = dMap[iy][ix];
// cout << ix << " " << iy << endl;
/*ip=dataMap[ix][iy]/sizeof(dataType);
xmap[ip]=ix;
ymap[ip]=iy;Annaa*/
}
}
}
for (iy = 0; iy < ny; iy++) {
for (ix = 0; ix < nx; ix++) {
ip = dataMap[iy][ix] / sizeof(dataType);
xmap[ip] = ix;
ymap[ip] = iy;
}
}
// cout << "nx:" <<nx << " ny:" << ny << endl;
}
template <typename dataType>
void slsDetectorData<dataType>::setDataMask(dataType **dMask) {
if (dMask != NULL) {
for (int iy = 0; iy < ny; iy++)
for (int ix = 0; ix < nx; ix++)
dataMask[iy][ix] = dMask[iy][ix];
} else {
for (int iy = 0; iy < ny; iy++)
for (int ix = 0; ix < nx; ix++)
dataMask[iy][ix] = 0;
}
}
template <typename dataType>
void slsDetectorData<dataType>::setDataROIMask(int **dROI) {
if (dROI != NULL) {
for (int iy = 0; iy < ny; iy++)
for (int ix = 0; ix < nx; ix++)
dataROIMask[iy][ix] = dROI[iy][ix];
} else {
for (int iy = 0; iy < ny; iy++)
for (int ix = 0; ix < nx; ix++)
dataROIMask[iy][ix] = 1;
}
}
template <typename dataType>
int slsDetectorData<dataType>::setGood(int ix, int iy, int i) {
if (ix >= 0 && ix < nx && iy >= 0 && iy < ny)
dataROIMask[iy][ix] = i;
return isGood(ix, iy);
}
template <typename dataType>
int slsDetectorData<dataType>::isGood(int ix, int iy) {
if (ix >= 0 && ix < nx && iy >= 0 && iy < ny)
return dataROIMask[iy][ix];
else
return -1;
};
template <typename dataType>
int slsDetectorData<dataType>::getDetectorSize(int &npx, int &npy) {
npx = nx;
npy = ny;
return nx * ny;
}
template <typename dataType>
void slsDetectorData<dataType>::getPixel(int ip, int &x, int &y) {
x = xmap[ip];
y = ymap[ip];
}
template <typename dataType>
dataType **slsDetectorData<dataType>::getData(char *ptr, int dsize) {
int el = dsize / sizeof(dataType);
// dataType **data;
int ix, iy;
// data=new dataType*[ny];
// for(int i = 0; i < ny; i++) {
// data[i]=new dataType[nx];
// }
isOrdered = 0;
if (dsize <= 0 || dsize > dataSize)
dsize = dataSize;
for (int ip = 0; ip < (el); ip++) {
getPixel(ip, ix, iy);
if (ix >= 0 && ix < nx && iy >= 0 && iy < ny) {
// data[iy][ix]=getChannel(ptr,ix,iy);
orderedData[iy][ix] = *(ptr + ip); // getChannel(ptr,ix,iy);
}
}
isOrdered = 1;
return orderedData;
}
template <typename dataType>
double **slsDetectorData<dataType>::getImage(char *ptr, int dsize) {
double **data;
int ix, iy;
data = new double *[ny];
for (int i = 0; i < ny; i++) {
data[i] = new double[nx];
}
int el = dsize / sizeof(dataType);
if (dsize <= 0 || dsize > dataSize)
dsize = dataSize;
for (int ip = 0; ip < el; ip++) {
getPixel(ip, ix, iy);
if (ix >= 0 && ix < nx && iy >= 0 && iy < ny) {
data[iy][ix] = getValue(ptr, ix, iy);
}
}
return data;
}
template <typename dataType>
dataType slsDetectorData<dataType>::getChannel(char *data, int ix, int iy) {
dataType m = 0, d = 0;
if (ix >= 0 && ix < nx && iy >= 0 && iy < ny && dataMap[iy][ix] >= 0 &&
dataMap[iy][ix] < dataSize) {
m = dataMask[iy][ix];
if (isOrdered == 0)
d = *((dataType *)(data + getPointer(ix, iy)));
else
d = orderedData[iy][ix];
}
return d ^ m;
}; };
#endif #endif

View File

@ -149,7 +149,7 @@ class interpolatingDetector : public singlePhotonDetector {
{ {
nph = addFrame(data, val, 1); nph = addFrame(data, val, 1);
if (interp) if (interp)
return interp->getFlatFieldDistribution(); return interp->getFlatField();
else else
return NULL; return NULL;
}; };

View File

@ -238,96 +238,96 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
// cout <<"******"<< etax << " " << etay << endl; // cout <<"******"<< etax << " " << etay << endl;
return addToFlatFieldDistribution(etax, etay); return addToFlatField(etax, etay);
} }
/* virtual int addToFlatField(double totquad, int quad, double *cl, */ virtual int addToFlatField(double totquad, int quad, double *cl,
/* double &etax, double &etay) { */ double &etax, double &etay) {
/* double cc[2][2]; */ double cc[2][2];
/* int xoff = 0, yoff = 0; */ int xoff = 0, yoff = 0;
/* switch (quad) { */ switch (quad) {
/* case BOTTOM_LEFT: */ case BOTTOM_LEFT:
/* xoff = 0; */ xoff = 0;
/* yoff = 0; */ yoff = 0;
/* break; */ break;
/* case BOTTOM_RIGHT: */ case BOTTOM_RIGHT:
/* xoff = 1; */ xoff = 1;
/* yoff = 0; */ yoff = 0;
/* break; */ break;
/* case TOP_LEFT: */ case TOP_LEFT:
/* xoff = 0; */ xoff = 0;
/* yoff = 1; */ yoff = 1;
/* break; */ break;
/* case TOP_RIGHT: */ case TOP_RIGHT:
/* xoff = 1; */ xoff = 1;
/* yoff = 1; */ yoff = 1;
/* break; */ break;
/* default:; */ default:;
/* } */ }
/* cc[0][0] = cl[xoff + 3 * yoff]; */ cc[0][0] = cl[xoff + 3 * yoff];
/* cc[1][0] = cl[(yoff + 1) * 3 + xoff]; */ cc[1][0] = cl[(yoff + 1) * 3 + xoff];
/* cc[0][1] = cl[yoff * 3 + xoff + 1]; */ cc[0][1] = cl[yoff * 3 + xoff + 1];
/* cc[1][1] = cl[(yoff + 1) * 3 + xoff + 1]; */ cc[1][1] = cl[(yoff + 1) * 3 + xoff + 1];
/* /\* cout << cl[0] << " " << cl[1] << " " << cl[2] << endl; *\/ */ /* cout << cl[0] << " " << cl[1] << " " << cl[2] << endl; */
/* /\* cout << cl[3] << " " << cl[4] << " " << cl[5] << endl; *\/ */ /* cout << cl[3] << " " << cl[4] << " " << cl[5] << endl; */
/* /\* cout << cl[6] << " " << cl[7] << " " << cl[8] << endl; *\/ */ /* cout << cl[6] << " " << cl[7] << " " << cl[8] << endl; */
/* /\* cout <<"******"<<totquad << " " << quad << endl; *\/ */ /* cout <<"******"<<totquad << " " << quad << endl; */
/* /\* cout << cc[0][0]<< " " << cc[0][1] << endl; *\/ */ /* cout << cc[0][0]<< " " << cc[0][1] << endl; */
/* /\* cout << cc[1][0]<< " " << cc[1][1] << endl; *\/ */ /* cout << cc[1][0]<< " " << cc[1][1] << endl; */
/* // calcMyEta(totquad,quad,cl,etax, etay); */ // calcMyEta(totquad,quad,cl,etax, etay);
/* calcEta(totquad, cc, etax, etay); */ calcEta(totquad, cc, etax, etay);
/* // cout <<"******"<< etax << " " << etay << endl; */ // cout <<"******"<< etax << " " << etay << endl;
/* return addToFlatFieldDistribution(etax, etay); */ return addToFlatField(etax, etay);
/* } */ }
////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////
/* virtual int addToFlatField(double *cluster, double &etax, double &etay) { */ virtual int addToFlatField(double *cluster, double &etax, double &etay) {
/* double sDum[2][2]; */ double sDum[2][2];
/* double tot, totquad; */ double tot, totquad;
/* // int corner; */ // int corner;
/* // corner= */ // corner=
/* calcQuad(cluster, tot, totquad, sDum); */ calcQuad(cluster, tot, totquad, sDum);
/* // double xpos_eta,ypos_eta; */ // double xpos_eta,ypos_eta;
/* // double dX,dY; */ // double dX,dY;
/* calcEta(totquad, sDum, etax, etay); */ calcEta(totquad, sDum, etax, etay);
/* return addToFlatField(etax, etay); */ return addToFlatField(etax, etay);
/* }; */ };
/* virtual int addToFlatField(int *cluster, double &etax, double &etay) { */ virtual int addToFlatField(int *cluster, double &etax, double &etay) {
/* double sDum[2][2]; */ double sDum[2][2];
/* double tot, totquad; */ double tot, totquad;
/* // int corner; */ // int corner;
/* // corner= */ // corner=
/* calcQuad(cluster, tot, totquad, sDum); */ calcQuad(cluster, tot, totquad, sDum);
/* // double xpos_eta,ypos_eta; */ // double xpos_eta,ypos_eta;
/* // double dX,dY; */ // double dX,dY;
/* calcEta(totquad, sDum, etax, etay); */ calcEta(totquad, sDum, etax, etay);
/* return addToFlatField(etax, etay); */ return addToFlatField(etax, etay);
/* }; */ };
/* virtual int addToFlatFieldDistribution(double etax, double etay) { */ virtual int addToFlatField(double etax, double etay) {
/* #ifdef MYROOT1 */ #ifdef MYROOT1
/* heta->Fill(etax, etay); */ heta->Fill(etax, etay);
/* #endif */ #endif
/* #ifndef MYROOT1 */ #ifndef MYROOT1
/* int ex, ey; */ int ex, ey;
/* ex = (etax - etamin) / etastepX; */ ex = (etax - etamin) / etastepX;
/* ey = (etay - etamin) / etastepY; */ ey = (etay - etamin) / etastepY;
/* if (ey < nbetaY && ex < nbetaX && ex >= 0 && ey >= 0) */ if (ey < nbetaY && ex < nbetaX && ex >= 0 && ey >= 0)
/* heta[ey * nbetaX + ex]++; */ heta[ey * nbetaX + ex]++;
/* #endif */ #endif
/* return 0; */ return 0;
/* }; */ };
virtual int *getInterpolatedImage() { virtual int *getInterpolatedImage() {
int ipx, ipy; int ipx, ipy;

View File

@ -205,44 +205,44 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
double &etay) { double &etay) {
calcEta3(cl, etax, etay, totquad); calcEta3(cl, etax, etay, totquad);
return addToFlatFieldDistribution(etax, etay); return addToFlatField(etax, etay);
} }
/* virtual int addToFlatField(double totquad, int quad, double *cl, */ virtual int addToFlatField(double totquad, int quad, double *cl,
/* double &etax, double &etay) { */ double &etax, double &etay) {
/* calcEta3(cl, etax, etay, totquad); */ calcEta3(cl, etax, etay, totquad);
/* return addToFlatField(etax, etay); */ return addToFlatField(etax, etay);
/* } */ }
////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////
/* virtual int addToFlatField(double *cluster, double &etax, double &etay) { */ virtual int addToFlatField(double *cluster, double &etax, double &etay) {
/* double totquad; */ double totquad;
/* calcEta3(cluster, etax, etay, totquad); */ calcEta3(cluster, etax, etay, totquad);
/* return addToFlatField(etax, etay); */ return addToFlatField(etax, etay);
/* }; */ };
/* virtual int addToFlatField(int *cluster, double &etax, double &etay) { */ virtual int addToFlatField(int *cluster, double &etax, double &etay) {
/* double totquad; */ double totquad;
/* calcEta3(cluster, etax, etay, totquad); */ calcEta3(cluster, etax, etay, totquad);
/* return addToFlatField(etax, etay); */ return addToFlatField(etax, etay);
/* }; */ };
/* virtual int addToFlatField(double etax, double etay) { */ virtual int addToFlatField(double etax, double etay) {
/* #ifdef MYROOT1 */ #ifdef MYROOT1
/* heta->Fill(etax, etay); */ heta->Fill(etax, etay);
/* #endif */ #endif
/* #ifndef MYROOT1 */ #ifndef MYROOT1
/* int ex, ey; */ int ex, ey;
/* ex = (etax - etamin) / etastepX; */ ex = (etax - etamin) / etastepX;
/* ey = (etay - etamin) / etastepY; */ ey = (etay - etamin) / etastepY;
/* if (ey < nbetaY && ex < nbetaX && ex >= 0 && ey >= 0) */ if (ey < nbetaY && ex < nbetaX && ex >= 0 && ey >= 0)
/* heta[ey * nbetaX + ex]++; */ heta[ey * nbetaX + ex]++;
/* #endif */ #endif
/* return 0; */ return 0;
/* }; */ };
/* protected: */ /* protected: */

View File

@ -3,7 +3,7 @@
#ifndef ETA_INTERPOLATION_ADAPTIVEBINS_H #ifndef ETA_INTERPOLATION_ADAPTIVEBINS_H
#define ETA_INTERPOLATION_ADAPTIVEBINS_H #define ETA_INTERPOLATION_ADAPTIVEBINS_H
#include "sls/tiffIO.h" #include "tiffIO.h"
#include <cmath> #include <cmath>
//#include "etaInterpolationBase.h" //#include "etaInterpolationBase.h"
#include "etaInterpolationPosXY.h" #include "etaInterpolationPosXY.h"

View File

@ -10,7 +10,7 @@
#include <TTree.h> #include <TTree.h>
#endif #endif
#include "slsInterpolation.h" #include "slsInterpolation.h"
#include "sls/tiffIO.h" #include "tiffIO.h"
#include <cmath> #include <cmath>
class etaInterpolationBase : public slsInterpolation { class etaInterpolationBase : public slsInterpolation {
@ -128,7 +128,7 @@ class etaInterpolationBase : public slsInterpolation {
return NULL; return NULL;
}; };
void *readFlatField(const char *imgname, double emin = 1, double emax = 0) { int readFlatField(const char *imgname, double emin = 1, double emax = 0) {
if (emax >= 1) if (emax >= 1)
etamax = emax; etamax = emax;
if (emin <= 0) if (emin <= 0)
@ -169,9 +169,9 @@ class etaInterpolationBase : public slsInterpolation {
} }
} }
delete[] gm; delete[] gm;
return heta; return 1;
} }
return NULL; return 0;
}; };
float *gethhx() { float *gethhx() {
@ -183,17 +183,12 @@ class etaInterpolationBase : public slsInterpolation {
// hhy->Scale((double)nSubPixels); // hhy->Scale((double)nSubPixels);
return hhy; return hhy;
}; };
virtual int addToFlatFieldDistribution(double etax, double etay) { virtual int addToFlatField(double etax, double etay) {
#ifdef MYROOT1
heta->Fill(etax, etay);
#endif
#ifndef MYROOT1
int ex, ey; int ex, ey;
ex = (etax - etamin) / etastepX; ex = (etax - etamin) / etastepX;
ey = (etay - etamin) / etastepY; ey = (etay - etamin) / etastepY;
if (ey < nbetaY && ex < nbetaX && ex >= 0 && ey >= 0) if (ey < nbetaY && ex < nbetaX && ex >= 0 && ey >= 0)
heta[ey * nbetaX + ex]++; heta[ey * nbetaX + ex]++;
#endif
return 0; return 0;
}; };

View File

@ -3,7 +3,7 @@
#ifndef ETA_INTERPOLATION_CLEVER_ADAPTIVEBINS_H #ifndef ETA_INTERPOLATION_CLEVER_ADAPTIVEBINS_H
#define ETA_INTERPOLATION_CLEVER_ADAPTIVEBINS_H #define ETA_INTERPOLATION_CLEVER_ADAPTIVEBINS_H
#include "sls/tiffIO.h" #include "tiffIO.h"
#include <cmath> #include <cmath>
//#include "etaInterpolationBase.h" //#include "etaInterpolationBase.h"
#include "etaInterpolationAdaptiveBins.h" #include "etaInterpolationAdaptiveBins.h"

View File

@ -3,7 +3,7 @@
#ifndef ETA_INTERPOLATION_POSXY_H #ifndef ETA_INTERPOLATION_POSXY_H
#define ETA_INTERPOLATION_POSXY_H #define ETA_INTERPOLATION_POSXY_H
//#include "sls/tiffIO.h" //#include "tiffIO.h"
#include "eta2InterpolationBase.h" #include "eta2InterpolationBase.h"
#include "eta3InterpolationBase.h" #include "eta3InterpolationBase.h"
#include "etaInterpolationBase.h" #include "etaInterpolationBase.h"

View File

@ -3,7 +3,7 @@
#ifndef ETA_INTERPOLATION_RANDOMBINS_H #ifndef ETA_INTERPOLATION_RANDOMBINS_H
#define ETA_INTERPOLATION_RANDOMBINS_H #define ETA_INTERPOLATION_RANDOMBINS_H
#include "sls/tiffIO.h" #include "tiffIO.h"
//#include "etaInterpolationBase.h" //#include "etaInterpolationBase.h"
#include "etaInterpolationPosXY.h" #include "etaInterpolationPosXY.h"
#include <algorithm> #include <algorithm>

View File

@ -78,20 +78,20 @@ class noInterpolation : public slsInterpolation {
}; };
////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////
/* virtual int addToFlatField(double *cluster, double &etax, double &etay) { */ virtual int addToFlatField(double *cluster, double &etax, double &etay) {
/* return 0; */ return 0;
/* }; */ };
/* virtual int addToFlatField(int *cluster, double &etax, double &etay) { */ virtual int addToFlatField(int *cluster, double &etax, double &etay) {
/* return 0; */ return 0;
/* }; */ };
virtual int addToFlatFieldDistribution(double etax, double etay) { return 0; }; virtual int addToFlatField(double etax, double etay) { return 0; };
/* virtual int addToFlatField(double totquad, int quad, double *cl, */ virtual int addToFlatField(double totquad, int quad, double *cl,
/* double &etax, double &etay) { */ double &etax, double &etay) {
/* return 0; */ return 0;
/* }; */ };
virtual int addToFlatField(double totquad, int quad, int *cl, double &etax, virtual int addToFlatField(double totquad, int quad, int *cl, double &etax,
double &etay) { double &etay) {

View File

@ -5,7 +5,7 @@
#include <cstdlib> #include <cstdlib>
#ifndef MY_TIFF_IO_H #ifndef MY_TIFF_IO_H
#include "sls/tiffIO.h" #include "tiffIO.h"
#endif #endif
#ifndef DEF_QUAD #ifndef DEF_QUAD
@ -175,31 +175,29 @@ class slsInterpolation {
return hint; return hint;
}; };
//virtual int addToFlatField(double *cluster, double &etax, double &etay) = 0; virtual int addToFlatField(double *cluster, double &etax, double &etay) = 0;
//virtual int addToFlatField(int *cluster, double &etax, double &etay) = 0; virtual int addToFlatField(int *cluster, double &etax, double &etay) = 0;
virtual int addToFlatField(double totquad, int quad, int *cl, double &etax, virtual int addToFlatField(double totquad, int quad, int *cl, double &etax,
double &etay) = 0; double &etay) = 0;
//virtual int addToFlatField(double totquad, int quad, double *cluster, virtual int addToFlatField(double totquad, int quad, double *cluster,
// double &etax, double &etay) = 0; double &etax, double &etay) = 0;
virtual int addToFlatFieldDistribution(double etax, double etay) = 0; virtual int addToFlatField(double etax, double etay) = 0;
virtual int *getFlatFieldDistribution() { return NULL; }; virtual int *getFlatField() { return NULL; };
virtual int *setFlatField(int *h, int nbx = -1, int nby = -1, virtual int *setFlatField(int *h, int nb = -1, double emin = -1,
double emin = -1,
double emax = -1) { double emax = -1) {
return NULL; return NULL;
}; };
virtual void *writeFlatField(const char *imgname) { return NULL; }; virtual void *writeFlatField(const char *imgname) { return NULL; };
virtual void *readFlatField(const char *imgname, virtual void *readFlatField(const char *imgname, int nb = -1,
double emin = 1, double emax = 0) { double emin = 1, double emax = 0) {
return NULL; return NULL;
}; };
virtual int *getFlatField(int &nbx, int &nby, double &emin, double &emax) { virtual int *getFlatField(int &nb, double &emin, double &emax) {
nbx = 0; nb = 0;
nby=0;
emin = 0; emin = 0;
emax = 0; emax = 0;
return getFlatFieldDistribution(); return getFlatField();
}; };
virtual void resetFlatField() = 0; virtual void resetFlatField() = 0;

View File

@ -23,7 +23,7 @@
#endif #endif
#include "moench03CommonMode.h" #include "moench03CommonMode.h"
#include "moench03GhostSummation.h" #include "moench03GhostSummation.h"
#include "sls/tiffIO.h" #include "tiffIO.h"
#include <fstream> #include <fstream>
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>

View File

@ -20,7 +20,7 @@ class commonModeSubtractionColumn : public commonModeSubtraction {
mean2[iroi] += val * val; mean2[iroi] += val * val;
nCm[iroi]++; nCm[iroi]++;
if (nCm[iroi] > rows) if (nCm[iroi] > rows)
std::cout << "Too many pixels added " << nCm[iroi] << std::endl; cout << "Too many pixels added " << nCm[iroi] << endl;
/* if (ix==10 && iy<20) */ /* if (ix==10 && iy<20) */
/* cout << " ** "<<val << " " << mean[iroi] << " " << /* cout << " ** "<<val << " " << mean[iroi] << " " <<
* nCm[iroi] << " " << getCommonMode(ix, iy) << endl; */ * nCm[iroi] << " " << getCommonMode(ix, iy) << endl; */

View File

@ -1,52 +1,57 @@
# SPDX-License-Identifier: LGPL-3.0-or-other # SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package # Copyright (C) 2021 Contributors to the SLS Detector Package
find_package(TIFF REQUIRED)
set(MOENCH_EXECUTABLES) set(MOENCH_EXECUTABLES)
#Moench ZMQ #Moench ZMQ
add_executable(moench03ZmqProcess moenchZmqProcess.cpp) add_executable(moenchZmqProcess moenchZmqProcess.cpp ../tiffIO.cpp)
target_compile_definitions(moench03ZmqProcess PRIVATE NEWZMQ INTERP) target_compile_definitions(moenchZmqProcess PRIVATE NEWZMQ INTERP)
list(APPEND MOENCH_EXECUTABLES moench03ZmqProcess) list(APPEND MOENCH_EXECUTABLES moenchZmqProcess)
#Moench HighZ ZMQ
add_executable(moenchHighZZmqProcess moenchZmqProcess.cpp)
target_compile_definitions(moenchHighZZmqProcess PRIVATE NEWZMQ INTERP HIGHZ)
list(APPEND MOENCH_EXECUTABLES moenchHighZZmqProcess)
#Moench04 ZMQ #Moench04 ZMQ
add_executable(moench04ZmqProcess moenchZmqProcess.cpp) add_executable(moench04ZmqProcess moenchZmqProcess.cpp ../tiffIO.cpp)
target_compile_definitions(moench04ZmqProcess PRIVATE NEWZMQ INTERP MOENCH04) target_compile_definitions(moench04ZmqProcess PRIVATE NEWZMQ INTERP MOENCH04)
list(APPEND MOENCH_EXECUTABLES moench04ZmqProcess) list(APPEND MOENCH_EXECUTABLES moench04ZmqProcess)
#OFFLINE Processing? #OFFLINE Processing?
add_executable(moench03RawDataProcess moenchRawDataProcess.cpp) add_executable(moenchClusterFinder moench03ClusterFinder.cpp ../tiffIO.cpp)
target_compile_definitions(moench03RawDataProcess PRIVATE) target_compile_definitions(moenchClusterFinder PRIVATE SAVE_ALL NEWRECEIVER)
list(APPEND MOENCH_EXECUTABLES moench03RawDataProcess) list(APPEND MOENCH_EXECUTABLES moenchClusterFinder)
add_executable(moenchHighZRawDataProcess moenchRawDataProcess.cpp) add_executable(moenchClusterFinderHighZ moench03ClusterFinder.cpp ../tiffIO.cpp)
target_compile_definitions(moenchHighZRawDataProcess PRIVATE HIGHZ) target_compile_definitions(moenchClusterFinderHighZ PRIVATE SAVE_ALL NEWRECEIVER HIGHZ)
list(APPEND MOENCH_EXECUTABLES moenchHighZRawDataProcess) list(APPEND MOENCH_EXECUTABLES moenchClusterFinderHighZ)
add_executable(moench04RawDataProcess moenchRawDataProcess.cpp) add_executable(moenchMakeEta moench03Interpolation.cpp ../tiffIO.cpp)
target_compile_definitions(moench04RawDataProcess PRIVATE MOENCH04) target_compile_definitions(moenchMakeEta PRIVATE FF)
list(APPEND MOENCH_EXECUTABLES moench04RawDataProcess) list(APPEND MOENCH_EXECUTABLES moenchMakeEta)
#interpolation stuff add_executable(moenchInterpolation moench03Interpolation.cpp ../tiffIO.cpp)
add_executable(moench03MakeEta moench03Interpolation.cpp)
target_compile_definitions(moench03MakeEta PRIVATE FF)
list(APPEND MOENCH_EXECUTABLES moench03MakeEta)
add_executable(moench03Interpolation moench03Interpolation.cpp)
#no compile defs #no compile defs
list(APPEND MOENCH_EXECUTABLES moench03Interpolation) list(APPEND MOENCH_EXECUTABLES moenchInterpolation)
add_executable(moench03NoInterpolation moench03NoInterpolation.cpp) add_executable(moenchNoInterpolation moench03NoInterpolation.cpp ../tiffIO.cpp)
#no compile defs #no compile defs
list(APPEND MOENCH_EXECUTABLES moench03NoInterpolation) list(APPEND MOENCH_EXECUTABLES moenchNoInterpolation)
add_executable(moenchPhotonCounter moenchPhotonCounter.cpp ../tiffIO.cpp)
target_compile_definitions(moenchPhotonCounter PRIVATE NEWRECEIVER)
list(APPEND MOENCH_EXECUTABLES moenchPhotonCounter)
add_executable(moenchAnalog moenchPhotonCounter.cpp ../tiffIO.cpp)
target_compile_definitions(moenchAnalog PRIVATE NEWRECEIVER ANALOG)
list(APPEND MOENCH_EXECUTABLES moenchAnalog)
add_executable(moenchPhotonCounterHighZ moenchPhotonCounter.cpp ../tiffIO.cpp)
target_compile_definitions(moenchPhotonCounterHighZ PRIVATE NEWRECEIVER HIGHZ)
list(APPEND MOENCH_EXECUTABLES moenchPhotonCounterHighZ)
add_executable(moenchAnalogHighZ moenchPhotonCounter.cpp ../tiffIO.cpp)
target_compile_definitions(moenchAnalogHighZ PRIVATE NEWRECEIVER ANALOG HIGHZ)
list(APPEND MOENCH_EXECUTABLES moenchAnalogHighZ)
foreach(exe ${MOENCH_EXECUTABLES}) foreach(exe ${MOENCH_EXECUTABLES})
@ -56,8 +61,6 @@ foreach(exe ${MOENCH_EXECUTABLES})
../dataStructures ../dataStructures
../interpolations ../interpolations
../../slsReceiverSoftware/include/ ../../slsReceiverSoftware/include/
../../slsSupportLib/include/
${SLS_INTERNAL_RAPIDJSON_DIR}
) )
target_link_libraries(${exe} target_link_libraries(${exe}
@ -65,11 +68,10 @@ foreach(exe ${MOENCH_EXECUTABLES})
slsSupportStatic slsSupportStatic
${ZeroMQ_LIBRARIES} ${ZeroMQ_LIBRARIES}
pthread pthread
tiffio TIFF::TIFF
PRIVATE PRIVATE
slsProjectWarnings slsProjectWarnings
slsProjectOptions
) )
@ -81,6 +83,8 @@ foreach(exe ${MOENCH_EXECUTABLES})
endif() endif()
endforeach(exe ${MOENCH_EXECUTABLES}) endforeach(exe ${MOENCH_EXECUTABLES})
install(TARGETS ${MOENCH_EXECUTABLES} DESTINATION bin) install(TARGETS ${MOENCH_EXECUTABLES} DESTINATION bin)

View File

@ -0,0 +1,219 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
//#include "sls/ansi.h"
#include <iostream>
//#include "moench03T1ZmqData.h"
#ifdef NEWRECEIVER
#ifndef RECT
#include "moench03T1ReceiverDataNew.h"
#endif
#ifdef RECT
#include "moench03T1ReceiverDataNewRect.h"
#endif
#endif
#ifdef CSAXS_FP
#include "moench03T1ReceiverData.h"
#endif
#ifdef OLDDATA
#include "moench03Ctb10GbT1Data.h"
#endif
#ifdef REORDERED
#include "moench03T1ReorderedData.h"
#endif
// #include "interpolatingDetector.h"
//#include "etaInterpolationPosXY.h"
// #include "linearInterpolation.h"
// #include "noInterpolation.h"
#include "multiThreadedAnalogDetector.h"
#include "singlePhotonDetector.h"
//#include "interpolatingDetector.h"
#include <fstream>
#include <map>
#include <stdio.h>
#include <sys/stat.h>
#include <ctime>
using namespace std;
int main(int argc, char *argv[]) {
if (argc < 6) {
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax "
<< endl;
return 1;
}
int p = 10000;
int fifosize = 1000;
int nthreads = 1;
int nsubpix = 25;
int etabins = nsubpix * 10;
double etamin = -1, etamax = 2;
int csize = 3;
int nx = 400, ny = 400;
int save = 1;
int nsigma = 5;
int nped = 1000;
int ndark = 100;
int ok;
int iprog = 0;
#ifdef NEWRECEIVER
#ifdef RECT
cout << "Should be rectangular!" << endl;
#endif
moench03T1ReceiverDataNew *decoder = new moench03T1ReceiverDataNew();
cout << "RECEIVER DATA WITH ONE HEADER!" << endl;
#endif
#ifdef CSAXS_FP
moench03T1ReceiverData *decoder = new moench03T1ReceiverData();
cout << "RECEIVER DATA WITH ALL HEADERS!" << endl;
#endif
#ifdef OLDDATA
moench03Ctb10GbT1Data *decoder = new moench03Ctb10GbT1Data();
cout << "OLD RECEIVER DATA!" << endl;
#endif
#ifdef REORDERED
moench03T1ReorderedData *decoder = new moench03T1ReorderedData();
cout << "REORDERED DATA!" << endl;
#endif
decoder->getDetectorSize(nx, ny);
cout << "nx " << nx << " ny " << ny << endl;
// moench03T1ZmqData *decoder=new moench03T1ZmqData();
singlePhotonDetector *filter =
new singlePhotonDetector(decoder, csize, nsigma, 1, 0, nped, 200);
// char tit[10000];
cout << "filter " << endl;
// filter->readPedestals("/scratch/ped_100.tiff");
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
// cout << "filter "<< endl;
int size = 327680; ////atoi(argv[3]);
int *image;
// int* image =new int[327680/sizeof(int)];
filter->newDataSet();
int ff, np;
int dsize = decoder->getDataSize();
cout << " data size is " << dsize;
char data[dsize];
ifstream filebin;
char *indir = argv[1];
char *outdir = argv[2];
char *fformat = argv[3];
int runmin = atoi(argv[4]);
int runmax = atoi(argv[5]);
char fname[10000];
char outfname[10000];
char imgfname[10000];
char pedfname[10000];
// strcpy(pedfname,argv[6]);
char fn[10000];
std::time_t end_time;
FILE *of = NULL;
cout << "input directory is " << indir << endl;
cout << "output directory is " << outdir << endl;
cout << "fileformat is " << fformat << endl;
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
char *buff;
multiThreadedAnalogDetector *mt =
new multiThreadedAnalogDetector(filter, nthreads, fifosize);
mt->setDetectorMode(ePhotonCounting);
mt->setFrameMode(eFrame);
mt->StartThreads();
mt->popFree(buff);
cout << "mt " << endl;
int ifr = 0;
for (int irun = runmin; irun < runmax; irun++) {
sprintf(fn, fformat, irun);
sprintf(fname, "%s/%s.raw", indir, fn);
sprintf(outfname, "%s/%s.clust", outdir, fn);
sprintf(imgfname, "%s/%s.tiff", outdir, fn);
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
cout << fname << " " << outfname << " " << imgfname << endl;
filebin.open((const char *)(fname), ios::in | ios::binary);
// //open file
if (filebin.is_open()) {
of = fopen(outfname, "w");
if (of) {
mt->setFilePointer(of);
// cout << "file pointer set " << endl;
} else {
cout << "Could not open " << outfname << " for writing "
<< endl;
mt->setFilePointer(NULL);
return 1;
}
// //while read frame
ff = -1;
while (decoder->readNextFrame(filebin, ff, np, buff)) {
// cout << "*"<<ifr++<<"*"<<ff<< endl;
// cout << ff << " " << np << endl;
// //push
// for (int ix=0; ix<400; ix++)
// for (int iy=0; iy<400; iy++) {
// if (decoder->getChannel(buff, ix, iy)<3000 ||
// decoder->getChannel(buff, ix, iy)>8000) {
// cout << ifr << " " << ff << " " << ix << " " << iy <<
// " " << decoder->getChannel(buff, ix, iy) << endl ;
// }
// }
mt->pushData(buff);
// // //pop
mt->nextThread();
// // // cout << " " << (void*)buff;
mt->popFree(buff);
ifr++;
if (ifr % 10000 == 0)
cout << ifr << " " << ff << endl;
ff = -1;
}
cout << "--" << endl;
filebin.close();
// //close file
// //join threads
while (mt->isBusy()) {
;
} // wait until all data are processed from the queues
if (of)
fclose(of);
mt->writeImage(imgfname);
mt->clearImage();
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
} else
cout << "Could not open " << fname << " for reading " << endl;
}
return 0;
}

View File

@ -47,6 +47,7 @@ int main(int argc, char *argv[]) {
#endif #endif
int iarg = 4; int iarg = 4;
char infname[10000]; char infname[10000];
char fname[10000];
char outfname[10000]; char outfname[10000];
#ifndef FF #ifndef FF
iarg = 4; iarg = 4;
@ -73,17 +74,18 @@ int main(int argc, char *argv[]) {
int etabins = 1000; // nsubpix*2*100; int etabins = 1000; // nsubpix*2*100;
double etamin = -1, etamax = 2; double etamin = -1, etamax = 2;
// double etamin=-0.1, etamax=1.1; // double etamin=-0.1, etamax=1.1;
// double eta3min = -2, eta3max = 2; double eta3min = -2, eta3max = 2;
int quad;
double sum, totquad; double sum, totquad;
double sDum[2][2]; double sDum[2][2];
double etax, etay; double etax, etay, int_x, int_y;
// double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y; double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y;
int ok;
int f0 = -1;
int ix, iy, isx, isy; int ix, iy, isx, isy;
int nframes = 0, lastframe = -1; int nframes = 0, lastframe = -1;
//double d_x, d_y, res = 5, xx, yy; double d_x, d_y, res = 5, xx, yy;
int nph = 0, totph = 0; int nph = 0, badph = 0, totph = 0;
//badph = 0,
FILE *f = NULL; FILE *f = NULL;
#ifdef DOUBLE_SPH #ifdef DOUBLE_SPH
@ -94,8 +96,7 @@ int main(int argc, char *argv[]) {
single_photon_hit cl(3, 3); single_photon_hit cl(3, 3);
#endif #endif
//int f0 = -1; int nSubPixels = nsubpix;
// int nSubPixels = nsubpix;
#ifndef NOINTERPOLATION #ifndef NOINTERPOLATION
eta2InterpolationPosXY *interp = eta2InterpolationPosXY *interp =
new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax); new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
@ -108,12 +109,7 @@ int main(int argc, char *argv[]) {
#endif #endif
#ifndef FF #ifndef FF
int quad;
#ifndef NOINTERPOLATION #ifndef NOINTERPOLATION
char fname[10000];
int ok;
double int_x, int_y;
int *img;
cout << "read ff " << argv[2] << endl; cout << "read ff " << argv[2] << endl;
sprintf(fname, "%s", argv[2]); sprintf(fname, "%s", argv[2]);
interp->readFlatField(fname); interp->readFlatField(fname);
@ -125,6 +121,7 @@ int main(int argc, char *argv[]) {
cout << "Will write eta file " << argv[2] << endl; cout << "Will write eta file " << argv[2] << endl;
#endif #endif
int *img;
float *totimg = new float[NC * NR * nsubpix * nsubpix]; float *totimg = new float[NC * NR * nsubpix * nsubpix];
for (ix = 0; ix < NC; ix++) { for (ix = 0; ix < NC; ix++) {
for (iy = 0; iy < NR; iy++) { for (iy = 0; iy < NR; iy++) {
@ -152,7 +149,7 @@ int main(int argc, char *argv[]) {
if (f) { if (f) {
cout << infname << endl; cout << infname << endl;
nframes = 0; nframes = 0;
//f0 = -1; f0 = -1;
while (cl.read(f)) { while (cl.read(f)) {
totph++; totph++;
@ -160,21 +157,14 @@ int main(int argc, char *argv[]) {
lastframe = cl.iframe; lastframe = cl.iframe;
// cout << cl.iframe << endl; // cout << cl.iframe << endl;
// f0=cl.iframe; // f0=cl.iframe;
// if (nframes == 0) if (nframes == 0)
// f0 = lastframe; f0 = lastframe;
nframes++; nframes++;
} }
// quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum); // quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
#ifndef FF
quad = interp->calcEta(cl.get_cluster(), etax, etay, sum, quad = interp->calcEta(cl.get_cluster(), etax, etay, sum,
totquad, sDum); totquad, sDum);
#endif if (sum > cmin && totquad / sum > 0.8 && totquad / sum < 1.2 &&
#ifdef FF
interp->calcEta(cl.get_cluster(), etax, etay, sum,
totquad, sDum);
#endif
if (sum > cmin && totquad / sum > 0.8 && totquad / sum < 1.2 &&
sum < cmax) { sum < cmax) {
nph++; nph++;
// if (sum>200 && sum<580) { // if (sum>200 && sum<580) {
@ -209,7 +199,7 @@ int main(int argc, char *argv[]) {
// if (cl.x>50) // if (cl.x>50)
// #endif // #endif
// if (etax!=0 && etay!=0 && etax!=1 && etay!=1) // if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
interp->addToFlatFieldDistribution(etax, etay); interp->addToFlatField(etax, etay);
// if (etax==0 || etay==0) cout << cl.x << " " << cl.y << // if (etax==0 || etay==0) cout << cl.x << " " << cl.y <<
// endl; // endl;
@ -252,9 +242,9 @@ int main(int argc, char *argv[]) {
} }
} }
} }
// cout << "Read " << nframes << " frames (first frame: " << f0 cout << "Read " << nframes << " frames (first frame: " << f0
// << " last frame: " << lastframe << " delta:" << lastframe - f0 << " last frame: " << lastframe << " delta:" << lastframe - f0
// << ") nph=" << nph << endl; << ") nph=" << nph << endl;
interp->clearInterpolatedImage(); interp->clearInterpolatedImage();
#endif #endif

View File

@ -2,33 +2,43 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
//#include "sls/ansi.h" //#include "sls/ansi.h"
#include <iostream> #include <iostream>
#undef CORR #define CORR
#define C_GHOST 0.0004 #define C_GHOST 0.0004
#define CM_ROWS 50 #define CM_ROWS 50
#define RAWDATA //#define VERSION_V1
#ifndef MOENCH04 //#include "moench03T1ZmqData.h"
#ifdef NEWRECEIVER
#ifndef RECT #ifndef RECT
#include "moench03T1ReceiverDataNew.h" #include "moench03T1ReceiverDataNew.h"
#endif #endif
#endif
#ifdef RECT #ifdef RECT
#include "moench03T1ReceiverDataNewRect.h" #include "moench03T1ReceiverDataNewRect.h"
#endif #endif
#ifdef MOENCH04
#include "moench04CtbZmq10GbData.h"
#endif #endif
#ifdef CSAXS_FP
#include "moench03T1ReceiverData.h"
#endif
#ifdef OLDDATA
#include "moench03Ctb10GbT1Data.h"
#endif
// #include "interpolatingDetector.h"
//#include "etaInterpolationPosXY.h"
// #include "linearInterpolation.h"
// #include "noInterpolation.h"
#include "multiThreadedCountingDetector.h" #include "multiThreadedCountingDetector.h"
//#include "multiThreadedAnalogDetector.h"
#include "moench03CommonMode.h" #include "moench03CommonMode.h"
#include "moench03GhostSummation.h" #include "moench03GhostSummation.h"
#include "singlePhotonDetector.h" #include "singlePhotonDetector.h"
//#include "interpolatingDetector.h"
#include <fstream> #include <fstream>
#include <map> #include <map>
@ -42,7 +52,7 @@ int main(int argc, char *argv[]) {
if (argc < 4) { if (argc < 4) {
cout << "Usage is " << argv[0] cout << "Usage is " << argv[0]
<< "indir outdir fname(no extension) [runmin] [runmax] [pedfile (raw or tiff)] [threshold] " << "indir outdir fname [runmin] [runmax] [pedfile] [threshold] "
"[nframes] [xmin xmax ymin ymax] [gainmap]" "[nframes] [xmin xmax ymin ymax] [gainmap]"
<< endl; << endl;
cout << "threshold <0 means analog; threshold=0 means cluster finder; " cout << "threshold <0 means analog; threshold=0 means cluster finder; "
@ -54,39 +64,55 @@ int main(int argc, char *argv[]) {
return 1; return 1;
} }
int p = 10000;
int fifosize = 1000; int fifosize = 1000;
int nthreads = 10; int nthreads = 10;
int nsubpix = 25;
int etabins = nsubpix * 10;
double etamin = -1, etamax = 2;
int csize = 3; int csize = 3;
int save = 1;
int nsigma = 5; int nsigma = 5;
int nped = 10000; int nped = 10000;
int ndark = 100;
int ok;
int iprog = 0;
int cf = 0; int cf = 0;
#ifdef NEWRECEIVER
#ifdef RECT #ifdef RECT
cout << "Should be rectangular but now it will crash! No data structure defined!" << endl; cout << "Should be rectangular!" << endl;
#endif #endif
#ifndef MOENCH04
moench03T1ReceiverDataNew *decoder = new moench03T1ReceiverDataNew(); moench03T1ReceiverDataNew *decoder = new moench03T1ReceiverDataNew();
cout << "MOENCH03!" << endl; cout << "RECEIVER DATA WITH ONE HEADER!" << endl;
#endif #endif
#ifdef MOENCH04 #ifdef CSAXS_FP
moench04CtbZmq10GbData *decoder = new moench04CtbZmq10GbData(); moench03T1ReceiverData *decoder = new moench03T1ReceiverData();
cout << "MOENCH04!" << endl; cout << "RECEIVER DATA WITH ALL HEADERS!" << endl;
#endif #endif
#ifdef OLDDATA
moench03Ctb10GbT1Data *decoder = new moench03Ctb10GbT1Data();
cout << "OLD RECEIVER DATA!" << endl;
#endif
int nx = 400, ny = 400; int nx = 400, ny = 400;
decoder->getDetectorSize(nx, ny); decoder->getDetectorSize(nx, ny);
#ifdef CORR
int ncol_cm = CM_ROWS; int ncol_cm = CM_ROWS;
double xt_ghost = C_GHOST; double xt_ghost = C_GHOST;
#endif
moench03CommonMode *cm = NULL; moench03CommonMode *cm = NULL;
moench03GhostSummation *gs; moench03GhostSummation *gs;
double *gainmap = NULL; double *gainmap = NULL;
//float *gm; float *gm;
int size = 327680; ////atoi(argv[3]);
int *image;
// int* image =new int[327680/sizeof(int)];
int ff, np; int ff, np;
// cout << " data size is " << dsize; // cout << " data size is " << dsize;
@ -143,6 +169,7 @@ int main(int argc, char *argv[]) {
char fname[10000]; char fname[10000];
char imgfname[10000]; char imgfname[10000];
char cfname[10000]; char cfname[10000];
char fn[10000];
std::time_t end_time; std::time_t end_time;
@ -159,6 +186,19 @@ int main(int argc, char *argv[]) {
cout << "Nframes is " << nframes << endl; cout << "Nframes is " << nframes << endl;
uint32_t nnx, nny; uint32_t nnx, nny;
double *gmap;
// if (gainfname) {
// gm=ReadFromTiff(gainfname, nny, nnx);
// if (gm && nnx==nx && nny==ny) {
// gmap=new double[nx*ny];
// for (int i=0; i<nx*ny; i++) {
// gmap[i]=gm[i];
// }
// delete gm;
// } else
// cout << "Could not open gain map " << gainfname << endl;
// }
#ifdef CORR #ifdef CORR
cout << "Applying common mode " << ncol_cm << endl; cout << "Applying common mode " << ncol_cm << endl;
@ -180,15 +220,21 @@ int main(int argc, char *argv[]) {
} else } else
thr = 0.15 * thr; thr = 0.15 * thr;
filter->newDataSet(); filter->newDataSet();
//int dsize = decoder->getDataSize(); int dsize = decoder->getDataSize();
char data[dsize];
//#ifndef ANALOG
if (thr > 0) { if (thr > 0) {
cout << "threshold is " << thr << endl; cout << "threshold is " << thr << endl;
//#ifndef ANALOG
filter->setThreshold(thr); filter->setThreshold(thr);
//#endif
cf = 0; cf = 0;
} else } else
cf = 1; cf = 1;
//#endif
filter->setROI(xmin, xmax, ymin, ymax); filter->setROI(xmin, xmax, ymin, ymax);
std::time(&end_time); std::time(&end_time);
@ -223,7 +269,7 @@ int main(int argc, char *argv[]) {
int ifr = 0; int ifr = 0;
double *ped=new double[nx * ny];//, *ped1; double ped[nx * ny], *ped1;
if (pedfile) { if (pedfile) {
@ -231,10 +277,10 @@ int main(int argc, char *argv[]) {
sprintf(imgfname, "%s/pedestals.tiff", outdir); sprintf(imgfname, "%s/pedestals.tiff", outdir);
if (string(pedfile).find(".tif") == std::string::npos) { if (string(pedfile).find(".tif") == std::string::npos) {
sprintf(fname, "%s", pedfile); sprintf(fname, "%s.raw", pedfile);
cout << fname << endl; cout << fname << endl;
std::time(&end_time); std::time(&end_time);
//cout << "aaa" << std::ctime(&end_time) << endl; cout << "aaa" << std::ctime(&end_time) << endl;
mt->setFrameMode(ePedestal); mt->setFrameMode(ePedestal);
// sprintf(fn,fformat,irun); // sprintf(fn,fformat,irun);
@ -264,12 +310,18 @@ int main(int argc, char *argv[]) {
<< " for reading " << endl; << " for reading " << endl;
} else { } else {
float *pp = ReadFromTiff(pedfile, nny, nnx); float *pp = ReadFromTiff(pedfile, nny, nnx);
if (pp && (int)nnx == nx && (int)nny == ny) { if (pp && nnx == nx && nny == ny) {
for (int i = 0; i < nx * ny; i++) { for (int i = 0; i < nx * ny; i++) {
ped[i] = pp[i]; ped[i] = pp[i];
} }
delete[] pp; delete[] pp;
mt->setPedestal(ped); mt->setPedestal(ped);
// ped1=mt->getPedestal();
// for (int i=0; i<nx*ny; i++) {
// cout << ped[i]<<"/"<<ped1[i] << " " ;
// }
cout << "Pedestal set from tiff file " << pedfile << endl; cout << "Pedestal set from tiff file " << pedfile << endl;
} else { } else {
cout << "Could not open pedestal tiff file " << pedfile cout << "Could not open pedestal tiff file " << pedfile
@ -290,11 +342,11 @@ int main(int argc, char *argv[]) {
cout << "DATA "; cout << "DATA ";
// sprintf(fn,fformat,irun); // sprintf(fn,fformat,irun);
sprintf(ffname, "%s/%s.raw", indir, fformat); sprintf(ffname, "%s/%s.raw", indir, fformat);
sprintf(fname, (const char*)ffname, irun); sprintf(fname, ffname, irun);
sprintf(ffname, "%s/%s.tiff", outdir, fformat); sprintf(ffname, "%s/%s.tiff", outdir, fformat);
sprintf(imgfname, (const char*)ffname, irun); sprintf(imgfname, ffname, irun);
sprintf(ffname, "%s/%s.clust", outdir, fformat); sprintf(ffname, "%s/%s.clust", outdir, fformat);
sprintf(cfname, (const char*)ffname, irun); sprintf(cfname, ffname, irun);
cout << fname << " "; cout << fname << " ";
cout << imgfname << endl; cout << imgfname << endl;
std::time(&end_time); std::time(&end_time);
@ -323,10 +375,13 @@ int main(int argc, char *argv[]) {
ifr = 0; ifr = 0;
while (decoder->readNextFrame(filebin, ff, np, buff)) { while (decoder->readNextFrame(filebin, ff, np, buff)) {
if (np == 40) { if (np == 40) {
// cout << "*"<<ifr++<<"*"<<ff<< endl;
// cout << ff << " " << np << endl;
// //push // //push
mt->pushData(buff); mt->pushData(buff);
// // //pop // // //pop
mt->nextThread(); mt->nextThread();
// // // cout << " " << (void*)buff;
mt->popFree(buff); mt->popFree(buff);
ifr++; ifr++;
@ -334,9 +389,15 @@ int main(int argc, char *argv[]) {
cout << ifr << " " << ff << endl; cout << ifr << " " << ff << endl;
if (nframes > 0) { if (nframes > 0) {
if (ifr % nframes == 0) { if (ifr % nframes == 0) {
// The name has an additional "_fXXXXX" at the end,
// where "XXXXX" is the initial frame number of the
// image (0,1000,2000...)
sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat, sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat,
ifile); ifile);
sprintf(imgfname, (const char*)ffname, irun); sprintf(imgfname, ffname, irun);
// cout << "Writing tiff to " << imgfname << " " <<
// thr1 << endl;
mt->writeImage(imgfname, thr1); mt->writeImage(imgfname, thr1);
mt->clearImage(); mt->clearImage();
ifile++; ifile++;
@ -348,16 +409,18 @@ int main(int argc, char *argv[]) {
} }
cout << "--" << endl; cout << "--" << endl;
filebin.close(); filebin.close();
// //close file
// //join threads
while (mt->isBusy()) { while (mt->isBusy()) {
; ;
} }
if (nframes >= 0) { if (nframes >= 0) {
if (nframes > 0) { if (nframes > 0) {
sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat, ifile); sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat, ifile);
sprintf(imgfname, (const char*)ffname, irun); sprintf(imgfname, ffname, irun);
} else { } else {
sprintf(ffname, "%s/%s.tiff", outdir, fformat); sprintf(ffname, "%s/%s.tiff", outdir, fformat);
sprintf(imgfname, (const char*)ffname, irun); sprintf(imgfname, ffname, irun);
} }
cout << "Writing tiff to " << imgfname << " " << thr1 << endl; cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
mt->writeImage(imgfname, thr1); mt->writeImage(imgfname, thr1);

View File

@ -1,9 +1,9 @@
// SPDX-License-Identifier: LGPL-3.0-or-other // SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
//#define WRITE_QUAD //#define WRITE_QUAD
//#define DEVELOPER #define DEVELOPER
#undef CORR #undef CORR
//#undef MOENCH04 #undef MOENCH04
#define C_GHOST 0.0004 #define C_GHOST 0.0004
@ -11,21 +11,21 @@
#include "sls/ZmqSocket.h" #include "sls/ZmqSocket.h"
#include "sls/sls_detector_defs.h" #include "sls/sls_detector_defs.h"
#ifndef RECT
#ifndef MOENCH04 #ifndef MOENCH04
//#ifndef RECT
#include "moench03T1ZmqDataNew.h" #include "moench03T1ZmqDataNew.h"
//#endif
//#ifdef RECT
//#include "moench03T1ZmqDataNewRect.h"
//#endif
#endif #endif
#ifdef MOENCH04 #ifdef MOENCH04
#include "moench04CtbZmq10GbData.h" #include "moench04CtbZmq10GbData.h"
#endif #endif
#endif
#ifdef RECT
#include "moench03T1ZmqDataNewRect.h"
#endif
#include "moench03CommonMode.h" #include "moench03CommonMode.h"
#include "moench03GhostSummation.h" #include "moench03GhostSummation.h"
#include "sls/tiffIO.h" #include "tiffIO.h"
#include <fstream> #include <fstream>
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
@ -156,7 +156,7 @@ int main(int argc, char *argv[]) {
int send_something = 0; int send_something = 0;
int maxSize = npx * npy * 2; // 32*2*8192;//5000;//atoi(argv[3]); int maxSize = npx * npy * 2; // 32*2*8192;//5000;//atoi(argv[3]);
int size = maxSize+sizeof(int); // 32*2*5000; int size = maxSize; // 32*2*5000;
// int multisize=size; // int multisize=size;
// int dataSize=size; // int dataSize=size;
@ -305,10 +305,10 @@ int main(int argc, char *argv[]) {
// header variables // header variables
uint64_t acqIndex = -1; uint64_t acqIndex = -1;
uint64_t frameIndex = -1; uint64_t frameIndex = -1;
// #ifdef MOENCH_BRANCH #ifdef MOENCH_BRANCH
// uint32_t subFrameIndex = -1; uint32_t subFrameIndex = -1;
// int *flippedData = 0; int *flippedData = 0;
// #endif #endif
uint64_t subframes = 0; uint64_t subframes = 0;
// uint64_t isubframe=0; // uint64_t isubframe=0;
@ -502,13 +502,13 @@ int main(int argc, char *argv[]) {
} }
#ifdef INTERP #ifdef INTERP
else if (fMode == eFlat) { else if (fMode == eFlat) {
int nbx, nby; int nb;
double emi = 0, ema = 1; double emi = 0, ema = 1;
int *ff = mt->getFlatField(nbx, nby, emi, ema); int *ff = mt->getFlatField(nb, emi, ema);
nnx = nbx; nnx = nb;
nny = nby; nny = nb;
dout = new int32_t[nbx * nby]; dout = new int32_t[nb * nb];
for (int ix = 0; ix < nbx * nby; ix++) { for (int ix = 0; ix < nb * nb; ix++) {
dout[ix] = ff[ix]; dout[ix] = ff[ix];
} }
} }

View File

@ -182,10 +182,10 @@ class threadedAnalogDetector {
interp->prepareInterpolation(ok); interp->prepareInterpolation(ok);
} }
virtual int *getFlatFieldDistribution() { virtual int *getFlatField() {
slsInterpolation *interp = (det)->getInterpolation(); slsInterpolation *interp = (det)->getInterpolation();
if (interp) if (interp)
return interp->getFlatFieldDistribution(); return interp->getFlatField();
else else
return NULL; return NULL;
} }
@ -208,19 +208,19 @@ class threadedAnalogDetector {
return NULL; return NULL;
} }
void *readFlatField(const char *imgname, double emin = 1, void *readFlatField(const char *imgname, int nb = -1, double emin = 1,
double emax = 0) { double emax = 0) {
slsInterpolation *interp = (det)->getInterpolation(); slsInterpolation *interp = (det)->getInterpolation();
if (interp) if (interp)
return interp->readFlatField(imgname, emin, emax); return interp->readFlatField(imgname, nb, emin, emax);
return NULL; return NULL;
} }
virtual int *getFlatField(int &nbx, int &nby, double &emi, double &ema) { virtual int *getFlatField(int &nb, double emi, double ema) {
slsInterpolation *interp = (det)->getInterpolation(); slsInterpolation *interp = (det)->getInterpolation();
int *ff = NULL; int *ff = NULL;
if (interp) { if (interp) {
ff = interp->getFlatField(nbx, nby, emi, ema); ff = interp->getFlatField(nb, emi, ema);
} }
return ff; return ff;
} }

View File

@ -25,10 +25,10 @@ class multiThreadedInterpolatingDetector
// } // }
} }
virtual int *getFlatFieldDistribution() { return (dets[0])->getFlatFieldDistribution(); } virtual int *getFlatField() { return (dets[0])->getFlatField(); }
virtual int *getFlatField(int &nbx, int &nby, double &emi, double &ema) { virtual int *getFlatField(int &nb, double emi, double ema) {
return (dets[0])->getFlatField(nbx, nby, emi, ema); return (dets[0])->getFlatField(nb, emi, ema);
} }
virtual int *setFlatField(int *h = NULL, int nb = -1, double emin = 1, virtual int *setFlatField(int *h = NULL, int nb = -1, double emin = 1,
@ -40,9 +40,9 @@ class multiThreadedInterpolatingDetector
return dets[0]->writeFlatField(imgname); return dets[0]->writeFlatField(imgname);
}; };
void *readFlatField(const char *imgname, double emin = 1, void *readFlatField(const char *imgname, int nb = -1, double emin = 1,
double emax = 0) { double emax = 0) {
return (dets[0])->readFlatField(imgname, emin, emax); return (dets[0])->readFlatField(imgname, nb, emin, emax);
}; };
/* virtual int setNSubPixels(int ns) { return /* virtual int setNSubPixels(int ns) { return

View File

@ -429,28 +429,23 @@ class singlePhotonDetector : public analogDetector<uint16_t> {
for (ic = -(clusterSize / 2); ic < (clusterSize / 2) + 1; for (ic = -(clusterSize / 2); ic < (clusterSize / 2) + 1;
ic++) { ic++) {
if ((iy + ir) >= 0 && (iy + ir) < ny && if ((iy + ir) >= iy && (iy + ir) < ny &&
(ix + ic) >= 0 && (ix + ic) < nx) { (ix + ic) >= ix && (ix + ic) < nx) {
if ((iy + ir) >= iy && (ix + ic) >= ix ) {
val[(iy + ir) * nx + ix + ic] = val[(iy + ir) * nx + ix + ic] =
subtractPedestal(data, ix + ic, iy + ir, cm); subtractPedestal(data, ix + ic, iy + ir, cm);
v = &(val[(iy + ir) * nx + ix + ic]);
} tot += *v;
v = &(val[(iy + ir) * nx + ix + ic]); if (ir <= 0 && ic <= 0)
tot += *v; bl += *v;
if (ir <= 0 && ic <= 0) if (ir <= 0 && ic >= 0)
bl += *v; br += *v;
if (ir <= 0 && ic >= 0) if (ir >= 0 && ic <= 0)
br += *v; tl += *v;
if (ir >= 0 && ic <= 0) if (ir >= 0 && ic >= 0)
tl += *v; tr += *v;
if (ir >= 0 && ic >= 0) if (*v > max) {
tr += *v; max = *v;
if (*v > max) //{ }
max = *v;
//}
} }
} }
} }
@ -518,19 +513,12 @@ class singlePhotonDetector : public analogDetector<uint16_t> {
for (ic = -(clusterSize / 2); for (ic = -(clusterSize / 2);
ic < (clusterSize / 2) + 1; ic++) { ic < (clusterSize / 2) + 1; ic++) {
if ((iy + ir) >= 0 && (iy + ir) < ny && if ((iy + ir) >= 0 && (iy + ir) < ny &&
(ix + ic) >= 0 && (ix + ic) < nx) { (ix + ic) >= 0 && (ix + ic) < nx)
(clusters + nph) (clusters + nph)
->set_data(val[(iy + ir) * nx + ix + ic], ->set_data(val[(iy + ir) * nx + ix + ic],
ic, ir); ic, ir);
if (val[(iy + ir) * nx + ix + ic]>max)
good=0;
}
} }
} }
if (good==0) {
(clusters + nph)->print();
cout << max << " " << val[iy * nx + ix] << endl;
}
good = 1; good = 1;
if (eMin > 0 && tot < eMin) if (eMin > 0 && tot < eMin)
good = 0; good = 0;

View File

@ -216,18 +216,14 @@ class single_photon_hit {
// int ix, iy; // int ix, iy;
printf("***************\n");
printf("** %d %d **\n",x,y);
for (int iy = 0; iy < dy; iy++) { for (int iy = 0; iy < dy; iy++) {
for (int ix = 0; ix < dx; ix++) { for (int ix = 0; ix < dx; ix++) {
printf("%d \t", data[ix + iy * dx]); printf("%d \t", data[ix + iy * dx]);
} }
printf("\n"); printf("\n");
} }
printf("***************\n");
} }
/** /**
assign the value to the element of the cluster matrix, with relative assign the value to the element of the cluster matrix, with relative
coordinates where the center of the cluster is (0,0) \param v value to be coordinates where the center of the cluster is (0,0) \param v value to be

View File

@ -1,12 +1,26 @@
// SPDX-License-Identifier: LGPL-3.0-or-other // SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
#ifndef MY_TIFF_IO_H
#include "sls/tiffIO.h" #include "tiffIO.h"
#endif
#include <iostream> #include <iostream>
#include <tiffio.h> using namespace std;
// #undef cbf_failnez
// #define cbf_failnez(x)
// {
// int err;
// err = (x);
// if (err) {
// fprintf(stderr,"\nCBFlib fatal error %x \n",err);
// exit(-1);
// }
// }
void *WriteToTiff(float *imgData, const char *imgname, int nrow, int ncol) { void *WriteToTiff(float *imgData, const char *imgname, int nrow, int ncol) {
constexpr uint32_t sampleperpixel = 1; int sampleperpixel = 1;
// unsigned char * buff=NULL;
// tsize_t linebytes;
// cout << "--" <<endl;
TIFF *tif = TIFFOpen(imgname, "w"); TIFF *tif = TIFFOpen(imgname, "w");
if (tif) { if (tif) {
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, ncol); TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, ncol);
@ -17,32 +31,50 @@ void *WriteToTiff(float *imgData, const char *imgname, int nrow, int ncol) {
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP);
// linebytes = sampleperpixel*ncol;
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP,
TIFFDefaultStripSize(tif, ncol * sampleperpixel)); TIFFDefaultStripSize(tif, ncol * sampleperpixel));
for (int irow = 0; irow < nrow; irow++) { for (int irow = 0; irow < nrow; irow++) {
TIFFWriteScanline(tif, &imgData[irow * ncol], irow, 0); TIFFWriteScanline(tif, &imgData[irow * ncol], irow, 0);
} }
TIFFClose(tif); TIFFClose(tif);
} else { } else
std::cout << "could not open file " << imgname << " for writing\n"; cout << "could not open file " << imgname << " for writing " << endl;
}
return nullptr; return NULL;
} };
float *ReadFromTiff(const char *imgname, uint32_t &nrow, uint32_t &ncol) { float *ReadFromTiff(const char *imgname, uint32_t &nrow, uint32_t &ncol) {
// unsigned char * buff=NULL;
TIFF *tif = TIFFOpen(imgname, "r"); TIFF *tif = TIFFOpen(imgname, "r");
if (tif) { if (tif) {
uint32_t bps;
uint32_t sampleperpixel = 1;
// tsize_t linebytes;
uint32_t imagelength;
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &ncol); TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &ncol);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &nrow); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &nrow);
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, sampleperpixel);
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, &bps);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength);
float *imgData = new float[ncol * nrow]; float *imgData = new float[ncol * nrow];
for (uint32_t irow = 0; irow < nrow; ++irow) { // linebytes = sampleperpixel*ncol;
// TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tif,
// ncol*sampleperpixel));
for (uint32_t irow = 0; irow < nrow; irow++) {
// tiffreadscanline(tif, buf, row);
TIFFReadScanline(tif, &imgData[irow * ncol], irow); TIFFReadScanline(tif, &imgData[irow * ncol], irow);
} }
TIFFClose(tif); TIFFClose(tif);
return imgData; return imgData;
} else { } else
std::cout << "could not open file " << imgname << " for reading\n"; cout << "could not open file " << imgname << " for reading " << endl;
return nullptr; return NULL;
} };
}

View File

@ -0,0 +1,35 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#ifndef MY_TIFF_IO_H
#define MY_TIFF_IO_H
#include <fstream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
/*****************************************************************************/
//
// CBFlib must be installed to use this program
//
/*****************************************************************************/
#include <tiffio.h>
#undef cbf_failnez
#define cbf_failnez(x) \
{ \
int err; \
err = (x); \
if (err) { \
fprintf(stderr, "\nCBFlib fatal error %x \n", err); \
exit(-1); \
} \
}
void *WriteToTiff(float *imgData, const char *imgname, int nrow, int ncol);
float *ReadFromTiff(const char *imgname, uint32_t &nrow, uint32_t &ncol);
#endif

View File

@ -1,14 +0,0 @@
find_package(TIFF REQUIRED)
add_library(tiffio STATIC src/tiffIO.cpp)
target_include_directories(tiffio PUBLIC include/)
target_link_libraries(tiffio
PUBLIC
TIFF::TIFF
PRIVATE
slsProjectWarnings
slsProjectOptions
)
if(SLS_USE_TESTS)
add_subdirectory(tests)
endif()

View File

@ -1,16 +0,0 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#pragma once
#include <cstdint>
//Write 32bit float data to tiff file
//Always returns nullptr, prints message on failure
void *WriteToTiff(float *imgData, const char *imgname, int nrow, int ncol);
//Read 32bit float data from tiff file, returns pointer to data and sets
//image dimensions in the out parameters nrow, ncol.
//Returns nullptr on failure
//The caller is responsible to deallocate the memory that the returned
//pointer points to.
float *ReadFromTiff(const char *imgname, uint32_t &nrow, uint32_t &ncol);

View File

@ -1,5 +0,0 @@
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
target_sources(tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/test-tiffio.cpp
)

View File

@ -1,54 +0,0 @@
#include "catch.hpp"
#include "sls/tiffIO.h"
#include <cstdio>
#include <ftw.h>
#include <iostream>
#include <vector>
/* Call-back to the 'remove()' function called by nftw() */
static int remove_callback(const char *pathname,
__attribute__((unused)) const struct stat *sbuf,
__attribute__((unused)) int type,
__attribute__((unused)) struct FTW *ftwb) {
return remove(pathname);
}
TEST_CASE("Write and read back data from tiff file") {
std::vector<float> data{1, 2, 3, 4, 5, 6, 7, 8, 9};
/* Create the temporary directory */
char tmp[] = "/tmp/tmpdir.XXXXXX";
char *tmp_dirname = mkdtemp(tmp);
if (tmp_dirname == NULL) {
perror("tempdir: error: Could not create tmp directory");
CHECK(false);
}
std::string fname = std::string(tmp_dirname) + std::string("/test.tif");
std::cout << "Writing to: " << fname<< '\n';
WriteToTiff(data.data(), fname.c_str(), 3, 3);
//Readback
uint32_t nrow, ncol;
float* ptr = ReadFromTiff(fname.c_str(), nrow, ncol);
CHECK(nrow == 3);
CHECK(ncol == 3);
uint32_t size = nrow*ncol;
for (uint32_t i = 0; i!=size; ++i){
CHECK(data[i] == ptr[i]);
}
delete[] ptr;
/* Delete the temporary directory */
if (nftw(tmp_dirname, remove_callback, FOPEN_MAX,
FTW_DEPTH | FTW_MOUNT | FTW_PHYS) == -1) {
perror("tempdir: error: ");
exit(EXIT_FAILURE);
}
}

View File

@ -235,7 +235,6 @@
</property> </property>
<addaction name="actionLoadConfiguration"/> <addaction name="actionLoadConfiguration"/>
<addaction name="actionLoadTrimbits"/> <addaction name="actionLoadTrimbits"/>
<addaction name="actionSaveTrimbits"/>
<addaction name="actionLoadParameters"/> <addaction name="actionLoadParameters"/>
</widget> </widget>
<widget class="QMenu" name="menuModes"> <widget class="QMenu" name="menuModes">
@ -420,11 +419,6 @@ p, li { white-space: pre-wrap; }
<string>&amp;About</string> <string>&amp;About</string>
</property> </property>
</action> </action>
<action name="actionSaveTrimbits">
<property name="text">
<string>Save Trimbits</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="../include/icons.qrc"/> <include location="../include/icons.qrc"/>

View File

@ -20,105 +20,7 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="5"> <item row="2" column="0" colspan="4">
<widget class="QLabel" name="lblRxRoiEnabled">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>139</red>
<green>142</green>
<blue>142</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Rx Roi Enabled</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="0" colspan="7">
<widget class="QGroupBox" name="boxPlot">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="title">
<string>Sample Plot</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="plotLayout">
<property name="margin">
<number>9</number>
</property>
<property name="spacing">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="7">
<widget class="QWidget" name="widgetStatistics" native="true"> <widget class="QWidget" name="widgetStatistics" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -310,69 +212,37 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="1"> <item row="0" column="0" colspan="4">
<widget class="QLabel" name="lblCompleteImage"> <widget class="QGroupBox" name="boxPlot">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize"> <property name="font">
<size> <font>
<width>120</width> <family>Sans Serif</family>
<height>0</height> <pointsize>10</pointsize>
</size> </font>
</property> </property>
<property name="maximumSize"> <property name="title">
<size> <string>Sample Plot</string>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>150</green>
<blue>110</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>150</green>
<blue>110</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>139</red>
<green>142</green>
<blue>142</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Complete Image</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="plotLayout">
<property name="margin">
<number>9</number>
</property>
<property name="spacing">
<number>0</number>
</property>
</layout>
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="2">
@ -385,7 +255,7 @@
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>110</width> <width>40</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
@ -440,6 +310,71 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QLabel" name="lblCompleteImage">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>150</green>
<blue>110</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>150</green>
<blue>110</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>139</red>
<green>142</green>
<blue>142</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Complete Image</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>

View File

@ -32,29 +32,17 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="3"> <item row="0" column="0">
<widget class="QTabWidget" name="tabWidget"> <widget class="QLabel" name="lblReadout">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>5</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="currentIndex"> <property name="text">
<number>1</number> <string>Readout: </string>
</property> </property>
<widget class="QWidget" name="tabDAC">
<attribute name="title">
<string>DACs</string>
</attribute>
<layout class="QGridLayout" name="gridlayoutDac"/>
</widget>
<widget class="QWidget" name="tabADC">
<attribute name="title">
<string>ADCs</string>
</attribute>
<layout class="QGridLayout" name="gridlayoutAdc"/>
</widget>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
@ -89,17 +77,143 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="0"> <item row="1" column="0">
<widget class="QLabel" name="lblReadout"> <widget class="QLabel" name="lblComboHV">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred"> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="toolTip">
<string>Readout: </string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;High Voltage&lt;/p&gt;&lt;p&gt; #highvoltage#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text">
<string>High Voltage: </string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboHV">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;High Voltage&lt;/p&gt;&lt;p&gt; #highvoltage#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<item>
<property name="text">
<string>0</string>
</property>
</item>
<item>
<property name="text">
<string>90</string>
</property>
</item>
<item>
<property name="text">
<string>110</string>
</property>
</item>
<item>
<property name="text">
<string>120</string>
</property>
</item>
<item>
<property name="text">
<string>150</string>
</property>
</item>
<item>
<property name="text">
<string>180</string>
</property>
</item>
<item>
<property name="text">
<string>200</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lblSpinHV">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;High Voltage. Range: 60 - 200V. Swich off high voltage by setting to 0.&lt;/p&gt;&lt;p&gt;-1 corresponds to different values from detectors.&lt;/p&gt;&lt;p&gt;#highvoltage#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>High Voltage: </string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="spinHV">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;High Voltage. Range: 60 - 200V. Swich off high voltage by setting to 0.&lt;/p&gt;&lt;p&gt;-1 corresponds to different values from detectors.&lt;/p&gt;&lt;p&gt;#highvoltage#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>200</number>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>5</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tabDAC">
<attribute name="title">
<string>DACs</string>
</attribute>
<layout class="QGridLayout" name="gridlayoutDac"/>
</widget>
<widget class="QWidget" name="tabADC">
<attribute name="title">
<string>ADCs</string>
</attribute>
<layout class="QGridLayout" name="gridlayoutAdc"/>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>775</width> <width>775</width>
<height>400</height> <height>380</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -32,99 +32,26 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="2" colspan="5"> <item row="4" column="3">
<widget class="QComboBox" name="comboHV"> <widget class="QCheckBox" name="chkCounter2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;High Voltage&lt;/p&gt;&lt;p&gt; #highvoltage#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<item>
<property name="text">
<string>0</string>
</property>
</item>
<item>
<property name="text">
<string>90</string>
</property>
</item>
<item>
<property name="text">
<string>110</string>
</property>
</item>
<item>
<property name="text">
<string>120</string>
</property>
</item>
<item>
<property name="text">
<string>150</string>
</property>
</item>
<item>
<property name="text">
<string>180</string>
</property>
</item>
<item>
<property name="text">
<string>200</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblComboHV">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;High Voltage&lt;/p&gt;&lt;p&gt; #highvoltage#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>High Voltage: </string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lblThreshold">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>110</width> <width>50</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>Threshold:</string> <string>2</string>
</property>
<property name="checked">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="4"> <item row="4" column="4">
<widget class="QCheckBox" name="chkCounter3"> <widget class="QCheckBox" name="chkCounter3">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -143,23 +70,233 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="14"> <item row="3" column="2" colspan="3">
<spacer name="horizontalSpacer_2"> <widget class="QComboBox" name="comboDynamicRange">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>1.67772e+07</string>
</property>
</item>
<item>
<property name="text">
<string>65535</string>
</property>
</item>
<item>
<property name="text">
<string>255</string>
</property>
</item>
<item>
<property name="text">
<string>7</string>
</property>
</item>
</widget>
</item>
<item row="2" column="2" colspan="3">
<widget class="QSpinBox" name="spinThreshold">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string> eV</string>
</property>
<property name="minimum">
<number>-100000</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>-1</number>
</property>
</widget>
</item>
<item row="2" column="6">
<widget class="QSpinBox" name="spinThreshold3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string> eV</string>
</property>
<property name="minimum">
<number>-100000</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>-1</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lblDynamicRange">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Dynamic Range:</string>
</property>
</widget>
</item>
<item row="5" column="2">
<spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeType"> <property name="sizeType">
<enum>QSizePolicy::Expanding</enum> <enum>QSizePolicy::Fixed</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>20</width>
<height>20</height> <height>190</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="2" column="0"> <item row="2" column="8">
<widget class="QPushButton" name="btnSetThreshold">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>20</red>
<green>20</green>
<blue>20</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>20</red>
<green>20</green>
<blue>20</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>20</red>
<green>20</green>
<blue>20</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="text">
<string>Set</string>
</property>
<property name="icon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/rightArrow.png</normaloff>:/icons/images/rightArrow.png</iconset>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblSettings"> <widget class="QLabel" name="lblSettings">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
@ -181,7 +318,120 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="2"> <item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lblThreshold">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Threshold:</string>
</property>
</widget>
</item>
<item row="2" column="5">
<widget class="QSpinBox" name="spinThreshold2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string> eV</string>
</property>
<property name="minimum">
<number>-100000</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>-1</number>
</property>
</widget>
</item>
<item row="2" column="9">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lblCounter">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Counters:</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QCheckBox" name="chkCounter1"> <widget class="QCheckBox" name="chkCounter1">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -200,7 +450,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="2" colspan="9"> <item row="0" column="2" colspan="3">
<widget class="QComboBox" name="comboSettings"> <widget class="QComboBox" name="comboSettings">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
@ -214,7 +464,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>140</width> <width>140</width>
<height>28</height> <height>25</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -339,269 +589,7 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="4" column="11"> <item row="1" column="0">
<widget class="QSpinBox" name="spinThreshold2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string> eV</string>
</property>
<property name="minimum">
<number>-100000</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>-1</number>
</property>
</widget>
</item>
<item row="4" column="13">
<widget class="QPushButton" name="btnSetThreshold">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>20</red>
<green>20</green>
<blue>20</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>20</red>
<green>20</green>
<blue>20</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>20</red>
<green>20</green>
<blue>20</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="text">
<string>Set</string>
</property>
<property name="icon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/rightArrow.png</normaloff>:/icons/images/rightArrow.png</iconset>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="12">
<widget class="QSpinBox" name="spinThreshold3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string> eV</string>
</property>
<property name="minimum">
<number>-100000</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>-1</number>
</property>
</widget>
</item>
<item row="7" column="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>190</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="2" colspan="9">
<widget class="QSpinBox" name="spinThreshold">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string> eV</string>
</property>
<property name="minimum">
<number>-100000</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>-1</number>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="lblCounter">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Counters:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="lblDynamicRange">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Dynamic Range:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lblGainMode"> <widget class="QLabel" name="lblGainMode">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -623,70 +611,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="2" colspan="9"> <item row="1" column="2">
<widget class="QComboBox" name="comboDynamicRange">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>28</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>1.67772e+07</string>
</property>
</item>
<item>
<property name="text">
<string>65535</string>
</property>
</item>
<item>
<property name="text">
<string>4095</string>
</property>
</item>
<item>
<property name="text">
<string>255</string>
</property>
</item>
<item>
<property name="text">
<string>7</string>
</property>
</item>
</widget>
</item>
<item row="6" column="3">
<widget class="QCheckBox" name="chkCounter2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>2</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="2" colspan="9">
<widget class="QComboBox" name="comboGainMode"> <widget class="QComboBox" name="comboGainMode">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -700,7 +625,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>140</width> <width>140</width>
<height>28</height> <height>25</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -744,50 +669,6 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="lblSpinHV">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;High Voltage. Range: 60 - 200V. Swich off high voltage by setting to 0.&lt;/p&gt;&lt;p&gt;-1 corresponds to different values from detectors.&lt;/p&gt;&lt;p&gt;#highvoltage#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>High Voltage: </string>
</property>
</widget>
</item>
<item row="1" column="2" colspan="5">
<widget class="QSpinBox" name="spinHV">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;High Voltage. Range: 60 - 200V. Swich off high voltage by setting to 0.&lt;/p&gt;&lt;p&gt;-1 corresponds to different values from detectors.&lt;/p&gt;&lt;p&gt;#highvoltage#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>200</number>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>

View File

@ -5,8 +5,6 @@
#include <QMainWindow> #include <QMainWindow>
#include <QString> #include <QString>
namespace sls {
class SlsQtH1D; class SlsQtH1D;
class SlsQt1DPlot; class SlsQt1DPlot;
class SlsQt2DPlot; class SlsQt2DPlot;
@ -45,5 +43,3 @@ class qCloneWidget : public QMainWindow, private Ui::ClonePlotObject {
static int NumClones; static int NumClones;
}; };
} // namespace sls

View File

@ -6,13 +6,11 @@
#include "ui_form_dac.h" #include "ui_form_dac.h"
#include <string> #include <string>
namespace sls {
class qDacWidget : public QWidget, private Ui::WidgetDacObject { class qDacWidget : public QWidget, private Ui::WidgetDacObject {
Q_OBJECT Q_OBJECT
public: public:
qDacWidget(QWidget *parent, Detector *detector, bool d, std::string n, qDacWidget(QWidget *parent, sls::Detector *detector, bool d, std::string n,
slsDetectorDefs::dacIndex i); slsDetectorDefs::dacIndex i);
~qDacWidget(); ~qDacWidget();
void SetDetectorIndex(int id); void SetDetectorIndex(int id);
@ -27,10 +25,8 @@ class qDacWidget : public QWidget, private Ui::WidgetDacObject {
void GetAdc(); void GetAdc();
void Refresh(); void Refresh();
Detector *det; sls::Detector *det;
bool isDac{true}; bool isDac{true};
slsDetectorDefs::dacIndex index; slsDetectorDefs::dacIndex index;
int detectorIndex{-1}; int detectorIndex{-1};
}; };
} // namespace sls

View File

@ -14,8 +14,6 @@
#include <ostream> #include <ostream>
#include <string> #include <string>
namespace sls {
using std::chrono::duration; using std::chrono::duration;
using std::chrono::duration_cast; using std::chrono::duration_cast;
using std::chrono::hours; using std::chrono::hours;
@ -49,9 +47,9 @@ class qDefs : public QWidget {
static void DisplayExceptions(std::string emsg, std::string src) { static void DisplayExceptions(std::string emsg, std::string src) {
try { try {
throw; throw;
} catch (const SocketError &e) { } catch (const sls::SocketError &e) {
throw; throw;
} catch (const SharedMemoryError &e) { } catch (const sls::SharedMemoryError &e) {
throw; throw;
} catch (const std::exception &e) { } catch (const std::exception &e) {
ExceptionMessage(emsg, e.what(), src); ExceptionMessage(emsg, e.what(), src);
@ -65,9 +63,9 @@ class qDefs : public QWidget {
typename NonDeduced<CT>::type... Args) { typename NonDeduced<CT>::type... Args) {
try { try {
throw; throw;
} catch (const SocketError &e) { } catch (const sls::SocketError &e) {
throw; throw;
} catch (const SharedMemoryError &e) { } catch (const sls::SharedMemoryError &e) {
throw; throw;
} catch (const std::exception &e) { } catch (const std::exception &e) {
ExceptionMessage(emsg, e.what(), src); ExceptionMessage(emsg, e.what(), src);
@ -331,5 +329,3 @@ class qDefs : public QWidget {
source); source);
} }
}; };
} // namespace sls

View File

@ -6,11 +6,6 @@
#include "ui_form_detectormain.h" #include "ui_form_detectormain.h"
#include <QTabWidget> #include <QTabWidget>
class QScrollArea;
class QResizeEvent;
namespace sls {
class qDrawPlot; class qDrawPlot;
class qTabMeasurement; class qTabMeasurement;
class qTabDataOutput; class qTabDataOutput;
@ -20,6 +15,8 @@ class qTabSettings;
class qTabDebugging; class qTabDebugging;
class qTabDeveloper; class qTabDeveloper;
class qTabMessages; class qTabMessages;
class QScrollArea;
class QResizeEvent;
/** To Over-ride the QTabWidget class to get the tabBar protected /** To Over-ride the QTabWidget class to get the tabBar protected
* methodTabWidget */ * methodTabWidget */
@ -73,7 +70,7 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
NumberOfTabs NumberOfTabs
}; };
slsDetectorDefs::detectorType detType; slsDetectorDefs::detectorType detType;
std::unique_ptr<Detector> det; std::unique_ptr<sls::Detector> det;
qDrawPlot *plot; qDrawPlot *plot;
MyTabWidget *tabs; MyTabWidget *tabs;
QScrollArea *scroll[NumberOfTabs]; QScrollArea *scroll[NumberOfTabs];
@ -91,5 +88,3 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
QString zoomToolTip; QString zoomToolTip;
QColor defaultTabColor; QColor defaultTabColor;
}; };
} // namespace sls

View File

@ -6,21 +6,18 @@
#include "ui_form_plot.h" #include "ui_form_plot.h"
#include <mutex> #include <mutex>
class QResizeEvent;
namespace sls {
class SlsQt1DPlot; class SlsQt1DPlot;
class SlsQtH1D; class SlsQtH1D;
class SlsQt2DPlot; class SlsQt2DPlot;
class qCloneWidget; class qCloneWidget;
class detectorData; class detectorData;
class QResizeEvent;
class qDrawPlot : public QWidget, private Ui::PlotObject { class qDrawPlot : public QWidget, private Ui::PlotObject {
Q_OBJECT Q_OBJECT
public: public:
qDrawPlot(QWidget *parent, Detector *detector); qDrawPlot(QWidget *parent, sls::Detector *detector);
~qDrawPlot(); ~qDrawPlot();
bool GetIsRunning(); bool GetIsRunning();
void SetRunning(bool enable); void SetRunning(bool enable);
@ -58,7 +55,6 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
void EnableGainPlot(bool enable); void EnableGainPlot(bool enable);
void ClonePlot(); void ClonePlot();
void SavePlot(); void SavePlot();
void SetGapPixels(bool enable);
protected: protected:
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
@ -95,11 +91,9 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
void Update2dPlot(); void Update2dPlot();
void Update1dXYRange(); void Update1dXYRange();
void Update2dXYRange(); void Update2dXYRange();
void rearrangeGotthard25data(double *data);
static const int NUM_PEDESTAL_FRAMES = 20; static const int NUM_PEDESTAL_FRAMES = 20;
static const int NUM_GOTTHARD25_CHANS = 1280; sls::Detector *det;
Detector *det;
slsDetectorDefs::detectorType detType; slsDetectorDefs::detectorType detType;
SlsQt1DPlot *plot1d{nullptr}; SlsQt1DPlot *plot1d{nullptr};
@ -164,16 +158,10 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
int64_t currentFrame{0}; int64_t currentFrame{0};
mutable std::mutex mPlots; mutable std::mutex mPlots;
int64_t currentAcqIndex{0}; int64_t currentAcqIndex{0};
slsDetectorDefs::ROI rxRoi{};
bool isRxRoiDisplayed{false};
bool isGapPixels{false};
unsigned int nPixelsX{0}; unsigned int nPixelsX{0};
unsigned int nPixelsY{0}; unsigned int nPixelsY{0};
uint32_t pixelMask{0}; uint32_t pixelMask{0};
uint32_t gainMask{0}; uint32_t gainMask{0};
int gainOffset{0}; int gainOffset{0};
bool gotthard25;
}; };
} // namespace sls

View File

@ -4,15 +4,13 @@
#include "sls/Detector.h" #include "sls/Detector.h"
#include "ui_form_tab_advanced.h" #include "ui_form_tab_advanced.h"
namespace sls {
class qDrawPlot; class qDrawPlot;
class qTabAdvanced : public QWidget, private Ui::TabAdvancedObject { class qTabAdvanced : public QWidget, private Ui::TabAdvancedObject {
Q_OBJECT Q_OBJECT
public: public:
qTabAdvanced(QWidget *parent, Detector *detector, qDrawPlot *p); qTabAdvanced(QWidget *parent, sls::Detector *detector, qDrawPlot *p);
~qTabAdvanced(); ~qTabAdvanced();
public slots: public slots:
@ -76,8 +74,6 @@ class qTabAdvanced : public QWidget, private Ui::TabAdvancedObject {
void GetExposureTime(); void GetExposureTime();
void GetGateDelay(); void GetGateDelay();
Detector *det; sls::Detector *det;
qDrawPlot *plot; qDrawPlot *plot;
}; };
} // namespace sls

View File

@ -4,13 +4,11 @@
#include "sls/Detector.h" #include "sls/Detector.h"
#include "ui_form_tab_dataoutput.h" #include "ui_form_tab_dataoutput.h"
namespace sls {
class qTabDataOutput : public QWidget, private Ui::TabDataOutputObject { class qTabDataOutput : public QWidget, private Ui::TabDataOutputObject {
Q_OBJECT Q_OBJECT
public: public:
qTabDataOutput(QWidget *parent, Detector *detector); qTabDataOutput(QWidget *parent, sls::Detector *detector);
~qTabDataOutput(); ~qTabDataOutput();
void Refresh(); void Refresh();
@ -41,9 +39,7 @@ class qTabDataOutput : public QWidget, private Ui::TabDataOutputObject {
void GetSpeed(); void GetSpeed();
void GetParallel(); void GetParallel();
Detector *det; sls::Detector *det;
// Button group for radiobuttons for rate // Button group for radiobuttons for rate
QButtonGroup *btnGroupRate; QButtonGroup *btnGroupRate;
}; };
} // namespace sls

View File

@ -7,13 +7,11 @@
class QTreeWidget; class QTreeWidget;
class QTreeWidgetItem; class QTreeWidgetItem;
namespace sls {
class qTabDebugging : public QWidget, private Ui::TabDebuggingObject { class qTabDebugging : public QWidget, private Ui::TabDebuggingObject {
Q_OBJECT Q_OBJECT
public: public:
qTabDebugging(QWidget *parent, Detector *detector); qTabDebugging(QWidget *parent, sls::Detector *detector);
~qTabDebugging(); ~qTabDebugging();
void Refresh(); void Refresh();
@ -28,12 +26,10 @@ class qTabDebugging : public QWidget, private Ui::TabDebuggingObject {
void Initialization(); void Initialization();
void PopulateDetectors(); void PopulateDetectors();
Detector *det; sls::Detector *det;
/** Tree Widget displaying the detectors, modules */ /** Tree Widget displaying the detectors, modules */
QTreeWidget *treeDet; QTreeWidget *treeDet;
QLabel *lblDetectorHostname; QLabel *lblDetectorHostname;
QLabel *lblDetectorFirmware; QLabel *lblDetectorFirmware;
QLabel *lblDetectorSoftware; QLabel *lblDetectorSoftware;
}; };
} // namespace sls

View File

@ -6,30 +6,35 @@
#include "ui_form_tab_developer.h" #include "ui_form_tab_developer.h"
#include <vector> #include <vector>
namespace sls {
class qDacWidget; class qDacWidget;
class qTabDeveloper : public QWidget, private Ui::TabDeveloperObject { class qTabDeveloper : public QWidget, private Ui::TabDeveloperObject {
Q_OBJECT Q_OBJECT
public: public:
qTabDeveloper(QWidget *parent, Detector *detector); qTabDeveloper(QWidget *parent, sls::Detector *detector);
~qTabDeveloper(); ~qTabDeveloper();
public slots: public slots:
void Refresh(); void Refresh();
private slots:
void SetHighVoltage();
private: private:
void SetupWidgetWindow(); void SetupWidgetWindow();
void Initialization(); void Initialization();
void PopulateDetectors(); void PopulateDetectors();
void GetHighVoltage();
slsDetectorDefs::dacIndex getSLSIndex(slsDetectorDefs::detectorType detType, slsDetectorDefs::dacIndex getSLSIndex(slsDetectorDefs::detectorType detType,
int index); int index);
Detector *det; sls::Detector *det;
std::vector<qDacWidget *> dacWidgets; std::vector<qDacWidget *> dacWidgets;
std::vector<qDacWidget *> adcWidgets; std::vector<qDacWidget *> adcWidgets;
};
} // namespace sls enum hvVals { HV_0, HV_90, HV_110, HV_120, HV_150, HV_180, HV_200 };
int hvmin;
static const int HV_MIN = 60;
static const int HV_MAX = 200;
};

View File

@ -4,17 +4,14 @@
#include "sls/Detector.h" #include "sls/Detector.h"
#include "ui_form_tab_measurement.h" #include "ui_form_tab_measurement.h"
class QStandardItemModel;
namespace sls {
class qDrawPlot; class qDrawPlot;
class QStandardItemModel;
class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject { class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
Q_OBJECT Q_OBJECT
public: public:
qTabMeasurement(QWidget *parent, Detector *detector, qDrawPlot *p); qTabMeasurement(QWidget *parent, sls::Detector *detector, qDrawPlot *p);
~qTabMeasurement(); ~qTabMeasurement();
void Refresh(); void Refresh();
@ -84,7 +81,7 @@ class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
void FileNameChangedSignal(QString); void FileNameChangedSignal(QString);
private: private:
Detector *det; sls::Detector *det;
qDrawPlot *plot; qDrawPlot *plot;
// enum for the timing mode // enum for the timing mode
enum { AUTO, TRIGGER, GATED, BURST_TRIGGER, TRIGGER_GATED, NUMTIMINGMODES }; enum { AUTO, TRIGGER, GATED, BURST_TRIGGER, TRIGGER_GATED, NUMTIMINGMODES };
@ -101,5 +98,3 @@ class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
int numMeasurements{1}; int numMeasurements{1};
int currentMeasurement{0}; int currentMeasurement{0};
}; };
} // namespace sls

View File

@ -6,8 +6,6 @@
class QProcess; class QProcess;
class QKeyEvent; class QKeyEvent;
namespace sls {
class qTabMessages : public QWidget, private Ui::TabMessagesObject { class qTabMessages : public QWidget, private Ui::TabMessagesObject {
Q_OBJECT Q_OBJECT
@ -36,5 +34,3 @@ class qTabMessages : public QWidget, private Ui::TabMessagesObject {
QProcess *process; QProcess *process;
QStringList lastCommand; QStringList lastCommand;
}; };
} // namespace sls

View File

@ -4,15 +4,13 @@
#include "sls/Detector.h" #include "sls/Detector.h"
#include "ui_form_tab_plot.h" #include "ui_form_tab_plot.h"
namespace sls {
class qDrawPlot; class qDrawPlot;
class qTabPlot : public QWidget, private Ui::TabPlotObject { class qTabPlot : public QWidget, private Ui::TabPlotObject {
Q_OBJECT Q_OBJECT
public: public:
qTabPlot(QWidget *parent, Detector *detector, qDrawPlot *p); qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p);
~qTabPlot(); ~qTabPlot();
void SetScanArgument(); void SetScanArgument();
void Refresh(); void Refresh();
@ -55,7 +53,7 @@ class qTabPlot : public QWidget, private Ui::TabPlotObject {
void SetXYRange(); void SetXYRange();
void MaintainAspectRatio(int dimension); void MaintainAspectRatio(int dimension);
Detector *det; sls::Detector *det;
qDrawPlot *plot; qDrawPlot *plot;
bool is1d; bool is1d;
@ -67,5 +65,3 @@ class qTabPlot : public QWidget, private Ui::TabPlotObject {
static QString defaultImageYAxisTitle; static QString defaultImageYAxisTitle;
static QString defaultImageZAxisTitle; static QString defaultImageZAxisTitle;
}; };
} // namespace sls

View File

@ -5,20 +5,17 @@
#include "ui_form_tab_settings.h" #include "ui_form_tab_settings.h"
#include <QCheckBox> #include <QCheckBox>
namespace sls {
class qTabSettings : public QWidget, private Ui::TabSettingsObject { class qTabSettings : public QWidget, private Ui::TabSettingsObject {
Q_OBJECT Q_OBJECT
public: public:
qTabSettings(QWidget *parent, Detector *detector); qTabSettings(QWidget *parent, sls::Detector *detector);
~qTabSettings(); ~qTabSettings();
void Refresh(); void Refresh();
public slots: public slots:
void SetExportMode(bool exportMode); void SetExportMode(bool exportMode);
private slots: private slots:
void SetHighVoltage();
void SetSettings(int index); void SetSettings(int index);
void SetGainMode(int index); void SetGainMode(int index);
void SetDynamicRange(int index); void SetDynamicRange(int index);
@ -33,7 +30,6 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
void ShowFixG0(bool expertMode); void ShowFixG0(bool expertMode);
void Initialization(); void Initialization();
void GetHighVoltage();
void GetSettings(); void GetSettings();
void GetGainMode(); void GetGainMode();
void GetDynamicRange(); void GetDynamicRange();
@ -41,15 +37,9 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
void GetThresholdEnergies(); void GetThresholdEnergies();
void GetCounterMask(); void GetCounterMask();
Detector *det; sls::Detector *det;
std::vector<QCheckBox *> counters; std::vector<QCheckBox *> counters;
enum hvVals { HV_0, HV_90, HV_110, HV_120, HV_150, HV_180, HV_200 };
int hvmin;
static const int HV_MIN = 60;
static const int HV_MAX = 200;
enum { enum {
STANDARD, STANDARD,
FAST, FAST,
@ -79,13 +69,5 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
enum { DYNAMIC, FORCE_SWITCH_G1, FORCE_SWITCH_G2, FIX_G1, FIX_G2, FIX_G0 }; enum { DYNAMIC, FORCE_SWITCH_G1, FORCE_SWITCH_G2, FIX_G1, FIX_G2, FIX_G0 };
bool isVisibleFixG0{false}; bool isVisibleFixG0{false};
enum { enum { DYNAMICRANGE_32, DYNAMICRANGE_16, DYNAMICRANGE_8, DYNAMICRANGE_4 };
DYNAMICRANGE_32,
DYNAMICRANGE_16,
DYNAMICRANGE_12,
DYNAMICRANGE_8,
DYNAMICRANGE_4
};
}; };
} // namespace sls

View File

@ -9,14 +9,10 @@
#include <qwt_plot_curve.h> #include <qwt_plot_curve.h>
#include <qwt_plot_marker.h> #include <qwt_plot_marker.h>
#include <qwt_scale_div.h> #include <qwt_scale_div.h>
#include <qwt_plot_shapeitem.h>
class QPen; class QPen;
class QwtSymbol;
namespace sls {
class SlsQt1DPlot; class SlsQt1DPlot;
class QwtSymbol;
class SlsQtH1D : public QwtPlotCurve { class SlsQtH1D : public QwtPlotCurve {
@ -140,9 +136,6 @@ class SlsQt1DPlot : public QwtPlot {
void SetLogX(bool yes = 1); void SetLogX(bool yes = 1);
void SetLogY(bool yes = 1); void SetLogY(bool yes = 1);
void EnableRoiBox(std::array<int, 4> roi);
void DisableRoiBox();
private: private:
SlsQtH1DList *hist_list{nullptr}; SlsQtH1DList *hist_list{nullptr};
SlsQt1DZoomer *zoomer{nullptr}; SlsQt1DZoomer *zoomer{nullptr};
@ -166,15 +159,9 @@ class SlsQt1DPlot : public QwtPlot {
friend void SlsQtH1D::Attach(SlsQt1DPlot *p); friend void SlsQtH1D::Attach(SlsQt1DPlot *p);
friend void SlsQtH1D::Detach(SlsQt1DPlot *p); friend void SlsQtH1D::Detach(SlsQt1DPlot *p);
QwtPlotShapeItem *roiBox{nullptr};
public slots: public slots:
void UnZoom(); void UnZoom();
void Update(); void Update();
}; };
} // namespace sls
#endif #endif

View File

@ -8,8 +8,6 @@
#include <qwt_plot_panner.h> #include <qwt_plot_panner.h>
#include <qwt_plot_zoomer.h> #include <qwt_plot_zoomer.h>
namespace sls {
class SlsQtH1D; class SlsQtH1D;
class SlsQt1DZoomer : public QwtPlotZoomer { class SlsQt1DZoomer : public QwtPlotZoomer {
@ -53,6 +51,4 @@ class SlsQt1DZoomer : public QwtPlotZoomer {
} }
}; };
} // namespace sls
#endif #endif

View File

@ -9,8 +9,6 @@
#include <qwt_scale_draw.h> #include <qwt_scale_draw.h>
#include <qwt_scale_widget.h> #include <qwt_scale_widget.h>
namespace sls {
class SlsQt2DHist : public QwtRasterData { class SlsQt2DHist : public QwtRasterData {
private: private:
@ -127,6 +125,4 @@ class SlsQt2DHist : public QwtRasterData {
} }
}; };
} // namespace sls
#endif #endif

View File

@ -6,14 +6,11 @@
#include <qlist.h> #include <qlist.h>
#include <qwt_plot.h> #include <qwt_plot.h>
#include <qwt_plot_spectrogram.h> #include <qwt_plot_spectrogram.h>
#include <qwt_plot_shapeitem.h>
class QwtPlotPanner; class QwtPlotPanner;
class QwtScaleWidget; class QwtScaleWidget;
class QwtLinearColorMap; class QwtLinearColorMap;
namespace sls {
class SlsQt2DPlot : public QwtPlot { class SlsQt2DPlot : public QwtPlot {
Q_OBJECT Q_OBJECT
@ -70,8 +67,6 @@ class SlsQt2DPlot : public QwtPlot {
void SetLogz(bool enable, bool isMin, bool isMax, double min, double max); void SetLogz(bool enable, bool isMin, bool isMax, double min, double max);
void SetZRange(bool isMin, bool isMax, double min, double max); void SetZRange(bool isMin, bool isMax, double min, double max);
void LogZ(bool on = 1); void LogZ(bool on = 1);
void EnableRoiBox(std::array<int, 4> roi);
void DisableRoiBox();
public slots: public slots:
void showSpectrogram(bool on); void showSpectrogram(bool on);
@ -91,7 +86,4 @@ class SlsQt2DPlot : public QwtPlot {
QList<double> contourLevelsLog; QList<double> contourLevelsLog;
bool disableZoom{false}; bool disableZoom{false};
int isLog; int isLog;
QwtPlotShapeItem *roiBox{nullptr};
}; };
} // namespace sls

View File

@ -7,8 +7,6 @@
#include <qwt_plot_panner.h> #include <qwt_plot_panner.h>
#include <qwt_plot_zoomer.h> #include <qwt_plot_zoomer.h>
namespace sls {
class SlsQt2DZoomer : public QwtPlotZoomer { class SlsQt2DZoomer : public QwtPlotZoomer {
private: private:
SlsQt2DHist *hist; SlsQt2DHist *hist;
@ -42,6 +40,4 @@ class SlsQt2DZoomer : public QwtPlotZoomer {
} }
}; };
} // namespace sls
#endif #endif

View File

@ -15,8 +15,6 @@
#include <qwt_symbol.h> #include <qwt_symbol.h>
#include <stdlib.h> #include <stdlib.h>
namespace sls {
#define QwtLog10ScaleEngine QwtLogScaleEngine // hmm #define QwtLog10ScaleEngine QwtLogScaleEngine // hmm
SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data) SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data)
@ -444,28 +442,6 @@ void SlsQt1DPlot::SetLog(int axisId, bool yes) {
Update(); Update();
} }
void SlsQt1DPlot::EnableRoiBox(std::array<int, 4> roi) {
if (roiBox == nullptr) {
roiBox = new QwtPlotShapeItem();
roiBox->attach(this);
roiBox->setPen(QColor(Qt::yellow), 2.0, Qt::SolidLine);
}
// TopLeft - BottomRight (max points are +1 on graph)
QRect myRect(QPoint(roi[0], roi[2]), QPoint(roi[1] - 1, roi[3] - 1));
roiBox->setRect( QRectF(myRect) );
replot();
}
void SlsQt1DPlot::DisableRoiBox() {
if (roiBox != nullptr) {
roiBox->detach();
replot();
}
}
void SlsQt1DPlot::UnZoom() { void SlsQt1DPlot::UnZoom() {
setAxisScale(QwtPlot::xBottom, zoomer->x(), zoomer->x() + zoomer->w()); setAxisScale(QwtPlot::xBottom, zoomer->x(), zoomer->x() + zoomer->w());
setAxisScale(QwtPlot::yLeft, zoomer->y(), zoomer->y() + zoomer->h()); setAxisScale(QwtPlot::yLeft, zoomer->y(), zoomer->y() + zoomer->h());
@ -604,5 +580,3 @@ void SlsQt1DPlot::DisableZoom(bool disable) {
} }
} }
} }
} // namespace sls

View File

@ -7,8 +7,6 @@
#include <qwt_plot.h> #include <qwt_plot.h>
#include <qwt_scale_div.h> #include <qwt_scale_div.h>
namespace sls {
void SlsQt1DZoomer::ResetZoomBase() { void SlsQt1DZoomer::ResetZoomBase() {
SetZoomBase(x0, y0, x1 - x0, SetZoomBase(x0, y0, x1 - x0,
y1 - y0); // for going between log and nonlog plots y1 - y0); // for going between log and nonlog plots
@ -95,5 +93,3 @@ void SlsQt1DZoomer::ExtendZoomBase(SlsQtH1D *h) {
ResetZoomBase(); ResetZoomBase();
} }
} // namespace sls

View File

@ -9,8 +9,6 @@
using std::cout; using std::cout;
using std::endl; using std::endl;
namespace sls {
SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy, SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy,
double ymin, double ymax, double *d, double zmin, double ymin, double ymax, double *d, double zmin,
double zmax) double zmax)
@ -145,5 +143,3 @@ double SlsQt2DHist::SetMinimumToFirstGreaterThanZero() {
return z_min; return z_min;
} }
} // namespace sls

View File

@ -18,8 +18,6 @@
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>
namespace sls {
SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) { SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
isLog = 0; isLog = 0;
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating); axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating);
@ -291,27 +289,4 @@ void SlsQt2DPlot::showSpectrogram(bool on) {
d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, on); d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, on);
d_spectrogram->setDefaultContourPen(on ? QPen() : QPen(Qt::NoPen)); d_spectrogram->setDefaultContourPen(on ? QPen() : QPen(Qt::NoPen));
Update(); Update();
} }
void SlsQt2DPlot::EnableRoiBox(std::array<int, 4> roi) {
if (roiBox == nullptr) {
roiBox = new QwtPlotShapeItem();
}
roiBox->setPen(QColor(Qt::yellow), 2.0, Qt::SolidLine);
// TopLeft - BottomRight (max points are +1 on graph)
QRect myRect(QPoint(roi[0], roi[2]), QPoint(roi[1] - 1, roi[3] - 1));
roiBox->setRect( QRectF(myRect) );
roiBox->attach(this);
replot();
}
void SlsQt2DPlot::DisableRoiBox() {
if (roiBox != nullptr) {
roiBox->detach();
replot();
}
}
} // namespace sls

View File

@ -11,8 +11,6 @@
#include <QPainter> #include <QPainter>
#include <qwt_text.h> #include <qwt_text.h>
namespace sls {
int qCloneWidget::NumClones{0}; int qCloneWidget::NumClones{0};
qCloneWidget::qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2, qCloneWidget::qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2,
@ -46,7 +44,7 @@ qCloneWidget::~qCloneWidget() {
void qCloneWidget::SetupWidgetWindow(QString title) { void qCloneWidget::SetupWidgetWindow(QString title) {
std::string winTitle = std::string("Snapshot:") + std::to_string(id) + std::string winTitle = std::string("Snapshot:") + std::to_string(id) +
std::string(" - ") + Logger::Timestamp(); std::string(" - ") + sls::Logger::Timestamp();
setWindowTitle(QString(winTitle.c_str())); setWindowTitle(QString(winTitle.c_str()));
boxPlot->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); boxPlot->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
@ -148,6 +146,4 @@ void qCloneWidget::resizeEvent(QResizeEvent *event) {
qDefs::DATA_GAIN_PLOT_RATIO); qDefs::DATA_GAIN_PLOT_RATIO);
} }
event->accept(); event->accept();
} }
} // namespace sls

View File

@ -3,9 +3,7 @@
#include "qDacWidget.h" #include "qDacWidget.h"
#include "qDefs.h" #include "qDefs.h"
namespace sls { qDacWidget::qDacWidget(QWidget *parent, sls::Detector *detector, bool d,
qDacWidget::qDacWidget(QWidget *parent, Detector *detector, bool d,
std::string n, slsDetectorDefs::dacIndex i) std::string n, slsDetectorDefs::dacIndex i)
: QWidget(parent), det(detector), isDac(d), index(i) { : QWidget(parent), det(detector), isDac(d), index(i) {
setupUi(this); setupUi(this);
@ -96,5 +94,3 @@ void qDacWidget::Refresh() {
GetAdc(); GetAdc();
} }
} }
} // namespace sls

View File

@ -59,7 +59,7 @@ int main(int argc, char **argv) {
case 'f': case 'f':
fname = optarg; fname = optarg;
LOG(sls::logDEBUG) << long_options[option_index].name << " " << optarg; LOG(logDEBUG) << long_options[option_index].name << " " << optarg;
break; break;
case 'd': case 'd':
@ -72,7 +72,7 @@ int main(int argc, char **argv) {
case 'v': case 'v':
tempval = APIGUI; tempval = APIGUI;
LOG(sls::logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x" LOG(logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x"
<< std::hex << tempval << ")"; << std::hex << tempval << ")";
return 0; return 0;
@ -88,7 +88,7 @@ int main(int argc, char **argv) {
"i. Default: 0. Required \n" + "i. Default: 0. Required \n" +
"\t only when more than one multi " "\t only when more than one multi "
"detector object is needed.\n\n"; "detector object is needed.\n\n";
LOG(sls::logERROR) << help_message; LOG(logERROR) << help_message;
return -1; return -1;
} }
} }
@ -96,18 +96,16 @@ int main(int argc, char **argv) {
QApplication app(argc, argv); QApplication app(argc, argv);
app.setStyle(new QPlastiqueStyle); // style is deleted by QApplication app.setStyle(new QPlastiqueStyle); // style is deleted by QApplication
try { try {
sls::qDetectorMain det(multiId, fname, isDeveloper); qDetectorMain det(multiId, fname, isDeveloper);
det.show(); det.show();
app.exec(); app.exec();
} catch (const std::exception &e) { } catch (const std::exception &e) {
sls::qDefs::Message(sls::qDefs::CRITICAL, qDefs::Message(qDefs::CRITICAL,
std::string(e.what()) + "\nExiting Gui :'( ", "main"); std::string(e.what()) + "\nExiting Gui :'( ", "main");
} }
return 0; return 0;
} }
namespace sls {
qDetectorMain::qDetectorMain(int multiId, const std::string &fname, qDetectorMain::qDetectorMain(int multiId, const std::string &fname,
bool isDevel) bool isDevel)
: QMainWindow(nullptr), detType(slsDetectorDefs::GENERIC), : QMainWindow(nullptr), detType(slsDetectorDefs::GENERIC),
@ -197,7 +195,6 @@ void qDetectorMain::SetUpWidgetWindow() {
tabs->setTabEnabled(ADVANCED, false); tabs->setTabEnabled(ADVANCED, false);
tabs->setTabEnabled(DEVELOPER, isDeveloper); tabs->setTabEnabled(DEVELOPER, isDeveloper);
actionLoadTrimbits->setVisible(false); actionLoadTrimbits->setVisible(false);
actionSaveTrimbits->setVisible(false);
dockWidgetPlot->setFloating(false); dockWidgetPlot->setFloating(false);
dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures); dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures);
@ -215,7 +212,7 @@ void qDetectorMain::SetUpWidgetWindow() {
void qDetectorMain::SetUpDetector(const std::string &config_file, int multiID) { void qDetectorMain::SetUpDetector(const std::string &config_file, int multiID) {
// instantiate detector and set window title // instantiate detector and set window title
det = make_unique<Detector>(multiID); det = sls::make_unique<sls::Detector>(multiID);
// create messages tab to capture config file loading logs // create messages tab to capture config file loading logs
tabMessages = new qTabMessages(this); tabMessages = new qTabMessages(this);
@ -228,12 +225,10 @@ void qDetectorMain::SetUpDetector(const std::string &config_file, int multiID) {
detType = det->getDetectorType().tsquash( detType = det->getDetectorType().tsquash(
"Different detector type for all modules."); "Different detector type for all modules.");
actionLoadTrimbits->setEnabled(false); actionLoadTrimbits->setEnabled(false);
actionSaveTrimbits->setEnabled(false);
switch (detType) { switch (detType) {
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
case slsDetectorDefs::MYTHEN3: case slsDetectorDefs::MYTHEN3:
actionLoadTrimbits->setEnabled(true); actionLoadTrimbits->setEnabled(true);
actionSaveTrimbits->setEnabled(true);
break; break;
case slsDetectorDefs::GOTTHARD: case slsDetectorDefs::GOTTHARD:
case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::JUNGFRAU:
@ -243,15 +238,15 @@ void qDetectorMain::SetUpDetector(const std::string &config_file, int multiID) {
default: default:
std::ostringstream os; std::ostringstream os;
os << det->getHostname() << " has " os << det->getHostname() << " has "
<< ToString(det->getDetectorType().squash()) << sls::ToString(det->getDetectorType().squash())
<< " detector type (" << std::to_string(detType) << " detector type (" << std::to_string(detType)
<< "). Exiting GUI."; << "). Exiting GUI.";
std::string errorMess = os.str(); std::string errorMess = os.str();
throw RuntimeError(errorMess.c_str()); throw sls::RuntimeError(errorMess.c_str());
} }
std::ostringstream os; std::ostringstream os;
os << "SLS Detector GUI : " os << "SLS Detector GUI : "
<< ToString(det->getDetectorType().squash()) << " - " << sls::ToString(det->getDetectorType().squash()) << " - "
<< det->getHostname(); << det->getHostname();
std::string title = os.str(); std::string title = os.str();
LOG(logINFO) << title; LOG(logINFO) << title;
@ -344,9 +339,9 @@ void qDetectorMain::EnableModes(QAction *action) {
enable = actionExpert->isChecked(); enable = actionExpert->isChecked();
tabs->setTabEnabled(ADVANCED, enable); tabs->setTabEnabled(ADVANCED, enable);
bool visible = enable && (detType == slsDetectorDefs::EIGER || detType == slsDetectorDefs::MYTHEN3); actionLoadTrimbits->setVisible(enable &&
actionLoadTrimbits->setVisible(visible); (detType == slsDetectorDefs::EIGER ||
actionSaveTrimbits->setVisible(visible); detType == slsDetectorDefs::MYTHEN3));
tabSettings->SetExportMode(enable); tabSettings->SetExportMode(enable);
LOG(logINFO) << "Expert Mode: " << qDefs::stringEnable(enable); LOG(logINFO) << "Expert Mode: " << qDefs::stringEnable(enable);
} }
@ -422,22 +417,6 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
LOG(logINFO) << "Trimbits loaded successfully"; LOG(logINFO) << "Trimbits loaded successfully";
} }
} }
else if (action == actionSaveTrimbits) {
QString fPath =
QString((det->getSettingsPath().squash("/tmp/")).c_str());
LOG(logDEBUG) << "Saving Trimbits";
QString fName = QFileDialog::getSaveFileName(
this, tr("Save Detector Trimbits"), fPath,
tr("Trimbit files (*.trim noise.sn*);;All Files(*)"));
if (!fName.isEmpty()) {
det->saveTrimbits(std::string(fName.toAscii().constData()));
qDefs::Message(qDefs::INFORMATION,
"The Trimbits have been saved successfully.",
"qDetectorMain::ExecuteUtilities");
LOG(logINFO) << "Trimbits saved successfully";
}
}
} }
CATCH_DISPLAY("Could not execute utilities.", CATCH_DISPLAY("Could not execute utilities.",
"qDetectorMain::ExecuteUtilities") "qDetectorMain::ExecuteUtilities")
@ -462,10 +441,10 @@ void qDetectorMain::ExecuteHelp(QAction *action) {
LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, " LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, "
"Gotthard, Gotthard2 and Moench detectors"; "Gotthard, Gotthard2 and Moench detectors";
std::string guiVersion = ToStringHex(APIGUI); std::string guiVersion = sls::ToStringHex(APIGUI);
std::string clientVersion = "unknown"; std::string clientVersion = "unknown";
try { try {
clientVersion = ToStringHex(det->getClientVersion()); clientVersion = sls::ToStringHex(det->getClientVersion());
} }
CATCH_DISPLAY("Could not get client version.", CATCH_DISPLAY("Could not get client version.",
"qDetectorMain::ExecuteHelp") "qDetectorMain::ExecuteHelp")
@ -598,8 +577,6 @@ void qDetectorMain::EnableTabs(bool enable) {
tabs->setTabEnabled(ADVANCED, expertTab); tabs->setTabEnabled(ADVANCED, expertTab);
actionLoadTrimbits->setVisible(expertTab && actionLoadTrimbits->setVisible(expertTab &&
detType == slsDetectorDefs::EIGER); detType == slsDetectorDefs::EIGER);
actionSaveTrimbits->setVisible(expertTab &&
detType == slsDetectorDefs::EIGER);
// moved to here, so that its all in order, instead of signals and different // moved to here, so that its all in order, instead of signals and different
// threads // threads
@ -632,5 +609,3 @@ void qDetectorMain::SetZoomToolTip(bool disable) {
else else
dockWidgetPlot->setToolTip(zoomToolTip); dockWidgetPlot->setToolTip(zoomToolTip);
} }
} // namespace sls

View File

@ -14,9 +14,7 @@
#include <QResizeEvent> #include <QResizeEvent>
#include <QtConcurrentRun> #include <QtConcurrentRun>
namespace sls { qDrawPlot::qDrawPlot(QWidget *parent, sls::Detector *detector)
qDrawPlot::qDrawPlot(QWidget *parent, Detector *detector)
: QWidget(parent), det(detector) { : QWidget(parent), det(detector) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
@ -82,10 +80,6 @@ void qDrawPlot::SetupWidgetWindow() {
fileSaveName = "Image"; fileSaveName = "Image";
} }
gotthard25 = ((detType == slsDetectorDefs::GOTTHARD2 ||
detType == slsDetectorDefs::GOTTHARD) &&
det->size() == 2);
SetupPlots(); SetupPlots();
SetDataCallBack(true); SetDataCallBack(true);
det->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack), det->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack),
@ -280,13 +274,11 @@ void qDrawPlot::Select1dPlot(bool enable) {
} }
void qDrawPlot::SetPlotTitlePrefix(QString title) { void qDrawPlot::SetPlotTitlePrefix(QString title) {
std::lock_guard<std::mutex> lock(mPlots);
LOG(logINFO) << "Setting Title to " << title.toAscii().constData(); LOG(logINFO) << "Setting Title to " << title.toAscii().constData();
plotTitlePrefix = title; plotTitlePrefix = title;
} }
void qDrawPlot::SetXAxisTitle(QString title) { void qDrawPlot::SetXAxisTitle(QString title) {
std::lock_guard<std::mutex> lock(mPlots);
LOG(logINFO) << "Setting X Axis Title to " << title.toAscii().constData(); LOG(logINFO) << "Setting X Axis Title to " << title.toAscii().constData();
if (is1d) { if (is1d) {
xTitle1d = title; xTitle1d = title;
@ -296,7 +288,6 @@ void qDrawPlot::SetXAxisTitle(QString title) {
} }
void qDrawPlot::SetYAxisTitle(QString title) { void qDrawPlot::SetYAxisTitle(QString title) {
std::lock_guard<std::mutex> lock(mPlots);
LOG(logINFO) << "Setting Y Axis Title to " << title.toAscii().constData(); LOG(logINFO) << "Setting Y Axis Title to " << title.toAscii().constData();
if (is1d) { if (is1d) {
yTitle1d = title; yTitle1d = title;
@ -306,7 +297,6 @@ void qDrawPlot::SetYAxisTitle(QString title) {
} }
void qDrawPlot::SetZAxisTitle(QString title) { void qDrawPlot::SetZAxisTitle(QString title) {
std::lock_guard<std::mutex> lock(mPlots);
LOG(logINFO) << "Setting Z Axis Title to " << title.toAscii().constData(); LOG(logINFO) << "Setting Z Axis Title to " << title.toAscii().constData();
zTitle2d = title; zTitle2d = title;
} }
@ -324,7 +314,6 @@ void qDrawPlot::SetXYRangeChanged(bool disable, double *xy, bool *isXY) {
} }
void qDrawPlot::SetZRange(double *z, bool *isZ) { void qDrawPlot::SetZRange(double *z, bool *isZ) {
std::lock_guard<std::mutex> lock(mPlots);
std::copy(z, z + 2, zRange); std::copy(z, z + 2, zRange);
std::copy(isZ, isZ + 2, isZRange); std::copy(isZ, isZ + 2, isZRange);
} }
@ -358,7 +347,6 @@ double qDrawPlot::GetYMaximum() {
} }
void qDrawPlot::SetDataCallBack(bool enable) { void qDrawPlot::SetDataCallBack(bool enable) {
std::lock_guard<std::mutex> lock(mPlots);
LOG(logINFO) << "Setting data call back to " << std::boolalpha << enable LOG(logINFO) << "Setting data call back to " << std::boolalpha << enable
<< std::noboolalpha; << std::noboolalpha;
try { try {
@ -377,7 +365,6 @@ void qDrawPlot::SetDataCallBack(bool enable) {
} }
void qDrawPlot::SetBinary(bool enable, int from, int to) { void qDrawPlot::SetBinary(bool enable, int from, int to) {
std::lock_guard<std::mutex> lock(mPlots);
LOG(logINFO) << (enable ? "Enabling" : "Disabling") LOG(logINFO) << (enable ? "Enabling" : "Disabling")
<< " Binary output from " << from << " to " << to; << " Binary output from " << from << " to " << to;
binaryFrom = from; binaryFrom = from;
@ -386,7 +373,6 @@ void qDrawPlot::SetBinary(bool enable, int from, int to) {
} }
void qDrawPlot::SetPersistency(int val) { void qDrawPlot::SetPersistency(int val) {
std::lock_guard<std::mutex> lock(mPlots);
LOG(logINFO) << "Setting Persistency to " << val; LOG(logINFO) << "Setting Persistency to " << val;
persistency = val; persistency = val;
} }
@ -468,20 +454,17 @@ void qDrawPlot::ResetAccumulate() {
} }
void qDrawPlot::DisplayStatistics(bool enable) { void qDrawPlot::DisplayStatistics(bool enable) {
std::lock_guard<std::mutex> lock(mPlots);
LOG(logINFO) << (enable ? "Enabling" : "Disabling") LOG(logINFO) << (enable ? "Enabling" : "Disabling")
<< " Statistics Display"; << " Statistics Display";
displayStatistics = enable; displayStatistics = enable;
} }
void qDrawPlot::SetNumDiscardBits(int value) { void qDrawPlot::SetNumDiscardBits(int value) {
std::lock_guard<std::mutex> lock(mPlots);
LOG(logINFO) << "Setting number of bits to discard: " << value; LOG(logINFO) << "Setting number of bits to discard: " << value;
numDiscardBits = value; numDiscardBits = value;
} }
void qDrawPlot::EnableGainPlot(bool enable) { void qDrawPlot::EnableGainPlot(bool enable) {
std::lock_guard<std::mutex> lock(mPlots);
LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " Gain Plot"; LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " Gain Plot";
hasGainData = enable; hasGainData = enable;
} }
@ -622,13 +605,6 @@ void qDrawPlot::SavePlot() {
} }
} }
void qDrawPlot::SetGapPixels(bool enable) {
LOG(logDEBUG) << "Gap pixels enabled";
std::lock_guard<std::mutex> lock(mPlots);
isGapPixels = enable;
}
void qDrawPlot::GetStatistics(double &min, double &max, double &sum) { void qDrawPlot::GetStatistics(double &min, double &max, double &sum) {
LOG(logDEBUG) << "Calculating Statistics"; LOG(logDEBUG) << "Calculating Statistics";
double *array = data2d; double *array = data2d;
@ -662,7 +638,6 @@ void qDrawPlot::StartAcquisition() {
currentFrame = 0; currentFrame = 0;
boxPlot->setTitle("Old Plot"); boxPlot->setTitle("Old Plot");
det->clearAcquiringFlag(); // (from previous exit) or if running det->clearAcquiringFlag(); // (from previous exit) or if running
isRxRoiDisplayed = false;
// ensure data streaming in receiver (if plot enabled) // ensure data streaming in receiver (if plot enabled)
if (isPlot) { if (isPlot) {
@ -730,7 +705,7 @@ void qDrawPlot::AcquisitionFinished(double currentProgress,
int detectorStatus) { int detectorStatus) {
progress = currentProgress; progress = currentProgress;
std::string status = std::string status =
ToString(static_cast<slsDetectorDefs::runStatus>(detectorStatus)); sls::ToString(static_cast<slsDetectorDefs::runStatus>(detectorStatus));
if (detectorStatus == slsDetectorDefs::ERROR) { if (detectorStatus == slsDetectorDefs::ERROR) {
qDefs::Message(qDefs::WARNING, qDefs::Message(qDefs::WARNING,
@ -763,7 +738,6 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
<< " \t dynamic range: " << data->dynamicRange << std::endl << " \t dynamic range: " << data->dynamicRange << std::endl
<< " \t file index: " << data->fileIndex << std::endl << " \t file index: " << data->fileIndex << std::endl
<< " \t complete image: " << data->completeImage << std::endl << " \t complete image: " << data->completeImage << std::endl
<< " \t rx Roi: " << ToString(data->rxRoi) << std::endl
<< " ]"; << " ]";
progress = data->progressIndex; progress = data->progressIndex;
@ -771,22 +745,6 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
currentFrame = frameIndex; currentFrame = frameIndex;
LOG(logDEBUG) << "[ Progress:" << progress << "%, Frame:" << currentFrame LOG(logDEBUG) << "[ Progress:" << progress << "%, Frame:" << currentFrame
<< " ]"; << " ]";
if (!isRxRoiDisplayed) {
rxRoi.xmin = data->rxRoi[0];
rxRoi.xmax = data->rxRoi[1];
rxRoi.ymin = data->rxRoi[2];
rxRoi.ymax = data->rxRoi[3];
// only for 2d anyway
if (isGapPixels) {
rxRoi.xmin += ((rxRoi.xmin/1024) * 6 + (rxRoi.xmin/256) * 2);
rxRoi.xmax += ((rxRoi.xmax/1024) * 6 + (rxRoi.xmax/256) * 2);
rxRoi.ymin += ((rxRoi.ymin/512) * 34 + (rxRoi.ymin/256) * 2);
rxRoi.ymax += ((rxRoi.ymax/512) * 34 + (rxRoi.ymax/256) * 2);
LOG(logINFO) << "Rx_roi recalculated with gap pixels: " << ToString(rxRoi);
}
LOG(logDEBUG) << "Rx_roi: " << ToString(rxRoi);
}
// 1d check if npixelX has changed (m3 for different counters enabled) // 1d check if npixelX has changed (m3 for different counters enabled)
if (is1d && static_cast<int>(nPixelsX) != data->nx) { if (is1d && static_cast<int>(nPixelsX) != data->nx) {
@ -849,11 +807,6 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
isGainDataExtracted = false; isGainDataExtracted = false;
} }
// gotthard25um rearranging
if (gotthard25) {
rearrangeGotthard25data(rawData);
}
// title and frame index titles // title and frame index titles
plotTitle = plotTitle =
plotTitlePrefix + QString(data->fileName.c_str()).section('/', -1); plotTitlePrefix + QString(data->fileName.c_str()).section('/', -1);
@ -1025,26 +978,6 @@ void qDrawPlot::Update1dPlot() {
xyRangeChanged = false; xyRangeChanged = false;
} }
plot1d->DisableZoom(disableZoom); plot1d->DisableZoom(disableZoom);
if (!isRxRoiDisplayed) {
isRxRoiDisplayed = true;
if (rxRoi.completeRoi()) {
plot1d->DisableRoiBox();
if (isGainDataExtracted) {
gainplot1d->DisableRoiBox();
}
lblRxRoiEnabled->hide();
} else {
plot1d->EnableRoiBox(std::array<int, 4>{rxRoi.xmin, rxRoi.xmax, (int)plot1d->GetYMinimum(), (int)plot1d->GetYMaximum()});
if (isGainDataExtracted) {
gainplot1d->EnableRoiBox(std::array<int, 4>{rxRoi.xmin, rxRoi.xmax, 0, 3});
}
lblRxRoiEnabled->show();
}
}
// ymin and ymax could change (so replot roi every time)
if (!rxRoi.completeRoi()) {
plot1d->EnableRoiBox(std::array<int, 4>{rxRoi.xmin, rxRoi.xmax, (int)plot1d->GetYMinimum(), (int)plot1d->GetYMaximum()});
}
} }
void qDrawPlot::Update2dPlot() { void qDrawPlot::Update2dPlot() {
@ -1073,22 +1006,6 @@ void qDrawPlot::Update2dPlot() {
} }
plot2d->DisableZoom(disableZoom); plot2d->DisableZoom(disableZoom);
plot2d->SetZRange(isZRange[0], isZRange[1], zRange[0], zRange[1]); plot2d->SetZRange(isZRange[0], isZRange[1], zRange[0], zRange[1]);
if (!isRxRoiDisplayed) {
isRxRoiDisplayed = true;
if (rxRoi.completeRoi()) {
plot2d->DisableRoiBox();
if (isGainDataExtracted) {
gainplot2d->DisableRoiBox();
}
lblRxRoiEnabled->hide();
} else {
plot2d->EnableRoiBox(rxRoi.getIntArray());
if (isGainDataExtracted) {
gainplot2d->EnableRoiBox(rxRoi.getIntArray());
}
lblRxRoiEnabled->show();
}
}
} }
void qDrawPlot::Update1dXYRange() { void qDrawPlot::Update1dXYRange() {
@ -1147,8 +1064,6 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size,
// mythen3 / gotthard2 debugging // mythen3 / gotthard2 debugging
int discardBits = numDiscardBits; int discardBits = numDiscardBits;
uint16_t temp = 0;
uint8_t *src = (uint8_t *)source;
switch (dr) { switch (dr) {
case 4: case 4:
@ -1168,19 +1083,6 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size,
} }
break; break;
case 12:
for (ichan = 0; ichan < size; ++ichan) {
temp = (*src++ & 0xFF);
temp |= ((*src & 0xF) << 8u);
dest[ichan] = (double)temp;
++ichan;
temp = ((*src++ & 0xF0) >> 4u);
temp |= ((*src++ & 0xFF) << 4u);
dest[ichan] = (double)temp;
}
break;
case 16: case 16:
if (detType == slsDetectorDefs::JUNGFRAU || if (detType == slsDetectorDefs::JUNGFRAU ||
detType == slsDetectorDefs::GOTTHARD2) { detType == slsDetectorDefs::GOTTHARD2) {
@ -1228,18 +1130,6 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size,
} }
} }
void qDrawPlot::rearrangeGotthard25data(double *data) {
const int nChans = NUM_GOTTHARD25_CHANS;
double temp[nChans * 2] = {0.0};
for (int i = 0; i != nChans; ++i) {
// master module
temp[i * 2] = data[i];
// slave module
temp[i * 2 + 1] = data[nChans + i];
}
memcpy(data, temp, nChans * 2 * sizeof(double));
}
void qDrawPlot::UpdatePlot() { void qDrawPlot::UpdatePlot() {
std::lock_guard<std::mutex> lock(mPlots); std::lock_guard<std::mutex> lock(mPlots);
LOG(logDEBUG) << "Update Plot"; LOG(logDEBUG) << "Update Plot";
@ -1274,5 +1164,3 @@ void qDrawPlot::UpdatePlot() {
LOG(logDEBUG) << "End of Update Plot"; LOG(logDEBUG) << "End of Update Plot";
} }
} // namespace sls

View File

@ -5,9 +5,7 @@
#include "qDrawPlot.h" #include "qDrawPlot.h"
#include "sls/network_utils.h" #include "sls/network_utils.h"
namespace sls { qTabAdvanced::qTabAdvanced(QWidget *parent, sls::Detector *detector,
qTabAdvanced::qTabAdvanced(QWidget *parent, Detector *detector,
qDrawPlot *p) qDrawPlot *p)
: QWidget(parent), det(detector), plot(p) { : QWidget(parent), det(detector), plot(p) {
setupUi(this); setupUi(this);
@ -445,7 +443,7 @@ void qTabAdvanced::SetDetectorUDPIP(bool force) {
std::string s = dispDetectorUDPIP->text().toAscii().constData(); std::string s = dispDetectorUDPIP->text().toAscii().constData();
LOG(logINFO) << "Setting Detector UDP IP:" << s; LOG(logINFO) << "Setting Detector UDP IP:" << s;
try { try {
det->setSourceUDPIP(IpAddr{s}, det->setSourceUDPIP(sls::IpAddr{s},
{comboDetector->currentIndex()}); {comboDetector->currentIndex()});
} }
CATCH_HANDLE("Could not set Detector UDP IP.", CATCH_HANDLE("Could not set Detector UDP IP.",
@ -463,7 +461,7 @@ void qTabAdvanced::SetDetectorUDPMAC(bool force) {
std::string s = dispDetectorUDPMAC->text().toAscii().constData(); std::string s = dispDetectorUDPMAC->text().toAscii().constData();
LOG(logINFO) << "Setting Detector UDP MAC:" << s; LOG(logINFO) << "Setting Detector UDP MAC:" << s;
try { try {
det->setSourceUDPMAC(MacAddr{s}, det->setSourceUDPMAC(sls::MacAddr{s},
{comboDetector->currentIndex()}); {comboDetector->currentIndex()});
} }
CATCH_HANDLE("Could not set Detector UDP MAC.", CATCH_HANDLE("Could not set Detector UDP MAC.",
@ -491,7 +489,7 @@ void qTabAdvanced::SetCltZMQIP(bool force) {
std::string s = dispZMQIP->text().toAscii().constData(); std::string s = dispZMQIP->text().toAscii().constData();
LOG(logINFO) << "Setting Client ZMQ IP:" << s; LOG(logINFO) << "Setting Client ZMQ IP:" << s;
try { try {
det->setClientZmqIp(IpAddr{s}, det->setClientZmqIp(sls::IpAddr{s},
{comboDetector->currentIndex()}); {comboDetector->currentIndex()});
} }
CATCH_HANDLE("Could not set Client ZMQ IP.", CATCH_HANDLE("Could not set Client ZMQ IP.",
@ -549,7 +547,7 @@ void qTabAdvanced::SetRxrUDPIP(bool force) {
std::string s = dispRxrUDPIP->text().toAscii().constData(); std::string s = dispRxrUDPIP->text().toAscii().constData();
LOG(logINFO) << "Setting Receiver UDP IP:" << s; LOG(logINFO) << "Setting Receiver UDP IP:" << s;
try { try {
det->setDestinationUDPIP(IpAddr{s}, det->setDestinationUDPIP(sls::IpAddr{s},
{comboDetector->currentIndex()}); {comboDetector->currentIndex()});
} }
CATCH_HANDLE("Could not set Receiver UDP IP.", CATCH_HANDLE("Could not set Receiver UDP IP.",
@ -567,7 +565,7 @@ void qTabAdvanced::SetRxrUDPMAC(bool force) {
std::string s = dispRxrUDPMAC->text().toAscii().constData(); std::string s = dispRxrUDPMAC->text().toAscii().constData();
LOG(logINFO) << "Setting Receiver UDP MAC:" << s; LOG(logINFO) << "Setting Receiver UDP MAC:" << s;
try { try {
det->setDestinationUDPMAC(MacAddr{s}, det->setDestinationUDPMAC(sls::MacAddr{s},
{comboDetector->currentIndex()}); {comboDetector->currentIndex()});
} }
CATCH_HANDLE("Could not set Receiver UDP MAC.", CATCH_HANDLE("Could not set Receiver UDP MAC.",
@ -595,7 +593,7 @@ void qTabAdvanced::SetRxrZMQIP(bool force) {
std::string s = dispRxrZMQIP->text().toAscii().constData(); std::string s = dispRxrZMQIP->text().toAscii().constData();
LOG(logINFO) << "Setting Receiver ZMQ IP:" << s; LOG(logINFO) << "Setting Receiver ZMQ IP:" << s;
try { try {
det->setRxZmqIP(IpAddr{s}, {comboDetector->currentIndex()}); det->setRxZmqIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
} }
CATCH_HANDLE("Could not set Receiver ZMQ IP.", CATCH_HANDLE("Could not set Receiver ZMQ IP.",
"qTabAdvanced::SetRxrZMQIP", this, "qTabAdvanced::SetRxrZMQIP", this,
@ -893,5 +891,3 @@ void qTabAdvanced::Refresh() {
} }
LOG(logDEBUG) << "**Updated Advanced Tab"; LOG(logDEBUG) << "**Updated Advanced Tab";
} }
} // namespace sls

View File

@ -11,9 +11,7 @@
#include <unistd.h> #include <unistd.h>
namespace sls { qTabDataOutput::qTabDataOutput(QWidget *parent, sls::Detector *detector)
qTabDataOutput::qTabDataOutput(QWidget *parent, Detector *detector)
: QWidget(parent), det(detector), btnGroupRate(nullptr) { : QWidget(parent), det(detector), btnGroupRate(nullptr) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
@ -234,7 +232,7 @@ void qTabDataOutput::GetFileFormat() {
comboFileFormat->setCurrentIndex(static_cast<int>(retval)); comboFileFormat->setCurrentIndex(static_cast<int>(retval));
break; break;
default: default:
throw RuntimeError(std::string("Unknown file format: ") + throw sls::RuntimeError(std::string("Unknown file format: ") +
std::to_string(static_cast<int>(retval))); std::to_string(static_cast<int>(retval)));
} }
} }
@ -341,7 +339,7 @@ void qTabDataOutput::EnableRateCorrection() {
LOG(logINFO) << "Disabling Rate correction"; LOG(logINFO) << "Disabling Rate correction";
// disable // disable
try { try {
det->setRateCorrection(ns(0)); det->setRateCorrection(sls::ns(0));
} }
CATCH_HANDLE("Could not switch off rate correction.", CATCH_HANDLE("Could not switch off rate correction.",
"qTabDataOutput::EnableRateCorrection", this, "qTabDataOutput::EnableRateCorrection", this,
@ -359,7 +357,7 @@ void qTabDataOutput::SetRateCorrection() {
int64_t deadtime = spinCustomDeadTime->value(); int64_t deadtime = spinCustomDeadTime->value();
LOG(logINFO) << "Setting Rate Correction with custom dead time: " LOG(logINFO) << "Setting Rate Correction with custom dead time: "
<< deadtime; << deadtime;
det->setRateCorrection(ns(deadtime)); det->setRateCorrection(sls::ns(deadtime));
} }
// default dead time // default dead time
else { else {
@ -444,5 +442,3 @@ void qTabDataOutput::Refresh() {
LOG(logDEBUG) << "**Updated DataOutput Tab"; LOG(logDEBUG) << "**Updated DataOutput Tab";
} }
} // namespace sls

View File

@ -7,9 +7,7 @@
#include <QGridLayout> #include <QGridLayout>
#include <QTreeWidget> #include <QTreeWidget>
namespace sls { qTabDebugging::qTabDebugging(QWidget *parent, sls::Detector *detector)
qTabDebugging::qTabDebugging(QWidget *parent, Detector *detector)
: QWidget(parent), det(detector), treeDet(nullptr), : QWidget(parent), det(detector), treeDet(nullptr),
lblDetectorHostname(nullptr), lblDetectorFirmware(nullptr), lblDetectorHostname(nullptr), lblDetectorFirmware(nullptr),
lblDetectorSoftware(nullptr) { lblDetectorSoftware(nullptr) {
@ -64,7 +62,7 @@ void qTabDebugging::GetDetectorStatus() {
LOG(logDEBUG) << "Getting Status"; LOG(logDEBUG) << "Getting Status";
try { try {
std::string status = ToString( std::string status = sls::ToString(
det->getDetectorStatus({comboDetector->currentIndex()})[0]); det->getDetectorStatus({comboDetector->currentIndex()})[0]);
lblStatus->setText(QString(status.c_str()).toUpper()); lblStatus->setText(QString(status.c_str()).toUpper());
} }
@ -90,7 +88,7 @@ void qTabDebugging::GetInfo() {
lblDetectorFirmware->setFixedWidth(100); lblDetectorFirmware->setFixedWidth(100);
layout->addWidget(dispFrame, 0, 1); layout->addWidget(dispFrame, 0, 1);
QString detName = QString detName =
QString(ToString(det->getDetectorType().squash()).c_str()); QString(sls::ToString(det->getDetectorType().squash()).c_str());
switch (det->getDetectorType().squash()) { switch (det->getDetectorType().squash()) {
@ -243,5 +241,3 @@ void qTabDebugging::Refresh() {
GetDetectorStatus(); GetDetectorStatus();
LOG(logDEBUG) << "**Updated Debugging Tab"; LOG(logDEBUG) << "**Updated Debugging Tab";
} }
} // namespace sls

View File

@ -4,9 +4,7 @@
#include "qDacWidget.h" #include "qDacWidget.h"
#include "qDefs.h" #include "qDefs.h"
namespace sls { qTabDeveloper::qTabDeveloper(QWidget *parent, sls::Detector *detector)
qTabDeveloper::qTabDeveloper(QWidget *parent, Detector *detector)
: QWidget(parent), det(detector) { : QWidget(parent), det(detector) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
@ -18,6 +16,12 @@ qTabDeveloper::~qTabDeveloper() {}
void qTabDeveloper::SetupWidgetWindow() { void qTabDeveloper::SetupWidgetWindow() {
int tempid = 0; int tempid = 0;
comboHV->hide();
lblComboHV->hide();
lblSpinHV->hide();
spinHV->hide();
hvmin = HV_MIN;
try { try {
slsDetectorDefs::detectorType detType = det->getDetectorType().squash(); slsDetectorDefs::detectorType detType = det->getDetectorType().squash();
switch (detType) { switch (detType) {
@ -78,6 +82,8 @@ void qTabDeveloper::SetupWidgetWindow() {
break; break;
case slsDetectorDefs::GOTTHARD: case slsDetectorDefs::GOTTHARD:
comboHV->show();
lblComboHV->show();
dacWidgets.push_back(new qDacWidget( dacWidgets.push_back(new qDacWidget(
this, det, true, this, det, true,
"v Reference: ", getSLSIndex(detType, tempid++))); "v Reference: ", getSLSIndex(detType, tempid++)));
@ -111,6 +117,8 @@ void qTabDeveloper::SetupWidgetWindow() {
break; break;
case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::JUNGFRAU:
lblSpinHV->show();
spinHV->show();
dacWidgets.push_back( dacWidgets.push_back(
new qDacWidget(this, det, true, new qDacWidget(this, det, true,
"v vb comp: ", getSLSIndex(detType, tempid++))); "v vb comp: ", getSLSIndex(detType, tempid++)));
@ -140,6 +148,8 @@ void qTabDeveloper::SetupWidgetWindow() {
break; break;
case slsDetectorDefs::MOENCH: case slsDetectorDefs::MOENCH:
lblSpinHV->show();
spinHV->show();
dacWidgets.push_back( dacWidgets.push_back(
new qDacWidget(this, det, true, new qDacWidget(this, det, true,
"vbp_colbuf: ", getSLSIndex(detType, tempid++))); "vbp_colbuf: ", getSLSIndex(detType, tempid++)));
@ -163,6 +173,9 @@ void qTabDeveloper::SetupWidgetWindow() {
break; break;
case slsDetectorDefs::MYTHEN3: case slsDetectorDefs::MYTHEN3:
lblSpinHV->show();
spinHV->show();
hvmin = 0;
dacWidgets.push_back(new qDacWidget( dacWidgets.push_back(new qDacWidget(
this, det, true, "vcassh: ", getSLSIndex(detType, tempid++))); this, det, true, "vcassh: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget( dacWidgets.push_back(new qDacWidget(
@ -203,6 +216,9 @@ void qTabDeveloper::SetupWidgetWindow() {
break; break;
case slsDetectorDefs::GOTTHARD2: case slsDetectorDefs::GOTTHARD2:
lblSpinHV->show();
spinHV->show();
hvmin = 0;
dacWidgets.push_back( dacWidgets.push_back(
new qDacWidget(this, det, true, new qDacWidget(this, det, true,
"vref_h_adc: ", getSLSIndex(detType, tempid++))); "vref_h_adc: ", getSLSIndex(detType, tempid++)));
@ -274,6 +290,9 @@ void qTabDeveloper::SetupWidgetWindow() {
void qTabDeveloper::Initialization() { void qTabDeveloper::Initialization() {
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, connect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
SLOT(Refresh())); SLOT(Refresh()));
connect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
} }
void qTabDeveloper::PopulateDetectors() { void qTabDeveloper::PopulateDetectors() {
@ -290,6 +309,75 @@ void qTabDeveloper::PopulateDetectors() {
comboDetector->setCurrentIndex(0); comboDetector->setCurrentIndex(0);
} }
void qTabDeveloper::GetHighVoltage() {
// not enabled for eiger
if (!comboHV->isVisible() && !spinHV->isVisible())
return;
LOG(logDEBUG) << "Getting High Voltage";
disconnect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
try {
// dac units
auto retval = det->getHighVoltage({comboDetector->currentIndex() - 1})
.tsquash("Inconsistent values for high voltage.");
// spinHV
if (spinHV->isVisible()) {
if (retval != 0 && retval < hvmin && retval > HV_MAX) {
throw sls::RuntimeError(std::string("Unknown High Voltage: ") +
std::to_string(retval));
}
spinHV->setValue(retval);
}
// combo HV
else {
switch (retval) {
case 0:
comboHV->setCurrentIndex(HV_0);
break;
case 90:
comboHV->setCurrentIndex(HV_90);
break;
case 110:
comboHV->setCurrentIndex(HV_110);
break;
case 120:
comboHV->setCurrentIndex(HV_120);
break;
case 150:
comboHV->setCurrentIndex(HV_150);
break;
case 180:
comboHV->setCurrentIndex(HV_180);
break;
case 200:
comboHV->setCurrentIndex(HV_200);
break;
default:
throw sls::RuntimeError(std::string("Unknown High Voltage: ") +
std::to_string(retval));
}
}
}
CATCH_DISPLAY("Could not get high voltage.",
"qTabDeveloper::GetHighVoltage")
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
connect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
}
void qTabDeveloper::SetHighVoltage() {
int val = (comboHV->isVisible() ? comboHV->currentText().toInt()
: spinHV->value());
LOG(logINFO) << "Setting high voltage:" << val;
try {
det->setHighVoltage({comboDetector->currentIndex() - 1});
}
CATCH_HANDLE("Could not set high voltage.", "qTabDeveloper::SetHighVoltage",
this, &qTabDeveloper::GetHighVoltage)
}
slsDetectorDefs::dacIndex slsDetectorDefs::dacIndex
qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) { qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
switch (detType) { switch (detType) {
@ -343,7 +431,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
case 22: case 22:
return slsDetectorDefs::TEMPERATURE_FPGA; return slsDetectorDefs::TEMPERATURE_FPGA;
default: default:
throw RuntimeError(std::string("Unknown dac/adc index") + throw sls::RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index)); std::to_string(index));
} }
break; break;
@ -370,7 +458,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
case 9: case 9:
return slsDetectorDefs::TEMPERATURE_FPGA; return slsDetectorDefs::TEMPERATURE_FPGA;
default: default:
throw RuntimeError(std::string("Unknown dac/adc index") + throw sls::RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index)); std::to_string(index));
} }
break; break;
@ -396,7 +484,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
case 8: case 8:
return slsDetectorDefs::TEMPERATURE_ADC; return slsDetectorDefs::TEMPERATURE_ADC;
default: default:
throw RuntimeError(std::string("Unknown dac/adc index") + throw sls::RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index)); std::to_string(index));
} }
break; break;
@ -420,7 +508,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
case 7: case 7:
return slsDetectorDefs::IBIAS_SFP; return slsDetectorDefs::IBIAS_SFP;
default: default:
throw RuntimeError(std::string("Unknown dac/adc index") + throw sls::RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index)); std::to_string(index));
} }
break; break;
@ -462,7 +550,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
case 16: case 16:
return slsDetectorDefs::VTHRESHOLD; return slsDetectorDefs::VTHRESHOLD;
default: default:
throw RuntimeError(std::string("Unknown dac/adc index") + throw sls::RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index)); std::to_string(index));
} }
break; break;
@ -498,13 +586,13 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
case 13: case 13:
return slsDetectorDefs::VCOM_ADC2; return slsDetectorDefs::VCOM_ADC2;
default: default:
throw RuntimeError(std::string("Unknown dac/adc index") + throw sls::RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index)); std::to_string(index));
} }
break; break;
default: default:
throw RuntimeError(std::string("Unknown detector type")); throw sls::RuntimeError(std::string("Unknown detector type"));
} }
} }
@ -516,7 +604,6 @@ void qTabDeveloper::Refresh() {
for (const auto &it : adcWidgets) { for (const auto &it : adcWidgets) {
it->SetDetectorIndex(comboDetector->currentIndex() - 1); it->SetDetectorIndex(comboDetector->currentIndex() - 1);
} }
GetHighVoltage();
LOG(logDEBUG) << "**Updated Developer Tab"; LOG(logDEBUG) << "**Updated Developer Tab";
} }
} // namespace sls

View File

@ -7,9 +7,7 @@
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QTimer> #include <QTimer>
namespace sls { qTabMeasurement::qTabMeasurement(QWidget *parent, sls::Detector *detector,
qTabMeasurement::qTabMeasurement(QWidget *parent, Detector *detector,
qDrawPlot *p) qDrawPlot *p)
: QWidget(parent), det(detector), plot(p), progressTimer(nullptr) { : QWidget(parent), det(detector), plot(p), progressTimer(nullptr) {
setupUi(this); setupUi(this);
@ -339,26 +337,9 @@ void qTabMeasurement::GetTimingMode() {
disconnect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, disconnect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetTimingMode(int))); SLOT(SetTimingMode(int)));
try { try {
slsDetectorDefs::timingMode retval{slsDetectorDefs::AUTO_TIMING};
// m3: remove slave modes (always trigger) before squashing
if (det->getDetectorType().squash() == slsDetectorDefs::MYTHEN3) {
auto retvals = det->getTimingMode();
auto is_master = det->getMaster();
Result<slsDetectorDefs::timingMode> masterRetvals;
for (size_t i = 0; i != is_master.size(); ++i) {
if (is_master[i]) {
masterRetvals.push_back(retvals[i]);
}
}
retval = masterRetvals.tsquash(
"Inconsistent timing mode for all detectors.");
} else {
retval = det->getTimingMode().tsquash(
"Inconsistent timing mode for all detectors.");
}
auto oldMode = comboTimingMode->currentIndex(); auto oldMode = comboTimingMode->currentIndex();
auto retval = det->getTimingMode().tsquash(
"Inconsistent timing mode for all detectors.");
switch (retval) { switch (retval) {
case slsDetectorDefs::AUTO_TIMING: case slsDetectorDefs::AUTO_TIMING:
case slsDetectorDefs::TRIGGER_EXPOSURE: case slsDetectorDefs::TRIGGER_EXPOSURE:
@ -372,7 +353,7 @@ void qTabMeasurement::GetTimingMode() {
} }
break; break;
default: default:
throw RuntimeError(std::string("Unknown timing mode: ") + throw sls::RuntimeError(std::string("Unknown timing mode: ") +
std::to_string(retval)); std::to_string(retval));
} }
} }
@ -409,7 +390,7 @@ void qTabMeasurement::GetBurstMode() {
ShowTriggerDelay(); ShowTriggerDelay();
break; break;
default: default:
throw RuntimeError(std::string("Unknown burst mode: ") + throw sls::RuntimeError(std::string("Unknown burst mode: ") +
std::to_string(retval)); std::to_string(retval));
} }
} }
@ -1019,5 +1000,3 @@ void qTabMeasurement::Refresh() {
LOG(logDEBUG) << "**Updated Measurement Tab"; LOG(logDEBUG) << "**Updated Measurement Tab";
} }
} // namespace sls

View File

@ -11,8 +11,6 @@
#include <QTextStream> #include <QTextStream>
#include <string> #include <string>
namespace sls {
qTabMessages::qTabMessages(QWidget *parent) : QWidget(parent) { qTabMessages::qTabMessages(QWidget *parent) : QWidget(parent) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
@ -144,5 +142,3 @@ void qTabMessages::Refresh() {
dispCommand->clear(); dispCommand->clear();
dispCommand->setFocus(); dispCommand->setFocus();
} }
} // namespace sls

View File

@ -6,8 +6,6 @@
#include <QStackedLayout> #include <QStackedLayout>
#include <QStandardItemModel> #include <QStandardItemModel>
namespace sls {
QString qTabPlot::defaultPlotTitle(""); QString qTabPlot::defaultPlotTitle("");
QString qTabPlot::defaultHistXAxisTitle("Channel Number"); QString qTabPlot::defaultHistXAxisTitle("Channel Number");
QString qTabPlot::defaultHistYAxisTitle("Counts"); QString qTabPlot::defaultHistYAxisTitle("Counts");
@ -15,7 +13,7 @@ QString qTabPlot::defaultImageXAxisTitle("Pixel");
QString qTabPlot::defaultImageYAxisTitle("Pixel"); QString qTabPlot::defaultImageYAxisTitle("Pixel");
QString qTabPlot::defaultImageZAxisTitle("Intensity"); QString qTabPlot::defaultImageZAxisTitle("Intensity");
qTabPlot::qTabPlot(QWidget *parent, Detector *detector, qDrawPlot *p) qTabPlot::qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p)
: QWidget(parent), det(detector), plot(p), is1d(false) { : QWidget(parent), det(detector), plot(p), is1d(false) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
@ -76,10 +74,6 @@ void qTabPlot::SetupWidgetWindow() {
// set zmq high water mark to GUI_ZMQ_RCV_HWM (2) // set zmq high water mark to GUI_ZMQ_RCV_HWM (2)
spinSndHwm->setValue(qDefs::GUI_ZMQ_RCV_HWM); spinSndHwm->setValue(qDefs::GUI_ZMQ_RCV_HWM);
spinRcvHwm->setValue(qDefs::GUI_ZMQ_RCV_HWM); spinRcvHwm->setValue(qDefs::GUI_ZMQ_RCV_HWM);
if (chkGapPixels->isEnabled()) {
chkGapPixels->setChecked(true);
}
} }
void qTabPlot::Initialization() { void qTabPlot::Initialization() {
@ -333,7 +327,6 @@ void qTabPlot::SetGapPixels(bool enable) {
LOG(logINFO) << "Setting Gap Pixels Enable to " << enable; LOG(logINFO) << "Setting Gap Pixels Enable to " << enable;
try { try {
det->setGapPixelsinCallback(enable); det->setGapPixelsinCallback(enable);
plot->SetGapPixels(enable);
} }
CATCH_HANDLE("Could not set gap pixels enable.", "qTabPlot::SetGapPixels", CATCH_HANDLE("Could not set gap pixels enable.", "qTabPlot::SetGapPixels",
this, &qTabPlot::GetGapPixels) this, &qTabPlot::GetGapPixels)
@ -799,5 +792,3 @@ void qTabPlot::Refresh() {
LOG(logDEBUG) << "**Updated Plot Tab"; LOG(logDEBUG) << "**Updated Plot Tab";
} }
} // namespace sls

View File

@ -6,9 +6,7 @@
#include "sls/bit_utils.h" #include "sls/bit_utils.h"
#include <QStandardItemModel> #include <QStandardItemModel>
namespace sls { qTabSettings::qTabSettings(QWidget *parent, sls::Detector *detector)
qTabSettings::qTabSettings(QWidget *parent, Detector *detector)
: QWidget(parent), det(detector) { : QWidget(parent), det(detector) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
@ -19,12 +17,6 @@ qTabSettings::~qTabSettings() {}
void qTabSettings::SetupWidgetWindow() { void qTabSettings::SetupWidgetWindow() {
comboHV->hide();
lblComboHV->hide();
lblSpinHV->hide();
spinHV->hide();
hvmin = HV_MIN;
counters = std::vector<QCheckBox *>{chkCounter1, chkCounter2, chkCounter3}; counters = std::vector<QCheckBox *>{chkCounter1, chkCounter2, chkCounter3};
spinThreshold2->hide(); spinThreshold2->hide();
@ -43,9 +35,6 @@ void qTabSettings::SetupWidgetWindow() {
// enabling according to det type // enabling according to det type
slsDetectorDefs::detectorType detType = det->getDetectorType().squash(); slsDetectorDefs::detectorType detType = det->getDetectorType().squash();
if (detType == slsDetectorDefs::MYTHEN3) { if (detType == slsDetectorDefs::MYTHEN3) {
lblSpinHV->show();
spinHV->show();
hvmin = 0;
lblDynamicRange->setEnabled(true); lblDynamicRange->setEnabled(true);
comboDynamicRange->setEnabled(true); comboDynamicRange->setEnabled(true);
@ -71,43 +60,22 @@ void qTabSettings::SetupWidgetWindow() {
QStandardItemModel *model = QStandardItemModel *model =
qobject_cast<QStandardItemModel *>(comboDynamicRange->model()); qobject_cast<QStandardItemModel *>(comboDynamicRange->model());
if (model) { if (model) {
QModelIndex index;
QStandardItem *item; QStandardItem *item;
int dr = DYNAMICRANGE_4; index =
for (int i = 0; i != 2; ++i) { model->index(DYNAMICRANGE_4, comboDynamicRange->modelColumn(),
// disable dr 4 comboDynamicRange->rootModelIndex());
QModelIndex index = item = model->itemFromIndex(index);
model->index(dr, comboDynamicRange->modelColumn(), item->setEnabled(false);
comboDynamicRange->rootModelIndex());
item = model->itemFromIndex(index);
item->setEnabled(false);
// disable dr 12
dr = DYNAMICRANGE_12;
}
} }
} else if (detType == slsDetectorDefs::EIGER) { } else if (detType == slsDetectorDefs::EIGER) {
lblSpinHV->show();
spinHV->show();
hvmin = 0;
lblDynamicRange->setEnabled(true); lblDynamicRange->setEnabled(true);
comboDynamicRange->setEnabled(true); comboDynamicRange->setEnabled(true);
lblThreshold->setEnabled(true); lblThreshold->setEnabled(true);
spinThreshold->setEnabled(true); spinThreshold->setEnabled(true);
} else if (detType == slsDetectorDefs::JUNGFRAU) { } else if (detType == slsDetectorDefs::JUNGFRAU) {
lblSpinHV->show();
spinHV->show();
lblGainMode->setEnabled(true); lblGainMode->setEnabled(true);
comboGainMode->setEnabled(true); comboGainMode->setEnabled(true);
} else if (detType == slsDetectorDefs::GOTTHARD) {
comboHV->show();
lblComboHV->show();
} else if (detType == slsDetectorDefs::MOENCH) {
lblSpinHV->show();
spinHV->show();
} else if (detType == slsDetectorDefs::GOTTHARD2) {
lblSpinHV->show();
spinHV->show();
hvmin = 0;
} }
// default settings for the disabled // default settings for the disabled
@ -189,11 +157,6 @@ void qTabSettings::ShowFixG0(bool expertMode) {
} }
void qTabSettings::Initialization() { void qTabSettings::Initialization() {
// High voltage
connect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
// Settings // Settings
if (comboSettings->isEnabled()) if (comboSettings->isEnabled())
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, connect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
@ -230,91 +193,6 @@ void qTabSettings::Initialization() {
} }
} }
void qTabSettings::GetHighVoltage() {
// not enabled for eiger
if (!comboHV->isVisible() && !spinHV->isVisible())
return;
LOG(logDEBUG) << "Getting High Voltage";
disconnect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
try {
Result<int> retvals = det->getHighVoltage();
int retval = 0;
if (det->getDetectorType().squash() != slsDetectorDefs::EIGER) {
retval = retvals.tsquash("Inconsistent values for high voltage.");
}
// eiger slaves return -999
else {
auto is_master = det->getMaster();
Result<int> master_retvals;
for (size_t i = 0; i != retvals.size(); ++i) {
if (is_master[i]) {
master_retvals.push_back(retvals[i]);
}
}
retval = master_retvals.tsquash("Inconsistent values for high voltage.");
}
// spinHV
if (spinHV->isVisible()) {
if (retval != 0 && retval < hvmin && retval > HV_MAX) {
throw RuntimeError(std::string("Unknown High Voltage: ") +
std::to_string(retval));
}
spinHV->setValue(retval);
}
// combo HV
else {
switch (retval) {
case 0:
comboHV->setCurrentIndex(HV_0);
break;
case 90:
comboHV->setCurrentIndex(HV_90);
break;
case 110:
comboHV->setCurrentIndex(HV_110);
break;
case 120:
comboHV->setCurrentIndex(HV_120);
break;
case 150:
comboHV->setCurrentIndex(HV_150);
break;
case 180:
comboHV->setCurrentIndex(HV_180);
break;
case 200:
comboHV->setCurrentIndex(HV_200);
break;
default:
throw RuntimeError(std::string("Unknown High Voltage: ") +
std::to_string(retval));
}
}
}
CATCH_DISPLAY("Could not get high voltage.",
"qTabSettings::GetHighVoltage")
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
connect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
}
void qTabSettings::SetHighVoltage() {
int val = (comboHV->isVisible() ? comboHV->currentText().toInt()
: spinHV->value());
LOG(logINFO) << "Setting high voltage:" << val;
try {
det->setHighVoltage(val);
}
CATCH_HANDLE("Could not set high voltage.", "qTabSettings::SetHighVoltage",
this, &qTabSettings::GetHighVoltage)
}
void qTabSettings::GetSettings() { void qTabSettings::GetSettings() {
LOG(logDEBUG) << "Getting settings"; LOG(logDEBUG) << "Getting settings";
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
@ -331,7 +209,7 @@ void qTabSettings::GetSettings() {
break; break;
default: default:
if ((int)retval < -1 || (int)retval >= comboSettings->count()) { if ((int)retval < -1 || (int)retval >= comboSettings->count()) {
throw RuntimeError(std::string("Unknown settings: ") + throw sls::RuntimeError(std::string("Unknown settings: ") +
std::to_string(retval)); std::to_string(retval));
} }
comboSettings->setCurrentIndex(retval); comboSettings->setCurrentIndex(retval);
@ -347,7 +225,7 @@ void qTabSettings::SetSettings(int index) {
// settings // settings
auto val = static_cast<slsDetectorDefs::detectorSettings>(index); auto val = static_cast<slsDetectorDefs::detectorSettings>(index);
try { try {
LOG(logINFO) << "Setting Settings to " << ToString(val); LOG(logINFO) << "Setting Settings to " << sls::ToString(val);
det->setSettings(val); det->setSettings(val);
} }
CATCH_HANDLE("Could not set settings.", "qTabSettings::SetSettings", this, CATCH_HANDLE("Could not set settings.", "qTabSettings::SetSettings", this,
@ -366,7 +244,7 @@ void qTabSettings::GetGainMode() {
auto retval = det->getGainMode().tsquash( auto retval = det->getGainMode().tsquash(
"Inconsistent gain mode for all detectors."); "Inconsistent gain mode for all detectors.");
if ((int)retval < 0 || (int)retval >= comboGainMode->count()) { if ((int)retval < 0 || (int)retval >= comboGainMode->count()) {
throw RuntimeError(std::string("Unknown gain mode: ") + throw sls::RuntimeError(std::string("Unknown gain mode: ") +
std::to_string(retval)); std::to_string(retval));
} }
// warning when using fix_g0 and not in export mode // warning when using fix_g0 and not in export mode
@ -427,9 +305,6 @@ void qTabSettings::GetDynamicRange() {
case 16: case 16:
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_16); comboDynamicRange->setCurrentIndex(DYNAMICRANGE_16);
break; break;
case 12:
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_12);
break;
case 8: case 8:
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_8); comboDynamicRange->setCurrentIndex(DYNAMICRANGE_8);
break; break;
@ -437,7 +312,7 @@ void qTabSettings::GetDynamicRange() {
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_4); comboDynamicRange->setCurrentIndex(DYNAMICRANGE_4);
break; break;
default: default:
throw RuntimeError(std::string("Unknown dynamic range: ") + throw sls::RuntimeError(std::string("Unknown dynamic range: ") +
std::to_string(retval)); std::to_string(retval));
} }
} }
@ -458,9 +333,6 @@ void qTabSettings::SetDynamicRange(int index) {
case DYNAMICRANGE_16: case DYNAMICRANGE_16:
det->setDynamicRange(16); det->setDynamicRange(16);
break; break;
case DYNAMICRANGE_12:
det->setDynamicRange(12);
break;
case DYNAMICRANGE_8: case DYNAMICRANGE_8:
det->setDynamicRange(8); det->setDynamicRange(8);
break; break;
@ -468,7 +340,7 @@ void qTabSettings::SetDynamicRange(int index) {
det->setDynamicRange(4); det->setDynamicRange(4);
break; break;
default: default:
throw RuntimeError(std::string("Unknown dynamic range: ") + throw sls::RuntimeError(std::string("Unknown dynamic range: ") +
std::to_string(index)); std::to_string(index));
} }
} }
@ -515,7 +387,7 @@ void qTabSettings::SetThresholdEnergies() {
slsDetectorDefs::detectorSettings sett = slsDetectorDefs::detectorSettings sett =
static_cast<slsDetectorDefs::detectorSettings>( static_cast<slsDetectorDefs::detectorSettings>(
comboSettings->currentIndex()); comboSettings->currentIndex());
LOG(logINFO) << "Setting Threshold Energies to " << ToString(eV) LOG(logINFO) << "Setting Threshold Energies to " << sls::ToString(eV)
<< " (eV)"; << " (eV)";
try { try {
det->setThresholdEnergy(eV, sett); det->setThresholdEnergy(eV, sett);
@ -546,7 +418,7 @@ void qTabSettings::GetCounterMask() {
disconnect(chkCounter3, SIGNAL(toggled(bool)), this, disconnect(chkCounter3, SIGNAL(toggled(bool)), this,
SLOT(SetCounterMask())); SLOT(SetCounterMask()));
try { try {
auto retval = getSetBits(det->getCounterMask().tsquash( auto retval = sls::getSetBits(det->getCounterMask().tsquash(
"Counter mask is inconsistent for all detectors.")); "Counter mask is inconsistent for all detectors."));
// default to unchecked // default to unchecked
for (auto p : counters) { for (auto p : counters) {
@ -555,7 +427,7 @@ void qTabSettings::GetCounterMask() {
// if retval[i] = 2, chkCounter2 is checked // if retval[i] = 2, chkCounter2 is checked
for (auto i : retval) { for (auto i : retval) {
if (i > 3) { if (i > 3) {
throw RuntimeError( throw sls::RuntimeError(
std::string("Unknown counter index : ") + std::string("Unknown counter index : ") +
std::to_string(static_cast<int>(i))); std::to_string(static_cast<int>(i)));
} }
@ -586,8 +458,6 @@ void qTabSettings::SetCounterMask() {
void qTabSettings::Refresh() { void qTabSettings::Refresh() {
LOG(logDEBUG) << "**Updating Settings Tab"; LOG(logDEBUG) << "**Updating Settings Tab";
GetHighVoltage();
if (comboSettings->isEnabled()) { if (comboSettings->isEnabled()) {
GetSettings(); GetSettings();
} }
@ -614,5 +484,3 @@ void qTabSettings::Refresh() {
LOG(logDEBUG) << "**Updated Settings Tab"; LOG(logDEBUG) << "**Updated Settings Tab";
} }
} // namespace sls

View File

@ -165,9 +165,11 @@
#define PATTERN_OUT_LSB_REG (0x20 << MEM_MAP_SHIFT) #define PATTERN_OUT_LSB_REG (0x20 << MEM_MAP_SHIFT)
#define PATTERN_OUT_MSB_REG (0x21 << MEM_MAP_SHIFT) #define PATTERN_OUT_MSB_REG (0x21 << MEM_MAP_SHIFT)
/* Frame number of next acquisition register (64 bit register) */ /* Frames From Start 64 bit RO register TODO */
#define NEXT_FRAME_NUMB_LOCAL_LSB_REG (0x22 << MEM_MAP_SHIFT) //#define FRAMES_FROM_START_LSB_REG (0x22 << MEM_MAP_SHIFT) // Not
#define NEXT_FRAME_NUMB_LOCAL_MSB_REG (0x23 << MEM_MAP_SHIFT) // used in FW #define FRAMES_FROM_START_MSB_REG (0x23 <<
// MEM_MAP_SHIFT)
//// Not used in FW
/* Frames From Start PG 64 bit RO register. Reset using CONTROL_CRST. TODO */ /* Frames From Start PG 64 bit RO register. Reset using CONTROL_CRST. TODO */
#define FRAMES_FROM_START_PG_LSB_REG (0x24 << MEM_MAP_SHIFT) #define FRAMES_FROM_START_PG_LSB_REG (0x24 << MEM_MAP_SHIFT)

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