Compare commits

..

33 Commits

Author SHA1 Message Date
641b40ffe0 fixed zmq path when building as submodule 2024-01-12 09:18:12 +01:00
bd1a125154 moench default speed set to after init readout configuration (half speed) (#886) 2024-01-11 18:07:34 +01:00
ffe7728966 formatting 2024-01-11 18:04:19 +01:00
b69e053bb4 updated commands generation 2024-01-11 18:03:34 +01:00
daec0dc389 minor 2024-01-11 18:02:30 +01:00
c8bb70f876 Dev/xilinx defaults and pattern (#888)
* implemented testbus, testfpga, set/get #frames, triggers, allowed that and for connection to client, also allowed, getnumchannels, configuremac, getrunstatus, setdetectorposition with dummy values

* connected kernelversion, hardwareversion, versions, framesl, triggersl, dr, timingmode, pattern (except patioctrl) thats there for altera ctb

* replaced set/get64Bit to set/getU64bit in all loadpattern.c for (ctb and m3 also)
2024-01-11 18:01:08 +01:00
9a08ecc5a5 Xilinx client tests (#887)
* implemented testbus, testfpga, set/get #frames, triggers, allowed that and for connection to client, also allowed, getnumchannels, configuremac, getrunstatus, setdetectorposition with dummy values

* allowing tests for xilinx

* binaries in
2024-01-10 16:23:52 +01:00
9738cb7d74 Xilinx ctb (#884)
* updated registers, arm64

* compiler set to aarch64 for xilinx server

* updated RegisterDefs.h

* merge into generate branch and resolving conflicts and adding the xilinx changes to callerspecial and commands.yaml

* compiles and can print firmware version (using a different csp0 address)

* fixing other servers (gotthard, jungfrau, moench, mythen3) that it returns in case of mapping failure, xilinxctb: added that it checks type, prints proper fw version, checks kernel date, added armprocessor define to use in common places, added specifiers to supress overflow and truncation warnings

* added detector ip and mac adddress to the printout

* fixed tests and recompiled servers
2024-01-04 17:10:16 +01:00
4f4125a3b2 Generate commands/fix detp detg command rename (#882)
* replacing detp with sls_Detector_put and detg with sls_detector_get

* sls_detector_not implemented, but extended message to ask user to use sls_detector_get or sls_detector_put

* autocompletion also for sls_detector or det
2023-12-13 17:01:10 +01:00
51412f40cf Generate commands/fix det command rename (#881)
* made a link to bash autocompletion script in main folder, and replaced all references to 'det' command with 'sls_detector'
2023-12-13 15:38:10 +01:00
ce7270e8a2 commands code generation (#871)
* commands code generation  (#803)

* commands code generation for only frames command

* fix cmake file and add Caller files

* working exptime, fully extended commands file and its variants

* start adding template commands

* add INT_CMD_VEC_ID template

* add list command, generate multiple bins, format code

* reach 208 commands using the cpp macros

* add tests for command parser

* start adding tests for commands parser

* fix typo to use commands.yaml

* add more tests for command_parser

* add all template functions (up to 218 commands)

* finish template functions and add more CmdProxy.cpp functions (250+)

* 257 commands

* 300 commands the rest are very special commands

* add special commands without generation

* separate special functions from generated c++ file

* implementing one command for put and get (buggy)

* add infer action in a separate file

* generate header for special commands from yaml

* allow only 0 or 1 for bool inputs

* group all commands in gen_commands.py

* add help to gen_commands.py

* add autocomplete bash script

* autocompletion: add support for module levels and help

* remove debugging line

* add autocompletion, help to commands, change int [0,1] to bool

* copy tests for Caller.cpp. Tests pass

* update with the new developer branch changes

* fix errors after merging (there is problems with tests)

* fixed port/stopport in yaml (intput typo), added '_caller' to the test dac and test on chip dac command in global test for cmdcaller

* undo previous test simulator debug change

* add documentation for the generated code

* reducing the comment to be replaced in length so formatting does not split into 2 lines

* removed formatting specific style of C++11 in gen_commands.py to keep with the top level clang format of the project
* regeneratign code for commands

* automation generated

* Redirect deprecated commands (#872)

* working implementation, need to fix dac

* fixed deprecation redirect for dac command

* Detector specific autocomplete (#873)

* working implementation, need to fix dac

* fixed deprecation redirect for dac command

* detector specific completion for dac

* added autocomplete using detector specific

* fixed error when autocompleting partial words

* Generate commands/fix commands (#875)

* fix vm_a, im_a etc have deg Celsius suffix, also help missing or changed in some places

* dac: require det id for all, arg0 to be printed at output, help for onchip dac and dac, onchipdac: spacing

* getscan detid and blocking trigger help

* udp_Dstlist det_id fixed, but rx_id invalid

* cmdApp in line with cmdLineApp (missing version, receiver_id, not creating det object in help action

* added set_command to differentiate between check_det_id and require_det_id (mixed up), args: -1 needs to check for at least one argument

* reordering

* reordering and checked till integer_command_hex

* fixed a lot more commands

* fix caller tests for eiger

* changes to tests after Bechir left

* changing .cmd to .cmdcall for the caller commands

* fixed tests for caller, still warning for setexptime about cast input

* autocomplete ran

* add moench test

* regenerating autocomplete and commands

* fixing other things from merge conflicts (renaming slsDetectorDefs to defs in commands.yaml)

* formatting

* added code injection to help (#876)

* updated 3 commands to have get output that can be put into put (#877)

* updated some commands to have get output that can be put into put

* fix tests for clkdiv

* adding help to free (#878)

* removing old commands and renaming them, (also making it work for parameters command as it was still calling cmdproxy) (#879)

* More helpful error messages for unsupported actions (#880)

* removing old commands and renaming them, (also making it work for parameters command as it was still calling cmdproxy)

* Added specific help for unsupported actions

* fixed a vetofile get special exception message. more specific warning for special exception message instead of no function warning

* added condition checking true in exceptions for special message

---------
Co-authored-by: Bechir Brahem <bachbrahem@gmail.com>
Co-authored-by: Erik Frojdh <erik.frojdh@gmail.com>
Co-authored-by: Dhanya Thattil <dhanya.thattil@psi.ch>
2023-12-13 14:43:38 +01:00
d72c9e29a4 dev: moench: min exptime (#865)
* moench: remove min clock cycles for setting exptime (had been ported from jf)
2023-11-27 15:22:16 +01:00
62dc0e1a34 removed zmq as dependency for slsdet (#870) 2023-11-24 09:09:29 +01:00
d7aa3305d1 forward declare zmq_msg_t and moved include (#869)
* forward declare zmq_msg_t and moved include

* removed zmq from pkg list
2023-11-20 11:43:30 +01:00
96ed74c47c formatting 2023-11-12 15:35:05 +01:00
4198db8365 documentation and examples 2023-11-12 15:34:58 +01:00
e2d7af28dc added python 3.12 to the conda build variants 2023-11-10 17:34:39 +01:00
66d57c1852 fixed doc 2023-11-10 17:34:32 +01:00
aa4bf6e7f9 updating docs 2023-11-10 17:34:28 +01:00
7f0868f344 minor fix for test_simulator 2023-11-10 11:39:03 +01:00
e57cf49c49 Dev: trigger signal issues handled at acquire (#864)
* if blocking and handling sync, only master gets blocking acq, slaves get non blocking as they are first and so dont get status or error caught when slaves dont get trigger (due to not connected etc) and acq returns with slaves still in waiting status. so check status of all in blocking acq

* for all dets with sync, ensure atleast one master when starting acq

* docs updated about sync
2023-11-10 11:38:06 +01:00
66baaf1ebd dev: fix server logic in checking detector idle (#861)
* fix buggy logic in checking detector idle and an argument check
2023-11-09 15:07:34 +01:00
7d7ac26c30 execute command inside server fixed (from fix simulator tests and exec command PR) (#857) 2023-11-08 09:26:11 +01:00
1a7c74fe4e tests for jf (#835) 2023-11-07 15:01:22 +01:00
01e4bcb47e formatting 2023-11-07 14:52:14 +01:00
397e846509 Dev: fix py virtual test (#846)
* draft to fix virtual test when it fails

* catching errors in tests and removing sigchild ignore so servers (process in background) executing commands will not fail (pclose no child processes, if sigchld is ignored) fixed

* uncommented python loading config

* somehow killal slsReciever in second detector test fails even though no receiver running

* fixing script for virtual simlator test:fixed issue with check if process running, fixed moench tests
2023-11-07 09:30:46 +01:00
314a8a0daa handling inconsistent fnums to be -1 in gui, so when one sets 0 (change of value) will also give an exception (#854) 2023-11-06 16:11:52 +01:00
ebb352b13a Dev: : gui acq finished callback for different status (#850)
* fix acquisition finished status to have different status for different modules, but does not have to be error. for eg. jf sync fw (2.4.1 gives idle for master and stopped for slaves when stopping acquiistion)
2023-11-06 16:08:07 +01:00
9b5d44f0b3 fix warning for prev_val (variable size array) in tests (#838) 2023-10-23 15:56:22 +02:00
1892963fcb eiger required fw version to 32: fix for blocking trigger in quad (#834) 2023-10-18 17:04:39 +02:00
62f45b15d2 dev jf: reconfigure chip when touching electron collection mode bit (#831)
* jf: if bit 14 in reg 0x5d (electron mode collection bit) is changed, configure chip if v1.1 and powered on. so touch writeregister (setbit/clearbit also calls write register in the end). replace when electroncollectionmode command introduced
2023-10-18 10:52:22 +02:00
82ac45873c dev jf: change status reg bits (#829)
* jf: rewrite of status reg bits, waiting state includes both wati for trigger and start frame, blocking trigger only waits if its not in waiting for trigger and run busy enabled, error state connected in firmware
2023-10-18 10:47:52 +02:00
2b2e50916c dev: jf sync: stopping master gives idle (#824)
* jf sync mode master could return idle when stopped and so not all modules return the same value and must check for 'stopped or idle', Also must throw if any of the module gives an error

* added contains_only to sls::Result (#827)

* added variadic template for checking if a result contains only specified values

* fix for gcc4.8

* renamed to Result::contains_only

* updated condition in Detector.cpp

* stop on only the positions

---------

Co-authored-by: Erik Fröjdh <erik.frojdh@gmail.com>
2023-10-13 15:25:41 +02:00
137 changed files with 184719 additions and 11233 deletions

View File

@ -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

View File

@ -0,0 +1 @@
# This file is generated by cmake for dependency checking of the CMakeCache.txt file

View 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()
@ -244,6 +244,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
View File

@ -0,0 +1 @@
slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh

2
cmk.sh
View File

@ -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

View File

@ -2,7 +2,6 @@ python:
- 3.8
- 3.9
- 3.10
- 3.11
- 3.11
- 3.12
numpy:
- 1.17

View File

@ -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:

View File

@ -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)

View File

@ -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)

View File

@ -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:

View File

@ -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);

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,3 +1,5 @@
.. _Result Class:
Result
==============================================

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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+

View File

@ -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

View File

@ -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'),
],

View File

@ -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
@ -475,7 +479,8 @@ class Detector(CppDetectorApi):
@element
def gaincaps(self):
"""
[Mythen3] Gain caps. Enum: M3_GainCaps \n
[Mythen3] Gain caps.
Enum: M3_GainCaps
Note
----
@ -573,8 +578,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
@ -641,9 +644,6 @@ class Detector(CppDetectorApi):
"""
[Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] Delay after trigger, accepts either a value in seconds, DurationWrapper or datetime.timedelta
Note
-----
:getter: always returns in seconds. To get in DurationWrapper, use getDelayAfterTrigger
Example
@ -895,7 +895,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 +970,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 +1567,8 @@ class Detector(CppDetectorApi):
@property
@element
def status(self):
"""Gets detector status. Enum: runStatus
"""Gets detector status.
Enum: runStatus
Note
-----
@ -1579,7 +1582,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 +1677,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 +1812,7 @@ class Detector(CppDetectorApi):
def daclist(self):
"""
List of enums/names for every dac for this detector
:setter: Only implemented for Chiptestboard
"""
@ -1815,9 +1825,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 +1836,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 +1847,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 +1859,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 +1878,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 +1886,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 +1951,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
----
@ -2056,8 +2060,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 +2084,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 +2174,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 +2235,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 +2500,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())
@ -2777,7 +2777,8 @@ class Detector(CppDetectorApi):
@property
def gainmode(self):
"""
[Jungfrau] Detector gain mode. Enum: gainMode
[Jungfrau] Detector gain mode.
Enum: gainMode
Note
-----
@ -2890,11 +2891,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 +2910,8 @@ class Detector(CppDetectorApi):
@element
def timingsource(self):
"""
[Gotthard2] Timing source. Enum: timingSourceType
[Gotthard2] Timing source.
Enum: timingSourceType
Note
-----
@ -2956,7 +2955,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 +2974,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 +3096,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
----
@ -3273,7 +3271,8 @@ class Detector(CppDetectorApi):
@element
def romode(self):
"""
[CTB] Readout mode of detector. Enum: readoutMode
[CTB] Readout mode of detector.
Enum: readoutMode
Note
------
@ -3379,9 +3378,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 +3422,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 +3471,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 +3495,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 +3520,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 +3540,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 +3557,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 +3575,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 +3592,7 @@ class Detector(CppDetectorApi):
@property
@element
def patwait0(self):
"""[Ctb][Mythen3] Wait 0 address.
"""[Ctb][Mythen3][Xilinx Ctb] Wait 0 address.
Example
--------
@ -3625,7 +3612,7 @@ class Detector(CppDetectorApi):
@property
@element
def patwait1(self):
"""[Ctb][Mythen3] Wait 1 address.
"""[Ctb][Mythen3][Xilinx Ctb] Wait 1 address.
Example
--------
@ -3645,7 +3632,7 @@ class Detector(CppDetectorApi):
@property
@element
def patwait2(self):
"""[Ctb][Mythen3] Wait 2 address.
"""[Ctb][Mythen3][Xilinx Ctb] Wait 2 address.
Example
--------
@ -3665,7 +3652,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 +3669,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 +3680,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 +3691,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 +3703,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 +3720,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 +3740,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 +3761,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 +3783,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 +3800,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 +3811,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 +3822,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
@ -3919,10 +3906,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 +3916,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 +3925,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 +3934,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 +3943,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 +3992,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 +4026,6 @@ class Detector(CppDetectorApi):
"""
[Gotthard2][Mythen3] Frequency of clock in Hz.
Note
----
:setter: Not implemented. Use clkdiv to set frequency
Example
@ -4079,7 +4045,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

View File

@ -28,10 +28,6 @@
@li version is the version number of this structure format
*/
#include <algorithm>
#include <numeric>
#include <tuple>
namespace strixelSingleChip {
constexpr int nc_rawimg = 1024; // for full images //256;
constexpr int nr_rawimg = 512;
@ -81,7 +77,7 @@ constexpr int c6g1_ystart = c6g2_yend + 1; // 448
constexpr int c6g1_yend = c6g2_yend + 64 - gr; // 502
// y shift due to faulty bonding (relevant for M408)
constexpr int bond_shift_y = 0; // CHANGE IF YOU CHANGE MODULE!
constexpr int bond_shift_y = 1; // CHANGE IF YOU CHANGE MODULE!
} // namespace strixelSingleChip
@ -101,13 +97,6 @@ class jungfrauLGADStrixelsData : public slsDetectorData<uint16_t> {
int chip_x0;
int chip_y0;
int x0, y0, x1, y1, shifty;
struct {
uint16_t xmin;
uint16_t xmax;
uint16_t ymin;
uint16_t ymax;
int nc;
} globalROI;
int getMultiplicator(const int group) {
int multiplicator;
@ -226,113 +215,9 @@ class jungfrauLGADStrixelsData : public slsDetectorData<uint16_t> {
}
}
std::tuple< uint16_t, uint16_t, uint16_t, uint16_t > adjustROItoLimits(uint16_t xmin,
uint16_t xmax,
uint16_t ymin,
uint16_t ymax,
uint16_t lim_roi_xmin,
uint16_t lim_roi_xmax,
uint16_t lim_roi_ymin,
uint16_t lim_roi_ymax) {
uint16_t xmin_roi, xmax_roi, ymin_roi, ymax_roi;
if ( xmin < lim_roi_xmin)
xmin_roi = lim_roi_xmin;
else
xmin_roi = xmin;
if ( xmax > lim_roi_xmax )
xmax_roi = lim_roi_xmax;
else
xmax_roi = xmax;
if ( ymin < lim_roi_ymin )
ymin_roi = lim_roi_ymin;
else
ymin_roi = ymin;
if ( ymax > lim_roi_ymax )
ymax_roi = lim_roi_ymax;
else
ymax_roi = ymax;
return std::make_tuple(xmin_roi, xmax_roi, ymin_roi, ymax_roi);
}
std::vector < std::tuple< int, int, uint16_t, uint16_t, uint16_t, uint16_t > > mapSubROIs(uint16_t xmin,
uint16_t xmax,
uint16_t ymin,
uint16_t ymax) {
bool chip_1_1 = false;
bool chip_1_2 = false;
bool chip_1_3 = false;
bool chip_6_1 = false;
bool chip_6_2 = false;
bool chip_6_3 = false;
for ( int x=xmin; x!=xmax+1; ++x ) {
for ( int y=ymin; y!=ymax; ++y ) {
if ( c1g1_xstart<=x && x<=c1_xend && (c1g1_ystart+bond_shift_y)<=y && y<=(c1g1_yend+bond_shift_y) )
chip_1_1 = true;
if ( c1g2_xstart<=x && x<=c1_xend && (c1g2_ystart+bond_shift_y)<=y && y<=(c1g2_yend+bond_shift_y) )
chip_1_2 = true;
if ( c1g3_xstart<=x && x<=c1_xend && (c1g3_ystart+bond_shift_y)<=y && y<=(c1g3_yend+bond_shift_y) )
chip_1_3 = true;
if ( c6_xstart<=x && x<=c6g1_xend && (c6g1_ystart-bond_shift_y)<=y && y<=(c6g1_yend-bond_shift_y) )
chip_6_1 = true;
if ( c6_xstart<=x && x<=c6g2_xend && (c6g2_ystart-bond_shift_y)<=y && y<=(c6g2_yend-bond_shift_y) )
chip_6_2 = true;
if ( c6_xstart<=x && x<=c6g3_xend && (c6g3_ystart-bond_shift_y)<=y && y<=(c6g3_yend-bond_shift_y) )
chip_6_3 = true;
}
}
uint16_t xmin_roi{}, xmax_roi{}, ymin_roi{}, ymax_roi{};
//[ chip, group, xmin, xmax, ymin, ymax ]
std::vector < std::tuple< int, int, uint16_t, uint16_t, uint16_t, uint16_t > > rois{};
if (chip_1_1) {
std::tie( xmin_roi, xmax_roi, ymin_roi, ymax_roi ) =
adjustROItoLimits( xmin, xmax, ymin, ymax,
c1g1_xstart, c1_xend, 0, c1g1_yend+bond_shift_y );
rois.push_back( std::make_tuple( 1, 1, xmin_roi, xmax_roi, ymin_roi, ymax_roi ) );
}
if (chip_1_2) {
std::tie( xmin_roi, xmax_roi, ymin_roi, ymax_roi ) =
adjustROItoLimits( xmin, xmax, ymin, ymax,
c1g2_xstart, c1_xend, c1g2_ystart+bond_shift_y, c1g2_yend+bond_shift_y );
rois.push_back( std::make_tuple( 1, 2, xmin_roi, xmax_roi, ymin_roi, ymax_roi ) );
}
if (chip_1_3) {
std::tie( xmin_roi, xmax_roi, ymin_roi, ymax_roi ) =
adjustROItoLimits( xmin, xmax, ymin, ymax,
c1g3_xstart, c1_xend, c1g3_ystart+bond_shift_y, c1g3_yend+bond_shift_y );
rois.push_back( std::make_tuple( 1, 3, xmin_roi, xmax_roi, ymin_roi, ymax_roi ) );
}
if (chip_6_3) {
std::tie( xmin_roi, xmax_roi, ymin_roi, ymax_roi ) =
adjustROItoLimits( xmin, xmax, ymin, ymax,
c6_xstart, c6g3_xend, c6g3_ystart-bond_shift_y, c6g3_yend-bond_shift_y );
rois.push_back( std::make_tuple( 6, 3, xmin_roi, xmax_roi, ymin_roi, ymax_roi ) );
}
if (chip_6_2) {
std::tie( xmin_roi, xmax_roi, ymin_roi, ymax_roi ) =
adjustROItoLimits( xmin, xmax, ymin, ymax,
c6_xstart, c6g2_xend, c6g2_ystart-bond_shift_y, c6g2_yend-bond_shift_y );
rois.push_back( std::make_tuple( 6, 2, xmin_roi, xmax_roi, ymin_roi, ymax_roi ) );
}
if (chip_6_1) {
std::tie( xmin_roi, xmax_roi, ymin_roi, ymax_roi ) =
adjustROItoLimits( xmin, xmax, ymin, ymax,
c6_xstart, c6g1_xend, c6g1_ystart-bond_shift_y, 511 );
rois.push_back( std::make_tuple( 6, 1, xmin_roi, xmax_roi, ymin_roi, ymax_roi ) );
}
return rois;
}
void remapROI(std::tuple< int, int, uint16_t, uint16_t, uint16_t, uint16_t > roi) {
void remapROI(uint16_t xmin, uint16_t xmax, uint16_t ymin, uint16_t ymax) {
// determine group and chip selected by ROI
int group, xmin, xmax, ymin, ymax;
std::tie( mchip, group, xmin, xmax, ymin, ymax ) = roi;
/*
int group;
if (ymax <= c1g1_yend + bond_shift_y) {
group = 1;
mchip = 1;
@ -358,17 +243,18 @@ class jungfrauLGADStrixelsData : public slsDetectorData<uint16_t> {
group = -1;
mchip = -1;
}
*/
int multiplicator = getMultiplicator(group);
setMappingShifts(group);
std::cout << "remapping chip: " << mchip << ", group: " << group << ", m: " << multiplicator
std::cout << "chip: " << mchip << ", group: " << group << ", m: " << multiplicator
<< ", x0: " << x0 << ", x1: " << x1 << ", y0: " << y0
<< ", y1: " << y1 << std::endl;
std::cout << "Adjusted roi: [" << xmin << ", " << xmax << ", " << ymin << ", " << ymax << "]" << std::endl;
// get ROI raw image number of columns
int nc_roi = xmax - xmin + 1;
std::cout << "nc_roi = " << nc_roi << std::endl;
// make sure loop bounds are correct
/*
if (y0 < ymin)
std::cout << "Error ymin" << std::endl;
if (y1 > ymax)
@ -378,7 +264,6 @@ class jungfrauLGADStrixelsData : public slsDetectorData<uint16_t> {
std::cout << "Error xmin" << std::endl;
if (x1 > xmax)
std::cout << "Error xmax" << std::endl;
*/
// remapping loop
int ix, iy = 0;
@ -392,10 +277,8 @@ class jungfrauLGADStrixelsData : public slsDetectorData<uint16_t> {
}
// if (iy< 40) cout << iy << " " << ix <<endl;
if ( ipx>=xmin && ipx<=xmax && ipy>=ymin && ipy <=ymax )
dataMap[iy][ix] =
sizeof(header) + (globalROI.nc * (ipy - globalROI.ymin) + (ipx - globalROI.xmin)) * 2;
else dataMap[iy][ix] = sizeof(header);
dataMap[iy][ix] =
sizeof(header) + (nc_roi * (ipy - ymin) + (ipx - xmin)) * 2;
groupmap[iy][ix] = group - 1;
}
}
@ -424,31 +307,16 @@ class jungfrauLGADStrixelsData : public slsDetectorData<uint16_t> {
}
}
globalROI.xmin = xmin;
globalROI.xmax = xmax;
globalROI.ymin = ymin;
globalROI.ymax = ymax;
std::cout << "sizeofheader = " << sizeof(header) << std::endl;
std::cout << "Jungfrau strixels 2X single chip with full module data "
<< std::endl;
if (xmin < xmax && ymin < ymax) {
// get ROI raw image number of columns
globalROI.nc = xmax - xmin + 1;
std::cout << "nc_roi = " << globalROI.nc << std::endl;
dataSize =
(xmax - xmin + 1) * (ymax - ymin + 1) * 2 + sizeof(header);
std::cout << "datasize " << dataSize << std::endl;
//[ chip, group, xmin, xmax, ymin, ymax ]
auto rois = mapSubROIs(xmin, xmax, ymin, ymax);
//function to fill vector of rois from globalROI
for ( auto roi : rois )
remapROI(roi);
dataSize =
(xmax - xmin + 1) * (ymax - ymin + 1) * 2 + sizeof(header);
std::cout << "datasize " << dataSize << std::endl;
remapROI(xmin, xmax, ymin, ymax);
} else {

View File

@ -3,7 +3,6 @@
#ifndef JUNGFRAUMODULEDATA_H
#define JUNGFRAUMODULEDATA_H
#include <cstdint>
#include "sls/sls_detector_defs.h"
#include "slsDetectorData.h"
//#define VERSION_V2
@ -28,7 +27,7 @@ typedef struct {
uint64_t bunchNumber; /**< is the frame number */
uint64_t pre; /**< something */
} jf_header; //Aldo's header!
} jf_header;
using namespace std;
class jungfrauModuleData : public slsDetectorData<uint16_t> {
@ -43,56 +42,20 @@ class jungfrauModuleData : public slsDetectorData<uint16_t> {
1286 large etc.) \param c crosstalk parameter for the output buffer
*/
#ifdef ALDO
using header = jf_header;
#else
using header = sls::defs::sls_receiver_header;
#endif
#ifndef ZMQ
#define off sizeof(header)
#define off sizeof(jf_header)
#endif
#ifdef ZMQ
#define off 0
#endif
jungfrauModuleData(uint16_t xmin=0, uint16_t xmax=0,
uint16_t ymin=0, uint16_t ymax=0)
jungfrauModuleData()
: slsDetectorData<uint16_t>(1024, 512,
1024* 512 * 2 + off) {
for (int ix = 0; ix != 1024; ++ix) {
for (int iy = 0; iy != 512; ++iy) {
dataMap[iy][ix] = off;
}
}
if (xmin < xmax && ymin < ymax) {
int nc_roi = xmax - xmin + 1;
int nr_roi = ymax - ymin + 1;
std::cout << "nc_roi = " << nc_roi << std::endl;
std::cout << "nr_roi = " << nr_roi << std::endl;
dataSize =
(xmax - xmin + 1) * (ymax - ymin + 1) * 2 + off;
std::cout << "datasize " << dataSize << std::endl;
for (int ix = xmin; ix < xmax+1; ++ix) {
for (int iy = ymin; iy < ymax+1; ++iy) {
dataMap[iy][ix] = off + (nc_roi * iy + ix) * 2;
#ifdef HIGHZ
dataMask[iy][ix] = 0x3fff;
#endif
}
}
} else {
for (int ix = 0; ix < 1024; ++ix) {
for (int iy = 0; iy < 512; ++iy) {
for (int ix = 0; ix < 1024; ix++) {
for (int iy = 0; iy < 512; iy++) {
dataMap[iy][ix] = off + (1024 * iy + ix) * 2;
#ifdef HIGHZ
dataMask[iy][ix] = 0x3fff;
@ -100,7 +63,7 @@ class jungfrauModuleData : public slsDetectorData<uint16_t> {
}
}
}
iframe = 0;
@ -187,7 +150,7 @@ class jungfrauModuleData : public slsDetectorData<uint16_t> {
//int pn;
// cout << dataSize << endl;
//if (ff >= 0)
if (ff >= 0)
//fnum = ff;
if (filebin.is_open()) {

View File

@ -7,7 +7,6 @@
set(JUNGFRAU_EXECUTABLES)
find_package(fmt REQUIRED)
find_package(nlohmann_json 3.11.2 REQUIRED)
# jungfrauRawDataProcess
add_executable(jungfrauRawDataProcess jungfrauRawDataProcess.cpp)
@ -80,7 +79,6 @@ foreach(exe ${JUNGFRAU_EXECUTABLES})
pthread
tiffio
fmt::fmt
nlohmann_json::nlohmann_json
#-L/usr/lib64/
#-lm -lstdc++ -lrt

View File

@ -41,9 +41,6 @@
#include <ctime>
#include <fmt/core.h>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
std::string getRootString( const std::string& filepath ) {
size_t pos1 = filepath.find_last_of("/");
@ -64,24 +61,20 @@ std::string getRootString( const std::string& filepath ) {
std::string createFileName( const std::string& dir, const std::string& fprefix="run", const std::string& fsuffix="", const std::string& fext="raw", int aindex=0, int mindex=0, int findex=0, int outfilecounter=-1 ) {
if (outfilecounter >= 0)
return fmt::format("{:s}/{:s}_d{:d}_f{:d}_{:d}_f{:05d}.{:s}", dir, fprefix, mindex, findex, aindex, outfilecounter, fext);
else if (fsuffix.length()!=0) {
if (fsuffix == "master")
return fmt::format("{:s}/{:s}_master_{:d}.{:s}", dir, fprefix, aindex, fext);
else
return fmt::format("{:s}/{:s}_{:s}.{:s}", dir, fprefix, fsuffix, fext);
}
else if (fsuffix.length()!=0)
return fmt::format("{:s}/{:s}_{:s}.{:s}", dir, fprefix, fsuffix, fext);
else
return fmt::format("{:s}/{:s}_d{:d}_f{:d}_{:d}.{:s}", dir, fprefix, mindex, findex, aindex, fext);
}
int main(int argc, char *argv[]) {
if (argc < 6) {
if (argc < 5) {
std::cout
<< "Usage is " << argv[0]
<< "indir outdir [fprefix(excluding slsDetector standard suffixes and extension)] [fextension] "
"[fmin] [fmax] [runmin] [runmax] [pedfile (raw or tiff)] [threshold] "
"[nframes] [xmin xmax ymin ymax] [optional: bool read rxroi from data file header] [gainmap]"
<< "indir outdir fprefix(excluding slsDetector standard suffixes and extension) fextension "
"[runmin] [runmax] [pedfile (raw or tiff)] [threshold] "
"[nframes] [xmin xmax ymin ymax] [gainmap]"
<< std::endl;
std::cout
<< "threshold <0 means analog; threshold=0 means cluster finder; "
@ -113,71 +106,36 @@ int main(int argc, char *argv[]) {
std::string outdir(argv[2]);
std::string fprefix(argv[3]);
std::string fext(argv[4]);
int fmin = 0;
if (argc >= 6)
fmin = atoi(argv[5]);
int fmax = fmin;
if (argc >= 7)
fmax = atoi(argv[6]);
int runmin = 0;
// cout << "argc is " << argc << endl;
if (argc >= 8) {
runmin = atoi(argv[7]);
if (argc >= 6) {
runmin = atoi(argv[5]);
}
int runmax = runmin;
if (argc >= 9) {
runmax = atoi(argv[8]);
if (argc >= 7) {
runmax = atoi(argv[6]);
}
std::string pedfilename{};
if (argc >= 10) {
pedfilename = argv[9];
if (argc >= 8) {
pedfilename = argv[7];
}
double thr = 0;
double thr1 = 1;
if (argc >= 11) {
thr = atof(argv[10]);
if (argc >= 9) {
thr = atof(argv[8]);
}
int nframes = 0;
if (argc >= 12) {
nframes = atoi(argv[11]);
if (argc >= 10) {
nframes = atoi(argv[9]);
}
bool readrxroifromdatafile = false;
if (argc >= 17)
readrxroifromdatafile = atoi(argv[16]);
// Receiver ROI
uint16_t rxroi_xmin = 0;
uint16_t rxroi_xmax = 0;
uint16_t rxroi_ymin = 0;
uint16_t rxroi_ymax = 0;
{ //protective scope so ifstream gets destroyed properly
auto jsonmastername = createFileName( indir, fprefix, "master", "json", runmin );
std::cout << "json master file " << jsonmastername << std::endl;
std::ifstream masterfile(jsonmastername); //, ios::in | ios::binary);
if (masterfile.is_open()) {
json j;
masterfile >> j;
rxroi_xmin = j["Receiver Roi"]["xmin"];
rxroi_xmax = j["Receiver Roi"]["xmax"];
rxroi_ymin = j["Receiver Roi"]["ymin"];
rxroi_ymax = j["Receiver Roi"]["ymax"];
masterfile.close();
std::cout << "Read Receiver ROI [" << rxroi_xmin << ", " << rxroi_xmax << ", "
<< rxroi_ymin << ", " << rxroi_ymax << "] from json master file" << std::endl;
} else
std::cout << "Could not open master file " << jsonmastername << std::endl;
}
// Define decoders...
#if !defined JFSTRX && !defined JFSTRXOLD && !defined JFSTRXCHIP1 && \
!defined JFSTRXCHIP6
@ -186,52 +144,56 @@ int main(int argc, char *argv[]) {
int nx = 256, ny = 256;
#endif
#ifdef MODULE
jungfrauModuleData *decoder = new jungfrauModuleData(rxroi_xmin, rxroi_xmax, rxroi_ymin, rxroi_ymax);
jungfrauModuleData *decoder = new jungfrauModuleData();
int nx = 1024, ny = 512;
#endif
#endif
#ifdef JFSTRX
cout << "Jungfrau strixel full module readout" << endl;
// ROI
uint16_t xxmin = 0;
uint16_t xxmax = 0;
uint16_t yymin = 0;
uint16_t yymax = 0;
#ifndef ALDO
if (readrxroifromdatafile)
{ //THIS SCOPE IS IMPORTANT! (To ensure proper destruction of ifstream)
using header = sls::defs::sls_receiver_header;
// check if there is a roi in the header
typedef struct {
uint16_t xmin;
uint16_t xmax;
uint16_t ymin;
uint16_t ymax;
} receiverRoi_compact;
receiverRoi_compact croi;
std::string fsuffix{};
auto filename = createFileName( indir, fprefix, fsuffix, fext, runmin );
std::cout << "Reading header of file " << filename << " to check for ROI "
<< std::endl;
ifstream firstfile(filename, ios::in | ios::binary);
if (firstfile.is_open()) {
header hbuffer;
std::cout << "sizeof(header) = " << sizeof(header) << std::endl;
if (firstfile.read((char *)&hbuffer, sizeof(header))) {
memcpy(&croi, &hbuffer.detHeader.detSpec1, 8);
std::cout << "Read ROI [" << croi.xmin << ", " << croi.xmax << ", "
<< croi.ymin << ", " << croi.ymax << "]" << std::endl;
rxroi_xmin = croi.xmin;
rxroi_xmax = croi.xmax;
rxroi_ymin = croi.ymin;
rxroi_ymax = croi.ymax;
} else
std::cout << "reading error" << std::endl;
firstfile.close();
} else
std::cout << "Could not open " << filename << " for reading " << std::endl;
} //end of protective scope
{ //THIS SCOPE IS IMPORTANT! (To ensure proper destruction of ifstream)
using header = sls::defs::sls_receiver_header;
// check if there is a roi in the header
typedef struct {
uint16_t xmin;
uint16_t xmax;
uint16_t ymin;
uint16_t ymax;
} receiverRoi_compact;
receiverRoi_compact croi;
std::string fsuffix{};
auto filename = createFileName( indir, fprefix, fsuffix, fext, runmin );
std::cout << "Reading header of file " << filename << " to check for ROI "
<< std::endl;
ifstream firstfile(filename, ios::in | ios::binary);
if (firstfile.is_open()) {
header hbuffer;
std::cout << "sizeof(header) = " << sizeof(header) << std::endl;
if (firstfile.read((char *)&hbuffer, sizeof(header))) {
memcpy(&croi, &hbuffer.detHeader.detSpec1, 8);
std::cout << "Read ROI [" << croi.xmin << ", " << croi.xmax << ", "
<< croi.ymin << ", " << croi.ymax << "]" << std::endl;
xxmin = croi.xmin;
xxmax = croi.xmax;
yymin = croi.ymin;
yymax = croi.ymax;
} else
std::cout << "reading error" << std::endl;
firstfile.close();
} else
std::cout << "Could not open " << filename << " for reading " << std::endl;
} //end of protective scope
#endif
jungfrauLGADStrixelsData *decoder =
new jungfrauLGADStrixelsData(rxroi_xmin, rxroi_xmax, rxroi_ymin, rxroi_ymax);
new jungfrauLGADStrixelsData(xxmin, xxmax, yymin, yymax);
int nx = 1024 / 3, ny = 512 * 5;
#endif
#ifdef JFSTRXCHIP1
@ -256,20 +218,19 @@ int main(int argc, char *argv[]) {
decoder->getDetectorSize(nx, ny);
std::cout << "Detector size is " << nx << " " << ny << std::endl;
//Cluster finder ROI
int xmin = 0, xmax = nx-1, ymin = 0, ymax = ny-1;
if (argc >= 16) {
xmin = atoi(argv[12]);
xmax = atoi(argv[13]);
ymin = atoi(argv[14]);
ymax = atoi(argv[15]);
int xmin = 0, xmax = nx, ymin = 0, ymax = ny;
if (argc >= 14) {
xmin = atoi(argv[10]);
xmax = atoi(argv[11]);
ymin = atoi(argv[12]);
ymax = atoi(argv[13]);
}
std::cout << "Cluster finder ROI: [" << xmin << ", " << xmax << ", " << ymin << ", " << ymax << "]"
std::cout << xmin << " " << xmax << " " << ymin << " " << ymax << " "
<< std::endl;
char *gainfname = NULL;
if (argc > 17) {
gainfname = argv[17];
if (argc > 14) {
gainfname = argv[14];
std::cout << "Gain map file name is: " << gainfname << std::endl;
}
@ -278,8 +239,6 @@ int main(int argc, char *argv[]) {
std::cout << "input directory is " << indir << std::endl;
std::cout << "output directory is " << outdir << std::endl;
std::cout << "input file prefix is " << fprefix << std::endl;
std::cout << "fmin is " << fmin << std::endl;
std::cout << "fmax is " << fmax << std::endl;
std::cout << "runmin is " << runmin << std::endl;
std::cout << "runmax is " << runmax << std::endl;
if (pedfilename.length()!=0)
@ -360,7 +319,7 @@ int main(int argc, char *argv[]) {
mt->setFrameMode(ePedestal);
std::ifstream pedefile(fname, ios::in | ios::binary);
ifstream pedefile(fname, ios::in | ios::binary);
// //open file
if (pedefile.is_open()) {
std::cout << "bbbb " << std::ctime(&end_time) << std::endl;
@ -421,27 +380,26 @@ int main(int argc, char *argv[]) {
}
ifr = 0;
int ioutfile = 0;
int ifile = 0;
mt->setFrameMode(eFrame);
FILE *of = NULL;
for (int irun = runmin; irun <= runmax; ++irun) {
for (int ifile = fmin; ifile <= fmax; ++ifile) {
for (int irun = runmin; irun <= runmax; irun++) {
std::cout << "DATA ";
std::string fsuffix{};
auto fname = createFileName( indir, fprefix, fsuffix, fext, irun, 0, ifile );
auto imgfname = createFileName( outdir, fprefix, fsuffix, "tiff", irun, 0, ifile );
auto cfname = createFileName( outdir, fprefix, fsuffix, "clust", irun, 0, ifile );
auto fname = createFileName( indir, fprefix, fsuffix, fext, irun );
auto imgfname = createFileName( outdir, fprefix, fsuffix, "tiff", irun );
auto cfname = createFileName( outdir, fprefix, fsuffix, "clust", irun );
std::cout << fname << " ";
std::cout << imgfname << std::endl;
std::time(&end_time);
std::cout << std::ctime(&end_time) << std::endl;
// std::cout << fname << " " << outfname << " " << imgfname << std::endl;
std::ifstream filebin(fname, ios::in | ios::binary);
ifstream filebin(fname, ios::in | ios::binary);
// //open file
ioutfile = 0;
ifile = 0;
if (filebin.is_open()) {
if (thr <= 0 && cf != 0) { // cluster finder
if (of == NULL) {
@ -478,10 +436,10 @@ int main(int argc, char *argv[]) {
std::cout << " " << ifr << " " << ff << std::endl;
if (nframes > 0) {
if (ifr % nframes == 0) {
imgfname = createFileName( outdir, fprefix, fsuffix, "tiff", irun, 0, 0, ioutfile );
imgfname = createFileName( outdir, fprefix, fsuffix, "tiff", irun, 0, 0, ifile );
mt->writeImage(imgfname.c_str(), thr1);
mt->clearImage();
ioutfile++;
ifile++;
}
}
// } else
@ -495,7 +453,7 @@ int main(int argc, char *argv[]) {
}
if (nframes >= 0) {
if (nframes > 0)
imgfname = createFileName( outdir, fprefix, fsuffix, "tiff", irun, 0, 0, ioutfile );
imgfname = createFileName( outdir, fprefix, fsuffix, "tiff", irun, 0, 0, ifile );
std::cout << "Writing tiff to " << imgfname << " " << thr1
<< std::endl;
mt->writeImage(imgfname.c_str(), thr1);
@ -511,10 +469,9 @@ int main(int argc, char *argv[]) {
} else
std::cout << "Could not open " << fname << " for reading "
<< std::endl;
}
}
if (nframes < 0) {
auto imgfname = createFileName( outdir, fprefix, "sum", "tiff", runmin, 0, fmin, -1 );
auto imgfname = createFileName( outdir, fprefix, "sum", "tiff", -1, 0, 0, -1 );
std::cout << "Writing tiff to " << imgfname << " " << thr1 << std::endl;
mt->writeImage(imgfname.c_str(), thr1);
}

View File

@ -41,9 +41,6 @@
#include <ctime>
#include <fmt/core.h>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
std::string getRootString( const std::string& filepath ) {
size_t pos1;
@ -74,11 +71,11 @@ std::string createFileName( const std::string& dir, const std::string& fprefix="
//NOTE THAT THE DATA FILES HAVE TO BE IN THE RIGHT ORDER SO THAT PEDESTAL TRACKING WORKS!
int main(int argc, char *argv[]) {
if (argc < 11) {
if (argc < 10) {
std::cout
<< "Usage is " << argv[0]
<< " filestxt outdir [json master] [pedfile (raw or tiff)] [xmin xmax ymin ymax] "
"[threshold] [nframes] [optional: bool read rxroi from data file header]"
<< " filestxt outdir [pedfile (raw or tiff)] [xmin xmax ymin ymax] "
"[threshold] [nframes] "
"NOTE THAT THE DATA FILES HAVE TO BE IN THE RIGHT ORDER SO THAT PEDESTAL TRACKING WORKS! "
<< std::endl;
std::cout
@ -108,19 +105,19 @@ int main(int argc, char *argv[]) {
const std::string txtfilename(argv[1]);
const std::string outdir(argv[2]);
const std::string jsonmastername(argv[3]);
const std::string pedfilename(argv[4]);
const std::string pedfilename(argv[3]);
int xmin = atoi(argv[4]);
int xmax = atoi(argv[5]);
int ymin = atoi(argv[6]);
int ymax = atoi(argv[7]);
double thr = 0;
double thr1 = 1;
thr = atof(argv[9]);
thr = atof(argv[8]);
int nframes = 0;
nframes = atoi(argv[10]);
bool readrxroifromdatafile = false;
if (argc > 11)
readrxroifromdatafile = atoi(argv[11]);
nframes = atoi(argv[9]);
//Get vector of filenames from input txt-file
std::vector<std::string> filenames{};
@ -149,31 +146,7 @@ int main(int argc, char *argv[]) {
}
std::cout << "###############" << std::endl;
// Receiver ROI
uint16_t rxroi_xmin = 0;
uint16_t rxroi_xmax = 0;
uint16_t rxroi_ymin = 0;
uint16_t rxroi_ymax = 0;
{ //protective scope so ifstream gets destroyed properly
std::ifstream masterfile(jsonmastername); //, ios::in | ios::binary);
if (masterfile.is_open()) {
json j;
masterfile >> j;
rxroi_xmin = j["Receiver Roi"]["xmin"];
rxroi_xmax = j["Receiver Roi"]["xmax"];
rxroi_ymin = j["Receiver Roi"]["ymin"];
rxroi_ymax = j["Receiver Roi"]["ymax"];
masterfile.close();
std::cout << "Read rxROI [" << rxroi_xmin << ", " << rxroi_xmax << ", "
<< rxroi_ymin << ", " << rxroi_ymax << "]" << std::endl;
} else
std::cout << "Could not open master file " << jsonmastername << std::endl;
}
// Define decoders...
#if !defined JFSTRX && !defined JFSTRXOLD && !defined JFSTRXCHIP1 && \
!defined JFSTRXCHIP6
@ -189,44 +162,48 @@ int main(int argc, char *argv[]) {
#ifdef JFSTRX
cout << "Jungfrau strixel full module readout" << endl;
// ROI
uint16_t xxmin = 0;
uint16_t xxmax = 0;
uint16_t yymin = 0;
uint16_t yymax = 0;
#ifndef ALDO
if (readrxroifromdatafile)
{ //THIS SCOPE IS IMPORTANT! (To ensure proper destruction of ifstream)
using header = sls::defs::sls_receiver_header;
// check if there is a roi in the header
typedef struct {
uint16_t xmin;
uint16_t xmax;
uint16_t ymin;
uint16_t ymax;
} receiverRoi_compact;
receiverRoi_compact croi;
//std::string filepath(argv[9]); //This is a problem if the input files have different ROIs!
std::cout << "Reading header of file " << filenames[0] << " to check for ROI "
<< std::endl;
std::ifstream firstfile( filenames[0], ios::in | ios::binary);
if (firstfile.is_open()) {
header hbuffer;
std::cout << "sizeof(header) = " << sizeof(header) << std::endl;
if (firstfile.read((char *)&hbuffer, sizeof(header))) {
memcpy(&croi, &hbuffer.detHeader.detSpec1, 8);
std::cout << "Read ROI [" << croi.xmin << ", " << croi.xmax << ", "
<< croi.ymin << ", " << croi.ymax << "]" << std::endl;
rxroi_xmin = croi.xmin;
rxroi_xmax = croi.xmax;
rxroi_ymin = croi.ymin;
rxroi_ymax = croi.ymax;
} else
std::cout << "reading error" << std::endl;
firstfile.close();
} else
std::cout << "Could not open " << filenames[0] << " for reading " << std::endl;
} //end of protective scope
{ //THIS SCOPE IS IMPORTANT! (To ensure proper destruction of ifstream)
using header = sls::defs::sls_receiver_header;
// check if there is a roi in the header
typedef struct {
uint16_t xmin;
uint16_t xmax;
uint16_t ymin;
uint16_t ymax;
} receiverRoi_compact;
receiverRoi_compact croi;
//std::string filepath(argv[9]); //This is a problem if the input files have different ROIs!
std::cout << "Reading header of file " << filenames[0] << " to check for ROI "
<< std::endl;
ifstream firstfile(filenames[0], ios::in | ios::binary);
if (firstfile.is_open()) {
header hbuffer;
std::cout << "sizeof(header) = " << sizeof(header) << std::endl;
if (firstfile.read((char *)&hbuffer, sizeof(header))) {
memcpy(&croi, &hbuffer.detHeader.detSpec1, 8);
std::cout << "Read ROI [" << croi.xmin << ", " << croi.xmax << ", "
<< croi.ymin << ", " << croi.ymax << "]" << std::endl;
xxmin = croi.xmin;
xxmax = croi.xmax;
yymin = croi.ymin;
yymax = croi.ymax;
} else
std::cout << "reading error" << std::endl;
firstfile.close();
} else
std::cout << "Could not open " << filenames[0] << " for reading " << std::endl;
} //end of protective scope
#endif
jungfrauLGADStrixelsData *decoder =
new jungfrauLGADStrixelsData(rxroi_xmin, rxroi_xmax, rxroi_ymin, rxroi_ymax);
new jungfrauLGADStrixelsData(xxmin, xxmax, yymin, yymax);
int nx = 1024 / 3, ny = 512 * 5;
#endif
#ifdef JFSTRXCHIP1
@ -251,16 +228,7 @@ int main(int argc, char *argv[]) {
decoder->getDetectorSize(nx, ny);
std::cout << "Detector size is " << nx << " " << ny << std::endl;
//Cluster finder ROI
int xmin = 0, xmax = nx-1, ymin = 0, ymax = ny-1;
xmin = atoi(argv[5]);
xmax = atoi(argv[6]);
ymin = atoi(argv[7]);
ymax = atoi(argv[8]);
std::cout << "Cluster finder ROI: [" << xmin << ", " << xmax << ", " << ymin << ", " << ymax << "]"
<< std::endl;
/* old
if ( xmin == xmax ) {
xmin = 0;
xmax = nx;
@ -271,7 +239,6 @@ int main(int argc, char *argv[]) {
}
std::cout << xmin << " " << xmax << " " << ymin << " " << ymax << " "
<< std::endl;
*/
/*
char *gainfname = NULL;
@ -443,7 +410,7 @@ int main(int argc, char *argv[]) {
std::time(&end_time);
std::cout << std::ctime(&end_time) << std::endl;
std::ifstream filebin(filenames[ifile], ios::in | ios::binary);
ifstream filebin(filenames[ifile], ios::in | ios::binary);
// //open file
ioutfile = 0;
if (filebin.is_open()) {

View File

@ -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)));
}

View File

@ -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)

View File

@ -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'"

View File

@ -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'"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
@ -2924,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"));
@ -2964,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 {
@ -2977,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;
}
}

View File

@ -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);
}

View File

@ -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,7 +58,6 @@
/* 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)

View File

@ -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

View 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 <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);
int mapCSP0(void);

View File

@ -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) // TODO || defined(XILINX_CHIPTESTBOARDD)
uint64_t validate_readPatternIOControl();
int validate_writePatternIOControl(char *message, uint64_t arg);
void writePatternIOControl(uint64_t word);

View File

@ -25,6 +25,10 @@
#include "blackfin.h"
#endif
#ifdef ARMPROCESSOR
#include "arm64.h"
#endif
#ifdef MYTHEN3D
#include "mythen3.h"
#endif
@ -61,8 +65,7 @@ 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();
int testBus();
@ -81,13 +84,17 @@ u_int64_t getFirmwareVersion();
#ifdef EIGERD
uint64_t getFrontEndFirmwareVersion(enum fpgaPosition fpgaPosition);
#endif
#ifndef XILINX_CHIPTESTBOARDD
u_int64_t getFirmwareAPIVersion();
#endif
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 +118,6 @@ int updateModuleId();
void setModuleId(int modid);
#endif
#endif
u_int64_t getDetectorMAC();
u_int32_t getDetectorIP();
@ -136,7 +142,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);
@ -245,12 +251,14 @@ void setNumFrames(int64_t val);
int64_t getNumFrames();
void setNumTriggers(int64_t val);
int64_t getNumTriggers();
#ifndef XILINX_CHIPTESTBOARDD
#ifndef MYTHEN3D
int setExpTime(int64_t val);
int64_t getExpTime();
#endif
int setPeriod(int64_t val);
int64_t getPeriod();
#endif
#ifdef MYTHEN3D
void setNumIntGates(int val);
void setNumGates(int val);
@ -299,12 +307,15 @@ uint32_t getCounterMask();
void updatePacketizing();
#endif
#ifndef EIGERD
int64_t getNumFramesLeft();
int64_t getNumTriggersLeft();
#endif
#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARDD) || \
defined(CHIPTESTBOARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
int setDelayAfterTrigger(int64_t val);
int64_t getDelayAfterTrigger();
int64_t getNumFramesLeft();
int64_t getNumTriggersLeft();
int64_t getDelayAfterTriggerLeft();
int64_t getPeriodLeft();
#endif
@ -337,10 +348,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);
@ -366,10 +379,14 @@ void setDAC(enum DACINDEX ind, int val, int mV, int counterEnableCheck);
void setGeneralDAC(enum DACINDEX ind, int val, int mV);
void setVthDac(int index, int enable);
#else
#ifndef XILINX_CHIPTESTBOARDD
void setDAC(enum DACINDEX ind, int val, int mV);
#endif
#endif
#ifndef XILINX_CHIPTESTBOARDD
int getDAC(enum DACINDEX ind, int mV);
int getMaxDacSteps();
#endif
#if defined(CHIPTESTBOARDD)
int dacToVoltage(int dac);
int checkVLimitCompliant(int mV);
@ -394,14 +411,17 @@ void powerOff();
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
int getADC(enum ADCINDEX ind, int *value);
#else
#ifndef XILINX_CHIPTESTBOARDD
int getADC(enum ADCINDEX ind);
#endif
#endif
#ifdef CHIPTESTBOARDD
int getSlowADC(int ichan);
int getSlowADCTemperature();
#endif
#ifndef XILINX_CHIPTESTBOARDD
int setHighVoltage(int val);
#endif
// parameters - timing, extsig
#if defined(EIGERD) || defined(GOTTHARD2D) || defined(JUNGFRAUD) || \
@ -674,11 +694,13 @@ int setTransmissionDelayRight(int value);
#endif
// aquisition
#ifndef XILINX_CHIPTESTBOARDD
int startStateMachine();
#ifdef VIRTUAL
void *start_timer(void *arg);
#endif
int stopStateMachine();
#endif
#ifdef MYTHEN3D
int softwareTrigger();
#endif
@ -692,8 +714,10 @@ enum runStatus getRunStatus();
#ifdef EIGERD
void waitForAcquisitionEnd(int *ret, char *mess);
#else
#ifndef XILINX_CHIPTESTBOARDD
void waitForAcquisitionEnd();
#endif
#endif
#if defined(CHIPTESTBOARDD)
int validateUDPSocket();
void readandSendUDPFrames();
@ -714,11 +738,15 @@ u_int32_t runState(enum TLogLevel lev);
#endif
// common
#ifndef XILINX_CHIPTESTBOARDD
int calculateDataBytes();
int getTotalNumberOfChannels();
#if defined(CHIPTESTBOARDD)
#endif
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
void getNumberOfChannels(int *nchanx, int *nchany);
#endif
#ifndef XILINX_CHIPTESTBOARDD
int getNumberOfChips();
int getNumberOfDACs();
int getNumberOfChannelsPerChip();
#endif

View File

@ -0,0 +1,73 @@
// 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 (0xB0010000)
#define MEM_SIZE 0x100000
u_int32_t *csp0base = 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));
}
int mapCSP0(void) {
// if not mapped
if (csp0base == 0) {
LOG(logINFO, ("Mapping memory\n"));
#ifdef VIRTUAL
csp0base = malloc(MEM_SIZE);
if (csp0base == NULL) {
LOG(logERROR, ("Could not allocate virtual memory.\n"));
return FAIL;
}
LOG(logINFO, ("memory allocated\n"));
#else
int fd;
fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
if (fd == -1) {
LOG(logERROR, ("Can't find /dev/mem\n"));
return FAIL;
}
LOG(logDEBUG1, ("/dev/mem opened\n"));
csp0base = (u_int32_t *)mmap(0, MEM_SIZE, PROT_READ | PROT_WRITE,
MAP_FILE | MAP_SHARED, fd, CSP0);
if (csp0base == MAP_FAILED) {
LOG(logERROR, ("Can't map memmory area\n"));
return FAIL;
}
#endif
LOG(logINFO, ("csp0base mapped from %p to %p\n", csp0base,
(csp0base + MEM_SIZE)));
} else
LOG(logINFO, ("Memory already mapped before\n"));
return OK;
}

View File

@ -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);
}

View File

@ -114,6 +114,10 @@ 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);
if (*result == -1) {
LOG(logERROR, ("Could not convert time structure to time_t\n"));
return FAIL;
}
return OK;
}
@ -143,14 +147,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 +174,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 +183,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;
}

View File

@ -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,13 +44,15 @@ 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) // TODO || defined(XILINX_CHIPTESTBOARDD)
uint64_t validate_readPatternIOControl() {
return getU64BitReg(PATTERN_IO_CNTRL_LSB_REG, PATTERN_IO_CNTRL_MSB_REG);
}
@ -101,7 +103,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 +120,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 +162,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 +180,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 +313,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 +371,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 +777,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 +837,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 +958,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 +973,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 +1065,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) {

View File

@ -7,7 +7,8 @@
#include "sls/sls_detector_funcs.h"
#include "slsDetectorFunctionList.h"
#if defined(CHIPTESTBOARDD) || defined(MYTHEN3D)
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) || \
defined(MYTHEN3D)
#include "Pattern.h"
#include "loadPattern.h"
#endif
@ -33,6 +34,8 @@ const enum detectorType myDetectorType = MOENCH;
const enum detectorType myDetectorType = MYTHEN3;
#elif GOTTHARD2D
const enum detectorType myDetectorType = GOTTHARD2;
#elif XILINX_CHIPTESTBOARDD
const enum detectorType myDetectorType = XILINX_CHIPTESTBOARD;
#else
const enum detectorType myDetectorType = GENERIC;
#endif
@ -532,6 +535,11 @@ int executeCommand(char *command, char *result, enum TLogLevel level) {
fflush(stdout);
FILE *sysFile = popen(cmd, "r");
if (sysFile == NULL) {
ret = FAIL;
sprintf(mess, "Executing cmd[%s] failed\n", cmd);
return ret;
}
while (fgets(temp, tempsize, sysFile) != NULL) {
// size left excludes terminating character
size_t sizeleft = MAX_STR_LENGTH - strlen(result) - 1;
@ -547,17 +555,15 @@ int executeCommand(char *command, char *result, enum TLogLevel level) {
if (strlen(result) == 0) {
strcpy(result, "No result");
}
int retval = OK;
int success = pclose(sysFile);
if (success) {
retval = FAIL;
LOG(logERROR, ("Executing cmd[%s]:%s\n", cmd, result));
if (success == -1) {
ret = FAIL;
strcpy(mess, result);
LOG(logERROR, ("Executing cmd[%s] failed:%s\n", cmd, mess));
} else {
LOG(level, ("Result:\n[%s]\n", result));
}
return retval;
return ret;
}
int M_nofunc(int file_des) {
@ -585,7 +591,7 @@ int exec_command(int file_des) {
// set
if (Server_VerifyLock() == OK) {
ret = executeCommand(cmd, retval, logINFO);
executeCommand(cmd, retval, logINFO);
}
return Server_SendResult(file_des, OTHER, retval, sizeof(retval));
}
@ -784,7 +790,7 @@ int get_serial_number(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
#ifdef EIGERD
#if defined(EIGERD) || defined(XILINX_CHIPTESTBOARDD)
functionNotImplemented();
#else
retval = getDetectorNumber();
@ -1116,6 +1122,8 @@ enum DACINDEX getDACIndex(enum dacIndex ind) {
case IBIAS_SFP:
serverDacIndex = MO_IBIAS_SFP;
break;
#elif XILINX_CHIPTESTBOARDD
#endif
default:
@ -1134,8 +1142,9 @@ enum DACINDEX getDACIndex(enum dacIndex ind) {
int validateAndSetDac(enum dacIndex ind, int val, int mV) {
int retval = -1;
enum DACINDEX serverDacIndex = 0;
#ifndef XILINX_CHIPTESTBOARDD
enum DACINDEX serverDacIndex = 0;
// valid enums
switch (ind) {
case HIGH_VOLTAGE:
@ -1386,6 +1395,7 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) {
#endif
break;
}
#endif
return retval;
}
@ -1398,6 +1408,9 @@ int set_dac(int file_des) {
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError();
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
enum dacIndex ind = args[0];
int mV = args[1];
int val = args[2];
@ -1408,6 +1421,7 @@ int set_dac(int file_des) {
if ((val == GET_FLAG) || (Server_VerifyLock() == OK)) {
retval = validateAndSetDac(ind, val, mV);
}
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
@ -1420,6 +1434,9 @@ int get_adc(int file_des) {
if (receiveData(file_des, &ind, sizeof(ind), INT32) < 0)
return printSocketReadError();
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
enum ADCINDEX serverAdcIndex = 0;
// get
@ -1541,6 +1558,7 @@ int get_adc(int file_des) {
LOG(logDEBUG1, ("ADC(%d): %d\n", serverAdcIndex, retval));
#endif
}
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
@ -1557,6 +1575,9 @@ int write_register(int file_des) {
uint32_t val = args[1];
LOG(logDEBUG1, ("Writing to register 0x%x, data 0x%x\n", addr, val));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
#ifdef GOTTHARDD
@ -1591,6 +1612,7 @@ int write_register(int file_des) {
}
LOG(logDEBUG1, ("Write register (0x%x): 0x%x\n", retval));
}
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
@ -1605,6 +1627,10 @@ int read_register(int file_des) {
LOG(logDEBUG1, ("Reading from register 0x%x\n", addr));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// get
#ifdef GOTTHARDD
retval = readRegister16And32(addr);
@ -1621,7 +1647,7 @@ int read_register(int file_des) {
retval = readRegister(addr);
#endif
LOG(logINFO, ("Read register (0x%x): 0x%x\n", addr, retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
@ -1825,7 +1851,7 @@ int set_settings(int file_des) {
if (receiveData(file_des, &isett, sizeof(isett), INT32) < 0)
return printSocketReadError();
#ifdef CHIPTESTBOARDD
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
functionNotImplemented();
#else
LOG(logDEBUG1, ("Setting settings %d\n", isett));
@ -1902,6 +1928,9 @@ int acquire(int blocking, int file_des) {
} else {
LOG(logINFOBLUE, ("Unblocking Acquisition\n"));
}
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
#if defined(JUNGFRAUD)
@ -1948,64 +1977,64 @@ int acquire(int blocking, int file_des) {
#ifdef EIGERD
// check for hardware mac and hardware ip
if (udpDetails[0].srcmac != getDetectorMAC()) {
ret = FAIL;
uint64_t sourcemac = getDetectorMAC();
char src_mac[MAC_ADDRESS_SIZE];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac);
sprintf(
mess,
ret = FAIL;
uint64_t sourcemac = getDetectorMAC();
char src_mac[MAC_ADDRESS_SIZE];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac);
sprintf(mess,
"Invalid udp source mac address for this detector. Must be "
"same as hardware detector mac address %s\n",
src_mac);
LOG(logERROR, (mess));
} else if (!enableTenGigabitEthernet(GET_FLAG) &&
(udpDetails[0].srcip != getDetectorIP())) {
ret = FAIL;
uint32_t sourceip = getDetectorIP();
char src_ip[INET_ADDRSTRLEN];
getIpAddressinString(src_ip, sourceip);
sprintf(
mess,
LOG(logERROR, (mess));
} else if (!enableTenGigabitEthernet(GET_FLAG) &&
(udpDetails[0].srcip != getDetectorIP())) {
ret = FAIL;
uint32_t sourceip = getDetectorIP();
char src_ip[INET_ADDRSTRLEN];
getIpAddressinString(src_ip, sourceip);
sprintf(mess,
"Invalid udp source ip address for this detector. Must be "
"same as hardware detector ip address %s in 1G readout "
"mode \n",
src_ip);
LOG(logERROR, (mess));
} else
LOG(logERROR, (mess));
} else
#endif
if (configured == FAIL) {
if (configured == FAIL) {
ret = FAIL;
strcpy(mess, "Could not start acquisition because ");
strcat(mess, configureMessage);
LOG(logERROR, (mess));
} else if (sharedMemory_getScanStatus() == RUNNING) {
ret = FAIL;
strcpy(mess, "Could not start acquisition because a scan is "
"already running!\n");
LOG(logERROR, (mess));
} else {
memset(scanErrMessage, 0, MAX_STR_LENGTH);
sharedMemory_setScanStop(0);
sharedMemory_setScanStatus(IDLE); // if it was error
if (pthread_create(&pthread_tid, NULL, &start_state_machine,
&blocking)) {
ret = FAIL;
strcpy(mess, "Could not start acquisition because ");
strcat(mess, configureMessage);
LOG(logERROR, (mess));
} else if (sharedMemory_getScanStatus() == RUNNING) {
ret = FAIL;
strcpy(mess, "Could not start acquisition because a scan is "
"already running!\n");
strcpy(mess, "Could not start acquisition thread!\n");
LOG(logERROR, (mess));
} else {
memset(scanErrMessage, 0, MAX_STR_LENGTH);
sharedMemory_setScanStop(0);
sharedMemory_setScanStatus(IDLE); // if it was error
if (pthread_create(&pthread_tid, NULL, &start_state_machine,
&blocking)) {
ret = FAIL;
strcpy(mess, "Could not start acquisition thread!\n");
LOG(logERROR, (mess));
} else {
// wait for blocking always (scan or not)
// non blocking-no scan also wait (for error message)
// non blcoking-scan dont wait (there is scanErrorMessage)
if (blocking || !scan) {
pthread_join(pthread_tid, NULL);
}
// wait for blocking always (scan or not)
// non blocking-no scan also wait (for error message)
// non blcoking-scan dont wait (there is scanErrorMessage)
if (blocking || !scan) {
pthread_join(pthread_tid, NULL);
}
}
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
void *start_state_machine(void *arg) {
#ifndef XILINX_CHIPTESTBOARDD
int *blocking = (int *)arg;
int times = 1;
// start of scan
@ -2131,6 +2160,7 @@ void *start_state_machine(void *arg) {
if (scan && sharedMemory_getScanStatus() != ERROR) {
sharedMemory_setScanStatus(IDLE);
}
#endif
return NULL;
}
@ -2148,6 +2178,9 @@ int stop_acquisition(int file_des) {
memset(mess, 0, sizeof(mess));
LOG(logDEBUG1, ("Stopping Acquisition\n"));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
ret = stopStateMachine();
@ -2157,6 +2190,7 @@ int stop_acquisition(int file_des) {
}
LOG(logDEBUG1, ("Stopping Acquisition ret: %d\n", ret));
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
@ -2166,9 +2200,13 @@ int get_run_status(int file_des) {
enum runStatus retval = ERROR;
LOG(logDEBUG1, ("Getting status\n"));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// only get
retval = getRunStatus();
LOG(logDEBUG1, ("Status: %d\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
@ -2446,6 +2484,9 @@ int get_exptime(int file_des) {
if (receiveData(file_des, &gateIndex, sizeof(gateIndex), INT32) < 0)
return printSocketReadError();
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// get only
#ifdef MYTHEN3D
if (gateIndex < 0 || gateIndex > 2) {
@ -2469,6 +2510,7 @@ int get_exptime(int file_des) {
retval = getExpTime();
LOG(logDEBUG1, ("retval exptime %lld ns\n", (long long int)retval));
}
#endif
#endif
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
}
@ -2485,6 +2527,9 @@ int set_exptime(int file_des) {
LOG(logDEBUG1, ("Setting exptime %lld ns (gateIndex:%d)\n",
(long long int)val, gateIndex));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
#ifdef MYTHEN3D
@ -2532,7 +2577,7 @@ int set_exptime(int file_des) {
if (gateIndex != -1) {
ret = FAIL;
sprintf(mess,
"Could not get exposure time. Gate index not implemented "
"Could not set exposure time. Gate index not implemented "
"for this detector\n");
LOG(logERROR, (mess));
} else {
@ -2549,6 +2594,7 @@ int set_exptime(int file_des) {
}
#endif
}
#endif
return Server_SendResult(file_des, INT64, NULL, 0);
}
@ -2557,9 +2603,13 @@ int get_period(int file_des) {
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// get only
retval = getPeriod();
LOG(logDEBUG1, ("retval period %lld ns\n", (long long int)retval));
#endif
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
}
@ -2572,6 +2622,9 @@ int set_period(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting period %lld ns\n", (long long int)arg));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
ret = setPeriod(arg);
@ -2583,6 +2636,7 @@ int set_period(int file_des) {
LOG(logERROR, (mess));
}
}
#endif
return Server_SendResult(file_des, INT64, NULL, 0);
}
@ -2824,7 +2878,8 @@ int get_frames_left(int file_des) {
int64_t retval = -1;
#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARDD) && \
!defined(CHIPTESTBOARDD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
!defined(CHIPTESTBOARDD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D) && \
!defined(XILINX_CHIPTESTBOARDD)
functionNotImplemented();
#else
// get only
@ -2840,7 +2895,8 @@ int get_triggers_left(int file_des) {
int64_t retval = -1;
#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARDD) && \
!defined(CHIPTESTBOARDD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
!defined(CHIPTESTBOARDD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D) && \
!defined(XILINX_CHIPTESTBOARDD)
functionNotImplemented();
#else
// get only
@ -3010,7 +3066,8 @@ int set_dynamic_range(int file_des) {
case 32:
#endif
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MOENCHD) || \
defined(CHIPTESTBOARDD) || defined(GOTTHARD2D)
defined(CHIPTESTBOARDD) || defined(GOTTHARD2D) || \
defined(XILINX_CHIPTESTBOARDD)
case 16:
#endif
if (dr >= 0) {
@ -3152,7 +3209,7 @@ int enable_ten_giga(int file_des) {
LOG(logDEBUG, ("Setting 10GbE: %d\n", arg));
#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARDD) || \
defined(GOTTHARD2D)
defined(GOTTHARD2D) || defined(XILINX_CHIPTESTBOARDD)
functionNotImplemented();
#else
// set & get
@ -3283,7 +3340,8 @@ int set_pattern_word(int file_des) {
if (receiveData(file_des, args, sizeof(args), INT64) < 0)
return printSocketReadError();
#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) && \
!defined(MYTHEN3D)
functionNotImplemented();
#else
int addr = (int)args[0];
@ -3311,7 +3369,8 @@ int set_pattern_loop_addresses(int file_des) {
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError();
#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) && \
!defined(MYTHEN3D)
functionNotImplemented();
#else
int loopLevel = args[0];
@ -3357,7 +3416,8 @@ int set_pattern_loop_cycles(int file_des) {
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError();
#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) && \
!defined(MYTHEN3D)
functionNotImplemented();
#else
int loopLevel = args[0];
@ -3386,7 +3446,8 @@ int set_pattern_wait_addr(int file_des) {
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError();
#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) && \
!defined(MYTHEN3D)
functionNotImplemented();
#else
int loopLevel = args[0];
@ -3415,7 +3476,8 @@ int set_pattern_wait_time(int file_des) {
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError();
#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) && \
!defined(MYTHEN3D)
functionNotImplemented();
#else
int loopLevel = (int)args[0];
@ -3445,7 +3507,8 @@ int set_pattern_mask(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Set Pattern Mask to %d\n", arg));
#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) && \
!defined(MYTHEN3D)
functionNotImplemented();
#else
// only set
@ -3473,7 +3536,8 @@ int get_pattern_mask(int file_des) {
LOG(logDEBUG1, ("Get Pattern Mask\n"));
#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) && \
!defined(MYTHEN3D)
functionNotImplemented();
#else
// only get
@ -3494,7 +3558,8 @@ int set_pattern_bit_mask(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Set Pattern Bit Mask to %d\n", arg));
#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) && \
!defined(MYTHEN3D)
functionNotImplemented();
#else
// only set
@ -3523,7 +3588,8 @@ int get_pattern_bit_mask(int file_des) {
LOG(logDEBUG1, ("Get Pattern Bit Mask\n"));
#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) && \
!defined(MYTHEN3D)
functionNotImplemented();
#else
// only get
@ -3546,7 +3612,8 @@ int write_adc_register(int file_des) {
uint32_t val = args[1];
LOG(logDEBUG1, ("Writing 0x%x to ADC Register 0x%x\n", val, addr));
#if defined(EIGERD) || defined(GOTTHARD2D) || defined(MYTHEN3D)
#if defined(EIGERD) || defined(GOTTHARD2D) || defined(MYTHEN3D) || \
defined(XILINX_CHIPTESTBOARDD)
functionNotImplemented();
#else
#ifndef VIRTUAL
@ -3941,7 +4008,7 @@ int reset_fpga(int file_des) {
LOG(logDEBUG1, ("Reset FPGA\n"));
#if defined(EIGERD) || defined(GOTTHARDD) || defined(GOTTHARD2D) || \
defined(MYTHEN3D)
defined(MYTHEN3D) || defined(XILINX_CHIPTESTBOARDD)
functionNotImplemented();
#else
// only set
@ -4321,7 +4388,7 @@ int reboot_controller(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
#ifdef EIGERD
#if defined(EIGERD) || defined(XILINX_CHIPTESTBOARDD)
functionNotImplemented();
#elif VIRTUAL
ret = GOODBYE;
@ -4771,7 +4838,8 @@ int set_read_n_rows(int file_des) {
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
if ((Server_VerifyLock() == OK) &&
(check_detector_idle("set number of rows") == OK)) {
if (arg < MIN_ROWS_PER_READOUT || arg > MAX_ROWS_PER_READOUT) {
ret = FAIL;
sprintf(mess,
@ -4803,8 +4871,7 @@ int set_read_n_rows(int file_des) {
LOG(logERROR, (mess));
} else
#elif defined(JUNGFRAUD) || defined(MOENCHD)
if ((check_detector_idle("set number of rows") == OK) &&
(arg % READ_N_ROWS_MULTIPLE != 0)) {
if (arg % READ_N_ROWS_MULTIPLE != 0) {
ret = FAIL;
sprintf(mess,
"Could not set number of rows. %d must be a multiple "
@ -5079,6 +5146,9 @@ int set_source_udp_ip(int file_des) {
arg = __builtin_bswap32(arg);
LOG(logINFO, ("Setting udp source ip: 0x%x\n", arg));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
if (check_detector_idle("configure mac") == OK) {
@ -5091,6 +5161,7 @@ int set_source_udp_ip(int file_des) {
}
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
@ -5100,11 +5171,14 @@ int get_source_udp_ip(int file_des) {
uint32_t retval = -1;
LOG(logDEBUG1, ("Getting udp source ip\n"));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// get only
retval = udpDetails[0].srcip;
retval = __builtin_bswap32(retval);
LOG(logDEBUG1, ("udp soure ip retval: 0x%x\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
@ -5164,6 +5238,9 @@ int set_dest_udp_ip(int file_des) {
arg = __builtin_bswap32(arg);
LOG(logINFO, ("Setting udp destination ip: 0x%x\n", arg));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
if (check_detector_idle("configure mac") == OK) {
@ -5173,6 +5250,7 @@ int set_dest_udp_ip(int file_des) {
}
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
@ -5182,11 +5260,14 @@ int get_dest_udp_ip(int file_des) {
uint32_t retval = -1;
LOG(logDEBUG1, ("Getting destination ip\n"));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// get only
retval = udpDetails[0].dstip;
retval = __builtin_bswap32(retval);
LOG(logDEBUG1, ("udp destination ip retval: 0x%x\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
@ -5242,6 +5323,9 @@ int set_source_udp_mac(int file_des) {
return printSocketReadError();
LOG(logINFO, ("Setting udp source mac: 0x%lx\n", arg));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
if (check_detector_idle("configure mac") == OK) {
@ -5263,6 +5347,7 @@ int set_source_udp_mac(int file_des) {
}
}
}
#endif
return Server_SendResult(file_des, INT64, NULL, 0);
}
@ -5271,11 +5356,13 @@ int get_source_udp_mac(int file_des) {
memset(mess, 0, sizeof(mess));
uint64_t retval = -1;
LOG(logDEBUG1, ("Getting udp source mac\n"));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// get only
retval = udpDetails[0].srcmac;
LOG(logDEBUG1, ("udp soure mac retval: 0x%lx\n", retval));
#endif
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
}
@ -5332,6 +5419,9 @@ int set_dest_udp_mac(int file_des) {
return printSocketReadError();
LOG(logINFO, ("Setting udp destination mac: 0x%lx\n", arg));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
if (check_detector_idle("configure mac") == OK) {
@ -5341,6 +5431,7 @@ int set_dest_udp_mac(int file_des) {
}
}
}
#endif
return Server_SendResult(file_des, INT64, NULL, 0);
}
@ -5349,11 +5440,13 @@ int get_dest_udp_mac(int file_des) {
memset(mess, 0, sizeof(mess));
uint64_t retval = -1;
LOG(logDEBUG1, ("Getting udp destination mac\n"));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// get only
retval = udpDetails[0].dstmac;
LOG(logDEBUG1, ("udp destination mac retval: 0x%lx\n", retval));
#endif
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
}
@ -5407,6 +5500,9 @@ int set_dest_udp_port(int file_des) {
return printSocketReadError();
LOG(logINFO, ("Setting udp destination port: %hu\n", arg));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
if (check_detector_idle("configure mac") == OK) {
@ -5416,6 +5512,7 @@ int set_dest_udp_port(int file_des) {
}
}
}
#endif
return Server_SendResult(file_des, INT16, NULL, 0);
}
@ -5424,11 +5521,13 @@ int get_dest_udp_port(int file_des) {
memset(mess, 0, sizeof(mess));
uint16_t retval = -1;
LOG(logDEBUG1, ("Getting destination port"));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// get only
retval = udpDetails[0].dstport;
LOG(logDEBUG, ("udp destination port retval: %hu\n", retval));
#endif
return Server_SendResult(file_des, INT16, &retval, sizeof(retval));
}
@ -5484,7 +5583,8 @@ int set_num_interfaces(int file_des) {
return printSocketReadError();
LOG(logINFO, ("Setting number of interfaces: %d\n", arg));
#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARD2D)
#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARD2D) && \
!defined(XLINX_CHIPTESTBOARDD)
// fixed number of udp interfaces
int num_interfaces = getNumberofUDPInterfaces();
if (arg != num_interfaces) {
@ -5556,7 +5656,6 @@ int get_num_interfaces(int file_des) {
// get only
retval = getNumberofUDPInterfaces();
LOG(logDEBUG1, ("Number of udp interfaces retval: %u\n", retval));
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
@ -6987,7 +7086,7 @@ int get_num_channels(int file_des) {
LOG(logDEBUG1, ("Getting number of channels\n"));
#if !defined(CHIPTESTBOARDD)
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD)
functionNotImplemented();
#else
// get only
@ -7019,6 +7118,10 @@ int get_receiver_parameters(int file_des) {
memset(mess, 0, sizeof(mess));
LOG(logDEBUG1, ("Getting receiver parameters\n"));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
Server_SendResult(file_des, INT32, NULL, 0);
#else
// get only
Server_SendResult(file_des, INT32, NULL, 0);
@ -7476,7 +7579,7 @@ int get_receiver_parameters(int file_des) {
return printSocketReadError();
LOG(logINFO, ("Sent %d bytes for receiver parameters\n", n));
#endif
return OK;
}
@ -7705,7 +7808,8 @@ int set_pattern(int file_des) {
char args[MAX_STR_LENGTH];
memset(args, 0, MAX_STR_LENGTH);
#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) && \
!defined(MYTHEN3D)
functionNotImplemented();
#else
@ -7742,7 +7846,8 @@ int get_pattern_file(int file_des) {
LOG(logDEBUG1, ("Getting pattern file name\n"));
#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) && \
!defined(MYTHEN3D)
functionNotImplemented();
#else
// get only
@ -7756,7 +7861,8 @@ int get_pattern(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) && \
!defined(MYTHEN3D)
functionNotImplemented();
return Server_SendResult(file_des, INT32, NULL, 0);
#else
@ -7818,6 +7924,9 @@ int set_scan(int file_des) {
if (receiveData(file_des, &dacTime, sizeof(dacTime), INT64) < 0)
return printSocketReadError();
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
int enable = args[0];
@ -7907,6 +8016,7 @@ int set_scan(int file_des) {
}
}
}
#endif
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
}
@ -8264,6 +8374,9 @@ int reconfigure_udp(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
if (Server_VerifyLock() == OK) {
LOG(logINFO, ("Reconfiguring UDP\n"));
if (check_detector_idle("configure mac") == OK) {
@ -8276,6 +8389,7 @@ int reconfigure_udp(int file_des) {
}
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
@ -8376,7 +8490,7 @@ int reset_to_default_dacs(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Resetting dacs to defaults (hard reset: %d)\n", arg));
#ifdef CHIPTESTBOARDD
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
functionNotImplemented();
#else
if (Server_VerifyLock() == OK) {
@ -8471,9 +8585,9 @@ int set_master(int file_des) {
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
if ((check_detector_idle("set master") == OK) &&
(arg != 0 && arg != 1)) {
if ((Server_VerifyLock() == OK) &&
(check_detector_idle("set master") == OK)) {
if (arg != 0 && arg != 1) {
ret = FAIL;
sprintf(mess, "Could not set master. Invalid argument %d.\n", arg);
LOG(logERROR, (mess));
@ -8791,7 +8905,7 @@ int get_default_dac(int file_des) {
LOG(logDEBUG1,
("Getting default dac [dacindex:%d, settings: %d]\n", dacindex, sett));
#ifdef CHIPTESTBOARDD
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
functionNotImplemented();
#else
// get only
@ -8831,7 +8945,7 @@ int set_default_dac(int file_des) {
LOG(logDEBUG1, ("Setting default dac [dacindex: %d, settings: %d] to %d\n",
(int)dacindex, (int)sett, value));
#ifdef CHIPTESTBOARDD
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
functionNotImplemented();
#else
// only set
@ -9027,9 +9141,9 @@ int set_flip_rows(int file_des) {
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
if ((check_detector_idle("set flip rows") == OK) &&
(arg != 0 && arg != 1)) {
if ((Server_VerifyLock() == OK) &&
(check_detector_idle("set flip rows") == OK)) {
if (arg != 0 && arg != 1) {
ret = FAIL;
sprintf(mess, "Could not set flip rows. Invalid argument %d.\n",
arg);
@ -9451,6 +9565,11 @@ int clear_all_udp_dst(int file_des) {
memset(mess, 0, sizeof(mess));
LOG(logINFO, ("Clearing all udp destinations\n"));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
if (Server_VerifyLock() == OK) {
if (check_detector_idle("clear all udp destinations") == OK) {
memset(udpDetails, 0, sizeof(udpDetails));
@ -9478,6 +9597,7 @@ int clear_all_udp_dst(int file_des) {
}
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
@ -9636,7 +9756,7 @@ int get_kernel_version(int file_des) {
int update_kernel(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
#ifdef EIGERD
#if defined(EIGERD) || defined(XILINX_CHIPTESTBOARDD)
functionNotImplemented();
return Server_SendResult(file_des, INT32, NULL, 0);
#else
@ -9688,7 +9808,8 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
LOG(logINFO, ("\tServer Name: %s\n", serverName));
}
#if !defined(GOTTHARD2D) && !defined(MYTHEN3D) && !defined(EIGERD)
#if !defined(GOTTHARD2D) && !defined(MYTHEN3D) && !defined(EIGERD) && \
!defined(XILINX_CHIPTESTBOARDD)
int forceDeleteNormalFile = 0;
if (receiveData(file_des, &forceDeleteNormalFile,
sizeof(forceDeleteNormalFile), INT32) < 0)
@ -9724,7 +9845,8 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
}
if (ret == OK) {
#if defined(GOTTHARD2D) || defined(MYTHEN3D) || defined(EIGERD)
#if defined(GOTTHARD2D) || defined(MYTHEN3D) || defined(EIGERD) || \
defined(XILINX_CHIPTESTBOARDD)
receive_program_default(file_des, index, functionType, filesize,
checksum, serverName);
#else
@ -9870,7 +9992,8 @@ void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
void receive_program_default(int file_des, enum PROGRAM_INDEX index,
char *functionType, uint64_t filesize,
char *checksum, char *serverName) {
#if !defined(GOTTHARD2D) && !defined(MYTHEN3D) && !defined(EIGERD)
#if !defined(GOTTHARD2D) && !defined(MYTHEN3D) && !defined(EIGERD) && \
!defined(XILINX_CHIPTESTBOARDD)
ret = FAIL;
sprintf(mess,
"Could not %s. program via blackfin not implmented for this "
@ -10364,9 +10487,9 @@ int set_synchronization(int file_des) {
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
if ((check_detector_idle("set synchronization") == OK) &&
(arg != 0 && arg != 1)) {
if ((Server_VerifyLock() == OK) &&
(check_detector_idle("set synchronization") == OK)) {
if (arg != 0 && arg != 1) {
ret = FAIL;
sprintf(mess,
"Could not set synchronization. Invalid argument %d.\n",
@ -10388,8 +10511,10 @@ int get_hardware_version(int file_des) {
memset(mess, 0, sizeof(mess));
char retvals[MAX_STR_LENGTH];
memset(retvals, 0, MAX_STR_LENGTH);
getHardwareVersion(retvals);
LOG(logDEBUG1, ("hardware version retval: %s\n", retvals));
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
}
@ -10442,6 +10567,10 @@ int set_bit(int file_des) {
int nBit = (int)args[1];
LOG(logDEBUG1, ("Setting bit %d of reg 0x%x\n", nBit, addr));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
if (nBit < 0 || nBit > 31) {
@ -10472,6 +10601,7 @@ int set_bit(int file_des) {
}
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
@ -10486,6 +10616,9 @@ int clear_bit(int file_des) {
int nBit = (int)args[1];
LOG(logDEBUG1, ("Clearing bit %d of reg 0x%x\n", nBit, addr));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
if (nBit < 0 || nBit > 31) {
@ -10516,6 +10649,7 @@ int clear_bit(int file_des) {
}
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
@ -10531,6 +10665,9 @@ int get_bit(int file_des) {
int nBit = (int)args[1];
LOG(logDEBUG1, ("Getting bit %d of reg 0x%x\n", nBit, addr));
#ifdef XILINX_CHIPTESTBOARDD
functionNotImplemented();
#else
if (nBit < 0 || nBit > 31) {
ret = FAIL;
sprintf(mess,
@ -10555,6 +10692,7 @@ int get_bit(int file_des) {
LOG(logDEBUG1, ("regval: 0x%x bit value:0%d\n", regval, retval));
#endif
}
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}

View File

@ -0,0 +1,39 @@
# 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
../../slsSupportLib/src/md5.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 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}
)

View 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
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

View File

@ -0,0 +1,968 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#pragma once
#define CTRLREG1 (0x0)
#define CTRLREG2 (0x4)
#define STATUSREG1 (0x8)
#define STATUSREG2 (0xC)
#define FPGAVERSIONREG (0x10)
#define COMPDATE_OFST (0)
#define COMPDATE_MSK (0x00ffffff << COMPDATE_OFST)
#define DETTYPE_OFST (24)
#define DETTYPE_MSK (0x000000ff << DETTYPE_OFST)
#define EMPTY14REG (0x14)
#define EMPTY18REG (0x18)
#define EMPTY1CREG (0x1C)
#define EMPTY20REG (0x20)
#define EMPTY24REG (0x24)
#define PKTPACKETLENGTHREG (0x28)
#define PACKETLENGTH1G_OFST (0)
#define PACKETLENGTH1G_MSK (0x0000ffff << PACKETLENGTH1G_OFST)
#define PACKETLENGTH10G_OFST (16)
#define PACKETLENGTH10G_MSK (0x0000ffff << PACKETLENGTH10G_OFST)
#define EMPTY2CREG (0x2C)
#define PKTNOPACKETSREG (0x30)
#define NOPACKETS1G_OFST (0)
#define NOPACKETS1G_MSK (0x0000003f << NOPACKETS1G_OFST)
#define NOPACKETS10G_OFST (16)
#define NOPACKETS10G_MSK (0x0000003f << NOPACKETS10G_OFST)
#define EMPTY34REG (0x34)
#define PKTCTRLREG (0x38)
#define NOSERVERS_OFST (0)
#define NOSERVERS_MSK (0x0000003f << NOSERVERS_OFST)
#define SERVERSTART_OFST (8)
#define SERVERSTART_MSK (0x0000001f << SERVERSTART_OFST)
#define ETHINTERF_OFST (16)
#define ETHINTERF_MSK (0x00000001 << ETHINTERF_OFST)
#define EMPTY3CREG (0x3C)
#define PKTCOORDREG1 (0x40)
#define COORDX_OFST (0)
#define COORDX_MSK (0x0000ffff << COORDX_OFST)
#define COORDY_OFST (16)
#define COORDY_MSK (0x0000ffff << COORDY_OFST)
#define EMPTY44REG (0x44)
#define PKTCOORDREG2 (0x48)
#define COORDZ_OFST (0)
#define COORDZ_MSK (0x0000ffff << COORDZ_OFST)
#define EMPTY4CREG (0x4C)
#define EMPTY50REG (0x50)
#define EMPTY54REG (0x54)
#define EMPTY58REG (0x58)
#define EMPTY5CREG (0x5C)
#define EMPTY60REG (0x60)
#define EMPTY64REG (0x64)
#define EMPTY68REG (0x68)
#define EMPTY6CREG (0x6C)
#define EMPTY70REG (0x70)
#define EMPTY74REG (0x74)
#define EMPTY78REG (0x78)
#define EMPTY7CREG (0x7C)
#define EMPTY80REG (0x80)
#define EMPTY84REG (0x84)
#define EMPTY88REG (0x88)
#define EMPTY8CREG (0x8C)
#define EMPTY90REG (0x90)
#define EMPTY94REG (0x94)
#define EMPTY98REG (0x98)
#define EMPTY9CREG (0x9C)
#define FLOWSTATUSREG (0x100)
#define RSMBUSY_OFST (0)
#define RSMBUSY_MSK (0x00000001 << RSMBUSY_OFST)
#define RSMTRGWAIT_OFST (3)
#define RSMTRGWAIT_MSK (0x00000001 << RSMTRGWAIT_OFST)
#define CSMBUSY_OFST (17)
#define CSMBUSY_MSK (0x00000001 << CSMBUSY_OFST)
#define EMPTY104REG (0x104)
#define FLOWCONTROLREG (0x108)
#define STARTF_OFST (0)
#define STARTF_MSK (0x00000001 << STARTF_OFST)
#define STOPF_OFST (1)
#define STOPF_MSK (0x00000001 << STOPF_OFST)
#define RSTF_OFST (2)
#define RSTF_MSK (0x00000001 << RSTF_OFST)
#define SWTRIGGERF_OFST (3)
#define SWTRIGGERF_MSK (0x00000001 << SWTRIGGERF_OFST)
#define TRIGGERENABLE_OFST (4)
#define TRIGGERENABLE_MSK (0x00000001 << TRIGGERENABLE_OFST)
#define EMPTY10CREG (0x10C)
#define TIMEFROMSTARTOUTREG1 (0x110)
#define TIMEFROMSTARTOUTREG2 (0x114)
#define FRAMESFROMSTARTOUTREG1 (0x118)
#define FRAMESFROMSTARTOUTREG2 (0x11C)
#define FRAMETIMEOUTREG1 (0x120)
#define FRAMETIMEOUTREG2 (0x124)
#define DELAYOUTREG1 (0x128)
#define DELAYOUTREG2 (0x12C)
#define CYCLESOUTREG1 (0x130)
#define CYCLESOUTREG2 (0x134)
#define FRAMESOUTREG1 (0x138)
#define FRAMESOUTREG2 (0x13C)
#define PERIODOUTREG1 (0x140)
#define PERIODOUTREG2 (0x144)
#define DELAYINREG1 (0x148)
#define DELAYINREG2 (0x14C)
#define CYCLESINREG1 (0x150)
#define CYCLESINREG2 (0x154)
#define FRAMESINREG1 (0x158)
#define FRAMESINREG2 (0x15C)
#define PERIODINREG1 (0x160)
#define PERIODINREG2 (0x164)
#define EMPTY168REG (0x168)
#define EMPTY16CREG (0x16C)
#define EMPTY170REG (0x170)
#define EMPTY174REG (0x174)
#define EMPTY178REG (0x178)
#define EMPTY17CREG (0x17C)
#define EMPTY180REG (0x180)
#define EMPTY184REG (0x184)
#define EMPTY188REG (0x188)
#define EMPTY18CREG (0x18C)
#define EMPTY190REG (0x190)
#define EMPTY194REG (0x194)
#define EMPTY198REG (0x198)
#define EMPTY19CREG (0x19C)
#define PATTERN_OUT_LSB_REG (0x200)
#define PATTERN_OUT_MSB_REG (0x204)
#define PATTERN_IN_LSB_REG (0x208)
#define PATTERN_IN_MSB_REG (0x20C)
#define PATTERN_MASK_LSB_REG (0x210)
#define PATTERN_MASK_MSB_REG (0x214)
#define PATTERN_SET_LSB_REG (0x218)
#define PATTERN_SET_MSB_REG (0x21C)
#define PATTERN_CNTRL_REG (0x220)
#define PATTERN_CNTRL_WR_OFST (0)
#define PATTERN_CNTRL_WR_MSK (0x00000001 << PATTERN_CNTRL_WR_OFST)
#define PATTERN_CNTRL_RD_OFST (1)
#define PATTERN_CNTRL_RD_MSK (0x00000001 << PATTERN_CNTRL_RD_OFST)
#define PATTERN_CNTRL_ADDR_OFST (16)
#define PATTERN_CNTRL_ADDR_MSK (0x00001fff << PATTERN_CNTRL_ADDR_OFST)
#define EMPTY224REG (0x224)
#define PATTERN_LIMIT_REG (0x228)
#define PATTERN_LIMIT_STRT_OFST (0)
#define PATTERN_LIMIT_STRT_MSK (0x00001fff << PATTERN_LIMIT_STRT_OFST)
#define PATTERN_LIMIT_STP_OFST (16)
#define PATTERN_LIMIT_STP_MSK (0x00001fff << PATTERN_LIMIT_STP_OFST)
#define EMPTY22CREG (0x22C)
#define PATTERN_LOOP_0_ADDR_REG (0x230)
#define PATTERN_LOOP_0_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_0_ADDR_STRT_MSK \
(0x00001fff << PATTERN_LOOP_0_ADDR_STRT_OFST)
#define PATTERN_LOOP_0_ADDR_STP_OFST (16)
#define PATTERN_LOOP_0_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_0_ADDR_STP_OFST)
#define EMPTY234REG (0x234)
#define PATTERN_LOOP_0_ITERATION_REG (0x238)
#define EMPTY23CREG (0x23C)
#define PATTERN_WAIT_0_ADDR_REG (0x240)
#define PATTERN_WAIT_0_ADDR_OFST (0)
#define PATTERN_WAIT_0_ADDR_MSK (0x00001fff << PATTERN_WAIT_0_ADDR_OFST)
#define EMPTY244REG (0x244)
#define PATTERN_WAIT_TIMER_0_LSB_REG (0x248)
#define PATTERN_WAIT_TIMER_0_MSB_REG (0x24C)
#define PATTERN_LOOP_1_ADDR_REG (0x250)
#define PATTERN_LOOP_1_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_1_ADDR_STRT_MSK \
(0x00001fff << PATTERN_LOOP_1_ADDR_STRT_OFST)
#define PATTERN_LOOP_1_ADDR_STP_OFST (16)
#define PATTERN_LOOP_1_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_1_ADDR_STP_OFST)
#define EMPTY254REG (0x254)
#define PATTERN_LOOP_1_ITERATION_REG (0x258)
#define EMPTY25CREG (0x25C)
#define PATTERN_WAIT_1_ADDR_REG (0x260)
#define PATTERN_WAIT_1_ADDR_OFST (0)
#define PATTERN_WAIT_1_ADDR_MSK (0x00001fff << PATTERN_WAIT_1_ADDR_OFST)
#define EMPTY264REG (0x264)
#define PATTERN_WAIT_TIMER_1_LSB_REG (0x268)
#define PATTERN_WAIT_TIMER_1_MSB_REG (0x26C)
#define PATTERN_LOOP_2_ADDR_REG (0x270)
#define PATTERN_LOOP_2_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_2_ADDR_STRT_MSK \
(0x00001fff << PATTERN_LOOP_2_ADDR_STRT_OFST)
#define PATTERN_LOOP_2_ADDR_STP_OFST (16)
#define PATTERN_LOOP_2_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_2_ADDR_STP_OFST)
#define EMPTY274REG (0x274)
#define PATTERN_LOOP_2_ITERATION_REG (0x278)
#define EMPTY27CREG (0x27C)
#define PATTERN_WAIT_2_ADDR_REG (0x280)
#define PATTERN_WAIT_2_ADDR_OFST (0)
#define PATTERN_WAIT_2_ADDR_MSK (0x00001fff << PATTERN_WAIT_2_ADDR_OFST)
#define EMPTY284REG (0x284)
#define PATTERN_WAIT_TIMER_2_LSB_REG (0x288)
#define PATTERN_WAIT_TIMER_2_MSB_REG (0x28C)
#define PATTERN_LOOP_3_ADDR_REG (0x290)
#define PATTERN_LOOP_3_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_3_ADDR_STRT_MSK \
(0x00001fff << PATTERN_LOOP_3_ADDR_STRT_OFST)
#define PATTERN_LOOP_3_ADDR_STP_OFST (16)
#define PATTERN_LOOP_3_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_3_ADDR_STP_OFST)
#define EMPTY294REG (0x294)
#define PATTERN_LOOP_3_ITERATION_REG (0x298)
#define EMPTY29CREG (0x29C)
#define PATTERN_WAIT_3_ADDR_REG (0x300)
#define PATTERN_WAIT_3_ADDR_OFST (0)
#define PATTERN_WAIT_3_ADDR_MSK (0x00001fff << PATTERN_WAIT_3_ADDR_OFST)
#define EMPTY304REG (0x304)
#define PATTERN_WAIT_TIMER_3_LSB_REG (0x308)
#define PATTERN_WAIT_TIMER_3_MSB_REG (0x30C)
#define PATTERN_LOOP_4_ADDR_REG (0x310)
#define PATTERN_LOOP_4_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_4_ADDR_STRT_MSK \
(0x00001fff << PATTERN_LOOP_4_ADDR_STRT_OFST)
#define PATTERN_LOOP_4_ADDR_STP_OFST (16)
#define PATTERN_LOOP_4_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_4_ADDR_STP_OFST)
#define EMPTY314REG (0x314)
#define PATTERN_LOOP_4_ITERATION_REG (0x318)
#define EMPTY31CREG (0x31C)
#define PATTERN_WAIT_4_ADDR_REG (0x320)
#define PATTERN_WAIT_4_ADDR_OFST (0)
#define PATTERN_WAIT_4_ADDR_MSK (0x00001fff << PATTERN_WAIT_4_ADDR_OFST)
#define EMPTY324REG (0x324)
#define PATTERN_WAIT_TIMER_4_LSB_REG (0x328)
#define PATTERN_WAIT_TIMER_4_MSB_REG (0x32C)
#define PATTERN_LOOP_5_ADDR_REG (0x330)
#define PATTERN_LOOP_5_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_5_ADDR_STRT_MSK \
(0x00001fff << PATTERN_LOOP_5_ADDR_STRT_OFST)
#define PATTERN_LOOP_5_ADDR_STP_OFST (16)
#define PATTERN_LOOP_5_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_5_ADDR_STP_OFST)
#define EMPTY334REG (0x334)
#define PATTERN_LOOP_5_ITERATION_REG (0x338)
#define EMPTY33CREG (0x33C)
#define PATTERN_WAIT_5_ADDR_REG (0x340)
#define PATTERN_WAIT_5_ADDR_OFST (0)
#define PATTERN_WAIT_5_ADDR_MSK (0x00001fff << PATTERN_WAIT_5_ADDR_OFST)
#define EMPTY344REG (0x344)
#define PATTERN_WAIT_TIMER_5_LSB_REG (0x348)
#define PATTERN_WAIT_TIMER_5_MSB_REG (0x34C)
#define PINIOCTRLREG (0x350)
#define EMPTY354REG (0x354)
#define EMPTY358REG (0x358)
#define EMPTY35CREG (0x35C)
#define EMPTY360REG (0x360)
#define EMPTY364REG (0x364)
#define EMPTY368REG (0x368)
#define EMPTY36CREG (0x36C)
#define EMPTY370REG (0x370)
#define EMPTY374REG (0x374)
#define EMPTY378REG (0x378)
#define EMPTY37CREG (0x37C)
#define EMPTY380REG (0x380)
#define EMPTY384REG (0x384)
#define EMPTY388REG (0x388)
#define EMPTY38CREG (0x38C)
#define EMPTY390REG (0x390)
#define EMPTY394REG (0x394)
#define EMPTY398REG (0x398)
#define EMPTY39CREG (0x39C)
#define EMPTY3A0REG (0x3A0)
#define EMPTY3A4REG (0x3A4)
#define EMPTY3A8REG (0x3A8)
#define EMPTY3ACREG (0x3AC)
#define EMPTY3B0REG (0x3B0)
#define EMPTY3B4REG (0x3B4)
#define EMPTY3B8REG (0x3B8)
#define EMPTY3BCREG (0x3BC)
#define EMPTY3C0REG (0x3C0)
#define EMPTY3C4REG (0x3C4)
#define EMPTY3C8REG (0x3C8)
#define EMPTY3CCREG (0x3CC)
#define EMPTY3D0REG (0x3D0)
#define EMPTY3D4REG (0x3D4)
#define EMPTY3D8REG (0x3D8)
#define EMPTY3DCREG (0x3DC)
#define EMPTY3E0REG (0x3E0)
#define EMPTY3E4REG (0x3E4)
#define EMPTY3E8REG (0x3E8)
#define EMPTY3ECREG (0x3EC)
#define EMPTY3F0REG (0x3F0)
#define EMPTY3F4REG (0x3F4)
#define EMPTY3F8REG (0x3F8)
#define EMPTY3FCREG (0x3FC)
#define EXPCTRLREG (0x400)
#define STARTP_OFST (0)
#define STARTP_MSK (0x00000001 << STARTP_OFST)
#define EMPTY404REG (0x404)
#define EXPFRAMESREG (0x408)
#define EMPTY40CREG (0x40C)
#define EXPTIMEREG (0x410)
#define EMPTY414REG (0x414)
#define EMPTY418REG (0x418)
#define EMPTY41CREG (0x41C)
#define EMPTY420REG (0x420)
#define EMPTY424REG (0x424)
#define EMPTY428REG (0x428)
#define EMPTY42CREG (0x42C)
#define EMPTY430REG (0x430)
#define EMPTY434REG (0x434)
#define EMPTY438REG (0x438)
#define EMPTY43CREG (0x43C)
#define EMPTY440REG (0x440)
#define EMPTY444REG (0x444)
#define EMPTY448REG (0x448)
#define EMPTY44CREG (0x44C)
#define EMPTY450REG (0x450)
#define EMPTY454REG (0x454)
#define EMPTY458REG (0x458)
#define EMPTY45CREG (0x45C)
#define EMPTY460REG (0x460)
#define EMPTY464REG (0x464)
#define EMPTY468REG (0x468)
#define EMPTY46CREG (0x46C)
#define EMPTY470REG (0x470)
#define EMPTY474REG (0x474)
#define EMPTY478REG (0x478)
#define EMPTY47CREG (0x47C)
#define EMPTY480REG (0x480)
#define EMPTY484REG (0x484)
#define EMPTY488REG (0x488)
#define EMPTY48CREG (0x48C)
#define EMPTY490REG (0x490)
#define EMPTY494REG (0x494)
#define EMPTY498REG (0x498)
#define EMPTY49CREG (0x49C)
#define EMPTY4A0REG (0x4A0)
#define EMPTY4A4REG (0x4A4)
#define EMPTY4A8REG (0x4A8)
#define EMPTY4ACREG (0x4AC)
#define EMPTY4B0REG (0x4B0)
#define EMPTY4B4REG (0x4B4)
#define EMPTY4B8REG (0x4B8)
#define EMPTY4BCREG (0x4BC)
#define EMPTY4C0REG (0x4C0)
#define EMPTY4C4REG (0x4C4)
#define EMPTY4C8REG (0x4C8)
#define EMPTY4CCREG (0x4CC)
#define EMPTY4D0REG (0x4D0)
#define EMPTY4D4REG (0x4D4)
#define EMPTY4D8REG (0x4D8)
#define EMPTY4DCREG (0x4DC)
#define EMPTY4E0REG (0x4E0)
#define EMPTY4E4REG (0x4E4)
#define EMPTY4E8REG (0x4E8)
#define EMPTY4ECREG (0x4EC)
#define EMPTY4F0REG (0x4F0)
#define EMPTY4F4REG (0x4F4)
#define EMPTY4F8REG (0x4F8)
#define EMPTY4FCREG (0x4FC)
#define FIFOTOGBCONTROLREG (0x500)
#define ENABLEDCHANNELS_OFST (0)
#define ENABLEDCHANNELS_MSK (0x00001fff << ENABLEDCHANNELS_OFST)
#define ROMODE_OFST (13)
#define ROMODE_MSK (0x00000007 << ROMODE_OFST)
#define COUNTFRAMESFROMUPDATE_OFST (16)
#define COUNTFRAMESFROMUPDATE_MSK (0x00000001 << COUNTFRAMESFROMUPDATE_OFST)
#define STARTSTREAMING_P_OFST (17)
#define STARTSTREAMING_P_MSK (0x00000001 << STARTSTREAMING_P_OFST)
#define EMPTY504REG (0x504)
#define NOSAMPLESDREG (0x508)
#define NOSAMPLESD_OFST (0)
#define NOSAMPLESD_MSK (0x00003fff << NOSAMPLESD_OFST)
#define EMPTY50CREG (0x50C)
#define NOSAMPLESAREG (0x510)
#define NOSAMPLESA_OFST (0)
#define NOSAMPLESA_MSK (0x00003fff << NOSAMPLESA_OFST)
#define EMPTY514REG (0x514)
#define NOSAMPLESXREG (0x518)
#define NOSAMPLESX_OFST (0)
#define NOSAMPLESX_MSK (0x00001fff << NOSAMPLESX_OFST)
#define EMPTY51CREG (0x51C)
#define COUNTFRAMESFROMREG1 (0x520)
#define COUNTFRAMESFROMREG2 (0x524)
#define LOCALFRAMENUMBERREG1 (0x528)
#define LOCALFRAMENUMBERREG2 (0x52C)
#define EMPTY530REG (0x530)
#define EMPTY534REG (0x534)
#define EMPTY538REG (0x538)
#define EMPTY53CREG (0x53C)
#define EMPTY540REG (0x540)
#define EMPTY544REG (0x544)
#define EMPTY548REG (0x548)
#define EMPTY54CREG (0x54C)
#define EMPTY550REG (0x550)
#define EMPTY554REG (0x554)
#define EMPTY558REG (0x558)
#define EMPTY55CREG (0x55C)
#define EMPTY560REG (0x560)
#define EMPTY564REG (0x564)
#define EMPTY568REG (0x568)
#define EMPTY56CREG (0x56C)
#define EMPTY570REG (0x570)
#define EMPTY574REG (0x574)
#define EMPTY578REG (0x578)
#define EMPTY57CREG (0x57C)
#define EMPTY580REG (0x580)
#define EMPTY584REG (0x584)
#define EMPTY588REG (0x588)
#define EMPTY58CREG (0x58C)
#define EMPTY590REG (0x590)
#define EMPTY594REG (0x594)
#define EMPTY598REG (0x598)
#define EMPTY59CREG (0x59C)
#define EMPTY5A0REG (0x5A0)
#define EMPTY5A4REG (0x5A4)
#define EMPTY5A8REG (0x5A8)
#define EMPTY5ACREG (0x5AC)
#define EMPTY5B0REG (0x5B0)
#define EMPTY5B4REG (0x5B4)
#define EMPTY5B8REG (0x5B8)
#define EMPTY5BCREG (0x5BC)
#define EMPTY5C0REG (0x5C0)
#define EMPTY5C4REG (0x5C4)
#define EMPTY5C8REG (0x5C8)
#define EMPTY5CCREG (0x5CC)
#define EMPTY5D0REG (0x5D0)
#define EMPTY5D4REG (0x5D4)
#define EMPTY5D8REG (0x5D8)
#define EMPTY5DCREG (0x5DC)
#define EMPTY5E0REG (0x5E0)
#define EMPTY5E4REG (0x5E4)
#define EMPTY5E8REG (0x5E8)
#define EMPTY5ECREG (0x5EC)
#define EMPTY5F0REG (0x5F0)
#define EMPTY5F4REG (0x5F4)
#define EMPTY5F8REG (0x5F8)
#define EMPTY5FCREG (0x5FC)
#define MATTERHORNSPIREG1 (0x600)
#define MATTERHORNSPIREG2 (0x604)
#define MATTERHORNSPICTRL (0x608)
#define MATTERHORNSPICTRL_EN_OFST (0)
#define MATTERHORNSPICTRL_EN_MSK (0x00000001 << MATTERHORNSPICTRL_EN_OFST)
#define CONFIGSTART_OFST (1)
#define CONFIGSTART_MSK (0x00000001 << CONFIGSTART_OFST)
#define START_P_OFST (2)
#define START_P_MSK (0x00000001 << START_P_OFST)
#define STARTREAD_P_OFST (3)
#define STARTREAD_P_MSK (0x00000001 << STARTREAD_P_OFST)
#define BUSY_OFST (4)
#define BUSY_MSK (0x00000001 << BUSY_OFST)
#define EMPTY60CREG (0x60C)
#define EMPTY610REG (0x610)
#define EMPTY614REG (0x614)
#define EMPTY618REG (0x618)
#define EMPTY61CREG (0x61C)
#define EMPTY620REG (0x620)
#define EMPTY624REG (0x624)
#define EMPTY628REG (0x628)
#define EMPTY62CREG (0x62C)
#define TRANSCEIVERRXCTRL0REG1 (0x630)
#define TRANSCEIVERRXCTRL0REG2 (0x634)
#define TRANSCEIVERRXCTRL1REG1 (0x638)
#define TRANSCEIVERRXCTRL1REG2 (0x63C)
#define TRANSCEIVERRXCTRL2REG (0x640)
#define EMPTY644REG (0x644)
#define TRANSCEIVERRXCTRL3REG (0x648)
#define EMPTY64CREG (0x64C)
#define TRANSCEIVERSTATUS (0x650)
#define LINKDOWNLATCHEDOUT_OFST (0)
#define LINKDOWNLATCHEDOUT_MSK (0x00000001 << LINKDOWNLATCHEDOUT_OFST)
#define TXUSERCLKACTIVE_OFST (1)
#define TXUSERCLKACTIVE_MSK (0x00000001 << TXUSERCLKACTIVE_OFST)
#define RXUSERCLKACTIVE_OFST (2)
#define RXUSERCLKACTIVE_MSK (0x00000001 << RXUSERCLKACTIVE_OFST)
#define RXCOMMADET_OFST (3)
#define RXCOMMADET_MSK (0x0000000f << RXCOMMADET_OFST)
#define RXBYTEREALIGN_OFST (7)
#define RXBYTEREALIGN_MSK (0x0000000f << RXBYTEREALIGN_OFST)
#define RXBYTEISALIGNED_OFST (11)
#define RXBYTEISALIGNED_MSK (0x0000000f << RXBYTEISALIGNED_OFST)
#define GTWIZRXCDRSTABLE_OFST (15)
#define GTWIZRXCDRSTABLE_MSK (0x00000001 << GTWIZRXCDRSTABLE_OFST)
#define RESETTXDONE_OFST (16)
#define RESETTXDONE_MSK (0x00000001 << RESETTXDONE_OFST)
#define RESETRXDONE_OFST (17)
#define RESETRXDONE_MSK (0x00000001 << RESETRXDONE_OFST)
#define RXPMARESETDONE_OFST (18)
#define RXPMARESETDONE_MSK (0x0000000f << RXPMARESETDONE_OFST)
#define TXPMARESETDONE_OFST (22)
#define TXPMARESETDONE_MSK (0x0000000f << TXPMARESETDONE_OFST)
#define GTTPOWERGOOD_OFST (26)
#define GTTPOWERGOOD_MSK (0x0000000f << GTTPOWERGOOD_OFST)
#define EMPTY654REG (0x654)
#define TRANSCEIVERCONTROL (0x658)
#define GTWIZRESETALL_OFST (0)
#define GTWIZRESETALL_MSK (0x00000001 << GTWIZRESETALL_OFST)
#define RESETTXPLLANDDATAPATH_OFST (1)
#define RESETTXPLLANDDATAPATH_MSK (0x00000001 << RESETTXPLLANDDATAPATH_OFST)
#define RESETTXDATAPATHIN_OFST (2)
#define RESETTXDATAPATHIN_MSK (0x00000001 << RESETTXDATAPATHIN_OFST)
#define RESETRXPLLANDDATAPATH_OFST (3)
#define RESETRXPLLANDDATAPATH_MSK (0x00000001 << RESETRXPLLANDDATAPATH_OFST)
#define RESETRXDATAPATHIN_OFST (4)
#define RESETRXDATAPATHIN_MSK (0x00000001 << RESETRXDATAPATHIN_OFST)
#define EMPTY65CREG (0x65C)
#define EMPTY660REG (0x660)
#define EMPTY664REG (0x664)
#define EMPTY668REG (0x668)
#define EMPTY66CREG (0x66C)
#define EMPTY670REG (0x670)
#define EMPTY674REG (0x674)
#define EMPTY678REG (0x678)
#define EMPTY67CREG (0x67C)
#define EMPTY680REG (0x680)
#define EMPTY684REG (0x684)
#define EMPTY688REG (0x688)
#define EMPTY68CREG (0x68C)
#define EMPTY690REG (0x690)
#define EMPTY694REG (0x694)
#define EMPTY698REG (0x698)
#define EMPTY69CREG (0x69C)
#define EMPTY6A0REG (0x6A0)
#define EMPTY6A4REG (0x6A4)
#define EMPTY6A8REG (0x6A8)
#define EMPTY6ACREG (0x6AC)
#define EMPTY6B0REG (0x6B0)
#define EMPTY6B4REG (0x6B4)
#define EMPTY6B8REG (0x6B8)
#define EMPTY6BCREG (0x6BC)
#define EMPTY6C0REG (0x6C0)
#define EMPTY6C4REG (0x6C4)
#define EMPTY6C8REG (0x6C8)
#define EMPTY6CCREG (0x6CC)
#define EMPTY6D0REG (0x6D0)
#define EMPTY6D4REG (0x6D4)
#define EMPTY6D8REG (0x6D8)
#define EMPTY6DCREG (0x6DC)
#define EMPTY6E0REG (0x6E0)
#define EMPTY6E4REG (0x6E4)
#define EMPTY6E8REG (0x6E8)
#define EMPTY6ECREG (0x6EC)
#define EMPTY6F0REG (0x6F0)
#define EMPTY6F4REG (0x6F4)
#define EMPTY6F8REG (0x6F8)
#define EMPTY6FCREG (0x6FC)
#define DBITFIFOCTRLREG (0x700)
#define DBITRD_OFST (0)
#define DBITRD_MSK (0x00000001 << DBITRD_OFST)
#define DBITRST_OFST (1)
#define DBITRST_MSK (0x00000001 << DBITRST_OFST)
#define DBITFULL_OFST (2)
#define DBITFULL_MSK (0x00000001 << DBITFULL_OFST)
#define DBITEMPTY_OFST (3)
#define DBITEMPTY_MSK (0x00000001 << DBITEMPTY_OFST)
#define DBITUNDERFLOW_OFST (4)
#define DBITUNDERFLOW_MSK (0x00000001 << DBITUNDERFLOW_OFST)
#define DBITOVERFLOW_OFST (5)
#define DBITOVERFLOW_MSK (0x00000001 << DBITOVERFLOW_OFST)
#define EMPTYREG (0x704)
#define DBITFIFODATAREG1 (0x708)
#define DBITFIFODATAREG2 (0x70C)
#define EMPTY710REG (0x710)
#define EMPTY714REG (0x714)
#define EMPTY718REG (0x718)
#define EMPTY71CREG (0x71C)
#define EMPTY720REG (0x720)

View File

@ -0,0 +1,435 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#include "slsDetectorFunctionList.h"
#include "arm64.h"
#include "clogger.h"
#include "common.h"
#include "sharedMemory.h"
#include "sls/versionAPI.h"
#include "loadPattern.h"
#include <arpa/inet.h> // INET_ADDRSTRLEN
#include <string.h>
#include <unistd.h> // usleep
// Global variable from slsDetectorServer_funcs
extern int debugflag;
extern int updateFlag;
extern const enum detectorType myDetectorType;
// Global variable from communication_funcs.c
extern int isControlServer;
int initError = OK;
int initCheckDone = 0;
char initErrorMessage[MAX_STR_LENGTH];
int detPos[2] = {0, 0};
int isInitCheckDone() { return initCheckDone; }
int getInitResult(char **mess) {
*mess = initErrorMessage;
return initError;
}
void basictests() {
initError = OK;
initCheckDone = 0;
memset(initErrorMessage, 0, MAX_STR_LENGTH);
#ifdef VIRTUAL
LOG(logINFOBLUE, ("****** Xilinx Chip Test Board Virtual Server ******\n"));
#else
LOG(logINFOBLUE, ("********** Xilinx Chip Test Board Server **********\n"));
#endif
if (mapCSP0() == FAIL) {
strcpy(initErrorMessage,
"Could not map to memory. Cannot proceed. Check Firmware.\n");
LOG(logERROR, (initErrorMessage));
initError = FAIL;
return;
}
#ifndef VIRTUAL
if ((!debugflag) && (!updateFlag) &&
((validateKernelVersion(KERNEL_DATE_VRSN) == FAIL) ||
(checkType() == FAIL) || (testFpga() == FAIL) ||
(testBus() == FAIL))) {
sprintf(initErrorMessage,
"Could not pass basic tests of FPGA and bus. Cannot proceed. "
"Check Firmware. (Firmware version:0x%lx) \n",
getFirmwareVersion());
LOG(logERROR, ("%s\n\n", initErrorMessage));
initError = FAIL;
return;
}
#endif
uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC();
int64_t fwversion = getFirmwareVersion();
char swversion[MAX_STR_LENGTH] = {0};
memset(swversion, 0, MAX_STR_LENGTH);
getServerVersion(swversion);
uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN;
LOG(logINFOBLUE,
("**************************************************\n"
"Detector IP Addr:\t\t 0x%x\n"
"Detector MAC Addr:\t\t 0x%lx\n\n"
"Firmware Version:\t\t 0x%lx\n"
"Software Version:\t\t %s\n"
"Required Firmware Version:\t 0x%x\n"
"********************************************************\n",
ipadd, macadd, fwversion, swversion, requiredFirmwareVersion));
}
int checkType() {
#ifdef VIRTUAL
return OK;
#endif
u_int32_t type = ((bus_r(FPGAVERSIONREG) & DETTYPE_MSK) >> DETTYPE_OFST);
if (type != XILINX_CHIPTESTBOARD) {
LOG(logERROR,
("This is not a Xilinx CTB firmware (read %d, expected %d)\n", type,
XILINX_CHIPTESTBOARD));
return FAIL;
}
return OK;
}
int testFpga() {
#ifdef VIRTUAL
return OK;
#endif
LOG(logINFO, ("Testing FPGA:\n"));
// fixed pattern
int ret = OK;
/* TODO: FIX PATTERN not defined in firmware
uint32_t val = bus_r(FIX_PATT_REG);
if (val == FIX_PATT_VAL) {
LOG(logINFO, ("\tFixed pattern: successful match (0x%08x)\n", val));
} else {
LOG(logERROR,
("Fixed pattern does not match! Read 0x%08x, expected 0x%08x\n",
val, FIX_PATT_VAL));
ret = FAIL;
}
*/
if (ret == OK) {
// Delay LSB reg
LOG(logINFO, ("\tTesting Delay LSB Register:\n"));
uint32_t addr = DELAYINREG1;
// store previous delay value
uint32_t previousValue = bus_r(addr);
volatile uint32_t val = 0, readval = 0;
int times = 1000 * 1000;
for (int i = 0; i < times; ++i) {
val = 0x5A5A5A5A - i;
bus_w(addr, val);
readval = bus_r(addr);
if (readval != val) {
LOG(logERROR, ("1:Mismatch! Loop(%d): Wrote 0x%x, read 0x%x\n",
i, val, readval));
ret = FAIL;
break;
}
val = (i + (i << 10) + (i << 20));
bus_w(addr, val);
readval = bus_r(addr);
if (readval != val) {
LOG(logERROR, ("2:Mismatch! Loop(%d): Wrote 0x%x, read 0x%x\n",
i, val, readval));
ret = FAIL;
break;
}
val = 0x0F0F0F0F;
bus_w(addr, val);
readval = bus_r(addr);
if (readval != val) {
LOG(logERROR, ("3:Mismatch! Loop(%d): Wrote 0x%x, read 0x%x\n",
i, val, readval));
ret = FAIL;
break;
}
val = 0xF0F0F0F0;
bus_w(addr, val);
readval = bus_r(addr);
if (readval != val) {
LOG(logERROR, ("4:Mismatch! Loop(%d): Wrote 0x%x, read 0x%x\n",
i, val, readval));
ret = FAIL;
break;
}
}
// write back previous value
bus_w(addr, previousValue);
if (ret == OK) {
LOG(logINFO,
("\tSuccessfully tested FPGA Delay LSB Register %d times\n",
times));
}
}
return ret;
}
int testBus() {
#ifdef VIRTUAL
return OK;
#endif
LOG(logINFO, ("Testing Bus:\n"));
int ret = OK;
uint32_t addr = DELAYINREG1;
// store previous delay value
uint32_t previousValue = bus_r(addr);
volatile uint32_t val = 0, readval = 0;
int times = 1000 * 1000;
for (int i = 0; i < times; ++i) {
val += 0xbbbbb;
bus_w(addr, val);
readval = bus_r(addr);
if (readval != val) {
LOG(logERROR, ("Mismatch! Loop(%d): Wrote 0x%x, read 0x%x\n", i,
val, readval));
ret = FAIL;
}
}
// write back previous value
bus_w(addr, previousValue);
if (ret == OK) {
LOG(logINFO, ("\tSuccessfully tested bus %d times\n", times));
}
return ret;
}
/* Ids */
void getServerVersion(char *version) { strcpy(version, APIXILINXCTB); }
uint64_t getFirmwareVersion() {
#ifdef VIRTUAL
return REQRD_FRMWRE_VRSN;
#endif
return ((bus_r(FPGAVERSIONREG) & COMPDATE_MSK) >> COMPDATE_OFST);
}
void getHardwareVersion(char *version) { strcpy(version, "Not applicable"); }
u_int64_t getDetectorMAC() {
#ifdef VIRTUAL
return 0;
#else
char output[255], mac[255] = "";
u_int64_t res = 0;
FILE *sysFile =
popen("ifconfig eth0 | grep ether | awk '{ print $2 }'", "r");
fgets(output, sizeof(output), sysFile);
pclose(sysFile);
// getting rid of ":"
char *pch;
pch = strtok(output, ":");
while (pch != NULL) {
strcat(mac, pch);
pch = strtok(NULL, ":");
}
sscanf(mac, "%lx", &res);
return res;
#endif
}
u_int32_t getDetectorIP() {
#ifdef VIRTUAL
return 0;
#endif
char temp[INET_ADDRSTRLEN] = "";
u_int32_t res = 0;
// execute and get address
char output[255];
FILE *sysFile = popen(
"ifconfig | grep 'inet '| grep -v '127.0.0.1' | awk '{ print $2 }'",
"r");
fgets(output, sizeof(output), sysFile);
pclose(sysFile);
// converting IPaddress to hex.
char *pcword = strtok(output, ".");
while (pcword != NULL) {
sprintf(output, "%02x", atoi(pcword));
strcat(temp, output);
pcword = strtok(NULL, ".");
}
strcpy(output, temp);
sscanf(output, "%x", &res);
// LOG(logINFO, ("ip:%x\n",res);
return res;
}
/* initialization */
void initControlServer() {
if (!updateFlag && initError == OK) {
setupDetector();
}
initCheckDone = 1;
}
void initStopServer() {
if (!updateFlag && initError == OK) {
usleep(CTRL_SRVR_INIT_TIME_US);
if (mapCSP0() == FAIL) {
initError = FAIL;
strcpy(initErrorMessage,
"Stop Server: Map Fail. Cannot proceed. Check Firmware.\n");
LOG(logERROR, (initErrorMessage));
initCheckDone = 1;
return;
}
#ifdef VIRTUAL
sharedMemory_setStop(0);
#endif
}
initCheckDone = 1;
}
/* set up detector */
void setupDetector() {
LOG(logINFO, ("Setting up Server for 1 Xilinx Chip Test Board\n"));
#ifdef VIRTUAL
sharedMemory_setStatus(IDLE);
initializePatternWord();
#endif
LOG(logINFOBLUE, ("Setting Default parameters\n"));
initializePatternAddresses();
setNumFrames(DEFAULT_NUM_FRAMES);
setNumTriggers(DEFAULT_NUM_CYCLES);
setTiming(DEFAULT_TIMING_MODE);
}
/* set parameters - dr */
int setDynamicRange(int dr) {
if (dr == 16)
return OK;
return FAIL;
}
int getDynamicRange(int *retval) {
*retval = DYNAMIC_RANGE;
return OK;
}
/* parameters - timer */
void setNumFrames(int64_t val) {
if (val > 0) {
LOG(logINFO, ("Setting number of frames %ld\n", val));
setU64BitReg(val, FRAMESINREG1, FRAMESINREG2);
}
}
int64_t getNumFrames() { return getU64BitReg(FRAMESINREG1, FRAMESINREG2); }
void setNumTriggers(int64_t val) {
if (val > 0) {
LOG(logINFO, ("Setting number of triggers %ld\n", val));
setU64BitReg(val, CYCLESINREG1, CYCLESINREG2);
}
}
int64_t getNumTriggers() { return getU64BitReg(CYCLESINREG1, CYCLESINREG2); }
int64_t getNumFramesLeft() {
return getU64BitReg(FRAMESOUTREG1, FRAMESOUTREG2);
}
int64_t getNumTriggersLeft() {
return getU64BitReg(CYCLESOUTREG1, CYCLESOUTREG2);
}
/* parameters - timing, extsig */
void setTiming(enum timingMode arg) {
switch (arg) {
case AUTO_TIMING:
LOG(logINFO, ("Set Timing: Auto\n"));
bus_w(FLOWCONTROLREG, bus_r(FLOWCONTROLREG) & ~TRIGGERENABLE_MSK);
break;
case TRIGGER_EXPOSURE:
LOG(logINFO, ("Set Timing: Trigger\n"));
bus_w(FLOWCONTROLREG, bus_r(FLOWCONTROLREG) | TRIGGERENABLE_MSK);
break;
default:
LOG(logERROR, ("Unknown timing mode %d\n", arg));
}
}
enum timingMode getTiming() {
if (bus_r(FLOWCONTROLREG) == TRIGGERENABLE_MSK)
return TRIGGER_EXPOSURE;
return AUTO_TIMING;
}
int setDetectorPosition(int pos[]) {
memcpy(detPos, pos, sizeof(detPos));
// TODO
return OK;
}
int configureMAC() {
// TODO
LOG(logINFO, ("Configuring MAC\n"));
return OK;
}
int *getDetectorPosition() { return detPos; }
int getNumberofUDPInterfaces() { return 1; }
/* aquisition */
enum runStatus getRunStatus() {
LOG(logDEBUG1, ("Getting status\n"));
// scan error or running
if (sharedMemory_getScanStatus() == ERROR) {
LOG(logINFOBLUE, ("Status: scan ERROR\n"));
return ERROR;
}
if (sharedMemory_getScanStatus() == RUNNING) {
LOG(logINFOBLUE, ("Status: scan RUNNING\n"));
return RUNNING;
}
#ifdef VIRTUAL
if (sharedMemory_getStatus() == RUNNING) {
LOG(logINFOBLUE, ("Status: RUNNING\n"));
return RUNNING;
}
LOG(logINFOBLUE, ("Status: IDLE\n"));
return IDLE;
#endif
// TODO: get status
LOG(logINFOBLUE, ("Status: IDLE\n"));
return IDLE;
}
void getNumberOfChannels(int *nchanx, int *nchany) {
// TODO
*nchanx = NCHAN;
*nchany = 1;
}

View File

@ -0,0 +1,27 @@
// 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 (0x230000)
#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 (1)
enum ADCINDEX { V_PWR_IO };
enum DACINDEX { D0 };
/** Default Parameters */
#define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_NUM_CYCLES (1)
#define DYNAMIC_RANGE (16)
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
/* Defines in the Firmware */
#define WAIT_TIME_PATTERN_READ (10)

View File

@ -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)

View 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
}

View 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

View 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)

View File

@ -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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View 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()

View 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()

View 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

File diff suppressed because it is too large Load Diff

View 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')

View 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

View File

@ -0,0 +1,30 @@
#include "CmdParser.h"
#include <iostream>
#include <map>
#include <vector>
namespace sls {
class InferAction {
public:
InferAction() {}
int infer(sls::CmdParser &parser, std::ostream &os = std::cout);
std::vector<std::string> args;
std::string cmd;
// generated functions
// THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (1) - DO NOT REMOVE
// int frames();
private:
using FunctionMap = std::map<std::string, int (InferAction::*)()>;
FunctionMap functions{
// generated functions
// THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (2) - DO NOT REMOVE
// {"frames",&InferAction::frames}
};
};
} // namespace sls

View File

@ -0,0 +1,64 @@
from pathlib import Path
import argparse
import yaml
def check_infer(EXTENDED_COMMANDS_PATH=Path(__file__).parent.parent / "extended_commands.yaml", commands=None):
if commands is None:
# load yaml file
with EXTENDED_COMMANDS_PATH.open('r') as f:
commands = yaml.safe_load(f)
type_distinguishable = {}
non_distinguishable = {}
for command_name, command in commands.items():
# todo: remove this (added for debug)
# if command_name != 'badchannels':
# continue
if len(command["actions"]) == 1:
action = list(command["actions"].items())[0][1]
for arg in action['args']:
if arg['argc'] == -1:
non_distinguishable[(command_name, arg['argc'])] = ([], arg['arg_types'])
continue
get_argcs = {}
get_args = command['actions']['GET']['args']
for arg in get_args:
if arg['argc'] != -1:
get_argcs[arg["argc"]] = arg['arg_types']
else:
non_distinguishable[(command_name, arg['argc'])] = ([], arg['arg_types'])
put_args = command['actions']['PUT']['args']
for arg in put_args:
if arg['argc'] == -1:
non_distinguishable[(command_name, arg['argc'])] = ([], arg['arg_types'])
elif arg['argc'] in get_argcs:
if arg['arg_types'] != get_argcs[arg['argc']]:
type_distinguishable[(command_name, arg['argc'])] = (get_argcs[arg['argc']], arg['arg_types'])
else:
non_distinguishable[(command_name, arg['argc'])] = (get_argcs[arg['argc']], arg['arg_types'])
return type_distinguishable, non_distinguishable
if __name__ == "__main__":
argparse = argparse.ArgumentParser()
argparse.add_argument("--print", choices=['all', 'type', 'impossible'], default="all", help="command name")
args = argparse.parse_args()
type_distinguishable, non_distinguishable = check_infer()
if args.print == 'type' or args.print == 'all':
print("type distinguishable:")
print("command_name: argc get_arg_type put_arg_type\n")
for (command_name, argc), (get_arg_types, put_arg_types) in type_distinguishable.items():
print(f"{command_name}: {argc} {get_arg_types} {put_arg_types}")
if args.print == 'impossible' or args.print == 'all':
print("\n\nimpossible to distinguish:")
print("command_name: argc get_arg_type put_arg_type")
for (command_name, argc), (get_arg_types, put_arg_types) in non_distinguishable.items():
print(f"{command_name}: {argc} {get_arg_types} {put_arg_types}")

View File

@ -0,0 +1,288 @@
# Generator
used to generate C++ cli commands. and bash autocompletion scripts.
## Autocomplete
### Overview
Looks through the `dump.json` file for the different values of an enum and stores them in the dictionary `type_values`.
```sh
# To print the different values for enums
python gen_commands.py -a
```
also the autocomplete.py generates shell autocompletion scripts for both bash and zsh. It uses the template file `bash_autocomplete.in.sh` and adds the necessary code in an output file `bash_autocomplete.sh` (same for zsh).
To use the bash autocompletion the `bash_autocomplete.sh` must be sourced.
```sh
source bash_autocomplete.sh
# g <Tab><Tab> will give the list of all commands
# p 0:<Tab><Tab> will also give the list of all commands
# g exp<Tab> will autocomplete to g exptime
# g exptime <Tab><Tab> will return "s ms us ns"
# p timing <Tab><Tab> will return "auto,burst_trigger,gating..."
```
**Note:**
The dump.json is the AST of the file `slsDetectorPackage/slsSupportLib/src/ToString.cpp`.
```sh
# to generate the dump.json file
cd slsSupportLib/src/ToString.cpp
clang++ -Xclang -ast-dump=json -Xclang -ast-dump-filter -Xclang StringTo -c ToString.cpp -I ../include/ -std=gnu++11
# clang version used: 14.0.0-1ubuntu1.1
```
the `dump.json` file produced by clang is not a correct json file because we used the `-ast-dump-filter`. autocomplete.py can be used to fix the format of `dump.json` and produce a new file called `fixed.json` that is json format.
```
# to convert dump.json into correct json format.
python autocomplete.py -f # produces the file fixed.json
```
### Code components
- `type_values` is a dictionary that contains the different values for commands args. It is populated with enum values that stard with defs:: or slsDetectorDefs:: (eg. defs::burstMode). Also it contains values added manually such as "mv,mV" and those start with special::
- `generate_type_values` parses the AST file to find the part that contains if statements. and extracts the different possible values for an enum.
- `generate_bash_autocomplete` generates autocompletion scripts for bash or zsh. the difference between zsh and bash scripts can be found in the template files. (bash handles 0:<Tab><Tab> completion differently than zsh more details can be found in the comments of the template files )
- `fix_json` fixes the file 'autocomplete/dump.json' and outputs a new corrected file in 'autocomplete/fixed.json'
## Command Parser
Definitely the most important component of all the generator module.
command_parser exist to keep the commands.yaml file concise and easy to read and produce a complete version of the commands.yaml for the code generator to work on.
The goal is that the code generator works on a version of commands.yaml that is easy to iterate over and generate code.
```
# complete version
some_command:
help: "do this"
infer_action: true
actions:
GET:
args:
- argc: 0
function: "getCommand"
...
- argc: 1
function: "getCommand"
...
detectors:
MYTHEN3:
- argc: 0
function: "getCommandMythen"
...
PUT:
args:
- argc: 2
function: "setCommand"
...
- argc: 3
function: "setCommand"
...
```
the complete vesion can only have `args` or `detectors` field inside an action (GET or PUT). **Each element in the args array have a different argc**. and in each element in the args array we can find all the information needed to generate the code for that one argc case. for example in the code `if(action == 'GET')` and `if (args.size() == 1)` then we can generate the code for that one case independetly.
commands.yaml has a lot on ~inheritance~. examples show best what it is:
> fields insides an action will be passed to args and detectors
> the extended args for default actions will be used for detectors
> any field can be overriden
```
resetdacs:
help: "[(optional) hard] ..."
actions:
PUT:
function: resetToDefaultDacs
require_det_id: true
output: [ '"successful"' ]
input_types: [ bool ]
args:
- argc: 1
arg_types: [ special::hard ]
input: [ '"1"' ]
- argc: 0
input: [ '"0"' ]
# this will be converted to
resetdacs:
actions:
PUT:
args:
- arg_types:
- special::hard
argc: 1
cast_input:
- false
check_det_id: false
convert_det_id: true
function: resetToDefaultDacs
input:
- '"1"'
input_types:
- bool
output:
- '"successful"'
require_det_id: true
store_result_in_t: false
- arg_types: []
argc: 0
cast_input:
- false
check_det_id: false
convert_det_id: true
function: resetToDefaultDacs
input:
- '"0"'
input_types:
- bool
output:
- '"successful"'
require_det_id: true
store_result_in_t: false
command_name: resetdacs
function_alias: resetdacs
help: "[(optional) hard] ..."
infer_action: true
```
command_parser does not have a specific schema for the commands.yaml this is by design so it can be very extensible and future-proof. This also can have problems when there is typos (writing intput instead of input...)
command_parser first verifies the commands.yaml and checks if there's some obvious problems in it.
templates found in commands.yaml were taken from the CmdProxy code they were added for debugging purposes when writing the generator.
tricky things:
--
- if input array has n elements and cast_input array is empty. command_parser will fill it with n false values.
- store_result_in_t will be added by default as true to GET action. but as false to PUT action. (unless it is written in the action)
- infer_action by default is true
- commands that have is_description true won't be verified
- function_alias is the name of the function in the c++ code. by default it is the command name. errors came up with the command virtual as virtual is a reserved keyword in c++
- command_name is the string of the command that will be typed in cli. (frames, exptime, ...). by default it is the command name. pattern is a special keyword in yaml. problems came up with the command pattern
- arg_types is by default input_types unless otherwise specified
- when the parent has specific detector behaviour and the child does not. writing an empty detector section in the action would not inherit any detector specific fields (check exptime1)
- commands can inherit other commands (check exptime1 and exptime2)
- argc: -1 means that the command has an unknown number of arguments
### Code Walkthrough
the code is well commented it is well explained in the script
### Tests
tests for command_parser can be found in `generator/tests/command_parser/`
```
pip install -r requirements.txt
python -m pytests
```
verification is not well tested
## codegen
Now for C++ code generation. After parsing the commands.yaml file and producing the extended_commands.yaml `gen_commands.py` will iterate over the commands and generate `Caller.h`, `Caller.cpp`, `inferAction.cpp` and `inferAction.h` .
### infer action
the generated code will produce 5 new targets: "sls_detector_get sls_detector_put sls_detector_acquire sls_detector_help sls_detector"
`sls_detector_get` will set the action as GET
`sls_detector_put` will the action as PUT
`sls_detector` will guess the action depending on the number of arguments
the codegen module will generate a function for every command that will return the action based on the number of arguments
```cpp
int InferAction::activate() {
if (args.size() == 0) {
return slsDetectorDefs::GET_ACTION;
}
if (args.size() == 1) {
return slsDetectorDefs::PUT_ACTION;
} else {
throw RuntimeError("Could not infer action: Wrong number of arguments");
}
}
```
the `inferAction` class will be called from `CmdApp.cpp` to infer the action and the command function will be called with the appropriate action.
some commands have the same number of argument count for both get and put. These commands can be found using the the `check_infer.py` script. in the generated code it will say that "sls_detector is disabled"
```bash
# to see these commands
python infer_action/check_infer.py
```
### Caller.cpp code
in this level we only use the extended_commands.yaml file.
the `generate()` function in `gen_commands.py` will iterate over all of the commands and :
- write the function signature
- write the help
- write c++ code to check the inputs: check argument count and check if we are able to convert the arguments into the required types
- iterate over actions and arguments
- iterate over the detectors and write code for each one of them (if mythen3 ... if eiger ... else default code... ) and call `codegen.write_arg()` to write the argument for a single argument
codegen.write_arg()
-
write_arg in codegen reads the argument fields and generate c++ code accordingly.
## fields explanations
- arg_types:[array of types] it is only used for autocompletion no C++ code is dependent on it
- is_description:[boolean] same as above
- template:[boolean] only used in commands.yaml and it won't present in extended_commands.yaml. it is inspired by the CmdProxy.h code
- help:[string] command help
- input:[array of variable names] the input arguments that will be passed to the function
- input_types:[array of types] the types of the input arguments given to the function
- cast_input:[array of boolean] if true it will cast the corresponding input to the type in input_types
- output:[array] outputs that will be printed (eg. ["123", "'a'"] will be os<<123<<'a')
- function: the function that will be called
- function_alias: the name of the function in the c++ code (more on it in tricky things)
- command_name: the string of the command that will be typed in cli. (more on it in tricky things)
- require_det_id: if true it will require a detector id to be passed as the last argument
- check_det_id: if true it will check the detector id and throw an error if it is not valid
- convert_det_id: if true it will convert the detector id to the correct type `std::vector<int>{ det_id }`
- store_result_in_t: if true it will store the result of the function in the variable t (more on it in tricky things)
- infer_action: if true it will infer the action (only if sls_detector is used)
- detectors: the detectors that have specific behaviour
- args: the arguments of the command
- argc: the number of arguments
- extra_variables[array]: each element takes three parameters: value, name, type and creates that variable in the beginning of the argument code
- exceptions[array]: each element takes two parameters: condition, message
- pattern_command: takes three arguments: nGetArgs, nPutArgs and command_name and it will write this code
```cpp
int level = -1, iArg = 0, nGetArgs = $nGetArgs$, nPutArgs = $nPutArgs$;
GetLevelAndUpdateArgIndex(action, $command_name$, level, iArg, nGetArgs,nPutArgs);
```
- separate_time_units: takes three parameters: input, output[0], output[1] each one is a variable name
```cpp
std::string tmp_time($input$);
std::string $output[1]$ = RemoveUnit(tmp_time);
auto $output[0]$ = StringTo<time::ns>(tmp_time, $output[1]$);
```
- convert_to_time: takes three parameters: input[0], input[1], output
```cpp
auto output = StringTo<time::ns>(input[0], input[1]);
```
- ctb_output_list: **maybe it should be removed?** takes 5 parameters: GETFCNLIST, GETFCNNAME, GETFCN, suffix, printable_name

View File

@ -0,0 +1,6 @@
coverage==7.3.1
iniconfig==2.0.0
packaging==23.1
pluggy==1.3.0
pytest==7.4.2
PyYAML==6.0.1

View File

@ -0,0 +1,16 @@
basic:
infer_action: false
help: "xx11"
actions:
GET:
function: 'func1'
output: [ OutString(t) ]
args:
- argc: 0
PUT:
function: 'func2'
output: [ 'args.front()' ]
input: [ 'args[0]' ]
input_types: [ int ]
cast_input: [ true ]
argc: 1

View File

@ -0,0 +1,66 @@
---
template:
infer_action: false
help: ""
actions:
GET:
function: 'func1'
args:
- argc: 0
output: [ OutString(t) ]
PUT:
function: 'func2'
output: [ 'args.front()' ]
input: [ 'args[0]' ]
input_types: [ int ]
cast_input: [ true ]
argc: 1
basic:
help: "xx11"
inherit_actions: template
actions:
GET:
function: 'x'
argc: 2
args:
- check_det_id: true
template2:
infer_action: false
template: true
help: ""
actions:
GET:
convert_to_time:
input: [ 'args[0]', 'args[1]' ]
output: converted_time
separate_time_units:
input: 'args[0]'
output: [ converted_time, unit ]
function: 'func1'
output: [ OutString(t) ]
args:
- argc: 0
- argc: 99
PUT:
function: funcTemplatePUT
args:
- argc: 19
function: 'func19'
- argc: 91
basic2:
inherit_actions: template2
actions:
GET:
function: 'x'
argc: 2
args:
- check_det_id: true
input: [ 'args[0]', a,b,c ]
input_types: [ int, int, int, int ]
PUT:
function: 'y'

View File

@ -0,0 +1,208 @@
basic:
infer_action: false
help: "xx11"
actions:
GET:
function: 'func1'
output: [ OutString(t) ]
args:
- argc: 0
- argc : 1
output: [ testytest ]
detectors:
MYTHEN3:
function: 'do_mythen3'
CHIPTESTBOARD:
args:
- argc: 55
output: [ ctbOutput ]
PUT:
detectors:
EIGER:
function: 'do_eiger'
argc: 99
output: [ eigerOutput ]
# classes of tests:
# classes of template tests: has args or has detectors => 4 cases noted (0,0) ... (1,1)
# classes of childs: has args or has detectors => 4 cases noted (0,0) ... (1,1)
# => 16 cases
# example: case_0111: template (0,1) and child (1,1)
#################### exhaustive testing over chosen classes of tests
template_01:
infer_action: true
help: "vv12"
template: true
actions:
GET:
detectors:
MYTHEN3:
function: 'do_mythen3'
argc: 99
CHIPTESTBOARD:
function: 'do_ctb'
argc: 98
case_0100:
inherit_actions: template_01
help: "0100"
case_0101:
inherit_actions: template_01
help: "0101"
actions:
GET:
function: 'get_function'
detectors:
MYTHEN3:
function: 'do_mythen23'
argc: 420
case_0110:
inherit_actions: template_01
help: "0110"
actions:
GET:
argc: 111
function: 'get_function'
case_0110v2:
inherit_actions: template_01
help: "0110v2"
actions:
GET:
args:
- argc: 111
function: 'get_function'
case_0111:
inherit_actions: template_01
help: "0111"
actions:
GET:
args:
- argc: 111
function: 'get_function'
detectors:
MYTHEN3:
function: 'do_mythen23'
argc: 420
##### cases 10** tests
template_10:
template: true
actions:
GET:
args:
- argc: 0
- argc : 1
output: [ testytest ]
case_1000:
inherit_actions: template_10
help: "1000"
case_1001:
inherit_actions: template_10
help: "1001"
actions:
GET:
detectors:
MYTHEN3:
args:
- function: 'do_mythen23'
argc: 420
- function: 'do_mythen3'
argc: 99
case_1010:
inherit_actions: template_10
help: "1010"
actions:
GET:
args:
- argc: 111
function: 'get_function'
case_1011:
inherit_actions: template_10
help: "1011"
actions:
GET:
args:
- argc: 111
function: 'get_function'
detectors:
MYTHEN3:
function: 'do_mythen23'
##### cases 11** tests
template_11:
template: true
actions:
GET:
args:
- argc: 0
- argc : 1
output: [ testytest ]
detectors:
EIGER:
function: 'do_eiger'
args:
- argc: 99
output: [ eigerOutput ]
POTATO:
function: 'do_potato'
case_1100:
inherit_actions: template_11
help: "1100"
case_1101:
inherit_actions: template_11
help: "1101"
actions:
GET:
detectors:
MYTHEN3:
function: 'do_mythen3'
POTATO:
function: 'do_potato'
args:
- argc: 101
function: 'potato_function'
- argc: 202
case_1110:
inherit_actions: template_11
help: "1110"
actions:
GET:
argc: 77
function: 'get_function'
case_1111:
inherit_actions: template_11
help: "1111"
actions:
GET:
argc: 77
function: 'get_function'
detectors:
MYTHEN3:
function: 'do_mythen3'
POTATO:
function: 'do_potato'
args:
- argc: 101
function: 'potato_function'
- argc: 202

View File

@ -0,0 +1,101 @@
from pathlib import Path
import yaml
from commands_parser.commands_parser import CommandParser
data_path = Path(__file__).parent.parent / "data"
def test_basic_propagation(tmp_path):
output_file = tmp_path / "basic.yaml"
command_parser = CommandParser(commands_file=data_path / "basic.yaml", output_file=output_file)
command_parser.verify_format()
command_parser.parse_all_commands()
assert output_file.exists()
command = yaml.unsafe_load(output_file.open('r'))['basic']
assert command['help'] == "xx11"
assert len(command['actions']) == 2
# test 'GET' action
assert 'args' in command['actions']['GET']
assert len(command['actions']['GET'].keys()) == 1 # only 'args' key
assert len(command['actions']['GET']['args']) == 1 # only one argument
assert command['actions']['GET']['args'][0]['argc'] == 0
assert command['actions']['GET']['args'][0]['function'] == 'func1'
assert command['actions']['GET']['args'][0]['output'] == ['OutString(t)']
assert command['actions']['GET']['args'][0]['input'] == []
assert command['actions']['GET']['args'][0]['cast_input'] == []
assert command['actions']['GET']['args'][0]['require_det_id'] is False
# test PUT action
assert 'args' in command['actions']['PUT']
assert len(command['actions']['PUT'].keys()) == 1 # only 'args' key
assert len(command['actions']['PUT']['args']) == 1 # only one argument
assert command['actions']['PUT']['args'][0]['argc'] == 1
assert command['actions']['PUT']['args'][0]['function'] == 'func2'
assert command['actions']['PUT']['args'][0]['cast_input'] == [True]
assert command['actions']['PUT']['args'][0]['output'] == ['args.front()']
assert command['actions']['PUT']['args'][0]['input_types'] == ['int']
assert command['actions']['PUT']['args'][0]['require_det_id'] is False
def test_basic_inheritance(tmp_path):
output_file = tmp_path / "basic_inheritance.yaml"
command_parser = CommandParser(commands_file=data_path / "basic_inheritance.yaml", output_file=output_file)
command_parser.verify_format()
command_parser.parse_all_commands()
assert output_file.exists()
command = yaml.unsafe_load(output_file.open('r'))['basic']
assert command['help'] == "xx11"
assert command['actions'].keys() == {'GET', 'PUT'}
# test 'GET' action
assert 'args' in command['actions']['GET']
assert command['actions']['GET'].keys() == {'args'} # only 'args' key
assert len(command['actions']['GET']['args']) == 1 # only one argument
assert command['actions']['GET']['args'][0]['argc'] == 2
assert command['actions']['GET']['args'][0]['function'] == 'x'
assert command['actions']['GET']['args'][0]['output'] == [] # test overwriting args when they are present in child
assert command['actions']['GET']['args'][0]['input'] == []
assert command['actions']['GET']['args'][0]['cast_input'] == []
assert command['actions']['GET']['args'][0]['require_det_id'] is False
# test PUT action
assert 'args' in command['actions']['PUT']
assert command['actions']['PUT'].keys() == {'args'} # only 'args' key
assert len(command['actions']['PUT']['args']) == 1 # only one argument
assert command['actions']['PUT']['args'][0]['argc'] == 1
assert command['actions']['PUT']['args'][0]['function'] == 'func2'
assert command['actions']['PUT']['args'][0]['cast_input'] == [True]
assert command['actions']['PUT']['args'][0]['output'] == ['args.front()']
assert command['actions']['PUT']['args'][0]['input_types'] == ['int']
assert command['actions']['PUT']['args'][0]['require_det_id'] is False
def test_basic_inheritance2(tmp_path):
output_file = tmp_path / "basic_inheritance.yaml"
command_parser = CommandParser(commands_file=data_path / "basic_inheritance.yaml", output_file=output_file)
command_parser.verify_format()
command_parser.parse_all_commands()
assert output_file.exists()
command = yaml.unsafe_load(output_file.open('r'))['basic2']
# check GET
assert len(command['actions']['GET']['args']) == 1
assert command['actions']['GET'].keys() == {'args'}
arg = command['actions']['GET']['args'][0]
assert arg['argc'] == 2
assert arg['output'] == ['OutString(t)']
# check that length of cast input is equal to length of input_types and input
assert len(arg['input']) == len(arg['input_types']) == len(arg['cast_input']) == 4
assert arg['function'] == 'x'
assert 'convert_to_time' in arg
assert arg['convert_to_time'].keys() == {'input', 'output'}
assert 'separate_time_units' in arg
assert arg['separate_time_units'].keys() == {'input', 'output'}
# check PUT
assert command['actions']['PUT'].keys() == {'args'}
assert len(command['actions']['PUT']['args']) == 2
assert command['actions']['PUT']['args'][0]['argc'] == 19
assert command['actions']['PUT']['args'][0]['function'] == 'y'
assert command['actions']['PUT']['args'][1]['argc'] == 91
assert command['actions']['PUT']['args'][1]['function'] == 'y'

View File

@ -0,0 +1,309 @@
import json
from pathlib import Path
import pytest as pytest
import yaml
from commands_parser.commands_parser import CommandParser
data_path = Path(__file__).parent.parent / "data"
@pytest.fixture()
def detector_file_commands(tmp_path):
output_file = tmp_path / "detectors.yaml"
command_parser = CommandParser(commands_file=data_path / "detectors.yaml", output_file=output_file)
command_parser.verify_format()
def func(command):
return command_parser.parse_command(command)
return func
def test_basic_propagation(tmp_path, detector_file_commands):
command = detector_file_commands('basic')
assert command['help'] == "xx11"
# GET
assert command['actions']['GET'].keys() == {'detectors', 'args'}
assert command['actions']['GET']['detectors'].keys() == {'MYTHEN3', 'CHIPTESTBOARD'}
mythen = command['actions']['GET']['detectors']['MYTHEN3']
assert len(mythen) == 2
assert mythen[0]['argc'] == 0
assert mythen[1]['argc'] == 1
assert mythen[0]['function'] == mythen[1]['function'] == 'do_mythen3'
assert mythen[0]['output'] == ['OutString(t)']
assert mythen[1]['output'] == ['testytest']
ctb = command['actions']['GET']['detectors']['CHIPTESTBOARD']
assert len(ctb) == 1
assert ctb[0]['argc'] == 55
assert ctb[0]['function'] == 'func1'
# PUT
assert command['actions']['PUT'].keys() == {'detectors'}
assert command['actions']['PUT']['detectors'].keys() == {'EIGER'}
eiger = command['actions']['PUT']['detectors']['EIGER']
assert len(eiger) == 1
assert eiger[0]['argc'] == 99
assert eiger[0]['function'] == 'do_eiger'
assert eiger[0]['output'] == ['eigerOutput']
# 16 test cases for inheritance
# 1st bit: parent has args
# 2nd bit: parent has detectors
# 3rd bit: child has args
# 4th bit: child has detectors
# each test case is a combination of the above bits
# all the possible combinations are tested
def test_inheritance_0100(tmp_path, detector_file_commands):
command = detector_file_commands('case_0100')
assert command['help'] == "0100"
assert 'actions' in command
assert command['actions'].keys() == {'GET'}
assert command['actions']['GET'].keys() == {'detectors'}
assert command['actions']['GET']['detectors'].keys() == {'MYTHEN3', 'CHIPTESTBOARD'}
mythen = command['actions']['GET']['detectors']['MYTHEN3']
assert len(mythen) == 1
assert mythen[0]['argc'] == 99
assert mythen[0]['function'] == 'do_mythen3'
def test_inheritance_0101(tmp_path, detector_file_commands):
command = detector_file_commands('case_0101')
assert command['help'] == "0101"
assert 'actions' in command
assert command['actions'].keys() == {'GET'}
assert command['actions']['GET'].keys() == {'detectors'}
assert command['actions']['GET']['detectors'].keys() == {'MYTHEN3', 'CHIPTESTBOARD'}
mythen = command['actions']['GET']['detectors']['MYTHEN3']
assert len(mythen) == 1
assert mythen[0]['argc'] == 420
assert mythen[0]['function'] == 'do_mythen23'
ctb = command['actions']['GET']['detectors']['CHIPTESTBOARD']
assert len(ctb) == 1
assert ctb[0]['argc'] == 98
assert ctb[0]['function'] == 'do_ctb'
def test_inheritance_0110(tmp_path, detector_file_commands):
command = detector_file_commands('case_0110')
assert command['help'] == "0110"
assert 'actions' in command
assert command['actions'].keys() == {'GET'}
assert command['actions']['GET'].keys() == {'args', 'detectors'}
assert command['actions']['GET']['args'][0]['argc'] == 111
mythen = command['actions']['GET']['detectors']['MYTHEN3']
assert len(mythen) == 1
assert mythen[0]['argc'] == 99
assert mythen[0]['function'] == 'do_mythen3'
ctb = command['actions']['GET']['detectors']['CHIPTESTBOARD']
assert len(ctb) == 1
assert ctb[0]['argc'] == 98
assert ctb[0]['function'] == 'do_ctb'
def test_inheritance_0110v2(tmp_path, detector_file_commands):
command = detector_file_commands('case_0110v2')
assert command['help'] == "0110v2"
assert 'actions' in command
assert command['actions'].keys() == {'GET'}
assert command['actions']['GET'].keys() == {'args', 'detectors'}
assert command['actions']['GET']['args'][0]['argc'] == 111
mythen = command['actions']['GET']['detectors']['MYTHEN3']
assert len(mythen) == 1
assert mythen[0]['argc'] == 99
assert mythen[0]['function'] == 'do_mythen3'
ctb = command['actions']['GET']['detectors']['CHIPTESTBOARD']
assert len(ctb) == 1
assert ctb[0]['argc'] == 98
assert ctb[0]['function'] == 'do_ctb'
def test_inheritacnce_0111(tmp_path, detector_file_commands):
command = detector_file_commands('case_0111')
assert command['help'] == "0111"
assert 'actions' in command
assert command['actions'].keys() == {'GET'}
assert command['actions']['GET'].keys() == {'args', 'detectors'}
assert command['actions']['GET']['detectors'].keys() == {'MYTHEN3', 'CHIPTESTBOARD'}
mythen = command['actions']['GET']['detectors']['MYTHEN3']
assert len(mythen) == 1
assert command['actions']['GET']['args'][0]['argc'] == 111
assert len(mythen) == 1
assert mythen[0]['argc'] == 420
assert mythen[0]['function'] == 'do_mythen23'
ctb = command['actions']['GET']['detectors']['CHIPTESTBOARD']
assert len(ctb) == 1
assert ctb[0]['argc'] == 98
assert ctb[0]['function'] == 'do_ctb'
# cases 1000, 1001, 1010, 1011
def test_inheritance_1000(tmp_path, detector_file_commands):
command = detector_file_commands('case_1000')
assert command['help'] == "1000"
assert 'actions' in command
assert command['actions'].keys() == {'GET'}
assert command['actions']['GET'].keys() == {'args'}
assert len(command['actions']['GET']['args']) == 2
assert command['actions']['GET']['args'][0]['argc'] == 0
assert command['actions']['GET']['args'][0]['output'] == []
assert command['actions']['GET']['args'][1]['argc'] == 1
assert command['actions']['GET']['args'][1]['output'] == ['testytest']
def test_inheritance_1001(tmp_path, detector_file_commands):
command = detector_file_commands('case_1001')
assert command['help'] == "1001"
assert 'actions' in command
assert command['actions'].keys() == {'GET'}
assert command['actions']['GET'].keys() == {'args', 'detectors'}
assert len(command['actions']['GET']['args']) == 2
assert command['actions']['GET']['args'][0]['argc'] == 0
assert command['actions']['GET']['args'][0]['output'] == []
assert command['actions']['GET']['args'][1]['argc'] == 1
assert command['actions']['GET']['args'][1]['output'] == ['testytest']
assert command['actions']['GET']['detectors'].keys() == {'MYTHEN3'}
assert len(command['actions']['GET']['detectors']['MYTHEN3']) == 2
assert command['actions']['GET']['detectors']['MYTHEN3'][0]['argc'] == 420
assert command['actions']['GET']['detectors']['MYTHEN3'][0]['function'] == 'do_mythen23'
assert command['actions']['GET']['detectors']['MYTHEN3'][1]['argc'] == 99
assert command['actions']['GET']['detectors']['MYTHEN3'][1]['function'] == 'do_mythen3'
def test_inheritance_1010(tmp_path, detector_file_commands):
command = detector_file_commands('case_1010')
assert command['help'] == "1010"
assert 'actions' in command
assert command['actions'].keys() == {'GET'}
assert command['actions']['GET'].keys() == {'args'}
assert len(command['actions']['GET']['args']) == 1
assert command['actions']['GET']['args'][0]['argc'] == 111
assert command['actions']['GET']['args'][0]['function'] == 'get_function'
def test_inheritance_1011(tmp_path, detector_file_commands):
command = detector_file_commands('case_1011')
assert command['help'] == "1011"
assert 'actions' in command
assert command['actions'].keys() == {'GET'}
assert command['actions']['GET'].keys() == {'args', 'detectors'}
assert len(command['actions']['GET']['args']) == 1
assert command['actions']['GET']['args'][0]['argc'] == 111
assert command['actions']['GET']['args'][0]['function'] == 'get_function'
assert command['actions']['GET']['detectors'].keys() == {'MYTHEN3'}
assert len(command['actions']['GET']['detectors']['MYTHEN3']) == 1
assert command['actions']['GET']['detectors']['MYTHEN3'][0]['argc'] == 111
assert command['actions']['GET']['detectors']['MYTHEN3'][0]['function'] == 'do_mythen23'
# cases 1100, 1101, 1110, 1111
def test_inheritance_1100(tmp_path, detector_file_commands):
command = detector_file_commands('case_1100')
assert command['help'] == "1100"
assert 'actions' in command
assert command['actions'].keys() == {'GET'}
assert command['actions']['GET'].keys() == {'args', 'detectors'}
assert len(command['actions']['GET']['args']) == 2
assert command['actions']['GET']['args'][0]['argc'] == 0
assert command['actions']['GET']['args'][0]['output'] == []
assert command['actions']['GET']['args'][1]['argc'] == 1
assert command['actions']['GET']['args'][1]['output'] == ['testytest']
assert command['actions']['GET']['detectors'].keys() == {'EIGER', 'POTATO'}
assert len(command['actions']['GET']['detectors']['EIGER']) == 1
assert command['actions']['GET']['detectors']['EIGER'][0]['argc'] == 99
assert command['actions']['GET']['detectors']['EIGER'][0]['function'] == 'do_eiger'
assert command['actions']['GET']['detectors']['EIGER'][0]['output'] == ['eigerOutput']
assert len(command['actions']['GET']['detectors']['POTATO']) == 2
assert command['actions']['GET']['detectors']['POTATO'][0]['argc'] == 0
assert command['actions']['GET']['detectors']['POTATO'][0]['function'] == 'do_potato'
def test_inheritance_1101(tmp_path, detector_file_commands):
command = detector_file_commands('case_1101')
assert command['help'] == "1101"
assert 'actions' in command
assert command['actions'].keys() == {'GET'}
assert command['actions']['GET'].keys() == {'args', 'detectors'}
assert len(command['actions']['GET']['args']) == 2
assert command['actions']['GET']['args'][0]['argc'] == 0
assert command['actions']['GET']['args'][0]['output'] == []
assert command['actions']['GET']['args'][1]['argc'] == 1
assert command['actions']['GET']['args'][1]['output'] == ['testytest']
assert command['actions']['GET']['detectors'].keys() == {'EIGER', 'MYTHEN3', 'POTATO'}
assert len(command['actions']['GET']['detectors']['MYTHEN3']) == 2
assert command['actions']['GET']['detectors']['MYTHEN3'][0]['argc'] == 0
assert command['actions']['GET']['detectors']['MYTHEN3'][0]['function'] == 'do_mythen3'
assert command['actions']['GET']['detectors']['MYTHEN3'][1]['argc'] == 1
assert command['actions']['GET']['detectors']['MYTHEN3'][1]['function'] == 'do_mythen3'
assert len(command['actions']['GET']['detectors']['EIGER']) == 1
assert command['actions']['GET']['detectors']['EIGER'][0]['argc'] == 99
assert command['actions']['GET']['detectors']['EIGER'][0]['function'] == 'do_eiger'
assert command['actions']['GET']['detectors']['EIGER'][0]['output'] == ['eigerOutput']
assert len(command['actions']['GET']['detectors']['POTATO']) == 2
assert command['actions']['GET']['detectors']['POTATO'][0]['argc'] == 101
assert command['actions']['GET']['detectors']['POTATO'][0]['function'] == 'potato_function'
assert command['actions']['GET']['detectors']['POTATO'][1]['argc'] == 202
assert command['actions']['GET']['detectors']['POTATO'][1]['function'] == 'do_potato'
def test_inheritance_1110(tmp_path, detector_file_commands):
command = detector_file_commands('case_1110')
assert command['help'] == "1110"
assert 'actions' in command
assert command['actions'].keys() == {'GET'}
assert command['actions']['GET'].keys() == {'args', 'detectors'}
assert len(command['actions']['GET']['args']) == 1
assert command['actions']['GET']['args'][0]['argc'] == 77
assert command['actions']['GET']['args'][0]['function'] == 'get_function'
assert command['actions']['GET']['detectors'].keys() == {'EIGER', 'POTATO'}
assert len(command['actions']['GET']['detectors']['EIGER']) == 1
assert command['actions']['GET']['detectors']['EIGER'][0]['argc'] == 99
assert command['actions']['GET']['detectors']['EIGER'][0]['function'] == 'do_eiger'
assert len(command['actions']['GET']['detectors']['POTATO']) == 2
assert command['actions']['GET']['detectors']['POTATO'][0]['argc'] == 0
assert command['actions']['GET']['detectors']['POTATO'][0]['function'] == 'do_potato'
assert command['actions']['GET']['detectors']['POTATO'][1]['argc'] == 1
assert command['actions']['GET']['detectors']['POTATO'][1]['function'] == 'do_potato'
def test_inheritance_1111(tmp_path, detector_file_commands):
command = detector_file_commands('case_1111')
assert command['help'] == "1111"
assert 'actions' in command
assert command['actions'].keys() == {'GET'}
assert command['actions']['GET'].keys() == {'args', 'detectors'}
assert len(command['actions']['GET']['args']) == 1
assert command['actions']['GET']['args'][0]['argc'] == 77
assert command['actions']['GET']['args'][0]['function'] == 'get_function'
assert command['actions']['GET']['detectors'].keys() == {'EIGER', 'MYTHEN3', 'POTATO'}
assert len(command['actions']['GET']['detectors']['MYTHEN3']) == 1
assert command['actions']['GET']['detectors']['MYTHEN3'][0]['argc'] == 77
assert command['actions']['GET']['detectors']['MYTHEN3'][0]['function'] == 'do_mythen3'
assert len(command['actions']['GET']['detectors']['EIGER']) == 1
assert command['actions']['GET']['detectors']['EIGER'][0]['argc'] == 99
assert command['actions']['GET']['detectors']['EIGER'][0]['function'] == 'do_eiger'
assert len(command['actions']['GET']['detectors']['POTATO']) == 2
assert command['actions']['GET']['detectors']['POTATO'][0]['argc'] == 101
assert command['actions']['GET']['detectors']['POTATO'][0]['function'] == 'potato_function'
assert command['actions']['GET']['detectors']['POTATO'][1]['argc'] == 202
assert command['actions']['GET']['detectors']['POTATO'][1]['function'] == 'do_potato'

View File

@ -0,0 +1,29 @@
from pathlib import Path
from commands_parser.commands_parser import CommandParser
import gen_commands
data_path = Path(__file__).parent.parent
def test_parse_and_generate(tmp_path):
"""
tests that the parse and generate functions work without errors
:param tmp_path:
:return:
"""
output_file = tmp_path / "detectors.yaml"
command_parser = CommandParser(commands_file=data_path / "commands.yaml", output_file=output_file)
command_parser.verify_format()
command_parser.parse_all_commands()
assert output_file.exists()
GEN_PATH = Path(__file__).parent.parent
gen_commands.generate(
output_file,
GEN_PATH / "Caller.in.cpp",
GEN_PATH / "Caller.in.h",
tmp_path / "Caller.cpp",
tmp_path / "Caller.h",
)
assert (tmp_path / "Caller.cpp").exists()
assert (tmp_path / "Caller.h").exists()

View File

@ -0,0 +1,28 @@
hostname (find +)
acquire
versions (maybe with few tweaks)
threshold (+++++)
trimen (maybe with few tweaks)
badchannels (somewhat special)
currentsource (special)
dacvalues (can be done with the ctb_output_list)
udp_srcip (could be done if I add condition functionality for logging)
udp_srcip2 (same as above)
udp_dstip (same as above)
udp_dstip2
rx_hostname (split('+'))
rx_roi (can be done if there;s condition support?)
ratecorr (can be done if there's condition support?)
burstmode (very special)
vetostream
counters
gaincaps (has for loop and condition)
samples (ask Dhanya if it is okay to change the order of calling the ctb functions in PUT)
slowadc (has for loop)
rx_dbitlist (very special)
rx_jsonaddheader (very special)
execcommand (has for loop)
thresholdnotb
# notes
# ReceiverStatus error on put is not done
# ask about burstmode function

View File

@ -71,7 +71,6 @@ class Detector {
/** Gets shared memory ID */
int getShmId() const;
/** package git branch */
std::string getPackageVersion() const;
std::string getClientVersion() const;
@ -99,7 +98,7 @@ class Detector {
Result<std::string> getReceiverVersion(Positions pos = {}) const;
/** Options: EIGER, JUNGFRAU, GOTTHARD, MOENCH, MYTHEN3, GOTTHARD2,
* CHIPTESTBOARD */
* CHIPTESTBOARD, XILINX_CHIPTESTBOARD */
Result<defs::detectorType> getDetectorType(Positions pos = {}) const;
/** Gets the total number of modules in shared memory */
@ -216,7 +215,10 @@ class Detector {
/** [Jungfrau][Moench] **/
Result<bool> getSynchronization(Positions pos = {}) const;
/** [Jungfrau][Moench] */
/** [Jungfrau][Moench] Sync mode requires at least one master configured.
Also requires flatband cabling between master and slave with
termination board.
*/
void setSynchronization(bool value);
/** [Gotthard2][Mythen3] */
@ -320,11 +322,11 @@ class Detector {
/** [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] */
void setDelayAfterTrigger(ns value, Positions pos = {});
/** [Gotthard][Jungfrau][Moench][CTB][Mythen3]
/** [Gotthard][Jungfrau][Moench][CTB][Mythen3][Xilinx CTB]
* [Gotthard2] only in continuous auto mode */
Result<int64_t> getNumberOfFramesLeft(Positions pos = {}) const;
/** [Gotthard][Jungfrau][Moench][CTB][Mythen3]
/** [Gotthard][Jungfrau][Moench][CTB][Mythen3][Xilinx CTB]
* Only when external trigger used */
Result<int64_t> getNumberOfTriggersLeft(Positions pos = {}) const;
@ -341,7 +343,7 @@ class Detector {
/**
* [Eiger] Options: 4, 8, 12, 16, 32. If i is 32, also sets clkdivider to 2,
* else sets clkdivider to 1 \n [Mythen3] Options: 8, 16, 32 \n
* [Jungfrau][Moench][Gotthard][Ctb][Mythen3][Gotthard2] 16
* [Jungfrau][Moench][Gotthard][CTB][Mythen3][Gotthard2][Xilinx CTB] 16
*/
void setDynamicRange(int value);
@ -351,10 +353,10 @@ class Detector {
Result<defs::timingMode> getTimingMode(Positions pos = {}) const;
/**
* [Gotthard][Jungfrau][Moench][Gotthard][CTB][Gotthard2] Options:
* AUTO_TIMING, TRIGGER_EXPOSURE \n
* [Mythen3] Options: AUTO_TIMING, TRIGGER_EXPOSURE, GATED, TRIGGER_GATED \n
* [Eiger] Options: AUTO_TIMING, TRIGGER_EXPOSURE, GATED, BURST_TRIGGER
* [Gotthard][Jungfrau][Moench][Gotthard][CTB][Gotthard2][Xilinx CTB]
* Options: AUTO_TIMING, TRIGGER_EXPOSURE \n [Mythen3] Options: AUTO_TIMING,
* TRIGGER_EXPOSURE, GATED, TRIGGER_GATED \n [Eiger] Options: AUTO_TIMING,
* TRIGGER_EXPOSURE, GATED, BURST_TRIGGER
*/
void setTimingMode(defs::timingMode value, Positions pos = {});
@ -1844,20 +1846,20 @@ class Detector {
* Pattern *
* *
* ************************************************/
/** [CTB][Mythen3] Gets the pattern file name including path of the last
* pattern uploaded. \n Returns an empty if nothing was uploaded or via a
* server default file*/
/** [CTB][Mythen3][Xilinx CTB] Gets the pattern file name including path of
* the last pattern uploaded. \n Returns an empty if nothing was uploaded or
* via a server default file*/
Result<std::string> getPatterFileName(Positions pos = {}) const;
/** [CTB][Mythen3] Loads ASCII pattern file directly to server
/** [CTB][Mythen3][Xilinx CTB] Loads ASCII pattern file directly to server
* (instead of executing line by line)*/
void setPattern(const std::string &fname, Positions pos = {});
/** [CTB][Mythen3] Loads pattern parameters structure directly to
* server */
/** [CTB][Mythen3][Xilinx CTB] Loads pattern parameters structure directly
* to server */
void setPattern(const Pattern &pat, Positions pos = {});
/** [CTB][Mythen3] [Ctb][Mythen3] Saves pattern to file
/** [CTB][Mythen3][Xilinx CTB] Saves pattern to file
* (ascii). \n [Ctb] Also executes pattern.*/
void savePattern(const std::string &fname);
@ -1870,57 +1872,57 @@ class Detector {
/** [CTB] */
void setPatternIOControl(uint64_t word, Positions pos = {});
/** [CTB][Mythen3] same as executing for ctb */
/** [CTB][Mythen3][Xilinx CTB] same as executing for ctb */
Result<uint64_t> getPatternWord(int addr, Positions pos = {});
/** [CTB] Caution: If word is -1 reads the addr (same as
/** [CTB][Xilinx CTB] Caution: If word is -1 reads the addr (same as
* executing the pattern)
* [Mythen3] */
void setPatternWord(int addr, uint64_t word, Positions pos = {});
/**[CTB][Mythen3] Options: level: -1 (complete pattern) and 0-2
/**[CTB][Mythen3][Xilinx CTB] Options: level: -1 (complete pattern) and 0-2
* levels
* @returns array of start address and stop address
*/
Result<std::array<int, 2>>
getPatternLoopAddresses(int level, Positions pos = {}) const;
/** [CTB][Mythen3] Options: level: -1 (complete pattern) and 0-2
/** [CTB][Mythen3][Xilinx CTB] Options: level: -1 (complete pattern) and 0-2
* levels */
void setPatternLoopAddresses(int level, int start, int stop,
Positions pos = {});
/**[CTB][Mythen3] Options: level: -1 (complete pattern) and 0-2
/**[CTB][Mythen3][Xilinx CTB] Options: level: -1 (complete pattern) and 0-2
* levels */
Result<int> getPatternLoopCycles(int level, Positions pos = {}) const;
/** [CTB][Mythen3] n: 0-2, level: -1 (complete pattern) and 0-2
/** [CTB][Mythen3][Xilinx CTB] n: 0-2, level: -1 (complete pattern) and 0-2
* levels */
void setPatternLoopCycles(int level, int n, Positions pos = {});
/**[CTB][Mythen3] */
/**[CTB][Mythen3][Xilinx CTB] */
Result<int> getPatternWaitAddr(int level, Positions pos = {}) const;
/** [CTB][Mythen3] Options: level 0-2 */
/** [CTB][Mythen3][Xilinx CTB] Options: level 0-2 */
void setPatternWaitAddr(int level, int addr, Positions pos = {});
/** [CTB][Mythen3] */
/** [CTB][Mythen3][Xilinx CTB] */
Result<uint64_t> getPatternWaitTime(int level, Positions pos = {}) const;
/** [CTB][Mythen3] Options: level 0-2 */
/** [CTB][Mythen3][Xilinx CTB] Options: level 0-2 */
void setPatternWaitTime(int level, uint64_t t, Positions pos = {});
/** [CTB][Mythen3] */
/** [CTB][Mythen3][Xilinx CTB] */
Result<uint64_t> getPatternMask(Positions pos = {});
/** [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. */
void setPatternMask(uint64_t mask, Positions pos = {});
/** [CTB][Mythen3] */
/** [CTB][Mythen3][Xilinx CTB] */
Result<uint64_t> getPatternBitMask(Positions pos = {}) const;
/** [CTB][Mythen3] Sets the mask applied to every pattern to the
/** [CTB][Mythen3][Xilinx CTB] Sets the mask applied to every pattern to the
* selected bits */
void setPatternBitMask(uint64_t mask, Positions pos = {});

View File

@ -8,7 +8,8 @@
* from the detector. Since every module could have a different value, we need
* to return a vector instead of just a single value.
*
* Easy conversions to single values are provided using the squash method.
* Easy conversions to single values are provided using the squash and tsquash
* method.
*/
#include <algorithm>
@ -16,6 +17,7 @@
#include <vector>
#include "sls/ToString.h"
#include "sls/TypeTraits.h"
#include "sls/container_utils.h"
namespace sls {
@ -128,6 +130,25 @@ template <class T, class Allocator = std::allocator<T>> class Result {
/** Test whether all elements of the result are equal */
bool equal() const noexcept { return allEqual(vec); }
/** Test whether any element of the result are equal to a value */
bool any(const T &value) const noexcept { return anyEqualTo(vec, value); }
template <typename V, typename... Args, typename = AllSame<V, Args...>>
typename std::enable_if<std::is_same<V, T>::value, bool>::type
contains_only(const V &a, const Args &...args) const noexcept {
auto values = {a, args...};
for (const auto &element : vec) {
int found = 0;
for (const auto &value : values) {
if (value == element)
found++;
}
if (!found)
return false;
}
return true;
}
/** Convert Result<T> to std::vector<T> */
operator std::vector<T>() { return vec; }
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,878 @@
// 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);
std::string acquire(int action);
std::string activate(int action);
std::string adcclk(int action);
std::string adcenable(int action);
std::string adcenable10g(int action);
std::string adcindex(int action);
std::string adcinvert(int action);
std::string adclist(int action);
std::string adcname(int action);
std::string adcphase(int action);
std::string adcpipeline(int action);
std::string adcreg(int action);
std::string adcvpp(int action);
std::string apulse(int action);
std::string asamples(int action);
std::string autocompdisable(int action);
std::string badchannels(int action);
std::string blockingtrigger(int action);
std::string burstmode(int action);
std::string burstperiod(int action);
std::string bursts(int action);
std::string burstsl(int action);
std::string bustest(int action);
std::string cdsgain(int action);
std::string chipversion(int action);
std::string clearbit(int action);
std::string clearbusy(int action);
std::string clearroi(int action);
std::string clientversion(int action);
std::string clkdiv(int action);
std::string clkfreq(int action);
std::string clkphase(int action);
std::string column(int action);
std::string compdisabletime(int action);
std::string confadc(int action);
std::string config(int action);
std::string counters(int action);
std::string currentsource(int action);
std::string dac(int action);
std::string dacindex(int action);
std::string daclist(int action);
std::string dacname(int action);
std::string dacvalues(int action);
std::string datastream(int action);
std::string dbitclk(int action);
std::string dbitphase(int action);
std::string dbitpipeline(int action);
std::string defaultdac(int action);
std::string defaultpattern(int action);
std::string delay(int action);
std::string delayl(int action);
std::string detectorserverversion(int action);
std::string detsize(int action);
std::string diodelay(int action);
std::string dpulse(int action);
std::string dr(int action);
std::string drlist(int action);
std::string dsamples(int action);
std::string execcommand(int action);
std::string exptime(int action);
std::string exptime1(int action);
std::string exptime2(int action);
std::string exptime3(int action);
std::string exptimel(int action);
std::string extrastoragecells(int action);
std::string extsampling(int action);
std::string extsamplingsrc(int action);
std::string extsig(int action);
std::string fformat(int action);
std::string filtercells(int action);
std::string filterresistor(int action);
std::string findex(int action);
std::string firmwaretest(int action);
std::string firmwareversion(int action);
std::string fliprows(int action);
std::string flowcontrol10g(int action);
std::string fmaster(int action);
std::string fname(int action);
std::string foverwrite(int action);
std::string fpath(int action);
std::string framecounter(int action);
std::string frames(int action);
std::string framesl(int action);
std::string frametime(int action);
std::string free(int action);
std::string fwrite(int action);
std::string gaincaps(int action);
std::string gainmode(int action);
std::string gappixels(int action);
std::string gatedelay(int action);
std::string gatedelay1(int action);
std::string gatedelay2(int action);
std::string gatedelay3(int action);
std::string gates(int action);
std::string getbit(int action);
std::string hardwareversion(int action);
std::string highvoltage(int action);
std::string hostname(int action);
std::string im_a(int action);
std::string im_b(int action);
std::string im_c(int action);
std::string im_d(int action);
std::string im_io(int action);
std::string imagetest(int action);
std::string initialchecks(int action);
std::string inj_ch(int action);
std::string interpolation(int action);
std::string interruptsubframe(int action);
std::string kernelversion(int action);
std::string lastclient(int action);
std::string led(int action);
std::string lock(int action);
std::string master(int action);
std::string maxadcphaseshift(int action);
std::string maxclkphaseshift(int action);
std::string maxdbitphaseshift(int action);
std::string measuredperiod(int action);
std::string measuredsubperiod(int action);
std::string moduleid(int action);
std::string nextframenumber(int action);
std::string nmod(int action);
std::string numinterfaces(int action);
std::string overflow(int action);
std::string packageversion(int action);
std::string parallel(int action);
std::string parameters(int action);
std::string partialreset(int action);
std::string patfname(int action);
std::string patioctrl(int action);
std::string patlimits(int action);
std::string patloop(int action);
std::string patloop0(int action);
std::string patloop1(int action);
std::string patloop2(int action);
std::string patmask(int action);
std::string patnloop(int action);
std::string patnloop0(int action);
std::string patnloop1(int action);
std::string patnloop2(int action);
std::string patsetbit(int action);
std::string pattern(int action);
std::string patternstart(int action);
std::string patwait(int action);
std::string patwait0(int action);
std::string patwait1(int action);
std::string patwait2(int action);
std::string patwaittime(int action);
std::string patwaittime0(int action);
std::string patwaittime1(int action);
std::string patwaittime2(int action);
std::string patword(int action);
std::string pedestalmode(int action);
std::string period(int action);
std::string periodl(int action);
std::string polarity(int action);
std::string port(int action);
std::string powerchip(int action);
std::string powerindex(int action);
std::string powerlist(int action);
std::string powername(int action);
std::string powervalues(int action);
std::string programfpga(int action);
std::string pulse(int action);
std::string pulsechip(int action);
std::string pulsenmove(int action);
std::string pumpprobe(int action);
std::string quad(int action);
std::string ratecorr(int action);
std::string readnrows(int action);
std::string readout(int action);
std::string readoutspeed(int action);
std::string readoutspeedlist(int action);
std::string rebootcontroller(int action);
std::string reg(int action);
std::string resetdacs(int action);
std::string resetfpga(int action);
std::string roi(int action);
std::string romode(int action);
std::string row(int action);
std::string runclk(int action);
std::string runtime(int action);
std::string rx_arping(int action);
std::string rx_clearroi(int action);
std::string rx_dbitlist(int action);
std::string rx_dbitoffset(int action);
std::string rx_discardpolicy(int action);
std::string rx_fifodepth(int action);
std::string rx_frameindex(int action);
std::string rx_framescaught(int action);
std::string rx_framesperfile(int action);
std::string rx_hostname(int action);
std::string rx_jsonaddheader(int action);
std::string rx_jsonpara(int action);
std::string rx_lastclient(int action);
std::string rx_lock(int action);
std::string rx_missingpackets(int action);
std::string rx_padding(int action);
std::string rx_printconfig(int action);
std::string rx_realudpsocksize(int action);
std::string rx_roi(int action);
std::string rx_silent(int action);
std::string rx_start(int action);
std::string rx_status(int action);
std::string rx_stop(int action);
std::string rx_tcpport(int action);
std::string rx_threads(int action);
std::string rx_udpsocksize(int action);
std::string rx_version(int action);
std::string rx_zmqfreq(int action);
std::string rx_zmqhwm(int action);
std::string rx_zmqip(int action);
std::string rx_zmqport(int action);
std::string rx_zmqstartfnum(int action);
std::string rx_zmqstream(int action);
std::string samples(int action);
std::string savepattern(int action);
std::string scan(int action);
std::string scanerrmsg(int action);
std::string selinterface(int action);
std::string serialnumber(int action);
std::string setbit(int action);
std::string settings(int action);
std::string settingslist(int action);
std::string settingspath(int action);
std::string signalindex(int action);
std::string signallist(int action);
std::string signalname(int action);
std::string slowadc(int action);
std::string slowadcindex(int action);
std::string slowadclist(int action);
std::string slowadcname(int action);
std::string slowadcvalues(int action);
std::string start(int action);
std::string status(int action);
std::string stop(int action);
std::string stopport(int action);
std::string storagecell_delay(int action);
std::string storagecell_start(int action);
std::string subdeadtime(int action);
std::string subexptime(int action);
std::string sync(int action);
std::string syncclk(int action);
std::string temp_10ge(int action);
std::string temp_adc(int action);
std::string temp_control(int action);
std::string temp_dcdc(int action);
std::string temp_event(int action);
std::string temp_fpga(int action);
std::string temp_fpgaext(int action);
std::string temp_fpgafl(int action);
std::string temp_fpgafr(int action);
std::string temp_slowadc(int action);
std::string temp_sodl(int action);
std::string temp_sodr(int action);
std::string temp_threshold(int action);
std::string templist(int action);
std::string tempvalues(int action);
std::string tengiga(int action);
std::string threshold(int action);
std::string timing(int action);
std::string timinglist(int action);
std::string timingsource(int action);
std::string top(int action);
std::string transceiverenable(int action);
std::string trigger(int action);
std::string triggers(int action);
std::string triggersl(int action);
std::string trimbits(int action);
std::string trimen(int action);
std::string trimval(int action);
std::string tsamples(int action);
std::string txdelay(int action);
std::string txdelay_frame(int action);
std::string txdelay_left(int action);
std::string txdelay_right(int action);
std::string type(int action);
std::string udp_cleardst(int action);
std::string udp_dstip(int action);
std::string udp_dstip2(int action);
std::string udp_dstlist(int action);
std::string udp_dstmac(int action);
std::string udp_dstmac2(int action);
std::string udp_dstport(int action);
std::string udp_dstport2(int action);
std::string udp_firstdst(int action);
std::string udp_numdst(int action);
std::string udp_reconfigure(int action);
std::string udp_srcip(int action);
std::string udp_srcip2(int action);
std::string udp_srcmac(int action);
std::string udp_srcmac2(int action);
std::string udp_validate(int action);
std::string update(int action);
std::string updatedetectorserver(int action);
std::string updatekernel(int action);
std::string updatemode(int action);
std::string user(int action);
std::string v_a(int action);
std::string v_b(int action);
std::string v_c(int action);
std::string v_chip(int action);
std::string v_d(int action);
std::string v_io(int action);
std::string v_limit(int action);
std::string vchip_comp_adc(int action);
std::string vchip_comp_fe(int action);
std::string vchip_cs(int action);
std::string vchip_opa_1st(int action);
std::string vchip_opa_fd(int action);
std::string vchip_ref_comp_fe(int action);
std::string versions(int action);
std::string veto(int action);
std::string vetoalg(int action);
std::string vetofile(int action);
std::string vetophoton(int action);
std::string vetoref(int action);
std::string vetostream(int action);
std::string virtualFunction(int action);
std::string vm_a(int action);
std::string vm_b(int action);
std::string vm_c(int action);
std::string vm_d(int action);
std::string vm_io(int action);
std::string zmqhwm(int action);
std::string zmqip(int action);
std::string zmqport(int action);
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},
{"acquire", &Caller::acquire},
{"activate", &Caller::activate},
{"adcclk", &Caller::adcclk},
{"adcenable", &Caller::adcenable},
{"adcenable10g", &Caller::adcenable10g},
{"adcindex", &Caller::adcindex},
{"adcinvert", &Caller::adcinvert},
{"adclist", &Caller::adclist},
{"adcname", &Caller::adcname},
{"adcphase", &Caller::adcphase},
{"adcpipeline", &Caller::adcpipeline},
{"adcreg", &Caller::adcreg},
{"adcvpp", &Caller::adcvpp},
{"apulse", &Caller::apulse},
{"asamples", &Caller::asamples},
{"autocompdisable", &Caller::autocompdisable},
{"badchannels", &Caller::badchannels},
{"blockingtrigger", &Caller::blockingtrigger},
{"burstmode", &Caller::burstmode},
{"burstperiod", &Caller::burstperiod},
{"bursts", &Caller::bursts},
{"burstsl", &Caller::burstsl},
{"bustest", &Caller::bustest},
{"cdsgain", &Caller::cdsgain},
{"chipversion", &Caller::chipversion},
{"clearbit", &Caller::clearbit},
{"clearbusy", &Caller::clearbusy},
{"clearroi", &Caller::clearroi},
{"clientversion", &Caller::clientversion},
{"clkdiv", &Caller::clkdiv},
{"clkfreq", &Caller::clkfreq},
{"clkphase", &Caller::clkphase},
{"column", &Caller::column},
{"compdisabletime", &Caller::compdisabletime},
{"confadc", &Caller::confadc},
{"config", &Caller::config},
{"counters", &Caller::counters},
{"currentsource", &Caller::currentsource},
{"dac", &Caller::dac},
{"dacindex", &Caller::dacindex},
{"daclist", &Caller::daclist},
{"dacname", &Caller::dacname},
{"dacvalues", &Caller::dacvalues},
{"datastream", &Caller::datastream},
{"dbitclk", &Caller::dbitclk},
{"dbitphase", &Caller::dbitphase},
{"dbitpipeline", &Caller::dbitpipeline},
{"defaultdac", &Caller::defaultdac},
{"defaultpattern", &Caller::defaultpattern},
{"delay", &Caller::delay},
{"delayl", &Caller::delayl},
{"detectorserverversion", &Caller::detectorserverversion},
{"detsize", &Caller::detsize},
{"diodelay", &Caller::diodelay},
{"dpulse", &Caller::dpulse},
{"dr", &Caller::dr},
{"drlist", &Caller::drlist},
{"dsamples", &Caller::dsamples},
{"execcommand", &Caller::execcommand},
{"exptime", &Caller::exptime},
{"exptime1", &Caller::exptime1},
{"exptime2", &Caller::exptime2},
{"exptime3", &Caller::exptime3},
{"exptimel", &Caller::exptimel},
{"extrastoragecells", &Caller::extrastoragecells},
{"extsampling", &Caller::extsampling},
{"extsamplingsrc", &Caller::extsamplingsrc},
{"extsig", &Caller::extsig},
{"fformat", &Caller::fformat},
{"filtercells", &Caller::filtercells},
{"filterresistor", &Caller::filterresistor},
{"findex", &Caller::findex},
{"firmwaretest", &Caller::firmwaretest},
{"firmwareversion", &Caller::firmwareversion},
{"fliprows", &Caller::fliprows},
{"flowcontrol10g", &Caller::flowcontrol10g},
{"fmaster", &Caller::fmaster},
{"fname", &Caller::fname},
{"foverwrite", &Caller::foverwrite},
{"fpath", &Caller::fpath},
{"framecounter", &Caller::framecounter},
{"frames", &Caller::frames},
{"framesl", &Caller::framesl},
{"frametime", &Caller::frametime},
{"free", &Caller::free},
{"fwrite", &Caller::fwrite},
{"gaincaps", &Caller::gaincaps},
{"gainmode", &Caller::gainmode},
{"gappixels", &Caller::gappixels},
{"gatedelay", &Caller::gatedelay},
{"gatedelay1", &Caller::gatedelay1},
{"gatedelay2", &Caller::gatedelay2},
{"gatedelay3", &Caller::gatedelay3},
{"gates", &Caller::gates},
{"getbit", &Caller::getbit},
{"hardwareversion", &Caller::hardwareversion},
{"highvoltage", &Caller::highvoltage},
{"hostname", &Caller::hostname},
{"im_a", &Caller::im_a},
{"im_b", &Caller::im_b},
{"im_c", &Caller::im_c},
{"im_d", &Caller::im_d},
{"im_io", &Caller::im_io},
{"imagetest", &Caller::imagetest},
{"initialchecks", &Caller::initialchecks},
{"inj_ch", &Caller::inj_ch},
{"interpolation", &Caller::interpolation},
{"interruptsubframe", &Caller::interruptsubframe},
{"kernelversion", &Caller::kernelversion},
{"lastclient", &Caller::lastclient},
{"led", &Caller::led},
{"lock", &Caller::lock},
{"master", &Caller::master},
{"maxadcphaseshift", &Caller::maxadcphaseshift},
{"maxclkphaseshift", &Caller::maxclkphaseshift},
{"maxdbitphaseshift", &Caller::maxdbitphaseshift},
{"measuredperiod", &Caller::measuredperiod},
{"measuredsubperiod", &Caller::measuredsubperiod},
{"moduleid", &Caller::moduleid},
{"nextframenumber", &Caller::nextframenumber},
{"nmod", &Caller::nmod},
{"numinterfaces", &Caller::numinterfaces},
{"overflow", &Caller::overflow},
{"packageversion", &Caller::packageversion},
{"parallel", &Caller::parallel},
{"parameters", &Caller::parameters},
{"partialreset", &Caller::partialreset},
{"patfname", &Caller::patfname},
{"patioctrl", &Caller::patioctrl},
{"patlimits", &Caller::patlimits},
{"patloop", &Caller::patloop},
{"patloop0", &Caller::patloop0},
{"patloop1", &Caller::patloop1},
{"patloop2", &Caller::patloop2},
{"patmask", &Caller::patmask},
{"patnloop", &Caller::patnloop},
{"patnloop0", &Caller::patnloop0},
{"patnloop1", &Caller::patnloop1},
{"patnloop2", &Caller::patnloop2},
{"patsetbit", &Caller::patsetbit},
{"patternX", &Caller::pattern},
{"patternstart", &Caller::patternstart},
{"patwait", &Caller::patwait},
{"patwait0", &Caller::patwait0},
{"patwait1", &Caller::patwait1},
{"patwait2", &Caller::patwait2},
{"patwaittime", &Caller::patwaittime},
{"patwaittime0", &Caller::patwaittime0},
{"patwaittime1", &Caller::patwaittime1},
{"patwaittime2", &Caller::patwaittime2},
{"patword", &Caller::patword},
{"pedestalmode", &Caller::pedestalmode},
{"period", &Caller::period},
{"periodl", &Caller::periodl},
{"polarity", &Caller::polarity},
{"port", &Caller::port},
{"powerchip", &Caller::powerchip},
{"powerindex", &Caller::powerindex},
{"powerlist", &Caller::powerlist},
{"powername", &Caller::powername},
{"powervalues", &Caller::powervalues},
{"programfpga", &Caller::programfpga},
{"pulse", &Caller::pulse},
{"pulsechip", &Caller::pulsechip},
{"pulsenmove", &Caller::pulsenmove},
{"pumpprobe", &Caller::pumpprobe},
{"quad", &Caller::quad},
{"ratecorr", &Caller::ratecorr},
{"readnrows", &Caller::readnrows},
{"readout", &Caller::readout},
{"readoutspeed", &Caller::readoutspeed},
{"readoutspeedlist", &Caller::readoutspeedlist},
{"rebootcontroller", &Caller::rebootcontroller},
{"reg", &Caller::reg},
{"resetdacs", &Caller::resetdacs},
{"resetfpga", &Caller::resetfpga},
{"roi", &Caller::roi},
{"romode", &Caller::romode},
{"row", &Caller::row},
{"runclk", &Caller::runclk},
{"runtime", &Caller::runtime},
{"rx_arping", &Caller::rx_arping},
{"rx_clearroi", &Caller::rx_clearroi},
{"rx_dbitlist", &Caller::rx_dbitlist},
{"rx_dbitoffset", &Caller::rx_dbitoffset},
{"rx_discardpolicy", &Caller::rx_discardpolicy},
{"rx_fifodepth", &Caller::rx_fifodepth},
{"rx_frameindex", &Caller::rx_frameindex},
{"rx_framescaught", &Caller::rx_framescaught},
{"rx_framesperfile", &Caller::rx_framesperfile},
{"rx_hostname", &Caller::rx_hostname},
{"rx_jsonaddheader", &Caller::rx_jsonaddheader},
{"rx_jsonpara", &Caller::rx_jsonpara},
{"rx_lastclient", &Caller::rx_lastclient},
{"rx_lock", &Caller::rx_lock},
{"rx_missingpackets", &Caller::rx_missingpackets},
{"rx_padding", &Caller::rx_padding},
{"rx_printconfig", &Caller::rx_printconfig},
{"rx_realudpsocksize", &Caller::rx_realudpsocksize},
{"rx_roi", &Caller::rx_roi},
{"rx_silent", &Caller::rx_silent},
{"rx_start", &Caller::rx_start},
{"rx_status", &Caller::rx_status},
{"rx_stop", &Caller::rx_stop},
{"rx_tcpport", &Caller::rx_tcpport},
{"rx_threads", &Caller::rx_threads},
{"rx_udpsocksize", &Caller::rx_udpsocksize},
{"rx_version", &Caller::rx_version},
{"rx_zmqfreq", &Caller::rx_zmqfreq},
{"rx_zmqhwm", &Caller::rx_zmqhwm},
{"rx_zmqip", &Caller::rx_zmqip},
{"rx_zmqport", &Caller::rx_zmqport},
{"rx_zmqstartfnum", &Caller::rx_zmqstartfnum},
{"rx_zmqstream", &Caller::rx_zmqstream},
{"samples", &Caller::samples},
{"savepattern", &Caller::savepattern},
{"scan", &Caller::scan},
{"scanerrmsg", &Caller::scanerrmsg},
{"selinterface", &Caller::selinterface},
{"serialnumber", &Caller::serialnumber},
{"setbit", &Caller::setbit},
{"settings", &Caller::settings},
{"settingslist", &Caller::settingslist},
{"settingspath", &Caller::settingspath},
{"signalindex", &Caller::signalindex},
{"signallist", &Caller::signallist},
{"signalname", &Caller::signalname},
{"slowadc", &Caller::slowadc},
{"slowadcindex", &Caller::slowadcindex},
{"slowadclist", &Caller::slowadclist},
{"slowadcname", &Caller::slowadcname},
{"slowadcvalues", &Caller::slowadcvalues},
{"start", &Caller::start},
{"status", &Caller::status},
{"stop", &Caller::stop},
{"stopport", &Caller::stopport},
{"storagecell_delay", &Caller::storagecell_delay},
{"storagecell_start", &Caller::storagecell_start},
{"subdeadtime", &Caller::subdeadtime},
{"subexptime", &Caller::subexptime},
{"sync", &Caller::sync},
{"syncclk", &Caller::syncclk},
{"temp_10ge", &Caller::temp_10ge},
{"temp_adc", &Caller::temp_adc},
{"temp_control", &Caller::temp_control},
{"temp_dcdc", &Caller::temp_dcdc},
{"temp_event", &Caller::temp_event},
{"temp_fpga", &Caller::temp_fpga},
{"temp_fpgaext", &Caller::temp_fpgaext},
{"temp_fpgafl", &Caller::temp_fpgafl},
{"temp_fpgafr", &Caller::temp_fpgafr},
{"temp_slowadc", &Caller::temp_slowadc},
{"temp_sodl", &Caller::temp_sodl},
{"temp_sodr", &Caller::temp_sodr},
{"temp_threshold", &Caller::temp_threshold},
{"templist", &Caller::templist},
{"tempvalues", &Caller::tempvalues},
{"tengiga", &Caller::tengiga},
{"threshold", &Caller::threshold},
{"thresholdnotb", &Caller::threshold},
{"timing", &Caller::timing},
{"timinglist", &Caller::timinglist},
{"timingsource", &Caller::timingsource},
{"top", &Caller::top},
{"transceiverenable", &Caller::transceiverenable},
{"trigger", &Caller::trigger},
{"triggers", &Caller::triggers},
{"triggersl", &Caller::triggersl},
{"trimbits", &Caller::trimbits},
{"trimen", &Caller::trimen},
{"trimval", &Caller::trimval},
{"tsamples", &Caller::tsamples},
{"txdelay", &Caller::txdelay},
{"txdelay_frame", &Caller::txdelay_frame},
{"txdelay_left", &Caller::txdelay_left},
{"txdelay_right", &Caller::txdelay_right},
{"type", &Caller::type},
{"udp_cleardst", &Caller::udp_cleardst},
{"udp_dstip", &Caller::udp_dstip},
{"udp_dstip2", &Caller::udp_dstip2},
{"udp_dstlist", &Caller::udp_dstlist},
{"udp_dstmac", &Caller::udp_dstmac},
{"udp_dstmac2", &Caller::udp_dstmac2},
{"udp_dstport", &Caller::udp_dstport},
{"udp_dstport2", &Caller::udp_dstport2},
{"udp_firstdst", &Caller::udp_firstdst},
{"udp_numdst", &Caller::udp_numdst},
{"udp_reconfigure", &Caller::udp_reconfigure},
{"udp_srcip", &Caller::udp_srcip},
{"udp_srcip2", &Caller::udp_srcip2},
{"udp_srcmac", &Caller::udp_srcmac},
{"udp_srcmac2", &Caller::udp_srcmac2},
{"udp_validate", &Caller::udp_validate},
{"update", &Caller::update},
{"updatedetectorserver", &Caller::updatedetectorserver},
{"updatekernel", &Caller::updatekernel},
{"updatemode", &Caller::updatemode},
{"user", &Caller::user},
{"v_a", &Caller::v_a},
{"v_b", &Caller::v_b},
{"v_c", &Caller::v_c},
{"v_chip", &Caller::v_chip},
{"v_d", &Caller::v_d},
{"v_io", &Caller::v_io},
{"v_limit", &Caller::v_limit},
{"vchip_comp_adc", &Caller::vchip_comp_adc},
{"vchip_comp_fe", &Caller::vchip_comp_fe},
{"vchip_cs", &Caller::vchip_cs},
{"vchip_opa_1st", &Caller::vchip_opa_1st},
{"vchip_opa_fd", &Caller::vchip_opa_fd},
{"vchip_ref_comp_fe", &Caller::vchip_ref_comp_fe},
{"versions", &Caller::versions},
{"veto", &Caller::veto},
{"vetoalg", &Caller::vetoalg},
{"vetofile", &Caller::vetofile},
{"vetophoton", &Caller::vetophoton},
{"vetoref", &Caller::vetoref},
{"vetostream", &Caller::vetostream},
{"virtual", &Caller::virtualFunction},
{"vm_a", &Caller::vm_a},
{"vm_b", &Caller::vm_b},
{"vm_c", &Caller::vm_c},
{"vm_d", &Caller::vm_d},
{"vm_io", &Caller::vm_io},
{"zmqhwm", &Caller::zmqhwm},
{"zmqip", &Caller::zmqip},
{"zmqport", &Caller::zmqport}
};
StringMap depreciated_functions{
{"detectorversion", "firmwareversion"},
{"softwareversion", "detectorserverversion"},
{"receiverversion", "rx_version"},
{"detectornumber", "serialnumber"},
{"thisversion", "clientversion"},
{"detsizechan", "detsize"},
{"trimdir", "settingspath"},
{"settingsdir", "settingspath"},
{"flippeddatax", "fliprows"},
{"cycles", "triggers"},
{"cyclesl", "triggersl"},
{"clkdivider", "readoutspeed"},
{"speed", "readoutspeed"},
{"vhighvoltage", "highvoltage"},
{"digitest", "imagetest"},
{"filter", "filterresistor"},
{"readnlines", "readnrows"},
{"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"},
{"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"},
{"busy", "clearbusy"},
{"receiver", "rx_status"},
{"framescaught", "rx_framescaught"},
{"startingfnum", "nextframenumber"},
{"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"},
{"r_silent", "rx_silent"},
{"r_discardpolicy", "rx_discardpolicy"},
{"r_padding", "rx_padding"},
{"r_lock", "rx_lock"},
{"r_lastclient", "rx_lastclient"},
{"fileformat", "fformat"},
{"outdir", "fpath"},
{"index", "findex"},
{"enablefwrite", "fwrite"},
{"masterfile", "fmaster"},
{"overwrite", "foverwrite"},
{"r_framesperfile", "rx_framesperfile"},
{"r_readfreq", "rx_zmqfreq"},
{"rx_readfreq", "rx_zmqfreq"},
{"rx_datastream", "rx_zmqstream"},
{"resmat", "partialreset"},
{"storagecells", "extrastoragecells"},
{"auto_comp_disable", "autocompdisable"},
{"comp_disable_time", "compdisabletime"},
{"adc", "slowadc"},
{"flags", "romode"},
{"i_a", "im_a"},
{"i_b", "im_b"},
{"i_c", "im_c"},
{"i_d", "im_d"},
{"i_io", "im_io"},
{"copydetectorserver", "updatedetectorserver"},
{"nframes", "framecounter"},
{"now", "runtime"},
{"timestamp", "frametime"},
{"frameindex", "rx_frameindex"},
};
};
} // namespace sls

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +1,12 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
/*
This file is used to generate the command line binaries
(sls_detector_get/put/acquire/help). By defines in CMake
we get the different files.
*/
#include "sls/Detector.h"
#include "Caller.h"
#include "CmdParser.h"
#include "CmdProxy.h"
#include "sls/sls_detector_defs.h"
#include "inferAction.h"
#include "sls/Detector.h"
#include "sls/logger.h"
#include "sls/versionAPI.h"
#include <cstring> //strcmp
#include <iostream>
int main(int argc, char *argv[]) {
// To genereate sepereate binaries for put, get, acquire and help
#ifdef PUT
int action = slsDetectorDefs::PUT_ACTION;
@ -33,6 +23,9 @@ int main(int argc, char *argv[]) {
#ifdef HELP
int action = slsDetectorDefs::HELP_ACTION;
#endif
#ifdef INFER
int action = -1;
#endif
// Check for --version in the arguments
for (int i = 1; i < argc; ++i) {
@ -45,14 +38,12 @@ int main(int argc, char *argv[]) {
sls::CmdParser parser;
parser.Parse(argc, argv);
// If we called sls_detector_acquire, add the acquire command
if (action == slsDetectorDefs::READOUT_ACTION)
parser.setCommand("acquire");
if (parser.isHelp())
action = slsDetectorDefs::HELP_ACTION;
else {
// Free shared memory should work also without a detector
// if we have an option for verify in the detector constructor
// we could avoid this but clutter the code
@ -65,22 +56,30 @@ int main(int argc, char *argv[]) {
}
}
// prevent mem size check
if (parser.command() == "config" && action == slsDetectorDefs::PUT_ACTION) {
sls::freeSharedMemory(parser.multi_id());
}
sls::InferAction inferAction = sls::InferAction();
try {
std::unique_ptr<sls::Detector> det{nullptr};
if (action != slsDetectorDefs::HELP_ACTION) {
det = sls::make_unique<sls::Detector>(parser.multi_id());
if (action == -1) {
action = inferAction.infer(parser);
std::string actionString =
(action == slsDetectorDefs::GET_ACTION) ? "GET" : "PUT";
std::cout << "inferred action: " << actionString << std::endl;
}
sls::CmdProxy proxy(det.get());
proxy.Call(parser.command(), parser.arguments(), parser.detector_id(),
action, std::cout, parser.receiver_id());
} catch (const sls::RuntimeError &e) {
std::unique_ptr<sls::Detector> d{nullptr};
if (action != slsDetectorDefs::HELP_ACTION) {
d = sls::make_unique<sls::Detector>(parser.multi_id());
}
sls::Caller c(d.get());
c.call(parser.command(), parser.arguments(), parser.detector_id(),
action, std::cout, parser.receiver_id());
} catch (sls::RuntimeError &e) {
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
}

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