mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-17 15:27:13 +02:00
Compare commits
55 Commits
8.0.1
...
moench8.0.
Author | SHA1 | Date | |
---|---|---|---|
e575fc0933 | |||
cc233686f1 | |||
64d489f1e6 | |||
56abf82d92 | |||
3d21bb64c4 | |||
f6b0ba9703 | |||
e5bea401a0 | |||
ecda5db97e | |||
d17bc5da62 | |||
a884db0e2c | |||
5e9fd43d49 | |||
8bce89d5dc | |||
aa40128965 | |||
7d9bc6d6eb | |||
a03780718e | |||
bd1a125154 | |||
ffe7728966 | |||
b69e053bb4 | |||
daec0dc389 | |||
c8bb70f876 | |||
9a08ecc5a5 | |||
9738cb7d74 | |||
4f4125a3b2 | |||
51412f40cf | |||
ce7270e8a2 | |||
664de6b204 | |||
d72c9e29a4 | |||
62dc0e1a34 | |||
d7aa3305d1 | |||
96ed74c47c | |||
4198db8365 | |||
e2d7af28dc | |||
66d57c1852 | |||
aa4bf6e7f9 | |||
7f0868f344 | |||
e57cf49c49 | |||
66baaf1ebd | |||
7d7ac26c30 | |||
1a7c74fe4e | |||
01e4bcb47e | |||
397e846509 | |||
314a8a0daa | |||
ebb352b13a | |||
9b5d44f0b3 | |||
1892963fcb | |||
62f45b15d2 | |||
82ac45873c | |||
2b2e50916c | |||
d34f396ef8 | |||
f9c4405da6 | |||
8ab2aa589d | |||
b4e06eb62b | |||
c7c672ccde | |||
18cdd6a2f7 | |||
799903dddb |
2
.github/workflows/cmake.yml
vendored
2
.github/workflows/cmake.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: libzmq3-dev libhdf5-dev qtbase5-dev qt5-qmake libqt5svg5-dev
|
||||
packages: libhdf5-dev qtbase5-dev qt5-qmake libqt5svg5-dev
|
||||
version: 1.0
|
||||
|
||||
- name: Configure CMake
|
||||
|
1
CMakeFiles/cmake.check_cache
Normal file
1
CMakeFiles/cmake.check_cache
Normal file
@ -0,0 +1 @@
|
||||
# This file is generated by cmake for dependency checking of the CMakeCache.txt file
|
@ -33,7 +33,7 @@ else()
|
||||
# Standard behaviour use libzmq included in this repo (libs/libzmq)
|
||||
FetchContent_Declare(
|
||||
libzmq
|
||||
URL ${CMAKE_SOURCE_DIR}/libs/libzmq/libzmq-4.3.4.tar.gz
|
||||
URL ${CMAKE_CURRENT_SOURCE_DIR}/libs/libzmq/libzmq-4.3.4.tar.gz
|
||||
URL_HASH MD5=cc20b769ac10afa352e5ed2769bb23b3
|
||||
)
|
||||
endif()
|
||||
@ -232,6 +232,8 @@ if (NOT TARGET slsProjectCSettings)
|
||||
-Wredundant-decls
|
||||
-Wdouble-promotion
|
||||
-Werror=return-type
|
||||
-Wno-format-overflow
|
||||
-Wno-format-truncation
|
||||
)
|
||||
sls_disable_c_warning("-Wstringop-truncation")
|
||||
endif()
|
||||
@ -244,6 +246,7 @@ if(SLS_USE_SANITIZER)
|
||||
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
|
||||
endif()
|
||||
|
||||
|
||||
if(SLS_TUNE_LOCAL)
|
||||
target_compile_options(slsProjectOptions INTERFACE -mtune=native -march=native)
|
||||
endif()
|
||||
|
1
bash_autocomplete.sh
Symbolic link
1
bash_autocomplete.sh
Symbolic link
@ -0,0 +1 @@
|
||||
slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh
|
2
cmk.sh
2
cmk.sh
@ -26,7 +26,7 @@ CMAKE_PRE=""
|
||||
CMAKE_POST=""
|
||||
|
||||
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
|
||||
-b: Builds/Rebuilds CMake files normal mode
|
||||
-c: Clean
|
||||
|
@ -2,7 +2,6 @@ python:
|
||||
- 3.8
|
||||
- 3.9
|
||||
- 3.10
|
||||
- 3.11
|
||||
- 3.11
|
||||
- 3.12
|
||||
|
||||
numpy:
|
||||
- 1.17
|
||||
|
@ -18,7 +18,6 @@ requirements:
|
||||
- {{compiler('cxx')}}
|
||||
- cmake
|
||||
- qt 5.*
|
||||
- zeromq
|
||||
- xorg-libx11
|
||||
- xorg-libice
|
||||
- xorg-libxext
|
||||
@ -37,7 +36,6 @@ requirements:
|
||||
host:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- zeromq
|
||||
- xorg-libx11
|
||||
- xorg-libice
|
||||
- xorg-libxext
|
||||
@ -48,7 +46,6 @@ requirements:
|
||||
- expat
|
||||
|
||||
run:
|
||||
- zeromq
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
|
||||
@ -63,15 +60,11 @@ outputs:
|
||||
- {{compiler('cxx')}}
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- zeromq
|
||||
|
||||
host:
|
||||
- zeromq
|
||||
|
||||
run:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- zeromq
|
||||
|
||||
- name: slsdet
|
||||
|
||||
@ -84,10 +77,12 @@ outputs:
|
||||
- {{compiler('cxx')}}
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
- setuptools
|
||||
- pybind11=2.11
|
||||
|
||||
host:
|
||||
- python
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
- pybind11=2.11
|
||||
|
||||
|
||||
run:
|
||||
|
@ -19,7 +19,7 @@ A minimal CMakeLists.txt could look like this:
|
||||
.. code-block:: cmake
|
||||
|
||||
project(myDetectorIntegration)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
add_subdirectory(slsDetectorPackage)
|
||||
|
||||
#Add your executable
|
||||
@ -43,7 +43,7 @@ should be needed, otherwise specify cmake prefix path.
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(myintegration)
|
||||
|
||||
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:
|
||||
|
||||
* 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)
|
||||
* ZeroMQ version 4
|
||||
|
||||
-----------------------
|
||||
GUI
|
||||
-----------------------
|
||||
|
||||
* Qt 5.9
|
||||
* Qwt 6.1.5 (packaged in libs/)
|
||||
|
||||
-----------------------
|
||||
Python bindings
|
||||
-----------------------
|
||||
|
||||
* 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
|
||||
@ -54,4 +66,6 @@ Packaged in libs/
|
||||
|
||||
* catch2 (unit testing)
|
||||
* rapidjson (streaming from receiver)
|
||||
* pybind11 (python bindings)
|
||||
* pybind11 (python bindings)
|
||||
* qwt (gui plotting)
|
||||
* libzmq (streaming to/from receiver)
|
@ -1,16 +1,19 @@
|
||||
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
|
||||
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.
|
||||
|
||||
Most, if not all, functions are called in parallel
|
||||
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
|
||||
:members:
|
||||
:undoc-members:
|
@ -1,3 +1,4 @@
|
||||
.. _Cplusplus Api Examples:
|
||||
|
||||
|
||||
|
||||
@ -53,8 +54,8 @@ then set up the detector.
|
||||
|
||||
jungfrauDetectorServer_virtual
|
||||
|
||||
This launches a virtual Jungfrau detector server. As default is uses port 1952 and 1953
|
||||
for communication over TCP. Most commands go on 1952 and only stop and status on 1953.
|
||||
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 a few such as stop and status on 1953.
|
||||
|
||||
**Run example to configure**
|
||||
|
||||
@ -90,7 +91,10 @@ std::vector.
|
||||
sls::Result<int> res1{1, 1, 1};
|
||||
std::cout << "res1: " << res1 << '\n';
|
||||
res1.squash();
|
||||
# return -1 if different
|
||||
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
|
||||
# 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
|
||||
|
||||
# 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
|
||||
# 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
|
||||
|
||||
# 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
|
||||
# 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
|
||||
|
||||
# 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
|
||||
# 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
|
||||
|
||||
# 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
|
||||
# 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
|
||||
|
||||
# v6.1.1 - present (copies server from the full path provided)
|
||||
|
@ -8,8 +8,8 @@ Welcome to slsDetectorPackage's documentation!
|
||||
|
||||
.. note ::
|
||||
|
||||
This is the documentation for the latest development version of slsDetectorPackage
|
||||
For documentation on current and previous releases visit the official page: https://www.psi.ch/en/detectors/documentation
|
||||
This is the documentation for the latest development version of slsDetectorPackage.
|
||||
For further documentation, visit the official page: https://www.psi.ch/en/detectors/documentation
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
@ -57,7 +57,6 @@ We have three different packages available:
|
||||
Build from source
|
||||
-------------------
|
||||
|
||||
|
||||
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
|
||||
|
||||
.. note ::
|
||||
|
||||
| **Pybind for Python**
|
||||
| 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
|
||||
|
||||
For v6.x.x of slsDetectorPackage and older, refer :ref:`pybind11 notes on cloning. <pybind for different slsDetectorPackage versions>`
|
||||
|
||||
.. _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 ..
|
||||
|
||||
# choose the options
|
||||
# first press [c] - configure
|
||||
# first press [c] - configure (maybe multiple times till you see [g])
|
||||
# then press [g] - generate
|
||||
|
||||
|
||||
|
||||
=============================== ===========================================
|
||||
=============================== ===============================
|
||||
Example cmake options Comment
|
||||
=============================== ===========================================
|
||||
=============================== ===============================
|
||||
-DSLS_USE_PYTHON=ON Python
|
||||
-DPython_FIND_VIRTUALENV=ONLY Python from only the conda environment
|
||||
-DZeroMQ_HINT=/usr/lib64 Use system zmq instead
|
||||
-DPython_FIND_VIRTUALENV=ONLY Python from the conda env
|
||||
-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
|
||||
@ -142,9 +130,9 @@ Build using in-built cmk.sh script
|
||||
|
||||
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>]
|
||||
[-k <CMake command>] [-l <Install directory>] [m] [n] [-p] [-q <Zmq hint directory>]
|
||||
[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
|
||||
-b: Builds/Rebuilds CMake files normal mode
|
||||
-c: Clean
|
||||
@ -159,7 +147,6 @@ Build using in-built cmk.sh script
|
||||
-m: Manuals
|
||||
-n: Manuals without compiling doxygen (only rst)
|
||||
-p: Builds/Rebuilds Python API
|
||||
-q: Zmq hint directory
|
||||
-r: Build/Rebuilds only receiver
|
||||
-s: Simulator
|
||||
-t: Build/Rebuilds only text client
|
||||
@ -176,9 +163,13 @@ Build using in-built cmk.sh script
|
||||
# new build, python and compile in parallel:
|
||||
./cmk.sh -cbpj5
|
||||
|
||||
#To use the system zmq (/usr/lib64) instead
|
||||
./cmk.sh -cbj5 -q /usr/lib64
|
||||
#For rebuilding only certain sections
|
||||
./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
|
||||
@ -191,7 +182,7 @@ using this compiler
|
||||
.. code-block:: bash
|
||||
|
||||
#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
|
||||
|
||||
# outside slsDetecorPackage folder
|
||||
@ -200,6 +191,11 @@ using this compiler
|
||||
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)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -228,9 +224,9 @@ Build slsDetectorGui (Qt5)
|
||||
|
||||
# create environment to compile
|
||||
# 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
|
||||
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
|
||||
|
||||
@ -246,6 +242,9 @@ Build slsDetectorGui (Qt5)
|
||||
cd slsDetectorPackage
|
||||
./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
|
||||
|
||||
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
|
||||
@ -270,3 +269,51 @@ is to use conda
|
||||
|
||||
make docs # generate API docs and build Sphinx RST
|
||||
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
|
||||
hostname bchipxxx+bchipyyy+
|
||||
|
||||
# connects to receivers at ports 2012 and 2014
|
||||
rx_hostname mpc1922:2012+mpc1922:2013+
|
||||
# tcp port increases for each module (multi detector command)
|
||||
rx_tcpport 2012
|
||||
|
||||
# sets differernt destination udp ports
|
||||
0:udp_dstport 50012
|
||||
1:udp_dstport 50014
|
||||
# connects to receivers at ports 2012 and 2014
|
||||
rx_hostname mpc1922
|
||||
|
||||
# increasing udp ports (multi detector command)
|
||||
udp_dstport 50012
|
||||
|
||||
# source udp ips must be same subnet at destintaion udp ips
|
||||
0:udp_srcip 192.168.1.112
|
||||
|
@ -1,3 +1,5 @@
|
||||
.. _Result Class:
|
||||
|
||||
Result
|
||||
==============================================
|
||||
|
||||
|
@ -52,8 +52,13 @@ Client Commands
|
||||
|
||||
# multi modules with custom ports
|
||||
rx_hostname xxx:1955+xxx:1956+
|
||||
|
||||
|
||||
# multi modules using increasing tcp ports when using multi detector command
|
||||
rx_tcpport 1955
|
||||
rx_hostname xxx
|
||||
|
||||
# multi modules with custom ports on same rxr pc
|
||||
# or specify multi modules with custom ports on same rxr pc
|
||||
0:rx_tcpport 1954
|
||||
1:rx_tcpport 1955
|
||||
2:rx_tcpport 1956
|
||||
|
@ -92,6 +92,9 @@ Common
|
||||
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:
|
||||
|
||||
@ -421,3 +424,20 @@ Cannot get multi module data
|
||||
* 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.
|
||||
|
||||
|
||||
|
||||
.. _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
|
||||
|
||||
# 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)
|
||||
udp_dstip auto
|
||||
@ -101,12 +102,14 @@ For Multiple Modules
|
||||
virtual 2 1912
|
||||
# or hostname localhost:1912+localhost:1914+
|
||||
|
||||
# connects to receivers at ports 2012 and 2014
|
||||
rx_hostname mpc1922:2012+mpc1922:2013+
|
||||
# increasing receiver tcp ports (multi detector command)
|
||||
rx_tcpport 2012
|
||||
|
||||
# sets differernt destination udp ports
|
||||
0:udp_dstport 50012
|
||||
1:udp_dstport 50014
|
||||
# connects to reciever at port 2012 and 2013
|
||||
rx_hostname mpc1922
|
||||
|
||||
# sets increasing destination udp ports
|
||||
udp_dstport 50012
|
||||
|
||||
# source udp ips must be same subnet at destintaion udp ips
|
||||
0:udp_srcip 192.168.1.112
|
||||
|
@ -4,27 +4,33 @@ detsize 1024 512
|
||||
# detector hostname for controls
|
||||
hostname beb059+beb058+
|
||||
|
||||
# 1Gb receiver pc hostname with tcp port to configure receiver
|
||||
rx_hostname x12sa-vcons:1991+x12sa-vcons:1992
|
||||
# increasing receiver tcp port (multi detector command)
|
||||
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
|
||||
0:udp_dstport 50011
|
||||
|
||||
#0:udp_dstport 50011
|
||||
# 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
|
||||
0:udp_dstip 10.0.30.210
|
||||
|
||||
# first half module 10 Gb IP (same subnet as 0:udp_dstip)
|
||||
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,
|
||||
1:udp_dstip 10.0.40.210
|
||||
|
||||
|
@ -4,18 +4,23 @@ detsize 1024 512
|
||||
# detector hostname for controls
|
||||
hostname beb059+beb058+
|
||||
|
||||
# 1Gb receiver pc hostname with tcp port to configure receiver
|
||||
rx_hostname x12sa-vcons:1991+x12sa-vcons:1992
|
||||
# increasing receiver tcp port (multi detector command)
|
||||
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
|
||||
0:udp_dstport 50011
|
||||
#0:udp_dstport 50011
|
||||
#udp port second quadrant, first halfmodule
|
||||
0:udp_dstport2 50012
|
||||
|
||||
#0:udp_dstport2 50012
|
||||
# udp port first quadrant, second halfmodule
|
||||
1:udp_dstport 50013
|
||||
#1:udp_dstport 50013
|
||||
# udp port second quadrant, second halfmodule
|
||||
1:udp_dstport2 50014
|
||||
#1:udp_dstport2 50014
|
||||
|
||||
# output directory
|
||||
fpath /sls/X12SA/data/x12saop/Data10/Eiger0.5M
|
||||
|
@ -4,14 +4,18 @@ detsize 1024 1024
|
||||
# detector hostname
|
||||
hostname bchip048+bchip052+
|
||||
|
||||
# 1Gb receiver pc hostname (default tcpport: 1954)
|
||||
rx_hostname pcmoench01:1954+pcmoench01:1955+
|
||||
# increasing receiver ports 1954 and 1955 (multi detector command)
|
||||
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)
|
||||
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)
|
||||
0:udp_srcip 10.1.1.10
|
||||
|
||||
|
||||
|
||||
# udp configurations for 2nd module
|
||||
# udp destination port (receiver)
|
||||
1:udp_dstport 50005
|
||||
|
||||
# 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)
|
||||
1:udp_srcip 10.1.1.11
|
||||
1:udp_srcip 10.1.2.11
|
||||
|
||||
|
||||
|
||||
@ -45,5 +43,5 @@ timing trigger
|
||||
# output file directory
|
||||
fpath /external_pool/jungfrau_data/softwaretest
|
||||
|
||||
# disable file writing
|
||||
# disable file writing (default)
|
||||
fwrite 0
|
22
examples/rawdata.config
Normal file
22
examples/rawdata.config
Normal file
@ -0,0 +1,22 @@
|
||||
numfiles 1
|
||||
nthreads 5,
|
||||
fifosize 5000
|
||||
nsigma 5
|
||||
gainfile none
|
||||
detectorMode counting
|
||||
threshold 0
|
||||
pedestalfile none
|
||||
nframes 0
|
||||
xMin 0
|
||||
xMax 400
|
||||
yMin 0
|
||||
yMax 400
|
||||
outdir ./
|
||||
indir ./
|
||||
flist none
|
||||
fformat none
|
||||
runmin 0
|
||||
runmax -1
|
||||
readnrows 400
|
||||
eMin 0
|
||||
eMax 16000
|
@ -2,10 +2,8 @@
|
||||
hostname localhost:1900+localhost:1902+
|
||||
|
||||
# udp destination ports
|
||||
0:udp_dstport 50000
|
||||
0:udp_dstport2 50001
|
||||
1:udp_dstport 50002
|
||||
1:udp_dstport2 50003
|
||||
udp_dstport 50000
|
||||
udp_dstport2 50001
|
||||
|
||||
# receiver hostname
|
||||
rx_hostname mpc1922:2000+mpc1922:2001+
|
||||
|
@ -5,24 +5,26 @@ detsize 2048 1024
|
||||
virtual 4 1952
|
||||
|
||||
# udp destination ports
|
||||
0:udp_dstport2 50001
|
||||
0:udp_dstport2 50002
|
||||
1:udp_dstport 50003
|
||||
1:udp_dstport2 50004
|
||||
2:udp_dstport 50005
|
||||
2:udp_dstport2 50006
|
||||
3:udp_dstport 50007
|
||||
3:udp_dstport2 50008
|
||||
udp_dstport 50001
|
||||
#0:udp_dstport2 50001
|
||||
#0:udp_dstport2 50002
|
||||
#1:udp_dstport 50003
|
||||
#1:udp_dstport2 50004
|
||||
#2:udp_dstport 50005
|
||||
#2:udp_dstport2 50006
|
||||
#3:udp_dstport 50007
|
||||
#3:udp_dstport2 50008
|
||||
|
||||
# udp source ip (same subnet as udp_dstip)
|
||||
udp_srcip 192.168.1.100
|
||||
udp_srcip2 192.168.1.100
|
||||
|
||||
# receiver hostname and tcpports
|
||||
0:rx_tcpport 1970
|
||||
1:rx_tcpport 1971
|
||||
2:rx_tcpport 1972
|
||||
3:rx_tcpport 1973
|
||||
rx_tcpport 1970
|
||||
#0:rx_tcpport 1970
|
||||
#1:rx_tcpport 1971
|
||||
#2:rx_tcpport 1972
|
||||
#3:rx_tcpport 1973
|
||||
rx_hostname mpc1922
|
||||
|
||||
# udp destination ip from rx_hostname
|
||||
|
16
examples/zmq.config
Normal file
16
examples/zmq.config
Normal file
@ -0,0 +1,16 @@
|
||||
numinterfaces 1
|
||||
rx_zmqip 10.1.2.102
|
||||
rx_zmqport 1978
|
||||
zmqip 129.129.202.57
|
||||
zmqport 1979
|
||||
nthreads 6
|
||||
fifosize 5000
|
||||
nsigma 5
|
||||
gainfile none
|
||||
nbinsx 5
|
||||
nbinsy 5
|
||||
etafile none
|
||||
etabinsx 1000
|
||||
etabinsy 1000
|
||||
etamin -1
|
||||
etamax 2
|
@ -3,3 +3,10 @@ slsDetectorPackage/7.0.1_rh7 stable cmake/3.15.5 zeromq/4.3.4 Qt/5.12.10
|
||||
slsDetectorPackage/7.0.1_rh8 stable cmake/3.15.5 zeromq/4.3.4 Qt/5.12.10
|
||||
slsDetectorPackage/7.0.2_rh7 stable cmake/3.15.5 zeromq/4.3.4 Qt/5.12.10
|
||||
slsDetectorPackage/7.0.2_rh8 stable cmake/3.15.5 zeromq/4.3.4 Qt/5.12.10
|
||||
slsDetectorPackage/7.0.3_rh7 stable cmake/3.15.5 zeromq/4.3.4 Qt/5.12.10
|
||||
slsDetectorPackage/7.0.3_rh8 stable cmake/3.15.5 zeromq/4.3.4 Qt/5.12.10
|
||||
slsDetectorPackage/8.0.0_rh7 stable cmake/3.15.5 Qt/5.12.10
|
||||
slsDetectorPackage/8.0.0_rh8 stable cmake/3.15.5 Qt/5.12.10
|
||||
slsDetectorPackage/8.0.1_rh7 stable cmake/3.15.5 Qt/5.12.10
|
||||
slsDetectorPackage/8.0.1_rh8 stable cmake/3.15.5 Qt/5.12.10
|
||||
|
||||
|
@ -7,7 +7,6 @@ Build upon the pybind11 example found here: https://github.com/pybind/python_exa
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.append('../libs/pybind')
|
||||
from setuptools import setup, find_packages
|
||||
from pybind11.setup_helpers import Pybind11Extension, build_ext
|
||||
|
||||
@ -41,11 +40,10 @@ ext_modules = [
|
||||
|
||||
,
|
||||
include_dirs=[
|
||||
os.path.join('../libs/pybind/include'),
|
||||
os.path.join(get_conda_path(), 'include'),
|
||||
|
||||
],
|
||||
libraries=['SlsDetector', 'SlsSupport', 'SlsReceiver', 'zmq'],
|
||||
libraries=['SlsDetector', 'SlsSupport', 'SlsReceiver'],
|
||||
library_dirs=[
|
||||
os.path.join(get_conda_path(), 'lib'),
|
||||
],
|
||||
|
@ -232,7 +232,7 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def hardwareversion(self):
|
||||
"""
|
||||
[Jungfrau][Moench][Gotthard2][Myhten3][Gotthard][Ctb] Hardware version of detector. \n
|
||||
Hardware version of detector. \n
|
||||
[Eiger] Hardware version of front FPGA on detector.
|
||||
"""
|
||||
return self.getHardwareVersion()
|
||||
@ -308,7 +308,7 @@ class Detector(CppDetectorApi):
|
||||
-----
|
||||
[Eiger] Options: 4, 8, 12, 16, 32. If set to 32, also sets clkdivider to 2 (quarter speed), else to 0 (full speed)\n
|
||||
[Mythen3] Options: 8, 16, 32 \n
|
||||
[Jungfrau][Moench][Gotthard][Ctb][Mythen3][Gotthard2] 16
|
||||
[Jungfrau][Moench][Gotthard][Ctb][Mythen3][Gotthard2][Xilinx Ctb] 16
|
||||
"""
|
||||
return self.getDynamicRange()
|
||||
|
||||
@ -360,7 +360,8 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
def settings(self):
|
||||
"""
|
||||
Detector settings. Enum: detectorSettings
|
||||
Detector settings.
|
||||
Enum: detectorSettings
|
||||
|
||||
Note
|
||||
-----
|
||||
@ -399,7 +400,10 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def framesl(self):
|
||||
"""
|
||||
[Gotthard][Jungfrau][Moench][Mythen3][Gotthard2][CTB] Number of frames left in acquisition.\n
|
||||
[Gotthard][Jungfrau][Moench][Mythen3][Gotthard2][CTB][Xilinx CTB] Number of frames left in acquisition.\n
|
||||
|
||||
Note
|
||||
----
|
||||
[Gotthard2] only in continuous auto mode.
|
||||
|
||||
:setter: Not Implemented
|
||||
@ -410,7 +414,7 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def framecounter(self):
|
||||
"""
|
||||
[Jungfrau][Moench][Mythen3][Gotthard2][CTB] Number of frames from start run control.
|
||||
[Jungfrau][Moench][Mythen3][Gotthard2][CTB][Xilinx Ctb] Number of frames from start run control.
|
||||
|
||||
Note
|
||||
-----
|
||||
@ -439,12 +443,13 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def powerchip(self):
|
||||
"""
|
||||
[Jungfrau][Moench][Mythen3][Gotthard2] Power the chip.
|
||||
[Jungfrau][Moench][Mythen3][Gotthard2][Xilinx Ctb] Power the chip.
|
||||
|
||||
Note
|
||||
----
|
||||
[Jungfrau][Moench] Default is disabled. Get will return power status. Can be off if temperature event occured (temperature over temp_threshold with temp_control enabled. Will configure chip (only chip v1.1).\n
|
||||
[Mythen3][Gotthard2] Default is 1. If module not connected or wrong module, powerchip will fail.
|
||||
[Xilinx Ctb] Default is 0. Also configures the chip if powered on.
|
||||
"""
|
||||
return self.getPowerChip()
|
||||
|
||||
@ -452,6 +457,16 @@ class Detector(CppDetectorApi):
|
||||
def powerchip(self, value):
|
||||
ut.set_using_dict(self.setPowerChip, value)
|
||||
|
||||
def configtransceiver(self):
|
||||
"""
|
||||
[Xilinx Ctb] Waits for transceiver to be aligned.
|
||||
|
||||
Note
|
||||
----
|
||||
Chip had to be configured (powered on) before this.
|
||||
"""
|
||||
self.configureTransceiver()
|
||||
|
||||
@property
|
||||
@element
|
||||
def triggers(self):
|
||||
@ -475,7 +490,8 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def gaincaps(self):
|
||||
"""
|
||||
[Mythen3] Gain caps. Enum: M3_GainCaps \n
|
||||
[Mythen3] Gain caps.
|
||||
Enum: M3_GainCaps
|
||||
|
||||
Note
|
||||
----
|
||||
@ -573,8 +589,6 @@ class Detector(CppDetectorApi):
|
||||
"""
|
||||
Period between frames, accepts either a value in seconds or datetime.timedelta
|
||||
|
||||
Note
|
||||
-----
|
||||
:getter: always returns in seconds. To get in DurationWrapper, use getPeriod
|
||||
|
||||
Example
|
||||
@ -617,7 +631,7 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def periodl(self):
|
||||
"""
|
||||
[Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] Period left for current frame.
|
||||
[Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2][Xilinx Ctb] Period left for current frame.
|
||||
|
||||
Note
|
||||
-----
|
||||
@ -639,10 +653,7 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def delay(self):
|
||||
"""
|
||||
[Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] Delay after trigger, accepts either a value in seconds, DurationWrapper or datetime.timedelta
|
||||
|
||||
Note
|
||||
-----
|
||||
[Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2][Xilinx Ctb] Delay after trigger, accepts either a value in seconds, DurationWrapper or datetime.timedelta
|
||||
|
||||
:getter: always returns in seconds. To get in DurationWrapper, use getDelayAfterTrigger
|
||||
|
||||
@ -684,7 +695,7 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def delayl(self):
|
||||
"""
|
||||
[Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] Delay left after trigger during acquisition, accepts either a value in seconds, datetime.timedelta or DurationWrapper
|
||||
[Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2][Xilinx Ctb] Delay left after trigger during acquisition, accepts either a value in seconds, datetime.timedelta or DurationWrapper
|
||||
|
||||
Note
|
||||
-----
|
||||
@ -732,7 +743,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def nextframenumber(self):
|
||||
"""[Eiger][Jungfrau][Moench][CTB] Next frame number. Stopping acquisition might result in different frame numbers for different modules. """
|
||||
"""[Eiger][Jungfrau][Moench][CTB][Xilinx CTB] Next frame number. Stopping acquisition might result in different frame numbers for different modules. """
|
||||
return self.getNextFrameNumber()
|
||||
|
||||
@nextframenumber.setter
|
||||
@ -895,7 +906,8 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def rx_discardpolicy(self):
|
||||
"""
|
||||
Frame discard policy of receiver. Enum: frameDiscardPolicy
|
||||
Frame discard policy of receiver.
|
||||
Enum: frameDiscardPolicy
|
||||
|
||||
Note
|
||||
-----
|
||||
@ -969,7 +981,8 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def fformat(self):
|
||||
""" File format of data file in receiver. Enum: fileFormat
|
||||
""" File format of data file in receiver.
|
||||
Enum: fileFormat
|
||||
|
||||
Note
|
||||
-----
|
||||
@ -1565,7 +1578,8 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def status(self):
|
||||
"""Gets detector status. Enum: runStatus
|
||||
"""Gets detector status.
|
||||
Enum: runStatus
|
||||
|
||||
Note
|
||||
-----
|
||||
@ -1579,7 +1593,8 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def rx_status(self):
|
||||
"""Gets receiver listener status. Enum: runStatus
|
||||
"""Gets receiver listener status.
|
||||
Enum: runStatus
|
||||
|
||||
Note
|
||||
-----
|
||||
@ -1673,6 +1688,11 @@ class Detector(CppDetectorApi):
|
||||
def sync(self):
|
||||
"""
|
||||
[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()
|
||||
|
||||
@ -1803,6 +1823,7 @@ class Detector(CppDetectorApi):
|
||||
def daclist(self):
|
||||
"""
|
||||
List of enums/names for every dac for this detector
|
||||
|
||||
:setter: Only implemented for Chiptestboard
|
||||
|
||||
"""
|
||||
@ -1815,9 +1836,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
def adclist(self):
|
||||
"""
|
||||
List of names for every adc for this board. 32 adcs
|
||||
:setter: Only implemented for Chiptestboard
|
||||
|
||||
[Chiptestboard] List of names for every adc for this board. 32 adcs
|
||||
"""
|
||||
return self.getAdcNames()
|
||||
|
||||
@ -1828,9 +1847,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
def signallist(self):
|
||||
"""
|
||||
List of names for every io signal for this board. 64 signals
|
||||
:setter: Only implemented for Chiptestboard
|
||||
|
||||
[Chiptestboard] List of names for every io signal for this board. 64 signals
|
||||
"""
|
||||
return self.getSignalNames()
|
||||
|
||||
@ -1841,8 +1858,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
def powerlist(self):
|
||||
"""
|
||||
List of names for every power for this board. 5 power supply
|
||||
:setter: Only implemented for Chiptestboard
|
||||
[Chiptestboard] List of names for every power for this board. 5 power supply
|
||||
|
||||
"""
|
||||
return self.getPowerNames()
|
||||
@ -1854,8 +1870,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
def slowadclist(self):
|
||||
"""
|
||||
List of names for every slowadc for this board. 8 slowadc
|
||||
:setter: Only implemented for Chiptestboard
|
||||
[Chiptestboard] List of names for every slowadc for this board. 8 slowadc
|
||||
|
||||
"""
|
||||
return self.getSlowADCNames()
|
||||
@ -1874,7 +1889,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@property
|
||||
def powervalues(self):
|
||||
"""Gets the power values for every power for this detector."""
|
||||
"""[Chiptestboard] Gets the power values for every power for this detector."""
|
||||
return {
|
||||
power.name.lower(): element_if_equal(np.array(self.getPower(power)))
|
||||
for power in self.getPowerList()
|
||||
@ -1882,7 +1897,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@property
|
||||
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 {
|
||||
slowadc.name.lower(): element_if_equal(np.array(self.getSlowADC(slowadc)))
|
||||
for slowadc in self.getSlowADCList()
|
||||
@ -1947,7 +1962,7 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def triggersl(self):
|
||||
"""
|
||||
[Gotthard][Jungfrau][Moench][Mythen3][Gotthard2][CTB] Number of triggers left in acquisition.\n
|
||||
[Gotthard][Jungfrau][Moench][Mythen3][Gotthard2][CTB][Xilinx CTB] Number of triggers left in acquisition.\n
|
||||
|
||||
Note
|
||||
----
|
||||
@ -1960,7 +1975,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def frametime(self):
|
||||
"""[Jungfrau][Moench][Mythen3][Gotthard2][CTB] Timestamp at a frame start.
|
||||
"""[Jungfrau][Moench][Mythen3][Gotthard2][CTB][Xilinx Ctb] Timestamp at a frame start.
|
||||
|
||||
Note
|
||||
----
|
||||
@ -2056,8 +2071,7 @@ class Detector(CppDetectorApi):
|
||||
-----
|
||||
To set default rate correction from trimbit file, use setDefaultRateCorrection
|
||||
|
||||
Known Issue
|
||||
------------
|
||||
Known Issue:
|
||||
|
||||
: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
|
||||
@ -2081,7 +2095,8 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def readoutspeed(self):
|
||||
"""
|
||||
[Eiger][Jungfrau|Gotthard2] Readout speed of chip. Enum: speedLevel
|
||||
[Eiger][Jungfrau|Gotthard2] Readout speed of chip.
|
||||
Enum: speedLevel
|
||||
|
||||
Note
|
||||
-----
|
||||
@ -2170,12 +2185,13 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def timing(self):
|
||||
"""
|
||||
Set Timing Mode of detector. Enum: timingMode
|
||||
Set Timing Mode of detector.
|
||||
Enum: timingMode
|
||||
|
||||
Note
|
||||
-----
|
||||
Default: AUTO_TIMING \n
|
||||
[Jungfrau][Moench][Gotthard][Ctb][Gotthard2] AUTO_TIMING, TRIGGER_EXPOSURE \n
|
||||
[Jungfrau][Moench][Gotthard][Ctb][Gotthard2][Xilinx Ctb] AUTO_TIMING, TRIGGER_EXPOSURE \n
|
||||
[Mythen3] AUTO_TIMING, TRIGGER_EXPOSURE, GATED, TRIGGER_GATED \n
|
||||
[Eiger] AUTO_TIMING, TRIGGER_EXPOSURE, GATED, BURST_TRIGGER
|
||||
"""
|
||||
@ -2230,13 +2246,11 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def type(self):
|
||||
""" Returns detector type. Enum: detectorType
|
||||
|
||||
Note
|
||||
----
|
||||
""" Returns detector type.
|
||||
Enum: detectorType
|
||||
[EIGER, JUNGFRAU, GOTTHARD, MOENCH, MYTHEN3, GOTTHARD2, CHIPTESTBOARD]
|
||||
|
||||
:setter: Not implemented
|
||||
Values: EIGER, JUNGFRAU, GOTTHARD, MOENCH, MYTHEN3, GOTTHARD2, CHIPTESTBOARD
|
||||
"""
|
||||
return self.getDetectorType()
|
||||
|
||||
@ -2497,9 +2511,6 @@ class Detector(CppDetectorApi):
|
||||
"""
|
||||
[Eiger] Measured sub frame period between last sub frame and previous one.
|
||||
|
||||
Note
|
||||
-----
|
||||
|
||||
:setter: Not implemented
|
||||
"""
|
||||
return ut.reduce_time(self.getMeasuredSubFramePeriod())
|
||||
@ -2602,7 +2613,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def runtime(self):
|
||||
"""[Jungfrau][Moench][Mythen3][Gotthard2][CTB] Time from detector start up.
|
||||
"""[Jungfrau][Moench][Mythen3][Gotthard2][CTB][Xilinx Ctb] Time from detector start up.
|
||||
|
||||
Note
|
||||
-----
|
||||
@ -2777,7 +2788,8 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
def gainmode(self):
|
||||
"""
|
||||
[Jungfrau] Detector gain mode. Enum: gainMode
|
||||
[Jungfrau] Detector gain mode.
|
||||
Enum: gainMode
|
||||
|
||||
Note
|
||||
-----
|
||||
@ -2890,11 +2902,8 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
def maxclkphaseshift(self):
|
||||
"""
|
||||
[Gotthard2][Mythen3] Absolute maximum Phase shift of clocks.
|
||||
|
||||
Note
|
||||
----
|
||||
|
||||
[Gotthard2][Mythen3] Absolute maximum Phase shift of clocks.
|
||||
|
||||
:setter: Not Implemented
|
||||
|
||||
Example
|
||||
@ -2912,7 +2921,8 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def timingsource(self):
|
||||
"""
|
||||
[Gotthard2] Timing source. Enum: timingSourceType
|
||||
[Gotthard2] Timing source.
|
||||
Enum: timingSourceType
|
||||
|
||||
Note
|
||||
-----
|
||||
@ -2956,7 +2966,8 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def burstmode(self):
|
||||
"""[Gotthard2] Burst mode of detector. Enum: burstMode
|
||||
"""[Gotthard2] Burst mode of detector.
|
||||
Enum: burstMode
|
||||
|
||||
Note
|
||||
----
|
||||
@ -2974,9 +2985,6 @@ class Detector(CppDetectorApi):
|
||||
"""
|
||||
[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
|
||||
:setter: Not Implemented
|
||||
|
||||
@ -3099,7 +3107,8 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@property
|
||||
def vetoalg(self):
|
||||
"""[Gotthard2] Algorithm used for veto. Enum: vetoAlgorithm, streamingInterface
|
||||
"""[Gotthard2] Algorithm used for veto.
|
||||
Enum: vetoAlgorithm, streamingInterface
|
||||
|
||||
Note
|
||||
----
|
||||
@ -3239,7 +3248,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def transceiverenable(self):
|
||||
"""[Ctb] Transceiver Enable Mask. Enable for each 4 transceiver channel."""
|
||||
"""[CTB][Xilinx CTB] Transceiver Enable Mask. Enable for each 4 transceiver channel."""
|
||||
return self.getTransceiverEnableMask()
|
||||
|
||||
@transceiverenable.setter
|
||||
@ -3273,12 +3282,15 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def romode(self):
|
||||
"""
|
||||
[CTB] Readout mode of detector. Enum: readoutMode
|
||||
[CTB] Readout mode of detector.
|
||||
Enum: readoutMode
|
||||
|
||||
Note
|
||||
------
|
||||
Options: ANALOG_ONLY, DIGITAL_ONLY, ANALOG_AND_DIGITAL, TRANSCEIVER_ONLY, DIGITAL_AND_TRANSCEIVER
|
||||
Default: ANALOG_ONLY
|
||||
[CTB] Options: ANALOG_ONLY, DIGITAL_ONLY, ANALOG_AND_DIGITAL, TRANSCEIVER_ONLY, DIGITAL_AND_TRANSCEIVER
|
||||
[CTB] Default: ANALOG_ONLY
|
||||
[Xilinx CTB] Options: TRANSCEIVER_ONLY
|
||||
[Xilinx CTB] Default: TRANSCEIVER_ONLY
|
||||
|
||||
Example
|
||||
--------
|
||||
@ -3315,7 +3327,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def tsamples(self):
|
||||
"""[CTB] Number of transceiver samples expected. """
|
||||
"""[CTB][Xilinx CTB] Number of transceiver samples expected. """
|
||||
return self.getNumberOfTransceiverSamples()
|
||||
|
||||
@tsamples.setter
|
||||
@ -3379,9 +3391,6 @@ class Detector(CppDetectorApi):
|
||||
def maxdbitphaseshift(self):
|
||||
"""[CTB][Jungfrau] Absolute maximum Phase shift of of the clock to latch digital bits.
|
||||
|
||||
Note
|
||||
-----
|
||||
|
||||
:setter: Not Implemented
|
||||
"""
|
||||
return self.getMaxDBITPhaseShift()
|
||||
@ -3426,9 +3435,6 @@ class Detector(CppDetectorApi):
|
||||
def maxadcphaseshift(self):
|
||||
"""[Jungfrau][Moench][CTB] Absolute maximum Phase shift of ADC clock.
|
||||
|
||||
Note
|
||||
-----
|
||||
|
||||
:setter: Not Implemented
|
||||
"""
|
||||
return self.getMaxADCPhaseShift()
|
||||
@ -3478,20 +3484,14 @@ class Detector(CppDetectorApi):
|
||||
"""
|
||||
[Ctb] Sync clock in MHz.
|
||||
|
||||
Note
|
||||
-----
|
||||
|
||||
:setter: Not implemented
|
||||
"""
|
||||
return self.getSYNCClock()
|
||||
|
||||
@property
|
||||
def pattern(self):
|
||||
"""[Mythen3][Ctb] Loads ASCII pattern file directly to server (instead of executing line by line).
|
||||
|
||||
Note
|
||||
----
|
||||
|
||||
"""[Mythen3][Ctb][Xilinx Ctb] Loads ASCII pattern file directly to server (instead of executing line by line).
|
||||
|
||||
:getter: Not Implemented
|
||||
|
||||
Example
|
||||
@ -3508,7 +3508,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
def patfname(self):
|
||||
"""
|
||||
[Ctb][Mythen3] Gets the pattern file name including path of the last pattern uploaded. Returns an empty if nothing was uploaded or via a server default
|
||||
[Ctb][Mythen3][Xilinx Ctb] Gets the pattern file name including path of the last pattern uploaded. Returns an empty if nothing was uploaded or via a server default
|
||||
file
|
||||
"""
|
||||
return self.getPatterFileName()
|
||||
@ -3533,7 +3533,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def patlimits(self):
|
||||
"""[Ctb][Mythen3] Limits (start and stop address) of complete pattern.
|
||||
"""[Ctb][Mythen3][Xilinx Ctb] Limits (start and stop address) of complete pattern.
|
||||
|
||||
Example
|
||||
---------
|
||||
@ -3553,7 +3553,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def patsetbit(self):
|
||||
"""[Ctb][Mythen3] Sets the mask applied to every pattern to the selected bits.
|
||||
"""[Ctb][Mythen3][Xilinx Ctb] Sets the mask applied to every pattern to the selected bits.
|
||||
|
||||
Example
|
||||
--------
|
||||
@ -3570,7 +3570,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def patmask(self):
|
||||
"""[Ctb][Mythen3] Selects the bits that will have a pattern mask applied to the selected patmask for every pattern.
|
||||
"""[Ctb][Mythen3][Xilinx Ctb] Selects the bits that will have a pattern mask applied to the selected patmask for every pattern.
|
||||
|
||||
Example
|
||||
--------
|
||||
@ -3588,7 +3588,7 @@ class Detector(CppDetectorApi):
|
||||
# @element
|
||||
def patwait(self):
|
||||
"""
|
||||
[Ctb][Mythen3] Wait address of loop level provided.
|
||||
[Ctb][Mythen3][Xilinx Ctb] Wait address of loop level provided.
|
||||
|
||||
Example
|
||||
-------
|
||||
@ -3605,7 +3605,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def patwait0(self):
|
||||
"""[Ctb][Mythen3] Wait 0 address.
|
||||
"""[Ctb][Mythen3][Xilinx Ctb] Wait 0 address.
|
||||
|
||||
Example
|
||||
--------
|
||||
@ -3625,7 +3625,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def patwait1(self):
|
||||
"""[Ctb][Mythen3] Wait 1 address.
|
||||
"""[Ctb][Mythen3][Xilinx Ctb] Wait 1 address.
|
||||
|
||||
Example
|
||||
--------
|
||||
@ -3645,7 +3645,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def patwait2(self):
|
||||
"""[Ctb][Mythen3] Wait 2 address.
|
||||
"""[Ctb][Mythen3][Xilinx Ctb] Wait 2 address.
|
||||
|
||||
Example
|
||||
--------
|
||||
@ -3665,7 +3665,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
def patwaittime(self):
|
||||
"""
|
||||
[Ctb][Mythen3] Wait time in clock cycles of loop level provided.
|
||||
[Ctb][Mythen3][Xilinx Ctb] Wait time in clock cycles of loop level provided.
|
||||
|
||||
Example
|
||||
-------
|
||||
@ -3682,7 +3682,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def patwaittime0(self):
|
||||
"""[Ctb][Mythen3] Wait 0 time in clock cycles."""
|
||||
"""[Ctb][Mythen3][Xilinx Ctb] Wait 0 time in clock cycles."""
|
||||
return self.getPatternWaitTime(0)
|
||||
|
||||
@patwaittime0.setter
|
||||
@ -3693,7 +3693,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def patwaittime1(self):
|
||||
"""[Ctb][Mythen3] Wait 1 time in clock cycles."""
|
||||
"""[Ctb][Mythen3][Xilinx Ctb] Wait 1 time in clock cycles."""
|
||||
return self.getPatternWaitTime(1)
|
||||
|
||||
@patwaittime1.setter
|
||||
@ -3704,7 +3704,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def patwaittime2(self):
|
||||
"""[Ctb][Mythen3] Wait 2 time in clock cycles."""
|
||||
"""[Ctb][Mythen3][Xilinx Ctb] Wait 2 time in clock cycles."""
|
||||
return self.getPatternWaitTime(2)
|
||||
|
||||
@patwaittime2.setter
|
||||
@ -3716,7 +3716,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
def patloop(self):
|
||||
"""
|
||||
[Ctb][Mythen3] Limits (start and stop address) of the loop provided.
|
||||
[Ctb][Mythen3][Xilinx Ctb] Limits (start and stop address) of the loop provided.
|
||||
|
||||
Example
|
||||
-------
|
||||
@ -3733,7 +3733,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def patloop0(self):
|
||||
"""[Ctb][Mythen3] Limits (start and stop address) of loop 0.
|
||||
"""[Ctb][Mythen3][Xilinx Ctb] Limits (start and stop address) of loop 0.
|
||||
|
||||
Example
|
||||
---------
|
||||
@ -3753,7 +3753,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def patloop1(self):
|
||||
"""[Ctb][Mythen3] Limits (start and stop address) of loop 1.
|
||||
"""[Ctb][Mythen3][Xilinx Ctb] Limits (start and stop address) of loop 1.
|
||||
|
||||
Example
|
||||
---------
|
||||
@ -3774,7 +3774,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def patloop2(self):
|
||||
"""[Ctb][Mythen3] Limits (start and stop address) of loop 2.
|
||||
"""[Ctb][Mythen3][Xilinx Ctb] Limits (start and stop address) of loop 2.
|
||||
|
||||
Example
|
||||
---------
|
||||
@ -3796,7 +3796,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
def patnloop(self):
|
||||
"""
|
||||
[Ctb][Mythen3] Number of cycles of the loop provided.
|
||||
[Ctb][Mythen3][Xilinx Ctb] Number of cycles of the loop provided.
|
||||
|
||||
Example
|
||||
-------
|
||||
@ -3813,7 +3813,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def patnloop0(self):
|
||||
"""[Ctb][Mythen3] Number of cycles of loop 0."""
|
||||
"""[Ctb][Mythen3][Xilinx Ctb] Number of cycles of loop 0."""
|
||||
return self.getPatternLoopCycles(0)
|
||||
|
||||
@patnloop0.setter
|
||||
@ -3824,7 +3824,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def patnloop1(self):
|
||||
"""[Ctb][Mythen3] Number of cycles of loop 1."""
|
||||
"""[Ctb][Mythen3][Xilinx Ctb] Number of cycles of loop 1."""
|
||||
return self.getPatternLoopCycles(1)
|
||||
|
||||
@patnloop1.setter
|
||||
@ -3835,7 +3835,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def patnloop2(self):
|
||||
"""[Ctb][Mythen3] Number of cycles of loop 2."""
|
||||
"""[Ctb][Mythen3][Xilinx Ctb] Number of cycles of loop 2."""
|
||||
return self.getPatternLoopCycles(2)
|
||||
|
||||
@patnloop2.setter
|
||||
@ -3846,7 +3846,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def v_a(self):
|
||||
"""[Ctb] Power supply a in mV."""
|
||||
"""[Ctb][Xilinx Ctb] Power supply a in mV."""
|
||||
return self.getPower(dacIndex.V_POWER_A)
|
||||
|
||||
@v_a.setter
|
||||
@ -3857,7 +3857,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def v_b(self):
|
||||
"""[Ctb] Power supply b in mV."""
|
||||
"""[Ctb][Xilinx Ctb] Power supply b in mV."""
|
||||
return self.getPower(dacIndex.V_POWER_B)
|
||||
|
||||
@v_b.setter
|
||||
@ -3868,7 +3868,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def v_c(self):
|
||||
"""[Ctb] Power supply c in mV."""
|
||||
"""[Ctb][Xilinx Ctb] Power supply c in mV."""
|
||||
return self.getPower(dacIndex.V_POWER_C)
|
||||
|
||||
@v_c.setter
|
||||
@ -3879,7 +3879,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def v_d(self):
|
||||
"""[Ctb] Power supply d in mV."""
|
||||
"""[Ctb][Xilinx Ctb] Power supply d in mV."""
|
||||
return self.getPower(dacIndex.V_POWER_D)
|
||||
|
||||
@v_d.setter
|
||||
@ -3890,7 +3890,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def v_io(self):
|
||||
"""[Ctb] Power supply io in mV. Minimum 1200 mV.
|
||||
"""[Ctb][Xilinx Ctb] Power supply io in mV. Minimum 1200 mV.
|
||||
|
||||
Note
|
||||
----
|
||||
@ -3906,7 +3906,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def v_limit(self):
|
||||
"""[Ctb] Soft limit for power supplies (ctb only) and DACS in mV."""
|
||||
"""[Ctb][Xilinx Ctb] Soft limit for power supplies (ctb only) and DACS in mV."""
|
||||
return self.getPower(dacIndex.V_LIMIT)
|
||||
|
||||
@v_limit.setter
|
||||
@ -3919,10 +3919,7 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def im_a(self):
|
||||
"""[Ctb] Measured current of power supply a in mA.
|
||||
|
||||
Note
|
||||
-----
|
||||
|
||||
|
||||
:setter: Not implemented
|
||||
"""
|
||||
return self.getMeasuredCurrent(dacIndex.I_POWER_A)
|
||||
@ -3932,9 +3929,6 @@ class Detector(CppDetectorApi):
|
||||
def im_b(self):
|
||||
"""[Ctb] Measured current of power supply b in mA.
|
||||
|
||||
Note
|
||||
-----
|
||||
|
||||
:setter: Not implemented
|
||||
"""
|
||||
return self.getMeasuredCurrent(dacIndex.I_POWER_B)
|
||||
@ -3944,9 +3938,6 @@ class Detector(CppDetectorApi):
|
||||
def im_c(self):
|
||||
"""[Ctb] Measured current of power supply c in mA.
|
||||
|
||||
Note
|
||||
-----
|
||||
|
||||
:setter: Not implemented
|
||||
"""
|
||||
return self.getMeasuredCurrent(dacIndex.I_POWER_C)
|
||||
@ -3956,9 +3947,6 @@ class Detector(CppDetectorApi):
|
||||
def im_d(self):
|
||||
"""[Ctb] Measured current of power supply d in mA.
|
||||
|
||||
Note
|
||||
-----
|
||||
|
||||
:setter: Not implemented
|
||||
"""
|
||||
return self.getMeasuredCurrent(dacIndex.I_POWER_D)
|
||||
@ -3968,9 +3956,6 @@ class Detector(CppDetectorApi):
|
||||
def im_io(self):
|
||||
"""[Ctb] Measured current of power supply io in mA.
|
||||
|
||||
Note
|
||||
-----
|
||||
|
||||
:setter: Not implemented
|
||||
"""
|
||||
return self.getMeasuredCurrent(dacIndex.I_POWER_IO)
|
||||
@ -4020,9 +4005,6 @@ class Detector(CppDetectorApi):
|
||||
def exptimel(self):
|
||||
"""[Gotthard] Exposure time left for current frame.
|
||||
|
||||
Note
|
||||
-----
|
||||
|
||||
:getter: always returns in seconds. To get in DurationWrapper, use getExptimeLeft
|
||||
:setter: Not Implemented
|
||||
|
||||
@ -4057,9 +4039,6 @@ class Detector(CppDetectorApi):
|
||||
"""
|
||||
[Gotthard2][Mythen3] Frequency of clock in Hz.
|
||||
|
||||
Note
|
||||
----
|
||||
|
||||
:setter: Not implemented. Use clkdiv to set frequency
|
||||
|
||||
Example
|
||||
@ -4079,7 +4058,9 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def polarity(self):
|
||||
"""[Mythen3] Set positive or negative polarity. Enum: polarity"""
|
||||
"""[Mythen3] Set positive or negative polarity.
|
||||
Enum: polarity
|
||||
"""
|
||||
return self.getPolarity()
|
||||
|
||||
@polarity.setter
|
||||
|
@ -1778,6 +1778,10 @@ void init_det(py::module &m) {
|
||||
(std::string(Detector::*)(const defs::dacIndex) const) &
|
||||
Detector::getSlowADCName,
|
||||
py::arg());
|
||||
CppDetectorApi.def("configureTransceiver",
|
||||
(void (Detector::*)(sls::Positions)) &
|
||||
Detector::configureTransceiver,
|
||||
py::arg() = Positions{});
|
||||
CppDetectorApi.def(
|
||||
"getPatterFileName",
|
||||
(Result<std::string>(Detector::*)(sls::Positions) const) &
|
||||
|
@ -25,6 +25,8 @@ void init_enums(py::module &m) {
|
||||
.value("MOENCH", slsDetectorDefs::detectorType::MOENCH)
|
||||
.value("MYTHEN3", slsDetectorDefs::detectorType::MYTHEN3)
|
||||
.value("GOTTHARD2", slsDetectorDefs::detectorType::GOTTHARD2)
|
||||
.value("XILINX_CHIPTESTBOARD",
|
||||
slsDetectorDefs::detectorType::XILINX_CHIPTESTBOARD)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::runStatus>(Defs, "runStatus")
|
||||
|
240
slsDetectorCalibration/dataStructures/moench03v2Data.h
Normal file
240
slsDetectorCalibration/dataStructures/moench03v2Data.h
Normal file
@ -0,0 +1,240 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef MOENCH03v2DATA_H
|
||||
#define MOENCH03v2DATA_H
|
||||
//#define MYROOT
|
||||
|
||||
#ifndef MYROOT
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef MYROOT
|
||||
|
||||
typedef struct {
|
||||
uint64_t frameNumber;
|
||||
uint32_t expLength;
|
||||
uint32_t packetNumber;
|
||||
uint64_t bunchId;
|
||||
uint64_t timestamp;
|
||||
uint16_t modId;
|
||||
uint16_t row;
|
||||
uint16_t column;
|
||||
uint16_t reserved;
|
||||
uint32_t debug;
|
||||
uint16_t roundRNumber;
|
||||
uint8_t detType;
|
||||
uint8_t version;
|
||||
} sls_detector_header;
|
||||
#define MAX_NUM_PACKETS 512
|
||||
// using sls_bitset = std::bitset<MAX_NUM_PACKETS>;
|
||||
// using bitset_storage = uint8_t[MAX_NUM_PACKETS / 8];
|
||||
struct sls_receiver_header {
|
||||
sls_detector_header detHeader; /**< is the detector header */
|
||||
uint8_t packetsMask[64]; /**< is the packets caught bit mask */
|
||||
};
|
||||
#endif
|
||||
|
||||
#include "slsDetectorData.h"
|
||||
#ifdef RAWDATA
|
||||
#define DATA_OFFSET sizeof(header)
|
||||
#endif
|
||||
#ifndef RAWDATA
|
||||
#define DATA_OFFSET 0
|
||||
#endif
|
||||
|
||||
|
||||
class moench03v2Data : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
int iframe;
|
||||
const int nRows;
|
||||
|
||||
|
||||
|
||||
double ghost[200][25];
|
||||
|
||||
// Single point of definition if we need to customize
|
||||
#ifndef MYROOT
|
||||
using header = sls::defs::sls_receiver_header;
|
||||
#endif
|
||||
#ifdef MYROOT
|
||||
sls_receiver_header header;
|
||||
#endif
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
moench03v2Data(int nrows = 200)
|
||||
: slsDetectorData<uint16_t>(400, nrows*2,2* 400*nrows*2 + DATA_OFFSET),
|
||||
nRows(nrows) {
|
||||
|
||||
std::cout << "MOENCH width new firmware " << dataSize << std::endl;
|
||||
|
||||
int off=DATA_OFFSET;
|
||||
for (int ix = 0; ix < 400; ix++) {
|
||||
for (int iy = 0; iy < nRows*2; iy++) {
|
||||
dataMap[iy][ix]=off+2*(iy*400+ix);
|
||||
}
|
||||
}
|
||||
|
||||
iframe = 0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the value of the selected channel for the given dataset as
|
||||
double. \param data pointer to the dataset (including headers etc) \param
|
||||
ix pixel number in the x direction \param iy pixel number in the y
|
||||
direction \returns data for the selected channel, with inversion if
|
||||
required as double
|
||||
|
||||
*/
|
||||
double getValue(char *data, int ix, int iy = 0) override {
|
||||
uint16_t val = getChannel(data, ix, iy) & 0x3fff;
|
||||
return val;
|
||||
};
|
||||
|
||||
virtual void calcGhost(char *data, int ix, int iy) {
|
||||
double val = 0;
|
||||
/* for (int ix=0; ix<25; ix++){ */
|
||||
/* for (int iy=0; iy<200; iy++) { */
|
||||
val = 0;
|
||||
// cout << "** ";
|
||||
for (int isc = 0; isc < 16; isc++) {
|
||||
// for (int ii=0; ii<2; ii++) {
|
||||
val += getChannel(data, ix + 25 * isc, iy);
|
||||
// cout << "(" << isc << "," << val << " " ;
|
||||
val += getChannel(data, ix + 25 * isc, 399 - iy);
|
||||
// cout << val << " " ;
|
||||
// }
|
||||
}
|
||||
ghost[iy][ix] = val; //-6224;
|
||||
// cout << " --"<< endl;
|
||||
/* } */
|
||||
/* } */
|
||||
// cout << "*" << endl;
|
||||
}
|
||||
|
||||
virtual void calcGhost(char *data) {
|
||||
for (int ix = 0; ix < 25; ix++) {
|
||||
for (int iy = 0; iy < 200; iy++) {
|
||||
calcGhost(data, ix, iy);
|
||||
}
|
||||
}
|
||||
// cout << "*" << endl;
|
||||
}
|
||||
|
||||
double getGhost(int ix, int iy) {
|
||||
if (iy < 200)
|
||||
return ghost[iy][ix % 25];
|
||||
if (iy < 400)
|
||||
return ghost[399 - iy][ix % 25];
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
#ifdef RAWDATA
|
||||
return ((sls::defs::sls_receiver_header *)buff)->detHeader.frameNumber;
|
||||
#endif
|
||||
#ifndef RAWDATA
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff) {
|
||||
#ifdef RAWDATA
|
||||
return ((sls::defs::sls_receiver_header *)buff)->detHeader.packetNumber;
|
||||
#endif
|
||||
#ifndef RAWDATA
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
char *readNextFrame(std::ifstream &filebin) override {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
}
|
||||
|
||||
// not present in base class
|
||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
// not present in base class
|
||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np) {
|
||||
char *data = new char[dataSize];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
// not present in base class
|
||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np,
|
||||
char *data) {
|
||||
np = 0;
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize)) {
|
||||
ff = getFrameNumber(data);
|
||||
np = getPacketNumber(data);
|
||||
// std::cout << "**" << ff << " " << dataSize << " " << ff << " " << np << std::endl;
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
std::cout << "**" << ff << " " << dataSize << " " << ff << " " << np << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all
|
||||
packets 0 to nPackets, same frame number). purely virtual func \param
|
||||
data pointer to the memory to be analyzed \param ndata reference to the
|
||||
amount of data found for the frame, in case the frame is incomplete at
|
||||
the end of the memory slot \param dsize size of the memory slot to be
|
||||
analyzed \returns pointer to the beginning of the last good frame (might
|
||||
be incomplete if ndata smaller than dataSize), or NULL if no frame is
|
||||
found
|
||||
|
||||
*/
|
||||
char *findNextFrame(char *data, int &ndata, int dsize) override {
|
||||
if (dsize < dataSize)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = dataSize;
|
||||
return data;
|
||||
}
|
||||
|
||||
// int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
};
|
||||
|
||||
#endif
|
240
slsDetectorCalibration/dataStructures/moench03v2HalfData.h
Normal file
240
slsDetectorCalibration/dataStructures/moench03v2HalfData.h
Normal file
@ -0,0 +1,240 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef MOENCH03v2DATA_H
|
||||
#define MOENCH03v2DATA_H
|
||||
//#define MYROOT
|
||||
|
||||
#ifndef MYROOT
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef MYROOT
|
||||
|
||||
typedef struct {
|
||||
uint64_t frameNumber;
|
||||
uint32_t expLength;
|
||||
uint32_t packetNumber;
|
||||
uint64_t bunchId;
|
||||
uint64_t timestamp;
|
||||
uint16_t modId;
|
||||
uint16_t row;
|
||||
uint16_t column;
|
||||
uint16_t reserved;
|
||||
uint32_t debug;
|
||||
uint16_t roundRNumber;
|
||||
uint8_t detType;
|
||||
uint8_t version;
|
||||
} sls_detector_header;
|
||||
#define MAX_NUM_PACKETS 512
|
||||
// using sls_bitset = std::bitset<MAX_NUM_PACKETS>;
|
||||
// using bitset_storage = uint8_t[MAX_NUM_PACKETS / 8];
|
||||
struct sls_receiver_header {
|
||||
sls_detector_header detHeader; /**< is the detector header */
|
||||
uint8_t packetsMask[64]; /**< is the packets caught bit mask */
|
||||
};
|
||||
#endif
|
||||
|
||||
#include "slsDetectorData.h"
|
||||
#ifdef RAWDATA
|
||||
#define DATA_OFFSET sizeof(header)
|
||||
#endif
|
||||
#ifndef RAWDATA
|
||||
#define DATA_OFFSET 0
|
||||
#endif
|
||||
|
||||
|
||||
class moench03v2Data : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
int iframe;
|
||||
const int nRows;
|
||||
|
||||
|
||||
|
||||
double ghost[200][25];
|
||||
|
||||
// Single point of definition if we need to customize
|
||||
#ifndef MYROOT
|
||||
using header = sls::defs::sls_receiver_header;
|
||||
#endif
|
||||
#ifdef MYROOT
|
||||
sls_receiver_header header;
|
||||
#endif
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
moench03v2Data(int nrows = 200)
|
||||
: slsDetectorData<uint16_t>(400, nrows*2,2* 400*nrows*2 + DATA_OFFSET),
|
||||
nRows(nrows) {
|
||||
|
||||
std::cout << "MOENCH width new firmware " << dataSize << std::endl;
|
||||
|
||||
int off=DATA_OFFSET;
|
||||
for (int ix = 0; ix < 400; ix++) {
|
||||
for (int iy = 0; iy < nRows*2; iy++) {
|
||||
dataMap[iy][ix]=off+2*(iy*400+ix);
|
||||
}
|
||||
}
|
||||
|
||||
iframe = 0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the value of the selected channel for the given dataset as
|
||||
double. \param data pointer to the dataset (including headers etc) \param
|
||||
ix pixel number in the x direction \param iy pixel number in the y
|
||||
direction \returns data for the selected channel, with inversion if
|
||||
required as double
|
||||
|
||||
*/
|
||||
double getValue(char *data, int ix, int iy = 0) override {
|
||||
uint16_t val = getChannel(data, ix, iy) & 0x3fff;
|
||||
return val;
|
||||
};
|
||||
|
||||
virtual void calcGhost(char *data, int ix, int iy) {
|
||||
double val = 0;
|
||||
/* for (int ix=0; ix<25; ix++){ */
|
||||
/* for (int iy=0; iy<200; iy++) { */
|
||||
val = 0;
|
||||
// cout << "** ";
|
||||
for (int isc = 0; isc < 16; isc++) {
|
||||
// for (int ii=0; ii<2; ii++) {
|
||||
val += getChannel(data, ix + 25 * isc, iy);
|
||||
// cout << "(" << isc << "," << val << " " ;
|
||||
val += getChannel(data, ix + 25 * isc, 399 - iy);
|
||||
// cout << val << " " ;
|
||||
// }
|
||||
}
|
||||
ghost[iy][ix] = val; //-6224;
|
||||
// cout << " --"<< endl;
|
||||
/* } */
|
||||
/* } */
|
||||
// cout << "*" << endl;
|
||||
}
|
||||
|
||||
virtual void calcGhost(char *data) {
|
||||
for (int ix = 0; ix < 25; ix++) {
|
||||
for (int iy = 0; iy < 200; iy++) {
|
||||
calcGhost(data, ix, iy);
|
||||
}
|
||||
}
|
||||
// cout << "*" << endl;
|
||||
}
|
||||
|
||||
double getGhost(int ix, int iy) {
|
||||
if (iy < 200)
|
||||
return ghost[iy][ix % 25];
|
||||
if (iy < 400)
|
||||
return ghost[399 - iy][ix % 25];
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
#ifdef RAWDATA
|
||||
return ((sls::defs::sls_receiver_header *)buff)->detHeader.frameNumber;
|
||||
#endif
|
||||
#ifndef RAWDATA
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff) {
|
||||
#ifdef RAWDATA
|
||||
return ((sls::defs::sls_receiver_header *)buff)->detHeader.packetNumber;
|
||||
#endif
|
||||
#ifndef RAWDATA
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
char *readNextFrame(std::ifstream &filebin) override {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
}
|
||||
|
||||
// not present in base class
|
||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
// not present in base class
|
||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np) {
|
||||
char *data = new char[dataSize];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
// not present in base class
|
||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np,
|
||||
char *data) {
|
||||
np = 0;
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize)) {
|
||||
ff = getFrameNumber(data);
|
||||
np = getPacketNumber(data);
|
||||
std::cout << "**" << ff << " " << dataSize << " " << ff << " " << np << std::endl;
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
std::cout << "**" << ff << " " << dataSize << " " << ff << " " << np << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all
|
||||
packets 0 to nPackets, same frame number). purely virtual func \param
|
||||
data pointer to the memory to be analyzed \param ndata reference to the
|
||||
amount of data found for the frame, in case the frame is incomplete at
|
||||
the end of the memory slot \param dsize size of the memory slot to be
|
||||
analyzed \returns pointer to the beginning of the last good frame (might
|
||||
be incomplete if ndata smaller than dataSize), or NULL if no frame is
|
||||
found
|
||||
|
||||
*/
|
||||
char *findNextFrame(char *data, int &ndata, int dsize) override {
|
||||
if (dsize < dataSize)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = dataSize;
|
||||
return data;
|
||||
}
|
||||
|
||||
// int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
};
|
||||
|
||||
#endif
|
@ -33,7 +33,7 @@ int main(int argc, char *argv[]) {
|
||||
#ifndef FF
|
||||
if (argc < 9) {
|
||||
cout << "Wrong usage! Should be: " << argv[0]
|
||||
<< " infile etafile outfile runmin runmax ns cmin cmax" << endl;
|
||||
<< " infile etafile outfile runmin runmax ns [cmin cmax xmin xmax ymin ymax]" << endl;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
@ -41,7 +41,7 @@ int main(int argc, char *argv[]) {
|
||||
#ifdef FF
|
||||
if (argc < 7) {
|
||||
cout << "Wrong usage! Should be: " << argv[0]
|
||||
<< " infile etafile runmin runmax cmin cmax" << endl;
|
||||
<< " infile etafile runmin runmax [cmin cmax xmin xmax ymin ymax]" << endl;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
@ -65,13 +65,30 @@ int main(int argc, char *argv[]) {
|
||||
nsubpix = atoi(argv[iarg++]);
|
||||
cout << "Subpix: " << nsubpix << endl;
|
||||
#endif
|
||||
float cmin = atof(argv[iarg++]);
|
||||
float cmax = atof(argv[iarg++]);
|
||||
|
||||
float cmin = 0;
|
||||
float cmax=1000000;
|
||||
if (argc>iarg)
|
||||
cmin=atof(argv[iarg++]);
|
||||
if (argc>iarg)
|
||||
cmax= atof(argv[iarg++]);
|
||||
cout << "Energy min: " << cmin << endl;
|
||||
cout << "Energy max: " << cmax << endl;
|
||||
int xmin=0, xmax=NC, ymin=0, ymax=NR;
|
||||
|
||||
if (argc>iarg)
|
||||
xmin=atof(argv[iarg++]);
|
||||
if (argc>iarg)
|
||||
xmax= atof(argv[iarg++]);
|
||||
|
||||
if (argc>iarg)
|
||||
ymin=atof(argv[iarg++]);
|
||||
if (argc>iarg)
|
||||
ymax= atof(argv[iarg++]);
|
||||
|
||||
// int etabins=500;
|
||||
int etabins = 1000; // nsubpix*2*100;
|
||||
double etamin = -1, etamax = 2;
|
||||
double etamin = -0.25, etamax = 1.25;
|
||||
// double etamin=-0.1, etamax=1.1;
|
||||
// double eta3min = -2, eta3max = 2;
|
||||
double sum, totquad;
|
||||
@ -80,7 +97,7 @@ int main(int argc, char *argv[]) {
|
||||
// double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y;
|
||||
|
||||
int ix, iy, isx, isy;
|
||||
int nframes = 0, lastframe = -1;
|
||||
int nframes = 0, lastframe = -1, iframe, nphFrame;
|
||||
//double d_x, d_y, res = 5, xx, yy;
|
||||
int nph = 0, totph = 0;
|
||||
//badph = 0,
|
||||
@ -98,7 +115,7 @@ int main(int argc, char *argv[]) {
|
||||
// int nSubPixels = nsubpix;
|
||||
#ifndef NOINTERPOLATION
|
||||
eta2InterpolationPosXY *interp =
|
||||
new eta2InterpolationPosXY(NC, NR, nsubpix, nsubpix,etabins,etabins, etamin, etamax);
|
||||
new eta2InterpolationPosXY(NC, NR, nsubpix, nsubpix, etabins, etabins, etamin, etamax);
|
||||
// eta2InterpolationCleverAdaptiveBins *interp=new
|
||||
// eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin,
|
||||
// etamax);
|
||||
@ -107,8 +124,8 @@ int main(int argc, char *argv[]) {
|
||||
noInterpolation *interp = new noInterpolation(NC, NR, nsubpix);
|
||||
#endif
|
||||
|
||||
#ifndef FF
|
||||
int quad;
|
||||
#ifndef FF
|
||||
#ifndef NOINTERPOLATION
|
||||
char fname[10000];
|
||||
int ok;
|
||||
@ -142,19 +159,26 @@ int main(int argc, char *argv[]) {
|
||||
#endif
|
||||
|
||||
int irun;
|
||||
for (irun = runmin; irun < runmax; irun++) {
|
||||
for (irun = runmin; irun <= runmax; irun++) {
|
||||
sprintf(infname, argv[1], irun);
|
||||
#ifndef FF
|
||||
sprintf(outfname, argv[3], irun);
|
||||
#endif
|
||||
|
||||
|
||||
f = fopen(infname, "r");
|
||||
if (f) {
|
||||
cout << infname << endl;
|
||||
nframes = 0;
|
||||
//f0 = -1;
|
||||
|
||||
while (cl.read(f)) {
|
||||
//iff=0;
|
||||
while (fread((void*)&iframe, 1, sizeof(int), f)) {
|
||||
//n=0;
|
||||
if (fread((void*)&nphFrame, 1, sizeof(int), f)) {
|
||||
for (int iph=0; iph<nphFrame; iph++) {
|
||||
//while (cl.read(f)) {
|
||||
if (cl.read(f)) {
|
||||
totph++;
|
||||
if (lastframe != cl.iframe) {
|
||||
lastframe = cl.iframe;
|
||||
@ -165,18 +189,28 @@ int main(int argc, char *argv[]) {
|
||||
nframes++;
|
||||
}
|
||||
// quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
||||
#ifndef FF
|
||||
// #ifndef FF
|
||||
// quad = interp->calcEta(cl.get_cluster(), etax, etay, sum,
|
||||
// totquad, sDum);
|
||||
// #endif
|
||||
// #ifdef FF
|
||||
|
||||
quad = interp->calcEta(cl.get_cluster(), etax, etay, sum,
|
||||
totquad, sDum);
|
||||
#endif
|
||||
#ifdef FF
|
||||
interp->calcEta(cl.get_cluster(), etax, etay, sum,
|
||||
totquad, sDum);
|
||||
#endif
|
||||
|
||||
|
||||
/* cl.print();
|
||||
cout << "(" << etax <<","<< etay <<")"<< quad<< endl;
|
||||
*/
|
||||
//#endif
|
||||
|
||||
if (sum > cmin && totquad / sum > 0.8 && totquad / sum < 1.2 &&
|
||||
sum < cmax) {
|
||||
nph++;
|
||||
if (totquad > cmin && cl.x >= xmin && cl.x <= xmax &&
|
||||
cl.y >= ymin && cl.y <= ymax &&
|
||||
totquad < cmax) {
|
||||
|
||||
// if (sum > cmin && totquad / sum > 0.8 && totquad / sum < 1.2 &&
|
||||
// sum < cmax) {
|
||||
nph++;
|
||||
// if (sum>200 && sum<580) {
|
||||
// interp->getInterpolatedPosition(cl.x,cl.y,
|
||||
// totquad,quad,cl.get_cluster(),int_x, int_y);
|
||||
@ -227,9 +261,12 @@ int main(int argc, char *argv[]) {
|
||||
#ifdef FF
|
||||
interp->writeFlatField(outfname);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
#ifdef FF
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#ifndef MOENCH04
|
||||
#ifndef RECT
|
||||
#include "moench03T1ReceiverDataNew.h"
|
||||
#include "moench03v2Data.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -41,34 +41,148 @@ using namespace std;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
if (argc < 4) {
|
||||
std::map<std::string, std::string> args = {
|
||||
{"numfiles","1"},
|
||||
{"nthreads","5"},
|
||||
{"fifosize","5000"},
|
||||
{"nsigma","5"},
|
||||
{"gainfile","none"},
|
||||
{"detectorMode","counting"},
|
||||
{"threshold","0"},
|
||||
{"pedestalfile","none"},
|
||||
{"nframes","0"},
|
||||
{"xMin","0"},
|
||||
{"xMax","400"},
|
||||
{"yMin","0"},
|
||||
{"yMax","400"},
|
||||
{"eMin","0"},
|
||||
{"eMax","16000"},
|
||||
{"outdir","./"},
|
||||
{"indir","./"},
|
||||
{"flist","none"},
|
||||
{"fformat","none"},
|
||||
{"runmin","0"},
|
||||
{"runmax","-1"},
|
||||
{"readnrows","400"}
|
||||
};
|
||||
//float *gm;
|
||||
|
||||
int ff, np;
|
||||
// cout << " data size is " << dsize;
|
||||
|
||||
ifstream filebin;
|
||||
if (argc < 4) {
|
||||
std::string name, value,sline;
|
||||
int ic=0;
|
||||
ifstream flist;
|
||||
flist.open (argv[1], std::ifstream::in);
|
||||
if (flist.is_open()) {
|
||||
cout << "Using config file " <<argv[1] << endl;
|
||||
while (std::getline(flist,sline)){
|
||||
if (sline.at(0)!='#') {
|
||||
ic=sline.find(' ');
|
||||
name = sline.substr(0,ic);
|
||||
value = sline.substr(ic+1,sline.size()-ic);
|
||||
args[name]=value;
|
||||
}
|
||||
|
||||
}
|
||||
flist.close();
|
||||
} else {
|
||||
cout << "Usage is " << argv[0]
|
||||
<< "indir outdir fname(no extension) [runmin] [runmax] [pedfile (raw or tiff)] [threshold] "
|
||||
"[nframes] [xmin xmax ymin ymax] [gainmap]"
|
||||
"[nframes] [xmin xmax ymin ymax] [gainmap]"
|
||||
<< endl;
|
||||
cout << "threshold <0 means analog; threshold=0 means cluster finder; "
|
||||
"threshold>0 means photon counting"
|
||||
"threshold>0 means photon counting"
|
||||
<< endl;
|
||||
cout << "nframes <0 means sum everything; nframes=0 means one file per "
|
||||
"run; nframes>0 means one file every nframes"
|
||||
"run; nframes>0 means one file every nframes"
|
||||
<< endl;
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
args["indir"]=argv[1];
|
||||
args["outdir"]=argv[1];
|
||||
args["fformat"]=argv[3];
|
||||
if (argc >= 5) {
|
||||
args["runmin"] = argv[4];
|
||||
}
|
||||
args["runmax"] = args["runmin"];
|
||||
|
||||
if (argc >= 6) {
|
||||
args["runmax"] = argv[5];
|
||||
}
|
||||
if (argc >= 7) {
|
||||
args["pedestalfile"] = argv[6];
|
||||
}
|
||||
if (argc >= 8) {
|
||||
args["threshold"] = argv[7];
|
||||
}
|
||||
if (argc >= 9) {
|
||||
args["nframes"] = argv[8];
|
||||
}
|
||||
if (argc >= 13) {
|
||||
args["xMin"] = argv[9];
|
||||
args["xMax"] = argv[10];
|
||||
args["yMin"] = argv[11];
|
||||
args["yMax"] = argv[12];
|
||||
}
|
||||
if (argc > 13) {
|
||||
args["gainfile"] = argv[13];
|
||||
}
|
||||
|
||||
if (atof(args["threshold"].c_str())<0) {
|
||||
args["detectorMode"]="analog";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int fifosize = 1000;
|
||||
int nthreads = 10;
|
||||
int csize = 3;
|
||||
int nsigma = 5;
|
||||
int nped = 10000;
|
||||
|
||||
|
||||
for (auto const& x : args)
|
||||
{
|
||||
std::cout << x.first // string (key)
|
||||
<< ':'
|
||||
<< x.second // string's value
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
string indir=args["indir"];
|
||||
string outdir = args["outdir"];
|
||||
string fformat= args["fformat"];
|
||||
int runmin = atoi(args["runmin"].c_str());
|
||||
int runmax = atoi(args["runmin"].c_str());
|
||||
string pedfile =args["pedestalfile"];
|
||||
double thr = atof(args["threshold"].c_str());
|
||||
double thr1 = 1;
|
||||
|
||||
int nframes = atoi(args["nframes"].c_str());
|
||||
|
||||
int xmin = atoi(args["xMin"].c_str()), xmax = atoi(args["xMax"].c_str()), ymin = atoi(args["yMin"].c_str()), ymax = atoi(args["yMax"].c_str());
|
||||
|
||||
string gainfname=args["gainfile"];
|
||||
|
||||
int fifosize = atoi(args["fifosize"].c_str());
|
||||
int nthreads = atoi(args["nthreads"].c_str());
|
||||
int nsigma = atoi(args["nsigma"].c_str());
|
||||
int nrows = atoi(args["readnrows"].c_str());
|
||||
float eMin = atof(args["eMin"].c_str());
|
||||
float eMax = atof(args["eMax"].c_str());
|
||||
int csize = 3;
|
||||
int nped = 1000;
|
||||
|
||||
int cf = 0;
|
||||
int numberOfPackets=40;
|
||||
|
||||
int numberOfPackets=nrows/8;
|
||||
|
||||
#ifdef RECT
|
||||
cout << "Should be rectangular but now it will crash! No data structure defined!" << endl;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MOENCH04
|
||||
moench03T1ReceiverDataNew *decoder = new moench03T1ReceiverDataNew();
|
||||
moench03v2Data *decoder = new moench03v2Data(100);
|
||||
cout << "MOENCH03!" << endl;
|
||||
#endif
|
||||
|
||||
@ -77,7 +191,7 @@ int main(int argc, char *argv[]) {
|
||||
moench04CtbZmq10GbData *decoder = new moench04CtbZmq10GbData(5000,0);
|
||||
cout << "MOENCH04!" << endl;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MOENCH04_DGS
|
||||
moench04CtbZmq10GbData *decoder = new moench04CtbZmq10GbData(5000,5000);
|
||||
cout << "MOENCH04 DGS!" << endl;
|
||||
@ -86,63 +200,11 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
#endif
|
||||
|
||||
//Read detector size from decoder
|
||||
int nx , ny;
|
||||
decoder->getDetectorSize(nx, ny);
|
||||
|
||||
//float *gm;
|
||||
|
||||
int ff, np;
|
||||
// cout << " data size is " << dsize;
|
||||
|
||||
ifstream filebin;
|
||||
char *indir = argv[1];
|
||||
char *outdir = argv[2];
|
||||
char *fformat = argv[3];
|
||||
int runmin = 0;
|
||||
|
||||
// cout << "argc is " << argc << endl;
|
||||
if (argc >= 5) {
|
||||
runmin = atoi(argv[4]);
|
||||
}
|
||||
|
||||
int runmax = runmin;
|
||||
|
||||
if (argc >= 6) {
|
||||
runmax = atoi(argv[5]);
|
||||
}
|
||||
|
||||
char *pedfile = NULL;
|
||||
if (argc >= 7) {
|
||||
pedfile = argv[6];
|
||||
}
|
||||
double thr = 0;
|
||||
double thr1 = 1;
|
||||
|
||||
if (argc >= 8) {
|
||||
thr = atof(argv[7]);
|
||||
}
|
||||
|
||||
int nframes = 0;
|
||||
|
||||
if (argc >= 9) {
|
||||
nframes = atoi(argv[8]);
|
||||
}
|
||||
|
||||
int xmin = 0, xmax = nx, ymin = 0, ymax = ny;
|
||||
if (argc >= 13) {
|
||||
xmin = atoi(argv[9]);
|
||||
xmax = atoi(argv[10]);
|
||||
ymin = atoi(argv[11]);
|
||||
ymax = atoi(argv[12]);
|
||||
}
|
||||
|
||||
char *gainfname = NULL;
|
||||
if (argc > 13) {
|
||||
gainfname = argv[13];
|
||||
cout << "Gain map file name is: " << gainfname << endl;
|
||||
}
|
||||
|
||||
//Read detector size from decoder
|
||||
|
||||
char ffname[10000];
|
||||
char fname[10000];
|
||||
char imgfname[10000];
|
||||
@ -151,17 +213,6 @@ int main(int argc, char *argv[]) {
|
||||
std::time_t end_time;
|
||||
|
||||
FILE *of = NULL;
|
||||
cout << "input directory is " << indir << endl;
|
||||
cout << "output directory is " << outdir << endl;
|
||||
cout << "input file is " << fformat << endl;
|
||||
cout << "runmin is " << runmin << endl;
|
||||
cout << "runmax is " << runmax << endl;
|
||||
if (pedfile)
|
||||
cout << "pedestal file is " << pedfile << endl;
|
||||
if (thr > 0)
|
||||
cout << "threshold is " << thr << endl;
|
||||
cout << "Nframes is " << nframes << endl;
|
||||
|
||||
uint32_t nnx, nny;
|
||||
|
||||
|
||||
@ -182,50 +233,62 @@ int main(int argc, char *argv[]) {
|
||||
singlePhotonDetector *filter = new singlePhotonDetector(
|
||||
decoder, csize, nsigma, 1, cm, nped, 200, -1, -1, gainmap, gs);
|
||||
|
||||
if (gainfname) {
|
||||
//if (gainfname) {
|
||||
|
||||
if (filter->readGainMap(gainfname))
|
||||
if (filter->readGainMap(gainfname.c_str()))
|
||||
cout << "using gain map " << gainfname << endl;
|
||||
else
|
||||
cout << "Could not open gain map " << gainfname << endl;
|
||||
} else
|
||||
thr = 0.15 * thr;
|
||||
// } else
|
||||
thr = 0.15 * thr;
|
||||
filter->newDataSet();
|
||||
//int dsize = decoder->getDataSize();
|
||||
|
||||
if (thr > 0) {
|
||||
cout << "threshold is " << thr << endl;
|
||||
filter->setThreshold(thr);
|
||||
cf = 0;
|
||||
|
||||
cout << "threshold is " << thr << endl;
|
||||
filter->setThreshold(thr);
|
||||
cf = 0;
|
||||
} else
|
||||
cf = 1;
|
||||
|
||||
cf = 1;
|
||||
|
||||
filter->setROI(xmin, xmax, ymin, ymax);
|
||||
filter->setEnergyRange(eMin, eMax);
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
char *buff;
|
||||
|
||||
|
||||
// multiThreadedAnalogDetector *mt=new
|
||||
// multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
multiThreadedCountingDetector *mt =
|
||||
new multiThreadedCountingDetector(filter, nthreads, fifosize);
|
||||
#ifndef ANALOG
|
||||
mt->setDetectorMode(ePhotonCounting);
|
||||
cout << "Counting!" << endl;
|
||||
if (thr > 0) {
|
||||
|
||||
if (args["detectorMode"]=="counting") {
|
||||
mt->setDetectorMode(ePhotonCounting);
|
||||
if (thr > 0) {
|
||||
cf = 0;
|
||||
}
|
||||
} else {
|
||||
mt->setDetectorMode(eAnalog);
|
||||
cf = 0;
|
||||
}
|
||||
#endif
|
||||
//{
|
||||
#ifdef ANALOG
|
||||
mt->setDetectorMode(eAnalog);
|
||||
cout << "Analog!" << endl;
|
||||
cf = 0;
|
||||
// thr1=thr;
|
||||
#endif
|
||||
// }
|
||||
|
||||
|
||||
// #ifndef ANALOG
|
||||
// mt->setDetectorMode(ePhotonCounting);
|
||||
// cout << "Counting!" << endl;
|
||||
// if (thr > 0) {
|
||||
// cf = 0;
|
||||
// }
|
||||
// #endif
|
||||
// //{
|
||||
// #ifdef ANALOG
|
||||
// mt->setDetectorMode(eAnalog);
|
||||
// cout << "Analog!" << endl;
|
||||
// cf = 0;
|
||||
// // thr1=thr;
|
||||
// #endif
|
||||
// // }
|
||||
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
@ -236,84 +299,122 @@ int main(int argc, char *argv[]) {
|
||||
char froot[1000];
|
||||
double *ped=new double[nx * ny];//, *ped1;
|
||||
int pos,pos1;
|
||||
|
||||
if (pedfile) {
|
||||
if (string(pedfile).find(".raw") != std::string::npos) {
|
||||
pos1=string(pedfile).rfind("/");
|
||||
strcpy(froot,pedfile+pos1);
|
||||
pos=string(froot).find(".raw");
|
||||
froot[pos]='\0';
|
||||
}
|
||||
//return 0;
|
||||
|
||||
if (pedfile.find(".raw") != std::string::npos) {
|
||||
pos1=pedfile.rfind("/");
|
||||
strcpy(froot,pedfile.substr(pos1).c_str());
|
||||
pos=string(froot).find(".raw");
|
||||
froot[pos]='\0';
|
||||
}
|
||||
|
||||
cout << "PEDESTAL " << endl;
|
||||
if (pedfile.find(".tif") == std::string::npos) {
|
||||
sprintf(fname, "%s", pedfile.c_str());
|
||||
|
||||
cout << "PEDESTAL " << endl;
|
||||
if (string(pedfile).find(".tif") == std::string::npos) {
|
||||
sprintf(fname, "%s", pedfile);
|
||||
cout << fname << endl;
|
||||
std::time(&end_time);
|
||||
//cout << "aaa" << std::ctime(&end_time) << endl;
|
||||
|
||||
|
||||
mt->setFrameMode(ePedestal);
|
||||
// sprintf(fn,fformat,irun);
|
||||
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||
// //open file
|
||||
if (filebin.is_open()) {
|
||||
ff = -1;
|
||||
ff = -1;
|
||||
while (decoder->readNextFrame(filebin, ff, np, buff)) {
|
||||
if (np == numberOfPackets) {
|
||||
mt->pushData(buff);
|
||||
|
||||
if (np == numberOfPackets) {
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
ifr++;
|
||||
if (ifr % 100 == 0)
|
||||
cout << ifr << " " << ff << " " << np << endl;
|
||||
} else
|
||||
cout << ifr << " " << ff << " " << np << endl;
|
||||
if (ifr % 100 == 0)
|
||||
|
||||
cout << ifr << " " << ff << " " << np << endl;
|
||||
// break;
|
||||
} else {
|
||||
cout << ifr << " " << ff << " " << np << endl;
|
||||
break;
|
||||
}
|
||||
ff = -1;
|
||||
}
|
||||
filebin.close();
|
||||
while (mt->isBusy()) {
|
||||
;
|
||||
}
|
||||
|
||||
sprintf(imgfname, "%s/%s_ped.tiff", outdir,froot);
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
sprintf(imgfname, "%s/%s_ped.tiff", outdir.c_str(),froot);
|
||||
mt->writePedestal(imgfname);
|
||||
sprintf(imgfname, "%s/%s_var.tiff", outdir,froot);
|
||||
sprintf(imgfname, "%s/%s_var.tiff", outdir.c_str(),froot);
|
||||
mt->writePedestalRMS(imgfname);
|
||||
} else
|
||||
cout << "Could not open pedestal file " << fname
|
||||
<< " for reading " << endl;
|
||||
} else {
|
||||
float *pp = ReadFromTiff(pedfile, nny, nnx);
|
||||
if (pp && (int)nnx == nx && (int)nny == ny) {
|
||||
for (int i = 0; i < nx * ny; i++) {
|
||||
cout << "Could not open pedestal file " << fname
|
||||
<< " for reading " << endl;
|
||||
} else {
|
||||
float *pp = ReadFromTiff(pedfile.c_str(), nny, nnx);
|
||||
if (pp && (int)nnx == nx && (int)nny == ny) {
|
||||
for (int i = 0; i < nx * ny; i++) {
|
||||
ped[i] = pp[i];
|
||||
}
|
||||
delete[] pp;
|
||||
mt->setPedestal(ped);
|
||||
cout << "Pedestal set from tiff file " << pedfile << endl;
|
||||
} else {
|
||||
cout << "Could not open pedestal tiff file " << pedfile
|
||||
}
|
||||
delete[] pp;
|
||||
mt->setPedestal(ped);
|
||||
cout << "Pedestal set from tiff file " << pedfile << endl;
|
||||
} else {
|
||||
cout << "Could not open pedestal tiff file " << pedfile
|
||||
<< " for reading " << endl;
|
||||
}
|
||||
}
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
}
|
||||
}
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
|
||||
ifr = 0;
|
||||
int ifile = 0;
|
||||
|
||||
mt->setFrameMode(eFrame);
|
||||
//t filelist=0;
|
||||
ifstream flist;
|
||||
flist.open (args["flist"].c_str(), std::ifstream::in);
|
||||
if (flist.is_open()) {
|
||||
cout << "Using file list" << endl;
|
||||
runmin=0;
|
||||
runmax=0;
|
||||
while (flist.getline(ffname,10000)){
|
||||
cout << ffname << endl;
|
||||
runmax++;
|
||||
}
|
||||
runmax--;
|
||||
flist.close();
|
||||
cout << "Found " << runmax << " files " << endl;
|
||||
flist.open (fformat, std::ifstream::in);
|
||||
}
|
||||
|
||||
for (int irun = runmin; irun <= runmax; irun++) {
|
||||
cout << "DATA ";
|
||||
// sprintf(fn,fformat,irun);
|
||||
sprintf(ffname, "%s/%s.raw", indir, fformat);
|
||||
sprintf(fname, (const char*)ffname, irun);
|
||||
sprintf(ffname, "%s/%s.tiff", outdir, fformat);
|
||||
sprintf(imgfname, (const char*)ffname, irun);
|
||||
sprintf(ffname, "%s/%s.clust", outdir, fformat);
|
||||
sprintf(cfname, (const char*)ffname, irun);
|
||||
// sprintf(ffname, "%s/%s.raw", indir, fformat);
|
||||
// sprintf(fname, (const char*)ffname, irun);
|
||||
// sprintf(ffname, "%s/%s.tiff", outdir, fformat);
|
||||
// sprintf(imgfname, (const char*)ffname, irun);
|
||||
// sprintf(ffname, "%s/%s.clust", outdir, fformat);
|
||||
// sprintf(cfname, (const char*)ffname, irun);
|
||||
if (flist.is_open()) {
|
||||
flist.getline(ffname,10000);
|
||||
cout << "file list " << ffname << endl;
|
||||
} else {
|
||||
//sprintf(ffname,(const char*)fformat,irun);
|
||||
sprintf(ffname,args["fformat"].c_str(),irun);
|
||||
cout << "loop " << ffname << endl;
|
||||
}
|
||||
cout << "ffname "<< ffname << endl;
|
||||
sprintf(fname, "%s/%s.raw",indir.c_str(),ffname);
|
||||
sprintf(imgfname, "%s/%s.tiff",outdir.c_str(),ffname);
|
||||
sprintf(cfname, "%s/%s.clust",outdir.c_str(),ffname);
|
||||
|
||||
|
||||
cout << fname << " ";
|
||||
cout << imgfname << endl;
|
||||
std::time(&end_time);
|
||||
@ -323,7 +424,7 @@ int main(int argc, char *argv[]) {
|
||||
// //open file
|
||||
ifile = 0;
|
||||
if (filebin.is_open()) {
|
||||
if (thr <= 0 && cf != 0) { // cluster finder
|
||||
if (cf != 0) { // cluster finder
|
||||
if (of == NULL) {
|
||||
of = fopen(cfname, "w");
|
||||
if (of) {
|
||||
@ -341,7 +442,8 @@ int main(int argc, char *argv[]) {
|
||||
ff = -1;
|
||||
ifr = 0;
|
||||
while (decoder->readNextFrame(filebin, ff, np, buff)) {
|
||||
if (np == numberOfPackets) {
|
||||
|
||||
if (np == numberOfPackets) {
|
||||
// //push
|
||||
mt->pushData(buff);
|
||||
// // //pop
|
||||
@ -350,21 +452,27 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
ifr++;
|
||||
if (ifr % 100 == 0)
|
||||
cout << ifr << " " << ff << endl;
|
||||
cout << ifr << " " << ff << " " << np << endl;
|
||||
//break;
|
||||
if (nframes > 0) {
|
||||
if (ifr % nframes == 0) {
|
||||
sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat,
|
||||
ifile);
|
||||
sprintf(imgfname, (const char*)ffname, irun);
|
||||
// sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat,
|
||||
// ifile);
|
||||
// sprintf(imgfname, (const char*)ffname, irun);
|
||||
sprintf(imgfname, "%s/%s_f%05d.tiff",outdir.c_str(),ffname,ifile);
|
||||
while (mt->isBusy())
|
||||
;
|
||||
|
||||
mt->writeImage(imgfname, thr1);
|
||||
mt->clearImage();
|
||||
ifile++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cout << "bp " << ifr << " " << ff << " " << np << endl;
|
||||
//break;
|
||||
}
|
||||
} else {
|
||||
cout << "bp " << ifr << " " << ff << " " << np << endl;
|
||||
|
||||
//break;
|
||||
}
|
||||
ff = -1;
|
||||
}
|
||||
cout << "--" << endl;
|
||||
@ -374,13 +482,17 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
if (nframes >= 0) {
|
||||
if (nframes > 0) {
|
||||
sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat, ifile);
|
||||
sprintf(imgfname, (const char*)ffname, irun);
|
||||
sprintf(imgfname, "%s/%s_f%05d.tiff",outdir.c_str(),ffname,ifile);
|
||||
// sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat, ifile);
|
||||
//sprintf(imgfname, (const char*)ffname, irun);
|
||||
} else {
|
||||
sprintf(ffname, "%s/%s.tiff", outdir, fformat);
|
||||
sprintf(imgfname, (const char*)ffname, irun);
|
||||
sprintf(imgfname, "%s/%s.tiff",outdir.c_str(),ffname);
|
||||
// sprintf(ffname, "%s/%s.tiff", outdir, fformat);
|
||||
// sprintf(imgfname, (const char*)ffname, irun);
|
||||
}
|
||||
cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
|
||||
cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
|
||||
while (mt->isBusy())
|
||||
;
|
||||
mt->writeImage(imgfname, thr1);
|
||||
mt->clearImage();
|
||||
if (of) {
|
||||
@ -395,11 +507,16 @@ int main(int argc, char *argv[]) {
|
||||
cout << "Could not open " << fname << " for reading " << endl;
|
||||
}
|
||||
if (nframes < 0) {
|
||||
sprintf(ffname, "%s/%s.tiff", outdir, fformat);
|
||||
strcpy(imgfname, ffname);
|
||||
cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
|
||||
mt->writeImage(imgfname, thr1);
|
||||
//sprintf(ffname, "%s/%s.tiff", outdir, fformat);
|
||||
// strcpy(imgfname, ffname);
|
||||
sprintf(imgfname, "%s/%s_tot.tiff",outdir.c_str(),ffname);
|
||||
cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
|
||||
while (mt->isBusy())
|
||||
;
|
||||
mt->writeImage(imgfname, thr1);
|
||||
}
|
||||
if (flist.is_open()) {
|
||||
flist.close();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -13,7 +13,8 @@
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#ifndef MOENCH04
|
||||
//#ifndef RECT
|
||||
#include "moench03T1ZmqDataNew.h"
|
||||
#include "moench03v2Data.h"
|
||||
//#include "moench03T1ZmqDataNew.h"
|
||||
//#endif
|
||||
//#ifdef RECT
|
||||
//#include "moench03T1ZmqDataNewRect.h"
|
||||
@ -31,6 +32,7 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <rapidjson/document.h> //json header in zmq stream
|
||||
|
||||
@ -63,36 +65,48 @@ int main(int argc, char *argv[]) {
|
||||
* trial.o [socket ip] [starting port number] [send_socket ip] [send port
|
||||
* number]
|
||||
*
|
||||
*/
|
||||
FILE *of = NULL;
|
||||
int fifosize = 5000;
|
||||
*/
|
||||
std::map<std::string, std::string> args = {
|
||||
{"numinterfaces","1"},
|
||||
{"rx_zmqip","10.1.2.102"},
|
||||
{"rx_zmqport","7770"},
|
||||
{"zmqip","129.129.202.153"},
|
||||
{"zmqport","7780"},
|
||||
{"nthreads","5"},
|
||||
{"fifosize","5000"},
|
||||
{"nsigma","5"},
|
||||
{"gainfile","none"},
|
||||
{"nbinsx","5"},
|
||||
{"nbinsy","5"},
|
||||
{"etafile","none"},
|
||||
{"etabinsx","1000"},
|
||||
{"etamin","-1"},
|
||||
{"etamax","2"} };
|
||||
FILE *of = NULL;
|
||||
int etabins = 1000, etabinsy = 1000; // nsubpix*2*100;
|
||||
double etamin = -1, etamax = 2;
|
||||
int nSubPixelsX = 2;
|
||||
int emin, emax;
|
||||
int nSubPixelsY = 2;
|
||||
int nthreads = 5;
|
||||
int fifosize = 5000;
|
||||
uint32_t nSigma = 5;
|
||||
|
||||
// help
|
||||
if (argc < 3) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port "
|
||||
"number] [send_socket ip] [send starting port number] "
|
||||
"[nthreads] [nsubpix] [gainmap] [etafile]\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
string etafname;// = NULL;
|
||||
string gainfname;// = NULL;
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char *socketip = argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
// send parameters if any
|
||||
char *socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
string socketip2;// = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
string socketip;// = 0;
|
||||
uint32_t portnum = 0;
|
||||
|
||||
sls::zmqHeader zHeader, outHeader;
|
||||
zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
|
||||
outHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
|
||||
|
||||
uint32_t nSigma = 5;
|
||||
|
||||
int ok;
|
||||
|
||||
@ -102,48 +116,85 @@ int main(int argc, char *argv[]) {
|
||||
// time_t begin,end,finished;
|
||||
int rms = 0;
|
||||
|
||||
if (argc > 4) {
|
||||
socketip2 = argv[3];
|
||||
portnum2 = atoi(argv[4]);
|
||||
if (portnum2 > 0)
|
||||
send = true;
|
||||
}
|
||||
cout << "\nrx socket ip : " << socketip << "\nrx port num : " << portnum;
|
||||
if (send) {
|
||||
cout << "\ntx socket ip : " << socketip2
|
||||
<< "\ntx port num : " << portnum2;
|
||||
}
|
||||
int nthreads = 5;
|
||||
if (argc > 5)
|
||||
nthreads = atoi(argv[5]);
|
||||
send = true;
|
||||
// help
|
||||
if (argc < 5) {
|
||||
std::string name, value,sline;
|
||||
int ic=0;
|
||||
ifstream flist;
|
||||
flist.open (argv[1], std::ifstream::in);
|
||||
if (flist.is_open()) {
|
||||
cout << "Using config file " <<argv[1] << endl;
|
||||
while (std::getline(flist,sline)){
|
||||
if (sline.at(0)!='#') {
|
||||
ic=sline.find(' ');
|
||||
name = sline.substr(0,ic);
|
||||
value = sline.substr(ic+1,sline.size()-ic);
|
||||
args[name]=value;
|
||||
}
|
||||
|
||||
cout << "Number of threads is: " << nthreads << endl;
|
||||
if (argc > 6) {
|
||||
nSubPixelsX = atoi(argv[6]);
|
||||
nSubPixelsY = nSubPixelsX;
|
||||
#ifdef RECT
|
||||
nSubPixelsX = 2;
|
||||
#endif
|
||||
}
|
||||
cout << "Number of subpixels is: " << nSubPixelsX << " " << nSubPixelsY
|
||||
<< endl;
|
||||
}
|
||||
flist.close();
|
||||
} else {
|
||||
cprintf(RED, "Arguments are either: \n [config file] \n or the following list (deprecated): [receive socket ip] [receive starting port "
|
||||
"number] [send_socket ip] [send starting port number] "
|
||||
"[nthreads] [nsubpix] [gainmap] [etafile]\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
args["rx_zmqip"]=argv[1];
|
||||
args["rx_zmqport"]=argv[2];
|
||||
|
||||
args["zmqip"]=argv[3];
|
||||
args["zmqport"]=argv[4];
|
||||
if (argc > 5)
|
||||
args["nthreads"] = argv[5];
|
||||
if (argc > 6) {
|
||||
args["nbinsx"]=argv[6];
|
||||
args["nbinsy"]=argv[6];
|
||||
}
|
||||
|
||||
if (argc > 7) {
|
||||
args["gainfile"]=argv[7];
|
||||
}
|
||||
if (argc > 8) {
|
||||
args["etafilefile"]=argv[8];
|
||||
}
|
||||
|
||||
char *gainfname = NULL;
|
||||
if (argc > 7) {
|
||||
gainfname = argv[7];
|
||||
cout << "Gain map file name is: " << gainfname << endl;
|
||||
}
|
||||
|
||||
char *etafname = NULL;
|
||||
if (argc > 8) {
|
||||
etafname = argv[8];
|
||||
cout << "Eta file name is: " << etafname << endl;
|
||||
for (auto const& x : args)
|
||||
{
|
||||
std::cout << x.first // string (key)
|
||||
<< ':'
|
||||
<< x.second // string's value
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
socketip = args["rx_zmqip"];
|
||||
portnum = atoi(args["rx_zmqport"].c_str());
|
||||
|
||||
socketip2 = args["zmqip"];
|
||||
portnum2 = atoi(args["zmqport"].c_str());
|
||||
|
||||
nthreads = atoi(args["nthreads"].c_str());
|
||||
nSubPixelsX =atoi(args["nbinsx"].c_str());
|
||||
nSubPixelsY =atoi(args["nbinsy"].c_str());
|
||||
gainfname = args["gainfile"];
|
||||
etafname = args["etafilefile"];
|
||||
|
||||
if (atoi(args["nuninterfaces"].c_str())>1){
|
||||
cprintf(RED, "Sorry, at the moment only a single interface is supported instead of %d\n",atoi(args["nuninterfaces"].c_str()));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
// slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
#ifndef MOENCH04
|
||||
cout << "This is a Moench03" << endl;
|
||||
moench03T1ZmqDataNew *det = new moench03T1ZmqDataNew();
|
||||
cout << "This is a Moench03 v2" << endl;
|
||||
//moench03T1ZmqDataNew *det = new moench03T1ZmqDataNew();
|
||||
moench03v2Data *det = new moench03v2Data();
|
||||
cout << "MOENCH03!" << endl;
|
||||
#endif
|
||||
#ifdef MOENCH04
|
||||
cout << "This is a Moench04" << endl;
|
||||
@ -177,8 +228,8 @@ int main(int argc, char *argv[]) {
|
||||
double *gmap = NULL;
|
||||
|
||||
uint32_t nnnx, nnny;
|
||||
if (gainfname) {
|
||||
gm = ReadFromTiff(gainfname, nnny, nnnx);
|
||||
//if (gainfname) {
|
||||
gm = ReadFromTiff(gainfname.c_str(), nnny, nnnx);
|
||||
if (gm && nnnx == (uint)npx && nnny == (uint)npy) {
|
||||
gmap = new double[npx * npy];
|
||||
for (int i = 0; i < npx * npy; i++) {
|
||||
@ -187,7 +238,7 @@ int main(int argc, char *argv[]) {
|
||||
delete[] gm;
|
||||
} else
|
||||
cout << "Could not open gain map " << gainfname << endl;
|
||||
}
|
||||
//}
|
||||
|
||||
// analogDetector<uint16_t> *filter=new
|
||||
// analogDetector<uint16_t>(det,1,NULL,1000);
|
||||
@ -205,8 +256,8 @@ int main(int argc, char *argv[]) {
|
||||
eta2InterpolationPosXY *interp = new eta2InterpolationPosXY(
|
||||
npx, npy, nSubPixelsX, nSubPixelsY, etabins, etabinsy, etamin, etamax);
|
||||
|
||||
if (etafname)
|
||||
interp->readFlatField(etafname);
|
||||
//if (etafname)
|
||||
interp->readFlatField(etafname.c_str());
|
||||
|
||||
interpolatingDetector *filter = new interpolatingDetector(
|
||||
det, interp, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs);
|
||||
@ -226,13 +277,13 @@ int main(int argc, char *argv[]) {
|
||||
try {
|
||||
#endif
|
||||
|
||||
zmqsocket = new sls::ZmqSocket(socketip, portnum);
|
||||
zmqsocket = new sls::ZmqSocket(socketip.c_str(), portnum);
|
||||
|
||||
#ifdef NEWZMQ
|
||||
} catch (...) {
|
||||
cprintf(RED,
|
||||
"Error: Could not create Zmq socket on port %d with ip %s\n",
|
||||
portnum, socketip);
|
||||
portnum, socketip.c_str());
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@ -242,7 +293,7 @@ int main(int argc, char *argv[]) {
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED,
|
||||
"Error: Could not create Zmq socket on port %d with ip %s\n",
|
||||
portnum, socketip);
|
||||
portnum, socketip.c_str());
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@ -263,14 +314,14 @@ int main(int argc, char *argv[]) {
|
||||
// receive socket
|
||||
try {
|
||||
#endif
|
||||
zmqsocket2 = new sls::ZmqSocket(portnum2, socketip2);
|
||||
zmqsocket2 = new sls::ZmqSocket(portnum2, socketip2.c_str());
|
||||
|
||||
#ifdef NEWZMQ
|
||||
} catch (...) {
|
||||
cprintf(RED,
|
||||
"Error: Could not create Zmq socket server on port %d and "
|
||||
"ip %s\n",
|
||||
portnum2, socketip2);
|
||||
portnum2, socketip2.c_str());
|
||||
// delete zmqsocket2;
|
||||
// zmqsocket2=NULL;
|
||||
// delete zmqsocket;
|
||||
@ -284,7 +335,7 @@ int main(int argc, char *argv[]) {
|
||||
cprintf(RED,
|
||||
"AAA Error: Could not create Zmq socket server on port %d "
|
||||
"and ip %s\n",
|
||||
portnum2, socketip2);
|
||||
portnum2, socketip2.c_str());
|
||||
// delete zmqsocket2;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
@ -722,6 +773,25 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
cprintf(MAGENTA, "%d %d %d %d\n", xmin, xmax, ymin, ymax);
|
||||
mt->setROI(xmin, xmax, ymin, ymax);
|
||||
|
||||
if (addJsonHeader.find("xMin") != addJsonHeader.end()) {
|
||||
istringstream(addJsonHeader.at("xMin")) >> xmin;
|
||||
}
|
||||
|
||||
if (addJsonHeader.find("yMin") != addJsonHeader.end()) {
|
||||
istringstream(addJsonHeader.at("yMin")) >> ymin;
|
||||
}
|
||||
|
||||
if (addJsonHeader.find("xMax") != addJsonHeader.end()) {
|
||||
istringstream(addJsonHeader.at("xMax")) >> xmax;
|
||||
}
|
||||
|
||||
if (addJsonHeader.find("yMax") != addJsonHeader.end()) {
|
||||
istringstream(addJsonHeader.at("yMax")) >> ymax;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (addJsonHeader.find("dynamicRange") != addJsonHeader.end()) {
|
||||
istringstream(addJsonHeader.at("dynamicRange")) >> dr;
|
||||
dr = 32;
|
||||
@ -821,7 +891,7 @@ int main(int argc, char *argv[]) {
|
||||
// cout << acqIndex << " " << frameIndex << " " << subFrameIndex << "
|
||||
// "<< detSpec1 << " " << timestamp << " " << packetNumber << endl;
|
||||
// cprintf(GREEN, "frame\n");
|
||||
if (packetNumber >= 40) {
|
||||
if (packetNumber <= 50) {
|
||||
//*((int*)buff)=frameIndex;
|
||||
if (insubframe == 0)
|
||||
f0 = frameIndex;
|
||||
|
@ -193,6 +193,7 @@ void qDrawPlot::SetupPlots() {
|
||||
gainplot2d = new SlsQt2DPlot(boxPlot, true);
|
||||
gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5,
|
||||
nPixelsY - 0.5, gainData);
|
||||
gainplot2d->Update();
|
||||
gainplot2d->hide();
|
||||
connect(plot2d, SIGNAL(PlotZoomedSignal(const QRectF &)), this,
|
||||
SLOT(Zoom2DGainPlot(const QRectF &)));
|
||||
@ -1009,6 +1010,7 @@ void qDrawPlot::Update2dPlot() {
|
||||
if (isGainDataExtracted) {
|
||||
gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5,
|
||||
nPixelsY - 0.5, gainData);
|
||||
gainplot2d->Update();
|
||||
if (!gainplot2d->isVisible()) {
|
||||
gainplot2d->setFixedWidth(plot2d->width() /
|
||||
qDefs::DATA_GAIN_PLOT_RATIO);
|
||||
|
@ -803,8 +803,9 @@ void qTabMeasurement::GetNextFrameNumber() {
|
||||
"Inconsistent starting frame number for all detectors.");
|
||||
spinNextFrameNumber->setValue(retval);
|
||||
}
|
||||
CATCH_DISPLAY("Could not get starting frame number.",
|
||||
"qTabMeasurement::GetNextFrameNumber")
|
||||
CATCH_HANDLE("Could not get starting frame number.",
|
||||
"qTabMeasurement::GetNextFrameNumber", spinNextFrameNumber,
|
||||
&QSpinBox::setValue, -1)
|
||||
connect(spinNextFrameNumber, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetNextFrameNumber(int)));
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ install(TARGETS slsProjectCSettings
|
||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
add_subdirectory(ctbDetectorServer)
|
||||
add_subdirectory(xilinx_ctbDetectorServer)
|
||||
add_subdirectory(eigerDetectorServer)
|
||||
add_subdirectory(gotthardDetectorServer)
|
||||
add_subdirectory(jungfrauDetectorServer)
|
||||
|
@ -8,7 +8,8 @@ det_list=("ctbDetectorServer
|
||||
gotthard2DetectorServer
|
||||
jungfrauDetectorServer
|
||||
mythen3DetectorServer
|
||||
moenchDetectorServer"
|
||||
moenchDetectorServer
|
||||
xilinx_ctbDetectorServer"
|
||||
)
|
||||
usage="\nUsage: compileAllServers.sh [server|all(opt)] [branch(opt)]. \n\tNo arguments mean all servers with 'developer' branch. \n\tNo 'branch' input means 'developer branch'"
|
||||
|
||||
|
@ -9,6 +9,7 @@ det_list=("ctbDetectorServer"
|
||||
"jungfrauDetectorServer"
|
||||
"mythen3DetectorServer"
|
||||
"moenchDetectorServer"
|
||||
"xilinx_ctbDetectorServer"
|
||||
)
|
||||
usage="\nUsage: compileAllServers.sh [server|all(opt)] [branch(opt)]. \n\tNo arguments mean all servers with 'developer' branch. \n\tNo 'branch' input means 'developer branch'"
|
||||
|
||||
|
@ -37,8 +37,7 @@ target_compile_definitions(ctbDetectorServer_virtual
|
||||
)
|
||||
|
||||
target_link_libraries(ctbDetectorServer_virtual
|
||||
PUBLIC pthread rt slsProjectCSettings
|
||||
m
|
||||
PUBLIC pthread rt m slsProjectCSettings
|
||||
)
|
||||
|
||||
set_target_properties(ctbDetectorServer_virtual PROPERTIES
|
||||
|
Binary file not shown.
@ -55,7 +55,9 @@
|
||||
#define DEFAULT_SYNC_CLK (40) // 20
|
||||
#define DEFAULT_DBIT_CLK (200)
|
||||
#define DEFAULT_TRANSCEIVER_MASK (0x3)
|
||||
#define MAX_TRANSCEIVER_MASK (0xF)
|
||||
|
||||
#define MAX_TRANSCEIVER_MASK (0xF)
|
||||
#define MAX_TRANSCEIVER_SAMPLES (0xFFFF)
|
||||
|
||||
#define UDP_HEADER_MAX_FRAME_VALUE (0xFFFFFFFFFFFF)
|
||||
|
||||
|
Binary file not shown.
@ -10,7 +10,7 @@
|
||||
#define HARDWARE_VERSION_NAMES \
|
||||
{ "FX70T", "FX30T" }
|
||||
|
||||
#define REQUIRED_FIRMWARE_VERSION (31)
|
||||
#define REQUIRED_FIRMWARE_VERSION (32)
|
||||
// virtual ones renamed for consistency
|
||||
// real ones keep previous name for compatibility (already in production)
|
||||
#ifdef VIRTUAL
|
||||
|
Binary file not shown.
@ -471,7 +471,8 @@ void setupDetector() {
|
||||
// hv
|
||||
DAC6571_SetDefines(HV_HARD_MAX_VOLTAGE, HV_DRIVER_FILE_NAME);
|
||||
// dacs
|
||||
LTC2620_D_SetDefines(DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC);
|
||||
LTC2620_D_SetDefines(DAC_MIN_MV, DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC, 1,
|
||||
0, "");
|
||||
// on chip dacs
|
||||
ASIC_Driver_SetDefines(ONCHIP_DAC_DRIVER_FILE_NAME);
|
||||
setTimingSource(DEFAULT_TIMING_SOURCE);
|
||||
@ -3323,6 +3324,27 @@ void *start_timer(void *arg) {
|
||||
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
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
|
@ -35,6 +35,7 @@
|
||||
#define TEMPERATURE_FILE_NAME ("/sys/class/hwmon/hwmon0/temp1_input")
|
||||
#endif
|
||||
#define CONFIG_FILE ("config_gotthard2.txt")
|
||||
#define DAC_MIN_MV (0)
|
||||
#define DAC_MAX_MV (2048)
|
||||
#define ONCHIP_DAC_MAX_VAL (0x3FF)
|
||||
#define ADU_MAX_VAL (0xFFF)
|
||||
|
Binary file not shown.
@ -90,6 +90,7 @@ void basictests() {
|
||||
"Could not map to memory. Cannot proceed. Check Firmware.\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initError = FAIL;
|
||||
return;
|
||||
}
|
||||
#ifndef VIRTUAL
|
||||
// does check only if flag is 0 (by default), set by command line
|
||||
|
@ -24,16 +24,18 @@
|
||||
|
||||
#define RUN_BUSY_OFST (0)
|
||||
#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 DELAYBEFORE_OFST (4) // Not used in software
|
||||
#define DELAYBEFORE_MSK (0x00000001 << DELAYBEFORE_OFST) // Not used in software
|
||||
#define DELAYAFTER_OFST (5) // Not used in software
|
||||
#define DELAYAFTER_MSK (0x00000001 << DELAYAFTER_OFST) // Not used in software
|
||||
#define STOPPED_OFST (15)
|
||||
#define WAITING_FOR_START_FRAME_OFST (2)
|
||||
#define WAITING_FOR_START_FRAME_MSK (0x00000001 << WAITING_FOR_START_FRAME_OFST)
|
||||
#define ACQUIRING_FRAME_OFST (3) // Not used in software
|
||||
#define ACQUIRING_FRAME_MSK (0x00000001 << ACQUIRING_FRAME_OFST)
|
||||
#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 RUNMACHINE_BUSY_OFST (17)
|
||||
#define RUNMACHINE_BUSY_MSK (0x00000001 << RUNMACHINE_BUSY_OFST)
|
||||
#define INTERNAL_STOP_OFST (9)
|
||||
#define INTERNAL_STOP_MSK (0x00000001 << INTERNAL_STOP_OFST)
|
||||
|
||||
/* Look at me register */
|
||||
#define LOOK_AT_ME_REG (0x03 << MEM_MAP_SHIFT) // Not used in firmware or software
|
||||
|
Binary file not shown.
@ -88,6 +88,7 @@ void basictests() {
|
||||
"Could not map to memory. Cannot proceed. Check Firmware.\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initError = FAIL;
|
||||
return;
|
||||
}
|
||||
#ifndef VIRTUAL
|
||||
// does check only if flag is 0 (by default), set by command line
|
||||
@ -2552,8 +2553,7 @@ void setPedestalMode(int enable, uint8_t frames, uint16_t loops) {
|
||||
if (enable) {
|
||||
LOG(logINFOBLUE, ("Enabling pedestal mode [frames: %hhu, loops: %hu]\n",
|
||||
frames, loops));
|
||||
// enable
|
||||
bus_w(addr, bus_r(addr) | PEDESTAL_MODE_ENBLE_MSK);
|
||||
|
||||
// frames
|
||||
bus_w(addr, bus_r(addr) & ~PEDESTAL_MODE_LNGTH_MSK);
|
||||
bus_w(addr, bus_r(addr) | ((frames << PEDESTAL_MODE_LNGTH_OFST) &
|
||||
@ -2562,6 +2562,8 @@ void setPedestalMode(int enable, uint8_t frames, uint16_t 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) {
|
||||
@ -2726,6 +2728,7 @@ void *start_timer(void *arg) {
|
||||
if (i % pixelsPerPacket == 0) {
|
||||
++dataVal;
|
||||
}
|
||||
|
||||
if ((i % 1024) < 300) {
|
||||
gainVal = 1;
|
||||
} else if ((i % 1024) < 600) {
|
||||
@ -2766,6 +2769,28 @@ void *start_timer(void *arg) {
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
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 srcOffset2 = DATA_BYTES / 2;
|
||||
int row0 = (numInterfaces == 1 ? detPos[1] : detPos[3]);
|
||||
@ -2900,14 +2925,17 @@ int softwareTrigger(int block) {
|
||||
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);
|
||||
// wait to make sure its out of this state and even 'wait for start frame'
|
||||
usleep(100);
|
||||
|
||||
#ifndef VIRTUAL
|
||||
// block till frame is sent out
|
||||
// block till frame sent out & back to wait for trigger (or not busy
|
||||
// anymore)
|
||||
if (block) {
|
||||
enum runStatus s = getRunStatus();
|
||||
while (s == RUNNING || s == TRANSMITTING) {
|
||||
uint32_t retval = bus_r(STATUS_REG);
|
||||
while ((retval & RUN_BUSY_MSK) && !(retval & WAITING_FOR_TRIGGER_MSK)) {
|
||||
usleep(5000);
|
||||
s = getRunStatus();
|
||||
retval = bus_r(STATUS_REG);
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("Ready for Next Trigger...\n"));
|
||||
@ -2940,9 +2968,16 @@ enum runStatus getRunStatus() {
|
||||
u_int32_t retval = bus_r(STATUS_REG);
|
||||
LOG(logINFO, ("Status Register: %08x\n", retval));
|
||||
|
||||
// error
|
||||
if (retval & INTERNAL_STOP_MSK) {
|
||||
LOG(logINFOBLUE, ("Status: ERROR\n"));
|
||||
s = ERROR;
|
||||
}
|
||||
|
||||
// running
|
||||
if (retval & RUN_BUSY_MSK) {
|
||||
if (retval & WAITING_FOR_TRIGGER_MSK) {
|
||||
else if (retval & RUN_BUSY_MSK) {
|
||||
if ((retval & WAITING_FOR_TRIGGER_MSK) ||
|
||||
(retval & WAITING_FOR_START_FRAME_MSK)) {
|
||||
LOG(logINFOBLUE, ("Status: WAITING\n"));
|
||||
s = WAITING;
|
||||
} else {
|
||||
@ -2953,19 +2988,13 @@ enum runStatus getRunStatus() {
|
||||
|
||||
// not running
|
||||
else {
|
||||
// stopped or error
|
||||
// stopped or idle
|
||||
if (retval & STOPPED_MSK) {
|
||||
LOG(logINFOBLUE, ("Status: STOPPED\n"));
|
||||
s = STOPPED;
|
||||
} else if (retval & RUNMACHINE_BUSY_MSK) {
|
||||
LOG(logINFOBLUE, ("Status: READ MACHINE BUSY\n"));
|
||||
s = TRANSMITTING;
|
||||
} else if (!retval) {
|
||||
} else {
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
s = IDLE;
|
||||
} else {
|
||||
LOG(logERROR, ("Status: Unknown status %08x\n", retval));
|
||||
s = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
Binary file not shown.
@ -82,6 +82,7 @@ void basictests() {
|
||||
"Could not map to memory. Cannot proceed. Check Firmware.\n");
|
||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
initError = FAIL;
|
||||
return;
|
||||
}
|
||||
#ifndef VIRTUAL
|
||||
// does check only if flag is 0 (by default), set by command line
|
||||
@ -481,7 +482,6 @@ void setupDetector() {
|
||||
return;
|
||||
}
|
||||
|
||||
setReadoutSpeed(DEFAULT_SPEED);
|
||||
cleanFifos();
|
||||
resetCore();
|
||||
|
||||
@ -495,6 +495,7 @@ void setupDetector() {
|
||||
initReadoutConfiguration();
|
||||
|
||||
// Initialization of acquistion parameters
|
||||
setReadoutSpeed(DEFAULT_SPEED);
|
||||
setSettings(DEFAULT_SETTINGS);
|
||||
setNumFrames(DEFAULT_NUM_FRAMES);
|
||||
setNumTriggers(DEFAULT_NUM_CYCLES);
|
||||
@ -699,14 +700,12 @@ int setExpTime(int64_t val) {
|
||||
}
|
||||
LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val));
|
||||
val *= (1E-3 * CLK_RUN);
|
||||
val -= ACQ_TIME_MIN_CLOCK;
|
||||
if (val < 0) {
|
||||
val = 0;
|
||||
}
|
||||
set64BitReg(val, SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG);
|
||||
|
||||
// validate for tolerance
|
||||
val += ACQ_TIME_MIN_CLOCK;
|
||||
int64_t retval = getExpTime();
|
||||
val /= (1E-3 * CLK_RUN);
|
||||
if (val != retval) {
|
||||
@ -716,8 +715,7 @@ int setExpTime(int64_t val) {
|
||||
}
|
||||
|
||||
int64_t getExpTime() {
|
||||
return (get64BitReg(SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG) +
|
||||
ACQ_TIME_MIN_CLOCK) /
|
||||
return get64BitReg(SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG) /
|
||||
(1E-3 * CLK_RUN);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
#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 HARDWARE_VERSION_NUMBERS \
|
||||
@ -58,11 +58,10 @@
|
||||
/* Defines in the Firmware */
|
||||
#define MAX_TIMESLOT_VAL (0x1F)
|
||||
#define MAX_THRESHOLD_TEMP_VAL (127999) // millidegrees
|
||||
#define ACQ_TIME_MIN_CLOCK (2)
|
||||
#define ASIC_FILTER_MAX_RES_VALUE (1)
|
||||
#define MAX_SELECT_CHIP10_VAL (63)
|
||||
|
||||
#define MAX_PHASE_SHIFTS (240)
|
||||
#define MAX_PHASE_SHIFTS (200)
|
||||
#define BIT16_MASK (0xFFFF)
|
||||
|
||||
#define ADC_DECMT_QUARTER_SPEED (0x3)
|
||||
|
Binary file not shown.
@ -92,6 +92,7 @@ void basictests() {
|
||||
"Could not map to memory. Cannot proceed. Check Firmware.\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initError = FAIL;
|
||||
return;
|
||||
}
|
||||
#ifndef VIRTUAL
|
||||
// does check only if flag is 0 (by default), set by command line
|
||||
@ -482,7 +483,8 @@ void setupDetector() {
|
||||
// hv
|
||||
DAC6571_SetDefines(HV_HARD_MAX_VOLTAGE, HV_DRIVER_FILE_NAME);
|
||||
// dac
|
||||
LTC2620_D_SetDefines(DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC);
|
||||
LTC2620_D_SetDefines(DAC_MIN_MV, DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC, 1,
|
||||
0, "");
|
||||
|
||||
resetCore();
|
||||
resetPeripheral();
|
||||
|
@ -34,6 +34,7 @@
|
||||
#else
|
||||
#define TEMPERATURE_FILE_NAME ("/sys/class/hwmon/hwmon0/temp1_input")
|
||||
#endif
|
||||
#define DAC_MIN_MV (0)
|
||||
#define DAC_MAX_MV (2048)
|
||||
#define TYPE_MYTHEN3_MODULE_VAL (93)
|
||||
#define TYPE_TOLERANCE (5)
|
||||
|
@ -4,18 +4,11 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
/**
|
||||
* Set Defines
|
||||
* @param hardMaxV maximum hardware limit
|
||||
* @param driverfname driver file name
|
||||
* @param numdacs number of dacs
|
||||
*/
|
||||
void LTC2620_D_SetDefines(int hardMaxV, char *driverfname, int numdacs);
|
||||
|
||||
/**
|
||||
* Get max number of steps
|
||||
*/
|
||||
void LTC2620_D_SetDefines(int hardMinV, int hardMaxV, char *driverfname,
|
||||
int numdacs, int numdevices, int startingDeviceIndex,
|
||||
char *powerdownDriverfname);
|
||||
int LTC2620_D_GetMaxNumSteps();
|
||||
int LTC2620_D_GetPowerDownValue();
|
||||
|
||||
/**
|
||||
* Convert voltage to dac units
|
||||
|
15
slsDetectorServers/slsDetectorServer/include/arm64.h
Normal file
15
slsDetectorServers/slsDetectorServer/include/arm64.h
Normal file
@ -0,0 +1,15 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
void bus_w(u_int32_t offset, u_int32_t data);
|
||||
u_int32_t bus_r(u_int32_t offset);
|
||||
uint64_t getU64BitReg(int aLSB, int aMSB);
|
||||
void setU64BitReg(uint64_t value, int aLSB, int aMSB);
|
||||
u_int32_t readRegister(u_int32_t offset);
|
||||
u_int32_t writeRegister(u_int32_t offset, u_int32_t data);
|
||||
int mapCSP0(void);
|
||||
u_int32_t *Arm_getUDPBaseAddress();
|
@ -6,10 +6,12 @@
|
||||
#include "clogger.h"
|
||||
|
||||
void initializePatternAddresses();
|
||||
#ifdef CHIPTESTBOARDD
|
||||
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||
#ifdef VIRTUAL
|
||||
void initializePatternWord();
|
||||
#endif
|
||||
#endif
|
||||
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||
uint64_t validate_readPatternIOControl();
|
||||
int validate_writePatternIOControl(char *message, uint64_t arg);
|
||||
void writePatternIOControl(uint64_t word);
|
||||
|
12
slsDetectorServers/slsDetectorServer/include/programViaArm.h
Normal file
12
slsDetectorServers/slsDetectorServer/include/programViaArm.h
Normal file
@ -0,0 +1,12 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
int resetFPGA(char *mess);
|
||||
int loadDeviceTree(char *mess, int *adcDeviceIndex, int *dacDeviceIndex);
|
||||
|
||||
int checksBeforeCreatingDeviceTree(char *mess);
|
||||
int createDeviceTree(char *mess);
|
||||
int verifyDeviceTree(char *mess, int *adcDeviceIndex, int *dacDeviceIndex);
|
@ -25,6 +25,11 @@
|
||||
#include "blackfin.h"
|
||||
#endif
|
||||
|
||||
#ifdef ARMPROCESSOR
|
||||
#include "arm64.h"
|
||||
#include "programViaArm.h"
|
||||
#endif
|
||||
|
||||
#ifdef MYTHEN3D
|
||||
#include "mythen3.h"
|
||||
#endif
|
||||
@ -61,12 +66,15 @@ typedef struct udpStruct_s {
|
||||
int isInitCheckDone();
|
||||
int getInitResult(char **mess);
|
||||
void basictests();
|
||||
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MOENCHD) || \
|
||||
defined(CHIPTESTBOARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
#if !defined(EIGERD)
|
||||
int checkType();
|
||||
int testFpga();
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
int testFixedFPGAPattern();
|
||||
#else
|
||||
int testBus();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(GOTTHARDD) || \
|
||||
((defined(EIGERD) || defined(JUNGFRAUD) || defined(MOENCHD)) && \
|
||||
@ -86,8 +94,10 @@ void getHardwareVersion(char *version);
|
||||
#ifdef EIGERD
|
||||
int getHardwareVersionNumber();
|
||||
#else
|
||||
#ifndef XILINX_CHIPTESTBOARDD
|
||||
u_int16_t getHardwareVersionNumber();
|
||||
#endif
|
||||
#endif
|
||||
#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD)
|
||||
u_int16_t getHardwareSerialNumber();
|
||||
#endif
|
||||
@ -111,7 +121,6 @@ int updateModuleId();
|
||||
void setModuleId(int modid);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
u_int64_t getDetectorMAC();
|
||||
u_int32_t getDetectorIP();
|
||||
|
||||
@ -136,7 +145,7 @@ int updateDatabytesandAllocateRAM();
|
||||
void updateDataBytes();
|
||||
#endif
|
||||
|
||||
#ifndef CHIPTESTBOARDD
|
||||
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD)
|
||||
int resetToDefaultDacs(int hardReset);
|
||||
int getDefaultDac(enum DACINDEX index, enum detectorSettings sett, int *retval);
|
||||
int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value);
|
||||
@ -172,6 +181,22 @@ uint32_t readRegister16And32(uint32_t offset);
|
||||
#endif
|
||||
|
||||
// firmware functions (resets)
|
||||
#if defined(XILINX_CHIPTESTBOARDD)
|
||||
void cleanFifos();
|
||||
void resetFlow();
|
||||
int waitTranseiverReset(char *mess);
|
||||
#ifdef VIRTUAL
|
||||
void setTransceiverAlignment(int align);
|
||||
#endif
|
||||
int isTransceiverAligned();
|
||||
int waitTransceiverAligned(char *mess);
|
||||
int configureTransceiver(char *mess);
|
||||
int isChipConfigured();
|
||||
int powerChip(int on, char *mess);
|
||||
int getPowerChip();
|
||||
int configureChip(char *mess);
|
||||
void startPeriphery();
|
||||
#endif
|
||||
#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD) || \
|
||||
defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
void cleanFifos();
|
||||
@ -211,6 +236,12 @@ uint32_t getTransceiverEnableMask();
|
||||
void setADCInvertRegister(uint32_t val);
|
||||
uint32_t getADCInvertRegister();
|
||||
#endif
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
void setADCEnableMask_10G(uint32_t mask);
|
||||
uint32_t getADCEnableMask_10G();
|
||||
int setTransceiverEnableMask(uint32_t mask);
|
||||
uint32_t getTransceiverEnableMask();
|
||||
#endif
|
||||
#if defined(CHIPTESTBOARDD)
|
||||
int setExternalSamplingSource(int val);
|
||||
int setExternalSampling(int val);
|
||||
@ -226,7 +257,7 @@ int getParallelMode();
|
||||
int setOverFlowMode(int mode);
|
||||
int getOverFlowMode();
|
||||
#endif
|
||||
#ifdef CHIPTESTBOARDD
|
||||
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||
int setReadoutMode(enum readoutMode mode);
|
||||
int getReadoutMode();
|
||||
#endif
|
||||
@ -237,7 +268,7 @@ int selectStoragecellStart(int pos);
|
||||
int getMaxStoragecellStart();
|
||||
#endif
|
||||
#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(EIGERD) || \
|
||||
defined(CHIPTESTBOARDD)
|
||||
defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||
int setNextFrameNumber(uint64_t value);
|
||||
int getNextFrameNumber(uint64_t *value);
|
||||
#endif
|
||||
@ -282,11 +313,9 @@ int getNumAdditionalStorageCells();
|
||||
int setStorageCellDelay(int64_t val);
|
||||
int64_t getStorageCellDelay();
|
||||
#endif
|
||||
#if defined(CHIPTESTBOARDD)
|
||||
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||
int setNumAnalogSamples(int val);
|
||||
int getNumAnalogSamples();
|
||||
#endif
|
||||
#ifdef CHIPTESTBOARDD
|
||||
int setNumDigitalSamples(int val);
|
||||
int getNumDigitalSamples();
|
||||
int setNumTransceiverSamples(int val);
|
||||
@ -299,12 +328,15 @@ uint32_t getCounterMask();
|
||||
void updatePacketizing();
|
||||
#endif
|
||||
|
||||
#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARDD) || \
|
||||
defined(CHIPTESTBOARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
int setDelayAfterTrigger(int64_t val);
|
||||
int64_t getDelayAfterTrigger();
|
||||
#ifndef EIGERD
|
||||
int64_t getNumFramesLeft();
|
||||
int64_t getNumTriggersLeft();
|
||||
#endif
|
||||
#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARDD) || \
|
||||
defined(CHIPTESTBOARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D) || \
|
||||
defined(XILINX_CHIPTESTBOARDD)
|
||||
int setDelayAfterTrigger(int64_t val);
|
||||
int64_t getDelayAfterTrigger();
|
||||
int64_t getDelayAfterTriggerLeft();
|
||||
int64_t getPeriodLeft();
|
||||
#endif
|
||||
@ -315,7 +347,7 @@ int64_t getNumBurstsLeft();
|
||||
int64_t getExpTimeLeft();
|
||||
#endif
|
||||
#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD) || \
|
||||
defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
defined(MYTHEN3D) || defined(GOTTHARD2D) || defined(XILINX_CHIPTESTBOARDD)
|
||||
int64_t getFramesFromStart();
|
||||
int64_t getActualTime();
|
||||
int64_t getMeasurementTime();
|
||||
@ -337,10 +369,12 @@ int setTrimbits(int *trimbits);
|
||||
int setAllTrimbits(int val);
|
||||
int getAllTrimbits();
|
||||
#endif
|
||||
#ifndef XILINX_CHIPTESTBOARDD
|
||||
#ifndef CHIPTESTBOARDD
|
||||
enum detectorSettings setSettings(enum detectorSettings sett);
|
||||
#endif
|
||||
enum detectorSettings getSettings();
|
||||
#endif
|
||||
#if defined(JUNGFRAUD)
|
||||
enum gainMode getGainMode();
|
||||
void setGainMode(enum gainMode mode);
|
||||
@ -370,7 +404,7 @@ void setDAC(enum DACINDEX ind, int val, int mV);
|
||||
#endif
|
||||
int getDAC(enum DACINDEX ind, int mV);
|
||||
int getMaxDacSteps();
|
||||
#if defined(CHIPTESTBOARDD)
|
||||
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||
int dacToVoltage(int dac);
|
||||
int checkVLimitCompliant(int mV);
|
||||
int checkVLimitDacCompliant(int dac);
|
||||
@ -389,9 +423,12 @@ int isPowerValid(enum DACINDEX ind, int val);
|
||||
int getPower();
|
||||
void setPower(enum DACINDEX ind, int val);
|
||||
void powerOff();
|
||||
#elif XILINX_CHIPTESTBOARDD
|
||||
int getPower();
|
||||
void setPower(enum DACINDEX ind, int val);
|
||||
#endif
|
||||
|
||||
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
#if defined(MYTHEN3D) || defined(GOTTHARD2D) || defined(XILINX_CHIPTESTBOARDD)
|
||||
int getADC(enum ADCINDEX ind, int *value);
|
||||
#else
|
||||
int getADC(enum ADCINDEX ind);
|
||||
@ -400,8 +437,12 @@ int getADC(enum ADCINDEX ind);
|
||||
int getSlowADC(int ichan);
|
||||
int getSlowADCTemperature();
|
||||
#endif
|
||||
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
int getSlowADC(int ichan, int *retval);
|
||||
int getTemperature(int *retval);
|
||||
#else
|
||||
int setHighVoltage(int val);
|
||||
#endif
|
||||
|
||||
// parameters - timing, extsig
|
||||
#if defined(EIGERD) || defined(GOTTHARD2D) || defined(JUNGFRAUD) || \
|
||||
@ -471,7 +512,8 @@ void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip,
|
||||
uint32_t sourceip, uint16_t sourceport);
|
||||
#endif
|
||||
#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARD2D) || \
|
||||
defined(MYTHEN3D) || defined(CHIPTESTBOARDD)
|
||||
defined(MYTHEN3D) || defined(CHIPTESTBOARDD) || \
|
||||
defined(XILINX_CHIPTESTBOARDD)
|
||||
void calcChecksum(udp_header *udp);
|
||||
#endif
|
||||
#ifdef GOTTHARDD
|
||||
@ -679,13 +721,14 @@ int startStateMachine();
|
||||
void *start_timer(void *arg);
|
||||
#endif
|
||||
int stopStateMachine();
|
||||
#ifdef MYTHEN3D
|
||||
#if defined(MYTHEN3D) || defined(XILINX_CHIPTESTBOARDD)
|
||||
int softwareTrigger();
|
||||
#endif
|
||||
#if defined(EIGERD) || defined(JUNGFRAUD) || defined(MOENCHD)
|
||||
int softwareTrigger(int block);
|
||||
#endif
|
||||
#if defined(EIGERD) || defined(MYTHEN3D) || defined(CHIPTESTBOARDD)
|
||||
#if defined(EIGERD) || defined(MYTHEN3D) || defined(CHIPTESTBOARDD) || \
|
||||
defined(XILINX_CHIPTESTBOARDD)
|
||||
int startReadOut();
|
||||
#endif
|
||||
enum runStatus getRunStatus();
|
||||
@ -705,7 +748,8 @@ int readFrameFromFifo();
|
||||
#endif
|
||||
|
||||
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MOENCHD) || \
|
||||
defined(CHIPTESTBOARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
defined(CHIPTESTBOARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D) || \
|
||||
defined(XILINX_CHIPTESTBOARDD)
|
||||
u_int32_t runBusy();
|
||||
#endif
|
||||
|
||||
@ -716,9 +760,9 @@ u_int32_t runState(enum TLogLevel lev);
|
||||
// common
|
||||
int calculateDataBytes();
|
||||
int getTotalNumberOfChannels();
|
||||
#if defined(CHIPTESTBOARDD)
|
||||
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||
void getNumberOfChannels(int *nchanx, int *nchany);
|
||||
#endif
|
||||
int getNumberOfChips();
|
||||
int getNumberOfDACs();
|
||||
int getNumberOfChannelsPerChip();
|
||||
int getNumberOfChannelsPerChip();
|
@ -329,3 +329,4 @@ int getColumn();
|
||||
int setColumn(int);
|
||||
int get_pedestal_mode(int);
|
||||
int set_pedestal_mode(int);
|
||||
int config_transceiver(int);
|
||||
|
@ -13,35 +13,54 @@
|
||||
#define LTC2620_D_MAX_STEPS (LTC2620_D_MAX_DAC_VAL + 1)
|
||||
|
||||
// defines from the fpga
|
||||
int LTC2620_D_HardMinVoltage = 0;
|
||||
int LTC2620_D_HardMaxVoltage = 0;
|
||||
char LTC2620_D_DriverFileName[MAX_STR_LENGTH];
|
||||
char LTC2620_D_PowerDownDriverFileName[MAX_STR_LENGTH];
|
||||
int LTC2620_D_NumDacs = 0;
|
||||
int LTC2620_D_NumDevices = 0;
|
||||
int LTC2620_D_NumChannelsPerDevice = 0;
|
||||
int LTC2620_D_DacDriverStartingDeviceIndex = 0;
|
||||
|
||||
void LTC2620_D_SetDefines(int hardMaxV, char *driverfname, int numdacs) {
|
||||
void LTC2620_D_SetDefines(int hardMinV, int hardMaxV, char *driverfname,
|
||||
int numdacs, int numdevices, int startingDeviceIndex,
|
||||
char *powerdownDriverfname) {
|
||||
LOG(logINFOBLUE,
|
||||
("Configuring DACs (LTC2620) to %s (numdacs:%d, hard max: %dmV)\n",
|
||||
driverfname, numdacs, hardMaxV));
|
||||
("Configuring DACs (LTC2620) to %s\n\t (numdacs:%d, hard min:%d, hard "
|
||||
"max: %dmV, idev:%d)\n",
|
||||
driverfname, numdacs, hardMinV, hardMaxV, startingDeviceIndex));
|
||||
LTC2620_D_HardMinVoltage = hardMinV;
|
||||
LTC2620_D_HardMaxVoltage = hardMaxV;
|
||||
memset(LTC2620_D_DriverFileName, 0, MAX_STR_LENGTH);
|
||||
strcpy(LTC2620_D_DriverFileName, driverfname);
|
||||
memset(LTC2620_D_PowerDownDriverFileName, 0, MAX_STR_LENGTH);
|
||||
strcpy(LTC2620_D_PowerDownDriverFileName, powerdownDriverfname);
|
||||
LTC2620_D_NumDacs = numdacs;
|
||||
LTC2620_D_NumDevices = numdevices;
|
||||
LTC2620_D_NumChannelsPerDevice = LTC2620_D_NumDacs / LTC2620_D_NumDevices;
|
||||
LTC2620_D_DacDriverStartingDeviceIndex = startingDeviceIndex;
|
||||
}
|
||||
|
||||
int LTC2620_D_GetMaxNumSteps() { return LTC2620_D_MAX_STEPS; }
|
||||
|
||||
int LTC2620_D_GetPowerDownValue() { return LTC2620_D_PWR_DOWN_VAL; }
|
||||
|
||||
int LTC2620_D_VoltageToDac(int voltage, int *dacval) {
|
||||
return ConvertToDifferentRange(0, LTC2620_D_HardMaxVoltage, 0,
|
||||
return ConvertToDifferentRange(LTC2620_D_HardMinVoltage,
|
||||
LTC2620_D_HardMaxVoltage, 0,
|
||||
LTC2620_D_MAX_DAC_VAL, voltage, dacval);
|
||||
}
|
||||
|
||||
int LTC2620_D_DacToVoltage(int dacval, int *voltage) {
|
||||
return ConvertToDifferentRange(0, LTC2620_D_MAX_DAC_VAL, 0,
|
||||
return ConvertToDifferentRange(0, LTC2620_D_MAX_DAC_VAL,
|
||||
LTC2620_D_HardMinVoltage,
|
||||
LTC2620_D_HardMaxVoltage, dacval, voltage);
|
||||
}
|
||||
|
||||
int LTC2620_D_SetDACValue(int dacnum, int val, int mV, char *dacname,
|
||||
int *dacval) {
|
||||
LOG(logDEBUG1, ("dacnum:%d, val:%d, ismV:%d\n", dacnum, val, mV));
|
||||
|
||||
// validate index
|
||||
if (dacnum < 0 || dacnum >= LTC2620_D_NumDacs) {
|
||||
LOG(logERROR, ("Dac index %d is out of bounds (0 to %d)\n", dacnum,
|
||||
@ -49,53 +68,90 @@ int LTC2620_D_SetDACValue(int dacnum, int val, int mV, char *dacname,
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// get
|
||||
// validate set
|
||||
if (val < 0 && val != LTC2620_D_PWR_DOWN_VAL)
|
||||
return FAIL;
|
||||
|
||||
// convert to dac or get mV value
|
||||
*dacval = val;
|
||||
int dacmV = val;
|
||||
int ret = OK;
|
||||
if (mV) {
|
||||
ret = LTC2620_D_VoltageToDac(val, dacval);
|
||||
} else if (val >= 0) {
|
||||
// do not convert power down dac val
|
||||
ret = LTC2620_D_DacToVoltage(val, &dacmV);
|
||||
}
|
||||
|
||||
// conversion out of bounds
|
||||
if (ret == FAIL) {
|
||||
LOG(logERROR, ("Setting Dac %d %s is out of bounds\n", dacnum,
|
||||
(mV ? "mV" : "dac units")));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// set
|
||||
if ((*dacval >= 0) || (*dacval == LTC2620_D_PWR_DOWN_VAL)) {
|
||||
LOG(logINFO, ("Setting DAC %2d [%-12s] : %d dac (%d mV)\n", dacnum,
|
||||
dacname, *dacval, dacmV));
|
||||
|
||||
*dacval = val;
|
||||
#ifndef VIRTUAL
|
||||
char fname[MAX_STR_LENGTH];
|
||||
strcpy(fname, LTC2620_D_DriverFileName);
|
||||
char temp[20];
|
||||
memset(temp, 0, sizeof(temp));
|
||||
sprintf(temp, "%d", dacnum);
|
||||
strcat(fname, temp);
|
||||
LOG(logDEBUG1, ("fname %s\n", fname));
|
||||
char fnameFormat[MAX_STR_LENGTH];
|
||||
memset(fnameFormat, 0, MAX_STR_LENGTH);
|
||||
strcpy(fnameFormat, LTC2620_D_DriverFileName);
|
||||
#endif
|
||||
|
||||
// open file
|
||||
FILE *fd = fopen(fname, "w");
|
||||
if (fd == NULL) {
|
||||
LOG(logERROR, ("Could not open file %s for writing to set dac %d\n",
|
||||
fname, dacnum));
|
||||
return FAIL;
|
||||
}
|
||||
// convert to string, add 0 and write to file
|
||||
fprintf(fd, "%d\n", *dacval);
|
||||
fclose(fd);
|
||||
// power down dac (different file name)
|
||||
if (val == LTC2620_D_PWR_DOWN_VAL) {
|
||||
#if defined(XILINX_CHIPTESTBOARDD) && !defined(VIRTUAL)
|
||||
LOG(logINFO, ("Powering down DAC %2d [%-6s] \n", dacnum, dacname));
|
||||
strcpy(fnameFormat, LTC2620_D_PowerDownDriverFileName);
|
||||
#endif
|
||||
}
|
||||
|
||||
// proper value to set
|
||||
else {
|
||||
// convert to dac or get mV value
|
||||
int dacmV = val;
|
||||
if (mV) {
|
||||
ret = LTC2620_D_VoltageToDac(val, dacval);
|
||||
} else if (val >= 0) {
|
||||
// do not convert power down dac val
|
||||
ret = LTC2620_D_DacToVoltage(val, &dacmV);
|
||||
}
|
||||
|
||||
// conversion out of bounds
|
||||
if (ret == FAIL) {
|
||||
LOG(logERROR, ("Setting Dac %d %s is out of bounds\n", dacnum,
|
||||
(mV ? "mV" : "dac units")));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// print and set
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
if (*dacval >= 0) {
|
||||
LOG(logINFO, ("Setting DAC %2d [%-6s] : %d dac (%d mV)\n", dacnum,
|
||||
dacname, *dacval, dacmV));
|
||||
}
|
||||
#else
|
||||
if ((*dacval >= 0) || (*dacval == LTC2620_D_PWR_DOWN_VAL)) {
|
||||
LOG(logINFO, ("Setting DAC %2d [%-12s] : %d dac (%d mV)\n", dacnum,
|
||||
dacname, *dacval, dacmV));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// set in file
|
||||
#ifndef VIRTUAL
|
||||
char fname[MAX_STR_LENGTH];
|
||||
memset(fname, 0, MAX_STR_LENGTH);
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
int idev = LTC2620_D_DacDriverStartingDeviceIndex +
|
||||
(dacnum / LTC2620_D_NumChannelsPerDevice);
|
||||
int idac = dacnum % LTC2620_D_NumChannelsPerDevice;
|
||||
sprintf(fname, fnameFormat, idev, idac);
|
||||
#else
|
||||
sprintf(fname, "%s%d", fnameFormat, dacnum);
|
||||
#endif
|
||||
LOG(logDEBUG1, ("fname %s\n", fname));
|
||||
|
||||
// open file
|
||||
FILE *fd = fopen(fname, "w");
|
||||
if (fd == NULL) {
|
||||
LOG(logERROR, ("Could not open file %s for writing to set dac %d\n",
|
||||
fname, dacnum));
|
||||
return FAIL;
|
||||
}
|
||||
// convert to string, add 0 and write to file
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
// not changing *dacval from -100 (cant write -100 to file: invalid arg)
|
||||
int writeValue = *dacval;
|
||||
if (writeValue == LTC2620_D_PWR_DOWN_VAL)
|
||||
writeValue = 1;
|
||||
fprintf(fd, "%d\n", writeValue);
|
||||
#else
|
||||
fprintf(fd, "%d\n", *dacval);
|
||||
#endif
|
||||
fclose(fd);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
94
slsDetectorServers/slsDetectorServer/src/arm64.c
Normal file
94
slsDetectorServers/slsDetectorServer/src/arm64.c
Normal file
@ -0,0 +1,94 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include "arm64.h"
|
||||
#include "RegisterDefs.h"
|
||||
#include "clogger.h"
|
||||
#include "common.h"
|
||||
#include "sls/ansi.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
#include <fcntl.h> // open
|
||||
#include <sys/mman.h> // mmap
|
||||
|
||||
/* global variables */
|
||||
#define CSP0 (0xB0080000)
|
||||
#define CSP1 (0xB0050000) // udp
|
||||
#define MEM_SIZE (0x10000)
|
||||
//#define MEM_SIZE_CSP0 (4096)
|
||||
//#define MEM_SIZE_CSP1 (2 * 4096)
|
||||
u_int32_t *csp0base = 0;
|
||||
u_int32_t *csp1base = 0;
|
||||
|
||||
void bus_w(u_int32_t offset, u_int32_t data) {
|
||||
volatile u_int32_t *ptr1;
|
||||
ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t)));
|
||||
*ptr1 = data;
|
||||
}
|
||||
|
||||
u_int32_t bus_r(u_int32_t offset) {
|
||||
volatile u_int32_t *ptr1;
|
||||
ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t)));
|
||||
return *ptr1;
|
||||
}
|
||||
|
||||
uint64_t getU64BitReg(int aLSB, int aMSB) {
|
||||
uint64_t retval = bus_r(aMSB);
|
||||
retval = (retval << 32) | bus_r(aLSB);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void setU64BitReg(uint64_t value, int aLSB, int aMSB) {
|
||||
bus_w(aLSB, value & (0xffffffff));
|
||||
bus_w(aMSB, (value >> 32) & (0xffffffff));
|
||||
}
|
||||
|
||||
u_int32_t readRegister(u_int32_t offset) { return bus_r(offset); }
|
||||
|
||||
u_int32_t writeRegister(u_int32_t offset, u_int32_t data) {
|
||||
bus_w(offset, data);
|
||||
return readRegister(offset);
|
||||
}
|
||||
|
||||
int mapCSP0(void) {
|
||||
u_int32_t csps[2] = {CSP0, CSP1};
|
||||
u_int32_t **cspbases[2] = {&csp0base, &csp1base};
|
||||
char names[2][10] = {"csp0base", "csp1base"};
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
// if not mapped
|
||||
if (*cspbases[i] == 0) {
|
||||
LOG(logINFO, ("Mapping memory for %s\n", names[i]));
|
||||
#ifdef VIRTUAL
|
||||
*cspbases[i] = malloc(MEM_SIZE);
|
||||
if (*cspbases[i] == NULL) {
|
||||
LOG(logERROR,
|
||||
("Could not allocate virtual memory for %s.\n", names[i]));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("memory allocated for %s\n", names[i]));
|
||||
#else
|
||||
int fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
|
||||
if (fd == -1) {
|
||||
LOG(logERROR, ("Can't find /dev/mem for %s\n", names[i]));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logDEBUG1,
|
||||
("/dev/mem opened for %s, (CSP:0x%x)\n", names[i], csps[i]));
|
||||
*cspbases[i] =
|
||||
(u_int32_t *)mmap(0, MEM_SIZE, PROT_READ | PROT_WRITE,
|
||||
MAP_FILE | MAP_SHARED, fd, csps[i]);
|
||||
if (*cspbases[i] == MAP_FAILED) {
|
||||
LOG(logERROR, ("Can't map memmory area for %s\n", names[i]));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
LOG(logINFO, ("%s mapped from %p to %p,(CSP:0x%x) \n", names[i],
|
||||
*cspbases[i], *cspbases[i] + MEM_SIZE, csps[i]));
|
||||
// LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG)));
|
||||
} else
|
||||
LOG(logINFO, ("Memory %s already mapped before\n", names[i]));
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
u_int32_t *Arm_getUDPBaseAddress() { return csp1base; }
|
@ -15,6 +15,11 @@ u_int32_t *csp0base = 0;
|
||||
#define CSP0 0x20200000
|
||||
#define MEM_SIZE 0x100000
|
||||
|
||||
#ifdef JUNGFRAUD
|
||||
|
||||
extern void configureChip();
|
||||
#endif
|
||||
|
||||
void bus_w16(u_int32_t offset, u_int16_t data) {
|
||||
volatile u_int16_t *ptr1;
|
||||
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) {
|
||||
// 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);
|
||||
#ifdef JUNGFRAUD
|
||||
if (electronCollectionModeChange) {
|
||||
configureChip();
|
||||
}
|
||||
#endif
|
||||
return readRegister(offset);
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,11 @@ int getTimeFromString(char *buf, time_t *result) {
|
||||
t.tm_mday, t.tm_mon, t.tm_year + 1900, t.tm_hour, t.tm_min, t.tm_sec));
|
||||
|
||||
*result = mktime(&t);
|
||||
/* Do not check as it fails with nios
|
||||
if (*result == (time_t)-1) {
|
||||
LOG(logERROR, ("Could not convert time structure to time_t\n"));
|
||||
return FAIL;
|
||||
}*/
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -143,14 +148,25 @@ int validateKernelVersion(char *expectedVersion) {
|
||||
#ifdef VIRTUAL
|
||||
strcpy(currentVersion, expectedVersion);
|
||||
#else
|
||||
#ifndef ARMPROCESSOR
|
||||
// remove first word (#version number)
|
||||
const char *ptr = strchr(version, ' ');
|
||||
const char *ptr = strstr(version, " ");
|
||||
if (ptr == NULL) {
|
||||
LOG(logERROR, ("Could not parse kernel version\n"));
|
||||
return FAIL;
|
||||
}
|
||||
strcpy(currentVersion, version + (ptr - version + 1));
|
||||
strcpy(currentVersion, ptr + 1);
|
||||
#else
|
||||
// remove first two words (#version number and SMP)
|
||||
const char *ptr = strstr(version, "SMP ");
|
||||
if (ptr == NULL) {
|
||||
LOG(logERROR, ("Could not parse kernel version\n"));
|
||||
return FAIL;
|
||||
}
|
||||
strcpy(currentVersion, ptr + 4);
|
||||
#endif
|
||||
#endif
|
||||
currentVersion[sizeof(currentVersion) - 1] = '\0';
|
||||
|
||||
// convert kernel date string into time
|
||||
time_t kernelDate;
|
||||
@ -159,6 +175,7 @@ int validateKernelVersion(char *expectedVersion) {
|
||||
("Could not parse retrieved kernel date, %s\n", currentVersion));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logDEBUG, ("Kernel Date: [%s]\n", ctime(&kernelDate)));
|
||||
|
||||
// convert expected date into time
|
||||
time_t expDate;
|
||||
@ -167,11 +184,12 @@ int validateKernelVersion(char *expectedVersion) {
|
||||
("Could not parse expected kernel date, %s\n", expectedVersion));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logDEBUG, ("Expected Date: [%s]\n", ctime(&expDate)));
|
||||
|
||||
// compare if kernel time is older than expected time
|
||||
if (kernelDate < expDate) {
|
||||
LOG(logERROR, ("Kernel Version Incompatible (too old)! Expected: [%s], "
|
||||
"Got [%s]\n",
|
||||
LOG(logERROR, ("Kernel Version Incompatible (too old)!\nExpected: '%s'"
|
||||
"\nGot : '%s'\n",
|
||||
expectedVersion, currentVersion));
|
||||
return FAIL;
|
||||
}
|
||||
@ -734,13 +752,17 @@ int readADCFromFile(char *fname, int *value) {
|
||||
|
||||
*value = -1;
|
||||
if (sscanf(line, "%d", value) != 1) {
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
LOG(logERROR, ("Could not scan adc from %s\n", line));
|
||||
#else
|
||||
LOG(logERROR, ("Could not scan temperature from %s\n", line));
|
||||
#endif
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
#ifdef EIGERD
|
||||
*value /= 10;
|
||||
#else
|
||||
#elif !defined(XILINX_CHIPTESTBOARDD)
|
||||
LOG(logINFO, ("Temperature: %.2f °C\n", (double)(*value) / 1000.00));
|
||||
#endif
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
extern enum TLogLevel trimmingPrint;
|
||||
#endif
|
||||
|
||||
#ifdef CHIPTESTBOARDD
|
||||
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||
#ifdef VIRTUAL
|
||||
uint64_t virtual_pattern[MAX_PATTERN_LENGTH];
|
||||
#endif
|
||||
@ -21,8 +21,8 @@ uint64_t virtual_pattern[MAX_PATTERN_LENGTH];
|
||||
|
||||
extern void bus_w(u_int32_t offset, u_int32_t data);
|
||||
extern u_int32_t bus_r(u_int32_t offset);
|
||||
extern int64_t get64BitReg(int aLSB, int aMSB);
|
||||
extern int64_t set64BitReg(int64_t value, int aLSB, int aMSB);
|
||||
// extern int64_t get64BitReg(int aLSB, int aMSB); TODO for all servers (only
|
||||
// uint64_t) extern int64_t set64BitReg(int64_t value, int aLSB, int aMSB);
|
||||
extern uint64_t getU64BitReg(int aLSB, int aMSB);
|
||||
extern void setU64BitReg(uint64_t value, int aLSB, int aMSB);
|
||||
|
||||
@ -44,18 +44,34 @@ void initializePatternAddresses() {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CHIPTESTBOARDD
|
||||
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||
#ifdef VIRTUAL
|
||||
void initializePatternWord() {
|
||||
memset(virtual_pattern, 0, sizeof(virtual_pattern));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||
uint64_t validate_readPatternIOControl() {
|
||||
#if defined(CHIPTESTBOARDD)
|
||||
return getU64BitReg(PATTERN_IO_CNTRL_LSB_REG, PATTERN_IO_CNTRL_MSB_REG);
|
||||
#elif defined(XILINX_CHIPTESTBOARDD)
|
||||
return (uint64_t)(bus_r(PINIOCTRLREG));
|
||||
#endif
|
||||
}
|
||||
|
||||
int validate_writePatternIOControl(char *message, uint64_t arg) {
|
||||
// validate input
|
||||
#ifdef XILINX_CHIPTESTBOARDD
|
||||
if (arg > BIT32_MSK) {
|
||||
strcpy(message, "Could not set pattern IO Control. Must be 32 bit for "
|
||||
"this detector\n");
|
||||
LOG(logERROR, (message));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
|
||||
writePatternIOControl(arg);
|
||||
|
||||
// validate result
|
||||
@ -75,9 +91,15 @@ int validate_writePatternIOControl(char *message, uint64_t arg) {
|
||||
}
|
||||
|
||||
void writePatternIOControl(uint64_t word) {
|
||||
#ifdef CHIPTESTBOARDD
|
||||
LOG(logINFO,
|
||||
("Setting Pattern I/O Control: 0x%llx\n", (long long int)word));
|
||||
setU64BitReg(word, PATTERN_IO_CNTRL_LSB_REG, PATTERN_IO_CNTRL_MSB_REG);
|
||||
#elif defined(XILINX_CHIPTESTBOARDD)
|
||||
uint32_t val = (uint32_t)word;
|
||||
LOG(logINFO, ("Setting Pattern I/O Control: 0x%x\n", val));
|
||||
bus_w(PINIOCTRLREG, val);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -101,7 +123,7 @@ uint64_t readPatternWord(int addr) {
|
||||
// the first word in RAM as base plus the offset of the word to write (addr)
|
||||
uint32_t reg_lsb = PATTERN_STEP0_LSB_REG + addr * REG_OFFSET * 2;
|
||||
uint32_t reg_msb = PATTERN_STEP0_MSB_REG + addr * REG_OFFSET * 2;
|
||||
return get64BitReg(reg_lsb, reg_msb);
|
||||
return getU64BitReg(reg_lsb, reg_msb);
|
||||
#else
|
||||
LOG(logDEBUG1, (" Reading (Executing) Pattern Word (addr:0x%x)\n", addr));
|
||||
uint32_t reg = PATTERN_CNTRL_REG;
|
||||
@ -118,7 +140,7 @@ uint64_t readPatternWord(int addr) {
|
||||
|
||||
// read value
|
||||
#ifndef VIRTUAL
|
||||
return get64BitReg(PATTERN_OUT_LSB_REG, PATTERN_OUT_MSB_REG);
|
||||
return getU64BitReg(PATTERN_OUT_LSB_REG, PATTERN_OUT_MSB_REG);
|
||||
#else
|
||||
return virtual_pattern[addr];
|
||||
#endif
|
||||
@ -160,7 +182,7 @@ void writePatternWord(int addr, uint64_t word) {
|
||||
uint32_t reg = PATTERN_CNTRL_REG;
|
||||
|
||||
// write word
|
||||
set64BitReg(word, PATTERN_IN_LSB_REG, PATTERN_IN_MSB_REG);
|
||||
setU64BitReg(word, PATTERN_IN_LSB_REG, PATTERN_IN_MSB_REG);
|
||||
|
||||
// overwrite with only addr
|
||||
bus_w(reg, ((addr << PATTERN_CNTRL_ADDR_OFST) & PATTERN_CNTRL_ADDR_MSK));
|
||||
@ -178,7 +200,7 @@ void writePatternWord(int addr, uint64_t word) {
|
||||
// the first word in RAM as base plus the offset of the word to write (addr)
|
||||
uint32_t reg_lsb = PATTERN_STEP0_LSB_REG + addr * REG_OFFSET * 2;
|
||||
uint32_t reg_msb = PATTERN_STEP0_MSB_REG + addr * REG_OFFSET * 2;
|
||||
set64BitReg(word, reg_lsb, reg_msb);
|
||||
setU64BitReg(word, reg_lsb, reg_msb);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -311,24 +333,24 @@ int validate_getPatternWaitTime(char *message, int level, uint64_t *waittime) {
|
||||
uint64_t getPatternWaitTime(int level) {
|
||||
switch (level) {
|
||||
case 0:
|
||||
return get64BitReg(PATTERN_WAIT_TIMER_0_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_0_MSB_REG);
|
||||
return getU64BitReg(PATTERN_WAIT_TIMER_0_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_0_MSB_REG);
|
||||
case 1:
|
||||
return get64BitReg(PATTERN_WAIT_TIMER_1_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_1_MSB_REG);
|
||||
return getU64BitReg(PATTERN_WAIT_TIMER_1_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_1_MSB_REG);
|
||||
case 2:
|
||||
return get64BitReg(PATTERN_WAIT_TIMER_2_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_2_MSB_REG);
|
||||
return getU64BitReg(PATTERN_WAIT_TIMER_2_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_2_MSB_REG);
|
||||
#ifndef MYTHEN3D
|
||||
case 3:
|
||||
return get64BitReg(PATTERN_WAIT_TIMER_3_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_3_MSB_REG);
|
||||
return getU64BitReg(PATTERN_WAIT_TIMER_3_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_3_MSB_REG);
|
||||
case 4:
|
||||
return get64BitReg(PATTERN_WAIT_TIMER_4_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_4_MSB_REG);
|
||||
return getU64BitReg(PATTERN_WAIT_TIMER_4_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_4_MSB_REG);
|
||||
case 5:
|
||||
return get64BitReg(PATTERN_WAIT_TIMER_5_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_5_MSB_REG);
|
||||
return getU64BitReg(PATTERN_WAIT_TIMER_5_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_5_MSB_REG);
|
||||
#endif
|
||||
default:
|
||||
return -1;
|
||||
@ -369,29 +391,29 @@ void setPatternWaitTime(int level, uint64_t t) {
|
||||
(long long int)t));
|
||||
switch (level) {
|
||||
case 0:
|
||||
set64BitReg(t, PATTERN_WAIT_TIMER_0_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_0_MSB_REG);
|
||||
setU64BitReg(t, PATTERN_WAIT_TIMER_0_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_0_MSB_REG);
|
||||
break;
|
||||
case 1:
|
||||
set64BitReg(t, PATTERN_WAIT_TIMER_1_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_1_MSB_REG);
|
||||
setU64BitReg(t, PATTERN_WAIT_TIMER_1_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_1_MSB_REG);
|
||||
break;
|
||||
case 2:
|
||||
set64BitReg(t, PATTERN_WAIT_TIMER_2_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_2_MSB_REG);
|
||||
setU64BitReg(t, PATTERN_WAIT_TIMER_2_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_2_MSB_REG);
|
||||
break;
|
||||
#ifndef MYTHEN3D
|
||||
case 3:
|
||||
set64BitReg(t, PATTERN_WAIT_TIMER_3_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_3_MSB_REG);
|
||||
setU64BitReg(t, PATTERN_WAIT_TIMER_3_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_3_MSB_REG);
|
||||
break;
|
||||
case 4:
|
||||
set64BitReg(t, PATTERN_WAIT_TIMER_4_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_4_MSB_REG);
|
||||
setU64BitReg(t, PATTERN_WAIT_TIMER_4_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_4_MSB_REG);
|
||||
break;
|
||||
case 5:
|
||||
set64BitReg(t, PATTERN_WAIT_TIMER_5_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_5_MSB_REG);
|
||||
setU64BitReg(t, PATTERN_WAIT_TIMER_5_LSB_REG,
|
||||
PATTERN_WAIT_TIMER_5_MSB_REG);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
@ -775,7 +797,7 @@ int loadPattern(char *message, enum TLogLevel printLevel,
|
||||
}
|
||||
}
|
||||
// iocontrol
|
||||
#ifndef MYTHEN3D
|
||||
#if !defined(MYTHEN3D) && !defined(XILINX_CHIPTESTBOARDD) // TODO
|
||||
if (ret == OK) {
|
||||
ret = validate_writePatternIOControl(message, pat->ioctrl);
|
||||
}
|
||||
@ -835,7 +857,7 @@ int getPattern(char *message, patternParameters *pat) {
|
||||
pat->word[i] = retval64;
|
||||
}
|
||||
// iocontrol
|
||||
#ifndef MYTHEN3D
|
||||
#if !defined(MYTHEN3D) && !defined(XILINX_CHIPTESTBOARDD) // TODO
|
||||
if (ret == OK) {
|
||||
validate_readPatternIOControl();
|
||||
}
|
||||
@ -956,7 +978,7 @@ int loadPatternFile(char *patFname, char *errMessage) {
|
||||
uint64_t word = 0;
|
||||
|
||||
// cannot scan values
|
||||
#ifdef VIRTUAL
|
||||
#if defined(VIRTUAL) || defined(XILINX_CHIPTESTBOARDD)
|
||||
if (sscanf(line, "%s 0x%x 0x%lx", command, &addr, &word) != 3) {
|
||||
#else
|
||||
if (sscanf(line, "%s 0x%x 0x%llx", command, &addr, &word) != 3) {
|
||||
@ -971,7 +993,7 @@ int loadPatternFile(char *patFname, char *errMessage) {
|
||||
}
|
||||
|
||||
// patioctrl
|
||||
#ifndef MYTHEN3D
|
||||
#if !defined(MYTHEN3D) && !defined(XILINX_CHIPTESTBOARDD) // TODO
|
||||
if (!strncmp(line, "patioctrl", strlen("patioctrl"))) {
|
||||
uint64_t arg = 0;
|
||||
|
||||
@ -1063,7 +1085,7 @@ int loadPatternFile(char *patFname, char *errMessage) {
|
||||
uint64_t waittime = 0;
|
||||
|
||||
// cannot scan values
|
||||
#ifdef VIRTUAL
|
||||
#if defined(VIRTUAL) || defined(XILINX_CHIPTESTBOARDD)
|
||||
if (sscanf(line, "%s %d %ld", command, &level, &waittime) != 3) {
|
||||
#else
|
||||
if (sscanf(line, "%s %d %lld", command, &level, &waittime) != 3) {
|
||||
|
196
slsDetectorServers/slsDetectorServer/src/programViaArm.c
Normal file
196
slsDetectorServers/slsDetectorServer/src/programViaArm.c
Normal file
@ -0,0 +1,196 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include "programViaArm.h"
|
||||
#include "clogger.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
#include <string.h> //memset
|
||||
#include <unistd.h> // access
|
||||
|
||||
#define CMD_ARM_LOAD_BIT_FILE \
|
||||
"~/fpgautil/fpgautil -b /root/apps/xilinx-ctb/XilinxCTB.bit -f Full"
|
||||
#define CMD_ARM_DEVICE_TREE_API_FOLDER \
|
||||
"/sys/kernel/config/device-tree/overlays/spidr"
|
||||
#define CMD_ARM_DEVICE_TREE_OVERLAY_FILE "/root/apps/xilinx-ctb/pl.dtbo"
|
||||
#define CMD_ARM_LOAD_DEVICE_TREE_FORMAT "cat %s > %s/dtbo"
|
||||
#define CMD_ARM_DEVICE_TREE_DST "/sys/bus/iio/devices/iio:device"
|
||||
#define CMD_ARM_DEVICE_NAME "xilinx-ams", "ad7689", "dac@0", "dac@1", "dac@2"
|
||||
#define TIME_LOAD_DEVICE_TREE_MS (500)
|
||||
|
||||
extern int executeCommand(char *command, char *result, enum TLogLevel level);
|
||||
|
||||
int resetFPGA(char *mess) {
|
||||
LOG(logINFOBLUE, ("Reseting FPGA...\n"));
|
||||
#ifndef VIRTUAL
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
if (executeCommand(CMD_ARM_LOAD_BIT_FILE, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not reset fpga. Command to load bit file failed (%s)\n",
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
LOG(logINFOBLUE, ("FPGA reset successfully\n"))
|
||||
return OK;
|
||||
}
|
||||
|
||||
int loadDeviceTree(char *mess, int *adcDeviceIndex, int *dacDeviceIndex) {
|
||||
if (verifyDeviceTree(mess, adcDeviceIndex, dacDeviceIndex) == OK)
|
||||
return OK;
|
||||
|
||||
if (checksBeforeCreatingDeviceTree(mess) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
if (createDeviceTree(mess) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
if (verifyDeviceTree(mess, adcDeviceIndex, dacDeviceIndex) == FAIL) {
|
||||
LOG(logERROR, ("Device tree loading failed at verification\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
LOG(logINFOBLUE, ("Device tree loaded successfully\n"))
|
||||
return OK;
|
||||
}
|
||||
|
||||
int checksBeforeCreatingDeviceTree(char *mess) {
|
||||
// check if device tree overlay file exists
|
||||
if (access(CMD_ARM_DEVICE_TREE_OVERLAY_FILE, F_OK) != 0) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Device tree overlay file (%s) does not exist\n",
|
||||
CMD_ARM_DEVICE_TREE_OVERLAY_FILE);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tDevice tree overlay file exists (%s)\n",
|
||||
CMD_ARM_DEVICE_TREE_OVERLAY_FILE));
|
||||
|
||||
// check if device tree folder exists. If it does, remove it
|
||||
if (access(CMD_ARM_DEVICE_TREE_API_FOLDER, F_OK) == 0) {
|
||||
// remove it
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
memset(cmd, 0, MAX_STR_LENGTH);
|
||||
sprintf(cmd, "rmdir %s", CMD_ARM_DEVICE_TREE_API_FOLDER);
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
memset(retvals, 0, MAX_STR_LENGTH);
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not unload device tree overlay api with %s (%s)\n",
|
||||
cmd, retvals);
|
||||
LOG(logWARNING, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tUnloaded existing device tree overlay api (%s)\n",
|
||||
CMD_ARM_DEVICE_TREE_API_FOLDER));
|
||||
} else {
|
||||
LOG(logINFO, ("\tNo existing device tree overlay api found(%s)\n",
|
||||
CMD_ARM_DEVICE_TREE_API_FOLDER));
|
||||
}
|
||||
|
||||
// create device tree overlay folder
|
||||
{
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
memset(cmd, 0, MAX_STR_LENGTH);
|
||||
sprintf(cmd, "mkdir %s", CMD_ARM_DEVICE_TREE_API_FOLDER);
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
memset(retvals, 0, MAX_STR_LENGTH);
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not create device tree overlay api with %s (%s)\n",
|
||||
cmd, retvals);
|
||||
LOG(logWARNING, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tDevice tree overlay api created (%s)\n",
|
||||
CMD_ARM_DEVICE_TREE_API_FOLDER));
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int createDeviceTree(char *mess) {
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
memset(cmd, 0, MAX_STR_LENGTH);
|
||||
sprintf(cmd, CMD_ARM_LOAD_DEVICE_TREE_FORMAT,
|
||||
CMD_ARM_DEVICE_TREE_OVERLAY_FILE, CMD_ARM_DEVICE_TREE_API_FOLDER);
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
memset(retvals, 0, MAX_STR_LENGTH);
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not load device tree overlay with %s (%s)\n", cmd,
|
||||
retvals);
|
||||
LOG(logWARNING, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tDevice tree overlay created (cmd: %s)\n", cmd));
|
||||
|
||||
usleep(TIME_LOAD_DEVICE_TREE_MS * 1000);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int verifyDeviceTree(char *mess, int *adcDeviceIndex, int *dacDeviceIndex) {
|
||||
LOG(logINFOBLUE, ("Verifying Device Tree...\n"));
|
||||
*adcDeviceIndex = 1;
|
||||
*dacDeviceIndex = 2;
|
||||
#ifndef VIRTUAL
|
||||
|
||||
// check if iio:device0-4 exists in device tree destination
|
||||
int hardcodedDeviceIndex = 0;
|
||||
for (int i = 0; i != 5; ++i) {
|
||||
char deviceName[MAX_STR_LENGTH] = {0};
|
||||
memset(deviceName, 0, MAX_STR_LENGTH);
|
||||
sprintf(deviceName, "%s%d/name", CMD_ARM_DEVICE_TREE_DST, i);
|
||||
// check if device exist
|
||||
if (access(deviceName, F_OK) != 0) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not verify device tree. Device %s does not exist\n",
|
||||
deviceName);
|
||||
LOG(logWARNING, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
// find name
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
memset(cmd, 0, MAX_STR_LENGTH);
|
||||
sprintf(cmd, "cat %s", deviceName);
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
memset(retvals, 0, MAX_STR_LENGTH);
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not retrieve device name from device %s (%s)\n",
|
||||
deviceName, retvals);
|
||||
LOG(logWARNING, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
// verify name
|
||||
char *deviceNames[] = {CMD_ARM_DEVICE_NAME};
|
||||
if (strstr(retvals, deviceNames[hardcodedDeviceIndex]) == NULL) {
|
||||
// dacs got loaded first
|
||||
if (i == 1 &&
|
||||
strstr(retvals, deviceNames[hardcodedDeviceIndex + 1]) !=
|
||||
NULL) {
|
||||
++hardcodedDeviceIndex;
|
||||
*adcDeviceIndex = 4;
|
||||
*dacDeviceIndex = 1;
|
||||
} else {
|
||||
snprintf(
|
||||
mess, MAX_STR_LENGTH,
|
||||
"Could not verify device tree. Device %s expected %s but "
|
||||
"got %s\n",
|
||||
deviceName, deviceNames[i], retvals);
|
||||
LOG(logWARNING, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
++hardcodedDeviceIndex;
|
||||
// in case dacs were loaded first
|
||||
if (hardcodedDeviceIndex == 5)
|
||||
hardcodedDeviceIndex = 1;
|
||||
}
|
||||
#endif
|
||||
LOG(logINFOBLUE, ("Device tree verified successfully [temp: 0, adc:%d, "
|
||||
"dac:%d, %d, %d]\n",
|
||||
*adcDeviceIndex, *dacDeviceIndex, *dacDeviceIndex + 1,
|
||||
*dacDeviceIndex + 2));
|
||||
return OK;
|
||||
}
|
@ -79,7 +79,7 @@ int main(int argc, char *argv[]) {
|
||||
"\t-v, --version : Software version\n"
|
||||
"\t-p, --port <port> : TCP communication port with client. "
|
||||
"\n"
|
||||
"\t-g, --nomodule : [Mythen3][Gotthard2] \n"
|
||||
"\t-g, --nomodule : [Mythen3][Gotthard2][Xilinx Ctb] \n"
|
||||
"\t Generic or No Module mode. Skips "
|
||||
"detector type checks. \n"
|
||||
"\t-f, --phaseshift <value> : [Gotthard] only. Sets phase shift. \n"
|
||||
|
File diff suppressed because it is too large
Load Diff
42
slsDetectorServers/xilinx_ctbDetectorServer/CMakeLists.txt
Normal file
42
slsDetectorServers/xilinx_ctbDetectorServer/CMakeLists.txt
Normal file
@ -0,0 +1,42 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
add_executable(xilinx_ctbDetectorServer_virtual
|
||||
slsDetectorFunctionList.c
|
||||
../slsDetectorServer/src/slsDetectorServer.c
|
||||
../slsDetectorServer/src/slsDetectorServer_funcs.c
|
||||
../slsDetectorServer/src/communication_funcs.c
|
||||
../slsDetectorServer/src/arm64.c
|
||||
../slsDetectorServer/src/common.c
|
||||
../slsDetectorServer/src/sharedMemory.c
|
||||
../slsDetectorServer/src/loadPattern.c
|
||||
../slsDetectorServer/src/programViaArm.c
|
||||
../slsDetectorServer/src/communication_funcs_UDP.c
|
||||
../../slsSupportLib/src/md5.c
|
||||
../slsDetectorServer/src/LTC2620_Driver.c
|
||||
)
|
||||
|
||||
include_directories(
|
||||
../slsDetectorServer/include
|
||||
../../slsSupportLib/include
|
||||
../../slsDetectorSoftware/include/sls/
|
||||
)
|
||||
|
||||
target_include_directories(xilinx_ctbDetectorServer_virtual
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_compile_definitions(xilinx_ctbDetectorServer_virtual
|
||||
PUBLIC XILINX_CHIPTESTBOARDD ARMPROCESSOR VIRTUAL STOP_SERVER
|
||||
)
|
||||
|
||||
target_link_libraries(xilinx_ctbDetectorServer_virtual
|
||||
PUBLIC pthread rt m slsProjectCSettings
|
||||
)
|
||||
|
||||
set_target_properties(xilinx_ctbDetectorServer_virtual PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
install(TARGETS xilinx_ctbDetectorServer_virtual
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
47
slsDetectorServers/xilinx_ctbDetectorServer/Makefile
Executable file
47
slsDetectorServers/xilinx_ctbDetectorServer/Makefile
Executable file
@ -0,0 +1,47 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
current_dir = $(shell pwd)
|
||||
main_inc = ../slsDetectorServer/include/
|
||||
main_src = ../slsDetectorServer/src/
|
||||
support_lib = ../../slsSupportLib/include/
|
||||
det_lib = ../../slsDetectorSoftware/include/sls/
|
||||
md5_dir = ../../slsSupportLib/src/
|
||||
|
||||
CROSS = aarch64-none-linux-gnu-
|
||||
CC = $(CROSS)gcc
|
||||
#TODO: allow these warnings and fix code
|
||||
CFLAGS += -Wall -std=gnu99 -Wno-format-overflow -Wno-format-truncation -DXILINX_CHIPTESTBOARDD -DARMPROCESSOR -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(det_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
||||
#CFLAGS += -Wall -std=gnu99 -DXILINX_CHIPTESTBOARDD -DARMPROCESSOR -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(det_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm -lrt -pthread
|
||||
PROGS = xilinx_ctbDetectorServer
|
||||
DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRCS = slsDetectorFunctionList.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)arm64.c $(main_src)common.c $(main_src)/sharedMemory.c $(main_src)/loadPattern.c $(md5_dir)md5.c $(main_src)programViaArm.c $(main_src)LTC2620_Driver.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
all: clean $(PROGS)
|
||||
version: clean versioning $(PROGS)
|
||||
|
||||
boot: $(OBJS)
|
||||
|
||||
version_branch=$(API_BRANCH)
|
||||
version_name=APIXILINXCTB
|
||||
version_path=slsDetectorServers/xilinx_ctbDetectorServer
|
||||
versioning:
|
||||
cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;`
|
||||
|
||||
|
||||
$(PROGS): $(OBJS)
|
||||
# echo $(OBJS)
|
||||
mkdir -p $(DESTDIR)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
|
||||
mv $(PROGS) $(DESTDIR)
|
||||
rm $(main_src)*.o $(md5_dir)*.o
|
||||
clean:
|
||||
rm -rf $(DESTDIR)/$(PROGS) *.o *.gdb $(main_src)*.o $(md5_dir)*.o
|
||||
|
||||
|
||||
|
1020
slsDetectorServers/xilinx_ctbDetectorServer/RegisterDefs.h
Normal file
1020
slsDetectorServers/xilinx_ctbDetectorServer/RegisterDefs.h
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,145 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
#include "RegisterDefs.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
#define REQRD_FRMWRE_VRSN (0x230710)
|
||||
#define KERNEL_DATE_VRSN "Wed Nov 29 17:32:14 CET 2023"
|
||||
|
||||
#define LINKED_SERVER_NAME "xilinx_ctbDetectorServer"
|
||||
|
||||
#define CTRL_SRVR_INIT_TIME_US (2 * 1000 * 1000)
|
||||
|
||||
/* Hardware Definitions */
|
||||
#define NCHAN (40)
|
||||
#define NCHAN_ANALOG (32)
|
||||
#define NCHAN_DIGITAL (64)
|
||||
#define NCHAN_TRANSCEIVER (4)
|
||||
#define NBITS_PER_TRANSCEIVER (64)
|
||||
#define NCHIP (1)
|
||||
#define NDAC (24)
|
||||
#define NPWR (6)
|
||||
#define NDAC_ONLY (NDAC - NPWR)
|
||||
|
||||
#define DYNAMIC_RANGE (16)
|
||||
#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
|
||||
|
||||
#define DAC_DRIVER_NUM_DEVICES (3)
|
||||
#define DAC_DRIVER_FILE_NAME \
|
||||
("/sys/bus/iio/devices/iio:device%d/out_voltage%d_raw")
|
||||
#define DAC_POWERDOWN_DRIVER_FILE_NAME \
|
||||
("/sys/bus/iio/devices/iio:device%d/out_voltage%d_powerdown")
|
||||
|
||||
#define SLOWADC_DRIVER_FILE_NAME \
|
||||
("/sys/bus/iio/devices/iio:device%d/in_voltage%d_raw")
|
||||
//#define SLOWDAC_CONVERTION_FACTOR_TO_UV (62.500953)
|
||||
|
||||
#define TEMP_DRIVER_FILE_NAME \
|
||||
("/sys/bus/iio/devices/iio:device0/in_temp7_input")
|
||||
|
||||
/** Default Parameters */
|
||||
#define DEFAULT_NUM_FRAMES (1)
|
||||
#define DEFAULT_NUM_CYCLES (1)
|
||||
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
|
||||
#define DEFAULT_EXPTIME (0)
|
||||
#define DEFAULT_PERIOD (300 * 1000) // 300us
|
||||
#define DEFAULT_READOUT_MODE (TRANSCEIVER_ONLY)
|
||||
#define DEFAULT_READOUT_MODE_STR "transceiver_only"
|
||||
#define DEFAULT_TRANSCEIVER_MASK (0x3) // TODO: check
|
||||
#define DEFAULT_NUM_ASAMPLES (1)
|
||||
#define DEFAULT_NUM_DSAMPLES (1)
|
||||
#define DEFAULT_NUM_TSAMPLES (200)
|
||||
#define DEFAULT_STARTING_FRAME_NUMBER (1)
|
||||
#define DEFAULT_VLIMIT (-100)
|
||||
#define DEFAULT_DELAY (0)
|
||||
|
||||
#define MAX_TRANSCEIVER_MASK (0xF)
|
||||
#define MAX_TRANSCEIVER_SAMPLES (0x1FFF)
|
||||
|
||||
#define MAX_ANALOG_SAMPLES (0x3FFF)
|
||||
#define MAX_DIGITAL_SAMPLES (0x3FFF)
|
||||
|
||||
#define DAC_MIN_MV (0)
|
||||
#define DAC_MAX_MV (2500)
|
||||
|
||||
#define TICK_CLK (20) // MHz (trig_timeFromStart, frametime, timeFromStart)
|
||||
#define RUN_CLK \
|
||||
(100) // MHz (framesFromStart, c_swTrigger, run, waitForTrigger, starting,
|
||||
// acquiring, waitForPeriod, internalStop, c_framesFromSTart_reset,
|
||||
// s_start, c_stop, triggerEnable, period, frames, cycles, delay)
|
||||
|
||||
/* Defines in the Firmware */
|
||||
#define WAIT_TIME_PATTERN_READ (10)
|
||||
#define WAIT_TIME_OUT_0US_TIMES (35000) // 2s
|
||||
|
||||
#define BIT32_MSK (0xFFFFFFFF)
|
||||
#define BIT16_MASK (0xFFFF)
|
||||
|
||||
#define MAX_DATA_SIZE_IN_PACKET (8144)
|
||||
|
||||
/* Enum Definitions */
|
||||
enum ADCINDEX {
|
||||
S_ADC0,
|
||||
S_ADC1,
|
||||
S_ADC2,
|
||||
S_ADC3,
|
||||
S_ADC4,
|
||||
S_ADC5,
|
||||
S_ADC6,
|
||||
S_ADC7,
|
||||
TEMP_FPGA
|
||||
};
|
||||
enum DACINDEX {
|
||||
D0,
|
||||
D1,
|
||||
D2,
|
||||
D3,
|
||||
D4,
|
||||
D5,
|
||||
D6,
|
||||
D7,
|
||||
D8,
|
||||
D9,
|
||||
D10,
|
||||
D11,
|
||||
D12,
|
||||
D13,
|
||||
D14,
|
||||
D15,
|
||||
D16,
|
||||
D17,
|
||||
D_PWR_D,
|
||||
D_PWR_EMPTY,
|
||||
D_PWR_IO,
|
||||
D_PWR_A,
|
||||
D_PWR_B,
|
||||
D_PWR_C
|
||||
};
|
||||
|
||||
/* Struct Definitions */
|
||||
typedef struct udp_header_struct {
|
||||
uint32_t udp_destmac_msb;
|
||||
uint16_t udp_srcmac_msb;
|
||||
uint16_t udp_destmac_lsb;
|
||||
uint32_t udp_srcmac_lsb;
|
||||
uint8_t ip_tos;
|
||||
uint8_t ip_ihl : 4, ip_ver : 4;
|
||||
uint16_t udp_ethertype;
|
||||
uint16_t ip_identification;
|
||||
uint16_t ip_totallength;
|
||||
uint8_t ip_protocol;
|
||||
uint8_t ip_ttl;
|
||||
uint16_t ip_fragmentoffset : 13, ip_flags : 3;
|
||||
uint16_t ip_srcip_msb;
|
||||
uint16_t ip_checksum;
|
||||
uint16_t ip_destip_msb;
|
||||
uint16_t ip_srcip_lsb;
|
||||
uint16_t udp_srcport;
|
||||
uint16_t ip_destip_lsb;
|
||||
uint16_t udp_checksum;
|
||||
uint16_t udp_destport;
|
||||
} udp_header;
|
||||
|
||||
#define IP_HEADER_SIZE (20)
|
||||
#define UDP_IP_HEADER_LENGTH_BYTES (28)
|
@ -4,10 +4,13 @@ set(SOURCES
|
||||
src/DetectorImpl.cpp
|
||||
src/Module.cpp
|
||||
src/Detector.cpp
|
||||
src/CmdProxy.cpp
|
||||
src/HelpDacs.cpp
|
||||
src/CmdParser.cpp
|
||||
src/Pattern.cpp
|
||||
src/CtbConfig.cpp
|
||||
src/Caller.cpp
|
||||
src/CallerSpecial.cpp
|
||||
src/inferAction.cpp
|
||||
)
|
||||
|
||||
add_library(slsDetectorObject OBJECT
|
||||
@ -76,26 +79,30 @@ endif()
|
||||
|
||||
|
||||
if(SLS_USE_TEXTCLIENT)
|
||||
# Loop over list to generate command line binaries
|
||||
set(bin_names "sls_detector_put"
|
||||
set(det_bin_names "sls_detector_put"
|
||||
"sls_detector_get"
|
||||
"sls_detector_acquire"
|
||||
"sls_detector_help")
|
||||
set(cmd_name "PUT" "GET" "READOUT" "HELP")
|
||||
list(LENGTH bin_names len1)
|
||||
"sls_detector_help"
|
||||
"sls_detector"
|
||||
)
|
||||
set(det_cmd_name "PUT" "GET" "READOUT" "HELP" "INFER")
|
||||
list(LENGTH det_bin_names len1)
|
||||
math(EXPR len2 "${len1} - 1")
|
||||
|
||||
foreach(val RANGE ${len2})
|
||||
list(GET bin_names ${val} val1)
|
||||
list(GET cmd_name ${val} val2)
|
||||
list(GET det_bin_names ${val} val1)
|
||||
list(GET det_cmd_name ${val} val2)
|
||||
message(STATUS "${val1} ${val2}")
|
||||
|
||||
add_executable(${val1} src/CmdLineApp.cpp)
|
||||
add_executable(${val1} src/CmdApp.cpp)
|
||||
|
||||
target_link_libraries(${val1}
|
||||
slsDetectorStatic
|
||||
pthread
|
||||
rt
|
||||
slsDetectorStatic
|
||||
pthread
|
||||
rt
|
||||
)
|
||||
SET_SOURCE_FILES_PROPERTIES( src/Caller.cpp PROPERTIES COMPILE_FLAGS "-Wno-unused-variable -Wno-unused-but-set-variable")
|
||||
|
||||
set_target_properties(${val1} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
COMPILE_DEFINITIONS ${val2}=1
|
||||
@ -104,7 +111,8 @@ if(SLS_USE_TEXTCLIENT)
|
||||
set_property(TARGET ${val1} PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
endif()
|
||||
endforeach()
|
||||
install(TARGETS ${bin_names} DESTINATION bin)
|
||||
install(TARGETS ${det_bin_names} DESTINATION bin)
|
||||
|
||||
|
||||
endif(SLS_USE_TEXTCLIENT)
|
||||
|
||||
|
10
slsDetectorSoftware/generator/Caller.in.cpp
Normal file
10
slsDetectorSoftware/generator/Caller.in.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "Caller.h"
|
||||
#include "sls/logger.h"
|
||||
#include "sls/string_utils.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace sls {
|
||||
|
||||
// THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE
|
||||
|
||||
}
|
88
slsDetectorSoftware/generator/Caller.in.h
Normal file
88
slsDetectorSoftware/generator/Caller.in.h
Normal file
@ -0,0 +1,88 @@
|
||||
// This file is used as input to generate the caller class
|
||||
|
||||
#include "CmdParser.h"
|
||||
#include "HelpDacs.h"
|
||||
#include "sls/Detector.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
namespace sls {
|
||||
|
||||
class Caller {
|
||||
public:
|
||||
Caller(Detector *ptr) : det(ptr) {}
|
||||
void call(const std::string &command,
|
||||
const std::vector<std::string> &arguments, int detector_id,
|
||||
int action, std::ostream &os = std::cout, int receiver_id = -1);
|
||||
|
||||
IpAddr getDstIpFromAuto();
|
||||
IpAddr getSrcIpFromAuto();
|
||||
UdpDestination getUdpEntry();
|
||||
void GetLevelAndUpdateArgIndex(int action,
|
||||
std::string levelSeparatedCommand,
|
||||
int &level, int &iArg, size_t nGetArgs,
|
||||
size_t nPutArgs);
|
||||
void WrongNumberOfParameters(size_t expected);
|
||||
|
||||
template <typename V> std::string OutStringHex(const V &value) {
|
||||
if (value.equal())
|
||||
return ToStringHex(value.front());
|
||||
return ToStringHex(value);
|
||||
}
|
||||
|
||||
template <typename V> std::string OutStringHex(const V &value, int width) {
|
||||
if (value.equal())
|
||||
return ToStringHex(value.front(), width);
|
||||
return ToStringHex(value, width);
|
||||
}
|
||||
|
||||
template <typename V> std::string OutString(const Result<V> &value) {
|
||||
if (value.equal())
|
||||
return ToString(value.front());
|
||||
return ToString(value);
|
||||
}
|
||||
|
||||
template <typename V> std::string OutString(const V &value) {
|
||||
return ToString(value);
|
||||
}
|
||||
|
||||
template <typename V>
|
||||
std::string OutString(const V &value, const std::string &unit) {
|
||||
if (value.equal())
|
||||
return ToString(value.front(), unit);
|
||||
return ToString(value, unit);
|
||||
}
|
||||
|
||||
std::vector<std::string> getAllCommands();
|
||||
std::string list(int action);
|
||||
|
||||
// THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (1)
|
||||
|
||||
std::vector<std::string> args;
|
||||
std::string cmd;
|
||||
Detector *det;
|
||||
int det_id{-1};
|
||||
int rx_id{-1};
|
||||
|
||||
private:
|
||||
bool ReplaceIfDepreciated(std::string &command);
|
||||
using FunctionMap = std::map<std::string, std::string (Caller::*)(int)>;
|
||||
using StringMap = std::map<std::string, std::string>;
|
||||
Detector *ptr; // pointer to the detector that executes the command
|
||||
|
||||
FunctionMap functions{
|
||||
{"list", &Caller::list},
|
||||
|
||||
// THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (2)
|
||||
|
||||
};
|
||||
|
||||
StringMap depreciated_functions{
|
||||
|
||||
// THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (3)
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace sls
|
236
slsDetectorSoftware/generator/autocomplete/autocomplete.py
Normal file
236
slsDetectorSoftware/generator/autocomplete/autocomplete.py
Normal file
@ -0,0 +1,236 @@
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
# command to generate the ast
|
||||
# clang version: 14.0.0-1ubuntu1.1
|
||||
# clang++ -Xclang -ast-dump=json -Xclang -ast-dump-filter -Xclang StringTo -c ToString.cpp -I ../include/ -std=gnu++11
|
||||
#
|
||||
import yaml
|
||||
|
||||
AUTOCOMPLETE_PATH = Path(__file__).parent
|
||||
DUMP_PATH = AUTOCOMPLETE_PATH / 'dump.json'
|
||||
FIXED_PATH = AUTOCOMPLETE_PATH / 'fixed.json'
|
||||
|
||||
type_values = {
|
||||
'special::mv': ["mv", "mV"],
|
||||
"special::deg": ["deg"],
|
||||
"special::time_unit": ["s", "ms", "us", "ns"],
|
||||
"special::hard": ["hard"],
|
||||
"special::force-delete-normal-file": ["--force-delete-normal-file"],
|
||||
"special::currentSourceFix": ["fix", "nofix"],
|
||||
"special::currentSourceLow": ["normal", "low"],
|
||||
"special::path": [],
|
||||
"special::pedestal_parameters" : ["", "0"]
|
||||
|
||||
}
|
||||
|
||||
|
||||
def get_types(arg_types):
|
||||
ret = set()
|
||||
for arg_type in arg_types:
|
||||
if type_info(arg_type) == 'base':
|
||||
if arg_type == 'bool':
|
||||
ret = ret.union(["0", "1"])
|
||||
else:
|
||||
tmp = [not_list for not_list in type_values[arg_type] if not isinstance(not_list, list)]
|
||||
ret = ret.union(tmp)
|
||||
|
||||
#Intercept the options and in case detector specific options appear replace the
|
||||
#list of options with a command line call that fetches them
|
||||
#TODO! Rename sls_detector_get
|
||||
if "defs::dacIndex" in arg_types:
|
||||
return "`sls_detector_get daclist | sed -e 's/.*\[\(.*\)\].*/\\1/' | sed 's/,//g'`"
|
||||
elif "defs::detectorSettings" in arg_types:
|
||||
return "`sls_detector_get settingslist | sed -e 's/.*\[\(.*\)\].*/\\1/' | sed 's/,//g'`"
|
||||
elif "defs::timingMode" in arg_types:
|
||||
return "`sls_detector_get timinglist | sed -e 's/.*\[\(.*\)\].*/\\1/' | sed 's/,//g'`"
|
||||
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def type_info(type_name):
|
||||
if type_name.startswith('defs::') or type_name.startswith('slsDetectorDefs::'):
|
||||
return 'enum'
|
||||
if type_name.startswith('special::'):
|
||||
return 'special'
|
||||
return 'base'
|
||||
|
||||
|
||||
def get_enum(function):
|
||||
return function['type']['qualType'].split(' ')[0]
|
||||
|
||||
|
||||
def get_literal(ifstmt):
|
||||
stringliteral = []
|
||||
expression = ifstmt['inner'][0]
|
||||
if expression['kind'] == 'BinaryOperator':
|
||||
if expression['opcode'] == '!=':
|
||||
return None, None
|
||||
for cxxOperatorCall in expression['inner']:
|
||||
if cxxOperatorCall['kind'] == 'CXXOperatorCallExpr':
|
||||
implicitCastExpr = cxxOperatorCall['inner'][2]
|
||||
stringliteral.append(implicitCastExpr['inner'][0]['value'][1:-1])
|
||||
else:
|
||||
cxxOperatorCall = expression
|
||||
implicitCastExpr = cxxOperatorCall['inner'][2]
|
||||
stringliteral = implicitCastExpr['inner'][0]['value'][1:-1]
|
||||
|
||||
retstmt = get_object_by_kind(ifstmt['inner'], 'ReturnStmt')
|
||||
declrefexpt = get_object_by_kind(retstmt['inner'], 'DeclRefExpr')
|
||||
enum_val = declrefexpt["referencedDecl"]["name"]
|
||||
|
||||
return enum_val, stringliteral
|
||||
|
||||
|
||||
def get_object_by_kind(inner, kind, position=1):
|
||||
for obj in inner:
|
||||
if obj['kind'] == kind:
|
||||
position -= 1
|
||||
if position == 0:
|
||||
return obj
|
||||
return None
|
||||
|
||||
|
||||
def generate_type_values():
|
||||
functions = json.loads(FIXED_PATH.read_text())
|
||||
for function in functions:
|
||||
if function['kind'] != 'FunctionDecl' or function['name'] != 'StringTo':
|
||||
continue
|
||||
enum = get_enum(function)
|
||||
|
||||
if not enum.startswith('defs::'):
|
||||
continue
|
||||
# if enum != 'defs::dacIndex':
|
||||
# continue
|
||||
if not function['loc']['file'].endswith('ToString.cpp'):
|
||||
continue
|
||||
|
||||
compound_stmt = get_object_by_kind(function['inner'], 'CompoundStmt')
|
||||
|
||||
for ifstmt in compound_stmt['inner']:
|
||||
if ifstmt['kind'] != 'IfStmt':
|
||||
continue
|
||||
enum_val, stringliteral = get_literal(ifstmt)
|
||||
if enum_val is None:
|
||||
continue
|
||||
|
||||
if enum not in type_values or type_values[enum] is None:
|
||||
type_values[enum] = []
|
||||
type_values[enum].append(stringliteral)
|
||||
items = list(type_values.items())
|
||||
for key, val in items:
|
||||
if key.startswith('defs::'):
|
||||
new_key = key.split('::')[1]
|
||||
new_key = 'slsDetectorDefs::' + new_key
|
||||
type_values[new_key] = val
|
||||
elif key.startswith('slsDetectorDefs::'):
|
||||
new_key = key.split('::')[1]
|
||||
new_key = 'defs::' + new_key
|
||||
type_values[new_key] = val
|
||||
|
||||
return json.dumps(type_values, indent=2)
|
||||
|
||||
|
||||
def fix_json():
|
||||
with DUMP_PATH.open('r') as f:
|
||||
tmp = '[\n'
|
||||
for line in f.read().split('\n'):
|
||||
if line.startswith('}'):
|
||||
tmp += line + ',\n'
|
||||
else:
|
||||
tmp += line + '\n'
|
||||
tmp = tmp[:-3] + '\n]'
|
||||
with FIXED_PATH.open('w') as f:
|
||||
f.write(tmp)
|
||||
|
||||
|
||||
def generate_bash_autocomplete(output_path=Path(__file__).parent / 'bash_autocomplete.sh', input_path=Path(__file__).parent / 'bash_autocomplete.in.sh'):
|
||||
generate_type_values()
|
||||
output_file = output_path.open('w')
|
||||
template_file = input_path.open('r')
|
||||
|
||||
def writeline(line):
|
||||
output_file.write(line + '\n')
|
||||
|
||||
class if_block:
|
||||
def __init__(self, condition):
|
||||
self.condition = condition
|
||||
|
||||
def __enter__(self):
|
||||
output_file.write('if [[ ' + self.condition + ' ]]; then\n')
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
output_file.write('fi\n')
|
||||
|
||||
class function:
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
|
||||
def __enter__(self):
|
||||
output_file.write(self.name + '() {\n')
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
output_file.write('}\n')
|
||||
|
||||
command_path = Path(__file__).parent.parent / 'extended_commands.yaml'
|
||||
commands = yaml.unsafe_load(command_path.open('r'))
|
||||
|
||||
for line in template_file:
|
||||
if '-- THIS LINE WILL BE REPLACED WITH GENERATED CODE --' not in line:
|
||||
output_file.write(line)
|
||||
continue
|
||||
writeline(f'local SLS_COMMANDS=" {" ".join(commands.keys())} "')
|
||||
# generate functions
|
||||
for command_name, command in commands.items():
|
||||
# added for debugging
|
||||
if command_name == 'xxxexptime':
|
||||
continue
|
||||
with function('__' + command_name):
|
||||
writeline('FCN_RETURN=""')
|
||||
|
||||
actions = ['GET', 'PUT']
|
||||
for action in actions:
|
||||
if action in command['actions'] and 'args' in command['actions'][action]:
|
||||
args = command['actions'][action]['args']
|
||||
possible_argc = {}
|
||||
for arg in args:
|
||||
if arg['argc'] == 0:
|
||||
pass
|
||||
for i in range(arg['argc']):
|
||||
if i + 1 not in possible_argc:
|
||||
possible_argc[i + 1] = []
|
||||
possible_argc[i + 1].append(arg['arg_types'][i])
|
||||
if possible_argc:
|
||||
with if_block(f'${{IS_GET}} -eq {"1" if action == "GET" else "0"}'):
|
||||
for argc in possible_argc:
|
||||
with if_block(f'"${{cword}}" == "{argc + 1}"'):
|
||||
if "defs::detectorSettings" in possible_argc[argc]:
|
||||
print(argc, command_name, possible_argc[argc])
|
||||
choices = get_types(possible_argc[argc])
|
||||
|
||||
#check if we got choices back or a bash command
|
||||
if isinstance(choices, (list,set)):
|
||||
writeline(f'FCN_RETURN="{" ".join(sorted(choices))}"')
|
||||
else:
|
||||
writeline(f'FCN_RETURN="{choices}"')
|
||||
if 'special::path' in possible_argc[argc]:
|
||||
writeline('IS_PATH=1')
|
||||
|
||||
writeline('return 0')
|
||||
|
||||
|
||||
|
||||
output_file.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='use parsed c++ code to generate autocomplete snippets')
|
||||
parser.add_argument('-f', '--fix', action='store_true', help='fix the parsed ast to make it loadable')
|
||||
# parser.add_argument('-p', '--path', type=str, help='output path to the fixed ast', default='ast.json')
|
||||
args = parser.parse_known_args()
|
||||
if args[0].fix:
|
||||
fix_json()
|
||||
ret = generate_type_values()
|
||||
print(ret)
|
@ -0,0 +1,167 @@
|
||||
# GENERATED FILE - DO NOT EDIT
|
||||
# ANY CHANGES TO THIS FILE WILL BE OVERWRITTEN
|
||||
|
||||
_sd() {
|
||||
|
||||
# Taken from https://github.com/scop/bash-completion/blob/15b74b1050333f425877a7cbd99af2998b95c476/bash_completion#L770C12-L770C12
|
||||
# Reassemble command line words, excluding specified characters from the
|
||||
# list of word completion separators (COMP_WORDBREAKS).
|
||||
# @param $1 chars Characters out of $COMP_WORDBREAKS which should
|
||||
# NOT be considered word breaks. This is useful for things like scp where
|
||||
# we want to return host:path and not only path, so we would pass the
|
||||
# colon (:) as $1 here.
|
||||
# @param $2 words Name of variable to return words to
|
||||
# @param $3 cword Name of variable to return cword to
|
||||
#
|
||||
_comp__reassemble_words()
|
||||
{
|
||||
local exclude="" i j line ref
|
||||
# Exclude word separator characters?
|
||||
if [[ $1 ]]; then
|
||||
# Yes, exclude word separator characters;
|
||||
# Exclude only those characters, which were really included
|
||||
exclude="[${1//[^$COMP_WORDBREAKS]/}]"
|
||||
fi
|
||||
|
||||
# Default to cword unchanged
|
||||
printf -v "$3" %s "$COMP_CWORD"
|
||||
# Are characters excluded which were former included?
|
||||
if [[ $exclude ]]; then
|
||||
# Yes, list of word completion separators has shrunk;
|
||||
line=$COMP_LINE
|
||||
# Re-assemble words to complete
|
||||
for ((i = 0, j = 0; i < ${#COMP_WORDS[@]}; i++, j++)); do
|
||||
# Is current word not word 0 (the command itself) and is word not
|
||||
# empty and is word made up of just word separator characters to
|
||||
# be excluded and is current word not preceded by whitespace in
|
||||
# original line?
|
||||
while [[ $i -gt 0 && ${COMP_WORDS[i]} == +($exclude) ]]; do
|
||||
# Is word separator not preceded by whitespace in original line
|
||||
# and are we not going to append to word 0 (the command
|
||||
# itself), then append to current word.
|
||||
[[ $line != [[:blank:]]* ]] && ((j >= 2)) && ((j--))
|
||||
# Append word separator to current or new word
|
||||
ref="$2[$j]"
|
||||
printf -v "$ref" %s "${!ref-}${COMP_WORDS[i]}"
|
||||
# Indicate new cword
|
||||
((i == COMP_CWORD)) && printf -v "$3" %s "$j"
|
||||
# Remove optional whitespace + word separator from line copy
|
||||
line=${line#*"${COMP_WORDS[i]}"}
|
||||
# Indicate next word if available, else end *both* while and
|
||||
# for loop
|
||||
if ((i < ${#COMP_WORDS[@]} - 1)); then
|
||||
((i++))
|
||||
else
|
||||
break 2
|
||||
fi
|
||||
# Start new word if word separator in original line is
|
||||
# followed by whitespace.
|
||||
[[ $line == [[:blank:]]* ]] && ((j++))
|
||||
done
|
||||
# Append word to current word
|
||||
ref="$2[$j]"
|
||||
printf -v "$ref" %s "${!ref-}${COMP_WORDS[i]}"
|
||||
# Remove optional whitespace + word from line copy
|
||||
line=${line#*"${COMP_WORDS[i]}"}
|
||||
# Indicate new cword
|
||||
((i == COMP_CWORD)) && printf -v "$3" %s "$j"
|
||||
done
|
||||
((i == COMP_CWORD)) && printf -v "$3" %s "$j"
|
||||
else
|
||||
# No, list of word completions separators hasn't changed;
|
||||
for i in "${!COMP_WORDS[@]}"; do
|
||||
printf -v "$2[i]" %s "${COMP_WORDS[i]}"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
local FCN_RETURN=""
|
||||
local IS_PATH=0
|
||||
|
||||
|
||||
# -- THIS LINE WILL BE REPLACED WITH GENERATED CODE --
|
||||
|
||||
|
||||
COMPREPLY=()
|
||||
local OPTIONS_NEW=""
|
||||
|
||||
# check if bash or zsh
|
||||
# _get_comp_words_by_ref is a bash built-in function, we check if it exists
|
||||
declare -Ff _get_comp_words_by_ref > /dev/null && IS_BASH=1 || IS_BASH=0
|
||||
|
||||
|
||||
# bash interprets the colon character : as a special character and splits the argument in two
|
||||
# different than what zsh does
|
||||
# https://stackoverflow.com/a/3224910
|
||||
# https://stackoverflow.com/a/12495727
|
||||
local cur
|
||||
local cword words=()
|
||||
_comp__reassemble_words ":" words cword
|
||||
cur=${words[cword]}
|
||||
|
||||
# check the action (get or put)
|
||||
case "${words[0]}" in
|
||||
"sls_detector_get" | "g" | "detg")
|
||||
local IS_GET=1
|
||||
;;
|
||||
*)
|
||||
local IS_GET=0
|
||||
;;
|
||||
esac
|
||||
|
||||
# if no command is written, autocomplete with the commands
|
||||
if [[ ${cword} -eq 1 ]]; then
|
||||
# local SLS_COMMANDS="trimbits exptime"
|
||||
local SLS_COMMANDS_NEW=""
|
||||
|
||||
case "$cur" in
|
||||
[0-9]*:*)
|
||||
local suggestions=($(compgen -W "${SLS_COMMANDS}" -- "${cur#*:}"))
|
||||
COMPREPLY=( ${suggestions[*]} )
|
||||
;;
|
||||
[0-9]*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $( compgen -W "$SLS_COMMANDS -h" -- "$cur" ) );;
|
||||
|
||||
esac
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ ${cword} -eq 2 ]] && [[ ${words[1]} == "-h" ]]; then
|
||||
COMPREPLY=( $( compgen -W "$SLS_COMMANDS" -- "$cur" ) )
|
||||
return 0
|
||||
fi
|
||||
|
||||
# if a command is written, autocomplete with the options
|
||||
# call the function for the command
|
||||
|
||||
if [[ "$SLS_COMMANDS" == *"${words[1]##*:}"* ]]; then
|
||||
__"${words[1]##*:}"
|
||||
fi
|
||||
|
||||
# if IS_PATH is activated, autocomplete with the path
|
||||
if [[ ${IS_PATH} -eq 1 ]]; then
|
||||
COMPREPLY=($(compgen -f -- "${cur}"))
|
||||
return 0
|
||||
fi
|
||||
|
||||
# autocomplete with the options
|
||||
COMPREPLY=($(compgen -W "${FCN_RETURN}" -- "${cur}"))
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
complete -F _sd -o filenames sls_detector_get
|
||||
complete -F _sd -o filenames g
|
||||
complete -F _sd -o filenames detg
|
||||
|
||||
complete -F _sd -o filenames sls_detector_put
|
||||
complete -F _sd -o filenames p
|
||||
complete -F _sd -o filenames detp
|
||||
|
||||
complete -F _sd -o filenames sls_detector
|
||||
complete -F _sd -o filenames det
|
3265
slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh
Normal file
3265
slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh
Normal file
File diff suppressed because it is too large
Load Diff
62035
slsDetectorSoftware/generator/autocomplete/dump.json
Normal file
62035
slsDetectorSoftware/generator/autocomplete/dump.json
Normal file
File diff suppressed because it is too large
Load Diff
62037
slsDetectorSoftware/generator/autocomplete/fixed.json
Normal file
62037
slsDetectorSoftware/generator/autocomplete/fixed.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,177 @@
|
||||
#### simpler version of autocomplete.sh to understand the logic
|
||||
#### each command has its own function when called it will produce the possible values for autocompletion
|
||||
|
||||
|
||||
_sd() {
|
||||
|
||||
# Reassemble command line words, excluding specified characters from the
|
||||
# list of word completion separators (COMP_WORDBREAKS).
|
||||
# @param $1 chars Characters out of $COMP_WORDBREAKS which should
|
||||
# NOT be considered word breaks. This is useful for things like scp where
|
||||
# we want to return host:path and not only path, so we would pass the
|
||||
# colon (:) as $1 here.
|
||||
# @param $2 words Name of variable to return words to
|
||||
# @param $3 cword Name of variable to return cword to
|
||||
#
|
||||
_comp__reassemble_words()
|
||||
{
|
||||
local exclude="" i j line ref
|
||||
# Exclude word separator characters?
|
||||
if [[ $1 ]]; then
|
||||
# Yes, exclude word separator characters;
|
||||
# Exclude only those characters, which were really included
|
||||
exclude="[${1//[^$COMP_WORDBREAKS]/}]"
|
||||
fi
|
||||
|
||||
# Default to cword unchanged
|
||||
printf -v "$3" %s "$COMP_CWORD"
|
||||
# Are characters excluded which were former included?
|
||||
if [[ $exclude ]]; then
|
||||
# Yes, list of word completion separators has shrunk;
|
||||
line=$COMP_LINE
|
||||
# Re-assemble words to complete
|
||||
for ((i = 0, j = 0; i < ${#COMP_WORDS[@]}; i++, j++)); do
|
||||
# Is current word not word 0 (the command itself) and is word not
|
||||
# empty and is word made up of just word separator characters to
|
||||
# be excluded and is current word not preceded by whitespace in
|
||||
# original line?
|
||||
while [[ $i -gt 0 && ${COMP_WORDS[i]} == +($exclude) ]]; do
|
||||
# Is word separator not preceded by whitespace in original line
|
||||
# and are we not going to append to word 0 (the command
|
||||
# itself), then append to current word.
|
||||
[[ $line != [[:blank:]]* ]] && ((j >= 2)) && ((j--))
|
||||
# Append word separator to current or new word
|
||||
ref="$2[$j]"
|
||||
printf -v "$ref" %s "${!ref-}${COMP_WORDS[i]}"
|
||||
# Indicate new cword
|
||||
((i == COMP_CWORD)) && printf -v "$3" %s "$j"
|
||||
# Remove optional whitespace + word separator from line copy
|
||||
line=${line#*"${COMP_WORDS[i]}"}
|
||||
# Indicate next word if available, else end *both* while and
|
||||
# for loop
|
||||
if ((i < ${#COMP_WORDS[@]} - 1)); then
|
||||
((i++))
|
||||
else
|
||||
break 2
|
||||
fi
|
||||
# Start new word if word separator in original line is
|
||||
# followed by whitespace.
|
||||
[[ $line == [[:blank:]]* ]] && ((j++))
|
||||
done
|
||||
# Append word to current word
|
||||
ref="$2[$j]"
|
||||
printf -v "$ref" %s "${!ref-}${COMP_WORDS[i]}"
|
||||
# Remove optional whitespace + word from line copy
|
||||
line=${line#*"${COMP_WORDS[i]}"}
|
||||
# Indicate new cword
|
||||
((i == COMP_CWORD)) && printf -v "$3" %s "$j"
|
||||
done
|
||||
((i == COMP_CWORD)) && printf -v "$3" %s "$j"
|
||||
else
|
||||
# No, list of word completions separators hasn't changed;
|
||||
for i in "${!COMP_WORDS[@]}"; do
|
||||
printf -v "$2[i]" %s "${COMP_WORDS[i]}"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
__exptime(){
|
||||
if [ "${IS_GET}" == "1" ]; then
|
||||
if [ "${cword}" == "2" ]; then
|
||||
FCN_RETURN="s ms us ns"
|
||||
fi
|
||||
else
|
||||
if [ "${cword}" == "2" ]; then
|
||||
FCN_RETURN=""
|
||||
fi
|
||||
|
||||
if [ "${cword}" == "3" ]; then
|
||||
FCN_RETURN="s ms us ns"
|
||||
fi
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
# trimbits will activate IS_PATH and signal that its input is a path
|
||||
__trimbits(){
|
||||
if [ "${IS_GET}" == "1" ]; then
|
||||
if [ "${cword}" == "2" ]; then
|
||||
FCN_RETURN=""
|
||||
IS_PATH=1
|
||||
fi
|
||||
else
|
||||
if [ "${cword}" == "2" ]; then
|
||||
FCN_RETURN=""
|
||||
IS_PATH=1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
local cword words=()
|
||||
_comp__reassemble_words ":" words cword
|
||||
local FCN_RETURN=""
|
||||
local IS_PATH=0
|
||||
COMPREPLY=()
|
||||
local OPTIONS_NEW=""
|
||||
# _get_comp_words_by_ref -n : cur
|
||||
local cur=${words[cword]}
|
||||
# check the action (get or put)
|
||||
if [ "${words[0]}" == "sls_detector_get" ]; then
|
||||
local IS_GET=1
|
||||
else
|
||||
local IS_GET=0
|
||||
fi
|
||||
|
||||
|
||||
# if no command is written, autocomplete with the commands
|
||||
if [[ ${cword} -eq 1 ]]; then
|
||||
local SLS_COMMANDS="trimbits exptime"
|
||||
local SLS_COMMANDS_NEW=""
|
||||
|
||||
case "$cur" in
|
||||
[0-9]*:*)
|
||||
local suggestions=($(compgen -W "${SLS_COMMANDS}" -- "${cur#*:}"))
|
||||
COMPREPLY=( ${suggestions[*]} )
|
||||
;;
|
||||
[0-9]*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $( compgen -W "$SLS_COMMANDS -h" -- "$cur" ) );;
|
||||
|
||||
esac
|
||||
return 0
|
||||
fi
|
||||
|
||||
# if a command is written, autocomplete with the options
|
||||
# call the function for the command
|
||||
__"${words[1]##*:}"
|
||||
|
||||
# if IS_PATH is activated, autocomplete with the path
|
||||
if [[ ${IS_PATH} -eq 1 ]]; then
|
||||
COMPREPLY=($(compgen -f -- "${cur}"))
|
||||
return 0
|
||||
fi
|
||||
|
||||
# autocomplete with the options
|
||||
COMPREPLY=($(compgen -W "${FCN_RETURN}" -- "${cur}"))
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
complete -F _sd -o filenames sls_detector_put
|
||||
complete -F _sd -o filenames sls_detector_get
|
||||
|
||||
complete -F _sd -o filenames g
|
||||
complete -F _sd -o filenames p
|
||||
|
||||
complete -F _sd -o filenames detg
|
||||
complete -F _sd -o filenames detp
|
||||
|
||||
|
||||
complete -F _sd -o filenames sls_detector
|
||||
complete -F _sd -o filenames det
|
||||
|
@ -0,0 +1,77 @@
|
||||
# GENERATED FILE - DO NOT EDIT
|
||||
# ANY CHANGES TO THIS FILE WILL BE OVERWRITTEN
|
||||
|
||||
_sd() {
|
||||
|
||||
|
||||
# -- THIS LINE WILL BE REPLACED WITH GENERATED CODE --
|
||||
|
||||
|
||||
local FCN_RETURN=""
|
||||
local IS_PATH=0
|
||||
COMPREPLY=()
|
||||
local OPTIONS_NEW=""
|
||||
words=("${COMP_WORDS[@]}")
|
||||
cword=$COMP_CWORD
|
||||
|
||||
local cur=${words[cword]}
|
||||
# check the action (get or put)
|
||||
case "${words[0]}" in
|
||||
"sls_detector_get" | "g" | "detg")
|
||||
local IS_GET=1
|
||||
;;
|
||||
*)
|
||||
local IS_GET=0
|
||||
;;
|
||||
esac
|
||||
|
||||
# if no command is written, autocomplete with the commands
|
||||
if [[ ${cword} -eq 1 ]]; then
|
||||
|
||||
case "$cur" in
|
||||
[0-9]*)
|
||||
for i in $SLS_COMMANDS; do
|
||||
SLS_COMMANDS_NEW="${SLS_COMMANDS_NEW} ${cur%%:*}:$i"
|
||||
done
|
||||
COMPREPLY=( $( compgen -W "${SLS_COMMANDS_NEW}" -- "$cur" ) );;
|
||||
*)
|
||||
COMPREPLY=( $( compgen -W "$SLS_COMMANDS -h" -- "$cur" ) );;
|
||||
esac
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ ${cword} -eq 2 ]] && [[ ${words[1]} == "-h" ]]; then
|
||||
COMPREPLY=( $( compgen -W "$SLS_COMMANDS" -- "$cur" ) )
|
||||
return 0
|
||||
fi
|
||||
|
||||
# if a command is written, autocomplete with the options
|
||||
# call the function for the command
|
||||
|
||||
if [[ "$SLS_COMMANDS" == *"${words[1]##*:}"* ]]; then
|
||||
__"${words[1]##*:}"
|
||||
fi
|
||||
|
||||
# if IS_PATH is activated, autocomplete with the path
|
||||
if [[ ${IS_PATH} -eq 1 ]]; then
|
||||
COMPREPLY=($(compgen -f -- "${cur}"))
|
||||
return 0
|
||||
fi
|
||||
|
||||
# autocomplete with the options
|
||||
COMPREPLY=($(compgen -W "${FCN_RETURN}" -- "${cur}"))
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
complete -F _sd -o filenames sls_detector_get
|
||||
complete -F _sd -o filenames g
|
||||
complete -F _sd -o filenames detg
|
||||
|
||||
complete -F _sd -o filenames sls_detector_put
|
||||
complete -F _sd -o filenames p
|
||||
complete -F _sd -o filenames detp
|
||||
|
||||
complete -F _sd -o filenames sls_detector
|
||||
complete -F _sd -o filenames det
|
3175
slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh
Normal file
3175
slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh
Normal file
File diff suppressed because it is too large
Load Diff
4285
slsDetectorSoftware/generator/commands.yaml
Normal file
4285
slsDetectorSoftware/generator/commands.yaml
Normal file
File diff suppressed because it is too large
Load Diff
379
slsDetectorSoftware/generator/commands_parser/commands_parser.py
Normal file
379
slsDetectorSoftware/generator/commands_parser/commands_parser.py
Normal file
@ -0,0 +1,379 @@
|
||||
import copy
|
||||
import logging
|
||||
import yaml
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class CommandParser:
|
||||
def __init__(
|
||||
self,
|
||||
commands_file: Path = Path(__file__).parent.parent / 'commands.yaml',
|
||||
output_file: Path = Path(__file__).parent.parent / 'extended_commands.yaml'
|
||||
):
|
||||
|
||||
self.output_file = output_file
|
||||
self.commands_file = commands_file
|
||||
self.fp = self.commands_file.open('r')
|
||||
self.simple_commands = yaml.unsafe_load(self.fp)
|
||||
self.extended_commands = {}
|
||||
self.argc_set = set()
|
||||
self.logger = logging.getLogger('command_parser')
|
||||
self.__current_action: str = ''
|
||||
FORMAT = '[%(levelname)s] %(message)s'
|
||||
logging.basicConfig(format=FORMAT, level=logging.INFO)
|
||||
|
||||
self.propagate_config = {
|
||||
'require_det_id': False,
|
||||
'convert_det_id': True,
|
||||
'input': [],
|
||||
'input_types': [],
|
||||
'function': '',
|
||||
'output': [],
|
||||
'cast_input': [],
|
||||
'check_det_id': False,
|
||||
'arg_types': [],
|
||||
# 'store_result_in_t': False, # always true in GET action
|
||||
}
|
||||
self.default_config = {
|
||||
'infer_action': True,
|
||||
'help': '',
|
||||
'actions': {}
|
||||
}
|
||||
|
||||
def _verify_argument(self, arg, infer_action, command_name, action):
|
||||
if arg['function'] == '' and 'ctb_output_list' not in arg:
|
||||
special_exception_message_list = ["Cannot put", "Cannot get"]
|
||||
if 'exceptions' in arg and arg['exceptions'][0]['condition'] == 'true' and any(ele in arg['exceptions'][0]['message'] for ele in special_exception_message_list):
|
||||
self.logger.warning(f"{command_name} has a special exception message for {action}.")
|
||||
else:
|
||||
self.logger.warning(f"{command_name} [{action}] does not have a function")
|
||||
if len(arg['input_types']) != len(arg['input']):
|
||||
raise ValueError(f'Argument {arg} does not have the correct number of inputs')
|
||||
if 'separate_time_units' in arg:
|
||||
|
||||
if arg['separate_time_units']['input'] == "":
|
||||
raise ValueError(f'Argument {arg} does not have the correct number of inputs for separate_time_units')
|
||||
if len(arg['separate_time_units']['output']) != 2:
|
||||
raise ValueError(f'Argument {arg} does not have the correct number of outputs for separate_time_units')
|
||||
if 'convert_to_time' in arg:
|
||||
if len(arg['convert_to_time']['input']) != 2:
|
||||
raise ValueError(f'Argument {arg} does not have the correct number of inputs for convert_to_time')
|
||||
if len(arg['convert_to_time']['output']) == "":
|
||||
raise ValueError(f'Argument {arg} does not have the correct number of outputs for convert_to_time')
|
||||
# if infer_action:
|
||||
# if arg['argc'] in self.argc_set:
|
||||
# raise ValueError(f'Argument {arg} has a duplicate argc')
|
||||
# self.argc_set.add(arg['argc'])
|
||||
|
||||
def verify_format(self):
|
||||
# todo verify detectors
|
||||
# todo verify circular inheritance
|
||||
# todo verify child commands (those that inherit)
|
||||
# todo verify that there is no wrongly typed parameters
|
||||
# todo verify that the same number of input_types and input are given
|
||||
# todo verify that each argument has argc (error can happen when inheriting)
|
||||
for command_name, command in self.simple_commands.items():
|
||||
if 'inherit_actions' in command or 'template' in command and command[
|
||||
'template'] or 'is_description' in command and command['is_description']:
|
||||
continue
|
||||
self.argc_set = set()
|
||||
if 'infer_action' not in command:
|
||||
command['infer_action'] = True
|
||||
if 'actions' not in command:
|
||||
raise ValueError(f'Command {command_name} does not have any actions')
|
||||
for action, action_params in command['actions'].items():
|
||||
if 'argc' in action_params:
|
||||
if 'args' in action_params:
|
||||
raise ValueError(f'Action {action} has both argc and args')
|
||||
arg = {**self.propagate_config, **action_params}
|
||||
self._verify_argument(arg, command['infer_action'], command_name, action)
|
||||
elif 'args' in action_params:
|
||||
if type(action_params['args']) is not list:
|
||||
raise ValueError(f'Action {action} args is not a list')
|
||||
if len(action_params['args']) == 0:
|
||||
raise ValueError(f'Action {action} args is empty')
|
||||
action_args = {**self.propagate_config, **action_params}
|
||||
del action_args['args']
|
||||
for arg in action_params['args']:
|
||||
arg = {**action_args, **arg}
|
||||
self._verify_argument(arg, command['infer_action'], command_name, action)
|
||||
self.logger.info('Commands file is valid ✅️')
|
||||
return True
|
||||
|
||||
def _parse_inherited_command(self, parent, command, simple_parent):
|
||||
"""
|
||||
parse a command that inherits from parent command
|
||||
:param parent: parsed parent command
|
||||
:param command: the current command
|
||||
:param simple_parent: unparsed parent command
|
||||
:return: parsed command
|
||||
"""
|
||||
# deepcopy parent and command to avoid modifying the originals
|
||||
command = copy.deepcopy(command)
|
||||
config = copy.deepcopy(parent)
|
||||
# add help
|
||||
if 'help' in command:
|
||||
config['help'] = command['help']
|
||||
if 'actions' not in command:
|
||||
return config
|
||||
for action, command_params in command['actions'].items():
|
||||
self.__current_action = action
|
||||
if action not in config['actions']:
|
||||
# todo: handle this case
|
||||
pass
|
||||
parent_params = config['actions'][action]
|
||||
if 'args' in command_params:
|
||||
# child has args => inherit action level params from parent + override with child args + use child's
|
||||
# action level params
|
||||
context = {**self.propagate_config, **simple_parent['actions'][action], **command_params}
|
||||
config['actions'][action]['args'] = self.parse_action(context, command_params['args'])
|
||||
elif 'argc' in command_params:
|
||||
# child has action level args (argc)
|
||||
context = {**self.propagate_config, **simple_parent['actions'][action], **command_params}
|
||||
config['actions'][action]['args'] = self.parse_action(context, [])
|
||||
else:
|
||||
# child does not have args => use parent's action level params + override with child's action level
|
||||
if 'args' in parent_params:
|
||||
config['actions'][action]['args'] = self.parse_action({}, parent_params['args'], command_params)
|
||||
|
||||
if 'detectors' in command_params:
|
||||
if command_params['detectors'] is None:
|
||||
# if child has an empty detector section, then delete the parent's detector section
|
||||
del config['actions'][action]['detectors']
|
||||
continue
|
||||
|
||||
for detector_name, detector_params in command_params['detectors'].items():
|
||||
if 'detectors' not in config['actions'][action]:
|
||||
config['actions'][action]['detectors'] = {}
|
||||
config_detector = config['actions'][action]['detectors']
|
||||
if 'detectors' not in parent_params or detector_name not in parent_params['detectors']:
|
||||
if 'args' in detector_params:
|
||||
# if child has detector args and parent does not have detectors
|
||||
# => use child's detector args
|
||||
context = {**self.propagate_config, **simple_parent['actions'][action], **detector_params}
|
||||
config_detector[detector_name] = self.parse_action(context, detector_params['args'])
|
||||
elif 'args' in parent_params:
|
||||
# if child does not have detector args and parent does not have detectors
|
||||
# => use the child's action args
|
||||
context = {**self.propagate_config, **simple_parent['actions'][action]}
|
||||
config_detector[detector_name] = self.parse_action(context,
|
||||
config['actions'][action]['args'],
|
||||
detector_params)
|
||||
elif detector_name in parent_params['detectors']:
|
||||
|
||||
if 'args' in detector_params:
|
||||
# child and parent have the same detector and child has detector args
|
||||
# => use child's detector args
|
||||
context = {
|
||||
**self.propagate_config,
|
||||
**simple_parent['actions'][action],
|
||||
**simple_parent['actions'][action]['detectors'][detector_name],
|
||||
|
||||
}
|
||||
config_detector[detector_name] = self.parse_action(context, detector_params['args'])
|
||||
else:
|
||||
# child and parent have the same detector and child does not have detector args
|
||||
# => use parent's detector args
|
||||
priority_context = {**command_params, **detector_params}
|
||||
config_detector[detector_name] = self.parse_action(
|
||||
{},
|
||||
parent_params['detectors'][detector_name],
|
||||
priority_context
|
||||
)
|
||||
|
||||
else:
|
||||
pass
|
||||
|
||||
return config
|
||||
|
||||
def _parse_command(self, command):
|
||||
"""
|
||||
logic function for parse_command.
|
||||
This function is recursive
|
||||
:return: parsed command
|
||||
"""
|
||||
config = self.default_config.copy()
|
||||
config.update(command)
|
||||
config['actions'] = {}
|
||||
|
||||
# check if command inherits from another command
|
||||
if 'inherit_actions' in command:
|
||||
if command['inherit_actions'] in self.extended_commands:
|
||||
# if parent command has already been parsed, use that
|
||||
parent = self.extended_commands[command['inherit_actions']]
|
||||
else:
|
||||
# if parent command has not been parsed, parse it
|
||||
parent = self.parse_command(command['inherit_actions'])
|
||||
# parse the current command and merge it with the parent command
|
||||
config = self._parse_inherited_command(parent, command, self.simple_commands[command['inherit_actions']])
|
||||
return config
|
||||
|
||||
if 'actions' not in command:
|
||||
return config
|
||||
|
||||
for action, action_params in command['actions'].items():
|
||||
self.__current_action = action
|
||||
|
||||
config['actions'][action] = {}
|
||||
config_action = config['actions'][action]
|
||||
# the context in the current command and the current action
|
||||
action_context = {**self.propagate_config, **action_params}
|
||||
if 'args' not in action_params:
|
||||
# parse the action with the action context
|
||||
if action_params.keys() != {'detectors'}:
|
||||
config_action['args'] = self.parse_action(action_context, [])
|
||||
else:
|
||||
config_action['args'] = self.parse_action(action_context, action_params['args'])
|
||||
|
||||
# check if the action has detectors
|
||||
if 'detectors' in action_params:
|
||||
config_action['detectors'] = {}
|
||||
for detector_name, detector_params in action_params['detectors'].items():
|
||||
# get the context for the detector and merge it with the action context
|
||||
detector_context = {**action_context, **detector_params}
|
||||
|
||||
# if the detector does not have args, then use the action args
|
||||
# otherwise, use the detector args and override the action args
|
||||
tmp_args = []
|
||||
if 'args' not in detector_params:
|
||||
if 'args' in config_action:
|
||||
tmp_args = config_action['args']
|
||||
else:
|
||||
tmp_args = detector_params['args']
|
||||
detector_params['args'] = tmp_args
|
||||
|
||||
# parse the action with the detector context
|
||||
config_action['detectors'][detector_name] = self.parse_action(detector_context,
|
||||
tmp_args,
|
||||
detector_params)
|
||||
return config
|
||||
|
||||
def sanitize_argument(func):
|
||||
def f(self, action_context, args_old, priority_context={}):
|
||||
args = func(self, action_context, args_old, priority_context)
|
||||
for i, arg in enumerate(args):
|
||||
if 'args' in arg:
|
||||
del arg['args']
|
||||
if 'detectors' in arg:
|
||||
del arg['detectors']
|
||||
if not arg['cast_input']:
|
||||
# if the cast_input is empty, then set it to False
|
||||
arg['cast_input'] = [False] * len(arg['input'])
|
||||
|
||||
elif len(arg['cast_input']) != len(arg['input']):
|
||||
# if the cast_input is not the same length as the input, then set it to False
|
||||
arg['cast_input'] = [False] * len(arg['input'])
|
||||
self.logger.warning(f'cast_input for {arg["function"]} '
|
||||
f'with argc: {arg["argc"]} has different length than input')
|
||||
if 'store_result_in_t' not in arg:
|
||||
if self.__current_action == 'GET':
|
||||
arg['store_result_in_t'] = True
|
||||
else:
|
||||
arg['store_result_in_t'] = False
|
||||
return args
|
||||
|
||||
return f
|
||||
|
||||
@sanitize_argument
|
||||
def parse_action(self, action_context, args, priority_context={}):
|
||||
"""
|
||||
parse an action
|
||||
:param action_context: context of the action
|
||||
:param args: arguments to be used in the action
|
||||
:param priority_context: context that should override the arguments params
|
||||
:return: parsed action
|
||||
"""
|
||||
|
||||
def add_cast_input(argument):
|
||||
return argument
|
||||
|
||||
# deepcopy action_context to avoid modifying the original
|
||||
action_context = {**self.propagate_config, **copy.deepcopy(action_context)}
|
||||
priority_context = copy.deepcopy(priority_context)
|
||||
|
||||
if 'detectors' in action_context:
|
||||
del action_context['detectors']
|
||||
if 'detectors' in priority_context:
|
||||
del priority_context['detectors']
|
||||
|
||||
if args == []:
|
||||
# if there are no arguments, then the action has only one argument
|
||||
context = {**action_context, **priority_context}
|
||||
return [add_cast_input(context)]
|
||||
|
||||
ret_args = []
|
||||
if 'args' in action_context:
|
||||
del action_context['args']
|
||||
if 'args' in priority_context:
|
||||
del priority_context['args']
|
||||
|
||||
# if there are arguments, then merge them with the action context and priority context
|
||||
for arg in args:
|
||||
arg = {**action_context, **arg, **priority_context}
|
||||
ret_args.append(add_cast_input(arg))
|
||||
return ret_args
|
||||
|
||||
def parse_command(self, command_name):
|
||||
"""
|
||||
parse a single command
|
||||
This function is recursive
|
||||
|
||||
:param command_name: name of the command to parse
|
||||
:return: the parsed command
|
||||
"""
|
||||
command = self.simple_commands[command_name]
|
||||
parsed_command = self._parse_command(command)
|
||||
if 'function_alias' not in command:
|
||||
if 'command_name' in command:
|
||||
parsed_command['function_alias'] = command['command_name']
|
||||
else:
|
||||
parsed_command['function_alias'] = command_name
|
||||
|
||||
if 'command_name' not in command:
|
||||
parsed_command['command_name'] = command_name
|
||||
|
||||
if 'template' in command and command['template']:
|
||||
return parsed_command
|
||||
self.extended_commands[command_name] = parsed_command
|
||||
return self.extended_commands[command_name]
|
||||
|
||||
def parse_all_commands(self):
|
||||
"""
|
||||
iterate over all commands in yaml file and parse them
|
||||
:return: None
|
||||
"""
|
||||
|
||||
for command_name in self.simple_commands:
|
||||
# todo remove this (added for debugging)
|
||||
if command_name != 'xtiming':
|
||||
self.parse_command(command_name)
|
||||
|
||||
# post-process the parsed commands
|
||||
self.post_process_all_commands()
|
||||
|
||||
yaml.Dumper.ignore_aliases = lambda *args: True
|
||||
self.logger.info(f'parsed {len(self.extended_commands)} commands')
|
||||
yaml.dump(self.extended_commands, self.output_file.open('w'), default_flow_style=False)
|
||||
|
||||
def post_process_all_commands(self):
|
||||
for command_name, command in self.extended_commands.items():
|
||||
if 'is_description' in command and command['is_description']:
|
||||
continue
|
||||
for action_name, action, in command['actions'].items():
|
||||
for arg in action['args']:
|
||||
if arg['argc'] == 0:
|
||||
arg['arg_types'] = []
|
||||
continue
|
||||
if arg['argc'] == -1:
|
||||
pass
|
||||
if arg['arg_types'] == []:
|
||||
arg['arg_types'] = arg['input_types']
|
||||
|
||||
|
||||
# command_parser = CommandParser(Path(
|
||||
# '/afs/psi.ch/user/b/braham_b/github/slsDetectorPackage/slsDetectorSoftware/generator/tests/command_parser/data/detectors.yaml'))
|
||||
command_parser = CommandParser()
|
||||
|
||||
if __name__ == '__main__':
|
||||
command_parser.verify_format()
|
||||
command_parser.parse_all_commands()
|
282
slsDetectorSoftware/generator/cpp_codegen/codegen.py
Normal file
282
slsDetectorSoftware/generator/cpp_codegen/codegen.py
Normal file
@ -0,0 +1,282 @@
|
||||
class CodeGenerator:
|
||||
def __init__(self):
|
||||
self.file = None
|
||||
self.actions_dict = {
|
||||
'GET': 'slsDetectorDefs::GET_ACTION',
|
||||
'PUT': 'slsDetectorDefs::PUT_ACTION',
|
||||
'READOUT': 'slsDetectorDefs::READOUT_ACTION',
|
||||
'HELP': 'slsDetectorDefs::HELP_ACTION',
|
||||
}
|
||||
self.template_file = None
|
||||
|
||||
def open(self, path):
|
||||
self.file = path.open('w')
|
||||
|
||||
def close(self):
|
||||
self.file.close()
|
||||
self.file = None
|
||||
|
||||
def write_line(self, line):
|
||||
self.file.write(line + '\n')
|
||||
|
||||
def write(self, text):
|
||||
self.file.write(text)
|
||||
|
||||
def write_opening(self, path):
|
||||
"""Write the opening file for the caller.cpp file"""
|
||||
self.template_file = path.open('r')
|
||||
for line in self.template_file:
|
||||
if "THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE" in line:
|
||||
return
|
||||
self.file.write(line)
|
||||
|
||||
def write_closing(self):
|
||||
"""Write the closing file for the caller.cpp file"""
|
||||
for line in self.template_file.readlines():
|
||||
self.file.write(line)
|
||||
self.template_file.close()
|
||||
|
||||
def write_header(self, in_path, out_path, commands, deprecated_commands):
|
||||
"""Write the header file for the caller.h file"""
|
||||
with out_path.open('w') as fp:
|
||||
with in_path.open('r') as fp2:
|
||||
for line in fp2:
|
||||
if "THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (1)" in line:
|
||||
for command_name, command in commands.items():
|
||||
if 'duplicate_function' in command and command['duplicate_function']:
|
||||
continue
|
||||
fp.write(f'std::string {command["function_alias"]}(int action);\n')
|
||||
continue
|
||||
if "THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (2)" in line:
|
||||
map_string = ''
|
||||
for command_name, command in commands.items():
|
||||
map_string += f'{{"{command_name}", &Caller::{command["function_alias"]}}},'
|
||||
fp.write(map_string[:-1] + '\n')
|
||||
continue
|
||||
|
||||
if "THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (3)" in line:
|
||||
for key, value in deprecated_commands.items():
|
||||
fp.write(f'{{"{key}", "{value}"}},\n')
|
||||
continue
|
||||
|
||||
fp.write(line)
|
||||
|
||||
def write_infer_header(self, in_path, out_path, commands):
|
||||
"""Write the header file for the inferAction.h file"""
|
||||
with out_path.open('w+') as fp:
|
||||
with in_path.open('r') as fp2:
|
||||
for line in fp2:
|
||||
if "THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (1) - DO NOT REMOVE" in line:
|
||||
for command_name, command in commands.items():
|
||||
if 'duplicate_function' in command and command['duplicate_function']:
|
||||
continue
|
||||
|
||||
fp.write(f'int {command["function_alias"]}();\n')
|
||||
continue
|
||||
if "THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (2) - DO NOT REMOVE" in line:
|
||||
map_string = ''
|
||||
for command_name, command in commands.items():
|
||||
map_string += f'{{"{command_name}", &InferAction::{command["function_alias"]}}},'
|
||||
fp.write(map_string[:-1] + '\n')
|
||||
continue
|
||||
fp.write(line)
|
||||
|
||||
def write_infer_cpp(self, in_path, out_path, commands, non_dist, type_dist):
|
||||
"""Write the source file for the inferAction.cpp file"""
|
||||
with in_path.open('r') as fp2:
|
||||
for line in fp2:
|
||||
if "THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (1) - DO NOT REMOVE" in line:
|
||||
for command_name, command in commands.items():
|
||||
if 'duplicate_function' in command and command['duplicate_function']:
|
||||
continue
|
||||
|
||||
with function('int', f"InferAction::{command['function_alias']}", []) as f:
|
||||
if (command_name, -1) in non_dist| type_dist:
|
||||
self.write_line(
|
||||
f'throw RuntimeError("sls_detector is disabled for command: {command_name}. Use sls_detector_get or sls_detector_put");')
|
||||
elif not command['infer_action']:
|
||||
self.write_line('throw RuntimeError("infer_action is disabled");')
|
||||
else:
|
||||
checked_argcs = set()
|
||||
for action, action_params in command['actions'].items():
|
||||
for arg in action_params['args']:
|
||||
if arg['argc'] in checked_argcs:
|
||||
continue
|
||||
checked_argcs.add(arg['argc'])
|
||||
with if_block(f'args.size() == {arg["argc"]}'):
|
||||
# check if this argc is not distinguishable
|
||||
if (command_name, arg["argc"]) in non_dist | type_dist:
|
||||
self.write_line(
|
||||
f'throw RuntimeError("sls_detector is disabled for command: {command_name} with number of arguments {arg["argc"]}. Use sls_detector_get or sls_detector_put");')
|
||||
else:
|
||||
self.write_line(f'return {self.actions_dict[action]};')
|
||||
with else_block():
|
||||
self.write_line(
|
||||
'throw RuntimeError("Could not infer action: Wrong number of arguments");')
|
||||
continue
|
||||
self.write_line(line)
|
||||
|
||||
def write_check_arg(self):
|
||||
pass
|
||||
|
||||
def write_arg(self, args, action, command_name):
|
||||
for arg in args:
|
||||
if arg['argc'] != -1:
|
||||
if_block(f'args.size() == {arg["argc"]}',).__enter__()
|
||||
if 'pattern_command' in arg and arg['pattern_command']:
|
||||
self.write_line(f'int level = -1, iArg = 0, '
|
||||
f'nGetArgs = {arg["pattern_command"]["nGetArgs"]},'
|
||||
f' nPutArgs = {arg["pattern_command"]["nPutArgs"]};\nGetLevelAndUpdateArgIndex(action, '
|
||||
f'"{arg["pattern_command"]["command_name"]}", level, iArg, nGetArgs,nPutArgs);'
|
||||
)
|
||||
|
||||
if 'extra_variables' in arg:
|
||||
for var in arg['extra_variables']:
|
||||
codegen.write_line(f'{var["type"]} {var["name"]} = {var["value"]};')
|
||||
if 'separate_time_units' in arg and arg['separate_time_units']:
|
||||
self.write_line(f'std::string tmp_time({arg["separate_time_units"]["input"]});')
|
||||
self.write_line(f'std::string {arg["separate_time_units"]["output"][1]}'
|
||||
f' = RemoveUnit(tmp_time);')
|
||||
self.write_line(f'auto {arg["separate_time_units"]["output"][0]} = '
|
||||
f'StringTo < time::ns > (tmp_time,'
|
||||
f' {arg["separate_time_units"]["output"][1]});')
|
||||
if 'convert_to_time' in arg and arg['convert_to_time']:
|
||||
self.write_line(f'auto {arg["convert_to_time"]["output"]} = '
|
||||
f'StringTo < time::ns > ({", ".join(arg["convert_to_time"]["input"])});')
|
||||
input_arguments = []
|
||||
if 'exceptions' in arg:
|
||||
for exception in arg['exceptions']:
|
||||
self.write_line(f'if ({exception["condition"]}) {{ throw RuntimeError({exception["message"]}); }}')
|
||||
if 'check_det_id' in arg and arg['check_det_id']:
|
||||
self.write_line(
|
||||
f'if (det_id != -1) {{ throw RuntimeError("Cannot execute {command_name} at module level"); }} '
|
||||
)
|
||||
# only used for 3 commands :(
|
||||
if 'ctb_output_list' in arg:
|
||||
self.write_line(f"""
|
||||
std::string suffix = " {arg['ctb_output_list']['suffix']}";
|
||||
auto t = det->{arg['ctb_output_list']['GETFCNLIST']}();""")
|
||||
if arg['ctb_output_list']['GETFCNNAME'] != '':
|
||||
self.write_line(f"""
|
||||
auto names = det->{arg['ctb_output_list']['GETFCNNAME']}();
|
||||
auto name_it = names.begin();""")
|
||||
self.write_line("os << '[';")
|
||||
with if_block(f't.size() > 0'):
|
||||
self.write_line(f"""
|
||||
auto it = t.cbegin();
|
||||
os << ToString({arg['ctb_output_list']['printable_name']}) << ' ';
|
||||
os << OutString(det->{arg['ctb_output_list']['GETFCN']}(*it++, std::vector<int>{{det_id}}))<< suffix;
|
||||
while (it != t.cend()) {{
|
||||
os << ", " << ToString({arg['ctb_output_list']['printable_name']}) << ' ';
|
||||
os << OutString(det->{arg['ctb_output_list']['GETFCN']}(*it++, std::vector<int>{{det_id}}))<< suffix;
|
||||
}}
|
||||
""")
|
||||
self.write_line('os << "]\\n";')
|
||||
if arg['argc'] != -1:
|
||||
if_block().__exit__()
|
||||
|
||||
return
|
||||
|
||||
for i in range(len(arg['input'])):
|
||||
if arg['cast_input'][i]:
|
||||
self.write_line(
|
||||
f'auto arg{i} = StringTo<{arg["input_types"][i]}>({arg["input"][i]});')
|
||||
input_arguments.append(f'arg{i}')
|
||||
else:
|
||||
input_arguments.append(arg["input"][i])
|
||||
if 'require_det_id' in arg and arg['require_det_id']:
|
||||
if 'convert_det_id' in arg and arg['convert_det_id']:
|
||||
input_arguments.append("std::vector<int>{ det_id }")
|
||||
else:
|
||||
input_arguments.append("det_id")
|
||||
|
||||
input_arguments = ", ".join(input_arguments)
|
||||
# call function
|
||||
if arg["function"]:
|
||||
if arg['store_result_in_t']:
|
||||
self.write_line(f'auto t = det->{arg["function"]}({input_arguments});')
|
||||
else:
|
||||
self.write_line(f'det->{arg["function"]}({input_arguments});')
|
||||
else:
|
||||
pass #We have no function so skip block
|
||||
|
||||
output_args = []
|
||||
for output in arg['output']:
|
||||
output_args.append(output)
|
||||
if len(output_args) > 0:
|
||||
self.write_line(f"os << {'<< '.join(output_args)} << '\\n';")
|
||||
|
||||
if arg['argc'] != -1:
|
||||
if_block().__exit__()
|
||||
|
||||
|
||||
class if_block:
|
||||
def __init__(self, condition="", elseif=False):
|
||||
self.condition = condition
|
||||
self.elseif = elseif
|
||||
self.block = False
|
||||
|
||||
def __enter__(self):
|
||||
if self.elseif:
|
||||
codegen.write_line('else if (' + self.condition + ') {')
|
||||
else:
|
||||
codegen.write_line('if (' + self.condition + ') {')
|
||||
if self.block:
|
||||
codegen.write_line('{\n')
|
||||
|
||||
def __exit__(self, *args):
|
||||
codegen.write_line('}')
|
||||
if self.block:
|
||||
codegen.write_line('}')
|
||||
codegen.write_line('')
|
||||
|
||||
|
||||
class else_block:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def __enter__(self):
|
||||
codegen.write_line('else {')
|
||||
codegen.write_line('')
|
||||
|
||||
def __exit__(self, *args):
|
||||
codegen.write_line('}')
|
||||
codegen.write_line('')
|
||||
|
||||
|
||||
class for_block:
|
||||
def __init__(self, condition):
|
||||
self.condition = condition
|
||||
|
||||
def __enter__(self):
|
||||
codegen.write_line('for (' + self.condition + ') {')
|
||||
codegen.write_line('')
|
||||
|
||||
def __exit__(self, *args):
|
||||
codegen.write_line('}')
|
||||
codegen.write_line('')
|
||||
|
||||
|
||||
class function:
|
||||
def __init__(self, return_type, name, args: list[tuple[str, str]]):
|
||||
self.name = name
|
||||
self.args = args
|
||||
self.return_type = return_type
|
||||
|
||||
def __enter__(self):
|
||||
s = ""
|
||||
for arg in self.args:
|
||||
arg_type, arg_name = arg
|
||||
s += arg_type + ' ' + arg_name + ', '
|
||||
s = s[:-2]
|
||||
codegen.write_line(self.return_type + ' ' + self.name +
|
||||
f'({s}) {{')
|
||||
codegen.write_line('')
|
||||
return self
|
||||
|
||||
def __exit__(self, *args):
|
||||
codegen.write_line('}')
|
||||
codegen.write_line('')
|
||||
|
||||
|
||||
codegen = CodeGenerator()
|
176
slsDetectorSoftware/generator/deprecated_commands.yaml
Normal file
176
slsDetectorSoftware/generator/deprecated_commands.yaml
Normal file
@ -0,0 +1,176 @@
|
||||
#configuration
|
||||
detectorversion: firmwareversion
|
||||
softwareversion: detectorserverversion
|
||||
receiverversion: rx_version
|
||||
detectornumber: serialnumber
|
||||
thisversion: clientversion
|
||||
detsizechan: detsize
|
||||
trimdir: settingspath
|
||||
settingsdir: settingspath
|
||||
flippeddatax: fliprows
|
||||
|
||||
#acquisition parameters
|
||||
cycles: triggers
|
||||
cyclesl: triggersl
|
||||
clkdivider: readoutspeed
|
||||
speed: readoutspeed
|
||||
vhighvoltage: highvoltage
|
||||
digitest: imagetest
|
||||
filter: filterresistor
|
||||
readnlines: readnrows
|
||||
|
||||
# temperature
|
||||
|
||||
# super old dacs
|
||||
vtr: vtrim
|
||||
vrf: vrpreamp
|
||||
vrs: vrshaper
|
||||
vcall: vcal
|
||||
vis: vishaper
|
||||
vshaper: vrshaper
|
||||
vpreamp: vrpreamp
|
||||
vshaperneg: vrshaper_n
|
||||
viinsh: vishaper
|
||||
vpl: vcal_n
|
||||
vph: vcal_p
|
||||
|
||||
# dacs
|
||||
vthreshold: dac
|
||||
vsvp: dac
|
||||
vsvn: dac
|
||||
vtrim: dac
|
||||
vrpreamp: dac
|
||||
vrshaper: dac
|
||||
vtgstv: dac
|
||||
vcmp_ll: dac
|
||||
vcmp_lr: dac
|
||||
vcal: dac
|
||||
vcmp_rl: dac
|
||||
vcmp_rr: dac
|
||||
rxb_rb: dac
|
||||
rxb_lb: dac
|
||||
vcp: dac
|
||||
vcn: dac
|
||||
vishaper: dac
|
||||
iodelay: dac
|
||||
vref_ds: dac
|
||||
vcascn_pb: dac
|
||||
vcascp_pb: dac
|
||||
vout_cm: dac
|
||||
vcasc_out: dac
|
||||
vin_cm: dac
|
||||
vref_comp: dac
|
||||
ib_test_c: dac
|
||||
vrshaper_n: dac
|
||||
vipre: dac
|
||||
vdcsh: dac
|
||||
vth1: dac
|
||||
vth2: dac
|
||||
vth3: dac
|
||||
vcal_n: dac
|
||||
vcal_p: dac
|
||||
vcassh: dac
|
||||
vcas: dac
|
||||
vicin: dac
|
||||
vipre_out: dac
|
||||
vref_h_adc: dac
|
||||
vb_comp_fe: dac
|
||||
vb_comp_adc: dac
|
||||
vcom_cds: dac
|
||||
vref_rstore: dac
|
||||
vb_opa_1st: dac
|
||||
vref_comp_fe: dac
|
||||
vcom_adc1: dac
|
||||
vref_prech: dac
|
||||
vref_l_adc: dac
|
||||
vref_cds: dac
|
||||
vb_cs: dac
|
||||
vb_opa_fd: dac
|
||||
vcom_adc2: dac
|
||||
vb_ds: dac
|
||||
vb_comp: dac
|
||||
vb_pixbuf: dac
|
||||
vin_com: dac
|
||||
vdd_prot: dac
|
||||
vbp_colbuf: dac
|
||||
vb_sda: dac
|
||||
vcasc_sfp: dac
|
||||
vipre_cds: dac
|
||||
ibias_sfp: dac
|
||||
|
||||
defaultdacs: resetdacs
|
||||
|
||||
#acquisition
|
||||
busy: clearbusy
|
||||
receiver: rx_status
|
||||
framescaught: rx_framescaught
|
||||
startingfnum: nextframenumber
|
||||
|
||||
#Network Configuration (Detector<->Receiver)
|
||||
detectorip: udp_srcip
|
||||
detectorip2: udp_srcip2
|
||||
detectormac: udp_srcmac
|
||||
detectormac2: udp_srcmac2
|
||||
rx_udpip: udp_dstip
|
||||
rx_udpip2: udp_dstip2
|
||||
rx_udpmac: udp_dstmac
|
||||
rx_udpmac2: udp_dstmac2
|
||||
rx_udpport: udp_dstport
|
||||
rx_udpport2: udp_dstport2
|
||||
flowcontrol_10g: flowcontrol10g
|
||||
txndelay_frame: txdelay_frame
|
||||
txndelay_left: txdelay_left
|
||||
txndelay_right: txdelay_right
|
||||
|
||||
#Receiver Config
|
||||
r_silent: rx_silent
|
||||
r_discardpolicy: rx_discardpolicy
|
||||
r_padding: rx_padding
|
||||
r_lock: rx_lock
|
||||
r_lastclient: rx_lastclient
|
||||
|
||||
#File
|
||||
fileformat: fformat
|
||||
outdir: fpath
|
||||
index: findex
|
||||
enablefwrite: fwrite
|
||||
masterfile: fmaster
|
||||
overwrite: foverwrite
|
||||
r_framesperfile: rx_framesperfile
|
||||
|
||||
#ZMQ Streaming Parameters (Receiver<->Client)
|
||||
r_readfreq: rx_zmqfreq
|
||||
rx_readfreq: rx_zmqfreq
|
||||
rx_datastream: rx_zmqstream
|
||||
|
||||
#Eiger Specific
|
||||
resmat: partialreset
|
||||
|
||||
#Jungfrau Specific
|
||||
storagecells: extrastoragecells
|
||||
auto_comp_disable: autocompdisable
|
||||
comp_disable_time: compdisabletime
|
||||
|
||||
#Gotthard Specific
|
||||
#Gotthard2 Specific
|
||||
#Mythen3 Specific
|
||||
#CTB Specific
|
||||
adc: slowadc
|
||||
flags: romode
|
||||
i_a: im_a
|
||||
i_b: im_b
|
||||
i_c: im_c
|
||||
i_d: im_d
|
||||
i_io: im_io
|
||||
|
||||
#Pattern
|
||||
#Moench
|
||||
|
||||
#Advanced
|
||||
copydetectorserver: updatedetectorserver
|
||||
|
||||
#Insignificant
|
||||
nframes: framecounter
|
||||
now: runtime
|
||||
timestamp: frametime
|
||||
frameindex: rx_frameindex
|
13840
slsDetectorSoftware/generator/extended_commands.yaml
Normal file
13840
slsDetectorSoftware/generator/extended_commands.yaml
Normal file
File diff suppressed because it is too large
Load Diff
276
slsDetectorSoftware/generator/gen_commands.py
Normal file
276
slsDetectorSoftware/generator/gen_commands.py
Normal file
@ -0,0 +1,276 @@
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
from autocomplete.autocomplete import type_info
|
||||
from cpp_codegen.codegen import codegen, if_block, for_block, function, else_block
|
||||
from infer_action.check_infer import check_infer
|
||||
from autocomplete.autocomplete import type_values
|
||||
|
||||
GEN_PATH = Path(__file__).parent
|
||||
|
||||
COMMANDS_PATH = GEN_PATH / 'extended_commands.yaml'
|
||||
DEPRECATED_COMMANDS_PATH = GEN_PATH / 'deprecated_commands.yaml'
|
||||
CPP_INPUT_PATH = GEN_PATH / 'Caller.in.cpp'
|
||||
HEADER_INPUT_PATH = GEN_PATH / 'Caller.in.h'
|
||||
CPP_OUTPUT_PATH = GEN_PATH.parent / 'src' / 'Caller.cpp'
|
||||
HEADER_OUTPUT_PATH = GEN_PATH.parent / 'src' / 'Caller.h'
|
||||
|
||||
INFER_HEADER_INPUT_PATH = GEN_PATH / 'inferAction.in.h'
|
||||
INFER_CPP_INPUT_PATH = GEN_PATH / 'inferAction.in.cpp'
|
||||
INFER_HEADER_OUTPUT_PATH = GEN_PATH.parent / 'src' / 'inferAction.h'
|
||||
INFER_CPP_OUTPUT_PATH = GEN_PATH.parent / 'src' / 'inferAction.cpp'
|
||||
|
||||
|
||||
def generate(
|
||||
commands_path=COMMANDS_PATH,
|
||||
cpp_input_path=CPP_INPUT_PATH,
|
||||
header_input_path=HEADER_INPUT_PATH,
|
||||
cpp_output_path=CPP_OUTPUT_PATH,
|
||||
header_output_path=HEADER_OUTPUT_PATH,
|
||||
infer_header_input_path=INFER_HEADER_INPUT_PATH,
|
||||
infer_cpp_input_path=INFER_CPP_INPUT_PATH,
|
||||
infer_header_output_path=INFER_HEADER_OUTPUT_PATH,
|
||||
infer_cpp_output_path=INFER_CPP_OUTPUT_PATH,
|
||||
|
||||
):
|
||||
commands_config = yaml.unsafe_load(commands_path.open('r'))
|
||||
deprecated_commands_config = yaml.unsafe_load(DEPRECATED_COMMANDS_PATH.open('r'))
|
||||
type_dist, non_dist = check_infer(commands=commands_config)
|
||||
|
||||
codegen.open(cpp_output_path)
|
||||
# write call function
|
||||
codegen.write_opening(cpp_input_path)
|
||||
|
||||
# iterate over the commands and generate code for each
|
||||
print(f"[X] found {len(commands_config)} commands")
|
||||
print('[*] generating code for commands')
|
||||
for command_name, command in commands_config.items():
|
||||
if 'is_description' in command and command['is_description']:
|
||||
continue
|
||||
with function('std::string', 'Caller::' + command['function_alias'], [('int', 'action')]) as fn:
|
||||
codegen.write_line('std::ostringstream os;')
|
||||
|
||||
# print help
|
||||
codegen.write_line('// print help')
|
||||
with if_block('action == slsDetectorDefs::HELP_ACTION'):
|
||||
if command["help"].startswith('code:'):
|
||||
codegen.write_line(command["help"].strip('code:'))
|
||||
else:
|
||||
codegen.write_line(f'os << "Command: {command_name}" << std::endl;')
|
||||
codegen.write_line(f'os << R"V0G0N({command["help"]} )V0G0N" << std::endl;')
|
||||
codegen.write_line('return os.str();')
|
||||
|
||||
# check if action and arguments are valid
|
||||
|
||||
codegen.write_line('// check if action and arguments are valid')
|
||||
first = True
|
||||
for action, action_params in command['actions'].items():
|
||||
|
||||
with if_block(f'action == {codegen.actions_dict[action]}', elseif=not first):
|
||||
|
||||
check_argc = True
|
||||
for arg in action_params['args']:
|
||||
if arg['argc'] == -1:
|
||||
check_argc = False
|
||||
break
|
||||
# check number of arguments
|
||||
condition = "1" if check_argc else "0"
|
||||
|
||||
if check_argc:
|
||||
for arg in action_params['args']:
|
||||
condition += f' && args.size() != {arg["argc"]}'
|
||||
|
||||
with if_block(condition):
|
||||
codegen.write_line(f'throw RuntimeError("Wrong number of arguments for action {action}");')
|
||||
|
||||
for arg in action_params['args']:
|
||||
if not check_argc:
|
||||
continue
|
||||
with if_block(f'args.size() == {arg["argc"]}'):
|
||||
# check argument types
|
||||
if 'extra_variables' in arg:
|
||||
for var in arg['extra_variables']:
|
||||
codegen.write_line(f'{var["type"]} {var["name"]} = {var["value"]};')
|
||||
|
||||
if 'separate_time_units' in arg and arg['separate_time_units']:
|
||||
codegen.write_line(f'try {{')
|
||||
# TODO: refactor this repeating code
|
||||
codegen.write_line(f'std::string tmp_time({arg["separate_time_units"]["input"]});')
|
||||
codegen.write_line(f'std::string {arg["separate_time_units"]["output"][1]}'
|
||||
f' = RemoveUnit(tmp_time);')
|
||||
codegen.write_line(f'auto {arg["separate_time_units"]["output"][0]} = '
|
||||
f'StringTo < time::ns > (tmp_time,'
|
||||
f' {arg["separate_time_units"]["output"][1]});')
|
||||
codegen.write_line(
|
||||
f'}} catch (...) {{ throw RuntimeError("Could not convert argument to time::ns");}}')
|
||||
|
||||
elif 'convert_to_time' in arg and arg['convert_to_time']:
|
||||
codegen.write_line(f'try {{')
|
||||
|
||||
codegen.write_line(
|
||||
f'StringTo < time::ns > ({", ".join(arg["convert_to_time"]["input"])});')
|
||||
codegen.write_line(
|
||||
f'}} catch (...) {{ throw RuntimeError("Could not convert arguments to time::ns");}}')
|
||||
|
||||
for i in range(len(arg['input'])):
|
||||
if not arg['cast_input'][i]:
|
||||
continue
|
||||
codegen.write_line(f'try {{')
|
||||
codegen.write_line(f'StringTo<{arg["input_types"][i]}>({arg["input"][i]});')
|
||||
codegen.write_line(f'}} catch (...) {{')
|
||||
codegen.write_line(
|
||||
f' throw RuntimeError("Could not convert argument {i} to {arg["input_types"][i]}");')
|
||||
codegen.write_line(f'}}')
|
||||
first = False
|
||||
with else_block():
|
||||
codegen.write_line(
|
||||
f'throw RuntimeError("INTERNAL ERROR: Invalid action: supported actions are {list(command["actions"].keys())}");')
|
||||
|
||||
# generate code for each action
|
||||
codegen.write_line('// generate code for each action')
|
||||
for action, action_params in command['actions'].items():
|
||||
if 'detectors' in action_params:
|
||||
codegen.write_line('auto detector_type = det->getDetectorType().squash();')
|
||||
|
||||
with if_block(f'action == {codegen.actions_dict[action]}'):
|
||||
if 'detectors' in action_params:
|
||||
first = True
|
||||
for detector, detector_params in action_params['detectors'].items():
|
||||
with if_block(f'detector_type == defs::{detector}', elseif=not first):
|
||||
codegen.write_arg(detector_params, action, command_name)
|
||||
|
||||
else_block().__enter__()
|
||||
|
||||
if not action_params:
|
||||
codegen.write_line(f'throw RuntimeError("detector not supported for action: {action}");')
|
||||
else:
|
||||
tmp_args = []
|
||||
if 'args' in action_params:
|
||||
tmp_args = action_params['args']
|
||||
codegen.write_arg(tmp_args, action, command_name)
|
||||
|
||||
if 'detectors' in action_params:
|
||||
else_block().__exit__()
|
||||
|
||||
codegen.write_line('return os.str();')
|
||||
|
||||
# close sls namespace
|
||||
codegen.write_closing()
|
||||
codegen.close()
|
||||
print('[X] .cpp code generated')
|
||||
deprecated_commands = []
|
||||
codegen.write_header(header_input_path, header_output_path, commands_config, deprecated_commands_config)
|
||||
print('[X] header code generated')
|
||||
|
||||
|
||||
codegen.write_infer_header(infer_header_input_path, infer_header_output_path, commands_config) #TODO: add deprecated commands
|
||||
print('[X] infer header code generated')
|
||||
codegen.open(infer_cpp_output_path)
|
||||
|
||||
codegen.write_infer_cpp(infer_cpp_input_path, infer_cpp_output_path, commands_config, non_dist, type_dist)
|
||||
codegen.close()
|
||||
print('[X] infer cpp code generated')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(
|
||||
description='generate c++ code for cli commands from the commands.yaml file',
|
||||
)
|
||||
parser.add_argument('-f', '--format', action='store_true', default=False, dest='format',
|
||||
help='format header and cpp file using clang-format')
|
||||
parser.add_argument('-p', '--parse', action='store_true', default=False, dest='parse',
|
||||
help='parse the commands.yaml file into extended_commands.yaml')
|
||||
parser.add_argument('-c', '--check', action='store_true', default=False, dest='check',
|
||||
help='check missing commands')
|
||||
parser.add_argument('-g', '--generate', action='store_true', default=False, dest='generate', help='generate code (C++ or bash if -a is used)')
|
||||
parser.add_argument('-a', '--autocomplete', action='store_true', default=False, dest='autocomplete',
|
||||
help='print bash autocomplete values')
|
||||
cli_args = parser.parse_args()
|
||||
|
||||
if cli_args.autocomplete:
|
||||
from autocomplete.autocomplete import generate_type_values, generate_bash_autocomplete
|
||||
if cli_args.generate:
|
||||
generate_bash_autocomplete()
|
||||
print('[X] bash autocomplete generated')
|
||||
generate_bash_autocomplete(
|
||||
output_path=Path(__file__).parent / 'autocomplete' / 'zsh_autocomplete.sh',
|
||||
input_path=Path(__file__).parent / 'autocomplete' / 'zsh_autocomplete.in.sh'
|
||||
)
|
||||
print('[X] zsh autocomplete generated')
|
||||
exit(0)
|
||||
else:
|
||||
ret = generate_type_values()
|
||||
print(ret)
|
||||
exit(0)
|
||||
|
||||
if cli_args.check:
|
||||
from commands_parser.commands_parser import command_parser
|
||||
|
||||
commands_config = yaml.unsafe_load(COMMANDS_PATH.open('r'))
|
||||
|
||||
# infer action based on number of arguments and types
|
||||
type_dist, non_dist = check_infer(commands=commands_config)
|
||||
|
||||
command_parser.verify_format()
|
||||
command_parser.parse_all_commands()
|
||||
# generate list of commands found in sls_detector_get
|
||||
glist_path = GEN_PATH / 'glist'
|
||||
ret = subprocess.run([f"sls_detector_get list | tail -n +2 | sort > {glist_path.absolute()}"], shell=True,
|
||||
capture_output=True, check=True)
|
||||
if ret.stderr != b'':
|
||||
print('[!] glist generation failed and glist not found')
|
||||
exit(1)
|
||||
|
||||
if not COMMANDS_PATH.exists():
|
||||
print('[!] extended_commands.yaml not found')
|
||||
exit(1)
|
||||
detglist = set(command['command_name'] for __, command in commands_config.items())
|
||||
detglist.add('free')
|
||||
detglist.add('list')
|
||||
|
||||
g_path = GEN_PATH / 'glist'
|
||||
if not g_path.exists():
|
||||
print('[!] glist not found')
|
||||
exit(1)
|
||||
glist = set(g_path.read_text().split('\n'))
|
||||
if "" in glist:
|
||||
glist.remove("")
|
||||
if "" in detglist:
|
||||
detglist.remove("")
|
||||
|
||||
not_found = set()
|
||||
for command in glist:
|
||||
if command not in detglist:
|
||||
not_found.add(command)
|
||||
print()
|
||||
if len(not_found) > 0:
|
||||
print(f'[!] found {len(not_found)} missing')
|
||||
print(f"not_found: {not_found}")
|
||||
else:
|
||||
print(f'[X] found no missing commands')
|
||||
|
||||
for command in detglist:
|
||||
if command not in glist:
|
||||
print(f'[!] command {command} found in commands.yaml but not found in g list')
|
||||
|
||||
exit(0)
|
||||
|
||||
if cli_args.parse:
|
||||
from commands_parser.commands_parser import command_parser
|
||||
|
||||
command_parser.verify_format()
|
||||
command_parser.parse_all_commands()
|
||||
|
||||
if cli_args.generate:
|
||||
generate()
|
||||
|
||||
if cli_args.format:
|
||||
files = [CPP_OUTPUT_PATH, HEADER_OUTPUT_PATH, INFER_HEADER_OUTPUT_PATH, INFER_CPP_OUTPUT_PATH]
|
||||
for file in files:
|
||||
os.system(f'clang-format -i {file.absolute()}')
|
||||
#os.system(f'clang-format -i --style="{{Standard: C++11}}" {file.absolute()}')
|
||||
print('[X] code formatted')
|
20
slsDetectorSoftware/generator/inferAction.in.cpp
Normal file
20
slsDetectorSoftware/generator/inferAction.in.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include "inferAction.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
namespace sls {
|
||||
|
||||
int InferAction::infer(sls::CmdParser &parser, std::ostream &os) {
|
||||
args = parser.arguments();
|
||||
cmd = parser.command();
|
||||
auto it = functions.find(parser.command());
|
||||
if (it != functions.end()) {
|
||||
return ((*this).*(it->second))();
|
||||
} else {
|
||||
throw RuntimeError(
|
||||
"sls_detector not implemented for command: " + parser.command() +
|
||||
". Use sls_detector_get or sls_detector_put.");
|
||||
}
|
||||
}
|
||||
|
||||
// THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (1) - DO NOT REMOVE
|
||||
|
||||
} // namespace sls
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user