diff --git a/CMakeLists.txt b/CMakeLists.txt
index 67476213b..7ee614911 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,7 @@
# Copyright (C) 2021 Contributors to the SLS Detector Package
cmake_minimum_required(VERSION 3.12)
project(slsDetectorPackage)
-set(PROJECT_VERSION 6.1.1)
+set(PROJECT_VERSION 7.0.0)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
diff --git a/README.md b/README.md
index a646d587a..abee0e773 100755
--- a/README.md
+++ b/README.md
@@ -1,102 +1,233 @@
-### Note
+## Dependencies
+Before building from source make sure that you have the [software wiki](https://slsdetectorgroup.github.io/devdoc/dependencies.html) installed. If installing using conda, conda will manage the dependencies. Avoid also installing packages with pip.
-Please do not update to any xxxx.xx.xx.dev0 tags. They are not releases, but tags for internal usage.
-Use only releases with tags such as x.x.x or x.x.x-rcx.
+## Documentaion
+Detailed documentation can be found in the [software wiki](https://slsdetectorgroup.github.io/devdoc/index.html) and on the [official site](https://www.psi.ch/en/detectors/software).
-### Documentation
-##### 5.0.0 - Latest Release
-Detailed documentation on the latest release can be found in the [software wiki](https://slsdetectorgroup.github.io/devdoc/index.html) and on the [official site](https://www.psi.ch/en/detectors/software).
+## Installation
-##### Older Releases
-Documentation is found in the package.
+### 1. Install binaries using conda
+Conda is not only useful to manage python environments but can also
+be used as a user space package manager. Dates in the tag (for eg. 2020.07.23.dev0)
+are from the developer branch. Please use released tags for stability.
+
+We have three different packages available:
+* **slsdetlib** shared libraries and command line utilities
+* **slsdetgui** GUI
+* **slsdet** Python bindings
-### Binaries
-Binaries for the slsDetectorPackage are available through conda.
```
-#Add conda channels
+#Add channels for dependencies and our library
conda config --add channels conda-forge
conda config --add channels slsdetectorgroup
conda config --set channel_priority strict
-conda install slsdetlib #only shared lib and command line
-conda install slsdet #python bindings (includes slsdetlib)
-conda install slsdetgui #gui (includes qt4)
-
-#Install specific version
-conda install slsdet=2020.03.02.dev0 #developer version from 3 March 2020
+#create and activate an environment with our library
+#replace 6.1.1 with the required tag
+conda create -n myenv slsdetlib=6.1.1
+conda activate myenv
+#ready to use
+sls_detector_get exptime
+etc ...
```
-### Source code
-One can also obtain the source code from this repository and compile.
```
-git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git
+# List available versions
+# lib and binaries
+conda search slsdetlib
+# python
+conda search slsdet
+# gui
+conda search slsdetgui
+```
+
+### 2. Build from source
+
+##### 2.1 Download Source Code from github
+```
+git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git --branch 7.0.0
+```
+
+**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.
```
-#### Dependencies
+# clone using recursive to get pybind11 submodule
+git clone --recursive https://github.com/slsdetectorgroup/slsDetectorPackage.git
-Refer [this page](https://slsdetectorgroup.github.io/devdoc/dependencies.html) for dependencies.
-
-
-#### Compilation
-
-Compiling can be done in two ways. Either with the convenience script
-cmk.sh or directly with cmake for more control.
-
-**1. Compile using script cmk.sh**
-
-These are mainly aimed at those not familiar with using ccmake and cmake.
+# update submodule when switching between releases
+cd slsDetectorPackage
+git submodule update --init
```
- The binaries are generated in slsDetectorPackage/build/bin directory.
- Usage: ./cmk.sh [-c] [-b] [-p] [e] [t] [r] [g] [s] [u] [i] [m] [n] [-h] [z] [-d ] [-l Install directory] [-k ] [-j ]
- -[no option]: only make
- -c: Clean
- -b: Builds/Rebuilds CMake files normal mode
- -p: Builds/Rebuilds Python API
- -h: Builds/Rebuilds Cmake files with HDF5 package
- -d: HDF5 Custom Directory
- -k: CMake command
- -l: Install directory
- -t: Build/Rebuilds only text client
- -r: Build/Rebuilds only receiver
- -g: Build/Rebuilds only gui
- -s: Simulator
- -u: Chip Test Gui
- -j: Number of threads to compile through
- -e: Debug mode
- -i: Builds tests
- -m: Manuals
- -n: Manuals without compiling doxygen (only rst)
- -z: Moench zmq processor
+##### 2.2 Build from source
+
+
+###### Build using CMake
+
+```
+# outside slsDetecorPackage folder
+mkdir build && cd build
+
+# configure & generate Makefiles using cmake
+# by listing all your options (alternately use ccmake described below)
+# cmake3 for some systems
+cmake ../slsDetectorPackage -DCMAKE_INSTALL_PREFIX=/your/install/path
+
+# compiled to the build/bin directory
+make -j12 #or whatever number of cores you are using to build
+
+# install headers and libs in /your/install/path directory
+make install
+```
+
+Instead of the cmake command, one can use ccmake to get a list of options to configure and generate Makefiles at ease.
+
+
+```
+# ccmake3 for some systems
+ccmake ..
+
+# choose the options
+# first press [c] - configure
+# 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 |
+| -DSLS_USE_GUI=ON | GUI |
+
+
+###### Build using in-built cmk.sh script
+
+```
+The binaries are generated in slsDetectorPackage/build/bin directory.
+
+Usage: ./cmk.sh [-b] [-c] [-d ] [e] [g] [-h] [i] [-j ]
+[-k ] [-l ] [m] [n] [-p] [-q ]
+[r] [s] [t] [u] [z]
+-[no option]: only make
+-b: Builds/Rebuilds CMake files normal mode
+-c: Clean
+-d: HDF5 Custom Directory
+-e: Debug mode
+-g: Build/Rebuilds gui
+-h: Builds/Rebuilds Cmake files with HDF5 package
+-i: Builds tests
+-j: Number of threads to compile through
+-k: CMake command
+-l: Install directory
+-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
+-u: Chip Test Gui
+-z: Moench zmq processor
- # get all options
- ./cmk.sh -?
+# display all options
+./cmk.sh -?
- # new build and compile in parallel:
- ./cmk.sh -bj5
-```
-
-**2. Compile without script**
-Use cmake to create out-of-source builds, by creating a build folder parallel to source directory. This would create a debug build with address sanitizers.
-```
- $ mkdir build
- $ cd build
- $ cmake ../slsDetectorPackage -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_SANITIZER=ON
- $ make -j12 #or whatever number of threads wanted
+# new build and compile in parallel (recommended basic option):
+./cmk.sh -cbj5
+
+# new build, python and compile in parallel:
+./cmk.sh -cbpj5
+
+#To use the system zmq (/usr/lib64) instead
+./cmk.sh -cbj5 -q /usr/lib64
```
-To install binaries using CMake
+###### Build on old distributions
+
+If your linux distribution doesn't come with a C++11 compiler (gcc>4.8) then
+it's possible to install a newer gcc using conda and build the slsDetectorPackage
+using this compiler
+
```
- git clone --recursive https://github.com/slsdetectorgroup/slsDetectorPackage.git
- mkdir build && cd build
- cmake ../slsDetectorPackage -DCMAKE_INSTALL_PREFIX=/your/install/path
- make -j12 #or whatever number of cores you are using to build
- make install
+#Create an environment with the dependencies
+conda create -n myenv gxx_linux-64 cmake zmq
+conda activate myenv
+
+# outside slsDetecorPackage folder
+mkdir build && cd build
+cmake ../slsDetectorPackage -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
+make -j12
+```
+
+###### Build slsDetectorGui (Qt5)
+
+1. Using pre-built binary on conda
+```
+conda create -n myenv slsdetgui=7.0.0
+conda activate myenv
+```
+
+2. Using system installation on RHEL7
+```
+yum install qt5-qtbase-devel.x86_64
+yum install qt5-qtsvg-devel.x86_64
+```
+
+3. Using conda
+```
+#Add channels for dependencies and our library
+conda config --add channels conda-forge
+conda config --add channels slsdetectorgroup
+conda config --set channel_priority strict
+
+# create environment to compile
+# on rhel7
+conda create -n slsgui zeromq gxx_linux-64 gxx_linux-64 mesa-libgl-devel-cos6-x86_64 qt
+# on fedora or newer systems
+conda create -n slsgui zeromq qt
+
+# when using conda compilers, would also need libgl, but no need for it on fedora unless maybe using it with ROOT
+
+# activate environment
+conda activate slsgui
+
+# compile with cmake outside slsDetecorPackage folder
+mkdir build && cd build
+cmake ../slsDetectorPackage -DSLS_USE_GUI=ON
+make -j12
+
+# or compile with cmk.sh
+cd slsDetectorPackage
+./cmk.sh -cbgj9
+```
+
+###### Build documentation from package
+The documentation for the slsDetectorPackage is build using a combination
+of Doxygen, Sphinx and Breathe. The easiest way to install the dependencies
+is to use conda
+
+```
+conda create -n myenv python sphinx_rtd_theme breathe
+```
+
+```
+# using cmake or ccmake to enable DSLS_BUILD_DOCS
+# outside slsDetecorPackage folder
+mkdir build && cd build
+cmake ../slsDetectorPackage -DSLS_BUILD_DOCS=ON
+
+make docs # generate API docs and build Sphinx RST
+make rst # rst only, saves time in case the API did not change
```
-### Support
+## Support
dhanya.thattil@psi.ch
- erik.frojdh@psi.ch
\ No newline at end of file
+ erik.frojdh@psi.ch
diff --git a/RELEASE.txt b/RELEASE.txt
index 0c59b40bb..191012b66 100644
--- a/RELEASE.txt
+++ b/RELEASE.txt
@@ -1,210 +1,133 @@
-SLS Detector Package Minor Release 7.0.0 released on 25.11.2021
+SLS Detector Package Major Release 7.x.x released on xx.xx.2023
===============================================================
-This document describes the differences between v7.0.0 and v6.x.x
+This document describes the differences between v7.x.x and v7.0.0
CONTENTS
--------
- 1. New or Changed Features
- 2. Resolved Issues
- 3. Firmware Requirements
- 4. Kernel Requirements
- 5. Download, Documentation & Support
+ 1 New, Changed or Resolved Features
+ 1.1 Compilation
+ 1.2 Callback
+ 1.3 Python
+ 1.4 Client
+ 1.5 Detector Server
+ 1.6 Simulator
+ 1.7 Receiver
+ 1.8 Gui
+ 2 On-board Detector Server Compatibility
+ 3 Firmware Requirements
+ 4 Kernel Requirements
+ 5 Download, Documentation & Support
-1. New or Changed Features
-==========================
-
-- Fixed minor warnings (will fix commandline print of excess packets for missing packets)
-- ctb slow adcs and any other adcs (other than temp) goes to the control Server
-- number of udp interfaces is 2 for Eiger (CHANGE IN API??)
-- added module id for virtual servers into the udp header
-- refactoring (rxr)
-- fixed patsetbit and patsetmask for moench
-- changed default vref of adc9257 to 2V for moench (from 1.33V)
-- moench and ctb - can set the starting frame number of next acquisition
-- mythen server kernel check incompatible (cet timezone)
-- rx_arping
-- rx_threadsids max is now 9 (breaking api)
-- fixed datastream disabling for eiger. Its only available in 10g mode.
-- m3 server crash (vthrehsold dac names were not provided)
-- allow vtrim to be interpolated for Eiger settings
-- m3 setThresholdEnergy and setAllThresholdEnergy was overwriting gaincaps with settings enum
-- can set localhost with virtual server with minimum configuration: (hostname localhost, rx_hostname localhost, udp_dstip auto)
-- increases the progress according to listened index. (not processed index)
-- current frame index points to listened frame index (not processed index)
-- when in discard partial frames or empty mode, the frame number doesnt increase by 1, it increases to that number (so its faster)
-- file write disabled by default
-- eiger 12 bit mode
-- start non blocking acquisition at modular level
-- connect master commands to api (allow set master for eiger)
---ignore-config command line
-- command line argument 'master' mainly for virtual servers (also master/top for real eiger), only one virtual server for eiger, use command lines for master/top
-- stop servers also check for errors at startup( in case it was running with an older version)
-- hostname cmd failed when connecting to servers in update mode (ctb, moench, jungfrau, eiger)
-- missingpackets signed (negative => extra packets)
-- framescaught and frameindex now returns a vector for each port
-- progress looks at activated or enabled ports, so progress does not stagnate
-- (eiger) disable datastreaming also for virtual servers only for 10g
-- missing packets also takes care of disabled ports
-- added geometry to metadata
-- 10g eiger nextframenumber get fixed.
-- stop, able to set nextframenumber to a consistent (max + 1) for all modules if different (eiger/ctb/jungfrau/moench)
-- ctb: can set names for all the dacs
-- fpga/kernel programming, checks if drive is a special file and not a normal file
-- gotthard 25 um image reconstructed in gui and virtual hdf5 (firmware updated for slave to reverse channels)
-- master binary file in json format now
-- fixed bug introduced in 6.0.0: hdf5 files created 1 file per frame after the initial file which had maxframesperfile
-- rx_roi
-- m3 polarity, interpolation (enables all counters when enabled), pump probe, analog pulsing, digital pulsing
-- updatedetectorserver - removes old server current binary pointing to for blackfin
-- removing copydetectorserver using tftp
-- registerCallBackRawDataReady and registerCallBackRawDataModifyReady now gives a sls_receiver_header* instead of a char*, and uint32_t to size_t
-- registerCallBackStartAcquisition gave incorrect imagesize (+120 bytes). corrected.
-- registerCallBackStartAcquisition parameter is a const string reference
-- m3 (runnig config second time with tengiga 0, dr !=32, counters !=0x7) calculated incorrect image size expected
-- fixed row column indexing (mainly for multi module Jungfrau 2 interfaces )
-- eiger gui row indices not flipped anymore (fix in config)
-- m3 (settings dac check disabled temporarily?)
-- m3 virtual server sends the right pacets now
-- gap pixels in gui enabled by default
-- rxr src files and classes (detectordata, ZmqSocket, helpDacs) added to sls namespace, and macros (namely from logger (logINFO etc)), slsDetectorGui (make_unique in implemtnation requires sls nemspace (points to std otherwise) but not deectorImpl.cpp)
-- blackfin programing made seamless (nCE fixed which helps)
--save settings file for m3 and eiger
-- m3 threshold changes
-- g2 and m3 clkdiv 2 (system clock) change should affect time settings (g2: exptime, period, delayaftertrigger, burstperiod, m3: exptime, gatedelay, gateperiod, period, delayaftertrigger)
-- g2 system frequency is the same irrespective of timing source
-- (apparently) rxr doesnt get stuck anymore from 6.1.1
-- rxr mem size changed (fifo header size from 8 to 16) due to sls rxr header = 112.. 112+ 16=128 (reduces packet losss especially for g2)
--udp_srcip and udp_Srcip2: can set to auto (for virtual or 1g data networks)
-- set dataset name for all hdf5 files to "data" only
-- number of storage cells is not updated in teh receiver. done. and also allowing it to be modified in running status
-- refactored memory structure in receiver and listener code (maybe resolves stuck issue, need to check)
-- callback modified to have rx header and not rx header pointer
-- adapted for g2 hdi v2.0. able to set master from server command line, server config file, and client.
-- rx udp socket refactored (maybe resolves getting stuck?)remove check for eiger header and isntead checks for malformed packets for every detector
-- jungfrau sw trigger , blocking trigger
--help should not create a new object
-- jungfrau master
-- g2 parallel command
-- jungfrau sync
-- m3 bad channels (badchannel file also for g2 extended to include commas and colons, remove duplicates)
-- m3 fix for gain caps to invert where needed when loading from trimbit file (fix for feature might have been added only in developer branch)
-- pat loop and wait address default
-- ctb and moench Fw fixed (to work with pattern commdand) )addreess length
-- setting rx_hostname (or udp_dstip with rx_hostname not none) will always set udp_dstmac. solves problem of chaing udp_dstip and udp_dstmac stays the same
-- jungfrau reset core and usleep removed (fix for 6.1.1 is now fixed in firmware)
-- m3 clock update, m3 clk 4 and 5 cannot be set
-- g2 change clkdivs 2 3 4 to defaults for burst and cw mode.
-- ctb and moench: allowing 1g non blocking acquire to send data
-- m3 and g2 rr
-- m3 and g2 temp
-- gain plot zooming fixed (disabled, acc. to main plot)
-- ctb, moench, jungfrau (pll reset at start fixed, before no defines)
-- pybind built into package, no need to update submodule when previous release had different pybind version
-- adcvpp moved from dac.. and api added (ctb, moench)
-- qt4->qt5
- - in built qt5 6.1.5 because rhel7 is not upto date with qt5, removed findqwt.cmake
- - made a fix in qwt lib (qwt_plot_layout.h) to work with 5.15 and lower versions
- - qt5 forms fixed, qt4 many hard coding forms switched to forms including qtabwidget, scrolls etc, fonts moved to forms
- - docking option enabled by default, removed option to disable docking feature from "Mode"
- - added qVersionResolve utility functions to handle compatibility before and after qt5.12
- - qtplots (ian's code) takes in gain mode enable to set some settings within the class, with proper gain plot ticks
- - ensure gain plots have no zooming of z axis in 2d and y axis in 1d
-- fixed some error messages in server side that were empty for fail in funcs (mostly minor as if this error, major issues)
-- eiger (removed feb reset in stop acquisition as it caused processing bit to randomly not go high (leads to infinite loop waiting for it to go high). This is anyway done at prepare acquisition and set trimbits.
- - left AND right registers monitored for processing bit done
- - febProcessinginprogress returns STATUS_IDLE and not IDLE
- - In feb stop acquisition, if processing bit is running forever, checks for 1 s, then if acq done bit is high, returns ok, else throws
- - feb stop acquisition returns 1 if success and fucntion in list calling it compares properly instead of STATUS_IDLE (no effect, but incorrect logic)
- - chipsignals to trimquad should only monitor right fpga (not both as it will throw)
- - fixed error messages of readregister inconsistent values
- - setmodule and read frame was returning fail without setting error messages (leading to broken tcp connection due to no error message) )
-- gui nios temperature added
-- detector header change (bunchid, reserved, debug, roundRnumber) ->detSpec1 - 4
- -ctb and moench (allowing all clkdivs (totaldiv was a float instead of int))
- - txndelay_ ->txdelay_ (also for python), txdelay = delay for all with step
- - hardwareversion
-- jungfrau connected moduleid to detid_jungfrau.txt on board
+1 New, Changed or Resolved Features
+=====================================
-2. Resolved Issues
-==================
- - Reading back sub-microsecond exposure times from the Python API.
+- moench being made compatible with jungfrau 2.0 boards (jungfrau structure, away from ctb)
+- eiger febl and febr in versions, ensure its the same as beb fw version
+- eiger hardware version fx30 and fx70 (versions command)
+- fixed rx_arping error
+- fix hdf5 compilation (detspec fields)
-3. Firmware Requirements
-========================
-
- Eiger
- =====
- Compatible version : 08.10.2021 (v29)
+
+
+2 On-board Detector Server Compatibility
+==========================================
+
+
+ Eiger 7.0.0
+ Jungfrau 7.0.0
+ Mythen3 7.0.0
+ Gotthard2 7.0.0
+ Gotthard 7.0.0
+ Moench 7.0.0
+ Ctb 7.0.0
- Jungfrau
- ========
- Compatible version : 31.08.2021 (v1.2, PCB v1.0)
- : 08.10.2021 (v2.2, PCB v2.0)
- Gotthard
- ========
- Compatible version : 08.02.2018 (50um and 25um Master)
- : 09.02.2018 (25 um Slave)
+ On-board Detector Server Upgrade
+ --------------------------------
- Mythen3
- =======
- Compatible version : 10.09.2021 (v1.1)
-
- Gotthard2
- =========
- Compatible version : 27.05.2021 (v0.1)
-
- Moench
- ======
- Compatible version : 05.10.2020 (v1.0)
-
- Ctb
- ===
- Compatible version : 05.10.2020 (v1.0)
-
- Detector Upgrade
- ================
- The following can be upgraded remotely:
- Eiger via bit files
- Jungfrau via command <.pof>
- Mythen3 via command <.rbf>
- Gotthard2 via command <.rbf>
- Moench via command <.pof>
- Ctb via command <.pof>
-
- The following cannot be upgraded remotely:
- Gotthard
+ From v6.1.0 (without tftp):
+ Using command 'updatedetectorserver'
+ From 5.0.0 (with tftp):
+ Using command 'copydetectorserver'
Instructions available at
- https://slsdetectorgroup.github.io/devdoc/firmware.html
- and
https://slsdetectorgroup.github.io/devdoc/serverupgrade.html
-4. Kernel Requirements
+
+3 Firmware Requirements
+========================
+
+
+ Eiger 20.02.2023 (v31)
+
+ Jungfrau 04.11.2022 (v1.4, HW v1.0)
+ 03.11.2022 (v2.4, HW v2.0)
+
+ Mythen3 24.01.2023 (v1.4)
+
+ Gotthard2 23.11.2022 (v0.3)
+
+ Gotthard 08.02.2018 (50um and 25um Master)
+ 09.02.2018 (25 um Slave)
+
+ Moench 05.12.2022 (v0.3)
+
+ Ctb 05.12.2022 (v1.1)
+
+
+ Detector Upgrade
+ ----------------
+
+ The following can be upgraded remotely:
+
+ Eiger via bit files
+ Jungfrau via command <.pof>
+ Mythen3 via command <.rbf>
+ Gotthard2 via command <.rbf>
+ Moench via command <.pof>
+ Ctb via command <.pof>
+
+ Gotthard cannot be upgraded remotely
+
+ Except Eiger,
+ upgrade
+ Using command 'programfpga' or
+
+ udpate both server and firmware simultaneously
+ Using command 'update'
+
+
+ Instructions available at
+ https://slsdetectorgroup.github.io/devdoc/firmware.html
+
+
+
+
+4 Kernel Requirements
======================
Blackfin
- ========
+ --------
Latest version: Fri Oct 29 00:00:00 2021
Older ones will work, but might have issues with programming firmware via
the package.
Nios
- ====
+ -----
Compatible version: Mon May 10 18:00:21 CEST 2021
Kernel Upgrade
- ==============
+ ---------------
Eiger via bit files
Others via command
@@ -216,7 +139,8 @@ This document describes the differences between v7.0.0 and v6.x.x
-5. Download, Documentation & Support
+
+5 Download, Documentation & Support
====================================
Download
@@ -229,7 +153,10 @@ This document describes the differences between v7.0.0 and v6.x.x
-------------
Installation:
- https://slsdetectorgroup.github.io/devdoc/installation.html#
+ https://slsdetectorgroup.github.io/devdoc/installation.html
+
+ Quick Start Guide:
+ https://slsdetectorgroup.github.io/devdoc/quick_start_guide.html
Firmware Upgrade:
https://slsdetectorgroup.github.io/devdoc/firmware.html
@@ -249,9 +176,6 @@ This document describes the differences between v7.0.0 and v6.x.x
Command Line Documentation:
https://slsdetectorgroup.github.io/devdoc/commandline.html
- Quick Start Guide:
- https://slsdetectorgroup.github.io/devdoc/quick_start_guide.html
-
C++ API Documentation:
https://slsdetectorgroup.github.io/devdoc/detector.html
@@ -268,8 +192,16 @@ This document describes the differences between v7.0.0 and v6.x.x
https://slsdetectorgroup.github.io/devdoc/receivers.html
https://slsdetectorgroup.github.io/devdoc/slsreceiver.html
+ Detector UDP Header:
+ https://slsdetectorgroup.github.io/devdoc/udpheader.html
+ https://slsdetectorgroup.github.io/devdoc/udpdetspec.html
+
+ slsReceiver Zmq Format:
+ https://slsdetectorgroup.github.io/devdoc/slsreceiver.html#zmq-json-header-format
+
TroubleShooting:
https://slsdetectorgroup.github.io/devdoc/troubleshooting.html
+ https://slsdetectorgroup.github.io/devdoc/troubleshooting.html#receiver-pc-tuning-options
Further Documentation:
https://www.psi.ch/en/detectors/documentation
@@ -283,4 +215,3 @@ This document describes the differences between v7.0.0 and v6.x.x
dhanya.thattil@psi.ch
erik.frojdh@psi.ch
-
diff --git a/cmk.sh b/cmk.sh
index 8df13ac68..9ed267843 100755
--- a/cmk.sh
+++ b/cmk.sh
@@ -33,7 +33,7 @@ Usage: $0 [-b] [-c] [-d ] [e] [g] [-h] [i] [-j ` if you run into issues while programming firmware.
-Always ensure that the client and server software are of the same release.
+
Program from console
.. code-block:: bash
- # copies server from tftp folder of pc, links new server to jungfrauDetectorServer,
+ # These instructions are for upgrades from v5.0.0. For earlier versions, please contact us.
+
+ # Always ensure that the client and server software are of the same release.
+
+ # copies server, links new server to jungfrauDetectorServer,
# removes old server from respawn, sets up new lnked server to respawn
- # programs fpga,
- # reboots
+ # programs fpga, reboots
+
+ # v5.0.0 - 6.0.0 (copies server from tftp folder of the pc)
sls_detector_put update jungfrauDetectorServervxxx pcxxx xx.pof
+ # v6.1.1 - present (copies server from the full path provided)
+ sls_detector_put update jungfrauDetectorServervxxx xx.pof
+
# Or only program firmware
sls_detector_put programfpga xxx.pof
@@ -155,10 +170,6 @@ Upgrade
Mythen III
-----------
-.. note ::
-
- As it is still in development, the rbf files must be picked up from us.
-
Download
^^^^^^^^^^^^^
@@ -170,16 +181,21 @@ Download
Upgrade
^^^^^^^^
-Always ensure that the client and server software are of the same release.
-
Program from console
.. code-block:: bash
- # copies server from tftp folder of pc, links new server to mythen3DetectorServer,
- # programs fpga,
- # reboots
+ # Always ensure that the client and server software are of the same release.
+
+ # copies server, links new server to mythen3DetectorServer,
+ # 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)
sls_detector_put update mythen3DetectorServervxxx pcxxx xxx.rbf
+ # v6.1.1 - present (copies server from the full path provided)
+ sls_detector_put update mythen3DetectorServervxxx xxx.rbf
+
# Or only program firmware
sls_detector_put programfpga xxx.rbf
@@ -199,16 +215,21 @@ Download
Upgrade
^^^^^^^^
-Always ensure that the client and server software are of the same release.
-
Program from console
.. code-block:: bash
- # copies server from tftp folder of pc, links new server to gotthard2DetectorServer,
- # programs fpga,
- # reboots
+ # Always ensure that the client and server software are of the same release.
+
+ # copies server, links new server to gotthard2DetectorServer,
+ # 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)
sls_detector_put update gotthard2DetectorServervxxx pcxxx xxx.rbf
+ # v6.1.1 - present (copies server from the full path provided)
+ sls_detector_put update gotthard2DetectorServervxxx xxx.rbf
+
# Or only program firmware
sls_detector_put programfpga xxx.rbf
@@ -230,19 +251,36 @@ Download
Upgrade
^^^^^^^^
+.. warning ::
+
+ In case you have had issues in the past with programming via software:
+
+ * 6.1.2 server has a fix for seamless fpga programming
+
+ * We recommend first updating the on-board detector server to 6.1.2 (with client 6.1.x) using command 'updatedetectorserver' or 'copydetectorserver'.
+
+ * Then use command 'programfpga' to only update firmware or use command 'update' to update firmware and server to the latest release.
+
+
+
Check :ref:`firmware troubleshooting ` if you run into issues while programming firmware.
-Always ensure that the client and server software are of the same release.
Program from console
.. code-block:: bash
- # copies server from tftp folder of pc, links new server to moenchDetectorServer,
+ # Always ensure that the client and server software are of the same release.
+
+ # copies server, links new server to moenchDetectorServer,
# removes old server from respawn, sets up new lnked server to respawn
- # programs fpga,
- # reboots
+ # programs fpga, reboots
+
+ # v5.0.0 - 6.0.0 (copies server from tftp folder of the pc)
sls_detector_put update moenchDetectorServervxxx pcxxx xx.pof
+ # v6.1.1 - present (copies server from the full path provided)
+ sls_detector_put update moenchDetectorServervxxx xx.pof
+
# Or only program firmware
sls_detector_put programfpga xxx.pof
@@ -262,17 +300,22 @@ Upgrade
Check :ref:`firmware troubleshooting ` if you run into issues while programming firmware.
-Always ensure that the client and server software are of the same release.
Program from console
.. code-block:: bash
- # copies server from tftp folder of pc, links new server to ctbDetectorServer,
+ # Always ensure that the client and server software are of the same release.
+
+ # copies server, links new server to ctbDetectorServer,
# removes old server from respawn, sets up new lnked server to respawn
- # programs fpga,
- # reboots
+ # programs fpga, reboots
+
+ # v5.0.0 - 6.0.0 (copies server from tftp folder of the pc)
sls_detector_put update ctbDetectorServervxxx pcxxx xx.pof
+ # v6.1.1 - present (copies server from the full path provided)
+ sls_detector_put update ctbDetectorServervxxx xx.pof
+
# Or only program firmware
sls_detector_put programfpga xxx.pof
diff --git a/docs/src/installation.rst b/docs/src/installation.rst
index 3d3e521f7..1a2003192 100644
--- a/docs/src/installation.rst
+++ b/docs/src/installation.rst
@@ -1,14 +1,3 @@
-
-
-
-.. note ::
-
- The default branch of our git repository is developer. It contains the
- latest development version. It is expected to compile and work but
- features might be added or tweaked. In some cases the API might also change
- without being communicated. If absolute stability of the API is needed please
- use one of the release versions.
-
.. warning ::
Before building from source make sure that you have the
@@ -55,7 +44,13 @@ We have three different packages available:
.. code-block:: bash
#List available versions
+ # lib and binaries
+ conda search slsdetlib
+ # python
conda search slsdet
+ # gui
+ conda search slsdetgui
+
@@ -71,12 +66,12 @@ Build from source
git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git --branch 6.1.1
-| **Pybind**
+| **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.
+| pybind11 is a submodule. Must be cloned using "recursive" and updated when switching between versions using the following commands.
.. code-block:: bash
@@ -133,14 +128,14 @@ Example cmake options Comment
=============================== ===========================================
-DSLS_USE_PYTHON=ON Python
-DPython_FIND_VIRTUALENV=ONLY Python from only the conda environment
--DZeroMQ_HINT=/usr/lib64 System zmq instead of conda
+-DZeroMQ_HINT=/usr/lib64 Use system zmq instead
-DSLS_USE_GUI=ON GUI
=============================== ===========================================
-Build using in-build cmk.sh script
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Build using in-built cmk.sh script
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
@@ -155,7 +150,7 @@ Build using in-build cmk.sh script
-c: Clean
-d: HDF5 Custom Directory
-e: Debug mode
- -g: Build/Rebuilds only gui
+ -g: Build/Rebuilds gui
-h: Builds/Rebuilds Cmake files with HDF5 package
-i: Builds tests
-j: Number of threads to compile through
@@ -172,17 +167,18 @@ Build using in-build cmk.sh script
-z: Moench zmq processor
- # get all options
+ # display all options
./cmk.sh -?
- # new build and compile in parallel:
- ./cmk.sh -bj5
+ # new build and compile in parallel (recommended basic option):
+ ./cmk.sh -cbj5
# new build, python and compile in parallel:
- ./cmk.sh -bpj5
+ ./cmk.sh -cbpj5
+
+ #To use the system zmq (/usr/lib64) instead
+ ./cmk.sh -cbj5 -q /usr/lib64
- #To use the system zmq (/usr/lib64) instead of conda
- ./cmk.sh -bj5 -q /usr/lib64
Build on old distributions
@@ -204,8 +200,57 @@ using this compiler
make -j12
+
+Build slsDetectorGui (Qt5)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+1. Using pre-built binary on conda
+ .. code-block:: bash
+
+ conda create -n myenv slsdetgui=7.0.0
+ conda activate myenv
+
+
+2. Using system installation on RHEL7
+ .. code-block:: bash
+
+ yum install qt5-qtbase-devel.x86_64
+ yum install qt5-qtsvg-devel.x86_64
+
+
+3. Using conda
+ .. code-block:: bash
+
+ #Add channels for dependencies and our library
+ conda config --add channels conda-forge
+ conda config --add channels slsdetectorgroup
+ conda config --set channel_priority strict
+
+ # create environment to compile
+ # on rhel7
+ conda create -n slsgui zeromq gxx_linux-64 gxx_linux-64 mesa-libgl-devel-cos6-x86_64 qt
+ # on fedora or newer systems
+ conda create -n slsgui zeromq qt
+
+ # when using conda compilers, would also need libgl, but no need for it on fedora unless maybe using it with ROOT
+
+ # activate environment
+ conda activate slsgui
+
+ # compile with cmake outside slsDetecorPackage folder
+ mkdir build && cd build
+ cmake ../slsDetectorPackage -DSLS_USE_GUI=ON
+ make -j12
+
+ # or compile with cmk.sh
+ cd slsDetectorPackage
+ ./cmk.sh -cbgj9
+
+
+
+
Build this documentation
--------------------------------
+^^^^^^^^^^^^^^^^^^^^^^^^
The documentation for the slsDetectorPackage is build using a combination
of Doxygen, Sphinx and Breathe. The easiest way to install the dependencies
@@ -213,11 +258,15 @@ is to use conda
.. code-block:: bash
- conda create -n myenv python sphinx sphinx_rtd_theme
+ conda create -n myenv python sphinx_rtd_theme breathe
-Then enable the option SLS_BUILD_DOCS to create the targets
.. code-block:: bash
+ # using cmake or ccmake to enable DSLS_BUILD_DOCS
+ # outside slsDetecorPackage folder
+ mkdir build && cd build
+ cmake ../slsDetectorPackage -DSLS_BUILD_DOCS=ON
+
make docs # generate API docs and build Sphinx RST
make rst # rst only, saves time in case the API did not change
diff --git a/docs/src/pyexamples.rst b/docs/src/pyexamples.rst
index f432541da..9521b32c0 100755
--- a/docs/src/pyexamples.rst
+++ b/docs/src/pyexamples.rst
@@ -10,27 +10,46 @@ open an issue in our our `github repo
Setting exposure time
------------------------------------
-Setting and reading back exposure time can be done either using a Python datetime.timedelta
-or by setting the time in seconds.
+Setting and reading back exposure time can be done either using a Python
+datetime.timedelta, DurationWrapper or by setting the time in seconds.
::
# Set exposure time to 1.2 seconds
>>> d.exptime = 1.2
+ >>> d.exptime = 5e-07
- # Setting exposure time using timedelta
+ # Setting exposure time using timedelta (upto microseconds precision)
import datetime as dt
>>> d.exptime = dt.timedelta(seconds = 1.2)
+ >>> d.exptime = dt.timedelta(seconds = 1, microseconds = 3)
# With timedelta any arbitrary combination of units can be used
>>> t = dt.timedelta(microseconds = 100, seconds = 5.3, minutes = .3)
+ # using DurationWrapper to set in seconds
+ >>> from slsdet import DurationWrapper
+ >>> d.exptime = DurationWrapper(1.2)
+
+ # using DurationWrapper to set in ns
+ >>> t = DurationWrapper()
+ >>> t.set_count(500)
+ >>> d.exptime = t
+
# To set exposure time for individual detector one have to resort
# to the C++ style API.
# Sets exposure time to 1.2 seconds for module 0, 6 and 12
>>> d.setExptime(1.2, [0, 6, 12])
>>> d.setExptime(dt.timedelta(seconds = 1.2), [0, 6, 12])
+ # to get in seconds
+ >>> d.period
+ 181.23
+
+ # to get in DurationWrapper
+ >>> d.getExptime()
+ [sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)]
+
------------------------------------
@@ -220,8 +239,7 @@ Setting and getting times
# This sets the exposure time for all modules
d.exptime = 0.5
- # exptime also accepts a python datetime.timedelta
- # which can be used to set the time in almost any unit
+ # exptime also accepts a python datetime.timedelta (upto microseconds resolution)
t = dt.timedelta(milliseconds = 2.3)
d.exptime = t
@@ -229,16 +247,25 @@ Setting and getting times
t = dt.timedelta(minutes = 3, seconds = 1.23)
d.exptime = t
+ # using DurationWrapper to set in seconds
+ >>> from slsdet import DurationWrapper
+ >>> d.exptime = DurationWrapper(1.2)
+
+ # using DurationWrapper to set in ns
+ >>> t = DurationWrapper()
+ >>> t.set_count(500)
+ >>> d.exptime = t
+
# exptime however always returns the time in seconds
>>> d.exptime
181.23
# To get back the exposure time for each module
# it's possible to use getExptime, this also returns
- # the values as datetime.timedelta
+ # the values as DurationWrapper
>>> d.getExptime()
- [datetime.timedelta(seconds=181, microseconds=230000), datetime.timedelta(seconds=181, microseconds=230000)]
+ [sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)]
# In case the values are the same it's possible to use the
# element_if_equal function to reduce the values to a single
@@ -246,7 +273,8 @@ Setting and getting times
>>> t = d.getExptime()
>>> element_if_equal(t)
- datetime.timedelta(seconds=1)
+ sls::DurationWrapper(total_seconds: 1.2 count: 1200000000)
+
--------------
Reading dacs
diff --git a/docs/src/pygettingstarted.rst b/docs/src/pygettingstarted.rst
index 20ae20276..5caf8723e 100644
--- a/docs/src/pygettingstarted.rst
+++ b/docs/src/pygettingstarted.rst
@@ -6,7 +6,7 @@ Getting Started
Which Python?
--------------------
-We require at lest Python 3.6 and strongly recommended that you don't use the system
+We require at least Python 3.6 and strongly recommended that you don't use the system
Python installation. The examples in this documentation uses `conda
`_ since it provides good support
also for non Python packages but there are also other alternatives like, pyenv.
@@ -14,29 +14,35 @@ also for non Python packages but there are also other alternatives like, pyenv.
Using something like conda also allows you to quickly switch beteen different Python
environments.
+---------------------
+Building from Source
+---------------------
+
+If you are not installing slsdet binaries from conda, but instead building from
+source, please refer to :ref:`the installation section` for details.
+
+Don't forget to compile with the option SLS_USE_PYTHON=ON to enable the Python
+bindings or if you use the cmk.sh script -p.
+
.. note ::
- Ensure that the python lib compiled is for the expected python version.
+ Ensure that the sls det python lib compiled is for the expected python version.
For example, build/bin/_slsdet.cpython-39-x86_64-linux-gnu.so for Python v3.9.x
+
---------------------
PYTHONPATH
---------------------
-If you install slsdet using conda everything is set up and you can
+If you install slsdet binaries using conda everything is set up and you can
directly start using the Python bindings. However, if you build
-from source you need to tell Python where to find slsdet. This
-is be done by adding your build/bin directory to PYTHONPATH.
+from source you need to tell Python where to find slsdet to use it. This
+can be done by adding your build/bin directory to PYTHONPATH.
.. code-block:: bash
export PYTHONPATH = /path/to/your/build/bin:$PYTHONPATH
-.. note ::
-
- Don't forget to compile with the option SLS_USE_PYTHON=ON to enable
- the Python bindings or if you use the cmk.sh script -p.
-
--------------------------------------
Which detector class should I use?
--------------------------------------
@@ -147,9 +153,11 @@ their name.
::
>>> [item for item in dir(d) if 'time' in item]
- ['exptime', 'getExptime', 'getExptimeForAllGates', 'getExptimeLeft',
- 'getSubExptime', 'patwaittime0', 'patwaittime1', 'patwaittime2',
- 'setExptime', 'setSubExptime', 'subdeadtime', 'subexptime']
+ ['compdisabletime', 'exptime', 'exptimel', 'frametime', 'getExptime',
+ 'getExptimeForAllGates', 'getExptimeLeft', 'getSubExptime', 'patwaittime',
+ 'patwaittime0', 'patwaittime1', 'patwaittime2', 'runtime', 'setExptime',
+ 'setSubExptime', 'subdeadtime', 'subexptime']
+
The above method works on any Python object but for convenience we also
included two functions to find names. View prints the names one per line
@@ -161,6 +169,7 @@ while find returns a list of names.
>>> view('exptime')
exptime
+ exptimel
getExptime
getExptimeForAllGates
getExptimeLeft
@@ -169,6 +178,7 @@ while find returns a list of names.
setSubExptime
subexptime
+
>>> find('exptime')
['exptime', 'getExptime', 'getExptimeForAllGates', 'getExptimeLeft',
'getSubExptime', 'setExptime', 'setSubExptime', 'subexptime']
@@ -186,19 +196,39 @@ To access the documentation of a function directly from the Python prompt use he
Help on property:
Period between frames, accepts either a value in seconds or datetime.timedelta
-
+
Note
-----
- :getter: always returns in seconds. To get in datetime.delta, use getPeriod
-
- Examples
+ :getter: always returns in seconds. To get in DurationWrapper, use getPeriod
+
+ Example
-----------
+ >>> # setting directly in seconds
>>> d.period = 1.05
- >>> d.period = datetime.timedelta(minutes = 3, seconds = 1.23)
+ >>>
+ >>> # setting directly in seconds
+ >>> d.period = 5e-07
+ >>>
+ >>> # using timedelta (up to microseconds precision)
+ >>> from datatime import timedelta
+ >>> d.period = timedelta(seconds = 1, microseconds = 3)
+ >>>
+ >>> # using DurationWrapper to set in seconds
+ >>> from slsdet import DurationWrapper
+ >>> d.period = DurationWrapper(1.2)
+ >>>
+ >>> # using DurationWrapper to set in ns
+ >>> t = DurationWrapper()
+ >>> t.set_count(500)
+ >>> d.period = t
+ >>>
+ >>> # to get in seconds
>>> d.period
181.23
- >>> d.getPeriod()
- [datetime.timedelta(seconds=181, microseconds=230000)]
+ >>>
+ >>> d.getExptime()
+ [sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)]
+
----------------------
@@ -218,11 +248,12 @@ The enums can be found in slsdet.enums
import slsdet
>>> [e for e in dir(slsdet.enums) if not e.startswith('_')]
- ['burstMode', 'clockIndex', 'dacIndex',
- 'detectorSettings', 'detectorType', 'dimension', 'externalSignalFlag',
- 'fileFormat', 'frameDiscardPolicy',
- 'readoutMode', 'runStatus', 'speedLevel', 'timingMode',
- 'timingSourceType']
+ ['M3_GainCaps', 'burstMode', 'clockIndex', 'cls', 'dacIndex', 'detectorSettings',
+ 'detectorType', 'dimension', 'externalSignalFlag', 'fileFormat',
+ 'frameDiscardPolicy', 'gainMode', 'name', 'polarity', 'portPosition',
+ 'readoutMode', 'runStatus', 'speedLevel', 'streamingInterface', 'timingMode',
+ 'timingSourceType', 'vetoAlgorithm']
+
# Even though importing using * is not recommended one could
# get all the enums like this:
diff --git a/docs/src/quick_start_guide.rst b/docs/src/quick_start_guide.rst
index 1e17ebfc4..428d77989 100644
--- a/docs/src/quick_start_guide.rst
+++ b/docs/src/quick_start_guide.rst
@@ -66,11 +66,15 @@ For a Single Module
# sets destination udp ports (not needed, default is 50001)
udp_dstport 50012
+ # 1g data out
# source udp ips must be same subnet at destintaion udp ips
- udp_srcip 192.168.1.112
-
+ # udp_srcip 192.168.1.112
# destination udp ip picked up from rx_hostname (if auto)
- udp_dstip auto
+ # udp_dstip auto
+
+ # 10g data out
+ udp_srcip 10.30.20.200
+ udp_dstip 10.30.20.6
# set file path
fpath /tmp
diff --git a/docs/src/servers.rst b/docs/src/servers.rst
index bcf94c156..4a0faebb9 100644
--- a/docs/src/servers.rst
+++ b/docs/src/servers.rst
@@ -23,15 +23,19 @@ Arguments
.. code-block:: bash
Possible arguments are:
- -v, --version : Software version
- -p, --port : TCP communication port with client.
- -g, --nomodule : [Mythen3][Gotthard2] Generic or No Module mode.
- Skips detector type checks.
- -f, --phaseshift : [Gotthard] only. Sets phase shift.
- -d, --devel : Developer mode. Skips firmware checks.
- -u, --update : Update mode. Skips firmware checks and initial detector setup.
- -s, --stopserver : Stop server. Do not use as it is created by control server
-
+ -v, --version : Software version
+ -p, --port : TCP communication port with client.
+ -g, --nomodule : [Mythen3][Gotthard2]
+ Generic or No Module mode. Skips detector type checks.
+ -f, --phaseshift : [Gotthard] only. Sets phase shift.
+ -d, --devel : Developer mode. Skips firmware checks.
+ -u, --update : Update mode. Skips firmware checks and initial detector setup.
+ -i, --ignore-config : [Eiger][Jungfrau][Gotthard][Gotthard2][Moench]
+ Ignore config file.
+ -m, --master : [Eiger][Mythen3][Gotthard][Gotthard2]
+ Set Master to 0 or 1. Precedence over config file. Only for virtual servers except Eiger.
+ -t, --top : [Eiger] Set Top to 0 or 1. Precedence over config file.
+ -s, --stopserver : Stop server. Do not use as it is created by control server
.. _Automatic start servers:
@@ -88,6 +92,8 @@ One can start the on-board detector server automatically upon powering on the bo
.. code-block:: bash
sync
+
+ # physically reboot for Gotthard II or Mythen III
reboot
# verify
diff --git a/docs/src/slsreceiver.rst b/docs/src/slsreceiver.rst
index db2c77e06..6e794a30c 100644
--- a/docs/src/slsreceiver.rst
+++ b/docs/src/slsreceiver.rst
@@ -86,16 +86,199 @@ Client Commands
sls_detector_get -h rx_framescaught
+ZMQ: Json Header Format
+------------------------
+
+
+**Change in field names from slsDetectorPackage v6.x.x to v7.0.0**
+
+* detSpec1 <- bunchId
+* detSpec2 <- reserved
+* detSpec3 <- debug
+* detSpec4 <- roundRNumber
+
+
+**Format**
+
+ .. code-block:: bash
+
+ {
+ "jsonversion": unsigned int,
+ "bitmode": unsigned int,
+ "fileIndex": unsigned long int,
+ "detshape": [
+ unsigned int,
+ unsigned int
+ ],
+ "shape": [
+ unsigned int,
+ unsigned int
+ ],
+ "size": unsigned int,
+ "acqIndex": unsigned long int,
+ "frameIndex": unsigned long int,
+ "progress": double,
+ "fname": string,
+ "data": unsigned int,
+ "completeImage": unsigned int,
+
+ "frameNumber": unsigned long long int,
+ "expLength": unsigned int,
+ "packetNumber": unsigned int,
+ "detSpec1": unsigned long int,
+ "timestamp": unsigned long int,
+ "modId": unsigned int,
+ "row": unsigned int,
+ "column": unsigned int,
+ "detSpec2": unsigned int,
+ "detSpec3": unsigned int,
+ "detSpec4": unsigned int,
+ "detType": unsigned int,
+ "version": unsigned int,
+
+ "flipRows": unsigned int,
+ "quad": unsigned int,
+ "addJsonHeader": {
+ string : string
+ }
+ }
+
+ +--------------+----------------------------------------------+
+ | Field | Description |
+ +--------------+----------------------------------------------+
+ | jsonversion | Version of the json header. |
+ | | Value at 4 for v6.x.x and v7.x.x |
+ +--------------+----------------------------------------------+
+ | bitmode | Bits per pixel [4|8|16|32] |
+ +--------------+----------------------------------------------+
+ | fileIndex | Current file acquisition index |
+ +--------------+----------------------------------------------+
+ | detshape | Geometry of the entire detector |
+ +--------------+----------------------------------------------+
+ | shape | Geometry of the current port streamed out |
+ +--------------+----------------------------------------------+
+ | size | Size of image of current port in bytesout |
+ +--------------+----------------------------------------------+
+ | acqIndex | Frame number from the detector (redundant) |
+ +--------------+----------------------------------------------+
+ | frameIndex | Frame number of current acquisition |
+ | | (Starting at 0) |
+ +--------------+----------------------------------------------+
+ | progress | Progress of current acquisition in % |
+ +--------------+----------------------------------------------+
+ | fname | Current file name |
+ +--------------+----------------------------------------------+
+ | data | 1 if there is data following |
+ | | 0 if dummy header |
+ +--------------+----------------------------------------------+
+ | completeImage| 1 if no missing packets for this frame |
+ | | in this port, else 0 |
+ +--------------+----------------------------------------------+
+ | frameNumber | Frame number |
+ | | [From detector udp header] |
+ +--------------+----------------------------------------------+
+ | expLength | subframe number (32 bit eiger) |
+ | | or real time exposure time in 100ns (others) |
+ | | [From detector udp header] |
+ +--------------+----------------------------------------------+
+ | packetNumber | Number of packets caught for that frame |
+ +--------------+----------------------------------------------+
+ | detSpec1 | See :ref:`here` |
+ | | [From detector udp header] |
+ +--------------+----------------------------------------------+
+ | timestamp | Timestamp with 10 MHz clock |
+ | | [From detector udp header] |
+ +--------------+----------------------------------------------+
+ | modId | Module Id |
+ | | [From detector udp header] |
+ +--------------+----------------------------------------------+
+ | row | Row number in detector |
+ | | [From detector udp header] |
+ +--------------+----------------------------------------------+
+ | column | Column number in detector |
+ | | [From detector udp header] |
+ +--------------+----------------------------------------------+
+ | detSpec2 | See :ref:`here` |
+ | | [From detector udp header] |
+ +--------------+----------------------------------------------+
+ | detSpec3 | See :ref:`here` |
+ | | [From detector udp header] |
+ +--------------+----------------------------------------------+
+ | detSpec4 | See :ref:`here` |
+ | | [From detector udp header] |
+ +--------------+----------------------------------------------+
+ | detType | Detector type enum |
+ | detSpec3 | See :ref:`Detector enum` |
+ | | [From detector udp header] |
+ +--------------+----------------------------------------------+
+ | version | Detector header version. At 2 |
+ | | [From detector udp header] |
+ +--------------+----------------------------------------------+
+ | flipRows | 1 if rows should be flipped. |
+ | | Usually for Eiger bottom. |
+ +--------------+----------------------------------------------+
+ | quad | 1 if its an Eiger quad. |
+ +--------------+----------------------------------------------+
+ | addJsonHeader| Optional custom parameters that is required |
+ | | for processing code. |
+ +--------------+----------------------------------------------+
+
+
+SLS Receiver Header Format
+--------------------------
+
+It is 112 bytes and consists of:
+ * 48 bytes of the SLS Detector Header (described in :ref:`the current detector header `)
+ * 64 bytes of packet mask
+
+.. code-block:: cpp
+
+ typedef struct {
+ uint64_t frameNumber;
+ uint32_t expLength;
+ uint32_t packetNumber;
+ uint64_t detSpec1;
+ uint64_t timestamp;
+ uint16_t modId;
+ uint16_t row;
+ uint16_t column;
+ uint16_t detSpec2;
+ uint32_t detSpec3;
+ uint16_t detSpec4;
+ uint8_t detType;
+ uint8_t version;
+ } sls_detector_header;
+
+ struct sls_receiver_header {
+ sls_detector_header detHeader; /**< is the detector header */
+ sls_bitset packetsMask; /**< is the packets caught bit mask */
+ };
+
+
+.. note ::
+
+ | The packetNumber in the SLS Receiver Header will be modified to number of packets caught by receiver for that frame. For eg. Jungfrau will have 128 packets per frame. If it is less, then this is a partial frame due to missing packets.
+
+ | Furthermore, the bit mask will specify which packets have been received.
+
+
+
+
File format
--------------
-* The file name format is [fpath]/[fname]_dx_fy_[findex].raw, where x is module index and y is file index. **fname** is file name prefix and by default "run". **fpath** is '/' by default.
+Master file is in json format.
-* Each acquisition will have an increasing acquisition index or findex (if file write enabled). This can be retrieved by using **findex** command.
+The file name format is [fpath]/[fname]_dx_fy_[findex].raw, where x is module index and y is file index. **fname** is file name prefix and by default "run". **fpath** is '/' by default.
-* Each acquisition can have multiple files (the file index number **y**), with **rx_framesperfile** being the maximum number of frames per file. The default varies for each detector type.
-* Some file name examples:
+Each acquisition will have an increasing acquisition index or findex (if file write enabled). This can be retrieved by using **findex** command.
+
+
+Each acquisition can have multiple files (the file index number **y**), with **rx_framesperfile** being the maximum number of frames per file. The default varies for each detector type.
+
+
+Some file name examples:
.. code-block:: bash
@@ -108,17 +291,19 @@ File format
# second acquisition, first file
path-to-file/run_d0_f0_1.raw
-* Each acquisition will create a master file that can be enabled/disabled using **fmaster**. This should have parameters relevant to the acquisition.
-* SLS Receiver Header consist of SLS Detector Header + 64 bytes of bitmask, altogether 112 bytes. The packetNumber in the sls detector header part, will be updated to number of packets caught by receiver for that frame. Furthermore, the bit mask will specify which packets have been received.
+Each acquisition will create a master file that can be enabled/disabled using **fmaster**. This should have parameters relevant to the acquisition.
+
**Binary file format**
-* This is the default file format.
+This is the default file format.
-* Each data file will consist of frames, each consisting of slsReceiver Header followed by data for 1 frame.
-* Master file is of ASCII format and will also include the format of the slsReceiver Header.
+Each data file will consist of frames, each consisting of slsReceiver Header followed by data for 1 frame.
+
+
+Master file is of ASCII format and will also include the format of the slsReceiver Header.
**HDF5 file formats**
diff --git a/docs/src/troubleshooting.rst b/docs/src/troubleshooting.rst
index 8abd4665a..164886f67 100644
--- a/docs/src/troubleshooting.rst
+++ b/docs/src/troubleshooting.rst
@@ -8,21 +8,24 @@ open an issue at our `github repo issues
Common
------
-Missing Packets
-^^^^^^^^^^^^^^^
-Possible causes could be the following:
-#. Receiver PC is not tuned for socket buffer size and input packet queue.
- * Refer to :ref:`Increase rmem_default, rmem_max and max_backlog`
+1. Total Failure of Packet Delivery
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#. Wiring
- * Faulty wiring or connecting cable to incorrect interface.
+#. Data cable plugged into the wrong interface on board (Jungfrau)
+ * Please ensure that the data cable is plugged into the rightmost interface (default for single interface). The inner one is disabled for PCB v1.0 and must be selected via command for PCB v2.0.
#. Link up and speed
- * Check to see if there is a blue LED on board to signal that the link is up. Check ethtool and find if Link Deteced:Yes and Speed is acceptable (>10k).
+ * Check ethtool and find if Link Deteced:Yes and Speed is acceptable (>10k).
+ * Check to see if the 10G link is up (blue or red LED on board, close to SFP+). If not:
+
+ * Check transeiver and fibers are compatible (all MMF 850nm or all SMF 1030nm)
+ * Check fiber
+ * Check fiber polarity (if short range, unplug the link anywhere, and look at the light/dark pattern: dark has to mate with light)
#. Detector is not acquiring (Not Eiger)
* Take an acquisition with many images and using the following steps instead of acquire:
+
.. code-block:: bash
sls_detector_put status start
@@ -30,37 +33,63 @@ Possible causes could be the following:
# which means the detector is acquiring.
sls_detector_get framesl
- .. note ::
-
- If you are using multiple modules, the previous command can return -1 because each module will return different values. Then, check for a single module instead: sls_detector_get 0:framesl
+ # If you are using multiple modules, the previous command can return -1 because each module will return different values. Then, check for a single module instead: sls_detector_get 0:framesl
-#. Data cable plugged into the wrong interface on board (Jungfrau)
- * Please ensure that the data cable is plugged into the rightmost interface. The middle one is disabled for PCB v1.0 and must be selected via command for PCB v2.0.
-#. Detector is not sending data
- * Check the board to see if the green LED is blinking next to the data cable, which means that the detector is sending data.
+#. Detector is not sending data (Except Eiger)
+ * Check the board to see if the green LED close to SFP is blinking (detector is sending data). If not, detector is not operated properly (period too short/long, no trigger in trigger mode) or misconfigured and needs reboot.
-#. Firewall or security feature
- * A firewall or some security feature could be blocking the reception of data.
-
-#. Ethernet interface not configured properly
- * Ensure that the interfaces used are configured properly with the right mask and ip. Eg. use ifconfig and route commands to verify.
+#. Power supply
+ * Check if power supply has enough current.
+ * For Jungfrau, refer to :ref:`Jungfrau Power Supply Troubleshooting`.
#. Ethernet interface not configured for Jumbo frames (10Gb)
- * Ensure that the interfaces used in receiver pc have MTU 9000 (jumbo frames) enabled.
+ * Ensure that the interfaces (on NIC and the switch) used in receiver pc have MTU 9000 (jumbo frames) enabled.
-#. Detector IP (Not Eiger)
- * Ensure it is valid and does not end if 0 or 255. Also ensure that the detector ip is in the same subnet as rx_udpip and the masking in the interface configuration ensures this rule.
-#. Tcpdump or wireshark
+#. Check if 'rx_frames' counter in 'ifconfig' do not increment for interface.
+ * If no, check switch configuration if present. Port counters of switch can also help to identify problem.
+ * If yes, but receiver software does not see it:
+
+ * Check no firewall (eg. firewalld) is present or add rules
+ * Check that selinux is disabled ( or add rules)
+
+#. Source UDP IP in config file (Not Eiger)
+ * Ensure it is valid and does not end if 0 or 255. Also ensure that the source ip 'udp_srcip' is in the same subnet as destination ip 'udp_dstip' and the masking in the interface configuration ensures this rule.
+ * Eg. If interface IP is 102.10.10.110 and mask is 255.255.255.0, udp_srcip has to be 102.10.10.xxx (same subnet)
+ * Use ifconfig and route commands to verify etheret interface configuration
+
+
+#. Netstat and netcat
+ * Try with netstat to see if its really listening to the right interface. Or netcat to see if you get packets.
+
+#. Wireshark or Tcpdump
* Use one of these to confirm that you receive packets (with the right filtering ie. source and destination ports, ip).
-#. Check SFP modules
- * Check if the SFP modules on both sides of the fiber are of same type.
+
+
+2. Partial or Random Packet Loss (Performance)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. note ::
+
+ The following suggestions are for convenience. Please do not follow blindly, research each parameter and adapt it to your system.
+
+#. Receiver PC is not tuned for socket buffer size and input packet queue or other parameters.
+ * Refer to :ref:`Receiver PC Tuning`
+
+#. Wiring
+ * Faulty wiring or connecting cable to incorrect interface.
+
#. Pinging the subnet (receiving only a few number of packets each time)
* If a switch is used between a receiver pc and detector instead of plugging the cables directly, one might have to ping any ip in the subnet of the Ethernet interface constantly so that it does not forget the ip during operation.
* Eg. if rx_udpip is 10.2.3.100, then ping constantly 10.2.3.xxx, where xxx is any ip other than 100.
+ * Using slsReceiver, you can use a command that does this for you:
+ .. code-block:: bash
+
+ # arping the interface in a separate thread every minute
+ sls_detector_put rx_arping 1
@@ -68,6 +97,12 @@ Possible causes could be the following:
Receiver PC Tuning Options
^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. note ::
+
+ | xth1 is example interface name in the following examples.
+ | These settings are lost at pc reboot.
+
#. Increase maximum receive socket buffer size and socket input packet queue.
* Temporarily (until shut down)
.. code-block:: bash
@@ -111,6 +146,7 @@ Receiver PC Tuning Options
# check how many GB memory you can allocate, to avoid swapping otherwise
+
#. Modify ethtool settings.
* rx ring parameters
.. code-block:: bash
@@ -127,6 +163,9 @@ Receiver PC Tuning Options
# check
ethtool -c xth1
+ # enable adaptive xoalescence parameters
+ ethtool -C xth1 adaptive-rx on
+
# set to max value in your pc settings
ethtool -C xth1 rx-usecs 100
@@ -138,13 +177,18 @@ Receiver PC Tuning Options
# set to max value in your pc settings
ethtool -A xth1 rx on
-
- .. note ::
+
+ * generic receiver offload (might not always work)
+ .. code-block:: bash
- | xth1 is example interface name.
- | These settings are lost at pc reboot.
+ # check
+ ethtool -k xth1
-#. Disable CPU frequency scaling and set system to performance
+ # enable generic receiver offload
+ ethtool -K xth1 gro
+
+
+#. Disable power saving in CPU frequency scaling and set system to performance
* Check current policy (default might be powersave or schedutil)
.. code-block:: bash
@@ -159,7 +203,10 @@ Receiver PC Tuning Options
# set to performance
sudo cpupower frequency-set -g performance
-
+ # or
+ cpufreq-info
+ for i in ‘seq 0 7‘; do cpufreq-set -c $i -g performance; done
+
* Permanently
.. code-block:: bash
@@ -179,18 +226,29 @@ Receiver PC Tuning Options
This is also set if slsReceiver is run as root user.
+#. Some more advanced options:
+ .. warning ::
-#. Disable power saving in CPU frequency
- .. code-block:: bash
+ Please do not try if you do not understand
- # or similar command depending on your distribution
- cpupower frequency-info
- cpupower frequency-set -g performance
+ #. reduce the number of queue per NIC to the number of expected streams: ethtool -L xth0 combined 2
+ #. assign each queue to its stream: ethtool -U xth0 flow-type tcp4 dst-port 50004 action 1
+ #. assign to each queue (IRQ) one CPU on the right socket: echo "3"> /proc/irq/47/smp_affinity_list #change the numbers looking at /proc/interrupts
+ #. disable irqbalance service
+ #. Be sure that the switch knows the receiver mac address. Most switches reset the mac lists every few minutes, and since the receiver only receives, there is not a periodic refresh of the mac list. In this case, one can set a fixed mac list in the switch, or setup some kind of script arping or pinging out from that interface (will be available in 7.0.0).
+ #. assign the receiver numa node (also with -m) to the socket where the NIC is attached. To know it, cat /sys/class/net/ethxxx/device/numa_node
+ #. ensure file system performance can handle sustained high data rate:
+
+ * One can use dd:
- # or
- cpufreq-info
- for i in ‘seq 0 7‘; do cpufreq-set -c $i -g performance; done
+ .. code-block:: bash
+
+ dd if=/dev/zero of=/testpath/testfile bs=1M count=100000
+ * Or better fio (which needs to be installed)
+ .. code-block:: bash
+
+ fio --name=global –directory=/testpath/ --rw=write --ioengine=libaio --direct=0 --size=200G -- numjobs=2 --iodepth=1 --bs=1M –name=job
slsReceiver Tuning
^^^^^^^^^^^^^^^^^^
@@ -198,18 +256,25 @@ slsReceiver Tuning
#. Starting receiver as root to have scheduling privileges.
#. For 10g, enable flow control
+
.. code-block:: bash
sls_detector_put flowcontrol10g 1
-#. Increase slsReceiver fifo depth between listening and processing threads.
+#. Increase slsReceiver ring buffer depth
+ This can be tuned depending on the number of receivers (modules) and memory available.
+
.. code-block:: bash
- sls_detector_get rx_fifodepth
- # sets number of frames in fifo to 5000
- sls_detector_put rx_fifodepth 5000
+ # sugggested not to use more than half memory of CPU socket in case of NUMA systems) for this
+
+ sls_detector_get rx_fifodepth
+ # sets number of frames in fifo to 1024 ~1GB per receiver. Default is 2500
+ sls_detector_put rx_fifodepth 1024
+
+#. Increase number of frames per file
+ This can reduce time taken to open and close files.
-#. Increase number of frames per file to reduce time taken to open and close files.
.. code-block:: bash
sls_detector_get rx_framesperfile
@@ -217,10 +282,31 @@ slsReceiver Tuning
# writes all frames into a single file
sls_detector_put rx_framesperfile 0
+#. Disable file write
+ This can ensure it is not the file system performance hampering high date rate.
+
+ .. code-block:: bash
+
+ sls_detector_put fwrite 0
+
Shared memory error
^^^^^^^^^^^^^^^^^^^
-| For errors due to access or size, delete shared memory files nd try again.
+For errors due to access or size, use any of the following suggestions.
+ #. Delete shared memory files and try again
+ #. Use environment variable to use a different shared memory ending in jfxx
+
+ .. code-block:: bash
+
+ # shared memory ending in jfxx
+ export SLSDETNAME=jfxx
+
+ #. USe a different multi shared memory ID
+ .. code-block:: bash
+
+ sls_detector_put 2-config xxxx.config
+ # or
+ sls_detector_put 2-hostname bchipxxx
To list all shared memory files of sls detector package.
.. code-block:: bash
@@ -331,6 +417,7 @@ Cannot get multi module data
#. Check :ref:`Common Multi Module Troubleshooting`
#. Power Supply
+ * Jungfrau needs a ~4A per module for a short time at startup. If not, it reboots misconfigured.
* 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.
diff --git a/docs/src/udpconfig.rst b/docs/src/udpconfig.rst
index 457d1f381..f3e56d82a 100644
--- a/docs/src/udpconfig.rst
+++ b/docs/src/udpconfig.rst
@@ -6,6 +6,10 @@ Config file
Commands to configure the UDP in the config file:
+.. note ::
+
+ These command are recommended to be placed before "rx_hostname" if it is used.
+
Source Port
-----------
Hardcoded in detector server, starting at 32410.
diff --git a/docs/src/udpdetspec.rst b/docs/src/udpdetspec.rst
index de84e707b..afeeeb564 100644
--- a/docs/src/udpdetspec.rst
+++ b/docs/src/udpdetspec.rst
@@ -49,13 +49,13 @@ Jungfrau
+----------+--------------------+-----+----------------------------------------+
| 0 | High gain | 1 | High Gain enabled |
| | +-----+----------------------------------------+
- | | | 0 | High Gain disabled |
+ | | | 0 | High Gain disabled |
+----------+--------------------+-----+----------------------------------------+
| 1 | Fix gain stage 1 | 1 | Gain stage 1 fixed. The switch that |
| | | | selects the gains stage 1 is active all|
| | | | the time. |
| | +-----+----------------------------------------+
- | | | 0 | Gain stage 1 unset. The switch that |
+ | | | 0 | Gain stage 1 unset. The switch that |
| | | | selects the gains stage 1 is inactive |
| | | | all the time. |
+----------+--------------------+-----+----------------------------------------+
@@ -63,7 +63,7 @@ Jungfrau
| | | | selects the gains stage 2 is active all|
| | | | the time. |
| | +-----+----------------------------------------+
- | | | 0 | Gain stage 2 unset. The switch that |
+ | | | 0 | Gain stage 2 unset. The switch that |
| | | | selects the gains stage 2 is inactive |
| | | | all the time. |
+----------+--------------------+-----+----------------------------------------+
@@ -71,7 +71,7 @@ Jungfrau
| | | | Dynamic-gain switching is therefore |
| | | | disabled. |
| | +-----+----------------------------------------+
- | | | 0 | On-chip comparator active. |
+ | | | 0 | On-chip comparator active. |
+----------+--------------------+-----+-----+-----+----------------------------+
| 7-5 | Jungfrau chip |Bit 7|Bit 6|Bit 5| Description |
| | version +-----+-----+-----+----------------------------+
@@ -90,7 +90,7 @@ Jungfrau
| 12 | Force switching | 1 | Forced switching to gain stage 1 at the|
| | to gain stage 1 | | start of the exposure period. |
| | +-----+----------------------------------------+
- | | | 0 | Disabled forced gain switching to gain |
+ | | | 0 | Disabled forced gain switching to gain |
| | | | stage 1. Dynamic gain switching |
| | | | conditions apply. |
+----------+--------------------+-----+----------------------------------------+
@@ -109,8 +109,8 @@ Jungfrau
| 31 | External input flag| 1 | External input flag detected in the |
| | | | last exposure. |
| | +-----+----------------------------------------+
- | | | 0 | External input flag not detected in the|
- | | | | last exposure. |
+ | | | 0 | External input flag not detected in the|
+ | | | | last exposure. |
+----------+--------------------+-----+----------------------------------------+
@@ -131,6 +131,22 @@ Gotthard2
+----------+------------------------------+
+Mythen3
+----------
+
+.. table:: Detector Specific Field
+
+ +----------+------------------------------+
+ | detSpec1 | 0 |
+ +----------+------------------------------+
+ | detSpec2 | 0 |
+ +----------+------------------------------+
+ | detSpec3 | 0 |
+ +----------+------------------------------+
+ | detSpec4 | 0 |
+ +----------+------------------------------+
+
+
.. [#] **Bunch Id**: bunch identification number received by the detector at the moment of frame acquisition.
.. [#] **Train Id**: train identification number received by the detector at the moment of frame acquisition.
.. [#] **Bunch Id**: bunch identification number to identify every single exposure during a burst acquisition.
diff --git a/docs/src/udpheader.rst b/docs/src/udpheader.rst
index 6bedffc91..04f3a5a6a 100644
--- a/docs/src/udpheader.rst
+++ b/docs/src/udpheader.rst
@@ -9,9 +9,9 @@ The UDP data format for the packets consist of a common header for all detectors
Current Version
---------------------------
-**v3.0 (slsDetectorPackage v7.0.0+)**
+**v2.0 (slsDetectorPackage v7.0.0+)**
-.. table:: <---------------------------------------------------- 8 bytes ---------------------------------------------------->
+.. table:: <---------------------------------------------------- 8 bytes per row --------------------------------------------->
:align: center
:widths: 30,30,30,15,15
@@ -30,6 +30,18 @@ Current Version
+-------------------------------+---------------+-------+-------+
+.. note ::
+
+ Since there is no difference in the format of the UDP header from the detector
+ from the previous version (v2.0), the version number stays the same.
+
+ Only the struture member names have changed in sls_detector_defs.h
+
+
+
+Description
+------------
+
* **Detector specific field** descriptions are found :ref:`here`.
* **frameNumber**: framenumber to which the current packet belongs to.
@@ -48,6 +60,12 @@ Current Version
* **detType**: detector type from enum of detectorType in the package.
+* **version**: current version of the detector header (0x2).
+
+
+Detector Enum
+--------------
+
================ ========
Detector Type Value
================ ========
@@ -61,7 +79,6 @@ Current Version
GOTTHARD2 7
================ ========
-* **version**: current version of the detector header. It is at 0x3.
Previous Versions
diff --git a/docs/src/virtualserver.rst b/docs/src/virtualserver.rst
index 66d66ab74..7a030347a 100644
--- a/docs/src/virtualserver.rst
+++ b/docs/src/virtualserver.rst
@@ -13,16 +13,14 @@ Compilation
* Using cmk.sh script,
.. code-block:: bash
- ./cmk.sh -bsj9 #option s is for simulator
+ ./cmk.sh -bsj9 # option -s is for simulator
Binaries
^^^^^^^^
.. code-block:: bash
- eigerDetectorServerMaster_virtual
- eigerDetectorServerSlaveTop_virtual
- eigerDetectorServerSlaveBottom_virtual
+ eigerDetectorServer_virtual
jungfrauDetectorServer_virtual
gotthardDetectorServer_virtual
gotthard2DetectorServer_virtual
@@ -67,7 +65,15 @@ Sample Config file
^^^^^^^^^^^^^^^^^^
There are sample config files for each detector in slsDetectorPackage/examples folder.
-For a Single Module
+For a Single Module (Basic)
+ .. code-block:: bash
+
+ hostname localhost
+ rx_hostname localhost
+ udp_dstip auto
+
+
+For a Single Module (With Options)
.. code-block:: bash
# connects to control port 1912
@@ -140,7 +146,7 @@ Gui
Limitations
-----------
-#. Data coming out of virtual server is fake. Value at each pixel/ channel is incremented by 1.
+#. Data coming out of virtual server is fake.
#. A stop will stop the virtual acquisition only at the start of every new frame.
diff --git a/examples/badchannel.txt b/examples/badchannel.txt
new file mode 100644
index 000000000..1de3c6eb6
--- /dev/null
+++ b/examples/badchannel.txt
@@ -0,0 +1,6 @@
+0
+10, 30
+40:45 50:52
+1279
+# all bad channels are applied for all counters in deector
+
diff --git a/examples/jungfrau_two.config b/examples/jungfrau_two.config
index f6c6230fe..4ee3f9d7f 100755
--- a/examples/jungfrau_two.config
+++ b/examples/jungfrau_two.config
@@ -5,7 +5,7 @@ detsize 1024 1024
hostname bchip048+bchip052+
# 1Gb receiver pc hostname (default tcpport: 1954)
-rx_hostname pcmoench01+pcmoench01:1955
+rx_hostname pcmoench01:1954+pcmoench01:1955+
diff --git a/examples/virtual_ctb_moench.config b/examples/virtual_ctb_moench.config
index e5c74c65e..3b6c35bde 100644
--- a/examples/virtual_ctb_moench.config
+++ b/examples/virtual_ctb_moench.config
@@ -1,18 +1,18 @@
# detector hostname
hostname localhost:1910
-# receiver hostname
-rx_hostname mpc1922:2010
-
# udp destination ports
udp_dstport 50010
-# udp destination ip from rx_hostname
-udp_dstip auto
-
# udp source ip (same subnet as udp_dstip)
udp_srcip 192.168.1.100
+# receiver hostname
+rx_hostname mpc1922:2010
+
+# udp destination ip from rx_hostname
+udp_dstip auto
+
# output file directory
fpath /tmp
@@ -27,418 +27,7 @@ dbitclk 40
# patterns
-patword 0x0000 0x0000000000000000
-patword 0x0001 0x0000000000000000
-patword 0x0002 0x0008000900080000
-patword 0x0003 0x0008000900080000
-patword 0x0004 0x0008000900080000
-patword 0x0005 0x0008000900080000
-patword 0x0006 0x0008000900080000
-patword 0x0007 0x0008000900080000
-patword 0x0008 0x0008000900080000
-patword 0x0009 0x0008000900080000
-patword 0x000a 0x0008000900080000
-patword 0x000b 0x0008000900080000
-patword 0x000c 0x0008000900080000
-patword 0x000d 0x0008000900080000
-patword 0x000e 0x0008000900080000
-patword 0x000f 0x0008000900080000
-patword 0x0010 0x0008000900080000
-patword 0x0011 0x0008000900080000
-patword 0x0012 0x0008000900080000
-patword 0x0013 0x0008000900080000
-patword 0x0014 0x0008000900080000
-patword 0x0015 0x0008000900080000
-patword 0x0016 0x0008400900080020
-patword 0x0017 0x0008400900080020
-patword 0x0018 0x0008599f0418503a
-patword 0x0019 0x0008599f0418503a
-patword 0x001a 0x0108599f0418503a
-patword 0x001b 0x0108599f0418503a
-patword 0x001c 0x0108599f0418503a
-patword 0x001d 0x0108599f0418503a
-patword 0x001e 0x0108599f0418503a
-patword 0x001f 0x0108599f0418503a
-patword 0x0020 0x0108599f0418503a
-patword 0x0021 0x0108599f0418503a
-patword 0x0022 0x0108599f0418503a
-patword 0x0023 0x0108599f0418503a
-patword 0x0024 0x0108599f0418503a
-patword 0x0025 0x0108599f0418503a
-patword 0x0026 0x0108599f0418503a
-patword 0x0027 0x0108599f0418503a
-patword 0x0028 0x0108599f0418503a
-patword 0x0029 0x0108599f0418503a
-patword 0x002a 0x0108599f0418503a
-patword 0x002b 0x0108599f0418503a
-patword 0x002c 0x0108599f0418503a
-patword 0x002d 0x0108599f0418503a
-patword 0x002e 0x0108599f0418503a
-patword 0x002f 0x0108599f0418503a
-patword 0x0030 0x0108599f0418503a
-patword 0x0031 0x0108599f0418503a
-patword 0x0032 0x0108599f0418503a
-patword 0x0033 0x0108599f0418503a
-patword 0x0034 0x0108599f0418503a
-patword 0x0035 0x0108599f0418503a
-patword 0x0036 0x0108599f0418503a
-patword 0x0037 0x0108599f0418503a
-patword 0x0038 0x0108599f0418503a
-patword 0x0039 0x0108599f0418503a
-patword 0x003a 0x0108599f0418503a
-patword 0x003b 0x0108599f0418503a
-patword 0x003c 0x0108599f0418503a
-patword 0x003d 0x0108599f0418503a
-patword 0x003e 0x0108599f0418503a
-patword 0x003f 0x0108599f0418503a
-patword 0x0040 0x0108599f0418503a
-patword 0x0041 0x0108599f0418503a
-patword 0x0042 0x0108599f0418503a
-patword 0x0043 0x0108599f0418503a
-patword 0x0044 0x0108599f0418503a
-patword 0x0045 0x0108599f0418503a
-patword 0x0046 0x0108599f0418503a
-patword 0x0047 0x0108599f0418503a
-patword 0x0048 0x0108599f0418503a
-patword 0x0049 0x0108599f0418503a
-patword 0x004a 0x0108599f0418503a
-patword 0x004b 0x0108599f0418503a
-patword 0x004c 0x0108599f0418503a
-patword 0x004d 0x0108599f0418503a
-patword 0x004e 0x0108599f0418503a
-patword 0x004f 0x0108599f0418503a
-patword 0x0050 0x0108599f0418503a
-patword 0x0051 0x0108599f0418503a
-patword 0x0052 0x0108599f0418503a
-patword 0x0053 0x0108599f0418503a
-patword 0x0054 0x0108599f0418503a
-patword 0x0055 0x0108599f0418503a
-patword 0x0056 0x0108599f0418503a
-patword 0x0057 0x0108599f0418503a
-patword 0x0058 0x0108599f0418503a
-patword 0x0059 0x0108599f0418503a
-patword 0x005a 0x0108599f0418503a
-patword 0x005b 0x0108599f0418503a
-patword 0x005c 0x0108599f0418503a
-patword 0x005d 0x0108599f0418503a
-patword 0x005e 0x0108599f0418503a
-patword 0x005f 0x0108599f0418503a
-patword 0x0060 0x0108599f0418503a
-patword 0x0061 0x0108599f0418503a
-patword 0x0062 0x0108599f0418503a
-patword 0x0063 0x0108599f0418503a
-patword 0x0064 0x0108599f0418503a
-patword 0x0065 0x0108599f0418503a
-patword 0x0066 0x0108599f0418503a
-patword 0x0067 0x0108599f0418503a
-patword 0x0068 0x0108599f0418503a
-patword 0x0069 0x0108599f0418503a
-patword 0x006a 0x0108599f0418503a
-patword 0x006b 0x0108599f0418503a
-patword 0x006c 0x0108599f0418503a
-patword 0x006d 0x0108599f0418503a
-patword 0x006e 0x0108599f0418503a
-patword 0x006f 0x0108599f0418503a
-patword 0x0070 0x0108599f0418503a
-patword 0x0071 0x0108599f0418503a
-patword 0x0072 0x0108599f0418503a
-patword 0x0073 0x0108599f0418503a
-patword 0x0074 0x0108599f0418503a
-patword 0x0075 0x0108599f0418503a
-patword 0x0076 0x0108599f0418503a
-patword 0x0077 0x0108599f0418503a
-patword 0x0078 0x0108599f0418503a
-patword 0x0079 0x0108599f0418503a
-patword 0x007a 0x0108599f0418503a
-patword 0x007b 0x0108599f0418503a
-patword 0x007c 0x0108599f0418503a
-patword 0x007d 0x0108599f0418503a
-patword 0x007e 0x010859960418503a
-patword 0x007f 0x010859960418503a
-patword 0x0080 0x010859960418503a
-patword 0x0081 0x010859960418503a
-patword 0x0082 0x010859960418503a
-patword 0x0083 0x010859960418503a
-patword 0x0084 0x010859960418503a
-patword 0x0085 0x010859960418503a
-patword 0x0086 0x010859960418503a
-patword 0x0087 0x010859960418503a
-patword 0x0088 0x010859960418503a
-patword 0x0089 0x010859960418503a
-patword 0x008a 0x010859960418503a
-patword 0x008b 0x010859960418503a
-patword 0x008c 0x010859960418503a
-patword 0x008d 0x010859960418503a
-patword 0x008e 0x010859960418503a
-patword 0x008f 0x010859960418503a
-patword 0x0090 0x010859960418503a
-patword 0x0091 0x010859960418503a
-patword 0x0092 0x010819960418501a
-patword 0x0093 0x010819960418501a
-patword 0x0094 0x010819960418501a
-patword 0x0095 0x010819960418501a
-patword 0x0096 0x030819960418501a
-patword 0x0097 0x030819960418501a
-patword 0x0098 0x030819960418501a
-patword 0x0099 0x030819960418501a
-patword 0x009a 0x030819960418501a
-patword 0x009b 0x030819960418501a
-patword 0x009c 0x030819960418501a
-patword 0x009d 0x030819960418501a
-patword 0x009e 0x030819960418501a
-patword 0x009f 0x030819960418501a
-patword 0x00a0 0x030819960418501a
-patword 0x00a1 0x030819960418501a
-patword 0x00a2 0x030819960418501a
-patword 0x00a3 0x030819960418501a
-patword 0x00a4 0x030819960418501a
-patword 0x00a5 0x030819960418501a
-patword 0x00a6 0x030819960418501a
-patword 0x00a7 0x030819960418501a
-patword 0x00a8 0x030819960418501a
-patword 0x00a9 0x030819960418501a
-patword 0x00aa 0x030819960418501a
-patword 0x00ab 0x030819960418501a
-patword 0x00ac 0x030819960008501a
-patword 0x00ad 0x030819960008501a
-patword 0x00ae 0x030819960008501a
-patword 0x00af 0x030819960008501a
-patword 0x00b0 0x030819960008501a
-patword 0x00b1 0x030819960008501a
-patword 0x00b2 0x030819960008501a
-patword 0x00b3 0x030819960008501a
-patword 0x00b4 0x030819960008501a
-patword 0x00b5 0x030819960008501a
-patword 0x00b6 0x030819960008501a
-patword 0x00b7 0x030819960008501a
-patword 0x00b8 0x030819960008501a
-patword 0x00b9 0x030819960008501a
-patword 0x00ba 0x030819960008501a
-patword 0x00bb 0x030819960008501a
-patword 0x00bc 0x030819960008501a
-patword 0x00bd 0x030819960008501a
-patword 0x00be 0x030819960008501a
-patword 0x00bf 0x030819960008501a
-patword 0x00c0 0x0308199f0008501a
-patword 0x00c1 0x0308199f0008501a
-patword 0x00c2 0x0308199f0008501a
-patword 0x00c3 0x0308199f0008501a
-patword 0x00c4 0x0308199f0008501a
-patword 0x00c5 0x0308199f0008501a
-patword 0x00c6 0x0308199f0008501a
-patword 0x00c7 0x0308199f0008501a
-patword 0x00c8 0x0308199f0008501a
-patword 0x00c9 0x0308199f0008501a
-patword 0x00ca 0x0308199f0008501a
-patword 0x00cb 0x0308199f0008501a
-patword 0x00cc 0x0308199f0008501a
-patword 0x00cd 0x0308199f0008501a
-patword 0x00ce 0x0308199f0008501a
-patword 0x00cf 0x0308199f0008501a
-patword 0x00d0 0x0308199f0008501a
-patword 0x00d1 0x0308199f0008501a
-patword 0x00d2 0x0308199f0008501a
-patword 0x00d3 0x0308199f0008501a
-patword 0x00d4 0x0308599f0008503a
-patword 0x00d5 0x0308599f0008503a
-patword 0x00d6 0x030c599f000850ba
-patword 0x00d7 0x030c599f000850ba
-patword 0x00d8 0x030c599f000850ba
-patword 0x00d9 0x030c599f000850ba
-patword 0x00da 0x030c599f000850ba
-patword 0x00db 0x030c599f000850ba
-patword 0x00dc 0x030c599f000850ba
-patword 0x00dd 0x030c599f000850ba
-patword 0x00de 0x030c599f000850ba
-patword 0x00df 0x030c599f000850ba
-patword 0x00e0 0x030c599f000850ba
-patword 0x00e1 0x030c599f000850ba
-patword 0x00e2 0x030c599f000850ba
-patword 0x00e3 0x030c599f000850ba
-patword 0x00e4 0x030c599f000850ba
-patword 0x00e5 0x030c599f000850ba
-patword 0x00e6 0x030c599f000850ba
-patword 0x00e7 0x030c599f000850ba
-patword 0x00e8 0x030c599f000850ba
-patword 0x00e9 0x030c599f000850ba
-patword 0x00ea 0x030c799f010858ba
-patword 0x00eb 0x030c799f010858ba
-patword 0x00ec 0x030c599f000850ba
-patword 0x00ed 0x030c599f000850ba
-patword 0x00ee 0x030c599f000850ba
-patword 0x00ef 0x030c599f000850ba
-patword 0x00f0 0x030c599f000850ba
-patword 0x00f1 0x030c599f000850ba
-patword 0x00f2 0x030c599f000850ba
-patword 0x00f3 0x030c599f000850ba
-patword 0x00f4 0x030c599f000850ba
-patword 0x00f5 0x030c599f000850ba
-patword 0x00f6 0x030c599f000850ba
-patword 0x00f7 0x030c599f000850ba
-patword 0x00f8 0x030c599f000850ba
-patword 0x00f9 0x030c599f000850ba
-patword 0x00fa 0x030c599f000850ba
-patword 0x00fb 0x030c599f000850ba
-patword 0x00fc 0x030c599f000850ba
-patword 0x00fd 0x030c599f000850ba
-patword 0x00fe 0x030c599f000850ba
-patword 0x00ff 0x030c599f000850ba
-patword 0x0100 0x030c599f000850ba
-patword 0x0101 0x030c599f000850ba
-patword 0x0102 0x030c599f400850ba
-patword 0x0103 0x030c599f400850ba
-patword 0x0104 0x030c599f600850ba
-patword 0x0105 0x030c599f400850ba
-patword 0x0106 0x030c599f400850ba
-patword 0x0107 0x030c599f400850ba
-patword 0x0108 0x870c599f682e50ba
-patword 0x0109 0x870c599f482850ba
-patword 0x010a 0x870c599f000e50ba
-patword 0x010b 0x870c599f000850ba
-patword 0x010c 0x870c599f000e50ba
-patword 0x010d 0x870c599f000850ba
-patword 0x010e 0x870c599f000e50ba
-patword 0x010f 0x870c599f000850ba
-patword 0x0110 0x870c599f000e50ba
-patword 0x0111 0x870c599f000850ba
-patword 0x0112 0x870c599f000e50ba
-patword 0x0113 0x870c599f000850ba
-patword 0x0114 0x870c599f000e50ba
-patword 0x0115 0x870c599f000850ba
-patword 0x0116 0x870c599f000e50ba
-patword 0x0117 0x870c599f000850ba
-patword 0x0118 0x870c599f000e50ba
-patword 0x0119 0x870c599f000850ba
-patword 0x011a 0x870c599f000e50ba
-patword 0x011b 0x870c599f000850ba
-patword 0x011c 0x870c599f000e50ba
-patword 0x011d 0x870c599f000850ba
-patword 0x011e 0x870c599f000e50ba
-patword 0x011f 0x870c599f000850ba
-patword 0x0120 0x870c599f000e50ba
-patword 0x0121 0x870c599f000850ba
-patword 0x0122 0x870c599f200e50ba
-patword 0x0123 0x870c599f000850ba
-patword 0x0124 0x870c599f000e50ba
-patword 0x0125 0x870c599f000850ba
-patword 0x0126 0x870c599f000e50ba
-patword 0x0127 0x870c599f000850ba
-patword 0x0128 0x870c599f000e50ba
-patword 0x0129 0x870c599f000850ba
-patword 0x012a 0x870c599f000e50ba
-patword 0x012b 0x870c599f000850ba
-patword 0x012c 0x870c599f000e50ba
-patword 0x012d 0x870c599f000850ba
-patword 0x012e 0x870c599f000e50ba
-patword 0x012f 0x870c599f000850ba
-patword 0x0130 0x870c599f000e50ba
-patword 0x0131 0x870c599f000850ba
-patword 0x0132 0x870c599f000e50ba
-patword 0x0133 0x870c599f000850ba
-patword 0x0134 0x870c599f000e50ba
-patword 0x0135 0x870c599f000850ba
-patword 0x0136 0x870c599f000e50ba
-patword 0x0137 0x870c599f000850ba
-patword 0x0138 0x870c599f000e50ba
-patword 0x0139 0x870c599f000850ba
-patword 0x013a 0x870c599f282e50ba
-patword 0x013b 0x870c599f082850ba
-patword 0x013c 0x870c599f000e50ba
-patword 0x013d 0x870c599f000850ba
-patword 0x013e 0x870c599f000e50ba
-patword 0x013f 0x870c599f000850ba
-patword 0x0140 0x870c599f000e50ba
-patword 0x0141 0x870c599f000850ba
-patword 0x0142 0x870c599f000e50ba
-patword 0x0143 0x870c599f000850ba
-patword 0x0144 0x870c599f000e50ba
-patword 0x0145 0x870c599f000850ba
-patword 0x0146 0x870c599f000e50ba
-patword 0x0147 0x870c599f000850ba
-patword 0x0148 0x870c599f000e50ba
-patword 0x0149 0x870c599f000850ba
-patword 0x014a 0x870c599f000e50ba
-patword 0x014b 0x870c599f000850ba
-patword 0x014c 0x870c599f000e50ba
-patword 0x014d 0x870c599f000850ba
-patword 0x014e 0x870c599f000e50ba
-patword 0x014f 0x870c599f000850ba
-patword 0x0150 0x870c599f000e50ba
-patword 0x0151 0x870c599f000850ba
-patword 0x0152 0x870c599f000e50ba
-patword 0x0153 0x870c599f000850ba
-patword 0x0154 0x870c599f200e50ba
-patword 0x0155 0x870c599f000850ba
-patword 0x0156 0x870c599f000e50ba
-patword 0x0157 0x870c599f000850ba
-patword 0x0158 0x870c599f000e50ba
-patword 0x0159 0x870c599f000850ba
-patword 0x015a 0x870c599f000e50ba
-patword 0x015b 0x870c599f000850ba
-patword 0x015c 0x870c599f000e50ba
-patword 0x015d 0x870c599f000850ba
-patword 0x015e 0x870c599f000e50ba
-patword 0x015f 0x870c599f000850ba
-patword 0x0160 0x870c599f000e50ba
-patword 0x0161 0x870c599f000850ba
-patword 0x0162 0x870c599f000e50ba
-patword 0x0163 0x870c599f000850ba
-patword 0x0164 0x870c599f000e50ba
-patword 0x0165 0x870c599f000850ba
-patword 0x0166 0x870c599f000e50ba
-patword 0x0167 0x870c599f000850ba
-patword 0x0168 0x870c599f000e50ba
-patword 0x0169 0x870c599f000850ba
-patword 0x016a 0x870c599f000e50ba
-patword 0x016b 0x870c599f000850ba
-patword 0x016c 0x070c599f000850ba
-patword 0x016d 0x070c599f000850ba
-patword 0x016e 0x000c599f000850ba
-patword 0x016f 0x000c599f000850ba
-patword 0x0170 0x0008599f200e503a
-patword 0x0171 0x0008599f0008503a
-patword 0x0172 0x0008599f200e503a
-patword 0x0173 0x0008599f0008503a
-patword 0x0174 0x0008599f0008503a
-patword 0x0175 0x0008599f0008503a
-patword 0x0176 0x0008599f0008503a
-patword 0x0177 0x0008599f0008503a
-patword 0x0178 0x0008599f0008503a
-patword 0x0179 0x0008599f0008503a
-patword 0x017a 0x0008599f0008503a
-patword 0x017b 0x0008599f0008503a
-patword 0x017c 0x0008599f0008503a
-patword 0x017d 0x0008599f0008503a
-patword 0x017e 0x0008599f0008503a
-patword 0x017f 0x0008599f0008503a
-patword 0x0180 0x0008599f0008503a
-patword 0x0181 0x0008599f0008503a
-patword 0x0182 0x0008599f0008503a
-patword 0x0183 0x0008599f0008503a
-patword 0x0184 0x0008599f0008503a
-patword 0x0185 0x0008599f0008503a
-patword 0x0186 0x0008599f0008503a
-patword 0x0187 0x0008599f0008503a
-patword 0x0188 0x0008599f0008503a
-patword 0x0189 0x0008599f0008503a
-patword 0x018a 0x0008599f0008503a
-patword 0x018b 0x0008599f0008503a
-patword 0x018c 0x0008599f0008503a
-patword 0x018d 0x0008599f0008503a
-patioctrl 0x8f0effff6dbffdbf
-patlimits 0x0000 0x018c
-patloop 0 0x013a 0x016b
-patnloop 0 0x199
-patloop 1 0x0400 0x0400
-patnloop 1 0
-patloop 2 0x0400 0x0400
-patnloop 2 0
-patwait 0 0x00aa
-patwaittime 0 10000
-patwait 1 0x0400
-patwaittime 1 0
-patwait 2 0x0400
-patwaittime 2 0
+pattern /tmp/pattern.pat
# dacs
dac 6 800
diff --git a/examples/virtual_eiger_1_half_module.config b/examples/virtual_eiger_1_half_module.config
index fa815af3e..c88cd0fde 100644
--- a/examples/virtual_eiger_1_half_module.config
+++ b/examples/virtual_eiger_1_half_module.config
@@ -1,13 +1,13 @@
# detector hostname
hostname localhost:1900
-# receiver hostname
-rx_hostname mpc1922:2000
-
# udp destination ports
udp_dstport 50000
udp_dstport2 50001
+# receiver hostname
+rx_hostname mpc1922:2000
+
# udp destination ip from rx_hostname
udp_dstip auto
diff --git a/examples/virtual_eiger_2_half_modules.config b/examples/virtual_eiger_2_half_modules.config
index f58270678..e4d1f5ed8 100644
--- a/examples/virtual_eiger_2_half_modules.config
+++ b/examples/virtual_eiger_2_half_modules.config
@@ -1,15 +1,15 @@
# detector hostname
hostname localhost:1900+localhost:1902+
-# receiver hostname
-rx_hostname mpc1922:2000+mpc1922:2001+
-
# udp destination ports
0:udp_dstport 50000
0:udp_dstport2 50001
1:udp_dstport 50002
1:udp_dstport2 50003
+# receiver hostname
+rx_hostname mpc1922:2000+mpc1922:2001+
+
# udp destination ip from rx_hostname
udp_dstip auto
diff --git a/examples/virtual_gotthard.config b/examples/virtual_gotthard.config
index c30957154..df4482d0b 100644
--- a/examples/virtual_gotthard.config
+++ b/examples/virtual_gotthard.config
@@ -1,18 +1,18 @@
# detector hostname
hostname localhost:1904
-# receiver hostname
-rx_hostname mpc1922:2004
-
# udp destination ports
udp_dstport 50004
-# udp destination ip from rx_hostname
-udp_dstip auto
-
# udp source ip (same subnet as udp_dstip)
udp_srcip 192.168.1.100
+# receiver hostname
+rx_hostname mpc1922:2004
+
+# udp destination ip from rx_hostname
+udp_dstip auto
+
# output file directory
fpath /tmp
diff --git a/examples/virtual_gotthard2.config b/examples/virtual_gotthard2.config
index 9e2456fe9..8ebf9326a 100644
--- a/examples/virtual_gotthard2.config
+++ b/examples/virtual_gotthard2.config
@@ -1,24 +1,12 @@
# detector hostname
hostname localhost:1914
-# receiver hostname
-rx_hostname mpc1922:2014
-
# udp destination ports
udp_dstport 50014
-# udp destination ip from rx_hostname
-udp_dstip auto
-
# udp source ip (same subnet as udp_dstip)
udp_srcip 192.168.1.100
-# output file directory
-fpath /tmp
-
-# disable file writing
-fwrite 0
-
# enable 2nd interface for veto debugging
# udp destination port for veto
udp_dstport2 50015
@@ -27,6 +15,18 @@ udp_dstip2 auto
# udp source ip (same subnet as udp_dstip)
udp_srcip2 192.168.1.100
+# receiver hostname
+rx_hostname mpc1922:2014
+
+# udp destination ip from rx_hostname
+udp_dstip auto
+
+# output file directory
+fpath /tmp
+
+# disable file writing
+fwrite 0
+
# to enable 2nd interface for veto debugging
numinterfaces 2
diff --git a/examples/virtual_jungfrau.config b/examples/virtual_jungfrau.config
index c81b8d08c..4f7ed99f5 100644
--- a/examples/virtual_jungfrau.config
+++ b/examples/virtual_jungfrau.config
@@ -1,21 +1,21 @@
# detector hostname
hostname localhost:1906
-# receiver hostname
-rx_hostname mpc1922:2006
-
# udp destination ports
udp_dstport 50006
udp_dstport2 50007
-# udp destination ip from rx_hostname
-udp_dstip auto
-udp_dstip2 auto
-
# udp source ip (same subnet as udp_dstip)
udp_srcip 192.168.1.100
udp_srcip2 192.168.1.100
+# receiver hostname
+rx_hostname mpc1922:2006
+
+# udp destination ip from rx_hostname
+udp_dstip auto
+udp_dstip2 auto
+
# output file directory
fpath /tmp
diff --git a/examples/virtual_jungfrau_4.config b/examples/virtual_jungfrau_4.config
index 91e5b259f..021c2c4ae 100644
--- a/examples/virtual_jungfrau_4.config
+++ b/examples/virtual_jungfrau_4.config
@@ -4,13 +4,6 @@ detsize 2048 1024
# detector hostname
virtual 4 1952
-# receiver hostname and tcpports
-0:rx_tcpport 1970
-1:rx_tcpport 1971
-2:rx_tcpport 1972
-3:rx_tcpport 1973
-rx_hostname mpc1922
-
# udp destination ports
0:udp_dstport2 50001
0:udp_dstport2 50002
@@ -21,14 +14,21 @@ rx_hostname mpc1922
3:udp_dstport 50007
3:udp_dstport2 50008
-# udp destination ip from rx_hostname
-udp_dstip auto
-udp_dstip2 auto
-
# 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_hostname mpc1922
+
+# udp destination ip from rx_hostname
+udp_dstip auto
+udp_dstip2 auto
+
# transmission delay frame
0:txndelay_frame 0
1:txndelay_frame 1
diff --git a/examples/virtual_moench.config b/examples/virtual_moench.config
index be9adfb14..921f3a77c 100644
--- a/examples/virtual_moench.config
+++ b/examples/virtual_moench.config
@@ -1,18 +1,18 @@
# detector hostname
hostname localhost:1908
-# receiver hostname
-rx_hostname mpc1922:2008
-
# udp destination ports
udp_dstport 50008
-# udp destination ip from rx_hostname
-udp_dstip auto
-
# udp source ip (same subnet as udp_dstip)
udp_srcip 192.168.1.100
+# receiver hostname
+rx_hostname mpc1922:2008
+
+# udp destination ip from rx_hostname
+udp_dstip auto
+
# output file directory
fpath /tmp
diff --git a/examples/virtual_mythen3.config b/examples/virtual_mythen3.config
index 55bcfc625..02f5a672d 100644
--- a/examples/virtual_mythen3.config
+++ b/examples/virtual_mythen3.config
@@ -1,18 +1,18 @@
# detector hostname
hostname localhost:1912
-# receiver hostname
-rx_hostname mpc1922:2012
-
# udp destination ports
udp_dstport 50012
-# udp destination ip from rx_hostname
-udp_dstip auto
-
# udp source ip (same subnet as udp_dstip)
udp_srcip 192.168.1.100
+# receiver hostname
+rx_hostname mpc1922:2012
+
+# udp destination ip from rx_hostname
+udp_dstip auto
+
# output file directory
fpath /tmp
diff --git a/patternGenerator/example_pattern/example_pattern.png b/patternGenerator/example_pattern/example_pattern.png
index d43e49dd0..12c5b5b9d 100644
Binary files a/patternGenerator/example_pattern/example_pattern.png and b/patternGenerator/example_pattern/example_pattern.png differ
diff --git a/patternGenerator/plotPattern.py b/patternGenerator/plotPattern.py
index 8228ba515..e069e8e10 100755
--- a/patternGenerator/plotPattern.py
+++ b/patternGenerator/plotPattern.py
@@ -31,7 +31,7 @@ alpha_wait = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
alpha_wait_rect = [0.2, 0.2, 0.2, 0.2, 0.2, 0.2]
# Loop colors and line styles (6 needed from 0 to 5)
-colors_loop = ['tab:green', 'tab:red', 'tab:purple', 'tab:brown', 'tab:ping', 'tab:grey']
+colors_loop = ['tab:green', 'tab:red', 'tab:purple', 'tab:brown', 'tab:pink', 'tab:grey']
linestyles_loop = ['-.', '-.', '-.', '-.', '-.', '-.']
alpha_loop = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
alpha_loop_rect = [0.2, 0.2, 0.2, 0.2, 0.2, 0.2]
@@ -527,7 +527,7 @@ for idx, i in enumerate(range(nbiteff)):
linestyle=linestyles_loop[2], color=colors_loop[2], alpha=alpha_loop[2],
label="loop 2: " + str(nloop2) + " times" if idx == 0 else "", linewidth=2.0)
axs2[idx].plot([loop2_end, loop2_end], [-10, 10],
- linestyle=linestyles_loop[0], color=colors_loop[0], alpha=alpha_loop[2], linewidth=2.0)
+ linestyle=linestyles_loop[2], color=colors_loop[2], alpha=alpha_loop[2], linewidth=2.0)
# Loop 3
if nloop3 is not None:
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index 51bb92de7..ae05bbf99 100755
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -34,6 +34,7 @@ set( PYTHON_FILES
slsdet/eiger.py
slsdet/enums.py
slsdet/errors.py
+ slsdet/gaincaps.py
slsdet/gotthard.py
slsdet/pattern.py
slsdet/gotthard2.py
diff --git a/python/scripts/compare_with_commandline.py b/python/scripts/compare_with_commandline.py
index d4d68fab6..ef72bc0a6 100644
--- a/python/scripts/compare_with_commandline.py
+++ b/python/scripts/compare_with_commandline.py
@@ -2,7 +2,7 @@
# Copyright (C) 2021 Contributors to the SLS Detector Package
import subprocess
import locale
-out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.getpreferredencoding())
+out = subprocess.run(['sls_detector_get', 'list'], stdout = subprocess.PIPE, encoding=locale.getpreferredencoding())
cmd = out.stdout.splitlines()
cmd.pop(0)
@@ -99,7 +99,6 @@ intentionally_missing = [
'temp_slowadc',
'temp_sodl',
'temp_sodr',
- 'trigger', #use sendSoftwareTrigger
'update', #use updateServerAndFirmare
'udp_validate', #use validateUdpConfiguration
'udp_reconfigure', #use reconfigureUdpDestination
diff --git a/python/setup.py b/python/setup.py
index 6a4c6bbed..47c732e82 100755
--- a/python/setup.py
+++ b/python/setup.py
@@ -7,7 +7,7 @@ Build upon the pybind11 example found here: https://github.com/pybind/python_exa
import os
import sys
-sys.path.append('../libs/pybind11')
+sys.path.append('../libs/pybind')
from setuptools import setup, find_packages
from pybind11.setup_helpers import Pybind11Extension, build_ext
@@ -22,19 +22,25 @@ def get_conda_path():
return os.environ['CONDA_PREFIX']
-#TODO migrate to CMake build?
+#TODO migrate to CMake build or fetch files from cmake?
ext_modules = [
Pybind11Extension(
'_slsdet',
['src/main.cpp',
- 'src/current.cpp',
'src/enums.cpp',
+ 'src/current.cpp',
'src/detector.cpp',
'src/network.cpp',
'src/pattern.cpp',
- 'src/scan.cpp',],
+ 'src/scan.cpp',
+ 'src/duration.cpp',
+ 'src/DurationWrapper.cpp',
+ ]
+
+
+ ,
include_dirs=[
- os.path.join('../libs/pybind11/include'),
+ os.path.join('../libs/pybind/include'),
os.path.join(get_conda_path(), 'include'),
],
diff --git a/python/slsdet/__init__.py b/python/slsdet/__init__.py
index cf03a8a4e..09568cbd1 100755
--- a/python/slsdet/__init__.py
+++ b/python/slsdet/__init__.py
@@ -11,7 +11,7 @@ from .gotthard2 import Gotthard2
from .gotthard import Gotthard
from .moench import Moench
from .pattern import Pattern, patternParameters
-
+from .gaincaps import Mythen3GainCapsWrapper
import _slsdet
xy = _slsdet.xy
diff --git a/python/slsdet/defines.py b/python/slsdet/defines.py
index 4f86a03f3..244ce207e 100644
--- a/python/slsdet/defines.py
+++ b/python/slsdet/defines.py
@@ -26,6 +26,7 @@ SHORT_STR_LENGTH=20
MAX_PATTERN_LENGTH=0x2000
MAX_PATTERN_LEVELS=6
M3_MAX_PATTERN_LEVELS=3
+MAX_NUM_COUNTERS=3
DEFAULT_STREAMING_TIMER_IN_MS=500
NUM_RX_THREAD_IDS=9
MAX_NUM_PACKETS=512
diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py
index 30d60f961..803faee77 100755
--- a/python/slsdet/detector.py
+++ b/python/slsdet/detector.py
@@ -14,8 +14,9 @@ streamingInterface = slsDetectorDefs.streamingInterface
defs = slsDetectorDefs
from .utils import element_if_equal, all_equal, get_set_bits, list_to_bitmask
-from .utils import Geometry, to_geo, element, reduce_time, is_iterable
+from .utils import Geometry, to_geo, element, reduce_time, is_iterable, hostname_list
from _slsdet import xy
+from .gaincaps import Mythen3GainCapsWrapper
from . import utils as ut
from .proxy import JsonProxy, SlowAdcProxy, ClkDivProxy, MaxPhaseProxy, ClkFreqProxy, PatLoopProxy, PatNLoopProxy, PatWaitProxy, PatWaitTimeProxy
from .registers import Register, Adc_register
@@ -162,12 +163,8 @@ class Detector(CppDetectorApi):
@hostname.setter
def hostname(self, hostnames):
- if isinstance(hostnames, str):
- hostnames = [hostnames]
- if isinstance(hostnames, list):
- self.setHostname(hostnames)
- else:
- raise ValueError("hostname needs to be string or list of strings")
+ args = hostname_list(hostnames)
+ self.setHostname(args)
@property
@@ -233,9 +230,10 @@ class Detector(CppDetectorApi):
@element
def hardwareversion(self):
"""
- [Jungfrau][Gotthard2][Myhten3][Gotthard][Ctb][Moench] Hardware version of detector.
+ [Jungfrau][Moench][Gotthard2][Myhten3][Gotthard][Ctb] Hardware version of detector. \n
+ [Eiger] Hardware version of front FPGA on detector.
"""
- return ut.lhex(self.getHardwareVersion())
+ return self.getHardwareVersion()
@property
@element
@@ -267,11 +265,17 @@ class Detector(CppDetectorApi):
"""Receiver version """
return self.getReceiverVersion()
+ @property
+ @element
+ def serialnumber(self):
+ """Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench] Serial number of detector """
+ return ut.lhex(self.getSerialNumber())
+
@property
@element
def rx_threads(self):
"""
- Get thread ids from the receiver in order of [parent, tcp, listener 0, processor 0, streamer 0, listener 1, processor 1, streamer 1, arping].
+ Get kernel thread ids from the receiver in order of [parent, tcp, listener 0, processor 0, streamer 0, listener 1, processor 1, streamer 1, arping].
Note
-----
@@ -302,7 +306,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][Gotthard][Ctb][Moench][Mythen3][Gotthard2] 16
+ [Jungfrau][Moench][Gotthard][Ctb][Mythen3][Gotthard2] 16
"""
return self.getDynamicRange()
@@ -360,10 +364,9 @@ class Detector(CppDetectorApi):
-----
[Eiger] Use threshold command to load settings
- [Jungfrau] GAIN0, HIGHGAIN0 \n
+ [Jungfrau][Moench] GAIN0, HIGHGAIN0 \n
[Gotthard] DYNAMICGAIN, HIGHGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN \n
[Gotthard2] DYNAMICGAIN, FIXGAIN1, FIXGAIN2 \n
- [Moench] G1_HIGHGAIN, G1_LOWGAIN, G2_HIGHCAP_HIGHGAIN, G2_HIGHCAP_LOWGAIN, G2_LOWCAP_HIGHGAIN, G2_LOWCAP_LOWGAIN, G4_HIGHGAIN, G4_LOWGAIN \n
[Eiger] settings loaded from file found in settingspath
"""
return element_if_equal(self.getSettings())
@@ -393,7 +396,7 @@ class Detector(CppDetectorApi):
@element
def framesl(self):
"""
- [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] Number of frames left in acquisition.\n
+ [Gotthard][Jungfrau][Moench][Mythen3][Gotthard2][CTB] Number of frames left in acquisition.\n
[Gotthard2] only in continuous auto mode.
:setter: Not Implemented
@@ -404,7 +407,7 @@ class Detector(CppDetectorApi):
@element
def framecounter(self):
"""
- [Jungfrau][Mythen3][Gotthard2][Moench][CTB] Number of frames from start run control.
+ [Jungfrau][Moench][Mythen3][Gotthard2][CTB] Number of frames from start run control.
Note
-----
@@ -433,12 +436,11 @@ class Detector(CppDetectorApi):
@element
def powerchip(self):
"""
- [Jungfrau][Mythen3][Gotthard2][Moench] Power the chip.
+ [Jungfrau][Moench][Mythen3][Gotthard2] Power the chip.
Note
----
- [Moench] Default is disabled. \n
- [Jungfrau] Default is disabled. Get will return power status. Can be off if temperature event occured (temperature over temp_threshold with temp_control enabled. Will configure chip (only chip v1.1).\n
+ [Jungfrau][Moench] Default is disabled. Get will return power status. Can be off if temperature event occured (temperature over temp_threshold with temp_control enabled. Will configure chip (only chip v1.1).\n
[Mythen3][Gotthard2] Default is 1. If module not connected or wrong module, powerchip will fail.
"""
return self.getPowerChip()
@@ -457,6 +459,56 @@ class Detector(CppDetectorApi):
def triggers(self, n_triggers):
self.setNumberOfTriggers(n_triggers)
+ def resetdacs(self, use_hardware_values):
+ self.resetToDefaultDacs(use_hardware_values)
+
+ def trigger(self):
+ self.sendSoftwareTrigger()
+
+ def blockingtrigger(self):
+ self.sendSoftwareTrigger(True)
+
+ @property
+ @element
+ def gaincaps(self):
+ """
+ [Mythen3] Gain caps. Enum: M3_GainCaps \n
+
+ Note
+ ----
+ Options: M3_GainCaps, M3_C15sh, M3_C30sh, M3_C50sh, M3_C225ACsh, M3_C15pre
+
+ Example
+ -------
+ >>> d.gaincaps
+ C15pre, C30sh
+ >>> d.gaincaps = M3_GainCaps.M3_C30sh
+ >>> d.gaincaps
+ C30sh
+ >>> d.gaincaps = M3_GainCaps.M3_C30sh | M3_GainCaps.M3_C15sh
+ >>> d.gaincaps
+ C15sh, C30sh
+ """
+ res = [Mythen3GainCapsWrapper(it) for it in self.getGainCaps()]
+ return res
+
+ @gaincaps.setter
+ def gaincaps(self, caps):
+ #convert to int if called with Wrapper
+ if isinstance(caps, Mythen3GainCapsWrapper):
+ self.setGainCaps(caps.value)
+ elif isinstance(caps, dict):
+ corr = {}
+ for key, value in caps.items():
+ if isinstance(value, Mythen3GainCapsWrapper):
+ corr[key] = value.value
+ else:
+ corr[key] = value
+ ut.set_using_dict(self.setGainCaps, corr)
+ else:
+ self.setGainCaps(caps)
+
+
@property
def exptime(self):
"""
@@ -466,16 +518,35 @@ class Detector(CppDetectorApi):
-----
[Mythen3] sets exposure time to all gate signals in auto and trigger mode (internal gating). To specify gateIndex, use getExptime or setExptime.
- :getter: always returns in seconds. To get in datetime.delta, use getExptime
+ :getter: always returns in seconds. To get in DurationWrapper, use getExptime
Example
-----------
+ >>> # setting directly in seconds
>>> d.exptime = 1.05
- >>> d.exptime = datetime.timedelta(minutes = 3, seconds = 1.23)
+ >>>
+ >>> # setting directly in seconds
+ >>> d.exptime = 5e-07
+ >>>
+ >>> # using timedelta (up to microseconds precision)
+ >>> from datatime import timedelta
+ >>> d.exptime = timedelta(seconds = 1, microseconds = 3)
+ >>>
+ >>> # using DurationWrapper to set in seconds
+ >>> from slsdet import DurationWrapper
+ >>> d.exptime = DurationWrapper(1.2)
+ >>>
+ >>> # using DurationWrapper to set in ns
+ >>> t = DurationWrapper()
+ >>> t.set_count(500)
+ >>> d.exptime = t
+ >>>
+ >>> # to get in seconds
>>> d.exptime
181.23
+ >>>
>>> d.getExptime()
- [datetime.timedelta(seconds=181, microseconds=230000)]
+ [sls::DurationWrapper(total_seconds: 1e-08 count: 10)]
"""
if self.type == detectorType.MYTHEN3:
res = self.getExptimeForAllGates()
@@ -485,7 +556,7 @@ class Detector(CppDetectorApi):
@exptime.setter
def exptime(self, t):
- if self.type == detectorType.MYTHEN3 and is_iterable(t):
+ if self.type == detectorType.MYTHEN3 and is_iterable(t) and not isinstance(t,dict):
for i, v in enumerate(t):
if isinstance(v, int):
v = float(v)
@@ -494,8 +565,6 @@ class Detector(CppDetectorApi):
ut.set_time_using_dict(self.setExptime, t)
-
-
@property
def period(self):
"""
@@ -503,16 +572,35 @@ class Detector(CppDetectorApi):
Note
-----
- :getter: always returns in seconds. To get in datetime.delta, use getPeriod
+ :getter: always returns in seconds. To get in DurationWrapper, use getPeriod
Example
-----------
+ >>> # setting directly in seconds
>>> d.period = 1.05
- >>> d.period = datetime.timedelta(minutes = 3, seconds = 1.23)
+ >>>
+ >>> # setting directly in seconds
+ >>> d.period = 5e-07
+ >>>
+ >>> # using timedelta (up to microseconds precision)
+ >>> from datatime import timedelta
+ >>> d.period = timedelta(seconds = 1, microseconds = 3)
+ >>>
+ >>> # using DurationWrapper to set in seconds
+ >>> from slsdet import DurationWrapper
+ >>> d.period = DurationWrapper(1.2)
+ >>>
+ >>> # using DurationWrapper to set in ns
+ >>> t = DurationWrapper()
+ >>> t.set_count(500)
+ >>> d.period = t
+ >>>
+ >>> # to get in seconds
>>> d.period
181.23
- >>> d.getPeriod()
- [datetime.timedelta(seconds=181, microseconds=230000)]
+ >>>
+ >>> d.getExptime()
+ sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)
"""
res = self.getPeriod()
return reduce_time(res)
@@ -526,13 +614,13 @@ class Detector(CppDetectorApi):
@element
def periodl(self):
"""
- [Gotthard][Jungfrau][CTB][Moench][Mythen3][Gotthard2] Period left for current frame.
+ [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] Period left for current frame.
Note
-----
[Gotthard2] only in continuous mode.
- :getter: always returns in seconds. To get in datetime.delta, use getPeriodLeft
+ :getter: always returns in seconds. To get in DurationWrapper, use getPeriodLeft
:setter: Not Implemented
Example
@@ -540,7 +628,7 @@ class Detector(CppDetectorApi):
>>> d.periodl
181.23
>>> d.getPeriodLeft()
- [datetime.timedelta(seconds=181, microseconds=230000)]
+ [sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)]
"""
return self.getPeriodLeft()
@@ -548,21 +636,40 @@ class Detector(CppDetectorApi):
@element
def delay(self):
"""
- [Gotthard][Jungfrau][CTB][Moench][Mythen3][Gotthard2] Delay after trigger, accepts either a value in seconds or datetime.timedelta
+ [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] Delay after trigger, accepts either a value in seconds, DurationWrapper or datetime.timedelta
Note
-----
- :getter: always returns in seconds. To get in datetime.delta, use getDelayAfterTrigger
+ :getter: always returns in seconds. To get in DurationWrapper, use getDelayAfterTrigger
Example
-----------
+ >>> # setting directly in seconds
>>> d.delay = 1.05
- >>> d.delay = datetime.timedelta(minutes = 3, seconds = 1.23)
+ >>>
+ >>> # setting directly in seconds
+ >>> d.delay = 5e-07
+ >>>
+ >>> # using timedelta (up to microseconds precision)
+ >>> from datatime import timedelta
+ >>> d.delay = timedelta(seconds = 1, microseconds = 3)
+ >>>
+ >>> # using DurationWrapper to set in seconds
+ >>> from slsdet import DurationWrapper
+ >>> d.delay = DurationWrapper(1.2)
+ >>>
+ >>> # using DurationWrapper to set in ns
+ >>> t = DurationWrapper()
+ >>> t.set_count(500)
+ >>> d.delay = t
+ >>>
+ >>> # to get in seconds
>>> d.delay
181.23
+ >>>
>>> d.getDelayAfterTrigger()
- [datetime.timedelta(seconds=181, microseconds=230000)]
+ sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)
"""
return ut.reduce_time(self.getDelayAfterTrigger())
@@ -574,13 +681,13 @@ class Detector(CppDetectorApi):
@element
def delayl(self):
"""
- [Gotthard][Jungfrau][CTB][Moench][Mythen3][Gotthard2] Delay left after trigger during acquisition, accepts either a value in seconds or datetime.timedelta
+ [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] Delay left after trigger during acquisition, accepts either a value in seconds, datetime.timedelta or DurationWrapper
Note
-----
[Gotthard2] only in continuous mdoe.
- :getter: always returns in seconds. To get in datetime.delta, use getDelayAfterTriggerLeft
+ :getter: always returns in seconds. To get in DurationWrapper, use getDelayAfterTriggerLeft
:setter: Not Implemented
Example
@@ -588,7 +695,7 @@ class Detector(CppDetectorApi):
>>> d.delayl
181.23
>>> d.getDelayAfterTriggerLeft()
- [datetime.timedelta(seconds=181, microseconds=230000)]
+ [sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)]
"""
return ut.reduce_time(self.getDelayAfterTriggerLeft())
@@ -596,6 +703,10 @@ class Detector(CppDetectorApi):
"""Start detector acquisition. Status changes to RUNNING or WAITING and automatically returns to idle at the end of acquisition."""
self.startDetector()
+ def clearbusy(self):
+ """If acquisition aborted during acquire command, use this to clear acquiring flag in shared memory before starting next acquisition"""
+ self.clearAcquiringFlag()
+
def rx_start(self):
"""Starts receiver listener for detector data packets and create a data file (if file write enabled)."""
self.startReceiver()
@@ -629,7 +740,7 @@ class Detector(CppDetectorApi):
@element
def txdelay(self):
"""
- [Eiger][Jungfrau][Mythen3] Set transmission delay for all modules in the detector using the step size provided.
+ [Eiger][Jungfrau][Moench][Mythen3] Set transmission delay for all modules in the detector using the step size provided.
Note
----
@@ -637,7 +748,7 @@ class Detector(CppDetectorApi):
\t\t[Eiger] txdelay_left to (2 * mod_index * n_delay), \n
\t\t[Eiger] txdelay_right to ((2 * mod_index + 1) * n_delay) and \n
\t\t[Eiger] txdelay_frame to (2 *num_modules * n_delay) \n
- \t\t[Jungfrau][Mythen3] txdelay_frame to (num_modules * n_delay)\n\n
+ \t\t[Jungfrau][Moench][Mythen3] txdelay_frame to (num_modules * n_delay)\n\n
Please refer txdelay_left, txdelay_right and txdelay_frame for details.
"""
return self.getTransmissionDelay()
@@ -650,11 +761,11 @@ class Detector(CppDetectorApi):
@element
def txdelay_frame(self):
"""
- [Eiger][Jungfrau][Mythen3] Transmission delay of first udp packet being streamed out of the module.\n
+ [Eiger][Jungfrau][Moench][Mythen3] Transmission delay of first udp packet being streamed out of the module.\n
Note
----
- [Jungfrau] [0-31] Each value represents 1 ms. \n
+ [Jungfrau][Moench] [0-31] Each value represents 1 ms. \n
[Eiger] Additional delay to txdelay_left and txdelay_right. Each value represents 10ns. Typical value is 50000. \n
[Mythen3] [0-16777215] Each value represents 8 ns (125 MHz clock), max is 134 ms.
"""
@@ -727,7 +838,8 @@ class Detector(CppDetectorApi):
@rx_hostname.setter
def rx_hostname(self, hostname):
- self.setRxHostname(hostname)
+ args = hostname_list(hostname)
+ self.setRxHostname(args)
@property
@element
@@ -836,7 +948,7 @@ class Detector(CppDetectorApi):
@property
@element
def numinterfaces(self):
- """[Jungfrau][Gotthard2] Number of udp interfaces to stream data from detector. Default is 1.
+ """[Jungfrau][Moench][Gotthard2] Number of udp interfaces to stream data from detector. Default is 1.
Note
-----
@@ -1182,11 +1294,11 @@ class Detector(CppDetectorApi):
@element
def udp_dstip2(self):
"""
- [Jungfrau][Gotthard2] Ip address of the receiver (destination) udp interface 2.
+ [Jungfrau][Moench][Gotthard2] Ip address of the receiver (destination) udp interface 2.
Note
----
- [Jungfrau] bottom half \n
+ [Jungfrau][Moench] bottom half \n
[Gotthard2] veto debugging \n
If 'auto' used, then ip is set to ip of rx_hostname. \n
To set IPs for individual modules, use setDestinationUDPIP2.
@@ -1235,13 +1347,13 @@ class Detector(CppDetectorApi):
@element
def udp_dstmac2(self):
"""
- [Jungfrau][Gotthard2] Mac address of the receiver (destination) udp interface 2.
+ [Jungfrau][Moench][Gotthard2] Mac address of the receiver (destination) udp interface 2.
Note
----
Not mandatory to set as udp_dstip2 retrieves it from slsReceiver process but must be set if you use a custom receiver (not slsReceiver). \n
To set MACs for individual modules, use setDestinationUDPMAC2. \n
- [Jungfrau] bottom half \n
+ [Jungfrau][Moench] bottom half \n
[Gotthard2] veto debugging \n
Use router mac if router between detector and receiver.
@@ -1286,11 +1398,11 @@ class Detector(CppDetectorApi):
@element
def udp_srcmac2(self):
"""
- [Jungfrau][Gotthard2] Mac address of the receiver (source) udp interface 2.
+ [Jungfrau][Moench][Gotthard2] Mac address of the receiver (source) udp interface 2.
Note
----
- [Jungfrau] bottom half \n
+ [Jungfrau][Moench] bottom half \n
[Gotthard2] veto debugging \n
To set MACs for individual modules, use setSourceUDPMAC2.
@@ -1336,11 +1448,11 @@ class Detector(CppDetectorApi):
@element
def udp_srcip2(self):
"""
- [Jungfrau][Gotthard2] Ip address of the detector (source) udp interface 2.
+ [Jungfrau][Moench][Gotthard2] Ip address of the detector (source) udp interface 2.
Note
-----
- [Jungfrau] bottom half \n
+ [Jungfrau][Moench] bottom half \n
[Gotthard2] veto debugging \n
Must be same subnet as destination udp ip2.\n
To set IPs for individual modules, use setSourceUDPIP2.
@@ -1386,7 +1498,7 @@ class Detector(CppDetectorApi):
----
Default is 50002. \n
[Eiger] right half \n
- [Jungfrau] bottom half \n
+ [Jungfrau][Moench] bottom half \n
[Gotthard2] veto debugging \n
Ports for each module is calculated (incremented by 2) \n
To set ports for individual modules, use setDestinationUDPPort2.
@@ -1406,7 +1518,7 @@ class Detector(CppDetectorApi):
-----
[Gotthard] 0, 90, 110, 120, 150, 180, 200 \n
[Eiger][Mythen3][Gotthard2] 0 - 200 \n
- [Jungfrau][Ctb][Moench] 0, 60 - 200
+ [Jungfrau][Moench][Ctb] 0, 60 - 200
"""
return self.getHighVoltage()
@@ -1511,12 +1623,26 @@ class Detector(CppDetectorApi):
def trimval(self, value):
ut.set_using_dict(self.setAllTrimbits, value)
+ @property
+ @element
+ def fliprows(self):
+ """
+ [Eiger] flips rows paramater sent to slsreceiver to stream as json parameter to flip rows in gui. \n
+ [Jungfrau] flips rows in the detector itself. For bottom module and number of interfaces must be set to 2. slsReceiver and slsDetectorGui does not handle.
+ """
+ return self.getFlipRows()
+
+ @fliprows.setter
+ def fliprows(self, value):
+ ut.set_using_dict(self.setFlipRows, value)
+
+
@property
@element
def master(self):
"""
- [Eiger][Gotthard2][Jungfrau] Sets (half) module to master and other(s) to slaves.\n
- [Gotthard][Gotthard2][Mythen3][Eiger][Jungfrau] Gets if the current (half) module is master.
+ [Eiger][Gotthard2][Jungfrau][Moench] Sets (half) module to master and other(s) to slaves.\n
+ [Gotthard][Gotthard2][Mythen3][Eiger][Jungfrau][Moench] Gets if the current (half) module is master.
"""
return self.getMaster()
@@ -1528,7 +1654,7 @@ class Detector(CppDetectorApi):
@element
def sync(self):
"""
- [Jungfrau] Enables or disables synchronization between modules.
+ [Jungfrau][Moench] Enables or disables synchronization between modules.
"""
return self.getSynchronization()
@@ -1536,6 +1662,19 @@ class Detector(CppDetectorApi):
def sync(self, value):
ut.set_using_dict(self.setSynchronization, value)
+ @property
+ @element
+ def badchannels(self):
+ """
+ [fname|none|0]\n\t[Gotthard2][Mythen3] Sets the bad channels (from file of bad channel numbers) to be masked out. None or 0 unsets all the badchannels.\n
+ [Mythen3] Also does trimming
+ """
+ return self.getBadChannels()
+
+ @badchannels.setter
+ def badchannels(self, value):
+ ut.set_using_dict(self.setBadChannels, value)
+
@property
@element
def lock(self):
@@ -1644,6 +1783,11 @@ class Detector(CppDetectorApi):
"""Gets the list of timing modes (timingMode) for this detector."""
return self.getTimingModeList()
+ @property
+ def readoutspeedlist(self):
+ """List of readout speed levels implemented for this detector."""
+ return self.getReadoutSpeedList()
+
@property
def templist(self):
"""List of temperature enums (dacIndex) implemented for this detector."""
@@ -1664,7 +1808,7 @@ class Detector(CppDetectorApi):
@property
def adcreg(self):
- """[Jungfrau][Ctb][Moench][Gotthard] Writes to an adc register
+ """[Jungfrau][Moench][Ctb][Gotthard] Writes to an adc register
Note
-----
@@ -1677,7 +1821,7 @@ class Detector(CppDetectorApi):
@property
@element
def adcinvert(self):
- """[Ctb][Moench][Jungfrau] ADC Inversion Mask.
+ """[Ctb][Jungfrau][Moench] ADC Inversion Mask.
Note
-----
@@ -1693,7 +1837,7 @@ class Detector(CppDetectorApi):
@element
def triggersl(self):
"""
- [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] Number of triggers left in acquisition.\n
+ [Gotthard][Jungfrau][Moench][Mythen3][Gotthard2][CTB] Number of triggers left in acquisition.\n
Note
----
@@ -1706,7 +1850,7 @@ class Detector(CppDetectorApi):
@property
@element
def frametime(self):
- """[Jungfrau][Mythen3][Gotthard2][Moench][CTB] Timestamp at a frame start.
+ """[Jungfrau][Moench][Mythen3][Gotthard2][CTB] Timestamp at a frame start.
Note
----
@@ -1745,14 +1889,25 @@ class Detector(CppDetectorApi):
@property
def versions(self):
- return {'type': self.type,
+ version_list = {'type': self.type,
'package': self.packageversion,
- 'client': self.clientversion,
- 'firmware': self.firmwareversion,
- 'detectorserver': self.detectorserverversion,
- 'hardware':self.hardwareversion,
- 'kernel': self.kernelversion,
- 'receiver': self.rx_version}
+ 'client': self.clientversion}
+
+ if self.type == detectorType.EIGER:
+ version_list ['firmware (Beb)'] = self.firmwareversion
+ version_list ['firmware(Febl)'] = self.getFrontEndFirmwareVersion(slsDetectorDefs.fpgaPosition.FRONT_LEFT)
+ version_list ['firmware (Febr)'] = self.getFrontEndFirmwareVersion(slsDetectorDefs.fpgaPosition.FRONT_RIGHT)
+ else:
+ version_list ['firmware'] = self.firmwareversion
+
+ version_list ['detectorserver'] = self.detectorserverversion
+ version_list ['kernel'] = self.kernelversion
+ version_list ['hardware'] = self.hardwareversion
+
+ if self.use_receiver:
+ version_list ['receiver'] = self.rx_version
+
+ return version_list
@property
def virtual(self):
@@ -1819,10 +1974,10 @@ class Detector(CppDetectorApi):
Note
-----
- [Jungfrau] FULL_SPEED, HALF_SPEED (Default), QUARTER_SPEED
+ [Jungfrau][Moench] FULL_SPEED, HALF_SPEED (Default), QUARTER_SPEED
[Eiger] FULL_SPEED (Default), HALF_SPEED, QUARTER_SPEED
[Gottthard2] G2_108MHZ (Default), G2_144MHZ
- [Jungfrau] FULL_SPEED option only available from v2.0 boards and is recommended to set number of interfaces to 2. \n
+ [Jungfrau][Moench] FULL_SPEED option only available from v2.0 boards and is recommended to set number of interfaces to 2. \n
Also overwrites adcphase to recommended default.
"""
return element_if_equal(self.getReadoutSpeed())
@@ -1908,7 +2063,7 @@ class Detector(CppDetectorApi):
Note
-----
Default: AUTO_TIMING \n
- [Jungfrau][Gotthard][Ctb][Moench][Gotthard2] AUTO_TIMING, TRIGGER_EXPOSURE \n
+ [Jungfrau][Moench][Gotthard][Ctb][Gotthard2] AUTO_TIMING, TRIGGER_EXPOSURE \n
[Mythen3] AUTO_TIMING, TRIGGER_EXPOSURE, GATED, TRIGGER_GATED \n
[Eiger] AUTO_TIMING, TRIGGER_EXPOSURE, GATED, BURST_TRIGGER
"""
@@ -2025,16 +2180,35 @@ class Detector(CppDetectorApi):
----
Subperiod = subexptime + subdeadtime.
- :getter: always returns in seconds. To get in datetime.delta, use getSubExptime
+ :getter: always returns in seconds. To get in DurationWrapper, use getSubExptime
Example
-----------
+ >>> # setting directly in seconds
>>> d.subexptime = 1.230203
- >>> d.subexptime = datetime.timedelta(seconds = 1.23, microseconds = 203)
+ >>>
+ >>> # setting directly in seconds
+ >>> d.subexptime = 5e-07
+ >>>
+ >>> # using timedelta (up to microseconds precision)
+ >>> from datatime import timedelta
+ >>> d.subexptime = timedelta(seconds = 1.23, microseconds = 203)
+ >>>
+ >>> # using DurationWrapper to set in seconds
+ >>> from slsdet import DurationWrapper
+ >>> d.subexptime = DurationWrapper(1.2)
+ >>>
+ >>> # using DurationWrapper to set in ns
+ >>> t = DurationWrapper()
+ >>> t.set_count(500)
+ >>> d.subexptime = t
+ >>>
+ >>> # to get in seconds
>>> d.subexptime
- 1.230203
+ 181.23
+ >>>
>>> d.getSubExptime()
- [datetime.timedelta(seconds = 1, microseconds = 203)]
+ sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)
"""
res = self.getSubExptime()
return reduce_time(res)
@@ -2048,13 +2222,13 @@ class Detector(CppDetectorApi):
def readnrows(self):
"""
[Eiger] Number of rows to read out per half module starting from the centre.
- [Jungfrau] Number of rows to read per module starting from the centre.
+ [Jungfrau][Moench] Number of rows to read per module starting from the centre.
Note
----
[Eiger] Options: 1 - 256. 256 is default. \n
[Eiger]The permissible values depend on dynamic range and 10Gbe enabled.\n\n
- [Jungfrau] Options: 8 - 512 (multiples of 8)
+ [Jungfrau][Moench] Options: 8 - 512 (multiples of 8)
"""
return self.getReadNRows()
@@ -2066,22 +2240,41 @@ class Detector(CppDetectorApi):
@property
def subdeadtime(self):
"""
- [Eiger] Dead time of EIGER subframes in 32 bit mode, accepts either a value in seconds or datetime.timedelta
+ [Eiger] Dead time of EIGER subframes in 32 bit mode, accepts either a value in seconds, datetime.timedelta or DurationWrapper
Note
----
Subperiod = subexptime + subdeadtime.
- :getter: always returns in seconds. To get in datetime.delta, use getSubDeadTime
+ :getter: always returns in seconds. To get in DurationWrapper, use getSubDeadTime
Example
-----------
+ >>> # setting directly in seconds
>>> d.subdeadtime = 1.230203
- >>> d.subdeadtime = datetime.timedelta(seconds = 1.23, microseconds = 203)
+ >>>
+ >>> # setting directly in seconds
+ >>> d.subdeadtime = 5e-07
+ >>>
+ >>> # using timedelta (up to microseconds precision)
+ >>> from datatime import timedelta
+ >>> d.subdeadtime = timedelta(seconds = 1.23, microseconds = 203)
+ >>>
+ >>> # using DurationWrapper to set in seconds
+ >>> from slsdet import DurationWrapper
+ >>> d.subdeadtime = DurationWrapper(1.2)
+ >>>
+ >>> # using DurationWrapper to set in ns
+ >>> t = DurationWrapper()
+ >>> t.set_count(500)
+ >>> d.subdeadtime = t
+ >>>
+ >>> # to get in seconds
>>> d.subdeadtime
- 1.230203
+ 181.23
+ >>>
>>> d.getSubDeadTime()
- [datetime.timedelta(seconds = 1, microseconds = 203)]
+ sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)
"""
res = self.getSubDeadTime()
return reduce_time(res)
@@ -2126,7 +2319,7 @@ class Detector(CppDetectorApi):
@property
@element
def tengiga(self):
- """[Eiger][Ctb][Moench][Mythen3] 10GbE Enable."""
+ """[Eiger][Ctb][Mythen3] 10GbE Enable."""
return self.getTenGiga()
@tengiga.setter
@@ -2146,7 +2339,7 @@ class Detector(CppDetectorApi):
@property
@element
def flowcontrol10g(self):
- """[Eiger][Jungfrau] Enable or disable 10GbE Flow Control."""
+ """[Eiger][Jungfrau][Moench] Enable or disable 10GbE Flow Control."""
return self.getTenGigaFlowControl()
@flowcontrol10g.setter
@@ -2166,7 +2359,7 @@ class Detector(CppDetectorApi):
@property
@element
def gappixels(self):
- """[Eiger][Jungfrau] Include Gap pixels in client data call back in Detecor api. Will not be in detector streaming, receiver file or streaming. Default is disabled. """
+ """[Eiger][Jungfrau][Moench] Include Gap pixels in client data call back in Detecor api. Will not be in detector streaming, receiver file or streaming. Default is disabled. """
return self.getRxAddGapPixels()
@gappixels.setter
@@ -2222,7 +2415,7 @@ class Detector(CppDetectorApi):
@element
def chipversion(self):
"""
- [Jungfrau] Chip version of module. Can be 1.0 or 1.1.
+ [Jungfrau][Moench] Chip version of module. Can be 1.0 or 1.1.
Example
-------
@@ -2235,7 +2428,7 @@ class Detector(CppDetectorApi):
@property
@element
def autocompdisable(self):
- """[Jungfrau] Enable or disable auto comparator disable mode.
+ """[Jungfrau][Moench] Enable or disable auto comparator disable mode.
Note
-----
@@ -2251,22 +2444,41 @@ class Detector(CppDetectorApi):
@property
@element
def compdisabletime(self):
- """[Jungfrau] Time before end of exposure when comparator is disabled.
+ """[Jungfrau][Moench] Time before end of exposure when comparator is disabled.
Note
-----
It is only possible for chipv1.1.
- :getter: always returns in seconds. To get in datetime.delta, use getComparatorDisableTime
+ :getter: always returns in seconds. To get in DurationWrapper, use getComparatorDisableTime
Example
-----------
+ >>> # setting directly in seconds
>>> d.compdisabletime = 1.05
- >>> d.compdisabletime = datetime.timedelta(minutes = 3, seconds = 1.23)
+ >>>
+ >>> # setting directly in seconds
+ >>> d.compdisabletime = 5e-07
+ >>>
+ >>> # using timedelta (up to microseconds precision)
+ >>> from datatime import timedelta
+ >>> d.compdisabletime = timedelta(seconds = 1, microseconds = 3)
+ >>>
+ >>> # using DurationWrapper to set in seconds
+ >>> from slsdet import DurationWrapper
+ >>> d.compdisabletime = DurationWrapper(1.2)
+ >>>
+ >>> # using DurationWrapper to set in ns
+ >>> t = DurationWrapper()
+ >>> t.set_count(500)
+ >>> d.compdisabletime = t
+ >>>
+ >>> # to get in seconds
>>> d.compdisabletime
181.23
+ >>>
>>> d.getComparatorDisableTime()
- [datetime.timedelta(seconds=181, microseconds=230000)]
+ sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)
"""
return ut.reduce_time(self.getComparatorDisableTime())
@@ -2278,7 +2490,7 @@ class Detector(CppDetectorApi):
@property
@element
def runtime(self):
- """[Jungfrau][Mythen3][Gotthard2][Moench][CTB] Time from detector start up.
+ """[Jungfrau][Moench][Mythen3][Gotthard2][CTB] Time from detector start up.
Note
-----
@@ -2324,23 +2536,42 @@ class Detector(CppDetectorApi):
@property
def storagecell_delay(self):
"""
- [Jungfrau] Additional time delay between 2 consecutive exposures in burst mode, accepts either a value in seconds or datetime.timedelta
+ [Jungfrau] Additional time delay between 2 consecutive exposures in burst mode, accepts either a value in seconds, datetime.timedelta or DurationWrapper
Note
-----
Only applicable for chipv1.0. For advanced users only \n
Value: 0-1638375 ns (resolution of 25ns)
- :getter: always returns in seconds. To get in datetime.delta, use getStorageCellDelay
+ :getter: always returns in seconds. To get in DurationWrapper, use getStorageCellDelay
Example
-----------
- >>> d.storagecell_delay = 0.00056
- >>> d.storagecell_delay = datetime.timedelta(microseconds = 45)
+ >>> # setting directly in seconds
+ >>> d.storagecell_delay = 1.05
+ >>>
+ >>> # setting directly in seconds
+ >>> d.storagecell_delay = 5e-07
+ >>>
+ >>> # using timedelta (up to microseconds precision)
+ >>> from datatime import timedelta
+ >>> d.storagecell_delay = timedelta(seconds = 1, microseconds = 3)
+ >>>
+ >>> # using DurationWrapper to set in seconds
+ >>> from slsdet import DurationWrapper
+ >>> d.storagecell_delay = DurationWrapper(1.2)
+ >>>
+ >>> # using DurationWrapper to set in ns
+ >>> t = DurationWrapper()
+ >>> t.set_count(500)
+ >>> d.storagecell_delay = t
+ >>>
+ >>> # to get in seconds
>>> d.storagecell_delay
- 4.5e-05
+ 181.23
+ >>>
>>> d.getStorageCellDelay()
- [datetime.timedelta(microseconds=45)]
+ sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)
"""
return ut.reduce_time(self.getStorageCellDelay())
@@ -2352,7 +2583,7 @@ class Detector(CppDetectorApi):
@element
def temp_threshold(self):
"""
- [Jungfrau] Threshold temperature in degrees.
+ [Jungfrau][Moench] Threshold temperature in degrees.
Note
-----
@@ -2369,7 +2600,7 @@ class Detector(CppDetectorApi):
@element
def temp_event(self):
"""
- [Jungfrau] 1, if a temperature event occured. \n
+ [Jungfrau][Moench] 1, if a temperature event occured. \n
Note
----
@@ -2397,7 +2628,7 @@ class Detector(CppDetectorApi):
@element
def temp_control(self):
"""
- [Jungfrau] Temperature control enable.
+ [Jungfrau][Moench] Temperature control enable.
Note
-----
@@ -2414,7 +2645,7 @@ class Detector(CppDetectorApi):
@property
@element
def selinterface(self):
- """[Jungfrau] The udp interface to stream data from detector.
+ """[Jungfrau][Moench] The udp interface to stream data from detector.
Note
-----
@@ -2434,11 +2665,11 @@ class Detector(CppDetectorApi):
@property
def gainmode(self):
"""
- [Jungfrau] Detector gain mode. Enum: gainMode
+ [Jungfrau][Moench] Detector gain mode. Enum: gainMode
Note
-----
- [Jungfrau] DYNAMIC, FORCE_SWITCH_G1, FORCE_SWITCH_G2, FIX_G1, FIX_G2, FIX_G0 \n
+ [Jungfrau][Moench] DYNAMIC, FORCE_SWITCH_G1, FORCE_SWITCH_G2, FIX_G1, FIX_G2, FIX_G0 \n
CAUTION: Do not use FIX_G0 without caution, you can damage the detector!!!
"""
return element_if_equal(self.getGainMode())
@@ -2493,14 +2724,14 @@ class Detector(CppDetectorApi):
@element
def filterresistor(self):
"""
- [Gotthard2][Jungfrau] Set filter resistor. Increasing values for increasing "
+ [Gotthard2][Jungfrau][Moench] Set filter resistor. Increasing values for increasing "
"resistance.
Note
----
Advanced user command.
[Gotthard2] Default is 0. Options: 0-3.
- [Jungfrau] Default is 1. Options: 0-1.
+ [Jungfrau][Moench] Default is 1. Options: 0-1.
"""
return self.getFilterResistor()
@@ -2512,11 +2743,11 @@ class Detector(CppDetectorApi):
@element
def filtercells(self):
"""
- [Jungfrau] Set filter capacitor.
+ [Jungfrau][Moench] Set filter capacitor.
Note
----
- [Jungfrau] Options: 0-12. Default: 0. Advanced user command. Only for chipv1.1.
+ [Jungfrau][Moench] Options: 0-12. Default: 0. Advanced user command. Only for chipv1.1.
"""
return self.getNumberOfFilterCells()
@@ -2614,18 +2845,36 @@ class Detector(CppDetectorApi):
Note
-----
- :getter: always returns in seconds. To get in datetime.delta, use getBurstPeriod
+ :getter: always returns in seconds. To get in DurationWrapper, use getBurstPeriod
:setter: Not Implemented
Example
-----------
+ >>> # setting directly in seconds
>>> d.burstperiod = 1.05
- >>> d.burstperiod = datetime.timedelta(minutes = 3, seconds = 1.23)
+ >>>
+ >>> # setting directly in seconds
+ >>> d.burstperiod = 5e-07
+ >>>
+ >>> # using timedelta (up to microseconds precision)
+ >>> from datatime import timedelta
+ >>> d.burstperiod = timedelta(seconds = 1, microseconds = 3)
+ >>>
+ >>> # using DurationWrapper to set in seconds
+ >>> from slsdet import DurationWrapper
+ >>> d.burstperiod = DurationWrapper(1.2)
+ >>>
+ >>> # using DurationWrapper to set in ns
+ >>> t = DurationWrapper()
+ >>> t.set_count(500)
+ >>> d.burstperiod = t
+ >>>
+ >>> # to get in seconds
>>> d.burstperiod
181.23
+ >>>
>>> d.getBurstPeriod()
- [datetime.timedelta(seconds=181, microseconds=230000)]
-
+ sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)
"""
return ut.reduce_time(self.getBurstPeriod())
@@ -2750,25 +2999,41 @@ class Detector(CppDetectorApi):
@property
def gatedelay(self):
"""
- [Mythen3] Gate Delay of all gate signals in auto and trigger mode (internal gating), accepts either a value in seconds or datetime.timedelta
+ [Mythen3] Gate Delay of all gate signals in auto and trigger mode (internal gating), accepts either a value in seconds, datetime.timedelta or DurationWrapper
Note
-----
To specify gateIndex, use getGateDelay or setGateDelay.
- :getter: always returns in seconds. To get in datetime.delta, use getGateDelayForAllGates or getGateDelay(gateIndex)
+ :getter: always returns in seconds. To get in DurationWrapper, use getGateDelayForAllGates or getGateDelay(gateIndex)
Example
-----------
+ >>> # setting directly in seconds
>>> d.gatedelay = 1.05
- >>> d.gatedelay = datetime.timedelta(minutes = 3, seconds = 1.23)
+ >>>
+ >>> # setting directly in seconds
+ >>> d.gatedelay = 5e-07
+ >>>
+ >>> # using timedelta (up to microseconds precision)
+ >>> from datatime import timedelta
+ >>> d.gatedelay = timedelta(seconds = 1, microseconds = 3)
+ >>>
+ >>> # using DurationWrapper to set in seconds
+ >>> from slsdet import DurationWrapper
+ >>> d.gatedelay = DurationWrapper(1.2)
+ >>>
+ >>> # using DurationWrapper to set in ns
+ >>> t = DurationWrapper()
+ >>> t.set_count(500)
+ >>> d.gatedelay = t
+ >>>
+ >>> # to get in seconds
>>> d.gatedelay
181.23
- >>> d.setGateDelay(1, datetime.timedelta(seconds = 2))
- >>> d.gatedelay
- >>> [1.0, 2.0, 1.0]
+ >>>
>>> d.getExptimeForAllGates()
- >>> [[datetime.timedelta(seconds=181, microseconds=230000), datetime.timedelta(seconds=181, microseconds=230000), datetime.timedelta(seconds=181, microseconds=230000)]]
+ sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)
"""
return reduce_time(self.getGateDelayForAllGates())
@@ -2818,7 +3083,7 @@ class Detector(CppDetectorApi):
@property
@element
def adcenable(self):
- """[Ctb][Moench] ADC Enable Mask for 1Gb. Enable for each 32 ADC channel."""
+ """[Ctb] ADC Enable Mask for 1Gb. Enable for each 32 ADC channel."""
return self.getADCEnableMask()
@adcenable.setter
@@ -2828,7 +3093,7 @@ class Detector(CppDetectorApi):
@property
@element
def adcenable10g(self):
- """[Ctb][Moench] ADC Enable Mask for 10Gb mode for each 32 ADC channel.
+ """[Ctb] ADC Enable Mask for 10Gb mode for each 32 ADC channel.
Note
-----
@@ -2845,7 +3110,6 @@ class Detector(CppDetectorApi):
def samples(self):
"""
[CTB] Number of samples (both analog and digitial) expected. \n
- [Moench] Number of samples (analog only)
"""
return self.getNumberOfAnalogSamples()
@@ -2856,7 +3120,7 @@ class Detector(CppDetectorApi):
@property
@element
def runclk(self):
- """[Ctb][Moench] Run clock in MHz."""
+ """[Ctb] Run clock in MHz."""
return self.getRUNClock()
@runclk.setter
@@ -2889,7 +3153,7 @@ class Detector(CppDetectorApi):
@property
@element
def asamples(self):
- """[Ctb][Moench] Number of analog samples expected. """
+ """[Ctb] Number of analog samples expected. """
return element_if_equal(self.getNumberOfAnalogSamples())
@asamples.setter
@@ -2909,7 +3173,7 @@ class Detector(CppDetectorApi):
@property
@element
def dbitphase(self):
- """[Ctb][Jungfrau] Phase shift of clock to latch digital bits. Absolute phase shift.
+ """[Ctb][Jungfrau][Moench] Phase shift of clock to latch digital bits. Absolute phase shift.
Note
-----
@@ -2931,6 +3195,17 @@ class Detector(CppDetectorApi):
def dbitclk(self, value):
ut.set_using_dict(self.setDBITClock, value)
+ @property
+ @element
+ def adcvpp(self):
+ """[Ctb][Moench] Vpp of ADC. [0 -> 1V | 1 -> 1.14V | 2 -> 1.33V | 3 -> 1.6V | 4 -> 2V] \n
+ Advanced User function!"""
+ return self.getADCVpp(False)
+
+ @adcvpp.setter
+ def adcvpp(self, value):
+ ut.set_using_dict(self.setADCVpp, value, False)
+
@property
@element
def dbitpipeline(self):
@@ -2950,7 +3225,7 @@ class Detector(CppDetectorApi):
@property
@element
def maxdbitphaseshift(self):
- """[CTB][Jungfrau] Absolute maximum Phase shift of of the clock to latch digital bits.
+ """[CTB][Jungfrau][Moench] Absolute maximum Phase shift of of the clock to latch digital bits.
Note
-----
@@ -2997,7 +3272,7 @@ class Detector(CppDetectorApi):
@property
@element
def maxadcphaseshift(self):
- """[Jungfrau][CTB][Moench] Absolute maximum Phase shift of ADC clock.
+ """[Jungfrau][Moench][CTB] Absolute maximum Phase shift of ADC clock.
Note
-----
@@ -3009,12 +3284,12 @@ class Detector(CppDetectorApi):
@property
@element
def adcphase(self):
- """[Gotthard][Jungfrau][CTB][Moench] Sets phase shift of ADC clock.
+ """[Gotthard][Jungfrau][Moench][CTB] Sets phase shift of ADC clock.
Note
-----
- [Jungfrau] Absolute phase shift. Changing Speed also resets adcphase to recommended defaults.\n
- [Ctb][Moench] Absolute phase shift. Changing adcclk also resets adcphase and sets it to previous values.\n
+ [Jungfrau][Moench] Absolute phase shift. Changing Speed also resets adcphase to recommended defaults.\n
+ [Ctb] Absolute phase shift. Changing adcclk also resets adcphase and sets it to previous values.\n
[Gotthard] Relative phase shift.
:getter: Not implemented for Gotthard
@@ -3028,7 +3303,7 @@ class Detector(CppDetectorApi):
@property
@element
def adcpipeline(self):
- """[Ctb][Moench] Sets pipeline for ADC clock. """
+ """[Ctb] Sets pipeline for ADC clock. """
return self.getADCPipeline()
@adcpipeline.setter
@@ -3038,7 +3313,7 @@ class Detector(CppDetectorApi):
@property
@element
def adcclk(self):
- """[Ctb][Moench] Sets ADC clock frequency in MHz. """
+ """[Ctb] Sets ADC clock frequency in MHz. """
return self.getADCClock()
@adcclk.setter
@@ -3049,7 +3324,7 @@ class Detector(CppDetectorApi):
@element
def syncclk(self):
"""
- [Ctb][Moench] Sync clock in MHz.
+ [Ctb] Sync clock in MHz.
Note
-----
@@ -3060,7 +3335,7 @@ class Detector(CppDetectorApi):
@property
def pattern(self):
- """[Mythen3][Moench][Ctb] Loads ASCII pattern file directly to server (instead of executing line by line).
+ """[Mythen3][Ctb] Loads ASCII pattern file directly to server (instead of executing line by line).
Note
----
@@ -3082,7 +3357,7 @@ class Detector(CppDetectorApi):
@property
@element
def patioctrl(self):
- """[Ctb][Moench] 64 bit mask defining input (0) and output (1) signals.
+ """[Ctb] 64 bit mask defining input (0) and output (1) signals.
Example
--------
@@ -3099,7 +3374,7 @@ class Detector(CppDetectorApi):
@property
@element
def patlimits(self):
- """[Ctb][Moench][Mythen3] Limits (start and stop address) of complete pattern.
+ """[Ctb][Mythen3] Limits (start and stop address) of complete pattern.
Example
---------
@@ -3119,7 +3394,7 @@ class Detector(CppDetectorApi):
@property
@element
def patsetbit(self):
- """[Ctb][Moench][Mythen3] Sets the mask applied to every pattern to the selected bits.
+ """[Ctb][Mythen3] Sets the mask applied to every pattern to the selected bits.
Example
--------
@@ -3136,7 +3411,7 @@ class Detector(CppDetectorApi):
@property
@element
def patmask(self):
- """[Ctb][Moench][Mythen3] Selects the bits that will have a pattern mask applied to the selected patmask for every pattern.
+ """[Ctb][Mythen3] Selects the bits that will have a pattern mask applied to the selected patmask for every pattern.
Example
--------
@@ -3154,7 +3429,7 @@ class Detector(CppDetectorApi):
# @element
def patwait(self):
"""
- [Ctb][Moench][Mythen3] Wait address of loop level provided.
+ [Ctb][Mythen3] Wait address of loop level provided.
Example
-------
@@ -3171,7 +3446,7 @@ class Detector(CppDetectorApi):
@property
@element
def patwait0(self):
- """[Ctb][Moench][Mythen3] Wait 0 address.
+ """[Ctb][Mythen3] Wait 0 address.
Example
--------
@@ -3191,7 +3466,7 @@ class Detector(CppDetectorApi):
@property
@element
def patwait1(self):
- """[Ctb][Moench][Mythen3] Wait 1 address.
+ """[Ctb][Mythen3] Wait 1 address.
Example
--------
@@ -3211,7 +3486,7 @@ class Detector(CppDetectorApi):
@property
@element
def patwait2(self):
- """[Ctb][Moench][Mythen3] Wait 2 address.
+ """[Ctb][Mythen3] Wait 2 address.
Example
--------
@@ -3231,7 +3506,7 @@ class Detector(CppDetectorApi):
@property
def patwaittime(self):
"""
- [Ctb][Moench][Mythen3] Wait time in clock cycles of loop level provided.
+ [Ctb][Mythen3] Wait time in clock cycles of loop level provided.
Example
-------
@@ -3248,7 +3523,7 @@ class Detector(CppDetectorApi):
@property
@element
def patwaittime0(self):
- """[Ctb][Moench][Mythen3] Wait 0 time in clock cycles."""
+ """[Ctb][Mythen3] Wait 0 time in clock cycles."""
return self.getPatternWaitTime(0)
@patwaittime0.setter
@@ -3259,7 +3534,7 @@ class Detector(CppDetectorApi):
@property
@element
def patwaittime1(self):
- """[Ctb][Moench][Mythen3] Wait 1 time in clock cycles."""
+ """[Ctb][Mythen3] Wait 1 time in clock cycles."""
return self.getPatternWaitTime(1)
@patwaittime1.setter
@@ -3270,7 +3545,7 @@ class Detector(CppDetectorApi):
@property
@element
def patwaittime2(self):
- """[Ctb][Moench][Mythen3] Wait 2 time in clock cycles."""
+ """[Ctb][Mythen3] Wait 2 time in clock cycles."""
return self.getPatternWaitTime(2)
@patwaittime2.setter
@@ -3282,7 +3557,7 @@ class Detector(CppDetectorApi):
@property
def patloop(self):
"""
- [Ctb][Moench][Mythen3] Limits (start and stop address) of the loop provided.
+ [Ctb][Mythen3] Limits (start and stop address) of the loop provided.
Example
-------
@@ -3299,7 +3574,7 @@ class Detector(CppDetectorApi):
@property
@element
def patloop0(self):
- """[Ctb][Moench][Mythen3] Limits (start and stop address) of loop 0.
+ """[Ctb][Mythen3] Limits (start and stop address) of loop 0.
Example
---------
@@ -3319,7 +3594,7 @@ class Detector(CppDetectorApi):
@property
@element
def patloop1(self):
- """[Ctb][Moench][Mythen3] Limits (start and stop address) of loop 1.
+ """[Ctb][Mythen3] Limits (start and stop address) of loop 1.
Example
---------
@@ -3340,7 +3615,7 @@ class Detector(CppDetectorApi):
@property
@element
def patloop2(self):
- """[Ctb][Moench][Mythen3] Limits (start and stop address) of loop 2.
+ """[Ctb][Mythen3] Limits (start and stop address) of loop 2.
Example
---------
@@ -3362,7 +3637,7 @@ class Detector(CppDetectorApi):
@property
def patnloop(self):
"""
- [Ctb][Moench][Mythen3] Number of cycles of the loop provided.
+ [Ctb][Mythen3] Number of cycles of the loop provided.
Example
-------
@@ -3379,7 +3654,7 @@ class Detector(CppDetectorApi):
@property
@element
def patnloop0(self):
- """[Ctb][Moench][Mythen3] Number of cycles of loop 0."""
+ """[Ctb][Mythen3] Number of cycles of loop 0."""
return self.getPatternLoopCycles(0)
@patnloop0.setter
@@ -3390,7 +3665,7 @@ class Detector(CppDetectorApi):
@property
@element
def patnloop1(self):
- """[Ctb][Moench][Mythen3] Number of cycles of loop 1."""
+ """[Ctb][Mythen3] Number of cycles of loop 1."""
return self.getPatternLoopCycles(1)
@patnloop1.setter
@@ -3401,7 +3676,7 @@ class Detector(CppDetectorApi):
@property
@element
def patnloop2(self):
- """[Ctb][Moench][Mythen3] Number of cycles of loop 2."""
+ """[Ctb][Mythen3] Number of cycles of loop 2."""
return self.getPatternLoopCycles(2)
@patnloop2.setter
@@ -3472,7 +3747,7 @@ class Detector(CppDetectorApi):
@property
@element
def v_limit(self):
- """[Ctb][Moench] Soft limit for power supplies (ctb only) and DACS in mV."""
+ """[Ctb] Soft limit for power supplies (ctb only) and DACS in mV."""
return self.getDAC(dacIndex.V_LIMIT, True)
@v_limit.setter
@@ -3541,6 +3816,23 @@ class Detector(CppDetectorApi):
"""
return self.getMeasuredCurrent(dacIndex.I_POWER_IO)
+ @property
+ def clkphase(self):
+ """
+ [Gotthard2][Mythen3] Phase shift of all clocks.
+
+ Example
+ -------
+ >>> d.clkphase[0] = 20
+ >>> d.clkphase
+ 0: 20
+ 1: 10
+ 2: 20
+ 3: 10
+ 4: 10
+ 5: 5
+ """
+ return ClkPhaseProxy(self)
@property
def clkdiv(self):
@@ -3572,7 +3864,7 @@ class Detector(CppDetectorApi):
Note
-----
- :getter: always returns in seconds. To get in datetime.delta, use getExptimeLeft
+ :getter: always returns in seconds. To get in DurationWrapper, use getExptimeLeft
:setter: Not Implemented
Example
@@ -3580,7 +3872,7 @@ class Detector(CppDetectorApi):
>>> d.exptimel
181.23
>>> d.getExptimeLeft()
- [datetime.timedelta(seconds=181, microseconds=230000)]
+ [sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)]
"""
t = self.getExptimeLeft()
return reduce_time(t)
diff --git a/python/slsdet/gaincaps.py b/python/slsdet/gaincaps.py
new file mode 100644
index 000000000..ab3acd381
--- /dev/null
+++ b/python/slsdet/gaincaps.py
@@ -0,0 +1,42 @@
+
+
+import _slsdet
+gc = _slsdet.slsDetectorDefs.M3_GainCaps
+
+
+class Mythen3GainCapsWrapper:
+ """Holds M3_GainCaps enums and facilitates printing"""
+ # 'M3_C10pre', 'M3_C15pre', 'M3_C15sh', 'M3_C225ACsh', 'M3_C30sh', 'M3_C50sh'
+ all_bits = gc.M3_C10pre | gc.M3_C15pre | gc.M3_C15sh | gc.M3_C225ACsh | gc.M3_C30sh | gc.M3_C50sh
+ all_caps = (gc.M3_C10pre, gc.M3_C15pre, gc.M3_C15sh, gc.M3_C225ACsh, gc.M3_C30sh, gc.M3_C50sh)
+ def __init__(self, value = 0):
+ self._validate(value)
+ self.value = value
+
+
+ def __eq__(self, other) -> bool:
+ if isinstance(other, Mythen3GainCapsWrapper):
+ return self.value == other.value
+ else:
+ return self.value == other
+
+
+ def __ne__(self, other) -> bool:
+ return not self.__eq__(other)
+
+ def __str__(self) -> str:
+ s = ', '.join(str(c).rsplit('_', 1)[1] for c in self.all_caps if self.value & c)
+ return s
+
+ def __repr__(self) -> str:
+ return self.__str__()
+
+ def _validate(self, value):
+ """Check that only bits representing real capacitors are set"""
+ if isinstance(value, gc):
+ return True
+ elif isinstance(value, int):
+ if value & (~self.all_bits):
+ raise ValueError(f"The value: {value} is not allowed for Mythen3GainCapsWrapper")
+ else:
+ raise ValueError("GainCaps can only be initialized from int or M3_GainCaps enum")
\ No newline at end of file
diff --git a/python/slsdet/mythen3.py b/python/slsdet/mythen3.py
index b018699df..369d6ac99 100644
--- a/python/slsdet/mythen3.py
+++ b/python/slsdet/mythen3.py
@@ -13,6 +13,7 @@ from .detector import Detector, freeze
from .dacs import DetectorDacs
import _slsdet
dacIndex = _slsdet.slsDetectorDefs.dacIndex
+gc_enums = _slsdet.slsDetectorDefs.M3_GainCaps
from .detector_property import DetectorProperty
@@ -62,4 +63,6 @@ class Mythen3(Detector):
@property
def dacs(self):
- return self._dacs
\ No newline at end of file
+ return self._dacs
+
+
diff --git a/python/slsdet/proxy.py b/python/slsdet/proxy.py
index a02a3267a..90c9f4523 100644
--- a/python/slsdet/proxy.py
+++ b/python/slsdet/proxy.py
@@ -4,6 +4,7 @@ from .utils import element_if_equal
from .enums import dacIndex
from .defines import M3_MAX_PATTERN_LEVELS, MAX_PATTERN_LEVELS
from _slsdet import slsDetectorDefs
+detectorType = slsDetectorDefs.detectorType
def set_proxy_using_dict(func, key, value, unpack = False):
@@ -87,7 +88,10 @@ class ClkDivProxy:
def __repr__(self):
rstr = ''
- for i in range(6):
+ num_clocks = 6
+ if self.det.type == detectorType.MYTHEN3:
+ num_clocks = 5
+ for i in range(num_clocks):
r = element_if_equal(self.__getitem__(i))
if isinstance(r, list):
rstr += ' '.join(f'{item}' for item in r)
@@ -96,10 +100,35 @@ class ClkDivProxy:
return rstr.strip('\n')
+class ClkPhaseProxy:
+ """
+ Proxy class to allow for more intuitive reading clock phase
+ """
+ def __init__(self, det):
+ self.det = det
+
+ def __getitem__(self, key):
+ return element_if_equal(self.det.getClockPhase(key))
+
+ def __setitem__(self, key, value):
+ set_proxy_using_dict(self.det.setClockPhase, key, value)
+
+ def __repr__(self):
+ rstr = ''
+ if self.det.type == detectorType.MYTHEN3:
+ num_clocks = 5
+ for i in range(num_clocks):
+ r = element_if_equal(self.__getitem__(i))
+ if isinstance(r, list):
+ rstr += ' '.join(f'{item}' for item in r)
+ else:
+ rstr += f'{i}: {r}\n'
+
+ return rstr.strip('\n')
class MaxPhaseProxy:
"""
- Proxy class to allow for more intuitive reading clockdivider
+ Proxy class to allow for more intuitive reading max clock phase shift
"""
def __init__(self, det):
self.det = det
@@ -109,7 +138,9 @@ class MaxPhaseProxy:
def __repr__(self):
rstr = ''
- for i in range(5):
+ if self.det.type == detectorType.MYTHEN3:
+ num_clocks = 5
+ for i in range(num_clocks):
r = element_if_equal(self.__getitem__(i))
if isinstance(r, list):
rstr += ' '.join(f'{item}' for item in r)
@@ -120,7 +151,7 @@ class MaxPhaseProxy:
class ClkFreqProxy:
"""
- Proxy class to allow for more intuitive reading clockdivider
+ Proxy class to allow for more intuitive reading clock frequency
"""
def __init__(self, det):
self.det = det
@@ -130,7 +161,9 @@ class ClkFreqProxy:
def __repr__(self):
rstr = ''
- for i in range(5):
+ if self.det.type == detectorType.MYTHEN3:
+ num_clocks = 5
+ for i in range(num_clocks):
r = element_if_equal(self.__getitem__(i))
if isinstance(r, list):
rstr += ' '.join(f'{item}' for item in r)
diff --git a/python/slsdet/utils.py b/python/slsdet/utils.py
index afa9f59a2..60bbbb2a7 100755
--- a/python/slsdet/utils.py
+++ b/python/slsdet/utils.py
@@ -260,4 +260,21 @@ def merge_args(*args):
return (ret,)
else:
- raise ValueError("Multiple dictionaries passes cannot merge args")
\ No newline at end of file
+ raise ValueError("Multiple dictionaries passes cannot merge args")
+
+
+def hostname_list(args):
+ """
+ Generates a list from a hostname string
+ * Lists are passed through
+ * as are tuples (conversion in pybind11 to vector)
+ * if + is found it splits the string
+ """
+ if isinstance(args, (list, tuple)):
+ return args
+ elif(isinstance(args, str)):
+ hosts = args.split('+')
+ hosts = [it for it in hosts if len(it)]
+ return hosts
+ else:
+ raise ValueError("hostname needs to be string or list of strings")
diff --git a/python/src/detector.cpp b/python/src/detector.cpp
index 0df2feaef..9d7fba35e 100644
--- a/python/src/detector.cpp
+++ b/python/src/detector.cpp
@@ -61,6 +61,11 @@ void init_det(py::module &m) {
(Result(Detector::*)(sls::Positions) const) &
Detector::getFirmwareVersion,
py::arg() = Positions{});
+ CppDetectorApi.def("getFrontEndFirmwareVersion",
+ (Result(Detector::*)(const defs::fpgaPosition,
+ sls::Positions) const) &
+ Detector::getFrontEndFirmwareVersion,
+ py::arg(), py::arg() = Positions{});
CppDetectorApi.def(
"getDetectorServerVersion",
(Result(Detector::*)(sls::Positions) const) &
@@ -219,6 +224,21 @@ void init_det(py::module &m) {
(void (Detector::*)(const std::string &, sls::Positions)) &
Detector::setBadChannels,
py::arg(), py::arg() = Positions{});
+ CppDetectorApi.def(
+ "getBadChannels",
+ (Result>(Detector::*)(sls::Positions) const) &
+ Detector::getBadChannels,
+ py::arg() = Positions{});
+ CppDetectorApi.def(
+ "setBadChannels",
+ (void (Detector::*)(const std::vector, sls::Positions)) &
+ Detector::setBadChannels,
+ py::arg(), py::arg() = Positions{});
+ CppDetectorApi.def(
+ "setBadChannels",
+ (void (Detector::*)(const std::vector>)) &
+ Detector::setBadChannels,
+ py::arg());
CppDetectorApi.def("isVirtualDetectorServer",
(Result(Detector::*)(sls::Positions) const) &
Detector::isVirtualDetectorServer,
diff --git a/python/src/duration.cpp b/python/src/duration.cpp
index e77daad2f..db6da3d06 100644
--- a/python/src/duration.cpp
+++ b/python/src/duration.cpp
@@ -12,6 +12,7 @@ void init_duration(py::module &m) {
.def("total_seconds", &DurationWrapper::total_seconds)
.def("count", &DurationWrapper::count)
.def("set_count", &DurationWrapper::set_count)
+ .def("__eq__", &DurationWrapper::operator==)
.def("__repr__", [](const DurationWrapper &self) {
std::stringstream ss;
ss << "sls::DurationWrapper(total_seconds: " << self.total_seconds()
diff --git a/python/src/enums.cpp b/python/src/enums.cpp
index e8967a7dd..7981dd096 100644
--- a/python/src/enums.cpp
+++ b/python/src/enums.cpp
@@ -286,6 +286,11 @@ void init_enums(py::module &m) {
.value("BOTTOM", slsDetectorDefs::portPosition::BOTTOM)
.export_values();
+ py::enum_(Defs, "fpgaPosition")
+ .value("FRONT_LEFT", slsDetectorDefs::fpgaPosition::FRONT_LEFT)
+ .value("FRONT_RIGHT", slsDetectorDefs::fpgaPosition::FRONT_RIGHT)
+ .export_values();
+
py::enum_(Defs, "streamingInterface",
py::arithmetic())
.value("NONE", slsDetectorDefs::streamingInterface::NONE)
diff --git a/python/tests/test_m3gaincaps.py b/python/tests/test_m3gaincaps.py
new file mode 100644
index 000000000..d1e5e4bcc
--- /dev/null
+++ b/python/tests/test_m3gaincaps.py
@@ -0,0 +1,24 @@
+import pytest
+
+from slsdet import Mythen3GainCapsWrapper
+from slsdet.enums import M3_GainCaps #this is the c++ enum
+
+
+def test_comapre_with_int():
+ c = Mythen3GainCapsWrapper(128) #C10pre
+ assert c == 128
+ assert c != 5
+ assert c != 1280
+
+def test_compare_with_other():
+ a = Mythen3GainCapsWrapper(128)
+ b = Mythen3GainCapsWrapper(1<<10)
+ c = Mythen3GainCapsWrapper(128)
+ assert a!=b
+ assert (a==b) == False
+ assert a==c
+
+def test_can_be_default_constructed():
+ c = Mythen3GainCapsWrapper()
+ assert c == 0
+
diff --git a/python/tests/test_utils.py b/python/tests/test_utils.py
index 1dd8dd152..309ffa9a2 100755
--- a/python/tests/test_utils.py
+++ b/python/tests/test_utils.py
@@ -8,7 +8,7 @@ Testing functions from utils.py
import pytest
from slsdet.utils import *
-from slsdet import IpAddr, MacAddr
+from slsdet import IpAddr, MacAddr, DurationWrapper
import datetime as dt
import pathlib
from pathlib import Path
@@ -22,7 +22,11 @@ def test_iterable():
def test_reduce_time_to_single_value_from_list():
- t = 3 * [dt.timedelta(seconds=1)]
+ t = [dt.timedelta(seconds=1) for i in range(3)]
+ assert reduce_time(t) == 1
+
+def test_reduce_time_to_single_value_from_list_DurationWrapper():
+ t = [DurationWrapper(1) for i in range(3)]
assert reduce_time(t) == 1
@@ -83,6 +87,12 @@ def test_all_equal_str_fails():
assert all_equal('aaab') == False
+def test_all_equal_DurationWrapper():
+ assert all_equal([DurationWrapper(1), DurationWrapper(1)])
+
+def test_all_equal_DurationWrapper_fail():
+ assert not all_equal([DurationWrapper(1), DurationWrapper(2)])
+
def test_element_if_equal_int():
assert element_if_equal([5, 5]) == 5
@@ -341,4 +351,33 @@ def test_merge_args_tuple():
assert merge_args(*("a", "b"), 5) == ("a", "b", 5)
def test_merge_args_dict_with_tuple():
- assert merge_args({0: (1,2)}, 3) == ({0: (1,2,3)},)
\ No newline at end of file
+ assert merge_args({0: (1,2)}, 3) == ({0: (1,2,3)},)
+
+
+def test_hostname_to_list():
+ s = "localhost"
+ r = hostname_list(s)
+ assert r == [s]
+
+def test_hostname_to_list_passthrough():
+ args = ["localhost"]
+ ret = hostname_list(args)
+ assert ret == args
+
+ args = ("localhost",)
+ ret = hostname_list(args)
+ assert ret == args
+
+def test_splitting_hostname():
+ args = 'apple+banana+pear+'
+ ret = hostname_list(args)
+ assert ret == ['apple', 'banana', 'pear']
+
+ #not sensitive to trailing +
+ args = 'apple+banana+pear'
+ ret = hostname_list(args)
+ assert ret == ['apple', 'banana', 'pear']
+
+def test_hostame_throws_on_wrong_args():
+ with pytest.raises(Exception) as e:
+ hostname_list(5)
diff --git a/serverBin/ctbDetectorServer_developer b/serverBin/ctbDetectorServer_developer
new file mode 120000
index 000000000..2304a2043
--- /dev/null
+++ b/serverBin/ctbDetectorServer_developer
@@ -0,0 +1 @@
+../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer
\ No newline at end of file
diff --git a/serverBin/ctbDetectorServerv6.1.0 b/serverBin/ctbDetectorServerv6.1.0
deleted file mode 120000
index a3e856888..000000000
--- a/serverBin/ctbDetectorServerv6.1.0
+++ /dev/null
@@ -1 +0,0 @@
-../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv6.1.0
\ No newline at end of file
diff --git a/serverBin/ctbDetectorServerv7.0.0 b/serverBin/ctbDetectorServerv7.0.0
new file mode 120000
index 000000000..bc7dc05d2
--- /dev/null
+++ b/serverBin/ctbDetectorServerv7.0.0
@@ -0,0 +1 @@
+../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv7.0.0
\ No newline at end of file
diff --git a/serverBin/eigerDetectorServer_developer b/serverBin/eigerDetectorServer_developer
new file mode 120000
index 000000000..117c94c37
--- /dev/null
+++ b/serverBin/eigerDetectorServer_developer
@@ -0,0 +1 @@
+../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer
\ No newline at end of file
diff --git a/serverBin/eigerDetectorServerv6.1.0 b/serverBin/eigerDetectorServerv6.1.0
deleted file mode 120000
index 70dc2c5ff..000000000
--- a/serverBin/eigerDetectorServerv6.1.0
+++ /dev/null
@@ -1 +0,0 @@
-../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv6.1.0
\ No newline at end of file
diff --git a/serverBin/eigerDetectorServerv7.0.0 b/serverBin/eigerDetectorServerv7.0.0
new file mode 120000
index 000000000..06272c8f6
--- /dev/null
+++ b/serverBin/eigerDetectorServerv7.0.0
@@ -0,0 +1 @@
+../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv7.0.0
\ No newline at end of file
diff --git a/serverBin/gotthard2DetectorServer_developer b/serverBin/gotthard2DetectorServer_developer
new file mode 120000
index 000000000..7c8e54bee
--- /dev/null
+++ b/serverBin/gotthard2DetectorServer_developer
@@ -0,0 +1 @@
+../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer
\ No newline at end of file
diff --git a/serverBin/gotthard2DetectorServerv6.1.0 b/serverBin/gotthard2DetectorServerv6.1.0
deleted file mode 120000
index 0e92f1900..000000000
--- a/serverBin/gotthard2DetectorServerv6.1.0
+++ /dev/null
@@ -1 +0,0 @@
-../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv6.1.0
\ No newline at end of file
diff --git a/serverBin/gotthard2DetectorServerv7.0.0 b/serverBin/gotthard2DetectorServerv7.0.0
new file mode 120000
index 000000000..6e601d619
--- /dev/null
+++ b/serverBin/gotthard2DetectorServerv7.0.0
@@ -0,0 +1 @@
+../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv7.0.0
\ No newline at end of file
diff --git a/serverBin/gotthardDetectorServer_developer b/serverBin/gotthardDetectorServer_developer
new file mode 120000
index 000000000..28e8385e0
--- /dev/null
+++ b/serverBin/gotthardDetectorServer_developer
@@ -0,0 +1 @@
+../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer
\ No newline at end of file
diff --git a/serverBin/gotthardDetectorServerv6.1.0 b/serverBin/gotthardDetectorServerv6.1.0
deleted file mode 120000
index 0582cc98f..000000000
--- a/serverBin/gotthardDetectorServerv6.1.0
+++ /dev/null
@@ -1 +0,0 @@
-../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv6.1.0
\ No newline at end of file
diff --git a/serverBin/gotthardDetectorServerv7.0.0 b/serverBin/gotthardDetectorServerv7.0.0
new file mode 120000
index 000000000..d8d2d651e
--- /dev/null
+++ b/serverBin/gotthardDetectorServerv7.0.0
@@ -0,0 +1 @@
+../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv7.0.0
\ No newline at end of file
diff --git a/serverBin/jungfrauDetectorServer_developer b/serverBin/jungfrauDetectorServer_developer
new file mode 120000
index 000000000..8ae22b591
--- /dev/null
+++ b/serverBin/jungfrauDetectorServer_developer
@@ -0,0 +1 @@
+../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer
\ No newline at end of file
diff --git a/serverBin/jungfrauDetectorServerv6.1.0 b/serverBin/jungfrauDetectorServerv6.1.0
deleted file mode 120000
index e5ae30c80..000000000
--- a/serverBin/jungfrauDetectorServerv6.1.0
+++ /dev/null
@@ -1 +0,0 @@
-../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv6.1.0
\ No newline at end of file
diff --git a/serverBin/jungfrauDetectorServerv7.0.0 b/serverBin/jungfrauDetectorServerv7.0.0
new file mode 120000
index 000000000..c91c000b3
--- /dev/null
+++ b/serverBin/jungfrauDetectorServerv7.0.0
@@ -0,0 +1 @@
+../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv7.0.0
\ No newline at end of file
diff --git a/serverBin/moenchDetectorServer_developer b/serverBin/moenchDetectorServer_developer
new file mode 120000
index 000000000..147ecfb53
--- /dev/null
+++ b/serverBin/moenchDetectorServer_developer
@@ -0,0 +1 @@
+../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer
\ No newline at end of file
diff --git a/serverBin/moenchDetectorServerv6.1.0 b/serverBin/moenchDetectorServerv6.1.0
deleted file mode 120000
index 1ca884421..000000000
--- a/serverBin/moenchDetectorServerv6.1.0
+++ /dev/null
@@ -1 +0,0 @@
-../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv6.1.0
\ No newline at end of file
diff --git a/serverBin/moenchDetectorServerv7.0.0 b/serverBin/moenchDetectorServerv7.0.0
new file mode 120000
index 000000000..ea12c878c
--- /dev/null
+++ b/serverBin/moenchDetectorServerv7.0.0
@@ -0,0 +1 @@
+../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv7.0.0
\ No newline at end of file
diff --git a/serverBin/mythen3DetectorServer_developer b/serverBin/mythen3DetectorServer_developer
new file mode 120000
index 000000000..cc8b2c91f
--- /dev/null
+++ b/serverBin/mythen3DetectorServer_developer
@@ -0,0 +1 @@
+../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer
\ No newline at end of file
diff --git a/serverBin/mythen3DetectorServerv6.1.0 b/serverBin/mythen3DetectorServerv6.1.0
deleted file mode 120000
index 1c5ad2ba8..000000000
--- a/serverBin/mythen3DetectorServerv6.1.0
+++ /dev/null
@@ -1 +0,0 @@
-../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv6.1.0
\ No newline at end of file
diff --git a/serverBin/mythen3DetectorServerv7.0.0 b/serverBin/mythen3DetectorServerv7.0.0
new file mode 120000
index 000000000..f5fe23393
--- /dev/null
+++ b/serverBin/mythen3DetectorServerv7.0.0
@@ -0,0 +1 @@
+../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv7.0.0
\ No newline at end of file
diff --git a/slsDetectorCalibration/dataStructures/jungfrauModuleData.h b/slsDetectorCalibration/dataStructures/jungfrauModuleData.h
index ab7b7e463..272a8a831 100644
--- a/slsDetectorCalibration/dataStructures/jungfrauModuleData.h
+++ b/slsDetectorCalibration/dataStructures/jungfrauModuleData.h
@@ -40,20 +40,31 @@ class jungfrauModuleData : public slsDetectorData {
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
1286 large etc.) \param c crosstalk parameter for the output buffer
- */
+ */
+#ifndef ZMQ
+#define off sizeof(jf_header)
+#endif
+#ifdef ZMQ
+#define off 0
+#endif
+
+
jungfrauModuleData()
: slsDetectorData(1024, 512,
- 1024* 512 * 2 + sizeof(jf_header)) {
-
+ 1024* 512 * 2 + off) {
+
for (int ix = 0; ix < 1024; ix++) {
for (int iy = 0; iy < 512; iy++) {
- dataMap[iy][ix] = sizeof(jf_header) + (1024 * iy + ix) * 2;
+ dataMap[iy][ix] = off + (1024 * iy + ix) * 2;
#ifdef HIGHZ
dataMask[iy][ix] = 0x3fff;
#endif
}
}
+
+
+
iframe = 0;
// cout << "data struct created" << endl;
};
diff --git a/slsDetectorCalibration/jungfrauExecutables/Makefile.zmq b/slsDetectorCalibration/jungfrauExecutables/Makefile.zmq
index af60de798..007e8cfed 100644
--- a/slsDetectorCalibration/jungfrauExecutables/Makefile.zmq
+++ b/slsDetectorCalibration/jungfrauExecutables/Makefile.zmq
@@ -1,25 +1,19 @@
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
-INCDIR= -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ -I../../libs/rapidjson/
+INCDIR= -I. -I../dataStructures ../tiffio/src/tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ -I../../libs/rapidjson/ -I../tiffio/include
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3 -std=c++11 -Wall -L../../build/bin/ -lSlsSupport
#-L../../bin -lhdf5 -L.
#DESTDIR?=../bin
-all: moenchZmqProcess moenchZmq04Process
- #moenchZmqProcessCtbGui
+all: jungfrauZmqProcess
+ #jungfrauZmqProcessCtbGui
-moenchZmqProcess: moenchZmqProcess.cpp clean
- g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP
-
-moenchZmq04Process: moenchZmqProcess.cpp clean
- g++ -o moench04ZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DMOENCH04
-
-#moenchZmqProcessCtbGui: moenchZmqProcess.cpp clean
-# g++ -o moenchZmqProcessCtbGui moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DCTBGUI
+jungfrauZmqProcess: jungfrauZmqProcess.cpp clean
+ g++ -o jungfrauZmqProcess jungfrauZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP
clean:
- rm -f moenchZmqProcess
+ rm -f jungfrauZmqProcess
diff --git a/slsDetectorCalibration/jungfrauExecutables/Makefile.zmqrootdisp b/slsDetectorCalibration/jungfrauExecutables/Makefile.zmqrootdisp
new file mode 100644
index 000000000..86db24343
--- /dev/null
+++ b/slsDetectorCalibration/jungfrauExecutables/Makefile.zmqrootdisp
@@ -0,0 +1,26 @@
+ROOTSYS=/opt/cern/v6/root
+#/afs/psi.ch/project/sls_det_sof/roottware/root_v5.34.23_sl6_64bit
+
+
+
+LIBZMQDIR = $(PWD)
+LIBZMQ = -L$(LIBZMQDIR) -lzmq
+SHLIB_PATH=/opt/cern/v6/root/lib
+CMAKE_PREFIX_PATH=/opt/cern/v6/root
+DYLD_LIBRARY_PATH=/opt/cern/v6/root/lib
+
+
+INCDIR= -I. -I../dataStructures ../tiffio/src/tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ -I../../libs/rapidjson/ -I../tiffio/include
+LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3 -std=c++11 -Wall -L../../build/bin/ -lSlsSupport
+#-L../../bin -lhdf5 -L.
+
+
+
+default: onlinedisp_zmq
+
+onlinedisp_zmq: onlinedisp_zmq.cpp onlinedisp_zmq.h
+# flags from root-config --cflags --glibs
+ g++ -o onlinedisp_zmq onlinedisp_zmq.cpp -I. -I$(ROOTSYS)/include -Wall -g -lm -L. -lzmq -pthread -lrt -L$(ROOTSYS)/lib -lGui -lCore -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -m64 $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
+
+#-lCint
+
diff --git a/slsDetectorCalibration/jungfrauExecutables/examples.txt b/slsDetectorCalibration/jungfrauExecutables/examples.txt
new file mode 100644
index 000000000..b72d370e1
--- /dev/null
+++ b/slsDetectorCalibration/jungfrauExecutables/examples.txt
@@ -0,0 +1,10 @@
+
+
+ sls_detector_put rx_jsonpara detectorMode counting
+ sls_detector_put rx_jsonpara frameMode newPedestal
+ sls_detector_put rx_jsonpara frameMode frame
+ sls_detector_put rx_jsonpara detectorMode analog
+ sls_detector_put rx_jsonpara threshold 150
+ sls_detector_put rx_jsonpara threshold 0
+ sls_detector_put rx_jsonpara threshold 300
+ sls_detector_put rx_zmqhwm 50
diff --git a/slsDetectorCalibration/jungfrauExecutables/jungfrauRawDataProcess.cpp b/slsDetectorCalibration/jungfrauExecutables/jungfrauRawDataProcess.cpp
index a0bf7c5cc..6aadba3b6 100644
--- a/slsDetectorCalibration/jungfrauExecutables/jungfrauRawDataProcess.cpp
+++ b/slsDetectorCalibration/jungfrauExecutables/jungfrauRawDataProcess.cpp
@@ -222,6 +222,7 @@ int main(int argc, char *argv[]) {
multiThreadedCountingDetector *mt =
new multiThreadedCountingDetector(filter, nthreads, fifosize);
mt->setClusterSize(csize,csize);
+
#ifndef ANALOG
mt->setDetectorMode(ePhotonCounting);
cout << "Counting!" << endl;
diff --git a/slsDetectorCalibration/jungfrauExecutables/jungfrauZmqProcess.cpp b/slsDetectorCalibration/jungfrauExecutables/jungfrauZmqProcess.cpp
index 7977e208d..994729355 100644
--- a/slsDetectorCalibration/jungfrauExecutables/jungfrauZmqProcess.cpp
+++ b/slsDetectorCalibration/jungfrauExecutables/jungfrauZmqProcess.cpp
@@ -1,28 +1,26 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
//#define WRITE_QUAD
-#define DEVELOPER
+//#define DEVELOPER
#undef CORR
+//#undef MOENCH04
+
#define C_GHOST 0.0004
#define CM_ROWS 20
+#define ZMQ
#include "sls/ZmqSocket.h"
#include "sls/sls_detector_defs.h"
-#ifndef RECT
-#ifndef MOENCH04
-#include "moench03T1ZmqDataNew.h"
-#endif
-#ifdef MOENCH04
-#include "moench04CtbZmq10GbData.h"
-#endif
-#endif
-#ifdef RECT
-#include "moench03T1ZmqDataNewRect.h"
-#endif
+//#include "moench03T1ZmqDataNew.h"
+
+#include "jungfrauModuleData.h"
+
+
#include "moench03CommonMode.h"
#include "moench03GhostSummation.h"
+
#include "sls/tiffIO.h"
#include
#include
@@ -57,983 +55,852 @@ using namespace std::chrono;
//\"what\":\"nothing\" ");
int main(int argc, char *argv[]) {
- /**
- * trial.o [socket ip] [starting port number] [send_socket ip] [send port
- * number]
- *
- */
- FILE *of = NULL;
- int fifosize = 5000;
- int etabins = 1000, etabinsy = 1000; // nsubpix*2*100;
- double etamin = -1, etamax = 2;
- int nSubPixelsX = 2;
- // int emin, emax;
- int nSubPixelsY = 2;
- // help
- if (argc < 3) {
- cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port "
- "number] [send_socket ip] [send starting port number] "
- "[nthreads] [nsubpix] [gainmap] [etafile]\n");
- return EXIT_FAILURE;
- }
+ /**
+ * trial.o [socket ip] [starting port number] [send_socket ip] [send port
+ * number]
+ *
+ */
+ FILE *of = NULL;
+ int fifosize = 500;
+ int etabins = 1000, etabinsy = 1000; // nsubpix*2*100;
+ double etamin = -1, etamax = 2;
+ int nSubPixelsX = 2;
+ int emin, emax;
+ int nSubPixelsY = 2;
- // receive parameters
- bool send = false;
- char *socketip = argv[1];
- uint32_t portnum = atoi(argv[2]);
- // send parameters if any
- char *socketip2 = 0;
- uint32_t portnum2 = 0;
+ // help
+ if (argc < 3) {
+ cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port "
+ "number] [send_socket ip] [send starting port number] "
+ "[nthreads] [nsubpix] [gainmap] [etafile]\n");
+ return EXIT_FAILURE;
+ }
- zmqHeader zHeader, outHeader;
- zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
- outHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
+ // receive parameters
+ bool send = false;
+ char *socketip = argv[1];
+ uint32_t portnum = atoi(argv[2]);
+ // send parameters if any
+ char *socketip2 = 0;
+ uint32_t portnum2 = 0;
- uint32_t nSigma = 5;
+ sls::zmqHeader zHeader, outHeader;
+ zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
+ outHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
- int ok;
+ uint32_t nSigma = 5;
- high_resolution_clock::time_point t1;
- high_resolution_clock::time_point t2;
- std::chrono::steady_clock::time_point begin, end, finished;
- // time_t begin,end,finished;
- int rms = 0;
+ int ok;
- if (argc > 4) {
- socketip2 = argv[3];
- portnum2 = atoi(argv[4]);
- if (portnum2 > 0)
- send = true;
- }
- cout << "\nrx socket ip : " << socketip << "\nrx port num : " << portnum;
- if (send) {
- cout << "\ntx socket ip : " << socketip2
- << "\ntx port num : " << portnum2;
- }
- int nthreads = 5;
- if (argc > 5)
- nthreads = atoi(argv[5]);
+ high_resolution_clock::time_point t1;
+ high_resolution_clock::time_point t2;
+ std::chrono::steady_clock::time_point begin, end, finished;
+ // time_t begin,end,finished;
+ int rms = 0;
- cout << "Number of threads is: " << nthreads << endl;
- if (argc > 6) {
- nSubPixelsX = atoi(argv[6]);
- nSubPixelsY = nSubPixelsX;
+ if (argc > 4) {
+ socketip2 = argv[3];
+ portnum2 = atoi(argv[4]);
+ if (portnum2 > 0)
+ send = true;
+ }
+ cout << "\nrx socket ip : " << socketip << "\nrx port num : " << portnum;
+ if (send) {
+ cout << "\ntx socket ip : " << socketip2
+ << "\ntx port num : " << portnum2;
+ }
+ int nthreads = 4;
+ if (argc > 5)
+ nthreads = atoi(argv[5]);
+ cout << "Number of threads is: " << nthreads << endl;
+
+ if (argc > 6) {
+ nSubPixelsX = atoi(argv[6]);
+ nSubPixelsY = nSubPixelsX;
#ifdef RECT
- nSubPixelsX = 2;
+ nSubPixelsX = 2;
#endif
- }
- cout << "Number of subpixels is: " << nSubPixelsX << " " << nSubPixelsY
- << endl;
+ }
+ cout << "Number of subpixels is: " << nSubPixelsX << " " << nSubPixelsY
+ << endl;
- char *gainfname = NULL;
- if (argc > 7) {
- gainfname = argv[7];
- cout << "Gain map file name is: " << gainfname << endl;
- }
+ char *gainfname = NULL;
+ if (argc > 7) {
+ gainfname = argv[7];
+ cout << "Gain map file name is: " << gainfname << endl;
+ }
- char *etafname = NULL;
- if (argc > 8) {
- etafname = argv[8];
- cout << "Eta file name is: " << etafname << endl;
- }
+ char *etafname = NULL;
+ if (argc > 8) {
+ etafname = argv[8];
+ cout << "Eta file name is: " << etafname << endl;
+ }
- // slsDetectorData *det=new moench03T1ZmqDataNew();
-#ifndef MOENCH04
- moench03T1ZmqDataNew *det = new moench03T1ZmqDataNew();
-#endif
-#ifdef MOENCH04
- moench04CtbZmq10GbData *det = new moench04CtbZmq10GbData();
-#endif
- cout << endl << " det" << endl;
- int npx, npy;
- det->getDetectorSize(npx, npy);
+ // slsDetectorData *det=new moench03T1ZmqDataNew();
- int send_something = 0;
- int maxSize = npx * npy * 2; // 32*2*8192;//5000;//atoi(argv[3]);
- int size = maxSize; // 32*2*5000;
- // int multisize=size;
- // int dataSize=size;
- char dummybuff[size];
+ jungfrauModuleData *det = new jungfrauModuleData();
+ cout << endl << " det" << endl;
+ int npx, npy;
+ det->getDetectorSize(npx, npy);
- moench03CommonMode *cm = NULL;
- moench03GhostSummation *gs = NULL;
+ int send_something = 0;
+
+ int maxSize = npx * npy * 2; // 32*2*8192;//5000;//atoi(argv[3]);
+ int size = maxSize+sizeof(int); // 32*2*5000;
+ // int multisize=size;
+ // int dataSize=size;
+
+ char *dummybuff = new char[size];
+
+ moench03CommonMode *cm = NULL;
+ moench03GhostSummation *gs = NULL;
#ifdef CORR
- // int ncol_cm=CM_ROWS;
- // double xt_ghost=C_GHOST;
+ // int ncol_cm=CM_ROWS;
+ // double xt_ghost=C_GHOST;
- cm = new moench03CommonMode(CM_ROWS);
- gs = new moench03GhostSummation(det, C_GHOST);
+ cm = new moench03CommonMode(CM_ROWS);
+ gs = new moench03GhostSummation(det, C_GHOST);
#endif
- double *gainmap = NULL;
- float *gm;
- double *gmap = NULL;
+ double *gainmap = NULL;
+ float *gm;
+ double *gmap = NULL;
- uint32_t nnnx, nnny;
- if (gainfname) {
- gm = ReadFromTiff(gainfname, nnny, nnnx);
- if (gm && nnnx == (uint)npx && nnny == (uint)npy) {
- gmap = new double[npx * npy];
- for (int i = 0; i < npx * npy; i++) {
- gmap[i] = gm[i];
- }
- delete[] gm;
- } else
- cout << "Could not open gain map " << gainfname << endl;
- }
+ uint32_t nnnx, nnny;
+ if (gainfname) {
+ gm = ReadFromTiff(gainfname, nnny, nnnx);
+ if (gm && nnnx == (uint)npx && nnny == (uint)npy) {
+ gmap = new double[npx * npy];
+ for (int i = 0; i < npx * npy; i++) {
+ gmap[i] = gm[i];
+ }
+ delete[] gm;
+ } else
+ cout << "Could not open gain map " << gainfname << endl;
+ }
- // analogDetector *filter=new
- // analogDetector(det,1,NULL,1000);
+ // analogDetector *filter=new
+ // analogDetector(det,1,NULL,1000);
#ifndef INTERP
- singlePhotonDetector *filter = new singlePhotonDetector(
- det, 3, nSigma, 1, cm, 1000, 100, -1, -1, gainmap, gs);
+ singlePhotonDetector *filter = new singlePhotonDetector(
+ det, 3, nSigma, 1, cm, 1000, 0, -1, -1, gainmap, gs);
- multiThreadedCountingDetector *mt =
- new multiThreadedCountingDetector(filter, nthreads, fifosize);
+ multiThreadedCountingDetector *mt =
+ new multiThreadedCountingDetector(filter, nthreads, fifosize);
- // multiThreadedAnalogDetector *mt=new
- // multiThreadedAnalogDetector(filter,nthreads,fifosize);
+ // multiThreadedAnalogDetector *mt=new
+ // multiThreadedAnalogDetector(filter,nthreads,fifosize);
#endif
#ifdef INTERP
- eta2InterpolationPosXY *interp = new eta2InterpolationPosXY(
- npx, npy, nSubPixelsX, nSubPixelsY, etabins, etabinsy, etamin, etamax);
+ eta2InterpolationPosXY *interp = new eta2InterpolationPosXY(
+ npx, npy, nSubPixelsX, nSubPixelsY, etabins, etabinsy, etamin, etamax);
- if (etafname)
- interp->readFlatField(etafname);
+ if (etafname)
+ interp->readFlatField(etafname);
- interpolatingDetector *filter = new interpolatingDetector(
- det, interp, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs);
- multiThreadedInterpolatingDetector *mt =
- new multiThreadedInterpolatingDetector(filter, nthreads, fifosize);
+ interpolatingDetector *filter = new interpolatingDetector(
+ det, interp, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs);
+ multiThreadedInterpolatingDetector *mt =
+ new multiThreadedInterpolatingDetector(filter, nthreads, fifosize);
#endif
- char *buff;
- mt->setFrameMode(eFrame);
- mt->StartThreads();
- mt->popFree(buff);
+ char *buff;
+ mt->setFrameMode(eFrame);
+ mt->StartThreads();
+ mt->popFree(buff);
- ZmqSocket *zmqsocket = NULL;
+ sls::ZmqSocket *zmqsocket = NULL;
+#ifdef NEWZMQ
+ // receive socket
+ try {
+#endif
+
+ zmqsocket = new sls::ZmqSocket(socketip, portnum);
+
+#ifdef NEWZMQ
+ } catch (...) {
+ cprintf(RED,
+ "Error: Could not create Zmq socket on port %d with ip %s\n",
+ portnum, socketip);
+ delete zmqsocket;
+ return EXIT_FAILURE;
+ }
+#endif
+
+
+
+ if (zmqsocket->Connect()) {
+ cprintf(RED, "Error: Could not connect to socket %s\n",
+ (zmqsocket->GetZmqServerAddress()).c_str());
+ delete zmqsocket;
+ return EXIT_FAILURE;
+ } else
+ printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress().c_str());
+
+ // send socket
+ sls::ZmqSocket *zmqsocket2 = 0;
+ // cout << "zmq2 " << endl;
+ if (send) {
#ifdef NEWZMQ
// receive socket
try {
#endif
-
- zmqsocket = new ZmqSocket(socketip, portnum);
+ zmqsocket2 = new sls::ZmqSocket(portnum2, socketip2);
#ifdef NEWZMQ
} catch (...) {
- cprintf(RED,
- "Error: Could not create Zmq socket on port %d with ip %s\n",
- portnum, socketip);
- delete zmqsocket;
- return EXIT_FAILURE;
+ cprintf(RED,
+ "Error: Could not create Zmq socket server on port %d and "
+ "ip %s\n",
+ portnum2, socketip2);
+
+ send = false;
}
#endif
-#ifndef NEWZMQ
- if (zmqsocket->IsError()) {
- cprintf(RED,
- "Error: Could not create Zmq socket on port %d with ip %s\n",
- portnum, socketip);
- delete zmqsocket;
- return EXIT_FAILURE;
- }
-#endif
- if (zmqsocket->Connect()) {
- cprintf(RED, "Error: Could not connect to socket %s\n",
- (zmqsocket->GetZmqServerAddress()).c_str());
- delete zmqsocket;
- return EXIT_FAILURE;
+ if (zmqsocket2->Connect()) {
+ cprintf(RED, "Error: Could not connect to socket %s\n",
+ zmqsocket2->GetZmqServerAddress().c_str());
+ // delete zmqsocket2;
+ send = false;
+ // return EXIT_FAILURE;
} else
- printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress().c_str());
+ printf("Zmq Client at %s\n",
+ zmqsocket2->GetZmqServerAddress().c_str());
+ }
- // send socket
- ZmqSocket *zmqsocket2 = 0;
- // cout << "zmq2 " << endl;
- if (send) {
-#ifdef NEWZMQ
- // receive socket
- try {
-#endif
- zmqsocket2 = new ZmqSocket(portnum2, socketip2);
+ // header variables
+ uint64_t acqIndex = -1;
+ uint64_t frameIndex = -1;
+
+ uint64_t subframes = 0;
+ uint64_t insubframe = 0;
+
+ double subnorm = 1;
+ uint64_t f0 = -1, nsubframes = 0, nnsubframe = 0;
+ uint64_t fileindex = -1;
+ string filename = "";
-#ifdef NEWZMQ
- } catch (...) {
- cprintf(RED,
- "Error: Could not create Zmq socket server on port %d and "
- "ip %s\n",
- portnum2, socketip2);
- // delete zmqsocket2;
- // zmqsocket2=NULL;
- // delete zmqsocket;
- // return EXIT_FAILURE;
- send = false;
- }
-#endif
+ int iframe = 0;
+ char ofname[10000];
-#ifndef NEWZMQ
- if (zmqsocket2->IsError()) {
- cprintf(RED,
- "AAA Error: Could not create Zmq socket server on port %d "
- "and ip %s\n",
- portnum2, socketip2);
- // delete zmqsocket2;
- // delete zmqsocket;
- // return EXIT_FAILURE;
- send = false;
- }
+ string fname;
+ // int length;
+ int *detimage = NULL;
+ int nnx, nny, nnsx, nnsy;
+ uint32_t packetNumber = 0;
+ uint64_t detSpec1 = 0;
+ uint64_t timestamp = 0;
+ int16_t modId = 0;
+ uint32_t expLength = 0;
+ uint16_t xCoord = 0;
+ uint16_t yCoord = 0;
+ // uint16_t zCoord = 0;
+ uint32_t detSpec3 = 0;
+ // uint32_t dr = 16;
+ // int16_t *dout;//=new int16_t [nnx*nny];
+ uint32_t dr = 32;
+ int32_t *dout = NULL; //=new int32_t [nnx*nny];
+ float *doutf = NULL; //=new int32_t [nnx*nny];
+ uint16_t detSpec4 = 0;
+ uint8_t detType = 0;
+ uint8_t version = 0;
+ string additionalJsonHeader = "";
+
+ int32_t threshold = 0;
+
+ int32_t xmin = 0, xmax = 400, ymin = 0, ymax = 400;
+
+ string frameMode_s, detectorMode_s, intMode_s;
+
+ // int resetFlat=0;
+ // int resetPed=0;
+ // int nsubPixels=1;
+ // int isPedestal=0;
+ // int isFlat=0;
+ int newFrame = 1;
+ detectorMode dMode = eAnalog;
+ frameMode fMode = eFrame;
+ double *ped;
+
+ filter->getImageSize(nnx, nny, nnsx, nnsy);
+
+ std::map addJsonHeader;
+
+ while (1) {
+
+ // cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
+ // get header, (if dummy, fail is on parse error or end of acquisition)
+
+ // rapidjson::Document doc;
+ if (!zmqsocket->ReceiveHeader(0, zHeader,
+ SLS_DETECTOR_JSON_HEADER_VERSION)) {
+ /* zmqsocket->CloseHeaderMessage();*/
+
+ // if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex,
+ //subframeIndex, filename, fileindex)) {
+ cprintf(RED, "Got Dummy\n");
+ // t1=high_resolution_clock::now();
+ // time(&end);
+ // cout << "Measurement lasted " << difftime(end,begin) << endl;
+
+ end = std::chrono::steady_clock::now();
+ cout << "Measurement lasted " << (end - begin).count() * 0.000001
+ << " ms" << endl;
+
+ while (mt->isBusy()) {
+ ;
+ } // wait until all data are processed from the queues
+ usleep(100);
+ if (of) {
+ mt->setFilePointer(NULL);
+ fclose(of);
+ of = NULL;
+ }
+ if (newFrame > 0) {
+ cprintf(RED, "DIDn't receive any data!\n");
+ if (send) {
+
+ // zHeader.data = false;
+ outHeader.data = false;
+ // zmqsocket2->SendHeaderData(0, true,
+ // SLS_DETECTOR_JSON_HEADER_VERSION);
+ zmqsocket2->SendHeader(0, outHeader);
+ cprintf(RED, "Sent Dummy\n");
+ }
+ } else {
+ send_something = 0;
+ if (fMode == ePedestal) {
+ sprintf(ofname, "%s_%ld_ped.tiff", fname.c_str(),
+ fileindex);
+ mt->writePedestal(ofname);
+ cout << "Writing pedestal to " << ofname << endl;
+ if (rms) {
+ sprintf(ofname, "%s_%ld_var.tiff", fname.c_str(),
+ fileindex);
+ mt->writePedestalRMS(ofname);
+ }
+ send_something = 1;
+ }
+#ifdef INTERP
+ else if (fMode == eFlat) {
+ mt->prepareInterpolation(ok);
+ sprintf(ofname, "%s_%ld_eta.tiff", fname.c_str(),
+ fileindex);
+ mt->writeFlatField(ofname);
+ cout << "Writing eta to " << ofname << endl;
+ send_something = 1;
+ }
#endif
- if (zmqsocket2->Connect()) {
- cprintf(RED, "BBB Error: Could not connect to socket %s\n",
- zmqsocket2->GetZmqServerAddress().c_str());
- // delete zmqsocket2;
- send = false;
- // return EXIT_FAILURE;
- } else
- printf("Zmq Client at %s\n",
- zmqsocket2->GetZmqServerAddress().c_str());
+ else {
+ if (subframes > 0) {
+ if (insubframe > 0) {
+ sprintf(ofname, "%s_sf%ld_%ld.tiff", fname.c_str(),
+ nnsubframe, fileindex);
+ // mt->writeImage(ofname);
+ doutf = new float[nnx * nny];
+ if (subframes > 0 && insubframe != subframes &&
+ insubframe > 0)
+ subnorm =
+ ((double)subframes) / ((double)insubframe);
+ else
+ subnorm = 1.;
+ for (int ix = 0; ix < nnx * nny; ix++) {
+ doutf[ix] = detimage[ix] * subnorm;
+ if (doutf[ix] < 0)
+ doutf[ix] = 0;
+ }
+
+ cout << "Writing image to " << ofname << endl;
+
+ WriteToTiff(doutf, ofname, nnx, nny);
+
+ if (doutf)
+ delete[] doutf;
+ doutf = NULL;
+
+ nsubframes++;
+ insubframe = 0;
+ send_something = 1;
+ }
+ } else {
+ sprintf(ofname, "%s_%ld.tiff", fname.c_str(),
+ fileindex);
+ mt->writeImage(ofname);
+ send_something = 1;
+ }
+
+ cout << "Writing image to " << ofname << endl;
+ }
+ // cout << nns*nnx*nny*nns*dr/8 << " " << length << endl;
+
+ if (send) {
+
+ if (fMode == ePedestal) {
+ cprintf(MAGENTA, "Get pedestal!\n");
+ nnsx = 1;
+ nnsy = 1;
+
+ nnx = npx;
+ nny = npy;
+ // dout= new int16_t[nnx*nny*nns*nns];
+ dout = new int32_t[nnx * nny * nnsx * nnsy];
+ // cout << "get pedestal " << endl;
+ ped = mt->getPedestal();
+ // cout << "got pedestal " << endl;
+ for (int ix = 0; ix < nnx * nny; ix++) {
+
+ dout[ix] = ped[ix];
+
+ }
+
+ }
+#ifdef INTERP
+ else if (fMode == eFlat) {
+ int nbx, nby;
+ double emi = 0, ema = 1;
+ int *ff = mt->getFlatField(nbx, nby, emi, ema);
+ nnx = nbx;
+ nny = nby;
+ dout = new int32_t[nbx * nby];
+ for (int ix = 0; ix < nbx * nby; ix++) {
+ dout[ix] = ff[ix];
+ }
+ }
+#endif
+ else {
+ detimage = mt->getImage(nnx, nny, nnsx, nnsy);
+ cprintf(MAGENTA, "Get image!\n");
+ cout << nnx << " " << nny << " " << nnsx << " " << nnsy
+ << endl;
+ // nns=1;
+ // nnx=npx;
+ // nny=npy;
+ // nnx=nnx*nns;
+ // nny=nny*nns;
+ dout = new int32_t[nnx * nny];
+ if (subframes > 0 && insubframe != subframes &&
+ insubframe > 0)
+ subnorm =
+ ((double)subframes) / ((double)insubframe);
+ else
+ subnorm = 1.;
+ for (int ix = 0; ix < nnx * nny; ix++) {
+ // for (int iy=0; iy0 && subframes>0) || (subframes<=0) ){
+
+ if (send_something) {
+
+ outHeader.data = true;
+ outHeader.dynamicRange = dr;
+ outHeader.fileIndex = fileindex;
+ outHeader.ndetx = 1;
+ outHeader.ndety = 1;
+ outHeader.npixelsx = nnx;
+ outHeader.npixelsy = nny;
+ outHeader.imageSize = nnx * nny * dr / 8;
+ outHeader.acqIndex = acqIndex;
+ outHeader.frameIndex = frameIndex;
+ outHeader.fname = fname;
+ outHeader.frameNumber = acqIndex;
+ outHeader.expLength = expLength;
+ outHeader.packetNumber = packetNumber;
+ outHeader.detSpec1 = detSpec1;
+ outHeader.timestamp = timestamp;
+ outHeader.modId = modId;
+ outHeader.row = xCoord;
+ outHeader.column = yCoord;
+ outHeader.detSpec3 = detSpec3;
+ outHeader.detSpec4 = detSpec4;
+ outHeader.detType = detType;
+ outHeader.version = version;
+
+ zmqsocket2->SendHeader(0, outHeader);
+ zmqsocket2->SendData((char *)dout, nnx * nny * dr / 8);
+ cprintf(GREEN, "Sent Data\n");
+ }
+ outHeader.data = false;
+ zmqsocket2->SendHeader(0, outHeader);
+ // zmqsocket2->SendHeaderData(0, true,
+ // SLS_DETECTOR_JSON_HEADER_VERSION);
+ cprintf(RED, "Sent Dummy\n");
+ if (dout)
+ delete[] dout;
+ dout = NULL;
+ }
+ }
+
+ mt->clearImage();
+
+ newFrame = 1;
+
+ // time(&finished);
+ // cout << "Processing lasted " << difftime(finished,begin) << endl;
+
+ finished = std::chrono::steady_clock::now();
+ cout << "Processing lasted "
+ << (finished - begin).count() * 0.000001 << " ms" << endl;
+#ifdef OPTIMIZE
+ return 0;
+#endif
+ continue; // continue to not get out
}
- // header variables
- uint64_t acqIndex = -1;
- uint64_t frameIndex = -1;
-#ifdef MOENCH_BRANCH
- uint32_t subFrameIndex = -1;
- int *flippedData = 0;
-#endif
+ //#ifdef NEWZMQ
+ if (newFrame) {
+ begin = std::chrono::steady_clock::now();
- uint64_t subframes = 0;
- // uint64_t isubframe=0;
- uint64_t insubframe = 0;
- double subnorm = 1;
- uint64_t f0 = -1, nsubframes = 0, nnsubframe = 0;
+ size = zHeader.imageSize; // doc["size"].GetUint();
- uint64_t fileindex = -1;
- string filename = "";
- // char* image = new char[size];
- // int* image = new int[(size/sizeof(int))]();
- // uint32_t flippedDataX = -1;
- // int *nph;
- int iframe = 0;
- char ofname[10000];
+ // dynamicRange = zheader.dynamicRange; //doc["bitmode"].GetUint();
+ // nPixelsX = zHeader.npixelsx; //doc["shape"][0].GetUint();
+ // nPixelsY = zHeader.npixelsy;// doc["shape"][1].GetUint();
+ filename = zHeader.fname; // doc["fname"].GetString();
+ acqIndex =
+ zHeader
+ .acqIndex; // doc["acqIndex"].GetUint64();
+ // frameIndex =
+ // zHeader.frameIndex;//doc["fIndex"].GetUint64();
+ fileindex = zHeader.fileIndex; // doc["fileIndex"].GetUint64();
+ expLength = zHeader.expLength; // doc["expLength"].GetUint();
+ packetNumber =
+ zHeader.packetNumber; // doc["packetNumber"].GetUint();
+ detSpec1 = zHeader.detSpec1; // doc["detSpec1"].GetUint();
+ timestamp = zHeader.timestamp; // doc["timestamp"].GetUint();
+ modId = zHeader.modId; // doc["modId"].GetUint();
+ detSpec3 = zHeader.detSpec3; // doc["detSpec3"].GetUint();
+ // detSpec4=r.detSpec4;//doc["detSpec4"].GetUint();
+ detType = zHeader.detType; // doc["detType"].GetUint();
+ version = zHeader.version; // doc["version"].GetUint();
+ /*document["bitmode"].GetUint(); zHeader.dynamicRange
- string fname;
- // int length;
- int *detimage = NULL;
- int nnx, nny, nnsx, nnsy;
- // uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0,
- // uint32_t dynamicRange = 0;
- // infinite loop
- uint32_t packetNumber = 0;
- uint64_t bunchId = 0;
- uint64_t timestamp = 0;
- int16_t modId = 0;
- uint32_t expLength = 0;
- uint16_t xCoord = 0;
- uint16_t yCoord = 0;
- // uint16_t zCoord = 0;
- uint32_t debug = 0;
- // uint32_t dr = 16;
- // int16_t *dout;//=new int16_t [nnx*nny];
- uint32_t dr = 32;
- int32_t *dout = NULL; //=new int32_t [nnx*nny];
- float *doutf = NULL; //=new int32_t [nnx*nny];
- uint16_t roundRNumber = 0;
- uint8_t detType = 0;
- uint8_t version = 0;
- string additionalJsonHeader = "";
- int32_t threshold = 0;
+ */
- int32_t xmin = 0, xmax = 400, ymin = 0, ymax = 400;
+ // strcpy(fname,filename.c_str());
+ fname = filename;
+ addJsonHeader = zHeader.addJsonHeader;
- string frameMode_s, detectorMode_s, intMode_s;
-
- // int resetFlat=0;
- // int resetPed=0;
- // int nsubPixels=1;
- // int isPedestal=0;
- // int isFlat=0;
- int newFrame = 1;
- detectorMode dMode = eAnalog;
- frameMode fMode = eFrame;
- double *ped;
-
- filter->getImageSize(nnx, nny, nnsx, nnsy);
-
- std::map addJsonHeader;
-
- while (1) {
-
- // cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
- // get header, (if dummy, fail is on parse error or end of acquisition)
-
- // rapidjson::Document doc;
- if (!zmqsocket->ReceiveHeader(0, zHeader,
- SLS_DETECTOR_JSON_HEADER_VERSION)) {
- /* zmqsocket->CloseHeaderMessage();*/
-
- // if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex,
- //subframeIndex, filename, fileindex)) {
- cprintf(RED, "Got Dummy\n");
- // t1=high_resolution_clock::now();
- // time(&end);
- // cout << "Measurement lasted " << difftime(end,begin) << endl;
-
- end = std::chrono::steady_clock::now();
- cout << "Measurement lasted " << (end - begin).count() * 0.000001
- << " ms" << endl;
-
- while (mt->isBusy()) {
- ;
- } // wait until all data are processed from the queues
-
- if (of) {
- mt->setFilePointer(NULL);
- fclose(of);
- of = NULL;
- }
- if (newFrame > 0) {
- cprintf(RED, "DIDn't receive any data!\n");
- if (send) {
-
- // zHeader.data = false;
- outHeader.data = false;
- // zmqsocket2->SendHeaderData(0, true,
- // SLS_DETECTOR_JSON_HEADER_VERSION);
- zmqsocket2->SendHeader(0, outHeader);
- cprintf(RED, "Sent Dummy\n");
- }
- } else {
- send_something = 0;
- if (fMode == ePedestal) {
- sprintf(ofname, "%s_%ld_ped.tiff", fname.c_str(),
- fileindex);
- mt->writePedestal(ofname);
- cout << "Writing pedestal to " << ofname << endl;
- if (rms) {
- sprintf(ofname, "%s_%ld_var.tiff", fname.c_str(),
- fileindex);
- mt->writePedestalRMS(ofname);
- }
- send_something = 1;
- }
+ rms = 0;
+ fMode = eFrame;
+ frameMode_s = "frame";
+ cprintf(MAGENTA, "Frame mode: ");
+ // if (doc.HasMember("frameMode")) {
+ if (addJsonHeader.find("frameMode") != addJsonHeader.end()) {
+ // if (doc["frameMode"].IsString()) {
+ frameMode_s = addJsonHeader.at(
+ "frameMode"); // doc["frameMode"].GetString();
+ if (frameMode_s == "pedestal") {
+ fMode = ePedestal;
+ // isPedestal=1;
+ } else if (frameMode_s == "newPedestal") {
+ mt->newDataSet(); // resets pedestal
+ // cprintf(MAGENTA, "Resetting pedestal\n");
+ fMode = ePedestal;
+ // isPedestal=1;
+ } else if (frameMode_s == "variance") {
+ mt->newDataSet(); // resets pedestal
+ // cprintf(MAGENTA, "Resetting pedestal\n");
+ fMode = ePedestal;
+ // isPedestal=1;
+ rms = 1;
+ } else if (frameMode_s == "raw") {
+ // mt->newDataSet(); //resets pedestal
+ // cprintf(MAGENTA, "Resetting pedestal\n");
+ fMode = eRaw;
+ // isPedestal=1;
+ }
#ifdef INTERP
- else if (fMode == eFlat) {
- mt->prepareInterpolation(ok);
- sprintf(ofname, "%s_%ld_eta.tiff", fname.c_str(),
- fileindex);
- mt->writeFlatField(ofname);
- cout << "Writing eta to " << ofname << endl;
- send_something = 1;
- }
-#endif
- else {
- if (subframes > 0) {
- if (insubframe > 0) {
- sprintf(ofname, "%s_sf%ld_%ld.tiff", fname.c_str(),
- nnsubframe, fileindex);
- // mt->writeImage(ofname);
- doutf = new float[nnx * nny];
- if (subframes > 0 && insubframe != subframes &&
- insubframe > 0)
- subnorm =
- ((double)subframes) / ((double)insubframe);
- else
- subnorm = 1.;
- for (int ix = 0; ix < nnx * nny; ix++) {
- doutf[ix] = detimage[ix] * subnorm;
- if (doutf[ix] < 0)
- doutf[ix] = 0;
- }
+ else if (frameMode_s == "flatfield") {
+ fMode = eFlat;
+ // isFlat=1;
+ } else if (frameMode_s == "newFlatfield") {
+ mt->resetFlatField();
+ // isFlat=1;
+ cprintf(MAGENTA, "Resetting flatfield\n");
+ fMode = eFlat;
+ }
+ //#endif
+ else {
+ // isPedestal=0;
+ // isFlat=0;
+ fMode = eFrame;
+ frameMode_s = "frame";
+ }
+ //}
+ }
+ cprintf(MAGENTA, "%s\n", frameMode_s.c_str());
+ mt->setFrameMode(fMode);
- cout << "Writing image to " << ofname << endl;
+ // threshold=0;
+ cprintf(MAGENTA, "Threshold: ");
+ if (addJsonHeader.find("threshold") != addJsonHeader.end()) {
+ istringstream(addJsonHeader.at("threshold")) >> threshold;
+ }
+ mt->setThreshold(threshold);
+ cprintf(MAGENTA, "%d\n", threshold);
+
+ cprintf(MAGENTA, "subframes: ");
+ if (addJsonHeader.find("subframes") != addJsonHeader.end()) {
+ istringstream(addJsonHeader.at("subframes")) >> subframes;
+ }
+
+ cprintf(MAGENTA, "%d\n", subframes);
+
- WriteToTiff(doutf, ofname, nnx, nny);
- if (doutf)
- delete[] doutf;
- doutf = NULL;
- nsubframes++;
- insubframe = 0;
- send_something = 1;
- }
- } else {
- sprintf(ofname, "%s_%ld.tiff", fname.c_str(),
- fileindex);
- mt->writeImage(ofname);
- send_something = 1;
- }
+ xmin = 0;
+ xmax = npx;
+ ymin = 0;
+ ymax = npy;
+ cprintf(MAGENTA, "ROI: ");
- cout << "Writing image to " << ofname << endl;
- }
- // cout << nns*nnx*nny*nns*dr/8 << " " << length << endl;
+ if (addJsonHeader.find("roi") != addJsonHeader.end()) {
+ istringstream(addJsonHeader.at("roi")) >> xmin >> xmax >>
+ ymin >> ymax;
+ }
- if (send) {
-
- if (fMode == ePedestal) {
- cprintf(MAGENTA, "Get pedestal!\n");
- nnsx = 1;
- nnsy = 1;
-
- nnx = npx;
- nny = npy;
- // dout= new int16_t[nnx*nny*nns*nns];
- dout = new int32_t[nnx * nny * nnsx * nnsy];
- // cout << "get pedestal " << endl;
- ped = mt->getPedestal();
- // cout << "got pedestal " << endl;
- for (int ix = 0; ix < nnx * nny; ix++) {
-
- dout[ix] = ped[ix];
- // if (ix<100*400)
- // cout << ix << " " << ped[ix] << endl;
- }
-
- }
+ cprintf(MAGENTA, "%d %d %d %d\n", xmin, xmax, ymin, ymax);
+ mt->setROI(xmin, xmax, ymin, ymax);
+ if (addJsonHeader.find("dynamicRange") != addJsonHeader.end()) {
+ istringstream(addJsonHeader.at("dynamicRange")) >> dr;
+ dr = 32;
+ }
+ dMode = eAnalog;
+ detectorMode_s = "analog";
+ cprintf(MAGENTA, "Detector mode: ");
+ if (addJsonHeader.find("detectorMode") != addJsonHeader.end()) {
+ ;
+ detectorMode_s = addJsonHeader.at(
+ "detectorMode"); //=doc["detectorMode"].GetString();
#ifdef INTERP
- else if (fMode == eFlat) {
- int nb;
- double emi = 0, ema = 1;
- int *ff = mt->getFlatField(nb, emi, ema);
- nnx = nb;
- nny = nb;
- dout = new int32_t[nb * nb];
- for (int ix = 0; ix < nb * nb; ix++) {
- dout[ix] = ff[ix];
- }
- }
+ if (detectorMode_s == "interpolating") {
+ dMode = eInterpolating;
+ mt->setInterpolation(interp);
+ } else
#endif
- else {
- detimage = mt->getImage(nnx, nny, nnsx, nnsy);
- cprintf(MAGENTA, "Get image!\n");
- cout << nnx << " " << nny << " " << nnsx << " " << nnsy
- << endl;
- // nns=1;
- // nnx=npx;
- // nny=npy;
- // nnx=nnx*nns;
- // nny=nny*nns;
- dout = new int32_t[nnx * nny];
- if (subframes > 0 && insubframe != subframes &&
- insubframe > 0)
- subnorm =
- ((double)subframes) / ((double)insubframe);
- else
- subnorm = 1.;
- for (int ix = 0; ix < nnx * nny; ix++) {
- // for (int iy=0; iy0 && subframes>0) || (subframes<=0) ){
-
- if (send_something) {
-
- // zmqsocket2->SendHeaderData (0,
- // false,SLS_DETECTOR_JSON_HEADER_VERSION , dr,
- // fileindex, 1,1,nnx,nny,nnx*nny*dr/8,acqIndex,
- // frameIndex, fname,acqIndex,0 , packetNumber,bunchId,
- // timestamp, modId,xCoord, yCoord, zCoord,debug,
- // roundRNumber, detType, version, 0,0,
- // 0,&additionalJsonHeader);
-
- outHeader.data = true;
- outHeader.dynamicRange = dr;
- outHeader.fileIndex = fileindex;
- outHeader.ndetx = 1;
- outHeader.ndety = 1;
- outHeader.npixelsx = nnx;
- outHeader.npixelsy = nny;
- outHeader.imageSize = nnx * nny * dr / 8;
- outHeader.acqIndex = acqIndex;
- outHeader.frameIndex = frameIndex;
- outHeader.fname = fname;
- outHeader.frameNumber = acqIndex;
- outHeader.expLength = expLength;
- outHeader.packetNumber = packetNumber;
- outHeader.bunchId = bunchId;
- outHeader.timestamp = timestamp;
- outHeader.modId = modId;
- outHeader.row = xCoord;
- outHeader.column = yCoord;
- outHeader.debug = debug;
- outHeader.roundRNumber = roundRNumber;
- outHeader.detType = detType;
- outHeader.version = version;
-
- zmqsocket2->SendHeader(0, outHeader);
- zmqsocket2->SendData((char *)dout, nnx * nny * dr / 8);
- cprintf(GREEN, "Sent Data\n");
- }
- outHeader.data = false;
- zmqsocket2->SendHeader(0, outHeader);
- // zmqsocket2->SendHeaderData(0, true,
- // SLS_DETECTOR_JSON_HEADER_VERSION);
- cprintf(RED, "Sent Dummy\n");
- if (dout)
- delete[] dout;
- dout = NULL;
- }
- }
-
- mt->clearImage();
-
- newFrame = 1;
-
- // time(&finished);
- // cout << "Processing lasted " << difftime(finished,begin) << endl;
-
- finished = std::chrono::steady_clock::now();
- cout << "Processing lasted "
- << (finished - begin).count() * 0.000001 << " ms" << endl;
-#ifdef OPTIMIZE
- return 0;
-#endif
- continue; // continue to not get out
- }
-
- //#ifdef NEWZMQ
- if (newFrame) {
- begin = std::chrono::steady_clock::now();
-
- size = zHeader.imageSize; // doc["size"].GetUint();
-
- // dynamicRange = zheader.dynamicRange; //doc["bitmode"].GetUint();
- // nPixelsX = zHeader.npixelsx; //doc["shape"][0].GetUint();
- // nPixelsY = zHeader.npixelsy;// doc["shape"][1].GetUint();
- filename = zHeader.fname; // doc["fname"].GetString();
- acqIndex =
- zHeader
- .acqIndex; // doc["acqIndex"].GetUint64();
- // frameIndex =
- // zHeader.frameIndex;//doc["fIndex"].GetUint64();
- fileindex = zHeader.fileIndex; // doc["fileIndex"].GetUint64();
- expLength = zHeader.expLength; // doc["expLength"].GetUint();
- packetNumber =
- zHeader.packetNumber; // doc["packetNumber"].GetUint();
- bunchId = zHeader.bunchId; // doc["bunchId"].GetUint();
- timestamp = zHeader.timestamp; // doc["timestamp"].GetUint();
- modId = zHeader.modId; // doc["modId"].GetUint();
- debug = zHeader.debug; // doc["debug"].GetUint();
- // roundRNumber=r.roundRNumber;//doc["roundRNumber"].GetUint();
- detType = zHeader.detType; // doc["detType"].GetUint();
- version = zHeader.version; // doc["version"].GetUint();
- /*document["bitmode"].GetUint(); zHeader.dynamicRange
-
-document["fileIndex"].GetUint64(); zHeader.fileIndex
-
-document["detshape"][0].GetUint();
-zHeader.ndetx
-
-document["detshape"][1].GetUint();
-zHeader.ndety
-
-document["shape"][0].GetUint();
-zHeader.npixelsx
-
-document["shape"][1].GetUint();
-zHeader.npixelsy
-
-document["size"].GetUint(); zHeader.imageSize
-
-document["acqIndex"].GetUint64(); zHeader.acqIndex
-
-document["frameIndex"].GetUint64(); zHeader.frameIndex
-
-document["fname"].GetString(); zHeader.fname
-
-document["frameNumber"].GetUint64(); zHeader.frameNumber
-
-document["expLength"].GetUint(); zHeader.expLength
-
-document["packetNumber"].GetUint(); zHeader.packetNumber
-
-document["bunchId"].GetUint64(); zHeader.bunchId
-
-document["timestamp"].GetUint64(); zHeader.timestamp
-
-document["modId"].GetUint(); zHeader.modId
-
-document["row"].GetUint(); zHeader.row
-
-document["column"].GetUint(); zHeader.column
-
-document["reserved"].GetUint(); zHeader.reserved
-
-document["debug"].GetUint(); zHeader.debug
-
-document["roundRNumber"].GetUint(); zHeader.roundRNumber
-
-document["detType"].GetUint(); zHeader.detType
-
-document["version"].GetUint(); zHeader.version
-
-document["flippedDataX"].GetUint(); zHeader.flippedDataX
-
-document["quad"].GetUint(); zHeader.quad
-
-document["completeImage"].GetUint(); zHeader.completeImage
- */
- // dataSize=size;
-
- // strcpy(fname,filename.c_str());
- fname = filename;
- // cprintf(BLUE, "Header Info:\n"
- // "size: %u\n"
- // "multisize: %u\n"
- // "dynamicRange: %u\n"
- // "nPixelsX: %u\n"
- // "nPixelsY: %u\n"
- // "currentFileName: %s\n"
- // "currentAcquisitionIndex: %lu\n"
- // "currentFrameIndex: %lu\n"
- // "currentFileIndex: %lu\n"
- // "currentSubFrameIndex: %u\n"
- // "xCoordX: %u\n"
- // "yCoordY: %u\n"
- // "zCoordZ: %u\n"
- // "flippedDataX: %u\n"
- // "packetNumber: %u\n"
- // "bunchId: %u\n"
- // "timestamp: %u\n"
- // "modId: %u\n"
- // "debug: %u\n"
- // "roundRNumber: %u\n"
- // "detType: %u\n"
- // "version: %u\n",
- // size, multisize, dynamicRange, nPixelsX, nPixelsY,
- // filename.c_str(), acqIndex,
- // frameIndex, fileindex, subFrameIndex,
- // xCoord, yCoord,zCoord,
- // flippedDataX, packetNumber, bunchId, timestamp, modId,
- // debug, roundRNumber, detType, version);
-
- addJsonHeader = zHeader.addJsonHeader;
-
- /* Analog detector commands */
- // isPedestal=0;
- // isFlat=0;
- rms = 0;
- fMode = eFrame;
- frameMode_s = "frame";
- cprintf(MAGENTA, "Frame mode: ");
- // if (doc.HasMember("frameMode")) {
- if (addJsonHeader.find("frameMode") != addJsonHeader.end()) {
- // if (doc["frameMode"].IsString()) {
- frameMode_s = addJsonHeader.at(
- "frameMode"); // doc["frameMode"].GetString();
- if (frameMode_s == "pedestal") {
- fMode = ePedestal;
- // isPedestal=1;
- } else if (frameMode_s == "newPedestal") {
- mt->newDataSet(); // resets pedestal
- // cprintf(MAGENTA, "Resetting pedestal\n");
- fMode = ePedestal;
- // isPedestal=1;
- } else if (frameMode_s == "variance") {
- mt->newDataSet(); // resets pedestal
- // cprintf(MAGENTA, "Resetting pedestal\n");
- fMode = ePedestal;
- // isPedestal=1;
- rms = 1;
- }
+ if (detectorMode_s == "counting") {
+ dMode = ePhotonCounting;
#ifdef INTERP
- else if (frameMode_s == "flatfield") {
- fMode = eFlat;
- // isFlat=1;
- } else if (frameMode_s == "newFlatfield") {
- mt->resetFlatField();
- // isFlat=1;
- cprintf(MAGENTA, "Resetting flatfield\n");
- fMode = eFlat;
- }
- //#endif
- else {
- fMode = eFrame;
- // isPedestal=0;
- // isFlat=0;
- fMode = eFrame;
- frameMode_s = "frame";
- }
- //}
- }
- cprintf(MAGENTA, "%s\n", frameMode_s.c_str());
- mt->setFrameMode(fMode);
-
- // threshold=0;
- cprintf(MAGENTA, "Threshold: ");
- if (addJsonHeader.find("threshold") != addJsonHeader.end()) {
- istringstream(addJsonHeader.at("threshold")) >> threshold;
- // threshold=atoi(addJsonHeader.at("threshold").c_str());//doc["frameMode"].GetString();
- }
- // if (doc.HasMember("threshold")) {
- // if (doc["threshold"].IsInt()) {
- // threshold=doc["threshold"].GetInt();
- mt->setThreshold(threshold);
- // }
- // }
- cprintf(MAGENTA, "%d\n", threshold);
-
- xmin = 0;
- xmax = npx;
- ymin = 0;
- ymax = npy;
- cprintf(MAGENTA, "ROI: ");
-
- if (addJsonHeader.find("roi") != addJsonHeader.end()) {
- istringstream(addJsonHeader.at("roi")) >> xmin >> xmax >>
- ymin >> ymax;
- // if (doc.HasMember("roi")) {
- // if (doc["roi"].IsArray()) {
- // if (doc["roi"].Size() > 0 )
- // if (doc["roi"][0].IsInt())
- // xmin=doc["roi"][0].GetInt();
-
- // if (doc["roi"].Size() > 1 )
- // if (doc["roi"][1].IsInt())
- // xmax=doc["roi"][1].GetInt();
-
- // if (doc["roi"].Size() > 2 )
- // if (doc["roi"][2].IsInt())
- // ymin=doc["roi"][2].GetInt();
-
- // if (doc["roi"].Size() > 3 )
- // if (doc["roi"][3].IsInt())
- // ymax=doc["roi"][3].GetInt();
- // }
- }
-
- cprintf(MAGENTA, "%d %d %d %d\n", xmin, xmax, ymin, ymax);
- mt->setROI(xmin, xmax, ymin, ymax);
- if (addJsonHeader.find("dynamicRange") != addJsonHeader.end()) {
- istringstream(addJsonHeader.at("dynamicRange")) >> dr;
- dr = 32;
- }
- // if (doc.HasMember("dynamicRange")) {
- // dr=doc["dynamicRange"].GetUint();
- // dr=32;
- // }
-
- dMode = eAnalog;
- detectorMode_s = "analog";
- cprintf(MAGENTA, "Detector mode: ");
- if (addJsonHeader.find("detectorMode") != addJsonHeader.end()) {
- ;
- // if (doc.HasMember("detectorMode")) {
- // if (doc["detectorMode"].IsString()) {
- detectorMode_s = addJsonHeader.at(
- "detectorMode"); //=doc["detectorMode"].GetString();
+ mt->setInterpolation(NULL);
+#endif
+ } else {
+ dMode = eAnalog;
#ifdef INTERP
- if (detectorMode_s == "interpolating") {
- dMode = eInterpolating;
- mt->setInterpolation(interp);
- } else
+ mt->setInterpolation(NULL);
#endif
- if (detectorMode_s == "counting") {
- dMode = ePhotonCounting;
-#ifdef INTERP
- mt->setInterpolation(NULL);
-#endif
- } else {
- dMode = eAnalog;
-#ifdef INTERP
- mt->setInterpolation(NULL);
-#endif
- }
- // }
- }
+ }
+ // }
+ if (fMode == eRaw) {
+ detectorMode_s = "analog";
+ dMode = eAnalog;
+ }
+ }
- mt->setDetectorMode(dMode);
- cprintf(MAGENTA, "%s\n", detectorMode_s.c_str());
+ mt->setDetectorMode(dMode);
+ cprintf(MAGENTA, "%s\n", detectorMode_s.c_str());
- // cout << "done " << endl;
+ cout << "done " << endl;
- // /* Single Photon Detector commands */
- // nSigma=5;
- // if (doc.HasMember("nSigma")) {
- // if (doc["nSigma"].IsInt())
- // nSigma=doc["nSigma"].GetInt();
- // mt->setNSigma(nSigma);
- // }
+ /* Single Photon Detector commands */
+ nSigma = 5;
- // emin=-1;
- // emax=-1;
- // if (doc.HasMember("energyRange")) {
- // if (doc["energyRange"].IsArray()) {
- // if (doc["energyRange"].Size() > 0 )
- // if (doc["energyRange"][0].IsInt())
- // emin=doc["energyRange"][0].GetInt();
+ if (addJsonHeader.find("nSigma") != addJsonHeader.end()) {
+ ;
+ istringstream(addJsonHeader.at("nSigma")) >> nSigma;
+ mt->setNSigma(nSigma);
+ }
- // if (doc["energyRange"].Size() > 1 )
- // if (doc["energyRange"][1].IsInt())
- // emax=doc["energyRange"][1].GetUint();
- // }
- // }
- // if (doc.HasMember("eMin")) {
- // if (doc["eMin"][1].IsInt())
- // emin=doc["eMin"].GetInt();
- // }
- // if (doc.HasMember("eMax")) {
- // if (doc["eMax"][1].IsInt())
- // emin=doc["eMax"].GetInt();
- // }
- // mt->setEnergyRange(emin,emax);
+ emin = -1;
+ emax = -1;
+ if (addJsonHeader.find("energyRange") != addJsonHeader.end()) {
+ istringstream(addJsonHeader.at("energyRange")) >> emin >> emax;
+ }
+ if (addJsonHeader.find("eMin") != addJsonHeader.end()) {
+ istringstream(addJsonHeader.at("eMin")) >> emin;
+ }
- // /* interpolating detector commands */
+ if (addJsonHeader.find("eMax") != addJsonHeader.end()) {
+ istringstream(addJsonHeader.at("eMax")) >> emax;
+ }
- // if (doc.HasMember("nSubPixels")) {
- // if (doc["nSubPixels"].IsUint())
- // nSubPixels=doc["nSubPixels"].GetUint();
- // mt->setNSubPixels(nSubPixels);
- // }
+ mt->setEnergyRange(emin, emax);
- // threshold=0;
- // cprintf(MAGENTA, "Subframes: ");
- // subframes=0;
- // //isubframe=0;
- // insubframe=0;
- // subnorm=1;
- // f0=0;
- // nnsubframe=0;
- // if (doc.HasMember("subframes")) {
- // if (doc["subframes"].IsInt()) {
- // subframes=doc["subframes"].GetInt();
- // }
- // }
- // cprintf(MAGENTA, "%ld\n", subframes);
+ /* interpolating detector commands */
+ // must set subpixels X and Y separately
+ // if (addJsonHeader.find("nSubPixels")!= addJsonHeader.end()) {
+ // istringstream(addJsonHeader.at("nSubPixels")) >>
+ // nSubPixels ; mt->setNSubPixels(nSubPixels);
+ // }
- newFrame = 0;
- /* zmqsocket->CloseHeaderMessage();*/
- }
+ threshold = 0;
+ cprintf(MAGENTA, "Subframes: ");
+ subframes = 0;
+ // isubframe=0;
+ insubframe = 0;
+ subnorm = 1;
+ f0 = 0;
+ nnsubframe = 0;
+ if (addJsonHeader.find("subframes") != addJsonHeader.end()) {
+ istringstream(addJsonHeader.at("subframes")) >> subframes;
+ }
+
+ cprintf(MAGENTA, "%ld\n", subframes);
+
+ newFrame = 0;
+ }
#endif
- // cout << "file" << endl;
- // cout << "data " << endl;
- if (of == NULL) {
-#ifdef WRITE_QUAD
- sprintf(ofname, "%s_%ld.clust2", filename.c_str(), fileindex);
-#endif
-#ifndef WRITE_QUAD
- sprintf(ofname, "%s_%ld.clust", filename.c_str(), fileindex);
-#endif
- of = fopen(ofname, "w");
- if (of) {
- mt->setFilePointer(of);
- } else {
- cout << "Could not open " << ofname << " for writing " << endl;
- mt->setFilePointer(NULL);
- }
- }
+ frameIndex = zHeader.frameIndex; ////doc["fIndex"].GetUint64();
- // cout << "data" << endl;
- // get data
- // acqIndex = doc["acqIndex"].GetUint64();
+ // subFrameIndex = doc["expLength"].GetUint();
- frameIndex = zHeader.frameIndex; ////doc["fIndex"].GetUint64();
+ // detSpec1=doc["detSpec1"].GetUint();
+ // timestamp=doc["timestamp"].GetUint();
+ packetNumber = zHeader.packetNumber; // doc["packetNumber"].GetUint();
+ // cout << acqIndex << " " << frameIndex << " " << subFrameIndex << "
+ // "<< detSpec1 << " " << timestamp << " " << packetNumber << endl;
+ // cprintf(GREEN, "frame\n");
+ if (packetNumber >= 40) {
+ //*((int*)buff)=frameIndex;
+ if (insubframe == 0)
+ f0 = frameIndex;
+ memcpy(buff, &frameIndex, sizeof(int));
+ // length =
+ zmqsocket->ReceiveData(0, buff + sizeof(int), size);
- // subFrameIndex = doc["expLength"].GetUint();
+ mt->setFilePointer(NULL);
- // bunchId=doc["bunchId"].GetUint();
- // timestamp=doc["timestamp"].GetUint();
- packetNumber = zHeader.packetNumber; // doc["packetNumber"].GetUint();
- // cout << acqIndex << " " << frameIndex << " " << subFrameIndex << "
- // "<< bunchId << " " << timestamp << " " << packetNumber << endl;
- // cprintf(GREEN, "frame\n");
- if (packetNumber >= 40) {
- //*((int*)buff)=frameIndex;
- if (insubframe == 0)
- f0 = frameIndex;
- memcpy(buff, &frameIndex, sizeof(int));
- // length =
- zmqsocket->ReceiveData(0, buff + sizeof(int), size);
- mt->pushData(buff);
- mt->nextThread();
- mt->popFree(buff);
- insubframe++;
- nsubframes = frameIndex + 1 - f0;
- } else {
- cprintf(RED, "Incomplete frame: received only %d packet\n",
- packetNumber);
- // length =
- zmqsocket->ReceiveData(0, dummybuff, size);
- }
+ mt->pushData(buff);
+ mt->nextThread();
+ mt->popFree(buff);
+ insubframe++;
+ nsubframes = frameIndex + 1 - f0;
+ // cout << "insubframe " << insubframe << endl;
+ // cout << "nsubframes " << nsubframes << endl;
+ // cout << "f0 " << f0 << endl;
+ // cout << "frameIndex " << frameIndex << endl;
- if (subframes > 0 && insubframe >= subframes && fMode == eFrame) {
- while (mt->isBusy()) {
- ;
- } // wait until all data are processed from the queues
- detimage = mt->getImage(nnx, nny, nnsx, nnsy);
- cprintf(MAGENTA, "Get image!\n");
- dout = new int32_t[nnx * nny];
- doutf = new float[nnx * nny];
- if (subframes > 0 && insubframe != subframes && insubframe > 0)
- subnorm = ((double)subframes) / ((double)insubframe);
- else
- subnorm = 1.;
- for (int ix = 0; ix < nnx * nny; ix++) {
- dout[ix] = detimage[ix] * subnorm;
- if (dout[ix] < 0)
- dout[ix] = 0;
- doutf[ix] = dout[ix];
- }
- sprintf(ofname, "%s_sf%ld_%ld.tiff", fname.c_str(), nnsubframe,
- fileindex);
+ } else {
+ cprintf(RED, "Incomplete frame: received only %d packet\n",
+ packetNumber);
+ // length =
+ zmqsocket->ReceiveData(0, dummybuff, size);
+ }
- cout << "Writing image to " << ofname << endl;
+ if (subframes > 0 && insubframe >= subframes &&
+ (fMode == eFrame || fMode == eRaw)) {
+ while (mt->isBusy()) {
+ ;
+ } // wait until all data are processed from the queues
+ usleep(100);
- WriteToTiff(doutf, ofname, nnx, nny);
- nsubframes++;
- insubframe = 0;
- nnsubframe++;
+ detimage = mt->getImage(nnx, nny, nnsx, nnsy);
- // zmqsocket2->SendHeaderData (0,
- // false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex,
- // 1,1,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0
- // , packetNumber,bunchId, timestamp, modId,xCoord, yCoord,
- // zCoord,debug, roundRNumber, detType, version, 0,0,
- // 0,&additionalJsonHeader);
- zHeader.data = true;
- zmqsocket2->SendHeader(0, zHeader);
- zmqsocket2->SendData((char *)dout, nnx * nny * dr / 8);
- cprintf(GREEN, "Sent subdata\n");
+ cprintf(MAGENTA, "Get image!\n");
+ dout = new int32_t[nnx * nny];
+ doutf = new float[nnx * nny];
+ if (subframes > 0 && insubframe != subframes && insubframe > 0)
+ subnorm = ((double)subframes) / ((double)insubframe);
+ else
+ subnorm = 1.;
+ for (int ix = 0; ix < nnx * nny; ix++) {
+ dout[ix] = detimage[ix] * subnorm;
+ if (dout[ix] < 0)
+ dout[ix] = 0;
+ doutf[ix] = dout[ix];
+ }
+ sprintf(ofname, "%s_sf%ld_%ld.tiff", fname.c_str(), nnsubframe,
+ fileindex);
- if (dout)
- delete[] dout;
- dout = NULL;
+ cout << "Writing image to " << ofname << endl;
- if (doutf)
- delete[] doutf;
- doutf = NULL;
+ WriteToTiff(doutf, ofname, nnx, nny);
+ nsubframes++;
+ insubframe = 0;
+ nnsubframe++;
- mt->clearImage();
- }
+ // zmqsocket2->SendHeaderData (0,
+ // false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex,
+ // 1,1,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0
+ // , packetNumber,detSpec1, timestamp, modId,xCoord, yCoord,
+ // zCoord,detSpec3, detSpec4, detType, version, 0,0,
+ // 0,&additionalJsonHeader);
- iframe++;
+ // zmqsocket2->SendHeaderData (0,
+ // false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex,
+ // 1,1,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0
+ // , packetNumber,detSpec1, timestamp, modId,xCoord, yCoord,
+ // zCoord,detSpec3, detSpec4, detType, version, 0,0,
+ // 0,&additionalJsonHeader);
- } // exiting infinite loop
+ outHeader.data = true;
+ outHeader.dynamicRange = dr;
+ outHeader.fileIndex = fileindex;
+ outHeader.ndetx = 1;
+ outHeader.ndety = 1;
+ outHeader.npixelsx = nnx;
+ outHeader.npixelsy = nny;
+ outHeader.imageSize = nnx * nny * dr / 8;
+ outHeader.acqIndex = acqIndex;
+ outHeader.frameIndex = frameIndex;
+ outHeader.fname = fname;
+ outHeader.frameNumber = acqIndex;
+ outHeader.expLength = expLength;
+ outHeader.packetNumber = packetNumber;
+ outHeader.detSpec1 = detSpec1;
+ outHeader.timestamp = timestamp;
+ outHeader.modId = modId;
+ outHeader.row = xCoord;
+ outHeader.column = yCoord;
+ outHeader.detSpec3 = detSpec3;
+ outHeader.detSpec4 = detSpec4;
+ outHeader.detType = detType;
+ outHeader.version = version;
- delete zmqsocket;
- if (send)
- delete zmqsocket2;
+ zmqsocket2->SendHeader(0, outHeader);
+ zmqsocket2->SendData((char *)dout, nnx * nny * dr / 8);
+ cprintf(GREEN, "Sent subdata\n");
- cout << "Goodbye" << endl;
- return 0;
+ if (dout)
+ delete[] dout;
+ dout = NULL;
+
+ if (doutf)
+ delete[] doutf;
+ doutf = NULL;
+
+ mt->clearImage();
+ }
+
+ iframe++;
+
+ } // exiting infinite loop
+
+ delete zmqsocket;
+ if (send)
+ delete zmqsocket2;
+
+ cout << "Goodbye" << endl;
+ return 0;
}
diff --git a/slsDetectorCalibration/jungfrauExecutables/onlinedisp_zmq.cpp b/slsDetectorCalibration/jungfrauExecutables/onlinedisp_zmq.cpp
new file mode 100644
index 000000000..d63105080
--- /dev/null
+++ b/slsDetectorCalibration/jungfrauExecutables/onlinedisp_zmq.cpp
@@ -0,0 +1,679 @@
+#include "onlinedisp_zmq.h"
+bool hasallpede;
+TH1F * his102;TH1F * his101;
+int processedf;
+sls::zmqHeader zHeader;
+#define PEDEFNAME "current_pede.dat"
+#define NPRO 50
+#define NPRI 50
+
+//#define JFSTRX
+#ifdef JFSTRX
+#include "jungfrauLGADStrixelsData.h"
+#else
+#include "jungfrauModuleData.h"
+#endif
+
+
+
+int main(int argc, char* argv[])
+{
+ goout=1;
+ hasallpede=false;
+ dophotonmap=true; if ((argc<3)) {printf("USAGE: command photon_energy_(peakinADC) [rx_ip] [port] \n"); return -1 ;}
+ else {
+ phene=atoi(argv[1]);
+ if (phene<0) dophotonmap=false;
+ threshold=float (phene/2);
+ printf( " \n");
+ printf( "phene %d \n",phene);
+ }
+
+ if (argc>=3) {
+ strcpy(serverip,argv[2]);
+ printf("ip is %s ",serverip);
+ }
+
+ portnum=30001;
+ if (argc>=4 ){ portnum= atoi(argv[3]);
+ }
+ printf(", port number is %d ",portnum); printf(". \n");
+
+
+#ifdef JFSTRX
+ cout << "JFSTRX" << endl;
+ jungfrauLGADStrixelsData *decoder = new jungfrauLGADStrixelsData();
+ nx = 1024/5; ny= 512*5;
+#else
+ nx = 1024; ny= 512;
+#endif
+
+
+
+
+ gain_flag=false;
+ pede_flag=false;
+ bw_flag=false;
+
+ HDraw_every=20;
+ fixranges=false;
+
+
+ hchptr = (short*) malloc(NCH*sizeof(short));
+
+ startsocket(); //create and connect ZMQ
+
+ for (ipx=0;ipxgetValue((char*)(hchptr),279,130)<SetOption("colz");
+ his2000= new TH2F("his2000","2d gain ",nx,-0.5,nx-0.5,ny,-0.5,ny-0.5);
+ his2000->GetZaxis()->SetRangeUser(0,4);
+
+ if (dophotonmap) {
+ his3000= new TH2F("his3000"," photon map ",nx,-0.5,nx-0.5,ny,-0.5,ny-0.5);
+ }
+ else {
+ his3000= new TH2F("his3000"," raw adc ",nx,-0.5,nx-0.5,ny,-0.5,ny-0.5);
+ }
+
+ his4500= new TH2F("his45000","L vs R",101,-50,500,101,-50,500);
+ hchip=new TH1I*[8];
+ for (i=0;i<8;i++) {
+ sprintf(hname,"hchip%d",i);
+ hchip[i] = new TH1I(hname,hname,NBIN,MIN_POS,MAX_POS);
+ }
+
+ cout <<"end of histo booking" <Clear();
+ A4->Divide(4,2,0.005,0.005);
+ if (A5==NULL) A5 = new TCanvas("A5","Plotting Canvas Photon Map",750,300,1000,600);
+ if (A6==NULL) A6 = new TCanvas("A6","Plotting Canvas LvsR",650,250,650,660);
+
+ gSystem->ProcessEvents();
+ int running=0;
+ char runc[15]="*\\-/|";
+ printhelp();
+
+
+
+ while (1==1) { // loop on streamed frames
+
+ if(!zmqSocket->ReceiveHeader(0,zHeader, SLS_DETECTOR_JSON_HEADER_VERSION)){
+ cout<< "Receiver stopped, waiting for new stream" << endl;
+ zmqSocket->Disconnect();
+ zmqSocket->Connect();
+ }
+ else {
+
+ // if (((icount++)%10)==0) cout <<"recived frameindex "<ReceiveData(0, (char *)(&image_data), NCH*2);
+ }
+
+ {
+
+ framesinstream++;
+ running++;
+
+ fill1Ds=true; //alway fill 1d and LR plots
+ //if (((framesinstream%(int(HDraw_every)))==(int (HDraw_every)-1))) {fill1Ds=true;}else{fill1Ds=false;}
+ if (((framesinstream%(HDraw_every))==(HDraw_every)-1)) {show2Ds=true;}else{show2Ds=false;}
+ if (((framesinstream%NPRI)==NPRI-1)) { cout<<"\r "<<"frame (from start): "<Reset();
+ his2000->Reset();
+ if (!dophotonmap) his3000->Reset(); //FOR RAW ADC DISPLAY
+ }
+
+
+ if ((fill1Ds)or(show2Ds)or(dophotonmap)) { // do something, otherwise skip to the next
+ processedf++;
+
+ for (i=0 ;i>14) & 0x3;} else {gain=0;}
+ if (pede_flag){
+
+ if (gain_flag)
+ {
+ if ((gain==0)||(!hasallpede)) adcpedecorr=(adcvalue&0x3fff)*fgaind[i]-fpeded[i]*fgaind[i];
+
+ if ((gain==1)&&hasallpede) adcpedecorr=(fpedeG1d[i]*fgaind[i]+G1Poffset-adcvalue*fgaind[i])*30.0;
+ if ((gain==3)&&hasallpede) adcpedecorr=(fpedeG2d[i]*fgaind[i]+G2Poffset-adcvalue*fgaind[i])*340.0;
+ }
+ else
+
+ {
+
+ if ((gain==0)||(!hasallpede)) adcpedecorr=(adcvalue&0x3fff)-fpeded[i];
+ if ((gain==1)&&hasallpede) adcpedecorr=(fpedeG1d[i]+G1Poffset-adcvalue)*30.0;
+ if ((gain==3)&&hasallpede) adcpedecorr=(fpedeG2d[i]+G2Poffset-adcvalue)*340.0;
+ }
+
+
+ } else {adcpedecorr=float (adcvalue);} //end of if pede
+
+
+
+
+ if ((adcpedecorr>threshold)&&(pede_flag)) hchptr[(i)]= hchptr[(i)]+(int)((adcpedecorr+threshold)/phene);
+
+
+ if (fill1Ds) {
+ if (((i%1024)<1004)&&((i%1024)>20)&&((i/1024)>20)) { //skip the pix near guardring for PH plots
+ ichip= i/(256*256*4)*4+((i/256)%4) ;
+
+ hchip[ichip]->Fill(adcpedecorr,1);
+
+ if (((i%256)<253)&&((i%256)>2)) his4500->Fill(adcpedecorrold,adcpedecorr,1);
+ adcpedecorrold=adcpedecorr;
+
+
+ }
+ }//if (fill1Ds)
+
+
+
+
+ if ((show2Ds)) {
+ factor=2.0;
+ value=adcpedecorr;
+ if ((i%256==0)||(i%256==255)) value=int(value/factor);
+ if ((i/1024==255)||(i/1024==256)||(i/1024==767)||(i/1024==768)) value=int(value/factor);
+
+ his1000->Fill(float(i%1024),float(int (i/1024)),value);
+
+ if (!dophotonmap) his3000->Fill(float(i%1024),float(int (i/1024)) ,adcvalue);
+
+ his2000->Fill(float(i%1024),float(int (i/1024)) ,gain);
+
+ value=(int)(hchptr[i]);
+
+ if ((i%256==0)||(i%256==255)) value=int(value/factor);
+ if ((i/1024==255)||(i/1024==256)||(i/1024==767)||(i/1024==768)) value=int(value/factor);
+ if (dophotonmap) his3000->Fill(float(i%1024),float(int (i/1024)),float(value));
+
+ }
+ }// for (i=0 ;iProcessEvents();
+
+
+ }
+
+
+
+
+
+ }// end of infinite loop
+
+ rootapp->Run();
+ nonblock(NB_DISABLE);
+ return 0;
+
+
+}
+void processifp(int ifp){
+
+ if (ifp!=0){
+ c=fgetc(stdin);
+ if (c=='s') {if (goout==0){goout=1;}else {myloop();}}
+ if (c=='S') SetRanges();
+ if (c=='+') { HDraw_every=HDraw_every*0.8;cout<< endl <<"Drawing every "<< HDraw_every<<" frames "<SetOption("surf2z");
+ if (c=='C') his1000->SetOption("colz");
+
+ if (c=='q') exit(0);
+ if (c=='r') historeset();
+ if (c=='R') axisreset();
+ }
+
+}
+void loadallpede(){
+ cout <<"not implemented "<< endl;
+ // hasallpede=true;
+
+ // system("./sls_detector_put setbit 0x5d 12 "); //setting to FSG1 ;
+
+ // loadpede();
+ // loadpede();
+ // for (i=0;iReceiveHeader(0,zHeader, SLS_DETECTOR_JSON_HEADER_VERSION)){
+ return;
+ }
+
+ cout <<"received frameindex "<ReceiveData(0, (char *)(&image_data), NCH*2);
+ framesinstream++;nframes++;
+ for (ipx=0;ipxProcessEvents();
+ usleep(5000);
+
+ }
+}
+void printhelp(){
+ cout<< endl << "s=start/pause| p/n=getnewpede/raw | o/O=read/save pede | n=nopede(raw) | r/R=rst His/Axis | +/- = faster/slower ref. |q=exit | U/C sUrf2/Colz " <Reset();
+ his3000->Reset();
+ for (i=0;i<8;i++) {
+ hchip[i]->Reset();
+
+ }
+ Plot2DHistos();
+ Plot1DHistos();
+
+}
+
+void SetRanges() {
+ string str;
+ std::cin.clear();
+ //cin.ignore(std::numeric_limits::max(), '\n');
+
+ cout<< endl;
+ cout<< " adc min " <> adcmin;
+ cout<< " adc max " <> adcmax;
+ cout<< " p.map min " <> pmmin;
+ cout<< " p.map max " <> pmmax;
+
+ fixranges=true;
+
+
+
+}
+
+
+void axisreset(){
+ fixranges=false;
+ his1000->GetXaxis()->UnZoom();
+
+ his1000->GetYaxis()->UnZoom();
+ his1000->GetZaxis()->UnZoom();
+ his2000->GetXaxis()->UnZoom();
+ his2000->GetYaxis()->UnZoom();
+
+ his3000->GetZaxis()->UnZoom();
+
+ for (i=0;i<8;i++) {
+ hchip[i]->GetXaxis()->UnZoom();
+ hchip[i]->GetYaxis()->UnZoom();
+ }
+
+ his4500->GetXaxis()->UnZoom();
+ his4500->GetYaxis()->UnZoom();
+ his4500->GetZaxis()->UnZoom();
+
+ Plot2DHistos();
+ Plot1DHistos();
+
+
+}
+
+
+
+
+
+void nonblock(int state)
+{
+ struct termios ttystate;
+ //get the terminal state
+ tcgetattr(STDIN_FILENO, &ttystate);
+ if (state==NB_ENABLE)
+ {
+ //turn off canonical mode
+ ttystate.c_lflag &= ~ICANON;
+ //minimum of number input read.
+ ttystate.c_cc[VMIN] = 1;
+ }
+ else if (state==NB_DISABLE)
+ { //turn on canonical mode
+ ttystate.c_lflag |= ICANON;
+ }
+ //set the terminal attributes.
+ tcsetattr(STDIN_FILENO, TCSANOW, &ttystate);
+}
+
+
+void LoadPaletteFalse(){
+ const Int_t NRGBs = 5;
+ const Int_t NCont = 90;
+
+ Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
+ Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
+ Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
+ Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
+ TColor::CreateGradientColorTable(NRGBs, stops, red,green, blue, NCont);
+ gStyle->SetNumberContours(NCont);
+ TColor::CreateGradientColorTable(NRGBs, stops, red,green ,blue, NCont);
+ gStyle->SetNumberContours(NCont);
+
+}
+void LoadPaletteBW(float gammatune){
+
+ vgamma=vgamma*gammatune;
+ cout<< "gamma is "<SetNumberContours(NCont);
+
+
+
+ // TColor::SetPalette(52,0,1);
+
+}
+
+void Plot1DHistos(void){
+
+ if (hchip[0]->GetXaxis()->GetLast()!=oldh0xlast){
+ oldh0xlast=hchip[0]->GetXaxis()->GetLast();
+ oldh0xfirst=hchip[0]->GetXaxis()->GetFirst();
+ for (int ipad=1; ipad<8;ipad++) {
+ hchip[ipad]->GetXaxis()->SetRange(oldh0xfirst,oldh0xlast);
+
+
+ }
+ }
+
+
+ for (int ipad=0; ipad<8;ipad++) {
+ A4->cd(ipad+1);
+ gStyle->SetOptStat(1); gPad->SetLogy();
+ hchip[ipad%4+(1-int(ipad/4))*4]->Draw();
+
+ }
+ A4->cd();
+ A4->Update();
+}
+
+
+void Plot2DHistos(void){
+ gStyle->SetOptStat(0);
+ A3->cd();
+
+ // if (bw_flag) LoadPaletteBW(1.0);
+
+ if (fixranges) {
+
+ his1000->GetZaxis()->SetRangeUser(float(adcmin),float(adcmax));
+ his3000->GetZaxis()->SetRangeUser(float(pmmin),float(pmmax));
+
+
+ }
+
+ his1000->SetMinimum(-200);
+ his1000->Draw();
+
+ A3->Update();
+ A2->cd();
+ // if (bw_flag) LoadPaletteFalse();
+ his2000->GetXaxis()->SetRange(his1000->GetXaxis()->GetFirst(),his1000->GetXaxis()->GetLast());
+ his2000->GetYaxis()->SetRange(his1000->GetYaxis()->GetFirst(),his1000->GetYaxis()->GetLast());
+
+ his2000->Draw("colz");
+ A2->Update();
+ A5->cd();
+
+ his3000->GetXaxis()->SetRange(his1000->GetXaxis()->GetFirst(),his1000->GetXaxis()->GetLast());
+ his3000->GetYaxis()->SetRange(his1000->GetYaxis()->GetFirst(),his1000->GetYaxis()->GetLast());
+ his3000->Draw("colz");
+ A5->Update();
+
+ A6->cd();
+ his4500->Draw("colz");
+ A6->Update();
+
+
+
+}
+
+
+void startsocket(void) {
+
+
+
+
+ try {
+ zmqSocket = new sls::ZmqSocket(serverip, portnum);
+
+ } catch (...) {
+ cprintf(RED,
+ "Error: Could not create Zmq socket on port %d with ip %s\n",
+ portnum, serverip);
+ delete zmqSocket;
+ return;
+ }
+ zmqSocket->SetReceiveHighWaterMark(3);
+ zmqSocket->SetReceiveBuffer(1024*1024);
+ zmqSocket->Connect();
+
+
+ cout<<"Zmq Client[] "<< zmqSocket->GetZmqServerAddress()<~ZmqSocket ();
+
+
+
+ haveconnection=false;
+
+
+
+
+}
+void savepede(void) {
+
+ int pfd;
+
+ pfd=open(PEDEFNAME,O_CREAT|O_WRONLY, 0666);
+ if (pfd==-1) perror("open pede file");
+
+ write(pfd,fpeded,2*NCH*sizeof(float));
+ write(pfd,fpedeG1d,2*NCH*sizeof(float));
+ write(pfd,fpedeG2d,2*NCH*sizeof(float));
+ close(pfd);
+
+}
+
+void readpede(void) {
+
+ int pfd;
+
+ pfd=open(PEDEFNAME,O_RDONLY);
+ if (pfd==-1) perror("open pede file");
+
+ read(pfd,fpeded,NCH*2*sizeof(float));
+ read(pfd,fpedeG1d,NCH*2*sizeof(float));
+ read(pfd,fpedeG2d,NCH*2*sizeof(float));
+
+ close(pfd);
+ pede_flag=true;
+ hasallpede=true;
+
+}
+
diff --git a/slsDetectorCalibration/jungfrauExecutables/onlinedisp_zmq.h b/slsDetectorCalibration/jungfrauExecutables/onlinedisp_zmq.h
new file mode 100644
index 000000000..100bac801
--- /dev/null
+++ b/slsDetectorCalibration/jungfrauExecutables/onlinedisp_zmq.h
@@ -0,0 +1,204 @@
+
+/**************************************************************************/
+/* Header files section needs cleanup */
+/**************************************************************************/
+#include
+#include
+#include
+#include "sls/ZmqSocket.h"
+
+#include "sls/tiffIO.h"
+#include
+#include
+#include /* exit() */
+#include /* memset(), memcpy() */
+#include /* uname() */
+#include
+#include /* socket(), bind(),
+ listen(), accept() */
+#include
+#include
+#include
+#include
+#include
+#include
+#include /* fork(), write(), close() */
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include //json header in zmq stream
+#include
+#define NTHREADS 2
+
+#include
+#include
+#include // time_t
+
+using namespace std;
+using namespace std::chrono;
+using namespace sls;
+
+#include "TCanvas.h"
+#include "TH1F.h"
+#include "TF1.h"
+#include "TH2F.h"
+#include "TMath.h"
+#include "TFile.h"
+#include "TStyle.h"
+#include "TSystem.h"
+#include "TTimer.h"
+#include "TProfile.h"
+#include "TColor.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "sls/ansi.h"
+#define SLS_DETECTOR_JSON_HEADER_VERSION 0x4
+
+#define PI 3.14159265
+
+#define FALSE 0
+#define OFFSET 0
+#define NBIN 500
+#define MIN_POS -500.5 // 400.5
+#define MAX_POS 3499.5 //-100.5
+
+
+#define NCH 524288
+// #define NCH 262144 in case of half_frames
+
+char serverip[256];
+int portnum;
+FILE * sfilefd;
+
+short* hchptr; // photon counted map "histogram"
+int value;
+float factor=1.84;
+int npacket=0;
+int totalnpacket=0;
+float vgamma;
+
+struct sockaddr_in serveraddr;
+struct sockaddr_in clientaddr;
+struct in_addr inadr;
+struct hostent *server;
+
+int i=0;
+int ipx=0;
+bool haveconnection;
+
+
+TStyle *gStyle;
+TApplication* rootapp;
+TCanvas *A2;
+TCanvas *A3;
+TCanvas *A4;
+TCanvas *A5;
+TCanvas *A6;
+
+TH1I **hchip;
+TH2F **h4500chip;
+short image_data[NCH*2];
+short imaged[NCH*2];
+float fpeded[NCH*2];
+float fpedeG2d[NCH*2];
+float fpedeG1d[NCH*2];
+short ipeded[NCH*2];
+short pcimaged[NCH*2];
+
+float fgaind[NCH*2];
+
+
+float adcpedecorr,adcpedecorrold;
+
+bool gain_flag;
+bool bw_flag;
+bool fill2Ds;
+bool show2Ds;
+bool fill1Ds;
+bool pede_flag;
+bool dophotonmap;
+
+int nx, ny;
+int nframes;
+int goout;
+int framesinstream;
+int ifp;
+float threshold;
+int phene;
+int adcvalue;
+int gain;
+int ichip;
+int frameIndex_old;
+
+char pedefilename[128];
+int framenum,bunchid;
+
+TH2F* his1000;
+TH2F* his2000;
+TH2F* his3000;
+TH2F* his4500;
+TH1I* hproj;
+TH1I* hchcum;
+
+
+using namespace std;
+void printhelp(void);
+void processifp(int ifp);
+void historeset(void);
+void SetRanges(void);
+void startsocket(void);
+void stopsocket(void);
+void axisreset(void);
+int kbhit(void);
+void myloop(void);
+void loadpede(void);
+void loadallpede(void);
+void loadgain(void);
+void nonblock(int state);
+void LoadPaletteFalse(void);
+void LoadPaletteBW(float);
+void Plot1DHistos(void);
+void Plot2DHistos(void);
+void savepede(void);
+void readpede(void);
+int findinterpoindex(int startindex);
+int findclumax(int startindex);
+void tryconnect(void) ;
+
+#define NB_ENABLE 1
+#define NB_DISABLE 0
+char c;
+int HDraw_every;
+
+
+float oldh0xfirst,oldh0xlast;
+int idx;
+int GXPoffset,G1Poffset,G2Poffset;
+int ix,iy;
+int adcmin,adcmax;
+int pmmin,pmmax; //min/mnx for the photon map
+bool fixranges;
+
+
+sls::ZmqSocket *zmqSocket= NULL;
diff --git a/slsDetectorGui/forms/form_tab_measurement.ui b/slsDetectorGui/forms/form_tab_measurement.ui
index 7616ef49b..0b7968fe2 100755
--- a/slsDetectorGui/forms/form_tab_measurement.ui
+++ b/slsDetectorGui/forms/form_tab_measurement.ui
@@ -516,12 +516,344 @@
QFrame::Plain
-
- -
-
+
+
-
+
+
+
+ Cantarell
+ 10
+
+
+
+ <html><head/><body><p>Timing Mode of the detector. </p><p> #timing#</p></body></html>
+
+
+ Timing Mode:
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 25
+
+
+
+
+ 16777215
+ 25
+
+
+
+
+ Cantarell
+ 10
+
+
+
+ Timing Mode of the detector.
+ #timing#
+
+
-
+
+ Auto
+
+
+ -
+
+ Trigger Exposure Series
+
+
+ -
+
+ Gated with fixed number
+
+
+ -
+
+ Burst Trigger
+
+
+ -
+
+ Trigger Gated
+
+
+
+
+ -
+
+
+
+ Cantarell
+ 10
+
+
+
+ <html><head/><body><p>Burst modes</p><p>#burstmode#</p></body></html>
+
+
+ Burst Mode:
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 25
+
+
+
+
+ 16777215
+ 25
+
+
+
+
+ Cantarell
+ 10
+
+
+
+ <html><head/><body><p>Burst modes</p><p> #burstmode#</p></body></html>
+
+
-
+
+ Burst Internal
+
+
+ -
+
+ Burst External
+
+
+ -
+
+ Continuous Internal
+
+
+ -
+
+ Continuous External
+
+
+
+
+ -
+
+
+
+ 170
+ 0
+
+
+
+
+ Cantarell
+ 10
+
+
+
+ <html><head/><body><p>Number of measurements (not in real time) that will be acquired. </p><p> #only in gui#</p></body></html>
+
+
+ Number of Measurements:
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 25
+
+
+
+
+ 16777215
+ 25
+
+
+
+
+ Cantarell
+ 10
+
+
+
+ <html><head/><body><p>Number of measurements (not in real time) that will be acquired. </p><p> #only in gui#</p></body></html>
+
+
+
+
+
+
+
+
+ Qt::LeftToRight
+
+
+
+
+
+ true
+
+
+ QAbstractSpinBox::PlusMinus
+
+
+ false
+
+
+
+
+
+ -1
+
+
+ 2000000000
+
+
+ 1
+
+
+
+ -
+
false
+
+
+ Cantarell
+ 10
+
+
+
+ <html><head/><body><p>Number of frames per hardware/software trigger that will be acquired </p><p> #frames#</p></body></html>
+
+
+ Number of Frames:
+
+
+
+ -
+
+
+ false
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 25
+
+
+
+
+ 16777215
+ 25
+
+
+
+
+ Cantarell
+ 10
+
+
+
+ <html><head/><body><p>Number of frames per hardware/software trigger that will be acquired </p><p> #frames#</p></body></html>
+
+
+
+
+
+
+
+
+
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+ QAbstractSpinBox::PlusMinus
+
+
+ false
+
+
+
+
+
+ -1
+
+
+ 2000000000
+
+
+ 1
+
+
+
+ -
+
+
+ true
+
+
+
+ Cantarell
+ 10
+
+
+
+ <nobr>
+Exposure Time of a frame.
+</nobr><br><nobr>
+ #exptime#
+</nobr>
+
+
+ Exposure Time:
+
+
+
+ -
+
+
+ true
+
0
@@ -548,9 +880,9 @@
<nobr>
-Frame period between exposures.
+Exposure Time of a frame.
</nobr><br><nobr>
- #period#
+ #exptime#
</nobr>
@@ -575,271 +907,11 @@ Frame period between exposures.
2000000000.000000000000000
- 0.000000000000000
+ 1.000000000000000
- -
-
-
-
- 0
- 0
-
-
-
-
- 171
- 32
-
-
-
-
- 171
- 32
-
-
-
-
- Cantarell
- 10
-
-
-
- 0
-
-
-
-
- Cantarell
- 10
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- false
-
-
-
- Cantarell
- 10
-
-
-
- <html><head/><body><p>Number of analog samples.</p><p>#asamples#</p></body></html>
-
-
- Number of Samples:
-
-
-
-
-
-
-
-
- Cantarell
- 10
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
- -
-
-
- false
-
-
-
- Cantarell
- 10
-
-
-
- <html><head/><body><p>Number of external gates.</p><p>#gates#</p></body></html>
-
-
- Number of Gates:
-
-
-
-
-
-
-
- -
-
-
-
- 170
- 0
-
-
-
-
- Cantarell
- 10
-
-
-
- <html><head/><body><p>Number of measurements (not in real time) that will be acquired. </p><p> #only in gui#</p></body></html>
-
-
- Number of Measurements:
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 171
- 32
-
-
-
-
- 171
- 32
-
-
-
-
- Cantarell
- 10
-
-
-
- 0
-
-
-
-
- Cantarell
- 10
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- false
-
-
-
- Cantarell
- 10
-
-
-
- <html><head/><body><p>The Delay between Trigger Edge and Start of Exposure ( or Readout). </p><p>#delay#</p></body></html>
-
-
- Delay After Trigger:
-
-
-
-
-
-
-
-
- Cantarell
- 10
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
- -
-
-
- false
-
-
-
- Cantarell
- 10
-
-
-
- <html><head/><body><p>Burst period between bursts</p><p>#burstperiod#</p></body></html>
-
-
- Burst Period:
-
-
-
-
-
-
-
- -
+
-
true
@@ -913,7 +985,285 @@ Exposure Time of a frame.
- -
+
-
+
+
+ false
+
+
+
+ Cantarell
+ 10
+
+
+
+ <nobr>
+Frame period between exposures.
+</nobr><br><nobr>
+ #period#
+</nobr>
+
+
+ Acquisition Period:
+
+
+
+ -
+
+
+ false
+
+
+
+ 0
+ 0
+
+
+
+
+ 170
+ 25
+
+
+
+
+ 16777215
+ 25
+
+
+
+
+ Cantarell
+ 10
+
+
+
+ <nobr>
+Frame period between exposures.
+</nobr><br><nobr>
+ #period#
+</nobr>
+
+
+
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+ QAbstractSpinBox::PlusMinus
+
+
+ false
+
+
+ 9
+
+
+ -1.000000000000000
+
+
+ 2000000000.000000000000000
+
+
+ 0.000000000000000
+
+
+
+ -
+
+
+ false
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 25
+
+
+
+
+ 70
+ 25
+
+
+
+
+ Cantarell
+ 10
+
+
+
+ <nobr>
+Frame period between exposures.
+</nobr><br><nobr>
+ #period#
+</nobr>
+
+
+ Qt::LeftToRight
+
+
+ 2
+
+
-
+
+ hr
+
+
+ -
+
+ min
+
+
+ -
+
+ s
+
+
+ -
+
+ ms
+
+
+ -
+
+ us
+
+
+ -
+
+ ns
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 16777215
+
+
+
+
+ Cantarell
+ 10
+
+
+
+ 0
+
+
+
+
+ Cantarell
+ 10
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ false
+
+
+
+ Cantarell
+ 10
+
+
+
+ <html><head/><body><p>Number of Triggers to be expected.</p><p> #triggers#</p></body></html>
+
+
+ Number of Triggers:
+
+
+
+
+
+
+
+
+ Cantarell
+ 10
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+ false
+
+
+
+ Cantarell
+ 10
+
+
+
+ <html><head/><body><p>Number of bursts to be expected.</p><p>#bursts#</p></body></html>
+
+
+ Number of Bursts:
+
+
+
+
+
+
+
+ -
@@ -1110,50 +1460,24 @@ Exposure Time of a frame.
- -
-
-
- false
-
-
-
- Cantarell
- 10
-
-
-
- <nobr>
-Frame period between exposures.
-</nobr><br><nobr>
- #period#
-</nobr>
-
-
- Acquisition Period:
-
-
-
- -
-
-
- false
-
+
-
+
-
+
0
0
- 0
- 25
+ 171
+ 32
- 16777215
- 25
+ 171
+ 32
@@ -1162,58 +1486,100 @@ Frame period between exposures.
10
-
- <html><head/><body><p>Number of frames per hardware/software trigger that will be acquired </p><p> #frames#</p></body></html>
-
-
-
-
-
-
-
-
-
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
- QAbstractSpinBox::PlusMinus
-
-
- false
-
-
-
-
-
- -1
-
-
- 2000000000
-
-
- 1
+
+ 0
+
+
+
+ Cantarell
+ 10
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ false
+
+
+
+ Cantarell
+ 10
+
+
+
+ <html><head/><body><p>The Delay between Trigger Edge and Start of Exposure ( or Readout). </p><p>#delay#</p></body></html>
+
+
+ Delay After Trigger:
+
+
+
+
+
+
+
+
+ Cantarell
+ 10
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+ false
+
+
+
+ Cantarell
+ 10
+
+
+
+ <html><head/><body><p>Burst period between bursts</p><p>#burstperiod#</p></body></html>
+
+
+ Burst Period:
+
+
+
+
+
- -
-
-
-
- Cantarell
- 10
-
-
-
- <html><head/><body><p>Burst modes</p><p>#burstmode#</p></body></html>
-
-
- Burst Mode:
-
-
-
- -
+
-
@@ -1405,426 +1771,7 @@ Frame period between exposures.
- -
-
-
- true
-
-
-
- 0
- 0
-
-
-
-
- 170
- 25
-
-
-
-
- 16777215
- 25
-
-
-
-
- Cantarell
- 10
-
-
-
- <nobr>
-Exposure Time of a frame.
-</nobr><br><nobr>
- #exptime#
-</nobr>
-
-
-
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
- QAbstractSpinBox::PlusMinus
-
-
- false
-
-
- 9
-
-
- -1.000000000000000
-
-
- 2000000000.000000000000000
-
-
- 1.000000000000000
-
-
-
- -
-
-
- false
-
-
-
- 0
- 0
-
-
-
-
- 0
- 25
-
-
-
-
- 70
- 25
-
-
-
-
- Cantarell
- 10
-
-
-
- <nobr>
-Frame period between exposures.
-</nobr><br><nobr>
- #period#
-</nobr>
-
-
- Qt::LeftToRight
-
-
- 2
-
-
-
-
- hr
-
-
- -
-
- min
-
-
- -
-
- s
-
-
- -
-
- ms
-
-
- -
-
- us
-
-
- -
-
- ns
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 16777215
- 30
-
-
-
-
- Cantarell
- 10
-
-
-
- 0
-
-
-
-
- Cantarell
- 10
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- false
-
-
-
- 0
- 0
-
-
-
-
- 0
- 25
-
-
-
-
- 16777215
- 25
-
-
-
-
- Cantarell
- 10
-
-
-
- <html><head/><body><p>Number of analog samples.</p><p>#asamples#</p><p><br/></p></body></html>
-
-
-
-
-
-
-
-
-
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
- QAbstractSpinBox::PlusMinus
-
-
- false
-
-
-
-
-
- -1
-
-
- 2000000000
-
-
- 1
-
-
-
-
-
-
-
-
- Cantarell
- 10
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
- -
-
-
- false
-
-
-
- 0
- 0
-
-
-
-
- 0
- 25
-
-
-
-
- 16777215
- 25
-
-
-
-
- Cantarell
- 10
-
-
-
- <html><head/><body><p>Number of external gates.</p><p>#gates#</p></body></html>
-
-
-
-
-
-
-
-
-
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
- QAbstractSpinBox::PlusMinus
-
-
- false
-
-
-
-
-
- -1
-
-
- 2000000000
-
-
- 1
-
-
-
-
-
-
-
- -
-
-
- true
-
-
-
- Cantarell
- 10
-
-
-
- <nobr>
-Exposure Time of a frame.
-</nobr><br><nobr>
- #exptime#
-</nobr>
-
-
- Exposure Time:
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 0
- 25
-
-
-
-
- 16777215
- 25
-
-
-
-
- Cantarell
- 10
-
-
-
- Timing Mode of the detector.
- #timing#
-
-
-
-
- Auto
-
-
- -
-
- Trigger Exposure Series
-
-
- -
-
- Gated with fixed number
-
-
- -
-
- Burst Trigger
-
-
- -
-
- Trigger Gated
-
-
-
-
- -
+
-
@@ -2046,8 +1993,8 @@ Exposure Time of a frame.
- -
-
+
-
+
false
@@ -2058,134 +2005,18 @@ Exposure Time of a frame.
- <html><head/><body><p>Number of frames per hardware/software trigger that will be acquired </p><p> #frames#</p></body></html>
+ <html><head/><body><p>Number of external gates.</p><p>#gates#</p></body></html>
- Number of Frames:
+ Number of Gates:
- -
-
-
-
- 0
- 0
-
+
-
+
+
+ false
-
-
- 0
- 0
-
-
-
-
- 16777215
- 16777215
-
-
-
-
- Cantarell
- 10
-
-
-
- 0
-
-
-
-
- Cantarell
- 10
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- false
-
-
-
- Cantarell
- 10
-
-
-
- <html><head/><body><p>Number of Triggers to be expected.</p><p> #triggers#</p></body></html>
-
-
- Number of Triggers:
-
-
-
-
-
-
-
-
- Cantarell
- 10
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
- -
-
-
- false
-
-
-
- Cantarell
- 10
-
-
-
- <html><head/><body><p>Number of bursts to be expected.</p><p>#bursts#</p></body></html>
-
-
- Number of Bursts:
-
-
-
-
-
-
-
- -
-
0
@@ -2211,7 +2042,7 @@ Exposure Time of a frame.
- <html><head/><body><p>Number of measurements (not in real time) that will be acquired. </p><p> #only in gui#</p></body></html>
+ <html><head/><body><p>Number of external gates.</p><p>#gates#</p></body></html>
@@ -2219,14 +2050,11 @@ Exposure Time of a frame.
-
- Qt::LeftToRight
-
-
- true
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
QAbstractSpinBox::PlusMinus
@@ -2248,74 +2076,7 @@ Exposure Time of a frame.
- -
-
-
-
- 0
- 0
-
-
-
-
- 0
- 25
-
-
-
-
- 16777215
- 25
-
-
-
-
- Cantarell
- 10
-
-
-
- <html><head/><body><p>Burst modes</p><p> #burstmode#</p></body></html>
-
-
-
-
- Burst Internal
-
-
- -
-
- Burst External
-
-
- -
-
- Continuous Internal
-
-
- -
-
- Continuous External
-
-
-
-
- -
-
-
-
- Cantarell
- 10
-
-
-
- <html><head/><body><p>Timing Mode of the detector. </p><p> #timing#</p></body></html>
-
-
- Timing Mode:
-
-
-
- -
+
-
Qt::Vertical
@@ -2489,8 +2250,6 @@ Exposure Time of a frame.
comboDelayUnit
spinBurstPeriod
comboBurstPeriodUnit
- spinNumSamples
- spinNumGates
diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h
index d02ef306d..3dd42244e 100644
--- a/slsDetectorGui/include/qDrawPlot.h
+++ b/slsDetectorGui/include/qDrawPlot.h
@@ -59,6 +59,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
void ClonePlot();
void SavePlot();
void SetGapPixels(bool enable);
+ void UpdatePlot();
protected:
void resizeEvent(QResizeEvent *event);
@@ -67,7 +68,6 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
void Zoom1DGainPlot(const QRectF &rect);
void Zoom2DGainPlot(const QRectF &rect);
void SetSaveFileName(QString val);
- void UpdatePlot();
signals:
void AcquireFinishedSignal();
diff --git a/slsDetectorGui/include/qTabMeasurement.h b/slsDetectorGui/include/qTabMeasurement.h
index ccfa4a41d..5248476ce 100644
--- a/slsDetectorGui/include/qTabMeasurement.h
+++ b/slsDetectorGui/include/qTabMeasurement.h
@@ -32,7 +32,6 @@ class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
void SetNumFrames(int val);
void SetNumTriggers(int val);
void SetNumBursts(int val);
- void SetNumSamples(int val);
void SetNumGates(int val);
void SetExposureTime();
void SetAcquisitionPeriod();
@@ -64,7 +63,6 @@ class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
void GetNumFrames();
void GetNumTriggers();
void GetNumBursts();
- void GetNumSamples();
void GetNumGates();
void GetExposureTime();
void GetAcquisitionPeriod();
@@ -96,7 +94,6 @@ class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
QString errPeriodTip;
QPalette red;
bool delayImplemented;
- bool sampleImplemented;
bool gateImplemented;
bool startingFnumImplemented;
bool isAcquisitionStopped{false};
diff --git a/slsDetectorGui/include/qTabPlot.h b/slsDetectorGui/include/qTabPlot.h
index 3e57eb24a..77cefc0df 100644
--- a/slsDetectorGui/include/qTabPlot.h
+++ b/slsDetectorGui/include/qTabPlot.h
@@ -47,6 +47,7 @@ class qTabPlot : public QWidget, private Ui::TabPlotObject {
private:
void SetupWidgetWindow();
void Initialization();
+ bool VerifyGapPixelsAllowed();
void Select1DPlot(bool enable);
void GetGapPixels();
void GetStreamingFrequency();
@@ -60,7 +61,8 @@ class qTabPlot : public QWidget, private Ui::TabPlotObject {
Detector *det;
qDrawPlot *plot;
- bool is1d;
+ bool is1d{false};
+ bool isGapPixelsAllowed{false};
/** default plot and axis titles */
static QString defaultPlotTitle;
diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp
index d1a233731..58e69fc0a 100644
--- a/slsDetectorGui/src/qDrawPlot.cpp
+++ b/slsDetectorGui/src/qDrawPlot.cpp
@@ -52,6 +52,7 @@ void qDrawPlot::SetupWidgetWindow() {
detType = det->getDetectorType().squash();
switch (detType) {
case slsDetectorDefs::JUNGFRAU:
+ case slsDetectorDefs::MOENCH:
pixelMask = ((1 << 14) - 1);
gainMask = (3 << 14);
gainOffset = 14;
@@ -1142,7 +1143,8 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size,
break;
case 16:
- if (detType == slsDetectorDefs::JUNGFRAU ||
+ if (detType == slsDetectorDefs::MOENCH ||
+ detType == slsDetectorDefs::JUNGFRAU ||
detType == slsDetectorDefs::GOTTHARD2) {
// show gain plot
diff --git a/slsDetectorGui/src/qTabAdvanced.cpp b/slsDetectorGui/src/qTabAdvanced.cpp
index fbb78537f..ae3c2b39f 100644
--- a/slsDetectorGui/src/qTabAdvanced.cpp
+++ b/slsDetectorGui/src/qTabAdvanced.cpp
@@ -48,6 +48,10 @@ void qTabAdvanced::SetupWidgetWindow() {
lblDiscardBits->setEnabled(true);
spinDiscardBits->setEnabled(true);
break;
+ case slsDetectorDefs::JUNGFRAU:
+ lblNumStoragecells->setEnabled(true);
+ spinNumStoragecells->setEnabled(true);
+ break;
default:
break;
}
diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp
index cdedf42e4..2ec1575a3 100644
--- a/slsDetectorGui/src/qTabDataOutput.cpp
+++ b/slsDetectorGui/src/qTabDataOutput.cpp
@@ -40,13 +40,11 @@ void qTabDataOutput::SetupWidgetWindow() {
comboClkDivider->setEnabled(true);
chkParallel->setEnabled(true);
break;
- case slsDetectorDefs::MOENCH:
- chkTenGiga->setEnabled(true);
- break;
case slsDetectorDefs::MYTHEN3:
chkParallel->setEnabled(true);
break;
case slsDetectorDefs::JUNGFRAU:
+ case slsDetectorDefs::MOENCH:
lblClkDivider->setEnabled(true);
comboClkDivider->setEnabled(true);
break;
@@ -182,8 +180,10 @@ void qTabDataOutput::BrowseOutputDir() {
LOG(logDEBUG) << "Browsing output directory";
QString directory = QFileDialog::getExistingDirectory(
this, tr("Choose Output Directory "), dispOutputDir->text());
- if (!directory.isEmpty())
+ if (!directory.isEmpty()) {
dispOutputDir->setText(directory);
+ ForceSetOutputDir();
+ }
}
void qTabDataOutput::SetOutputDir(bool force) {
diff --git a/slsDetectorGui/src/qTabDeveloper.cpp b/slsDetectorGui/src/qTabDeveloper.cpp
index 6665f1516..f2fde92a9 100644
--- a/slsDetectorGui/src/qTabDeveloper.cpp
+++ b/slsDetectorGui/src/qTabDeveloper.cpp
@@ -111,6 +111,7 @@ void qTabDeveloper::SetupWidgetWindow() {
break;
case slsDetectorDefs::JUNGFRAU:
+ case slsDetectorDefs::MOENCH:
dacWidgets.push_back(
new qDacWidget(this, det, true,
"v vb comp: ", getSLSIndex(detType, tempid++)));
@@ -139,72 +140,6 @@ void qTabDeveloper::SetupWidgetWindow() {
"Temperature ADC: ", getSLSIndex(detType, tempid++)));
break;
- case slsDetectorDefs::MOENCH:
- dacWidgets.push_back(
- new qDacWidget(this, det, true,
- "vbp_colbuf: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vipre: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vin_cm: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vb_sda: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(
- new qDacWidget(this, det, true,
- "vcasc_sfp: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vout_cm: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(
- new qDacWidget(this, det, true,
- "vipre_cds: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(
- new qDacWidget(this, det, true,
- "ibias_sfp: ", getSLSIndex(detType, tempid++)));
- break;
-
- case slsDetectorDefs::MYTHEN3:
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vcassh: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vth2: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vrshaper: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(
- new qDacWidget(this, det, true,
- "vrshaper_n: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(
- new qDacWidget(this, det, true,
- "vipre_out: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vth3: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vth1: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vicin: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vcas: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vrpreamp: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vcal_p: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vipre: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vishaper: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vcal_n: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vtrim: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(new qDacWidget(
- this, det, true, "vdcsh: ", getSLSIndex(detType, tempid++)));
- dacWidgets.push_back(
- new qDacWidget(this, det, true,
- "vthreshold: ", getSLSIndex(detType, tempid++)));
- adcWidgets.push_back(new qDacWidget(
- this, det, false,
- "Temperature FPGA: ", getSLSIndex(detType, tempid++)));
- break;
-
case slsDetectorDefs::GOTTHARD2:
dacWidgets.push_back(
new qDacWidget(this, det, true,
@@ -386,6 +321,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
break;
case slsDetectorDefs::JUNGFRAU:
+ case slsDetectorDefs::MOENCH:
switch (index) {
case 0:
return slsDetectorDefs::VB_COMP;
@@ -411,30 +347,6 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
}
break;
- case slsDetectorDefs::MOENCH:
- switch (index) {
- case 0:
- return slsDetectorDefs::VBP_COLBUF;
- case 1:
- return slsDetectorDefs::VIPRE;
- case 2:
- return slsDetectorDefs::VIN_CM;
- case 3:
- return slsDetectorDefs::VB_SDA;
- case 4:
- return slsDetectorDefs::VCASC_SFP;
- case 5:
- return slsDetectorDefs::VOUT_CM;
- case 6:
- return slsDetectorDefs::VIPRE_CDS;
- case 7:
- return slsDetectorDefs::IBIAS_SFP;
- default:
- throw RuntimeError(std::string("Unknown dac/adc index") +
- std::to_string(index));
- }
- break;
-
case slsDetectorDefs::MYTHEN3:
switch (index) {
case 0:
diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp
index 009ace46a..c3282d67e 100644
--- a/slsDetectorGui/src/qTabMeasurement.cpp
+++ b/slsDetectorGui/src/qTabMeasurement.cpp
@@ -35,7 +35,6 @@ void qTabMeasurement::SetupWidgetWindow() {
// timer to update the progress bar
progressTimer = new QTimer(this);
- sampleImplemented = false;
gateImplemented = false;
delayImplemented = true;
startingFnumImplemented = false;
@@ -47,18 +46,11 @@ void qTabMeasurement::SetupWidgetWindow() {
// default is triggers and delay (not #bursts and burst period for gotthard2
// in auto mode)
ShowTriggerDelay();
- // default is to show samples, mythen3, show gates
- ShowGates();
// enabling according to det type
lblBurstMode->hide();
comboBurstMode->hide();
switch (det->getDetectorType().squash()) {
- case slsDetectorDefs::MOENCH:
- lblNumSamples->setEnabled(true);
- spinNumSamples->setEnabled(true);
- sampleImplemented = true;
- break;
case slsDetectorDefs::EIGER:
delayImplemented = false;
lblNextFrameNumber->setEnabled(true);
@@ -66,6 +58,7 @@ void qTabMeasurement::SetupWidgetWindow() {
startingFnumImplemented = true;
break;
case slsDetectorDefs::JUNGFRAU:
+ case slsDetectorDefs::MOENCH:
lblNextFrameNumber->setEnabled(true);
spinNextFrameNumber->setEnabled(true);
startingFnumImplemented = true;
@@ -112,10 +105,6 @@ void qTabMeasurement::Initialization() {
connect(spinNumBursts, SIGNAL(valueChanged(int)), this,
SLOT(SetNumBursts(int)));
}
- if (spinNumSamples->isEnabled()) {
- connect(spinNumSamples, SIGNAL(valueChanged(int)), this,
- SLOT(SetNumSamples(int)));
- }
if (gateImplemented) {
connect(spinNumGates, SIGNAL(valueChanged(int)), this,
SLOT(SetNumGates(int)));
@@ -198,16 +187,6 @@ void qTabMeasurement::ShowTriggerDelay() {
}
}
-void qTabMeasurement::ShowGates() {
- if (det->getDetectorType().squash() == slsDetectorDefs::MYTHEN3) {
- stackedLblSamplesGates->setCurrentWidget(pageLblGates);
- stackedSpinSamplesGates->setCurrentWidget(pageSpinGates);
- } else {
- stackedLblSamplesGates->setCurrentWidget(pageLblSamples);
- stackedSpinSamplesGates->setCurrentWidget(pageSpinSamples);
- }
-}
-
void qTabMeasurement::SetupTimingMode() {
QStandardItemModel *model =
qobject_cast(comboTimingMode->model());
@@ -510,31 +489,6 @@ void qTabMeasurement::SetNumBursts(int val) {
&qTabMeasurement::GetNumBursts)
}
-void qTabMeasurement::GetNumSamples() {
- LOG(logDEBUG) << "Getting number of samples";
- disconnect(spinNumSamples, SIGNAL(valueChanged(int)), this,
- SLOT(SetNumSamples(int)));
- try {
- auto retval = det->getNumberOfAnalogSamples().tsquash(
- "Inconsistent number of analog samples for all detectors.");
- spinNumSamples->setValue(retval);
- }
- CATCH_DISPLAY("Could not get number of samples.",
- "qTabMeasurement::GetNumSamples")
- connect(spinNumSamples, SIGNAL(valueChanged(int)), this,
- SLOT(SetNumSamples(int)));
-}
-
-void qTabMeasurement::SetNumSamples(int val) {
- LOG(logINFO) << "Setting number of samples to " << val;
- try {
- det->setNumberOfAnalogSamples(val);
- }
- CATCH_HANDLE("Could not set number of samples.",
- "qTabMeasurement::SetNumSamples", this,
- &qTabMeasurement::GetNumSamples)
-}
-
void qTabMeasurement::GetNumGates() {
LOG(logDEBUG) << "Getting number of gates";
disconnect(spinNumGates, SIGNAL(valueChanged(int)), this,
@@ -1003,9 +957,6 @@ void qTabMeasurement::Refresh() {
if (spinBurstPeriod->isEnabled()) {
GetBurstPeriod();
}
- if (sampleImplemented) {
- GetNumSamples();
- }
if (gateImplemented) {
GetNumGates();
}
diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp
index 1579558f9..75d873137 100644
--- a/slsDetectorGui/src/qTabPlot.cpp
+++ b/slsDetectorGui/src/qTabPlot.cpp
@@ -16,7 +16,7 @@ QString qTabPlot::defaultImageYAxisTitle("Pixel");
QString qTabPlot::defaultImageZAxisTitle("Intensity");
qTabPlot::qTabPlot(QWidget *parent, Detector *detector, qDrawPlot *p)
- : QWidget(parent), det(detector), plot(p), is1d(false) {
+ : QWidget(parent), det(detector), plot(p) {
setupUi(this);
SetupWidgetWindow();
LOG(logDEBUG) << "Plot ready";
@@ -57,11 +57,12 @@ void qTabPlot::SetupWidgetWindow() {
chkGainPlot1D->setChecked(true);
plot->EnableGainPlot(true);
break;
- case slsDetectorDefs::EIGER:
- chkGapPixels->setEnabled(true);
- break;
case slsDetectorDefs::JUNGFRAU:
- chkGapPixels->setEnabled(true);
+ chkGainPlot->setEnabled(true);
+ chkGainPlot->setChecked(true);
+ plot->EnableGainPlot(true);
+ break;
+ case slsDetectorDefs::MOENCH:
chkGainPlot->setEnabled(true);
chkGainPlot->setChecked(true);
plot->EnableGainPlot(true);
@@ -69,6 +70,8 @@ void qTabPlot::SetupWidgetWindow() {
default:
break;
}
+ isGapPixelsAllowed = VerifyGapPixelsAllowed();
+ chkGapPixels->setEnabled(isGapPixelsAllowed);
Select1DPlot(is1d);
Initialization();
@@ -195,6 +198,29 @@ void qTabPlot::Initialization() {
connect(dispZMax, SIGNAL(editingFinished()), this, SLOT(isZMaxModified()));
}
+bool qTabPlot::VerifyGapPixelsAllowed() {
+ try {
+ switch (det->getDetectorType().squash()) {
+ case slsDetectorDefs::JUNGFRAU:
+ return true;
+ case slsDetectorDefs::EIGER:
+ if (det->getQuad().squash(false)) {
+ return true;
+ }
+ // full modules
+ if (det->getModuleGeometry().y % 2 == 0) {
+ return true;
+ }
+ return false;
+ default:
+ return false;
+ }
+ }
+ CATCH_DISPLAY("Could not verify if gap pixels allowed.",
+ "qTabPlot::VerifyGapPixelsAllowed")
+ return false;
+}
+
void qTabPlot::Select1DPlot(bool enable) {
LOG(logDEBUG) << "Selecting " << (enable ? "1" : "2") << "D Plot";
is1d = enable;
@@ -487,6 +513,7 @@ void qTabPlot::SetXYRange() {
}
plot->SetXYRangeChanged(disablezoom, xyRange, isRange);
+ plot->UpdatePlot();
emit DisableZoomSignal(disablezoom);
}
@@ -624,6 +651,7 @@ void qTabPlot::SetZRange() {
zRange[1] = val;
}
plot->SetZRange(zRange, isZRange);
+ plot->UpdatePlot();
}
void qTabPlot::GetStreamingFrequency() {
@@ -770,23 +798,26 @@ void qTabPlot::Refresh() {
boxFrequency->setEnabled(true);
GetStreamingFrequency();
GetHwm();
- // gain plot, gap pixels enable
+ // gain plot
switch (det->getDetectorType().squash()) {
- case slsDetectorDefs::EIGER:
- chkGapPixels->setEnabled(true);
- GetGapPixels();
- break;
case slsDetectorDefs::JUNGFRAU:
chkGainPlot->setEnabled(true);
- chkGapPixels->setEnabled(true);
GetGapPixels();
break;
+ case slsDetectorDefs::MOENCH:
+ chkGainPlot->setEnabled(true);
+ break;
case slsDetectorDefs::GOTTHARD2:
chkGainPlot1D->setEnabled(true);
break;
default:
break;
}
+ // gap pixels
+ if (isGapPixelsAllowed) {
+ chkGapPixels->setEnabled(true);
+ GetGapPixels();
+ }
} else {
boxFrequency->setEnabled(false);
chkGainPlot->setEnabled(false);
diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp
index 9adf559b3..e45abdbce 100644
--- a/slsDetectorGui/src/qTabSettings.cpp
+++ b/slsDetectorGui/src/qTabSettings.cpp
@@ -92,7 +92,8 @@ void qTabSettings::SetupWidgetWindow() {
comboDynamicRange->setEnabled(true);
lblThreshold->setEnabled(true);
spinThreshold->setEnabled(true);
- } else if (detType == slsDetectorDefs::JUNGFRAU) {
+ } else if (detType == slsDetectorDefs::JUNGFRAU ||
+ detType == slsDetectorDefs::MOENCH) {
lblSpinHV->show();
spinHV->show();
lblGainMode->setEnabled(true);
@@ -100,9 +101,6 @@ void qTabSettings::SetupWidgetWindow() {
} else if (detType == slsDetectorDefs::GOTTHARD) {
comboHV->show();
lblComboHV->show();
- } else if (detType == slsDetectorDefs::MOENCH) {
- lblSpinHV->show();
- spinHV->show();
} else if (detType == slsDetectorDefs::GOTTHARD2) {
lblSpinHV->show();
spinHV->show();
diff --git a/slsDetectorServers/compileAllServers.sh b/slsDetectorServers/compileAllServers.sh
index c79f4dc5b..fe48f61fd 100644
--- a/slsDetectorServers/compileAllServers.sh
+++ b/slsDetectorServers/compileAllServers.sh
@@ -3,12 +3,12 @@
# empty branch = developer branch in updateAPIVersion.sh
branch=""
-det_list=("ctbDetectorServer"
- "gotthardDetectorServer"
- "gotthard2DetectorServer"
- "jungfrauDetectorServer"
- "mythen3DetectorServer"
- "moenchDetectorServer"
+det_list=("ctbDetectorServer
+ gotthardDetectorServer
+ gotthard2DetectorServer
+ jungfrauDetectorServer
+ mythen3DetectorServer
+ moenchDetectorServer"
)
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'"
@@ -25,9 +25,11 @@ elif [ $# -eq 1 ] || [ $# -eq 2 ]; then
else
# only one server
# arg not in list
- if [[ $det_list != *$1* ]]; then
+ echo $det_list | grep -w -q $1
+ #if [[ $det_list != *$1* ]]; then
+ if ! [[ $? ]] ; then
echo -e "Invalid argument 1: $1. $usage"
- return -1
+ return 1
fi
declare -a det=("${1}")
#echo "Compiling only $1"
@@ -37,14 +39,14 @@ elif [ $# -eq 1 ] || [ $# -eq 2 ]; then
# arg in list
if [[ $det_list == *$2* ]]; then
echo -e "Invalid argument 2: $2. $usage"
- return -1
+ return 1
fi
branch+=$2
#echo "with branch $branch"
fi
else
echo -e "Too many arguments.$usage"
- return -1
+ return 1
fi
declare -a deterror=("OK" "OK" "OK" "OK" "OK" "OK")
diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer
index a680b6fca..fed56a0f6 100755
Binary files a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ
diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c
index a55b61a28..dddb324f8 100644
--- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c
+++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c
@@ -99,7 +99,7 @@ void basictests() {
#endif
if (mapCSP0() == FAIL) {
strcpy(initErrorMessage,
- "Could not map to memory. Dangerous to continue.\n");
+ "Could not map to memory. Cannot proceed. Check Firmware.\n");
LOG(logERROR, (initErrorMessage));
initError = FAIL;
return;
@@ -109,8 +109,10 @@ void basictests() {
if ((!debugflag) && (!updateFlag) &&
((checkType() == FAIL) || (testFpga() == FAIL) ||
(testBus() == FAIL))) {
- strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. "
- "Dangerous to continue.\n");
+ sprintf(initErrorMessage,
+ "Could not pass basic tests of FPGA and bus. Cannot proceed. "
+ "Check Firmware. (Firmware version:0x%llx) \n",
+ getFirmwareVersion());
LOG(logERROR, ("%s\n\n", initErrorMessage));
initError = FAIL;
return;
@@ -446,7 +448,7 @@ void initStopServer() {
if (mapCSP0() == FAIL) {
initError = FAIL;
strcpy(initErrorMessage,
- "Stop Server: Map Fail. Dangerous to continue. Goodbye!\n");
+ "Stop Server: Map Fail. Cannot proceed. Check Firmware.\n");
LOG(logERROR, (initErrorMessage));
initCheckDone = 1;
return;
diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h
index 89bf864f6..af8e7e3e0 100644
--- a/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h
+++ b/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h
@@ -5,7 +5,7 @@
#include "sls/sls_detector_defs.h"
#define MIN_REQRD_VRSN_T_RD_API 0x181130
-#define REQRD_FRMWR_VRSN 0x220825
+#define REQRD_FRMWR_VRSN 0x221205
#define NUM_HARDWARE_VERSIONS (1)
#define HARDWARE_VERSION_NUMBERS \
diff --git a/slsDetectorServers/eigerDetectorServer/Beb.c b/slsDetectorServers/eigerDetectorServer/Beb.c
index 4b7ae520d..82d82f697 100644
--- a/slsDetectorServers/eigerDetectorServer/Beb.c
+++ b/slsDetectorServers/eigerDetectorServer/Beb.c
@@ -1106,7 +1106,9 @@ int Beb_SetDetectorPosition(int pos[]) {
int posRight[2] = {Beb_top ? pos[X] + 1 : pos[X], pos[Y]};
if (Beb_quadEnable) {
- posRight[Y] = 1; // right is next row
+ posLeft[Y] = 1; // left is next row
+ posLeft[X] = 0; // left same first row
+ posRight[Y] = 0; // right same first row
posRight[X] = 0; // right same first column
}
diff --git a/slsDetectorServers/eigerDetectorServer/CMakeLists.txt b/slsDetectorServers/eigerDetectorServer/CMakeLists.txt
index 39f0aea23..ddba9e4a4 100644
--- a/slsDetectorServers/eigerDetectorServer/CMakeLists.txt
+++ b/slsDetectorServers/eigerDetectorServer/CMakeLists.txt
@@ -25,7 +25,7 @@ target_include_directories(eigerDetectorServer_virtual
)
target_compile_definitions(eigerDetectorServer_virtual
- PUBLIC EIGERD PCCOMPILE STOP_SERVER
+ PUBLIC EIGERD PCCOMPILE STOP_SERVER #TEST_MOD_GEOMETRY
PUBLIC VIRTUAL #VIRTUAL_9M
)
diff --git a/slsDetectorServers/eigerDetectorServer/FebControl.c b/slsDetectorServers/eigerDetectorServer/FebControl.c
index c37ce2ced..27acb91a0 100644
--- a/slsDetectorServers/eigerDetectorServer/FebControl.c
+++ b/slsDetectorServers/eigerDetectorServer/FebControl.c
@@ -1240,19 +1240,16 @@ int Feb_Control_GetDynamicRange(int *retval) {
int Feb_Control_Disable16bitConversion(int disable) {
LOG(logINFO, ("%s 16 bit expansion\n", disable ? "Disabling" : "Enabling"));
+
+ uint32_t bitmask = DAQ_REG_HRDWRE_DSBL_16BIT_MSK;
unsigned int regval = 0;
- if (!Feb_Control_ReadRegister(DAQ_REG_HRDWRE, ®val)) {
- LOG(logERROR, ("Could not %s 16 bit expansion (bit mode)\n",
- (disable ? "disable" : "enable")));
- return 0;
- }
if (disable) {
- regval |= DAQ_REG_HRDWRE_DSBL_16BIT_MSK;
+ regval |= bitmask;
} else {
- regval &= ~DAQ_REG_HRDWRE_DSBL_16BIT_MSK;
+ regval &= ~bitmask;
}
- if (!Feb_Control_WriteRegister(DAQ_REG_HRDWRE, regval)) {
+ if (!Feb_Control_WriteRegister_BitMask(DAQ_REG_HRDWRE, regval, bitmask)) {
LOG(logERROR, ("Could not %s 16 bit expansion (bit mode)\n",
(disable ? "disable" : "enable")));
return 0;
@@ -1262,11 +1259,12 @@ int Feb_Control_Disable16bitConversion(int disable) {
int Feb_Control_Get16bitConversionDisabled(int *ret) {
unsigned int regval = 0;
- if (!Feb_Control_ReadRegister(DAQ_REG_HRDWRE, ®val)) {
+ if (!Feb_Control_ReadRegister_BitMask(DAQ_REG_HRDWRE, ®val,
+ DAQ_REG_HRDWRE_DSBL_16BIT_MSK)) {
LOG(logERROR, ("Could not get 16 bit expansion (bit mode)\n"));
return 0;
}
- if (regval & DAQ_REG_HRDWRE_DSBL_16BIT_MSK) {
+ if (regval) {
*ret = 1;
} else {
*ret = 0;
@@ -1667,6 +1665,15 @@ int Feb_Control_GetReadNRows() {
}
int Feb_Control_WriteRegister(uint32_t offset, uint32_t data) {
+ return Feb_Control_WriteRegister_BitMask(offset, data, BIT32_MSK);
+}
+
+int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval) {
+ return Feb_Control_ReadRegister_BitMask(offset, retval, BIT32_MASK);
+}
+
+int Feb_Control_WriteRegister_BitMask(uint32_t offset, uint32_t data,
+ uint32_t bitmask) {
uint32_t actualOffset = offset;
char side[2][10] = {"right", "left"};
unsigned int addr[2] = {Feb_Control_rightAddress, Feb_Control_leftAddress};
@@ -1690,24 +1697,41 @@ int Feb_Control_WriteRegister(uint32_t offset, uint32_t data) {
for (int iloop = 0; iloop < 2; ++iloop) {
if (run[iloop]) {
- LOG(logDEBUG1,
- ("Writing 0x%x to %s 0x%x\n", data, side[iloop], actualOffset));
- if (!Feb_Interface_WriteRegister(addr[iloop], actualOffset, data, 0,
- 0)) {
- LOG(logERROR, ("Could not write 0x%x to %s addr 0x%x\n", data,
+ LOG(logDEBUG1, ("Writing 0x%x to %s 0x%x (mask:0x%x)\n", data,
+ side[iloop], actualOffset, bitmask));
+
+ uint32_t writeVal = 0;
+ if (!Feb_Interface_ReadRegister(addr[iloop], actualOffset,
+ &writeVal)) {
+ LOG(logERROR, ("Could not read %s addr 0x%x register\n",
side[iloop], actualOffset));
return 0;
}
- uint32_t regVal = 0;
- if (!Feb_Interface_ReadRegister(addr[iloop], actualOffset,
- ®Val)) {
- LOG(logERROR, ("Could not read %s register\n", addr[iloop]));
+ // set only the bits in the mask
+ writeVal &= ~(bitmask);
+ writeVal |= (data & bitmask);
+
+ LOG(logDEBUG1, ("writing 0x%x to 0x%x\n", writeVal, actualOffset));
+ if (!Feb_Interface_WriteRegister(addr[iloop], actualOffset,
+ writeVal, 0, 0)) {
+ LOG(logERROR, ("Could not write 0x%x to %s addr 0x%x\n",
+ writeVal, side[iloop], actualOffset));
return 0;
}
- if (regVal != data) {
+ writeVal &= bitmask;
+
+ uint32_t readVal = 0;
+ if (!Feb_Interface_ReadRegister(addr[iloop], actualOffset,
+ &readVal)) {
+ return 0;
+ }
+ readVal &= bitmask;
+
+ if (writeVal != readVal) {
LOG(logERROR,
- ("Could not write %s register. Write 0x%x, read 0x%x\n",
- addr[iloop], data, regVal));
+ ("Could not write %s addr 0x%x register. Wrote "
+ "0x%x, read 0x%x (mask:0x%x)\n",
+ side[iloop], actualOffset, writeVal, readVal, bitmask));
return 0;
}
}
@@ -1716,7 +1740,9 @@ int Feb_Control_WriteRegister(uint32_t offset, uint32_t data) {
return 1;
}
-int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval) {
+int Feb_Control_ReadRegister_BitMask(uint32_t offset, uint32_t *retval,
+ uint32_t bitmask) {
+
uint32_t actualOffset = offset;
char side[2][10] = {"right", "left"};
unsigned int addr[2] = {Feb_Control_rightAddress, Feb_Control_leftAddress};
@@ -1746,8 +1772,9 @@ int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval) {
side[iloop], actualOffset));
return 0;
}
- LOG(logDEBUG1, ("Read 0x%x from %s 0x%x\n", value[iloop],
- side[iloop], actualOffset));
+ value[iloop] &= bitmask;
+ LOG(logDEBUG1, ("Read 0x%x from %s 0x%x (mask:0x%x)\n",
+ value[iloop], side[iloop], actualOffset, bitmask));
*retval = value[iloop];
// if not the other (left, not right OR right, not left), return the
// value
@@ -1758,7 +1785,7 @@ int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval) {
}
// Inconsistent values when reading both registers
if ((run[0] & run[1]) & (value[0] != value[1])) {
- LOG(logERROR, ("Inconsistent values read from %s 0x%x and %s 0x%x\n",
+ LOG(logERROR, ("Inconsistent values read from %s: 0x%x and %s: 0x%x\n",
side[0], value[0], side[1], value[1]));
return 0;
}
@@ -2180,6 +2207,51 @@ int Feb_Control_GetRightFPGATemp() {
return (int)temperature;
}
+int Feb_Control_GetFPGAHardwareVersion(int *retval) {
+ if (!Feb_Control_activated) {
+ return 0;
+ }
+ unsigned int value = 0;
+ if (!Feb_Control_ReadRegister_BitMask(FEB_REG_STATUS, &value,
+ FEB_REG_STATUS_FX30_MSK)) {
+ LOG(logERROR,
+ ("Trouble reading FEB_REG_STATUS reg to feb hardware version\n"));
+ return 0;
+ }
+ *retval = (value >> FEB_REG_STATUS_FX30_OFST);
+ return 1;
+}
+
+int64_t Feb_Control_GetFrontLeftFirmwareVersion() {
+ if (!Feb_Control_activated) {
+ return 0;
+ }
+ unsigned int value = 0;
+ if (!Feb_Interface_ReadRegister(Feb_Control_leftAddress, FEB_REG_STATUS,
+ &value)) {
+ LOG(logERROR, ("Trouble reading FEB_REG_STATUS reg to get left feb "
+ "fw version\n"));
+ return 0;
+ }
+ return ((value & FEB_REG_STATUS_FW_VERSION_MSK) >>
+ FEB_REG_STATUS_FW_VERSION_OFST);
+}
+
+int64_t Feb_Control_GetFrontRightFirmwareVersion() {
+ if (!Feb_Control_activated) {
+ return 0;
+ }
+ unsigned int value = 0;
+ if (!Feb_Interface_ReadRegister(Feb_Control_rightAddress, FEB_REG_STATUS,
+ &value)) {
+ LOG(logERROR, ("Trouble reading FEB_REG_STATUS reg to get right feb "
+ "fw version\n"));
+ return 0;
+ }
+ return ((value & FEB_REG_STATUS_FW_VERSION_MSK) >>
+ FEB_REG_STATUS_FW_VERSION_OFST);
+}
+
int64_t Feb_Control_GetMeasuredPeriod() {
if (!Feb_Control_activated) {
return 0;
diff --git a/slsDetectorServers/eigerDetectorServer/FebControl.h b/slsDetectorServers/eigerDetectorServer/FebControl.h
index 325c4af44..e5ca463b1 100644
--- a/slsDetectorServers/eigerDetectorServer/FebControl.h
+++ b/slsDetectorServers/eigerDetectorServer/FebControl.h
@@ -95,7 +95,10 @@ int Feb_Control_SetReadNRows(int value);
int Feb_Control_GetReadNRows();
int Feb_Control_WriteRegister(uint32_t offset, uint32_t data);
int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval);
-
+int Feb_Control_WriteRegister_BitMask(uint32_t offset, uint32_t data,
+ uint32_t bitmask);
+int Feb_Control_ReadRegister_BitMask(uint32_t offset, uint32_t *retval,
+ uint32_t bitmask);
// pulsing
int Feb_Control_Pulse_Pixel(int npulses, int x, int y);
int Feb_Control_PulsePixelNMove(int npulses, int inc_x_pos, int inc_y_pos);
@@ -116,5 +119,7 @@ int Feb_Control_PrintCorrectedValues();
// adcs
int Feb_Control_GetLeftFPGATemp();
int Feb_Control_GetRightFPGATemp();
+int64_t Feb_Control_GetFrontLeftFirmwareVersion();
+int64_t Feb_Control_GetFrontRightFirmwareVersion();
int64_t Feb_Control_GetMeasuredPeriod();
int64_t Feb_Control_GetSubMeasuredPeriod();
diff --git a/slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h b/slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h
index 1ec86f834..b1246db33 100644
--- a/slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h
+++ b/slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h
@@ -46,6 +46,10 @@
#define FEB_REG_STATUS_WAIT_FOR_TRGGR_MSK (0x00000001 << FEB_REG_STATUS_WAIT_FOR_TRGGR_OFST)
#define FEB_REG_STATUS_ACQ_DONE_OFST (6)
#define FEB_REG_STATUS_ACQ_DONE_MSK (0x00000001 << FEB_REG_STATUS_ACQ_DONE_OFST)
+#define FEB_REG_STATUS_FX30_OFST (7)
+#define FEB_REG_STATUS_FX30_MSK (0x00000001 << FEB_REG_STATUS_FX30_OFST)
+#define FEB_REG_STATUS_FW_VERSION_OFST (8)
+#define FEB_REG_STATUS_FW_VERSION_MSK (0x000000FF << FEB_REG_STATUS_FW_VERSION_OFST)
#define FEB_REG_STATUS_TEMP_OFST (16)
#define FEB_REG_STATUS_TEMP_MSK (0x0000FFFF << FEB_REG_STATUS_TEMP_OFST)
diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer
index 71197009f..3f8418bcb 100755
Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ
diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_v6.1.2_rc0 b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_v6.1.2_rc0
deleted file mode 100755
index 2ede86048..000000000
Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_v6.1.2_rc0 and /dev/null differ
diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv6.1.1_patch b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv6.1.1_patch
deleted file mode 100755
index 8719a503f..000000000
Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv6.1.1_patch and /dev/null differ
diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c
index 815db9050..11f2d7155 100644
--- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c
+++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c
@@ -123,18 +123,18 @@ void basictests() {
int64_t sw_fw_apiversion = getFirmwareAPIVersion();
LOG(logINFOBLUE,
- ("**************************************************\n"
- "Detector IP Addr:\t\t 0x%x\n"
- "Detector MAC Addr:\t\t 0x%llx\n"
+ ("\n********************************************************\n"
+ "Detector IP Addr : 0x%x\n"
+ "Detector MAC Addr : 0x%llx\n"
- "Firmware Version:\t\t %lld\n"
- "Software Version:\t\t %s\n"
- "F/w-S/w API Version:\t\t %lld\n"
- "Required Firmware Version:\t %d\n"
+ "Firmware (Beb) Version : %lld\n"
+ "F/w-S/w API Version : %lld\n"
+ "Required Firmware Version: %d\n"
+ "Software Version : %s\n"
"********************************************************\n",
(unsigned int)ipadd, (long long unsigned int)macadd,
- (long long int)fwversion, swversion, (long long int)sw_fw_apiversion,
- REQUIRED_FIRMWARE_VERSION));
+ (long long int)fwversion, (long long int)sw_fw_apiversion,
+ REQUIRED_FIRMWARE_VERSION, swversion));
// update default udpdstip and udpdstmac (1g is hardware ip and hardware
// mac)
@@ -161,9 +161,9 @@ void basictests() {
// check for API compatibility - old server
if (sw_fw_apiversion > REQUIRED_FIRMWARE_VERSION) {
sprintf(initErrorMessage,
- "This firmware-software api version (0x%llx) is incompatible "
+ "This firmware-software api version (0x%lld) is incompatible "
"with the software's minimum required firmware version "
- "(0x%llx).\nPlease update detector software to be compatible "
+ "(0x%lld).\nPlease update detector software to be compatible "
"with this firmware.\n",
(long long int)sw_fw_apiversion,
(long long int)REQUIRED_FIRMWARE_VERSION);
@@ -210,20 +210,70 @@ void getServerVersion(char *version) { strcpy(version, APIEIGER); }
u_int64_t getFirmwareVersion() {
#ifdef VIRTUAL
- return 0;
+ return REQUIRED_FIRMWARE_VERSION;
#else
return Beb_GetFirmwareRevision();
#endif
}
+uint64_t getFrontEndFirmwareVersion(enum fpgaPosition fpgaPosition) {
+ uint64_t retval = 0;
+#ifdef VIRTUAL
+ return REQUIRED_FIRMWARE_VERSION;
+#else
+ sharedMemory_lockLocalLink();
+ switch (fpgaPosition) {
+ case FRONT_LEFT:
+ retval = Feb_Control_GetFrontLeftFirmwareVersion(fpgaPosition);
+ break;
+ case FRONT_RIGHT:
+ retval = Feb_Control_GetFrontRightFirmwareVersion(fpgaPosition);
+ break;
+ default:
+ LOG(logERROR,
+ ("unknown index for fpga position to read firmware version\n"));
+ retval = 0;
+ }
+ sharedMemory_unlockLocalLink();
+#endif
+ return retval;
+}
+
u_int64_t getFirmwareAPIVersion() {
#ifdef VIRTUAL
- return 0;
+ return REQUIRED_FIRMWARE_VERSION;
#else
- return (u_int64_t)Beb_GetFirmwareSoftwareAPIVersion();
+ return Beb_GetFirmwareSoftwareAPIVersion();
#endif
}
+void getHardwareVersion(char *version) {
+ strcpy(version, "unknown");
+ int hwversion = getHardwareVersionNumber();
+ const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
+ const char *hwNamesList[] = HARDWARE_VERSION_NAMES;
+ for (int i = 0; i != NUM_HARDWARE_VERSIONS; ++i) {
+ LOG(logDEBUG, ("0x%x %d 0x%x %s\n", hwversion, i, hwNumberList[i],
+ hwNamesList[i]));
+ if (hwNumberList[i] == hwversion) {
+ strcpy(version, hwNamesList[i]);
+ return;
+ }
+ }
+}
+
+int getHardwareVersionNumber() {
+ int retval = 0;
+#ifndef VIRTUAL
+ sharedMemory_lockLocalLink();
+ if (!Feb_Control_GetFPGAHardwareVersion(&retval)) {
+ retval = -1;
+ }
+ sharedMemory_unlockLocalLink();
+#endif
+ return retval;
+}
+
int getModuleId(int *ret, char *mess) {
return getModuleIdInFile(ret, mess, ID_FILE);
}
@@ -355,6 +405,37 @@ void initControlServer() {
Beb_SetTopVariable(top);
Beb_Beb();
LOG(logDEBUG1, ("Control server: BEB Initialization done\n"));
+
+ // Getting the feb versions after initialization
+ char hversion[MAX_STR_LENGTH] = {0};
+ memset(hversion, 0, MAX_STR_LENGTH);
+ getHardwareVersion(hversion);
+ int64_t fwversion = getFirmwareVersion();
+ int64_t feblfwversion = getFrontEndFirmwareVersion(FRONT_LEFT);
+ int64_t febrfwversion = getFrontEndFirmwareVersion(FRONT_RIGHT);
+ LOG(logINFOBLUE,
+ ("\n********************************************************\n"
+ "Feb Versions\n"
+ "Hardware Version : %s\n"
+ "Firmware (Febl) Version : %lld\n"
+ "Firmware (Febr) Version : %lld\n"
+ "********************************************************\n",
+ hversion, (long long int)feblfwversion,
+ (long long int)febrfwversion));
+
+ // ensure febl, febr and beb fw versions are the same
+ if (fwversion != feblfwversion || fwversion != febrfwversion) {
+ sprintf(
+ initErrorMessage,
+ "Inconsistent firmware versions in feb and beb. [Beb: %lld, "
+ "Febl: %lld Febr: %lld]\n",
+ (long long int)fwversion, (long long int)feblfwversion,
+ (long long int)febrfwversion);
+ LOG(logERROR, (initErrorMessage));
+ initError = FAIL;
+ return;
+ }
+
#endif
// also reads config file and deactivates
setupDetector();
@@ -861,12 +942,15 @@ int setDynamicRange(int dr) {
LOG(logINFO, ("Setting dynamic range: %d\n", dr));
#else
sharedMemory_lockLocalLink();
- if (Feb_Control_SetDynamicRange(dr)) {
- if (!Beb_SetUpTransferParameters(dr)) {
- LOG(logERROR, ("Could not set bit mode in the back end\n"));
- sharedMemory_unlockLocalLink();
- return eiger_dynamicrange;
- }
+ if (!Feb_Control_SetDynamicRange(dr)) {
+ LOG(logERROR, ("Could not set dynamic range in feb\n"));
+ sharedMemory_unlockLocalLink();
+ return FAIL;
+ }
+ if (!Beb_SetUpTransferParameters(dr)) {
+ LOG(logERROR, ("Could not set bit mode in the back end\n"));
+ sharedMemory_unlockLocalLink();
+ return eiger_dynamicrange;
}
sharedMemory_unlockLocalLink();
#endif
@@ -1454,6 +1538,12 @@ int setHighVoltage(int val) {
sharedMemory_unlockLocalLink();
return -3;
}
+ // need to read the file twice to get the proper value
+ if (!Feb_Control_GetHighVoltage(&eiger_highvoltage)) {
+ LOG(logERROR, ("Could not read high voltage\n"));
+ sharedMemory_unlockLocalLink();
+ return -3;
+ }
sharedMemory_unlockLocalLink();
// tolerance of 5
@@ -2664,6 +2754,10 @@ void *start_timer(void *arg) {
header->modId = eiger_virtual_module_id;
header->row = row;
header->column = colLeft;
+ if (eiger_virtual_quad_mode) {
+ header->row = 1; // left is next row
+ header->column = 0; // left same first column
+ }
char packetData2[packetsize];
memset(packetData2, 0, packetsize);
@@ -2672,11 +2766,11 @@ void *start_timer(void *arg) {
header->version = SLS_DETECTOR_HEADER_VERSION;
header->frameNumber = frameNr + iframes;
header->packetNumber = i;
- header->modId = eiger_virtual_module_id;
+ header->modId = eiger_virtual_module_id + 1;
header->row = row;
header->column = colRight;
if (eiger_virtual_quad_mode) {
- header->row = 1; // right is next row
+ header->row = 0; // right is next row
header->column = 0; // right same first column
}
diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h
index cca94c3fd..57c8d9a0c 100644
--- a/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h
+++ b/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h
@@ -5,7 +5,12 @@
#define LINKED_SERVER_NAME "eigerDetectorServer"
-#define REQUIRED_FIRMWARE_VERSION (30)
+#define NUM_HARDWARE_VERSIONS (2)
+#define HARDWARE_VERSION_NUMBERS {0x0, 0x1};
+#define HARDWARE_VERSION_NAMES \
+ { "FX70T", "FX30T" }
+
+#define REQUIRED_FIRMWARE_VERSION (31)
// virtual ones renamed for consistency
// real ones keep previous name for compatibility (already in production)
#ifdef VIRTUAL
@@ -137,6 +142,7 @@ enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
#define UDP_HEADER_MAX_FRAME_VALUE (0xFFFFFFFFFFFF)
#define BIT16_MASK (0xFFFF)
+#define BIT32_MSK (0xFFFFFFFF)
#define DAC_MIN_MV (0)
#define DAC_MAX_MV (2048)
diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer
index 22bc1f759..f30601627 100755
Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ
diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c
index 7b1162277..886d947ee 100644
--- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c
+++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c
@@ -93,7 +93,7 @@ void basictests() {
#endif
if (mapCSP0() == FAIL) {
strcpy(initErrorMessage,
- "Could not map to memory. Dangerous to continue.\n");
+ "Could not map to memory. Cannot proceed. Check Firmware.\n");
LOG(logERROR, (initErrorMessage));
initError = FAIL;
return;
@@ -105,8 +105,8 @@ void basictests() {
(checkType() == FAIL) || (testFpga() == FAIL) ||
(testBus() == FAIL))) {
sprintf(initErrorMessage,
- "Could not pass basic tests of FPGA and bus. Dangerous to "
- "continue. (Firmware version:0x%llx) \n",
+ "Could not pass basic tests of FPGA and bus. Cannot proceed. "
+ "Check Firmware. (Firmware version:0x%llx) \n",
getFirmwareVersion());
LOG(logERROR, ("%s\n\n", initErrorMessage));
initError = FAIL;
@@ -396,7 +396,7 @@ void initStopServer() {
if (mapCSP0() == FAIL) {
initError = FAIL;
strcpy(initErrorMessage,
- "Stop Server: Map Fail. Dangerous to continue. Goodbye!\n");
+ "Stop Server: Map Fail. Cannot proceed. Check Firmware.\n");
LOG(logERROR, (initErrorMessage));
initCheckDone = 1;
return;
diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h
index d54c39643..6c3dd1f0b 100644
--- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h
+++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h
@@ -3,7 +3,7 @@
#pragma once
#include "sls/sls_detector_defs.h"
-#define REQRD_FRMWRE_VRSN (0x220901)
+#define REQRD_FRMWRE_VRSN (0x221123)
#define KERNEL_DATE_VRSN "Mon May 10 18:00:21 CEST 2021"
#define ID_FILE "detid_gotthard2.txt"
diff --git a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer
index 745c14b42..0c52b5ea9 100755
Binary files a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer and b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer differ
diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c
index ae6308439..ebdca8fa0 100644
--- a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c
+++ b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c
@@ -87,7 +87,7 @@ void basictests() {
#endif
if (mapCSP0() == FAIL) {
strcpy(initErrorMessage,
- "Could not map to memory. Dangerous to continue.\n");
+ "Could not map to memory. Cannot proceed. Check Firmware.\n");
LOG(logERROR, (initErrorMessage));
initError = FAIL;
}
@@ -97,7 +97,7 @@ void basictests() {
((checkType() == FAIL) || (testFpga() == FAIL) ||
(testBus() == FAIL))) {
strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. "
- "Dangerous to continue.\n");
+ "Cannot proceed. Check Firmware.\n");
LOG(logERROR, ("%s\n\n", initErrorMessage));
initError = FAIL;
return;
@@ -381,7 +381,7 @@ void initStopServer() {
if (mapCSP0() == FAIL) {
initError = FAIL;
strcpy(initErrorMessage,
- "Stop Server: Map Fail. Dangerous to continue. Goodbye!\n");
+ "Stop Server: Map Fail. Cannot proceed. Check Firmware.\n");
LOG(logERROR, (initErrorMessage));
initCheckDone = 1;
return;
@@ -1007,7 +1007,9 @@ int setDelayAfterTrigger(int64_t val) {
// validate for tolerance
int64_t retval = getDelayAfterTrigger();
val /= (1E-9 * CLK_FREQ);
- val -= masterdefaultdelay;
+ if (master) {
+ val -= masterdefaultdelay;
+ }
if (val != retval) {
return FAIL;
}
diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer
index 1a85d4cc9..ea5764e54 100755
Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ
diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c
index e7d474840..62ea6fe04 100644
--- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c
+++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c
@@ -82,7 +82,7 @@ void basictests() {
#endif
if (mapCSP0() == FAIL) {
strcpy(initErrorMessage,
- "Could not map to memory. Dangerous to continue.\n");
+ "Could not map to memory. Cannot proceed. Check Firmware.\n");
LOG(logERROR, (initErrorMessage));
initError = FAIL;
}
@@ -91,8 +91,10 @@ void basictests() {
if ((!debugflag) && (!updateFlag) &&
((checkType() == FAIL) || (testFpga() == FAIL) ||
(testBus() == FAIL))) {
- strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. "
- "Dangerous to continue.\n");
+ sprintf(initErrorMessage,
+ "Could not pass basic tests of FPGA and bus. Cannot proceed. "
+ "Check Firmware. (Firmware version:0x%llx) \n",
+ getFirmwareVersion());
LOG(logERROR, ("%s\n\n", initErrorMessage));
initError = FAIL;
return;
@@ -428,7 +430,7 @@ void initStopServer() {
if (mapCSP0() == FAIL) {
initError = FAIL;
strcpy(initErrorMessage,
- "Stop Server: Map Fail. Dangerous to continue. Goodbye!\n");
+ "Stop Server: Map Fail. Cannot proceed. Check Firmware.\n");
LOG(logERROR, (initErrorMessage));
initCheckDone = 1;
return;
@@ -2798,6 +2800,7 @@ 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);
#ifndef VIRTUAL
// block till frame is sent out
diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h
index 955b49eb7..d54926855 100644
--- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h
+++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h
@@ -5,8 +5,8 @@
#include "sls/sls_detector_defs.h"
#define MIN_REQRD_VRSN_T_RD_API 0x171220
-#define REQRD_FRMWRE_VRSN_BOARD2 0x220421 // 1.0 pcb (version = 010)
-#define REQRD_FRMWRE_VRSN 0x220422 // 2.0 pcb (version = 011)
+#define REQRD_FRMWRE_VRSN_BOARD2 0x221104 // 1.0 pcb (version = 010)
+#define REQRD_FRMWRE_VRSN 0x221103 // 2.0 pcb (version = 011)
#define NUM_HARDWARE_VERSIONS (2)
#define HARDWARE_VERSION_NUMBERS \
diff --git a/slsDetectorServers/moenchDetectorServer/CMakeLists.txt b/slsDetectorServers/moenchDetectorServer/CMakeLists.txt
index 4d6901afc..3f54d0371 100644
--- a/slsDetectorServers/moenchDetectorServer/CMakeLists.txt
+++ b/slsDetectorServers/moenchDetectorServer/CMakeLists.txt
@@ -8,35 +8,28 @@ add_executable(moenchDetectorServer_virtual
../slsDetectorServer/src/blackfin.c
../slsDetectorServer/src/common.c
../slsDetectorServer/src/commonServerFunctions.c
- ../slsDetectorServer/src/communication_funcs_UDP.c
- ../slsDetectorServer/src/UDPPacketHeaderGenerator.c
../slsDetectorServer/src/AD9257.c
../slsDetectorServer/src/ALTERA_PLL.c
../slsDetectorServer/src/LTC2620.c
../slsDetectorServer/src/MAX1932.c
- ../slsDetectorServer/src/programViaBlackfin.c
- ../slsDetectorServer/src/loadPattern.c
+ ../slsDetectorServer/src/programViaBlackfin.c
+ ../slsDetectorServer/src/communication_funcs_UDP.c
../slsDetectorServer/src/sharedMemory.c
../../slsSupportLib/src/md5.c
)
-include_directories(
+target_include_directories(moenchDetectorServer_virtual
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
../slsDetectorServer/include
../../slsSupportLib/include
- ../../slsDetectorSoftware/include/sls/
-)
-
-target_include_directories(moenchDetectorServer_virtual
- PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
)
target_compile_definitions(moenchDetectorServer_virtual
- PUBLIC MOENCHD VIRTUAL STOP_SERVER
+ PUBLIC MOENCHD VIRTUAL STOP_SERVER #TEST_MOD_GEOMETRY
)
target_link_libraries(moenchDetectorServer_virtual
PUBLIC pthread rt slsProjectCSettings
- m
)
set_target_properties(moenchDetectorServer_virtual PROPERTIES
@@ -44,7 +37,9 @@ set_target_properties(moenchDetectorServer_virtual PROPERTIES
)
install(TARGETS moenchDetectorServer_virtual
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ EXPORT "${TARGETS_EXPORT_NAME}"
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
-configure_file(DefaultPattern_moench.txt ${CMAKE_BINARY_DIR}/bin/DefaultPattern_moench.txt COPYONLY)
\ No newline at end of file
+configure_file(config_moench.txt ${CMAKE_BINARY_DIR}/bin/config_moench.txt COPYONLY)
+configure_file(detid_moench.txt ${CMAKE_BINARY_DIR}/bin/detid_moench.txt COPYONLY)
diff --git a/slsDetectorServers/moenchDetectorServer/DefaultPattern_moench.txt b/slsDetectorServers/moenchDetectorServer/DefaultPattern_moench.txt
deleted file mode 100755
index 0114e9bb0..000000000
--- a/slsDetectorServers/moenchDetectorServer/DefaultPattern_moench.txt
+++ /dev/null
@@ -1,301 +0,0 @@
-patword 0x0000 0x0008599f0418503a
-patword 0x0001 0x0008599f0418503a
-patword 0x0002 0x000859960418503a
-patword 0x0003 0x000859960418503a
-patword 0x0004 0x000859960418503a
-patword 0x0005 0x000859960418503a
-patword 0x0006 0x000859960418503a
-patword 0x0007 0x000859960418503a
-patword 0x0008 0x000859960418503a
-patword 0x0009 0x000859960418503a
-patword 0x000a 0x000859960418503a
-patword 0x000b 0x000859960418503a
-patword 0x000c 0x000859960418503a
-patword 0x000d 0x000859960418503a
-patword 0x000e 0x000859960418503a
-patword 0x000f 0x000859960418503a
-patword 0x0010 0x000859960418503a
-patword 0x0011 0x000859960418503a
-patword 0x0012 0x000859960418503a
-patword 0x0013 0x000859960418503a
-patword 0x0014 0x000859960418503a
-patword 0x0015 0x000859960418503a
-patword 0x0016 0x000819960418501a
-patword 0x0017 0x000819960418501a
-patword 0x0018 0x000819960418501a
-patword 0x0019 0x000819960418501a
-patword 0x001a 0x000819960418501a
-patword 0x001b 0x000819960418501a
-patword 0x001c 0x000819960418501a
-patword 0x001d 0x000819960418501a
-patword 0x001e 0x000819960418501a
-patword 0x001f 0x000819960418501a
-patword 0x0020 0x000819960418501a
-patword 0x0021 0x000819960418501a
-patword 0x0022 0x000819960418501a
-patword 0x0023 0x000819960418501a
-patword 0x0024 0x000819960418501a
-patword 0x0025 0x000819960418501a
-patword 0x0026 0x000819960418501a
-patword 0x0027 0x000819960418501a
-patword 0x0028 0x000819960418501a
-patword 0x0029 0x000819960418501a
-patword 0x002a 0x000819960418501a
-patword 0x002b 0x000819960418501a
-patword 0x002c 0x000819960418501a
-patword 0x002d 0x000819960418501a
-patword 0x002e 0x000819960418501a
-patword 0x002f 0x000819960418501a
-patword 0x0030 0x000819960008501a
-patword 0x0031 0x000819960008501a
-patword 0x0032 0x000819960008501a
-patword 0x0033 0x000819960008501a
-patword 0x0034 0x000819960008501a
-patword 0x0035 0x000819960008501a
-patword 0x0036 0x000819960008501a
-patword 0x0037 0x000819960008501a
-patword 0x0038 0x000819960008501a
-patword 0x0039 0x000819960008501a
-patword 0x003a 0x000819960008501a
-patword 0x003b 0x000819960008501a
-patword 0x003c 0x000819960008501a
-patword 0x003d 0x000819960008501a
-patword 0x003e 0x000819960008501a
-patword 0x003f 0x000819960008501a
-patword 0x0040 0x000819960008501a
-patword 0x0041 0x000819960008501a
-patword 0x0042 0x000819960008501a
-patword 0x0043 0x000819960008501a
-patword 0x0044 0x0008199f0008501a
-patword 0x0045 0x0008199f0008501a
-patword 0x0046 0x0008199f0008501a
-patword 0x0047 0x0008199f0008501a
-patword 0x0048 0x0008199f0008501a
-patword 0x0049 0x0008199f0008501a
-patword 0x004a 0x0008199f0008501a
-patword 0x004b 0x0008199f0008501a
-patword 0x004c 0x0008199f0008501a
-patword 0x004d 0x0008199f0008501a
-patword 0x004e 0x0008199f0008501a
-patword 0x004f 0x0008199f0008501a
-patword 0x0050 0x0008199f0008501a
-patword 0x0051 0x0008199f0008501a
-patword 0x0052 0x0008199f0008501a
-patword 0x0053 0x0008199f0008501a
-patword 0x0054 0x0008199f0008501a
-patword 0x0055 0x0008199f0008501a
-patword 0x0056 0x0008199f0008501a
-patword 0x0057 0x0008199f0008501a
-patword 0x0058 0x0008599f0008503a
-patword 0x0059 0x0008599f0008503a
-patword 0x005a 0x000c599f000850ba
-patword 0x005b 0x000c599f000850ba
-patword 0x005c 0x000c599f000850ba
-patword 0x005d 0x000c599f000850ba
-patword 0x005e 0x000c599f000850ba
-patword 0x005f 0x000c599f000850ba
-patword 0x0060 0x000c599f000850ba
-patword 0x0061 0x000c599f000850ba
-patword 0x0062 0x000c599f000850ba
-patword 0x0063 0x000c599f000850ba
-patword 0x0064 0x000c599f000850ba
-patword 0x0065 0x000c599f000850ba
-patword 0x0066 0x000c599f000850ba
-patword 0x0067 0x000c599f000850ba
-patword 0x0068 0x000c599f000850ba
-patword 0x0069 0x000c599f000850ba
-patword 0x006a 0x000c599f000850ba
-patword 0x006b 0x000c599f000850ba
-patword 0x006c 0x000c599f000850ba
-patword 0x006d 0x000c599f000850ba
-patword 0x006e 0x000c799f010858ba
-patword 0x006f 0x000c799f010858ba
-patword 0x0070 0x000c599f000850ba
-patword 0x0071 0x000c599f000850ba
-patword 0x0072 0x000c599f000850ba
-patword 0x0073 0x000c599f000850ba
-patword 0x0074 0x000c599f000850ba
-patword 0x0075 0x000c599f000850ba
-patword 0x0076 0x000c599f000850ba
-patword 0x0077 0x000c599f000850ba
-patword 0x0078 0x000c599f000850ba
-patword 0x0079 0x000c599f000850ba
-patword 0x007a 0x000c599f000850ba
-patword 0x007b 0x000c599f000850ba
-patword 0x007c 0x000c599f000850ba
-patword 0x007d 0x000c599f000850ba
-patword 0x007e 0x000c599f000850ba
-patword 0x007f 0x000c599f000850ba
-patword 0x0080 0x000c599f000850ba
-patword 0x0081 0x000c599f000850ba
-patword 0x0082 0x000c599f000850ba
-patword 0x0083 0x000c599f000850ba
-patword 0x0084 0x000c599f000850ba
-patword 0x0085 0x000c599f000850ba
-patword 0x0086 0x000c599f400850ba
-patword 0x0087 0x000c599f400850ba
-patword 0x0088 0x000c599f600850ba
-patword 0x0089 0x000c599f400850ba
-patword 0x008a 0x000c599f400850ba
-patword 0x008b 0x000c599f400850ba
-patword 0x008c 0x840c599f682e50ba
-patword 0x008d 0x840c599f482850ba
-patword 0x008e 0x840c599f000e50ba
-patword 0x008f 0x840c599f000850ba
-patword 0x0090 0x840c599f000e50ba
-patword 0x0091 0x840c599f000850ba
-patword 0x0092 0x840c599f000e50ba
-patword 0x0093 0x840c599f000850ba
-patword 0x0094 0x840c599f000e50ba
-patword 0x0095 0x840c599f000850ba
-patword 0x0096 0x840c599f000e50ba
-patword 0x0097 0x840c599f000850ba
-patword 0x0098 0x840c599f000e50ba
-patword 0x0099 0x840c599f000850ba
-patword 0x009a 0x840c599f000e50ba
-patword 0x009b 0x840c599f000850ba
-patword 0x009c 0x840c599f000e50ba
-patword 0x009d 0x840c599f000850ba
-patword 0x009e 0x840c599f000e50ba
-patword 0x009f 0x840c599f000850ba
-patword 0x00a0 0x840c599f000e50ba
-patword 0x00a1 0x840c599f000850ba
-patword 0x00a2 0x840c599f000e50ba
-patword 0x00a3 0x840c599f000850ba
-patword 0x00a4 0x840c599f000e50ba
-patword 0x00a5 0x840c599f000850ba
-patword 0x00a6 0x840c599f200e50ba
-patword 0x00a7 0x840c599f000850ba
-patword 0x00a8 0x840c599f000e50ba
-patword 0x00a9 0x840c599f000850ba
-patword 0x00aa 0x840c599f000e50ba
-patword 0x00ab 0x840c599f000850ba
-patword 0x00ac 0x840c599f000e50ba
-patword 0x00ad 0x840c599f000850ba
-patword 0x00ae 0x840c599f000e50ba
-patword 0x00af 0x840c599f000850ba
-patword 0x00b0 0x840c599f000e50ba
-patword 0x00b1 0x840c599f000850ba
-patword 0x00b2 0x840c599f000e50ba
-patword 0x00b3 0x840c599f000850ba
-patword 0x00b4 0x840c599f000e50ba
-patword 0x00b5 0x840c599f000850ba
-patword 0x00b6 0x840c599f000e50ba
-patword 0x00b7 0x840c599f000850ba
-patword 0x00b8 0x840c599f000e50ba
-patword 0x00b9 0x840c599f000850ba
-patword 0x00ba 0x840c599f000e50ba
-patword 0x00bb 0x840c599f000850ba
-patword 0x00bc 0x840c599f000e50ba
-patword 0x00bd 0x840c599f000850ba
-patword 0x00be 0x840c599f282e50ba
-patword 0x00bf 0x840c599f082850ba
-patword 0x00c0 0x840c599f000e50ba
-patword 0x00c1 0x840c599f000850ba
-patword 0x00c2 0x840c599f000e50ba
-patword 0x00c3 0x840c599f000850ba
-patword 0x00c4 0x840c599f000e50ba
-patword 0x00c5 0x840c599f000850ba
-patword 0x00c6 0x840c599f000e50ba
-patword 0x00c7 0x840c599f000850ba
-patword 0x00c8 0x840c599f000e50ba
-patword 0x00c9 0x840c599f000850ba
-patword 0x00ca 0x840c599f000e50ba
-patword 0x00cb 0x840c599f000850ba
-patword 0x00cc 0x840c599f000e50ba
-patword 0x00cd 0x840c599f000850ba
-patword 0x00ce 0x840c599f000e50ba
-patword 0x00cf 0x840c599f000850ba
-patword 0x00d0 0x840c599f000e50ba
-patword 0x00d1 0x840c599f000850ba
-patword 0x00d2 0x840c599f000e50ba
-patword 0x00d3 0x840c599f000850ba
-patword 0x00d4 0x840c599f000e50ba
-patword 0x00d5 0x840c599f000850ba
-patword 0x00d6 0x840c599f000e50ba
-patword 0x00d7 0x840c599f000850ba
-patword 0x00d8 0x840c599f200e50ba
-patword 0x00d9 0x840c599f000850ba
-patword 0x00da 0x840c599f000e50ba
-patword 0x00db 0x840c599f000850ba
-patword 0x00dc 0x840c599f000e50ba
-patword 0x00dd 0x840c599f000850ba
-patword 0x00de 0x840c599f000e50ba
-patword 0x00df 0x840c599f000850ba
-patword 0x00e0 0x840c599f000e50ba
-patword 0x00e1 0x840c599f000850ba
-patword 0x00e2 0x840c599f000e50ba
-patword 0x00e3 0x840c599f000850ba
-patword 0x00e4 0x840c599f000e50ba
-patword 0x00e5 0x840c599f000850ba
-patword 0x00e6 0x840c599f000e50ba
-patword 0x00e7 0x840c599f000850ba
-patword 0x00e8 0x840c599f000e50ba
-patword 0x00e9 0x840c599f000850ba
-patword 0x00ea 0x840c599f000e50ba
-patword 0x00eb 0x840c599f000850ba
-patword 0x00ec 0x840c599f000e50ba
-patword 0x00ed 0x840c599f000850ba
-patword 0x00ee 0x840c599f000e50ba
-patword 0x00ef 0x840c599f000850ba
-patword 0x00f0 0x040c599f000850ba
-patword 0x00f1 0x040c599f000850ba
-patword 0x00f2 0x000c599f000850ba
-patword 0x00f3 0x000c599f000850ba
-patword 0x00f4 0x0008599f200e503a
-patword 0x00f5 0x0008599f0008503a
-patword 0x00f6 0x0008599f200e503a
-patword 0x00f7 0x0008599f0008503a
-patword 0x00f8 0x0008599f0008503a
-patword 0x00f9 0x0008599f0008503a
-patword 0x00fa 0x0008599f0008503a
-patword 0x00fb 0x0008599f0008503a
-patword 0x00fc 0x0008599f0008503a
-patword 0x00fd 0x0008599f0008503a
-patword 0x00fe 0x0008599f0008503a
-patword 0x00ff 0x0008599f0008503a
-patword 0x0100 0x0008599f0008503a
-patword 0x0101 0x0008599f0008503a
-patword 0x0102 0x0008599f0008503a
-patword 0x0103 0x0008599f0008503a
-patword 0x0104 0x0008599f0008503a
-patword 0x0105 0x0008599f0008503a
-patword 0x0106 0x0008599f0008503a
-patword 0x0107 0x0008599f0008503a
-patword 0x0108 0x0008599f0008503a
-patword 0x0109 0x0008599f0008503a
-patword 0x010a 0x0008599f0008503a
-patword 0x010b 0x0008599f0008503a
-patword 0x010c 0x0008599f0008503a
-patword 0x010d 0x0008599f0008503a
-patword 0x010e 0x0008599f0008503a
-patword 0x010f 0x0008599f0008503a
-patword 0x0110 0x0008599f0008503a
-patword 0x0111 0x0008599f0008503a
-patioctrl 0x8f0effff6dbffdbf
-patlimits 0x0000 0x0110
-patloop 0 0x00be 0x00ef
-patnloop 0 199
-patloop 1 0x0400 0x0400
-patnloop 1 0
-patloop 2 0x0400 0x0400
-patnloop 2 0
-patwait 0 0x002e
-patwaittime 0 800
-patwait 1 0x0400
-patwaittime 1 0
-patwait 2 0x0400
-patwaittime 2 0
-
-patloop 3 0x1fff 0x1fff
-patnloop 3 0
-patloop 4 0x1fff 0x1fff
-patnloop 4 0
-patloop 5 0x1fff 0x1fff
-patnloop 5 0
-patwait 3 0x1fff
-patwaittime 3 0
-patwait 4 0x1fff
-patwaittime 4 0
-patwait 5 0x1fff
-patwaittime 5 0
diff --git a/slsDetectorServers/moenchDetectorServer/Makefile b/slsDetectorServers/moenchDetectorServer/Makefile
index e3592fcf3..4f79b49f9 100755
--- a/slsDetectorServers/moenchDetectorServer/Makefile
+++ b/slsDetectorServers/moenchDetectorServer/Makefile
@@ -4,22 +4,21 @@ 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 = bfin-uclinux-
CC = $(CROSS)gcc
-CFLAGS += -Wall -std=gnu99 -DMOENCHD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(det_lib) -I$(current_dir) #-DVERBOSEI #-DVERBOSE
-LDLIBS += -lm -lrt -pthread
+CFLAGS += -Wall -std=gnu99 -DMOENCHD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DVERBOSEI #-DVERBOSE
+LDLIBS += -lm -lrt -pthread
PROGS = moenchDetectorServer
DESTDIR ?= bin
INSTMODE = 0777
-SRCS = slsDetectorFunctionList.c
-SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programViaBlackfin.c $(main_src)loadPattern.c $(main_src)/sharedMemory.c $(md5_dir)md5.c
-
-OBJS = $(SRCS:.c=.o)
+SRCS = slsDetectorFunctionList.c
+SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programViaBlackfin.c $(main_src)/sharedMemory.c $(md5_dir)md5.c
+OBJS = $(SRCS:.c=.o)
+
all: clean $(PROGS)
version: clean versioning $(PROGS)
@@ -35,12 +34,12 @@ versioning:
$(PROGS): $(OBJS)
# echo $(OBJS)
mkdir -p $(DESTDIR)
- $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
+ $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
mv $(PROGS) $(DESTDIR)
- cp DefaultPattern_moench.txt $(DESTDIR)
+ cp config_moench.txt $(DESTDIR)
+ cp detid_moench.txt $(DESTDIR)
rm *.gdb
- rm $(main_src)*.o
- rm *.o $(md5_dir)*.o
+ rm $(main_src)*.o $(md5_dir)*.o
clean:
rm -rf $(DESTDIR)/$(PROGS) *.o *.gdb $(main_src)*.o $(md5_dir)*.o
diff --git a/slsDetectorServers/moenchDetectorServer/RegisterDefs.h b/slsDetectorServers/moenchDetectorServer/RegisterDefs.h
index bfd563358..2e1870768 100644
--- a/slsDetectorServers/moenchDetectorServer/RegisterDefs.h
+++ b/slsDetectorServers/moenchDetectorServer/RegisterDefs.h
@@ -1,642 +1,467 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#pragma once
+// clang-format off
-/* Definitions for FPGA */
+/* Definitions for FPGA*/
#define MEM_MAP_SHIFT 1
-/* FPGA Version RO register */
-#define FPGA_VERSION_REG (0x00 << MEM_MAP_SHIFT)
-
-#define FPGA_VERSION_BRD_RVSN_OFST (0)
-#define FPGA_VERSION_BRD_RVSN_MSK (0x00FFFFFF << FPGA_VERSION_BRD_RVSN_OFST)
-#define FPGA_VERSION_DTCTR_TYP_OFST (24)
-#define FPGA_VERSION_DTCTR_TYP_MSK (0x000000FF << FPGA_VERSION_DTCTR_TYP_OFST)
-#define FPGA_VERSION_DTCTR_TYP_MOENCH_VAL \
- ((0x5 << FPGA_VERSION_DTCTR_TYP_OFST) & FPGA_VERSION_DTCTR_TYP_MSK)
-
-/* Fix pattern RO register */
-#define FIX_PATT_REG (0x01 << MEM_MAP_SHIFT)
-
-#define FIX_PATT_VAL (0xACDC2016)
-
-/* Status RO register */
-#define STATUS_REG (0x02 << MEM_MAP_SHIFT)
-
-#define STATUS_RN_BSY_OFST (0)
-#define STATUS_RN_BSY_MSK (0x00000001 << STATUS_RN_BSY_OFST)
-#define STATUS_RDT_BSY_OFST (1)
-#define STATUS_RDT_BSY_MSK (0x00000001 << STATUS_RDT_BSY_OFST)
-#define STATUS_ANY_FF_FLL_OFST (2)
-#define STATUS_ANY_FF_FLL_MSK (0x00000001 << STATUS_ANY_FF_FLL_OFST)
-#define STATUS_WTNG_FR_TRGGR_OFST (3)
-#define STATUS_WTNG_FR_TRGGR_MSK (0x00000001 << STATUS_WTNG_FR_TRGGR_OFST)
-#define STATUS_DLY_BFR_OFST (4)
-#define STATUS_DLY_BFR_MSK (0x00000001 << STATUS_DLY_BFR_OFST)
-#define STATUS_DLY_AFTR_OFST (5)
-#define STATUS_DLY_AFTR_MSK (0x00000001 << STATUS_DLY_AFTR_OFST)
-#define STATUS_EXPSNG_OFST (6)
-#define STATUS_EXPSNG_MSK (0x00000001 << STATUS_EXPSNG_OFST)
-#define STATUS_CNT_ENBL_OFST (7)
-#define STATUS_CNT_ENBL_MSK (0x00000001 << STATUS_CNT_ENBL_OFST)
-#define STATUS_SM_FF_FLL_OFST (11)
-#define STATUS_SM_FF_FLL_MSK (0x00000001 << STATUS_SM_FF_FLL_OFST)
-#define STATUS_STPPD_OFST (15)
-#define STATUS_STPPD_MSK (0x00000001 << STATUS_STPPD_OFST)
-#define STATUS_ALL_FF_EMPTY_OFST (16)
-#define STATUS_ALL_FF_EMPTY_MSK (0x00000001 << STATUS_ALL_FF_EMPTY_OFST)
-#define STATUS_CYCL_RN_BSY_OFST (17)
-#define STATUS_CYCL_RN_BSY_MSK (0x00000001 << STATUS_CYCL_RN_BSY_OFST)
-#define STATUS_FRM_RN_BSY_OFST (18)
-#define STATUS_FRM_RN_BSY_MSK (0x00000001 << STATUS_FRM_RN_BSY_OFST)
-#define STATUS_ADC_DESERON_OFST (19)
-#define STATUS_ADC_DESERON_MSK (0x00000001 << STATUS_ADC_DESERON_OFST)
-#define STATUS_PLL_RCNFG_BSY_OFST (20)
-#define STATUS_PLL_RCNFG_BSY_MSK (0x00000001 << STATUS_PLL_RCNFG_BSY_OFST)
-#define STATUS_DT_STRMNG_BSY_OFST (21)
-#define STATUS_DT_STRMNG_BSY_MSK (0x00000001 << STATUS_DT_STRMNG_BSY_OFST)
-#define STATUS_FRM_PCKR_BSY_OFST (22)
-#define STATUS_FRM_PCKR_BSY_MSK (0x00000001 << STATUS_FRM_PCKR_BSY_OFST)
-#define STATUS_PLL_PHS_DN_OFST (23)
-#define STATUS_PLL_PHS_DN_MSK (0x00000001 << STATUS_PLL_PHS_DN_OFST)
-#define STATUS_PT_CNTRL_STTS_OFF_OFST (24)
-#define STATUS_PT_CNTRL_STTS_OFF_MSK \
- (0x000000FF << STATUS_PT_CNTRL_STTS_OFF_OFST)
-#define STATUS_IDLE_MSK (0x677FF)
-
-/* Look at me RO register TODO */
-#define LOOK_AT_ME_REG (0x03 << MEM_MAP_SHIFT)
-
-/* System Status RO register */
-#define SYSTEM_STATUS_REG (0x04 << MEM_MAP_SHIFT)
-
-#define SYSTEM_STATUS_DDR3_CLBRTN_OK_OFST (0)
-#define SYSTEM_STATUS_DDR3_CLBRTN_OK_MSK \
- (0x00000001 << SYSTEM_STATUS_DDR3_CLBRTN_OK_OFST)
-#define SYSTEM_STATUS_DDR3_CLBRTN_FL_OFST (1)
-#define SYSTEM_STATUS_DDR3_CLBRTN_FL_MSK \
- (0x00000001 << SYSTEM_STATUS_DDR3_CLBRTN_FL_OFST)
-#define SYSTEM_STATUS_DDR3_INT_DN_OFST (2)
-#define SYSTEM_STATUS_DDR3_INT_DN_MSK \
- (0x00000001 << SYSTEM_STATUS_DDR3_INT_DN_OFST)
-#define SYSTEM_STATUS_RCNFG_PLL_LCK_OFST (3)
-#define SYSTEM_STATUS_RCNFG_PLL_LCK_MSK \
- (0x00000001 << SYSTEM_STATUS_RCNFG_PLL_LCK_OFST)
-#define SYSTEM_STATUS_PLL_A_LCK_OFST (4)
-#define SYSTEM_STATUS_PLL_A_LCK_MSK (0x00000001 << SYSTEM_STATUS_PLL_A_LCK_OFST)
-
-/* PLL Param (Reconfiguratble PLL Parameter) RO register TODO FIXME: Same as
- * PLL_PARAM_REG 0x50 */
-//#define PLL_PARAM_REG (0x05 << MEM_MAP_SHIFT)
-
-/* FIFO Data RO register TODO */
-#define FIFO_DATA_REG (0x06 << MEM_MAP_SHIFT)
-
-#define FIFO_DATA_HRDWR_SRL_NMBR_OFST (0)
-#define FIFO_DATA_HRDWR_SRL_NMBR_MSK \
- (0x0000FFFF << FIFO_DATA_HRDWR_SRL_NMBR_OFST)
-//#define FIFO_DATA_WRD_OFST (16)
-//#define FIFO_DATA_WRD_MSK (0x0000FFFF << FIFO_DATA_WRD_OFST)
-
-/* FIFO Status RO register TODO */
-#define FIFO_STATUS_REG (0x07 << MEM_MAP_SHIFT)
-
-/* FIFO Empty RO register TODO */
-#define FIFO_EMPTY_REG (0x08 << MEM_MAP_SHIFT)
-#define FIFO_EMPTY_ALL_EMPTY_MSK (0xFFFFFFFF)
-
-/* FIFO Full RO register TODO */
-#define FIFO_FULL_REG (0x09 << MEM_MAP_SHIFT)
-
-/* MCB Serial Number RO register */
-#define MOD_SERIAL_NUMBER_REG (0x0A << MEM_MAP_SHIFT)
-
-#define MOD_SERIAL_NUMBER_OFST (0)
-#define MOD_SERIAL_NUMBER_MSK (0x000000FF << MOD_SERIAL_NUMBER_OFST)
-#define MOD_SERIAL_NUMBER_VRSN_OFST (16)
-#define MOD_SERIAL_NUMBER_VRSN_MSK (0x0000003F << MOD_SERIAL_NUMBER_VRSN_OFST)
-
-/* API Version RO register */
-#define API_VERSION_REG (0x0F << MEM_MAP_SHIFT)
-
-#define API_VERSION_OFST (0)
-#define API_VERSION_MSK (0x00FFFFFF << API_VERSION_OFST)
-#define API_VERSION_DTCTR_TYP_OFST (24)
-#define API_VERSION_DTCTR_TYP_MSK (0x000000FF << API_VERSION_DTCTR_TYP_OFST)
-
-/* Time from Start 64 bit RO register. t = GCLK x 50 ns. Reset using
- * CONTROL_CRST. TODO */
-#define TIME_FROM_START_LSB_REG (0x10 << MEM_MAP_SHIFT)
-#define TIME_FROM_START_MSB_REG (0x11 << MEM_MAP_SHIFT)
-
-/* Delay Left 64 bit RO register. t = DLY x 50 ns. TODO */
-#define DELAY_LEFT_LSB_REG (0x12 << MEM_MAP_SHIFT)
-#define DELAY_LEFT_MSB_REG (0x13 << MEM_MAP_SHIFT)
-
-/* Triggers Left 64 bit RO register TODO */
-#define CYCLES_LEFT_LSB_REG (0x14 << MEM_MAP_SHIFT)
-#define CYCLES_LEFT_MSB_REG (0x15 << MEM_MAP_SHIFT)
-
-/* Frames Left 64 bit RO register TODO */
-#define FRAMES_LEFT_LSB_REG (0x16 << MEM_MAP_SHIFT)
-#define FRAMES_LEFT_MSB_REG (0x17 << MEM_MAP_SHIFT)
-
-/* Period Left 64 bit RO register. t = T x 50 ns. TODO */
-#define PERIOD_LEFT_LSB_REG (0x18 << MEM_MAP_SHIFT)
-#define PERIOD_LEFT_MSB_REG (0x19 << MEM_MAP_SHIFT)
-
-/* Exposure Time Left 64 bit RO register */
-//#define EXPTIME_LEFT_LSB_REG (0x1A << MEM_MAP_SHIFT) // Not
-// used in FW #define EXPTIME_LEFT_MSB_REG (0x1B <<
-// MEM_MAP_SHIFT)
-//// Not used in FW
-
-/* Gates Left 64 bit RO register */
-//#define GATES_LEFT_LSB_REG (0x1C << MEM_MAP_SHIFT) // Not
-// used in FW #define GATES_LEFT_MSB_REG (0x1D <<
-// MEM_MAP_SHIFT)
-//// Not used in FW
-
-/* Data In 64 bit RO register TODO */
-#define DATA_IN_LSB_REG (0x1E << MEM_MAP_SHIFT)
-#define DATA_IN_MSB_REG (0x1F << MEM_MAP_SHIFT)
-
-/* Pattern Out 64 bit RO register */
-#define PATTERN_OUT_LSB_REG (0x20 << MEM_MAP_SHIFT)
-#define PATTERN_OUT_MSB_REG (0x21 << MEM_MAP_SHIFT)
-
-/* Frame number of next acquisition register (64 bit register) */
-#define NEXT_FRAME_NUMB_LOCAL_LSB_REG (0x22 << MEM_MAP_SHIFT)
-#define NEXT_FRAME_NUMB_LOCAL_MSB_REG (0x23 << MEM_MAP_SHIFT)
-
-/* Frames From Start PG 64 bit RO register. Reset using CONTROL_CRST. TODO */
-#define FRAMES_FROM_START_PG_LSB_REG (0x24 << MEM_MAP_SHIFT)
-#define FRAMES_FROM_START_PG_MSB_REG (0x25 << MEM_MAP_SHIFT)
-
-/* Start Frame Time (Measurement Time) 64 bit register (timestamp at a frame
- * start until reset) TODO */
-#define START_FRAME_TIME_LSB_REG (0x26 << MEM_MAP_SHIFT)
-#define START_FRAME_TIME_MSB_REG (0x27 << MEM_MAP_SHIFT)
-
-/* Power Status RO register */
-#define POWER_STATUS_REG (0x29 << MEM_MAP_SHIFT)
-
-#define POWER_STATUS_ALRT_OFST (27)
-#define POWER_STATUS_ALRT_MSK (0x0000001F << POWER_STATUS_ALRT_OFST)
-
-/* DAC Value Out RO register */
-//#define DAC_VAL_OUT_REG (0x2A << MEM_MAP_SHIFT)
-
-/* Slow ADC SPI Value RO register */
-#define ADC_SPI_SLOW_VAL_REG (0x2B << MEM_MAP_SHIFT)
-
-/* FIFO Digital In Status RO register */
-#define FIFO_DIN_STATUS_REG (0x3B << MEM_MAP_SHIFT)
-#define FIFO_DIN_STATUS_FIFO_FULL_OFST (30)
-#define FIFO_DIN_STATUS_FIFO_FULL_MSK \
- (0x00000001 << FIFO_DIN_STATUS_FIFO_FULL_OFST)
-#define FIFO_DIN_STATUS_FIFO_EMPTY_OFST (31)
-#define FIFO_DIN_STATUS_FIFO_EMPTY_MSK \
- (0x00000001 << FIFO_DIN_STATUS_FIFO_EMPTY_OFST)
-
-/* FIFO Digital In 64 bit RO register */
-#define FIFO_DIN_LSB_REG (0x3C << MEM_MAP_SHIFT)
-#define FIFO_DIN_MSB_REG (0x3D << MEM_MAP_SHIFT)
-
-/* SPI (Serial Peripheral Interface) DAC, HV RW register */
-#define SPI_REG (0x40 << MEM_MAP_SHIFT)
-
-#define SPI_DAC_SRL_DGTL_OTPT_OFST (0)
-#define SPI_DAC_SRL_DGTL_OTPT_MSK (0x00000001 << SPI_DAC_SRL_DGTL_OTPT_OFST)
-#define SPI_DAC_SRL_CLK_OTPT_OFST (1)
-#define SPI_DAC_SRL_CLK_OTPT_MSK (0x00000001 << SPI_DAC_SRL_CLK_OTPT_OFST)
-#define SPI_DAC_SRL_CS_OTPT_OFST (2)
-#define SPI_DAC_SRL_CS_OTPT_MSK (0x00000001 << SPI_DAC_SRL_CS_OTPT_OFST)
-#define SPI_HV_SRL_DGTL_OTPT_OFST (8)
-#define SPI_HV_SRL_DGTL_OTPT_MSK (0x00000001 << SPI_HV_SRL_DGTL_OTPT_OFST)
-#define SPI_HV_SRL_CLK_OTPT_OFST (9)
-#define SPI_HV_SRL_CLK_OTPT_MSK (0x00000001 << SPI_HV_SRL_CLK_OTPT_OFST)
-#define SPI_HV_SRL_CS_OTPT_OFST (10)
-#define SPI_HV_SRL_CS_OTPT_MSK (0x00000001 << SPI_HV_SRL_CS_OTPT_OFST)
-
-/* ADC SPI (Serial Peripheral Interface) RW register */
-#define ADC_SPI_REG (0x41 << MEM_MAP_SHIFT)
-
-#define ADC_SPI_SRL_CLK_OTPT_OFST (0)
-#define ADC_SPI_SRL_CLK_OTPT_MSK (0x00000001 << ADC_SPI_SRL_CLK_OTPT_OFST)
-#define ADC_SPI_SRL_DT_OTPT_OFST (1)
-#define ADC_SPI_SRL_DT_OTPT_MSK (0x00000001 << ADC_SPI_SRL_DT_OTPT_OFST)
-#define ADC_SPI_SRL_CS_OTPT_OFST (2)
-#define ADC_SPI_SRL_CS_OTPT_MSK (0x0000000F << ADC_SPI_SRL_CS_OTPT_OFST)
-#define ADC_SPI_SLOW_SRL_DT_OFST (8)
-#define ADC_SPI_SLOW_SRL_DT_MSK (0x00000001 << ADC_SPI_SLOW_SRL_DT_OFST)
-#define ADC_SPI_SLOW_SRL_CLK_OFST (9)
-#define ADC_SPI_SLOW_SRL_CLK_MSK (0x00000001 << ADC_SPI_SLOW_SRL_CLK_OFST)
-#define ADC_SPI_SLOW_SRL_CNV_OFST (10)
-#define ADC_SPI_SLOW_SRL_CNV_MSK (0x00000001 << ADC_SPI_SLOW_SRL_CNV_OFST)
-
-/* ADC Offset RW register */
-#define ADC_OFFSET_REG (0x42 << MEM_MAP_SHIFT)
-
-#define ADC_OFFSET_ADC_PPLN_OFST (0)
-#define ADC_OFFSET_ADC_PPLN_MSK (0x000000FF << ADC_OFFSET_ADC_PPLN_OFST)
-#define ADC_OFFSET_DBT_PPLN_OFST (16)
-#define ADC_OFFSET_DBT_PPLN_MSK (0x000000FF << ADC_OFFSET_DBT_PPLN_OFST)
-
-/* ADC Port Invert RW register */
-#define ADC_PORT_INVERT_REG (0x43 << MEM_MAP_SHIFT)
-
-#define ADC_PORT_INVERT_0_INPT_OFST (0)
-#define ADC_PORT_INVERT_0_INPT_MSK (0x000000FF << ADC_PORT_INVERT_0_INPT_OFST)
-#define ADC_PORT_INVERT_1_INPT_OFST (8)
-#define ADC_PORT_INVERT_1_INPT_MSK (0x000000FF << ADC_PORT_INVERT_1_INPT_OFST)
-#define ADC_PORT_INVERT_2_INPT_OFST (16)
-#define ADC_PORT_INVERT_2_INPT_MSK (0x000000FF << ADC_PORT_INVERT_2_INPT_OFST)
-#define ADC_PORT_INVERT_3_INPT_OFST (24)
-#define ADC_PORT_INVERT_3_INPT_MSK (0x000000FF << ADC_PORT_INVERT_3_INPT_OFST)
-
-/* Dummy RW register */
-#define DUMMY_REG (0x44 << MEM_MAP_SHIFT)
-
-#define DUMMY_FIFO_CHNNL_SLCT_OFST (0)
-#define DUMMY_FIFO_CHNNL_SLCT_MSK (0x0000003F << DUMMY_FIFO_CHNNL_SLCT_OFST)
-#define DUMMY_ANLG_FIFO_RD_STRBE_OFST (8)
-#define DUMMY_ANLG_FIFO_RD_STRBE_MSK \
- (0x00000001 << DUMMY_ANLG_FIFO_RD_STRBE_OFST)
-#define DUMMY_DGTL_FIFO_RD_STRBE_OFST (9)
-#define DUMMY_DGTL_FIFO_RD_STRBE_MSK \
- (0x00000001 << DUMMY_DGTL_FIFO_RD_STRBE_OFST)
-
-/* Receiver IP Address RW register */
-#define RX_IP_REG (0x45 << MEM_MAP_SHIFT)
-
-/* UDP Port RW register */
-#define UDP_PORT_REG (0x46 << MEM_MAP_SHIFT)
-
-#define UDP_PORT_RX_OFST (0)
-#define UDP_PORT_RX_MSK (0x0000FFFF << UDP_PORT_RX_OFST)
-#define UDP_PORT_TX_OFST (16)
-#define UDP_PORT_TX_MSK (0x0000FFFF << UDP_PORT_TX_OFST)
-
-/* Receiver Mac Address 64 bit RW register */
-#define RX_MAC_LSB_REG (0x47 << MEM_MAP_SHIFT)
-#define RX_MAC_MSB_REG (0x48 << MEM_MAP_SHIFT)
-
-#define RX_MAC_LSB_OFST (0)
-#define RX_MAC_LSB_MSK (0xFFFFFFFF << RX_MAC_LSB_OFST)
-#define RX_MAC_MSB_OFST (0)
-#define RX_MAC_MSB_MSK (0x0000FFFF << RX_MAC_MSB_OFST)
-
-/* Detector/ Transmitter Mac Address 64 bit RW register */
-#define TX_MAC_LSB_REG (0x49 << MEM_MAP_SHIFT)
-#define TX_MAC_MSB_REG (0x4A << MEM_MAP_SHIFT)
-
-#define TX_MAC_LSB_OFST (0)
-#define TX_MAC_LSB_MSK (0xFFFFFFFF << TX_MAC_LSB_OFST)
-#define TX_MAC_MSB_OFST (0)
-#define TX_MAC_MSB_MSK (0x0000FFFF << TX_MAC_MSB_OFST)
-
-/* Detector/ Transmitter IP Address RW register */
-#define TX_IP_REG (0x4B << MEM_MAP_SHIFT)
-
-/* Detector/ Transmitter IP Checksum RW register */
-#define TX_IP_CHECKSUM_REG (0x4C << MEM_MAP_SHIFT)
-
-#define TX_IP_CHECKSUM_OFST (0)
-#define TX_IP_CHECKSUM_MSK (0x0000FFFF << TX_IP_CHECKSUM_OFST)
-
-/* Configuration RW register */
-#define CONFIG_REG (0x4D << MEM_MAP_SHIFT)
-
-#define CONFIG_LED_DSBL_OFST (0) // Not used in firmware or software
-#define CONFIG_LED_DSBL_MSK (0x00000001 << CONFIG_LED_DSBL_OFST)
-#define CONFIG_DSBL_ANLG_OTPT_OFST (8)
-#define CONFIG_DSBL_ANLG_OTPT_MSK (0x00000001 << CONFIG_DSBL_ANLG_OTPT_OFST)
-#define CONFIG_ENBLE_DGTL_OTPT_OFST (9)
-#define CONFIG_ENBLE_DGTL_OTPT_MSK (0x00000001 << CONFIG_ENBLE_DGTL_OTPT_OFST)
-#define CONFIG_GB10_SND_UDP_OFST (12)
-#define CONFIG_GB10_SND_UDP_MSK (0x00000001 << CONFIG_GB10_SND_UDP_OFST)
-
-/* External Signal RW register */
-#define EXT_SIGNAL_REG (0x4E << MEM_MAP_SHIFT)
-
-#define EXT_SIGNAL_OFST (0)
-#define EXT_SIGNAL_MSK (0x00000001 << EXT_SIGNAL_OFST)
-#define EXT_SIGNAL_AUTO_VAL ((0x0 << EXT_SIGNAL_OFST) & EXT_SIGNAL_MSK)
-#define EXT_SIGNAL_TRGGR_VAL ((0x1 << EXT_SIGNAL_OFST) & EXT_SIGNAL_MSK)
-
-/* Control RW register */
-#define CONTROL_REG (0x4F << MEM_MAP_SHIFT)
-
-#define CONTROL_STRT_ACQSTN_OFST (0)
-#define CONTROL_STRT_ACQSTN_MSK (0x00000001 << CONTROL_STRT_ACQSTN_OFST)
-#define CONTROL_STP_ACQSTN_OFST (1)
-#define CONTROL_STP_ACQSTN_MSK (0x00000001 << CONTROL_STP_ACQSTN_OFST)
-//#define CONTROL_STRT_FF_TST_OFST (2)
-//#define CONTROL_STRT_FF_TST_MSK (0x00000001 <<
-// CONTROL_STRT_FF_TST_OFST) #define CONTROL_STP_FF_TST_OFST (3)
-//#define CONTROL_STP_FF_TST_MSK (0x00000001 <<
-// CONTROL_STP_FF_TST_OFST) #define CONTROL_STRT_RDT_OFST (4)
-//#define CONTROL_STRT_RDT_MSK (0x00000001 <<
-// CONTROL_STRT_RDT_OFST) #define CONTROL_STP_RDT_OFST (5)
-// #define CONTROL_STP_RDT_MSK (0x00000001 <<
-// CONTROL_STP_RDT_OFST)
-#define CONTROL_STRT_EXPSR_OFST (6)
-#define CONTROL_STRT_EXPSR_MSK (0x00000001 << CONTROL_STRT_EXPSR_OFST)
-//#define CONTROL_STP_EXPSR_OFST (7)
-//#define CONTROL_STP_EXPSR_MSK (0x00000001 <<
-// CONTROL_STP_RDT_OFST) #define CONTROL_STRT_TRN_OFST (8) #define
-// CONTROL_STRT_TRN_MSK (0x00000001 << CONTROL_STRT_RDT_OFST)
-//#define CONTROL_STP_TRN_OFST (9)
-//#define CONTROL_STP_TRN_MSK (0x00000001 <<
-// CONTROL_STP_RDT_OFST)
-#define CONTROL_CRE_RST_OFST (10)
-#define CONTROL_CRE_RST_MSK (0x00000001 << CONTROL_CRE_RST_OFST)
-#define CONTROL_PRPHRL_RST_OFST (11) // Only GBE10?
-#define CONTROL_PRPHRL_RST_MSK (0x00000001 << CONTROL_PRPHRL_RST_OFST)
-#define CONTROL_MMRY_RST_OFST (12)
-#define CONTROL_MMRY_RST_MSK (0x00000001 << CONTROL_MMRY_RST_OFST)
-//#define CONTROL_PLL_RCNFG_WR_OFST (13)
-//#define CONTROL_PLL_RCNFG_WR_MSK (0x00000001 <<
-// CONTROL_PLL_RCNFG_WR_OFST)
-#define CONTROL_SND_10GB_PCKT_OFST (14)
-#define CONTROL_SND_10GB_PCKT_MSK (0x00000001 << CONTROL_SND_10GB_PCKT_OFST)
-#define CONTROL_CLR_ACQSTN_FIFO_OFST (15)
-#define CONTROL_CLR_ACQSTN_FIFO_MSK (0x00000001 << CONTROL_CLR_ACQSTN_FIFO_OFST)
-
-/* Reconfiguratble PLL Paramater RW register */
-#define PLL_PARAM_REG (0x50 << MEM_MAP_SHIFT)
-
-/* Reconfiguratble PLL Control RW regiser */
-#define PLL_CNTRL_REG (0x51 << MEM_MAP_SHIFT)
-
-#define PLL_CNTRL_RCNFG_PRMTR_RST_OFST (0)
-#define PLL_CNTRL_RCNFG_PRMTR_RST_MSK \
- (0x00000001 << PLL_CNTRL_RCNFG_PRMTR_RST_OFST)
-#define PLL_CNTRL_WR_PRMTR_OFST (2)
-#define PLL_CNTRL_WR_PRMTR_MSK (0x00000001 << PLL_CNTRL_WR_PRMTR_OFST)
-#define PLL_CNTRL_PLL_RST_OFST (3)
-#define PLL_CNTRL_PLL_RST_MSK (0x00000001 << PLL_CNTRL_PLL_RST_OFST)
-#define PLL_CNTRL_ADDR_OFST (16)
-#define PLL_CNTRL_ADDR_MSK (0x0000003F << PLL_CNTRL_ADDR_OFST)
-
-/* Pattern Control RW register */
-#define PATTERN_CNTRL_REG (0x52 << MEM_MAP_SHIFT)
-
-#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)
-
-/* Pattern Limit RW regiser */
-#define PATTERN_LIMIT_REG (0x53 << MEM_MAP_SHIFT)
-
-#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)
-
-/* Pattern Loop 0 Address RW regiser */
-#define PATTERN_LOOP_0_ADDR_REG (0x54 << MEM_MAP_SHIFT)
-
-#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)
-
-/* Pattern Loop 0 Iteration RW regiser */
-#define PATTERN_LOOP_0_ITERATION_REG (0x55 << MEM_MAP_SHIFT)
-
-/* Pattern Loop 1 Address RW regiser */
-#define PATTERN_LOOP_1_ADDR_REG (0x56 << MEM_MAP_SHIFT)
-
-#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)
-
-/* Pattern Loop 1 Iteration RW regiser */
-#define PATTERN_LOOP_1_ITERATION_REG (0x57 << MEM_MAP_SHIFT)
-
-/* Pattern Loop 2 Address RW regiser */
-#define PATTERN_LOOP_2_ADDR_REG (0x58 << MEM_MAP_SHIFT)
-
-#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)
-
-/* Pattern Loop 2 Iteration RW regiser */
-#define PATTERN_LOOP_2_ITERATION_REG (0x59 << MEM_MAP_SHIFT)
-
-/* Pattern Wait 0 RW regiser */
-#define PATTERN_WAIT_0_ADDR_REG (0x5A << MEM_MAP_SHIFT)
-
-#define PATTERN_WAIT_0_ADDR_OFST (0)
-#define PATTERN_WAIT_0_ADDR_MSK (0x00001FFF << PATTERN_WAIT_0_ADDR_OFST)
-// FIXME: is mask 3FF
-
-/* Pattern Wait 1 RW regiser */
-#define PATTERN_WAIT_1_ADDR_REG (0x5B << MEM_MAP_SHIFT)
-
-#define PATTERN_WAIT_1_ADDR_OFST (0)
-#define PATTERN_WAIT_1_ADDR_MSK (0x00001FFF << PATTERN_WAIT_1_ADDR_OFST)
-
-/* Pattern Wait 2 RW regiser */
-#define PATTERN_WAIT_2_ADDR_REG (0x5C << MEM_MAP_SHIFT)
-
-#define PATTERN_WAIT_2_ADDR_OFST (0)
-#define PATTERN_WAIT_2_ADDR_MSK (0x00001FFF << PATTERN_WAIT_2_ADDR_OFST)
-
-/* Samples RW register */
-#define SAMPLES_REG (0x5D << MEM_MAP_SHIFT)
-
-#define SAMPLES_DIGITAL_OFST (0)
-#define SAMPLES_DIGITAL_MSK (0x0000FFFF << SAMPLES_DIGITAL_OFST)
-#define SAMPLES_ANALOG_OFST (16)
-#define SAMPLES_ANALOG_MSK (0x0000FFFF << SAMPLES_ANALOG_OFST)
-
-/** Power RW register */
-#define POWER_REG (0x5E << MEM_MAP_SHIFT)
-
-#define POWER_CHIP_OFST (16)
-#define POWER_CHIP_MSK (0x00000001 << POWER_CHIP_OFST)
-#define POWER_HV_INTERNAL_SLCT_OFST (31)
-#define POWER_HV_INTERNAL_SLCT_MSK (0x00000001 << POWER_HV_INTERNAL_SLCT_OFST)
-
-/* Number of Words RW register TODO */
-#define NUMBER_OF_WORDS_REG (0x5F << MEM_MAP_SHIFT)
-
-/* Delay 64 bit RW register. t = DLY x 50 ns. */
-#define DELAY_LSB_REG (0x60 << MEM_MAP_SHIFT)
-#define DELAY_MSB_REG (0x61 << MEM_MAP_SHIFT)
-
-/* Triggers 64 bit RW register */
-#define CYCLES_LSB_REG (0x62 << MEM_MAP_SHIFT)
-#define CYCLES_MSB_REG (0x63 << MEM_MAP_SHIFT)
-
-/* Frames 64 bit RW register */
-#define FRAMES_LSB_REG (0x64 << MEM_MAP_SHIFT)
-#define FRAMES_MSB_REG (0x65 << MEM_MAP_SHIFT)
-
-/* Period 64 bit RW register */
-#define PERIOD_LSB_REG (0x66 << MEM_MAP_SHIFT)
-#define PERIOD_MSB_REG (0x67 << MEM_MAP_SHIFT)
-
-/* Period 64 bit RW register */
-//#define EXPTIME_LSB_REG (0x68 << MEM_MAP_SHIFT) //
-// Not used in FW #define EXPTIME_MSB_REG (0x69 <<
-// MEM_MAP_SHIFT) // Not used in FW
-
-/* Gates 64 bit RW register */
-//#define GATES_LSB_REG (0x6A << MEM_MAP_SHIFT) // Not used
-// in FW #define GATES_MSB_REG (0x6B << MEM_MAP_SHIFT) //
-// Not used in FW
-
-/* Pattern IO Control 64 bit RW regiser
- * Each bit configured as output(1)/ input(0) */
-#define PATTERN_IO_CNTRL_LSB_REG (0x6C << MEM_MAP_SHIFT)
-#define PATTERN_IO_CNTRL_MSB_REG (0x6D << MEM_MAP_SHIFT)
-
-/* Pattern IO Clock Control 64 bit RW regiser
- * When bit n enabled (1), clocked output for DIO[n] (T run clock)
- * When bit n disabled (0), Dio[n] driven by its pattern output */
-#define PATTERN_IO_CLK_CNTRL_LSB_REG (0x6E << MEM_MAP_SHIFT)
-#define PATTERN_IO_CLK_CNTRL_MSB_REG (0x6F << MEM_MAP_SHIFT)
-
-/* Pattern In 64 bit RW register */
-#define PATTERN_IN_LSB_REG (0x70 << MEM_MAP_SHIFT)
-#define PATTERN_IN_MSB_REG (0x71 << MEM_MAP_SHIFT)
-
-/* Pattern Wait Timer 0 64 bit RW register. t = PWT1 x T run clock */
-#define PATTERN_WAIT_TIMER_0_LSB_REG (0x72 << MEM_MAP_SHIFT)
-#define PATTERN_WAIT_TIMER_0_MSB_REG (0x73 << MEM_MAP_SHIFT)
-
-/* Pattern Wait Timer 1 64 bit RW register. t = PWT2 x T run clock */
-#define PATTERN_WAIT_TIMER_1_LSB_REG (0x74 << MEM_MAP_SHIFT)
-#define PATTERN_WAIT_TIMER_1_MSB_REG (0x75 << MEM_MAP_SHIFT)
-
-/* Pattern Wait Timer 2 64 bit RW register. t = PWT3 x T run clock */
-#define PATTERN_WAIT_TIMER_2_LSB_REG (0x76 << MEM_MAP_SHIFT)
-#define PATTERN_WAIT_TIMER_2_MSB_REG (0x77 << MEM_MAP_SHIFT)
-
-/* Readout enable RW register */
-#define READOUT_10G_ENABLE_REG (0x79 << MEM_MAP_SHIFT)
-
-#define READOUT_10G_ENABLE_ANLG_OFST (0)
-#define READOUT_10G_ENABLE_ANLG_MSK (0x000000FF << READOUT_10G_ENABLE_ANLG_OFST)
-#define READOUT_10G_ENABLE_DGTL_OFST (8)
-#define READOUT_10G_ENABLE_DGTL_MSK (0x00000001 << READOUT_10G_ENABLE_DGTL_OFST)
-
-/* Digital Bit External Trigger RW register */
-#define DBIT_EXT_TRG_REG \
- (0x7B << MEM_MAP_SHIFT) // Not used in firmware or software
-
-#define DBIT_EXT_TRG_SRC_OFST (0)
-#define DBIT_EXT_TRG_SRC_MSK (0x0000003F << DBIT_EXT_TRG_SRC_OFST)
-#define DBIT_EXT_TRG_OPRTN_MD_OFST (16)
-#define DBIT_EXT_TRG_OPRTN_MD_MSK (0x00000001 << DBIT_EXT_TRG_OPRTN_MD_OFST)
-
-/* Pin Delay 0 RW register */
-#define OUTPUT_DELAY_0_REG \
- (0x7C << MEM_MAP_SHIFT) // Not used in firmware or software
-
-#define OUTPUT_DELAY_0_OTPT_STTNG_STEPS (25)
-#define OUTPUT_DELAY_0_OTPT_STTNG_OFST \
- (0) // t = OTPT_STTNG * 25 ps, max for Cyclone V = 775 ps
-#define OUTPUT_DELAY_0_OTPT_STTNG_MSK \
- (0x0000001F << OUTPUT_DELAY_0_OTPT_STTNG_OFST)
-// 1: load dynamic output settings, 0: trigger start of dynamic output delay
-// configuration pn falling edge of ODT (output delay trigger) bit
-#define OUTPUT_DELAY_0_OTPT_TRGGR_OFST (31)
-#define OUTPUT_DELAY_0_OTPT_TRGGR_MSK \
- (0x00000001 << OUTPUT_DELAY_0_OTPT_TRGGR_OFST)
-#define OUTPUT_DELAY_0_OTPT_TRGGR_LD_VAL (1)
-#define OUTPUT_DELAY_0_OTPT_TRGGR_STRT_VAL (0)
-
-/* Pin Delay 1 RW register
- * Each bit configured as enable for dynamic output delay configuration */
-#define PIN_DELAY_1_REG \
- (0x7D << MEM_MAP_SHIFT) // Not used in firmware or software
-
-/** Pattern Mask 64 bit RW regiser */
-#define PATTERN_MASK_LSB_REG (0x80 << MEM_MAP_SHIFT)
-#define PATTERN_MASK_MSB_REG (0x81 << MEM_MAP_SHIFT)
-
-/** Pattern Set 64 bit RW regiser */
-#define PATTERN_SET_LSB_REG (0x82 << MEM_MAP_SHIFT)
-#define PATTERN_SET_MSB_REG (0x83 << MEM_MAP_SHIFT)
-
-/* Pattern Loop 3 Address RW regiser */
-#define PATTERN_LOOP_3_ADDR_REG (0x84 << MEM_MAP_SHIFT)
-
-#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)
-
-/* Pattern Loop 3 Iteration RW regiser */
-#define PATTERN_LOOP_3_ITERATION_REG (0x85 << MEM_MAP_SHIFT)
-
-/* Pattern Loop 4 Address RW regiser */
-#define PATTERN_LOOP_4_ADDR_REG (0x86 << MEM_MAP_SHIFT)
-
-#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)
-
-/* Pattern Loop 4 Iteration RW regiser */
-#define PATTERN_LOOP_4_ITERATION_REG (0x87 << MEM_MAP_SHIFT)
-
-/* Pattern Loop 5 Address RW regiser */
-#define PATTERN_LOOP_5_ADDR_REG (0x88 << MEM_MAP_SHIFT)
-
-#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)
-
-/* Pattern Loop 5 Iteration RW regiser */
-#define PATTERN_LOOP_5_ITERATION_REG (0x89 << MEM_MAP_SHIFT)
-
-/* Pattern Wait 3 RW regiser */
-#define PATTERN_WAIT_3_ADDR_REG (0x8A << MEM_MAP_SHIFT)
-
-#define PATTERN_WAIT_3_ADDR_OFST (0)
-#define PATTERN_WAIT_3_ADDR_MSK (0x00001FFF << PATTERN_WAIT_3_ADDR_OFST)
-
-/* Pattern Wait 4 RW regiser */
-#define PATTERN_WAIT_4_ADDR_REG (0x8B << MEM_MAP_SHIFT)
-
-#define PATTERN_WAIT_4_ADDR_OFST (0)
-#define PATTERN_WAIT_4_ADDR_MSK (0x00001FFF << PATTERN_WAIT_4_ADDR_OFST)
-
-/* Pattern Wait 5 RW regiser */
-#define PATTERN_WAIT_5_ADDR_REG (0x8C << MEM_MAP_SHIFT)
-
-#define PATTERN_WAIT_5_ADDR_OFST (0)
-#define PATTERN_WAIT_5_ADDR_MSK (0x00001FFF << PATTERN_WAIT_5_ADDR_OFST)
-
-/* Pattern Wait Timer 3 64 bit RW register. t = PWT1 x T run clock */
-#define PATTERN_WAIT_TIMER_3_LSB_REG (0x8D << MEM_MAP_SHIFT)
-#define PATTERN_WAIT_TIMER_3_MSB_REG (0x8E << MEM_MAP_SHIFT)
-
-/* Pattern Wait Timer 4 64 bit RW register. t = PWT1 x T run clock */
-#define PATTERN_WAIT_TIMER_4_LSB_REG (0x8F << MEM_MAP_SHIFT)
-#define PATTERN_WAIT_TIMER_4_MSB_REG (0x90 << MEM_MAP_SHIFT)
-
-/* Pattern Wait Timer 5 64 bit RW register. t = PWT1 x T run clock */
-#define PATTERN_WAIT_TIMER_5_LSB_REG (0x91 << MEM_MAP_SHIFT)
-#define PATTERN_WAIT_TIMER_5_MSB_REG (0x92 << MEM_MAP_SHIFT)
+/* FPGA Version register */
+#define FPGA_VERSION_REG (0x00 << MEM_MAP_SHIFT)
+
+#define FPGA_COMPILATION_DATE_OFST (0)
+#define FPGA_COMPILATION_DATE_MSK (0x00FFFFFF << FPGA_COMPILATION_DATE_OFST)
+#define DETECTOR_TYPE_OFST (24)
+#define DETECTOR_TYPE_MSK (0x000000FF << DETECTOR_TYPE_OFST)
+
+/* Fix pattern register */
+#define FIX_PATT_REG (0x01 << MEM_MAP_SHIFT)
+
+#define FIX_PATT_VAL (0xACDC2014)
+
+/* Status register */
+#define STATUS_REG (0x02 << MEM_MAP_SHIFT)
+
+#define RUN_BUSY_OFST (0)
+#define RUN_BUSY_MSK (0x00000001 << RUN_BUSY_OFST)
+#define WAITING_FOR_TRIGGER_OFST (3)
+#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 STOPPED_MSK (0x00000001 << STOPPED_OFST)
+#define RUNMACHINE_BUSY_OFST (17)
+#define RUNMACHINE_BUSY_MSK (0x00000001 << RUNMACHINE_BUSY_OFST)
+
+/* Look at me register */
+#define LOOK_AT_ME_REG (0x03 << MEM_MAP_SHIFT) // Not used in firmware or software
+
+/* System Status register */
+#define SYSTEM_STATUS_REG (0x04 << MEM_MAP_SHIFT) // Not used in software
+
+#define DDR3_CAL_DONE_OFST (0) // Not used in software
+#define DDR3_CAL_DONE_MSK (0x00000001 << DDR3_CAL_DONE_OFST) // Not used in software
+#define DDR3_CAL_FAIL_OFST (1) // Not used in software
+#define DDR3_CAL_FAIL_MSK (0x00000001 << DDR3_CAL_FAIL_OFST) // Not used in software
+#define DDR3_INIT_DONE_OFST (2) // Not used in software
+#define DDR3_INIT_DONE_MSK (0x00000001 << DDR3_INIT_DONE_OFST) // Not used in software
+#define RECONFIG_PLL_LCK_OFST (3) // Not used in software
+#define RECONFIG_PLL_LCK_MSK (0x00000001 << RECONFIG_PLL_LCK_OFST) // Not used in software
+#define PLL_A_LCK_OFST (4) // Not used in software
+#define PLL_A_LCK_MSK (0x00000001 << PLL_A_LCK_OFST) // Not used in software
+#define DD3_PLL_LCK_OFST (5) // Not used in software
+#define DD3_PLL_LCK_MSK (0x00000001 << DD3_PLL_LCK_OFST) // Not used in software
+
+/* Module Control Board Serial Number Register */
+#define MOD_SERIAL_NUM_REG (0x0A << MEM_MAP_SHIFT)
+
+#define HARDWARE_SERIAL_NUM_OFST (0)
+#define HARDWARE_SERIAL_NUM_MSK (0x000000FF << HARDWARE_SERIAL_NUM_OFST)
+#define HARDWARE_VERSION_NUM_OFST (16)
+#define HARDWARE_VERSION_NUM_MSK (0x0000003F << HARDWARE_VERSION_NUM_OFST)
+
+/* API Version Register */
+#define API_VERSION_REG (0x0F << MEM_MAP_SHIFT)
+
+#define API_VERSION_OFST (0)
+#define API_VERSION_MSK (0x00FFFFFF << API_VERSION_OFST)
+#define API_VERSION_DETECTOR_TYPE_OFST (24) // Not used in software
+#define API_VERSION_DETECTOR_TYPE_MSK (0x000000FF << API_VERSION_DETECTOR_TYPE_OFST) // Not used in software
+
+/* Time from Start 64 bit register */
+#define TIME_FROM_START_LSB_REG (0x10 << MEM_MAP_SHIFT)
+#define TIME_FROM_START_MSB_REG (0x11 << MEM_MAP_SHIFT)
+
+/* Get Delay 64 bit register */
+#define GET_DELAY_LSB_REG (0x12 << MEM_MAP_SHIFT) // different kind of delay
+#define GET_DELAY_MSB_REG (0x13 << MEM_MAP_SHIFT) // different kind of delay
+
+/* Get Triggers 64 bit register */
+#define GET_CYCLES_LSB_REG (0x14 << MEM_MAP_SHIFT)
+#define GET_CYCLES_MSB_REG (0x15 << MEM_MAP_SHIFT)
+
+/* Get Frames 64 bit register */
+#define GET_FRAMES_LSB_REG (0x16 << MEM_MAP_SHIFT)
+#define GET_FRAMES_MSB_REG (0x17 << MEM_MAP_SHIFT)
+
+/* Get Period 64 bit register tT = T x 50 ns */
+#define GET_PERIOD_LSB_REG (0x18 << MEM_MAP_SHIFT)
+#define GET_PERIOD_MSB_REG (0x19 << MEM_MAP_SHIFT)
+
+/** Get Temperature Carlos, incorrectl as get gates */
+#define GET_TEMPERATURE_TMP112_REG (0x1c << MEM_MAP_SHIFT) // (after multiplying by 625) in 10ths of
+ // millidegrees of TMP112
+
+#define TEMPERATURE_VALUE_BIT (0)
+#define TEMPERATURE_VALUE_MSK (0x000007FF << TEMPERATURE_VALUE_BIT)
+#define TEMPERATURE_POLARITY_BIT (11)
+#define TEMPERATURE_POLARITY_MSK (0x00000001 << TEMPERATURE_POLARITY_BIT)
+
+/* Config Status Register for chip 1.1 */
+#define CONFIG_V11_STATUS_REG (0x1D << MEM_MAP_SHIFT)
+
+#define CONFIG_V11_STATUS_FLTR_CLL_OFST (0)
+#define CONFIG_V11_STATUS_FLTR_CLL_MSK (0x00000FFF << CONFIG_V11_STATUS_FLTR_CLL_OFST)
+// CSM mode = high current (100%), low current (16%)
+#define CONFIG_V11_STATUS_CRRNT_SRC_LOW_OFST (19)
+#define CONFIG_V11_STATUS_CRRNT_SRC_LOW_MSK (0x00000001 << CONFIG_V11_STATUS_CRRNT_SRC_LOW_OFST)
+#define CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_OFST (21)
+#define CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_MSK (0x00000001 << CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_OFST)
+#define CONFIG_V11_STATUS_AUTO_MODE_OVRRD_OFST (23)
+#define CONFIG_V11_STATUS_AUTO_MODE_OVRRD_MSK (0x00000001 << CONFIG_V11_STATUS_AUTO_MODE_OVRRD_OFST)
+
+/* Get Frames from Start 64 bit register (frames from last reset using
+ * CONTROL_CRST) */
+#define FRAMES_FROM_START_LSB_REG (0x22 << MEM_MAP_SHIFT)
+#define FRAMES_FROM_START_MSB_REG (0x23 << MEM_MAP_SHIFT)
+
+/* Get Starting Frame Number */
+#define GET_FRAME_NUMBER_LSB_REG (0x24 << MEM_MAP_SHIFT)
+#define GET_FRAME_NUMBER_MSB_REG (0x25 << MEM_MAP_SHIFT)
+
+/* Measurement Time 64 bit register (timestamp at a frame start until reset)*/
+#define START_FRAME_TIME_LSB_REG (0x26 << MEM_MAP_SHIFT)
+#define START_FRAME_TIME_MSB_REG (0x27 << MEM_MAP_SHIFT)
+
+/* SPI (Serial Peripheral Interface) Register */
+#define SPI_REG (0x40 << MEM_MAP_SHIFT)
+
+#define SPI_DAC_SRL_DGTL_OTPT_OFST (0)
+#define SPI_DAC_SRL_DGTL_OTPT_MSK (0x00000001 << SPI_DAC_SRL_DGTL_OTPT_OFST)
+#define SPI_DAC_SRL_CLK_OTPT_OFST (1)
+#define SPI_DAC_SRL_CLK_OTPT_MSK (0x00000001 << SPI_DAC_SRL_CLK_OTPT_OFST)
+#define SPI_DAC_SRL_CS_OTPT_OFST (2)
+#define SPI_DAC_SRL_CS_OTPT_MSK (0x00000001 << SPI_DAC_SRL_CS_OTPT_OFST)
+#define SPI_HV_SRL_DGTL_OTPT_OFST (8)
+#define SPI_HV_SRL_DGTL_OTPT_MSK (0x00000001 << SPI_HV_SRL_DGTL_OTPT_OFST)
+#define SPI_HV_SRL_CLK_OTPT_OFST (9)
+#define SPI_HV_SRL_CLK_OTPT_MSK (0x00000001 << SPI_HV_SRL_CLK_OTPT_OFST)
+#define SPI_HV_SRL_CS_OTPT_OFST (10)
+#define SPI_HV_SRL_CS_OTPT_MSK (0x00000001 << SPI_HV_SRL_CS_OTPT_OFST)
+
+/* ADC SPI (Serial Peripheral Interface) Register */
+#define ADC_SPI_REG (0x41 << MEM_MAP_SHIFT)
+
+#define ADC_SPI_SRL_CLK_OTPT_OFST (0)
+#define ADC_SPI_SRL_CLK_OTPT_MSK (0x00000001 << ADC_SPI_SRL_CLK_OTPT_OFST)
+#define ADC_SPI_SRL_DT_OTPT_OFST (1)
+#define ADC_SPI_SRL_DT_OTPT_MSK (0x00000001 << ADC_SPI_SRL_DT_OTPT_OFST)
+#define ADC_SPI_SRL_CS_OTPT_OFST (2)
+#define ADC_SPI_SRL_CS_OTPT_MSK (0x0000000F << ADC_SPI_SRL_CS_OTPT_OFST)
+
+/* ADC offset Register */
+#define ADC_OFST_REG (0x42 << MEM_MAP_SHIFT)
+
+/* ADC Port Invert Register */
+#define ADC_PORT_INVERT_REG (0x43 << MEM_MAP_SHIFT)
+
+#define ADC_PORT_INVERT_ADC_0_OFST (0)
+#define ADC_PORT_INVERT_ADC_0_MSK (0x000000FF << ADC_PORT_INVERT_ADC_0_OFST)
+#define ADC_PORT_INVERT_ADC_1_OFST (8)
+#define ADC_PORT_INVERT_ADC_1_MSK (0x000000FF << ADC_PORT_INVERT_ADC_1_OFST)
+#define ADC_PORT_INVERT_ADC_2_OFST (16)
+#define ADC_PORT_INVERT_ADC_2_MSK (0x000000FF << ADC_PORT_INVERT_ADC_2_OFST)
+#define ADC_PORT_INVERT_ADC_3_OFST (24)
+#define ADC_PORT_INVERT_ADC_3_MSK (0x000000FF << ADC_PORT_INVERT_ADC_3_OFST)
+
+/** Read N Rows Register */
+#define READ_N_ROWS_REG (0x44 << MEM_MAP_SHIFT)
+
+#define READ_N_ROWS_NUM_ROWS_OFST (0)
+#define READ_N_ROWS_NUM_ROWS_MSK (0x0000003F << READ_N_ROWS_NUM_ROWS_OFST)
+#define READ_N_ROWS_ENBL_OFST (7)
+#define READ_N_ROWS_ENBL_MSK (0x00000001 << READ_N_ROWS_ENBL_OFST)
+
+
+/* Configuration Register */
+#define CONFIG_REG (0x4D << MEM_MAP_SHIFT)
+
+// readout timer (from chip) to stabilize (esp in burst acquisition mode) tRDT =
+// (RDT + 1) * 25ns
+#define CONFIG_RDT_TMR_OFST (0)
+#define CONFIG_RDT_TMR_MSK (0x0000FFFF << CONFIG_RDT_TMR_OFST)
+// if 0, outer is the primary interface
+// bottom via port 0 (outer)
+#define CONFIG_OPRTN_MDE_2_X_10GbE_OFST (16)
+#define CONFIG_OPRTN_MDE_2_X_10GbE_MSK (0x00000001 << CONFIG_OPRTN_MDE_2_X_10GbE_OFST)
+#define CONFIG_INNR_PRIMRY_INTRFCE_OFST (17)
+#define CONFIG_INNR_PRIMRY_INTRFCE_MSK (0x00000001 << CONFIG_INNR_PRIMRY_INTRFCE_OFST)
+#define CONFIG_READOUT_SPEED_OFST (20)
+#define CONFIG_READOUT_SPEED_MSK (0x00000003 << CONFIG_READOUT_SPEED_OFST)
+#define CONFIG_QUARTER_SPEED_10MHZ_VAL ((0x0 << CONFIG_READOUT_SPEED_OFST) & CONFIG_READOUT_SPEED_MSK)
+#define CONFIG_HALF_SPEED_20MHZ_VAL ((0x1 << CONFIG_READOUT_SPEED_OFST) & CONFIG_READOUT_SPEED_MSK)
+#define CONFIG_FULL_SPEED_40MHZ_VAL ((0x2 << CONFIG_READOUT_SPEED_OFST) & CONFIG_READOUT_SPEED_MSK)
+#define CONFIG_TDMA_ENABLE_OFST (24)
+#define CONFIG_TDMA_ENABLE_MSK (0x00000001 << CONFIG_TDMA_ENABLE_OFST)
+#define CONFIG_TDMA_TIMESLOT_OFST (25) // 1ms
+#define CONFIG_TDMA_TIMESLOT_MSK (0x0000001F << CONFIG_TDMA_TIMESLOT_OFST)
+#define CONFIG_BOTTOM_INVERT_STREAM_OFST (30)
+#define CONFIG_BOTTOM_INVERT_STREAM_MSK (0x00000001 << CONFIG_BOTTOM_INVERT_STREAM_OFST)
+#define CONFIG_ETHRNT_FLW_CNTRL_OFST (31)
+#define CONFIG_ETHRNT_FLW_CNTRL_MSK (0x00000001 << CONFIG_ETHRNT_FLW_CNTRL_OFST)
+
+/* External Signal Register */
+#define EXT_SIGNAL_REG (0x4E << MEM_MAP_SHIFT)
+
+#define EXT_SIGNAL_OFST (0)
+#define EXT_SIGNAL_MSK (0x00000001 << EXT_SIGNAL_OFST)
+#define EXT_SYNC_OFST (4)
+#define EXT_SYNC_MSK (0x00000001 << EXT_SYNC_OFST)
+
+/* Control Register */
+#define CONTROL_REG (0x4F << MEM_MAP_SHIFT)
+
+#define CONTROL_START_ACQ_OFST (0)
+#define CONTROL_START_ACQ_MSK (0x00000001 << CONTROL_START_ACQ_OFST)
+#define CONTROL_STOP_ACQ_OFST (1)
+#define CONTROL_STOP_ACQ_MSK (0x00000001 << CONTROL_STOP_ACQ_OFST)
+#define CONTROL_SOFTWARE_TRIGGER_OFST (2)
+#define CONTROL_SOFTWARE_TRIGGER_MSK (0x00000001 << CONTROL_SOFTWARE_TRIGGER_OFST)
+#define CONTROL_CORE_RST_OFST (10)
+#define CONTROL_CORE_RST_MSK (0x00000001 << CONTROL_CORE_RST_OFST)
+#define CONTROL_PERIPHERAL_RST_OFST (11) // DDR3 HMem Ctrlr, GBE, Temp
+#define CONTROL_PERIPHERAL_RST_MSK (0x00000001 << CONTROL_PERIPHERAL_RST_OFST) // DDR3 HMem Ctrlr, GBE, Temp
+#define CONTROL_DDR3_MEM_RST_OFST (12) // only PHY, not DDR3 PLL ,Not used in software
+#define CONTROL_DDR3_MEM_RST_MSK (0x00000001 << CONTROL_DDR3_MEM_RST_OFST) // only PHY, not DDR3 PLL ,Not used in software
+#define CONTROL_ACQ_FIFO_CLR_OFST (14)
+#define CONTROL_ACQ_FIFO_CLR_MSK (0x00000001 << CONTROL_ACQ_FIFO_CLR_OFST)
+#define CONTROL_MASTER_OFST (15)
+#define CONTROL_MASTER_MSK (0x00000001 << CONTROL_MASTER_OFST)
+#define CONTROL_RX_ADDTNL_ENDPTS_NUM_OFST (20)
+#define CONTROL_RX_ADDTNL_ENDPTS_NUM_MSK (0x0000003F << CONTROL_RX_ADDTNL_ENDPTS_NUM_OFST)
+#define CONTROL_RX_ENDPTS_START_OFST (26)
+#define CONTROL_RX_ENDPTS_START_MSK (0x0000003F << CONTROL_RX_ENDPTS_START_OFST)
+
+/* Reconfiguratble PLL Paramater Register */
+#define PLL_PARAM_REG (0x50 << MEM_MAP_SHIFT)
+
+/* Reconfiguratble PLL Control Regiser */
+#define PLL_CNTRL_REG (0x51 << MEM_MAP_SHIFT)
+
+#define PLL_CNTRL_RCNFG_PRMTR_RST_OFST (0) // parameter reset
+#define PLL_CNTRL_RCNFG_PRMTR_RST_MSK (0x00000001 << PLL_CNTRL_RCNFG_PRMTR_RST_OFST) // parameter reset
+#define PLL_CNTRL_WR_PRMTR_OFST (2)
+#define PLL_CNTRL_WR_PRMTR_MSK (0x00000001 << PLL_CNTRL_WR_PRMTR_OFST)
+#define PLL_CNTRL_PLL_RST_OFST (3)
+#define PLL_CNTRL_PLL_RST_MSK (0x00000001 << PLL_CNTRL_PLL_RST_OFST)
+#define PLL_CNTRL_DBIT_WR_PRMTR_OFST (5)
+#define PLL_CNTRL_DBIT_WR_PRMTR_MSK (0x00000001 << PLL_CNTRL_DBIT_WR_PRMTR_OFST)
+#define PLL_CNTRL_ADDR_OFST (16)
+#define PLL_CNTRL_ADDR_MSK (0x0000003F << PLL_CNTRL_ADDR_OFST)
+
+/* Config Register for chip 1.1 */
+#define CONFIG_V11_REG (0x58 << MEM_MAP_SHIFT)
+
+#define CONFIG_V11_FLTR_CLL_OFST (0)
+#define CONFIG_V11_FLTR_CLL_MSK (0x00000FFF << CONFIG_V11_FLTR_CLL_OFST)
+// CSM mode = high current (100%), low current (16%)
+#define CONFIG_V11_CRRNT_SRC_LOW_OFST (19)
+#define CONFIG_V11_CRRNT_SRC_LOW_MSK (0x00000001 << CONFIG_V11_CRRNT_SRC_LOW_OFST)
+#define CONFIG_V11_FLTR_RSSTR_SMLR_OFST (21)
+#define CONFIG_V11_FLTR_RSSTR_SMLR_MSK (0x00000001 << CONFIG_V11_FLTR_RSSTR_SMLR_OFST)
+#define CONFIG_V11_AUTO_MODE_OVRRD_OFST (23)
+#define CONFIG_V11_AUTO_MODE_OVRRD_MSK (0x00000001 << CONFIG_V11_AUTO_MODE_OVRRD_OFST)
+
+/* Sample Register */
+#define SAMPLE_REG (0x59 << MEM_MAP_SHIFT)
+
+#define SAMPLE_ADC_SAMPLE_SEL_OFST (0)
+#define SAMPLE_ADC_SAMPLE_SEL_MSK (0x00000007 << SAMPLE_ADC_SAMPLE_SEL_OFST)
+#define SAMPLE_ADC_SAMPLE_0_VAL ((0x0 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
+#define SAMPLE_ADC_SAMPLE_1_VAL ((0x1 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
+#define SAMPLE_ADC_SAMPLE_2_VAL ((0x2 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
+#define SAMPLE_ADC_SAMPLE_3_VAL ((0x3 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
+#define SAMPLE_ADC_SAMPLE_4_VAL ((0x4 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
+#define SAMPLE_ADC_SAMPLE_5_VAL ((0x5 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
+#define SAMPLE_ADC_SAMPLE_6_VAL ((0x6 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
+#define SAMPLE_ADC_SAMPLE_7_VAL ((0x7 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK)
+// Decimation = ADF + 1
+#define SAMPLE_ADC_DECMT_FACTOR_OFST (4)
+#define SAMPLE_ADC_DECMT_FACTOR_MSK (0x00000007 << SAMPLE_ADC_DECMT_FACTOR_OFST)
+#define SAMPLE_ADC_DECMT_FACTOR_0_VAL ((0x0 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
+#define SAMPLE_ADC_DECMT_FACTOR_1_VAL ((0x1 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
+#define SAMPLE_ADC_DECMT_FACTOR_2_VAL ((0x2 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
+#define SAMPLE_ADC_DECMT_FACTOR_3_VAL ((0x3 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
+#define SAMPLE_ADC_DECMT_FACTOR_4_VAL ((0x4 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
+#define SAMPLE_ADC_DECMT_FACTOR_5_VAL ((0x5 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
+#define SAMPLE_ADC_DECMT_FACTOR_6_VAL ((0x6 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
+#define SAMPLE_ADC_DECMT_FACTOR_7_VAL ((0x7 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK)
+
+#define SAMPLE_DGTL_SAMPLE_SEL_OFST (8)
+#define SAMPLE_DGTL_SAMPLE_SEL_MSK (0x0000000F << SAMPLE_DGTL_SAMPLE_SEL_OFST)
+#define SAMPLE_DGTL_SAMPLE_0_VAL ((0x0 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
+#define SAMPLE_DGTL_SAMPLE_1_VAL ((0x1 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
+#define SAMPLE_DGTL_SAMPLE_2_VAL ((0x2 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
+#define SAMPLE_DGTL_SAMPLE_3_VAL ((0x3 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
+#define SAMPLE_DGTL_SAMPLE_4_VAL ((0x4 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
+#define SAMPLE_DGTL_SAMPLE_5_VAL ((0x5 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
+#define SAMPLE_DGTL_SAMPLE_6_VAL ((0x6 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
+#define SAMPLE_DGTL_SAMPLE_7_VAL ((0x7 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
+#define SAMPLE_DGTL_SAMPLE_8_VAL ((0x8 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
+#define SAMPLE_DGTL_SAMPLE_9_VAL ((0x9 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
+#define SAMPLE_DGTL_SAMPLE_10_VAL ((0xa << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
+#define SAMPLE_DGTL_SAMPLE_11_VAL ((0xb << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
+#define SAMPLE_DGTL_SAMPLE_12_VAL ((0xc << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
+#define SAMPLE_DGTL_SAMPLE_13_VAL ((0xd << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
+#define SAMPLE_DGTL_SAMPLE_14_VAL ((0xe << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
+#define SAMPLE_DGTL_SAMPLE_15_VAL ((0xf << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK)
+
+#define SAMPLE_DGTL_DECMT_FACTOR_OFST (12)
+#define SAMPLE_DGTL_DECMT_FACTOR_MSK (0x00000003 << SAMPLE_DGTL_DECMT_FACTOR_OFST)
+#define SAMPLE_DECMT_FACTOR_FULL_VAL ((0x0 << SAMPLE_DGTL_DECMT_FACTOR_OFST) & SAMPLE_DGTL_DECMT_FACTOR_MSK)
+#define SAMPLE_DECMT_FACTOR_HALF_VAL ((0x1 << SAMPLE_DGTL_DECMT_FACTOR_OFST) & SAMPLE_DGTL_DECMT_FACTOR_MSK)
+#define SAMPLE_DECMT_FACTOR_QUARTER_VAL ((0x2 << SAMPLE_DGTL_DECMT_FACTOR_OFST) & SAMPLE_DGTL_DECMT_FACTOR_MSK)
+
+/** Current Source Column 0 (0 - 31)) */
+#define CRRNT_SRC_COL_LSB_REG (0x5A << MEM_MAP_SHIFT)
+
+/** Current Source Column 1 (32 - 63) */
+#define CRRNT_SRC_COL_MSB_REG (0x5B << MEM_MAP_SHIFT)
+
+/** Vref Comp Mod Register */
+#define EXT_DAQ_CTRL_REG (0x5C << MEM_MAP_SHIFT)
+
+#define EXT_DAQ_CTRL_VREF_COMP_OFST (0)
+#define EXT_DAQ_CTRL_VREF_COMP_MSK (0x00000FFF << EXT_DAQ_CTRL_VREF_COMP_OFST)
+#define EXT_DAQ_CTRL_CMP_LGC_ENBL_OFST (15)
+#define EXT_DAQ_CTRL_CMP_LGC_ENBL_MSK (0x00000001 << EXT_DAQ_CTRL_CMP_LGC_ENBL_OFST)
+#define EXT_DAQ_CTRL_INPT_DETECT_OFST (16)
+#define EXT_DAQ_CTRL_INPT_DETECT_MSK (0x00000007 << EXT_DAQ_CTRL_INPT_DETECT_OFST)
+#define EXT_DAQ_CTRL_INPT_DETECT_ENBL_OFST (19)
+#define EXT_DAQ_CTRL_INPT_DETECT_ENBL_MSK (0x00000001 << EXT_DAQ_CTRL_INPT_DETECT_ENBL_OFST)
+
+/** DAQ Register */
+#define DAQ_REG (0x5D << MEM_MAP_SHIFT)
+
+// dynamic gain (default)
+#define DAQ_HIGH_GAIN_OFST (0)
+#define DAQ_HIGH_GAIN_MSK (0x00000001 << DAQ_HIGH_GAIN_OFST)
+#define DAQ_FIX_GAIN_OFST (1)
+#define DAQ_FIX_GAIN_MSK (0x00000003 << DAQ_FIX_GAIN_OFST)
+#define DAQ_FIX_GAIN_STG_1_VAL ((0x1 << DAQ_FIX_GAIN_OFST) & DAQ_FIX_GAIN_MSK)
+#define DAQ_FIX_GAIN_STG_2_VAL ((0x3 << DAQ_FIX_GAIN_OFST) & DAQ_FIX_GAIN_MSK)
+#define DAQ_CMP_RST_OFST (4)
+#define DAQ_CMP_RST_MSK (0x00000001 << DAQ_CMP_RST_OFST)
+#define DAQ_CHIP11_VRSN_OFST (7)
+#define DAQ_CHIP11_VRSN_MSK (0x00000001 << DAQ_CHIP11_VRSN_OFST)
+#define DAQ_FRCE_SWTCH_GAIN_OFST (12)
+#define DAQ_FRCE_SWTCH_GAIN_MSK (0x00000003 << DAQ_FRCE_SWTCH_GAIN_OFST)
+#define DAQ_FRCE_GAIN_STG_0_VAL ((0x0 << DAQ_FRCE_SWTCH_GAIN_OFST) & DAQ_FRCE_SWTCH_GAIN_MSK)
+#define DAQ_FRCE_GAIN_STG_1_VAL ((0x1 << DAQ_FRCE_SWTCH_GAIN_OFST) & DAQ_FRCE_SWTCH_GAIN_MSK)
+#define DAQ_FRCE_GAIN_STG_2_VAL ((0x3 << DAQ_FRCE_SWTCH_GAIN_OFST) & DAQ_FRCE_SWTCH_GAIN_MSK)
+#define DAQ_ELCTRN_CLLCTN_MDE_OFST (14)
+#define DAQ_ELCTRN_CLLCTN_MDE_MSK (0x00000001 << DAQ_ELCTRN_CLLCTN_MDE_OFST)
+#define DAQ_G2_CNNT_OFST (15)
+#define DAQ_G2_CNNT_MSK (0x00000001 << DAQ_G2_CNNT_OFST)
+#define DAQ_CRRNT_SRC_ENBL_OFST (16)
+#define DAQ_CRRNT_SRC_ENBL_MSK (0x00000001 << DAQ_CRRNT_SRC_ENBL_OFST)
+#define DAQ_CRRNT_SRC_CLMN_FIX_OFST (17)
+#define DAQ_CRRNT_SRC_CLMN_FIX_MSK (0x00000001 << DAQ_CRRNT_SRC_CLMN_FIX_OFST)
+#define DAQ_CRRNT_SRC_CLMN_SLCT_OFST (20)
+#define DAQ_CRRNT_SRC_CLMN_SLCT_MSK (0x0000003F << DAQ_CRRNT_SRC_CLMN_SLCT_OFST)
+#define DAQ_GAIN_MODE_MASK (DAQ_FRCE_SWTCH_GAIN_MSK | DAQ_FIX_GAIN_MSK | DAQ_CMP_RST_MSK)
+
+/** Chip Power Register */
+#define CHIP_POWER_REG (0x5E << MEM_MAP_SHIFT)
+
+#define CHIP_POWER_ENABLE_OFST (0)
+#define CHIP_POWER_ENABLE_MSK (0x00000001 << CHIP_POWER_ENABLE_OFST)
+#define CHIP_POWER_STATUS_OFST (1)
+#define CHIP_POWER_STATUS_MSK (0x00000001 << CHIP_POWER_STATUS_OFST)
+
+/** Temperature Control Register */
+#define TEMP_CTRL_REG (0x5F << MEM_MAP_SHIFT)
+
+#define TEMP_CTRL_PROTCT_THRSHLD_OFST (0)
+#define TEMP_CTRL_PROTCT_THRSHLD_MSK (0x000007FF << TEMP_CTRL_PROTCT_THRSHLD_OFST)
+#define TEMP_CTRL_PROTCT_ENABLE_OFST (16)
+#define TEMP_CTRL_PROTCT_ENABLE_MSK (0x00000001 << TEMP_CTRL_PROTCT_ENABLE_OFST)
+// set when temp higher than over threshold, write 1 to clear it
+#define TEMP_CTRL_OVR_TMP_EVNT_OFST (31)
+#define TEMP_CTRL_OVR_TMP_EVNT_MSK (0x00000001 << TEMP_CTRL_OVR_TMP_EVNT_OFST)
+
+/* Set Delay 64 bit register */
+#define SET_DELAY_LSB_REG (0x60 << MEM_MAP_SHIFT) // different kind of delay
+#define SET_DELAY_MSB_REG (0x61 << MEM_MAP_SHIFT) // different kind of delay
+
+/* Set Triggers 64 bit register */
+#define SET_CYCLES_LSB_REG (0x62 << MEM_MAP_SHIFT)
+#define SET_CYCLES_MSB_REG (0x63 << MEM_MAP_SHIFT)
+
+/* Set Frames 64 bit register */
+#define SET_FRAMES_LSB_REG (0x64 << MEM_MAP_SHIFT)
+#define SET_FRAMES_MSB_REG (0x65 << MEM_MAP_SHIFT)
+
+/* Set Period 64 bit register tT = T x 50 ns */
+#define SET_PERIOD_LSB_REG (0x66 << MEM_MAP_SHIFT)
+#define SET_PERIOD_MSB_REG (0x67 << MEM_MAP_SHIFT)
+
+/* Set Exptime 64 bit register eEXP = Exp x 25 ns */
+#define SET_EXPTIME_LSB_REG (0x68 << MEM_MAP_SHIFT)
+#define SET_EXPTIME_MSB_REG (0x69 << MEM_MAP_SHIFT)
+
+/* Starting Frame number 64 bit register */
+#define FRAME_NUMBER_LSB_REG (0x6A << MEM_MAP_SHIFT)
+#define FRAME_NUMBER_MSB_REG (0x6B << MEM_MAP_SHIFT)
+
+/* Comparator disable time (chipv1.1) 32 bit register tT = T x 25 ns
+Time before end of exposure when comparator is disabled */
+#define COMP_DSBLE_TIME_REG (0x6C << MEM_MAP_SHIFT)
+
+
+/* Trigger Delay 32 bit register */
+#define SET_TRIGGER_DELAY_LSB_REG (0x70 << MEM_MAP_SHIFT)
+#define SET_TRIGGER_DELAY_MSB_REG (0x71 << MEM_MAP_SHIFT)
+
+/** Module row coordinates */
+#define COORD_ROW_REG (0x7C << MEM_MAP_SHIFT)
+
+#define COORD_ROW_OUTER_OFST (0)
+#define COORD_ROW_OUTER_MSK (0x0000FFFF << COORD_ROW_OUTER_OFST)
+#define COORD_ROW_INNER_OFST (16)
+#define COORD_ROW_INNER_MSK (0x0000FFFF << COORD_ROW_INNER_OFST)
+
+/** Module column coordinates */
+#define COORD_COL_REG (0x7D << MEM_MAP_SHIFT)
+
+#define COORD_COL_OUTER_OFST (0)
+#define COORD_COL_OUTER_MSK (0x0000FFFF << COORD_COL_OUTER_OFST)
+#define COORD_COL_INNER_OFST (16)
+#define COORD_COL_INNER_MSK (0x0000FFFF << COORD_COL_INNER_OFST)
+
+/** Module ID coordinates */
+#define MOD_ID_REG (0x7E << MEM_MAP_SHIFT)
+
+#define MOD_ID_OFST (0)
+#define MOD_ID_MSK (0x0000FFFF << MOD_ID_OFST)
+
+/* ADC 0 Deserializer Control */
+#define ADC_DSRLZR_0_REG (0xF0 << MEM_MAP_SHIFT)
+#define ADC_DSRLZR_0_RFRSH_ALGNMNT_OFST (31) /* Refresh alignment */
+#define ADC_DSRLZR_0_RFRSH_ALGNMNT_MSK (0x00000001 << ADC_DSRLZR_0_RFRSH_ALGNMNT_OFST)
+
+/* ADC 0 Deserializer Control */
+#define ADC_DSRLZR_1_REG (0xF1 << MEM_MAP_SHIFT)
+#define ADC_DSRLZR_1_RFRSH_ALGNMNT_OFST (31)
+#define ADC_DSRLZR_1_RFRSH_ALGNMNT_MSK (0x00000001 << ADC_DSRLZR_1_RFRSH_ALGNMNT_OFST)
+
+/* ADC 0 Deserializer Control */
+#define ADC_DSRLZR_2_REG (0xF2 << MEM_MAP_SHIFT)
+#define ADC_DSRLZR_2_RFRSH_ALGNMNT_OFST (31)
+#define ADC_DSRLZR_2_RFRSH_ALGNMNT_MSK (0x00000001 << ADC_DSRLZR_2_RFRSH_ALGNMNT_OFST)
+
+/* ADC 0 Deserializer Control */
+#define ADC_DSRLZR_3_REG (0xF3 << MEM_MAP_SHIFT)
+#define ADC_DSRLZR_3_RFRSH_ALGNMNT_OFST (31)
+#define ADC_DSRLZR_3_RFRSH_ALGNMNT_MSK (0x00000001 << ADC_DSRLZR_3_RFRSH_ALGNMNT_OFST)
/* Round Robin */
-#define RXR_ENDPOINT_START_REG (0x1000 << MEM_MAP_SHIFT)
+#define RXR_ENDPOINTS_MAX (64)
+#define RXR_ENDPOINT_OUTER_START_REG (0x1000 << MEM_MAP_SHIFT)
+#define RXR_ENDPOINT_INNER_START_REG (0x2000 << MEM_MAP_SHIFT)
+
+#define RXR_ENDPOINT_OFST (0x10 << MEM_MAP_SHIFT)
+
+// clang-format on
diff --git a/slsDetectorServers/moenchDetectorServer/bin/DefaultPattern_moench.txt b/slsDetectorServers/moenchDetectorServer/bin/DefaultPattern_moench.txt
deleted file mode 100755
index 0114e9bb0..000000000
--- a/slsDetectorServers/moenchDetectorServer/bin/DefaultPattern_moench.txt
+++ /dev/null
@@ -1,301 +0,0 @@
-patword 0x0000 0x0008599f0418503a
-patword 0x0001 0x0008599f0418503a
-patword 0x0002 0x000859960418503a
-patword 0x0003 0x000859960418503a
-patword 0x0004 0x000859960418503a
-patword 0x0005 0x000859960418503a
-patword 0x0006 0x000859960418503a
-patword 0x0007 0x000859960418503a
-patword 0x0008 0x000859960418503a
-patword 0x0009 0x000859960418503a
-patword 0x000a 0x000859960418503a
-patword 0x000b 0x000859960418503a
-patword 0x000c 0x000859960418503a
-patword 0x000d 0x000859960418503a
-patword 0x000e 0x000859960418503a
-patword 0x000f 0x000859960418503a
-patword 0x0010 0x000859960418503a
-patword 0x0011 0x000859960418503a
-patword 0x0012 0x000859960418503a
-patword 0x0013 0x000859960418503a
-patword 0x0014 0x000859960418503a
-patword 0x0015 0x000859960418503a
-patword 0x0016 0x000819960418501a
-patword 0x0017 0x000819960418501a
-patword 0x0018 0x000819960418501a
-patword 0x0019 0x000819960418501a
-patword 0x001a 0x000819960418501a
-patword 0x001b 0x000819960418501a
-patword 0x001c 0x000819960418501a
-patword 0x001d 0x000819960418501a
-patword 0x001e 0x000819960418501a
-patword 0x001f 0x000819960418501a
-patword 0x0020 0x000819960418501a
-patword 0x0021 0x000819960418501a
-patword 0x0022 0x000819960418501a
-patword 0x0023 0x000819960418501a
-patword 0x0024 0x000819960418501a
-patword 0x0025 0x000819960418501a
-patword 0x0026 0x000819960418501a
-patword 0x0027 0x000819960418501a
-patword 0x0028 0x000819960418501a
-patword 0x0029 0x000819960418501a
-patword 0x002a 0x000819960418501a
-patword 0x002b 0x000819960418501a
-patword 0x002c 0x000819960418501a
-patword 0x002d 0x000819960418501a
-patword 0x002e 0x000819960418501a
-patword 0x002f 0x000819960418501a
-patword 0x0030 0x000819960008501a
-patword 0x0031 0x000819960008501a
-patword 0x0032 0x000819960008501a
-patword 0x0033 0x000819960008501a
-patword 0x0034 0x000819960008501a
-patword 0x0035 0x000819960008501a
-patword 0x0036 0x000819960008501a
-patword 0x0037 0x000819960008501a
-patword 0x0038 0x000819960008501a
-patword 0x0039 0x000819960008501a
-patword 0x003a 0x000819960008501a
-patword 0x003b 0x000819960008501a
-patword 0x003c 0x000819960008501a
-patword 0x003d 0x000819960008501a
-patword 0x003e 0x000819960008501a
-patword 0x003f 0x000819960008501a
-patword 0x0040 0x000819960008501a
-patword 0x0041 0x000819960008501a
-patword 0x0042 0x000819960008501a
-patword 0x0043 0x000819960008501a
-patword 0x0044 0x0008199f0008501a
-patword 0x0045 0x0008199f0008501a
-patword 0x0046 0x0008199f0008501a
-patword 0x0047 0x0008199f0008501a
-patword 0x0048 0x0008199f0008501a
-patword 0x0049 0x0008199f0008501a
-patword 0x004a 0x0008199f0008501a
-patword 0x004b 0x0008199f0008501a
-patword 0x004c 0x0008199f0008501a
-patword 0x004d 0x0008199f0008501a
-patword 0x004e 0x0008199f0008501a
-patword 0x004f 0x0008199f0008501a
-patword 0x0050 0x0008199f0008501a
-patword 0x0051 0x0008199f0008501a
-patword 0x0052 0x0008199f0008501a
-patword 0x0053 0x0008199f0008501a
-patword 0x0054 0x0008199f0008501a
-patword 0x0055 0x0008199f0008501a
-patword 0x0056 0x0008199f0008501a
-patword 0x0057 0x0008199f0008501a
-patword 0x0058 0x0008599f0008503a
-patword 0x0059 0x0008599f0008503a
-patword 0x005a 0x000c599f000850ba
-patword 0x005b 0x000c599f000850ba
-patword 0x005c 0x000c599f000850ba
-patword 0x005d 0x000c599f000850ba
-patword 0x005e 0x000c599f000850ba
-patword 0x005f 0x000c599f000850ba
-patword 0x0060 0x000c599f000850ba
-patword 0x0061 0x000c599f000850ba
-patword 0x0062 0x000c599f000850ba
-patword 0x0063 0x000c599f000850ba
-patword 0x0064 0x000c599f000850ba
-patword 0x0065 0x000c599f000850ba
-patword 0x0066 0x000c599f000850ba
-patword 0x0067 0x000c599f000850ba
-patword 0x0068 0x000c599f000850ba
-patword 0x0069 0x000c599f000850ba
-patword 0x006a 0x000c599f000850ba
-patword 0x006b 0x000c599f000850ba
-patword 0x006c 0x000c599f000850ba
-patword 0x006d 0x000c599f000850ba
-patword 0x006e 0x000c799f010858ba
-patword 0x006f 0x000c799f010858ba
-patword 0x0070 0x000c599f000850ba
-patword 0x0071 0x000c599f000850ba
-patword 0x0072 0x000c599f000850ba
-patword 0x0073 0x000c599f000850ba
-patword 0x0074 0x000c599f000850ba
-patword 0x0075 0x000c599f000850ba
-patword 0x0076 0x000c599f000850ba
-patword 0x0077 0x000c599f000850ba
-patword 0x0078 0x000c599f000850ba
-patword 0x0079 0x000c599f000850ba
-patword 0x007a 0x000c599f000850ba
-patword 0x007b 0x000c599f000850ba
-patword 0x007c 0x000c599f000850ba
-patword 0x007d 0x000c599f000850ba
-patword 0x007e 0x000c599f000850ba
-patword 0x007f 0x000c599f000850ba
-patword 0x0080 0x000c599f000850ba
-patword 0x0081 0x000c599f000850ba
-patword 0x0082 0x000c599f000850ba
-patword 0x0083 0x000c599f000850ba
-patword 0x0084 0x000c599f000850ba
-patword 0x0085 0x000c599f000850ba
-patword 0x0086 0x000c599f400850ba
-patword 0x0087 0x000c599f400850ba
-patword 0x0088 0x000c599f600850ba
-patword 0x0089 0x000c599f400850ba
-patword 0x008a 0x000c599f400850ba
-patword 0x008b 0x000c599f400850ba
-patword 0x008c 0x840c599f682e50ba
-patword 0x008d 0x840c599f482850ba
-patword 0x008e 0x840c599f000e50ba
-patword 0x008f 0x840c599f000850ba
-patword 0x0090 0x840c599f000e50ba
-patword 0x0091 0x840c599f000850ba
-patword 0x0092 0x840c599f000e50ba
-patword 0x0093 0x840c599f000850ba
-patword 0x0094 0x840c599f000e50ba
-patword 0x0095 0x840c599f000850ba
-patword 0x0096 0x840c599f000e50ba
-patword 0x0097 0x840c599f000850ba
-patword 0x0098 0x840c599f000e50ba
-patword 0x0099 0x840c599f000850ba
-patword 0x009a 0x840c599f000e50ba
-patword 0x009b 0x840c599f000850ba
-patword 0x009c 0x840c599f000e50ba
-patword 0x009d 0x840c599f000850ba
-patword 0x009e 0x840c599f000e50ba
-patword 0x009f 0x840c599f000850ba
-patword 0x00a0 0x840c599f000e50ba
-patword 0x00a1 0x840c599f000850ba
-patword 0x00a2 0x840c599f000e50ba
-patword 0x00a3 0x840c599f000850ba
-patword 0x00a4 0x840c599f000e50ba
-patword 0x00a5 0x840c599f000850ba
-patword 0x00a6 0x840c599f200e50ba
-patword 0x00a7 0x840c599f000850ba
-patword 0x00a8 0x840c599f000e50ba
-patword 0x00a9 0x840c599f000850ba
-patword 0x00aa 0x840c599f000e50ba
-patword 0x00ab 0x840c599f000850ba
-patword 0x00ac 0x840c599f000e50ba
-patword 0x00ad 0x840c599f000850ba
-patword 0x00ae 0x840c599f000e50ba
-patword 0x00af 0x840c599f000850ba
-patword 0x00b0 0x840c599f000e50ba
-patword 0x00b1 0x840c599f000850ba
-patword 0x00b2 0x840c599f000e50ba
-patword 0x00b3 0x840c599f000850ba
-patword 0x00b4 0x840c599f000e50ba
-patword 0x00b5 0x840c599f000850ba
-patword 0x00b6 0x840c599f000e50ba
-patword 0x00b7 0x840c599f000850ba
-patword 0x00b8 0x840c599f000e50ba
-patword 0x00b9 0x840c599f000850ba
-patword 0x00ba 0x840c599f000e50ba
-patword 0x00bb 0x840c599f000850ba
-patword 0x00bc 0x840c599f000e50ba
-patword 0x00bd 0x840c599f000850ba
-patword 0x00be 0x840c599f282e50ba
-patword 0x00bf 0x840c599f082850ba
-patword 0x00c0 0x840c599f000e50ba
-patword 0x00c1 0x840c599f000850ba
-patword 0x00c2 0x840c599f000e50ba
-patword 0x00c3 0x840c599f000850ba
-patword 0x00c4 0x840c599f000e50ba
-patword 0x00c5 0x840c599f000850ba
-patword 0x00c6 0x840c599f000e50ba
-patword 0x00c7 0x840c599f000850ba
-patword 0x00c8 0x840c599f000e50ba
-patword 0x00c9 0x840c599f000850ba
-patword 0x00ca 0x840c599f000e50ba
-patword 0x00cb 0x840c599f000850ba
-patword 0x00cc 0x840c599f000e50ba
-patword 0x00cd 0x840c599f000850ba
-patword 0x00ce 0x840c599f000e50ba
-patword 0x00cf 0x840c599f000850ba
-patword 0x00d0 0x840c599f000e50ba
-patword 0x00d1 0x840c599f000850ba
-patword 0x00d2 0x840c599f000e50ba
-patword 0x00d3 0x840c599f000850ba
-patword 0x00d4 0x840c599f000e50ba
-patword 0x00d5 0x840c599f000850ba
-patword 0x00d6 0x840c599f000e50ba
-patword 0x00d7 0x840c599f000850ba
-patword 0x00d8 0x840c599f200e50ba
-patword 0x00d9 0x840c599f000850ba
-patword 0x00da 0x840c599f000e50ba
-patword 0x00db 0x840c599f000850ba
-patword 0x00dc 0x840c599f000e50ba
-patword 0x00dd 0x840c599f000850ba
-patword 0x00de 0x840c599f000e50ba
-patword 0x00df 0x840c599f000850ba
-patword 0x00e0 0x840c599f000e50ba
-patword 0x00e1 0x840c599f000850ba
-patword 0x00e2 0x840c599f000e50ba
-patword 0x00e3 0x840c599f000850ba
-patword 0x00e4 0x840c599f000e50ba
-patword 0x00e5 0x840c599f000850ba
-patword 0x00e6 0x840c599f000e50ba
-patword 0x00e7 0x840c599f000850ba
-patword 0x00e8 0x840c599f000e50ba
-patword 0x00e9 0x840c599f000850ba
-patword 0x00ea 0x840c599f000e50ba
-patword 0x00eb 0x840c599f000850ba
-patword 0x00ec 0x840c599f000e50ba
-patword 0x00ed 0x840c599f000850ba
-patword 0x00ee 0x840c599f000e50ba
-patword 0x00ef 0x840c599f000850ba
-patword 0x00f0 0x040c599f000850ba
-patword 0x00f1 0x040c599f000850ba
-patword 0x00f2 0x000c599f000850ba
-patword 0x00f3 0x000c599f000850ba
-patword 0x00f4 0x0008599f200e503a
-patword 0x00f5 0x0008599f0008503a
-patword 0x00f6 0x0008599f200e503a
-patword 0x00f7 0x0008599f0008503a
-patword 0x00f8 0x0008599f0008503a
-patword 0x00f9 0x0008599f0008503a
-patword 0x00fa 0x0008599f0008503a
-patword 0x00fb 0x0008599f0008503a
-patword 0x00fc 0x0008599f0008503a
-patword 0x00fd 0x0008599f0008503a
-patword 0x00fe 0x0008599f0008503a
-patword 0x00ff 0x0008599f0008503a
-patword 0x0100 0x0008599f0008503a
-patword 0x0101 0x0008599f0008503a
-patword 0x0102 0x0008599f0008503a
-patword 0x0103 0x0008599f0008503a
-patword 0x0104 0x0008599f0008503a
-patword 0x0105 0x0008599f0008503a
-patword 0x0106 0x0008599f0008503a
-patword 0x0107 0x0008599f0008503a
-patword 0x0108 0x0008599f0008503a
-patword 0x0109 0x0008599f0008503a
-patword 0x010a 0x0008599f0008503a
-patword 0x010b 0x0008599f0008503a
-patword 0x010c 0x0008599f0008503a
-patword 0x010d 0x0008599f0008503a
-patword 0x010e 0x0008599f0008503a
-patword 0x010f 0x0008599f0008503a
-patword 0x0110 0x0008599f0008503a
-patword 0x0111 0x0008599f0008503a
-patioctrl 0x8f0effff6dbffdbf
-patlimits 0x0000 0x0110
-patloop 0 0x00be 0x00ef
-patnloop 0 199
-patloop 1 0x0400 0x0400
-patnloop 1 0
-patloop 2 0x0400 0x0400
-patnloop 2 0
-patwait 0 0x002e
-patwaittime 0 800
-patwait 1 0x0400
-patwaittime 1 0
-patwait 2 0x0400
-patwaittime 2 0
-
-patloop 3 0x1fff 0x1fff
-patnloop 3 0
-patloop 4 0x1fff 0x1fff
-patnloop 4 0
-patloop 5 0x1fff 0x1fff
-patnloop 5 0
-patwait 3 0x1fff
-patwaittime 3 0
-patwait 4 0x1fff
-patwaittime 4 0
-patwait 5 0x1fff
-patwaittime 5 0
diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer
index c7c21c2cb..b80fdb937 100755
Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ
diff --git a/slsDetectorServers/moenchDetectorServer/config_moench.txt b/slsDetectorServers/moenchDetectorServer/config_moench.txt
new file mode 100755
index 000000000..48fea871e
--- /dev/null
+++ b/slsDetectorServers/moenchDetectorServer/config_moench.txt
@@ -0,0 +1,4 @@
+
+
+#chip version version (multiplied by 10)
+chipversion 11
diff --git a/slsDetectorServers/moenchDetectorServer/detid_moench.txt b/slsDetectorServers/moenchDetectorServer/detid_moench.txt
new file mode 100755
index 000000000..274c0052d
--- /dev/null
+++ b/slsDetectorServers/moenchDetectorServer/detid_moench.txt
@@ -0,0 +1 @@
+1234
\ No newline at end of file
diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c
index f327b5071..56af23ead 100644
--- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c
+++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c
@@ -8,29 +8,27 @@
#include "ALTERA_PLL.h" // pll
#include "LTC2620.h" // dacs
#include "MAX1932.h" // hv
-#include "UDPPacketHeaderGenerator.h"
#include "common.h"
+#ifdef VIRTUAL
#include "communication_funcs_UDP.h"
-#include "loadPattern.h"
+#endif
#include
#include
+#include
#include // usleep
#ifdef VIRTUAL
-#include //ceil
#include
#include
#endif
-
+extern int portno;
// Global variable from slsDetectorServer_funcs
extern int debugflag;
extern int updateFlag;
extern udpStruct udpDetails[MAX_UDP_DESTINATION];
+extern int numUdpDestinations;
extern const enum detectorType myDetectorType;
-
-// Global variable from UDPPacketHeaderGenerator
-extern uint64_t udpFrameNumber;
-extern uint32_t udpPacketNumber;
+extern int ignoreConfigFileFlag;
// Global variable from communication_funcs.c
extern int isControlServer;
@@ -43,38 +41,19 @@ char initErrorMessage[MAX_STR_LENGTH];
#ifdef VIRTUAL
pthread_t pthread_virtual_tid;
+int virtual_image_test_mode = 0;
+int virtual_moduleid = 0;
#endif
-// 1g readout
-int dataBytes = 0;
-int analogDataBytes = 0;
-int digitalDataBytes = 0;
-char *analogData = 0;
-char *digitalData = 0;
-char volatile *analogDataPtr = 0;
-char volatile *digitalDataPtr = 0;
-char udpPacketData[UDP_PACKET_DATA_BYTES + sizeof(sls_detector_header)];
-uint32_t adcEnableMask_1g = BIT32_MSK;
-
-// 10g readout
-uint8_t adcEnableMask_10g = 0xFF;
-
-int32_t clkPhase[NUM_CLOCKS] = {};
-uint32_t clkFrequency[NUM_CLOCKS] = {40, 20, 20, 200};
-int dacValues[NDAC] = {};
-int defaultDacValues[NDAC] = DEFAULT_DAC_VALS;
-// software limit that depends on the current chip on the ctb
-int vLimit = 0;
enum detectorSettings thisSettings = UNINITIALIZED;
int highvoltage = 0;
-
-// getNumberofchannels return 0 for y in --update mode (virtual servers)
-#ifdef VIRTUAL
-int nSamples = DEFAULT_NUM_SAMPLES;
-#else
-int nSamples = 1;
-#endif
-int detPos[2] = {0, 0};
+int dacValues[NDAC] = {};
+int defaultDacValues[] = DEFAULT_DAC_VALS;
+int defaultDacValue_G0[] = SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS;
+int defaultDacValue_HG0[] = SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS;
+int32_t clkPhase[NUM_CLOCKS] = {};
+int detPos[4] = {};
+int chipConfigured = 0;
int isInitCheckDone() { return initCheckDone; }
@@ -88,9 +67,9 @@ void basictests() {
initCheckDone = 0;
memset(initErrorMessage, 0, MAX_STR_LENGTH);
#ifdef VIRTUAL
- LOG(logINFOBLUE, ("********* Moench Detector Virtual Server *********\n"));
+ LOG(logINFOBLUE, ("******** Moench Virtual Server *****************\n"));
#else
- LOG(logINFOBLUE, ("************* Moench Detector Server *************\n"));
+ LOG(logINFOBLUE, ("************ Moench Server *********************\n"));
initError = defineGPIOpins(initErrorMessage);
if (initError == FAIL) {
@@ -103,18 +82,27 @@ void basictests() {
#endif
if (mapCSP0() == FAIL) {
strcpy(initErrorMessage,
- "Could not map to memory. Dangerous to continue.\n");
+ "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
if ((!debugflag) && (!updateFlag) &&
((checkType() == FAIL) || (testFpga() == FAIL) ||
(testBus() == FAIL))) {
- strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. "
- "Dangerous to continue.\n");
+ sprintf(initErrorMessage,
+ "Could not pass basic tests of FPGA and bus. Cannot proceed. "
+ "Check Firmware. (Firmware version:0x%llx) \n",
+ getFirmwareVersion());
+ LOG(logERROR, ("%s\n\n", initErrorMessage));
+ initError = FAIL;
+ return;
+ }
+ // works currenly only for hw2.0
+ if (isHardwareVersion_1_0()) {
+ strcpy(initErrorMessage,
+ "HW v1.0 not supported yet. Please use HW v2.0\n");
LOG(logERROR, ("%s\n\n", initErrorMessage));
initError = FAIL;
return;
@@ -130,12 +118,13 @@ void basictests() {
char swversion[MAX_STR_LENGTH] = {0};
memset(swversion, 0, MAX_STR_LENGTH);
getServerVersion(swversion);
- int64_t sw_fw_apiversion = 0;
+ uint32_t requiredFirmwareVersion =
+ (isHardwareVersion_1_0() ? REQRD_FRMWRE_VRSN_BOARD2
+ : REQRD_FRMWRE_VRSN);
+ int64_t sw_fw_apiversion = getFirmwareAPIVersion();
- if (fwversion >= MIN_REQRD_VRSN_T_RD_API)
- sw_fw_apiversion = getFirmwareAPIVersion();
LOG(logINFOBLUE,
- ("**************************************************\n"
+ ("************ Moench Server *********************\n"
"Hardware Version:\t\t %s\n"
"Hardware Serial Nr:\t\t 0x%x\n"
@@ -149,7 +138,7 @@ void basictests() {
"********************************************************\n",
hversion, hsnumber, ipadd, (long long unsigned int)macadd,
(long long int)fwversion, swversion, (long long int)sw_fw_apiversion,
- REQRD_FRMWR_VRSN));
+ requiredFirmwareVersion));
#ifndef VIRTUAL
// return if flag is not zero, debug mode
@@ -168,31 +157,32 @@ void basictests() {
}
// check for API compatibility - old server
- if (sw_fw_apiversion > REQRD_FRMWR_VRSN) {
+ if (sw_fw_apiversion > requiredFirmwareVersion) {
sprintf(initErrorMessage,
"This firmware-software api version (0x%llx) is incompatible "
"with the software's minimum required firmware version "
"(0x%llx).\nPlease update detector software to be compatible "
"with this firmware.\n",
(long long int)sw_fw_apiversion,
- (long long int)REQRD_FRMWR_VRSN);
+ (long long int)requiredFirmwareVersion);
LOG(logERROR, (initErrorMessage));
initError = FAIL;
return;
}
// check for firmware compatibility - old firmware
- if (REQRD_FRMWR_VRSN > fwversion) {
+ if (requiredFirmwareVersion > fwversion) {
sprintf(initErrorMessage,
"This firmware version (0x%llx) is incompatible.\n"
"Please update firmware (min. 0x%llx) to be compatible with "
"this server.\n",
- (long long int)fwversion, (long long int)REQRD_FRMWR_VRSN);
+ (long long int)fwversion,
+ (long long int)requiredFirmwareVersion);
LOG(logERROR, (initErrorMessage));
initError = FAIL;
return;
}
- LOG(logINFO, ("\tCompatibility - success\n"));
+ LOG(logINFO, ("Compatibility - success\n"));
#endif
}
@@ -200,18 +190,14 @@ int checkType() {
#ifdef VIRTUAL
return OK;
#endif
- uint32_t type = ((bus_r(FPGA_VERSION_REG) & FPGA_VERSION_DTCTR_TYP_MSK) >>
- FPGA_VERSION_DTCTR_TYP_OFST);
- uint32_t expectedType =
- (((FPGA_VERSION_DTCTR_TYP_MOENCH_VAL)&FPGA_VERSION_DTCTR_TYP_MSK) >>
- FPGA_VERSION_DTCTR_TYP_OFST);
-
- if (type != expectedType) {
- LOG(logERROR, ("(Type Fail) - This is not a Moench Detector firmware "
- "(read %d, expected %d)\n",
- type, expectedType));
+ u_int32_t type =
+ ((bus_r(FPGA_VERSION_REG) & DETECTOR_TYPE_MSK) >> DETECTOR_TYPE_OFST);
+ if (type != MOENCH) {
+ LOG(logERROR, ("This is not a Moench firmware (read %d, expected %d)\n",
+ type, MOENCH));
return FAIL;
}
+
return OK;
}
@@ -223,73 +209,15 @@ int testFpga() {
// fixed pattern
int ret = OK;
- uint32_t val = bus_r(FIX_PATT_REG);
+ volatile u_int32_t val = bus_r(FIX_PATT_REG);
if (val == FIX_PATT_VAL) {
- LOG(logINFO, ("\tFixed pattern: successful match (0x%08x)\n", val));
+ LOG(logINFO, ("Fixed 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 = DELAY_LSB_REG;
-
- // 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;
}
@@ -300,47 +228,55 @@ int testBus() {
LOG(logINFO, ("Testing Bus:\n"));
int ret = OK;
- uint32_t addr = DELAY_LSB_REG;
+ u_int32_t addr = SET_TRIGGER_DELAY_LSB_REG;
+ u_int32_t times = 1000 * 1000;
- // 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));
+ for (u_int32_t i = 0; i < times; ++i) {
+ bus_w(addr, i * 100);
+ if (i * 100 != bus_r(addr)) {
+ LOG(logERROR,
+ ("Mismatch! Wrote 0x%x, read 0x%x\n", i * 100, bus_r(addr)));
ret = FAIL;
}
}
- // write back previous value
- bus_w(addr, previousValue);
+ bus_w(addr, 0);
if (ret == OK) {
- LOG(logINFO, ("\tSuccessfully tested bus %d times\n", times));
+ LOG(logINFO, ("Successfully tested bus %d times\n", times));
}
return ret;
}
+#ifdef VIRTUAL
+void setTestImageMode(int ival) {
+ if (ival >= 0) {
+ if (ival == 0) {
+ LOG(logINFO, ("Switching off Image Test Mode\n"));
+ virtual_image_test_mode = 0;
+ } else {
+ LOG(logINFO, ("Switching on Image Test Mode\n"));
+ virtual_image_test_mode = 1;
+ }
+ }
+}
+
+int getTestImageMode() { return virtual_image_test_mode; }
+#endif
+
/* Ids */
void getServerVersion(char *version) { strcpy(version, APIMOENCH); }
-uint64_t getFirmwareVersion() {
+u_int64_t getFirmwareVersion() {
#ifdef VIRTUAL
return 0;
#endif
- return ((bus_r(FPGA_VERSION_REG) & FPGA_VERSION_BRD_RVSN_MSK) >>
- FPGA_VERSION_BRD_RVSN_OFST);
+ return ((bus_r(FPGA_VERSION_REG) & FPGA_COMPILATION_DATE_MSK) >>
+ FPGA_COMPILATION_DATE_OFST);
}
-uint64_t getFirmwareAPIVersion() {
+u_int64_t getFirmwareAPIVersion() {
#ifdef VIRTUAL
return 0;
#endif
@@ -362,35 +298,82 @@ void getHardwareVersion(char *version) {
}
}
-uint16_t getHardwareVersionNumber() {
+u_int16_t getHardwareVersionNumber() {
#ifdef VIRTUAL
- return 0x1;
+ return 0x3;
#endif
- return ((bus_r(MOD_SERIAL_NUMBER_REG) & MOD_SERIAL_NUMBER_VRSN_MSK) >>
- MOD_SERIAL_NUMBER_VRSN_OFST);
+ return ((bus_r(MOD_SERIAL_NUM_REG) & HARDWARE_VERSION_NUM_MSK) >>
+ HARDWARE_VERSION_NUM_OFST);
}
-uint16_t getHardwareSerialNumber() {
+u_int16_t getHardwareSerialNumber() {
#ifdef VIRTUAL
return 0;
#endif
- return ((bus_r(MOD_SERIAL_NUMBER_REG) & MOD_SERIAL_NUMBER_MSK) >>
- MOD_SERIAL_NUMBER_OFST);
+ return ((bus_r(MOD_SERIAL_NUM_REG) & HARDWARE_SERIAL_NUM_MSK) >>
+ HARDWARE_SERIAL_NUM_OFST);
}
-uint32_t getDetectorNumber() {
+int isHardwareVersion_1_0() {
+ const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
+ return ((getHardwareVersionNumber() == hwNumberList[0]) ? 1 : 0);
+}
+
+int getChipVersion() {
+ // chip v1.1
+ if (bus_r(DAQ_REG) & DAQ_CHIP11_VRSN_MSK) {
+ return 11;
+ }
+ // chip v1.0
+ return 10;
+}
+
+void setChipVersion(int version) {
+ LOG(logINFO,
+ ("Setting chip version to %0.1f in FPGA\n", (double)version / 10.0));
+ if (version == 11) {
+ bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_CHIP11_VRSN_MSK);
+ } else {
+ bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_CHIP11_VRSN_MSK);
+ }
+}
+
+u_int32_t getDetectorNumber() {
#ifdef VIRTUAL
return 0;
#endif
- return bus_r(MOD_SERIAL_NUMBER_REG);
+ return bus_r(MOD_SERIAL_NUM_REG);
}
-uint64_t getDetectorMAC() {
+int getModuleId(int *ret, char *mess) {
+ return ((bus_r(MOD_ID_REG) & MOD_ID_MSK) >> MOD_ID_OFST);
+}
+
+void setModuleId(int modid) {
+ LOG(logINFOBLUE, ("Setting module id in fpga: %d\n", modid));
+ bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) & ~MOD_ID_MSK);
+ bus_w(MOD_ID_REG,
+ bus_r(MOD_ID_REG) | ((modid << MOD_ID_OFST) & MOD_ID_MSK));
+}
+
+int updateModuleId() {
+ int modid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
+ if (initError == FAIL) {
+ return FAIL;
+ }
+#ifdef VIRTUAL
+ virtual_moduleid = modid;
+#endif
+ setModuleId(modid);
+ return OK;
+}
+
+u_int64_t getDetectorMAC() {
#ifdef VIRTUAL
return 0;
#else
char output[255], mac[255] = "";
- uint64_t res = 0;
+ u_int64_t res = 0;
FILE *sysFile =
popen("ifconfig eth0 | grep HWaddr | cut -d \" \" -f 11", "r");
fgets(output, sizeof(output), sysFile);
@@ -407,12 +390,12 @@ uint64_t getDetectorMAC() {
#endif
}
-uint32_t getDetectorIP() {
+u_int32_t getDetectorIP() {
#ifdef VIRTUAL
return 0;
#endif
char temp[INET_ADDRSTRLEN] = "";
- uint32_t res = 0;
+ u_int32_t res = 0;
// execute and get address
char output[255];
FILE *sysFile = popen(
@@ -451,13 +434,20 @@ void initStopServer() {
if (mapCSP0() == FAIL) {
initError = FAIL;
strcpy(initErrorMessage,
- "Stop Server: Map Fail. Dangerous to continue. Goodbye!\n");
+ "Stop Server: Map Fail. Cannot proceed. Check Firmware.\n");
LOG(logERROR, (initErrorMessage));
initCheckDone = 1;
return;
}
+ if (readConfigFile() == FAIL) {
+ initCheckDone = 1;
+ return;
+ }
#ifdef VIRTUAL
sharedMemory_setStop(0);
+ // temp threshold and reset event (read by stop server)
+ setThresholdTemperature(DEFAULT_TMP_THRSHLD);
+ setTemperatureEvent(0);
#endif
}
initCheckDone = 1;
@@ -466,70 +456,28 @@ void initStopServer() {
/* set up detector */
void setupDetector() {
- LOG(logINFO, ("This Server is for 1 Moench Board module\n"));
+ LOG(logINFO, ("This Server is for 1 Moench module (500k)\n"));
- // default variables
- dataBytes = 0;
- analogDataBytes = 0;
- digitalDataBytes = 0;
- if (analogData) {
- free(analogData);
- analogData = 0;
- }
- if (digitalData) {
- free(digitalData);
- digitalData = 0;
- }
- analogDataPtr = 0;
- digitalDataPtr = 0;
for (int i = 0; i < NUM_CLOCKS; ++i) {
clkPhase[i] = 0;
}
- clkFrequency[RUN_CLK] = DEFAULT_RUN_CLK_AT_STARTUP;
- clkFrequency[ADC_CLK] = DEFAULT_ADC_CLK_AT_STARTUP;
- clkFrequency[SYNC_CLK] = DEFAULT_SYNC_CLK_AT_STARTUP;
- clkFrequency[DBIT_CLK] = DEFAULT_DBIT_CLK_AT_STARTUP;
- // default adc phase in deg
- /*
- {
- int phase_shifts = 0;
- ConvertToDifferentRange(0, 359, 0, getMaxPhase(ADC_CLK) - 1,
- DEFAULT_ADC_PHASE_DEG, &phase_shifts); clkPhase[ADC_CLK] =
- phase_shifts;
- }
- LOG(logINFO, ("Default Run clk: %d MHz\n",
- clkFrequency[RUN_CLK])); LOG(logINFO, ("Default Adc clk: %d MHz\n",
- clkFrequency[ADC_CLK])); LOG(logINFO, ("Default Sync clk: %d MHz\n",
- clkFrequency[SYNC_CLK])); LOG(logINFO, ("Default Dbit clk: %d MHz\n",
- clkFrequency[DBIT_CLK])); LOG(logINFO, ("Default Adc Phase: %d (%d
- deg)\n", clkPhase[ADC_CLK], getPhase(ADC_CLK, 1)));
- */
- for (int i = 0; i < NDAC; ++i)
- dacValues[i] = -1;
- vLimit = DEFAULT_VLIMIT;
- highvoltage = 0;
- adcEnableMask_1g = BIT32_MSK;
- adcEnableMask_10g = 0xFF;
- nSamples = 1;
+ chipConfigured = 0;
#ifdef VIRTUAL
sharedMemory_setStatus(IDLE);
- initializePatternWord();
-#endif
setupUDPCommParameters();
+#endif
// altera pll
- ALTERA_PLL_SetDefines(PLL_CNTRL_REG, PLL_PARAM_REG,
- PLL_CNTRL_RCNFG_PRMTR_RST_MSK, PLL_CNTRL_WR_PRMTR_MSK,
- PLL_CNTRL_PLL_RST_MSK, PLL_CNTRL_ADDR_MSK,
- PLL_CNTRL_ADDR_OFST);
- ALTERA_PLL_ResetPLLAndReconfiguration();
+ ALTERA_PLL_SetDefines(
+ PLL_CNTRL_REG, PLL_PARAM_REG, PLL_CNTRL_RCNFG_PRMTR_RST_MSK,
+ PLL_CNTRL_WR_PRMTR_MSK, PLL_CNTRL_PLL_RST_MSK, PLL_CNTRL_ADDR_MSK,
+ PLL_CNTRL_ADDR_OFST, PLL_CNTRL_DBIT_WR_PRMTR_MSK, DBIT_CLK_INDEX);
+ ALTERA_PLL_ResetPLL();
resetCore();
resetPeripheral();
cleanFifos();
- initializePatternAddresses();
-
// hv
MAX1932_SetDefines(SPI_REG, SPI_HV_SRL_CS_OTPT_MSK, SPI_HV_SRL_CLK_OTPT_MSK,
SPI_HV_SRL_DGTL_OTPT_MSK, SPI_HV_SRL_DGTL_OTPT_OFST,
@@ -537,142 +485,157 @@ void setupDetector() {
MAX1932_Disable();
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
- // power off chip
- powerChip(0);
-
- // adcs
+ // adc
AD9257_SetDefines(ADC_SPI_REG, ADC_SPI_SRL_CS_OTPT_MSK,
ADC_SPI_SRL_CLK_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_MSK,
ADC_SPI_SRL_DT_OTPT_OFST);
AD9257_Disable();
AD9257_Configure();
- // dacs
+ // dac
LTC2620_SetDefines(SPI_REG, SPI_DAC_SRL_CS_OTPT_MSK,
SPI_DAC_SRL_CLK_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_MSK,
SPI_DAC_SRL_DGTL_OTPT_OFST, NDAC, DAC_MIN_MV,
- DAC_MAX_MV); // has to be before setvchip
+ DAC_MAX_MV);
LTC2620_Disable();
LTC2620_Configure();
resetToDefaultDacs(0);
- // not using setADCInvertRegister command (as it xors the default)
- bus_w(ADC_PORT_INVERT_REG, ADC_PORT_INVERT_VAL);
+ /* Only once at server startup */
+ bus_w(DAQ_REG, 0x0);
LOG(logINFOBLUE, ("Setting Default parameters\n"));
- cleanFifos(); // FIXME: why twice?
+
+ // get chip version
+ if (readConfigFile() == FAIL) {
+ return;
+ }
+
+ if (updateModuleId() == FAIL) {
+ return;
+ }
+
+ setReadoutSpeed(HALF_SPEED);
+ cleanFifos();
resetCore();
- // 1G UDP
- enableTenGigabitEthernet(0);
+ alignDeserializer();
+
+ // delay
+ bus_w(ADC_PORT_INVERT_REG,
+ (isHardwareVersion_1_0() ? ADC_PORT_INVERT_BOARD2_VAL
+ : ADC_PORT_INVERT_VAL));
+
+ initReadoutConfiguration();
// Initialization of acquistion parameters
- setNumAnalogSamples(DEFAULT_NUM_SAMPLES);
+ disableCurrentSource();
+ setSettings(DEFAULT_SETTINGS);
+ setGainMode(DEFAULT_GAINMODE);
+
setNumFrames(DEFAULT_NUM_FRAMES);
- setExpTime(DEFAULT_EXPTIME);
setNumTriggers(DEFAULT_NUM_CYCLES);
+ setExpTime(DEFAULT_EXPTIME);
setPeriod(DEFAULT_PERIOD);
setDelayAfterTrigger(DEFAULT_DELAY);
setTiming(DEFAULT_TIMING_MODE);
- setADCEnableMask(BIT32_MSK);
- setADCEnableMask_10G(BIT32_MSK);
- if (setAnalogOnlyReadout() == FAIL) {
- strcpy(initErrorMessage,
- "Could not set readout mode to analog only.\n");
- LOG(logERROR, ("%s\n\n", initErrorMessage));
- initError = FAIL;
- }
- setADCPipeline(DEFAULT_PIPELINE);
- if (initError != FAIL) {
- initError = loadPatternFile(DEFAULT_PATTERN_FILE, initErrorMessage);
- }
- setSettings(DEFAULT_SETTINGS);
-
- setFrequency(RUN_CLK, DEFAULT_RUN_CLK);
- setFrequency(ADC_CLK, DEFAULT_ADC_CLK);
- setFrequency(DBIT_CLK, DEFAULT_DBIT_CLK);
- setPhase(ADC_CLK, DEFAULT_ADC_PHASE_DEG, 1);
setNextFrameNumber(DEFAULT_STARTING_FRAME_NUMBER);
-}
-int updateDatabytesandAllocateRAM() {
-
- int oldDataBytes = analogDataBytes;
- updateDataBytes();
-
- // update only if change in databytes
- if (analogDataBytes == oldDataBytes) {
- LOG(logDEBUG1,
- ("RAM size (Databytes:%d) already allocated. Nothing to be done.\n",
- dataBytes));
- return OK;
+ // temp threshold and reset event
+ setThresholdTemperature(DEFAULT_TMP_THRSHLD);
+ setTemperatureEvent(0);
+ if (getChipVersion() == 11) {
+ setFilterResistor(DEFAULT_FILTER_RESISTOR);
+ setNumberOfFilterCells(DEFAULT_FILTER_CELL);
}
- // Zero databytes
- if (analogDataBytes == 0) {
- LOG(logERROR, ("Can not allocate RAM for 0 bytes.\n"));
- return FAIL;
+ if (!isHardwareVersion_1_0()) {
+ setFlipRows(DEFAULT_FLIP_ROWS);
+ setReadNRows(MAX_ROWS_PER_READOUT);
}
- // clear RAM
- if (analogData) {
- free(analogData);
- analogData = 0;
- }
- // allocate RAM
- analogData = malloc(analogDataBytes);
- // cannot malloc
- if (analogData == NULL) {
- LOG(logERROR, ("Can not allocate data RAM for even 1 frame. "
- "Probable cause: Memory Leak.\n"));
- return FAIL;
- }
- LOG(logINFO, ("\tRAM allocated to %d bytes\n", analogDataBytes));
- return OK;
-}
-
-void updateDataBytes() {
- int nchans = 0;
- analogDataBytes = 0;
-
- if (adcEnableMask_1g == BIT32_MSK)
- nchans = 32;
- else {
- for (int ichan = 0; ichan < NCHAN; ++ichan) {
- if (adcEnableMask_1g & (1 << ichan))
- ++nchans;
- }
- }
- analogDataBytes = nchans * (DYNAMIC_RANGE / 8) * nSamples;
- LOG(logINFO, ("\t#Channels:%d, Databytes:%d\n", nchans, analogDataBytes));
-
- dataBytes = analogDataBytes;
}
int resetToDefaultDacs(int hardReset) {
+ LOG(logINFOBLUE, ("Resetting %s to Default Dac values\n",
+ (hardReset == 1 ? "hard" : "")));
+
// reset defaults to hardcoded defaults
if (hardReset) {
const int vals[] = DEFAULT_DAC_VALS;
for (int i = 0; i < NDAC; ++i) {
defaultDacValues[i] = vals[i];
}
- }
- // reset dacs to defaults
- int ret = OK;
- LOG(logINFOBLUE, ("Setting Default Dac values\n"));
- for (int i = 0; i < NDAC; ++i) {
- setDAC((enum DACINDEX)i, defaultDacValues[i], 0);
- if (dacValues[i] != defaultDacValues[i]) {
- ret = FAIL;
- LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
- defaultDacValues[i], dacValues[i]));
+ const int vals_G0[] = SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS;
+ for (int i = 0; i < NSPECIALDACS; ++i) {
+ defaultDacValue_G0[i] = vals_G0[i];
+ }
+ const int vals_HG0[] = SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS;
+ for (int i = 0; i < NSPECIALDACS; ++i) {
+ defaultDacValue_HG0[i] = vals_HG0[i];
}
}
- return ret;
+
+ // remember settings
+ enum detectorSettings oldSettings = thisSettings;
+
+ // reset dacs to defaults
+ const int specialDacs[] = SPECIALDACINDEX;
+ for (int i = 0; i < NDAC; ++i) {
+ int value = defaultDacValues[i];
+
+ for (int j = 0; j < NSPECIALDACS; ++j) {
+ // special dac: replace default value
+ if (specialDacs[j] == i) {
+ switch (oldSettings) {
+ case GAIN0:
+ value = defaultDacValue_G0[j];
+ break;
+ case HIGHGAIN0:
+ value = defaultDacValue_HG0[j];
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ }
+
+ // set to defualt
+ setDAC((enum DACINDEX)i, value, 0);
+ if (dacValues[i] != value) {
+ LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
+ value, dacValues[i]));
+ return FAIL;
+ }
+ }
+ return OK;
}
+
int getDefaultDac(enum DACINDEX index, enum detectorSettings sett,
int *retval) {
+
+ // settings only for special dacs
if (sett != UNDEFINED) {
+ const int specialDacs[] = SPECIALDACINDEX;
+ // find special dac index
+ for (int i = 0; i < NSPECIALDACS; ++i) {
+ if ((int)index == specialDacs[i]) {
+ switch (sett) {
+ case GAIN0:
+ *retval = defaultDacValue_G0[i];
+ return OK;
+ case HIGHGAIN0:
+ *retval = defaultDacValue_HG0[i];
+ return OK;
+ // unknown settings
+ default:
+ return FAIL;
+ }
+ }
+ }
+ // not a special dac
return FAIL;
}
+
if (index < 0 || index >= NDAC)
return FAIL;
*retval = defaultDacValues[index];
@@ -680,19 +643,184 @@ int getDefaultDac(enum DACINDEX index, enum detectorSettings sett,
}
int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value) {
+ char *dac_names[] = {DAC_NAMES};
+
+ // settings only for special dacs
if (sett != UNDEFINED) {
+ const int specialDacs[] = SPECIALDACINDEX;
+ // find special dac index
+ for (int i = 0; i < NSPECIALDACS; ++i) {
+ if ((int)index == specialDacs[i]) {
+ switch (sett) {
+ case GAIN0:
+ LOG(logINFO, ("Setting Default Dac [%d - %s, gain0]: %d\n",
+ (int)index, dac_names[index], value));
+ defaultDacValue_G0[i] = value;
+ return OK;
+ case HIGHGAIN0:
+ LOG(logINFO,
+ ("Setting Default Dac [%d - %s, highgain0]: %d\n",
+ (int)index, dac_names[index], value));
+ defaultDacValue_HG0[i] = value;
+ return OK;
+ // unknown settings
+ default:
+ return FAIL;
+ }
+ }
+ }
+ // not a special dac
return FAIL;
}
if (index < 0 || index >= NDAC)
return FAIL;
-
- char *dac_names[] = {DAC_NAMES};
LOG(logINFO, ("Setting Default Dac [%d - %s]: %d\n", (int)index,
dac_names[index], value));
defaultDacValues[index] = value;
return OK;
}
+int readConfigFile() {
+
+ if (initError == FAIL) {
+ return initError;
+ }
+
+ if (ignoreConfigFileFlag) {
+ LOG(logWARNING, ("Ignoring Config file\n"));
+ return OK;
+ }
+
+ const int fileNameSize = 128;
+ char fname[fileNameSize];
+ if (getAbsPath(fname, fileNameSize, CONFIG_FILE) == FAIL) {
+ return FAIL;
+ }
+
+ // file doesnt exist (give warning and assume chipv1.0)
+ if (access(fname, F_OK) != 0) {
+ LOG(logWARNING, ("Could not find config file. Assuming chipv1.0\n"));
+ return OK;
+ }
+
+ // open config file
+ FILE *fd = fopen(fname, "r");
+ if (fd == NULL) {
+
+ sprintf(initErrorMessage,
+ "Could not open on-board detector server config file [%s].\n",
+ CONFIG_FILE);
+ initError = FAIL;
+ LOG(logERROR, ("%s\n\n", initErrorMessage));
+ return FAIL;
+ }
+
+ LOG(logINFOBLUE, ("Reading config file %s\n", CONFIG_FILE));
+
+ // Initialization
+ const size_t LZ = 256;
+ char line[LZ];
+ memset(line, 0, LZ);
+ char command[LZ];
+
+ // keep reading a line
+ while (fgets(line, LZ, fd)) {
+
+ // ignore comments
+ if (line[0] == '#') {
+ LOG(logDEBUG1, ("Ignoring Comment\n"));
+ continue;
+ }
+
+ // ignore empty lines
+ if (strlen(line) <= 1) {
+ LOG(logDEBUG1, ("Ignoring Empty line\n"));
+ continue;
+ }
+
+ // removing leading spaces
+ if (line[0] == ' ' || line[0] == '\t') {
+ int len = strlen(line);
+ // find first valid character
+ int i = 0;
+ for (i = 0; i < len; ++i) {
+ if (line[i] != ' ' && line[i] != '\t') {
+ break;
+ }
+ }
+ // ignore the line full of spaces (last char \n)
+ if (i >= len - 1) {
+ LOG(logDEBUG1, ("Ignoring line full of spaces\n"));
+ continue;
+ }
+ // copying only valid char
+ char temp[LZ];
+ memset(temp, 0, LZ);
+ memcpy(temp, line + i, strlen(line) - i);
+ memset(line, 0, LZ);
+ memcpy(line, temp, strlen(temp));
+ LOG(logDEBUG1, ("Removing leading spaces.\n"));
+ }
+
+ LOG(logDEBUG1, ("Command to process: (size:%d) %.*s\n", strlen(line),
+ strlen(line) - 1, line));
+ memset(command, 0, LZ);
+
+ // chipversion command
+ if (!strncmp(line, "chipversion", strlen("chipversion"))) {
+ int version = 0;
+
+ // cannot scan values
+ if (sscanf(line, "%s %d", command, &version) != 2) {
+ sprintf(
+ initErrorMessage,
+ "Could not scan chipversion commands from on-board server "
+ "config file. Line:[%s].\n",
+ line);
+ break;
+ }
+ // validations
+ if (version != 10 && version != 11) {
+ sprintf(initErrorMessage,
+ "Could not set chip version from on-board server "
+ "config file. Invalid chip version %d. Line:[%s].\n",
+ version, line);
+ break;
+ }
+ // chipversion 1.1 and HW 1.0 is incompatible
+ if (version == 11 && isHardwareVersion_1_0()) {
+ strcpy(initErrorMessage,
+ "Chip version 1.1 (from on-board config file) is "
+ "incompatible with hardware version v1.0. Please update "
+ "board or correct on-board config file.\n");
+ break;
+ }
+
+ setChipVersion(version);
+ }
+
+ // other commands
+ else {
+ sprintf(initErrorMessage,
+ "Could not scan command from on-board server "
+ "config file. Line:[%s].\n",
+ line);
+ break;
+ }
+
+ memset(line, 0, LZ);
+ }
+ fclose(fd);
+
+ if (strlen(initErrorMessage)) {
+ initError = FAIL;
+ LOG(logERROR, ("%s\n\n", initErrorMessage));
+ } else {
+ LOG(logINFOBLUE, ("Successfully read config file\n"));
+ }
+ return initError;
+}
+
/* firmware functions (resets) */
void cleanFifos() {
@@ -700,8 +828,8 @@ void cleanFifos() {
return;
#endif
LOG(logINFO, ("Clearing Acquisition Fifos\n"));
- bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_CLR_ACQSTN_FIFO_MSK);
- bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_CLR_ACQSTN_FIFO_MSK);
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_ACQ_FIFO_CLR_MSK);
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_ACQ_FIFO_CLR_MSK);
}
void resetCore() {
@@ -709,8 +837,9 @@ void resetCore() {
return;
#endif
LOG(logINFO, ("Resetting Core\n"));
- bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_CRE_RST_MSK);
- bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_CRE_RST_MSK);
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_CORE_RST_MSK);
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_CORE_RST_MSK);
+ usleep(1000 * 1000);
}
void resetPeripheral() {
@@ -718,11 +847,11 @@ void resetPeripheral() {
return;
#endif
LOG(logINFO, ("Resetting Peripheral\n"));
- bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_PRPHRL_RST_MSK);
- bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_PRPHRL_RST_MSK);
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_PERIPHERAL_RST_MSK);
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_PERIPHERAL_RST_MSK);
}
-/* set parameters - dr, adcenablemask */
+/* set parameters - dr, roi */
int setDynamicRange(int dr) {
if (dr == 16)
@@ -735,89 +864,11 @@ int getDynamicRange(int *retval) {
return OK;
}
-int setADCEnableMask(uint32_t mask) {
- if (mask == 0u) {
- LOG(logERROR, ("Cannot set 1gb adc mask to 0\n"));
- return FAIL;
- }
- int topAdcs = __builtin_popcount(mask & 0xF0F0F0F0);
- int bottomAdcs = __builtin_popcount(mask & 0x0F0F0F0F);
- if (topAdcs > 0 && bottomAdcs > 0 && topAdcs != bottomAdcs) {
- LOG(logERROR,
- ("Invalid mask. Top and bottom number of adcs do not match\n"));
- return FAIL;
- }
- LOG(logINFO, ("Setting adcEnableMask 1G to 0x%08x\n", mask));
- adcEnableMask_1g = mask;
- // 1Gb enabled
- if (!enableTenGigabitEthernet(-1)) {
- if (updateDatabytesandAllocateRAM() == FAIL) {
- return FAIL;
- }
- }
- return OK;
-}
-
-uint32_t getADCEnableMask() { return adcEnableMask_1g; }
-
-void setADCEnableMask_10G(uint32_t mask) {
- if (mask == 0u) {
- LOG(logERROR, ("Cannot set 10gb adc mask to 0\n"));
- return;
- }
- int topAdcs = __builtin_popcount(mask & 0xF0F0F0F0);
- int bottomAdcs = __builtin_popcount(mask & 0x0F0F0F0F);
- if (topAdcs > 0 && bottomAdcs > 0 && topAdcs != bottomAdcs) {
- LOG(logERROR,
- ("Invalid mask. Top and bottom number of adcs do not match\n"));
- return;
- }
- // convert 32 bit mask to 8 bit mask
- uint8_t actualMask = 0;
- if (mask != 0) {
- int ival = 0;
- for (int ich = 0; ich < NCHAN; ich = ich + 4) {
- if ((1 << ich) & mask) {
- actualMask |= (1 << ival);
- }
- ++ival;
- }
- }
-
- LOG(logINFO, ("Setting adcEnableMask 10G to 0x%x (from 0x%08x)\n",
- actualMask, mask));
- adcEnableMask_10g = actualMask;
- uint32_t addr = READOUT_10G_ENABLE_REG;
- bus_w(addr, bus_r(addr) & (~READOUT_10G_ENABLE_ANLG_MSK));
- bus_w(addr,
- bus_r(addr) | ((adcEnableMask_10g << READOUT_10G_ENABLE_ANLG_OFST) &
- READOUT_10G_ENABLE_ANLG_MSK));
-}
-
-uint32_t getADCEnableMask_10G() {
- adcEnableMask_10g =
- ((bus_r(READOUT_10G_ENABLE_REG) & READOUT_10G_ENABLE_ANLG_MSK) >>
- READOUT_10G_ENABLE_ANLG_OFST);
-
- // convert 8 bit mask to 32 bit mask
- uint32_t retval = 0;
- if (adcEnableMask_10g) {
- for (int ival = 0; ival < 8; ++ival) {
- // if bit in 8 bit mask set
- if ((1 << ival) & adcEnableMask_10g) {
- // set it for 4 bits in 32 bit mask
- for (int iloop = 0; iloop < 4; ++iloop) {
- retval |= (1 << (ival * 4 + iloop));
- }
- }
- }
- }
- return retval;
-}
-
void setADCInvertRegister(uint32_t val) {
LOG(logINFO, ("Setting ADC Port Invert Reg to 0x%x\n", val));
- uint32_t defaultValue = ADC_PORT_INVERT_VAL;
+ uint32_t defaultValue =
+ (isHardwareVersion_1_0() ? ADC_PORT_INVERT_BOARD2_VAL
+ : ADC_PORT_INVERT_VAL);
uint32_t changeValue = defaultValue ^ val;
LOG(logINFO, ("\t default: 0x%x, final:0x%x\n", defaultValue, changeValue));
bus_w(ADC_PORT_INVERT_REG, changeValue);
@@ -825,7 +876,8 @@ void setADCInvertRegister(uint32_t val) {
uint32_t getADCInvertRegister() {
uint32_t readValue = bus_r(ADC_PORT_INVERT_REG);
- int32_t defaultValue = ADC_PORT_INVERT_VAL;
+ int32_t defaultValue = (isHardwareVersion_1_0() ? ADC_PORT_INVERT_BOARD2_VAL
+ : ADC_PORT_INVERT_VAL);
uint32_t val = defaultValue ^ readValue;
LOG(logDEBUG1, ("\tread:0x%x, default:0x%x returned:0x%x\n", readValue,
defaultValue, val));
@@ -833,76 +885,71 @@ uint32_t getADCInvertRegister() {
}
/* parameters - timer */
+
int setNextFrameNumber(uint64_t value) {
LOG(logINFO,
("Setting next frame number: %llu\n", (long long unsigned int)value));
- setU64BitReg(value, NEXT_FRAME_NUMB_LOCAL_LSB_REG,
- NEXT_FRAME_NUMB_LOCAL_MSB_REG);
-#ifndef VIRTUAL
- // for 1g udp interface
- setUDPFrameNumber(value);
+#ifdef VIRTUAL
+ setU64BitReg(value, FRAME_NUMBER_LSB_REG, FRAME_NUMBER_MSB_REG);
+#else
+ // decrement is for firmware
+ setU64BitReg(value - 1, FRAME_NUMBER_LSB_REG, FRAME_NUMBER_MSB_REG);
+ // need to set it twice for the firmware to catch
+ setU64BitReg(value - 1, FRAME_NUMBER_LSB_REG, FRAME_NUMBER_MSB_REG);
#endif
return OK;
}
int getNextFrameNumber(uint64_t *retval) {
- *retval = getU64BitReg(NEXT_FRAME_NUMB_LOCAL_LSB_REG,
- NEXT_FRAME_NUMB_LOCAL_MSB_REG);
+#ifdef VIRTUAL
+ *retval = getU64BitReg(FRAME_NUMBER_LSB_REG, FRAME_NUMBER_MSB_REG);
+#else
+ // increment is for firmware
+ *retval =
+ (getU64BitReg(GET_FRAME_NUMBER_LSB_REG, GET_FRAME_NUMBER_MSB_REG) + 1);
+#endif
return OK;
}
void setNumFrames(int64_t val) {
if (val > 0) {
LOG(logINFO, ("Setting number of frames %lld\n", (long long int)val));
- set64BitReg(val, FRAMES_LSB_REG, FRAMES_MSB_REG);
+ set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
}
}
-int64_t getNumFrames() { return get64BitReg(FRAMES_LSB_REG, FRAMES_MSB_REG); }
+int64_t getNumFrames() {
+ return get64BitReg(SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
+}
void setNumTriggers(int64_t val) {
if (val > 0) {
LOG(logINFO, ("Setting number of triggers %lld\n", (long long int)val));
- set64BitReg(val, CYCLES_LSB_REG, CYCLES_MSB_REG);
+ set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
}
}
-int64_t getNumTriggers() { return get64BitReg(CYCLES_LSB_REG, CYCLES_MSB_REG); }
-
-int setNumAnalogSamples(int val) {
- if (val < 0) {
- LOG(logERROR, ("Invalid analog samples: %d\n", val));
- return FAIL;
- }
- LOG(logINFO, ("Setting number of analog samples %d\n", val));
- nSamples = val;
- bus_w(SAMPLES_REG, bus_r(SAMPLES_REG) & ~SAMPLES_ANALOG_MSK);
- bus_w(SAMPLES_REG, bus_r(SAMPLES_REG) |
- ((val << SAMPLES_ANALOG_OFST) & SAMPLES_ANALOG_MSK));
-
- // 1Gb
- if (!enableTenGigabitEthernet(-1)) {
- if (updateDatabytesandAllocateRAM() == FAIL) {
- return FAIL;
- }
- }
- return OK;
+int64_t getNumTriggers() {
+ return get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
}
-int getNumAnalogSamples() { return nSamples; }
-
int setExpTime(int64_t val) {
if (val < 0) {
LOG(logERROR, ("Invalid exptime: %lld ns\n", (long long int)val));
return FAIL;
}
LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val));
- val *= (1E-3 * clkFrequency[RUN_CLK]);
- setPatternWaitTime(0, 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 * clkFrequency[RUN_CLK]);
+ val /= (1E-3 * CLK_RUN);
if (val != retval) {
return FAIL;
}
@@ -910,7 +957,9 @@ int setExpTime(int64_t val) {
}
int64_t getExpTime() {
- return getPatternWaitTime(0) / (1E-3 * clkFrequency[RUN_CLK]);
+ return (get64BitReg(SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG) +
+ ACQ_TIME_MIN_CLOCK) /
+ (1E-3 * CLK_RUN);
}
int setPeriod(int64_t val) {
@@ -919,12 +968,12 @@ int setPeriod(int64_t val) {
return FAIL;
}
LOG(logINFO, ("Setting period %lld ns\n", (long long int)val));
- val *= (1E-3 * clkFrequency[SYNC_CLK]);
- set64BitReg(val, PERIOD_LSB_REG, PERIOD_MSB_REG);
+ val *= (1E-3 * CLK_SYNC);
+ set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
// validate for tolerance
int64_t retval = getPeriod();
- val /= (1E-3 * clkFrequency[SYNC_CLK]);
+ val /= (1E-3 * CLK_SYNC);
if (val != retval) {
return FAIL;
}
@@ -932,8 +981,8 @@ int setPeriod(int64_t val) {
}
int64_t getPeriod() {
- return get64BitReg(PERIOD_LSB_REG, PERIOD_MSB_REG) /
- (1E-3 * clkFrequency[SYNC_CLK]);
+ return get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG) /
+ (1E-3 * CLK_SYNC);
}
int setDelayAfterTrigger(int64_t val) {
@@ -943,12 +992,12 @@ int setDelayAfterTrigger(int64_t val) {
return FAIL;
}
LOG(logINFO, ("Setting delay after trigger %lld ns\n", (long long int)val));
- val *= (1E-3 * clkFrequency[SYNC_CLK]);
- set64BitReg(val, DELAY_LSB_REG, DELAY_MSB_REG);
+ val *= (1E-3 * CLK_SYNC);
+ set64BitReg(val, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG);
// validate for tolerance
int64_t retval = getDelayAfterTrigger();
- val /= (1E-3 * clkFrequency[SYNC_CLK]);
+ val /= (1E-3 * CLK_SYNC);
if (val != retval) {
return FAIL;
}
@@ -956,151 +1005,201 @@ int setDelayAfterTrigger(int64_t val) {
}
int64_t getDelayAfterTrigger() {
- return get64BitReg(DELAY_LSB_REG, DELAY_MSB_REG) /
- (1E-3 * clkFrequency[SYNC_CLK]);
+ return get64BitReg(SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG) /
+ (1E-3 * CLK_SYNC);
}
int64_t getNumFramesLeft() {
- return get64BitReg(FRAMES_LEFT_LSB_REG, FRAMES_LEFT_MSB_REG);
+ return get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG);
}
int64_t getNumTriggersLeft() {
- return get64BitReg(CYCLES_LEFT_LSB_REG, CYCLES_LEFT_MSB_REG);
-}
-
-int64_t getDelayAfterTriggerLeft() {
- return get64BitReg(DELAY_LEFT_LSB_REG, DELAY_LEFT_MSB_REG) /
- (1E-3 * clkFrequency[SYNC_CLK]);
+ return get64BitReg(GET_CYCLES_LSB_REG, GET_CYCLES_MSB_REG);
}
int64_t getPeriodLeft() {
- return get64BitReg(PERIOD_LEFT_LSB_REG, PERIOD_LEFT_MSB_REG) /
- (1E-3 * clkFrequency[SYNC_CLK]);
+ return get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG) /
+ (1E-3 * CLK_SYNC);
+}
+
+int64_t getDelayAfterTriggerLeft() {
+ return get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG) /
+ (1E-3 * CLK_SYNC);
}
int64_t getFramesFromStart() {
- return get64BitReg(FRAMES_FROM_START_PG_LSB_REG,
- FRAMES_FROM_START_PG_MSB_REG);
+ return get64BitReg(FRAMES_FROM_START_LSB_REG, FRAMES_FROM_START_MSB_REG);
}
int64_t getActualTime() {
return get64BitReg(TIME_FROM_START_LSB_REG, TIME_FROM_START_MSB_REG) /
- (1E-3 * CLK_FREQ);
+ (1E-3 * CLK_SYNC);
}
int64_t getMeasurementTime() {
return get64BitReg(START_FRAME_TIME_LSB_REG, START_FRAME_TIME_MSB_REG) /
- (1E-3 * CLK_FREQ);
+ (1E-3 * CLK_SYNC);
}
-/* parameters - settings */
+/* parameters - channel, chip, module, settings */
+
+int setModule(sls_detector_module myMod, char *mess) {
+
+ LOG(logINFO, ("Setting module with settings %d\n", myMod.reg));
+
+ // settings
+ setSettings((enum detectorSettings)myMod.reg);
+
+ // set dac values
+ for (int i = 0; i < NDAC; ++i)
+ setDAC((enum DACINDEX)i, myMod.dacs[i], 0);
+ return OK;
+}
enum detectorSettings setSettings(enum detectorSettings sett) {
if (sett == UNINITIALIZED)
return thisSettings;
+ int *dacVals = NULL;
// set settings
switch (sett) {
- case G1_HIGHGAIN:
- LOG(logINFO, ("Set settings - G1_HIGHGAIN\n"));
- setPatternBitMask(G1_HIGHGAIN_PATSETBIT);
+ case GAIN0:
+ bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_HIGH_GAIN_MSK);
+ LOG(logINFO,
+ ("Set settings - Gain 0 [DAQ Reg:0x%x]\n", bus_r(DAQ_REG)));
+ dacVals = defaultDacValue_G0;
break;
- case G1_LOWGAIN:
- LOG(logINFO, ("Set settings - G1_LOWGAIN\n"));
- setPatternBitMask(G1_LOWGAIN_PATSETBIT);
- break;
- case G2_HIGHCAP_HIGHGAIN:
- LOG(logINFO, ("Set settings - G2_HIGHCAP_HIGHGAIN\n"));
- setPatternBitMask(G2_HIGHCAP_HIGHGAIN_PATSETBIT);
- break;
- case G2_HIGHCAP_LOWGAIN:
- LOG(logINFO, ("Set settings - G2_HIGHCAP_LOWGAIN\n"));
- setPatternBitMask(G2_HIGHCAP_LOWGAIN_PATSETBIT);
- break;
- case G2_LOWCAP_HIGHGAIN:
- LOG(logINFO, ("Set settings - G2_LOWCAP_HIGHGAIN\n"));
- setPatternBitMask(G2_LOWCAP_HIGHGAIN_PATSETBIT);
- break;
- case G2_LOWCAP_LOWGAIN:
- LOG(logINFO, ("Set settings - G2_LOWCAP_LOWGAIN\n"));
- setPatternBitMask(G2_LOWCAP_LOWGAIN_PATSETBIT);
- break;
- case G4_HIGHGAIN:
- LOG(logINFO, ("Set settings - G4_HIGHGAIN\n"));
- setPatternBitMask(G4_HIGHGAIN_PATSETBIT);
- break;
- case G4_LOWGAIN:
- LOG(logINFO, ("Set settings - G4_LOWGAIN\n"));
- setPatternBitMask(G4_LOWGAIN_PATSETBIT);
+ case HIGHGAIN0:
+ bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_HIGH_GAIN_MSK);
+ LOG(logINFO,
+ ("Set settings - High Gain 0 [DAQ Reg:0x%x]\n", bus_r(DAQ_REG)));
+ dacVals = defaultDacValue_HG0;
break;
default:
- LOG(logERROR,
- ("This settings is not defined for this detector %d\n", (int)sett));
+ LOG(logERROR, ("This settings %d is not defined\n", (int)sett));
return -1;
}
- setPatternMask(DEFAULT_PATMASK);
+
thisSettings = sett;
+ // set special dacs
+ const int specialDacs[] = SPECIALDACINDEX;
+ for (int i = 0; i < NSPECIALDACS; ++i) {
+ setDAC(specialDacs[i], dacVals[i], 0);
+ }
+
+ // if chipv1.1 and powered on
+ configureChip();
+
return getSettings();
}
enum detectorSettings getSettings() {
+ if (bus_r(DAQ_REG) & DAQ_HIGH_GAIN_MSK)
+ return HIGHGAIN0;
+ return GAIN0;
+}
- uint64_t patmask = getPatternMask();
- if (patmask != DEFAULT_PATMASK) {
- LOG(logERROR,
- ("Patmask is 0x%llx, and not 0x%llx. Undefined Settings!\n",
- patmask, DEFAULT_PATMASK));
- thisSettings = UNDEFINED;
- return thisSettings;
+enum gainMode getGainMode() {
+ uint32_t regval = bus_r(DAQ_REG);
+ uint32_t retval_force = regval & DAQ_FRCE_SWTCH_GAIN_MSK;
+ uint32_t retval_fix = regval & DAQ_FIX_GAIN_MSK;
+ uint32_t retval_cmp_rst = regval & DAQ_CMP_RST_MSK;
+
+ // only one set should be valid
+ if ((retval_force && retval_fix) || (retval_fix && retval_cmp_rst) ||
+ (retval_force && retval_cmp_rst)) {
+ LOG(logERROR, ("undefined gain mode. DAQ reg: 0x%x\n", regval));
}
- uint64_t patsetbit = getPatternBitMask();
- switch (patsetbit) {
- case G1_HIGHGAIN_PATSETBIT:
- thisSettings = G1_HIGHGAIN;
+ // dynamic gain, when nothing is set
+ if (retval_force == 0 && retval_fix == 0 && retval_cmp_rst == 0) {
+ return DYNAMIC;
+ }
+
+ switch (retval_force) {
+ case DAQ_FRCE_GAIN_STG_1_VAL:
+ return FORCE_SWITCH_G1;
+ case DAQ_FRCE_GAIN_STG_2_VAL:
+ return FORCE_SWITCH_G2;
+ default:
break;
- case G1_LOWGAIN_PATSETBIT:
- thisSettings = G1_LOWGAIN;
+ }
+
+ switch (retval_fix) {
+ case DAQ_FIX_GAIN_STG_1_VAL:
+ return FIX_G1;
+ case DAQ_FIX_GAIN_STG_2_VAL:
+ return FIX_G2;
+ default:
break;
- case G2_HIGHCAP_HIGHGAIN_PATSETBIT:
- thisSettings = G2_HIGHCAP_HIGHGAIN;
+ }
+
+ if (retval_cmp_rst) {
+ return FIX_G0;
+ }
+
+ LOG(logERROR, ("This gain mode is undefined [DAQ reg: %d]\n", regval));
+ return -1;
+}
+
+void setGainMode(enum gainMode mode) {
+ uint32_t addr = DAQ_REG;
+ uint32_t value = bus_r(addr);
+
+ switch (mode) {
+ case DYNAMIC:
+ value &= ~(DAQ_GAIN_MODE_MASK);
+ bus_w(addr, value);
+ LOG(logINFO,
+ ("Set gain mode - Dynamic Gain [DAQ Reg:0x%x]\n", bus_r(DAQ_REG)));
break;
- case G2_HIGHCAP_LOWGAIN_PATSETBIT:
- thisSettings = G2_HIGHCAP_LOWGAIN;
+ case FORCE_SWITCH_G1:
+ value &= ~(DAQ_GAIN_MODE_MASK);
+ value |= DAQ_FRCE_GAIN_STG_1_VAL;
+ bus_w(addr, value);
+ LOG(logINFO, ("Set gain mode - Force Switch G1 [DAQ Reg:0x%x]\n",
+ bus_r(DAQ_REG)));
break;
- case G2_LOWCAP_HIGHGAIN_PATSETBIT:
- thisSettings = G2_LOWCAP_HIGHGAIN;
+ case FORCE_SWITCH_G2:
+ value &= ~(DAQ_GAIN_MODE_MASK);
+ value |= DAQ_FRCE_GAIN_STG_2_VAL;
+ bus_w(addr, value);
+ LOG(logINFO, ("Set gain mode - Force Switch G2 [DAQ Reg:0x%x]\n",
+ bus_r(DAQ_REG)));
break;
- case G2_LOWCAP_LOWGAIN_PATSETBIT:
- thisSettings = G2_LOWCAP_LOWGAIN;
+ case FIX_G1:
+ value &= ~(DAQ_GAIN_MODE_MASK);
+ value |= DAQ_FIX_GAIN_STG_1_VAL;
+ bus_w(addr, value);
+ LOG(logINFO,
+ ("Set gain mode - Fix G1 [DAQ Reg:0x%x]\n", bus_r(DAQ_REG)));
break;
- case G4_HIGHGAIN_PATSETBIT:
- thisSettings = G4_HIGHGAIN;
+ case FIX_G2:
+ value &= ~(DAQ_GAIN_MODE_MASK);
+ value |= DAQ_FIX_GAIN_STG_2_VAL;
+ bus_w(addr, value);
+ LOG(logINFO,
+ ("Set gain mode - Fix G2 [DAQ Reg:0x%x]\n", bus_r(DAQ_REG)));
break;
- case G4_LOWGAIN_PATSETBIT:
- thisSettings = G4_LOWGAIN;
+ case FIX_G0:
+ value &= ~(DAQ_GAIN_MODE_MASK);
+ value |= DAQ_CMP_RST_MSK;
+ bus_w(addr, value);
+ LOG(logINFO,
+ ("Set gain mode - Fix G0 [DAQ Reg:0x%x]\n", bus_r(DAQ_REG)));
break;
default:
- LOG(logERROR,
- ("Patsetbit is 0x%llx. Undefined Settings!\n", patsetbit));
- thisSettings = UNDEFINED;
- break;
+ LOG(logERROR, ("This gain mode %d is not defined\n", (int)mode));
}
- return thisSettings;
}
/* parameters - dac, adc, hv */
-
void setDAC(enum DACINDEX ind, int val, int mV) {
- if (val < 0 && val != LTC2620_GetPowerDownValue()) {
+ if (val < 0)
return;
- }
char *dac_names[] = {DAC_NAMES};
- LOG(logINFO, ("Setting DAC %s\n", dac_names[ind]));
- LOG(logDEBUG, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dac_names[ind],
- val, (mV ? "mV" : "dac units")));
int dacval = val;
#ifdef VIRTUAL
LOG(logINFO, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dac_names[ind],
@@ -1113,8 +1212,18 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
dacValues[ind] = dacval;
}
#else
- if (LTC2620_SetDACValue((int)ind, val, mV, &dacval) == OK)
+ LOG(logINFO, ("Setting DAC %s\n", dac_names[ind]));
+ if (LTC2620_SetDACValue((int)ind, val, mV, &dacval) == OK) {
dacValues[ind] = dacval;
+ if (ind == J_VREF_COMP &&
+ (val >= 0)) { // FIXME: if val == pwr down value, write 0?
+ bus_w(EXT_DAQ_CTRL_REG,
+ (bus_r(EXT_DAQ_CTRL_REG) &
+ ~(EXT_DAQ_CTRL_VREF_COMP_MSK)) // reset
+ | ((val << EXT_DAQ_CTRL_VREF_COMP_OFST) &
+ EXT_DAQ_CTRL_VREF_COMP_MSK)); // or it with value
+ }
+ }
#endif
}
@@ -1132,52 +1241,37 @@ int getDAC(enum DACINDEX ind, int mV) {
int getMaxDacSteps() { return LTC2620_GetMaxNumSteps(); }
-int dacToVoltage(int dac) {
- int val;
- LTC2620_DacToVoltage(dac, &val);
- return val;
-}
+int getADC(enum ADCINDEX ind) {
+#ifdef VIRTUAL
+ return 0;
+#endif
+ char tempnames[2][40] = {"VRs/FPGAs Temperature", "ADCs/ASICs Temperature"};
+ LOG(logDEBUG1, ("Getting Temperature for %s\n", tempnames[ind]));
+ u_int32_t addr = GET_TEMPERATURE_TMP112_REG;
+ uint32_t regvalue = bus_r(addr);
+ uint32_t value = regvalue & TEMPERATURE_VALUE_MSK;
+ double retval = value;
-int checkVLimitCompliant(int mV) {
- if (vLimit > 0 && mV > vLimit)
- return FAIL;
- return OK;
-}
-
-int checkVLimitDacCompliant(int dac) {
- if (vLimit > 0) {
- int mv = 0;
- // could not convert
- if (LTC2620_DacToVoltage(dac, &mv) == FAIL)
- return FAIL;
- if (mv > vLimit)
- return FAIL;
+ // negative
+ if (regvalue & TEMPERATURE_POLARITY_MSK) {
+ // 2s complement
+ int ret = (~value) + 1;
+ // attach negative sign
+ ret = 0 - value;
+ retval = ret;
}
- return OK;
-}
-int getVLimit() { return vLimit; }
-
-void setVLimit(int l) {
- if (l >= 0)
- vLimit = l;
+ // conversion
+ retval *= 625.0 / 10.0;
+ LOG(logINFO, ("Temperature %s: %f °C\n", tempnames[ind], retval / 1000.00));
+ return retval;
}
int setHighVoltage(int val) {
// setting hv
if (val >= 0) {
- LOG(logINFO, ("Setting High voltage: %d V\n", val));
- uint32_t addr = POWER_REG;
-
- // switch to external high voltage
- bus_w(addr, bus_r(addr) & (~POWER_HV_INTERNAL_SLCT_MSK));
-
+ LOG(logINFO, ("Setting High voltage: %d V", val));
MAX1932_Set(&val);
-
- // switch on internal high voltage, if set
- if (val > 0)
- bus_w(addr, bus_r(addr) | POWER_HV_INTERNAL_SLCT_MSK);
-
highvoltage = val;
}
return highvoltage;
@@ -1185,6 +1279,55 @@ int setHighVoltage(int val) {
/* parameters - timing, extsig */
+int setMaster(enum MASTERINDEX m) {
+ char *master_names[] = {MASTER_NAMES};
+ LOG(logINFOBLUE, ("Setting up as %s in (%s server)\n", master_names[m],
+ (isControlServer ? "control" : "stop")));
+ int retval = -1;
+ switch (m) {
+ case OW_MASTER:
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_MASTER_MSK);
+ isMaster(&retval);
+ if (retval != 1) {
+ LOG(logERROR, ("Could not set master\n"));
+ return FAIL;
+ }
+ break;
+ case OW_SLAVE:
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_MASTER_MSK);
+ isMaster(&retval);
+ if (retval != 0) {
+ LOG(logERROR, ("Could not set slave\n"));
+ return FAIL;
+ }
+ break;
+ default:
+ LOG(logERROR, ("Cannot reset to hardware settings from client. Restart "
+ "detector server.\n"));
+ return FAIL;
+ }
+ return OK;
+}
+
+int isMaster(int *retval) {
+ *retval =
+ ((bus_r(CONTROL_REG) & CONTROL_MASTER_MSK) >> CONTROL_MASTER_OFST);
+ return OK;
+}
+
+int getSynchronization() {
+ return ((bus_r(EXT_SIGNAL_REG) & EXT_SYNC_MSK) >> EXT_SYNC_OFST);
+}
+
+void setSynchronization(int enable) {
+ LOG(logINFOBLUE,
+ ("%s Synchronization\n", (enable ? "Enabling" : "Disabling")));
+ if (enable)
+ bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SYNC_MSK);
+ else
+ bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SYNC_MSK);
+}
+
void setTiming(enum timingMode arg) {
switch (arg) {
case AUTO_TIMING:
@@ -1207,8 +1350,122 @@ enum timingMode getTiming() {
}
/* configure mac */
+void setNumberofUDPInterfaces(int val) {
+ uint32_t addr = CONFIG_REG;
-int getNumberofUDPInterfaces() { return 1; }
+ // enable 2 interfaces
+ if (val > 1) {
+ LOG(logINFOBLUE, ("Setting #Interfaces: 2\n"));
+ bus_w(addr, bus_r(addr) | CONFIG_OPRTN_MDE_2_X_10GbE_MSK);
+ }
+ // enable only 1 interface
+ else {
+ LOG(logINFOBLUE, ("Setting #Interfaces: 1\n"));
+ bus_w(addr, bus_r(addr) & ~CONFIG_OPRTN_MDE_2_X_10GbE_MSK);
+ }
+ LOG(logDEBUG, ("config reg:0x%x\n", bus_r(addr)));
+}
+
+int getNumberofUDPInterfaces() {
+ LOG(logDEBUG, ("config reg:0x%x\n", bus_r(CONFIG_REG)));
+ // return 2 if enabled, else 1
+ return ((bus_r(CONFIG_REG) & CONFIG_OPRTN_MDE_2_X_10GbE_MSK) ? 2 : 1);
+}
+
+int getNumberofDestinations(int *retval) {
+ *retval = (((bus_r(CONTROL_REG) & CONTROL_RX_ADDTNL_ENDPTS_NUM_MSK) >>
+ CONTROL_RX_ADDTNL_ENDPTS_NUM_OFST) +
+ 1);
+ return OK;
+}
+
+int setNumberofDestinations(int value) {
+ LOG(logINFO, ("Setting number of entries to %d\n", value));
+ --value;
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_RX_ADDTNL_ENDPTS_NUM_MSK);
+ bus_w(CONTROL_REG,
+ bus_r(CONTROL_REG) | ((value << CONTROL_RX_ADDTNL_ENDPTS_NUM_OFST) &
+ CONTROL_RX_ADDTNL_ENDPTS_NUM_MSK));
+ return OK;
+}
+
+int getFirstUDPDestination() {
+ return ((bus_r(CONTROL_REG) & CONTROL_RX_ENDPTS_START_MSK) >>
+ CONTROL_RX_ENDPTS_START_OFST);
+}
+
+void setFirstUDPDestination(int value) {
+ LOG(logINFO, ("Setting first entry to %d\n", value));
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_RX_ENDPTS_START_MSK);
+ bus_w(CONTROL_REG,
+ bus_r(CONTROL_REG) | ((value << CONTROL_RX_ENDPTS_START_OFST) &
+ CONTROL_RX_ENDPTS_START_MSK));
+}
+
+void selectPrimaryInterface(int val) {
+ uint32_t addr = CONFIG_REG;
+
+ // outer (user input: 0)
+ if (val == 0) {
+ LOG(logINFOBLUE, ("Setting Primary Interface: 0 (Outer)\n"));
+ bus_w(addr, bus_r(addr) & ~CONFIG_INNR_PRIMRY_INTRFCE_MSK);
+ }
+ // inner (user input: 1)
+ else {
+ LOG(logINFOBLUE, ("Setting Secondary Interface: 1 (Inner)\n"));
+ bus_w(addr, bus_r(addr) | CONFIG_INNR_PRIMRY_INTRFCE_MSK);
+ }
+}
+
+int getPrimaryInterface() {
+ return ((bus_r(CONFIG_REG) & CONFIG_INNR_PRIMRY_INTRFCE_MSK) ? 1 : 0);
+}
+
+void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip,
+ uint64_t destmac, uint32_t destport, uint64_t sourcemac,
+ uint32_t sourceip, uint32_t sourceport) {
+
+ // start addr
+ uint32_t addr = (type == INNER ? RXR_ENDPOINT_INNER_START_REG
+ : RXR_ENDPOINT_OUTER_START_REG);
+ // calculate rxr endpoint offset
+ addr += (iRxEntry * RXR_ENDPOINT_OFST);
+ // get struct memory
+ udp_header *udp = (udp_header *)(Blackfin_getBaseAddress() + addr / 2);
+ memset(udp, 0, sizeof(udp_header));
+
+ // mac addresses
+ // msb (32) + lsb (16)
+ udp->udp_destmac_msb = ((destmac >> 16) & BIT32_MASK);
+ udp->udp_destmac_lsb = ((destmac >> 0) & BIT16_MASK);
+ // msb (16) + lsb (32)
+ udp->udp_srcmac_msb = ((sourcemac >> 32) & BIT16_MASK);
+ udp->udp_srcmac_lsb = ((sourcemac >> 0) & BIT32_MASK);
+
+ // ip addresses
+ udp->ip_srcip_msb = ((sourceip >> 16) & BIT16_MASK);
+ udp->ip_srcip_lsb = ((sourceip >> 0) & BIT16_MASK);
+ udp->ip_destip_msb = ((destip >> 16) & BIT16_MASK);
+ udp->ip_destip_lsb = ((destip >> 0) & BIT16_MASK);
+
+ // source port
+ udp->udp_srcport = sourceport;
+ udp->udp_destport = destport;
+
+ // other defines
+ udp->udp_ethertype = 0x800;
+ udp->ip_ver = 0x4;
+ udp->ip_ihl = 0x5;
+ udp->ip_flags = 0x2; // FIXME
+ udp->ip_ttl = 0x40;
+ udp->ip_protocol = 0x11;
+ // total length is redefined in firmware
+
+ calcChecksum(udp);
+ if (iRxEntry < numUdpDestinations) {
+ LOG(logINFO, ("\tIP checksum : 0x%lx\n\n", udp->ip_checksum));
+ }
+}
void calcChecksum(udp_header *udp) {
int count = IP_HEADER_SIZE;
@@ -1238,171 +1495,486 @@ void calcChecksum(udp_header *udp) {
sum = (sum & 0xffff) + (sum >> 16); // Fold 32-bit sum to 16 bits
long int checksum = sum & 0xffff;
checksum += UDP_IP_HEADER_LENGTH_BYTES;
- LOG(logINFO, ("\tIP checksum is 0x%lx\n", checksum));
udp->ip_checksum = checksum;
}
int configureMAC() {
- uint32_t srcip = udpDetails[0].srcip;
- uint32_t dstip = udpDetails[0].dstip;
- uint64_t srcmac = udpDetails[0].srcmac;
- uint64_t dstmac = udpDetails[0].dstmac;
- int srcport = udpDetails[0].srcport;
- int dstport = udpDetails[0].dstport;
LOG(logINFOBLUE, ("Configuring MAC\n"));
- char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
- dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
- getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
- getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
- getIpAddressinString(src_ip, srcip);
- getIpAddressinString(dst_ip, dstip);
- LOG(logINFO, ("\tSource IP : %s\n"
- "\tSource MAC : %s\n"
- "\tSource Port : %d\n"
- "\tDest IP : %s\n"
- "\tDest MAC : %s\n"
- "\tDest Port : %d\n",
- src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
+ int numInterfaces = getNumberofUDPInterfaces();
+ int selInterface = getPrimaryInterface();
+ LOG(logINFO, ("\t#Interfaces : %d\n", numInterfaces));
+ LOG(logINFO, ("\tInterface : %d %s\n\n", selInterface,
+ (selInterface ? "Inner" : "Outer")));
- // 1 giga udp
- if (!enableTenGigabitEthernet(-1)) {
- LOG(logINFOBLUE, ("\t1G MAC\n"));
- if (updateDatabytesandAllocateRAM() == FAIL)
- return -1;
- if (setUDPDestinationDetails(0, 0, dst_ip, dstport) == FAIL) {
- LOG(logERROR, ("could not set udp 1G destination IP and port\n"));
+ LOG(logINFO, ("Number of entries: %d\n\n", numUdpDestinations));
+ for (int iRxEntry = 0; iRxEntry != MAX_UDP_DESTINATION; ++iRxEntry) {
+ uint32_t srcip = udpDetails[iRxEntry].srcip;
+ uint32_t srcip2 = udpDetails[iRxEntry].srcip2;
+ uint32_t dstip = udpDetails[iRxEntry].dstip;
+ uint32_t dstip2 = udpDetails[iRxEntry].dstip2;
+ uint64_t srcmac = udpDetails[iRxEntry].srcmac;
+ uint64_t srcmac2 = udpDetails[iRxEntry].srcmac2;
+ uint64_t dstmac = udpDetails[iRxEntry].dstmac;
+ uint64_t dstmac2 = udpDetails[iRxEntry].dstmac2;
+ int srcport = udpDetails[iRxEntry].srcport;
+ int srcport2 = udpDetails[iRxEntry].srcport2;
+ int dstport = udpDetails[iRxEntry].dstport;
+ int dstport2 = udpDetails[iRxEntry].dstport2;
+
+ char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
+ dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
+ getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
+ getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
+ getIpAddressinString(src_ip, srcip);
+ getIpAddressinString(dst_ip, dstip);
+ char src_mac2[MAC_ADDRESS_SIZE], src_ip2[INET_ADDRSTRLEN],
+ dst_mac2[MAC_ADDRESS_SIZE], dst_ip2[INET_ADDRSTRLEN];
+ getMacAddressinString(src_mac2, MAC_ADDRESS_SIZE, srcmac2);
+ getMacAddressinString(dst_mac2, MAC_ADDRESS_SIZE, dstmac2);
+ getIpAddressinString(src_ip2, srcip2);
+ getIpAddressinString(dst_ip2, dstip2);
+
+ if (iRxEntry < numUdpDestinations) {
+ LOG(logINFOBLUE, ("\tEntry %d\n", iRxEntry));
+
+ LOG(logINFO,
+ ("\tOuter %s\n", (numInterfaces == 2)
+ ? "(Bottom)"
+ : (selInterface ? "Not Used" : "Used")));
+ LOG(logINFO, ("\tSource IP : %s\n"
+ "\tSource MAC : %s\n"
+ "\tSource Port : %d\n"
+ "\tDest IP : %s\n"
+ "\tDest MAC : %s\n"
+ "\tDest Port : %d\n\n",
+ src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
+
+ LOG(logINFO,
+ ("\tInner %s\n", (numInterfaces == 2)
+ ? "(Top)"
+ : (selInterface ? "Used" : "Not Used")));
+ LOG(logINFO,
+ ("\tSource IP2 : %s\n"
+ "\tSource MAC2 : %s\n"
+ "\tSource Port2: %d\n"
+ "\tDest IP2 : %s\n"
+ "\tDest MAC2 : %s\n"
+ "\tDest Port2 : %d\n\n",
+ src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2));
+ }
+#ifdef VIRTUAL
+ if (setUDPDestinationDetails(iRxEntry, 0, dst_ip, dstport) == FAIL) {
+ LOG(logERROR, ("could not set udp destination IP and port for "
+ "interface 1 [entry:%d] \n",
+ iRxEntry));
return FAIL;
}
- return OK;
+ if (numInterfaces == 2 &&
+ setUDPDestinationDetails(iRxEntry, 1, dst_ip2, dstport2) == FAIL) {
+ LOG(logERROR, ("could not set udp destination IP and port for "
+ "interface 2 [entry:%d]\n",
+ iRxEntry));
+ return FAIL;
+ }
+#endif
+ if (numInterfaces == 2) {
+ // bottom
+ setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, srcip,
+ srcport);
+ // top
+ setupHeader(iRxEntry, INNER, dstip2, dstmac2, dstport2, srcmac2,
+ srcip2, srcport2);
+ }
+ // single interface
+ else {
+ // default
+ if (selInterface == 0) {
+ setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac,
+ srcip, srcport);
+ } else {
+ setupHeader(iRxEntry, INNER, dstip, dstmac, dstport, srcmac,
+ srcip, srcport2);
+ }
+ }
}
+ setNumberofUDPInterfaces(numInterfaces);
+ selectPrimaryInterface(selInterface);
- // 10 G
- LOG(logINFOBLUE, ("\t10G MAC\n"));
-
- // start addr
- uint32_t addr = RXR_ENDPOINT_START_REG;
- // get struct memory
- udp_header *udp = (udp_header *)(Blackfin_getBaseAddress() + addr / 2);
- memset(udp, 0, sizeof(udp_header));
-
- // mac addresses
- // msb (32) + lsb (16)
- udp->udp_destmac_msb = ((dstmac >> 16) & BIT32_MASK);
- udp->udp_destmac_lsb = ((dstmac >> 0) & BIT16_MASK);
- // msb (16) + lsb (32)
- udp->udp_srcmac_msb = ((srcmac >> 32) & BIT16_MASK);
- udp->udp_srcmac_lsb = ((srcmac >> 0) & BIT32_MASK);
-
- // ip addresses
- udp->ip_srcip_msb = ((srcip >> 16) & BIT16_MASK);
- udp->ip_srcip_lsb = ((srcip >> 0) & BIT16_MASK);
- udp->ip_destip_msb = ((dstip >> 16) & BIT16_MASK);
- udp->ip_destip_lsb = ((dstip >> 0) & BIT16_MASK);
-
- // source port
- udp->udp_srcport = srcport;
- udp->udp_destport = dstport;
-
- // other defines
- udp->udp_ethertype = 0x800;
- udp->ip_ver = 0x4;
- udp->ip_ihl = 0x5;
- udp->ip_flags = 0x2; // FIXME
- udp->ip_ttl = 0x40;
- udp->ip_protocol = 0x11;
- // total length is redefined in firmware
-
- calcChecksum(udp);
-
- cleanFifos(); // FIXME: resetPerpheral() for ctb?
- resetPeripheral();
- LOG(logINFO, ("Waiting for %d s for mac to be up\n",
- WAIT_TIME_CONFIGURE_MAC / (1000 * 1000)));
- usleep(WAIT_TIME_CONFIGURE_MAC); // todo maybe without
-
+ cleanFifos();
+ resetCore();
+ alignDeserializer();
return OK;
}
int setDetectorPosition(int pos[]) {
- memcpy(detPos, pos, sizeof(detPos));
- return OK;
+ int ret = OK;
+ // row, col
+ uint32_t innerPos[2] = {pos[X], pos[Y]};
+ uint32_t outerPos[2] = {pos[X], pos[Y]};
+ int selInterface = getPrimaryInterface();
+
+ if (getNumberofUDPInterfaces() == 1) {
+ LOG(logDEBUG,
+ ("Setting detector position: 1 Interface %s \n(%d, %d)\n",
+ (selInterface ? "Inner" : "Outer"), innerPos[X], innerPos[Y]));
+ } else {
+ // top has row incremented by 1
+ ++innerPos[Y];
+ LOG(logDEBUG, ("Setting detector position: 2 Interfaces \n"
+ " inner top(%d, %d), outer bottom(%d, %d)\n",
+ innerPos[X], innerPos[Y], outerPos[X], outerPos[Y]));
+ }
+ detPos[0] = innerPos[X];
+ detPos[1] = innerPos[Y];
+ detPos[2] = outerPos[X];
+ detPos[3] = outerPos[Y];
+
+ // row
+ // outer
+ uint32_t addr = COORD_ROW_REG;
+ bus_w(addr,
+ (bus_r(addr) & ~COORD_ROW_OUTER_MSK) |
+ ((outerPos[X] << COORD_ROW_OUTER_OFST) & COORD_ROW_OUTER_MSK));
+ if (((bus_r(addr) & COORD_ROW_OUTER_MSK) >> COORD_ROW_OUTER_OFST) !=
+ outerPos[X])
+ ret = FAIL;
+ // inner
+ bus_w(addr,
+ (bus_r(addr) & ~COORD_ROW_INNER_MSK) |
+ ((innerPos[X] << COORD_ROW_INNER_OFST) & COORD_ROW_INNER_MSK));
+ if (((bus_r(addr) & COORD_ROW_INNER_MSK) >> COORD_ROW_INNER_OFST) !=
+ innerPos[X])
+ ret = FAIL;
+
+ // col
+ // outer
+ addr = COORD_COL_REG;
+ bus_w(addr,
+ (bus_r(addr) & ~COORD_COL_OUTER_MSK) |
+ ((outerPos[Y] << COORD_COL_OUTER_OFST) & COORD_COL_OUTER_MSK));
+ if (((bus_r(addr) & COORD_COL_OUTER_MSK) >> COORD_COL_OUTER_OFST) !=
+ outerPos[Y])
+ ret = FAIL;
+ // inner
+ bus_w(addr,
+ (bus_r(addr) & ~COORD_COL_INNER_MSK) |
+ ((innerPos[Y] << COORD_COL_INNER_OFST) & COORD_COL_INNER_MSK));
+ if (((bus_r(addr) & COORD_COL_INNER_MSK) >> COORD_COL_INNER_OFST) !=
+ innerPos[Y])
+ ret = FAIL;
+
+ if (ret == OK) {
+ if (getNumberofUDPInterfaces() == 1) {
+ LOG(logINFOBLUE, ("Position set to [%d, %d] #(col, row)\n",
+ innerPos[X], innerPos[Y]));
+ } else {
+ LOG(logINFOBLUE, (" Inner (top) position set to [%d, %d]\n",
+ innerPos[X], innerPos[Y]));
+ LOG(logINFOBLUE, (" Outer (bottom) position set to [%d, %d]\n",
+ outerPos[X], outerPos[Y]));
+ }
+ }
+ return ret;
}
int *getDetectorPosition() { return detPos; }
-int enableTenGigabitEthernet(int val) {
- uint32_t addr = CONFIG_REG;
+/* moench specific - powerchip, autocompdisable, asictimer, clockdiv, pll,
+ * flashing fpga */
- // set
- if (val != -1) {
- LOG(logINFO, ("Setting 10Gbe: %d\n", (val > 0) ? 1 : 0));
- if (val > 0) {
- bus_w(addr, bus_r(addr) | CONFIG_GB10_SND_UDP_MSK);
- } else {
- bus_w(addr, bus_r(addr) & (~CONFIG_GB10_SND_UDP_MSK));
- }
- // configuremac called from client
+int setReadNRows(int value) {
+ if (value < 0 || (value % READ_N_ROWS_MULTIPLE != 0)) {
+ LOG(logERROR, ("Invalid number of rows %d\n", value));
+ return FAIL;
}
- return ((bus_r(addr) & CONFIG_GB10_SND_UDP_MSK) >>
- CONFIG_GB10_SND_UDP_OFST);
+ if (isHardwareVersion_1_0()) {
+ LOG(logERROR, ("Could not set number of rows. Only available for "
+ "Hardware Board version v2.0.\n"));
+ return FAIL;
+ }
+
+ // regval is numpackets
+ int regval = (value / READ_N_ROWS_MULTIPLE);
+ uint32_t addr = READ_N_ROWS_REG;
+ LOG(logINFO, ("Setting number of rows: %d (regval:%d)\n", value, regval));
+ bus_w(addr, bus_r(addr) & ~READ_N_ROWS_NUM_ROWS_MSK);
+ bus_w(addr, bus_r(addr) | ((regval << READ_N_ROWS_NUM_ROWS_OFST) &
+ READ_N_ROWS_NUM_ROWS_MSK));
+ if (value == MAX_ROWS_PER_READOUT) {
+ LOG(logINFO, ("Disabling Partial Readout (#rows)\n"));
+ bus_w(addr, bus_r(addr) & ~READ_N_ROWS_ENBL_MSK);
+ } else {
+ LOG(logINFO, ("Enabling Partial Readout (#rows)\n"));
+ bus_w(addr, bus_r(addr) | READ_N_ROWS_ENBL_MSK);
+ }
+ return OK;
+}
+
+int getReadNRows() {
+ // cannot set it in old board
+ if (isHardwareVersion_1_0()) {
+ return MAX_ROWS_PER_READOUT;
+ }
+ int enable = (bus_r(READ_N_ROWS_REG) & READ_N_ROWS_ENBL_MSK);
+ int regval = ((bus_r(READ_N_ROWS_REG) & READ_N_ROWS_NUM_ROWS_MSK) >>
+ READ_N_ROWS_NUM_ROWS_OFST);
+
+ int maxRegval = (MAX_ROWS_PER_READOUT / READ_N_ROWS_MULTIPLE);
+ if ((regval == maxRegval && enable) || (regval != maxRegval && !enable)) {
+ return -1;
+ }
+
+ return (regval * READ_N_ROWS_MULTIPLE);
+}
+
+void initReadoutConfiguration() {
+
+ LOG(logINFO, ("Initializing Readout Configuration:\n"
+ "\t Reset readout Timer\n"
+ "\t 1 x 10G mode\n"
+ "\t outer interface is primary\n"
+ "\t half speed\n"
+ "\t TDMA disabled, 0 as TDMA slot\n"
+ "\t Ethernet overflow disabled\n"
+ "\t Reset Round robin entries\n"));
+
+ uint32_t val = 0;
+ // reset readouttimer
+ val &= ~CONFIG_RDT_TMR_MSK;
+ // 1 x 10G mode
+ val &= ~CONFIG_OPRTN_MDE_2_X_10GbE_MSK;
+ // outer interface
+ val &= ~CONFIG_INNR_PRIMRY_INTRFCE_MSK;
+ // half speed
+ val &= ~CONFIG_READOUT_SPEED_MSK;
+ val |= CONFIG_HALF_SPEED_20MHZ_VAL;
+ // tdma disable
+ val &= ~CONFIG_TDMA_ENABLE_MSK;
+ // tdma slot 0
+ val &= ~CONFIG_TDMA_TIMESLOT_MSK;
+ // no ethernet overflow
+ val &= ~CONFIG_ETHRNT_FLW_CNTRL_MSK;
+ bus_w(CONFIG_REG, val);
+
+ val = bus_r(CONTROL_REG);
+ // reset (addtional round robin entry) rx endpoints num
+ val &= CONTROL_RX_ADDTNL_ENDPTS_NUM_MSK;
+ // reset start of round robin entry to 0
+ val &= CONTROL_RX_ENDPTS_START_MSK;
+ bus_w(CONTROL_REG, val);
}
-/* moench specific - powerchip, configure frequency, phase, pll*/
int powerChip(int on) {
- uint32_t addr = POWER_REG;
- if (on > 0) {
- LOG(logINFOBLUE, ("Powering on chip\n"));
- bus_w(addr, bus_r(addr) | POWER_CHIP_MSK);
- } else if (on == 0) {
- LOG(logINFOBLUE, ("Powering off chip\n"));
- bus_w(addr, bus_r(addr) & ~POWER_CHIP_MSK);
+ if (on != -1) {
+ if (on) {
+ LOG(logINFOBLUE, ("Powering chip: on\n"));
+ bus_w(CHIP_POWER_REG,
+ bus_r(CHIP_POWER_REG) | CHIP_POWER_ENABLE_MSK);
+
+ configureChip();
+ } else {
+ LOG(logINFOBLUE, ("Powering chip: off\n"));
+ bus_w(CHIP_POWER_REG,
+ bus_r(CHIP_POWER_REG) & ~CHIP_POWER_ENABLE_MSK);
+
+ chipConfigured = 0;
+ }
}
- return ((bus_r(addr) & POWER_CHIP_MSK) >> POWER_CHIP_OFST);
+#ifdef VIRTUAL
+ return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_ENABLE_MSK) >>
+ CHIP_POWER_ENABLE_OFST);
+#endif
+ return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_STATUS_MSK) >>
+ CHIP_POWER_STATUS_OFST);
}
-/* parameters - readout */
+int isChipConfigured() { return chipConfigured; }
-int setAnalogOnlyReadout() {
- LOG(logINFOBLUE, ("Setting Number of Digital samples to 0\n"));
+void configureChip() {
+ // only for chipv1.1 and chip is powered on
+ if (getChipVersion() == 11 && powerChip(-1)) {
+ LOG(logINFOBLUE, ("\tConfiguring chip\n"));
- // digital num samples = 0
- bus_w(SAMPLES_REG, bus_r(SAMPLES_REG) & ~SAMPLES_DIGITAL_MSK);
+ // waiting 500 ms before configuring selection
+ usleep(500 * 1000);
- LOG(logINFOBLUE, ("Setting Analog Only Readout\n"));
- // analog only readout
- uint32_t addr = CONFIG_REG;
- uint32_t addr_readout_10g = READOUT_10G_ENABLE_REG;
- // default: analog only
- bus_w(addr, bus_r(addr) & (~CONFIG_DSBL_ANLG_OTPT_MSK) &
- (~CONFIG_ENBLE_DGTL_OTPT_MSK));
- bus_w(addr_readout_10g, bus_r(addr_readout_10g) &
- (~READOUT_10G_ENABLE_ANLG_MSK) &
- ~(READOUT_10G_ENABLE_DGTL_MSK));
- bus_w(addr_readout_10g,
- bus_r(addr_readout_10g) |
- ((adcEnableMask_10g << READOUT_10G_ENABLE_ANLG_OFST) &
- READOUT_10G_ENABLE_ANLG_MSK));
+ // write same values to configure selection
+ // if (chip was powered off earlier)
+ LOG(logINFO, ("\tRewriting values for selection\n"))
+ bus_w(CRRNT_SRC_COL_LSB_REG, bus_r(CRRNT_SRC_COL_LSB_REG));
+ bus_w(CRRNT_SRC_COL_MSB_REG, bus_r(CRRNT_SRC_COL_MSB_REG));
- // 1Gb
- if (!enableTenGigabitEthernet(-1)) {
- if (updateDatabytesandAllocateRAM() == FAIL) {
- return FAIL;
+ // waiting 500 ms before configuring chip
+ usleep(500 * 1000);
+
+ // write same register values back to configure chip
+ bus_w(CONFIG_V11_REG, bus_r(CONFIG_V11_REG));
+
+ LOG(logINFOBLUE, ("\tChip configured\n"));
+ chipConfigured = 1;
+ }
+}
+
+int autoCompDisable(int on) {
+ if (on != -1) {
+ if (on) {
+ LOG(logINFO, ("Auto comp disable mode: on\n"));
+ bus_w(EXT_DAQ_CTRL_REG,
+ bus_r(EXT_DAQ_CTRL_REG) | EXT_DAQ_CTRL_CMP_LGC_ENBL_MSK);
+ } else {
+ LOG(logINFO, ("Auto comp disable mode: off\n"));
+ bus_w(EXT_DAQ_CTRL_REG,
+ bus_r(EXT_DAQ_CTRL_REG) & ~EXT_DAQ_CTRL_CMP_LGC_ENBL_MSK);
}
}
- // 10Gb
- else {
- // validate adcenablemask for 10g
- if (adcEnableMask_10g !=
- ((bus_r(READOUT_10G_ENABLE_REG) & READOUT_10G_ENABLE_ANLG_MSK) >>
- READOUT_10G_ENABLE_ANLG_OFST)) {
- LOG(logERROR, ("Setting readout mode failed. Could not set 10g adc "
- "enable mask to 0x%x\n.",
- adcEnableMask_10g));
+ return ((bus_r(EXT_DAQ_CTRL_REG) & EXT_DAQ_CTRL_CMP_LGC_ENBL_MSK) >>
+ EXT_DAQ_CTRL_CMP_LGC_ENBL_OFST);
+}
+
+int setComparatorDisableTime(int64_t val) {
+ if (getChipVersion() != 11) {
+ return FAIL;
+ }
+ if (val < 0) {
+ LOG(logERROR,
+ ("Invalid comp disable time: %lld ns\n", (long long int)val));
+ return FAIL;
+ }
+ LOG(logINFO, ("Setting comp disable time %lld ns\n", (long long int)val));
+ val *= (1E-3 * CLK_RUN);
+ bus_w(COMP_DSBLE_TIME_REG, val);
+
+ // validate for tolerance
+ int64_t retval = getComparatorDisableTime();
+ val /= (1E-3 * CLK_RUN);
+ if (val != retval) {
+ return FAIL;
+ }
+ return OK;
+}
+
+int64_t getComparatorDisableTime() {
+ return bus_r(COMP_DSBLE_TIME_REG) / (1E-3 * CLK_RUN);
+}
+
+int setReadoutSpeed(int val) {
+ // stop state machine if running
+ if (runBusy()) {
+ stopStateMachine();
+ }
+
+ uint32_t adcOfst = 0;
+ uint32_t sampleAdcSpeed = 0;
+ uint32_t adcPhase = 0;
+ uint32_t dbitPhase = 0;
+ uint32_t config = CONFIG_FULL_SPEED_40MHZ_VAL;
+
+ switch (val) {
+
+ case FULL_SPEED:
+ if (isHardwareVersion_1_0()) {
+ LOG(logERROR, ("Cannot set full speed. Should not be here\n"));
return FAIL;
}
+ LOG(logINFO, ("Setting Full Speed (40 MHz):\n"));
+ if (getChipVersion() == 10) {
+ sampleAdcSpeed = SAMPLE_ADC_FULL_SPEED_CHIP10;
+ adcPhase = ADC_PHASE_FULL_SPEED_CHIP10;
+ dbitPhase = DBIT_PHASE_FULL_SPEED_CHIP10;
+ adcOfst = ADC_OFST_FULL_SPEED_VAL_CHIP10;
+ } else {
+ sampleAdcSpeed = SAMPLE_ADC_FULL_SPEED_CHIP11;
+ adcPhase = ADC_PHASE_FULL_SPEED_CHIP11;
+ dbitPhase = DBIT_PHASE_FULL_SPEED_CHIP11;
+ adcOfst = ADC_OFST_FULL_SPEED_VAL_CHIP11;
+ }
+ config = CONFIG_FULL_SPEED_40MHZ_VAL;
+ break;
+
+ case HALF_SPEED:
+ LOG(logINFO, ("Setting Half Speed (20 MHz):\n"));
+ if (isHardwareVersion_1_0()) {
+ adcOfst = ADC_OFST_HALF_SPEED_BOARD2_VAL;
+ sampleAdcSpeed = SAMPLE_ADC_HALF_SPEED_BOARD2;
+ adcPhase = ADC_PHASE_HALF_SPEED_BOARD2;
+ dbitPhase = DBIT_PHASE_HALF_SPEED_BOARD2;
+ } else if (getChipVersion() == 10) {
+ adcOfst = ADC_OFST_HALF_SPEED_VAL_CHIP10;
+ sampleAdcSpeed = SAMPLE_ADC_HALF_SPEED_CHIP10;
+ adcPhase = ADC_PHASE_HALF_SPEED_CHIP10;
+ dbitPhase = DBIT_PHASE_HALF_SPEED_CHIP10;
+ } else {
+ adcOfst = ADC_OFST_HALF_SPEED_VAL_CHIP11;
+ sampleAdcSpeed = SAMPLE_ADC_HALF_SPEED_CHIP11;
+ adcPhase = ADC_PHASE_HALF_SPEED_CHIP11;
+ dbitPhase = DBIT_PHASE_HALF_SPEED_CHIP11;
+ }
+ config = CONFIG_HALF_SPEED_20MHZ_VAL;
+ break;
+
+ case QUARTER_SPEED:
+ LOG(logINFO, ("Setting Half Speed (10 MHz):\n"));
+ if (isHardwareVersion_1_0()) {
+ adcOfst = ADC_OFST_QUARTER_SPEED_BOARD2_VAL;
+ sampleAdcSpeed = SAMPLE_ADC_QUARTER_SPEED_BOARD2;
+ adcPhase = ADC_PHASE_QUARTER_SPEED_BOARD2;
+ dbitPhase = DBIT_PHASE_QUARTER_SPEED_BOARD2;
+ } else if (getChipVersion() == 10) {
+ adcOfst = ADC_OFST_QUARTER_SPEED_VAL_CHIP10;
+ sampleAdcSpeed = SAMPLE_ADC_QUARTER_SPEED_CHIP10;
+ adcPhase = ADC_PHASE_QUARTER_SPEED_CHIP10;
+ dbitPhase = DBIT_PHASE_QUARTER_SPEED_CHIP10;
+ } else {
+ adcOfst = ADC_OFST_QUARTER_SPEED_VAL_CHIP11;
+ sampleAdcSpeed = SAMPLE_ADC_QUARTER_SPEED_CHIP11;
+ adcPhase = ADC_PHASE_QUARTER_SPEED_CHIP11;
+ dbitPhase = DBIT_PHASE_QUARTER_SPEED_CHIP11;
+ }
+ config = CONFIG_QUARTER_SPEED_10MHZ_VAL;
+ break;
+
+ default:
+ LOG(logERROR, ("Unknown speed val %d\n", val));
+ return FAIL;
+ }
+
+ bus_w(CONFIG_REG, (bus_r(CONFIG_REG) & ~CONFIG_READOUT_SPEED_MSK) | config);
+ LOG(logINFO, ("\tSet Config Reg to 0x%x\n", bus_r(CONFIG_REG)));
+
+ bus_w(ADC_OFST_REG, adcOfst);
+ LOG(logINFO, ("\tSet ADC Ofst Reg to 0x%x\n", bus_r(ADC_OFST_REG)));
+
+ bus_w(SAMPLE_REG, sampleAdcSpeed);
+ LOG(logINFO, ("\tSet Sample Reg to 0x%x\n", bus_r(SAMPLE_REG)));
+
+ setPhase(ADC_CLK, adcPhase, 0);
+ LOG(logINFO, ("\tSet ADC Phase Reg to %d\n", adcPhase));
+
+ setPhase(DBIT_CLK, dbitPhase, 0);
+ LOG(logINFO, ("\tSet DBIT Phase Reg to %d\n", dbitPhase));
+
+ return OK;
+}
+
+int getReadoutSpeed(int *retval) {
+ u_int32_t speed = bus_r(CONFIG_REG) & CONFIG_READOUT_SPEED_MSK;
+ switch (speed) {
+ case CONFIG_FULL_SPEED_40MHZ_VAL:
+ *retval = FULL_SPEED;
+ break;
+ case CONFIG_HALF_SPEED_20MHZ_VAL:
+ *retval = HALF_SPEED;
+ break;
+ case CONFIG_QUARTER_SPEED_10MHZ_VAL:
+ *retval = QUARTER_SPEED;
+ break;
+ default:
+ LOG(logERROR, ("Unknown speed val: %d\n", speed));
+ *retval = -1;
+ return FAIL;
}
return OK;
}
@@ -1415,15 +1987,16 @@ int setPhase(enum CLKINDEX ind, int val, int degrees) {
char *clock_names[] = {CLK_NAMES};
LOG(logINFO, ("Setting %s clock (%d) phase to %d %s\n", clock_names[ind],
ind, val, degrees == 0 ? "" : "degrees"));
- int maxShift = getMaxPhase(ind);
+ int maxShift = MAX_PHASE_SHIFTS;
// validation
if (degrees && (val < 0 || val > 359)) {
- LOG(logERROR, ("\tPhase outside limits (0 - 359°C)\n"));
+ LOG(logERROR, ("\tPhase provided outside limits (0 - 359°C)\n"));
return FAIL;
}
- if (!degrees && (val < 0 || val > maxShift - 1)) {
+ if (!degrees && (val < 0 || val > MAX_PHASE_SHIFTS - 1)) {
LOG(logERROR,
- ("\tPhase outside limits (0 - %d phase shifts)\n", maxShift - 1));
+ ("\tPhase provided outside limits (0 - %d phase shifts)\n",
+ maxShift - 1));
return FAIL;
}
@@ -1440,7 +2013,7 @@ int setPhase(enum CLKINDEX ind, int val, int degrees) {
// same phase
if (!relativePhase) {
- LOG(logINFO, ("\tNothing to do in Phase Shift\n"));
+ LOG(logINFO, ("Nothing to do in Phase Shift\n"));
return OK;
}
LOG(logINFOBLUE, ("Configuring Phase\n"));
@@ -1454,9 +2027,12 @@ int setPhase(enum CLKINDEX ind, int val, int degrees) {
LOG(logDEBUG1, ("[Single Direction] Phase:%d (0x%x). Max Phase shifts:%d\n",
phase, phase, maxShift));
- ALTERA_PLL_SetPhaseShift(phase, (int)ind, 0);
+ ALTERA_PLL_SetPhaseShift(
+ phase, (ind == ADC_CLK ? ADC_CLK_INDEX : DBIT_CLK_INDEX), 0);
clkPhase[ind] = valShift;
+
+ alignDeserializer();
return OK;
}
@@ -1469,7 +2045,7 @@ int getPhase(enum CLKINDEX ind, int degrees) {
return clkPhase[ind];
// convert back to degrees
int val = 0;
- ConvertToDifferentRange(0, getMaxPhase(ind) - 1, 0, 359, clkPhase[ind],
+ ConvertToDifferentRange(0, MAX_PHASE_SHIFTS - 1, 0, 359, clkPhase[ind],
&val);
return val;
}
@@ -1479,15 +2055,7 @@ int getMaxPhase(enum CLKINDEX ind) {
LOG(logERROR, ("Unknown clock index %d to get max phase\n", ind));
return -1;
}
- int ret = ((double)PLL_VCO_FREQ_MHZ / (double)clkFrequency[ind]) *
- MAX_PHASE_SHIFTS_STEPS;
-
- char *clock_names[] = {CLK_NAMES};
- LOG(logDEBUG1,
- ("Max Phase Shift (%s): %d (Clock: %d MHz, VCO:%d MHz)\n",
- clock_names[ind], ret, clkFrequency[ind], PLL_VCO_FREQ_MHZ));
-
- return ret;
+ return MAX_PHASE_SHIFTS;
}
int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval) {
@@ -1499,8 +2067,8 @@ int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval) {
if (val == -1) {
return OK;
}
- LOG(logDEBUG1, ("validating phase in degrees for clk %d\n", ind));
- int maxShift = getMaxPhase(ind);
+ LOG(logDEBUG1, ("validating phase in degrees\n"));
+ int maxShift = MAX_PHASE_SHIFTS;
// convert degrees to shift
int valShift = 0;
ConvertToDifferentRange(0, 359, 0, maxShift - 1, val, &valShift);
@@ -1512,132 +2080,358 @@ int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval) {
return FAIL;
}
-int setFrequency(enum CLKINDEX ind, int val) {
- if (ind < 0 || ind >= NUM_CLOCKS) {
- LOG(logERROR, ("Unknown clock index %d to set frequency\n", ind));
- return FAIL;
- }
- if (val <= 0) {
- return FAIL;
- }
- char *clock_names[] = {CLK_NAMES};
- LOG(logINFOBLUE, ("Setting %s clock (%d) frequency to %d MHz\n",
- clock_names[ind], ind, val));
+int setThresholdTemperature(int val) {
- // check adc clk too high
- if (ind == ADC_CLK && val > MAXIMUM_ADC_CLK) {
- LOG(logERROR, ("Frequency %d MHz too high for ADC\n", val));
- return FAIL;
+ if (val >= 0) {
+ LOG(logINFO, ("Setting Threshold Temperature: %f °C\n", val / 1000.00));
+ val *= (10.0 / 625.0);
+ LOG(logDEBUG1, ("Converted Threshold Temperature: %d\n", val));
+ bus_w(TEMP_CTRL_REG,
+ (bus_r(TEMP_CTRL_REG) & ~(TEMP_CTRL_PROTCT_THRSHLD_MSK) &
+ ~(TEMP_CTRL_OVR_TMP_EVNT_MSK)) |
+ (((val << TEMP_CTRL_PROTCT_THRSHLD_OFST) &
+ TEMP_CTRL_PROTCT_THRSHLD_MSK)));
+ LOG(logDEBUG1,
+ ("Converted Threshold Temperature set to %d\n",
+ ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_THRSHLD_MSK) >>
+ TEMP_CTRL_PROTCT_THRSHLD_OFST)));
+ }
+ uint32_t temp = ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_THRSHLD_MSK) >>
+ TEMP_CTRL_PROTCT_THRSHLD_OFST);
+
+ // conversion
+ temp = (temp * (625.0 / 10.0));
+
+ double ftemp = (double)temp / 1000.00;
+ LOG(logDEBUG1, ("Threshold Temperature read %f °C\n", ftemp));
+
+ return temp;
+}
+
+int setTemperatureControl(int val) {
+ if (val >= 0) {
+ // binary value
+ if (val > 0)
+ val = 1;
+ LOG(logINFO, ("Setting Temperature control: %d\n", val));
+ bus_w(TEMP_CTRL_REG,
+ (bus_r(TEMP_CTRL_REG) & ~(TEMP_CTRL_PROTCT_ENABLE_MSK) &
+ ~(TEMP_CTRL_OVR_TMP_EVNT_MSK)) |
+ (((val << TEMP_CTRL_PROTCT_ENABLE_OFST) &
+ TEMP_CTRL_PROTCT_ENABLE_MSK)));
+ LOG(logDEBUG1, ("Temperature control read: %d\n",
+ ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_ENABLE_MSK) >>
+ TEMP_CTRL_PROTCT_ENABLE_OFST)));
+ }
+ return ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_PROTCT_ENABLE_MSK) >>
+ TEMP_CTRL_PROTCT_ENABLE_OFST);
+}
+
+int setTemperatureEvent(int val) {
+#ifdef VIRTUAL
+ return 0;
+#endif
+ if (val >= 0) {
+ // set bit to clear it
+ val = 1;
+ LOG(logINFO, ("Setting Temperature Event (clearing): %d\n", val));
+ bus_w(TEMP_CTRL_REG,
+ (bus_r(TEMP_CTRL_REG) & ~TEMP_CTRL_OVR_TMP_EVNT_MSK) |
+ (((val << TEMP_CTRL_OVR_TMP_EVNT_OFST) &
+ TEMP_CTRL_OVR_TMP_EVNT_MSK)));
+ LOG(logDEBUG1, ("Temperature Event read %d\n",
+ ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_OVR_TMP_EVNT_MSK) >>
+ TEMP_CTRL_OVR_TMP_EVNT_OFST)));
+ }
+ return ((bus_r(TEMP_CTRL_REG) & TEMP_CTRL_OVR_TMP_EVNT_MSK) >>
+ TEMP_CTRL_OVR_TMP_EVNT_OFST);
+}
+
+void alignDeserializer() {
+ // refresh alignment
+ bus_w(ADC_DSRLZR_0_REG,
+ bus_r(ADC_DSRLZR_0_REG) | ADC_DSRLZR_0_RFRSH_ALGNMNT_MSK);
+ bus_w(ADC_DSRLZR_1_REG,
+ bus_r(ADC_DSRLZR_1_REG) | ADC_DSRLZR_1_RFRSH_ALGNMNT_MSK);
+ bus_w(ADC_DSRLZR_2_REG,
+ bus_r(ADC_DSRLZR_2_REG) | ADC_DSRLZR_2_RFRSH_ALGNMNT_MSK);
+ bus_w(ADC_DSRLZR_3_REG,
+ bus_r(ADC_DSRLZR_3_REG) | ADC_DSRLZR_3_RFRSH_ALGNMNT_MSK);
+
+ usleep(1 * 1000 * 1000);
+
+ // disable the refresh
+ bus_w(ADC_DSRLZR_0_REG,
+ bus_r(ADC_DSRLZR_0_REG) & (~(ADC_DSRLZR_0_RFRSH_ALGNMNT_MSK)));
+ bus_w(ADC_DSRLZR_1_REG,
+ bus_r(ADC_DSRLZR_1_REG) & (~(ADC_DSRLZR_1_RFRSH_ALGNMNT_MSK)));
+ bus_w(ADC_DSRLZR_2_REG,
+ bus_r(ADC_DSRLZR_2_REG) & (~(ADC_DSRLZR_2_RFRSH_ALGNMNT_MSK)));
+ bus_w(ADC_DSRLZR_3_REG,
+ bus_r(ADC_DSRLZR_3_REG) & (~(ADC_DSRLZR_3_RFRSH_ALGNMNT_MSK)));
+}
+
+int getFlipRows() {
+ return ((bus_r(CONFIG_REG) & CONFIG_BOTTOM_INVERT_STREAM_MSK) >>
+ CONFIG_BOTTOM_INVERT_STREAM_OFST);
+}
+
+void setFlipRows(int arg) {
+ if (isHardwareVersion_1_0()) {
+ LOG(logERROR, ("Could not set flip rows. Only available for "
+ "Hardware Board version 2.0.\n"));
+ return;
+ }
+ if (arg >= 0) {
+ if (arg == 0) {
+ LOG(logINFO, ("Switching off bottom row flipping\n"));
+ bus_w(CONFIG_REG,
+ bus_r(CONFIG_REG) & ~CONFIG_BOTTOM_INVERT_STREAM_MSK);
+ } else {
+ LOG(logINFO, ("Switching on bottom row flipping\n"));
+ bus_w(CONFIG_REG,
+ bus_r(CONFIG_REG) | CONFIG_BOTTOM_INVERT_STREAM_MSK);
+ }
+ }
+}
+
+int getFilterResistor() {
+#ifdef VIRTUAL
+ uint32_t addr = CONFIG_V11_REG;
+#else
+ uint32_t addr = CONFIG_V11_STATUS_REG;
+#endif
+ // return 0 for lower value, 1 for higher value
+ if (bus_r(addr) & CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_MSK) {
+ return 0;
+ }
+ return 1;
+}
+
+int setFilterResistor(int value) {
+ // lower resistor
+ if (value == 0) {
+ LOG(logINFO, ("Setting Lower Filter Resistor\n"));
+ bus_w(CONFIG_V11_REG,
+ bus_r(CONFIG_V11_REG) | CONFIG_V11_FLTR_RSSTR_SMLR_MSK);
+ return OK;
+ }
+ // higher resistor
+ else if (value == 1) {
+ LOG(logINFO, ("Setting Higher Filter Resistor\n"));
+ bus_w(CONFIG_V11_REG,
+ bus_r(CONFIG_V11_REG) & ~CONFIG_V11_FLTR_RSSTR_SMLR_MSK);
+ return OK;
+ }
+ LOG(logERROR, ("Could not set Filter Resistor. Invalid value %d\n", value));
+ return FAIL;
+}
+
+int getNumberOfFilterCells() {
+#ifdef VIRTUAL
+ uint32_t addr = CONFIG_V11_REG;
+#else
+ uint32_t addr = CONFIG_V11_STATUS_REG;
+#endif
+ uint32_t regval = bus_r(addr);
+#ifndef VIRTUAL
+ // flip all contents of register //TODO FIRMWARE FIX
+ regval ^= BIT32_MASK;
+#endif
+ uint32_t retval =
+ (regval & CONFIG_V11_FLTR_CLL_MSK) >> CONFIG_V11_FLTR_CLL_OFST;
+ // count number of bits = which icell
+ return (__builtin_popcount(retval));
+}
+
+void setNumberOfFilterCells(int iCell) {
+ if (iCell > MAX_FILTER_CELL_VAL) {
+ return;
}
- // Remembering adcphase/ dbit phase in degrees
- int adcPhase = getPhase(ADC_CLK, 1);
- LOG(logDEBUG1, ("\tRemembering ADC phase: %d degrees\n", adcPhase));
- int dbitPhase = getPhase(DBIT_CLK, 1);
- LOG(logDEBUG1, ("\tRemembering DBIT phase: %d degrees\n", dbitPhase));
+ uint32_t addr = CONFIG_V11_REG;
+ bus_w(addr, bus_r(addr) & ~CONFIG_V11_FLTR_CLL_MSK);
- // Calculate and set output frequency
- clkFrequency[ind] =
- ALTERA_PLL_SetOuputFrequency(ind, PLL_VCO_FREQ_MHZ, val);
- LOG(logINFO, ("\t%s clock (%d) frequency set to %d MHz\n", clock_names[ind],
- ind, clkFrequency[ind]));
+ if (iCell > 0) {
+ // enables as many cells
+ uint32_t value = 0;
+ for (int i = 0; i != iCell; ++i) {
+ value |= (1 << i);
+ }
+ bus_w(addr, bus_r(addr) | ((value << CONFIG_V11_FLTR_CLL_OFST) &
+ CONFIG_V11_FLTR_CLL_MSK));
+ }
+ LOG(logINFO, ("Setting Number of Filter Cells to %d [Reg:0x%x]\n", iCell,
+ bus_r(addr)));
+}
- // phase reset by pll (when setting output frequency)
- clkPhase[ADC_CLK] = 0;
- clkPhase[DBIT_CLK] = 0;
+void disableCurrentSource() {
+ LOG(logINFO, ("Disabling Current Source\n"));
- // set the phase (reset by pll)
- LOG(logINFO, ("\tCorrecting ADC phase to %d degrees\n", adcPhase));
- setPhase(ADC_CLK, adcPhase, 1);
- LOG(logINFO, ("\tCorrecting DBIT phase to %d degrees\n", dbitPhase));
- setPhase(DBIT_CLK, dbitPhase, 1);
+ // set default values for current source first
+ if (getChipVersion() == 11) {
+ LOG(logINFO, ("\tSetting default values for selection\n"))
+ bus_w(CRRNT_SRC_COL_LSB_REG, BIT32_MASK);
+ bus_w(CRRNT_SRC_COL_MSB_REG, BIT32_MASK);
+ }
- // required to reconfigure as adc clock is stopped temporarily when
- // resetting pll (in changing output frequency)
- AD9257_Configure();
+ bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_CRRNT_SRC_ENBL_MSK);
+ LOG(logINFO, ("\tCurrent Source disabled\n"));
- if (ind != SYNC_CLK) {
- configureSyncFrequency(ind);
+ configureChip();
+}
+
+void enableCurrentSource(int fix, uint64_t select, int normal) {
+ disableCurrentSource();
+
+ if (getChipVersion() == 11) {
+ LOG(logINFO, ("Enabling current source [fix:%d, select:0x%lx]\n", fix,
+ (long unsigned int)select));
+ } else {
+ LOG(logINFO,
+ ("Enabling current source [fix:%d, select:%ld, normal:%d]\n", fix,
+ (long int)select, normal));
+ }
+ // fix
+ if (fix) {
+ LOG(logINFO, ("\tEnabling fix\n"));
+ bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_CRRNT_SRC_CLMN_FIX_MSK);
+ } else {
+ LOG(logINFO, ("\tDisabling fix\n"));
+ bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_CRRNT_SRC_CLMN_FIX_MSK);
+ }
+ if (getChipVersion() == 10) {
+ // select
+ LOG(logINFO, ("\tSetting selection to %ld\n", (long int)select));
+ bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_CRRNT_SRC_CLMN_SLCT_MSK);
+ bus_w(DAQ_REG,
+ bus_r(DAQ_REG) | ((select << DAQ_CRRNT_SRC_CLMN_SLCT_OFST) &
+ DAQ_CRRNT_SRC_CLMN_SLCT_MSK));
+
+ } else {
+ // select
+ // invert select first
+ uint64_t tmp = select;
+ uint64_t inverted = 0;
+ for (int i = 0; i != 64; ++i) {
+ // get each bit from LSB side
+ uint64_t bit = (tmp >> i) & 0x1;
+ // push the bit into MSB side
+ inverted |= (bit << (63 - i));
+ }
+ LOG(logINFO, ("\tSetting selection to 0x%lx (inverted from 0x%lx)\n",
+ (long unsigned int)inverted, (long unsigned int)select));
+ set64BitReg(inverted, CRRNT_SRC_COL_LSB_REG, CRRNT_SRC_COL_MSB_REG);
+
+ // normal
+ if (normal) {
+ LOG(logINFO, ("\tEnabling normal\n"))
+ bus_w(CONFIG_V11_REG,
+ bus_r(CONFIG_V11_REG) & ~CONFIG_V11_CRRNT_SRC_LOW_MSK);
+ } else {
+ LOG(logINFO, ("\tEnabling low\n"))
+ bus_w(CONFIG_V11_REG,
+ bus_r(CONFIG_V11_REG) | CONFIG_V11_CRRNT_SRC_LOW_MSK);
+ }
+ }
+ // validating before enabling current source
+ if (getFixCurrentSource() != fix || getSelectCurrentSource() != select) {
+ LOG(logERROR,
+ ("Could not set fix or select parameters for current source.\n"))
+ return;
+ }
+ // not validating normal because the status register might not update during
+ // acquisition
+
+ // enabling current source
+ LOG(logINFO, ("\tEnabling Current Source\n"));
+ bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_CRRNT_SRC_ENBL_MSK);
+
+ configureChip();
+}
+
+int getCurrentSource() {
+ return ((bus_r(DAQ_REG) & DAQ_CRRNT_SRC_ENBL_MSK) >>
+ DAQ_CRRNT_SRC_ENBL_OFST);
+}
+
+int getFixCurrentSource() {
+ return ((bus_r(DAQ_REG) & DAQ_CRRNT_SRC_CLMN_FIX_MSK) >>
+ DAQ_CRRNT_SRC_CLMN_FIX_OFST);
+}
+
+int getNormalCurrentSource() {
+ if (getChipVersion() == 11) {
+ int low = ((bus_r(CONFIG_V11_STATUS_REG) &
+ CONFIG_V11_STATUS_CRRNT_SRC_LOW_MSK) >>
+ CONFIG_V11_STATUS_CRRNT_SRC_LOW_OFST);
+ return (low == 0 ? 1 : 0);
+ }
+ return -1;
+}
+
+uint64_t getSelectCurrentSource() {
+ if (getChipVersion() == 10) {
+ return ((bus_r(DAQ_REG) & DAQ_CRRNT_SRC_CLMN_SLCT_MSK) >>
+ DAQ_CRRNT_SRC_CLMN_SLCT_OFST);
+ } else {
+ // invert the select
+ uint64_t retval =
+ get64BitReg(CRRNT_SRC_COL_LSB_REG, CRRNT_SRC_COL_MSB_REG);
+
+ uint64_t tmp = retval;
+ uint64_t inverted = 0;
+ for (int i = 0; i != 64; ++i) {
+ // get each bit from LSB side
+ uint64_t bit = (tmp >> i) & 0x1;
+ // push the bit into MSB side
+ inverted |= (bit << (63 - i));
+ }
+ return inverted;
+ }
+}
+
+int getTenGigaFlowControl() {
+ return ((bus_r(CONFIG_REG) & CONFIG_ETHRNT_FLW_CNTRL_MSK) >>
+ CONFIG_ETHRNT_FLW_CNTRL_OFST);
+}
+
+int setTenGigaFlowControl(int value) {
+ if (value >= 0) {
+ if (value == 0) {
+ LOG(logINFO, ("Switching off 10G flow control\n"));
+ bus_w(CONFIG_REG, bus_r(CONFIG_REG) & ~CONFIG_ETHRNT_FLW_CNTRL_MSK);
+ } else {
+ LOG(logINFO, ("Switching on 10G flow control\n"));
+ bus_w(CONFIG_REG, bus_r(CONFIG_REG) | CONFIG_ETHRNT_FLW_CNTRL_MSK);
+ }
}
return OK;
}
-int getFrequency(enum CLKINDEX ind) {
- if (ind < 0 || ind >= NUM_CLOCKS) {
- LOG(logERROR, ("Unknown clock index %d to get frequency\n", ind));
- return -1;
- }
- return clkFrequency[ind];
+int getTransmissionDelayFrame() {
+ return ((bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK) >>
+ CONFIG_TDMA_TIMESLOT_OFST);
}
-void configureSyncFrequency(enum CLKINDEX ind) {
- char *clock_names[] = {CLK_NAMES};
- int clka = 0, clkb = 0;
- switch (ind) {
- case ADC_CLK:
- clka = DBIT_CLK;
- clkb = RUN_CLK;
- break;
- case DBIT_CLK:
- clka = ADC_CLK;
- clkb = RUN_CLK;
- break;
- case RUN_CLK:
- clka = DBIT_CLK;
- clkb = ADC_CLK;
- break;
- default:
- LOG(logERROR,
- ("Unknown clock index %d to configure sync frequcny\n", ind));
- return;
+int setTransmissionDelayFrame(int value) {
+ if (value >= 0) {
+ LOG(logINFO, ("Setting transmission delay: %d\n", value));
+ bus_w(CONFIG_REG, (bus_r(CONFIG_REG) & ~CONFIG_TDMA_TIMESLOT_MSK) |
+ (((value << CONFIG_TDMA_TIMESLOT_OFST) &
+ CONFIG_TDMA_TIMESLOT_MSK)));
+ if (value == 0) {
+ LOG(logINFO, ("Switching off transmission delay\n"));
+ bus_w(CONFIG_REG, bus_r(CONFIG_REG) & ~CONFIG_TDMA_ENABLE_MSK);
+ } else {
+ LOG(logINFO, ("Switching on transmission delay\n"));
+ bus_w(CONFIG_REG, bus_r(CONFIG_REG) | CONFIG_TDMA_ENABLE_MSK);
+ }
+ LOG(logDEBUG1, ("Transmission delay read %d\n",
+ ((bus_r(CONFIG_REG) & CONFIG_TDMA_TIMESLOT_MSK) >>
+ CONFIG_TDMA_TIMESLOT_OFST)));
}
-
- int syncFreq = getFrequency(SYNC_CLK);
- int retval = getFrequency(ind);
- int aFreq = getFrequency(clka);
- int bFreq = getFrequency(clkb);
- LOG(logDEBUG1,
- ("Sync Frequncy:%d, RetvalFreq(%s):%d, aFreq(%s):%d, bFreq(%s):%d\n",
- syncFreq, clock_names[ind], retval, clock_names[clka], aFreq,
- clock_names[clkb], bFreq));
-
- int configure = 0;
-
- // find the smallest frequency
- int min = (aFreq < bFreq) ? aFreq : bFreq;
- min = (retval < min) ? retval : min;
-
- // sync is greater than min
- if (syncFreq > retval) {
- LOG(logINFO, ("\t--Configuring Sync Clock\n"));
- configure = 1;
- }
-
- // sync is smaller than min
- else if (syncFreq < min) {
- LOG(logINFO, ("\t++Configuring Sync Clock\n"));
- configure = 1;
- }
-
- // configure sync to current
- if (configure)
- setFrequency(SYNC_CLK, min);
-}
-
-void setADCPipeline(int val) {
- if (val < 0) {
- return;
- }
- LOG(logINFO, ("Setting adc pipeline to %d\n", val));
- uint32_t addr = ADC_OFFSET_REG;
- bus_w(addr, bus_r(addr) & ~ADC_OFFSET_ADC_PPLN_MSK);
- bus_w(addr, bus_r(addr) | ((val << ADC_OFFSET_ADC_PPLN_OFST) &
- ADC_OFFSET_ADC_PPLN_MSK));
-}
-
-int getADCPipeline() {
- return ((bus_r(ADC_OFFSET_REG) & ADC_OFFSET_ADC_PPLN_MSK) >>
- ADC_OFFSET_ADC_PPLN_OFST);
+ return OK;
}
/* aquisition */
@@ -1648,7 +2442,10 @@ int startStateMachine() {
if (createUDPSocket(0) != OK) {
return FAIL;
}
- LOG(logINFOBLUE, ("Starting State Machine\n"));
+ if (getNumberofUDPInterfaces() == 2 && createUDPSocket(1) != OK) {
+ return FAIL;
+ }
+ LOG(logINFOBLUE, ("starting state machine\n"));
if (sharedMemory_getStop() != 0) {
LOG(logERROR, ("Cant start acquisition. "
"Stop server has not updated stop status to 0\n"));
@@ -1663,30 +2460,13 @@ int startStateMachine() {
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
return OK;
#endif
- int send_to_10g = enableTenGigabitEthernet(-1);
- // 1 giga udp
- if (send_to_10g == 0) {
- // create udp socket
- if (createUDPSocket(0) != OK) {
- return FAIL;
- }
- // update header with modId, detType and version. Reset offset and fnum
- createUDPPacketHeader(udpPacketData, getHardwareSerialNumber());
- }
-
LOG(logINFOBLUE, ("Starting State Machine\n"));
+
cleanFifos();
- if (send_to_10g == 0) {
- unsetFifoReadStrobes(); // FIXME: unnecessary to write bus_w(dumm, 0) as
- // it is 0 in the beginnig and the strobes are
- // always unset if set
- }
// start state machine
- bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STRT_ACQSTN_MSK |
- CONTROL_STRT_EXPSR_MSK);
- bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_STRT_ACQSTN_MSK &
- ~CONTROL_STRT_EXPSR_MSK);
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_START_ACQ_MSK);
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_START_ACQ_MSK);
LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG)));
return OK;
@@ -1697,77 +2477,169 @@ void *start_timer(void *arg) {
if (!isControlServer) {
return NULL;
}
-
+ int firstDest = getFirstUDPDestination();
+ int transmissionDelayUs = getTransmissionDelayFrame() * 1000;
+ int numInterfaces = getNumberofUDPInterfaces();
int64_t periodNs = getPeriod();
- int numFrames = (getNumFrames() * getNumTriggers());
- int64_t expNs = getExpTime();
+ int numFrames = getNumFrames() * getNumTriggers();
+ int64_t expUs = getExpTime() / 1000;
+ const int maxPacketsPerFrame = (MAX_ROWS_PER_READOUT / ROWS_PER_PACKET);
+ const int dataSize = (DATA_BYTES / maxPacketsPerFrame);
+ const int packetsize = dataSize + sizeof(sls_detector_header);
+ const int maxRows = MAX_ROWS_PER_READOUT;
+ int readNRows = getReadNRows();
+ if (readNRows == -1) {
+ LOG(logERROR,
+ ("number of rows is -1. Assuming no partial readout (#rows).\n"));
+ readNRows = MAX_ROWS_PER_READOUT;
+ }
+ const int packetsPerFrame =
+ ((maxPacketsPerFrame / 2) * readNRows) / (maxRows / 2);
- int imageSize = dataBytes;
- int dataSize = UDP_PACKET_DATA_BYTES;
- int packetSize = sizeof(sls_detector_header) + dataSize;
- int packetsPerFrame = ceil((double)imageSize / (double)dataSize);
+ // Generate data
+ char imageData[DATA_BYTES];
+ memset(imageData, 0, DATA_BYTES);
+ {
+ const int npixels = (NCHAN * NCHIP);
+ const int pixelsPerPacket = dataSize / NUM_BYTES_PER_PIXEL;
+ int dataVal = 0;
+ int gainVal = 0;
+ int pixelVal = 0;
+ for (int i = 0; i < npixels; ++i) {
+ if (i % pixelsPerPacket == 0) {
+ ++dataVal;
+ }
+ if ((i % 400) < 100) {
+ gainVal = 1;
+ } else if ((i % 400) < 300) {
+ gainVal = 2;
+ } else {
+ gainVal = 3;
+ }
+ pixelVal = (dataVal & ~GAIN_VAL_MSK) | (gainVal << GAIN_VAL_OFST);
+// to debug multi module geometry (row, column) in virtual servers (all pixels
+// in a module set to particular value)
+#ifdef TEST_MOD_GEOMETRY
+ *((uint16_t *)(imageData + i * sizeof(uint16_t))) =
+ portno % 1900 + (i >= npixels / 2 ? 1 : 0);
+#else
+ *((uint16_t *)(imageData + i * sizeof(uint16_t))) =
+ virtual_image_test_mode ? 0x0FFE : (uint16_t)pixelVal;
- // Generate Data
- char imageData[imageSize];
- memset(imageData, 0, imageSize);
- for (int i = 0; i < imageSize; i += sizeof(uint16_t)) {
- *((uint16_t *)(imageData + i)) = i;
+#endif
+ }
}
// Send data
- uint64_t frameNr = 0;
- getNextFrameNumber(&frameNr);
- // loop over number of frames
- for (int iframes = 0; iframes != numFrames; ++iframes) {
+ {
+ uint64_t frameNr = 0;
+ getNextFrameNumber(&frameNr);
+ int iRxEntry = firstDest;
+ for (int iframes = 0; iframes != numFrames; ++iframes) {
+ usleep(transmissionDelayUs);
- // check if manual stop
- if (sharedMemory_getStop() == 1) {
- setNextFrameNumber(frameNr + iframes + 1);
- break;
- }
+ // check if manual stop
+ if (sharedMemory_getStop() == 1) {
+ setNextFrameNumber(frameNr + iframes + 1);
+ break;
+ }
- // sleep for exposure time
- struct timespec begin, end;
- clock_gettime(CLOCK_REALTIME, &begin);
- usleep(expNs / 1000);
+ // sleep for exposure time
+ struct timespec begin, end;
+ clock_gettime(CLOCK_REALTIME, &begin);
+ usleep(expUs);
- int srcOffset = 0;
- // loop packet
- for (int i = 0; i != packetsPerFrame; ++i) {
- // set header
- char packetData[packetSize];
- memset(packetData, 0, packetSize);
- sls_detector_header *header = (sls_detector_header *)(packetData);
- header->detType = (uint16_t)myDetectorType;
- header->version = SLS_DETECTOR_HEADER_VERSION;
- header->frameNumber = frameNr + iframes;
- header->packetNumber = i;
- header->modId = 0;
- header->row = detPos[Y];
- header->column = detPos[X];
+ int srcOffset = 0;
+ int srcOffset2 = DATA_BYTES / 2;
+ int row0 = (numInterfaces == 1 ? detPos[1] : detPos[3]);
+ int col0 = (numInterfaces == 1 ? detPos[0] : detPos[2]);
+ int row1 = detPos[1];
+ int col1 = detPos[0];
+ // loop packet (50 packets)
+ for (int i = 0; i != maxPacketsPerFrame; ++i) {
- // fill data
- memcpy(packetData + sizeof(sls_detector_header),
- imageData + srcOffset, dataSize);
- srcOffset += dataSize;
+ const int startval =
+ (maxPacketsPerFrame / 2) - (packetsPerFrame / 2);
+ const int endval = startval + packetsPerFrame - 1;
+ int pnum = i;
- sendUDPPacket(0, 0, packetData, packetSize);
- }
- LOG(logINFO, ("Sent frame: %d [%lld]\n", iframes, frameNr + iframes));
- clock_gettime(CLOCK_REALTIME, &end);
- int64_t timeNs =
- ((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec));
+ // first interface
+ if (numInterfaces == 1 || i < (maxPacketsPerFrame / 2)) {
+ char packetData[packetsize];
+ memset(packetData, 0, packetsize);
+ sls_detector_header *header =
+ (sls_detector_header *)(packetData);
+ header->detType = (uint16_t)myDetectorType;
+ header->version = SLS_DETECTOR_HEADER_VERSION;
+ header->frameNumber = frameNr + iframes;
+ header->packetNumber = pnum;
+ header->modId = virtual_moduleid;
+ header->row = row0;
+ header->column = col0;
- // sleep for (period - exptime)
- if (iframes < numFrames) { // if there is a next frame
- if (periodNs > timeNs) {
- usleep((periodNs - timeNs) / 1000);
+ // fill data
+ memcpy(packetData + sizeof(sls_detector_header),
+ imageData + srcOffset, dataSize);
+ srcOffset += dataSize;
+
+ if (i >= startval && i <= endval) {
+ sendUDPPacket(iRxEntry, 0, packetData, packetsize);
+ LOG(logDEBUG1, ("Sent packet: %d [interface 0]\n", i));
+ }
+ }
+
+ // second interface
+ else if (numInterfaces == 2 && i >= (maxPacketsPerFrame / 2)) {
+ pnum = i % (maxPacketsPerFrame / 2);
+
+ char packetData2[packetsize];
+ memset(packetData2, 0, packetsize);
+ sls_detector_header *header =
+ (sls_detector_header *)(packetData2);
+ header->detType = (uint16_t)myDetectorType;
+ header->version = SLS_DETECTOR_HEADER_VERSION;
+ header->frameNumber = frameNr + iframes;
+ header->packetNumber = pnum;
+ header->modId = virtual_moduleid;
+ header->row = row1;
+ header->column = col1;
+
+ // fill data
+ memcpy(packetData2 + sizeof(sls_detector_header),
+ imageData + srcOffset2, dataSize);
+ srcOffset2 += dataSize;
+
+ if (i >= startval && i <= endval) {
+ sendUDPPacket(iRxEntry, 1, packetData2, packetsize);
+ LOG(logDEBUG1,
+ ("Sent packet: %d [interface 1]\n", pnum));
+ }
+ }
+ }
+ LOG(logINFO, ("Sent frame %d [#%ld] to E%d\n", iframes,
+ frameNr + iframes, iRxEntry));
+ clock_gettime(CLOCK_REALTIME, &end);
+ int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
+ (end.tv_nsec - begin.tv_nsec));
+
+ // sleep for (period - exptime)
+ if (iframes < numFrames) { // if there is a next frame
+ if (periodNs > timeNs) {
+ usleep((periodNs - timeNs) / 1000);
+ }
+ }
+ ++iRxEntry;
+ if (iRxEntry == numUdpDestinations) {
+ iRxEntry = 0;
}
}
setNextFrameNumber(frameNr + numFrames);
}
closeUDPSocket(0);
+ if (numInterfaces == 2) {
+ closeUDPSocket(1);
+ }
sharedMemory_setStatus(IDLE);
LOG(logINFOBLUE, ("Transmitting frames done\n"));
@@ -1791,11 +2663,37 @@ int stopStateMachine() {
return OK;
#endif
// stop state machine
- bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STP_ACQSTN_MSK);
- usleep(WAIT_TIME_US_STP_ACQ);
- bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_STP_ACQSTN_MSK);
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STOP_ACQ_MSK);
+ usleep(100);
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_STOP_ACQ_MSK);
LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG)));
+ return OK;
+}
+
+int softwareTrigger(int block) {
+#ifndef VIRTUAL
+ // ready for trigger
+ if (getRunStatus() != WAITING) {
+ LOG(logWARNING, ("Not yet ready for trigger!\n"));
+ return 0;
+ }
+#endif
+
+ LOG(logINFO, ("Sending Software Trigger\n"));
+ bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_SOFTWARE_TRIGGER_MSK);
+
+#ifndef VIRTUAL
+ // block till frame is sent out
+ if (block) {
+ enum runStatus s = getRunStatus();
+ while (s == RUNNING || s == TRANSMITTING) {
+ usleep(5000);
+ s = getRunStatus();
+ }
+ }
+ LOG(logINFO, ("Ready for Next Trigger...\n"));
+#endif
return OK;
}
@@ -1820,76 +2718,40 @@ enum runStatus getRunStatus() {
return IDLE;
#endif
- uint32_t retval = bus_r(STATUS_REG);
+ enum runStatus s;
+ u_int32_t retval = bus_r(STATUS_REG);
LOG(logINFO, ("Status Register: %08x\n", retval));
- // error
- // if (retval & STATUS_SM_FF_FLL_MSK) { This bit is high when a analog fifo
- // is full Or when external stop
- if (retval & STATUS_ANY_FF_FLL_MSK) { // if adc or digital fifo is full
- LOG(logINFORED, ("Status: Error (Any fifo full)\n"));
- return ERROR;
- }
-
// running
- if (retval & STATUS_RN_BSY_MSK) {
- if (retval & STATUS_WTNG_FR_TRGGR_MSK) {
- LOG(logINFOBLUE, ("Status: Waiting for Trigger\n"));
- return WAITING;
+ if (retval & RUN_BUSY_MSK) {
+ if (retval & WAITING_FOR_TRIGGER_MSK) {
+ LOG(logINFOBLUE, ("Status: WAITING\n"));
+ s = WAITING;
+ } else {
+ LOG(logINFOBLUE, ("Status: RUNNING\n"));
+ s = RUNNING;
}
-
- LOG(logINFOBLUE, ("Status: Running\n"));
- return RUNNING;
-
}
// not running
else {
- if (retval & STATUS_STPPD_MSK) {
- LOG(logINFOBLUE, ("Status: Stopped\n"));
- return STOPPED;
- }
-
- if (retval & STATUS_FRM_RN_BSY_MSK) {
- LOG(logINFOBLUE, ("Status: Transmitting (Read machine busy)\n"));
- return TRANSMITTING;
- }
-
- if (!(retval & STATUS_IDLE_MSK)) {
- LOG(logINFOBLUE, ("Status: Idle\n"));
- return IDLE;
- }
-
- LOG(logERROR, ("Status: Unknown status %08x\n", retval));
- return ERROR;
- }
-}
-
-void readandSendUDPFrames(int *ret, char *mess) {
- LOG(logDEBUG1, ("Reading from 1G UDP\n"));
-
- // validate udp socket
- if (getUdPSocketDescriptor(0, 0) <= 0) {
- *ret = FAIL;
- sprintf(mess, "UDP Socket not created. sockfd:%d\n",
- getUdPSocketDescriptor(0, 0));
- LOG(logERROR, (mess));
- return;
- }
-
- // every frame read
- while (readFrameFromFifo() == OK) {
- int bytesToSend = 0, n = 0;
- while ((bytesToSend = fillUDPPacket(udpPacketData))) {
- n += sendUDPPacket(0, 0, udpPacketData, bytesToSend);
- }
- if (n >= dataBytes) {
- LOG(logINFO, (" Frame %lld sent (%d packets, %d databytes, n:%d "
- "bytes sent)\n",
- udpFrameNumber, udpPacketNumber + 1, dataBytes, n));
+ // stopped or error
+ 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) {
+ LOG(logINFOBLUE, ("Status: IDLE\n"));
+ s = IDLE;
+ } else {
+ LOG(logERROR, ("Status: Unknown status %08x\n", retval));
+ s = ERROR;
}
}
- closeUDPSocket(0);
+
+ return s;
}
void waitForAcquisitionEnd() {
@@ -1905,171 +2767,22 @@ void waitForAcquisitionEnd() {
LOG(logINFOGREEN, ("Blocking Acquisition done\n"));
}
-void readFrames(int *ret, char *mess) {
-#ifdef VIRTUAL
- while (runBusy()) {
- usleep(500);
- }
-#else
- // 1G force reading of frames
- if (!enableTenGigabitEthernet(-1)) {
- readandSendUDPFrames(ret, mess);
- LOG(logINFOBLUE, ("Transmitting frames done\n"));
- }
-#endif
-}
-
-void unsetFifoReadStrobes() {
- bus_w(DUMMY_REG, bus_r(DUMMY_REG) & (~DUMMY_ANLG_FIFO_RD_STRBE_MSK) &
- (~DUMMY_DGTL_FIFO_RD_STRBE_MSK));
-}
-
-void readSample(int ns) {
- uint32_t addr = DUMMY_REG;
-
- // read adcs
- if (ns < nSamples) {
-
- uint32_t fifoAddr = FIFO_DATA_REG;
-
- // read strobe to all analog fifos
- bus_w(addr, bus_r(addr) | DUMMY_ANLG_FIFO_RD_STRBE_MSK);
- bus_w(addr, bus_r(addr) & (~DUMMY_ANLG_FIFO_RD_STRBE_MSK));
-
- // wait for 1 us to latch different clocks of read and read strobe
- for (int i = 0; i < WAIT_TIME_1US_FOR_LOOP_CNT; ++i)
- ;
-
- if (!(ns % 1000)) {
- LOG(logDEBUG1, ("Reading sample ns:%d of %d AEmtpy:0x%x AFull:0x%x "
- "Status:0x%x\n",
- ns, nSamples, bus_r(FIFO_EMPTY_REG),
- bus_r(FIFO_FULL_REG), bus_r(STATUS_REG)));
- }
-
- // loop through all channels
- for (int ich = 0; ich < NCHAN; ++ich) {
-
- // if channel is in enable mask
- if ((1 << ich) & (adcEnableMask_1g)) {
-
- // unselect channel
- bus_w(addr, bus_r(addr) & ~(DUMMY_FIFO_CHNNL_SLCT_MSK));
-
- // select channel
- bus_w(addr, bus_r(addr) | ((ich << DUMMY_FIFO_CHNNL_SLCT_OFST) &
- DUMMY_FIFO_CHNNL_SLCT_MSK));
-
- // read fifo and write it to current position of data pointer
- *((uint16_t *)analogDataPtr) = bus_r16(fifoAddr);
-
- // keep reading till the value is the same
- /* while (*((uint16_t*)analogDataPtr) != bus_r16(fifoAddr)) {
- LOG(logDEBUG1, ("%d ", ich));
- *((uint16_t*)analogDataPtr) = bus_r16(fifoAddr);
- }*/
-
- // increment pointer to data out destination
- analogDataPtr += 2;
- }
- }
- }
-}
-
-uint32_t checkDataInFifo() {
- uint32_t dataPresent = 0;
- uint32_t fifoEmpty = bus_r(FIFO_EMPTY_REG);
- LOG(logINFO, ("Analog Fifo Empty (32 channels): 0x%08x\n", fifoEmpty));
- dataPresent = (~fifoEmpty);
- LOG(logDEBUG2, ("Data in Fifo :0x%x\n", dataPresent));
- return dataPresent;
-}
-
-// only called for starting of a new frame
-int checkFifoForEndOfAcquisition() {
- uint32_t dataPresent = checkDataInFifo();
- LOG(logDEBUG2, ("status:0x%x\n", bus_r(STATUS_REG)));
-
- // as long as no data
- while (!dataPresent) {
- // acquisition done
- if (!runBusy()) {
- // wait to be sure there is no data in fifo
- usleep(WAIT_TME_US_FR_ACQDONE_REG);
-
- // still no data
- if (!checkDataInFifo()) {
- LOG(logINFO, ("Acquisition Finished (State: 0x%08x), "
- "no frame found .\n",
- bus_r(STATUS_REG)));
- return FAIL;
- }
- // got data, exit
- else {
- break;
- }
- }
- // check if data in fifo again
- dataPresent = checkDataInFifo();
- }
- LOG(logDEBUG1, ("Got data :0x%x\n", dataPresent));
- return OK;
-}
-
-int readFrameFromFifo() {
- int ns = 0;
- // point the data pointer to the starting position of data
- analogDataPtr = analogData;
-
- // no data for this frame
- if (checkFifoForEndOfAcquisition() == FAIL) {
- return FAIL;
- }
-
- // read Sample
- while (ns < nSamples) {
- readSample(ns);
- ns++;
- }
-
- // got frame
- return OK;
-}
-
-uint32_t runBusy() {
+u_int32_t runBusy() {
#ifdef VIRTUAL
return ((sharedMemory_getStatus() == RUNNING) ? 1 : 0);
#endif
- uint32_t s = (bus_r(STATUS_REG) & STATUS_RN_BSY_MSK);
- // LOG(logDEBUG1, ("Status Register: %08x\n", s));
+ u_int32_t s = (bus_r(STATUS_REG) & RUN_BUSY_MSK);
+ LOG(logDEBUG1, ("Status Register: %08x\n", s));
return s;
}
/* common */
-int calculateDataBytes() { return dataBytes; }
+int calculateDataBytes() { return DATA_BYTES; }
int getTotalNumberOfChannels() {
- int nchanx = 0, nchany = 0;
- getNumberOfChannels(&nchanx, &nchany);
- return nchanx * nchany;
+ return (getNumberOfChannelsPerChip() * getNumberOfChips());
}
-
-void getNumberOfChannels(int *nchanx, int *nchany) {
- uint32_t mask =
- enableTenGigabitEthernet(-1) ? adcEnableMask_10g : adcEnableMask_1g;
- // count number of channels in x, each adc has 25 channels each
- int nchanTop = __builtin_popcount(mask & 0xF0F0F0F0) * NCHANS_PER_ADC;
- int nchanBot = __builtin_popcount(mask & 0x0F0F0F0F) * NCHANS_PER_ADC;
- *nchanx = nchanTop > 0 ? nchanTop : nchanBot;
- // if both top and bottom adcs enabled, rows = 2
- int nrows = 1;
- if (nchanTop > 0 && nchanBot > 0) {
- nrows = 2;
- }
- *nchany = nSamples / NSAMPLES_PER_ROW * nrows;
-}
-
int getNumberOfChips() { return NCHIP; }
int getNumberOfDACs() { return NDAC; }
int getNumberOfChannelsPerChip() { return NCHAN; }
diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h
index 3db8a8011..6aadebe60 100644
--- a/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h
+++ b/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h
@@ -4,18 +4,140 @@
#include "RegisterDefs.h"
#include "sls/sls_detector_defs.h"
-#define MIN_REQRD_VRSN_T_RD_API 0x180314
-#define REQRD_FRMWR_VRSN 0x220825
+#define REQRD_FRMWRE_VRSN_BOARD2 0x221130 // 1.0 pcb (version = 010)
+#define REQRD_FRMWRE_VRSN 0x221130 // 2.0 pcb (version = 011)
-#define NUM_HARDWARE_VERSIONS (1)
+#define NUM_HARDWARE_VERSIONS (2)
#define HARDWARE_VERSION_NUMBERS \
- { 0x1 }
+ { 0x2, 0x3 }
#define HARDWARE_VERSION_NAMES \
- { "1.0" }
+ { "1.0", "2.0" }
+#define ID_FILE ("detid_moench.txt")
+#define CONFIG_FILE ("config_moench.txt")
#define LINKED_SERVER_NAME "moenchDetectorServer"
-#define CTRL_SRVR_INIT_TIME_US (2 * 1000 * 1000)
+#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
+
+/* Hardware Definitions */
+#define NCHAN (400 * 400)
+#define NCHIP (1)
+#define NDAC (8)
+#define DYNAMIC_RANGE (16)
+#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
+#define DATA_BYTES (NCHIP * NCHAN * NUM_BYTES_PER_PIXEL)
+#define CLK_RUN (40) // MHz
+#define CLK_SYNC (20) // MHz
+#define ADC_CLK_INDEX (1)
+#define DBIT_CLK_INDEX (0)
+
+/** Default Parameters */
+#define DEFAULT_NUM_FRAMES (1)
+#define DEFAULT_STARTING_FRAME_NUMBER (1)
+#define DEFAULT_NUM_CYCLES (1)
+#define DEFAULT_EXPTIME (10 * 1000) // ns
+#define DEFAULT_PERIOD (2 * 1000 * 1000) // ns
+#define DEFAULT_DELAY (0)
+#define DEFAULT_HIGH_VOLTAGE (0)
+#define DEFAULT_TIMING_MODE (AUTO_TIMING)
+#define DEFAULT_SETTINGS (GAIN0)
+#define DEFAULT_GAINMODE (DYNAMIC)
+#define DEFAULT_TX_UDP_PORT (0x7e9a)
+#define DEFAULT_TMP_THRSHLD (65 * 1000) // milli degree Celsius
+#define DEFAULT_FLIP_ROWS (0)
+#define DEFAULT_FILTER_RESISTOR (1) // higher resistor
+#define DEFAULT_FILTER_CELL (0)
+
+#define HIGHVOLTAGE_MIN (60)
+#define HIGHVOLTAGE_MAX (200)
+#define DAC_MIN_MV (0)
+#define DAC_MAX_MV (2500)
+#define MAX_FILTER_CELL_VAL (12)
+
+#define READ_N_ROWS_MULTIPLE (16) // 400 rows/50packets * 2 interfaces
+#define MIN_ROWS_PER_READOUT (16)
+#define MAX_ROWS_PER_READOUT (400)
+#define ROWS_PER_PACKET (8)
+
+/* Defines in the Firmware */
+#define MAX_TIMESLOT_VAL (0x1F)
+#define MAX_THRESHOLD_TEMP_VAL (127999) // millidegrees
+#define ACQ_TIME_MIN_CLOCK (2)
+#define ASIC_FILTER_MAX_RES_VALUE (1)
+#define MAX_SELECT_CHIP10_VAL (63)
+
+#define MAX_PHASE_SHIFTS (240)
+#define BIT16_MASK (0xFFFF)
+
+#define GAIN_VAL_OFST (14)
+#define GAIN_VAL_MSK (0x3 << GAIN_VAL_OFST)
+
+// pipeline
+#define ADC_PORT_INVERT_VAL (0x5A5A5A5A)
+#define ADC_PORT_INVERT_BOARD2_VAL (0x453b2a9c)
+
+// 2.0 pcb (chipv1.1)
+#define SAMPLE_ADC_FULL_SPEED_CHIP11 \
+ (SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_0_VAL + \
+ SAMPLE_DGTL_SAMPLE_0_VAL + SAMPLE_DECMT_FACTOR_FULL_VAL) // 0x0000
+#define SAMPLE_ADC_HALF_SPEED_CHIP11 \
+ (SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_1_VAL + \
+ SAMPLE_DGTL_SAMPLE_1_VAL + SAMPLE_DECMT_FACTOR_HALF_VAL) // 0x1110
+#define SAMPLE_ADC_QUARTER_SPEED_CHIP11 \
+ (SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_3_VAL + \
+ SAMPLE_DGTL_SAMPLE_2_VAL + SAMPLE_DECMT_FACTOR_QUARTER_VAL) // 0x2230
+
+#define ADC_PHASE_FULL_SPEED_CHIP11 (160)
+#define ADC_PHASE_HALF_SPEED_CHIP11 (160)
+#define ADC_PHASE_QUARTER_SPEED_CHIP11 (160)
+
+#define DBIT_PHASE_FULL_SPEED_CHIP11 (80)
+#define DBIT_PHASE_HALF_SPEED_CHIP11 (135)
+#define DBIT_PHASE_QUARTER_SPEED_CHIP11 (135)
+
+#define ADC_OFST_FULL_SPEED_VAL_CHIP11 (0x10)
+#define ADC_OFST_HALF_SPEED_VAL_CHIP11 (0x08)
+#define ADC_OFST_QUARTER_SPEED_VAL_CHIP11 (0x04)
+
+// 2.0 pcb (chipv1.0)
+#define SAMPLE_ADC_FULL_SPEED_CHIP10 \
+ (SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_0_VAL + \
+ SAMPLE_DGTL_SAMPLE_1_VAL + SAMPLE_DECMT_FACTOR_FULL_VAL) // 0x0100
+#define SAMPLE_ADC_HALF_SPEED_CHIP10 \
+ (SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_1_VAL + \
+ SAMPLE_DGTL_SAMPLE_3_VAL + SAMPLE_DECMT_FACTOR_HALF_VAL) // 0x1310
+#define SAMPLE_ADC_QUARTER_SPEED_CHIP10 \
+ (SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_3_VAL + \
+ SAMPLE_DGTL_SAMPLE_6_VAL + SAMPLE_DECMT_FACTOR_QUARTER_VAL) // 0x2630
+
+#define ADC_PHASE_FULL_SPEED_CHIP10 (160)
+#define ADC_PHASE_HALF_SPEED_CHIP10 (160)
+#define ADC_PHASE_QUARTER_SPEED_CHIP10 (160)
+
+#define DBIT_PHASE_FULL_SPEED_CHIP10 (125)
+#define DBIT_PHASE_HALF_SPEED_CHIP10 (175)
+#define DBIT_PHASE_QUARTER_SPEED_CHIP10 (175)
+
+#define ADC_OFST_FULL_SPEED_VAL_CHIP10 (0x10)
+#define ADC_OFST_HALF_SPEED_VAL_CHIP10 (0x08)
+#define ADC_OFST_QUARTER_SPEED_VAL_CHIP10 (0x04)
+
+// 1.0 pcb (2 resistor network)
+#define SAMPLE_ADC_HALF_SPEED_BOARD2 \
+ (SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_0_VAL + \
+ SAMPLE_DGTL_SAMPLE_3_VAL + SAMPLE_DECMT_FACTOR_HALF_VAL) // 0x1300
+#define SAMPLE_ADC_QUARTER_SPEED_BOARD2 \
+ (SAMPLE_ADC_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_1_VAL + \
+ SAMPLE_DGTL_SAMPLE_6_VAL + SAMPLE_DECMT_FACTOR_QUARTER_VAL) // 0x2610
+
+#define ADC_PHASE_HALF_SPEED_BOARD2 (110)
+#define ADC_PHASE_QUARTER_SPEED_BOARD2 (220)
+
+#define DBIT_PHASE_HALF_SPEED_BOARD2 (150)
+#define DBIT_PHASE_QUARTER_SPEED_BOARD2 (150)
+
+#define ADC_OFST_HALF_SPEED_BOARD2_VAL (0x10)
+#define ADC_OFST_QUARTER_SPEED_BOARD2_VAL (0x08)
/* Struct Definitions */
typedef struct udp_header_struct {
@@ -45,111 +167,44 @@ typedef struct udp_header_struct {
#define UDP_IP_HEADER_LENGTH_BYTES (28)
/* Enums */
+enum ADCINDEX { TEMP_FPGA, TEMP_ADC };
enum DACINDEX {
- MO_VBP_COLBUF,
- MO_VIPRE,
- MO_VIN_CM,
- MO_VB_SDA,
- MO_VCASC_SFP,
- MO_VOUT_CM,
- MO_VIPRE_CDS,
- MO_IBIAS_SFP
+ J_VB_COMP,
+ J_VDD_PROT,
+ J_VIN_COM,
+ J_VREF_PRECH,
+ J_VB_PIXBUF,
+ J_VB_DS,
+ J_VREF_DS,
+ J_VREF_COMP
};
#define DAC_NAMES \
- "vbp_colbuf", "vipre", "vin_cm", "vb_sda", "vcasc_sfp", "vout_cm", \
- "vipre_cds", "ibias_sfp"
+ "vb_comp", "vdd_prot", "vin_com", "vref_prech", "vb_pixbuf", "vb_ds", \
+ "vref_ds", "vref_comp"
+
#define DEFAULT_DAC_VALS \
{ \
- 1300, /* MO_VBP_COLBUF */ \
- 1000, /* MO_VIPRE */ \
- 1400, /* MO_VIN_CM */ \
- 680, /* MO_VB_SDA */ \
- 1428, /* MO_VCASC_SFP */ \
- 1200, /* MO_VOUT_CM */ \
- 800, /* MO_VIPRE_CDS */ \
- 900 /* MO_IBIAS_SFP */ \
+ 1220, /* J_VB_COMP */ \
+ 3000, /* J_VDD_PROT */ \
+ 1053, /* J_VIN_COM */ \
+ 1450, /* J_VREF_PRECH */ \
+ 750, /* J_VB_PIXBUF */ \
+ 1000, /* J_VB_DS */ \
+ 480, /* J_VREF_DS */ \
+ 420 /* J_VREF_COMP */ \
};
-enum CLKINDEX { RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS };
-#define CLK_NAMES "run", "adc", "sync", "dbit"
+enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
+#define MASTER_NAMES "hardware", "master", "slave"
-/* Hardware Definitions */
-#define NCHAN (32)
-#define NCHIP (1)
-#define NDAC (8)
-#define DYNAMIC_RANGE (16)
-#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
-#define CLK_FREQ (156.25) /* MHz */
-#define NSAMPLES_PER_ROW (25)
-#define NCHANS_PER_ADC (25)
+#define NUMSETTINGS (2)
+#define NSPECIALDACS (3)
+#define SPECIALDACINDEX {J_VREF_PRECH, J_VREF_DS, J_VREF_COMP};
+#define SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS \
+ { 1450, 480, 420 }
+#define SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS \
+ { 1550, 450, 620 }
-/** Default Parameters */
-#define DEFAULT_PATTERN_FILE ("DefaultPattern_moench.txt")
-#define DEFAULT_STARTING_FRAME_NUMBER (1)
-#define DEFAULT_DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
-#define DEFAULT_NUM_SAMPLES (5000)
-#define DEFAULT_EXPTIME (0)
-#define DEFAULT_NUM_FRAMES (1)
-#define DEFAULT_NUM_CYCLES (1)
-#define DEFAULT_PERIOD (1 * 1000 * 1000) // ns
-#define DEFAULT_DELAY (0)
-#define DEFAULT_HIGH_VOLTAGE (0)
-#define DEFAULT_VLIMIT (-100)
-#define DEFAULT_TIMING_MODE (AUTO_TIMING)
-#define DEFAULT_TX_UDP_PORT (0x7e9a)
-
-#define DEFAULT_RUN_CLK_AT_STARTUP (200) // 40
-#define DEFAULT_ADC_CLK_AT_STARTUP (40) // 20
-#define DEFAULT_SYNC_CLK_AT_STARTUP (40) // 20
-#define DEFAULT_DBIT_CLK_AT_STARTUP (200)
-
-#define DEFAULT_RUN_CLK (40)
-#define DEFAULT_ADC_CLK (20)
-#define DEFAULT_DBIT_CLK (40)
-#define DEFAULT_ADC_PHASE_DEG (30)
-
-#define DEFAULT_PIPELINE (15)
-#define DEFAULT_SETTINGS (G4_HIGHGAIN)
-
-#define UDP_HEADER_MAX_FRAME_VALUE (0xFFFFFFFFFFFF)
-
-// settings
-#define DEFAULT_PATMASK (0x00000C800000800AULL)
-#define G1_HIGHGAIN_PATSETBIT (0x00000C0000008008ULL)
-#define G1_LOWGAIN_PATSETBIT (0x0000040000008000ULL)
-#define G2_HIGHCAP_HIGHGAIN_PATSETBIT (0x0000080000000008ULL)
-#define G2_HIGHCAP_LOWGAIN_PATSETBIT (0x0000000000000000ULL)
-#define G2_LOWCAP_HIGHGAIN_PATSETBIT (0x00000C800000800AULL)
-#define G2_LOWCAP_LOWGAIN_PATSETBIT (0x0000048000008002ULL)
-#define G4_HIGHGAIN_PATSETBIT (0x000008800000000AULL)
-#define G4_LOWGAIN_PATSETBIT (0x0000008000000002ULL)
-
-#define HIGHVOLTAGE_MIN (60)
-#define HIGHVOLTAGE_MAX (200) // min dac val
-#define DAC_MIN_MV (0)
-#define DAC_MAX_MV (2500)
-
-/* Defines in the Firmware */
-#define DIGITAL_IO_DELAY_MAXIMUM_PS \
- ((OUTPUT_DELAY_0_OTPT_STTNG_MSK >> OUTPUT_DELAY_0_OTPT_STTNG_OFST) * \
- OUTPUT_DELAY_0_OTPT_STTNG_STEPS)
-#define MAX_PHASE_SHIFTS_STEPS (8)
-
-#define WAIT_TME_US_FR_ACQDONE_REG \
- (100) // wait time in us after acquisition done to ensure there is no data
- // in fifo
-#define WAIT_TIME_US_PLL (10 * 1000)
-#define WAIT_TIME_US_STP_ACQ (100)
-#define WAIT_TIME_CONFIGURE_MAC (2 * 1000 * 1000)
-#define WAIT_TIME_PATTERN_READ (10)
-#define WAIT_TIME_1US_FOR_LOOP_CNT (50) // around 30 is 1 us in blackfin
-
-/* MSB & LSB DEFINES */
-#define MSB_OF_64_BIT_REG_OFST (32)
-#define LSB_OF_64_BIT_REG_OFST (0)
-#define BIT32_MSK (0xFFFFFFFF)
-#define BIT16_MASK (0xFFFF)
-
-#define ADC_PORT_INVERT_VAL (0x4a342593)
-#define MAXIMUM_ADC_CLK (20)
-#define PLL_VCO_FREQ_MHZ (800)
+enum NETWORKINDEX { TXN_FRAME, FLOWCTRL_10G };
+enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS };
+#define CLK_NAMES "run", "adc", "dbit"
diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer
index 04d42976d..adf9675fe 100755
Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ
diff --git a/slsDetectorServers/mythen3DetectorServer/mythen3.c b/slsDetectorServers/mythen3DetectorServer/mythen3.c
index acb39b487..96bf73902 100644
--- a/slsDetectorServers/mythen3DetectorServer/mythen3.c
+++ b/slsDetectorServers/mythen3DetectorServer/mythen3.c
@@ -313,7 +313,7 @@ patternParameters *setChannelRegisterChip(int ichip, char *mask,
chanReg, ichip * NCHAN + ich * NCOUNTERS,
ichip * NCHAN_1_COUNTER + ich, ichip, ich));
}
- for (int i = 0; i < 24; i++) {
+ for (int i = 0; i < 23; i++) {
patword = clearBit(SIGNAL_clk, patword);
pat->word[iaddr++] = patword;
diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c
index 215c06ba2..ee8ee9bc5 100644
--- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c
+++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c
@@ -89,7 +89,7 @@ void basictests() {
#endif
if (mapCSP0() == FAIL) {
strcpy(initErrorMessage,
- "Could not map to memory. Dangerous to continue.\n");
+ "Could not map to memory. Cannot proceed. Check Firmware.\n");
LOG(logERROR, (initErrorMessage));
initError = FAIL;
}
@@ -99,8 +99,10 @@ void basictests() {
((validateKernelVersion(KERNEL_DATE_VRSN) == FAIL) ||
(checkType() == FAIL) || (testFpga() == FAIL) ||
(testBus() == FAIL))) {
- strcpy(initErrorMessage, "Could not pass basic tests of FPGA and bus. "
- "Dangerous to continue.\n");
+ sprintf(initErrorMessage,
+ "Could not pass basic tests of FPGA and bus. Cannot proceed. "
+ "Check Firmware. (Firmware version:0x%llx) \n",
+ getFirmwareVersion());
LOG(logERROR, ("%s\n\n", initErrorMessage));
initError = FAIL;
return;
@@ -388,7 +390,7 @@ void initStopServer() {
if (mapCSP0() == FAIL) {
initError = FAIL;
strcpy(initErrorMessage,
- "Stop Server: Map Fail. Dangerous to continue. Goodbye!\n");
+ "Stop Server: Map Fail. Cannot proceed. Check Firmware. \n");
LOG(logERROR, (initErrorMessage));
initCheckDone = 1;
return;
diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h
index f908a9494..e9e020ca0 100644
--- a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h
+++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h
@@ -3,7 +3,7 @@
#pragma once
#include "sls/sls_detector_defs.h"
-#define REQRD_FRMWRE_VRSN (0x220824)
+#define REQRD_FRMWRE_VRSN (0x230124)
#define KERNEL_DATE_VRSN "Mon May 10 18:00:21 CEST 2021"
#define ID_FILE "detid_mythen3.txt"
@@ -57,10 +57,10 @@
#define DEFAULT_TRIMBIT_VALUE (0)
#define DEFAULT_COUNTER_DISABLED_VTH_VAL (2800)
-#define DEFAULT_READOUT_C0 (12) //(083333333) // rdo_clk, 83.33 MHz
-#define DEFAULT_READOUT_C1 (12) //(083333333) // rdo_smp_clk, 83.33 MHz
-#define DEFAULT_SYSTEM_C0 (20) //(050000000) // run_clk, 20 MHz
-#define DEFAULT_SYSTEM_C1 (8) //(125000000) // str_clk, 125 MHz const
+#define DEFAULT_READOUT_C0 (10) //(100000000) // rdo_clk, 100 MHz
+#define DEFAULT_READOUT_C1 (10) //(100000000) // rdo_smp_clk, 100 MHz
+#define DEFAULT_SYSTEM_C0 (10) //(100000000) // run_clk, 100 MHz
+#define DEFAULT_SYSTEM_C1 (6) //(166666666) // str_clk, 166 MHz const
#define DEFAULT_SYSTEM_C2 (5) //(200000000) // smp_clk, 200 MHz const
#define DEFAULT_TRIMMING_RUN_CLKDIV (40) // (25000000) // 25 MHz
diff --git a/slsDetectorServers/slsDetectorServer/include/ALTERA_PLL.h b/slsDetectorServers/slsDetectorServer/include/ALTERA_PLL.h
index 57e6fac7d..bdf5a7fcf 100644
--- a/slsDetectorServers/slsDetectorServer/include/ALTERA_PLL.h
+++ b/slsDetectorServers/slsDetectorServer/include/ALTERA_PLL.h
@@ -4,7 +4,7 @@
#include
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
/**
* Set Defines
* @param creg control register
@@ -14,8 +14,9 @@
* @param prmsk pll reset mask
* @param amsk address mask
* @param aofst address offset
- * @param wd2msk write parameter mask for pll for dbit clock (Jungfrau only)
- * @param clk2Index clkIndex of second pll (Jungfrau only)
+ * @param wd2msk write parameter mask for pll for dbit clock (Jungfrau/moench
+ * only)
+ * @param clk2Index clkIndex of second pll (Jungfrau/moench only)
*/
void ALTERA_PLL_SetDefines(uint32_t creg, uint32_t preg, uint32_t rprmsk,
uint32_t wpmsk, uint32_t prmsk, uint32_t amsk,
@@ -50,8 +51,8 @@ void ALTERA_PLL_ResetPLLAndReconfiguration();
* Set PLL Reconfig register
* @param reg register
* @param val value
- * @param useDefaultWRMask only jungfrau for dbit clk (clkindex1, use second WR
- * mask)
+ * @param useDefaultWRMask only jungfrau/moench for dbit clk (clkindex1, use
+ * second WR mask)
*/
void ALTERA_PLL_SetPllReconfigReg(uint32_t reg, uint32_t val,
int useSecondWRMask);
diff --git a/slsDetectorServers/slsDetectorServer/include/loadPattern.h b/slsDetectorServers/slsDetectorServer/include/loadPattern.h
index e6a23bf43..dfc040270 100644
--- a/slsDetectorServers/slsDetectorServer/include/loadPattern.h
+++ b/slsDetectorServers/slsDetectorServer/include/loadPattern.h
@@ -6,7 +6,7 @@
#include "clogger.h"
void initializePatternAddresses();
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#ifdef CHIPTESTBOARDD
#ifdef VIRTUAL
void initializePatternWord();
#endif
diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h
index 71eaedf05..0570be4a5 100644
--- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h
+++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h
@@ -6,8 +6,8 @@
#include "AD9252.h" // old board compatibility
#include "clogger.h" // runState(enum TLogLevel)
#endif
-#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || \
- defined(MOENCHD)
+#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MOENCHD) || \
+ defined(CHIPTESTBOARDD)
#include "AD9257.h" // commonServerFunctions.h, blackfin.h, ansi.h
#endif
@@ -20,8 +20,8 @@
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
#include "nios.h"
-#elif defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || \
- defined(MOENCHD)
+#elif defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MOENCHD) || \
+ defined(CHIPTESTBOARDD)
#include "blackfin.h"
#endif
@@ -61,15 +61,16 @@ typedef struct udpStruct_s {
int isInitCheckDone();
int getInitResult(char **mess);
void basictests();
-#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || \
- defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
+#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MOENCHD) || \
+ defined(CHIPTESTBOARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
int checkType();
int testFpga();
int testBus();
#endif
#if defined(GOTTHARDD) || \
- ((defined(EIGERD) || defined(JUNGFRAUD)) && defined(VIRTUAL))
+ ((defined(EIGERD) || defined(JUNGFRAUD) || defined(MOENCHD)) && \
+ defined(VIRTUAL))
void setTestImageMode(int ival);
int getTestImageMode();
#endif
@@ -77,19 +78,24 @@ int getTestImageMode();
// Ids
void getServerVersion(char *version);
u_int64_t getFirmwareVersion();
+#ifdef EIGERD
+uint64_t getFrontEndFirmwareVersion(enum fpgaPosition fpgaPosition);
+#endif
u_int64_t getFirmwareAPIVersion();
-#ifndef EIGERD
void getHardwareVersion(char *version);
+#ifdef EIGERD
+int getHardwareVersionNumber();
+#else
u_int16_t getHardwareVersionNumber();
#endif
-#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD)
u_int16_t getHardwareSerialNumber();
#endif
-#if defined(JUNGFRAUD) || defined(GOTTHARD2D) || defined(MYTHEN3D) || \
- defined(GOTTHARDD)
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARD2D) || \
+ defined(MYTHEN3D) || defined(GOTTHARDD)
int isHardwareVersion_1_0();
#endif
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
int getChipVersion();
void setChipVersion(int version);
#endif
@@ -98,7 +104,7 @@ u_int32_t getDetectorNumber();
#endif
#if defined(GOTTHARD2D) || defined(EIGERD) || defined(MYTHEN3D) || \
- defined(JUNGFRAUD)
+ defined(JUNGFRAUD) || defined(MOENCHD)
int getModuleId(int *ret, char *mess);
int updateModuleId();
#ifndef EIGERD
@@ -125,7 +131,7 @@ void checkVirtual9MFlag();
void allocateDetectorStructureMemory();
#endif
void setupDetector();
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(CHIPTESTBOARDD)
int updateDatabytesandAllocateRAM();
void updateDataBytes();
#endif
@@ -141,7 +147,8 @@ void setASICDefaults();
#ifdef MYTHEN3D
void setADIFDefaults();
#endif
-#if defined(GOTTHARD2D) || defined(EIGERD) || defined(JUNGFRAUD)
+#if defined(GOTTHARD2D) || defined(EIGERD) || defined(JUNGFRAUD) || \
+ defined(MOENCHD)
int readConfigFile();
#endif
#if defined(GOTTHARDD) || defined(GOTTHARD2D) || defined(EIGERD) || \
@@ -157,14 +164,13 @@ void resetToHardwareSettings();
int writeRegister(uint32_t offset, uint32_t data);
int readRegister(uint32_t offset, uint32_t *retval);
#elif GOTTHARDD
-uint32_t
-writeRegister16And32(uint32_t offset,
- uint32_t data); // FIXME its not there in ctb or moench?
+uint32_t writeRegister16And32(uint32_t offset,
+ uint32_t data); // FIXME its not there in ctb
uint32_t readRegister16And32(uint32_t offset);
#endif
// firmware functions (resets)
-#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || \
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD) || \
defined(MYTHEN3D) || defined(GOTTHARD2D)
void cleanFifos();
void resetCore();
@@ -189,11 +195,11 @@ int getDynamicRange(int *retval);
int setROI(ROI arg);
ROI getROI();
#endif
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
void setADCInvertRegister(uint32_t val);
uint32_t getADCInvertRegister();
#endif
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(CHIPTESTBOARDD)
int setADCEnableMask(uint32_t mask);
uint32_t getADCEnableMask();
void setADCEnableMask_10G(uint32_t mask);
@@ -221,11 +227,11 @@ int getReadoutMode();
#endif
// parameters - timer
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD)
int selectStoragecellStart(int pos);
int getMaxStoragecellStart();
#endif
-#if defined(JUNGFRAUD) || defined(EIGERD) || defined(MOENCHD) || \
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(EIGERD) || \
defined(CHIPTESTBOARDD)
int setNextFrameNumber(uint64_t value);
int getNextFrameNumber(uint64_t *value);
@@ -265,13 +271,13 @@ int64_t getSubDeadTime();
int64_t getMeasuredPeriod();
int64_t getMeasuredSubPeriod();
#endif
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD)
void setNumAdditionalStorageCells(int val);
int getNumAdditionalStorageCells();
int setStorageCellDelay(int64_t val);
int64_t getStorageCellDelay();
#endif
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(CHIPTESTBOARDD)
int setNumAnalogSamples(int val);
int getNumAnalogSamples();
#endif
@@ -286,8 +292,8 @@ uint32_t getCounterMask();
void updatePacketizing();
#endif
-#if defined(JUNGFRAUD) || defined(GOTTHARDD) || defined(CHIPTESTBOARDD) || \
- defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARDD) || \
+ defined(CHIPTESTBOARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
int setDelayAfterTrigger(int64_t val);
int64_t getDelayAfterTrigger();
int64_t getNumFramesLeft();
@@ -301,7 +307,7 @@ int64_t getNumBurstsLeft();
#ifdef GOTTHARDD
int64_t getExpTimeLeft();
#endif
-#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || \
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD) || \
defined(MYTHEN3D) || defined(GOTTHARD2D)
int64_t getFramesFromStart();
int64_t getActualTime();
@@ -312,7 +318,7 @@ int64_t getMeasurementTime();
#if defined(MYTHEN3D) || defined(EIGERD)
void getModule(sls_detector_module *myMod);
#endif
-#if (!defined(CHIPTESTBOARDD)) && (!defined(MOENCHD)) && (!defined(GOTTHARD2D))
+#if (!defined(CHIPTESTBOARDD)) && (!defined(GOTTHARD2D))
int setModule(sls_detector_module myMod, char *mess);
#endif
@@ -328,7 +334,7 @@ int getAllTrimbits();
enum detectorSettings setSettings(enum detectorSettings sett);
#endif
enum detectorSettings getSettings();
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
enum gainMode getGainMode();
void setGainMode(enum gainMode mode);
#endif
@@ -357,7 +363,7 @@ void setDAC(enum DACINDEX ind, int val, int mV);
#endif
int getDAC(enum DACINDEX ind, int mV);
int getMaxDacSteps();
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(CHIPTESTBOARDD)
int dacToVoltage(int dac);
int checkVLimitCompliant(int mV);
int checkVLimitDacCompliant(int dac);
@@ -380,14 +386,15 @@ void powerOff();
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
int getADC(enum ADCINDEX ind, int *value);
-#elif !defined(MOENCHD)
+#else
int getADC(enum ADCINDEX ind);
#endif
int setHighVoltage(int val);
// parameters - timing, extsig
-#if defined(EIGERD) || defined(GOTTHARD2D) || defined(JUNGFRAUD)
+#if defined(EIGERD) || defined(GOTTHARD2D) || defined(JUNGFRAUD) || \
+ defined(MOENCHD)
int setMaster(enum MASTERINDEX m);
#endif
#ifdef EIGERD
@@ -395,11 +402,11 @@ int setTop(enum TOPINDEX t);
int isTop(int *retval);
#endif
#if defined(MYTHEN3D) || defined(EIGERD) || defined(GOTTHARDD) || \
- defined(GOTTHARD2D) || defined(JUNGFRAUD)
+ defined(GOTTHARD2D) || defined(JUNGFRAUD) || defined(MOENCHD)
int isMaster(int *retval);
#endif
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
int getSynchronization();
void setSynchronization(int enable);
#endif
@@ -430,29 +437,30 @@ int getExtSignal(int signalIndex);
#ifdef GOTTHARDD
void calcChecksum(mac_conf *mac, int sourceip, int destip);
#endif
-#if defined(JUNGFRAUD) || defined(GOTTHARD2D)
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARD2D)
void setNumberofUDPInterfaces(int val);
#endif
int getNumberofUDPInterfaces();
-#if defined(JUNGFRAUD) || defined(EIGERD) || defined(MYTHEN3D) || \
- defined(GOTTHARD2D)
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(EIGERD) || \
+ defined(MYTHEN3D) || defined(GOTTHARD2D)
int getNumberofDestinations(int *retval);
int setNumberofDestinations(int value);
#endif
-#if defined(JUNGFRAUD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(MYTHEN3D) || \
+ defined(GOTTHARD2D)
int getFirstUDPDestination();
void setFirstUDPDestination(int value);
#endif
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
void selectPrimaryInterface(int val);
int getPrimaryInterface();
void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip,
uint64_t destmac, uint32_t destport, uint64_t sourcemac,
uint32_t sourceip, uint32_t sourceport);
#endif
-#if defined(JUNGFRAUD) || defined(GOTTHARD2D) || defined(MYTHEN3D) || \
- defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARD2D) || \
+ defined(MYTHEN3D) || defined(CHIPTESTBOARDD)
void calcChecksum(udp_header *udp);
#endif
#ifdef GOTTHARDD
@@ -471,22 +479,15 @@ int getInterruptSubframe();
int setReadNRows(int value);
int getReadNRows();
#endif
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(EIGERD) || \
- defined(MYTHEN3D)
+#if defined(CHIPTESTBOARDD) || defined(EIGERD) || defined(MYTHEN3D)
int enableTenGigabitEthernet(int val);
#endif
// very detector specific
-// moench specific - powerchip
-#ifdef MOENCHD
-int powerChip(int on);
-int setAnalogOnlyReadout();
-#endif
-
-// chip test board or moench specific - configure frequency, phase, pll,
+// chip test board specific - configure frequency, phase, pll,
// flashing firmware
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(CHIPTESTBOARDD)
int setPhase(enum CLKINDEX ind, int val, int degrees);
int getPhase(enum CLKINDEX ind, int degrees);
int getMaxPhase(enum CLKINDEX ind);
@@ -505,9 +506,9 @@ int setLEDEnable(int enable);
void setDigitalIODelay(uint64_t pinMask, int delay);
#endif
-// jungfrau specific - powerchip, autocompdisable, clockdiv, asictimer, clock,
-// pll, flashing firmware
-#ifdef JUNGFRAUD
+// jungfrau/moench specific - powerchip, autocompdisable, clockdiv, asictimer,
+// clock, pll, flashing firmware
+#if defined(JUNGFRAUD) || defined(MOENCHD)
int setReadNRows(int value);
int getReadNRows();
void initReadoutConfiguration();
@@ -517,7 +518,9 @@ void configureChip();
int autoCompDisable(int on);
int setComparatorDisableTime(int64_t val);
int64_t getComparatorDisableTime();
+#ifndef MOENCHD
void configureASICTimer();
+#endif
int setReadoutSpeed(int val);
int getReadoutSpeed(int *retval);
int setPhase(enum CLKINDEX ind, int val, int degrees);
@@ -637,11 +640,12 @@ int setBadChannels(int numChannels, int *channelList);
int *getBadChannels(int *numChannels);
#endif
-#if defined(JUNGFRAUD) || defined(EIGERD)
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(EIGERD)
int getTenGigaFlowControl();
int setTenGigaFlowControl(int value);
#endif
-#if defined(JUNGFRAUD) || defined(EIGERD) || defined(MYTHEN3D)
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(EIGERD) || \
+ defined(MYTHEN3D)
int getTransmissionDelayFrame();
int setTransmissionDelayFrame(int value);
#endif
@@ -661,14 +665,14 @@ int stopStateMachine();
#ifdef MYTHEN3D
int softwareTrigger();
#endif
-#if defined(EIGERD) || defined(JUNGFRAUD)
+#if defined(EIGERD) || defined(JUNGFRAUD) || defined(MOENCHD)
int softwareTrigger(int block);
#endif
#if defined(EIGERD) || defined(MYTHEN3D)
int startReadOut();
#endif
enum runStatus getRunStatus();
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(CHIPTESTBOARDD)
void readFrames(int *ret, char *mess);
#endif
#ifdef EIGERD
@@ -676,7 +680,7 @@ void waitForAcquisitionEnd(int *ret, char *mess);
#else
void waitForAcquisitionEnd();
#endif
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(CHIPTESTBOARDD)
void readandSendUDPFrames(int *ret, char *mess);
void unsetFifoReadStrobes();
void readSample(int ns);
@@ -685,8 +689,8 @@ int checkFifoForEndOfAcquisition();
int readFrameFromFifo();
#endif
-#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || \
- defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
+#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MOENCHD) || \
+ defined(CHIPTESTBOARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
u_int32_t runBusy();
#endif
@@ -697,7 +701,7 @@ u_int32_t runState(enum TLogLevel lev);
// common
int calculateDataBytes();
int getTotalNumberOfChannels();
-#if defined(MOENCHD) || defined(CHIPTESTBOARDD)
+#if defined(CHIPTESTBOARDD)
void getNumberOfChannels(int *nchanx, int *nchany);
#endif
int getNumberOfChips();
diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h
index 65ea37fbd..bbfdf26c5 100644
--- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h
+++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h
@@ -306,3 +306,4 @@ int get_module(int);
int get_synchronization(int);
int set_synchronization(int);
int get_hardware_version(int);
+int get_frontend_firmware_version(int);
diff --git a/slsDetectorServers/slsDetectorServer/src/AD9257.c b/slsDetectorServers/slsDetectorServer/src/AD9257.c
index 7d49d4f0e..20502922d 100644
--- a/slsDetectorServers/slsDetectorServer/src/AD9257.c
+++ b/slsDetectorServers/slsDetectorServer/src/AD9257.c
@@ -300,7 +300,7 @@ void AD9257_Configure() {
AD9257_CLK_CH_IFCO_MSK);
// vref
-#if defined(GOTTHARDD) || defined(MOENCHD)
+#ifdef GOTTHARDD
LOG(logINFO, ("\tVref default at 2.0\n"));
AD9257_SetVrefVoltage(AD9257_VREF_DEFAULT_VAL, 0);
#else
diff --git a/slsDetectorServers/slsDetectorServer/src/ALTERA_PLL.c b/slsDetectorServers/slsDetectorServer/src/ALTERA_PLL.c
index 230d3f241..1b7960933 100644
--- a/slsDetectorServers/slsDetectorServer/src/ALTERA_PLL.c
+++ b/slsDetectorServers/slsDetectorServer/src/ALTERA_PLL.c
@@ -127,7 +127,7 @@ uint32_t ALTERA_PLL_Cntrl_Reg = 0x0;
uint32_t ALTERA_PLL_Param_Reg = 0x0;
uint32_t ALTERA_PLL_Cntrl_RcnfgPrmtrRstMask = 0x0;
uint32_t ALTERA_PLL_Cntrl_WrPrmtrMask = 0x0;
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
uint32_t ALTERA_PLL_Cntrl_DBIT_PLL_WrPrmtrMask = 0x0;
int ALTERA_PLL_Cntrl_DBIT_ClkIndex = 0;
@@ -136,7 +136,7 @@ uint32_t ALTERA_PLL_Cntrl_PLLRstMask = 0x0;
uint32_t ALTERA_PLL_Cntrl_AddrMask = 0x0;
int ALTERA_PLL_Cntrl_AddrOfst = 0;
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
void ALTERA_PLL_SetDefines(uint32_t creg, uint32_t preg, uint32_t rprmsk,
uint32_t wpmsk, uint32_t prmsk, uint32_t amsk,
int aofst, uint32_t wd2msk, int clk2Index) {
@@ -201,7 +201,7 @@ void ALTERA_PLL_SetPllReconfigReg(uint32_t reg, uint32_t val,
reg, val, useSecondWRMask));
uint32_t wrmask = ALTERA_PLL_Cntrl_WrPrmtrMask;
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
if (useSecondWRMask) {
wrmask = ALTERA_PLL_Cntrl_DBIT_PLL_WrPrmtrMask;
}
@@ -252,7 +252,7 @@ void ALTERA_PLL_SetPhaseShift(int32_t phase, int clkIndex, int pos) {
LOG(logDEBUG1, ("C%d phase word:0x%08x\n", clkIndex, value));
int useSecondWR = 0;
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
if (clkIndex == ALTERA_PLL_Cntrl_DBIT_ClkIndex) {
useSecondWR = 1;
}
diff --git a/slsDetectorServers/slsDetectorServer/src/common.c b/slsDetectorServers/slsDetectorServer/src/common.c
index eca942733..3a00038e3 100644
--- a/slsDetectorServers/slsDetectorServer/src/common.c
+++ b/slsDetectorServers/slsDetectorServer/src/common.c
@@ -224,9 +224,10 @@ int getModuleIdInFile(int *ret, char *mess, char *fileName) {
// open id file
FILE *fd = fopen(fname, "r");
if (fd == NULL) {
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
*ret = OK;
- LOG(logWARNING, ("Could not find detid_jungfrau.txt to set module id\n"));
+ LOG(logWARNING, ("Could not find detid file to set module id. "
+ "Continuing without.\n"));
return 0;
#else
*ret = FAIL;
@@ -484,7 +485,7 @@ int setupDetectorServer(char *mess, char *sname) {
// blackfin boards (respawn) (only kept for backwards compatibility)
#ifndef VIRTUAL
-#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || \
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD) || \
defined(GOTTHARDD)
// delete every line with DetectorServer in /etc/inittab
strcpy(cmd, "sed -i '/DetectorServer/d' /etc/inittab");
diff --git a/slsDetectorServers/slsDetectorServer/src/loadPattern.c b/slsDetectorServers/slsDetectorServer/src/loadPattern.c
index 017b99b00..e0e0db094 100644
--- a/slsDetectorServers/slsDetectorServer/src/loadPattern.c
+++ b/slsDetectorServers/slsDetectorServer/src/loadPattern.c
@@ -13,7 +13,7 @@
extern enum TLogLevel trimmingPrint;
#endif
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#ifdef CHIPTESTBOARDD
#ifdef VIRTUAL
uint64_t virtual_pattern[MAX_PATTERN_LENGTH];
#endif
@@ -40,7 +40,7 @@ void initializePatternAddresses() {
}
}
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#ifdef CHIPTESTBOARDD
#ifdef VIRTUAL
void initializePatternWord() {
memset(virtual_pattern, 0, sizeof(virtual_pattern));
@@ -128,7 +128,7 @@ int validate_writePatternWord(char *message, int addr, uint64_t word) {
// validate result
int ret = OK;
- // cannot validate for moench, ctb ( same as executing pattern word)
+ // cannot validate for ctb ( same as executing pattern word)
#ifdef MYTHEN3D
uint64_t retval = readPatternWord(addr);
LOG(logDEBUG1, ("Pattern word (addr:0x%x) retval: 0x%llx\n", addr,
diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c
index 3542ba431..43e2a6345 100644
--- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c
+++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c
@@ -88,7 +88,7 @@ int main(int argc, char *argv[]) {
"and "
"initial detector setup. \n"
"\t-i, --ignore-config : "
- "[Eiger][Jungfrau][Gotthard][Gotthard2] \n"
+ "[Eiger][Jungfrau][Gotthard][Gotthard2][Moench] \n"
"\t Ignore config file. \n"
"\t-m, --master : "
"[Eiger][Mythen3][Gotthard][Gotthard2] \n"
@@ -205,7 +205,7 @@ int main(int argc, char *argv[]) {
case 'i':
#if defined(EIGERD) || defined(GOTTHARDD) || defined(GOTTHARD2D) || \
- defined(JUNGFRAUD)
+ defined(JUNGFRAUD) || defined(MOENCHD)
LOG(logINFO, ("Ignoring config file\n"));
ignoreConfigFileFlag = 1;
#else
diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c
index 6419060a0..229911c1f 100644
--- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c
+++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c
@@ -7,7 +7,7 @@
#include "sls/sls_detector_funcs.h"
#include "slsDetectorFunctionList.h"
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D)
+#if defined(CHIPTESTBOARDD) || defined(MYTHEN3D)
#include "Pattern.h"
#include "loadPattern.h"
#endif
@@ -87,7 +87,8 @@ int updateModeAllowedFunction(int file_des) {
F_PROGRAM_FPGA, F_RESET_FPGA, F_INITIAL_CHECKS,
F_REBOOT_CONTROLLER, F_GET_KERNEL_VERSION, F_UPDATE_KERNEL,
F_UPDATE_DETECTOR_SERVER, F_GET_UPDATE_MODE, F_SET_UPDATE_MODE,
- F_GET_NUM_CHANNELS, F_GET_NUM_INTERFACES, F_ACTIVATE};
+ F_GET_NUM_CHANNELS, F_GET_NUM_INTERFACES, F_ACTIVATE,
+ F_GET_HARDWARE_VERSION};
size_t allowedFuncsSize = sizeof(allowedFuncs) / sizeof(enum detFuncs);
for (unsigned int i = 0; i < allowedFuncsSize; ++i) {
@@ -470,6 +471,7 @@ void function_table() {
flist[F_GET_SYNCHRONIZATION] = &get_synchronization;
flist[F_SET_SYNCHRONIZATION] = &set_synchronization;
flist[F_GET_HARDWARE_VERSION] = &get_hardware_version;
+ flist[F_GET_FRONTEND_FIRMWARE_VERSION] = &get_frontend_firmware_version;
// check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@@ -546,8 +548,8 @@ int M_nofunc(int file_des) {
ret = FAIL;
memset(mess, 0, sizeof(mess));
- sprintf(mess, "Unrecognized Function enum %d. Please do not proceed.\n",
- fnum);
+ sprintf(mess, "%s Function enum %d. Please do not proceed.\n",
+ UNRECOGNIZED_FNUM_ENUM, fnum);
LOG(logERROR, (mess));
return Server_SendResult(file_des, OTHER, NULL, 0);
}
@@ -730,8 +732,14 @@ int get_firmware_version(int file_des) {
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
retval = getFirmwareVersion();
- LOG(logDEBUG1,
- ("firmware version retval: 0x%llx\n", (long long int)retval));
+ if (retval == 0) {
+ ret = FAIL;
+ strcpy(mess, "Could not get firmware version\n");
+ LOG(logERROR, (mess));
+ } else {
+ LOG(logDEBUG1,
+ ("firmware version retval: 0x%llx\n", (long long int)retval));
+ }
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
}
@@ -763,8 +771,8 @@ int set_firmware_test(int file_des) {
memset(mess, 0, sizeof(mess));
LOG(logDEBUG1, ("Executing firmware test\n"));
-#if !defined(GOTTHARDD) && !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && \
- !defined(MOENCHD) && !defined(GOTTHARD2D) && !defined(MYTHEN3D)
+#if !defined(GOTTHARDD) && !defined(JUNGFRAUD) && !defined(MOENCHD) && \
+ !defined(CHIPTESTBOARDD) && !defined(GOTTHARD2D) && !defined(MYTHEN3D)
functionNotImplemented();
#else
ret = testFpga();
@@ -781,8 +789,8 @@ int set_bus_test(int file_des) {
memset(mess, 0, sizeof(mess));
LOG(logDEBUG1, ("Executing bus test\n"));
-#if !defined(GOTTHARDD) && !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && \
- !defined(MOENCHD) && !defined(GOTTHARD2D) && !defined(MYTHEN3D)
+#if !defined(GOTTHARDD) && !defined(JUNGFRAUD) && !defined(MOENCHD) && \
+ !defined(CHIPTESTBOARDD) && !defined(GOTTHARD2D) && !defined(MYTHEN3D)
functionNotImplemented();
#else
ret = testBus();
@@ -804,7 +812,8 @@ int set_image_test_mode(int file_des) {
LOG(logDEBUG1, ("Setting image test mode to \n", arg));
#if defined(GOTTHARDD) || \
- ((defined(EIGERD) || defined(JUNGFRAUD)) && defined(VIRTUAL))
+ ((defined(EIGERD) || defined(JUNGFRAUD) || defined(MOENCHD)) && \
+ defined(VIRTUAL))
setTestImageMode(arg);
#else
functionNotImplemented();
@@ -819,7 +828,8 @@ int get_image_test_mode(int file_des) {
LOG(logDEBUG1, ("Getting image test mode\n"));
#if defined(GOTTHARDD) || \
- ((defined(EIGERD) || defined(JUNGFRAUD)) && defined(VIRTUAL))
+ ((defined(EIGERD) || defined(JUNGFRAUD) || defined(MOENCHD)) && \
+ defined(VIRTUAL))
retval = getTestImageMode();
LOG(logDEBUG1, ("image test mode retval: %d\n", retval));
#else
@@ -928,31 +938,6 @@ enum DACINDEX getDACIndex(enum dacIndex ind) {
case V_POWER_CHIP:
serverDacIndex = D_PWR_CHIP;
break;
-#elif MOENCHD
- case VBP_COLBUF:
- serverDacIndex = MO_VBP_COLBUF;
- break;
- case VIPRE:
- serverDacIndex = MO_VIPRE;
- break;
- case VIN_CM:
- serverDacIndex = MO_VIN_CM;
- break;
- case VB_SDA:
- serverDacIndex = MO_VB_SDA;
- break;
- case VCASC_SFP:
- serverDacIndex = MO_VCASC_SFP;
- break;
- case VOUT_CM:
- serverDacIndex = MO_VOUT_CM;
- break;
- case VIPRE_CDS:
- serverDacIndex = MO_VIPRE_CDS;
- break;
- case IBIAS_SFP:
- serverDacIndex = MO_IBIAS_SFP;
- break;
#elif MYTHEN3D
case VCASSH:
serverDacIndex = M_VCASSH;
@@ -1050,7 +1035,7 @@ enum DACINDEX getDACIndex(enum dacIndex ind) {
case VCOM_ADC2:
serverDacIndex = G2_VCOM_ADC2;
break;
-#elif JUNGFRAUD
+#elif defined(JUNGFRAUD) || defined(MOENCHD)
case HIGH_VOLTAGE:
break;
case VB_COMP:
@@ -1105,9 +1090,6 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) {
#elif CHIPTESTBOARDD
case ADC_VPP:
case V_LIMIT:
-#elif MOENCHD
- case ADC_VPP:
- case V_LIMIT:
#endif
break;
default:
@@ -1119,7 +1101,7 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) {
}
switch (ind) {
// adc vpp
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(CHIPTESTBOARDD)
case ADC_VPP:
// set
if (val >= 0) {
@@ -1151,7 +1133,7 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) {
case HIGH_VOLTAGE:
retval = setHighVoltage(val);
LOG(logDEBUG1, ("High Voltage: %d\n", retval));
-#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || \
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD) || \
defined(GOTTHARD2D) || defined(MYTHEN3D)
validate(&ret, mess, val, retval, "set high voltage", DEC);
#endif
@@ -1252,7 +1234,7 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) {
break;
#endif
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(CHIPTESTBOARDD)
case V_LIMIT:
if (val >= 0) {
if (!mV) {
@@ -1286,7 +1268,7 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) {
ind, val, getMaxDacSteps());
LOG(logERROR, (mess));
} else {
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(CHIPTESTBOARDD)
if ((val != GET_FLAG && mV && checkVLimitCompliant(val) == FAIL) ||
(val != GET_FLAG && !mV &&
checkVLimitDacCompliant(val) == FAIL)) {
@@ -1384,9 +1366,6 @@ int get_adc(int file_des) {
if (receiveData(file_des, &ind, sizeof(ind), INT32) < 0)
return printSocketReadError();
-#if defined(MOENCHD)
- functionNotImplemented();
-#else
enum ADCINDEX serverAdcIndex = 0;
// get
@@ -1396,7 +1375,7 @@ int get_adc(int file_des) {
serverAdcIndex = TEMP_FPGA;
break;
#endif
-#if defined(GOTTHARDD) || defined(JUNGFRAUD)
+#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MOENCHD)
case TEMPERATURE_FPGA:
serverAdcIndex = TEMP_FPGA;
break;
@@ -1508,7 +1487,6 @@ 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));
}
@@ -1750,7 +1728,7 @@ void validate_settings(enum detectorSettings sett) {
switch (sett) {
#ifdef EIGERD
case STANDARD:
-#elif JUNGFRAUD
+#elif defined(JUNGFRAUD) || defined(MOENCHD)
case GAIN0:
case HIGHGAIN0:
#elif GOTTHARDD
@@ -1763,15 +1741,6 @@ void validate_settings(enum detectorSettings sett) {
case DYNAMICGAIN:
case FIXGAIN1:
case FIXGAIN2:
-#elif MOENCHD
- case G1_HIGHGAIN:
- case G1_LOWGAIN:
- case G2_HIGHCAP_HIGHGAIN:
- case G2_HIGHCAP_LOWGAIN:
- case G2_LOWCAP_HIGHGAIN:
- case G2_LOWCAP_LOWGAIN:
- case G4_HIGHGAIN:
- case G4_LOWGAIN:
#elif MYTHEN3D
case STANDARD:
case FAST:
@@ -1872,7 +1841,7 @@ int acquire(int blocking, int file_des) {
}
// only set
if (Server_VerifyLock() == OK) {
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
// chipv1.1 has to be configured before acquisition
if (getChipVersion() == 11 && !isChipConfigured()) {
ret = FAIL;
@@ -1881,16 +1850,6 @@ int acquire(int blocking, int file_des) {
LOG(logERROR, (mess));
} else
#endif
-#ifdef MOENCHD
- if (getNumAnalogSamples() <= 0) {
- ret = FAIL;
- sprintf(mess,
- "Could not start acquisition. Invalid number of analog "
- "samples: %d.\n",
- getNumAnalogSamples());
- LOG(logERROR, (mess));
- } else
-#endif
#ifdef CHIPTESTBOARDD
if ((getReadoutMode() == ANALOG_AND_DIGITAL ||
getReadoutMode() == ANALOG_ONLY) &&
@@ -2026,7 +1985,7 @@ void *start_state_machine(void *arg) {
ret = startStateMachine();
LOG(logDEBUG2, ("Starting Acquisition ret: %d\n", ret));
if (ret == FAIL) {
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(VIRTUAL)
+#if defined(CHIPTESTBOARDD) || defined(VIRTUAL)
sprintf(mess, "Could not start acquisition. Could not create udp "
"socket in server. Check udp_dstip & udp_dstport.\n");
#else
@@ -2041,7 +2000,7 @@ void *start_state_machine(void *arg) {
break;
}
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(CHIPTESTBOARDD)
readFrames(&ret, mess);
if (ret == FAIL && scan) {
sprintf(scanErrMessage, "Cannot scan at %d. ", scanSteps[i]);
@@ -2206,7 +2165,7 @@ int get_num_additional_storage_cells(int file_des) {
memset(mess, 0, sizeof(mess));
int retval = -1;
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD)
functionNotImplemented();
#else
// get only
@@ -2225,7 +2184,7 @@ int set_num_additional_storage_cells(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting number of addl. storage cells %d\n", arg));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD)
functionNotImplemented();
#else
// only set
@@ -2257,7 +2216,7 @@ int get_num_analog_samples(int file_des) {
memset(mess, 0, sizeof(mess));
int retval = -1;
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD)
+#if !defined(CHIPTESTBOARDD)
functionNotImplemented();
#else
// get only
@@ -2276,21 +2235,11 @@ int set_num_analog_samples(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting number of analog samples %d\n", arg));
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD)
+#if !defined(CHIPTESTBOARDD)
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
-#ifdef MOENCHD
- if (arg % NSAMPLES_PER_ROW != 0) {
- ret = FAIL;
- sprintf(mess,
- "Could not set number of analog samples to %d. Must be "
- "divisible by %d\n",
- arg, NSAMPLES_PER_ROW);
- LOG(logERROR, (mess));
- }
-#endif
if (ret == OK) {
ret = setNumAnalogSamples(arg);
if (ret == FAIL) {
@@ -2512,8 +2461,8 @@ int get_delay_after_trigger(int file_des) {
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
-#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) && !defined(CHIPTESTBOARDD) && \
- !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARDD) && \
+ !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// get only
@@ -2534,8 +2483,8 @@ int set_delay_after_trigger(int file_des) {
LOG(logDEBUG1,
("Setting delay after trigger %lld ns\n", (long long int)arg));
-#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) && !defined(CHIPTESTBOARDD) && \
- !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARDD) && \
+ !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// only set
@@ -2678,7 +2627,7 @@ int get_storage_cell_delay(int file_des) {
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD)
functionNotImplemented();
#else
// get only
@@ -2705,7 +2654,7 @@ int set_storage_cell_delay(int file_des) {
LOG(logDEBUG1,
("Setting storage cell delay %lld ns\n", (long long int)arg));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD)
functionNotImplemented();
#else
// only set
@@ -2744,8 +2693,8 @@ int get_frames_left(int file_des) {
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
-#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) && !defined(CHIPTESTBOARDD) && \
- !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARDD) && \
+ !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// get only
@@ -2760,8 +2709,8 @@ int get_triggers_left(int file_des) {
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
-#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) && !defined(CHIPTESTBOARDD) && \
- !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARDD) && \
+ !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// get only
@@ -2791,8 +2740,9 @@ int get_period_left(int file_des) {
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
-#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) /* && !defined(CHIPTESTBOARDD) \
- && !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)*/
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && \
+ !defined(GOTTHARDD) /* && !defined(CHIPTESTBOARDD) \
+&& !defined(MYTHEN3D) && !defined(GOTTHARD2D)*/
functionNotImplemented();
#else
// get only
@@ -2807,8 +2757,9 @@ int get_delay_after_trigger_left(int file_des) {
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
-#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) /* && !defined(CHIPTESTBOARDD) \
- && !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)*/
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && \
+ !defined(GOTTHARDD) /* && !defined(CHIPTESTBOARDD) \
+&& !defined(MYTHEN3D) && !defined(GOTTHARD2D)*/
functionNotImplemented();
#else
// get only
@@ -2855,7 +2806,7 @@ int get_frames_from_start(int file_des) {
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
-#if !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && \
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && \
!defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
@@ -2871,7 +2822,7 @@ int get_actual_time(int file_des) {
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
-#if !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && \
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && \
!defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
@@ -2887,7 +2838,7 @@ int get_measurement_time(int file_des) {
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
-#if !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && \
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && \
!defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
@@ -2928,8 +2879,8 @@ int set_dynamic_range(int file_des) {
case 16:
case 32:
#endif
-#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || \
- defined(MOENCHD) || defined(GOTTHARD2D)
+#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MOENCHD) || \
+ defined(CHIPTESTBOARDD) || defined(GOTTHARD2D)
case 16:
#endif
if (dr >= 0) {
@@ -3070,7 +3021,8 @@ int enable_ten_giga(int file_des) {
return printSocketReadError();
LOG(logDEBUG, ("Setting 10GbE: %d\n", arg));
-#if defined(JUNGFRAUD) || defined(GOTTHARDD) || defined(GOTTHARD2D)
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARDD) || \
+ defined(GOTTHARD2D)
functionNotImplemented();
#else
// set & get
@@ -3168,7 +3120,7 @@ int set_pattern_io_control(int file_des) {
if (receiveData(file_des, &arg, sizeof(arg), INT64) < 0)
return printSocketReadError();
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD)
+#if !defined(CHIPTESTBOARDD)
functionNotImplemented();
#else
LOG(logDEBUG1,
@@ -3191,7 +3143,7 @@ int set_pattern_word(int file_des) {
if (receiveData(file_des, args, sizeof(args), INT64) < 0)
return printSocketReadError();
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D)
+#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
int addr = (int)args[0];
@@ -3219,7 +3171,7 @@ int set_pattern_loop_addresses(int file_des) {
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError();
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D)
+#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
int loopLevel = args[0];
@@ -3265,7 +3217,7 @@ int set_pattern_loop_cycles(int file_des) {
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError();
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D)
+#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
int loopLevel = args[0];
@@ -3294,7 +3246,7 @@ int set_pattern_wait_addr(int file_des) {
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError();
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D)
+#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
int loopLevel = args[0];
@@ -3323,7 +3275,7 @@ int set_pattern_wait_time(int file_des) {
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError();
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D)
+#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
int loopLevel = (int)args[0];
@@ -3353,7 +3305,7 @@ int set_pattern_mask(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Set Pattern Mask to %d\n", arg));
-#if !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
+#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// only set
@@ -3375,7 +3327,7 @@ int get_pattern_mask(int file_des) {
LOG(logDEBUG1, ("Get Pattern Mask\n"));
-#if !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
+#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// only get
@@ -3396,7 +3348,7 @@ int set_pattern_bit_mask(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Set Pattern Bit Mask to %d\n", arg));
-#if !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
+#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// only set
@@ -3418,7 +3370,7 @@ int get_pattern_bit_mask(int file_des) {
LOG(logDEBUG1, ("Get Pattern Bit Mask\n"));
-#if !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
+#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// only get
@@ -3447,7 +3399,7 @@ int write_adc_register(int file_des) {
#ifndef VIRTUAL
// only set
if (Server_VerifyLock() == OK) {
-#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD)
AD9257_Set(addr, val);
#elif GOTTHARDD
if (isHardwareVersion_1_0()) {
@@ -3614,7 +3566,7 @@ int set_ten_giga_flow_control(int file_des) {
return printSocketReadError();
LOG(logINFO, ("Setting ten giga flow control: %d\n", arg));
-#if !defined(EIGERD) && !defined(JUNGFRAUD)
+#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// only set
@@ -3640,7 +3592,7 @@ int get_ten_giga_flow_control(int file_des) {
LOG(logDEBUG1, ("Getting ten giga flow control\n"));
-#if !defined(EIGERD) && !defined(JUNGFRAUD)
+#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// get only
@@ -3663,7 +3615,8 @@ int set_transmission_delay_frame(int file_des) {
return printSocketReadError();
LOG(logINFO, ("Setting transmission delay frame: %d\n", arg));
-#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MYTHEN3D)
+#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MOENCHD) && \
+ !defined(MYTHEN3D)
functionNotImplemented();
#else
// only set
@@ -3701,7 +3654,8 @@ int get_transmission_delay_frame(int file_des) {
LOG(logDEBUG1, ("Getting transmission delay frame\n"));
-#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MYTHEN3D)
+#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MOENCHD) && \
+ !defined(MYTHEN3D)
functionNotImplemented();
#else
// get only
@@ -3900,7 +3854,7 @@ int power_chip(int file_des) {
LOG(logDEBUG1, ("Power chip: %d\n", retval));
}
validate(&ret, mess, arg, retval, "power on/off chip", DEC);
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
// narrow down error when powering on
if (ret == FAIL && arg > 0) {
if (setTemperatureEvent(GET_FLAG) == 1)
@@ -3965,7 +3919,7 @@ int threshold_temp(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting threshold temperature to %d\n", arg));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// set & get
@@ -3998,7 +3952,7 @@ int temp_control(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting temperature control to %d\n", arg));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// set & get
@@ -4022,7 +3976,7 @@ int temp_event(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting temperature event to %d\n", arg));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// set & get
@@ -4045,7 +3999,7 @@ int auto_comp_disable(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting Auto comp disable to %d\n", arg));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// set & get
@@ -4068,7 +4022,7 @@ int storage_cell_start(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting Storage cell start to %d\n", arg));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD)
functionNotImplemented();
#else
// set & get
@@ -4128,7 +4082,8 @@ int software_trigger(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Software Trigger (block: %d\n", arg));
-#if !defined(EIGERD) && !defined(MYTHEN3D) && !defined(JUNGFRAUD)
+#if !defined(EIGERD) && !defined(MYTHEN3D) && !defined(JUNGFRAUD) && \
+ !defined(MOENCHD)
functionNotImplemented();
#else
if (arg && myDetectorType == MYTHEN3) {
@@ -4243,7 +4198,7 @@ int set_adc_enable_mask(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Seting 1Gb ADC Enable Mask to %u\n", arg));
-#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
+#if (!defined(CHIPTESTBOARDD))
functionNotImplemented();
#else
// only set
@@ -4275,7 +4230,7 @@ int get_adc_enable_mask(int file_des) {
LOG(logDEBUG1, ("Getting 1Gb ADC Enable Mask \n"));
-#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
+#if (!defined(CHIPTESTBOARDD))
functionNotImplemented();
#else
// get
@@ -4294,7 +4249,7 @@ int set_adc_enable_mask_10g(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Seting 10Gb ADC Enable Mask to %u\n", arg));
-#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
+#if (!defined(CHIPTESTBOARDD))
functionNotImplemented();
#else
// only set
@@ -4321,7 +4276,7 @@ int get_adc_enable_mask_10g(int file_des) {
LOG(logDEBUG1, ("Getting 10Gb ADC Enable Mask\n"));
-#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
+#if (!defined(CHIPTESTBOARDD))
functionNotImplemented();
#else
// get
@@ -4340,7 +4295,7 @@ int set_adc_invert(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Seting ADC Invert to %u\n", arg));
-#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD)) && (!defined(JUNGFRAUD))
+#if !defined(CHIPTESTBOARDD) && !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// only set
@@ -4367,7 +4322,7 @@ int get_adc_invert(int file_des) {
LOG(logDEBUG1, ("Getting ADC Invert register \n"));
-#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD)) && (!defined(JUNGFRAUD))
+#if !defined(CHIPTESTBOARDD) && !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// get
@@ -4443,8 +4398,8 @@ int set_next_frame_number(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting next frame number to %llu\n", arg));
-#if (!defined(EIGERD)) && (!defined(JUNGFRAUD)) && (!defined(MOENCHD)) && \
- (!defined(CHIPTESTBOARDD))
+#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MOENCHD) && \
+ !defined(CHIPTESTBOARDD)
functionNotImplemented();
#else
// only set
@@ -4454,7 +4409,7 @@ int set_next_frame_number(int file_des) {
sprintf(mess, "Could not set next frame number. Cannot be 0.\n");
LOG(logERROR, (mess));
}
-#if (defined(EIGERD)) || (defined(MOENCHD)) || (defined(CHIPTESTBOARDD))
+#if (defined(EIGERD)) || (defined(CHIPTESTBOARDD))
else if (arg > UDP_HEADER_MAX_FRAME_VALUE) {
ret = FAIL;
#ifdef VIRTUAL
@@ -4522,8 +4477,8 @@ int get_next_frame_number(int file_des) {
LOG(logDEBUG1, ("Getting next frame number \n"));
-#if (!defined(EIGERD)) && (!defined(JUNGFRAUD)) && (!defined(MOENCHD)) && \
- (!defined(CHIPTESTBOARDD))
+#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MOENCHD) && \
+ !defined(CHIPTESTBOARDD)
functionNotImplemented();
#else
// get
@@ -4659,12 +4614,12 @@ int set_read_n_rows(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting number of rows: %u\n", arg));
-#if !defined(EIGERD) && !defined(JUNGFRAUD)
+#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
- if (arg <= 0 || arg > MAX_ROWS_PER_READOUT) {
+ if (arg < MIN_ROWS_PER_READOUT || arg > MAX_ROWS_PER_READOUT) {
ret = FAIL;
sprintf(mess,
"Could not set read n rows. Must be between %d "
@@ -4694,7 +4649,7 @@ int set_read_n_rows(int file_des) {
maxnl);
LOG(logERROR, (mess));
} else
-#elif JUNGFRAUD
+#elif defined(JUNGFRAUD) || defined(MOENCHD)
if ((check_detector_idle("set number of rows") == OK) &&
(arg % READ_N_ROWS_MULTIPLE != 0)) {
ret = FAIL;
@@ -4740,7 +4695,7 @@ int get_read_n_rows(int file_des) {
LOG(logDEBUG1, ("Getting number of rows\n"));
-#if !defined(EIGERD) && !defined(JUNGFRAUD)
+#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
retval = getReadNRows();
@@ -4768,10 +4723,10 @@ void calculate_and_set_position() {
int pos[2] = {0, 0};
int portGeometry[2] = {1, 1};
- // position does change for eiger and jungfrau (2 interfaces)
+ // position does change for eiger and jungfrau/moench (2 interfaces)
#if defined(EIGERD)
portGeometry[X] = getNumberofUDPInterfaces(); // horz
-#elif defined(JUNGFRAUD)
+#elif defined(JUNGFRAUD) || defined(MOENCHD)
portGeometry[Y] = getNumberofUDPInterfaces(); // vert
#endif
LOG(logDEBUG1, ("moduleIndex:%d maxymods:%d portGeo.x:%d portgeo.y:%d\n",
@@ -4805,7 +4760,7 @@ void calculate_and_set_position() {
udpDetails[iRxEntry].srcmac = udpDetails[0].srcmac;
}
}
-#if defined(JUNGFRAUD) || defined(GOTTHARD2D)
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARD2D)
if (getNumberofUDPInterfaces() > 1) {
if (udpDetails[0].srcmac2 == 0) {
char dmac2[MAC_ADDRESS_SIZE];
@@ -4829,7 +4784,7 @@ void calculate_and_set_position() {
#endif
configure_mac();
}
- // no need to do a get (also jungfrau gives bigger set for second)
+ // no need to do a get (also jungfrau/moench gives bigger set for second)
}
int set_detector_position(int file_des) {
@@ -4898,7 +4853,7 @@ int is_udp_configured() {
return FAIL;
}
#endif
-#if defined(JUNGFRAUD) || defined(GOTTHARD2D)
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARD2D)
if (getNumberofUDPInterfaces() == 2) {
if (udpDetails[i].srcip2 == 0) {
sprintf(configureMessage,
@@ -4937,7 +4892,7 @@ void configure_mac() {
if (is_udp_configured() == OK) {
ret = configureMAC();
if (ret != OK) {
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(CHIPTESTBOARDD)
if (ret == -1) {
sprintf(mess, "Could not allocate RAM\n");
} else {
@@ -5010,7 +4965,7 @@ int set_source_udp_ip2(int file_des) {
arg = __builtin_bswap32(arg);
LOG(logINFO, ("Setting udp source ip2: 0x%x\n", arg));
-#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// only set
@@ -5035,7 +4990,7 @@ int get_source_udp_ip2(int file_des) {
uint32_t retval = -1;
LOG(logDEBUG1, ("Getting udp source ip2\n"));
-#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// get only
@@ -5092,7 +5047,7 @@ int set_dest_udp_ip2(int file_des) {
arg = __builtin_bswap32(arg);
LOG(logINFO, ("Setting udp destination ip2: 0x%x\n", arg));
-#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// only set
@@ -5114,7 +5069,7 @@ int get_dest_udp_ip2(int file_des) {
uint32_t retval = -1;
LOG(logDEBUG1, ("Getting udp destination ip2\n"));
-#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// get only
@@ -5138,11 +5093,20 @@ int set_source_udp_mac(int file_des) {
if (Server_VerifyLock() == OK) {
if (check_detector_idle("configure mac") == OK) {
if (udpDetails[0].srcmac != arg) {
- for (int iRxEntry = 0; iRxEntry != MAX_UDP_DESTINATION;
- ++iRxEntry) {
- udpDetails[iRxEntry].srcmac = arg;
+ // multicast (LSB of first octet = 1)
+ if ((arg >> 40) & 0x1) {
+ ret = FAIL;
+ sprintf(mess,
+ "Cannot set source mac address. Must be a unicast "
+ "address (LSB of first octet should be 0).");
+ LOG(logERROR, (mess));
+ } else {
+ for (int iRxEntry = 0; iRxEntry != MAX_UDP_DESTINATION;
+ ++iRxEntry) {
+ udpDetails[iRxEntry].srcmac = arg;
+ }
+ configure_mac();
}
- configure_mac();
}
}
}
@@ -5171,7 +5135,7 @@ int set_source_udp_mac2(int file_des) {
return printSocketReadError();
LOG(logINFO, ("Setting udp source mac2: 0x%lx\n", arg));
-#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// only set
@@ -5196,7 +5160,7 @@ int get_source_udp_mac2(int file_des) {
uint64_t retval = -1;
LOG(logDEBUG1, ("Getting udp source mac2\n"));
-#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// get only
@@ -5249,7 +5213,7 @@ int set_dest_udp_mac2(int file_des) {
return printSocketReadError();
LOG(logINFO, ("Setting udp destination mac2: 0x%lx\n", arg));
-#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// only set
@@ -5271,7 +5235,7 @@ int get_dest_udp_mac2(int file_des) {
uint64_t retval = -1;
LOG(logDEBUG1, ("Getting udp destination mac2\n"));
-#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// get only
@@ -5324,7 +5288,8 @@ int set_dest_udp_port2(int file_des) {
return printSocketReadError();
LOG(logINFO, ("Setting udp destination port2: %u\n", arg));
-#if !defined(JUNGFRAUD) && !defined(EIGERD) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(EIGERD) && \
+ !defined(GOTTHARD2D)
functionNotImplemented();
#else
// only set
@@ -5346,7 +5311,8 @@ int get_dest_udp_port2(int file_des) {
int retval = -1;
LOG(logDEBUG1, ("Getting destination port2\n"));
-#if !defined(JUNGFRAUD) && !defined(EIGERD) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(EIGERD) && \
+ !defined(GOTTHARD2D)
functionNotImplemented();
#else
// get only
@@ -5365,7 +5331,7 @@ int set_num_interfaces(int file_des) {
return printSocketReadError();
LOG(logINFO, ("Setting number of interfaces: %d\n", arg));
-#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARD2D)
// fixed number of udp interfaces
int num_interfaces = getNumberofUDPInterfaces();
if (arg != num_interfaces) {
@@ -5451,7 +5417,7 @@ int set_interface_sel(int file_des) {
return printSocketReadError();
LOG(logINFO, ("Setting selected interface: %d\n", arg));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// only set
@@ -5478,7 +5444,7 @@ int get_interface_sel(int file_des) {
int retval = -1;
LOG(logDEBUG1, ("Getting selected interface\n"));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// get only
@@ -5666,7 +5632,7 @@ int set_clock_frequency(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting clock (%d) frequency : %u\n", args[0], args[1]));
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD)
+#if !defined(CHIPTESTBOARDD)
functionNotImplemented();
#else
@@ -5729,14 +5695,13 @@ int get_clock_frequency(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Getting clock (%d) frequency\n", arg));
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(GOTTHARD2D) && \
- !defined(MYTHEN3D)
+#if !defined(CHIPTESTBOARDD) && !defined(GOTTHARD2D) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// get only
enum CLKINDEX c = 0;
switch (arg) {
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(CHIPTESTBOARDD)
case ADC_CLOCK:
c = ADC_CLK;
break;
@@ -5785,7 +5750,7 @@ int set_clock_phase(int file_des) {
LOG(logDEBUG1, ("Setting clock (%d) phase: %u %s\n", args[0], args[1],
(args[2] == 0 ? "" : "degrees")));
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(JUNGFRAUD) && \
+#if !defined(CHIPTESTBOARDD) && !defined(JUNGFRAUD) && !defined(MOENCHD) && \
!defined(GOTTHARDD) && !defined(GOTTHARD2D) && !defined(MYTHEN3D)
functionNotImplemented();
#else
@@ -5796,13 +5761,13 @@ int set_clock_phase(int file_des) {
int inDegrees = args[2] == 0 ? 0 : 1;
enum CLKINDEX c = 0;
switch (ind) {
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(JUNGFRAUD) || \
+#if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD) || defined(MOENCHD) || \
defined(GOTTHARDD)
case ADC_CLOCK:
c = ADC_CLK;
break;
#endif
-#if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD)
+#if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD) || defined(MOENCHD)
case DBIT_CLOCK:
c = DBIT_CLK;
break;
@@ -5894,7 +5859,7 @@ int get_clock_phase(int file_des) {
LOG(logINFOBLUE, ("Getting clock (%d) phase %s \n", args[0],
(args[1] == 0 ? "" : "in degrees")));
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(JUNGFRAUD) && \
+#if !defined(CHIPTESTBOARDD) && !defined(JUNGFRAUD) && !defined(MOENCHD) && \
!defined(GOTTHARD2D) && !defined(MYTHEN3D)
functionNotImplemented();
#else
@@ -5903,12 +5868,12 @@ int get_clock_phase(int file_des) {
int inDegrees = args[1] == 0 ? 0 : 1;
enum CLKINDEX c = 0;
switch (ind) {
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(JUNGFRAUD)
+#if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD) || defined(MOENCHD)
case ADC_CLOCK:
c = ADC_CLK;
break;
#endif
-#if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD)
+#if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD) || defined(MOENCHD)
case DBIT_CLOCK:
c = DBIT_CLK;
break;
@@ -5944,19 +5909,19 @@ int get_max_clock_phase_shift(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Getting clock (%d) max phase shift\n", arg));
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(JUNGFRAUD) && \
+#if !defined(CHIPTESTBOARDD) && !defined(JUNGFRAUD) && !defined(MOENCHD) && \
!defined(GOTTHARD2D) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// get only
enum CLKINDEX c = 0;
switch (arg) {
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(JUNGFRAUD)
+#if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD) || defined(MOENCHD)
case ADC_CLOCK:
c = ADC_CLK;
break;
#endif
-#if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD)
+#if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD) || defined(MOENCHD)
case DBIT_CLOCK:
c = DBIT_CLK;
break;
@@ -6003,7 +5968,7 @@ int set_clock_divider(int file_des) {
#endif
modeNotImplemented("clock index (divider set)", args[0]);
}
-
+ // TODO: if value between to set and num clocks, msg = "cannot set"
enum CLKINDEX c = 0;
int val = args[1];
if (ret == OK) {
@@ -6678,7 +6643,7 @@ int set_current_source(int file_des) {
"normal:%d]\n",
enable, fix, (long long int)select, normal));
-#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD)
+#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// only set
@@ -6751,7 +6716,7 @@ int set_current_source(int file_des) {
}
if (ret == OK) {
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
if (enable == 0) {
disableCurrentSource();
} else {
@@ -6778,13 +6743,13 @@ int get_current_source(int file_des) {
LOG(logDEBUG1, ("Getting current source\n"));
-#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD)
+#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// get only
retvals[0] = getCurrentSource();
LOG(logDEBUG1, ("current source enable retval: %u\n", retvals[0]));
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
if (retvals[0]) {
retvals[1] = getFixCurrentSource();
retvals[2] = getNormalCurrentSource();
@@ -6865,7 +6830,7 @@ int get_num_channels(int file_des) {
LOG(logDEBUG1, ("Getting number of channels\n"));
-#if !defined(MOENCHD) && !defined(CHIPTESTBOARDD)
+#if !defined(CHIPTESTBOARDD)
functionNotImplemented();
#else
// get only
@@ -7009,7 +6974,7 @@ int get_receiver_parameters(int file_des) {
return printSocketReadError();
// additional storage cells
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD)
i32 = getNumAdditionalStorageCells();
#else
i32 = 0;
@@ -7019,7 +6984,7 @@ int get_receiver_parameters(int file_des) {
return printSocketReadError();
// analog samples
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(CHIPTESTBOARDD)
i32 = getNumAnalogSamples();
#else
i32 = 0;
@@ -7118,7 +7083,7 @@ int get_receiver_parameters(int file_des) {
return printSocketReadError();
// ReadNRows
-#if defined(EIGERD) || defined(JUNGFRAUD)
+#if defined(EIGERD) || defined(JUNGFRAUD) || defined(MOENCHD)
i32 = getReadNRows();
#else
i32 = 0;
@@ -7158,8 +7123,7 @@ int get_receiver_parameters(int file_des) {
return printSocketReadError();
// 10 gbe
-#if defined(EIGERD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || \
- defined(MYTHEN3D)
+#if defined(EIGERD) || defined(CHIPTESTBOARDD) || defined(MYTHEN3D)
i32 = enableTenGigabitEthernet(GET_FLAG);
#else
i32 = 0;
@@ -7179,7 +7143,7 @@ int get_receiver_parameters(int file_des) {
return printSocketReadError();
// adc mask
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(CHIPTESTBOARDD)
u32 = getADCEnableMask();
#else
u32 = 0;
@@ -7189,7 +7153,7 @@ int get_receiver_parameters(int file_des) {
return printSocketReadError();
// 10g adc mask
-#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
+#if defined(CHIPTESTBOARDD)
u32 = getADCEnableMask_10G();
#else
u32 = 0;
@@ -7561,7 +7525,7 @@ int set_pattern(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D)
+#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
@@ -7589,7 +7553,7 @@ int get_pattern(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D)
+#if !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
return Server_SendResult(file_des, INT32, NULL, 0);
#else
@@ -7800,11 +7764,11 @@ int get_filter_resistor(int file_des) {
LOG(logDEBUG1, ("Getting filter resistor\n"));
-#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD)
+#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// get only
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
if (getChipVersion() == 10) {
ret = FAIL;
strcpy(mess, "Could not get filter cell. Not available for this chip "
@@ -7829,7 +7793,7 @@ int set_filter_resistor(int file_des) {
return printSocketReadError();
LOG(logINFO, ("Setting filter resistor: %u\n", arg));
-#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD)
+#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// only set
@@ -7843,7 +7807,7 @@ int set_filter_resistor(int file_des) {
arg, ASIC_FILTER_MAX_RES_VALUE);
LOG(logERROR, (mess));
}
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
else if (getChipVersion() == 10) {
ret = FAIL;
strcpy(mess, "Could not set filter cell. Not available for this "
@@ -7857,8 +7821,9 @@ int set_filter_resistor(int file_des) {
strcpy(mess, "Could not set filter resistor.\n");
LOG(logERROR, (mess));
}
-#ifndef JUNGFRAUD
- // jungfrau might take time to update status register if acquiring
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
+ // jungfrau/moench might take time to update status register if
+ // acquiring
int retval = getFilterResistor();
LOG(logDEBUG1, ("filter resistor retval: %u\n", retval));
validate(&ret, mess, arg, retval, "set filter resistor", DEC);
@@ -8206,7 +8171,7 @@ int load_default_pattern(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
-#if !defined(MYTHEN3D) && !defined(MOENCHD)
+#if !defined(MYTHEN3D)
functionNotImplemented();
#else
if (Server_VerifyLock() == OK) {
@@ -8245,7 +8210,7 @@ int get_master(int file_des) {
LOG(logDEBUG1, ("Getting master\n"));
#if !defined(MYTHEN3D) && !defined(EIGERD) && !defined(GOTTHARDD) && \
- !defined(GOTTHARD2D) && !defined(JUNGFRAUD)
+ !defined(GOTTHARD2D) && !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
ret = isMaster(&retval);
@@ -8266,7 +8231,8 @@ int set_master(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting master: %u\n", (int)arg));
-#if !defined(EIGERD) && !defined(GOTTHARD2D) && !defined(JUNGFRAUD)
+#if !defined(EIGERD) && !defined(GOTTHARD2D) && !defined(JUNGFRAUD) && \
+ !defined(MOENCHD)
functionNotImplemented();
#else
// only set
@@ -8568,7 +8534,7 @@ int get_chip_version(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
retval = getChipVersion();
@@ -8675,7 +8641,7 @@ int get_gain_mode(int file_des) {
enum gainMode retval = DYNAMIC;
LOG(logDEBUG1, ("Getting gain mode\n"));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// get only
@@ -8699,7 +8665,7 @@ int set_gain_mode(int file_des) {
enum gainMode gainmode = arg;
LOG(logDEBUG1, ("Setting gain mode %d\n", (int)gainmode));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// only set
@@ -8735,7 +8701,7 @@ int get_comp_disable_time(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// get only
@@ -8761,7 +8727,7 @@ int set_comp_disable_time(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting comp disable time %lld ns\n", (long long int)arg));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// only set
@@ -8796,7 +8762,7 @@ int get_flip_rows(int file_des) {
LOG(logDEBUG1, ("Getting flip rows\n"));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// get only
@@ -8822,7 +8788,7 @@ int set_flip_rows(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting flip rows: %u\n", (int)arg));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// only set
@@ -8861,7 +8827,7 @@ int get_num_filter_cells(int file_des) {
LOG(logDEBUG1, ("Getting number of filter cellsn"));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// get only
@@ -8888,7 +8854,7 @@ int set_num_filter_cells(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting number of filter cells: %u\n", (int)arg));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// only set
@@ -8929,7 +8895,7 @@ int set_adc_pipeline(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting adc pipeline : %u\n", arg));
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD)
+#if !defined(CHIPTESTBOARDD)
functionNotImplemented();
#else
@@ -8951,7 +8917,7 @@ int get_adc_pipeline(int file_des) {
LOG(logDEBUG1, ("Getting adc pipeline\n"));
-#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD)
+#if !defined(CHIPTESTBOARDD)
functionNotImplemented();
#else
// get only
@@ -9006,7 +8972,7 @@ int get_module_id(int file_des) {
memset(mess, 0, sizeof(mess));
int retval = -1;
#if !(defined(GOTTHARD2D) || defined(EIGERD) || defined(MYTHEN3D) || \
- defined(JUNGFRAUD))
+ defined(JUNGFRAUD) || defined(MOENCHD))
functionNotImplemented();
#else
retval = getModuleId(&ret, mess);
@@ -9026,8 +8992,8 @@ int get_dest_udp_list(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Getting udp destination list for entry %d\n", arg));
-#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MYTHEN3D) && \
- !defined(GOTTHARD2D)
+#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MOENCHD) && \
+ !defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
if (arg >= MAX_UDP_DESTINATION) {
@@ -9094,8 +9060,8 @@ int set_dest_udp_list(int file_des) {
getMacAddressinString(mac, MAC_ADDRESS_SIZE, args64[0]);
getMacAddressinString(mac2, MAC_ADDRESS_SIZE, args64[1]);
-#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MYTHEN3D) && \
- !defined(GOTTHARD2D)
+#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MOENCHD) && \
+ !defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// only set
@@ -9145,7 +9111,7 @@ int set_dest_udp_list(int file_des) {
// if still 0, set defaults
int twoInterfaces = 0;
-#if defined(JUNGFRAUD) || defined(GOTTHARD2D)
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARD2D)
twoInterfaces = getNumberofUDPInterfaces() == 2 ? 1 : 0;
#endif
udpDetails[entry].srcport = DEFAULT_UDP_SRC_PORTNO;
@@ -9216,8 +9182,8 @@ int get_num_dest_list(int file_des) {
memset(mess, 0, sizeof(mess));
int retval = -1;
-#if !defined(JUNGFRAUD) && !defined(EIGERD) && !defined(MYTHEN3D) && \
- !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(EIGERD) && \
+ !defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
retval = numUdpDestinations;
@@ -9247,8 +9213,8 @@ int clear_all_udp_dst(int file_des) {
// minimum 1 destination in fpga
int numdest = 1;
// set number of destinations
-#if defined(JUNGFRAUD) || defined(EIGERD) || defined(MYTHEN3D) || \
- defined(GOTTHARD2D)
+#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(EIGERD) || \
+ defined(MYTHEN3D) || defined(GOTTHARD2D)
if (setNumberofDestinations(numdest) == FAIL) {
ret = FAIL;
strcpy(mess, "Could not clear udp destinations to 1 entry.\n");
@@ -9275,7 +9241,8 @@ int get_udp_first_dest(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
-#if !defined(JUNGFRAUD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(MYTHEN3D) && \
+ !defined(GOTTHARD2D)
functionNotImplemented();
#else
retval = getFirstUDPDestination();
@@ -9293,7 +9260,8 @@ int set_udp_first_dest(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting first udp destination to %d\n", arg));
-#if !defined(JUNGFRAUD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(MYTHEN3D) && \
+ !defined(GOTTHARD2D)
functionNotImplemented();
#else
// only set
@@ -9322,7 +9290,8 @@ int get_readout_speed(int file_des) {
int retval = -1;
LOG(logDEBUG1, ("Getting readout speed\n"));
-#if !defined(JUNGFRAUD) && !defined(EIGERD) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(EIGERD) && \
+ !defined(GOTTHARD2D)
functionNotImplemented();
#else
// get only
@@ -9345,12 +9314,13 @@ int set_readout_speed(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting readout speed : %u\n", arg));
-#if !defined(JUNGFRAUD) && !defined(EIGERD) && !defined(GOTTHARD2D)
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(EIGERD) && \
+ !defined(GOTTHARD2D)
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
-#ifdef JUNGFRAUD
+#if defined(JUNGFRAUD) || defined(MOENCHD)
if (arg == (int)FULL_SPEED && isHardwareVersion_1_0()) {
ret = FAIL;
strcpy(
@@ -9361,7 +9331,7 @@ int set_readout_speed(int file_des) {
#endif
if (ret == OK) {
switch (arg) {
-#if defined(EIGERD) || defined(JUNGFRAUD)
+#if defined(EIGERD) || defined(JUNGFRAUD) || defined(MOENCHD)
case FULL_SPEED:
case HALF_SPEED:
case QUARTER_SPEED:
@@ -9535,7 +9505,7 @@ void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
char *checksum, char *serverName,
int forceDeleteNormalFile) {
-#if !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && \
+#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && \
!defined(GOTTHARDD)
ret = FAIL;
sprintf(mess,
@@ -10129,7 +10099,7 @@ int get_synchronization(int file_des) {
LOG(logDEBUG1, ("Getting synchronization\n"));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
retval = getSynchronization();
@@ -10146,7 +10116,7 @@ int set_synchronization(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting synchronization: %u\n", (int)arg));
-#ifndef JUNGFRAUD
+#if !defined(JUNGFRAUD) && !defined(MOENCHD)
functionNotImplemented();
#else
// only set
@@ -10174,11 +10144,45 @@ int get_hardware_version(int file_des) {
memset(mess, 0, sizeof(mess));
char retvals[MAX_STR_LENGTH];
memset(retvals, 0, MAX_STR_LENGTH);
-#ifdef EIGERD
- functionNotImplemented();
-#else
getHardwareVersion(retvals);
LOG(logDEBUG1, ("hardware version retval: %s\n", retvals));
-#endif
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
}
+
+int get_frontend_firmware_version(int file_des) {
+ ret = OK;
+ memset(mess, 0, sizeof(mess));
+ enum fpgaPosition arg = FRONT_LEFT;
+ int64_t retval = -1;
+
+ if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
+ return printSocketReadError();
+ LOG(logDEBUG1, ("Getting front end firmware version: %s\n",
+ (arg == FRONT_LEFT ? "left" : "right")));
+
+#if !defined(EIGERD)
+ functionNotImplemented();
+#else
+ switch (arg) {
+ case FRONT_LEFT:
+ case FRONT_RIGHT:
+ break;
+ default:
+ modeNotImplemented("Fpga position Index", (int)arg);
+ break;
+ }
+ if (ret == OK) {
+ retval = getFrontEndFirmwareVersion(arg);
+ if (retval == 0) {
+ ret = FAIL;
+ strcpy(mess, "Could not get febl/r firmware version\n");
+ LOG(logERROR, (mess));
+ } else {
+ LOG(logDEBUG1, ("Front %s version retval: 0x%llx\n",
+ (arg == FRONT_LEFT ? "left" : "right"),
+ (long long int)retval));
+ }
+ }
+#endif
+ return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
+}
\ No newline at end of file
diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h
index d0bb203b0..790a951e1 100644
--- a/slsDetectorSoftware/include/sls/Detector.h
+++ b/slsDetectorSoftware/include/sls/Detector.h
@@ -78,18 +78,22 @@ class Detector {
Result getFirmwareVersion(Positions pos = {}) const;
+ /** [Eiger] Options: FRONT_LEFT, FRONT_RIGHT */
+ Result
+ getFrontEndFirmwareVersion(const defs::fpgaPosition fpgaPosition,
+ Positions pos = {}) const;
+
Result getDetectorServerVersion(Positions pos = {}) const;
- /** [Jungfrau][Gotthard2][Myhten3][Gotthard][Ctb][Moench] */
Result getHardwareVersion(Positions pos = {}) const;
Result getKernelVersion(Positions pos = {}) const;
- /* [Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench] */
+ /* [Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][CTB] */
Result getSerialNumber(Positions pos = {}) const;
- /** [Eiger][Gotthard2][Mythen3][Jungfrau] 6 bit value (ideally unique) that
- * is streamed out in the UDP header of the detector.*/
+ /** [Eiger][Gotthard2][Mythen3][Jungfrau][Moench] 6 bit value (ideally
+ * unique) that is streamed out in the UDP header of the detector.*/
Result getModuleId(Positions pos = {}) const;
Result getReceiverVersion(Positions pos = {}) const;
@@ -122,14 +126,12 @@ class Detector {
/** list of possible settings for this detector */
std::vector getSettingsList() const;
- /** [Jungfrau][Gotthard][Gotthard2][Mythen3] */
+ /** [Jungfrau][Moench][Gotthard][Gotthard2][Mythen3] */
Result getSettings(Positions pos = {}) const;
- /** [Jungfrau] GAIN0, HIGHGAIN0 \n [Gotthard] DYNAMICGAIN, HIGHGAIN,
+ /** [Jungfrau][Moench] GAIN0, HIGHGAIN0 \n [Gotthard] DYNAMICGAIN, HIGHGAIN,
* LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN \n [Gotthard2] DYNAMICGAIN,
- * FIXGAIN1, FIXGAIN2 \n [Moench] G1_HIGHGAIN, G1_LOWGAIN,
- * G2_HIGHCAP_HIGHGAIN, G2_HIGHCAP_LOWGAIN, G2_LOWCAP_HIGHGAIN,
- * G2_LOWCAP_LOWGAIN, G4_HIGHGAIN, G4_LOWGAIN \n [Mythen3] STANDARD, FAST,
+ * FIXGAIN1, FIXGAIN2 \n [Mythen3] STANDARD, FAST,
* HIGHGAIN. Also changes vrshaper and vrpreamp \n [Eiger] Use threshold
* command. Settings loaded from file found in settingspath
*/
@@ -179,38 +181,39 @@ class Detector {
* files exist in corresponding trim folders */
void setTrimEnergies(std::vector energies, Positions pos = {});
- /**[Eiger][Jungfrau] */
+ /**[Eiger][Jungfrau][Moench] */
bool getGapPixelsinCallback() const;
/**
- * [Eiger][Jungfrau]
+ * [Eiger][Jungfrau][Moench]
* Include gap pixels in client data call back. Will not be in detector
* streaming, receiver file or streaming. Default is disabled.
*/
void setGapPixelsinCallback(const bool enable);
- /** [Eiger][Jungfrau] */
+ /** [Eiger][Jungfrau][Moench] */
Result getFlipRows(Positions pos = {}) const;
/** [Eiger] flips rows paramater sent to slsreceiver to stream as json
- * parameter to flip rows in gui \n[Jungfrau] flips rows in the detector
- * itself. For bottom module and number of interfaces must be set to 2.
- * slsReceiver and slsDetectorGui does not handle.slsReceiver and
+ * parameter to flip rows in gui \n[Jungfrau][Moench] flips rows in the
+ * detector itself. For bottom module and number of interfaces must be set
+ * to 2. slsReceiver and slsDetectorGui does not handle.slsReceiver and
* slsDetectorGui does not handle
*/
void setFlipRows(bool value, Positions pos = {});
- /** [Eiger][Mythen3][Gotthard1][Gotthard2][Jungfrau] via stop server **/
+ /** [Eiger][Mythen3][Gotthard1][Gotthard2][Jungfrau][Moench] via stop server
+ * **/
Result getMaster(Positions pos = {}) const;
- /** [Eiger][Gotthard2][Jungfrau] Set (half) module to master and the
+ /** [Eiger][Gotthard2][Jungfrau][Moench] Set (half) module to master and the
* other(s) to slaves */
void setMaster(bool value, int pos);
- /** [Jungfrau] **/
+ /** [Jungfrau][Moench] **/
Result getSynchronization(Positions pos = {}) const;
- /** [Jungfrau] */
+ /** [Jungfrau][Moench] */
void setSynchronization(bool value);
/** [Gotthard2][Mythen3] */
@@ -221,6 +224,17 @@ class Detector {
*/
void setBadChannels(const std::string &fname, Positions pos = {});
+ /** [Gotthard2][Mythen3] */
+ Result> getBadChannels(Positions pos = {}) const;
+
+ /** [Gotthard2][Mythen3] Empty list resets bad channel list */
+ void setBadChannels(const std::vector list, Positions pos = {});
+
+ /** [Gotthard2][Mythen3] Size of list should match number of modules. Each
+ * value is at module level and can start at 0. Empty vector resets bad
+ * channel list. */
+ void setBadChannels(const std::vector> list);
+
Result isVirtualDetectorServer(Positions pos = {}) const;
///@}
@@ -274,11 +288,11 @@ class Detector {
void setNumberOfTriggers(int64_t value);
- /** [Gotthard][Jungfrau][Eiger][CTB][Moench][Gotthard2] \n
+ /** [Gotthard][Jungfrau][Moench][Eiger][CTB][Gotthard2] \n
* [Mythen3] use function with gate index **/
Result getExptime(Positions pos = {}) const;
- /** [Gotthard][Jungfrau][Eiger][CTB][Moench][Gotthard2] \n
+ /** [Gotthard][Jungfrau][Moench][Eiger][CTB][Gotthard2] \n
* [Mythen3] sets exptime for all gate signals. To specify gate index, use
* function with gate index **/
void setExptime(ns t, Positions pos = {});
@@ -287,25 +301,25 @@ class Detector {
void setPeriod(ns t, Positions pos = {});
- /** [Gotthard][Jungfrau][CTB][Moench][Mythen3][Gotthard2] */
+ /** [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] */
Result getDelayAfterTrigger(Positions pos = {}) const;
- /** [Gotthard][Jungfrau][CTB][Moench][Mythen3][Gotthard2] */
+ /** [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] */
void setDelayAfterTrigger(ns value, Positions pos = {});
- /** [Gotthard][Jungfrau][CTB][Moench][Mythen3]
+ /** [Gotthard][Jungfrau][Moench][CTB][Mythen3]
* [Gotthard2] only in continuous auto mode */
Result getNumberOfFramesLeft(Positions pos = {}) const;
- /** [Gotthard][Jungfrau][CTB][Moench][Mythen3]
+ /** [Gotthard][Jungfrau][Moench][CTB][Mythen3]
* Only when external trigger used */
Result getNumberOfTriggersLeft(Positions pos = {}) const;
- /** [Gotthard][Jungfrau][CTB][Moench][Mythen3][Gotthard2]
+ /** [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2]
* [Gotthard2] only in continuous mode */
Result getPeriodLeft(Positions pos = {}) const;
- /** [Gotthard][Jungfrau][CTB][Moench][Mythen3]
+ /** [Gotthard][Jungfrau][Moench][CTB][Mythen3]
* [Gotthard2] only in continuous mode */
Result getDelayAfterTriggerLeft(Positions pos = {}) const;
@@ -314,7 +328,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][Gotthard][Ctb][Moench][Mythen3][Gotthard2] 16
+ * [Jungfrau][Moench][Gotthard][Ctb][Mythen3][Gotthard2] 16
*/
void setDynamicRange(int value);
@@ -324,7 +338,7 @@ class Detector {
Result getTimingMode(Positions pos = {}) const;
/**
- * [Gotthard][Jungfrau][Gotthard][CTB][Moench][Gotthard2] Options:
+ * [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
@@ -334,64 +348,62 @@ class Detector {
/** list of possible timing modes for this detector */
std::vector getTimingModeList() const;
- /** [Eiger][Jungfrau][Gotthard2] */
+ /** [Eiger][Jungfrau][Moench][Gotthard2] */
Result getReadoutSpeed(Positions pos = {}) const;
- /** [Eiger][Jungfrau][Gotthard2]
- * [Jungfrau] Options: FULL_SPEED, HALF_SPEED (Default), QUARTER_SPEED \n
- * [Eiger] Options: FULL_SPEED (Default), HALF_SPEED, QUARTER_SPEED \n
- * [Gotthard2] Options: G2_108MHZ (Default), G2_144MHZ \n
- * [Jungfrau] FULL_SPEED option only available from v2.0 boards and is
- * recommended to set number of interfaces to 2. \n Also overwrites adcphase
- * to recommended default.
+ /** [Eiger][Jungfrau][Moench][Gotthard2]
+ * [Jungfrau][Moench] Options: FULL_SPEED, HALF_SPEED (Default),
+ * QUARTER_SPEED \n [Eiger] Options: FULL_SPEED (Default), HALF_SPEED,
+ * QUARTER_SPEED \n [Gotthard2] Options: G2_108MHZ (Default), G2_144MHZ \n
+ * [Jungfrau][Moench] FULL_SPEED option only available from v2.0 boards and
+ * is recommended to set number of interfaces to 2. \n Also overwrites
+ * adcphase to recommended default.
*/
void setReadoutSpeed(defs::speedLevel value, Positions pos = {});
/** list of possible readoutspeed modes for this detector */
std::vector getReadoutSpeedList() const;
- /** [Jungfrau][CTB][Moench] */
+ /** [Jungfrau][Moench][CTB] */
Result getADCPhase(Positions pos = {}) const;
- /** [Gotthard][Jungfrau][CTB][Moench]
- * [Jungfrau] Absolute phase shift. Changing Speed also resets adcphase to
- * recommended defaults. \n
- * [Ctb][Moench] Absolute phase shift. Changing adcclk also resets adcphase
- * and sets it to previous values. \n
- * [Gotthard] Relative phase shift
+ /** [Gotthard][Jungfrau][Moench][CTB]
+ * [Jungfrau][Moench] Absolute phase shift. Changing Speed also resets
+ * adcphase to recommended defaults. \n [Ctb] Absolute phase shift. Changing
+ * adcclk also resets adcphase and sets it to previous values. \n [Gotthard]
+ * Relative phase shift
*/
void setADCPhase(int value, Positions pos = {});
- /** [Jungfrau][CTB][Moench] */
+ /** [Jungfrau][Moench][CTB] */
Result getMaxADCPhaseShift(Positions pos = {}) const;
- /** [Gotthard][Jungfrau][CTB][Moench] */
+ /** [Gotthard][Jungfrau][Moench][CTB] */
Result getADCPhaseInDegrees(Positions pos = {}) const;
- /** [Gotthard][Jungfrau][CTB][Moench]
- * [Jungfrau] Absolute phase shift. Changing Speed also resets adcphase to
- * recommended defaults. \n
- * [Ctb][Moench] Absolute phase shift. Changing adcclk also resets adcphase
- * and sets it to previous values. \n
- * [Gotthard] Relative phase shift
+ /** [Gotthard][Jungfrau][Moench][CTB]
+ * [Jungfrau][Moench] Absolute phase shift. Changing Speed also resets
+ * adcphase to recommended defaults. \n [Ctb] Absolute phase shift. Changing
+ * adcclk also resets adcphase and sets it to previous values. \n [Gotthard]
+ * Relative phase shift
*/
void setADCPhaseInDegrees(int value, Positions pos = {});
- /** [CTB][Jungfrau] */
+ /** [CTB][Jungfrau][Moench] */
Result getDBITPhase(Positions pos = {}) const;
- /** [CTB][Jungfrau] Absolute phase shift \n
+ /** [CTB][Jungfrau][Moench] Absolute phase shift \n
* [CTB] changing dbitclk also resets dbitphase and sets to previous values.
*/
void setDBITPhase(int value, Positions pos = {});
- /** [CTB][Jungfrau] */
+ /** [CTB][Jungfrau][Moench] */
Result getMaxDBITPhaseShift(Positions pos = {}) const;
- /** [CTB][Jungfrau] */
+ /** [CTB][Jungfrau][Moench] */
Result getDBITPhaseInDegrees(Positions pos = {}) const;
- /** [CTB][Jungfrau] Absolute phase shift \n
+ /** [CTB][Jungfrau][Moench] Absolute phase shift \n
* [CTB] changing dbitclk also resets dbitphase and sets to previous values.
*/
void setDBITPhaseInDegrees(int value, Positions pos = {});
@@ -424,18 +436,18 @@ class Detector {
/**
* [Gotthard] Options: 0, 90, 110, 120, 150, 180, 200
- * [Jungfrau][CTB][Moench] Options: 0, 60 - 200
+ * [Jungfrau][Moench][CTB] Options: 0, 60 - 200
* [Eiger][Mythen3][Gotthard2] Options: 0 - 200
*/
void setHighVoltage(int value, Positions pos = {});
- /** [Jungfrau][Mythen3][Gotthard2][Moench] */
+ /** [Jungfrau][Moench][Mythen3][Gotthard2] */
Result getPowerChip(Positions pos = {}) const;
- /** [Jungfrau][Mythen3][Gotthard2][Moench] Power the chip. \n
- * [Moench] Default is disabled. \n
- * [Jungfrau] Default is disabled. Get will return power status. Can be off
- * if temperature event occured (temperature over temp_threshold with
+ /** [Jungfrau][Moench][Mythen3][Gotthard2] Power the chip. \n
+ * Default is disabled. \n
+ * [Jungfrau][Moench] Default is disabled. Get will return power status. Can
+ * be off if temperature event occured (temperature over temp_threshold with
* temp_control enabled. Will configure chip (only chip v1.1)\n
* [Mythen3][Gotthard2] Default is 1. If module not connected or wrong
* module, powerchip will fail.
@@ -447,8 +459,8 @@ class Detector {
/** [Gotthard] If 1, adds channel intensity with precalculated values.
* Default is 0 \n
- * [Eiger][Jungfrau] Only for virtual servers, if 1, pixels are saturated.
- * If 0, increasing intensity */
+ * [Eiger][Jungfrau][Moench] Only for virtual servers, if 1, pixels are
+ * saturated. If 0, increasing intensity */
void setImageTestMode(const int value, Positions pos = {});
/** gets list of temperature indices for this detector */
@@ -458,7 +470,7 @@ class Detector {
* (Degrees)
* [Mythen3][Gotthard2] Options: TEMPERATURE_FPGA
* [Gotthard] Options: TEMPERATURE_ADC, TEMPERATURE_FPGA \n
- * [Jungfrau] Options: TEMPERATURE_ADC, TEMPERATURE_FPGA \n
+ * [Jungfrau][Moench] Options: TEMPERATURE_ADC, TEMPERATURE_FPGA \n
* [Eiger] Options: TEMPERATURE_FPGA, TEMPERATURE_FPGAEXT, TEMPERATURE_10GE,
* TEMPERATURE_DCDC, TEMPERATURE_SODL, TEMPERATURE_SODR, TEMPERATURE_FPGA2,
* TEMPERATURE_FPGA3 \n [CTB] Options: SLOW_ADC_TEMP
@@ -475,11 +487,11 @@ class Detector {
void setDefaultDac(defs::dacIndex index, int defaultValue,
Positions pos = {});
- /** [Jungfrau][Mythen3] */
+ /** [Jungfrau][Moench][Mythen3] */
Result getDefaultDac(defs::dacIndex index, defs::detectorSettings sett,
Positions pos = {});
- /** [Jungfrau][Mythen3] */
+ /** [Jungfrau][Moench][Mythen3] */
void setDefaultDac(defs::dacIndex index, int defaultValue,
defs::detectorSettings sett, Positions pos = {});
@@ -528,20 +540,21 @@ class Detector {
* mode.*/
void setParallelMode(bool value, Positions pos = {});
- /** [Gotthard2][Jungfrau] */
+ /** [Gotthard2][Jungfrau][Moench] */
Result getFilterResistor(Positions pos = {}) const;
- /** [Gotthard2][Jungfrau] Set filter resistor. Increasing values for
+ /** [Gotthard2][Jungfrau][Moench] Set filter resistor. Increasing values for
* increasing resistance.\n[Gotthard2] Options: [0|1|2|3]. Default is
- * 0.\n[Jungfrau] Options: [0|1]. Default is 1.*/
+ * 0.\n[Jungfrau][Moench] Options: [0|1]. Default is 1.*/
void setFilterResistor(int value, Positions pos = {});
- /** [Gotthard2][Jungfrau] */
+ /** [Gotthard2][Jungfrau][Moench] */
Result
getCurrentSource(Positions pos = {}) const;
- /** [Gotthard2][Jungfrau] Please refer documentation on currentSrcParameters
- * (sls_detector_defs.h) on the structure and its members */
+ /** [Gotthard2][Jungfrau][Moench] Please refer documentation on
+ * currentSrcParameters (sls_detector_defs.h) on the structure and its
+ * members */
void setCurrentSource(defs::currentSrcParameters par, Positions pos = {});
/** [CTB][Gotthard2] */
@@ -550,14 +563,14 @@ class Detector {
/** [CTB] Options: 0-255 \n [Gotthard2] Options: 0-7 */
void setDBITPipeline(int value, Positions pos = {});
- /** [Eiger][Jungfrau] */
+ /** [Eiger][Jungfrau][Moench] */
Result getReadNRows(Positions pos = {}) const;
/** [Eiger] Number of rows to read out per half module
* Options: 0 - 256. 256 is default. The permissible values depend on
- * dynamic range and 10Gbe enabled. \n[Jungfrau] Number of rows per module
- * starting from the centre. Options: 8 - 512, must be multiples of 8.
- * Default is 512.
+ * dynamic range and 10Gbe enabled. \n[Jungfrau][Moench] Number of rows per
+ * module starting from the centre. Options: 8 - 512, must be multiples
+ * of 8. Default is 512.
*/
void setReadNRows(const int lines, Positions pos = {});
@@ -636,10 +649,9 @@ class Detector {
* different frame numbers for different modules.*/
void setNextFrameNumber(uint64_t value, Positions pos = {});
- /** [Eiger][Mythen3][Jungfrau] Sends an internal software trigger to the
- * detector block true if command blocks till frames are sent out from that
- * trigger
- * [Eiger][Jungfrau] Block can be true
+ /** [Eiger][Mythen3][Jungfrau][Moench] Sends an internal software trigger to
+ * the detector block true if command blocks till frames are sent out from
+ * that trigger [Eiger][Jungfrau][Moench] Block can be true
*/
void sendSoftwareTrigger(const bool block = false, Positions pos = {});
@@ -665,23 +677,23 @@ class Detector {
* *
* ************************************************/
- /** [Jungfrau][Gotthard2] */
+ /** [Jungfrau][Moench][Gotthard2][Eiger] */
Result getNumberofUDPInterfaces(Positions pos = {}) const;
- /** [Jungfrau][Gotthard2] Number of udp interfaces to stream data from
- * detector. Default is 1. \n Also enables second interface in receiver for
- * listening (Writes a file per interface if writing enabled). \n Also
+ /** [Jungfrau][Moench][Gotthard2] Number of udp interfaces to stream data
+ * from detector. Default is 1. \n Also enables second interface in receiver
+ * for listening (Writes a file per interface if writing enabled). \n Also
* restarts client and receiver zmq sockets if zmq streaming enabled. \n
* [Gotthard2] second interface enabled to send veto information via 10Gbps
* for debugging. By default, if veto enabled, it is sent via 2.5 gbps
* interface. */
void setNumberofUDPInterfaces(int n, Positions pos = {});
- /** [Jungfrau] */
+ /** [Jungfrau][Moench] */
Result getSelectedUDPInterface(Positions pos = {}) const;
/**
- * [Jungfrau]
+ * [Jungfrau][Moench]
* Effective only when number of interfaces is 1.
* Options: 0 (outer, default), 1(inner)] //TODO: enum?
*/
@@ -695,11 +707,11 @@ class Detector {
*/
void setSourceUDPIP(const IpAddr ip, Positions pos = {});
- /** [Jungfrau] bottom half [Gotthard2] veto debugging */
+ /** [Jungfrau][Moench] bottom half [Gotthard2] veto debugging */
Result getSourceUDPIP2(Positions pos = {}) const;
- /** [Jungfrau] bottom half [Gotthard2] veto debugging. \n The source UDP IP
- * must be in the same subnet of the destination UDP IP2 */
+ /** [Jungfrau][Moench] bottom half [Gotthard2] veto debugging. \n The source
+ * UDP IP must be in the same subnet of the destination UDP IP2 */
void setSourceUDPIP2(const IpAddr ip, Positions pos = {});
Result getSourceUDPMAC(Positions pos = {}) const;
@@ -710,10 +722,10 @@ class Detector {
*/
void setSourceUDPMAC(const MacAddr mac, Positions pos = {});
- /** [Jungfrau] bottom half [Gotthard2] veto debugging */
+ /** [Jungfrau][Moench] bottom half [Gotthard2] veto debugging */
Result getSourceUDPMAC2(Positions pos = {}) const;
- /** [Jungfrau] bottom half [Gotthard2] veto debugging */
+ /** [Jungfrau][Moench] bottom half [Gotthard2] veto debugging */
void setSourceUDPMAC2(const MacAddr mac, Positions pos = {});
Result getDestinationUDPList(const uint32_t entry,
@@ -721,16 +733,16 @@ class Detector {
void setDestinationUDPList(const UdpDestination, const int module_id);
- /** [Jungfrau][Eiger][Mythen3][Gotthard2] */
+ /** [Jungfrau][Moench][Eiger][Mythen3][Gotthard2] */
Result getNumberofUDPDestinations(Positions pos = {}) const;
void clearUDPDestinations(Positions pos = {});
- /** [Jungfrau][Mythen3][Gotthard2] */
+ /** [Jungfrau][Moench][Mythen3][Gotthard2] */
Result getFirstUDPDestination(Positions pos = {}) const;
- /**[Jungfrau][Gotthard2] Options 0-31 (or number of udp destinations)\n
- * [Mythen3] Options 0-63 (or number of udp destinations)
+ /**[Jungfrau][Moench][Gotthard2] Options 0-31 (or number of udp
+ * destinations)\n [Mythen3] Options 0-63 (or number of udp destinations)
*/
void setFirstUDPDestination(const int value, Positions pos = {});
@@ -739,10 +751,10 @@ class Detector {
/** IP of the interface in receiver that the detector sends data to */
void setDestinationUDPIP(const IpAddr ip, Positions pos = {});
- /** [Jungfrau] bottom half \n [Gotthard2] veto debugging */
+ /** [Jungfrau][Moench] bottom half \n [Gotthard2] veto debugging */
Result getDestinationUDPIP2(Positions pos = {}) const;
- /** [Jungfrau] bottom half \n [Gotthard2] veto debugging */
+ /** [Jungfrau][Moench] bottom half \n [Gotthard2] veto debugging */
void setDestinationUDPIP2(const IpAddr ip, Positions pos = {});
Result getDestinationUDPMAC(Positions pos = {}) const;
@@ -754,14 +766,15 @@ class Detector {
*/
void setDestinationUDPMAC(const MacAddr mac, Positions pos = {});
- /** [Jungfrau] bottom half \n [Gotthard2] veto debugging */
+ /** [Jungfrau][Moench] bottom half \n [Gotthard2] veto debugging */
Result getDestinationUDPMAC2(Positions pos = {}) const;
- /* [Jungfrau][Gotthard2] Mac address of the receiver (destination) udp
- * interface 2. \n Not mandatory to set as udp_dstip2 retrieves it from
+ /* [Jungfrau][Moench][Gotthard2] Mac address of the receiver (destination)
+ * udp interface 2. \n Not mandatory to set as udp_dstip2 retrieves it from
* slsReceiver process but must be set if you use a custom receiver (not
- * slsReceiver). \n [Jungfrau] bottom half \n [Gotthard2] veto debugging \n
- * Use router mac address if router in between detector and receiver.
+ * slsReceiver). \n [Jungfrau][Moench] bottom half \n [Gotthard2] veto
+ * debugging \n Use router mac address if router in between detector and
+ * receiver.
*/
void setDestinationUDPMAC2(const MacAddr mac, Positions pos = {});
@@ -771,12 +784,13 @@ class Detector {
* calculated (incremented by 1 if no 2nd interface) */
void setDestinationUDPPort(int port, int module_id = -1);
- /** [Eiger] right port[Jungfrau] bottom half [Gotthard2] veto debugging */
+ /** [Eiger] right port[Jungfrau][Moench] bottom half [Gotthard2] veto
+ * debugging */
Result getDestinationUDPPort2(Positions pos = {}) const;
- /** [Eiger] right port[Jungfrau] bottom half [Gotthard2] veto debugging \n
- * Default is 50002. \n If module_id is -1, ports for each module is
- * calculated (incremented by 1 if no 2nd interface)*/
+ /** [Eiger] right port[Jungfrau][Moench] bottom half [Gotthard2] veto
+ * debugging \n Default is 50002. \n If module_id is -1, ports for each
+ * module is calculated (incremented by 1 if no 2nd interface)*/
void setDestinationUDPPort2(int port, int module_id = -1);
/** Reconfigures Detector with UDP destination. More for debugging as the
@@ -791,27 +805,28 @@ class Detector {
Result printRxConfiguration(Positions pos = {}) const;
- /** [Eiger][CTB][Moench][Mythen3] */
+ /** [Eiger][CTB][Mythen3] */
Result getTenGiga(Positions pos = {}) const;
- /** [Eiger][CTB][Moench][Mythen3] */
+ /** [Eiger][CTB][Mythen3] */
void setTenGiga(bool value, Positions pos = {});
- /** [Eiger][Jungfrau] */
+ /** [Eiger][Jungfrau][Moench] */
Result getTenGigaFlowControl(Positions pos = {}) const;
- /** [Eiger][Jungfrau] */
+ /** [Eiger][Jungfrau][Moench] */
void setTenGigaFlowControl(bool enable, Positions pos = {});
- /** [Eiger][Jungfrau][Mythen3] */
+ /** [Eiger][Jungfrau][Moench][Mythen3] */
Result getTransmissionDelayFrame(Positions pos = {}) const;
/**
- * Eiger][Jungfrau][Mythen3] Transmission delay of first udp packet being
- * streamed out of the module.\n[Jungfrau] [0-31] Each value represents 1
- * ms\n[Eiger] Additional delay to txndelay_left and txndelay_right. Each
- * value represents 10ns. Typical value is 50000.\n[Mythen3] [0-16777215]
- * Each value represents 8 ns (125 MHz clock), max is 134 ms.
+ * Eiger][Jungfrau][Moench][Mythen3] Transmission delay of first udp packet
+ * being streamed out of the module.\n[Jungfrau][Moench] [0-31] Each value
+ * represents 1 ms\n[Eiger] Additional delay to txndelay_left and
+ * txndelay_right. Each value represents 10ns. Typical value is
+ * 50000.\n[Mythen3] [0-16777215] Each value represents 8 ns (125 MHz
+ * clock), max is 134 ms.
*/
void setTransmissionDelayFrame(int value, Positions pos = {});
@@ -836,16 +851,16 @@ class Detector {
*/
void setTransmissionDelayRight(int value, Positions pos = {});
- /** [Eiger][Jungfrau] */
+ /** [Eiger][Jungfrau][Moench] */
int getTransmissionDelay() const;
/**
- * [Eiger][Jungfrau][Mythen3] Set transmission delay for all modules in the
- * detector using the step size provided.Sets up \n\t\t[Eiger] txdelay_left
- * to (2 * mod_index * n_delay), \n\t\t[Eiger] txdelay_right to ((2 *
- * mod_index + 1) * n_delay) and \n\t\t[Eiger] txdelay_frame to (2
- * *num_modules * n_delay) \n\t\t[Jungfrau][Mythen3] txdelay_frame to
- * (num_modules * n_delay) \nfor every module.
+ * [Eiger][Jungfrau][Moench][Mythen3] Set transmission delay for all modules
+ * in the detector using the step size provided.Sets up \n\t\t[Eiger]
+ * txdelay_left to (2 * mod_index * n_delay), \n\t\t[Eiger] txdelay_right to
+ * ((2 * mod_index + 1) * n_delay) and \n\t\t[Eiger] txdelay_frame to (2
+ * *num_modules * n_delay) \n\t\t[Jungfrau][Moench][Mythen3] txdelay_frame
+ * to (num_modules * n_delay) \nfor every module.
*/
void setTransmissionDelay(int step);
@@ -932,9 +947,10 @@ class Detector {
/** Client IP Address that last communicated with the receiver */
Result getRxLastClientIP(Positions pos = {}) const;
- /** Get thread ids from the receiver in order of [parent, tcp, listener 0,
- * processor 0, streamer 0, listener 1, processor 1, streamer 1, arping]. If
- * no streamer yet or there is no second interface, it gives 0 in its place.
+ /** Get kernel thread ids from the receiver in order of [parent, tcp,
+ * listener 0, processor 0, streamer 0, listener 1, processor 1, streamer 1,
+ * arping]. If no streamer yet or there is no second interface, it gives 0
+ * in its place.
*/
Result>
getRxThreadIds(Positions pos = {}) const;
@@ -1226,22 +1242,22 @@ class Detector {
///@}
- /** @name Jungfrau Specific */
+ /** @name Jungfrau/Moench Specific */
///@{
/**************************************************
* *
- * Jungfrau Specific *
+ * Jungfrau/Moench Specific *
* *
* ************************************************/
- /** [Jungfrau] */
+ /** [Jungfrau][Moench] */
Result getChipVersion(Positions pos = {}) const;
- /** [Jungfrau] */
+ /** [Jungfrau][Moench] */
Result getThresholdTemperature(Positions pos = {}) const;
/**
- * [Jungfrau]Set threshold temperature in degrees.
+ * [Jungfrau][Moench]Set threshold temperature in degrees.
* If temperature crosses threshold temperature
* and temperature control is enabled (default is disabled), power to chip
* will be switched off and temperature event will be set. \n To power on
@@ -1250,23 +1266,23 @@ class Detector {
*/
void setThresholdTemperature(int temp, Positions pos = {});
- /** [Jungfrau] */
+ /** [Jungfrau][Moench] */
Result getTemperatureControl(Positions pos = {}) const;
- /** [Jungfrau] refer to setThresholdTemperature
+ /** [Jungfrau][Moench] refer to setThresholdTemperature
* Default is disabled */
void setTemperatureControl(bool enable, Positions pos = {});
- /** [Jungfrau] refer to setThresdholdTemperature */
+ /** [Jungfrau][Moench] refer to setThresdholdTemperature */
Result getTemperatureEvent(Positions pos = {}) const;
- /** [Jungfrau] refer to setThresdholdTemperature */
+ /** [Jungfrau][Moench] refer to setThresdholdTemperature */
void resetTemperatureEvent(Positions pos = {});
- /** [Jungfrau] */
+ /** [Jungfrau][Moench] */
Result getAutoComparatorDisable(Positions pos = {}) const;
- /** [Jungfrau] Advanced
+ /** [Jungfrau][Moench] Advanced
* //TODO naming
* By default, the on-chip gain switching is active during the
* entire exposure. This mode disables the on-chip gain switching comparator
@@ -1278,11 +1294,11 @@ class Detector {
*/
void setAutoComparatorDisable(bool value, Positions pos = {});
- /** [Jungfrau] */
+ /** [Jungfrau][Moench] */
Result getComparatorDisableTime(Positions pos = {}) const;
- /** [Jungfrau] Time before end of exposure when comparator is disabled. It
- * is only possible for chipv1.1.*/
+ /** [Jungfrau][Moench] Time before end of exposure when comparator is
+ * disabled. It is only possible for chipv1.1.*/
void setComparatorDisableTime(ns t, Positions pos = {});
/** [Jungfrau] Advanced TODO naming */
@@ -1296,37 +1312,37 @@ class Detector {
/** [Jungfrau] Advanced */
Result getStorageCellStart(Positions pos = {}) const;
- /** [Jungfrau] Advanced. Sets the storage cell storing the first acquisition
- * of the series. Options: 0-max. max is 15 (default) for chipv1.0 and 3
- * (default) for chipv1.1.
+ /** [Jungfrau] Advanced. Sets the storage cell storing the first
+ * acquisition of the series. Options: 0-max. max is 15 (default) for
+ * chipv1.0 and 3 (default) for chipv1.1.
*/
void setStorageCellStart(int cell, Positions pos = {});
/** [Jungfrau] Advanced*/
Result getStorageCellDelay(Positions pos = {}) const;
- /** [Jungfrau] Advanced \n Additional time delay between 2 consecutive
- * exposures in burst mode. \n Options: (0-1638375 ns (resolution of 25ns)\n
- * Only applicable for chipv1.0.
+ /** [Jungfrau] Advanced \n Additional time delay between 2
+ * consecutive exposures in burst mode. \n Options: (0-1638375 ns
+ * (resolution of 25ns)\n Only applicable for chipv1.0.
*/
void setStorageCellDelay(ns value, Positions pos = {});
/** list of possible gainmode */
std::vector getGainModeList() const;
- /** [Jungfrau]*/
+ /** [Jungfrau][Moench]*/
Result getGainMode(Positions pos = {}) const;
- /** [Jungfrau] Options: DYNAMIC, FORCE_SWITCH_G1, FORCE_SWITCH_G2,
+ /** [Jungfrau][Moench] Options: DYNAMIC, FORCE_SWITCH_G1, FORCE_SWITCH_G2,
* FIX_G1, FIX_G2, FIX_G0 \n\CAUTION: Do not use FIX_G0 without caution, you
* can damage the detector!!!\n
*/
void setGainMode(const defs::gainMode mode, Positions pos = {});
- /** [Jungfrau] Advanced */
+ /** [Jungfrau][Moench] Advanced */
Result getNumberOfFilterCells(Positions pos = {}) const;
- /** [Jungfrau] Advanced Options[0-12], only for chip v1.1
+ /** [Jungfrau][Moench] Advanced Options[0-12], only for chip v1.1
*/
void setNumberOfFilterCells(int cell, Positions pos = {});
@@ -1464,8 +1480,9 @@ class Detector {
Result getADCConfiguration(const int chipIndex, const int adcIndex,
Positions pos = {}) const;
- /** [Gotthard2] configures one chip at a time for specific adc, chipIndex
- * and adcIndex is -1 for all */
+ /** [Gotthard2] configures one chip at a time for specific adc, chipIndex.
+ * -1 for all. Setting specific chip index not implemented in hardware yet
+ */
void setADCConfiguration(const int chipIndex, const int adcIndex,
const int value, Positions pos = {});
@@ -1557,69 +1574,68 @@ class Detector {
///@}
- /** @name CTB / Moench Specific */
+ /** @name CTB Specific */
///@{
/**************************************************
* *
- * CTB / Moench Specific *
+ * CTB Specific *
* *
* ************************************************/
- /** [CTB][Moench] */
+ /** [CTB] */
Result getNumberOfAnalogSamples(Positions pos = {}) const;
- /** [CTB][Moench] */
+ /** [CTB] */
void setNumberOfAnalogSamples(int value, Positions pos = {});
- /** [CTB][Moench] */
+ /** [CTB] */
Result getADCClock(Positions pos = {}) const;
- /** [CTB][Moench] */
+ /** [CTB] */
void setADCClock(int value_in_MHz, Positions pos = {});
- /** [CTB][Moench] */
+ /** [CTB] */
Result getRUNClock(Positions pos = {}) const;
- /** [CTB][Moench] */
+ /** [CTB] */
void setRUNClock(int value_in_MHz, Positions pos = {});
- /** [CTB][Moench] in MHZ */
+ /** [CTB] in MHZ */
Result getSYNCClock(Positions pos = {}) const;
- /** [CTB][Moench] */
+ /** [CTB] */
Result getADCPipeline(Positions pos = {}) const;
- /** [CTB][Moench] */
+ /** [CTB] */
void setADCPipeline(int value, Positions pos = {});
- /** [CTB][Moench] */
+ /** [CTB] */
Result getVoltage(defs::dacIndex index, Positions pos = {}) const;
/**
- * [CTB][Moench] mV
+ * [CTB] mV
* [Ctb] Options: V_LIMIT, V_POWER_A, V_POWER_B, V_POWER_C,
* V_POWER_D, V_POWER_IO, V_POWER_CHIP
- * [Moench] Options: V_LIMIT
*/
void setVoltage(defs::dacIndex index, int value, Positions pos = {});
/**
- * [CTB][Moench] Options: [0- 4] or [1V, 1.14V, 1.33V, 1.6V, 2V]
+ * [CTB] Options: [0- 4] or [1V, 1.14V, 1.33V, 1.6V, 2V]
*/
Result getADCVpp(bool mV = false, Positions pos = {}) const;
- /** [CTB][Moench] */
+ /** [CTB] */
void setADCVpp(int value, bool mV = false, Positions pos = {});
- /** [CTB][Moench] */
+ /** [CTB] */
Result getADCEnableMask(Positions pos = {}) const;
- /** [CTB][Moench] */
+ /** [CTB] */
void setADCEnableMask(uint32_t mask, Positions pos = {});
- /** [CTB][Moench] */
+ /** [CTB] */
Result getTenGigaADCEnableMask(Positions pos = {}) const;
- /** [CTB][Moench] If any of a consecutive 4 bits are enabled, the "
+ /** [CTB] If any of a consecutive 4 bits are enabled, the "
"complete 4 bits are enabled */
void setTenGigaADCEnableMask(uint32_t mask, Positions pos = {});
///@}
@@ -1721,78 +1737,78 @@ class Detector {
* *
* ************************************************/
- /** [CTB][Moench][Mythen3] Loads ASCII pattern file directly to server
+ /** [CTB][Mythen3] Loads ASCII pattern file directly to server
* (instead of executing line by line)*/
void setPattern(const std::string &fname, Positions pos = {});
- /** [CTB][Moench][Mythen3] Loads pattern parameters structure directly to
+ /** [CTB][Mythen3] Loads pattern parameters structure directly to
* server */
void setPattern(const Pattern &pat, Positions pos = {});
- /** [CTB][Moench][Mythen3] [Ctb][Moench][Mythen3] Saves pattern to file
- * (ascii). \n [Ctb][Moench] Also executes pattern.*/
+ /** [CTB][Mythen3] [Ctb][Mythen3] Saves pattern to file
+ * (ascii). \n [Ctb] Also executes pattern.*/
void savePattern(const std::string &fname);
- /** [Mythen3][Moench] Loads and runs default pattern */
+ /** [Mythen3] Loads and runs default pattern */
void loadDefaultPattern(Positions pos = {});
- /** [CTB][Moench] */
+ /** [CTB] */
Result getPatternIOControl(Positions pos = {}) const;
- /** [CTB][Moench] */
+ /** [CTB] */
void setPatternIOControl(uint64_t word, Positions pos = {});
- /** [CTB][Moench][Mythen3] same as executing for ctb and moench */
+ /** [CTB][Mythen3] same as executing for ctb */
Result getPatternWord(int addr, Positions pos = {});
- /** [CTB][Moench] Caution: If word is -1 reads the addr (same as
+ /** [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][Moench][Mythen3] Options: level: -1 (complete pattern) and 0-2
+ /**[CTB][Mythen3] Options: level: -1 (complete pattern) and 0-2
* levels
* @returns array of start address and stop address
*/
Result>
getPatternLoopAddresses(int level, Positions pos = {}) const;
- /** [CTB][Moench][Mythen3] Options: level: -1 (complete pattern) and 0-2
+ /** [CTB][Mythen3] Options: level: -1 (complete pattern) and 0-2
* levels */
void setPatternLoopAddresses(int level, int start, int stop,
Positions pos = {});
- /**[CTB][Moench][Mythen3] Options: level: -1 (complete pattern) and 0-2
+ /**[CTB][Mythen3] Options: level: -1 (complete pattern) and 0-2
* levels */
Result getPatternLoopCycles(int level, Positions pos = {}) const;
- /** [CTB][Moench][Mythen3] n: 0-2, level: -1 (complete pattern) and 0-2
+ /** [CTB][Mythen3] n: 0-2, level: -1 (complete pattern) and 0-2
* levels */
void setPatternLoopCycles(int level, int n, Positions pos = {});
- /**[CTB][Moench][Mythen3] */
+ /**[CTB][Mythen3] */
Result getPatternWaitAddr(int level, Positions pos = {}) const;
- /** [CTB][Moench][Mythen3] Options: level 0-2 */
+ /** [CTB][Mythen3] Options: level 0-2 */
void setPatternWaitAddr(int level, int addr, Positions pos = {});
- /** [CTB][Moench][Mythen3] */
+ /** [CTB][Mythen3] */
Result getPatternWaitTime(int level, Positions pos = {}) const;
- /** [CTB][Moench][Mythen3] Options: level 0-2 */
+ /** [CTB][Mythen3] Options: level 0-2 */
void setPatternWaitTime(int level, uint64_t t, Positions pos = {});
- /** [CTB][Moench][Mythen3] */
+ /** [CTB][Mythen3] */
Result getPatternMask(Positions pos = {});
- /** [CTB][Moench][Mythen3] Selects the bits that will have a pattern mask
+ /** [CTB][Mythen3] 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][Moench][Mythen3] */
+ /** [CTB][Mythen3] */
Result getPatternBitMask(Positions pos = {}) const;
- /** [CTB][Moench][Mythen3] Sets the mask applied to every pattern to the
+ /** [CTB][Mythen3] Sets the mask applied to every pattern to the
* selected bits */
void setPatternBitMask(uint64_t mask, Positions pos = {});
@@ -1800,19 +1816,18 @@ class Detector {
void startPattern(Positions pos = {});
///@}
- /** @name Moench specific */
+ /** @name Json Header specific */
///@{
/**************************************************
* *
- * Moench specific *
+ * Json Header specific *
* *
* ************************************************/
- /** [Moench] */
Result>
getAdditionalJsonHeader(Positions pos = {}) const;
- /** [Moench] If empty, reset additional json header. Default is empty. Max
+ /** If empty, reset additional json header. Default is empty. Max
* 20 characters for each key/value. Empty value deletes header. Use only if
* to be processed by an intermediate user process listening to receiver zmq
* packets such as in Moench */
@@ -1820,11 +1835,9 @@ class Detector {
const std::map &jsonHeader,
Positions pos = {});
- /** [Moench] */
Result getAdditionalJsonParameter(const std::string &key,
Positions pos = {}) const;
/**
- * [Moench]
* Sets the value for additional json header parameters. If not found,
* the pair is appended. Empty value deletes parameter. Max 20 characters
* for each key/value.
@@ -1842,41 +1855,41 @@ class Detector {
* *
* ************************************************/
- /** [Jungfrau][Gotthard][CTB][Moench][Mythen3][Gotthard2]
+ /** [Jungfrau][Moench][Gotthard][CTB][Mythen3][Gotthard2]
* Advanced user Function!
* Program firmware from command line, after which detector controller is
* rebooted. forceDeleteNormalFile is true, if normal file found
* in device tree, it must be deleted, a new device drive created and
- * programming continued.[Jungfrau][CTB][Moench] fname is a pof file (full
+ * programming continued.[Jungfrau][Moench][CTB] fname is a pof file (full
* path) \n [Mythen3][Gotthard2] fname is an rbf file (full path)
*/
void programFPGA(const std::string &fname, const bool forceDeleteNormalFile,
Positions pos = {});
- /** [Jungfrau][CTB][Moench] Advanced user Function! */
+ /** [Jungfrau][Moench][CTB] Advanced user Function! */
void resetFPGA(Positions pos = {});
- /** [Jungfrau][Eiger][Ctb][Moench][Mythen3][Gotthard2] Copies detector
+ /** [Jungfrau][Moench][Eiger][Ctb][Mythen3][Gotthard2] Copies detector
* server via TCP (without tftp).\nMakes a symbolic link with a shorter
* name (without vx.x.x).\nThen, detector controller reboots (except
- * Eiger).\n[Jungfrau][Ctb][Moench] Also deletes old server binary and
+ * Eiger).\n[Jungfrau][Moench][Ctb] Also deletes old server binary and
* changes respawn server to the link, which is effective after a reboot.
*/
void updateDetectorServer(const std::string &fname, Positions pos = {});
- /** [Jungfrau][Ctb][Moench][Mythen3][Gotthard2] \n
+ /** [Jungfrau][Moench][Ctb][Mythen3][Gotthard2] \n
* Advanced Command!! You could damage the detector. Please use with
* caution.\nUpdates the kernel image. Then, detector controller reboots
* with new kernel
*/
void updateKernel(const std::string &fname, Positions pos = {});
- /** [Jungfrau][Gotthard][CTB][Moench][Mythen3][Gotthard2] Advanced user
+ /** [Jungfrau][Moench][Gotthard][CTB][Mythen3][Gotthard2] Advanced user
* Function! */
void rebootController(Positions pos = {});
/**
- * Advanced user Function!\n [Jungfrau][Gotthard][CTB][Moench] Updates the
+ * Advanced user Function!\n [Jungfrau][Moench][Gotthard][CTB] Updates the
* firmware, detector server, make a soft link and then reboots detector
* controller. \n [Mythen3][Gotthard2] Will require a script to start up the
* shorter named server link at start up \n sname is full path name of
@@ -1913,16 +1926,16 @@ class Detector {
/** Advanced user Function! */
Result getBit(uint32_t addr, int bitnr, Positions pos = {});
- /** [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] Advanced user
+ /** [Gotthard][Jungfrau][Moench][Mythen3][Gotthard2][CTB] Advanced user
* Function! */
void executeFirmwareTest(Positions pos = {});
- /** [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB][Moench] Advanced user
+ /** [Gotthard][Jungfrau][Moench][Mythen3][Gotthard2][CTB] Advanced user
* Function! Writes different values in a R/W register and confirms the
* writes to check bus */
void executeBusTest(Positions pos = {});
- /** [Gotthard][Jungfrau][CTB][Moench] Advanced user Function! not possible
+ /** [Gotthard][Jungfrau][Moench][CTB] Advanced user Function! not possible
* to read back */
void writeAdcRegister(uint32_t addr, uint32_t value, Positions pos = {});
@@ -1935,11 +1948,11 @@ class Detector {
* incompatible. \n Advanced user Function! */
void setInitialChecks(const bool value);
- /** [CTB][Moench][Jungfrau] Advanced user Function! */
+ /** [CTB][Jungfrau][Moench] Advanced user Function! */
Result getADCInvert(Positions pos = {}) const;
- /** [CTB][Moench][Jungfrau] Advanced user Function! \n
- [Jungfrau] Inversions on top of default mask */
+ /** [CTB][Jungfrau][Moench] Advanced user Function! \n
+ [Jungfrau][Moench] Inversions on top of default mask */
void setADCInvert(uint32_t value, Positions pos = {});
///@}
@@ -1976,15 +1989,15 @@ class Detector {
Result executeCommand(const std::string &value,
Positions pos = {});
- /** [Jungfrau][Mythen3][CTB][Moench]
+ /** [Jungfrau][Moench][Mythen3][CTB]
* [Gotthard2] only in continuous mode */
Result getNumberOfFramesFromStart(Positions pos = {}) const;
- /** [Jungfrau][Mythen3][CTB][Moench] Get time from detector start
+ /** [Jungfrau][Moench][Mythen3][CTB] Get time from detector start
* [Gotthard2] not in burst and auto mode */
Result getActualTime(Positions pos = {}) const;
- /** [Jungfrau][Mythen3][CTB][Moench] Get timestamp at a frame start
+ /** [Jungfrau][Moench][Mythen3][CTB] Get timestamp at a frame start
* [Gotthard2] not in burst and auto mode */
Result getMeasurementTime(Positions pos = {}) const;
diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp
index 35f3cf777..bc812601d 100644
--- a/slsDetectorSoftware/src/CmdProxy.cpp
+++ b/slsDetectorSoftware/src/CmdProxy.cpp
@@ -7,6 +7,7 @@
#include "sls/ToString.h"
#include "sls/bit_utils.h"
#include "sls/container_utils.h"
+#include "sls/file_utils.h"
#include "sls/logger.h"
#include "sls/sls_detector_defs.h"
@@ -274,25 +275,36 @@ std::string CmdProxy::Versions(int action) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
+ bool eiger = (det->getDetectorType().squash() == defs::EIGER);
auto t = det->getFirmwareVersion(std::vector{det_id});
- os << "\nType : " << OutString(det->getDetectorType())
- << "\nRelease : " << det->getPackageVersion() << std::hex
- << "\nClient : " << det->getClientVersion();
- os << "\nFirmware : ";
- if (det->getDetectorType().squash() == defs::EIGER) {
- os << OutString(t);
+ os << "\nType : " << OutString(det->getDetectorType())
+ << "\nRelease : " << det->getPackageVersion() << std::hex
+ << "\nClient : " << det->getClientVersion();
+
+ if (eiger) {
+ os << "\nFirmware (Beb) : "
+ << OutString(det->getFirmwareVersion(std::vector{det_id}));
+ os << "\nFirmware (Febl) : "
+ << OutString(det->getFrontEndFirmwareVersion(
+ defs::FRONT_LEFT, std::vector{det_id}));
+ os << "\nFirmware (Febr) : "
+ << OutString(det->getFrontEndFirmwareVersion(
+ defs::FRONT_RIGHT, std::vector{det_id}));
} else {
- os << OutStringHex(t);
+ os << "\nFirmware : "
+ << OutStringHex(
+ det->getFirmwareVersion(std::vector{det_id}));
}
- os << "\nServer : "
- << OutString(
- det->getDetectorServerVersion(std::vector{det_id}));
- os << "\nHardware : "
+
+ os << "\nServer : "
+ << OutString(det->getDetectorServerVersion(std::vector{det_id}))
+ << "\nKernel : "
+ << OutString(det->getKernelVersion({std::vector{det_id}}))
+ << "\nHardware : "
<< OutString(det->getHardwareVersion(std::vector{det_id}));
- os << "\nKernel : "
- << OutString(det->getKernelVersion({std::vector{det_id}}));
+
if (det->getUseReceiverFlag().squash(true)) {
- os << "\nReceiver : "
+ os << "\nReceiver : "
<< OutString(det->getReceiverVersion(std::vector{det_id}));
}
os << std::dec << '\n';
@@ -514,7 +526,8 @@ std::string CmdProxy::GapPixels(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
- os << "[0, 1]\n\t[Eiger][Jungfrau] Include Gap pixels in client data "
+ os << "[0, 1]\n\t[Eiger][Jungfrau][Moench] Include Gap pixels in "
+ "client data "
"call back in Detecor api. Will not be in detector streaming, "
"receiver file or streaming. Default is 0. "
<< '\n';
@@ -546,9 +559,9 @@ std::string CmdProxy::BadChannels(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
- os << "[fname]\n\t[Gotthard2][Mythen3] Sets the bad channels (from "
- "file of bad channel numbers) to be masked out."
- "\n\t[Mythen3] Also does trimming"
+ os << "[fname|none|0]\n\t[Gotthard2][Mythen3] Sets the bad channels "
+ "(from file of bad channel numbers) to be masked out. None or 0 "
+ "unsets all the badchannels.\n\t[Mythen3] Also does trimming"
<< '\n';
} else if (action == defs::GET_ACTION) {
if (args.size() != 1) {
@@ -557,10 +570,25 @@ std::string CmdProxy::BadChannels(int action) {
det->getBadChannels(args[0], std::vector{det_id});
os << "successfully retrieved" << '\n';
} else if (action == defs::PUT_ACTION) {
- if (args.size() != 1) {
+ bool parse = false;
+ if (args.size() == 0) {
WrongNumberOfParameters(1);
+ } else if (args.size() == 1) {
+ if (args[0] == "none" || args[0] == "0") {
+ det->setBadChannels(std::vector{},
+ std::vector{det_id});
+ } else if (args[0].find(".") != std::string::npos) {
+ det->setBadChannels(args[0], std::vector{det_id});
+ } else {
+ parse = true;
+ }
+ }
+ // parse multi args or single one with range or single value
+ if (parse || args.size() > 1) {
+ // get channels
+ auto list = getChannelsFromStringList(args);
+ det->setBadChannels(list, std::vector{det_id});
}
- det->setBadChannels(args[0], std::vector{det_id});
os << "successfully loaded" << '\n';
} else {
throw RuntimeError("Unknown action");
@@ -589,8 +617,8 @@ std::string CmdProxy::Exptime(int action) {
if (action == defs::HELP_ACTION) {
if (cmd == "exptime") {
os << "[duration] [(optional unit) "
- "ns|us|ms|s]\n\t[Eiger][Jungfrau][Gotthard][Gotthard2]["
- "Moench][Ctb] Exposure time"
+ "ns|us|ms|s]\n\t[Eiger][Jungfrau][Moench][Gotthard]["
+ "Gotthard2][Ctb] Exposure time"
"\n\t[Mythen3] Exposure time of all gate signals in auto and "
"trigger mode (internal gating). To specify gate index, use "
"exptime1, exptime2, exptime3."
@@ -674,9 +702,10 @@ std::string CmdProxy::ReadoutSpeed(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "\n\t[0 or full_speed|1 or half_speed|2 or "
- "quarter_speed]\n\t\t[Eiger][Jungfrau] Readout "
+ "quarter_speed]\n\t\t[Eiger][Jungfrau][Moench] Readout "
"speed of chip.\n\t\t[Eiger] Default speed is full_speed."
- "\n\t\t[Jungfrau] Default speed is half_speed. full_speed "
+ "\n\t\t[Jungfrau][Moench] Default speed is half_speed. "
+ "full_speed "
"option only available from v2.0 boards and is recommended to "
"set "
"number of interfaces to 2. Also overwrites "
@@ -685,7 +714,7 @@ std::string CmdProxy::ReadoutSpeed(int action) {
<< '\n';
} else {
defs::detectorType type = det->getDetectorType().squash();
- if (type == defs::CHIPTESTBOARD || type == defs::MOENCH) {
+ if (type == defs::CHIPTESTBOARD) {
throw RuntimeError(
"ReadoutSpeed not implemented. Did you mean runclk?");
}
@@ -714,10 +743,11 @@ std::string CmdProxy::Adcphase(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[n_value] "
- "[(optional)deg]\n\t[Jungfrau][Ctb][Moench][Gotthard] "
- "Phase shift of ADC clock. \n\t[Jungfrau] Absolute phase shift. "
+ "[(optional)deg]\n\t[Jungfrau][Moench][Ctb][Gotthard] "
+ "Phase shift of ADC clock. \n\t[Jungfrau][Moench] Absolute phase "
+ "shift. "
"If deg used, then shift in degrees. Changing Speed also resets "
- "adcphase to recommended defaults.\n\t[Ctb][Moench] Absolute "
+ "adcphase to recommended defaults.\n\t[Ctb] Absolute "
"phase shift. If deg used, then shift in degrees. Changing "
"adcclk also resets adcphase and sets it to previous "
"values.\n\t[Gotthard] Relative phase shift. Cannot get"
@@ -770,7 +800,8 @@ std::string CmdProxy::Dbitphase(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
- os << "[n_value] [(optional)deg]\n\t[Ctb][Jungfrau] Phase shift of "
+ os << "[n_value] [(optional)deg]\n\t[Ctb][Jungfrau][Moench] Phase "
+ "shift of "
"clock to latch digital bits. Absolute phase shift. If deg used, "
"then shift in degrees. \n\t[Ctb]Changing dbitclk also resets "
"dbitphase and sets to previous values."
@@ -1007,7 +1038,8 @@ std::string CmdProxy::CurrentSource(int action) {
os << "\n\t[0|1]\n\t\t[Gotthard2] Enable or disable current source. "
"Default "
"is disabled.\n\t[0|1] [fix|nofix] [select source] [(only for "
- "chipv1.1)normal|low]\n\t\t[Jungfrau] Disable or enable current "
+ "chipv1.1)normal|low]\n\t\t[Jungfrau][Moench] Disable or enable "
+ "current "
"source with some parameters. The select source is 0-63 for "
"chipv1.0 and a 64 bit mask for chipv1.1. To disable, one needs "
"only one argument '0'."
@@ -1256,7 +1288,7 @@ std::string CmdProxy::ResetDacs(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[(optional) hard] "
- "\n\t[Eiger][Jungfrau][Gotthard][Moench][Gotthard2]["
+ "\n\t[Eiger][Jungfrau][Moench][Gotthard][Gotthard2]["
"Mythen3]Reset dac values to the defaults. A 'hard' optional "
"reset will reset the dacs to the hardcoded defaults in on-board "
"detector server."
@@ -1287,7 +1319,8 @@ std::string CmdProxy::DefaultDac(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[dac name][value][(optional)setting]\n\tSets the default for "
- "that dac to this value.\n\t[Jungfrau][Mythen3] When settings is "
+ "that dac to this value.\n\t[Jungfrau][Moench][Mythen3] When "
+ "settings is "
"provided, it sets the default value only for that setting"
<< '\n';
} else if (action == defs::GET_ACTION) {
@@ -1430,10 +1463,12 @@ std::string CmdProxy::Trigger(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "trigger") {
- os << "\n\t[Eiger][Mythen3][Jungfrau] Sends software trigger "
+ os << "\n\t[Eiger][Mythen3][Jungfrau][Moench] Sends software "
+ "trigger "
"signal to detector";
} else if (cmd == "blockingtrigger") {
- os << "\n\t[Eiger][Jungfrau] Sends software trigger signal to "
+ os << "\n\t[Eiger][Jungfrau][Moench] Sends software trigger signal "
+ "to "
"detector and blocks till the frames are sent out for that "
"trigger.";
} else {
@@ -1463,7 +1498,7 @@ std::string CmdProxy::Trigger(int action) {
/* Network Configuration (Detector<->Receiver) */
-IpAddr CmdProxy::getIpFromAuto() {
+IpAddr CmdProxy::getDstIpFromAuto() {
std::string rxHostname =
det->getRxHostname(std::vector