Compare commits

...

98 Commits

Author SHA1 Message Date
908afc790d jungfrau: new firmware version 2020-03-06 18:08:08 +01:00
d6e174ea11 jungfrau: adc phase changed again 2020-03-06 17:54:38 +01:00
f255becffe jungfrau: adcphase values nad dbit values done for new boards 2020-03-06 17:49:22 +01:00
0a596c689b sanitizer on, gui:removed qfuture, client: not implemented made specific as to what is not 2020-03-06 15:41:15 +01:00
a2e019ff36 moench: updated adcpipeline from 14 to 15 2020-03-06 10:47:21 +01:00
959d62ed66 moench: default clocks and phase are same as ctb at startup 2020-03-05 18:03:53 +01:00
1d2a46cdbe moench:dsamples=0 at startup 2020-03-05 17:13:58 +01:00
aeb9ddfe62 moench:dbit clock updated to 40 2020-03-05 17:10:37 +01:00
4a802bd2e4 gotthard2: switching between continuous to burst mode (burstperiod got reset: fixed) 2020-03-05 16:35:52 +01:00
c2639854fa ctb gui works with moench detector 2020-03-05 14:53:24 +01:00
dec4d00fbf ctb: gui call back fix 2020-03-05 11:31:36 +01:00
e3f9ef0b25 moench and eiger updated as well 2020-03-05 10:24:59 +01:00
9ca86c2edb ctb, gotthard, gotthard2, jungfrau, mythen updated 2020-03-05 10:21:24 +01:00
c64b09ee79 Jungfraufix (#84)
* jungfrau: added dbitphase, different pll clkindex 0 with different wr bit
2020-03-04 17:06:18 +01:00
4e2f685b76 gotthard2: gain plot fix with clones 2020-03-04 14:39:44 +01:00
6e4a3353a3 moench: removed commented out settings 2020-03-04 13:53:28 +01:00
042e5715e6 conflict fix 2020-03-04 13:51:58 +01:00
e143204ce1 Corrected settings and patter for moench detector 2020-03-04 13:33:42 +01:00
5f3af794ce moench bug fix: power chip enable 2020-03-04 12:34:32 +01:00
e7df925d6b moench sample config file in examples 2020-03-04 11:32:11 +01:00
7859cf78e9 moench: allow power chip 2020-03-04 10:41:10 +01:00
1b996d1703 revised gain plot; updated version api 2020-03-04 10:25:38 +01:00
2fcb41426a Merge pull request #82 from slsdetectorgroup/moenchUpdated
Moench updated
2020-03-04 10:22:09 +01:00
032475fc14 gainplot clone revised 2020-03-04 10:17:51 +01:00
5430288ce8 merge fix 2020-03-03 17:57:55 +01:00
a61c5e0206 Merge pull request #81 from slsdetectorgroup/readme
Updated readme
2020-03-03 17:56:05 +01:00
582a3c6878 Update README.md 2020-03-03 17:55:16 +01:00
134611c638 gotthard2: switching between period and burst period (not delay and burst period), internal frequency depending on timing source (for all except actualtime and measurement time) 2020-03-03 17:49:28 +01:00
06bd6dfd53 Merge branch 'developer' into moenchUpdated 2020-03-03 16:37:31 +01:00
fca7d51cb4 moench: removed hardcoding ny in call back for gui 2020-03-03 16:30:28 +01:00
85aca0ffad moench: insignficant dac naming fix 2020-03-03 16:21:45 +01:00
fac95516cf moench: insignficant naming fix 2020-03-03 16:07:37 +01:00
8abc32e7f1 moench: default pattern file in server, settings, tests 2020-03-03 16:00:01 +01:00
1efacc9475 cleaning up headers 2020-03-03 11:33:28 +01:00
b2d88b441a removed comments 2020-03-03 11:17:26 +01:00
75e083ae46 find tests and commands 2020-03-03 11:04:05 +01:00
9699e064d3 WIP 2020-03-03 10:12:26 +01:00
c6c3a68520 WIP 2020-03-03 10:08:20 +01:00
5e92c5b67e WIP 2020-03-03 09:38:05 +01:00
0947cefe08 WIP 2020-03-03 09:29:25 +01:00
6bbcf6173d moench: first version 2020-03-02 18:34:10 +01:00
ecc3b36204 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-02 14:50:48 +01:00
3e88beb8a5 O3 as default and option for mtune 2020-03-02 13:50:16 +01:00
cce659d98c deploy only on tags 2020-03-02 13:12:46 +01:00
95d56ad545 lookup 2020-03-02 11:57:35 +01:00
84cd4d8436 generated python funcs 2020-03-02 11:34:30 +01:00
d7319968a7 gui: always show gain plots, include intensity ticks(2d), channels number and gain ticks(1d) 2020-02-28 17:28:44 +01:00
a769f7515c gotthard2 bug fix: fixed pll freq was incorrect when 0 in front 2020-02-28 16:03:15 +01:00
11e7737a2f gotthard2: timingsource and currentsource features, (timing source external yet to be implemented in fpga to test (#80) 2020-02-28 12:45:02 +01:00
913df8ecae Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-28 12:26:48 +01:00
c10e04c4eb explicitly setting rx zmq datastream int the ctb Gui 2020-02-28 12:25:48 +01:00
2e2e91b219 ctb adc: get in uV and print in client in mV to get decimals 2020-02-27 15:43:42 +01:00
10ba16a9dc updating versions 2020-02-27 14:26:18 +01:00
8c8032dc69 ctb bug fix: slow adcs incorrect mv read out, needed clk down and usleep before reading 2020-02-27 09:16:22 +01:00
90acd51389 server api changes: for mythen3, jungfrau, eiger as well 2020-02-26 17:52:35 +01:00
f38ed8706f removing gui warnings from qwt section 2020-02-26 16:56:41 +01:00
300b0c8105 Merge pull request #79 from slsdetectorgroup/bursts
Bursts
2020-02-26 11:29:05 +01:00
d9cfc59df6 code refactor in slsdet: prevval for setnumtriggers 2020-02-26 11:27:24 +01:00
80304c2eaf multi progress calculated in one function rather getting all of them from shm 2020-02-26 11:17:49 +01:00
fe3a7b0faf gotthard2: removed unnecessary casting 2020-02-26 11:02:28 +01:00
e66d42a43d old form fix 2020-02-26 10:28:45 +01:00
ec76590f28 Merge branch 'developer' into bursts 2020-02-26 09:29:18 +01:00
2fcb2bff75 dac tests 2020-02-26 09:29:06 +01:00
2310b5e55d Merge branch 'developer' into bursts 2020-02-25 20:03:18 +01:00
dca2d098a9 gui: hide gain legend 2020-02-25 20:03:09 +01:00
462bc2e70c Merge branch 'developer' into bursts 2020-02-25 18:22:58 +01:00
2da3d179ee gotthard2 gain plot in gui 2020-02-25 18:22:18 +01:00
5e6a3b7e3d merge resolved 2020-02-25 15:48:41 +01:00
6a0a931e3e gotthard2: bursts and burst period, written to same register as triggers and delay (kept in server as variables) and set if conditions meet. bursts and burst period only in auto timing and burst mode. Also updating theses registers when switching between timing modes or burst modes 2020-02-25 15:45:40 +01:00
2bec476b4f fixed failed tests 2020-02-25 09:26:57 +01:00
f902bb06ad gui bug fix: trigger timing mode was disconnected 2020-02-24 17:40:00 +01:00
c03bc4a6b4 gotthard2: copy #frames and period when switching between continuous and burst mode 2020-02-24 17:20:51 +01:00
6118567959 gotthard2 gui bug fix: gainbit not masked out 2020-02-24 17:04:37 +01:00
02b367ffe8 mythen3 and gotthard2: updated clocks 2020-02-24 16:50:47 +01:00
87d48fd943 bugfix rxr numpacketscaught if stopped 2020-02-24 15:02:01 +01:00
21a1b872bf bugfix:mythen3 date change 2020-02-24 11:00:16 +01:00
3a74ca8fc2 bugfix: mythen3 git date incorrect 2020-02-24 10:53:06 +01:00
f4b922165f bugfix from earlier commit: dr in readfromreceiver commented out 2020-02-24 10:36:52 +01:00
247d40f5a6 added Zmq image structures 2020-02-21 11:56:44 +01:00
8953235268 reverted to UdpRxSocket.h version of revision fc27cfd (with gcc problem fixed) 2020-02-21 11:07:24 +01:00
3b84684415 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-18 18:26:19 +01:00
d0da5d3fcd update manual 2020-02-18 18:26:11 +01:00
52a89cbcc5 fix for older gcc 2020-02-18 17:54:28 +01:00
d8c9748850 update manual to 4.1.1 2020-02-18 15:49:00 +01:00
f42e87e37f format 2020-02-18 15:03:02 +01:00
53a3656d5e removed copy, fixed receive to external buffer 2020-02-18 15:02:40 +01:00
fc27cfd663 merging problem 2020-02-18 10:55:41 +01:00
6b0bf02a85 Some fixes to use moench 2020-02-18 10:45:53 +01:00
f1bce15a57 replaced udp socket 2020-02-17 17:43:14 +01:00
3ea9b86bf5 date fix 2020-02-13 14:50:23 +01:00
4cce0aee62 Fixed ctbGui to work also with moench03 2020-02-06 14:28:20 +01:00
dfb1b9ad69 Revert "gotthard2: burst mode check"
This reverts commit 4d6996bd55.
2020-02-04 15:29:43 +01:00
4d6996bd55 gotthard2: burst mode check 2020-02-04 15:28:24 +01:00
0ac28c0208 gotthard2: burst mode check for #frames 2020-02-04 15:27:18 +01:00
37c3048c2a gotthard2: bug fix from previosu commit 2020-02-04 12:32:37 +01:00
d3dc9a7690 gotthard2: disentangled burst mode #frames, exptime, period from start of acquisition, order dependent now for debugging 2020-02-04 12:23:58 +01:00
c4559fadb3 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-04 12:00:15 +01:00
806a2736c1 gotthard2: longer wait for startup, period 0 2020-02-04 12:00:07 +01:00
154 changed files with 6603 additions and 3433 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@ bin/
*.out *.out
*.toc *.toc
*.o *.o
*.so
.* .*
build build
RELEASE.txt RELEASE.txt

View File

@ -4,39 +4,25 @@ language: cpp
os: linux os: linux
env: dist: bionic
matrix:
- CONDA_PY=3.6
- CONDA_PY=3.7
- CONDA_PY=3.8
dist: trusty
install: install:
- sudo apt-get update - sudo apt-get update
- ldd --version - ldd --version
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
- bash miniconda.sh -b -p $HOME/miniconda - bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH" - source "$HOME/miniconda/etc/profile.d/conda.sh"
- rm -f miniconda.sh - rm -f miniconda.sh
- hash -r - hash -r
- conda config --set always_yes yes --set changeps1 no - conda config --set always_yes yes --set changeps1 no
- conda config --add channels conda-forge - conda config --add channels conda-forge
- conda config --add channels slsdetectorgroup - conda config --add channels slsdetectorgroup
- conda update conda - conda update -q conda
- conda update --all
- conda install conda-build=3.17
- conda install anaconda-client
- conda install conda-verify
# Useful for debugging any issues with conda
- conda info -a - conda info -a
# Useful for debugging any issues with conda
# Replace dep1 dep2 ... with your dependencies - conda create -q -n testenv conda-build anaconda-client conda-verify
- conda create -q -n test-environment python=$CONDA_PY - conda activate testenv
- source activate test-environment
- conda-build . - conda-build .
script: script:
@ -45,7 +31,8 @@ script:
deploy: deploy:
provider: script provider: script
script: find $HOME/miniconda/conda-bld/${TRAVIS_OS_NAME}-64 -name "*.tar.bz2" -exec anaconda -t $CONDA_TOKEN upload --force {} \; script: find $HOME/miniconda/envs/testenv/conda-bld/${TRAVIS_OS_NAME}-64 -name "*.tar.bz2" -exec anaconda -t $CONDA_TOKEN upload --force {} \;
on: on:
branch: developer branch: developer
tags: true

View File

@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.11) cmake_minimum_required(VERSION 3.12)
project(slsDetectorPackage) project(slsDetectorPackage)
set(PROJECT_VERSION 5.0.0) set(PROJECT_VERSION 5.0.0)
include(CheckIPOSupported) include(CheckIPOSupported)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
cmake_policy(SET CMP0074 NEW) cmake_policy(SET CMP0074 NEW)
include(cmake/project_version.cmake) include(cmake/project_version.cmake)
@ -44,6 +44,9 @@ option(SLS_USE_PYTHON "Python bindings" OFF)
option(SLS_USE_CTBGUI "ctb GUI" OFF) option(SLS_USE_CTBGUI "ctb GUI" OFF)
option(SLS_BUILD_DOCS "docs" OFF) option(SLS_BUILD_DOCS "docs" OFF)
option(SLS_BUILD_EXAMPLES "examples" OFF) option(SLS_BUILD_EXAMPLES "examples" OFF)
option(SLS_TUNE_LOCAL "tune to local machine" OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
@ -111,6 +114,11 @@ if(SLS_USE_SANITIZER)
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread) # target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
endif() endif()
if(SLS_TUNE_LOCAL)
target_compile_options(slsProjectOptions INTERFACE -mtune=native -march=native)
endif()
#rapidjson #rapidjson
add_library(rapidjson INTERFACE) add_library(rapidjson INTERFACE)
target_include_directories(rapidjson INTERFACE target_include_directories(rapidjson INTERFACE
@ -126,7 +134,7 @@ install(TARGETS slsProjectOptions slsProjectWarnings rapidjson
) )
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_INSTALL_RPATH "$ORIGIN") set(CMAKE_INSTALL_RPATH $ORIGIN)
# set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) # set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
@ -174,6 +182,7 @@ if (SLS_USE_INTEGRATION_TESTS)
endif (SLS_USE_INTEGRATION_TESTS) endif (SLS_USE_INTEGRATION_TESTS)
if (SLS_USE_PYTHON) if (SLS_USE_PYTHON)
set(PYBIND11_CPP_STANDARD -std=c++11)
add_subdirectory(libs/pybind11) add_subdirectory(libs/pybind11)
add_subdirectory(python) add_subdirectory(python)
endif(SLS_USE_PYTHON) endif(SLS_USE_PYTHON)

111
README.md
View File

@ -2,90 +2,67 @@
Detailed documentation can be found on the [official site.](https://www.psi.ch/detectors/users-support) Detailed documentation can be found on the [official site.](https://www.psi.ch/detectors/users-support)
### Binaries ### Binaries
Documentation to obtain the binaries via the conda package is available for [lib](https://github.com/slsdetectorgroup/sls_detector_lib) and [gui](https://github.com/slsdetectorgroup/sls_detector_gui) Binaries for the slsDetectorPackage are available through conda.
```
#Add conda channels
conda config --add channels conda-forge
conda config --add channels slsdetectorgroup
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
```
### Source code ### Source code
One can also obtain the source code from this repository and compile while realizing the setup dependencies as required. One can also obtain the source code from this repository and compile.
``` ```
git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git
``` ```
#### Setup dependencies #### Dependencies
* Gui Client <br> * Lib: c++11 compiler (gcc=>4.8), ZeroMQ 4
Requirements: Qt 4.8 and Qwt 6.0 * Gui: Qt 4.8 and Qwt 6.0
``` * Calibration wizards and ctbGUI: ROOT
export QTDIR=/usr/local/Trolltech/ * Optional: HDF5
export QWTDIR=/usr/local/qwt-6.0.1/
```
If either of them does not exist, the GUI client will not be built.
* Advanced user Calibration wizards<br>
Requirements: ROOT
```
export ROOTSYS=/usr/local/root-5.34
```
#### Compilation #### Compilation
Compiling can be done in two ways. 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**<br> **1. Compile using script cmk.sh**<br>
After compiling, the libraries and executables will be found in `slsDetectorPackage/build/bin` directory<br> After compiling, the libraries and executables will be found in `slsDetectorPackage/build/bin` directory<br>
Usage: [-c] [-b] [-h] [-d HDF5 directory] [-j]<br> Usage: [-c] [-b] [-p] [e] [t] [r] [g] [s] [u] [i] [-h] [-d <HDF5 directory>] [-j] <Number of threads>
* -[no option]: only make<br> -[no option]: only make
* -c: Clean<br> -c: Clean
* -b: Builds/Rebuilds CMake files normal mode<br> -b: Builds/Rebuilds CMake files normal mode
* -h: Builds/Rebuilds Cmake files with HDF5 package<br> -p: Builds/Rebuilds Python API
* -d: HDF5 Custom Directory<br> -h: Builds/Rebuilds Cmake files with HDF5 package
* -t: Build/Rebuilds only text client<br> -d: HDF5 Custom Directory
* -r: Build/Rebuilds only receiver<br> -t: Build/Rebuilds only text client
* -g: Build/Rebuilds only gui<br> -r: Build/Rebuilds only receiver
* -j: Number of threads to compile through<br> -g: Build/Rebuilds only gui
* -e: Debug mode -s: Simulator
-u: Chip Test Gui
Basic Option: -j: Number of threads to compile through
./cmk.sh -b -e: Debug mode
-i: Builds tests
For only make:
./cmk.sh
For make clean;make:
./cmk.sh -c
For using hdf5 without custom dir /blabla:
./cmk.sh -h -d /blabla
For rebuilding cmake without hdf5
./cmk.sh -b
For using multiple cores to compile faster:
./cmk.sh -j9<br>
For rebuilding only certain sections<br>
./cmk.sh -tg #only text client and gui<br>
./cmk.sh -r #only receiver<br>
eg. Rebuild when you switch to a new build and compile in parallel:
./cmk.sh -bj5
**2. Compile without script**<br> **2. Compile without script**<br>
Use cmake to create out-of-source builds, by creating a build folder parallel to source directory. 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.
``` ```
$ cd .. $ mkdir build
$ mkdir slsDetectorPackage-build $ cd build
$ cd slsDetectorPackage-build $ cmake ../slsDetectorPackage -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_SANITIZER=ON
$ cmake ../slsDetectorPackage -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_HDF5=OFF $ make -j12 #or whatever number of threads wanted
$ make
```
Use the following as an example to compile statically and using specific hdf5 folder
```
$ HDF5_ROOT=/opt/hdf5v1.10.0 cmake ../slsDetectorPackage -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_HDF5=ON
```
After compiling, the libraries and executables will be found at `bin` directory
```
$ ls bin/
gui_client libSlsDetector.a libSlsDetector.so libSlsReceiver.a libSlsReceiver.so
sls_detector_acquire sls_detector_get slsDetectorGui sls_detector_help sls_detector_put slsReceiver slsMultiReceiver
``` ```

4
cmk.sh
View File

@ -187,8 +187,8 @@ fi
#Debug #Debug
if [ $DEBUG -eq 1 ]; then if [ $DEBUG -eq 1 ]; then
CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug " # CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug "
# CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_SANITIZER=ON " CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_SANITIZER=ON "
echo "Debug Option enabled" echo "Debug Option enabled"
fi fi

View File

@ -1,3 +1,4 @@
mkdir build mkdir build
mkdir install mkdir install
cd build cd build
@ -6,7 +7,7 @@ cmake .. \
-DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_INSTALL_PREFIX=install \
-DSLS_USE_TEXTCLIENT=ON \ -DSLS_USE_TEXTCLIENT=ON \
-DSLS_USE_RECEIVER=ON \ -DSLS_USE_RECEIVER=ON \
-DSLS_USE_GUI=OFF \ -DSLS_USE_GUI=ON \
-DSLS_USE_TESTS=ON \ -DSLS_USE_TESTS=ON \
-DSLS_USE_PYTHON=OFF \ -DSLS_USE_PYTHON=OFF \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \

View File

@ -1,14 +1,4 @@
# mkdir $PREFIX/lib echo "|<-------- starting python build"
# mkdir $PREFIX/include
# #Shared and static libraries
# cp build/bin/_sls_detector* $PREFIX/lib/.
# #Binaries
# cp -r build/bin/sls_detector $PREFIX/lib/.
cd python cd python
${PYTHON} setup.py install ${PYTHON} setup.py install

View File

@ -0,0 +1,7 @@
python:
- 3.6
- 3.7
- 3.8
numpy:
- 1.17

View File

@ -0,0 +1,9 @@
mkdir $PREFIX/lib
mkdir $PREFIX/bin
mkdir $PREFIX/include
cp build/bin/ctbGui $PREFIX/bin/.
cp build/bin/libctbRootLib.so $PREFIX/lib/.

View File

@ -1,15 +1,3 @@
#Copy the GUI
mkdir $PREFIX/lib
mkdir $PREFIX/bin mkdir $PREFIX/bin
mkdir $PREFIX/include
#No libs for gui?
#Binaries
cp build/bin/gui_client $PREFIX/bin/.
cp build/bin/slsDetectorGui $PREFIX/bin/. cp build/bin/slsDetectorGui $PREFIX/bin/.
#Which headers do we need for development??
# cp include/some_lib.h $PREFIX/include/.

View File

@ -1,13 +1,14 @@
package: package:
name: sls_detector_software name: sls_detector_software
version: "developer" version: {{ environ.get('GIT_DESCRIBE_TAG', '') }}
source: source:
- path: .. - path: ..
build: build:
number: 1 number: 2
binary_relocation: True
rpaths: rpaths:
- lib/ - lib/
@ -16,10 +17,9 @@ requirements:
- {{ compiler('c') }} - {{ compiler('c') }}
- {{compiler('cxx')}} - {{compiler('cxx')}}
- cmake - cmake
# - qwt 6.* #require qt5 investigate befor activating gui - qwt 6.*
# - qt=4.8.7=7 - qt 4.8.*
- zeromq=4.2.5=hfc679d8_5 - zeromq
- pyzmq
- xorg-libx11 - xorg-libx11
- xorg-libice - xorg-libice
- xorg-libxext - xorg-libxext
@ -51,70 +51,46 @@ requirements:
outputs: outputs:
- name: sls_detector_lib - name: slsdetlib
script: copy_lib.sh script: copy_lib.sh
- name: sls_detector requirements:
run:
- libstdcxx-ng
- libgcc-ng
- zeromq
- name: slsdet
script: build_pylib.sh script: build_pylib.sh
requirements: requirements:
build: build:
- python
- {{ compiler('c') }} - {{ compiler('c') }}
- {{compiler('cxx')}} - {{compiler('cxx')}}
- python {{ python }} - {{ pin_subpackage('slsdetlib', exact=True) }}
- setuptools - setuptools
- sls_detector_lib
- pyzmq
- pybind11 2.4
host: host:
- python - python
- pybind11 2.4
- pyzmq run:
- sls_detector_lib
- libstdcxx-ng - libstdcxx-ng
- libgcc-ng - libgcc-ng
run:
- python - python
- numpy - numpy
- sls_detector_lib=developer - {{ pin_subpackage('slsdetlib', exact=True) }}
- pyzmq
- libstdcxx-ng
- libgcc-ng
test: test:
imports: imports:
- sls_detector - slsdet
# requirements: - name: slsdetgui
# build: script: copy_gui.sh
# - {{ compiler('c') }} requirements:
# - {{compiler('cxx')}} run:
- {{ pin_subpackage('slsdetlib', exact=True) }}
# - name: sls_detector_gui - qwt 6.*
# version: "refactor" - qt 4.8.*
# script: copy_gui.sh
# requirements:
# build:
# - {{ compiler('c') }}
# - {{compiler('cxx')}}
# - cmake
# - qwt 6.*
# - qt=4.8.7=7
# - zeromq=4.2.5=hfc679d8_5
# - pyzmq
# - xorg-libx11
# - xorg-libice
# - xorg-libxext
# - xorg-libsm
# - xorg-libxau
# - xorg-libxrender
# - xorg-libxfixes
# - {{ cdt('mesa-libgl-devel') }} # [linux]
# - {{ cdt('mesa-libegl-devel') }} # [linux]
# - {{ cdt('mesa-dri-drivers') }} # [linux]
# - {{ cdt('libselinux') }} # [linux]
# - {{ cdt('libxdamage') }} # [linux]
# - {{ cdt('libxxf86vm') }} # [linux]
# run:
# - sls_detector_lib=refactor
# - qwt 6.*
# - qt=4.8.7=7

View File

@ -71,6 +71,11 @@ target_link_libraries(ctbRootLib PUBLIC
${ROOT_EXE_LINKER_FLAGS} ${ROOT_EXE_LINKER_FLAGS}
) )
set_target_properties(
ctbRootLib PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
target_link_libraries(ctbGui PUBLIC target_link_libraries(ctbGui PUBLIC
slsDetectorShared slsDetectorShared
slsSupportLib slsSupportLib
@ -80,4 +85,5 @@ target_link_libraries(ctbGui PUBLIC
set_target_properties(ctbGui PROPERTIES set_target_properties(ctbGui PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
) )

View File

@ -29,9 +29,10 @@
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include "ctbMain.h" #include "ctbMain.h"
#include "moench03CtbData.h" #include "moench03CtbData.h"
#include "moench03TCtbData.h" //#include "moench03TCtbData.h"
#include "moench03T1CtbData.h" //#include "moench03T1CtbData.h"
#include "moench03CommonMode.h" #include "moench03CommonMode.h"
#include "moench03T1ZmqDataNew.h"
#include "moench02CtbData.h" #include "moench02CtbData.h"
//#include "jungfrau10ModuleData.h" //#include "jungfrau10ModuleData.h"
#include "moenchCommonMode.h" #include "moenchCommonMode.h"
@ -43,6 +44,9 @@
#include "moench04CtbZmq10GbData.h" #include "moench04CtbZmq10GbData.h"
#include "deserializer.h" #include "deserializer.h"
#include "detectorData.h" #include "detectorData.h"
#include "imageZmq16bit.h"
#include "imageZmq32bit.h"
using namespace std; using namespace std;
@ -232,7 +236,10 @@ hframe=new TGHorizontalFrame(this, 800,50);
cbDetType->AddEntry("MOENCH02", MOENCH02); cbDetType->AddEntry("MOENCH02", MOENCH02);
cbDetType->AddEntry("MOENCH04", MOENCH04); cbDetType->AddEntry("MOENCH04", MOENCH04);
// cbDetType->AddEntry("JUNGFRAU1.0", 2); // cbDetType->AddEntry("JUNGFRAU1.0", 2);
//cbDetType->AddEntry("MOENCH03 T", iiii++); cbDetType->AddEntry("MOENCH03",MOENCH03);
cbDetType->AddEntry("IMAGE32BIT",IMAGE32B);
cbDetType->AddEntry("IMAGE16BIT",IMAGE16B);
//cbDetType->AddEntry("MOENCH03", iiii++); //cbDetType->AddEntry("MOENCH03", iiii++);
// cbDetType->AddEntry("MYTHEN3 0.1", MYTHEN301); // cbDetType->AddEntry("MYTHEN3 0.1", MYTHEN301);
// cbDetType->AddEntry("ADCSAR2", ADCSAR2); // cbDetType->AddEntry("ADCSAR2", ADCSAR2);
@ -271,7 +278,7 @@ hframe=new TGHorizontalFrame(this, 800,50);
cout << "off "<< endl; // cout << "off "<< endl;
hframe=new TGHorizontalFrame(this, 800,50); hframe=new TGHorizontalFrame(this, 800,50);
@ -290,8 +297,8 @@ hframe=new TGHorizontalFrame(this, 800,50);
TGNumberFormat::kNEANonNegative, TGNumberFormat::kNEANonNegative,
TGNumberFormat::kNELLimitMinMax,0,16535); TGNumberFormat::kNELLimitMinMax,0,16535);
hframe->AddFrame(eSerOff,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1)); hframe->AddFrame(eSerOff,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1));
eSerOff->MapWindow();; eSerOff->MapWindow();
eSerOff->SetNumber(5); eSerOff->SetNumber(0);
e= eSerOff->TGNumberEntry::GetNumberEntry(); e= eSerOff->TGNumberEntry::GetNumberEntry();
eSerOff->Connect("ValueSet(Long_t)","ctbAcquisition",this,"ChangeSerialOffset(Long_t)"); eSerOff->Connect("ValueSet(Long_t)","ctbAcquisition",this,"ChangeSerialOffset(Long_t)");
e->Connect("ReturnPressed()","ctbAcquisition",this,"ChangeSerialOffset()"); e->Connect("ReturnPressed()","ctbAcquisition",this,"ChangeSerialOffset()");
@ -337,6 +344,53 @@ hframe=new TGHorizontalFrame(this, 800,50);
hframe=new TGHorizontalFrame(this, 800,50);
AddFrame(hframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 10,10,10,10));
hframe->MapWindow();
label=new TGLabel(hframe,"Image Pixels");
hframe->AddFrame(label,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 5, 5, 5, 5));
label->MapWindow();
label->SetTextJustify(kTextLeft);
label=new TGLabel(hframe,"X: ");
hframe->AddFrame(label,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 5, 5, 5, 5));
label->MapWindow();
label->SetTextJustify(kTextRight);
ePixX=new TGNumberEntry(hframe, 0, 9,999, TGNumberFormat::kNESInteger,
TGNumberFormat::kNEANonNegative,
TGNumberFormat::kNELLimitMinMax,0,16535);
hframe->AddFrame(ePixX,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1));
ePixX->MapWindow();
ePixX->SetNumber(400);
e= ePixX->TGNumberEntry::GetNumberEntry();
ePixX->Connect("ValueSet(Long_t)","ctbAcquisition",this,"ChangeImagePixels(Long_t)");
e->Connect("ReturnPressed()","ctbAcquisition",this,"ChangeImagePixels()");
label=new TGLabel(hframe,"Y: ");
hframe->AddFrame(label,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 5, 5, 5, 5));
label->MapWindow();
label->SetTextJustify(kTextRight);
ePixY=new TGNumberEntry(hframe, 0, 9,999, TGNumberFormat::kNESInteger,
TGNumberFormat::kNEANonNegative,
TGNumberFormat::kNELLimitMinMax,0,16535);
hframe->AddFrame(ePixY,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1));
ePixY->MapWindow();
ePixY->SetNumber(400);
e= ePixY->TGNumberEntry::GetNumberEntry();
ePixY->Connect("ValueSet(Long_t)","ctbAcquisition",this,"ChangeImagePixels(Long_t)");
e->Connect("ReturnPressed()","ctbAcquisition",this,"ChangeImagePixels()");
hframe=new TGHorizontalFrame(this, 800,50); hframe=new TGHorizontalFrame(this, 800,50);
@ -610,7 +664,9 @@ hframe=new TGHorizontalFrame(this, 800,50);
try { try {
myDet->registerDataCallback(&dataCallback, (void*)this); myDet->registerDataCallback(&dataCallback, (void*)this);
} CATCH_DISPLAY ("Could not get register call back.", "ctbAcquisition::ctbAcquisition") } CATCH_DISPLAY ("Could not get register call back.", "ctbAcquisition::ctbAcquisition")
try {
myDet->setRxZmqDataStream(true);
} CATCH_DISPLAY ("Could not get set RxZmqDataStream.", "ctbAcquisition::ctbAcquisition")
cout <<"Done" << endl; cout <<"Done" << endl;
// mgAdcs=new TMultiGraph(); // mgAdcs=new TMultiGraph();
@ -832,7 +888,7 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
// cout <<"global plot is " << globalPlot << endl; // cout <<"global plot is " << globalPlot << endl;
// cout << "*******************************************" <<endl; // cout << "*******************************************" <<endl;
// cout <<"------Plot: "<< index << " prog:" << data->progressIndex << " npoints:" << data->npoints << " npy: " << data->npy << " " << data->fileName << " bytes: " << data->databytes << " dr:"<< data->dynamicRange << " fi: " << data ->fileIndex << endl; cout <<"------Plot: "<< index << " prog:" << data->progressIndex << " nx:" << data->nx << " ny: " << data->ny << " " << data->fileName << " bytes: " << data->databytes << " dr:"<< data->dynamicRange << " fi: " << data ->fileIndex << endl;
if (globalPlot || cbGetPedestal->IsOn()) { if (globalPlot || cbGetPedestal->IsOn()) {
//#ifdef TESTADC //#ifdef TESTADC
// cout <<"------"<< index << " " << ip << " " << data->npoints << endl; // cout <<"------"<< index << " " << ip << " " << data->npoints << endl;
@ -859,6 +915,11 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
nx=eNumCount->GetIntNumber(); nx=eNumCount->GetIntNumber();
dr=eDynRange->GetIntNumber(); dr=eDynRange->GetIntNumber();
soff=eSerOff->GetIntNumber(); soff=eSerOff->GetIntNumber();
// cout <<"deserializer: " << endl;
// cout << "Number of chans:\t" << nx << endl;
// cout << "Serial Offset:\t" << soff << endl;
// cout << "Dynamic range:\t" << dr << endl;
} }
i=0; i=0;
@ -923,7 +984,8 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
for (int y=0; y<ny; y++) { for (int y=0; y<ny; y++) {
ped=0; ped=0;
aval=dataStructure->getValue(data->data,x,y); aval=dataStructure->getValue(data->data,x,y);
//aval=dataStructure->getChannel(data->data,x,y);
cout << x << " " <<y << " "<< aval << endl;
if (cbGetPedestal->IsOn()) { if (cbGetPedestal->IsOn()) {
if (photonFinder) { if (photonFinder) {
photonFinder->addToPedestal(aval,x,y); photonFinder->addToPedestal(aval,x,y);
@ -1095,7 +1157,19 @@ void ctbAcquisition::changePlot(){
if (rbPlotOff->IsOn()) { if (rbPlotOff->IsOn()) {
adcPlot=0; adcPlot=0;
dbitPlot=0; dbitPlot=0;
try {
myDet->registerDataCallback(nullptr, this);
} CATCH_DISPLAY ("Could not get unregister call back.", "ctbAcquisition::ctbAcquisition")
try {
myDet->setRxZmqDataStream(false);
} CATCH_DISPLAY ("Could not get unset RxZmqDataStream.", "ctbAcquisition::ctbAcquisition")
} else { } else {
try {
myDet->registerDataCallback(&dataCallback, (void*)this);
} CATCH_DISPLAY ("Could not get register call back.", "ctbAcquisition::ctbAcquisition")
try {
myDet->setRxZmqDataStream(true);
} CATCH_DISPLAY ("Could not get set RxZmqDataStream.", "ctbAcquisition::ctbAcquisition")
adcPlot=0; adcPlot=0;
dbitPlot=0; dbitPlot=0;
for (int ii=0; ii<NADCS; ii++) for (int ii=0; ii<NADCS; ii++)
@ -1200,6 +1274,9 @@ void ctbAcquisition::changeDetector(){
eNumCount->SetState(kFALSE); eNumCount->SetState(kFALSE);
eDynRange->SetState(kFALSE); eDynRange->SetState(kFALSE);
eSerOff->SetState(kFALSE); eSerOff->SetState(kFALSE);
ePixX->SetState(kFALSE);
ePixY->SetState(kFALSE);
deserializer=0; deserializer=0;
if (rb2D->IsOn() ) {//|| rbScan->IsOn() if (rb2D->IsOn() ) {//|| rbScan->IsOn()
switch (cbDetType->GetSelected()) { switch (cbDetType->GetSelected()) {
@ -1210,7 +1287,6 @@ void ctbAcquisition::changeDetector(){
// commonMode=new moench03CommonMode(); // commonMode=new moench03CommonMode();
break; break;
case MOENCH04: case MOENCH04:
try { try {
auto retval = myDet->getTenGiga().tsquash("Different values"); auto retval = myDet->getTenGiga().tsquash("Different values");
if (retval) { if (retval) {
@ -1223,6 +1299,54 @@ void ctbAcquisition::changeDetector(){
cout << "MOENCH 0.4!" << endl; cout << "MOENCH 0.4!" << endl;
commonMode=new moench03CommonMode(); commonMode=new moench03CommonMode();
break; break;
case MOENCH03:
//try {
// auto retval = myDet->getTenGiga().tsquash("Different values");
// if (retval) {
dataStructure=new moench03T1ZmqDataNew(nAnalogSamples);
// } else {
// dataStructure=new moench04CtbZmqData(nAnalogSamples, nDigitalSamples);
// }
//} CATCH_DISPLAY ("Could not get ten giga enable.", "ctbAcquisition::changeDetector")
cout << "MOENCH 0.3! USE JUNGFRAU MODULE!" << endl;
commonMode=new moench03CommonMode();
break;
case IMAGE32B:
//try {
// auto retval = myDet->getTenGiga().tsquash("Different values");
// if (retval) {
// if (deserializer) {
ePixX->SetState(kTRUE);
ePixY->SetState(kTRUE);
// }
dataStructure=new imageZmq32bit(ePixX->GetIntNumber(),ePixY->GetIntNumber());
// } else {
// dataStructure=new moench04CtbZmqData(nAnalogSamples, nDigitalSamples);
// }
//} CATCH_DISPLAY ("Could not get ten giga enable.", "ctbAcquisition::changeDetector")
cout << "Image 32bit, no channel shuffling" << endl;
commonMode=NULL;
break;
case IMAGE16B:
//try {
// auto retval = myDet->getTenGiga().tsquash("Different values");
// if (retval) {
// if (deserializer) {
ePixX->SetState(kTRUE);
ePixY->SetState(kTRUE);
// }
dataStructure=new imageZmq16bit(ePixX->GetIntNumber(),ePixY->GetIntNumber());
// } else {
// dataStructure=new moench04CtbZmqData(nAnalogSamples, nDigitalSamples);
// }
//} CATCH_DISPLAY ("Could not get ten giga enable.", "ctbAcquisition::changeDetector")
cout << "Image 16bit, no channel shuffling" << endl;
commonMode=NULL;
break;
// case 1: // case 1:
// cout << "************** T!!!!!!!!!!" << endl; // cout << "************** T!!!!!!!!!!" << endl;
@ -1286,6 +1410,7 @@ void ctbAcquisition::changeDetector(){
photonFinder=new singlePhotonDetector(dataStructure,csize,nsigma,1,cm); //sign is positive - should correct with ADC mask, no common mode photonFinder=new singlePhotonDetector(dataStructure,csize,nsigma,1,cm); //sign is positive - should correct with ADC mask, no common mode
//photonFinder=new singlePhotonDetector(dataStructure,csize,nsigma,1,cm); //sign is positive - should correct with ADC mask, no common mode //photonFinder=new singlePhotonDetector(dataStructure,csize,nsigma,1,cm); //sign is positive - should correct with ADC mask, no common mode
dataStructure->getDetectorSize(nx,ny); dataStructure->getDetectorSize(nx,ny);
} }
if (deserializer) { if (deserializer) {
ny=1; ny=1;
@ -1511,13 +1636,13 @@ void ctbAcquisition::update() {
if (dataStructure) { if (dataStructure) {
cout << cbDetType->GetSelected()<< endl; cout << cbDetType->GetSelected()<< endl;
if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302){ // if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302){
cout << "settings deserialiation parameters for MYTHEN" << endl; // cout << "settings deserialiation parameters for MYTHEN" << endl;
mythen3_01_jctbData* ms=(mythen3_01_jctbData*)dataStructure; // mythen3_01_jctbData* ms=(mythen3_01_jctbData*)dataStructure;
eSerOff->SetNumber( ms->setSerialOffset(-1)); // eSerOff->SetNumber( ms->setSerialOffset(-1));
eDynRange->SetNumber( ms->setDynamicRange(-1)); // eDynRange->SetNumber( ms->setDynamicRange(-1));
eNumCount->SetNumber( ms->setNumberOfCounters(-1)); // eNumCount->SetNumber( ms->setNumberOfCounters(-1));
} // }
} }
@ -1977,20 +2102,22 @@ void ctbAcquisition::ChangeNumberOfChannels(Long_t a){
void ctbAcquisition::ChangeSerialOffset(){ void ctbAcquisition::ChangeSerialOffset(){
changeDetector();
// if (dataStructure) { // if (dataStructure) {
// // cout << cbDetType->GetSelected()<< endl; // cout << cbDetType->GetSelected()<< endl;
// // if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302 ){ // if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302 ){
// // cout << "settings offsets for MYTHEN" << endl; // cout << "settings offsets for MYTHEN" << endl;
// // mythen3_01_jctbData* ms=(mythen3_01_jctbData*)dataStructure; // mythen3_01_jctbData* ms=(mythen3_01_jctbData*)dataStructure;
// // ms->setSerialOffset(eSerOff->GetIntNumber()); // ms->setSerialOffset(eSerOff->GetIntNumber());
// // } // }
// } // }
}; };
void ctbAcquisition::ChangeDynamicRange(){ void ctbAcquisition::ChangeDynamicRange(){
changeDetector();
// if (dataStructure) { // if (dataStructure) {
// cout << cbDetType->GetSelected()<< endl; // cout << cbDetType->GetSelected()<< endl;
@ -2004,6 +2131,7 @@ void ctbAcquisition::ChangeDynamicRange(){
}; };
void ctbAcquisition::ChangeNumberOfChannels(){ void ctbAcquisition::ChangeNumberOfChannels(){
changeDetector();
// if (dataStructure) { // if (dataStructure) {
// cout << cbDetType->GetSelected()<< endl; // cout << cbDetType->GetSelected()<< endl;
// if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302){ // if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302){
@ -2017,6 +2145,24 @@ void ctbAcquisition::ChangeNumberOfChannels(){
changePlot(); changePlot();
}; };
void ctbAcquisition::ChangeImagePixels(Long_t a){
ChangeImagePixels();
};
void ctbAcquisition::ChangeImagePixels(){
changeDetector();
// if (dataStructure) {
// cout << cbDetType->GetSelected()<< endl;
// if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302){
// cout << "settings number of channels for MYTHEN" << endl;
// mythen3_01_jctbData* ms=(mythen3_01_jctbData*)dataStructure;
// ms->setNumberOfCounters(eNumCount->GetIntNumber());
// }
// }
// if (deserializer)
// changePlot();
};
void ctbAcquisition::ChangeHistoLimitsPedSub(Long_t a){ void ctbAcquisition::ChangeHistoLimitsPedSub(Long_t a){

View File

@ -42,7 +42,7 @@ using namespace std;
class ctbAcquisition : public TGGroupFrame { class ctbAcquisition : public TGGroupFrame {
enum {DESERIALIZER, MOENCH04, MOENCH02, ADCSAR2, MYTHEN301, MYTHEN302}; enum {DESERIALIZER, MOENCH04, MOENCH02, MOENCH03, IMAGE32B, IMAGE16B, ADCSAR2, MYTHEN301, MYTHEN302};
private: private:
@ -57,6 +57,9 @@ class ctbAcquisition : public TGGroupFrame {
TGNumberEntry *eNumCount; TGNumberEntry *eNumCount;
TGNumberEntry *ePixX;
TGNumberEntry *ePixY;
TGNumberEntry *eFitADC; TGNumberEntry *eFitADC;
TGNumberEntry *eBitPlot; TGNumberEntry *eBitPlot;
TGNumberEntry *eMinRaw; TGNumberEntry *eMinRaw;
@ -231,7 +234,8 @@ class ctbAcquisition : public TGGroupFrame {
void ChangeNumberOfChannels(Long_t); void ChangeNumberOfChannels(Long_t);
void ChangeDynamicRange(); void ChangeDynamicRange();
void ChangeDynamicRange(Long_t); void ChangeDynamicRange(Long_t);
void ChangeImagePixels();
void ChangeImagePixels(Long_t);
void canvasClicked(); void canvasClicked();
void FitADC(); void FitADC();

View File

@ -108,15 +108,26 @@ string ctbDac::getLabel() {
} }
int ctbDac::getMoenchDacId() {
slsDetectorDefs::dacIndex moenchDacIndices[8] = {slsDetectorDefs::VBP_COLBUF, slsDetectorDefs::VIPRE, slsDetectorDefs::VIN_CM, slsDetectorDefs::VB_SDA, slsDetectorDefs::VCASC_SFP, slsDetectorDefs::VOUT_CM, slsDetectorDefs::VIPRE_CDS, slsDetectorDefs::IBIAS_SFP};
if (id >= 8) {
return id;
}
return static_cast<int>(moenchDacIndices[id]);
}
void ctbDac::setValue(Long_t a) {setValue();} void ctbDac::setValue(Long_t a) {setValue();}
void ctbDac::setValue() { void ctbDac::setValue() {
cout << "setting dac! "<< id << " value " << dacsEntry->GetIntNumber() << " units " << dacsUnit->IsOn() << endl; cout << "setting dac! "<< id << " value " << dacsEntry->GetIntNumber() << " units " << dacsUnit->IsOn() << endl;
try { try {
myDet->setDAC(static_cast<slsDetectorDefs::dacIndex>(id), dacsEntry->GetIntNumber(), dacsUnit->IsOn()); int sid = id;
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
sid = getMoenchDacId();
}
myDet->setDAC(static_cast<slsDetectorDefs::dacIndex>(sid), dacsEntry->GetIntNumber(), dacsUnit->IsOn());
} CATCH_DISPLAY ("Could not set dac " + to_string(id) + ".", "ctbDac::setValue") } CATCH_DISPLAY ("Could not set dac " + to_string(id) + ".", "ctbDac::setValue")
getValue(); getValue();
@ -128,7 +139,11 @@ void ctbDac::setOn(Bool_t b) {
setValue(); setValue();
} else { } else {
try { try {
myDet->setDAC(static_cast<slsDetectorDefs::dacIndex>(id), -100, false); int sid = id;
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
sid = getMoenchDacId();
}
myDet->setDAC(static_cast<slsDetectorDefs::dacIndex>(sid), -100, false);
} CATCH_DISPLAY ("Could not power off dac " + to_string(id) + ".", "ctbDac::setOn") } CATCH_DISPLAY ("Could not power off dac " + to_string(id) + ".", "ctbDac::setOn")
} }
getValue(); getValue();
@ -136,7 +151,11 @@ void ctbDac::setOn(Bool_t b) {
int ctbDac::getValue() { int ctbDac::getValue() {
try { try {
int val = myDet->getDAC(static_cast<slsDetectorDefs::dacIndex>(id), dacsUnit->IsOn()).tsquash("Different values"); int sid = id;
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
sid = getMoenchDacId();
}
int val = myDet->getDAC(static_cast<slsDetectorDefs::dacIndex>(sid), dacsUnit->IsOn()).tsquash("Different values");
cout << "dac " << id << " " << val << endl; cout << "dac " << id << " " << val << endl;
dacsValue->SetText(to_string(val).c_str()); dacsValue->SetText(to_string(val).c_str());
if (val >= 0) { if (val >= 0) {

View File

@ -45,7 +45,7 @@ class ctbDac : public TGHorizontalFrame {
int setLabel(char *tit, int mv); int setLabel(char *tit, int mv);
string getLabel(); string getLabel();
int getMoenchDacId();
ClassDef(ctbDac,0) ClassDef(ctbDac,0)
@ -54,8 +54,6 @@ class ctbDac : public TGHorizontalFrame {
class ctbDacs : public TGGroupFrame { class ctbDacs : public TGGroupFrame {
private: private:
ctbDac *dacs[NDACS+2]; ctbDac *dacs[NDACS+2];
sls::Detector* myDet; sls::Detector* myDet;

View File

@ -71,10 +71,10 @@ class ctbDefs {
std::string exceptionMessage, std::string exceptionMessage,
std::string source) { std::string source) {
// because sls_detector_exceptions cannot be included // because sls_detector_exceptions cannot be included
if (exceptionMessage.find("hared memory")) { if (exceptionMessage.find("hared memory") != std::string::npos) {
throw; throw;
} }
if (exceptionMessage.find("annot connect")) { if (exceptionMessage.find("annot connect") != std::string::npos) {
throw; throw;
} }
cprintf(RED, "Warning (%s): %s [Caught Exception: %s]\n", source.c_str(), message.c_str(), exceptionMessage.c_str()); cprintf(RED, "Warning (%s): %s [Caught Exception: %s]\n", source.c_str(), message.c_str(), exceptionMessage.c_str());

View File

@ -259,8 +259,10 @@ ctbMain::ctbMain(const TGWindow *p, sls::Detector *det)
cout << "connect mtab" << endl; cout << "connect mtab" << endl;
try{
setReadoutMode(pat->getReadoutMode()); setReadoutMode(pat->getReadoutMode());
} CATCH_DISPLAY ("Could not get readout flags", "ctbPattern::getReadoutMode")
setADCEnable(adcs->setEnable()); setADCEnable(adcs->setEnable());
setAnalogSamples(pat->getAnalogSamples()); setAnalogSamples(pat->getAnalogSamples());
setDigitalSamples(pat->getDigitalSamples()); setDigitalSamples(pat->getDigitalSamples());

View File

@ -1036,8 +1036,13 @@ void ctbPattern::readoutModeChanged(int flags) {
} }
int ctbPattern::getReadoutMode() { int ctbPattern::getReadoutMode() {
int retval=slsDetectorDefs::ANALOG_ONLY;
if (myDet->getDetectorType().squash() == slsDetectorDefs::CHIPTESTBOARD) {
try{ try{
auto retval = myDet->getReadoutMode().tsquash("Different values"); retval = myDet->getReadoutMode().tsquash("Different values");
} CATCH_DISPLAY ("Could not get readout flags", "ctbPattern::getReadoutMode")
switch(retval) { switch(retval) {
case slsDetectorDefs::ANALOG_AND_DIGITAL: case slsDetectorDefs::ANALOG_AND_DIGITAL:
cout << "analog and digital" << endl; cout << "analog and digital" << endl;
@ -1057,11 +1062,15 @@ int ctbPattern::getReadoutMode() {
default: default:
throw("unknown readout flag"); throw("unknown readout flag");
} }
} else {
cbAnalog->SetOn(kTRUE);
cbDigital->SetOn(kFALSE);
}
Emit("readoutModeChanged(int)",static_cast<int>(retval)); Emit("readoutModeChanged(int)",static_cast<int>(retval));
return retval; return retval;
} CATCH_DISPLAY ("Could not get readout flags", "ctbPattern::getReadoutMode")
return -1;
} }
int ctbPattern::getAnalogSamples() { int ctbPattern::getAnalogSamples() {
@ -1076,12 +1085,16 @@ int ctbPattern::getAnalogSamples() {
} }
int ctbPattern::getDigitalSamples() { int ctbPattern::getDigitalSamples() {
int retval=0;
if (myDet->getDetectorType().squash() == slsDetectorDefs::CHIPTESTBOARD) {
try{ try{
auto retval = myDet->getNumberOfDigitalSamples().tsquash("Different values"); auto retval = myDet->getNumberOfDigitalSamples().tsquash("Different values");
} CATCH_DISPLAY ("Could not get number of digital samples.", "ctbPattern::getDigitalSamples")
}
eDigitalSamples->SetNumber((Double_t)retval); eDigitalSamples->SetNumber((Double_t)retval);
Emit("digitalSamplesChanged(const int)", eDigitalSamples->GetNumber()); Emit("digitalSamplesChanged(const int)", eDigitalSamples->GetNumber());
return eDigitalSamples->GetNumber(); return eDigitalSamples->GetNumber();
} CATCH_DISPLAY ("Could not get number of triggers.", "ctbPattern::update")
return -1; return -1;
} }

View File

@ -12,7 +12,7 @@ file writing etc.
.. code-block:: python .. code-block:: python
from sls_detector import Eiger from slsdet import Eiger
d = Eiger() d = Eiger()
threshold = range(0, 2000, 200) threshold = range(0, 2000, 200)

View File

@ -1,4 +1,14 @@
hostname bchip085+ initialchecks 0
#############################################
### edit with hostname or IP address of your detector
############################################
hostname bchip181+
runclk 40
adcclk 20
dbitclk 40
patword 0000 0000000000000000 patword 0000 0000000000000000
patword 0001 0000000000000000 patword 0001 0000000000000000
@ -408,84 +418,84 @@ patnloop1 0
patloop2 0400 0400 patloop2 0400 0400
patnloop2 0 patnloop2 0
patwait0 00aa patwait0 00aa
patwaittime0 40000 patwaittime0 10000
patwait1 0400 patwait1 0400
patwaittime1 0 patwaittime1 0
patwait2 0400 patwait2 0400
patwaittime2 0 patwaittime2 0
####mcp2011 #0:rx_tcpport 1977
#0:rx_udpip 10.1.1.102
#0:detectorip 10.1.1.19
#0:rx_udpport 32410
####gui listening to
#zmqip 129.129.202.131
#zmqport 30001
####data streaming out of
#rx_zmqip 10.1.2.103
#rx_zmqport 30003
#0:rx_hostname mpc2011
####mx-test-1 #############################################
0:rx_udpip 10.1.1.100 ### edit with 10 Gbs IP of your server
0:detectorip 10.1.1.19 ############################################
0:rx_udpport 32410 #0:udp_dstip 10.1.1.102
####gui listening to (on receiver pc) 0:udp_dstip 129.129.202.136
zmqip 129.129.202.92 #############################################
zmqport 30001 ### edit with any number in the subnet of your server (first 3 numbers as above)
####data streaming out of ############################################
rx_zmqip 10.1.1.100 #0:udp_srcip 10.1.1.19
rx_zmqport 30003 0:udp_srcip 129.129.202.13
0:rx_hostname pcmoench01
0:udp_dstport 33410
#############################################
### edit with 10 Gbs IP of your server
############################################
#zmqip 129.129.202.110
#rx_zmqip 10.1.1.102
#rx_zmqport 30001
#############################################
### edit with 1 Gbs IP of PC where you will run the GUI
############################################
#zmqip 129.129.202.110
#zmqport 50001
#############################################
### edit with hostname or 1Gbs IP address of your server
############################################
rx_hostname mpc2011
tengiga 0
#turn on datastream from commandline
rx_datastream 1 rx_datastream 1
rx_readfreq 1
r_readfreq 1
#0:configuremac -1
rx_datastream 1
r_readfreq 1
dac:6 800 dac 6 800
dac:0 1300 dac 0 1300
dac:4 1428 dac 4 1428
dac:1 1000 dac 1 1000
dac:7 900 dac 7 900
dac:3 680 dac 3 680
dac:2 1400 dac 2 1400
dac:5 1200 dac 5 1200
adcinvert 4a342593 adcinvert 4a342593
samples 5000 #0xb5cbda6c
adcphase 90 asamples 5000
adcpipeline 15 dsamples 0
adcphase 30 deg
adcpipeline 14
adcreg 14 40 adcreg 14 40
powerchip 1
frames 1000
period 0.001
#############################################
### edit with directory you want to write to
############################################
fpath /tmp/
fwrite 0
romode analog
#rx_jsonaddheader frameMode
rx_jsonpara frameMode newpedestal
#rx_jsonaddheader detectorMode
rx_jsonpara detectorMode analog
#flags newpedestal
#flags analog
reg 0x5e 0x00010000
#powerchip 1
vhighvoltage 90 vhighvoltage 90
period 0.005
frames 100
period 0.1
outdir /scratch/
enablefwrite 0

View File

@ -0,0 +1,61 @@
#initialchecks 0
#############################################
### edit with hostname or IP address of your detector
############################################
hostname bchip181+
#############################################
### edit with 10 Gbs IP of your server
############################################
udp_dstip 10.1.1.102
#############################################
### edit with any number in the subnet of your server (first 3 numbers as above)
############################################
udp_srcip 10.1.1.19
udp_dstport 33410
#############################################
### edit with 10 Gbs IP of your server
############################################
#rx_zmqip 10.1.1.102
#rx_zmqport 30001
#############################################
### edit with 1 Gbs IP of PC where you will run the GUI
############################################
#zmqip 129.129.202.136
#zmqport 40001
#############################################
### edit with hostname or 1Gbs IP address of your server
############################################
rx_hostname mpc2011
tengiga 1
rx_datastream 1
frames 1
period 0.001
#############################################
### edit with directory you want to write to
############################################
fpath /mnt/moench_data/scratch/
fwrite 0
rx_datastream 1
rx_jsonpara frameMode newpedestal
rx_jsonpara detectorMode analog
rx_discardpolicy discardpartial
adcpipeline 15
powerchip 1
vhighvoltage 90
adcreg 14 40

View File

@ -176,6 +176,7 @@ One can configure all the detector settings in a parameter file {\tt{setup.det}}
\begin{verbatim} \begin{verbatim}
sls_detector_put 0-parameters setup.det sls_detector_put 0-parameters setup.det
\end{verbatim} \end{verbatim}
Note that the parameter file for any realease before 4.1.1 has not the possibility to understand parameters to be set differently for different half modules, i.e. {\tt{0:txndelay\_left xxxxx},\tt{1:txndelay\_left yyyyy}}.
In the case of \E, the proper bias voltage of the sensor has to be setup, i.e. the {\tt{setup.det}} file needs to contain the line {\tt{vhighvoltage 150}}. Other detector functionality, which are rarely changed can be setup here. In the case of \E, the proper bias voltage of the sensor has to be setup, i.e. the {\tt{setup.det}} file needs to contain the line {\tt{vhighvoltage 150}}. Other detector functionality, which are rarely changed can be setup here.
Other important settings that are configured in the {\tt{setup.det}} file are: Other important settings that are configured in the {\tt{setup.det}} file are:
@ -609,18 +610,19 @@ The detector can be setup such to receive external triggers. Connect a LEMO sign
\begin{verbatim} \begin{verbatim}
sls_detector_put 0-timing [auto/trigger/burst_trigger/gating] sls_detector_put 0-timing [auto/trigger/burst_trigger/gating]
sls_detector_put 0-frames x sls_detector_put 0-frames x
sls_detector_put 0-triggers y sls_detector_put 0-cycles y
sls_detector_acquire 0- sls_detector_acquire 0-
\end{verbatim} \end{verbatim}
No timeout is expected between the start of the acquisition and the arrival of the first trigger. No timeout is expected between the start of the acquisition and the arrival of the first trigger.
Here are the implemented options so far: Here are the implemented options so far:
\begin{itemize} \begin{itemize}
\item {\tt{auto}} is the software controlled acquisition (does not use triggers), where {\tt{exptime}} and {\tt{period}} have to be set. Set number of triggers (i.e. triggers) to 1 using {\tt{triggers}}. Set number of frames using {\tt{frames}}. \item {\tt{auto}} is the software controlled acquisition (does not use triggers), where {\tt{exptime}} and {\tt{period}} have to be set. Set number of cycles (i.e. triggers) to 1 using {\tt{cycles}}. Set number of frames using {\tt{frames}}.
\item {\tt{trigger}} 1 frame taken for 1 trigger. Your {\tt{frames}} needs to be 1 always, {\tt{triggers}} can be changed and defines how many triggers are considered. {\tt{exptime}} needs to be set. In the GUI this is called trigger exposure series. \item {\tt{trigger}} 1 frame taken for 1 trigger. Your {\tt{frames}} needs to be 1 always, {\tt{cycles}} can be changed and defines how many triggers are considered. {\tt{exptime}} needs to be set. In the GUI this is called trigger exposure series.
\item {\tt{burst\_trigger}} gets only 1 trigger, but allows to take many frames. With {\tt{frames}} one can change the number of frames. {\tt{triggers}} needs to be 1. {\tt{exptime}} and {\tt{period}} have to be set. In the gui it is called trigger readout. \item {\tt{burst\_trigger}} gets only 1 trigger, but allows to take many frames. With {\tt{frames}} one can change the number of frames. {\tt{cycles}} needs to be 1. {\tt{exptime}} and {\tt{period}} have to be set. In the gui it is called trigger readout.
\item{\tt{gating}} allows to get a frame only when the trigger pulse is gating. Note that in this case the exp time and period only depend on the gating signal. {\tt{triggers}} allows to select how many gates to consider. Set number of frames to 1 using {\tt{frames}}. IMPORTANT: Up to firmware 23, the last subframe is oblige to finish being taken, despite the gate signal going down. This will be configurable from later fw and software version. Also, in gating mode, due to timimg of the state machine, you need to leave 500~$\mu$s deadtime between the end on an acquisition and the next. This is as the state machine is unable to check for changes in the status in the first 500~$\mu$s. ATTENTION: if you are in 16 bit mode and you are applying online rate corrections, as now the exptime is generated by the trigger, you might not have correct rate corrections. If you know what the exposure time is in the gating signal, then you can set the {\tt{exptime}} once and the rate corrections will be correct. In 32 bit mode, it does not matter as the rate corrections depends on the {\tt{subexptime}} which is software set independently from the gate exptime. \item{\tt{gating}} allows to get a frame only when the trigger pulse is gating. Note that in this case the exp time and period only depend on the gating signal. {\tt{cycles}} allows to select how many gates to consider. Set number of frames to 1 using {\tt{frames}}. IMPORTANT: Up to firmware 23, the last subframe is oblige to finish being taken, despite the gate signal going down. This will be configurable from later fw and software version. Also, in gating mode, due to timimg of the state machine, you need to leave 500~$\mu$s deadtime between the end on an acquisition and the next. This is as the state machine is unable to check for changes in the status in the first 500~$\mu$s. ATTENTION: if you are in 16 bit mode and you are applying online rate corrections, as now the exptime is generated by the trigger, you might not have correct rate corrections. If you know what the exposure time is in the gating signal, then you can set the {\tt{exptime}} once and the rate corrections will be correct. In 32 bit mode, it does not matter as the rate corrections depends on the {\tt{subexptime}} which is software set independently from the gate exptime.
ATTENTION: From release 4.1.1 with the {\tt{trigger}} option it is possible to have software triggers as a debugging tool (instead of the hardware trigger signal. One should start the acquisition (with the blocking {\tt{sls\_detector\_acquire}} if wanted and with another client one can send the softare trigger {\tt{sls\_detector\_put status trigger}}. This option allows for example to perform a motor scan (moving a motor in between single images) and still writing all images to the same file.
When using 32-bit mode, by default the acquisition ends the last complete subframe that was started when still the acquisition time was valid. This has been chosen as many people wants to know the exact acquisition time for when the detector was taking data and also, if {\tt{ratecorr}} are active, the last subframe will be correctly corrected, while otherwise it will be corrected with a wrong subdeadtime. When using 32-bit mode, by default the acquisition ends the last complete subframe that was started when still the acquisition time was valid. This has been chosen as many people wants to know the exact acquisition time for when the detector was taking data and also, if {\tt{ratecorr}} are active, the last subframe will be correctly corrected, while otherwise it will be corrected with a wrong subdeadtime.
However, from 4.1.0, in gating mode, an option to immediately terminate the subframe when the gate signal goes down it is implemented to stop the acquisition at the same time. This option is {\tt{./sls\_detector\_put interruptsubframe 1}} while the default option is {\tt{./sls\_detector\_put interruptsubframe 0}}. However, from 4.1.0, in gating mode, an option to immediately terminate the subframe when the gate signal goes down it is implemented to stop the acquisition at the same time. This option is {\tt{./sls\_detector\_put interruptsubframe 1}} while the default option is {\tt{./sls\_detector\_put interruptsubframe 0}}.
@ -628,13 +630,13 @@ However, from 4.1.0, in gating mode, an option to immediately terminate the subf
Hardware-wise, the ENABLE OUT signal outputs when the chips are really acquiring. This means that the single subframes will be output in 32 bit mode. The TRIGGER OUT outputs the sum-up-signal at the moment (which is useless). This will be changed in the future to output the envelop of the enable signal. Hardware-wise, the ENABLE OUT signal outputs when the chips are really acquiring. This means that the single subframes will be output in 32 bit mode. The TRIGGER OUT outputs the sum-up-signal at the moment (which is useless). This will be changed in the future to output the envelop of the enable signal.
We are planning to change some functionality, i.e. unify the {\tt{trigger}} and {\tt{burst\_trigger}} trigger modes and make both {\tt{frames}} and {\tt{triggers}} configurable at the same time. We are planning to change some functionality, i.e. unify the {\tt{trigger}} and {\tt{burst\_trigger}} trigger modes and make both {\tt{frames}} and {\tt{cycles}} configurable at the same time.
There is the possibility to use {\tt{timing trigger/burst\_trigger}} and send software single commands to fake the trigger. This is done with: There is the possibility to use {\tt{timing trigger/burst\_trigger}} and send software single commands to fake the trigger. This is done with:
\begin{verbatim} \begin{verbatim}
sls_detector_put 0-timing [trigger/burst_trigger] sls_detector_put 0-timing [trigger/burst_trigger]
sls_detector_put 0-frames x sls_detector_put 0-frames x
sls_detector_put 0-triggers y sls_detector_put 0-cycles y
sls_detector_status trigger sls_detector_status trigger
\end{verbatim} \end{verbatim}
Note that this functionality is very (!) useful if you need to do something between and acquisition and the next. This can be used to do a fast threshold scan for example. See section~\ref{sec:fastthresholdscan}. Note that this functionality is very (!) useful if you need to do something between and acquisition and the next. This can be used to do a fast threshold scan for example. See section~\ref{sec:fastthresholdscan}.
@ -715,7 +717,7 @@ If \textbf{dr} is 32 and \textbf{clkdivider} is not 2, whatever the detector get
Here is a list of parameters that should be reset: Here is a list of parameters that should be reset:
\begin{enumerate} \begin{enumerate}
\item \textbf{resetframescaught} should be reset to zero after every acquisition taken with {\tt{receiver start}},{\tt{status start}},{\tt{receiver stop}}. If the acquisition is taken with {\tt{sls\_detector\_acquire}}, there is no need to reset this. \item \textbf{resetframescaught} should be reset to zero after every acquisition taken with {\tt{receiver start}},{\tt{status start}},{\tt{receiver stop}}. If the acquisition is taken with {\tt{sls\_detector\_acquire}}, there is no need to reset this.
\item After changing the {\tt{timing}} mode of the detector, one should reset to '1' the unused value, in that specific timing mode, between \textbf{frames} and \textbf{triggers}. See section~\ref{triggering} for how to use the timing. At the present moment the detector will acquire more frames than planned if the variable not used between \textbf{frames} and \textbf{triggers} is not reset. In future releases, the unused variable will be ignored. Still resetting is a good practice. \item After changing the {\tt{timing}} mode of the detector, one should reset to '1' the unused value, in that specific timing mode, between \textbf{frames} and \textbf{cycles}. See section~\ref{triggering} for how to use the timing. At the present moment the detector will acquire more frames than planned if the variable not used between \textbf{frames} and \textbf{cycles} is not reset. In future releases, the unused variable will be ignored. Still resetting is a good practice.
\end{enumerate} \end{enumerate}
@ -988,13 +990,14 @@ Packets Caught Mask : 64 bytes
Note that if one wants to reconstruct the real time the detector was acquiring in 32 bit (autosumming mode), one would have to multiply the SubExptime (ns) for the SubFrame Number. Note that if one wants to reconstruct the real time the detector was acquiring in 32 bit (autosumming mode), one would have to multiply the SubExptime (ns) for the SubFrame Number.
\subsection{Offline image reconstruction} \subsection{Offline image reconstruction}
The offline image reconstruction{\tt{slsImageReconstruction}} is not part of the package anymore. The code is still available doing \\ The offline image reconstruction{\tt{slsImageReconstruction}} is not part of the package anymore. However, it can be retrieved from \\
{\tt{git clone git@git.psi.ch:sls\_detectors\_software/sls\_image\_reconstruction.git slsImageReconstruction}}. {\tt{git clone https://github.com/slsdetectorgroup/slsImageReconstruction.git slsImageReconstruction}}.\\
Checkout the {\tt{developer}} branch if in a 3.1.X release, the {\tt{v4.0.0}} branch if in 4.0.X release, or the {\tt{v4.1}} branch if in 4.1.X release of the {\tt{slsDetector}} code. Checkout the {\tt{v3.1}} branch if in a 3.1.X release, the {\tt{v4.0.0}} branch if in 4.0.X release, or the {\tt{v4.1}} branch if in 4.1.X release of the {\tt{slsDetector}} code. There is a {\tt{developer}} branch that has newer updates but needs to be tested.
Three possible conversions are possible: into \textbf{cbf}, \textbf{hdf5} and \textbf{root} format. The detector writes 4 raw files per receiver. An offline image reconstruction executable has been written to collate the possible files together and produce output files. By default an interpolation between the values of the large pixels is performed. Gap pixels between modules are also inserted. Three possible conversions are possible: into \textbf{cbf}, \textbf{hdf5}. \textbf{tiff} and \textbf{root} format. The detector writes 2 raw files per receiver. An offline image reconstruction executable has been written to collate the possible files together and produce output files. By default an interpolation between the values of the large pixels is performed. Gap pixels between modules are also inserted.
Note that the number of images per file in the 3.1.X release is hardcoded and needs to match whatever you are using in {\tt{slsDetectorsPackage/slsReceiverSoftware/include/sls\_receiver\_defs.h}}: Note that the number of images per file in the 3.1.X release is hardcoded and needs to match whatever you are using in \\
{\tt{slsDetectorsPackage/slsReceiverSoftware/include/sls\_receiver\_defs.h}}:
\begin{verbatim} \begin{verbatim}
#define EIGER_MAX_FRAMES_PER_FILE 2000 #define EIGER_MAX_FRAMES_PER_FILE 2000
\end{verbatim} \end{verbatim}
@ -1043,11 +1046,12 @@ cbfMaker9M [file_name_with_dir]
contain the hardcoded geometry for the 1.5M (3 modules horizontal on the long side), the 1.5M OMNY geometry (3 modules next to each other on the long side) and for the 9M at cSAXS: 6(short side)$\times$3 (long side) modules.\\ contain the hardcoded geometry for the 1.5M (3 modules horizontal on the long side), the 1.5M OMNY geometry (3 modules next to each other on the long side) and for the 9M at cSAXS: 6(short side)$\times$3 (long side) modules.\\
Missing packets in a frame and border pixels ($\times 2$ and $\times 4$ are given with value $-1$ at the present time. Missing packets in a frame and border pixels ($\times 2$ and $\times 4$ are given with value $-1$ at the present time.
From the new {{v4.1.1}} all the define that you see below need only to be modified in the Makefile.
Make sure the following options are uncommented in the {\tt{slsImageReconstruction/src/main\_csaxs.cpp}} file. Make sure the following options are uncommented in the {\tt{slsImageReconstruction/src/main\_csaxs.cpp}} file.
\begin{verbatim} \begin{verbatim}
#define MYCBF #define MYCBF
##following line only if you need to process with ##following line only if you need to process with BUBBLE
##BUBBLE (Material Science / uXAS beamlines).
#define MSHeader #define MSHeader
\end{verbatim} \end{verbatim}
Compile it with: Compile it with:
@ -1096,6 +1100,10 @@ To use it any geometry:\\
eg. eg.
{\tt image /scratch/run\_63\_d0\_f000000000000\_3.raw 3072 512 1 2 ``Eiger'' 0}.\\ {\tt image /scratch/run\_63\_d0\_f000000000000\_3.raw 3072 512 1 2 ``Eiger'' 0}.\\
With new new software, the new options to run the cbfMaker/hdf5Maker executablesare:
./hdf5Maker -f [filename] -d [outdirname] -x [npix\_x] -y [npix\_y] -v (v flags that longedge is vertical, no argument) -n [name\_of\_hdf5\_dataset] -m (mask\_hot\_pixels, need to be in file maskpix.txt in the samedir as executable, no argument) -g [0,no filling/1,division/2,interpolation/3,interpolate,alternative]
\subsection{Read temperatures/HV from boards} \subsection{Read temperatures/HV from boards}
With an updated kernel on the linux boards (ask to the SLS detector group for specifications), it is possible to monitor the temperature on the boards: With an updated kernel on the linux boards (ask to the SLS detector group for specifications), it is possible to monitor the temperature on the boards:
@ -1257,7 +1265,7 @@ We have also been requested if we could speed up the threshold scan. At the mome
./sls_detector_put enablefwrite 0 ./sls_detector_put enablefwrite 0
./sls_detector_put resetframescaught 0 ./sls_detector_put resetframescaught 0
./sls_detector_put index 0 ./sls_detector_put index 0
./sls_detector_put triggers 21 ./sls_detector_put cycles 21
./sls_detector_put receiver start ./sls_detector_put receiver start
./sls_detector_put status start ./sls_detector_put status start
for i in $(seq 0 20); for i in $(seq 0 20);
@ -1515,8 +1523,8 @@ frames number
where {\tt{number}} is a string to be interpreted as an integer. where {\tt{number}} is a string to be interpreted as an integer.
\item \begin{verbatim} \item \begin{verbatim}
sls_detector_get triggers sls_detector_get cycles
triggers number cycles number
\end{verbatim} \end{verbatim}
where {\tt{number}} is a string to be interpreted as an integer. where {\tt{number}} is a string to be interpreted as an integer.

View File

@ -1,20 +1,22 @@
pybind11_add_module(_sls_detector # find_package (Python COMPONENTS Interpreter Development)
pybind11_add_module(_slsdet
src/main.cpp src/main.cpp
src/enums.cpp src/enums.cpp
src/detector.cpp src/detector.cpp
src/network.cpp src/network.cpp
) )
target_link_libraries(_sls_detector PUBLIC target_link_libraries(_slsdet PUBLIC
slsDetectorShared slsDetectorShared
slsReceiverShared slsReceiverShared
slsSupportLib slsSupportLib
zmq ) )
set_target_properties(_sls_detector PROPERTIES set_target_properties(_slsdet PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
) )
@ -38,8 +40,8 @@ set( PYTHON_FILES
) )
foreach(FILE ${PYTHON_FILES}) foreach(FILE ${PYTHON_FILES})
configure_file( sls_detector/${FILE} configure_file( slsdet/${FILE}
${CMAKE_BINARY_DIR}/bin/sls_detector/${FILE} ) ${CMAKE_BINARY_DIR}/bin/slsdet/${FILE} )
endforeach(FILE ${PYTHON_FILES}) endforeach(FILE ${PYTHON_FILES})

View File

@ -3,9 +3,9 @@ import sys
import numpy as np import numpy as np
sys.path.append(os.path.join(os.getcwd(), 'bin')) sys.path.append(os.path.join(os.getcwd(), 'bin'))
from sls_detector import Detector, Mythen3, Eiger, Jungfrau, DetectorDacs, Dac, Ctb from slsdet import Detector, Mythen3, Eiger, Jungfrau, DetectorDacs, Dac, Ctb
from sls_detector import dacIndex, readoutMode from slsdet import dacIndex, readoutMode
from sls_detector.lookup import view, find from slsdet.lookup import view, find
d = Detector() d = Detector()
# e = Eiger() # e = Eiger()

View File

@ -4,10 +4,11 @@ out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.ge
cmd = out.stdout.splitlines() cmd = out.stdout.splitlines()
cmd.pop(0) cmd.pop(0)
from sls_detector import Detector, Eiger, Ctb from slsdet import Detector, Eiger, Ctb
pycmd = dir(Detector)+dir(Eiger)+dir(Ctb) pycmd = dir(Detector)+dir(Eiger)+dir(Ctb)
#Add commands that we should not expect as direct commands in python
pycmd += ['vrf', 'vtr', 'vrs', 'vtgstv', 'vsvn', 'vtrim', pycmd += ['vrf', 'vtr', 'vrs', 'vtgstv', 'vsvn', 'vtrim',
'vsvp', 'vth1', 'vth2', 'vth3', 'vshaper', 'vshaperneg', 'rxb_rb', 'vsvp', 'vth1', 'vth2', 'vth3', 'vshaper', 'vshaperneg', 'rxb_rb',
'rxb_lb', 'vref_prech', 'vref_rstore', 'vref_cds', 'rxb_lb', 'vref_prech', 'vref_rstore', 'vref_cds',

View File

@ -1,11 +1,19 @@
"""
Utility to find and list which command line functions have tests and
where the tests are located
"""
#local import for for parsing c++
import parse import parse
from pathlib import Path
#General python stuff
import os import os
import locale import locale
import argparse import argparse
path = Path('../../slsDetectorSoftware/tests/')
import subprocess import subprocess
from pathlib import Path
#Realative path from this dir
path = Path('../../slsDetectorSoftware/tests/')
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("-s", "--startswith", help="for filter", type = str, default=None) parser.add_argument("-s", "--startswith", help="for filter", type = str, default=None)
args = parser.parse_args() args = parser.parse_args()
@ -15,15 +23,12 @@ tested = []
for fname in files: for fname in files:
with open(path/fname) as f: with open(path/fname) as f:
data = f.read() data = f.read()
data = parse.remove_comments(data) data = parse.remove_comments(data)
data = data.splitlines() data = data.splitlines()
for line in data: for line in data:
if 'TEST_CASE' in line or 'SECTION' in line: if 'TEST_CASE' in line or 'SECTION' in line:
cmd = line.split("\"")[1] cmd = line.split("\"")[1]
tested.append(cmd) tested.append([cmd, fname])
out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.getpreferredencoding()) out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.getpreferredencoding())
all_cmd = out.stdout.splitlines() all_cmd = out.stdout.splitlines()
@ -33,18 +38,18 @@ all_cmd.pop(0)
if args.startswith is not None: if args.startswith is not None:
all_cmd = [cmd for cmd in all_cmd if cmd.startswith(args.startswith)] all_cmd = [cmd for cmd in all_cmd if cmd.startswith(args.startswith)]
tested = [cmd for cmd in tested if cmd.startswith(args.startswith)] tested = [cmd for cmd in tested if cmd[0].startswith(args.startswith)]
tn = [cmd[0] for cmd in tested]
not_tested = [cmd for cmd in all_cmd if cmd not in tn]
not_tested = [cmd for cmd in all_cmd if cmd not in tested] misnamed = [cmd for cmd in tn if cmd not in all_cmd]
misnamed = [cmd for cmd in tested if cmd not in all_cmd] tested = [cmd for cmd in tested if cmd[0] in all_cmd]
tested = [cmd for cmd in tested if cmd in all_cmd]
print("\nThe following commands are tested:") print("\nThe following commands are tested:")
for cmd in tested: for cmd in tested:
print(cmd) print(f'{cmd[0]:>18} : {cmd[1]}')
print("\nThe following commands are NOT tested:") print("\nThe following commands are NOT tested:")
for cmd in not_tested: for cmd in not_tested:

View File

@ -8,7 +8,7 @@ import sys
import setuptools import setuptools
import os import os
__version__ = 'refactor' __version__ = os.environ.get('GIT_DESCRIBE_TAG', 'developer')
def get_conda_path(): def get_conda_path():
@ -19,31 +19,32 @@ def get_conda_path():
return os.environ['CONDA_PREFIX'] return os.environ['CONDA_PREFIX']
class get_pybind_include(object): # class get_pybind_include(object):
"""Helper class to determine the pybind11 include path # """Helper class to determine the pybind11 include path
The purpose of this class is to postpone importing pybind11 # The purpose of this class is to postpone importing pybind11
until it is actually installed, so that the ``get_include()`` # until it is actually installed, so that the ``get_include()``
method can be invoked. """ # method can be invoked. """
def __init__(self, user=False): # def __init__(self, user=False):
self.user = user # self.user = user
def __str__(self): # def __str__(self):
import pybind11 # import pybind11
return pybind11.get_include(self.user) # return pybind11.get_include(self.user)
ext_modules = [ ext_modules = [
Extension( Extension(
'_sls_detector', '_slsdet',
['src/main.cpp', ['src/main.cpp',
'src/enums.cpp', 'src/enums.cpp',
'src/detector.cpp', 'src/detector.cpp',
'src/network.cpp'], 'src/network.cpp'],
include_dirs=[ include_dirs=[
# Path to pybind11 headers # Path to pybind11 headers
get_pybind_include(), # get_pybind_include(),
get_pybind_include(user=True), # get_pybind_include(user=True),
os.path.join('../libs/pybind11/include'),
os.path.join(get_conda_path(), 'include/slsDetectorPackage'), os.path.join(get_conda_path(), 'include/slsDetectorPackage'),
], ],
@ -109,20 +110,28 @@ class BuildExt(build_ext):
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version()) opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
for ext in self.extensions: for ext in self.extensions:
ext.extra_compile_args = opts ext.extra_compile_args = opts
print('**************************************************')
print(ct)
print(opts)
print('**************************************************')
build_ext.build_extensions(self) build_ext.build_extensions(self)
def get_shared_lib():
return [f for f in os.listdir('.') if '_slsdet' in f]
setup( setup(
name='sls_detector', name='slsdet',
version=__version__, version=__version__,
author='Erik Frojdh', author='Erik Frojdh',
author_email='erik.frojdh@psi.ch', author_email='erik.frojdh@psi.ch',
url='https://github.com/slsdetectorgroup/sls_detector', url='https://github.com/slsdetectorgroup/slsDetectorPackage',
description='Detector API for SLS Detector Group detectors', description='Detector API for SLS Detector Group detectors',
long_description='', long_description='',
packages=find_packages(exclude=['contrib', 'docs', 'tests']), packages=find_packages(exclude=['contrib', 'docs', 'tests']),
ext_modules=ext_modules, ext_modules=ext_modules,
install_requires=['pybind11>=2.2'],
cmdclass={'build_ext': BuildExt}, cmdclass={'build_ext': BuildExt},
zip_safe=False, zip_safe=False,
) )

View File

@ -1,23 +0,0 @@
# from .detector import Detector, DetectorError, free_shared_memory
from .eiger import Eiger
from .ctb import Ctb
from .dacs import DetectorDacs, Dac
from .detector import Detector
from .jungfrau import Jungfrau
from .mythen3 import Mythen3
# from .jungfrau_ctb import JungfrauCTB
# from _sls_detector import DetectorApi
import _sls_detector
defs = _sls_detector.slsDetectorDefs
runStatus = _sls_detector.slsDetectorDefs.runStatus
speedLevel = _sls_detector.slsDetectorDefs.speedLevel
timingMode = _sls_detector.slsDetectorDefs.timingMode
dacIndex = _sls_detector.slsDetectorDefs.dacIndex
detectorType = _sls_detector.slsDetectorDefs.detectorType
detectorSettings = _sls_detector.slsDetectorDefs.detectorSettings
readoutMode = _sls_detector.slsDetectorDefs.readoutMode
IpAddr = _sls_detector.IpAddr
MacAddr = _sls_detector.MacAddr

View File

@ -1,9 +0,0 @@
from .detector import Detector
def view(name):
names = find(name)
for n in names:
print(n)
def find(name):
return [n for n in dir(Detector) if name in n]

23
python/slsdet/__init__.py Executable file
View File

@ -0,0 +1,23 @@
# from .detector import Detector, DetectorError, free_shared_memory
from .eiger import Eiger
from .ctb import Ctb
from .dacs import DetectorDacs, Dac
from .detector import Detector
from .jungfrau import Jungfrau
from .mythen3 import Mythen3
# from .jungfrau_ctb import JungfrauCTB
# from _slsdet import DetectorApi
import _slsdet
defs = _slsdet.slsDetectorDefs
runStatus = _slsdet.slsDetectorDefs.runStatus
speedLevel = _slsdet.slsDetectorDefs.speedLevel
timingMode = _slsdet.slsDetectorDefs.timingMode
dacIndex = _slsdet.slsDetectorDefs.dacIndex
detectorType = _slsdet.slsDetectorDefs.detectorType
detectorSettings = _slsdet.slsDetectorDefs.detectorSettings
readoutMode = _slsdet.slsDetectorDefs.readoutMode
IpAddr = _slsdet.IpAddr
MacAddr = _slsdet.MacAddr

View File

@ -1,8 +1,8 @@
from .detector import Detector from .detector import Detector
from .utils import element_if_equal from .utils import element_if_equal
from .dacs import DetectorDacs from .dacs import DetectorDacs
import _sls_detector import _slsdet
dacIndex = _sls_detector.slsDetectorDefs.dacIndex dacIndex = _slsdet.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty from .detector_property import DetectorProperty
class CtbDacs(DetectorDacs): class CtbDacs(DetectorDacs):

View File

@ -1,9 +1,9 @@
from .detector_property import DetectorProperty from .detector_property import DetectorProperty
from functools import partial from functools import partial
import numpy as np import numpy as np
import _sls_detector import _slsdet
from .detector import freeze from .detector import freeze
dacIndex = _sls_detector.slsDetectorDefs.dacIndex dacIndex = _slsdet.slsDetectorDefs.dacIndex
class Dac(DetectorProperty): class Dac(DetectorProperty):
""" """
This class represents a dac on the detector. One instance handles all This class represents a dac on the detector. One instance handles all

View File

@ -1,5 +1,5 @@
from _sls_detector import CppDetectorApi from _slsdet import CppDetectorApi
from _sls_detector import slsDetectorDefs from _slsdet import slsDetectorDefs
runStatus = slsDetectorDefs.runStatus runStatus = slsDetectorDefs.runStatus
speedLevel = slsDetectorDefs.speedLevel speedLevel = slsDetectorDefs.speedLevel

View File

@ -11,8 +11,8 @@ from .detector import Detector
# from .adcs import Adc, DetectorAdcs # from .adcs import Adc, DetectorAdcs
from .dacs import DetectorDacs from .dacs import DetectorDacs
import _sls_detector import _slsdet
dacIndex = _sls_detector.slsDetectorDefs.dacIndex dacIndex = _slsdet.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty from .detector_property import DetectorProperty
# from .utils import element_if_equal # from .utils import element_if_equal
# from sls_detector.errors import DetectorValueError, DetectorError # from sls_detector.errors import DetectorValueError, DetectorError

View File

@ -9,8 +9,8 @@ from .detector import Detector, freeze
# from .adcs import Adc, DetectorAdcs # from .adcs import Adc, DetectorAdcs
from .dacs import DetectorDacs from .dacs import DetectorDacs
import _sls_detector import _slsdet
dacIndex = _sls_detector.slsDetectorDefs.dacIndex dacIndex = _slsdet.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty from .detector_property import DetectorProperty
# @freeze # @freeze

9
python/slsdet/lookup.py Normal file
View File

@ -0,0 +1,9 @@
from .detector import Detector
def view(name, det = Detector):
names = find(name, det)
for n in names:
print(n)
def find(name, det = Detector):
return [n for n in dir(det) if name.lower() in n.lower()]

View File

@ -9,8 +9,8 @@ from .detector import Detector, freeze
# from .adcs import Adc, DetectorAdcs # from .adcs import Adc, DetectorAdcs
from .dacs import DetectorDacs from .dacs import DetectorDacs
import _sls_detector import _slsdet
dacIndex = _sls_detector.slsDetectorDefs.dacIndex dacIndex = _slsdet.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty from .detector_property import DetectorProperty
# vcassh 1200, # vcassh 1200,

View File

@ -5,7 +5,7 @@ but not directly used in controlling the detector
from collections import namedtuple from collections import namedtuple
import _sls_detector #C++ lib import _slsdet #C++ lib
import functools import functools
@ -29,7 +29,7 @@ def list_to_bitmask(values):
return mask return mask
def to_geo(value): def to_geo(value):
if isinstance(value, _sls_detector.xy): if isinstance(value, _slsdet.xy):
return Geometry(x = value.x, y = value.y) return Geometry(x = value.x, y = value.y)
else: else:
raise ValueError("Can only convert sls_detector.xy") raise ValueError("Can only convert sls_detector.xy")

View File

@ -2,7 +2,7 @@ C++ API
===================================================== =====================================================
.. py:currentmodule:: _sls_detector .. py:currentmodule:: _slsdet
.. autoclass:: DetectorApi .. autoclass:: DetectorApi
:members: :members:

View File

@ -428,6 +428,13 @@ void init_det(py::module &m) {
py::arg() = Positions{}) py::arg() = Positions{})
.def("setImageTestMode", &Detector::setImageTestMode, py::arg(), .def("setImageTestMode", &Detector::setImageTestMode, py::arg(),
py::arg() = Positions{}) py::arg() = Positions{})
.def("getNumberOfBursts", &Detector::getNumberOfBursts,
py::arg() = Positions{})
.def("setNumberOfBursts", &Detector::setNumberOfBursts, py::arg())
.def("getBurstPeriod", &Detector::getBurstPeriod,
py::arg() = Positions{})
.def("setBurstPeriod", &Detector::setBurstPeriod, py::arg(),
py::arg() = Positions{})
.def("getInjectChannel", &Detector::getInjectChannel, .def("getInjectChannel", &Detector::getInjectChannel,
py::arg() = Positions{}) py::arg() = Positions{})
.def("setInjectChannel", &Detector::setInjectChannel, py::arg(), .def("setInjectChannel", &Detector::setInjectChannel, py::arg(),
@ -441,6 +448,14 @@ void init_det(py::module &m) {
.def("getBurstMode", &Detector::getBurstMode, py::arg() = Positions{}) .def("getBurstMode", &Detector::getBurstMode, py::arg() = Positions{})
.def("setBurstMode", &Detector::setBurstMode, py::arg(), .def("setBurstMode", &Detector::setBurstMode, py::arg(),
py::arg() = Positions{}) py::arg() = Positions{})
.def("getCurrentSource", &Detector::getCurrentSource,
py::arg() = Positions{})
.def("setCurrentSource", &Detector::setCurrentSource, py::arg(),
py::arg() = Positions{})
.def("getTimingSource", &Detector::getTimingSource,
py::arg() = Positions{})
.def("setTimingSource", &Detector::setTimingSource, py::arg(),
py::arg() = Positions{})
.def("getCounterMask", &Detector::getCounterMask, .def("getCounterMask", &Detector::getCounterMask,
py::arg() = Positions{}) py::arg() = Positions{})
.def("setCounterMask", &Detector::setCounterMask, py::arg(), .def("setCounterMask", &Detector::setCounterMask, py::arg(),
@ -610,6 +625,8 @@ void init_det(py::module &m) {
py::arg() = Positions{}) py::arg() = Positions{})
.def("writeAdcRegister", &Detector::writeAdcRegister, py::arg(), .def("writeAdcRegister", &Detector::writeAdcRegister, py::arg(),
py::arg(), py::arg() = Positions{}) py::arg(), py::arg() = Positions{})
.def("getInitialChecks", &Detector::getInitialChecks)
.def("setInitialChecks", &Detector::setInitialChecks, py::arg())
.def("getControlPort", &Detector::getControlPort, .def("getControlPort", &Detector::getControlPort,
py::arg() = Positions{}) py::arg() = Positions{})
.def("setControlPort", &Detector::setControlPort, py::arg(), .def("setControlPort", &Detector::setControlPort, py::arg(),

View File

@ -284,4 +284,11 @@ void init_enums(py::module &m) {
.value("BURST_INTERNAL", slsDetectorDefs::burstMode::BURST_INTERNAL) .value("BURST_INTERNAL", slsDetectorDefs::burstMode::BURST_INTERNAL)
.value("BURST_EXTERNAL", slsDetectorDefs::burstMode::BURST_EXTERNAL) .value("BURST_EXTERNAL", slsDetectorDefs::burstMode::BURST_EXTERNAL)
.export_values(); .export_values();
py::enum_<slsDetectorDefs::timingSourceType>(Defs, "timingSourceType")
.value("TIMING_INTERNAL",
slsDetectorDefs::timingSourceType::TIMING_INTERNAL)
.value("TIMING_EXTERNAL",
slsDetectorDefs::timingSourceType::TIMING_EXTERNAL)
.export_values();
} }

View File

@ -19,7 +19,7 @@ void init_enums(py::module &);
void init_experimental(py::module &); void init_experimental(py::module &);
void init_det(py::module &); void init_det(py::module &);
void init_network(py::module &); void init_network(py::module &);
PYBIND11_MODULE(_sls_detector, m) { PYBIND11_MODULE(_slsdet, m) {
m.doc() = R"pbdoc( m.doc() = R"pbdoc(
C/C++ API C/C++ API
----------------------- -----------------------

View File

@ -16,12 +16,12 @@ def d():
def test_acq_call(d, mocker): def test_acq_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.acq') m = mocker.patch('_slsdet.DetectorApi.acq')
d.acq() d.acq()
m.assert_called_once_with() m.assert_called_once_with()
def test_busy_call(d, mocker): def test_busy_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getAcquiringFlag') m = mocker.patch('_slsdet.DetectorApi.getAcquiringFlag')
m.return_value = False m.return_value = False
assert d.busy == False assert d.busy == False
@ -31,103 +31,103 @@ def test_assign_to_detector_type(d):
d.detector_type = 'Eiger' d.detector_type = 'Eiger'
def test_det_type(d, mocker): def test_det_type(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDetectorType') m = mocker.patch('_slsdet.DetectorApi.getDetectorType')
m.return_value = 'Eiger' m.return_value = 'Eiger'
assert d.detector_type == 'Eiger' assert d.detector_type == 'Eiger'
def test_set_dynamic_range_4(d, mocker): def test_set_dynamic_range_4(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setDynamicRange') m = mocker.patch('_slsdet.DetectorApi.setDynamicRange')
d.dynamic_range = 4 d.dynamic_range = 4
m.assert_called_with(4) m.assert_called_with(4)
def test_set_dynamic_range_8(d, mocker): def test_set_dynamic_range_8(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setDynamicRange') m = mocker.patch('_slsdet.DetectorApi.setDynamicRange')
d.dynamic_range = 8 d.dynamic_range = 8
m.assert_called_with(8) m.assert_called_with(8)
def test_set_dynamic_range_16(d, mocker): def test_set_dynamic_range_16(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setDynamicRange') m = mocker.patch('_slsdet.DetectorApi.setDynamicRange')
d.dynamic_range = 16 d.dynamic_range = 16
m.assert_called_with(16) m.assert_called_with(16)
def test_set_dynamic_range_32(d, mocker): def test_set_dynamic_range_32(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setDynamicRange') m = mocker.patch('_slsdet.DetectorApi.setDynamicRange')
d.dynamic_range = 32 d.dynamic_range = 32
m.assert_called_with(32) m.assert_called_with(32)
def test_set_dynamic_range_raises_exception(d, mocker): def test_set_dynamic_range_raises_exception(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setDynamicRange') mocker.patch('_slsdet.DetectorApi.setDynamicRange')
with pytest.raises(ValueError): with pytest.raises(ValueError):
d.dynamic_range = 17 d.dynamic_range = 17
def test_get_dynamic_range_32(d, mocker): def test_get_dynamic_range_32(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDynamicRange') m = mocker.patch('_slsdet.DetectorApi.getDynamicRange')
m.return_value = 32 m.return_value = 32
dr = d.dynamic_range dr = d.dynamic_range
assert dr == 32 assert dr == 32
def test_eiger_matrix_reset(d, mocker): def test_eiger_matrix_reset(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getCounterBit') m = mocker.patch('_slsdet.DetectorApi.getCounterBit')
m.return_value = True m.return_value = True
assert d.eiger_matrix_reset == True assert d.eiger_matrix_reset == True
def test_set_eiger_matrix_reset(d, mocker): def test_set_eiger_matrix_reset(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setCounterBit') m = mocker.patch('_slsdet.DetectorApi.setCounterBit')
d.eiger_matrix_reset = True d.eiger_matrix_reset = True
m.assert_called_once_with(True) m.assert_called_once_with(True)
def test_get_exposure_time(d, mocker): def test_get_exposure_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getExposureTime') m = mocker.patch('_slsdet.DetectorApi.getExposureTime')
m.return_value = 100000000 m.return_value = 100000000
assert d.exposure_time == 0.1 assert d.exposure_time == 0.1
def test_set_exposure_time(d, mocker): def test_set_exposure_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setExposureTime') m = mocker.patch('_slsdet.DetectorApi.setExposureTime')
d.exposure_time = 1.5 d.exposure_time = 1.5
m.assert_called_once_with(1500000000) m.assert_called_once_with(1500000000)
def test_set_exposure_time_less_than_zero(d, mocker): def test_set_exposure_time_less_than_zero(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setExposureTime') mocker.patch('_slsdet.DetectorApi.setExposureTime')
with pytest.raises(ValueError): with pytest.raises(ValueError):
d.exposure_time = -7 d.exposure_time = -7
def test_get_file_index(d, mocker): def test_get_file_index(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFileIndex') m = mocker.patch('_slsdet.DetectorApi.getFileIndex')
m.return_value = 8 m.return_value = 8
assert d.file_index == 8 assert d.file_index == 8
def test_set_file_index(d, mocker): def test_set_file_index(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setFileIndex') m = mocker.patch('_slsdet.DetectorApi.setFileIndex')
d.file_index = 9 d.file_index = 9
m.assert_called_with(9) m.assert_called_with(9)
def test_set_file_index_raises_on_neg(d, mocker): def test_set_file_index_raises_on_neg(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setFileIndex') mocker.patch('_slsdet.DetectorApi.setFileIndex')
with pytest.raises(ValueError): with pytest.raises(ValueError):
d.file_index = -9 d.file_index = -9
def test_get_file_name(d, mocker): def test_get_file_name(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFileName') m = mocker.patch('_slsdet.DetectorApi.getFileName')
d.file_name d.file_name
m.assert_called_once_with() m.assert_called_once_with()
def test_set_file_name(d, mocker): def test_set_file_name(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setFileName') m = mocker.patch('_slsdet.DetectorApi.setFileName')
d.file_name = 'hej' d.file_name = 'hej'
m.assert_called_once_with('hej') m.assert_called_once_with('hej')
def test_get_file_path(d, mocker): def test_get_file_path(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFilePath') m = mocker.patch('_slsdet.DetectorApi.getFilePath')
d.file_path d.file_path
m.assert_called_once_with() m.assert_called_once_with()
def test_set_file_path_when_path_exists(d, mocker): def test_set_file_path_when_path_exists(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setFilePath') m = mocker.patch('_slsdet.DetectorApi.setFilePath')
#To avoid raising an exception because path is not there #To avoid raising an exception because path is not there
mock_os = mocker.patch('os.path.exists') mock_os = mocker.patch('os.path.exists')
mock_os.return_value = True mock_os.return_value = True
@ -135,25 +135,25 @@ def test_set_file_path_when_path_exists(d, mocker):
m.assert_called_once_with('/path/to/something/') m.assert_called_once_with('/path/to/something/')
def test_set_file_path_raises_when_not_exists(d, mocker): def test_set_file_path_raises_when_not_exists(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setFilePath') mocker.patch('_slsdet.DetectorApi.setFilePath')
mock_os = mocker.patch('os.path.exists') mock_os = mocker.patch('os.path.exists')
mock_os.return_value = False mock_os.return_value = False
with pytest.raises(FileNotFoundError): with pytest.raises(FileNotFoundError):
d.file_path = '/path/to/something/' d.file_path = '/path/to/something/'
def test_get_file_write(d, mocker): def test_get_file_write(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFileWrite') m = mocker.patch('_slsdet.DetectorApi.getFileWrite')
m.return_value = False m.return_value = False
assert d.file_write == False assert d.file_write == False
def test_set_file_write(d, mocker): def test_set_file_write(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setFileWrite') m = mocker.patch('_slsdet.DetectorApi.setFileWrite')
d.file_write = True d.file_write = True
m.assert_called_once_with(True) m.assert_called_once_with(True)
def test_get_firmware_version(d, mocker): def test_get_firmware_version(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFirmwareVersion') m = mocker.patch('_slsdet.DetectorApi.getFirmwareVersion')
m.return_value = 20 m.return_value = 20
assert d.firmware_version == 20 assert d.firmware_version == 20
@ -162,38 +162,38 @@ def test_cannot_set_fw_version(d):
d.firmware_version = 20 d.firmware_version = 20
def test_get_high_voltage_call_signature(d, mocker): def test_get_high_voltage_call_signature(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDac') m = mocker.patch('_slsdet.DetectorApi.getDac')
d.high_voltage d.high_voltage
m.assert_called_once_with('vhighvoltage', -1) m.assert_called_once_with('vhighvoltage', -1)
def test_get_high_voltage(d, mocker): def test_get_high_voltage(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDac') m = mocker.patch('_slsdet.DetectorApi.getDac')
m.return_value = 80 m.return_value = 80
assert d.high_voltage == 80 assert d.high_voltage == 80
#self._api.setDac('vhighvoltage', -1, voltage) #self._api.setDac('vhighvoltage', -1, voltage)
def test_set_high_voltage(d, mocker): def test_set_high_voltage(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setDac') m = mocker.patch('_slsdet.DetectorApi.setDac')
d.high_voltage = 80 d.high_voltage = 80
m.assert_called_once_with('vhighvoltage', -1, 80) m.assert_called_once_with('vhighvoltage', -1, 80)
def test_decode_hostname_two_names(d, mocker): def test_decode_hostname_two_names(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getHostname') m = mocker.patch('_slsdet.DetectorApi.getHostname')
m.return_value = 'beb059+beb048+' m.return_value = 'beb059+beb048+'
assert d.hostname == ['beb059', 'beb048'] assert d.hostname == ['beb059', 'beb048']
def test_decode_hostname_four_names(d, mocker): def test_decode_hostname_four_names(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getHostname') m = mocker.patch('_slsdet.DetectorApi.getHostname')
m.return_value = 'beb059+beb048+beb120+beb153+' m.return_value = 'beb059+beb048+beb120+beb153+'
assert d.hostname == ['beb059', 'beb048', 'beb120', 'beb153'] assert d.hostname == ['beb059', 'beb048', 'beb120', 'beb153']
def test_decode_hostname_blank(d, mocker): def test_decode_hostname_blank(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getHostname') m = mocker.patch('_slsdet.DetectorApi.getHostname')
m.return_value = '' m.return_value = ''
assert d.hostname == [] assert d.hostname == []
def test_get_image_size_gives_correct_size(d, mocker): def test_get_image_size_gives_correct_size(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getImageSize') m = mocker.patch('_slsdet.DetectorApi.getImageSize')
m.return_value = (512,1024) m.return_value = (512,1024)
im_size = d.image_size im_size = d.image_size
assert im_size.rows == 512 assert im_size.rows == 512
@ -202,7 +202,7 @@ def test_get_image_size_gives_correct_size(d, mocker):
def test_load_config(d, mocker): def test_load_config(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.readConfigurationFile') m = mocker.patch('_slsdet.DetectorApi.readConfigurationFile')
#To avoid raising an exception because path is not there #To avoid raising an exception because path is not there
mock_os = mocker.patch('os.path.isfile') mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = True mock_os.return_value = True
@ -210,14 +210,14 @@ def test_load_config(d, mocker):
m.assert_called_once_with('/path/to/my/file.config') m.assert_called_once_with('/path/to/my/file.config')
def test_load_config_raises_when_file_is_not_found(d, mocker): def test_load_config_raises_when_file_is_not_found(d, mocker):
mocker.patch('_sls_detector.DetectorApi.readConfigurationFile') mocker.patch('_slsdet.DetectorApi.readConfigurationFile')
mock_os = mocker.patch('os.path.isfile') mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = False mock_os.return_value = False
with pytest.raises(FileNotFoundError): with pytest.raises(FileNotFoundError):
d.load_config('/path/to/my/file.config') d.load_config('/path/to/my/file.config')
def test_load_parameters(d, mocker): def test_load_parameters(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.readParametersFile') m = mocker.patch('_slsdet.DetectorApi.readParametersFile')
#To avoid raising an exception because path is not there #To avoid raising an exception because path is not there
mock_os = mocker.patch('os.path.isfile') mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = True mock_os.return_value = True
@ -225,7 +225,7 @@ def test_load_parameters(d, mocker):
m.assert_called_once_with('/path/to/my/file.par') m.assert_called_once_with('/path/to/my/file.par')
def test_load_parameters_raises_when_file_is_not_found(d, mocker): def test_load_parameters_raises_when_file_is_not_found(d, mocker):
mocker.patch('_sls_detector.DetectorApi.readParametersFile') mocker.patch('_slsdet.DetectorApi.readParametersFile')
mock_os = mocker.patch('os.path.isfile') mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = False mock_os.return_value = False
with pytest.raises(FileNotFoundError): with pytest.raises(FileNotFoundError):
@ -233,14 +233,14 @@ def test_load_parameters_raises_when_file_is_not_found(d, mocker):
#getDetectorGeometry #getDetectorGeometry
def test_get_module_geometry_gives_correct_size(d, mocker): def test_get_module_geometry_gives_correct_size(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDetectorGeometry') m = mocker.patch('_slsdet.DetectorApi.getDetectorGeometry')
m.return_value = (13,7) m.return_value = (13,7)
g = d.module_geometry g = d.module_geometry
assert g.vertical == 7 assert g.vertical == 7
assert g.horizontal == 13 assert g.horizontal == 13
def test_get_module_geometry_access(d, mocker): def test_get_module_geometry_access(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDetectorGeometry') m = mocker.patch('_slsdet.DetectorApi.getDetectorGeometry')
m.return_value = (12,3) m.return_value = (12,3)
assert d.module_geometry[0] == 12 assert d.module_geometry[0] == 12
assert d.module_geometry[1] == 3 assert d.module_geometry[1] == 3
@ -248,237 +248,237 @@ def test_get_module_geometry_access(d, mocker):
assert d.module_geometry.horizontal == 12 assert d.module_geometry.horizontal == 12
def test_get_n_frames(d, mocker): def test_get_n_frames(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNumberOfFrames') m = mocker.patch('_slsdet.DetectorApi.getNumberOfFrames')
m.return_value = 3 m.return_value = 3
assert d.n_frames == 3 assert d.n_frames == 3
def test_set_n_frames(d, mocker): def test_set_n_frames(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames') m = mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
d.n_frames = 9 d.n_frames = 9
m.assert_called_once_with(9) m.assert_called_once_with(9)
def test_set_n_frames_raises_on_neg(d, mocker): def test_set_n_frames_raises_on_neg(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames') mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
with pytest.raises(ValueError): with pytest.raises(ValueError):
d.n_frames = -1 d.n_frames = -1
def test_set_n_frames_raises_on_zero(d, mocker): def test_set_n_frames_raises_on_zero(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames') mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
with pytest.raises(ValueError): with pytest.raises(ValueError):
d.n_frames = 0 d.n_frames = 0
def test_get_n_modules(d, mocker): def test_get_n_modules(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors') m = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
m.return_value = 12 m.return_value = 12
assert d.n_modules == 12 assert d.n_modules == 12
def test_get_period_time(d, mocker): def test_get_period_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getPeriod') m = mocker.patch('_slsdet.DetectorApi.getPeriod')
m.return_value = 130000000 m.return_value = 130000000
assert d.period == 0.13 assert d.period == 0.13
def test_set_period_time(d, mocker): def test_set_period_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setPeriod') m = mocker.patch('_slsdet.DetectorApi.setPeriod')
d.period = 1.953 d.period = 1.953
m.assert_called_once_with(1953000000) m.assert_called_once_with(1953000000)
def test_set_period_time_less_than_zero(d, mocker): def test_set_period_time_less_than_zero(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setPeriod') mocker.patch('_slsdet.DetectorApi.setPeriod')
with pytest.raises(ValueError): with pytest.raises(ValueError):
d.period = -7 d.period = -7
def test_pulse_chip_call(d, mocker): def test_pulse_chip_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.pulseChip') m = mocker.patch('_slsdet.DetectorApi.pulseChip')
d.pulse_chip(15) d.pulse_chip(15)
m.assert_called_once_with(15) m.assert_called_once_with(15)
def test_pulse_chip_call_minus_one(d, mocker): def test_pulse_chip_call_minus_one(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.pulseChip') m = mocker.patch('_slsdet.DetectorApi.pulseChip')
d.pulse_chip(-1) d.pulse_chip(-1)
m.assert_called_once_with(-1) m.assert_called_once_with(-1)
def test_pulse_chip_asserts_on_smaller_than_minus_one(d, mocker): def test_pulse_chip_asserts_on_smaller_than_minus_one(d, mocker):
mocker.patch('_sls_detector.DetectorApi.pulseChip') mocker.patch('_slsdet.DetectorApi.pulseChip')
with pytest.raises(ValueError): with pytest.raises(ValueError):
d.pulse_chip(-3) d.pulse_chip(-3)
#--------------------------------------------------------------------subexptime #--------------------------------------------------------------------subexptime
def test_get_sub_exposure_time(d, mocker): def test_get_sub_exposure_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getSubExposureTime') m = mocker.patch('_slsdet.DetectorApi.getSubExposureTime')
m.return_value = 2370000 m.return_value = 2370000
assert d.sub_exposure_time == 0.00237 assert d.sub_exposure_time == 0.00237
def test_set_sub_exposure_time(d, mocker): def test_set_sub_exposure_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setSubExposureTime') m = mocker.patch('_slsdet.DetectorApi.setSubExposureTime')
d.sub_exposure_time = 0.002 d.sub_exposure_time = 0.002
m.assert_called_once_with(2000000) m.assert_called_once_with(2000000)
def test_set_sub_exposure_time_raises_on_zero(d, mocker): def test_set_sub_exposure_time_raises_on_zero(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setSubExposureTime') mocker.patch('_slsdet.DetectorApi.setSubExposureTime')
with pytest.raises(ValueError): with pytest.raises(ValueError):
d.sub_exposure_time = 0 d.sub_exposure_time = 0
#-------------------------------------------------------------Rate correction #-------------------------------------------------------------Rate correction
def test_get_rate_correction(d, mocker): def test_get_rate_correction(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getRateCorrection') m = mocker.patch('_slsdet.DetectorApi.getRateCorrection')
m.return_value = [132,129] m.return_value = [132,129]
assert d.rate_correction == [132,129] assert d.rate_correction == [132,129]
def test_set_rate_correction(d, mocker): def test_set_rate_correction(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setRateCorrection') m = mocker.patch('_slsdet.DetectorApi.setRateCorrection')
mock_n = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors') mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
mock_n.return_value = 3 mock_n.return_value = 3
d.rate_correction = [123,90,50] d.rate_correction = [123,90,50]
m.assert_called_once_with([123,90,50]) m.assert_called_once_with([123,90,50])
def test_set_rate_correction_raises_on_wrong_number_of_values(d, mocker): def test_set_rate_correction_raises_on_wrong_number_of_values(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setRateCorrection') mocker.patch('_slsdet.DetectorApi.setRateCorrection')
mock_n = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors') mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
mock_n.return_value = 4 mock_n.return_value = 4
with pytest.raises(ValueError): with pytest.raises(ValueError):
d.rate_correction = [123,90,50] d.rate_correction = [123,90,50]
#----------------------------------------------------------------Readout clock #----------------------------------------------------------------Readout clock
def test_get_readout_clock_0(d, mocker): def test_get_readout_clock_0(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed') m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
m.return_value = 0 m.return_value = 0
assert d.readout_clock == 'Full Speed' assert d.readout_clock == 'Full Speed'
def test_get_readout_clock_1(d, mocker): def test_get_readout_clock_1(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed') m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
m.return_value = 1 m.return_value = 1
assert d.readout_clock == 'Half Speed' assert d.readout_clock == 'Half Speed'
def test_get_readout_clock_2(d, mocker): def test_get_readout_clock_2(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed') m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
m.return_value = 2 m.return_value = 2
assert d.readout_clock == 'Quarter Speed' assert d.readout_clock == 'Quarter Speed'
def test_get_readout_clock_3(d, mocker): def test_get_readout_clock_3(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed') m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
m.return_value = 3 m.return_value = 3
assert d.readout_clock == 'Super Slow Speed' assert d.readout_clock == 'Super Slow Speed'
def test_set_readout_clock_0(d, mocker): def test_set_readout_clock_0(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed') m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
d.readout_clock = 'Full Speed' d.readout_clock = 'Full Speed'
m.assert_called_once_with(0) m.assert_called_once_with(0)
def test_set_readout_clock_1(d, mocker): def test_set_readout_clock_1(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed') m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
d.readout_clock = 'Half Speed' d.readout_clock = 'Half Speed'
m.assert_called_once_with(1) m.assert_called_once_with(1)
def test_set_readout_clock_2(d, mocker): def test_set_readout_clock_2(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed') m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
d.readout_clock = 'Quarter Speed' d.readout_clock = 'Quarter Speed'
m.assert_called_once_with(2) m.assert_called_once_with(2)
def test_set_readout_clock_3(d, mocker): def test_set_readout_clock_3(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed') m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
d.readout_clock = 'Super Slow Speed' d.readout_clock = 'Super Slow Speed'
m.assert_called_once_with(3) m.assert_called_once_with(3)
#----------------------------------------------------------------rx_datastream #----------------------------------------------------------------rx_datastream
def test_get_rx_datastream(d, mocker): def test_get_rx_datastream(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getRxDataStreamStatus') m = mocker.patch('_slsdet.DetectorApi.getRxDataStreamStatus')
m.return_value = False m.return_value = False
assert d.rx_datastream == False assert d.rx_datastream == False
def test_set_rx_datastream(d, mocker): def test_set_rx_datastream(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setRxDataStreamStatus') m = mocker.patch('_slsdet.DetectorApi.setRxDataStreamStatus')
d.rx_datastream = True d.rx_datastream = True
m.assert_called_once_with(True) m.assert_called_once_with(True)
def test_get_rx_zmqip(d, mocker): def test_get_rx_zmqip(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter') m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
d.rx_zmqip d.rx_zmqip
m.assert_called_once_with('rx_zmqip') m.assert_called_once_with('rx_zmqip')
def test_get_rx_zmqport_call(d, mocker): def test_get_rx_zmqport_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter') m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
d.rx_zmqport d.rx_zmqport
m.assert_called_once_with('rx_zmqport') m.assert_called_once_with('rx_zmqport')
def test_get_rx_zmqport_decode(d, mocker): def test_get_rx_zmqport_decode(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter') m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
m.return_value = '30001+30003+' m.return_value = '30001+30003+'
assert d.rx_zmqport == [30001, 30002, 30003, 30004] assert d.rx_zmqport == [30001, 30002, 30003, 30004]
def test_get_rx_zmqport_empty(d, mocker): def test_get_rx_zmqport_empty(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter') m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
m.return_value = '' m.return_value = ''
assert d.rx_zmqport == [] assert d.rx_zmqport == []
#--------------------------------------------------------------------status #--------------------------------------------------------------------status
def test_status_call(d, mocker): def test_status_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getRunStatus') m = mocker.patch('_slsdet.DetectorApi.getRunStatus')
d.status d.status
m.assert_called_once_with() m.assert_called_once_with()
def test_start_acq_call(d, mocker): def test_start_acq_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.startAcquisition') m = mocker.patch('_slsdet.DetectorApi.startAcquisition')
d.start_acq() d.start_acq()
m.assert_called_once_with() m.assert_called_once_with()
def test_stop_acq_call(d, mocker): def test_stop_acq_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.stopAcquisition') m = mocker.patch('_slsdet.DetectorApi.stopAcquisition')
d.stop_acq() d.stop_acq()
m.assert_called_once_with() m.assert_called_once_with()
#--------------------------------------------------------------------subexptime #--------------------------------------------------------------------subexptime
def test_get_sub_exposure_time(d, mocker): def test_get_sub_exposure_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getSubExposureTime') m = mocker.patch('_slsdet.DetectorApi.getSubExposureTime')
m.return_value = 2370000 m.return_value = 2370000
assert d.sub_exposure_time == 0.00237 assert d.sub_exposure_time == 0.00237
def test_set_sub_exposure_time(d, mocker): def test_set_sub_exposure_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setSubExposureTime') m = mocker.patch('_slsdet.DetectorApi.setSubExposureTime')
d.sub_exposure_time = 0.002 d.sub_exposure_time = 0.002
m.assert_called_once_with(2000000) m.assert_called_once_with(2000000)
def test_set_sub_exposure_time_raises_on_zero(d, mocker): def test_set_sub_exposure_time_raises_on_zero(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setSubExposureTime') mocker.patch('_slsdet.DetectorApi.setSubExposureTime')
with pytest.raises(ValueError): with pytest.raises(ValueError):
d.sub_exposure_time = 0 d.sub_exposure_time = 0
#------------------------------------------------------------------timing mode #------------------------------------------------------------------timing mode
def test_get_timing_mode(d, mocker): def test_get_timing_mode(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getTimingMode') m = mocker.patch('_slsdet.DetectorApi.getTimingMode')
d.timing_mode d.timing_mode
m.assert_called_once_with() m.assert_called_once_with()
def test_set_timing_mode(d, mocker): def test_set_timing_mode(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setTimingMode') m = mocker.patch('_slsdet.DetectorApi.setTimingMode')
d.timing_mode = 'auto' d.timing_mode = 'auto'
m.assert_called_once_with('auto') m.assert_called_once_with('auto')
#----------------------------------------------------------------vthreshold #----------------------------------------------------------------vthreshold
def test_get_vthreshold(d, mocker): def test_get_vthreshold(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDac') m = mocker.patch('_slsdet.DetectorApi.getDac')
d.vthreshold d.vthreshold
m.assert_called_once_with('vthreshold', -1) m.assert_called_once_with('vthreshold', -1)
def test_set_vthreshold(d, mocker): def test_set_vthreshold(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setDac') m = mocker.patch('_slsdet.DetectorApi.setDac')
d.vthreshold = 1675 d.vthreshold = 1675
m.assert_called_once_with('vthreshold', -1, 1675) m.assert_called_once_with('vthreshold', -1, 1675)
#----------------------------------------------------------------trimbits #----------------------------------------------------------------trimbits
def test_get_trimbits(d, mocker): def test_get_trimbits(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getAllTrimbits') m = mocker.patch('_slsdet.DetectorApi.getAllTrimbits')
d.trimbits d.trimbits
m.assert_called_once_with() m.assert_called_once_with()
def test_set_trimbits(d, mocker): def test_set_trimbits(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setAllTrimbits') m = mocker.patch('_slsdet.DetectorApi.setAllTrimbits')
d.trimbits = 15 d.trimbits = 15
m.assert_called_once_with(15) m.assert_called_once_with(15)
def test_set_trimbits_raises_outside_range(d, mocker): def test_set_trimbits_raises_outside_range(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setAllTrimbits') mocker.patch('_slsdet.DetectorApi.setAllTrimbits')
with pytest.raises(ValueError): with pytest.raises(ValueError):
d.trimbits = 69 d.trimbits = 69

View File

@ -15,7 +15,7 @@ from pytest_mock import mocker
import sys import sys
sys.path.append('/home/l_frojdh/slsdetectorgrup/sls_detector') sys.path.append('/home/l_frojdh/slsdetectorgrup/sls_detector')
import _sls_detector import _slsdet
from sls_detector.errors import DetectorValueError, DetectorError from sls_detector.errors import DetectorValueError, DetectorError
from sls_detector.utils import all_equal, element_if_equal from sls_detector.utils import all_equal, element_if_equal
@ -47,7 +47,7 @@ def test_set_counters_single(d, mocker):
# def test_busy_call(d, mocker): # def test_busy_call(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getAcquiringFlag') # m = mocker.patch('_slsdet.DetectorApi.getAcquiringFlag')
# m.return_value = False # m.return_value = False
# assert d.busy == False # assert d.busy == False
@ -73,34 +73,34 @@ def test_set_counters_single(d, mocker):
# d.detector_type = 'Eiger' # d.detector_type = 'Eiger'
# def test_det_type(d, mocker): # def test_det_type(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getDetectorType') # m = mocker.patch('_slsdet.DetectorApi.getDetectorType')
# m.return_value = 'Eiger' # m.return_value = 'Eiger'
# assert d.detector_type == 'Eiger' # assert d.detector_type == 'Eiger'
# def test_get_exposure_time(d, mocker): # def test_get_exposure_time(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getExposureTime') # m = mocker.patch('_slsdet.DetectorApi.getExposureTime')
# m.return_value = 100000000 # m.return_value = 100000000
# assert d.exposure_time == 0.1 # assert d.exposure_time == 0.1
# def test_set_exposure_time(d, mocker): # def test_set_exposure_time(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setExposureTime') # m = mocker.patch('_slsdet.DetectorApi.setExposureTime')
# d.exposure_time = 1.5 # d.exposure_time = 1.5
# m.assert_called_once_with(1500000000) # m.assert_called_once_with(1500000000)
# def test_set_exposure_time_less_than_zero(d, mocker): # def test_set_exposure_time_less_than_zero(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setExposureTime') # mocker.patch('_slsdet.DetectorApi.setExposureTime')
# with pytest.raises(DetectorValueError): # with pytest.raises(DetectorValueError):
# d.exposure_time = -7 # d.exposure_time = -7
# def test_get_file_index(d, mocker): # def test_get_file_index(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getFileIndex') # m = mocker.patch('_slsdet.DetectorApi.getFileIndex')
# m.return_value = 8 # m.return_value = 8
# assert d.file_index == 8 # assert d.file_index == 8
# def test_set_file_index(d, mocker): # def test_set_file_index(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setFileIndex') # m = mocker.patch('_slsdet.DetectorApi.setFileIndex')
# d.file_index = 9 # d.file_index = 9
# m.assert_called_with(9) # m.assert_called_with(9)
@ -112,28 +112,28 @@ def test_set_counters_single(d, mocker):
# assert d.dynamic_range == -100 # assert d.dynamic_range == -100
# def test_set_file_index_raises_on_neg(d, mocker): # def test_set_file_index_raises_on_neg(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setFileIndex') # mocker.patch('_slsdet.DetectorApi.setFileIndex')
# with pytest.raises(ValueError): # with pytest.raises(ValueError):
# d.file_index = -9 # d.file_index = -9
# def test_get_file_name(d, mocker): # def test_get_file_name(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getFileName') # m = mocker.patch('_slsdet.DetectorApi.getFileName')
# d.file_name # d.file_name
# m.assert_called_once_with() # m.assert_called_once_with()
# def test_set_file_name(d, mocker): # def test_set_file_name(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setFileName') # m = mocker.patch('_slsdet.DetectorApi.setFileName')
# d.file_name = 'hej' # d.file_name = 'hej'
# m.assert_called_once_with('hej') # m.assert_called_once_with('hej')
# def test_get_file_path(d, mocker): # def test_get_file_path(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getFilePath') # m = mocker.patch('_slsdet.DetectorApi.getFilePath')
# d.file_path # d.file_path
# m.assert_called_once_with() # m.assert_called_once_with()
# def test_set_file_path_when_path_exists(d, mocker): # def test_set_file_path_when_path_exists(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setFilePath') # m = mocker.patch('_slsdet.DetectorApi.setFilePath')
# #To avoid raising an exception because path is not there # #To avoid raising an exception because path is not there
# mock_os = mocker.patch('os.path.exists') # mock_os = mocker.patch('os.path.exists')
# mock_os.return_value = True # mock_os.return_value = True
@ -141,25 +141,25 @@ def test_set_counters_single(d, mocker):
# m.assert_called_once_with('/path/to/something/') # m.assert_called_once_with('/path/to/something/')
# def test_set_file_path_raises_when_not_exists(d, mocker): # def test_set_file_path_raises_when_not_exists(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setFilePath') # mocker.patch('_slsdet.DetectorApi.setFilePath')
# mock_os = mocker.patch('os.path.exists') # mock_os = mocker.patch('os.path.exists')
# mock_os.return_value = False # mock_os.return_value = False
# with pytest.raises(FileNotFoundError): # with pytest.raises(FileNotFoundError):
# d.file_path = '/path/to/something/' # d.file_path = '/path/to/something/'
# def test_get_file_write(d, mocker): # def test_get_file_write(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getFileWrite') # m = mocker.patch('_slsdet.DetectorApi.getFileWrite')
# m.return_value = False # m.return_value = False
# assert d.file_write == False # assert d.file_write == False
# def test_set_file_write(d, mocker): # def test_set_file_write(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setFileWrite') # m = mocker.patch('_slsdet.DetectorApi.setFileWrite')
# d.file_write = True # d.file_write = True
# m.assert_called_once_with(True) # m.assert_called_once_with(True)
# def test_get_firmware_version(d, mocker): # def test_get_firmware_version(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getFirmwareVersion') # m = mocker.patch('_slsdet.DetectorApi.getFirmwareVersion')
# m.return_value = 20 # m.return_value = 20
# assert d.firmware_version == 20 # assert d.firmware_version == 20
@ -168,38 +168,38 @@ def test_set_counters_single(d, mocker):
# d.firmware_version = 20 # d.firmware_version = 20
# def test_get_high_voltage_call_signature(d, mocker): # def test_get_high_voltage_call_signature(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getDac') # m = mocker.patch('_slsdet.DetectorApi.getDac')
# d.high_voltage # d.high_voltage
# m.assert_called_once_with('vhighvoltage', -1) # m.assert_called_once_with('vhighvoltage', -1)
# def test_get_high_voltage(d, mocker): # def test_get_high_voltage(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getDac') # m = mocker.patch('_slsdet.DetectorApi.getDac')
# m.return_value = 80 # m.return_value = 80
# assert d.high_voltage == 80 # assert d.high_voltage == 80
# #self._api.setDac('vhighvoltage', -1, voltage) # #self._api.setDac('vhighvoltage', -1, voltage)
# def test_set_high_voltage(d, mocker): # def test_set_high_voltage(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setDac') # m = mocker.patch('_slsdet.DetectorApi.setDac')
# d.high_voltage = 80 # d.high_voltage = 80
# m.assert_called_once_with('vhighvoltage', -1, 80) # m.assert_called_once_with('vhighvoltage', -1, 80)
# def test_decode_hostname_two_names(d, mocker): # def test_decode_hostname_two_names(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getHostname') # m = mocker.patch('_slsdet.DetectorApi.getHostname')
# m.return_value = 'beb059+beb048+' # m.return_value = 'beb059+beb048+'
# assert d.hostname == ['beb059', 'beb048'] # assert d.hostname == ['beb059', 'beb048']
# def test_decode_hostname_four_names(d, mocker): # def test_decode_hostname_four_names(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getHostname') # m = mocker.patch('_slsdet.DetectorApi.getHostname')
# m.return_value = 'beb059+beb048+beb120+beb153+' # m.return_value = 'beb059+beb048+beb120+beb153+'
# assert d.hostname == ['beb059', 'beb048', 'beb120', 'beb153'] # assert d.hostname == ['beb059', 'beb048', 'beb120', 'beb153']
# def test_decode_hostname_blank(d, mocker): # def test_decode_hostname_blank(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getHostname') # m = mocker.patch('_slsdet.DetectorApi.getHostname')
# m.return_value = '' # m.return_value = ''
# assert d.hostname == [] # assert d.hostname == []
# def test_get_image_size_gives_correct_size(d, mocker): # def test_get_image_size_gives_correct_size(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getImageSize') # m = mocker.patch('_slsdet.DetectorApi.getImageSize')
# m.return_value = (512,1024) # m.return_value = (512,1024)
# im_size = d.image_size # im_size = d.image_size
# assert im_size.rows == 512 # assert im_size.rows == 512
@ -208,7 +208,7 @@ def test_set_counters_single(d, mocker):
# def test_load_config(d, mocker): # def test_load_config(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.readConfigurationFile') # m = mocker.patch('_slsdet.DetectorApi.readConfigurationFile')
# #To avoid raising an exception because path is not there # #To avoid raising an exception because path is not there
# mock_os = mocker.patch('os.path.isfile') # mock_os = mocker.patch('os.path.isfile')
# mock_os.return_value = True # mock_os.return_value = True
@ -216,14 +216,14 @@ def test_set_counters_single(d, mocker):
# m.assert_called_once_with('/path/to/my/file.config') # m.assert_called_once_with('/path/to/my/file.config')
# def test_load_config_raises_when_file_is_not_found(d, mocker): # def test_load_config_raises_when_file_is_not_found(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.readConfigurationFile') # mocker.patch('_slsdet.DetectorApi.readConfigurationFile')
# mock_os = mocker.patch('os.path.isfile') # mock_os = mocker.patch('os.path.isfile')
# mock_os.return_value = False # mock_os.return_value = False
# with pytest.raises(FileNotFoundError): # with pytest.raises(FileNotFoundError):
# d.load_config('/path/to/my/file.config') # d.load_config('/path/to/my/file.config')
# def test_load_parameters(d, mocker): # def test_load_parameters(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.readParametersFile') # m = mocker.patch('_slsdet.DetectorApi.readParametersFile')
# #To avoid raising an exception because path is not there # #To avoid raising an exception because path is not there
# mock_os = mocker.patch('os.path.isfile') # mock_os = mocker.patch('os.path.isfile')
# mock_os.return_value = True # mock_os.return_value = True
@ -231,7 +231,7 @@ def test_set_counters_single(d, mocker):
# m.assert_called_once_with('/path/to/my/file.par') # m.assert_called_once_with('/path/to/my/file.par')
# def test_load_parameters_raises_when_file_is_not_found(d, mocker): # def test_load_parameters_raises_when_file_is_not_found(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.readParametersFile') # mocker.patch('_slsdet.DetectorApi.readParametersFile')
# mock_os = mocker.patch('os.path.isfile') # mock_os = mocker.patch('os.path.isfile')
# mock_os.return_value = False # mock_os.return_value = False
# with pytest.raises(FileNotFoundError): # with pytest.raises(FileNotFoundError):
@ -239,14 +239,14 @@ def test_set_counters_single(d, mocker):
# #getDetectorGeometry # #getDetectorGeometry
# def test_get_module_geometry_gives_correct_size(d, mocker): # def test_get_module_geometry_gives_correct_size(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getDetectorGeometry') # m = mocker.patch('_slsdet.DetectorApi.getDetectorGeometry')
# m.return_value = (13,7) # m.return_value = (13,7)
# g = d.module_geometry # g = d.module_geometry
# assert g.vertical == 7 # assert g.vertical == 7
# assert g.horizontal == 13 # assert g.horizontal == 13
# def test_get_module_geometry_access(d, mocker): # def test_get_module_geometry_access(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getDetectorGeometry') # m = mocker.patch('_slsdet.DetectorApi.getDetectorGeometry')
# m.return_value = (12,3) # m.return_value = (12,3)
# assert d.module_geometry[0] == 12 # assert d.module_geometry[0] == 12
# assert d.module_geometry[1] == 3 # assert d.module_geometry[1] == 3
@ -259,12 +259,12 @@ def test_set_counters_single(d, mocker):
# assert t.vertical == 0 # assert t.vertical == 0
# def test_get_n_frames(d, mocker): # def test_get_n_frames(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getNumberOfFrames') # m = mocker.patch('_slsdet.DetectorApi.getNumberOfFrames')
# m.return_value = 3 # m.return_value = 3
# assert d.n_frames == 3 # assert d.n_frames == 3
# def test_set_n_frames(d, mocker): # def test_set_n_frames(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames') # m = mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
# d.n_frames = 9 # d.n_frames = 9
# m.assert_called_once_with(9) # m.assert_called_once_with(9)
@ -272,12 +272,12 @@ def test_set_counters_single(d, mocker):
# assert d.n_frames == -100 # assert d.n_frames == -100
# def test_set_n_frames_raises_on_neg(d, mocker): # def test_set_n_frames_raises_on_neg(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames') # mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
# with pytest.raises(DetectorValueError): # with pytest.raises(DetectorValueError):
# d.n_frames = -1 # d.n_frames = -1
# def test_set_n_frames_raises_on_zero(d, mocker): # def test_set_n_frames_raises_on_zero(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames') # mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
# with pytest.raises(DetectorValueError): # with pytest.raises(DetectorValueError):
# d.n_frames = 0 # d.n_frames = 0
@ -285,12 +285,12 @@ def test_set_counters_single(d, mocker):
# assert d.n_cycles == -100 # assert d.n_cycles == -100
# def test_set_n_cycles_raises_on_zero(d, mocker): # def test_set_n_cycles_raises_on_zero(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setCycles') # mocker.patch('_slsdet.DetectorApi.setCycles')
# with pytest.raises(DetectorValueError): # with pytest.raises(DetectorValueError):
# d.n_cycles = 0 # d.n_cycles = 0
# def test_set_n_cycles(d, mocker): # def test_set_n_cycles(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setCycles') # m = mocker.patch('_slsdet.DetectorApi.setCycles')
# d.n_cycles = 56 # d.n_cycles = 56
# m.assert_called_once_with(56) # m.assert_called_once_with(56)
@ -300,12 +300,12 @@ def test_set_counters_single(d, mocker):
# assert d.n_measurements == -100 # assert d.n_measurements == -100
# def test_set_n_measurements_raises_on_zero(d, mocker): # def test_set_n_measurements_raises_on_zero(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setNumberOfMeasurements') # mocker.patch('_slsdet.DetectorApi.setNumberOfMeasurements')
# with pytest.raises(DetectorValueError): # with pytest.raises(DetectorValueError):
# d.n_measurements = 0 # d.n_measurements = 0
# def test_set_n_measurements(d, mocker): # def test_set_n_measurements(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setNumberOfMeasurements') # m = mocker.patch('_slsdet.DetectorApi.setNumberOfMeasurements')
# d.n_measurements = 560 # d.n_measurements = 560
# m.assert_called_once_with(560) # m.assert_called_once_with(560)
@ -313,33 +313,33 @@ def test_set_counters_single(d, mocker):
# assert d.n_modules == 0 # assert d.n_modules == 0
# def test_get_n_modules(d, mocker): # def test_get_n_modules(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors') # m = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
# m.return_value = 12 # m.return_value = 12
# assert d.n_modules == 12 # assert d.n_modules == 12
# def test_get_period_time(d, mocker): # def test_get_period_time(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getPeriod') # m = mocker.patch('_slsdet.DetectorApi.getPeriod')
# m.return_value = 130000000 # m.return_value = 130000000
# assert d.period == 0.13 # assert d.period == 0.13
# def test_set_period_time(d, mocker): # def test_set_period_time(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setPeriod') # m = mocker.patch('_slsdet.DetectorApi.setPeriod')
# d.period = 1.953 # d.period = 1.953
# m.assert_called_once_with(1953000000) # m.assert_called_once_with(1953000000)
# def test_set_period_time_less_than_zero(d, mocker): # def test_set_period_time_less_than_zero(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setPeriod') # mocker.patch('_slsdet.DetectorApi.setPeriod')
# with pytest.raises(ValueError): # with pytest.raises(ValueError):
# d.period = -7 # d.period = -7
# def test_get_online(d, mocker): # def test_get_online(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getOnline') # m = mocker.patch('_slsdet.DetectorApi.getOnline')
# d.online # d.online
# m.assert_called_once_with() # m.assert_called_once_with()
# def test_set_online(d, mocker): # def test_set_online(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setOnline') # m = mocker.patch('_slsdet.DetectorApi.setOnline')
# d.online = True # d.online = True
# m.assert_called_once_with(True) # m.assert_called_once_with(True)
@ -347,116 +347,116 @@ def test_set_counters_single(d, mocker):
# assert d.last_client_ip == '' # assert d.last_client_ip == ''
# def test_last_cliten_ip_call(d, mocker): # def test_last_cliten_ip_call(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getLastClientIP') # m = mocker.patch('_slsdet.DetectorApi.getLastClientIP')
# d.last_client_ip # d.last_client_ip
# m.assert_called_once_with() # m.assert_called_once_with()
# #-------------------------------------------------------------Rate correction # #-------------------------------------------------------------Rate correction
# def test_get_rate_correction(d, mocker): # def test_get_rate_correction(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getRateCorrection') # m = mocker.patch('_slsdet.DetectorApi.getRateCorrection')
# m.return_value = [132,129] # m.return_value = [132,129]
# assert d.rate_correction == [132,129] # assert d.rate_correction == [132,129]
# def test_set_rate_correction(d, mocker): # def test_set_rate_correction(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setRateCorrection') # m = mocker.patch('_slsdet.DetectorApi.setRateCorrection')
# mock_n = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors') # mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
# mock_n.return_value = 3 # mock_n.return_value = 3
# d.rate_correction = [123,90,50] # d.rate_correction = [123,90,50]
# m.assert_called_once_with([123,90,50]) # m.assert_called_once_with([123,90,50])
# def test_set_rate_correction_raises_on_wrong_number_of_values(d, mocker): # def test_set_rate_correction_raises_on_wrong_number_of_values(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setRateCorrection') # mocker.patch('_slsdet.DetectorApi.setRateCorrection')
# mock_n = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors') # mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
# mock_n.return_value = 4 # mock_n.return_value = 4
# with pytest.raises(ValueError): # with pytest.raises(ValueError):
# d.rate_correction = [123,90,50] # d.rate_correction = [123,90,50]
# #----------------------------------------------------------------Readout clock # #----------------------------------------------------------------Readout clock
# def test_get_readout_clock_0(d, mocker): # def test_get_readout_clock_0(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed') # m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
# m.return_value = 0 # m.return_value = 0
# assert d.readout_clock == 'Full Speed' # assert d.readout_clock == 'Full Speed'
# def test_get_readout_clock_1(d, mocker): # def test_get_readout_clock_1(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed') # m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
# m.return_value = 1 # m.return_value = 1
# assert d.readout_clock == 'Half Speed' # assert d.readout_clock == 'Half Speed'
# def test_get_readout_clock_2(d, mocker): # def test_get_readout_clock_2(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed') # m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
# m.return_value = 2 # m.return_value = 2
# assert d.readout_clock == 'Quarter Speed' # assert d.readout_clock == 'Quarter Speed'
# def test_get_readout_clock_3(d, mocker): # def test_get_readout_clock_3(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed') # m = mocker.patch('_slsdet.DetectorApi.getReadoutClockSpeed')
# m.return_value = 3 # m.return_value = 3
# assert d.readout_clock == 'Super Slow Speed' # assert d.readout_clock == 'Super Slow Speed'
# def test_set_readout_clock_0(d, mocker): # def test_set_readout_clock_0(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed') # m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
# d.readout_clock = 'Full Speed' # d.readout_clock = 'Full Speed'
# m.assert_called_once_with(0) # m.assert_called_once_with(0)
# def test_set_readout_clock_1(d, mocker): # def test_set_readout_clock_1(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed') # m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
# d.readout_clock = 'Half Speed' # d.readout_clock = 'Half Speed'
# m.assert_called_once_with(1) # m.assert_called_once_with(1)
# def test_set_readout_clock_2(d, mocker): # def test_set_readout_clock_2(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed') # m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
# d.readout_clock = 'Quarter Speed' # d.readout_clock = 'Quarter Speed'
# m.assert_called_once_with(2) # m.assert_called_once_with(2)
# def test_set_readout_clock_3(d, mocker): # def test_set_readout_clock_3(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed') # m = mocker.patch('_slsdet.DetectorApi.setReadoutClockSpeed')
# d.readout_clock = 'Super Slow Speed' # d.readout_clock = 'Super Slow Speed'
# m.assert_called_once_with(3) # m.assert_called_once_with(3)
# #----------------------------------------------------------------rx_datastream # #----------------------------------------------------------------rx_datastream
# def test_get_rx_datastream(d, mocker): # def test_get_rx_datastream(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getRxDataStreamStatus') # m = mocker.patch('_slsdet.DetectorApi.getRxDataStreamStatus')
# m.return_value = False # m.return_value = False
# assert d.rx_datastream == False # assert d.rx_datastream == False
# def test_set_rx_datastream(d, mocker): # def test_set_rx_datastream(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setRxDataStreamStatus') # m = mocker.patch('_slsdet.DetectorApi.setRxDataStreamStatus')
# d.rx_datastream = True # d.rx_datastream = True
# m.assert_called_once_with(True) # m.assert_called_once_with(True)
# def test_get_rx_zmqip(d, mocker): # def test_get_rx_zmqip(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter') # m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
# d.rx_zmqip # d.rx_zmqip
# m.assert_called_once_with('rx_zmqip') # m.assert_called_once_with('rx_zmqip')
# def test_get_rx_zmqport_call(d, mocker): # def test_get_rx_zmqport_call(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter') # m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
# d.rx_zmqport # d.rx_zmqport
# m.assert_called_once_with('rx_zmqport') # m.assert_called_once_with('rx_zmqport')
# def test_get_rx_zmqport_decode(d, mocker): # def test_get_rx_zmqport_decode(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter') # m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
# m.return_value = ['30001', '30003'] # m.return_value = ['30001', '30003']
# assert d.rx_zmqport == [30001, 30003] # assert d.rx_zmqport == [30001, 30003]
# def test_get_rx_zmqport_empty(d, mocker): # def test_get_rx_zmqport_empty(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter') # m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
# m.return_value = '' # m.return_value = ''
# assert d.rx_zmqport == [] # assert d.rx_zmqport == []
# #--------------------------------------------------------------------status # #--------------------------------------------------------------------status
# def test_status_call(d, mocker): # def test_status_call(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getRunStatus') # m = mocker.patch('_slsdet.DetectorApi.getRunStatus')
# d.status # d.status
# m.assert_called_once_with() # m.assert_called_once_with()
# def test_start_detecor(d, mocker): # def test_start_detecor(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.startAcquisition') # m = mocker.patch('_slsdet.DetectorApi.startAcquisition')
# d.start_detector() # d.start_detector()
# m.assert_called_once_with() # m.assert_called_once_with()
# def test_stop_acq_call(d, mocker): # def test_stop_acq_call(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.stopAcquisition') # m = mocker.patch('_slsdet.DetectorApi.stopAcquisition')
# d.stop_detector() # d.stop_detector()
# m.assert_called_once_with() # m.assert_called_once_with()
@ -464,23 +464,23 @@ def test_set_counters_single(d, mocker):
# #------------------------------------------------------------------timing mode # #------------------------------------------------------------------timing mode
# def test_get_timing_mode(d, mocker): # def test_get_timing_mode(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getTimingMode') # m = mocker.patch('_slsdet.DetectorApi.getTimingMode')
# d.timing_mode # d.timing_mode
# m.assert_called_once_with() # m.assert_called_once_with()
# def test_set_timing_mode(d, mocker): # def test_set_timing_mode(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setTimingMode') # m = mocker.patch('_slsdet.DetectorApi.setTimingMode')
# d.timing_mode = 'auto' # d.timing_mode = 'auto'
# m.assert_called_once_with('auto') # m.assert_called_once_with('auto')
# #----------------------------------------------------------------vthreshold # #----------------------------------------------------------------vthreshold
# def test_get_vthreshold(d, mocker): # def test_get_vthreshold(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getDac') # m = mocker.patch('_slsdet.DetectorApi.getDac')
# d.vthreshold # d.vthreshold
# m.assert_called_once_with('vthreshold', -1) # m.assert_called_once_with('vthreshold', -1)
# def test_set_vthreshold(d, mocker): # def test_set_vthreshold(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setDac') # m = mocker.patch('_slsdet.DetectorApi.setDac')
# d.vthreshold = 1675 # d.vthreshold = 1675
# m.assert_called_once_with('vthreshold', -1, 1675) # m.assert_called_once_with('vthreshold', -1, 1675)

View File

@ -19,3 +19,18 @@ target_link_libraries(result
set_target_properties(result PROPERTIES set_target_properties(result PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
) )
add_executable(udp udp.cpp)
target_link_libraries(udp
slsDetectorShared
slsSupportLib
pthread
rt
fmt
)
set_target_properties(udp PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)

65
sample/udp.cpp Normal file
View File

@ -0,0 +1,65 @@
#include "UdpRxSocket.h"
#include "sls_detector_defs.h"
#include <chrono>
#include <fmt/format.h>
#include <iostream>
#include <thread>
#include "network_utils.h"
// Assume packages arrive in order
// Assume frame nr starts from 0
using header_t = slsDetectorDefs::sls_detector_header;
int main() {
fmt::print("Hej!\n");
constexpr ssize_t packet_size = 4144;
constexpr ssize_t payload_size = packet_size - sizeof(header_t);
int port = 50012;
char * buffer = new char[packet_size];
sls::UdpRxSocket s(port, packet_size, "10.1.1.107");
int n = 0;
while(true){
// s.ReceiveDataOnly(buffer);
if (s.ReceivePacket())
std::cout << n++ << std::endl;
}
// auto header = reinterpret_cast<header_t *>(s.buffer());
// char *data = s.buffer() + sizeof(header_t);
// fmt::print("buffer start: {}\nheader: {}\ndata: {}\n", fmt::ptr(s.buffer()),
// fmt::ptr(header), fmt::ptr(data));
// int n = 0;
// fmt::print("Buffer size: {}\n", s.buffer_size());
// std::vector<uint16_t> image(n_pixels);
// char *image_data = (char *)image.data();
// uint64_t frame_nr = 0;
// while (true) {
// if (s.ReceivePacket()) {
// // fmt::print("frame: {} pkt: {} dst: {}\n", header->frameNumber,
// // header->packetNumber, header->packetNumber*payload_size);
// if (header->frameNumber != frame_nr) {
// // dispatch frame
// fmt::print("frame {} done! got: {} pkgs\n", frame_nr, n);
// frame_nr = header->frameNumber;
// n = 0;
// std::this_thread::sleep_for(std::chrono::milliseconds(1));
// }
// ++n;
// memcpy(image_data + header->packetNumber * payload_size, data,
// payload_size);
// } else {
// std::cout << "timeout\n";
// }
// }
}

View File

@ -423,7 +423,7 @@ template <class dataType> class analogDetector {
if (g==0) g=-1.; if (g==0) g=-1.;
} }
return stat[iy][ix].getPedestalRMS()/g;//divide by gain? return stat[iy][ix].getPedestalRMS();//divide by gain?
} }
return -1; return -1;
}; };

View File

@ -1,6 +1,7 @@
#ifndef DESERIALIZER_H #ifndef DESERIALIZER_H
#define DESERIALIZER_H #define DESERIALIZER_H
#include <vector> #include <vector>
#include "slsDetectorData.h"
class deserializer : public slsDetectorData<int> { class deserializer : public slsDetectorData<int> {
@ -52,7 +53,13 @@ class deserializer : public slsDetectorData<int> {
static int* deserializeAll(char *ptr, std::vector <int> dbl, int dr=24, int nch=64*3, int off=5) { static int* deserializeAll(char *ptr, std::vector <int> dbl, int dr=24, int nch=64*3, int off=5) {
// off=0; // off=0;
//int iarg; //int iarg;
int64_t word, *wp;
cout <<"** deserializer: " << endl;
cout << "** Number of chans:\t" << nch << endl;
cout << "** Serial Offset:\t" << off << endl;
cout << "** Dynamic range:\t" << dr << endl;
int64_t word, *wp, ww,one=1, bit ;
int* val=new int[nch]; int* val=new int[nch];
int ioff=0; int ioff=0;
int idr=0; int idr=0;
@ -67,38 +74,61 @@ class deserializer : public slsDetectorData<int> {
} }
wp=(int64_t*)ptr; wp=(int64_t*)ptr;
for (iw=0; iw<nch/nb; iw) { int nw=nch/nb;
cout << "** Number of bits:\t" << nb << endl;
cout << "** Samples:\t" << nw << endl;
for (ib=0; ib<nb; ib++) {
cout << dbl[ib] << " " ;
}
cout << endl;
for (ib=0; ib<nch; ib++) {
val[ib]=0;
}
for (iw=0; iw<nw; iw) {
word=*wp;; word=*wp;;
if (ioff<off) { if (ioff<off) {
ioff++; ioff++;
// cout <<"*"; // cout <<"*";
} else { } else {
//if (idr<16) { //if (idr<16) {
ib=0; //ib=0;
for (const auto &bit : dbl) { // cout << hex << "*************" << word << endl;
ich=iw+nch/nb*(ib); for (ib=0; ib<nb; ib++) {
if (word&(1<<bit) && ich<nch) { // for (const auto &bit : dbl) {
ich=iw+nch*ib/nb;
/* if (ich>1060) */
/* cout << iw << " " << idr << " " << ib << " " << bit << " " << ich << " " << val[ich] << " ** " ; */
bit=dbl[ib];
ww=one<<bit;
if (word&(ww) && ich<nch) {
//cout << "+" ; //cout << "+" ;
val[ich]|=(1<<idr); val[ich]|=(1<<idr);
} //else { }
/* if (ich>1060) */
/* cout << val[ich] << " " << hex << word << " " << ww << " " << (word&(ww)) << dec <<endl; */
/* //else { */
//cout << "-" ; //cout << "-" ;
//} //}
ib++; //ib++;
}
} }
idr++; idr++;
}
if (idr==dr) { if (idr==dr) {
idr=0; idr=0;
// cout << dec << " " << iw << " " << val[iw] << " " << val[iw+nch/2] << endl; // cout << dec << " " << iw << " " << val[iw] << " " << val[iw+nch/2] << endl;
cout <<dec << iw<<endl; // cout <<dec << iw<<endl;
iw++; iw++;
}//end if() }//end if()
//end else() //end else()
wp+=1; wp+=1;
ii++; // ii++;
}//end for }//end for
@ -117,7 +147,7 @@ class deserializer : public slsDetectorData<int> {
int ii=0; int ii=0;
int ich; int ich;
int nb=dbl.size(); int nb=dbl.size();
int bit;
char *dval; char *dval;
idr=0; idr=0;
@ -128,7 +158,12 @@ class deserializer : public slsDetectorData<int> {
ib=0; ib=0;
ich=0; ich=0;
for (const auto &bit : dbl) { for (ib=0; ib<nb; ib++) {
// for (const auto &bit : dbl) {
/* if (ich>1060) */
/* cout << iw << " " << idr << " " << ib << " " << bit << " " << ich << " " << val[ich] << " ** " ; */
bit=dbl[ib];
//ioff=off; //ioff=off;
idr=0; idr=0;
for (iw=0; iw<(nch*dr/nb)/8; iw++) { for (iw=0; iw<(nch*dr/nb)/8; iw++) {
@ -141,7 +176,7 @@ class deserializer : public slsDetectorData<int> {
} }
} }
ii++; ii++;
ib++; // ib++;
}//end for }//end for

View File

@ -0,0 +1,125 @@
#ifndef IMAGEZMQ16BIT_H
#define IMAGEZMQ16BIT_H
#include "slsDetectorData.h"
class imageZmq16bit : public slsDetectorData<uint16_t> {
private:
// int iframe;
public:
/**
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
(160x160 pixels, 40 packets 1286 large etc.)
\param c crosstalk parameter for the output buffer
*/
// moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)), xtalk(0.00021) {
imageZmq16bit(int nnx=400, int nny=400): slsDetectorData<uint16_t>(nnx, nny, 2*nnx*nny) {
cout << "* " << nx << " " << ny << endl;
int is=0;
for (int row=0; row<ny; row++){
for(int col=0;col<nx;col++){
dataMap[row][col]=is*2;
is++;
}
}
};
virtual double getValue(char *data, int ix, int iy=0) {
cout << ix << " " << ix << dataMap[iy][ix] << 2*nx*ny << " "<< endl;
uint16_t val=getChannel(data, ix, iy)&0x3fff;
return val;
};
int getFrameNumber(char *buff){return *((int*)buff);};//*((int*)(buff+5))&0xffffff;};
int getPacketNumber(char *buff){return 0;}//((*(((int*)(buff+4))))&0xff)+1;};
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int &ff) {
int np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
char *data=new char[2*nx*ny];
char *d=readNextFrame(filebin, ff, np, data);
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
//char *retval=0;
// int nd;
//int fnum = -1;
np=0;
// int pn;
// if (ff>=0)
// fnum=ff;
if (filebin.is_open()) {
if (filebin.read(data, 2*nx*ny) ){
// iframe++;
//ff=iframe;
return data;
}
}
return NULL;
};
virtual char *findNextFrame(char *data, int &ndata, int dsize){
if (dsize<2*nx*ny) ndata=dsize;
else ndata=2*nx*ny;
return data;
}
// virtual int setFrameNumber(int ff){iframe=ff};
int getPacketNumber(int x, int y) {return 0;};
};
#endif

View File

@ -0,0 +1,125 @@
#ifndef IMAGEZMQ32BIT_H
#define IMAGEZMQ32BIT_H
#include "slsDetectorData.h"
class imageZmq32bit : public slsDetectorData<uint16_t> {
private:
// int iframe;
public:
/**
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
(160x160 pixels, 40 packets 1286 large etc.)
\param c crosstalk parameter for the output buffer
*/
// moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)), xtalk(0.00021) {
imageZmq32bit(int nnx=400, int nny=400): slsDetectorData<uint16_t>(nnx, nny, sizeof(uint32_t)*nnx*nny) {
cout << "* " << nx << " " << ny << endl;
int is=0;
for (int row=0; row<ny; row++){
for(int col=0;col<nx;col++){
dataMap[row][col]=is*sizeof(uint32_t);
is++;
}
}
};
/* virtual double getValue(char *data, int ix, int iy=0) { */
/* //cout << ix << " " << ix << dataMap[iy][ix] << 2*nx*ny << " "<< endl; */
/* uint16_t val=getChannel(data, ix, iy); */
/* return val; */
/* }; */
int getFrameNumber(char *buff){return *((int*)buff);};//*((int*)(buff+5))&0xffffff;};
int getPacketNumber(char *buff){return 0;}//((*(((int*)(buff+4))))&0xff)+1;};
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int &ff) {
int np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
char *data=new char[2*nx*ny];
char *d=readNextFrame(filebin, ff, np, data);
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
//char *retval=0;
// int nd;
//int fnum = -1;
np=0;
// int pn;
// if (ff>=0)
// fnum=ff;
if (filebin.is_open()) {
if (filebin.read(data, 2*nx*ny) ){
// iframe++;
//ff=iframe;
return data;
}
}
return NULL;
};
virtual char *findNextFrame(char *data, int &ndata, int dsize){
if (dsize<2*nx*ny) ndata=dsize;
else ndata=2*nx*ny;
return data;
}
// virtual int setFrameNumber(int ff){iframe=ff};
int getPacketNumber(int x, int y) {return 0;};
};
#endif

View File

@ -28,7 +28,8 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
\param c crosstalk parameter for the output buffer \param c crosstalk parameter for the output buffer
*/ */
moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)), xtalk(0.00021) { // moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)), xtalk(0.00021) {
moench03T1ZmqDataNew(int ns=5000, int oo=0): slsDetectorData<uint16_t>(400, 400, ns*32*2+oo), nSamples(ns), offset(oo), xtalk(0.00021) {
int nadc=32; int nadc=32;
int sc_width=25; int sc_width=25;
@ -137,6 +138,7 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
/* vout+=0.0008*val-6224; */ /* vout+=0.0008*val-6224; */
/* return vout; //(double)getChannel(data, ix, iy); /* return vout; //(double)getChannel(data, ix, iy);
*/ */
// cout << ix << " "<< iy << " " << dataMap[iy][ix] << endl;
return ((double)getChannel(data, ix, iy))+xtalk*getGhost(iy,iy); return ((double)getChannel(data, ix, iy))+xtalk*getGhost(iy,iy);
}; };

View File

@ -1,15 +1,19 @@
INCDIR= -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ INCDIR= -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ -I../../libs/rapidjson/
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3 -g -std=c++11 -Wall LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3 -g -std=c++11 -Wall
#-L../../bin -lhdf5 -L. #-L../../bin -lhdf5 -L.
#DESTDIR?=../bin #DESTDIR?=../bin
all: moenchZmqProcess all: moenchZmqProcess moenchZmqProcessCtbGui
moenchZmqProcess: moenchZmqProcess.cpp clean moenchZmqProcess: moenchZmqProcess.cpp clean
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP
moenchZmqProcessCtbGui: moenchZmqProcess.cpp clean
g++ -o moenchZmqProcessCtbGui moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DCTBGUI
clean: clean:
rm -f moenchZmqProcess rm -f moenchZmqProcess

View File

@ -149,6 +149,7 @@ int main(int argc, char *argv[]) {
if (argc>=9) { if (argc>=9) {
nframes=atoi(argv[8]); nframes=atoi(argv[8]);
} }
int xmin=0, xmax=nx, ymin=0, ymax=ny; int xmin=0, xmax=nx, ymin=0, ymax=ny;
if (argc>=13) { if (argc>=13) {
xmin=atoi(argv[9]); xmin=atoi(argv[9]);
@ -185,6 +186,7 @@ int main(int argc, char *argv[]) {
cout << "pedestal file is " << pedfile << endl; cout << "pedestal file is " << pedfile << endl;
if (thr>0) if (thr>0)
cout << "threshold is " << thr << endl; cout << "threshold is " << thr << endl;
cout << "Nframes is " << nframes << endl;
uint32 nnx, nny; uint32 nnx, nny;
double *gmap; double *gmap;

View File

@ -74,6 +74,14 @@ int main(int argc, char *argv[]) {
// high_resolution_clock::time_point t1; // high_resolution_clock::time_point t1;
// high_resolution_clock::time_point t2 ; // high_resolution_clock::time_point t2 ;
time_t begin,end,finished; time_t begin,end,finished;
int rms=0;
int nped=1000, nped0=100;
#ifdef PTC
nped=10000;
nped0=10000;
#endif
if (argc > 4) { if (argc > 4) {
@ -111,7 +119,7 @@ int main(int argc, char *argv[]) {
} }
//slsDetectorData *det=new moench03T1ZmqDataNew(); //slsDetectorData *det=new moench03T1ZmqDataNew();
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew(); moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew(5000,sizeof(int));
cout << endl << " det" <<endl; cout << endl << " det" <<endl;
int npx, npy; int npx, npy;
det->getDetectorSize(npx, npy); det->getDetectorSize(npx, npy);
@ -129,8 +137,15 @@ int main(int argc, char *argv[]) {
int ncol_cm=CM_ROWS; int ncol_cm=CM_ROWS;
double xt_ghost=C_GHOST; double xt_ghost=C_GHOST;
moench03CommonMode *cm=new moench03CommonMode(ncol_cm);
moench03GhostSummation *gs=new moench03GhostSummation(det, xt_ghost);
moench03CommonMode *cm=NULL;
moench03GhostSummation *gs=NULL;
#ifdef CORR
cm=new moench03CommonMode(ncol_cm);
gs=new moench03GhostSummation(det, xt_ghost);
#endif
double *gainmap=NULL; double *gainmap=NULL;
float *gm; float *gm;
double *gmap=NULL; double *gmap=NULL;
@ -158,7 +173,7 @@ int main(int argc, char *argv[]) {
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000); //analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
#ifndef INTERP #ifndef INTERP
singlePhotonDetector *filter=new singlePhotonDetector(det,3, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs); singlePhotonDetector *filter=new singlePhotonDetector(det,3, nSigma, 1, cm, nped, nped0, -1, -1, gainmap, gs);
multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize); multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize);
@ -169,7 +184,7 @@ int main(int argc, char *argv[]) {
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); interpolatingDetector *filter=new interpolatingDetector(det,interp, nSigma, 1, cm, nped, nped0, -1, -1, gainmap, gs);
multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize); multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize);
#endif #endif
@ -293,7 +308,8 @@ int main(int argc, char *argv[]) {
uint8_t detType = 0; uint8_t detType = 0;
uint8_t version = 0; uint8_t version = 0;
// int* flippedData = 0; // int* flippedData = 0;
char* additionalJsonHeader = 0; string* additionalJsonHeader = 0;
//char* additionalJsonHeader = 0;
int32_t threshold=0; int32_t threshold=0;
@ -356,6 +372,11 @@ int main(int argc, char *argv[]) {
sprintf(ofname,"%s_%ld_ped.tiff",fname,fileindex); sprintf(ofname,"%s_%ld_ped.tiff",fname,fileindex);
mt->writePedestal(ofname); mt->writePedestal(ofname);
cout << "Writing pedestal to " << ofname << endl; cout << "Writing pedestal to " << ofname << endl;
if (rms) {
sprintf(ofname,"%s_%ld_var.tiff",fname,fileindex);
mt->writePedestalRMS(ofname);
cout << "Writing pedestal variance to " << ofname << endl;
}
} }
#ifdef INTERP #ifdef INTERP
else if (fMode==eFlat) { else if (fMode==eFlat) {
@ -388,7 +409,7 @@ int main(int argc, char *argv[]) {
dout[ix]=ped[ix]; dout[ix]=ped[ix];
// if (ix<100*400) // if (ix<100*400)
// cout << ix << " " << ped[ix] << endl; // cout << ix << " " << ped[ix] << " "<< dout[ix] << endl;
} }
} }
@ -448,43 +469,20 @@ int main(int argc, char *argv[]) {
// cout << "Sending image size " << nnx << " " << nny << endl; // cout << "Sending image size " << nnx << " " << nny << endl;
#ifndef DEVELOPER // #ifndef DEVELOPER
#ifndef MOENCH_BRANCH // #ifndef MOENCH_BRANCH
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, 0,0, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex,0 , packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, additionalJsonHeader); // zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, 1,1, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex,0 , packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, additionalJsonHeader);
#endif // #endif
#endif // #endif
#ifdef DEVELOPER
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
#endif
#ifdef MOENCH_BRANCH
/*
int SendHeaderData ( int index, bool dummy, uint32_t jsonversion, uint32_t dynamicrange = 0, uint64_t fileIndex = 0,
uint32_t npixelsx = 0, uint32_t npixelsy = 0, uint32_t imageSize = 0,
uint64_t acqIndex = 0, uint64_t fIndex = 0, char* fname = NULL,
uint64_t frameNumber = 0, uint32_t expLength = 0, uint32_t packetNumber = 0,
uint64_t bunchId = 0, uint64_t timestamp = 0,
uint16_t modId = 0, uint16_t row = 0, uint16_t column = 0, uint16_t reserved = 0,
uint32_t debug = 0, uint16_t roundRNumber = 0,
uint8_t detType = 0, uint8_t version = 0, int* flippedData = 0,
char* additionalJsonHeader = 0) {
int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEADER_VERSION , uint32_t dr, uint64_t fileindex, uint32_t 0, uint32_t 0, uint32_t, uint64_t, uint64_t, char*, uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, int*, char*)
*/
//zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version);//, 0,additionalJsonHeader);
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
/* old
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
*/
/*
new // #ifdef DEVELOPER
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,additionalJsonHeader); // #ifdef CTBGUI
*/ // zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
#endif // #endif
// #ifndef CTBGUI
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 1,1,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
//#endif
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8); zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
@ -577,6 +575,7 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
/* Analog detector commands */ /* Analog detector commands */
//isPedestal=0; //isPedestal=0;
//isFlat=0; //isFlat=0;
rms=0;
fMode=eFrame; fMode=eFrame;
frameMode_s="frame"; frameMode_s="frame";
cprintf(MAGENTA, "Frame mode: "); cprintf(MAGENTA, "Frame mode: ");
@ -586,11 +585,17 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
if (frameMode_s == "pedestal"){ if (frameMode_s == "pedestal"){
fMode=ePedestal; fMode=ePedestal;
//isPedestal=1; //isPedestal=1;
} else if (frameMode_s == "newPedestal"){ } else if (frameMode_s == "newpedestal"){
mt->newDataSet(); //resets pedestal mt->newDataSet(); //resets pedestal
// cprintf(MAGENTA, "Resetting pedestal\n"); // cprintf(MAGENTA, "Resetting pedestal\n");
fMode=ePedestal; fMode=ePedestal;
//isPedestal=1; //isPedestal=1;
} else if (frameMode_s == "variance"){
mt->newDataSet(); //resets pedestal
// cprintf(MAGENTA, "Resetting pedestal\n");
fMode=ePedestal;
rms=1;
//isPedestal=1;
} }
#ifdef INTERP #ifdef INTERP
else if (frameMode_s == "flatfield") { else if (frameMode_s == "flatfield") {
@ -611,11 +616,13 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
frameMode_s="frame"; frameMode_s="frame";
} }
} }
}
cprintf(MAGENTA, "%s\n" , frameMode_s.c_str()); cprintf(MAGENTA, "%s\n" , frameMode_s.c_str());
} else
cprintf(RED, "%s\n" , frameMode_s.c_str());
mt->setFrameMode(fMode); mt->setFrameMode(fMode);
// threshold=0; threshold=0;
cprintf(MAGENTA, "Threshold: "); cprintf(MAGENTA, "Threshold: ");
if (doc.HasMember("threshold")) { if (doc.HasMember("threshold")) {
if (doc["threshold"].IsInt()) { if (doc["threshold"].IsInt()) {
@ -683,10 +690,11 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
} }
} }
} cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
} else
cprintf(RED, "%s\n" , frameMode_s.c_str());
mt->setDetectorMode(dMode); mt->setDetectorMode(dMode);
cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
// cout << "done " << endl; // cout << "done " << endl;
@ -737,7 +745,7 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
// cout << "file" << endl; // cout << "file" << endl;
// cout << "data " << endl; // cout << "data " << endl;
if (of==NULL) { if (of==NULL && dMode!=eAnalog && fMode!=ePedestal && threshold<=0) {
#ifdef WRITE_QUAD #ifdef WRITE_QUAD
sprintf(ofname,"%s_%ld.clust2",filename.c_str(),fileindex); sprintf(ofname,"%s_%ld.clust2",filename.c_str(),fileindex);
#endif #endif
@ -772,15 +780,13 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
mt->pushData(buff); mt->pushData(buff);
mt->nextThread(); mt->nextThread();
mt->popFree(buff); mt->popFree(buff);
cprintf(GREEN, "Frame\n");
} else { } else {
cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber); cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber);
//length = //length =
zmqsocket->ReceiveData(0, dummybuff, size); zmqsocket->ReceiveData(0, dummybuff, size);
} }
iframe++; iframe++;
} // exiting infinite loop } // exiting infinite loop

View File

@ -462,6 +462,50 @@ public:
}; };
virtual double *getPedestalRMS(){
int nx, ny;
dets[0]->getDetectorSize(nx,ny);
// if (ped) delete [] ped;
double *rms=new double[nx*ny];
double *p0=new double[nx*ny];
for (int i=0; i<nThreads; i++) {
//inte=(slsInterpolation*)dets[i]->getInterpolation(nb,emi,ema);
// cout << i << endl;
p0=dets[i]->getPedestalRMS(p0);
if (p0) {
if (i==0) {
for (int ib=0; ib<nx*ny; ib++) {
rms[ib]=p0[ib]*p0[ib]/((double)nThreads);
// cout << p0[ib] << " ";
}
} else {
for (int ib=0; ib<nx*ny; ib++) {
rms[ib]+=p0[ib]*p0[ib]/((double)nThreads);
// cout << p0[ib] << " ";
}
}
}
}
delete [] p0;
/* for (int ib=0; ib<nx*ny; ib++) { */
/* if (rms[ib]>0) */
/* rms[ib]=sqrt(ped[ib]); */
/* else */
/* rms[ib]=0; */
/* } */
return rms;
};
virtual double *setPedestal(double *h=NULL){ virtual double *setPedestal(double *h=NULL){
//int nb=0; //int nb=0;
@ -498,6 +542,27 @@ public:
}; };
virtual void *writePedestalRMS(const char * imgname){
int nx, ny;
dets[0]->getDetectorSize(nx,ny);
double *rms=getPedestalRMS();
float *gm=new float[nx*ny];
if (gm) {
for (int ix=0; ix<nx*ny; ix++) {
gm[ix]=rms[ix];
}
WriteToTiff(gm,imgname ,nx, ny);
delete [] gm;
delete [] rms;
} else cout << "Could not allocate float image " << endl;
return NULL;
};
virtual void *readPedestal(const char * imgname, int nb=-1, double emin=1, double emax=0){ virtual void *readPedestal(const char * imgname, int nb=-1, double emin=1, double emax=0){
int nx, ny; int nx, ny;

View File

@ -1,5 +1,8 @@
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
find_package(PNG REQUIRED)
find_package(ZLIB REQUIRED)
set(SOURCES set(SOURCES
slsDetectorPlotting/src/SlsQt1DPlot.cxx slsDetectorPlotting/src/SlsQt1DPlot.cxx
slsDetectorPlotting/src/SlsQt1DZoomer.cxx slsDetectorPlotting/src/SlsQt1DZoomer.cxx
@ -89,8 +92,8 @@ target_link_libraries(slsDetectorGui PUBLIC
${QT_QTCORE_LIBRARIES} ${QT_QTCORE_LIBRARIES}
${QT_QTGUI_LIBRARIES} ${QT_QTGUI_LIBRARIES}
${QWT_LIBRARIES} ${QWT_LIBRARIES}
png PNG::PNG
z ZLIB::ZLIB
Qt4::QtOpenGL Qt4::QtOpenGL
Qt4::QtSvg Qt4::QtSvg
) )

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>500</width> <width>376</width>
<height>350</height> <height>425</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
@ -240,7 +240,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>500</width> <width>376</width>
<height>28</height> <height>28</height>
</rect> </rect>
</property> </property>

View File

@ -145,6 +145,10 @@
<property name="windowTitle"> <property name="windowTitle">
<string>SLS Detector GUI</string> <string>SLS Detector GUI</string>
</property> </property>
<property name="windowIcon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/mountain.png</normaloff>:/icons/images/mountain.png</iconset>
</property>
<property name="inputMethodHints"> <property name="inputMethodHints">
<set>Qt::ImhNone</set> <set>Qt::ImhNone</set>
</property> </property>
@ -371,101 +375,6 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</widget> </widget>
<action name="actionOpenSetup">
<property name="text">
<string>&amp;Load &amp;Setup</string>
</property>
<property name="font">
<font/>
</property>
</action>
<action name="actionSaveSetup">
<property name="text">
<string>&amp;Save &amp;Setup</string>
</property>
<property name="font">
<font/>
</property>
</action>
<action name="actionMeasurementWizard">
<property name="text">
<string>&amp;Measurement Wizard</string>
</property>
</action>
<action name="actionOpenConfiguration">
<property name="text">
<string>&amp;Load &amp;Configuration</string>
</property>
</action>
<action name="actionSaveConfiguration">
<property name="text">
<string>&amp;Save &amp;Configuration</string>
</property>
</action>
<action name="actionEnergyCalibration">
<property name="text">
<string>&amp;Energy Calibration</string>
</property>
</action>
<action name="actionAngularCalibration">
<property name="text">
<string>&amp;Angular Calibration</string>
</property>
</action>
<action name="actionDebug">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Debug</string>
</property>
</action>
<action name="actionBeamline">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Beamline</string>
</property>
</action>
<action name="actionExpert">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Expert</string>
</property>
</action>
<action name="actionConfiguration">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Configuration</string>
</property>
</action>
<action name="actionVersion">
<property name="text">
<string>&amp;Version</string>
</property>
</action>
<action name="actionAbout">
<property name="text">
<string>&amp;About</string>
</property>
</action>
<action name="actionLoadConfiguration"> <action name="actionLoadConfiguration">
<property name="text"> <property name="text">
<string>Load Configuration</string> <string>Load Configuration</string>
@ -476,6 +385,11 @@ p, li { white-space: pre-wrap; }
<string>Load Trimbits</string> <string>Load Trimbits</string>
</property> </property>
</action> </action>
<action name="actionLoadParameters">
<property name="text">
<string>Load Parameters</string>
</property>
</action>
<action name="actionDebug"> <action name="actionDebug">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
@ -500,12 +414,14 @@ p, li { white-space: pre-wrap; }
<string>Dockable Windows</string> <string>Dockable Windows</string>
</property> </property>
</action> </action>
<action name="actionLoadParameters"> <action name="actionAbout">
<property name="text"> <property name="text">
<string>Load Parameters</string> <string>&amp;About</string>
</property> </property>
</action> </action>
</widget> </widget>
<resources/> <resources>
<include location="../include/icons.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -432,19 +432,6 @@
<property name="verticalSpacing"> <property name="verticalSpacing">
<number>4</number> <number>4</number>
</property> </property>
<item row="5" column="0">
<widget class="QLabel" name="lblNumTriggers">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of Triggers to be expected.&lt;/p&gt;&lt;p&gt; #triggers#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Number of Triggers:</string>
</property>
</widget>
</item>
<item row="4" column="3"> <item row="4" column="3">
<widget class="QComboBox" name="comboPeriodUnit"> <widget class="QComboBox" name="comboPeriodUnit">
<property name="enabled"> <property name="enabled">
@ -666,108 +653,6 @@ Frame period between exposures.
</item> </item>
</widget> </widget>
</item> </item>
<item row="6" column="0">
<widget class="QLabel" name="lblDelay">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>The Delay between Trigger Edge and Start of Exposure ( or Readout).
#delay#</string>
</property>
<property name="text">
<string>Delay After Trigger:</string>
</property>
</widget>
</item>
<item row="5" column="2" colspan="2">
<widget class="QSpinBox" name="spinNumTriggers">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>Number of Triggers to be expected.
#triggers#</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>2000000000</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QDoubleSpinBox" name="spinDelay">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>The Delay between Trigger Edge and Start of Exposure ( or Readout).
#delay#</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="decimals">
<number>9</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>2000000000.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="2"> <item row="3" column="2">
<widget class="QDoubleSpinBox" name="spinExpTime"> <widget class="QDoubleSpinBox" name="spinExpTime">
<property name="enabled"> <property name="enabled">
@ -903,65 +788,6 @@ Exposure Time of a frame.
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="3">
<widget class="QComboBox" name="comboDelayUnit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>The Delay between Trigger Edge and Start of Exposure ( or Readout).
#delay#</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="currentIndex">
<number>2</number>
</property>
<item>
<property name="text">
<string>hr</string>
</property>
</item>
<item>
<property name="text">
<string>min</string>
</property>
</item>
<item>
<property name="text">
<string>s</string>
</property>
</item>
<item>
<property name="text">
<string>ms</string>
</property>
</item>
<item>
<property name="text">
<string>us</string>
</property>
</item>
<item>
<property name="text">
<string>ns</string>
</property>
</item>
</widget>
</item>
<item row="3" column="3"> <item row="3" column="3">
<widget class="QComboBox" name="comboExpUnit"> <widget class="QComboBox" name="comboExpUnit">
<property name="enabled"> <property name="enabled">
@ -1084,6 +910,577 @@ Frame period between exposures.
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="5" column="0">
<widget class="QStackedWidget" name="stackedLblTriggerBurst">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>171</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>171</width>
<height>32</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageLblTrigger">
<layout class="QGridLayout" name="gridLblTrigger">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lblNumTriggers">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of Triggers to be expected.&lt;/p&gt;&lt;p&gt; #triggers#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Number of Triggers:</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageLblBurst">
<layout class="QGridLayout" name="gridLblBurst">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lblNumBursts">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of Triggers to be expected.&lt;/p&gt;&lt;p&gt; #triggers#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Number of Bursts:</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="5" column="2">
<widget class="QStackedWidget" name="stackedSpinTriggerBurst">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>208</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>208</width>
<height>32</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageSpinTrigger">
<layout class="QGridLayout" name="gridSpinTrigger">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QSpinBox" name="spinNumTriggers">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>Number of Triggers to be expected.
#triggers#</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>2000000000</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageSpinBurst">
<layout class="QGridLayout" name="gridSpinBurst">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QSpinBox" name="spinNumBursts">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>Number of Triggers to be expected.
#triggers#</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>2000000000</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="6" column="0">
<widget class="QStackedWidget" name="stackedLblDelayBurstPeriod">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>171</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>171</width>
<height>32</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageLblDelay">
<layout class="QGridLayout" name="gridLblDelay">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lblDelay">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of Triggers to be expected.&lt;/p&gt;&lt;p&gt; #triggers#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Delay After Trigger:</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageLblBurstPeriod">
<layout class="QGridLayout" name="gridLblBurstPeriod">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QLabel" name="lblBurstPeriod">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of Triggers to be expected.&lt;/p&gt;&lt;p&gt; #triggers#&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Burst Period:</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="6" column="2">
<widget class="QStackedWidget" name="stackedSpinDelayBurstPeriod">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>152</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>152</width>
<height>32</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageSpinDelay">
<layout class="QGridLayout" name="gridSpinDelay">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QDoubleSpinBox" name="spinDelay">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>The Delay between Trigger Edge and Start of Exposure ( or Readout).
#delay#</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="decimals">
<number>9</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>2000000000.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageSpinBurstPeriod">
<layout class="QGridLayout" name="gridSpinBurstPeriod">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QDoubleSpinBox" name="spinBurstPeriod">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>The Delay between Trigger Edge and Start of Exposure ( or Readout).
#delay#</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="decimals">
<number>9</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>2000000000.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="6" column="3">
<widget class="QStackedWidget" name="stackedComboDelayBurstPeriod">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>32</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageComboDelay">
<layout class="QGridLayout" name="gridComboDelay">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QComboBox" name="comboDelayUnit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>The Delay between Trigger Edge and Start of Exposure ( or Readout).
#delay#</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="currentIndex">
<number>2</number>
</property>
<item>
<property name="text">
<string>hr</string>
</property>
</item>
<item>
<property name="text">
<string>min</string>
</property>
</item>
<item>
<property name="text">
<string>s</string>
</property>
</item>
<item>
<property name="text">
<string>ms</string>
</property>
</item>
<item>
<property name="text">
<string>us</string>
</property>
</item>
<item>
<property name="text">
<string>ns</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageComboBurstPeriod">
<layout class="QGridLayout" name="gridComboBurstPeriod">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QComboBox" name="comboBurstPeriodUnit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>The Delay between Trigger Edge and Start of Exposure ( or Readout).
#delay#</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="currentIndex">
<number>2</number>
</property>
<item>
<property name="text">
<string>hr</string>
</property>
</item>
<item>
<property name="text">
<string>min</string>
</property>
</item>
<item>
<property name="text">
<string>s</string>
</property>
</item>
<item>
<property name="text">
<string>ms</string>
</property>
</item>
<item>
<property name="text">
<string>us</string>
</property>
</item>
<item>
<property name="text">
<string>ns</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -1116,9 +1513,6 @@ Frame period between exposures.
<tabstop>comboExpUnit</tabstop> <tabstop>comboExpUnit</tabstop>
<tabstop>spinPeriod</tabstop> <tabstop>spinPeriod</tabstop>
<tabstop>comboPeriodUnit</tabstop> <tabstop>comboPeriodUnit</tabstop>
<tabstop>spinNumTriggers</tabstop>
<tabstop>spinDelay</tabstop>
<tabstop>comboDelayUnit</tabstop>
<tabstop>spinNumSamples</tabstop> <tabstop>spinNumSamples</tabstop>
</tabstops> </tabstops>
<resources> <resources>

View File

@ -822,7 +822,7 @@ Displays minimum, maximum and sum of values for each plot.
<item row="0" column="1"> <item row="0" column="1">
<widget class="QStackedWidget" name="stackedWidget1D"> <widget class="QStackedWidget" name="stackedWidget1D">
<property name="currentIndex"> <property name="currentIndex">
<number>3</number> <number>5</number>
</property> </property>
<widget class="QWidget" name="pageSuperImpose"> <widget class="QWidget" name="pageSuperImpose">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
@ -1360,6 +1360,27 @@ Displays minimum, maximum and sum of values for each plot.
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QCheckBox" name="chkGainPlot1D">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Displays minimum, maximum and sum of values for each plot.
&lt;nobr&gt;</string>
</property>
<property name="text">
<string>Gain Plot</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
@ -2347,7 +2368,6 @@ Displays minimum, maximum and sum of values for each plot.
<zorder>box1D</zorder> <zorder>box1D</zorder>
<zorder>boxFrequency</zorder> <zorder>boxFrequency</zorder>
<zorder>box2D</zorder> <zorder>box2D</zorder>
<zorder>horizontalSpacer_6</zorder>
<zorder>boxPlotAxis</zorder> <zorder>boxPlotAxis</zorder>
<zorder>boxSave</zorder> <zorder>boxSave</zorder>
</widget> </widget>

View File

@ -214,6 +214,46 @@
<string>Very Low Gain</string> <string>Very Low Gain</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>G1_HG</string>
</property>
</item>
<item>
<property name="text">
<string>G1_LG</string>
</property>
</item>
<item>
<property name="text">
<string>G2_HC_HG</string>
</property>
</item>
<item>
<property name="text">
<string>G2_HC_LG</string>
</property>
</item>
<item>
<property name="text">
<string>G2_LC_HG</string>
</property>
</item>
<item>
<property name="text">
<string>G2_LC_LG</string>
</property>
</item>
<item>
<property name="text">
<string>G4_HG</string>
</property>
</item>
<item>
<property name="text">
<string>G4_LG</string>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>Undefined</string> <string>Undefined</string>

View File

@ -16,7 +16,7 @@ class qCloneWidget : public QMainWindow, private Ui::ClonePlotObject {
Q_OBJECT Q_OBJECT
public: public:
qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2, SlsQt2DPlot *gp, qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2, SlsQt1DPlot *gp1, SlsQt2DPlot *gp,
QString title, QString filePath, QString fileName, QString title, QString filePath, QString fileName,
int64_t aIndex, bool displayStats, QString min, QString max, int64_t aIndex, bool displayStats, QString min, QString max,
QString sum); QString sum);
@ -37,6 +37,7 @@ class qCloneWidget : public QMainWindow, private Ui::ClonePlotObject {
int id; int id;
SlsQt1DPlot *plot1d{nullptr}; SlsQt1DPlot *plot1d{nullptr};
SlsQt2DPlot *plot2d{nullptr}; SlsQt2DPlot *plot2d{nullptr};
SlsQt1DPlot *gainplot1d{nullptr};
SlsQt2DPlot *gainplot2d{nullptr}; SlsQt2DPlot *gainplot2d{nullptr};
QString filePath{"/"}; QString filePath{"/"};
QString fileName{"run"}; QString fileName{"run"};

View File

@ -31,6 +31,7 @@ class qDefs : public QWidget {
static const int Q_FONT_SIZE=9; static const int Q_FONT_SIZE=9;
static const int DATA_GAIN_PLOT_RATIO=5; static const int DATA_GAIN_PLOT_RATIO=5;
static const int MIN_HEIGHT_GAIN_PLOT_1D=75;
static void DisplayExceptions(std::string emsg, std::string src) { static void DisplayExceptions(std::string emsg, std::string src) {
try { try {

View File

@ -30,8 +30,7 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
Q_OBJECT Q_OBJECT
public: public:
qDetectorMain(int argc, char **argv, QApplication *app, qDetectorMain(int multiId, std::string fname, bool isDevel);
QWidget *parent = 0);
~qDetectorMain(); ~qDetectorMain();
private slots: private slots:

View File

@ -12,7 +12,6 @@ class detectorData;
#include "Detector.h" #include "Detector.h"
class QResizeEvent; class QResizeEvent;
#include <QFutureWatcher>
#include <mutex> #include <mutex>
@ -64,11 +63,11 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
private slots: private slots:
void SetSaveFileName(QString val); void SetSaveFileName(QString val);
void AcquireFinished(); void AcquireThread();
void UpdatePlot(); void UpdatePlot();
signals: signals:
void StartAcquireSignal();
void AcquireFinishedSignal(); void AcquireFinishedSignal();
void AbortSignal(); void AbortSignal();
void UpdateSignal(); void UpdateSignal();
@ -81,7 +80,6 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
void DetachHists(); void DetachHists();
static void GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer); static void GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer);
static void GetDataCallBack(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex, void *this_pointer); static void GetDataCallBack(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex, void *this_pointer);
std::string AcquireThread();
void AcquisitionFinished(double currentProgress, int detectorStatus); void AcquisitionFinished(double currentProgress, int detectorStatus);
void GetData(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex); void GetData(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex);
void toDoublePixelData(double *dest, char *source, int size, int databytes, int dr, double *gaindest = NULL); void toDoublePixelData(double *dest, char *source, int size, int databytes, int dr, double *gaindest = NULL);
@ -98,9 +96,10 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
SlsQt1DPlot *plot1d{nullptr}; SlsQt1DPlot *plot1d{nullptr};
QVector<SlsQtH1D *> hists1d; QVector<SlsQtH1D *> hists1d;
SlsQt1DPlot *gainplot1d{nullptr};
SlsQtH1D * gainhist1d{nullptr};
SlsQt2DPlot *plot2d{nullptr}; SlsQt2DPlot *plot2d{nullptr};
SlsQt2DPlot *gainplot2d{nullptr}; SlsQt2DPlot *gainplot2d{nullptr};
QFutureWatcher<std::string> *acqResultWatcher;
bool is1d{true}; bool is1d{true};
bool isRunning{false}; bool isRunning{false};
@ -124,6 +123,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
int nHists{1}; int nHists{1};
double *datax1d{nullptr}; double *datax1d{nullptr};
std::vector<double *> datay1d; std::vector<double *> datay1d;
double *gainDatay1d{nullptr};
double *data2d{nullptr}; double *data2d{nullptr};
double *gainData{nullptr}; double *gainData{nullptr};
@ -158,7 +158,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
unsigned int nPixelsX{0}; unsigned int nPixelsX{0};
unsigned int nPixelsY{0}; unsigned int nPixelsY{0};
const static int npixelsx_jctb = 400;
int npixelsy_jctb{0};
uint32_t pixelMask{0}; uint32_t pixelMask{0};
uint32_t gainMask{0};
int gainOffset{0};
}; };

View File

@ -26,10 +26,12 @@ private slots:
void SetNumMeasurements(int val); void SetNumMeasurements(int val);
void SetNumFrames(int val); void SetNumFrames(int val);
void SetNumTriggers(int val); void SetNumTriggers(int val);
void SetNumBursts(int val);
void SetNumSamples(int val); void SetNumSamples(int val);
void SetExposureTime(); void SetExposureTime();
void SetAcquisitionPeriod(); void SetAcquisitionPeriod();
void SetDelay(); void SetDelay();
void SetBurstPeriod();
void SetFileWrite(bool val); void SetFileWrite(bool val);
void SetFileName(); void SetFileName();
void SetRunIndex(int val); void SetRunIndex(int val);
@ -41,17 +43,24 @@ private slots:
private: private:
void SetupWidgetWindow(); void SetupWidgetWindow();
void Initialization(); void Initialization();
/** default, show trigger and delay,
* otherwise for gotthard2 in auto timing mode and burst mode,
* show bursts and burst period
*/
void ShowTriggerDelay();
void SetupTimingMode(); void SetupTimingMode();
void EnableWidgetsforTimingMode(); void EnableWidgetsforTimingMode();
void GetTimingMode(); void GetTimingMode();
void GetNumFrames(); void GetNumFrames();
void GetNumTriggers(); void GetNumTriggers();
void GetNumBursts();
void GetNumSamples(); void GetNumSamples();
void GetExposureTime(); void GetExposureTime();
void GetAcquisitionPeriod(); void GetAcquisitionPeriod();
void CheckAcqPeriodGreaterThanExp(); void CheckAcqPeriodGreaterThanExp();
void GetDelay(); void GetDelay();
void GetBurstPeriod();
void GetFileWrite(); void GetFileWrite();
void GetFileName(); void GetFileName();
void GetRunIndex(); void GetRunIndex();

View File

@ -41,6 +41,14 @@ private:
FORCESWITCHG1, FORCESWITCHG1,
FORCESWITCHG2, FORCESWITCHG2,
VERLOWGAIN, VERLOWGAIN,
G1_HIGHGAIN,
G1_LOWGAIN,
G2_HIGHCAP_HIGHGAIN,
G2_HIGHCAP_LOWGAIN,
G2_LOWCAP_HIGHGAIN,
G2_LOWCAP_LOWGAIN,
G4_HIGHGAIN,
G4_LOWGAIN,
UNDEFINED, UNDEFINED,
UNINITIALIZED, UNINITIALIZED,
NUMSETTINGS NUMSETTINGS

View File

@ -77,14 +77,14 @@ class SlsQtH1D:public QwtPlotCurve{
int ndata; int ndata;
int n_array; int n_array;
double dx; double dx;
double *x,*y; double *x{nullptr},*y{nullptr};
double ymin,ymax; double ymin,ymax;
double firstXgt0,firstYgt0; double firstXgt0,firstYgt0;
void Initailize(); void Initailize();
int SetUpArrays(int n); int SetUpArrays(int n);
int CheckIndex(int bx); int CheckIndex(int bx);
QPen* pen_ptr; QPen* pen_ptr{nullptr};
}; };
@ -132,6 +132,7 @@ class SlsQt1DPlot:public QwtPlot{
void DisableZoom(bool disable); void DisableZoom(bool disable);
void EnableXAutoScaling() {setAxisAutoScale(QwtPlot::xBottom, true);Update();}; void EnableXAutoScaling() {setAxisAutoScale(QwtPlot::xBottom, true);Update();};
void EnableYAutoScaling() {setAxisAutoScale(QwtPlot::yLeft, true);Update();}; void EnableYAutoScaling() {setAxisAutoScale(QwtPlot::yLeft, true);Update();};
void SetYStep (int step) {ystep = step;};
void SetXMinMax(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);}; void SetXMinMax(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);};
void SetYMinMax(double min,double max){setAxisScale(QwtPlot::yLeft,min,max);}; void SetYMinMax(double min,double max){setAxisScale(QwtPlot::yLeft,min,max);};
double GetXMinimum(){return hist_list->Hist()->GetXMin();}; double GetXMinimum(){return hist_list->Hist()->GetXMin();};
@ -150,13 +151,14 @@ class SlsQt1DPlot:public QwtPlot{
void SetLogY(bool yes=1); void SetLogY(bool yes=1);
private: private:
SlsQtH1DList* hist_list; SlsQtH1DList* hist_list{nullptr};
SlsQt1DZoomer* zoomer; SlsQt1DZoomer* zoomer{nullptr};
QwtPlotPanner* panner; QwtPlotPanner* panner{nullptr};
QwtPlotMarker *hline; QwtPlotMarker *hline{nullptr};
QwtPlotMarker *vline; QwtPlotMarker *vline{nullptr};
bool disableZoom{false}; bool disableZoom{false};
int ystep{0};
void SetupZoom(); void SetupZoom();
void UnknownStuff(); void UnknownStuff();

View File

@ -26,7 +26,7 @@ class SlsQt2DHist: public QwtRasterData{
double x_width,y_width; double x_width,y_width;
int nx,ny,nb; int nx,ny,nb;
double *data; double *data{nullptr};
double z_min,z_mean,z_max; double z_min,z_mean,z_max;
bool z_mean_has_been_calculated; bool z_mean_has_been_calculated;

View File

@ -20,7 +20,7 @@ class SlsQt2DPlot: public QwtPlot{
public: public:
SlsQt2DPlot(QWidget * = NULL); SlsQt2DPlot(QWidget * = NULL);
~SlsQt2DPlot();
void SetTitle(QString title); void SetTitle(QString title);
void SetXTitle(QString title); void SetXTitle(QString title);
void SetYTitle(QString title); void SetYTitle(QString title);
@ -77,17 +77,17 @@ private:
QwtLinearColorMap* myColourMap(QVector<double> colourStops); QwtLinearColorMap* myColourMap(QVector<double> colourStops);
QwtLinearColorMap* myColourMap(int log=0); QwtLinearColorMap* myColourMap(int log=0);
QwtPlotSpectrogram *d_spectrogram; QwtPlotSpectrogram *d_spectrogram{nullptr};
SlsQt2DHist* hist; SlsQt2DHist* hist{nullptr};
SlsQt2DZoomer* zoomer; SlsQt2DZoomer* zoomer{nullptr};
QwtPlotPanner* panner; QwtPlotPanner* panner{nullptr};
QwtScaleWidget *rightAxis; QwtScaleWidget *rightAxis{nullptr};
QwtLinearColorMap* colorMapLinearScale; QwtLinearColorMap* colorMapLinearScale{nullptr};
QwtLinearColorMap* colorMapLogScale; QwtLinearColorMap* colorMapLogScale{nullptr};
#if QWT_VERSION<0x060000 #if QWT_VERSION<0x060000
QwtValueList* contourLevelsLinear; QwtValueList* contourLevelsLinear{nullptr};
QwtValueList* contourLevelsLog; QwtValueList* contourLevelsLog{nullptr};
#else #else
QList<double> contourLevelsLinear; QList<double> contourLevelsLinear;
QList<double> contourLevelsLog; QList<double> contourLevelsLog;

View File

@ -21,7 +21,7 @@
#define QwtLog10ScaleEngine QwtLogScaleEngine #define QwtLog10ScaleEngine QwtLogScaleEngine
#endif #endif
SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data) : QwtPlotCurve(title) { SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data) : QwtPlotCurve(title), x(nullptr), y(nullptr), pen_ptr(nullptr) {
Initailize(); Initailize();
SetData(n, min, max, data); SetData(n, min, max, data);
} }
@ -33,14 +33,17 @@ SlsQtH1D::SlsQtH1D(QString title, int n, double *data_x, double *data_y) : QwtPl
void SlsQtH1D::Initailize() { void SlsQtH1D::Initailize() {
ndata = n_array = 0; ndata = n_array = 0;
x = y = 0; x = y = nullptr;
pen_ptr = new QPen(); pen_ptr = new QPen();
SetLineColor(); SetLineColor();
} }
SlsQtH1D::~SlsQtH1D() { SlsQtH1D::~SlsQtH1D() {
delete x; if (x)
delete y; delete [] x;
if (y)
delete [] y;
if (pen_ptr)
delete pen_ptr; delete pen_ptr;
} }
@ -358,12 +361,16 @@ SlsQt1DPlot::SlsQt1DPlot(QWidget *parent) : QwtPlot(parent) {
} }
SlsQt1DPlot::~SlsQt1DPlot() { SlsQt1DPlot::~SlsQt1DPlot() {
if (hist_list)
delete hist_list; delete hist_list;
if (hline) if (hline)
delete hline; delete hline;
if (vline) if (vline)
delete vline; delete vline;
if (zoomer)
delete zoomer;
if (panner)
delete panner;
} }
void SlsQt1DPlot::CalculateNResetZoomBase() { void SlsQt1DPlot::CalculateNResetZoomBase() {

View File

@ -52,6 +52,32 @@ SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
} }
SlsQt2DPlot::~SlsQt2DPlot() {
if (d_spectrogram) {
d_spectrogram->detach();
//delete d_spectrogram;
}
if (hist) {
delete hist;
}
if (colorMapLinearScale)
delete colorMapLinearScale;
if (colorMapLogScale)
delete colorMapLogScale;
if (zoomer)
delete zoomer;
if (panner)
delete panner;
#if QWT_VERSION<0x060000
if (contourLevelsLinear)
delete contourLevelsLinear;
if (contourLevelsLog)
delete contourLevelsLog;
#endif
}
void SlsQt2DPlot::SetTitle(QString title) { void SlsQt2DPlot::SetTitle(QString title) {
setTitle(title); setTitle(title);
} }

View File

@ -11,10 +11,10 @@
int qCloneWidget::NumClones{0}; int qCloneWidget::NumClones{0};
qCloneWidget::qCloneWidget(QWidget *parent, SlsQt1DPlot* p1, SlsQt2DPlot* p2, SlsQt2DPlot* gp, qCloneWidget::qCloneWidget(QWidget *parent, SlsQt1DPlot* p1, SlsQt2DPlot* p2, SlsQt1DPlot *gp1, SlsQt2DPlot* gp,
QString title, QString fPath, QString fName, int64_t aIndex, QString title, QString fPath, QString fName, int64_t aIndex,
bool displayStats, QString min, QString max, QString sum): bool displayStats, QString min, QString max, QString sum):
QMainWindow(parent), plot1d(p1), plot2d(p2), gainplot2d(gp), filePath(fPath), fileName(fName), acqIndex(aIndex) { QMainWindow(parent), plot1d(p1), plot2d(p2), gainplot1d(gp1), gainplot2d(gp), filePath(fPath), fileName(fName), acqIndex(aIndex) {
setupUi(this); setupUi(this);
id = qCloneWidget::NumClones++; id = qCloneWidget::NumClones++;
SetupWidgetWindow(title); SetupWidgetWindow(title);
@ -26,6 +26,8 @@ qCloneWidget::~qCloneWidget() {
delete plot1d; delete plot1d;
if (plot2d) if (plot2d)
delete plot2d; delete plot2d;
if (gainplot1d)
delete gainplot1d;
if (gainplot2d) if (gainplot2d)
delete gainplot2d; delete gainplot2d;
} }
@ -40,21 +42,35 @@ void qCloneWidget::SetupWidgetWindow(QString title) {
// 1d // 1d
if (plot1d != nullptr) { if (plot1d != nullptr) {
if (gainplot1d == nullptr) {
plotLayout->addWidget(plot1d); plotLayout->addWidget(plot1d);
} else {
int ratio = qDefs::DATA_GAIN_PLOT_RATIO - 1;
plotLayout->addWidget(plot1d, 0, 0, ratio, ratio);
plotLayout->addWidget(gainplot1d, ratio, 0, 1, ratio, Qt::AlignTop);
}
} }
// 2d // 2d
else { else {
if (gainplot2d == nullptr) { if (gainplot2d == nullptr) {
plotLayout->addWidget(plot2d); plotLayout->addWidget(plot2d);
} else { } else {
gainplot2d->setFixedWidth(plot2d->width() / qDefs::DATA_GAIN_PLOT_RATIO);
gainplot2d->setFixedHeight(plot2d->height() / qDefs::DATA_GAIN_PLOT_RATIO);
int ratio = qDefs::DATA_GAIN_PLOT_RATIO - 1; int ratio = qDefs::DATA_GAIN_PLOT_RATIO - 1;
plotLayout->addWidget(plot2d, 0, 0, ratio, ratio); plotLayout->addWidget(plot2d, 0, 0, ratio, ratio);
plotLayout->addWidget(gainplot2d, 0, ratio, 1, 1, Qt::AlignRight | Qt::AlignTop); plotLayout->addWidget(gainplot2d, 0, ratio, 1, 1, Qt::AlignRight | Qt::AlignTop);
} }
} }
connect(actionSaveClone, SIGNAL(triggered()), this, SLOT(SavePlot())); connect(actionSaveClone, SIGNAL(triggered()), this, SLOT(SavePlot()));
this->show();
if (gainplot1d != nullptr) {
gainplot1d->setMinimumHeight(qDefs::MIN_HEIGHT_GAIN_PLOT_1D);
gainplot1d->setFixedWidth(plot1d->width());
// gainplot1d->setFixedHeight(plot1d->height() / qDefs::DATA_GAIN_PLOT_RATIO - 1);
}
if (gainplot2d != nullptr) {
gainplot2d->setFixedWidth(plot2d->width() / qDefs::DATA_GAIN_PLOT_RATIO);
gainplot2d->setFixedHeight(plot2d->height() / qDefs::DATA_GAIN_PLOT_RATIO);
}
} }
void qCloneWidget::DisplayStats(bool enable, QString min, QString max, QString sum) { void qCloneWidget::DisplayStats(bool enable, QString min, QString max, QString sum) {
@ -92,6 +108,10 @@ void qCloneWidget::SavePlot() {
} }
void qCloneWidget::resizeEvent(QResizeEvent *event) { void qCloneWidget::resizeEvent(QResizeEvent *event) {
if (gainplot1d != nullptr) {
gainplot1d->setFixedWidth(plot1d->width());
gainplot1d->setFixedHeight(plot1d->height() / qDefs::DATA_GAIN_PLOT_RATIO);
}
if (gainplot2d != nullptr) { if (gainplot2d != nullptr) {
gainplot2d->setFixedWidth(plot2d->width() / qDefs::DATA_GAIN_PLOT_RATIO); gainplot2d->setFixedWidth(plot2d->width() / qDefs::DATA_GAIN_PLOT_RATIO);
gainplot2d->setFixedHeight(plot2d->height() / qDefs::DATA_GAIN_PLOT_RATIO); gainplot2d->setFixedHeight(plot2d->height() / qDefs::DATA_GAIN_PLOT_RATIO);

View File

@ -26,27 +26,10 @@
#include <sys/stat.h> #include <sys/stat.h>
int main(int argc, char **argv) { int main(int argc, char **argv) {
QApplication *theApp = new QApplication(argc, argv);
theApp->setStyle(new QPlastiqueStyle);
theApp->setWindowIcon(QIcon(":/icons/images/mountain.png"));
try {
qDetectorMain *det = new qDetectorMain(argc, argv, theApp, 0);
det->show();
theApp->exec();
} catch (const std::exception &e) {
qDefs::Message(qDefs::CRITICAL,
std::string(e.what()) + "\nExiting Gui :'( ", "main");
}
return 0;
}
qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app,
QWidget *parent)
: QMainWindow(parent), detType(slsDetectorDefs::GENERIC), isDeveloper(0),
heightPlotWindow(0), heightCentralWidget(0) {
// options // options
std::string fname = ""; std::string fname = "";
bool isDeveloper = false;
int64_t tempval = 0; int64_t tempval = 0;
int multiId = 0; int multiId = 0;
@ -81,7 +64,7 @@ qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app,
break; break;
case 'd': case 'd':
isDeveloper = 1; isDeveloper = true;
break; break;
case 'i': case 'i':
@ -92,7 +75,7 @@ qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app,
tempval = APIGUI; tempval = APIGUI;
FILE_LOG(logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x" FILE_LOG(logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x"
<< std::hex << tempval << ")"; << std::hex << tempval << ")";
return; return 0;
case 'h': case 'h':
default: default:
@ -107,10 +90,29 @@ qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app,
"\t only when more than one multi " "\t only when more than one multi "
"detector object is needed.\n\n"; "detector object is needed.\n\n";
FILE_LOG(logERROR) << help_message; FILE_LOG(logERROR) << help_message;
exit(EXIT_FAILURE); return -1;
} }
} }
QApplication app(argc, argv);
app.setStyle(new QPlastiqueStyle);
//app.setWindowIcon(QIcon(":/icons/images/mountain.png"));
try {
qDetectorMain det(multiId, fname, isDeveloper);
det.show();
app.exec();
} catch (const std::exception &e) {
qDefs::Message(qDefs::CRITICAL,
std::string(e.what()) + "\nExiting Gui :'( ", "main");
}
return 0;
}
qDetectorMain::qDetectorMain(int multiId, std::string fname, bool isDevel)
: QMainWindow(0), detType(slsDetectorDefs::GENERIC), isDeveloper(isDevel),
heightPlotWindow(0), heightCentralWidget(0) {
setupUi(this); setupUi(this);
SetUpDetector(fname, multiId); SetUpDetector(fname, multiId);
SetUpWidgetWindow(); SetUpWidgetWindow();
@ -429,8 +431,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
void qDetectorMain::ExecuteHelp(QAction *action) { void qDetectorMain::ExecuteHelp(QAction *action) {
if (action == actionAbout) { if (action == actionAbout) {
FILE_LOG(logINFO) << "About Common GUI for Eiger, Gotthard, Jungfrau " FILE_LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, Gotthard, Gotthard2 and Moench detectors";
"and Moench detectors";
std::string guiVersion = std::to_string(APIGUI); std::string guiVersion = std::to_string(APIGUI);
std::string clientVersion = "unknown"; std::string clientVersion = "unknown";
@ -447,7 +448,7 @@ void qDetectorMain::ExecuteHelp(QAction *action) {
clientVersion + clientVersion +
"<br><br>" "<br><br>"
"Common GUI to control the SLS Detectors: " "Common GUI to control the SLS Detectors: "
"Eiger, Jungfrau, Mythen3, Gotthard, Gotthard2 and Moench.<br><br>" "Jungfrau, Eiger, Mythen3, Gotthard, Gotthard2 and Moench.<br><br>"
"It can be operated in parallel with the command " "It can be operated in parallel with the command "
"line interface:<br>" "line interface:<br>"
"sls_detector_put,<br>sls_detector_get,<br>sls_" "sls_detector_put,<br>sls_detector_get,<br>sls_"

View File

@ -13,7 +13,6 @@
#include <QtConcurrentRun> #include <QtConcurrentRun>
#include <QResizeEvent> #include <QResizeEvent>
qDrawPlot::qDrawPlot(QWidget *parent, sls::Detector *detector) : QWidget(parent), det(detector) { qDrawPlot::qDrawPlot(QWidget *parent, sls::Detector *detector) : QWidget(parent), det(detector) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
@ -32,6 +31,8 @@ qDrawPlot::~qDrawPlot() {
delete [] datax1d; delete [] datax1d;
for (auto &it : datay1d) for (auto &it : datay1d)
delete [] it; delete [] it;
if (gainDatay1d)
delete [] gainDatay1d;
if (data2d) if (data2d)
delete [] data2d; delete [] data2d;
if (gainData) if (gainData)
@ -39,6 +40,10 @@ qDrawPlot::~qDrawPlot() {
if (plot1d) if (plot1d)
delete plot1d; delete plot1d;
if (gainhist1d)
delete gainhist1d;
if (gainplot1d)
delete gainplot1d;
if (plot2d) if (plot2d)
delete plot2d; delete plot2d;
if (gainplot2d) if (gainplot2d)
@ -54,13 +59,18 @@ void qDrawPlot::SetupWidgetWindow() {
detType = det->getDetectorType().squash(); detType = det->getDetectorType().squash();
switch (detType) { switch (detType) {
case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::MOENCH: pixelMask = ((1 << 14) - 1);
pixelMask = ((1 << 15) - 1); gainMask = (3 << 14);
FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask << std::dec; gainOffset = 14;
FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask
<< ", Gain Mask:" << gainMask << ", Gain Offset:" << std::dec << gainOffset;
break; break;
case slsDetectorDefs::GOTTHARD2: case slsDetectorDefs::GOTTHARD2:
pixelMask = ((1 << 13) - 1); pixelMask = ((1 << 12) - 1);
FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask << std::dec; gainMask = (3 << 12);
gainOffset = 12;
FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask
<< ", Gain Mask:" << gainMask << ", Gain Offset:" << std::dec << gainOffset;
break; break;
default: default:
break; break;
@ -80,15 +90,12 @@ void qDrawPlot::SetupWidgetWindow() {
SetupPlots(); SetupPlots();
SetDataCallBack(true); SetDataCallBack(true);
det->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack), this); det->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack), this);
// future watcher to watch result of AcquireThread only because it uses signals/slots to handle acquire exception
acqResultWatcher = new QFutureWatcher<std::string>();
Initialization(); Initialization();
} }
void qDrawPlot::Initialization() { void qDrawPlot::Initialization() {
connect(this, SIGNAL(UpdateSignal()), this, SLOT(UpdatePlot())); connect(this, SIGNAL(UpdateSignal()), this, SLOT(UpdatePlot()));
connect(acqResultWatcher, SIGNAL(finished()), this, SLOT(AcquireFinished())); connect(this, SIGNAL(StartAcquireSignal()), this, SLOT(AcquireThread()));
} }
void qDrawPlot::SetupPlots() { void qDrawPlot::SetupPlots() {
@ -99,13 +106,6 @@ void qDrawPlot::SetupPlots() {
nPixelsX = res.x; nPixelsX = res.x;
nPixelsY = res.y; nPixelsY = res.y;
switch(detType) { switch(detType) {
case slsDetectorDefs::MOENCH:
try{
npixelsy_jctb = (det->getNumberOfAnalogSamples().tsquash("Inconsistent values for number of analog samples") * 2)/25;// for moench 03
nPixelsX = npixelsx_jctb;
nPixelsY = npixelsy_jctb;
} CATCH_DISPLAY ("Could not get number of analog samples.", "qDrawPlot::SetupPlots")
break;
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
try{ try{
if (det->getQuad().tsquash("Inconsistent values for quad type")) { if (det->getQuad().tsquash("Inconsistent values for quad type")) {
@ -154,12 +154,40 @@ void qDrawPlot::SetupPlots() {
plot1d->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); plot1d->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
plot1d->SetXFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); plot1d->SetXFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
plot1d->SetYFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); plot1d->SetYFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
plot1d->SetTitle("--"); plot1d->SetTitle("");
plot1d->SetXTitle(xTitle1d); plot1d->SetXTitle(xTitle1d);
plot1d->SetYTitle(yTitle1d); plot1d->SetYTitle(yTitle1d);
h->Attach(plot1d); h->Attach(plot1d);
plot1d->hide(); plot1d->hide();
if (gainDatay1d)
delete[] gainDatay1d;
gainDatay1d = new double[nPixelsX];
// default display data
for (unsigned int px = 0; px < nPixelsX; ++px) {
gainDatay1d[px] = 0;
}
// set gain hist
gainhist1d = new SlsQtH1D("", nPixelsX, datax1d, gainDatay1d);
gainhist1d->SetLineColor(0);
gainhist1d->setStyleLinesorDots(isLines);
gainhist1d->setSymbolMarkers(isMarkers);
// setup 1d gain plot
gainplot1d = new SlsQt1DPlot(boxPlot);
gainplot1d->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
gainplot1d->SetYFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
gainplot1d->SetTitle("");
gainplot1d->SetYTitle("Gain");
// set ticks to just 3
QList<double> majorTicks({0, 1, 2, 3});
QwtScaleDiv div( 0, 3, QList<double>(), QList<double>(), majorTicks);
gainplot1d->setAxisScaleDiv( QwtPlot::yLeft, div);
//gainplot1d->axisScaleDraw(QwtPlot::xBottom)->enableComponent(QwtScaleDraw::Ticks, false);
//gainplot1d->axisScaleDraw(QwtPlot::yLeft)->enableComponent(QwtScaleDraw::Labels, false);
gainhist1d->setItemAttribute(QwtPlotItem::Legend, false);
gainhist1d->Attach(gainplot1d);
gainplot1d->hide();
// setup 2d data // setup 2d data
if (data2d) if (data2d)
delete [] data2d; delete [] data2d;
@ -197,17 +225,21 @@ void qDrawPlot::SetupPlots() {
gainplot2d = new SlsQt2DPlot(boxPlot); gainplot2d = new SlsQt2DPlot(boxPlot);
gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5, nPixelsY - 0.5, gainData); gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5, nPixelsY - 0.5, gainData);
gainplot2d->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); gainplot2d->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
gainplot2d->setTitle(""); gainplot2d->setTitle("Gain");
gainplot2d->enableAxis(0, false); gainplot2d->SetZTitle("");
gainplot2d->enableAxis(1, false); gainplot2d->enableAxis(QwtPlot::yLeft, false);
gainplot2d->enableAxis(2, false); //gainplot2d->enableAxis(1, false);
gainplot2d->enableAxis(QwtPlot::xBottom, false);
// set ticks to just 3
gainplot2d->setAxisScaleDiv( QwtPlot::yRight, div);
gainplot2d->hide(); gainplot2d->hide();
// layout of plots // layout of plots
int ratio = qDefs::DATA_GAIN_PLOT_RATIO - 1; int ratio = qDefs::DATA_GAIN_PLOT_RATIO - 1;
plotLayout->addWidget(plot1d, 0, 0, ratio, ratio); plotLayout->addWidget(plot1d, 0, 0, ratio, ratio);
plotLayout->addWidget(plot2d, 0, 0, ratio, ratio); plotLayout->addWidget(plot2d, 0, 0, ratio, ratio);
plotLayout->addWidget(gainplot1d, ratio, 0, 1, ratio, Qt::AlignTop);
plotLayout->addWidget(gainplot2d, 0, ratio, 1, 1, Qt::AlignRight | Qt::AlignTop); plotLayout->addWidget(gainplot2d, 0, ratio, 1, 1, Qt::AlignRight | Qt::AlignTop);
} }
@ -216,6 +248,10 @@ void qDrawPlot::resizeEvent(QResizeEvent *event) {
gainplot2d->setFixedWidth(plot2d->width() / qDefs::DATA_GAIN_PLOT_RATIO); gainplot2d->setFixedWidth(plot2d->width() / qDefs::DATA_GAIN_PLOT_RATIO);
gainplot2d->setFixedHeight(plot2d->height() / qDefs::DATA_GAIN_PLOT_RATIO); gainplot2d->setFixedHeight(plot2d->height() / qDefs::DATA_GAIN_PLOT_RATIO);
} }
if (gainplot1d->isVisible()) {
gainplot1d->setFixedWidth(plot1d->width());
gainplot1d->setFixedHeight(plot1d->height() / qDefs::DATA_GAIN_PLOT_RATIO);
}
event->accept(); event->accept();
} }
@ -447,6 +483,7 @@ void qDrawPlot::ClonePlot() {
SlsQt1DPlot* cloneplot1D = nullptr; SlsQt1DPlot* cloneplot1D = nullptr;
SlsQt2DPlot* cloneplot2D = nullptr; SlsQt2DPlot* cloneplot2D = nullptr;
SlsQt1DPlot* clonegainplot1D = nullptr;
SlsQt2DPlot* clonegainplot2D = nullptr; SlsQt2DPlot* clonegainplot2D = nullptr;
if (is1d) { if (is1d) {
@ -468,6 +505,24 @@ void qDrawPlot::ClonePlot() {
cloneplotHists1D.append(h); cloneplotHists1D.append(h);
h->Attach(cloneplot1D); h->Attach(cloneplot1D);
} }
if (isGainDataExtracted) {
SlsQtH1D *h = new SlsQtH1D("", nPixelsX, datax1d, gainDatay1d);
h->SetLineColor(0);
h->setStyleLinesorDots(isLines);
h->setSymbolMarkers(isMarkers);
h->setItemAttribute(QwtPlotItem::Legend, false);
clonegainplot1D = new SlsQt1DPlot();
clonegainplot1D->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
clonegainplot1D->SetYFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
clonegainplot1D->SetTitle("");
clonegainplot1D->SetYTitle("Gain");
// set ticks to just 3
QList<double> majorTicks({0, 1, 2, 3});
QwtScaleDiv div( 0, 3, QList<double>(), QList<double>(), majorTicks);
clonegainplot1D->setAxisScaleDiv( QwtPlot::yLeft, div);
h->Attach(clonegainplot1D);
}
} else { } else {
FILE_LOG(logDEBUG) << "Cloning 2D Image"; FILE_LOG(logDEBUG) << "Cloning 2D Image";
cloneplot2D = new SlsQt2DPlot(); cloneplot2D = new SlsQt2DPlot();
@ -485,19 +540,26 @@ void qDrawPlot::ClonePlot() {
if (isGainDataExtracted) { if (isGainDataExtracted) {
clonegainplot2D = new SlsQt2DPlot(); clonegainplot2D = new SlsQt2DPlot();
clonegainplot2D->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); clonegainplot2D->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
clonegainplot2D->SetTitle("Gain");
clonegainplot2D->SetZTitle("");
clonegainplot2D->enableAxis(QwtPlot::yLeft, false);
clonegainplot2D->enableAxis(QwtPlot::xBottom, false);
// set ticks to just 3
QList<double> majorTicks({0, 1, 2, 3});
QwtScaleDiv div( 0, 3, QList<double>(), QList<double>(), majorTicks);
clonegainplot2D->setAxisScaleDiv( QwtPlot::yRight, div);
clonegainplot2D->enableAxis(0, false); clonegainplot2D->enableAxis(0, false);
clonegainplot2D->enableAxis(1, false); clonegainplot2D->enableAxis(1, false);
clonegainplot2D->enableAxis(2, false); clonegainplot2D->enableAxis(2, false);
clonegainplot2D->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5, nPixelsY - 0.5, gainData); clonegainplot2D->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5, nPixelsY - 0.5, gainData);
clonegainplot2D->SetTitle("");
} }
} }
qCloneWidget* q = new qCloneWidget(this, cloneplot1D, cloneplot2D, clonegainplot2D, new qCloneWidget(this, cloneplot1D, cloneplot2D, clonegainplot1D,
boxPlot->title(), fileSavePath, fileSaveName, currentAcqIndex, clonegainplot2D, boxPlot->title(), fileSavePath, fileSaveName, currentAcqIndex,
displayStatistics, lblMinDisp->text(), lblMaxDisp->text(), lblSumDisp->text()); displayStatistics, lblMinDisp->text(), lblMaxDisp->text(), lblSumDisp->text());
q->show();
} }
void qDrawPlot::SavePlot() { void qDrawPlot::SavePlot() {
@ -547,6 +609,9 @@ void qDrawPlot::DetachHists() {
for (QVector<SlsQtH1D *>::iterator h = hists1d.begin(); h != hists1d.end(); ++h) { for (QVector<SlsQtH1D *>::iterator h = hists1d.begin(); h != hists1d.end(); ++h) {
(*h)->Detach(plot1d); (*h)->Detach(plot1d);
} }
if (gainhist1d) {
gainhist1d->Detach(gainplot1d);
}
} }
void qDrawPlot::StartAcquisition() { void qDrawPlot::StartAcquisition() {
@ -571,16 +636,19 @@ void qDrawPlot::StartAcquisition() {
xyRangeChanged = true; xyRangeChanged = true;
} }
// acquisition in another thread emit StartAcquireSignal();
QFuture<std::string> future = QtConcurrent::run(this, &qDrawPlot::AcquireThread);
acqResultWatcher->setFuture(future);
FILE_LOG(logDEBUG) << "End of Starting Acquisition in qDrawPlot"; FILE_LOG(logDEBUG) << "End of Starting Acquisition in qDrawPlot";
} }
void qDrawPlot::AcquireFinished() { void qDrawPlot::AcquireThread() {
FILE_LOG(logDEBUG) << "Acquisition Finished"; FILE_LOG(logDEBUG) << "Acquire Thread";
std::string mess = acqResultWatcher->result(); std::string mess;
try {
det->acquire();
} catch (const std::exception &e) {
mess = std::string(e.what());
}
FILE_LOG(logINFO) << "Acquisition Finished";
// exception in acquire will not call acquisition finished call back, so handle it // exception in acquire will not call acquisition finished call back, so handle it
if (!mess.empty()) { if (!mess.empty()) {
FILE_LOG(logERROR) << "Acquisition Finished with an exception: " << mess; FILE_LOG(logERROR) << "Acquisition Finished with an exception: " << mess;
@ -596,16 +664,6 @@ void qDrawPlot::AcquireFinished() {
FILE_LOG(logDEBUG) << "End of Acquisition Finished"; FILE_LOG(logDEBUG) << "End of Acquisition Finished";
} }
std::string qDrawPlot::AcquireThread() {
FILE_LOG(logDEBUG) << "Acquire Thread";
try {
det->acquire();
} catch (const std::exception &e) {
return std::string(e.what());
}
return std::string("");
}
void qDrawPlot::GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer) { void qDrawPlot::GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer) {
((qDrawPlot *)this_pointer)->AcquisitionFinished(currentProgress, detectorStatus); ((qDrawPlot *)this_pointer)->AcquisitionFinished(currentProgress, detectorStatus);
FILE_LOG(logDEBUG) << "Acquisition Finished Call back successful"; FILE_LOG(logDEBUG) << "Acquisition Finished Call back successful";
@ -666,7 +724,8 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFra
unsigned int nPixels = nPixelsX * (is1d ? 1 : nPixelsY); unsigned int nPixels = nPixelsX * (is1d ? 1 : nPixelsY);
double* rawData = new double[nPixels]; double* rawData = new double[nPixels];
if (hasGainData) { if (hasGainData) {
toDoublePixelData(rawData, data->data, nPixels, data->databytes, data->dynamicRange, gainData); toDoublePixelData(rawData, data->data, nPixels, data->databytes, data->dynamicRange,
is1d ? gainDatay1d : gainData);
isGainDataExtracted = true; isGainDataExtracted = true;
} else { } else {
toDoublePixelData(rawData, data->data, nPixels, data->databytes, data->dynamicRange); toDoublePixelData(rawData, data->data, nPixels, data->databytes, data->dynamicRange);
@ -716,6 +775,7 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFra
} else { } else {
Get2dData(rawData); Get2dData(rawData);
} }
delete [] rawData;
FILE_LOG(logDEBUG) << "End of Get Data"; FILE_LOG(logDEBUG) << "End of Get Data";
emit UpdateSignal(); emit UpdateSignal();
@ -819,6 +879,20 @@ void qDrawPlot::Update1dPlot() {
h->Attach(plot1d); h->Attach(plot1d);
} }
} }
if (isGainDataExtracted) {
gainhist1d->SetData(nPixelsX, datax1d, gainDatay1d);
gainhist1d->SetLineColor(0);
gainhist1d->setStyleLinesorDots(isLines);
gainhist1d->setSymbolMarkers(isMarkers);
gainhist1d->Attach(gainplot1d);
if (!gainplot1d->isVisible()) {
gainplot1d->setFixedWidth(plot1d->width() );
gainplot1d->setFixedHeight(plot1d->height() / qDefs::DATA_GAIN_PLOT_RATIO);
gainplot1d->show();
}
} else if (gainplot1d->isVisible()) {
gainplot1d->hide();
}
if (xyRangeChanged) { if (xyRangeChanged) {
Update1dXYRange(); Update1dXYRange();
xyRangeChanged = false; xyRangeChanged = false;
@ -918,14 +992,13 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, int data
case 16: case 16:
if (detType == slsDetectorDefs::JUNGFRAU || if (detType == slsDetectorDefs::JUNGFRAU ||
detType == slsDetectorDefs::MOENCH ||
detType == slsDetectorDefs::GOTTHARD2) { detType == slsDetectorDefs::GOTTHARD2) {
// show gain plot // show gain plot
if (gaindest != NULL) { if (gaindest != NULL) {
for (ichan = 0; ichan < size; ++ichan) { for (ichan = 0; ichan < size; ++ichan) {
uint16_t temp = (*((u_int16_t *)source)); uint16_t temp = (*((u_int16_t *)source));
gaindest[ichan] = ((temp & 0xC000) >> 14); gaindest[ichan] = ((temp & gainMask) >> gainOffset);
dest[ichan] = (temp & pixelMask); dest[ichan] = (temp & pixelMask);
source += 2; source += 2;
} }

View File

@ -82,14 +82,14 @@ void qTabDeveloper::SetupWidgetWindow() {
case slsDetectorDefs::MOENCH: case slsDetectorDefs::MOENCH:
lblSpinHV->show(); lblSpinHV->show();
spinHV->show(); spinHV->show();
dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 0: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(this, det, true, "vbp_colbuf: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 1: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(this, det, true, "vipre: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 2: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(this, det, true, "vin_cm: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 3: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(this, det, true, "vb_sda: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 4: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(this, det, true, "vcasc_sfp: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 5: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(this, det, true, "vout_cm: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 6: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(this, det, true, "vipre_cds: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "i Dac 7: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(this, det, true, "ibias_sfp: ", getSLSIndex(detType, tempid++)));
break; break;
case slsDetectorDefs::MYTHEN3: case slsDetectorDefs::MYTHEN3:
@ -343,10 +343,27 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorTy
break; break;
case slsDetectorDefs::MOENCH: case slsDetectorDefs::MOENCH:
if (index >= 0 && index < (int)dacWidgets.size()) { switch (index) {
return (slsDetectorDefs::dacIndex)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 sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index)); throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index));
}
break;
case slsDetectorDefs::MYTHEN3: case slsDetectorDefs::MYTHEN3:
switch (index) { switch (index) {

View File

@ -42,6 +42,10 @@ void qTabMeasurement::SetupWidgetWindow() {
lblDelay->setEnabled(true); lblDelay->setEnabled(true);
spinDelay->setEnabled(true); spinDelay->setEnabled(true);
comboDelayUnit->setEnabled(true); comboDelayUnit->setEnabled(true);
// default is triggers and delay (not #bursts and burst period for gotthard2 in auto mode)
ShowTriggerDelay();
// enabling according to det type // enabling according to det type
switch(det->getDetectorType().squash()) { switch(det->getDetectorType().squash()) {
case slsDetectorDefs::MOENCH: case slsDetectorDefs::MOENCH:
@ -60,6 +64,13 @@ void qTabMeasurement::SetupWidgetWindow() {
spinStartingFrameNumber->setEnabled(true); spinStartingFrameNumber->setEnabled(true);
startingFnumImplemented = true; startingFnumImplemented = true;
break; break;
case slsDetectorDefs::GOTTHARD2:
lblNumBursts->setEnabled(true);
spinNumBursts->setEnabled(true);
lblBurstPeriod->setEnabled(true);
spinBurstPeriod->setEnabled(true);
comboBurstPeriodUnit->setEnabled(true);
break;
default: default:
break; break;
} }
@ -78,6 +89,9 @@ void qTabMeasurement::Initialization() {
connect(spinNumMeasurements, SIGNAL(valueChanged(int)), this, SLOT(SetNumMeasurements(int))); connect(spinNumMeasurements, SIGNAL(valueChanged(int)), this, SLOT(SetNumMeasurements(int)));
connect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(SetNumFrames(int))); connect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(SetNumFrames(int)));
connect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(SetNumTriggers(int))); connect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(SetNumTriggers(int)));
if (spinNumBursts->isEnabled()) {
connect(spinNumBursts, SIGNAL(valueChanged(int)), this, SLOT(SetNumBursts(int)));
}
if (spinNumSamples->isEnabled()) { if (spinNumSamples->isEnabled()) {
connect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(SetNumSamples(int))); connect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(SetNumSamples(int)));
} }
@ -89,6 +103,10 @@ void qTabMeasurement::Initialization() {
connect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(SetDelay())); connect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(SetDelay()));
connect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDelay())); connect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDelay()));
} }
if (spinBurstPeriod->isEnabled()) {
connect(spinBurstPeriod, SIGNAL(valueChanged(double)), this, SLOT(SetBurstPeriod()));
connect(comboBurstPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetBurstPeriod()));
}
connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool))); connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool)));
connect(dispFileName, SIGNAL(editingFinished()), this, SLOT(SetFileName())); connect(dispFileName, SIGNAL(editingFinished()), this, SLOT(SetFileName()));
connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(SetRunIndex(int))); connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(SetRunIndex(int)));
@ -101,6 +119,35 @@ void qTabMeasurement::Initialization() {
} }
void qTabMeasurement::ShowTriggerDelay() {
bool showTrigger = true;
if (det->getDetectorType().squash() == slsDetectorDefs::GOTTHARD2) {
try {
FILE_LOG(logDEBUG) << "Getting burst mode";
auto retval = det->getBurstMode().tsquash("Inconsistent burst mode for all detectors.");
// burst mode and auto timing mode
if (retval != slsDetectorDefs::BURST_OFF && comboTimingMode->currentIndex() == AUTO) {
showTrigger = false;
}
} CATCH_DISPLAY ("Could not get burst mode.", "qTabMeasurement::ShowTriggerDelay")
}
if (showTrigger) {
stackedLblTriggerBurst->setCurrentWidget(pageLblTrigger);
stackedSpinTriggerBurst->setCurrentWidget(pageSpinTrigger);
stackedLblDelayBurstPeriod->setCurrentWidget(pageLblDelay);
stackedSpinDelayBurstPeriod->setCurrentWidget(pageSpinDelay);
stackedComboDelayBurstPeriod->setCurrentWidget(pageComboDelay);
} else {
stackedLblTriggerBurst->setCurrentWidget(pageLblBurst);
stackedSpinTriggerBurst->setCurrentWidget(pageSpinBurst);
stackedLblDelayBurstPeriod->setCurrentWidget(pageLblBurstPeriod);
stackedSpinDelayBurstPeriod->setCurrentWidget(pageSpinBurstPeriod);
stackedComboDelayBurstPeriod->setCurrentWidget(pageComboBurstPeriod);
}
}
void qTabMeasurement::SetupTimingMode() { void qTabMeasurement::SetupTimingMode() {
QStandardItemModel* model = qobject_cast<QStandardItemModel *>(comboTimingMode->model()); QStandardItemModel* model = qobject_cast<QStandardItemModel *>(comboTimingMode->model());
QModelIndex index[NUMTIMINGMODES]; QModelIndex index[NUMTIMINGMODES];
@ -139,7 +186,9 @@ void qTabMeasurement::EnableWidgetsforTimingMode() {
switch(comboTimingMode->currentIndex()) { switch(comboTimingMode->currentIndex()) {
case AUTO: case AUTO:
// #frames, exptime, period // #frames, exptime, period
if (det->getDetectorType().squash() != slsDetectorDefs::GOTTHARD2) {
spinNumTriggers->setValue(1); spinNumTriggers->setValue(1);
}
lblNumFrames->setEnabled(true); lblNumFrames->setEnabled(true);
spinNumFrames->setEnabled(true); spinNumFrames->setEnabled(true);
lblExpTime->setEnabled(true); lblExpTime->setEnabled(true);
@ -148,6 +197,9 @@ void qTabMeasurement::EnableWidgetsforTimingMode() {
lblPeriod->setEnabled(true); lblPeriod->setEnabled(true);
spinPeriod->setEnabled(true); spinPeriod->setEnabled(true);
comboPeriodUnit->setEnabled(true); comboPeriodUnit->setEnabled(true);
if (det->getDetectorType().squash() == slsDetectorDefs::GOTTHARD2) {
ShowTriggerDelay();
}
break; break;
case TRIGGER: case TRIGGER:
// #triggers, exptime // #triggers, exptime
@ -168,6 +220,9 @@ void qTabMeasurement::EnableWidgetsforTimingMode() {
lblDelay->setEnabled(true); lblDelay->setEnabled(true);
spinDelay->setEnabled(true); spinDelay->setEnabled(true);
comboDelayUnit->setEnabled(true); comboDelayUnit->setEnabled(true);
if (det->getDetectorType().squash() == slsDetectorDefs::GOTTHARD2) {
ShowTriggerDelay();
}
} }
break; break;
case GATED: case GATED:
@ -197,7 +252,7 @@ void qTabMeasurement::EnableWidgetsforTimingMode() {
void qTabMeasurement::GetTimingMode() { void qTabMeasurement::GetTimingMode() {
FILE_LOG(logDEBUG) << "Getting timing mode"; FILE_LOG(logDEBUG) << "Getting timing mode";
connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int))); disconnect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int)));
try { try {
auto oldMode = comboTimingMode->currentIndex(); auto oldMode = comboTimingMode->currentIndex();
auto retval = det->getTimingMode().tsquash("Inconsistent timing mode for all detectors."); auto retval = det->getTimingMode().tsquash("Inconsistent timing mode for all detectors.");
@ -216,7 +271,7 @@ void qTabMeasurement::GetTimingMode() {
throw sls::RuntimeError(std::string("Unknown timing mode: ")+ std::to_string(retval)); throw sls::RuntimeError(std::string("Unknown timing mode: ")+ std::to_string(retval));
} }
} CATCH_DISPLAY("Could not get timing mode.", "qTabMeasurement::GetTimingMode") } CATCH_DISPLAY("Could not get timing mode.", "qTabMeasurement::GetTimingMode")
disconnect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int))); connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int)));
} }
void qTabMeasurement::SetTimingMode(int val) { void qTabMeasurement::SetTimingMode(int val) {
@ -266,6 +321,23 @@ void qTabMeasurement::SetNumTriggers(int val) {
} CATCH_HANDLE("Could not set number of triggers.", "qTabMeasurement::SetNumTriggers", this, &qTabMeasurement::GetNumTriggers) } CATCH_HANDLE("Could not set number of triggers.", "qTabMeasurement::SetNumTriggers", this, &qTabMeasurement::GetNumTriggers)
} }
void qTabMeasurement::GetNumBursts() {
FILE_LOG(logDEBUG) << "Getting number of bursts";
disconnect(spinNumBursts, SIGNAL(valueChanged(int)), this, SLOT(SetNumBursts(int)));
try {
auto retval = det->getNumberOfBursts().tsquash("Inconsistent number of bursts for all detectors.");
spinNumBursts->setValue(retval);
} CATCH_DISPLAY ("Could not get number of frames.", "qTabMeasurement::GetNumBursts")
connect(spinNumBursts, SIGNAL(valueChanged(int)), this, SLOT(SetNumBursts(int)));
}
void qTabMeasurement::SetNumBursts(int val) {
FILE_LOG(logINFO) << "Setting number of bursts to " << val;
try {
det->setNumberOfBursts(val);
} CATCH_HANDLE("Could not set number of bursts.", "qTabMeasurement::SetNumBursts", this, &qTabMeasurement::GetNumBursts)
}
void qTabMeasurement::GetNumSamples() { void qTabMeasurement::GetNumSamples() {
FILE_LOG(logDEBUG) << "Getting number of samples"; FILE_LOG(logDEBUG) << "Getting number of samples";
disconnect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(SetNumSamples(int))); disconnect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(SetNumSamples(int)));
@ -385,6 +457,32 @@ void qTabMeasurement::SetDelay() {
} CATCH_HANDLE("Could not set delay.", "qTabMeasurement::SetDelay", this, &qTabMeasurement::GetDelay) } CATCH_HANDLE("Could not set delay.", "qTabMeasurement::SetDelay", this, &qTabMeasurement::GetDelay)
} }
void qTabMeasurement::GetBurstPeriod() {
FILE_LOG(logDEBUG) << "Getting Burst Period";
disconnect(spinBurstPeriod, SIGNAL(valueChanged(double)), this, SLOT(SetBurstPeriod()));
disconnect(comboBurstPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetBurstPeriod()));
try {
spinBurstPeriod->setValue(-1);
auto retval = det->getBurstPeriod().tsquash("Inconsistent burst period for all detectors.");
auto time = qDefs::getUserFriendlyTime(retval);
spinBurstPeriod->setValue(time.first);
comboBurstPeriodUnit->setCurrentIndex(static_cast<int>(time.second));
} CATCH_DISPLAY ("Could not get burst period.", "qTabMeasurement::GetBurstPeriod")
connect(spinBurstPeriod, SIGNAL(valueChanged(double)), this, SLOT(SetBurstPeriod()));
connect(comboBurstPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetBurstPeriod()));
}
void qTabMeasurement::SetBurstPeriod() {
auto val = spinBurstPeriod->value();
auto unit = static_cast<qDefs::timeUnit>(comboBurstPeriodUnit->currentIndex());
FILE_LOG(logINFO) << "Setting burst period to " << val << " " << qDefs::getUnitString(unit);
try {
auto timeNS = qDefs::getNSTime(std::make_pair(val, unit));
det->setBurstPeriod(timeNS);
} CATCH_HANDLE("Could not set burst period.", "qTabMeasurement::SetBurstPeriod", this, &qTabMeasurement::GetBurstPeriod)
}
void qTabMeasurement::GetFileWrite() { void qTabMeasurement::GetFileWrite() {
FILE_LOG(logDEBUG) << "Getting File Write Enable"; FILE_LOG(logDEBUG) << "Getting File Write Enable";
disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool))); disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool)));
@ -577,9 +675,15 @@ void qTabMeasurement::Refresh() {
GetExposureTime(); GetExposureTime();
GetAcquisitionPeriod(); GetAcquisitionPeriod();
GetNumTriggers(); GetNumTriggers();
if (spinNumBursts->isEnabled()) {
GetNumBursts();
}
if (delayImplemented) { if (delayImplemented) {
GetDelay(); GetDelay();
} }
if (spinBurstPeriod->isEnabled()) {
GetBurstPeriod();
}
if (sampleImplemented) { if (sampleImplemented) {
GetNumSamples(); GetNumSamples();
} }

View File

@ -60,15 +60,21 @@ void qTabPlot::SetupWidgetWindow() {
switch(det->getDetectorType().squash()) { switch(det->getDetectorType().squash()) {
case slsDetectorDefs::GOTTHARD: case slsDetectorDefs::GOTTHARD:
case slsDetectorDefs::MYTHEN3: case slsDetectorDefs::MYTHEN3:
is1d = true;
break;
case slsDetectorDefs::GOTTHARD2: case slsDetectorDefs::GOTTHARD2:
is1d = true; is1d = true;
chkGainPlot1D->setEnabled(true);
chkGainPlot1D->setChecked(true);
plot->EnableGainPlot(true);
break; break;
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
chkGapPixels->setEnabled(true); chkGapPixels->setEnabled(true);
break; break;
case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::MOENCH:
chkGainPlot->setEnabled(true); chkGainPlot->setEnabled(true);
chkGainPlot->setChecked(true);
plot->EnableGainPlot(true);
break; break;
default: default:
break; break;
@ -128,6 +134,8 @@ void qTabPlot::Initialization() {
//gainplot //gainplot
if (chkGainPlot->isEnabled()) if (chkGainPlot->isEnabled())
connect(chkGainPlot, SIGNAL(toggled(bool)), plot, SLOT(EnableGainPlot(bool))); connect(chkGainPlot, SIGNAL(toggled(bool)), plot, SLOT(EnableGainPlot(bool)));
if (chkGainPlot1D->isEnabled())
connect(chkGainPlot1D, SIGNAL(toggled(bool)), plot, SLOT(EnableGainPlot(bool)));
// gap pixels // gap pixels
if (chkGapPixels->isEnabled()) if (chkGapPixels->isEnabled())
connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool))); connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool)));
@ -576,9 +584,11 @@ void qTabPlot::Refresh() {
GetGapPixels(); GetGapPixels();
break; break;
case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::MOENCH:
chkGainPlot->setEnabled(true); chkGainPlot->setEnabled(true);
break; break;
case slsDetectorDefs::GOTTHARD2:
chkGainPlot1D->setEnabled(true);
break;
default: default:
break; break;
} }
@ -586,6 +596,7 @@ void qTabPlot::Refresh() {
boxPlotType->setEnabled(false); boxPlotType->setEnabled(false);
boxFrequency->setEnabled(false); boxFrequency->setEnabled(false);
chkGainPlot->setEnabled(false); chkGainPlot->setEnabled(false);
chkGainPlot1D->setEnabled(false);
chkGapPixels->setEnabled(false); chkGapPixels->setEnabled(false);
} }

View File

@ -20,7 +20,6 @@ void qTabSettings::SetupWidgetWindow() {
// enabling according to det type // enabling according to det type
switch(det->getDetectorType().squash()) { switch(det->getDetectorType().squash()) {
case slsDetectorDefs::MOENCH:
case slsDetectorDefs::MYTHEN3: case slsDetectorDefs::MYTHEN3:
lblSettings->setEnabled(false); lblSettings->setEnabled(false);
comboSettings->setEnabled(false); comboSettings->setEnabled(false);
@ -88,6 +87,16 @@ void qTabSettings::SetupDetectorSettings() {
item[(int)FIXGAIN1]->setEnabled(true); item[(int)FIXGAIN1]->setEnabled(true);
item[(int)FIXGAIN2]->setEnabled(true); item[(int)FIXGAIN2]->setEnabled(true);
break; break;
case slsDetectorDefs::MOENCH:
item[(int)G1_HIGHGAIN]->setEnabled(true);
item[(int)G1_LOWGAIN]->setEnabled(true);
item[(int)G2_HIGHCAP_HIGHGAIN]->setEnabled(true);
item[(int)G2_HIGHCAP_LOWGAIN]->setEnabled(true);
item[(int)G2_LOWCAP_HIGHGAIN]->setEnabled(true);
item[(int)G2_LOWCAP_LOWGAIN]->setEnabled(true);
item[(int)G4_HIGHGAIN]->setEnabled(true);
item[(int)G4_LOWGAIN]->setEnabled(true);
break;
default: default:
FILE_LOG(logDEBUG) << "Unknown detector type. Exiting GUI."; FILE_LOG(logDEBUG) << "Unknown detector type. Exiting GUI.";
qDefs::Message(qDefs::CRITICAL, qDefs::Message(qDefs::CRITICAL,

View File

@ -4,13 +4,14 @@ if [ $# -eq 0 ]; then
"gotthard2DetectorServer" "gotthard2DetectorServer"
"jungfrauDetectorServer" "jungfrauDetectorServer"
"mythen3DetectorServer" "mythen3DetectorServer"
"moenchDetectorServer"
) )
else else
declare -a det=("${1}") declare -a det=("${1}")
echo "got something" echo "got something"
fi fi
declare -a deterror=("OK" "OK" "OK" "OK") declare -a deterror=("OK" "OK" "OK" "OK" "OK" "OK")
for ((i=0;i<${#det[@]};++i)) for ((i=0;i<${#det[@]};++i))
do do

View File

@ -515,7 +515,7 @@ void setupDetector() {
// altera pll // 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_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);
bus_w(ADC_PORT_INVERT_REG, 0);// depends on chip setADCInvertRegister(0);// depends on chip
FILE_LOG(logINFOBLUE, ("Setting Default parameters\n")); FILE_LOG(logINFOBLUE, ("Setting Default parameters\n"));
cleanFifos(); // FIXME: why twice? cleanFifos(); // FIXME: why twice?

View File

@ -107,7 +107,6 @@ enum CLKINDEX {RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS};
#define BIT32_MSK (0xFFFFFFFF) #define BIT32_MSK (0xFFFFFFFF)
#define BIT16_MASK (0xFFFF) #define BIT16_MASK (0xFFFF)
#define ADC_PORT_INVERT_VAL (0x453b2593)
#define MAXIMUM_ADC_CLK (65) #define MAXIMUM_ADC_CLK (65)
#define PLL_VCO_FREQ_MHZ (800) #define PLL_VCO_FREQ_MHZ (800)

View File

@ -23,7 +23,7 @@ target_include_directories(gotthard2DetectorServer_virtual
) )
target_compile_definitions(gotthard2DetectorServer_virtual target_compile_definitions(gotthard2DetectorServer_virtual
PUBLIC GOTTHARD2D VIRTUAL STOP_SERVER DEBUG1 PUBLIC GOTTHARD2D VIRTUAL STOP_SERVER #DEBUG1
) )
target_link_libraries(gotthard2DetectorServer_virtual target_link_libraries(gotthard2DetectorServer_virtual

View File

@ -5,7 +5,7 @@ support_lib = ../../slsSupportLib/include/
CROSS = nios2-buildroot-linux-gnu- CROSS = nios2-buildroot-linux-gnu-
CC = $(CROSS)gcc CC = $(CROSS)gcc
CFLAGS += -Wall -DGOTTHARD2D -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) -DDEBUG1 #-DVERBOSEI #-DVERBOSE CFLAGS += -Wall -DGOTTHARD2D -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
LDLIBS += -lm LDLIBS += -lm
PROGS = gotthard2DetectorServer PROGS = gotthard2DetectorServer
DESTDIR ?= bin DESTDIR ?= bin

View File

@ -104,6 +104,8 @@
#define CONTROL_PRPHRL_RST_MSK (0x00000001 << CONTROL_PRPHRL_RST_OFST) #define CONTROL_PRPHRL_RST_MSK (0x00000001 << CONTROL_PRPHRL_RST_OFST)
#define CONTROL_CLR_ACQSTN_FIFO_OFST (15) #define CONTROL_CLR_ACQSTN_FIFO_OFST (15)
#define CONTROL_CLR_ACQSTN_FIFO_MSK (0x00000001 << CONTROL_CLR_ACQSTN_FIFO_OFST) #define CONTROL_CLR_ACQSTN_FIFO_MSK (0x00000001 << CONTROL_CLR_ACQSTN_FIFO_OFST)
#define CONTROL_TIMING_SOURCE_EXT_OFST (17)
#define CONTROL_TIMING_SOURCE_EXT_MSK (0x00000001 << CONTROL_TIMING_SOURCE_EXT_OFST)
#define CONTROL_PWR_CHIP_OFST (31) #define CONTROL_PWR_CHIP_OFST (31)
#define CONTROL_PWR_CHIP_MSK (0x00000001 << CONTROL_PWR_CHIP_OFST) #define CONTROL_PWR_CHIP_MSK (0x00000001 << CONTROL_PWR_CHIP_OFST)
@ -128,6 +130,8 @@
#define ASIC_CONFIG_FIX_GAIN_1_VAL ((0x1 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) #define ASIC_CONFIG_FIX_GAIN_1_VAL ((0x1 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_FIX_GAIN_2_VAL ((0x2 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) #define ASIC_CONFIG_FIX_GAIN_2_VAL ((0x2 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_RESERVED_VAL ((0x3 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) #define ASIC_CONFIG_RESERVED_VAL ((0x3 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_CURRENT_SRC_EN_OFST (7)
#define ASIC_CONFIG_CURRENT_SRC_EN_MSK (0x00000001 << ASIC_CONFIG_CURRENT_SRC_EN_OFST)
#define ASIC_CONFIG_RST_DAC_OFST (15) #define ASIC_CONFIG_RST_DAC_OFST (15)
#define ASIC_CONFIG_RST_DAC_MSK (0x00000001 << ASIC_CONFIG_RST_DAC_OFST) #define ASIC_CONFIG_RST_DAC_MSK (0x00000001 << ASIC_CONFIG_RST_DAC_OFST)
#define ASIC_CONFIG_DONE_OFST (31) #define ASIC_CONFIG_DONE_OFST (31)
@ -224,7 +228,7 @@
#define SET_DELAY_LSB_REG (0x22 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_DELAY_LSB_REG (0x22 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_DELAY_MSB_REG (0x23 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_DELAY_MSB_REG (0x23 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Cylces 64bit Write-register */ /* Cylces (also #bursts) 64bit Write-register */
#define SET_CYCLES_LSB_REG (0x24 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_CYCLES_LSB_REG (0x24 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_CYCLES_MSB_REG (0x25 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_CYCLES_MSB_REG (0x25 * REG_OFFSET + BASE_FLOW_CONTROL)
@ -232,7 +236,7 @@
#define SET_FRAMES_LSB_REG (0x26 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_FRAMES_LSB_REG (0x26 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_FRAMES_MSB_REG (0x27 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_FRAMES_MSB_REG (0x27 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Period 64bit Write-register */ /* Period (also burst period) 64bit Write-register */
#define SET_PERIOD_LSB_REG (0x28 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_PERIOD_LSB_REG (0x28 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_PERIOD_MSB_REG (0x29 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_PERIOD_MSB_REG (0x29 * REG_OFFSET + BASE_FLOW_CONTROL)

View File

@ -39,6 +39,7 @@ int virtual_stop = 0;
enum detectorSettings thisSettings = UNINITIALIZED; enum detectorSettings thisSettings = UNINITIALIZED;
int32_t clkPhase[NUM_CLOCKS] = {}; int32_t clkPhase[NUM_CLOCKS] = {};
uint32_t clkFrequency[NUM_CLOCKS] = {}; uint32_t clkFrequency[NUM_CLOCKS] = {};
uint32_t systemFrequency = 0;
int highvoltage = 0; int highvoltage = 0;
int dacValues[NDAC] = {0}; int dacValues[NDAC] = {0};
int onChipdacValues[ONCHIP_NDAC][NCHIP] = {0}; int onChipdacValues[ONCHIP_NDAC][NCHIP] = {0};
@ -47,9 +48,9 @@ int injectedChannelsIncrement = 0;
int vetoReference[NCHIP][NCHAN]; int vetoReference[NCHIP][NCHAN];
uint8_t adcConfiguration[NCHIP][NADC]; uint8_t adcConfiguration[NCHIP][NADC];
int burstMode = BURST_INTERNAL; int burstMode = BURST_INTERNAL;
int64_t exptime_ns = 0; int64_t numTriggers = 1;
int64_t period_ns = 0; int64_t numBursts = 1;
int64_t nframes = 0; int64_t burstPeriodNs = 0;
int detPos[2] = {}; int detPos[2] = {};
int isInitCheckDone() { int isInitCheckDone() {
@ -345,6 +346,7 @@ void setupDetector() {
clkFrequency[SYSTEM_C1] = DEFAULT_SYSTEM_C1; clkFrequency[SYSTEM_C1] = DEFAULT_SYSTEM_C1;
clkFrequency[SYSTEM_C2] = DEFAULT_SYSTEM_C2; clkFrequency[SYSTEM_C2] = DEFAULT_SYSTEM_C2;
clkFrequency[SYSTEM_C3] = DEFAULT_SYSTEM_C3; clkFrequency[SYSTEM_C3] = DEFAULT_SYSTEM_C3;
systemFrequency = INT_SYSTEM_C0_FREQUENCY;
detPos[0] = 0; detPos[0] = 0;
detPos[1] = 0; detPos[1] = 0;
@ -353,9 +355,9 @@ void setupDetector() {
injectedChannelsOffset = 0; injectedChannelsOffset = 0;
injectedChannelsIncrement = 0; injectedChannelsIncrement = 0;
burstMode = BURST_INTERNAL; burstMode = BURST_INTERNAL;
exptime_ns = 0; numTriggers = 1;
period_ns = 0; numBursts = 1;
nframes = 0; burstPeriodNs = 0;
{ {
int i, j; int i, j;
for (i = 0; i < NUM_CLOCKS; ++i) { for (i = 0; i < NUM_CLOCKS; ++i) {
@ -392,6 +394,7 @@ void setupDetector() {
// on chip dacs // on chip dacs
ASIC_Driver_SetDefines(ONCHIP_DAC_DRIVER_FILE_NAME); ASIC_Driver_SetDefines(ONCHIP_DAC_DRIVER_FILE_NAME);
#endif #endif
setTimingSource(DEFAULT_TIMING_SOURCE);
// Default values // Default values
setHighVoltage(DEFAULT_HIGH_VOLTAGE); setHighVoltage(DEFAULT_HIGH_VOLTAGE);
@ -439,10 +442,13 @@ void setupDetector() {
// Initialization of acquistion parameters // Initialization of acquistion parameters
setNumFrames(DEFAULT_NUM_FRAMES); setNumFrames(DEFAULT_NUM_FRAMES);
setNumTriggers(DEFAULT_NUM_CYCLES); setNumTriggers(DEFAULT_NUM_CYCLES);
setNumBursts(DEFAULT_NUM_BURSTS);
setExpTime(DEFAULT_EXPTIME); setExpTime(DEFAULT_EXPTIME);
setPeriod(DEFAULT_PERIOD); setPeriod(DEFAULT_PERIOD);
setDelayAfterTrigger(DEFAULT_DELAY_AFTER_TRIGGER); setDelayAfterTrigger(DEFAULT_DELAY_AFTER_TRIGGER);
setBurstPeriod(DEFAULT_BURST_PERIOD);
setTiming(DEFAULT_TIMING_MODE); setTiming(DEFAULT_TIMING_MODE);
setCurrentSource(DEFAULT_CURRENT_SOURCE);
} }
int readConfigFile() { int readConfigFile() {
@ -452,13 +458,13 @@ int readConfigFile() {
} }
// require a sleep before and after the rst dac signal // require a sleep before and after the rst dac signal
usleep (1 * 1000); usleep (INITIAL_STARTUP_WAIT);
// inform FPGA that onchip dacs will be configured soon // inform FPGA that onchip dacs will be configured soon
FILE_LOG(logINFO, ("Setting configuration starting bit\n")); FILE_LOG(logINFO, ("Setting configuration starting bit\n"));
bus_w(ASIC_CONFIG_REG, bus_r(ASIC_CONFIG_REG) | ASIC_CONFIG_RST_DAC_MSK); bus_w(ASIC_CONFIG_REG, bus_r(ASIC_CONFIG_REG) | ASIC_CONFIG_RST_DAC_MSK);
usleep (1 * 1000); usleep (INITIAL_STARTUP_WAIT);
FILE* fd = fopen(CONFIG_FILE, "r"); FILE* fd = fopen(CONFIG_FILE, "r");
if(fd == NULL) { if(fd == NULL) {
@ -731,52 +737,104 @@ int setDynamicRange(int dr){
/* parameters - timer */ /* parameters - timer */
void setNumFrames(int64_t val) { void setNumFrames(int64_t val) {
if (val > 0) { if (val > 0) {
FILE_LOG(logINFO, ("Setting number of frames %lld [local]\n", (long long int)val)); FILE_LOG(logINFO, ("Setting number of frames %lld [local]\n", val));
nframes = val; // continuous mode
if (burstMode == BURST_OFF) {
setNumFramesCont(val);
setNumFramesBurst(1);
} else {
setNumFramesBurst(val);
setNumFramesCont(1);
}
} }
} }
int64_t getNumFrames() { int64_t getNumFrames() {
return nframes; if (burstMode == BURST_OFF) {
return getNumFramesCont();
} else {
return getNumFramesBurst();
}
} }
void setNumTriggers(int64_t val) { void setNumTriggers(int64_t val) {
if (val > 0) { if (val > 0) {
FILE_LOG(logINFO, ("Setting number of triggers %lld\n", (long long int)val)); FILE_LOG(logINFO, ("Setting number of triggers %lld\n", val));
numTriggers = val;
if (burstMode != BURST_OFF && getTiming() == AUTO_TIMING) {
FILE_LOG(logINFO, ("\tBurst and Auto mode: not writing #triggers to register\n"));
} else {
set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG); set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
} }
} }
}
int64_t getNumTriggers() { int64_t getNumTriggers() {
if (burstMode != BURST_OFF && getTiming() == AUTO_TIMING) {
return numTriggers;
}
return get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG); return get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
} }
void setNumBursts(int64_t val) {
if (val > 0) {
FILE_LOG(logINFO, ("Setting number of bursts %lld\n", val));
numBursts = val;
if (burstMode != BURST_OFF && getTiming() == AUTO_TIMING) {
set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
} else {
FILE_LOG(logINFO, ("\tNot (Burst and Auto mode): not writing #bursts to register\n"));
}
}
}
int64_t getNumBursts() {
if (burstMode != BURST_OFF && getTiming() == AUTO_TIMING) {
return get64BitReg(SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
}
return numBursts;
}
int setExpTime(int64_t val) { int setExpTime(int64_t val) {
if (val < 0) { if (val < 0) {
FILE_LOG(logERROR, ("Invalid exptime: %lld ns\n", (long long int)val)); FILE_LOG(logERROR, ("Invalid exptime: %lld ns\n", val));
return FAIL; return FAIL;
} }
FILE_LOG(logINFO, ("Setting exptime %lld ns [local]\n", (long long int)val)); FILE_LOG(logINFO, ("Setting exptime %lld ns [local]\n", val));
exptime_ns = val; // continuous mode
return OK; if (burstMode == BURST_OFF) {
return setExptimeCont(val);
} else {
return setExptimeBurst(val);
}
} }
int64_t getExpTime() { int64_t getExpTime() {
return exptime_ns; return getExptimeBoth();
} }
int setPeriod(int64_t val) { int setPeriod(int64_t val) {
if (val < 0) { if (val < 0) {
FILE_LOG(logERROR, ("Invalid period: %lld ns\n", (long long int)val)); FILE_LOG(logERROR, ("Invalid period: %lld ns\n", val));
return FAIL; return FAIL;
} }
FILE_LOG(logINFO, ("Setting period %lld ns [local]\n", (long long int)val)); FILE_LOG(logINFO, ("Setting period %lld ns [local]\n", val));
period_ns = val; // continuous mode
return OK; if (burstMode == BURST_OFF) {
setPeriodBurst(0);
return setPeriodCont(val);
} else {
//setPeriodCont(0);
return setPeriodBurst(val);
}
} }
int64_t getPeriod() { int64_t getPeriod() {
return period_ns; if (burstMode == BURST_OFF) {
return getPeriodCont();
} else {
return getPeriodBurst();
}
} }
void setNumFramesBurst(int64_t val) { void setNumFramesBurst(int64_t val) {
@ -790,7 +848,7 @@ int64_t getNumFramesBurst() {
} }
void setNumFramesCont(int64_t val) { void setNumFramesCont(int64_t val) {
FILE_LOG(logINFO, ("Setting number of frames %lld [Continuous mode]\n", (long long int)val)); FILE_LOG(logINFO, ("Setting number of frames %lld [Continuous mode]\n", val));
set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG); set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
} }
@ -799,22 +857,22 @@ int64_t getNumFramesCont() {
} }
int setExptimeBurst(int64_t val) { int setExptimeBurst(int64_t val) {
FILE_LOG(logINFO, ("Setting exptime %lld ns [Burst mode]\n", (long long int)val)); FILE_LOG(logINFO, ("Setting exptime %lld ns [Burst mode]\n", val));
return setExptimeBoth(val); return setExptimeBoth(val);
} }
int setExptimeCont(int64_t val) { int setExptimeCont(int64_t val) {
FILE_LOG(logINFO, ("Setting exptime %lld ns [Continuous mode]\n", (long long int)val)); FILE_LOG(logINFO, ("Setting exptime %lld ns [Continuous mode]\n", val));
return setExptimeBoth(val); return setExptimeBoth(val);
} }
int setExptimeBoth(int64_t val) { int setExptimeBoth(int64_t val) {
val *= (1E-9 * clkFrequency[SYSTEM_C0]); val *= (1E-9 * systemFrequency);
set64BitReg(val, ASIC_INT_EXPTIME_LSB_REG, ASIC_INT_EXPTIME_MSB_REG); set64BitReg(val, ASIC_INT_EXPTIME_LSB_REG, ASIC_INT_EXPTIME_MSB_REG);
// validate for tolerance // validate for tolerance
int64_t retval = getExptimeBoth(); int64_t retval = getExptimeBoth();
val /= (1E-9 * clkFrequency[SYSTEM_C0]); val /= (1E-9 * systemFrequency);
if (val != retval) { if (val != retval) {
return FAIL; return FAIL;
} }
@ -822,18 +880,18 @@ int setExptimeBoth(int64_t val) {
} }
int64_t getExptimeBoth() { int64_t getExptimeBoth() {
return get64BitReg(ASIC_INT_EXPTIME_LSB_REG, ASIC_INT_EXPTIME_MSB_REG) / (1E-9 * clkFrequency[SYSTEM_C0]); return get64BitReg(ASIC_INT_EXPTIME_LSB_REG, ASIC_INT_EXPTIME_MSB_REG) / (1E-9 * systemFrequency);
} }
int setPeriodBurst(int64_t val) { int setPeriodBurst(int64_t val) {
FILE_LOG(logINFO, ("Setting period %lld ns [Burst mode]\n", (long long int)val)); FILE_LOG(logINFO, ("Setting period %lld ns [Burst mode]\n", val));
val *= (1E-9 * clkFrequency[SYSTEM_C0]); val *= (1E-9 * systemFrequency);
set64BitReg(val, ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG); set64BitReg(val, ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG);
// validate for tolerance // validate for tolerance
int64_t retval = getPeriodBurst(); int64_t retval = getPeriodBurst();
val /= (1E-9 * clkFrequency[SYSTEM_C0]); val /= (1E-9 * systemFrequency);
if (val != retval) { if (val != retval) {
return FAIL; return FAIL;
} }
@ -841,17 +899,18 @@ int setPeriodBurst(int64_t val) {
} }
int64_t getPeriodBurst() { int64_t getPeriodBurst() {
return get64BitReg(ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG)/ (1E-9 * clkFrequency[SYSTEM_C0]); FILE_LOG(logDEBUG, ("Getting period [Burst mode]\n"));
return get64BitReg(ASIC_INT_PERIOD_LSB_REG, ASIC_INT_PERIOD_MSB_REG)/ (1E-9 * systemFrequency);
} }
int setPeriodCont(int64_t val) { int setPeriodCont(int64_t val) {
FILE_LOG(logINFO, ("Setting period %lld ns [Continuous mode]\n", (long long int)val)); FILE_LOG(logINFO, ("Setting period %lld ns [Continuous mode]\n", val));
val *= (1E-9 * FIXED_PLL_FREQUENCY); val *= (1E-9 * systemFrequency);
set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG); set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
// validate for tolerance // validate for tolerance
int64_t retval = getPeriodCont(); int64_t retval = getPeriodCont();
val /= (1E-9 * FIXED_PLL_FREQUENCY); val /= (1E-9 * systemFrequency);
if (val != retval) { if (val != retval) {
return FAIL; return FAIL;
} }
@ -859,21 +918,22 @@ int setPeriodCont(int64_t val) {
} }
int64_t getPeriodCont() { int64_t getPeriodCont() {
return get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG)/ (1E-9 * FIXED_PLL_FREQUENCY); FILE_LOG(logDEBUG, ("Getting period [Continuous mode]\n"));
return get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG)/ (1E-9 * systemFrequency);
} }
int setDelayAfterTrigger(int64_t val) { int setDelayAfterTrigger(int64_t val) {
if (val < 0) { if (val < 0) {
FILE_LOG(logERROR, ("Invalid delay after trigger: %lld ns\n", (long long int)val)); FILE_LOG(logERROR, ("Invalid delay after trigger: %lld ns\n", val));
return FAIL; return FAIL;
} }
FILE_LOG(logINFO, ("Setting delay after trigger %lld ns\n", (long long int)val)); FILE_LOG(logINFO, ("Setting delay after trigger %lld ns\n", val));
val *= (1E-9 * FIXED_PLL_FREQUENCY); val *= (1E-9 * systemFrequency);
set64BitReg(val, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG); set64BitReg(val, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG);
// validate for tolerance // validate for tolerance
int64_t retval = getDelayAfterTrigger(); int64_t retval = getDelayAfterTrigger();
val /= (1E-9 * FIXED_PLL_FREQUENCY); val /= (1E-9 * systemFrequency);
if (val != retval) { if (val != retval) {
return FAIL; return FAIL;
} }
@ -881,7 +941,37 @@ int setDelayAfterTrigger(int64_t val) {
} }
int64_t getDelayAfterTrigger() { int64_t getDelayAfterTrigger() {
return get64BitReg(SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG) / (1E-9 * FIXED_PLL_FREQUENCY); return get64BitReg(SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG) / (1E-9 * systemFrequency);
}
int setBurstPeriod(int64_t val) {
if (val < 0) {
FILE_LOG(logERROR, ("Invalid burst period: %lld ns\n", val));
return FAIL;
}
FILE_LOG(logINFO, ("Setting burst period %lld ns\n", val));
burstPeriodNs = val;
val *= (1E-9 * systemFrequency);
if (burstMode != BURST_OFF) {
set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
} else {
FILE_LOG(logINFO, ("\t(Continuous mode): not writing burst period to register\n"));
}
// validate for tolerance
int64_t retval = getBurstPeriod();
val /= (1E-9 * systemFrequency);
if (val != retval) {
return FAIL;
}
return OK;
}
int64_t getBurstPeriod() {
if (burstMode != BURST_OFF) {
return get64BitReg(SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG) / (1E-9 * systemFrequency);
}
return burstPeriodNs;
} }
int64_t getNumFramesLeft() { int64_t getNumFramesLeft() {
@ -893,11 +983,11 @@ int64_t getNumTriggersLeft() {
} }
int64_t getDelayAfterTriggerLeft() { int64_t getDelayAfterTriggerLeft() {
return get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG) / (1E-9 * FIXED_PLL_FREQUENCY); return get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG) / (1E-9 * systemFrequency);
} }
int64_t getPeriodLeft() { int64_t getPeriodLeft() {
return get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG) / (1E-9 * FIXED_PLL_FREQUENCY); return get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG) / (1E-9 * systemFrequency);
} }
int64_t getFramesFromStart() { int64_t getFramesFromStart() {
@ -1108,6 +1198,10 @@ void setTiming( enum timingMode arg){
default: default:
FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg)); FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg));
} }
FILE_LOG(logINFO, ("\tUpdating trigger/burst and delay/burst period registers\n"))
setNumTriggers(numTriggers);
setNumBursts(numBursts);
} }
enum timingMode getTiming() { enum timingMode getTiming() {
@ -1470,6 +1564,10 @@ int setClockDivider(enum CLKINDEX ind, int val) {
ALTERA_PLL_C10_SetOuputFrequency (pllIndex, clkIndex, newfreq); ALTERA_PLL_C10_SetOuputFrequency (pllIndex, clkIndex, newfreq);
clkFrequency[ind] = newfreq; clkFrequency[ind] = newfreq;
FILE_LOG(logINFO, ("\t%s clock (%d) divider set to %d (%d Hz)\n", clock_names[ind], ind, val, clkFrequency[ind])); FILE_LOG(logINFO, ("\t%s clock (%d) divider set to %d (%d Hz)\n", clock_names[ind], ind, val, clkFrequency[ind]));
// update system frequency
if (ind == SYSTEM_C0) {
setTimingSource(getTimingSource());
}
// phase is reset by pll (when setting output frequency) // phase is reset by pll (when setting output frequency)
if (ind >= READOUT_C0) { if (ind >= READOUT_C0) {
@ -1778,10 +1876,24 @@ int setBurstModeinFPGA(enum burstMode value) {
int setBurstMode(enum burstMode burst) { int setBurstMode(enum burstMode burst) {
FILE_LOG(logINFO, ("Setting burst mode to %s\n", burst == BURST_OFF ? "off" : (burst == BURST_INTERNAL ? "internal" : "external"))); FILE_LOG(logINFO, ("Setting burst mode to %s\n", burst == BURST_OFF ? "off" : (burst == BURST_INTERNAL ? "internal" : "external")));
// remember the number of frames and period (before changing burst mode)
int64_t frames = getNumFrames();
int64_t period = getPeriod();
if (setBurstModeinFPGA(burst) == FAIL) { if (setBurstModeinFPGA(burst) == FAIL) {
return FAIL; return FAIL;
} }
FILE_LOG(logINFO, ("\tUpdating trigger/burst and burst period registers\n"))
setNumTriggers(numTriggers);
setNumBursts(numBursts);
setBurstPeriod(burstPeriodNs);
// set number of frames and period again (set registers according to timing mode)
FILE_LOG(logINFO, ("\tUpdating #frames and period registers\n"));
setNumFrames(frames);
setPeriod(period);
FILE_LOG(logINFO, ("\tSetting %s Mode in Chip\n", burstMode == BURST_OFF ? "Continuous" : "Burst")); FILE_LOG(logINFO, ("\tSetting %s Mode in Chip\n", burstMode == BURST_OFF ? "Continuous" : "Burst"));
int value = burstMode ? ASIC_GLOBAL_BURST_VALUE : ASIC_GLOBAL_CONT_VALUE; int value = burstMode ? ASIC_GLOBAL_BURST_VALUE : ASIC_GLOBAL_CONT_VALUE;
@ -1829,84 +1941,64 @@ enum burstMode getBurstMode() {
int runmode = bus_r (addr) & ASIC_CONFIG_RUN_MODE_MSK; int runmode = bus_r (addr) & ASIC_CONFIG_RUN_MODE_MSK;
switch (runmode) { switch (runmode) {
case ASIC_CONFIG_RUN_MODE_CONT_VAL: case ASIC_CONFIG_RUN_MODE_CONT_VAL:
return BURST_OFF; burstMode = BURST_OFF;
break;
case ASIC_CONFIG_RUN_MODE_INT_BURST_VAL: case ASIC_CONFIG_RUN_MODE_INT_BURST_VAL:
return BURST_INTERNAL; burstMode = BURST_INTERNAL;
break;
case ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL: case ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL:
return BURST_EXTERNAL; burstMode = BURST_EXTERNAL;
break;
default: default:
FILE_LOG(logERROR, ("Unknown run mode read from FPGA %d\n", runmode)); FILE_LOG(logERROR, ("Unknown run mode read from FPGA %d\n", runmode));
return -1; return -1;
} }
return burstMode;
} }
void setCurrentSource(int value) {
uint32_t addr = ASIC_CONFIG_REG;
if (value > 0) {
bus_w(addr, (bus_r(addr) | ASIC_CONFIG_CURRENT_SRC_EN_MSK));
} else if (value == 0) {
bus_w(addr, (bus_r(addr) &~ ASIC_CONFIG_CURRENT_SRC_EN_MSK));
}
}
int getCurrentSource() {
return ((bus_r(ASIC_CONFIG_REG) & ASIC_CONFIG_CURRENT_SRC_EN_MSK) >> ASIC_CONFIG_CURRENT_SRC_EN_OFST);
}
void setTimingSource(enum timingSourceType value) {
uint32_t addr = CONTROL_REG;
switch (value) {
case TIMING_INTERNAL:
FILE_LOG(logINFO, ("Setting timing source to internal\n"));
bus_w(addr, (bus_r(addr) &~ CONTROL_TIMING_SOURCE_EXT_MSK));
systemFrequency = INT_SYSTEM_C0_FREQUENCY;
break;
case TIMING_EXTERNAL:
FILE_LOG(logINFO, ("Setting timing source to exernal\n"));
bus_w(addr, (bus_r(addr) | CONTROL_TIMING_SOURCE_EXT_MSK));
systemFrequency = clkFrequency[SYSTEM_C0];
break;
default:
FILE_LOG(logERROR, ("Unknown timing source %d\n", value));
break;
}
}
enum timingSourceType getTimingSource() {
if (bus_r(CONTROL_REG) & CONTROL_TIMING_SOURCE_EXT_MSK) {
return TIMING_EXTERNAL;
}
return TIMING_INTERNAL;
}
/* aquisition */ /* aquisition */
int updateAcquisitionRegisters(char* mess) {
// burst mode
if (burstMode != BURST_OFF) {
// validate #frames in burst mode
if (nframes > MAX_FRAMES_IN_BURST_MODE) {
sprintf(mess, "Could not start acquisition because number of frames %lld must be <= %d in burst mode.\n", (long long unsigned int)nframes, MAX_FRAMES_IN_BURST_MODE);
FILE_LOG(logERROR,(mess));
return FAIL;
}
setNumFramesBurst(nframes);
// exptime
if (setExptimeBurst(exptime_ns) == FAIL) {
sprintf(mess, "Could not start acquisition because exptime could not be set in burst mode. Set %lld ns, got %lld ns.\n", (long long unsigned int)exptime_ns, getExptimeBoth());
FILE_LOG(logERROR,(mess));
return FAIL;
}
// period
if (setPeriodBurst(period_ns) == FAIL) {
sprintf(mess, "Could not start acquisition because period could not be set in burst mode. Set %lld ns, got %lld ns.\n", (long long unsigned int)period_ns, getPeriodBurst());
FILE_LOG(logERROR,(mess));
return FAIL;
}
// set continuous values to default (exptime same register)
FILE_LOG(logINFO, ("Setting continuous mode registers to defaults\n"));
// frames
setNumFramesCont(1);
// period
if (setPeriodCont(0) == FAIL) {
sprintf(mess, "Could not start acquisition because period could not be set in continuous mode. Set 0 ns, got %lld ns.\n", getPeriodCont());
FILE_LOG(logERROR,(mess));
return FAIL;
}
}
// continuous
else {
// frames
setNumFramesCont(nframes);
// exptime
if (setExptimeCont(exptime_ns) == FAIL) {
sprintf(mess, "Could not start acquisition because exptime could not be set in continuous mode. Set %lld ns, got %lld ns.\n", (long long unsigned int)exptime_ns, getExptimeBoth());
FILE_LOG(logERROR,(mess));
return FAIL;
}
// period
if (setPeriodCont(period_ns) == FAIL) {
sprintf(mess, "Could not start acquisition because period could not be set in continuous mode. Set %lld ns, got %lld ns.\n", (long long unsigned int)period_ns, getPeriodCont());
FILE_LOG(logERROR,(mess));
return FAIL;
}
// set burst values to default (exptime same register)
FILE_LOG(logINFO, ("Setting burst mode registers to defaults\n"));
setNumFramesBurst(1);
// period
if (setPeriodBurst(0) == FAIL) {
sprintf(mess, "Could not start acquisition because period could not be set in burst mode. Set 0 ns, got %lld ns.\n", getPeriodBurst());
FILE_LOG(logERROR,(mess));
return FAIL;
}
}
return OK;
}
int startStateMachine(){ int startStateMachine(){
#ifdef VIRTUAL #ifdef VIRTUAL
// create udp socket // create udp socket

View File

@ -27,17 +27,23 @@
#define TYPE_GOTTHARD2_MODULE_VAL (512) #define TYPE_GOTTHARD2_MODULE_VAL (512)
#define TYPE_TOLERANCE (10) #define TYPE_TOLERANCE (10)
#define TYPE_NO_MODULE_STARTING_VAL (800) #define TYPE_NO_MODULE_STARTING_VAL (800)
#define INITIAL_STARTUP_WAIT (1 * 1000 * 1000)
/** Default Parameters */ /** Default Parameters */
#define DEFAULT_BURST_MODE (BURST_INTERNAL) #define DEFAULT_BURST_MODE (BURST_INTERNAL)
#define DEFAULT_NUM_FRAMES (1) #define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_NUM_CYCLES (1) #define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_NUM_BURSTS (1)
#define DEFAULT_EXPTIME (0) // 0 ms (220ns in firmware) #define DEFAULT_EXPTIME (0) // 0 ms (220ns in firmware)
#define DEFAULT_PERIOD (1 * 1000) // 1 ms #define DEFAULT_PERIOD (0) // 0 ms
#define DEFAULT_DELAY_AFTER_TRIGGER (0) #define DEFAULT_DELAY_AFTER_TRIGGER (0)
#define DEFAULT_BURST_PERIOD (0)
#define DEFAULT_HIGH_VOLTAGE (0) #define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_TIMING_MODE (AUTO_TIMING) #define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_SETTINGS (DYNAMICGAIN) #define DEFAULT_SETTINGS (DYNAMICGAIN)
#define DEFAULT_CURRENT_SOURCE (0)
#define DEFAULT_TIMING_SOURCE (TIMING_INTERNAL)
#define DEFAULT_READOUT_C0 (144444448) // rdo_clk, 144 MHz #define DEFAULT_READOUT_C0 (144444448) // rdo_clk, 144 MHz
#define DEFAULT_READOUT_C1 (144444448) // rdo_x2_clk, 144 MHz #define DEFAULT_READOUT_C1 (144444448) // rdo_x2_clk, 144 MHz
#define DEFAULT_SYSTEM_C0 (144444448) // run_clk, 144 MHz #define DEFAULT_SYSTEM_C0 (144444448) // run_clk, 144 MHz
@ -47,9 +53,10 @@
/* Firmware Definitions */ /* Firmware Definitions */
#define IP_HEADER_SIZE (20) #define IP_HEADER_SIZE (20)
#define FIXED_PLL_FREQUENCY (020000000) // 20MHz #define FIXED_PLL_FREQUENCY (20000000) // 20MHz
#define READOUT_PLL_VCO_FREQ_HZ (866666688) // Hz #define INT_SYSTEM_C0_FREQUENCY (144000000) //144 MHz
#define SYSTEM_PLL_VCO_FREQ_HZ (722222240) // Hz #define READOUT_PLL_VCO_FREQ_HZ (866666688) // 866 MHz
#define SYSTEM_PLL_VCO_FREQ_HZ (722222224) // 722 MHz
/** Other Definitions */ /** Other Definitions */
#define BIT16_MASK (0xFFFF) #define BIT16_MASK (0xFFFF)

View File

@ -28,7 +28,7 @@ target_compile_definitions(jungfrauDetectorServer_virtual
) )
target_link_libraries(jungfrauDetectorServer_virtual target_link_libraries(jungfrauDetectorServer_virtual
PUBLIC pthread rt PUBLIC pthread rt slsProjectOptions slsProjectWarnings
) )
set_target_properties(jungfrauDetectorServer_virtual PROPERTIES set_target_properties(jungfrauDetectorServer_virtual PROPERTIES

View File

@ -219,6 +219,8 @@
#define PLL_CNTRL_WR_PRMTR_MSK (0x00000001 << PLL_CNTRL_WR_PRMTR_OFST) #define PLL_CNTRL_WR_PRMTR_MSK (0x00000001 << PLL_CNTRL_WR_PRMTR_OFST)
#define PLL_CNTRL_PLL_RST_OFST (3) #define PLL_CNTRL_PLL_RST_OFST (3)
#define PLL_CNTRL_PLL_RST_MSK (0x00000001 << PLL_CNTRL_PLL_RST_OFST) #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_OFST (16)
#define PLL_CNTRL_ADDR_MSK (0x0000003F << PLL_CNTRL_ADDR_OFST) #define PLL_CNTRL_ADDR_MSK (0x0000003F << PLL_CNTRL_ADDR_OFST)

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