mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-03 19:30:04 +02:00
Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer
This commit is contained in:
commit
664de6b204
2
.github/workflows/cmake.yml
vendored
2
.github/workflows/cmake.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||||
with:
|
with:
|
||||||
packages: libzmq3-dev libhdf5-dev qtbase5-dev qt5-qmake libqt5svg5-dev
|
packages: libhdf5-dev qtbase5-dev qt5-qmake libqt5svg5-dev
|
||||||
version: 1.0
|
version: 1.0
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
|
2
cmk.sh
2
cmk.sh
@ -26,7 +26,7 @@ CMAKE_PRE=""
|
|||||||
CMAKE_POST=""
|
CMAKE_POST=""
|
||||||
|
|
||||||
usage() { echo -e "
|
usage() { echo -e "
|
||||||
Usage: $0 [-b] [-c] [-d <HDF5 directory>] [e] [g] [-h] [i] [-j <Number of threads>] [-k <CMake command>] [-l <Install directory>] [m] [n] [-p] [r] [s] [t] [u] [z]
|
Usage: $0 [-b] [-c] [-d <HDF5 directory>] [-e] [-g] [-h] [-i] [-j <Number of threads>] [-k <CMake command>] [-l <Install directory>] [-m] [-n] [-p] [-r] [-s] [-t] [-u] [-z]
|
||||||
-[no option]: only make
|
-[no option]: only make
|
||||||
-b: Builds/Rebuilds CMake files normal mode
|
-b: Builds/Rebuilds CMake files normal mode
|
||||||
-c: Clean
|
-c: Clean
|
||||||
|
@ -3,6 +3,5 @@ python:
|
|||||||
- 3.9
|
- 3.9
|
||||||
- 3.10
|
- 3.10
|
||||||
- 3.11
|
- 3.11
|
||||||
|
- 3.12
|
||||||
|
|
||||||
numpy:
|
|
||||||
- 1.17
|
|
||||||
|
@ -18,7 +18,6 @@ requirements:
|
|||||||
- {{compiler('cxx')}}
|
- {{compiler('cxx')}}
|
||||||
- cmake
|
- cmake
|
||||||
- qt 5.*
|
- qt 5.*
|
||||||
- zeromq
|
|
||||||
- xorg-libx11
|
- xorg-libx11
|
||||||
- xorg-libice
|
- xorg-libice
|
||||||
- xorg-libxext
|
- xorg-libxext
|
||||||
@ -37,7 +36,6 @@ requirements:
|
|||||||
host:
|
host:
|
||||||
- libstdcxx-ng
|
- libstdcxx-ng
|
||||||
- libgcc-ng
|
- libgcc-ng
|
||||||
- zeromq
|
|
||||||
- xorg-libx11
|
- xorg-libx11
|
||||||
- xorg-libice
|
- xorg-libice
|
||||||
- xorg-libxext
|
- xorg-libxext
|
||||||
@ -48,7 +46,6 @@ requirements:
|
|||||||
- expat
|
- expat
|
||||||
|
|
||||||
run:
|
run:
|
||||||
- zeromq
|
|
||||||
- libstdcxx-ng
|
- libstdcxx-ng
|
||||||
- libgcc-ng
|
- libgcc-ng
|
||||||
|
|
||||||
@ -63,15 +60,11 @@ outputs:
|
|||||||
- {{compiler('cxx')}}
|
- {{compiler('cxx')}}
|
||||||
- libstdcxx-ng
|
- libstdcxx-ng
|
||||||
- libgcc-ng
|
- libgcc-ng
|
||||||
- zeromq
|
|
||||||
|
|
||||||
host:
|
|
||||||
- zeromq
|
|
||||||
|
|
||||||
run:
|
run:
|
||||||
- libstdcxx-ng
|
- libstdcxx-ng
|
||||||
- libgcc-ng
|
- libgcc-ng
|
||||||
- zeromq
|
|
||||||
|
|
||||||
- name: slsdet
|
- name: slsdet
|
||||||
|
|
||||||
@ -84,10 +77,12 @@ outputs:
|
|||||||
- {{compiler('cxx')}}
|
- {{compiler('cxx')}}
|
||||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||||
- setuptools
|
- setuptools
|
||||||
|
- pybind11=2.11
|
||||||
|
|
||||||
host:
|
host:
|
||||||
- python
|
- python
|
||||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||||
|
- pybind11=2.11
|
||||||
|
|
||||||
|
|
||||||
run:
|
run:
|
||||||
|
@ -19,7 +19,7 @@ A minimal CMakeLists.txt could look like this:
|
|||||||
.. code-block:: cmake
|
.. code-block:: cmake
|
||||||
|
|
||||||
project(myDetectorIntegration)
|
project(myDetectorIntegration)
|
||||||
cmake_minimum_required(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
add_subdirectory(slsDetectorPackage)
|
add_subdirectory(slsDetectorPackage)
|
||||||
|
|
||||||
#Add your executable
|
#Add your executable
|
||||||
@ -43,7 +43,7 @@ should be needed, otherwise specify cmake prefix path.
|
|||||||
|
|
||||||
.. code-block:: cmake
|
.. code-block:: cmake
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
project(myintegration)
|
project(myintegration)
|
||||||
|
|
||||||
find_package(slsDetectorPackage 5.0 REQUIRED)
|
find_package(slsDetectorPackage 5.0 REQUIRED)
|
||||||
|
@ -13,24 +13,36 @@ To use the basic building blocks, meaning sls_detector_get/put and
|
|||||||
the shared libraries these are needed:
|
the shared libraries these are needed:
|
||||||
|
|
||||||
* Linux, preferably recent kernel (currently no cross platform support)
|
* Linux, preferably recent kernel (currently no cross platform support)
|
||||||
* CMake > 3.12
|
* CMake >= 3.14
|
||||||
* C++11 compatible compiler. (We test with gcc and clang)
|
* C++11 compatible compiler. (We test with gcc and clang)
|
||||||
* ZeroMQ version 4
|
|
||||||
|
|
||||||
-----------------------
|
|
||||||
GUI
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
* Qt 5.9
|
|
||||||
* Qwt 6.1.5 (packaged in libs/)
|
|
||||||
|
|
||||||
-----------------------
|
-----------------------
|
||||||
Python bindings
|
Python bindings
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
* Python > 3.6
|
* Python > 3.6
|
||||||
* pybind11 (packaged in libs/)
|
* pybind11 2.11.0 (packaged in libs)
|
||||||
|
|
||||||
|
.. note ::
|
||||||
|
|
||||||
|
Refer :ref:`pybind11 notes. <pybind for different slsDetectorPackage versions>`
|
||||||
|
|
||||||
|
-----------------------
|
||||||
|
ZeroMQ
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
* Zeromq 4.3.4 (packaged in libs)
|
||||||
|
|
||||||
|
.. note ::
|
||||||
|
|
||||||
|
Refer :ref:`zeromq notes. <zeromq for different slsDetectorPackage versions>`
|
||||||
|
|
||||||
|
-----------------------
|
||||||
|
GUI
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
* Qt 5.9
|
||||||
|
* Qwt 6.1.5 (packaged in libs)
|
||||||
|
|
||||||
-----------------------
|
-----------------------
|
||||||
Moench executables
|
Moench executables
|
||||||
@ -55,3 +67,5 @@ Packaged in libs/
|
|||||||
* catch2 (unit testing)
|
* catch2 (unit testing)
|
||||||
* rapidjson (streaming from receiver)
|
* rapidjson (streaming from receiver)
|
||||||
* pybind11 (python bindings)
|
* pybind11 (python bindings)
|
||||||
|
* qwt (gui plotting)
|
||||||
|
* libzmq (streaming to/from receiver)
|
@ -1,16 +1,19 @@
|
|||||||
Detector
|
Detector
|
||||||
==============================================
|
==============================================
|
||||||
|
|
||||||
The sls::Detector is the new public API to control
|
The sls::Detector is the public API to control
|
||||||
detectors from C++. This API is also used internally
|
detectors from C++. This API is also used internally
|
||||||
for the Python bindings and the command line interface.
|
for the Python bindings and the command line interface.
|
||||||
If a receiver has been configured this is also controlled
|
If a receiver has been configured, this is also controlled
|
||||||
through this class.
|
through this class.
|
||||||
|
|
||||||
Most, if not all, functions are called in parallel
|
Most, if not all, functions are called in parallel
|
||||||
and the return value is a thin std::vector wrapper
|
and the return value is a thin std::vector wrapper
|
||||||
containing results from all modules. (Result<T>)
|
containing results from all modules. (:ref:`Result class<Result Class>`)
|
||||||
|
|
||||||
|
Here are some :ref:`examples <Cplusplus Api Examples>` on how to use the API.
|
||||||
|
|
||||||
|
.. _Cplusplus Api Examples:
|
||||||
.. doxygenclass:: sls::Detector
|
.. doxygenclass:: sls::Detector
|
||||||
:members:
|
:members:
|
||||||
:undoc-members:
|
:undoc-members:
|
@ -1,3 +1,4 @@
|
|||||||
|
.. _Cplusplus Api Examples:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -53,8 +54,8 @@ then set up the detector.
|
|||||||
|
|
||||||
jungfrauDetectorServer_virtual
|
jungfrauDetectorServer_virtual
|
||||||
|
|
||||||
This launches a virtual Jungfrau detector server. As default is uses port 1952 and 1953
|
This launches a virtual Jungfrau detector server. As default it uses port 1952 and 1953
|
||||||
for communication over TCP. Most commands go on 1952 and only stop and status on 1953.
|
for communication over TCP. Most commands go on 1952 and only a few such as stop and status on 1953.
|
||||||
|
|
||||||
**Run example to configure**
|
**Run example to configure**
|
||||||
|
|
||||||
@ -90,7 +91,10 @@ std::vector.
|
|||||||
sls::Result<int> res1{1, 1, 1};
|
sls::Result<int> res1{1, 1, 1};
|
||||||
std::cout << "res1: " << res1 << '\n';
|
std::cout << "res1: " << res1 << '\n';
|
||||||
res1.squash();
|
res1.squash();
|
||||||
|
# return -1 if different
|
||||||
res1.squash(-1);
|
res1.squash(-1);
|
||||||
|
# throw exception with custom message if different
|
||||||
|
res1.tsquash("Values are different);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ Program from console
|
|||||||
# removes old server from respawn, sets up new lnked server to respawn
|
# removes old server from respawn, sets up new lnked server to respawn
|
||||||
# programs fpga, reboots
|
# programs fpga, reboots
|
||||||
|
|
||||||
# v5.0.0 - 6.0.0 (copies server from tftp folder of the pc)
|
# older versions: v5.0.0 - 6.0.0 using tftp from tftp folder of pc
|
||||||
sls_detector_put update jungfrauDetectorServervxxx pcxxx xx.pof
|
sls_detector_put update jungfrauDetectorServervxxx pcxxx xx.pof
|
||||||
|
|
||||||
# v6.1.1 - present (copies server from the full path provided)
|
# v6.1.1 - present (copies server from the full path provided)
|
||||||
@ -190,7 +190,7 @@ Program from console
|
|||||||
# removes old server from respawn, sets up new lnked server to respawn
|
# removes old server from respawn, sets up new lnked server to respawn
|
||||||
# programs fpga, reboots
|
# programs fpga, reboots
|
||||||
|
|
||||||
# v5.0.0 - 6.0.0 (copies server from tftp folder of the pc)
|
# older versions: v5.0.0 - 6.0.0 using tftp from tftp folder of pc
|
||||||
sls_detector_put update mythen3DetectorServervxxx pcxxx xxx.rbf
|
sls_detector_put update mythen3DetectorServervxxx pcxxx xxx.rbf
|
||||||
|
|
||||||
# v6.1.1 - present (copies server from the full path provided)
|
# v6.1.1 - present (copies server from the full path provided)
|
||||||
@ -224,7 +224,7 @@ Program from console
|
|||||||
# removes old server from respawn, sets up new lnked server to respawn
|
# removes old server from respawn, sets up new lnked server to respawn
|
||||||
# programs fpga, reboots
|
# programs fpga, reboots
|
||||||
|
|
||||||
# v5.0.0 - 6.0.0 (copies server from tftp folder of the pc)
|
# older versions: v5.0.0 - 6.0.0 using tftp from tftp folder of pc
|
||||||
sls_detector_put update gotthard2DetectorServervxxx pcxxx xxx.rbf
|
sls_detector_put update gotthard2DetectorServervxxx pcxxx xxx.rbf
|
||||||
|
|
||||||
# v6.1.1 - present (copies server from the full path provided)
|
# v6.1.1 - present (copies server from the full path provided)
|
||||||
@ -275,7 +275,7 @@ Program from console
|
|||||||
# removes old server from respawn, sets up new lnked server to respawn
|
# removes old server from respawn, sets up new lnked server to respawn
|
||||||
# programs fpga, reboots
|
# programs fpga, reboots
|
||||||
|
|
||||||
# v5.0.0 - 6.0.0 (copies server from tftp folder of the pc)
|
# older versions: v5.0.0 - 6.0.0 using tftp from tftp folder of pc
|
||||||
sls_detector_put update moenchDetectorServervxxx pcxxx xx.pof
|
sls_detector_put update moenchDetectorServervxxx pcxxx xx.pof
|
||||||
|
|
||||||
# v6.1.1 - present (copies server from the full path provided)
|
# v6.1.1 - present (copies server from the full path provided)
|
||||||
@ -310,7 +310,7 @@ Program from console
|
|||||||
# removes old server from respawn, sets up new lnked server to respawn
|
# removes old server from respawn, sets up new lnked server to respawn
|
||||||
# programs fpga, reboots
|
# programs fpga, reboots
|
||||||
|
|
||||||
# v5.0.0 - 6.0.0 (copies server from tftp folder of the pc)
|
# older versions: v5.0.0 - 6.0.0 using tftp from tftp folder of pc
|
||||||
sls_detector_put update ctbDetectorServervxxx pcxxx xx.pof
|
sls_detector_put update ctbDetectorServervxxx pcxxx xx.pof
|
||||||
|
|
||||||
# v6.1.1 - present (copies server from the full path provided)
|
# v6.1.1 - present (copies server from the full path provided)
|
||||||
|
@ -8,8 +8,8 @@ Welcome to slsDetectorPackage's documentation!
|
|||||||
|
|
||||||
.. note ::
|
.. note ::
|
||||||
|
|
||||||
This is the documentation for the latest development version of slsDetectorPackage
|
This is the documentation for the latest development version of slsDetectorPackage.
|
||||||
For documentation on current and previous releases visit the official page: https://www.psi.ch/en/detectors/documentation
|
For further documentation, visit the official page: https://www.psi.ch/en/detectors/documentation
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 1
|
:maxdepth: 1
|
||||||
|
@ -57,7 +57,6 @@ We have three different packages available:
|
|||||||
Build from source
|
Build from source
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
|
||||||
1. Download Source Code from github
|
1. Download Source Code from github
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
@ -65,23 +64,9 @@ Build from source
|
|||||||
|
|
||||||
git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git --branch 6.1.1
|
git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git --branch 6.1.1
|
||||||
|
|
||||||
|
.. note ::
|
||||||
|
|
||||||
| **Pybind for Python**
|
For v6.x.x of slsDetectorPackage and older, refer :ref:`pybind11 notes on cloning. <pybind for different slsDetectorPackage versions>`
|
||||||
| v7.0.0+:
|
|
||||||
| pybind11 packaged into 'libs/pybind'. No longer a submodule. No need for "recursive" or "submodule update".
|
|
||||||
|
|
|
||||||
| Older versions:
|
|
||||||
| pybind11 is a submodule. Must be cloned using "recursive" and updated when switching between versions using the following commands.
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
# clone using recursive to get pybind11 submodule
|
|
||||||
git clone --recursive https://github.com/slsdetectorgroup/slsDetectorPackage.git
|
|
||||||
|
|
||||||
# update submodule when switching between releases
|
|
||||||
cd slsDetectorPackage
|
|
||||||
git submodule update --init
|
|
||||||
|
|
||||||
|
|
||||||
.. _build from source using cmake:
|
.. _build from source using cmake:
|
||||||
|
|
||||||
@ -118,20 +103,23 @@ Instead of the cmake command, one can use ccmake to get a list of options to con
|
|||||||
ccmake ..
|
ccmake ..
|
||||||
|
|
||||||
# choose the options
|
# choose the options
|
||||||
# first press [c] - configure
|
# first press [c] - configure (maybe multiple times till you see [g])
|
||||||
# then press [g] - generate
|
# then press [g] - generate
|
||||||
|
|
||||||
|
|
||||||
|
=============================== ===============================
|
||||||
=============================== ===========================================
|
|
||||||
Example cmake options Comment
|
Example cmake options Comment
|
||||||
=============================== ===========================================
|
=============================== ===============================
|
||||||
-DSLS_USE_PYTHON=ON Python
|
-DSLS_USE_PYTHON=ON Python
|
||||||
-DPython_FIND_VIRTUALENV=ONLY Python from only the conda environment
|
-DPython_FIND_VIRTUALENV=ONLY Python from the conda env
|
||||||
-DZeroMQ_HINT=/usr/lib64 Use system zmq instead
|
|
||||||
-DSLS_USE_GUI=ON GUI
|
-DSLS_USE_GUI=ON GUI
|
||||||
=============================== ===========================================
|
-DSLS_USE_HDF5=ON HDF5
|
||||||
|
-DSLS_USE_SIMULATOR=ON Simulator
|
||||||
|
=============================== ===============================
|
||||||
|
|
||||||
|
.. note ::
|
||||||
|
|
||||||
|
For v7.x.x of slsDetectorPackage and older, refer :ref:`zeromq notes for cmake option to hint library location. <zeromq for different slsDetectorPackage versions>`
|
||||||
|
|
||||||
|
|
||||||
Build using in-built cmk.sh script
|
Build using in-built cmk.sh script
|
||||||
@ -142,9 +130,9 @@ Build using in-built cmk.sh script
|
|||||||
|
|
||||||
The binaries are generated in slsDetectorPackage/build/bin directory.
|
The binaries are generated in slsDetectorPackage/build/bin directory.
|
||||||
|
|
||||||
Usage: ./cmk.sh [-b] [-c] [-d <HDF5 directory>] [e] [g] [-h] [i] [-j <Number of threads>]
|
Usage: $0 [-b] [-c] [-d <HDF5 directory>] [-e] [-g] [-h] [-i]
|
||||||
[-k <CMake command>] [-l <Install directory>] [m] [n] [-p] [-q <Zmq hint directory>]
|
[-j <Number of threads>] [-k <CMake command>] [-l <Install directory>]
|
||||||
[r] [s] [t] [u] [z]
|
[-m] [-n] [-p] [-r] [-s] [-t] [-u] [-z]
|
||||||
-[no option]: only make
|
-[no option]: only make
|
||||||
-b: Builds/Rebuilds CMake files normal mode
|
-b: Builds/Rebuilds CMake files normal mode
|
||||||
-c: Clean
|
-c: Clean
|
||||||
@ -159,7 +147,6 @@ Build using in-built cmk.sh script
|
|||||||
-m: Manuals
|
-m: Manuals
|
||||||
-n: Manuals without compiling doxygen (only rst)
|
-n: Manuals without compiling doxygen (only rst)
|
||||||
-p: Builds/Rebuilds Python API
|
-p: Builds/Rebuilds Python API
|
||||||
-q: Zmq hint directory
|
|
||||||
-r: Build/Rebuilds only receiver
|
-r: Build/Rebuilds only receiver
|
||||||
-s: Simulator
|
-s: Simulator
|
||||||
-t: Build/Rebuilds only text client
|
-t: Build/Rebuilds only text client
|
||||||
@ -176,9 +163,13 @@ Build using in-built cmk.sh script
|
|||||||
# new build, python and compile in parallel:
|
# new build, python and compile in parallel:
|
||||||
./cmk.sh -cbpj5
|
./cmk.sh -cbpj5
|
||||||
|
|
||||||
#To use the system zmq (/usr/lib64) instead
|
#For rebuilding only certain sections
|
||||||
./cmk.sh -cbj5 -q /usr/lib64
|
./cmk.sh -tg #only text client and gui
|
||||||
|
./cmk.sh -r #only receiver
|
||||||
|
|
||||||
|
.. note ::
|
||||||
|
|
||||||
|
For v7.x.x of slsDetectorPackage and older, refer :ref:`zeromq notes for cmk script option to hint library location. <zeromq for different slsDetectorPackage versions>`
|
||||||
|
|
||||||
|
|
||||||
Build on old distributions
|
Build on old distributions
|
||||||
@ -191,7 +182,7 @@ using this compiler
|
|||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
#Create an environment with the dependencies
|
#Create an environment with the dependencies
|
||||||
conda create -n myenv gxx_linux-64 cmake zmq
|
conda create -n myenv gxx_linux-64 cmake
|
||||||
conda activate myenv
|
conda activate myenv
|
||||||
|
|
||||||
# outside slsDetecorPackage folder
|
# outside slsDetecorPackage folder
|
||||||
@ -200,6 +191,11 @@ using this compiler
|
|||||||
make -j12
|
make -j12
|
||||||
|
|
||||||
|
|
||||||
|
.. note ::
|
||||||
|
|
||||||
|
For v7.x.x of slsDetectorPackage and older, refer :ref:`zeromq notes for dependencies for conda. <zeromq for different slsDetectorPackage versions>`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Build slsDetectorGui (Qt5)
|
Build slsDetectorGui (Qt5)
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -228,9 +224,9 @@ Build slsDetectorGui (Qt5)
|
|||||||
|
|
||||||
# create environment to compile
|
# create environment to compile
|
||||||
# on rhel7
|
# on rhel7
|
||||||
conda create -n slsgui zeromq gxx_linux-64 gxx_linux-64 mesa-libgl-devel-cos6-x86_64 qt
|
conda create -n slsgui gxx_linux-64 gxx_linux-64 mesa-libgl-devel-cos6-x86_64 qt
|
||||||
# on fedora or newer systems
|
# on fedora or newer systems
|
||||||
conda create -n slsgui zeromq qt
|
conda create -n slsgui qt
|
||||||
|
|
||||||
# when using conda compilers, would also need libgl, but no need for it on fedora unless maybe using it with ROOT
|
# when using conda compilers, would also need libgl, but no need for it on fedora unless maybe using it with ROOT
|
||||||
|
|
||||||
@ -246,6 +242,9 @@ Build slsDetectorGui (Qt5)
|
|||||||
cd slsDetectorPackage
|
cd slsDetectorPackage
|
||||||
./cmk.sh -cbgj9
|
./cmk.sh -cbgj9
|
||||||
|
|
||||||
|
.. note ::
|
||||||
|
|
||||||
|
For v7.x.x of slsDetectorPackage and older, refer :ref:`zeromq notes for dependencies for conda. <zeromq for different slsDetectorPackage versions>`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -258,7 +257,7 @@ is to use conda
|
|||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
conda create -n myenv python sphinx_rtd_theme breathe
|
conda create -n myenv python=3.12 sphinx sphinx_rtd_theme breathe doxygen numpy
|
||||||
|
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
@ -270,3 +269,51 @@ is to use conda
|
|||||||
|
|
||||||
make docs # generate API docs and build Sphinx RST
|
make docs # generate API docs and build Sphinx RST
|
||||||
make rst # rst only, saves time in case the API did not change
|
make rst # rst only, saves time in case the API did not change
|
||||||
|
|
||||||
|
|
||||||
|
Pybind and Zeromq
|
||||||
|
^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
.. _pybind for different slsDetectorPackage versions:
|
||||||
|
|
||||||
|
|
||||||
|
| **Pybind for Python**
|
||||||
|
| v8.0.0+:
|
||||||
|
| pybind11 (v2.11.0) is built
|
||||||
|
| * by default from tar file in repo (libs/pybind/v2.11.0.tar.gz)
|
||||||
|
| * or use advanced option SLS_FETCH_PYBIND11_FROM_GITHUB [`link <https://github.com/pybind/pybind11>`__].
|
||||||
|
|
|
||||||
|
| v7.x.x:
|
||||||
|
| pybind11 packaged into 'libs/pybind'. No longer a submodule. No need for "recursive" or "submodule update".
|
||||||
|
|
|
||||||
|
| Older versions:
|
||||||
|
| pybind11 is a submodule. Must be cloned using "recursive" and updated when switching between versions using the following commands.
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
# Note: Only for v6.x.x versions and older
|
||||||
|
|
||||||
|
# clone using recursive to get pybind11 submodule
|
||||||
|
git clone --recursive https://github.com/slsdetectorgroup/slsDetectorPackage.git
|
||||||
|
|
||||||
|
# update submodule when switching between releases
|
||||||
|
cd slsDetectorPackage
|
||||||
|
git submodule update --init
|
||||||
|
|
||||||
|
|
||||||
|
.. _zeromq for different slsDetectorPackage versions:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| **Zeromq**
|
||||||
|
| v8.0.0+:
|
||||||
|
| zeromq (v4.3.4) is built
|
||||||
|
| * by default from tar file in repo (libs/libzmq/libzmq-4.3.4.tar.gz)
|
||||||
|
| * or use advanced option SLS_FETCH_ZMQ_FROM_GITHUB [`link <https://github.com/zeromq/libzmq.git>`__].
|
||||||
|
|
|
||||||
|
| v7.x.x and older:
|
||||||
|
| zeromq must be installed and one can hint its location using
|
||||||
|
| * cmake option:'-DZeroMQ_HINT=/usr/lib64' or
|
||||||
|
| * option '-q' in cmk.sh script: : ./cmk.sh -cbj5 -q /usr/lib64
|
||||||
|
| * 'zeromq' dependency added when installing using conda
|
||||||
|
|
||||||
|
@ -109,12 +109,14 @@ For Multiple Modules
|
|||||||
# connects to mulitple modules
|
# connects to mulitple modules
|
||||||
hostname bchipxxx+bchipyyy+
|
hostname bchipxxx+bchipyyy+
|
||||||
|
|
||||||
# connects to receivers at ports 2012 and 2014
|
# tcp port increases for each module (multi detector command)
|
||||||
rx_hostname mpc1922:2012+mpc1922:2013+
|
rx_tcpport 2012
|
||||||
|
|
||||||
# sets differernt destination udp ports
|
# connects to receivers at ports 2012 and 2014
|
||||||
0:udp_dstport 50012
|
rx_hostname mpc1922
|
||||||
1:udp_dstport 50014
|
|
||||||
|
# increasing udp ports (multi detector command)
|
||||||
|
udp_dstport 50012
|
||||||
|
|
||||||
# source udp ips must be same subnet at destintaion udp ips
|
# source udp ips must be same subnet at destintaion udp ips
|
||||||
0:udp_srcip 192.168.1.112
|
0:udp_srcip 192.168.1.112
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
.. _Result Class:
|
||||||
|
|
||||||
Result
|
Result
|
||||||
==============================================
|
==============================================
|
||||||
|
|
||||||
|
@ -53,7 +53,12 @@ Client Commands
|
|||||||
# multi modules with custom ports
|
# multi modules with custom ports
|
||||||
rx_hostname xxx:1955+xxx:1956+
|
rx_hostname xxx:1955+xxx:1956+
|
||||||
|
|
||||||
# multi modules with custom ports on same rxr pc
|
|
||||||
|
# multi modules using increasing tcp ports when using multi detector command
|
||||||
|
rx_tcpport 1955
|
||||||
|
rx_hostname xxx
|
||||||
|
|
||||||
|
# or specify multi modules with custom ports on same rxr pc
|
||||||
0:rx_tcpport 1954
|
0:rx_tcpport 1954
|
||||||
1:rx_tcpport 1955
|
1:rx_tcpport 1955
|
||||||
2:rx_tcpport 1956
|
2:rx_tcpport 1956
|
||||||
|
@ -92,6 +92,9 @@ Common
|
|||||||
sls_detector_put rx_arping 1
|
sls_detector_put rx_arping 1
|
||||||
|
|
||||||
|
|
||||||
|
#. Only the slaves get no data
|
||||||
|
* Check trigger cabling and trigger configuration
|
||||||
|
* When you cannot stop Jungfrau slaves in sync mode, refer to :ref:`Cannot stop slaves<Jungfrau Troubleshooting Sync Slaves Cannot Stop>`.
|
||||||
|
|
||||||
.. _Receiver PC Tuning:
|
.. _Receiver PC Tuning:
|
||||||
|
|
||||||
@ -421,3 +424,20 @@ Cannot get multi module data
|
|||||||
* Comment out this line in the config file: powerchip 1
|
* Comment out this line in the config file: powerchip 1
|
||||||
* Powering on the chip increases the power consumption by a considerable amount. If commenting out this line aids in getting data (strange data due to powered off chip), then it could be the power supply current limit. Fix it (possibly to 8A current limit) and uncomment the powerchip line back in config file.
|
* Powering on the chip increases the power consumption by a considerable amount. If commenting out this line aids in getting data (strange data due to powered off chip), then it could be the power supply current limit. Fix it (possibly to 8A current limit) and uncomment the powerchip line back in config file.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.. _Jungfrau Troubleshooting Sync Slaves Cannot Stop:
|
||||||
|
|
||||||
|
Cannot stop slaves in sync mode
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
#. If cabling is accessible, ensure termination board and flatband cable between the masters and the slaves are connnected properly. Then try to stop.
|
||||||
|
#. If cabling is inaccessible, unsync first so that the slaves can get the stop directly from the client using the command. Then, don't use sync mode until the cabling is fixed.
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
# unsync, slaves command will fail as it is still in waiting state
|
||||||
|
sls_detector_put sync 0
|
||||||
|
|
||||||
|
# stop should now be successful as master does not determine the stop anymore
|
||||||
|
sls_detector_put stop
|
||||||
|
@ -86,7 +86,8 @@ For a Single Module (With Options)
|
|||||||
udp_dstport 50012
|
udp_dstport 50012
|
||||||
|
|
||||||
# source udp ips must be same subnet at destintaion udp ips
|
# source udp ips must be same subnet at destintaion udp ips
|
||||||
udp_srcip 192.168.1.112
|
# takes the same ip as hostname
|
||||||
|
udp_srcip auto
|
||||||
|
|
||||||
# destination udp ip picked up from rx_hostname (if auto)
|
# destination udp ip picked up from rx_hostname (if auto)
|
||||||
udp_dstip auto
|
udp_dstip auto
|
||||||
@ -101,12 +102,14 @@ For Multiple Modules
|
|||||||
virtual 2 1912
|
virtual 2 1912
|
||||||
# or hostname localhost:1912+localhost:1914+
|
# or hostname localhost:1912+localhost:1914+
|
||||||
|
|
||||||
# connects to receivers at ports 2012 and 2014
|
# increasing receiver tcp ports (multi detector command)
|
||||||
rx_hostname mpc1922:2012+mpc1922:2013+
|
rx_tcpport 2012
|
||||||
|
|
||||||
# sets differernt destination udp ports
|
# connects to reciever at port 2012 and 2013
|
||||||
0:udp_dstport 50012
|
rx_hostname mpc1922
|
||||||
1:udp_dstport 50014
|
|
||||||
|
# sets increasing destination udp ports
|
||||||
|
udp_dstport 50012
|
||||||
|
|
||||||
# source udp ips must be same subnet at destintaion udp ips
|
# source udp ips must be same subnet at destintaion udp ips
|
||||||
0:udp_srcip 192.168.1.112
|
0:udp_srcip 192.168.1.112
|
||||||
|
@ -4,14 +4,26 @@ detsize 1024 512
|
|||||||
# detector hostname for controls
|
# detector hostname for controls
|
||||||
hostname beb059+beb058+
|
hostname beb059+beb058+
|
||||||
|
|
||||||
# 1Gb receiver pc hostname with tcp port to configure receiver
|
# increasing receiver tcp port (multi detector command)
|
||||||
rx_hostname x12sa-vcons:1991+x12sa-vcons:1992
|
rx_tcpport 1991
|
||||||
|
|
||||||
|
# 1Gb receiver pc hostname to configure receiver
|
||||||
|
rx_hostname x12sa-vcons
|
||||||
|
|
||||||
|
# or 1Gb receiver pc hostname with tcp port to configure receiver
|
||||||
|
#rx_hostname x12sa-vcons:1991+x12sa-vcons:1992
|
||||||
|
|
||||||
|
# increasing udp destination ports for all half modules
|
||||||
|
udp_dstport 50011
|
||||||
|
|
||||||
# udp port first quadrant, first halfmodule
|
# udp port first quadrant, first halfmodule
|
||||||
0:udp_dstport 50011
|
#0:udp_dstport 50011
|
||||||
|
|
||||||
# udp port second quadrant, first halfmodule
|
# udp port second quadrant, first halfmodule
|
||||||
0:udp_dstport2 50012
|
#0:udp_dstport2 50012
|
||||||
|
# udp port first quadrant, second halfmodule
|
||||||
|
#1:udp_dstport 50013
|
||||||
|
# udp port second quadrant, second halfmodule
|
||||||
|
#1:udp_dstport2 50014
|
||||||
|
|
||||||
# udp IP of the receiver over 10Gb
|
# udp IP of the receiver over 10Gb
|
||||||
0:udp_dstip 10.0.30.210
|
0:udp_dstip 10.0.30.210
|
||||||
@ -19,12 +31,6 @@ rx_hostname x12sa-vcons:1991+x12sa-vcons:1992
|
|||||||
# first half module 10 Gb IP (same subnet as 0:udp_dstip)
|
# first half module 10 Gb IP (same subnet as 0:udp_dstip)
|
||||||
0:udp_srcip 10.0.30.100
|
0:udp_srcip 10.0.30.100
|
||||||
|
|
||||||
# udp port first quadrant, second halfmodule
|
|
||||||
1:udp_dstport 50013
|
|
||||||
|
|
||||||
# udp port second quadrant, second halfmodule
|
|
||||||
1:udp_dstport2 50014
|
|
||||||
|
|
||||||
# udp IP of the receiver over 10Gb,
|
# udp IP of the receiver over 10Gb,
|
||||||
1:udp_dstip 10.0.40.210
|
1:udp_dstip 10.0.40.210
|
||||||
|
|
||||||
|
@ -4,18 +4,23 @@ detsize 1024 512
|
|||||||
# detector hostname for controls
|
# detector hostname for controls
|
||||||
hostname beb059+beb058+
|
hostname beb059+beb058+
|
||||||
|
|
||||||
# 1Gb receiver pc hostname with tcp port to configure receiver
|
# increasing receiver tcp port (multi detector command)
|
||||||
rx_hostname x12sa-vcons:1991+x12sa-vcons:1992
|
rx_tcpport 1991
|
||||||
|
|
||||||
|
# 1Gb receiver pc hostname to configure receiver
|
||||||
|
rx_hostname x12sa-vcons
|
||||||
|
|
||||||
|
# increasing udp destination ports for all half modules
|
||||||
|
udp_dstport 50011
|
||||||
|
|
||||||
# udp port first quadrant, first halfmodule
|
# udp port first quadrant, first halfmodule
|
||||||
0:udp_dstport 50011
|
#0:udp_dstport 50011
|
||||||
#udp port second quadrant, first halfmodule
|
#udp port second quadrant, first halfmodule
|
||||||
0:udp_dstport2 50012
|
#0:udp_dstport2 50012
|
||||||
|
|
||||||
# udp port first quadrant, second halfmodule
|
# udp port first quadrant, second halfmodule
|
||||||
1:udp_dstport 50013
|
#1:udp_dstport 50013
|
||||||
# udp port second quadrant, second halfmodule
|
# udp port second quadrant, second halfmodule
|
||||||
1:udp_dstport2 50014
|
#1:udp_dstport2 50014
|
||||||
|
|
||||||
# output directory
|
# output directory
|
||||||
fpath /sls/X12SA/data/x12saop/Data10/Eiger0.5M
|
fpath /sls/X12SA/data/x12saop/Data10/Eiger0.5M
|
||||||
|
@ -4,14 +4,18 @@ detsize 1024 1024
|
|||||||
# detector hostname
|
# detector hostname
|
||||||
hostname bchip048+bchip052+
|
hostname bchip048+bchip052+
|
||||||
|
|
||||||
# 1Gb receiver pc hostname (default tcpport: 1954)
|
# increasing receiver ports 1954 and 1955 (multi detector command)
|
||||||
rx_hostname pcmoench01:1954+pcmoench01:1955+
|
rx_tcpport 1954
|
||||||
|
|
||||||
|
# 1Gb receiver pc hostname
|
||||||
|
rx_hostname pcmoench01
|
||||||
|
|
||||||
|
|
||||||
|
# increasing udp ports 50004 and 50005 (multi detector command)
|
||||||
|
udp_dstport 50004
|
||||||
|
# or custom udp destination port (receiver) for 1st module
|
||||||
|
#0:udp_dstport 50014
|
||||||
|
|
||||||
# udp configurations for 1st module
|
|
||||||
# udp destination port (receiver)
|
|
||||||
0:udp_dstport 50004
|
|
||||||
|
|
||||||
# udp destination ip (receiver)
|
# udp destination ip (receiver)
|
||||||
0:udp_dstip 10.1.1.100
|
0:udp_dstip 10.1.1.100
|
||||||
@ -19,17 +23,11 @@ rx_hostname pcmoench01:1954+pcmoench01:1955+
|
|||||||
# udp source ip (same subnet as 0:udp_dstip)
|
# udp source ip (same subnet as 0:udp_dstip)
|
||||||
0:udp_srcip 10.1.1.10
|
0:udp_srcip 10.1.1.10
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# udp configurations for 2nd module
|
|
||||||
# udp destination port (receiver)
|
|
||||||
1:udp_dstport 50005
|
|
||||||
|
|
||||||
# udp destination ip (receiver)
|
# udp destination ip (receiver)
|
||||||
1:udp_dstip 10.1.1.100
|
1:udp_dstip 10.1.2.100
|
||||||
|
|
||||||
# udp source ip (same subnet as 1:udp_dstip)
|
# udp source ip (same subnet as 1:udp_dstip)
|
||||||
1:udp_srcip 10.1.1.11
|
1:udp_srcip 10.1.2.11
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -45,5 +43,5 @@ timing trigger
|
|||||||
# output file directory
|
# output file directory
|
||||||
fpath /external_pool/jungfrau_data/softwaretest
|
fpath /external_pool/jungfrau_data/softwaretest
|
||||||
|
|
||||||
# disable file writing
|
# disable file writing (default)
|
||||||
fwrite 0
|
fwrite 0
|
@ -2,10 +2,8 @@
|
|||||||
hostname localhost:1900+localhost:1902+
|
hostname localhost:1900+localhost:1902+
|
||||||
|
|
||||||
# udp destination ports
|
# udp destination ports
|
||||||
0:udp_dstport 50000
|
udp_dstport 50000
|
||||||
0:udp_dstport2 50001
|
udp_dstport2 50001
|
||||||
1:udp_dstport 50002
|
|
||||||
1:udp_dstport2 50003
|
|
||||||
|
|
||||||
# receiver hostname
|
# receiver hostname
|
||||||
rx_hostname mpc1922:2000+mpc1922:2001+
|
rx_hostname mpc1922:2000+mpc1922:2001+
|
||||||
|
@ -5,24 +5,26 @@ detsize 2048 1024
|
|||||||
virtual 4 1952
|
virtual 4 1952
|
||||||
|
|
||||||
# udp destination ports
|
# udp destination ports
|
||||||
0:udp_dstport2 50001
|
udp_dstport 50001
|
||||||
0:udp_dstport2 50002
|
#0:udp_dstport2 50001
|
||||||
1:udp_dstport 50003
|
#0:udp_dstport2 50002
|
||||||
1:udp_dstport2 50004
|
#1:udp_dstport 50003
|
||||||
2:udp_dstport 50005
|
#1:udp_dstport2 50004
|
||||||
2:udp_dstport2 50006
|
#2:udp_dstport 50005
|
||||||
3:udp_dstport 50007
|
#2:udp_dstport2 50006
|
||||||
3:udp_dstport2 50008
|
#3:udp_dstport 50007
|
||||||
|
#3:udp_dstport2 50008
|
||||||
|
|
||||||
# udp source ip (same subnet as udp_dstip)
|
# udp source ip (same subnet as udp_dstip)
|
||||||
udp_srcip 192.168.1.100
|
udp_srcip 192.168.1.100
|
||||||
udp_srcip2 192.168.1.100
|
udp_srcip2 192.168.1.100
|
||||||
|
|
||||||
# receiver hostname and tcpports
|
# receiver hostname and tcpports
|
||||||
0:rx_tcpport 1970
|
rx_tcpport 1970
|
||||||
1:rx_tcpport 1971
|
#0:rx_tcpport 1970
|
||||||
2:rx_tcpport 1972
|
#1:rx_tcpport 1971
|
||||||
3:rx_tcpport 1973
|
#2:rx_tcpport 1972
|
||||||
|
#3:rx_tcpport 1973
|
||||||
rx_hostname mpc1922
|
rx_hostname mpc1922
|
||||||
|
|
||||||
# udp destination ip from rx_hostname
|
# udp destination ip from rx_hostname
|
||||||
|
@ -11,6 +11,7 @@ pybind11_add_module(_slsdet
|
|||||||
src/current.cpp
|
src/current.cpp
|
||||||
src/duration.cpp
|
src/duration.cpp
|
||||||
src/DurationWrapper.cpp
|
src/DurationWrapper.cpp
|
||||||
|
src/pedestal.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(_slsdet PUBLIC
|
target_link_libraries(_slsdet PUBLIC
|
||||||
@ -27,8 +28,7 @@ set( PYTHON_FILES
|
|||||||
slsdet/__init__.py
|
slsdet/__init__.py
|
||||||
slsdet/adcs.py
|
slsdet/adcs.py
|
||||||
slsdet/dacs.py
|
slsdet/dacs.py
|
||||||
slsdet/voltages.py
|
slsdet/powers.py
|
||||||
slsdet/slowadcs.py
|
|
||||||
slsdet/decorators.py
|
slsdet/decorators.py
|
||||||
slsdet/detector_property.py
|
slsdet/detector_property.py
|
||||||
slsdet/detector.py
|
slsdet/detector.py
|
||||||
|
12
python/examples/use_pedestalmode.py
Normal file
12
python/examples/use_pedestalmode.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
|
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
|
from slsdet import Detector, pedestalParameters
|
||||||
|
|
||||||
|
p = pedestalParameters()
|
||||||
|
p.frames = 10
|
||||||
|
p.loops= 20
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
d = Detector()
|
||||||
|
d.pedestalmode = p
|
@ -7,7 +7,6 @@ Build upon the pybind11 example found here: https://github.com/pybind/python_exa
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
sys.path.append('../libs/pybind')
|
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
from pybind11.setup_helpers import Pybind11Extension, build_ext
|
from pybind11.setup_helpers import Pybind11Extension, build_ext
|
||||||
|
|
||||||
@ -35,16 +34,16 @@ ext_modules = [
|
|||||||
'src/scan.cpp',
|
'src/scan.cpp',
|
||||||
'src/duration.cpp',
|
'src/duration.cpp',
|
||||||
'src/DurationWrapper.cpp',
|
'src/DurationWrapper.cpp',
|
||||||
|
'src/pedestal.cpp',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
,
|
,
|
||||||
include_dirs=[
|
include_dirs=[
|
||||||
os.path.join('../libs/pybind/include'),
|
|
||||||
os.path.join(get_conda_path(), 'include'),
|
os.path.join(get_conda_path(), 'include'),
|
||||||
|
|
||||||
],
|
],
|
||||||
libraries=['SlsDetector', 'SlsSupport', 'SlsReceiver', 'zmq'],
|
libraries=['SlsDetector', 'SlsSupport', 'SlsReceiver'],
|
||||||
library_dirs=[
|
library_dirs=[
|
||||||
os.path.join(get_conda_path(), 'lib'),
|
os.path.join(get_conda_path(), 'lib'),
|
||||||
],
|
],
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
from .eiger import Eiger
|
from .eiger import Eiger
|
||||||
from .ctb import Ctb
|
from .ctb import Ctb
|
||||||
from .dacs import DetectorDacs, Dac
|
from .dacs import DetectorDacs, Dac
|
||||||
from .voltages import DetectorVoltages, Voltage
|
from .powers import DetectorPowers, Power
|
||||||
from .slowadcs import DetectorSlowAdcs, SlowAdc
|
|
||||||
from .detector import Detector
|
from .detector import Detector
|
||||||
from .jungfrau import Jungfrau
|
from .jungfrau import Jungfrau
|
||||||
from .mythen3 import Mythen3
|
from .mythen3 import Mythen3
|
||||||
@ -28,3 +27,4 @@ MacAddr = _slsdet.MacAddr
|
|||||||
scanParameters = _slsdet.scanParameters
|
scanParameters = _slsdet.scanParameters
|
||||||
currentSrcParameters = _slsdet.currentSrcParameters
|
currentSrcParameters = _slsdet.currentSrcParameters
|
||||||
DurationWrapper = _slsdet.DurationWrapper
|
DurationWrapper = _slsdet.DurationWrapper
|
||||||
|
pedestalParameters = _slsdet.pedestalParameters
|
@ -3,8 +3,7 @@
|
|||||||
from .detector import Detector, freeze
|
from .detector import Detector, freeze
|
||||||
from .utils import element_if_equal
|
from .utils import element_if_equal
|
||||||
from .dacs import DetectorDacs, NamedDacs
|
from .dacs import DetectorDacs, NamedDacs
|
||||||
from .voltages import DetectorVoltages, NamedVoltages
|
from .powers import DetectorPowers, NamedPowers
|
||||||
from .slowadcs import DetectorSlowAdcs, NamedSlowAdcs
|
|
||||||
import _slsdet
|
import _slsdet
|
||||||
dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
||||||
from .detector_property import DetectorProperty
|
from .detector_property import DetectorProperty
|
||||||
@ -17,17 +16,12 @@ class Ctb(Detector):
|
|||||||
super().__init__(id)
|
super().__init__(id)
|
||||||
self._frozen = False
|
self._frozen = False
|
||||||
self._dacs = NamedDacs(self)
|
self._dacs = NamedDacs(self)
|
||||||
self._voltages = NamedVoltages(self)
|
self._powers = NamedPowers(self)
|
||||||
self._slowadcs = NamedSlowAdcs(self)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def dacs(self):
|
def dacs(self):
|
||||||
return self._dacs
|
return self._dacs
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def voltages(self):
|
def powers(self):
|
||||||
return self._voltages
|
return self._powers
|
||||||
|
|
||||||
@property
|
|
||||||
def slowadcs(self):
|
|
||||||
return self._slowadcs
|
|
@ -182,6 +182,7 @@ class Detector(CppDetectorApi):
|
|||||||
|
|
||||||
@port.setter
|
@port.setter
|
||||||
def port(self, value):
|
def port(self, value):
|
||||||
|
ut.validate_port(value)
|
||||||
ut.set_using_dict(self.setControlPort, value)
|
ut.set_using_dict(self.setControlPort, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -197,6 +198,7 @@ class Detector(CppDetectorApi):
|
|||||||
|
|
||||||
@stopport.setter
|
@stopport.setter
|
||||||
def stopport(self, args):
|
def stopport(self, args):
|
||||||
|
ut.validate_port(args)
|
||||||
ut.set_using_dict(self.setStopPort, args)
|
ut.set_using_dict(self.setStopPort, args)
|
||||||
|
|
||||||
|
|
||||||
@ -358,7 +360,8 @@ class Detector(CppDetectorApi):
|
|||||||
@property
|
@property
|
||||||
def settings(self):
|
def settings(self):
|
||||||
"""
|
"""
|
||||||
Detector settings. Enum: detectorSettings
|
Detector settings.
|
||||||
|
Enum: detectorSettings
|
||||||
|
|
||||||
Note
|
Note
|
||||||
-----
|
-----
|
||||||
@ -398,6 +401,9 @@ class Detector(CppDetectorApi):
|
|||||||
def framesl(self):
|
def framesl(self):
|
||||||
"""
|
"""
|
||||||
[Gotthard][Jungfrau][Moench][Mythen3][Gotthard2][CTB] Number of frames left in acquisition.\n
|
[Gotthard][Jungfrau][Moench][Mythen3][Gotthard2][CTB] Number of frames left in acquisition.\n
|
||||||
|
|
||||||
|
Note
|
||||||
|
----
|
||||||
[Gotthard2] only in continuous auto mode.
|
[Gotthard2] only in continuous auto mode.
|
||||||
|
|
||||||
:setter: Not Implemented
|
:setter: Not Implemented
|
||||||
@ -473,7 +479,8 @@ class Detector(CppDetectorApi):
|
|||||||
@element
|
@element
|
||||||
def gaincaps(self):
|
def gaincaps(self):
|
||||||
"""
|
"""
|
||||||
[Mythen3] Gain caps. Enum: M3_GainCaps \n
|
[Mythen3] Gain caps.
|
||||||
|
Enum: M3_GainCaps
|
||||||
|
|
||||||
Note
|
Note
|
||||||
----
|
----
|
||||||
@ -571,8 +578,6 @@ class Detector(CppDetectorApi):
|
|||||||
"""
|
"""
|
||||||
Period between frames, accepts either a value in seconds or datetime.timedelta
|
Period between frames, accepts either a value in seconds or datetime.timedelta
|
||||||
|
|
||||||
Note
|
|
||||||
-----
|
|
||||||
:getter: always returns in seconds. To get in DurationWrapper, use getPeriod
|
:getter: always returns in seconds. To get in DurationWrapper, use getPeriod
|
||||||
|
|
||||||
Example
|
Example
|
||||||
@ -639,9 +644,6 @@ class Detector(CppDetectorApi):
|
|||||||
"""
|
"""
|
||||||
[Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] Delay after trigger, accepts either a value in seconds, DurationWrapper or datetime.timedelta
|
[Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] Delay after trigger, accepts either a value in seconds, DurationWrapper or datetime.timedelta
|
||||||
|
|
||||||
Note
|
|
||||||
-----
|
|
||||||
|
|
||||||
:getter: always returns in seconds. To get in DurationWrapper, use getDelayAfterTrigger
|
:getter: always returns in seconds. To get in DurationWrapper, use getDelayAfterTrigger
|
||||||
|
|
||||||
Example
|
Example
|
||||||
@ -866,6 +868,7 @@ class Detector(CppDetectorApi):
|
|||||||
|
|
||||||
@rx_tcpport.setter
|
@rx_tcpport.setter
|
||||||
def rx_tcpport(self, port):
|
def rx_tcpport(self, port):
|
||||||
|
ut.validate_port(port)
|
||||||
ut.set_using_dict(self.setRxPort, port)
|
ut.set_using_dict(self.setRxPort, port)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -892,7 +895,8 @@ class Detector(CppDetectorApi):
|
|||||||
@element
|
@element
|
||||||
def rx_discardpolicy(self):
|
def rx_discardpolicy(self):
|
||||||
"""
|
"""
|
||||||
Frame discard policy of receiver. Enum: frameDiscardPolicy
|
Frame discard policy of receiver.
|
||||||
|
Enum: frameDiscardPolicy
|
||||||
|
|
||||||
Note
|
Note
|
||||||
-----
|
-----
|
||||||
@ -966,7 +970,8 @@ class Detector(CppDetectorApi):
|
|||||||
@property
|
@property
|
||||||
@element
|
@element
|
||||||
def fformat(self):
|
def fformat(self):
|
||||||
""" File format of data file in receiver. Enum: fileFormat
|
""" File format of data file in receiver.
|
||||||
|
Enum: fileFormat
|
||||||
|
|
||||||
Note
|
Note
|
||||||
-----
|
-----
|
||||||
@ -1145,11 +1150,14 @@ class Detector(CppDetectorApi):
|
|||||||
@rx_zmqport.setter
|
@rx_zmqport.setter
|
||||||
def rx_zmqport(self, port):
|
def rx_zmqport(self, port):
|
||||||
if isinstance(port, int):
|
if isinstance(port, int):
|
||||||
|
ut.validate_port(port)
|
||||||
self.setRxZmqPort(port, -1)
|
self.setRxZmqPort(port, -1)
|
||||||
elif isinstance(port, dict):
|
elif isinstance(port, dict):
|
||||||
|
ut.validate_port(port)
|
||||||
ut.set_using_dict(self.setRxZmqPort, port)
|
ut.set_using_dict(self.setRxZmqPort, port)
|
||||||
elif is_iterable(port):
|
elif is_iterable(port):
|
||||||
for i, p in enumerate(port):
|
for i, p in enumerate(port):
|
||||||
|
ut.validate_port(p)
|
||||||
self.setRxZmqPort(p, i)
|
self.setRxZmqPort(p, i)
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unknown argument type")
|
raise ValueError("Unknown argument type")
|
||||||
@ -1179,11 +1187,14 @@ class Detector(CppDetectorApi):
|
|||||||
@zmqport.setter
|
@zmqport.setter
|
||||||
def zmqport(self, port):
|
def zmqport(self, port):
|
||||||
if isinstance(port, int):
|
if isinstance(port, int):
|
||||||
|
ut.validate_port(port)
|
||||||
self.setClientZmqPort(port, -1)
|
self.setClientZmqPort(port, -1)
|
||||||
elif isinstance(port, dict):
|
elif isinstance(port, dict):
|
||||||
|
ut.validate_port(port)
|
||||||
ut.set_using_dict(self.setClientZmqPort, port)
|
ut.set_using_dict(self.setClientZmqPort, port)
|
||||||
elif is_iterable(port):
|
elif is_iterable(port):
|
||||||
for i, p in enumerate(port):
|
for i, p in enumerate(port):
|
||||||
|
ut.validate_port(p)
|
||||||
self.setClientZmqPort(p, i)
|
self.setClientZmqPort(p, i)
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unknown argument type")
|
raise ValueError("Unknown argument type")
|
||||||
@ -1493,6 +1504,7 @@ class Detector(CppDetectorApi):
|
|||||||
|
|
||||||
@udp_dstport.setter
|
@udp_dstport.setter
|
||||||
def udp_dstport(self, port):
|
def udp_dstport(self, port):
|
||||||
|
ut.validate_port(port)
|
||||||
ut.set_using_dict(self.setDestinationUDPPort, port)
|
ut.set_using_dict(self.setDestinationUDPPort, port)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -1514,6 +1526,7 @@ class Detector(CppDetectorApi):
|
|||||||
|
|
||||||
@udp_dstport2.setter
|
@udp_dstport2.setter
|
||||||
def udp_dstport2(self, port):
|
def udp_dstport2(self, port):
|
||||||
|
ut.validate_port(port)
|
||||||
ut.set_using_dict(self.setDestinationUDPPort2, port)
|
ut.set_using_dict(self.setDestinationUDPPort2, port)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -1554,7 +1567,8 @@ class Detector(CppDetectorApi):
|
|||||||
@property
|
@property
|
||||||
@element
|
@element
|
||||||
def status(self):
|
def status(self):
|
||||||
"""Gets detector status. Enum: runStatus
|
"""Gets detector status.
|
||||||
|
Enum: runStatus
|
||||||
|
|
||||||
Note
|
Note
|
||||||
-----
|
-----
|
||||||
@ -1568,7 +1582,8 @@ class Detector(CppDetectorApi):
|
|||||||
@property
|
@property
|
||||||
@element
|
@element
|
||||||
def rx_status(self):
|
def rx_status(self):
|
||||||
"""Gets receiver listener status. Enum: runStatus
|
"""Gets receiver listener status.
|
||||||
|
Enum: runStatus
|
||||||
|
|
||||||
Note
|
Note
|
||||||
-----
|
-----
|
||||||
@ -1662,6 +1677,11 @@ class Detector(CppDetectorApi):
|
|||||||
def sync(self):
|
def sync(self):
|
||||||
"""
|
"""
|
||||||
[Jungfrau][Moench] Enables or disables synchronization between modules.
|
[Jungfrau][Moench] Enables or disables synchronization between modules.
|
||||||
|
|
||||||
|
Note
|
||||||
|
----
|
||||||
|
Sync mode requires at least one master configured. Also requires flatband cabling between master and slave with termination board.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return self.getSynchronization()
|
return self.getSynchronization()
|
||||||
|
|
||||||
@ -1792,6 +1812,7 @@ class Detector(CppDetectorApi):
|
|||||||
def daclist(self):
|
def daclist(self):
|
||||||
"""
|
"""
|
||||||
List of enums/names for every dac for this detector
|
List of enums/names for every dac for this detector
|
||||||
|
|
||||||
:setter: Only implemented for Chiptestboard
|
:setter: Only implemented for Chiptestboard
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -1804,9 +1825,7 @@ class Detector(CppDetectorApi):
|
|||||||
@property
|
@property
|
||||||
def adclist(self):
|
def adclist(self):
|
||||||
"""
|
"""
|
||||||
List of names for every adc for this board. 32 adcs
|
[Chiptestboard] List of names for every adc for this board. 32 adcs
|
||||||
:setter: Only implemented for Chiptestboard
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return self.getAdcNames()
|
return self.getAdcNames()
|
||||||
|
|
||||||
@ -1817,9 +1836,7 @@ class Detector(CppDetectorApi):
|
|||||||
@property
|
@property
|
||||||
def signallist(self):
|
def signallist(self):
|
||||||
"""
|
"""
|
||||||
List of names for every io signal for this board. 64 signals
|
[Chiptestboard] List of names for every io signal for this board. 64 signals
|
||||||
:setter: Only implemented for Chiptestboard
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return self.getSignalNames()
|
return self.getSignalNames()
|
||||||
|
|
||||||
@ -1828,23 +1845,21 @@ class Detector(CppDetectorApi):
|
|||||||
self.setSignalNames(value)
|
self.setSignalNames(value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def voltagelist(self):
|
def powerlist(self):
|
||||||
"""
|
"""
|
||||||
List of names for every voltage for this board. 5 voltage supply
|
[Chiptestboard] List of names for every power for this board. 5 power supply
|
||||||
:setter: Only implemented for Chiptestboard
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return self.getVoltageNames()
|
return self.getPowerNames()
|
||||||
|
|
||||||
@voltagelist.setter
|
@powerlist.setter
|
||||||
def voltagelist(self, value):
|
def powerlist(self, value):
|
||||||
self.setVoltageNames(value)
|
self.setPowerNames(value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def slowadclist(self):
|
def slowadclist(self):
|
||||||
"""
|
"""
|
||||||
List of names for every slowadc for this board. 8 slowadc
|
[Chiptestboard] List of names for every slowadc for this board. 8 slowadc
|
||||||
:setter: Only implemented for Chiptestboard
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return self.getSlowADCNames()
|
return self.getSlowADCNames()
|
||||||
@ -1862,16 +1877,16 @@ class Detector(CppDetectorApi):
|
|||||||
}
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def voltagevalues(self):
|
def powervalues(self):
|
||||||
"""Gets the voltage values for every voltage for this detector."""
|
"""[Chiptestboard] Gets the power values for every power for this detector."""
|
||||||
return {
|
return {
|
||||||
voltage.name.lower(): element_if_equal(np.array(self.getVoltage(voltage)))
|
power.name.lower(): element_if_equal(np.array(self.getPower(power)))
|
||||||
for voltage in self.getVoltageList()
|
for power in self.getPowerList()
|
||||||
}
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def slowadcvalues(self):
|
def slowadcvalues(self):
|
||||||
"""Gets the slow adc values for every slow adc for this detector."""
|
"""[Chiptestboard] Gets the slow adc values for every slow adc for this detector."""
|
||||||
return {
|
return {
|
||||||
slowadc.name.lower(): element_if_equal(np.array(self.getSlowADC(slowadc)))
|
slowadc.name.lower(): element_if_equal(np.array(self.getSlowADC(slowadc)))
|
||||||
for slowadc in self.getSlowADCList()
|
for slowadc in self.getSlowADCList()
|
||||||
@ -2026,6 +2041,7 @@ class Detector(CppDetectorApi):
|
|||||||
@virtual.setter
|
@virtual.setter
|
||||||
def virtual(self, args):
|
def virtual(self, args):
|
||||||
n_detectors, starting_port = args
|
n_detectors, starting_port = args
|
||||||
|
ut.validate_port(starting_port)
|
||||||
self.setVirtualDetectorServers(n_detectors, starting_port)
|
self.setVirtualDetectorServers(n_detectors, starting_port)
|
||||||
|
|
||||||
|
|
||||||
@ -2044,8 +2060,7 @@ class Detector(CppDetectorApi):
|
|||||||
-----
|
-----
|
||||||
To set default rate correction from trimbit file, use setDefaultRateCorrection
|
To set default rate correction from trimbit file, use setDefaultRateCorrection
|
||||||
|
|
||||||
Known Issue
|
Known Issue:
|
||||||
------------
|
|
||||||
|
|
||||||
:getter: Always give 0 due to the microseconds precision.
|
:getter: Always give 0 due to the microseconds precision.
|
||||||
:setter: Use scientific notation to set custom rate correction, since timedelta resolution is 1 microseconds. \n
|
:setter: Use scientific notation to set custom rate correction, since timedelta resolution is 1 microseconds. \n
|
||||||
@ -2069,7 +2084,8 @@ class Detector(CppDetectorApi):
|
|||||||
@element
|
@element
|
||||||
def readoutspeed(self):
|
def readoutspeed(self):
|
||||||
"""
|
"""
|
||||||
[Eiger][Jungfrau|Gotthard2] Readout speed of chip. Enum: speedLevel
|
[Eiger][Jungfrau|Gotthard2] Readout speed of chip.
|
||||||
|
Enum: speedLevel
|
||||||
|
|
||||||
Note
|
Note
|
||||||
-----
|
-----
|
||||||
@ -2158,7 +2174,8 @@ class Detector(CppDetectorApi):
|
|||||||
@element
|
@element
|
||||||
def timing(self):
|
def timing(self):
|
||||||
"""
|
"""
|
||||||
Set Timing Mode of detector. Enum: timingMode
|
Set Timing Mode of detector.
|
||||||
|
Enum: timingMode
|
||||||
|
|
||||||
Note
|
Note
|
||||||
-----
|
-----
|
||||||
@ -2218,13 +2235,11 @@ class Detector(CppDetectorApi):
|
|||||||
@property
|
@property
|
||||||
@element
|
@element
|
||||||
def type(self):
|
def type(self):
|
||||||
""" Returns detector type. Enum: detectorType
|
""" Returns detector type.
|
||||||
|
Enum: detectorType
|
||||||
Note
|
[EIGER, JUNGFRAU, GOTTHARD, MOENCH, MYTHEN3, GOTTHARD2, CHIPTESTBOARD]
|
||||||
----
|
|
||||||
|
|
||||||
:setter: Not implemented
|
:setter: Not implemented
|
||||||
Values: EIGER, JUNGFRAU, GOTTHARD, MOENCH, MYTHEN3, GOTTHARD2, CHIPTESTBOARD
|
|
||||||
"""
|
"""
|
||||||
return self.getDetectorType()
|
return self.getDetectorType()
|
||||||
|
|
||||||
@ -2485,9 +2500,6 @@ class Detector(CppDetectorApi):
|
|||||||
"""
|
"""
|
||||||
[Eiger] Measured sub frame period between last sub frame and previous one.
|
[Eiger] Measured sub frame period between last sub frame and previous one.
|
||||||
|
|
||||||
Note
|
|
||||||
-----
|
|
||||||
|
|
||||||
:setter: Not implemented
|
:setter: Not implemented
|
||||||
"""
|
"""
|
||||||
return ut.reduce_time(self.getMeasuredSubFramePeriod())
|
return ut.reduce_time(self.getMeasuredSubFramePeriod())
|
||||||
@ -2765,7 +2777,8 @@ class Detector(CppDetectorApi):
|
|||||||
@property
|
@property
|
||||||
def gainmode(self):
|
def gainmode(self):
|
||||||
"""
|
"""
|
||||||
[Jungfrau] Detector gain mode. Enum: gainMode
|
[Jungfrau] Detector gain mode.
|
||||||
|
Enum: gainMode
|
||||||
|
|
||||||
Note
|
Note
|
||||||
-----
|
-----
|
||||||
@ -2856,12 +2869,29 @@ class Detector(CppDetectorApi):
|
|||||||
ut.set_using_dict(self.setNumberOfFilterCells, value)
|
ut.set_using_dict(self.setNumberOfFilterCells, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def maxclkphaseshift(self):
|
@element
|
||||||
|
def pedestalmode(self):
|
||||||
"""
|
"""
|
||||||
[Gotthard2][Mythen3] Absolute maximum Phase shift of clocks.
|
[Jungfrau] Enables or disables pedestal mode. Pass in a pedestalParameters object
|
||||||
|
see python/examples/use_pedestalmode.py
|
||||||
|
|
||||||
Note
|
Note
|
||||||
----
|
----
|
||||||
|
The number of frames or triggers is overwritten by #pedestal_frames x pedestal_loops x 2. \n
|
||||||
|
In auto timing mode or in trigger mode with #frames > 1, #frames is overwritten and #triggers = 1, else #triggers is overwritten and #frames = 1. \n
|
||||||
|
One cannot set #frames, #triggers or timing mode in pedestal mode (exception thrown).\n
|
||||||
|
Disabling pedestal mode will set back the normal mode values of #frames and #triggers."
|
||||||
|
"""
|
||||||
|
return self.getPedestalMode()
|
||||||
|
|
||||||
|
@pedestalmode.setter
|
||||||
|
def pedestalmode(self, value):
|
||||||
|
ut.set_using_dict(self.setPedestalMode, value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def maxclkphaseshift(self):
|
||||||
|
"""
|
||||||
|
[Gotthard2][Mythen3] Absolute maximum Phase shift of clocks.
|
||||||
|
|
||||||
:setter: Not Implemented
|
:setter: Not Implemented
|
||||||
|
|
||||||
@ -2880,7 +2910,8 @@ class Detector(CppDetectorApi):
|
|||||||
@element
|
@element
|
||||||
def timingsource(self):
|
def timingsource(self):
|
||||||
"""
|
"""
|
||||||
[Gotthard2] Timing source. Enum: timingSourceType
|
[Gotthard2] Timing source.
|
||||||
|
Enum: timingSourceType
|
||||||
|
|
||||||
Note
|
Note
|
||||||
-----
|
-----
|
||||||
@ -2924,7 +2955,8 @@ class Detector(CppDetectorApi):
|
|||||||
@property
|
@property
|
||||||
@element
|
@element
|
||||||
def burstmode(self):
|
def burstmode(self):
|
||||||
"""[Gotthard2] Burst mode of detector. Enum: burstMode
|
"""[Gotthard2] Burst mode of detector.
|
||||||
|
Enum: burstMode
|
||||||
|
|
||||||
Note
|
Note
|
||||||
----
|
----
|
||||||
@ -2942,9 +2974,6 @@ class Detector(CppDetectorApi):
|
|||||||
"""
|
"""
|
||||||
[Gotthard2] Period between 2 bursts. Only in burst mode and auto timing mode.
|
[Gotthard2] Period between 2 bursts. Only in burst mode and auto timing mode.
|
||||||
|
|
||||||
Note
|
|
||||||
-----
|
|
||||||
|
|
||||||
:getter: always returns in seconds. To get in DurationWrapper, use getBurstPeriod
|
:getter: always returns in seconds. To get in DurationWrapper, use getBurstPeriod
|
||||||
:setter: Not Implemented
|
:setter: Not Implemented
|
||||||
|
|
||||||
@ -3067,7 +3096,8 @@ class Detector(CppDetectorApi):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def vetoalg(self):
|
def vetoalg(self):
|
||||||
"""[Gotthard2] Algorithm used for veto. Enum: vetoAlgorithm, streamingInterface
|
"""[Gotthard2] Algorithm used for veto.
|
||||||
|
Enum: vetoAlgorithm, streamingInterface
|
||||||
|
|
||||||
Note
|
Note
|
||||||
----
|
----
|
||||||
@ -3241,7 +3271,8 @@ class Detector(CppDetectorApi):
|
|||||||
@element
|
@element
|
||||||
def romode(self):
|
def romode(self):
|
||||||
"""
|
"""
|
||||||
[CTB] Readout mode of detector. Enum: readoutMode
|
[CTB] Readout mode of detector.
|
||||||
|
Enum: readoutMode
|
||||||
|
|
||||||
Note
|
Note
|
||||||
------
|
------
|
||||||
@ -3347,9 +3378,6 @@ class Detector(CppDetectorApi):
|
|||||||
def maxdbitphaseshift(self):
|
def maxdbitphaseshift(self):
|
||||||
"""[CTB][Jungfrau] Absolute maximum Phase shift of of the clock to latch digital bits.
|
"""[CTB][Jungfrau] Absolute maximum Phase shift of of the clock to latch digital bits.
|
||||||
|
|
||||||
Note
|
|
||||||
-----
|
|
||||||
|
|
||||||
:setter: Not Implemented
|
:setter: Not Implemented
|
||||||
"""
|
"""
|
||||||
return self.getMaxDBITPhaseShift()
|
return self.getMaxDBITPhaseShift()
|
||||||
@ -3394,9 +3422,6 @@ class Detector(CppDetectorApi):
|
|||||||
def maxadcphaseshift(self):
|
def maxadcphaseshift(self):
|
||||||
"""[Jungfrau][Moench][CTB] Absolute maximum Phase shift of ADC clock.
|
"""[Jungfrau][Moench][CTB] Absolute maximum Phase shift of ADC clock.
|
||||||
|
|
||||||
Note
|
|
||||||
-----
|
|
||||||
|
|
||||||
:setter: Not Implemented
|
:setter: Not Implemented
|
||||||
"""
|
"""
|
||||||
return self.getMaxADCPhaseShift()
|
return self.getMaxADCPhaseShift()
|
||||||
@ -3446,9 +3471,6 @@ class Detector(CppDetectorApi):
|
|||||||
"""
|
"""
|
||||||
[Ctb] Sync clock in MHz.
|
[Ctb] Sync clock in MHz.
|
||||||
|
|
||||||
Note
|
|
||||||
-----
|
|
||||||
|
|
||||||
:setter: Not implemented
|
:setter: Not implemented
|
||||||
"""
|
"""
|
||||||
return self.getSYNCClock()
|
return self.getSYNCClock()
|
||||||
@ -3457,9 +3479,6 @@ class Detector(CppDetectorApi):
|
|||||||
def pattern(self):
|
def pattern(self):
|
||||||
"""[Mythen3][Ctb] Loads ASCII pattern file directly to server (instead of executing line by line).
|
"""[Mythen3][Ctb] Loads ASCII pattern file directly to server (instead of executing line by line).
|
||||||
|
|
||||||
Note
|
|
||||||
----
|
|
||||||
|
|
||||||
:getter: Not Implemented
|
:getter: Not Implemented
|
||||||
|
|
||||||
Example
|
Example
|
||||||
@ -3814,73 +3833,73 @@ class Detector(CppDetectorApi):
|
|||||||
@property
|
@property
|
||||||
@element
|
@element
|
||||||
def v_a(self):
|
def v_a(self):
|
||||||
"""[Ctb] Voltage supply a in mV."""
|
"""[Ctb] Power supply a in mV."""
|
||||||
return self.getVoltage(dacIndex.V_POWER_A)
|
return self.getPower(dacIndex.V_POWER_A)
|
||||||
|
|
||||||
@v_a.setter
|
@v_a.setter
|
||||||
def v_a(self, value):
|
def v_a(self, value):
|
||||||
value = ut.merge_args(dacIndex.V_POWER_A, value)
|
value = ut.merge_args(dacIndex.V_POWER_A, value)
|
||||||
ut.set_using_dict(self.setVoltage, *value)
|
ut.set_using_dict(self.setPower, *value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@element
|
@element
|
||||||
def v_b(self):
|
def v_b(self):
|
||||||
"""[Ctb] Voltage supply b in mV."""
|
"""[Ctb] Power supply b in mV."""
|
||||||
return self.getVoltage(dacIndex.V_POWER_B)
|
return self.getPower(dacIndex.V_POWER_B)
|
||||||
|
|
||||||
@v_b.setter
|
@v_b.setter
|
||||||
def v_b(self, value):
|
def v_b(self, value):
|
||||||
value = ut.merge_args(dacIndex.V_POWER_B, value)
|
value = ut.merge_args(dacIndex.V_POWER_B, value)
|
||||||
ut.set_using_dict(self.setVoltage, *value)
|
ut.set_using_dict(self.setPower, *value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@element
|
@element
|
||||||
def v_c(self):
|
def v_c(self):
|
||||||
"""[Ctb] Voltage supply c in mV."""
|
"""[Ctb] Power supply c in mV."""
|
||||||
return self.getVoltage(dacIndex.V_POWER_C)
|
return self.getPower(dacIndex.V_POWER_C)
|
||||||
|
|
||||||
@v_c.setter
|
@v_c.setter
|
||||||
def v_c(self, value):
|
def v_c(self, value):
|
||||||
value = ut.merge_args(dacIndex.V_POWER_C, value)
|
value = ut.merge_args(dacIndex.V_POWER_C, value)
|
||||||
ut.set_using_dict(self.setVoltage, *value)
|
ut.set_using_dict(self.setPower, *value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@element
|
@element
|
||||||
def v_d(self):
|
def v_d(self):
|
||||||
"""[Ctb] Voltage supply d in mV."""
|
"""[Ctb] Power supply d in mV."""
|
||||||
return self.getVoltage(dacIndex.V_POWER_D)
|
return self.getPower(dacIndex.V_POWER_D)
|
||||||
|
|
||||||
@v_d.setter
|
@v_d.setter
|
||||||
def v_d(self, value):
|
def v_d(self, value):
|
||||||
value = ut.merge_args(dacIndex.V_POWER_D, value)
|
value = ut.merge_args(dacIndex.V_POWER_D, value)
|
||||||
ut.set_using_dict(self.setVoltage, *value)
|
ut.set_using_dict(self.setPower, *value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@element
|
@element
|
||||||
def v_io(self):
|
def v_io(self):
|
||||||
"""[Ctb] Voltage supply io in mV. Minimum 1200 mV.
|
"""[Ctb] Power supply io in mV. Minimum 1200 mV.
|
||||||
|
|
||||||
Note
|
Note
|
||||||
----
|
----
|
||||||
Must be the first power regulator to be set after fpga reset (on-board detector server start up).
|
Must be the first power regulator to be set after fpga reset (on-board detector server start up).
|
||||||
"""
|
"""
|
||||||
return self.getVoltage(dacIndex.V_POWER_IO)
|
return self.getPower(dacIndex.V_POWER_IO)
|
||||||
|
|
||||||
@v_io.setter
|
@v_io.setter
|
||||||
def v_io(self, value):
|
def v_io(self, value):
|
||||||
value = ut.merge_args(dacIndex.V_POWER_IO, value)
|
value = ut.merge_args(dacIndex.V_POWER_IO, value)
|
||||||
ut.set_using_dict(self.setVoltage, *value)
|
ut.set_using_dict(self.setPower, *value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@element
|
@element
|
||||||
def v_limit(self):
|
def v_limit(self):
|
||||||
"""[Ctb] Soft limit for power supplies (ctb only) and DACS in mV."""
|
"""[Ctb] Soft limit for power supplies (ctb only) and DACS in mV."""
|
||||||
return self.getVoltage(dacIndex.V_LIMIT)
|
return self.getPower(dacIndex.V_LIMIT)
|
||||||
|
|
||||||
@v_limit.setter
|
@v_limit.setter
|
||||||
def v_limit(self, value):
|
def v_limit(self, value):
|
||||||
value = ut.merge_args(dacIndex.V_LIMIT, value)
|
value = ut.merge_args(dacIndex.V_LIMIT, value)
|
||||||
ut.set_using_dict(self.setVoltage, *value)
|
ut.set_using_dict(self.setPower, *value)
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -3888,9 +3907,6 @@ class Detector(CppDetectorApi):
|
|||||||
def im_a(self):
|
def im_a(self):
|
||||||
"""[Ctb] Measured current of power supply a in mA.
|
"""[Ctb] Measured current of power supply a in mA.
|
||||||
|
|
||||||
Note
|
|
||||||
-----
|
|
||||||
|
|
||||||
:setter: Not implemented
|
:setter: Not implemented
|
||||||
"""
|
"""
|
||||||
return self.getMeasuredCurrent(dacIndex.I_POWER_A)
|
return self.getMeasuredCurrent(dacIndex.I_POWER_A)
|
||||||
@ -3900,9 +3916,6 @@ class Detector(CppDetectorApi):
|
|||||||
def im_b(self):
|
def im_b(self):
|
||||||
"""[Ctb] Measured current of power supply b in mA.
|
"""[Ctb] Measured current of power supply b in mA.
|
||||||
|
|
||||||
Note
|
|
||||||
-----
|
|
||||||
|
|
||||||
:setter: Not implemented
|
:setter: Not implemented
|
||||||
"""
|
"""
|
||||||
return self.getMeasuredCurrent(dacIndex.I_POWER_B)
|
return self.getMeasuredCurrent(dacIndex.I_POWER_B)
|
||||||
@ -3912,9 +3925,6 @@ class Detector(CppDetectorApi):
|
|||||||
def im_c(self):
|
def im_c(self):
|
||||||
"""[Ctb] Measured current of power supply c in mA.
|
"""[Ctb] Measured current of power supply c in mA.
|
||||||
|
|
||||||
Note
|
|
||||||
-----
|
|
||||||
|
|
||||||
:setter: Not implemented
|
:setter: Not implemented
|
||||||
"""
|
"""
|
||||||
return self.getMeasuredCurrent(dacIndex.I_POWER_C)
|
return self.getMeasuredCurrent(dacIndex.I_POWER_C)
|
||||||
@ -3924,9 +3934,6 @@ class Detector(CppDetectorApi):
|
|||||||
def im_d(self):
|
def im_d(self):
|
||||||
"""[Ctb] Measured current of power supply d in mA.
|
"""[Ctb] Measured current of power supply d in mA.
|
||||||
|
|
||||||
Note
|
|
||||||
-----
|
|
||||||
|
|
||||||
:setter: Not implemented
|
:setter: Not implemented
|
||||||
"""
|
"""
|
||||||
return self.getMeasuredCurrent(dacIndex.I_POWER_D)
|
return self.getMeasuredCurrent(dacIndex.I_POWER_D)
|
||||||
@ -3936,9 +3943,6 @@ class Detector(CppDetectorApi):
|
|||||||
def im_io(self):
|
def im_io(self):
|
||||||
"""[Ctb] Measured current of power supply io in mA.
|
"""[Ctb] Measured current of power supply io in mA.
|
||||||
|
|
||||||
Note
|
|
||||||
-----
|
|
||||||
|
|
||||||
:setter: Not implemented
|
:setter: Not implemented
|
||||||
"""
|
"""
|
||||||
return self.getMeasuredCurrent(dacIndex.I_POWER_IO)
|
return self.getMeasuredCurrent(dacIndex.I_POWER_IO)
|
||||||
@ -3988,9 +3992,6 @@ class Detector(CppDetectorApi):
|
|||||||
def exptimel(self):
|
def exptimel(self):
|
||||||
"""[Gotthard] Exposure time left for current frame.
|
"""[Gotthard] Exposure time left for current frame.
|
||||||
|
|
||||||
Note
|
|
||||||
-----
|
|
||||||
|
|
||||||
:getter: always returns in seconds. To get in DurationWrapper, use getExptimeLeft
|
:getter: always returns in seconds. To get in DurationWrapper, use getExptimeLeft
|
||||||
:setter: Not Implemented
|
:setter: Not Implemented
|
||||||
|
|
||||||
@ -4025,9 +4026,6 @@ class Detector(CppDetectorApi):
|
|||||||
"""
|
"""
|
||||||
[Gotthard2][Mythen3] Frequency of clock in Hz.
|
[Gotthard2][Mythen3] Frequency of clock in Hz.
|
||||||
|
|
||||||
Note
|
|
||||||
----
|
|
||||||
|
|
||||||
:setter: Not implemented. Use clkdiv to set frequency
|
:setter: Not implemented. Use clkdiv to set frequency
|
||||||
|
|
||||||
Example
|
Example
|
||||||
@ -4047,7 +4045,9 @@ class Detector(CppDetectorApi):
|
|||||||
@property
|
@property
|
||||||
@element
|
@element
|
||||||
def polarity(self):
|
def polarity(self):
|
||||||
"""[Mythen3] Set positive or negative polarity. Enum: polarity"""
|
"""[Mythen3] Set positive or negative polarity.
|
||||||
|
Enum: polarity
|
||||||
|
"""
|
||||||
return self.getPolarity()
|
return self.getPolarity()
|
||||||
|
|
||||||
@polarity.setter
|
@polarity.setter
|
||||||
|
195
python/slsdet/powers.py
Executable file
195
python/slsdet/powers.py
Executable file
@ -0,0 +1,195 @@
|
|||||||
|
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
|
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
|
from .detector_property import DetectorProperty
|
||||||
|
from functools import partial
|
||||||
|
import numpy as np
|
||||||
|
import _slsdet
|
||||||
|
from .detector import freeze
|
||||||
|
dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
||||||
|
class Power(DetectorProperty):
|
||||||
|
"""
|
||||||
|
This class represents a power on the Chip Test Board. One instance handles all
|
||||||
|
powers with the same name for a multi detector instance. (TODO: Not needed for CTB)
|
||||||
|
|
||||||
|
.. note ::
|
||||||
|
|
||||||
|
This class is used to build up DetectorPowers and is in general
|
||||||
|
not directly accessible to the user.
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
def __init__(self, name, enum, default, detector):
|
||||||
|
|
||||||
|
super().__init__(partial(detector.getPower, enum),
|
||||||
|
lambda x, y : detector.setPower(enum, x, y),
|
||||||
|
detector.size,
|
||||||
|
name)
|
||||||
|
|
||||||
|
self.default = default
|
||||||
|
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
"""String representation for a single power in all modules"""
|
||||||
|
powerstr = ''.join([f'{item:5d}' for item in self.get()])
|
||||||
|
return f'{self.__name__:15s}:{powerstr}'
|
||||||
|
|
||||||
|
class NamedPowers:
|
||||||
|
"""
|
||||||
|
New implementation of the detector powers.
|
||||||
|
"""
|
||||||
|
_frozen = False
|
||||||
|
_direct_access = ['_detector', '_current', '_powernames']
|
||||||
|
def __init__(self, detector):
|
||||||
|
self._detector = detector
|
||||||
|
self._current = 0
|
||||||
|
|
||||||
|
#only get the powernames if we have modules attached
|
||||||
|
if detector.size() == 0:
|
||||||
|
self._powernames = ["VA", "VB", "VC", "VD", "VIO"]
|
||||||
|
else:
|
||||||
|
self._powernames = [n.replace(" ", "") for n in detector.getPowerNames()]
|
||||||
|
|
||||||
|
# Populate the powers
|
||||||
|
for i,name in enumerate(self._powernames):
|
||||||
|
#name, enum, low, high, default, detector
|
||||||
|
k = dacIndex(i + int(dacIndex.V_POWER_A))
|
||||||
|
setattr(self, name, Power(name, k, 0, detector))
|
||||||
|
|
||||||
|
self._frozen = True
|
||||||
|
|
||||||
|
# def __getattr__(self, name):
|
||||||
|
# return self.__getattribute__('_' + name)
|
||||||
|
|
||||||
|
def __setattr__(self, name, value):
|
||||||
|
if not self._frozen:
|
||||||
|
#durning init we need to be able to set up the class
|
||||||
|
super().__setattr__(name, value)
|
||||||
|
else:
|
||||||
|
#Later we restrict us to manipulate powers and a few fields
|
||||||
|
if name in self._direct_access:
|
||||||
|
super().__setattr__(name, value)
|
||||||
|
elif name in self._powernames:
|
||||||
|
return self.__getattribute__(name).__setitem__(slice(None, None), value)
|
||||||
|
else:
|
||||||
|
raise AttributeError(f'Power not found: {name}')
|
||||||
|
|
||||||
|
def __next__(self):
|
||||||
|
if self._current >= len(self._powernames):
|
||||||
|
self._current = 0
|
||||||
|
raise StopIteration
|
||||||
|
else:
|
||||||
|
self._current += 1
|
||||||
|
return self.__getattribute__(self._powernames[self._current-1])
|
||||||
|
# return self.__getattr__(self._powernames[self._current-1])
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
r_str = ['========== POWERS =========']
|
||||||
|
r_str += [repr(power) for power in self]
|
||||||
|
return '\n'.join(r_str)
|
||||||
|
def get_asarray(self):
|
||||||
|
"""
|
||||||
|
Read the powers into a numpy array with dimensions [npowers, nmodules]
|
||||||
|
"""
|
||||||
|
power_array = np.zeros((len(self._powernames), len(self._detector)))
|
||||||
|
for i, _d in enumerate(self):
|
||||||
|
power_array[i,:] = _d[:]
|
||||||
|
return power_array
|
||||||
|
|
||||||
|
def to_array(self):
|
||||||
|
return self.get_asarray()
|
||||||
|
|
||||||
|
def set_from_array(self, power_array):
|
||||||
|
"""
|
||||||
|
Set the power from an numpy array with power values. [npowers, nmodules]
|
||||||
|
"""
|
||||||
|
power_array = power_array.astype(np.int)
|
||||||
|
for i, _d in enumerate(self):
|
||||||
|
_d[:] = power_array[i]
|
||||||
|
|
||||||
|
def from_array(self, power_array):
|
||||||
|
self.set_from_array(power_array)
|
||||||
|
|
||||||
|
class DetectorPowers:
|
||||||
|
_powers = []
|
||||||
|
_powernames = [_d[0] for _d in _powers]
|
||||||
|
_allowed_attr = ['_detector', '_current']
|
||||||
|
_frozen = False
|
||||||
|
|
||||||
|
def __init__(self, detector):
|
||||||
|
# We need to at least initially know which detector we are connected to
|
||||||
|
self._detector = detector
|
||||||
|
|
||||||
|
# Index to support iteration
|
||||||
|
self._current = 0
|
||||||
|
|
||||||
|
# Name the attributes?
|
||||||
|
for _d in self._powers:
|
||||||
|
setattr(self, '_'+_d[0], Power(*_d, detector))
|
||||||
|
|
||||||
|
self._frozen = True
|
||||||
|
|
||||||
|
def __getattr__(self, name):
|
||||||
|
return self.__getattribute__('_' + name)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def powernames(self):
|
||||||
|
return [_d[0] for _d in _powers]
|
||||||
|
|
||||||
|
def __setattr__(self, name, value):
|
||||||
|
if name in self._powernames:
|
||||||
|
return self.__getattribute__('_' + name).__setitem__(slice(None, None), value)
|
||||||
|
else:
|
||||||
|
if self._frozen == True and name not in self._allowed_attr:
|
||||||
|
raise AttributeError(f'Power not found: {name}')
|
||||||
|
super().__setattr__(name, value)
|
||||||
|
|
||||||
|
|
||||||
|
def __next__(self):
|
||||||
|
if self._current >= len(self._powers):
|
||||||
|
self._current = 0
|
||||||
|
raise StopIteration
|
||||||
|
else:
|
||||||
|
self._current += 1
|
||||||
|
return self.__getattr__(self._powernames[self._current-1])
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
r_str = ['========== POWERS =========']
|
||||||
|
r_str += [repr(power) for power in self]
|
||||||
|
return '\n'.join(r_str)
|
||||||
|
|
||||||
|
def get_asarray(self):
|
||||||
|
"""
|
||||||
|
Read the powers into a numpy array with dimensions [npowers, nmodules]
|
||||||
|
"""
|
||||||
|
power_array = np.zeros((len(self._powers), len(self._detector)))
|
||||||
|
for i, _d in enumerate(self):
|
||||||
|
power_array[i,:] = _d[:]
|
||||||
|
return power_array
|
||||||
|
|
||||||
|
def to_array(self):
|
||||||
|
return self.get_asarray()
|
||||||
|
|
||||||
|
def set_from_array(self, power_array):
|
||||||
|
"""
|
||||||
|
Set the powers from an numpy array with power values. [npowers, nmodules]
|
||||||
|
"""
|
||||||
|
power_array = power_array.astype(np.int)
|
||||||
|
for i, _d in enumerate(self):
|
||||||
|
_d[:] = power_array[i]
|
||||||
|
|
||||||
|
def from_array(self, power_array):
|
||||||
|
self.set_from_array(power_array)
|
||||||
|
|
||||||
|
def set_default(self):
|
||||||
|
"""
|
||||||
|
Set all powers to their default values
|
||||||
|
"""
|
||||||
|
for _d in self:
|
||||||
|
_d[:] = _d.default
|
||||||
|
|
@ -60,19 +60,28 @@ class SlowAdcProxy:
|
|||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
dac_index = dacIndex(int(dacIndex.SLOW_ADC0)+key)
|
dac_index = dacIndex(int(dacIndex.SLOW_ADC0)+key)
|
||||||
return element_if_equal(self.det.getSlowADC(dac_index))
|
return element_if_equal(self.det.getSlowADC(dac_index))/1000 #TODO! Multi module?
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
rstr = ''
|
rstr = ''
|
||||||
for i in range(8):
|
for i,name in enumerate(self.det.getSlowADCNames()):
|
||||||
r = element_if_equal(self.__getitem__(i))
|
r = element_if_equal(self.__getitem__(i))
|
||||||
if isinstance(r, list):
|
if isinstance(r, list):
|
||||||
rstr += ' '.join(f'{item} uV' for item in r)
|
rstr += ' '.join(f'{item/1000} mV' for item in r)
|
||||||
else:
|
else:
|
||||||
rstr += f'{i}: {r} uV\n'
|
rstr += f'[{i}] {name}: {r/1000} mV\n'
|
||||||
|
|
||||||
return rstr.strip('\n')
|
return rstr.strip('\n')
|
||||||
|
|
||||||
|
def __getattr__(self, name):
|
||||||
|
if name in self.det.getSlowADCNames():
|
||||||
|
i = self.det.getSlowADCIndex(name)
|
||||||
|
return element_if_equal(self.det.getSlowADC(i))
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Could not find slow adc with name: {name}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ClkDivProxy:
|
class ClkDivProxy:
|
||||||
"""
|
"""
|
||||||
Proxy class to allow for more intuitive reading clockdivider
|
Proxy class to allow for more intuitive reading clockdivider
|
||||||
|
@ -1,195 +0,0 @@
|
|||||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
|
||||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
from .detector_property import DetectorProperty
|
|
||||||
from functools import partial
|
|
||||||
import numpy as np
|
|
||||||
import _slsdet
|
|
||||||
from .detector import freeze
|
|
||||||
dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
|
||||||
class SlowAdc(DetectorProperty):
|
|
||||||
"""
|
|
||||||
This class represents a slowadc on the Chip Test Board. One instance handles all
|
|
||||||
slowadcs with the same name for a multi detector instance. (TODO: Not needed for CTB)
|
|
||||||
|
|
||||||
.. note ::
|
|
||||||
|
|
||||||
This class is used to build up DetectorSlowAdcs and is in general
|
|
||||||
not directly accessible to the user.
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
def __init__(self, name, enum, default, detector):
|
|
||||||
|
|
||||||
super().__init__(partial(detector.getVoltage, enum),
|
|
||||||
lambda x, y : detector.setVoltage(enum, x, y),
|
|
||||||
detector.size,
|
|
||||||
name)
|
|
||||||
|
|
||||||
self.default = default
|
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
"""String representation for a single slowadc in all modules"""
|
|
||||||
slowadcstr = ''.join([f'{item:5d}' for item in self.get()])
|
|
||||||
return f'{self.__name__:15s}:{slowadcstr}'
|
|
||||||
|
|
||||||
class NamedSlowAdcs:
|
|
||||||
"""
|
|
||||||
New implementation of the detector slowadcs.
|
|
||||||
"""
|
|
||||||
_frozen = False
|
|
||||||
_direct_access = ['_detector', '_current', '_voltagenames']
|
|
||||||
def __init__(self, detector):
|
|
||||||
self._detector = detector
|
|
||||||
self._current = 0
|
|
||||||
|
|
||||||
#only get the voltagenames if we have modules attached
|
|
||||||
if detector.size() == 0:
|
|
||||||
self._voltagenames = ["VA", "VB", "VC", "VD", "VIO"]
|
|
||||||
else:
|
|
||||||
self._voltagenames = [n.replace(" ", "") for n in detector.getVoltageNames()]
|
|
||||||
|
|
||||||
# Populate the slowadcs
|
|
||||||
for i,name in enumerate(self._voltagenames):
|
|
||||||
#name, enum, low, high, default, detector
|
|
||||||
k = dacIndex(i + int(dacIndex.V_POWER_A))
|
|
||||||
setattr(self, name, SlowAdc(name, k, 0, detector))
|
|
||||||
|
|
||||||
self._frozen = True
|
|
||||||
|
|
||||||
# def __getattr__(self, name):
|
|
||||||
# return self.__getattribute__('_' + name)
|
|
||||||
|
|
||||||
def __setattr__(self, name, value):
|
|
||||||
if not self._frozen:
|
|
||||||
#durning init we need to be able to set up the class
|
|
||||||
super().__setattr__(name, value)
|
|
||||||
else:
|
|
||||||
#Later we restrict us to manipulate slowadcs and a few fields
|
|
||||||
if name in self._direct_access:
|
|
||||||
super().__setattr__(name, value)
|
|
||||||
elif name in self._voltagenames:
|
|
||||||
return self.__getattribute__(name).__setitem__(slice(None, None), value)
|
|
||||||
else:
|
|
||||||
raise AttributeError(f'SlowAdc not found: {name}')
|
|
||||||
|
|
||||||
def __next__(self):
|
|
||||||
if self._current >= len(self._voltagenames):
|
|
||||||
self._current = 0
|
|
||||||
raise StopIteration
|
|
||||||
else:
|
|
||||||
self._current += 1
|
|
||||||
return self.__getattribute__(self._voltagenames[self._current-1])
|
|
||||||
# return self.__getattr__(self._voltagenames[self._current-1])
|
|
||||||
|
|
||||||
def __iter__(self):
|
|
||||||
return self
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
r_str = ['========== SLOW ADCS =========']
|
|
||||||
r_str += [repr(slowadc) for slowadc in self]
|
|
||||||
return '\n'.join(r_str)
|
|
||||||
def get_asarray(self):
|
|
||||||
"""
|
|
||||||
Read the slowadcs into a numpy array with dimensions [nslowadcs, nmodules]
|
|
||||||
"""
|
|
||||||
voltage_array = np.zeros((len(self._voltagenames), len(self._detector)))
|
|
||||||
for i, _d in enumerate(self):
|
|
||||||
voltage_array[i,:] = _d[:]
|
|
||||||
return voltage_array
|
|
||||||
|
|
||||||
def to_array(self):
|
|
||||||
return self.get_asarray()
|
|
||||||
|
|
||||||
def set_from_array(self, voltage_array):
|
|
||||||
"""
|
|
||||||
Set the slowadc from an numpy array with slowadc values. [nslowadcs, nmodules]
|
|
||||||
"""
|
|
||||||
voltage_array = voltage_array.astype(np.int)
|
|
||||||
for i, _d in enumerate(self):
|
|
||||||
_d[:] = voltage_array[i]
|
|
||||||
|
|
||||||
def from_array(self, voltage_array):
|
|
||||||
self.set_from_array(voltage_array)
|
|
||||||
|
|
||||||
class DetectorSlowAdcs:
|
|
||||||
_slowadcs = []
|
|
||||||
_voltagenames = [_d[0] for _d in _slowadcs]
|
|
||||||
_allowed_attr = ['_detector', '_current']
|
|
||||||
_frozen = False
|
|
||||||
|
|
||||||
def __init__(self, detector):
|
|
||||||
# We need to at least initially know which detector we are connected to
|
|
||||||
self._detector = detector
|
|
||||||
|
|
||||||
# Index to support iteration
|
|
||||||
self._current = 0
|
|
||||||
|
|
||||||
# Name the attributes?
|
|
||||||
for _d in self._slowadcs:
|
|
||||||
setattr(self, '_'+_d[0], SlowAdc(*_d, detector))
|
|
||||||
|
|
||||||
self._frozen = True
|
|
||||||
|
|
||||||
def __getattr__(self, name):
|
|
||||||
return self.__getattribute__('_' + name)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def voltagenames(self):
|
|
||||||
return [_d[0] for _d in _slowadcs]
|
|
||||||
|
|
||||||
def __setattr__(self, name, value):
|
|
||||||
if name in self._voltagenames:
|
|
||||||
return self.__getattribute__('_' + name).__setitem__(slice(None, None), value)
|
|
||||||
else:
|
|
||||||
if self._frozen == True and name not in self._allowed_attr:
|
|
||||||
raise AttributeError(f'SlowAdc not found: {name}')
|
|
||||||
super().__setattr__(name, value)
|
|
||||||
|
|
||||||
|
|
||||||
def __next__(self):
|
|
||||||
if self._current >= len(self._slowadcs):
|
|
||||||
self._current = 0
|
|
||||||
raise StopIteration
|
|
||||||
else:
|
|
||||||
self._current += 1
|
|
||||||
return self.__getattr__(self._voltagenames[self._current-1])
|
|
||||||
|
|
||||||
def __iter__(self):
|
|
||||||
return self
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
r_str = ['========== SLOW ADCS =========']
|
|
||||||
r_str += [repr(slowadc) for slowadc in self]
|
|
||||||
return '\n'.join(r_str)
|
|
||||||
|
|
||||||
def get_asarray(self):
|
|
||||||
"""
|
|
||||||
Read the slowadcs into a numpy array with dimensions [nslowadcs, nmodules]
|
|
||||||
"""
|
|
||||||
voltage_array = np.zeros((len(self._slowadcs), len(self._detector)))
|
|
||||||
for i, _d in enumerate(self):
|
|
||||||
voltage_array[i,:] = _d[:]
|
|
||||||
return voltage_array
|
|
||||||
|
|
||||||
def to_array(self):
|
|
||||||
return self.get_asarray()
|
|
||||||
|
|
||||||
def set_from_array(self, voltage_array):
|
|
||||||
"""
|
|
||||||
Set the slowadcs from an numpy array with slowadc values. [nslowadcs, nmodules]
|
|
||||||
"""
|
|
||||||
voltage_array = voltage_array.astype(np.int)
|
|
||||||
for i, _d in enumerate(self):
|
|
||||||
_d[:] = voltage_array[i]
|
|
||||||
|
|
||||||
def from_array(self, voltage_array):
|
|
||||||
self.set_from_array(voltage_array)
|
|
||||||
|
|
||||||
def set_default(self):
|
|
||||||
"""
|
|
||||||
Set all slowadcs to their default values
|
|
||||||
"""
|
|
||||||
for _d in self:
|
|
||||||
_d[:] = _d.default
|
|
||||||
|
|
@ -278,3 +278,9 @@ def hostname_list(args):
|
|||||||
return hosts
|
return hosts
|
||||||
else:
|
else:
|
||||||
raise ValueError("hostname needs to be string or list of strings")
|
raise ValueError("hostname needs to be string or list of strings")
|
||||||
|
|
||||||
|
|
||||||
|
def validate_port(value):
|
||||||
|
if value <= 0 or value > 65535:
|
||||||
|
raise ValueError("port must be in range 1 - 65535")
|
||||||
|
|
||||||
|
@ -1,195 +0,0 @@
|
|||||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
|
||||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
from .detector_property import DetectorProperty
|
|
||||||
from functools import partial
|
|
||||||
import numpy as np
|
|
||||||
import _slsdet
|
|
||||||
from .detector import freeze
|
|
||||||
dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
|
||||||
class Voltage(DetectorProperty):
|
|
||||||
"""
|
|
||||||
This class represents a voltage on the Chip Test Board. One instance handles all
|
|
||||||
voltages with the same name for a multi detector instance. (TODO: Not needed for CTB)
|
|
||||||
|
|
||||||
.. note ::
|
|
||||||
|
|
||||||
This class is used to build up DetectorVoltages and is in general
|
|
||||||
not directly accessible to the user.
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
def __init__(self, name, enum, default, detector):
|
|
||||||
|
|
||||||
super().__init__(partial(detector.getVoltage, enum),
|
|
||||||
lambda x, y : detector.setVoltage(enum, x, y),
|
|
||||||
detector.size,
|
|
||||||
name)
|
|
||||||
|
|
||||||
self.default = default
|
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
"""String representation for a single voltage in all modules"""
|
|
||||||
voltagestr = ''.join([f'{item:5d}' for item in self.get()])
|
|
||||||
return f'{self.__name__:15s}:{voltagestr}'
|
|
||||||
|
|
||||||
class NamedVoltages:
|
|
||||||
"""
|
|
||||||
New implementation of the detector voltages.
|
|
||||||
"""
|
|
||||||
_frozen = False
|
|
||||||
_direct_access = ['_detector', '_current', '_voltagenames']
|
|
||||||
def __init__(self, detector):
|
|
||||||
self._detector = detector
|
|
||||||
self._current = 0
|
|
||||||
|
|
||||||
#only get the voltagenames if we have modules attached
|
|
||||||
if detector.size() == 0:
|
|
||||||
self._voltagenames = ["VA", "VB", "VC", "VD", "VIO"]
|
|
||||||
else:
|
|
||||||
self._voltagenames = [n.replace(" ", "") for n in detector.getVoltageNames()]
|
|
||||||
|
|
||||||
# Populate the voltages
|
|
||||||
for i,name in enumerate(self._voltagenames):
|
|
||||||
#name, enum, low, high, default, detector
|
|
||||||
k = dacIndex(i + int(dacIndex.V_POWER_A))
|
|
||||||
setattr(self, name, Voltage(name, k, 0, detector))
|
|
||||||
|
|
||||||
self._frozen = True
|
|
||||||
|
|
||||||
# def __getattr__(self, name):
|
|
||||||
# return self.__getattribute__('_' + name)
|
|
||||||
|
|
||||||
def __setattr__(self, name, value):
|
|
||||||
if not self._frozen:
|
|
||||||
#durning init we need to be able to set up the class
|
|
||||||
super().__setattr__(name, value)
|
|
||||||
else:
|
|
||||||
#Later we restrict us to manipulate voltages and a few fields
|
|
||||||
if name in self._direct_access:
|
|
||||||
super().__setattr__(name, value)
|
|
||||||
elif name in self._voltagenames:
|
|
||||||
return self.__getattribute__(name).__setitem__(slice(None, None), value)
|
|
||||||
else:
|
|
||||||
raise AttributeError(f'Voltage not found: {name}')
|
|
||||||
|
|
||||||
def __next__(self):
|
|
||||||
if self._current >= len(self._voltagenames):
|
|
||||||
self._current = 0
|
|
||||||
raise StopIteration
|
|
||||||
else:
|
|
||||||
self._current += 1
|
|
||||||
return self.__getattribute__(self._voltagenames[self._current-1])
|
|
||||||
# return self.__getattr__(self._voltagenames[self._current-1])
|
|
||||||
|
|
||||||
def __iter__(self):
|
|
||||||
return self
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
r_str = ['========== VOLTAGES =========']
|
|
||||||
r_str += [repr(voltage) for voltage in self]
|
|
||||||
return '\n'.join(r_str)
|
|
||||||
def get_asarray(self):
|
|
||||||
"""
|
|
||||||
Read the voltages into a numpy array with dimensions [nvoltages, nmodules]
|
|
||||||
"""
|
|
||||||
voltage_array = np.zeros((len(self._voltagenames), len(self._detector)))
|
|
||||||
for i, _d in enumerate(self):
|
|
||||||
voltage_array[i,:] = _d[:]
|
|
||||||
return voltage_array
|
|
||||||
|
|
||||||
def to_array(self):
|
|
||||||
return self.get_asarray()
|
|
||||||
|
|
||||||
def set_from_array(self, voltage_array):
|
|
||||||
"""
|
|
||||||
Set the voltage from an numpy array with voltage values. [nvoltages, nmodules]
|
|
||||||
"""
|
|
||||||
voltage_array = voltage_array.astype(np.int)
|
|
||||||
for i, _d in enumerate(self):
|
|
||||||
_d[:] = voltage_array[i]
|
|
||||||
|
|
||||||
def from_array(self, voltage_array):
|
|
||||||
self.set_from_array(voltage_array)
|
|
||||||
|
|
||||||
class DetectorVoltages:
|
|
||||||
_voltages = []
|
|
||||||
_voltagenames = [_d[0] for _d in _voltages]
|
|
||||||
_allowed_attr = ['_detector', '_current']
|
|
||||||
_frozen = False
|
|
||||||
|
|
||||||
def __init__(self, detector):
|
|
||||||
# We need to at least initially know which detector we are connected to
|
|
||||||
self._detector = detector
|
|
||||||
|
|
||||||
# Index to support iteration
|
|
||||||
self._current = 0
|
|
||||||
|
|
||||||
# Name the attributes?
|
|
||||||
for _d in self._voltages:
|
|
||||||
setattr(self, '_'+_d[0], Voltage(*_d, detector))
|
|
||||||
|
|
||||||
self._frozen = True
|
|
||||||
|
|
||||||
def __getattr__(self, name):
|
|
||||||
return self.__getattribute__('_' + name)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def voltagenames(self):
|
|
||||||
return [_d[0] for _d in _voltages]
|
|
||||||
|
|
||||||
def __setattr__(self, name, value):
|
|
||||||
if name in self._voltagenames:
|
|
||||||
return self.__getattribute__('_' + name).__setitem__(slice(None, None), value)
|
|
||||||
else:
|
|
||||||
if self._frozen == True and name not in self._allowed_attr:
|
|
||||||
raise AttributeError(f'Voltage not found: {name}')
|
|
||||||
super().__setattr__(name, value)
|
|
||||||
|
|
||||||
|
|
||||||
def __next__(self):
|
|
||||||
if self._current >= len(self._voltages):
|
|
||||||
self._current = 0
|
|
||||||
raise StopIteration
|
|
||||||
else:
|
|
||||||
self._current += 1
|
|
||||||
return self.__getattr__(self._voltagenames[self._current-1])
|
|
||||||
|
|
||||||
def __iter__(self):
|
|
||||||
return self
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
r_str = ['========== VOLTAGES =========']
|
|
||||||
r_str += [repr(voltage) for voltage in self]
|
|
||||||
return '\n'.join(r_str)
|
|
||||||
|
|
||||||
def get_asarray(self):
|
|
||||||
"""
|
|
||||||
Read the voltages into a numpy array with dimensions [nvoltages, nmodules]
|
|
||||||
"""
|
|
||||||
voltage_array = np.zeros((len(self._voltages), len(self._detector)))
|
|
||||||
for i, _d in enumerate(self):
|
|
||||||
voltage_array[i,:] = _d[:]
|
|
||||||
return voltage_array
|
|
||||||
|
|
||||||
def to_array(self):
|
|
||||||
return self.get_asarray()
|
|
||||||
|
|
||||||
def set_from_array(self, voltage_array):
|
|
||||||
"""
|
|
||||||
Set the voltages from an numpy array with voltage values. [nvoltages, nmodules]
|
|
||||||
"""
|
|
||||||
voltage_array = voltage_array.astype(np.int)
|
|
||||||
for i, _d in enumerate(self):
|
|
||||||
_d[:] = voltage_array[i]
|
|
||||||
|
|
||||||
def from_array(self, voltage_array):
|
|
||||||
self.set_from_array(voltage_array)
|
|
||||||
|
|
||||||
def set_default(self):
|
|
||||||
"""
|
|
||||||
Set all voltages to their default values
|
|
||||||
"""
|
|
||||||
for _d in self:
|
|
||||||
_d[:] = _d.default
|
|
||||||
|
|
@ -48,7 +48,7 @@ void init_det(py::module &m) {
|
|||||||
Detector::setHostname,
|
Detector::setHostname,
|
||||||
py::arg());
|
py::arg());
|
||||||
CppDetectorApi.def("setVirtualDetectorServers",
|
CppDetectorApi.def("setVirtualDetectorServers",
|
||||||
(void (Detector::*)(int, int)) &
|
(void (Detector::*)(int, uint16_t)) &
|
||||||
Detector::setVirtualDetectorServers,
|
Detector::setVirtualDetectorServers,
|
||||||
py::arg(), py::arg());
|
py::arg(), py::arg());
|
||||||
CppDetectorApi.def("getShmId",
|
CppDetectorApi.def("getShmId",
|
||||||
@ -751,19 +751,19 @@ void init_det(py::module &m) {
|
|||||||
Detector::setDestinationUDPMAC2,
|
Detector::setDestinationUDPMAC2,
|
||||||
py::arg(), py::arg() = Positions{});
|
py::arg(), py::arg() = Positions{});
|
||||||
CppDetectorApi.def("getDestinationUDPPort",
|
CppDetectorApi.def("getDestinationUDPPort",
|
||||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
(Result<uint16_t>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getDestinationUDPPort,
|
Detector::getDestinationUDPPort,
|
||||||
py::arg() = Positions{});
|
py::arg() = Positions{});
|
||||||
CppDetectorApi.def("setDestinationUDPPort",
|
CppDetectorApi.def("setDestinationUDPPort",
|
||||||
(void (Detector::*)(int, int)) &
|
(void (Detector::*)(uint16_t, int)) &
|
||||||
Detector::setDestinationUDPPort,
|
Detector::setDestinationUDPPort,
|
||||||
py::arg(), py::arg() = -1);
|
py::arg(), py::arg() = -1);
|
||||||
CppDetectorApi.def("getDestinationUDPPort2",
|
CppDetectorApi.def("getDestinationUDPPort2",
|
||||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
(Result<uint16_t>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getDestinationUDPPort2,
|
Detector::getDestinationUDPPort2,
|
||||||
py::arg() = Positions{});
|
py::arg() = Positions{});
|
||||||
CppDetectorApi.def("setDestinationUDPPort2",
|
CppDetectorApi.def("setDestinationUDPPort2",
|
||||||
(void (Detector::*)(int, int)) &
|
(void (Detector::*)(uint16_t, int)) &
|
||||||
Detector::setDestinationUDPPort2,
|
Detector::setDestinationUDPPort2,
|
||||||
py::arg(), py::arg() = -1);
|
py::arg(), py::arg() = -1);
|
||||||
CppDetectorApi.def("reconfigureUDPDestination",
|
CppDetectorApi.def("reconfigureUDPDestination",
|
||||||
@ -844,11 +844,11 @@ void init_det(py::module &m) {
|
|||||||
Detector::setRxHostname,
|
Detector::setRxHostname,
|
||||||
py::arg());
|
py::arg());
|
||||||
CppDetectorApi.def("getRxPort",
|
CppDetectorApi.def("getRxPort",
|
||||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
(Result<uint16_t>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getRxPort,
|
Detector::getRxPort,
|
||||||
py::arg() = Positions{});
|
py::arg() = Positions{});
|
||||||
CppDetectorApi.def("setRxPort",
|
CppDetectorApi.def(
|
||||||
(void (Detector::*)(int, int)) & Detector::setRxPort,
|
"setRxPort", (void (Detector::*)(uint16_t, int)) & Detector::setRxPort,
|
||||||
py::arg(), py::arg() = -1);
|
py::arg(), py::arg() = -1);
|
||||||
CppDetectorApi.def("getRxFifoDepth",
|
CppDetectorApi.def("getRxFifoDepth",
|
||||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
(Result<int>(Detector::*)(sls::Positions) const) &
|
||||||
@ -1032,11 +1032,12 @@ void init_det(py::module &m) {
|
|||||||
Detector::setRxZmqStartingFrame,
|
Detector::setRxZmqStartingFrame,
|
||||||
py::arg(), py::arg() = Positions{});
|
py::arg(), py::arg() = Positions{});
|
||||||
CppDetectorApi.def("getRxZmqPort",
|
CppDetectorApi.def("getRxZmqPort",
|
||||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
(Result<uint16_t>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getRxZmqPort,
|
Detector::getRxZmqPort,
|
||||||
py::arg() = Positions{});
|
py::arg() = Positions{});
|
||||||
CppDetectorApi.def("setRxZmqPort",
|
CppDetectorApi.def("setRxZmqPort",
|
||||||
(void (Detector::*)(int, int)) & Detector::setRxZmqPort,
|
(void (Detector::*)(uint16_t, int)) &
|
||||||
|
Detector::setRxZmqPort,
|
||||||
py::arg(), py::arg() = -1);
|
py::arg(), py::arg() = -1);
|
||||||
CppDetectorApi.def(
|
CppDetectorApi.def(
|
||||||
"getRxZmqIP",
|
"getRxZmqIP",
|
||||||
@ -1048,11 +1049,11 @@ void init_det(py::module &m) {
|
|||||||
Detector::setRxZmqIP,
|
Detector::setRxZmqIP,
|
||||||
py::arg(), py::arg() = Positions{});
|
py::arg(), py::arg() = Positions{});
|
||||||
CppDetectorApi.def("getClientZmqPort",
|
CppDetectorApi.def("getClientZmqPort",
|
||||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
(Result<uint16_t>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getClientZmqPort,
|
Detector::getClientZmqPort,
|
||||||
py::arg() = Positions{});
|
py::arg() = Positions{});
|
||||||
CppDetectorApi.def("setClientZmqPort",
|
CppDetectorApi.def("setClientZmqPort",
|
||||||
(void (Detector::*)(int, int)) &
|
(void (Detector::*)(uint16_t, int)) &
|
||||||
Detector::setClientZmqPort,
|
Detector::setClientZmqPort,
|
||||||
py::arg(), py::arg() = -1);
|
py::arg(), py::arg() = -1);
|
||||||
CppDetectorApi.def(
|
CppDetectorApi.def(
|
||||||
@ -1269,6 +1270,16 @@ void init_det(py::module &m) {
|
|||||||
(void (Detector::*)(int, sls::Positions)) &
|
(void (Detector::*)(int, sls::Positions)) &
|
||||||
Detector::setNumberOfFilterCells,
|
Detector::setNumberOfFilterCells,
|
||||||
py::arg(), py::arg() = Positions{});
|
py::arg(), py::arg() = Positions{});
|
||||||
|
CppDetectorApi.def(
|
||||||
|
"getPedestalMode",
|
||||||
|
(Result<defs::pedestalParameters>(Detector::*)(sls::Positions) const) &
|
||||||
|
Detector::getPedestalMode,
|
||||||
|
py::arg() = Positions{});
|
||||||
|
CppDetectorApi.def(
|
||||||
|
"setPedestalMode",
|
||||||
|
(void (Detector::*)(const defs::pedestalParameters, sls::Positions)) &
|
||||||
|
Detector::setPedestalMode,
|
||||||
|
py::arg(), py::arg() = Positions{});
|
||||||
CppDetectorApi.def("getROI",
|
CppDetectorApi.def("getROI",
|
||||||
(Result<defs::ROI>(Detector::*)(sls::Positions) const) &
|
(Result<defs::ROI>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getROI,
|
Detector::getROI,
|
||||||
@ -1524,29 +1535,21 @@ void init_det(py::module &m) {
|
|||||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
(Result<int>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getSYNCClock,
|
Detector::getSYNCClock,
|
||||||
py::arg() = Positions{});
|
py::arg() = Positions{});
|
||||||
CppDetectorApi.def("getADCPipeline",
|
CppDetectorApi.def("getPowerList",
|
||||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
|
||||||
Detector::getADCPipeline,
|
|
||||||
py::arg() = Positions{});
|
|
||||||
CppDetectorApi.def("setADCPipeline",
|
|
||||||
(void (Detector::*)(int, sls::Positions)) &
|
|
||||||
Detector::setADCPipeline,
|
|
||||||
py::arg(), py::arg() = Positions{});
|
|
||||||
CppDetectorApi.def("getVoltageList",
|
|
||||||
(std::vector<defs::dacIndex>(Detector::*)() const) &
|
(std::vector<defs::dacIndex>(Detector::*)() const) &
|
||||||
Detector::getVoltageList);
|
Detector::getPowerList);
|
||||||
CppDetectorApi.def("getSlowADCList",
|
CppDetectorApi.def("getSlowADCList",
|
||||||
(std::vector<defs::dacIndex>(Detector::*)() const) &
|
(std::vector<defs::dacIndex>(Detector::*)() const) &
|
||||||
Detector::getSlowADCList);
|
Detector::getSlowADCList);
|
||||||
CppDetectorApi.def(
|
CppDetectorApi.def(
|
||||||
"getVoltage",
|
"getPower",
|
||||||
(Result<int>(Detector::*)(defs::dacIndex, sls::Positions) const) &
|
(Result<int>(Detector::*)(defs::dacIndex, sls::Positions) const) &
|
||||||
Detector::getVoltage,
|
Detector::getPower,
|
||||||
py::arg(), py::arg() = Positions{});
|
py::arg(), py::arg() = Positions{});
|
||||||
CppDetectorApi.def(
|
CppDetectorApi.def(
|
||||||
"setVoltage",
|
"setPower",
|
||||||
(void (Detector::*)(defs::dacIndex, int, sls::Positions)) &
|
(void (Detector::*)(defs::dacIndex, int, sls::Positions)) &
|
||||||
Detector::setVoltage,
|
Detector::setPower,
|
||||||
py::arg(), py::arg(), py::arg() = Positions{});
|
py::arg(), py::arg(), py::arg() = Positions{});
|
||||||
CppDetectorApi.def("getADCVpp",
|
CppDetectorApi.def("getADCVpp",
|
||||||
(Result<int>(Detector::*)(bool, sls::Positions) const) &
|
(Result<int>(Detector::*)(bool, sls::Positions) const) &
|
||||||
@ -1614,9 +1617,9 @@ void init_det(py::module &m) {
|
|||||||
Detector::setDBITClock,
|
Detector::setDBITClock,
|
||||||
py::arg(), py::arg() = Positions{});
|
py::arg(), py::arg() = Positions{});
|
||||||
CppDetectorApi.def(
|
CppDetectorApi.def(
|
||||||
"getMeasuredVoltage",
|
"getMeasuredPower",
|
||||||
(Result<int>(Detector::*)(defs::dacIndex, sls::Positions) const) &
|
(Result<int>(Detector::*)(defs::dacIndex, sls::Positions) const) &
|
||||||
Detector::getMeasuredVoltage,
|
Detector::getMeasuredPower,
|
||||||
py::arg(), py::arg() = Positions{});
|
py::arg(), py::arg() = Positions{});
|
||||||
CppDetectorApi.def(
|
CppDetectorApi.def(
|
||||||
"getMeasuredCurrent",
|
"getMeasuredCurrent",
|
||||||
@ -1733,26 +1736,26 @@ void init_det(py::module &m) {
|
|||||||
(std::string(Detector::*)(const int) const) &
|
(std::string(Detector::*)(const int) const) &
|
||||||
Detector::getSignalName,
|
Detector::getSignalName,
|
||||||
py::arg());
|
py::arg());
|
||||||
CppDetectorApi.def("setVoltageNames",
|
CppDetectorApi.def("setPowerNames",
|
||||||
(void (Detector::*)(const std::vector<std::string>)) &
|
(void (Detector::*)(const std::vector<std::string>)) &
|
||||||
Detector::setVoltageNames,
|
Detector::setPowerNames,
|
||||||
py::arg());
|
py::arg());
|
||||||
CppDetectorApi.def("getVoltageNames",
|
CppDetectorApi.def("getPowerNames",
|
||||||
(std::vector<std::string>(Detector::*)() const) &
|
(std::vector<std::string>(Detector::*)() const) &
|
||||||
Detector::getVoltageNames);
|
Detector::getPowerNames);
|
||||||
CppDetectorApi.def(
|
CppDetectorApi.def(
|
||||||
"getVoltageIndex",
|
"getPowerIndex",
|
||||||
(defs::dacIndex(Detector::*)(const std::string &) const) &
|
(defs::dacIndex(Detector::*)(const std::string &) const) &
|
||||||
Detector::getVoltageIndex,
|
Detector::getPowerIndex,
|
||||||
py::arg());
|
py::arg());
|
||||||
CppDetectorApi.def(
|
CppDetectorApi.def(
|
||||||
"setVoltageName",
|
"setPowerName",
|
||||||
(void (Detector::*)(const defs::dacIndex, const std::string &)) &
|
(void (Detector::*)(const defs::dacIndex, const std::string &)) &
|
||||||
Detector::setVoltageName,
|
Detector::setPowerName,
|
||||||
py::arg(), py::arg());
|
py::arg(), py::arg());
|
||||||
CppDetectorApi.def("getVoltageName",
|
CppDetectorApi.def("getPowerName",
|
||||||
(std::string(Detector::*)(const defs::dacIndex) const) &
|
(std::string(Detector::*)(const defs::dacIndex) const) &
|
||||||
Detector::getVoltageName,
|
Detector::getPowerName,
|
||||||
py::arg());
|
py::arg());
|
||||||
CppDetectorApi.def("setSlowADCNames",
|
CppDetectorApi.def("setSlowADCNames",
|
||||||
(void (Detector::*)(const std::vector<std::string>)) &
|
(void (Detector::*)(const std::vector<std::string>)) &
|
||||||
@ -1891,6 +1894,14 @@ void init_det(py::module &m) {
|
|||||||
sls::Positions)) &
|
sls::Positions)) &
|
||||||
Detector::setAdditionalJsonParameter,
|
Detector::setAdditionalJsonParameter,
|
||||||
py::arg(), py::arg(), py::arg() = Positions{});
|
py::arg(), py::arg(), py::arg() = Positions{});
|
||||||
|
CppDetectorApi.def("getADCPipeline",
|
||||||
|
(Result<int>(Detector::*)(sls::Positions) const) &
|
||||||
|
Detector::getADCPipeline,
|
||||||
|
py::arg() = Positions{});
|
||||||
|
CppDetectorApi.def("setADCPipeline",
|
||||||
|
(void (Detector::*)(int, sls::Positions)) &
|
||||||
|
Detector::setADCPipeline,
|
||||||
|
py::arg(), py::arg() = Positions{});
|
||||||
CppDetectorApi.def(
|
CppDetectorApi.def(
|
||||||
"programFPGA",
|
"programFPGA",
|
||||||
(void (Detector::*)(const std::string &, const bool, sls::Positions)) &
|
(void (Detector::*)(const std::string &, const bool, sls::Positions)) &
|
||||||
@ -1978,19 +1989,19 @@ void init_det(py::module &m) {
|
|||||||
Detector::setADCInvert,
|
Detector::setADCInvert,
|
||||||
py::arg(), py::arg() = Positions{});
|
py::arg(), py::arg() = Positions{});
|
||||||
CppDetectorApi.def("getControlPort",
|
CppDetectorApi.def("getControlPort",
|
||||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
(Result<uint16_t>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getControlPort,
|
Detector::getControlPort,
|
||||||
py::arg() = Positions{});
|
py::arg() = Positions{});
|
||||||
CppDetectorApi.def("setControlPort",
|
CppDetectorApi.def("setControlPort",
|
||||||
(void (Detector::*)(int, sls::Positions)) &
|
(void (Detector::*)(uint16_t, sls::Positions)) &
|
||||||
Detector::setControlPort,
|
Detector::setControlPort,
|
||||||
py::arg(), py::arg() = Positions{});
|
py::arg(), py::arg() = Positions{});
|
||||||
CppDetectorApi.def("getStopPort",
|
CppDetectorApi.def("getStopPort",
|
||||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
(Result<uint16_t>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getStopPort,
|
Detector::getStopPort,
|
||||||
py::arg() = Positions{});
|
py::arg() = Positions{});
|
||||||
CppDetectorApi.def("setStopPort",
|
CppDetectorApi.def("setStopPort",
|
||||||
(void (Detector::*)(int, sls::Positions)) &
|
(void (Detector::*)(uint16_t, sls::Positions)) &
|
||||||
Detector::setStopPort,
|
Detector::setStopPort,
|
||||||
py::arg(), py::arg() = Positions{});
|
py::arg(), py::arg() = Positions{});
|
||||||
CppDetectorApi.def("getDetectorLock",
|
CppDetectorApi.def("getDetectorLock",
|
||||||
|
@ -19,6 +19,8 @@ void init_pattern(py::module &);
|
|||||||
void init_scan(py::module &);
|
void init_scan(py::module &);
|
||||||
void init_source(py::module &);
|
void init_source(py::module &);
|
||||||
void init_duration(py::module &);
|
void init_duration(py::module &);
|
||||||
|
void init_pedestal(py::module &);
|
||||||
|
|
||||||
PYBIND11_MODULE(_slsdet, m) {
|
PYBIND11_MODULE(_slsdet, m) {
|
||||||
m.doc() = R"pbdoc(
|
m.doc() = R"pbdoc(
|
||||||
C/C++ API
|
C/C++ API
|
||||||
@ -37,6 +39,7 @@ PYBIND11_MODULE(_slsdet, m) {
|
|||||||
init_scan(m);
|
init_scan(m);
|
||||||
init_source(m);
|
init_source(m);
|
||||||
init_duration(m);
|
init_duration(m);
|
||||||
|
init_pedestal(m);
|
||||||
// init_experimental(m);
|
// init_experimental(m);
|
||||||
|
|
||||||
py::module io = m.def_submodule("io", "Submodule for io");
|
py::module io = m.def_submodule("io", "Submodule for io");
|
||||||
|
23
python/src/pedestal.cpp
Normal file
23
python/src/pedestal.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
|
|
||||||
|
#include "py_headers.h"
|
||||||
|
|
||||||
|
#include "sls/ToString.h"
|
||||||
|
#include "sls/sls_detector_defs.h"
|
||||||
|
|
||||||
|
namespace py = pybind11;
|
||||||
|
void init_pedestal(py::module &m) {
|
||||||
|
|
||||||
|
using src = slsDetectorDefs::pedestalParameters;
|
||||||
|
py::class_<src> pedestalParameters(m, "pedestalParameters");
|
||||||
|
|
||||||
|
pedestalParameters.def(py::init());
|
||||||
|
pedestalParameters.def_readwrite("enable", &src::enable);
|
||||||
|
pedestalParameters.def_readwrite("frames", &src::frames);
|
||||||
|
pedestalParameters.def_readwrite("loops", &src::loops);
|
||||||
|
pedestalParameters.def(pybind11::self == pybind11::self);
|
||||||
|
|
||||||
|
pedestalParameters.def("__repr__",
|
||||||
|
[](const src &a) { return sls::ToString(a); });
|
||||||
|
}
|
@ -193,6 +193,7 @@ void qDrawPlot::SetupPlots() {
|
|||||||
gainplot2d = new SlsQt2DPlot(boxPlot, true);
|
gainplot2d = new SlsQt2DPlot(boxPlot, true);
|
||||||
gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5,
|
gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5,
|
||||||
nPixelsY - 0.5, gainData);
|
nPixelsY - 0.5, gainData);
|
||||||
|
gainplot2d->Update();
|
||||||
gainplot2d->hide();
|
gainplot2d->hide();
|
||||||
connect(plot2d, SIGNAL(PlotZoomedSignal(const QRectF &)), this,
|
connect(plot2d, SIGNAL(PlotZoomedSignal(const QRectF &)), this,
|
||||||
SLOT(Zoom2DGainPlot(const QRectF &)));
|
SLOT(Zoom2DGainPlot(const QRectF &)));
|
||||||
@ -1009,6 +1010,7 @@ void qDrawPlot::Update2dPlot() {
|
|||||||
if (isGainDataExtracted) {
|
if (isGainDataExtracted) {
|
||||||
gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5,
|
gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5,
|
||||||
nPixelsY - 0.5, gainData);
|
nPixelsY - 0.5, gainData);
|
||||||
|
gainplot2d->Update();
|
||||||
if (!gainplot2d->isVisible()) {
|
if (!gainplot2d->isVisible()) {
|
||||||
gainplot2d->setFixedWidth(plot2d->width() /
|
gainplot2d->setFixedWidth(plot2d->width() /
|
||||||
qDefs::DATA_GAIN_PLOT_RATIO);
|
qDefs::DATA_GAIN_PLOT_RATIO);
|
||||||
|
@ -803,8 +803,9 @@ void qTabMeasurement::GetNextFrameNumber() {
|
|||||||
"Inconsistent starting frame number for all detectors.");
|
"Inconsistent starting frame number for all detectors.");
|
||||||
spinNextFrameNumber->setValue(retval);
|
spinNextFrameNumber->setValue(retval);
|
||||||
}
|
}
|
||||||
CATCH_DISPLAY("Could not get starting frame number.",
|
CATCH_HANDLE("Could not get starting frame number.",
|
||||||
"qTabMeasurement::GetNextFrameNumber")
|
"qTabMeasurement::GetNextFrameNumber", spinNextFrameNumber,
|
||||||
|
&QSpinBox::setValue, -1)
|
||||||
connect(spinNextFrameNumber, SIGNAL(valueChanged(int)), this,
|
connect(spinNextFrameNumber, SIGNAL(valueChanged(int)), this,
|
||||||
SLOT(SetNextFrameNumber(int)));
|
SLOT(SetNextFrameNumber(int)));
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -1789,8 +1789,8 @@ int configureMAC() {
|
|||||||
uint32_t dstip = udpDetails[0].dstip;
|
uint32_t dstip = udpDetails[0].dstip;
|
||||||
uint64_t srcmac = udpDetails[0].srcmac;
|
uint64_t srcmac = udpDetails[0].srcmac;
|
||||||
uint64_t dstmac = udpDetails[0].dstmac;
|
uint64_t dstmac = udpDetails[0].dstmac;
|
||||||
int srcport = udpDetails[0].srcport;
|
uint16_t srcport = udpDetails[0].srcport;
|
||||||
int dstport = udpDetails[0].dstport;
|
uint16_t dstport = udpDetails[0].dstport;
|
||||||
|
|
||||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||||
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
|
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
|
||||||
@ -1802,10 +1802,10 @@ int configureMAC() {
|
|||||||
|
|
||||||
LOG(logINFO, ("\tSource IP : %s\n"
|
LOG(logINFO, ("\tSource IP : %s\n"
|
||||||
"\tSource MAC : %s\n"
|
"\tSource MAC : %s\n"
|
||||||
"\tSource Port : %d\n"
|
"\tSource Port : %hu\n"
|
||||||
"\tDest IP : %s\n"
|
"\tDest IP : %s\n"
|
||||||
"\tDest MAC : %s\n"
|
"\tDest MAC : %s\n"
|
||||||
"\tDest Port : %d\n",
|
"\tDest Port : %hu\n",
|
||||||
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
|
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
|
||||||
|
|
||||||
// 1 giga udp
|
// 1 giga udp
|
||||||
|
Binary file not shown.
@ -1808,9 +1808,9 @@ int configureMAC() {
|
|||||||
uint32_t dstip = udpDetails[iRxEntry].dstip;
|
uint32_t dstip = udpDetails[iRxEntry].dstip;
|
||||||
uint64_t srcmac = udpDetails[iRxEntry].srcmac;
|
uint64_t srcmac = udpDetails[iRxEntry].srcmac;
|
||||||
uint64_t dstmac = udpDetails[iRxEntry].dstmac;
|
uint64_t dstmac = udpDetails[iRxEntry].dstmac;
|
||||||
int srcport = udpDetails[iRxEntry].srcport;
|
uint16_t srcport = udpDetails[iRxEntry].srcport;
|
||||||
int dstport = udpDetails[iRxEntry].dstport;
|
uint16_t dstport = udpDetails[iRxEntry].dstport;
|
||||||
int dstport2 = udpDetails[iRxEntry].dstport2;
|
uint16_t dstport2 = udpDetails[iRxEntry].dstport2;
|
||||||
|
|
||||||
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
|
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
|
||||||
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
|
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
|
||||||
@ -1824,11 +1824,11 @@ int configureMAC() {
|
|||||||
LOG(logINFO,
|
LOG(logINFO,
|
||||||
("\tSource IP : %s\n"
|
("\tSource IP : %s\n"
|
||||||
"\tSource MAC : %s\n"
|
"\tSource MAC : %s\n"
|
||||||
"\tSource Port : %d\n"
|
"\tSource Port : %hu\n"
|
||||||
"\tDest IP : %s\n"
|
"\tDest IP : %s\n"
|
||||||
"\tDest MAC : %s\n"
|
"\tDest MAC : %s\n"
|
||||||
"\tDest Port : %d\n"
|
"\tDest Port : %hu\n"
|
||||||
"\tDest Port2 : %d\n",
|
"\tDest Port2 : %hu\n",
|
||||||
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport, dstport2));
|
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport, dstport2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#define HARDWARE_VERSION_NAMES \
|
#define HARDWARE_VERSION_NAMES \
|
||||||
{ "FX70T", "FX30T" }
|
{ "FX70T", "FX30T" }
|
||||||
|
|
||||||
#define REQUIRED_FIRMWARE_VERSION (31)
|
#define REQUIRED_FIRMWARE_VERSION (32)
|
||||||
// virtual ones renamed for consistency
|
// virtual ones renamed for consistency
|
||||||
// real ones keep previous name for compatibility (already in production)
|
// real ones keep previous name for compatibility (already in production)
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
|
Binary file not shown.
@ -1902,8 +1902,8 @@ void setFirstUDPDestination(int value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setupHeader(int iRxEntry, int vetoInterface, uint32_t destip,
|
void setupHeader(int iRxEntry, int vetoInterface, uint32_t destip,
|
||||||
uint64_t destmac, uint32_t destport, uint64_t sourcemac,
|
uint64_t destmac, uint16_t destport, uint64_t sourcemac,
|
||||||
uint32_t sourceip, uint32_t sourceport) {
|
uint32_t sourceip, uint16_t sourceport) {
|
||||||
|
|
||||||
// start addr
|
// start addr
|
||||||
uint32_t addr = BASE_UDP_RAM;
|
uint32_t addr = BASE_UDP_RAM;
|
||||||
@ -1995,10 +1995,10 @@ int configureMAC() {
|
|||||||
uint64_t srcmac2 = udpDetails[iRxEntry].srcmac2;
|
uint64_t srcmac2 = udpDetails[iRxEntry].srcmac2;
|
||||||
uint64_t dstmac = udpDetails[iRxEntry].dstmac;
|
uint64_t dstmac = udpDetails[iRxEntry].dstmac;
|
||||||
uint64_t dstmac2 = udpDetails[iRxEntry].dstmac2;
|
uint64_t dstmac2 = udpDetails[iRxEntry].dstmac2;
|
||||||
int srcport = udpDetails[iRxEntry].srcport;
|
uint16_t srcport = udpDetails[iRxEntry].srcport;
|
||||||
int srcport2 = udpDetails[iRxEntry].srcport2;
|
uint16_t srcport2 = udpDetails[iRxEntry].srcport2;
|
||||||
int dstport = udpDetails[iRxEntry].dstport;
|
uint16_t dstport = udpDetails[iRxEntry].dstport;
|
||||||
int dstport2 = udpDetails[iRxEntry].dstport2;
|
uint16_t dstport2 = udpDetails[iRxEntry].dstport2;
|
||||||
|
|
||||||
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
|
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
|
||||||
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
|
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
|
||||||
@ -2020,10 +2020,10 @@ int configureMAC() {
|
|||||||
LOG(logINFO, ("\tData Interface \n"));
|
LOG(logINFO, ("\tData Interface \n"));
|
||||||
LOG(logINFO, ("\tSource IP : %s\n"
|
LOG(logINFO, ("\tSource IP : %s\n"
|
||||||
"\tSource MAC : %s\n"
|
"\tSource MAC : %s\n"
|
||||||
"\tSource Port : %d\n"
|
"\tSource Port : %hu\n"
|
||||||
"\tDest IP : %s\n"
|
"\tDest IP : %s\n"
|
||||||
"\tDest MAC : %s\n"
|
"\tDest MAC : %s\n"
|
||||||
"\tDest Port : %d\n\n",
|
"\tDest Port : %hu\n\n",
|
||||||
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
|
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
|
||||||
|
|
||||||
if (getVetoStream()) {
|
if (getVetoStream()) {
|
||||||
@ -2039,10 +2039,10 @@ int configureMAC() {
|
|||||||
LOG(logINFO,
|
LOG(logINFO,
|
||||||
("\tSource IP2 : %s\n"
|
("\tSource IP2 : %s\n"
|
||||||
"\tSource MAC2 : %s\n"
|
"\tSource MAC2 : %s\n"
|
||||||
"\tSource Port2: %d\n"
|
"\tSource Port2: %hu\n"
|
||||||
"\tDest IP2 : %s\n"
|
"\tDest IP2 : %s\n"
|
||||||
"\tDest MAC2 : %s\n"
|
"\tDest MAC2 : %s\n"
|
||||||
"\tDest Port2 : %d\n\n",
|
"\tDest Port2 : %hu\n\n",
|
||||||
src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2));
|
src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2));
|
||||||
}
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
@ -3323,6 +3323,27 @@ void *start_timer(void *arg) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// change gain and data for every frame
|
||||||
|
{
|
||||||
|
const int nchannels = NCHIP * NCHAN;
|
||||||
|
int gainVal = 0;
|
||||||
|
for (int i = 0; i < nchannels; ++i) {
|
||||||
|
if ((i % nchannels) < 400) {
|
||||||
|
gainVal = 1 + frameNr;
|
||||||
|
} else if ((i % nchannels) < 800) {
|
||||||
|
gainVal = 2 + frameNr;
|
||||||
|
} else {
|
||||||
|
gainVal = 3 + frameNr;
|
||||||
|
}
|
||||||
|
int dataVal =
|
||||||
|
*((uint16_t *)(imageData + i * sizeof(uint16_t)));
|
||||||
|
dataVal += frameNr;
|
||||||
|
int channelVal =
|
||||||
|
(dataVal & ~GAIN_VAL_MSK) | (gainVal << GAIN_VAL_OFST);
|
||||||
|
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
|
||||||
|
(uint16_t)channelVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
// sleep for exposure time
|
// sleep for exposure time
|
||||||
struct timespec begin, end;
|
struct timespec begin, end;
|
||||||
clock_gettime(CLOCK_REALTIME, &begin);
|
clock_gettime(CLOCK_REALTIME, &begin);
|
||||||
|
Binary file not shown.
@ -1425,8 +1425,8 @@ int configureMAC() {
|
|||||||
uint32_t dstip = udpDetails[0].dstip;
|
uint32_t dstip = udpDetails[0].dstip;
|
||||||
uint64_t srcmac = udpDetails[0].srcmac;
|
uint64_t srcmac = udpDetails[0].srcmac;
|
||||||
uint64_t dstmac = udpDetails[0].dstmac;
|
uint64_t dstmac = udpDetails[0].dstmac;
|
||||||
int srcport = udpDetails[0].srcport;
|
uint16_t srcport = udpDetails[0].srcport;
|
||||||
int dstport = udpDetails[0].dstport;
|
uint16_t dstport = udpDetails[0].dstport;
|
||||||
|
|
||||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||||
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
|
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
|
||||||
@ -1438,10 +1438,10 @@ int configureMAC() {
|
|||||||
|
|
||||||
LOG(logINFO, ("\tSource IP : %s\n"
|
LOG(logINFO, ("\tSource IP : %s\n"
|
||||||
"\tSource MAC : %s\n"
|
"\tSource MAC : %s\n"
|
||||||
"\tSource Port : %d\n"
|
"\tSource Port : %hu\n"
|
||||||
"\tDest IP : %s\n"
|
"\tDest IP : %s\n"
|
||||||
"\tDest MAC : %s\n"
|
"\tDest MAC : %s\n"
|
||||||
"\tDest Port : %d\n",
|
"\tDest Port : %hu\n",
|
||||||
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
|
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
|
||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
|
@ -24,16 +24,18 @@
|
|||||||
|
|
||||||
#define RUN_BUSY_OFST (0)
|
#define RUN_BUSY_OFST (0)
|
||||||
#define RUN_BUSY_MSK (0x00000001 << RUN_BUSY_OFST)
|
#define RUN_BUSY_MSK (0x00000001 << RUN_BUSY_OFST)
|
||||||
#define WAITING_FOR_TRIGGER_OFST (3)
|
#define WAITING_FOR_TRIGGER_OFST (1)
|
||||||
#define WAITING_FOR_TRIGGER_MSK (0x00000001 << WAITING_FOR_TRIGGER_OFST)
|
#define WAITING_FOR_TRIGGER_MSK (0x00000001 << WAITING_FOR_TRIGGER_OFST)
|
||||||
#define DELAYBEFORE_OFST (4) // Not used in software
|
#define WAITING_FOR_START_FRAME_OFST (2)
|
||||||
#define DELAYBEFORE_MSK (0x00000001 << DELAYBEFORE_OFST) // Not used in software
|
#define WAITING_FOR_START_FRAME_MSK (0x00000001 << WAITING_FOR_START_FRAME_OFST)
|
||||||
#define DELAYAFTER_OFST (5) // Not used in software
|
#define ACQUIRING_FRAME_OFST (3) // Not used in software
|
||||||
#define DELAYAFTER_MSK (0x00000001 << DELAYAFTER_OFST) // Not used in software
|
#define ACQUIRING_FRAME_MSK (0x00000001 << ACQUIRING_FRAME_OFST)
|
||||||
#define STOPPED_OFST (15)
|
#define WAITING_FOR_PERIOD_TO_ELAPSE_OFST (4) // Not used in software
|
||||||
|
#define WAITING_FOR_PERIOD_TO_ELAPSE_MSK (0x00000001 << WAITING_FOR_PERIOD_TO_ELAPSE_OFST)
|
||||||
|
#define STOPPED_OFST (8)
|
||||||
#define STOPPED_MSK (0x00000001 << STOPPED_OFST)
|
#define STOPPED_MSK (0x00000001 << STOPPED_OFST)
|
||||||
#define RUNMACHINE_BUSY_OFST (17)
|
#define INTERNAL_STOP_OFST (9)
|
||||||
#define RUNMACHINE_BUSY_MSK (0x00000001 << RUNMACHINE_BUSY_OFST)
|
#define INTERNAL_STOP_MSK (0x00000001 << INTERNAL_STOP_OFST)
|
||||||
|
|
||||||
/* Look at me register */
|
/* Look at me register */
|
||||||
#define LOOK_AT_ME_REG (0x03 << MEM_MAP_SHIFT) // Not used in firmware or software
|
#define LOOK_AT_ME_REG (0x03 << MEM_MAP_SHIFT) // Not used in firmware or software
|
||||||
@ -255,6 +257,17 @@
|
|||||||
#define PLL_CNTRL_ADDR_OFST (16)
|
#define PLL_CNTRL_ADDR_OFST (16)
|
||||||
#define PLL_CNTRL_ADDR_MSK (0x0000003F << PLL_CNTRL_ADDR_OFST)
|
#define PLL_CNTRL_ADDR_MSK (0x0000003F << PLL_CNTRL_ADDR_OFST)
|
||||||
|
|
||||||
|
|
||||||
|
/* Pedestal Mode Regiser */
|
||||||
|
#define PEDESTAL_MODE_REG (0x57 << MEM_MAP_SHIFT)
|
||||||
|
|
||||||
|
#define PEDESTAL_MODE_ITRTNS_OFST (0)
|
||||||
|
#define PEDESTAL_MODE_ITRTNS_MSK (0x0000FFFF << PEDESTAL_MODE_ITRTNS_OFST)
|
||||||
|
#define PEDESTAL_MODE_LNGTH_OFST (16)
|
||||||
|
#define PEDESTAL_MODE_LNGTH_MSK (0x000000FF << PEDESTAL_MODE_LNGTH_OFST)
|
||||||
|
#define PEDESTAL_MODE_ENBLE_OFST (31)
|
||||||
|
#define PEDESTAL_MODE_ENBLE_MSK (0x00000001 << PEDESTAL_MODE_ENBLE_OFST)
|
||||||
|
|
||||||
/* Config Register for chip 1.1 */
|
/* Config Register for chip 1.1 */
|
||||||
#define CONFIG_V11_REG (0x58 << MEM_MAP_SHIFT)
|
#define CONFIG_V11_REG (0x58 << MEM_MAP_SHIFT)
|
||||||
|
|
||||||
|
Binary file not shown.
@ -55,6 +55,9 @@ int32_t clkPhase[NUM_CLOCKS] = {};
|
|||||||
int detPos[4] = {};
|
int detPos[4] = {};
|
||||||
int chipConfigured = 0;
|
int chipConfigured = 0;
|
||||||
|
|
||||||
|
uint64_t normal_mode_frames = -1;
|
||||||
|
uint64_t normal_mode_triggers = -1;
|
||||||
|
|
||||||
int isInitCheckDone() { return initCheckDone; }
|
int isInitCheckDone() { return initCheckDone; }
|
||||||
|
|
||||||
int getInitResult(char **mess) {
|
int getInitResult(char **mess) {
|
||||||
@ -555,6 +558,13 @@ void setupDetector() {
|
|||||||
setFlipRows(DEFAULT_FLIP_ROWS);
|
setFlipRows(DEFAULT_FLIP_ROWS);
|
||||||
setReadNRows(MAX_ROWS_PER_READOUT);
|
setReadNRows(MAX_ROWS_PER_READOUT);
|
||||||
}
|
}
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
// setting pedestalmode depends on previous values
|
||||||
|
bus_w(PEDESTAL_MODE_REG,
|
||||||
|
bus_r(PEDESTAL_MODE_REG) & ~PEDESTAL_MODE_ENBLE_MSK);
|
||||||
|
#endif
|
||||||
|
setPedestalMode(DEFAULT_PEDESTAL_MODE, DEFAULT_PEDESTAL_FRAMES,
|
||||||
|
DEFAULT_PEDESTAL_LOOPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int resetToDefaultDacs(int hardReset) {
|
int resetToDefaultDacs(int hardReset) {
|
||||||
@ -975,6 +985,9 @@ int getNextFrameNumber(uint64_t *retval) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setNumFrames(int64_t val) {
|
void setNumFrames(int64_t val) {
|
||||||
|
if (getPedestalMode()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (val > 0) {
|
if (val > 0) {
|
||||||
LOG(logINFO, ("Setting number of frames %lld\n", (long long int)val));
|
LOG(logINFO, ("Setting number of frames %lld\n", (long long int)val));
|
||||||
set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
||||||
@ -986,6 +999,9 @@ int64_t getNumFrames() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setNumTriggers(int64_t val) {
|
void setNumTriggers(int64_t val) {
|
||||||
|
if (getPedestalMode()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (val > 0) {
|
if (val > 0) {
|
||||||
LOG(logINFO, ("Setting number of triggers %lld\n", (long long int)val));
|
LOG(logINFO, ("Setting number of triggers %lld\n", (long long int)val));
|
||||||
set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
||||||
@ -1439,6 +1455,9 @@ void setSynchronization(int enable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setTiming(enum timingMode arg) {
|
void setTiming(enum timingMode arg) {
|
||||||
|
if (getPedestalMode()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case AUTO_TIMING:
|
case AUTO_TIMING:
|
||||||
LOG(logINFO, ("Set Timing: Auto\n"));
|
LOG(logINFO, ("Set Timing: Auto\n"));
|
||||||
@ -1532,8 +1551,8 @@ int getPrimaryInterface() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip,
|
void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip,
|
||||||
uint64_t destmac, uint32_t destport, uint64_t sourcemac,
|
uint64_t destmac, uint16_t destport, uint64_t sourcemac,
|
||||||
uint32_t sourceip, uint32_t sourceport) {
|
uint32_t sourceip, uint16_t sourceport) {
|
||||||
|
|
||||||
// start addr
|
// start addr
|
||||||
uint32_t addr = (type == INNER ? RXR_ENDPOINT_INNER_START_REG
|
uint32_t addr = (type == INNER ? RXR_ENDPOINT_INNER_START_REG
|
||||||
@ -1628,10 +1647,10 @@ int configureMAC() {
|
|||||||
uint64_t srcmac2 = udpDetails[iRxEntry].srcmac2;
|
uint64_t srcmac2 = udpDetails[iRxEntry].srcmac2;
|
||||||
uint64_t dstmac = udpDetails[iRxEntry].dstmac;
|
uint64_t dstmac = udpDetails[iRxEntry].dstmac;
|
||||||
uint64_t dstmac2 = udpDetails[iRxEntry].dstmac2;
|
uint64_t dstmac2 = udpDetails[iRxEntry].dstmac2;
|
||||||
int srcport = udpDetails[iRxEntry].srcport;
|
uint16_t srcport = udpDetails[iRxEntry].srcport;
|
||||||
int srcport2 = udpDetails[iRxEntry].srcport2;
|
uint16_t srcport2 = udpDetails[iRxEntry].srcport2;
|
||||||
int dstport = udpDetails[iRxEntry].dstport;
|
uint16_t dstport = udpDetails[iRxEntry].dstport;
|
||||||
int dstport2 = udpDetails[iRxEntry].dstport2;
|
uint16_t dstport2 = udpDetails[iRxEntry].dstport2;
|
||||||
|
|
||||||
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
|
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
|
||||||
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
|
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
|
||||||
@ -1655,10 +1674,10 @@ int configureMAC() {
|
|||||||
: (selInterface ? "Not Used" : "Used")));
|
: (selInterface ? "Not Used" : "Used")));
|
||||||
LOG(logINFO, ("\tSource IP : %s\n"
|
LOG(logINFO, ("\tSource IP : %s\n"
|
||||||
"\tSource MAC : %s\n"
|
"\tSource MAC : %s\n"
|
||||||
"\tSource Port : %d\n"
|
"\tSource Port : %hu\n"
|
||||||
"\tDest IP : %s\n"
|
"\tDest IP : %s\n"
|
||||||
"\tDest MAC : %s\n"
|
"\tDest MAC : %s\n"
|
||||||
"\tDest Port : %d\n\n",
|
"\tDest Port : %hu\n\n",
|
||||||
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
|
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
|
||||||
|
|
||||||
LOG(logINFO,
|
LOG(logINFO,
|
||||||
@ -1668,10 +1687,10 @@ int configureMAC() {
|
|||||||
LOG(logINFO,
|
LOG(logINFO,
|
||||||
("\tSource IP2 : %s\n"
|
("\tSource IP2 : %s\n"
|
||||||
"\tSource MAC2 : %s\n"
|
"\tSource MAC2 : %s\n"
|
||||||
"\tSource Port2: %d\n"
|
"\tSource Port2: %hu\n"
|
||||||
"\tDest IP2 : %s\n"
|
"\tDest IP2 : %s\n"
|
||||||
"\tDest MAC2 : %s\n"
|
"\tDest MAC2 : %s\n"
|
||||||
"\tDest Port2 : %d\n\n",
|
"\tDest Port2 : %hu\n\n",
|
||||||
src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2));
|
src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2));
|
||||||
}
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
@ -2513,6 +2532,82 @@ uint64_t getSelectCurrentSource() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getPedestalMode() {
|
||||||
|
return ((bus_r(PEDESTAL_MODE_REG) & PEDESTAL_MODE_ENBLE_MSK) >>
|
||||||
|
PEDESTAL_MODE_ENBLE_OFST);
|
||||||
|
}
|
||||||
|
|
||||||
|
void getPedestalParameters(uint8_t *frames, uint16_t *loops) {
|
||||||
|
uint32_t addr = PEDESTAL_MODE_REG;
|
||||||
|
*frames =
|
||||||
|
((bus_r(addr) & PEDESTAL_MODE_LNGTH_MSK) >> PEDESTAL_MODE_LNGTH_OFST);
|
||||||
|
*loops = ((bus_r(PEDESTAL_MODE_REG) & PEDESTAL_MODE_ITRTNS_MSK) >>
|
||||||
|
PEDESTAL_MODE_ITRTNS_OFST);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPedestalMode(int enable, uint8_t frames, uint16_t loops) {
|
||||||
|
int prevPedestalEnable = getPedestalMode();
|
||||||
|
uint32_t addr = PEDESTAL_MODE_REG;
|
||||||
|
|
||||||
|
if (enable) {
|
||||||
|
LOG(logINFOBLUE, ("Enabling pedestal mode [frames: %hhu, loops: %hu]\n",
|
||||||
|
frames, loops));
|
||||||
|
|
||||||
|
// frames
|
||||||
|
bus_w(addr, bus_r(addr) & ~PEDESTAL_MODE_LNGTH_MSK);
|
||||||
|
bus_w(addr, bus_r(addr) | ((frames << PEDESTAL_MODE_LNGTH_OFST) &
|
||||||
|
PEDESTAL_MODE_LNGTH_MSK));
|
||||||
|
// loops
|
||||||
|
bus_w(addr, bus_r(addr) & ~PEDESTAL_MODE_ITRTNS_MSK);
|
||||||
|
bus_w(addr, bus_r(addr) | ((loops << PEDESTAL_MODE_ITRTNS_OFST) &
|
||||||
|
PEDESTAL_MODE_ITRTNS_MSK));
|
||||||
|
// enable
|
||||||
|
bus_w(addr, bus_r(addr) | PEDESTAL_MODE_ENBLE_MSK);
|
||||||
|
|
||||||
|
// if it was switched off before, remember the #frames and #triggers
|
||||||
|
if (prevPedestalEnable == 0) {
|
||||||
|
normal_mode_frames = getNumFrames();
|
||||||
|
normal_mode_triggers = getNumTriggers();
|
||||||
|
LOG(logINFO, ("\tRemembering Normal mode #frames and "
|
||||||
|
"#triggers[%lld, %lld]\n",
|
||||||
|
normal_mode_frames, normal_mode_triggers));
|
||||||
|
}
|
||||||
|
|
||||||
|
// overwrite #frames and #triggers to new values
|
||||||
|
int64_t expFrames = -1;
|
||||||
|
int64_t expTriggers = -1;
|
||||||
|
enum timingMode timing = getTiming();
|
||||||
|
if (timing == AUTO_TIMING ||
|
||||||
|
(timing == TRIGGER_EXPOSURE && normal_mode_frames > 1)) {
|
||||||
|
expFrames = frames * loops * 2;
|
||||||
|
expTriggers = 1;
|
||||||
|
} else {
|
||||||
|
expFrames = 1;
|
||||||
|
expTriggers = frames * loops * 2;
|
||||||
|
}
|
||||||
|
LOG(logINFO, ("\tOverwriting [#frames: %lld, #triggers: %lld]\n",
|
||||||
|
expFrames, expTriggers));
|
||||||
|
set64BitReg(expFrames, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
||||||
|
set64BitReg(expTriggers, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
LOG(logINFOBLUE, ("Disabling pedestal mode\n"));
|
||||||
|
bus_w(addr, bus_r(addr) & ~PEDESTAL_MODE_ENBLE_MSK);
|
||||||
|
|
||||||
|
// if it was switched on before, reset the normal mode #frames and
|
||||||
|
// #triggers
|
||||||
|
if (prevPedestalEnable == 1) {
|
||||||
|
LOG(logINFO,
|
||||||
|
("\tResetting to Normal mode [#frames:%lld, #triggers:%lld\n",
|
||||||
|
normal_mode_frames, normal_mode_triggers));
|
||||||
|
set64BitReg(normal_mode_frames, SET_FRAMES_LSB_REG,
|
||||||
|
SET_FRAMES_MSB_REG);
|
||||||
|
set64BitReg(normal_mode_triggers, SET_CYCLES_LSB_REG,
|
||||||
|
SET_CYCLES_MSB_REG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int getTenGigaFlowControl() {
|
int getTenGigaFlowControl() {
|
||||||
return ((bus_r(CONFIG_REG) & CONFIG_ETHRNT_FLW_CNTRL_MSK) >>
|
return ((bus_r(CONFIG_REG) & CONFIG_ETHRNT_FLW_CNTRL_MSK) >>
|
||||||
CONFIG_ETHRNT_FLW_CNTRL_OFST);
|
CONFIG_ETHRNT_FLW_CNTRL_OFST);
|
||||||
@ -2632,6 +2727,7 @@ void *start_timer(void *arg) {
|
|||||||
if (i % pixelsPerPacket == 0) {
|
if (i % pixelsPerPacket == 0) {
|
||||||
++dataVal;
|
++dataVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((i % 1024) < 300) {
|
if ((i % 1024) < 300) {
|
||||||
gainVal = 1;
|
gainVal = 1;
|
||||||
} else if ((i % 1024) < 600) {
|
} else if ((i % 1024) < 600) {
|
||||||
@ -2672,6 +2768,28 @@ void *start_timer(void *arg) {
|
|||||||
clock_gettime(CLOCK_REALTIME, &begin);
|
clock_gettime(CLOCK_REALTIME, &begin);
|
||||||
usleep(expUs);
|
usleep(expUs);
|
||||||
|
|
||||||
|
// change gain and data for every frame
|
||||||
|
{
|
||||||
|
const int npixels = (NCHAN * NCHIP);
|
||||||
|
for (int i = 0; i < npixels; ++i) {
|
||||||
|
int gainVal = 0;
|
||||||
|
if ((i % 1024) < 300) {
|
||||||
|
gainVal = 1 + iframes;
|
||||||
|
} else if ((i % 1024) < 600) {
|
||||||
|
gainVal = 2 + iframes;
|
||||||
|
} else {
|
||||||
|
gainVal = 3 + iframes;
|
||||||
|
}
|
||||||
|
int dataVal =
|
||||||
|
*((uint16_t *)(imageData + i * sizeof(uint16_t)));
|
||||||
|
dataVal += iframes;
|
||||||
|
int pixelVal =
|
||||||
|
(dataVal & ~GAIN_VAL_MSK) | (gainVal << GAIN_VAL_OFST);
|
||||||
|
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
|
||||||
|
(uint16_t)pixelVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int srcOffset = 0;
|
int srcOffset = 0;
|
||||||
int srcOffset2 = DATA_BYTES / 2;
|
int srcOffset2 = DATA_BYTES / 2;
|
||||||
int row0 = (numInterfaces == 1 ? detPos[1] : detPos[3]);
|
int row0 = (numInterfaces == 1 ? detPos[1] : detPos[3]);
|
||||||
@ -2806,14 +2924,17 @@ int softwareTrigger(int block) {
|
|||||||
LOG(logINFO, ("Sending Software Trigger\n"));
|
LOG(logINFO, ("Sending Software Trigger\n"));
|
||||||
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_SOFTWARE_TRIGGER_MSK);
|
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_SOFTWARE_TRIGGER_MSK);
|
||||||
bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_SOFTWARE_TRIGGER_MSK);
|
bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_SOFTWARE_TRIGGER_MSK);
|
||||||
|
// wait to make sure its out of this state and even 'wait for start frame'
|
||||||
|
usleep(100);
|
||||||
|
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
// block till frame is sent out
|
// block till frame sent out & back to wait for trigger (or not busy
|
||||||
|
// anymore)
|
||||||
if (block) {
|
if (block) {
|
||||||
enum runStatus s = getRunStatus();
|
uint32_t retval = bus_r(STATUS_REG);
|
||||||
while (s == RUNNING || s == TRANSMITTING) {
|
while ((retval & RUN_BUSY_MSK) && !(retval & WAITING_FOR_TRIGGER_MSK)) {
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
s = getRunStatus();
|
retval = bus_r(STATUS_REG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG(logINFO, ("Ready for Next Trigger...\n"));
|
LOG(logINFO, ("Ready for Next Trigger...\n"));
|
||||||
@ -2846,9 +2967,16 @@ enum runStatus getRunStatus() {
|
|||||||
u_int32_t retval = bus_r(STATUS_REG);
|
u_int32_t retval = bus_r(STATUS_REG);
|
||||||
LOG(logINFO, ("Status Register: %08x\n", retval));
|
LOG(logINFO, ("Status Register: %08x\n", retval));
|
||||||
|
|
||||||
|
// error
|
||||||
|
if (retval & INTERNAL_STOP_MSK) {
|
||||||
|
LOG(logINFOBLUE, ("Status: ERROR\n"));
|
||||||
|
s = ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
// running
|
// running
|
||||||
if (retval & RUN_BUSY_MSK) {
|
else if (retval & RUN_BUSY_MSK) {
|
||||||
if (retval & WAITING_FOR_TRIGGER_MSK) {
|
if ((retval & WAITING_FOR_TRIGGER_MSK) ||
|
||||||
|
(retval & WAITING_FOR_START_FRAME_MSK)) {
|
||||||
LOG(logINFOBLUE, ("Status: WAITING\n"));
|
LOG(logINFOBLUE, ("Status: WAITING\n"));
|
||||||
s = WAITING;
|
s = WAITING;
|
||||||
} else {
|
} else {
|
||||||
@ -2859,19 +2987,13 @@ enum runStatus getRunStatus() {
|
|||||||
|
|
||||||
// not running
|
// not running
|
||||||
else {
|
else {
|
||||||
// stopped or error
|
// stopped or idle
|
||||||
if (retval & STOPPED_MSK) {
|
if (retval & STOPPED_MSK) {
|
||||||
LOG(logINFOBLUE, ("Status: STOPPED\n"));
|
LOG(logINFOBLUE, ("Status: STOPPED\n"));
|
||||||
s = STOPPED;
|
s = STOPPED;
|
||||||
} else if (retval & RUNMACHINE_BUSY_MSK) {
|
} else {
|
||||||
LOG(logINFOBLUE, ("Status: READ MACHINE BUSY\n"));
|
|
||||||
s = TRANSMITTING;
|
|
||||||
} else if (!retval) {
|
|
||||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||||
s = IDLE;
|
s = IDLE;
|
||||||
} else {
|
|
||||||
LOG(logERROR, ("Status: Unknown status %08x\n", retval));
|
|
||||||
s = ERROR;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
#include "sls/sls_detector_defs.h"
|
#include "sls/sls_detector_defs.h"
|
||||||
|
|
||||||
#define MIN_REQRD_VRSN_T_RD_API 0x171220
|
#define MIN_REQRD_VRSN_T_RD_API 0x171220
|
||||||
#define REQRD_FRMWRE_VRSN_BOARD2 0x230516 // 1.0 pcb (version = 010)
|
#define REQRD_FRMWRE_VRSN_BOARD2 0x230920 // 1.0 pcb (version = 010)
|
||||||
#define REQRD_FRMWRE_VRSN 0x230515 // 2.0 pcb (version = 011)
|
#define REQRD_FRMWRE_VRSN 0x230921 // 2.0 pcb (version = 011)
|
||||||
|
|
||||||
#define NUM_HARDWARE_VERSIONS (2)
|
#define NUM_HARDWARE_VERSIONS (2)
|
||||||
#define HARDWARE_VERSION_NUMBERS \
|
#define HARDWARE_VERSION_NUMBERS \
|
||||||
@ -52,6 +52,9 @@
|
|||||||
#define DEFAULT_FLIP_ROWS (0)
|
#define DEFAULT_FLIP_ROWS (0)
|
||||||
#define DEFAULT_FILTER_RESISTOR (1) // higher resistor
|
#define DEFAULT_FILTER_RESISTOR (1) // higher resistor
|
||||||
#define DEFAULT_FILTER_CELL (0)
|
#define DEFAULT_FILTER_CELL (0)
|
||||||
|
#define DEFAULT_PEDESTAL_MODE (0)
|
||||||
|
#define DEFAULT_PEDESTAL_FRAMES (1)
|
||||||
|
#define DEFAULT_PEDESTAL_LOOPS (1)
|
||||||
|
|
||||||
#define HIGHVOLTAGE_MIN (60)
|
#define HIGHVOLTAGE_MIN (60)
|
||||||
#define HIGHVOLTAGE_MAX (200)
|
#define HIGHVOLTAGE_MAX (200)
|
||||||
|
Binary file not shown.
@ -699,14 +699,12 @@ int setExpTime(int64_t val) {
|
|||||||
}
|
}
|
||||||
LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val));
|
LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val));
|
||||||
val *= (1E-3 * CLK_RUN);
|
val *= (1E-3 * CLK_RUN);
|
||||||
val -= ACQ_TIME_MIN_CLOCK;
|
|
||||||
if (val < 0) {
|
if (val < 0) {
|
||||||
val = 0;
|
val = 0;
|
||||||
}
|
}
|
||||||
set64BitReg(val, SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG);
|
set64BitReg(val, SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG);
|
||||||
|
|
||||||
// validate for tolerance
|
// validate for tolerance
|
||||||
val += ACQ_TIME_MIN_CLOCK;
|
|
||||||
int64_t retval = getExpTime();
|
int64_t retval = getExpTime();
|
||||||
val /= (1E-3 * CLK_RUN);
|
val /= (1E-3 * CLK_RUN);
|
||||||
if (val != retval) {
|
if (val != retval) {
|
||||||
@ -716,8 +714,7 @@ int setExpTime(int64_t val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int64_t getExpTime() {
|
int64_t getExpTime() {
|
||||||
return (get64BitReg(SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG) +
|
return get64BitReg(SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG) /
|
||||||
ACQ_TIME_MIN_CLOCK) /
|
|
||||||
(1E-3 * CLK_RUN);
|
(1E-3 * CLK_RUN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1120,8 +1117,8 @@ int getPrimaryInterface() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip,
|
void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip,
|
||||||
uint64_t destmac, uint32_t destport, uint64_t sourcemac,
|
uint64_t destmac, uint16_t destport, uint64_t sourcemac,
|
||||||
uint32_t sourceip, uint32_t sourceport) {
|
uint32_t sourceip, uint16_t sourceport) {
|
||||||
|
|
||||||
// start addr
|
// start addr
|
||||||
uint32_t addr = (type == INNER ? RXR_ENDPOINT_INNER_START_REG
|
uint32_t addr = (type == INNER ? RXR_ENDPOINT_INNER_START_REG
|
||||||
@ -1216,10 +1213,10 @@ int configureMAC() {
|
|||||||
uint64_t srcmac2 = udpDetails[iRxEntry].srcmac2;
|
uint64_t srcmac2 = udpDetails[iRxEntry].srcmac2;
|
||||||
uint64_t dstmac = udpDetails[iRxEntry].dstmac;
|
uint64_t dstmac = udpDetails[iRxEntry].dstmac;
|
||||||
uint64_t dstmac2 = udpDetails[iRxEntry].dstmac2;
|
uint64_t dstmac2 = udpDetails[iRxEntry].dstmac2;
|
||||||
int srcport = udpDetails[iRxEntry].srcport;
|
uint16_t srcport = udpDetails[iRxEntry].srcport;
|
||||||
int srcport2 = udpDetails[iRxEntry].srcport2;
|
uint16_t srcport2 = udpDetails[iRxEntry].srcport2;
|
||||||
int dstport = udpDetails[iRxEntry].dstport;
|
uint16_t dstport = udpDetails[iRxEntry].dstport;
|
||||||
int dstport2 = udpDetails[iRxEntry].dstport2;
|
uint16_t dstport2 = udpDetails[iRxEntry].dstport2;
|
||||||
|
|
||||||
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
|
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
|
||||||
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
|
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
|
||||||
@ -1243,10 +1240,10 @@ int configureMAC() {
|
|||||||
: (selInterface ? "Not Used" : "Used")));
|
: (selInterface ? "Not Used" : "Used")));
|
||||||
LOG(logINFO, ("\tSource IP : %s\n"
|
LOG(logINFO, ("\tSource IP : %s\n"
|
||||||
"\tSource MAC : %s\n"
|
"\tSource MAC : %s\n"
|
||||||
"\tSource Port : %d\n"
|
"\tSource Port : %hu\n"
|
||||||
"\tDest IP : %s\n"
|
"\tDest IP : %s\n"
|
||||||
"\tDest MAC : %s\n"
|
"\tDest MAC : %s\n"
|
||||||
"\tDest Port : %d\n\n",
|
"\tDest Port : %hu\n\n",
|
||||||
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
|
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
|
||||||
|
|
||||||
LOG(logINFO,
|
LOG(logINFO,
|
||||||
@ -1256,10 +1253,10 @@ int configureMAC() {
|
|||||||
LOG(logINFO,
|
LOG(logINFO,
|
||||||
("\tSource IP2 : %s\n"
|
("\tSource IP2 : %s\n"
|
||||||
"\tSource MAC2 : %s\n"
|
"\tSource MAC2 : %s\n"
|
||||||
"\tSource Port2: %d\n"
|
"\tSource Port2: %hu\n"
|
||||||
"\tDest IP2 : %s\n"
|
"\tDest IP2 : %s\n"
|
||||||
"\tDest MAC2 : %s\n"
|
"\tDest MAC2 : %s\n"
|
||||||
"\tDest Port2 : %d\n\n",
|
"\tDest Port2 : %hu\n\n",
|
||||||
src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2));
|
src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2));
|
||||||
}
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "sls/sls_detector_defs.h"
|
#include "sls/sls_detector_defs.h"
|
||||||
|
|
||||||
#define REQRD_FRMWRE_VRSN_BOARD2 0x444445 // 1.0 pcb (version = 010)
|
#define REQRD_FRMWRE_VRSN_BOARD2 0x444445 // 1.0 pcb (version = 010)
|
||||||
#define REQRD_FRMWRE_VRSN 0x230710 // 2.0 pcb (version = 011)
|
#define REQRD_FRMWRE_VRSN 0x231026 // 2.0 pcb (version = 011)
|
||||||
|
|
||||||
#define NUM_HARDWARE_VERSIONS (2)
|
#define NUM_HARDWARE_VERSIONS (2)
|
||||||
#define HARDWARE_VERSION_NUMBERS \
|
#define HARDWARE_VERSION_NUMBERS \
|
||||||
@ -58,7 +58,6 @@
|
|||||||
/* Defines in the Firmware */
|
/* Defines in the Firmware */
|
||||||
#define MAX_TIMESLOT_VAL (0x1F)
|
#define MAX_TIMESLOT_VAL (0x1F)
|
||||||
#define MAX_THRESHOLD_TEMP_VAL (127999) // millidegrees
|
#define MAX_THRESHOLD_TEMP_VAL (127999) // millidegrees
|
||||||
#define ACQ_TIME_MIN_CLOCK (2)
|
|
||||||
#define ASIC_FILTER_MAX_RES_VALUE (1)
|
#define ASIC_FILTER_MAX_RES_VALUE (1)
|
||||||
#define MAX_SELECT_CHIP10_VAL (63)
|
#define MAX_SELECT_CHIP10_VAL (63)
|
||||||
|
|
||||||
|
Binary file not shown.
@ -1963,8 +1963,8 @@ int configureMAC() {
|
|||||||
uint32_t dstip = udpDetails[iRxEntry].dstip;
|
uint32_t dstip = udpDetails[iRxEntry].dstip;
|
||||||
uint64_t srcmac = udpDetails[iRxEntry].srcmac;
|
uint64_t srcmac = udpDetails[iRxEntry].srcmac;
|
||||||
uint64_t dstmac = udpDetails[iRxEntry].dstmac;
|
uint64_t dstmac = udpDetails[iRxEntry].dstmac;
|
||||||
int srcport = udpDetails[iRxEntry].srcport;
|
uint16_t srcport = udpDetails[iRxEntry].srcport;
|
||||||
int dstport = udpDetails[iRxEntry].dstport;
|
uint16_t dstport = udpDetails[iRxEntry].dstport;
|
||||||
|
|
||||||
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
|
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
|
||||||
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
|
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
|
||||||
@ -1976,10 +1976,10 @@ int configureMAC() {
|
|||||||
LOG(logINFOBLUE, ("\tEntry %d\n", iRxEntry));
|
LOG(logINFOBLUE, ("\tEntry %d\n", iRxEntry));
|
||||||
LOG(logINFO, ("\tSource IP : %s\n"
|
LOG(logINFO, ("\tSource IP : %s\n"
|
||||||
"\tSource MAC : %s\n"
|
"\tSource MAC : %s\n"
|
||||||
"\tSource Port : %d\n"
|
"\tSource Port : %hu\n"
|
||||||
"\tDest IP : %s\n"
|
"\tDest IP : %s\n"
|
||||||
"\tDest MAC : %s\n"
|
"\tDest MAC : %s\n"
|
||||||
"\tDest Port : %d\n",
|
"\tDest Port : %hu\n",
|
||||||
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
|
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
|
||||||
}
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
|
@ -42,10 +42,10 @@ single detector.
|
|||||||
|
|
||||||
enum interfaceType { OUTER, INNER };
|
enum interfaceType { OUTER, INNER };
|
||||||
typedef struct udpStruct_s {
|
typedef struct udpStruct_s {
|
||||||
int srcport;
|
uint16_t srcport;
|
||||||
int srcport2;
|
uint16_t srcport2;
|
||||||
int dstport;
|
uint16_t dstport;
|
||||||
int dstport2;
|
uint16_t dstport2;
|
||||||
uint64_t srcmac;
|
uint64_t srcmac;
|
||||||
uint64_t srcmac2;
|
uint64_t srcmac2;
|
||||||
uint64_t dstmac;
|
uint64_t dstmac;
|
||||||
@ -467,8 +467,8 @@ void setFirstUDPDestination(int value);
|
|||||||
void selectPrimaryInterface(int val);
|
void selectPrimaryInterface(int val);
|
||||||
int getPrimaryInterface();
|
int getPrimaryInterface();
|
||||||
void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip,
|
void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip,
|
||||||
uint64_t destmac, uint32_t destport, uint64_t sourcemac,
|
uint64_t destmac, uint16_t destport, uint64_t sourcemac,
|
||||||
uint32_t sourceip, uint32_t sourceport);
|
uint32_t sourceip, uint16_t sourceport);
|
||||||
#endif
|
#endif
|
||||||
#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARD2D) || \
|
#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARD2D) || \
|
||||||
defined(MYTHEN3D) || defined(CHIPTESTBOARDD)
|
defined(MYTHEN3D) || defined(CHIPTESTBOARDD)
|
||||||
@ -516,7 +516,7 @@ void setDigitalIODelay(uint64_t pinMask, int delay);
|
|||||||
|
|
||||||
// jungfrau/moench specific - powerchip, autocompdisable, clockdiv, asictimer,
|
// jungfrau/moench specific - powerchip, autocompdisable, clockdiv, asictimer,
|
||||||
// clock, pll, flashing firmware
|
// clock, pll, flashing firmware
|
||||||
#if defined(MOENCHED)
|
#if defined(MOENCHD)
|
||||||
void setADCPipeline(int val);
|
void setADCPipeline(int val);
|
||||||
int getADCPipeline();
|
int getADCPipeline();
|
||||||
#endif
|
#endif
|
||||||
@ -556,6 +556,9 @@ int getCurrentSource();
|
|||||||
int getFixCurrentSource();
|
int getFixCurrentSource();
|
||||||
int getNormalCurrentSource();
|
int getNormalCurrentSource();
|
||||||
uint64_t getSelectCurrentSource();
|
uint64_t getSelectCurrentSource();
|
||||||
|
int getPedestalMode();
|
||||||
|
void getPedestalParameters(uint8_t *frames, uint16_t *loops);
|
||||||
|
void setPedestalMode(int enable, uint8_t frames, uint16_t loops);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter
|
// eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter
|
||||||
|
@ -327,3 +327,5 @@ int getRow();
|
|||||||
int setRow(int);
|
int setRow(int);
|
||||||
int getColumn();
|
int getColumn();
|
||||||
int setColumn(int);
|
int setColumn(int);
|
||||||
|
int get_pedestal_mode(int);
|
||||||
|
int set_pedestal_mode(int);
|
||||||
|
@ -15,6 +15,11 @@ u_int32_t *csp0base = 0;
|
|||||||
#define CSP0 0x20200000
|
#define CSP0 0x20200000
|
||||||
#define MEM_SIZE 0x100000
|
#define MEM_SIZE 0x100000
|
||||||
|
|
||||||
|
#ifdef JUNGFRAUD
|
||||||
|
|
||||||
|
extern void configureChip();
|
||||||
|
#endif
|
||||||
|
|
||||||
void bus_w16(u_int32_t offset, u_int16_t data) {
|
void bus_w16(u_int32_t offset, u_int16_t data) {
|
||||||
volatile u_int16_t *ptr1;
|
volatile u_int16_t *ptr1;
|
||||||
ptr1 = (u_int16_t *)(csp0base + offset / 2);
|
ptr1 = (u_int16_t *)(csp0base + offset / 2);
|
||||||
@ -80,7 +85,21 @@ u_int32_t readRegister(u_int32_t offset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
u_int32_t writeRegister(u_int32_t offset, u_int32_t data) {
|
u_int32_t writeRegister(u_int32_t offset, u_int32_t data) {
|
||||||
|
// if electron mode bit touched
|
||||||
|
#ifdef JUNGFRAUD
|
||||||
|
int electronCollectionModeChange = 0;
|
||||||
|
if ((offset << MEM_MAP_SHIFT) == DAQ_REG) {
|
||||||
|
if ((readRegister(offset) ^ data) & DAQ_ELCTRN_CLLCTN_MDE_MSK) {
|
||||||
|
electronCollectionModeChange = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
bus_w(offset << MEM_MAP_SHIFT, data);
|
bus_w(offset << MEM_MAP_SHIFT, data);
|
||||||
|
#ifdef JUNGFRAUD
|
||||||
|
if (electronCollectionModeChange) {
|
||||||
|
configureChip();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return readRegister(offset);
|
return readRegister(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "slsDetectorServer_funcs.h"
|
#include "slsDetectorServer_funcs.h"
|
||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -276,6 +277,15 @@ int main(int argc, char *argv[]) {
|
|||||||
LOG(logERROR, ("Could not set handler function for SIGINT"));
|
LOG(logERROR, ("Could not set handler function for SIGINT"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validate control and stop port number
|
||||||
|
if (0 >= portno || portno > USHRT_MAX || 0 >= (portno + 1) ||
|
||||||
|
(portno + 1) > USHRT_MAX) {
|
||||||
|
LOG(logERROR, ("Invalid control server or stop server port "
|
||||||
|
"numbers (%d, %d). It must be in range 1 - %d",
|
||||||
|
portno, portno + 1, USHRT_MAX));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (sharedMemory_create(portno) == FAIL) {
|
if (sharedMemory_create(portno) == FAIL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -486,6 +486,8 @@ void function_table() {
|
|||||||
flist[F_SET_ROW] = &set_row;
|
flist[F_SET_ROW] = &set_row;
|
||||||
flist[F_GET_COLUMN] = &get_column;
|
flist[F_GET_COLUMN] = &get_column;
|
||||||
flist[F_SET_COLUMN] = &set_column;
|
flist[F_SET_COLUMN] = &set_column;
|
||||||
|
flist[F_GET_PEDESTAL_MODE] = &get_pedestal_mode;
|
||||||
|
flist[F_SET_PEDESTAL_MODE] = &set_pedestal_mode;
|
||||||
|
|
||||||
// check
|
// check
|
||||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||||
@ -530,6 +532,11 @@ int executeCommand(char *command, char *result, enum TLogLevel level) {
|
|||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
FILE *sysFile = popen(cmd, "r");
|
FILE *sysFile = popen(cmd, "r");
|
||||||
|
if (sysFile == NULL) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(mess, "Executing cmd[%s] failed\n", cmd);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
while (fgets(temp, tempsize, sysFile) != NULL) {
|
while (fgets(temp, tempsize, sysFile) != NULL) {
|
||||||
// size left excludes terminating character
|
// size left excludes terminating character
|
||||||
size_t sizeleft = MAX_STR_LENGTH - strlen(result) - 1;
|
size_t sizeleft = MAX_STR_LENGTH - strlen(result) - 1;
|
||||||
@ -545,17 +552,15 @@ int executeCommand(char *command, char *result, enum TLogLevel level) {
|
|||||||
if (strlen(result) == 0) {
|
if (strlen(result) == 0) {
|
||||||
strcpy(result, "No result");
|
strcpy(result, "No result");
|
||||||
}
|
}
|
||||||
|
|
||||||
int retval = OK;
|
|
||||||
int success = pclose(sysFile);
|
int success = pclose(sysFile);
|
||||||
if (success) {
|
if (success == -1) {
|
||||||
retval = FAIL;
|
ret = FAIL;
|
||||||
LOG(logERROR, ("Executing cmd[%s]:%s\n", cmd, result));
|
strcpy(mess, result);
|
||||||
|
LOG(logERROR, ("Executing cmd[%s] failed:%s\n", cmd, mess));
|
||||||
} else {
|
} else {
|
||||||
LOG(level, ("Result:\n[%s]\n", result));
|
LOG(level, ("Result:\n[%s]\n", result));
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int M_nofunc(int file_des) {
|
int M_nofunc(int file_des) {
|
||||||
@ -583,7 +588,7 @@ int exec_command(int file_des) {
|
|||||||
|
|
||||||
// set
|
// set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
ret = executeCommand(cmd, retval, logINFO);
|
executeCommand(cmd, retval, logINFO);
|
||||||
}
|
}
|
||||||
return Server_SendResult(file_des, OTHER, retval, sizeof(retval));
|
return Server_SendResult(file_des, OTHER, retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
@ -724,6 +729,17 @@ int set_timing_mode(int file_des) {
|
|||||||
case GATED:
|
case GATED:
|
||||||
case TRIGGER_GATED:
|
case TRIGGER_GATED:
|
||||||
#endif
|
#endif
|
||||||
|
#if JUNGFRAUD
|
||||||
|
// cannot set in pedestal mode
|
||||||
|
if (getPedestalMode()) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(mess,
|
||||||
|
"Cannot set timing mode in pedestal mode. Switch off "
|
||||||
|
"pedestal mode to change timing mode.\n");
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (ret == OK)
|
||||||
setTiming(arg);
|
setTiming(arg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -2211,6 +2227,14 @@ int set_num_frames(int file_des) {
|
|||||||
(long long unsigned int)arg, MAX_FRAMES_IN_BURST_MODE);
|
(long long unsigned int)arg, MAX_FRAMES_IN_BURST_MODE);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
}
|
}
|
||||||
|
#elif JUNGFRAUD
|
||||||
|
// cannot set in pedestal mode
|
||||||
|
if (getPedestalMode()) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(mess, "Cannot set frames in pedestal mode. It is "
|
||||||
|
"overwritten anyway.\n");
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
setNumFrames(arg);
|
setNumFrames(arg);
|
||||||
@ -2247,11 +2271,23 @@ int set_num_triggers(int file_des) {
|
|||||||
|
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
|
#if JUNGFRAUD
|
||||||
|
// cannot set in pedestal mode
|
||||||
|
if (getPedestalMode()) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(mess, "Cannot set triggers in pedestal mode. It is "
|
||||||
|
"overwritten anyway.\n");
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (ret == OK) {
|
||||||
setNumTriggers(arg);
|
setNumTriggers(arg);
|
||||||
int64_t retval = getNumTriggers();
|
int64_t retval = getNumTriggers();
|
||||||
LOG(logDEBUG1, ("retval num triggers %lld\n", (long long int)retval));
|
LOG(logDEBUG1,
|
||||||
|
("retval num triggers %lld\n", (long long int)retval));
|
||||||
validate64(&ret, mess, arg, retval, "set number of triggers", DEC);
|
validate64(&ret, mess, arg, retval, "set number of triggers", DEC);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return Server_SendResult(file_des, INT64, NULL, 0);
|
return Server_SendResult(file_des, INT64, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2497,7 +2533,7 @@ int set_exptime(int file_des) {
|
|||||||
if (gateIndex != -1) {
|
if (gateIndex != -1) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess,
|
sprintf(mess,
|
||||||
"Could not get exposure time. Gate index not implemented "
|
"Could not set exposure time. Gate index not implemented "
|
||||||
"for this detector\n");
|
"for this detector\n");
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
} else {
|
} else {
|
||||||
@ -4736,7 +4772,8 @@ int set_read_n_rows(int file_des) {
|
|||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
#else
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if ((Server_VerifyLock() == OK) &&
|
||||||
|
(check_detector_idle("set number of rows") == OK)) {
|
||||||
if (arg < MIN_ROWS_PER_READOUT || arg > MAX_ROWS_PER_READOUT) {
|
if (arg < MIN_ROWS_PER_READOUT || arg > MAX_ROWS_PER_READOUT) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess,
|
sprintf(mess,
|
||||||
@ -4768,8 +4805,7 @@ int set_read_n_rows(int file_des) {
|
|||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
} else
|
} else
|
||||||
#elif defined(JUNGFRAUD) || defined(MOENCHD)
|
#elif defined(JUNGFRAUD) || defined(MOENCHD)
|
||||||
if ((check_detector_idle("set number of rows") == OK) &&
|
if (arg % READ_N_ROWS_MULTIPLE != 0) {
|
||||||
(arg % READ_N_ROWS_MULTIPLE != 0)) {
|
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess,
|
sprintf(mess,
|
||||||
"Could not set number of rows. %d must be a multiple "
|
"Could not set number of rows. %d must be a multiple "
|
||||||
@ -5366,11 +5402,11 @@ int get_dest_udp_mac2(int file_des) {
|
|||||||
int set_dest_udp_port(int file_des) {
|
int set_dest_udp_port(int file_des) {
|
||||||
ret = OK;
|
ret = OK;
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
int arg = 0;
|
uint16_t arg = 0;
|
||||||
|
|
||||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
if (receiveData(file_des, &arg, sizeof(arg), INT16) < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
LOG(logINFO, ("Setting udp destination port: %u\n", arg));
|
LOG(logINFO, ("Setting udp destination port: %hu\n", arg));
|
||||||
|
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
@ -5381,30 +5417,30 @@ int set_dest_udp_port(int file_des) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT16, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_dest_udp_port(int file_des) {
|
int get_dest_udp_port(int file_des) {
|
||||||
ret = OK;
|
ret = OK;
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
int retval = -1;
|
uint16_t retval = -1;
|
||||||
LOG(logDEBUG1, ("Getting destination port"));
|
LOG(logDEBUG1, ("Getting destination port"));
|
||||||
|
|
||||||
// get only
|
// get only
|
||||||
retval = udpDetails[0].dstport;
|
retval = udpDetails[0].dstport;
|
||||||
LOG(logDEBUG, ("udp destination port retval: %u\n", retval));
|
LOG(logDEBUG, ("udp destination port retval: %hu\n", retval));
|
||||||
|
|
||||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT16, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_dest_udp_port2(int file_des) {
|
int set_dest_udp_port2(int file_des) {
|
||||||
ret = OK;
|
ret = OK;
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
int arg = 0;
|
uint16_t arg = 0;
|
||||||
|
|
||||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
if (receiveData(file_des, &arg, sizeof(arg), INT16) < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
LOG(logINFO, ("Setting udp destination port2: %u\n", arg));
|
LOG(logINFO, ("Setting udp destination port2: %hu\n", arg));
|
||||||
|
|
||||||
#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(EIGERD) && \
|
#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(EIGERD) && \
|
||||||
!defined(GOTTHARD2D)
|
!defined(GOTTHARD2D)
|
||||||
@ -5420,13 +5456,13 @@ int set_dest_udp_port2(int file_des) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT16, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_dest_udp_port2(int file_des) {
|
int get_dest_udp_port2(int file_des) {
|
||||||
ret = OK;
|
ret = OK;
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
int retval = -1;
|
uint16_t retval = -1;
|
||||||
LOG(logDEBUG1, ("Getting destination port2\n"));
|
LOG(logDEBUG1, ("Getting destination port2\n"));
|
||||||
|
|
||||||
#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(EIGERD) && \
|
#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(EIGERD) && \
|
||||||
@ -5435,9 +5471,9 @@ int get_dest_udp_port2(int file_des) {
|
|||||||
#else
|
#else
|
||||||
// get only
|
// get only
|
||||||
retval = udpDetails[0].dstport2;
|
retval = udpDetails[0].dstport2;
|
||||||
LOG(logDEBUG1, ("udp destination port2 retval: %u\n", retval));
|
LOG(logDEBUG1, ("udp destination port2 retval: %hu\n", retval));
|
||||||
#endif
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT16, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_num_interfaces(int file_des) {
|
int set_num_interfaces(int file_des) {
|
||||||
@ -6990,6 +7026,7 @@ int get_receiver_parameters(int file_des) {
|
|||||||
int n = 0;
|
int n = 0;
|
||||||
int i32 = 0;
|
int i32 = 0;
|
||||||
int64_t i64 = 0;
|
int64_t i64 = 0;
|
||||||
|
uint16_t u16 = 0;
|
||||||
uint32_t u32 = 0;
|
uint32_t u32 = 0;
|
||||||
uint64_t u64 = 0;
|
uint64_t u64 = 0;
|
||||||
|
|
||||||
@ -7032,8 +7069,8 @@ int get_receiver_parameters(int file_des) {
|
|||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
|
|
||||||
// udp dst port
|
// udp dst port
|
||||||
i32 = udpDetails[0].dstport;
|
u16 = udpDetails[0].dstport;
|
||||||
n += sendData(file_des, &i32, sizeof(i32), INT32);
|
n += sendData(file_des, &u16, sizeof(u16), INT16);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
|
|
||||||
@ -7051,8 +7088,8 @@ int get_receiver_parameters(int file_des) {
|
|||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
|
|
||||||
// udp dst port2
|
// udp dst port2
|
||||||
i32 = udpDetails[0].dstport2;
|
u16 = udpDetails[0].dstport2;
|
||||||
n += sendData(file_des, &i32, sizeof(i32), INT32);
|
n += sendData(file_des, &u16, sizeof(u16), INT16);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
|
|
||||||
@ -7790,6 +7827,14 @@ int set_scan(int file_des) {
|
|||||||
int stop = args[3];
|
int stop = args[3];
|
||||||
int step = args[4];
|
int step = args[4];
|
||||||
|
|
||||||
|
#ifdef JUNGFRAUD
|
||||||
|
if (getPedestalMode()) {
|
||||||
|
ret = FAIL;
|
||||||
|
strcpy(mess, "Cannot set scan when in pedestal mode.\n");
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (ret == OK) {
|
||||||
// disable scan
|
// disable scan
|
||||||
if (enable == 0) {
|
if (enable == 0) {
|
||||||
LOG(logINFOBLUE, ("Disabling scan"));
|
LOG(logINFOBLUE, ("Disabling scan"));
|
||||||
@ -7799,12 +7844,15 @@ int set_scan(int file_des) {
|
|||||||
int64_t arg = 1;
|
int64_t arg = 1;
|
||||||
setNumFrames(arg);
|
setNumFrames(arg);
|
||||||
retval = getNumFrames();
|
retval = getNumFrames();
|
||||||
LOG(logDEBUG1, ("retval num frames %lld\n", (long long int)retval));
|
LOG(logDEBUG1,
|
||||||
validate64(&ret, mess, arg, retval, "set number of frames", DEC);
|
("retval num frames %lld\n", (long long int)retval));
|
||||||
|
validate64(&ret, mess, arg, retval, "set number of frames",
|
||||||
|
DEC);
|
||||||
}
|
}
|
||||||
// enable scan
|
// enable scan
|
||||||
else {
|
else {
|
||||||
if ((start < stop && step <= 0) || (stop < start && step >= 0)) {
|
if ((start < stop && step <= 0) ||
|
||||||
|
(stop < start && step >= 0)) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess, "Invalid scan parameters\n");
|
sprintf(mess, "Invalid scan parameters\n");
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
@ -7821,7 +7869,8 @@ int set_scan(int file_des) {
|
|||||||
// validate index
|
// validate index
|
||||||
getDACIndex(index);
|
getDACIndex(index);
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
LOG(logINFOBLUE, ("Dac [%d] scan enabled\n", index));
|
LOG(logINFOBLUE,
|
||||||
|
("Dac [%d] scan enabled\n", index));
|
||||||
scanTrimbits = 0;
|
scanTrimbits = 0;
|
||||||
scanGlobalIndex = index;
|
scanGlobalIndex = index;
|
||||||
scanSettleTime_ns = dacTime;
|
scanSettleTime_ns = dacTime;
|
||||||
@ -7840,10 +7889,11 @@ int set_scan(int file_des) {
|
|||||||
scanSteps[i] = start + i * step;
|
scanSteps[i] = start + i * step;
|
||||||
LOG(logDEBUG1, ("scansteps[%d]:%d\n", i, scanSteps[i]));
|
LOG(logDEBUG1, ("scansteps[%d]:%d\n", i, scanSteps[i]));
|
||||||
}
|
}
|
||||||
LOG(logINFOBLUE, ("Enabling scan for %s, start[%d], stop[%d], "
|
LOG(logINFOBLUE,
|
||||||
|
("Enabling scan for %s, start[%d], stop[%d], "
|
||||||
"step[%d], nsteps[%d]\n",
|
"step[%d], nsteps[%d]\n",
|
||||||
scanTrimbits == 1 ? "trimbits" : "dac", start,
|
scanTrimbits == 1 ? "trimbits" : "dac", start, stop,
|
||||||
stop, step, numScanSteps));
|
step, numScanSteps));
|
||||||
|
|
||||||
// setting number of frames to scansteps
|
// setting number of frames to scansteps
|
||||||
int64_t arg = 1;
|
int64_t arg = 1;
|
||||||
@ -7857,6 +7907,7 @@ int set_scan(int file_des) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8421,9 +8472,9 @@ int set_master(int file_des) {
|
|||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
#else
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if ((Server_VerifyLock() == OK) &&
|
||||||
if ((check_detector_idle("set master") == OK) &&
|
(check_detector_idle("set master") == OK)) {
|
||||||
(arg != 0 && arg != 1)) {
|
if (arg != 0 && arg != 1) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess, "Could not set master. Invalid argument %d.\n", arg);
|
sprintf(mess, "Could not set master. Invalid argument %d.\n", arg);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
@ -8977,9 +9028,9 @@ int set_flip_rows(int file_des) {
|
|||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
#else
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if ((Server_VerifyLock() == OK) &&
|
||||||
if ((check_detector_idle("set flip rows") == OK) &&
|
(check_detector_idle("set flip rows") == OK)) {
|
||||||
(arg != 0 && arg != 1)) {
|
if (arg != 0 && arg != 1) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess, "Could not set flip rows. Invalid argument %d.\n",
|
sprintf(mess, "Could not set flip rows. Invalid argument %d.\n",
|
||||||
arg);
|
arg);
|
||||||
@ -9170,7 +9221,8 @@ int get_dest_udp_list(int file_des) {
|
|||||||
ret = OK;
|
ret = OK;
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
uint32_t arg = 0;
|
uint32_t arg = 0;
|
||||||
uint32_t retvals[5] = {};
|
uint16_t retvals16[2] = {};
|
||||||
|
uint32_t retvals32[3] = {};
|
||||||
uint64_t retvals64[2] = {};
|
uint64_t retvals64[2] = {};
|
||||||
|
|
||||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||||
@ -9189,34 +9241,36 @@ int get_dest_udp_list(int file_des) {
|
|||||||
MAX_UDP_DESTINATION - 1);
|
MAX_UDP_DESTINATION - 1);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
} else {
|
} else {
|
||||||
retvals[0] = arg;
|
// arg;
|
||||||
retvals[1] = udpDetails[arg].dstport;
|
retvals16[0] = udpDetails[arg].dstport;
|
||||||
retvals[2] = udpDetails[arg].dstport2;
|
retvals16[1] = udpDetails[arg].dstport2;
|
||||||
retvals[3] = udpDetails[arg].dstip;
|
retvals32[0] = udpDetails[arg].dstip;
|
||||||
retvals[4] = udpDetails[arg].dstip2;
|
retvals32[1] = udpDetails[arg].dstip2;
|
||||||
retvals64[0] = udpDetails[arg].dstmac;
|
retvals64[0] = udpDetails[arg].dstmac;
|
||||||
retvals64[1] = udpDetails[arg].dstmac2;
|
retvals64[1] = udpDetails[arg].dstmac2;
|
||||||
|
|
||||||
// swap ip
|
// swap ip
|
||||||
retvals[3] = __builtin_bswap32(retvals[3]);
|
retvals32[0] = __builtin_bswap32(retvals32[0]);
|
||||||
retvals[4] = __builtin_bswap32(retvals[4]);
|
retvals32[1] = __builtin_bswap32(retvals32[1]);
|
||||||
|
|
||||||
// convert to string
|
// convert to string
|
||||||
char ip[INET_ADDRSTRLEN], ip2[INET_ADDRSTRLEN];
|
char ip[INET_ADDRSTRLEN], ip2[INET_ADDRSTRLEN];
|
||||||
getIpAddressinString(ip, retvals[3]);
|
getIpAddressinString(ip, retvals32[0]);
|
||||||
getIpAddressinString(ip2, retvals[4]);
|
getIpAddressinString(ip2, retvals32[1]);
|
||||||
char mac[MAC_ADDRESS_SIZE], mac2[MAC_ADDRESS_SIZE];
|
char mac[MAC_ADDRESS_SIZE], mac2[MAC_ADDRESS_SIZE];
|
||||||
getMacAddressinString(mac, MAC_ADDRESS_SIZE, retvals64[0]);
|
getMacAddressinString(mac, MAC_ADDRESS_SIZE, retvals64[0]);
|
||||||
getMacAddressinString(mac2, MAC_ADDRESS_SIZE, retvals64[1]);
|
getMacAddressinString(mac2, MAC_ADDRESS_SIZE, retvals64[1]);
|
||||||
LOG(logDEBUG1,
|
LOG(logDEBUG1,
|
||||||
("Udp Dest. retval [%d]: [port %d, port2 %d, ip %s, ip2 %s, "
|
("Udp Dest. retval [%d]: [port %hu, port2 %hu, ip %s, ip2 %s, "
|
||||||
"mac %s, mac2 %s]\n",
|
"mac %s, mac2 %s]\n",
|
||||||
retvals[0], retvals[1], retvals[2], ip, ip2, mac, mac2));
|
arg, retvals16[0], retvals16[1], ip, ip2, mac, mac2));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Server_SendResult(file_des, INT32, NULL, 0);
|
Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
if (ret != FAIL) {
|
if (ret != FAIL) {
|
||||||
sendData(file_des, retvals, sizeof(retvals), INT32);
|
sendData(file_des, &arg, sizeof(arg), INT32);
|
||||||
|
sendData(file_des, retvals16, sizeof(retvals16), INT16);
|
||||||
|
sendData(file_des, retvals32, sizeof(retvals32), INT32);
|
||||||
sendData(file_des, retvals64, sizeof(retvals64), INT64);
|
sendData(file_des, retvals64, sizeof(retvals64), INT64);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -9225,22 +9279,28 @@ int get_dest_udp_list(int file_des) {
|
|||||||
int set_dest_udp_list(int file_des) {
|
int set_dest_udp_list(int file_des) {
|
||||||
ret = OK;
|
ret = OK;
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
uint32_t args[5] = {};
|
uint32_t arg = 0;
|
||||||
|
uint16_t args16[2] = {};
|
||||||
|
uint32_t args32[2] = {};
|
||||||
uint64_t args64[2] = {};
|
uint64_t args64[2] = {};
|
||||||
|
|
||||||
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
if (receiveData(file_des, args16, sizeof(args16), INT16) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
if (receiveData(file_des, args32, sizeof(args32), INT32) < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
if (receiveData(file_des, args64, sizeof(args64), INT64) < 0)
|
if (receiveData(file_des, args64, sizeof(args64), INT64) < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
|
|
||||||
// swap ip
|
// swap ip
|
||||||
args[3] = __builtin_bswap32(args[3]);
|
args32[0] = __builtin_bswap32(args32[0]);
|
||||||
args[4] = __builtin_bswap32(args[4]);
|
args32[1] = __builtin_bswap32(args32[1]);
|
||||||
|
|
||||||
// convert to string
|
// convert to string
|
||||||
char ip[INET_ADDRSTRLEN], ip2[INET_ADDRSTRLEN];
|
char ip[INET_ADDRSTRLEN], ip2[INET_ADDRSTRLEN];
|
||||||
getIpAddressinString(ip, args[3]);
|
getIpAddressinString(ip, args32[0]);
|
||||||
getIpAddressinString(ip2, args[4]);
|
getIpAddressinString(ip2, args32[1]);
|
||||||
char mac[MAC_ADDRESS_SIZE], mac2[MAC_ADDRESS_SIZE];
|
char mac[MAC_ADDRESS_SIZE], mac2[MAC_ADDRESS_SIZE];
|
||||||
getMacAddressinString(mac, MAC_ADDRESS_SIZE, args64[0]);
|
getMacAddressinString(mac, MAC_ADDRESS_SIZE, args64[0]);
|
||||||
getMacAddressinString(mac2, MAC_ADDRESS_SIZE, args64[1]);
|
getMacAddressinString(mac2, MAC_ADDRESS_SIZE, args64[1]);
|
||||||
@ -9251,11 +9311,11 @@ int set_dest_udp_list(int file_des) {
|
|||||||
#else
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
int entry = args[0];
|
int entry = arg;
|
||||||
LOG(logINFOBLUE,
|
LOG(logINFOBLUE,
|
||||||
("Setting udp dest. [%d]: [port %d, port2 %d, ip %s, ip2 %s, "
|
("Setting udp dest. [%d]: [port %hu, port2 %hu, ip %s, ip2 %s, "
|
||||||
"mac %s, mac2 %s]\n",
|
"mac %s, mac2 %s]\n",
|
||||||
entry, args[1], args[2], ip, ip2, mac, mac2));
|
entry, args16[0], args16[1], ip, ip2, mac, mac2));
|
||||||
|
|
||||||
if (entry < 1 || entry >= MAX_UDP_DESTINATION) {
|
if (entry < 1 || entry >= MAX_UDP_DESTINATION) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
@ -9266,7 +9326,7 @@ int set_dest_udp_list(int file_des) {
|
|||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
}
|
}
|
||||||
#if defined(EIGERD) || defined(MYTHEN3D)
|
#if defined(EIGERD) || defined(MYTHEN3D)
|
||||||
else if (args[4] != 0 || args64[1] != 0) {
|
else if (args32[1] != 0 || args64[1] != 0) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
strcpy(mess, "Could not set udp destination. ip2 and mac2 not "
|
strcpy(mess, "Could not set udp destination. ip2 and mac2 not "
|
||||||
"implemented for this detector.\n");
|
"implemented for this detector.\n");
|
||||||
@ -9275,17 +9335,17 @@ int set_dest_udp_list(int file_des) {
|
|||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
if (check_detector_idle("set udp destination list entries") == OK) {
|
if (check_detector_idle("set udp destination list entries") == OK) {
|
||||||
if (args[1] != 0) {
|
if (args16[0] != 0) {
|
||||||
udpDetails[entry].dstport = args[1];
|
udpDetails[entry].dstport = args16[0];
|
||||||
}
|
}
|
||||||
if (args[2] != 0) {
|
if (args16[1] != 0) {
|
||||||
udpDetails[entry].dstport2 = args[2];
|
udpDetails[entry].dstport2 = args16[1];
|
||||||
}
|
}
|
||||||
if (args[3] != 0) {
|
if (args32[0] != 0) {
|
||||||
udpDetails[entry].dstip = args[3];
|
udpDetails[entry].dstip = args32[0];
|
||||||
}
|
}
|
||||||
if (args[4] != 0) {
|
if (args32[1] != 0) {
|
||||||
udpDetails[entry].dstip2 = args[4];
|
udpDetails[entry].dstip2 = args32[1];
|
||||||
}
|
}
|
||||||
if (args64[0] != 0) {
|
if (args64[0] != 0) {
|
||||||
udpDetails[entry].dstmac = args64[0];
|
udpDetails[entry].dstmac = args64[0];
|
||||||
@ -10305,9 +10365,9 @@ int set_synchronization(int file_des) {
|
|||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
#else
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if ((Server_VerifyLock() == OK) &&
|
||||||
if ((check_detector_idle("set synchronization") == OK) &&
|
(check_detector_idle("set synchronization") == OK)) {
|
||||||
(arg != 0 && arg != 1)) {
|
if (arg != 0 && arg != 1) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess,
|
sprintf(mess,
|
||||||
"Could not set synchronization. Invalid argument %d.\n",
|
"Could not set synchronization. Invalid argument %d.\n",
|
||||||
@ -10731,3 +10791,107 @@ int setColumn(int value) {
|
|||||||
pos[X] = value;
|
pos[X] = value;
|
||||||
return setDetectorPosition(pos);
|
return setDetectorPosition(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_pedestal_mode(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int retvalEnable = -1;
|
||||||
|
uint8_t retvalFrames = -1;
|
||||||
|
uint16_t retvalLoops = -1;
|
||||||
|
LOG(logDEBUG1, ("Getting pedestal mode\n"));
|
||||||
|
|
||||||
|
#if !defined(JUNGFRAUD)
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
retvalEnable = getPedestalMode();
|
||||||
|
getPedestalParameters(&retvalFrames, &retvalLoops);
|
||||||
|
LOG(logDEBUG1, ("pedestal mode retval: [enable:%d frames:%hhu, "
|
||||||
|
"loops:%hu]\n",
|
||||||
|
retvalEnable, retvalFrames, retvalLoops));
|
||||||
|
#endif
|
||||||
|
Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
if (ret != FAIL) {
|
||||||
|
sendData(file_des, &retvalEnable, sizeof(retvalEnable), INT32);
|
||||||
|
sendData(file_des, &retvalFrames, sizeof(retvalFrames), OTHER);
|
||||||
|
sendData(file_des, &retvalLoops, sizeof(retvalLoops), INT16);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int set_pedestal_mode(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int enable = -1;
|
||||||
|
uint8_t frames = -1;
|
||||||
|
uint16_t loops = -1;
|
||||||
|
|
||||||
|
if (receiveData(file_des, &enable, sizeof(enable), INT32) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
if (receiveData(file_des, &frames, sizeof(frames), OTHER) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
if (receiveData(file_des, &loops, sizeof(loops), INT16) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
LOG(logDEBUG1, ("Setting pedestal mode: enable:%d frames:%hhu, "
|
||||||
|
"loops:%hu]\n",
|
||||||
|
enable, frames, loops));
|
||||||
|
|
||||||
|
#if !defined(JUNGFRAUD)
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// only set
|
||||||
|
if (Server_VerifyLock() == OK) {
|
||||||
|
if (check_detector_idle("set pedestal mode") == OK) {
|
||||||
|
if (enable != 0 && enable != 1) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(
|
||||||
|
mess,
|
||||||
|
"Could not set pedestal mode. Invalid enable argument %d. "
|
||||||
|
"Options: [0, 1]\n",
|
||||||
|
enable);
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
} else if (enable == 1 && (frames == 0 || loops == 0)) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(mess,
|
||||||
|
"Could not set pedestal mode. Frames and loops cannot "
|
||||||
|
"be 0. [%hhu, %hu].\n",
|
||||||
|
frames, loops);
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
} else {
|
||||||
|
setPedestalMode(enable, frames, loops);
|
||||||
|
int retvalEnable = getPedestalMode();
|
||||||
|
LOG(logDEBUG1, ("pedestal mode retval: %d\n", retvalEnable));
|
||||||
|
if (enable != retvalEnable) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(
|
||||||
|
mess,
|
||||||
|
"Could not set pedestal mode. Tried to %s, but is %s\n",
|
||||||
|
(enable ? "enable" : "disable"),
|
||||||
|
(retvalEnable ? "enabled" : "disabled"));
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
}
|
||||||
|
if (enable) {
|
||||||
|
uint8_t retvalFrames = -1;
|
||||||
|
uint16_t retvalLoops = -1;
|
||||||
|
getPedestalParameters(&retvalFrames, &retvalLoops);
|
||||||
|
LOG(logDEBUG1,
|
||||||
|
("pedestal mode retval: [enable:%d frames:%hhu, "
|
||||||
|
"loops:%hu]\n",
|
||||||
|
retvalEnable, retvalFrames, retvalLoops));
|
||||||
|
if (frames != retvalFrames || loops != retvalLoops) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(
|
||||||
|
mess,
|
||||||
|
"Could not set pedestal mode. Tried to set "
|
||||||
|
"[enable: %d, frames: %hhu, loops: %hu], but got "
|
||||||
|
"[enable: %d, frames: %hhu, loops: %hu].\n",
|
||||||
|
enable, frames, loops, retvalEnable, retvalFrames,
|
||||||
|
retvalLoops);
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
}
|
||||||
|
@ -66,7 +66,7 @@ class Detector {
|
|||||||
|
|
||||||
/** connects to n servers at local host starting at specific control port.
|
/** connects to n servers at local host starting at specific control port.
|
||||||
* Every virtual server will have a stop port (control port + 1) */
|
* Every virtual server will have a stop port (control port + 1) */
|
||||||
void setVirtualDetectorServers(int numServers, int startingPort);
|
void setVirtualDetectorServers(int numServers, uint16_t startingPort);
|
||||||
|
|
||||||
/** Gets shared memory ID */
|
/** Gets shared memory ID */
|
||||||
int getShmId() const;
|
int getShmId() const;
|
||||||
@ -216,7 +216,10 @@ class Detector {
|
|||||||
/** [Jungfrau][Moench] **/
|
/** [Jungfrau][Moench] **/
|
||||||
Result<bool> getSynchronization(Positions pos = {}) const;
|
Result<bool> getSynchronization(Positions pos = {}) const;
|
||||||
|
|
||||||
/** [Jungfrau][Moench] */
|
/** [Jungfrau][Moench] Sync mode requires at least one master configured.
|
||||||
|
Also requires flatband cabling between master and slave with
|
||||||
|
termination board.
|
||||||
|
*/
|
||||||
void setSynchronization(bool value);
|
void setSynchronization(bool value);
|
||||||
|
|
||||||
/** [Gotthard2][Mythen3] */
|
/** [Gotthard2][Mythen3] */
|
||||||
@ -791,20 +794,20 @@ class Detector {
|
|||||||
*/
|
*/
|
||||||
void setDestinationUDPMAC2(const MacAddr mac, Positions pos = {});
|
void setDestinationUDPMAC2(const MacAddr mac, Positions pos = {});
|
||||||
|
|
||||||
Result<int> getDestinationUDPPort(Positions pos = {}) const;
|
Result<uint16_t> getDestinationUDPPort(Positions pos = {}) const;
|
||||||
|
|
||||||
/** Default is 50001. \n If module_id is -1, ports for each module is
|
/** Default is 50001. \n If module_id is -1, ports for each module is
|
||||||
* calculated (incremented by 1 if no 2nd interface) */
|
* calculated (incremented by 1 if no 2nd interface) */
|
||||||
void setDestinationUDPPort(int port, int module_id = -1);
|
void setDestinationUDPPort(uint16_t port, int module_id = -1);
|
||||||
|
|
||||||
/** [Eiger] right port[Jungfrau][Moench] bottom half [Gotthard2] veto
|
/** [Eiger] right port[Jungfrau][Moench] bottom half [Gotthard2] veto
|
||||||
* debugging */
|
* debugging */
|
||||||
Result<int> getDestinationUDPPort2(Positions pos = {}) const;
|
Result<uint16_t> getDestinationUDPPort2(Positions pos = {}) const;
|
||||||
|
|
||||||
/** [Eiger] right port[Jungfrau][Moench] bottom half [Gotthard2] veto
|
/** [Eiger] right port[Jungfrau][Moench] bottom half [Gotthard2] veto
|
||||||
* debugging \n Default is 50002. \n If module_id is -1, ports for each
|
* debugging \n Default is 50002. \n If module_id is -1, ports for each
|
||||||
* module is calculated (incremented by 1 if no 2nd interface)*/
|
* module is calculated (incremented by 1 if no 2nd interface)*/
|
||||||
void setDestinationUDPPort2(int port, int module_id = -1);
|
void setDestinationUDPPort2(uint16_t port, int module_id = -1);
|
||||||
|
|
||||||
/** Reconfigures Detector with UDP destination. More for debugging as the
|
/** Reconfigures Detector with UDP destination. More for debugging as the
|
||||||
* configuration is done automatically when the detector has sufficient UDP
|
* configuration is done automatically when the detector has sufficient UDP
|
||||||
@ -904,14 +907,14 @@ class Detector {
|
|||||||
/** multiple rx hostnames. Single element will set it for all */
|
/** multiple rx hostnames. Single element will set it for all */
|
||||||
void setRxHostname(const std::vector<std::string> &name);
|
void setRxHostname(const std::vector<std::string> &name);
|
||||||
|
|
||||||
Result<int> getRxPort(Positions pos = {}) const;
|
Result<uint16_t> getRxPort(Positions pos = {}) const;
|
||||||
|
|
||||||
/** TCP port for client-receiver communication. \n
|
/** TCP port for client-receiver communication. \n
|
||||||
* Default is 1954. \n Must be different if multiple receivers on same pc.
|
* Default is 1954. \n Must be different if multiple receivers on same pc.
|
||||||
* \n Must be first command to set a receiver parameter to be able to
|
* \n Must be first command to set a receiver parameter to be able to
|
||||||
* communicate. \n Multi command will automatically increment port for
|
* communicate. \n Multi command will automatically increment port for
|
||||||
* individual modules.*/
|
* individual modules.*/
|
||||||
void setRxPort(int port, int module_id = -1);
|
void setRxPort(uint16_t port, int module_id = -1);
|
||||||
|
|
||||||
Result<int> getRxFifoDepth(Positions pos = {}) const;
|
Result<int> getRxFifoDepth(Positions pos = {}) const;
|
||||||
|
|
||||||
@ -1089,7 +1092,7 @@ class Detector {
|
|||||||
*/
|
*/
|
||||||
void setRxZmqStartingFrame(int fnum, Positions pos = {});
|
void setRxZmqStartingFrame(int fnum, Positions pos = {});
|
||||||
|
|
||||||
Result<int> getRxZmqPort(Positions pos = {}) const;
|
Result<uint16_t> getRxZmqPort(Positions pos = {}) const;
|
||||||
|
|
||||||
/** Zmq port for data to be streamed out of the receiver. \n
|
/** Zmq port for data to be streamed out of the receiver. \n
|
||||||
* Also restarts receiver zmq streaming if enabled. \n Default is 30001. \n
|
* Also restarts receiver zmq streaming if enabled. \n Default is 30001. \n
|
||||||
@ -1098,7 +1101,7 @@ class Detector {
|
|||||||
* no 2nd interface). \n Restarts receiver zmq sockets only if it was
|
* no 2nd interface). \n Restarts receiver zmq sockets only if it was
|
||||||
* already enabled
|
* already enabled
|
||||||
*/
|
*/
|
||||||
void setRxZmqPort(int port, int module_id = -1);
|
void setRxZmqPort(uint16_t port, int module_id = -1);
|
||||||
|
|
||||||
Result<IpAddr> getRxZmqIP(Positions pos = {}) const;
|
Result<IpAddr> getRxZmqIP(Positions pos = {}) const;
|
||||||
|
|
||||||
@ -1108,7 +1111,7 @@ class Detector {
|
|||||||
* receiver. */
|
* receiver. */
|
||||||
void setRxZmqIP(const IpAddr ip, Positions pos = {});
|
void setRxZmqIP(const IpAddr ip, Positions pos = {});
|
||||||
|
|
||||||
Result<int> getClientZmqPort(Positions pos = {}) const;
|
Result<uint16_t> getClientZmqPort(Positions pos = {}) const;
|
||||||
|
|
||||||
/** Port number to listen to zmq data streamed out from receiver or
|
/** Port number to listen to zmq data streamed out from receiver or
|
||||||
* intermediate process. \n Must be different for every detector (and udp
|
* intermediate process. \n Must be different for every detector (and udp
|
||||||
@ -1117,7 +1120,7 @@ class Detector {
|
|||||||
* sockets only if it was already enabled \n Default connects to receiver
|
* sockets only if it was already enabled \n Default connects to receiver
|
||||||
* zmq streaming out port (30001).
|
* zmq streaming out port (30001).
|
||||||
*/
|
*/
|
||||||
void setClientZmqPort(int port, int module_id = -1);
|
void setClientZmqPort(uint16_t port, int module_id = -1);
|
||||||
|
|
||||||
Result<IpAddr> getClientZmqIp(Positions pos = {}) const;
|
Result<IpAddr> getClientZmqIp(Positions pos = {}) const;
|
||||||
|
|
||||||
@ -1359,6 +1362,20 @@ class Detector {
|
|||||||
*/
|
*/
|
||||||
void setNumberOfFilterCells(int cell, Positions pos = {});
|
void setNumberOfFilterCells(int cell, Positions pos = {});
|
||||||
|
|
||||||
|
/** [Jungfrau] */
|
||||||
|
Result<defs::pedestalParameters> getPedestalMode(Positions pos = {}) const;
|
||||||
|
|
||||||
|
/** [Jungfrau] In pedestal mode, the number of frames or triggers is
|
||||||
|
* overwritten by \n(#pedestal_frames x #pedestal_loops x 2). \nIn
|
||||||
|
* auto timing mode or in trigger mode with #frames > 1, #frames is
|
||||||
|
* overwritten and #triggers = 1, \nelse #triggers is overwritten and
|
||||||
|
* #frames = 1. One cannot set #frames, #triggers or timing mode in pedestal
|
||||||
|
* mode (it will throw an exception). Disabling pedestal mode will set back
|
||||||
|
* the original values of #frames and #triggers
|
||||||
|
*/
|
||||||
|
void setPedestalMode(const defs::pedestalParameters par,
|
||||||
|
Positions pos = {});
|
||||||
|
|
||||||
///@}
|
///@}
|
||||||
|
|
||||||
/** @name Gotthard Specific */
|
/** @name Gotthard Specific */
|
||||||
@ -1615,21 +1632,21 @@ class Detector {
|
|||||||
/** [CTB] in MHZ */
|
/** [CTB] in MHZ */
|
||||||
Result<int> getSYNCClock(Positions pos = {}) const;
|
Result<int> getSYNCClock(Positions pos = {}) const;
|
||||||
|
|
||||||
/** gets list of voltage enums */
|
/** gets list of power enums */
|
||||||
std::vector<defs::dacIndex> getVoltageList() const;
|
std::vector<defs::dacIndex> getPowerList() const;
|
||||||
|
|
||||||
/** gets list of slow adc enums */
|
/** gets list of slow adc enums */
|
||||||
std::vector<defs::dacIndex> getSlowADCList() const;
|
std::vector<defs::dacIndex> getSlowADCList() const;
|
||||||
|
|
||||||
/** [CTB] */
|
/** [CTB] */
|
||||||
Result<int> getVoltage(defs::dacIndex index, Positions pos = {}) const;
|
Result<int> getPower(defs::dacIndex index, Positions pos = {}) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [CTB] mV
|
* [CTB] mV
|
||||||
* [Ctb] Options: V_LIMIT, V_POWER_A, V_POWER_B, V_POWER_C,
|
* [Ctb] Options: V_LIMIT, V_POWER_A, V_POWER_B, V_POWER_C,
|
||||||
* V_POWER_D, V_POWER_IO, V_POWER_CHIP
|
* V_POWER_D, V_POWER_IO, V_POWER_CHIP
|
||||||
*/
|
*/
|
||||||
void setVoltage(defs::dacIndex index, int value, Positions pos = {});
|
void setPower(defs::dacIndex index, int value, Positions pos = {});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [CTB] Options: [0- 4] or [1V, 1.14V, 1.33V, 1.6V, 2V]
|
* [CTB] Options: [0- 4] or [1V, 1.14V, 1.33V, 1.6V, 2V]
|
||||||
@ -1697,7 +1714,7 @@ class Detector {
|
|||||||
/**
|
/**
|
||||||
* [CTB] mV
|
* [CTB] mV
|
||||||
* Options: V_POWER_A, V_POWER_B, V_POWER_C, V_POWER_D, V_POWER_IO */
|
* Options: V_POWER_A, V_POWER_B, V_POWER_C, V_POWER_D, V_POWER_IO */
|
||||||
Result<int> getMeasuredVoltage(defs::dacIndex index,
|
Result<int> getMeasuredPower(defs::dacIndex index,
|
||||||
Positions pos = {}) const;
|
Positions pos = {}) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1792,19 +1809,19 @@ class Detector {
|
|||||||
std::string getSignalName(const int i) const;
|
std::string getSignalName(const int i) const;
|
||||||
|
|
||||||
/** [CTB] */
|
/** [CTB] */
|
||||||
void setVoltageNames(const std::vector<std::string> names);
|
void setPowerNames(const std::vector<std::string> names);
|
||||||
|
|
||||||
/** [CTB] */
|
/** [CTB] */
|
||||||
std::vector<std::string> getVoltageNames() const;
|
std::vector<std::string> getPowerNames() const;
|
||||||
|
|
||||||
/** [CTB] */
|
/** [CTB] */
|
||||||
defs::dacIndex getVoltageIndex(const std::string &name) const;
|
defs::dacIndex getPowerIndex(const std::string &name) const;
|
||||||
|
|
||||||
/** [CTB] */
|
/** [CTB] */
|
||||||
void setVoltageName(const defs::dacIndex i, const std::string &name);
|
void setPowerName(const defs::dacIndex i, const std::string &name);
|
||||||
|
|
||||||
/** [CTB] */
|
/** [CTB] */
|
||||||
std::string getVoltageName(const defs::dacIndex i) const;
|
std::string getPowerName(const defs::dacIndex i) const;
|
||||||
|
|
||||||
/** [CTB] */
|
/** [CTB] */
|
||||||
void setSlowADCNames(const std::vector<std::string> names);
|
void setSlowADCNames(const std::vector<std::string> names);
|
||||||
@ -2068,18 +2085,18 @@ class Detector {
|
|||||||
* *
|
* *
|
||||||
* ************************************************/
|
* ************************************************/
|
||||||
|
|
||||||
Result<int> getControlPort(Positions pos = {}) const;
|
Result<uint16_t> getControlPort(Positions pos = {}) const;
|
||||||
|
|
||||||
/** Detector Control TCP port (for client communication with Detector
|
/** Detector Control TCP port (for client communication with Detector
|
||||||
* control server) Default is 1952. Normally unchanged. Set different ports
|
* control server) Default is 1952. Normally unchanged. Set different ports
|
||||||
* for virtual servers on same pc */
|
* for virtual servers on same pc */
|
||||||
void setControlPort(int value, Positions pos = {});
|
void setControlPort(uint16_t value, Positions pos = {});
|
||||||
|
|
||||||
Result<int> getStopPort(Positions pos = {}) const;
|
Result<uint16_t> getStopPort(Positions pos = {}) const;
|
||||||
|
|
||||||
/** Port number of the stop server on detector for detector-client tcp
|
/** Port number of the stop server on detector for detector-client tcp
|
||||||
* interface. Default is 1953. Normally unchanged. */
|
* interface. Default is 1953. Normally unchanged. */
|
||||||
void setStopPort(int value, Positions pos = {});
|
void setStopPort(uint16_t value, Positions pos = {});
|
||||||
|
|
||||||
Result<bool> getDetectorLock(Positions pos = {}) const;
|
Result<bool> getDetectorLock(Positions pos = {}) const;
|
||||||
|
|
||||||
@ -2112,7 +2129,7 @@ class Detector {
|
|||||||
///@}
|
///@}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<int> getPortNumbers(int start_port);
|
std::vector<uint16_t> getValidPortNumbers(uint16_t start_port);
|
||||||
void updateRxRateCorrections();
|
void updateRxRateCorrections();
|
||||||
void setNumberofUDPInterfaces_(int n, Positions pos);
|
void setNumberofUDPInterfaces_(int n, Positions pos);
|
||||||
};
|
};
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
* from the detector. Since every module could have a different value, we need
|
* from the detector. Since every module could have a different value, we need
|
||||||
* to return a vector instead of just a single value.
|
* to return a vector instead of just a single value.
|
||||||
*
|
*
|
||||||
* Easy conversions to single values are provided using the squash method.
|
* Easy conversions to single values are provided using the squash and tsquash
|
||||||
|
* method.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -16,6 +17,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "sls/ToString.h"
|
#include "sls/ToString.h"
|
||||||
|
#include "sls/TypeTraits.h"
|
||||||
#include "sls/container_utils.h"
|
#include "sls/container_utils.h"
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
@ -128,6 +130,25 @@ template <class T, class Allocator = std::allocator<T>> class Result {
|
|||||||
/** Test whether all elements of the result are equal */
|
/** Test whether all elements of the result are equal */
|
||||||
bool equal() const noexcept { return allEqual(vec); }
|
bool equal() const noexcept { return allEqual(vec); }
|
||||||
|
|
||||||
|
/** Test whether any element of the result are equal to a value */
|
||||||
|
bool any(const T &value) const noexcept { return anyEqualTo(vec, value); }
|
||||||
|
|
||||||
|
template <typename V, typename... Args, typename = AllSame<V, Args...>>
|
||||||
|
typename std::enable_if<std::is_same<V, T>::value, bool>::type
|
||||||
|
contains_only(const V &a, const Args &...args) const noexcept {
|
||||||
|
auto values = {a, args...};
|
||||||
|
for (const auto &element : vec) {
|
||||||
|
int found = 0;
|
||||||
|
for (const auto &value : values) {
|
||||||
|
if (value == element)
|
||||||
|
found++;
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/** Convert Result<T> to std::vector<T> */
|
/** Convert Result<T> to std::vector<T> */
|
||||||
operator std::vector<T>() { return vec; }
|
operator std::vector<T>() { return vec; }
|
||||||
};
|
};
|
||||||
|
@ -197,7 +197,7 @@ std::string CmdProxy::VirtualServer(int action) {
|
|||||||
throw RuntimeError("Cannot execute this at module level");
|
throw RuntimeError("Cannot execute this at module level");
|
||||||
}
|
}
|
||||||
det->setVirtualDetectorServers(StringTo<int>(args[0]),
|
det->setVirtualDetectorServers(StringTo<int>(args[0]),
|
||||||
StringTo<int>(args[1]));
|
StringTo<uint16_t>(args[1]));
|
||||||
os << ToString(args);
|
os << ToString(args);
|
||||||
} else {
|
} else {
|
||||||
throw RuntimeError("Unknown action");
|
throw RuntimeError("Unknown action");
|
||||||
@ -2105,6 +2105,55 @@ std::string CmdProxy::TemperatureEvent(int action) {
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CmdProxy::PedestalMode(int action) {
|
||||||
|
std::ostringstream os;
|
||||||
|
os << cmd << ' ';
|
||||||
|
if (action == defs::HELP_ACTION) {
|
||||||
|
os << " [frames<uint8_t>] [loops<uint16_t>]\n\t\t[Jungfrau] "
|
||||||
|
"Enable pedestal mode. \n\t\tThe number of frames or triggers is "
|
||||||
|
"overwritten by: \n\t\t(#pedestal_frames x #pedestal_loops x 2). "
|
||||||
|
"\n\t\tIn auto timing mode or in trigger mode with #frames > 1, "
|
||||||
|
"\n\t\t#frames is overwritten and #triggers = 1, \n\t\telse "
|
||||||
|
"#triggers is overwritten and #frames = 1. \n\t\tOne cannot set "
|
||||||
|
"#frames, #triggers or timing mode in pedestal mode (exception "
|
||||||
|
"thrown).\n\n";
|
||||||
|
os << cmd
|
||||||
|
<< " [0]\n\t\t[Jungfrau] Disable pedestal "
|
||||||
|
"mode.\n\t\tDisabling pedestal mode will set back the normal "
|
||||||
|
"mode values of #frames and #triggers."
|
||||||
|
<< '\n';
|
||||||
|
} else if (action == defs::GET_ACTION) {
|
||||||
|
if (args.size() != 0) {
|
||||||
|
WrongNumberOfParameters(0);
|
||||||
|
}
|
||||||
|
auto t = det->getPedestalMode(std::vector<int>{det_id});
|
||||||
|
os << OutString(t) << '\n';
|
||||||
|
} else if (action == defs::PUT_ACTION) {
|
||||||
|
// disable
|
||||||
|
if (args.size() == 1) {
|
||||||
|
if (args[0] != "0") {
|
||||||
|
throw RuntimeError(
|
||||||
|
"Unknown argument " + args[0] +
|
||||||
|
". Did you mean '0' to disable pedestal mode?");
|
||||||
|
}
|
||||||
|
det->setPedestalMode(defs::pedestalParameters());
|
||||||
|
}
|
||||||
|
// enable
|
||||||
|
else if (args.size() == 2) {
|
||||||
|
uint8_t frames = StringTo<uint8_t>(args[0]);
|
||||||
|
uint16_t loops = StringTo<uint16_t>(args[1]);
|
||||||
|
det->setPedestalMode(defs::pedestalParameters(frames, loops));
|
||||||
|
} else {
|
||||||
|
throw RuntimeError(
|
||||||
|
"Invalid number of parareters for this command.");
|
||||||
|
}
|
||||||
|
os << ToString(args) << '\n';
|
||||||
|
} else {
|
||||||
|
throw RuntimeError("Unknown action");
|
||||||
|
}
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
|
|
||||||
/* Gotthard Specific */
|
/* Gotthard Specific */
|
||||||
|
|
||||||
std::string CmdProxy::ROI(int action) {
|
std::string CmdProxy::ROI(int action) {
|
||||||
@ -2670,7 +2719,7 @@ std::string CmdProxy::SlowADC(int action) {
|
|||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[n_channel (0-7 for channel]\n\t[Ctb] Slow "
|
os << "[n_channel (0-7 for channel]\n\t[Ctb] Slow "
|
||||||
"ADC channel in uV"
|
"ADC channel in mV"
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
|
@ -187,7 +187,6 @@ namespace sls {
|
|||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/** int or enum */
|
|
||||||
#define INTEGER_COMMAND_VEC_ID_GET(CMDNAME, GETFCN, SETFCN, CONV, HLPSTR) \
|
#define INTEGER_COMMAND_VEC_ID_GET(CMDNAME, GETFCN, SETFCN, CONV, HLPSTR) \
|
||||||
std::string CMDNAME(const int action) { \
|
std::string CMDNAME(const int action) { \
|
||||||
std::ostringstream os; \
|
std::ostringstream os; \
|
||||||
@ -1054,10 +1053,10 @@ class CmdProxy {
|
|||||||
{"signallist", &CmdProxy::signallist},
|
{"signallist", &CmdProxy::signallist},
|
||||||
{"signalname", &CmdProxy::signalname},
|
{"signalname", &CmdProxy::signalname},
|
||||||
{"signalindex", &CmdProxy::signalindex},
|
{"signalindex", &CmdProxy::signalindex},
|
||||||
{"voltagelist", &CmdProxy::voltagelist},
|
{"powerlist", &CmdProxy::powerlist},
|
||||||
{"voltagename", &CmdProxy::voltagename},
|
{"powername", &CmdProxy::powername},
|
||||||
{"voltageindex", &CmdProxy::voltageindex},
|
{"powerindex", &CmdProxy::powerindex},
|
||||||
{"voltagevalues", &CmdProxy::voltagevalues},
|
{"powervalues", &CmdProxy::powervalues},
|
||||||
{"slowadclist", &CmdProxy::slowadclist},
|
{"slowadclist", &CmdProxy::slowadclist},
|
||||||
{"slowadcname", &CmdProxy::slowadcname},
|
{"slowadcname", &CmdProxy::slowadcname},
|
||||||
{"slowadcindex", &CmdProxy::slowadcindex},
|
{"slowadcindex", &CmdProxy::slowadcindex},
|
||||||
@ -1188,6 +1187,7 @@ class CmdProxy {
|
|||||||
{"storagecell_delay", &CmdProxy::storagecell_delay},
|
{"storagecell_delay", &CmdProxy::storagecell_delay},
|
||||||
{"gainmode", &CmdProxy::gainmode},
|
{"gainmode", &CmdProxy::gainmode},
|
||||||
{"filtercells", &CmdProxy::filtercells},
|
{"filtercells", &CmdProxy::filtercells},
|
||||||
|
{"pedestalmode", &CmdProxy::PedestalMode},
|
||||||
|
|
||||||
/* Gotthard Specific */
|
/* Gotthard Specific */
|
||||||
{"roi", &CmdProxy::ROI},
|
{"roi", &CmdProxy::ROI},
|
||||||
@ -1400,6 +1400,7 @@ class CmdProxy {
|
|||||||
std::string DataStream(int action);
|
std::string DataStream(int action);
|
||||||
/* Jungfrau Specific */
|
/* Jungfrau Specific */
|
||||||
std::string TemperatureEvent(int action);
|
std::string TemperatureEvent(int action);
|
||||||
|
std::string PedestalMode(int action);
|
||||||
/* Gotthard Specific */
|
/* Gotthard Specific */
|
||||||
std::string ROI(int action);
|
std::string ROI(int action);
|
||||||
/* Gotthard2 Specific */
|
/* Gotthard2 Specific */
|
||||||
@ -1542,7 +1543,9 @@ class CmdProxy {
|
|||||||
INTEGER_COMMAND_SET_NOID_GET_ID(
|
INTEGER_COMMAND_SET_NOID_GET_ID(
|
||||||
sync, getSynchronization, setSynchronization, StringTo<int>,
|
sync, getSynchronization, setSynchronization, StringTo<int>,
|
||||||
"[0, 1]\n\t[Jungfrau][Moench] Enables or disables "
|
"[0, 1]\n\t[Jungfrau][Moench] Enables or disables "
|
||||||
"synchronization between modules.");
|
"synchronization between modules. Sync mode requires at least one "
|
||||||
|
"master configured. Also requires flatband cabling between master and "
|
||||||
|
"slave with termination board.");
|
||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID(row, getRow, setRow, StringTo<int>,
|
INTEGER_COMMAND_VEC_ID(row, getRow, setRow, StringTo<int>,
|
||||||
"[value]\n\tSet Detector row (udp header) to value. "
|
"[value]\n\tSet Detector row (udp header) to value. "
|
||||||
@ -1778,22 +1781,21 @@ class CmdProxy {
|
|||||||
"[name] \n\t\t[ChipTestBoard] Get "
|
"[name] \n\t\t[ChipTestBoard] Get "
|
||||||
"the signal index for the given name.");
|
"the signal index for the given name.");
|
||||||
|
|
||||||
CTB_NAMED_LIST(voltagelist, getVoltageNames, setVoltageNames,
|
CTB_NAMED_LIST(powerlist, getPowerNames, setPowerNames,
|
||||||
"[voltagename1 voltagename2 .. voltagename4] "
|
"[powername1 powername2 .. powername4] "
|
||||||
"\n\t\t[ChipTestBoard] Set "
|
"\n\t\t[ChipTestBoard] Set "
|
||||||
"the list of voltage names for this board.");
|
"the list of power names for this board.");
|
||||||
|
|
||||||
CTB_SINGLE_DACNAME(voltagename, getVoltageName, setVoltageName,
|
CTB_SINGLE_DACNAME(powername, getPowerName, setPowerName, defs::V_POWER_A,
|
||||||
defs::V_POWER_A,
|
|
||||||
"[0-4][name] \n\t\t[ChipTestBoard] Set "
|
"[0-4][name] \n\t\t[ChipTestBoard] Set "
|
||||||
"the voltage at the given position to the given name.");
|
"the power at the given position to the given name.");
|
||||||
|
|
||||||
CTB_GET_DACINDEX(voltageindex, getVoltageIndex, defs::V_POWER_A,
|
CTB_GET_DACINDEX(powerindex, getPowerIndex, defs::V_POWER_A,
|
||||||
"[name] \n\t\t[ChipTestBoard] Get "
|
"[name] \n\t\t[ChipTestBoard] Get "
|
||||||
"the voltage index for the given name.");
|
"the power index for the given name.");
|
||||||
|
|
||||||
CTB_VALUES(voltagevalues, getVoltage, getVoltageList, getVoltageNames,
|
CTB_VALUES(powervalues, getPower, getPowerList, getPowerNames,
|
||||||
"[name] \n\t\t[ChipTestBoard] Get values of all voltages.");
|
"[name] \n\t\t[ChipTestBoard] Get values of all powers.");
|
||||||
|
|
||||||
CTB_VALUES(slowadcvalues, getSlowADC, getSlowADCList, getSlowADCNames,
|
CTB_VALUES(slowadcvalues, getSlowADC, getSlowADCList, getSlowADCNames,
|
||||||
"[name] \n\t\t[ChipTestBoard] Get values of all slow adcs.");
|
"[name] \n\t\t[ChipTestBoard] Get values of all slow adcs.");
|
||||||
@ -1976,14 +1978,14 @@ class CmdProxy {
|
|||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID_GET(
|
INTEGER_COMMAND_VEC_ID_GET(
|
||||||
udp_dstport, getDestinationUDPPort, setDestinationUDPPort,
|
udp_dstport, getDestinationUDPPort, setDestinationUDPPort,
|
||||||
StringTo<int>,
|
StringTo<uint16_t>,
|
||||||
"[n]\n\tPort number of the receiver (destination) udp "
|
"[n]\n\tPort number of the receiver (destination) udp "
|
||||||
"interface. Default is 50001. \n\tIf multi command, ports for each "
|
"interface. Default is 50001. \n\tIf multi command, ports for each "
|
||||||
"module is calculated (incremented by 1 if no 2nd interface)");
|
"module is calculated (incremented by 1 if no 2nd interface)");
|
||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID_GET(
|
INTEGER_COMMAND_VEC_ID_GET(
|
||||||
udp_dstport2, getDestinationUDPPort2, setDestinationUDPPort2,
|
udp_dstport2, getDestinationUDPPort2, setDestinationUDPPort2,
|
||||||
StringTo<int>,
|
StringTo<uint16_t>,
|
||||||
"[n]\n\t[Jungfrau][Moench][Eiger][Gotthard2] Port number of the "
|
"[n]\n\t[Jungfrau][Moench][Eiger][Gotthard2] Port number of the "
|
||||||
"receiver (destination) udp interface 2. Default is 50002. "
|
"receiver (destination) udp interface 2. Default is 50002. "
|
||||||
"\n\tIf multi command, ports for each module is calculated "
|
"\n\tIf multi command, ports for each module is calculated "
|
||||||
@ -2041,7 +2043,7 @@ class CmdProxy {
|
|||||||
/* Receiver Config */
|
/* Receiver Config */
|
||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID_GET(
|
INTEGER_COMMAND_VEC_ID_GET(
|
||||||
rx_tcpport, getRxPort, setRxPort, StringTo<int>,
|
rx_tcpport, getRxPort, setRxPort, StringTo<uint16_t>,
|
||||||
"[port]\n\tTCP port for client-receiver communication. Default is "
|
"[port]\n\tTCP port for client-receiver communication. Default is "
|
||||||
"1954. Must be different if multiple receivers on same pc. Must be "
|
"1954. Must be different if multiple receivers on same pc. Must be "
|
||||||
"first command to set a receiver parameter. Multi command will "
|
"first command to set a receiver parameter. Multi command will "
|
||||||
@ -2172,7 +2174,7 @@ class CmdProxy {
|
|||||||
"and then depending on the rx zmq frequency/ timer");
|
"and then depending on the rx zmq frequency/ timer");
|
||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID_GET(
|
INTEGER_COMMAND_VEC_ID_GET(
|
||||||
rx_zmqport, getRxZmqPort, setRxZmqPort, StringTo<int>,
|
rx_zmqport, getRxZmqPort, setRxZmqPort, StringTo<uint16_t>,
|
||||||
"[port]\n\tZmq port for data to be streamed out of the receiver. "
|
"[port]\n\tZmq port for data to be streamed out of the receiver. "
|
||||||
"Also restarts receiver zmq streaming if enabled. Default is 30001. "
|
"Also restarts receiver zmq streaming if enabled. Default is 30001. "
|
||||||
"Modified only when using an intermediate process between receiver and "
|
"Modified only when using an intermediate process between receiver and "
|
||||||
@ -2180,7 +2182,7 @@ class CmdProxy {
|
|||||||
"Multi command will automatically increment for individual modules.");
|
"Multi command will automatically increment for individual modules.");
|
||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID_GET(
|
INTEGER_COMMAND_VEC_ID_GET(
|
||||||
zmqport, getClientZmqPort, setClientZmqPort, StringTo<int>,
|
zmqport, getClientZmqPort, setClientZmqPort, StringTo<uint16_t>,
|
||||||
"[port]\n\tZmq port in client(gui) or intermediate process for "
|
"[port]\n\tZmq port in client(gui) or intermediate process for "
|
||||||
"data to be streamed to from receiver. Default connects to receiver "
|
"data to be streamed to from receiver. Default connects to receiver "
|
||||||
"zmq streaming out port (30001). Modified only when using an "
|
"zmq streaming out port (30001). Modified only when using an "
|
||||||
@ -2425,7 +2427,7 @@ class CmdProxy {
|
|||||||
GET_COMMAND(syncclk, getSYNCClock,
|
GET_COMMAND(syncclk, getSYNCClock,
|
||||||
"[n_clk in MHz]\n\t[Ctb] Sync clock in MHz.");
|
"[n_clk in MHz]\n\t[Ctb] Sync clock in MHz.");
|
||||||
|
|
||||||
INTEGER_IND_COMMAND(v_limit, getVoltage, setVoltage, StringTo<int>,
|
INTEGER_IND_COMMAND(v_limit, getPower, setPower, StringTo<int>,
|
||||||
defs::V_LIMIT,
|
defs::V_LIMIT,
|
||||||
"[n_value]\n\t[Ctb] Soft limit for power "
|
"[n_value]\n\t[Ctb] Soft limit for power "
|
||||||
"supplies (ctb only) and DACS in mV.");
|
"supplies (ctb only) and DACS in mV.");
|
||||||
@ -2467,47 +2469,43 @@ class CmdProxy {
|
|||||||
"[n_clk in MHz]\n\t[Ctb] Clock for latching the "
|
"[n_clk in MHz]\n\t[Ctb] Clock for latching the "
|
||||||
"digital bits in MHz.");
|
"digital bits in MHz.");
|
||||||
|
|
||||||
INTEGER_IND_COMMAND(v_a, getVoltage, setVoltage, StringTo<int>,
|
INTEGER_IND_COMMAND(v_a, getPower, setPower, StringTo<int>, defs::V_POWER_A,
|
||||||
defs::V_POWER_A,
|
"[n_value]\n\t[Ctb] Power supply a in mV.");
|
||||||
"[n_value]\n\t[Ctb] Voltage supply a in mV.");
|
|
||||||
|
|
||||||
INTEGER_IND_COMMAND(v_b, getVoltage, setVoltage, StringTo<int>,
|
INTEGER_IND_COMMAND(v_b, getPower, setPower, StringTo<int>, defs::V_POWER_B,
|
||||||
defs::V_POWER_B,
|
"[n_value]\n\t[Ctb] Power supply b in mV.");
|
||||||
"[n_value]\n\t[Ctb] Voltage supply b in mV.");
|
|
||||||
|
|
||||||
INTEGER_IND_COMMAND(v_c, getVoltage, setVoltage, StringTo<int>,
|
INTEGER_IND_COMMAND(v_c, getPower, setPower, StringTo<int>, defs::V_POWER_C,
|
||||||
defs::V_POWER_C,
|
"[n_value]\n\t[Ctb] Power supply c in mV.");
|
||||||
"[n_value]\n\t[Ctb] Voltage supply c in mV.");
|
|
||||||
|
|
||||||
INTEGER_IND_COMMAND(v_d, getVoltage, setVoltage, StringTo<int>,
|
INTEGER_IND_COMMAND(v_d, getPower, setPower, StringTo<int>, defs::V_POWER_D,
|
||||||
defs::V_POWER_D,
|
"[n_value]\n\t[Ctb] Power supply d in mV.");
|
||||||
"[n_value]\n\t[Ctb] Voltage supply d in mV.");
|
|
||||||
|
|
||||||
INTEGER_IND_COMMAND(
|
INTEGER_IND_COMMAND(
|
||||||
v_io, getVoltage, setVoltage, StringTo<int>, defs::V_POWER_IO,
|
v_io, getPower, setPower, StringTo<int>, defs::V_POWER_IO,
|
||||||
"[n_value]\n\t[Ctb] Voltage supply io in mV. Minimum 1200 mV. Must "
|
"[n_value]\n\t[Ctb] Power supply io in mV. Minimum 1200 mV. Must "
|
||||||
"be the first power regulator to be set after fpga reset (on-board "
|
"be the first power regulator to be set after fpga reset (on-board "
|
||||||
"detector server start up).");
|
"detector server start up).");
|
||||||
|
|
||||||
INTEGER_IND_COMMAND(
|
INTEGER_IND_COMMAND(
|
||||||
v_chip, getVoltage, setVoltage, StringTo<int>, defs::V_POWER_CHIP,
|
v_chip, getPower, setPower, StringTo<int>, defs::V_POWER_CHIP,
|
||||||
"[n_value]\n\t[Ctb] Voltage supply chip in mV. Do not use it "
|
"[n_value]\n\t[Ctb] Power supply chip in mV. Do not use it "
|
||||||
"unless "
|
"unless "
|
||||||
"you are completely sure you will not fry the board.");
|
"you are completely sure you will not fry the board.");
|
||||||
|
|
||||||
GET_IND_COMMAND(vm_a, getMeasuredVoltage, defs::V_POWER_A, "",
|
GET_IND_COMMAND(vm_a, getMeasuredPower, defs::V_POWER_A, "",
|
||||||
"\n\t[Ctb] Measured voltage of power supply a in mV.");
|
"\n\t[Ctb] Measured voltage of power supply a in mV.");
|
||||||
|
|
||||||
GET_IND_COMMAND(vm_b, getMeasuredVoltage, defs::V_POWER_B, "",
|
GET_IND_COMMAND(vm_b, getMeasuredPower, defs::V_POWER_B, "",
|
||||||
"\n\t[Ctb] Measured voltage of power supply b in mV.");
|
"\n\t[Ctb] Measured voltage of power supply b in mV.");
|
||||||
|
|
||||||
GET_IND_COMMAND(vm_c, getMeasuredVoltage, defs::V_POWER_C, "",
|
GET_IND_COMMAND(vm_c, getMeasuredPower, defs::V_POWER_C, "",
|
||||||
"\n\t[Ctb] Measured voltage of power supply c in mV.");
|
"\n\t[Ctb] Measured voltage of power supply c in mV.");
|
||||||
|
|
||||||
GET_IND_COMMAND(vm_d, getMeasuredVoltage, defs::V_POWER_D, "",
|
GET_IND_COMMAND(vm_d, getMeasuredPower, defs::V_POWER_D, "",
|
||||||
"\n\t[Ctb] Measured voltage of power supply d in mV.");
|
"\n\t[Ctb] Measured voltage of power supply d in mV.");
|
||||||
|
|
||||||
GET_IND_COMMAND(vm_io, getMeasuredVoltage, defs::V_POWER_IO, "",
|
GET_IND_COMMAND(vm_io, getMeasuredPower, defs::V_POWER_IO, "",
|
||||||
"\n\t[Ctb] Measured voltage of power supply io in mV.");
|
"\n\t[Ctb] Measured voltage of power supply io in mV.");
|
||||||
|
|
||||||
GET_IND_COMMAND(im_a, getMeasuredCurrent, defs::I_POWER_A, "",
|
GET_IND_COMMAND(im_a, getMeasuredCurrent, defs::I_POWER_A, "",
|
||||||
@ -2619,13 +2617,13 @@ class CmdProxy {
|
|||||||
/* Insignificant */
|
/* Insignificant */
|
||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID(
|
INTEGER_COMMAND_VEC_ID(
|
||||||
port, getControlPort, setControlPort, StringTo<int>,
|
port, getControlPort, setControlPort, StringTo<uint16_t>,
|
||||||
"[n]\n\tPort number of the control server on detector for "
|
"[n]\n\tPort number of the control server on detector for "
|
||||||
"detector-client tcp interface. Default is 1952. Normally unchanged. "
|
"detector-client tcp interface. Default is 1952. Normally unchanged. "
|
||||||
"Set different ports for virtual servers on same pc.");
|
"Set different ports for virtual servers on same pc.");
|
||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID(
|
INTEGER_COMMAND_VEC_ID(
|
||||||
stopport, getStopPort, setStopPort, StringTo<int>,
|
stopport, getStopPort, setStopPort, StringTo<uint16_t>,
|
||||||
"[n]\n\tPort number of the stop server on detector for detector-client "
|
"[n]\n\tPort number of the stop server on detector for detector-client "
|
||||||
"tcp interface. Default is 1953. Normally unchanged.");
|
"tcp interface. Default is 1953. Normally unchanged.");
|
||||||
|
|
||||||
|
@ -20,11 +20,11 @@ CtbConfig::CtbConfig() {
|
|||||||
for (size_t i = 0; i != num_signals; ++i) {
|
for (size_t i = 0; i != num_signals; ++i) {
|
||||||
setSignalName(i, "BIT" + ToString(i));
|
setSignalName(i, "BIT" + ToString(i));
|
||||||
}
|
}
|
||||||
setVoltageName(0, "VA");
|
setPowerName(0, "VA");
|
||||||
setVoltageName(1, "VB");
|
setPowerName(1, "VB");
|
||||||
setVoltageName(2, "VC");
|
setPowerName(2, "VC");
|
||||||
setVoltageName(3, "VD");
|
setPowerName(3, "VD");
|
||||||
setVoltageName(4, "VIO");
|
setPowerName(4, "VIO");
|
||||||
for (size_t i = 0; i != num_slowADCs; ++i) {
|
for (size_t i = 0; i != num_slowADCs; ++i) {
|
||||||
setSlowADCName(i, "SLOWADC" + ToString(i));
|
setSlowADCName(i, "SLOWADC" + ToString(i));
|
||||||
}
|
}
|
||||||
@ -54,10 +54,10 @@ void CtbConfig::check_signal_index(size_t i) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CtbConfig::check_voltage_index(size_t i) const {
|
void CtbConfig::check_power_index(size_t i) const {
|
||||||
if (i >= num_voltages) {
|
if (i >= num_powers) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "Invalid Voltage index. Options: 0 - " << num_voltages
|
oss << "Invalid Power index. Options: 0 - " << num_powers
|
||||||
<< " or V_POWER_A - V_POWER_IO";
|
<< " or V_POWER_A - V_POWER_IO";
|
||||||
throw RuntimeError(oss.str());
|
throw RuntimeError(oss.str());
|
||||||
}
|
}
|
||||||
@ -176,33 +176,33 @@ std::vector<std::string> CtbConfig::getSignalNames() const {
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CtbConfig::setVoltageName(size_t index, const std::string &name) {
|
void CtbConfig::setPowerName(size_t index, const std::string &name) {
|
||||||
check_voltage_index(index);
|
check_power_index(index);
|
||||||
check_size(name);
|
check_size(name);
|
||||||
char *dst = &voltagenames[index * name_length];
|
char *dst = &powernames[index * name_length];
|
||||||
memset(dst, '\0', name_length);
|
memset(dst, '\0', name_length);
|
||||||
memcpy(dst, &name[0], name.size());
|
memcpy(dst, &name[0], name.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CtbConfig::setVoltageNames(const std::vector<std::string> &names) {
|
void CtbConfig::setPowerNames(const std::vector<std::string> &names) {
|
||||||
if (names.size() != num_voltages) {
|
if (names.size() != num_powers) {
|
||||||
throw RuntimeError("Voltage names need to be of size " +
|
throw RuntimeError("Power names need to be of size " +
|
||||||
std::to_string(num_voltages));
|
std::to_string(num_powers));
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i != num_voltages; ++i) {
|
for (size_t i = 0; i != num_powers; ++i) {
|
||||||
setVoltageName(i, names[i]);
|
setPowerName(i, names[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CtbConfig::getVoltageName(size_t index) const {
|
std::string CtbConfig::getPowerName(size_t index) const {
|
||||||
check_voltage_index(index);
|
check_power_index(index);
|
||||||
return voltagenames + index * name_length;
|
return powernames + index * name_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> CtbConfig::getVoltageNames() const {
|
std::vector<std::string> CtbConfig::getPowerNames() const {
|
||||||
std::vector<std::string> names;
|
std::vector<std::string> names;
|
||||||
for (size_t i = 0; i != num_voltages; ++i)
|
for (size_t i = 0; i != num_powers; ++i)
|
||||||
names.push_back(getVoltageName(i));
|
names.push_back(getPowerName(i));
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,19 +8,19 @@ class CtbConfig {
|
|||||||
static constexpr size_t num_dacs = 18;
|
static constexpr size_t num_dacs = 18;
|
||||||
static constexpr size_t num_adcs = 32;
|
static constexpr size_t num_adcs = 32;
|
||||||
static constexpr size_t num_signals = 64;
|
static constexpr size_t num_signals = 64;
|
||||||
static constexpr size_t num_voltages = 5;
|
static constexpr size_t num_powers = 5;
|
||||||
static constexpr size_t num_slowADCs = 8;
|
static constexpr size_t num_slowADCs = 8;
|
||||||
static constexpr const char *shm_tag_ = "ctbdacs";
|
static constexpr const char *shm_tag_ = "ctbdacs";
|
||||||
char dacnames[name_length * num_dacs]{};
|
char dacnames[name_length * num_dacs]{};
|
||||||
char adcnames[name_length * num_adcs]{};
|
char adcnames[name_length * num_adcs]{};
|
||||||
char signalnames[name_length * num_signals]{};
|
char signalnames[name_length * num_signals]{};
|
||||||
char voltagenames[name_length * num_voltages]{};
|
char powernames[name_length * num_powers]{};
|
||||||
char slowADCnames[name_length * num_slowADCs]{};
|
char slowADCnames[name_length * num_slowADCs]{};
|
||||||
|
|
||||||
void check_dac_index(size_t i) const;
|
void check_dac_index(size_t i) const;
|
||||||
void check_adc_index(size_t i) const;
|
void check_adc_index(size_t i) const;
|
||||||
void check_signal_index(size_t i) const;
|
void check_signal_index(size_t i) const;
|
||||||
void check_voltage_index(size_t i) const;
|
void check_power_index(size_t i) const;
|
||||||
void check_slow_adc_index(size_t i) const;
|
void check_slow_adc_index(size_t i) const;
|
||||||
void check_size(const std::string &name) const;
|
void check_size(const std::string &name) const;
|
||||||
|
|
||||||
@ -46,10 +46,10 @@ class CtbConfig {
|
|||||||
std::string getSignalName(size_t index) const;
|
std::string getSignalName(size_t index) const;
|
||||||
std::vector<std::string> getSignalNames() const;
|
std::vector<std::string> getSignalNames() const;
|
||||||
|
|
||||||
void setVoltageNames(const std::vector<std::string> &names);
|
void setPowerNames(const std::vector<std::string> &names);
|
||||||
void setVoltageName(size_t index, const std::string &name);
|
void setPowerName(size_t index, const std::string &name);
|
||||||
std::string getVoltageName(size_t index) const;
|
std::string getPowerName(size_t index) const;
|
||||||
std::vector<std::string> getVoltageNames() const;
|
std::vector<std::string> getPowerNames() const;
|
||||||
|
|
||||||
void setSlowADCNames(const std::vector<std::string> &names);
|
void setSlowADCNames(const std::vector<std::string> &names);
|
||||||
void setSlowADCName(size_t index, const std::string &name);
|
void setSlowADCName(size_t index, const std::string &name);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <set>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
@ -107,7 +108,9 @@ void Detector::setHostname(const std::vector<std::string> &hostname) {
|
|||||||
pimpl->setHostname(hostname);
|
pimpl->setHostname(hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setVirtualDetectorServers(int numServers, int startingPort) {
|
void Detector::setVirtualDetectorServers(int numServers,
|
||||||
|
uint16_t startingPort) {
|
||||||
|
validatePortRange(startingPort, numServers * 2);
|
||||||
pimpl->setVirtualDetectorServers(numServers, startingPort);
|
pimpl->setVirtualDetectorServers(numServers, startingPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -871,18 +874,26 @@ void Detector::startDetectorReadout() {
|
|||||||
|
|
||||||
void Detector::stopDetector(Positions pos) {
|
void Detector::stopDetector(Positions pos) {
|
||||||
|
|
||||||
// stop and check status X times
|
|
||||||
int retries{0};
|
int retries{0};
|
||||||
// avoid default construction of runStatus::IDLE on squash
|
auto status = getDetectorStatus(pos);
|
||||||
auto status = getDetectorStatus().squash(defs::runStatus::RUNNING);
|
|
||||||
while (status != defs::runStatus::IDLE &&
|
// jf sync fix: status [stopped or idle] = [stopped]
|
||||||
status != defs::runStatus::STOPPED) {
|
// sync issue: (master idle sometimes, slaves stopped)
|
||||||
if (status == defs::runStatus::ERROR) {
|
|
||||||
throw RuntimeError(
|
// eiger fix: stop multiple times from multi client till all modules stopped
|
||||||
"Could not stop detector. Returned error status.");
|
// issue: asynchronous start and stop scripts with a module being started
|
||||||
|
// (stop before) and waiting for the other to be done. So a module that was
|
||||||
|
// idle before stopping will return running (after async start script) when
|
||||||
|
// getting status after, which will then be stopped again.
|
||||||
|
|
||||||
|
while (!status.contains_only(defs::runStatus::IDLE,
|
||||||
|
defs::runStatus::STOPPED)) {
|
||||||
|
if (status.any(defs::runStatus::ERROR)) {
|
||||||
|
throw RuntimeError("Could not stop detector. At least one module "
|
||||||
|
"returned error status.");
|
||||||
}
|
}
|
||||||
pimpl->stopDetector(pos);
|
pimpl->stopDetector(pos);
|
||||||
status = getDetectorStatus().squash(defs::runStatus::RUNNING);
|
status = getDetectorStatus(pos);
|
||||||
++retries;
|
++retries;
|
||||||
|
|
||||||
if (retries == 10)
|
if (retries == 10)
|
||||||
@ -901,7 +912,7 @@ void Detector::stopDetector(Positions pos) {
|
|||||||
for (auto it : res) {
|
for (auto it : res) {
|
||||||
maxVal = std::max(maxVal, it);
|
maxVal = std::max(maxVal, it);
|
||||||
}
|
}
|
||||||
setNextFrameNumber(maxVal + 1);
|
setNextFrameNumber(maxVal + 1, pos);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
@ -982,10 +993,10 @@ void Detector::setNumberofUDPInterfaces_(int n, Positions pos) {
|
|||||||
throw RuntimeError("No modules added.");
|
throw RuntimeError("No modules added.");
|
||||||
}
|
}
|
||||||
bool previouslyClientStreaming = pimpl->getDataStreamingToClient();
|
bool previouslyClientStreaming = pimpl->getDataStreamingToClient();
|
||||||
int clientStartingPort = getClientZmqPort({0}).squash(0);
|
uint16_t clientStartingPort = getClientZmqPort({0}).squash(0);
|
||||||
bool useReceiver = getUseReceiverFlag().squash(false);
|
bool useReceiver = getUseReceiverFlag().squash(false);
|
||||||
bool previouslyReceiverStreaming = false;
|
bool previouslyReceiverStreaming = false;
|
||||||
int rxStartingPort = 0;
|
uint16_t rxStartingPort = 0;
|
||||||
if (useReceiver) {
|
if (useReceiver) {
|
||||||
previouslyReceiverStreaming = getRxZmqDataStream(pos).squash(true);
|
previouslyReceiverStreaming = getRxZmqDataStream(pos).squash(true);
|
||||||
rxStartingPort = getRxZmqPort({0}).squash(0);
|
rxStartingPort = getRxZmqPort({0}).squash(0);
|
||||||
@ -1108,34 +1119,36 @@ void Detector::setDestinationUDPMAC2(const MacAddr mac, Positions pos) {
|
|||||||
pimpl->Parallel(&Module::setDestinationUDPMAC2, pos, mac);
|
pimpl->Parallel(&Module::setDestinationUDPMAC2, pos, mac);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getDestinationUDPPort(Positions pos) const {
|
Result<uint16_t> Detector::getDestinationUDPPort(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getDestinationUDPPort, pos);
|
return pimpl->Parallel(&Module::getDestinationUDPPort, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setDestinationUDPPort(int port, int module_id) {
|
void Detector::setDestinationUDPPort(uint16_t port, int module_id) {
|
||||||
if (module_id == -1) {
|
if (module_id == -1) {
|
||||||
std::vector<int> port_list = getPortNumbers(port);
|
std::vector<uint16_t> port_list = getValidPortNumbers(port);
|
||||||
for (int idet = 0; idet < size(); ++idet) {
|
for (int idet = 0; idet < size(); ++idet) {
|
||||||
pimpl->Parallel(&Module::setDestinationUDPPort, {idet},
|
pimpl->Parallel(&Module::setDestinationUDPPort, {idet},
|
||||||
port_list[idet]);
|
port_list[idet]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
validatePortNumber(port);
|
||||||
pimpl->Parallel(&Module::setDestinationUDPPort, {module_id}, port);
|
pimpl->Parallel(&Module::setDestinationUDPPort, {module_id}, port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getDestinationUDPPort2(Positions pos) const {
|
Result<uint16_t> Detector::getDestinationUDPPort2(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getDestinationUDPPort2, pos);
|
return pimpl->Parallel(&Module::getDestinationUDPPort2, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setDestinationUDPPort2(int port, int module_id) {
|
void Detector::setDestinationUDPPort2(uint16_t port, int module_id) {
|
||||||
if (module_id == -1) {
|
if (module_id == -1) {
|
||||||
std::vector<int> port_list = getPortNumbers(port);
|
std::vector<uint16_t> port_list = getValidPortNumbers(port);
|
||||||
for (int idet = 0; idet < size(); ++idet) {
|
for (int idet = 0; idet < size(); ++idet) {
|
||||||
pimpl->Parallel(&Module::setDestinationUDPPort2, {idet},
|
pimpl->Parallel(&Module::setDestinationUDPPort2, {idet},
|
||||||
port_list[idet]);
|
port_list[idet]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
validatePortNumber(port);
|
||||||
pimpl->Parallel(&Module::setDestinationUDPPort2, {module_id}, port);
|
pimpl->Parallel(&Module::setDestinationUDPPort2, {module_id}, port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1235,21 +1248,23 @@ void Detector::setRxHostname(const std::vector<std::string> &name) {
|
|||||||
updateRxRateCorrections();
|
updateRxRateCorrections();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getRxPort(Positions pos) const {
|
Result<uint16_t> Detector::getRxPort(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getReceiverPort, pos);
|
return pimpl->Parallel(&Module::getReceiverPort, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setRxPort(int port, int module_id) {
|
void Detector::setRxPort(uint16_t port, int module_id) {
|
||||||
if (module_id == -1) {
|
if (module_id == -1) {
|
||||||
std::vector<int> port_list(size());
|
validatePortRange(port, size() - 1);
|
||||||
for (auto &it : port_list) {
|
|
||||||
it = port++;
|
std::vector<uint16_t> port_list(size());
|
||||||
}
|
std::iota(std::begin(port_list), std::end(port_list), port);
|
||||||
|
|
||||||
// no need to verify hostname-port combo as unique port(incremented)
|
// no need to verify hostname-port combo as unique port(incremented)
|
||||||
for (int idet = 0; idet < size(); ++idet) {
|
for (int idet = 0; idet < size(); ++idet) {
|
||||||
pimpl->Parallel(&Module::setReceiverPort, {idet}, port_list[idet]);
|
pimpl->Parallel(&Module::setReceiverPort, {idet}, port_list[idet]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
validatePortNumber(port);
|
||||||
pimpl->verifyUniqueRxHost(port, module_id);
|
pimpl->verifyUniqueRxHost(port, module_id);
|
||||||
pimpl->Parallel(&Module::setReceiverPort, {module_id}, port);
|
pimpl->Parallel(&Module::setReceiverPort, {module_id}, port);
|
||||||
}
|
}
|
||||||
@ -1440,20 +1455,21 @@ void Detector::setRxZmqStartingFrame(int fnum, Positions pos) {
|
|||||||
pimpl->Parallel(&Module::setReceiverStreamingStartingFrame, pos, fnum);
|
pimpl->Parallel(&Module::setReceiverStreamingStartingFrame, pos, fnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getRxZmqPort(Positions pos) const {
|
Result<uint16_t> Detector::getRxZmqPort(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getReceiverStreamingPort, pos);
|
return pimpl->Parallel(&Module::getReceiverStreamingPort, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setRxZmqPort(int port, int module_id) {
|
void Detector::setRxZmqPort(uint16_t port, int module_id) {
|
||||||
bool previouslyReceiverStreaming =
|
bool previouslyReceiverStreaming =
|
||||||
getRxZmqDataStream(std::vector<int>{module_id}).squash(false);
|
getRxZmqDataStream(std::vector<int>{module_id}).squash(false);
|
||||||
if (module_id == -1) {
|
if (module_id == -1) {
|
||||||
std::vector<int> port_list = getPortNumbers(port);
|
std::vector<uint16_t> port_list = getValidPortNumbers(port);
|
||||||
for (int idet = 0; idet < size(); ++idet) {
|
for (int idet = 0; idet < size(); ++idet) {
|
||||||
pimpl->Parallel(&Module::setReceiverStreamingPort, {idet},
|
pimpl->Parallel(&Module::setReceiverStreamingPort, {idet},
|
||||||
port_list[idet]);
|
port_list[idet]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
validatePortNumber(port);
|
||||||
pimpl->Parallel(&Module::setReceiverStreamingPort, {module_id}, port);
|
pimpl->Parallel(&Module::setReceiverStreamingPort, {module_id}, port);
|
||||||
}
|
}
|
||||||
if (previouslyReceiverStreaming) {
|
if (previouslyReceiverStreaming) {
|
||||||
@ -1475,19 +1491,20 @@ void Detector::setRxZmqIP(const IpAddr ip, Positions pos) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getClientZmqPort(Positions pos) const {
|
Result<uint16_t> Detector::getClientZmqPort(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getClientStreamingPort, pos);
|
return pimpl->Parallel(&Module::getClientStreamingPort, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setClientZmqPort(int port, int module_id) {
|
void Detector::setClientZmqPort(uint16_t port, int module_id) {
|
||||||
bool previouslyClientStreaming = pimpl->getDataStreamingToClient();
|
bool previouslyClientStreaming = pimpl->getDataStreamingToClient();
|
||||||
if (module_id == -1) {
|
if (module_id == -1) {
|
||||||
std::vector<int> port_list = getPortNumbers(port);
|
std::vector<uint16_t> port_list = getValidPortNumbers(port);
|
||||||
for (int idet = 0; idet < size(); ++idet) {
|
for (int idet = 0; idet < size(); ++idet) {
|
||||||
pimpl->Parallel(&Module::setClientStreamingPort, {idet},
|
pimpl->Parallel(&Module::setClientStreamingPort, {idet},
|
||||||
port_list[idet]);
|
port_list[idet]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
validatePortNumber(port);
|
||||||
pimpl->Parallel(&Module::setClientStreamingPort, {module_id}, port);
|
pimpl->Parallel(&Module::setClientStreamingPort, {module_id}, port);
|
||||||
}
|
}
|
||||||
if (previouslyClientStreaming) {
|
if (previouslyClientStreaming) {
|
||||||
@ -1752,6 +1769,16 @@ void Detector::setNumberOfFilterCells(int cell, Positions pos) {
|
|||||||
pimpl->Parallel(&Module::setNumberOfFilterCells, pos, cell);
|
pimpl->Parallel(&Module::setNumberOfFilterCells, pos, cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result<defs::pedestalParameters>
|
||||||
|
Detector::getPedestalMode(Positions pos) const {
|
||||||
|
return pimpl->Parallel(&Module::getPedestalMode, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Detector::setPedestalMode(const defs::pedestalParameters par,
|
||||||
|
Positions pos) {
|
||||||
|
pimpl->Parallel(&Module::setPedestalMode, pos, par);
|
||||||
|
}
|
||||||
|
|
||||||
// Gotthard Specific
|
// Gotthard Specific
|
||||||
|
|
||||||
Result<defs::ROI> Detector::getROI(Positions pos) const {
|
Result<defs::ROI> Detector::getROI(Positions pos) const {
|
||||||
@ -2051,9 +2078,9 @@ Result<int> Detector::getSYNCClock(Positions pos) const {
|
|||||||
return pimpl->Parallel(&Module::getClockFrequency, pos, defs::SYNC_CLOCK);
|
return pimpl->Parallel(&Module::getClockFrequency, pos, defs::SYNC_CLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<defs::dacIndex> Detector::getVoltageList() const {
|
std::vector<defs::dacIndex> Detector::getPowerList() const {
|
||||||
if (getDetectorType().squash() != defs::CHIPTESTBOARD) {
|
if (getDetectorType().squash() != defs::CHIPTESTBOARD) {
|
||||||
throw RuntimeError("Voltage list not implemented for this detector");
|
throw RuntimeError("Power list not implemented for this detector");
|
||||||
}
|
}
|
||||||
return std::vector<defs::dacIndex>{defs::V_POWER_A, defs::V_POWER_B,
|
return std::vector<defs::dacIndex>{defs::V_POWER_A, defs::V_POWER_B,
|
||||||
defs::V_POWER_C, defs::V_POWER_D,
|
defs::V_POWER_C, defs::V_POWER_D,
|
||||||
@ -2069,7 +2096,7 @@ std::vector<defs::dacIndex> Detector::getSlowADCList() const {
|
|||||||
defs::SLOW_ADC4, defs::SLOW_ADC5, defs::SLOW_ADC6, defs::SLOW_ADC7};
|
defs::SLOW_ADC4, defs::SLOW_ADC5, defs::SLOW_ADC6, defs::SLOW_ADC7};
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getVoltage(defs::dacIndex index, Positions pos) const {
|
Result<int> Detector::getPower(defs::dacIndex index, Positions pos) const {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case defs::V_LIMIT:
|
case defs::V_LIMIT:
|
||||||
case defs::V_POWER_A:
|
case defs::V_POWER_A:
|
||||||
@ -2080,12 +2107,12 @@ Result<int> Detector::getVoltage(defs::dacIndex index, Positions pos) const {
|
|||||||
case defs::V_POWER_CHIP:
|
case defs::V_POWER_CHIP:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw RuntimeError("Unknown Voltage Index");
|
throw RuntimeError("Unknown Power Index");
|
||||||
}
|
}
|
||||||
return pimpl->Parallel(&Module::getDAC, pos, index, true);
|
return pimpl->Parallel(&Module::getDAC, pos, index, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setVoltage(defs::dacIndex index, int value, Positions pos) {
|
void Detector::setPower(defs::dacIndex index, int value, Positions pos) {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case defs::V_LIMIT:
|
case defs::V_LIMIT:
|
||||||
case defs::V_POWER_A:
|
case defs::V_POWER_A:
|
||||||
@ -2096,7 +2123,7 @@ void Detector::setVoltage(defs::dacIndex index, int value, Positions pos) {
|
|||||||
case defs::V_POWER_CHIP:
|
case defs::V_POWER_CHIP:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw RuntimeError("Unknown Voltage Index");
|
throw RuntimeError("Unknown Power Index");
|
||||||
}
|
}
|
||||||
pimpl->Parallel(&Module::setDAC, pos, value, index, true);
|
pimpl->Parallel(&Module::setDAC, pos, value, index, true);
|
||||||
}
|
}
|
||||||
@ -2167,7 +2194,7 @@ void Detector::setDBITClock(int value_in_MHz, Positions pos) {
|
|||||||
value_in_MHz);
|
value_in_MHz);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getMeasuredVoltage(defs::dacIndex index,
|
Result<int> Detector::getMeasuredPower(defs::dacIndex index,
|
||||||
Positions pos) const {
|
Positions pos) const {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case defs::V_POWER_A:
|
case defs::V_POWER_A:
|
||||||
@ -2178,7 +2205,7 @@ Result<int> Detector::getMeasuredVoltage(defs::dacIndex index,
|
|||||||
case defs::V_POWER_CHIP:
|
case defs::V_POWER_CHIP:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw RuntimeError("Unknown Voltage Index");
|
throw RuntimeError("Unknown Power Index");
|
||||||
}
|
}
|
||||||
return pimpl->Parallel(&Module::getADC, pos, index);
|
return pimpl->Parallel(&Module::getADC, pos, index);
|
||||||
}
|
}
|
||||||
@ -2359,39 +2386,39 @@ std::string Detector::getSignalName(const int i) const {
|
|||||||
return pimpl->getCtbSignalName(i);
|
return pimpl->getCtbSignalName(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setVoltageNames(const std::vector<std::string> names) {
|
void Detector::setPowerNames(const std::vector<std::string> names) {
|
||||||
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
|
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
|
||||||
throw RuntimeError("Named powers only for CTB");
|
throw RuntimeError("Named powers only for CTB");
|
||||||
pimpl->setCtbVoltageNames(names);
|
pimpl->setCtbPowerNames(names);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> Detector::getVoltageNames() const {
|
std::vector<std::string> Detector::getPowerNames() const {
|
||||||
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
|
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
|
||||||
throw RuntimeError("Named powers only for CTB");
|
throw RuntimeError("Named powers only for CTB");
|
||||||
return pimpl->getCtbVoltageNames();
|
return pimpl->getCtbPowerNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
defs::dacIndex Detector::getVoltageIndex(const std::string &name) const {
|
defs::dacIndex Detector::getPowerIndex(const std::string &name) const {
|
||||||
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
|
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
|
||||||
throw RuntimeError("Named powers only for CTB");
|
throw RuntimeError("Named powers only for CTB");
|
||||||
auto names = getVoltageNames();
|
auto names = getPowerNames();
|
||||||
auto it = std::find(names.begin(), names.end(), name);
|
auto it = std::find(names.begin(), names.end(), name);
|
||||||
if (it == names.end())
|
if (it == names.end())
|
||||||
throw RuntimeError("Voltage name not found");
|
throw RuntimeError("Power name not found");
|
||||||
return static_cast<defs::dacIndex>(it - names.begin() + defs::V_POWER_A);
|
return static_cast<defs::dacIndex>(it - names.begin() + defs::V_POWER_A);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setVoltageName(const defs::dacIndex index,
|
void Detector::setPowerName(const defs::dacIndex index,
|
||||||
const std::string &name) {
|
const std::string &name) {
|
||||||
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
|
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
|
||||||
throw RuntimeError("Named powers only for CTB");
|
throw RuntimeError("Named powers only for CTB");
|
||||||
pimpl->setCtbVoltageName(index, name);
|
pimpl->setCtbPowerName(index, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Detector::getVoltageName(const defs::dacIndex i) const {
|
std::string Detector::getPowerName(const defs::dacIndex i) const {
|
||||||
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
|
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
|
||||||
throw RuntimeError("Named powers only for CTB");
|
throw RuntimeError("Named powers only for CTB");
|
||||||
return pimpl->getCtbVoltageName(i);
|
return pimpl->getCtbPowerName(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setSlowADCNames(const std::vector<std::string> names) {
|
void Detector::setSlowADCNames(const std::vector<std::string> names) {
|
||||||
@ -2665,21 +2692,23 @@ void Detector::setADCInvert(uint32_t value, Positions pos) {
|
|||||||
|
|
||||||
// Insignificant
|
// Insignificant
|
||||||
|
|
||||||
Result<int> Detector::getControlPort(Positions pos) const {
|
Result<uint16_t> Detector::getControlPort(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getControlPort, pos);
|
return pimpl->Parallel(&Module::getControlPort, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setControlPort(int value, Positions pos) {
|
void Detector::setControlPort(uint16_t value, Positions pos) {
|
||||||
|
validatePortNumber(value);
|
||||||
pimpl->verifyUniqueDetHost(value, pos);
|
pimpl->verifyUniqueDetHost(value, pos);
|
||||||
pimpl->Parallel(&Module::setControlPort, pos, value);
|
pimpl->Parallel(&Module::setControlPort, pos, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getStopPort(Positions pos) const {
|
Result<uint16_t> Detector::getStopPort(Positions pos) const {
|
||||||
// not verifying unique stop port (control port is sufficient)
|
// not verifying unique stop port (control port is sufficient)
|
||||||
return pimpl->Parallel(&Module::getStopPort, pos);
|
return pimpl->Parallel(&Module::getStopPort, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setStopPort(int value, Positions pos) {
|
void Detector::setStopPort(uint16_t value, Positions pos) {
|
||||||
|
validatePortNumber(value);
|
||||||
pimpl->Parallel(&Module::setStopPort, pos, value);
|
pimpl->Parallel(&Module::setStopPort, pos, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2714,13 +2743,17 @@ Result<ns> Detector::getMeasurementTime(Positions pos) const {
|
|||||||
|
|
||||||
std::string Detector::getUserDetails() const { return pimpl->getUserDetails(); }
|
std::string Detector::getUserDetails() const { return pimpl->getUserDetails(); }
|
||||||
|
|
||||||
std::vector<int> Detector::getPortNumbers(int start_port) {
|
std::vector<uint16_t> Detector::getValidPortNumbers(uint16_t start_port) {
|
||||||
int num_sockets_per_detector = getNumberofUDPInterfaces({}).tsquash(
|
int num_sockets_per_detector = getNumberofUDPInterfaces({}).tsquash(
|
||||||
"Number of UDP Interfaces is not consistent among modules");
|
"Number of UDP Interfaces is not consistent among modules");
|
||||||
std::vector<int> res;
|
|
||||||
|
validatePortRange(start_port, (size() - 1) * num_sockets_per_detector);
|
||||||
|
|
||||||
|
std::vector<uint16_t> res;
|
||||||
res.reserve(size());
|
res.reserve(size());
|
||||||
for (int idet = 0; idet < size(); ++idet) {
|
for (int idet = 0; idet < size(); ++idet) {
|
||||||
res.push_back(start_port + (idet * num_sockets_per_detector));
|
uint16_t port = start_port + (idet * num_sockets_per_detector);
|
||||||
|
res.push_back(port);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,8 @@ std::string DetectorImpl::exec(const char *cmd) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::setVirtualDetectorServers(const int numdet, const int port) {
|
void DetectorImpl::setVirtualDetectorServers(const int numdet,
|
||||||
|
const uint16_t port) {
|
||||||
std::vector<std::string> hostnames;
|
std::vector<std::string> hostnames;
|
||||||
for (int i = 0; i < numdet; ++i) {
|
for (int i = 0; i < numdet; ++i) {
|
||||||
// * 2 is for control and stop port
|
// * 2 is for control and stop port
|
||||||
@ -283,7 +284,7 @@ void DetectorImpl::addModule(const std::string &name) {
|
|||||||
LOG(logINFO) << "Adding module " << name;
|
LOG(logINFO) << "Adding module " << name;
|
||||||
auto host = verifyUniqueDetHost(name);
|
auto host = verifyUniqueDetHost(name);
|
||||||
std::string hostname = host.first;
|
std::string hostname = host.first;
|
||||||
int port = host.second;
|
uint16_t port = host.second;
|
||||||
|
|
||||||
// get type by connecting
|
// get type by connecting
|
||||||
detectorType type = Module::getTypeFromDetector(hostname, port);
|
detectorType type = Module::getTypeFromDetector(hostname, port);
|
||||||
@ -1219,10 +1220,26 @@ int DetectorImpl::acquire() {
|
|||||||
dataProcessingThread.join();
|
dataProcessingThread.join();
|
||||||
|
|
||||||
if (acquisition_finished != nullptr) {
|
if (acquisition_finished != nullptr) {
|
||||||
int status = Parallel(&Module::getRunStatus, {}).squash(ERROR);
|
// status
|
||||||
|
runStatus status = IDLE;
|
||||||
|
auto statusList = Parallel(&Module::getRunStatus, {});
|
||||||
|
status = statusList.squash(ERROR);
|
||||||
|
// difference, but none error
|
||||||
|
if (status == ERROR && (!statusList.any(ERROR))) {
|
||||||
|
// handle jf sync issue (master idle, slaves stopped)
|
||||||
|
if (statusList.contains_only(IDLE, STOPPED)) {
|
||||||
|
status = STOPPED;
|
||||||
|
} else
|
||||||
|
status = statusList.squash(RUNNING);
|
||||||
|
}
|
||||||
|
|
||||||
|
// progress
|
||||||
auto a = Parallel(&Module::getReceiverProgress, {});
|
auto a = Parallel(&Module::getReceiverProgress, {});
|
||||||
double progress = (*std::max_element(a.begin(), a.end()));
|
double progress = (*std::max_element(a.begin(), a.end()));
|
||||||
acquisition_finished(progress, status, acqFinished_p);
|
|
||||||
|
// callback
|
||||||
|
acquisition_finished(progress, static_cast<int>(status),
|
||||||
|
acqFinished_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
@ -1292,13 +1309,24 @@ void DetectorImpl::startAcquisition(const bool blocking, Positions pos) {
|
|||||||
std::vector<int> masters;
|
std::vector<int> masters;
|
||||||
std::vector<int> slaves;
|
std::vector<int> slaves;
|
||||||
getMasterSlaveList(pos, masters, slaves);
|
getMasterSlaveList(pos, masters, slaves);
|
||||||
|
if (masters.empty()) {
|
||||||
|
throw RuntimeError("Cannot start acquisition in sync mode. No "
|
||||||
|
"master module found");
|
||||||
|
}
|
||||||
if (!slaves.empty()) {
|
if (!slaves.empty()) {
|
||||||
Parallel(&Module::startAcquisition, slaves);
|
Parallel(&Module::startAcquisition, slaves);
|
||||||
}
|
}
|
||||||
if (!masters.empty()) {
|
if (blocking) {
|
||||||
Parallel((blocking ? &Module::startAndReadAll
|
Parallel(&Module::startAndReadAll, masters);
|
||||||
: &Module::startAcquisition),
|
// ensure all status normal (slaves not blocking)
|
||||||
masters);
|
// to catch those slaves that are still 'waiting'
|
||||||
|
auto status = Parallel(&Module::getRunStatus, pos);
|
||||||
|
if (!status.contains_only(IDLE, STOPPED, RUN_FINISHED)) {
|
||||||
|
throw RuntimeError("Acquisition not successful. "
|
||||||
|
"Unexpected detector status");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Parallel(&Module::startAcquisition, masters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// all in parallel
|
// all in parallel
|
||||||
@ -1583,41 +1611,41 @@ defs::xy DetectorImpl::calculatePosition(int moduleIndex,
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::verifyUniqueDetHost(const int port,
|
void DetectorImpl::verifyUniqueDetHost(const uint16_t port,
|
||||||
std::vector<int> positions) const {
|
std::vector<int> positions) const {
|
||||||
// port for given positions
|
// port for given positions
|
||||||
if (positions.empty() || (positions.size() == 1 && positions[0] == -1)) {
|
if (positions.empty() || (positions.size() == 1 && positions[0] == -1)) {
|
||||||
positions.resize(modules.size());
|
positions.resize(modules.size());
|
||||||
std::iota(begin(positions), end(positions), 0);
|
std::iota(begin(positions), end(positions), 0);
|
||||||
}
|
}
|
||||||
std::vector<std::pair<std::string, int>> hosts(size());
|
std::vector<std::pair<std::string, uint16_t>> hosts(size());
|
||||||
for (auto it : positions) {
|
for (auto it : positions) {
|
||||||
hosts[it].second = port;
|
hosts[it].second = port;
|
||||||
}
|
}
|
||||||
verifyUniqueHost(true, hosts);
|
verifyUniqueHost(true, hosts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::verifyUniqueRxHost(const int port,
|
void DetectorImpl::verifyUniqueRxHost(const uint16_t port,
|
||||||
const int moduleId) const {
|
const int moduleId) const {
|
||||||
std::vector<std::pair<std::string, int>> hosts(size());
|
std::vector<std::pair<std::string, uint16_t>> hosts(size());
|
||||||
hosts[moduleId].second = port;
|
hosts[moduleId].second = port;
|
||||||
verifyUniqueHost(false, hosts);
|
verifyUniqueHost(false, hosts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<std::string, int>
|
std::pair<std::string, uint16_t>
|
||||||
DetectorImpl::verifyUniqueDetHost(const std::string &name) {
|
DetectorImpl::verifyUniqueDetHost(const std::string &name) {
|
||||||
// extract port
|
// extract port
|
||||||
// C++17 could be auto [hostname, port] = ParseHostPort(name);
|
// C++17 could be auto [hostname, port] = ParseHostPort(name);
|
||||||
auto res = ParseHostPort(name);
|
auto res = ParseHostPort(name);
|
||||||
std::string hostname = res.first;
|
std::string hostname = res.first;
|
||||||
int port = res.second;
|
uint16_t port = res.second;
|
||||||
if (port == 0) {
|
if (port == 0) {
|
||||||
port = DEFAULT_TCP_CNTRL_PORTNO;
|
port = DEFAULT_TCP_CNTRL_PORTNO;
|
||||||
}
|
}
|
||||||
|
|
||||||
int detSize = size();
|
int detSize = size();
|
||||||
// mod not yet added
|
// mod not yet added
|
||||||
std::vector<std::pair<std::string, int>> hosts(detSize + 1);
|
std::vector<std::pair<std::string, uint16_t>> hosts(detSize + 1);
|
||||||
hosts[detSize].first = hostname;
|
hosts[detSize].first = hostname;
|
||||||
hosts[detSize].second = port;
|
hosts[detSize].second = port;
|
||||||
|
|
||||||
@ -1625,7 +1653,7 @@ DetectorImpl::verifyUniqueDetHost(const std::string &name) {
|
|||||||
return std::make_pair(hostname, port);
|
return std::make_pair(hostname, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<std::string, int>
|
std::pair<std::string, uint16_t>
|
||||||
DetectorImpl::verifyUniqueRxHost(const std::string &name,
|
DetectorImpl::verifyUniqueRxHost(const std::string &name,
|
||||||
std::vector<int> positions) const {
|
std::vector<int> positions) const {
|
||||||
// no checks if setting to none
|
// no checks if setting to none
|
||||||
@ -1636,7 +1664,7 @@ DetectorImpl::verifyUniqueRxHost(const std::string &name,
|
|||||||
// C++17 could be auto [hostname, port] = ParseHostPort(name);
|
// C++17 could be auto [hostname, port] = ParseHostPort(name);
|
||||||
auto res = ParseHostPort(name);
|
auto res = ParseHostPort(name);
|
||||||
std::string hostname = res.first;
|
std::string hostname = res.first;
|
||||||
int port = res.second;
|
uint16_t port = res.second;
|
||||||
|
|
||||||
// hostname and port for given positions
|
// hostname and port for given positions
|
||||||
if (positions.empty() || (positions.size() == 1 && positions[0] == -1)) {
|
if (positions.empty() || (positions.size() == 1 && positions[0] == -1)) {
|
||||||
@ -1644,7 +1672,7 @@ DetectorImpl::verifyUniqueRxHost(const std::string &name,
|
|||||||
std::iota(begin(positions), end(positions), 0);
|
std::iota(begin(positions), end(positions), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<std::string, int>> hosts(size());
|
std::vector<std::pair<std::string, uint16_t>> hosts(size());
|
||||||
for (auto it : positions) {
|
for (auto it : positions) {
|
||||||
hosts[it].first = hostname;
|
hosts[it].first = hostname;
|
||||||
hosts[it].second = port;
|
hosts[it].second = port;
|
||||||
@ -1654,7 +1682,7 @@ DetectorImpl::verifyUniqueRxHost(const std::string &name,
|
|||||||
return std::make_pair(hostname, port);
|
return std::make_pair(hostname, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<std::string, int>>
|
std::vector<std::pair<std::string, uint16_t>>
|
||||||
DetectorImpl::verifyUniqueRxHost(const std::vector<std::string> &names) const {
|
DetectorImpl::verifyUniqueRxHost(const std::vector<std::string> &names) const {
|
||||||
if ((int)names.size() != size()) {
|
if ((int)names.size() != size()) {
|
||||||
throw RuntimeError(
|
throw RuntimeError(
|
||||||
@ -1663,7 +1691,7 @@ DetectorImpl::verifyUniqueRxHost(const std::vector<std::string> &names) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// extract ports
|
// extract ports
|
||||||
std::vector<std::pair<std::string, int>> hosts;
|
std::vector<std::pair<std::string, uint16_t>> hosts;
|
||||||
for (const auto &name : names) {
|
for (const auto &name : names) {
|
||||||
hosts.push_back(ParseHostPort(name));
|
hosts.push_back(ParseHostPort(name));
|
||||||
}
|
}
|
||||||
@ -1673,7 +1701,7 @@ DetectorImpl::verifyUniqueRxHost(const std::vector<std::string> &names) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::verifyUniqueHost(
|
void DetectorImpl::verifyUniqueHost(
|
||||||
bool isDet, std::vector<std::pair<std::string, int>> &hosts) const {
|
bool isDet, std::vector<std::pair<std::string, uint16_t>> &hosts) const {
|
||||||
|
|
||||||
// fill from shm if not provided
|
// fill from shm if not provided
|
||||||
for (int i = 0; i != size(); ++i) {
|
for (int i = 0; i != size(); ++i) {
|
||||||
@ -1689,7 +1717,7 @@ void DetectorImpl::verifyUniqueHost(
|
|||||||
|
|
||||||
// remove the ones without a hostname
|
// remove the ones without a hostname
|
||||||
hosts.erase(std::remove_if(hosts.begin(), hosts.end(),
|
hosts.erase(std::remove_if(hosts.begin(), hosts.end(),
|
||||||
[](const std::pair<std::string, int> &x) {
|
[](const std::pair<std::string, uint16_t> &x) {
|
||||||
return (x.first == "none" ||
|
return (x.first == "none" ||
|
||||||
x.first.empty());
|
x.first.empty());
|
||||||
}),
|
}),
|
||||||
@ -2038,21 +2066,21 @@ void DetectorImpl::setCtbSignalName(const int index, const std::string &name) {
|
|||||||
ctb_shm()->setSignalName(index, name);
|
ctb_shm()->setSignalName(index, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> DetectorImpl::getCtbVoltageNames() const {
|
std::vector<std::string> DetectorImpl::getCtbPowerNames() const {
|
||||||
return ctb_shm()->getVoltageNames();
|
return ctb_shm()->getPowerNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::setCtbVoltageNames(const std::vector<std::string> &names) {
|
void DetectorImpl::setCtbPowerNames(const std::vector<std::string> &names) {
|
||||||
ctb_shm()->setVoltageNames(names);
|
ctb_shm()->setPowerNames(names);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DetectorImpl::getCtbVoltageName(const defs::dacIndex i) const {
|
std::string DetectorImpl::getCtbPowerName(const defs::dacIndex i) const {
|
||||||
return ctb_shm()->getVoltageName(static_cast<int>(i - defs::V_POWER_A));
|
return ctb_shm()->getPowerName(static_cast<int>(i - defs::V_POWER_A));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::setCtbVoltageName(const defs::dacIndex index,
|
void DetectorImpl::setCtbPowerName(const defs::dacIndex index,
|
||||||
const std::string &name) {
|
const std::string &name) {
|
||||||
ctb_shm()->setVoltageName(static_cast<int>(index - defs::V_POWER_A), name);
|
ctb_shm()->setPowerName(static_cast<int>(index - defs::V_POWER_A), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> DetectorImpl::getCtbSlowADCNames() const {
|
std::vector<std::string> DetectorImpl::getCtbSlowADCNames() const {
|
||||||
|
@ -220,7 +220,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
* @param numdet number of modules
|
* @param numdet number of modules
|
||||||
* @param port starting port number
|
* @param port starting port number
|
||||||
*/
|
*/
|
||||||
void setVirtualDetectorServers(const int numdet, const int port);
|
void setVirtualDetectorServers(const int numdet, const uint16_t port);
|
||||||
|
|
||||||
/** Sets the hostname of all sls modules in shared memory and updates
|
/** Sets the hostname of all sls modules in shared memory and updates
|
||||||
* local cache */
|
* local cache */
|
||||||
@ -307,14 +307,16 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
void setDefaultDac(defs::dacIndex index, int defaultValue,
|
void setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||||
defs::detectorSettings sett, Positions pos);
|
defs::detectorSettings sett, Positions pos);
|
||||||
|
|
||||||
void verifyUniqueDetHost(const int port, std::vector<int> positions) const;
|
void verifyUniqueDetHost(const uint16_t port,
|
||||||
void verifyUniqueRxHost(const int port, const int moduleId) const;
|
std::vector<int> positions) const;
|
||||||
|
void verifyUniqueRxHost(const uint16_t port, const int moduleId) const;
|
||||||
|
|
||||||
std::pair<std::string, int> verifyUniqueDetHost(const std::string &name);
|
std::pair<std::string, uint16_t>
|
||||||
std::pair<std::string, int>
|
verifyUniqueDetHost(const std::string &name);
|
||||||
|
std::pair<std::string, uint16_t>
|
||||||
verifyUniqueRxHost(const std::string &name,
|
verifyUniqueRxHost(const std::string &name,
|
||||||
std::vector<int> positions) const;
|
std::vector<int> positions) const;
|
||||||
std::vector<std::pair<std::string, int>>
|
std::vector<std::pair<std::string, uint16_t>>
|
||||||
verifyUniqueRxHost(const std::vector<std::string> &names) const;
|
verifyUniqueRxHost(const std::vector<std::string> &names) const;
|
||||||
|
|
||||||
defs::ROI getRxROI() const;
|
defs::ROI getRxROI() const;
|
||||||
@ -340,10 +342,10 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
void setCtbSignalNames(const std::vector<std::string> &names);
|
void setCtbSignalNames(const std::vector<std::string> &names);
|
||||||
void setCtbSignalName(const int index, const std::string &name);
|
void setCtbSignalName(const int index, const std::string &name);
|
||||||
|
|
||||||
std::vector<std::string> getCtbVoltageNames() const;
|
std::vector<std::string> getCtbPowerNames() const;
|
||||||
std::string getCtbVoltageName(const defs::dacIndex i) const;
|
std::string getCtbPowerName(const defs::dacIndex i) const;
|
||||||
void setCtbVoltageNames(const std::vector<std::string> &names);
|
void setCtbPowerNames(const std::vector<std::string> &names);
|
||||||
void setCtbVoltageName(const defs::dacIndex index, const std::string &name);
|
void setCtbPowerName(const defs::dacIndex index, const std::string &name);
|
||||||
|
|
||||||
std::vector<std::string> getCtbSlowADCNames() const;
|
std::vector<std::string> getCtbSlowADCNames() const;
|
||||||
std::string getCtbSlowADCName(const defs::dacIndex i) const;
|
std::string getCtbSlowADCName(const defs::dacIndex i) const;
|
||||||
@ -439,9 +441,8 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
defs::xy getPortGeometry() const;
|
defs::xy getPortGeometry() const;
|
||||||
defs::xy calculatePosition(int moduleIndex, defs::xy geometry) const;
|
defs::xy calculatePosition(int moduleIndex, defs::xy geometry) const;
|
||||||
|
|
||||||
void
|
void verifyUniqueHost(
|
||||||
verifyUniqueHost(bool isDet,
|
bool isDet, std::vector<std::pair<std::string, uint16_t>> &hosts) const;
|
||||||
std::vector<std::pair<std::string, int>> &hosts) const;
|
|
||||||
|
|
||||||
const int detectorIndex{0};
|
const int detectorIndex{0};
|
||||||
SharedMemory<sharedDetector> shm{0, -1};
|
SharedMemory<sharedDetector> shm{0, -1};
|
||||||
|
@ -165,11 +165,15 @@ std::string Module::getReceiverSoftwareVersion() const {
|
|||||||
|
|
||||||
// static function
|
// static function
|
||||||
slsDetectorDefs::detectorType
|
slsDetectorDefs::detectorType
|
||||||
Module::getTypeFromDetector(const std::string &hostname, int cport) {
|
Module::getTypeFromDetector(const std::string &hostname, uint16_t cport) {
|
||||||
LOG(logDEBUG1) << "Getting Module type ";
|
LOG(logDEBUG1) << "Getting Module type ";
|
||||||
ClientSocket socket("Detector", hostname, cport);
|
ClientSocket socket("Detector", hostname, cport);
|
||||||
socket.Send(F_GET_DETECTOR_TYPE);
|
socket.Send(F_GET_DETECTOR_TYPE);
|
||||||
socket.Receive<int>(); // TODO! Should we look at this OK/FAIL?
|
if (socket.Receive<int>() == FAIL) {
|
||||||
|
throw RuntimeError("Detector (" + hostname + ", " +
|
||||||
|
std::to_string(cport) +
|
||||||
|
") returned error at getting detector type");
|
||||||
|
}
|
||||||
auto retval = socket.Receive<detectorType>();
|
auto retval = socket.Receive<detectorType>();
|
||||||
LOG(logDEBUG1) << "Module type is " << retval;
|
LOG(logDEBUG1) << "Module type is " << retval;
|
||||||
return retval;
|
return retval;
|
||||||
@ -1241,22 +1245,22 @@ void Module::setDestinationUDPMAC2(const MacAddr mac) {
|
|||||||
sendToDetector(F_SET_DEST_UDP_MAC2, mac, nullptr);
|
sendToDetector(F_SET_DEST_UDP_MAC2, mac, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Module::getDestinationUDPPort() const {
|
uint16_t Module::getDestinationUDPPort() const {
|
||||||
return sendToDetector<int>(F_GET_DEST_UDP_PORT);
|
return sendToDetector<uint16_t>(F_GET_DEST_UDP_PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setDestinationUDPPort(const int port) {
|
void Module::setDestinationUDPPort(const uint16_t port) {
|
||||||
sendToDetector(F_SET_DEST_UDP_PORT, port, nullptr);
|
sendToDetector(F_SET_DEST_UDP_PORT, port, nullptr);
|
||||||
if (shm()->useReceiverFlag) {
|
if (shm()->useReceiverFlag) {
|
||||||
sendToReceiver(F_SET_RECEIVER_UDP_PORT, port, nullptr);
|
sendToReceiver(F_SET_RECEIVER_UDP_PORT, port, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Module::getDestinationUDPPort2() const {
|
uint16_t Module::getDestinationUDPPort2() const {
|
||||||
return sendToDetector<int>(F_GET_DEST_UDP_PORT2);
|
return sendToDetector<uint16_t>(F_GET_DEST_UDP_PORT2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setDestinationUDPPort2(const int port) {
|
void Module::setDestinationUDPPort2(const uint16_t port) {
|
||||||
sendToDetector(F_SET_DEST_UDP_PORT2, port, nullptr);
|
sendToDetector(F_SET_DEST_UDP_PORT2, port, nullptr);
|
||||||
if (shm()->useReceiverFlag) {
|
if (shm()->useReceiverFlag) {
|
||||||
sendToReceiver(F_SET_RECEIVER_UDP_PORT2, port, nullptr);
|
sendToReceiver(F_SET_RECEIVER_UDP_PORT2, port, nullptr);
|
||||||
@ -1354,7 +1358,8 @@ std::string Module::getReceiverHostname() const {
|
|||||||
return std::string(shm()->rxHostname);
|
return std::string(shm()->rxHostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setReceiverHostname(const std::string &hostname, const int port,
|
void Module::setReceiverHostname(const std::string &hostname,
|
||||||
|
const uint16_t port,
|
||||||
const bool initialChecks) {
|
const bool initialChecks) {
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -1427,13 +1432,10 @@ void Module::setReceiverHostname(const std::string &hostname, const int port,
|
|||||||
updateReceiverStreamingIP();
|
updateReceiverStreamingIP();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Module::getReceiverPort() const { return shm()->rxTCPPort; }
|
uint16_t Module::getReceiverPort() const { return shm()->rxTCPPort; }
|
||||||
|
|
||||||
int Module::setReceiverPort(int port_number) {
|
void Module::setReceiverPort(uint16_t port_number) {
|
||||||
if (port_number >= 0 && port_number != shm()->rxTCPPort) {
|
|
||||||
shm()->rxTCPPort = port_number;
|
shm()->rxTCPPort = port_number;
|
||||||
}
|
|
||||||
return shm()->rxTCPPort;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Module::getReceiverFifoDepth() const {
|
int Module::getReceiverFifoDepth() const {
|
||||||
@ -1645,11 +1647,11 @@ void Module::setReceiverStreamingStartingFrame(int fnum) {
|
|||||||
sendToReceiver(F_SET_RECEIVER_STREAMING_START_FNUM, fnum, nullptr);
|
sendToReceiver(F_SET_RECEIVER_STREAMING_START_FNUM, fnum, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Module::getReceiverStreamingPort() const {
|
uint16_t Module::getReceiverStreamingPort() const {
|
||||||
return sendToReceiver<int>(F_GET_RECEIVER_STREAMING_PORT);
|
return sendToReceiver<uint16_t>(F_GET_RECEIVER_STREAMING_PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setReceiverStreamingPort(int port) {
|
void Module::setReceiverStreamingPort(uint16_t port) {
|
||||||
sendToReceiver(F_SET_RECEIVER_STREAMING_PORT, port, nullptr);
|
sendToReceiver(F_SET_RECEIVER_STREAMING_PORT, port, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1668,9 +1670,9 @@ void Module::setReceiverStreamingIP(const IpAddr ip) {
|
|||||||
sendToReceiver(F_SET_RECEIVER_STREAMING_SRC_IP, ip, nullptr);
|
sendToReceiver(F_SET_RECEIVER_STREAMING_SRC_IP, ip, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Module::getClientStreamingPort() const { return shm()->zmqport; }
|
uint16_t Module::getClientStreamingPort() const { return shm()->zmqport; }
|
||||||
|
|
||||||
void Module::setClientStreamingPort(int port) { shm()->zmqport = port; }
|
void Module::setClientStreamingPort(uint16_t port) { shm()->zmqport = port; }
|
||||||
|
|
||||||
IpAddr Module::getClientStreamingIP() const { return shm()->zmqip; }
|
IpAddr Module::getClientStreamingIP() const { return shm()->zmqip; }
|
||||||
|
|
||||||
@ -1938,6 +1940,20 @@ void Module::setNumberOfFilterCells(int value) {
|
|||||||
sendToDetector(F_SET_NUM_FILTER_CELLS, value, nullptr);
|
sendToDetector(F_SET_NUM_FILTER_CELLS, value, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defs::pedestalParameters Module::getPedestalMode() const {
|
||||||
|
return sendToDetector<defs::pedestalParameters>(F_GET_PEDESTAL_MODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Module::setPedestalMode(const defs::pedestalParameters par) {
|
||||||
|
sendToDetector(F_SET_PEDESTAL_MODE, par, nullptr);
|
||||||
|
if (shm()->useReceiverFlag) {
|
||||||
|
auto value = getNumberOfFrames();
|
||||||
|
sendToReceiver(F_RECEIVER_SET_NUM_FRAMES, value, nullptr);
|
||||||
|
value = getNumberOfTriggers();
|
||||||
|
sendToReceiver(F_SET_RECEIVER_NUM_TRIGGERS, value, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Gotthard Specific
|
// Gotthard Specific
|
||||||
|
|
||||||
slsDetectorDefs::ROI Module::getROI() const {
|
slsDetectorDefs::ROI Module::getROI() const {
|
||||||
@ -2839,15 +2855,17 @@ void Module::setADCInvert(uint32_t value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Insignificant
|
// Insignificant
|
||||||
int Module::getControlPort() const { return shm()->controlPort; }
|
uint16_t Module::getControlPort() const { return shm()->controlPort; }
|
||||||
|
|
||||||
void Module::setControlPort(int port_number) {
|
void Module::setControlPort(uint16_t port_number) {
|
||||||
shm()->controlPort = port_number;
|
shm()->controlPort = port_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Module::getStopPort() const { return shm()->stopPort; }
|
uint16_t Module::getStopPort() const { return shm()->stopPort; }
|
||||||
|
|
||||||
void Module::setStopPort(int port_number) { shm()->stopPort = port_number; }
|
void Module::setStopPort(uint16_t port_number) {
|
||||||
|
shm()->stopPort = port_number;
|
||||||
|
}
|
||||||
|
|
||||||
bool Module::getLockDetector() const {
|
bool Module::getLockDetector() const {
|
||||||
return sendToDetector<int>(F_LOCK_SERVER, GET_FLAG);
|
return sendToDetector<int>(F_LOCK_SERVER, GET_FLAG);
|
||||||
@ -3928,8 +3946,8 @@ void Module::sendProgram(bool blackfin, std::vector<char> buffer,
|
|||||||
|
|
||||||
void Module::simulatingActivityinDetector(const std::string &functionType,
|
void Module::simulatingActivityinDetector(const std::string &functionType,
|
||||||
const int timeRequired) {
|
const int timeRequired) {
|
||||||
LOG(logINFO) << "(Simulating) " << functionType << " for module "
|
LOG(logINFO) << functionType << " for module " << moduleIndex << " ("
|
||||||
<< moduleIndex << " (" << shm()->hostname << ")";
|
<< shm()->hostname << ")";
|
||||||
printf("%d%%\r", 0);
|
printf("%d%%\r", 0);
|
||||||
std::cout << std::flush;
|
std::cout << std::flush;
|
||||||
const int ERASE_TIME = timeRequired;
|
const int ERASE_TIME = timeRequired;
|
||||||
|
@ -19,7 +19,7 @@ namespace sls {
|
|||||||
class ServerInterface;
|
class ServerInterface;
|
||||||
|
|
||||||
#define MODULE_SHMAPIVERSION 0x190726
|
#define MODULE_SHMAPIVERSION 0x190726
|
||||||
#define MODULE_SHMVERSION 0x200402
|
#define MODULE_SHMVERSION 0x230913
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @short structure allocated in shared memory to store Module settings for
|
* @short structure allocated in shared memory to store Module settings for
|
||||||
@ -36,8 +36,8 @@ struct sharedModule {
|
|||||||
/** END OF FIXED PATTERN -----------------------------------------------*/
|
/** END OF FIXED PATTERN -----------------------------------------------*/
|
||||||
|
|
||||||
slsDetectorDefs::xy numberOfModule;
|
slsDetectorDefs::xy numberOfModule;
|
||||||
int controlPort;
|
uint16_t controlPort;
|
||||||
int stopPort;
|
uint16_t stopPort;
|
||||||
char settingsDir[MAX_STR_LENGTH];
|
char settingsDir[MAX_STR_LENGTH];
|
||||||
/** list of the energies at which the Module has been trimmed */
|
/** list of the energies at which the Module has been trimmed */
|
||||||
StaticVector<int, MAX_TRIMEN> trimEnergies;
|
StaticVector<int, MAX_TRIMEN> trimEnergies;
|
||||||
@ -46,11 +46,11 @@ struct sharedModule {
|
|||||||
slsDetectorDefs::xy nChip;
|
slsDetectorDefs::xy nChip;
|
||||||
int nDacs;
|
int nDacs;
|
||||||
char rxHostname[MAX_STR_LENGTH];
|
char rxHostname[MAX_STR_LENGTH];
|
||||||
int rxTCPPort;
|
uint16_t rxTCPPort;
|
||||||
/** if rxHostname and rxTCPPort can be connected to */
|
/** if rxHostname and rxTCPPort can be connected to */
|
||||||
bool useReceiverFlag;
|
bool useReceiverFlag;
|
||||||
/** Listening tcp port from gui (only data) */
|
/** Listening tcp port from gui (only data) */
|
||||||
int zmqport;
|
uint16_t zmqport;
|
||||||
/** Listening tcp ip address from gui (only data) **/
|
/** Listening tcp ip address from gui (only data) **/
|
||||||
IpAddr zmqip;
|
IpAddr zmqip;
|
||||||
int numUDPInterfaces;
|
int numUDPInterfaces;
|
||||||
@ -102,7 +102,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
std::string getReceiverSoftwareVersion() const;
|
std::string getReceiverSoftwareVersion() const;
|
||||||
static detectorType
|
static detectorType
|
||||||
getTypeFromDetector(const std::string &hostname,
|
getTypeFromDetector(const std::string &hostname,
|
||||||
int cport = DEFAULT_TCP_CNTRL_PORTNO);
|
uint16_t cport = DEFAULT_TCP_CNTRL_PORTNO);
|
||||||
|
|
||||||
/** Get Detector type from shared memory */
|
/** Get Detector type from shared memory */
|
||||||
detectorType getDetectorType() const;
|
detectorType getDetectorType() const;
|
||||||
@ -261,10 +261,10 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
void setDestinationUDPMAC(const MacAddr mac);
|
void setDestinationUDPMAC(const MacAddr mac);
|
||||||
MacAddr getDestinationUDPMAC2() const;
|
MacAddr getDestinationUDPMAC2() const;
|
||||||
void setDestinationUDPMAC2(const MacAddr mac);
|
void setDestinationUDPMAC2(const MacAddr mac);
|
||||||
int getDestinationUDPPort() const;
|
uint16_t getDestinationUDPPort() const;
|
||||||
void setDestinationUDPPort(int udpport);
|
void setDestinationUDPPort(uint16_t udpport);
|
||||||
int getDestinationUDPPort2() const;
|
uint16_t getDestinationUDPPort2() const;
|
||||||
void setDestinationUDPPort2(int udpport);
|
void setDestinationUDPPort2(uint16_t udpport);
|
||||||
void reconfigureUDPDestination();
|
void reconfigureUDPDestination();
|
||||||
void validateUDPConfiguration();
|
void validateUDPConfiguration();
|
||||||
std::string printReceiverConfiguration();
|
std::string printReceiverConfiguration();
|
||||||
@ -286,10 +286,10 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
* ************************************************/
|
* ************************************************/
|
||||||
bool getUseReceiverFlag() const;
|
bool getUseReceiverFlag() const;
|
||||||
std::string getReceiverHostname() const;
|
std::string getReceiverHostname() const;
|
||||||
void setReceiverHostname(const std::string &hostname, const int port,
|
void setReceiverHostname(const std::string &hostname, const uint16_t port,
|
||||||
const bool initialChecks);
|
const bool initialChecks);
|
||||||
int getReceiverPort() const;
|
uint16_t getReceiverPort() const;
|
||||||
int setReceiverPort(int port_number);
|
void setReceiverPort(uint16_t port_number);
|
||||||
int getReceiverFifoDepth() const;
|
int getReceiverFifoDepth() const;
|
||||||
void setReceiverFifoDepth(int n_frames);
|
void setReceiverFifoDepth(int n_frames);
|
||||||
bool getReceiverSilentMode() const;
|
bool getReceiverSilentMode() const;
|
||||||
@ -349,12 +349,12 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
void setReceiverStreamingTimer(int time_in_ms = 200);
|
void setReceiverStreamingTimer(int time_in_ms = 200);
|
||||||
int getReceiverStreamingStartingFrame() const;
|
int getReceiverStreamingStartingFrame() const;
|
||||||
void setReceiverStreamingStartingFrame(int fnum);
|
void setReceiverStreamingStartingFrame(int fnum);
|
||||||
int getReceiverStreamingPort() const;
|
uint16_t getReceiverStreamingPort() const;
|
||||||
void setReceiverStreamingPort(int port);
|
void setReceiverStreamingPort(uint16_t port);
|
||||||
IpAddr getReceiverStreamingIP() const;
|
IpAddr getReceiverStreamingIP() const;
|
||||||
void setReceiverStreamingIP(const IpAddr ip);
|
void setReceiverStreamingIP(const IpAddr ip);
|
||||||
int getClientStreamingPort() const;
|
uint16_t getClientStreamingPort() const;
|
||||||
void setClientStreamingPort(int port);
|
void setClientStreamingPort(uint16_t port);
|
||||||
IpAddr getClientStreamingIP() const;
|
IpAddr getClientStreamingIP() const;
|
||||||
void setClientStreamingIP(const IpAddr ip);
|
void setClientStreamingIP(const IpAddr ip);
|
||||||
int getReceiverStreamingHwm() const;
|
int getReceiverStreamingHwm() const;
|
||||||
@ -419,6 +419,8 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
void setGainMode(const gainMode mode);
|
void setGainMode(const gainMode mode);
|
||||||
int getNumberOfFilterCells() const;
|
int getNumberOfFilterCells() const;
|
||||||
void setNumberOfFilterCells(int value);
|
void setNumberOfFilterCells(int value);
|
||||||
|
defs::pedestalParameters getPedestalMode() const;
|
||||||
|
void setPedestalMode(defs::pedestalParameters par);
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* *
|
* *
|
||||||
@ -597,10 +599,10 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
* Insignificant *
|
* Insignificant *
|
||||||
* *
|
* *
|
||||||
* ************************************************/
|
* ************************************************/
|
||||||
int getControlPort() const;
|
uint16_t getControlPort() const;
|
||||||
void setControlPort(int port_number);
|
void setControlPort(uint16_t port_number);
|
||||||
int getStopPort() const;
|
uint16_t getStopPort() const;
|
||||||
void setStopPort(int port_number);
|
void setStopPort(uint16_t port_number);
|
||||||
bool getLockDetector() const;
|
bool getLockDetector() const;
|
||||||
void setLockDetector(bool lock);
|
void setLockDetector(bool lock);
|
||||||
IpAddr getLastClientIP() const;
|
IpAddr getLastClientIP() const;
|
||||||
|
@ -261,15 +261,15 @@ TEST_CASE("signalindex", "[.cmd]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("voltagelist", "[.cmd]") {
|
TEST_CASE("powerlist", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
|
|
||||||
if (det_type == defs::CHIPTESTBOARD) {
|
if (det_type == defs::CHIPTESTBOARD) {
|
||||||
auto prev = det.getVoltageNames();
|
auto prev = det.getPowerNames();
|
||||||
|
|
||||||
REQUIRE_THROWS(proxy.Call("voltagelist", {"a", "s", "d"}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("powerlist", {"a", "s", "d"}, -1, PUT));
|
||||||
|
|
||||||
std::vector<std::string> names;
|
std::vector<std::string> names;
|
||||||
for (int iarg = 0; iarg != 5; ++iarg) {
|
for (int iarg = 0; iarg != 5; ++iarg) {
|
||||||
@ -277,94 +277,108 @@ TEST_CASE("voltagelist", "[.cmd]") {
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(proxy.Call("voltagelist", names, -1, PUT, oss));
|
REQUIRE_NOTHROW(proxy.Call("powerlist", names, -1, PUT, oss));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(proxy.Call("voltagelist", {}, -1, GET, oss));
|
REQUIRE_NOTHROW(proxy.Call("powerlist", {}, -1, GET, oss));
|
||||||
REQUIRE(oss.str() ==
|
REQUIRE(oss.str() ==
|
||||||
std::string("voltagelist ") + ToString(names) + '\n');
|
std::string("powerlist ") + ToString(names) + '\n');
|
||||||
}
|
}
|
||||||
det.setVoltageNames(prev);
|
det.setPowerNames(prev);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("voltagelist", {"a", "b"}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("powerlist", {"a", "b"}, -1, PUT));
|
||||||
REQUIRE_THROWS(proxy.Call("voltagelist", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("powerlist", {}, -1, GET));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("voltagename", "[.cmd]") {
|
TEST_CASE("powername", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
|
|
||||||
if (det_type == defs::CHIPTESTBOARD) {
|
if (det_type == defs::CHIPTESTBOARD) {
|
||||||
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::V_POWER_A);
|
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::V_POWER_A);
|
||||||
std::string str_voltage_index = "2";
|
std::string str_power_index = "2";
|
||||||
auto prev = det.getVoltageName(ind);
|
auto prev = det.getPowerName(ind);
|
||||||
|
|
||||||
// 1 arg throw
|
// 1 arg throw
|
||||||
REQUIRE_THROWS(proxy.Call("voltagename", {"2", "3", "bname"}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("powername", {"2", "3", "bname"}, -1, PUT));
|
||||||
// invalid index
|
// invalid index
|
||||||
REQUIRE_THROWS(proxy.Call("voltagename", {"5", "bname"}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("powername", {"5", "bname"}, -1, PUT));
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(proxy.Call(
|
REQUIRE_NOTHROW(proxy.Call("powername", {str_power_index, "bname"},
|
||||||
"voltagename", {str_voltage_index, "bname"}, -1, PUT, oss));
|
-1, PUT, oss));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(
|
REQUIRE_NOTHROW(
|
||||||
proxy.Call("voltagename", {str_voltage_index}, -1, GET, oss));
|
proxy.Call("powername", {str_power_index}, -1, GET, oss));
|
||||||
REQUIRE(oss.str() == std::string("voltagename ") +
|
REQUIRE(oss.str() ==
|
||||||
str_voltage_index + " bname\n");
|
std::string("powername ") + str_power_index + " bname\n");
|
||||||
}
|
}
|
||||||
det.setVoltageName(ind, prev);
|
det.setPowerName(ind, prev);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("voltagename", {"2", "b"}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("powername", {"2", "b"}, -1, PUT));
|
||||||
REQUIRE_THROWS(proxy.Call("voltagename", {"2"}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("powername", {"2"}, -1, GET));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("voltageindex", "[.cmd]") {
|
TEST_CASE("powerindex", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
|
|
||||||
if (det_type == defs::CHIPTESTBOARD) {
|
if (det_type == defs::CHIPTESTBOARD) {
|
||||||
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::V_POWER_A);
|
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::V_POWER_A);
|
||||||
std::string str_voltage_index = "2";
|
std::string str_power_index = "2";
|
||||||
|
|
||||||
// 1 arg throw
|
// 1 arg throw
|
||||||
REQUIRE_THROWS(proxy.Call("voltageindex", {"2", "2"}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("powerindex", {"2", "2"}, -1, PUT));
|
||||||
// invalid index
|
// invalid index
|
||||||
REQUIRE_THROWS(proxy.Call("voltageindex", {"5"}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("powerindex", {"5"}, -1, PUT));
|
||||||
auto voltagename = det.getVoltageName(ind);
|
auto powername = det.getPowerName(ind);
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(
|
REQUIRE_NOTHROW(
|
||||||
proxy.Call("voltageindex", {voltagename}, -1, GET, oss));
|
proxy.Call("powerindex", {powername}, -1, GET, oss));
|
||||||
REQUIRE(oss.str() ==
|
REQUIRE(oss.str() ==
|
||||||
std::string("voltageindex ") + str_voltage_index + '\n');
|
std::string("powerindex ") + str_power_index + '\n');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("voltageindex", {"2"}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("powerindex", {"2"}, -1, GET));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("voltagevalues", "[.cmd]") {
|
TEST_CASE("powervalues", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
REQUIRE_NOTHROW(proxy.Call("voltagevalues", {}, -1, GET));
|
|
||||||
REQUIRE_THROWS(proxy.Call("voltagevalues", {}, -1, PUT));
|
auto det_type = det.getDetectorType().squash();
|
||||||
|
|
||||||
|
if (det_type == defs::CHIPTESTBOARD) {
|
||||||
|
REQUIRE_NOTHROW(proxy.Call("powervalues", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("powervalues", {}, -1, PUT));
|
||||||
|
} else {
|
||||||
|
REQUIRE_THROWS(proxy.Call("powervalues", {}, -1, GET));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("slowadcvalues", "[.cmd]") {
|
TEST_CASE("slowadcvalues", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
|
|
||||||
|
auto det_type = det.getDetectorType().squash();
|
||||||
|
|
||||||
|
if (det_type == defs::CHIPTESTBOARD) {
|
||||||
REQUIRE_NOTHROW(proxy.Call("slowadcvalues", {}, -1, GET));
|
REQUIRE_NOTHROW(proxy.Call("slowadcvalues", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("slowadcvalues", {}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("slowadcvalues", {}, -1, PUT));
|
||||||
|
} else {
|
||||||
|
REQUIRE_THROWS(proxy.Call("slowadcvalues", {}, -1, GET));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("slowadclist", "[.cmd]") {
|
TEST_CASE("slowadclist", "[.cmd]") {
|
||||||
@ -733,7 +747,7 @@ TEST_CASE("v_limit", "[.cmd]") {
|
|||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
|
|
||||||
if (det_type == defs::CHIPTESTBOARD) {
|
if (det_type == defs::CHIPTESTBOARD) {
|
||||||
auto prev_val = det.getVoltage(defs::V_LIMIT);
|
auto prev_val = det.getPower(defs::V_LIMIT);
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("v_limit", {"1500"}, -1, PUT, oss);
|
proxy.Call("v_limit", {"1500"}, -1, PUT, oss);
|
||||||
@ -758,7 +772,7 @@ TEST_CASE("v_limit", "[.cmd]") {
|
|||||||
if (prev_val[i] == -100) {
|
if (prev_val[i] == -100) {
|
||||||
prev_val[i] = 0;
|
prev_val[i] = 0;
|
||||||
}
|
}
|
||||||
det.setVoltage(defs::V_LIMIT, prev_val[i], {i});
|
det.setPower(defs::V_LIMIT, prev_val[i], {i});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("v_limit", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("v_limit", {}, -1, GET));
|
||||||
@ -1006,7 +1020,7 @@ TEST_CASE("v_a", "[.cmd]") {
|
|||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::CHIPTESTBOARD) {
|
if (det_type == defs::CHIPTESTBOARD) {
|
||||||
auto prev_val = det.getVoltage(defs::V_POWER_A);
|
auto prev_val = det.getPower(defs::V_POWER_A);
|
||||||
{
|
{
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
proxy.Call("v_a", {"700"}, -1, PUT, oss1);
|
proxy.Call("v_a", {"700"}, -1, PUT, oss1);
|
||||||
@ -1015,7 +1029,7 @@ TEST_CASE("v_a", "[.cmd]") {
|
|||||||
REQUIRE(oss2.str() == "v_a 700\n");
|
REQUIRE(oss2.str() == "v_a 700\n");
|
||||||
}
|
}
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setVoltage(defs::V_POWER_A, prev_val[i], {i});
|
det.setPower(defs::V_POWER_A, prev_val[i], {i});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("v_a", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("v_a", {}, -1, GET));
|
||||||
@ -1027,7 +1041,7 @@ TEST_CASE("v_b", "[.cmd]") {
|
|||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::CHIPTESTBOARD) {
|
if (det_type == defs::CHIPTESTBOARD) {
|
||||||
auto prev_val = det.getVoltage(defs::V_POWER_B);
|
auto prev_val = det.getPower(defs::V_POWER_B);
|
||||||
{
|
{
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
proxy.Call("v_b", {"700"}, -1, PUT, oss1);
|
proxy.Call("v_b", {"700"}, -1, PUT, oss1);
|
||||||
@ -1036,7 +1050,7 @@ TEST_CASE("v_b", "[.cmd]") {
|
|||||||
REQUIRE(oss2.str() == "v_b 700\n");
|
REQUIRE(oss2.str() == "v_b 700\n");
|
||||||
}
|
}
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setVoltage(defs::V_POWER_B, prev_val[i], {i});
|
det.setPower(defs::V_POWER_B, prev_val[i], {i});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("v_b", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("v_b", {}, -1, GET));
|
||||||
@ -1048,7 +1062,7 @@ TEST_CASE("v_c", "[.cmd]") {
|
|||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::CHIPTESTBOARD) {
|
if (det_type == defs::CHIPTESTBOARD) {
|
||||||
auto prev_val = det.getVoltage(defs::V_POWER_C);
|
auto prev_val = det.getPower(defs::V_POWER_C);
|
||||||
{
|
{
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
proxy.Call("v_c", {"700"}, -1, PUT, oss1);
|
proxy.Call("v_c", {"700"}, -1, PUT, oss1);
|
||||||
@ -1057,7 +1071,7 @@ TEST_CASE("v_c", "[.cmd]") {
|
|||||||
REQUIRE(oss2.str() == "v_c 700\n");
|
REQUIRE(oss2.str() == "v_c 700\n");
|
||||||
}
|
}
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setVoltage(defs::V_POWER_C, prev_val[i], {i});
|
det.setPower(defs::V_POWER_C, prev_val[i], {i});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("v_c", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("v_c", {}, -1, GET));
|
||||||
@ -1069,7 +1083,7 @@ TEST_CASE("v_d", "[.cmd]") {
|
|||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::CHIPTESTBOARD) {
|
if (det_type == defs::CHIPTESTBOARD) {
|
||||||
auto prev_val = det.getVoltage(defs::V_POWER_D);
|
auto prev_val = det.getPower(defs::V_POWER_D);
|
||||||
{
|
{
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
proxy.Call("v_d", {"700"}, -1, PUT, oss1);
|
proxy.Call("v_d", {"700"}, -1, PUT, oss1);
|
||||||
@ -1078,7 +1092,7 @@ TEST_CASE("v_d", "[.cmd]") {
|
|||||||
REQUIRE(oss2.str() == "v_d 700\n");
|
REQUIRE(oss2.str() == "v_d 700\n");
|
||||||
}
|
}
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setVoltage(defs::V_POWER_D, prev_val[i], {i});
|
det.setPower(defs::V_POWER_D, prev_val[i], {i});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("v_d", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("v_d", {}, -1, GET));
|
||||||
|
@ -11,6 +11,26 @@ namespace sls {
|
|||||||
using test::GET;
|
using test::GET;
|
||||||
using test::PUT;
|
using test::PUT;
|
||||||
|
|
||||||
|
void test_valid_port(const std::string &command,
|
||||||
|
const std::vector<std::string> &arguments, int detector_id,
|
||||||
|
int action) {
|
||||||
|
Detector det;
|
||||||
|
CmdProxy proxy(&det);
|
||||||
|
|
||||||
|
std::vector<std::string> arg(arguments);
|
||||||
|
if (arg.empty())
|
||||||
|
arg.push_back("0");
|
||||||
|
|
||||||
|
int test_values[3] = {77797, -1, 0};
|
||||||
|
for (int i = 0; i != 3; ++i) {
|
||||||
|
int port_number = test_values[i];
|
||||||
|
arg[arg.size() - 1] = std::to_string(port_number);
|
||||||
|
REQUIRE_THROWS(proxy.Call(command, arg, detector_id, action));
|
||||||
|
/*REQUIRE_THROWS_WITH(proxy.Call(command, arguments, detector_id,
|
||||||
|
action), "Invalid port range. Must be between 1 - 65535.");*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void test_dac(defs::dacIndex index, const std::string &dacname, int dacvalue) {
|
void test_dac(defs::dacIndex index, const std::string &dacname, int dacvalue) {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
|
@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
|
void test_valid_port(const std::string &command,
|
||||||
|
const std::vector<std::string> &arguments, int detector_id,
|
||||||
|
int action);
|
||||||
|
|
||||||
void test_dac(slsDetectorDefs::dacIndex index, const std::string &dacname,
|
void test_dac(slsDetectorDefs::dacIndex index, const std::string &dacname,
|
||||||
int dacvalue);
|
int dacvalue);
|
||||||
void test_onchip_dac(slsDetectorDefs::dacIndex index,
|
void test_onchip_dac(slsDetectorDefs::dacIndex index,
|
||||||
|
@ -689,10 +689,11 @@ TEST_CASE("confadc", "[.cmd]") {
|
|||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
|
|
||||||
if (det_type == defs::GOTTHARD2) {
|
if (det_type == defs::GOTTHARD2) {
|
||||||
int ndet = det.size();
|
const int ndet = det.size();
|
||||||
int nchip = 10;
|
const int nchip = 10;
|
||||||
int nadc = 32;
|
const int nadc = 32;
|
||||||
int prev_val[ndet][nchip][nadc];
|
std::vector<std::vector<std::vector<int>>> prev_val(
|
||||||
|
ndet, std::vector<std::vector<int>>(nchip, std::vector<int>(nadc)));
|
||||||
for (int i = 0; i != ndet; ++i) {
|
for (int i = 0; i != ndet; ++i) {
|
||||||
for (int j = 0; j != nchip; ++j) {
|
for (int j = 0; j != nchip; ++j) {
|
||||||
for (int k = 0; k != nadc; ++k) {
|
for (int k = 0; k != nadc; ++k) {
|
||||||
|
@ -23,7 +23,7 @@ TEST_CASE("Setting and reading back Jungfrau dacs", "[.cmd][.dacs]") {
|
|||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
|
if (det_type == defs::JUNGFRAU) {
|
||||||
SECTION("vb_comp") { test_dac(defs::VB_COMP, "vb_comp", 1220); }
|
SECTION("vb_comp") { test_dac(defs::VB_COMP, "vb_comp", 1220); }
|
||||||
SECTION("vdd_prot") { test_dac(defs::VDD_PROT, "vdd_prot", 3000); }
|
SECTION("vdd_prot") { test_dac(defs::VDD_PROT, "vdd_prot", 3000); }
|
||||||
SECTION("vin_com") { test_dac(defs::VIN_COM, "vin_com", 1053); }
|
SECTION("vin_com") { test_dac(defs::VIN_COM, "vin_com", 1053); }
|
||||||
@ -163,7 +163,7 @@ TEST_CASE("chipversion", "[.cmd]") {
|
|||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
|
if (det_type == defs::JUNGFRAU) {
|
||||||
REQUIRE_NOTHROW(proxy.Call("chipversion", {}, -1, GET));
|
REQUIRE_NOTHROW(proxy.Call("chipversion", {}, -1, GET));
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("chipversion", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("chipversion", {}, -1, GET));
|
||||||
@ -506,6 +506,161 @@ TEST_CASE("filtercells", "[.cmd]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("pedestalmode", "[.cmd]") {
|
||||||
|
Detector det;
|
||||||
|
CmdProxy proxy(&det);
|
||||||
|
auto det_type = det.getDetectorType().squash();
|
||||||
|
if (det_type == defs::JUNGFRAU) {
|
||||||
|
auto prev_val = det.getPedestalMode();
|
||||||
|
auto prev_frames = det.getNumberOfFrames().tsquash(
|
||||||
|
"Inconsistent number of frames to test");
|
||||||
|
auto prev_triggers = det.getNumberOfTriggers().tsquash(
|
||||||
|
"Inconsistent number of triggers to test");
|
||||||
|
auto prev_timingmode =
|
||||||
|
det.getTimingMode().tsquash("Inconsistent timing mode to test");
|
||||||
|
|
||||||
|
REQUIRE_NOTHROW(proxy.Call("pedestalmode", {}, 0, GET));
|
||||||
|
REQUIRE_NOTHROW(proxy.Call("pedestalmode", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("pedestalmode", {"0"}, -1, GET));
|
||||||
|
|
||||||
|
REQUIRE_THROWS(proxy.Call("pedestalmode", {"256", "10"}, -1, PUT));
|
||||||
|
REQUIRE_THROWS(proxy.Call("pedestalmode", {"-1", "10"}, 0, PUT));
|
||||||
|
REQUIRE_THROWS(proxy.Call("pedestalmode", {"20", "65536"}, 0, PUT));
|
||||||
|
REQUIRE_THROWS(proxy.Call("pedestalmode", {"20", "-1"}, 0, PUT));
|
||||||
|
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("pedestalmode", {"30", "1000"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "pedestalmode [30, 1000]\n");
|
||||||
|
}
|
||||||
|
// cannot change any of these in pedestal mode
|
||||||
|
REQUIRE_THROWS_WITH(proxy.Call("frames", {"200"}, -1, PUT),
|
||||||
|
"Detector returned: Cannot set frames in pedestal "
|
||||||
|
"mode. It is overwritten anyway.\n");
|
||||||
|
REQUIRE_THROWS_WITH(proxy.Call("triggers", {"200"}, -1, PUT),
|
||||||
|
"Detector returned: Cannot set triggers in "
|
||||||
|
"pedestal mode. It is overwritten anyway.\n");
|
||||||
|
REQUIRE_THROWS_WITH(
|
||||||
|
proxy.Call("timing", {"auto"}, -1, PUT),
|
||||||
|
"Detector returned: Cannot set timing mode in pedestal mode. "
|
||||||
|
"Switch off pedestal mode to change timing mode.\n");
|
||||||
|
REQUIRE_THROWS_WITH(
|
||||||
|
proxy.Call("scan", {"vb_comp", "500", "1500", "10"}, -1, PUT),
|
||||||
|
"Detector returned: Cannot set scan when in pedestal mode.\n");
|
||||||
|
REQUIRE_THROWS_WITH(
|
||||||
|
proxy.Call("scan", {"0"}, -1, PUT),
|
||||||
|
"Detector returned: Cannot set scan when in pedestal mode.\n");
|
||||||
|
// should not throw to get these values though
|
||||||
|
REQUIRE_NOTHROW(proxy.Call("frames", {}, -1, GET));
|
||||||
|
REQUIRE_NOTHROW(proxy.Call("triggers", {}, -1, GET));
|
||||||
|
REQUIRE_NOTHROW(proxy.Call("timing", {}, -1, GET));
|
||||||
|
REQUIRE_NOTHROW(proxy.Call("scan", {}, -1, GET));
|
||||||
|
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("pedestalmode", {"50", "500"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "pedestalmode [50, 500]\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("pedestalmode", {}, -1, GET, oss);
|
||||||
|
REQUIRE(oss.str() == "pedestalmode [enabled, 50, 500]\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto pedemode = det.getPedestalMode().tsquash(
|
||||||
|
"Inconsistent pedestal mode to test");
|
||||||
|
REQUIRE(pedemode.enable == true);
|
||||||
|
REQUIRE(pedemode.frames == 50);
|
||||||
|
REQUIRE(pedemode.loops == 500);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("pedestalmode", {"0"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "pedestalmode [0]\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("pedestalmode", {}, -1, GET, oss);
|
||||||
|
REQUIRE(oss.str() == "pedestalmode [disabled]\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t pedestalFrames = 50;
|
||||||
|
uint16_t pedestalLoops = 1000;
|
||||||
|
int64_t expNumFrames = pedestalFrames * pedestalLoops * 2;
|
||||||
|
auto origFrames = det.getNumberOfFrames().squash(-1);
|
||||||
|
auto origTriggers = det.getNumberOfTriggers().squash(-1);
|
||||||
|
|
||||||
|
// auto mode
|
||||||
|
det.setTimingMode(defs::AUTO_TIMING);
|
||||||
|
REQUIRE_NOTHROW(proxy.Call(
|
||||||
|
"pedestalmode",
|
||||||
|
{std::to_string(pedestalFrames), std::to_string(pedestalLoops)}, -1,
|
||||||
|
PUT));
|
||||||
|
auto numTriggers = det.getNumberOfTriggers().squash(-1);
|
||||||
|
auto numFrames = det.getNumberOfFrames().squash(-1);
|
||||||
|
REQUIRE(numFrames == expNumFrames);
|
||||||
|
REQUIRE(numTriggers == 1);
|
||||||
|
|
||||||
|
// pedestal mode off
|
||||||
|
REQUIRE_NOTHROW(proxy.Call("pedestalmode", {"0"}, -1, PUT));
|
||||||
|
numTriggers = det.getNumberOfTriggers().squash(-1);
|
||||||
|
numFrames = det.getNumberOfFrames().squash(-1);
|
||||||
|
REQUIRE(numFrames == origFrames);
|
||||||
|
REQUIRE(numTriggers == origTriggers);
|
||||||
|
|
||||||
|
// trigger mode (frames > 1)
|
||||||
|
REQUIRE_NOTHROW(det.setTimingMode(defs::TRIGGER_EXPOSURE));
|
||||||
|
origFrames = 5;
|
||||||
|
REQUIRE_NOTHROW(det.setNumberOfFrames(origFrames));
|
||||||
|
REQUIRE_NOTHROW(proxy.Call(
|
||||||
|
"pedestalmode",
|
||||||
|
{std::to_string(pedestalFrames), std::to_string(pedestalLoops)}, -1,
|
||||||
|
PUT));
|
||||||
|
numTriggers = det.getNumberOfTriggers().squash(-1);
|
||||||
|
numFrames = det.getNumberOfFrames().squash(-1);
|
||||||
|
REQUIRE(numFrames == expNumFrames);
|
||||||
|
REQUIRE(numTriggers == 1);
|
||||||
|
|
||||||
|
// pedestal mode off
|
||||||
|
REQUIRE_NOTHROW(proxy.Call("pedestalmode", {"0"}, -1, PUT));
|
||||||
|
numTriggers = det.getNumberOfTriggers().squash(-1);
|
||||||
|
numFrames = det.getNumberOfFrames().squash(-1);
|
||||||
|
REQUIRE(numFrames == origFrames);
|
||||||
|
REQUIRE(numTriggers == origTriggers);
|
||||||
|
|
||||||
|
// trigger mode (frames = 1)
|
||||||
|
origFrames = 1;
|
||||||
|
REQUIRE_NOTHROW(det.setNumberOfFrames(origFrames));
|
||||||
|
origTriggers = 10;
|
||||||
|
REQUIRE_NOTHROW(det.setNumberOfTriggers(origTriggers));
|
||||||
|
REQUIRE_NOTHROW(proxy.Call(
|
||||||
|
"pedestalmode",
|
||||||
|
{std::to_string(pedestalFrames), std::to_string(pedestalLoops)}, -1,
|
||||||
|
PUT));
|
||||||
|
numTriggers = det.getNumberOfTriggers().squash(-1);
|
||||||
|
numFrames = det.getNumberOfFrames().squash(-1);
|
||||||
|
REQUIRE(numFrames == 1);
|
||||||
|
REQUIRE(numTriggers == expNumFrames);
|
||||||
|
|
||||||
|
// pedestal mode off
|
||||||
|
REQUIRE_NOTHROW(proxy.Call("pedestalmode", {"0"}, -1, PUT));
|
||||||
|
numTriggers = det.getNumberOfTriggers().squash(-1);
|
||||||
|
numFrames = det.getNumberOfFrames().squash(-1);
|
||||||
|
REQUIRE(numFrames == origFrames);
|
||||||
|
REQUIRE(numTriggers == origTriggers);
|
||||||
|
|
||||||
|
det.setNumberOfFrames(prev_frames);
|
||||||
|
det.setNumberOfTriggers(prev_triggers);
|
||||||
|
det.setTimingMode(prev_timingmode);
|
||||||
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
|
det.setPedestalMode(prev_val[i], {i});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
REQUIRE_THROWS(proxy.Call("pedestalmode", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("pedestalmode", {"0"}, -1, PUT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("sync", "[.cmd]") {
|
TEST_CASE("sync", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
@ -550,6 +705,34 @@ TEST_CASE("sync", "[.cmd]") {
|
|||||||
proxy.Call("sync", {}, -1, GET, oss);
|
proxy.Call("sync", {}, -1, GET, oss);
|
||||||
REQUIRE(oss.str() == "sync 1\n");
|
REQUIRE(oss.str() == "sync 1\n");
|
||||||
}
|
}
|
||||||
|
// setting sync when running
|
||||||
|
{
|
||||||
|
auto prev_timing =
|
||||||
|
det.getTimingMode().tsquash("inconsistent timing mode in test");
|
||||||
|
auto prev_frames =
|
||||||
|
det.getNumberOfFrames().tsquash("inconsistent #frames in test");
|
||||||
|
auto prev_exptime =
|
||||||
|
det.getExptime().tsquash("inconsistent exptime in test");
|
||||||
|
auto prev_period =
|
||||||
|
det.getPeriod().tsquash("inconsistent period in test");
|
||||||
|
det.setTimingMode(defs::AUTO_TIMING);
|
||||||
|
det.setNumberOfFrames(10000);
|
||||||
|
det.setExptime(std::chrono::microseconds(200));
|
||||||
|
det.setPeriod(std::chrono::milliseconds(1000));
|
||||||
|
det.setSynchronization(1);
|
||||||
|
det.startDetector();
|
||||||
|
REQUIRE_THROWS(proxy.Call("sync", {"0"}, -1, PUT));
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("sync", {}, -1, GET, oss);
|
||||||
|
REQUIRE(oss.str() == "sync 1\n");
|
||||||
|
}
|
||||||
|
det.stopDetector();
|
||||||
|
det.setTimingMode(prev_timing);
|
||||||
|
det.setNumberOfFrames(prev_frames);
|
||||||
|
det.setExptime(prev_exptime);
|
||||||
|
det.setPeriod(prev_period);
|
||||||
|
}
|
||||||
det.setSynchronization(prev_val);
|
det.setSynchronization(prev_val);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("sync", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("sync", {}, -1, GET));
|
||||||
|
@ -18,5 +18,92 @@ using test::GET;
|
|||||||
using test::PUT;
|
using test::PUT;
|
||||||
|
|
||||||
/* dacs */
|
/* dacs */
|
||||||
|
TEST_CASE("Setting and reading back moench dacs", "[.cmd][.dacs]") {
|
||||||
|
// vbp_colbuf, vipre, vin_cm, vb_sda, vcasc_sfp, vout_cm, vipre_cds,
|
||||||
|
// ibias_sfp
|
||||||
|
Detector det;
|
||||||
|
CmdProxy proxy(&det);
|
||||||
|
auto det_type = det.getDetectorType().squash();
|
||||||
|
if (det_type == defs::MOENCH) {
|
||||||
|
SECTION("vbp_colbuf") {
|
||||||
|
test_dac(defs::VBP_COLBUF, "vbp_colbuf", 1300);
|
||||||
|
}
|
||||||
|
SECTION("vipre") { test_dac(defs::VIPRE, "vipre", 1000); }
|
||||||
|
SECTION("vin_cm") { test_dac(defs::VIN_CM, "vin_cm", 1400); }
|
||||||
|
SECTION("vb_sda") { test_dac(defs::VB_SDA, "vb_sda", 680); }
|
||||||
|
SECTION("vcasc_sfp") { test_dac(defs::VCASC_SFP, "vcasc_sfp", 1428); }
|
||||||
|
SECTION("vout_cm") { test_dac(defs::VOUT_CM, "vout_cm", 1200); }
|
||||||
|
SECTION("vipre_cds") { test_dac(defs::VIPRE_CDS, "vipre_cds", 800); }
|
||||||
|
SECTION("ibias_sfp") { test_dac(defs::IBIAS_SFP, "ibias_sfp", 900); }
|
||||||
|
// 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("vtrim", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("vrpreamp", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("vrshaper", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("vtgstv", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("vcmp_ll", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("vcmp_lr", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("vcal", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("vcmp_rl", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("vcmp_rr", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("rxb_rb", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("rxb_lb", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("vcp", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("vcn", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("vishaper", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("iodelay", {}, -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));
|
||||||
|
// mythen3
|
||||||
|
REQUIRE_THROWS(proxy.Call("vrpreamp", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("vrshaper", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("vrshaper_n", {}, -1, GET));
|
||||||
|
// REQUIRE_THROWS(proxy.Call("vipre", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("vishaper", {}, -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("vcal_n", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("vcal_p", {}, -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "sls/Detector.h"
|
#include "sls/Detector.h"
|
||||||
#include "sls/Version.h"
|
#include "sls/Version.h"
|
||||||
#include "sls/sls_detector_defs.h"
|
#include "sls/sls_detector_defs.h"
|
||||||
|
#include "test-CmdProxy-global.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "sls/versionAPI.h"
|
#include "sls/versionAPI.h"
|
||||||
@ -223,7 +224,7 @@ TEST_CASE("rx_tcpport", "[.cmd][.rx]") {
|
|||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto prev_val = det.getRxPort();
|
auto prev_val = det.getRxPort();
|
||||||
|
|
||||||
int port = 3500;
|
uint16_t port = 3500;
|
||||||
proxy.Call("rx_tcpport", {std::to_string(port)}, -1, PUT);
|
proxy.Call("rx_tcpport", {std::to_string(port)}, -1, PUT);
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -237,6 +238,22 @@ TEST_CASE("rx_tcpport", "[.cmd][.rx]") {
|
|||||||
proxy.Call("rx_tcpport", {}, i, GET, oss);
|
proxy.Call("rx_tcpport", {}, i, GET, oss);
|
||||||
REQUIRE(oss.str() == "rx_tcpport " + std::to_string(port + i) + '\n');
|
REQUIRE(oss.str() == "rx_tcpport " + std::to_string(port + i) + '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_valid_port("rx_tcpport", {}, -1, PUT);
|
||||||
|
test_valid_port("rx_tcpport", {}, 0, PUT);
|
||||||
|
// should fail for the second module
|
||||||
|
if (det.size() > 1) {
|
||||||
|
REQUIRE_THROWS(proxy.Call("rx_tcpport", {"65535"}, -1, PUT));
|
||||||
|
auto rxHostname = det.getRxHostname().squash("none");
|
||||||
|
if (rxHostname != "none") {
|
||||||
|
std::ostringstream oss;
|
||||||
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
|
oss << rxHostname << ":" << 65536 + i << "+";
|
||||||
|
}
|
||||||
|
REQUIRE_THROWS(proxy.Call("rx_hostname", {oss.str()}, -1, PUT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setRxPort(prev_val[i], i);
|
det.setRxPort(prev_val[i], i);
|
||||||
}
|
}
|
||||||
@ -810,7 +827,7 @@ TEST_CASE("rx_zmqport", "[.cmd][.rx]") {
|
|||||||
proxy.Call("numinterfaces", {"2"}, -1, PUT);
|
proxy.Call("numinterfaces", {"2"}, -1, PUT);
|
||||||
socketsperdetector *= 2;
|
socketsperdetector *= 2;
|
||||||
}
|
}
|
||||||
int port = 3500;
|
uint16_t port = 3500;
|
||||||
proxy.Call("rx_zmqport", {std::to_string(port)}, -1, PUT);
|
proxy.Call("rx_zmqport", {std::to_string(port)}, -1, PUT);
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -828,6 +845,14 @@ TEST_CASE("rx_zmqport", "[.cmd][.rx]") {
|
|||||||
std::to_string(port + i * socketsperdetector) +
|
std::to_string(port + i * socketsperdetector) +
|
||||||
'\n');
|
'\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_valid_port("rx_zmqport", {}, -1, PUT);
|
||||||
|
test_valid_port("rx_zmqport", {}, 0, PUT);
|
||||||
|
// should fail for the second module
|
||||||
|
if (det.size() > 1) {
|
||||||
|
REQUIRE_THROWS(proxy.Call("rx_zmqport", {"65535"}, -1, PUT));
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setRxZmqPort(prev_val_zmqport[i], i);
|
det.setRxZmqPort(prev_val_zmqport[i], i);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "sls/Detector.h"
|
#include "sls/Detector.h"
|
||||||
#include "sls/file_utils.h"
|
#include "sls/file_utils.h"
|
||||||
#include "sls/sls_detector_defs.h"
|
#include "sls/sls_detector_defs.h"
|
||||||
|
#include "test-CmdProxy-global.h"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -76,7 +77,13 @@ TEST_CASE("hostname", "[.cmd]") {
|
|||||||
REQUIRE_NOTHROW(proxy.Call("hostname", {}, -1, GET));
|
REQUIRE_NOTHROW(proxy.Call("hostname", {}, -1, GET));
|
||||||
}
|
}
|
||||||
|
|
||||||
// virtual: not testing
|
TEST_CASE("virtual", "[.cmd]") {
|
||||||
|
Detector det;
|
||||||
|
CmdProxy proxy(&det);
|
||||||
|
REQUIRE_THROWS(proxy.Call("virtual", {}, -1, GET));
|
||||||
|
test_valid_port("virtual", {"1"}, -1, PUT);
|
||||||
|
REQUIRE_THROWS(proxy.Call("virtual", {"3", "65534"}, -1, PUT));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("versions", "[.cmd]") {
|
TEST_CASE("versions", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
@ -2057,7 +2064,7 @@ TEST_CASE("defaultdac", "[.cmd]") {
|
|||||||
det.setDefaultDac(it, prev_val[i], {i});
|
det.setDefaultDac(it, prev_val[i], {i});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
|
if (det_type == defs::JUNGFRAU) {
|
||||||
std::vector<defs::dacIndex> daclist = {
|
std::vector<defs::dacIndex> daclist = {
|
||||||
defs::VREF_PRECH, defs::VREF_DS, defs::VREF_COMP};
|
defs::VREF_PRECH, defs::VREF_DS, defs::VREF_COMP};
|
||||||
for (auto it : daclist) {
|
for (auto it : daclist) {
|
||||||
@ -2410,10 +2417,13 @@ TEST_CASE("scan", "[.cmd]") {
|
|||||||
notImplementedInd = defs::VCASCP_PB;
|
notImplementedInd = defs::VCASCP_PB;
|
||||||
break;
|
break;
|
||||||
case defs::JUNGFRAU:
|
case defs::JUNGFRAU:
|
||||||
case defs::MOENCH:
|
|
||||||
ind = defs::VB_COMP;
|
ind = defs::VB_COMP;
|
||||||
notImplementedInd = defs::VSVP;
|
notImplementedInd = defs::VSVP;
|
||||||
break;
|
break;
|
||||||
|
case defs::MOENCH:
|
||||||
|
ind = defs::VIN_CM;
|
||||||
|
notImplementedInd = defs::VSVP;
|
||||||
|
break;
|
||||||
case defs::GOTTHARD:
|
case defs::GOTTHARD:
|
||||||
ind = defs::VREF_DS;
|
ind = defs::VREF_DS;
|
||||||
notImplementedInd = defs::VSVP;
|
notImplementedInd = defs::VSVP;
|
||||||
@ -2693,6 +2703,12 @@ TEST_CASE("udp_dstport", "[.cmd]") {
|
|||||||
proxy.Call("udp_dstport", {"50084"}, -1, PUT, oss);
|
proxy.Call("udp_dstport", {"50084"}, -1, PUT, oss);
|
||||||
REQUIRE(oss.str() == "udp_dstport 50084\n");
|
REQUIRE(oss.str() == "udp_dstport 50084\n");
|
||||||
}
|
}
|
||||||
|
test_valid_port("udp_dstport", {}, -1, PUT);
|
||||||
|
test_valid_port("udp_dstport", {}, 0, PUT);
|
||||||
|
// should fail for the second module
|
||||||
|
if (det.size() > 1) {
|
||||||
|
REQUIRE_THROWS(proxy.Call("udp_dstport", {"65535"}, -1, PUT));
|
||||||
|
}
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setDestinationUDPPort(prev_val[i], {i});
|
det.setDestinationUDPPort(prev_val[i], {i});
|
||||||
}
|
}
|
||||||
@ -2781,9 +2797,19 @@ TEST_CASE("udp_dstport2", "[.cmd]") {
|
|||||||
proxy.Call("udp_dstport2", {"50084"}, -1, PUT, oss);
|
proxy.Call("udp_dstport2", {"50084"}, -1, PUT, oss);
|
||||||
REQUIRE(oss.str() == "udp_dstport2 50084\n");
|
REQUIRE(oss.str() == "udp_dstport2 50084\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_valid_port("udp_dstport2", {}, -1, PUT);
|
||||||
|
test_valid_port("udp_dstport2", {}, 0, PUT);
|
||||||
|
// should fail for the second module
|
||||||
|
if (det.size() > 1) {
|
||||||
|
REQUIRE_THROWS(proxy.Call("udp_dstport2", {"65535"}, -1, PUT));
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
|
if (prev_val[i] != 0) {
|
||||||
det.setDestinationUDPPort2(prev_val[i], {i});
|
det.setDestinationUDPPort2(prev_val[i], {i});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("udp_dstport2", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("udp_dstport2", {}, -1, GET));
|
||||||
}
|
}
|
||||||
@ -2976,7 +3002,7 @@ TEST_CASE("zmqport", "[.cmd]") {
|
|||||||
det.setNumberofUDPInterfaces(2);
|
det.setNumberofUDPInterfaces(2);
|
||||||
socketsperdetector *= 2;
|
socketsperdetector *= 2;
|
||||||
}
|
}
|
||||||
int port = 3500;
|
uint16_t port = 3500;
|
||||||
auto port_str = std::to_string(port);
|
auto port_str = std::to_string(port);
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -3005,6 +3031,12 @@ TEST_CASE("zmqport", "[.cmd]") {
|
|||||||
std::to_string(port + i * socketsperdetector) +
|
std::to_string(port + i * socketsperdetector) +
|
||||||
'\n');
|
'\n');
|
||||||
}
|
}
|
||||||
|
test_valid_port("zmqport", {}, -1, PUT);
|
||||||
|
test_valid_port("zmqport", {}, 0, PUT);
|
||||||
|
// should fail for the second module
|
||||||
|
if (det.size() > 1) {
|
||||||
|
REQUIRE_THROWS(proxy.Call("zmqport", {"65535"}, -1, PUT));
|
||||||
|
}
|
||||||
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
|
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
|
||||||
det.setNumberofUDPInterfaces(prev);
|
det.setNumberofUDPInterfaces(prev);
|
||||||
}
|
}
|
||||||
@ -3384,6 +3416,12 @@ TEST_CASE("port", "[.cmd]") {
|
|||||||
proxy.Call("port", {}, 0, GET, oss);
|
proxy.Call("port", {}, 0, GET, oss);
|
||||||
REQUIRE(oss.str() == "port 1942\n");
|
REQUIRE(oss.str() == "port 1942\n");
|
||||||
}
|
}
|
||||||
|
test_valid_port("port", {}, -1, PUT);
|
||||||
|
test_valid_port("port", {}, 0, PUT);
|
||||||
|
// should fail for the second module
|
||||||
|
if (det.size() > 1) {
|
||||||
|
REQUIRE_THROWS(proxy.Call("port", {"65536"}, -1, PUT));
|
||||||
|
}
|
||||||
det.setControlPort(prev_val, {0});
|
det.setControlPort(prev_val, {0});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3401,6 +3439,12 @@ TEST_CASE("stopport", "[.cmd]") {
|
|||||||
proxy.Call("stopport", {}, 0, GET, oss);
|
proxy.Call("stopport", {}, 0, GET, oss);
|
||||||
REQUIRE(oss.str() == "stopport 1942\n");
|
REQUIRE(oss.str() == "stopport 1942\n");
|
||||||
}
|
}
|
||||||
|
test_valid_port("stopport", {}, -1, PUT);
|
||||||
|
test_valid_port("stopport", {}, 0, PUT);
|
||||||
|
// should fail for the second module
|
||||||
|
if (det.size() > 1) {
|
||||||
|
REQUIRE_THROWS(proxy.Call("stopport", {"65536"}, -1, PUT));
|
||||||
|
}
|
||||||
det.setStopPort(prev_val, {0});
|
det.setStopPort(prev_val, {0});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3431,7 +3475,7 @@ TEST_CASE("lock", "[.cmd]") {
|
|||||||
TEST_CASE("execcommand", "[.cmd]") {
|
TEST_CASE("execcommand", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
REQUIRE_NOTHROW(proxy.Call("execcommand", {"ls"}, -1, PUT));
|
REQUIRE_NOTHROW(proxy.Call("execcommand", {"ls *.txt"}, -1, PUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("framecounter", "[.cmd]") {
|
TEST_CASE("framecounter", "[.cmd]") {
|
||||||
|
@ -26,7 +26,7 @@ TEST_CASE("Default construction") {
|
|||||||
REQUIRE(adcnames[1] == "ADC1");
|
REQUIRE(adcnames[1] == "ADC1");
|
||||||
REQUIRE(adcnames[2] == "ADC2");
|
REQUIRE(adcnames[2] == "ADC2");
|
||||||
REQUIRE(adcnames[3] == "ADC3");
|
REQUIRE(adcnames[3] == "ADC3");
|
||||||
auto powernames = c.getVoltageNames();
|
auto powernames = c.getPowerNames();
|
||||||
REQUIRE(powernames.size() == 5);
|
REQUIRE(powernames.size() == 5);
|
||||||
REQUIRE(powernames[0] == "VA");
|
REQUIRE(powernames[0] == "VA");
|
||||||
REQUIRE(powernames[1] == "VB");
|
REQUIRE(powernames[1] == "VB");
|
||||||
|
@ -196,4 +196,24 @@ TEST_CASE("String conversions") {
|
|||||||
"[{one: 1}, {one: 1, three: 3, two: 2}, {one: 1}]");
|
"[{one: 1}, {one: 1, three: 3, two: 2}, {one: 1}]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Any element is equal") {
|
||||||
|
Result<int> r{1, 2, 3, 4, 5};
|
||||||
|
REQUIRE(r.any(3));
|
||||||
|
REQUIRE_FALSE(r.any(9));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Result contains only the specified elements") {
|
||||||
|
Result<int> r{1, 1, 1};
|
||||||
|
REQUIRE(r.contains_only(1));
|
||||||
|
REQUIRE(r.contains_only(1, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Only with multiple values") {
|
||||||
|
Result<int> r{1, 1, 2, 1, 2, 1, 1};
|
||||||
|
REQUIRE_FALSE(r.contains_only(1));
|
||||||
|
REQUIRE_FALSE(r.contains_only(2));
|
||||||
|
REQUIRE(r.contains_only(1, 2));
|
||||||
|
REQUIRE(r.contains_only(2, 1));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -28,7 +28,7 @@ class Receiver : private virtual slsDetectorDefs {
|
|||||||
* throws an exception in case of failure
|
* throws an exception in case of failure
|
||||||
* @param tcpip_port_no TCP/IP port number
|
* @param tcpip_port_no TCP/IP port number
|
||||||
*/
|
*/
|
||||||
Receiver(int tcpip_port_no = 1954);
|
Receiver(uint16_t tcpip_port_no = 1954);
|
||||||
|
|
||||||
~Receiver();
|
~Receiver();
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ void BinaryDataFile::CreateFirstBinaryDataFile(const std::string &fNamePrefix,
|
|||||||
const uint64_t fIndex,
|
const uint64_t fIndex,
|
||||||
const bool ovEnable,
|
const bool ovEnable,
|
||||||
const bool sMode,
|
const bool sMode,
|
||||||
const uint32_t uPortNumber,
|
const uint16_t uPortNumber,
|
||||||
const uint32_t mFramesPerFile) {
|
const uint32_t mFramesPerFile) {
|
||||||
|
|
||||||
subFileIndex = 0;
|
subFileIndex = 0;
|
||||||
|
@ -16,7 +16,7 @@ class BinaryDataFile : private virtual slsDetectorDefs, public File {
|
|||||||
void CloseFile() override;
|
void CloseFile() override;
|
||||||
void CreateFirstBinaryDataFile(const std::string &fNamePrefix,
|
void CreateFirstBinaryDataFile(const std::string &fNamePrefix,
|
||||||
const uint64_t fIndex, const bool ovEnable,
|
const uint64_t fIndex, const bool ovEnable,
|
||||||
const bool sMode, const uint32_t uPortNumber,
|
const bool sMode, const uint16_t uPortNumber,
|
||||||
const uint32_t mFramesPerFile) override;
|
const uint32_t mFramesPerFile) override;
|
||||||
|
|
||||||
void WriteToFile(char *imageData, sls_receiver_header &header,
|
void WriteToFile(char *imageData, sls_receiver_header &header,
|
||||||
|
@ -41,10 +41,9 @@ ClientInterface::~ClientInterface() {
|
|||||||
tcpThread->join();
|
tcpThread->join();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientInterface::ClientInterface(int portNumber)
|
ClientInterface::ClientInterface(uint16_t portNumber)
|
||||||
: detType(GOTTHARD),
|
: detType(GOTTHARD), portNumber(portNumber), server(portNumber) {
|
||||||
portNumber(portNumber > 0 ? portNumber : DEFAULT_TCP_RX_PORTNO),
|
validatePortNumber(portNumber);
|
||||||
server(portNumber) {
|
|
||||||
functionTable();
|
functionTable();
|
||||||
parentThreadId = gettid();
|
parentThreadId = gettid();
|
||||||
tcpThread =
|
tcpThread =
|
||||||
@ -1064,9 +1063,12 @@ int ClientInterface::get_file_format(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ClientInterface::set_streaming_port(Interface &socket) {
|
int ClientInterface::set_streaming_port(Interface &socket) {
|
||||||
auto port = socket.Receive<int>();
|
auto port = socket.Receive<uint16_t>();
|
||||||
if (port < 0) {
|
try {
|
||||||
throw RuntimeError("Invalid zmq port " + std::to_string(port));
|
validatePortNumber(port);
|
||||||
|
} catch (...) {
|
||||||
|
throw RuntimeError(
|
||||||
|
"Could not set streaming (zmq) port number. Invalid value.");
|
||||||
}
|
}
|
||||||
verifyIdle(socket);
|
verifyIdle(socket);
|
||||||
impl()->setStreamingPort(port);
|
impl()->setStreamingPort(port);
|
||||||
@ -1074,7 +1076,7 @@ int ClientInterface::set_streaming_port(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ClientInterface::get_streaming_port(Interface &socket) {
|
int ClientInterface::get_streaming_port(Interface &socket) {
|
||||||
int retval = impl()->getStreamingPort();
|
uint16_t retval = impl()->getStreamingPort();
|
||||||
LOG(logDEBUG1) << "streaming port:" << retval;
|
LOG(logDEBUG1) << "streaming port:" << retval;
|
||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
@ -1449,7 +1451,7 @@ int ClientInterface::set_udp_ip2(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ClientInterface::set_udp_port(Interface &socket) {
|
int ClientInterface::set_udp_port(Interface &socket) {
|
||||||
auto arg = socket.Receive<int>();
|
auto arg = socket.Receive<uint16_t>();
|
||||||
verifyIdle(socket);
|
verifyIdle(socket);
|
||||||
LOG(logDEBUG1) << "Setting UDP Port:" << arg;
|
LOG(logDEBUG1) << "Setting UDP Port:" << arg;
|
||||||
impl()->setUDPPortNumber(arg);
|
impl()->setUDPPortNumber(arg);
|
||||||
@ -1457,7 +1459,7 @@ int ClientInterface::set_udp_port(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ClientInterface::set_udp_port2(Interface &socket) {
|
int ClientInterface::set_udp_port2(Interface &socket) {
|
||||||
auto arg = socket.Receive<int>();
|
auto arg = socket.Receive<uint16_t>();
|
||||||
verifyIdle(socket);
|
verifyIdle(socket);
|
||||||
if (detType != JUNGFRAU && detType != MOENCH && detType != EIGER &&
|
if (detType != JUNGFRAU && detType != MOENCH && detType != EIGER &&
|
||||||
detType != GOTTHARD2) {
|
detType != GOTTHARD2) {
|
||||||
|
@ -17,7 +17,7 @@ class ServerInterface;
|
|||||||
class ClientInterface : private virtual slsDetectorDefs {
|
class ClientInterface : private virtual slsDetectorDefs {
|
||||||
enum numberMode { DEC, HEX };
|
enum numberMode { DEC, HEX };
|
||||||
detectorType detType;
|
detectorType detType;
|
||||||
int portNumber{0};
|
uint16_t portNumber{0};
|
||||||
ServerSocket server;
|
ServerSocket server;
|
||||||
std::unique_ptr<Implementation> receiver;
|
std::unique_ptr<Implementation> receiver;
|
||||||
std::unique_ptr<std::thread> tcpThread;
|
std::unique_ptr<std::thread> tcpThread;
|
||||||
@ -29,7 +29,7 @@ class ClientInterface : private virtual slsDetectorDefs {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~ClientInterface();
|
virtual ~ClientInterface();
|
||||||
ClientInterface(int portNumber = -1);
|
ClientInterface(uint16_t portNumber = DEFAULT_TCP_RX_PORTNO);
|
||||||
std::string getReceiverVersion();
|
std::string getReceiverVersion();
|
||||||
|
|
||||||
//***callback functions***
|
//***callback functions***
|
||||||
|
@ -127,7 +127,7 @@ void DataProcessor::CreateFirstFiles(const std::string &fileNamePrefix,
|
|||||||
const uint64_t fileIndex,
|
const uint64_t fileIndex,
|
||||||
const bool overWriteEnable,
|
const bool overWriteEnable,
|
||||||
const bool silentMode,
|
const bool silentMode,
|
||||||
const uint32_t udpPortNumber,
|
const uint16_t udpPortNumber,
|
||||||
const uint64_t numImages,
|
const uint64_t numImages,
|
||||||
const bool detectorDataStream) {
|
const bool detectorDataStream) {
|
||||||
if (dataFile == nullptr) {
|
if (dataFile == nullptr) {
|
||||||
|
@ -56,7 +56,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
|
|
||||||
void CreateFirstFiles(const std::string &fileNamePrefix,
|
void CreateFirstFiles(const std::string &fileNamePrefix,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable,
|
const uint64_t fileIndex, const bool overWriteEnable,
|
||||||
const bool silentMode, const uint32_t udpPortNumber,
|
const bool silentMode, const uint16_t udpPortNumber,
|
||||||
const uint64_t numImages,
|
const uint64_t numImages,
|
||||||
const bool detectorDataStream);
|
const bool detectorDataStream);
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
|
@ -84,8 +84,8 @@ void DataStreamer::RecordFirstIndex(uint64_t fnum, size_t firstImageIndex) {
|
|||||||
<< ", First Streamer Index:" << fnum;
|
<< ", First Streamer Index:" << fnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataStreamer::CreateZmqSockets(uint32_t port, const IpAddr ip, int hwm) {
|
void DataStreamer::CreateZmqSockets(uint16_t port, const IpAddr ip, int hwm) {
|
||||||
uint32_t portnum = port + index;
|
uint16_t portnum = port + index;
|
||||||
std::string sip = ip.str();
|
std::string sip = ip.str();
|
||||||
try {
|
try {
|
||||||
zmqSocket = new ZmqSocket(portnum, (ip != 0 ? sip.c_str() : nullptr));
|
zmqSocket = new ZmqSocket(portnum, (ip != 0 ? sip.c_str() : nullptr));
|
||||||
|
@ -48,7 +48,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* @param ip streaming source ip
|
* @param ip streaming source ip
|
||||||
* @param hwm streaming high water mark
|
* @param hwm streaming high water mark
|
||||||
*/
|
*/
|
||||||
void CreateZmqSockets(uint32_t port, const IpAddr ip, int hwm);
|
void CreateZmqSockets(uint16_t port, const IpAddr ip, int hwm);
|
||||||
void CloseZmqSocket();
|
void CloseZmqSocket();
|
||||||
void RestreamStop();
|
void RestreamStop();
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class File : private virtual slsDetectorDefs {
|
|||||||
virtual void CreateFirstHDF5DataFile(
|
virtual void CreateFirstHDF5DataFile(
|
||||||
const std::string &fileNamePrefix, const uint64_t fileIndex,
|
const std::string &fileNamePrefix, const uint64_t fileIndex,
|
||||||
const bool overWriteEnable, const bool silentMode,
|
const bool overWriteEnable, const bool silentMode,
|
||||||
const uint32_t udpPortNumber, const uint32_t maxFramesPerFile,
|
const uint16_t udpPortNumber, const uint32_t maxFramesPerFile,
|
||||||
const uint64_t numImages, const uint32_t nPixelsX,
|
const uint64_t numImages, const uint32_t nPixelsX,
|
||||||
const uint32_t nPixelsY, const uint32_t dynamicRange) {
|
const uint32_t nPixelsY, const uint32_t dynamicRange) {
|
||||||
LOG(logERROR)
|
LOG(logERROR)
|
||||||
@ -70,7 +70,7 @@ class File : private virtual slsDetectorDefs {
|
|||||||
const uint64_t fileIndex,
|
const uint64_t fileIndex,
|
||||||
const bool overWriteEnable,
|
const bool overWriteEnable,
|
||||||
const bool silentMode,
|
const bool silentMode,
|
||||||
const uint32_t udpPortNumber,
|
const uint16_t udpPortNumber,
|
||||||
const uint32_t maxFramesPerFile) {
|
const uint32_t maxFramesPerFile) {
|
||||||
LOG(logERROR)
|
LOG(logERROR)
|
||||||
<< "This is a generic function CreateFirstBinaryDataFile that "
|
<< "This is a generic function CreateFirstBinaryDataFile that "
|
||||||
|
@ -88,7 +88,7 @@ void HDF5DataFile::CloseFile() {
|
|||||||
|
|
||||||
void HDF5DataFile::CreateFirstHDF5DataFile(
|
void HDF5DataFile::CreateFirstHDF5DataFile(
|
||||||
const std::string &fNamePrefix, const uint64_t fIndex, const bool owEnable,
|
const std::string &fNamePrefix, const uint64_t fIndex, const bool owEnable,
|
||||||
const bool sMode, const uint32_t uPortNumber, const uint32_t mFramesPerFile,
|
const bool sMode, const uint16_t uPortNumber, const uint32_t mFramesPerFile,
|
||||||
const uint64_t nImages, const uint32_t nX, const uint32_t nY,
|
const uint64_t nImages, const uint32_t nX, const uint32_t nY,
|
||||||
const uint32_t dr) {
|
const uint32_t dr) {
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class HDF5DataFile : private virtual slsDetectorDefs, public File {
|
|||||||
|
|
||||||
void CreateFirstHDF5DataFile(const std::string &fNamePrefix,
|
void CreateFirstHDF5DataFile(const std::string &fNamePrefix,
|
||||||
const uint64_t fIndex, const bool owEnable,
|
const uint64_t fIndex, const bool owEnable,
|
||||||
const bool sMode, const uint32_t uPortNumber,
|
const bool sMode, const uint16_t uPortNumber,
|
||||||
const uint32_t mFramesPerFile,
|
const uint32_t mFramesPerFile,
|
||||||
const uint64_t nImages, const uint32_t nX,
|
const uint64_t nImages, const uint32_t nX,
|
||||||
const uint32_t nY, const uint32_t dr) override;
|
const uint32_t nY, const uint32_t dr) override;
|
||||||
@ -69,7 +69,7 @@ class HDF5DataFile : private virtual slsDetectorDefs, public File {
|
|||||||
uint64_t fileIndex{0};
|
uint64_t fileIndex{0};
|
||||||
bool overWriteEnable{false};
|
bool overWriteEnable{false};
|
||||||
bool silentMode{false};
|
bool silentMode{false};
|
||||||
uint32_t udpPortNumber{0};
|
uint16_t udpPortNumber{0};
|
||||||
|
|
||||||
static const int EIGER_NUM_PIXELS{256 * 2 * 256};
|
static const int EIGER_NUM_PIXELS{256 * 2 * 256};
|
||||||
static const int EIGER_16_BIT_IMAGE_SIZE{EIGER_NUM_PIXELS * 2};
|
static const int EIGER_16_BIT_IMAGE_SIZE{EIGER_NUM_PIXELS * 2};
|
||||||
|
@ -1140,17 +1140,17 @@ void Implementation::setEthernetInterface2(const std::string &c) {
|
|||||||
LOG(logINFO) << "Ethernet Interface 2: " << eth[1];
|
LOG(logINFO) << "Ethernet Interface 2: " << eth[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Implementation::getUDPPortNumber() const { return udpPortNum[0]; }
|
uint16_t Implementation::getUDPPortNumber() const { return udpPortNum[0]; }
|
||||||
|
|
||||||
void Implementation::setUDPPortNumber(const uint32_t i) {
|
void Implementation::setUDPPortNumber(const uint16_t i) {
|
||||||
udpPortNum[0] = i;
|
udpPortNum[0] = i;
|
||||||
listener[0]->SetUdpPortNumber(i);
|
listener[0]->SetUdpPortNumber(i);
|
||||||
LOG(logINFO) << "UDP Port Number[0]: " << udpPortNum[0];
|
LOG(logINFO) << "UDP Port Number[0]: " << udpPortNum[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Implementation::getUDPPortNumber2() const { return udpPortNum[1]; }
|
uint16_t Implementation::getUDPPortNumber2() const { return udpPortNum[1]; }
|
||||||
|
|
||||||
void Implementation::setUDPPortNumber2(const uint32_t i) {
|
void Implementation::setUDPPortNumber2(const uint16_t i) {
|
||||||
udpPortNum[1] = i;
|
udpPortNum[1] = i;
|
||||||
if (listener.size() > 1) {
|
if (listener.size() > 1) {
|
||||||
listener[1]->SetUdpPortNumber(i);
|
listener[1]->SetUdpPortNumber(i);
|
||||||
@ -1251,9 +1251,9 @@ void Implementation::setStreamingStartingFrameNumber(const uint32_t fnum) {
|
|||||||
LOG(logINFO) << "Streaming Start Frame num: " << streamingStartFnum;
|
LOG(logINFO) << "Streaming Start Frame num: " << streamingStartFnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Implementation::getStreamingPort() const { return streamingPort; }
|
uint16_t Implementation::getStreamingPort() const { return streamingPort; }
|
||||||
|
|
||||||
void Implementation::setStreamingPort(const uint32_t i) {
|
void Implementation::setStreamingPort(const uint16_t i) {
|
||||||
streamingPort = i;
|
streamingPort = i;
|
||||||
LOG(logINFO) << "Streaming Port: " << streamingPort;
|
LOG(logINFO) << "Streaming Port: " << streamingPort;
|
||||||
}
|
}
|
||||||
|
@ -117,11 +117,11 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
std::string getEthernetInterface2() const;
|
std::string getEthernetInterface2() const;
|
||||||
/* [Jungfrau][Moench] */
|
/* [Jungfrau][Moench] */
|
||||||
void setEthernetInterface2(const std::string &c);
|
void setEthernetInterface2(const std::string &c);
|
||||||
uint32_t getUDPPortNumber() const;
|
uint16_t getUDPPortNumber() const;
|
||||||
void setUDPPortNumber(const uint32_t i);
|
void setUDPPortNumber(const uint16_t i);
|
||||||
uint32_t getUDPPortNumber2() const;
|
uint16_t getUDPPortNumber2() const;
|
||||||
/* [Eiger][Jungfrau][Moench] */
|
/* [Eiger][Jungfrau][Moench] */
|
||||||
void setUDPPortNumber2(const uint32_t i);
|
void setUDPPortNumber2(const uint16_t i);
|
||||||
int getUDPSocketBufferSize() const;
|
int getUDPSocketBufferSize() const;
|
||||||
void setUDPSocketBufferSize(const int s);
|
void setUDPSocketBufferSize(const int s);
|
||||||
int getActualUDPSocketBufferSize() const;
|
int getActualUDPSocketBufferSize() const;
|
||||||
@ -140,8 +140,8 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
void setStreamingTimer(const uint32_t time_in_ms);
|
void setStreamingTimer(const uint32_t time_in_ms);
|
||||||
uint32_t getStreamingStartingFrameNumber() const;
|
uint32_t getStreamingStartingFrameNumber() const;
|
||||||
void setStreamingStartingFrameNumber(const uint32_t fnum);
|
void setStreamingStartingFrameNumber(const uint32_t fnum);
|
||||||
uint32_t getStreamingPort() const;
|
uint16_t getStreamingPort() const;
|
||||||
void setStreamingPort(const uint32_t i);
|
void setStreamingPort(const uint16_t i);
|
||||||
IpAddr getStreamingSourceIP() const;
|
IpAddr getStreamingSourceIP() const;
|
||||||
void setStreamingSourceIP(const IpAddr ip);
|
void setStreamingSourceIP(const IpAddr ip);
|
||||||
int getStreamingHwm() const;
|
int getStreamingHwm() const;
|
||||||
@ -336,7 +336,7 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
|
|
||||||
// network configuration (UDP)
|
// network configuration (UDP)
|
||||||
std::array<std::string, MAX_NUMBER_OF_LISTENING_THREADS> eth;
|
std::array<std::string, MAX_NUMBER_OF_LISTENING_THREADS> eth;
|
||||||
std::array<uint32_t, MAX_NUMBER_OF_LISTENING_THREADS> udpPortNum{
|
std::array<uint16_t, MAX_NUMBER_OF_LISTENING_THREADS> udpPortNum{
|
||||||
{DEFAULT_UDP_DST_PORTNO, DEFAULT_UDP_DST_PORTNO + 1}};
|
{DEFAULT_UDP_DST_PORTNO, DEFAULT_UDP_DST_PORTNO + 1}};
|
||||||
int actualUDPSocketBufferSize{0};
|
int actualUDPSocketBufferSize{0};
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
uint32_t streamingFrequency{1};
|
uint32_t streamingFrequency{1};
|
||||||
uint32_t streamingTimerInMs{DEFAULT_STREAMING_TIMER_IN_MS};
|
uint32_t streamingTimerInMs{DEFAULT_STREAMING_TIMER_IN_MS};
|
||||||
uint32_t streamingStartFnum{0};
|
uint32_t streamingStartFnum{0};
|
||||||
uint32_t streamingPort{0};
|
uint16_t streamingPort{0};
|
||||||
IpAddr streamingSrcIP = IpAddr{};
|
IpAddr streamingSrcIP = IpAddr{};
|
||||||
int streamingHwm{-1};
|
int streamingHwm{-1};
|
||||||
std::map<std::string, std::string> additionalJsonHeader;
|
std::map<std::string, std::string> additionalJsonHeader;
|
||||||
|
@ -71,7 +71,7 @@ void Listener::SetFifo(Fifo *f) { fifo = f; }
|
|||||||
|
|
||||||
void Listener::SetGeneralData(GeneralData *g) { generalData = g; }
|
void Listener::SetGeneralData(GeneralData *g) { generalData = g; }
|
||||||
|
|
||||||
void Listener::SetUdpPortNumber(const uint32_t portNumber) {
|
void Listener::SetUdpPortNumber(const uint16_t portNumber) {
|
||||||
udpPortNumber = portNumber;
|
udpPortNumber = portNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
|
|
||||||
void SetFifo(Fifo *f);
|
void SetFifo(Fifo *f);
|
||||||
void SetGeneralData(GeneralData *g);
|
void SetGeneralData(GeneralData *g);
|
||||||
void SetUdpPortNumber(const uint32_t portNumber);
|
void SetUdpPortNumber(const uint16_t portNumber);
|
||||||
void SetEthernetInterface(const std::string e);
|
void SetEthernetInterface(const std::string e);
|
||||||
void SetActivate(bool enable);
|
void SetActivate(bool enable);
|
||||||
void SetDetectorDatastream(bool enable);
|
void SetDetectorDatastream(bool enable);
|
||||||
@ -112,7 +112,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
std::atomic<runStatus> *status;
|
std::atomic<runStatus> *status;
|
||||||
std::unique_ptr<UdpRxSocket> udpSocket{nullptr};
|
std::unique_ptr<UdpRxSocket> udpSocket{nullptr};
|
||||||
|
|
||||||
uint32_t udpPortNumber{0};
|
uint16_t udpPortNumber{0};
|
||||||
std::string eth;
|
std::string eth;
|
||||||
bool activated{false};
|
bool activated{false};
|
||||||
bool detectorDataStream{true};
|
bool detectorDataStream{true};
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
/* Creates the slsMultiReceiver for running multiple receivers form a single
|
/* Creates the slsMultiReceiver for running multiple receivers form a single
|
||||||
* binary */
|
* binary */
|
||||||
#include "sls/Receiver.h"
|
#include "sls/Receiver.h"
|
||||||
|
#include "sls/ToString.h"
|
||||||
#include "sls/container_utils.h"
|
#include "sls/container_utils.h"
|
||||||
#include "sls/logger.h"
|
#include "sls/logger.h"
|
||||||
#include "sls/sls_detector_defs.h"
|
#include "sls/sls_detector_defs.h"
|
||||||
@ -36,14 +37,12 @@ void sigInterruptHandler(int p) { sem_post(&semaphore); }
|
|||||||
/**
|
/**
|
||||||
* prints usage of this example program
|
* prints usage of this example program
|
||||||
*/
|
*/
|
||||||
void printHelp() {
|
std::string getHelpMessage() {
|
||||||
cprintf(
|
return std::string(
|
||||||
RESET,
|
"\n\nUsage:\n"
|
||||||
"Usage:\n"
|
"./slsMultiReceiver(detReceiver) [start_tcp_port (non-zero and 16 "
|
||||||
"./slsMultiReceiver(detReceiver) [start_tcp_port] "
|
"bit)] [num_receivers] [optional: 1 for call back (print frame header "
|
||||||
"[num_receivers] [optional: 1 for call back (print frame header for "
|
"for debugging), 0 for none (default)]\n\n");
|
||||||
"debugging), 0 for none (default)]\n\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,25 +139,31 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
/** - set default values */
|
/** - set default values */
|
||||||
int numReceivers = 1;
|
int numReceivers = 1;
|
||||||
int startTCPPort = 1954;
|
uint16_t startTCPPort = 1954;
|
||||||
int withCallback = 0;
|
int withCallback = 0;
|
||||||
sem_init(&semaphore, 1, 0);
|
sem_init(&semaphore, 1, 0);
|
||||||
|
|
||||||
/** - get number of receivers and start tcp port from command line
|
/** - get number of receivers and start tcp port from command line
|
||||||
* arguments */
|
* arguments */
|
||||||
if (argc != 3 && argc != 4)
|
try {
|
||||||
printHelp();
|
if (argc == 3 || argc == 4) {
|
||||||
if ((argc == 3) && ((!sscanf(argv[1], "%d", &startTCPPort)) ||
|
startTCPPort = sls::StringTo<uint16_t>(argv[1]);
|
||||||
(!sscanf(argv[2], "%d", &numReceivers))))
|
if (startTCPPort == 0) {
|
||||||
printHelp();
|
throw;
|
||||||
if ((argc == 4) && ((!sscanf(argv[1], "%d", &startTCPPort)) ||
|
}
|
||||||
(!sscanf(argv[2], "%d", &numReceivers)) ||
|
numReceivers = std::stoi(argv[2]);
|
||||||
(!sscanf(argv[3], "%d", &withCallback))))
|
if (argc == 4) {
|
||||||
printHelp();
|
withCallback = std::stoi(argv[3]);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
throw;
|
||||||
|
} catch (...) {
|
||||||
|
throw std::runtime_error(getHelpMessage());
|
||||||
|
}
|
||||||
|
|
||||||
cprintf(BLUE, "Parent Process Created [ Tid: %ld ]\n", (long)gettid());
|
cprintf(BLUE, "Parent Process Created [ Tid: %ld ]\n", (long)gettid());
|
||||||
cprintf(RESET, "Number of Receivers: %d\n", numReceivers);
|
cprintf(RESET, "Number of Receivers: %d\n", numReceivers);
|
||||||
cprintf(RESET, "Start TCP Port: %d\n", startTCPPort);
|
cprintf(RESET, "Start TCP Port: %hu\n", startTCPPort);
|
||||||
cprintf(RESET, "Callback Enable: %d\n", withCallback);
|
cprintf(RESET, "Callback Enable: %d\n", withCallback);
|
||||||
|
|
||||||
/** - Catch signal SIGINT to close files and call destructors properly */
|
/** - Catch signal SIGINT to close files and call destructors properly */
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
#include "sls/Receiver.h"
|
#include "sls/Receiver.h"
|
||||||
#include "ClientInterface.h"
|
#include "ClientInterface.h"
|
||||||
|
#include "sls/ToString.h"
|
||||||
#include "sls/container_utils.h"
|
#include "sls/container_utils.h"
|
||||||
#include "sls/logger.h"
|
#include "sls/logger.h"
|
||||||
#include "sls/sls_detector_exceptions.h"
|
#include "sls/sls_detector_exceptions.h"
|
||||||
@ -29,7 +30,7 @@ Receiver::~Receiver() = default;
|
|||||||
Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
|
Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
|
||||||
|
|
||||||
// options
|
// options
|
||||||
int tcpip_port_no = 1954;
|
uint16_t tcpip_port_no = 1954;
|
||||||
uid_t userid = -1;
|
uid_t userid = -1;
|
||||||
|
|
||||||
// parse command line for config
|
// parse command line for config
|
||||||
@ -51,6 +52,15 @@ Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
|
|||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
|
|
||||||
|
std::string help_message =
|
||||||
|
"\nUsage: " + std::string(argv[0]) + " [arguments]\n" +
|
||||||
|
"Possible arguments are:\n" +
|
||||||
|
"\t-t, --rx_tcpport <port> : TCP Communication Port with "
|
||||||
|
"client. Non-zero and 16 bit.\n" +
|
||||||
|
"\t-u, --uid <user id> : Set effective user id if receiver "
|
||||||
|
"\n" +
|
||||||
|
"\t started with privileges. \n\n";
|
||||||
|
|
||||||
while (c != -1) {
|
while (c != -1) {
|
||||||
c = getopt_long(argc, argv, "hvf:t:u:", long_options, &option_index);
|
c = getopt_long(argc, argv, "hvf:t:u:", long_options, &option_index);
|
||||||
|
|
||||||
@ -61,12 +71,18 @@ Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
|
|||||||
switch (c) {
|
switch (c) {
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
sscanf(optarg, "%d", &tcpip_port_no);
|
try {
|
||||||
|
tcpip_port_no = sls::StringTo<uint16_t>(optarg);
|
||||||
|
validatePortNumber(tcpip_port_no);
|
||||||
|
} catch (...) {
|
||||||
|
throw RuntimeError("Could not scan TCP port number." +
|
||||||
|
help_message);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'u':
|
case 'u':
|
||||||
if (sscanf(optarg, "%u", &userid) != 1) {
|
if (sscanf(optarg, "%u", &userid) != 1) {
|
||||||
throw RuntimeError("Could not scan uid");
|
throw RuntimeError("Could not scan uid" + help_message);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -76,19 +92,9 @@ Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
|
|||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
|
std::cout << help_message << std::endl;
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
default:
|
default:
|
||||||
std::cout << std::endl;
|
|
||||||
|
|
||||||
std::string help_message =
|
|
||||||
"Usage: " + std::string(argv[0]) + " [arguments]\n" +
|
|
||||||
"Possible arguments are:\n" +
|
|
||||||
"\t-t, --rx_tcpport <port> : TCP Communication Port with "
|
|
||||||
"client. \n" +
|
|
||||||
"\t-u, --uid <user id> : Set effective user id if receiver "
|
|
||||||
"\n" +
|
|
||||||
"\t started with privileges. \n\n";
|
|
||||||
|
|
||||||
// std::cout << help_message << std::endl;
|
|
||||||
throw RuntimeError(help_message);
|
throw RuntimeError(help_message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,7 +124,7 @@ Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
|
|||||||
tcpipInterface = make_unique<ClientInterface>(tcpip_port_no);
|
tcpipInterface = make_unique<ClientInterface>(tcpip_port_no);
|
||||||
}
|
}
|
||||||
|
|
||||||
Receiver::Receiver(int tcpip_port_no) {
|
Receiver::Receiver(uint16_t tcpip_port_no) {
|
||||||
// might throw an exception
|
// might throw an exception
|
||||||
tcpipInterface = make_unique<ClientInterface>(tcpip_port_no);
|
tcpipInterface = make_unique<ClientInterface>(tcpip_port_no);
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,9 @@ std::ostream &operator<<(std::ostream &os,
|
|||||||
std::string ToString(const slsDetectorDefs::currentSrcParameters &r);
|
std::string ToString(const slsDetectorDefs::currentSrcParameters &r);
|
||||||
std::ostream &operator<<(std::ostream &os,
|
std::ostream &operator<<(std::ostream &os,
|
||||||
const slsDetectorDefs::currentSrcParameters &r);
|
const slsDetectorDefs::currentSrcParameters &r);
|
||||||
|
std::string ToString(const slsDetectorDefs::pedestalParameters &r);
|
||||||
|
std::ostream &operator<<(std::ostream &os,
|
||||||
|
const slsDetectorDefs::pedestalParameters &r);
|
||||||
const std::string &ToString(const std::string &s);
|
const std::string &ToString(const std::string &s);
|
||||||
|
|
||||||
/** Convert std::chrono::duration with specified output unit */
|
/** Convert std::chrono::duration with specified output unit */
|
||||||
@ -316,6 +319,8 @@ template <> defs::vetoAlgorithm StringTo(const std::string &s);
|
|||||||
template <> defs::gainMode StringTo(const std::string &s);
|
template <> defs::gainMode StringTo(const std::string &s);
|
||||||
template <> defs::polarity StringTo(const std::string &s);
|
template <> defs::polarity StringTo(const std::string &s);
|
||||||
|
|
||||||
|
template <> uint8_t StringTo(const std::string &s);
|
||||||
|
template <> uint16_t StringTo(const std::string &s);
|
||||||
template <> uint32_t StringTo(const std::string &s);
|
template <> uint32_t StringTo(const std::string &s);
|
||||||
template <> uint64_t StringTo(const std::string &s);
|
template <> uint64_t StringTo(const std::string &s);
|
||||||
template <> int StringTo(const std::string &s);
|
template <> int StringTo(const std::string &s);
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user