mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 00:07:13 +02:00
Compare commits
97 Commits
2020.03.06
...
2020.04.01
Author | SHA1 | Date | |
---|---|---|---|
03af145ee8 | |||
043e62f9fd | |||
6289163ac8 | |||
3ba9e5ec22 | |||
719157f5c3 | |||
d58eb1dc6e | |||
6a6af528ef | |||
112d120a89 | |||
8dfb55d476 | |||
d488f4bea8 | |||
58ab3c4123 | |||
02d7381788 | |||
fb051355b8 | |||
4d8a63eee1 | |||
d0c3e006fb | |||
f22f23849d | |||
94bddb9908 | |||
ed20e17c3a | |||
8fc1578a5e | |||
9753d075f0 | |||
865b4e50ad | |||
597c359ef8 | |||
a108a4df4c | |||
0a6b04ee76 | |||
78dd96357d | |||
9230182e35 | |||
8f7adb130f | |||
16d5321885 | |||
9a6f521f6a | |||
dee0aea378 | |||
0e3cd00579 | |||
6091271f37 | |||
272a8bfaf1 | |||
75692c3539 | |||
46e9b450c0 | |||
40c5ccfe37 | |||
bf1b1a2d9e | |||
b608ec6fbd | |||
4813b5567a | |||
8ab742c2b7 | |||
cb8403f1b0 | |||
b751238fc1 | |||
5479d3a198 | |||
e1768905dd | |||
775d0842e9 | |||
e7e201bd2a | |||
ec9f8305e9 | |||
3307bfab1b | |||
ce2c62000d | |||
cf817c4ec1 | |||
bd01a5f2d2 | |||
b059ba7c90 | |||
89d70097f6 | |||
41d115a394 | |||
45c1d3a553 | |||
17227be4df | |||
7f4f8e8f09 | |||
6809bd6567 | |||
711d40a56e | |||
81911fae3c | |||
f940397e3a | |||
dc53887a48 | |||
5784ce8231 | |||
012c66bbbf | |||
3dbd6a33f7 | |||
0de0d82a1a | |||
4aeb8bf62e | |||
2acf64b09c | |||
dea8cba985 | |||
9467b4c610 | |||
2cb09a590a | |||
5900403f20 | |||
53749c3b77 | |||
1d2f4a8af0 | |||
df2512fb1c | |||
e4942a5c8d | |||
ac1c40d6f9 | |||
8ba0ef093e | |||
cb268aa43f | |||
5192dae9c5 | |||
d818e2570f | |||
ee799b540a | |||
ae3189d836 | |||
9ede0629ef | |||
bd6529a64c | |||
758afad02c | |||
013836bea5 | |||
de6808b170 | |||
4c4ee3ae25 | |||
0e171f291d | |||
bd47c969dd | |||
e4a86e544a | |||
a4fa9ff480 | |||
c6ddd19c0f | |||
661adaf4ed | |||
ff9c37701b | |||
3431752649 |
@ -17,7 +17,8 @@ Checks: '*,
|
||||
-google-runtime-references,
|
||||
-google-readability-todo,
|
||||
-google-readability-braces-around-statements,
|
||||
-modernize-use-trailing-return-type'
|
||||
-modernize-use-trailing-return-type,
|
||||
-readability-isolate-declaration'
|
||||
|
||||
HeaderFilterRegex: \.h
|
||||
AnalyzeTemporaryDtors: false
|
||||
|
@ -46,7 +46,17 @@ option(SLS_BUILD_DOCS "docs" OFF)
|
||||
option(SLS_BUILD_EXAMPLES "examples" OFF)
|
||||
option(SLS_TUNE_LOCAL "tune to local machine" OFF)
|
||||
|
||||
|
||||
# Use ld.gold if it is available and isn't disabled explicitly
|
||||
option(SLS_USE_LD_GOLD "Use GNU gold linker" ON)
|
||||
if (SLS_USE_LD_GOLD)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
|
||||
if ("${LD_VERSION}" MATCHES "GNU gold")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=gold")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold")
|
||||
else ()
|
||||
message(WARNING "GNU gold linker isn't available, using the default system linker.")
|
||||
endif ()
|
||||
endif ()
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
@ -167,7 +177,7 @@ endif (SLS_USE_RECEIVER)
|
||||
|
||||
if (SLS_USE_GUI)
|
||||
find_package(Qt4 REQUIRED)
|
||||
find_package(Qwt 6 REQUIRED)
|
||||
find_package(Qwt 6.1 REQUIRED)
|
||||
if (QT4_FOUND AND QWT_FOUND)
|
||||
add_subdirectory(slsDetectorGui)
|
||||
endif()
|
||||
@ -203,11 +213,9 @@ if(SLS_BUILD_DOCS)
|
||||
add_subdirectory(docs)
|
||||
endif(SLS_BUILD_DOCS)
|
||||
|
||||
|
||||
|
||||
if(SLS_MASTER_PROJECT)
|
||||
# Set install dir CMake packages
|
||||
set(CMAKE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/cmake/sls)
|
||||
set(CMAKE_INSTALL_DIR "share/cmake/${PROJECT_NAME}")
|
||||
# Set the list of exported targets
|
||||
set(PROJECT_LIBRARIES slsSupportLib slsDetectorShared slsReceiverShared)
|
||||
# Generate and install package config file and version
|
||||
|
@ -15,17 +15,20 @@ configure_package_config_file(
|
||||
write_basic_package_version_file(
|
||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWER}-config-version.cmake"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY SameMajorVersion)
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
|
||||
install(FILES
|
||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWER}-config.cmake"
|
||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWER}-config-version.cmake"
|
||||
COMPONENT devel
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME_LOWER})
|
||||
DESTINATION ${CMAKE_INSTALL_DIR}
|
||||
)
|
||||
|
||||
if (PROJECT_LIBRARIES OR PROJECT_STATIC_LIBRARIES)
|
||||
install(
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
FILE ${PROJECT_NAME_LOWER}-targets.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME_LOWER})
|
||||
DESTINATION ${CMAKE_INSTALL_DIR}
|
||||
)
|
||||
endif ()
|
||||
|
19
cmk.sh
19
cmk.sh
@ -11,6 +11,7 @@ PYTHON=0
|
||||
TESTS=0
|
||||
SIMULATOR=0
|
||||
CTBGUI=0
|
||||
MANUALS=0
|
||||
|
||||
|
||||
CLEAN=0
|
||||
@ -19,7 +20,7 @@ CMAKE_PRE=""
|
||||
CMAKE_POST=""
|
||||
|
||||
usage() { echo -e "
|
||||
Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [s] [u] [i] [-h] [-d <HDF5 directory>] [-j] <Number of threads>
|
||||
Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [s] [u] [i] [m] [-h] [-d <HDF5 directory>] [-j] <Number of threads>
|
||||
-[no option]: only make
|
||||
-c: Clean
|
||||
-b: Builds/Rebuilds CMake files normal mode
|
||||
@ -34,6 +35,7 @@ Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [s] [u] [i] [-h] [-d <HDF5 directory>]
|
||||
-j: Number of threads to compile through
|
||||
-e: Debug mode
|
||||
-i: Builds tests
|
||||
-m: Manuals
|
||||
|
||||
Rebuild when you switch to a new build and compile in parallel:
|
||||
./cmk.sh -bj5
|
||||
@ -69,7 +71,7 @@ For rebuilding only certain sections
|
||||
|
||||
" ; exit 1; }
|
||||
|
||||
while getopts ":bpchd:j:trgeisu" opt ; do
|
||||
while getopts ":bpchd:j:trgeisum" opt ; do
|
||||
case $opt in
|
||||
b)
|
||||
echo "Building of CMake files Required"
|
||||
@ -124,6 +126,10 @@ while getopts ":bpchd:j:trgeisu" opt ; do
|
||||
echo "Compiling Options: Simulator"
|
||||
SIMULATOR=1
|
||||
;;
|
||||
m)
|
||||
echo "Compiling Manuals"
|
||||
MANUALS=1
|
||||
;;
|
||||
u)
|
||||
echo "Compiling Options: Chip Test Gui"
|
||||
CTBGUI=1
|
||||
@ -198,6 +204,12 @@ if [ $SIMULATOR -eq 1 ]; then
|
||||
echo "Simulator Option enabled"
|
||||
fi
|
||||
|
||||
#Manuals
|
||||
if [ $MANUALS -eq 1 ]; then
|
||||
CMAKE_POST+=" -DSLS_BUILD_DOCS=ON "
|
||||
echo "Manuals Option enabled"
|
||||
fi
|
||||
|
||||
#Chip Test Gui
|
||||
if [ $CTBGUI -eq 1 ]; then
|
||||
CMAKE_POST+=" -DSLS_USE_CTBGUI=ON "
|
||||
@ -251,6 +263,9 @@ else
|
||||
make
|
||||
fi
|
||||
|
||||
if [ $MANUALS -eq 1 ]; then
|
||||
make docs
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
@ -5,18 +5,20 @@ mkdir $PREFIX/include
|
||||
mkdir $PREFIX/include/slsDetectorPackage
|
||||
|
||||
#Shared and static libraries
|
||||
cp build/bin/libSlsDetector.so $PREFIX/lib/.
|
||||
cp build/bin/libSlsReceiver.so $PREFIX/lib/.
|
||||
cp build/bin/libSlsSupport.so $PREFIX/lib/.
|
||||
# cp build/bin/libSlsDetector.so $PREFIX/lib/.
|
||||
# cp build/bin/libSlsReceiver.so $PREFIX/lib/.
|
||||
# cp build/bin/libSlsSupport.so $PREFIX/lib/.
|
||||
|
||||
cp build/install/lib/* $PREFIX/lib/
|
||||
|
||||
#Binaries
|
||||
cp build/bin/sls_detector_acquire $PREFIX/bin/.
|
||||
cp build/bin/sls_detector_get $PREFIX/bin/.
|
||||
cp build/bin/sls_detector_put $PREFIX/bin/.
|
||||
cp build/bin/sls_detector_help $PREFIX/bin/.
|
||||
cp build/bin/slsReceiver $PREFIX/bin/.
|
||||
cp build/bin/slsMultiReceiver $PREFIX/bin/.
|
||||
cp build/install/bin/sls_detector_acquire $PREFIX/bin/.
|
||||
cp build/install/bin/sls_detector_get $PREFIX/bin/.
|
||||
cp build/install/bin/sls_detector_put $PREFIX/bin/.
|
||||
cp build/install/bin/sls_detector_help $PREFIX/bin/.
|
||||
cp build/install/bin/slsReceiver $PREFIX/bin/.
|
||||
cp build/install/bin/slsMultiReceiver $PREFIX/bin/.
|
||||
|
||||
#Which headers do we need for development??
|
||||
cp build/install/include/* $PREFIX/include/slsDetectorPackage/
|
||||
# cp include/some_lib.h $PREFIX/include/.
|
||||
|
||||
cp build/install/include/* $PREFIX/include/
|
||||
cp -r build/install/share/ $PREFIX/share
|
||||
|
@ -7,7 +7,7 @@ source:
|
||||
- path: ..
|
||||
|
||||
build:
|
||||
number: 2
|
||||
number: 0
|
||||
binary_relocation: True
|
||||
rpaths:
|
||||
- lib/
|
||||
@ -37,6 +37,7 @@ requirements:
|
||||
host:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- zeromq
|
||||
- xorg-libx11
|
||||
- xorg-libice
|
||||
- xorg-libxext
|
||||
@ -46,6 +47,7 @@ requirements:
|
||||
- xorg-libxfixes
|
||||
|
||||
run:
|
||||
- zeromq
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
|
||||
|
@ -1646,10 +1646,13 @@ void ctbAcquisition::update() {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
dBitOffset = myDet->getRxDbitOffset().tsquash("Different values");
|
||||
} CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::update")
|
||||
|
||||
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
|
||||
dBitOffset = 0;
|
||||
} else {
|
||||
try {
|
||||
dBitOffset = myDet->getRxDbitOffset().tsquash("Different values");
|
||||
} CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::update")
|
||||
}
|
||||
try {
|
||||
tenG = myDet->getTenGiga().tsquash("Different values");
|
||||
} CATCH_DISPLAY ("Could not get ten giga enable", "ctbAcquisition::update")
|
||||
@ -1735,9 +1738,13 @@ void ctbAcquisition::toggleAcquisition() {
|
||||
setDigitalSamples(retval);
|
||||
} CATCH_DISPLAY ("Could not get number of digital samples", "ctbAcquisition::toggleAcquisition")
|
||||
|
||||
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
|
||||
dBitOffset = 0;
|
||||
} else {
|
||||
try {
|
||||
dBitOffset = myDet->getRxDbitOffset().tsquash("Different values");
|
||||
} CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::toggleAcquisition")
|
||||
dBitOffset = myDet->getRxDbitOffset().tsquash("Different values");
|
||||
} CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::toggleAcquisition")
|
||||
}
|
||||
|
||||
try {
|
||||
roMode = static_cast<int>(myDet->getReadoutMode().tsquash("Different values"));
|
||||
@ -1974,14 +1981,18 @@ void ctbAcquisition::setDbitEnable(Int_t reg){
|
||||
void ctbAcquisition::updateChans() {
|
||||
|
||||
// dbit list
|
||||
try {
|
||||
auto retval = myDet->getRxDbitList().tsquash("Different values");
|
||||
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
|
||||
dbitlist.clear();
|
||||
if (!retval.empty()) {
|
||||
for (const auto &value : retval)
|
||||
dbitlist.push_back(value);
|
||||
}
|
||||
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbAcquisition::updateChans")
|
||||
} else {
|
||||
try {
|
||||
auto retval = myDet->getRxDbitList().tsquash("Different values");
|
||||
dbitlist.clear();
|
||||
if (!retval.empty()) {
|
||||
for (const auto &value : retval)
|
||||
dbitlist.push_back(value);
|
||||
}
|
||||
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbAcquisition::updateChans")
|
||||
}
|
||||
|
||||
// adc mask
|
||||
try {
|
||||
|
@ -374,33 +374,43 @@ void ctbSignals::update() {
|
||||
|
||||
} CATCH_DISPLAY ("Could not get patternIOcontrol.", "ctbSignals::update")
|
||||
|
||||
try {
|
||||
|
||||
auto dbitlist = myDet->getRxDbitList().tsquash("Different values");
|
||||
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
|
||||
// enable all
|
||||
if (dbitlist.empty()) {
|
||||
for (int is=0; is<64; is++) {
|
||||
signals[is]->setDbitList(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// disable all
|
||||
for (int is=0; is<64; is++) {
|
||||
signals[is]->setDbitList(0);
|
||||
for (int is=0; is<64; is++) {
|
||||
signals[is]->setDbitList(1);
|
||||
}
|
||||
eDbitOffset->SetNumber(0);
|
||||
}
|
||||
|
||||
// ctb
|
||||
else {
|
||||
try {
|
||||
|
||||
auto dbitlist = myDet->getRxDbitList().tsquash("Different values");
|
||||
// enable all
|
||||
if (dbitlist.empty()) {
|
||||
for (int is=0; is<64; is++) {
|
||||
signals[is]->setDbitList(1);
|
||||
}
|
||||
}
|
||||
// enable selected
|
||||
for (const auto &value : dbitlist) {
|
||||
signals[value]->setDbitList(1);
|
||||
else {
|
||||
// disable all
|
||||
for (int is=0; is<64; is++) {
|
||||
signals[is]->setDbitList(0);
|
||||
}
|
||||
// enable selected
|
||||
for (const auto &value : dbitlist) {
|
||||
signals[value]->setDbitList(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbSignals::update")
|
||||
|
||||
try {
|
||||
auto val = myDet->getRxDbitOffset().tsquash("Different values");
|
||||
eDbitOffset->SetNumber(val);
|
||||
} CATCH_DISPLAY ("Could not get receiver dbit offset.", "ctbSignals::update")
|
||||
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbSignals::update")
|
||||
|
||||
try {
|
||||
auto val = myDet->getRxDbitOffset().tsquash("Different values");
|
||||
eDbitOffset->SetNumber(val);
|
||||
} CATCH_DISPLAY ("Could not get receiver dbit offset.", "ctbSignals::update")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,69 +1,69 @@
|
||||
find_package(Doxygen)
|
||||
find_package(Sphinx)
|
||||
find_package(Doxygen REQUIRED)
|
||||
find_package(Sphinx REQUIRED)
|
||||
|
||||
|
||||
if (DOXYGEN_FOUND AND SPHINX_FOUND)
|
||||
message(${CMAKE_PROJECT_SORURCE_DIR}/slsDetectorSoftware/src)
|
||||
# Utility to generate command line documentation
|
||||
add_executable(gendoc src/gendoc.cpp)
|
||||
# This is a bit hacky, but better than exposing stuff?
|
||||
target_include_directories(gendoc PRIVATE ${PROJECT_SOURCE_DIR}/slsDetectorSoftware/src)
|
||||
target_link_libraries(gendoc PRIVATE
|
||||
slsDetectorShared
|
||||
)
|
||||
set_target_properties(gendoc PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
#Doxygen
|
||||
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
|
||||
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
|
||||
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
|
||||
# Utility to generate command line documentation
|
||||
add_executable(gendoc src/gendoc.cpp)
|
||||
# This is a bit hacky, but better than exposing stuff?
|
||||
target_include_directories(gendoc PRIVATE ${PROJECT_SOURCE_DIR}/slsDetectorSoftware/src)
|
||||
target_link_libraries(gendoc PRIVATE
|
||||
slsDetectorShared
|
||||
)
|
||||
set_target_properties(gendoc PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
#Sphinx
|
||||
set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
set(SPHINX_SOURCE_FILES
|
||||
src/commandline.rst
|
||||
src/container_utils.rst
|
||||
src/dependencies.rst
|
||||
src/detector.rst
|
||||
src/index.rst
|
||||
src/installation.rst
|
||||
src/pydetector.rst
|
||||
src/pyenums.rst
|
||||
src/pyexamples.rst
|
||||
src/receiver.rst
|
||||
src/result.rst
|
||||
src/type_traits.rst
|
||||
src/ToString.rst
|
||||
|
||||
)
|
||||
|
||||
foreach(filename ${SPHINX_SOURCE_FILES})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${filename}
|
||||
"${SPHINX_BUILD}/${filename}")
|
||||
endforeach(filename ${SPHINX_SOURCE_FILES})
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in"
|
||||
"${SPHINX_BUILD}/conf.py"
|
||||
@ONLY)
|
||||
#Doxygen
|
||||
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
|
||||
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
|
||||
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
|
||||
|
||||
#Sphinx
|
||||
set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
set(SPHINX_SOURCE_FILES
|
||||
src/commandline.rst
|
||||
src/container_utils.rst
|
||||
src/consuming.rst
|
||||
src/dependencies.rst
|
||||
src/detector.rst
|
||||
src/index.rst
|
||||
src/installation.rst
|
||||
src/pydetector.rst
|
||||
src/pyenums.rst
|
||||
src/pyexamples.rst
|
||||
src/receiver.rst
|
||||
src/result.rst
|
||||
src/type_traits.rst
|
||||
src/ToString.rst
|
||||
src/examples.rst
|
||||
|
||||
)
|
||||
|
||||
foreach(filename ${SPHINX_SOURCE_FILES})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${filename}
|
||||
"${SPHINX_BUILD}/${filename}")
|
||||
endforeach(filename ${SPHINX_SOURCE_FILES})
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in"
|
||||
"${SPHINX_BUILD}/conf.py"
|
||||
@ONLY)
|
||||
|
||||
add_custom_target(docs
|
||||
gendoc
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
|
||||
COMMAND ${SPHINX_EXECUTABLE} -a -b html
|
||||
-Dbreathe_projects.slsDetectorPackage=${CMAKE_CURRENT_BINARY_DIR}/xml
|
||||
-c "${SPHINX_BUILD}"
|
||||
${SPHINX_BUILD}/src
|
||||
${SPHINX_BUILD}/html
|
||||
COMMENT "Generating documentation with Sphinx")
|
||||
|
||||
add_custom_target(docs
|
||||
gendoc
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
|
||||
COMMAND ${SPHINX_EXECUTABLE} -a -b html
|
||||
-Dbreathe_projects.slsDetectorPackage=${CMAKE_CURRENT_BINARY_DIR}/xml
|
||||
-c "${SPHINX_BUILD}"
|
||||
${SPHINX_BUILD}/src
|
||||
${SPHINX_BUILD}/html
|
||||
COMMENT "Generating documentation with Sphinx")
|
||||
|
||||
else (DOXYGEN_FOUND AND SPHINX_FOUND)
|
||||
message("Doxygen and Sphinx are needed to build documentation")
|
||||
endif (DOXYGEN_FOUND AND SPHINX_FOUND)
|
||||
|
116
docs/src/consuming.rst
Normal file
116
docs/src/consuming.rst
Normal file
@ -0,0 +1,116 @@
|
||||
Consuming slsDetectorPackage
|
||||
===============================
|
||||
|
||||
Depending on how you want to build your integration with
|
||||
slsDetectorPackage there are a few different ways to
|
||||
consume our package. The recommended way is to use one of the
|
||||
CMake approaches.
|
||||
|
||||
|
||||
|
||||
CMake: slsDetectorPackage as submodule in your project
|
||||
---------------------------------------
|
||||
|
||||
If you are using CMake to build your integration and want to build everything
|
||||
in one go, we support adding slsDetectorPackage as a subfolder in your cmake project.
|
||||
|
||||
A minimal CMakeLists.txt could look like this:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
project(myDetectorIntegration)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
add_subdirectory(slsDetectorPackage)
|
||||
|
||||
#Add your executable
|
||||
add_executable(example main.cpp)
|
||||
target_compile_features(example PRIVATE cxx_std_11)
|
||||
|
||||
#Link towards slsDetectorShared
|
||||
target_link_libraries(example slsDetectorShared)
|
||||
|
||||
A fully working example can be found at:
|
||||
|
||||
https://github.com/slsdetectorgroup/cmake-subfolder-example
|
||||
|
||||
|
||||
CMake: find_package(slsDetectorPackage)
|
||||
------------------------------------------
|
||||
|
||||
If you have compiled and installed slsDetectorPackage we also support
|
||||
find_package in CMake. If installed in a system wide location no path
|
||||
should be needed, otherwise specify cmake prefix path.
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(myintegration)
|
||||
|
||||
find_package(slsDetectorPackage 5.0 REQUIRED)
|
||||
add_executable(example main.cpp)
|
||||
target_link_libraries(example slsDetectorShared)
|
||||
|
||||
|
||||
Then assuming the slsDetectorPackage is installed in /path/to/sls/install
|
||||
you should be able to configure and build your project in this way.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cmake ../path/to/your/source -DCMAKE_PREFIX_PATH=/path/to/sls/install
|
||||
make
|
||||
|
||||
|
||||
A minimal example is available at: https://github.com/slsdetectorgroup/minimal-cmake
|
||||
|
||||
|
||||
CMake: find_package and conda
|
||||
----------------------------------
|
||||
|
||||
.. note::
|
||||
|
||||
conda can also be used for installing dependencies such as zmq, Qt4 etc.
|
||||
|
||||
find_package(slsDetectorPackage) also works if you have installed slsDetectorPackage using conda.
|
||||
The only difference is that you point CMake to $CONDA_PREFIX
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
#assuming myenv contains slsdetlib
|
||||
conda activate myenv
|
||||
cmake ../path/to/your/source -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
|
||||
make
|
||||
|
||||
Depending on your system compiler you might also have to install gxx_linux-64 to compiled.
|
||||
|
||||
No tools minimal approach
|
||||
-----------------------------
|
||||
|
||||
While not recommended it is still possible to specify the include and library paths
|
||||
manually when invoking g++. This can sometimes be handy for a quick try.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
#include "Detector.h"
|
||||
#include <iostream>
|
||||
int main(){
|
||||
|
||||
sls::Detector det;
|
||||
|
||||
//Get all values and print them
|
||||
std::cout << "Hostname: " << det.getHostname() << "\n";
|
||||
std::cout << "Type: " << det.getDetectorType() << "\n";
|
||||
std::cout << "Udp ip: " << det.getSourceUDPIP() << "\n";
|
||||
|
||||
|
||||
//Get mac addr
|
||||
const int module = 0;
|
||||
auto mac = det.getSourceUDPMAC()[module];
|
||||
std::cout << "Mac addr of module "<< module << " is " << mac.str() << '\n';
|
||||
|
||||
}
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
g++ -I/install/path/include/ -L/install/path/lib64/ myapp.cpp -lSlsDetector -lSlsSupport -Wl,-rpath=../install/path/lib64
|
@ -13,7 +13,7 @@ To use the basic building blocks, meaning sls_detector_get/put and
|
||||
the shared libraries these are needed:
|
||||
|
||||
* Linux, preferably recent kernel (currently no cross platform support)
|
||||
* CMake > 3.9
|
||||
* CMake > 3.12
|
||||
* C++11 compatible compiler. (We test with gcc and clang)
|
||||
* ZeroMQ version 4
|
||||
|
||||
@ -24,7 +24,7 @@ GUI
|
||||
The GUI is currently using Qt4 but watch out for an upgrade to 5.
|
||||
|
||||
* Qt 4.8
|
||||
* Qwt 6
|
||||
* Qwt 6.1
|
||||
|
||||
-----------------------
|
||||
Python bindings
|
||||
|
115
docs/src/examples.rst
Normal file
115
docs/src/examples.rst
Normal file
@ -0,0 +1,115 @@
|
||||
|
||||
|
||||
|
||||
Examples
|
||||
===========
|
||||
|
||||
Setup
|
||||
------------
|
||||
|
||||
The examples here assume that you have compiled and installed slsDetectorPackage
|
||||
to ~/sls/install and that the option for SLS_USE_SIMULATOR was enabled. This also builds
|
||||
the virtual detector servers that we will be using for testing.
|
||||
|
||||
We also add ~/sls/detector/install/bin to the path for convenience.
|
||||
|
||||
Compile examples
|
||||
-------------------
|
||||
|
||||
The source code of the examples is available at:
|
||||
https://github.com/slsdetectorgroup/api-examples
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
git clone https://github.com/slsdetectorgroup/api-examples.git
|
||||
mkdir build && cd build
|
||||
cmake ../api-examples -DCMAKE_PREFIX_PATH=~/sls/detector/install
|
||||
make
|
||||
|
||||
Below follows a short description of what is included in the examples.
|
||||
|
||||
|
||||
Running a config file [e1]
|
||||
-----------------------------
|
||||
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
#include "Detector.h"
|
||||
...
|
||||
sls::Detector det;
|
||||
det.loadConfig("path/to/config/file.config");
|
||||
|
||||
|
||||
|
||||
To configure the connection between PC and detector the easiest
|
||||
is to run a config file. For this example we first launch a virtual Jungfrau server and
|
||||
then set up the detector.
|
||||
|
||||
**Launch a virtual detector server**
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
jungfrauDetectorServer_virtual
|
||||
|
||||
This launches a virtual Jungfrau detector server. As default is uses port 1952 and 1953
|
||||
for communication over TCP. Most commands go on 1952 and only stop and status on 1953.
|
||||
|
||||
**Run example to configure**
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
./e1-config one_det_no_receiver.config
|
||||
- 12:01:06.371 INFO: Shared memory deleted /slsDetectorPackage_multi_0_sls_0
|
||||
- 12:01:06.371 INFO: Shared memory deleted /slsDetectorPackage_multi_0
|
||||
- 12:01:06.372 INFO: Shared memory created /slsDetectorPackage_multi_0
|
||||
- 12:01:06.376 INFO: Loading configuration file: one_det_no_receiver.config
|
||||
- 12:01:06.376 INFO: Adding detector localhost
|
||||
- 12:01:06.377 INFO: Shared memory created /slsDetectorPackage_multi_0_sls_0
|
||||
- 12:01:06.377 INFO: Checking Detector Version Compatibility
|
||||
- 12:01:06.378 INFO: Detector connecting - updating!
|
||||
hostname [localhost]
|
||||
|
||||
|
||||
Jungfrau detector with 1 modules configured
|
||||
|
||||
|
||||
Using the return type sls::Result [e2]
|
||||
-----------------------------------------
|
||||
|
||||
Since many our detectors have multiple modules we cannot return
|
||||
a single value when reading from the Detector. Hostname, Ip and also
|
||||
for example exposure time can differ between modules.
|
||||
|
||||
Therefore we return Result<T> which is a thin wrapper around
|
||||
std::vector.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
sls::Result<int> res1{1, 1, 1};
|
||||
std::cout << "res1: " << res1 << '\n';
|
||||
res1.squash();
|
||||
res1.squash(-1);
|
||||
|
||||
|
||||
|
||||
Setting exposure time [e3]
|
||||
-----------------------------------------
|
||||
|
||||
For setting times, like exposure time, period, delay etc.
|
||||
we use std::chrono::duration.
|
||||
|
||||
Example 3 shows how to set and read exposure time as well
|
||||
as converting to floating point.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
#include "Detector.h"
|
||||
#include <chrono>
|
||||
...
|
||||
std::chrono::microseconds t0{500};
|
||||
det.setExptime(t0);
|
||||
|
||||
|
||||
|
@ -6,12 +6,18 @@
|
||||
Welcome to slsDetectorPackage's documentation!
|
||||
==============================================
|
||||
|
||||
.. note ::
|
||||
|
||||
This is the documentation for the latest development version of slsDetectorPackage
|
||||
For documentation on current and previous releases visit the official page: https://www.psi.ch/en/detectors/documentation
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: Installation:
|
||||
|
||||
installation
|
||||
dependencies
|
||||
consuming
|
||||
|
||||
.. toctree::
|
||||
:caption: C++ API
|
||||
@ -20,6 +26,7 @@ Welcome to slsDetectorPackage's documentation!
|
||||
detector
|
||||
result
|
||||
receiver
|
||||
examples
|
||||
|
||||
.. toctree::
|
||||
:caption: Python API
|
||||
|
@ -2,4 +2,68 @@
|
||||
Installation
|
||||
==============================================
|
||||
|
||||
get the source etc.
|
||||
Build from source using CMake
|
||||
---------------------------------
|
||||
|
||||
.. note ::
|
||||
|
||||
The default branch of our git repository is developer. It contains the
|
||||
latest development version. It is expected to compile and work but
|
||||
features might be added or tweaked. In some cases the API might also change
|
||||
without being communicated. If absolute stability of the API is needed please
|
||||
use one of the release versions.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git
|
||||
mkdir build && cd build
|
||||
cmake ../slsDetectorPackage -DCMAKE_INSTALL_PREFIX=/your/install/path
|
||||
make -j12
|
||||
make install
|
||||
|
||||
Install binaries using conda
|
||||
--------------------------------
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
#Add channels for dependencies and our library
|
||||
conda config --add channels conda-forge
|
||||
conda config --add channels slsdetectorgroup
|
||||
conda config --set channel_priority strict
|
||||
|
||||
#cerate an environment with our library, then activate
|
||||
conda create -n myenv slsdetlib=2020.03.18.dev2
|
||||
codna activate myenv
|
||||
|
||||
#ready to use
|
||||
sls_detector_get exptime
|
||||
etc ...
|
||||
|
||||
|
||||
|
||||
Build from source on old distributions
|
||||
-----------------------------------------
|
||||
|
||||
If your linux distribution doesn't come with a C++11 compiler (gcc>4.8) then
|
||||
it's possible to install a newer gcc using conda and build the slsDetectorPackage
|
||||
using this compiler
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
#Create an environment with the dependencies
|
||||
conda create -n myenv gxx_linux-64 cmake zmq
|
||||
conda activate myenv
|
||||
cmake ../slsDetectorPackage -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
|
||||
make -j12
|
||||
|
||||
|
||||
Build this documentation
|
||||
-------------------------------
|
||||
|
||||
The documentation for the slsDetectorPackage is build using a combination
|
||||
of Doxygen, Sphinx and Breathe. The easiest way to install the dependencies
|
||||
is to use conda
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
conda create -n myenv python sphinx sphinx_rtd_theme
|
@ -1,9 +1,9 @@
|
||||
Detector
|
||||
=====================================================
|
||||
|
||||
.. py:currentmodule:: sls_detector
|
||||
.. py:currentmodule:: slsdet
|
||||
|
||||
.. autoclass:: ExperimentalDetector
|
||||
.. autoclass:: Detector
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
@ -430,13 +430,13 @@ patwaittime2 0
|
||||
#############################################
|
||||
### edit with 10 Gbs IP of your server
|
||||
############################################
|
||||
#0:udp_dstip 10.1.1.102
|
||||
0:udp_dstip 129.129.202.136
|
||||
0:udp_dstip 10.1.1.102
|
||||
#0:udp_dstip 129.129.202.136
|
||||
#############################################
|
||||
### edit with any number in the subnet of your server (first 3 numbers as above)
|
||||
############################################
|
||||
#0:udp_srcip 10.1.1.19
|
||||
0:udp_srcip 129.129.202.13
|
||||
0:udp_srcip 10.1.1.19
|
||||
#0:udp_srcip 129.129.202.13
|
||||
|
||||
0:udp_dstport 33410
|
||||
#############################################
|
||||
@ -457,7 +457,7 @@ patwaittime2 0
|
||||
############################################
|
||||
rx_hostname mpc2011
|
||||
|
||||
tengiga 0
|
||||
tengiga 1
|
||||
|
||||
rx_datastream 1
|
||||
rx_readfreq 1
|
||||
|
@ -1,11 +1,15 @@
|
||||
#initialchecks 0
|
||||
initialchecks 0
|
||||
#############################################
|
||||
### edit with hostname or IP address of your detector
|
||||
############################################
|
||||
hostname bchip181+
|
||||
|
||||
#############################################
|
||||
### edit with hostname or 1Gbs IP address of your server
|
||||
############################################
|
||||
rx_hostname mpc2011
|
||||
|
||||
|
||||
rx_tcpport 1954
|
||||
#############################################
|
||||
### edit with 10 Gbs IP of your server
|
||||
############################################
|
||||
@ -14,24 +18,20 @@ udp_dstip 10.1.1.102
|
||||
### edit with any number in the subnet of your server (first 3 numbers as above)
|
||||
############################################
|
||||
udp_srcip 10.1.1.19
|
||||
udp_dstport 33410
|
||||
udp_dstport 32411
|
||||
|
||||
#############################################
|
||||
### edit with 10 Gbs IP of your server
|
||||
############################################
|
||||
#rx_zmqip 10.1.1.102
|
||||
#rx_zmqport 30001
|
||||
rx_zmqip 10.1.1.102
|
||||
rx_zmqport 50003
|
||||
#############################################
|
||||
### edit with 1 Gbs IP of PC where you will run the GUI
|
||||
############################################
|
||||
#zmqip 129.129.202.136
|
||||
#zmqport 40001
|
||||
zmqip 129.129.202.136
|
||||
zmqport 50001
|
||||
|
||||
|
||||
#############################################
|
||||
### edit with hostname or 1Gbs IP address of your server
|
||||
############################################
|
||||
rx_hostname mpc2011
|
||||
|
||||
|
||||
tengiga 1
|
||||
@ -39,8 +39,8 @@ rx_datastream 1
|
||||
|
||||
|
||||
|
||||
frames 1
|
||||
period 0.001
|
||||
frames 100000
|
||||
period 0.0006
|
||||
#############################################
|
||||
### edit with directory you want to write to
|
||||
############################################
|
||||
@ -48,8 +48,8 @@ fpath /mnt/moench_data/scratch/
|
||||
fwrite 0
|
||||
rx_datastream 1
|
||||
|
||||
rx_jsonpara frameMode newpedestal
|
||||
rx_jsonpara detectorMode analog
|
||||
rx_jsonpara frameMode frame
|
||||
rx_jsonpara detectorMode counting
|
||||
rx_discardpolicy discardpartial
|
||||
|
||||
|
||||
@ -58,4 +58,6 @@ adcpipeline 15
|
||||
powerchip 1
|
||||
vhighvoltage 90
|
||||
|
||||
adcreg 14 40
|
||||
#adcreg 0x14 0x40
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "ClientSocket.h"
|
||||
#include "logger.h"
|
||||
#include "DetectorImpl.h"
|
||||
#include "slsDetector.h"
|
||||
#include "Module.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include "Timer.h"
|
||||
@ -23,10 +23,10 @@
|
||||
// extern dt type;
|
||||
|
||||
TEST_CASE("Single detector no receiver", "[.integration][.single]") {
|
||||
auto t = slsDetector::getTypeFromDetector(test::hostname);
|
||||
auto t = Module::getTypeFromDetector(test::hostname);
|
||||
CHECK(t == test::type);
|
||||
|
||||
slsDetector d(t);
|
||||
Module d(t);
|
||||
CHECK(d.getDetectorTypeAsEnum() == t);
|
||||
CHECK(d.getDetectorTypeAsString() == test::detector_type);
|
||||
|
||||
@ -51,7 +51,7 @@ TEST_CASE("Set control port then create a new object with this control port",
|
||||
int new_cport = 1993;
|
||||
int new_sport = 2000;
|
||||
{
|
||||
slsDetector d(test::type);
|
||||
Module d(test::type);
|
||||
d.setHostname(test::hostname);
|
||||
CHECK(d.getControlPort() == old_cport);
|
||||
d.setControlPort(new_cport);
|
||||
@ -60,7 +60,7 @@ TEST_CASE("Set control port then create a new object with this control port",
|
||||
d.freeSharedMemory();
|
||||
}
|
||||
{
|
||||
slsDetector d(test::type);
|
||||
Module d(test::type);
|
||||
d.setHostname(test::hostname);
|
||||
d.setControlPort(new_cport);
|
||||
d.setStopPort(new_sport);
|
||||
@ -73,7 +73,7 @@ TEST_CASE("Set control port then create a new object with this control port",
|
||||
d.freeSharedMemory();
|
||||
}
|
||||
|
||||
slsDetector d(test::type);
|
||||
Module d(test::type);
|
||||
d.setHostname(test::hostname);
|
||||
CHECK(d.getStopPort() == DEFAULT_PORTNO + 1);
|
||||
d.freeSharedMemory();
|
||||
@ -86,11 +86,11 @@ TEST_CASE("single EIGER detector no receiver basic set and get",
|
||||
SingleDetectorConfig c;
|
||||
|
||||
// Read type by connecting to the detector
|
||||
auto type = slsDetector::getTypeFromDetector(c.hostname);
|
||||
auto type = Module::getTypeFromDetector(c.hostname);
|
||||
CHECK(type == c.type_enum);
|
||||
|
||||
// Create slsDetector of said type and set hostname and detector online
|
||||
slsDetector d(type);
|
||||
// Create Module of said type and set hostname and detector online
|
||||
Module d(type);
|
||||
CHECK(d.getDetectorTypeAsEnum() == type);
|
||||
CHECK(d.getDetectorTypeAsString() == c.type_string);
|
||||
|
||||
@ -133,7 +133,7 @@ TEST_CASE("single EIGER detector no receiver basic set and get",
|
||||
|
||||
|
||||
TEST_CASE("Locking mechanism and last ip", "[.integration][.single]") {
|
||||
slsDetector d(test::type);
|
||||
Module d(test::type);
|
||||
d.setHostname(test::hostname);
|
||||
|
||||
// Check that detector server is unlocked then lock
|
||||
@ -155,7 +155,7 @@ TEST_CASE("Locking mechanism and last ip", "[.integration][.single]") {
|
||||
}
|
||||
|
||||
TEST_CASE("Set settings", "[.integration][.single]"){
|
||||
slsDetector d(test::type);
|
||||
Module d(test::type);
|
||||
d.setHostname(test::hostname);
|
||||
CHECK(d.setSettings(defs::STANDARD) == defs::STANDARD);
|
||||
}
|
||||
@ -185,7 +185,7 @@ TEST_CASE("Timer functions", "[.integration][cli]") {
|
||||
// MEASURED_SUBPERIOD, /**< measured subperiod */
|
||||
// MAX_TIMERS
|
||||
|
||||
slsDetector d(test::type);
|
||||
Module d(test::type);
|
||||
d.setHostname(test::hostname);
|
||||
|
||||
// Number of frames
|
||||
@ -226,8 +226,8 @@ TEST_CASE("Timer functions", "[.integration][cli]") {
|
||||
|
||||
// TEST_CASE("Aquire", "[.integration][eiger]"){
|
||||
// SingleDetectorConfig c;
|
||||
// auto type = slsDetector::getTypeFromDetector(c.hostname);
|
||||
// slsDetector d(type);
|
||||
// auto type = Module::getTypeFromDetector(c.hostname);
|
||||
// Module d(type);
|
||||
// d.setHostname(c.hostname);
|
||||
|
||||
// auto period = 1000000000;
|
||||
|
@ -13,12 +13,18 @@ import argparse
|
||||
|
||||
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"
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-p", "--build_path", help="Path to the build database", type = str, default=default_build_path)
|
||||
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)
|
||||
@ -26,7 +32,7 @@ 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++')
|
||||
syspath = system_include_paths("clang++")
|
||||
incargs = ["-I" + inc for inc in syspath]
|
||||
args = args + incargs
|
||||
|
||||
@ -39,6 +45,7 @@ ag = []
|
||||
|
||||
lines = []
|
||||
|
||||
ag2 = []
|
||||
|
||||
def get_arguments(node):
|
||||
args = [a.type.spelling for a in node.get_arguments()]
|
||||
@ -46,9 +53,21 @@ def get_arguments(node):
|
||||
"py::arg() = Positions{}" if item == "sls::Positions" else "py::arg()"
|
||||
for item in args
|
||||
]
|
||||
args = ', '.join(args)
|
||||
args = ", ".join(args)
|
||||
if args:
|
||||
args = f', {args}'
|
||||
args = f", {args}"
|
||||
return args
|
||||
|
||||
|
||||
def get_fdec(node):
|
||||
args = [a.type.spelling for a in node.get_arguments()]
|
||||
if node.result_type.spelling:
|
||||
return_type = node.result_type.spelling
|
||||
else:
|
||||
return_type = 'void'
|
||||
|
||||
args = ", ".join(args)
|
||||
args = f'({return_type}(Detector::*)({args}))'
|
||||
return args
|
||||
|
||||
|
||||
@ -62,23 +81,36 @@ def visit(node):
|
||||
):
|
||||
m.append(child)
|
||||
args = get_arguments(child)
|
||||
lines.append(f'.def(\"{child.spelling}\", &Detector::{child.spelling}{args})')
|
||||
fs = get_fdec(child)
|
||||
lines.append(
|
||||
f'.def("{child.spelling}",{fs} &Detector::{child.spelling}{args})'
|
||||
)
|
||||
for child in node.get_children():
|
||||
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())
|
||||
|
||||
|
||||
visit(tu.cursor)
|
||||
|
||||
|
||||
with open('../src/detector_in.cpp') as f:
|
||||
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'
|
||||
with open('../src/detector.cpp', 'w') as f:
|
||||
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"
|
||||
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'])
|
||||
subprocess.run(["clang-format", "../src/detector.cpp", "-i"])
|
||||
|
||||
|
0
python/scripts/list_tested_cmd.py
Normal file → Executable file
0
python/scripts/list_tested_cmd.py
Normal file → Executable file
@ -45,7 +45,7 @@ ext_modules = [
|
||||
# get_pybind_include(),
|
||||
# get_pybind_include(user=True),
|
||||
os.path.join('../libs/pybind11/include'),
|
||||
os.path.join(get_conda_path(), 'include/slsDetectorPackage'),
|
||||
os.path.join(get_conda_path(), 'include'),
|
||||
|
||||
],
|
||||
libraries=['SlsDetector', 'SlsReceiver', 'zmq'],
|
||||
|
@ -1,5 +1,6 @@
|
||||
from _slsdet import CppDetectorApi
|
||||
from _slsdet import slsDetectorDefs
|
||||
from _slsdet import IpAddr, MacAddr
|
||||
|
||||
runStatus = slsDetectorDefs.runStatus
|
||||
speedLevel = slsDetectorDefs.speedLevel
|
||||
@ -12,12 +13,13 @@ import datetime as dt
|
||||
|
||||
from functools import wraps
|
||||
from collections import namedtuple
|
||||
import socket
|
||||
|
||||
def freeze(cls):
|
||||
cls._frozen = False
|
||||
|
||||
def frozensetattr(self, key, value):
|
||||
if self._frozen and not hasattr(self, key):
|
||||
if self._frozen and not key in dir(self):
|
||||
raise AttributeError(
|
||||
"Class {} is frozen. Cannot set {} = {}".format(
|
||||
cls.__name__, key, value
|
||||
@ -58,7 +60,6 @@ class Detector(CppDetectorApi):
|
||||
self._adc_register = Adc_register(self)
|
||||
|
||||
|
||||
|
||||
# CONFIGURATION
|
||||
def __len__(self):
|
||||
return self.size()
|
||||
@ -71,9 +72,6 @@ class Detector(CppDetectorApi):
|
||||
def free(self):
|
||||
self.freeSharedMemory()
|
||||
|
||||
|
||||
|
||||
|
||||
@property
|
||||
def config(self):
|
||||
return NotImplementedError("config is set only")
|
||||
@ -92,6 +90,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@property
|
||||
def hostname(self):
|
||||
print('getting host!')
|
||||
return self.getHostname()
|
||||
|
||||
@hostname.setter
|
||||
@ -422,7 +421,9 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@udp_dstip.setter
|
||||
def udp_dstip(self, ip):
|
||||
self.getDestinationUDPIP(ip)
|
||||
if ip == 'auto':
|
||||
ip = socket.gethostbyname(self.rx_hostname)
|
||||
self.setDestinationUDPIP(IpAddr(ip))
|
||||
|
||||
@property
|
||||
def udp_dstip2(self):
|
||||
@ -430,7 +431,9 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@udp_dstip2.setter
|
||||
def udp_dstip2(self, ip):
|
||||
self.getDestinationUDPIP2(ip)
|
||||
if ip == 'auto':
|
||||
ip = socket.gethostbyname(self.rx_hostname)
|
||||
self.setDestinationUDPIP2(IpAddr(ip))
|
||||
|
||||
@property
|
||||
def udp_dstmac(self):
|
||||
@ -438,7 +441,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@udp_dstmac.setter
|
||||
def udp_dstmac(self, mac):
|
||||
self.getDestinationUDPMAC2(mac)
|
||||
self.setDestinationUDPMAC(MacAddr(mac))
|
||||
|
||||
@property
|
||||
def udp_dstmac2(self):
|
||||
@ -446,7 +449,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@udp_dstmac2.setter
|
||||
def udp_dstmac2(self, mac):
|
||||
self.getDestinationUDPMAC2(mac)
|
||||
self.setDestinationUDPMAC2(MacAddr(mac))
|
||||
|
||||
|
||||
@property
|
||||
@ -455,7 +458,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@udp_srcip.setter
|
||||
def udp_srcip(self, ip):
|
||||
self.setSourceUDPIP(ip)
|
||||
self.setSourceUDPIP(IpAddr(ip))
|
||||
|
||||
@property
|
||||
def udp_srcip2(self):
|
||||
@ -487,7 +490,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@src_udpmac.setter
|
||||
def src_udpmac(self, mac):
|
||||
self.setSourceUDPMAC(mac)
|
||||
self.setSourceUDPMAC(MacAddr(mac))
|
||||
|
||||
@property
|
||||
def src_udpip2(self):
|
||||
@ -495,7 +498,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@src_udpip2.setter
|
||||
def src_udpip2(self, ip):
|
||||
self.setSourceUDPIP(ip)
|
||||
self.setSourceUDPIP(IpAddr(ip))
|
||||
|
||||
@property
|
||||
def src_udpip(self):
|
||||
@ -503,7 +506,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@src_udpip.setter
|
||||
def src_udpip(self, ip):
|
||||
self.setSourceUDPIP(ip)
|
||||
self.setSourceUDPIP(IpAddr(ip))
|
||||
|
||||
|
||||
@property
|
||||
@ -512,7 +515,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@src_udpmac2.setter
|
||||
def src_udpmac2(self, mac):
|
||||
self.setSourceUDPMAC2(mac)
|
||||
self.setSourceUDPMAC2(MacAddr(mac))
|
||||
|
||||
@property
|
||||
def vhighvoltage(self):
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -12,6 +12,8 @@ namespace py = pybind11;
|
||||
void init_det(py::module &m) {
|
||||
using sls::Detector;
|
||||
using sls::Positions;
|
||||
using sls::Result;
|
||||
using sls::defs;
|
||||
|
||||
py::class_<Detector> CppDetectorApi(m, "CppDetectorApi");
|
||||
CppDetectorApi
|
||||
|
@ -184,6 +184,11 @@ void init_enums(py::module &m) {
|
||||
.value("VB_PIXBUF", slsDetectorDefs::dacIndex::VB_PIXBUF)
|
||||
.value("VIN_COM", slsDetectorDefs::dacIndex::VIN_COM)
|
||||
.value("VDD_PROT", slsDetectorDefs::dacIndex::VDD_PROT)
|
||||
.value("VBP_COLBUF", slsDetectorDefs::dacIndex::VBP_COLBUF)
|
||||
.value("VB_SDA", slsDetectorDefs::dacIndex::VB_SDA)
|
||||
.value("VCASC_SFP", slsDetectorDefs::dacIndex::VCASC_SFP)
|
||||
.value("VIPRE_CDS", slsDetectorDefs::dacIndex::VIPRE_CDS)
|
||||
.value("IBIAS_SFP", slsDetectorDefs::dacIndex::IBIAS_SFP)
|
||||
.value("V_POWER_A", slsDetectorDefs::dacIndex::V_POWER_A)
|
||||
.value("V_POWER_B", slsDetectorDefs::dacIndex::V_POWER_B)
|
||||
.value("V_POWER_C", slsDetectorDefs::dacIndex::V_POWER_C)
|
||||
@ -224,6 +229,18 @@ void init_enums(py::module &m) {
|
||||
.value("FORCESWITCHG2",
|
||||
slsDetectorDefs::detectorSettings::FORCESWITCHG2)
|
||||
.value("VERYLOWGAIN", slsDetectorDefs::detectorSettings::VERYLOWGAIN)
|
||||
.value("G1_HIGHGAIN", slsDetectorDefs::detectorSettings::G1_HIGHGAIN)
|
||||
.value("G1_LOWGAIN", slsDetectorDefs::detectorSettings::G1_LOWGAIN)
|
||||
.value("G2_HIGHCAP_HIGHGAIN",
|
||||
slsDetectorDefs::detectorSettings::G2_HIGHCAP_HIGHGAIN)
|
||||
.value("G2_HIGHCAP_LOWGAIN",
|
||||
slsDetectorDefs::detectorSettings::G2_HIGHCAP_LOWGAIN)
|
||||
.value("G2_LOWCAP_HIGHGAIN",
|
||||
slsDetectorDefs::detectorSettings::G2_LOWCAP_HIGHGAIN)
|
||||
.value("G2_LOWCAP_LOWGAIN",
|
||||
slsDetectorDefs::detectorSettings::G2_LOWCAP_LOWGAIN)
|
||||
.value("G4_HIGHGAIN", slsDetectorDefs::detectorSettings::G4_HIGHGAIN)
|
||||
.value("G4_LOWGAIN", slsDetectorDefs::detectorSettings::G4_LOWGAIN)
|
||||
.value("UNDEFINED", slsDetectorDefs::detectorSettings::UNDEFINED)
|
||||
.value("UNINITIALIZED",
|
||||
slsDetectorDefs::detectorSettings::UNINITIALIZED)
|
||||
|
@ -15,10 +15,11 @@ using sls::IpAddr;
|
||||
using sls::MacAddr;
|
||||
void init_network(py::module &m) {
|
||||
|
||||
py::class_ <IpAddr> IpAddr(m, "IpAddr");
|
||||
IpAddr.def(py::init())
|
||||
py::class_ <IpAddr>(m, "IpAddr")
|
||||
.def(py::init())
|
||||
.def(py::init<const std::string&>())
|
||||
.def(py::init<uint32_t>())
|
||||
.def(py::init<const IpAddr&>())
|
||||
.def("hex", &IpAddr::hex)
|
||||
.def("uint32", &IpAddr::uint32)
|
||||
.def(py::self == py::self)
|
||||
@ -26,10 +27,11 @@ void init_network(py::module &m) {
|
||||
.def("str", &IpAddr::str);
|
||||
|
||||
|
||||
py::class_ <MacAddr> MacAddr(m, "MacAddr");
|
||||
MacAddr.def(py::init())
|
||||
py::class_ <MacAddr>(m, "MacAddr")
|
||||
.def(py::init())
|
||||
.def(py::init<const std::string&>())
|
||||
.def(py::init<uint64_t>())
|
||||
.def(py::init<const MacAddr&>())
|
||||
.def("hex", &MacAddr::hex)
|
||||
.def(py::self == py::self)
|
||||
.def("uint64", &MacAddr::uint64)
|
||||
|
@ -1,36 +1,35 @@
|
||||
add_executable(a api.cpp)
|
||||
target_link_libraries(a
|
||||
slsDetectorShared
|
||||
add_executable(using_logger using_logger.cpp)
|
||||
target_link_libraries(using_logger
|
||||
slsSupportLib
|
||||
pthread
|
||||
rt
|
||||
)
|
||||
|
||||
set_target_properties(a PROPERTIES
|
||||
set_target_properties(using_logger PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
|
||||
add_executable(result useResult.cpp)
|
||||
target_link_libraries(result
|
||||
slsDetectorShared
|
||||
)
|
||||
# add_executable(result useResult.cpp)
|
||||
# target_link_libraries(result
|
||||
# slsDetectorShared
|
||||
# )
|
||||
|
||||
set_target_properties(result PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
# set_target_properties(result PROPERTIES
|
||||
# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
# )
|
||||
|
||||
add_executable(udp udp.cpp)
|
||||
target_link_libraries(udp
|
||||
slsDetectorShared
|
||||
slsSupportLib
|
||||
pthread
|
||||
rt
|
||||
fmt
|
||||
)
|
||||
# add_executable(udp udp.cpp)
|
||||
# target_link_libraries(udp
|
||||
# slsDetectorShared
|
||||
# slsSupportLib
|
||||
# pthread
|
||||
# rt
|
||||
# fmt
|
||||
# )
|
||||
|
||||
set_target_properties(udp PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
# set_target_properties(udp PROPERTIES
|
||||
# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
# )
|
||||
|
||||
|
||||
|
42
sample/using_logger.cpp
Normal file
42
sample/using_logger.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
#include "logger.h"
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
int main() {
|
||||
|
||||
//compare old and new
|
||||
std::cout << "Compare output between old and new:\n";
|
||||
LOG(logINFO) << "Some info message";
|
||||
LOG(logERROR) << "This is an error";
|
||||
LOG(logWARNING) << "While this is only a warning";
|
||||
|
||||
//Logging level can be configure at runtime
|
||||
std::cout << "\n\n";
|
||||
std::cout << "The default macro controlled level is: "
|
||||
<< sls::Logger::ToString(LOG_MAX_REPORTING_LEVEL) << '\n';
|
||||
|
||||
sls::Logger::ReportingLevel() = logERROR;
|
||||
LOG(logINFO) << "Now this is not written";
|
||||
LOG(logWARNING) << "and also not this";
|
||||
|
||||
sls::Logger::ReportingLevel() = logINFO;
|
||||
LOG(logINFO) << "But now we can see it";
|
||||
|
||||
|
||||
//The output can be redirected to another buffer
|
||||
std::ostringstream local;
|
||||
auto clog_buff = std::clog.rdbuf();
|
||||
std::clog.rdbuf(local.rdbuf());
|
||||
|
||||
LOG(logINFOBLUE) << "A message";
|
||||
LOG(logWARNING) << "And another one";
|
||||
|
||||
std::clog.rdbuf(clog_buff); // restore
|
||||
|
||||
std::cout << "local buf:\n" << local.str();
|
||||
|
||||
LOG(logINFO) << "After reset we should print directly";
|
||||
LOG(logINFOBLUE) << "some infoBLUE text";
|
||||
LOG(logINFOGREEN) << "some infoGREEN text";
|
||||
LOG(logINFORED) << "some infoRED text";
|
||||
|
||||
}
|
@ -14,27 +14,27 @@ class MovingStat
|
||||
/** constructor
|
||||
\param nn number of samples parameter to be used
|
||||
*/
|
||||
MovingStat(int nn=1000) : n(nn), m_n(0) {}
|
||||
|
||||
MovingStat(int nn) : n(nn), m_n(0), m_newM(0),m_newM2(0) {}
|
||||
// void setPointers(double *me, double *va) {mean=me; var=va;}
|
||||
/**
|
||||
clears the moving average number of samples parameter, mean and standard deviation
|
||||
*/
|
||||
void Clear()
|
||||
{
|
||||
void Clear()
|
||||
{
|
||||
m_n = 0;
|
||||
m_newM=0;
|
||||
m_newM2=0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
clears the moving average number of samples parameter, mean and standard deviation
|
||||
*/
|
||||
void Set(double val, double rms=0, int m=-1)
|
||||
{
|
||||
if (m>0) m_n = m; else m_n = n;
|
||||
if (m>=0) m_n = m; else m_n = n;
|
||||
m_newM=val*m_n;
|
||||
// cout << "set " << val << " " << m << " " << m_n << " " << m_newM << endl;
|
||||
SetRMS(rms);
|
||||
// cout << "set " << val << " " << m << " " << m_n << " " << m_newM << endl;
|
||||
}
|
||||
/**
|
||||
clears the moving average number of samples parameter, mean and standard deviation
|
||||
@ -42,12 +42,15 @@ class MovingStat
|
||||
void SetRMS(double rms)
|
||||
{
|
||||
if (rms<=0) {
|
||||
m_newM2=m_newM*m_newM/n;
|
||||
if (m_n>0)
|
||||
m_newM2=m_newM*m_newM/m_n;
|
||||
else
|
||||
m_newM2=0;
|
||||
//m_n=0;
|
||||
} else {
|
||||
if (m_n>0)
|
||||
if (m_n>0) {
|
||||
m_newM2=(m_n*rms*rms+m_newM*m_newM/m_n);
|
||||
else {
|
||||
} else {
|
||||
m_newM2=(m_n*rms*rms+m_newM*m_newM/n);
|
||||
m_n=0;
|
||||
}
|
||||
@ -102,13 +105,14 @@ class MovingStat
|
||||
m_newM = x;
|
||||
m_newM2 = x*x;
|
||||
m_n++;
|
||||
} else {
|
||||
m_newM = m_newM + x - m_newM/m_n;
|
||||
m_newM2 = m_newM2 + x*x - m_newM2/m_n;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
m_newM = m_newM + x - m_newM/m_n;
|
||||
m_newM2 = m_newM2 + x*x - m_newM2/m_n;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** returns the current number of elements of the moving average
|
||||
\returns returns the current number of elements of the moving average
|
||||
*/
|
||||
@ -122,7 +126,9 @@ class MovingStat
|
||||
inline double Mean() const
|
||||
{
|
||||
// cout << "get " << m_n << " " << m_newM << " " << m_newM/m_n << endl;
|
||||
return (m_n > 0) ? m_newM/m_n : 0.0;
|
||||
|
||||
|
||||
return (m_n > 0) ? m_newM/m_n : 0.0;
|
||||
}
|
||||
|
||||
/** returns the squared mean, 0 if no elements are inside
|
||||
@ -138,7 +144,7 @@ class MovingStat
|
||||
*/
|
||||
inline double Variance() const
|
||||
{
|
||||
return ( (m_n > 1) ? (M2()-Mean()*Mean()) : 0.0 );
|
||||
return (m_n > 0) ? m_newM2/m_n-m_newM/m_n*m_newM/m_n : 0.0;
|
||||
}
|
||||
|
||||
/** returns the standard deviation, 0 if no elements are inside
|
||||
@ -146,7 +152,8 @@ class MovingStat
|
||||
*/
|
||||
inline double StandardDeviation() const
|
||||
{
|
||||
return ( (Variance() > 0) ? sqrt( Variance() ) : -1 );
|
||||
|
||||
return sqrt(Variance());//
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -68,10 +68,15 @@ template <class dataType> class analogDetector {
|
||||
det->getDetectorSize(nx,ny);
|
||||
|
||||
stat=new pedestalSubtraction*[ny];
|
||||
/* pedMean=new double*[ny]; */
|
||||
/* pedVariance=new double*[ny]; */
|
||||
for (int i=0; i<ny; i++) {
|
||||
stat[i]=new pedestalSubtraction[nx];
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
/* pedMean[i]=new double[nx]; */
|
||||
/* pedVariance[i]=new double[nx]; */
|
||||
for (ix=0; ix<nx; ++ix) {
|
||||
stat[i][ix].SetNPedestals(nped);
|
||||
/* stat[i][ix].setPointers(&(pedMean[iy][ix]),&(pedVariance[iy][ix])); */
|
||||
}
|
||||
}
|
||||
image=new int[nx*ny];
|
||||
@ -95,7 +100,16 @@ template <class dataType> class analogDetector {
|
||||
/**
|
||||
destructor. Deletes the pdestalSubtraction array and the image
|
||||
*/
|
||||
virtual ~analogDetector() {for (int i=0; i<ny; i++) delete [] stat[i]; delete [] stat; delete [] image;
|
||||
virtual ~analogDetector() {
|
||||
for (int i=0; i<ny; i++) {
|
||||
delete [] stat[i];
|
||||
/* delete [] pedMean[i]; */
|
||||
/* delete [] pedVariance[i]; */
|
||||
};
|
||||
/* delete [] pedMean; */
|
||||
/* delete [] pedVariance; */
|
||||
delete [] stat;
|
||||
delete [] image;
|
||||
#ifdef ROOTSPECTRUM
|
||||
delete hs;
|
||||
#ifdef ROOTCLUST
|
||||
@ -132,16 +146,23 @@ template <class dataType> class analogDetector {
|
||||
|
||||
|
||||
stat=new pedestalSubtraction*[ny];
|
||||
/* pedMean=new double*[ny]; */
|
||||
/* pedVariance=new double*[ny]; */
|
||||
for (int i=0; i<ny; i++) {
|
||||
stat[i]=new pedestalSubtraction[nx];
|
||||
/* pedMean[i]=new double[nx]; */
|
||||
/* pedVariance[i]=new double[nx]; */
|
||||
}
|
||||
|
||||
int nped=orig->SetNPedestals();
|
||||
//cout << nped << " " << orig->getPedestal(ix,iy) << orig->getPedestalRMS(ix,iy) << endl;
|
||||
for (int iy=0; iy<ny; iy++) {
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
for (iy=0; iy<ny; ++iy) {
|
||||
for (ix=0; ix<nx; ++ix) {
|
||||
//stat[iy][ix].setPointers(&(pedMean[iy][ix]),&(pedVariance[iy][ix]));
|
||||
stat[iy][ix].SetNPedestals(nped);
|
||||
setPedestal(ix,iy,orig->getPedestal(ix,iy),orig->getPedestalRMS(ix,iy),orig->GetNPedestals(ix,iy));
|
||||
/* if (ix==50 && iy==50) */
|
||||
/* cout << "clone ped " << " " << ix << " " << iy << " " << getPedestal(ix,iy) << " " << getPedestalRMS(ix,iy)<< " " << GetNPedestals(ix,iy) << endl; */
|
||||
}
|
||||
}
|
||||
image=new int[nx*ny];
|
||||
@ -199,7 +220,7 @@ template <class dataType> class analogDetector {
|
||||
\param nns reference to number of subpixels for interpolating detector, will always be 1 in this case
|
||||
\returns number of pixels of the detector image
|
||||
*/
|
||||
virtual int getImageSize(int &nnx, int &nny, int &nns){nnx=nx; nny=ny; nns=1; return nx*ny;};
|
||||
virtual int getImageSize(int &nnx, int &nny, int &nnsx, int &nnsy){nnx=nx; nny=ny; nnsx=1; nnsy=1; return nx*ny;};
|
||||
/**
|
||||
Returns data size of the detector image matrix
|
||||
\param nnx reference to pixel size in x
|
||||
@ -231,8 +252,8 @@ template <class dataType> class analogDetector {
|
||||
if (gm) {
|
||||
if (gmap) delete [] gmap;
|
||||
gmap=new double[nnx*nny];
|
||||
for (int iy=0; iy<nny; iy++) {
|
||||
for (int ix=0; ix<nnx; ix++) {
|
||||
for (iy=0; iy<nny; ++iy) {
|
||||
for (ix=0; ix<nnx; ++ix) {
|
||||
gmap[iy*nnx+ix]=gm[iy*nnx+ix];
|
||||
// cout << gmap[iy*nnx+ix] << " " ;
|
||||
}
|
||||
@ -251,8 +272,8 @@ template <class dataType> class analogDetector {
|
||||
void *ret;
|
||||
if (gmap) {
|
||||
gm=new float[nx*ny];
|
||||
for (int iy=0; iy<ny; iy++) {
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
for (iy=0; iy<ny; ++iy) {
|
||||
for (ix=0; ix<nx; ++ix) {
|
||||
gm[iy*nx+ix]=gmap[iy*nx+ix];
|
||||
}
|
||||
}
|
||||
@ -267,8 +288,8 @@ template <class dataType> class analogDetector {
|
||||
|
||||
virtual void newDataSet(){
|
||||
iframe=-1;
|
||||
for (int iy=0; iy<ny; iy++)
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
for (iy=0; iy<ny; ++iy)
|
||||
for (ix=0; ix<nx; ++ix) {
|
||||
stat[iy][ix].Clear();
|
||||
image[iy*nx+ix]=0;
|
||||
}
|
||||
@ -285,15 +306,17 @@ template <class dataType> class analogDetector {
|
||||
};
|
||||
|
||||
/** resets the commonModeSubtraction and increases the frame index */
|
||||
virtual void newFrame(){iframe++; if (cmSub) cmSub->newFrame();};
|
||||
virtual void newFrame(){iframe++; if (cmSub) cmSub->newFrame(); det->newFrame();};
|
||||
|
||||
/** resets the commonModeSubtraction and increases the frame index */
|
||||
virtual void newFrame(char *data){
|
||||
iframe++;
|
||||
if (cmSub) cmSub->newFrame();
|
||||
det->newFrame();
|
||||
// det->getData(data);
|
||||
calcGhost(data);
|
||||
// cout << getId() << " Calc ghost " << getGhost(15,15) << endl;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/** sets the commonModeSubtraction algorithm to be used
|
||||
@ -359,8 +382,8 @@ template <class dataType> class analogDetector {
|
||||
// cout << "+"<< getId() << endl;
|
||||
if (cmSub) {
|
||||
//cout << "*" << endl;
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (iy=ymin; iy<ymax; ++iy) {
|
||||
for (ix=xmin; ix<xmax; ++ix) {
|
||||
// if (getNumpedestals(ix,iy)>0)
|
||||
// if (det->isGood(ix,iy)) {
|
||||
addToCommonMode(data, ix, iy);
|
||||
@ -403,8 +426,10 @@ template <class dataType> class analogDetector {
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
|
||||
if (cmSub && cm>0) {
|
||||
return stat[iy][ix].getPedestal()+getCommonMode(ix,iy);
|
||||
|
||||
} else return stat[iy][ix].getPedestal();
|
||||
//return pedMean[iy][ix]+getCommonMode(ix,iy);
|
||||
}
|
||||
//return pedMean[iy][ix];
|
||||
return stat[iy][ix].getPedestal();
|
||||
} else return -1;
|
||||
};
|
||||
|
||||
@ -422,8 +447,8 @@ template <class dataType> class analogDetector {
|
||||
g=gmap[iy*nx+ix];
|
||||
if (g==0) g=-1.;
|
||||
}
|
||||
|
||||
return stat[iy][ix].getPedestalRMS();//divide by gain?
|
||||
// return sqrt(pedVariance[iy][ix])/g;
|
||||
return stat[iy][ix].getPedestalRMS()/g;//divide by gain?
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
@ -441,10 +466,11 @@ template <class dataType> class analogDetector {
|
||||
\returns pedestal value
|
||||
*/
|
||||
virtual double* getPedestal(double *ped){
|
||||
if (ped==NULL)
|
||||
if (ped==NULL) {
|
||||
ped=new double[nx*ny];
|
||||
for (int iy=0; iy<ny; iy++) {
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
}
|
||||
for (iy=0; iy<ny; ++iy) {
|
||||
for (ix=0; ix<nx; ++ix) {
|
||||
ped[iy*nx+ix]=stat[iy][ix].getPedestal();
|
||||
//cout << ped[iy*nx+ix] << " " ;
|
||||
}
|
||||
@ -459,10 +485,11 @@ template <class dataType> class analogDetector {
|
||||
\returns pedestal rms
|
||||
*/
|
||||
virtual double* getPedestalRMS(double *ped=NULL){
|
||||
if (ped==NULL)
|
||||
if (ped==NULL) {
|
||||
ped=new double[nx*ny];
|
||||
for (int iy=0; iy<ny; iy++) {
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
}
|
||||
for (iy=0; iy<ny; ++iy) {
|
||||
for (ix=0; ix<nx; ++ix) {
|
||||
ped[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
|
||||
}
|
||||
}
|
||||
@ -501,8 +528,8 @@ template <class dataType> class analogDetector {
|
||||
*/
|
||||
virtual void setPedestal(double *ped, double *rms=NULL, int m=-1){
|
||||
double rr=0;
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (iy=ymin; iy<ymax; ++iy) {
|
||||
for (ix=xmin; ix<xmax; ++ix) {
|
||||
if (rms) rr=rms[iy*nx+ix];
|
||||
stat[iy][ix].setPedestal(ped[iy*nx+ix],rr, m);
|
||||
// cout << ix << " " << iy << " " << ped[iy*nx+ix] << " " << stat[iy][ix].getPedestal() << endl;
|
||||
@ -531,8 +558,8 @@ template <class dataType> class analogDetector {
|
||||
\param rms pointer to array of pedestal rms
|
||||
*/
|
||||
virtual void setPedestalRMS(double *rms){
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (iy=ymin; iy<ymax; ++iy) {
|
||||
for (ix=xmin; ix<xmax; ++ix) {
|
||||
stat[iy][ix].setPedestalRMS(rms[iy*nx+ix]);
|
||||
};
|
||||
};
|
||||
@ -572,8 +599,8 @@ template <class dataType> class analogDetector {
|
||||
|
||||
#endif
|
||||
gm=new float[nx*ny];
|
||||
for (int iy=0; iy<ny; iy++) {
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
for (iy=0; iy<ny; ++iy) {
|
||||
for (ix=0; ix<nx; ++ix) {
|
||||
gm[iy*nx+ix]=image[iy*nx+ix];
|
||||
#ifdef ROOTSPECTRUM
|
||||
hmap->SetBinContent(ix+1, iy+1,image[iy*nx+ix]);
|
||||
@ -620,8 +647,8 @@ template <class dataType> class analogDetector {
|
||||
TH2F *hmap=new TH2F("hmap","hmap",nx, -0.5,nx-0.5, ny, -0.5, ny-0.5);
|
||||
|
||||
#endif
|
||||
for (int iy=0; iy<ny; iy++) {
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
for (iy=0; iy<ny; ++iy) {
|
||||
for (ix=0; ix<nx; ++ix) {
|
||||
/* if (cmSub) */
|
||||
/* gm[iy*nx+ix]=stat[iy][ix].getPedestal()-cmSub->getCommonMode(); */
|
||||
/* else */
|
||||
@ -667,15 +694,15 @@ template <class dataType> class analogDetector {
|
||||
|
||||
|
||||
if (gm) {
|
||||
for (int iy=0; iy<nny; iy++) {
|
||||
for (int ix=0; ix<nnx; ix++) {
|
||||
for (iy=0; iy<nny; ++iy) {
|
||||
for (ix=0; ix<nnx; ++ix) {
|
||||
stat[iy][ix].setPedestal(gm[iy*nx+ix],-1,-1);
|
||||
}
|
||||
}
|
||||
delete [] gm;
|
||||
return 1;
|
||||
}
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -692,15 +719,15 @@ template <class dataType> class analogDetector {
|
||||
|
||||
|
||||
if (gm) {
|
||||
for (int iy=0; iy<nny; iy++) {
|
||||
for (int ix=0; ix<nnx; ix++) {
|
||||
for (iy=0; iy<nny; ++iy) {
|
||||
for (ix=0; ix<nnx; ++ix) {
|
||||
image[iy*nx+ix]=gm[iy*nx+ix];
|
||||
}
|
||||
}
|
||||
delete [] gm;
|
||||
return 1;
|
||||
}
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -718,9 +745,9 @@ template <class dataType> class analogDetector {
|
||||
float *gm=NULL;
|
||||
void *ret;
|
||||
gm=new float[nx*ny];
|
||||
for (int iy=0; iy<ny; iy++) {
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
gm[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
|
||||
for (iy=0; iy<ny; ++iy) {
|
||||
for (ix=0; ix<nx; ++ix) {
|
||||
gm[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
|
||||
}
|
||||
}
|
||||
ret=WriteToTiff(gm, imgname, ny, nx);
|
||||
@ -740,8 +767,8 @@ template <class dataType> class analogDetector {
|
||||
if (nnx>nx) nnx=nx;
|
||||
if (nny>ny) nny=ny;
|
||||
if (gm) {
|
||||
for (int iy=0; iy<nny; iy++) {
|
||||
for (int ix=0; ix<nnx; ix++) {
|
||||
for (iy=0; iy<nny; ++iy) {
|
||||
for (ix=0; ix<nnx; ++ix) {
|
||||
stat[iy][ix].setPedestalRMS(gm[iy*nx+ix]);
|
||||
}
|
||||
}
|
||||
@ -777,11 +804,13 @@ template <class dataType> class analogDetector {
|
||||
|
||||
//cout << xmin << " " << xmax << endl;
|
||||
// cout << ymin << " " << ymax << endl;
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (iy=ymin; iy<ymax; ++iy) {
|
||||
for (ix=xmin; ix<xmax; ++ix) {
|
||||
if (det->isGood(ix,iy)) {
|
||||
// addToPedestal(data,ix,iy,1);
|
||||
addToPedestal(data,ix,iy,cm);
|
||||
/* if (ix==50 && iy==50) */
|
||||
/* cout<< "*ped* " << id << " " << ix << " " << iy << " " << det->getChannel(data,ix,iy) << " " << stat[iy][ix].getPedestal() << " " << stat[iy][ix].getPedestalRMS() <<" " << stat[iy][ix]. GetNPedestals() << endl; */
|
||||
//if (ix==10 && iy==10)
|
||||
// cout <<ix << " " << iy << " " << getPedestal(ix,iy)<< endl;
|
||||
#ifdef ROOTSPECTRUM
|
||||
@ -905,8 +934,8 @@ template <class dataType> class analogDetector {
|
||||
|
||||
//calcGhost(data);
|
||||
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (iy=ymin; iy<ymax; ++iy) {
|
||||
for (ix=xmin; ix<xmax; ++ix) {
|
||||
if (det->isGood(ix,iy))
|
||||
val[iy*nx+ix]+=subtractPedestal(data, ix, iy,cm);
|
||||
}
|
||||
@ -952,8 +981,8 @@ template <class dataType> class analogDetector {
|
||||
hs->Fill(val,(iy-ymin)*(xmax-xmin)+(ix-xmin));
|
||||
#ifdef ROOTCLUST
|
||||
double v3=0,v5=0,v7=0,v9=0;
|
||||
for (int iix=-4; iix<5; iix++)
|
||||
for (int iiy=-4; iiy<5; iiy++) {
|
||||
for (int iix=-4; iix<5; i++ix)
|
||||
for (int iiy=-4; iiy<5; i++iy) {
|
||||
if (det)
|
||||
val= (dataSign*det->getValue(data, ix+iix, iy+iiy)-getPedestal(ix+iix,iy+iiy,cm))/g;
|
||||
else
|
||||
@ -1047,8 +1076,8 @@ template <class dataType> class analogDetector {
|
||||
|
||||
//calcGhost(data);
|
||||
addToCommonMode(data);
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (iy=ymin; iy<ymax; ++iy) {
|
||||
for (ix=xmin; ix<xmax; ++ix) {
|
||||
if (det->isGood(ix,iy))
|
||||
nph[iy*nx+ix]+=getNPhotons(data, ix, iy);
|
||||
}
|
||||
@ -1062,8 +1091,8 @@ template <class dataType> class analogDetector {
|
||||
|
||||
*/
|
||||
virtual void clearImage(){
|
||||
for (int iy=0; iy<ny; iy++) {
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
for (iy=0; iy<ny; ++iy) {
|
||||
for (ix=0; ix<nx; ++ix) {
|
||||
image[iy*nx+ix]=0;
|
||||
}
|
||||
}
|
||||
@ -1093,8 +1122,8 @@ template <class dataType> class analogDetector {
|
||||
int SetNPedestals(int i=-1) {
|
||||
int ix=0, iy=0;
|
||||
if (i>0)
|
||||
for (iy=0; iy<ny; iy++)
|
||||
for (ix=0; ix<nx; ix++)
|
||||
for (iy=0; iy<ny; ++iy)
|
||||
for (ix=0; ix<nx; ++ix)
|
||||
stat[iy][ix].SetNPedestals(i);
|
||||
return stat[0][0].SetNPedestals();
|
||||
};
|
||||
@ -1129,8 +1158,8 @@ template <class dataType> class analogDetector {
|
||||
newFrame(data);
|
||||
//calcGhost(data);
|
||||
addToCommonMode(data);
|
||||
for (int iy=ymi; iy<yma; iy++)
|
||||
for (int ix=xmi; ix<xma; ix++)
|
||||
for (iy=ymi; iy<yma; ++iy)
|
||||
for (ix=xmi; ix<xma; ++ix)
|
||||
if (det->isGood(ix,iy)) {
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
|
||||
val+=getNPhotons(data, ix, iy);
|
||||
@ -1233,6 +1262,8 @@ FILE *getFilePointer(){return myFile;};
|
||||
int nx; /**< Size of the detector in x direction */
|
||||
int ny; /**< Size of the detector in y direction */
|
||||
pedestalSubtraction **stat; /**< pedestalSubtraction class */
|
||||
/* double **pedMean; /\**< pedestalSubtraction class *\/ */
|
||||
/* double **pedVariance; /\**< pedestalSubtraction class *\/ */
|
||||
commonModeSubtraction *cmSub;/**< commonModeSubtraction class */
|
||||
int dataSign; /**< sign of the data i.e. 1 if photon is positive, -1 if negative */
|
||||
int iframe; /**< frame number (not from file but incremented within the dataset every time newFrame is called */
|
||||
@ -1250,6 +1281,7 @@ FILE *getFilePointer(){return myFile;};
|
||||
frameMode fMode; /**< current detector frame mode */
|
||||
detectorMode dMode; /**< current detector frame mode */
|
||||
FILE *myFile; /**< file pointer to write to */
|
||||
int ix, iy;
|
||||
#ifdef ROOTSPECTRUM
|
||||
TH2F *hs;
|
||||
#ifdef ROOTCLUST
|
||||
|
@ -44,6 +44,28 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
|
||||
|
||||
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,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 isample;
|
||||
|
@ -20,6 +20,8 @@ class slsDetectorData {
|
||||
int **dataROIMask; /**< Array of size nx*ny 1 if channel is good (or in the ROI), 0 if bad channel (or out of ROI) */
|
||||
int *xmap;
|
||||
int *ymap;
|
||||
dataType **orderedData;
|
||||
int isOrdered;
|
||||
|
||||
public:
|
||||
|
||||
@ -37,35 +39,29 @@ class slsDetectorData {
|
||||
\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 (default) means all 1s.
|
||||
|
||||
*/
|
||||
slsDetectorData(int npx, int npy, int dsize, int **dMap=NULL, dataType **dMask=NULL, int **dROI=NULL): nx(npx), ny(npy), dataSize(dsize) {
|
||||
slsDetectorData(int npx, int npy, int dsize, int **dMap=NULL, dataType **dMask=NULL, int **dROI=NULL): nx(npx), ny(npy), dataSize(dsize), orderedData(NULL), isOrdered(0) {
|
||||
|
||||
|
||||
xmap=new int[dsize/sizeof(dataType)];
|
||||
ymap=new int[dsize/sizeof(dataType)];
|
||||
int el=dsize/sizeof(dataType);
|
||||
xmap=new int[el];
|
||||
ymap=new int[el];
|
||||
|
||||
|
||||
// if (dataMask==NULL) {
|
||||
dataMask=new dataType*[ny];
|
||||
for(int i = 0; i < ny; i++) {
|
||||
dataMask[i] = new dataType[nx];
|
||||
}
|
||||
// }
|
||||
|
||||
// if (dataMap==NULL) {
|
||||
orderedData=new dataType*[ny];
|
||||
dataMap=new int*[ny];
|
||||
for(int i = 0; i < ny; i++) {
|
||||
dataMap[i] = new int[nx];
|
||||
}
|
||||
// }
|
||||
// if (dataROIMask==NULL) {
|
||||
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<dsize/sizeof(dataType); ip++){
|
||||
|
||||
}
|
||||
|
||||
for (int ip=0; ip<el; ip++){
|
||||
xmap[ip]=-1;
|
||||
ymap[ip]=-1;
|
||||
}
|
||||
@ -74,22 +70,24 @@ class slsDetectorData {
|
||||
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 int getPointer(int ix,int iy) {return dataMap[iy][ix];};
|
||||
/**
|
||||
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);)
|
||||
@ -202,27 +200,32 @@ class slsDetectorData {
|
||||
int setDataSize(int d) {dataSize=d; return dataSize;};
|
||||
|
||||
|
||||
virtual void getPixel(int ip, int &x, int &y) {x=xmap[ip]; y=ymap[ip];};
|
||||
virtual void getPixel(int ip, int &x, int &y) {x=xmap[ip]; y=ymap[ip];};
|
||||
|
||||
virtual dataType **getData(char *ptr, int dsize=-1) {
|
||||
|
||||
dataType **data;
|
||||
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];
|
||||
}
|
||||
//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<(dsize/sizeof(dataType)); ip++) {
|
||||
|
||||
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);
|
||||
//data[iy][ix]=getChannel(ptr,ix,iy);
|
||||
orderedData[iy][ix]=*(ptr+ip);//getChannel(ptr,ix,iy);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
|
||||
};
|
||||
|
||||
isOrdered=1;
|
||||
return orderedData;
|
||||
}
|
||||
|
||||
void newFrame(){isOrdered=0;};
|
||||
|
||||
virtual double **getImage(char *ptr, int dsize=-1) {
|
||||
|
||||
double **data;
|
||||
@ -231,15 +234,15 @@ class slsDetectorData {
|
||||
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<(dsize/sizeof(dataType)); ip++) {
|
||||
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;
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -256,7 +259,10 @@ class slsDetectorData {
|
||||
// cout << ix << " " << iy << " " ;
|
||||
//cout << dataMap[ix][iy] << " " << (void*)data << " " << dataSize<< endl;
|
||||
m=dataMask[iy][ix];
|
||||
d=*((dataType*)(data+dataMap[iy][ix]));
|
||||
if (isOrdered==0)
|
||||
d=*((dataType*)(data+getPointer(ix,iy)));
|
||||
else
|
||||
d=orderedData[iy][ix];
|
||||
}
|
||||
return d^m;
|
||||
};
|
||||
|
@ -13,7 +13,7 @@ template <class dataType> class ghostSummation {
|
||||
/** constructor
|
||||
\param xt crosstalk
|
||||
*/
|
||||
ghostSummation(slsDetectorData<dataType> *d, double xt) : xtalk(xt),det(d) {
|
||||
ghostSummation(slsDetectorData<dataType> *d, double xt) : xtalk(xt),det(d), nx(1), ny(1) {
|
||||
if (det)
|
||||
det->getDetectorSize(nx,ny);
|
||||
ghost=new double[nx*ny];
|
||||
@ -22,6 +22,9 @@ template <class dataType> class ghostSummation {
|
||||
ghostSummation(ghostSummation *orig) {
|
||||
xtalk=orig->xtalk;
|
||||
det=orig->det;
|
||||
nx=1;
|
||||
ny=1;
|
||||
det->getDetectorSize(nx,ny);
|
||||
ghost=new double[nx*ny];
|
||||
|
||||
}
|
||||
|
@ -107,11 +107,11 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
singlePhotonDetector::clearImage();
|
||||
};
|
||||
|
||||
int getImageSize(int &nnx, int &nny, int &ns) {
|
||||
int getImageSize(int &nnx, int &nny, int &nsx, int &nsy) {
|
||||
if (interp)
|
||||
return interp->getImageSize(nnx, nny, ns);
|
||||
return interp->getImageSize(nnx, nny, nsx, nsy);
|
||||
else
|
||||
return analogDetector<uint16_t>::getImageSize(nnx, nny, ns);
|
||||
return analogDetector<uint16_t>::getImageSize(nnx, nny, nsx, nsy);
|
||||
};
|
||||
|
||||
|
||||
@ -251,6 +251,7 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
|
||||
}
|
||||
|
||||
virtual int getNSubPixels(){ if (interp) return interp->getNSubPixels(); else return 1;}
|
||||
|
||||
virtual int setNSubPixels(int ns) {
|
||||
if (interp) {
|
||||
pthread_mutex_lock(fi);
|
||||
|
@ -13,7 +13,7 @@
|
||||
class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
|
||||
public:
|
||||
eta2InterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nb, emin, emax) {
|
||||
eta2InterpolationBase(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax) {
|
||||
|
||||
/* if (etamin>=etamax) { */
|
||||
/* etamin=-1; */
|
||||
@ -37,7 +37,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
|
||||
int corner;
|
||||
corner=calcQuad(data, tot, totquad, sDum);
|
||||
if (nSubPixels>2)
|
||||
if (nSubPixelsX>2 || nSubPixelsY>2)
|
||||
calcEta(totquad, sDum, etax, etay);
|
||||
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
|
||||
|
||||
@ -53,7 +53,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
|
||||
int corner;
|
||||
corner=calcQuad(data, tot, totquad, sDum);
|
||||
if (nSubPixels>2)
|
||||
if (nSubPixelsX>2 || nSubPixelsY>2 )
|
||||
calcEta(totquad, sDum, etax, etay);
|
||||
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
|
||||
|
||||
@ -93,7 +93,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
;
|
||||
}
|
||||
double etax=0, etay=0;
|
||||
if (nSubPixels>2) {
|
||||
if (nSubPixelsX>2 || nSubPixelsY>2) {
|
||||
cc[0][0]=cl[xoff+3*yoff];
|
||||
cc[1][0]=cl[xoff+3*(yoff+1)];
|
||||
cc[0][1]=cl[xoff+1+3*yoff];
|
||||
@ -133,7 +133,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
;
|
||||
}
|
||||
double etax=0, etay=0;
|
||||
if (nSubPixels>2) {
|
||||
if (nSubPixelsX>2 || nSubPixelsY>2) {
|
||||
cc[0][0]=cl[xoff+3*yoff];
|
||||
cc[1][0]=cl[xoff+3*(yoff+1)];
|
||||
cc[0][1]=cl[xoff+1+3*yoff];
|
||||
@ -182,31 +182,31 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
}
|
||||
|
||||
|
||||
if (nSubPixels>2) {
|
||||
if (nSubPixelsX>2 || nSubPixelsY>2 ) {
|
||||
|
||||
ex=(etax-etamin)/etastep;
|
||||
ey=(etay-etamin)/etastep;
|
||||
ex=(etax-etamin)/etastepX;
|
||||
ey=(etay-etamin)/etastepY;
|
||||
if (ex<0) {
|
||||
cout << "x*"<< ex << endl;
|
||||
ex=0;
|
||||
}
|
||||
if (ex>=nbeta) {
|
||||
if (ex>=nbetaX) {
|
||||
cout << "x?"<< ex << endl;
|
||||
ex=nbeta-1;
|
||||
ex=nbetaX-1;
|
||||
}
|
||||
if (ey<0) {
|
||||
cout << "y*"<< ey << endl;
|
||||
cout << "y*"<< ey << " " << nbetaY << endl;
|
||||
ey=0;
|
||||
}
|
||||
if (ey>=nbeta) {
|
||||
cout << "y?"<< ey << endl;
|
||||
ey=nbeta-1;
|
||||
if (ey>=nbetaY) {
|
||||
cout << "y?"<< ey << " " << nbetaY << endl;
|
||||
ey=nbetaY-1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
xpos_eta=(((double)hhx[(ey*nbeta+ex)]))+dX ;///((double)nSubPixels);
|
||||
ypos_eta=(((double)hhy[(ey*nbeta+ex)]))+dY ;///((double)nSubPixels);
|
||||
xpos_eta=(((double)hhx[(ey*nbetaX+ex)]))+dX ;///((double)nSubPixels);
|
||||
ypos_eta=(((double)hhy[(ey*nbetaX+ex)]))+dY ;///((double)nSubPixels);
|
||||
|
||||
} else {
|
||||
xpos_eta=0.5*dX+0.25;
|
||||
@ -347,10 +347,10 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
int ex,ey;
|
||||
ex=(etax-etamin)/etastep;
|
||||
ey=(etay-etamin)/etastep;
|
||||
if (ey<nbeta && ex<nbeta && ex>=0 && ey>=0)
|
||||
heta[ey*nbeta+ex]++;
|
||||
ex=(etax-etamin)/etastepX;
|
||||
ey=(etay-etamin)/etastepY;
|
||||
if (ey<nbetaY && ex<nbetaX && ex>=0 && ey>=0)
|
||||
heta[ey*nbetaX+ex]++;
|
||||
#endif
|
||||
return 0;
|
||||
};
|
||||
@ -360,22 +360,22 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
// cout << "ff" << endl;
|
||||
calcDiff(1, hhx, hhy); //get flat
|
||||
double avg=0;
|
||||
for (ipx=0; ipx<nSubPixels; ipx++)
|
||||
for (ipy=0; ipy<nSubPixels; ipy++)
|
||||
avg+=flat[ipx+ipy*nSubPixels];
|
||||
avg/=nSubPixels*nSubPixels;
|
||||
for (ipx=0; ipx<nSubPixelsX; ipx++)
|
||||
for (ipy=0; ipy<nSubPixelsY; ipy++)
|
||||
avg+=flat[ipx+ipy*nSubPixelsX];
|
||||
avg/=nSubPixelsY*nSubPixelsX;
|
||||
|
||||
for (int ibx=0 ; ibx<nSubPixels*nPixelsX; ibx++) {
|
||||
ipx=ibx%nSubPixels-nSubPixels/2;
|
||||
if (ipx<0) ipx=nSubPixels+ipx;
|
||||
for (int iby=0 ; iby<nSubPixels*nPixelsY; iby++) {
|
||||
ipy=iby%nSubPixels-nSubPixels/2;
|
||||
if (ipy<0) ipy=nSubPixels+ipy;
|
||||
for (int ibx=0 ; ibx<nSubPixelsX*nPixelsX; ibx++) {
|
||||
ipx=ibx%nSubPixelsX-nSubPixelsX/2;
|
||||
if (ipx<0) ipx=nSubPixelsX+ipx;
|
||||
for (int iby=0 ; iby<nSubPixelsY*nPixelsY; iby++) {
|
||||
ipy=iby%nSubPixelsY-nSubPixelsY/2;
|
||||
if (ipy<0) ipy=nSubPixelsY+ipy;
|
||||
// cout << ipx << " " << ipy << " " << ibx << " " << iby << endl;
|
||||
if (flat[ipx+ipy*nSubPixels]>0)
|
||||
hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX]*(avg/flat[ipx+ipy*nSubPixels]);
|
||||
if (flat[ipx+ipy*nSubPixelsX]>0)
|
||||
hintcorr[ibx+iby*nSubPixelsX*nPixelsX]=hint[ibx+iby*nSubPixelsX*nPixelsX]*(avg/flat[ipx+ipy*nSubPixelsX]);
|
||||
else
|
||||
hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX];
|
||||
hintcorr[ibx+iby*nSubPixelsX*nPixelsX]=hint[ibx+iby*nSubPixelsX*nPixelsX];
|
||||
|
||||
|
||||
}
|
||||
|
@ -13,35 +13,12 @@
|
||||
class eta3InterpolationBase : public virtual etaInterpolationBase {
|
||||
|
||||
public:
|
||||
eta3InterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx, ny, ns, nb, emin, emax) {
|
||||
eta3InterpolationBase(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx, ny, ns, nsy, nb, nby, emin, emax) {
|
||||
// cout << "e3ib " << nb << " " << emin << " " << emax << endl;
|
||||
/* if (nbeta<=0) { */
|
||||
/* nbeta=nSubPixels*10; */
|
||||
/* } */
|
||||
if (etamin>=etamax) {
|
||||
etamin=-1;
|
||||
etamax=1;
|
||||
}
|
||||
|
||||
etastep=(etamax-etamin)/nbeta;
|
||||
#ifdef MYROOT1
|
||||
delete heta;
|
||||
delete hhx;
|
||||
delete hhy;
|
||||
heta=new TH2D("heta","heta",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
||||
hhx=new TH2D("hhx","hhx",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
||||
hhy=new TH2D("hhy","hhy",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
/* delete [] heta; */
|
||||
/* delete [] hhx; */
|
||||
/* delete [] hhy; */
|
||||
|
||||
/* heta=new int[nbeta*nbeta]; */
|
||||
/* hhx=new float[nbeta*nbeta]; */
|
||||
/* hhy=new float[nbeta*nbeta]; */
|
||||
|
||||
#endif
|
||||
|
||||
// cout << nbeta << " " << etamin << " " << etamax << endl;
|
||||
};
|
||||
|
||||
@ -88,7 +65,7 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
|
||||
|
||||
|
||||
double etax, etay;
|
||||
if (nSubPixels>2) {
|
||||
if (nSubPixelsX>2 || nSubPixelsY>2 ) {
|
||||
calcEta3(cl,etax,etay, totquad);
|
||||
}
|
||||
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
|
||||
@ -101,7 +78,7 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
|
||||
|
||||
|
||||
double etax, etay;
|
||||
if (nSubPixels>2) {
|
||||
if (nSubPixelsX>2 || nSubPixelsY>2 ) {
|
||||
calcEta3(cl,etax,etay, totquad);
|
||||
}
|
||||
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
|
||||
@ -117,38 +94,38 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
|
||||
double xpos_eta=0,ypos_eta=0;
|
||||
int ex,ey;
|
||||
|
||||
if (nSubPixels>2) {
|
||||
if (nSubPixelsX>2 || nSubPixelsY>2 ) {
|
||||
|
||||
#ifdef MYROOT1
|
||||
xpos_eta=(hhx->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels);
|
||||
ypos_eta=(hhy->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels);
|
||||
xpos_eta=(hhx->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixelsX);
|
||||
ypos_eta=(hhy->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixelsY);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
ex=(etax-etamin)/etastep;
|
||||
ey=(etay-etamin)/etastep;
|
||||
ex=(etax-etamin)/etastepX;
|
||||
ey=(etay-etamin)/etastepY;
|
||||
if (ex<0) {
|
||||
/* cout << etax << " " << etamin << " "; */
|
||||
/* cout << "3x*"<< ex << endl; */
|
||||
ex=0;
|
||||
}
|
||||
if (ex>=nbeta) {
|
||||
if (ex>=nbetaX) {
|
||||
/* cout << etax << " " << etamin << " "; */
|
||||
/* cout << "3x?"<< ex << endl; */
|
||||
ex=nbeta-1;
|
||||
ex=nbetaX-1;
|
||||
}
|
||||
if (ey<0) {
|
||||
/* cout << etay << " " << etamin << " "; */
|
||||
/* cout << "3y*"<< ey << endl; */
|
||||
ey=0;
|
||||
}
|
||||
if (ey>=nbeta) {
|
||||
if (ey>=nbetaY) {
|
||||
/* cout << etay << " " << etamin << " "; */
|
||||
/* cout << "3y?"<< ey << endl; */
|
||||
ey=nbeta-1;
|
||||
ey=nbetaY-1;
|
||||
|
||||
}
|
||||
xpos_eta=(((double)hhx[(ey*nbeta+ex)]));///((double)nSubPixels);
|
||||
ypos_eta=(((double)hhy[(ey*nbeta+ex)]));///((double)nSubPixels);
|
||||
xpos_eta=(((double)hhx[(ey*nbetaX+ex)]));///((double)nSubPixels);
|
||||
ypos_eta=(((double)hhy[(ey*nbetaX+ex)]));///((double)nSubPixels);
|
||||
|
||||
#endif
|
||||
|
||||
@ -265,10 +242,10 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
int ex,ey;
|
||||
ex=(etax-etamin)/etastep;
|
||||
ey=(etay-etamin)/etastep;
|
||||
if (ey<nbeta && ex<nbeta && ex>=0 && ey>=0)
|
||||
heta[ey*nbeta+ex]++;
|
||||
ex=(etax-etamin)/etastepX;
|
||||
ey=(etay-etamin)/etastepY;
|
||||
if (ey<nbetaY && ex<nbetaX && ex>=0 && ey>=0)
|
||||
heta[ey*nbetaX+ex]++;
|
||||
#endif
|
||||
return 0;
|
||||
};
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <TH2D.h>
|
||||
#include <TH2F.h>
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include "slsInterpolation.h"
|
||||
#include "tiffIO.h"
|
||||
|
||||
@ -15,44 +15,51 @@ class etaInterpolationBase : public slsInterpolation {
|
||||
|
||||
public:
|
||||
|
||||
etaInterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : slsInterpolation(nx,ny,ns), hhx(NULL), hhy(NULL), heta(NULL), nbeta(nb), etamin(emin), etamax(emax) {
|
||||
etaInterpolationBase(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : slsInterpolation(nx,ny,ns,nsy), hhx(NULL), hhy(NULL), heta(NULL), nbetaX(nb), nbetaY(nby), etamin(emin), etamax(emax) {
|
||||
// cout << "eb " << nb << " " << emin << " " << emax << endl;
|
||||
// cout << nb << " " << etamin << " " << etamax << endl;
|
||||
if (nbeta<=0) {
|
||||
if (nbetaX<=0) {
|
||||
//cout << "aaa:" <<endl;
|
||||
nbeta=nSubPixels*10;
|
||||
nbetaX=nSubPixelsX*10;
|
||||
}
|
||||
if (nbetaY<=0) {
|
||||
//cout << "aaa:" <<endl;
|
||||
nbetaY=nSubPixelsY*10;
|
||||
}
|
||||
if (etamin>=etamax) {
|
||||
etamin=-1;
|
||||
etamax=2;
|
||||
}
|
||||
etastep=(etamax-etamin)/nbeta;
|
||||
heta=new int[nbeta*nbeta];
|
||||
hhx=new float[nbeta*nbeta];
|
||||
hhy=new float[nbeta*nbeta];
|
||||
etastepX=(etamax-etamin)/nbetaX;
|
||||
etastepY=(etamax-etamin)/nbetaY;
|
||||
heta=new int[nbetaX*nbetaY];
|
||||
hhx=new float[nbetaX*nbetaY];
|
||||
hhy=new float[nbetaX*nbetaY];
|
||||
rangeMin=etamin;
|
||||
rangeMax=etamax;
|
||||
flat= new double[nSubPixels*nSubPixels];
|
||||
hintcorr=new int [nSubPixels*nSubPixels*nPixelsX*nPixelsY];
|
||||
flat= new double[nSubPixelsX*nSubPixelsY];
|
||||
hintcorr=new int [nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY];
|
||||
|
||||
};
|
||||
|
||||
etaInterpolationBase(etaInterpolationBase *orig): slsInterpolation(orig){
|
||||
nbeta=orig->nbeta;
|
||||
nbetaX=orig->nbetaX;
|
||||
nbetaY=orig->nbetaY;
|
||||
etamin=orig->etamin;
|
||||
etamax=orig->etamax;
|
||||
rangeMin=orig->rangeMin;
|
||||
rangeMax=orig->rangeMax;
|
||||
|
||||
|
||||
etastep=(etamax-etamin)/nbeta;
|
||||
heta=new int[nbeta*nbeta];
|
||||
memcpy(heta,orig->heta,nbeta*nbeta*sizeof(int));
|
||||
hhx=new float[nbeta*nbeta];
|
||||
memcpy(hhx,orig->hhx,nbeta*nbeta*sizeof(float));
|
||||
hhy=new float[nbeta*nbeta];
|
||||
memcpy(hhy,orig->hhy,nbeta*nbeta*sizeof(float));
|
||||
hintcorr=new int [nSubPixels*nSubPixels*nPixelsX*nPixelsY];
|
||||
etastepX=(etamax-etamin)/nbetaX;
|
||||
etastepY=(etamax-etamin)/nbetaY;
|
||||
heta=new int[nbetaX*nbetaY];
|
||||
memcpy(heta,orig->heta,nbetaX*nbetaY*sizeof(int));
|
||||
hhx=new float[nbetaX*nbetaY];
|
||||
memcpy(hhx,orig->hhx,nbetaX*nbetaY*sizeof(float));
|
||||
hhy=new float[nbetaX*nbetaY];
|
||||
memcpy(hhy,orig->hhy,nbetaX*nbetaY*sizeof(float));
|
||||
hintcorr=new int [nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY];
|
||||
|
||||
};
|
||||
|
||||
@ -61,7 +68,7 @@ class etaInterpolationBase : public slsInterpolation {
|
||||
|
||||
|
||||
virtual void resetFlatField() {
|
||||
for (int ibx=0; ibx<nbeta*nbeta; ibx++) {
|
||||
for (int ibx=0; ibx<nbetaX*nbetaY; ibx++) {
|
||||
heta[ibx]=0;
|
||||
hhx[ibx]=0;
|
||||
hhy[ibx]=0;
|
||||
@ -70,13 +77,16 @@ class etaInterpolationBase : public slsInterpolation {
|
||||
|
||||
};
|
||||
|
||||
int *setEta(int *h, int nb=-1, double emin=1, double emax=0)
|
||||
int *setEta(int *h, int nb=-1, int nby=-1, double emin=1, double emax=0)
|
||||
{
|
||||
if (h) {
|
||||
if (heta) delete [] heta;
|
||||
heta=h;
|
||||
nbeta=nb;
|
||||
if (nb<=0) nbeta=nSubPixels*10;
|
||||
nbetaX=nb;
|
||||
nbetaY=nby;
|
||||
if (nbetaX<=0) nbetaX=nSubPixelsX*10;
|
||||
if (nbetaY<=0) nbetaY=nSubPixelsY*10;
|
||||
|
||||
etamin=emin;
|
||||
etamax=emax;
|
||||
if (etamin>=etamax) {
|
||||
@ -85,22 +95,24 @@ class etaInterpolationBase : public slsInterpolation {
|
||||
}
|
||||
rangeMin=etamin;
|
||||
rangeMax=etamax;
|
||||
etastep=(etamax-etamin)/nbeta;
|
||||
etastepX=(etamax-etamin)/nbetaX;
|
||||
etastepY=(etamax-etamin)/nbetaY;
|
||||
}
|
||||
return heta;
|
||||
};
|
||||
|
||||
int *setFlatField(int *h, int nb=-1, double emin=1, double emax=0)
|
||||
int *setFlatField(int *h, int nb=-1, int nby=-1, double emin=1, double emax=0)
|
||||
{
|
||||
return setEta(h, nb, emin, emax);
|
||||
return setEta(h, nb, nby, emin, emax);
|
||||
};
|
||||
|
||||
|
||||
|
||||
int *getFlatField(){return setEta(NULL);};
|
||||
|
||||
int *getFlatField(int &nb, double &emin, double &emax){
|
||||
nb=nbeta;
|
||||
int *getFlatField(int &nb, int &nby, double &emin, double &emax){
|
||||
nb=nbetaX;
|
||||
nby=nbetaY;
|
||||
emin=etamin;
|
||||
emax=etamax;
|
||||
return getFlatField();
|
||||
@ -109,13 +121,13 @@ class etaInterpolationBase : public slsInterpolation {
|
||||
|
||||
void *writeFlatField(const char * imgname) {
|
||||
float *gm=NULL;
|
||||
gm=new float[nbeta*nbeta];
|
||||
for (int ix=0; ix<nbeta; ix++) {
|
||||
for (int iy=0; iy<nbeta; iy++) {
|
||||
gm[iy*nbeta+ix]=heta[iy*nbeta+ix];
|
||||
gm=new float[nbetaX*nbetaY];
|
||||
for (int ix=0; ix<nbetaX; ix++) {
|
||||
for (int iy=0; iy<nbetaY; iy++) {
|
||||
gm[iy*nbetaX+ix]=heta[iy*nbetaX+ix];
|
||||
}
|
||||
}
|
||||
WriteToTiff(gm, imgname, nbeta, nbeta);
|
||||
WriteToTiff(gm, imgname, nbetaX, nbetaY);
|
||||
delete [] gm;
|
||||
return NULL;
|
||||
};
|
||||
@ -129,16 +141,18 @@ class etaInterpolationBase : public slsInterpolation {
|
||||
etamax=2;
|
||||
}
|
||||
|
||||
etastep=(etamax-etamin)/nbeta;
|
||||
etastepX=(etamax-etamin)/nbetaX;
|
||||
etastepY=(etamax-etamin)/nbetaY;
|
||||
uint32 nnx;
|
||||
uint32 nny;
|
||||
float *gm=ReadFromTiff(imgname, nnx, nny);
|
||||
if (nnx!=nny) {
|
||||
cout << "different number of bins in x " << nnx << " and y " << nny<< " !"<< endl;
|
||||
cout << "Aborting read"<< endl;
|
||||
return 0;
|
||||
}
|
||||
nbeta=nnx;
|
||||
/* if (nnx!=nny) { */
|
||||
/* cout << "different number of bins in x " << nnx << " and y " << nny<< " !"<< endl; */
|
||||
/* cout << "Aborting read"<< endl; */
|
||||
/* return 0; */
|
||||
/* } */
|
||||
nbetaX=nnx;
|
||||
nbetaY=nny;
|
||||
if (gm) {
|
||||
if (heta) {
|
||||
delete [] heta;
|
||||
@ -146,13 +160,13 @@ class etaInterpolationBase : public slsInterpolation {
|
||||
delete [] hhy;
|
||||
}
|
||||
|
||||
heta=new int[nbeta*nbeta];
|
||||
hhx=new float[nbeta*nbeta];
|
||||
hhy=new float[nbeta*nbeta];
|
||||
heta=new int[nbetaX*nbetaY];
|
||||
hhx=new float[nbetaX*nbetaY];
|
||||
hhy=new float[nbetaX*nbetaY];
|
||||
|
||||
for (int ix=0; ix<nbeta; ix++) {
|
||||
for (int iy=0; iy<nbeta; iy++) {
|
||||
heta[iy*nbeta+ix]=gm[iy*nbeta+ix];
|
||||
for (int ix=0; ix<nbetaX; ix++) {
|
||||
for (int iy=0; iy<nbetaY; iy++) {
|
||||
heta[iy*nbetaX+ix]=gm[iy*nbetaX+ix];
|
||||
}
|
||||
}
|
||||
delete [] gm;
|
||||
@ -178,10 +192,10 @@ float *gethhx()
|
||||
};
|
||||
virtual int addToFlatField(double etax, double etay){
|
||||
int ex,ey;
|
||||
ex=(etax-etamin)/etastep;
|
||||
ey=(etay-etamin)/etastep;
|
||||
if (ey<nbeta && ex<nbeta && ex>=0 && ey>=0)
|
||||
heta[ey*nbeta+ex]++;
|
||||
ex=(etax-etamin)/etastepX;
|
||||
ey=(etay-etamin)/etastepY;
|
||||
if (ey<nbetaY && ex<nbetaX && ex>=0 && ey>=0)
|
||||
heta[ey*nbetaX+ex]++;
|
||||
return 0;
|
||||
};
|
||||
|
||||
@ -195,80 +209,80 @@ float *gethhx()
|
||||
|
||||
float tot_eta=0;
|
||||
|
||||
float *etah=new float[nbeta*nbeta];
|
||||
int etabins=nbeta;
|
||||
float *etah=new float[nbetaX*nbetaY];
|
||||
// int etabins=nbeta;
|
||||
int ibb=0;
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
for (int ii=0; ii<nbetaX*nbetaY; ii++) {
|
||||
|
||||
etah[ii]=heta[ii];
|
||||
tot_eta+=heta[ii];
|
||||
}
|
||||
sprintf(tit,"/scratch/eta_%d.tiff",ind);
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
WriteToTiff(etah, tit, nbetaX, nbetaY);
|
||||
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
ibb=(hhx[ii]*nSubPixels);
|
||||
for (int ii=0; ii<nbetaX*nbetaY; ii++) {
|
||||
ibb=(hhx[ii]*nSubPixelsX);
|
||||
etah[ii]=ibb;
|
||||
}
|
||||
sprintf(tit,"/scratch/eta_hhx_%d.tiff",ind);
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
WriteToTiff(etah, tit, nbetaX, nbetaY);
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
ibb=hhy[ii]*nSubPixels;
|
||||
for (int ii=0; ii<nbetaX*nbetaY; ii++) {
|
||||
ibb=hhy[ii]*nSubPixelsY;
|
||||
etah[ii]=ibb;
|
||||
}
|
||||
sprintf(tit,"/scratch/eta_hhy_%d.tiff",ind);
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
WriteToTiff(etah, tit, nbetaX, nbetaY);
|
||||
|
||||
|
||||
float *ftest=new float[nSubPixels*nSubPixels];
|
||||
float *ftest=new float[nSubPixelsX*nSubPixelsY];
|
||||
|
||||
for (int ib=0; ib<nSubPixels*nSubPixels; ib++) ftest[ib]=0;
|
||||
for (int ib=0; ib<nSubPixelsX*nSubPixelsY; ib++) ftest[ib]=0;
|
||||
|
||||
|
||||
//int ibx=0, iby=0;
|
||||
|
||||
for (int ii=0; ii<nbeta*nbeta; ii++) {
|
||||
for (int ii=0; ii<nbetaX*nbetaY; ii++) {
|
||||
|
||||
ibx=nSubPixels*hhx[ii];
|
||||
iby=nSubPixels*hhy[ii];
|
||||
ibx=nSubPixelsX*hhx[ii];
|
||||
iby=nSubPixelsY*hhy[ii];
|
||||
if (ibx<0) ibx=0;
|
||||
if (iby<0) iby=0;
|
||||
if (ibx>=nSubPixels) ibx=nSubPixels-1;
|
||||
if (iby>=nSubPixels) iby=nSubPixels-1;
|
||||
if (ibx>=nSubPixelsX) ibx=nSubPixelsX-1;
|
||||
if (iby>=nSubPixelsY) iby=nSubPixelsY-1;
|
||||
|
||||
|
||||
if (ibx>=0 && ibx<nSubPixels && iby>=0 && iby<nSubPixels) {
|
||||
if (ibx>=0 && ibx<nSubPixelsX && iby>=0 && iby<nSubPixelsY) {
|
||||
//
|
||||
// if (ibx>0 && iby>0) cout << ibx << " " << iby << " " << ii << endl;
|
||||
ftest[ibx+iby*nSubPixels]+=heta[ii];
|
||||
ftest[ibx+iby*nSubPixelsX]+=heta[ii];
|
||||
} else
|
||||
cout << "Bad interpolation "<< ii << " " << ibx << " " << iby<< endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
sprintf(tit,"/scratch/ftest_%d.tiff",ind);
|
||||
WriteToTiff(ftest, tit, nSubPixels, nSubPixels);
|
||||
WriteToTiff(ftest, tit, nSubPixelsX, nSubPixelsY);
|
||||
|
||||
//int ibx=0, iby=0;
|
||||
tot_eta/=nSubPixels*nSubPixels;
|
||||
tot_eta/=nSubPixelsX*nSubPixelsY;
|
||||
int nbad=0;
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
ibx=nSubPixels*hhx[ii];
|
||||
iby=nSubPixels*hhy[ii];
|
||||
if (ftest[ibx+iby*nSubPixels]<tot_eta*0.5) {
|
||||
for (int ii=0; ii<nbetaX*nbetaY; ii++) {
|
||||
ibx=nSubPixelsX*hhx[ii];
|
||||
iby=nSubPixelsY*hhy[ii];
|
||||
if (ftest[ibx+iby*nSubPixelsX]<tot_eta*0.5) {
|
||||
etah[ii]=1;
|
||||
nbad++;
|
||||
} else if(ftest[ibx+iby*nSubPixels]>tot_eta*2.){
|
||||
} else if(ftest[ibx+iby*nSubPixelsX]>tot_eta*2.){
|
||||
etah[ii]=2;
|
||||
nbad++;
|
||||
} else
|
||||
etah[ii]=0;
|
||||
}
|
||||
sprintf(tit,"/scratch/eta_bad_%d.tiff",ind);
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
WriteToTiff(etah, tit, nbetaX, nbetaY);
|
||||
// cout << "Index: " << ind << "\t Bad bins: "<< nbad << endl;
|
||||
//int ibx=0, iby=0;
|
||||
|
||||
@ -286,46 +300,44 @@ float *gethhx()
|
||||
double diff=0, d;
|
||||
//double bsize=1./nSubPixels;
|
||||
int nbad=0;
|
||||
double p_tot_x[nSubPixels], p_tot_y[nSubPixels], p_tot[nSubPixels*nSubPixels];
|
||||
double maxdiff=0, mindiff=avg*nSubPixels*nSubPixels;
|
||||
double p_tot_x[nSubPixelsX], p_tot_y[nSubPixelsY], p_tot[nSubPixelsX*nSubPixelsY];
|
||||
double maxdiff=0, mindiff=avg*nSubPixelsX*nSubPixelsY;
|
||||
|
||||
int ipx, ipy;
|
||||
for (ipy=0; ipy<nSubPixels; ipy++) {
|
||||
for (ipx=0; ipx<nSubPixels; ipx++) {
|
||||
p_tot[ipx+ipy*nSubPixels]=0;
|
||||
for (ipy=0; ipy<nSubPixelsY; ipy++) {
|
||||
for (ipx=0; ipx<nSubPixelsX; ipx++) {
|
||||
p_tot[ipx+ipy*nSubPixelsX]=0;
|
||||
}
|
||||
p_tot_y[ipy]=0;
|
||||
p_tot_x[ipy]=0;
|
||||
}
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
ipx=hx[ibx+iby*nbeta]*nSubPixels;
|
||||
for (int ibx=0; ibx<nbetaX; ibx++) {
|
||||
for (int iby=0; iby<nbetaY; iby++) {
|
||||
ipx=hx[ibx+iby*nbetaX]*nSubPixelsX;
|
||||
if (ipx<0) ipx=0;
|
||||
if (ipx>=nSubPixels) ipx=nSubPixels-1;
|
||||
if (ipx>=nSubPixelsX) ipx=nSubPixelsX-1;
|
||||
|
||||
ipy=hy[ibx+iby*nbeta]*nSubPixels;
|
||||
ipy=hy[ibx+iby*nbetaX]*nSubPixelsY;
|
||||
if (ipy<0) ipy=0;
|
||||
if (ipy>=nSubPixels) ipy=nSubPixels-1;
|
||||
if (ipy>=nSubPixelsY) ipy=nSubPixelsY-1;
|
||||
|
||||
p_tot[ipx+ipy*nSubPixels]+=heta[ibx+iby*nbeta];
|
||||
p_tot_y[ipy]+=heta[ibx+iby*nbeta];
|
||||
p_tot_x[ipx]+=heta[ibx+iby*nbeta];
|
||||
|
||||
|
||||
p_tot[ipx+ipy*nSubPixelsX]+=heta[ibx+iby*nbetaX];
|
||||
p_tot_y[ipy]+=heta[ibx+iby*nbetaX];
|
||||
p_tot_x[ipx]+=heta[ibx+iby*nbetaX];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// cout << endl << endl;
|
||||
for (ipy=0; ipy<nSubPixels; ipy++) {
|
||||
for (ipy=0; ipy<nSubPixelsY; ipy++) {
|
||||
cout.width(5);
|
||||
//flat_y[ipy]=p_tot_y[ipy];//avg/nSubPixels;
|
||||
for (ipx=0; ipx<nSubPixels; ipx++) {
|
||||
for (ipx=0; ipx<nSubPixelsX; ipx++) {
|
||||
|
||||
// flat_x[ipx]=p_tot_x[ipx];///avg/nSubPixels;
|
||||
flat[ipx+nSubPixels*ipy]=p_tot[ipx+nSubPixels*ipy];///avg;
|
||||
d=p_tot[ipx+nSubPixels*ipy]-avg;
|
||||
flat[ipx+nSubPixelsX*ipy]=p_tot[ipx+nSubPixelsX*ipy];///avg;
|
||||
d=p_tot[ipx+nSubPixelsX*ipy]-avg;
|
||||
if (d<0) d*=-1.;
|
||||
if (d>5*sqrt(avg) )
|
||||
nbad++;
|
||||
@ -354,8 +366,8 @@ float *gethhx()
|
||||
float *hhx;
|
||||
float *hhy;
|
||||
int *heta;
|
||||
int nbeta;
|
||||
double etamin, etamax, etastep;
|
||||
int nbetaX, nbetaY;
|
||||
double etamin, etamax, etastepX, etastepY;
|
||||
double rangeMin, rangeMax;
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
||||
public:
|
||||
etaInterpolationPosXY(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax){
|
||||
etaInterpolationPosXY(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax){
|
||||
// cout << "epxy " << nb << " " << emin << " " << emax << endl; cout << nbeta << " " << etamin << " " << etamax << endl;
|
||||
};
|
||||
|
||||
@ -24,14 +24,6 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
||||
virtual void prepareInterpolation(int &ok)
|
||||
{
|
||||
ok=1;
|
||||
#ifdef MYROOT1
|
||||
if (hhx) delete hhx;
|
||||
if (hhy) delete hhy;
|
||||
|
||||
hhx=new TH2D("hhx","hhx",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax());
|
||||
hhy=new TH2D("hhy","hhy",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax());
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
///*Eta Distribution Rebinning*///
|
||||
@ -40,106 +32,128 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
||||
double tot_eta=0;
|
||||
double tot_eta_x=0;
|
||||
double tot_eta_y=0;
|
||||
for (int ip=0; ip<nbeta*nbeta; ip++)
|
||||
for (int ip=0; ip<nbetaX*nbetaY; ip++)
|
||||
tot_eta+=heta[ip];
|
||||
cout << "total eta entries is :"<< tot_eta << endl;
|
||||
if (tot_eta<=0) {ok=0; return;};
|
||||
|
||||
|
||||
double hx[nbeta]; //profile x
|
||||
double hy[nbeta]; //profile y
|
||||
double hix[nbeta]; //integral of projection x
|
||||
double hiy[nbeta]; //integral of projection y
|
||||
double hx[nbetaX]; //profile x
|
||||
double hy[nbetaY]; //profile y
|
||||
double hix[nbetaX]; //integral of projection x
|
||||
double hiy[nbetaY]; //integral of projection y
|
||||
// int ii=0;
|
||||
double etax;//, etay;
|
||||
for (int ib=0; ib<nbeta; ib++) {
|
||||
double etax, etay;
|
||||
for (int ib=0; ib<nbetaX; ib++) {
|
||||
|
||||
tot_eta_x=0;
|
||||
tot_eta_y=0;
|
||||
|
||||
//tot_eta_y=0;
|
||||
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
etax=etamin+iby*etastep;
|
||||
for (int iby=0; iby<nbetaY; iby++) {
|
||||
etay=etamin+iby*etastepY;
|
||||
//cout << etax << endl;
|
||||
if (etax>=0 && etax<=1)
|
||||
hx[iby]=heta[iby+ib*nbeta];
|
||||
else {
|
||||
hx[iby]=0;
|
||||
}
|
||||
|
||||
// tot_eta_x+=hx[iby];
|
||||
if (etax>=0 && etax<=1)
|
||||
hy[iby]=heta[ib+iby*nbeta];
|
||||
if (etay>=0 && etay<=1)
|
||||
hy[iby]=heta[ib+iby*nbetaX];
|
||||
else
|
||||
hy[iby]=0;
|
||||
// tot_eta_y+=hy[iby];
|
||||
}
|
||||
|
||||
hix[0]=hx[0];
|
||||
|
||||
hiy[0]=hy[0];
|
||||
|
||||
for (int iby=1; iby<nbeta; iby++) {
|
||||
hix[iby]=hix[iby-1]+hx[iby];
|
||||
for (int iby=1; iby<nbetaY; iby++) {
|
||||
hiy[iby]=hiy[iby-1]+hy[iby];
|
||||
}
|
||||
|
||||
// ii=0;
|
||||
tot_eta_x=hix[nbeta-1]+1;
|
||||
tot_eta_y=hiy[nbeta-1]+1;
|
||||
tot_eta_y=hiy[nbetaY-1]+1;
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
if (tot_eta_x<=0) {
|
||||
hhx[ibx+ib*nbeta]=-1;
|
||||
//ii=(ibx)/nbeta;
|
||||
} else //if (hix[ibx]>(ii+1)*tot_eta_x*bsize)
|
||||
{
|
||||
//if (hix[ibx]>tot_eta_x*(ii+1)/nSubPixels) ii++;
|
||||
hhx[ibx+ib*nbeta]=hix[ibx]/tot_eta_x;
|
||||
}
|
||||
}
|
||||
/* if (ii!=(nSubPixels-1)) */
|
||||
/* cout << ib << " x " << tot_eta_x << " " << (ii+1)*tot_eta_x*bsize << " " << ii << " " << hix[nbeta-1]<< endl; */
|
||||
|
||||
//ii=0;
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int iby=0; iby<nbetaY; iby++) {
|
||||
if (tot_eta_y<=0) {
|
||||
hhy[ib+ibx*nbeta]=-1;
|
||||
hhy[ib+iby*nbetaX]=-1;
|
||||
//ii=(ibx*nSubPixels)/nbeta;
|
||||
} else {
|
||||
//if (hiy[ibx]>tot_eta_y*(ii+1)/nSubPixels) ii++;
|
||||
hhy[ib+ibx*nbeta]=hiy[ibx]/tot_eta_y;
|
||||
hhy[ib+iby*nbetaX]=hiy[iby]/tot_eta_y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (int ib=0; ib<nbetaY; ib++) {
|
||||
|
||||
for (int ibx=0; ibx<nbetaX; ibx++) {
|
||||
etax=etamin+ibx*etastepX;
|
||||
//cout << etax << endl;
|
||||
if (etax>=0 && etax<=1)
|
||||
hx[ibx]=heta[ibx+ib*nbetaX];
|
||||
else {
|
||||
hx[ibx]=0;
|
||||
}
|
||||
}
|
||||
hix[0]=hx[0];
|
||||
|
||||
for (int ibx=1; ibx<nbetaX; ibx++) {
|
||||
hix[ibx]=hix[ibx-1]+hx[ibx];
|
||||
}
|
||||
|
||||
|
||||
tot_eta_x=hix[nbetaX-1]+1;
|
||||
|
||||
for (int ibx=0; ibx<nbetaX; ibx++) {
|
||||
if (tot_eta_x<=0) {
|
||||
hhx[ibx+ib*nbetaX]=-1;
|
||||
}
|
||||
else {
|
||||
hhx[ibx+ib*nbetaX]=hix[ibx]/tot_eta_x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (int ibx=0; ibx<nbetaX; ibx++) {
|
||||
if (tot_eta_x<=0) {
|
||||
hhx[ibx+ib*nbetaX]=-1;
|
||||
} else {
|
||||
//if (hix[ibx]>tot_eta_x*(ii+1)/nSubPixels) ii++;
|
||||
hhx[ibx+ib*nbetaX]=hix[ibx]/tot_eta_x;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int ibx, iby, ib;
|
||||
|
||||
iby=0;
|
||||
while (hhx[iby*nbeta+nbeta/2]<0) iby++;
|
||||
while (hhx[iby*nbetaY+nbetaY/2]<0) iby++;
|
||||
for (ib=0; ib<iby;ib++) {
|
||||
for (ibx=0; ibx<nbeta;ibx++)
|
||||
hhx[ibx+nbeta*ib]=hhx[ibx+nbeta*iby];
|
||||
for (ibx=0; ibx<nbetaX;ibx++)
|
||||
hhx[ibx+nbetaX*ib]=hhx[ibx+nbetaX*iby];
|
||||
}
|
||||
iby=nbeta-1;
|
||||
iby=nbetaY-1;
|
||||
|
||||
while (hhx[iby*nbeta+nbeta/2]<0) iby--;
|
||||
for (ib=iby+1; ib<nbeta;ib++) {
|
||||
for (ibx=0; ibx<nbeta;ibx++)
|
||||
hhx[ibx+nbeta*ib]=hhx[ibx+nbeta*iby];
|
||||
while (hhx[iby*nbetaY+nbetaY/2]<0) iby--;
|
||||
for (ib=iby+1; ib<nbetaY;ib++) {
|
||||
for (ibx=0; ibx<nbetaX;ibx++)
|
||||
hhx[ibx+nbetaX*ib]=hhx[ibx+nbetaX*iby];
|
||||
}
|
||||
|
||||
iby=0;
|
||||
while (hhy[nbeta/2*nbeta+iby]<0) iby++;
|
||||
while (hhy[nbetaX/2*nbetaX+iby]<0) iby++;
|
||||
for (ib=0; ib<iby;ib++) {
|
||||
for (ibx=0; ibx<nbeta;ibx++)
|
||||
hhy[ib+nbeta*ibx]=hhy[iby+nbeta*ibx];
|
||||
for (ibx=0; ibx<nbetaY;ibx++)
|
||||
hhy[ib+nbetaX*ibx]=hhy[iby+nbetaX*ibx];
|
||||
}
|
||||
iby=nbeta-1;
|
||||
iby=nbetaX-1;
|
||||
|
||||
while (hhy[nbeta/2*nbeta+iby]<0) iby--;
|
||||
for (ib=iby+1; ib<nbeta;ib++) {
|
||||
for (ibx=0; ibx<nbeta;ibx++)
|
||||
hhy[ib+nbeta*ibx]=hhy[iby+nbeta*ibx];
|
||||
while (hhy[nbetaX/2*nbetaX+iby]<0) iby--;
|
||||
for (ib=iby+1; ib<nbetaX;ib++) {
|
||||
for (ibx=0; ibx<nbetaY;ibx++)
|
||||
hhy[ib+nbetaX*ibx]=hhy[iby+nbetaX*ibx];
|
||||
}
|
||||
|
||||
|
||||
@ -156,9 +170,16 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class eta2InterpolationPosXY : public virtual eta2InterpolationBase, public virtual etaInterpolationPosXY {
|
||||
public:
|
||||
eta2InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax),eta2InterpolationBase(nx,ny,ns, nb, emin,emax),etaInterpolationPosXY(nx,ny,ns, nb, emin,emax){
|
||||
eta2InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax),eta2InterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax),etaInterpolationPosXY(nx,ny, ns, nsy, nb, nby, emin, emax){
|
||||
// cout << "e2pxy " << nb << " " << emin << " " << emax << endl;
|
||||
};
|
||||
|
||||
@ -172,8 +193,8 @@ class eta2InterpolationPosXY : public virtual eta2InterpolationBase, public virt
|
||||
|
||||
class eta3InterpolationPosXY : public virtual eta3InterpolationBase, public virtual etaInterpolationPosXY {
|
||||
public:
|
||||
eta3InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax),eta3InterpolationBase(nx,ny,ns, nb, emin,emax), etaInterpolationPosXY(nx,ny,ns, nb, emin,emax){
|
||||
cout << "e3pxy " << nbeta << " " << etamin << " " << etamax << " " << nSubPixels<< endl;
|
||||
eta3InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax),eta3InterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax), etaInterpolationPosXY(nx,ny, ns, nsy, nb, nby, emin, emax){
|
||||
// cout << "e3pxy " << nbeta << " " << etamin << " " << etamax << " " << nSubPixels<< endl;
|
||||
};
|
||||
|
||||
eta3InterpolationPosXY(eta3InterpolationPosXY *orig): etaInterpolationBase(orig), etaInterpolationPosXY(orig) {};
|
||||
|
@ -29,19 +29,21 @@ class slsInterpolation
|
||||
{
|
||||
|
||||
public:
|
||||
slsInterpolation(int nx=400, int ny=400, int ns=25) :nPixelsX(nx), nPixelsY(ny), nSubPixels(ns), id(0) {
|
||||
slsInterpolation(int nx=400, int ny=400, int ns=25, int nsy=-1) :nPixelsX(nx), nPixelsY(ny), nSubPixelsX(ns), nSubPixelsY(nsy),id(0) {
|
||||
|
||||
hint=new int[ns*nx*ns*ny];
|
||||
if (nSubPixelsY<=0) nSubPixelsY=nSubPixelsX;
|
||||
hint=new int[nSubPixelsX*nx*nSubPixelsY*ny];
|
||||
|
||||
};
|
||||
|
||||
slsInterpolation(slsInterpolation *orig){
|
||||
nPixelsX=orig->nPixelsX;
|
||||
nPixelsY=orig->nPixelsY;
|
||||
nSubPixels=orig->nSubPixels;
|
||||
nSubPixelsX=orig->nSubPixelsX;
|
||||
nSubPixelsY=orig->nSubPixelsY;
|
||||
|
||||
hint=new int[nSubPixels*nPixelsX*nSubPixels*nPixelsY];
|
||||
memcpy(hint, orig->hint,nSubPixels*nPixelsX*nSubPixels*nPixelsY*sizeof(int));
|
||||
hint=new int[nSubPixelsX*nPixelsX*nSubPixelsY*nPixelsY];
|
||||
memcpy(hint, orig->hint,nSubPixelsX*nPixelsX*nSubPixelsY*nPixelsY*sizeof(int));
|
||||
|
||||
};
|
||||
|
||||
@ -51,23 +53,37 @@ class slsInterpolation
|
||||
return new slsInterpolation(this);
|
||||
}*/
|
||||
|
||||
int getNSubPixels() {return nSubPixels;};
|
||||
int getNSubPixelsX() {return nSubPixelsX;};
|
||||
int getNSubPixelsY() {return nSubPixelsY;};
|
||||
int getNSubPixels() {if (nSubPixelsX==nSubPixelsY) return nSubPixelsX; else return 0;};
|
||||
void getNSubPixels(int &nsx, int &nsy) {nsx=nSubPixelsX; nsy=nsx=nSubPixelsY;}
|
||||
|
||||
|
||||
int setNSubPixels(int ns) {
|
||||
if (ns>0 && ns!=nSubPixels) {
|
||||
void setNSubPixels(int ns, int nsy=-1) {
|
||||
|
||||
delete [] hint;
|
||||
nSubPixels=ns;
|
||||
hint=new int[nSubPixels*nPixelsX*nSubPixels*nPixelsY];
|
||||
}
|
||||
return nSubPixels;
|
||||
nSubPixelsX=ns;
|
||||
if (nsy>0) nSubPixelsY=nsy;
|
||||
else nSubPixelsY=ns;
|
||||
|
||||
hint=new int[nSubPixelsX*nPixelsX*nSubPixelsY*nPixelsY];
|
||||
|
||||
//return nSubPixels;
|
||||
}
|
||||
|
||||
int getImageSize(int &nnx, int &nny, int &ns) {
|
||||
nnx=nSubPixels*nPixelsX;
|
||||
nny=nSubPixels*nPixelsY;
|
||||
ns=nSubPixels;
|
||||
return nSubPixels*nSubPixels*nPixelsX*nPixelsY;
|
||||
|
||||
|
||||
|
||||
int getImageSize(int &nnx, int &nny, int &nsx, int &nsy) {
|
||||
nnx=nSubPixelsX*nPixelsX;
|
||||
nny=nSubPixelsY*nPixelsY;
|
||||
nsx=nSubPixelsX;
|
||||
nsy=nSubPixelsY;
|
||||
return nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY;
|
||||
};
|
||||
|
||||
|
||||
int getImageSize() {
|
||||
return nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY;
|
||||
};
|
||||
|
||||
|
||||
@ -92,14 +108,14 @@ class slsInterpolation
|
||||
//cout << "!" <<endl;
|
||||
float *gm=NULL;
|
||||
int *dummy=getInterpolatedImage();
|
||||
gm=new float[ nSubPixels* nSubPixels* nPixelsX*nPixelsY];
|
||||
gm=new float[ nSubPixelsX* nSubPixelsY* nPixelsX*nPixelsY];
|
||||
if (gm) {
|
||||
for (int ix=0; ix<nPixelsX*nSubPixels; ix++) {
|
||||
for (int iy=0; iy<nPixelsY*nSubPixels; iy++) {
|
||||
gm[iy*nPixelsX*nSubPixels+ix]=dummy[iy*nPixelsX*nSubPixels+ix];
|
||||
for (int ix=0; ix<nPixelsX*nSubPixelsX; ix++) {
|
||||
for (int iy=0; iy<nPixelsY*nSubPixelsY; iy++) {
|
||||
gm[iy*nPixelsX*nSubPixelsX+ix]=dummy[iy*nPixelsX*nSubPixelsX+ix];
|
||||
}
|
||||
}
|
||||
WriteToTiff(gm, imgname,nSubPixels* nPixelsX ,nSubPixels* nPixelsY);
|
||||
WriteToTiff(gm, imgname,nSubPixelsY* nPixelsX ,nSubPixelsY* nPixelsY);
|
||||
delete [] gm;
|
||||
} else cout << "Could not allocate float image " << endl;
|
||||
return NULL;
|
||||
@ -120,9 +136,9 @@ class slsInterpolation
|
||||
virtual void clearInterpolatedImage() {
|
||||
|
||||
|
||||
for (int ix=0; ix<nPixelsX*nSubPixels; ix++) {
|
||||
for (int iy=0; iy<nPixelsY*nSubPixels; iy++) {
|
||||
hint[iy*nPixelsX*nSubPixels+ix]=0;
|
||||
for (int ix=0; ix<nPixelsX*nSubPixelsX; ix++) {
|
||||
for (int iy=0; iy<nPixelsY*nSubPixelsY; iy++) {
|
||||
hint[iy*nPixelsX*nSubPixelsX+ix]=0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,11 +149,11 @@ class slsInterpolation
|
||||
|
||||
|
||||
virtual int *addToImage(double int_x, double int_y){
|
||||
int iy=((double)nSubPixels)*int_y;
|
||||
int ix=((double)nSubPixels)*int_x;
|
||||
if (ix>=0 && ix<(nPixelsX*nSubPixels) && iy<(nSubPixels*nPixelsY) && iy>=0 ){
|
||||
int iy=((double)nSubPixelsY)*int_y;
|
||||
int ix=((double)nSubPixelsX)*int_x;
|
||||
if (ix>=0 && ix<(nPixelsX*nSubPixelsX) && iy<(nSubPixelsY*nPixelsY) && iy>=0 ){
|
||||
// cout << int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << " " << hint[ix+iy*nPixelsX*nSubPixels];
|
||||
(*(hint+ix+iy*nPixelsX*nSubPixels))+=1;
|
||||
(*(hint+ix+iy*nPixelsX*nSubPixelsX))+=1;
|
||||
// cout << " " << hint[ix+iy*nPixelsX*nSubPixels] << endl;
|
||||
}// else
|
||||
// cout << "bad! "<< int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << endl;
|
||||
@ -180,11 +196,12 @@ class slsInterpolation
|
||||
/* cluster[2]=cl+6; */
|
||||
|
||||
sum=0;
|
||||
int xoff=0, yoff=0;
|
||||
#ifndef WRITE_QUAD
|
||||
double sumBL=0;
|
||||
double sumTL=0;
|
||||
double sumBR=0;
|
||||
double sumTR=0;
|
||||
int xoff=0, yoff=0;
|
||||
for (int ix=0; ix<3; ix++) {
|
||||
for (int iy=0; iy<3; iy++) {
|
||||
sum+=cl[ix+3*iy];
|
||||
@ -204,34 +221,95 @@ class slsInterpolation
|
||||
|
||||
|
||||
if(sumTL >= totquad){
|
||||
/* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; */
|
||||
/* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; */
|
||||
|
||||
/* #ifdef WRITE_QUAD */
|
||||
/* /\* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; *\/ */
|
||||
/* /\* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; *\/ */
|
||||
/* if (sumTL ==sum) { */
|
||||
/* #endif */
|
||||
corner = TOP_LEFT;
|
||||
totquad=sumTL;
|
||||
xoff=0;
|
||||
yoff=1;
|
||||
/* #ifdef WRITE_QUAD */
|
||||
/* } */
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
if(sumBR >= totquad){
|
||||
/* sDum[0][0] = cluster[0][1]; sDum[1][0] = cluster[1][1]; */
|
||||
/* sDum[0][1] = cluster[0][2]; sDum[1][1] = cluster[1][2]; */
|
||||
|
||||
/* #ifdef WRITE_QUAD */
|
||||
/* /\* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; *\/ */
|
||||
/* /\* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; *\/ */
|
||||
/* if (sumBR ==sum) { */
|
||||
/* #endif */
|
||||
corner = BOTTOM_RIGHT;
|
||||
xoff=1;
|
||||
yoff=0;
|
||||
corner = BOTTOM_RIGHT;
|
||||
totquad=sumBR;
|
||||
/* #ifdef WRITE_QUAD */
|
||||
/* } */
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
if(sumTR >= totquad){
|
||||
/* #ifdef WRITE_QUAD */
|
||||
/* /\* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; *\/ */
|
||||
/* /\* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; *\/ */
|
||||
/* if (sumTR ==sum) { */
|
||||
/* #endif */
|
||||
xoff=1;
|
||||
yoff=1;
|
||||
/* sDum[0][0] = cluster[1][1]; sDum[1][0] = cluster[2][1]; */
|
||||
/* sDum[0][1] = cluster[1][2]; sDum[1][1] = cluster[2][2]; */
|
||||
corner = TOP_RIGHT;
|
||||
totquad=sumTR;
|
||||
/* #ifdef WRITE_QUAD */
|
||||
/* } */
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef WRITE_QUAD
|
||||
|
||||
double sumB=0;
|
||||
double sumT=0;
|
||||
double sumR=0;
|
||||
double sumL=0;
|
||||
|
||||
for (int ix=0; ix<3; ix++) {
|
||||
for (int iy=0; iy<3; iy++) {
|
||||
sum+=cl[ix+3*iy];
|
||||
if (ix<1 ) sumL+=cl[ix+iy*3];
|
||||
if (ix>1) sumR+=cl[ix+iy*3];
|
||||
if (iy<1) sumB=cl[ix+iy*3];
|
||||
if (iy>1) sumT+=cl[ix+iy*3];
|
||||
}
|
||||
}
|
||||
|
||||
totquad=sum;
|
||||
if ( sumT==0 && sumR==0) {
|
||||
corner = BOTTOM_LEFT;
|
||||
xoff=0;
|
||||
yoff=0;
|
||||
} else if ( sumB==0 && sumR==0 ) {
|
||||
corner = TOP_LEFT;
|
||||
xoff=0;
|
||||
yoff=1;
|
||||
} else if ( sumT==0 && sumL==0) {
|
||||
corner = BOTTOM_RIGHT;
|
||||
xoff=1;
|
||||
yoff=0;
|
||||
} else if ( sumB==0 && sumL==0) {
|
||||
xoff=1;
|
||||
yoff=1;
|
||||
corner = TOP_RIGHT;
|
||||
} else
|
||||
printf("** bad 2x2 cluster!\n");
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
for (int ix=0; ix<2; ix++) {
|
||||
for (int iy=0; iy<2; iy++) {
|
||||
@ -495,7 +573,7 @@ class slsInterpolation
|
||||
|
||||
protected:
|
||||
int nPixelsX, nPixelsY;
|
||||
int nSubPixels;
|
||||
int nSubPixelsX, nSubPixelsY;
|
||||
int id;
|
||||
int *hint;
|
||||
};
|
||||
|
@ -1,18 +1,18 @@
|
||||
|
||||
INCDIR= -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ -I../../libs/rapidjson/
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3 -g -std=c++11 -Wall
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3 -std=c++11 -Wall -L../../build/bin/ -lSlsSupport
|
||||
#-L../../bin -lhdf5 -L.
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moenchZmqProcess moenchZmqProcessCtbGui
|
||||
|
||||
all: moenchZmqProcess
|
||||
#moenchZmqProcessCtbGui
|
||||
|
||||
moenchZmqProcess: moenchZmqProcess.cpp clean
|
||||
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP
|
||||
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP
|
||||
|
||||
moenchZmqProcessCtbGui: moenchZmqProcess.cpp clean
|
||||
g++ -o moenchZmqProcessCtbGui moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DCTBGUI
|
||||
#moenchZmqProcessCtbGui: moenchZmqProcess.cpp clean
|
||||
# g++ -o moenchZmqProcessCtbGui moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DCTBGUI
|
||||
|
||||
clean:
|
||||
rm -f moenchZmqProcess
|
||||
|
@ -16,7 +16,8 @@
|
||||
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
#include "noInterpolation.h"
|
||||
#include "etaInterpolationCleverAdaptiveBins.h"
|
||||
#include "etaInterpolationPosXY.h"
|
||||
//#include "etaInterpolationCleverAdaptiveBins.h"
|
||||
//#include "etaInterpolationRandomBins.h"
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
|
@ -1,13 +1,18 @@
|
||||
#define WRITE_QUAD
|
||||
//#define WRITE_QUAD
|
||||
#define DEVELOPER
|
||||
|
||||
#undef CORR
|
||||
#define C_GHOST 0.0004
|
||||
|
||||
#define CM_ROWS 20
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
#include "ZmqSocket.h"
|
||||
#ifndef RECT
|
||||
#include "moench03T1ZmqDataNew.h"
|
||||
#endif
|
||||
#ifdef RECT
|
||||
#include "moench03T1ZmqDataNewRect.h"
|
||||
#endif
|
||||
#include "moench03GhostSummation.h"
|
||||
#include "moench03CommonMode.h"
|
||||
#include <vector>
|
||||
@ -31,12 +36,12 @@
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
//#include <chrono>
|
||||
#include <chrono>
|
||||
#include <ctime> // time_t
|
||||
#include <cstdio>
|
||||
|
||||
using namespace std;
|
||||
//using namespace std::chrono;
|
||||
using namespace std::chrono;
|
||||
|
||||
//#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
@ -49,10 +54,11 @@ int main(int argc, char *argv[]) {
|
||||
*/
|
||||
FILE *of=NULL;
|
||||
int fifosize=5000;
|
||||
int etabins=1000;//nsubpix*2*100;
|
||||
int etabins=1000, etabinsy=1000;//nsubpix*2*100;
|
||||
double etamin=-1, etamax=2;
|
||||
int nSubPixels=2;
|
||||
int nSubPixelsX=2;
|
||||
// int emin, emax;
|
||||
int nSubPixelsY=2;
|
||||
// help
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number] [nthreads] [nsubpix] [gainmap] [etafile]\n");
|
||||
@ -71,17 +77,12 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
int ok;
|
||||
|
||||
// high_resolution_clock::time_point t1;
|
||||
// high_resolution_clock::time_point t2 ;
|
||||
time_t begin,end,finished;
|
||||
high_resolution_clock::time_point t1;
|
||||
high_resolution_clock::time_point t2 ;
|
||||
std::chrono::steady_clock::time_point begin,end,finished;
|
||||
//time_t begin,end,finished;
|
||||
int rms=0;
|
||||
|
||||
int nped=1000, nped0=100;
|
||||
|
||||
#ifdef PTC
|
||||
nped=10000;
|
||||
nped0=10000;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
if (argc > 4) {
|
||||
@ -101,10 +102,14 @@ int main(int argc, char *argv[]) {
|
||||
nthreads=atoi(argv[5]);
|
||||
|
||||
cout << "Number of threads is: " << nthreads << endl;
|
||||
if (argc>6)
|
||||
nSubPixels=atoi(argv[6]);
|
||||
cout << "Number of subpixels is: " << nSubPixels << endl;
|
||||
|
||||
if (argc>6) {
|
||||
nSubPixelsX=atoi(argv[6]);
|
||||
nSubPixelsY=nSubPixelsX;
|
||||
#ifdef RECT
|
||||
nSubPixelsX=2;
|
||||
#endif
|
||||
}
|
||||
cout << "Number of subpixels is: " << nSubPixelsX << " " << nSubPixelsY << endl;
|
||||
|
||||
char *gainfname=NULL;
|
||||
if (argc>7) {
|
||||
@ -119,12 +124,12 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew(5000,sizeof(int));
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||
cout << endl << " det" <<endl;
|
||||
int npx, npy;
|
||||
det->getDetectorSize(npx, npy);
|
||||
|
||||
|
||||
int send_something=0;
|
||||
|
||||
|
||||
int maxSize = npx*npy*2;//32*2*8192;//5000;//atoi(argv[3]);
|
||||
@ -137,15 +142,12 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
int ncol_cm=CM_ROWS;
|
||||
double xt_ghost=C_GHOST;
|
||||
|
||||
|
||||
moench03CommonMode *cm=NULL;
|
||||
moench03GhostSummation *gs=NULL;
|
||||
#ifdef CORR
|
||||
cm=new moench03CommonMode(ncol_cm);
|
||||
gs=new moench03GhostSummation(det, xt_ghost);
|
||||
#endif
|
||||
|
||||
double *gainmap=NULL;
|
||||
float *gm;
|
||||
double *gmap=NULL;
|
||||
@ -173,18 +175,18 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
|
||||
#ifndef INTERP
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(det,3, nSigma, 1, cm, nped, nped0, -1, -1, gainmap, gs);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(det,3, nSigma, 1, cm, 1000, 100, -1, -1, gainmap, gs);
|
||||
|
||||
multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize);
|
||||
|
||||
// multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
#endif
|
||||
#ifdef INTERP
|
||||
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(npx, npy, nSubPixels, etabins, etamin, etamax);
|
||||
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(npx, npy, nSubPixelsX,nSubPixelsY, etabins, etabinsy, etamin, etamax);
|
||||
|
||||
if (etafname) interp->readFlatField(etafname);
|
||||
|
||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, nSigma, 1, cm, nped, nped0, -1, -1, gainmap, gs);
|
||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs);
|
||||
multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize);
|
||||
#endif
|
||||
|
||||
@ -275,7 +277,17 @@ int main(int argc, char *argv[]) {
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
//uint32_t subFrameIndex = -1;
|
||||
#ifdef MOENCH_BRANCH
|
||||
uint32_t subFrameIndex = -1;
|
||||
int* flippedData = 0;
|
||||
#endif
|
||||
|
||||
uint64_t subframes=0;
|
||||
//uint64_t isubframe=0;
|
||||
uint64_t insubframe=0;
|
||||
double subnorm=1;
|
||||
uint64_t f0=-1, nsubframes=0, nnsubframe=0;
|
||||
|
||||
uint64_t fileindex = -1;
|
||||
string filename = "";
|
||||
// char* image = new char[size];
|
||||
@ -285,10 +297,10 @@ int main(int argc, char *argv[]) {
|
||||
int iframe=0;
|
||||
char ofname[10000];
|
||||
|
||||
char fname[10000];
|
||||
string fname;
|
||||
// int length;
|
||||
int *detimage;
|
||||
int nnx, nny,nns;
|
||||
int *detimage=NULL;
|
||||
int nnx, nny,nnsx, nnsy;
|
||||
//uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0,
|
||||
//uint32_t dynamicRange = 0;
|
||||
// infinite loop
|
||||
@ -304,12 +316,11 @@ int main(int argc, char *argv[]) {
|
||||
//int16_t *dout;//=new int16_t [nnx*nny];
|
||||
uint32_t dr = 32;
|
||||
int32_t *dout=NULL;//=new int32_t [nnx*nny];
|
||||
float *doutf=NULL;//=new int32_t [nnx*nny];
|
||||
uint16_t roundRNumber = 0;
|
||||
uint8_t detType = 0;
|
||||
uint8_t version = 0;
|
||||
// int* flippedData = 0;
|
||||
string* additionalJsonHeader = 0;
|
||||
//char* additionalJsonHeader = 0;
|
||||
string additionalJsonHeader="" ;
|
||||
|
||||
int32_t threshold=0;
|
||||
|
||||
@ -327,7 +338,7 @@ int main(int argc, char *argv[]) {
|
||||
frameMode fMode=eFrame;
|
||||
double *ped;
|
||||
|
||||
filter->getImageSize(nnx, nny,nns);
|
||||
filter->getImageSize(nnx, nny,nnsx, nnsy);
|
||||
|
||||
|
||||
|
||||
@ -350,10 +361,13 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
#endif
|
||||
// if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) {
|
||||
// cprintf(RED, "Got Dummy\n");
|
||||
cprintf(RED, "Got Dummy\n");
|
||||
// t1=high_resolution_clock::now();
|
||||
time(&end);
|
||||
//time(&end);
|
||||
//cout << "Measurement lasted " << difftime(end,begin) << endl;
|
||||
|
||||
end = std::chrono::steady_clock::now();
|
||||
cout << "Measurement lasted " << (end-begin).count()*0.000001 << " ms" << endl;
|
||||
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
@ -368,40 +382,75 @@ int main(int argc, char *argv[]) {
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
}
|
||||
} else {
|
||||
if (fMode==ePedestal) {
|
||||
sprintf(ofname,"%s_%ld_ped.tiff",fname,fileindex);
|
||||
mt->writePedestal(ofname);
|
||||
cout << "Writing pedestal to " << ofname << endl;
|
||||
if (rms) {
|
||||
sprintf(ofname,"%s_%ld_var.tiff",fname,fileindex);
|
||||
mt->writePedestalRMS(ofname);
|
||||
cout << "Writing pedestal variance to " << ofname << endl;
|
||||
}
|
||||
}
|
||||
send_something=0;
|
||||
if (fMode==ePedestal) {
|
||||
sprintf(ofname,"%s_%ld_ped.tiff",fname.c_str(),fileindex);
|
||||
mt->writePedestal(ofname);
|
||||
cout << "Writing pedestal to " << ofname << endl;
|
||||
if (rms){
|
||||
sprintf(ofname,"%s_%ld_var.tiff",fname.c_str(),fileindex);
|
||||
mt->writePedestalRMS(ofname);
|
||||
|
||||
}
|
||||
send_something=1;
|
||||
}
|
||||
#ifdef INTERP
|
||||
else if (fMode==eFlat) {
|
||||
mt->prepareInterpolation(ok);
|
||||
sprintf(ofname,"%s_%ld_eta.tiff",fname,fileindex);
|
||||
mt->writeFlatField(ofname);
|
||||
cout << "Writing eta to " << ofname << endl;
|
||||
}
|
||||
else if (fMode==eFlat) {
|
||||
mt->prepareInterpolation(ok);
|
||||
sprintf(ofname,"%s_%ld_eta.tiff",fname.c_str(),fileindex);
|
||||
mt->writeFlatField(ofname);
|
||||
cout << "Writing eta to " << ofname << endl;
|
||||
send_something=1;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
sprintf(ofname,"%s_%ld.tiff",fname,fileindex);
|
||||
mt->writeImage(ofname);
|
||||
cout << "Writing image to " << ofname << endl;
|
||||
}
|
||||
// cout << nns*nnx*nny*nns*dr/8 << " " << length << endl;
|
||||
else {
|
||||
if (subframes>0 ) {
|
||||
if (insubframe>0) {
|
||||
sprintf(ofname,"%s_sf%ld_%ld.tiff",fname.c_str(),nnsubframe,fileindex);
|
||||
// mt->writeImage(ofname);
|
||||
doutf= new float[nnx*nny];
|
||||
if (subframes>0 && insubframe!=subframes && insubframe>0)
|
||||
subnorm=((double)subframes)/((double)insubframe);
|
||||
else
|
||||
subnorm=1.;
|
||||
for (int ix=0; ix<nnx*nny; ix++) {
|
||||
doutf[ix]=detimage[ix]*subnorm;
|
||||
if (doutf[ix]<0) doutf[ix]=0;
|
||||
}
|
||||
|
||||
cout << "Writing image to " << ofname << endl;
|
||||
|
||||
WriteToTiff(doutf,ofname ,nnx, nny);
|
||||
|
||||
if (doutf)
|
||||
delete [] doutf;
|
||||
doutf=NULL;
|
||||
|
||||
nsubframes++;
|
||||
insubframe=0;
|
||||
send_something=1;
|
||||
}
|
||||
} else {
|
||||
sprintf(ofname,"%s_%ld.tiff",fname.c_str(),fileindex);
|
||||
mt->writeImage(ofname);
|
||||
send_something=1;
|
||||
}
|
||||
|
||||
cout << "Writing image to " << ofname << endl;
|
||||
}
|
||||
// cout << nns*nnx*nny*nns*dr/8 << " " << length << endl;
|
||||
|
||||
if (send) {
|
||||
|
||||
|
||||
if (fMode==ePedestal) {
|
||||
cprintf(MAGENTA,"Get pedestal!\n");
|
||||
nns=1;
|
||||
nnsx=1;
|
||||
nnsy=1;
|
||||
|
||||
nnx=npx;
|
||||
nny=npy;
|
||||
//dout= new int16_t[nnx*nny*nns*nns];
|
||||
dout= new int32_t[nnx*nny*nns*nns];
|
||||
dout= new int32_t[nnx*nny*nnsx*nnsy];
|
||||
// cout << "get pedestal " << endl;
|
||||
ped=mt->getPedestal();
|
||||
// cout << "got pedestal " << endl;
|
||||
@ -409,7 +458,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
dout[ix]=ped[ix];
|
||||
// if (ix<100*400)
|
||||
// cout << ix << " " << ped[ix] << " "<< dout[ix] << endl;
|
||||
// cout << ix << " " << ped[ix] << endl;
|
||||
}
|
||||
|
||||
}
|
||||
@ -427,15 +476,19 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
detimage=mt->getImage(nnx,nny,nns);
|
||||
detimage=mt->getImage(nnx,nny,nnsx, nnsy);
|
||||
cprintf(MAGENTA,"Get image!\n");
|
||||
cout << nnx << " " << nny << " " << nns << endl;
|
||||
cout << nnx << " " << nny << " " << nnsx << " " << nnsy << endl;
|
||||
// nns=1;
|
||||
// nnx=npx;
|
||||
// nny=npy;
|
||||
// nnx=nnx*nns;
|
||||
//nny=nny*nns;
|
||||
dout= new int32_t[nnx*nny];
|
||||
if (subframes>0 && insubframe!=subframes && insubframe>0)
|
||||
subnorm=((double)subframes)/((double)insubframe);
|
||||
else
|
||||
subnorm=1.;
|
||||
for (int ix=0; ix<nnx*nny; ix++) {
|
||||
// for (int iy=0; iy<nny*nns; iy++) {
|
||||
// for (int isx=0; isx<nns; isx++) {
|
||||
@ -447,67 +500,45 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// }
|
||||
// }
|
||||
dout[ix]=detimage[ix];
|
||||
if (dout[ix]<0) dout[ix]=0;
|
||||
//cout << ix << " " << dout[ix] << endl;
|
||||
dout[ix]=detimage[ix]*subnorm;
|
||||
if (dout[ix]<0) dout[ix]=0;
|
||||
// cout << ix << " " << dout[ix] << endl;
|
||||
// }
|
||||
}
|
||||
}
|
||||
//if ((insubframe>0 && subframes>0) || (subframes<=0) ){
|
||||
|
||||
|
||||
//// int SendHeaderData ( int index, bool dummy, uint32_t jsonversion, uint32_t dynamicrange = 0, uint64_t fileIndex = 0,
|
||||
// uint32_t ndetx = 0, uint32_t ndety = 0, uint32_t npixelsx = 0, uint32_t npixelsy = 0, uint32_t imageSize = 0,
|
||||
// uint64_t acqIndex = 0, uint64_t fIndex = 0, const char* fname = NULL,
|
||||
// uint64_t frameNumber = 0, uint32_t expLength = 0, uint32_t packetNumber = 0,
|
||||
// uint64_t bunchId = 0, uint64_t timestamp = 0,
|
||||
// uint16_t modId = 0, uint16_t row = 0, uint16_t column = 0, uint16_t reserved = 0,
|
||||
// uint32_t debug = 0, uint16_t roundRNumber = 0,
|
||||
// uint8_t detType = 0, uint8_t version = 0, int gapPixelsEnable = 0, int flippedDataX = 0,
|
||||
// char* additionalJsonHeader = 0) {
|
||||
|
||||
|
||||
|
||||
// cout << "Sending image size " << nnx << " " << nny << endl;
|
||||
|
||||
// #ifndef DEVELOPER
|
||||
// #ifndef MOENCH_BRANCH
|
||||
// zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, 1,1, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex,0 , packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, additionalJsonHeader);
|
||||
// #endif
|
||||
// #endif
|
||||
|
||||
|
||||
// #ifdef DEVELOPER
|
||||
// #ifdef CTBGUI
|
||||
// zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
|
||||
// #endif
|
||||
// #ifndef CTBGUI
|
||||
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 1,1,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
|
||||
//#endif
|
||||
|
||||
|
||||
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
|
||||
cprintf(GREEN, "Sent Data\n");
|
||||
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
if (dout)
|
||||
delete [] dout;
|
||||
dout=NULL;
|
||||
|
||||
if(send_something) {
|
||||
|
||||
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 1,1,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,&additionalJsonHeader);
|
||||
|
||||
|
||||
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
|
||||
cprintf(GREEN, "Sent Data\n");
|
||||
}
|
||||
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
if (dout)
|
||||
delete [] dout;
|
||||
dout=NULL;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
mt->clearImage();
|
||||
|
||||
newFrame=1;
|
||||
//t2 = high_resolution_clock::now();
|
||||
|
||||
time(&finished);
|
||||
// auto meas_duration = duration_cast<microseconds>( t2 - t0 ).count();
|
||||
// auto real_duration = duration_cast<microseconds>( t2 - t1 ).count();
|
||||
|
||||
cout << "Measurement lasted " << difftime(end,begin) << endl;
|
||||
cout << "Processing lasted " << difftime(finished,begin) << endl;
|
||||
//time(&finished);
|
||||
//cout << "Processing lasted " << difftime(finished,begin) << endl;
|
||||
|
||||
finished = std::chrono::steady_clock::now();
|
||||
cout << "Processing lasted " << (finished-begin).count()*0.000001 << " ms" << endl;
|
||||
#ifdef OPTIMIZE
|
||||
return 0;
|
||||
#endif
|
||||
continue; //continue to not get out
|
||||
|
||||
|
||||
@ -515,7 +546,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
#ifdef NEWZMQ
|
||||
if (newFrame) {
|
||||
time(&begin);
|
||||
begin = std::chrono::steady_clock::now();
|
||||
//time(&begin);
|
||||
// t0 = high_resolution_clock::now();
|
||||
//cout <<"new frame" << endl;
|
||||
|
||||
@ -541,8 +573,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
//dataSize=size;
|
||||
|
||||
strcpy(fname,filename.c_str());
|
||||
|
||||
//strcpy(fname,filename.c_str());
|
||||
fname=filename;
|
||||
// cprintf(BLUE, "Header Info:\n"
|
||||
// "size: %u\n"
|
||||
// "multisize: %u\n"
|
||||
@ -585,7 +617,7 @@ int main(int argc, char *argv[]) {
|
||||
if (frameMode_s == "pedestal"){
|
||||
fMode=ePedestal;
|
||||
//isPedestal=1;
|
||||
} else if (frameMode_s == "newpedestal"){
|
||||
} else if (frameMode_s == "newPedestal"){
|
||||
mt->newDataSet(); //resets pedestal
|
||||
// cprintf(MAGENTA, "Resetting pedestal\n");
|
||||
fMode=ePedestal;
|
||||
@ -594,8 +626,8 @@ int main(int argc, char *argv[]) {
|
||||
mt->newDataSet(); //resets pedestal
|
||||
// cprintf(MAGENTA, "Resetting pedestal\n");
|
||||
fMode=ePedestal;
|
||||
rms=1;
|
||||
//isPedestal=1;
|
||||
rms=1;
|
||||
}
|
||||
#ifdef INTERP
|
||||
else if (frameMode_s == "flatfield") {
|
||||
@ -616,13 +648,11 @@ int main(int argc, char *argv[]) {
|
||||
frameMode_s="frame";
|
||||
}
|
||||
}
|
||||
cprintf(MAGENTA, "%s\n" , frameMode_s.c_str());
|
||||
} else
|
||||
cprintf(RED, "%s\n" , frameMode_s.c_str());
|
||||
|
||||
}
|
||||
cprintf(MAGENTA, "%s\n" , frameMode_s.c_str());
|
||||
mt->setFrameMode(fMode);
|
||||
|
||||
threshold=0;
|
||||
// threshold=0;
|
||||
cprintf(MAGENTA, "Threshold: ");
|
||||
if (doc.HasMember("threshold")) {
|
||||
if (doc["threshold"].IsInt()) {
|
||||
@ -690,11 +720,10 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
|
||||
} else
|
||||
cprintf(RED, "%s\n" , frameMode_s.c_str());
|
||||
}
|
||||
|
||||
mt->setDetectorMode(dMode);
|
||||
cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
|
||||
|
||||
// cout << "done " << endl;
|
||||
|
||||
@ -737,6 +766,21 @@ int main(int argc, char *argv[]) {
|
||||
// mt->setNSubPixels(nSubPixels);
|
||||
// }
|
||||
|
||||
// threshold=0;
|
||||
cprintf(MAGENTA, "Subframes: ");
|
||||
subframes=0;
|
||||
//isubframe=0;
|
||||
insubframe=0;
|
||||
subnorm=1;
|
||||
f0=0;
|
||||
nnsubframe=0;
|
||||
if (doc.HasMember("subframes")) {
|
||||
if (doc["subframes"].IsInt()) {
|
||||
subframes=doc["subframes"].GetInt();
|
||||
}
|
||||
}
|
||||
cprintf(MAGENTA, "%ld\n", subframes);
|
||||
|
||||
|
||||
newFrame=0;
|
||||
/* zmqsocket->CloseHeaderMessage();*/
|
||||
@ -745,7 +789,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// cout << "file" << endl;
|
||||
// cout << "data " << endl;
|
||||
if (of==NULL && dMode!=eAnalog && fMode!=ePedestal && threshold<=0) {
|
||||
if (of==NULL) {
|
||||
#ifdef WRITE_QUAD
|
||||
sprintf(ofname,"%s_%ld.clust2",filename.c_str(),fileindex);
|
||||
#endif
|
||||
@ -760,33 +804,99 @@ int main(int argc, char *argv[]) {
|
||||
mt->setFilePointer(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// cout << "data" << endl;
|
||||
// get data
|
||||
// acqIndex = doc["acqIndex"].GetUint64();
|
||||
|
||||
frameIndex = doc["fIndex"].GetUint64();
|
||||
|
||||
// subFrameIndex = doc["expLength"].GetUint();
|
||||
|
||||
// bunchId=doc["bunchId"].GetUint();
|
||||
// timestamp=doc["timestamp"].GetUint();
|
||||
packetNumber=doc["packetNumber"].GetUint();
|
||||
// cout << acqIndex << " " << frameIndex << " " << subFrameIndex << " "<< bunchId << " " << timestamp << " " << packetNumber << endl;
|
||||
if (packetNumber>=40) {
|
||||
//*((int*)buff)=frameIndex;
|
||||
memcpy(buff,&frameIndex,sizeof(int));
|
||||
//length =
|
||||
zmqsocket->ReceiveData(0, buff+sizeof(int), size);
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
cprintf(GREEN, "Frame\n");
|
||||
} else {
|
||||
cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber);
|
||||
//length =
|
||||
zmqsocket->ReceiveData(0, dummybuff, size);
|
||||
packetNumber=doc["packetNumber"].GetUint();
|
||||
// cout << acqIndex << " " << frameIndex << " " << subFrameIndex << " "<< bunchId << " " << timestamp << " " << packetNumber << endl;
|
||||
//cprintf(GREEN, "frame\n");
|
||||
if (packetNumber>=40) {
|
||||
//*((int*)buff)=frameIndex;
|
||||
if (insubframe==0) f0=frameIndex;
|
||||
memcpy(buff,&frameIndex,sizeof(int));
|
||||
//length =
|
||||
zmqsocket->ReceiveData(0, buff+sizeof(int), size);
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
insubframe++;
|
||||
nsubframes=frameIndex+1-f0;
|
||||
} else {
|
||||
cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber);
|
||||
//length =
|
||||
zmqsocket->ReceiveData(0, dummybuff, size);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (subframes>0 && insubframe>=subframes && fMode==eFrame) {
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
detimage=mt->getImage(nnx,nny,nnsx, nnsy);
|
||||
cprintf(MAGENTA,"Get image!\n");
|
||||
dout= new int32_t[nnx*nny];
|
||||
doutf= new float[nnx*nny];
|
||||
if (subframes>0 && insubframe!=subframes && insubframe>0)
|
||||
subnorm=((double)subframes)/((double)insubframe);
|
||||
else
|
||||
subnorm=1.;
|
||||
for (int ix=0; ix<nnx*nny; ix++) {
|
||||
dout[ix]=detimage[ix]*subnorm;
|
||||
if (dout[ix]<0) dout[ix]=0;
|
||||
doutf[ix]=dout[ix];
|
||||
}
|
||||
sprintf(ofname,"%s_sf%ld_%ld.tiff",fname.c_str(),nnsubframe,fileindex);
|
||||
|
||||
cout << "Writing image to " << ofname << endl;
|
||||
|
||||
WriteToTiff(doutf,ofname ,nnx, nny);
|
||||
nsubframes++;
|
||||
insubframe=0;
|
||||
nnsubframe++;
|
||||
|
||||
|
||||
|
||||
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 1,1,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,&additionalJsonHeader);
|
||||
|
||||
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
|
||||
cprintf(GREEN, "Sent subdata\n");
|
||||
|
||||
|
||||
if (dout)
|
||||
delete [] dout;
|
||||
dout=NULL;
|
||||
|
||||
if (doutf)
|
||||
delete [] doutf;
|
||||
doutf=NULL;
|
||||
|
||||
mt->clearImage();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
iframe++;
|
||||
|
||||
} // exiting infinite loop
|
||||
|
@ -95,7 +95,7 @@ public:
|
||||
virtual int *getImage() {
|
||||
return det->getImage();
|
||||
}
|
||||
virtual int getImageSize(int &nnx, int &nny, int &ns) {return det->getImageSize(nnx, nny, ns);};
|
||||
virtual int getImageSize(int &nnx, int &nny, int &ns, int &nsy) {return det->getImageSize(nnx, nny, ns, nsy);};
|
||||
virtual int getDetectorSize(int &nnx, int &nny) {return det->getDetectorSize(nnx, nny);};
|
||||
|
||||
virtual ~threadedAnalogDetector() {StopThread(); delete fifoFree; delete fifoData;}
|
||||
@ -123,7 +123,7 @@ public:
|
||||
return fifoFree->pop(ptr);
|
||||
}
|
||||
|
||||
virtual int isBusy() {return busy;}
|
||||
virtual int isBusy() {if (fifoData->isEmpty() && busy==0) return 0; else return 1;}
|
||||
|
||||
//protected:
|
||||
/** Implement this method in your subclass with the code you want your thread to run. */
|
||||
@ -221,10 +221,10 @@ FILE *getFilePointer(){return det->getFilePointer();};
|
||||
}
|
||||
|
||||
|
||||
virtual int setNSubPixels(int ns) {
|
||||
virtual int setNSubPixels(int ns, int nsy) {
|
||||
slsInterpolation *interp=(det)->getInterpolation();
|
||||
if (interp) return interp->setNSubPixels(ns);
|
||||
else return 1;};
|
||||
if (interp) interp->setNSubPixels(ns, nsy);
|
||||
return 1;};
|
||||
|
||||
|
||||
virtual slsInterpolation *setInterpolation(slsInterpolation *f){
|
||||
@ -249,7 +249,7 @@ protected:
|
||||
}
|
||||
|
||||
void * processData() {
|
||||
busy=1;
|
||||
// busy=1;
|
||||
while (!stop) {
|
||||
if (fifoData->isEmpty()) {
|
||||
busy=0;
|
||||
@ -259,6 +259,7 @@ protected:
|
||||
fifoData->pop(data); //blocking!
|
||||
det->processData(data);
|
||||
fifoFree->push(data);
|
||||
//busy=0;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@ -313,11 +314,11 @@ public:
|
||||
|
||||
virtual void newDataSet(){for (int i=0; i<nThreads; i++) dets[i]->newDataSet();};
|
||||
|
||||
virtual int *getImage(int &nnx, int &nny, int &ns) {
|
||||
virtual int *getImage(int &nnx, int &nny, int &ns, int &nsy) {
|
||||
int *img;
|
||||
// int nnx, nny, ns;
|
||||
// int nnx, nny, ns;
|
||||
int nn=dets[0]->getImageSize(nnx, nny,ns);
|
||||
int nn=dets[0]->getImageSize(nnx, nny,ns, nsy);
|
||||
if (image) {
|
||||
delete image;
|
||||
image=NULL;
|
||||
@ -362,10 +363,10 @@ public:
|
||||
/* dets[ii]->writeImage(tit); */
|
||||
/* } */
|
||||
/* #endif */
|
||||
int nnx, nny, ns;
|
||||
getImage(nnx, nny, ns);
|
||||
int nnx, nny, ns, nsy;
|
||||
getImage(nnx, nny, ns,nsy);
|
||||
//int nnx, nny, ns;
|
||||
int nn=dets[0]->getImageSize(nnx, nny, ns);
|
||||
int nn=dets[0]->getImageSize(nnx, nny, ns, nsy);
|
||||
float *gm=new float[nn];
|
||||
if (gm) {
|
||||
for (int ix=0; ix<nn; ix++) {
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
virtual int setNSubPixels(int ns) { return (dets[0])->setNSubPixels(ns);};
|
||||
/* virtual int setNSubPixels(int ns) { return (dets[0])->setNSubPixels(ns);}; */
|
||||
|
||||
virtual void resetFlatField() {(dets[0])->resetFlatField();};
|
||||
|
||||
@ -69,13 +69,13 @@ public:
|
||||
|
||||
|
||||
|
||||
virtual int *getImage(int &nnx, int &nny, int &ns) {
|
||||
if (getInterpolation()==NULL) return multiThreadedAnalogDetector::getImage(nnx,nny,ns);
|
||||
virtual int *getImage(int &nnx, int &nny, int &nsx, int &nsy) {
|
||||
if (getInterpolation()==NULL) return multiThreadedAnalogDetector::getImage(nnx,nny,nsx, nsy);
|
||||
//if one interpolates, the whole image is stored in detector 0;
|
||||
int *img;
|
||||
// int nnx, nny, ns;
|
||||
// int nnx, nny, ns;
|
||||
int nn=dets[0]->getImageSize(nnx, nny,ns);
|
||||
int nn=dets[0]->getImageSize(nnx, nny,nsx, nsy);
|
||||
if (image) {
|
||||
delete image;
|
||||
image=NULL;
|
||||
|
@ -10,7 +10,7 @@ class pedestalSubtraction {
|
||||
\param nn number of samples to calculate the moving average (defaults to 1000)
|
||||
*/
|
||||
pedestalSubtraction (int nn=1000) : stat(nn) {};
|
||||
|
||||
/* void setPointers(double *me, double *va) {mean=me; var=va; stat.setPointers(mean, var);}; */
|
||||
/** virtual destructorr
|
||||
*/
|
||||
virtual ~pedestalSubtraction() {};
|
||||
|
@ -50,7 +50,6 @@ public analogDetector<uint16_t> {
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
singlePhotonDetector(slsDetectorData<uint16_t> *d,
|
||||
int csize=3,
|
||||
@ -58,7 +57,7 @@ public analogDetector<uint16_t> {
|
||||
int sign=1,
|
||||
commonModeSubtraction *cm=NULL,
|
||||
int nped=1000,
|
||||
int nd=100, int nnx=-1, int nny=-1, double *gm=NULL, ghostSummation<uint16_t> *gs=NULL) : analogDetector<uint16_t>(d, sign, cm, nped, nnx, nny, gm, gs), nDark(nd), eventMask(NULL),nSigma (nsigma), eMin(-1), eMax(-1), clusterSize(csize), clusterSizeY(csize), clusters(NULL), quad(UNDEFINED_QUADRANT), tot(0), quadTot(0) {
|
||||
int nd=100, int nnx=-1, int nny=-1, double *gm=NULL, ghostSummation<uint16_t> *gs=NULL) : analogDetector<uint16_t>(d, sign, cm, nped, nnx, nny, gm, gs), nDark(nd), eventMask(NULL),nSigma (nsigma), eMin(-1), eMax(-1), clusterSize(csize), clusterSizeY(csize), c2(1),c3(1), clusters(NULL), quad(UNDEFINED_QUADRANT), tot(0), quadTot(0) {
|
||||
|
||||
|
||||
|
||||
@ -66,13 +65,18 @@ public analogDetector<uint16_t> {
|
||||
fm=new pthread_mutex_t ;
|
||||
|
||||
eventMask=new eventType*[ny];
|
||||
// val=new double*[ny];
|
||||
for (int i=0; i<ny; i++) {
|
||||
eventMask[i]=new eventType[nx];
|
||||
// val[i]=new double[nx];
|
||||
}
|
||||
|
||||
if (ny==1)
|
||||
clusterSizeY=1;
|
||||
|
||||
|
||||
c2=sqrt((clusterSizeY+1)/2* (clusterSize+1)/2);
|
||||
c3=sqrt(clusterSizeY*clusterSize);
|
||||
// cluster=new single_photon_hit(clusterSize,clusterSizeY);
|
||||
clusters=new single_photon_hit[nx*ny];
|
||||
|
||||
@ -100,8 +104,10 @@ public analogDetector<uint16_t> {
|
||||
myFile=orig->myFile;
|
||||
|
||||
eventMask=new eventType*[ny];
|
||||
// val=new double*[ny];
|
||||
for (int i=0; i<ny; i++) {
|
||||
eventMask[i]=new eventType[nx];
|
||||
// val[i]=new double[nx];
|
||||
}
|
||||
eMin=orig->eMin;
|
||||
eMax=orig->eMax;
|
||||
@ -111,6 +117,10 @@ public analogDetector<uint16_t> {
|
||||
clusterSize=orig->clusterSize;
|
||||
clusterSizeY=orig->clusterSizeY;
|
||||
// cluster=new single_photon_hit(clusterSize,clusterSizeY);
|
||||
|
||||
c2=sqrt((clusterSizeY+1)/2* (clusterSize+1)/2);
|
||||
c3=sqrt(clusterSizeY*clusterSize);
|
||||
|
||||
clusters=new single_photon_hit[nx*ny];
|
||||
|
||||
// cluster=clusters;
|
||||
@ -124,7 +134,9 @@ public analogDetector<uint16_t> {
|
||||
gmap=orig->gmap;
|
||||
nphTot=0;
|
||||
nphFrame=0;
|
||||
|
||||
nphTot=0;
|
||||
nphFrame=0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -196,7 +208,6 @@ public analogDetector<uint16_t> {
|
||||
int nn=0;
|
||||
double max=0, tl=0, tr=0, bl=0,br=0, v;
|
||||
double rms=0;
|
||||
|
||||
int cm=0;
|
||||
if (cmSub) cm=1;
|
||||
|
||||
@ -218,8 +229,8 @@ public analogDetector<uint16_t> {
|
||||
cout << "add to common mode?"<< endl;
|
||||
addToCommonMode(data);
|
||||
}
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (iy=ymin; iy<ymax; ++iy) {
|
||||
for (ix=xmin; ix<xmax; ++ix) {
|
||||
if (det->isGood(ix,iy)) {
|
||||
val=subtractPedestal(data,ix,iy, cm);
|
||||
|
||||
@ -236,8 +247,8 @@ public analogDetector<uint16_t> {
|
||||
}
|
||||
}
|
||||
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (iy=ymin; iy<ymax; ++iy) {
|
||||
for (ix=xmin; ix<xmax; ++ix) {
|
||||
|
||||
if (det->isGood(ix,iy)) {
|
||||
eventMask[iy][ix]=PEDESTAL;
|
||||
@ -346,18 +357,23 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
|
||||
|
||||
int nph=0;
|
||||
double val[ny][nx];
|
||||
int cy=(clusterSizeY+1)/2;
|
||||
int cs=(clusterSize+1)/2;
|
||||
// const int cy=(clusterSizeY+1)/2;
|
||||
//const int cs=(clusterSize+1)/2;
|
||||
|
||||
//int ir, ic;
|
||||
|
||||
eventType ee;
|
||||
double max=0, tl=0, tr=0, bl=0,br=0, *v;
|
||||
int cm=0;
|
||||
int good=1;
|
||||
if (cmSub) cm=1;
|
||||
int ir, ic;
|
||||
// double quadTot;
|
||||
//quadrant quad;
|
||||
double rms;
|
||||
//if (cmSub) cm=1;
|
||||
double val[ny][nx];
|
||||
if (ph==NULL)
|
||||
ph=image;
|
||||
|
||||
|
||||
if (iframe<nDark) {
|
||||
addToPedestal(data);
|
||||
return 0;
|
||||
@ -366,13 +382,15 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
|
||||
|
||||
|
||||
if (cm)
|
||||
if (cmSub) {
|
||||
addToCommonMode(data);
|
||||
cm=1;
|
||||
}
|
||||
|
||||
for (iy=ymin; iy<ymax; ++iy) {
|
||||
for (ix=xmin; ix<xmax; ++ix) {
|
||||
if (det->isGood(ix,iy)==0) continue;
|
||||
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
if (det->isGood(ix,iy)) {
|
||||
max=0;
|
||||
tl=0;
|
||||
tr=0;
|
||||
@ -384,97 +402,120 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
|
||||
|
||||
|
||||
eventMask[iy][ix]=PEDESTAL;
|
||||
//eventMask[iy][ix]
|
||||
ee=PEDESTAL;
|
||||
|
||||
|
||||
(clusters+nph)->rms=getPedestalRMS(ix,iy);
|
||||
rms=getPedestalRMS(ix,iy);
|
||||
// cluster=clusters+nph;
|
||||
|
||||
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
// cout << ix << " " << iy << endl;
|
||||
for (ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
|
||||
if ((iy+ir)>=iy && (iy+ir)<ny && (ix+ic)>=ix && (ix+ic)<nx) {
|
||||
val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir, cm);
|
||||
}
|
||||
v=&(val[iy+ir][ix+ic]);
|
||||
tot+=*v;
|
||||
if (ir<=0 && ic<=0)
|
||||
bl+=*v;
|
||||
if (ir<=0 && ic>=0)
|
||||
br+=*v;
|
||||
if (ir>=0 && ic<=0)
|
||||
tl+=*v;
|
||||
if (ir>=0 && ic>=0)
|
||||
tr+=*v;
|
||||
if (*v>max) {
|
||||
max=*v;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
v=&(val[iy+ir][ix+ic]);
|
||||
tot+=*v;
|
||||
if (ir<=0 && ic<=0)
|
||||
bl+=*v;
|
||||
if (ir<=0 && ic>=0)
|
||||
br+=*v;
|
||||
if (ir>=0 && ic<=0)
|
||||
tl+=*v;
|
||||
if (ir>=0 && ic>=0)
|
||||
tr+=*v;
|
||||
if (*v>max) {
|
||||
max=*v;
|
||||
}
|
||||
|
||||
|
||||
if (ir==0 && ic==0) {
|
||||
if (*v<-nSigma*(clusters+nph)->rms)
|
||||
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
|
||||
else if (*v>nSigma*(clusters+nph)->rms)
|
||||
eventMask[iy][ix]=PHOTON;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (eventMask[iy][ix]==PHOTON && val[iy][ix]<max)
|
||||
continue;
|
||||
|
||||
if (bl>=br && bl>=tl && bl>=tr) {
|
||||
(clusters+nph)->quad=BOTTOM_LEFT;
|
||||
(clusters+nph)->quadTot=bl;
|
||||
} else if (br>=bl && br>=tl && br>=tr) {
|
||||
(clusters+nph)->quad=BOTTOM_RIGHT;
|
||||
(clusters+nph)->quadTot=br;
|
||||
} else if (tl>=br && tl>=bl && tl>=tr) {
|
||||
(clusters+nph)->quad=TOP_LEFT;
|
||||
(clusters+nph)->quadTot=tl;
|
||||
} else if (tr>=bl && tr>=tl && tr>=br) {
|
||||
(clusters+nph)->quad=TOP_RIGHT;
|
||||
(clusters+nph)->quadTot=tr;
|
||||
/* if (ix==50 && iy==50) */
|
||||
/* cout << id << " " << ix << " " << iy << " " << det->getValue(data,ix,iy)<< " " << val[iy][ix] << " " << getPedestal(ix,iy) << " " << rms << endl; */
|
||||
if (val[iy][ix]<-nSigma*rms){
|
||||
ee=NEGATIVE_PEDESTAL;
|
||||
continue;
|
||||
}
|
||||
if (max>nSigma*rms){
|
||||
// cout << "ph1 " << max << " " << nSigma*rms << endl;
|
||||
ee=PHOTON;
|
||||
if (val[iy][ix]<max)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (max>nSigma*(clusters+nph)->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*(clusters+nph)->rms || ((clusters+nph)->quadTot)>sqrt(cy*cs)*nSigma*(clusters+nph)->rms) {
|
||||
if (val[iy][ix]>=max) {
|
||||
eventMask[iy][ix]=PHOTON_MAX;
|
||||
(clusters+nph)->tot=tot;
|
||||
(clusters+nph)->x=ix;
|
||||
(clusters+nph)->y=iy;
|
||||
// (clusters+nph)->iframe=det->getFrameNumber(data);
|
||||
// cout << det->getFrameNumber(data) << " " << (clusters+nph)->iframe << endl;
|
||||
(clusters+nph)->ped=getPedestal(ix,iy,0);
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
(clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir);
|
||||
else if (tot>c3*nSigma*rms) {
|
||||
// cout << "ph3 " << tot << " " << c3*nSigma*rms << endl;
|
||||
ee=PHOTON;
|
||||
}
|
||||
#ifndef WRITE_QUAD
|
||||
else {
|
||||
#endif
|
||||
quad=BOTTOM_RIGHT;
|
||||
quadTot=br;
|
||||
if (bl>=quadTot) {
|
||||
quad=BOTTOM_LEFT;
|
||||
quadTot=bl;
|
||||
}
|
||||
if (tl>=quadTot) {
|
||||
quad=TOP_LEFT;
|
||||
quadTot=tl;
|
||||
}
|
||||
if (tr>=quadTot) {
|
||||
quad=TOP_RIGHT;
|
||||
quadTot=tr;
|
||||
}
|
||||
|
||||
if (quadTot>c2*nSigma*rms) {
|
||||
// cout << "ph2 " << quadTot << " " << c2*nSigma*rms << endl;
|
||||
ee=PHOTON;
|
||||
}
|
||||
}
|
||||
good=1;
|
||||
if (eMin>0 && tot<eMin) good=0;
|
||||
if (eMax>0 && tot>eMax) good=0;
|
||||
if (good) {
|
||||
nph++;
|
||||
image[iy*nx+ix]++;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
eventMask[iy][ix]=PHOTON;
|
||||
}
|
||||
} else if (eventMask[iy][ix]==PEDESTAL) {
|
||||
addToPedestal(data,ix,iy,cm);
|
||||
#ifndef WRITE_QUAD
|
||||
}
|
||||
#endif
|
||||
if (ee==PHOTON && val[iy][ix]==max) {
|
||||
ee=PHOTON_MAX;
|
||||
// cout << "**" <<id<< " " << iframe << " " << nDark << " " << ix << " " << iy << " " << rms << " " << max << " " << quadTot << " " << tot << endl;
|
||||
(clusters+nph)->tot=tot;
|
||||
(clusters+nph)->x=ix;
|
||||
(clusters+nph)->y=iy;
|
||||
(clusters+nph)->quad=quad;
|
||||
(clusters+nph)->quadTot=quadTot;
|
||||
//(clusters+nph)->rms=rms;
|
||||
// (clusters+nph)->iframe=det->getFrameNumber(data);
|
||||
// cout << det->getFrameNumber(data) << " " << (clusters+nph)->iframe << endl;
|
||||
// (clusters+nph)->ped=getPedestal(ix,iy,0);
|
||||
for (ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
if ((iy+ir)>=iy && (iy+ir)<ny && (ix+ic)>=ix && (ix+ic)<nx)
|
||||
(clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir);
|
||||
}
|
||||
}
|
||||
}
|
||||
good=1;
|
||||
if (eMin>0 && tot<eMin) good=0;
|
||||
if (eMax>0 && tot>eMax) good=0;
|
||||
if (good) {
|
||||
nph++;
|
||||
image[iy*nx+ix]++;
|
||||
}
|
||||
|
||||
|
||||
} else if (ee==PEDESTAL) {
|
||||
addToPedestal(data,ix,iy,cm);
|
||||
} /*else {
|
||||
eventMask[iy][ix]=PHOTON;
|
||||
}*/
|
||||
//eventMask[iy][ix]=ee;
|
||||
}
|
||||
}
|
||||
|
||||
nphFrame=nph;
|
||||
nphTot+=nph;
|
||||
//cout << nphFrame << endl;
|
||||
// cout <<"**********************************"<< det->getFrameNumber(data) << " " << nphFrame << endl;
|
||||
//cout <<id << " **********************************"<< iframe << " " << det->getFrameNumber(data) << " " << nphFrame << endl;
|
||||
writeClusters(det->getFrameNumber(data));
|
||||
return image;
|
||||
|
||||
@ -561,13 +602,20 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
*/
|
||||
|
||||
static void writeClusters(FILE *f, single_photon_hit *cl, int nph, int fn=0){
|
||||
|
||||
/* #ifndef OLDFORMAT */
|
||||
/* if (fwrite((void*)&fn, 1, sizeof(int), f)) */
|
||||
/* if (fwrite((void*)&nph, 1, sizeof(int), f)) */
|
||||
/* #endif */
|
||||
for (int i=0; i<nph; i++) (cl+i)->write(f);
|
||||
};
|
||||
if (nph>0) {
|
||||
#ifndef OLDFORMAT
|
||||
if (fwrite((void*)&fn, 1, sizeof(int), f))
|
||||
if (fwrite((void*)&nph, 1, sizeof(int), f))
|
||||
#endif
|
||||
for (int i=0; i<nph; i++) (cl+i)->write(f);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void writeClusters(FILE *f, int fn=0){
|
||||
writeClusters(f,clusters,nphFrame, fn);
|
||||
//for (int i=0; i<nphFrame; i++)
|
||||
@ -623,6 +671,7 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
double eMin, eMax;
|
||||
int clusterSize; /**< cluster size in the x direction */
|
||||
int clusterSizeY; /**< cluster size in the y direction i.e. 1 for strips, clusterSize for pixels */
|
||||
double c2, c3;
|
||||
// single_photon_hit *cluster; /**< single photon hit data structure */
|
||||
single_photon_hit *clusters; /**< single photon hit data structure */
|
||||
quadrant quad; /**< quadrant where the photon is located */
|
||||
@ -631,6 +680,7 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
int nphTot;
|
||||
int nphFrame;
|
||||
|
||||
// double **val;
|
||||
pthread_mutex_t *fm;
|
||||
|
||||
};
|
||||
|
@ -39,13 +39,13 @@ class single_photon_hit {
|
||||
//fwrite((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile);
|
||||
|
||||
// if (fwrite((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile))
|
||||
//#ifdef OLDFORMAT
|
||||
#ifdef OLDFORMAT
|
||||
if (fwrite((void*)&iframe, 1, sizeof(int), myFile)) {};
|
||||
//#endif
|
||||
#endif
|
||||
#ifndef WRITE_QUAD
|
||||
//printf("no quad ");
|
||||
if (fwrite((void*)&x, 2, sizeof(int16_t), myFile))
|
||||
return fwrite((void*)data, 1, dx*dy*sizeof(int), myFile);
|
||||
//if (fwrite((void*)&x, 2, sizeof(int16_t), myFile))
|
||||
return fwrite((void*)&x, 1, dx*dy*sizeof(int)+2*sizeof(int16_t), myFile);
|
||||
#endif
|
||||
#ifdef WRITE_QUAD
|
||||
// printf("quad ");
|
||||
@ -91,7 +91,7 @@ class single_photon_hit {
|
||||
default:
|
||||
;
|
||||
}
|
||||
if (fwrite((void*)&x, 2, sizeof(int16_t), myFile))
|
||||
if (fwrite((void*)&x, 2, sizeof(int16_t), myFile))
|
||||
return fwrite((void*)qq, 1, 4*sizeof(int), myFile);
|
||||
#endif
|
||||
return 0;
|
||||
@ -104,9 +104,9 @@ class single_photon_hit {
|
||||
size_t read(FILE *myFile) {
|
||||
//fread((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile);
|
||||
|
||||
//#ifdef OLDFORMAT
|
||||
#ifdef OLDFORMAT
|
||||
if (fread((void*)&iframe, 1, sizeof(int), myFile)) {}
|
||||
//#endif
|
||||
#endif
|
||||
#ifndef WRITE_QUAD
|
||||
// printf( "no quad \n");
|
||||
if (fread((void*)&x, 2, sizeof(int16_t), myFile))
|
||||
@ -246,15 +246,15 @@ class single_photon_hit {
|
||||
int *get_cluster() {return data;};
|
||||
|
||||
int iframe; /**< frame number */
|
||||
int16_t x; /**< x-coordinate of the center of hit */
|
||||
int16_t y; /**< x-coordinate of the center of hit */
|
||||
double rms; /**< noise of central pixel l -- at some point it can be removed*/
|
||||
double ped; /**< pedestal of the central pixel -- at some point it can be removed*/
|
||||
double tot; /**< sum of the 3x3 cluster */
|
||||
quadrant quad; /**< quadrant where the photon is located */
|
||||
double quadTot; /**< sum of the maximum 2x2cluster */
|
||||
int dx; /**< size of data cluster in x */
|
||||
int dy; /**< size of data cluster in y */
|
||||
int dy; /**< size of data cluster in y */
|
||||
int16_t x; /**< x-coordinate of the center of hit */
|
||||
int16_t y; /**< x-coordinate of the center of hit */
|
||||
int *data; /**< pointer to data */
|
||||
};
|
||||
|
||||
|
@ -4,10 +4,10 @@ find_package(PNG REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
set(SOURCES
|
||||
slsDetectorPlotting/src/SlsQt1DPlot.cxx
|
||||
slsDetectorPlotting/src/SlsQt1DZoomer.cxx
|
||||
slsDetectorPlotting/src/SlsQt2DHist.cxx
|
||||
slsDetectorPlotting/src/SlsQt2DPlot.cxx
|
||||
slsDetectorPlotting/src/SlsQt1DPlot.cpp
|
||||
slsDetectorPlotting/src/SlsQt1DZoomer.cpp
|
||||
slsDetectorPlotting/src/SlsQt2DHist.cpp
|
||||
slsDetectorPlotting/src/SlsQt2DPlot.cpp
|
||||
src/qDetectorMain.cpp
|
||||
src/qDrawPlot.cpp
|
||||
src/qCloneWidget.cpp
|
||||
@ -103,10 +103,10 @@ set_target_properties(slsDetectorGui PROPERTIES
|
||||
)
|
||||
|
||||
install(TARGETS slsDetectorGui
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
# EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
# ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
# PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
|
||||
|
@ -55,6 +55,149 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<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>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lblInCompleteImage">
|
||||
<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>255</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>0</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>Missing Packets</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>117</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QWidget" name="widgetStatistics" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
@ -241,7 +384,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>376</width>
|
||||
<height>28</height>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuSave">
|
||||
|
@ -19,47 +19,8 @@
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="layout">
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<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>false</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="1" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="0" colspan="4">
|
||||
<widget class="QWidget" name="widgetStatistics" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
@ -86,73 +47,6 @@
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="6">
|
||||
<widget class="QLabel" name="lblSum">
|
||||
<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>40</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sum: </string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lblMinDisp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QLabel" name="lblMaxDisp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="lblMax">
|
||||
<property name="sizePolicy">
|
||||
@ -181,8 +75,8 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7">
|
||||
<widget class="QLabel" name="lblSumDisp">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lblMinDisp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@ -194,6 +88,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblMin">
|
||||
<property name="sizePolicy">
|
||||
@ -222,6 +129,32 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QLabel" name="lblMaxDisp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7">
|
||||
<widget class="QLabel" name="lblSumDisp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
@ -235,9 +168,213 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<widget class="QLabel" name="lblSum">
|
||||
<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>40</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sum: </string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>419</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="4">
|
||||
<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="1" column="2">
|
||||
<widget class="QLabel" name="lblInCompleteImage">
|
||||
<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>255</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>0</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>Missing Packets</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
19
slsDetectorGui/include/qCloneWidget.h
Executable file → Normal file
19
slsDetectorGui/include/qCloneWidget.h
Executable file → Normal file
@ -1,25 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui_form_cloneplot.h"
|
||||
#include <QMainWindow>
|
||||
#include <QString>
|
||||
|
||||
class SlsQtH1D;
|
||||
class SlsQt1DPlot;
|
||||
class SlsQt2DPlot;
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QString>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
class qCloneWidget : public QMainWindow, private Ui::ClonePlotObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2, SlsQt1DPlot *gp1, SlsQt2DPlot *gp,
|
||||
QString title, QString filePath, QString fileName,
|
||||
int64_t aIndex, bool displayStats, QString min, QString max,
|
||||
QString sum);
|
||||
qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2,
|
||||
SlsQt1DPlot *gp1, SlsQt2DPlot *gp, QString title,
|
||||
QString filePath, QString fileName, int64_t aIndex,
|
||||
bool displayStats, QString min, QString max, QString sum, bool completeImage);
|
||||
|
||||
~qCloneWidget();
|
||||
|
||||
@ -28,7 +23,7 @@ class qCloneWidget : public QMainWindow, private Ui::ClonePlotObject {
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
|
||||
private:
|
||||
void SetupWidgetWindow(QString title);
|
||||
void DisplayStats(bool enable, QString min, QString max, QString sum);
|
||||
|
41
slsDetectorGui/include/qDacWidget.h
Executable file → Normal file
41
slsDetectorGui/include/qDacWidget.h
Executable file → Normal file
@ -1,33 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui_form_dac.h"
|
||||
|
||||
#include "Detector.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class qDacWidget:public QWidget, private Ui::WidgetDacObject {
|
||||
Q_OBJECT
|
||||
class qDacWidget : public QWidget, private Ui::WidgetDacObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qDacWidget(QWidget *parent, sls::Detector* detector, bool d, std::string n, slsDetectorDefs::dacIndex i);
|
||||
~qDacWidget();
|
||||
void SetDetectorIndex(int id);
|
||||
public:
|
||||
qDacWidget(QWidget *parent, sls::Detector *detector, bool d, std::string n,
|
||||
slsDetectorDefs::dacIndex i);
|
||||
~qDacWidget();
|
||||
void SetDetectorIndex(int id);
|
||||
|
||||
private slots:
|
||||
void SetDac();
|
||||
private slots:
|
||||
void SetDac();
|
||||
|
||||
private:
|
||||
void SetupWidgetWindow(std::string name);
|
||||
void Initialization();
|
||||
void GetDac();
|
||||
void GetAdc();
|
||||
void Refresh();
|
||||
private:
|
||||
void SetupWidgetWindow(std::string name);
|
||||
void Initialization();
|
||||
void GetDac();
|
||||
void GetAdc();
|
||||
void Refresh();
|
||||
|
||||
sls::Detector *det;
|
||||
bool isDac{true};
|
||||
slsDetectorDefs::dacIndex index;
|
||||
int detectorIndex{-1};
|
||||
sls::Detector *det;
|
||||
bool isDac{true};
|
||||
slsDetectorDefs::dacIndex index;
|
||||
int detectorIndex{-1};
|
||||
};
|
||||
|
||||
|
86
slsDetectorGui/include/qDefs.h
Executable file → Normal file
86
slsDetectorGui/include/qDefs.h
Executable file → Normal file
@ -5,22 +5,29 @@
|
||||
#include <QAbstractButton>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
|
||||
using std::chrono::duration;
|
||||
using std::chrono::duration_cast;
|
||||
using std::chrono::nanoseconds;
|
||||
using std::chrono::hours;
|
||||
using std::chrono::microseconds;
|
||||
using std::chrono::milliseconds;
|
||||
using std::chrono::seconds;
|
||||
using std::chrono::minutes;
|
||||
using std::chrono::hours;
|
||||
using std::chrono::nanoseconds;
|
||||
using std::chrono::seconds;
|
||||
|
||||
#define CATCH_DISPLAY(m, s) catch(...) { qDefs::DisplayExceptions(m, s); }
|
||||
#define CATCH_HANDLE(...) catch(...) { qDefs::HandleExceptions(__VA_ARGS__); }
|
||||
#define CATCH_DISPLAY(m, s) \
|
||||
catch (...) { \
|
||||
qDefs::DisplayExceptions(m, s); \
|
||||
}
|
||||
#define CATCH_HANDLE(...) \
|
||||
catch (...) { \
|
||||
qDefs::HandleExceptions(__VA_ARGS__); \
|
||||
}
|
||||
|
||||
class qDefs : public QWidget {
|
||||
public:
|
||||
@ -29,9 +36,9 @@ class qDefs : public QWidget {
|
||||
*/
|
||||
qDefs(){};
|
||||
|
||||
static const int Q_FONT_SIZE=9;
|
||||
static const int DATA_GAIN_PLOT_RATIO=5;
|
||||
static const int MIN_HEIGHT_GAIN_PLOT_1D=75;
|
||||
static const int Q_FONT_SIZE = 9;
|
||||
static const int DATA_GAIN_PLOT_RATIO = 5;
|
||||
static const int MIN_HEIGHT_GAIN_PLOT_1D = 75;
|
||||
|
||||
static void DisplayExceptions(std::string emsg, std::string src) {
|
||||
try {
|
||||
@ -47,8 +54,8 @@ class qDefs : public QWidget {
|
||||
|
||||
template <class CT> struct NonDeduced { using type = CT; };
|
||||
template <class S, typename RT, typename... CT>
|
||||
static void HandleExceptions(const std::string emsg, const std::string src, S* s,
|
||||
RT (S::*somefunc)(CT...),
|
||||
static void HandleExceptions(const std::string emsg, const std::string src,
|
||||
S *s, RT (S::*somefunc)(CT...),
|
||||
typename NonDeduced<CT>::type... Args) {
|
||||
try {
|
||||
throw;
|
||||
@ -72,15 +79,22 @@ class qDefs : public QWidget {
|
||||
QF_NUM_FUNCTIONS
|
||||
};
|
||||
|
||||
static const char* getQFunctionNameFromEnum(enum qFuncNames func) {
|
||||
static const char *getQFunctionNameFromEnum(enum qFuncNames func) {
|
||||
switch (func) {
|
||||
case QF_GET_DETECTOR_STATUS: return "QF_GET_DETECTOR_STATUS";
|
||||
case QF_START_ACQUISITION: return "QF_START_ACQUISITION";
|
||||
case QF_STOP_ACQUISITION: return "QF_STOP_ACQUISITION";
|
||||
case QF_START_AND_READ_ALL: return "QF_START_AND_READ_ALL";
|
||||
case QF_EXIT_SERVER: return "QF_EXIT_SERVER";
|
||||
case QF_NUM_FUNCTIONS: return "QF_NUM_FUNCTIONS";
|
||||
default: return "Unknown Function";
|
||||
case QF_GET_DETECTOR_STATUS:
|
||||
return "QF_GET_DETECTOR_STATUS";
|
||||
case QF_START_ACQUISITION:
|
||||
return "QF_START_ACQUISITION";
|
||||
case QF_STOP_ACQUISITION:
|
||||
return "QF_STOP_ACQUISITION";
|
||||
case QF_START_AND_READ_ALL:
|
||||
return "QF_START_AND_READ_ALL";
|
||||
case QF_EXIT_SERVER:
|
||||
return "QF_EXIT_SERVER";
|
||||
case QF_NUM_FUNCTIONS:
|
||||
return "QF_NUM_FUNCTIONS";
|
||||
default:
|
||||
return "Unknown Function";
|
||||
}
|
||||
};
|
||||
|
||||
@ -111,11 +125,16 @@ class qDefs : public QWidget {
|
||||
|
||||
static std::string getRangeAsString(enum range r) {
|
||||
switch (r) {
|
||||
case XMIN: return "XMIN";
|
||||
case XMAX: return "XMAX";
|
||||
case YMIN: return "YMIN";
|
||||
case YMAX: return "YMAX";
|
||||
default: return "Unknown";
|
||||
case XMIN:
|
||||
return "XMIN";
|
||||
case XMAX:
|
||||
return "XMAX";
|
||||
case YMIN:
|
||||
return "YMIN";
|
||||
case YMAX:
|
||||
return "YMAX";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
};
|
||||
|
||||
@ -190,7 +209,8 @@ class qDefs : public QWidget {
|
||||
MINUTES);
|
||||
}
|
||||
return std::make_pair(
|
||||
duration_cast<duration<double, std::ratio<3600>>>(tns).count(), HOURS);
|
||||
duration_cast<duration<double, std::ratio<3600>>>(tns).count(),
|
||||
HOURS);
|
||||
}
|
||||
|
||||
/** returns the value in ns */
|
||||
@ -296,10 +316,12 @@ class qDefs : public QWidget {
|
||||
/**
|
||||
* Wrap exception message
|
||||
*/
|
||||
static int ExceptionMessage(std::string message,
|
||||
std::string exceptionMessage,
|
||||
std::string source) {
|
||||
return Message(qDefs::WARNING, message + std::string("\nCaught exception:\n") + exceptionMessage, source);
|
||||
}
|
||||
|
||||
static int ExceptionMessage(std::string message,
|
||||
std::string exceptionMessage,
|
||||
std::string source) {
|
||||
return Message(qDefs::WARNING,
|
||||
message + std::string("\nCaught exception:\n") +
|
||||
exceptionMessage,
|
||||
source);
|
||||
}
|
||||
};
|
||||
|
42
slsDetectorGui/include/qDetectorMain.h
Executable file → Normal file
42
slsDetectorGui/include/qDetectorMain.h
Executable file → Normal file
@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui_form_detectormain.h"
|
||||
|
||||
#include "qDefs.h"
|
||||
#include "Detector.h"
|
||||
#include <QTabWidget>
|
||||
|
||||
class qDrawPlot;
|
||||
class qTabMeasurement;
|
||||
class qTabDataOutput;
|
||||
@ -12,17 +13,15 @@ class qTabSettings;
|
||||
class qTabDebugging;
|
||||
class qTabDeveloper;
|
||||
class qTabMessages;
|
||||
|
||||
#include "Detector.h"
|
||||
|
||||
#include <QTabWidget>
|
||||
class QScrollArea;
|
||||
class QResizeEvent;
|
||||
|
||||
/** To Over-ride the QTabWidget class to get the tabBar */
|
||||
/** To Over-ride the QTabWidget class to get the tabBar protected
|
||||
* methodTabWidget */
|
||||
class MyTabWidget : public QTabWidget {
|
||||
public:
|
||||
MyTabWidget(QWidget *parent = 0) { setParent(parent); }
|
||||
/** Overridden method from QTabWidget */
|
||||
/** Overridden protected method from QTabWidget */
|
||||
QTabBar *tabBar() { return QTabWidget::tabBar(); }
|
||||
};
|
||||
|
||||
@ -30,7 +29,7 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qDetectorMain(int multiId, std::string fname, bool isDevel);
|
||||
qDetectorMain(int multiId, const std::string& fname, bool isDevel);
|
||||
~qDetectorMain();
|
||||
|
||||
private slots:
|
||||
@ -52,9 +51,9 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
|
||||
|
||||
private:
|
||||
void SetUpWidgetWindow();
|
||||
void SetUpDetector(const std::string fName, int multiID);
|
||||
void SetUpDetector(const std::string& config_file, int multiID);
|
||||
void Initialization();
|
||||
void LoadConfigFile(const std::string fName);
|
||||
void LoadConfigFile(const std::string& config_file);
|
||||
|
||||
/** enumeration of the tabs */
|
||||
enum {
|
||||
@ -70,16 +69,17 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
|
||||
};
|
||||
slsDetectorDefs::detectorType detType;
|
||||
std::unique_ptr<sls::Detector> det;
|
||||
std::unique_ptr<qDrawPlot> plot;
|
||||
std::unique_ptr<MyTabWidget> tabs;
|
||||
std::unique_ptr<qTabMeasurement> tabMeasurement;
|
||||
std::unique_ptr<qTabDataOutput> tabDataOutput;
|
||||
std::unique_ptr<qTabPlot> tabPlot;
|
||||
std::unique_ptr<qTabSettings> tabSettings;
|
||||
std::unique_ptr<qTabAdvanced> tabAdvanced;
|
||||
std::unique_ptr<qTabDebugging> tabDebugging;
|
||||
std::unique_ptr<qTabDeveloper> tabDeveloper;
|
||||
std::unique_ptr<qTabMessages> tabMessages;
|
||||
qDrawPlot *plot;
|
||||
MyTabWidget* tabs;
|
||||
std::unique_ptr<QScrollArea> scroll[NumberOfTabs];
|
||||
qTabMeasurement *tabMeasurement;
|
||||
qTabDataOutput *tabDataOutput;
|
||||
qTabPlot *tabPlot;
|
||||
qTabSettings *tabSettings;
|
||||
qTabAdvanced *tabAdvanced;
|
||||
qTabDebugging *tabDebugging;
|
||||
qTabDeveloper *tabDeveloper;
|
||||
qTabMessages *tabMessages;
|
||||
int isDeveloper;
|
||||
int heightPlotWindow;
|
||||
int heightCentralWidget;
|
||||
|
60
slsDetectorGui/include/qDrawPlot.h
Executable file → Normal file
60
slsDetectorGui/include/qDrawPlot.h
Executable file → Normal file
@ -1,25 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui_form_plot.h"
|
||||
|
||||
#include "qDefs.h"
|
||||
#include "Detector.h"
|
||||
#include <mutex>
|
||||
|
||||
class SlsQt1DPlot;
|
||||
class SlsQtH1D;
|
||||
class SlsQt2DPlot;
|
||||
class qCloneWidget;
|
||||
|
||||
class detectorData;
|
||||
#include "Detector.h"
|
||||
|
||||
class QResizeEvent;
|
||||
|
||||
#include <mutex>
|
||||
|
||||
class qDrawPlot : public QWidget, private Ui::PlotObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qDrawPlot(QWidget *parent, sls::Detector *detector);
|
||||
qDrawPlot(QWidget *parent, sls::Detector *detector);
|
||||
~qDrawPlot();
|
||||
bool GetIsRunning();
|
||||
void SetRunning(bool enable);
|
||||
@ -30,8 +26,8 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
|
||||
void SetXAxisTitle(QString title);
|
||||
void SetYAxisTitle(QString title);
|
||||
void SetZAxisTitle(QString title);
|
||||
void SetXYRangeChanged(bool disable, double* xy, bool* isXY);
|
||||
void SetZRange(double* z, bool* isZ);
|
||||
void SetXYRangeChanged(bool disable, double *xy, bool *isXY);
|
||||
void SetZRange(double *z, bool *isZ);
|
||||
double GetXMinimum();
|
||||
double GetXMaximum();
|
||||
double GetYMinimum();
|
||||
@ -56,7 +52,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
|
||||
void SetNumDiscardBits(int value);
|
||||
void EnableGainPlot(bool enable);
|
||||
void ClonePlot();
|
||||
void SavePlot();
|
||||
void SavePlot();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
@ -65,7 +61,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
|
||||
void SetSaveFileName(QString val);
|
||||
void AcquireThread();
|
||||
void UpdatePlot();
|
||||
|
||||
|
||||
signals:
|
||||
void StartAcquireSignal();
|
||||
void AcquireFinishedSignal();
|
||||
@ -75,51 +71,57 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
void Initialization();
|
||||
void SetupPlots();
|
||||
void SetupPlots();
|
||||
void GetStatistics(double &min, double &max, double &sum);
|
||||
void DetachHists();
|
||||
static void GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer);
|
||||
static void GetDataCallBack(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex, void *this_pointer);
|
||||
static void GetAcquisitionFinishedCallBack(double currentProgress,
|
||||
int detectorStatus,
|
||||
void *this_pointer);
|
||||
static void GetDataCallBack(detectorData *data, uint64_t frameIndex,
|
||||
uint32_t subFrameIndex, void *this_pointer);
|
||||
void AcquisitionFinished(double currentProgress, int detectorStatus);
|
||||
void GetData(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex);
|
||||
void toDoublePixelData(double *dest, char *source, int size, int databytes, int dr, double *gaindest = NULL);
|
||||
void Get1dData(double* rawData);
|
||||
void Get2dData(double* rawData);
|
||||
void GetData(detectorData *data, uint64_t frameIndex,
|
||||
uint32_t subFrameIndex);
|
||||
void toDoublePixelData(double *dest, char *source, int size, int databytes,
|
||||
int dr, double *gaindest = NULL);
|
||||
void Get1dData(double *rawData);
|
||||
void Get2dData(double *rawData);
|
||||
void Update1dPlot();
|
||||
void Update2dPlot();
|
||||
void Update1dXYRange();
|
||||
void Update2dXYRange();
|
||||
|
||||
static const int NUM_PEDESTAL_FRAMES = 20;
|
||||
|
||||
static const int NUM_PEDESTAL_FRAMES = 20;
|
||||
sls::Detector *det;
|
||||
slsDetectorDefs::detectorType detType;
|
||||
|
||||
SlsQt1DPlot *plot1d{nullptr};
|
||||
QVector<SlsQtH1D *> hists1d;
|
||||
QVector<SlsQtH1D *> hists1d;
|
||||
SlsQt1DPlot *gainplot1d{nullptr};
|
||||
SlsQtH1D * gainhist1d{nullptr};
|
||||
SlsQtH1D *gainhist1d{nullptr};
|
||||
SlsQt2DPlot *plot2d{nullptr};
|
||||
SlsQt2DPlot *gainplot2d{nullptr};
|
||||
|
||||
bool is1d{true};
|
||||
bool isRunning{false};
|
||||
|
||||
// titles
|
||||
|
||||
// titles
|
||||
QString plotTitlePrefix{""};
|
||||
QString xTitle1d{"Channel Number"};
|
||||
QString yTitle1d{"Counts"};
|
||||
QString xTitle2d{"Pixel"};
|
||||
QString xTitle2d{"Pixel"};
|
||||
QString yTitle2d{"Pixel"};
|
||||
QString zTitle2d{"Intensity"};
|
||||
QString plotTitle{""};
|
||||
QString indexTitle{""};
|
||||
bool completeImage{false};
|
||||
bool xyRangeChanged{false};
|
||||
double xyRange[4]{0, 0, 0, 0};
|
||||
bool isXYRange[4]{false, false, false, false};
|
||||
double zRange[2]{0, 1};
|
||||
bool isZRange[2]{false, false};
|
||||
|
||||
// data
|
||||
// data
|
||||
int nHists{1};
|
||||
double *datax1d{nullptr};
|
||||
std::vector<double *> datay1d;
|
||||
@ -127,9 +129,9 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
|
||||
double *data2d{nullptr};
|
||||
double *gainData{nullptr};
|
||||
|
||||
//options
|
||||
// options
|
||||
bool isPlot{true};
|
||||
bool isBinary{false};
|
||||
bool isBinary{false};
|
||||
int binaryFrom{0};
|
||||
int binaryTo{0};
|
||||
int persistency{0};
|
||||
|
110
slsDetectorGui/include/qTabAdvanced.h
Executable file → Normal file
110
slsDetectorGui/include/qTabAdvanced.h
Executable file → Normal file
@ -1,69 +1,65 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui_form_tab_advanced.h"
|
||||
#include "Detector.h"
|
||||
|
||||
class qDrawPlot;
|
||||
|
||||
#include "Detector.h"
|
||||
class qTabAdvanced : public QWidget, private Ui::TabAdvancedObject {
|
||||
Q_OBJECT
|
||||
|
||||
class qTabAdvanced:public QWidget, private Ui::TabAdvancedObject{
|
||||
Q_OBJECT
|
||||
public:
|
||||
qTabAdvanced(QWidget *parent, sls::Detector *detector, qDrawPlot *p);
|
||||
~qTabAdvanced();
|
||||
|
||||
public:
|
||||
qTabAdvanced(QWidget *parent, sls::Detector* detector, qDrawPlot* p);
|
||||
~qTabAdvanced();
|
||||
public slots:
|
||||
void Refresh();
|
||||
|
||||
public slots:
|
||||
void Refresh();
|
||||
private slots:
|
||||
void SetDetector();
|
||||
void SetControlPort(int port);
|
||||
void SetStopPort(int port);
|
||||
void SetDetectorUDPIP();
|
||||
void SetDetectorUDPMAC();
|
||||
void SetCltZMQPort(int port);
|
||||
void SetCltZMQIP();
|
||||
void SetRxrHostname();
|
||||
void SetRxrTCPPort(int port);
|
||||
void SetRxrUDPPort(int port);
|
||||
void SetRxrUDPIP();
|
||||
void SetRxrUDPMAC();
|
||||
void SetRxrZMQPort(int port);
|
||||
void SetRxrZMQIP();
|
||||
void GetROI();
|
||||
void ClearROI();
|
||||
void SetROI();
|
||||
void SetAllTrimbits();
|
||||
void SetNumStoragecells(int value);
|
||||
void SetSubExposureTime();
|
||||
void SetSubDeadTime();
|
||||
|
||||
private slots:
|
||||
void SetDetector();
|
||||
void SetControlPort(int port);
|
||||
void SetStopPort(int port);
|
||||
void SetDetectorUDPIP();
|
||||
void SetDetectorUDPMAC();
|
||||
void SetCltZMQPort(int port);
|
||||
void SetCltZMQIP();
|
||||
void SetRxrHostname();
|
||||
void SetRxrTCPPort(int port);
|
||||
void SetRxrUDPPort(int port);
|
||||
void SetRxrUDPIP();
|
||||
void SetRxrUDPMAC();
|
||||
void SetRxrZMQPort(int port);
|
||||
void SetRxrZMQIP();
|
||||
void GetROI();
|
||||
void ClearROI();
|
||||
void SetROI();
|
||||
void SetAllTrimbits();
|
||||
void SetNumStoragecells(int value);
|
||||
void SetSubExposureTime();
|
||||
void SetSubDeadTime();
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
void Initialization();
|
||||
void PopulateDetectors();
|
||||
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
void Initialization();
|
||||
void PopulateDetectors();
|
||||
void GetControlPort();
|
||||
void GetStopPort();
|
||||
void GetDetectorUDPIP();
|
||||
void GetDetectorUDPMAC();
|
||||
void GetCltZMQPort();
|
||||
void GetCltZMQIP();
|
||||
void GetRxrHostname();
|
||||
void GetRxrTCPPort();
|
||||
void GetRxrUDPPort();
|
||||
void GetRxrUDPIP();
|
||||
void GetRxrUDPMAC();
|
||||
void GetRxrZMQPort();
|
||||
void GetRxrZMQIP();
|
||||
void GetAllTrimbits();
|
||||
void GetNumStoragecells();
|
||||
void GetSubExposureTime();
|
||||
void GetSubDeadTime();
|
||||
|
||||
void GetControlPort();
|
||||
void GetStopPort();
|
||||
void GetDetectorUDPIP();
|
||||
void GetDetectorUDPMAC();
|
||||
void GetCltZMQPort();
|
||||
void GetCltZMQIP();
|
||||
void GetRxrHostname();
|
||||
void GetRxrTCPPort();
|
||||
void GetRxrUDPPort();
|
||||
void GetRxrUDPIP();
|
||||
void GetRxrUDPMAC();
|
||||
void GetRxrZMQPort();
|
||||
void GetRxrZMQIP();
|
||||
void GetAllTrimbits();
|
||||
void GetNumStoragecells();
|
||||
void GetSubExposureTime();
|
||||
void GetSubDeadTime();
|
||||
|
||||
sls::Detector *det;
|
||||
qDrawPlot *plot;
|
||||
sls::Detector *det;
|
||||
qDrawPlot *plot;
|
||||
};
|
||||
|
||||
|
||||
|
76
slsDetectorGui/include/qTabDataOutput.h
Executable file → Normal file
76
slsDetectorGui/include/qTabDataOutput.h
Executable file → Normal file
@ -1,50 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui_form_tab_dataoutput.h"
|
||||
|
||||
#include "Detector.h"
|
||||
|
||||
class qTabDataOutput:public QWidget, private Ui::TabDataOutputObject{
|
||||
Q_OBJECT
|
||||
class qTabDataOutput : public QWidget, private Ui::TabDataOutputObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qTabDataOutput(QWidget *parent, sls::Detector* detector);
|
||||
~qTabDataOutput();
|
||||
void Refresh();
|
||||
public:
|
||||
qTabDataOutput(QWidget *parent, sls::Detector *detector);
|
||||
~qTabDataOutput();
|
||||
void Refresh();
|
||||
|
||||
private slots:
|
||||
void GetOutputDir();
|
||||
void BrowseOutputDir();
|
||||
void SetOutputDir();
|
||||
void SetFileFormat(int format);
|
||||
void SetOverwriteEnable(bool enable);
|
||||
void SetTenGigaEnable(bool enable);
|
||||
void EnableRateCorrection();
|
||||
void SetRateCorrection();
|
||||
void SetSpeed(int speed);
|
||||
void SetFlags();
|
||||
private slots:
|
||||
void GetOutputDir();
|
||||
void BrowseOutputDir();
|
||||
void SetOutputDir();
|
||||
void SetFileFormat(int format);
|
||||
void SetOverwriteEnable(bool enable);
|
||||
void SetTenGigaEnable(bool enable);
|
||||
void EnableRateCorrection();
|
||||
void SetRateCorrection();
|
||||
void SetSpeed(int speed);
|
||||
void SetFlags();
|
||||
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
void Initialization();
|
||||
void PopulateDetectors();
|
||||
void EnableBrowse();
|
||||
void GetFileWrite();
|
||||
void GetFileName();
|
||||
void GetFileFormat();
|
||||
void GetFileOverwrite();
|
||||
void GetTenGigaEnable();
|
||||
void GetRateCorrection();
|
||||
void GetSpeed();
|
||||
void GetFlags();
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
void Initialization();
|
||||
void PopulateDetectors();
|
||||
void EnableBrowse();
|
||||
void GetFileWrite();
|
||||
void GetFileName();
|
||||
void GetFileFormat();
|
||||
void GetFileOverwrite();
|
||||
void GetTenGigaEnable();
|
||||
void GetRateCorrection();
|
||||
void GetSpeed();
|
||||
void GetFlags();
|
||||
|
||||
sls::Detector *det;
|
||||
// Button group for radiobuttons for rate
|
||||
QButtonGroup *btnGroupRate;
|
||||
// enum for the Eiger Parallel flag
|
||||
enum {
|
||||
PARALLEL,
|
||||
NONPARALLEL
|
||||
};
|
||||
sls::Detector *det;
|
||||
// Button group for radiobuttons for rate
|
||||
QButtonGroup *btnGroupRate;
|
||||
// enum for the Eiger Parallel flag
|
||||
enum { PARALLEL, NONPARALLEL };
|
||||
};
|
||||
|
||||
|
45
slsDetectorGui/include/qTabDebugging.h
Executable file → Normal file
45
slsDetectorGui/include/qTabDebugging.h
Executable file → Normal file
@ -1,36 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui_form_tab_debugging.h"
|
||||
|
||||
#include "Detector.h"
|
||||
|
||||
class QTreeWidget;
|
||||
class QTreeWidgetItem;
|
||||
|
||||
class qTabDebugging:public QWidget, private Ui::TabDebuggingObject{
|
||||
Q_OBJECT
|
||||
class qTabDebugging : public QWidget, private Ui::TabDebuggingObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qTabDebugging(QWidget *parent, sls::Detector* detector);
|
||||
~qTabDebugging();
|
||||
void Refresh();
|
||||
public:
|
||||
qTabDebugging(QWidget *parent, sls::Detector *detector);
|
||||
~qTabDebugging();
|
||||
void Refresh();
|
||||
|
||||
private slots:
|
||||
void GetDetectorStatus();
|
||||
void GetInfo();
|
||||
void SetParameters(QTreeWidgetItem *item);
|
||||
void TestDetector();
|
||||
private slots:
|
||||
void GetDetectorStatus();
|
||||
void GetInfo();
|
||||
void SetParameters(QTreeWidgetItem *item);
|
||||
void TestDetector();
|
||||
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
void Initialization();
|
||||
void PopulateDetectors();
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
void Initialization();
|
||||
void PopulateDetectors();
|
||||
|
||||
sls::Detector *det;
|
||||
/** Tree Widget displaying the detectors, modules */
|
||||
QTreeWidget *treeDet;
|
||||
QLabel *lblDetectorHostname;
|
||||
QLabel *lblDetectorFirmware;
|
||||
QLabel *lblDetectorSoftware;
|
||||
sls::Detector *det;
|
||||
/** Tree Widget displaying the detectors, modules */
|
||||
QTreeWidget *treeDet;
|
||||
QLabel *lblDetectorHostname;
|
||||
QLabel *lblDetectorFirmware;
|
||||
QLabel *lblDetectorSoftware;
|
||||
};
|
||||
|
||||
|
63
slsDetectorGui/include/qTabDeveloper.h
Executable file → Normal file
63
slsDetectorGui/include/qTabDeveloper.h
Executable file → Normal file
@ -1,49 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui_form_tab_developer.h"
|
||||
class qDacWidget;
|
||||
|
||||
#include "Detector.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class qTabDeveloper:public QWidget, private Ui::TabDeveloperObject {
|
||||
Q_OBJECT
|
||||
class qDacWidget;
|
||||
|
||||
public:
|
||||
qTabDeveloper(QWidget *parent, sls::Detector* detector);
|
||||
~qTabDeveloper();
|
||||
class qTabDeveloper : public QWidget, private Ui::TabDeveloperObject {
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void Refresh();
|
||||
public:
|
||||
qTabDeveloper(QWidget *parent, sls::Detector *detector);
|
||||
~qTabDeveloper();
|
||||
|
||||
private slots:
|
||||
void SetHighVoltage();
|
||||
public slots:
|
||||
void Refresh();
|
||||
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
void Initialization();
|
||||
void PopulateDetectors();
|
||||
void GetHighVoltage();
|
||||
slsDetectorDefs::dacIndex getSLSIndex(slsDetectorDefs::detectorType detType, int index);
|
||||
private slots:
|
||||
void SetHighVoltage();
|
||||
|
||||
sls::Detector *det;
|
||||
std::vector<qDacWidget*> dacWidgets;
|
||||
std::vector<qDacWidget*> adcWidgets;
|
||||
|
||||
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;
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
void Initialization();
|
||||
void PopulateDetectors();
|
||||
void GetHighVoltage();
|
||||
slsDetectorDefs::dacIndex getSLSIndex(slsDetectorDefs::detectorType detType,
|
||||
int index);
|
||||
|
||||
sls::Detector *det;
|
||||
std::vector<qDacWidget *> dacWidgets;
|
||||
std::vector<qDacWidget *> adcWidgets;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
158
slsDetectorGui/include/qTabMeasurement.h
Executable file → Normal file
158
slsDetectorGui/include/qTabMeasurement.h
Executable file → Normal file
@ -1,99 +1,91 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui_form_tab_measurement.h"
|
||||
|
||||
class qDrawPlot;
|
||||
|
||||
#include "Detector.h"
|
||||
|
||||
class qDrawPlot;
|
||||
class QStandardItemModel;
|
||||
|
||||
class qTabMeasurement:public QWidget, private Ui::TabMeasurementObject{
|
||||
Q_OBJECT
|
||||
class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qTabMeasurement(QWidget *parent, sls::Detector* detector, qDrawPlot* p);
|
||||
~qTabMeasurement();
|
||||
public:
|
||||
qTabMeasurement(QWidget *parent, sls::Detector *detector, qDrawPlot *p);
|
||||
~qTabMeasurement();
|
||||
|
||||
void Refresh();
|
||||
void Refresh();
|
||||
|
||||
public slots:
|
||||
void AcquireFinished();
|
||||
void AbortAcquire();
|
||||
public slots:
|
||||
void AcquireFinished();
|
||||
void AbortAcquire();
|
||||
|
||||
private slots:
|
||||
void SetTimingMode(int val);
|
||||
void SetNumMeasurements(int val);
|
||||
void SetNumFrames(int val);
|
||||
void SetNumTriggers(int val);
|
||||
void SetNumBursts(int val);
|
||||
void SetNumSamples(int val);
|
||||
void SetExposureTime();
|
||||
void SetAcquisitionPeriod();
|
||||
void SetDelay();
|
||||
void SetBurstPeriod();
|
||||
void SetFileWrite(bool val);
|
||||
void SetFileName();
|
||||
void SetRunIndex(int val);
|
||||
void SetStartingFrameNumber(int val);
|
||||
void UpdateProgress();
|
||||
void StartAcquisition();
|
||||
void StopAcquisition();
|
||||
private slots:
|
||||
void SetTimingMode(int val);
|
||||
void SetNumMeasurements(int val);
|
||||
void SetNumFrames(int val);
|
||||
void SetNumTriggers(int val);
|
||||
void SetNumBursts(int val);
|
||||
void SetNumSamples(int val);
|
||||
void SetExposureTime();
|
||||
void SetAcquisitionPeriod();
|
||||
void SetDelay();
|
||||
void SetBurstPeriod();
|
||||
void SetFileWrite(bool val);
|
||||
void SetFileName();
|
||||
void SetRunIndex(int val);
|
||||
void SetStartingFrameNumber(int val);
|
||||
void UpdateProgress();
|
||||
void StartAcquisition();
|
||||
void StopAcquisition();
|
||||
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
void Initialization();
|
||||
/** default, show trigger and delay,
|
||||
* otherwise for gotthard2 in auto timing mode and burst mode,
|
||||
* show bursts and burst period
|
||||
*/
|
||||
void ShowTriggerDelay();
|
||||
void SetupTimingMode();
|
||||
void EnableWidgetsforTimingMode();
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
void Initialization();
|
||||
/** default, show trigger and delay,
|
||||
* otherwise for gotthard2 in auto timing mode and burst mode,
|
||||
* show bursts and burst period
|
||||
*/
|
||||
void ShowTriggerDelay();
|
||||
void SetupTimingMode();
|
||||
void EnableWidgetsforTimingMode();
|
||||
|
||||
void GetTimingMode();
|
||||
void GetNumFrames();
|
||||
void GetNumTriggers();
|
||||
void GetNumBursts();
|
||||
void GetNumSamples();
|
||||
void GetExposureTime();
|
||||
void GetAcquisitionPeriod();
|
||||
void CheckAcqPeriodGreaterThanExp();
|
||||
void GetDelay();
|
||||
void GetBurstPeriod();
|
||||
void GetFileWrite();
|
||||
void GetFileName();
|
||||
void GetRunIndex();
|
||||
void GetStartingFrameNumber();
|
||||
void GetTimingMode();
|
||||
void GetNumFrames();
|
||||
void GetNumTriggers();
|
||||
void GetNumBursts();
|
||||
void GetNumSamples();
|
||||
void GetExposureTime();
|
||||
void GetAcquisitionPeriod();
|
||||
void CheckAcqPeriodGreaterThanExp();
|
||||
void GetDelay();
|
||||
void GetBurstPeriod();
|
||||
void GetFileWrite();
|
||||
void GetFileName();
|
||||
void GetRunIndex();
|
||||
void GetStartingFrameNumber();
|
||||
|
||||
void ResetProgress();
|
||||
void ResetProgress();
|
||||
|
||||
void Enable(bool enable);
|
||||
int VerifyOutputDirectoryError();
|
||||
void Enable(bool enable);
|
||||
int VerifyOutputDirectoryError();
|
||||
|
||||
signals:
|
||||
void EnableTabsSignal(bool);
|
||||
void FileNameChangedSignal(QString);
|
||||
private:
|
||||
sls::Detector *det;
|
||||
qDrawPlot *plot;
|
||||
// enum for the timing mode
|
||||
enum{
|
||||
AUTO,
|
||||
TRIGGER,
|
||||
GATED,
|
||||
BURST_TRIGGER,
|
||||
NUMTIMINGMODES
|
||||
};
|
||||
QTimer *progressTimer;
|
||||
//tool tip variables
|
||||
QString acqPeriodTip;
|
||||
QString errPeriodTip;
|
||||
QPalette red;
|
||||
bool delayImplemented;
|
||||
bool sampleImplemented;
|
||||
bool startingFnumImplemented;
|
||||
bool isAcquisitionStopped{false};
|
||||
int numMeasurements{1};
|
||||
int currentMeasurement{0};
|
||||
signals:
|
||||
void EnableTabsSignal(bool);
|
||||
void FileNameChangedSignal(QString);
|
||||
|
||||
private:
|
||||
sls::Detector *det;
|
||||
qDrawPlot *plot;
|
||||
// enum for the timing mode
|
||||
enum { AUTO, TRIGGER, GATED, BURST_TRIGGER, NUMTIMINGMODES };
|
||||
QTimer *progressTimer;
|
||||
// tool tip variables
|
||||
QString acqPeriodTip;
|
||||
QString errPeriodTip;
|
||||
QPalette red;
|
||||
bool delayImplemented;
|
||||
bool sampleImplemented;
|
||||
bool startingFnumImplemented;
|
||||
bool isAcquisitionStopped{false};
|
||||
int numMeasurements{1};
|
||||
int currentMeasurement{0};
|
||||
};
|
||||
|
46
slsDetectorGui/include/qTabMessages.h
Executable file → Normal file
46
slsDetectorGui/include/qTabMessages.h
Executable file → Normal file
@ -1,36 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui_form_tab_messages.h"
|
||||
|
||||
class QProcess;
|
||||
class QKeyEvent;
|
||||
|
||||
class qTabMessages:public QWidget, private Ui::TabMessagesObject {
|
||||
Q_OBJECT
|
||||
class qTabMessages : public QWidget, private Ui::TabMessagesObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qTabMessages(QWidget* parent);
|
||||
~qTabMessages();
|
||||
void Refresh();
|
||||
public:
|
||||
qTabMessages(QWidget *parent);
|
||||
~qTabMessages();
|
||||
void Refresh();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
|
||||
private slots:
|
||||
void ExecuteCommand();
|
||||
void SaveLog();
|
||||
void ClearLog();
|
||||
private slots:
|
||||
void ExecuteCommand();
|
||||
void SaveLog();
|
||||
void ClearLog();
|
||||
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
void Initialization();
|
||||
void PrintNextLine();
|
||||
void GetLastCommand();
|
||||
void ClearCommand();
|
||||
void AppendOutput();
|
||||
void AppendError();
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
void Initialization();
|
||||
void PrintNextLine();
|
||||
void GetLastCommand();
|
||||
void ClearCommand();
|
||||
void AppendOutput();
|
||||
void AppendError();
|
||||
|
||||
QProcess* process;
|
||||
QStringList lastCommand;
|
||||
QProcess *process;
|
||||
QStringList lastCommand;
|
||||
};
|
||||
|
||||
|
93
slsDetectorGui/include/qTabPlot.h
Executable file → Normal file
93
slsDetectorGui/include/qTabPlot.h
Executable file → Normal file
@ -1,63 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui_form_tab_plot.h"
|
||||
|
||||
class qDrawPlot;
|
||||
|
||||
#include "Detector.h"
|
||||
|
||||
class qDrawPlot;
|
||||
class QButtonGroup;
|
||||
|
||||
class qTabPlot:public QWidget, private Ui::TabPlotObject{
|
||||
Q_OBJECT
|
||||
class qTabPlot : public QWidget, private Ui::TabPlotObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qTabPlot(QWidget *parent, sls::Detector* detector, qDrawPlot* p);
|
||||
~qTabPlot();
|
||||
void SetScanArgument();
|
||||
void Refresh();
|
||||
public:
|
||||
qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p);
|
||||
~qTabPlot();
|
||||
void SetScanArgument();
|
||||
void Refresh();
|
||||
|
||||
private slots:
|
||||
void SetPlot();
|
||||
void Set1DPlotOptionsRight();
|
||||
void Set1DPlotOptionsLeft();
|
||||
void Set2DPlotOptionsRight();
|
||||
void Set2DPlotOptionsLeft();
|
||||
void EnablePersistency(bool enable);
|
||||
void SetBinary();
|
||||
void SetGapPixels(bool enable);
|
||||
void SetTitles();
|
||||
void SetXRange();
|
||||
void SetYRange();
|
||||
void CheckAspectRatio();
|
||||
void SetZRange();
|
||||
void SetStreamingFrequency();
|
||||
private slots:
|
||||
void SetPlot();
|
||||
void Set1DPlotOptionsRight();
|
||||
void Set1DPlotOptionsLeft();
|
||||
void Set2DPlotOptionsRight();
|
||||
void Set2DPlotOptionsLeft();
|
||||
void EnablePersistency(bool enable);
|
||||
void SetBinary();
|
||||
void SetGapPixels(bool enable);
|
||||
void SetTitles();
|
||||
void SetXRange();
|
||||
void SetYRange();
|
||||
void CheckAspectRatio();
|
||||
void SetZRange();
|
||||
void SetStreamingFrequency();
|
||||
|
||||
signals:
|
||||
void DisableZoomSignal(bool);
|
||||
signals:
|
||||
void DisableZoomSignal(bool);
|
||||
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
void Initialization();
|
||||
void Select1DPlot(bool enable);
|
||||
void GetGapPixels();
|
||||
void GetStreamingFrequency();
|
||||
void SetXYRange();
|
||||
void MaintainAspectRatio(int dimension);
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
void Initialization();
|
||||
void Select1DPlot(bool enable);
|
||||
void GetGapPixels();
|
||||
void GetStreamingFrequency();
|
||||
void SetXYRange();
|
||||
void MaintainAspectRatio(int dimension);
|
||||
|
||||
sls::Detector *det;
|
||||
qDrawPlot *plot;
|
||||
bool is1d;
|
||||
sls::Detector *det;
|
||||
qDrawPlot *plot;
|
||||
bool is1d;
|
||||
|
||||
QButtonGroup *btnGroupPlotType{nullptr};
|
||||
QButtonGroup *btnGroupPlotType{nullptr};
|
||||
|
||||
/** default plot and axis titles */
|
||||
static QString defaultPlotTitle;
|
||||
static QString defaultHistXAxisTitle;
|
||||
static QString defaultHistYAxisTitle;
|
||||
static QString defaultImageXAxisTitle;
|
||||
static QString defaultImageYAxisTitle;
|
||||
static QString defaultImageZAxisTitle;
|
||||
/** default plot and axis titles */
|
||||
static QString defaultPlotTitle;
|
||||
static QString defaultHistXAxisTitle;
|
||||
static QString defaultHistYAxisTitle;
|
||||
static QString defaultImageXAxisTitle;
|
||||
static QString defaultImageYAxisTitle;
|
||||
static QString defaultImageZAxisTitle;
|
||||
};
|
||||
|
||||
|
||||
|
83
slsDetectorGui/include/qTabSettings.h
Executable file → Normal file
83
slsDetectorGui/include/qTabSettings.h
Executable file → Normal file
@ -1,46 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui_form_tab_settings.h"
|
||||
|
||||
#include "Detector.h"
|
||||
|
||||
class qTabSettings: public QWidget, private Ui::TabSettingsObject{
|
||||
Q_OBJECT
|
||||
class qTabSettings : public QWidget, private Ui::TabSettingsObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qTabSettings(QWidget *parent, sls::Detector* detector);
|
||||
~qTabSettings();
|
||||
void Refresh();
|
||||
public:
|
||||
qTabSettings(QWidget *parent, sls::Detector *detector);
|
||||
~qTabSettings();
|
||||
void Refresh();
|
||||
|
||||
private slots:
|
||||
void SetSettings(int index);
|
||||
void SetDynamicRange(int index);
|
||||
void SetThresholdEnergy(int index);
|
||||
private slots:
|
||||
void SetSettings(int index);
|
||||
void SetDynamicRange(int index);
|
||||
void SetThresholdEnergy(int index);
|
||||
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
void SetupDetectorSettings();
|
||||
void Initialization();
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
void SetupDetectorSettings();
|
||||
void Initialization();
|
||||
|
||||
void GetSettings();
|
||||
void GetDynamicRange();
|
||||
void GetThresholdEnergy();
|
||||
void GetSettings();
|
||||
void GetDynamicRange();
|
||||
void GetThresholdEnergy();
|
||||
|
||||
sls::Detector *det;
|
||||
enum {
|
||||
STANDARD,
|
||||
FAST,
|
||||
HIGHGAIN,
|
||||
DYNAMICGAIN,
|
||||
LOWGAIN,
|
||||
MEDIUMGAIN,
|
||||
VERYHIGHGAIN,
|
||||
DYNAMICHG0,
|
||||
FIXGAIN1,
|
||||
FIXGAIN2,
|
||||
FORCESWITCHG1,
|
||||
FORCESWITCHG2,
|
||||
VERLOWGAIN,
|
||||
sls::Detector *det;
|
||||
enum {
|
||||
STANDARD,
|
||||
FAST,
|
||||
HIGHGAIN,
|
||||
DYNAMICGAIN,
|
||||
LOWGAIN,
|
||||
MEDIUMGAIN,
|
||||
VERYHIGHGAIN,
|
||||
DYNAMICHG0,
|
||||
FIXGAIN1,
|
||||
FIXGAIN2,
|
||||
FORCESWITCHG1,
|
||||
FORCESWITCHG2,
|
||||
VERLOWGAIN,
|
||||
G1_HIGHGAIN,
|
||||
G1_LOWGAIN,
|
||||
G2_HIGHCAP_HIGHGAIN,
|
||||
@ -48,15 +46,10 @@ private:
|
||||
G2_LOWCAP_HIGHGAIN,
|
||||
G2_LOWCAP_LOWGAIN,
|
||||
G4_HIGHGAIN,
|
||||
G4_LOWGAIN,
|
||||
UNDEFINED,
|
||||
UNINITIALIZED,
|
||||
NUMSETTINGS
|
||||
};
|
||||
enum {
|
||||
DYNAMICRANGE_32,
|
||||
DYNAMICRANGE_16,
|
||||
DYNAMICRANGE_8,
|
||||
DYNAMICRANGE_4
|
||||
};
|
||||
G4_LOWGAIN,
|
||||
UNDEFINED,
|
||||
UNINITIALIZED,
|
||||
NUMSETTINGS
|
||||
};
|
||||
enum { DYNAMICRANGE_32, DYNAMICRANGE_16, DYNAMICRANGE_8, DYNAMICRANGE_4 };
|
||||
};
|
||||
|
262
slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h
Executable file → Normal file
262
slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h
Executable file → Normal file
@ -1,183 +1,165 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
* Modifications:
|
||||
* 19.06.2012: {Some functions have been added by Dhanya to enable zooming in and out
|
||||
* without using mouse control:
|
||||
* DisableZoom,
|
||||
* SetXMinMax,SetYMinMax,
|
||||
* GetXMinimum,GetXMaximum,GetYMinimum,GetYMaximum}
|
||||
* */
|
||||
|
||||
#ifndef SLSQT1DPLOT_H
|
||||
#define SLSQT1DPLOT_H
|
||||
|
||||
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
typedef int int32_t;
|
||||
|
||||
#include "ansi.h"
|
||||
|
||||
|
||||
#include "SlsQt1DZoomer.h"
|
||||
#include <qwt_plot.h>
|
||||
#include <qwt_plot_curve.h>
|
||||
#include <qwt_plot_marker.h>
|
||||
#include <qwt_scale_div.h>
|
||||
#include "SlsQt1DZoomer.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
class QPen;
|
||||
class SlsQt1DPlot;
|
||||
class QwtSymbol;
|
||||
|
||||
class SlsQtH1D:public QwtPlotCurve{
|
||||
class SlsQtH1D : public QwtPlotCurve {
|
||||
|
||||
public:
|
||||
SlsQtH1D(QString title, int n, double xmin, double xmax, double* data=0);
|
||||
SlsQtH1D(QString title, int n, double* data_x, double* data_y);
|
||||
~SlsQtH1D();
|
||||
public:
|
||||
SlsQtH1D(QString title, int n, double xmin, double xmax, double *data = 0);
|
||||
SlsQtH1D(QString title, int n, double *data_x, double *data_y);
|
||||
~SlsQtH1D();
|
||||
|
||||
void Attach(SlsQt1DPlot* p);
|
||||
void Detach(SlsQt1DPlot* p);
|
||||
void Attach(SlsQt1DPlot *p);
|
||||
void Detach(SlsQt1DPlot *p);
|
||||
|
||||
int SetLineColor(int c=-1);
|
||||
int SetLineWidth(int w=1);
|
||||
void SetLineStyle(int s=0);
|
||||
void setStyleLinesorDots(bool isLines);
|
||||
void setSymbolMarkers(bool isMarker);
|
||||
int SetLineColor(int c = -1);
|
||||
int SetLineWidth(int w = 1);
|
||||
void SetLineStyle(int s = 0);
|
||||
void setStyleLinesorDots(bool isLines);
|
||||
void setSymbolMarkers(bool isMarker);
|
||||
|
||||
void SetData(int n, double xmin, double xmax, double* d=0);
|
||||
void SetData(int n, double* dx, double* dy);
|
||||
void SetData(int n, double xmin, double xmax, double *d = 0);
|
||||
void SetData(int n, double *dx, double *dy);
|
||||
|
||||
double* GetX() {return x;}
|
||||
double* GetY() {return y;}
|
||||
int GetNBinsX() {return ndata;}
|
||||
double *GetX() { return x; }
|
||||
double *GetY() { return y; }
|
||||
int GetNBinsX() { return ndata; }
|
||||
|
||||
double FillBin(int bx, double v=1);
|
||||
double Fill(double x, double v=1);
|
||||
double SetBinContent(int bx,double v);
|
||||
double SetContent(double x,double v);
|
||||
int FindBinIndex(double px);
|
||||
double FillBin(int bx, double v = 1);
|
||||
double Fill(double x, double v = 1);
|
||||
double SetBinContent(int bx, double v);
|
||||
double SetContent(double x, double v);
|
||||
int FindBinIndex(double px);
|
||||
|
||||
double GetXMin() {return x[0];}
|
||||
double GetFirstXgtZero() {return firstXgt0;}
|
||||
double GetXMax() {return x[ndata-1];}
|
||||
double GetYMin() {return ymin;}
|
||||
double GetFirstYgtZero() {return firstYgt0;}
|
||||
double GetYMax() {return ymax;}
|
||||
double GetXMin() { return x[0]; }
|
||||
double GetFirstXgtZero() { return firstXgt0; }
|
||||
double GetXMax() { return x[ndata - 1]; }
|
||||
double GetYMin() { return ymin; }
|
||||
double GetFirstYgtZero() { return firstYgt0; }
|
||||
double GetYMax() { return ymax; }
|
||||
|
||||
SlsQtH1D* Add(double v);
|
||||
SlsQtH1D *Add(double v);
|
||||
|
||||
private:
|
||||
int ndata;
|
||||
int n_array;
|
||||
double dx;
|
||||
double *x{nullptr}, *y{nullptr};
|
||||
double ymin, ymax;
|
||||
double firstXgt0, firstYgt0;
|
||||
void Initailize();
|
||||
int SetUpArrays(int n);
|
||||
int CheckIndex(int bx);
|
||||
|
||||
|
||||
private:
|
||||
int ndata;
|
||||
int n_array;
|
||||
double dx;
|
||||
double *x{nullptr},*y{nullptr};
|
||||
double ymin,ymax;
|
||||
double firstXgt0,firstYgt0;
|
||||
void Initailize();
|
||||
int SetUpArrays(int n);
|
||||
int CheckIndex(int bx);
|
||||
|
||||
QPen* pen_ptr{nullptr};
|
||||
QPen *pen_ptr{nullptr};
|
||||
};
|
||||
|
||||
class SlsQtH1DList {
|
||||
public:
|
||||
SlsQtH1DList(SlsQtH1D *hist = 0);
|
||||
~SlsQtH1DList();
|
||||
|
||||
class SlsQtH1DList{
|
||||
public:
|
||||
SlsQtH1DList(SlsQtH1D* hist=0);
|
||||
~SlsQtH1DList();
|
||||
SlsQtH1D *Add(SlsQtH1D *h);
|
||||
void Remove(SlsQtH1D *h);
|
||||
void Print();
|
||||
|
||||
SlsQtH1D* Add(SlsQtH1D* h);
|
||||
void Remove(SlsQtH1D* h);
|
||||
void Print();
|
||||
SlsQtH1D *Hist() { return the_hist; } // if no hist returns 0
|
||||
SlsQtH1DList *Next() { return the_next; }
|
||||
|
||||
SlsQtH1D* Hist() {return the_hist;} //if no hist returns 0
|
||||
SlsQtH1DList* Next() {return the_next;}
|
||||
|
||||
|
||||
private:
|
||||
SlsQtH1DList* the_next;
|
||||
SlsQtH1D* the_hist;
|
||||
private:
|
||||
SlsQtH1DList *the_next;
|
||||
SlsQtH1D *the_hist;
|
||||
};
|
||||
|
||||
|
||||
class SlsQt1DPlot:public QwtPlot{
|
||||
Q_OBJECT
|
||||
class SlsQt1DPlot : public QwtPlot {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SlsQt1DPlot(QWidget* = NULL);
|
||||
~SlsQt1DPlot();
|
||||
|
||||
void SetTitle(QString title);
|
||||
void SetXTitle(QString title);
|
||||
void SetYTitle(QString title);
|
||||
void SetTitleFont(const QFont& f);
|
||||
void SetXFont(const QFont& f);
|
||||
void SetYFont(const QFont& f);
|
||||
|
||||
void InsertHLine(double y);
|
||||
void RemoveHLine();
|
||||
void InsertVLine(double v);
|
||||
void RemoveVLine();
|
||||
public:
|
||||
SlsQt1DPlot(QWidget * = NULL);
|
||||
~SlsQt1DPlot();
|
||||
|
||||
void SetTitle(QString title);
|
||||
void SetXTitle(QString title);
|
||||
void SetYTitle(QString title);
|
||||
void SetTitleFont(const QFont &f);
|
||||
void SetXFont(const QFont &f);
|
||||
void SetYFont(const QFont &f);
|
||||
|
||||
/** This group of functions have been added by Dhanya on 19.06.2012 to be able to
|
||||
use zooming functionality without mouse control*/
|
||||
void DisableZoom(bool disable);
|
||||
void EnableXAutoScaling() {setAxisAutoScale(QwtPlot::xBottom, true);Update();};
|
||||
void EnableYAutoScaling() {setAxisAutoScale(QwtPlot::yLeft, true);Update();};
|
||||
void SetYStep (int step) {ystep = step;};
|
||||
void SetXMinMax(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);};
|
||||
void SetYMinMax(double min,double max){setAxisScale(QwtPlot::yLeft,min,max);};
|
||||
double GetXMinimum(){return hist_list->Hist()->GetXMin();};
|
||||
double GetXMaximum(){return hist_list->Hist()->GetXMax();};
|
||||
double GetYMinimum(){return hist_list->Hist()->GetYMin();};
|
||||
double GetYMaximum(){return hist_list->Hist()->GetYMax();};
|
||||
/**---*/
|
||||
void InsertHLine(double y);
|
||||
void RemoveHLine();
|
||||
void InsertVLine(double v);
|
||||
void RemoveVLine();
|
||||
|
||||
/** This group of functions have been added by Dhanya on 19.06.2012 to be
|
||||
able to use zooming functionality without mouse control*/
|
||||
void DisableZoom(bool disable);
|
||||
void EnableXAutoScaling() {
|
||||
setAxisAutoScale(QwtPlot::xBottom, true);
|
||||
Update();
|
||||
};
|
||||
void EnableYAutoScaling() {
|
||||
setAxisAutoScale(QwtPlot::yLeft, true);
|
||||
Update();
|
||||
};
|
||||
void SetYStep(int step) { ystep = step; };
|
||||
void SetXMinMax(double min, double max) {
|
||||
setAxisScale(QwtPlot::xBottom, min, max);
|
||||
};
|
||||
void SetYMinMax(double min, double max) {
|
||||
setAxisScale(QwtPlot::yLeft, min, max);
|
||||
};
|
||||
double GetXMinimum() { return hist_list->Hist()->GetXMin(); };
|
||||
double GetXMaximum() { return hist_list->Hist()->GetXMax(); };
|
||||
double GetYMinimum() { return hist_list->Hist()->GetYMin(); };
|
||||
double GetYMaximum() { return hist_list->Hist()->GetYMax(); };
|
||||
/**---*/
|
||||
|
||||
void SetZoom(double xmin,double ymin,double x_width,double y_width);
|
||||
void SetZoomBase(double xmin,double ymin,double x_width, double y_width){ zoomer->SetZoomBase(xmin,ymin,x_width,y_width);}
|
||||
void SetZoom(double xmin, double ymin, double x_width, double y_width);
|
||||
void SetZoomBase(double xmin, double ymin, double x_width, double y_width) {
|
||||
zoomer->SetZoomBase(xmin, ymin, x_width, y_width);
|
||||
}
|
||||
|
||||
void alignScales();
|
||||
void alignScales();
|
||||
|
||||
void SetLogX(bool yes=1);
|
||||
void SetLogY(bool yes=1);
|
||||
private:
|
||||
|
||||
SlsQtH1DList* hist_list{nullptr};
|
||||
SlsQt1DZoomer* zoomer{nullptr};
|
||||
QwtPlotPanner* panner{nullptr};
|
||||
void SetLogX(bool yes = 1);
|
||||
void SetLogY(bool yes = 1);
|
||||
|
||||
QwtPlotMarker *hline{nullptr};
|
||||
QwtPlotMarker *vline{nullptr};
|
||||
bool disableZoom{false};
|
||||
int ystep{0};
|
||||
|
||||
void SetupZoom();
|
||||
void UnknownStuff();
|
||||
//void alignScales();
|
||||
|
||||
void CalculateNResetZoomBase();
|
||||
void NewHistogramAttached(SlsQtH1D* h);
|
||||
void HistogramDetached(SlsQtH1D* h);
|
||||
private:
|
||||
SlsQtH1DList *hist_list{nullptr};
|
||||
SlsQt1DZoomer *zoomer{nullptr};
|
||||
QwtPlotPanner *panner{nullptr};
|
||||
|
||||
void SetLog(int axisId, bool yes);
|
||||
|
||||
friend void SlsQtH1D::Attach(SlsQt1DPlot* p);
|
||||
friend void SlsQtH1D::Detach(SlsQt1DPlot* p);
|
||||
|
||||
|
||||
public slots:
|
||||
void UnZoom();
|
||||
void Update();
|
||||
QwtPlotMarker *hline{nullptr};
|
||||
QwtPlotMarker *vline{nullptr};
|
||||
bool disableZoom{false};
|
||||
int ystep{0};
|
||||
|
||||
void SetupZoom();
|
||||
void UnknownStuff();
|
||||
// void alignScales();
|
||||
|
||||
void CalculateNResetZoomBase();
|
||||
void NewHistogramAttached(SlsQtH1D *h);
|
||||
void HistogramDetached(SlsQtH1D *h);
|
||||
|
||||
void SetLog(int axisId, bool yes);
|
||||
|
||||
friend void SlsQtH1D::Attach(SlsQt1DPlot *p);
|
||||
friend void SlsQtH1D::Detach(SlsQt1DPlot *p);
|
||||
|
||||
public slots:
|
||||
void UnZoom();
|
||||
void Update();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
90
slsDetectorGui/slsDetectorPlotting/include/SlsQt1DZoomer.h
Executable file → Normal file
90
slsDetectorGui/slsDetectorPlotting/include/SlsQt1DZoomer.h
Executable file → Normal file
@ -1,74 +1,52 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
#ifndef SLSQT1DZOOMER_H
|
||||
#define SLSQT1DZOOMER_H
|
||||
|
||||
#include <qwt_plot_zoomer.h>
|
||||
#include <qwt_plot_panner.h>
|
||||
#include <qwt_global.h>
|
||||
#include <qwt_plot_panner.h>
|
||||
#include <qwt_plot_zoomer.h>
|
||||
|
||||
class SlsQtH1D;
|
||||
|
||||
class SlsQt1DZoomer:public QwtPlotZoomer{
|
||||
private:
|
||||
double x0,x1,y0,y1;
|
||||
double firstXgt0,firstYgt0;
|
||||
bool xIsLog,yIsLog;
|
||||
class SlsQt1DZoomer : public QwtPlotZoomer {
|
||||
private:
|
||||
double x0, x1, y0, y1;
|
||||
double firstXgt0, firstYgt0;
|
||||
bool xIsLog, yIsLog;
|
||||
|
||||
public:
|
||||
#if QWT_VERSION < 0x060100
|
||||
SlsQt1DZoomer(QwtPlotCanvas *canvas):QwtPlotZoomer(canvas){
|
||||
#else
|
||||
SlsQt1DZoomer(QWidget *canvas):QwtPlotZoomer(canvas){
|
||||
#endif
|
||||
setTrackerMode(AlwaysOn);
|
||||
xIsLog=yIsLog=0;
|
||||
}
|
||||
public:
|
||||
SlsQt1DZoomer(QWidget *canvas) : QwtPlotZoomer(canvas) {
|
||||
setTrackerMode(AlwaysOn);
|
||||
xIsLog = yIsLog = 0;
|
||||
}
|
||||
|
||||
double x() {return x0;}
|
||||
double x_firstGreaterThan0() {return firstXgt0;}
|
||||
double w() {return x1-x0;}
|
||||
double x() { return x0; }
|
||||
double x_firstGreaterThan0() { return firstXgt0; }
|
||||
double w() { return x1 - x0; }
|
||||
|
||||
double y() {return y0;}
|
||||
double y_firstGreaterThan0() {return firstYgt0;}
|
||||
double h() {return y1-y0;}
|
||||
double y() { return y0; }
|
||||
double y_firstGreaterThan0() { return firstYgt0; }
|
||||
double h() { return y1 - y0; }
|
||||
|
||||
void SetZoomBase(double xmin,double ymin,double x_width, double y_width);
|
||||
void SetZoomBase(SlsQtH1D* h);
|
||||
void ExtendZoomBase(SlsQtH1D* h);
|
||||
void ResetZoomBase();
|
||||
void SetZoomBase(double xmin, double ymin, double x_width, double y_width);
|
||||
void SetZoomBase(SlsQtH1D *h);
|
||||
void ExtendZoomBase(SlsQtH1D *h);
|
||||
void ResetZoomBase();
|
||||
|
||||
bool IsLogX(){ return xIsLog;}
|
||||
bool IsLogY(){ return yIsLog;}
|
||||
bool SetLogX(bool yes) { return xIsLog=yes;}
|
||||
bool SetLogY(bool yes) { return yIsLog=yes;}
|
||||
bool IsLogX() { return xIsLog; }
|
||||
bool IsLogY() { return yIsLog; }
|
||||
bool SetLogX(bool yes) { return xIsLog = yes; }
|
||||
bool SetLogY(bool yes) { return yIsLog = yes; }
|
||||
|
||||
|
||||
#if QWT_VERSION<0x060000
|
||||
virtual QwtText trackerText(const QwtDoublePoint &pos) const{
|
||||
#else
|
||||
using QwtPlotPicker::trackerText;
|
||||
virtual QwtText trackerText(const QPoint &pos) const{
|
||||
#endif
|
||||
QColor bg(Qt::white);
|
||||
|
||||
#if QT_VERSION >= 0x040300
|
||||
bg.setAlpha(200);
|
||||
#endif
|
||||
|
||||
#if QWT_VERSION<0x060000
|
||||
QwtText text = QwtPlotZoomer::trackerText(pos);
|
||||
#else
|
||||
QwtText text = QwtPlotPicker::trackerText(pos);
|
||||
#endif
|
||||
text.setBackgroundBrush( QBrush( bg ));
|
||||
return text;
|
||||
}
|
||||
using QwtPlotPicker::trackerText;
|
||||
virtual QwtText trackerText(const QPoint &pos) const {
|
||||
|
||||
QColor bg(Qt::white);
|
||||
bg.setAlpha(200);
|
||||
QwtText text = QwtPlotPicker::trackerText(pos);
|
||||
text.setBackgroundBrush(QBrush(bg));
|
||||
return text;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
201
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DHist.h
Executable file → Normal file
201
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DHist.h
Executable file → Normal file
@ -1,137 +1,126 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SLSQT2DHIST_H
|
||||
#define SLSQT2DHIST_H
|
||||
|
||||
|
||||
#if QT_VERSION >= 0x040000
|
||||
#include <qprintdialog.h>
|
||||
#endif
|
||||
#include <qwt_color_map.h>
|
||||
#include <qwt_plot_spectrogram.h>
|
||||
#include <qwt_scale_widget.h>
|
||||
#include <qwt_scale_draw.h>
|
||||
#include <qwt_scale_widget.h>
|
||||
|
||||
class SlsQt2DHist : public QwtRasterData {
|
||||
|
||||
class SlsQt2DHist: public QwtRasterData{
|
||||
|
||||
private:
|
||||
private:
|
||||
double x_min, x_max, y_min, y_max;
|
||||
double x_width, y_width;
|
||||
|
||||
double x_min,x_max,y_min,y_max;
|
||||
double x_width,y_width;
|
||||
int nx, ny, nb;
|
||||
double *data{nullptr};
|
||||
double z_min, z_mean, z_max;
|
||||
bool z_mean_has_been_calculated;
|
||||
|
||||
int nx,ny,nb;
|
||||
double *data{nullptr};
|
||||
double z_min,z_mean,z_max;
|
||||
bool z_mean_has_been_calculated;
|
||||
|
||||
int nx_array,ny_array;
|
||||
int nx_array, ny_array;
|
||||
|
||||
bool interp;
|
||||
bool interp;
|
||||
|
||||
static double value_between_points(double p1,double v1,double p2,double v2,double p){ //linear extrap
|
||||
return (v2-v1)/(p2-p1)*(p-p1)+v1;
|
||||
}
|
||||
|
||||
public:
|
||||
SlsQt2DHist(int nbinsx=10, double xmin=0, double xmax=10, int nbinsy=10, double ymin=0, double ymax=10, double* d=0,double zmin=0,double zmax=-1);
|
||||
virtual ~SlsQt2DHist();
|
||||
static double value_between_points(double p1, double v1, double p2,
|
||||
double v2, double p) { // linear extrap
|
||||
return (v2 - v1) / (p2 - p1) * (p - p1) + v1;
|
||||
}
|
||||
|
||||
double GetXMin() {return x_min;}
|
||||
double GetXMax() {return x_max;}
|
||||
double GetXBinWidth() {return x_width;}
|
||||
double GetYMin() {return y_min;}
|
||||
double GetYMax() {return y_max;}
|
||||
double GetYBinWidth() {return y_width;}
|
||||
double GetMinimum() {return z_min;}
|
||||
double GetMaximum() {return z_max;}
|
||||
double GetMean();
|
||||
public:
|
||||
SlsQt2DHist(int nbinsx = 10, double xmin = 0, double xmax = 10,
|
||||
int nbinsy = 10, double ymin = 0, double ymax = 10,
|
||||
double *d = 0, double zmin = 0, double zmax = -1);
|
||||
virtual ~SlsQt2DHist();
|
||||
|
||||
int GetNBinsX(){return nx;}
|
||||
int GetNBinsY(){return ny;}
|
||||
double GetBinValue(int bx,int by);
|
||||
int GetBinIndex(int bx,int by);
|
||||
double* GetDataPtr(){return data;}
|
||||
double GetXMin() { return x_min; }
|
||||
double GetXMax() { return x_max; }
|
||||
double GetXBinWidth() { return x_width; }
|
||||
double GetYMin() { return y_min; }
|
||||
double GetYMax() { return y_max; }
|
||||
double GetYBinWidth() { return y_width; }
|
||||
double GetMinimum() { return z_min; }
|
||||
double GetMaximum() { return z_max; }
|
||||
double GetMean();
|
||||
|
||||
void Interpolate(bool on=1) {interp=on;}
|
||||
void SetBinValue(int bx,int by,double v);
|
||||
void SetData(int nbinsx, double xmin, double xmax, int nbinsy,double ymin, double ymax,double *d,double zmin=0, double zmax=-1);
|
||||
|
||||
double SetMinimumToFirstGreaterThanZero();
|
||||
void SetMinimum(double zmin) {z_min=zmin;}
|
||||
void SetMaximum(double zmax) {z_max=zmax;}
|
||||
void SetMinMax(double zmin=0,double zmax=-1);
|
||||
int GetNBinsX() { return nx; }
|
||||
int GetNBinsY() { return ny; }
|
||||
double GetBinValue(int bx, int by);
|
||||
int GetBinIndex(int bx, int by);
|
||||
double *GetDataPtr() { return data; }
|
||||
|
||||
int FindBinIndex(double x, double y);
|
||||
void Interpolate(bool on = 1) { interp = on; }
|
||||
void SetBinValue(int bx, int by, double v);
|
||||
void SetData(int nbinsx, double xmin, double xmax, int nbinsy, double ymin,
|
||||
double ymax, double *d, double zmin = 0, double zmax = -1);
|
||||
|
||||
double SetMinimumToFirstGreaterThanZero();
|
||||
void SetMinimum(double zmin) { z_min = zmin; }
|
||||
void SetMaximum(double zmax) { z_max = zmax; }
|
||||
void SetMinMax(double zmin = 0, double zmax = -1);
|
||||
|
||||
int FindBinIndex(double x, double y);
|
||||
|
||||
virtual QwtRasterData *copy() const{
|
||||
//this function does not create a new SlsQt2DHistData instance,
|
||||
//just passes a pointer so that data is common to both the copy and the original instance
|
||||
return (QwtRasterData*) this;
|
||||
}
|
||||
virtual QwtRasterData *copy() const {
|
||||
// this function does not create a new SlsQt2DHistData instance,
|
||||
// just passes a pointer so that data is common to both the copy and the
|
||||
// original instance
|
||||
return (QwtRasterData *)this;
|
||||
}
|
||||
|
||||
#if QWT_VERSION<0x060000
|
||||
virtual QwtDoubleInterval range() const{ return QwtDoubleInterval(z_min,z_max);}
|
||||
#else
|
||||
virtual QwtInterval range() const{ return QwtInterval(z_min,z_max);}
|
||||
virtual QwtInterval interval(Qt::Axis axis) const {
|
||||
switch (axis){
|
||||
case Qt::ZAxis:
|
||||
return QwtInterval(z_min,z_max);
|
||||
case Qt::XAxis:
|
||||
return QwtInterval(x_min,x_max);
|
||||
case Qt::YAxis:
|
||||
return QwtInterval(y_min,y_max);
|
||||
default:
|
||||
return QwtInterval(z_min,z_max);
|
||||
virtual QwtInterval range() const { return QwtInterval(z_min, z_max); }
|
||||
virtual QwtInterval interval(Qt::Axis axis) const {
|
||||
switch (axis) {
|
||||
case Qt::ZAxis:
|
||||
return QwtInterval(z_min, z_max);
|
||||
case Qt::XAxis:
|
||||
return QwtInterval(x_min, x_max);
|
||||
case Qt::YAxis:
|
||||
return QwtInterval(y_min, y_max);
|
||||
default:
|
||||
return QwtInterval(z_min, z_max);
|
||||
};
|
||||
};
|
||||
};
|
||||
#endif
|
||||
|
||||
virtual double value(double x, double y) const {
|
||||
// if(!interp){ //default is box like plot
|
||||
int index =
|
||||
int((x - x_min) / x_width) + int((y - y_min) / y_width) * nx;
|
||||
if (index < 0 || index > nb)
|
||||
index = nb;
|
||||
if (!interp)
|
||||
return data[index];
|
||||
//}
|
||||
|
||||
int x_int = int((x - x_min) / x_width - 0.5);
|
||||
if (x_int < 0)
|
||||
x_int = 0;
|
||||
else if (x_int > nx - 2)
|
||||
x_int = nx - 2;
|
||||
int y_int = int((y - y_min) / y_width - 0.5);
|
||||
if (y_int < 0)
|
||||
y_int = 0;
|
||||
else if (y_int > ny - 2)
|
||||
y_int = ny - 2;
|
||||
|
||||
virtual double value(double x, double y) const{
|
||||
//if(!interp){ //default is box like plot
|
||||
int index = int((x-x_min)/x_width) + int((y-y_min)/y_width)*nx;
|
||||
if(index<0||index>nb) index = nb;
|
||||
if(!interp) return data[index];
|
||||
//}
|
||||
int b00 = x_int * ny + y_int;
|
||||
int b01 = x_int * ny + y_int + 1;
|
||||
int b10 = (x_int + 1) * ny + y_int;
|
||||
int b11 = (x_int + 1) * ny + y_int + 1;
|
||||
|
||||
|
||||
int x_int = int((x-x_min)/x_width-0.5);
|
||||
if(x_int<0) x_int = 0; else if(x_int>nx-2) x_int = nx-2;
|
||||
int y_int = int((y-y_min)/y_width-0.5);
|
||||
if(y_int<0) y_int = 0; else if(y_int>ny-2) y_int = ny-2;
|
||||
// vertical extrap
|
||||
double y0 = y_min + (y_int + 0.5) * y_width;
|
||||
double y1 = y_min + (y_int + 1.5) * y_width;
|
||||
double left_v = value_between_points(y0, data[b00], y1, data[b01], y);
|
||||
double right_v = value_between_points(y0, data[b10], y1, data[b11], y);
|
||||
// horazontal extrap
|
||||
|
||||
int b00 = x_int*ny + y_int;
|
||||
int b01 = x_int*ny + y_int+1;
|
||||
int b10 = (x_int+1)*ny + y_int;
|
||||
int b11 = (x_int+1)*ny + y_int+1;
|
||||
return 0.5;
|
||||
|
||||
//vertical extrap
|
||||
double y0 = y_min+(y_int+0.5)*y_width;
|
||||
double y1 = y_min+(y_int+1.5)*y_width;
|
||||
double left_v = value_between_points(y0,data[b00],y1,data[b01],y);
|
||||
double right_v = value_between_points(y0,data[b10],y1,data[b11],y);
|
||||
//horazontal extrap
|
||||
|
||||
|
||||
|
||||
return 0.5;
|
||||
|
||||
|
||||
return value_between_points(x_min+(x_int+0.5)*x_width,left_v,
|
||||
x_min+(x_int+1.5)*x_width,right_v,x);
|
||||
}
|
||||
|
||||
return value_between_points(x_min + (x_int + 0.5) * x_width, left_v,
|
||||
x_min + (x_int + 1.5) * x_width, right_v,
|
||||
x);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
111
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h
Executable file → Normal file
111
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h
Executable file → Normal file
@ -1,98 +1,87 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
#include <qwt_plot.h>
|
||||
#include "SlsQt2DHist.h"
|
||||
#include "SlsQt2DZoomer.h"
|
||||
#include <qlist.h>
|
||||
#include <qwt_plot.h>
|
||||
#include <qwt_plot_spectrogram.h>
|
||||
|
||||
#include "SlsQt2DZoomer.h"
|
||||
#include "SlsQt2DHist.h"
|
||||
class QwtPlotPanner;
|
||||
class QwtScaleWidget;
|
||||
class QwtLinearColorMap;
|
||||
|
||||
|
||||
class QwtPlotPanner;
|
||||
class QwtScaleWidget;
|
||||
class QwtLinearColorMap;
|
||||
|
||||
|
||||
class SlsQt2DPlot: public QwtPlot{
|
||||
class SlsQt2DPlot : public QwtPlot {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
SlsQt2DPlot(QWidget * = NULL);
|
||||
~SlsQt2DPlot();
|
||||
void SetTitle(QString title);
|
||||
void SetXTitle(QString title);
|
||||
void SetYTitle(QString title);
|
||||
void SetZTitle(QString title);
|
||||
void SetTitleFont(const QFont& f);
|
||||
void SetXFont(const QFont& f);
|
||||
void SetYFont(const QFont& f);
|
||||
void SetZFont(const QFont& f);
|
||||
void SetTitleFont(const QFont &f);
|
||||
void SetXFont(const QFont &f);
|
||||
void SetYFont(const QFont &f);
|
||||
void SetZFont(const QFont &f);
|
||||
|
||||
void UnZoom(bool replot=true);
|
||||
void SetZoom(double xmin,double ymin,double x_width,double y_width);
|
||||
void UnZoom(bool replot = true);
|
||||
void SetZoom(double xmin, double ymin, double x_width, double y_width);
|
||||
void DisableZoom(bool disable);
|
||||
void EnableXAutoScaling() {setAxisAutoScale(QwtPlot::xBottom, true);};
|
||||
void EnableYAutoScaling() {setAxisAutoScale(QwtPlot::yLeft, true);};
|
||||
void SetXMinMax(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);};
|
||||
void SetYMinMax(double min,double max){setAxisScale(QwtPlot::yLeft,min,max);};
|
||||
double GetXMinimum(){return hist->GetXMin();};
|
||||
double GetXMaximum(){return hist->GetXMax();};
|
||||
double GetYMinimum(){return hist->GetYMin();};
|
||||
double GetYMaximum(){return hist->GetYMax();};
|
||||
double GetZMinimum(){ return hist->GetMinimum();}
|
||||
double GetZMaximum(){ return hist->GetMaximum();}
|
||||
void SetZMinMax(double zmin=0,double zmax=-1);
|
||||
void SetZMinimumToFirstGreaterThanZero(){hist->SetMinimumToFirstGreaterThanZero();}
|
||||
double GetZMean() { return hist->GetMean();}
|
||||
void EnableXAutoScaling() { setAxisAutoScale(QwtPlot::xBottom, true); };
|
||||
void EnableYAutoScaling() { setAxisAutoScale(QwtPlot::yLeft, true); };
|
||||
void SetXMinMax(double min, double max) {
|
||||
setAxisScale(QwtPlot::xBottom, min, max);
|
||||
};
|
||||
void SetYMinMax(double min, double max) {
|
||||
setAxisScale(QwtPlot::yLeft, min, max);
|
||||
};
|
||||
double GetXMinimum() { return hist->GetXMin(); };
|
||||
double GetXMaximum() { return hist->GetXMax(); };
|
||||
double GetYMinimum() { return hist->GetYMin(); };
|
||||
double GetYMaximum() { return hist->GetYMax(); };
|
||||
double GetZMinimum() { return hist->GetMinimum(); }
|
||||
double GetZMaximum() { return hist->GetMaximum(); }
|
||||
void SetZMinMax(double zmin = 0, double zmax = -1);
|
||||
void SetZMinimumToFirstGreaterThanZero() {
|
||||
hist->SetMinimumToFirstGreaterThanZero();
|
||||
}
|
||||
double GetZMean() { return hist->GetMean(); }
|
||||
|
||||
void SetData(int nbinsx, double xmin, double xmax, int nbinsy,double ymin, double ymax,double *d,double zmin=0, double zmax=-1){
|
||||
hist->SetData(nbinsx,xmin,xmax,nbinsy,ymin,ymax,d,zmin,zmax);
|
||||
void SetData(int nbinsx, double xmin, double xmax, int nbinsy, double ymin,
|
||||
double ymax, double *d, double zmin = 0, double zmax = -1) {
|
||||
hist->SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d, zmin, zmax);
|
||||
}
|
||||
|
||||
double* GetDataPtr() {return hist->GetDataPtr();}
|
||||
int GetBinIndex(int bx,int by) {return hist->GetBinIndex(bx,by);}
|
||||
int FindBinIndex(double x,double y) {return hist->FindBinIndex(x,y);}
|
||||
void SetBinValue(int bx,int by,double v) { hist->SetBinValue(bx,by,v);}
|
||||
double GetBinValue(int bx,int by) {return hist->GetBinValue(bx,by);}
|
||||
void FillTestPlot(int i=0);
|
||||
double *GetDataPtr() { return hist->GetDataPtr(); }
|
||||
int GetBinIndex(int bx, int by) { return hist->GetBinIndex(bx, by); }
|
||||
int FindBinIndex(double x, double y) { return hist->FindBinIndex(x, y); }
|
||||
void SetBinValue(int bx, int by, double v) { hist->SetBinValue(bx, by, v); }
|
||||
double GetBinValue(int bx, int by) { return hist->GetBinValue(bx, by); }
|
||||
void FillTestPlot(int i = 0);
|
||||
void Update();
|
||||
|
||||
void SetInterpolate(bool enable);
|
||||
void SetContour(bool enable);
|
||||
void SetLogz(bool enable, 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);
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void showSpectrogram(bool on);
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
void SetupZoom();
|
||||
void SetupColorMap();
|
||||
QwtLinearColorMap* myColourMap(QVector<double> colourStops);
|
||||
QwtLinearColorMap* myColourMap(int log=0);
|
||||
QwtLinearColorMap *myColourMap(QVector<double> colourStops);
|
||||
QwtLinearColorMap *myColourMap(int log = 0);
|
||||
|
||||
QwtPlotSpectrogram *d_spectrogram{nullptr};
|
||||
SlsQt2DHist* hist{nullptr};
|
||||
SlsQt2DZoomer* zoomer{nullptr};
|
||||
QwtPlotPanner* panner{nullptr};
|
||||
SlsQt2DHist *hist{nullptr};
|
||||
SlsQt2DZoomer *zoomer{nullptr};
|
||||
QwtPlotPanner *panner{nullptr};
|
||||
QwtScaleWidget *rightAxis{nullptr};
|
||||
|
||||
QwtLinearColorMap* colorMapLinearScale{nullptr};
|
||||
QwtLinearColorMap* colorMapLogScale{nullptr};
|
||||
#if QWT_VERSION<0x060000
|
||||
QwtValueList* contourLevelsLinear{nullptr};
|
||||
QwtValueList* contourLevelsLog{nullptr};
|
||||
#else
|
||||
QList<double> contourLevelsLinear;
|
||||
QList<double> contourLevelsLog;
|
||||
#endif
|
||||
bool disableZoom{false};
|
||||
int isLog;
|
||||
};
|
||||
|
||||
|
96
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DZoomer.h
Executable file → Normal file
96
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DZoomer.h
Executable file → Normal file
@ -1,73 +1,41 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
* Dhanya-05.12.2012- included an additional header
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SLSQT2DZOOMER_H
|
||||
#define SLSQT2DZOOMER_H
|
||||
|
||||
|
||||
|
||||
/**included by Dhanya on 05.12.2012 to avoid compile time errors with the latest gcc*/
|
||||
#include <cstdio>
|
||||
/**end of Change by Dhanya*/
|
||||
|
||||
#include <qwt_plot_zoomer.h>
|
||||
#include <qwt_plot_panner.h>
|
||||
|
||||
#include "SlsQt2DHist.h"
|
||||
#include <qwt_plot_panner.h>
|
||||
#include <qwt_plot_zoomer.h>
|
||||
#include <cstdio>
|
||||
|
||||
class SlsQt2DZoomer:public QwtPlotZoomer{
|
||||
private:
|
||||
SlsQt2DHist* hist;
|
||||
|
||||
public:
|
||||
#if QWT_VERSION < 0x060100
|
||||
SlsQt2DZoomer(QwtPlotCanvas *canvas):QwtPlotZoomer(canvas){
|
||||
#else
|
||||
SlsQt2DZoomer(QWidget *canvas):QwtPlotZoomer(canvas){
|
||||
#endif
|
||||
setTrackerMode(AlwaysOn);
|
||||
}
|
||||
|
||||
void SetHist(SlsQt2DHist* h){
|
||||
hist=h;
|
||||
}
|
||||
|
||||
|
||||
#if QWT_VERSION<0x060000
|
||||
virtual QwtText trackerText(const QwtDoublePoint &pos) const{
|
||||
#else
|
||||
virtual QwtText trackerTextF(const QPointF &pos) const{
|
||||
#endif
|
||||
QColor bg(Qt::white);
|
||||
#if QT_VERSION >= 0x040300
|
||||
bg.setAlpha(200);
|
||||
#endif
|
||||
|
||||
|
||||
//QwtText text = QwtPlotZoomer::trackerText(pos);
|
||||
|
||||
static QwtText text;
|
||||
if(hist){
|
||||
static char t[200];
|
||||
sprintf(t,"%3.2f, %3.2f, %3.2f",pos.x(),pos.y(),hist->value(pos.x(),pos.y()));
|
||||
text.setText(t);
|
||||
}else {
|
||||
#if QWT_VERSION<0x060000
|
||||
QwtText text = QwtPlotZoomer::trackerText(pos);
|
||||
#else
|
||||
QPoint p=pos.toPoint();
|
||||
QwtText text = QwtPlotZoomer::trackerText(p);
|
||||
#endif
|
||||
class SlsQt2DZoomer : public QwtPlotZoomer {
|
||||
private:
|
||||
SlsQt2DHist *hist;
|
||||
|
||||
public:
|
||||
SlsQt2DZoomer(QWidget *canvas) : QwtPlotZoomer(canvas) {
|
||||
setTrackerMode(AlwaysOn);
|
||||
}
|
||||
|
||||
void SetHist(SlsQt2DHist *h) { hist = h; }
|
||||
|
||||
virtual QwtText trackerTextF(const QPointF &pos) const {
|
||||
QColor bg(Qt::white);
|
||||
bg.setAlpha(200);
|
||||
|
||||
// QwtText text = QwtPlotZoomer::trackerText(pos);
|
||||
|
||||
static QwtText text;
|
||||
if (hist) {
|
||||
static char t[200];
|
||||
sprintf(t, "%3.2f, %3.2f, %3.2f", pos.x(), pos.y(),
|
||||
hist->value(pos.x(), pos.y()));
|
||||
text.setText(t);
|
||||
} else {
|
||||
|
||||
QPoint p = pos.toPoint();
|
||||
QwtText text = QwtPlotZoomer::trackerText(p);
|
||||
}
|
||||
text.setBackgroundBrush(QBrush(bg));
|
||||
return text;
|
||||
}
|
||||
text.setBackgroundBrush( QBrush( bg ));
|
||||
return text;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
215
slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx → slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cpp
Executable file → Normal file
215
slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx → slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cpp
Executable file → Normal file
@ -1,11 +1,7 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
/* TODO! short description */
|
||||
#include "SlsQt1DPlot.h"
|
||||
#include <iostream>
|
||||
#include <qwt_symbol.h>
|
||||
#include <qwt_legend.h>
|
||||
#include <qwt_math.h>
|
||||
#include <qwt_painter.h>
|
||||
@ -14,19 +10,19 @@
|
||||
#include <qwt_scale_draw.h>
|
||||
#include <qwt_scale_engine.h>
|
||||
#include <qwt_scale_widget.h>
|
||||
#include "qwt_symbol.h"
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
|
||||
#if QWT_VERSION >= 0x060100
|
||||
#define QwtLog10ScaleEngine QwtLogScaleEngine
|
||||
#endif
|
||||
#define QwtLog10ScaleEngine QwtLogScaleEngine // hmm
|
||||
|
||||
SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data) : QwtPlotCurve(title), x(nullptr), y(nullptr), pen_ptr(nullptr) {
|
||||
SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data)
|
||||
: QwtPlotCurve(title), x(nullptr), y(nullptr), pen_ptr(nullptr) {
|
||||
Initailize();
|
||||
SetData(n, min, max, data);
|
||||
}
|
||||
|
||||
SlsQtH1D::SlsQtH1D(QString title, int n, double *data_x, double *data_y) : QwtPlotCurve(title) {
|
||||
SlsQtH1D::SlsQtH1D(QString title, int n, double *data_x, double *data_y)
|
||||
: QwtPlotCurve(title) {
|
||||
Initailize();
|
||||
SetData(n, data_x, data_y);
|
||||
}
|
||||
@ -39,12 +35,12 @@ void SlsQtH1D::Initailize() {
|
||||
}
|
||||
|
||||
SlsQtH1D::~SlsQtH1D() {
|
||||
if (x)
|
||||
delete [] x;
|
||||
if (y)
|
||||
delete [] y;
|
||||
if (pen_ptr)
|
||||
delete pen_ptr;
|
||||
|
||||
delete[] x;
|
||||
|
||||
delete[] y;
|
||||
|
||||
delete pen_ptr;
|
||||
}
|
||||
|
||||
void SlsQtH1D::Attach(SlsQt1DPlot *p) {
|
||||
@ -128,21 +124,17 @@ void SlsQtH1D::SetLineStyle(int s) {
|
||||
setPen(*pen_ptr);
|
||||
}
|
||||
|
||||
void SlsQtH1D::setStyleLinesorDots(bool isLines) {
|
||||
void SlsQtH1D::setStyleLinesorDots(bool isLines) {
|
||||
setStyle(isLines ? QwtPlotCurve::Lines : QwtPlotCurve::Dots);
|
||||
}
|
||||
|
||||
void SlsQtH1D::setSymbolMarkers(bool isMarker) {
|
||||
QwtSymbol* marker = new QwtSymbol();
|
||||
void SlsQtH1D::setSymbolMarkers(bool isMarker) {
|
||||
QwtSymbol *marker = new QwtSymbol();
|
||||
if (isMarker) {
|
||||
marker->setStyle(QwtSymbol::Cross);
|
||||
marker->setSize(5, 5);
|
||||
}
|
||||
#if QWT_VERSION < 0x060000
|
||||
setSymbol(*marker);
|
||||
#else
|
||||
setSymbol(marker);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SlsQtH1D::SetData(int n, double xmin, double xmax, double *data) {
|
||||
@ -173,11 +165,7 @@ void SlsQtH1D::SetData(int n, double xmin, double xmax, double *data) {
|
||||
firstYgt0 = y[i];
|
||||
}
|
||||
|
||||
#if QWT_VERSION < 0x060000
|
||||
setRawData(x, y, ndata);
|
||||
#else
|
||||
setRawSamples(x, y, ndata);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SlsQtH1D::SetData(int n, double *data_x, double *data_y) {
|
||||
@ -186,7 +174,7 @@ void SlsQtH1D::SetData(int n, double *data_x, double *data_y) {
|
||||
n = SetUpArrays(n);
|
||||
|
||||
ndata = n;
|
||||
dx = -1; //signifies not regular intervals
|
||||
dx = -1; // signifies not regular intervals
|
||||
|
||||
ymin = ymax = data_y ? data_y[0] : 0;
|
||||
|
||||
@ -206,23 +194,18 @@ void SlsQtH1D::SetData(int n, double *data_x, double *data_y) {
|
||||
if (y[b] > 0 && (firstYgt0 < 0 || firstYgt0 > y[b]))
|
||||
firstYgt0 = y[b];
|
||||
}
|
||||
|
||||
// #if QWT_VERSION<0x060000
|
||||
// setRawData(x,y,ndata);
|
||||
// #else
|
||||
setRawSamples(x, y, ndata);
|
||||
// #endif
|
||||
}
|
||||
|
||||
int SlsQtH1D::SetUpArrays(int n) {
|
||||
n = n < 1 ? 1 : n; //overflow bin
|
||||
n = n < 1 ? 1 : n; // overflow bin
|
||||
|
||||
if (n + 1 > n_array) {
|
||||
n_array = n + 1;
|
||||
if (x)
|
||||
delete x;
|
||||
if (y)
|
||||
delete y;
|
||||
|
||||
delete x;
|
||||
|
||||
delete y;
|
||||
x = new double[n_array];
|
||||
y = new double[n_array];
|
||||
}
|
||||
@ -234,7 +217,9 @@ double SlsQtH1D::FillBin(int bx, double v) {
|
||||
bx = CheckIndex(bx);
|
||||
return SetBinContent(bx, y[bx] + v);
|
||||
}
|
||||
double SlsQtH1D::Fill(double x, double v) { return FillBin(FindBinIndex(x), v); }
|
||||
double SlsQtH1D::Fill(double x, double v) {
|
||||
return FillBin(FindBinIndex(x), v);
|
||||
}
|
||||
|
||||
double SlsQtH1D::SetBinContent(int bx, double v) {
|
||||
bx = CheckIndex(bx);
|
||||
@ -250,13 +235,15 @@ double SlsQtH1D::SetBinContent(int bx, double v) {
|
||||
return y[bx];
|
||||
}
|
||||
|
||||
double SlsQtH1D::SetContent(double x, double v) { return SetBinContent(FindBinIndex(x), v); }
|
||||
double SlsQtH1D::SetContent(double x, double v) {
|
||||
return SetBinContent(FindBinIndex(x), v);
|
||||
}
|
||||
|
||||
int SlsQtH1D::FindBinIndex(double px) {
|
||||
if (dx > 0)
|
||||
CheckIndex(int((px - x[0]) / dx));
|
||||
|
||||
//find closest bin
|
||||
// find closest bin
|
||||
int b = 0;
|
||||
for (; b < ndata; b++)
|
||||
if (x[b] > px)
|
||||
@ -270,7 +257,9 @@ int SlsQtH1D::FindBinIndex(double px) {
|
||||
return b;
|
||||
}
|
||||
|
||||
int SlsQtH1D::CheckIndex(int bx) { return (bx < 0 || bx > ndata) ? ndata : bx; } //ndata is the overflow bin
|
||||
int SlsQtH1D::CheckIndex(int bx) {
|
||||
return (bx < 0 || bx > ndata) ? ndata : bx;
|
||||
} // ndata is the overflow bin
|
||||
|
||||
SlsQtH1D *SlsQtH1D::Add(double v) {
|
||||
for (int bx = 0; bx < ndata; bx++)
|
||||
@ -278,23 +267,20 @@ SlsQtH1D *SlsQtH1D::Add(double v) {
|
||||
return this;
|
||||
}
|
||||
|
||||
//1d hist list stuff
|
||||
// 1d hist list stuff
|
||||
SlsQtH1DList::SlsQtH1DList(SlsQtH1D *hist) {
|
||||
the_hist = hist;
|
||||
the_next = 0;
|
||||
the_next = nullptr;
|
||||
}
|
||||
|
||||
SlsQtH1DList::~SlsQtH1DList() {
|
||||
if (the_next)
|
||||
delete the_next;
|
||||
}
|
||||
SlsQtH1DList::~SlsQtH1DList() { delete the_next; }
|
||||
|
||||
SlsQtH1D *SlsQtH1DList::Add(SlsQtH1D *hist) {
|
||||
SlsQtH1DList *hl = this;
|
||||
|
||||
while (hl) {
|
||||
if (hist == hl->the_hist)
|
||||
return hist; //already added
|
||||
return hist; // already added
|
||||
if (!hl->the_next)
|
||||
break;
|
||||
hl = hl->the_next;
|
||||
@ -313,7 +299,8 @@ void SlsQtH1DList::Print() {
|
||||
SlsQtH1DList *hl = this;
|
||||
int i = 0;
|
||||
while (hl) {
|
||||
std::cout << " " << i++ << ") " << hl << " " << hl->the_hist << " " << hl->the_next << '\n';
|
||||
std::cout << " " << i++ << ") " << hl << " " << hl->the_hist << " "
|
||||
<< hl->the_next << '\n';
|
||||
hl = hl->the_next;
|
||||
if (i > 10)
|
||||
break;
|
||||
@ -322,27 +309,27 @@ void SlsQtH1DList::Print() {
|
||||
|
||||
void SlsQtH1DList::Remove(SlsQtH1D *hist) {
|
||||
SlsQtH1DList *hl = this;
|
||||
while (hl) { //every match will be removed
|
||||
while (hl) { // every match will be removed
|
||||
if (hl->the_hist != hist)
|
||||
hl = hl->the_next;
|
||||
else { //match
|
||||
else { // match
|
||||
if (!hl->the_next)
|
||||
hl->the_hist = 0; // first the_hist is zero when there's no next
|
||||
hl->the_hist = nullptr; // first the_hist is zero when there's no next
|
||||
else {
|
||||
SlsQtH1DList *t = hl->the_next;
|
||||
hl->the_hist = t->the_hist;
|
||||
hl->the_next = t->the_next;
|
||||
t->the_next = 0;
|
||||
t->the_next = nullptr;
|
||||
delete t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//1d plot stuff
|
||||
// 1d plot stuff
|
||||
SlsQt1DPlot::SlsQt1DPlot(QWidget *parent) : QwtPlot(parent) {
|
||||
// n_histograms_attached=0;
|
||||
hline = vline = 0;
|
||||
hline = vline = nullptr;
|
||||
hist_list = new SlsQtH1DList();
|
||||
|
||||
UnknownStuff();
|
||||
@ -361,16 +348,16 @@ SlsQt1DPlot::SlsQt1DPlot(QWidget *parent) : QwtPlot(parent) {
|
||||
}
|
||||
|
||||
SlsQt1DPlot::~SlsQt1DPlot() {
|
||||
if (hist_list)
|
||||
delete hist_list;
|
||||
if (hline)
|
||||
delete hline;
|
||||
if (vline)
|
||||
delete vline;
|
||||
if (zoomer)
|
||||
delete zoomer;
|
||||
if (panner)
|
||||
delete panner;
|
||||
|
||||
delete hist_list;
|
||||
|
||||
delete hline;
|
||||
|
||||
delete vline;
|
||||
|
||||
delete zoomer;
|
||||
|
||||
delete panner;
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::CalculateNResetZoomBase() {
|
||||
@ -387,8 +374,8 @@ void SlsQt1DPlot::CalculateNResetZoomBase() {
|
||||
void SlsQt1DPlot::NewHistogramAttached(SlsQtH1D *h) {
|
||||
hist_list->Add(h);
|
||||
CalculateNResetZoomBase();
|
||||
//commented out by dhanya to take off zooming every hist in 1d plots
|
||||
//if(!hist_list->Next()) UnZoom();
|
||||
// commented out by dhanya to take off zooming every hist in 1d plots
|
||||
// if(!hist_list->Next()) UnZoom();
|
||||
Update();
|
||||
}
|
||||
|
||||
@ -398,13 +385,9 @@ void SlsQt1DPlot::HistogramDetached(SlsQtH1D *h) {
|
||||
Update();
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::Update() {
|
||||
replot();
|
||||
}
|
||||
void SlsQt1DPlot::Update() { replot(); }
|
||||
|
||||
void SlsQt1DPlot::SetTitle(QString title) {
|
||||
setTitle(title);
|
||||
}
|
||||
void SlsQt1DPlot::SetTitle(QString title) { setTitle(title); }
|
||||
|
||||
void SlsQt1DPlot::SetXTitle(QString title) {
|
||||
setAxisTitle(QwtPlot::xBottom, title);
|
||||
@ -414,20 +397,20 @@ void SlsQt1DPlot::SetYTitle(QString title) {
|
||||
setAxisTitle(QwtPlot::yLeft, title);
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::SetTitleFont(const QFont& f) {
|
||||
void SlsQt1DPlot::SetTitleFont(const QFont &f) {
|
||||
QwtText t("");
|
||||
t.setFont(f);
|
||||
t.setRenderFlags( Qt::AlignLeft | Qt::AlignVCenter);
|
||||
t.setRenderFlags(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
setTitle(t);
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::SetXFont(const QFont& f) {
|
||||
void SlsQt1DPlot::SetXFont(const QFont &f) {
|
||||
QwtText t("");
|
||||
t.setFont(f);
|
||||
setAxisTitle(QwtPlot::xBottom, t);
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::SetYFont(const QFont& f) {
|
||||
void SlsQt1DPlot::SetYFont(const QFont &f) {
|
||||
QwtText t("");
|
||||
t.setFont(f);
|
||||
setAxisTitle(QwtPlot::yLeft, t);
|
||||
@ -441,9 +424,10 @@ void SlsQt1DPlot::SetLog(int axisId, bool yes) {
|
||||
if (axisId == QwtPlot::yLeft)
|
||||
zoomer->SetLogY(yes);
|
||||
|
||||
zoomer->ResetZoomBase(); //needs to be done before setting Engine
|
||||
zoomer->ResetZoomBase(); // needs to be done before setting Engine
|
||||
|
||||
//the old ones are deleted by in the setAxisScaleFunction() function see: 128 of file qwt_plot_axis.cpp
|
||||
// the old ones are deleted by in the setAxisScaleFunction() function see:
|
||||
// 128 of file qwt_plot_axis.cpp
|
||||
if (yes)
|
||||
setAxisScaleEngine(axisId, new QwtLog10ScaleEngine());
|
||||
else
|
||||
@ -459,11 +443,13 @@ void SlsQt1DPlot::UnZoom() {
|
||||
setAxisScale(QwtPlot::xBottom, zoomer->x(), zoomer->x() + zoomer->w());
|
||||
setAxisScale(QwtPlot::yLeft, zoomer->y(), zoomer->y() + zoomer->h());
|
||||
|
||||
zoomer->setZoomBase(); //Call replot for the attached plot before initializing the zoomer with its scales.
|
||||
zoomer->setZoomBase(); // Call replot for the attached plot before
|
||||
// initializing the zoomer with its scales.
|
||||
Update();
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::SetZoom(double xmin, double ymin, double x_width, double y_width) {
|
||||
void SlsQt1DPlot::SetZoom(double xmin, double ymin, double x_width,
|
||||
double y_width) {
|
||||
setAxisScale(QwtPlot::xBottom, xmin, xmin + x_width);
|
||||
setAxisScale(QwtPlot::yLeft, ymin, ymin + y_width);
|
||||
Update();
|
||||
@ -473,7 +459,7 @@ void SlsQt1DPlot::RemoveHLine() {
|
||||
if (hline)
|
||||
hline->detach();
|
||||
delete hline;
|
||||
hline = 0;
|
||||
hline = nullptr;
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::InsertHLine(double y) {
|
||||
@ -490,7 +476,7 @@ void SlsQt1DPlot::RemoveVLine() {
|
||||
if (vline)
|
||||
vline->detach();
|
||||
delete vline;
|
||||
vline = 0;
|
||||
vline = nullptr;
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::InsertVLine(double x) {
|
||||
@ -510,12 +496,9 @@ void SlsQt1DPlot::SetupZoom() {
|
||||
// Ctrl+RighButton: zoom out to full size
|
||||
|
||||
zoomer = new SlsQt1DZoomer(canvas());
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton,
|
||||
Qt::ControlModifier);
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton);
|
||||
#else
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
|
||||
#endif
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
|
||||
|
||||
panner = new QwtPlotPanner((QwtPlotCanvas *)canvas());
|
||||
@ -554,58 +537,40 @@ void SlsQt1DPlot::alignScales() {
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::UnknownStuff() {
|
||||
#if QWT_VERSION < 0x060000
|
||||
// Disable polygon clipping
|
||||
//not supported for version 6
|
||||
QwtPainter::setDeviceClipping(false);
|
||||
canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
|
||||
canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
|
||||
#else
|
||||
// We don't need the cache here
|
||||
((QwtPlotCanvas *)canvas())->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
|
||||
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= 0x040000
|
||||
((QwtPlotCanvas *)canvas())
|
||||
->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
|
||||
#ifdef Q_WS_X11
|
||||
// Qt::WA_PaintOnScreen is only supported for X11, but leads
|
||||
// to substantial bugs with Qt 4.2.x/Windows
|
||||
canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
//Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range has been set
|
||||
// Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range
|
||||
// has been set
|
||||
void SlsQt1DPlot::DisableZoom(bool disable) {
|
||||
if (disableZoom != disable) {
|
||||
disableZoom = disable;
|
||||
#ifdef VERBOSE
|
||||
if (disable)
|
||||
std::cout << "Disabling zoom\n";
|
||||
else
|
||||
std::cout << "Enabling zoom\n";
|
||||
#endif
|
||||
if (disable) {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton);
|
||||
#if QT_VERSION < 0x040000
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlButton);
|
||||
#else
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier);
|
||||
#endif
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1,
|
||||
Qt::NoButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
|
||||
Qt::NoButton, Qt::ControlModifier);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
|
||||
Qt::NoButton);
|
||||
}
|
||||
if (panner)
|
||||
panner->setMouseButton(Qt::NoButton);
|
||||
} else {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton);
|
||||
#if QT_VERSION < 0x040000
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton);
|
||||
#else
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
|
||||
#endif
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1,
|
||||
Qt::LeftButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
|
||||
Qt::RightButton, Qt::ControlModifier);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
|
||||
Qt::RightButton);
|
||||
}
|
||||
if (panner)
|
||||
panner->setMouseButton(Qt::MidButton);
|
93
slsDetectorGui/slsDetectorPlotting/src/SlsQt1DZoomer.cpp
Normal file
93
slsDetectorGui/slsDetectorPlotting/src/SlsQt1DZoomer.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
/* TODO! short description */
|
||||
#include "SlsQt1DZoomer.h"
|
||||
#include "SlsQt1DPlot.h"
|
||||
#include <qwt_plot.h>
|
||||
#include <qwt_scale_div.h>
|
||||
#include <iostream>
|
||||
|
||||
void SlsQt1DZoomer::ResetZoomBase() {
|
||||
SetZoomBase(x0, y0, x1 - x0,
|
||||
y1 - y0); // for going between log and nonlog plots
|
||||
}
|
||||
|
||||
void SlsQt1DZoomer::SetZoomBase(double xmin, double ymin, double x_width,
|
||||
double y_width) {
|
||||
if (xIsLog && xmin <= 0) {
|
||||
double xmax = xmin + x_width;
|
||||
xmin = firstXgt0 * 0.98;
|
||||
if (xmax <= xmin)
|
||||
x_width = firstXgt0;
|
||||
else
|
||||
x_width = xmax - xmin;
|
||||
}
|
||||
if (yIsLog && ymin <= 0) {
|
||||
double ymax = ymin + y_width;
|
||||
ymin = firstYgt0 * 0.98;
|
||||
if (ymax <= ymin)
|
||||
y_width = firstYgt0;
|
||||
else
|
||||
y_width = ymax - ymin;
|
||||
}
|
||||
|
||||
if (plot()) {
|
||||
if (xIsLog) {
|
||||
double xmin_curr =
|
||||
plot()->axisScaleDiv(QwtPlot::xBottom).lowerBound();
|
||||
double xmax_curr =
|
||||
plot()->axisScaleDiv(QwtPlot::xBottom).upperBound();
|
||||
if (xmin_curr < xmin)
|
||||
xmin_curr = xmin;
|
||||
if (xmax_curr > xmin + x_width)
|
||||
xmax_curr = xmin + x_width;
|
||||
plot()->setAxisScale(QwtPlot::xBottom, xmin_curr, xmax_curr);
|
||||
}
|
||||
if (yIsLog) {
|
||||
double ymin_curr =
|
||||
plot()->axisScaleDiv(QwtPlot::yLeft).lowerBound();
|
||||
double ymax_curr =
|
||||
plot()->axisScaleDiv(QwtPlot::yLeft).upperBound();
|
||||
if (ymin_curr < ymin)
|
||||
ymin_curr = ymin;
|
||||
if (ymax_curr > ymin + y_width)
|
||||
ymax_curr = ymin + y_width;
|
||||
plot()->setAxisScale(QwtPlot::yLeft, ymin_curr, ymax_curr);
|
||||
}
|
||||
plot()->replot();
|
||||
}
|
||||
setZoomBase(QRectF(xmin, ymin, x_width, y_width));
|
||||
}
|
||||
|
||||
void SlsQt1DZoomer::SetZoomBase(SlsQtH1D *h) {
|
||||
x0 = h->GetXMin() < 0 ? h->GetXMin() * 1.02 : h->GetXMin() / 1.02;
|
||||
x1 = h->GetXMax() < 0 ? h->GetXMax() / 1.02 : h->GetXMax() * 1.02;
|
||||
y0 = h->GetYMin() < 0 ? h->GetYMin() * 1.02 : h->GetYMin() / 1.02;
|
||||
y1 = h->GetYMax() < 0 ? h->GetYMax() / 1.02 : h->GetYMax() * 1.02;
|
||||
|
||||
firstXgt0 = h->GetFirstXgtZero(); // for log plots
|
||||
firstYgt0 = h->GetFirstYgtZero(); // for log plots
|
||||
|
||||
ResetZoomBase();
|
||||
}
|
||||
|
||||
void SlsQt1DZoomer::ExtendZoomBase(SlsQtH1D *h) {
|
||||
double h_x0 = h->GetXMin() < 0 ? h->GetXMin() * 1.02 : h->GetXMin() / 1.02;
|
||||
double h_x1 = h->GetXMax() < 0 ? h->GetXMax() / 1.02 : h->GetXMax() * 1.02;
|
||||
double h_y0 = h->GetYMin() < 0 ? h->GetYMin() * 1.02 : h->GetYMin() / 1.02;
|
||||
double h_y1 = h->GetYMax() < 0 ? h->GetYMax() / 1.02 : h->GetYMax() * 1.02;
|
||||
|
||||
if (h_x0 < x0)
|
||||
x0 = h_x0;
|
||||
if (h_x1 > x1)
|
||||
x1 = h_x1;
|
||||
if (h_y0 < y0)
|
||||
y0 = h_y0;
|
||||
if (h_y1 > y1)
|
||||
y1 = h_y1;
|
||||
|
||||
if (h->GetFirstXgtZero() < firstXgt0)
|
||||
firstXgt0 = h->GetFirstXgtZero();
|
||||
if (h->GetFirstYgtZero() < firstYgt0)
|
||||
firstYgt0 = h->GetFirstYgtZero();
|
||||
|
||||
ResetZoomBase();
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <qwt_plot.h>
|
||||
#include <qwt_scale_div.h>
|
||||
|
||||
#include "SlsQt1DPlot.h"
|
||||
#include "SlsQt1DZoomer.h"
|
||||
|
||||
|
||||
void SlsQt1DZoomer::ResetZoomBase(){
|
||||
SetZoomBase(x0,y0,x1-x0,y1-y0); //for going between log and nonlog plots
|
||||
}
|
||||
|
||||
void SlsQt1DZoomer::SetZoomBase(double xmin,double ymin,double x_width, double y_width){
|
||||
if(xIsLog&&xmin<=0){
|
||||
double xmax = xmin+x_width;
|
||||
xmin = firstXgt0*0.98;
|
||||
if(xmax<=xmin) x_width=firstXgt0;
|
||||
else x_width=xmax-xmin;
|
||||
}
|
||||
if(yIsLog&&ymin<=0){
|
||||
double ymax = ymin+y_width;
|
||||
ymin = firstYgt0*0.98;
|
||||
if(ymax<=ymin) y_width=firstYgt0;
|
||||
else y_width=ymax-ymin;
|
||||
}
|
||||
|
||||
if(plot()){
|
||||
if(xIsLog){
|
||||
#if QWT_VERSION < 0x50200
|
||||
double xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->lBound();
|
||||
double xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->hBound();
|
||||
#elif QWT_VERSION < 0x060100
|
||||
double xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->lowerBound();
|
||||
double xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom)->upperBound();
|
||||
#else
|
||||
double xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom).lowerBound();
|
||||
double xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom).upperBound();
|
||||
#endif
|
||||
if(xmin_curr<xmin) xmin_curr=xmin;
|
||||
if(xmax_curr>xmin+x_width) xmax_curr=xmin+x_width;
|
||||
plot()->setAxisScale(QwtPlot::xBottom,xmin_curr,xmax_curr);
|
||||
}
|
||||
if(yIsLog){
|
||||
#if QWT_VERSION < 0x50200
|
||||
double ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->lBound();
|
||||
double ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->hBound();
|
||||
#elif QWT_VERSION < 0x060100
|
||||
double ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->lowerBound();
|
||||
double ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft)->upperBound();
|
||||
#else
|
||||
double ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft).lowerBound();
|
||||
double ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft).upperBound();
|
||||
#endif
|
||||
if(ymin_curr<ymin) ymin_curr=ymin;
|
||||
if(ymax_curr>ymin+y_width) ymax_curr=ymin+y_width;
|
||||
plot()->setAxisScale(QwtPlot::yLeft,ymin_curr,ymax_curr);
|
||||
}
|
||||
plot()->replot();
|
||||
}
|
||||
|
||||
#if QWT_VERSION<0x060000
|
||||
setZoomBase(QwtDoubleRect(xmin,ymin,x_width,y_width));
|
||||
#else
|
||||
setZoomBase(QRectF(xmin,ymin,x_width,y_width));
|
||||
#endif
|
||||
}
|
||||
|
||||
void SlsQt1DZoomer::SetZoomBase(SlsQtH1D* h){
|
||||
x0 = h->GetXMin()<0 ? h->GetXMin()*1.02 : h->GetXMin()/1.02;
|
||||
x1 = h->GetXMax()<0 ? h->GetXMax()/1.02 : h->GetXMax()*1.02;
|
||||
y0 = h->GetYMin()<0 ? h->GetYMin()*1.02 : h->GetYMin()/1.02;
|
||||
y1 = h->GetYMax()<0 ? h->GetYMax()/1.02 : h->GetYMax()*1.02;
|
||||
|
||||
firstXgt0 = h->GetFirstXgtZero(); //for log plots
|
||||
firstYgt0 = h->GetFirstYgtZero(); //for log plots
|
||||
|
||||
ResetZoomBase();
|
||||
}
|
||||
|
||||
void SlsQt1DZoomer::ExtendZoomBase(SlsQtH1D* h){
|
||||
double h_x0 = h->GetXMin()<0 ? h->GetXMin()*1.02 : h->GetXMin()/1.02;
|
||||
double h_x1 = h->GetXMax()<0 ? h->GetXMax()/1.02 : h->GetXMax()*1.02;
|
||||
double h_y0 = h->GetYMin()<0 ? h->GetYMin()*1.02 : h->GetYMin()/1.02;
|
||||
double h_y1 = h->GetYMax()<0 ? h->GetYMax()/1.02 : h->GetYMax()*1.02;
|
||||
|
||||
if(h_x0<x0) x0 = h_x0;
|
||||
if(h_x1>x1) x1 = h_x1;
|
||||
if(h_y0<y0) y0 = h_y0;
|
||||
if(h_y1>y1) y1 = h_y1;
|
||||
|
||||
if(h->GetFirstXgtZero()<firstXgt0) firstXgt0 = h->GetFirstXgtZero();
|
||||
if(h->GetFirstYgtZero()<firstYgt0) firstYgt0 = h->GetFirstYgtZero();
|
||||
|
||||
ResetZoomBase();
|
||||
}
|
||||
|
||||
|
||||
|
143
slsDetectorGui/slsDetectorPlotting/src/SlsQt2DHist.cpp
Normal file
143
slsDetectorGui/slsDetectorPlotting/src/SlsQt2DHist.cpp
Normal file
@ -0,0 +1,143 @@
|
||||
/* TODO! short description */
|
||||
#include "SlsQt2DHist.h"
|
||||
#include "ansi.h"
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy,
|
||||
double ymin, double ymax, double *d, double zmin,
|
||||
double zmax)
|
||||
: QwtRasterData() {
|
||||
x_min = 0;
|
||||
x_max = 0;
|
||||
y_min = 0;
|
||||
y_max = 0;
|
||||
interp = 0;
|
||||
nx_array = ny_array = 0;
|
||||
data = nullptr;
|
||||
SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d, zmin, zmax);
|
||||
}
|
||||
|
||||
SlsQt2DHist::~SlsQt2DHist() { delete[] data; }
|
||||
|
||||
int SlsQt2DHist::GetBinIndex(int bx, int by) {
|
||||
int b = bx * ny + by;
|
||||
if (b < 0 || b >= nb) {
|
||||
cout << "GetBinIndex:: Incorrect indicies bx and by returning overflow "
|
||||
"bin;"
|
||||
<< endl;
|
||||
return nb;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
int SlsQt2DHist::FindBinIndex(double x, double y) {
|
||||
return GetBinIndex(int((x - x_min) / x_width), int((y - y_min) / y_width));
|
||||
}
|
||||
|
||||
double SlsQt2DHist::GetBinValue(int bx, int by) {
|
||||
return data[GetBinIndex(bx, by)];
|
||||
}
|
||||
|
||||
void SlsQt2DHist::SetBinValue(int bx, int by, double v) {
|
||||
z_mean_has_been_calculated = 0;
|
||||
data[GetBinIndex(bx, by)] = v;
|
||||
}
|
||||
|
||||
void SlsQt2DHist::SetData(int nbinsx, double xmin, double xmax, int nbinsy,
|
||||
double ymin, double ymax, double *d, double zmin,
|
||||
double zmax) {
|
||||
z_mean_has_been_calculated = 0;
|
||||
if (xmax < xmin || ymax < ymin)
|
||||
cout << "Warning input range invalid." << endl;
|
||||
|
||||
x_width = (xmax - xmin) / nbinsx;
|
||||
y_width = (ymax - ymin) / nbinsy;
|
||||
|
||||
if (x_min != xmin || x_max != xmax || y_min != ymin || y_max != ymax) {
|
||||
x_min = xmin;
|
||||
x_max = xmax;
|
||||
y_min = ymin;
|
||||
y_max = ymax;
|
||||
setInterval(Qt::XAxis, QwtInterval(xmin, xmax));
|
||||
setInterval(Qt::YAxis, QwtInterval(ymin, ymax));
|
||||
}
|
||||
|
||||
if (nbinsx * nbinsy < 1) {
|
||||
cout << "Exitting: SlsQt2DHist::SetData() number of bins must be "
|
||||
"greater than zero."
|
||||
<< endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (nbinsx * nbinsy > nx_array * ny_array) {
|
||||
delete[] data;
|
||||
data = new double[nbinsx * nbinsy + 1]; // one for under/overflow bin
|
||||
nx_array = nbinsx;
|
||||
ny_array = nbinsy;
|
||||
}
|
||||
nx = nbinsx;
|
||||
ny = nbinsy;
|
||||
nb = nx * ny;
|
||||
data[nb] = 0; // set over flow to zero
|
||||
if (d) {
|
||||
memcpy(data, d, nb * sizeof(double));
|
||||
SetMinMax(zmin, zmax);
|
||||
}
|
||||
}
|
||||
|
||||
void SlsQt2DHist::SetMinMax(double zmin, double zmax) {
|
||||
/* if(zmin<zmax){ edited out to test*/
|
||||
if (zmax != -1) {
|
||||
z_min = zmin;
|
||||
z_max = zmax;
|
||||
} else {
|
||||
z_mean_has_been_calculated = 1;
|
||||
z_min = data[0];
|
||||
z_mean = 0;
|
||||
z_max = data[0];
|
||||
for (int i = 0; i < nb; i++) {
|
||||
if (data[i] < z_min)
|
||||
z_min = data[i];
|
||||
if (data[i] > z_max)
|
||||
z_max = data[i];
|
||||
z_mean += data[i];
|
||||
}
|
||||
z_mean /= nb;
|
||||
if (z_min > 0)
|
||||
z_min /= 1.02;
|
||||
else
|
||||
z_min *= 1.02;
|
||||
if (z_max > 0)
|
||||
z_max *= 1.02;
|
||||
else
|
||||
z_max /= 1.02;
|
||||
}
|
||||
setInterval(Qt::ZAxis, QwtInterval(z_min, z_max));
|
||||
}
|
||||
|
||||
double SlsQt2DHist::GetMean() {
|
||||
if (!z_mean_has_been_calculated) {
|
||||
z_mean_has_been_calculated = 1;
|
||||
z_mean = 0;
|
||||
for (int i = 0; i < nb; i++)
|
||||
z_mean += data[i];
|
||||
z_mean /= nb;
|
||||
}
|
||||
|
||||
return z_mean;
|
||||
}
|
||||
|
||||
double SlsQt2DHist::SetMinimumToFirstGreaterThanZero() {
|
||||
z_min = fabs(z_max) + 1;
|
||||
for (int i = 0; i < nb; i++) {
|
||||
if (data[i] > 0 && data[i] < z_min)
|
||||
z_min = data[i];
|
||||
}
|
||||
setInterval(Qt::ZAxis, QwtInterval(z_min, z_max));
|
||||
|
||||
return z_min;
|
||||
}
|
@ -1,144 +0,0 @@
|
||||
|
||||
/**
|
||||
* @author Ian Johnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include "SlsQt2DHist.h"
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, double* d,double zmin,double zmax):QwtRasterData(){
|
||||
x_min=0;x_max=0;y_min=0;y_max=0;
|
||||
interp=0;
|
||||
nx_array=ny_array=0;data=0;
|
||||
SetData(nbinsx,xmin,xmax,nbinsy,ymin,ymax,d,zmin,zmax);
|
||||
}
|
||||
|
||||
|
||||
SlsQt2DHist::~SlsQt2DHist(){if(data) delete [] data;}
|
||||
|
||||
int SlsQt2DHist::GetBinIndex(int bx, int by){
|
||||
int b = bx*ny+by;
|
||||
if(b<0 || b>=nb){
|
||||
cout<<"GetBinIndex:: Incorrect indicies bx and by returning overflow bin;"<<endl;
|
||||
return nb;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
int SlsQt2DHist::FindBinIndex(double x, double y){
|
||||
return GetBinIndex(int((x-x_min)/x_width),int((y-y_min)/y_width));
|
||||
}
|
||||
|
||||
double SlsQt2DHist::GetBinValue(int bx,int by){
|
||||
return data[GetBinIndex(bx,by)];
|
||||
}
|
||||
|
||||
|
||||
void SlsQt2DHist::SetBinValue(int bx,int by,double v){
|
||||
z_mean_has_been_calculated = 0;
|
||||
data[GetBinIndex(bx,by)] = v;
|
||||
}
|
||||
|
||||
void SlsQt2DHist::SetData(int nbinsx, double xmin, double xmax, int nbinsy,double ymin, double ymax, double *d,double zmin,double zmax){
|
||||
z_mean_has_been_calculated = 0;
|
||||
if(xmax<xmin||ymax<ymin) cout<<"Warning input range invalid."<<endl;
|
||||
|
||||
x_width = (xmax - xmin)/nbinsx;
|
||||
y_width = (ymax - ymin)/nbinsy;
|
||||
|
||||
if(x_min!=xmin||x_max!=xmax||y_min!=ymin||y_max!=ymax){
|
||||
x_min=xmin;x_max=xmax;
|
||||
y_min=ymin;y_max=ymax;
|
||||
|
||||
#if QWT_VERSION<0x060000
|
||||
setBoundingRect(QRectF(xmin,ymin,x_max-x_min,y_max-y_min));
|
||||
#else
|
||||
setInterval( Qt::XAxis,QwtInterval(xmin,xmax));
|
||||
setInterval( Qt::YAxis,QwtInterval(ymin,ymax));
|
||||
// setInterval( Qt::ZAxis,QwtInterval(zmin,zmax));
|
||||
//setInterval( Qt::ZAxis,QwtInterval(0.,1.));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if(nbinsx*nbinsy<1){
|
||||
cout<<"Exitting: SlsQt2DHist::SetData() number of bins must be greater than zero."<<endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(nbinsx*nbinsy>nx_array*ny_array){
|
||||
if(data) delete [] data;
|
||||
data = new double [nbinsx*nbinsy+1]; //one for under/overflow bin
|
||||
nx_array = nbinsx;
|
||||
ny_array = nbinsy;
|
||||
}
|
||||
nx=nbinsx;
|
||||
ny=nbinsy;
|
||||
nb=nx*ny;
|
||||
data[nb]=0;//set over flow to zero
|
||||
if(d){
|
||||
memcpy(data,d,nb*sizeof(double));
|
||||
SetMinMax(zmin,zmax);
|
||||
}
|
||||
}
|
||||
|
||||
void SlsQt2DHist::SetMinMax(double zmin,double zmax){
|
||||
/* if(zmin<zmax){ edited out to test*/
|
||||
if(zmax != -1){
|
||||
z_min=zmin;
|
||||
z_max=zmax;
|
||||
}else{
|
||||
z_mean_has_been_calculated = 1;
|
||||
z_min=data[0];
|
||||
z_mean=0;
|
||||
z_max=data[0];
|
||||
for(int i=0;i<nb;i++){
|
||||
if(data[i]<z_min) z_min=data[i];
|
||||
if(data[i]>z_max) z_max=data[i];
|
||||
z_mean+=data[i];
|
||||
}
|
||||
z_mean/=nb;
|
||||
if(z_min>0) z_min/=1.02; else z_min*=1.02;
|
||||
if(z_max>0) z_max*=1.02; else z_max/=1.02;
|
||||
}
|
||||
#if QWT_VERSION<0x060000
|
||||
;
|
||||
#else
|
||||
setInterval( Qt::ZAxis,QwtInterval(z_min,z_max));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
double SlsQt2DHist::GetMean(){
|
||||
if(!z_mean_has_been_calculated){
|
||||
z_mean_has_been_calculated = 1;
|
||||
z_mean=0;
|
||||
for(int i=0;i<nb;i++) z_mean+=data[i];
|
||||
z_mean/=nb;
|
||||
}
|
||||
|
||||
return z_mean;
|
||||
}
|
||||
|
||||
double SlsQt2DHist::SetMinimumToFirstGreaterThanZero(){
|
||||
z_min=fabs(z_max)+1;
|
||||
for(int i=0;i<nb;i++){
|
||||
if(data[i]>0 && data[i]<z_min) z_min=data[i];
|
||||
}
|
||||
#if QWT_VERSION<0x060000
|
||||
;
|
||||
#else
|
||||
setInterval( Qt::ZAxis,QwtInterval(z_min,z_max));
|
||||
#endif
|
||||
|
||||
return z_min;
|
||||
}
|
||||
|
||||
|
||||
|
294
slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx → slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cpp
Executable file → Normal file
294
slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx → slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cpp
Executable file → Normal file
@ -1,15 +1,9 @@
|
||||
#include "SlsQt2DPlot.h"
|
||||
// #include "ansi.h"
|
||||
|
||||
#include "ansi.h"
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <qlist.h>
|
||||
#include <qprinter.h>
|
||||
#include <qtoolbutton.h>
|
||||
|
||||
#if QT_VERSION >= 0x040000
|
||||
#include <qprintdialog.h>
|
||||
#endif
|
||||
#include <qwt_color_map.h>
|
||||
#include <qwt_plot_layout.h>
|
||||
#include <qwt_plot_panner.h>
|
||||
@ -19,141 +13,73 @@
|
||||
#include <qwt_scale_engine.h>
|
||||
#include <qwt_scale_widget.h>
|
||||
|
||||
|
||||
|
||||
#if QWT_VERSION >= 0x060100
|
||||
#define QwtLog10ScaleEngine QwtLogScaleEngine
|
||||
#endif
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
|
||||
isLog = 0;
|
||||
|
||||
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating);
|
||||
axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating);
|
||||
|
||||
d_spectrogram = new QwtPlotSpectrogram();
|
||||
|
||||
hist = new SlsQt2DHist();
|
||||
SetupZoom();
|
||||
SetupColorMap();
|
||||
|
||||
#if QWT_VERSION < 0x060000
|
||||
d_spectrogram->setData(*hist);
|
||||
#else
|
||||
d_spectrogram->setData(hist);
|
||||
#endif
|
||||
|
||||
d_spectrogram->attach(this);
|
||||
|
||||
plotLayout()->setAlignCanvasToScales(true);
|
||||
|
||||
FillTestPlot();
|
||||
Update();
|
||||
}
|
||||
|
||||
SlsQt2DPlot::~SlsQt2DPlot() = default;
|
||||
|
||||
SlsQt2DPlot::~SlsQt2DPlot() {
|
||||
if (d_spectrogram) {
|
||||
d_spectrogram->detach();
|
||||
//delete d_spectrogram;
|
||||
}
|
||||
if (hist) {
|
||||
delete hist;
|
||||
}
|
||||
if (colorMapLinearScale)
|
||||
delete colorMapLinearScale;
|
||||
if (colorMapLogScale)
|
||||
delete colorMapLogScale;
|
||||
|
||||
|
||||
if (zoomer)
|
||||
delete zoomer;
|
||||
if (panner)
|
||||
delete panner;
|
||||
#if QWT_VERSION<0x060000
|
||||
if (contourLevelsLinear)
|
||||
delete contourLevelsLinear;
|
||||
if (contourLevelsLog)
|
||||
delete contourLevelsLog;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetTitle(QString title) {
|
||||
setTitle(title);
|
||||
}
|
||||
void SlsQt2DPlot::SetTitle(QString title) { setTitle(title); }
|
||||
|
||||
void SlsQt2DPlot::SetXTitle(QString title) {
|
||||
setAxisTitle(QwtPlot::xBottom, title);
|
||||
setAxisTitle(QwtPlot::xBottom, title);
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetYTitle(QString title) {
|
||||
setAxisTitle(QwtPlot::yLeft, title);
|
||||
setAxisTitle(QwtPlot::yLeft, title);
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetZTitle(QString title) {
|
||||
setAxisTitle(QwtPlot::yRight, title);
|
||||
setAxisTitle(QwtPlot::yRight, title);
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetTitleFont(const QFont& f) {
|
||||
void SlsQt2DPlot::SetTitleFont(const QFont &f) {
|
||||
QwtText t("");
|
||||
t.setFont(f);
|
||||
t.setRenderFlags( Qt::AlignLeft | Qt::AlignVCenter);
|
||||
t.setRenderFlags(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
setTitle(t);
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetXFont(const QFont& f) {
|
||||
void SlsQt2DPlot::SetXFont(const QFont &f) {
|
||||
QwtText t("");
|
||||
t.setFont(f);
|
||||
setAxisTitle(QwtPlot::xBottom, t);
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetYFont(const QFont& f) {
|
||||
void SlsQt2DPlot::SetYFont(const QFont &f) {
|
||||
QwtText t("");
|
||||
t.setFont(f);
|
||||
setAxisTitle(QwtPlot::yLeft, t);
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetZFont(const QFont& f) {
|
||||
void SlsQt2DPlot::SetZFont(const QFont &f) {
|
||||
QwtText t("");
|
||||
t.setFont(f);
|
||||
setAxisTitle(QwtPlot::yRight, t);
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetupColorMap() {
|
||||
|
||||
colorMapLinearScale = myColourMap(0);
|
||||
#if QWT_VERSION < 0x060000
|
||||
d_spectrogram->setColorMap(*colorMapLinearScale);
|
||||
#else
|
||||
d_spectrogram->setColorMap(colorMapLinearScale);
|
||||
#endif
|
||||
|
||||
colorMapLogScale = myColourMap(1);
|
||||
#if QWT_VERSION < 0x060000
|
||||
contourLevelsLinear = new QwtValueList();
|
||||
for (double level = 0.5; level < 10.0; level += 1.0)
|
||||
(*contourLevelsLinear) += level;
|
||||
d_spectrogram->setContourLevels(*contourLevelsLinear);
|
||||
#else
|
||||
;
|
||||
|
||||
d_spectrogram->setColorMap(myColourMap(0));
|
||||
for (double level = 0.5; level < 10.0; level += 1.0)
|
||||
(contourLevelsLinear) += level;
|
||||
d_spectrogram->setContourLevels(contourLevelsLinear);
|
||||
#endif
|
||||
|
||||
//
|
||||
#if QWT_VERSION < 0x060000
|
||||
contourLevelsLog = new QwtValueList();
|
||||
for (double level = 0.5; level < 10.0; level += 1.0)
|
||||
(*contourLevelsLog) += (pow(10, 2 * level / 10.0) - 1) / 99.0 * 10;
|
||||
|
||||
#else
|
||||
;
|
||||
|
||||
for (double level = 0.5; level < 10.0; level += 1.0)
|
||||
(contourLevelsLog) += (pow(10, 2 * level / 10.0) - 1) / 99.0 * 10;
|
||||
#endif
|
||||
|
||||
// A color bar on the right axis
|
||||
rightAxis = axisWidget(QwtPlot::yRight);
|
||||
@ -166,14 +92,15 @@ void SlsQt2DPlot::SetupColorMap() {
|
||||
void SlsQt2DPlot::FillTestPlot(int mode) {
|
||||
static int nx = 50;
|
||||
static int ny = 50;
|
||||
static double *the_data = 0;
|
||||
if (the_data == 0)
|
||||
static double *the_data = nullptr;
|
||||
if (the_data == nullptr)
|
||||
the_data = new double[nx * ny];
|
||||
|
||||
double dmax = sqrt(pow(nx / 2.0 - 0.5, 2) + pow(ny / 2.0 - 0.5, 2));
|
||||
for (int i = 0; i < nx; i++) {
|
||||
for (int j = 0; j < ny; j++) {
|
||||
double d = sqrt(pow(nx / 2.0 - (i + 0.5), 2) + pow(ny / 2.0 - (j + 0.5), 2));
|
||||
double d = sqrt(pow(nx / 2.0 - (i + 0.5), 2) +
|
||||
pow(ny / 2.0 - (j + 0.5), 2));
|
||||
|
||||
if (mode % 3)
|
||||
the_data[i + j * nx] = 10 * d / dmax;
|
||||
@ -193,14 +120,9 @@ void SlsQt2DPlot::SetupZoom() {
|
||||
|
||||
zoomer = new SlsQt2DZoomer(canvas());
|
||||
zoomer->SetHist(hist);
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton);
|
||||
#else
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
|
||||
#endif
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton,
|
||||
Qt::ControlModifier);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
|
||||
|
||||
panner = new QwtPlotPanner(canvas());
|
||||
panner->setAxisEnabled(QwtPlot::yRight, false);
|
||||
panner->setMouseButton(Qt::MidButton);
|
||||
@ -217,37 +139,25 @@ void SlsQt2DPlot::SetupZoom() {
|
||||
zoomer->setTrackerPen(c);
|
||||
}
|
||||
|
||||
/*void SlsQt2DPlot::CompletelyUnZoom(){
|
||||
setAxisScale(QwtPlot::xBottom,hist->GetXMin(),hist->GetXMin()+(hist->GetXMax()-hist->GetXMin()));
|
||||
setAxisScale(QwtPlot::yLeft,hist->GetYMin(),hist->GetYMin()+(hist->GetYMax()-hist->GetYMin()));
|
||||
zoomer->setZoomBase();
|
||||
//replot();
|
||||
}*/
|
||||
|
||||
void SlsQt2DPlot::UnZoom(bool replot) {
|
||||
#if QWT_VERSION < 0x060000
|
||||
zoomer->setZoomBase(QwtDoubleRect(hist->GetXMin(), hist->GetYMin(), hist->GetXMax() - hist->GetXMin(), hist->GetYMax() - hist->GetYMin()));
|
||||
#else
|
||||
zoomer->setZoomBase(QRectF(hist->GetXMin(), hist->GetYMin(), hist->GetXMax() - hist->GetXMin(), hist->GetYMax() - hist->GetYMin()));
|
||||
#endif
|
||||
zoomer->setZoomBase(replot); //Call replot for the attached plot before initializing the zoomer with its scales.
|
||||
|
||||
zoomer->setZoomBase(QRectF(hist->GetXMin(), hist->GetYMin(),
|
||||
hist->GetXMax() - hist->GetXMin(),
|
||||
hist->GetYMax() - hist->GetYMin()));
|
||||
zoomer->setZoomBase(replot); // Call replot for the attached plot before
|
||||
// initializing the zoomer with its scales.
|
||||
// zoomer->zoom(0);
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetZoom(double xmin, double ymin, double x_width, double y_width) {
|
||||
|
||||
#if QWT_VERSION < 0x060000
|
||||
zoomer->setZoomBase(QwtDoubleRect(xmin, ymin, x_width, y_width));
|
||||
|
||||
#else
|
||||
void SlsQt2DPlot::SetZoom(double xmin, double ymin, double x_width,
|
||||
double y_width) {
|
||||
zoomer->setZoomBase(QRectF(xmin, ymin, x_width, y_width));
|
||||
#endif
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::DisableZoom(bool disable) {
|
||||
if (disableZoom != disable) {
|
||||
disableZoom = disable;
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
if (disable)
|
||||
std::cout << "Disabling zoom\n";
|
||||
@ -256,25 +166,23 @@ void SlsQt2DPlot::DisableZoom(bool disable) {
|
||||
#endif
|
||||
if (disable) {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton);
|
||||
#if QT_VERSION < 0x040000
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlButton);
|
||||
#else
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier);
|
||||
#endif
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1,
|
||||
Qt::NoButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
|
||||
Qt::NoButton, Qt::ControlModifier);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
|
||||
Qt::NoButton);
|
||||
}
|
||||
if (panner)
|
||||
panner->setMouseButton(Qt::NoButton);
|
||||
} else {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton);
|
||||
#if QT_VERSION < 0x040000
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton);
|
||||
#else
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
|
||||
#endif
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1,
|
||||
Qt::LeftButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
|
||||
Qt::RightButton, Qt::ControlModifier);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
|
||||
Qt::RightButton);
|
||||
}
|
||||
if (panner)
|
||||
panner->setMouseButton(Qt::MidButton);
|
||||
@ -282,7 +190,6 @@ void SlsQt2DPlot::DisableZoom(bool disable) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SlsQt2DPlot::SetZMinMax(double zmin, double zmax) {
|
||||
hist->SetMinMax(zmin, zmax);
|
||||
}
|
||||
@ -295,63 +202,40 @@ QwtLinearColorMap *SlsQt2DPlot::myColourMap(QVector<double> colourStops) {
|
||||
double g[] = {0.00, 0.81, 1.00, 0.20, 0.00};
|
||||
double b[] = {0.51, 1.00, 0.12, 0.00, 0.00};
|
||||
|
||||
QColor c1, c2, c;
|
||||
c1.setRgbF(r[0], g[0], b[0], 0);
|
||||
// QColor c1, c2, c;
|
||||
QColor c2, c;
|
||||
c2.setRgbF(r[ns - 1], g[ns - 1], b[ns - 1]);
|
||||
QwtLinearColorMap *copyMap = new QwtLinearColorMap(Qt::lightGray, c2);
|
||||
|
||||
for (int is = 0; is < ns - 1; is++) {
|
||||
c.setRgbF(r[is], g[is], b[is]);
|
||||
copyMap->addColorStop(colourStops.value(is), c);
|
||||
copyMap->addColorStop(colourStops[is], c);
|
||||
}
|
||||
|
||||
return copyMap;
|
||||
}
|
||||
|
||||
QwtLinearColorMap *SlsQt2DPlot::myColourMap(int log) {
|
||||
|
||||
int ns = 5;
|
||||
|
||||
QVector<double> cs1(0);
|
||||
QVector<double> lcs1(0);
|
||||
|
||||
cs1.append(0.);
|
||||
cs1.append(0.34);
|
||||
cs1.append(0.61);
|
||||
cs1.append(0.84);
|
||||
cs1.append(1.);
|
||||
QVector<double> cs{0.0, 0.34, 0.61 ,0.84, 1.0};
|
||||
if (log) {
|
||||
for (int is = 0; is < ns; is++) {
|
||||
lcs1.append((pow(10, 2 * cs1.value(is)) - 1) / 99.0);
|
||||
}
|
||||
return myColourMap(lcs1);
|
||||
for (int i = 0; i < cs.size(); ++i)
|
||||
cs[i] = (pow(10, 2 * cs[i]) - 1) / 99.0;
|
||||
}
|
||||
|
||||
return myColourMap(cs1);
|
||||
return myColourMap(cs);
|
||||
}
|
||||
|
||||
|
||||
void SlsQt2DPlot::Update() {
|
||||
#if QWT_VERSION < 0x060000
|
||||
rightAxis->setColorMap(d_spectrogram->data().range(), d_spectrogram->colorMap());
|
||||
#else
|
||||
if (isLog)
|
||||
hist->SetMinimumToFirstGreaterThanZero();
|
||||
|
||||
const QwtInterval zInterval = d_spectrogram->data()->interval(Qt::ZAxis);
|
||||
|
||||
rightAxis->setColorMap(zInterval, myColourMap(isLog));
|
||||
#endif
|
||||
|
||||
if (!zoomer->zoomRectIndex())
|
||||
UnZoom();
|
||||
#if QWT_VERSION < 0x060000
|
||||
setAxisScale(QwtPlot::yRight, d_spectrogram->data().range().minValue(),
|
||||
d_spectrogram->data().range().maxValue());
|
||||
#else
|
||||
//cprintf(MAGENTA, "zmin:%f zmax:%f\n", zInterval.minValue(), zInterval.maxValue());
|
||||
setAxisScale(QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue());
|
||||
plotLayout()->setAlignCanvasToScales(true);
|
||||
#endif
|
||||
replot();
|
||||
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetInterpolate(bool enable) {
|
||||
@ -364,86 +248,44 @@ void SlsQt2DPlot::SetContour(bool enable) {
|
||||
Update();
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetLogz(bool enable, bool isMin, bool isMax, double min, double max) {
|
||||
LogZ(enable);
|
||||
SetZRange(isMin, isMax, min, max);
|
||||
void SlsQt2DPlot::SetLogz(bool enable, bool isMin, bool isMax, double min,
|
||||
double max) {
|
||||
LogZ(enable);
|
||||
SetZRange(isMin, isMax, min, max);
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetZRange(bool isMin, bool isMax, double min, double max){
|
||||
if(isLog) {
|
||||
SetZMinimumToFirstGreaterThanZero();
|
||||
}
|
||||
void SlsQt2DPlot::SetZRange(bool isMin, bool isMax, double min, double max) {
|
||||
if (isLog) {
|
||||
SetZMinimumToFirstGreaterThanZero();
|
||||
}
|
||||
|
||||
// set zmin and zmax
|
||||
if (isMin || isMax) {
|
||||
double zmin = (isMin ? min : GetZMinimum());
|
||||
double zmax = (isMax ? max : GetZMaximum());
|
||||
SetZMinMax(zmin, zmax);
|
||||
}
|
||||
// set zmin and zmax
|
||||
if (isMin || isMax) {
|
||||
double zmin = (isMin ? min : GetZMinimum());
|
||||
double zmax = (isMax ? max : GetZMaximum());
|
||||
SetZMinMax(zmin, zmax);
|
||||
}
|
||||
|
||||
Update();
|
||||
Update();
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::LogZ(bool on) {
|
||||
if (on) {
|
||||
isLog = 1;
|
||||
//if(hist->GetMinimum()<=0) hist->SetMinimumToFirstGreaterThanZero();
|
||||
#if QWT_VERSION < 0x060000
|
||||
d_spectrogram->setColorMap(*colorMapLogScale);
|
||||
#else
|
||||
d_spectrogram->setColorMap(myColourMap(isLog));
|
||||
#endif
|
||||
setAxisScaleEngine(QwtPlot::yRight, new QwtLog10ScaleEngine);
|
||||
#if QWT_VERSION < 0x060000
|
||||
d_spectrogram->setContourLevels(*contourLevelsLog);
|
||||
#else
|
||||
setAxisScaleEngine(QwtPlot::yRight, new QwtLogScaleEngine);
|
||||
d_spectrogram->setContourLevels(contourLevelsLog);
|
||||
#endif
|
||||
} else {
|
||||
isLog = 0;
|
||||
|
||||
#if QWT_VERSION < 0x060000
|
||||
d_spectrogram->setColorMap(*colorMapLinearScale);
|
||||
#else
|
||||
d_spectrogram->setColorMap(myColourMap(isLog));
|
||||
#endif
|
||||
|
||||
setAxisScaleEngine(QwtPlot::yRight, new QwtLinearScaleEngine);
|
||||
|
||||
#if QWT_VERSION < 0x060000
|
||||
d_spectrogram->setContourLevels(*contourLevelsLinear);
|
||||
#else
|
||||
d_spectrogram->setContourLevels(contourLevelsLinear);
|
||||
#endif
|
||||
}
|
||||
Update();
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::showSpectrogram(bool on) {
|
||||
// static int io=0;
|
||||
// FillTestPlot(io++);
|
||||
d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, on);
|
||||
d_spectrogram->setDefaultContourPen(on ? QPen() : QPen(Qt::NoPen));
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void SlsQt2DPlot::printPlot(){
|
||||
QPrinter printer;
|
||||
printer.setOrientation(QPrinter::Landscape);
|
||||
#if QT_VERSION < 0x040000
|
||||
printer.setColorMode(QPrinter::Color);
|
||||
printer.setOutputFileName("spectrogram.ps");
|
||||
if (printer.setup())
|
||||
#else
|
||||
printer.setOutputFileName("spectrogram.pdf");
|
||||
QPrintDialog dialog(&printer);
|
||||
if ( dialog.exec() )
|
||||
#endif
|
||||
{
|
||||
print(printer);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
101
slsDetectorGui/src/qCloneWidget.cpp
Executable file → Normal file
101
slsDetectorGui/src/qCloneWidget.cpp
Executable file → Normal file
@ -1,7 +1,7 @@
|
||||
#include "qCloneWidget.h"
|
||||
#include "qDefs.h"
|
||||
#include "SlsQt1DPlot.h"
|
||||
#include "SlsQt2DPlot.h"
|
||||
#include "qDefs.h"
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QFileDialog>
|
||||
@ -11,35 +11,43 @@
|
||||
|
||||
int qCloneWidget::NumClones{0};
|
||||
|
||||
qCloneWidget::qCloneWidget(QWidget *parent, SlsQt1DPlot* p1, SlsQt2DPlot* p2, SlsQt1DPlot *gp1, SlsQt2DPlot* gp,
|
||||
QString title, QString fPath, QString fName, int64_t aIndex,
|
||||
bool displayStats, QString min, QString max, QString sum):
|
||||
QMainWindow(parent), plot1d(p1), plot2d(p2), gainplot1d(gp1), gainplot2d(gp), filePath(fPath), fileName(fName), acqIndex(aIndex) {
|
||||
setupUi(this);
|
||||
id = qCloneWidget::NumClones++;
|
||||
qCloneWidget::qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2,
|
||||
SlsQt1DPlot *gp1, SlsQt2DPlot *gp, QString title,
|
||||
QString fPath, QString fName, int64_t aIndex,
|
||||
bool displayStats, QString min, QString max,
|
||||
QString sum, bool completeImage)
|
||||
: QMainWindow(parent), plot1d(p1), plot2d(p2), gainplot1d(gp1),
|
||||
gainplot2d(gp), filePath(fPath), fileName(fName), acqIndex(aIndex) {
|
||||
setupUi(this);
|
||||
id = qCloneWidget::NumClones++;
|
||||
SetupWidgetWindow(title);
|
||||
DisplayStats(displayStats, min, max, sum);
|
||||
lblCompleteImage->hide();
|
||||
lblInCompleteImage->hide();
|
||||
if (completeImage) {
|
||||
lblCompleteImage->show();
|
||||
} else {
|
||||
lblInCompleteImage->show();
|
||||
}
|
||||
}
|
||||
|
||||
qCloneWidget::~qCloneWidget() {
|
||||
if (plot1d)
|
||||
delete plot1d;
|
||||
if (plot2d)
|
||||
delete plot2d;
|
||||
if (gainplot1d)
|
||||
delete gainplot1d;
|
||||
if (gainplot2d)
|
||||
delete gainplot2d;
|
||||
|
||||
delete plot1d;
|
||||
delete plot2d;
|
||||
delete gainplot1d;
|
||||
delete gainplot2d;
|
||||
}
|
||||
|
||||
void qCloneWidget::SetupWidgetWindow(QString title) {
|
||||
|
||||
std::string winTitle = std::string("Snapshot:") + std::to_string(id) + std::string(" - ") + NowTime();
|
||||
std::string winTitle = std::string("Snapshot:") + std::to_string(id) +
|
||||
std::string(" - ") + sls::Logger::Timestamp();
|
||||
setWindowTitle(QString(winTitle.c_str()));
|
||||
|
||||
|
||||
boxPlot->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
boxPlot->setTitle(title);
|
||||
|
||||
|
||||
// 1d
|
||||
if (plot1d != nullptr) {
|
||||
if (gainplot1d == nullptr) {
|
||||
@ -49,7 +57,7 @@ void qCloneWidget::SetupWidgetWindow(QString title) {
|
||||
plotLayout->addWidget(plot1d, 0, 0, ratio, ratio);
|
||||
plotLayout->addWidget(gainplot1d, ratio, 0, 1, ratio, Qt::AlignTop);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 2d
|
||||
else {
|
||||
if (gainplot2d == nullptr) {
|
||||
@ -57,7 +65,8 @@ void qCloneWidget::SetupWidgetWindow(QString title) {
|
||||
} else {
|
||||
int ratio = qDefs::DATA_GAIN_PLOT_RATIO - 1;
|
||||
plotLayout->addWidget(plot2d, 0, 0, ratio, ratio);
|
||||
plotLayout->addWidget(gainplot2d, 0, ratio, 1, 1, Qt::AlignRight | Qt::AlignTop);
|
||||
plotLayout->addWidget(gainplot2d, 0, ratio, 1, 1,
|
||||
Qt::AlignRight | Qt::AlignTop);
|
||||
}
|
||||
}
|
||||
connect(actionSaveClone, SIGNAL(triggered()), this, SLOT(SavePlot()));
|
||||
@ -65,15 +74,19 @@ void qCloneWidget::SetupWidgetWindow(QString title) {
|
||||
if (gainplot1d != nullptr) {
|
||||
gainplot1d->setMinimumHeight(qDefs::MIN_HEIGHT_GAIN_PLOT_1D);
|
||||
gainplot1d->setFixedWidth(plot1d->width());
|
||||
// gainplot1d->setFixedHeight(plot1d->height() / qDefs::DATA_GAIN_PLOT_RATIO - 1);
|
||||
// gainplot1d->setFixedHeight(plot1d->height() /
|
||||
// qDefs::DATA_GAIN_PLOT_RATIO - 1);
|
||||
}
|
||||
if (gainplot2d != nullptr) {
|
||||
gainplot2d->setFixedWidth(plot2d->width() / qDefs::DATA_GAIN_PLOT_RATIO);
|
||||
gainplot2d->setFixedHeight(plot2d->height() / qDefs::DATA_GAIN_PLOT_RATIO);
|
||||
gainplot2d->setFixedWidth(plot2d->width() /
|
||||
qDefs::DATA_GAIN_PLOT_RATIO);
|
||||
gainplot2d->setFixedHeight(plot2d->height() /
|
||||
qDefs::DATA_GAIN_PLOT_RATIO);
|
||||
}
|
||||
}
|
||||
|
||||
void qCloneWidget::DisplayStats(bool enable, QString min, QString max, QString sum) {
|
||||
void qCloneWidget::DisplayStats(bool enable, QString min, QString max,
|
||||
QString sum) {
|
||||
if (enable) {
|
||||
lblMinDisp->setText(QString("%1").arg(min));
|
||||
lblMaxDisp->setText(QString("%1").arg(max));
|
||||
@ -87,22 +100,33 @@ void qCloneWidget::DisplayStats(bool enable, QString min, QString max, QString s
|
||||
void qCloneWidget::SavePlot() {
|
||||
char cID[10];
|
||||
sprintf(cID, "%d", id);
|
||||
//title
|
||||
QString fName = filePath + QString('/') + fileName + QString("_clone") + QString("%1").arg(id) + QString("_acq") + QString("%1").arg(acqIndex) + QString(".png");
|
||||
FILE_LOG(logINFO) << "Saving Clone:" << fName.toAscii().constData();
|
||||
//save
|
||||
QImage img(centralwidget->size().width(), centralwidget->size().height(), QImage::Format_RGB32);
|
||||
// title
|
||||
QString fName = filePath + QString('/') + fileName + QString("_clone") +
|
||||
QString("%1").arg(id) + QString("_acq") +
|
||||
QString("%1").arg(acqIndex) + QString(".png");
|
||||
LOG(logINFO) << "Saving Clone:" << fName.toAscii().constData();
|
||||
// save
|
||||
QImage img(centralwidget->size().width(), centralwidget->size().height(),
|
||||
QImage::Format_RGB32);
|
||||
QPainter painter(&img);
|
||||
centralwidget->render(&painter);
|
||||
|
||||
fName = QFileDialog::getSaveFileName(this, tr("Save Snapshot "), fName, tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"), 0, QFileDialog::ShowDirsOnly);
|
||||
fName = QFileDialog::getSaveFileName(
|
||||
this, tr("Save Snapshot "), fName,
|
||||
tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"), nullptr,
|
||||
QFileDialog::ShowDirsOnly);
|
||||
if (!fName.isEmpty()) {
|
||||
if ((img.save(fName))) {
|
||||
qDefs::Message(qDefs::INFORMATION, "The SnapShot has been successfully saved", "qCloneWidget::SavePlot");
|
||||
FILE_LOG(logINFO) << "The SnapShot has been successfully saved";
|
||||
qDefs::Message(qDefs::INFORMATION,
|
||||
"The SnapShot has been successfully saved",
|
||||
"qCloneWidget::SavePlot");
|
||||
LOG(logINFO) << "The SnapShot has been successfully saved";
|
||||
} else {
|
||||
qDefs::Message(qDefs::WARNING, "Attempt to save snapshot failed.\n Formats: .png, .jpg, .xpm.", "qCloneWidget::SavePlot");
|
||||
FILE_LOG(logWARNING) << "Attempt to save snapshot failed";
|
||||
qDefs::Message(
|
||||
qDefs::WARNING,
|
||||
"Attempt to save snapshot failed.\n Formats: .png, .jpg, .xpm.",
|
||||
"qCloneWidget::SavePlot");
|
||||
LOG(logWARNING) << "Attempt to save snapshot failed";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -110,11 +134,14 @@ void qCloneWidget::SavePlot() {
|
||||
void qCloneWidget::resizeEvent(QResizeEvent *event) {
|
||||
if (gainplot1d != nullptr) {
|
||||
gainplot1d->setFixedWidth(plot1d->width());
|
||||
gainplot1d->setFixedHeight(plot1d->height() / qDefs::DATA_GAIN_PLOT_RATIO);
|
||||
gainplot1d->setFixedHeight(plot1d->height() /
|
||||
qDefs::DATA_GAIN_PLOT_RATIO);
|
||||
}
|
||||
if (gainplot2d != nullptr) {
|
||||
gainplot2d->setFixedWidth(plot2d->width() / qDefs::DATA_GAIN_PLOT_RATIO);
|
||||
gainplot2d->setFixedHeight(plot2d->height() / qDefs::DATA_GAIN_PLOT_RATIO);
|
||||
gainplot2d->setFixedWidth(plot2d->width() /
|
||||
qDefs::DATA_GAIN_PLOT_RATIO);
|
||||
gainplot2d->setFixedHeight(plot2d->height() /
|
||||
qDefs::DATA_GAIN_PLOT_RATIO);
|
||||
}
|
||||
event->accept();
|
||||
}
|
117
slsDetectorGui/src/qDacWidget.cpp
Executable file → Normal file
117
slsDetectorGui/src/qDacWidget.cpp
Executable file → Normal file
@ -1,90 +1,93 @@
|
||||
#include "qDacWidget.h"
|
||||
#include "qDefs.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
qDacWidget::qDacWidget(QWidget *parent, sls::Detector *detector, bool d, std::string n, slsDetectorDefs::dacIndex i) :
|
||||
QWidget(parent), det(detector), isDac(d), index(i){
|
||||
setupUi(this);
|
||||
SetupWidgetWindow(n);
|
||||
qDacWidget::qDacWidget(QWidget *parent, sls::Detector *detector, bool d,
|
||||
std::string n, slsDetectorDefs::dacIndex i)
|
||||
: QWidget(parent), det(detector), isDac(d), index(i) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow(n);
|
||||
}
|
||||
|
||||
qDacWidget::~qDacWidget() {}
|
||||
|
||||
void qDacWidget::SetupWidgetWindow(std::string name) {
|
||||
lblDac->setText(name.c_str());
|
||||
if (isDac) {
|
||||
spinDac->setDecimals(0);
|
||||
} else {
|
||||
spinDac->setSuffix(0x00b0 + QString("C"));
|
||||
spinDac->setReadOnly(true);
|
||||
lblDacmV->setMinimumWidth(0);
|
||||
lblDacmV->setMaximumWidth(0);
|
||||
}
|
||||
Initialization();
|
||||
Refresh();
|
||||
lblDac->setText(name.c_str());
|
||||
if (isDac) {
|
||||
spinDac->setDecimals(0);
|
||||
} else {
|
||||
spinDac->setSuffix(0x00b0 + QString("C"));
|
||||
spinDac->setReadOnly(true);
|
||||
lblDacmV->setMinimumWidth(0);
|
||||
lblDacmV->setMaximumWidth(0);
|
||||
}
|
||||
Initialization();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
||||
void qDacWidget::Initialization() {
|
||||
if (isDac) {
|
||||
connect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
|
||||
}
|
||||
if (isDac) {
|
||||
connect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
|
||||
}
|
||||
}
|
||||
|
||||
void qDacWidget::SetDetectorIndex(int id) {
|
||||
detectorIndex = id;
|
||||
Refresh();
|
||||
detectorIndex = id;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void qDacWidget::GetDac() {
|
||||
FILE_LOG(logDEBUG) << "Getting Dac " << index;
|
||||
LOG(logDEBUG) << "Getting Dac " << index;
|
||||
|
||||
disconnect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
|
||||
try {
|
||||
// dac units
|
||||
auto retval = det->getDAC(index, 0, {detectorIndex}).squash(-1);
|
||||
spinDac->setValue(retval);
|
||||
// mv
|
||||
retval = det->getDAC(index, 1, {detectorIndex}).squash(-1);
|
||||
lblDacmV->setText(QString("%1mV").arg(retval -10));
|
||||
} CATCH_DISPLAY(std::string("Could not get dac ") + std::to_string(index), "qDacWidget::GetDac")
|
||||
disconnect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
|
||||
try {
|
||||
// dac units
|
||||
auto retval = det->getDAC(index, 0, {detectorIndex}).squash(-1);
|
||||
spinDac->setValue(retval);
|
||||
// mv
|
||||
retval = det->getDAC(index, 1, {detectorIndex}).squash(-1);
|
||||
lblDacmV->setText(QString("%1mV").arg(retval - 10));
|
||||
}
|
||||
CATCH_DISPLAY(std::string("Could not get dac ") + std::to_string(index),
|
||||
"qDacWidget::GetDac")
|
||||
|
||||
connect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
|
||||
connect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
|
||||
}
|
||||
|
||||
|
||||
void qDacWidget::SetDac() {
|
||||
int val = (int)spinDac->value();
|
||||
FILE_LOG(logINFO) << "Setting dac:" << lblDac->text().toAscii().data() << " : " << val;
|
||||
int val = (int)spinDac->value();
|
||||
LOG(logINFO) << "Setting dac:" << lblDac->text().toAscii().data()
|
||||
<< " : " << val;
|
||||
|
||||
try {
|
||||
det->setDAC(index, val, 0, {detectorIndex});
|
||||
} CATCH_DISPLAY (std::string("Could not set dac ") + std::to_string(index), "qDacWidget::SetDac")
|
||||
|
||||
// update mV anyway
|
||||
try {
|
||||
det->setDAC(index, val, 0, {detectorIndex});
|
||||
}
|
||||
CATCH_DISPLAY(std::string("Could not set dac ") + std::to_string(index),
|
||||
"qDacWidget::SetDac")
|
||||
|
||||
// update mV anyway
|
||||
GetDac();
|
||||
}
|
||||
|
||||
void qDacWidget::GetAdc() {
|
||||
FILE_LOG(logDEBUG) << "Getting ADC " << index;
|
||||
|
||||
try {
|
||||
auto retval = det->getTemperature(index, {detectorIndex}).squash(-1);
|
||||
if (retval == -1 && detectorIndex == -1) {
|
||||
spinDac->setValue(-1);
|
||||
} else {
|
||||
spinDac->setValue(retval);
|
||||
}
|
||||
} CATCH_DISPLAY (std::string("Could not get adc ") + std::to_string(index), "qDacWidget::GetAdc")
|
||||
LOG(logDEBUG) << "Getting ADC " << index;
|
||||
|
||||
try {
|
||||
auto retval = det->getTemperature(index, {detectorIndex}).squash(-1);
|
||||
if (retval == -1 && detectorIndex == -1) {
|
||||
spinDac->setValue(-1);
|
||||
} else {
|
||||
spinDac->setValue(retval);
|
||||
}
|
||||
}
|
||||
CATCH_DISPLAY(std::string("Could not get adc ") + std::to_string(index),
|
||||
"qDacWidget::GetAdc")
|
||||
}
|
||||
|
||||
void qDacWidget::Refresh() {
|
||||
if (isDac) {
|
||||
GetDac();
|
||||
} else {
|
||||
GetAdc();
|
||||
}
|
||||
if (isDac) {
|
||||
GetDac();
|
||||
} else {
|
||||
GetAdc();
|
||||
}
|
||||
}
|
||||
|
||||
|
281
slsDetectorGui/src/qDetectorMain.cpp
Executable file → Normal file
281
slsDetectorGui/src/qDetectorMain.cpp
Executable file → Normal file
@ -1,34 +1,32 @@
|
||||
#include "qDetectorMain.h"
|
||||
#include "qDefs.h"
|
||||
#include "qDrawPlot.h"
|
||||
#include "qTabMeasurement.h"
|
||||
#include "qTabDataOutput.h"
|
||||
#include "qTabPlot.h"
|
||||
#include "qTabAdvanced.h"
|
||||
#include "qTabSettings.h"
|
||||
#include "qTabDataOutput.h"
|
||||
#include "qTabDebugging.h"
|
||||
#include "qTabDeveloper.h"
|
||||
#include "qTabMeasurement.h"
|
||||
#include "qTabMessages.h"
|
||||
#include "qTabPlot.h"
|
||||
#include "qTabSettings.h"
|
||||
|
||||
#include "versionAPI.h"
|
||||
#include "ToString.h"
|
||||
#include "versionAPI.h"
|
||||
|
||||
#include <QResizeEvent>
|
||||
#include <QScrollArea>
|
||||
#include <QFileDialog>
|
||||
#include <QPlastiqueStyle>
|
||||
#include <QResizeEvent>
|
||||
#include <QScrollArea>
|
||||
#include <QSizePolicy>
|
||||
|
||||
#include <iostream>
|
||||
#include <getopt.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <getopt.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
// options
|
||||
std::string fname = "";
|
||||
std::string fname;
|
||||
bool isDeveloper = false;
|
||||
int64_t tempval = 0;
|
||||
int multiId = 0;
|
||||
@ -38,12 +36,12 @@ int main(int argc, char **argv) {
|
||||
// These options set a flag.
|
||||
//{"verbose", no_argument, &verbose_flag, 1},
|
||||
// These options don’t set a flag. We distinguish them by their indices.
|
||||
{"developer", no_argument, 0, 'd'},
|
||||
{"config", required_argument, 0, 'f'},
|
||||
{"id", required_argument, 0, 'i'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{0, 0, 0, 0}};
|
||||
{"developer", no_argument, nullptr, 'd'},
|
||||
{"config", required_argument, nullptr, 'f'},
|
||||
{"id", required_argument, nullptr, 'i'},
|
||||
{"version", no_argument, nullptr, 'v'},
|
||||
{"help", no_argument, nullptr, 'h'},
|
||||
{nullptr, 0, nullptr, 0}};
|
||||
|
||||
// getopt_long stores the option index here
|
||||
optind = 1;
|
||||
@ -59,7 +57,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
case 'f':
|
||||
fname = optarg;
|
||||
FILE_LOG(logDEBUG)
|
||||
LOG(logDEBUG)
|
||||
<< long_options[option_index].name << " " << optarg;
|
||||
break;
|
||||
|
||||
@ -73,7 +71,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
case 'v':
|
||||
tempval = APIGUI;
|
||||
FILE_LOG(logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x"
|
||||
LOG(logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x"
|
||||
<< std::hex << tempval << ")";
|
||||
return 0;
|
||||
|
||||
@ -89,15 +87,13 @@ int main(int argc, char **argv) {
|
||||
"i. Default: 0. Required \n" +
|
||||
"\t only when more than one multi "
|
||||
"detector object is needed.\n\n";
|
||||
FILE_LOG(logERROR) << help_message;
|
||||
LOG(logERROR) << help_message;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QApplication app(argc, argv);
|
||||
app.setStyle(new QPlastiqueStyle);
|
||||
//app.setWindowIcon(QIcon(":/icons/images/mountain.png"));
|
||||
app.setStyle(new QPlastiqueStyle); //style is deleted by QApplication
|
||||
try {
|
||||
qDetectorMain det(multiId, fname, isDeveloper);
|
||||
det.show();
|
||||
@ -109,8 +105,8 @@ int main(int argc, char **argv) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
qDetectorMain::qDetectorMain(int multiId, std::string fname, bool isDevel)
|
||||
: QMainWindow(0), detType(slsDetectorDefs::GENERIC), isDeveloper(isDevel),
|
||||
qDetectorMain::qDetectorMain(int multiId, const std::string& fname, bool isDevel)
|
||||
: QMainWindow(nullptr), detType(slsDetectorDefs::GENERIC), isDeveloper(isDevel),
|
||||
heightPlotWindow(0), heightCentralWidget(0) {
|
||||
|
||||
setupUi(this);
|
||||
@ -118,63 +114,66 @@ qDetectorMain::qDetectorMain(int multiId, std::string fname, bool isDevel)
|
||||
SetUpWidgetWindow();
|
||||
}
|
||||
|
||||
qDetectorMain::~qDetectorMain() {}
|
||||
qDetectorMain::~qDetectorMain(){
|
||||
disconnect(tabs, SIGNAL(currentChanged(int)), this,
|
||||
SLOT(Refresh(int)));
|
||||
}
|
||||
|
||||
void qDetectorMain::SetUpWidgetWindow() {
|
||||
setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
|
||||
// plot setup
|
||||
plot = sls::make_unique<qDrawPlot>(dockWidgetPlot, det.get());
|
||||
FILE_LOG(logDEBUG) << "DockPlot ready";
|
||||
dockWidgetPlot->setWidget(plot.get());
|
||||
plot = new qDrawPlot(dockWidgetPlot, det.get());
|
||||
LOG(logDEBUG) << "DockPlot ready";
|
||||
dockWidgetPlot->setWidget(plot);
|
||||
|
||||
// tabs setup
|
||||
tabs = sls::make_unique<MyTabWidget>(this);
|
||||
layoutTabs->addWidget(tabs.get());
|
||||
tabs = new MyTabWidget(this);
|
||||
layoutTabs->addWidget(tabs);
|
||||
|
||||
// creating all the other tab widgets
|
||||
tabMeasurement = sls::make_unique<qTabMeasurement>(this, det.get(), plot.get());
|
||||
tabDataOutput = sls::make_unique<qTabDataOutput>(this, det.get());
|
||||
tabPlot = sls::make_unique<qTabPlot>(this, det.get(), plot.get());
|
||||
tabSettings = sls::make_unique<qTabSettings>(this, det.get());
|
||||
tabAdvanced = sls::make_unique<qTabAdvanced>(this, det.get(), plot.get());
|
||||
tabDebugging = sls::make_unique<qTabDebugging>(this, det.get());
|
||||
tabDeveloper = sls::make_unique<qTabDeveloper>(this, det.get());
|
||||
tabMeasurement =
|
||||
new qTabMeasurement(this, det.get(), plot);
|
||||
tabDataOutput = new qTabDataOutput(this, det.get());
|
||||
tabPlot = new qTabPlot(this, det.get(), plot);
|
||||
tabSettings = new qTabSettings(this, det.get());
|
||||
tabAdvanced = new qTabAdvanced(this, det.get(), plot);
|
||||
tabDebugging = new qTabDebugging(this, det.get());
|
||||
tabDeveloper = new qTabDeveloper(this, det.get());
|
||||
|
||||
// creating the scroll area widgets for the tabs
|
||||
QScrollArea *scroll[NumberOfTabs];
|
||||
for (int i = 0; i < NumberOfTabs; ++i) {
|
||||
scroll[i] = new QScrollArea;
|
||||
scroll[i] = sls::make_unique<QScrollArea>();
|
||||
scroll[i]->setFrameShape(QFrame::NoFrame);
|
||||
}
|
||||
// setting the tab widgets to the scrollareas
|
||||
scroll[MEASUREMENT]->setWidget(tabMeasurement.get());
|
||||
scroll[DATAOUTPUT]->setWidget(tabDataOutput.get());
|
||||
scroll[PLOT]->setWidget(tabPlot.get());
|
||||
scroll[SETTINGS]->setWidget(tabSettings.get());
|
||||
scroll[ADVANCED]->setWidget(tabAdvanced.get());
|
||||
scroll[DEBUGGING]->setWidget(tabDebugging.get());
|
||||
scroll[DEVELOPER]->setWidget(tabDeveloper.get());
|
||||
scroll[MEASUREMENT]->setWidget(tabMeasurement);
|
||||
scroll[DATAOUTPUT]->setWidget(tabDataOutput);
|
||||
scroll[PLOT]->setWidget(tabPlot);
|
||||
scroll[SETTINGS]->setWidget(tabSettings);
|
||||
scroll[ADVANCED]->setWidget(tabAdvanced);
|
||||
scroll[DEBUGGING]->setWidget(tabDebugging);
|
||||
scroll[DEVELOPER]->setWidget(tabDeveloper);
|
||||
// inserting all the tabs
|
||||
tabs->insertTab(MEASUREMENT, scroll[MEASUREMENT], "Measurement");
|
||||
tabs->insertTab(DATAOUTPUT, scroll[DATAOUTPUT], "Data Output");
|
||||
tabs->insertTab(PLOT, scroll[PLOT], "Plot");
|
||||
tabs->insertTab(SETTINGS, scroll[SETTINGS], "Settings");
|
||||
tabs->insertTab(ADVANCED, scroll[ADVANCED], "Advanced");
|
||||
tabs->insertTab(DEBUGGING, scroll[DEBUGGING], "Debugging");
|
||||
tabs->insertTab(DEVELOPER, scroll[DEVELOPER], "Developer");
|
||||
tabs->insertTab(MEASUREMENT, scroll[MEASUREMENT].get(), "Measurement");
|
||||
tabs->insertTab(DATAOUTPUT, scroll[DATAOUTPUT].get(), "Data Output");
|
||||
tabs->insertTab(PLOT, scroll[PLOT].get(), "Plot");
|
||||
tabs->insertTab(SETTINGS, scroll[SETTINGS].get(), "Settings");
|
||||
tabs->insertTab(ADVANCED, scroll[ADVANCED].get(), "Advanced");
|
||||
tabs->insertTab(DEBUGGING, scroll[DEBUGGING].get(), "Debugging");
|
||||
tabs->insertTab(DEVELOPER, scroll[DEVELOPER].get(), "Developer");
|
||||
// no scroll buttons this way
|
||||
tabs->insertTab(MESSAGES, tabMessages.get(), "Terminal");
|
||||
tabs->insertTab(MESSAGES, tabMessages, "Terminal");
|
||||
|
||||
// swap tabs so that messages is last tab
|
||||
tabs->tabBar()->moveTab(tabs->indexOf(tabMeasurement.get()), MEASUREMENT);
|
||||
tabs->tabBar()->moveTab(tabs->indexOf(tabSettings.get()), SETTINGS);
|
||||
tabs->tabBar()->moveTab(tabs->indexOf(tabDataOutput.get()), DATAOUTPUT);
|
||||
tabs->tabBar()->moveTab(tabs->indexOf(tabPlot.get()), PLOT);
|
||||
tabs->tabBar()->moveTab(tabs->indexOf(tabAdvanced.get()), ADVANCED);
|
||||
tabs->tabBar()->moveTab(tabs->indexOf(tabDebugging.get()), DEBUGGING);
|
||||
tabs->tabBar()->moveTab(tabs->indexOf(tabDeveloper.get()), DEVELOPER);
|
||||
tabs->tabBar()->moveTab(tabs->indexOf(tabMessages.get()), MESSAGES);
|
||||
tabs->tabBar()->moveTab(tabs->indexOf(tabMeasurement), MEASUREMENT);
|
||||
tabs->tabBar()->moveTab(tabs->indexOf(tabSettings), SETTINGS);
|
||||
tabs->tabBar()->moveTab(tabs->indexOf(tabDataOutput), DATAOUTPUT);
|
||||
tabs->tabBar()->moveTab(tabs->indexOf(tabPlot), PLOT);
|
||||
tabs->tabBar()->moveTab(tabs->indexOf(tabAdvanced), ADVANCED);
|
||||
tabs->tabBar()->moveTab(tabs->indexOf(tabDebugging), DEBUGGING);
|
||||
tabs->tabBar()->moveTab(tabs->indexOf(tabDeveloper), DEVELOPER);
|
||||
tabs->tabBar()->moveTab(tabs->indexOf(tabMessages), MESSAGES);
|
||||
tabs->setCurrentIndex(MEASUREMENT);
|
||||
|
||||
// other tab properties
|
||||
@ -182,12 +181,11 @@ void qDetectorMain::SetUpWidgetWindow() {
|
||||
defaultTabColor = tabs->tabBar()->tabTextColor(DATAOUTPUT);
|
||||
// Set the current tab(measurement) to blue as it is the current one
|
||||
tabs->tabBar()->setTabTextColor(0, QColor(0, 0, 200, 255));
|
||||
// increase the width so it uses all the empty space for the tab titles
|
||||
tabs->tabBar()->setFixedWidth(width() + 61);
|
||||
tabs->tabBar()->setExpanding(true);
|
||||
|
||||
// mode setup - to set up the tabs initially as disabled, not in form so
|
||||
// done here
|
||||
FILE_LOG(logINFO)
|
||||
LOG(logINFO)
|
||||
<< "Dockable Mode: 0, Debug Mode: 0, Expert Mode: 0, Developer Mode: "
|
||||
<< isDeveloper;
|
||||
tabs->setTabEnabled(DEBUGGING, false);
|
||||
@ -208,20 +206,21 @@ void qDetectorMain::SetUpWidgetWindow() {
|
||||
Initialization();
|
||||
}
|
||||
|
||||
void qDetectorMain::SetUpDetector(const std::string fName, int multiID) {
|
||||
void qDetectorMain::SetUpDetector(const std::string& config_file, int multiID) {
|
||||
|
||||
// instantiate detector and set window title
|
||||
det = sls::make_unique<sls::Detector>(multiID);
|
||||
|
||||
// create messages tab to capture config file loading logs
|
||||
tabMessages = sls::make_unique<qTabMessages>(this);
|
||||
tabMessages = new qTabMessages(this);
|
||||
|
||||
// loads the config file at startup
|
||||
if (!fName.empty())
|
||||
LoadConfigFile(fName);
|
||||
if (!config_file.empty())
|
||||
LoadConfigFile(config_file);
|
||||
|
||||
// validate detector type (for GUI) and update menu
|
||||
detType = det->getDetectorType().tsquash("Different detector type for all modules.");
|
||||
detType = det->getDetectorType().tsquash(
|
||||
"Different detector type for all modules.");
|
||||
actionLoadTrimbits->setEnabled(false);
|
||||
switch (detType) {
|
||||
case slsDetectorDefs::EIGER:
|
||||
@ -232,64 +231,75 @@ void qDetectorMain::SetUpDetector(const std::string fName, int multiID) {
|
||||
case slsDetectorDefs::MOENCH:
|
||||
case slsDetectorDefs::MYTHEN3:
|
||||
case slsDetectorDefs::GOTTHARD2:
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
std::ostringstream os;
|
||||
os << det->getHostname() << " has " <<
|
||||
sls::ToString(det->getDetectorType().squash()) << " detector type (" <<
|
||||
std::to_string(detType) << "). Exiting GUI.";
|
||||
os << det->getHostname() << " has "
|
||||
<< sls::ToString(det->getDetectorType().squash())
|
||||
<< " detector type (" << std::to_string(detType)
|
||||
<< "). Exiting GUI.";
|
||||
std::string errorMess = os.str();
|
||||
throw sls::RuntimeError(errorMess.c_str());
|
||||
}
|
||||
std::ostringstream os;
|
||||
os << "SLS Detector GUI : " << sls::ToString(det->getDetectorType().squash())
|
||||
<< " - " << det->getHostname();
|
||||
os << "SLS Detector GUI : "
|
||||
<< sls::ToString(det->getDetectorType().squash()) << " - "
|
||||
<< det->getHostname();
|
||||
std::string title = os.str();
|
||||
FILE_LOG(logINFO) << title;
|
||||
LOG(logINFO) << title;
|
||||
setWindowTitle(QString(title.c_str()));
|
||||
}
|
||||
|
||||
void qDetectorMain::Initialization() {
|
||||
// Dockable Plot
|
||||
connect(dockWidgetPlot, SIGNAL(topLevelChanged(bool)), this, SLOT(ResizeMainWindow(bool)));
|
||||
connect(dockWidgetPlot, SIGNAL(topLevelChanged(bool)), this,
|
||||
SLOT(ResizeMainWindow(bool)));
|
||||
// tabs
|
||||
connect(tabs.get(),SIGNAL(currentChanged(int)), this, SLOT(Refresh(int)));//( QWidget*)));
|
||||
connect(tabs, SIGNAL(currentChanged(int)), this,
|
||||
SLOT(Refresh(int))); //( QWidget*)));
|
||||
// Measurement tab
|
||||
connect(tabMeasurement.get(), SIGNAL(EnableTabsSignal(bool)), this, SLOT(EnableTabs(bool)));
|
||||
connect(tabMeasurement.get(), SIGNAL(FileNameChangedSignal(QString)), plot.get(), SLOT(SetSaveFileName(QString)));
|
||||
connect(tabMeasurement, SIGNAL(EnableTabsSignal(bool)), this,
|
||||
SLOT(EnableTabs(bool)));
|
||||
connect(tabMeasurement, SIGNAL(FileNameChangedSignal(QString)),
|
||||
plot, SLOT(SetSaveFileName(QString)));
|
||||
// Plot tab
|
||||
connect(tabPlot.get(), SIGNAL(DisableZoomSignal(bool)), this, SLOT(SetZoomToolTip(bool)));
|
||||
connect(tabPlot, SIGNAL(DisableZoomSignal(bool)), this,
|
||||
SLOT(SetZoomToolTip(bool)));
|
||||
|
||||
// Plotting
|
||||
connect(plot.get(), SIGNAL(AcquireFinishedSignal()), tabMeasurement.get(), SLOT(AcquireFinished()));
|
||||
connect(plot.get(), SIGNAL(AbortSignal()), tabMeasurement.get(), SLOT(AbortAcquire()));
|
||||
connect(plot, SIGNAL(AcquireFinishedSignal()), tabMeasurement,
|
||||
SLOT(AcquireFinished()));
|
||||
connect(plot, SIGNAL(AbortSignal()), tabMeasurement,
|
||||
SLOT(AbortAcquire()));
|
||||
|
||||
// menubar
|
||||
// Modes Menu
|
||||
connect(menuModes, SIGNAL(triggered(QAction *)), this, SLOT(EnableModes(QAction *)));
|
||||
connect(menuModes, SIGNAL(triggered(QAction *)), this,
|
||||
SLOT(EnableModes(QAction *)));
|
||||
// Utilities Menu
|
||||
connect(menuUtilities, SIGNAL(triggered(QAction *)), this, SLOT(ExecuteUtilities(QAction *)));
|
||||
connect(menuUtilities, SIGNAL(triggered(QAction *)), this,
|
||||
SLOT(ExecuteUtilities(QAction *)));
|
||||
// Help Menu
|
||||
connect(menuHelp, SIGNAL(triggered(QAction *)), this, SLOT(ExecuteHelp(QAction *)));
|
||||
|
||||
connect(menuHelp, SIGNAL(triggered(QAction *)), this,
|
||||
SLOT(ExecuteHelp(QAction *)));
|
||||
}
|
||||
|
||||
void qDetectorMain::LoadConfigFile(const std::string fName) {
|
||||
void qDetectorMain::LoadConfigFile(const std::string& config_file) {
|
||||
|
||||
FILE_LOG(logINFO) << "Loading config file at start up:" << fName;
|
||||
LOG(logINFO) << "Loading config file at start up:" << config_file;
|
||||
|
||||
struct stat st_buf;
|
||||
QString file = QString(fName.c_str());
|
||||
QString file = QString(config_file.c_str());
|
||||
|
||||
// path doesnt exist
|
||||
if (stat(fName.c_str(), &st_buf)) {
|
||||
if (stat(config_file.c_str(), &st_buf)) {
|
||||
qDefs::Message(
|
||||
qDefs::WARNING,
|
||||
std::string("<nobr>Start up configuration failed to load. The "
|
||||
"following file does not exist:</nobr><br><nobr>") +
|
||||
fName,
|
||||
config_file,
|
||||
"qDetectorMain::LoadConfigFile");
|
||||
FILE_LOG(logWARNING) << "Config file does not exist";
|
||||
LOG(logWARNING) << "Config file does not exist";
|
||||
}
|
||||
// not a file
|
||||
else if (!S_ISREG(st_buf.st_mode)) {
|
||||
@ -298,13 +308,15 @@ void qDetectorMain::LoadConfigFile(const std::string fName) {
|
||||
std::string(
|
||||
"<nobr>Start up configuration failed to load. The following "
|
||||
"file is not a recognized file format:</nobr><br><nobr>") +
|
||||
fName,
|
||||
config_file,
|
||||
"qDetectorMain::LoadConfigFile");
|
||||
FILE_LOG(logWARNING) << "File not recognized";
|
||||
LOG(logWARNING) << "File not recognized";
|
||||
} else {
|
||||
try {
|
||||
det->loadConfig(fName);
|
||||
} CATCH_DISPLAY ("Could not load config file.", "qDetectorMain::LoadConfigFile")
|
||||
det->loadConfig(config_file);
|
||||
}
|
||||
CATCH_DISPLAY("Could not load config file.",
|
||||
"qDetectorMain::LoadConfigFile")
|
||||
}
|
||||
}
|
||||
|
||||
@ -315,8 +327,7 @@ void qDetectorMain::EnableModes(QAction *action) {
|
||||
if (action == actionDebug) {
|
||||
enable = actionDebug->isChecked();
|
||||
tabs->setTabEnabled(DEBUGGING, enable);
|
||||
FILE_LOG(logINFO) << "Debug Mode: "
|
||||
<< qDefs::stringEnable(enable);
|
||||
LOG(logINFO) << "Debug Mode: " << qDefs::stringEnable(enable);
|
||||
|
||||
}
|
||||
|
||||
@ -325,9 +336,9 @@ void qDetectorMain::EnableModes(QAction *action) {
|
||||
enable = actionExpert->isChecked();
|
||||
|
||||
tabs->setTabEnabled(ADVANCED, enable);
|
||||
actionLoadTrimbits->setVisible(enable && detType == slsDetectorDefs::EIGER);
|
||||
FILE_LOG(logINFO) << "Expert Mode: "
|
||||
<< qDefs::stringEnable(enable);
|
||||
actionLoadTrimbits->setVisible(enable &&
|
||||
detType == slsDetectorDefs::EIGER);
|
||||
LOG(logINFO) << "Expert Mode: " << qDefs::stringEnable(enable);
|
||||
}
|
||||
|
||||
// Set DockableMode
|
||||
@ -339,8 +350,7 @@ void qDetectorMain::EnableModes(QAction *action) {
|
||||
dockWidgetPlot->setFloating(false);
|
||||
dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
}
|
||||
FILE_LOG(logINFO) << "Dockable Mode: "
|
||||
<< qDefs::stringEnable(enable);
|
||||
LOG(logINFO) << "Dockable Mode: " << qDefs::stringEnable(enable);
|
||||
}
|
||||
}
|
||||
|
||||
@ -349,7 +359,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
|
||||
try {
|
||||
|
||||
if (action == actionLoadConfiguration) {
|
||||
FILE_LOG(logDEBUG) << "Loading Configuration";
|
||||
LOG(logDEBUG) << "Loading Configuration";
|
||||
QString fName = QString(det->getFilePath().squash("/tmp/").c_str());
|
||||
fName = QFileDialog::getOpenFileName(
|
||||
this, tr("Load Detector Configuration"), fName,
|
||||
@ -357,19 +367,18 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
|
||||
// Gets called when cancelled as well
|
||||
if (!fName.isEmpty()) {
|
||||
refreshTabs = true;
|
||||
det->loadConfig(
|
||||
std::string(fName.toAscii().constData()));
|
||||
det->loadConfig(std::string(fName.toAscii().constData()));
|
||||
qDefs::Message(qDefs::INFORMATION,
|
||||
"The Configuration Parameters have been "
|
||||
"configured successfully.",
|
||||
"qDetectorMain::ExecuteUtilities");
|
||||
FILE_LOG(logINFO)
|
||||
LOG(logINFO)
|
||||
<< "Configuration Parameters loaded successfully";
|
||||
}
|
||||
}
|
||||
|
||||
else if (action == actionLoadParameters) {
|
||||
FILE_LOG(logDEBUG) << "Loading Parameters";
|
||||
LOG(logDEBUG) << "Loading Parameters";
|
||||
QString fName = QString(det->getFilePath().squash("/tmp/").c_str());
|
||||
fName = QFileDialog::getOpenFileName(
|
||||
this, tr("Load Measurement Setup"), fName,
|
||||
@ -377,20 +386,19 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
|
||||
// Gets called when cancelled as well
|
||||
if (!fName.isEmpty()) {
|
||||
refreshTabs = true;
|
||||
det->loadParameters(
|
||||
std::string(fName.toAscii().constData()));
|
||||
det->loadParameters(std::string(fName.toAscii().constData()));
|
||||
qDefs::Message(qDefs::INFORMATION,
|
||||
"The Detector Parameters have been "
|
||||
"configured successfully.",
|
||||
"qDetectorMain::ExecuteUtilities");
|
||||
FILE_LOG(logINFO)
|
||||
<< "Parameters loaded successfully";
|
||||
LOG(logINFO) << "Parameters loaded successfully";
|
||||
}
|
||||
}
|
||||
|
||||
else if (action == actionLoadTrimbits) {
|
||||
QString fName = QString((det->getSettingsPath().squash("/tmp/")).c_str());
|
||||
FILE_LOG(logDEBUG) << "Loading Trimbits";
|
||||
QString fName =
|
||||
QString((det->getSettingsPath().squash("/tmp/")).c_str());
|
||||
LOG(logDEBUG) << "Loading Trimbits";
|
||||
// so that even nonexisting files can be selected
|
||||
QFileDialog *fileDialog = new QFileDialog(
|
||||
this, tr("Load Detector Trimbits"), fName,
|
||||
@ -401,18 +409,16 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
|
||||
|
||||
// Gets called when cancelled as well
|
||||
if (!fName.isEmpty()) {
|
||||
det->loadTrimbits(
|
||||
std::string(fName.toAscii().constData()));
|
||||
qDefs::Message(
|
||||
qDefs::INFORMATION,
|
||||
"The Trimbits have been loaded successfully.",
|
||||
"qDetectorMain::ExecuteUtilities");
|
||||
FILE_LOG(logINFO) << "Trimbits loaded successfully";
|
||||
det->loadTrimbits(std::string(fName.toAscii().constData()));
|
||||
qDefs::Message(qDefs::INFORMATION,
|
||||
"The Trimbits have been loaded successfully.",
|
||||
"qDetectorMain::ExecuteUtilities");
|
||||
LOG(logINFO) << "Trimbits loaded successfully";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} CATCH_DISPLAY ("Could not execute utilities.", "qDetectorMain::ExecuteUtilities")
|
||||
}
|
||||
CATCH_DISPLAY("Could not execute utilities.",
|
||||
"qDetectorMain::ExecuteUtilities")
|
||||
|
||||
Refresh(tabs->currentIndex());
|
||||
if (refreshTabs) {
|
||||
@ -431,13 +437,16 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
|
||||
|
||||
void qDetectorMain::ExecuteHelp(QAction *action) {
|
||||
if (action == actionAbout) {
|
||||
FILE_LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, Gotthard, Gotthard2 and Moench detectors";
|
||||
LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, "
|
||||
"Gotthard, Gotthard2 and Moench detectors";
|
||||
|
||||
std::string guiVersion = std::to_string(APIGUI);
|
||||
std::string clientVersion = "unknown";
|
||||
try {
|
||||
clientVersion = std::to_string(det->getClientVersion());
|
||||
} CATCH_DISPLAY ("Could not get client version.", "qDetectorMain::ExecuteHelp")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get client version.",
|
||||
"qDetectorMain::ExecuteHelp")
|
||||
|
||||
qDefs::Message(qDefs::INFORMATION,
|
||||
"<p style=\"font-family:verdana;\">"
|
||||
@ -448,7 +457,8 @@ void qDetectorMain::ExecuteHelp(QAction *action) {
|
||||
clientVersion +
|
||||
"<br><br>"
|
||||
"Common GUI to control the SLS Detectors: "
|
||||
"Jungfrau, Eiger, Mythen3, Gotthard, Gotthard2 and Moench.<br><br>"
|
||||
"Jungfrau, Eiger, Mythen3, Gotthard, Gotthard2 and "
|
||||
"Moench.<br><br>"
|
||||
"It can be operated in parallel with the command "
|
||||
"line interface:<br>"
|
||||
"sls_detector_put,<br>sls_detector_get,<br>sls_"
|
||||
@ -462,7 +472,7 @@ void qDetectorMain::ExecuteHelp(QAction *action) {
|
||||
}
|
||||
|
||||
void qDetectorMain::Refresh(int index) {
|
||||
FILE_LOG(logDEBUG) << "Refresh Main Tab";
|
||||
LOG(logDEBUG) << "Refresh Main Tab";
|
||||
|
||||
if (!tabs->isTabEnabled(index))
|
||||
tabs->setCurrentIndex((index++) < (tabs->count() - 1) ? index
|
||||
@ -501,14 +511,14 @@ void qDetectorMain::Refresh(int index) {
|
||||
}
|
||||
|
||||
void qDetectorMain::ResizeMainWindow(bool b) {
|
||||
FILE_LOG(logDEBUG1) << "Resizing Main Window: height:" << height();
|
||||
LOG(logDEBUG1) << "Resizing Main Window: height:" << height();
|
||||
|
||||
// undocked from the main window
|
||||
if (b) {
|
||||
// sets the main window height to a smaller maximum to get rid of space
|
||||
setMaximumHeight(height() - heightPlotWindow - 9);
|
||||
dockWidgetPlot->setMinimumHeight(0);
|
||||
FILE_LOG(logINFO) << "Undocking from main window";
|
||||
LOG(logINFO) << "Undocking from main window";
|
||||
} else {
|
||||
setMaximumHeight(QWIDGETSIZE_MAX);
|
||||
// the minimum for plot will be set when the widget gets resized
|
||||
@ -536,7 +546,7 @@ void qDetectorMain::resizeEvent(QResizeEvent *event) {
|
||||
}
|
||||
|
||||
void qDetectorMain::EnableTabs(bool enable) {
|
||||
FILE_LOG(logDEBUG) << "qDetectorMain::EnableTabs";
|
||||
LOG(logDEBUG) << "qDetectorMain::EnableTabs";
|
||||
|
||||
// normal tabs
|
||||
tabs->setTabEnabled(DATAOUTPUT, enable);
|
||||
@ -555,7 +565,8 @@ void qDetectorMain::EnableTabs(bool enable) {
|
||||
// expert
|
||||
bool expertTab = enable && (actionExpert->isChecked());
|
||||
tabs->setTabEnabled(ADVANCED, expertTab);
|
||||
actionLoadTrimbits->setVisible(expertTab && detType == slsDetectorDefs::EIGER);
|
||||
actionLoadTrimbits->setVisible(expertTab &&
|
||||
detType == slsDetectorDefs::EIGER);
|
||||
|
||||
// moved to here, so that its all in order, instead of signals and different
|
||||
// threads
|
||||
|
696
slsDetectorGui/src/qDrawPlot.cpp
Executable file → Normal file
696
slsDetectorGui/src/qDrawPlot.cpp
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
344
slsDetectorGui/src/qTabAdvanced.cpp
Executable file → Normal file
344
slsDetectorGui/src/qTabAdvanced.cpp
Executable file → Normal file
@ -1,15 +1,14 @@
|
||||
#include "qTabAdvanced.h"
|
||||
#include "network_utils.h"
|
||||
#include "qDefs.h"
|
||||
#include "qDrawPlot.h"
|
||||
#include "network_utils.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
qTabAdvanced::qTabAdvanced(QWidget *parent, sls::Detector *detector, qDrawPlot *p)
|
||||
qTabAdvanced::qTabAdvanced(QWidget *parent, sls::Detector *detector,
|
||||
qDrawPlot *p)
|
||||
: QWidget(parent), det(detector), plot(p) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logDEBUG) << "Advanced ready";
|
||||
LOG(logDEBUG) << "Advanced ready";
|
||||
}
|
||||
|
||||
qTabAdvanced::~qTabAdvanced() {}
|
||||
@ -88,7 +87,8 @@ void qTabAdvanced::Initialization() {
|
||||
|
||||
// roi
|
||||
if (tab_roi->isEnabled()) {
|
||||
connect(comboReadout, SIGNAL(currentIndexChanged(int)), this, SLOT(GetROI()));
|
||||
connect(comboReadout, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(GetROI()));
|
||||
connect(btnSetRoi, SIGNAL(clicked()), this, SLOT(SetROI()));
|
||||
connect(btnClearRoi, SIGNAL(clicked()), this, SLOT(ClearROI()));
|
||||
}
|
||||
@ -114,15 +114,16 @@ void qTabAdvanced::Initialization() {
|
||||
// throw bits
|
||||
if (lblDiscardBits->isEnabled()) {
|
||||
connect(spinDiscardBits, SIGNAL(valueChanged(int)), plot,
|
||||
SLOT(SetNumDiscardBits(int)));
|
||||
SLOT(SetNumDiscardBits(int)));
|
||||
}
|
||||
}
|
||||
|
||||
void qTabAdvanced::PopulateDetectors() {
|
||||
FILE_LOG(logDEBUG) << "Populating detectors";
|
||||
LOG(logDEBUG) << "Populating detectors";
|
||||
disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetDetector()));
|
||||
disconnect(comboReadout, SIGNAL(currentIndexChanged(int)), this, SLOT(GetROI()));
|
||||
disconnect(comboReadout, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(GetROI()));
|
||||
|
||||
comboDetector->clear();
|
||||
comboReadout->clear();
|
||||
@ -132,197 +133,223 @@ void qTabAdvanced::PopulateDetectors() {
|
||||
comboReadout->addItem(QString(it.c_str()));
|
||||
}
|
||||
comboDetector->setCurrentIndex(0);
|
||||
comboReadout->setCurrentIndex(0);
|
||||
comboReadout->setCurrentIndex(0);
|
||||
|
||||
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetDetector()));
|
||||
connect(comboReadout, SIGNAL(currentIndexChanged(int)), this, SLOT(GetROI()));
|
||||
connect(comboReadout, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(GetROI()));
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetControlPort() {
|
||||
FILE_LOG(logDEBUG) << "Getting control port ";
|
||||
LOG(logDEBUG) << "Getting control port ";
|
||||
disconnect(spinControlPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetControlPort(int)));
|
||||
|
||||
try {
|
||||
int retval = det->getControlPort({comboDetector->currentIndex()})[0];
|
||||
spinControlPort->setValue(retval);
|
||||
} CATCH_DISPLAY ("Could not get detector control port.", "qTabAdvanced::GetControlPort")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get detector control port.",
|
||||
"qTabAdvanced::GetControlPort")
|
||||
|
||||
connect(spinControlPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetControlPort(int)));
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetStopPort() {
|
||||
FILE_LOG(logDEBUG) << "Getting stop port";
|
||||
LOG(logDEBUG) << "Getting stop port";
|
||||
disconnect(spinStopPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetStopPort(int)));
|
||||
|
||||
try {
|
||||
int retval = det->getStopPort({comboDetector->currentIndex()})[0];
|
||||
spinStopPort->setValue(retval);
|
||||
} CATCH_DISPLAY ("Could not get detector stop port.", "qTabAdvanced::GetStopPort")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get detector stop port.",
|
||||
"qTabAdvanced::GetStopPort")
|
||||
|
||||
connect(spinStopPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetStopPort(int)));
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetDetectorUDPIP() {
|
||||
FILE_LOG(logDEBUG) << "Getting Detector UDP IP";
|
||||
LOG(logDEBUG) << "Getting Detector UDP IP";
|
||||
disconnect(dispDetectorUDPIP, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetDetectorUDPIP()));
|
||||
|
||||
try {
|
||||
auto retval = det->getSourceUDPIP({comboDetector->currentIndex()})[0].str();
|
||||
auto retval =
|
||||
det->getSourceUDPIP({comboDetector->currentIndex()})[0].str();
|
||||
dispDetectorUDPIP->setText(QString(retval.c_str()));
|
||||
} CATCH_DISPLAY ("Could not get detector UDP IP.", "qTabAdvanced::GetDetectorUDPIP")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get detector UDP IP.",
|
||||
"qTabAdvanced::GetDetectorUDPIP")
|
||||
|
||||
connect(dispDetectorUDPIP, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetDetectorUDPIP()));
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetDetectorUDPMAC() {
|
||||
FILE_LOG(logDEBUG) << "Getting Detector UDP MAC";
|
||||
LOG(logDEBUG) << "Getting Detector UDP MAC";
|
||||
disconnect(dispDetectorUDPMAC, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetDetectorUDPMAC()));
|
||||
|
||||
try {
|
||||
auto retval = det->getSourceUDPMAC({comboDetector->currentIndex()})[0].str();
|
||||
auto retval =
|
||||
det->getSourceUDPMAC({comboDetector->currentIndex()})[0].str();
|
||||
dispDetectorUDPMAC->setText(QString(retval.c_str()));
|
||||
} CATCH_DISPLAY ("Could not get detector UDP MAC.", "qTabAdvanced::GetDetectorUDPMAC")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get detector UDP MAC.",
|
||||
"qTabAdvanced::GetDetectorUDPMAC")
|
||||
|
||||
connect(dispDetectorUDPMAC, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetDetectorUDPMAC()));
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetCltZMQPort() {
|
||||
FILE_LOG(logDEBUG) << "Getting Client ZMQ port";
|
||||
LOG(logDEBUG) << "Getting Client ZMQ port";
|
||||
disconnect(spinZMQPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetCltZMQPort(int)));
|
||||
|
||||
try {
|
||||
int retval =
|
||||
det->getClientZmqPort({comboDetector->currentIndex()})[0];
|
||||
int retval = det->getClientZmqPort({comboDetector->currentIndex()})[0];
|
||||
spinZMQPort->setValue(retval);
|
||||
} CATCH_DISPLAY ("Could not get client zmq port.", "qTabAdvanced::GetCltZMQPort")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get client zmq port.",
|
||||
"qTabAdvanced::GetCltZMQPort")
|
||||
|
||||
connect(spinZMQPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetCltZMQPort(int)));
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetCltZMQIP() {
|
||||
FILE_LOG(logDEBUG) << "Getting Client ZMQ IP";
|
||||
LOG(logDEBUG) << "Getting Client ZMQ IP";
|
||||
disconnect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetCltZMQIP()));
|
||||
|
||||
try {
|
||||
auto retval =
|
||||
det->getClientZmqIp({comboDetector->currentIndex()})[0].str();
|
||||
dispZMQIP->setText(QString(retval.c_str()));
|
||||
} CATCH_DISPLAY ("Could not get client zmq ip.", "qTabAdvanced::GetCltZMQIP")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get client zmq ip.", "qTabAdvanced::GetCltZMQIP")
|
||||
|
||||
connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetCltZMQIP()));
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetRxrHostname() {
|
||||
FILE_LOG(logDEBUG) << "Getting Receiver Hostname";
|
||||
LOG(logDEBUG) << "Getting Receiver Hostname";
|
||||
disconnect(dispRxrHostname, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetRxrHostname()));
|
||||
|
||||
try {
|
||||
auto retval = det->getRxHostname({comboDetector->currentIndex()})[0];
|
||||
dispRxrHostname->setText(QString(retval.c_str()));
|
||||
} CATCH_DISPLAY ("Could not get receiver hostname.", "qTabAdvanced::GetRxrHostname")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get receiver hostname.",
|
||||
"qTabAdvanced::GetRxrHostname")
|
||||
|
||||
connect(dispRxrHostname, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetRxrHostname()));
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetRxrTCPPort() {
|
||||
FILE_LOG(logDEBUG) << "Getting Receiver TCP port";
|
||||
LOG(logDEBUG) << "Getting Receiver TCP port";
|
||||
disconnect(spinRxrTCPPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetRxrTCPPort(int)));
|
||||
|
||||
try {
|
||||
int retval = det->getRxPort({comboDetector->currentIndex()})[0];
|
||||
spinRxrTCPPort->setValue(retval);
|
||||
} CATCH_DISPLAY ("Could not get receiver tcp port.", "qTabAdvanced::GetRxrTCPPort")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get receiver tcp port.",
|
||||
"qTabAdvanced::GetRxrTCPPort")
|
||||
|
||||
connect(spinRxrTCPPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetRxrTCPPort(int)));
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetRxrUDPPort() {
|
||||
FILE_LOG(logDEBUG) << "Getting Receiver UDP port";
|
||||
LOG(logDEBUG) << "Getting Receiver UDP port";
|
||||
disconnect(spinRxrUDPPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetRxrUDPPort(int)));
|
||||
|
||||
try {
|
||||
int retval = det->getDestinationUDPPort({comboDetector->currentIndex()})[0];
|
||||
int retval =
|
||||
det->getDestinationUDPPort({comboDetector->currentIndex()})[0];
|
||||
spinRxrUDPPort->setValue(retval);
|
||||
} CATCH_DISPLAY ("Could not get receiver udp port.", "qTabAdvanced::GetRxrUDPPort")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get receiver udp port.",
|
||||
"qTabAdvanced::GetRxrUDPPort")
|
||||
|
||||
connect(spinRxrUDPPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetRxrUDPPort(int)));
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetRxrUDPIP() {
|
||||
FILE_LOG(logDEBUG) << "Getting Receiver UDP IP";
|
||||
LOG(logDEBUG) << "Getting Receiver UDP IP";
|
||||
disconnect(dispRxrUDPIP, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetRxrUDPIP()));
|
||||
|
||||
try {
|
||||
auto retval = det->getDestinationUDPIP({comboDetector->currentIndex()})[0].str();
|
||||
auto retval =
|
||||
det->getDestinationUDPIP({comboDetector->currentIndex()})[0].str();
|
||||
dispRxrUDPIP->setText(QString(retval.c_str()));
|
||||
} CATCH_DISPLAY ("Could not get receiver udp ip.", "qTabAdvanced::GetRxrUDPIP")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get receiver udp ip.", "qTabAdvanced::GetRxrUDPIP")
|
||||
|
||||
connect(dispRxrUDPIP, SIGNAL(editingFinished()), this, SLOT(SetRxrUDPIP()));
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetRxrUDPMAC() {
|
||||
FILE_LOG(logDEBUG) << "Getting Receiver UDP MAC";
|
||||
LOG(logDEBUG) << "Getting Receiver UDP MAC";
|
||||
disconnect(dispRxrUDPMAC, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetRxrUDPMAC()));
|
||||
|
||||
try {
|
||||
auto retval = det->getDestinationUDPMAC({comboDetector->currentIndex()})[0].str();
|
||||
auto retval =
|
||||
det->getDestinationUDPMAC({comboDetector->currentIndex()})[0].str();
|
||||
dispRxrUDPMAC->setText(QString(retval.c_str()));
|
||||
} CATCH_DISPLAY ("Could not get receiver udp mac.", "qTabAdvanced::GetRxrUDPMAC")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get receiver udp mac.",
|
||||
"qTabAdvanced::GetRxrUDPMAC")
|
||||
|
||||
connect(dispRxrUDPMAC, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetRxrUDPMAC()));
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetRxrZMQPort() {
|
||||
FILE_LOG(logDEBUG) << "Getting Receiver ZMQ port";
|
||||
LOG(logDEBUG) << "Getting Receiver ZMQ port";
|
||||
disconnect(spinRxrZMQPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetRxrZMQPort(int)));
|
||||
|
||||
try {
|
||||
int retval =
|
||||
det->getRxZmqPort({comboDetector->currentIndex()})[0];
|
||||
int retval = det->getRxZmqPort({comboDetector->currentIndex()})[0];
|
||||
spinRxrZMQPort->setValue(retval);
|
||||
} CATCH_DISPLAY ("Could not get receiver zmq port.", "qTabAdvanced::GetRxrZMQPort")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get receiver zmq port.",
|
||||
"qTabAdvanced::GetRxrZMQPort")
|
||||
|
||||
connect(spinRxrZMQPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetRxrZMQPort(int)));
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetRxrZMQIP() {
|
||||
FILE_LOG(logDEBUG) << "Getting Receiver ZMQ IP";
|
||||
LOG(logDEBUG) << "Getting Receiver ZMQ IP";
|
||||
disconnect(dispRxrZMQIP, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetRxrZMQIP()));
|
||||
|
||||
try {
|
||||
auto retval =
|
||||
det->getRxZmqIP({comboDetector->currentIndex()})[0].str();
|
||||
auto retval = det->getRxZmqIP({comboDetector->currentIndex()})[0].str();
|
||||
dispRxrZMQIP->setText(QString(retval.c_str()));
|
||||
} CATCH_DISPLAY ("Could not get receiver zmq ip.", "qTabAdvanced::GetRxrZMQIP")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get receiver zmq ip.", "qTabAdvanced::GetRxrZMQIP")
|
||||
|
||||
connect(dispRxrZMQIP, SIGNAL(editingFinished()), this, SLOT(SetRxrZMQIP()));
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetDetector() {
|
||||
FILE_LOG(logDEBUG) << "Set Detector: "
|
||||
LOG(logDEBUG) << "Set Detector: "
|
||||
<< comboDetector->currentText().toAscii().data();
|
||||
|
||||
GetControlPort();
|
||||
@ -339,149 +366,162 @@ void qTabAdvanced::SetDetector() {
|
||||
GetRxrZMQPort();
|
||||
GetRxrZMQIP();
|
||||
|
||||
FILE_LOG(logDEBUG) << det->printRxConfiguration();
|
||||
LOG(logDEBUG) << det->printRxConfiguration();
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetControlPort(int port) {
|
||||
FILE_LOG(logINFO) << "Setting Control Port:" << port;
|
||||
LOG(logINFO) << "Setting Control Port:" << port;
|
||||
try {
|
||||
det->setControlPort(port, {comboDetector->currentIndex()});
|
||||
} CATCH_HANDLE("Could not set control port.", "qTabAdvanced::SetControlPort",
|
||||
}
|
||||
CATCH_HANDLE("Could not set control port.", "qTabAdvanced::SetControlPort",
|
||||
this, &qTabAdvanced::GetControlPort)
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetStopPort(int port) {
|
||||
FILE_LOG(logINFO) << "Setting Stop Port:" << port;
|
||||
LOG(logINFO) << "Setting Stop Port:" << port;
|
||||
try {
|
||||
det->setStopPort(port, {comboDetector->currentIndex()});
|
||||
} CATCH_HANDLE ("Could not set stop port.", "qTabAdvanced::SetStopPort", this,
|
||||
&qTabAdvanced::GetStopPort)
|
||||
}
|
||||
CATCH_HANDLE("Could not set stop port.", "qTabAdvanced::SetStopPort", this,
|
||||
&qTabAdvanced::GetStopPort)
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetDetectorUDPIP() {
|
||||
std::string s = dispDetectorUDPIP->text().toAscii().constData();
|
||||
FILE_LOG(logINFO) << "Setting Detector UDP IP:" << s;
|
||||
LOG(logINFO) << "Setting Detector UDP IP:" << s;
|
||||
try {
|
||||
det->setSourceUDPIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
|
||||
} CATCH_HANDLE ("Could not set Detector UDP IP.",
|
||||
"qTabAdvanced::SetDetectorUDPIP", this,
|
||||
&qTabAdvanced::GetDetectorUDPIP)
|
||||
}
|
||||
CATCH_HANDLE("Could not set Detector UDP IP.",
|
||||
"qTabAdvanced::SetDetectorUDPIP", this,
|
||||
&qTabAdvanced::GetDetectorUDPIP)
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetDetectorUDPMAC() {
|
||||
std::string s = dispDetectorUDPMAC->text().toAscii().constData();
|
||||
FILE_LOG(logINFO) << "Setting Detector UDP MAC:" << s;
|
||||
LOG(logINFO) << "Setting Detector UDP MAC:" << s;
|
||||
try {
|
||||
det->setSourceUDPMAC(sls::MacAddr{s}, {comboDetector->currentIndex()});
|
||||
} CATCH_HANDLE ("Could not set Detector UDP MAC.",
|
||||
"qTabAdvanced::SetDetectorUDPMAC", this,
|
||||
&qTabAdvanced::GetDetectorUDPMAC)
|
||||
}
|
||||
CATCH_HANDLE("Could not set Detector UDP MAC.",
|
||||
"qTabAdvanced::SetDetectorUDPMAC", this,
|
||||
&qTabAdvanced::GetDetectorUDPMAC)
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetCltZMQPort(int port) {
|
||||
FILE_LOG(logINFO) << "Setting Client ZMQ Port:" << port;
|
||||
LOG(logINFO) << "Setting Client ZMQ Port:" << port;
|
||||
try {
|
||||
det->setClientZmqPort(port, {comboDetector->currentIndex()});
|
||||
} CATCH_HANDLE ("Could not set Client ZMQ port.",
|
||||
"qTabAdvanced::SetCltZMQPort", this,
|
||||
&qTabAdvanced::GetCltZMQPort)
|
||||
}
|
||||
CATCH_HANDLE("Could not set Client ZMQ port.",
|
||||
"qTabAdvanced::SetCltZMQPort", this,
|
||||
&qTabAdvanced::GetCltZMQPort)
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetCltZMQIP() {
|
||||
std::string s = dispZMQIP->text().toAscii().constData();
|
||||
FILE_LOG(logINFO) << "Setting Client ZMQ IP:" << s;
|
||||
LOG(logINFO) << "Setting Client ZMQ IP:" << s;
|
||||
try {
|
||||
det->setClientZmqIp(sls::IpAddr{s}, {comboDetector->currentIndex()});
|
||||
} CATCH_HANDLE ("Could not set Client ZMQ IP.",
|
||||
"qTabAdvanced::SetCltZMQIP", this,
|
||||
&qTabAdvanced::GetCltZMQIP)
|
||||
}
|
||||
CATCH_HANDLE("Could not set Client ZMQ IP.", "qTabAdvanced::SetCltZMQIP",
|
||||
this, &qTabAdvanced::GetCltZMQIP)
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetRxrHostname() {
|
||||
std::string s = dispZMQIP->text().toAscii().constData();
|
||||
FILE_LOG(logINFO) << "Setting Receiver Hostname:" << s;
|
||||
LOG(logINFO) << "Setting Receiver Hostname:" << s;
|
||||
try {
|
||||
det->setRxHostname(s, {comboDetector->currentIndex()});
|
||||
} CATCH_HANDLE ("Could not set Client ZMQ IP.",
|
||||
"qTabAdvanced::SetRxrHostname", this,
|
||||
&qTabAdvanced::GetRxrHostname)
|
||||
}
|
||||
CATCH_HANDLE("Could not set Client ZMQ IP.", "qTabAdvanced::SetRxrHostname",
|
||||
this, &qTabAdvanced::GetRxrHostname)
|
||||
|
||||
// update all network widgets (receiver mainly)
|
||||
SetDetector();
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetRxrTCPPort(int port) {
|
||||
FILE_LOG(logINFO) << "Setting Receiver TCP Port:" << port;
|
||||
LOG(logINFO) << "Setting Receiver TCP Port:" << port;
|
||||
try {
|
||||
det->setRxPort(port, {comboDetector->currentIndex()});
|
||||
} CATCH_HANDLE ("Could not set Receiver TCP port.",
|
||||
"qTabAdvanced::SetRxrTCPPort", this,
|
||||
&qTabAdvanced::GetRxrTCPPort)
|
||||
}
|
||||
CATCH_HANDLE("Could not set Receiver TCP port.",
|
||||
"qTabAdvanced::SetRxrTCPPort", this,
|
||||
&qTabAdvanced::GetRxrTCPPort)
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetRxrUDPPort(int port) {
|
||||
FILE_LOG(logINFO) << "Setting Receiver UDP Port:" << port;
|
||||
LOG(logINFO) << "Setting Receiver UDP Port:" << port;
|
||||
try {
|
||||
det->setRxPort(port, {comboDetector->currentIndex()});
|
||||
} CATCH_HANDLE ("Could not set Receiver UDP port.",
|
||||
"qTabAdvanced::SetRxrUDPPort", this,
|
||||
&qTabAdvanced::GetRxrUDPPort)
|
||||
}
|
||||
CATCH_HANDLE("Could not set Receiver UDP port.",
|
||||
"qTabAdvanced::SetRxrUDPPort", this,
|
||||
&qTabAdvanced::GetRxrUDPPort)
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetRxrUDPIP() {
|
||||
std::string s = dispRxrUDPIP->text().toAscii().constData();
|
||||
FILE_LOG(logINFO) << "Setting Receiver UDP IP:" << s;
|
||||
LOG(logINFO) << "Setting Receiver UDP IP:" << s;
|
||||
try {
|
||||
det->setDestinationUDPIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
|
||||
} CATCH_HANDLE ("Could not set Receiver UDP IP.",
|
||||
"qTabAdvanced::SetRxrUDPIP", this,
|
||||
&qTabAdvanced::GetRxrUDPIP)
|
||||
det->setDestinationUDPIP(sls::IpAddr{s},
|
||||
{comboDetector->currentIndex()});
|
||||
}
|
||||
CATCH_HANDLE("Could not set Receiver UDP IP.", "qTabAdvanced::SetRxrUDPIP",
|
||||
this, &qTabAdvanced::GetRxrUDPIP)
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetRxrUDPMAC() {
|
||||
std::string s = dispRxrUDPMAC->text().toAscii().constData();
|
||||
FILE_LOG(logINFO) << "Setting Receiver UDP MAC:" << s;
|
||||
LOG(logINFO) << "Setting Receiver UDP MAC:" << s;
|
||||
try {
|
||||
det->setDestinationUDPMAC(sls::MacAddr{s}, {comboDetector->currentIndex()});
|
||||
} CATCH_HANDLE ("Could not set Receiver UDP MAC.",
|
||||
"qTabAdvanced::SetRxrUDPMAC", this,
|
||||
&qTabAdvanced::GetRxrUDPMAC)
|
||||
det->setDestinationUDPMAC(sls::MacAddr{s},
|
||||
{comboDetector->currentIndex()});
|
||||
}
|
||||
CATCH_HANDLE("Could not set Receiver UDP MAC.",
|
||||
"qTabAdvanced::SetRxrUDPMAC", this,
|
||||
&qTabAdvanced::GetRxrUDPMAC)
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetRxrZMQPort(int port) {
|
||||
FILE_LOG(logINFO) << "Setting Receiver ZMQ Port:" << port;
|
||||
LOG(logINFO) << "Setting Receiver ZMQ Port:" << port;
|
||||
try {
|
||||
det->setRxZmqPort(port, {comboDetector->currentIndex()});
|
||||
} CATCH_HANDLE ("Could not set Receiver ZMQ port.",
|
||||
"qTabAdvanced::SetRxrZMQPort", this,
|
||||
&qTabAdvanced::GetRxrZMQPort)
|
||||
}
|
||||
CATCH_HANDLE("Could not set Receiver ZMQ port.",
|
||||
"qTabAdvanced::SetRxrZMQPort", this,
|
||||
&qTabAdvanced::GetRxrZMQPort)
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetRxrZMQIP() {
|
||||
std::string s = dispRxrZMQIP->text().toAscii().constData();
|
||||
FILE_LOG(logINFO) << "Setting Receiver ZMQ IP:" << s;
|
||||
LOG(logINFO) << "Setting Receiver ZMQ IP:" << s;
|
||||
try {
|
||||
det->setRxZmqIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
|
||||
} CATCH_HANDLE ("Could not set Receiver ZMQ IP.",
|
||||
"qTabAdvanced::SetRxrZMQIP", this,
|
||||
&qTabAdvanced::GetRxrZMQIP)
|
||||
}
|
||||
CATCH_HANDLE("Could not set Receiver ZMQ IP.", "qTabAdvanced::SetRxrZMQIP",
|
||||
this, &qTabAdvanced::GetRxrZMQIP)
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetROI() {
|
||||
FILE_LOG(logDEBUG) << "Getting ROI";
|
||||
LOG(logDEBUG) << "Getting ROI";
|
||||
try {
|
||||
slsDetectorDefs::ROI roi = det->getROI({comboReadout->currentIndex()})[0];
|
||||
slsDetectorDefs::ROI roi =
|
||||
det->getROI({comboReadout->currentIndex()})[0];
|
||||
spinXmin->setValue(roi.xmin);
|
||||
spinXmax->setValue(roi.xmax);
|
||||
} CATCH_DISPLAY ("Could not get ROI.", "qTabAdvanced::GetROI")
|
||||
spinXmax->setValue(roi.xmax);
|
||||
}
|
||||
CATCH_DISPLAY("Could not get ROI.", "qTabAdvanced::GetROI")
|
||||
}
|
||||
|
||||
void qTabAdvanced::ClearROI() {
|
||||
FILE_LOG(logINFO) << "Clearing ROI";
|
||||
LOG(logINFO) << "Clearing ROI";
|
||||
spinXmin->setValue(-1);
|
||||
spinXmax->setValue(-1);
|
||||
spinXmax->setValue(-1);
|
||||
SetROI();
|
||||
FILE_LOG(logDEBUG) << "ROIs cleared";
|
||||
LOG(logDEBUG) << "ROIs cleared";
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetROI() {
|
||||
@ -491,25 +531,27 @@ void qTabAdvanced::SetROI() {
|
||||
roi.xmax = spinXmax->value();
|
||||
|
||||
// set roi
|
||||
FILE_LOG(logINFO) << "Setting ROI: [" << roi.xmin << ", " << roi.xmax << "]";
|
||||
LOG(logINFO) << "Setting ROI: [" << roi.xmin << ", " << roi.xmax
|
||||
<< "]";
|
||||
try {
|
||||
det->setROI(roi, {comboReadout->currentIndex()});
|
||||
} CATCH_DISPLAY ("Could not set these ROIs.",
|
||||
"qTabAdvanced::SetROI")
|
||||
}
|
||||
CATCH_DISPLAY("Could not set these ROIs.", "qTabAdvanced::SetROI")
|
||||
|
||||
// update corrected list
|
||||
GetROI();
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetAllTrimbits() {
|
||||
FILE_LOG(logDEBUG) << "Getting all trimbits value";
|
||||
LOG(logDEBUG) << "Getting all trimbits value";
|
||||
disconnect(spinSetAllTrimbits, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetAllTrimbits()));
|
||||
|
||||
try {
|
||||
int retval = det->getAllTrimbits().squash(-1);
|
||||
spinSetAllTrimbits->setValue(retval);
|
||||
} CATCH_DISPLAY ("Could not get all trimbits.", "qTabAdvanced::GetAllTrimbits")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get all trimbits.", "qTabAdvanced::GetAllTrimbits")
|
||||
|
||||
connect(spinSetAllTrimbits, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetAllTrimbits()));
|
||||
@ -517,55 +559,58 @@ void qTabAdvanced::GetAllTrimbits() {
|
||||
|
||||
void qTabAdvanced::SetAllTrimbits() {
|
||||
int value = spinSetAllTrimbits->value();
|
||||
FILE_LOG(logINFO) << "Setting all trimbits:" << value;
|
||||
LOG(logINFO) << "Setting all trimbits:" << value;
|
||||
|
||||
try {
|
||||
det->setAllTrimbits(value);
|
||||
} CATCH_HANDLE("Could not set all trimbits.", "qTabAdvanced::SetAllTrimbits",
|
||||
}
|
||||
CATCH_HANDLE("Could not set all trimbits.", "qTabAdvanced::SetAllTrimbits",
|
||||
this, &qTabAdvanced::GetAllTrimbits)
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetNumStoragecells() {
|
||||
FILE_LOG(logDEBUG) << "Getting number of additional storage cells";
|
||||
LOG(logDEBUG) << "Getting number of additional storage cells";
|
||||
disconnect(spinNumStoragecells, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetNumStoragecells(int)));
|
||||
|
||||
try {
|
||||
auto retval = det->getNumberOfAdditionalStorageCells().tsquash("Inconsistent values for number of addditional storage cells.");
|
||||
auto retval = det->getNumberOfAdditionalStorageCells().tsquash(
|
||||
"Inconsistent values for number of addditional storage cells.");
|
||||
spinNumStoragecells->setValue(retval);
|
||||
} CATCH_DISPLAY (
|
||||
"Could not get number of additional storage cells.",
|
||||
"qTabAdvanced::GetNumStoragecells")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get number of additional storage cells.",
|
||||
"qTabAdvanced::GetNumStoragecells")
|
||||
|
||||
connect(spinNumStoragecells, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetNumStoragecells(int)));
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetNumStoragecells(int value) {
|
||||
FILE_LOG(logINFO) << "Setting number of additional stoarge cells: "
|
||||
LOG(logINFO) << "Setting number of additional stoarge cells: "
|
||||
<< value;
|
||||
try {
|
||||
det->setNumberOfAdditionalStorageCells(value);
|
||||
} CATCH_HANDLE (
|
||||
"Could not set number of additional storage cells.",
|
||||
"qTabAdvanced::SetNumStoragecells", this,
|
||||
&qTabAdvanced::GetNumStoragecells)
|
||||
}
|
||||
CATCH_HANDLE("Could not set number of additional storage cells.",
|
||||
"qTabAdvanced::SetNumStoragecells", this,
|
||||
&qTabAdvanced::GetNumStoragecells)
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetSubExposureTime() {
|
||||
FILE_LOG(logDEBUG) << "Getting sub exposure time";
|
||||
LOG(logDEBUG) << "Getting sub exposure time";
|
||||
disconnect(spinSubExpTime, SIGNAL(valueChanged(double)), this,
|
||||
SLOT(SetSubExposureTime()));
|
||||
disconnect(comboSubExpTimeUnit, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetSubExposureTime()));
|
||||
try {
|
||||
auto retval =
|
||||
det->getSubExptime().tsquash("Subexptime is inconsistent for all detectors.");
|
||||
auto retval = det->getSubExptime().tsquash(
|
||||
"Subexptime is inconsistent for all detectors.");
|
||||
auto time = qDefs::getUserFriendlyTime(retval);
|
||||
spinSubExpTime->setValue(time.first);
|
||||
comboSubExpTimeUnit->setCurrentIndex(static_cast<int>(time.second));
|
||||
} CATCH_DISPLAY ("Could not get sub exposure time.",
|
||||
"qTabSettings::GetSubExposureTime")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get sub exposure time.",
|
||||
"qTabSettings::GetSubExposureTime")
|
||||
connect(spinSubExpTime, SIGNAL(valueChanged(double)), this,
|
||||
SLOT(SetSubExposureTime()));
|
||||
connect(comboSubExpTimeUnit, SIGNAL(currentIndexChanged(int)), this,
|
||||
@ -573,34 +618,38 @@ void qTabAdvanced::GetSubExposureTime() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetSubExposureTime() {
|
||||
auto timeNS = qDefs::getNSTime(std::make_pair(spinSubExpTime->value(), static_cast<qDefs::timeUnit>(comboSubExpTimeUnit->currentIndex())));
|
||||
FILE_LOG(logINFO)
|
||||
auto timeNS = qDefs::getNSTime(std::make_pair(
|
||||
spinSubExpTime->value(),
|
||||
static_cast<qDefs::timeUnit>(comboSubExpTimeUnit->currentIndex())));
|
||||
LOG(logINFO)
|
||||
<< "Setting sub frame acquisition time to " << timeNS.count() << " ns"
|
||||
<< "/" << spinSubExpTime->value()
|
||||
<< qDefs::getUnitString(
|
||||
(qDefs::timeUnit)comboSubExpTimeUnit->currentIndex());
|
||||
try {
|
||||
det->setSubExptime(timeNS);
|
||||
} CATCH_DISPLAY ("Could not set sub exposure time.",
|
||||
"qTabAdvanced::SetSubExposureTime")
|
||||
}
|
||||
CATCH_DISPLAY("Could not set sub exposure time.",
|
||||
"qTabAdvanced::SetSubExposureTime")
|
||||
|
||||
GetSubExposureTime();
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetSubDeadTime() {
|
||||
FILE_LOG(logDEBUG) << "Getting sub dead time";
|
||||
LOG(logDEBUG) << "Getting sub dead time";
|
||||
disconnect(spinSubDeadTime, SIGNAL(valueChanged(double)), this,
|
||||
SLOT(SetSubDeadTime()));
|
||||
disconnect(comboSubDeadTimeUnit, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetSubDeadTime()));
|
||||
try {
|
||||
auto retval = det->getSubDeadTime().tsquash("Sub dead time is inconsistent for all detectors.");
|
||||
auto retval = det->getSubDeadTime().tsquash(
|
||||
"Sub dead time is inconsistent for all detectors.");
|
||||
auto time = qDefs::getUserFriendlyTime(retval);
|
||||
spinSubDeadTime->setValue(time.first);
|
||||
comboSubDeadTimeUnit->setCurrentIndex(
|
||||
static_cast<int>(time.second));
|
||||
} CATCH_DISPLAY ("Could not get sub dead time.",
|
||||
"qTabSettings::GetSubDeadTime")
|
||||
comboSubDeadTimeUnit->setCurrentIndex(static_cast<int>(time.second));
|
||||
}
|
||||
CATCH_DISPLAY("Could not get sub dead time.",
|
||||
"qTabSettings::GetSubDeadTime")
|
||||
connect(spinSubDeadTime, SIGNAL(valueChanged(double)), this,
|
||||
SLOT(SetSubDeadTime()));
|
||||
connect(comboSubDeadTimeUnit, SIGNAL(currentIndexChanged(int)), this,
|
||||
@ -608,22 +657,25 @@ void qTabAdvanced::GetSubDeadTime() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetSubDeadTime() {
|
||||
auto timeNS = qDefs::getNSTime(std::make_pair(spinSubDeadTime->value(), static_cast<qDefs::timeUnit>(comboSubDeadTimeUnit->currentIndex())));
|
||||
auto timeNS = qDefs::getNSTime(std::make_pair(
|
||||
spinSubDeadTime->value(),
|
||||
static_cast<qDefs::timeUnit>(comboSubDeadTimeUnit->currentIndex())));
|
||||
|
||||
FILE_LOG(logINFO)
|
||||
LOG(logINFO)
|
||||
<< "Setting sub frame dead time to " << timeNS.count() << " ns"
|
||||
<< "/" << spinSubDeadTime->value()
|
||||
<< qDefs::getUnitString(
|
||||
(qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex());
|
||||
try {
|
||||
det->setSubDeadTime(timeNS);
|
||||
} CATCH_DISPLAY ("Could not set sub dead time.",
|
||||
"qTabAdvanced::SetSubDeadTime")
|
||||
}
|
||||
CATCH_DISPLAY("Could not set sub dead time.",
|
||||
"qTabAdvanced::SetSubDeadTime")
|
||||
GetSubDeadTime();
|
||||
}
|
||||
|
||||
void qTabAdvanced::Refresh() {
|
||||
FILE_LOG(logDEBUG) << "**Updating Advanced Tab";
|
||||
LOG(logDEBUG) << "**Updating Advanced Tab";
|
||||
|
||||
// trimming
|
||||
if (tab_trimming->isEnabled()) {
|
||||
@ -649,5 +701,5 @@ void qTabAdvanced::Refresh() {
|
||||
GetSubDeadTime();
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG) << "**Updated Advanced Tab";
|
||||
LOG(logDEBUG) << "**Updated Advanced Tab";
|
||||
}
|
||||
|
590
slsDetectorGui/src/qTabDataOutput.cpp
Executable file → Normal file
590
slsDetectorGui/src/qTabDataOutput.cpp
Executable file → Normal file
@ -1,343 +1,431 @@
|
||||
#include "qTabDataOutput.h"
|
||||
#include "qDefs.h"
|
||||
|
||||
#include <QButtonGroup>
|
||||
#include <QFileDialog>
|
||||
#include <QStandardItemModel>
|
||||
#include <QButtonGroup>
|
||||
#include <QString>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
qTabDataOutput::qTabDataOutput(QWidget *parent, sls::Detector *detector) : QWidget(parent), det(detector), btnGroupRate(nullptr) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logDEBUG) << "DataOutput ready";
|
||||
qTabDataOutput::qTabDataOutput(QWidget *parent, sls::Detector *detector)
|
||||
: QWidget(parent), det(detector), btnGroupRate(nullptr) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
LOG(logDEBUG) << "DataOutput ready";
|
||||
}
|
||||
|
||||
qTabDataOutput::~qTabDataOutput() {
|
||||
if (btnGroupRate)
|
||||
delete btnGroupRate;
|
||||
}
|
||||
qTabDataOutput::~qTabDataOutput() { delete btnGroupRate; }
|
||||
|
||||
void qTabDataOutput::SetupWidgetWindow() {
|
||||
// button group for rate
|
||||
btnGroupRate = new QButtonGroup(this);
|
||||
btnGroupRate->addButton(radioDefaultDeadtime, 0);
|
||||
btnGroupRate->addButton(radioCustomDeadtime, 1);
|
||||
// button group for rate
|
||||
btnGroupRate = new QButtonGroup(this);
|
||||
btnGroupRate->addButton(radioDefaultDeadtime, 0);
|
||||
btnGroupRate->addButton(radioCustomDeadtime, 1);
|
||||
|
||||
// enabling according to det type
|
||||
switch(det->getDetectorType().squash()) {
|
||||
case slsDetectorDefs::EIGER:
|
||||
chkTenGiga->setEnabled(true);
|
||||
chkRate->setEnabled(true);
|
||||
radioDefaultDeadtime->setEnabled(true);
|
||||
radioCustomDeadtime->setEnabled(true);
|
||||
// flags and speed
|
||||
widgetEiger->setVisible(true);
|
||||
widgetEiger->setEnabled(true);
|
||||
break;
|
||||
case slsDetectorDefs::MOENCH:
|
||||
chkTenGiga->setEnabled(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
PopulateDetectors();
|
||||
// enabling according to det type
|
||||
switch (det->getDetectorType().squash()) {
|
||||
case slsDetectorDefs::EIGER:
|
||||
chkTenGiga->setEnabled(true);
|
||||
chkRate->setEnabled(true);
|
||||
radioDefaultDeadtime->setEnabled(true);
|
||||
radioCustomDeadtime->setEnabled(true);
|
||||
// flags and speed
|
||||
widgetEiger->setVisible(true);
|
||||
widgetEiger->setEnabled(true);
|
||||
break;
|
||||
case slsDetectorDefs::MOENCH:
|
||||
chkTenGiga->setEnabled(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
PopulateDetectors();
|
||||
|
||||
Initialization();
|
||||
Initialization();
|
||||
|
||||
Refresh();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void qTabDataOutput::Initialization() {
|
||||
// ourdir, fileformat, overwrite enable
|
||||
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir()));
|
||||
connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir()));
|
||||
connect(btnOutputBrowse, SIGNAL(clicked()), this, SLOT(BrowseOutputDir()));
|
||||
connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int)));
|
||||
connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool)));
|
||||
if (chkTenGiga->isEnabled()) {
|
||||
connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool)));
|
||||
}
|
||||
// rate
|
||||
if (chkRate->isEnabled()) {
|
||||
connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection()));
|
||||
connect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection()));
|
||||
connect(spinCustomDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
|
||||
}
|
||||
// flags, speed
|
||||
if (widgetEiger->isEnabled()) {
|
||||
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int)));
|
||||
connect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags()));
|
||||
}
|
||||
// ourdir, fileformat, overwrite enable
|
||||
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(GetOutputDir()));
|
||||
connect(dispOutputDir, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetOutputDir()));
|
||||
connect(btnOutputBrowse, SIGNAL(clicked()), this, SLOT(BrowseOutputDir()));
|
||||
connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetFileFormat(int)));
|
||||
connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this,
|
||||
SLOT(SetOverwriteEnable(bool)));
|
||||
if (chkTenGiga->isEnabled()) {
|
||||
connect(chkTenGiga, SIGNAL(toggled(bool)), this,
|
||||
SLOT(SetTenGigaEnable(bool)));
|
||||
}
|
||||
// rate
|
||||
if (chkRate->isEnabled()) {
|
||||
connect(chkRate, SIGNAL(toggled(bool)), this,
|
||||
SLOT(EnableRateCorrection()));
|
||||
connect(btnGroupRate, SIGNAL(buttonClicked(int)), this,
|
||||
SLOT(SetRateCorrection()));
|
||||
connect(spinCustomDeadTime, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetRateCorrection()));
|
||||
}
|
||||
// flags, speed
|
||||
if (widgetEiger->isEnabled()) {
|
||||
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetSpeed(int)));
|
||||
connect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetFlags()));
|
||||
}
|
||||
}
|
||||
|
||||
void qTabDataOutput::PopulateDetectors() {
|
||||
FILE_LOG(logDEBUG) << "Populating detectors";
|
||||
LOG(logDEBUG) << "Populating detectors";
|
||||
|
||||
comboDetector->clear();
|
||||
comboDetector->addItem("All");
|
||||
if (det->size() > 1) {
|
||||
auto res = det->getHostname();
|
||||
for (auto &it : res) {
|
||||
comboDetector->addItem(QString(it.c_str()));
|
||||
}
|
||||
}
|
||||
comboDetector->clear();
|
||||
comboDetector->addItem("All");
|
||||
if (det->size() > 1) {
|
||||
auto res = det->getHostname();
|
||||
for (auto &it : res) {
|
||||
comboDetector->addItem(QString(it.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void qTabDataOutput::EnableBrowse() {
|
||||
FILE_LOG(logDEBUG) << "Getting browse enable";
|
||||
try {
|
||||
btnOutputBrowse->setEnabled(false); // exception default
|
||||
std::string rxHostname = det->getRxHostname({comboDetector->currentIndex() - 1}).squash("none");
|
||||
if (rxHostname == "none") {
|
||||
btnOutputBrowse->setEnabled(false);
|
||||
} else if (rxHostname == "localhost") {
|
||||
btnOutputBrowse->setEnabled(true);
|
||||
} else {
|
||||
std::string hostname;
|
||||
const size_t len = 15;
|
||||
char host[len]{};
|
||||
if (gethostname(host, len) == 0) {
|
||||
hostname.assign(host);
|
||||
}
|
||||
// client pc (hostname) same as reciever hostname
|
||||
if (hostname == rxHostname) {
|
||||
btnOutputBrowse->setEnabled(true);
|
||||
} else {
|
||||
btnOutputBrowse->setEnabled(false);
|
||||
}
|
||||
}
|
||||
} CATCH_DISPLAY ("Could not get receiver hostname.", "qTabDataOutput::EnableBrowse")
|
||||
LOG(logDEBUG) << "Getting browse enable";
|
||||
try {
|
||||
btnOutputBrowse->setEnabled(false); // exception default
|
||||
std::string rxHostname =
|
||||
det->getRxHostname({comboDetector->currentIndex() - 1})
|
||||
.squash("none");
|
||||
if (rxHostname == "none") {
|
||||
btnOutputBrowse->setEnabled(false);
|
||||
} else if (rxHostname == "localhost") {
|
||||
btnOutputBrowse->setEnabled(true);
|
||||
} else {
|
||||
std::string hostname;
|
||||
const size_t len = 15;
|
||||
char host[len]{};
|
||||
if (gethostname(host, len) == 0) {
|
||||
hostname.assign(host);
|
||||
}
|
||||
// client pc (hostname) same as reciever hostname
|
||||
if (hostname == rxHostname) {
|
||||
btnOutputBrowse->setEnabled(true);
|
||||
} else {
|
||||
btnOutputBrowse->setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
CATCH_DISPLAY("Could not get receiver hostname.",
|
||||
"qTabDataOutput::EnableBrowse")
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetFileWrite() {
|
||||
FILE_LOG(logDEBUG) << "Getting file write enable";
|
||||
try {
|
||||
boxFileWriteEnabled->setEnabled(true); // exception default
|
||||
auto retval = det->getFileWrite().tsquash("File write is inconsistent for all detectors.");
|
||||
boxFileWriteEnabled->setEnabled(retval);
|
||||
} CATCH_DISPLAY("Could not get file enable.", "qTabDataOutput::GetFileWrite")
|
||||
LOG(logDEBUG) << "Getting file write enable";
|
||||
try {
|
||||
boxFileWriteEnabled->setEnabled(true); // exception default
|
||||
auto retval = det->getFileWrite().tsquash(
|
||||
"File write is inconsistent for all detectors.");
|
||||
boxFileWriteEnabled->setEnabled(retval);
|
||||
}
|
||||
CATCH_DISPLAY("Could not get file enable.", "qTabDataOutput::GetFileWrite")
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetFileName() {
|
||||
FILE_LOG(logDEBUG) << "Getting file name";
|
||||
try {
|
||||
auto retval = det->getFileNamePrefix().tsquash("File name is inconsistent for all detectors.");
|
||||
dispFileName->setText(QString(retval.c_str()));
|
||||
} CATCH_DISPLAY ("Could not get file name prefix.", "qTabDataOutput::GetFileName")
|
||||
LOG(logDEBUG) << "Getting file name";
|
||||
try {
|
||||
auto retval = det->getFileNamePrefix().tsquash(
|
||||
"File name is inconsistent for all detectors.");
|
||||
dispFileName->setText(QString(retval.c_str()));
|
||||
}
|
||||
CATCH_DISPLAY("Could not get file name prefix.",
|
||||
"qTabDataOutput::GetFileName")
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetOutputDir() {
|
||||
FILE_LOG(logDEBUG) << "Getting file path";
|
||||
disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir()));
|
||||
try {
|
||||
std::string path = det->getFilePath({comboDetector->currentIndex() - 1}).tsquash("File path is different for all detectors.");
|
||||
dispOutputDir->setText(QString(path.c_str()));
|
||||
} CATCH_DISPLAY ("Could not get file path.", "qTabDataOutput::GetOutputDir")
|
||||
connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir()));
|
||||
LOG(logDEBUG) << "Getting file path";
|
||||
disconnect(dispOutputDir, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetOutputDir()));
|
||||
try {
|
||||
std::string path =
|
||||
det->getFilePath({comboDetector->currentIndex() - 1})
|
||||
.tsquash("File path is different for all detectors.");
|
||||
dispOutputDir->setText(QString(path.c_str()));
|
||||
}
|
||||
CATCH_DISPLAY("Could not get file path.", "qTabDataOutput::GetOutputDir")
|
||||
connect(dispOutputDir, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetOutputDir()));
|
||||
}
|
||||
|
||||
void qTabDataOutput::BrowseOutputDir() {
|
||||
FILE_LOG(logDEBUG) << "Browsing output directory";
|
||||
QString directory = QFileDialog::getExistingDirectory(this, tr("Choose Output Directory "), dispOutputDir->text());
|
||||
if (!directory.isEmpty())
|
||||
dispOutputDir->setText(directory);
|
||||
LOG(logDEBUG) << "Browsing output directory";
|
||||
QString directory = QFileDialog::getExistingDirectory(
|
||||
this, tr("Choose Output Directory "), dispOutputDir->text());
|
||||
if (!directory.isEmpty())
|
||||
dispOutputDir->setText(directory);
|
||||
}
|
||||
|
||||
void qTabDataOutput::SetOutputDir() {
|
||||
QString path = dispOutputDir->text();
|
||||
FILE_LOG(logDEBUG) << "Setting output directory to " << path.toAscii().constData();
|
||||
QString path = dispOutputDir->text();
|
||||
LOG(logDEBUG) << "Setting output directory to "
|
||||
<< path.toAscii().constData();
|
||||
|
||||
// empty
|
||||
if (path.isEmpty()) {
|
||||
qDefs::Message(qDefs::WARNING, "Invalid Output Path. Must not be empty.", "qTabDataOutput::SetOutputDir");
|
||||
FILE_LOG(logWARNING) << "Invalid Output Path. Must not be empty.";
|
||||
GetOutputDir();
|
||||
} else {
|
||||
// chop off trailing '/'
|
||||
if (path.endsWith('/')) {
|
||||
while (path.endsWith('/')) {
|
||||
path.chop(1);
|
||||
}
|
||||
}
|
||||
std::string spath = std::string(path.toAscii().constData());
|
||||
try {
|
||||
det->setFilePath(spath, {comboDetector->currentIndex() - 1});
|
||||
} CATCH_HANDLE ("Could not set output file path.", "qTabDataOutput::SetOutputDir", this, &qTabDataOutput::GetOutputDir)
|
||||
}
|
||||
// empty
|
||||
if (path.isEmpty()) {
|
||||
qDefs::Message(qDefs::WARNING,
|
||||
"Invalid Output Path. Must not be empty.",
|
||||
"qTabDataOutput::SetOutputDir");
|
||||
LOG(logWARNING) << "Invalid Output Path. Must not be empty.";
|
||||
GetOutputDir();
|
||||
} else {
|
||||
// chop off trailing '/'
|
||||
if (path.endsWith('/')) {
|
||||
while (path.endsWith('/')) {
|
||||
path.chop(1);
|
||||
}
|
||||
}
|
||||
std::string spath = std::string(path.toAscii().constData());
|
||||
try {
|
||||
det->setFilePath(spath, {comboDetector->currentIndex() - 1});
|
||||
}
|
||||
CATCH_HANDLE("Could not set output file path.",
|
||||
"qTabDataOutput::SetOutputDir", this,
|
||||
&qTabDataOutput::GetOutputDir)
|
||||
}
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetFileFormat() {
|
||||
FILE_LOG(logDEBUG) << "Getting File Format";
|
||||
disconnect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int)));
|
||||
try {
|
||||
auto retval = det->getFileFormat().tsquash("File format is inconsistent for all detectors.");
|
||||
switch(retval) {
|
||||
case slsDetectorDefs::BINARY:
|
||||
case slsDetectorDefs::HDF5:
|
||||
comboFileFormat->setCurrentIndex(static_cast<int>(retval));
|
||||
break;
|
||||
default:
|
||||
throw sls::RuntimeError(std::string("Unknown file format: ") + std::to_string(static_cast<int>(retval)));
|
||||
LOG(logDEBUG) << "Getting File Format";
|
||||
disconnect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetFileFormat(int)));
|
||||
try {
|
||||
auto retval = det->getFileFormat().tsquash(
|
||||
"File format is inconsistent for all detectors.");
|
||||
switch (retval) {
|
||||
case slsDetectorDefs::BINARY:
|
||||
case slsDetectorDefs::HDF5:
|
||||
comboFileFormat->setCurrentIndex(static_cast<int>(retval));
|
||||
break;
|
||||
default:
|
||||
throw sls::RuntimeError(std::string("Unknown file format: ") +
|
||||
std::to_string(static_cast<int>(retval)));
|
||||
}
|
||||
} CATCH_DISPLAY("Could not get file format.", "qTabDataOutput::GetFileFormat")
|
||||
connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int)));
|
||||
}
|
||||
CATCH_DISPLAY("Could not get file format.", "qTabDataOutput::GetFileFormat")
|
||||
connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetFileFormat(int)));
|
||||
}
|
||||
|
||||
void qTabDataOutput::SetFileFormat(int format) {
|
||||
FILE_LOG(logINFO) << "Setting File Format to " << comboFileFormat->currentText().toAscii().data();
|
||||
try {
|
||||
det->setFileFormat(static_cast<slsDetectorDefs::fileFormat>(comboFileFormat->currentIndex()));
|
||||
} CATCH_HANDLE ("Could not set file format.", "qTabDataOutput::SetFileFormat", this, &qTabDataOutput::GetFileFormat)
|
||||
LOG(logINFO) << "Setting File Format to "
|
||||
<< comboFileFormat->currentText().toAscii().data();
|
||||
try {
|
||||
det->setFileFormat(static_cast<slsDetectorDefs::fileFormat>(
|
||||
comboFileFormat->currentIndex()));
|
||||
}
|
||||
CATCH_HANDLE("Could not set file format.", "qTabDataOutput::SetFileFormat",
|
||||
this, &qTabDataOutput::GetFileFormat)
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetFileOverwrite() {
|
||||
FILE_LOG(logDEBUG) << "Getting File Over Write Enable";
|
||||
disconnect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool)));
|
||||
try {
|
||||
auto retval = det->getFileOverWrite().tsquash("File over write is inconsistent for all detectors.");
|
||||
chkOverwriteEnable->setChecked(retval);
|
||||
} CATCH_DISPLAY ("Could not get file over write enable.", "qTabDataOutput::GetFileOverwrite")
|
||||
LOG(logDEBUG) << "Getting File Over Write Enable";
|
||||
disconnect(chkOverwriteEnable, SIGNAL(toggled(bool)), this,
|
||||
SLOT(SetOverwriteEnable(bool)));
|
||||
try {
|
||||
auto retval = det->getFileOverWrite().tsquash(
|
||||
"File over write is inconsistent for all detectors.");
|
||||
chkOverwriteEnable->setChecked(retval);
|
||||
}
|
||||
CATCH_DISPLAY("Could not get file over write enable.",
|
||||
"qTabDataOutput::GetFileOverwrite")
|
||||
|
||||
connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool)));
|
||||
connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this,
|
||||
SLOT(SetOverwriteEnable(bool)));
|
||||
}
|
||||
|
||||
void qTabDataOutput::SetOverwriteEnable(bool enable) {
|
||||
FILE_LOG(logINFO) << "Setting File Over Write Enable to " << enable;
|
||||
try {
|
||||
LOG(logINFO) << "Setting File Over Write Enable to " << enable;
|
||||
try {
|
||||
det->setFileOverWrite(enable);
|
||||
} CATCH_HANDLE ("Could not set file over write enable.", "qTabDataOutput::SetOverwriteEnable", this, &qTabDataOutput::GetFileOverwrite)
|
||||
}
|
||||
CATCH_HANDLE("Could not set file over write enable.",
|
||||
"qTabDataOutput::SetOverwriteEnable", this,
|
||||
&qTabDataOutput::GetFileOverwrite)
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetTenGigaEnable() {
|
||||
FILE_LOG(logDEBUG) << "Getting 10GbE enable";
|
||||
disconnect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool)));
|
||||
try {
|
||||
auto retval = det->getTenGiga().tsquash("10GbE enable is inconsistent for all detectors.");
|
||||
chkTenGiga->setChecked(retval);
|
||||
} CATCH_DISPLAY ("Could not get 10GbE enable.", "qTabDataOutput::GetTenGigaEnable")
|
||||
connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool)));
|
||||
LOG(logDEBUG) << "Getting 10GbE enable";
|
||||
disconnect(chkTenGiga, SIGNAL(toggled(bool)), this,
|
||||
SLOT(SetTenGigaEnable(bool)));
|
||||
try {
|
||||
auto retval = det->getTenGiga().tsquash(
|
||||
"10GbE enable is inconsistent for all detectors.");
|
||||
chkTenGiga->setChecked(retval);
|
||||
}
|
||||
CATCH_DISPLAY("Could not get 10GbE enable.",
|
||||
"qTabDataOutput::GetTenGigaEnable")
|
||||
connect(chkTenGiga, SIGNAL(toggled(bool)), this,
|
||||
SLOT(SetTenGigaEnable(bool)));
|
||||
}
|
||||
|
||||
void qTabDataOutput::SetTenGigaEnable(bool enable) {
|
||||
FILE_LOG(logINFO) << "Setting 10GbE to " << enable;
|
||||
try {
|
||||
LOG(logINFO) << "Setting 10GbE to " << enable;
|
||||
try {
|
||||
det->setTenGiga(enable);
|
||||
} CATCH_HANDLE ("Could not set 10GbE enable.", "qTabDataOutput::SetTenGigaEnable", this, &qTabDataOutput::GetTenGigaEnable)
|
||||
}
|
||||
CATCH_HANDLE("Could not set 10GbE enable.",
|
||||
"qTabDataOutput::SetTenGigaEnable", this,
|
||||
&qTabDataOutput::GetTenGigaEnable)
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetRateCorrection() {
|
||||
FILE_LOG(logDEBUG) << "Getting Rate Correction";
|
||||
disconnect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection()));
|
||||
disconnect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection()));
|
||||
disconnect(spinCustomDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
|
||||
try {
|
||||
spinCustomDeadTime->setValue(-1);
|
||||
int64_t retval = det->getRateCorrection().tsquash("Rate correction (enable/tau) is inconsistent for all detectors.").count();
|
||||
chkRate->setChecked(retval == 0 ? false : true);
|
||||
if (retval != 0)
|
||||
spinCustomDeadTime->setValue(retval);
|
||||
} CATCH_DISPLAY("Could not get rate correction.", "qTabDataOutput::GetRateCorrection")
|
||||
connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection()));
|
||||
connect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection()));
|
||||
connect(spinCustomDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
|
||||
LOG(logDEBUG) << "Getting Rate Correction";
|
||||
disconnect(chkRate, SIGNAL(toggled(bool)), this,
|
||||
SLOT(EnableRateCorrection()));
|
||||
disconnect(btnGroupRate, SIGNAL(buttonClicked(int)), this,
|
||||
SLOT(SetRateCorrection()));
|
||||
disconnect(spinCustomDeadTime, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetRateCorrection()));
|
||||
try {
|
||||
spinCustomDeadTime->setValue(-1);
|
||||
int64_t retval = det->getRateCorrection()
|
||||
.tsquash("Rate correction (enable/tau) is "
|
||||
"inconsistent for all detectors.")
|
||||
.count();
|
||||
chkRate->setChecked(retval == 0 ? false : true);
|
||||
if (retval != 0)
|
||||
spinCustomDeadTime->setValue(retval);
|
||||
}
|
||||
CATCH_DISPLAY("Could not get rate correction.",
|
||||
"qTabDataOutput::GetRateCorrection")
|
||||
connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection()));
|
||||
connect(btnGroupRate, SIGNAL(buttonClicked(int)), this,
|
||||
SLOT(SetRateCorrection()));
|
||||
connect(spinCustomDeadTime, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetRateCorrection()));
|
||||
}
|
||||
|
||||
void qTabDataOutput::EnableRateCorrection() {
|
||||
// enable
|
||||
if (chkRate->isChecked()) {
|
||||
SetRateCorrection();
|
||||
return;
|
||||
}
|
||||
FILE_LOG(logINFO) << "Disabling Rate correction";
|
||||
// disable
|
||||
try {
|
||||
det->setRateCorrection(sls::ns(0));
|
||||
} CATCH_HANDLE ("Could not switch off rate correction.", "qTabDataOutput::EnableRateCorrection", this, &qTabDataOutput::GetRateCorrection)
|
||||
// enable
|
||||
if (chkRate->isChecked()) {
|
||||
SetRateCorrection();
|
||||
return;
|
||||
}
|
||||
LOG(logINFO) << "Disabling Rate correction";
|
||||
// disable
|
||||
try {
|
||||
det->setRateCorrection(sls::ns(0));
|
||||
}
|
||||
CATCH_HANDLE("Could not switch off rate correction.",
|
||||
"qTabDataOutput::EnableRateCorrection", this,
|
||||
&qTabDataOutput::GetRateCorrection)
|
||||
}
|
||||
|
||||
void qTabDataOutput::SetRateCorrection() {
|
||||
// do nothing if rate correction is disabled
|
||||
if (!chkRate->isChecked()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// custom dead time
|
||||
if (radioCustomDeadtime->isChecked()) {
|
||||
int64_t deadtime = spinCustomDeadTime->value();
|
||||
FILE_LOG(logINFO) << "Setting Rate Correction with custom dead time: " << deadtime;
|
||||
det->setRateCorrection(sls::ns(deadtime));
|
||||
}
|
||||
// default dead time
|
||||
else {
|
||||
FILE_LOG(logINFO) << "Setting Rate Correction with default dead time";
|
||||
det->setDefaultRateCorrection();
|
||||
}
|
||||
} CATCH_HANDLE ("Could not set rate correction.", "qTabDataOutput::SetRateCorrection", this, &qTabDataOutput::GetRateCorrection)
|
||||
// do nothing if rate correction is disabled
|
||||
if (!chkRate->isChecked()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// custom dead time
|
||||
if (radioCustomDeadtime->isChecked()) {
|
||||
int64_t deadtime = spinCustomDeadTime->value();
|
||||
LOG(logINFO)
|
||||
<< "Setting Rate Correction with custom dead time: "
|
||||
<< deadtime;
|
||||
det->setRateCorrection(sls::ns(deadtime));
|
||||
}
|
||||
// default dead time
|
||||
else {
|
||||
LOG(logINFO)
|
||||
<< "Setting Rate Correction with default dead time";
|
||||
det->setDefaultRateCorrection();
|
||||
}
|
||||
}
|
||||
CATCH_HANDLE("Could not set rate correction.",
|
||||
"qTabDataOutput::SetRateCorrection", this,
|
||||
&qTabDataOutput::GetRateCorrection)
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetSpeed() {
|
||||
FILE_LOG(logDEBUG) << "Getting Speed";
|
||||
disconnect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int)));
|
||||
try {
|
||||
auto retval = det->getSpeed().tsquash("Speed is inconsistent for all detectors.");
|
||||
comboEigerClkDivider->setCurrentIndex(static_cast<int>(retval));
|
||||
} CATCH_DISPLAY ("Could not get speed.", "qTabDataOutput::GetSpeed")
|
||||
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int)));
|
||||
LOG(logDEBUG) << "Getting Speed";
|
||||
disconnect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetSpeed(int)));
|
||||
try {
|
||||
auto retval =
|
||||
det->getSpeed().tsquash("Speed is inconsistent for all detectors.");
|
||||
comboEigerClkDivider->setCurrentIndex(static_cast<int>(retval));
|
||||
}
|
||||
CATCH_DISPLAY("Could not get speed.", "qTabDataOutput::GetSpeed")
|
||||
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetSpeed(int)));
|
||||
}
|
||||
|
||||
void qTabDataOutput::SetSpeed(int speed) {
|
||||
FILE_LOG(logINFO) << "Setting Speed to " << comboEigerClkDivider->currentText().toAscii().data();;
|
||||
try {
|
||||
LOG(logINFO) << "Setting Speed to "
|
||||
<< comboEigerClkDivider->currentText().toAscii().data();
|
||||
;
|
||||
try {
|
||||
det->setSpeed(static_cast<slsDetectorDefs::speedLevel>(speed));
|
||||
} CATCH_HANDLE ("Could not set speed.", "qTabDataOutput::SetSpeed", this, &qTabDataOutput::GetSpeed)
|
||||
}
|
||||
CATCH_HANDLE("Could not set speed.", "qTabDataOutput::SetSpeed", this,
|
||||
&qTabDataOutput::GetSpeed)
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetFlags() {
|
||||
FILE_LOG(logDEBUG) << "Getting readout flags";
|
||||
disconnect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags()));
|
||||
try {
|
||||
auto retval = det->getParallelMode().tsquash("Parallel Flag is inconsistent for all detectors.");
|
||||
// parallel or non parallel
|
||||
if (retval)
|
||||
comboEigerParallelFlag->setCurrentIndex(PARALLEL);
|
||||
else
|
||||
comboEigerParallelFlag->setCurrentIndex(NONPARALLEL);
|
||||
} CATCH_DISPLAY ("Could not get flags.", "qTabDataOutput::GetFlags")
|
||||
connect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags()));
|
||||
LOG(logDEBUG) << "Getting readout flags";
|
||||
disconnect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetFlags()));
|
||||
try {
|
||||
auto retval = det->getParallelMode().tsquash(
|
||||
"Parallel Flag is inconsistent for all detectors.");
|
||||
// parallel or non parallel
|
||||
if (retval)
|
||||
comboEigerParallelFlag->setCurrentIndex(PARALLEL);
|
||||
else
|
||||
comboEigerParallelFlag->setCurrentIndex(NONPARALLEL);
|
||||
}
|
||||
CATCH_DISPLAY("Could not get flags.", "qTabDataOutput::GetFlags")
|
||||
connect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetFlags()));
|
||||
}
|
||||
|
||||
|
||||
void qTabDataOutput::SetFlags() {
|
||||
auto mode = comboEigerParallelFlag->currentIndex() == PARALLEL ? true : false;
|
||||
try {
|
||||
FILE_LOG(logINFO) << "Setting Readout Flags to " << comboEigerParallelFlag->currentText().toAscii().data();
|
||||
det->setParallelMode(mode);
|
||||
} CATCH_HANDLE ("Could not set readout flags.", "qTabDataOutput::SetFlags", this, &qTabDataOutput::GetFlags)
|
||||
auto mode =
|
||||
comboEigerParallelFlag->currentIndex() == PARALLEL ? true : false;
|
||||
try {
|
||||
LOG(logINFO)
|
||||
<< "Setting Readout Flags to "
|
||||
<< comboEigerParallelFlag->currentText().toAscii().data();
|
||||
det->setParallelMode(mode);
|
||||
}
|
||||
CATCH_HANDLE("Could not set readout flags.", "qTabDataOutput::SetFlags",
|
||||
this, &qTabDataOutput::GetFlags)
|
||||
}
|
||||
|
||||
void qTabDataOutput::Refresh() {
|
||||
FILE_LOG(logDEBUG) << "**Updating DataOutput Tab";
|
||||
LOG(logDEBUG) << "**Updating DataOutput Tab";
|
||||
|
||||
EnableBrowse();
|
||||
GetFileWrite();
|
||||
GetFileName();
|
||||
GetOutputDir();
|
||||
GetFileOverwrite();
|
||||
GetFileFormat();
|
||||
if (chkRate->isEnabled()) {
|
||||
GetRateCorrection();
|
||||
}
|
||||
if (chkTenGiga->isEnabled()) {
|
||||
GetTenGigaEnable();
|
||||
}
|
||||
if (widgetEiger->isEnabled()) {
|
||||
GetSpeed();
|
||||
GetFlags();
|
||||
}
|
||||
EnableBrowse();
|
||||
GetFileWrite();
|
||||
GetFileName();
|
||||
GetOutputDir();
|
||||
GetFileOverwrite();
|
||||
GetFileFormat();
|
||||
if (chkRate->isEnabled()) {
|
||||
GetRateCorrection();
|
||||
}
|
||||
if (chkTenGiga->isEnabled()) {
|
||||
GetTenGigaEnable();
|
||||
}
|
||||
if (widgetEiger->isEnabled()) {
|
||||
GetSpeed();
|
||||
GetFlags();
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG) << "**Updated DataOutput Tab";
|
||||
LOG(logDEBUG) << "**Updated DataOutput Tab";
|
||||
}
|
||||
|
158
slsDetectorGui/src/qTabDebugging.cpp
Executable file → Normal file
158
slsDetectorGui/src/qTabDebugging.cpp
Executable file → Normal file
@ -1,35 +1,28 @@
|
||||
#include "qTabDebugging.h"
|
||||
#include "qDefs.h"
|
||||
|
||||
#include "ToString.h"
|
||||
|
||||
#include <QDesktopWidget>
|
||||
#include <QGridLayout>
|
||||
#include <QTreeWidget>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
qTabDebugging::qTabDebugging(QWidget *parent, sls::Detector *detector) :
|
||||
QWidget(parent), det(detector), treeDet(nullptr), lblDetectorHostname(nullptr), lblDetectorFirmware(nullptr), lblDetectorSoftware(nullptr) {
|
||||
qTabDebugging::qTabDebugging(QWidget *parent, sls::Detector *detector)
|
||||
: QWidget(parent), det(detector), treeDet(nullptr),
|
||||
lblDetectorHostname(nullptr), lblDetectorFirmware(nullptr),
|
||||
lblDetectorSoftware(nullptr) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logDEBUG) << "Debugging ready";
|
||||
LOG(logDEBUG) << "Debugging ready";
|
||||
}
|
||||
|
||||
qTabDebugging::~qTabDebugging() {
|
||||
if (treeDet)
|
||||
delete treeDet;
|
||||
if (lblDetectorHostname)
|
||||
delete lblDetectorHostname;
|
||||
if (lblDetectorFirmware)
|
||||
delete lblDetectorFirmware;
|
||||
if (lblDetectorSoftware)
|
||||
delete lblDetectorSoftware;
|
||||
delete treeDet;
|
||||
delete lblDetectorHostname;
|
||||
delete lblDetectorFirmware;
|
||||
delete lblDetectorSoftware;
|
||||
}
|
||||
|
||||
|
||||
void qTabDebugging::SetupWidgetWindow() {
|
||||
// enabling according to det type
|
||||
// enabling according to det type
|
||||
if (det->getDetectorType().squash() == slsDetectorDefs::EIGER) {
|
||||
lblDetector->setText("Half Module:");
|
||||
chkDetectorFirmware->setEnabled(false);
|
||||
@ -44,19 +37,19 @@ void qTabDebugging::SetupWidgetWindow() {
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
||||
void qTabDebugging::Initialization() {
|
||||
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetDetectorStatus()));
|
||||
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(GetDetectorStatus()));
|
||||
connect(btnGetInfo, SIGNAL(clicked()), this, SLOT(GetInfo()));
|
||||
if (btnTest ->isEnabled()) {
|
||||
connect(btnTest, SIGNAL(clicked()), this, SLOT(TestDetector()));
|
||||
if (btnTest->isEnabled()) {
|
||||
connect(btnTest, SIGNAL(clicked()), this, SLOT(TestDetector()));
|
||||
}
|
||||
}
|
||||
|
||||
void qTabDebugging::PopulateDetectors() {
|
||||
FILE_LOG(logDEBUG) << "Populating detectors";
|
||||
LOG(logDEBUG) << "Populating detectors";
|
||||
|
||||
comboDetector->clear();
|
||||
comboDetector->clear();
|
||||
auto res = det->getHostname();
|
||||
for (auto &it : res) {
|
||||
comboDetector->addItem(QString(it.c_str()));
|
||||
@ -64,17 +57,19 @@ void qTabDebugging::PopulateDetectors() {
|
||||
}
|
||||
|
||||
void qTabDebugging::GetDetectorStatus() {
|
||||
FILE_LOG(logDEBUG) << "Getting Status";
|
||||
LOG(logDEBUG) << "Getting Status";
|
||||
|
||||
try {
|
||||
std::string status = sls::ToString(det->getDetectorStatus({comboDetector->currentIndex()})[0]);
|
||||
try {
|
||||
std::string status = sls::ToString(
|
||||
det->getDetectorStatus({comboDetector->currentIndex()})[0]);
|
||||
lblStatus->setText(QString(status.c_str()).toUpper());
|
||||
} CATCH_DISPLAY ("Could not get detector status.", "qTabDebugging::GetDetectorStatus")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get detector status.",
|
||||
"qTabDebugging::GetDetectorStatus")
|
||||
}
|
||||
|
||||
|
||||
void qTabDebugging::GetInfo() {
|
||||
FILE_LOG(logDEBUG) << "Getting Readout Info";
|
||||
LOG(logDEBUG) << "Getting Readout Info";
|
||||
|
||||
// open info in a new popup
|
||||
QFrame *popup1 = new QFrame(this, Qt::Popup | Qt::SubWindow);
|
||||
@ -87,67 +82,83 @@ void qTabDebugging::GetInfo() {
|
||||
lblDetectorHostname = new QLabel("");
|
||||
lblDetectorFirmware = new QLabel("");
|
||||
lblDetectorSoftware = new QLabel("");
|
||||
//to make sure the size is constant
|
||||
// to make sure the size is constant
|
||||
lblDetectorFirmware->setFixedWidth(100);
|
||||
layout->addWidget(dispFrame, 0, 1);
|
||||
QString detName = QString(sls::ToString(det->getDetectorType().squash()).c_str());
|
||||
QString detName =
|
||||
QString(sls::ToString(det->getDetectorType().squash()).c_str());
|
||||
|
||||
switch (det->getDetectorType().squash()) {
|
||||
|
||||
case slsDetectorDefs::EIGER:
|
||||
formLayout->addWidget(new QLabel("Half Module:"), 0, 0);
|
||||
formLayout->addItem(new QSpacerItem(15, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), 0, 1);
|
||||
formLayout->addItem(
|
||||
new QSpacerItem(15, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), 0,
|
||||
1);
|
||||
formLayout->addWidget(lblDetectorHostname, 0, 2);
|
||||
formLayout->addWidget(new QLabel("Half Module Firmware Version:"), 1, 0);
|
||||
formLayout->addWidget(new QLabel("Half Module Firmware Version:"), 1,
|
||||
0);
|
||||
formLayout->addWidget(lblDetectorFirmware, 1, 2);
|
||||
formLayout->addWidget(new QLabel("Half Module Software Version:"), 2, 0);
|
||||
formLayout->addWidget(new QLabel("Half Module Software Version:"), 2,
|
||||
0);
|
||||
formLayout->addWidget(lblDetectorSoftware, 2, 2);
|
||||
treeDet->setHeaderLabel("Eiger Detector");
|
||||
//get num modules
|
||||
// get num modules
|
||||
for (int i = 0; i < comboDetector->count() / 2; ++i)
|
||||
items.append(new QTreeWidgetItem((QTreeWidget *)0, QStringList(QString("Module %1").arg(i))));
|
||||
items.append(new QTreeWidgetItem(
|
||||
(QTreeWidget *)nullptr, QStringList(QString("Module %1").arg(i))));
|
||||
treeDet->insertTopLevelItems(0, items);
|
||||
//gets det names
|
||||
// gets det names
|
||||
for (int i = 0; i < comboDetector->count(); ++i) {
|
||||
QList<QTreeWidgetItem *> childItems;
|
||||
childItems.append(new QTreeWidgetItem((QTreeWidget *)0, QStringList(QString("Half Module (%1)").arg(comboDetector->itemText(i)))));
|
||||
childItems.append(new QTreeWidgetItem(
|
||||
(QTreeWidget *)nullptr,
|
||||
QStringList(QString("Half Module (%1)")
|
||||
.arg(comboDetector->itemText(i)))));
|
||||
treeDet->topLevelItem(i * 2)->insertChildren(0, childItems);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
formLayout->addWidget(new QLabel("Module:"), 0, 0);
|
||||
formLayout->addItem(new QSpacerItem(15, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), 0, 1);
|
||||
formLayout->addItem(
|
||||
new QSpacerItem(15, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), 0,
|
||||
1);
|
||||
formLayout->addWidget(lblDetectorHostname, 0, 2);
|
||||
formLayout->addWidget(new QLabel("Module Firmware Version:"), 1, 0);
|
||||
formLayout->addWidget(lblDetectorFirmware, 1, 2);
|
||||
formLayout->addWidget(new QLabel("Module Software Version:"), 2, 0);
|
||||
formLayout->addWidget(lblDetectorSoftware, 2, 2);
|
||||
treeDet->setHeaderLabel(QString(detName + " Detector"));
|
||||
//gets det names
|
||||
// gets det names
|
||||
for (int i = 0; i < comboDetector->count(); ++i)
|
||||
items.append(new QTreeWidgetItem((QTreeWidget *)0, QStringList(QString("Module (%1)").arg(comboDetector->itemText(i)))));
|
||||
items.append(new QTreeWidgetItem(
|
||||
(QTreeWidget *)nullptr,
|
||||
QStringList(
|
||||
QString("Module (%1)").arg(comboDetector->itemText(i)))));
|
||||
treeDet->insertTopLevelItems(0, items);
|
||||
break;
|
||||
}
|
||||
|
||||
//show and center widget
|
||||
// show and center widget
|
||||
int x = ((parentWidget()->width()) - (popup1->frameGeometry().width())) / 2;
|
||||
int y = ((parentWidget()->height()) - (popup1->frameGeometry().height())) / 2;
|
||||
int y =
|
||||
((parentWidget()->height()) - (popup1->frameGeometry().height())) / 2;
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
int screen = desktop->screenNumber(this);
|
||||
popup1->setWindowModality(Qt::WindowModal);
|
||||
popup1->move((desktop->screenGeometry(screen).x()) + x, (desktop->screenGeometry(screen).y()) + y);
|
||||
popup1->move((desktop->screenGeometry(screen).x()) + x,
|
||||
(desktop->screenGeometry(screen).y()) + y);
|
||||
popup1->show();
|
||||
|
||||
//put the first parameters
|
||||
// put the first parameters
|
||||
SetParameters(treeDet->topLevelItem(0));
|
||||
|
||||
// connect to slots
|
||||
connect(treeDet, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(SetParameters(QTreeWidgetItem *)));
|
||||
connect(treeDet, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this,
|
||||
SLOT(SetParameters(QTreeWidgetItem *)));
|
||||
}
|
||||
|
||||
|
||||
void qTabDebugging::SetParameters(QTreeWidgetItem *item) {
|
||||
// eiger: if half module clicked, others: true always
|
||||
bool ignoreOrHalfModuleClicked = true;
|
||||
@ -164,16 +175,22 @@ void qTabDebugging::SetParameters(QTreeWidgetItem *item) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
auto retval = std::string("0x") + std::to_string((unsigned long)det->getFirmwareVersion({comboDetector->currentIndex()})[0]);
|
||||
auto retval = std::string("0x") +
|
||||
std::to_string((unsigned long)det->getFirmwareVersion(
|
||||
{comboDetector->currentIndex()})[0]);
|
||||
lblDetectorFirmware->setText(QString(retval.c_str()));
|
||||
retval = std::string("0x") + std::to_string((unsigned long)det->getDetectorServerVersion({comboDetector->currentIndex()})[0]);
|
||||
retval =
|
||||
std::string("0x") +
|
||||
std::to_string((unsigned long)det->getDetectorServerVersion(
|
||||
{comboDetector->currentIndex()})[0]);
|
||||
lblDetectorSoftware->setText(QString(retval.c_str()));
|
||||
} CATCH_DISPLAY ("Could not get versions.", "qTabDebugging::SetParameters")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get versions.", "qTabDebugging::SetParameters")
|
||||
}
|
||||
}
|
||||
|
||||
void qTabDebugging::TestDetector() {
|
||||
FILE_LOG(logINFO) << "Testing Readout";
|
||||
LOG(logINFO) << "Testing Readout";
|
||||
|
||||
try {
|
||||
QString moduleName = "Module";
|
||||
@ -182,35 +199,42 @@ void qTabDebugging::TestDetector() {
|
||||
}
|
||||
|
||||
// construct message
|
||||
QString message = QString("<nobr>Test Results for %1:</nobr><br><br>").arg(comboDetector->currentText());
|
||||
QString message = QString("<nobr>Test Results for %1:</nobr><br><br>")
|
||||
.arg(comboDetector->currentText());
|
||||
|
||||
//detector firmware
|
||||
// detector firmware
|
||||
if (chkDetectorFirmware->isChecked()) {
|
||||
try {
|
||||
det->executeFirmwareTest({comboDetector->currentIndex()});
|
||||
message.append(QString("<nobr>%1 Firmware: PASS</nobr><br>").arg(moduleName));
|
||||
FILE_LOG(logINFO) << "Detector Firmware Test: Pass";
|
||||
} CATCH_DISPLAY ("Firmware test failed.", "qTabDebugging::TestDetector")
|
||||
message.append(QString("<nobr>%1 Firmware: PASS</nobr><br>")
|
||||
.arg(moduleName));
|
||||
LOG(logINFO) << "Detector Firmware Test: Pass";
|
||||
}
|
||||
CATCH_DISPLAY("Firmware test failed.",
|
||||
"qTabDebugging::TestDetector")
|
||||
}
|
||||
|
||||
//detector CPU-FPGA bus
|
||||
// detector CPU-FPGA bus
|
||||
if (chkDetectorBus->isChecked()) {
|
||||
try {
|
||||
det->executeBusTest({comboDetector->currentIndex()});
|
||||
message.append(QString("<nobr>%1 Bus: PASS</nobr><br>").arg(moduleName));
|
||||
FILE_LOG(logINFO) << "Detector Bus Test: Pass";
|
||||
} CATCH_DISPLAY ("Bus test failed.", "qTabDebugging::TestDetector")
|
||||
message.append(
|
||||
QString("<nobr>%1 Bus: PASS</nobr><br>").arg(moduleName));
|
||||
LOG(logINFO) << "Detector Bus Test: Pass";
|
||||
}
|
||||
CATCH_DISPLAY("Bus test failed.", "qTabDebugging::TestDetector")
|
||||
}
|
||||
|
||||
//display message
|
||||
qDefs::Message(qDefs::INFORMATION, message.toAscii().constData(), "qTabDebugging::TestDetector");
|
||||
} CATCH_DISPLAY ("Could not execute digital test.", "qTabDebugging::TestDetector")
|
||||
// display message
|
||||
qDefs::Message(qDefs::INFORMATION, message.toAscii().constData(),
|
||||
"qTabDebugging::TestDetector");
|
||||
}
|
||||
CATCH_DISPLAY("Could not execute digital test.",
|
||||
"qTabDebugging::TestDetector")
|
||||
}
|
||||
|
||||
|
||||
void qTabDebugging::Refresh() {
|
||||
FILE_LOG(logDEBUG) << "**Updating Debugging Tab";
|
||||
LOG(logDEBUG) << "**Updating Debugging Tab";
|
||||
GetDetectorStatus();
|
||||
FILE_LOG(logDEBUG) << "**Updated Debugging Tab";
|
||||
LOG(logDEBUG) << "**Updated Debugging Tab";
|
||||
}
|
||||
|
||||
|
978
slsDetectorGui/src/qTabDeveloper.cpp
Executable file → Normal file
978
slsDetectorGui/src/qTabDeveloper.cpp
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
1215
slsDetectorGui/src/qTabMeasurement.cpp
Executable file → Normal file
1215
slsDetectorGui/src/qTabMeasurement.cpp
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
87
slsDetectorGui/src/qTabMessages.cpp
Executable file → Normal file
87
slsDetectorGui/src/qTabMessages.cpp
Executable file → Normal file
@ -1,26 +1,23 @@
|
||||
#include "qTabMessages.h"
|
||||
#include "qDefs.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QTextStream>
|
||||
#include <QDir>
|
||||
#include <QProcess>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include <iostream>
|
||||
#include <QProcess>
|
||||
#include <QTextStream>
|
||||
#include <string>
|
||||
|
||||
qTabMessages::qTabMessages(QWidget *parent) : QWidget(parent) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logDEBUG) << "Messages ready";
|
||||
LOG(logDEBUG) << "Messages ready";
|
||||
}
|
||||
|
||||
qTabMessages::~qTabMessages() {
|
||||
process->close();
|
||||
if (process)
|
||||
delete process;
|
||||
delete process;
|
||||
}
|
||||
|
||||
void qTabMessages::SetupWidgetWindow() {
|
||||
@ -38,32 +35,32 @@ void qTabMessages::Initialization() {
|
||||
connect(dispCommand, SIGNAL(returnPressed()), this, SLOT(ExecuteCommand()));
|
||||
}
|
||||
|
||||
void qTabMessages::keyPressEvent(QKeyEvent* event) {
|
||||
//cout<<"inside KeyPressEvent()\n";
|
||||
if (event->key() == Qt::Key_Up) {
|
||||
void qTabMessages::keyPressEvent(QKeyEvent *event) {
|
||||
// cout<<"inside KeyPressEvent()\n";
|
||||
if (event->key() == Qt::Key_Up) {
|
||||
GetLastCommand();
|
||||
}
|
||||
else if (event->key() == Qt::Key_Down) {
|
||||
} else if (event->key() == Qt::Key_Down) {
|
||||
ClearCommand();
|
||||
}
|
||||
/* else if((event->key() == Qt::Key_Return) ||(event->key() == Qt::Key_Enter)) {
|
||||
ExecuteCommand();
|
||||
}*/ else {
|
||||
event->ignore();
|
||||
}
|
||||
/* else if((event->key() == Qt::Key_Return) ||(event->key() ==
|
||||
Qt::Key_Enter)) { ExecuteCommand();
|
||||
}*/
|
||||
else {
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void qTabMessages::PrintNextLine() {
|
||||
dispLog->append(QString("<font color = \"DarkGrey\">") + QDir::current().dirName() + QString("$ ") + QString("</font>"));
|
||||
dispLog->append(QString("<font color = \"DarkGrey\">") +
|
||||
QDir::current().dirName() + QString("$ ") +
|
||||
QString("</font>"));
|
||||
}
|
||||
|
||||
void qTabMessages::GetLastCommand() {
|
||||
dispCommand->setText(lastCommand.join(" "));
|
||||
dispCommand->setText(lastCommand.join(" "));
|
||||
}
|
||||
|
||||
void qTabMessages::ClearCommand() {
|
||||
dispCommand->setText("");
|
||||
}
|
||||
void qTabMessages::ClearCommand() { dispCommand->setText(""); }
|
||||
|
||||
void qTabMessages::ExecuteCommand() {
|
||||
QStringList param = dispCommand->text().split(" ");
|
||||
@ -71,16 +68,19 @@ void qTabMessages::ExecuteCommand() {
|
||||
lastCommand += param;
|
||||
dispCommand->clear();
|
||||
// appending command to log without newline
|
||||
dispLog->moveCursor (QTextCursor::End);
|
||||
dispLog->insertHtml(QString("<font color = \"DarkBlue\">") + param.join(" ") + QString("</font>"));
|
||||
|
||||
dispLog->moveCursor(QTextCursor::End);
|
||||
dispLog->insertHtml(QString("<font color = \"DarkBlue\">") +
|
||||
param.join(" ") + QString("</font>"));
|
||||
|
||||
QString command = param.at(0);
|
||||
param.removeFirst();
|
||||
FILE_LOG(logINFO) << "Executing Command:[" << command.toAscii().constData() << "] with Arguments:[" << param.join(" ").toAscii().constData() << "]";
|
||||
LOG(logINFO) << "Executing Command:[" << command.toAscii().constData()
|
||||
<< "] with Arguments:["
|
||||
<< param.join(" ").toAscii().constData() << "]";
|
||||
|
||||
process->setProcessChannelMode(QProcess::MergedChannels);
|
||||
process->start(command, param);
|
||||
if(!process->waitForFinished()) {
|
||||
if (!process->waitForFinished()) {
|
||||
AppendError();
|
||||
} else {
|
||||
AppendOutput();
|
||||
@ -90,34 +90,40 @@ void qTabMessages::ExecuteCommand() {
|
||||
void qTabMessages::AppendOutput() {
|
||||
QByteArray result = process->readAll();
|
||||
result.replace("\n", "<br>");
|
||||
dispLog->append(QString("<font color = \"DarkBlue\">") + result + QString("</font>"));
|
||||
FILE_LOG(logDEBUG) << "Command executed successfully";
|
||||
dispLog->append(QString("<font color = \"DarkBlue\">") + result +
|
||||
QString("</font>"));
|
||||
LOG(logDEBUG) << "Command executed successfully";
|
||||
PrintNextLine();
|
||||
}
|
||||
|
||||
void qTabMessages::AppendError() {
|
||||
dispLog->append(QString("<font color = \"Red\">") + process->errorString() + QString("</font>"));
|
||||
FILE_LOG(logERROR) << "Error executing command";
|
||||
dispLog->append(QString("<font color = \"Red\">") + process->errorString() +
|
||||
QString("</font>"));
|
||||
LOG(logERROR) << "Error executing command";
|
||||
PrintNextLine();
|
||||
}
|
||||
|
||||
|
||||
void qTabMessages::SaveLog() {
|
||||
QString fName = QDir::cleanPath(QDir::currentPath()) + "/LogFile.txt";
|
||||
fName = QFileDialog::getSaveFileName(this, tr("Save Snapshot "),
|
||||
fName, tr("Text files (*.txt);;All Files(*)"));
|
||||
fName =
|
||||
QFileDialog::getSaveFileName(this, tr("Save Snapshot "), fName,
|
||||
tr("Text files (*.txt);;All Files(*)"));
|
||||
if (!fName.isEmpty()) {
|
||||
QFile outfile;
|
||||
outfile.setFileName(fName);
|
||||
if (outfile.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
QTextStream out(&outfile);
|
||||
out << dispLog->toPlainText() << endl;
|
||||
std::string mess = std::string("The Log has been successfully saved to ") + fName.toAscii().constData();
|
||||
std::string mess =
|
||||
std::string("The Log has been successfully saved to ") +
|
||||
fName.toAscii().constData();
|
||||
qDefs::Message(qDefs::INFORMATION, mess, "TabMessages::SaveLog");
|
||||
FILE_LOG(logINFO) << mess;
|
||||
LOG(logINFO) << mess;
|
||||
} else {
|
||||
FILE_LOG(logWARNING) << "Attempt to save log file failed: " << fName.toAscii().constData();
|
||||
qDefs::Message(qDefs::WARNING, "Attempt to save log file failed.", "qTabMessages::SaveLog");
|
||||
LOG(logWARNING) << "Attempt to save log file failed: "
|
||||
<< fName.toAscii().constData();
|
||||
qDefs::Message(qDefs::WARNING, "Attempt to save log file failed.",
|
||||
"qTabMessages::SaveLog");
|
||||
}
|
||||
}
|
||||
dispCommand->setFocus();
|
||||
@ -125,7 +131,7 @@ void qTabMessages::SaveLog() {
|
||||
|
||||
void qTabMessages::ClearLog() {
|
||||
dispLog->clear();
|
||||
FILE_LOG(logINFO) << "Log Cleared";
|
||||
LOG(logINFO) << "Log Cleared";
|
||||
PrintNextLine();
|
||||
dispCommand->setFocus();
|
||||
}
|
||||
@ -134,4 +140,3 @@ void qTabMessages::Refresh() {
|
||||
dispCommand->clear();
|
||||
dispCommand->setFocus();
|
||||
}
|
||||
|
||||
|
447
slsDetectorGui/src/qTabPlot.cpp
Executable file → Normal file
447
slsDetectorGui/src/qTabPlot.cpp
Executable file → Normal file
@ -1,15 +1,11 @@
|
||||
#include "qTabPlot.h"
|
||||
#include "qDefs.h"
|
||||
#include "qDrawPlot.h"
|
||||
|
||||
#include <QStandardItemModel>
|
||||
#include <QStackedLayout>
|
||||
#include <QButtonGroup>
|
||||
#include <QAbstractButton>
|
||||
#include <QButtonGroup>
|
||||
#include <QStackedLayout>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include <string>
|
||||
|
||||
QString qTabPlot::defaultPlotTitle("");
|
||||
QString qTabPlot::defaultHistXAxisTitle("Channel Number");
|
||||
@ -18,18 +14,14 @@ QString qTabPlot::defaultImageXAxisTitle("Pixel");
|
||||
QString qTabPlot::defaultImageYAxisTitle("Pixel");
|
||||
QString qTabPlot::defaultImageZAxisTitle("Intensity");
|
||||
|
||||
|
||||
qTabPlot::qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p) :
|
||||
QWidget(parent), det(detector), plot(p), is1d(false) {
|
||||
qTabPlot::qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p)
|
||||
: QWidget(parent), det(detector), plot(p), is1d(false) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logDEBUG) << "Plot ready";
|
||||
LOG(logDEBUG) << "Plot ready";
|
||||
}
|
||||
|
||||
qTabPlot::~qTabPlot() {
|
||||
if (btnGroupPlotType)
|
||||
delete btnGroupPlotType;
|
||||
}
|
||||
qTabPlot::~qTabPlot() { delete btnGroupPlotType; }
|
||||
|
||||
void qTabPlot::SetupWidgetWindow() {
|
||||
// button group for plot type
|
||||
@ -57,27 +49,28 @@ void qTabPlot::SetupWidgetWindow() {
|
||||
|
||||
// enabling according to det type
|
||||
is1d = false;
|
||||
switch(det->getDetectorType().squash()) {
|
||||
case slsDetectorDefs::GOTTHARD:
|
||||
case slsDetectorDefs::MYTHEN3:
|
||||
is1d = true;
|
||||
break;
|
||||
case slsDetectorDefs::GOTTHARD2:
|
||||
is1d = true;
|
||||
chkGainPlot1D->setEnabled(true);
|
||||
chkGainPlot1D->setChecked(true);
|
||||
plot->EnableGainPlot(true);
|
||||
break;
|
||||
case slsDetectorDefs::EIGER:
|
||||
chkGapPixels->setEnabled(true);
|
||||
break;
|
||||
case slsDetectorDefs::JUNGFRAU:
|
||||
chkGainPlot->setEnabled(true);
|
||||
chkGainPlot->setChecked(true);
|
||||
plot->EnableGainPlot(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
switch (det->getDetectorType().squash()) {
|
||||
case slsDetectorDefs::GOTTHARD:
|
||||
case slsDetectorDefs::MYTHEN3:
|
||||
is1d = true;
|
||||
break;
|
||||
case slsDetectorDefs::GOTTHARD2:
|
||||
is1d = true;
|
||||
chkGainPlot1D->setEnabled(true);
|
||||
chkGainPlot1D->setChecked(true);
|
||||
plot->EnableGainPlot(true);
|
||||
break;
|
||||
case slsDetectorDefs::EIGER:
|
||||
chkGapPixels->setEnabled(true);
|
||||
break;
|
||||
case slsDetectorDefs::JUNGFRAU:
|
||||
chkGapPixels->setEnabled(true);
|
||||
chkGainPlot->setEnabled(true);
|
||||
chkGainPlot->setChecked(true);
|
||||
plot->EnableGainPlot(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Select1DPlot(is1d);
|
||||
@ -87,58 +80,78 @@ void qTabPlot::SetupWidgetWindow() {
|
||||
|
||||
void qTabPlot::Initialization() {
|
||||
// Plot arguments box
|
||||
connect(btnGroupPlotType, SIGNAL(buttonClicked(int)), this, SLOT(SetPlot()));
|
||||
connect(btnGroupPlotType, SIGNAL(buttonClicked(int)), this,
|
||||
SLOT(SetPlot()));
|
||||
|
||||
// Plotting frequency box
|
||||
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
|
||||
connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
|
||||
connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
|
||||
connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
|
||||
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetStreamingFrequency()));
|
||||
connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetStreamingFrequency()));
|
||||
connect(spinTimeGap, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetStreamingFrequency()));
|
||||
connect(spinNthFrame, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetStreamingFrequency()));
|
||||
|
||||
// navigation buttons for options
|
||||
connect(btnRight1D, SIGNAL(clicked()), this, SLOT(Set1DPlotOptionsRight()));
|
||||
connect(btnLeft1D, SIGNAL(clicked()), this, SLOT(Set1DPlotOptionsLeft()));
|
||||
connect(btnRight2D, SIGNAL(clicked()), this, SLOT(Set2DPlotOptionsRight()));
|
||||
connect(btnLeft2D, SIGNAL(clicked()), this, SLOT(Set2DPlotOptionsLeft()));
|
||||
|
||||
|
||||
// 1D options
|
||||
connect(chkSuperimpose, SIGNAL(toggled(bool)), this, SLOT(EnablePersistency(bool)));
|
||||
connect(spinPersistency, SIGNAL(valueChanged(int)), plot, SLOT(SetPersistency(int)));
|
||||
connect(chkSuperimpose, SIGNAL(toggled(bool)), this,
|
||||
SLOT(EnablePersistency(bool)));
|
||||
connect(spinPersistency, SIGNAL(valueChanged(int)), plot,
|
||||
SLOT(SetPersistency(int)));
|
||||
connect(chkPoints, SIGNAL(toggled(bool)), plot, SLOT(SetMarkers(bool)));
|
||||
connect(chkLines, SIGNAL(toggled(bool)), plot, SLOT(SetLines(bool)));
|
||||
connect(chk1DLog, SIGNAL(toggled(bool)), plot, SLOT(Set1dLogY(bool)));
|
||||
connect(chkStatistics, SIGNAL(toggled(bool)), plot, SLOT(DisplayStatistics(bool)));
|
||||
connect(chkStatistics, SIGNAL(toggled(bool)), plot,
|
||||
SLOT(DisplayStatistics(bool)));
|
||||
|
||||
// 2D Plot box
|
||||
connect(chkInterpolate, SIGNAL(toggled(bool)), plot, SLOT(SetInterpolate(bool)));
|
||||
connect(chkInterpolate, SIGNAL(toggled(bool)), plot,
|
||||
SLOT(SetInterpolate(bool)));
|
||||
connect(chkContour, SIGNAL(toggled(bool)), plot, SLOT(SetContour(bool)));
|
||||
connect(chkLogz, SIGNAL(toggled(bool)), plot, SLOT(SetLogz(bool)));
|
||||
connect(chkStatistics_2, SIGNAL(toggled(bool)), plot, SLOT(DisplayStatistics(bool)));
|
||||
//pedstal
|
||||
connect(chkStatistics_2, SIGNAL(toggled(bool)), plot,
|
||||
SLOT(DisplayStatistics(bool)));
|
||||
// pedstal
|
||||
connect(chkPedestal, SIGNAL(toggled(bool)), plot, SLOT(SetPedestal(bool)));
|
||||
connect(btnRecalPedestal, SIGNAL(clicked()), plot, SLOT(RecalculatePedestal()));
|
||||
connect(chkPedestal_2, SIGNAL(toggled(bool)), plot, SLOT(SetPedestal(bool)));
|
||||
connect(btnRecalPedestal_2, SIGNAL(clicked()), plot, SLOT(RecalculatePedestal()));
|
||||
//accumulate
|
||||
connect(chkAccumulate, SIGNAL(toggled(bool)), plot, SLOT(SetAccumulate(bool)));
|
||||
connect(btnResetAccumulate, SIGNAL(clicked()), plot, SLOT(ResetAccumulate()));
|
||||
connect(chkAccumulate_2, SIGNAL(toggled(bool)), plot, SLOT(SetAccumulate(bool)));
|
||||
connect(btnResetAccumulate_2, SIGNAL(clicked()), plot, SLOT(ResetAccumulate()));
|
||||
//binary
|
||||
connect(btnRecalPedestal, SIGNAL(clicked()), plot,
|
||||
SLOT(RecalculatePedestal()));
|
||||
connect(chkPedestal_2, SIGNAL(toggled(bool)), plot,
|
||||
SLOT(SetPedestal(bool)));
|
||||
connect(btnRecalPedestal_2, SIGNAL(clicked()), plot,
|
||||
SLOT(RecalculatePedestal()));
|
||||
// accumulate
|
||||
connect(chkAccumulate, SIGNAL(toggled(bool)), plot,
|
||||
SLOT(SetAccumulate(bool)));
|
||||
connect(btnResetAccumulate, SIGNAL(clicked()), plot,
|
||||
SLOT(ResetAccumulate()));
|
||||
connect(chkAccumulate_2, SIGNAL(toggled(bool)), plot,
|
||||
SLOT(SetAccumulate(bool)));
|
||||
connect(btnResetAccumulate_2, SIGNAL(clicked()), plot,
|
||||
SLOT(ResetAccumulate()));
|
||||
// binary
|
||||
connect(chkBinary, SIGNAL(toggled(bool)), this, SLOT(SetBinary()));
|
||||
connect(chkBinary_2, SIGNAL(toggled(bool)), this, SLOT(SetBinary()));
|
||||
connect(spinFrom, SIGNAL(valueChanged(int)), this, SLOT(SetBinary()));
|
||||
connect(spinFrom_2, SIGNAL(valueChanged(int)), this, SLOT(SetBinary()));
|
||||
connect(spinTo, SIGNAL(valueChanged(int)), this, SLOT(SetBinary()));
|
||||
connect(spinTo_2, SIGNAL(valueChanged(int)), this, SLOT(SetBinary()));
|
||||
//gainplot
|
||||
// gainplot
|
||||
if (chkGainPlot->isEnabled())
|
||||
connect(chkGainPlot, SIGNAL(toggled(bool)), plot, SLOT(EnableGainPlot(bool)));
|
||||
connect(chkGainPlot, SIGNAL(toggled(bool)), plot,
|
||||
SLOT(EnableGainPlot(bool)));
|
||||
if (chkGainPlot1D->isEnabled())
|
||||
connect(chkGainPlot1D, SIGNAL(toggled(bool)), plot, SLOT(EnableGainPlot(bool)));
|
||||
connect(chkGainPlot1D, SIGNAL(toggled(bool)), plot,
|
||||
SLOT(EnableGainPlot(bool)));
|
||||
// gap pixels
|
||||
if (chkGapPixels->isEnabled())
|
||||
connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool)));
|
||||
connect(chkGapPixels, SIGNAL(toggled(bool)), this,
|
||||
SLOT(SetGapPixels(bool)));
|
||||
|
||||
// Save, clone
|
||||
connect(btnSave, SIGNAL(clicked()), plot, SLOT(SavePlot()));
|
||||
@ -149,10 +162,14 @@ void qTabPlot::Initialization() {
|
||||
connect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
|
||||
connect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
|
||||
connect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
|
||||
connect(dispTitle, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
|
||||
connect(dispXAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
|
||||
connect(dispYAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
|
||||
connect(dispZAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
|
||||
connect(dispTitle, SIGNAL(textChanged(const QString &)), this,
|
||||
SLOT(SetTitles()));
|
||||
connect(dispXAxis, SIGNAL(textChanged(const QString &)), this,
|
||||
SLOT(SetTitles()));
|
||||
connect(dispYAxis, SIGNAL(textChanged(const QString &)), this,
|
||||
SLOT(SetTitles()));
|
||||
connect(dispZAxis, SIGNAL(textChanged(const QString &)), this,
|
||||
SLOT(SetTitles()));
|
||||
|
||||
connect(chkXMin, SIGNAL(toggled(bool)), this, SLOT(SetXRange()));
|
||||
connect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(SetXRange()));
|
||||
@ -162,7 +179,8 @@ void qTabPlot::Initialization() {
|
||||
connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXRange()));
|
||||
connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYRange()));
|
||||
connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYRange()));
|
||||
connect(chkAspectRatio, SIGNAL(toggled(bool)), this, SLOT(CheckAspectRatio()));
|
||||
connect(chkAspectRatio, SIGNAL(toggled(bool)), this,
|
||||
SLOT(CheckAspectRatio()));
|
||||
|
||||
connect(chkZMin, SIGNAL(toggled(bool)), this, SLOT(SetZRange()));
|
||||
connect(chkZMax, SIGNAL(toggled(bool)), this, SLOT(SetZRange()));
|
||||
@ -171,7 +189,7 @@ void qTabPlot::Initialization() {
|
||||
}
|
||||
|
||||
void qTabPlot::Select1DPlot(bool enable) {
|
||||
FILE_LOG(logDEBUG) << "Selecting " << (enable ? "1" : "2") << "D Plot";
|
||||
LOG(logDEBUG) << "Selecting " << (enable ? "1" : "2") << "D Plot";
|
||||
is1d = enable;
|
||||
box1D->setEnabled(enable);
|
||||
box2D->setEnabled(!enable);
|
||||
@ -192,9 +210,9 @@ void qTabPlot::Select1DPlot(bool enable) {
|
||||
void qTabPlot::SetPlot() {
|
||||
bool plotEnable = false;
|
||||
if (radioNoPlot->isChecked()) {
|
||||
FILE_LOG(logINFO) << "Setting Plot Type: No Plot";
|
||||
LOG(logINFO) << "Setting Plot Type: No Plot";
|
||||
} else if (radioDataGraph->isChecked()) {
|
||||
FILE_LOG(logINFO) << "Setting Plot Type: Datagraph";
|
||||
LOG(logINFO) << "Setting Plot Type: Datagraph";
|
||||
plotEnable = true;
|
||||
}
|
||||
boxFrequency->setEnabled(plotEnable);
|
||||
@ -210,52 +228,56 @@ void qTabPlot::SetPlot() {
|
||||
SetZRange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
plot->SetDataCallBack(plotEnable);
|
||||
}
|
||||
|
||||
void qTabPlot::Set1DPlotOptionsRight() {
|
||||
FILE_LOG(logDEBUG) << "1D Options Right";
|
||||
LOG(logDEBUG) << "1D Options Right";
|
||||
int i = stackedWidget1D->currentIndex();
|
||||
if (i == (stackedWidget1D->count() - 1))
|
||||
stackedWidget1D->setCurrentIndex(0);
|
||||
else
|
||||
stackedWidget1D->setCurrentIndex(i + 1);
|
||||
box1D->setTitle(QString("1D Plot Options %1").arg(stackedWidget1D->currentIndex() + 1));
|
||||
box1D->setTitle(
|
||||
QString("1D Plot Options %1").arg(stackedWidget1D->currentIndex() + 1));
|
||||
}
|
||||
|
||||
void qTabPlot::Set1DPlotOptionsLeft() {
|
||||
FILE_LOG(logDEBUG) << "1D Options Left";
|
||||
LOG(logDEBUG) << "1D Options Left";
|
||||
int i = stackedWidget1D->currentIndex();
|
||||
if (i == 0)
|
||||
stackedWidget1D->setCurrentIndex(stackedWidget1D->count() - 1);
|
||||
else
|
||||
stackedWidget1D->setCurrentIndex(i - 1);
|
||||
box1D->setTitle(QString("1D Plot Options %1").arg(stackedWidget1D->currentIndex() + 1));
|
||||
box1D->setTitle(
|
||||
QString("1D Plot Options %1").arg(stackedWidget1D->currentIndex() + 1));
|
||||
}
|
||||
|
||||
void qTabPlot::Set2DPlotOptionsRight() {
|
||||
FILE_LOG(logDEBUG) << "2D Options Right";
|
||||
LOG(logDEBUG) << "2D Options Right";
|
||||
int i = stackedWidget2D->currentIndex();
|
||||
if (i == (stackedWidget2D->count() - 1))
|
||||
stackedWidget2D->setCurrentIndex(0);
|
||||
else
|
||||
stackedWidget2D->setCurrentIndex(i + 1);
|
||||
box2D->setTitle(QString("2D Plot Options %1").arg(stackedWidget2D->currentIndex() + 1));
|
||||
box2D->setTitle(
|
||||
QString("2D Plot Options %1").arg(stackedWidget2D->currentIndex() + 1));
|
||||
}
|
||||
|
||||
void qTabPlot::Set2DPlotOptionsLeft() {
|
||||
FILE_LOG(logDEBUG) << "2D Options Left";
|
||||
LOG(logDEBUG) << "2D Options Left";
|
||||
int i = stackedWidget2D->currentIndex();
|
||||
if (i == 0)
|
||||
stackedWidget2D->setCurrentIndex(stackedWidget2D->count() - 1);
|
||||
else
|
||||
stackedWidget2D->setCurrentIndex(i - 1);
|
||||
box2D->setTitle(QString("2D Plot Options %1").arg(stackedWidget2D->currentIndex() + 1));
|
||||
box2D->setTitle(
|
||||
QString("2D Plot Options %1").arg(stackedWidget2D->currentIndex() + 1));
|
||||
}
|
||||
|
||||
void qTabPlot::EnablePersistency(bool enable) {
|
||||
FILE_LOG(logINFO) << "Superimpose " << (enable ? "enabled" : "disabled");
|
||||
LOG(logINFO) << "Superimpose " << (enable ? "enabled" : "disabled");
|
||||
lblPersistency->setEnabled(enable);
|
||||
spinPersistency->setEnabled(enable);
|
||||
if (enable)
|
||||
@ -266,16 +288,18 @@ void qTabPlot::EnablePersistency(bool enable) {
|
||||
|
||||
void qTabPlot::SetBinary() {
|
||||
bool binary1D = chkBinary->isChecked();
|
||||
bool binary2D = chkBinary_2->isChecked();
|
||||
bool binary2D = chkBinary_2->isChecked();
|
||||
if (is1d) {
|
||||
FILE_LOG(logINFO) << "Binary Plot " << (binary1D ? "enabled" : "disabled");
|
||||
LOG(logINFO) << "Binary Plot "
|
||||
<< (binary1D ? "enabled" : "disabled");
|
||||
lblFrom->setEnabled(binary1D);
|
||||
lblTo->setEnabled(binary1D);
|
||||
spinFrom->setEnabled(binary1D);
|
||||
spinTo->setEnabled(binary1D);
|
||||
plot->SetBinary(binary1D, spinFrom->value(), spinTo->value());
|
||||
} else {
|
||||
FILE_LOG(logINFO) << "Binary Plot " << (binary2D ? "enabled" : "disabled");
|
||||
LOG(logINFO) << "Binary Plot "
|
||||
<< (binary2D ? "enabled" : "disabled");
|
||||
lblFrom_2->setEnabled(binary2D);
|
||||
lblTo_2->setEnabled(binary2D);
|
||||
spinFrom_2->setEnabled(binary2D);
|
||||
@ -285,54 +309,67 @@ void qTabPlot::SetBinary() {
|
||||
}
|
||||
|
||||
void qTabPlot::GetGapPixels() {
|
||||
FILE_LOG(logDEBUG) << "Getting gap pixels";
|
||||
disconnect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool)));
|
||||
try {
|
||||
auto retval = det->getRxAddGapPixels().tsquash("Inconsistent gap pixels enabled for all detectors.");
|
||||
chkGapPixels->setChecked(retval);
|
||||
} CATCH_DISPLAY ("Could not get gap pixels enable.", "qTabPlot::GetGapPixels")
|
||||
connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool)));
|
||||
LOG(logDEBUG) << "Getting gap pixels";
|
||||
disconnect(chkGapPixels, SIGNAL(toggled(bool)), this,
|
||||
SLOT(SetGapPixels(bool)));
|
||||
try {
|
||||
auto retval = det->getGapPixelsinCallback();
|
||||
chkGapPixels->setChecked(retval);
|
||||
}
|
||||
CATCH_DISPLAY("Could not get gap pixels enable.", "qTabPlot::GetGapPixels")
|
||||
connect(chkGapPixels, SIGNAL(toggled(bool)), this,
|
||||
SLOT(SetGapPixels(bool)));
|
||||
}
|
||||
|
||||
void qTabPlot::SetGapPixels(bool enable) {
|
||||
FILE_LOG(logINFO) << "Setting Gap Pixels Enable to " << enable;
|
||||
try {
|
||||
det->setRxAddGapPixels(enable);
|
||||
} CATCH_HANDLE("Could not set gap pixels enable.", "qTabPlot::SetGapPixels", this, &qTabPlot::GetGapPixels)
|
||||
LOG(logINFO) << "Setting Gap Pixels Enable to " << enable;
|
||||
try {
|
||||
det->setGapPixelsinCallback(enable);
|
||||
}
|
||||
CATCH_HANDLE("Could not set gap pixels enable.", "qTabPlot::SetGapPixels",
|
||||
this, &qTabPlot::GetGapPixels)
|
||||
}
|
||||
|
||||
void qTabPlot::SetTitles() {
|
||||
FILE_LOG(logDEBUG) << "Setting Plot Titles";
|
||||
LOG(logDEBUG) << "Setting Plot Titles";
|
||||
disconnect(chkTitle, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
|
||||
disconnect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
|
||||
disconnect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
|
||||
disconnect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
|
||||
disconnect(dispTitle, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
|
||||
disconnect(dispXAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
|
||||
disconnect(dispYAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
|
||||
disconnect(dispZAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
|
||||
disconnect(dispTitle, SIGNAL(textChanged(const QString &)), this,
|
||||
SLOT(SetTitles()));
|
||||
disconnect(dispXAxis, SIGNAL(textChanged(const QString &)), this,
|
||||
SLOT(SetTitles()));
|
||||
disconnect(dispYAxis, SIGNAL(textChanged(const QString &)), this,
|
||||
SLOT(SetTitles()));
|
||||
disconnect(dispZAxis, SIGNAL(textChanged(const QString &)), this,
|
||||
SLOT(SetTitles()));
|
||||
|
||||
// title
|
||||
if (!chkTitle->isChecked() || dispTitle->text().isEmpty()) {
|
||||
plot->SetPlotTitlePrefix("");
|
||||
dispTitle->setText("");
|
||||
dispTitle->setText("");
|
||||
} else {
|
||||
plot->SetPlotTitlePrefix(dispTitle->text());
|
||||
}
|
||||
// x
|
||||
if (!chkXAxis->isChecked() || dispXAxis->text().isEmpty()) {
|
||||
dispXAxis->setText(is1d ? defaultHistXAxisTitle : defaultImageXAxisTitle);
|
||||
plot->SetXAxisTitle(is1d ? defaultHistXAxisTitle : defaultImageXAxisTitle);
|
||||
dispXAxis->setText(is1d ? defaultHistXAxisTitle
|
||||
: defaultImageXAxisTitle);
|
||||
plot->SetXAxisTitle(is1d ? defaultHistXAxisTitle
|
||||
: defaultImageXAxisTitle);
|
||||
} else {
|
||||
plot->SetXAxisTitle(dispXAxis->text());
|
||||
}
|
||||
}
|
||||
// y
|
||||
if (!chkYAxis->isChecked() || dispYAxis->text().isEmpty()) {
|
||||
dispYAxis->setText(is1d ? defaultHistYAxisTitle : defaultImageYAxisTitle);
|
||||
plot->SetYAxisTitle(is1d ? defaultHistYAxisTitle : defaultImageYAxisTitle);
|
||||
dispYAxis->setText(is1d ? defaultHistYAxisTitle
|
||||
: defaultImageYAxisTitle);
|
||||
plot->SetYAxisTitle(is1d ? defaultHistYAxisTitle
|
||||
: defaultImageYAxisTitle);
|
||||
} else {
|
||||
plot->SetYAxisTitle(dispYAxis->text());
|
||||
}
|
||||
}
|
||||
// z
|
||||
if (!chkZAxis->isChecked() || dispZAxis->text().isEmpty()) {
|
||||
plot->SetZAxisTitle(defaultImageZAxisTitle);
|
||||
@ -345,14 +382,18 @@ void qTabPlot::SetTitles() {
|
||||
connect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
|
||||
connect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
|
||||
connect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
|
||||
connect(dispTitle, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
|
||||
connect(dispXAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
|
||||
connect(dispYAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
|
||||
connect(dispZAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
|
||||
connect(dispTitle, SIGNAL(textChanged(const QString &)), this,
|
||||
SLOT(SetTitles()));
|
||||
connect(dispXAxis, SIGNAL(textChanged(const QString &)), this,
|
||||
SLOT(SetTitles()));
|
||||
connect(dispYAxis, SIGNAL(textChanged(const QString &)), this,
|
||||
SLOT(SetTitles()));
|
||||
connect(dispZAxis, SIGNAL(textChanged(const QString &)), this,
|
||||
SLOT(SetTitles()));
|
||||
}
|
||||
|
||||
void qTabPlot::SetXRange() {
|
||||
FILE_LOG(logDEBUG) << "Enable X axis range";
|
||||
LOG(logDEBUG) << "Enable X axis range";
|
||||
|
||||
if (chkAspectRatio->isChecked()) {
|
||||
MaintainAspectRatio(static_cast<int>(slsDetectorDefs::Y));
|
||||
@ -362,7 +403,7 @@ void qTabPlot::SetXRange() {
|
||||
}
|
||||
|
||||
void qTabPlot::SetYRange() {
|
||||
FILE_LOG(logDEBUG) << "Enable Y axis range";
|
||||
LOG(logDEBUG) << "Enable Y axis range";
|
||||
|
||||
if (chkAspectRatio->isChecked()) {
|
||||
MaintainAspectRatio(static_cast<int>(slsDetectorDefs::X));
|
||||
@ -380,18 +421,23 @@ void qTabPlot::CheckAspectRatio() {
|
||||
}
|
||||
|
||||
void qTabPlot::SetXYRange() {
|
||||
FILE_LOG(logDEBUG) << "Set XY Range";
|
||||
LOG(logDEBUG) << "Set XY Range";
|
||||
bool disablezoom = false;
|
||||
bool isRange[4]{false, false, false, false};
|
||||
double xyRange[4]{0, 0, 0, 0};
|
||||
|
||||
QString dispVal[4] {dispXMin->text(), dispXMax->text(), dispYMin->text(), dispYMax->text()};
|
||||
bool chkVal[4] {chkXMin->isChecked(), chkXMax->isChecked(), chkYMin->isChecked(), chkYMax->isChecked()};
|
||||
QString dispVal[4]{dispXMin->text(), dispXMax->text(), dispYMin->text(),
|
||||
dispYMax->text()};
|
||||
bool chkVal[4]{chkXMin->isChecked(), chkXMax->isChecked(),
|
||||
chkYMin->isChecked(), chkYMax->isChecked()};
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (chkVal[i] && !dispVal[i].isEmpty()) {
|
||||
double val = dispVal[i].toDouble();
|
||||
FILE_LOG(logDEBUG) << "Setting " << qDefs::getRangeAsString(static_cast<qDefs::range>(i)) << " to " << val;
|
||||
LOG(logDEBUG)
|
||||
<< "Setting "
|
||||
<< qDefs::getRangeAsString(static_cast<qDefs::range>(i))
|
||||
<< " to " << val;
|
||||
xyRange[i] = val;
|
||||
isRange[i] = true;
|
||||
disablezoom = true;
|
||||
@ -403,7 +449,7 @@ void qTabPlot::SetXYRange() {
|
||||
}
|
||||
|
||||
void qTabPlot::MaintainAspectRatio(int dimension) {
|
||||
FILE_LOG(logDEBUG) << "Maintaining Aspect Ratio";
|
||||
LOG(logDEBUG) << "Maintaining Aspect Ratio";
|
||||
|
||||
disconnect(chkXMin, SIGNAL(toggled(bool)), this, SLOT(SetXRange()));
|
||||
disconnect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(SetXRange()));
|
||||
@ -419,13 +465,13 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
|
||||
chkXMax->setChecked(true);
|
||||
chkYMin->setChecked(true);
|
||||
chkYMax->setChecked(true);
|
||||
if (dispXMin->text().isEmpty())
|
||||
if (dispXMin->text().isEmpty())
|
||||
dispXMin->setText(QString::number(plot->GetXMinimum()));
|
||||
if (dispXMax->text().isEmpty())
|
||||
if (dispXMax->text().isEmpty())
|
||||
dispXMax->setText(QString::number(plot->GetXMaximum()));
|
||||
if (dispYMin->text().isEmpty())
|
||||
if (dispYMin->text().isEmpty())
|
||||
dispYMin->setText(QString::number(plot->GetYMinimum()));
|
||||
if (dispYMax->text().isEmpty())
|
||||
if (dispYMax->text().isEmpty())
|
||||
dispYMax->setText(QString::number(plot->GetYMaximum()));
|
||||
|
||||
// calculate ideal aspect ratio with previous limits
|
||||
@ -434,52 +480,71 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
|
||||
ranges[qDefs::XMAX] = plot->GetXMaximum();
|
||||
ranges[qDefs::YMIN] = plot->GetYMinimum();
|
||||
ranges[qDefs::YMAX] = plot->GetYMaximum();
|
||||
double idealAspectratio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]);
|
||||
FILE_LOG(logDEBUG) << "Ideal Aspect ratio: " << idealAspectratio << " for x(" << ranges[qDefs::XMIN] << " - " << ranges[qDefs::XMAX] << "), y(" << ranges[qDefs::YMIN] << " - " << ranges[qDefs::YMAX] << ")";
|
||||
|
||||
double idealAspectratio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) /
|
||||
(ranges[qDefs::YMAX] - ranges[qDefs::YMIN]);
|
||||
LOG(logDEBUG) << "Ideal Aspect ratio: " << idealAspectratio
|
||||
<< " for x(" << ranges[qDefs::XMIN] << " - "
|
||||
<< ranges[qDefs::XMAX] << "), y(" << ranges[qDefs::YMIN]
|
||||
<< " - " << ranges[qDefs::YMAX] << ")";
|
||||
|
||||
// calculate current aspect ratio
|
||||
ranges[qDefs::XMIN] = dispXMin->text().toDouble();
|
||||
ranges[qDefs::XMAX] = dispXMax->text().toDouble();
|
||||
ranges[qDefs::YMIN] = dispYMin->text().toDouble();
|
||||
ranges[qDefs::YMAX] = dispYMax->text().toDouble();
|
||||
double currentAspectRatio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]);
|
||||
FILE_LOG(logDEBUG) << "Current Aspect ratio: " << currentAspectRatio << " for x(" << ranges[qDefs::XMIN] << " - " << ranges[qDefs::XMAX] << "), y(" << ranges[qDefs::YMIN] << " - " << ranges[qDefs::YMAX] << ")";
|
||||
|
||||
double currentAspectRatio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) /
|
||||
(ranges[qDefs::YMAX] - ranges[qDefs::YMIN]);
|
||||
LOG(logDEBUG) << "Current Aspect ratio: " << currentAspectRatio
|
||||
<< " for x(" << ranges[qDefs::XMIN] << " - "
|
||||
<< ranges[qDefs::XMAX] << "), y(" << ranges[qDefs::YMIN]
|
||||
<< " - " << ranges[qDefs::YMAX] << ")";
|
||||
|
||||
if (currentAspectRatio != idealAspectratio) {
|
||||
// dimension: 1(x changed: y adjusted), 0(y changed: x adjusted), -1(aspect ratio clicked: larger one adjusted)
|
||||
// dimension: 1(x changed: y adjusted), 0(y changed: x adjusted),
|
||||
// -1(aspect ratio clicked: larger one adjusted)
|
||||
if (dimension == -1) {
|
||||
dimension = ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) > (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]))
|
||||
? static_cast<int>(slsDetectorDefs::X) : static_cast<int>(slsDetectorDefs::Y);
|
||||
dimension = ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) >
|
||||
(ranges[qDefs::YMAX] - ranges[qDefs::YMIN]))
|
||||
? static_cast<int>(slsDetectorDefs::X)
|
||||
: static_cast<int>(slsDetectorDefs::Y);
|
||||
}
|
||||
|
||||
// calculate new value to maintain aspect ratio
|
||||
// adjust x
|
||||
double newval = 0;
|
||||
if (dimension == static_cast<int>(slsDetectorDefs::X)) {
|
||||
newval = idealAspectratio * (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]) + ranges[qDefs::XMIN];
|
||||
newval =
|
||||
idealAspectratio * (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]) +
|
||||
ranges[qDefs::XMIN];
|
||||
if (newval <= plot->GetXMaximum()) {
|
||||
ranges[qDefs::XMAX] = newval;
|
||||
dispXMax->setText(QString::number(newval));
|
||||
FILE_LOG(logDEBUG) << "New XMax: " << newval;
|
||||
LOG(logDEBUG) << "New XMax: " << newval;
|
||||
} else {
|
||||
newval = ranges[qDefs::XMAX] - (idealAspectratio * (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]));
|
||||
newval = ranges[qDefs::XMAX] -
|
||||
(idealAspectratio *
|
||||
(ranges[qDefs::YMAX] - ranges[qDefs::YMIN]));
|
||||
ranges[qDefs::XMIN] = newval;
|
||||
dispXMin->setText(QString::number(newval));
|
||||
FILE_LOG(logDEBUG) << "New XMin: " << newval;
|
||||
LOG(logDEBUG) << "New XMin: " << newval;
|
||||
}
|
||||
}
|
||||
// adjust y
|
||||
else {
|
||||
newval = ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / idealAspectratio) + ranges[qDefs::YMIN];
|
||||
else {
|
||||
newval = ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) /
|
||||
idealAspectratio) +
|
||||
ranges[qDefs::YMIN];
|
||||
if (newval <= plot->GetYMaximum()) {
|
||||
ranges[qDefs::YMAX] = newval;
|
||||
dispYMax->setText(QString::number(newval));
|
||||
FILE_LOG(logDEBUG) << "New YMax: " << newval;
|
||||
LOG(logDEBUG) << "New YMax: " << newval;
|
||||
} else {
|
||||
newval = ranges[qDefs::YMAX] - ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / idealAspectratio);
|
||||
newval = ranges[qDefs::YMAX] -
|
||||
((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) /
|
||||
idealAspectratio);
|
||||
ranges[qDefs::YMIN] = newval;
|
||||
dispYMin->setText(QString::number(newval));
|
||||
FILE_LOG(logDEBUG) << "New YMax: " << newval;
|
||||
LOG(logDEBUG) << "New YMax: " << newval;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -493,47 +558,58 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
|
||||
connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYRange()));
|
||||
connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYRange()));
|
||||
|
||||
bool isRange[4] {true, true, true, true};
|
||||
bool isRange[4]{true, true, true, true};
|
||||
plot->SetXYRangeChanged(true, ranges, isRange);
|
||||
emit DisableZoomSignal(true);
|
||||
}
|
||||
|
||||
void qTabPlot::SetZRange() {
|
||||
bool isZRange[2] {chkZMin->isChecked(), chkZMax->isChecked()};
|
||||
double zRange[2] {0 , 0};
|
||||
bool isZRange[2]{chkZMin->isChecked(), chkZMax->isChecked()};
|
||||
double zRange[2]{0, 0};
|
||||
|
||||
if (isZRange[0] && !dispZMin->text().isEmpty()) {
|
||||
double val = dispZMin->text().toDouble();
|
||||
FILE_LOG(logDEBUG) << "Setting zmin to " << val;
|
||||
LOG(logDEBUG) << "Setting zmin to " << val;
|
||||
zRange[0] = val;
|
||||
}
|
||||
if (isZRange[1] && !dispZMax->text().isEmpty()) {
|
||||
double val = dispZMax->text().toDouble();
|
||||
FILE_LOG(logDEBUG) << "Setting zmax to " << val;
|
||||
LOG(logDEBUG) << "Setting zmax to " << val;
|
||||
zRange[1] = val;
|
||||
}
|
||||
plot->SetZRange(zRange, isZRange);
|
||||
}
|
||||
|
||||
void qTabPlot::GetStreamingFrequency() {
|
||||
FILE_LOG(logDEBUG) << "Getting Streaming Frequency";
|
||||
disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
|
||||
disconnect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
|
||||
disconnect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
|
||||
disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
|
||||
try {
|
||||
int freq = det->getRxZmqFrequency().tsquash("Inconsistent receiver zmq streaming frequency for all detectors.");
|
||||
LOG(logDEBUG) << "Getting Streaming Frequency";
|
||||
disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetStreamingFrequency()));
|
||||
disconnect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetStreamingFrequency()));
|
||||
disconnect(spinTimeGap, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetStreamingFrequency()));
|
||||
disconnect(spinNthFrame, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetStreamingFrequency()));
|
||||
try {
|
||||
int freq = det->getRxZmqFrequency().tsquash(
|
||||
"Inconsistent receiver zmq streaming frequency for all detectors.");
|
||||
// time interval
|
||||
if (freq == 0) {
|
||||
comboFrequency->setCurrentIndex(0);
|
||||
stackedTimeInterval->setCurrentIndex(0);
|
||||
try {
|
||||
int timeMs = det->getRxZmqTimer().tsquash("Inconsistent receiver zmq streaming timer for all detectors.");
|
||||
auto timeNS = qDefs::getNSTime(std::make_pair(static_cast<double>(timeMs), qDefs::MILLISECONDS));
|
||||
int timeMs = det->getRxZmqTimer().tsquash(
|
||||
"Inconsistent receiver zmq streaming timer for all "
|
||||
"detectors.");
|
||||
auto timeNS = qDefs::getNSTime(std::make_pair(
|
||||
static_cast<double>(timeMs), qDefs::MILLISECONDS));
|
||||
auto time = qDefs::getUserFriendlyTime(timeNS);
|
||||
spinTimeGap->setValue(time.first);
|
||||
comboTimeGapUnit->setCurrentIndex(static_cast<int>(time.second));
|
||||
} CATCH_DISPLAY ("Could not get streaming timer.", "qTabPlot::GetStreamingFrequency")
|
||||
comboTimeGapUnit->setCurrentIndex(
|
||||
static_cast<int>(time.second));
|
||||
}
|
||||
CATCH_DISPLAY("Could not get streaming timer.",
|
||||
"qTabPlot::GetStreamingFrequency")
|
||||
}
|
||||
// every nth frame
|
||||
else {
|
||||
@ -541,33 +617,44 @@ void qTabPlot::GetStreamingFrequency() {
|
||||
stackedTimeInterval->setCurrentIndex(1);
|
||||
spinNthFrame->setValue(freq);
|
||||
}
|
||||
} CATCH_DISPLAY ("Could not get streaming frequency.", "qTabPlot::GetStreamingFrequency")
|
||||
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
|
||||
connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
|
||||
connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
|
||||
connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
|
||||
}
|
||||
CATCH_DISPLAY("Could not get streaming frequency.",
|
||||
"qTabPlot::GetStreamingFrequency")
|
||||
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetStreamingFrequency()));
|
||||
connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetStreamingFrequency()));
|
||||
connect(spinTimeGap, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetStreamingFrequency()));
|
||||
connect(spinNthFrame, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetStreamingFrequency()));
|
||||
}
|
||||
|
||||
void qTabPlot::SetStreamingFrequency() {
|
||||
bool frequency = (comboFrequency->currentIndex() == 0) ? 0 : 1;
|
||||
auto freqVal = spinNthFrame->value();
|
||||
auto timeVal = spinTimeGap->value();
|
||||
auto timeUnit = static_cast<qDefs::timeUnit>(comboTimeGapUnit->currentIndex());
|
||||
auto timeUnit =
|
||||
static_cast<qDefs::timeUnit>(comboTimeGapUnit->currentIndex());
|
||||
stackedTimeInterval->setCurrentIndex(comboFrequency->currentIndex());
|
||||
try {
|
||||
try {
|
||||
if (frequency) {
|
||||
FILE_LOG(logINFO) << "Setting Streaming Frequency to " << freqVal;
|
||||
LOG(logINFO) << "Setting Streaming Frequency to " << freqVal;
|
||||
det->setRxZmqFrequency(freqVal);
|
||||
} else {
|
||||
FILE_LOG(logINFO) << "Setting Streaming Timer to " << timeVal << " " << qDefs::getUnitString(timeUnit);
|
||||
LOG(logINFO) << "Setting Streaming Timer to " << timeVal << " "
|
||||
<< qDefs::getUnitString(timeUnit);
|
||||
auto timeMS = qDefs::getMSTime(std::make_pair(timeVal, timeUnit));
|
||||
det->setRxZmqTimer(timeMS.count());
|
||||
}
|
||||
} CATCH_HANDLE("Could not set streaming frequency/ timer.", "qTabPlot::SetStreamingFrequency", this, &qTabPlot::GetStreamingFrequency)
|
||||
}
|
||||
CATCH_HANDLE("Could not set streaming frequency/ timer.",
|
||||
"qTabPlot::SetStreamingFrequency", this,
|
||||
&qTabPlot::GetStreamingFrequency)
|
||||
}
|
||||
|
||||
void qTabPlot::Refresh() {
|
||||
FILE_LOG(logDEBUG) << "**Updating Plot Tab";
|
||||
LOG(logDEBUG) << "**Updating Plot Tab";
|
||||
|
||||
if (!plot->GetIsRunning()) {
|
||||
boxPlotType->setEnabled(true);
|
||||
@ -578,19 +665,21 @@ void qTabPlot::Refresh() {
|
||||
}
|
||||
GetStreamingFrequency();
|
||||
// gain plot, gap pixels enable
|
||||
switch(det->getDetectorType().squash()) {
|
||||
case slsDetectorDefs::EIGER:
|
||||
chkGapPixels->setEnabled(true);
|
||||
GetGapPixels();
|
||||
break;
|
||||
case slsDetectorDefs::JUNGFRAU:
|
||||
chkGainPlot->setEnabled(true);
|
||||
break;
|
||||
case slsDetectorDefs::GOTTHARD2:
|
||||
chkGainPlot1D->setEnabled(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
switch (det->getDetectorType().squash()) {
|
||||
case slsDetectorDefs::EIGER:
|
||||
chkGapPixels->setEnabled(true);
|
||||
GetGapPixels();
|
||||
break;
|
||||
case slsDetectorDefs::JUNGFRAU:
|
||||
chkGainPlot->setEnabled(true);
|
||||
chkGapPixels->setEnabled(true);
|
||||
GetGapPixels();
|
||||
break;
|
||||
case slsDetectorDefs::GOTTHARD2:
|
||||
chkGainPlot1D->setEnabled(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
boxPlotType->setEnabled(false);
|
||||
@ -600,5 +689,5 @@ void qTabPlot::Refresh() {
|
||||
chkGapPixels->setEnabled(false);
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG) << "**Updated Plot Tab";
|
||||
LOG(logDEBUG) << "**Updated Plot Tab";
|
||||
}
|
||||
|
176
slsDetectorGui/src/qTabSettings.cpp
Executable file → Normal file
176
slsDetectorGui/src/qTabSettings.cpp
Executable file → Normal file
@ -1,37 +1,33 @@
|
||||
#include "qTabSettings.h"
|
||||
#include "qDefs.h"
|
||||
|
||||
#include "ToString.h"
|
||||
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
qTabSettings::qTabSettings(QWidget *parent, sls::Detector *detector): QWidget(parent), det(detector) {
|
||||
qTabSettings::qTabSettings(QWidget *parent, sls::Detector *detector)
|
||||
: QWidget(parent), det(detector) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logDEBUG) << "Settings ready";
|
||||
LOG(logDEBUG) << "Settings ready";
|
||||
}
|
||||
|
||||
qTabSettings::~qTabSettings() {}
|
||||
|
||||
void qTabSettings::SetupWidgetWindow() {
|
||||
|
||||
// enabling according to det type
|
||||
switch(det->getDetectorType().squash()) {
|
||||
case slsDetectorDefs::MYTHEN3:
|
||||
lblSettings->setEnabled(false);
|
||||
comboSettings->setEnabled(false);
|
||||
break;
|
||||
case slsDetectorDefs::EIGER:
|
||||
lblDynamicRange->setEnabled(true);
|
||||
comboDynamicRange->setEnabled(true);
|
||||
lblThreshold->setEnabled(true);
|
||||
spinThreshold->setEnabled(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
// enabling according to det type
|
||||
switch (det->getDetectorType().squash()) {
|
||||
case slsDetectorDefs::MYTHEN3:
|
||||
lblSettings->setEnabled(false);
|
||||
comboSettings->setEnabled(false);
|
||||
break;
|
||||
case slsDetectorDefs::EIGER:
|
||||
lblDynamicRange->setEnabled(true);
|
||||
comboDynamicRange->setEnabled(true);
|
||||
lblThreshold->setEnabled(true);
|
||||
spinThreshold->setEnabled(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// default settings for the disabled
|
||||
@ -40,24 +36,23 @@ void qTabSettings::SetupWidgetWindow() {
|
||||
SetupDetectorSettings();
|
||||
}
|
||||
spinThreshold->setValue(-1);
|
||||
|
||||
Initialization();
|
||||
|
||||
// default for the disabled
|
||||
GetDynamicRange();
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void qTabSettings::SetupDetectorSettings() {
|
||||
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(comboSettings->model());
|
||||
QStandardItemModel *model =
|
||||
qobject_cast<QStandardItemModel *>(comboSettings->model());
|
||||
if (model) {
|
||||
QModelIndex index[NUMSETTINGS];
|
||||
QStandardItem *item[NUMSETTINGS];
|
||||
for (int i = 0; i < NUMSETTINGS; ++i) {
|
||||
index[i] = model->index(i, comboSettings->modelColumn(), comboSettings->rootModelIndex());
|
||||
index[i] = model->index(i, comboSettings->modelColumn(),
|
||||
comboSettings->rootModelIndex());
|
||||
item[i] = model->itemFromIndex(index[i]);
|
||||
item[i]->setEnabled(false);
|
||||
item[i]->setEnabled(false);
|
||||
}
|
||||
switch (det->getDetectorType().squash()) {
|
||||
case slsDetectorDefs::EIGER:
|
||||
@ -86,7 +81,7 @@ void qTabSettings::SetupDetectorSettings() {
|
||||
item[(int)DYNAMICGAIN]->setEnabled(true);
|
||||
item[(int)FIXGAIN1]->setEnabled(true);
|
||||
item[(int)FIXGAIN2]->setEnabled(true);
|
||||
break;
|
||||
break;
|
||||
case slsDetectorDefs::MOENCH:
|
||||
item[(int)G1_HIGHGAIN]->setEnabled(true);
|
||||
item[(int)G1_LOWGAIN]->setEnabled(true);
|
||||
@ -96,11 +91,12 @@ void qTabSettings::SetupDetectorSettings() {
|
||||
item[(int)G2_LOWCAP_LOWGAIN]->setEnabled(true);
|
||||
item[(int)G4_HIGHGAIN]->setEnabled(true);
|
||||
item[(int)G4_LOWGAIN]->setEnabled(true);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logDEBUG) << "Unknown detector type. Exiting GUI.";
|
||||
LOG(logDEBUG) << "Unknown detector type. Exiting GUI.";
|
||||
qDefs::Message(qDefs::CRITICAL,
|
||||
"Unknown detector type. Exiting GUI.", "qTabSettings::SetupDetectorSettings");
|
||||
"Unknown detector type. Exiting GUI.",
|
||||
"qTabSettings::SetupDetectorSettings");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
@ -109,47 +105,57 @@ void qTabSettings::SetupDetectorSettings() {
|
||||
void qTabSettings::Initialization() {
|
||||
// Settings
|
||||
if (comboSettings->isEnabled())
|
||||
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int)));
|
||||
|
||||
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetSettings(int)));
|
||||
|
||||
// Dynamic Range
|
||||
if (comboDynamicRange->isEnabled())
|
||||
connect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int)));
|
||||
connect(comboDynamicRange, SIGNAL(activated(int)), this,
|
||||
SLOT(SetDynamicRange(int)));
|
||||
|
||||
// Threshold
|
||||
if (spinThreshold->isEnabled())
|
||||
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy(int)));
|
||||
connect(spinThreshold, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetThresholdEnergy(int)));
|
||||
}
|
||||
|
||||
void qTabSettings::GetSettings() {
|
||||
FILE_LOG(logDEBUG) << "Getting settings";
|
||||
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int)));
|
||||
try{
|
||||
auto retval = det->getSettings().tsquash("Inconsistent settings for all detectors.");
|
||||
LOG(logDEBUG) << "Getting settings";
|
||||
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetSettings(int)));
|
||||
try {
|
||||
auto retval = det->getSettings().tsquash(
|
||||
"Inconsistent settings for all detectors.");
|
||||
switch (retval) {
|
||||
case slsDetectorDefs::UNDEFINED:
|
||||
comboSettings->setCurrentIndex(UNDEFINED);
|
||||
break;
|
||||
case slsDetectorDefs::UNINITIALIZED:
|
||||
comboSettings->setCurrentIndex(UNINITIALIZED);
|
||||
break;
|
||||
default:
|
||||
if ((int)retval < -1 || (int)retval >= NUMSETTINGS) {
|
||||
throw sls::RuntimeError(std::string("Unknown settings: ") + std::to_string(retval));
|
||||
}
|
||||
comboSettings->setCurrentIndex(retval);
|
||||
break;
|
||||
case slsDetectorDefs::UNDEFINED:
|
||||
comboSettings->setCurrentIndex(UNDEFINED);
|
||||
break;
|
||||
case slsDetectorDefs::UNINITIALIZED:
|
||||
comboSettings->setCurrentIndex(UNINITIALIZED);
|
||||
break;
|
||||
default:
|
||||
if ((int)retval < -1 || (int)retval >= NUMSETTINGS) {
|
||||
throw sls::RuntimeError(std::string("Unknown settings: ") +
|
||||
std::to_string(retval));
|
||||
}
|
||||
comboSettings->setCurrentIndex(retval);
|
||||
break;
|
||||
}
|
||||
} CATCH_DISPLAY ("Could not get settings.", "qTabSettings::GetSettings")
|
||||
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int)));
|
||||
}
|
||||
CATCH_DISPLAY("Could not get settings.", "qTabSettings::GetSettings")
|
||||
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetSettings(int)));
|
||||
}
|
||||
|
||||
void qTabSettings::SetSettings(int index) {
|
||||
// settings
|
||||
auto val = static_cast<slsDetectorDefs::detectorSettings>(index);
|
||||
try {
|
||||
FILE_LOG(logINFO) << "Setting Settings to " << sls::ToString(val);
|
||||
LOG(logINFO) << "Setting Settings to " << sls::ToString(val);
|
||||
det->setSettings(val);
|
||||
} CATCH_HANDLE ("Could not set settings.", "qTabSettings::SetSettings", this, &qTabSettings::GetSettings)
|
||||
}
|
||||
CATCH_HANDLE("Could not set settings.", "qTabSettings::SetSettings", this,
|
||||
&qTabSettings::GetSettings)
|
||||
// threshold
|
||||
if (spinThreshold->isEnabled()) {
|
||||
SetThresholdEnergy(spinThreshold->value());
|
||||
@ -157,10 +163,12 @@ void qTabSettings::SetSettings(int index) {
|
||||
}
|
||||
|
||||
void qTabSettings::GetDynamicRange() {
|
||||
FILE_LOG(logDEBUG) << "Getting dynamic range";
|
||||
disconnect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int)));
|
||||
try {
|
||||
auto retval = det->getDynamicRange().tsquash("Inconsistent dynamic range for all detectors.");
|
||||
LOG(logDEBUG) << "Getting dynamic range";
|
||||
disconnect(comboDynamicRange, SIGNAL(activated(int)), this,
|
||||
SLOT(SetDynamicRange(int)));
|
||||
try {
|
||||
auto retval = det->getDynamicRange().tsquash(
|
||||
"Inconsistent dynamic range for all detectors.");
|
||||
// set the final value on gui
|
||||
switch (retval) {
|
||||
case 32:
|
||||
@ -176,14 +184,19 @@ void qTabSettings::GetDynamicRange() {
|
||||
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_4);
|
||||
break;
|
||||
default:
|
||||
throw sls::RuntimeError(std::string("Unknown dynamic range: ") + std::to_string(retval));
|
||||
throw sls::RuntimeError(std::string("Unknown dynamic range: ") +
|
||||
std::to_string(retval));
|
||||
}
|
||||
} CATCH_DISPLAY ("Could not get dynamic range.", "qTabSettings::GetDynamicRange")
|
||||
connect(comboDynamicRange, SIGNAL(activated(int)), this,SLOT(SetDynamicRange(int)));
|
||||
}
|
||||
CATCH_DISPLAY("Could not get dynamic range.",
|
||||
"qTabSettings::GetDynamicRange")
|
||||
connect(comboDynamicRange, SIGNAL(activated(int)), this,
|
||||
SLOT(SetDynamicRange(int)));
|
||||
}
|
||||
|
||||
void qTabSettings::SetDynamicRange(int index) {
|
||||
FILE_LOG(logINFO) << "Setting dynamic range to " << comboDynamicRange->currentText().toAscii().data();
|
||||
LOG(logINFO) << "Setting dynamic range to "
|
||||
<< comboDynamicRange->currentText().toAscii().data();
|
||||
try {
|
||||
switch (index) {
|
||||
case DYNAMICRANGE_32:
|
||||
@ -199,32 +212,43 @@ void qTabSettings::SetDynamicRange(int index) {
|
||||
det->setDynamicRange(4);
|
||||
break;
|
||||
default:
|
||||
throw sls::RuntimeError(std::string("Unknown dynamic range: ") + std::to_string(index));
|
||||
throw sls::RuntimeError(std::string("Unknown dynamic range: ") +
|
||||
std::to_string(index));
|
||||
}
|
||||
} CATCH_HANDLE ("Could not set dynamic range.", "qTabSettings::SetDynamicRange", this, &qTabSettings::GetDynamicRange)
|
||||
}
|
||||
CATCH_HANDLE("Could not set dynamic range.",
|
||||
"qTabSettings::SetDynamicRange", this,
|
||||
&qTabSettings::GetDynamicRange)
|
||||
}
|
||||
|
||||
void qTabSettings::GetThresholdEnergy() {
|
||||
FILE_LOG(logDEBUG) << "Getting theshold energy";
|
||||
disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy(int)));
|
||||
LOG(logDEBUG) << "Getting theshold energy";
|
||||
disconnect(spinThreshold, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetThresholdEnergy(int)));
|
||||
try {
|
||||
auto retval = det->getThresholdEnergy().tsquash("Inconsistent threhsold energy for all detectors.");
|
||||
auto retval = det->getThresholdEnergy().tsquash(
|
||||
"Inconsistent threhsold energy for all detectors.");
|
||||
spinThreshold->setValue(retval);
|
||||
} CATCH_DISPLAY ("Could not get threshold energy.", "qTabDataOutput::GetThresholdEnergy")
|
||||
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy(int)));
|
||||
}
|
||||
CATCH_DISPLAY("Could not get threshold energy.",
|
||||
"qTabDataOutput::GetThresholdEnergy")
|
||||
connect(spinThreshold, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetThresholdEnergy(int)));
|
||||
}
|
||||
|
||||
void qTabSettings::SetThresholdEnergy(int index) {
|
||||
FILE_LOG(logINFO) << "Setting Threshold Energy to " << index << " eV";
|
||||
LOG(logINFO) << "Setting Threshold Energy to " << index << " eV";
|
||||
try {
|
||||
det->setThresholdEnergy(index);
|
||||
} CATCH_DISPLAY ("Could not get threshold energy.", "qTabSettings::SetThresholdEnergy")
|
||||
}
|
||||
CATCH_DISPLAY("Could not get threshold energy.",
|
||||
"qTabSettings::SetThresholdEnergy")
|
||||
// set the right value anyway (due to tolerance)
|
||||
GetThresholdEnergy();
|
||||
GetThresholdEnergy();
|
||||
}
|
||||
|
||||
void qTabSettings::Refresh() {
|
||||
FILE_LOG(logDEBUG) << "**Updating Settings Tab";
|
||||
LOG(logDEBUG) << "**Updating Settings Tab";
|
||||
|
||||
if (comboSettings->isEnabled()) {
|
||||
GetSettings();
|
||||
@ -233,9 +257,9 @@ void qTabSettings::Refresh() {
|
||||
if (comboDynamicRange->isEnabled()) {
|
||||
GetDynamicRange();
|
||||
}
|
||||
|
||||
|
||||
if (spinThreshold->isEnabled())
|
||||
GetThresholdEnergy();
|
||||
|
||||
FILE_LOG(logDEBUG) << "**Updated Settings Tab";
|
||||
LOG(logDEBUG) << "**Updated Settings Tab";
|
||||
}
|
||||
|
@ -1,7 +1,28 @@
|
||||
|
||||
add_library(slsProjectCWarnings INTERFACE)
|
||||
target_compile_options(slsProjectCWarnings INTERFACE
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wno-unused-parameter #Needs to be slowly mitigated
|
||||
-Wdouble-promotion
|
||||
-Wformat=2
|
||||
-Wredundant-decls
|
||||
# -Wconversion
|
||||
-Wdouble-promotion
|
||||
-Werror=return-type
|
||||
)
|
||||
|
||||
# Install fake the library
|
||||
install(TARGETS slsProjectCWarnings
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
add_subdirectory(ctbDetectorServer)
|
||||
add_subdirectory(eigerDetectorServer)
|
||||
add_subdirectory(gotthardDetectorServer)
|
||||
add_subdirectory(jungfrauDetectorServer)
|
||||
#add_subdirectory(moenchDetectorServer)
|
||||
add_subdirectory(mythen3DetectorServer)
|
||||
add_subdirectory(gotthard2DetectorServer)
|
||||
add_subdirectory(gotthard2DetectorServer)
|
||||
add_subdirectory(moenchDetectorServer)
|
||||
|
@ -32,7 +32,7 @@ target_compile_definitions(ctbDetectorServer_virtual
|
||||
)
|
||||
|
||||
target_link_libraries(ctbDetectorServer_virtual
|
||||
PUBLIC pthread rt
|
||||
PUBLIC pthread rt slsProjectCWarnings
|
||||
)
|
||||
|
||||
set_target_properties(ctbDetectorServer_virtual PROPERTIES
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -36,7 +36,7 @@ typedef struct udp_header_struct {
|
||||
#define UDP_IP_HEADER_LENGTH_BYTES (28)
|
||||
|
||||
/* Enums */
|
||||
enum ADCINDEX {V_PWR_IO, V_PWR_A, V_PWR_B, V_PWR_C, V_PWR_D, I_PWR_IO, I_PWR_A, I_PWR_B, I_PWR_C, I_PWR_D};
|
||||
enum ADCINDEX {V_PWR_IO, V_PWR_A, V_PWR_B, V_PWR_C, V_PWR_D, I_PWR_IO, I_PWR_A, I_PWR_B, I_PWR_C, I_PWR_D, S_ADC0, S_ADC1, S_ADC2, S_ADC3, S_ADC4, S_ADC5, S_ADC6, S_ADC7, S_TMP};
|
||||
enum DACINDEX {D0, D1, D2, D3, D4, D5, D6, D7, D8, D9,
|
||||
D10, D11, D12, D13, D14, D15, D16, D17,
|
||||
D_PWR_D, D_PWR_CHIP, D_PWR_C, D_PWR_B, D_PWR_A, D_PWR_IO};
|
||||
|
@ -25,13 +25,13 @@ int i2c_open(const char* file,unsigned int addr){
|
||||
//device file
|
||||
int fd = open( file, O_RDWR );
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Warning: Unable to open file %s\n",file));
|
||||
LOG(logERROR, ("Warning: Unable to open file %s\n",file));
|
||||
return -1;
|
||||
}
|
||||
|
||||
//device address
|
||||
if( ioctl( fd, I2C_SLAVE, addr&0x7F ) < 0 ) {
|
||||
FILE_LOG(logERROR, ("Warning: Unable to set slave address:0x%x \n",addr));
|
||||
LOG(logERROR, ("Warning: Unable to set slave address:0x%x \n",addr));
|
||||
return -2;
|
||||
}
|
||||
return fd;
|
||||
@ -45,17 +45,17 @@ int i2c_read(){
|
||||
|
||||
unsigned char buf = reg;
|
||||
if (write(fd, &buf, 1)!= 1){
|
||||
FILE_LOG(logERROR, ("Warning: Unable to write read request to register %d\n", reg));
|
||||
LOG(logERROR, ("Warning: Unable to write read request to register %d\n", reg));
|
||||
return -1;
|
||||
}
|
||||
//read and update value (but old value read out)
|
||||
if(read(fd, &buf, 1) != 1){
|
||||
FILE_LOG(logERROR, ("Warning: Unable to read register %d\n", reg));
|
||||
LOG(logERROR, ("Warning: Unable to read register %d\n", reg));
|
||||
return -2;
|
||||
}
|
||||
//read again to read the updated value
|
||||
if(read(fd, &buf, 1) != 1){
|
||||
FILE_LOG(logERROR, ("Warning: Unable to read register %d\n", reg));
|
||||
LOG(logERROR, ("Warning: Unable to read register %d\n", reg));
|
||||
return -2;
|
||||
}
|
||||
close(fd);
|
||||
@ -76,7 +76,7 @@ int i2c_write(unsigned int value){
|
||||
buf[0] = reg;
|
||||
buf[1] = val;
|
||||
if (write(fd, buf, 2) != 2) {
|
||||
FILE_LOG(logERROR, ("Warning: Unable to write %d to register %d\n",val, reg));
|
||||
LOG(logERROR, ("Warning: Unable to write %d to register %d\n",val, reg));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -92,10 +92,10 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
int fd = open(PORTNAME, O_RDWR | O_NOCTTY | O_SYNC);
|
||||
if(fd < 0){
|
||||
FILE_LOG(logERROR, ("Warning: Unable to open port %s\n", PORTNAME));
|
||||
LOG(logERROR, ("Warning: Unable to open port %s\n", PORTNAME));
|
||||
return -1;
|
||||
}
|
||||
FILE_LOG(logINFO, ("opened port at %s\n",PORTNAME));
|
||||
LOG(logINFO, ("opened port at %s\n",PORTNAME));
|
||||
|
||||
struct termios serial_conf;
|
||||
// reset structure
|
||||
@ -110,17 +110,17 @@ int main(int argc, char* argv[]) {
|
||||
serial_conf.c_lflag = ICANON;
|
||||
// flush input
|
||||
if(tcflush(fd, TCIOFLUSH) < 0){
|
||||
FILE_LOG(logERROR, ("Warning: error form tcflush %d\n", errno));
|
||||
LOG(logERROR, ("Warning: error form tcflush %d\n", errno));
|
||||
return 0;
|
||||
}
|
||||
// set new options for the port, TCSANOW:changes occur immediately without waiting for data to complete
|
||||
if(tcsetattr(fd, TCSANOW, &serial_conf) < 0){
|
||||
FILE_LOG(logERROR, ("Warning: error form tcsetattr %d\n", errno));
|
||||
LOG(logERROR, ("Warning: error form tcsetattr %d\n", errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(tcsetattr(fd, TCSAFLUSH, &serial_conf) < 0){
|
||||
FILE_LOG(logERROR, ("Warning: error form tcsetattr %d\n", errno));
|
||||
LOG(logERROR, ("Warning: error form tcsetattr %d\n", errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -130,25 +130,25 @@ int main(int argc, char* argv[]) {
|
||||
char buffer[BUFFERSIZE];
|
||||
memset(buffer,0,BUFFERSIZE);
|
||||
buffer[BUFFERSIZE-1] = '\n';
|
||||
FILE_LOG(logINFO, ("Ready...\n"));
|
||||
LOG(logINFO, ("Ready...\n"));
|
||||
|
||||
|
||||
while(ret != GOODBYE){
|
||||
memset(buffer,0,BUFFERSIZE);
|
||||
n = read(fd,buffer,BUFFERSIZE);
|
||||
FILE_LOG(logDEBUG1, ("Received %d Bytes\n", n));
|
||||
FILE_LOG(logINFO, ("Got message: '%s'\n",buffer));
|
||||
LOG(logDEBUG1, ("Received %d Bytes\n", n));
|
||||
LOG(logINFO, ("Got message: '%s'\n",buffer));
|
||||
|
||||
switch(buffer[0]){
|
||||
case '\0':
|
||||
FILE_LOG(logINFO, ("Got Start (Detector restart)\n"));
|
||||
LOG(logINFO, ("Got Start (Detector restart)\n"));
|
||||
break;
|
||||
case 's':
|
||||
FILE_LOG(logINFO, ("Got Start \n"));
|
||||
LOG(logINFO, ("Got Start \n"));
|
||||
break;
|
||||
case 'p':
|
||||
if (!sscanf(&buffer[1],"%d",&ival)){
|
||||
FILE_LOG(logERROR, ("Warning: cannot scan voltage value\n"));
|
||||
LOG(logERROR, ("Warning: cannot scan voltage value\n"));
|
||||
break;
|
||||
}
|
||||
// ok/ fail
|
||||
@ -158,9 +158,9 @@ int main(int argc, char* argv[]) {
|
||||
strcpy(buffer,"fail ");
|
||||
else
|
||||
strcpy(buffer,"success ");
|
||||
FILE_LOG(logINFO, ("Sending: '%s'\n",buffer));
|
||||
LOG(logINFO, ("Sending: '%s'\n",buffer));
|
||||
n = write(fd, buffer, BUFFERSIZE);
|
||||
FILE_LOG(logDEBUG1, ("Sent %d Bytes\n", n));
|
||||
LOG(logDEBUG1, ("Sent %d Bytes\n", n));
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
@ -173,17 +173,17 @@ int main(int argc, char* argv[]) {
|
||||
else
|
||||
strcpy(buffer,"success ");
|
||||
n = write(fd, buffer, BUFFERSIZE);
|
||||
FILE_LOG(logINFO, ("Sending: '%s'\n",buffer));
|
||||
FILE_LOG(logDEBUG1, ("Sent %d Bytes\n", n));
|
||||
LOG(logINFO, ("Sending: '%s'\n",buffer));
|
||||
LOG(logDEBUG1, ("Sent %d Bytes\n", n));
|
||||
//value
|
||||
memset(buffer,0,BUFFERSIZE);
|
||||
buffer[BUFFERSIZE-1] = '\n';
|
||||
if(ival >= 0){
|
||||
FILE_LOG(logINFO, ("Sending: '%d'\n",ival));
|
||||
LOG(logINFO, ("Sending: '%d'\n",ival));
|
||||
sprintf(buffer,"%d ",ival);
|
||||
n = write(fd, buffer, BUFFERSIZE);
|
||||
FILE_LOG(logINFO, ("Sent %d Bytes\n", n));
|
||||
}else FILE_LOG(logERROR, ("%s\n",buffer));
|
||||
LOG(logINFO, ("Sent %d Bytes\n", n));
|
||||
}else LOG(logERROR, ("%s\n",buffer));
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
@ -191,7 +191,7 @@ int main(int argc, char* argv[]) {
|
||||
ret = GOODBYE;
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Unknown Command. buffer:'%s'\n",buffer));
|
||||
LOG(logERROR, ("Unknown Command. buffer:'%s'\n",buffer));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ unsigned int BebInfo_GetSrcPort(struct BebInfo* bebInfo, int ten_gig) {return te
|
||||
|
||||
|
||||
void BebInfo_Print(struct BebInfo* bebInfo) {
|
||||
FILE_LOG(logINFO, (
|
||||
LOG(logINFO, (
|
||||
"%d) Beb Info:\n"
|
||||
"\tSerial Add: 0x%x\n"
|
||||
"\tMAC 1GbE: %s\n"
|
||||
@ -133,7 +133,7 @@ void Beb_Beb(int id) {
|
||||
|
||||
if (!Beb_InitBebInfos()) exit(1);
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Printing Beb infos:\n"));
|
||||
LOG(logDEBUG1, ("Printing Beb infos:\n"));
|
||||
unsigned int i;
|
||||
for(i=1;i<bebInfoSize;i++) BebInfo_Print(&beb_infos[i]);
|
||||
|
||||
@ -157,12 +157,12 @@ void Beb_GetModuleConfiguration(int* master, int* top, int* normal) {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Module Configuration FAIL\n"));
|
||||
LOG(logERROR, ("Module Configuration FAIL\n"));
|
||||
} else {
|
||||
//read data
|
||||
ret = Beb_Read32(csp0base, MODULE_CONFIGURATION_MASK);
|
||||
FILE_LOG(logDEBUG1, ("Module Configuration OK\n"));
|
||||
FILE_LOG(logDEBUG1, ("Beb: value =0x%x\n",ret));
|
||||
LOG(logDEBUG1, ("Module Configuration OK\n"));
|
||||
LOG(logDEBUG1, ("Beb: value =0x%x\n",ret));
|
||||
if (ret&TOP_BIT_MASK) {
|
||||
*top = 1;
|
||||
Beb_top = 1;
|
||||
@ -215,7 +215,7 @@ void Beb_EndofDataSend(int tengiga) {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_COUNTER_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Delay read counter fail\n"));
|
||||
LOG(logERROR, ("Delay read counter fail\n"));
|
||||
return;
|
||||
} else {
|
||||
//read data first time
|
||||
@ -227,7 +227,7 @@ void Beb_EndofDataSend(int tengiga) {
|
||||
r_framepktMsbcounter = Beb_Read32(csp0base, addr_r_framepktMsbcounter);
|
||||
r_txndelaycounter = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
r_framedelaycounter = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
FILE_LOG(logDEBUG1, ("\nLeft\n"
|
||||
LOG(logDEBUG1, ("\nLeft\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
@ -245,7 +245,7 @@ void Beb_EndofDataSend(int tengiga) {
|
||||
while(1) {
|
||||
maxtimer = MAX(MAX(l_txndelaycounter,l_framedelaycounter),MAX(r_txndelaycounter,r_framedelaycounter));
|
||||
maxtimer /= 100;
|
||||
FILE_LOG(logDEBUG1, ("Will wait for %d us\n",maxtimer));
|
||||
LOG(logDEBUG1, ("Will wait for %d us\n",maxtimer));
|
||||
usleep(maxtimer);
|
||||
|
||||
//read new values
|
||||
@ -257,7 +257,7 @@ void Beb_EndofDataSend(int tengiga) {
|
||||
r_framepktMsbcounter_new = Beb_Read32(csp0base, addr_r_framepktMsbcounter);
|
||||
r_txndelaycounter_new = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
r_framedelaycounter_new = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
FILE_LOG(logDEBUG1, ("\nLeft\n"
|
||||
LOG(logDEBUG1, ("\nLeft\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
@ -288,7 +288,7 @@ void Beb_EndofDataSend(int tengiga) {
|
||||
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO, ("Detector has sent all data\n"));
|
||||
LOG(logINFO, ("Detector has sent all data\n"));
|
||||
//close file pointer
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
@ -310,14 +310,14 @@ int Beb_SetMasterViaSoftware() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Master FAIL\n"));
|
||||
LOG(logERROR, ("Set Master FAIL\n"));
|
||||
} else {
|
||||
value = Beb_Read32(csp0base, MASTERCONFIG_OFFSET);
|
||||
value|=MASTER_BIT;
|
||||
value|=OVERWRITE_HARDWARE_BIT;
|
||||
int newval = Beb_Write32(csp0base, MASTERCONFIG_OFFSET,value);
|
||||
if (newval!=value) {
|
||||
FILE_LOG(logERROR, ("Could not set Master via Software\n"));
|
||||
LOG(logERROR, ("Could not set Master via Software\n"));
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
@ -343,14 +343,14 @@ int Beb_SetSlaveViaSoftware() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Slave FAIL\n"));
|
||||
LOG(logERROR, ("Set Slave FAIL\n"));
|
||||
} else {
|
||||
value = Beb_Read32(csp0base, MASTERCONFIG_OFFSET);
|
||||
value&=~MASTER_BIT;
|
||||
value|=OVERWRITE_HARDWARE_BIT;
|
||||
int newval = Beb_Write32(csp0base, MASTERCONFIG_OFFSET,value);
|
||||
if (newval!=value) {
|
||||
FILE_LOG(logERROR, ("Could not set Slave via Software\n"));
|
||||
LOG(logERROR, ("Could not set Slave via Software\n"));
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
@ -371,11 +371,11 @@ int Beb_Activate(int enable) {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Deactivate FAIL\n"));
|
||||
LOG(logERROR, ("Deactivate FAIL\n"));
|
||||
} else {
|
||||
if (enable > -1) {
|
||||
value = Beb_Read32(csp0base, MASTERCONFIG_OFFSET);
|
||||
FILE_LOG(logINFO, ("Deactivate register value before:%d\n",value));
|
||||
LOG(logINFO, ("Deactivate register value before:%d\n",value));
|
||||
if (enable)
|
||||
value&=~DEACTIVATE_BIT;
|
||||
else
|
||||
@ -384,9 +384,9 @@ int Beb_Activate(int enable) {
|
||||
int newval = Beb_Write32(csp0base, MASTERCONFIG_OFFSET,value);
|
||||
if (newval!=value) {
|
||||
if (enable) {
|
||||
FILE_LOG(logERROR, ("Could not activate via Software\n"));
|
||||
LOG(logERROR, ("Could not activate via Software\n"));
|
||||
} else {
|
||||
FILE_LOG(logERROR, ("Could not deactivate via Software\n"));
|
||||
LOG(logERROR, ("Could not deactivate via Software\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -396,9 +396,9 @@ int Beb_Activate(int enable) {
|
||||
else ret = 1;
|
||||
if (enable == -1) {
|
||||
if (ret) {
|
||||
FILE_LOG(logINFOBLUE, ("Detector is active. Register value:%d\n", value));
|
||||
LOG(logINFOBLUE, ("Detector is active. Register value:%d\n", value));
|
||||
} else {
|
||||
FILE_LOG(logERROR, ("Detector is deactivated! Register value:%d\n", value));
|
||||
LOG(logERROR, ("Detector is deactivated! Register value:%d\n", value));
|
||||
}
|
||||
}
|
||||
|
||||
@ -430,7 +430,7 @@ int Beb_Set32bitOverflow(int val) {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set overflow flag in 32 bit mode. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set overflow flag in 32 bit mode. FAIL\n"));
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
@ -459,7 +459,7 @@ int Beb_GetTenGigaFlowControl() {
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to get ten giga flow control. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to get ten giga flow control. FAIL\n"));
|
||||
return -1;
|
||||
} else {
|
||||
u_int32_t retval = Beb_Read32(csp0base, offset);
|
||||
@ -471,13 +471,13 @@ int Beb_GetTenGigaFlowControl() {
|
||||
}
|
||||
|
||||
int Beb_SetTenGigaFlowControl(int value) {
|
||||
FILE_LOG(logINFO, ("Setting ten giga flow control to %d\n", value));
|
||||
LOG(logINFO, ("Setting ten giga flow control to %d\n", value));
|
||||
value = value == 0 ? 0 : 1;
|
||||
u_int32_t offset = FLOW_REG_OFFSET;
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set ten giga flow control. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set ten giga flow control. FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
// reset bit
|
||||
@ -499,7 +499,7 @@ int Beb_GetTransmissionDelayFrame() {
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to get transmission delay frame. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to get transmission delay frame. FAIL\n"));
|
||||
return -1;
|
||||
} else {
|
||||
u_int32_t retval = Beb_Read32(csp0base, offset);
|
||||
@ -509,16 +509,16 @@ int Beb_GetTransmissionDelayFrame() {
|
||||
}
|
||||
|
||||
int Beb_SetTransmissionDelayFrame(int value) {
|
||||
FILE_LOG(logINFO, ("Setting transmission delay frame to %d\n", value));
|
||||
LOG(logINFO, ("Setting transmission delay frame to %d\n", value));
|
||||
if (value < 0) {
|
||||
FILE_LOG(logERROR, ("Invalid transmission delay frame value %d\n", value));
|
||||
LOG(logERROR, ("Invalid transmission delay frame value %d\n", value));
|
||||
return 0;
|
||||
}
|
||||
u_int32_t offset = TXM_DELAY_FRAME_OFFSET;
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set transmission delay frame. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set transmission delay frame. FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
Beb_Write32(csp0base, offset, value);
|
||||
@ -532,7 +532,7 @@ int Beb_GetTransmissionDelayLeft() {
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to get transmission delay left. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to get transmission delay left. FAIL\n"));
|
||||
return -1;
|
||||
} else {
|
||||
u_int32_t retval = Beb_Read32(csp0base, offset);
|
||||
@ -542,16 +542,16 @@ int Beb_GetTransmissionDelayLeft() {
|
||||
}
|
||||
|
||||
int Beb_SetTransmissionDelayLeft(int value) {
|
||||
FILE_LOG(logINFO, ("Setting transmission delay left to %d\n", value));
|
||||
LOG(logINFO, ("Setting transmission delay left to %d\n", value));
|
||||
if (value < 0) {
|
||||
FILE_LOG(logERROR, ("Invalid transmission delay left value %d\n", value));
|
||||
LOG(logERROR, ("Invalid transmission delay left value %d\n", value));
|
||||
return 0;
|
||||
}
|
||||
u_int32_t offset = TXM_DELAY_LEFT_OFFSET;
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set transmission delay left. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set transmission delay left. FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
Beb_Write32(csp0base, offset, value);
|
||||
@ -565,7 +565,7 @@ int Beb_GetTransmissionDelayRight() {
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to get transmission delay right. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to get transmission delay right. FAIL\n"));
|
||||
return -1;
|
||||
} else {
|
||||
u_int32_t retval = Beb_Read32(csp0base, offset);
|
||||
@ -575,16 +575,16 @@ int Beb_GetTransmissionDelayRight() {
|
||||
}
|
||||
|
||||
int Beb_SetTransmissionDelayRight(int value) {
|
||||
FILE_LOG(logINFO, ("Setting transmission delay right to %d\n", value));
|
||||
LOG(logINFO, ("Setting transmission delay right to %d\n", value));
|
||||
if (value < 0) {
|
||||
FILE_LOG(logERROR, ("Invalid transmission delay right value %d\n", value));
|
||||
LOG(logERROR, ("Invalid transmission delay right value %d\n", value));
|
||||
return 0;
|
||||
}
|
||||
u_int32_t offset = TXM_DELAY_RIGHT_OFFSET;
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set transmission delay right. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set transmission delay right. FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
Beb_Write32(csp0base, offset, value);
|
||||
@ -617,12 +617,12 @@ int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val) {
|
||||
break;
|
||||
|
||||
|
||||
default: FILE_LOG(logERROR, ("Unrecognized mode in network parameter: %d\n",mode)); return -1;
|
||||
default: LOG(logERROR, ("Unrecognized mode in network parameter: %d\n",mode)); return -1;
|
||||
}
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set network parameter. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set network parameter. FAIL\n"));
|
||||
return -1;
|
||||
} else {
|
||||
if (val > -1) {
|
||||
@ -655,11 +655,11 @@ int Beb_ResetToHardwareSettings() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Reset to Hardware Settings FAIL\n"));
|
||||
LOG(logERROR, ("Reset to Hardware Settings FAIL\n"));
|
||||
} else {
|
||||
value = Beb_Write32(csp0base, MASTERCONFIG_OFFSET,0);
|
||||
if (value) {
|
||||
FILE_LOG(logERROR, ("Could not reset to hardware settings\n"));
|
||||
LOG(logERROR, ("Could not reset to hardware settings\n"));
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
@ -682,11 +682,11 @@ u_int32_t Beb_GetFirmwareRevision() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_VERSION);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Firmware Revision Read FAIL\n"));
|
||||
LOG(logERROR, ("Firmware Revision Read FAIL\n"));
|
||||
} else {
|
||||
value = Beb_Read32(csp0base, FIRMWARE_VERSION_OFFSET);
|
||||
if (!value) {
|
||||
FILE_LOG(logERROR, ("Firmware Revision Number does not exist in this version\n"));
|
||||
LOG(logERROR, ("Firmware Revision Number does not exist in this version\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -706,11 +706,11 @@ u_int32_t Beb_GetFirmwareSoftwareAPIVersion() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_VERSION);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Firmware Software API Version Read FAIL\n"));
|
||||
LOG(logERROR, ("Firmware Software API Version Read FAIL\n"));
|
||||
} else {
|
||||
value = Beb_Read32(csp0base, FIRMWARESOFTWARE_API_OFFSET);
|
||||
if (!value) {
|
||||
FILE_LOG(logERROR, ("Firmware Software API Version does not exist in this version\n"));
|
||||
LOG(logERROR, ("Firmware Software API Version does not exist in this version\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -731,14 +731,14 @@ void Beb_ResetFrameNumber() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Reset Frame Number FAIL\n"));
|
||||
LOG(logERROR, ("Reset Frame Number FAIL\n"));
|
||||
} else {
|
||||
//write a 1
|
||||
Beb_Write32(csp0base, FRAME_NUM_RESET_OFFSET, 1);
|
||||
usleep(100000); //100ms
|
||||
//write a 0
|
||||
Beb_Write32(csp0base, FRAME_NUM_RESET_OFFSET, 0);
|
||||
FILE_LOG(logINFO, ("Frame Number Reset OK\n"));
|
||||
LOG(logINFO, ("Frame Number Reset OK\n"));
|
||||
//close file pointer
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
@ -764,7 +764,7 @@ int Beb_InitBebInfos() {//file name at some point
|
||||
|
||||
int i0=Beb_detid,i1=0;
|
||||
if (Beb_GetBebInfoIndex(i0)) {
|
||||
FILE_LOG(logERROR, ("cant add beb. adding beb %d, beb number %d already added.\n",Beb_detid, i0));
|
||||
LOG(logERROR, ("cant add beb. adding beb %d, beb number %d already added.\n",Beb_detid, i0));
|
||||
exit(0);
|
||||
}
|
||||
struct BebInfo b1;
|
||||
@ -798,7 +798,7 @@ int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig, char* src_mac
|
||||
/******* if (!i) return 0;****************************/ //i must be greater than 0, zero is the global send
|
||||
BebInfo_SetHeaderInfo(&beb_infos[i],ten_gig,src_mac,src_ip,src_port);
|
||||
|
||||
FILE_LOG(logINFO, ("Printing Beb info number (%d) :\n",i));
|
||||
LOG(logINFO, ("Printing Beb info number (%d) :\n",i));
|
||||
BebInfo_Print(&beb_infos[i]);
|
||||
|
||||
return 1;
|
||||
@ -813,7 +813,7 @@ int Beb_CheckSourceStuffBebInfo() {
|
||||
if (!Beb_SetHeaderData(
|
||||
BebInfo_GetBebNumber(&beb_infos[i]),0,"00:00:00:00:00:00","10.0.0.1",20000)||
|
||||
!Beb_SetHeaderData(BebInfo_GetBebNumber(&beb_infos[i]),1,"00:00:00:00:00:00","10.0.0.1",20000)) {
|
||||
FILE_LOG(logINFO, ("Error in BebInfo for module number %d.\n",BebInfo_GetBebNumber(&beb_infos[i])));
|
||||
LOG(logINFO, ("Error in BebInfo for module number %d.\n",BebInfo_GetBebNumber(&beb_infos[i])));
|
||||
BebInfo_Print(&beb_infos[i]);
|
||||
return 0;
|
||||
}
|
||||
@ -826,10 +826,10 @@ unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb) {
|
||||
unsigned int i;
|
||||
for(i=1;i<bebInfoSize;i++)
|
||||
if (beb_numb==BebInfo_GetBebNumber(&beb_infos[i])) {
|
||||
FILE_LOG(logDEBUG1, ("*****found beb index:%d, for beb number:%d\n",i,beb_numb));
|
||||
LOG(logDEBUG1, ("*****found beb index:%d, for beb number:%d\n",i,beb_numb));
|
||||
return i;
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("*****Returning 0\n"));
|
||||
LOG(logDEBUG1, ("*****Returning 0\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -841,7 +841,7 @@ int Beb_WriteTo(unsigned int index) {
|
||||
return 1;
|
||||
|
||||
if (index>=bebInfoSize) {
|
||||
FILE_LOG(logERROR, ("WriteTo index error.\n"));
|
||||
LOG(logERROR, ("WriteTo index error.\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -886,7 +886,7 @@ int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header
|
||||
|
||||
int fd = Beb_open(&csp0base,bram_phy_addr);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set up UDP Header FAIL\n"));
|
||||
LOG(logERROR, ("Set up UDP Header FAIL\n"));
|
||||
} else {
|
||||
//read data
|
||||
memcpy(csp0base+header_number*16, &udp_header, sizeof(udp_header));
|
||||
@ -932,18 +932,18 @@ int Beb_SetHeaderData1(char* src_mac, char* src_ip, unsigned int src_port, char*
|
||||
*/
|
||||
|
||||
if (!Beb_SetMAC(src_mac,&(udp_header.src_mac[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Source MAC to %s\n",src_mac));
|
||||
LOG(logINFO, ("Setting Source MAC to %s\n",src_mac));
|
||||
if (!Beb_SetIP(src_ip,&(udp_header.src_ip[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Source IP to %s\n",src_ip));
|
||||
LOG(logINFO, ("Setting Source IP to %s\n",src_ip));
|
||||
if (!Beb_SetPortNumber(src_port,&(udp_header.src_port[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Source port to %d\n",src_port));
|
||||
LOG(logINFO, ("Setting Source port to %d\n",src_port));
|
||||
|
||||
if (!Beb_SetMAC(dst_mac,&(udp_header.dst_mac[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Destination MAC to %s\n",dst_mac));
|
||||
LOG(logINFO, ("Setting Destination MAC to %s\n",dst_mac));
|
||||
if (!Beb_SetIP(dst_ip,&(udp_header.dst_ip[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Destination IP to %s\n",dst_ip));
|
||||
LOG(logINFO, ("Setting Destination IP to %s\n",dst_ip));
|
||||
if (!Beb_SetPortNumber(dst_port,&(udp_header.dst_port[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Destination port to %d\n",dst_port));
|
||||
LOG(logINFO, ("Setting Destination port to %d\n",dst_port));
|
||||
|
||||
|
||||
Beb_AdjustIPChecksum(&udp_header);
|
||||
@ -968,7 +968,7 @@ int Beb_SetMAC(char* mac, uint8_t* dst_ptr) {
|
||||
char *pch = strtok (macVal,":");
|
||||
while (pch != NULL) {
|
||||
if (strlen(pch)!=2) {
|
||||
FILE_LOG(logERROR, ("Error: in mac address -> %s\n",macVal));
|
||||
LOG(logERROR, ("Error: in mac address -> %s\n",macVal));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -987,7 +987,7 @@ int Beb_SetIP(char* ip, uint8_t* dst_ptr) {
|
||||
char *pch = strtok (ipVal,".");
|
||||
while (pch != NULL) {
|
||||
if (((i!=3) && ((strlen(pch)>3) || (strlen(pch)<1))) || ((i==3)&&((strlen(pch)<1) || (strlen(pch) > 3)))) {
|
||||
FILE_LOG(logERROR, ("Error: in ip address -> %s\n",ipVal));
|
||||
LOG(logERROR, ("Error: in ip address -> %s\n",ipVal));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1050,11 +1050,11 @@ int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, i
|
||||
|
||||
|
||||
Beb_send_data[1] = 0x62000000 | (!stop_read_when_fifo_empty) << 27 | (ten_gig==1) << 24 | packet_size << 14 | dst_number << 8 | npackets;
|
||||
FILE_LOG(logDEBUG1, ("Beb_send_data[1]:%X\n",Beb_send_data[1]));
|
||||
LOG(logDEBUG1, ("Beb_send_data[1]:%X\n",Beb_send_data[1]));
|
||||
Beb_send_data[2] = 0;
|
||||
|
||||
Beb_SwapDataFun(0,2,&(Beb_send_data[1]));
|
||||
FILE_LOG(logDEBUG1, ("Beb_send_data[1] Swapped:%X\n",Beb_send_data[1]));
|
||||
LOG(logDEBUG1, ("Beb_send_data[1] Swapped:%X\n",Beb_send_data[1]));
|
||||
|
||||
if (Beb_activated) {
|
||||
if (!Beb_WriteTo(i)) return 0;
|
||||
@ -1085,7 +1085,7 @@ int Beb_StopAcquisition()
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_CMD_GENERATOR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Beb Stop Acquisition FAIL\n"));
|
||||
LOG(logERROR, ("Beb Stop Acquisition FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
//find value
|
||||
@ -1098,7 +1098,7 @@ int Beb_StopAcquisition()
|
||||
Beb_Write32(csp0base, (LEFT_OFFSET + STOP_ACQ_OFFSET),(valuel&(~STOP_ACQ_BIT)));
|
||||
Beb_Write32(csp0base, (RIGHT_OFFSET + STOP_ACQ_OFFSET),(valuer&(~STOP_ACQ_BIT)));
|
||||
|
||||
FILE_LOG(logINFO, ("Beb Stop Acquisition OK\n"));
|
||||
LOG(logINFO, ("Beb Stop Acquisition OK\n"));
|
||||
//close file pointer
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
@ -1116,7 +1116,7 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
unsigned int nl = Beb_readNLines;
|
||||
unsigned int npackets = (nl * maxnp) / maxnl;
|
||||
if ((nl * maxnp) % maxnl) {
|
||||
FILE_LOG(logERROR, ("Read N Lines is incorrect. Switching to Full Image Readout\n"));
|
||||
LOG(logERROR, ("Read N Lines is incorrect. Switching to Full Image Readout\n"));
|
||||
npackets = maxnp;
|
||||
}
|
||||
int in_two_requests = (npackets > MAX_PACKETS_PER_REQUEST) ? 1 : 0;
|
||||
@ -1126,8 +1126,8 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
unsigned int header_size = 4; //4*64 bits
|
||||
unsigned int packet_size = ten_gig ? 0x200 : 0x80; // 4k or 1k packets
|
||||
|
||||
FILE_LOG(logDEBUG1, ("----Beb_RequestNImages Start----\n"));
|
||||
FILE_LOG(logINFO, ("beb_number:%d, ten_gig:%d,dst_number:%d, npackets:%d, "
|
||||
LOG(logDEBUG1, ("----Beb_RequestNImages Start----\n"));
|
||||
LOG(logINFO, ("beb_number:%d, ten_gig:%d,dst_number:%d, npackets:%d, "
|
||||
"Beb_bit_mode:%d, header_size:%d, nimages:%d, test_just_send_out_packets_no_wait:%d\n",
|
||||
beb_number, ten_gig, dst_number, npackets, Beb_bit_mode, header_size,
|
||||
nimages, test_just_send_out_packets_no_wait));
|
||||
@ -1138,13 +1138,13 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_CMD_GENERATOR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Beb Request N Images FAIL\n"));
|
||||
LOG(logERROR, ("Beb Request N Images FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < 10; i++)
|
||||
FILE_LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4))));
|
||||
LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4))));
|
||||
}
|
||||
// Generating commands
|
||||
u_int32_t send_header_command = 0x62000000 | (!test_just_send_out_packets_no_wait) << 27 | (ten_gig==1) << 24 | header_size << 14 | 0;
|
||||
@ -1152,8 +1152,8 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < 10; i++)
|
||||
FILE_LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4))));
|
||||
FILE_LOG(logDEBUG1, ("%d\n",in_two_requests));
|
||||
LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4))));
|
||||
LOG(logDEBUG1, ("%d\n",in_two_requests));
|
||||
}
|
||||
//"0x20 << 8" is dst_number (0x00 for left, 0x20 for right)
|
||||
//Left
|
||||
@ -1181,12 +1181,12 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < 10; i++)
|
||||
FILE_LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4)))); //*(ptrl+i));
|
||||
FILE_LOG(logDEBUG1, ("%d\n",in_two_requests));
|
||||
LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4)))); //*(ptrl+i));
|
||||
LOG(logDEBUG1, ("%d\n",in_two_requests));
|
||||
}
|
||||
Beb_close(fd,csp0base);
|
||||
|
||||
FILE_LOG(logDEBUG1, ("----Beb_RequestNImages----\n"));
|
||||
LOG(logDEBUG1, ("----Beb_RequestNImages----\n"));
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -1194,7 +1194,7 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
|
||||
|
||||
int Beb_Test(unsigned int beb_number) {
|
||||
FILE_LOG(logINFO, ("Testing module number: %d\n",beb_number));
|
||||
LOG(logINFO, ("Testing module number: %d\n",beb_number));
|
||||
|
||||
|
||||
//int SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header_number, string dst_mac, string dst_ip, unsigned int dst_port) {
|
||||
@ -1202,14 +1202,14 @@ int Beb_Test(unsigned int beb_number) {
|
||||
|
||||
unsigned int index = Beb_GetBebInfoIndex(beb_number);
|
||||
if (!index) {
|
||||
FILE_LOG(logERROR, ("Error beb number (%d)not in list????\n",beb_number));
|
||||
LOG(logERROR, ("Error beb number (%d)not in list????\n",beb_number));
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int i;
|
||||
for(i=0;i<64;i++) {
|
||||
if (!Beb_SetUpUDPHeader(beb_number,0,i,"60:fb:42:f4:e3:d2","129.129.205.186",22000+i)) {
|
||||
FILE_LOG(logERROR, ("Error setting up header table....\n"));
|
||||
LOG(logERROR, ("Error setting up header table....\n"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1217,7 +1217,7 @@ int Beb_Test(unsigned int beb_number) {
|
||||
// SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, int stop_read_when_fifo_empty=1);
|
||||
for(i=0;i<64;i++) {
|
||||
if (!Beb_SendMultiReadRequest(beb_number,i%3+1,0,i,1,0,1)) {
|
||||
FILE_LOG(logERROR, ("Error requesting data....\n"));
|
||||
LOG(logERROR, ("Error requesting data....\n"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1237,7 +1237,7 @@ int Beb_GetBebFPGATemp()
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_SYSMON_0_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Module Configuration FAIL\n"));
|
||||
LOG(logERROR, ("Module Configuration FAIL\n"));
|
||||
} else {
|
||||
//read data
|
||||
ret = Beb_Read32(csp0base, FPGA_TEMP_OFFSET);
|
||||
@ -1255,11 +1255,11 @@ void Beb_SetDetectorNumber(uint32_t detid) {
|
||||
return;
|
||||
|
||||
uint32_t swapid = Beb_swap_uint16(detid);
|
||||
//FILE_LOG(logINFO, "detector id %d swapped %d\n", detid, swapid));
|
||||
//LOG(logINFO, "detector id %d swapped %d\n", detid, swapid));
|
||||
u_int32_t* csp0base=0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_TEST_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
return;
|
||||
} else {
|
||||
uint32_t value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
|
||||
@ -1267,24 +1267,24 @@ void Beb_SetDetectorNumber(uint32_t detid) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
|
||||
if ((value & UDP_HEADER_ID_MSK) != ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)) {
|
||||
FILE_LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
}
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
|
||||
value &= UDP_HEADER_X_MSK; // to keep previous x value
|
||||
Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
|
||||
if ((value & UDP_HEADER_ID_MSK) != ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)) {
|
||||
FILE_LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
}
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
FILE_LOG(logINFO, ("Detector id %d set in UDP Header\n\n", detid));
|
||||
LOG(logINFO, ("Detector id %d set in UDP Header\n\n", detid));
|
||||
}
|
||||
|
||||
int Beb_SetQuad(int value) {
|
||||
if (value < 0)
|
||||
return OK;
|
||||
FILE_LOG(logINFO, ("Setting Quad to %d in Beb\n", value));
|
||||
LOG(logINFO, ("Setting Quad to %d in Beb\n", value));
|
||||
Beb_quadEnable = (value == 0 ? 0 : 1);
|
||||
return Beb_SetDetectorPosition(Beb_positions);
|
||||
}
|
||||
@ -1300,7 +1300,7 @@ int* Beb_GetDetectorPosition() {
|
||||
int Beb_SetDetectorPosition(int pos[]) {
|
||||
if (!Beb_activated)
|
||||
return OK;
|
||||
FILE_LOG(logINFO, ("Got Position values %d %d...\n", pos[0],pos[1]));
|
||||
LOG(logINFO, ("Got Position values %d %d...\n", pos[0],pos[1]));
|
||||
|
||||
// save positions
|
||||
Beb_positions[0] = pos[0];
|
||||
@ -1321,7 +1321,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_TEST_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Detector Position FAIL\n"));
|
||||
LOG(logERROR, ("Set Detector Position FAIL\n"));
|
||||
return FAIL;
|
||||
} else {
|
||||
uint32_t value = 0;
|
||||
@ -1333,7 +1333,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
|
||||
if ((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) {
|
||||
FILE_LOG(logERROR, ("Could not set row position for left port\n"));
|
||||
LOG(logERROR, ("Could not set row position for left port\n"));
|
||||
ret = FAIL;
|
||||
}
|
||||
// x right
|
||||
@ -1343,7 +1343,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
|
||||
if ((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) {
|
||||
FILE_LOG(logERROR, ("Could not set row position for right port\n"));
|
||||
LOG(logERROR, ("Could not set row position for right port\n"));
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
@ -1356,7 +1356,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, value | ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST);
|
||||
if ((value & UDP_HEADER_Y_MSK) != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)) {
|
||||
FILE_LOG(logERROR, ("Could not set column position for left port\n"));
|
||||
LOG(logERROR, ("Could not set column position for left port\n"));
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
@ -1367,7 +1367,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, value | ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST);
|
||||
if ((value & UDP_HEADER_Y_MSK) != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)) {
|
||||
FILE_LOG(logERROR, ("Could not set column position for right port\n"));
|
||||
LOG(logERROR, ("Could not set column position for right port\n"));
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
@ -1376,7 +1376,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
if (ret == OK) {
|
||||
FILE_LOG(logINFO, ("Position set to...\n"
|
||||
LOG(logINFO, ("Position set to...\n"
|
||||
"\tLeft: [%d, %d]\n"
|
||||
"\tRight:[%d, %d]\n",
|
||||
posLeft[0], posLeft[1], posRight[0], posRight[1]));
|
||||
@ -1390,12 +1390,12 @@ int Beb_SetStartingFrameNumber(uint64_t value) {
|
||||
Beb_deactivatedStartFrameNumber = value;
|
||||
return OK;
|
||||
}
|
||||
FILE_LOG(logINFO, ("Setting start frame number: %llu\n", (long long unsigned int)value));
|
||||
LOG(logINFO, ("Setting start frame number: %llu\n", (long long unsigned int)value));
|
||||
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_TEST_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Start Frame Number FAIL\n"));
|
||||
LOG(logERROR, ("Set Start Frame Number FAIL\n"));
|
||||
return FAIL;
|
||||
}
|
||||
// since the read is not implemented in firmware yet
|
||||
@ -1407,7 +1407,7 @@ int Beb_SetStartingFrameNumber(uint64_t value) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_FRAME_NUMBER_MSB_OFST, (valueInFirmware >> 32) & (0xffffffff));
|
||||
Beb_close(fd,csp0base);
|
||||
|
||||
FILE_LOG(logINFO, ("Going to reset Frame Number\n"));
|
||||
LOG(logINFO, ("Going to reset Frame Number\n"));
|
||||
Beb_ResetFrameNumber();
|
||||
return OK;
|
||||
}
|
||||
@ -1418,11 +1418,11 @@ int Beb_GetStartingFrameNumber(uint64_t* retval, int tengigaEnable) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Getting start frame number\n"));
|
||||
LOG(logDEBUG1, ("Getting start frame number\n"));
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base, XPAR_COUNTER_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Get Start Frame Number FAIL\n"));
|
||||
LOG(logERROR, ("Get Start Frame Number FAIL\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -1440,7 +1440,7 @@ int Beb_GetStartingFrameNumber(uint64_t* retval, int tengigaEnable) {
|
||||
|
||||
Beb_close(fd,csp0base);
|
||||
if (left1g != right1g) {
|
||||
FILE_LOG(logERROR, ("Retrieved inconsistent frame numbers from 1g left %llu and right %llu\n",
|
||||
LOG(logERROR, ("Retrieved inconsistent frame numbers from 1g left %llu and right %llu\n",
|
||||
(long long int)left1g, (long long int)right1g));
|
||||
*retval = (left1g > right1g) ? left1g : right1g; // give max to set it to when stopping acq & different value
|
||||
return -2; // to differentiate between failed address mapping
|
||||
@ -1461,7 +1461,7 @@ int Beb_GetStartingFrameNumber(uint64_t* retval, int tengigaEnable) {
|
||||
++right10g; // increment for firmware
|
||||
|
||||
if (left10g != right10g) {
|
||||
FILE_LOG(logERROR, ("Retrieved inconsistent frame numbers from `0g left %llu and right %llu\n",
|
||||
LOG(logERROR, ("Retrieved inconsistent frame numbers from `0g left %llu and right %llu\n",
|
||||
(long long int)left10g, (long long int)right10g));
|
||||
*retval = (left10g > right10g) ? left10g : right10g; // give max to set it to when stopping acq & different value
|
||||
return -2; // to differentiate between failed address mapping
|
||||
@ -1484,15 +1484,15 @@ int Beb_open(u_int32_t** csp0base, u_int32_t offset) {
|
||||
|
||||
int fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
|
||||
if (fd == -1) {
|
||||
FILE_LOG(logERROR, ("\nCan't find /dev/mem!\n"));
|
||||
LOG(logERROR, ("\nCan't find /dev/mem!\n"));
|
||||
} else {
|
||||
FILE_LOG(logDEBUG1, ("/dev/mem opened\n"));
|
||||
LOG(logDEBUG1, ("/dev/mem opened\n"));
|
||||
*csp0base = (u_int32_t*)mmap(0, BEB_MMAP_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, offset);
|
||||
if (*csp0base == MAP_FAILED) {
|
||||
FILE_LOG(logERROR, ("\nCan't map memmory area!!\n"));
|
||||
LOG(logERROR, ("\nCan't map memmory area!!\n"));
|
||||
fd = -1;
|
||||
}
|
||||
else FILE_LOG(logDEBUG1, ("CSP0 mapped %p\n",(void*)*csp0base));
|
||||
else LOG(logDEBUG1, ("CSP0 mapped %p\n",(void*)*csp0base));
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
@ -22,12 +22,12 @@ target_include_directories(eigerDetectorServerMaster_virtual
|
||||
|
||||
target_compile_definitions(eigerDetectorServerMaster_virtual
|
||||
PUBLIC EIGERD PCCOMPILE STOP_SERVER
|
||||
PUBLIC VIRTUAL DVIRTUAL_9M
|
||||
PUBLIC VIRTUAL #VIRTUAL_9M
|
||||
PUBLIC VIRTUAL_MASTER
|
||||
)
|
||||
|
||||
target_link_libraries(eigerDetectorServerMaster_virtual
|
||||
PUBLIC pthread rt
|
||||
PUBLIC pthread rt slsProjectCWarnings
|
||||
)
|
||||
|
||||
set_target_properties(eigerDetectorServerMaster_virtual PROPERTIES
|
||||
@ -38,27 +38,60 @@ install(TARGETS eigerDetectorServerMaster_virtual
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
add_executable(eigerDetectorServerSlave_virtual
|
||||
|
||||
|
||||
|
||||
|
||||
add_executable(eigerDetectorServerSlaveTop_virtual
|
||||
${src}
|
||||
)
|
||||
|
||||
target_include_directories(eigerDetectorServerSlave_virtual
|
||||
target_include_directories(eigerDetectorServerSlaveTop_virtual
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_compile_definitions(eigerDetectorServerSlave_virtual
|
||||
target_compile_definitions(eigerDetectorServerSlaveTop_virtual
|
||||
PUBLIC EIGERD PCCOMPILE STOP_SERVER
|
||||
PUBLIC VIRTUAL DVIRTUAL_9M
|
||||
PUBLIC VIRTUAL #VIRTUAL_9M
|
||||
PUBLIC VIRTUAL_TOP
|
||||
)
|
||||
|
||||
target_link_libraries(eigerDetectorServerSlave_virtual
|
||||
target_link_libraries(eigerDetectorServerSlaveTop_virtual
|
||||
PUBLIC pthread rt
|
||||
)
|
||||
|
||||
set_target_properties(eigerDetectorServerSlave_virtual PROPERTIES
|
||||
set_target_properties(eigerDetectorServerSlaveTop_virtual PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
install(TARGETS eigerDetectorServerSlave_virtual
|
||||
install(TARGETS eigerDetectorServerSlaveTop_virtual
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
add_executable(eigerDetectorServerSlaveBottom_virtual
|
||||
${src}
|
||||
)
|
||||
|
||||
target_include_directories(eigerDetectorServerSlaveBottom_virtual
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_compile_definitions(eigerDetectorServerSlaveBottom_virtual
|
||||
PUBLIC EIGERD PCCOMPILE STOP_SERVER
|
||||
PUBLIC VIRTUAL #VIRTUAL_9M
|
||||
)
|
||||
|
||||
target_link_libraries(eigerDetectorServerSlaveBottom_virtual
|
||||
PUBLIC pthread rt
|
||||
)
|
||||
|
||||
set_target_properties(eigerDetectorServerSlaveBottom_virtual PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
install(TARGETS eigerDetectorServerSlaveBottom_virtual
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -55,7 +55,7 @@ void Feb_Interface_SendCompleteList(unsigned int n,unsigned int* list) {
|
||||
int Feb_Interface_WriteTo(unsigned int ch) {
|
||||
if (ch>0xfff) return 0;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("FIW ch %d\n", ch));
|
||||
LOG(logDEBUG1, ("FIW ch %d\n", ch));
|
||||
|
||||
Feb_Interface_send_data_raw[0] = 0x8fff0000;
|
||||
if (Local_Write(ll,4,Feb_Interface_send_data_raw)!=4) return 0;
|
||||
@ -176,7 +176,7 @@ int Feb_Interface_WriteMemory(unsigned int sub_num, unsigned int mem_num, unsign
|
||||
start_address &= 0x3fff;
|
||||
nwrites &= 0x3ff;
|
||||
if (!nwrites||nwrites>Feb_Interface_send_buffer_size-2) {
|
||||
FILE_LOG(logERROR, ("invalid nwrites:%d\n",nwrites));
|
||||
LOG(logERROR, ("invalid nwrites:%d\n",nwrites));
|
||||
return 0;
|
||||
}//*d-1026
|
||||
|
||||
|
@ -8,18 +8,18 @@
|
||||
|
||||
|
||||
void Local_LocalLinkInterface1(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr) {
|
||||
FILE_LOG(logDEBUG1, ("Initialize PLB LL FIFOs\n"));
|
||||
LOG(logDEBUG1, ("Initialize PLB LL FIFOs\n"));
|
||||
ll->ll_fifo_base=0;
|
||||
ll->ll_fifo_ctrl_reg=0;
|
||||
if (Local_Init(ll,ll_fifo_badr)) {
|
||||
Local_Reset(ll);
|
||||
FILE_LOG(logDEBUG1, ("\tFIFO Status : 0x%08x\n\n\n", Local_StatusVector(ll)));
|
||||
} else FILE_LOG(logERROR, ("\tCould not map LocalLink : 0x%08x\n\n\n", ll_fifo_badr));
|
||||
LOG(logDEBUG1, ("\tFIFO Status : 0x%08x\n\n\n", Local_StatusVector(ll)));
|
||||
} else LOG(logERROR, ("\tCould not map LocalLink : 0x%08x\n\n\n", ll_fifo_badr));
|
||||
}
|
||||
|
||||
|
||||
void Local_LocalLinkInterface(struct LocalLinkInterface* ll) {
|
||||
FILE_LOG(logDEBUG1, ("Initializing new memory\n"));
|
||||
LOG(logDEBUG1, ("Initializing new memory\n"));
|
||||
}
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ int Local_Reset(struct LocalLinkInterface* ll) {
|
||||
|
||||
int Local_Reset1(struct LocalLinkInterface* ll,unsigned int rst_mask) {
|
||||
ll->ll_fifo_ctrl_reg |= rst_mask;
|
||||
FILE_LOG(logDEBUG1, ("\tCTRL Register bits: 0x%08x\n",ll->ll_fifo_ctrl_reg));
|
||||
LOG(logDEBUG1, ("\tCTRL Register bits: 0x%08x\n",ll->ll_fifo_ctrl_reg));
|
||||
|
||||
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
|
||||
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
|
||||
@ -90,9 +90,9 @@ int Local_Write(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buf
|
||||
last_word = (buffer_len-1)/4;
|
||||
word_ptr = (unsigned int *)buffer;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("LL Write - Len: %2d - If: %X - Data: ",buffer_len, ll->ll_fifo_base));
|
||||
LOG(logDEBUG1, ("LL Write - Len: %2d - If: %X - Data: ",buffer_len, ll->ll_fifo_base));
|
||||
for (i=0; i < buffer_len/4; i++)
|
||||
FILE_LOG(logDEBUG1, ("%.8X ",*(((unsigned *) buffer)+i)));
|
||||
LOG(logDEBUG1, ("%.8X ",*(((unsigned *) buffer)+i)));
|
||||
|
||||
while (words_send <= last_word)
|
||||
{
|
||||
@ -101,7 +101,7 @@ int Local_Write(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buf
|
||||
status = HWIO_xfs_in32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS);
|
||||
if ((status & PLB_LL_FIFO_STATUS_ALMOSTFULL) == 0) vacancy = 1;
|
||||
if (vacancy == 0) {
|
||||
FILE_LOG(logERROR, ("Fifo full!\n"));
|
||||
LOG(logERROR, ("Fifo full!\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff
|
||||
volatile unsigned int fifo_val;
|
||||
int sof = 0;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("LL Read - If: %X - Data: ",ll->ll_fifo_base));
|
||||
LOG(logDEBUG1, ("LL Read - If: %X - Data: ",ll->ll_fifo_base));
|
||||
|
||||
word_ptr = (unsigned int *)buffer;
|
||||
do
|
||||
@ -162,7 +162,7 @@ int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff
|
||||
{
|
||||
if ( (buffer_len >> 2) > buffer_ptr)
|
||||
{
|
||||
FILE_LOG(logDEBUG1, ("%.8X ", fifo_val));
|
||||
LOG(logDEBUG1, ("%.8X ", fifo_val));
|
||||
word_ptr[buffer_ptr++] = fifo_val; //write to buffer
|
||||
}
|
||||
else
|
||||
@ -174,7 +174,7 @@ int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff
|
||||
if (status & PLB_LL_FIFO_STATUS_LL_EOF)
|
||||
{
|
||||
len = (buffer_ptr << 2) -3 + ( (status & PLB_LL_FIFO_STATUS_LL_REM)>>PLB_LL_FIFO_STATUS_LL_REM_SHIFT );
|
||||
FILE_LOG(logDEBUG1, ("Len: %d\n",len));
|
||||
LOG(logDEBUG1, ("Len: %d\n",len));
|
||||
buffer_ptr = 0;
|
||||
return len;
|
||||
}
|
||||
@ -207,11 +207,11 @@ int Local_Test(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff
|
||||
|
||||
do{
|
||||
len = Local_Read(ll,rec_buff_len,rec_buffer);
|
||||
FILE_LOG(logDEBUG1, ("receive length: %i\n",len));
|
||||
LOG(logDEBUG1, ("receive length: %i\n",len));
|
||||
|
||||
if (len > 0) {
|
||||
rec_buffer[len]=0;
|
||||
FILE_LOG(logINFO, ("%s\n", (char*) rec_buffer));
|
||||
LOG(logINFO, ("%s\n", (char*) rec_buffer));
|
||||
}
|
||||
} while(len > 0);
|
||||
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -76,6 +76,8 @@ enum CLKINDEX {RUN_CLK, NUM_CLOCKS};
|
||||
#define DEFAULT_TEST_MODE (0)
|
||||
#define DEFAULT_HIGH_VOLTAGE (0)
|
||||
|
||||
#define MAX_TRIMBITS_VALUE (63)
|
||||
|
||||
#define MAX_ROWS_PER_READOUT (256)
|
||||
#define MAX_PACKETS_PER_REQUEST (256)
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user