mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-17 15:27:13 +02:00
Compare commits
120 Commits
2020.03.18
...
separateRx
Author | SHA1 | Date | |
---|---|---|---|
92be88ee19 | |||
56bc9c4e08 | |||
edbd70e91a | |||
4f712fcd70 | |||
bb32b2f653 | |||
085cbbf0d6 | |||
45a770cf38 | |||
990008c9d9 | |||
5339e16101 | |||
c976c63fb5 | |||
9ee2d389fb | |||
8d0146949c | |||
6de68eacc2 | |||
94103a05b1 | |||
1185f1ea17 | |||
d3f420ffd4 | |||
6b5511c9e5 | |||
d8aa1ab08e | |||
b4c31327d6 | |||
c408f9807a | |||
c1ae67ac46 | |||
9df128fced | |||
e39ec65d19 | |||
601be462af | |||
68f76e5356 | |||
8afa11ed33 | |||
bc389f4825 | |||
095ced153c | |||
1d31695cc1 | |||
df63a6dffe | |||
cfa9049ed3 | |||
a1a5a20845 | |||
9a208caca8 | |||
78fb8080ce | |||
cd45f9d45b | |||
c725a05ef8 | |||
d536ad2b5b | |||
815b6a37aa | |||
655a410d43 | |||
97ba81d923 | |||
3d00eed0f0 | |||
2921cbfac8 | |||
a7f5300455 | |||
2f33a1a479 | |||
39fa5e0185 | |||
ba4985ed4d | |||
f811c065d1 | |||
3a1d87728c | |||
0652ff6b5a | |||
373e177274 | |||
6dd6685e7d | |||
38c31fdada | |||
b3fe0e79bc | |||
215e4a56fd | |||
71a68c2022 | |||
55f8497eac | |||
738f341265 | |||
c4ae876ca7 | |||
07cd71f0c7 | |||
9f3ad4e2f4 | |||
ab9fed45fb | |||
a86ae0cb47 | |||
bdf0f9e2b9 | |||
fad10273ed | |||
83283b672a | |||
456b96446f | |||
80e55cd4da | |||
47b0e46f15 | |||
fdb6e3f3d4 | |||
eeed102bf3 | |||
7c7f7e8c70 | |||
262b4b0b16 | |||
83010de9f4 | |||
f2dd146e56 | |||
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 |
@ -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)
|
||||
|
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
|
||||
|
||||
|
||||
|
||||
|
@ -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,71 +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/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)
|
||||
#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)
|
||||
|
@ -62,6 +62,27 @@ you should be able to configure and build your project in this way.
|
||||
|
||||
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
|
||||
-----------------------------
|
||||
|
||||
|
@ -21,5 +21,49 @@ Build from source using CMake
|
||||
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
|
@ -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
|
||||
|
||||
|
||||
|
@ -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
@ -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)
|
||||
|
@ -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,13 +314,13 @@ 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;
|
||||
delete [] image;
|
||||
image=NULL;
|
||||
}
|
||||
image=new int[nn];
|
||||
@ -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 */
|
||||
};
|
||||
|
||||
|
@ -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/>
|
||||
|
@ -14,7 +14,7 @@ class qCloneWidget : public QMainWindow, private Ui::ClonePlotObject {
|
||||
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 displayStats, QString min, QString max, QString sum, bool completeImage);
|
||||
|
||||
~qCloneWidget();
|
||||
|
||||
|
@ -59,11 +59,9 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
|
||||
|
||||
private slots:
|
||||
void SetSaveFileName(QString val);
|
||||
void AcquireThread();
|
||||
void UpdatePlot();
|
||||
|
||||
signals:
|
||||
void StartAcquireSignal();
|
||||
void AcquireFinishedSignal();
|
||||
void AbortSignal();
|
||||
void UpdateSignal();
|
||||
@ -74,6 +72,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
|
||||
void SetupPlots();
|
||||
void GetStatistics(double &min, double &max, double &sum);
|
||||
void DetachHists();
|
||||
void AcquireThread();
|
||||
static void GetAcquisitionFinishedCallBack(double currentProgress,
|
||||
int detectorStatus,
|
||||
void *this_pointer);
|
||||
@ -114,6 +113,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
|
||||
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};
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "SlsQt2DPlot.h"
|
||||
#include "ansi.h"
|
||||
// #include "ansi.h"
|
||||
|
||||
#include <qlist.h>
|
||||
#include <qprinter.h>
|
||||
|
@ -15,13 +15,20 @@ 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)
|
||||
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() {
|
||||
|
@ -87,7 +87,6 @@ void qDrawPlot::SetupWidgetWindow() {
|
||||
|
||||
void qDrawPlot::Initialization() {
|
||||
connect(this, SIGNAL(UpdateSignal()), this, SLOT(UpdatePlot()));
|
||||
connect(this, SIGNAL(StartAcquireSignal()), this, SLOT(AcquireThread()));
|
||||
}
|
||||
|
||||
void qDrawPlot::SetupPlots() {
|
||||
@ -97,27 +96,13 @@ void qDrawPlot::SetupPlots() {
|
||||
slsDetectorDefs::xy res = det->getDetectorSize();
|
||||
nPixelsX = res.x;
|
||||
nPixelsY = res.y;
|
||||
switch (detType) {
|
||||
case slsDetectorDefs::EIGER:
|
||||
try {
|
||||
if (det->getQuad().tsquash("Inconsistent values for quad type")) {
|
||||
nPixelsX /= 2;
|
||||
nPixelsY *= 2;
|
||||
if (nPixelsX != nPixelsY) {
|
||||
--nPixelsX;
|
||||
}
|
||||
}
|
||||
}
|
||||
CATCH_DISPLAY("Could not get quad.", "qDrawPlot::SetupPlots")
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
LOG(logINFO) << "nPixelsX:" << nPixelsX;
|
||||
LOG(logINFO) << "nPixelsY:" << nPixelsY;
|
||||
|
||||
boxPlot->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
widgetStatistics->hide();
|
||||
lblCompleteImage->hide();
|
||||
lblInCompleteImage->hide();
|
||||
|
||||
// setup 1d data
|
||||
|
||||
@ -365,15 +350,18 @@ double qDrawPlot::GetYMaximum() {
|
||||
void qDrawPlot::SetDataCallBack(bool enable) {
|
||||
LOG(logINFO) << "Setting data call back to " << std::boolalpha
|
||||
<< enable << std::noboolalpha;
|
||||
if (enable) {
|
||||
isPlot = true;
|
||||
det->setRxZmqDataStream(true);
|
||||
det->registerDataCallback(&(GetDataCallBack), this);
|
||||
} else {
|
||||
isPlot = false;
|
||||
det->setRxZmqDataStream(false);
|
||||
det->registerDataCallback(nullptr, this);
|
||||
}
|
||||
try {
|
||||
if (enable) {
|
||||
isPlot = true;
|
||||
det->registerDataCallback(&(GetDataCallBack), this);
|
||||
det->setRxZmqDataStream(true);
|
||||
} else {
|
||||
isPlot = false;
|
||||
det->registerDataCallback(nullptr, this);
|
||||
det->setRxZmqDataStream(false);
|
||||
}
|
||||
} CATCH_DISPLAY("Could not get set rxr data streaming enable.",
|
||||
"qDrawPlot::SetDataCallBack")
|
||||
}
|
||||
|
||||
void qDrawPlot::SetBinary(bool enable, int from, int to) {
|
||||
@ -583,7 +571,7 @@ void qDrawPlot::ClonePlot() {
|
||||
clonegainplot2D, boxPlot->title(), fileSavePath,
|
||||
fileSaveName, currentAcqIndex, displayStatistics,
|
||||
lblMinDisp->text(), lblMaxDisp->text(),
|
||||
lblSumDisp->text());
|
||||
lblSumDisp->text(), completeImage);
|
||||
}
|
||||
|
||||
void qDrawPlot::SavePlot() {
|
||||
@ -668,7 +656,8 @@ void qDrawPlot::StartAcquisition() {
|
||||
xyRangeChanged = true;
|
||||
}
|
||||
|
||||
emit StartAcquireSignal();
|
||||
QtConcurrent::run(this, &qDrawPlot::AcquireThread);
|
||||
|
||||
LOG(logDEBUG) << "End of Starting Acquisition in qDrawPlot";
|
||||
}
|
||||
|
||||
@ -753,6 +742,7 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
|
||||
<< " \t dynamic range: " << data->dynamicRange
|
||||
<< std::endl
|
||||
<< " \t file index: " << data->fileIndex << std::endl
|
||||
<< " \t complete image: " << data->completeImage << std::endl
|
||||
<< " ]";
|
||||
|
||||
progress = (int)data->progressIndex;
|
||||
@ -773,6 +763,11 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
|
||||
delete[] data2d;
|
||||
data2d = new double[nPixelsY * nPixelsX];
|
||||
std::fill(data2d, data2d + nPixelsX * nPixelsY, 0);
|
||||
if (gainData) {
|
||||
delete[] gainData;
|
||||
gainData = new double[nPixelsY * nPixelsX];
|
||||
std::fill(gainData, gainData + nPixelsX * nPixelsY, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// convert data to double
|
||||
@ -795,6 +790,7 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
|
||||
if ((int)subFrameIndex != -1) {
|
||||
indexTitle = QString("%1 %2").arg(frameIndex, subFrameIndex);
|
||||
}
|
||||
completeImage = data->completeImage;
|
||||
|
||||
// reset pedestal
|
||||
if (resetPedestal) {
|
||||
@ -1115,6 +1111,16 @@ void qDrawPlot::UpdatePlot() {
|
||||
LOG(logDEBUG) << "Update Plot";
|
||||
|
||||
boxPlot->setTitle(plotTitle);
|
||||
|
||||
// notify of incomplete images
|
||||
lblCompleteImage->hide();
|
||||
lblInCompleteImage->hide();
|
||||
if(completeImage) {
|
||||
lblCompleteImage->show();
|
||||
} else {
|
||||
lblInCompleteImage->show();
|
||||
}
|
||||
|
||||
if (is1d) {
|
||||
Update1dPlot();
|
||||
} else {
|
||||
|
@ -64,6 +64,7 @@ void qTabPlot::SetupWidgetWindow() {
|
||||
chkGapPixels->setEnabled(true);
|
||||
break;
|
||||
case slsDetectorDefs::JUNGFRAU:
|
||||
chkGapPixels->setEnabled(true);
|
||||
chkGainPlot->setEnabled(true);
|
||||
chkGainPlot->setChecked(true);
|
||||
plot->EnableGainPlot(true);
|
||||
@ -312,8 +313,7 @@ void qTabPlot::GetGapPixels() {
|
||||
disconnect(chkGapPixels, SIGNAL(toggled(bool)), this,
|
||||
SLOT(SetGapPixels(bool)));
|
||||
try {
|
||||
auto retval = det->getRxAddGapPixels().tsquash(
|
||||
"Inconsistent gap pixels enabled for all detectors.");
|
||||
auto retval = det->getGapPixelsinCallback();
|
||||
chkGapPixels->setChecked(retval);
|
||||
}
|
||||
CATCH_DISPLAY("Could not get gap pixels enable.", "qTabPlot::GetGapPixels")
|
||||
@ -324,7 +324,7 @@ void qTabPlot::GetGapPixels() {
|
||||
void qTabPlot::SetGapPixels(bool enable) {
|
||||
LOG(logINFO) << "Setting Gap Pixels Enable to " << enable;
|
||||
try {
|
||||
det->setRxAddGapPixels(enable);
|
||||
det->setGapPixelsinCallback(enable);
|
||||
}
|
||||
CATCH_HANDLE("Could not set gap pixels enable.", "qTabPlot::SetGapPixels",
|
||||
this, &qTabPlot::GetGapPixels)
|
||||
@ -672,6 +672,8 @@ void qTabPlot::Refresh() {
|
||||
break;
|
||||
case slsDetectorDefs::JUNGFRAU:
|
||||
chkGainPlot->setEnabled(true);
|
||||
chkGapPixels->setEnabled(true);
|
||||
GetGapPixels();
|
||||
break;
|
||||
case slsDetectorDefs::GOTTHARD2:
|
||||
chkGainPlot1D->setEnabled(true);
|
||||
|
@ -16,6 +16,7 @@ add_executable(ctbDetectorServer_virtual
|
||||
../slsDetectorServer/src/LTC2620.c
|
||||
../slsDetectorServer/src/MAX1932.c
|
||||
../slsDetectorServer/src/programFpgaBlackfin.c
|
||||
../slsDetectorServer/src/communication_virtual.c
|
||||
)
|
||||
|
||||
include_directories(
|
||||
@ -33,6 +34,7 @@ target_compile_definitions(ctbDetectorServer_virtual
|
||||
|
||||
target_link_libraries(ctbDetectorServer_virtual
|
||||
PUBLIC pthread rt slsProjectCWarnings
|
||||
m
|
||||
)
|
||||
|
||||
set_target_properties(ctbDetectorServer_virtual PROPERTIES
|
||||
|
Binary file not shown.
@ -10,22 +10,33 @@
|
||||
#include "MAX1932.h" // hv
|
||||
#include "INA226.h" // i2c
|
||||
#include "ALTERA_PLL.h" // pll
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h> // usleep
|
||||
#include <netinet/in.h>
|
||||
#ifdef VIRTUAL
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
#include <math.h> //ceil
|
||||
#endif
|
||||
|
||||
// Global variable from slsDetectorServer_funcs
|
||||
extern int debugflag;
|
||||
extern udpStruct udpDetails;
|
||||
extern const enum detectorType myDetectorType;
|
||||
|
||||
// Global variable from UDPPacketHeaderGenerator
|
||||
extern uint64_t udpFrameNumber;
|
||||
extern uint32_t udpPacketNumber;
|
||||
|
||||
// Global variable from communication_funcs.c
|
||||
extern int isControlServer;
|
||||
extern void getMacAddressinString(char* cmac, int size, uint64_t mac);
|
||||
extern void getIpAddressinString(char* cip, uint32_t ip);
|
||||
|
||||
int initError = OK;
|
||||
int initCheckDone = 0;
|
||||
char initErrorMessage[MAX_STR_LENGTH];
|
||||
@ -420,6 +431,12 @@ void initStopServer() {
|
||||
LOG(logERROR, ("Stop Server: Map Fail. Dangerous to continue. Goodbye!\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -462,7 +479,12 @@ void setupDetector() {
|
||||
digitalEnable = 0;
|
||||
naSamples = 1;
|
||||
ndSamples = 1;
|
||||
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
#endif
|
||||
|
||||
ALTERA_PLL_ResetPLLAndReconfiguration();
|
||||
resetCore();
|
||||
@ -1379,12 +1401,6 @@ int getADC(enum ADCINDEX ind){
|
||||
|
||||
|
||||
int setHighVoltage(int val){
|
||||
#ifdef VIRTUAL
|
||||
if (val >= 0)
|
||||
highvoltage = val;
|
||||
return highvoltage;
|
||||
#endif
|
||||
|
||||
// setting hv
|
||||
if (val >= 0) {
|
||||
LOG(logINFO, ("Setting High voltage: %d V\n", val));
|
||||
@ -1393,7 +1409,7 @@ int setHighVoltage(int val){
|
||||
// switch to external high voltage
|
||||
bus_w(addr, bus_r(addr) & (~POWER_HV_INTERNAL_SLCT_MSK));
|
||||
|
||||
MAX1932_Set(val);
|
||||
MAX1932_Set(&val);
|
||||
|
||||
// switch on internal high voltage, if set
|
||||
if (val > 0)
|
||||
@ -1473,26 +1489,36 @@ void calcChecksum(udp_header* udp) {
|
||||
|
||||
|
||||
int configureMAC(){
|
||||
uint32_t sourceip = udpDetails.srcip;
|
||||
uint32_t destip = udpDetails.dstip;
|
||||
uint64_t sourcemac = udpDetails.srcmac;
|
||||
uint64_t destmac = udpDetails.dstmac;
|
||||
int sourceport = udpDetails.srcport;
|
||||
int destport = udpDetails.dstport;
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
uint32_t srcip = udpDetails.srcip;
|
||||
uint32_t dstip = udpDetails.dstip;
|
||||
uint64_t srcmac = udpDetails.srcmac;
|
||||
uint64_t dstmac = udpDetails.dstmac;
|
||||
int srcport = udpDetails.srcport;
|
||||
int dstport = udpDetails.dstport;
|
||||
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
||||
getMacAddressinString(src_mac, 50, srcmac);
|
||||
getMacAddressinString(dst_mac, 50, dstmac);
|
||||
getIpAddressinString(src_ip, srcip);
|
||||
getIpAddressinString(dst_ip, dstip);
|
||||
|
||||
LOG(logINFO, (
|
||||
"\tSource IP : %s\n"
|
||||
"\tSource MAC : %s\n"
|
||||
"\tSource Port : %d\n"
|
||||
"\tDest IP : %s\n"
|
||||
"\tDest MAC : %s\n"
|
||||
"\tDest Port : %d\n",
|
||||
src_ip, src_mac, srcport,
|
||||
dst_ip, dst_mac, dstport));
|
||||
|
||||
// 1 giga udp
|
||||
if (!enableTenGigabitEthernet(-1)) {
|
||||
LOG(logINFOBLUE, ("Configuring 1G MAC\n"));
|
||||
LOG(logINFOBLUE, ("\t1G MAC\n"));
|
||||
if (updateDatabytesandAllocateRAM() == FAIL)
|
||||
return -1;
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
|
||||
LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, destport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, destport) == FAIL) {
|
||||
if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) {
|
||||
LOG(logERROR, ("could not set udp 1G destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
@ -1500,31 +1526,7 @@ int configureMAC(){
|
||||
}
|
||||
|
||||
// 10 G
|
||||
LOG(logINFOBLUE, ("Configuring 10G MAC\n"));
|
||||
|
||||
LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(sourceip>>24)&0xff,(sourceip>>16)&0xff,(sourceip>>8)&0xff,(sourceip)&0xff, sourceip));
|
||||
LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((sourcemac>>40)&0xFF),
|
||||
(unsigned int)((sourcemac>>32)&0xFF),
|
||||
(unsigned int)((sourcemac>>24)&0xFF),
|
||||
(unsigned int)((sourcemac>>16)&0xFF),
|
||||
(unsigned int)((sourcemac>>8)&0xFF),
|
||||
(unsigned int)((sourcemac>>0)&0xFF),
|
||||
(long long unsigned int)sourcemac));
|
||||
LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n",sourceport, sourceport));
|
||||
|
||||
LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff, destip));
|
||||
LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((destmac>>40)&0xFF),
|
||||
(unsigned int)((destmac>>32)&0xFF),
|
||||
(unsigned int)((destmac>>24)&0xFF),
|
||||
(unsigned int)((destmac>>16)&0xFF),
|
||||
(unsigned int)((destmac>>8)&0xFF),
|
||||
(unsigned int)((destmac>>0)&0xFF),
|
||||
(long long unsigned int)destmac));
|
||||
LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n",destport, destport));
|
||||
LOG(logINFOBLUE, ("\t10G MAC\n"));
|
||||
|
||||
// start addr
|
||||
uint32_t addr = RXR_ENDPOINT_START_REG;
|
||||
@ -1534,21 +1536,21 @@ int configureMAC(){
|
||||
|
||||
// mac addresses
|
||||
// msb (32) + lsb (16)
|
||||
udp->udp_destmac_msb = ((destmac >> 16) & BIT32_MASK);
|
||||
udp->udp_destmac_lsb = ((destmac >> 0) & BIT16_MASK);
|
||||
udp->udp_destmac_msb = ((dstmac >> 16) & BIT32_MASK);
|
||||
udp->udp_destmac_lsb = ((dstmac >> 0) & BIT16_MASK);
|
||||
// msb (16) + lsb (32)
|
||||
udp->udp_srcmac_msb = ((sourcemac >> 32) & BIT16_MASK);
|
||||
udp->udp_srcmac_lsb = ((sourcemac >> 0) & BIT32_MASK);
|
||||
udp->udp_srcmac_msb = ((srcmac >> 32) & BIT16_MASK);
|
||||
udp->udp_srcmac_lsb = ((srcmac >> 0) & BIT32_MASK);
|
||||
|
||||
// ip addresses
|
||||
udp->ip_srcip_msb = ((sourceip >> 16) & BIT16_MASK);
|
||||
udp->ip_srcip_lsb = ((sourceip >> 0) & BIT16_MASK);
|
||||
udp->ip_destip_msb = ((destip >> 16) & BIT16_MASK);
|
||||
udp->ip_destip_lsb = ((destip >> 0) & BIT16_MASK);
|
||||
udp->ip_srcip_msb = ((srcip >> 16) & BIT16_MASK);
|
||||
udp->ip_srcip_lsb = ((srcip >> 0) & BIT16_MASK);
|
||||
udp->ip_destip_msb = ((dstip >> 16) & BIT16_MASK);
|
||||
udp->ip_destip_lsb = ((dstip >> 0) & BIT16_MASK);
|
||||
|
||||
// source port
|
||||
udp->udp_srcport = sourceport;
|
||||
udp->udp_destport = destport;
|
||||
udp->udp_srcport = srcport;
|
||||
udp->udp_destport = dstport;
|
||||
|
||||
// other defines
|
||||
udp->udp_ethertype = 0x800;
|
||||
@ -1579,6 +1581,9 @@ int* getDetectorPosition() {
|
||||
}
|
||||
|
||||
int enableTenGigabitEthernet(int val) {
|
||||
#ifdef VIRTUAL
|
||||
return 0;
|
||||
#endif
|
||||
uint32_t addr = CONFIG_REG;
|
||||
|
||||
// set
|
||||
@ -2157,11 +2162,27 @@ uint64_t getPatternBitMask() {
|
||||
|
||||
int startStateMachine(){
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 1;
|
||||
virtual_stop = 0;
|
||||
// create udp socket
|
||||
if(createUDPSocket(0) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
virtual_status = 1;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
if (virtual_stop != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
if(pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
virtual_status = 0;
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||
@ -2195,42 +2216,93 @@ int startStateMachine(){
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void* start_timer(void* arg) {
|
||||
int64_t periodns = getPeriod();
|
||||
if (!isControlServer) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int64_t periodNs = getPeriod();
|
||||
int numFrames = (getNumFrames() *
|
||||
getNumTriggers() );
|
||||
int64_t exp_ns = getExpTime();
|
||||
int64_t expUs = getExpTime() / 1000;
|
||||
|
||||
int frameNr = 0;
|
||||
// loop over number of frames
|
||||
for(frameNr=0; frameNr!= numFrames; ++frameNr ) {
|
||||
int imageSize = dataBytes;
|
||||
int dataSize = UDP_PACKET_DATA_BYTES;
|
||||
int packetSize = sizeof(sls_detector_header) + dataSize;
|
||||
int packetsPerFrame = ceil((double)imageSize / (double)dataSize);
|
||||
|
||||
//check if virtual_stop is high
|
||||
if(virtual_stop == 1){
|
||||
break;
|
||||
}
|
||||
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(exp_ns / 1000);
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
|
||||
// calculate time left in period
|
||||
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodns > time_ns) {
|
||||
usleep((periodns - time_ns)/ 1000);
|
||||
}
|
||||
}
|
||||
|
||||
// set register frames left
|
||||
// Generate Data
|
||||
char imageData[imageSize];
|
||||
memset(imageData, 0, imageSize);
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < imageSize; i += sizeof(uint16_t)) {
|
||||
*((uint16_t*)(imageData + i)) = i;
|
||||
}
|
||||
}
|
||||
|
||||
// set status to idle
|
||||
// Send data
|
||||
{
|
||||
int frameNr = 0;
|
||||
// loop over number of frames
|
||||
for(frameNr = 0; frameNr != numFrames; ++frameNr ) {
|
||||
|
||||
// update the virtual stop from stop server
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
//check if virtual_stop is high
|
||||
if(virtual_stop == 1){
|
||||
break;
|
||||
}
|
||||
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expUs);
|
||||
|
||||
int srcOffset = 0;
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 0; i != packetsPerFrame; ++i) {
|
||||
|
||||
char packetData[packetSize];
|
||||
memset(packetData, 0, packetSize);
|
||||
// set header
|
||||
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameNr;
|
||||
header->packetNumber = i;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
header->column = detPos[Y];
|
||||
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header), imageData + srcOffset, dataSize);
|
||||
srcOffset += dataSize;
|
||||
|
||||
sendUDPPacket(0, packetData, packetSize);
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs)/ 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closeUDPSocket(0);
|
||||
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
@ -2239,7 +2311,18 @@ void* start_timer(void* arg) {
|
||||
int stopStateMachine(){
|
||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
// read till status is idle
|
||||
int tempStatus = 1;
|
||||
while(tempStatus == 1) {
|
||||
tempStatus = ComVirtual_getStatus();
|
||||
}
|
||||
virtual_stop = 0;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
}
|
||||
return OK;
|
||||
#endif
|
||||
//stop state machine
|
||||
@ -2258,7 +2341,10 @@ int stopStateMachine(){
|
||||
|
||||
enum runStatus getRunStatus(){
|
||||
#ifdef VIRTUAL
|
||||
if(virtual_status == 0){
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
if(virtual_status == 0) {
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
}else{
|
||||
@ -2530,6 +2616,9 @@ int readFrameFromFifo() {
|
||||
|
||||
uint32_t runBusy() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
return virtual_status;
|
||||
#endif
|
||||
uint32_t s = (bus_r(STATUS_REG) & STATUS_RN_BSY_MSK);
|
||||
|
@ -178,120 +178,100 @@ void Beb_GetModuleConfiguration(int* master, int* top, int* normal) {
|
||||
|
||||
|
||||
|
||||
void Beb_EndofDataSend(int tengiga) {
|
||||
int Beb_IsTransmitting(int* retval, int tengiga, int waitForDelay) {
|
||||
//mapping new memory
|
||||
u_int32_t* csp0base=0;
|
||||
int l_framepktLsbcounter, l_framepktMsbcounter, l_txndelaycounter, l_framedelaycounter;
|
||||
int r_framepktLsbcounter, r_framepktMsbcounter, r_txndelaycounter, r_framedelaycounter;
|
||||
int l_framepktLsbcounter_new, l_framepktMsbcounter_new, l_txndelaycounter_new, l_framedelaycounter_new;
|
||||
int r_framepktLsbcounter_new, r_framepktMsbcounter_new, r_txndelaycounter_new, r_framedelaycounter_new;
|
||||
int addr_l_framepktLsbcounter, addr_l_framepktMsbcounter, addr_l_txndelaycounter, addr_l_framedelaycounter;
|
||||
int addr_r_framepktLsbcounter, addr_r_framepktMsbcounter, addr_r_txndelaycounter, addr_r_framedelaycounter;
|
||||
|
||||
switch(tengiga) {
|
||||
case 0:
|
||||
addr_l_framepktLsbcounter = ONE_GIGA_LEFT_INDEX_LSB_COUNTER;
|
||||
addr_l_framepktMsbcounter = ONE_GIGA_LEFT_INDEX_MSB_COUNTER;
|
||||
addr_l_txndelaycounter = ONE_GIGA_LEFT_TXN_DELAY_COUNTER;
|
||||
addr_l_framedelaycounter = ONE_GIGA_LEFT_FRAME_DELAY_COUNTER;
|
||||
addr_r_framepktLsbcounter = ONE_GIGA_RIGHT_INDEX_LSB_COUNTER;
|
||||
addr_r_framepktMsbcounter = ONE_GIGA_RIGHT_INDEX_MSB_COUNTER;
|
||||
addr_r_txndelaycounter = ONE_GIGA_RIGHT_TXN_DELAY_COUNTER;
|
||||
addr_r_framedelaycounter = ONE_GIGA_RIGHT_FRAME_DELAY_COUNTER;
|
||||
break;
|
||||
case 1:
|
||||
addr_l_framepktLsbcounter = TEN_GIGA_LEFT_INDEX_LSB_COUNTER;
|
||||
addr_l_framepktMsbcounter = TEN_GIGA_LEFT_INDEX_MSB_COUNTER;
|
||||
u_int32_t* csp0base = 0;
|
||||
int addr_l_txndelaycounter = 0, addr_l_framedelaycounter = 0;
|
||||
int addr_r_txndelaycounter = 0, addr_r_framedelaycounter = 0;
|
||||
int addr_l_framepktLsbcounter = 0, addr_l_framepktMsbcounter = 0;
|
||||
int addr_r_framepktLsbcounter = 0, addr_r_framepktMsbcounter = 0;
|
||||
if (tengiga) {
|
||||
addr_l_txndelaycounter = TEN_GIGA_LEFT_TXN_DELAY_COUNTER;
|
||||
addr_l_framedelaycounter = TEN_GIGA_LEFT_FRAME_DELAY_COUNTER;
|
||||
addr_r_framepktLsbcounter = TEN_GIGA_RIGHT_INDEX_LSB_COUNTER;
|
||||
addr_r_framepktMsbcounter = TEN_GIGA_RIGHT_INDEX_MSB_COUNTER;
|
||||
addr_r_txndelaycounter = TEN_GIGA_RIGHT_TXN_DELAY_COUNTER;
|
||||
addr_r_framedelaycounter = TEN_GIGA_RIGHT_FRAME_DELAY_COUNTER;
|
||||
break;
|
||||
addr_l_framepktLsbcounter = TEN_GIGA_LEFT_INDEX_LSB_COUNTER;
|
||||
addr_l_framepktMsbcounter = TEN_GIGA_LEFT_INDEX_MSB_COUNTER;
|
||||
addr_r_framepktLsbcounter = TEN_GIGA_RIGHT_INDEX_LSB_COUNTER;
|
||||
addr_r_framepktMsbcounter = TEN_GIGA_RIGHT_INDEX_MSB_COUNTER;
|
||||
} else {
|
||||
addr_l_txndelaycounter = ONE_GIGA_LEFT_TXN_DELAY_COUNTER;
|
||||
addr_l_framedelaycounter = ONE_GIGA_LEFT_FRAME_DELAY_COUNTER;
|
||||
addr_r_txndelaycounter = ONE_GIGA_RIGHT_TXN_DELAY_COUNTER;
|
||||
addr_r_framedelaycounter = ONE_GIGA_RIGHT_FRAME_DELAY_COUNTER;
|
||||
addr_l_framepktLsbcounter = ONE_GIGA_LEFT_INDEX_LSB_COUNTER;
|
||||
addr_l_framepktMsbcounter = ONE_GIGA_LEFT_INDEX_MSB_COUNTER;
|
||||
addr_r_framepktLsbcounter = ONE_GIGA_RIGHT_INDEX_LSB_COUNTER;
|
||||
addr_r_framepktMsbcounter = ONE_GIGA_RIGHT_INDEX_MSB_COUNTER;
|
||||
}
|
||||
|
||||
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_COUNTER_BASEADDR);
|
||||
if (fd < 0) {
|
||||
LOG(logERROR, ("Delay read counter fail\n"));
|
||||
return;
|
||||
if(fd < 0){
|
||||
cprintf(BG_RED,"Could not read Beb Delay read counter\n");
|
||||
return FAIL;
|
||||
} else {
|
||||
//read data first time
|
||||
l_framepktLsbcounter = Beb_Read32(csp0base, addr_l_framepktLsbcounter);
|
||||
l_framepktMsbcounter = Beb_Read32(csp0base, addr_l_framepktMsbcounter);
|
||||
l_txndelaycounter = Beb_Read32(csp0base, addr_l_txndelaycounter);
|
||||
l_framedelaycounter = Beb_Read32(csp0base, addr_l_framedelaycounter);
|
||||
r_framepktLsbcounter = Beb_Read32(csp0base, addr_r_framepktLsbcounter);
|
||||
r_framepktMsbcounter = Beb_Read32(csp0base, addr_r_framepktMsbcounter);
|
||||
r_txndelaycounter = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
r_framedelaycounter = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
LOG(logDEBUG1, ("\nLeft\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n"
|
||||
"\nRight\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n\n",
|
||||
l_framepktLsbcounter,l_framepktMsbcounter,l_txndelaycounter,l_framedelaycounter,
|
||||
r_framepktLsbcounter,r_framepktMsbcounter,r_txndelaycounter,r_framedelaycounter));
|
||||
|
||||
//keep comparing with previous values
|
||||
int maxtimer;
|
||||
while(1) {
|
||||
maxtimer = MAX(MAX(l_txndelaycounter,l_framedelaycounter),MAX(r_txndelaycounter,r_framedelaycounter));
|
||||
maxtimer /= 100;
|
||||
LOG(logDEBUG1, ("Will wait for %d us\n",maxtimer));
|
||||
usleep(maxtimer);
|
||||
|
||||
//read new values
|
||||
l_framepktLsbcounter_new = Beb_Read32(csp0base, addr_l_framepktLsbcounter);
|
||||
l_framepktMsbcounter_new = Beb_Read32(csp0base, addr_l_framepktMsbcounter);
|
||||
l_txndelaycounter_new = Beb_Read32(csp0base, addr_l_txndelaycounter);
|
||||
l_framedelaycounter_new = Beb_Read32(csp0base, addr_l_framedelaycounter);
|
||||
r_framepktLsbcounter_new = Beb_Read32(csp0base, addr_r_framepktLsbcounter);
|
||||
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);
|
||||
LOG(logDEBUG1, ("\nLeft\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n"
|
||||
"\nRight\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n\n",
|
||||
l_framepktLsbcounter_new,l_framepktMsbcounter_new,l_txndelaycounter_new,l_framedelaycounter_new,
|
||||
r_framepktLsbcounter_new,r_framepktMsbcounter_new,r_txndelaycounter_new,r_framedelaycounter_new));
|
||||
|
||||
if ((l_framepktLsbcounter == l_framepktLsbcounter_new) &&
|
||||
(l_framepktMsbcounter == l_framepktMsbcounter_new) &&
|
||||
(r_framepktLsbcounter == r_framepktLsbcounter_new) &&
|
||||
(r_framepktMsbcounter == r_framepktMsbcounter_new))
|
||||
break;
|
||||
|
||||
//update old values
|
||||
l_framepktLsbcounter = l_framepktLsbcounter_new;
|
||||
l_framepktMsbcounter = l_framepktMsbcounter_new;
|
||||
l_txndelaycounter = l_txndelaycounter_new;
|
||||
l_framedelaycounter = l_framedelaycounter_new;
|
||||
r_framepktLsbcounter = r_framepktLsbcounter_new;
|
||||
r_framepktMsbcounter = r_framepktMsbcounter_new;
|
||||
r_txndelaycounter = r_txndelaycounter_new;
|
||||
r_framedelaycounter = r_framedelaycounter_new;
|
||||
|
||||
int l_txndelaycounter = Beb_Read32(csp0base, addr_l_txndelaycounter);
|
||||
int l_framedelaycounter = Beb_Read32(csp0base, addr_l_framedelaycounter);
|
||||
int r_txndelaycounter = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
int r_framedelaycounter = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
int l_framepktLsbcounter = Beb_Read32(csp0base, addr_l_framepktLsbcounter);
|
||||
int l_framepktMsbcounter = Beb_Read32(csp0base, addr_l_framepktMsbcounter);
|
||||
int r_framepktLsbcounter = Beb_Read32(csp0base, addr_r_framepktLsbcounter);
|
||||
int r_framepktMsbcounter = Beb_Read32(csp0base, addr_r_framepktMsbcounter);
|
||||
#ifdef VERBOSE
|
||||
printf("\nFirst Read:\n"
|
||||
"\tLeft [Txndelaycounter:%d, Framedelaycounter:%d]\n"
|
||||
"\tRight [Txndelaycounter:%d, Framedelaycounter:%d]\n",
|
||||
"\tLeft [FramepacketLsbcounter:%d, FramepacketMsbcounter:%d]\n"
|
||||
"\tRight [FramepacketLsbcounter:%d, FramepacketMsbcounter:%d]\n",
|
||||
l_txndelaycounter,l_framedelaycounter, r_txndelaycounter,r_framedelaycounter,
|
||||
l_framepktLsbcounter, l_framepktMsbcounter, r_framepktLsbcounter, r_framepktMsbcounter);
|
||||
#endif
|
||||
// wait for max counter delay
|
||||
if (waitForDelay) {
|
||||
int maxtimer = (MAX(MAX(l_txndelaycounter,l_framedelaycounter),MAX(r_txndelaycounter,r_framedelaycounter))) / 100; // counter values in 10 ns
|
||||
printf("Will wait for %d us\n", maxtimer);
|
||||
usleep (maxtimer);
|
||||
}
|
||||
// wait for 1 ms
|
||||
else {
|
||||
printf("Will wait for 1 ms\n");
|
||||
usleep (1 * 1000);
|
||||
}
|
||||
|
||||
LOG(logINFO, ("Detector has sent all data\n"));
|
||||
// read values again
|
||||
int l_txndelaycounter2 = Beb_Read32(csp0base, addr_l_txndelaycounter);
|
||||
int l_framedelaycounter2 = Beb_Read32(csp0base, addr_l_framedelaycounter);
|
||||
int r_txndelaycounter2 = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
int r_framedelaycounter2 = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
int l_framepktLsbcounter2 = Beb_Read32(csp0base, addr_l_framepktLsbcounter);
|
||||
int l_framepktMsbcounter2 = Beb_Read32(csp0base, addr_l_framepktMsbcounter);
|
||||
int r_framepktLsbcounter2 = Beb_Read32(csp0base, addr_r_framepktLsbcounter);
|
||||
int r_framepktMsbcounter2 = Beb_Read32(csp0base, addr_r_framepktMsbcounter);
|
||||
#ifdef VERBOSE
|
||||
printf("\nSecond Read:\n"
|
||||
"\tLeft [Txndelaycounter:%d, Framedelaycounter:%d]\n"
|
||||
"\tRight [Txndelaycounter:%d, Framedelaycounter:%d]\n",
|
||||
"\tLeft [FramepacketLsbcounter:%d, FramepacketMsbcounter:%d]\n"
|
||||
"\tRight [FramepacketLsbcounter:%d, FramepacketMsbcounter:%d]\n",
|
||||
l_txndelaycounter2,l_framedelaycounter2, r_txndelaycounter2,r_framedelaycounter2,
|
||||
l_framepktLsbcounter2, l_framepktMsbcounter2, r_framepktLsbcounter2, r_framepktMsbcounter2);
|
||||
#endif
|
||||
// any change in values, it is still transmitting
|
||||
if (l_txndelaycounter != l_txndelaycounter2 || l_framedelaycounter != l_framedelaycounter2 ||
|
||||
r_txndelaycounter != r_txndelaycounter2 || r_framedelaycounter != r_framedelaycounter2 ||
|
||||
l_framepktLsbcounter != l_framepktLsbcounter2 || l_framepktMsbcounter != l_framepktMsbcounter2 ||
|
||||
r_framepktLsbcounter != r_framepktLsbcounter2 || r_framepktMsbcounter != r_framepktMsbcounter2) {
|
||||
*retval = 1;
|
||||
} else {
|
||||
*retval = 0;
|
||||
}
|
||||
//close file pointer
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@ unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb);
|
||||
|
||||
|
||||
void Beb_GetModuleConfiguration(int* master, int* top, int* normal);
|
||||
void Beb_EndofDataSend(int tengiga);
|
||||
int Beb_IsTransmitting(int* retval, int tengiga, int waitForDelay);
|
||||
|
||||
int Beb_SetMasterViaSoftware();
|
||||
int Beb_SetSlaveViaSoftware();
|
||||
|
@ -5,6 +5,7 @@ set(src
|
||||
../slsDetectorServer/src/communication_funcs.c
|
||||
../slsDetectorServer/src/communication_funcs_UDP.c
|
||||
../slsDetectorServer/src/common.c
|
||||
../slsDetectorServer/src/communication_virtual.c
|
||||
)
|
||||
|
||||
include_directories(
|
||||
@ -22,7 +23,7 @@ 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
|
||||
)
|
||||
|
||||
@ -38,27 +39,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}
|
||||
)
|
||||
|
@ -898,7 +898,7 @@ int Feb_Control_SendDACValue(unsigned int dst_num, unsigned int ch, unsigned int
|
||||
|
||||
|
||||
|
||||
int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits) {
|
||||
int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits, int top) {
|
||||
LOG(logINFO, ("Setting Trimbits\n"));
|
||||
|
||||
//for (int iy=10000;iy<20020;++iy)//263681
|
||||
@ -963,7 +963,7 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits) {
|
||||
int i;
|
||||
for(i=0;i<8;i++) { // column loop i
|
||||
|
||||
if (Module_TopAddressIsValid(&modules[1])) {
|
||||
if (top==1) {
|
||||
trimbits_to_load_l[offset+chip_sc] |= ( 0x7 & trimbits[row_set*16480+super_column_start_position_l+i])<<((7-i)*4);//low
|
||||
trimbits_to_load_l[offset+chip_sc+32] |= ((0x38 & trimbits[row_set*16480+super_column_start_position_l+i])>>3)<<((7-i)*4);//upper
|
||||
trimbits_to_load_r[offset+chip_sc] |= ( 0x7 & trimbits[row_set*16480+super_column_start_position_r+i])<<((7-i)*4);//low
|
||||
@ -1572,12 +1572,12 @@ int Feb_Control_StopAcquisition() {
|
||||
|
||||
|
||||
|
||||
int Feb_Control_SaveAllTrimbitsTo(int value) {
|
||||
int Feb_Control_SaveAllTrimbitsTo(int value, int top) {
|
||||
unsigned int chanregs[Feb_Control_trimbit_size];
|
||||
int i;
|
||||
for(i=0;i<Feb_Control_trimbit_size;i++)
|
||||
chanregs[i] = value;
|
||||
return Feb_Control_SetTrimbits(0,chanregs);
|
||||
return Feb_Control_SetTrimbits(0,chanregs, top);
|
||||
}
|
||||
|
||||
|
||||
|
@ -93,9 +93,9 @@ int Feb_Control_SetDAC(char* s, int value, int is_a_voltage_mv);
|
||||
int Feb_Control_GetDAC(char* s, int* ret_value, int voltage_mv);
|
||||
int Feb_Control_GetDACName(unsigned int dac_num,char* s);
|
||||
|
||||
int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int* trimbits);
|
||||
int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int* trimbits, int top);
|
||||
unsigned int* Feb_Control_GetTrimbits();
|
||||
int Feb_Control_SaveAllTrimbitsTo(int value);
|
||||
int Feb_Control_SaveAllTrimbitsTo(int value, int top);
|
||||
int Feb_Control_Reset();
|
||||
int Feb_Control_PrepareForAcquisition();
|
||||
|
||||
|
Binary file not shown.
@ -6,6 +6,8 @@
|
||||
#ifndef VIRTUAL
|
||||
#include "FebControl.h"
|
||||
#include "Beb.h"
|
||||
#else
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include <unistd.h> //to gethostname
|
||||
@ -20,6 +22,7 @@
|
||||
// Global variable from slsDetectorServer_funcs
|
||||
extern int debugflag;
|
||||
extern udpStruct udpDetails;
|
||||
extern const enum detectorType myDetectorType;
|
||||
|
||||
// Global variable from communication_funcs.c
|
||||
extern int isControlServer;
|
||||
@ -66,9 +69,13 @@ int eiger_extgating = 0;
|
||||
int eiger_extgatingpolarity = 0;
|
||||
int eiger_nexposures = 1;
|
||||
int eiger_ntriggers = 1;
|
||||
int eiger_tau_ns = 0;
|
||||
|
||||
|
||||
#ifdef VIRTUAL
|
||||
pthread_t virtual_tid;
|
||||
int virtual_status=0;
|
||||
int virtual_stop = 0;
|
||||
//values for virtual server
|
||||
int64_t eiger_virtual_exptime = 0;
|
||||
int64_t eiger_virtual_subexptime = 0;
|
||||
@ -82,12 +89,11 @@ int eiger_virtual_transmission_delay_left=0;
|
||||
int eiger_virtual_transmission_delay_right=0;
|
||||
int eiger_virtual_transmission_delay_frame=0;
|
||||
int eiger_virtual_transmission_flowcontrol_10g=0;
|
||||
int eiger_virtual_status=0;
|
||||
int eiger_virtual_activate=1;
|
||||
pthread_t eiger_virtual_tid;
|
||||
int eiger_virtual_stop = 0;
|
||||
uint64_t eiger_virtual_startingframenumber = 0;
|
||||
uint64_t eiger_virtual_startingframenumber = 1;
|
||||
int eiger_virtual_detPos[2] = {0, 0};
|
||||
int eiger_virtual_test_mode = 0;
|
||||
int eiger_virtual_quad_mode = 0;
|
||||
#endif
|
||||
|
||||
|
||||
@ -179,8 +185,23 @@ void basictests() {
|
||||
LOG(logINFO, ("Compatibility - success\n"));
|
||||
}
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void setTestImageMode(int ival) {
|
||||
if (ival >= 0) {
|
||||
if (ival == 0) {
|
||||
LOG(logINFO, ("Switching off Image Test Mode\n"));
|
||||
eiger_virtual_test_mode = 0;
|
||||
} else {
|
||||
LOG(logINFO, ("Switching on Image Test Mode\n"));
|
||||
eiger_virtual_test_mode = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int getTestImageMode() {
|
||||
return eiger_virtual_test_mode;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Ids */
|
||||
@ -306,7 +327,14 @@ void initControlServer() {
|
||||
getModuleConfiguration();
|
||||
Feb_Interface_FebInterface();
|
||||
Feb_Control_FebControl();
|
||||
Feb_Control_Init(master,top,normal, getDetectorNumber());
|
||||
// different addresses for top and bottom
|
||||
if (getFirmwareVersion() < FIRMWARE_VERSION_SAME_TOP_BOT_ADDR) {
|
||||
Feb_Control_Init(master,top,normal, getDetectorNumber());
|
||||
}
|
||||
// same addresses for top and bottom
|
||||
else {
|
||||
Feb_Control_Init(master,1, normal, getDetectorNumber());
|
||||
}
|
||||
//master of 9M, check high voltage serial communication to blackfin
|
||||
if (master && !normal) {
|
||||
if (Feb_Control_OpenSerialCommunication())
|
||||
@ -334,12 +362,23 @@ void initControlServer() {
|
||||
void initStopServer() {
|
||||
#ifdef VIRTUAL
|
||||
getModuleConfiguration();
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
}
|
||||
return;
|
||||
#else
|
||||
getModuleConfiguration();
|
||||
Feb_Interface_FebInterface();
|
||||
Feb_Control_FebControl();
|
||||
Feb_Control_Init(master,top,normal,getDetectorNumber());
|
||||
// different addresses for top and bottom
|
||||
if (getFirmwareVersion() < FIRMWARE_VERSION_SAME_TOP_BOT_ADDR) {
|
||||
Feb_Control_Init(master,top,normal, getDetectorNumber());
|
||||
}
|
||||
// same addresses for top and bottom
|
||||
else {
|
||||
Feb_Control_Init(master,1, normal, getDetectorNumber());
|
||||
}
|
||||
LOG(logDEBUG1, ("Stop server: FEB Initialization done\n"));
|
||||
// activate (if it gets ip) (later FW will deactivate at startup)
|
||||
// also needed for stop server for status
|
||||
@ -361,7 +400,11 @@ void getModuleConfiguration() {
|
||||
top = 1;
|
||||
#else
|
||||
master = 0;
|
||||
#ifdef VIRTUAL_TOP
|
||||
top = 1;
|
||||
#else
|
||||
top = 0;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef VIRTUAL_9M
|
||||
normal = 0;
|
||||
@ -446,6 +489,12 @@ void setupDetector() {
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
#endif
|
||||
|
||||
LOG(logINFOBLUE, ("Setting Default Parameters\n"));
|
||||
//setting default measurement parameters
|
||||
@ -455,6 +504,7 @@ void setupDetector() {
|
||||
getSubExpTime(DEFAULT_SUBFRAME_DEADTIME);
|
||||
setPeriod(DEFAULT_PERIOD);
|
||||
setNumTriggers(DEFAULT_NUM_CYCLES);
|
||||
eiger_dynamicrange = DEFAULT_DYNAMIC_RANGE;
|
||||
setDynamicRange(DEFAULT_DYNAMIC_RANGE);
|
||||
eiger_photonenergy = DEFAULT_PHOTON_ENERGY;
|
||||
setParallelMode(DEFAULT_PARALLEL_MODE);
|
||||
@ -466,6 +516,7 @@ void setupDetector() {
|
||||
setStartingFrameNumber(DEFAULT_STARTING_FRAME_NUMBER);
|
||||
setReadNLines(MAX_ROWS_PER_READOUT);
|
||||
//SetPhotonEnergyCalibrationParameters(-5.8381e-5,1.838515,5.09948e-7,-4.32390e-11,1.32527e-15);
|
||||
eiger_tau_ns = DEFAULT_RATE_CORRECTION;
|
||||
setRateCorrection(DEFAULT_RATE_CORRECTION);
|
||||
int enable[2] = {DEFAULT_EXT_GATING_ENABLE, DEFAULT_EXT_GATING_POLARITY};
|
||||
setExternalGating(enable);//disable external gating
|
||||
@ -510,31 +561,27 @@ int readRegister(uint32_t offset, uint32_t* retval) {
|
||||
|
||||
|
||||
int setDynamicRange(int dr) {
|
||||
#ifdef VIRTUAL
|
||||
if (dr > 0) {
|
||||
LOG(logINFO, ("Setting dynamic range: %d\n", dr));
|
||||
eiger_dynamicrange = dr;
|
||||
}
|
||||
return eiger_dynamicrange;
|
||||
#else
|
||||
// setting dr
|
||||
if (dr > 0) {
|
||||
LOG(logDEBUG1, ("Setting dynamic range: %d\n", dr));
|
||||
#ifndef VIRTUAL
|
||||
if (Feb_Control_SetDynamicRange(dr)) {
|
||||
|
||||
//EigerSetBitMode(dr);
|
||||
on_dst = 0;
|
||||
int i;
|
||||
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
|
||||
if (Beb_SetUpTransferParameters(dr))
|
||||
eiger_dynamicrange = dr;
|
||||
else LOG(logERROR, ("Could not set bit mode in the back end\n"));
|
||||
if (!Beb_SetUpTransferParameters(dr)) {
|
||||
LOG(logERROR, ("Could not set bit mode in the back end\n"));
|
||||
return eiger_dynamicrange;
|
||||
}
|
||||
}
|
||||
}
|
||||
//make sure back end and front end have the same bit mode
|
||||
dr= Feb_Control_GetDynamicRange();
|
||||
|
||||
return dr;
|
||||
#endif
|
||||
eiger_dynamicrange = dr;
|
||||
}
|
||||
// getting dr
|
||||
#ifndef VIRTUAL
|
||||
eiger_dynamicrange = Feb_Control_GetDynamicRange();
|
||||
#endif
|
||||
return eiger_dynamicrange;
|
||||
}
|
||||
|
||||
|
||||
@ -712,7 +759,7 @@ int64_t getSubExpTime() {
|
||||
#endif
|
||||
}
|
||||
|
||||
int setDeadTime(int64_t val) {
|
||||
int setSubDeadTime(int64_t val) {
|
||||
LOG(logINFO, ("Setting subdeadtime %lld ns\n", (long long int)val));
|
||||
#ifndef VIRTUAL
|
||||
// get subexptime
|
||||
@ -734,7 +781,7 @@ int setDeadTime(int64_t val) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int64_t getDeadTime() {
|
||||
int64_t getSubDeadTime() {
|
||||
#ifndef VIRTUAL
|
||||
// get subexptime
|
||||
int64_t subexptime = Feb_Control_GetSubFrameExposureTime();
|
||||
@ -820,8 +867,9 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// trimbits
|
||||
|
||||
#ifndef VIRTUAL
|
||||
// trimbits
|
||||
if (myMod.nchan == 0) {
|
||||
LOG(logINFO, ("Setting module without trimbits\n"));
|
||||
} else {
|
||||
@ -842,7 +890,7 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
}
|
||||
|
||||
//set trimbits
|
||||
if (!Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(), tt)) {
|
||||
if (!Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(), tt,top)) {
|
||||
sprintf(mess, "Could not set module. Could not set trimbits\n");
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
@ -850,6 +898,7 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//rate correction
|
||||
@ -869,17 +918,24 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
else {
|
||||
setDefaultSettingsTau_in_nsec(myMod.tau);
|
||||
if (getRateCorrectionEnable()) {
|
||||
int64_t retvalTau = setRateCorrection(myMod.tau);
|
||||
if (myMod.tau != retvalTau) {
|
||||
sprintf(mess, "Cannot set module. Could not set rate correction\n");
|
||||
if (setRateCorrection(myMod.tau) == FAIL) {
|
||||
sprintf(mess, "Cannot set module. Rate correction failed.\n");
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
return FAIL;
|
||||
return FAIL;
|
||||
} else {
|
||||
int64_t retvalTau = getCurrentTau();
|
||||
if (myMod.tau != retvalTau) {
|
||||
sprintf(mess, "Cannot set module. Could not set rate correction\n");
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -1178,21 +1234,20 @@ enum timingMode getTiming() {
|
||||
/* configure mac */
|
||||
|
||||
int configureMAC() {
|
||||
uint32_t sourceip = udpDetails.srcip;
|
||||
uint32_t destip = udpDetails.dstip;
|
||||
uint64_t sourcemac = udpDetails.srcmac;
|
||||
uint64_t destmac = udpDetails.dstmac;
|
||||
int src_port = udpDetails.srcport;
|
||||
int destport = udpDetails.dstport;
|
||||
int destport2 = udpDetails.dstport2;
|
||||
uint32_t srcip = udpDetails.srcip;
|
||||
uint32_t dstip = udpDetails.dstip;
|
||||
uint64_t srcmac = udpDetails.srcmac;
|
||||
uint64_t dstmac = udpDetails.dstmac;
|
||||
int srcport = udpDetails.srcport;
|
||||
int dstport = udpDetails.dstport;
|
||||
int dstport2 = udpDetails.dstport2;
|
||||
|
||||
LOG(logINFO, ("Configuring MAC\n"));
|
||||
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
||||
getMacAddressinString(src_mac, 50, sourcemac);
|
||||
getMacAddressinString(dst_mac, 50, destmac);
|
||||
getIpAddressinString(src_ip, sourceip);
|
||||
getIpAddressinString(dst_ip, destip);
|
||||
getMacAddressinString(src_mac, 50, srcmac);
|
||||
getMacAddressinString(dst_mac, 50, dstmac);
|
||||
getIpAddressinString(src_ip, srcip);
|
||||
getIpAddressinString(dst_ip, dstip);
|
||||
|
||||
LOG(logINFO, (
|
||||
"\tSource IP : %s\n"
|
||||
@ -1202,19 +1257,15 @@ int configureMAC() {
|
||||
"\tDest MAC : %s\n"
|
||||
"\tDest Port : %d\n"
|
||||
"\tDest Port2 : %d\n",
|
||||
src_ip, src_mac, src_port,
|
||||
dst_ip, dst_mac, destport, destport2));
|
||||
src_ip, src_mac, srcport,
|
||||
dst_ip, dst_mac, dstport, dstport2));
|
||||
|
||||
#ifdef VIRTUAL
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
|
||||
LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d, port2:%d)\n", cDestIp, destport, destport2));
|
||||
if (setUDPDestinationDetails(0, cDestIp, destport) == FAIL) {
|
||||
if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) {
|
||||
LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if (setUDPDestinationDetails(1, cDestIp, destport2) == FAIL) {
|
||||
if (setUDPDestinationDetails(1, dst_ip, dstport2) == FAIL) {
|
||||
LOG(logERROR, ("could not set udp destination IP and port2\n"));
|
||||
return FAIL;
|
||||
}
|
||||
@ -1223,15 +1274,13 @@ int configureMAC() {
|
||||
|
||||
int beb_num = detid;
|
||||
int header_number = 0;
|
||||
int dst_port = destport;
|
||||
int dst_port = dstport;
|
||||
if (!top)
|
||||
dst_port = destport2;
|
||||
|
||||
LOG(logINFO, ("\tDest Port : %d\n", dst_port));
|
||||
dst_port = dstport2;
|
||||
|
||||
int i=0;
|
||||
/* for(i=0;i<32;i++) { modified for Aldo*/
|
||||
if (Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) &&
|
||||
if (Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,srcport) &&
|
||||
Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port)) {
|
||||
LOG(logDEBUG1, ("\tset up left ok\n"));
|
||||
} else {
|
||||
@ -1240,13 +1289,12 @@ int configureMAC() {
|
||||
/*}*/
|
||||
|
||||
header_number = 32;
|
||||
dst_port = destport2;
|
||||
dst_port = dstport2;
|
||||
if (!top)
|
||||
dst_port = destport;
|
||||
LOG(logINFO, ("\tDest Port : %d\n",dst_port));
|
||||
dst_port = dstport;
|
||||
|
||||
/*for(i=0;i<32;i++) {*//** modified for Aldo*/
|
||||
if (Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) &&
|
||||
if (Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,srcport) &&
|
||||
Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port)) {
|
||||
LOG(logDEBUG1, (" set up right ok\n"));
|
||||
} else {
|
||||
@ -1291,13 +1339,15 @@ int setQuad(int value) {
|
||||
if (!Feb_Control_SetQuad(value)) {
|
||||
return FAIL;
|
||||
}
|
||||
#else
|
||||
eiger_virtual_quad_mode = value;
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getQuad() {
|
||||
#ifdef VIRTUAL
|
||||
return 0;
|
||||
return eiger_virtual_quad_mode;
|
||||
#else
|
||||
return Beb_GetQuad();
|
||||
#endif
|
||||
@ -1433,12 +1483,59 @@ int pulseChip(int n) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int64_t setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never be -1)
|
||||
int updateRateCorrection(char* mess) {
|
||||
int ret = OK;
|
||||
// recalculates rate correction table, or switches off in wrong bit mode
|
||||
if (eiger_tau_ns != 0) {
|
||||
switch (eiger_dynamicrange) {
|
||||
case 16:
|
||||
case 32:
|
||||
ret = setRateCorrection(eiger_tau_ns);
|
||||
break;
|
||||
default:
|
||||
setRateCorrection(0);
|
||||
strcpy(mess, "Rate correction Deactivated, must be in 32 or 16 bit mode");
|
||||
ret = FAIL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
getCurrentTau(); // update eiger_tau_ns
|
||||
return ret;
|
||||
}
|
||||
|
||||
int validateAndSetRateCorrection(int64_t tau_ns, char* mess) {
|
||||
// switching on in wrong bit mode
|
||||
if ((tau_ns != 0) &&
|
||||
(eiger_dynamicrange != 32) && (eiger_dynamicrange != 16)) {
|
||||
strcpy(mess,"Rate correction Deactivated, must be in 32 or 16 bit mode\n");
|
||||
LOG(logERROR,(mess));
|
||||
return FAIL;
|
||||
}
|
||||
// default tau (-1, get proper value)
|
||||
if (tau_ns < 0) {
|
||||
tau_ns = getDefaultSettingsTau_in_nsec();
|
||||
if (tau_ns < 0) {
|
||||
strcpy(mess,"Default settings file not loaded. No default tau yet\n");
|
||||
LOG(logERROR,(mess));
|
||||
return FAIL;
|
||||
}
|
||||
eiger_tau_ns = -1;
|
||||
}
|
||||
// user defined value (settings become undefined)
|
||||
else if (tau_ns > 0) {
|
||||
setSettings(UNDEFINED);
|
||||
LOG(logERROR, ("Settings has been changed to undefined (tau changed)\n"));
|
||||
eiger_tau_ns = tau_ns;
|
||||
}
|
||||
return setRateCorrection(tau_ns);
|
||||
}
|
||||
|
||||
int setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never be -1)
|
||||
#ifdef VIRTUAL
|
||||
//deactivating rate correction
|
||||
if (custom_tau_in_nsec==0) {
|
||||
eiger_virtual_ratecorrection_variable = 0;
|
||||
return 0;
|
||||
return OK;
|
||||
}
|
||||
|
||||
//when dynamic range changes, use old tau
|
||||
@ -1468,22 +1565,21 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never
|
||||
//different setting, calculate table
|
||||
else {
|
||||
eiger_virtual_ratetable_tau_in_ns = custom_tau_in_nsec;
|
||||
double period_in_sec = (double)(eiger_virtual_subexptime*10)/(double)1e9;
|
||||
eiger_virtual_ratetable_period_in_ns = eiger_virtual_subexptime*10;
|
||||
if (eiger_dynamicrange == 16)
|
||||
period_in_sec = eiger_virtual_exptime;
|
||||
eiger_virtual_ratetable_period_in_ns = period_in_sec*1e9;
|
||||
eiger_virtual_ratetable_period_in_ns = eiger_virtual_exptime;
|
||||
}
|
||||
//activating rate correction
|
||||
eiger_virtual_ratecorrection_variable = 1;
|
||||
LOG(logINFO, ("Rate Correction Value set to %lld ns\n",(long long int)eiger_virtual_ratetable_tau_in_ns));
|
||||
|
||||
return eiger_virtual_ratetable_tau_in_ns;
|
||||
return OK;
|
||||
#else
|
||||
|
||||
//deactivating rate correction
|
||||
if (custom_tau_in_nsec==0) {
|
||||
Feb_Control_SetRateCorrectionVariable(0);
|
||||
return 0;
|
||||
return OK;
|
||||
}
|
||||
|
||||
//when dynamic range changes, use old tau
|
||||
@ -1517,7 +1613,7 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never
|
||||
if (ret<=0) {
|
||||
LOG(logERROR, ("Rate correction failed. Deactivating rate correction\n"));
|
||||
Feb_Control_SetRateCorrectionVariable(0);
|
||||
return ret;
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
//activating rate correction
|
||||
@ -1525,7 +1621,7 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never
|
||||
LOG(logINFO, ("Rate Correction Value set to %lld ns\n", (long long int)Feb_Control_Get_RateTable_Tau_in_nsec()));
|
||||
Feb_Control_PrintCorrectedValues();
|
||||
|
||||
return Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||
return OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1543,18 +1639,22 @@ int getDefaultSettingsTau_in_nsec() {
|
||||
|
||||
void setDefaultSettingsTau_in_nsec(int t) {
|
||||
default_tau_from_file = t;
|
||||
LOG(logINFO, ("Default tau set to %d\n", default_tau_from_file));
|
||||
LOG(logINFOBLUE, ("Default tau set to %d\n", default_tau_from_file));
|
||||
}
|
||||
|
||||
int64_t getCurrentTau() {
|
||||
if (!getRateCorrectionEnable())
|
||||
if (!getRateCorrectionEnable()) {
|
||||
eiger_tau_ns = 0;
|
||||
return 0;
|
||||
else
|
||||
}
|
||||
else {
|
||||
#ifndef VIRTUAL
|
||||
return Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||
eiger_tau_ns = Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||
#else
|
||||
return eiger_virtual_ratetable_tau_in_ns;
|
||||
eiger_tau_ns = eiger_virtual_ratetable_tau_in_ns;
|
||||
#endif
|
||||
return eiger_tau_ns;
|
||||
}
|
||||
}
|
||||
|
||||
void setExternalGating(int enable[]) {
|
||||
@ -1571,7 +1671,7 @@ void setExternalGating(int enable[]) {
|
||||
|
||||
int setAllTrimbits(int val) {
|
||||
#ifndef VIRTUAL
|
||||
if (!Feb_Control_SaveAllTrimbitsTo(val)) {
|
||||
if (!Feb_Control_SaveAllTrimbitsTo(val,top)) {
|
||||
LOG(logERROR, ("Could not set all trimbits\n"));
|
||||
return FAIL;
|
||||
}
|
||||
@ -1728,18 +1828,29 @@ int startStateMachine() {
|
||||
if(createUDPSocket(1) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("starting state machine\n"));
|
||||
eiger_virtual_status = 1;
|
||||
eiger_virtual_stop = 0;
|
||||
if (pthread_create(&eiger_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
virtual_status = 1;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
if (virtual_stop != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
if (pthread_create(&virtual_tid, NULL, &start_timer, NULL)) {
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
eiger_virtual_status = 0;
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO ,("Virtual Acquisition started\n"));
|
||||
return OK;
|
||||
#else
|
||||
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
int ret = OK,prev_flag;
|
||||
//get the DAQ toggle bit
|
||||
prev_flag = Feb_Control_AcquisitionStartedBit();
|
||||
@ -1767,9 +1878,13 @@ int startStateMachine() {
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void* start_timer(void* arg) {
|
||||
int64_t periodns = eiger_virtual_period;
|
||||
if (!isControlServer) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int64_t periodNs = eiger_virtual_period;
|
||||
int numFrames = nimages_per_request;
|
||||
int64_t exp_us = eiger_virtual_exptime / 1000;
|
||||
int64_t expUs = eiger_virtual_exptime / 1000;
|
||||
|
||||
int dr = eiger_dynamicrange;
|
||||
double bytesPerPixel = (double)dr/8.00;
|
||||
@ -1779,100 +1894,160 @@ void* start_timer(void* arg) {
|
||||
int numPacketsPerFrame = (tgEnable ? 4 : 16) * dr;
|
||||
int npixelsx = 256 * 2 * bytesPerPixel;
|
||||
int databytes = 256 * 256 * 2 * bytesPerPixel;
|
||||
LOG(logINFO, (" dr:%f\n bytesperpixel:%d\n tgenable:%d\n datasize:%d\n packetsize:%d\n numpackes:%d\n npixelsx:%d\n databytes:%d\n",
|
||||
dr, bytesPerPixel, tgEnable, datasize, packetsize, numPacketsPerFrame, npixelsx, databytes));
|
||||
int row = eiger_virtual_detPos[0];
|
||||
int colLeft = top ? eiger_virtual_detPos[1] : eiger_virtual_detPos[1] + 1;
|
||||
int colRight = top ? eiger_virtual_detPos[1] + 1 : eiger_virtual_detPos[1];
|
||||
int ntotpixels = 256 * 256 * 4;
|
||||
|
||||
LOG(logINFO, (" dr:%d\n bytesperpixel:%f\n tgenable:%d\n datasize:%d\n packetsize:%d\n numpackes:%d\n npixelsx:%d\n databytes:%d\n ntotpixels:%d\n",
|
||||
dr, bytesPerPixel, tgEnable, datasize, packetsize, numPacketsPerFrame, npixelsx, databytes, ntotpixels));
|
||||
|
||||
//TODO: Generate data
|
||||
char imageData[databytes * 2];
|
||||
memset(imageData, 0, databytes * 2);
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < databytes * 2; i += sizeof(uint8_t)) {
|
||||
*((uint8_t*)(imageData + i)) = i;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Send data
|
||||
{
|
||||
int frameNr = 1;
|
||||
for(frameNr=1; frameNr <= numFrames; ++frameNr ) {
|
||||
|
||||
//check if virtual_stop is high
|
||||
if(eiger_virtual_stop == 1){
|
||||
break;
|
||||
// Generate data
|
||||
char imageData[databytes * 2];
|
||||
memset(imageData, 0, databytes * 2);
|
||||
{
|
||||
int i = 0;
|
||||
switch (dr) {
|
||||
case 4:
|
||||
for (i = 0; i < ntotpixels/2; ++i) {
|
||||
*((uint8_t*)(imageData + i)) = eiger_virtual_test_mode ? 0xEE : (uint8_t)(((2 * i & 0xF) << 4) | ((2 * i + 1) & 0xF));
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
for (i = 0; i < ntotpixels; ++i) {
|
||||
*((uint8_t*)(imageData + i)) = eiger_virtual_test_mode ? 0xFE : (uint8_t)i;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
for (i = 0; i < ntotpixels; ++i) {
|
||||
*((uint16_t*)(imageData + i * sizeof(uint16_t))) = eiger_virtual_test_mode ? 0xFFE : (uint16_t)i;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
for (i = 0; i < ntotpixels; ++i) {
|
||||
*((uint32_t*)(imageData + i * sizeof(uint32_t))) = eiger_virtual_test_mode ? 0xFFFFFE : (uint32_t)i;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Send data
|
||||
{
|
||||
uint64_t frameNr = 0;
|
||||
getStartingFrameNumber(&frameNr);
|
||||
// loop over number of frames
|
||||
int iframes = 0;
|
||||
for(iframes = 0; iframes != numFrames; ++iframes ) {
|
||||
|
||||
int srcOffset = 0;
|
||||
int srcOffset2 = npixelsx;
|
||||
usleep(eiger_virtual_transmission_delay_frame);
|
||||
|
||||
// update the virtual stop from stop server
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
//check if virtual_stop is high
|
||||
if(virtual_stop == 1){
|
||||
setStartingFrameNumber(frameNr + iframes + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expUs);
|
||||
|
||||
int srcOffset = 0;
|
||||
int srcOffset2 = npixelsx;
|
||||
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(exp_us);
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
char packetData2[packetsize];
|
||||
memset(packetData2, 0, packetsize);
|
||||
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 0; i != numPacketsPerFrame; ++i) {
|
||||
int dstOffset = sizeof(sls_detector_header);
|
||||
int dstOffset2 = sizeof(sls_detector_header);
|
||||
// set header
|
||||
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||
header->frameNumber = frameNr;
|
||||
header->packetNumber = i;
|
||||
header = (sls_detector_header*)(packetData2);
|
||||
header->frameNumber = frameNr;
|
||||
header->packetNumber = i;
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 0; i != numPacketsPerFrame; ++i) {
|
||||
// set header
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||
header->detType = 3;//(uint16_t)myDetectorType; updated when firmware updates
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameNr + iframes;
|
||||
header->packetNumber = i;
|
||||
header->row = row;
|
||||
header->column = colLeft;
|
||||
|
||||
// fill data
|
||||
{
|
||||
int psize = 0;
|
||||
for (psize = 0; psize < datasize; psize += npixelsx) {
|
||||
char packetData2[packetsize];
|
||||
memset(packetData2, 0, packetsize);
|
||||
header = (sls_detector_header*)(packetData2);
|
||||
header->detType = 3;//(uint16_t)myDetectorType; updated when firmware updates
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameNr + iframes;
|
||||
header->packetNumber = i;
|
||||
header->row = row;
|
||||
header->column = colRight;
|
||||
if (eiger_virtual_quad_mode) {
|
||||
header->row = 1; // right is next row
|
||||
header->column = 0; // right same first column
|
||||
}
|
||||
|
||||
if (dr == 32 && tgEnable == 0) {
|
||||
memcpy(packetData + dstOffset, imageData + srcOffset, npixelsx/2);
|
||||
memcpy(packetData2 + dstOffset2, imageData + srcOffset2, npixelsx/2);
|
||||
// fill data
|
||||
int dstOffset = sizeof(sls_detector_header);
|
||||
int dstOffset2 = sizeof(sls_detector_header);
|
||||
{
|
||||
int psize = 0;
|
||||
for (psize = 0; psize < datasize; psize += npixelsx) {
|
||||
|
||||
if (dr == 32 && tgEnable == 0) {
|
||||
memcpy(packetData + dstOffset, imageData + srcOffset, npixelsx/2);
|
||||
memcpy(packetData2 + dstOffset2, imageData + srcOffset2, npixelsx/2);
|
||||
if (srcOffset % npixelsx == 0) {
|
||||
srcOffset += npixelsx/2;
|
||||
srcOffset2 += npixelsx/2;
|
||||
}
|
||||
// skip the other half (2 packets in 1 line for 32 bit)
|
||||
else {
|
||||
srcOffset += npixelsx;
|
||||
srcOffset2 += npixelsx;
|
||||
dstOffset += npixelsx/2;
|
||||
dstOffset2 += npixelsx/2;
|
||||
} else {
|
||||
memcpy(packetData + dstOffset, imageData + srcOffset, npixelsx);
|
||||
memcpy(packetData2 + dstOffset2, imageData + srcOffset2, npixelsx);
|
||||
srcOffset += 2 * npixelsx;
|
||||
srcOffset2 += 2 * npixelsx;
|
||||
dstOffset += npixelsx;
|
||||
dstOffset2 += npixelsx;
|
||||
srcOffset2 += npixelsx;
|
||||
}
|
||||
dstOffset += npixelsx/2;
|
||||
dstOffset2 += npixelsx/2;
|
||||
} else {
|
||||
memcpy(packetData + dstOffset, imageData + srcOffset, npixelsx);
|
||||
memcpy(packetData2 + dstOffset2, imageData + srcOffset2, npixelsx);
|
||||
srcOffset += 2 * npixelsx;
|
||||
srcOffset2 += 2 * npixelsx;
|
||||
dstOffset += npixelsx;
|
||||
dstOffset2 += npixelsx;
|
||||
}
|
||||
}
|
||||
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
sendUDPPacket(1, packetData2, packetsize);
|
||||
}
|
||||
usleep(eiger_virtual_transmission_delay_left);
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
usleep(eiger_virtual_transmission_delay_right);
|
||||
sendUDPPacket(1, packetData2, packetsize);
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d\n", iframes));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodns > time_ns) {
|
||||
usleep((periodns - time_ns)/ 1000);
|
||||
}
|
||||
// sleep for (period - exptime)
|
||||
if (iframes < numFrames) { // if there is a next frame
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs)/ 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
setStartingFrameNumber(frameNr + numFrames);
|
||||
}
|
||||
|
||||
|
||||
closeUDPSocket(0);
|
||||
closeUDPSocket(1);
|
||||
|
||||
eiger_virtual_status = 0;
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
@ -1884,7 +2059,18 @@ void* start_timer(void* arg) {
|
||||
int stopStateMachine() {
|
||||
LOG(logINFORED, ("Going to stop acquisition\n"));
|
||||
#ifdef VIRTUAL
|
||||
eiger_virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
// read till status is idle
|
||||
int tempStatus = 1;
|
||||
while(tempStatus == 1) {
|
||||
tempStatus = ComVirtual_getStatus();
|
||||
}
|
||||
virtual_stop = 0;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
}
|
||||
return OK;
|
||||
#else
|
||||
if ((Feb_Control_StopAcquisition() != STATUS_IDLE) || (!Beb_StopAcquisition()) ) {
|
||||
@ -1944,7 +2130,10 @@ int startReadOut() {
|
||||
|
||||
enum runStatus getRunStatus() {
|
||||
#ifdef VIRTUAL
|
||||
if (eiger_virtual_status == 0) {
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
if (virtual_status == 0) {
|
||||
LOG(logINFO, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
} else {
|
||||
@ -1954,19 +2143,23 @@ enum runStatus getRunStatus() {
|
||||
#else
|
||||
|
||||
int i = Feb_Control_AcquisitionInProgress();
|
||||
switch (i) {
|
||||
case STATUS_ERROR:
|
||||
if (i == STATUS_ERROR) {
|
||||
LOG(logERROR, ("Status: ERROR reading status register\n"));
|
||||
return ERROR;
|
||||
case STATUS_IDLE:
|
||||
} else if (i == STATUS_IDLE) {
|
||||
int isTransmitting = 0;
|
||||
if (Beb_IsTransmitting(&isTransmitting, send_to_ten_gig, 0) == FAIL) {
|
||||
return ERROR;
|
||||
}
|
||||
if (isTransmitting) {
|
||||
printf("Status: TRANSMITTING\n");
|
||||
return TRANSMITTING;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
default:
|
||||
LOG(logINFOBLUE, ("Status: RUNNING...\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
|
||||
return IDLE;
|
||||
LOG(logINFOBLUE, ("Status: RUNNING...\n"));
|
||||
return RUNNING;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1975,7 +2168,7 @@ enum runStatus getRunStatus() {
|
||||
void readFrame(int *ret, char *mess) {
|
||||
#ifdef VIRTUAL
|
||||
// wait for status to be done
|
||||
while(eiger_virtual_status == 1){
|
||||
while(virtual_status == 1){
|
||||
usleep(500);
|
||||
}
|
||||
LOG(logINFOGREEN, ("acquisition successfully finished\n"));
|
||||
@ -2000,7 +2193,18 @@ void readFrame(int *ret, char *mess) {
|
||||
}
|
||||
|
||||
//wait for detector to send
|
||||
Beb_EndofDataSend(send_to_ten_gig);
|
||||
int isTransmitting = 1;
|
||||
while (isTransmitting) {
|
||||
if (Beb_IsTransmitting(&isTransmitting, send_to_ten_gig, 1) == FAIL) {
|
||||
strcpy(mess,"Could not read delay counters\n");
|
||||
*ret = (int)FAIL;
|
||||
return;
|
||||
}
|
||||
if (isTransmitting) {
|
||||
printf("Transmitting...\n");
|
||||
}
|
||||
}
|
||||
printf("Detector has sent all data\n");
|
||||
LOG(logINFOGREEN, ("Acquisition successfully finished\n"));
|
||||
#endif
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#define REQUIRED_FIRMWARE_VERSION (24)
|
||||
#define IDFILECOMMAND "more /home/root/executables/detid.txt"
|
||||
#define FIRMWARE_VERSION_SAME_TOP_BOT_ADDR (26)
|
||||
|
||||
#define STATUS_IDLE 0
|
||||
#define STATUS_RUNNING 1
|
||||
@ -63,10 +64,10 @@ enum CLKINDEX {RUN_CLK, NUM_CLOCKS};
|
||||
#define DEFAULT_SUBFRAME_DEADTIME (0)
|
||||
#define DEFAULT_DYNAMIC_RANGE (16)
|
||||
|
||||
#define DEFAULT_PARALLEL_MODE (0)
|
||||
#define DEFAULT_PARALLEL_MODE (1)
|
||||
#define DEFAULT_READOUT_STOREINRAM_MODE (0)
|
||||
#define DEFAULT_READOUT_OVERFLOW32_MODE (0)
|
||||
#define DEFAULT_CLK_SPEED (HALF_SPEED)
|
||||
#define DEFAULT_CLK_SPEED (FULL_SPEED)
|
||||
#define DEFAULT_IO_DELAY (650)
|
||||
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
|
||||
#define DEFAULT_PHOTON_ENERGY (-1)
|
||||
|
@ -11,6 +11,7 @@ add_executable(gotthard2DetectorServer_virtual
|
||||
../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c
|
||||
../slsDetectorServer/src/ASIC_Driver.c
|
||||
../slsDetectorServer/src/programFpgaNios.c
|
||||
../slsDetectorServer/src/communication_virtual.c
|
||||
)
|
||||
|
||||
include_directories(
|
||||
|
Binary file not shown.
@ -9,10 +9,12 @@
|
||||
#include "ASIC_Driver.h"
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_funcs_UDP.h"
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h> // usleep
|
||||
#include <netinet/in.h>
|
||||
#ifdef VIRTUAL
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
@ -25,6 +27,11 @@ extern int checkModuleFlag;
|
||||
extern udpStruct udpDetails;
|
||||
extern const enum detectorType myDetectorType;
|
||||
|
||||
// Global variable from communication_funcs.c
|
||||
extern int isControlServer;
|
||||
extern void getMacAddressinString(char* cmac, int size, uint64_t mac);
|
||||
extern void getIpAddressinString(char* cip, uint32_t ip);
|
||||
|
||||
int initError = OK;
|
||||
int initCheckDone = 0;
|
||||
char initErrorMessage[MAX_STR_LENGTH];
|
||||
@ -332,6 +339,12 @@ void initStopServer() {
|
||||
LOG(logERROR, ("Stop Server: Map Fail. Dangerous to continue. Goodbye!\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -381,9 +394,13 @@ void setupDetector() {
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef VIRTUAL
|
||||
// pll defines
|
||||
ALTERA_PLL_C10_SetDefines(REG_OFFSET, BASE_READOUT_PLL, BASE_SYSTEM_PLL, PLL_RESET_REG, PLL_RESET_REG, PLL_RESET_READOUT_MSK, PLL_RESET_SYSTEM_MSK, READOUT_PLL_VCO_FREQ_HZ, SYSTEM_PLL_VCO_FREQ_HZ);
|
||||
ALTERA_PLL_C10_ResetPLL(READOUT_PLL);
|
||||
@ -394,7 +411,6 @@ void setupDetector() {
|
||||
LTC2620_D_SetDefines(DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC);
|
||||
// on chip dacs
|
||||
ASIC_Driver_SetDefines(ONCHIP_DAC_DRIVER_FILE_NAME);
|
||||
#endif
|
||||
setTimingSource(DEFAULT_TIMING_SOURCE);
|
||||
|
||||
// Default values
|
||||
@ -431,12 +447,10 @@ void setupDetector() {
|
||||
// power on chip
|
||||
powerChip(1);
|
||||
|
||||
#ifndef VIRTUAL
|
||||
// also sets default dac and on chip dac values
|
||||
if (readConfigFile() == FAIL) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
setBurstMode(DEFAULT_BURST_MODE);
|
||||
setSettings(DEFAULT_SETTINGS);
|
||||
|
||||
@ -1187,42 +1201,30 @@ int configureMAC() {
|
||||
int srcport = udpDetails.srcport;
|
||||
int dstport = udpDetails.dstport;
|
||||
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
||||
getMacAddressinString(src_mac, 50, srcmac);
|
||||
getMacAddressinString(dst_mac, 50, dstmac);
|
||||
getIpAddressinString(src_ip, srcip);
|
||||
getIpAddressinString(dst_ip, dstip);
|
||||
|
||||
LOG(logINFO, (
|
||||
"\tSource IP : %s\n"
|
||||
"\tSource MAC : %s\n"
|
||||
"\tSource Port : %d\n"
|
||||
"\tDest IP : %s\n"
|
||||
"\tDest MAC : %s\n"
|
||||
"\tDest Port : %d\n",
|
||||
src_ip, src_mac, srcport,
|
||||
dst_ip, dst_mac, dstport));
|
||||
|
||||
#ifdef VIRTUAL
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff);
|
||||
LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, dstport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, dstport) == FAIL) {
|
||||
if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) {
|
||||
LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
#endif
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
|
||||
LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(srcip>>24)&0xff,(srcip>>16)&0xff,(srcip>>8)&0xff,(srcip)&0xff, srcip));
|
||||
LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((srcmac>>40)&0xFF),
|
||||
(unsigned int)((srcmac>>32)&0xFF),
|
||||
(unsigned int)((srcmac>>24)&0xFF),
|
||||
(unsigned int)((srcmac>>16)&0xFF),
|
||||
(unsigned int)((srcmac>>8)&0xFF),
|
||||
(unsigned int)((srcmac>>0)&0xFF),
|
||||
(long long unsigned int)srcmac));
|
||||
LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n", srcport, srcport));
|
||||
|
||||
LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff, dstip));
|
||||
LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((dstmac>>40)&0xFF),
|
||||
(unsigned int)((dstmac>>32)&0xFF),
|
||||
(unsigned int)((dstmac>>24)&0xFF),
|
||||
(unsigned int)((dstmac>>16)&0xFF),
|
||||
(unsigned int)((dstmac>>8)&0xFF),
|
||||
(unsigned int)((dstmac>>0)&0xFF),
|
||||
(long long unsigned int)dstmac));
|
||||
LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n\n",dstport, dstport));
|
||||
|
||||
// start addr
|
||||
uint32_t addr = BASE_UDP_RAM;
|
||||
@ -1340,6 +1342,9 @@ int* getDetectorPosition() {
|
||||
// Detector Specific
|
||||
|
||||
int checkDetectorType() {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
LOG(logINFO, ("Checking type of module\n"));
|
||||
FILE* fd = fopen(TYPE_FILE_NAME, "r");
|
||||
if (fd == NULL) {
|
||||
@ -2011,13 +2016,24 @@ int startStateMachine(){
|
||||
if(createUDPSocket(0) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("starting state machine\n"));
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
// set status to running
|
||||
virtual_status = 1;
|
||||
virtual_stop = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
if (virtual_stop != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
if(pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||
@ -2036,10 +2052,22 @@ int startStateMachine(){
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void* start_timer(void* arg) {
|
||||
int64_t periodns = getPeriod();
|
||||
int numFrames = (getNumFrames() *
|
||||
getNumTriggers() );
|
||||
int64_t exp_ns = getExpTime();
|
||||
if (!isControlServer) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int numRepeats = getNumTriggers();
|
||||
if (getTiming() == AUTO_TIMING) {
|
||||
if (burstMode == BURST_OFF) {
|
||||
numRepeats = 1;
|
||||
} else {
|
||||
numRepeats = getNumBursts();
|
||||
}
|
||||
}
|
||||
int repeatPeriodNs = getBurstPeriod();
|
||||
int numFrames = getNumFrames();
|
||||
int64_t periodNs = getPeriod();
|
||||
int64_t expUs = getExpTime() / 1000;
|
||||
int imagesize = NCHAN * NCHIP * 2;
|
||||
int datasize = imagesize;
|
||||
int packetsize = datasize + sizeof(sls_detector_header);
|
||||
@ -2049,62 +2077,87 @@ void* start_timer(void* arg) {
|
||||
memset(imageData, 0, imagesize);
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < imagesize; i += sizeof(uint8_t)) {
|
||||
*((uint8_t*)(imageData + i)) = i;
|
||||
for (i = 0; i < imagesize; i += sizeof(uint16_t)) {
|
||||
*((uint16_t*)(imageData + i)) = i;
|
||||
}
|
||||
}
|
||||
|
||||
int frameNr = 0;
|
||||
// loop over number of frames
|
||||
for(frameNr=0; frameNr!= numFrames; ++frameNr ) {
|
||||
{
|
||||
int repeatNr = 0;
|
||||
int frameHeaderNr = 0;
|
||||
// loop over number of repeats
|
||||
for(repeatNr=0; repeatNr!= numRepeats; ++repeatNr ) {
|
||||
|
||||
//check if virtual_stop is high
|
||||
if(virtual_stop == 1){
|
||||
break;
|
||||
}
|
||||
struct timespec rbegin, rend;
|
||||
clock_gettime(CLOCK_REALTIME, &rbegin);
|
||||
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(exp_ns / 1000);
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int frameNr = 0;
|
||||
// loop over number of frames
|
||||
for(frameNr = 0; frameNr != numFrames; ++frameNr ) {
|
||||
|
||||
// update the virtual stop from stop server
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
//check if virtual_stop is high
|
||||
if(virtual_stop == 1){
|
||||
break;
|
||||
}
|
||||
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
// set header
|
||||
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||
header->frameNumber = frameNr;
|
||||
header->packetNumber = 0;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
header->column = detPos[Y];
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expUs);
|
||||
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header), imageData, datasize);
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
// set header
|
||||
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameHeaderNr;
|
||||
++frameHeaderNr;
|
||||
header->packetNumber = 0;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
header->column = detPos[Y];
|
||||
|
||||
// send 1 packet = 1 frame
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header), imageData, datasize) ;
|
||||
|
||||
// calculate time left in period
|
||||
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
// send 1 packet = 1 frame
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodns > time_ns) {
|
||||
usleep((periodns - time_ns)/ 1000);
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
LOG(logINFO, ("Sent frame: %d (bursts: %d)\n", frameNr, repeatNr));
|
||||
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs)/ 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
clock_gettime(CLOCK_REALTIME, &rend);
|
||||
int64_t timeNs = ((rend.tv_sec - rbegin.tv_sec) * 1E9 +
|
||||
(rend.tv_nsec - rbegin.tv_nsec));
|
||||
|
||||
// sleep for (repeatPeriodNs - time remaining)
|
||||
if (repeatNr < numRepeats) { // if there is a next repeat
|
||||
if (repeatPeriodNs > timeNs) {
|
||||
usleep((repeatPeriodNs - timeNs)/ 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set register frames left
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closeUDPSocket(0);
|
||||
// set status to idle
|
||||
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
@ -2114,7 +2167,18 @@ void* start_timer(void* arg) {
|
||||
int stopStateMachine(){
|
||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
// read till status is idle
|
||||
int tempStatus = 1;
|
||||
while(tempStatus == 1) {
|
||||
tempStatus = ComVirtual_getStatus();
|
||||
}
|
||||
virtual_stop = 0;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
}
|
||||
return OK;
|
||||
#endif
|
||||
//stop state machine
|
||||
@ -2125,7 +2189,10 @@ int stopStateMachine(){
|
||||
|
||||
enum runStatus getRunStatus(){
|
||||
#ifdef VIRTUAL
|
||||
if(virtual_status == 0){
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
if(virtual_status == 0) {
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
}else{
|
||||
@ -2199,6 +2266,9 @@ void readFrame(int *ret, char *mess) {
|
||||
|
||||
u_int32_t runBusy() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
return virtual_status;
|
||||
#endif
|
||||
u_int32_t s = (bus_r(FLOW_STATUS_REG) & FLOW_STATUS_RUN_BUSY_MSK);
|
||||
|
@ -9,6 +9,8 @@ add_executable(gotthardDetectorServer_virtual
|
||||
../slsDetectorServer/src/LTC2620.c
|
||||
../slsDetectorServer/src/common.c
|
||||
../slsDetectorServer/src/commonServerFunctions.c
|
||||
../slsDetectorServer/src/communication_funcs_UDP.c
|
||||
../slsDetectorServer/src/communication_virtual.c
|
||||
)
|
||||
|
||||
include_directories(
|
||||
|
Binary file not shown.
@ -4,19 +4,30 @@
|
||||
#include "RegisterDefs.h"
|
||||
|
||||
#include "LTC2620.h" // dacs
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_funcs_UDP.h"
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include "string.h"
|
||||
#include <unistd.h> // usleep
|
||||
#include <netinet/in.h>
|
||||
#ifdef VIRTUAL
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
extern udpStruct udpDetails;
|
||||
extern const enum detectorType myDetectorType;
|
||||
|
||||
// Variables that will be exported
|
||||
int phaseShift = DEFAULT_PHASE_SHIFT;
|
||||
|
||||
// Global variable from communication_funcs.c
|
||||
extern int isControlServer;
|
||||
extern void getMacAddressinString(char* cmac, int size, uint64_t mac);
|
||||
extern void getIpAddressinString(char* cip, uint32_t ip);
|
||||
|
||||
int initError = OK;
|
||||
int initCheckDone = 0;
|
||||
char initErrorMessage[MAX_STR_LENGTH];
|
||||
@ -239,10 +250,10 @@ void setTestImageMode(int ival) {
|
||||
uint32_t addr = MULTI_PURPOSE_REG;
|
||||
if (ival >= 0) {
|
||||
if (ival == 0) {
|
||||
LOG(logINFO, ("Switching on Image Test Mode\n"));
|
||||
LOG(logINFO, ("Switching off Image Test Mode\n"));
|
||||
bus_w (addr, bus_r(addr) & ~DGTL_TST_MSK);
|
||||
} else {
|
||||
LOG(logINFO, ("Switching off Image Test Mode\n"));
|
||||
LOG(logINFO, ("Switching on Image Test Mode\n"));
|
||||
bus_w (addr, bus_r(addr) | DGTL_TST_MSK);
|
||||
}
|
||||
}
|
||||
@ -345,6 +356,12 @@ void initStopServer() {
|
||||
LOG(logERROR, ("Stop Server: Map Fail. Dangerous to continue. Goodbye!\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -353,6 +370,13 @@ void initStopServer() {
|
||||
void setupDetector() {
|
||||
LOG(logINFO, ("This Server is for 1 Gotthard module (1280 channels)\n"));
|
||||
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Initialization
|
||||
setPhaseShiftOnce();
|
||||
|
||||
@ -915,8 +939,9 @@ int getModule(sls_detector_module *myMod){
|
||||
if (dacValues[idac] >= 0)
|
||||
initialized = 1;
|
||||
}
|
||||
if (initialized)
|
||||
if (initialized) {
|
||||
return OK;
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -1088,11 +1113,6 @@ int getADC(enum ADCINDEX ind){
|
||||
}
|
||||
|
||||
int setHighVoltage(int val){
|
||||
#ifdef VIRTUAL
|
||||
if (val >= 0)
|
||||
highvoltage = val;
|
||||
return highvoltage;
|
||||
#endif
|
||||
u_int32_t addr = HV_REG;
|
||||
u_int32_t sel = 0x0;
|
||||
|
||||
@ -1262,44 +1282,42 @@ void calcChecksum(mac_conf* mac, int sourceip, int destip) {
|
||||
}
|
||||
|
||||
int configureMAC() {
|
||||
uint32_t sourceip = udpDetails.srcip;
|
||||
uint32_t destip = udpDetails.dstip;
|
||||
uint64_t sourcemac = udpDetails.srcmac;
|
||||
uint64_t destmac = udpDetails.dstmac;
|
||||
int sourceport = udpDetails.srcport;
|
||||
int destport = udpDetails.dstport;
|
||||
uint32_t srcip = udpDetails.srcip;
|
||||
uint32_t dstip = udpDetails.dstip;
|
||||
uint64_t srcmac = udpDetails.srcmac;
|
||||
uint64_t dstmac = udpDetails.dstmac;
|
||||
int srcport = udpDetails.srcport;
|
||||
int dstport = udpDetails.dstport;
|
||||
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
||||
getMacAddressinString(src_mac, 50, srcmac);
|
||||
getMacAddressinString(dst_mac, 50, dstmac);
|
||||
getIpAddressinString(src_ip, srcip);
|
||||
getIpAddressinString(dst_ip, dstip);
|
||||
|
||||
LOG(logINFO, (
|
||||
"\tSource IP : %s\n"
|
||||
"\tSource MAC : %s\n"
|
||||
"\tSource Port : %d\n"
|
||||
"\tDest IP : %s\n"
|
||||
"\tDest MAC : %s\n"
|
||||
"\tDest Port : %d\n",
|
||||
src_ip, src_mac, srcport,
|
||||
dst_ip, dst_mac, dstport));
|
||||
|
||||
#ifdef VIRTUAL
|
||||
if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) {
|
||||
LOG(logERROR, ("could not set udp 1G destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
#endif
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
u_int32_t addr = MULTI_PURPOSE_REG;
|
||||
|
||||
LOG(logDEBUG1, ("\tRoi: %d, Ip Packet size: %d UDP Packet size: %d\n",
|
||||
adcConfigured, ipPacketSize, udpPacketSize));
|
||||
|
||||
LOG(logINFO, ("\tSource IP : %d.%d.%d.%d (0x%08x)\n",
|
||||
(sourceip>>24)&0xff,(sourceip>>16)&0xff,(sourceip>>8)&0xff,(sourceip)&0xff, sourceip));
|
||||
LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x (0x%010llx)\n",
|
||||
(unsigned int)((sourcemac>>40)&0xFF),
|
||||
(unsigned int)((sourcemac>>32)&0xFF),
|
||||
(unsigned int)((sourcemac>>24)&0xFF),
|
||||
(unsigned int)((sourcemac>>16)&0xFF),
|
||||
(unsigned int)((sourcemac>>8)&0xFF),
|
||||
(unsigned int)((sourcemac>>0)&0xFF),
|
||||
(long long unsigned int)sourcemac));
|
||||
LOG(logINFO, ("\tSource Port : %d (0x%08x)\n",sourceport, sourceport));
|
||||
LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d (0x%08x)\n",
|
||||
(destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff, destip));
|
||||
LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x (0x%010llx)\n",
|
||||
(unsigned int)((destmac>>40)&0xFF),
|
||||
(unsigned int)((destmac>>32)&0xFF),
|
||||
(unsigned int)((destmac>>24)&0xFF),
|
||||
(unsigned int)((destmac>>16)&0xFF),
|
||||
(unsigned int)((destmac>>8)&0xFF),
|
||||
(unsigned int)((destmac>>0)&0xFF),
|
||||
(long long unsigned int)destmac));
|
||||
LOG(logINFO, ("\tDest. Port : %d (0x%08x)\n",destport, destport));
|
||||
|
||||
//reset mac
|
||||
bus_w (addr, bus_r(addr) | RST_MSK);
|
||||
LOG(logDEBUG1, ("\tReset Mac. MultiPurpose reg: 0x%x\n", bus_r(addr)));
|
||||
@ -1320,28 +1338,28 @@ int configureMAC() {
|
||||
|
||||
LOG(logDEBUG1, ("\tConfiguring MAC CONF\n"));
|
||||
mac_conf *mac_conf_regs = (mac_conf*)(Blackfin_getBaseAddress() + ENET_CONF_REG / 2); // direct write
|
||||
mac_conf_regs->mac.mac_dest_mac1 = ((destmac >> (8 * 5)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_dest_mac2 = ((destmac >> (8 * 4)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_dest_mac3 = ((destmac >> (8 * 3)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_dest_mac4 = ((destmac >> (8 * 2)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_dest_mac5 = ((destmac >> (8 * 1)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_dest_mac6 = ((destmac >> (8 * 0)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_dest_mac1 = ((dstmac >> (8 * 5)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_dest_mac2 = ((dstmac >> (8 * 4)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_dest_mac3 = ((dstmac >> (8 * 3)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_dest_mac4 = ((dstmac >> (8 * 2)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_dest_mac5 = ((dstmac >> (8 * 1)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_dest_mac6 = ((dstmac >> (8 * 0)) & 0xFF);
|
||||
LOG(logDEBUG1, ("\tDestination Mac: %llx %x:%x:%x:%x:%x:%x\n",
|
||||
destmac,
|
||||
dstmac,
|
||||
mac_conf_regs->mac.mac_dest_mac1,
|
||||
mac_conf_regs->mac.mac_dest_mac2,
|
||||
mac_conf_regs->mac.mac_dest_mac3,
|
||||
mac_conf_regs->mac.mac_dest_mac4,
|
||||
mac_conf_regs->mac.mac_dest_mac5,
|
||||
mac_conf_regs->mac.mac_dest_mac6));
|
||||
mac_conf_regs->mac.mac_src_mac1 = ((sourcemac >> (8 * 5)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_src_mac2 = ((sourcemac >> (8 * 4)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_src_mac3 = ((sourcemac >> (8 * 3)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_src_mac4 = ((sourcemac >> (8 * 2)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_src_mac5 = ((sourcemac >> (8 * 1)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_src_mac6 = ((sourcemac >> (8 * 0)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_src_mac1 = ((srcmac >> (8 * 5)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_src_mac2 = ((srcmac >> (8 * 4)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_src_mac3 = ((srcmac >> (8 * 3)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_src_mac4 = ((srcmac >> (8 * 2)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_src_mac5 = ((srcmac >> (8 * 1)) & 0xFF);
|
||||
mac_conf_regs->mac.mac_src_mac6 = ((srcmac >> (8 * 0)) & 0xFF);
|
||||
LOG(logDEBUG1, ("\tSource Mac: %llx %x:%x:%x:%x:%x:%x\n",
|
||||
sourcemac,
|
||||
srcmac,
|
||||
mac_conf_regs->mac.mac_src_mac1,
|
||||
mac_conf_regs->mac.mac_src_mac2,
|
||||
mac_conf_regs->mac.mac_src_mac3,
|
||||
@ -1350,9 +1368,9 @@ int configureMAC() {
|
||||
mac_conf_regs->mac.mac_src_mac6));
|
||||
mac_conf_regs->mac.mac_ether_type = 0x0800; //ipv4
|
||||
|
||||
calcChecksum(mac_conf_regs, sourceip, destip);
|
||||
mac_conf_regs->udp.udp_srcport = sourceport;
|
||||
mac_conf_regs->udp.udp_destport = destport;
|
||||
calcChecksum(mac_conf_regs, srcip, dstip);
|
||||
mac_conf_regs->udp.udp_srcport = srcport;
|
||||
mac_conf_regs->udp.udp_destport = dstport;
|
||||
mac_conf_regs->udp.udp_len = udpPacketSize;
|
||||
mac_conf_regs->udp.udp_chksum = 0x0000;
|
||||
|
||||
@ -1487,11 +1505,27 @@ int setPhase(enum CLKINDEX ind, int val, int degrees) {
|
||||
|
||||
int startStateMachine(){
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 1;
|
||||
virtual_stop = 0;
|
||||
// create udp socket
|
||||
if(createUDPSocket(0) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
virtual_status = 1;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
if (virtual_stop != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
if(pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
virtual_status = 0;
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||
@ -1511,17 +1545,92 @@ int startStateMachine(){
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void* start_timer(void* arg) {
|
||||
int wait_in_s = (getNumFrames() *
|
||||
getNumTriggers() *
|
||||
(getPeriod()/(1E9)));
|
||||
LOG(logDEBUG1, ("going to wait for %d s\n", wait_in_s));
|
||||
while(!virtual_stop && (wait_in_s >= 0)) {
|
||||
usleep(1000 * 1000);
|
||||
wait_in_s--;
|
||||
if (!isControlServer) {
|
||||
return NULL;
|
||||
}
|
||||
LOG(logINFOGREEN, ("Virtual Timer Done\n"));
|
||||
|
||||
int64_t periodNs = getPeriod();
|
||||
int numFrames = (getNumFrames() *
|
||||
getNumTriggers() );
|
||||
int64_t expUs = getExpTime() / 1000;
|
||||
|
||||
int imageSize = adcConfigured == -1 ? DATA_BYTES : NCHAN_PER_ADC * NUM_BITS_PER_PIXEL;
|
||||
int dataSize = adcConfigured == -1 ? 1280 : 512;
|
||||
int packetSize = adcConfigured == -1 ? 1286 : 518;
|
||||
int packetsPerFrame = adcConfigured == -1 ? 2 : 1;
|
||||
|
||||
// Generate Data
|
||||
char imageData[imageSize];
|
||||
memset(imageData, 0, imageSize);
|
||||
{
|
||||
int i = 0;
|
||||
if (adcConfigured == -1) {
|
||||
*((uint32_t*)(imageData)) = 0xCACACACA;
|
||||
}
|
||||
for (i = sizeof(uint32_t); i < imageSize; i += sizeof(uint16_t)) {
|
||||
*((uint16_t*)(imageData + i)) = (uint16_t)i;
|
||||
}
|
||||
}
|
||||
|
||||
// Send data
|
||||
{
|
||||
int frameNr = 0;
|
||||
uint16_t frameHeaderNr = 2;
|
||||
// loop over number of frames
|
||||
for(frameNr = 0; frameNr != numFrames; ++frameNr ) {
|
||||
|
||||
// update the virtual stop from stop server
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
//check if virtual_stop is high
|
||||
if(virtual_stop == 1){
|
||||
break;
|
||||
}
|
||||
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expUs);
|
||||
|
||||
int srcOffset = 0;
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 0; i != packetsPerFrame; ++i) {
|
||||
|
||||
char packetData[packetSize];
|
||||
memset(packetData, 0, packetSize);
|
||||
// set header
|
||||
*((uint16_t*)(packetData)) = frameHeaderNr;
|
||||
++frameHeaderNr;
|
||||
|
||||
// fill data
|
||||
memcpy(packetData + 4, imageData + srcOffset, dataSize);
|
||||
srcOffset += dataSize;
|
||||
|
||||
sendUDPPacket(0, packetData, packetSize);
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs)/ 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closeUDPSocket(0);
|
||||
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
@ -1529,7 +1638,18 @@ void* start_timer(void* arg) {
|
||||
int stopStateMachine(){
|
||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
// read till status is idle
|
||||
int tempStatus = 1;
|
||||
while(tempStatus == 1) {
|
||||
tempStatus = ComVirtual_getStatus();
|
||||
}
|
||||
virtual_stop = 0;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
}
|
||||
return OK;
|
||||
#endif
|
||||
//stop state machine
|
||||
@ -1551,7 +1671,10 @@ int stopStateMachine(){
|
||||
|
||||
enum runStatus getRunStatus(){
|
||||
#ifdef VIRTUAL
|
||||
if(virtual_status == 0){
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
if(virtual_status == 0) {
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
}else{
|
||||
@ -1653,6 +1776,9 @@ void readFrame(int *ret, char *mess){
|
||||
|
||||
u_int32_t runBusy() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
return virtual_status;
|
||||
#endif
|
||||
return runState(logDEBUG1) & STATUS_RN_BSY_MSK;
|
||||
|
@ -12,6 +12,7 @@ add_executable(jungfrauDetectorServer_virtual
|
||||
../slsDetectorServer/src/MAX1932.c
|
||||
../slsDetectorServer/src/programFpgaBlackfin.c
|
||||
../slsDetectorServer/src/communication_funcs_UDP.c
|
||||
../slsDetectorServer/src/communication_virtual.c
|
||||
)
|
||||
|
||||
target_include_directories(jungfrauDetectorServer_virtual
|
||||
|
Binary file not shown.
@ -8,11 +8,13 @@
|
||||
#include "common.h"
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_funcs_UDP.h"
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h> // usleep
|
||||
#include <sys/select.h>
|
||||
#include <netinet/in.h>
|
||||
#ifdef VIRTUAL
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
@ -23,6 +25,11 @@ extern int debugflag;
|
||||
extern udpStruct udpDetails;
|
||||
extern const enum detectorType myDetectorType;
|
||||
|
||||
// Global variable from communication_funcs.c
|
||||
extern int isControlServer;
|
||||
extern void getMacAddressinString(char* cmac, int size, uint64_t mac);
|
||||
extern void getIpAddressinString(char* cip, uint32_t ip);
|
||||
|
||||
int initError = OK;
|
||||
int initCheckDone = 0;
|
||||
char initErrorMessage[MAX_STR_LENGTH];
|
||||
@ -31,6 +38,7 @@ char initErrorMessage[MAX_STR_LENGTH];
|
||||
pthread_t pthread_virtual_tid;
|
||||
int virtual_status = 0;
|
||||
int virtual_stop = 0;
|
||||
int virtual_image_test_mode = 0;
|
||||
#endif
|
||||
|
||||
enum detectorSettings thisSettings = UNINITIALIZED;
|
||||
@ -41,6 +49,7 @@ int detPos[4] = {};
|
||||
int numUDPInterfaces = 1;
|
||||
|
||||
|
||||
|
||||
int isInitCheckDone() {
|
||||
return initCheckDone;
|
||||
}
|
||||
@ -226,6 +235,23 @@ int testBus() {
|
||||
}
|
||||
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void setTestImageMode(int ival) {
|
||||
if (ival >= 0) {
|
||||
if (ival == 0) {
|
||||
LOG(logINFO, ("Switching off Image Test Mode\n"));
|
||||
virtual_image_test_mode = 0;
|
||||
} else {
|
||||
LOG(logINFO, ("Switching on Image Test Mode\n"));
|
||||
virtual_image_test_mode = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int getTestImageMode() {
|
||||
return virtual_image_test_mode;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Ids */
|
||||
@ -349,6 +375,12 @@ void initStopServer() {
|
||||
LOG(logERROR, ("Stop Server: Map Fail. Dangerous to continue. Goodbye!\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -370,6 +402,13 @@ void setupDetector() {
|
||||
clkPhase[i] = 0;
|
||||
}
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
#endif
|
||||
|
||||
ALTERA_PLL_ResetPLL();
|
||||
resetCore();
|
||||
resetPeripheral();
|
||||
@ -521,16 +560,24 @@ int selectStoragecellStart(int pos) {
|
||||
|
||||
int setStartingFrameNumber(uint64_t value) {
|
||||
LOG(logINFO, ("Setting starting frame number: %llu\n",(long long unsigned int)value));
|
||||
#ifdef VIRTUAL
|
||||
setU64BitReg(value, FRAME_NUMBER_LSB_REG, FRAME_NUMBER_MSB_REG);
|
||||
#else
|
||||
// decrement is for firmware
|
||||
setU64BitReg(value - 1, FRAME_NUMBER_LSB_REG, FRAME_NUMBER_MSB_REG);
|
||||
// need to set it twice for the firmware to catch
|
||||
setU64BitReg(value - 1, FRAME_NUMBER_LSB_REG, FRAME_NUMBER_MSB_REG);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getStartingFrameNumber(uint64_t* retval) {
|
||||
#ifdef VIRTUAL
|
||||
*retval = getU64BitReg(FRAME_NUMBER_LSB_REG, FRAME_NUMBER_MSB_REG);
|
||||
#else
|
||||
// increment is for firmware
|
||||
*retval = (getU64BitReg(GET_FRAME_NUMBER_LSB_REG, GET_FRAME_NUMBER_MSB_REG) + 1);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -727,8 +774,9 @@ int getModule(sls_detector_module *myMod){
|
||||
if (dacValues[idac] >= 0)
|
||||
initialized = 1;
|
||||
}
|
||||
if (initialized)
|
||||
if (initialized) {
|
||||
return OK;
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -896,16 +944,10 @@ int getADC(enum ADCINDEX ind){
|
||||
|
||||
|
||||
int setHighVoltage(int val){
|
||||
#ifdef VIRTUAL
|
||||
if (val >= 0)
|
||||
highvoltage = val;
|
||||
return highvoltage;
|
||||
#endif
|
||||
|
||||
// setting hv
|
||||
if (val >= 0) {
|
||||
LOG(logINFO, ("Setting High voltage: %d V", val));
|
||||
MAX1932_Set(val);
|
||||
MAX1932_Set(&val);
|
||||
highvoltage = val;
|
||||
}
|
||||
return highvoltage;
|
||||
@ -1074,73 +1116,57 @@ int configureMAC() {
|
||||
int dstport = udpDetails.dstport;
|
||||
int dstport2 = udpDetails.dstport2;
|
||||
|
||||
#ifdef VIRTUAL
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff);
|
||||
LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, dstport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, dstport) == FAIL) {
|
||||
LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
#endif
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
||||
getMacAddressinString(src_mac, 50, srcmac);
|
||||
getMacAddressinString(dst_mac, 50, dstmac);
|
||||
getIpAddressinString(src_ip, srcip);
|
||||
getIpAddressinString(dst_ip, dstip);
|
||||
char src_mac2[50], src_ip2[INET_ADDRSTRLEN],dst_mac2[50], dst_ip2[INET_ADDRSTRLEN];
|
||||
getMacAddressinString(src_mac2, 50, srcmac2);
|
||||
getMacAddressinString(dst_mac2, 50, dstmac2);
|
||||
getIpAddressinString(src_ip2, srcip2);
|
||||
getIpAddressinString(dst_ip2, dstip2);
|
||||
|
||||
int numInterfaces = getNumberofUDPInterfaces();
|
||||
int selInterface = getPrimaryInterface();
|
||||
LOG(logINFO, ("\t#Interfaces : %d\n", numInterfaces));
|
||||
LOG(logINFO, ("\tInterface : %d %s\n\n", selInterface, (selInterface ? "Inner" : "Outer")));
|
||||
|
||||
LOG(logINFO, ("\tOuter %s\n", (numInterfaces == 2) ? "(Bottom)": (selInterface ? "Not Used" : "Used")));
|
||||
LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(srcip>>24)&0xff,(srcip>>16)&0xff,(srcip>>8)&0xff,(srcip)&0xff, srcip));
|
||||
LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((srcmac>>40)&0xFF),
|
||||
(unsigned int)((srcmac>>32)&0xFF),
|
||||
(unsigned int)((srcmac>>24)&0xFF),
|
||||
(unsigned int)((srcmac>>16)&0xFF),
|
||||
(unsigned int)((srcmac>>8)&0xFF),
|
||||
(unsigned int)((srcmac>>0)&0xFF),
|
||||
(long long unsigned int)srcmac));
|
||||
LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n", srcport, srcport));
|
||||
|
||||
LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff, dstip));
|
||||
LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((dstmac>>40)&0xFF),
|
||||
(unsigned int)((dstmac>>32)&0xFF),
|
||||
(unsigned int)((dstmac>>24)&0xFF),
|
||||
(unsigned int)((dstmac>>16)&0xFF),
|
||||
(unsigned int)((dstmac>>8)&0xFF),
|
||||
(unsigned int)((dstmac>>0)&0xFF),
|
||||
(long long unsigned int)dstmac));
|
||||
LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n\n",dstport, dstport));
|
||||
LOG(logINFO, (
|
||||
"\tSource IP : %s\n"
|
||||
"\tSource MAC : %s\n"
|
||||
"\tSource Port : %d\n"
|
||||
"\tDest IP : %s\n"
|
||||
"\tDest MAC : %s\n"
|
||||
"\tDest Port : %d\n",
|
||||
src_ip, src_mac, srcport,
|
||||
dst_ip, dst_mac, dstport));
|
||||
|
||||
LOG(logINFO, ("\tInner %s\n", (numInterfaces == 2) ? "(Top)": (selInterface ? "Used" : "Not Used")));
|
||||
LOG(logINFO, ("\tSource IP2 : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(srcip2>>24)&0xff,(srcip2>>16)&0xff,(srcip2>>8)&0xff,(srcip2)&0xff, srcip2));
|
||||
LOG(logINFO, ("\tSource MAC2 : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((srcmac2>>40)&0xFF),
|
||||
(unsigned int)((srcmac2>>32)&0xFF),
|
||||
(unsigned int)((srcmac2>>24)&0xFF),
|
||||
(unsigned int)((srcmac2>>16)&0xFF),
|
||||
(unsigned int)((srcmac2>>8)&0xFF),
|
||||
(unsigned int)((srcmac2>>0)&0xFF),
|
||||
(long long unsigned int)srcmac2));
|
||||
LOG(logINFO, ("\tSource Port2: %d \t\t\t(0x%08x)\n", srcport2, srcport2));
|
||||
LOG(logINFO, (
|
||||
"\tSource IP2 : %s\n"
|
||||
"\tSource MAC2 : %s\n"
|
||||
"\tSource Port2: %d\n"
|
||||
"\tDest IP2 : %s\n"
|
||||
"\tDest MAC2 : %s\n"
|
||||
"\tDest Port2 : %d\n",
|
||||
src_ip2, src_mac2, srcport2,
|
||||
dst_ip2, dst_mac2, dstport2));
|
||||
|
||||
LOG(logINFO, ("\tDest. IP2 : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(dstip2>>24)&0xff,(dstip2>>16)&0xff,(dstip2>>8)&0xff,(dstip2)&0xff, dstip2));
|
||||
LOG(logINFO, ("\tDest. MAC2 : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((dstmac2>>40)&0xFF),
|
||||
(unsigned int)((dstmac2>>32)&0xFF),
|
||||
(unsigned int)((dstmac2>>24)&0xFF),
|
||||
(unsigned int)((dstmac2>>16)&0xFF),
|
||||
(unsigned int)((dstmac2>>8)&0xFF),
|
||||
(unsigned int)((dstmac2>>0)&0xFF),
|
||||
(long long unsigned int)dstmac2));
|
||||
LOG(logINFO, ("\tDest. Port2 : %d \t\t\t(0x%08x)\n", dstport2, dstport2));
|
||||
|
||||
#ifdef VIRTUAL
|
||||
if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) {
|
||||
LOG(logERROR, ("could not set udp destination IP and port for interface 1\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if (numInterfaces == 2 && setUDPDestinationDetails(1, dst_ip2, dstport2) == FAIL) {
|
||||
LOG(logERROR, ("could not set udp destination IP and port for interface 2\n"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
#endif
|
||||
// default one rxr entry (others not yet implemented in client yet)
|
||||
int iRxEntry = 0;
|
||||
|
||||
@ -1281,7 +1307,9 @@ int powerChip (int on){
|
||||
bus_w(CHIP_POWER_REG, bus_r(CHIP_POWER_REG) & ~CHIP_POWER_ENABLE_MSK);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VIRTUAL
|
||||
return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_ENABLE_MSK) >> CHIP_POWER_ENABLE_OFST);
|
||||
#endif
|
||||
return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_STATUS_MSK) >> CHIP_POWER_STATUS_OFST);
|
||||
}
|
||||
|
||||
@ -1615,12 +1643,26 @@ int startStateMachine(){
|
||||
if(createUDPSocket(0) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
if (getNumberofUDPInterfaces() == 2 && createUDPSocket(1) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("starting state machine\n"));
|
||||
virtual_status = 1;
|
||||
virtual_stop = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
if (virtual_stop != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
if(pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||
@ -1641,85 +1683,127 @@ int startStateMachine(){
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void* start_timer(void* arg) {
|
||||
int64_t periodns = getPeriod();
|
||||
if (!isControlServer) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int numInterfaces = getNumberofUDPInterfaces();
|
||||
int64_t periodNs = getPeriod();
|
||||
int numFrames = (getNumFrames() *
|
||||
getNumTriggers() *
|
||||
(getNumAdditionalStorageCells() + 1));
|
||||
int64_t exp_us = getExpTime() / 1000;
|
||||
int64_t expUs = getExpTime() / 1000;
|
||||
const int npixels = 256 * 256 * 8;
|
||||
const int dataSize = 8192;
|
||||
const int packetsize = dataSize + sizeof(sls_detector_header);
|
||||
const int packetsPerFrame = numInterfaces == 1 ? 128 : 64;
|
||||
int transmissionDelayUs = getTransmissionDelayFrame() * 1000;
|
||||
|
||||
//TODO: Generate data
|
||||
char imageData[DATA_BYTES];
|
||||
memset(imageData, 0, DATA_BYTES);
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < DATA_BYTES; i += sizeof(uint16_t)) {
|
||||
*((uint16_t*)(imageData + i)) = i;
|
||||
}
|
||||
// Generate data
|
||||
char imageData[DATA_BYTES];
|
||||
memset(imageData, 0, DATA_BYTES);
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < npixels; ++i) {
|
||||
// avoiding gain also being divided when gappixels enabled in call back
|
||||
*((uint16_t*)(imageData + i * sizeof(uint16_t))) = virtual_image_test_mode ? 0x0FFE : (uint16_t)i;
|
||||
}
|
||||
int datasize = 8192;
|
||||
|
||||
|
||||
//TODO: Send data
|
||||
{
|
||||
int frameNr = 0;
|
||||
for(frameNr=0; frameNr!= numFrames; ++frameNr ) {
|
||||
}
|
||||
|
||||
|
||||
// Send data
|
||||
{
|
||||
uint64_t frameNr = 0;
|
||||
getStartingFrameNumber(&frameNr);
|
||||
int iframes = 0;
|
||||
for(iframes = 0; iframes != numFrames; ++iframes ) {
|
||||
|
||||
//check if virtual_stop is high
|
||||
if(virtual_stop == 1){
|
||||
break;
|
||||
}
|
||||
usleep(transmissionDelayUs);
|
||||
|
||||
int srcOffset = 0;
|
||||
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
// update the virtual stop from stop server
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
//check if virtual_stop is high
|
||||
if(virtual_stop == 1){
|
||||
setStartingFrameNumber(frameNr + iframes + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
usleep(exp_us);
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expUs);
|
||||
|
||||
const int size = datasize + sizeof(sls_detector_header);
|
||||
char packetData[size];
|
||||
memset(packetData, 0, sizeof(sls_detector_header));
|
||||
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for(i=0; i!=128; ++i) {
|
||||
// set header
|
||||
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||
int srcOffset = 0;
|
||||
int srcOffset2 = DATA_BYTES / 2;
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 0; i != packetsPerFrame; ++i) {
|
||||
// set header
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameNr + iframes;
|
||||
header->packetNumber = i;
|
||||
header->modId = 0;
|
||||
header->row = detPos[2];
|
||||
header->column = detPos[3];
|
||||
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header),
|
||||
imageData + srcOffset, dataSize);
|
||||
srcOffset += dataSize;
|
||||
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
|
||||
// second interface
|
||||
char packetData2[packetsize];
|
||||
memset(packetData2, 0, packetsize);
|
||||
if (numInterfaces == 2) {
|
||||
header = (sls_detector_header*)(packetData2);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameNr;
|
||||
header->packetNumber = i;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
header->column = detPos[Y];
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->row = detPos[0];
|
||||
header->column = detPos[1];
|
||||
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header), imageData + srcOffset, datasize);
|
||||
srcOffset += datasize;
|
||||
memcpy(packetData2 + sizeof(sls_detector_header),
|
||||
imageData + srcOffset2, dataSize);
|
||||
srcOffset2 += dataSize;
|
||||
|
||||
sendUDPPacket(0, packetData, size);
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodns > time_ns) {
|
||||
usleep((periodns - time_ns)/ 1000);
|
||||
sendUDPPacket(1, packetData2, packetsize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// }
|
||||
|
||||
LOG(logINFO, ("Sent frame: %d\n", iframes));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
// sleep for (period - exptime)
|
||||
if (iframes < numFrames) { // if there is a next frame
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs)/ 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
setStartingFrameNumber(frameNr + numFrames);
|
||||
}
|
||||
|
||||
closeUDPSocket(0);
|
||||
if (numInterfaces == 2) {
|
||||
closeUDPSocket(1);
|
||||
}
|
||||
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
@ -1728,7 +1812,18 @@ void* start_timer(void* arg) {
|
||||
int stopStateMachine(){
|
||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
// read till status is idle
|
||||
int tempStatus = 1;
|
||||
while(tempStatus == 1) {
|
||||
tempStatus = ComVirtual_getStatus();
|
||||
}
|
||||
virtual_stop = 0;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
}
|
||||
return OK;
|
||||
#endif
|
||||
//stop state machine
|
||||
@ -1746,7 +1841,10 @@ int stopStateMachine(){
|
||||
|
||||
enum runStatus getRunStatus(){
|
||||
#ifdef VIRTUAL
|
||||
if(virtual_status == 0){
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
if(virtual_status == 0) {
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
}else{
|
||||
@ -1820,6 +1918,9 @@ void readFrame(int *ret, char *mess){
|
||||
|
||||
u_int32_t runBusy() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
return virtual_status;
|
||||
#endif
|
||||
u_int32_t s = (bus_r(STATUS_REG) & RUN_BUSY_MSK);
|
||||
|
@ -14,6 +14,7 @@ add_executable(moenchDetectorServer_virtual
|
||||
../slsDetectorServer/src/MAX1932.c
|
||||
../slsDetectorServer/src/programFpgaBlackfin.c
|
||||
../slsDetectorServer/src/readDefaultPattern.c
|
||||
../slsDetectorServer/src/communication_virtual.c
|
||||
)
|
||||
|
||||
include_directories(
|
||||
@ -31,6 +32,7 @@ target_compile_definitions(moenchDetectorServer_virtual
|
||||
|
||||
target_link_libraries(moenchDetectorServer_virtual
|
||||
PUBLIC pthread rt slsProjectCWarnings
|
||||
m
|
||||
)
|
||||
|
||||
set_target_properties(moenchDetectorServer_virtual PROPERTIES
|
||||
|
Binary file not shown.
@ -8,22 +8,33 @@
|
||||
#include "MAX1932.h" // hv
|
||||
#include "ALTERA_PLL.h" // pll
|
||||
#include "common.h"
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h> // usleep
|
||||
#include <netinet/in.h>
|
||||
#ifdef VIRTUAL
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
#include <math.h> //ceil
|
||||
#endif
|
||||
|
||||
// Global variable from slsDetectorServer_funcs
|
||||
extern int debugflag;
|
||||
extern udpStruct udpDetails;
|
||||
extern const enum detectorType myDetectorType;
|
||||
|
||||
// Global variable from UDPPacketHeaderGenerator
|
||||
extern uint64_t udpFrameNumber;
|
||||
extern uint32_t udpPacketNumber;
|
||||
|
||||
// Global variable from communication_funcs.c
|
||||
extern int isControlServer;
|
||||
extern void getMacAddressinString(char* cmac, int size, uint64_t mac);
|
||||
extern void getIpAddressinString(char* cip, uint32_t ip);
|
||||
|
||||
int initError = OK;
|
||||
int initCheckDone = 0;
|
||||
char initErrorMessage[MAX_STR_LENGTH];
|
||||
@ -415,6 +426,12 @@ void initStopServer() {
|
||||
LOG(logERROR, ("Stop Server: Map Fail. Dangerous to continue. Goodbye!\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -467,6 +484,12 @@ void setupDetector() {
|
||||
adcEnableMask_1g = 0;
|
||||
adcEnableMask_10g = 0;
|
||||
nSamples = 1;
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
#endif
|
||||
|
||||
ALTERA_PLL_ResetPLLAndReconfiguration();
|
||||
resetCore();
|
||||
@ -969,8 +992,9 @@ enum detectorSettings getSettings() {
|
||||
|
||||
|
||||
void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
if (val < 0 && val != LTC2620_GetPowerDownValue())
|
||||
if (val < 0 && val != LTC2620_GetPowerDownValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
char* dac_names[] = {DAC_NAMES};
|
||||
LOG(logINFO, ("Setting DAC %s\n", dac_names[ind]));
|
||||
@ -1041,12 +1065,6 @@ void setVLimit(int l) {
|
||||
|
||||
|
||||
int setHighVoltage(int val){
|
||||
#ifdef VIRTUAL
|
||||
if (val >= 0)
|
||||
highvoltage = val;
|
||||
return highvoltage;
|
||||
#endif
|
||||
|
||||
// setting hv
|
||||
if (val >= 0) {
|
||||
LOG(logINFO, ("Setting High voltage: %d V\n", val));
|
||||
@ -1055,7 +1073,7 @@ int setHighVoltage(int val){
|
||||
// switch to external high voltage
|
||||
bus_w(addr, bus_r(addr) & (~POWER_HV_INTERNAL_SLCT_MSK));
|
||||
|
||||
MAX1932_Set(val);
|
||||
MAX1932_Set(&val);
|
||||
|
||||
// switch on internal high voltage, if set
|
||||
if (val > 0)
|
||||
@ -1135,26 +1153,36 @@ void calcChecksum(udp_header* udp) {
|
||||
|
||||
|
||||
int configureMAC(){
|
||||
uint32_t sourceip = udpDetails.srcip;
|
||||
uint32_t destip = udpDetails.dstip;
|
||||
uint64_t sourcemac = udpDetails.srcmac;
|
||||
uint64_t destmac = udpDetails.dstmac;
|
||||
int sourceport = udpDetails.srcport;
|
||||
int destport = udpDetails.dstport;
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
uint32_t srcip = udpDetails.srcip;
|
||||
uint32_t dstip = udpDetails.dstip;
|
||||
uint64_t srcmac = udpDetails.srcmac;
|
||||
uint64_t dstmac = udpDetails.dstmac;
|
||||
int srcport = udpDetails.srcport;
|
||||
int dstport = udpDetails.dstport;
|
||||
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
||||
getMacAddressinString(src_mac, 50, srcmac);
|
||||
getMacAddressinString(dst_mac, 50, dstmac);
|
||||
getIpAddressinString(src_ip, srcip);
|
||||
getIpAddressinString(dst_ip, dstip);
|
||||
|
||||
LOG(logINFO, (
|
||||
"\tSource IP : %s\n"
|
||||
"\tSource MAC : %s\n"
|
||||
"\tSource Port : %d\n"
|
||||
"\tDest IP : %s\n"
|
||||
"\tDest MAC : %s\n"
|
||||
"\tDest Port : %d\n",
|
||||
src_ip, src_mac, srcport,
|
||||
dst_ip, dst_mac, dstport));
|
||||
|
||||
// 1 giga udp
|
||||
if (!enableTenGigabitEthernet(-1)) {
|
||||
LOG(logINFOBLUE, ("Configuring 1G MAC\n"));
|
||||
LOG(logINFOBLUE, ("\t1G MAC\n"));
|
||||
if (updateDatabytesandAllocateRAM() == FAIL)
|
||||
return -1;
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
|
||||
LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, destport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, destport) == FAIL) {
|
||||
if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) {
|
||||
LOG(logERROR, ("could not set udp 1G destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
@ -1162,31 +1190,7 @@ int configureMAC(){
|
||||
}
|
||||
|
||||
// 10 G
|
||||
LOG(logINFOBLUE, ("Configuring 10G MAC\n"));
|
||||
|
||||
LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(sourceip>>24)&0xff,(sourceip>>16)&0xff,(sourceip>>8)&0xff,(sourceip)&0xff, sourceip));
|
||||
LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((sourcemac>>40)&0xFF),
|
||||
(unsigned int)((sourcemac>>32)&0xFF),
|
||||
(unsigned int)((sourcemac>>24)&0xFF),
|
||||
(unsigned int)((sourcemac>>16)&0xFF),
|
||||
(unsigned int)((sourcemac>>8)&0xFF),
|
||||
(unsigned int)((sourcemac>>0)&0xFF),
|
||||
(long long unsigned int)sourcemac));
|
||||
LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n",sourceport, sourceport));
|
||||
|
||||
LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff, destip));
|
||||
LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((destmac>>40)&0xFF),
|
||||
(unsigned int)((destmac>>32)&0xFF),
|
||||
(unsigned int)((destmac>>24)&0xFF),
|
||||
(unsigned int)((destmac>>16)&0xFF),
|
||||
(unsigned int)((destmac>>8)&0xFF),
|
||||
(unsigned int)((destmac>>0)&0xFF),
|
||||
(long long unsigned int)destmac));
|
||||
LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n",destport, destport));
|
||||
LOG(logINFOBLUE, ("\t10G MAC\n"));
|
||||
|
||||
// start addr
|
||||
uint32_t addr = RXR_ENDPOINT_START_REG;
|
||||
@ -1196,21 +1200,21 @@ int configureMAC(){
|
||||
|
||||
// mac addresses
|
||||
// msb (32) + lsb (16)
|
||||
udp->udp_destmac_msb = ((destmac >> 16) & BIT32_MASK);
|
||||
udp->udp_destmac_lsb = ((destmac >> 0) & BIT16_MASK);
|
||||
udp->udp_destmac_msb = ((dstmac >> 16) & BIT32_MASK);
|
||||
udp->udp_destmac_lsb = ((dstmac >> 0) & BIT16_MASK);
|
||||
// msb (16) + lsb (32)
|
||||
udp->udp_srcmac_msb = ((sourcemac >> 32) & BIT16_MASK);
|
||||
udp->udp_srcmac_lsb = ((sourcemac >> 0) & BIT32_MASK);
|
||||
udp->udp_srcmac_msb = ((srcmac >> 32) & BIT16_MASK);
|
||||
udp->udp_srcmac_lsb = ((srcmac >> 0) & BIT32_MASK);
|
||||
|
||||
// ip addresses
|
||||
udp->ip_srcip_msb = ((sourceip >> 16) & BIT16_MASK);
|
||||
udp->ip_srcip_lsb = ((sourceip >> 0) & BIT16_MASK);
|
||||
udp->ip_destip_msb = ((destip >> 16) & BIT16_MASK);
|
||||
udp->ip_destip_lsb = ((destip >> 0) & BIT16_MASK);
|
||||
udp->ip_srcip_msb = ((srcip >> 16) & BIT16_MASK);
|
||||
udp->ip_srcip_lsb = ((srcip >> 0) & BIT16_MASK);
|
||||
udp->ip_destip_msb = ((dstip >> 16) & BIT16_MASK);
|
||||
udp->ip_destip_lsb = ((dstip >> 0) & BIT16_MASK);
|
||||
|
||||
// source port
|
||||
udp->udp_srcport = sourceport;
|
||||
udp->udp_destport = destport;
|
||||
udp->udp_srcport = srcport;
|
||||
udp->udp_destport = dstport;
|
||||
|
||||
// other defines
|
||||
udp->udp_ethertype = 0x800;
|
||||
@ -1241,6 +1245,9 @@ int* getDetectorPosition() {
|
||||
}
|
||||
|
||||
int enableTenGigabitEthernet(int val) {
|
||||
#ifdef VIRTUAL
|
||||
return 0;
|
||||
#endif
|
||||
uint32_t addr = CONFIG_REG;
|
||||
|
||||
// set
|
||||
@ -1818,11 +1825,27 @@ uint64_t getPatternBitMask() {
|
||||
|
||||
int startStateMachine(){
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 1;
|
||||
virtual_stop = 0;
|
||||
// create udp socket
|
||||
if(createUDPSocket(0) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
virtual_status = 1;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
if (virtual_stop != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
if(pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
virtual_status = 0;
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||
@ -1856,42 +1879,92 @@ int startStateMachine(){
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void* start_timer(void* arg) {
|
||||
int64_t periodns = getPeriod();
|
||||
if (!isControlServer) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int64_t periodNs = getPeriod();
|
||||
int numFrames = (getNumFrames() *
|
||||
getNumTriggers() );
|
||||
int64_t exp_ns = getExpTime();
|
||||
int64_t expNs = getExpTime();
|
||||
|
||||
int frameNr = 0;
|
||||
// loop over number of frames
|
||||
for(frameNr=0; frameNr!= numFrames; ++frameNr ) {
|
||||
int imageSize = dataBytes;
|
||||
int dataSize = UDP_PACKET_DATA_BYTES;
|
||||
int packetSize = sizeof(sls_detector_header) + dataSize;
|
||||
int packetsPerFrame = ceil((double)imageSize / (double)dataSize);
|
||||
|
||||
//check if virtual_stop is high
|
||||
if(virtual_stop == 1){
|
||||
break;
|
||||
}
|
||||
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(exp_ns / 1000);
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
|
||||
// calculate time left in period
|
||||
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodns > time_ns) {
|
||||
usleep((periodns - time_ns)/ 1000);
|
||||
}
|
||||
}
|
||||
|
||||
// set register frames left
|
||||
// Generate Data
|
||||
char imageData[imageSize];
|
||||
memset(imageData, 0, imageSize);
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < imageSize; i += sizeof(uint16_t)) {
|
||||
*((uint16_t*)(imageData + i)) = i;
|
||||
}
|
||||
}
|
||||
|
||||
// set status to idle
|
||||
// Send data
|
||||
{
|
||||
int frameNr = 0;
|
||||
// loop over number of frames
|
||||
for(frameNr = 0; frameNr != numFrames; ++frameNr ) {
|
||||
|
||||
// update the virtual stop from stop server
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
//check if virtual_stop is high
|
||||
if(virtual_stop == 1){
|
||||
break;
|
||||
}
|
||||
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expNs / 1000);
|
||||
|
||||
int srcOffset = 0;
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 0; i != packetsPerFrame; ++i) {
|
||||
// set header
|
||||
char packetData[packetSize];
|
||||
memset(packetData, 0, packetSize);
|
||||
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameNr;
|
||||
header->packetNumber = i;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
header->column = detPos[Y];
|
||||
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header), imageData + srcOffset, dataSize);
|
||||
srcOffset += dataSize;
|
||||
|
||||
sendUDPPacket(0, packetData, packetSize);
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs)/ 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closeUDPSocket(0);
|
||||
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
@ -1900,7 +1973,18 @@ void* start_timer(void* arg) {
|
||||
int stopStateMachine(){
|
||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
// read till status is idle
|
||||
int tempStatus = 1;
|
||||
while(tempStatus == 1) {
|
||||
tempStatus = ComVirtual_getStatus();
|
||||
}
|
||||
virtual_stop = 0;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
}
|
||||
return OK;
|
||||
#endif
|
||||
//stop state machine
|
||||
@ -1919,7 +2003,10 @@ int stopStateMachine(){
|
||||
|
||||
enum runStatus getRunStatus(){
|
||||
#ifdef VIRTUAL
|
||||
if(virtual_status == 0){
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
if(virtual_status == 0) {
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
}else{
|
||||
@ -2154,6 +2241,9 @@ int readFrameFromFifo() {
|
||||
|
||||
uint32_t runBusy() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
return virtual_status;
|
||||
#endif
|
||||
uint32_t s = (bus_r(STATUS_REG) & STATUS_RN_BSY_MSK);
|
||||
|
@ -10,6 +10,7 @@ add_executable(mythen3DetectorServer_virtual
|
||||
../slsDetectorServer/src/LTC2620_Driver.c
|
||||
../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c
|
||||
../slsDetectorServer/src/programFpgaNios.c
|
||||
../slsDetectorServer/src/communication_virtual.c
|
||||
)
|
||||
|
||||
include_directories(
|
||||
|
Binary file not shown.
@ -8,10 +8,12 @@
|
||||
#include "ALTERA_PLL_CYCLONE10.h"
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_funcs_UDP.h"
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h> // usleep
|
||||
#include <netinet/in.h>
|
||||
#ifdef VIRTUAL
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
@ -22,6 +24,11 @@ extern int debugflag;
|
||||
extern udpStruct udpDetails;
|
||||
extern const enum detectorType myDetectorType;
|
||||
|
||||
// Global variable from communication_funcs.c
|
||||
extern int isControlServer;
|
||||
extern void getMacAddressinString(char* cmac, int size, uint64_t mac);
|
||||
extern void getIpAddressinString(char* cip, uint32_t ip);
|
||||
|
||||
int initError = OK;
|
||||
int initCheckDone = 0;
|
||||
char initErrorMessage[MAX_STR_LENGTH];
|
||||
@ -319,6 +326,12 @@ void initStopServer() {
|
||||
LOG(logERROR, ("Stop Server: Map Fail. Dangerous to continue. Goodbye!\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -343,8 +356,13 @@ void setupDetector() {
|
||||
dacValues[i] = 0;
|
||||
}
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef VIRTUAL
|
||||
// pll defines
|
||||
ALTERA_PLL_C10_SetDefines(REG_OFFSET, BASE_READOUT_PLL, BASE_SYSTEM_PLL, PLL_RESET_REG, PLL_RESET_REG, PLL_RESET_READOUT_MSK, PLL_RESET_SYSTEM_MSK, READOUT_PLL_VCO_FREQ_HZ, SYSTEM_PLL_VCO_FREQ_HZ);
|
||||
ALTERA_PLL_C10_ResetPLL(READOUT_PLL);
|
||||
@ -353,7 +371,6 @@ void setupDetector() {
|
||||
DAC6571_SetDefines(HV_HARD_MAX_VOLTAGE, HV_DRIVER_FILE_NAME);
|
||||
//dac
|
||||
LTC2620_D_SetDefines(DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC);
|
||||
#endif
|
||||
|
||||
resetCore();
|
||||
resetPeripheral();
|
||||
@ -738,41 +755,29 @@ int configureMAC() {
|
||||
int srcport = udpDetails.srcport;
|
||||
int dstport = udpDetails.dstport;
|
||||
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
||||
getMacAddressinString(src_mac, 50, srcmac);
|
||||
getMacAddressinString(dst_mac, 50, dstmac);
|
||||
getIpAddressinString(src_ip, srcip);
|
||||
getIpAddressinString(dst_ip, dstip);
|
||||
|
||||
LOG(logINFO, (
|
||||
"\tSource IP : %s\n"
|
||||
"\tSource MAC : %s\n"
|
||||
"\tSource Port : %d\n"
|
||||
"\tDest IP : %s\n"
|
||||
"\tDest MAC : %s\n"
|
||||
"\tDest Port : %d\n",
|
||||
src_ip, src_mac, srcport,
|
||||
dst_ip, dst_mac, dstport));
|
||||
|
||||
#ifdef VIRTUAL
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff);
|
||||
LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, dstport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, dstport) == FAIL) {
|
||||
if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) {
|
||||
LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
|
||||
LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(srcip>>24)&0xff,(srcip>>16)&0xff,(srcip>>8)&0xff,(srcip)&0xff, srcip));
|
||||
LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((srcmac>>40)&0xFF),
|
||||
(unsigned int)((srcmac>>32)&0xFF),
|
||||
(unsigned int)((srcmac>>24)&0xFF),
|
||||
(unsigned int)((srcmac>>16)&0xFF),
|
||||
(unsigned int)((srcmac>>8)&0xFF),
|
||||
(unsigned int)((srcmac>>0)&0xFF),
|
||||
(long long unsigned int)srcmac));
|
||||
LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n", srcport, srcport));
|
||||
|
||||
LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff, dstip));
|
||||
LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((dstmac>>40)&0xFF),
|
||||
(unsigned int)((dstmac>>32)&0xFF),
|
||||
(unsigned int)((dstmac>>24)&0xFF),
|
||||
(unsigned int)((dstmac>>16)&0xFF),
|
||||
(unsigned int)((dstmac>>8)&0xFF),
|
||||
(unsigned int)((dstmac>>0)&0xFF),
|
||||
(long long unsigned int)dstmac));
|
||||
LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n\n",dstport, dstport));
|
||||
|
||||
// start addr
|
||||
uint32_t addr = BASE_UDP_RAM;
|
||||
@ -1121,6 +1126,9 @@ uint64_t getPatternBitMask() {
|
||||
}
|
||||
|
||||
int checkDetectorType() {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
LOG(logINFO, ("Checking type of module\n"));
|
||||
FILE* fd = fopen(TYPE_FILE_NAME, "r");
|
||||
if (fd == NULL) {
|
||||
@ -1354,13 +1362,24 @@ int startStateMachine(){
|
||||
if(createUDPSocket(0) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("starting state machine\n"));
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
// set status to running
|
||||
virtual_status = 1;
|
||||
virtual_stop = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
if (virtual_stop != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
if(pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||
@ -1381,14 +1400,19 @@ int startStateMachine(){
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void* start_timer(void* arg) {
|
||||
int64_t periodns = getPeriod();
|
||||
if (!isControlServer) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int64_t periodNs = getPeriod();
|
||||
int numFrames = (getNumFrames() *
|
||||
getNumTriggers() );
|
||||
int64_t exp_ns = getExpTime();
|
||||
int64_t expUs = getExpTime() / 1000;
|
||||
|
||||
//int dr = setDynamicRange(-1);
|
||||
int imagesize = calculateDataBytes();
|
||||
int datasize = imagesize / PACKETS_PER_FRAME;
|
||||
int packetsize = datasize + sizeof(sls_detector_header);
|
||||
int dataSize = imagesize / PACKETS_PER_FRAME;
|
||||
int packetSize = dataSize + sizeof(sls_detector_header);
|
||||
|
||||
// Generate data
|
||||
char imageData[imagesize];
|
||||
@ -1400,66 +1424,71 @@ void* start_timer(void* arg) {
|
||||
}
|
||||
}
|
||||
|
||||
int frameNr = 1;
|
||||
// loop over number of frames
|
||||
for (frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||
// Send data
|
||||
{
|
||||
int frameNr = 1;
|
||||
// loop over number of frames
|
||||
for (frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||
|
||||
//check if virtual_stop is high
|
||||
if(virtual_stop == 1){
|
||||
break;
|
||||
}
|
||||
|
||||
int srcOffset = 0;
|
||||
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(exp_ns / 1000);
|
||||
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 0; i!=PACKETS_PER_FRAME; ++i) {
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
|
||||
// set header
|
||||
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||
header->frameNumber = frameNr + 1;
|
||||
header->packetNumber = i;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
header->column = detPos[Y];
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header), imageData + srcOffset, datasize);
|
||||
srcOffset += datasize;
|
||||
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
// update the virtual stop from stop server
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
//check if virtual_stop is high
|
||||
if(virtual_stop == 1){
|
||||
break;
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
|
||||
// calculate time left in period
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodns > time_ns) {
|
||||
usleep((periodns - time_ns)/ 1000);
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expUs);
|
||||
|
||||
int srcOffset = 0;
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 0; i != PACKETS_PER_FRAME; ++i) {
|
||||
char packetData[packetSize];
|
||||
memset(packetData, 0, packetSize);
|
||||
|
||||
// set header
|
||||
sls_detector_header* header = (sls_detector_header*) (packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameNr + 1;
|
||||
header->packetNumber = i;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
header->column = detPos[Y];
|
||||
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header),
|
||||
imageData + srcOffset, dataSize);
|
||||
srcOffset += dataSize;
|
||||
|
||||
sendUDPPacket(0, packetData, packetSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
// set register frames left
|
||||
}
|
||||
// sleep for (period - exptime)
|
||||
if (frameNr < numFrames) { // if there is a next frame
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs)/ 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closeUDPSocket(0);
|
||||
// set status to idle
|
||||
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
@ -1469,7 +1498,18 @@ void* start_timer(void* arg) {
|
||||
int stopStateMachine(){
|
||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
// read till status is idle
|
||||
int tempStatus = 1;
|
||||
while(tempStatus == 1) {
|
||||
tempStatus = ComVirtual_getStatus();
|
||||
}
|
||||
virtual_stop = 0;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
}
|
||||
return OK;
|
||||
#endif
|
||||
//stop state machine
|
||||
@ -1480,10 +1520,13 @@ int stopStateMachine(){
|
||||
|
||||
enum runStatus getRunStatus(){
|
||||
#ifdef VIRTUAL
|
||||
if(virtual_status == 0){
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
if(virtual_status == 0) {
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
}else{
|
||||
} else{
|
||||
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
@ -1555,6 +1598,9 @@ void readFrame(int *ret, char *mess) {
|
||||
|
||||
u_int32_t runBusy() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
return virtual_status;
|
||||
#endif
|
||||
u_int32_t s = (bus_r(PAT_STATUS_REG) & PAT_STATUS_RUN_BUSY_MSK);
|
||||
|
@ -21,11 +21,11 @@ void MAX1932_SetDefines(uint32_t reg, uint32_t cmsk, uint32_t clkmsk, uint32_t d
|
||||
void MAX1932_Disable();
|
||||
|
||||
/**
|
||||
* Set value
|
||||
* @param val value to set
|
||||
* Set value (value is updated to correct range)
|
||||
* @param val pointer to value to set
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int MAX1932_Set (int val) ;
|
||||
int MAX1932_Set (int* val) ;
|
||||
|
||||
|
||||
|
||||
|
@ -11,6 +11,13 @@ typedef enum{
|
||||
OTHER
|
||||
}intType;
|
||||
|
||||
// communciate with stop server
|
||||
#ifdef VIRTUAL
|
||||
#define FILE_STATUS "/tmp/Sls_virtual_server_status_"
|
||||
#define FILE_STOP "/tmp/Sls_virtual_server_stop_"
|
||||
#define FD_STATUS 0
|
||||
#define FD_STOP 1
|
||||
#endif
|
||||
|
||||
int bindSocket(unsigned short int port_number);
|
||||
int acceptConnection(int socketDescriptor);
|
||||
@ -45,12 +52,11 @@ int Server_VerifyLock();
|
||||
* Server sends result to client (also set ret to force_update if different clients)
|
||||
* @param fileDes file descriptor for the socket
|
||||
* @param itype 32 or 64 or others to determine to swap data from big endian to little endian
|
||||
* @param update 1 if one must update if different clients, else 0
|
||||
* @param retval pointer to result
|
||||
* @param retvalSize size of result
|
||||
* @returns result of operation
|
||||
*/
|
||||
int Server_SendResult(int fileDes, intType itype, int update, void* retval, int retvalSize);
|
||||
int Server_SendResult(int fileDes, intType itype, void* retval, int retvalSize);
|
||||
|
||||
/**
|
||||
* Convert mac address from integer to char array
|
||||
|
14
slsDetectorServers/slsDetectorServer/include/communication_virtual.h
Executable file
14
slsDetectorServers/slsDetectorServer/include/communication_virtual.h
Executable file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#ifdef VIRTUAL
|
||||
// communciate between control and stop server
|
||||
|
||||
int ComVirtual_createFiles(const int port);
|
||||
void ComVirtual_setFileNames(const int port);
|
||||
void ComVirtual_setStatus(int value);
|
||||
int ComVirtual_getStatus();
|
||||
void ComVirtual_setStop(int value);
|
||||
int ComVirtual_getStop();
|
||||
int ComVirtual_writeToFile(int value, const char* fname, const char* serverName);
|
||||
int ComVirtual_readFromFile(int* value, const char* fname, const char* serverName);
|
||||
|
||||
#endif
|
@ -61,7 +61,7 @@ int testFpga();
|
||||
int testBus();
|
||||
#endif
|
||||
|
||||
#ifdef GOTTHARDD
|
||||
#if defined(GOTTHARDD) || ((defined(EIGERD) || defined(JUNGFRAUD)) && defined(VIRTUAL))
|
||||
void setTestImageMode(int ival);
|
||||
int getTestImageMode();
|
||||
#endif
|
||||
@ -206,8 +206,8 @@ int64_t getBurstPeriod();
|
||||
#ifdef EIGERD
|
||||
int setSubExpTime(int64_t val);
|
||||
int64_t getSubExpTime();
|
||||
int setDeadTime(int64_t val);
|
||||
int64_t getDeadTime();
|
||||
int setSubDeadTime(int64_t val);
|
||||
int64_t getSubDeadTime();
|
||||
int64_t getMeasuredPeriod();
|
||||
int64_t getMeasuredSubPeriod();
|
||||
#endif
|
||||
@ -413,7 +413,9 @@ int setCounterBit(int val);
|
||||
int pulsePixel(int n, int x, int y);
|
||||
int pulsePixelNMove(int n, int x, int y);
|
||||
int pulseChip(int n);
|
||||
int64_t setRateCorrection(int64_t custom_tau_in_nsec);
|
||||
int updateRateCorrection(char* mess);
|
||||
int validateAndSetRateCorrection(int64_t tau_ns, char* mess);
|
||||
int setRateCorrection(int64_t custom_tau_in_nsec);
|
||||
int getRateCorrectionEnable();
|
||||
int getDefaultSettingsTau_in_nsec();
|
||||
void setDefaultSettingsTau_in_nsec(int t);
|
||||
|
@ -88,8 +88,6 @@ int exit_server(int);
|
||||
int lock_server(int);
|
||||
int get_last_client_ip(int);
|
||||
int set_port(int);
|
||||
int update_client(int);
|
||||
int send_update(int);
|
||||
int calibrate_pedestal(int);
|
||||
int enable_ten_giga(int);
|
||||
int set_all_trimbits(int);
|
||||
@ -217,3 +215,6 @@ int set_current_source(int);
|
||||
int get_timing_source(int);
|
||||
int set_timing_source(int);
|
||||
int get_num_channels(int);
|
||||
int update_rate_correction(int);
|
||||
int get_receiver_parameters(int);
|
||||
|
||||
|
@ -26,8 +26,12 @@ void ASIC_Driver_SetDefines(char* driverfname) {
|
||||
}
|
||||
|
||||
int ASIC_Driver_Set (int index, int length, char* buffer) {
|
||||
char temp[20];
|
||||
memset(temp, 0, sizeof(temp));
|
||||
sprintf(temp, "%d", index + 1);
|
||||
char fname[MAX_STR_LENGTH];
|
||||
sprintf(fname, "%s%d", ASIC_Driver_DriverFileName, index + 1);
|
||||
strcpy(fname, ASIC_Driver_DriverFileName);
|
||||
strcat(fname, temp);
|
||||
LOG(logDEBUG2, ("\t[chip index: %d, length: %d, fname: %s]\n", index, length, fname));
|
||||
{
|
||||
LOG(logDEBUG2, ("\t[values: \n"));
|
||||
@ -38,9 +42,7 @@ int ASIC_Driver_Set (int index, int length, char* buffer) {
|
||||
LOG(logDEBUG2, ("\t]\n"));
|
||||
}
|
||||
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
#ifndef VIRTUAL
|
||||
int fd=open(fname, O_RDWR);
|
||||
if (fd == -1) {
|
||||
LOG(logERROR, ("Could not open file %s for writing to control ASIC (%d)\n", fname, index));
|
||||
@ -62,6 +64,7 @@ int ASIC_Driver_Set (int index, int length, char* buffer) {
|
||||
return FAIL;
|
||||
}
|
||||
close(fd);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ int DAC6571_Set (int val) {
|
||||
|
||||
LOG(logINFO, ("\t%dV (dacval %d)\n", val, dacvalue));
|
||||
|
||||
#ifndef VIRTUAL
|
||||
//open file
|
||||
FILE* fd=fopen(DAC6571_DriverFileName,"w");
|
||||
if (fd==NULL) {
|
||||
@ -45,6 +46,7 @@ int DAC6571_Set (int val) {
|
||||
//convert to string, add 0 and write to file
|
||||
fprintf(fd, "%d\n", dacvalue);
|
||||
fclose(fd);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -72,8 +72,14 @@ int LTC2620_D_SetDACValue (int dacnum, int val, int mV, char* dacname, int* dacv
|
||||
if ( (*dacval >= 0) || (*dacval == LTC2620_D_PWR_DOWN_VAL)) {
|
||||
LOG(logINFO, ("Setting DAC %2d [%-12s] : %d dac (%d mV)\n",dacnum, dacname, *dacval, dacmV));
|
||||
|
||||
|
||||
#ifndef VIRTUAL
|
||||
char fname[MAX_STR_LENGTH];
|
||||
sprintf(fname, "%s%d", LTC2620_D_DriverFileName, dacnum);
|
||||
strcpy(fname, LTC2620_D_DriverFileName);
|
||||
char temp[20];
|
||||
memset(temp, 0, sizeof(temp));
|
||||
sprintf(temp, "%d", dacnum);
|
||||
strcat(fname, temp);
|
||||
LOG(logDEBUG1, ("fname %s\n",fname));
|
||||
|
||||
//open file
|
||||
@ -85,6 +91,8 @@ int LTC2620_D_SetDACValue (int dacnum, int val, int mV, char* dacname, int* dacv
|
||||
//convert to string, add 0 and write to file
|
||||
fprintf(fd, "%d\n", *dacval);
|
||||
fclose(fd);
|
||||
#endif
|
||||
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
@ -43,33 +43,33 @@ void MAX1932_Disable() {
|
||||
& ~(MAX1932_DigMask));
|
||||
}
|
||||
|
||||
int MAX1932_Set (int val) {
|
||||
LOG(logDEBUG1, ("Setting high voltage to %d\n", val));
|
||||
if (val < 0)
|
||||
int MAX1932_Set (int* val) {
|
||||
LOG(logDEBUG1, ("Setting high voltage to %d\n", *val));
|
||||
if (*val < 0)
|
||||
return FAIL;
|
||||
|
||||
int dacvalue = 0;
|
||||
|
||||
// limit values (normally < 60 => 0 (off))
|
||||
if (val < MAX1932_MinVoltage) {
|
||||
if (*val < MAX1932_MinVoltage) {
|
||||
dacvalue = MAX1932_POWER_OFF_DAC_VAL;
|
||||
val = 0;
|
||||
*val = 0;
|
||||
}
|
||||
// limit values (normally > 200 => 0x1 (max))
|
||||
else if (val > MAX1932_MaxVoltage) {
|
||||
else if (*val > MAX1932_MaxVoltage) {
|
||||
dacvalue = MAX1932_MAX_DAC_VAL;
|
||||
val = MAX1932_MaxVoltage;
|
||||
*val = MAX1932_MaxVoltage;
|
||||
}
|
||||
// convert value
|
||||
else {
|
||||
// no failure in conversion as limits handled (range from 0x1 to 0xFF)
|
||||
ConvertToDifferentRange(MAX1932_MinVoltage, MAX1932_MaxVoltage,
|
||||
MAX1932_MIN_DAC_VAL, MAX1932_MAX_DAC_VAL,
|
||||
val, &dacvalue);
|
||||
*val, &dacvalue);
|
||||
dacvalue &= MAX1932_HV_DATA_MSK;
|
||||
}
|
||||
|
||||
LOG(logINFO, ("\t%dV (dacval %d)\n", val, dacvalue));
|
||||
LOG(logINFO, ("\t%dV (dacval %d)\n", *val, dacvalue));
|
||||
serializeToSPI(MAX1932_Reg, dacvalue, MAX1932_CsMask, MAX1932_HV_NUMBITS,
|
||||
MAX1932_ClkMask, MAX1932_DigMask, MAX1932_DigOffset, 0);
|
||||
return OK;
|
||||
|
@ -577,11 +577,7 @@ int Server_VerifyLock() {
|
||||
}
|
||||
|
||||
|
||||
int Server_SendResult(int fileDes, intType itype, int update, void* retval, int retvalSize) {
|
||||
|
||||
// update if different clients (ret can be ok or acquisition finished), not fail to not overwrite e message
|
||||
if (update && isControlServer && ret != FAIL && differentClients)
|
||||
ret = FORCE_UPDATE;
|
||||
int Server_SendResult(int fileDes, intType itype, void* retval, int retvalSize) {
|
||||
|
||||
// send success of operation
|
||||
int ret1 = ret;
|
||||
@ -616,7 +612,12 @@ void getMacAddressinString(char* cmac, int size, uint64_t mac) {
|
||||
|
||||
void getIpAddressinString(char* cip, uint32_t ip) {
|
||||
memset(cip, 0, INET_ADDRSTRLEN);
|
||||
#if defined(EIGERD) && !defined(VIRTUAL)
|
||||
inet_ntop(AF_INET, &ip, cip, INET_ADDRSTRLEN);
|
||||
#else
|
||||
sprintf(cip, "%d.%d.%d.%d",
|
||||
(ip>>24)&0xff,(ip>>16)&0xff,(ip>>8)&0xff,(ip)&0xff);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
int udpSockfd[2] = {-1, -1};
|
||||
struct addrinfo* udpServerAddrInfo[2] = {0, 0};
|
||||
unsigned short int udpDestinationPort[2] = {0, 0};
|
||||
char udpDestinationIp[2][MAX_STR_LENGTH] = {"", ""};
|
||||
char udpDestinationIp[2][INET_ADDRSTRLEN] = {"", ""};
|
||||
|
||||
//DEFAULT_TX_UDP_PORT;// src port
|
||||
int getUdPSocketDescriptor(int index) {
|
||||
@ -26,8 +26,8 @@ int getUdPSocketDescriptor(int index) {
|
||||
int setUDPDestinationDetails(int index, const char* ip, unsigned short int port) {
|
||||
udpDestinationPort[index] = port;
|
||||
size_t len = strlen(ip);
|
||||
memset(udpDestinationIp[index], 0, MAX_STR_LENGTH);
|
||||
strncpy(udpDestinationIp[index], ip, len > MAX_STR_LENGTH ? MAX_STR_LENGTH : len );
|
||||
memset(udpDestinationIp[index], 0, INET_ADDRSTRLEN);
|
||||
strncpy(udpDestinationIp[index], ip, len > INET_ADDRSTRLEN ? INET_ADDRSTRLEN : len );
|
||||
|
||||
if (udpServerAddrInfo[index]) {
|
||||
freeaddrinfo(udpServerAddrInfo[index]);
|
||||
@ -37,7 +37,7 @@ int setUDPDestinationDetails(int index, const char* ip, unsigned short int port)
|
||||
// convert ip to internet address
|
||||
struct addrinfo hints;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
hints.ai_flags = 0;
|
||||
hints.ai_protocol = 0;
|
||||
@ -83,19 +83,16 @@ int createUDPSocket(int index) {
|
||||
LOG(logINFO, ("Udp client socket created for server (port %d, ip:%s)\n",
|
||||
udpDestinationPort[index], udpDestinationIp[index]));
|
||||
|
||||
// Using connect expects that the receiver (udp server) exists to listen to these packets
|
||||
// connecting allows to use "send/write" instead of "sendto", avoiding checking for server address for each packet
|
||||
// using write without a connect will end in segv
|
||||
if (connect(udpSockfd[index],udpServerAddrInfo[index]->ai_addr, udpServerAddrInfo[index]->ai_addrlen)==-1) {
|
||||
LOG(logERROR, ("Could not connect to UDP server at ip:%s, port:%d. (Error code:%d, %s)\n",
|
||||
udpDestinationIp[index], udpDestinationPort[index], errno, gai_strerror(errno)));
|
||||
}
|
||||
// using write without a connect will end in segv
|
||||
LOG(logINFO, ("Udp client socket connected\n",
|
||||
udpDestinationPort[index], udpDestinationIp[index]));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int sendUDPPacket(int index, const char* buf, int length) {
|
||||
int n = write(udpSockfd[index], buf, length);
|
||||
int n = sendto(udpSockfd[index], buf, length, 0, udpServerAddrInfo[index]->ai_addr, udpServerAddrInfo[index]->ai_addrlen);
|
||||
// udp sends atomically, no need to handle partial data
|
||||
if (n == -1) {
|
||||
LOG(logERROR, ("Could not send udp packet for socket %d. (Error code:%d, %s)\n",
|
||||
|
120
slsDetectorServers/slsDetectorServer/src/communication_virtual.c
Executable file
120
slsDetectorServers/slsDetectorServer/src/communication_virtual.c
Executable file
@ -0,0 +1,120 @@
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_virtual.h"
|
||||
#include "clogger.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h> // usleep
|
||||
|
||||
#define FILE_STATUS "/tmp/sls_virtual_server_status_"
|
||||
#define FILE_STOP "/tmp/sls_virtual_server_stop_"
|
||||
#define FD_STATUS 0
|
||||
#define FD_STOP 1
|
||||
#define FILE_NAME_LENGTH 1000
|
||||
|
||||
FILE* fd[2] = {NULL, NULL};
|
||||
char fnameStatus[FILE_NAME_LENGTH];
|
||||
char fnameStop[FILE_NAME_LENGTH];
|
||||
int portNumber = 0;
|
||||
|
||||
int ComVirtual_createFiles(const int port) {
|
||||
portNumber = port;
|
||||
// control server writign status file
|
||||
memset(fnameStatus, 0, FILE_NAME_LENGTH);
|
||||
sprintf(fnameStatus, "%s%d", FILE_STATUS, port);
|
||||
FILE* fd = NULL;
|
||||
if (NULL == (fd = fopen(fnameStatus, "w"))) {
|
||||
LOG(logERROR, ("Could not open the file %s for virtual communication\n",
|
||||
fnameStatus));
|
||||
return 0;
|
||||
}
|
||||
fclose(fd);
|
||||
LOG(logINFOBLUE, ("Created status file %s\n", fnameStatus));
|
||||
|
||||
// stop server writing stop file
|
||||
memset(fnameStop, 0, FILE_NAME_LENGTH);
|
||||
sprintf(fnameStop, "%s%d", FILE_STOP, port);
|
||||
if (NULL == (fd = fopen(fnameStop, "w"))) {
|
||||
LOG(logERROR, ("Could not open the file %s for virtual communication\n",
|
||||
fnameStop));
|
||||
return 0;
|
||||
}
|
||||
fclose(fd);
|
||||
LOG(logINFOBLUE, ("Created stop file %s\n", fnameStop));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ComVirtual_setFileNames(const int port) {
|
||||
portNumber = port;
|
||||
memset(fnameStatus, 0, FILE_NAME_LENGTH);
|
||||
memset(fnameStop, 0, FILE_NAME_LENGTH);
|
||||
sprintf(fnameStatus, "%s%d", FILE_STATUS, port);
|
||||
sprintf(fnameStop, "%s%d", FILE_STOP, port);
|
||||
}
|
||||
|
||||
void ComVirtual_setStatus(int value) {
|
||||
while (!ComVirtual_writeToFile(value, fnameStatus, "Control")) {
|
||||
usleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
int ComVirtual_getStatus() {
|
||||
int retval = 0;
|
||||
while (!ComVirtual_readFromFile(&retval, fnameStatus, "Stop")) {
|
||||
usleep(100);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
void ComVirtual_setStop(int value) {
|
||||
while (!ComVirtual_writeToFile(value, fnameStop, "Stop")) {
|
||||
usleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
int ComVirtual_getStop() {
|
||||
int retval = 0;
|
||||
while (!ComVirtual_readFromFile(&retval, fnameStop, "Control")) {
|
||||
usleep(100);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int ComVirtual_writeToFile(int value, const char* fname, const char* serverName) {
|
||||
FILE* fd = NULL;
|
||||
if (NULL == (fd = fopen(fname, "w"))) {
|
||||
LOG(logERROR, ("Vritual %s Server [%d] could not open "
|
||||
"the file %s for writing\n",
|
||||
serverName, portNumber, fname));
|
||||
return 0;
|
||||
}
|
||||
while (fwrite(&value, sizeof(value), 1, fd) < 1) {
|
||||
LOG(logERROR, ("Vritual %s Server [%d] could not write "
|
||||
"to file %s\n",
|
||||
serverName, portNumber, fname));
|
||||
return 0;
|
||||
}
|
||||
fclose(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ComVirtual_readFromFile(int* value, const char* fname, const char* serverName) {
|
||||
FILE* fd = NULL;
|
||||
if (NULL == (fd = fopen(fname, "r"))) {
|
||||
LOG(logERROR, ("Vritual %s Server [%d] could not open "
|
||||
"the file %s for reading\n",
|
||||
serverName, portNumber, fname));
|
||||
return 0;
|
||||
}
|
||||
while (fread(value, sizeof(int), 1, fd) < 1) {
|
||||
LOG(logERROR, ("Vritual %s Server [%d] could not read "
|
||||
"from file %s\n",
|
||||
serverName, portNumber, fname));
|
||||
return 0;
|
||||
}
|
||||
fclose(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
@ -7,6 +7,9 @@
|
||||
#include "slsDetectorServer_funcs.h"
|
||||
#include "slsDetectorServer_defs.h"
|
||||
#include "versionAPI.h"
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
@ -31,7 +34,8 @@ void error(char *msg){
|
||||
perror(msg);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
// print version
|
||||
if (argc > 1 && !strcasecmp(argv[1], "-version")) {
|
||||
int version = 0;
|
||||
@ -50,8 +54,9 @@ int main(int argc, char *argv[]){
|
||||
}
|
||||
|
||||
int portno = DEFAULT_PORTNO;
|
||||
int retval = OK;
|
||||
int fd = 0;
|
||||
isControlServer = 1;
|
||||
debugflag = 0;
|
||||
checkModuleFlag = 1;
|
||||
|
||||
// if socket crash, ignores SISPIPE, prevents global signal handler
|
||||
// subsequent read/write to socket gives error - must handle locally
|
||||
@ -100,46 +105,68 @@ int main(int argc, char *argv[]){
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef STOP_SERVER
|
||||
char cmd[100];
|
||||
memset(cmd, 0, 100);
|
||||
#endif
|
||||
// control server
|
||||
if (isControlServer) {
|
||||
LOG(logINFO, ("Opening control server on port %d \n", portno));
|
||||
#ifdef STOP_SERVER
|
||||
// start stop server process
|
||||
char cmd[MAX_STR_LENGTH];
|
||||
memset(cmd, 0, MAX_STR_LENGTH);
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < argc; ++i)
|
||||
sprintf(cmd, "%s %s", cmd, argv[i]);
|
||||
sprintf(cmd,"%s -stopserver -port %d &", cmd, portno + 1);
|
||||
for (i = 0; i < argc; ++i) {
|
||||
if (!strcasecmp(argv[i], "-port")) {
|
||||
i +=2;
|
||||
continue;
|
||||
}
|
||||
if (i > 0) {
|
||||
strcat(cmd, " ");
|
||||
}
|
||||
strcat(cmd, argv[i]);
|
||||
}
|
||||
char temp[50];
|
||||
memset(temp, 0, sizeof(temp));
|
||||
sprintf(temp, " -stopserver -port %d &", portno + 1);
|
||||
strcat(cmd, temp);
|
||||
|
||||
LOG(logDEBUG1, ("Command to start stop server:%s\n", cmd));
|
||||
system(cmd);
|
||||
}
|
||||
LOG(logINFOBLUE, ("Control Server [%d]\n", portno));
|
||||
#ifdef VIRTUAL
|
||||
// creating files for virtual servers to communicate with each other
|
||||
if (!ComVirtual_createFiles(portno)) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
// stop server
|
||||
else {
|
||||
LOG(logINFOBLUE, ("Stop Server [%d]\n", portno));
|
||||
#ifdef VIRTUAL
|
||||
ComVirtual_setFileNames(portno - 1);
|
||||
#endif
|
||||
} else {
|
||||
LOG(logINFO,("Opening stop server on port %d \n", portno));
|
||||
}
|
||||
|
||||
|
||||
init_detector();
|
||||
|
||||
{ // bind socket
|
||||
sockfd = bindSocket(portno);
|
||||
if (ret == FAIL)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// bind socket
|
||||
sockfd = bindSocket(portno);
|
||||
if (ret == FAIL)
|
||||
return -1;
|
||||
// assign function table
|
||||
function_table();
|
||||
|
||||
if (isControlServer) {
|
||||
LOG(logINFOBLUE, ("Control Server Ready...\n\n"));
|
||||
} else {
|
||||
LOG(logINFO, ("Stop Server Ready...\n\n"));
|
||||
LOG(logINFOBLUE, ("Stop Server Ready...\n\n"));
|
||||
}
|
||||
|
||||
// waits for connection
|
||||
int retval = OK;
|
||||
while(retval != GOODBYE && retval != REBOOT) {
|
||||
fd = acceptConnection(sockfd);
|
||||
int fd = acceptConnection(sockfd);
|
||||
if (fd > 0) {
|
||||
retval = decode_function(fd);
|
||||
closeConnection(fd);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,7 @@ set(SOURCES
|
||||
src/slsDetectorUsers.cpp
|
||||
src/Module.cpp
|
||||
src/Detector.cpp
|
||||
src/Receiver.cpp
|
||||
src/CmdProxy.cpp
|
||||
src/CmdParser.cpp
|
||||
)
|
||||
@ -15,7 +16,6 @@ add_library(slsDetectorShared SHARED
|
||||
${HEADERS}
|
||||
)
|
||||
|
||||
|
||||
# Do we have link time optimization?
|
||||
check_ipo_supported(RESULT LTO_AVAILABLE)
|
||||
if(LTO_AVAILABLE)
|
||||
@ -28,15 +28,18 @@ target_include_directories(slsDetectorShared PUBLIC
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||
)
|
||||
|
||||
target_link_libraries(slsDetectorShared PUBLIC
|
||||
slsProjectOptions
|
||||
slsProjectWarnings
|
||||
target_link_libraries(slsDetectorShared
|
||||
PUBLIC
|
||||
slsSupportLib
|
||||
${ZeroMQ_LIBRARIES}
|
||||
pthread
|
||||
rt
|
||||
slsProjectOptions
|
||||
PRIVATE
|
||||
slsProjectWarnings
|
||||
${ZeroMQ_LIBRARIES}
|
||||
)
|
||||
|
||||
|
||||
set(PUBLICHEADERS
|
||||
include/slsDetectorUsers.h
|
||||
include/detectorData.h
|
||||
@ -69,7 +72,7 @@ foreach(val RANGE ${len2})
|
||||
target_link_libraries(${val1}
|
||||
slsDetectorShared
|
||||
pthread
|
||||
${ZeroMQ_LIBRARIES}
|
||||
zmq
|
||||
rt
|
||||
)
|
||||
set_target_properties(${val1} PROPERTIES
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
|
||||
class detectorData;
|
||||
@ -18,7 +19,7 @@ class IpAddr;
|
||||
//Free function to avoid dependence on class
|
||||
//and avoid the option to free another objects
|
||||
//shm by mistake
|
||||
void freeSharedMemory(int multiId, int detPos = -1);
|
||||
void freeSharedMemory(int detectorId, int moduleId = -1);
|
||||
|
||||
|
||||
/**
|
||||
@ -56,6 +57,8 @@ class Detector {
|
||||
/* Frees shared memory, adds detectors to the list
|
||||
* and updates local detector cache */
|
||||
void setHostname(const std::vector<std::string> &hostname);
|
||||
void setHostname(const std::vector<std::string> &hostname,
|
||||
const std::vector<int> &port);
|
||||
|
||||
/** connects to n servers at local host starting at specific control port */
|
||||
void setVirtualDetectorServers(int numServers, int startingPort);
|
||||
@ -137,6 +140,16 @@ class Detector {
|
||||
void *),
|
||||
void *pArg);
|
||||
|
||||
/**[Eiger][Jungfrau] */
|
||||
bool getGapPixelsinCallback() const;
|
||||
|
||||
/**
|
||||
* [Eiger][Jungfrau]
|
||||
* Only in client data call back
|
||||
* Fills in gap pixels in data
|
||||
*/
|
||||
void setGapPixelsinCallback(const bool enable);
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
* Acquisition Parameters *
|
||||
@ -255,12 +268,6 @@ class Detector {
|
||||
|
||||
Result<int> getHighVoltage(Positions pos = {}) const;
|
||||
|
||||
/** [Jungfrau][Mythen3][Gotthard2][Moench] */
|
||||
Result<bool> getPowerChip(Positions pos = {}) const;
|
||||
|
||||
/** [Jungfrau][Mythen3][Gotthard2][Moench] */
|
||||
void setPowerChip(bool on, Positions pos = {});
|
||||
|
||||
/**
|
||||
* [Gotthard] Options: 0, 90, 110, 120, 150, 180, 200
|
||||
* [Jungfrau][CTB][Moench] Options: 0, 60 - 200
|
||||
@ -268,6 +275,21 @@ class Detector {
|
||||
*/
|
||||
void setHighVoltage(int value, Positions pos = {});
|
||||
|
||||
/** [Jungfrau][Mythen3][Gotthard2][Moench] */
|
||||
Result<bool> getPowerChip(Positions pos = {}) const;
|
||||
|
||||
/** [Jungfrau][Mythen3][Gotthard2][Moench] */
|
||||
void setPowerChip(bool on, Positions pos = {});
|
||||
|
||||
/** [Gotthard][Eiger virtual] */
|
||||
Result<int> getImageTestMode(Positions pos = {});
|
||||
|
||||
/** [Gotthard] If 1, adds channel intensity with precalculated values.
|
||||
* Default is 0
|
||||
* [Eiger virtual] If 1, pixels are saturated. If 0, increasing intensity
|
||||
* Only for virtual servers */
|
||||
void setImageTestMode(const int value, Positions pos = {});
|
||||
|
||||
/**
|
||||
* (Degrees)
|
||||
* [Gotthard] Options: TEMPERATURE_ADC, TEMPERATURE_FPGA
|
||||
@ -324,11 +346,15 @@ class Detector {
|
||||
|
||||
Result<defs::runStatus> getDetectorStatus(Positions pos = {}) const;
|
||||
|
||||
Result<defs::runStatus> getReceiverStatus(Positions pos = {}) const;
|
||||
Result<defs::runStatus> getReceiverStatus() const;
|
||||
/** interface is by 1 (primary udp interface),
|
||||
* 2 for second udp interface [Eiger][Jungfrau] */
|
||||
Result<defs::runStatus> getReceiverStatus(const int udpInterface,
|
||||
Positions pos = {}) const;
|
||||
|
||||
Result<int64_t> getFramesCaught(Positions pos = {}) const;
|
||||
Result<uint64_t> getFramesCaught(Positions pos = {}) const;
|
||||
|
||||
Result<std::vector<uint64_t>> getNumMissingPackets(Positions pos = {}) const;
|
||||
Result<uint64_t> getNumMissingPackets(Positions pos = {}) const;
|
||||
|
||||
/** [Eiger][Jungfrau] */
|
||||
Result<uint64_t> getStartingFrameNumber(Positions pos = {}) const;
|
||||
@ -483,25 +509,40 @@ class Detector {
|
||||
* *
|
||||
* ************************************************/
|
||||
|
||||
/** interface is by 1 (primary udp interface),
|
||||
* 2 for second udp interface [Eiger][Jungfrau] */
|
||||
void removeReceivers(const int udpInterface);
|
||||
|
||||
/** true when slsReceiver is used */
|
||||
Result<bool> getUseReceiverFlag(Positions pos = {}) const;
|
||||
|
||||
Result<std::string> getRxHostname(Positions pos = {}) const;
|
||||
|
||||
/** interface is by 1 (primary udp interface),
|
||||
* 2 for second udp interface [Eiger][Jungfrau]
|
||||
*/
|
||||
Result<std::string> getRxHostname(const int udpInterface, Positions pos = {}) const;
|
||||
/**
|
||||
* Validates and sets the receiver.
|
||||
* Updates local receiver cache parameters
|
||||
* Configures the detector to the receiver as UDP destination
|
||||
* @param receiver receiver hostname or IP address
|
||||
* interface is by 1 (primary udp interface),
|
||||
* 2 for second udp interface [Eiger][Jungfrau]
|
||||
*/
|
||||
void setRxHostname(const std::string &receiver, Positions pos = {});
|
||||
void setRxHostname(const int udpInterface, const std::string &hostname,
|
||||
Positions pos = {});
|
||||
|
||||
/** cannot be for multiple detectors as port is unique */
|
||||
void setRxHostname(const int udpInterface, const std::string &hostname,
|
||||
const int port, int module_id);
|
||||
|
||||
Result<int> getRxPort(Positions pos = {}) const;
|
||||
/** interface is by 1 (primary udp interface),
|
||||
* 2 for second udp interface [Eiger][Jungfrau] */
|
||||
Result<int> getRxPort(const int udpInterface, Positions pos = {}) const;
|
||||
|
||||
/** Receiver TCP port (for client communication with Receiver)
|
||||
* module_id is -1 for all detectors, ports for each module is calculated
|
||||
* (increments) */
|
||||
void setRxPort(int port, int module_id = -1);
|
||||
* (increments)
|
||||
* interface is by 1 (primary udp interface),
|
||||
* 2 for second udp interface [Eiger][Jungfrau] */
|
||||
void setRxPort(const int udpInterface, const int port, int module_id = -1);
|
||||
|
||||
Result<int> getRxFifoDepth(Positions pos = {}) const;
|
||||
|
||||
@ -633,6 +674,9 @@ class Detector {
|
||||
|
||||
void setRxZmqIP(const IpAddr ip, Positions pos = {});
|
||||
|
||||
Result<bool> getClientZmq(Positions pos = {}) const;
|
||||
void setClientZmq(const bool enable, Positions pos = {});
|
||||
|
||||
Result<int> getClientZmqPort(Positions pos = {}) const;
|
||||
|
||||
/**
|
||||
@ -691,16 +735,6 @@ class Detector {
|
||||
/** [Eiger] */
|
||||
void loadTrimbits(const std::string &fname, Positions pos = {});
|
||||
|
||||
/**[Eiger] */
|
||||
Result<bool> getRxAddGapPixels(Positions pos = {}) const;
|
||||
|
||||
/**
|
||||
* [Eiger]
|
||||
* 4 bit mode not implemented in Receiver, but in client data call back
|
||||
* Fills in gap pixels in data
|
||||
*/
|
||||
void setRxAddGapPixels(bool enable);
|
||||
|
||||
/** [Eiger] */
|
||||
Result<bool> getParallelMode(Positions pos = {}) const;
|
||||
|
||||
@ -902,12 +936,6 @@ class Detector {
|
||||
void setExternalSignalFlags(defs::externalSignalFlag value,
|
||||
Positions pos = {});
|
||||
|
||||
/** [Gotthard] */
|
||||
Result<int> getImageTestMode(Positions pos = {});
|
||||
|
||||
/** [Gotthard] If 1, adds channel intensity with precalculated values.
|
||||
* Default is 0 */
|
||||
void setImageTestMode(const int value, Positions pos = {});
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
@ -1193,10 +1221,10 @@ class Detector {
|
||||
* ************************************************/
|
||||
|
||||
/** [Moench] */
|
||||
Result<std::string> getAdditionalJsonHeader(Positions pos = {}) const;
|
||||
Result<std::map<std::string, std::string>> getAdditionalJsonHeader(Positions pos = {}) const;
|
||||
|
||||
/** [Moench] */
|
||||
void setAdditionalJsonHeader(const std::string &jsonheader,
|
||||
/** [Moench] If empty, reset additional json header. Max 20 characters for each key/value */
|
||||
void setAdditionalJsonHeader(const std::map<std::string, std::string> &jsonHeader,
|
||||
Positions pos = {});
|
||||
|
||||
/** [Moench] */
|
||||
@ -1204,12 +1232,11 @@ class Detector {
|
||||
Positions pos = {}) const;
|
||||
/**
|
||||
* [Moench]
|
||||
* Sets the value for additional json header parameter if found,
|
||||
* Sets the value for additional json header parameters if found,
|
||||
* else appends the parameter key and value
|
||||
* The value cannot be empty
|
||||
* If empty, deletes parameter. Max 20 characters for each key/value
|
||||
*/
|
||||
void setAdditionalJsonParameter(const std::string &key,
|
||||
const std::string &value,
|
||||
void setAdditionalJsonParameter(const std::string &key, const std::string &value,
|
||||
Positions pos = {});
|
||||
|
||||
/** [Moench] TODO! How do we do this best??? Can be refactored to something
|
||||
@ -1346,8 +1373,6 @@ class Detector {
|
||||
|
||||
Result<uint64_t> getRxCurrentFrameIndex(Positions pos = {}) const;
|
||||
|
||||
private:
|
||||
std::vector<int> getPortNumbers(int start_port);
|
||||
};
|
||||
|
||||
} // namespace sls
|
@ -16,9 +16,10 @@ class detectorData {
|
||||
* @param dbytes number of bytes of image pointed to by cval pointer
|
||||
* @param dr dynamic range or bits per pixel
|
||||
* @param fIndex file index
|
||||
* @param complete true if complete image, else missing packets
|
||||
*/
|
||||
detectorData(double progress, std::string fname, int x, int y, char *d, int dbytes, int dr, uint64_t fIndex) :
|
||||
progressIndex(progress), fileName(fname), fileIndex(fIndex), nx(x), ny(y), data(d), databytes(dbytes), dynamicRange(dr) {};
|
||||
detectorData(double progress, std::string fname, int x, int y, char *d, int dbytes, int dr, uint64_t fIndex, bool complete) :
|
||||
progressIndex(progress), fileName(fname), fileIndex(fIndex), nx(x), ny(y), data(d), databytes(dbytes), dynamicRange(dr), completeImage(complete) {};
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@ -55,4 +56,5 @@ class detectorData {
|
||||
char* data;
|
||||
int databytes;
|
||||
int dynamicRange;
|
||||
bool completeImage;
|
||||
};
|
||||
|
@ -115,13 +115,29 @@ std::string CmdProxy::ListCommands(int action) {
|
||||
}
|
||||
|
||||
/* configuration */
|
||||
std::pair<std::string, int>
|
||||
CmdProxy::parseHostnameAndPort(std::string name) {
|
||||
std::string host = name;
|
||||
std::string hostname;
|
||||
int port = 0;
|
||||
auto res = sls::split(host, ':');
|
||||
if (res.size() > 1) {
|
||||
hostname = res[0];
|
||||
port = StringTo<int>(res[1]);
|
||||
} else {
|
||||
hostname = host;
|
||||
}
|
||||
return std::make_pair(hostname, port);
|
||||
}
|
||||
|
||||
|
||||
std::string CmdProxy::Hostname(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "\n\tFrees shared memory and sets hostname (or IP address) of "
|
||||
"all modules concatenated by +."
|
||||
"all modules concatenated by +.\n\t"
|
||||
"[hostname or ip address]:[tcp port] Use this for virtual servers\n\t"
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (!args.empty()) {
|
||||
@ -136,18 +152,35 @@ std::string CmdProxy::Hostname(int action) {
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError("Cannot execute this at module level");
|
||||
}
|
||||
std::vector<std::string> arguments;
|
||||
// only args[0], but many hostames concatenated with +
|
||||
if (args[0].find('+') != std::string::npos) {
|
||||
auto t = sls::split(args[0], '+');
|
||||
det->setHostname(t);
|
||||
os << ToString(t) << '\n';
|
||||
if (args.size() > 1) {
|
||||
throw sls::RuntimeError("Cannot have concatenated hostnames and"
|
||||
"multiple arguments");
|
||||
}
|
||||
arguments = sls::split(args[0], '+');
|
||||
}
|
||||
// either hostnames separated by space, or single hostname
|
||||
else {
|
||||
det->setHostname(args);
|
||||
os << ToString(args) << '\n';
|
||||
arguments.assign(args.begin(), args.end());
|
||||
}
|
||||
// separate hostname and port
|
||||
std::vector<std::string> hostnames;
|
||||
std::vector<int> ports;
|
||||
for (size_t i = 0; i < arguments.size(); ++i) {
|
||||
std::pair<std::string, int> res = parseHostnameAndPort(arguments[i]);
|
||||
hostnames.push_back(res.first);
|
||||
if (res.second == 0) {
|
||||
ports.push_back(DEFAULT_PORTNO);
|
||||
} else {
|
||||
ports.push_back(res.second);
|
||||
}
|
||||
}
|
||||
det->setHostname(hostnames, ports);
|
||||
auto t = det->getHostname({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
@ -170,7 +203,7 @@ std::string CmdProxy::VirtualServer(int action) {
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError("Cannot execute this at module level");
|
||||
}
|
||||
det->setVirtualDetectorServers(std::stoi(args[0]), std::stoi(args[1]));
|
||||
det->setVirtualDetectorServers(StringTo<int>(args[0]), StringTo<int>(args[1]));
|
||||
os << sls::ToString(args);
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -315,14 +348,14 @@ std::string CmdProxy::DetectorSize(int action) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getDetectorSize();
|
||||
os << "[" << t.x << "," << t.y << "]\n";
|
||||
os << "[" << t.x << ", " << t.y << "]\n";
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
defs::xy t;
|
||||
t.x = std::stoi(args[0]);
|
||||
t.y = std::stoi(args[1]);
|
||||
t.x = StringTo<int>(args[0]);
|
||||
t.y = StringTo<int>(args[1]);
|
||||
det->setDetectorSize(t);
|
||||
os << ToString(args) << '\n';
|
||||
} else {
|
||||
@ -365,7 +398,7 @@ std::string CmdProxy::Speed(int action) {
|
||||
}
|
||||
defs::speedLevel t;
|
||||
try {
|
||||
int ival = std::stoi(args[0]);
|
||||
int ival = StringTo<int>(args[0]);
|
||||
switch (ival) {
|
||||
case 0:
|
||||
t = defs::FULL_SPEED;
|
||||
@ -403,37 +436,45 @@ std::string CmdProxy::Adcphase(int action) {
|
||||
"resets adcphase and sets it to previous values.\n\t[Gotthard] "
|
||||
"Relative phase shift"
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
Result<int> t;
|
||||
if (args.empty()) {
|
||||
t = det->getADCPhase({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (args.size() == 1) {
|
||||
if (args[0] != "deg") {
|
||||
throw sls::RuntimeError("Unknown adcphase argument " + args[0] +
|
||||
". Did you mean deg?");
|
||||
} else {
|
||||
auto det_type = det->getDetectorType().squash(defs::GENERIC);
|
||||
if (det_type == defs::EIGER ||
|
||||
det_type == defs::MYTHEN3 ||
|
||||
det_type == defs::GOTTHARD2) {
|
||||
throw sls::RuntimeError("adcphase not implemented for this detector");
|
||||
}
|
||||
t = det->getADCPhaseInDegrees({det_id});
|
||||
os << OutString(t) << " deg\n";
|
||||
} else {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
det->setADCPhase(std::stoi(args[0]), {det_id});
|
||||
os << args.front() << '\n';
|
||||
} else if (args.size() == 2) {
|
||||
if (args[1] != "deg") {
|
||||
throw sls::RuntimeError("Unknown adcphase 2nd argument " +
|
||||
args[1] + ". Did you mean deg?");
|
||||
if (action == defs::GET_ACTION) {
|
||||
Result<int> t;
|
||||
if (args.empty()) {
|
||||
t = det->getADCPhase({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (args.size() == 1) {
|
||||
if (args[0] != "deg") {
|
||||
throw sls::RuntimeError("Unknown adcphase argument " + args[0] +
|
||||
". Did you mean deg? ");
|
||||
}
|
||||
t = det->getADCPhaseInDegrees({det_id});
|
||||
os << OutString(t) << " deg\n";
|
||||
} else {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
det->setADCPhase(StringTo<int>(args[0]), {det_id} );
|
||||
os << args.front() << '\n';
|
||||
} else if (args.size() == 2) {
|
||||
if (args[1] != "deg") {
|
||||
throw sls::RuntimeError("Unknown adcphase 2nd argument " +
|
||||
args[1] + ". Did you mean deg?");
|
||||
}
|
||||
det->setADCPhaseInDegrees(StringTo<int>(args[0]) , {det_id});
|
||||
os << args[0] << " " << args[1] << '\n';
|
||||
} else {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setADCPhaseInDegrees(std::stoi(args[0]), {det_id});
|
||||
os << args[0] << args[1] << '\n';
|
||||
} else {
|
||||
WrongNumberOfParameters(1);
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
@ -447,37 +488,45 @@ std::string CmdProxy::Dbitphase(int action) {
|
||||
"shift in degrees. \n\t[Ctb]Changing dbitclk also resets dbitphase and "
|
||||
"sets to previous values."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
Result<int> t;
|
||||
if (args.empty()) {
|
||||
t = det->getDBITPhase({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (args.size() == 1) {
|
||||
if (args[0] != "deg") {
|
||||
throw sls::RuntimeError("Unknown dbitphase argument " +
|
||||
args[0] + ". Did you mean deg?");
|
||||
}
|
||||
t = det->getDBITPhaseInDegrees({det_id});
|
||||
os << OutString(t) << " deg\n";
|
||||
} else {
|
||||
WrongNumberOfParameters(0);
|
||||
} else {
|
||||
auto det_type = det->getDetectorType().squash(defs::GENERIC);
|
||||
if (det_type == defs::EIGER ||
|
||||
det_type == defs::MYTHEN3 ||
|
||||
det_type == defs::GOTTHARD2) {
|
||||
throw sls::RuntimeError("dbitphase not implemented for this detector");
|
||||
}
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
det->setDBITPhase(std::stoi(args[0]), {det_id});
|
||||
os << args.front() << '\n';
|
||||
} else if (args.size() == 2) {
|
||||
if (args[1] != "deg") {
|
||||
throw sls::RuntimeError("Unknown dbitphase 2nd argument " +
|
||||
args[1] + ". Did you mean deg?");
|
||||
if (action == defs::GET_ACTION) {
|
||||
Result<int> t;
|
||||
if (args.empty()) {
|
||||
t = det->getDBITPhase({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (args.size() == 1) {
|
||||
if (args[0] != "deg") {
|
||||
throw sls::RuntimeError("Unknown dbitphase argument " +
|
||||
args[0] + ". Did you mean deg? ");
|
||||
}
|
||||
t = det->getDBITPhaseInDegrees({det_id});
|
||||
os << OutString(t) << " deg\n";
|
||||
} else {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
det->setDBITPhase(StringTo<int>(args[0]), {det_id});
|
||||
os << args.front() << '\n';
|
||||
} else if (args.size() == 2) {
|
||||
if (args[1] != "deg") {
|
||||
throw sls::RuntimeError("Unknown dbitphase 2nd argument " +
|
||||
args[1] + ". Did you mean deg? ");
|
||||
}
|
||||
det->setDBITPhaseInDegrees(StringTo<int>(args[0]), {det_id} );
|
||||
os << args[0] << " " << args[1] << '\n';
|
||||
} else {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setDBITPhaseInDegrees(std::stoi(args[0]), {det_id});
|
||||
os << args[0] << args[1] << '\n';
|
||||
} else {
|
||||
WrongNumberOfParameters(1);
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
@ -498,15 +547,15 @@ std::string CmdProxy::ClockFrequency(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = det->getClockFrequency(std::stoi(args[0]), {det_id});
|
||||
auto t = det->getClockFrequency(StringTo<int>(args[0]), {det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setClockFrequency(std::stoi(args[0]), std::stoi(args[1]),
|
||||
det->setClockFrequency(StringTo<int>(args[0]), StringTo<int>(args[1]),
|
||||
{det_id});
|
||||
os << std::stoi(args[1]) << '\n';
|
||||
os << StringTo<int>(args[1]) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
@ -530,7 +579,7 @@ std::string CmdProxy::ClockPhase(int action) {
|
||||
}
|
||||
if (action == defs::GET_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
auto t = det->getClockPhase(std::stoi(args[0]), {det_id});
|
||||
auto t = det->getClockPhase(StringTo<int>(args[0]), {det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (args.size() == 2) {
|
||||
if (args[1] != "deg") {
|
||||
@ -538,14 +587,14 @@ std::string CmdProxy::ClockPhase(int action) {
|
||||
". Did you mean deg?");
|
||||
}
|
||||
auto t =
|
||||
det->getClockPhaseinDegrees(std::stoi(args[0]), {det_id});
|
||||
os << OutString(t) << '\n';
|
||||
det->getClockPhaseinDegrees(StringTo<int>(args[0]), {det_id});
|
||||
os << OutString(t) << " deg\n";
|
||||
} else {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() == 2) {
|
||||
det->setClockPhase(std::stoi(args[0]), std::stoi(args[1]),
|
||||
det->setClockPhase(StringTo<int>(args[0]), StringTo<int>(args[1]),
|
||||
{det_id});
|
||||
os << args[1] << '\n';
|
||||
} else if (args.size() == 3) {
|
||||
@ -553,9 +602,9 @@ std::string CmdProxy::ClockPhase(int action) {
|
||||
throw sls::RuntimeError("Cannot scan argument" + args[2] +
|
||||
". Did you mean deg?");
|
||||
}
|
||||
det->setClockPhaseinDegrees(std::stoi(args[0]),
|
||||
std::stoi(args[1]), {det_id});
|
||||
os << std::stoi(args[1]) << '\n';
|
||||
det->setClockPhaseinDegrees(StringTo<int>(args[0]),
|
||||
StringTo<int>(args[1]), {det_id});
|
||||
os << args[1] << " " << args[2] << '\n';
|
||||
} else {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
@ -582,7 +631,7 @@ std::string CmdProxy::MaxClockPhaseShift(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = det->getMaxClockPhaseShift(std::stoi(args[0]), {det_id});
|
||||
auto t = det->getMaxClockPhaseShift(StringTo<int>(args[0]), {det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
throw sls::RuntimeError("Cannot put");
|
||||
@ -609,15 +658,15 @@ std::string CmdProxy::ClockDivider(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = det->getClockDivider(std::stoi(args[0]), {det_id});
|
||||
auto t = det->getClockDivider(StringTo<int>(args[0]), {det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setClockDivider(std::stoi(args[0]), std::stoi(args[1]),
|
||||
det->setClockDivider(StringTo<int>(args[0]), StringTo<int>(args[1]),
|
||||
{det_id});
|
||||
os << std::stoi(args[1]) << '\n';
|
||||
os << args[1] << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
@ -647,7 +696,7 @@ std::string CmdProxy::Dac(int action) {
|
||||
} else if (args.size() > 2) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = det->getDAC(static_cast<defs::dacIndex>(std::stoi(args[0])),
|
||||
auto t = det->getDAC(static_cast<defs::dacIndex>(StringTo<int>(args[0])),
|
||||
mv, {det_id});
|
||||
os << args[0] << ' ' << OutString(t)
|
||||
<< (args.size() > 1 ? " mv\n" : "\n");
|
||||
@ -662,8 +711,8 @@ std::string CmdProxy::Dac(int action) {
|
||||
} else if (args.size() > 3 || args.size() < 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setDAC(static_cast<defs::dacIndex>(std::stoi(args[0])),
|
||||
std::stoi(args[1]), mv, {det_id});
|
||||
det->setDAC(static_cast<defs::dacIndex>(StringTo<int>(args[0])),
|
||||
StringTo<int>(args[1]), mv, {det_id});
|
||||
os << args[0] << ' ' << args[1] << (args.size() > 2 ? " mv\n" : "\n");
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -770,8 +819,209 @@ std::vector<std::string> CmdProxy::DacCommands() {
|
||||
}
|
||||
|
||||
/* acquisition */
|
||||
|
||||
std::string CmdProxy::ReceiverStatus(int action) {
|
||||
int udpInterface = 1;
|
||||
if (cmd == "rx_status") {
|
||||
udpInterface = 1;
|
||||
} else if (cmd == "rx_status2") {
|
||||
udpInterface = 2;
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown command, use list to list all commands");
|
||||
}
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
if (cmd == "rx_status") {
|
||||
os << "running, idle]\n\tReceiver listener status."
|
||||
<< '\n';
|
||||
} else {
|
||||
os << "running, idle]\n\tReceiver listener status for second udp port."
|
||||
<< '\n';
|
||||
}
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getReceiverStatus(udpInterface, {det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
throw sls::RuntimeError("Cannot put. Did you mean to use command 'rx_start' or 'rx_stop'?");
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::DetectorStatus(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[running, error, transmitting, finished, waiting, idle]\n\tDetector status."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getDetectorStatus({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
throw sls::RuntimeError("Cannot put. Did you mean to use command 'start' or 'stop'?");
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
/* Network Configuration (Detector<->Receiver) */
|
||||
|
||||
std::string CmdProxy::UDPDestinationIP(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[x.x.x.x] or auto\n\tIp address of the receiver (destination) udp interface. If 'auto' used, then ip is set to ip of rx_hostname."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
auto t = det->getDestinationUDPIP({det_id});
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
if (args[0] == "auto") {
|
||||
std::string rxHostname = det->getRxHostname({det_id}).squash("none");
|
||||
// Hostname could be ip try to decode otherwise look up the hostname
|
||||
auto val = sls::IpAddr{rxHostname};
|
||||
if (val == 0) {
|
||||
val = HostnameToIp(rxHostname.c_str());
|
||||
}
|
||||
LOG(logINFO) << "Setting udp_dstip of detector " <<
|
||||
det_id << " to " << val;
|
||||
det->setDestinationUDPIP(val, {det_id});
|
||||
os << val << '\n';
|
||||
} else {
|
||||
auto val = IpAddr(args[0]);
|
||||
det->setDestinationUDPIP(val, {det_id});
|
||||
os << args.front() << '\n';
|
||||
}
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::UDPDestinationIP2(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[x.x.x.x] or auto\n\t[Jungfrau] Ip address of the receiver (destination) udp interface where the second half of detector data is sent to. If 'auto' used, then ip is set to ip of rx_hostname."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
auto t = det->getDestinationUDPIP2({det_id});
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
if (args[0] == "auto") {
|
||||
std::string rxHostname = det->getRxHostname({det_id}).squash("none");
|
||||
// Hostname could be ip try to decode otherwise look up the hostname
|
||||
auto val = sls::IpAddr{rxHostname};
|
||||
if (val == 0) {
|
||||
val = HostnameToIp(rxHostname.c_str());
|
||||
}
|
||||
LOG(logINFO) << "Setting udp_dstip2 of detector " <<
|
||||
det_id << " to " << val;
|
||||
det->setDestinationUDPIP2(val, {det_id});
|
||||
os << val << '\n';
|
||||
} else {
|
||||
auto val = IpAddr(args[0]);
|
||||
det->setDestinationUDPIP2(val, {det_id});
|
||||
os << args.front() << '\n';
|
||||
}
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
/* Receiver Config */
|
||||
std::string CmdProxy::ReceiverHostname(int action) {
|
||||
int udpInterface = 1;
|
||||
if (cmd == "rx_hostname") {
|
||||
udpInterface = 1;
|
||||
} else if (cmd == "rx_hostname2") {
|
||||
udpInterface = 2;
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown command, use list to list all commands");
|
||||
}
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
if (cmd == "rx_hostname") {
|
||||
os << "[hostname or ip address]\n\t"
|
||||
"[hostname or ip address]:[tcp port]\n\t"
|
||||
"Receiver hostname or IP. Port is the receiver tcp port (optional).\n\t"
|
||||
"Use 'none' to remove receivers\n\t"
|
||||
"Used for TCP control communication between client and receiver "
|
||||
"to configure receiver. Also updates receiver with detector parameters.\n\t"
|
||||
"TCP port must be unique, if included.\n\t"
|
||||
"If port not included and not set earlier, then it takes default port 1954"
|
||||
" and calculates from there. \n\t"
|
||||
"[Eiger][Jungfrau] For the 2nd udp interface, use rx_hostname2."
|
||||
<< '\n';
|
||||
} else {
|
||||
os << "[hostname or ip address]\n\t"
|
||||
"[hostname or ip address]:[tcp port]\n\t"
|
||||
"[Eiger][Jungfrau] Receiver hostname or IP for the second udp port. "
|
||||
"Port is the receiver tcp port (optional).\n\t"
|
||||
"Use 'none' to remove receivers\n\t"
|
||||
"Refer rx_hostname help for details"
|
||||
<< '\n';
|
||||
}
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (!args.empty()) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getRxHostname(udpInterface, {det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
if (args[0].find('+') != std::string::npos) {
|
||||
throw sls::RuntimeError("Cannot concatenate receiver hostnames");
|
||||
}
|
||||
std::pair<std::string, int> res = parseHostnameAndPort(args[0]);
|
||||
// removing receivers
|
||||
if (res.first == "none") {
|
||||
det->removeReceivers(udpInterface);
|
||||
os << "removed" << '\n';
|
||||
}
|
||||
// adding receivers
|
||||
else {
|
||||
std::string hostname = res.first;
|
||||
int port = res.second;
|
||||
if (port == 0) {
|
||||
det->setRxHostname(udpInterface, hostname, {det_id});
|
||||
} else {
|
||||
det->setRxHostname(udpInterface, hostname, port, det_id);
|
||||
}
|
||||
auto t = det->getRxHostname(udpInterface, {det_id});
|
||||
os << OutString(t) << '\n';
|
||||
}
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
/* File */
|
||||
/* ZMQ Streaming Parameters (Receiver<->Client) */
|
||||
/* Eiger Specific */
|
||||
@ -797,7 +1047,7 @@ std::string CmdProxy::DynamicRange(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setDynamicRange(std::stoi(args[0]));
|
||||
det->setDynamicRange(StringTo<int>(args[0]));
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -819,12 +1069,12 @@ std::string CmdProxy::Threshold(int action) {
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
det->setThresholdEnergy(std::stoi(args[0]),
|
||||
det->setThresholdEnergy(StringTo<int>(args[0]),
|
||||
slsDetectorDefs::GET_SETTINGS, true,
|
||||
{det_id});
|
||||
} else if (args.size() == 2) {
|
||||
det->setThresholdEnergy(
|
||||
std::stoi(args[0]),
|
||||
StringTo<int>(args[0]),
|
||||
sls::StringTo<slsDetectorDefs::detectorSettings>(args[1]), true,
|
||||
{det_id});
|
||||
} else {
|
||||
@ -848,12 +1098,12 @@ std::string CmdProxy::ThresholdNoTb(int action) {
|
||||
throw sls::RuntimeError("cannot get");
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
det->setThresholdEnergy(std::stoi(args[0]),
|
||||
det->setThresholdEnergy(StringTo<int>(args[0]),
|
||||
slsDetectorDefs::GET_SETTINGS, false,
|
||||
{det_id});
|
||||
} else if (args.size() == 2) {
|
||||
det->setThresholdEnergy(
|
||||
std::stoi(args[0]),
|
||||
StringTo<int>(args[0]),
|
||||
sls::StringTo<slsDetectorDefs::detectorSettings>(args[1]),
|
||||
false, {det_id});
|
||||
} else {
|
||||
@ -870,24 +1120,27 @@ std::string CmdProxy::GapPixels(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[0, 1]\n\t[Eiger] Include Gap pixels in data file or data call "
|
||||
"back. 4 bit mode gap pixels only ind ata call back."
|
||||
os << "[0, 1]\n\t[Eiger][Jungfrau] Include Gap pixels only in data call back."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError(
|
||||
"Cannot get gap pixels at module level");
|
||||
}
|
||||
if (!args.empty()) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getRxAddGapPixels({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
auto t = det->getGapPixelsinCallback();
|
||||
os << t << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError(
|
||||
"Cannot execute dynamic range at module level");
|
||||
"Cannot add gap pixels at module level");
|
||||
}
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setRxAddGapPixels(std::stoi(args[0]));
|
||||
det->setGapPixelsinCallback(StringTo<int>(args[0]));
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -914,10 +1167,10 @@ std::string CmdProxy::TrimEnergies(int action) {
|
||||
if (args.empty()) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
unsigned int ntrim = args.size();
|
||||
std::vector<int> t(ntrim);
|
||||
for (unsigned int i = 0; i < ntrim; ++i) {
|
||||
t[i] = std::stoi(args[i]);
|
||||
|
||||
std::vector<int> t(args.size());
|
||||
for (size_t i = 0; i < t.size(); ++i) {
|
||||
t[i] = StringTo<int>(args[i]);
|
||||
}
|
||||
det->setTrimEnergies(t, {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
@ -945,7 +1198,7 @@ std::string CmdProxy::RateCorrection(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
int tau = std::stoi(args[0]);
|
||||
int tau = StringTo<int>(args[0]);
|
||||
if (tau == -1) {
|
||||
det->setDefaultRateCorrection({det_id});
|
||||
auto t = det->getRateCorrection({det_id});
|
||||
@ -984,7 +1237,7 @@ std::string CmdProxy::Activate(int action) {
|
||||
if (args.empty() || args.size() > 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
int t = std::stoi(args[0]);
|
||||
int t = StringTo<int>(args[0]);
|
||||
det->setActive(t, {det_id});
|
||||
os << args[0];
|
||||
if (args.size() == 2) {
|
||||
@ -1018,10 +1271,10 @@ std::string CmdProxy::PulsePixel(int action) {
|
||||
if (args.size() != 3) {
|
||||
WrongNumberOfParameters(3);
|
||||
}
|
||||
int n = std::stoi(args[0]);
|
||||
int n = StringTo<int>(args[0]);
|
||||
defs::xy c;
|
||||
c.x = std::stoi(args[1]);
|
||||
c.y = std::stoi(args[2]);
|
||||
c.x = StringTo<int>(args[1]);
|
||||
c.y = StringTo<int>(args[2]);
|
||||
det->pulsePixel(n, c, {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
@ -1043,10 +1296,10 @@ std::string CmdProxy::PulsePixelAndMove(int action) {
|
||||
if (args.size() != 3) {
|
||||
WrongNumberOfParameters(3);
|
||||
}
|
||||
int n = std::stoi(args[0]);
|
||||
int n = StringTo<int>(args[0]);
|
||||
defs::xy c;
|
||||
c.x = std::stoi(args[1]);
|
||||
c.y = std::stoi(args[2]);
|
||||
c.x = StringTo<int>(args[1]);
|
||||
c.y = StringTo<int>(args[2]);
|
||||
det->pulsePixelNMove(n, c, {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
@ -1069,7 +1322,7 @@ std::string CmdProxy::PulseChip(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->pulseChip(std::stoi(args[0]), {det_id});
|
||||
det->pulseChip(StringTo<int>(args[0]), {det_id});
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1093,12 +1346,12 @@ std::string CmdProxy::Quad(int action) {
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError(
|
||||
"Cannot execute dynamic range at module level");
|
||||
"Cannot execute quad at module level");
|
||||
}
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setQuad(std::stoi(args[0]));
|
||||
det->setQuad(StringTo<int>(args[0]));
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1129,7 +1382,7 @@ std::string CmdProxy::TemperatureEvent(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
if (std::stoi(args[0]) != 0) {
|
||||
if (StringTo<int>(args[0]) != 0) {
|
||||
throw sls::RuntimeError("Unknown argument for temp event. Did you "
|
||||
"mean 0 to reset event?");
|
||||
}
|
||||
@ -1167,8 +1420,8 @@ std::string CmdProxy::ROI(int action) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
defs::ROI t;
|
||||
t.xmin = std::stoi(args[0]);
|
||||
t.xmax = std::stoi(args[1]);
|
||||
t.xmin = StringTo<int>(args[0]);
|
||||
t.xmax = StringTo<int>(args[1]);
|
||||
det->setROI(t, det_id);
|
||||
os << '[' << t.xmin << ", " << t.xmax << "] \n";
|
||||
} else {
|
||||
@ -1219,7 +1472,7 @@ std::string CmdProxy::InjectChannel(int action) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setInjectChannel(std::stoi(args[0]), std::stoi(args[1]), {det_id});
|
||||
det->setInjectChannel(StringTo<int>(args[0]), StringTo<int>(args[1]), {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1240,14 +1493,14 @@ std::string CmdProxy::VetoPhoton(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = det->getVetoPhoton(std::stoi(args[0]), {det_id});
|
||||
auto t = det->getVetoPhoton(StringTo<int>(args[0]), {det_id});
|
||||
os << args[0] << ' ' << OutStringHex(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 4) {
|
||||
WrongNumberOfParameters(4);
|
||||
}
|
||||
det->setVetoPhoton(std::stoi(args[0]), std::stoi(args[1]),
|
||||
std::stoi(args[2]), args[3], {det_id});
|
||||
det->setVetoPhoton(StringTo<int>(args[0]), StringTo<int>(args[1]),
|
||||
StringTo<int>(args[2]), args[3], {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1268,7 +1521,7 @@ std::string CmdProxy::VetoReference(int action) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setVetoReference(std::stoi(args[0]), stoiHex(args[1]), {det_id});
|
||||
det->setVetoReference(StringTo<int>(args[0]), StringTo<int>(args[1]), {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1295,7 +1548,7 @@ std::string CmdProxy::BurstMode(int action) {
|
||||
}
|
||||
defs::burstMode t;
|
||||
try {
|
||||
int ival = std::stoi(args[0]);
|
||||
int ival = StringTo<int>(args[0]);
|
||||
switch (ival) {
|
||||
case 0:
|
||||
t = defs::BURST_OFF;
|
||||
@ -1350,7 +1603,7 @@ std::string CmdProxy::Counters(int action) {
|
||||
// convert vector to counter enable mask
|
||||
uint32_t mask = 0;
|
||||
for (size_t i = 0; i < args.size(); ++i) {
|
||||
int val = std::stoi(args[i]);
|
||||
int val = StringTo<int>(args[i]);
|
||||
// already enabled earlier
|
||||
if (mask & (1 << val)) {
|
||||
std::ostringstream oss;
|
||||
@ -1396,10 +1649,10 @@ std::string CmdProxy::Samples(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setNumberOfAnalogSamples(std::stoi(args[0]), {det_id});
|
||||
det->setNumberOfAnalogSamples(StringTo<int>(args[0]), {det_id});
|
||||
// set also digital samples for ctb
|
||||
if (det->getDetectorType().squash() == defs::CHIPTESTBOARD) {
|
||||
det->setNumberOfDigitalSamples(std::stoi(args[0]), {det_id});
|
||||
det->setNumberOfDigitalSamples(StringTo<int>(args[0]), {det_id});
|
||||
}
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
@ -1421,7 +1674,7 @@ std::string CmdProxy::SlowAdc(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
int nchan = std::stoi(args[0]);
|
||||
int nchan = StringTo<int>(args[0]);
|
||||
if (nchan < 0 || nchan > defs::SLOW_ADC_TEMP - defs::SLOW_ADC0) {
|
||||
throw sls::RuntimeError("Unknown adc argument " + args[0]);
|
||||
}
|
||||
@ -1475,7 +1728,7 @@ std::string CmdProxy::ReceiverDbitList(int action) {
|
||||
unsigned int ntrim = args.size();
|
||||
t.resize(ntrim);
|
||||
for (unsigned int i = 0; i < ntrim; ++i) {
|
||||
t[i] = std::stoi(args[i]);
|
||||
t[i] = StringTo<int>(args[i]);
|
||||
}
|
||||
}
|
||||
det->setRxDbitList(t, {det_id});
|
||||
@ -1500,7 +1753,7 @@ std::string CmdProxy::DigitalIODelay(int action) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setDigitalIODelay(stoulHex(args[0]), std::stoi(args[1]), {det_id});
|
||||
det->setDigitalIODelay(StringTo<uint64_t>(args[0]), StringTo<int>(args[1]), {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1542,13 +1795,13 @@ std::string CmdProxy::PatternWord(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = det->getPatternWord(stoiHex(args[0]), {det_id});
|
||||
auto t = det->getPatternWord(StringTo<uint64_t>(args[0]), {det_id});
|
||||
os << OutStringHex(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setPatternWord(stoiHex(args[0]), stoulHex(args[1]), {det_id});
|
||||
det->setPatternWord(StringTo<int>(args[0]), StringTo<uint64_t>(args[1]), {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1601,8 +1854,8 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->setPatternLoopAddresses(level, stoiHex(args[0]),
|
||||
stoiHex(args[1]), {det_id});
|
||||
det->setPatternLoopAddresses(level, StringTo<int>(args[0]),
|
||||
StringTo<int>(args[1]), {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1647,7 +1900,7 @@ std::string CmdProxy::PatternLoopCycles(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setPatternLoopCycles(level, std::stoi(args[0]), {det_id});
|
||||
det->setPatternLoopCycles(level, StringTo<int>(args[0]), {det_id});
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1692,7 +1945,7 @@ std::string CmdProxy::PatternWaitAddress(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setPatternWaitAddr(level, stoiHex(args[0]), {det_id});
|
||||
det->setPatternWaitAddr(level, StringTo<int>(args[0]), {det_id});
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1737,7 +1990,7 @@ std::string CmdProxy::PatternWaitTime(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setPatternWaitTime(level, std::stoul(args[0]), {det_id});
|
||||
det->setPatternWaitTime(level, StringTo<uint64_t>(args[0]), {det_id});
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1748,13 +2001,47 @@ std::string CmdProxy::PatternWaitTime(int action) {
|
||||
|
||||
/* Moench */
|
||||
|
||||
std::string CmdProxy::AdditionalJsonHeader(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[key1] [value1] [key2] [value2]...[keyn] [valuen]"
|
||||
"\n\tAdditional json header to be streamed out from receiver via zmq. "
|
||||
"Default is empty. Use only if to be processed by an intermediate user process "
|
||||
"listening to receiver zmq packets. Empty value deletes header. "
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getAdditionalJsonHeader({det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
// arguments can be empty
|
||||
std::map<std::string, std::string> json;
|
||||
for (size_t i = 0; i < args.size(); i = i + 2) {
|
||||
// last value is empty
|
||||
if (i + 1 >= args.size()) {
|
||||
json[args[i]] = "";
|
||||
} else {
|
||||
json[args[i]] = args[i + 1];
|
||||
}
|
||||
}
|
||||
det->setAdditionalJsonHeader(json, {det_id});
|
||||
os << sls::ToString(json) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::JsonParameter(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[key1] [value1]\n\tAdditional json header parameter streamed "
|
||||
"out from receiver. If empty in a get, then no parameter found. "
|
||||
"This is same as calling rx_jsonaddheader \"key\":\"value1\"."
|
||||
"out from receiver. If not found in header, the pair is appended. "
|
||||
"An empty values deletes parameter."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
@ -1763,11 +2050,21 @@ std::string CmdProxy::JsonParameter(int action) {
|
||||
auto t = det->getAdditionalJsonParameter(args[0], {det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
switch (args.size()) {
|
||||
case 1:
|
||||
det->setAdditionalJsonParameter(args[0], "", {det_id});
|
||||
break;
|
||||
case 2:
|
||||
det->setAdditionalJsonParameter(args[0], args[1], {det_id});
|
||||
break;
|
||||
default:
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
if (args.size() == 1) {
|
||||
os << args[0] << " deleted" << '\n';
|
||||
} else {
|
||||
os << "{" << args[0] << ": " << args[1] << "}" << '\n';
|
||||
}
|
||||
det->setAdditionalJsonParameter(args[0], args[1], {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
@ -1810,7 +2107,7 @@ std::string CmdProxy::MinMaxEnergyThreshold(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setDetectorMinMaxEnergyThreshold(emax, std::stoi(args[0]),
|
||||
det->setDetectorMinMaxEnergyThreshold(emax, StringTo<int>(args[0]),
|
||||
{det_id});
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
@ -1901,13 +2198,13 @@ std::string CmdProxy::Register(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = det->readRegister(stoiHex(args[0]), {det_id});
|
||||
auto t = det->readRegister(StringTo<uint32_t>(args[0]), {det_id});
|
||||
os << OutStringHex(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->writeRegister(stoiHex(args[0]), stoiHex(args[1]), {det_id});
|
||||
det->writeRegister(StringTo<uint32_t>(args[0]), StringTo<uint32_t>(args[1]), {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1928,7 +2225,7 @@ std::string CmdProxy::AdcRegister(int action) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
det->writeAdcRegister(stoiHex(args[0]), stoiHex(args[1]), {det_id});
|
||||
det->writeAdcRegister(StringTo<uint32_t>(args[0]), StringTo<uint32_t>(args[1]), {det_id});
|
||||
os << sls::ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
@ -1964,8 +2261,8 @@ std::string CmdProxy::BitOperations(int action) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
uint32_t addr = stoiHex(args[0]);
|
||||
int bitnr = std::stoi(args[1]);
|
||||
auto addr = StringTo<uint32_t>(args[0]);
|
||||
auto bitnr = StringTo<int>(args[1]);
|
||||
if (bitnr < 0 || bitnr > 31) {
|
||||
return std::string("Bit number out of range") +
|
||||
std::to_string(bitnr);
|
||||
@ -2021,7 +2318,7 @@ std::string CmdProxy::InitialChecks(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->setInitialChecks(std::stoi(args[0]));
|
||||
det->setInitialChecks(StringTo<int>(args[0]));
|
||||
os << args.front() << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
|
@ -89,10 +89,10 @@
|
||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||
os << HLPSTR << '\n'; \
|
||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||
auto t = det->GETFCN({det_id}); \
|
||||
if (args.size() != 0) { \
|
||||
WrongNumberOfParameters(0); \
|
||||
} \
|
||||
auto t = det->GETFCN({det_id}); \
|
||||
os << OutString(t) << '\n'; \
|
||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||
if (args.size() != 1) { \
|
||||
@ -115,10 +115,10 @@
|
||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||
os << HLPSTR << '\n'; \
|
||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||
auto t = det->GETFCN({det_id}); \
|
||||
if (args.size() != 0) { \
|
||||
WrongNumberOfParameters(0); \
|
||||
} \
|
||||
auto t = det->GETFCN({det_id}); \
|
||||
os << OutStringHex(t) << '\n'; \
|
||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||
if (args.size() != 1) { \
|
||||
@ -141,10 +141,10 @@
|
||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||
os << HLPSTR << '\n'; \
|
||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||
auto t = det->GETFCN({det_id}); \
|
||||
if (args.size() != 0) { \
|
||||
WrongNumberOfParameters(0); \
|
||||
} \
|
||||
auto t = det->GETFCN({det_id}); \
|
||||
os << OutString(t) << '\n'; \
|
||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||
if (args.size() != 1) { \
|
||||
@ -170,10 +170,10 @@
|
||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||
os << HLPSTR << '\n'; \
|
||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||
auto t = det->GETFCN(); \
|
||||
if (args.size() != 0) { \
|
||||
WrongNumberOfParameters(0); \
|
||||
} \
|
||||
auto t = det->GETFCN(); \
|
||||
os << OutString(t) << '\n'; \
|
||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||
if (args.size() != 1) { \
|
||||
@ -196,10 +196,10 @@
|
||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||
os << HLPSTR << '\n'; \
|
||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||
auto t = det->GETFCN(INDEX, {det_id}); \
|
||||
if (args.size() != 0) { \
|
||||
WrongNumberOfParameters(0); \
|
||||
} \
|
||||
auto t = det->GETFCN(INDEX, {det_id}); \
|
||||
os << OutString(t) << '\n'; \
|
||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||
if (args.size() != 1) { \
|
||||
@ -225,14 +225,14 @@
|
||||
if (args.size() != 1) { \
|
||||
WrongNumberOfParameters(1); \
|
||||
} \
|
||||
auto t = det->GETFCN(INDEX, std::stoi(args[0]), {det_id}); \
|
||||
auto t = det->GETFCN(INDEX, StringTo<int>(args[0]), {det_id}); \
|
||||
os << args [0] << ' ' << OutStringHex(t) << '\n'; \
|
||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||
if (args.size() != 2) { \
|
||||
WrongNumberOfParameters(2); \
|
||||
} \
|
||||
auto val = CONV(args[1]); \
|
||||
det->SETFCN(INDEX, std::stoi(args[0]), val, {det_id}); \
|
||||
det->SETFCN(INDEX, StringTo<int>(args[0]), val, {det_id}); \
|
||||
os << args[0] << ' ' << args[1] << '\n'; \
|
||||
} else { \
|
||||
throw sls::RuntimeError("Unknown action"); \
|
||||
@ -270,7 +270,7 @@
|
||||
} else if (args.size() > 2 || args.size() < 1) { \
|
||||
WrongNumberOfParameters(1); \
|
||||
} \
|
||||
det->SETFCN(DAC_INDEX, std::stoi(args[0]), mv, {det_id}); \
|
||||
det->SETFCN(DAC_INDEX, StringTo<int>(args[0]), mv, {det_id}); \
|
||||
os << args.front() << (args.size() > 1 ? " mv\n" : "\n"); \
|
||||
} else { \
|
||||
throw sls::RuntimeError("Unknown action"); \
|
||||
@ -448,19 +448,19 @@ class CmdProxy {
|
||||
return ToString(value, unit);
|
||||
}
|
||||
|
||||
inline unsigned int stoiHex(const std::string& s) {
|
||||
unsigned long lresult = stoul(s, nullptr, 16);
|
||||
unsigned int result = lresult;
|
||||
if (result != lresult) {
|
||||
throw std::out_of_range("cannot convert to unsigned int");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// inline unsigned int stoiHex(const std::string& s) {
|
||||
// unsigned long lresult = stoul(s, nullptr, 16);
|
||||
// unsigned int result = lresult;
|
||||
// if (result != lresult) {
|
||||
// throw std::out_of_range("cannot convert to unsigned int");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
inline unsigned long int stoulHex(const std::string& s) {
|
||||
unsigned long result = stoul(s, nullptr, 16);
|
||||
return result;
|
||||
}
|
||||
// inline unsigned long int stoulHex(const std::string& s) {
|
||||
// unsigned long result = stoul(s, nullptr, 16);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
using FunctionMap = std::map<std::string, std::string (CmdProxy::*)(int)>;
|
||||
using StringMap = std::map<std::string, std::string>;
|
||||
@ -477,6 +477,7 @@ class CmdProxy {
|
||||
{"cycles", "triggers"},
|
||||
{"cyclesl", "triggersl"},
|
||||
{"clkdivider", "speed"},
|
||||
{"digitest", "imagetest"},
|
||||
|
||||
/** temperature */
|
||||
/** dacs */
|
||||
@ -527,8 +528,6 @@ class CmdProxy {
|
||||
|
||||
/* Jungfrau Specific */
|
||||
/* Gotthard Specific */
|
||||
{"digitest", "imagetest"},
|
||||
|
||||
/* Gotthard2 Specific */
|
||||
/* Mythen3 Specific */
|
||||
/* CTB Specific */
|
||||
@ -572,11 +571,9 @@ class CmdProxy {
|
||||
{"acquire", &CmdProxy::acquire},
|
||||
{"frames", &CmdProxy::frames},
|
||||
{"triggers", &CmdProxy::triggers},
|
||||
{"bursts", &CmdProxy::bursts},
|
||||
{"exptime", &CmdProxy::exptime},
|
||||
{"period", &CmdProxy::period},
|
||||
{"delay", &CmdProxy::delay},
|
||||
{"burstperiod", &CmdProxy::burstperiod},
|
||||
{"framesl", &CmdProxy::framesl},
|
||||
{"triggersl", &CmdProxy::triggersl},
|
||||
{"delayl", &CmdProxy::delayl},
|
||||
@ -593,6 +590,7 @@ class CmdProxy {
|
||||
{"clkdiv", &CmdProxy::ClockDivider},
|
||||
{"vhighvoltage", &CmdProxy::vhighvoltage},
|
||||
{"powerchip", &CmdProxy::powerchip},
|
||||
{"imagetest", &CmdProxy::imagetest},
|
||||
|
||||
/** temperature */
|
||||
{"temp_adc", &CmdProxy::temp_adc},
|
||||
@ -693,8 +691,8 @@ class CmdProxy {
|
||||
{"rx_stop", &CmdProxy::rx_stop},
|
||||
{"start", &CmdProxy::start},
|
||||
{"stop", &CmdProxy::stop},
|
||||
{"rx_status", &CmdProxy::rx_status},
|
||||
{"status", &CmdProxy::status},
|
||||
{"rx_status", &CmdProxy::ReceiverStatus},
|
||||
{"status", &CmdProxy::DetectorStatus},
|
||||
{"rx_framescaught", &CmdProxy::rx_framescaught},
|
||||
{"rx_missingpackets", &CmdProxy::rx_missingpackets},
|
||||
{"startingfnum", &CmdProxy::startingfnum},
|
||||
@ -705,8 +703,8 @@ class CmdProxy {
|
||||
{"selinterface", &CmdProxy::selinterface},
|
||||
{"udp_srcip", &CmdProxy::udp_srcip},
|
||||
{"udp_srcip2", &CmdProxy::udp_srcip2},
|
||||
{"udp_dstip", &CmdProxy::udp_dstip},
|
||||
{"udp_dstip2", &CmdProxy::udp_dstip2},
|
||||
{"udp_dstip", &CmdProxy::UDPDestinationIP},
|
||||
{"udp_dstip2", &CmdProxy::UDPDestinationIP2},
|
||||
{"udp_srcmac", &CmdProxy::udp_srcmac},
|
||||
{"udp_srcmac2", &CmdProxy::udp_srcmac2},
|
||||
{"udp_dstmac", &CmdProxy::udp_dstmac},
|
||||
@ -721,8 +719,10 @@ class CmdProxy {
|
||||
{"txndelay_right", &CmdProxy::txndelay_right},
|
||||
|
||||
/* Receiver Config */
|
||||
{"rx_hostname", &CmdProxy::rx_hostname},
|
||||
{"rx_hostname", &CmdProxy::ReceiverHostname},
|
||||
{"rx_hostname2", &CmdProxy::ReceiverHostname},
|
||||
{"rx_tcpport", &CmdProxy::rx_tcpport},
|
||||
{"rx_tcpport2", &CmdProxy::rx_tcpport2},
|
||||
{"rx_fifodepth", &CmdProxy::rx_fifodepth},
|
||||
{"rx_silent", &CmdProxy::rx_silent},
|
||||
{"rx_discardpolicy", &CmdProxy::rx_discardpolicy},
|
||||
@ -791,9 +791,10 @@ class CmdProxy {
|
||||
{"clearroi", &CmdProxy::ClearROI},
|
||||
{"exptimel", &CmdProxy::exptimel},
|
||||
{"extsig", &CmdProxy::extsig},
|
||||
{"imagetest", &CmdProxy::imagetest},
|
||||
|
||||
/* Gotthard2 Specific */
|
||||
{"bursts", &CmdProxy::bursts},
|
||||
{"burstperiod", &CmdProxy::burstperiod},
|
||||
{"inj_ch", &CmdProxy::InjectChannel},
|
||||
{"vetophoton", &CmdProxy::VetoPhoton},
|
||||
{"vetoref", &CmdProxy::VetoReference},
|
||||
@ -867,7 +868,7 @@ class CmdProxy {
|
||||
{"patsetbit", &CmdProxy::patsetbit},
|
||||
|
||||
/* Moench */
|
||||
{"rx_jsonaddheader", &CmdProxy::rx_jsonaddheader},
|
||||
{"rx_jsonaddheader", &CmdProxy::AdditionalJsonHeader},
|
||||
{"rx_jsonpara", &CmdProxy::JsonParameter},
|
||||
{"emin", &CmdProxy::MinMaxEnergyThreshold},
|
||||
{"emax", &CmdProxy::MinMaxEnergyThreshold},
|
||||
@ -912,6 +913,7 @@ class CmdProxy {
|
||||
/* configuration */
|
||||
std::string free(int action);
|
||||
// std::string config2(int action);
|
||||
std::pair<std::string, int> parseHostnameAndPort(std::string name);
|
||||
std::string Hostname(int action);
|
||||
std::string VirtualServer(int action);
|
||||
std::string FirmwareVersion(int action);
|
||||
@ -934,10 +936,14 @@ class CmdProxy {
|
||||
std::string DacList(int action);
|
||||
std::string DacValues(int action);
|
||||
std::vector<std::string> DacCommands();
|
||||
std::string OnChipDac(int action);
|
||||
/* acquisition */
|
||||
std::string ReceiverStatus(int action);
|
||||
std::string DetectorStatus(int action);
|
||||
/* Network Configuration (Detector<->Receiver) */
|
||||
std::string UDPDestinationIP(int action);
|
||||
std::string UDPDestinationIP2(int action);
|
||||
/* Receiver Config */
|
||||
std::string ReceiverHostname(int action);
|
||||
/* File */
|
||||
/* ZMQ Streaming Parameters (Receiver<->Client) */
|
||||
/* Eiger Specific */
|
||||
@ -978,6 +984,7 @@ class CmdProxy {
|
||||
std::string PatternWaitAddress(int action);
|
||||
std::string PatternWaitTime(int action);
|
||||
/* Moench */
|
||||
std::string AdditionalJsonHeader(int action);
|
||||
std::string JsonParameter(int action);
|
||||
std::string MinMaxEnergyThreshold(int action);
|
||||
/* Advanced */
|
||||
@ -1026,18 +1033,14 @@ class CmdProxy {
|
||||
/* acquisition parameters */
|
||||
|
||||
INTEGER_COMMAND_NOID(frames, getNumberOfFrames, setNumberOfFrames,
|
||||
std::stol,
|
||||
StringTo<int64_t>,
|
||||
"[n_frames]\n\tNumber of frames per aquire. In trigger mode, number of frames per trigger."
|
||||
"\n\t[Gotthard2] Burst mode has a maximum of 2720 frames.");
|
||||
|
||||
INTEGER_COMMAND_NOID(triggers, getNumberOfTriggers, setNumberOfTriggers,
|
||||
std::stol,
|
||||
StringTo<int64_t>,
|
||||
"[n_triggers]\n\tNumber of triggers per aquire. Use timing command to set timing mode.");
|
||||
|
||||
INTEGER_COMMAND_NOID(bursts, getNumberOfBursts, setNumberOfBursts,
|
||||
std::stol,
|
||||
"[n_bursts]\n\t[Gotthard2] Number of bursts per aquire. Only in auto timing mode and burst mode. Use timing command to set timing mode and burstmode command to set burst mode.");
|
||||
|
||||
TIME_COMMAND(exptime, getExptime, setExptime,
|
||||
"[duration] [(optional unit) ns|us|ms|s]\n\tExposure time"
|
||||
"\n\t[Gotthard2] Uploaded to detector just before acquisition starts");
|
||||
@ -1077,19 +1080,23 @@ class CmdProxy {
|
||||
GET_COMMAND(maxdbitphaseshift, getMaxDBITPhaseShift,
|
||||
"\n\t[CTB][Jungfrau] Absolute maximum Phase shift of of the clock to latch digital bits.");
|
||||
|
||||
INTEGER_COMMAND(vhighvoltage, getHighVoltage, setHighVoltage, std::stoi,
|
||||
INTEGER_COMMAND(vhighvoltage, getHighVoltage, setHighVoltage, StringTo<int>,
|
||||
"[n_value]\n\tHigh voltage to the sensor in Voltage."
|
||||
"\n\t[Gotthard] [0|90|110|120|150|180|200]"
|
||||
"\n\t[Eiger][Mythen3][Gotthard2] 0-200"
|
||||
"\n\t[Jungfrau][Ctb][Moench] [0|60-200]");
|
||||
|
||||
INTEGER_COMMAND(powerchip, getPowerChip, setPowerChip, std::stoi,
|
||||
INTEGER_COMMAND(powerchip, getPowerChip, setPowerChip, StringTo<int>,
|
||||
"[0, 1]\n\t[Jungfrau][Mythen3][Gotthard2][Moench] Power the chip. Default 0."
|
||||
"\n\t[Jungfrau] Get will return power status."
|
||||
"Can be off if temperature event occured (temperature over temp_threshold with temp_control enabled."
|
||||
"\n\t[Mythen3] If module not connected or wrong module, 1 will fail. By default, not powered on"
|
||||
"\n\t[Gotthard2] If module not connected or wrong module, 1 will fail. By default, powered on at server start up.");
|
||||
|
||||
INTEGER_COMMAND(imagetest, getImageTestMode, setImageTestMode, StringTo<int>,
|
||||
"[0, 1]\n\t[Gotthard] 1 adds channel intensity with precalculated values when taking an acquisition. Default is 0."
|
||||
"\n\t[Eiger][Jungfrau] Only for Virtual servers. If 0, each pixel intensity incremented by 1. If 1, all pixels almost saturated.");
|
||||
|
||||
/** temperature */
|
||||
|
||||
GET_IND_COMMAND(temp_adc, getTemperature, slsDetectorDefs::TEMPERATURE_ADC, " °C",
|
||||
@ -1324,22 +1331,22 @@ class CmdProxy {
|
||||
|
||||
|
||||
/* on chip dacs */
|
||||
INTEGER_USER_IND_COMMAND(vchip_comp_fe, getOnChipDAC, setOnChipDAC, stoiHex, defs::VB_COMP_FE,
|
||||
INTEGER_USER_IND_COMMAND(vchip_comp_fe, getOnChipDAC, setOnChipDAC, StringTo<int>, defs::VB_COMP_FE,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac for comparator current of analogue front end.");
|
||||
|
||||
INTEGER_USER_IND_COMMAND(vchip_opa_1st, getOnChipDAC, setOnChipDAC, stoiHex, defs::VB_OPA_1ST,
|
||||
INTEGER_USER_IND_COMMAND(vchip_opa_1st, getOnChipDAC, setOnChipDAC, StringTo<int>, defs::VB_OPA_1ST,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac for opa current for driving the other DACs in chip.");
|
||||
|
||||
INTEGER_USER_IND_COMMAND(vchip_opa_fd, getOnChipDAC, setOnChipDAC, stoiHex, defs::VB_OPA_FD,
|
||||
INTEGER_USER_IND_COMMAND(vchip_opa_fd, getOnChipDAC, setOnChipDAC, StringTo<int>, defs::VB_OPA_FD,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac current for CDS opa stage.");
|
||||
|
||||
INTEGER_USER_IND_COMMAND(vchip_comp_adc, getOnChipDAC, setOnChipDAC, stoiHex, defs::VB_COMP_ADC,
|
||||
INTEGER_USER_IND_COMMAND(vchip_comp_adc, getOnChipDAC, setOnChipDAC, StringTo<int>, defs::VB_COMP_ADC,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac for comparator current of ADC.");
|
||||
|
||||
INTEGER_USER_IND_COMMAND(vchip_ref_comp_fe, getOnChipDAC, setOnChipDAC, stoiHex, defs::VREF_COMP_FE,
|
||||
INTEGER_USER_IND_COMMAND(vchip_ref_comp_fe, getOnChipDAC, setOnChipDAC, StringTo<int>, defs::VREF_COMP_FE,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac for reference voltage of the comparator of analogue front end.");
|
||||
|
||||
INTEGER_USER_IND_COMMAND(vchip_cs, getOnChipDAC, setOnChipDAC, stoiHex, defs::VB_CS,
|
||||
INTEGER_USER_IND_COMMAND(vchip_cs, getOnChipDAC, setOnChipDAC, StringTo<int>, defs::VB_CS,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac for current injection into preamplifier.");
|
||||
|
||||
|
||||
@ -1361,19 +1368,13 @@ class CmdProxy {
|
||||
EXECUTE_SET_COMMAND_NOID(stop, stopDetector,
|
||||
"\n\tStops detector state machine.");
|
||||
|
||||
GET_COMMAND(rx_status, getReceiverStatus,
|
||||
"running, idle]\n\tReceiver listener status.");
|
||||
|
||||
GET_COMMAND(status, getDetectorStatus,
|
||||
"[running, error, transmitting, finished, waiting, idle]\n\tDetector status.");
|
||||
|
||||
GET_COMMAND(rx_framescaught, getFramesCaught,
|
||||
"\n\tNumber of frames caught by receiver.");
|
||||
|
||||
GET_COMMAND(rx_missingpackets, getNumMissingPackets,
|
||||
"\n\tNumber of missing packets for each port in receiver.");
|
||||
|
||||
INTEGER_COMMAND(startingfnum, getStartingFrameNumber, setStartingFrameNumber, std::stoull,
|
||||
INTEGER_COMMAND(startingfnum, getStartingFrameNumber, setStartingFrameNumber, StringTo<uint64_t>,
|
||||
"[n_value]\n\t[Eiger[Jungfrau] Starting frame number for next acquisition.");
|
||||
|
||||
EXECUTE_SET_COMMAND(trigger, sendSoftwareTrigger,
|
||||
@ -1382,10 +1383,10 @@ class CmdProxy {
|
||||
|
||||
/* Network Configuration (Detector<->Receiver) */
|
||||
|
||||
INTEGER_COMMAND(numinterfaces, getNumberofUDPInterfaces, setNumberofUDPInterfaces, std::stoi,
|
||||
INTEGER_COMMAND(numinterfaces, getNumberofUDPInterfaces, setNumberofUDPInterfaces, StringTo<int>,
|
||||
"[1, 2]\n\t[Jungfrau] Number of udp interfaces to stream data from detector. Default: 1.");
|
||||
|
||||
INTEGER_COMMAND(selinterface, getSelectedUDPInterface, selectUDPInterface, std::stoi,
|
||||
INTEGER_COMMAND(selinterface, getSelectedUDPInterface, selectUDPInterface, StringTo<int>,
|
||||
"[0, 1]\n\t[Jungfrau] The udp interface to stream data from detector. Effective only when number of interfaces is 1. Default: 0 (outer)");
|
||||
|
||||
INTEGER_COMMAND(udp_srcip, getSourceUDPIP, setSourceUDPIP, IpAddr,
|
||||
@ -1394,12 +1395,6 @@ class CmdProxy {
|
||||
INTEGER_COMMAND(udp_srcip2, getSourceUDPIP2, setSourceUDPIP2, IpAddr,
|
||||
"[x.x.x.x]\n\t[Jungfrau] Ip address of the bottom half of detector (source) udp interface. Must be same subnet as destination udp ip2.");
|
||||
|
||||
INTEGER_COMMAND(udp_dstip, getDestinationUDPIP, setDestinationUDPIP, IpAddr,
|
||||
"[x.x.x.x]\n\tIp address of the receiver (destination) udp interface.");
|
||||
|
||||
INTEGER_COMMAND(udp_dstip2, getDestinationUDPIP2, setDestinationUDPIP2, IpAddr,
|
||||
"[x.x.x.x]\n\t[Jungfrau] Ip address of the receiver (destination) udp interface where the second half of detector data is sent to.");
|
||||
|
||||
INTEGER_COMMAND(udp_srcmac, getSourceUDPMAC, setSourceUDPMAC, MacAddr,
|
||||
"[x:x:x:x:x:x]\n\tMac address of the detector (source) udp interface. ");
|
||||
|
||||
@ -1407,65 +1402,65 @@ class CmdProxy {
|
||||
"[x:x:x:x:x:x]\n\t[Jungfrau] Mac address of the bottom half of detector (source) udp interface. ");
|
||||
|
||||
INTEGER_COMMAND(udp_dstmac, getDestinationUDPMAC, setDestinationUDPMAC, MacAddr,
|
||||
"[x:x:x:x:x:x]\n\tMac address of the receiver (destination) udp interface. Can be unused as rx_hostname/udp_dstip retrieves it.");
|
||||
"[x:x:x:x:x:x]\n\tMac address of the receiver (destination) udp interface. Can be unused as udp_dstip retrieves it.");
|
||||
|
||||
INTEGER_COMMAND(udp_dstmac2, getDestinationUDPMAC2, setDestinationUDPMAC2, MacAddr,
|
||||
"[x:x:x:x:x:x]\n\t[Jungfrau] Mac address of the receiver (destination) udp interface where the second half of detector data is sent to. Can be unused as rx_hostname/udp_dstip2 retrieves it.");
|
||||
"[x:x:x:x:x:x]\n\t[Jungfrau] Mac address of the receiver (destination) udp interface where the second half of detector data is sent to. Can be unused as udp_dstip2 retrieves it.");
|
||||
|
||||
INTEGER_COMMAND(udp_dstport, getDestinationUDPPort, setDestinationUDPPort, std::stoi,
|
||||
INTEGER_COMMAND(udp_dstport, getDestinationUDPPort, setDestinationUDPPort, StringTo<int>,
|
||||
"[n]\n\tPort number of the receiver (destination) udp interface. Default is 50001.");
|
||||
|
||||
INTEGER_COMMAND(udp_dstport2, getDestinationUDPPort2, setDestinationUDPPort2, std::stoi,
|
||||
INTEGER_COMMAND(udp_dstport2, getDestinationUDPPort2, setDestinationUDPPort2, StringTo<int>,
|
||||
"[n]\n\tDefault is 50002.\n\t[Jungfrau] Port number of the receiver (destination) udp interface where the second half of detector data is sent to. \n[Eiger] Port number of the reciever (desintation) udp interface where the right half of the detector data is sent to.");
|
||||
|
||||
GET_COMMAND(rx_printconfig, printRxConfiguration,
|
||||
"\n\tPrints the receiver configuration.");
|
||||
|
||||
INTEGER_COMMAND(tengiga, getTenGiga, setTenGiga, std::stoi,
|
||||
INTEGER_COMMAND(tengiga, getTenGiga, setTenGiga, StringTo<int>,
|
||||
"[0, 1]\n\t[Eiger][Ctb][Moench] 10GbE Enable.");
|
||||
|
||||
INTEGER_COMMAND(flowcontrol10g, getTenGigaFlowControl, setTenGigaFlowControl, std::stoi,
|
||||
INTEGER_COMMAND(flowcontrol10g, getTenGigaFlowControl, setTenGigaFlowControl, StringTo<int>,
|
||||
"[0, 1]\n\t[Eiger][Jungfrau] 10GbE Flow Control.");
|
||||
|
||||
INTEGER_COMMAND(txndelay_frame, getTransmissionDelayFrame, setTransmissionDelayFrame, std::stoi,
|
||||
INTEGER_COMMAND(txndelay_frame, getTransmissionDelayFrame, setTransmissionDelayFrame, StringTo<int>,
|
||||
"[n_delay]\n\t[Eiger][Jungfrau] Transmission delay of each image being streamed out of the module.\n\t[Jungfrau] [0-31] Each value represents 1 ms\n\t[Eiger] Additional delay to txndelay_left and txndelay_right. Each value represents 10ns. Typical value is 50000.");
|
||||
|
||||
INTEGER_COMMAND(txndelay_left, getTransmissionDelayLeft, setTransmissionDelayLeft, std::stoi,
|
||||
INTEGER_COMMAND(txndelay_left, getTransmissionDelayLeft, setTransmissionDelayLeft, StringTo<int>,
|
||||
"[n_delay]\n\t[Eiger] Transmission delay of first packet in an image being streamed out of the module's left UDP port. Each value represents 10ns. Typical value is 50000.");
|
||||
|
||||
INTEGER_COMMAND(txndelay_right, getTransmissionDelayRight, setTransmissionDelayRight, std::stoi,
|
||||
INTEGER_COMMAND(txndelay_right, getTransmissionDelayRight, setTransmissionDelayRight, StringTo<int>,
|
||||
"[n_delay]\n\t[Eiger] Transmission delay of first packet in an image being streamed out of the module's right UDP port. Each value represents 10ns. Typical value is 50000.");
|
||||
|
||||
|
||||
/* Receiver Config */
|
||||
|
||||
STRING_COMMAND(rx_hostname, getRxHostname, setRxHostname,
|
||||
"[hostname or ip address]\n\tReceiver hostname or IP. Used for TCP control communication between client and receiver to configure receiver.");
|
||||
|
||||
INTEGER_COMMAND(rx_tcpport, getRxPort, setRxPort, std::stoi,
|
||||
INTEGER_IND_COMMAND(rx_tcpport, getRxPort, setRxPort, StringTo<int>, 1,
|
||||
"[port]\n\tTCP port for client-receiver communication. Default is 1954. Must be different if multiple receivers on same pc. Must be first command to set a receiver parameter. Multi command will automatically increment for individual modules.");
|
||||
|
||||
INTEGER_IND_COMMAND(rx_tcpport2, getRxPort, setRxPort, StringTo<int>, 2,
|
||||
"[port]\n\t[Eiger][Jungfrau] TCP port for client-receiver communication for 2nd udp port. For details, refer rx_tcpport.");
|
||||
|
||||
INTEGER_COMMAND(rx_fifodepth, getRxFifoDepth, setRxFifoDepth, std::stoi,
|
||||
INTEGER_COMMAND(rx_fifodepth, getRxFifoDepth, setRxFifoDepth, StringTo<int>,
|
||||
"[n_frames]\n\tSet the number of frames in the receiver fifo (buffer between listener and writer threads).");
|
||||
|
||||
INTEGER_COMMAND(rx_silent, getRxSilentMode, setRxSilentMode, std::stoi,
|
||||
INTEGER_COMMAND(rx_silent, getRxSilentMode, setRxSilentMode, StringTo<int>,
|
||||
"[0, 1]\n\tSwitch on or off receiver text output during acquisition.");
|
||||
|
||||
INTEGER_COMMAND(rx_discardpolicy, getRxFrameDiscardPolicy, setRxFrameDiscardPolicy, sls::StringTo<slsDetectorDefs::frameDiscardPolicy>,
|
||||
"[nodiscard (default)|discardempty|discardpartial(fastest)]\n\tFrame discard policy of receiver. nodiscard does not discard frames, discardempty discards empty frames, discardpartial discards partial frames.");
|
||||
|
||||
INTEGER_COMMAND(rx_padding, getPartialFramesPadding, setPartialFramesPadding, std::stoi,
|
||||
INTEGER_COMMAND(rx_padding, getPartialFramesPadding, setPartialFramesPadding, StringTo<int>,
|
||||
"[0, 1]\n\tPartial frames padding enable in the "
|
||||
"receiver. 0 does not pad partial frames(fastest), 1 "
|
||||
"(default) pads partial frames");
|
||||
|
||||
INTEGER_COMMAND(rx_udpsocksize, getRxUDPSocketBufferSize, setRxUDPSocketBufferSize, std::stol,
|
||||
INTEGER_COMMAND(rx_udpsocksize, getRxUDPSocketBufferSize, setRxUDPSocketBufferSize, StringTo<int64_t>,
|
||||
"[n_size]\n\tUDP socket buffer size in receiver. Tune rmem_default and rmem_max accordingly. rx_hostname sets it to defaults.");
|
||||
|
||||
GET_COMMAND(rx_realudpsocksize, getRxRealUDPSocketBufferSize,
|
||||
"\n\tActual udp socket buffer size. Double the size of rx_udpsocksize due to kernel bookkeeping.");
|
||||
|
||||
INTEGER_COMMAND(rx_lock, getRxLock, setRxLock, std::stoi,
|
||||
INTEGER_COMMAND(rx_lock, getRxLock, setRxLock, StringTo<int>,
|
||||
"[0, 1]\n\tLock receiver to one IP, 1: locks");
|
||||
|
||||
GET_COMMAND(rx_lastclient, getRxLastClientIP,
|
||||
@ -1483,35 +1478,35 @@ class CmdProxy {
|
||||
STRING_COMMAND(fname, getFileNamePrefix, setFileNamePrefix,
|
||||
"[path]\n\tFile name prefix for output data file. Default is run. File name: [file name prefix]_d[detector index]_f[sub file index]_[acquisition/file index].raw.");
|
||||
|
||||
INTEGER_COMMAND(findex, getAcquisitionIndex, setAcquisitionIndex, std::stol,
|
||||
INTEGER_COMMAND(findex, getAcquisitionIndex, setAcquisitionIndex, StringTo<int64_t>,
|
||||
"[0, 1]\n\tFile or Acquisition index.");
|
||||
|
||||
INTEGER_COMMAND(fwrite, getFileWrite, setFileWrite, std::stoi,
|
||||
INTEGER_COMMAND(fwrite, getFileWrite, setFileWrite, StringTo<int>,
|
||||
"[0, 1]\n\tEnable or disable receiver file write. Default is 1.");
|
||||
|
||||
INTEGER_COMMAND_NOID(fmaster, getMasterFileWrite, setMasterFileWrite, std::stoi,
|
||||
INTEGER_COMMAND_NOID(fmaster, getMasterFileWrite, setMasterFileWrite, StringTo<int>,
|
||||
"[0, 1]\n\tEnable or disable receiver master file. Default is 1.");
|
||||
|
||||
INTEGER_COMMAND(foverwrite, getFileOverWrite, setFileOverWrite, std::stoi,
|
||||
INTEGER_COMMAND(foverwrite, getFileOverWrite, setFileOverWrite, StringTo<int>,
|
||||
"[0, 1]\n\tEnable or disable file overwriting. Default is 1.");
|
||||
|
||||
INTEGER_COMMAND(rx_framesperfile, getFramesPerFile, setFramesPerFile, std::stoi,
|
||||
INTEGER_COMMAND(rx_framesperfile, getFramesPerFile, setFramesPerFile, StringTo<int>,
|
||||
"[n_frames]\n\tNumber of frames per file in receiver. 0 is infinite or all frames in single file.");
|
||||
|
||||
|
||||
/* ZMQ Streaming Parameters (Receiver<->Client) */
|
||||
|
||||
INTEGER_COMMAND(rx_datastream, getRxZmqDataStream, setRxZmqDataStream, std::stoi,
|
||||
INTEGER_COMMAND(rx_datastream, getRxZmqDataStream, setRxZmqDataStream, StringTo<int>,
|
||||
"[0, 1]\n\tData streaming from receiver enable (eg. to GUI ot another process for further processing). 1 enables zmq data stream (creates zmq streamer threads), 0 disables (destroys streamer threads). Switching to Gui automatically enables data streaming in receiver. Switching back to command line acquire will require disabling data streaming in receiver for fast applications.");
|
||||
|
||||
INTEGER_COMMAND(rx_readfreq, getRxZmqFrequency, setRxZmqFrequency,
|
||||
std::stoi, "[nth frame]\n\tStream out every nth frame. Default is 1. 0 means streaming every 200 ms and discarding frames in this interval.");
|
||||
StringTo<int>, "[nth frame]\n\tStream out every nth frame. Default is 1. 0 means streaming every 200 ms and discarding frames in this interval.");
|
||||
|
||||
INTEGER_COMMAND(rx_zmqport, getRxZmqPort, setRxZmqPort,
|
||||
std::stoi, "[port]\n\tZmq port for data to be streamed out of the receiver. Also restarts receiver zmq streaming if enabled. Default is 30001. Modified only when using an intermediate process between receiver and client(gui). Must be different for every detector (and udp port). Multi command will automatically increment for individual modules.");
|
||||
StringTo<int>, "[port]\n\tZmq port for data to be streamed out of the receiver. Also restarts receiver zmq streaming if enabled. Default is 30001. Modified only when using an intermediate process between receiver and client(gui). Must be different for every detector (and udp port). Multi command will automatically increment for individual modules.");
|
||||
|
||||
INTEGER_COMMAND(zmqport, getClientZmqPort, setClientZmqPort,
|
||||
std::stoi, "[port]\n\tZmq port in client(gui) or intermediate process for data to be streamed to from receiver. efault connects to receiver zmq streaming out port (30001). Modified only when using an intermediate process between receiver and client(gui). Also restarts client zmq streaming if enabled. Must be different for every detector (and udp port). Multi command will automatically increment for individual modules.");
|
||||
StringTo<int>, "[port]\n\tZmq port in client(gui) or intermediate process for data to be streamed to from receiver. efault connects to receiver zmq streaming out port (30001). Modified only when using an intermediate process between receiver and client(gui). Also restarts client zmq streaming if enabled. Must be different for every detector (and udp port). Multi command will automatically increment for individual modules.");
|
||||
|
||||
INTEGER_COMMAND(rx_zmqip, getRxZmqIP, setRxZmqIP, IpAddr,
|
||||
"[x.x.x.x]\n\tZmq Ip Address from which data is to be streamed out of the receiver. Also restarts receiver zmq streaming if enabled. Default is from rx_hostname. Modified only when using an intermediate process between receiver and client(gui).");
|
||||
@ -1534,25 +1529,25 @@ class CmdProxy {
|
||||
EXECUTE_SET_COMMAND_NOID_1ARG(trimbits, loadTrimbits,
|
||||
"[fname]\n\t[Eiger] Loads the trimbit file to detector. If no extension specified, serial number of each module is attached.");
|
||||
|
||||
INTEGER_COMMAND(parallel, getParallelMode, setParallelMode, std::stoi,
|
||||
INTEGER_COMMAND(parallel, getParallelMode, setParallelMode, StringTo<int>,
|
||||
"[0, 1]\n\t[Eiger] Enable or disable parallel mode.");
|
||||
|
||||
INTEGER_COMMAND(overflow, getOverFlowMode, setOverFlowMode, std::stoi,
|
||||
INTEGER_COMMAND(overflow, getOverFlowMode, setOverFlowMode, StringTo<int>,
|
||||
"[0, 1]\n\t[Eiger] Enable or disable show overflow flag in 32 bit mode.");
|
||||
|
||||
INTEGER_COMMAND(storeinram, getStoreInRamMode, setStoreInRamMode, std::stoi,
|
||||
INTEGER_COMMAND(storeinram, getStoreInRamMode, setStoreInRamMode, StringTo<int>,
|
||||
"[0, 1]\n\t[Eiger] Enable or disable store in ram mode.");
|
||||
|
||||
INTEGER_COMMAND(flippeddatax, getBottom, setBottom, std::stoi,
|
||||
"[0, 1]\n\t[Eiger] Top or Bottom Half of Eiger module. 1 is bottom, 0 is top. Used to let Receiver and Gui know to flip the bottom image over the x axis.");
|
||||
INTEGER_COMMAND(flippeddatax, getBottom, setBottom, StringTo<int>,
|
||||
"[0, 1]\n\t[Eiger] Top or Bottom Half of Eiger module. 1 is bottom, 0 is top. Used to let Receivers and Gui know to flip the bottom image over the x axis. Files are not written without the flip however.");
|
||||
|
||||
INTEGER_COMMAND(trimval, getAllTrimbits, setAllTrimbits, std::stoi,
|
||||
INTEGER_COMMAND(trimval, getAllTrimbits, setAllTrimbits, StringTo<int>,
|
||||
"[n_trimval]\n\t[Eiger] All trimbits set to this value. A get returns -1 if all trimbits are different values.");
|
||||
|
||||
INTEGER_COMMAND(readnlines, getPartialReadout, setPartialReadout, std::stoi,
|
||||
INTEGER_COMMAND(readnlines, getPartialReadout, setPartialReadout, StringTo<int>,
|
||||
"[1 - 256]\n\t[Eiger] Number of rows to readout per half module starting from the centre. 256 is default. The permissible values depend on dynamic range and 10Gbe enabled.");
|
||||
|
||||
INTEGER_COMMAND(interruptsubframe, getInterruptSubframe, setInterruptSubframe, std::stoi,
|
||||
INTEGER_COMMAND(interruptsubframe, getInterruptSubframe, setInterruptSubframe, StringTo<int>,
|
||||
"[0, 1]\n\t[Eiger] 1 interrupts last subframe at required exposure time. 0 will wait for last sub frame to finish exposing. 0 is default.");
|
||||
|
||||
TIME_GET_COMMAND(measuredperiod, getMeasuredPeriod,
|
||||
@ -1561,25 +1556,25 @@ class CmdProxy {
|
||||
TIME_GET_COMMAND(measuredsubperiod, getMeasuredSubFramePeriod,
|
||||
"[(optional unit) ns|us|ms|s]\n\t[Eiger] Measured sub frame period between last sub frame and previous one.");
|
||||
|
||||
INTEGER_COMMAND(partialreset, getPartialReset, setPartialReset, std::stoi,
|
||||
INTEGER_COMMAND(partialreset, getPartialReset, setPartialReset, StringTo<int>,
|
||||
"[0, 1]\n\t[Eiger] Sets up detector to do partial or complete reset at start of acquisition. 0 complete reset, 1 partial reset.");
|
||||
|
||||
|
||||
/* Jungfrau Specific */
|
||||
|
||||
INTEGER_COMMAND(temp_threshold, getThresholdTemperature, setThresholdTemperature, std::stoi,
|
||||
INTEGER_COMMAND(temp_threshold, getThresholdTemperature, setThresholdTemperature, StringTo<int>,
|
||||
"[n_temp (in degrees)]\n\t[Jungfrau] Threshold temperature in degrees. If temperature crosses threshold temperature and temperature control is enabled, power to chip will be switched off and temperature event occurs. To power on chip again, temperature has to be less than threshold temperature and temperature event has to be cleared.");
|
||||
|
||||
INTEGER_COMMAND(temp_control, getTemperatureControl, setTemperatureControl, std::stoi,
|
||||
INTEGER_COMMAND(temp_control, getTemperatureControl, setTemperatureControl, StringTo<int>,
|
||||
"[0, 1]\n\t[Jungfrau] Temperature control enable. Default is 0 (disabled). If temperature crosses threshold temperature and temperature control is enabled, power to chip will be switched off and temperature event occurs. To power on chip again, temperature has to be less than threshold temperature and temperature event has to be cleared.");
|
||||
|
||||
INTEGER_COMMAND(auto_comp_disable, getAutoCompDisable, setAutoCompDisable, std::stoi,
|
||||
INTEGER_COMMAND(auto_comp_disable, getAutoCompDisable, setAutoCompDisable, StringTo<int>,
|
||||
"[0, 1]\n\t[Jungfrau] Auto comparator disable mode. Default 0 or this mode disabled(comparator enabled throughout). 1 enables mode. 0 disables mode. This mode disables the on-chip gain switching comparator automatically after 93.75% of exposure time (only for longer than 100us).");
|
||||
|
||||
INTEGER_COMMAND_NOID(storagecells, getNumberOfAdditionalStorageCells, setNumberOfAdditionalStorageCells, std::stoi,
|
||||
INTEGER_COMMAND_NOID(storagecells, getNumberOfAdditionalStorageCells, setNumberOfAdditionalStorageCells, StringTo<int>,
|
||||
"[0-15]\n\t[Jungfrau] Number of additional storage cells. Default is 0. For advanced users only. \n\tThe #images = #frames x #triggers x (#storagecells + 1).");
|
||||
|
||||
INTEGER_COMMAND(storagecell_start, getStorageCellStart, setStoragecellStart, std::stoi,
|
||||
INTEGER_COMMAND(storagecell_start, getStorageCellStart, setStoragecellStart, StringTo<int>,
|
||||
"[0-15]\n\t[Jungfrau] Storage cell that stores the first acquisition of the series. Default is 15. For advanced users only.");
|
||||
|
||||
TIME_COMMAND(storagecell_delay, getStorageCellDelay, setStorageCellDelay,
|
||||
@ -1593,11 +1588,12 @@ class CmdProxy {
|
||||
INTEGER_COMMAND(extsig, getExternalSignalFlags, setExternalSignalFlags, sls::StringTo<slsDetectorDefs::externalSignalFlag>,
|
||||
"[trigger_in_rising_edge|trigger_in_falling_edge]\n\t[Gotthard] External signal mode for trigger timing mode.");
|
||||
|
||||
INTEGER_COMMAND(imagetest, getImageTestMode, setImageTestMode, std::stoi,
|
||||
"[0, 1]\n\t[Gotthard] 1 adds channel intensity with precalculated values when taking an acquisition. Default is 0.");
|
||||
|
||||
/* Gotthard2 Specific */
|
||||
INTEGER_COMMAND(currentsource, getCurrentSource, setCurrentSource, std::stoi,
|
||||
INTEGER_COMMAND_NOID(bursts, getNumberOfBursts, setNumberOfBursts,
|
||||
StringTo<int64_t>,
|
||||
"[n_bursts]\n\t[Gotthard2] Number of bursts per aquire. Only in auto timing mode and burst mode. Use timing command to set timing mode and burstmode command to set burst mode.");
|
||||
|
||||
INTEGER_COMMAND(currentsource, getCurrentSource, setCurrentSource, StringTo<int>,
|
||||
"[0, 1]\n\t[Gotthard2] Enable or disable current source. Default is disabled.");
|
||||
|
||||
INTEGER_COMMAND(timingsource, getTimingSource, setTimingSource, sls::StringTo<slsDetectorDefs::timingSourceType>,
|
||||
@ -1607,61 +1603,61 @@ class CmdProxy {
|
||||
|
||||
/* CTB/ Moench Specific */
|
||||
|
||||
INTEGER_COMMAND(asamples, getNumberOfAnalogSamples, setNumberOfAnalogSamples, std::stoi,
|
||||
INTEGER_COMMAND(asamples, getNumberOfAnalogSamples, setNumberOfAnalogSamples, StringTo<int>,
|
||||
"[0, 1]\n\t[CTB][Moench] Number of analog samples expected.");
|
||||
|
||||
INTEGER_COMMAND(adcclk, getADCClock, setADCClock, std::stoi,
|
||||
INTEGER_COMMAND(adcclk, getADCClock, setADCClock, StringTo<int>,
|
||||
"[n_clk in MHz]\n\t[Ctb][Moench] ADC clock frequency in MHz.");
|
||||
|
||||
INTEGER_COMMAND(runclk, getRUNClock, setRUNClock, std::stoi,
|
||||
INTEGER_COMMAND(runclk, getRUNClock, setRUNClock, StringTo<int>,
|
||||
"[n_clk in MHz]\n\t[Ctb][Moench] Run clock in MHz.");
|
||||
|
||||
GET_COMMAND(syncclk, getSYNCClock,
|
||||
"[n_clk in MHz]\n\t[Ctb][Moench] Sync clock in MHz.");
|
||||
|
||||
INTEGER_COMMAND(adcpipeline, getADCPipeline, setADCPipeline, std::stoi,
|
||||
INTEGER_COMMAND(adcpipeline, getADCPipeline, setADCPipeline, StringTo<int>,
|
||||
"[n_value]\n\t[Ctb][Moench] Pipeline for ADC clock.");
|
||||
|
||||
INTEGER_IND_COMMAND(v_limit, getVoltage, setVoltage, std::stoi, defs::V_LIMIT,
|
||||
INTEGER_IND_COMMAND(v_limit, getVoltage, setVoltage, StringTo<int>, defs::V_LIMIT,
|
||||
"[n_value]\n\t[Ctb][Moench] Soft limit for power supplies(ctb only) and DACS in mV.");
|
||||
|
||||
INTEGER_COMMAND_HEX(adcenable, getADCEnableMask, setADCEnableMask, stoiHex,
|
||||
INTEGER_COMMAND_HEX(adcenable, getADCEnableMask, setADCEnableMask, StringTo<uint32_t>,
|
||||
"[bitmask]\n\t[Ctb][Moench] ADC Enable Mask for 1Gb Mode for each 32 ADC channel.");
|
||||
|
||||
INTEGER_COMMAND_HEX(adcenable10g, getTenGigaADCEnableMask, setTenGigaADCEnableMask, stoiHex,
|
||||
INTEGER_COMMAND_HEX(adcenable10g, getTenGigaADCEnableMask, setTenGigaADCEnableMask, StringTo<uint32_t>,
|
||||
"[bitmask]\n\t[Ctb][Moench] ADC Enable Mask for 10Gb mode for each 32 ADC channel. However, if any of consecutive 4 bits are enabled, the complete 4 bits are enabled.");
|
||||
|
||||
/* CTB Specific */
|
||||
|
||||
|
||||
INTEGER_COMMAND(dsamples, getNumberOfDigitalSamples, setNumberOfDigitalSamples, std::stoi,
|
||||
INTEGER_COMMAND(dsamples, getNumberOfDigitalSamples, setNumberOfDigitalSamples, StringTo<int>,
|
||||
"[0, 1]\n\t[CTB] Number of digital samples expected.");
|
||||
|
||||
INTEGER_COMMAND(romode, getReadoutMode, setReadoutMode, sls::StringTo<slsDetectorDefs::readoutMode>,
|
||||
"[analog|digital|analog_digital]\n\t[CTB] Readout mode. Default is analog.");
|
||||
|
||||
INTEGER_COMMAND(dbitclk, getDBITClock, setDBITClock, std::stoi,
|
||||
INTEGER_COMMAND(dbitclk, getDBITClock, setDBITClock, StringTo<int>,
|
||||
"[n_clk in MHz]\n\t[Ctb] Clock for latching the digital bits in MHz.");
|
||||
|
||||
INTEGER_COMMAND(dbitpipeline, getDBITPipeline, setDBITPipeline, std::stoi,
|
||||
INTEGER_COMMAND(dbitpipeline, getDBITPipeline, setDBITPipeline, StringTo<int>,
|
||||
"[n_value]\n\t[Ctb] Pipeline of the clock for latching digital bits.");
|
||||
|
||||
INTEGER_IND_COMMAND(v_a, getVoltage, setVoltage, std::stoi, defs::V_POWER_A,
|
||||
INTEGER_IND_COMMAND(v_a, getVoltage, setVoltage, StringTo<int>, defs::V_POWER_A,
|
||||
"[n_value]\n\t[Ctb] Voltage supply a in mV.");
|
||||
|
||||
INTEGER_IND_COMMAND(v_b, getVoltage, setVoltage, std::stoi, defs::V_POWER_B,
|
||||
INTEGER_IND_COMMAND(v_b, getVoltage, setVoltage, StringTo<int>, defs::V_POWER_B,
|
||||
"[n_value]\n\t[Ctb] Voltage supply b in mV.");
|
||||
|
||||
INTEGER_IND_COMMAND(v_c, getVoltage, setVoltage, std::stoi, defs::V_POWER_C,
|
||||
INTEGER_IND_COMMAND(v_c, getVoltage, setVoltage, StringTo<int>, defs::V_POWER_C,
|
||||
"[n_value]\n\t[Ctb] Voltage supply c in mV.");
|
||||
|
||||
INTEGER_IND_COMMAND(v_d, getVoltage, setVoltage, std::stoi, defs::V_POWER_D,
|
||||
INTEGER_IND_COMMAND(v_d, getVoltage, setVoltage, StringTo<int>, defs::V_POWER_D,
|
||||
"[n_value]\n\t[Ctb] Voltage supply d in mV.");
|
||||
|
||||
INTEGER_IND_COMMAND(v_io, getVoltage, setVoltage, std::stoi, defs::V_POWER_IO,
|
||||
INTEGER_IND_COMMAND(v_io, getVoltage, setVoltage, StringTo<int>, defs::V_POWER_IO,
|
||||
"[n_value]\n\t[Ctb] Voltage supply io in mV. Minimum 1200 mV. Must be the first power regulator to be set after fpga reset (on-board detector server start up).");
|
||||
|
||||
INTEGER_IND_COMMAND(v_chip, getVoltage, setVoltage, std::stoi, defs::V_POWER_CHIP,
|
||||
INTEGER_IND_COMMAND(v_chip, getVoltage, setVoltage, StringTo<int>, defs::V_POWER_CHIP,
|
||||
"[n_value]\n\t[Ctb] Voltage supply chip in mV. Do not use it unless you are completely sure you will not fry the board.");
|
||||
|
||||
GET_IND_COMMAND(vm_a, getMeasuredVoltage, defs::V_POWER_A, "",
|
||||
@ -1694,16 +1690,16 @@ class CmdProxy {
|
||||
GET_IND_COMMAND(im_io, getMeasuredCurrent, defs::I_POWER_IO, "",
|
||||
"\n\t[Ctb] Measured current of power supply io in mA.");
|
||||
|
||||
INTEGER_COMMAND(extsampling, getExternalSampling, setExternalSampling, std::stoi,
|
||||
INTEGER_COMMAND(extsampling, getExternalSampling, setExternalSampling, StringTo<int>,
|
||||
"[0, 1]\n\t[Ctb] Enable for external sampling signal to extsamplingsrc signal for digital data. For advanced users only.");
|
||||
|
||||
INTEGER_COMMAND(extsamplingsrc, getExternalSamplingSource, setExternalSamplingSource, std::stoi,
|
||||
INTEGER_COMMAND(extsamplingsrc, getExternalSamplingSource, setExternalSamplingSource, StringTo<int>,
|
||||
"[0-63]\n\t[Ctb] Sampling source signal for digital data. For advanced users only.");
|
||||
|
||||
INTEGER_COMMAND(rx_dbitoffset, getRxDbitOffset, setRxDbitOffset, std::stoi,
|
||||
INTEGER_COMMAND(rx_dbitoffset, getRxDbitOffset, setRxDbitOffset, StringTo<int>,
|
||||
"[n_bytes]\n\t[Ctb] Offset in bytes in digital data in receiver.");
|
||||
|
||||
INTEGER_COMMAND(led, getLEDEnable, setLEDEnable, std::stoi,
|
||||
INTEGER_COMMAND(led, getLEDEnable, setLEDEnable, StringTo<int>,
|
||||
"[0, 1]\n\t[Ctb] Switches on/off all LEDs.");
|
||||
|
||||
|
||||
@ -1712,23 +1708,20 @@ class CmdProxy {
|
||||
EXECUTE_SET_COMMAND_NOID_1ARG(savepattern, savePattern,
|
||||
"[fname]\n\t[Ctb][Moench][Mythen3] Saves pattern to file (ascii). Also executes pattern.");
|
||||
|
||||
INTEGER_COMMAND_HEX(patioctrl, getPatternIOControl, setPatternIOControl, stoulHex,
|
||||
INTEGER_COMMAND_HEX(patioctrl, getPatternIOControl, setPatternIOControl, StringTo<uint64_t>,
|
||||
"[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit mask defining input (0) and output (1) signals.");
|
||||
|
||||
INTEGER_COMMAND_HEX(patclkctrl, getPatternClockControl, setPatternClockControl, stoulHex,
|
||||
INTEGER_COMMAND_HEX(patclkctrl, getPatternClockControl, setPatternClockControl, StringTo<uint64_t>,
|
||||
"[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit mask defining output clock enable.");
|
||||
|
||||
INTEGER_COMMAND_HEX(patmask, getPatternMask, setPatternMask, stoulHex,
|
||||
INTEGER_COMMAND_HEX(patmask, getPatternMask, setPatternMask, StringTo<uint64_t>,
|
||||
"[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit mask applied to every pattern. Only these bits for each pattern will be masked against.");
|
||||
|
||||
INTEGER_COMMAND_HEX(patsetbit, getPatternBitMask, setPatternBitMask, stoulHex,
|
||||
INTEGER_COMMAND_HEX(patsetbit, getPatternBitMask, setPatternBitMask, StringTo<uint64_t>,
|
||||
"[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit values applied to the selected patmask for every pattern.");
|
||||
|
||||
/* Moench */
|
||||
|
||||
STRING_COMMAND(rx_jsonaddheader, getAdditionalJsonHeader, setAdditionalJsonHeader,
|
||||
"[\"label1\":\"value1\"], [\"label2\":\"value2\"]\n\tAdditional json header to be streamd out from receiver via zmq. Default is empty. Use only if to be processed by an intermediate user process listening to receiver zmq packets.");
|
||||
|
||||
INTEGER_COMMAND(framemode, getFrameMode, setFrameMode, sls::StringTo<slsDetectorDefs::frameModeType>,
|
||||
"[pedestal|newpedestal|flatfield|newflatfield]\n\t[Moench] Frame mode (soft setting) in processor.");
|
||||
|
||||
@ -1750,18 +1743,18 @@ class CmdProxy {
|
||||
EXECUTE_SET_COMMAND(bustest, executeBusTest,
|
||||
"\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb][Moench] Bus test, ie. keeps writing and reading back different values in R/W register.");
|
||||
|
||||
INTEGER_COMMAND_HEX(adcinvert, getADCInvert, setADCInvert, stoiHex,
|
||||
INTEGER_COMMAND_HEX(adcinvert, getADCInvert, setADCInvert, StringTo<uint32_t>,
|
||||
"[bitmask]\n\t[Ctb][Moench][Jungfrau][Moench] ADC Inversion Mask.\n\t[Jungfrau][Moench] Inversions on top of the default mask.");
|
||||
|
||||
/* Insignificant */
|
||||
|
||||
INTEGER_COMMAND(port, getControlPort, setControlPort, std::stoi,
|
||||
INTEGER_COMMAND(port, getControlPort, setControlPort, StringTo<int>,
|
||||
"[n]\n\tPort number of the control server on detector for detector-client tcp interface. Default is 1952. Normally unchanged.");
|
||||
|
||||
INTEGER_COMMAND(stopport, getStopPort, setStopPort, std::stoi,
|
||||
INTEGER_COMMAND(stopport, getStopPort, setStopPort, StringTo<int>,
|
||||
"[n]\n\tPort number of the stop server on detector for detector-client tcp interface. Default is 1953. Normally unchanged.");
|
||||
|
||||
INTEGER_COMMAND(lock, getDetectorLock, setDetectorLock, std::stoi,
|
||||
INTEGER_COMMAND(lock, getDetectorLock, setDetectorLock, StringTo<int>,
|
||||
"[0, 1]\n\tLock detector to one IP, 1: locks");
|
||||
|
||||
GET_COMMAND(lastclient, getLastClientIP,
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,6 @@
|
||||
#include "logger.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
class ZmqSocket;
|
||||
class detectorData;
|
||||
|
||||
#include <memory>
|
||||
@ -15,8 +14,8 @@ class detectorData;
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#define MULTI_SHMAPIVERSION 0x190809
|
||||
#define MULTI_SHMVERSION 0x200131
|
||||
#define DETECTOR_SHMAPIVERSION 0x190809
|
||||
#define DETECTOR_SHMVERSION 0x200319
|
||||
#define SHORT_STRING_LENGTH 50
|
||||
|
||||
#include <future>
|
||||
@ -25,12 +24,13 @@ class detectorData;
|
||||
namespace sls{
|
||||
|
||||
class Module;
|
||||
class Receiver;
|
||||
|
||||
/**
|
||||
* @short structure allocated in shared memory to store detector settings
|
||||
* for IPC and cache
|
||||
*/
|
||||
struct sharedMultiSlsDetector {
|
||||
struct sharedDetector {
|
||||
|
||||
/* FIXED PATTERN FOR STATIC FUNCTIONS. DO NOT CHANGE, ONLY APPEND
|
||||
* ------*/
|
||||
@ -47,10 +47,7 @@ struct sharedMultiSlsDetector {
|
||||
/** last time stamp when accessing the shared memory */
|
||||
char lastDate[SHORT_STRING_LENGTH];
|
||||
|
||||
/** number of sls detectors in shared memory */
|
||||
int numberOfDetectors;
|
||||
|
||||
/** multi detector type */
|
||||
int numberOfModules;
|
||||
slsDetectorDefs::detectorType multiDetectorType;
|
||||
|
||||
/** END OF FIXED PATTERN
|
||||
@ -62,23 +59,21 @@ struct sharedMultiSlsDetector {
|
||||
/** max number of channels for complete detector*/
|
||||
slsDetectorDefs::xy numberOfChannels;
|
||||
|
||||
/** flag for acquiring */
|
||||
bool acquiringFlag;
|
||||
|
||||
/** initial checks */
|
||||
bool initialChecks;
|
||||
bool gapPixels;
|
||||
};
|
||||
|
||||
class DetectorImpl : public virtual slsDetectorDefs {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
* @param id multi detector id
|
||||
* @param detector_id multi detector id
|
||||
* @param verify true to verify if shared memory version matches existing
|
||||
* one
|
||||
* @param update true to update last user pid, date etc
|
||||
*/
|
||||
explicit DetectorImpl(int multi_id = 0, bool verify = true,
|
||||
explicit DetectorImpl(int detector_id = 0, bool verify = true,
|
||||
bool update = true);
|
||||
|
||||
/**
|
||||
@ -194,14 +189,460 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template <typename RT, typename... CT>
|
||||
sls::Result<RT> Parallel1(RT (sls::Receiver::*somefunc)(CT...),
|
||||
std::vector<int> dPositions,
|
||||
std::vector<int> rxPositions,
|
||||
typename NonDeduced<CT>::type... Args) {
|
||||
|
||||
if (receivers.size() == 0)
|
||||
throw sls::RuntimeError("No receivers added");
|
||||
if (dPositions.empty() ||
|
||||
(dPositions.size() == 1 && dPositions[0] == -1)) {
|
||||
dPositions.resize(receivers.size());
|
||||
std::iota(begin(dPositions), end(dPositions), 0);
|
||||
}
|
||||
if (rxPositions.empty() ||
|
||||
(rxPositions.size() == 1 && rxPositions[0] == -1)) {
|
||||
rxPositions.resize(receivers[0].size());
|
||||
std::iota(begin(rxPositions), end(rxPositions), 0);
|
||||
}
|
||||
std::vector<std::future<RT>> futures;
|
||||
futures.reserve(dPositions.size() * rxPositions.size());
|
||||
for (size_t i : dPositions) {
|
||||
if (i >= receivers.size())
|
||||
throw sls::RuntimeError("Detector out of range");
|
||||
// each entry
|
||||
for (size_t j : rxPositions) {
|
||||
futures.push_back(std::async(std::launch::async, somefunc,
|
||||
receivers[i][j].get(), Args...));
|
||||
}
|
||||
}
|
||||
sls::Result<RT> result;
|
||||
result.reserve(dPositions.size() * rxPositions.size());
|
||||
for (auto &i : futures) {
|
||||
result.push_back(i.get());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename RT, typename... CT>
|
||||
sls::Result<RT> Parallel1(RT (sls::Receiver::*somefunc)(CT...) const,
|
||||
std::vector<int> dPositions,
|
||||
std::vector<int> rxPositions,
|
||||
typename NonDeduced<CT>::type... Args) const {
|
||||
|
||||
if (receivers.size() == 0)
|
||||
throw sls::RuntimeError("No receivers added");
|
||||
if (dPositions.empty() ||
|
||||
(dPositions.size() == 1 && dPositions[0] == -1)) {
|
||||
dPositions.resize(receivers.size());
|
||||
std::iota(begin(dPositions), end(dPositions), 0);
|
||||
}
|
||||
if (rxPositions.empty() ||
|
||||
(rxPositions.size() == 1 && rxPositions[0] == -1)) {
|
||||
rxPositions.resize(receivers[0].size());
|
||||
std::iota(begin(rxPositions), end(rxPositions), 0);
|
||||
}
|
||||
std::vector<std::future<RT>> futures;
|
||||
futures.reserve(dPositions.size() * rxPositions.size());
|
||||
for (size_t i : dPositions) {
|
||||
if (i >= receivers.size())
|
||||
throw sls::RuntimeError("Detector out of range");
|
||||
// each entry
|
||||
for (size_t j : rxPositions) {
|
||||
futures.push_back(std::async(std::launch::async, somefunc,
|
||||
receivers[i][j].get(), Args...));
|
||||
}
|
||||
}
|
||||
sls::Result<RT> result;
|
||||
result.reserve(dPositions.size() * rxPositions.size());
|
||||
for (auto &i : futures) {
|
||||
result.push_back(i.get());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename... CT>
|
||||
void Parallel1(void (sls::Receiver::*somefunc)(CT...),
|
||||
std::vector<int> dPositions,
|
||||
std::vector<int> rxPositions,
|
||||
typename NonDeduced<CT>::type... Args) {
|
||||
|
||||
if (receivers.size() == 0)
|
||||
throw sls::RuntimeError("No receivers added");
|
||||
if (dPositions.empty() ||
|
||||
(dPositions.size() == 1 && dPositions[0] == -1)) {
|
||||
dPositions.resize(receivers.size());
|
||||
std::iota(begin(dPositions), end(dPositions), 0);
|
||||
}
|
||||
if (rxPositions.empty() ||
|
||||
(rxPositions.size() == 1 && rxPositions[0] == -1)) {
|
||||
rxPositions.resize(receivers[0].size());
|
||||
std::iota(begin(rxPositions), end(rxPositions), 0);
|
||||
}
|
||||
std::vector<std::future<void>> futures;
|
||||
futures.reserve(dPositions.size() * rxPositions.size());
|
||||
for (size_t i : dPositions) {
|
||||
if (i >= receivers.size())
|
||||
throw sls::RuntimeError("Detector out of range");
|
||||
// each entry
|
||||
for (size_t j : rxPositions) {
|
||||
futures.push_back(std::async(std::launch::async, somefunc,
|
||||
receivers[i][j].get(), Args...));
|
||||
}
|
||||
}
|
||||
for (auto &i : futures) {
|
||||
i.get();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... CT>
|
||||
void Parallel1(void (sls::Receiver::*somefunc)(CT...) const,
|
||||
std::vector<int> dPositions,
|
||||
std::vector<int> rxPositions,
|
||||
typename NonDeduced<CT>::type... Args) const {
|
||||
|
||||
if (receivers.size() == 0)
|
||||
throw sls::RuntimeError("No receivers added");
|
||||
if (dPositions.empty() ||
|
||||
(dPositions.size() == 1 && dPositions[0] == -1)) {
|
||||
dPositions.resize(receivers.size());
|
||||
std::iota(begin(dPositions), end(dPositions), 0);
|
||||
}
|
||||
if (rxPositions.empty() ||
|
||||
(rxPositions.size() == 1 && rxPositions[0] == -1)) {
|
||||
rxPositions.resize(receivers[0].size());
|
||||
std::iota(begin(rxPositions), end(rxPositions), 0);
|
||||
}
|
||||
std::vector<std::future<void>> futures;
|
||||
futures.reserve(dPositions.size() * rxPositions.size());
|
||||
for (size_t i : dPositions) {
|
||||
if (i >= receivers.size())
|
||||
throw sls::RuntimeError("Detector out of range");
|
||||
// each entry
|
||||
for (size_t j : rxPositions) {
|
||||
futures.push_back(std::async(std::launch::async, somefunc,
|
||||
receivers[i][j].get(), Args...));
|
||||
}
|
||||
}
|
||||
for (auto &i : futures) {
|
||||
i.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template <typename RT, typename... CT>
|
||||
sls::Result<RT> Parallel2(RT (sls::Receiver::*somefunc)(CT...),
|
||||
std::vector<int> dPositions,
|
||||
std::vector<int> rxPositions,
|
||||
typename NonDeduced<CT>::type... Args) {
|
||||
|
||||
if (receivers2.size() == 0)
|
||||
throw sls::RuntimeError("No receivers2 added");
|
||||
if (dPositions.empty() ||
|
||||
(dPositions.size() == 1 && dPositions[0] == -1)) {
|
||||
dPositions.resize(receivers2.size());
|
||||
std::iota(begin(dPositions), end(dPositions), 0);
|
||||
}
|
||||
if (rxPositions.empty() ||
|
||||
(rxPositions.size() == 1 && rxPositions[0] == -1)) {
|
||||
rxPositions.resize(receivers2[0].size());
|
||||
std::iota(begin(rxPositions), end(rxPositions), 0);
|
||||
}
|
||||
std::vector<std::future<RT>> futures;
|
||||
futures.reserve(dPositions.size() * rxPositions.size());
|
||||
for (size_t i : dPositions) {
|
||||
if (i >= receivers2.size())
|
||||
throw sls::RuntimeError("Detector out of range");
|
||||
// each entry
|
||||
for (size_t j : rxPositions) {
|
||||
futures.push_back(std::async(std::launch::async, somefunc,
|
||||
receivers2[i][j].get(), Args...));
|
||||
}
|
||||
}
|
||||
sls::Result<RT> result;
|
||||
result.reserve(dPositions.size() * rxPositions.size());
|
||||
for (auto &i : futures) {
|
||||
result.push_back(i.get());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename RT, typename... CT>
|
||||
sls::Result<RT> Parallel2(RT (sls::Receiver::*somefunc)(CT...) const,
|
||||
std::vector<int> dPositions,
|
||||
std::vector<int> rxPositions,
|
||||
typename NonDeduced<CT>::type... Args) const {
|
||||
|
||||
if (receivers2.size() == 0)
|
||||
throw sls::RuntimeError("No receivers2 added");
|
||||
if (dPositions.empty() ||
|
||||
(dPositions.size() == 1 && dPositions[0] == -1)) {
|
||||
dPositions.resize(receivers2.size());
|
||||
std::iota(begin(dPositions), end(dPositions), 0);
|
||||
}
|
||||
if (rxPositions.empty() ||
|
||||
(rxPositions.size() == 1 && rxPositions[0] == -1)) {
|
||||
rxPositions.resize(receivers2[0].size());
|
||||
std::iota(begin(rxPositions), end(rxPositions), 0);
|
||||
}
|
||||
std::vector<std::future<RT>> futures;
|
||||
futures.reserve(dPositions.size() * rxPositions.size());
|
||||
for (size_t i : dPositions) {
|
||||
if (i >= receivers2.size())
|
||||
throw sls::RuntimeError("Detector out of range");
|
||||
// each entry
|
||||
for (size_t j : rxPositions) {
|
||||
futures.push_back(std::async(std::launch::async, somefunc,
|
||||
receivers2[i][j].get(), Args...));
|
||||
}
|
||||
}
|
||||
sls::Result<RT> result;
|
||||
result.reserve(dPositions.size() * rxPositions.size());
|
||||
for (auto &i : futures) {
|
||||
result.push_back(i.get());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename... CT>
|
||||
void Parallel2(void (sls::Receiver::*somefunc)(CT...),
|
||||
std::vector<int> dPositions,
|
||||
std::vector<int> rxPositions,
|
||||
typename NonDeduced<CT>::type... Args) {
|
||||
|
||||
if (receivers2.size() == 0)
|
||||
throw sls::RuntimeError("No receivers2 added");
|
||||
if (dPositions.empty() ||
|
||||
(dPositions.size() == 1 && dPositions[0] == -1)) {
|
||||
dPositions.resize(receivers2.size());
|
||||
std::iota(begin(dPositions), end(dPositions), 0);
|
||||
}
|
||||
if (rxPositions.empty() ||
|
||||
(rxPositions.size() == 1 && rxPositions[0] == -1)) {
|
||||
rxPositions.resize(receivers2[0].size());
|
||||
std::iota(begin(rxPositions), end(rxPositions), 0);
|
||||
}
|
||||
std::vector<std::future<void>> futures;
|
||||
futures.reserve(dPositions.size() * rxPositions.size());
|
||||
for (size_t i : dPositions) {
|
||||
if (i >= receivers2.size())
|
||||
throw sls::RuntimeError("Detector out of range");
|
||||
// each entry
|
||||
for (size_t j : rxPositions) {
|
||||
futures.push_back(std::async(std::launch::async, somefunc,
|
||||
receivers2[i][j].get(), Args...));
|
||||
}
|
||||
}
|
||||
for (auto &i : futures) {
|
||||
i.get();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... CT>
|
||||
void Parallel2(void (sls::Receiver::*somefunc)(CT...) const,
|
||||
std::vector<int> dPositions,
|
||||
std::vector<int> rxPositions,
|
||||
typename NonDeduced<CT>::type... Args) const {
|
||||
|
||||
if (receivers2.size() == 0)
|
||||
throw sls::RuntimeError("No receivers2 added");
|
||||
if (dPositions.empty() ||
|
||||
(dPositions.size() == 1 && dPositions[0] == -1)) {
|
||||
dPositions.resize(receivers2.size());
|
||||
std::iota(begin(dPositions), end(dPositions), 0);
|
||||
}
|
||||
if (rxPositions.empty() ||
|
||||
(rxPositions.size() == 1 && rxPositions[0] == -1)) {
|
||||
rxPositions.resize(receivers2[0].size());
|
||||
std::iota(begin(rxPositions), end(rxPositions), 0);
|
||||
}
|
||||
std::vector<std::future<void>> futures;
|
||||
futures.reserve(dPositions.size() * rxPositions.size());
|
||||
for (size_t i : dPositions) {
|
||||
if (i >= receivers2.size())
|
||||
throw sls::RuntimeError("Detector out of range");
|
||||
// each entry
|
||||
for (size_t j : rxPositions) {
|
||||
futures.push_back(std::async(std::launch::async, somefunc,
|
||||
receivers2[i][j].get(), Args...));
|
||||
}
|
||||
}
|
||||
for (auto &i : futures) {
|
||||
i.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// for all , but dont complain if receiver2 doesnt exist
|
||||
template <typename RT, typename... CT>
|
||||
sls::Result<RT> Parallel3(RT (sls::Receiver::*somefunc)(CT...),
|
||||
typename NonDeduced<CT>::type... Args) {
|
||||
|
||||
if (receivers.size() == 0)
|
||||
throw sls::RuntimeError("No receivers added");
|
||||
std::vector<int> dPositions;
|
||||
dPositions.resize(receivers.size());
|
||||
std::iota(begin(dPositions), end(dPositions), 0);
|
||||
std::vector<int> rxPositions;
|
||||
rxPositions.resize(receivers[0].size());
|
||||
std::iota(begin(rxPositions), end(rxPositions), 0);
|
||||
// multiply by 2 if receivers2 exists
|
||||
size_t futureSize = dPositions.size() * rxPositions.size() *
|
||||
(receivers2.size() > 0 ? 2 : 1);
|
||||
std::vector<std::future<RT>> futures;
|
||||
futures.reserve(futureSize);
|
||||
for (size_t i : dPositions) {
|
||||
// each entry
|
||||
for (size_t j : rxPositions) {
|
||||
futures.push_back(std::async(std::launch::async, somefunc,
|
||||
receivers[i][j].get(), Args...));
|
||||
if (receivers2.size()) {
|
||||
futures.push_back(std::async(std::launch::async, somefunc,
|
||||
receivers2[i][j].get(), Args...));
|
||||
}
|
||||
}
|
||||
}
|
||||
sls::Result<RT> result;
|
||||
result.reserve(futureSize);
|
||||
for (auto &i : futures) {
|
||||
result.push_back(i.get());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename RT, typename... CT>
|
||||
sls::Result<RT> Parallel3(RT (sls::Receiver::*somefunc)(CT...) const,
|
||||
typename NonDeduced<CT>::type... Args) const {
|
||||
|
||||
if (receivers.size() == 0)
|
||||
throw sls::RuntimeError("No receivers added");
|
||||
std::vector<int> dPositions;
|
||||
dPositions.resize(receivers.size());
|
||||
std::iota(begin(dPositions), end(dPositions), 0);
|
||||
std::vector<int> rxPositions;
|
||||
rxPositions.resize(receivers[0].size());
|
||||
std::iota(begin(rxPositions), end(rxPositions), 0);
|
||||
// multiply by 2 if receivers2 exists
|
||||
size_t futureSize = dPositions.size() * rxPositions.size() *
|
||||
(receivers2.size() > 0 ? 2 : 1);
|
||||
std::vector<std::future<RT>> futures;
|
||||
futures.reserve(futureSize);
|
||||
for (size_t i : dPositions) {
|
||||
// each entry
|
||||
for (size_t j : rxPositions) {
|
||||
futures.push_back(std::async(std::launch::async, somefunc,
|
||||
receivers[i][j].get(), Args...));
|
||||
if (receivers2.size()) {
|
||||
futures.push_back(std::async(std::launch::async, somefunc,
|
||||
receivers2[i][j].get(), Args...));
|
||||
}
|
||||
}
|
||||
}
|
||||
sls::Result<RT> result;
|
||||
result.reserve(futureSize);
|
||||
for (auto &i : futures) {
|
||||
result.push_back(i.get());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename... CT>
|
||||
void Parallel3(void (sls::Receiver::*somefunc)(CT...),
|
||||
typename NonDeduced<CT>::type... Args) {
|
||||
|
||||
if (receivers.size() == 0)
|
||||
throw sls::RuntimeError("No receivers added");
|
||||
std::vector<int> dPositions;
|
||||
dPositions.resize(receivers.size());
|
||||
std::iota(begin(dPositions), end(dPositions), 0);
|
||||
std::vector<int> rxPositions;
|
||||
rxPositions.resize(receivers[0].size());
|
||||
std::iota(begin(rxPositions), end(rxPositions), 0);
|
||||
// multiply by 2 if receivers2 exists
|
||||
size_t futureSize = dPositions.size() * rxPositions.size() *
|
||||
(receivers2.size() > 0 ? 2 : 1);
|
||||
std::vector<std::future<void>> futures;
|
||||
futures.reserve(futureSize);
|
||||
for (size_t i : dPositions) {
|
||||
// each entry
|
||||
for (size_t j : rxPositions) {
|
||||
futures.push_back(std::async(std::launch::async, somefunc,
|
||||
receivers[i][j].get(), Args...));
|
||||
if (receivers2.size()) {
|
||||
futures.push_back(std::async(std::launch::async, somefunc,
|
||||
receivers2[i][j].get(), Args...));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto &i : futures) {
|
||||
i.get();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... CT>
|
||||
void Parallel3(void (sls::Receiver::*somefunc)(CT...) const,
|
||||
typename NonDeduced<CT>::type... Args) const {
|
||||
|
||||
if (receivers.size() == 0)
|
||||
throw sls::RuntimeError("No receivers added");
|
||||
std::vector<int> dPositions;
|
||||
dPositions.resize(receivers.size());
|
||||
std::iota(begin(dPositions), end(dPositions), 0);
|
||||
std::vector<int> rxPositions;
|
||||
rxPositions.resize(receivers[0].size());
|
||||
std::iota(begin(rxPositions), end(rxPositions), 0);
|
||||
// multiply by 2 if receivers2 exists
|
||||
size_t futureSize = dPositions.size() * rxPositions.size() *
|
||||
(receivers2.size() > 0 ? 2 : 1);
|
||||
std::vector<std::future<void>> futures;
|
||||
futures.reserve(futureSize);
|
||||
for (size_t i : dPositions) {
|
||||
// each entry
|
||||
for (size_t j : rxPositions) {
|
||||
futures.push_back(std::async(std::launch::async, somefunc,
|
||||
receivers[i][j].get(), Args...));
|
||||
if (receivers2.size()) {
|
||||
futures.push_back(std::async(std::launch::async, somefunc,
|
||||
receivers2[i][j].get(), Args...));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto &i : futures) {
|
||||
i.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** set acquiring flag in shared memory */
|
||||
void setAcquiringFlag(bool flag);
|
||||
|
||||
/** return multi detector shared memory ID */
|
||||
int getMultiId() const;
|
||||
/** return detector shared memory ID */
|
||||
int getDetectorId() const;
|
||||
|
||||
/** Free specific shared memory from the command line without creating object */
|
||||
static void freeSharedMemory(int multiId, int detPos = -1);
|
||||
static void freeSharedMemory(int detectorId, int moduleId = -1);
|
||||
|
||||
/** Free all modules from current multi Id shared memory and delete members */
|
||||
void freeSharedMemory();
|
||||
@ -222,8 +663,18 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
*/
|
||||
void setVirtualDetectorServers(const int numdet, const int port);
|
||||
|
||||
/** Sets the hostname of all sls detectors in shared memory and updates local cache */
|
||||
void setHostname(const std::vector<std::string> &name);
|
||||
void setHostname(const std::vector<std::string> &name,
|
||||
const std::vector<int> &port);
|
||||
|
||||
int getNumberofReceiversPerModule() const;
|
||||
void initReceiver(const int udpInterface);
|
||||
bool isReceiverInitialized(const int udpInterface);
|
||||
void removeReceivers(const int udpInterface);
|
||||
void configureReceiver(const int udpInterface, Positions pos,
|
||||
const std::string &hostname);
|
||||
void configureReceiver(const int udpInterface, int module_id,
|
||||
const std::string &hostname, const int port);
|
||||
|
||||
/** Gets the total number of detectors */
|
||||
int size() const;
|
||||
@ -236,18 +687,10 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
* Sets maximum number of channels of all sls detectors */
|
||||
void setNumberOfChannels(const slsDetectorDefs::xy c);
|
||||
|
||||
/**
|
||||
* Enable gap pixels, only for Eiger and for 8,16 and 32 bit mode. (Eiger)
|
||||
* 4 bit mode gap pixels only in gui call back
|
||||
*/
|
||||
void setGapPixelsinReceiver(bool enable);
|
||||
|
||||
/**
|
||||
* Enable data streaming to client
|
||||
* @param enable 0 to disable, 1 to enable, -1 to get the value
|
||||
* @returns data streaming to client enable
|
||||
*/
|
||||
bool enableDataStreamingToClient(int enable = -1);
|
||||
/** [Eiger][Jungfrau] */
|
||||
bool getGapPixelsinCallback() const;
|
||||
/** [Eiger][Jungfrau] */
|
||||
void setGapPixelsinCallback(const bool enable);
|
||||
|
||||
/**
|
||||
* register callback for accessing acquisition final data
|
||||
@ -304,7 +747,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
* one
|
||||
* @param update true to update last user pid, date etc
|
||||
*/
|
||||
void setupMultiDetector(bool verify = true, bool update = true);
|
||||
void setupDetector(bool verify = true, bool update = true);
|
||||
|
||||
/**
|
||||
* Creates shm and initializes shm structure OR
|
||||
@ -330,40 +773,30 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
/** Execute command in terminal and return result */
|
||||
std::string exec(const char *cmd);
|
||||
|
||||
void addSlsDetector(const std::string &hostname);
|
||||
void addModule(const std::string &hostname, const int port);
|
||||
|
||||
void updateDetectorSize();
|
||||
|
||||
/**
|
||||
* Create Receiving Data Sockets
|
||||
* @param destroy is true to destroy all the sockets
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int createReceivingDataSockets(const bool destroy = false);
|
||||
|
||||
/**
|
||||
* Reads frames from receiver through a constant socket
|
||||
* Called during acquire() when call back registered or when using gui
|
||||
*/
|
||||
void readFrameFromReceiver();
|
||||
|
||||
/**
|
||||
* add gap pixels to the image (only for Eiger in 4 bit mode)
|
||||
/** [Eiger][Jungfrau]
|
||||
* add gap pixels to the imag
|
||||
* @param image pointer to image without gap pixels
|
||||
* @param gpImage poiner to image with gap pixels, if NULL, allocated
|
||||
* inside function
|
||||
* quadEnable quad enabled
|
||||
* @returns number of data bytes of image with gap pixels
|
||||
* @param quadEnable quad enabled
|
||||
* @param dr dynamic range
|
||||
* @param nPixelsx number of pixels in X axis (updated)
|
||||
* @param nPixelsy number of pixels in Y axis (updated)
|
||||
* @returns total data bytes for updated image
|
||||
*/
|
||||
int processImageWithGapPixels(char *image, char *&gpImage, bool quadEnable);
|
||||
int InsertGapPixels(char *image, char *&gpImage, bool quadEnable, int dr,
|
||||
int &nPixelsx, int &nPixelsy);
|
||||
|
||||
double setTotalProgress();
|
||||
|
||||
double getCurrentProgress();
|
||||
|
||||
void incrementProgress();
|
||||
|
||||
void setCurrentProgress(int64_t i = 0);
|
||||
void printProgress(double progress);
|
||||
|
||||
void startProcessingThread();
|
||||
|
||||
@ -386,19 +819,18 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
int kbhit();
|
||||
|
||||
/** Multi detector Id */
|
||||
const int multiId{0};
|
||||
const int detectorId{0};
|
||||
|
||||
/** Shared Memory object */
|
||||
sls::SharedMemory<sharedMultiSlsDetector> multi_shm{0, -1};
|
||||
sls::SharedMemory<sharedDetector> detector_shm{0, -1};
|
||||
|
||||
/** pointers to the Module structures */
|
||||
std::vector<std::unique_ptr<sls::Module>> detectors;
|
||||
|
||||
/** data streaming (down stream) enabled in client (zmq sckets created) */
|
||||
bool client_downstream{false};
|
||||
|
||||
/** ZMQ Socket - Receiver to Client */
|
||||
std::vector<std::unique_ptr<ZmqSocket>> zmqSocket;
|
||||
/** pointers to the Receiver structures, each row for a module */
|
||||
std::vector<std::vector<std::unique_ptr<sls::Receiver>>> receivers;
|
||||
/** for the second udp port [Eiger][Jungfrau] */
|
||||
std::vector<std::vector<std::unique_ptr<sls::Receiver>>> receivers2;
|
||||
|
||||
/** semaphore to let postprocessing thread continue for next
|
||||
* scan/measurement */
|
||||
@ -408,12 +840,6 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
* from ext. process) */
|
||||
sem_t sem_endRTAcquisition;
|
||||
|
||||
/** Total number of frames/images for next acquisition */
|
||||
double totalProgress{0};
|
||||
|
||||
/** Current progress or frames/images processed in current acquisition */
|
||||
double progressIndex{0};
|
||||
|
||||
/** mutex to synchronize main and data processing threads */
|
||||
mutable std::mutex mp;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
918
slsDetectorSoftware/src/Receiver.cpp
Executable file
918
slsDetectorSoftware/src/Receiver.cpp
Executable file
@ -0,0 +1,918 @@
|
||||
#include "Receiver.h"
|
||||
#include "ClientSocket.h"
|
||||
#include "ZmqSocket.h"
|
||||
#include "FixedCapacityContainer.h"
|
||||
#include "string_utils.h"
|
||||
#include "versionAPI.h"
|
||||
#include "ToString.h"
|
||||
|
||||
#include "container_utils.h"
|
||||
|
||||
namespace sls {
|
||||
|
||||
// create shm
|
||||
Receiver::Receiver(int detector_id, int module_id, int interface_id,
|
||||
int receiver_id, int tcp_port, std::string hostname,
|
||||
int zmq_port) :
|
||||
receiverId(receiver_id), interfaceId(interface_id), moduleId(module_id),
|
||||
shm(detector_id, module_id, interface_id, receiver_id) {
|
||||
createIndexString();
|
||||
|
||||
// ensure shared memory was not created before
|
||||
if (shm.IsExisting()) {
|
||||
LOG(logWARNING) << "This shared memory should have been deleted "
|
||||
"before! " << shm.GetName() << ". Freeing it again";
|
||||
shm.RemoveSharedMemory();
|
||||
}
|
||||
shm = SharedMemory<sharedReceiver>(detector_id, module_id, interface_id,
|
||||
receiver_id);
|
||||
shm.CreateSharedMemory();
|
||||
|
||||
// initalize receiver structure
|
||||
shm()->shmversion = RECEIVER_SHMVERSION;
|
||||
memset(shm()->hostname, 0, MAX_STR_LENGTH);
|
||||
shm()->tcpPort = DEFAULT_RX_PORTNO + receiver_id;
|
||||
shm()-> stoppedFlag = false;
|
||||
shm()->zmqPort = DEFAULT_ZMQ_RX_PORTNO + receiver_id;
|
||||
shm()->zmqIp = IpAddr{};
|
||||
|
||||
// copy port, hostname if given
|
||||
if (tcp_port != 0) {
|
||||
setTCPPort(tcp_port);
|
||||
}
|
||||
if (zmq_port != 0) {
|
||||
shm()->zmqPort = zmq_port;
|
||||
}
|
||||
if (!hostname.empty()) {
|
||||
setHostname(hostname);
|
||||
}
|
||||
}
|
||||
|
||||
// open shm
|
||||
Receiver::Receiver(int detector_id, int module_id, int interface_id,
|
||||
int receiver_id, bool verify) :
|
||||
receiverId(receiver_id), interfaceId(interface_id), moduleId(module_id),
|
||||
shm(detector_id, module_id, interface_id, receiver_id) {
|
||||
createIndexString();
|
||||
|
||||
shm.OpenSharedMemory();
|
||||
if (verify && shm()->shmversion != RECEIVER_SHMVERSION) {
|
||||
std::ostringstream ss;
|
||||
ss << "Receiver shared memory (" << detector_id << "-" << indexString
|
||||
<< ":" << receiverId << ") version mismatch (expected 0x" << std::hex
|
||||
<< RECEIVER_SHMVERSION << " but got 0x" << shm()->shmversion << ")"
|
||||
<< std::dec << ". Clear Shared memory to continue.";
|
||||
throw SharedMemoryError(ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
Receiver::~Receiver() = default;
|
||||
|
||||
void Receiver::createIndexString() {
|
||||
std::ostringstream oss;
|
||||
oss << '(' << moduleId << (char)(interfaceId + 97) << "." << receiverId << ')';
|
||||
indexString = oss.str();
|
||||
}
|
||||
|
||||
/** Configuration */
|
||||
|
||||
void Receiver::freeSharedMemory() {
|
||||
if (shm.IsExisting()) {
|
||||
shm.RemoveSharedMemory();
|
||||
}
|
||||
}
|
||||
|
||||
std::string Receiver::getHostname() const {
|
||||
return shm()->hostname;
|
||||
}
|
||||
|
||||
void Receiver::setHostname(const std::string &hostname) {
|
||||
if (hostname.empty()) {
|
||||
throw RuntimeError("Invalid receiver hostname. Cannot be empty.");
|
||||
}
|
||||
sls::strcpy_safe(shm()->hostname, hostname.c_str());
|
||||
checkVersionCompatibility();
|
||||
}
|
||||
|
||||
int Receiver::getTCPPort() const {
|
||||
return shm()->tcpPort;
|
||||
}
|
||||
|
||||
void Receiver::setTCPPort(const int port) {
|
||||
LOG(logDEBUG1) << "Setting reciever port to " << port;
|
||||
if (port >= 0 && port != shm()->tcpPort) {
|
||||
if (strlen(shm()->hostname) != 0) {
|
||||
int retval = -1;
|
||||
sendToReceiver(F_SET_RECEIVER_PORT, port, retval);
|
||||
shm()->tcpPort = retval;
|
||||
LOG(logDEBUG1) << "Receiver port: " << retval;
|
||||
} else {
|
||||
shm()->tcpPort = port;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Receiver::checkVersionCompatibility() {
|
||||
int64_t arg = APIRECEIVER;
|
||||
LOG(logDEBUG1)
|
||||
<< "Checking version compatibility with receiver with value "
|
||||
<< std::hex << arg << std::dec;
|
||||
sendToReceiver(F_RECEIVER_CHECK_VERSION, arg, nullptr);
|
||||
}
|
||||
|
||||
sls::MacAddr Receiver::configure(slsDetectorDefs::rxParameters arg) {
|
||||
// hostname
|
||||
memset(arg.hostname, 0, sizeof(arg.hostname));
|
||||
strcpy_safe(arg.hostname, shm()->hostname);
|
||||
// interface id
|
||||
arg.interfaceId = interfaceId;
|
||||
// zmqip
|
||||
{
|
||||
sls::IpAddr ip;
|
||||
// Hostname could be ip try to decode otherwise look up the hostname
|
||||
ip = sls::IpAddr{shm()->hostname};
|
||||
if (ip == 0) {
|
||||
ip = HostnameToIp(shm()->hostname);
|
||||
}
|
||||
LOG(logINFO) << "Setting default receiver " << indexString
|
||||
<< " streaming zmq ip to " << ip;
|
||||
// if client zmqip is empty, update it
|
||||
if (shm()->zmqIp == 0) {
|
||||
shm()->zmqIp = ip;
|
||||
}
|
||||
memcpy(&arg.zmq_ip, &ip, sizeof(ip));
|
||||
}
|
||||
|
||||
if (arg.detType == EIGER) {
|
||||
arg.udpInterfaces = 2;
|
||||
}
|
||||
|
||||
LOG(logDEBUG)
|
||||
<< "detType:" << arg.detType << std::endl
|
||||
<< "detectorSize.x:" << arg.detectorSize.x << std::endl
|
||||
<< "detectorSize.y:" << arg.detectorSize.y << std::endl
|
||||
<< "moduleId:" << arg.moduleId << std::endl
|
||||
<< "hostname:" << arg.hostname << std::endl
|
||||
<< "interfaceId: " << arg.interfaceId << std::endl
|
||||
<< "zmq ip:" << arg.zmq_ip << std::endl
|
||||
<< "udpInterfaces:" << arg.udpInterfaces << std::endl
|
||||
<< "udp_dstport:" << arg.udp_dstport << std::endl
|
||||
<< "udp_dstip:" << sls::IpAddr(arg.udp_dstip) << std::endl
|
||||
<< "udp_dstmac:" << sls::MacAddr(arg.udp_dstmac) << std::endl
|
||||
<< "udp_dstport2:" << arg.udp_dstport2 << std::endl
|
||||
<< "udp_dstip2:" << sls::IpAddr(arg.udp_dstip2) << std::endl
|
||||
<< "udp_dstmac2:" << sls::MacAddr(arg.udp_dstmac2) << std::endl
|
||||
<< "frames:" << arg.frames << std::endl
|
||||
<< "triggers:" << arg.triggers << std::endl
|
||||
<< "bursts:" << arg.bursts << std::endl
|
||||
<< "analogSamples:" << arg.analogSamples << std::endl
|
||||
<< "digitalSamples:" << arg.digitalSamples << std::endl
|
||||
<< "expTimeNs:" << arg.expTimeNs << std::endl
|
||||
<< "periodNs:" << arg.periodNs << std::endl
|
||||
<< "subExpTimeNs:" << arg.subExpTimeNs << std::endl
|
||||
<< "subDeadTimeNs:" << arg.subDeadTimeNs << std::endl
|
||||
<< "activate:" << arg.activate << std::endl
|
||||
<< "quad:" << arg.quad << std::endl
|
||||
<< "dynamicRange:" << arg.dynamicRange << std::endl
|
||||
<< "timMode:" << arg.timMode << std::endl
|
||||
<< "tenGiga:" << arg.tenGiga << std::endl
|
||||
<< "roMode:" << arg.roMode << std::endl
|
||||
<< "adcMask:" << arg.adcMask << std::endl
|
||||
<< "adc10gMask:" << arg.adc10gMask << std::endl
|
||||
<< "roi.xmin:" << arg.roi.xmin << std::endl
|
||||
<< "roi.xmax:" << arg.roi.xmax << std::endl
|
||||
<< "countermask:" << arg.countermask << std::endl
|
||||
<< "burstType:" << arg.burstType << std::endl;
|
||||
|
||||
sls::MacAddr mac;
|
||||
{
|
||||
sls::MacAddr retval;
|
||||
sendToReceiver(F_SETUP_RECEIVER, arg, retval);
|
||||
// detector does not have customized udp mac
|
||||
if (arg.udp_dstmac == 0) {
|
||||
mac = retval;
|
||||
}
|
||||
}
|
||||
if (arg.detType == MOENCH) {
|
||||
setAdditionalJsonParameter("adcmask_1g", std::to_string(arg.adcMask));
|
||||
setAdditionalJsonParameter("adcmask_10g", std::to_string(arg.adc10gMask));
|
||||
}
|
||||
|
||||
LOG(logINFOBLUE) << "reciever " << indexString << " configured!";
|
||||
return mac;
|
||||
}
|
||||
|
||||
std::string Receiver::printConfiguration() {
|
||||
std::ostringstream oss;
|
||||
|
||||
oss << std::endl << std::endl
|
||||
<< "Receiver " << indexString << std::endl
|
||||
<< "Hostname : " << shm()->hostname << std::endl
|
||||
<< "Tcp port : " << shm()->tcpPort << std::endl;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
os << "\nReceiver UDP IP:\t"
|
||||
<< getDestinationUDPIP() << "\nReceiver UDP MAC:\t" << getDestinationUDPMAC();
|
||||
|
||||
if (shm()->myDetectorType == JUNGFRAU) {
|
||||
os << "\nDetector UDP IP2:\t" << getSourceUDPIP2()
|
||||
<< "\nDetector UDP MAC2:\t" << getSourceUDPMAC2()
|
||||
<< "\nReceiver UDP IP2:\t" << getDestinationUDPIP2()
|
||||
<< "\nReceiver UDP MAC2:\t" << getDestinationUDPMAC2();
|
||||
}
|
||||
os << "\nReceiver UDP Port:\t" << getDestinationUDPPort();
|
||||
if (shm()->myDetectorType == JUNGFRAU || shm()->myDetectorType == EIGER) {
|
||||
os << "\nReceiver UDP Port2:\t" << getDestinationUDPPort2();
|
||||
}
|
||||
*/
|
||||
oss << "\n";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
int64_t Receiver::getSoftwareVersion() const {
|
||||
LOG(logDEBUG1) << "Getting receiver software version";
|
||||
return sendToReceiver<int64_t>(F_GET_RECEIVER_VERSION);
|
||||
}
|
||||
|
||||
/** Acquisition */
|
||||
|
||||
void Receiver::start() {
|
||||
LOG(logDEBUG1) << "Starting Receiver";
|
||||
shm()->stoppedFlag = false;
|
||||
sendToReceiver(F_START_RECEIVER, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::stop() {
|
||||
LOG(logDEBUG1) << "Stopping Receiver";
|
||||
int arg = static_cast<int>(shm()->stoppedFlag);
|
||||
sendToReceiver(F_STOP_RECEIVER, arg, nullptr);
|
||||
}
|
||||
|
||||
slsDetectorDefs::runStatus Receiver::getStatus() const {
|
||||
runStatus retval = ERROR;
|
||||
LOG(logDEBUG1) << "Getting Receiver Status";
|
||||
sendToReceiver(F_GET_RECEIVER_STATUS, nullptr, retval);
|
||||
LOG(logDEBUG1) << "Receiver Status: " << ToString(retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
int Receiver::getProgress() const {
|
||||
int retval = -1;
|
||||
sendToReceiver(F_GET_RECEIVER_PROGRESS, nullptr, retval);
|
||||
LOG(logDEBUG1) << "Current Progress of Receiver: " << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void Receiver::setStoppedFlag() {
|
||||
shm()->stoppedFlag = true;
|
||||
}
|
||||
|
||||
void Receiver::restreamStop() {
|
||||
LOG(logDEBUG1) << "Restream stop dummy from Receiver via zmq";
|
||||
sendToReceiver(F_RESTREAM_STOP_FROM_RECEIVER, nullptr, nullptr);
|
||||
}
|
||||
|
||||
|
||||
uint64_t Receiver::getFramesCaught() const {
|
||||
return sendToReceiver<uint64_t>(F_GET_RECEIVER_FRAMES_CAUGHT);
|
||||
}
|
||||
|
||||
uint64_t Receiver::getNumMissingPackets() const {
|
||||
return sendToReceiver<uint64_t>(F_GET_NUM_MISSING_PACKETS);
|
||||
}
|
||||
|
||||
uint64_t Receiver::getCurrentFrameIndex() const {
|
||||
return sendToReceiver<uint64_t>(F_GET_RECEIVER_FRAME_INDEX);
|
||||
}
|
||||
|
||||
/** Network Configuration (Detector<->Receiver) */
|
||||
|
||||
sls::MacAddr Receiver::setUDPIP(const IpAddr ip) {
|
||||
LOG(logDEBUG1) << "Setting udp ip to receier: " << ip;
|
||||
if (ip == 0) {
|
||||
throw RuntimeError("Invalid destination udp ip address");
|
||||
}
|
||||
sls::MacAddr retval(0LU);
|
||||
sendToReceiver(F_SET_RECEIVER_UDP_IP, ip, retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void Receiver::setUDPPort(const int port) {
|
||||
LOG(logDEBUG1) << "Setting udp port to receiver: " << port;
|
||||
sendToReceiver(F_SET_RECEIVER_UDP_PORT, port, nullptr);
|
||||
}
|
||||
|
||||
int64_t Receiver::getUDPSocketBufferSize() const {
|
||||
return sendToReceiver<int64_t>(F_GET_RECEIVER_UDP_SOCK_BUF_SIZE);
|
||||
}
|
||||
|
||||
void Receiver::setUDPSocketBufferSize(int64_t value) {
|
||||
LOG(logDEBUG1) << "Sending UDP Socket Buffer size to receiver: "
|
||||
<< value;
|
||||
sendToReceiver(F_SET_RECEIVER_UDP_SOCK_BUF_SIZE, value, nullptr);
|
||||
}
|
||||
|
||||
int64_t Receiver::getRealUDPSocketBufferSize() const {
|
||||
return sendToReceiver<int64_t>(F_GET_RECEIVER_REAL_UDP_SOCK_BUF_SIZE);
|
||||
}
|
||||
|
||||
/** ZMQ Streaming Parameters (Receiver<->Client) */
|
||||
|
||||
bool Receiver::getZmq() const {
|
||||
return sendToReceiver<int>(F_GET_RECEIVER_STREAMING);
|
||||
}
|
||||
|
||||
void Receiver::setZmq(const bool enable) {
|
||||
int arg = static_cast<int>(enable);
|
||||
sendToReceiver(F_SET_RECEIVER_STREAMING, arg, nullptr);
|
||||
}
|
||||
|
||||
int Receiver::getZmqFrequency() const {
|
||||
return sendToReceiver<int>(F_GET_RECEIVER_STREAMING_FREQUENCY);
|
||||
}
|
||||
|
||||
void Receiver::setZmqFrequency(const int freq) {
|
||||
if (freq < 0) {
|
||||
throw RuntimeError("Invalid streaming frequency " + std::to_string(freq));
|
||||
}
|
||||
sendToReceiver(F_SET_RECEIVER_STREAMING_FREQUENCY, freq, nullptr);
|
||||
}
|
||||
|
||||
int Receiver::getZmqTimer() const {
|
||||
return sendToReceiver<int>(F_GET_RECEIVER_STREAMING_TIMER);
|
||||
}
|
||||
|
||||
void Receiver::setZmqTimer(const int time_in_ms) {
|
||||
sendToReceiver(F_SET_RECEIVER_STREAMING_TIMER, time_in_ms, nullptr);
|
||||
}
|
||||
|
||||
int Receiver::getZmqPort() const {
|
||||
return sendToReceiver<int>(F_GET_RECEIVER_STREAMING_PORT);
|
||||
}
|
||||
|
||||
void Receiver::setZmqPort(int port) {
|
||||
sendToReceiver(F_SET_RECEIVER_STREAMING_PORT, port, nullptr);
|
||||
}
|
||||
|
||||
sls::IpAddr Receiver::getZmqIP() const {
|
||||
return sendToReceiver<sls::IpAddr>(F_GET_RECEIVER_STREAMING_SRC_IP);
|
||||
}
|
||||
|
||||
void Receiver::setZmqIP(const sls::IpAddr ip) {
|
||||
if (ip == 0) {
|
||||
throw RuntimeError("Invalid receiver zmq ip address");
|
||||
}
|
||||
|
||||
// if client zmqip is empty, update it
|
||||
if (shm()->zmqIp == 0) {
|
||||
shm()->zmqIp = ip;
|
||||
}
|
||||
sendToReceiver(F_SET_RECEIVER_STREAMING_SRC_IP, ip, nullptr);
|
||||
}
|
||||
|
||||
int Receiver::getClientZmqPort() const {
|
||||
return shm()->zmqPort;
|
||||
}
|
||||
|
||||
void Receiver::setClientZmqPort(const int port) {
|
||||
shm()->zmqPort = port;
|
||||
}
|
||||
|
||||
sls::IpAddr Receiver::getClientZmqIP() const {
|
||||
return shm()->zmqIp;
|
||||
}
|
||||
|
||||
void Receiver::setClientZmqIP(const sls::IpAddr ip) {
|
||||
LOG(logDEBUG1) << "Setting client zmq ip to " << ip;
|
||||
if (ip == 0) {
|
||||
throw RuntimeError("Invalid client zmq ip address");
|
||||
}
|
||||
shm()->zmqIp = ip;
|
||||
}
|
||||
|
||||
bool Receiver::getClientZmq() const {
|
||||
return (zmqSocket != nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setClientZmq(const bool enable) {
|
||||
// destroy
|
||||
if (!enable) {
|
||||
if (zmqSocket != nullptr) {
|
||||
zmqSocket.reset();
|
||||
}
|
||||
}
|
||||
// create
|
||||
else {
|
||||
if (zmqSocket == nullptr) {
|
||||
try {
|
||||
zmqSocket = sls::make_unique<ZmqSocket>(
|
||||
shm()->zmqIp.str().c_str(), shm()->zmqPort);
|
||||
LOG(logINFO) << "Zmq Client[" << indexString << "] at "
|
||||
<< zmqSocket->GetZmqServerAddress();
|
||||
} catch(...) {
|
||||
throw RuntimeError(
|
||||
"Could not create Zmq socket [" + indexString
|
||||
+ " on port " + std::to_string(shm()->zmqPort));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ZmqSocket* Receiver::getZmqSocket() {
|
||||
return zmqSocket.get();
|
||||
}
|
||||
|
||||
/** Receiver Parameters */
|
||||
|
||||
bool Receiver::getLock() const {
|
||||
return sendToReceiver<int>(F_GET_LOCK_RECEIVER);
|
||||
}
|
||||
|
||||
void Receiver::setLock(const bool lock) {
|
||||
LOG(logDEBUG1) << "Setting receiver server lock to " << lock;
|
||||
sendToReceiver(F_SET_LOCK_RECEIVER, lock, nullptr);
|
||||
}
|
||||
|
||||
sls::IpAddr Receiver::getLastClientIP() const {
|
||||
return sendToReceiver<sls::IpAddr>(F_GET_LAST_RECEIVER_CLIENT_IP);
|
||||
}
|
||||
|
||||
void Receiver::exitServer() {
|
||||
LOG(logDEBUG1) << "Sending exit command to receiver server";
|
||||
sendToReceiver(F_EXIT_RECEIVER, nullptr, nullptr);
|
||||
}
|
||||
|
||||
bool Receiver::getDeactivatedPaddingMode() const {
|
||||
return sendToReceiver<int>(F_GET_RECEIVER_DEACTIVATED_PADDING);
|
||||
}
|
||||
|
||||
void Receiver::setDeactivatedPaddingMode(const bool padding) {
|
||||
int arg = static_cast<int>(padding);
|
||||
sendToReceiver(F_SET_RECEIVER_DEACTIVATED_PADDING, arg, nullptr);
|
||||
}
|
||||
|
||||
bool Receiver::getFlippedDataX() const {
|
||||
int arg = -1;
|
||||
return sendToReceiver<int>(F_GET_FLIPPED_DATA_RECEIVER, arg);
|
||||
}
|
||||
|
||||
void Receiver::setFlippedDataX(const bool value) {
|
||||
int arg = static_cast<int>(value);
|
||||
LOG(logDEBUG1) << "Setting flipped data across x axis with value: "
|
||||
<< value;
|
||||
sendToReceiver(F_SET_FLIPPED_DATA_RECEIVER, arg, nullptr);
|
||||
}
|
||||
|
||||
slsDetectorDefs::frameDiscardPolicy Receiver::getFramesDiscardPolicy() const {
|
||||
return static_cast<frameDiscardPolicy>(
|
||||
sendToReceiver<int>(F_GET_RECEIVER_DISCARD_POLICY));
|
||||
}
|
||||
|
||||
void Receiver::setFramesDiscardPolicy(const frameDiscardPolicy f) {
|
||||
int arg = static_cast<int>(f);
|
||||
sendToReceiver(F_SET_RECEIVER_DISCARD_POLICY, arg, nullptr);
|
||||
}
|
||||
|
||||
bool Receiver::getPartialFramesPadding() const {
|
||||
return sendToReceiver<int>(F_GET_RECEIVER_PADDING);
|
||||
}
|
||||
|
||||
void Receiver::setPartialFramesPadding(const bool padding) {
|
||||
int arg = static_cast<int>(padding);
|
||||
sendToReceiver(F_SET_RECEIVER_PADDING, arg, nullptr);
|
||||
}
|
||||
|
||||
int Receiver::getFifoDepth() const {
|
||||
return sendToReceiver<int>(F_GET_RECEIVER_FIFO_DEPTH);
|
||||
}
|
||||
|
||||
void Receiver::setFifoDepth(const int value) {
|
||||
sendToReceiver(F_SET_RECEIVER_FIFO_DEPTH, value, nullptr);
|
||||
}
|
||||
|
||||
bool Receiver::getSilentMode() const {
|
||||
return sendToReceiver<int>(F_GET_RECEIVER_SILENT_MODE);
|
||||
}
|
||||
|
||||
void Receiver::setSilentMode(const bool enable) {
|
||||
int arg = static_cast<int>(enable);
|
||||
sendToReceiver(F_SET_RECEIVER_SILENT_MODE, arg, nullptr);
|
||||
}
|
||||
|
||||
/** File */
|
||||
|
||||
std::string Receiver::getFilePath() const {
|
||||
char retvals[MAX_STR_LENGTH]{};
|
||||
sendToReceiver(F_GET_RECEIVER_FILE_PATH, nullptr, retvals);
|
||||
return std::string(retvals);
|
||||
}
|
||||
|
||||
void Receiver::setFilePath(const std::string &path) {
|
||||
if (path.empty()) {
|
||||
throw RuntimeError("Cannot set empty file path");
|
||||
}
|
||||
char args[MAX_STR_LENGTH]{};
|
||||
sls::strcpy_safe(args, path.c_str());
|
||||
sendToReceiver(F_SET_RECEIVER_FILE_PATH, args, nullptr);
|
||||
}
|
||||
|
||||
std::string Receiver::getFileName() const {
|
||||
char retvals[MAX_STR_LENGTH]{};
|
||||
sendToReceiver(F_GET_RECEIVER_FILE_NAME, nullptr, retvals);
|
||||
return std::string(retvals);
|
||||
}
|
||||
|
||||
void Receiver::setFileName(const std::string &fname) {
|
||||
if (fname.empty()) {
|
||||
throw RuntimeError("Cannot set empty file name prefix");
|
||||
}
|
||||
char args[MAX_STR_LENGTH]{};
|
||||
sls::strcpy_safe(args, fname.c_str());
|
||||
sendToReceiver(F_SET_RECEIVER_FILE_NAME, args, nullptr);
|
||||
}
|
||||
|
||||
int64_t Receiver::getFileIndex() const {
|
||||
return sendToReceiver<int64_t>(F_GET_RECEIVER_FILE_INDEX);
|
||||
}
|
||||
|
||||
void Receiver::setFileIndex(const int64_t file_index) {
|
||||
sendToReceiver(F_SET_RECEIVER_FILE_INDEX, file_index, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::incrementFileIndex() {
|
||||
sendToReceiver(F_INCREMENT_FILE_INDEX, nullptr, nullptr);
|
||||
}
|
||||
|
||||
slsDetectorDefs::fileFormat Receiver::getFileFormat() const {
|
||||
return static_cast<fileFormat>(
|
||||
sendToReceiver<int>(F_GET_RECEIVER_FILE_FORMAT));
|
||||
}
|
||||
|
||||
void Receiver::setFileFormat(const fileFormat f) {
|
||||
int arg = static_cast<int>(f);
|
||||
sendToReceiver(F_SET_RECEIVER_FILE_FORMAT, arg, nullptr);
|
||||
}
|
||||
|
||||
int Receiver::getFramesPerFile() const {
|
||||
return sendToReceiver<int>(F_GET_RECEIVER_FRAMES_PER_FILE);
|
||||
}
|
||||
|
||||
void Receiver::setFramesPerFile(const int n_frames) {
|
||||
sendToReceiver(F_SET_RECEIVER_FRAMES_PER_FILE, n_frames, nullptr);
|
||||
}
|
||||
|
||||
bool Receiver::getFileWrite() const {
|
||||
return sendToReceiver<int>(F_GET_RECEIVER_FILE_WRITE);
|
||||
}
|
||||
|
||||
void Receiver::setFileWrite(const bool value) {
|
||||
int arg = static_cast<int>(value);
|
||||
sendToReceiver(F_SET_RECEIVER_FILE_WRITE, arg, nullptr);
|
||||
}
|
||||
|
||||
bool Receiver::getMasterFileWrite() const {
|
||||
return sendToReceiver<int>(F_GET_RECEIVER_MASTER_FILE_WRITE);
|
||||
}
|
||||
|
||||
void Receiver::setMasterFileWrite(const bool value) {
|
||||
int arg = static_cast<int>(value);
|
||||
sendToReceiver(F_SET_RECEIVER_MASTER_FILE_WRITE, arg, nullptr);
|
||||
}
|
||||
|
||||
bool Receiver::getFileOverWrite() const {
|
||||
return sendToReceiver<int>(F_GET_RECEIVER_OVERWRITE);
|
||||
}
|
||||
|
||||
void Receiver::setFileOverWrite(const bool value) {
|
||||
int arg = static_cast<int>(value);
|
||||
sendToReceiver(F_SET_RECEIVER_OVERWRITE, arg, nullptr);
|
||||
}
|
||||
|
||||
/** Detector Parameters */
|
||||
|
||||
void Receiver::setNumberOfFrames(const int64_t value) {
|
||||
LOG(logDEBUG1) << "Sending number of frames to Receiver: " << value;
|
||||
sendToReceiver(F_RECEIVER_SET_NUM_FRAMES, value, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setNumberOfTriggers(const int64_t value) {
|
||||
LOG(logDEBUG1) << "Sending number of triggers to Receiver: " << value;
|
||||
sendToReceiver(F_SET_RECEIVER_NUM_TRIGGERS, value, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setNumberOfBursts(const int64_t value) {
|
||||
LOG(logDEBUG1) << "Sending number of bursts to Receiver: " << value;
|
||||
sendToReceiver(F_SET_RECEIVER_NUM_BURSTS, value, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setNumberOfAnalogSamples(const int value) {
|
||||
LOG(logDEBUG1) << "Sending number of analog samples to Receiver: " << value;
|
||||
sendToReceiver(F_RECEIVER_SET_NUM_ANALOG_SAMPLES, value, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setNumberOfDigitalSamples(const int value) {
|
||||
LOG(logDEBUG1) << "Sending number of digital samples to Receiver: " << value;
|
||||
sendToReceiver(F_RECEIVER_SET_NUM_DIGITAL_SAMPLES, value, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setExptime(const int64_t value) {
|
||||
LOG(logDEBUG1) << "Sending exptime to Receiver: " << value;
|
||||
sendToReceiver(F_RECEIVER_SET_EXPTIME, value, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setPeriod(const int64_t value) {
|
||||
LOG(logDEBUG1) << "Sending period to Receiver: " << value;
|
||||
sendToReceiver(F_RECEIVER_SET_PERIOD, value, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setSubExptime(const int64_t value) {
|
||||
LOG(logDEBUG1) << "Sending sub exptime to Receiver: " << value;
|
||||
sendToReceiver(F_RECEIVER_SET_SUB_EXPTIME, value, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setSubDeadTime(const int64_t value) {
|
||||
LOG(logDEBUG1) << "Sending sub deadtime to Receiver: " << value;
|
||||
sendToReceiver(F_RECEIVER_SET_SUB_DEADTIME, value, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setTimingMode(const timingMode value) {
|
||||
LOG(logDEBUG1) << "Sending timing mode to Receiver: " << value;
|
||||
sendToReceiver(F_SET_RECEIVER_TIMING_MODE, value, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setDynamicRange(const int n) {
|
||||
int retval = -1;
|
||||
LOG(logDEBUG1) << "Sending dynamic range to receiver: " << n;
|
||||
sendToReceiver(F_SET_RECEIVER_DYNAMIC_RANGE, n, retval);
|
||||
}
|
||||
|
||||
void Receiver::setReadoutMode(const slsDetectorDefs::readoutMode mode) {
|
||||
sendToReceiver(F_RECEIVER_SET_READOUT_MODE, mode, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setQuad(const bool enable) {
|
||||
int value = enable ? 1 : 0;
|
||||
LOG(logDEBUG1) << "Setting Quad type to " << value << " in Receiver";
|
||||
sendToReceiver(F_SET_RECEIVER_QUAD, value, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setReadNLines(const int value) {
|
||||
LOG(logDEBUG1) << "Setting read n lines to " << value
|
||||
<< " in Receiver";
|
||||
sendToReceiver(F_SET_RECEIVER_READ_N_LINES, value, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setADCEnableMask(const uint32_t mask) {
|
||||
sendToReceiver(F_RECEIVER_SET_ADC_MASK, mask, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setTenGigaADCEnableMask(const uint32_t mask) {
|
||||
sendToReceiver(F_RECEIVER_SET_ADC_MASK_10G, mask, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setBurstMode(const slsDetectorDefs::burstMode value) {
|
||||
LOG(logDEBUG1) << "Sending burst mode to Receiver: " << value;
|
||||
sendToReceiver(F_SET_RECEIVER_BURST_MODE, value, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setROI(const slsDetectorDefs::ROI arg) {
|
||||
std::array<int, 2> args{arg.xmin, arg.xmax};
|
||||
LOG(logDEBUG1) << "Sending ROI to receiver";
|
||||
sendToReceiver(F_RECEIVER_SET_ROI, args, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::clearROI() {
|
||||
LOG(logDEBUG1) << "Clearing ROI";
|
||||
slsDetectorDefs::ROI arg;
|
||||
arg.xmin = -1;
|
||||
arg.xmax = -1;
|
||||
setROI(arg);
|
||||
}
|
||||
|
||||
std::vector<int> Receiver::getDbitList() const {
|
||||
sls::FixedCapacityContainer<int, MAX_RX_DBIT> retval;
|
||||
sendToReceiver(F_GET_RECEIVER_DBIT_LIST, nullptr, retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void Receiver::setDbitList(const std::vector<int>& list) {
|
||||
LOG(logDEBUG1) << "Setting Receiver Dbit List";
|
||||
if (list.size() > 64) {
|
||||
throw sls::RuntimeError("Dbit list size cannot be greater than 64\n");
|
||||
}
|
||||
for (auto &it : list) {
|
||||
if (it < 0 || it > 63) {
|
||||
throw sls::RuntimeError(
|
||||
"Dbit list value must be between 0 and 63\n");
|
||||
}
|
||||
}
|
||||
sls::FixedCapacityContainer<int, MAX_RX_DBIT> arg = list;
|
||||
sendToReceiver(F_SET_RECEIVER_DBIT_LIST, arg, nullptr);
|
||||
}
|
||||
|
||||
int Receiver::getDbitOffset() const {
|
||||
return sendToReceiver<int>(F_GET_RECEIVER_DBIT_OFFSET);
|
||||
}
|
||||
|
||||
void Receiver::setDbitOffset(const int value) {
|
||||
sendToReceiver(F_SET_RECEIVER_DBIT_OFFSET, value, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setActivate(const bool enable) {
|
||||
int arg = static_cast<int>(enable);
|
||||
sendToReceiver(F_RECEIVER_ACTIVATE, arg, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setTenGiga(const bool enable) {
|
||||
int arg = static_cast<int>(enable);
|
||||
sendToReceiver(F_ENABLE_RECEIVER_TEN_GIGA, arg, nullptr);
|
||||
}
|
||||
|
||||
void Receiver::setCounterMask(const uint32_t mask) {
|
||||
int ncounters = __builtin_popcount(mask);
|
||||
LOG(logDEBUG1) << "Sending Reciver #counters: " << ncounters;
|
||||
sendToReceiver(F_RECEIVER_SET_NUM_COUNTERS, ncounters, nullptr);
|
||||
}
|
||||
|
||||
/** Json */
|
||||
|
||||
std::map<std::string, std::string> Receiver::getAdditionalJsonHeader() const {
|
||||
int fnum = F_GET_ADDITIONAL_JSON_HEADER;
|
||||
int ret = FAIL;
|
||||
int size = 0;
|
||||
auto client = ReceiverSocket(shm()->hostname, shm()->tcpPort);
|
||||
client.Send(&fnum, sizeof(fnum));
|
||||
client.Receive(&ret, sizeof(ret));
|
||||
if (ret == FAIL) {
|
||||
char mess[MAX_STR_LENGTH]{};
|
||||
client.Receive(mess, MAX_STR_LENGTH);
|
||||
throw RuntimeError("Receiver " + std::to_string(moduleId) +
|
||||
" returned error: " + std::string(mess));
|
||||
} else {
|
||||
client.Receive(&size, sizeof(size));
|
||||
std::map<std::string, std::string> retval;
|
||||
if (size > 0) {
|
||||
char retvals[size * 2][SHORT_STR_LENGTH];
|
||||
memset(retvals, 0, sizeof(retvals));
|
||||
client.Receive(retvals, sizeof(retvals));
|
||||
for (int i = 0; i < size; ++i) {
|
||||
retval[retvals[2 * i]] = retvals[2 * i + 1];
|
||||
}
|
||||
}
|
||||
LOG(logDEBUG) << "Getting additional json header " << ToString(retval);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
void Receiver::setAdditionalJsonHeader(const std::map<std::string, std::string> &jsonHeader) {
|
||||
for (auto &it : jsonHeader) {
|
||||
if (it.first.empty() || it.first.length() > SHORT_STR_LENGTH ||
|
||||
it.second.length() > SHORT_STR_LENGTH ) {
|
||||
throw RuntimeError(it.first + " or " + it.second + " pair has invalid size. "
|
||||
"Key cannot be empty. Both can have max 20 characters");
|
||||
}
|
||||
}
|
||||
const int size = jsonHeader.size();
|
||||
int fnum = F_SET_ADDITIONAL_JSON_HEADER;
|
||||
int ret = FAIL;
|
||||
LOG(logDEBUG) << "Sending to receiver additional json header " << ToString(jsonHeader);
|
||||
auto client = ReceiverSocket(shm()->hostname, shm()->tcpPort);
|
||||
client.Send(&fnum, sizeof(fnum));
|
||||
client.Send(&size, sizeof(size));
|
||||
if (size > 0) {
|
||||
char args[size * 2][SHORT_STR_LENGTH];
|
||||
memset(args, 0, sizeof(args));
|
||||
int iarg = 0;
|
||||
for (auto &it : jsonHeader) {
|
||||
sls::strcpy_safe(args[iarg], it.first.c_str());
|
||||
sls::strcpy_safe(args[iarg + 1], it.second.c_str());
|
||||
iarg += 2;
|
||||
}
|
||||
client.Send(args, sizeof(args));
|
||||
}
|
||||
client.Receive(&ret, sizeof(ret));
|
||||
if (ret == FAIL) {
|
||||
char mess[MAX_STR_LENGTH]{};
|
||||
client.Receive(mess, MAX_STR_LENGTH);
|
||||
throw RuntimeError("Receiver " + std::to_string(moduleId) +
|
||||
" returned error: " + std::string(mess));
|
||||
}
|
||||
}
|
||||
|
||||
std::string Receiver::getAdditionalJsonParameter(const std::string &key) const {
|
||||
char arg[SHORT_STR_LENGTH]{};
|
||||
sls::strcpy_safe(arg, key.c_str());
|
||||
char retval[SHORT_STR_LENGTH]{};
|
||||
sendToReceiver(F_GET_ADDITIONAL_JSON_PARAMETER, arg, retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void Receiver::setAdditionalJsonParameter(const std::string &key, const std::string &value) {
|
||||
if (key.empty() || key.length() > SHORT_STR_LENGTH ||
|
||||
value.length() > SHORT_STR_LENGTH ) {
|
||||
throw RuntimeError(key + " or " + value + " pair has invalid size. "
|
||||
"Key cannot be empty. Both can have max 2 characters");
|
||||
}
|
||||
char args[2][SHORT_STR_LENGTH]{};
|
||||
sls::strcpy_safe(args[0], key.c_str());
|
||||
sls::strcpy_safe(args[1], value.c_str());
|
||||
sendToReceiver(F_SET_ADDITIONAL_JSON_PARAMETER, args, nullptr);
|
||||
}
|
||||
|
||||
|
||||
void Receiver::sendToReceiver(int fnum, const void *args, size_t args_size,
|
||||
void *retval, size_t retval_size) {
|
||||
static_cast<const Receiver &>(*this).sendToReceiver(
|
||||
fnum, args, args_size, retval, retval_size);
|
||||
}
|
||||
|
||||
void Receiver::sendToReceiver(int fnum, const void *args, size_t args_size,
|
||||
void *retval, size_t retval_size) const {
|
||||
if (strlen(shm()->hostname) == 0) {
|
||||
throw RuntimeError("Reciver not added");
|
||||
}
|
||||
auto receiver = ReceiverSocket(shm()->hostname, shm()->tcpPort);
|
||||
receiver.sendCommandThenRead(fnum, args, args_size, retval, retval_size);
|
||||
receiver.close();
|
||||
}
|
||||
|
||||
template <typename Arg, typename Ret>
|
||||
void Receiver::sendToReceiver(int fnum, const Arg &args, Ret &retval) {
|
||||
sendToReceiver(fnum, &args, sizeof(args), &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
template <typename Arg, typename Ret>
|
||||
void Receiver::sendToReceiver(int fnum, const Arg &args, Ret &retval) const {
|
||||
sendToReceiver(fnum, &args, sizeof(args), &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
template <typename Arg>
|
||||
void Receiver::sendToReceiver(int fnum, const Arg &args, std::nullptr_t) {
|
||||
sendToReceiver(fnum, &args, sizeof(args), nullptr, 0);
|
||||
}
|
||||
|
||||
template <typename Arg>
|
||||
void Receiver::sendToReceiver(int fnum, const Arg &args,
|
||||
std::nullptr_t) const {
|
||||
sendToReceiver(fnum, &args, sizeof(args), nullptr, 0);
|
||||
}
|
||||
|
||||
template <typename Ret>
|
||||
void Receiver::sendToReceiver(int fnum, std::nullptr_t, Ret &retval) {
|
||||
sendToReceiver(fnum, nullptr, 0, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
template <typename Ret>
|
||||
void Receiver::sendToReceiver(int fnum, std::nullptr_t, Ret &retval) const {
|
||||
sendToReceiver(fnum, nullptr, 0, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
template <typename Ret>
|
||||
Ret Receiver::sendToReceiver(int fnum){
|
||||
LOG(logDEBUG1) << "Sending: ["
|
||||
<< getFunctionNameFromEnum(static_cast<slsDetectorDefs::detFuncs>(fnum))
|
||||
<< ", nullptr, 0, " << typeid(Ret).name() << ", " << sizeof(Ret) << "]";
|
||||
Ret retval{};
|
||||
sendToReceiver(fnum, nullptr, 0, &retval, sizeof(retval));
|
||||
LOG(logDEBUG1) << "Got back: " << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
template <typename Ret>
|
||||
Ret Receiver::sendToReceiver(int fnum) const{
|
||||
LOG(logDEBUG1) << "Sending: ["
|
||||
<< getFunctionNameFromEnum(static_cast<slsDetectorDefs::detFuncs>(fnum))
|
||||
<< ", nullptr, 0, " << typeid(Ret).name() << ", " << sizeof(Ret) << "]";
|
||||
Ret retval{};
|
||||
sendToReceiver(fnum, nullptr, 0, &retval, sizeof(retval));
|
||||
LOG(logDEBUG1) << "Got back: " << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
template <typename Ret, typename Arg>
|
||||
Ret Receiver::sendToReceiver(int fnum, const Arg &args){
|
||||
LOG(logDEBUG1) << "Sending: ["
|
||||
<< getFunctionNameFromEnum(static_cast<slsDetectorDefs::detFuncs>(fnum))
|
||||
<< ", " << args << ", " << sizeof(args) << ", " << typeid(Ret).name()
|
||||
<< ", " << sizeof(Ret) << "]";
|
||||
Ret retval{};
|
||||
sendToReceiver(fnum, &args, sizeof(args), &retval, sizeof(retval));
|
||||
LOG(logDEBUG1) << "Got back: " << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
template <typename Ret, typename Arg>
|
||||
Ret Receiver::sendToReceiver(int fnum, const Arg &args) const{
|
||||
LOG(logDEBUG1) << "Sending: ["
|
||||
<< getFunctionNameFromEnum(static_cast<slsDetectorDefs::detFuncs>(fnum))
|
||||
<< ", " << args << ", " << sizeof(args) << ", " << typeid(Ret).name()
|
||||
<< ", " << sizeof(Ret) << "]";
|
||||
Ret retval{};
|
||||
sendToReceiver(fnum, &args, sizeof(args), &retval, sizeof(retval));
|
||||
LOG(logDEBUG1) << "Got back: " << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
} // namespace sls
|
258
slsDetectorSoftware/src/Receiver.h
Executable file
258
slsDetectorSoftware/src/Receiver.h
Executable file
@ -0,0 +1,258 @@
|
||||
#pragma once
|
||||
#include "SharedMemory.h"
|
||||
#include "logger.h"
|
||||
#include "sls_detector_defs.h"
|
||||
#include "network_utils.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#define RECEIVER_SHMVERSION 0x200421
|
||||
|
||||
class ZmqSocket;
|
||||
|
||||
namespace sls {
|
||||
struct sharedReceiver {
|
||||
|
||||
/* FIXED PATTERN FOR STATIC FUNCTIONS. DO NOT CHANGE, ONLY APPEND ------*/
|
||||
int shmversion;
|
||||
char hostname[MAX_STR_LENGTH];
|
||||
int tcpPort;
|
||||
/** END OF FIXED PATTERN -----------------------------------------------*/
|
||||
|
||||
int stoppedFlag;
|
||||
int zmqPort;
|
||||
sls::IpAddr zmqIp;
|
||||
|
||||
};
|
||||
|
||||
class Receiver : public virtual slsDetectorDefs {
|
||||
public:
|
||||
static size_t getNumReceivers();
|
||||
// create shm
|
||||
explicit Receiver(int detector_id, int module_id, int interface_id,
|
||||
int receiver_id, int tcp_port = 0, std::string hostname = "",
|
||||
int zmq_port = 0);
|
||||
// open shm
|
||||
explicit Receiver(int detector_id, int module_id, int interface_id,
|
||||
int receiver_id, bool verify);
|
||||
|
||||
virtual ~Receiver();
|
||||
|
||||
void createIndexString();
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
* Configuration *
|
||||
* *
|
||||
* ************************************************/
|
||||
/**
|
||||
* Free shared memory and delete shared memory structure
|
||||
* occupied by the sharedReceiver structure
|
||||
* Is only safe to call if one deletes the Receiver object afterward
|
||||
* and frees multi shared memory/updates
|
||||
* thisMultiDetector->numberOfReceivers
|
||||
*/
|
||||
void freeSharedMemory();
|
||||
std::string getHostname() const;
|
||||
void setHostname(const std::string &hostname);
|
||||
sls::MacAddr configure(slsDetectorDefs::rxParameters arg);
|
||||
int getTCPPort() const;
|
||||
void setTCPPort(const int port);
|
||||
std::string printConfiguration();
|
||||
int64_t getSoftwareVersion() const;
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
* Acquisition *
|
||||
* *
|
||||
* ************************************************/
|
||||
void start();
|
||||
void stop();
|
||||
slsDetectorDefs::runStatus getStatus() const;
|
||||
int getProgress() const;
|
||||
void setStoppedFlag();
|
||||
void restreamStop();
|
||||
uint64_t getFramesCaught() const;
|
||||
uint64_t getNumMissingPackets() const;
|
||||
uint64_t getCurrentFrameIndex() const;
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
* Network Configuration (Detector<->Receiver) *
|
||||
* *
|
||||
* ************************************************/
|
||||
sls::MacAddr setUDPIP(const sls::IpAddr ip);
|
||||
void setUDPPort(const int udpport);
|
||||
int64_t getUDPSocketBufferSize() const;
|
||||
void setUDPSocketBufferSize(int64_t value);
|
||||
int64_t getRealUDPSocketBufferSize() const;
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
* ZMQ Streaming Parameters (Receiver<->Client)*
|
||||
* *
|
||||
* ************************************************/
|
||||
bool getZmq() const;
|
||||
void setZmq(const bool enable);
|
||||
int getZmqFrequency() const;
|
||||
/** Freq = 0 for a timer, else frequency */
|
||||
void setZmqFrequency(const int freq);
|
||||
int getZmqTimer() const;
|
||||
void setZmqTimer(const int time_in_ms = 200);
|
||||
int getZmqPort() const;
|
||||
void setZmqPort(int port);
|
||||
sls::IpAddr getZmqIP() const;
|
||||
void setZmqIP(const sls::IpAddr ip);
|
||||
int getClientZmqPort() const;
|
||||
void setClientZmqPort(const int port);
|
||||
sls::IpAddr getClientZmqIP() const;
|
||||
void setClientZmqIP(const sls::IpAddr ip);
|
||||
bool getClientZmq() const;
|
||||
void setClientZmq(const bool enable);
|
||||
ZmqSocket* getZmqSocket();
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
* Receiver Parameters *
|
||||
* *
|
||||
* ************************************************/
|
||||
bool getLock() const;
|
||||
void setLock(const bool lock);
|
||||
sls::IpAddr getLastClientIP() const;
|
||||
void exitServer();
|
||||
|
||||
bool getDeactivatedPaddingMode() const;
|
||||
void setDeactivatedPaddingMode(const bool padding);
|
||||
bool getFlippedDataX() const;
|
||||
void setFlippedDataX(const bool value);
|
||||
frameDiscardPolicy getFramesDiscardPolicy() const;
|
||||
void setFramesDiscardPolicy(const frameDiscardPolicy f);
|
||||
bool getPartialFramesPadding() const;
|
||||
void setPartialFramesPadding(const bool padding);
|
||||
int getFifoDepth() const;
|
||||
void setFifoDepth(const int value);
|
||||
bool getSilentMode() const;
|
||||
void setSilentMode(const bool value);
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
* File *
|
||||
* *
|
||||
* ************************************************/
|
||||
std::string getFilePath() const;
|
||||
void setFilePath(const std::string &path);
|
||||
std::string getFileName() const;
|
||||
void setFileName(const std::string &fname);
|
||||
int64_t getFileIndex() const;
|
||||
void setFileIndex(const int64_t file_index);
|
||||
void incrementFileIndex();
|
||||
fileFormat getFileFormat() const;
|
||||
void setFileFormat(const fileFormat f);
|
||||
int getFramesPerFile() const;
|
||||
/** 0 will set frames per file to unlimited */
|
||||
void setFramesPerFile(const int n_frames);
|
||||
bool getFileWrite() const;
|
||||
void setFileWrite(const bool value);
|
||||
bool getMasterFileWrite() const;
|
||||
void setMasterFileWrite(const bool value);
|
||||
bool getFileOverWrite() const;
|
||||
void setFileOverWrite(const bool value);
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
* Detector Parameters *
|
||||
* *
|
||||
* ************************************************/
|
||||
void setNumberOfFrames(const int64_t value);
|
||||
void setNumberOfTriggers(const int64_t value);
|
||||
void setNumberOfBursts(const int64_t value);
|
||||
void setNumberOfAnalogSamples(const int value);
|
||||
void setNumberOfDigitalSamples(const int value);
|
||||
void setExptime(const int64_t value);
|
||||
void setPeriod(const int64_t value);
|
||||
void setSubExptime(const int64_t value);
|
||||
void setSubDeadTime(const int64_t value);
|
||||
void setTimingMode(const timingMode value);
|
||||
void setDynamicRange(const int n);
|
||||
void setReadoutMode(const readoutMode mode);
|
||||
void setQuad(const bool enable);
|
||||
void setReadNLines(const int value);
|
||||
void setADCEnableMask(const uint32_t mask);
|
||||
void setTenGigaADCEnableMask(const uint32_t mask);
|
||||
void setBurstMode(const burstMode value);
|
||||
void setROI(const slsDetectorDefs::ROI arg);
|
||||
void clearROI();
|
||||
std::vector<int> getDbitList() const;
|
||||
/** digital data bits enable (CTB only) */
|
||||
void setDbitList(const std::vector<int>& list);
|
||||
int getDbitOffset() const;
|
||||
/** Set digital data offset in bytes (CTB only) */
|
||||
void setDbitOffset(const int value);
|
||||
void setActivate(const bool enable);
|
||||
void setTenGiga(const bool enable);
|
||||
void setCounterMask(const uint32_t mask);
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
* Json *
|
||||
* *
|
||||
* ************************************************/
|
||||
|
||||
std::map<std::string, std::string> getAdditionalJsonHeader() const;
|
||||
/** empty vector deletes entire additional json header */
|
||||
void setAdditionalJsonHeader(const std::map<std::string, std::string> &jsonHeader);
|
||||
std::string getAdditionalJsonParameter(const std::string &key) const;
|
||||
/** Sets the value for the additional json header parameter key if found,
|
||||
else append it. If value empty, then deletes parameter */
|
||||
void setAdditionalJsonParameter(const std::string &key, const std::string &value);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
void sendToReceiver(int fnum, const void *args, size_t args_size,
|
||||
void *retval, size_t retval_size);
|
||||
|
||||
void sendToReceiver(int fnum, const void *args, size_t args_size,
|
||||
void *retval, size_t retval_size) const;
|
||||
|
||||
template <typename Arg, typename Ret>
|
||||
void sendToReceiver(int fnum, const Arg &args, Ret &retval);
|
||||
|
||||
template <typename Arg, typename Ret>
|
||||
void sendToReceiver(int fnum, const Arg &args, Ret &retval) const;
|
||||
|
||||
template <typename Arg>
|
||||
void sendToReceiver(int fnum, const Arg &args, std::nullptr_t);
|
||||
|
||||
template <typename Arg>
|
||||
void sendToReceiver(int fnum, const Arg &args, std::nullptr_t) const;
|
||||
|
||||
template <typename Ret>
|
||||
void sendToReceiver(int fnum, std::nullptr_t, Ret &retval);
|
||||
|
||||
template <typename Ret>
|
||||
void sendToReceiver(int fnum, std::nullptr_t, Ret &retval) const;
|
||||
|
||||
template <typename Ret>
|
||||
Ret sendToReceiver(int fnum);
|
||||
|
||||
template <typename Ret>
|
||||
Ret sendToReceiver(int fnum) const;
|
||||
|
||||
template <typename Ret, typename Arg>
|
||||
Ret sendToReceiver(int fnum, const Arg &args);
|
||||
|
||||
template <typename Ret, typename Arg>
|
||||
Ret sendToReceiver(int fnum, const Arg &args) const;
|
||||
|
||||
void checkVersionCompatibility();
|
||||
const int receiverId{0};
|
||||
const int interfaceId{0};
|
||||
const int moduleId{0};
|
||||
std::string indexString;
|
||||
mutable sls::SharedMemory<sharedReceiver> shm{0, 0, 0, 0};
|
||||
std::unique_ptr<ZmqSocket> zmqSocket;
|
||||
};
|
||||
|
||||
} // sls
|
@ -8,7 +8,6 @@
|
||||
*@short functions basic implemenation of shared memory
|
||||
*/
|
||||
|
||||
#include "ansi.h"
|
||||
#include "logger.h"
|
||||
#include "sls_detector_exceptions.h"
|
||||
|
||||
@ -18,13 +17,14 @@
|
||||
#include <fcntl.h> // O_CREAT, O_TRUNC..
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <stdio.h> // printf
|
||||
// #include <stdio.h> // printf
|
||||
#include <sys/mman.h> // shared memory
|
||||
#include <sys/stat.h> // fstat
|
||||
#include <unistd.h>
|
||||
|
||||
#define SHM_MULTI_PREFIX "/slsDetectorPackage_multi_"
|
||||
#define SHM_SLS_PREFIX "_sls_"
|
||||
#define SHM_MODULE_PREFIX "_module_"
|
||||
#define SHM_RECEIVER_PREFIX "_receiver_"
|
||||
#define SHM_ENV_NAME "SLSDETNAME"
|
||||
|
||||
#include <iostream>
|
||||
@ -40,10 +40,12 @@ class SharedMemory {
|
||||
* Constructor
|
||||
* creates the single/multi detector shared memory name
|
||||
* @param multiId multi detector id
|
||||
* @param slsId sls detector id, -1 if a multi detector shared memory
|
||||
* @param moduleId module detectr id, -1 if a multi detector shared memory
|
||||
* @param interfaceId 0 for primary interface, 1 for secondary
|
||||
* @param receiverId receiver id, -1 if not a rxr shm, else round robin entry
|
||||
*/
|
||||
SharedMemory(int multiId, int slsId) {
|
||||
name = ConstructSharedMemoryName(multiId, slsId);
|
||||
SharedMemory(int multiId, int moduleId, int interfaceId = 0, int receiverId = -1) {
|
||||
name = ConstructSharedMemoryName(multiId, moduleId, interfaceId, receiverId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -185,7 +187,8 @@ class SharedMemory {
|
||||
// silent exit if shm did not exist anyway
|
||||
if (errno == ENOENT)
|
||||
return;
|
||||
std::string msg = "Free Shared Memory " + name + " Failed: " + strerror(errno);
|
||||
std::string msg = "Free Shared Memory " + name + " Failed: " +
|
||||
strerror(errno);
|
||||
LOG(logERROR) << msg;
|
||||
throw SharedMemoryError(msg);
|
||||
}
|
||||
@ -216,10 +219,13 @@ class SharedMemory {
|
||||
* Create Shared memory name
|
||||
* throws exception if name created is longer than required 255(manpages)
|
||||
* @param multiId multi detector id
|
||||
* @param slsId sls detector id, -1 if a multi detector shared memory
|
||||
* @param moduleId module detector id, -1 if a multi detector shared memory
|
||||
* @param interfaceId 0 for primary interface, 1 for secondary
|
||||
* @param receiverId receiver id, -1 if not a rxr shm, else round robin entry
|
||||
* @returns shared memory name
|
||||
*/
|
||||
std::string ConstructSharedMemoryName(int multiId, int slsId) {
|
||||
std::string ConstructSharedMemoryName(int multiId, int moduleId,
|
||||
int interfaceId = 0, int receiverId = -1) {
|
||||
|
||||
// using environment path
|
||||
std::string sEnvPath = "";
|
||||
@ -230,14 +236,22 @@ class SharedMemory {
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
if (slsId < 0)
|
||||
if (moduleId < 0 && receiverId < 0)
|
||||
ss << SHM_MULTI_PREFIX << multiId << sEnvPath;
|
||||
else if (receiverId < 0)
|
||||
ss << SHM_MULTI_PREFIX << multiId <<
|
||||
SHM_MODULE_PREFIX << moduleId << sEnvPath;
|
||||
else
|
||||
ss << SHM_MULTI_PREFIX << multiId << SHM_SLS_PREFIX << slsId << sEnvPath;
|
||||
ss << SHM_MULTI_PREFIX << multiId <<
|
||||
SHM_MODULE_PREFIX << moduleId <<
|
||||
SHM_RECEIVER_PREFIX << (char)(interfaceId + 97) << '_' << receiverId << sEnvPath;
|
||||
|
||||
std::string temp = ss.str();
|
||||
if (temp.length() > NAME_MAX_LENGTH) {
|
||||
std::string msg = "Shared memory initialization failed. " + temp + " has " + std::to_string(temp.length()) + " characters. \n" + "Maximum is " + std::to_string(NAME_MAX_LENGTH) + ". Change the environment variable " + SHM_ENV_NAME;
|
||||
std::string msg = "Shared memory initialization failed. " +
|
||||
temp + " has " + std::to_string(temp.length()) + " characters. \n" +
|
||||
"Maximum is " + std::to_string(NAME_MAX_LENGTH) +
|
||||
". Change the environment variable " + SHM_ENV_NAME;
|
||||
LOG(logERROR) << msg;
|
||||
throw SharedMemoryError(msg);
|
||||
}
|
||||
@ -251,9 +265,11 @@ class SharedMemory {
|
||||
*/
|
||||
|
||||
T *MapSharedMemory() {
|
||||
void *addr = mmap(nullptr, sizeof(T), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
void *addr = mmap(nullptr, sizeof(T), PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, fd, 0);
|
||||
if (addr == MAP_FAILED) {
|
||||
std::string msg = "Mapping shared memory " + name + " failed: " + strerror(errno);
|
||||
std::string msg = "Mapping shared memory " + name + " failed: " +
|
||||
strerror(errno);
|
||||
LOG(logERROR) << msg;
|
||||
close(fd);
|
||||
throw SharedMemoryError(msg);
|
||||
@ -272,7 +288,8 @@ class SharedMemory {
|
||||
struct stat sb;
|
||||
// could not fstat
|
||||
if (fstat(fd, &sb) < 0) {
|
||||
std::string msg = "Could not verify existing shared memory " + name + " size match " + "(could not fstat): " + strerror(errno);
|
||||
std::string msg = "Could not verify existing shared memory " +
|
||||
name + " size match " + "(could not fstat): " + strerror(errno);
|
||||
LOG(logERROR) << msg;
|
||||
close(fd);
|
||||
throw SharedMemoryError(msg);
|
||||
@ -281,7 +298,9 @@ class SharedMemory {
|
||||
//size does not match
|
||||
auto sz = static_cast<size_t>(sb.st_size);
|
||||
if (sz != expectedSize) {
|
||||
std::string msg = "Existing shared memory " + name + " size does not match" + "Expected " + std::to_string(expectedSize) + ", found " + std::to_string(sz);
|
||||
std::string msg = "Existing shared memory " + name +
|
||||
" size does not match" + "Expected " +
|
||||
std::to_string(expectedSize) + ", found " + std::to_string(sz);
|
||||
LOG(logERROR) << msg;
|
||||
throw SharedMemoryError(msg);
|
||||
return 1;
|
||||
|
@ -15,7 +15,9 @@ using sls::Detector;
|
||||
using test::GET;
|
||||
using test::PUT;
|
||||
|
||||
TEST_CASE("Setting and reading back Chip test board dacs", "[.cmd][.dacs]") {
|
||||
/* dacs */
|
||||
|
||||
TEST_CASE("Setting and reading back Chip test board dacs", "[.cmd][.dacs][.new]") {
|
||||
// dac 0 to dac 17
|
||||
|
||||
Detector det;
|
||||
@ -23,12 +25,12 @@ TEST_CASE("Setting and reading back Chip test board dacs", "[.cmd][.dacs]") {
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::CHIPTESTBOARD) {
|
||||
for (int i = 0; i < 18; ++i) {
|
||||
SECTION("dac " + std::to_string(i)) { test_dac(static_cast<defs::dacIndex>(i), "dac " + std::to_string(i), 0); }
|
||||
SECTION("dac " + std::to_string(i)) { test_dac(static_cast<defs::dacIndex>(i), "dac", 0); }
|
||||
}
|
||||
// eiger
|
||||
REQUIRE_THROWS(proxy.Call("vthreshold", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vsvp", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vsvn", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vthreshold", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vsvp", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vsvn", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vtr", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vrf", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vrs", {}, -1, GET));
|
||||
@ -51,30 +53,30 @@ TEST_CASE("Setting and reading back Chip test board dacs", "[.cmd][.dacs]") {
|
||||
REQUIRE_THROWS(proxy.Call("vref_prech", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vb_pixbuf", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vb_ds", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET));
|
||||
// gotthard
|
||||
REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcascn_pb", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcascp_pb", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vout_cm", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcasc_out", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vin_cm", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("ib_test_c", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vcascn_pb", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vcascp_pb", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vout_cm", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vcasc_out", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vin_cm", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("ib_test_c", {}, -1, GET));
|
||||
// mythen3
|
||||
REQUIRE_THROWS(proxy.Call("vpreamp", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vshaper", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vshaperneg", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vpreamp", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vshaper", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vshaperneg", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vipre", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("viinsh", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vdcsh", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vth1", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vth1", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vth2", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vth3", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vpl", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vph", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vtrim", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vph", {}, -1, GET));
|
||||
//REQUIRE_THROWS(proxy.Call("vtrim", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcassh", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcas", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vicin", {}, -1, GET));
|
||||
|
@ -13,6 +13,245 @@ using sls::CmdProxy;
|
||||
using sls::Detector;
|
||||
using test::GET;
|
||||
using test::PUT;
|
||||
|
||||
|
||||
/** temperature */
|
||||
|
||||
TEST_CASE("temp_fpgaext", "[.cmd][.new]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::EIGER) {
|
||||
REQUIRE_NOTHROW(proxy.Call("temp_fpgaext", {}, -1, GET));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(proxy.Call("temp_fpgaext", {}, 0, GET, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("temp_fpgaext "));
|
||||
REQUIRE(std::stoi(s) != -1);
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("temp_fpgaext", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("temp_10ge", "[.cmd][.new]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::EIGER) {
|
||||
REQUIRE_NOTHROW(proxy.Call("temp_10ge", {}, -1, GET));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(proxy.Call("temp_10ge", {}, 0, GET, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("temp_10ge "));
|
||||
REQUIRE(std::stoi(s) != -1);
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("temp_10ge", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("temp_dcdc", "[.cmd][.new]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::EIGER) {
|
||||
REQUIRE_NOTHROW(proxy.Call("temp_dcdc", {}, -1, GET));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(proxy.Call("temp_dcdc", {}, 0, GET, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("temp_dcdc "));
|
||||
REQUIRE(std::stoi(s) != -1);
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("temp_dcdc", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("temp_sodl", "[.cmd][.new]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::EIGER) {
|
||||
REQUIRE_NOTHROW(proxy.Call("temp_sodl", {}, -1, GET));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(proxy.Call("temp_sodl", {}, 0, GET, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("temp_sodl "));
|
||||
REQUIRE(std::stoi(s) != -1);
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("temp_sodl", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("temp_sodr", "[.cmd][.new]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::EIGER) {
|
||||
REQUIRE_NOTHROW(proxy.Call("temp_sodr", {}, -1, GET));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(proxy.Call("temp_sodr", {}, 0, GET, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("temp_sodr "));
|
||||
REQUIRE(std::stoi(s) != -1);
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("temp_sodr", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("temp_fpgafl", "[.cmd][.new]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::EIGER) {
|
||||
REQUIRE_NOTHROW(proxy.Call("temp_fpgafl", {}, -1, GET));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(proxy.Call("temp_fpgafl", {}, 0, GET, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("temp_fpgafl "));
|
||||
REQUIRE(std::stoi(s) != -1);
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("temp_fpgafl", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("temp_fpgafr", "[.cmd][.new]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::EIGER) {
|
||||
REQUIRE_NOTHROW(proxy.Call("temp_fpgafr", {}, -1, GET));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(proxy.Call("temp_fpgafr", {}, 0, GET, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("temp_fpgafr "));
|
||||
REQUIRE(std::stoi(s) != -1);
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("temp_fpgafr", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
/* dacs */
|
||||
|
||||
TEST_CASE("Setting and reading back EIGER dacs", "[.cmd][.dacs][.new]") {
|
||||
// vsvp, vtr, vrf, vrs, vsvn, vtgstv, vcmp_ll, vcmp_lr, vcal, vcmp_rl,
|
||||
// rxb_rb, rxb_lb, vcmp_rr, vcp, vcn, vis, vthreshold
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::EIGER) {
|
||||
SECTION("vsvp") { test_dac(defs::SVP, "vsvp", 5); }
|
||||
SECTION("vtr") { test_dac(defs::VRF, "vtr", 1200); }
|
||||
SECTION("vrf") { test_dac(defs::VRF, "vrf", 1500); }
|
||||
SECTION("vrs") { test_dac(defs::VRF, "vrs", 1510); }
|
||||
SECTION("vsvn") { test_dac(defs::SVN, "vsvn", 3800); }
|
||||
SECTION("vtgstv") { test_dac(defs::VTGSTV, "vtgstv", 2550); }
|
||||
SECTION("vcmp_ll") { test_dac(defs::VCMP_LL, "vcmp_ll", 1400); }
|
||||
SECTION("vcmp_lr") { test_dac(defs::VCMP_LR, "vcmp_lr", 1400); }
|
||||
SECTION("vcal") { test_dac(defs::CAL, "vcal", 1400); }
|
||||
SECTION("vcmp_rl") { test_dac(defs::VCMP_RL, "vcmp_rl", 1400); }
|
||||
SECTION("rxb_rb") { test_dac(defs::RXB_RB, "rxb_rb", 1400); }
|
||||
SECTION("rxb_lb") { test_dac(defs::RXB_LB, "rxb_lb", 1400); }
|
||||
SECTION("vcmp_rr") { test_dac(defs::VCMP_RR, "vcmp_rr", 1400); }
|
||||
SECTION("vcp") { test_dac(defs::VCP, "vcp", 1400); }
|
||||
SECTION("vcn") { test_dac(defs::VCN, "vcn", 1400); }
|
||||
SECTION("vis") { test_dac(defs::VIS, "vis", 1400); }
|
||||
SECTION("iodelay") { test_dac(defs::IO_DELAY, "iodelay", 1400); }
|
||||
SECTION("vthreshold") {
|
||||
// Read out individual vcmp to be able to reset after
|
||||
// the test is done
|
||||
auto vcmp_ll = det.getDAC(defs::VCMP_LL, false);
|
||||
auto vcmp_lr = det.getDAC(defs::VCMP_LR, false);
|
||||
auto vcmp_rl = det.getDAC(defs::VCMP_RL, false);
|
||||
auto vcmp_rr = det.getDAC(defs::VCMP_RR, false);
|
||||
auto vcp = det.getDAC(defs::VCP, false);
|
||||
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("vthreshold", {"1234"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "vthreshold 1234\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("vthreshold", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "vthreshold 1234\n");
|
||||
}
|
||||
|
||||
// Reset dacs after test
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setDAC(defs::VCMP_LL, vcmp_ll[i], false, {i});
|
||||
det.setDAC(defs::VCMP_LR, vcmp_ll[i], false, {i});
|
||||
det.setDAC(defs::VCMP_RL, vcmp_ll[i], false, {i});
|
||||
det.setDAC(defs::VCMP_RR, vcmp_ll[i], false, {i});
|
||||
det.setDAC(defs::VCP, vcp[i], false, {i});
|
||||
}
|
||||
}
|
||||
// gotthard
|
||||
REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcascn_pb", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcascp_pb", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vout_cm", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcasc_out", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vin_cm", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("ib_test_c", {}, -1, GET));
|
||||
// mythen3
|
||||
REQUIRE_THROWS(proxy.Call("vpreamp", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vshaper", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vshaperneg", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vipre", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("viinsh", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vdcsh", {}, -1, GET));
|
||||
// REQUIRE_THROWS(proxy.Call("vth1", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vth2", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vth3", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vpl", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vph", {}, -1, GET));
|
||||
// REQUIRE_THROWS(proxy.Call("vtrim", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcassh", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcas", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vicin", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vipre_out", {}, -1, GET));
|
||||
// gotthard2
|
||||
REQUIRE_THROWS(proxy.Call("vref_h_adc", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vb_comp_fe", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vb_comp_adc", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcom_cds", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_rstore", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vb_opa_1st", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_comp_fe", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcom_adc1", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_l_adc", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_cds", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vb_cs", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vb_opa_fd", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcom_adc2", {}, -1, GET));
|
||||
// jungfrau
|
||||
REQUIRE_THROWS(proxy.Call("vb_comp", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vdd_prot", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vin_com", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_prech", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vb_pixbuf", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vb_ds", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TEST_CASE("Eiger transmission delay", "[.cmd]") {
|
||||
Detector det;
|
||||
@ -280,110 +519,7 @@ TEST_CASE("quad", "[.cmd]") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Setting and reading back EIGER dacs", "[.cmd][.dacs]") {
|
||||
// vsvp, vtr, vrf, vrs, vsvn, vtgstv, vcmp_ll, vcmp_lr, vcal, vcmp_rl,
|
||||
// rxb_rb, rxb_lb, vcmp_rr, vcp, vcn, vis, vthreshold
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::EIGER) {
|
||||
SECTION("vsvp") { test_dac(defs::SVP, "vsvp", 5); }
|
||||
SECTION("vtr") { test_dac(defs::VRF, "vtr", 1200); }
|
||||
SECTION("vrf") { test_dac(defs::VRF, "vrf", 1500); }
|
||||
SECTION("vrs") { test_dac(defs::VRF, "vrs", 1510); }
|
||||
SECTION("vsvn") { test_dac(defs::SVN, "vsvn", 3800); }
|
||||
SECTION("vtgstv") { test_dac(defs::VTGSTV, "vtgstv", 2550); }
|
||||
SECTION("vcmp_ll") { test_dac(defs::VCMP_LL, "vcmp_ll", 1400); }
|
||||
SECTION("vcmp_lr") { test_dac(defs::VCMP_LR, "vcmp_lr", 1400); }
|
||||
SECTION("vcal") { test_dac(defs::CAL, "vcal", 1400); }
|
||||
SECTION("vcmp_rl") { test_dac(defs::VCMP_RL, "vcmp_rl", 1400); }
|
||||
SECTION("rxb_rb") { test_dac(defs::RXB_RB, "rxb_rb", 1400); }
|
||||
SECTION("rxb_lb") { test_dac(defs::RXB_LB, "rxb_lb", 1400); }
|
||||
SECTION("vcmp_rr") { test_dac(defs::VCMP_RR, "vcmp_rr", 1400); }
|
||||
SECTION("vcp") { test_dac(defs::VCP, "vcp", 1400); }
|
||||
SECTION("vcn") { test_dac(defs::VCN, "vcn", 1400); }
|
||||
SECTION("vis") { test_dac(defs::VIS, "vis", 1400); }
|
||||
SECTION("iodelay") { test_dac(defs::IO_DELAY, "iodelay", 1400); }
|
||||
SECTION("vthreshold") {
|
||||
// Read out individual vcmp to be able to reset after
|
||||
// the test is done
|
||||
auto vcmp_ll = det.getDAC(defs::VCMP_LL, false);
|
||||
auto vcmp_lr = det.getDAC(defs::VCMP_LR, false);
|
||||
auto vcmp_rl = det.getDAC(defs::VCMP_RL, false);
|
||||
auto vcmp_rr = det.getDAC(defs::VCMP_RR, false);
|
||||
auto vcp = det.getDAC(defs::VCP, false);
|
||||
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("vthreshold", {"1234"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "vthreshold 1234\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("vthreshold", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "vthreshold 1234\n");
|
||||
}
|
||||
|
||||
// Reset dacs after test
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setDAC(defs::VCMP_LL, vcmp_ll[i], false, {i});
|
||||
det.setDAC(defs::VCMP_LR, vcmp_ll[i], false, {i});
|
||||
det.setDAC(defs::VCMP_RL, vcmp_ll[i], false, {i});
|
||||
det.setDAC(defs::VCMP_RR, vcmp_ll[i], false, {i});
|
||||
det.setDAC(defs::VCP, vcp[i], false, {i});
|
||||
}
|
||||
}
|
||||
// gotthard
|
||||
REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcascn_pb", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcascp_pb", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vout_cm", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcasc_out", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vin_cm", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("ib_test_c", {}, -1, GET));
|
||||
// mythen3
|
||||
REQUIRE_THROWS(proxy.Call("vpreamp", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vshaper", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vshaperneg", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vipre", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("viinsh", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vdcsh", {}, -1, GET));
|
||||
// REQUIRE_THROWS(proxy.Call("vth1", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vth2", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vth3", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vpl", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vph", {}, -1, GET));
|
||||
// REQUIRE_THROWS(proxy.Call("vtrim", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcassh", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcas", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vicin", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vipre_out", {}, -1, GET));
|
||||
// gotthard2
|
||||
REQUIRE_THROWS(proxy.Call("vref_h_adc", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vb_comp_fe", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vb_comp_adc", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcom_cds", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_rstore", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vb_opa_1st", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_comp_fe", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcom_adc1", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_l_adc", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_cds", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vb_cs", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vb_opa_fd", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vcom_adc2", {}, -1, GET));
|
||||
// jungfrau
|
||||
REQUIRE_THROWS(proxy.Call("vb_comp", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vdd_prot", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vin_com", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_prech", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vb_pixbuf", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vb_ds", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
// TEST_CASE("trigger", "[.cmd]") {
|
||||
// Detector det;
|
||||
|
@ -16,12 +16,46 @@ void test_dac(defs::dacIndex index, const std::string &dacname, int dacvalue) {
|
||||
std::ostringstream oss_set, oss_get;
|
||||
auto dacstr = std::to_string(dacvalue);
|
||||
auto previous = det.getDAC(index, false);
|
||||
proxy.Call(dacname, {dacstr}, -1, PUT, oss_set);
|
||||
REQUIRE(oss_set.str() == dacname + " " + dacstr + "\n");
|
||||
proxy.Call(dacname, {}, -1, GET, oss_get);
|
||||
REQUIRE(oss_get.str() == dacname + " " + dacstr + "\n");
|
||||
// chip test board
|
||||
if (dacname == "dac") {
|
||||
auto dacIndexstr = std::to_string(static_cast<int>(index));
|
||||
proxy.Call(dacname, {dacIndexstr, dacstr}, -1, PUT, oss_set);
|
||||
REQUIRE(oss_set.str() == dacname + " " + dacIndexstr + " " + dacstr + "\n");
|
||||
proxy.Call(dacname, {dacIndexstr}, -1, GET, oss_get);
|
||||
REQUIRE(oss_get.str() == dacname + " " + dacIndexstr + " " + dacstr + "\n");
|
||||
}
|
||||
// other detectors
|
||||
else {
|
||||
proxy.Call(dacname, {dacstr}, -1, PUT, oss_set);
|
||||
REQUIRE(oss_set.str() == dacname + " " + dacstr + "\n");
|
||||
proxy.Call(dacname, {}, -1, GET, oss_get);
|
||||
REQUIRE(oss_get.str() == dacname + " " + dacstr + "\n");
|
||||
}
|
||||
// Reset all dacs to previous value
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setDAC(index, previous[i], false, {i});
|
||||
}
|
||||
}
|
||||
|
||||
void test_onchip_dac(defs::dacIndex index, const std::string &dacname, int dacvalue) {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
REQUIRE_THROWS(proxy.Call(dacname, {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call(dacname, {"10", "0x0"}, -1, PUT)); // chip index (-1 to 9)
|
||||
REQUIRE_THROWS(proxy.Call(dacname, {"-1", "0x400"}, -1, PUT)); // max val is 0x3ff
|
||||
|
||||
int chipIndex = -1; // for now, it is -1 only
|
||||
auto prev_val = det.getOnChipDAC(index, chipIndex);
|
||||
auto dacValueStr = sls::ToStringHex(dacvalue);
|
||||
auto chipIndexStr = std::to_string(chipIndex);
|
||||
std::ostringstream oss_set, oss_get;
|
||||
proxy.Call(dacname, {chipIndexStr, dacValueStr}, -1, PUT, oss_set);
|
||||
REQUIRE(oss_set.str() == dacname + " " + chipIndexStr + " " + dacValueStr + "\n");
|
||||
proxy.Call(dacname, {chipIndexStr}, -1, GET, oss_get);
|
||||
REQUIRE(oss_get.str() == dacname + " " + chipIndexStr + " " + dacValueStr + "\n");
|
||||
|
||||
// Reset all dacs to previous value
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setOnChipDAC(index, chipIndex, prev_val[i], {i});
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user