Compare commits

..

134 Commits

Author SHA1 Message Date
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
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
94fcf52e64 Merge pull request #76 from slsdetectorgroup/exec
Buffern in exec
2020-02-04 10:59:48 +01:00
64214f22f9 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-04 10:50:14 +01:00
36bd91daa3 gotthard2: sleep before configuring on chip dacs, default exptime 0 and default period to 1ms 2020-02-04 10:50:01 +01:00
40bfca588b minor from clang-tidy 2020-02-04 10:36:03 +01:00
b9446f40d1 fmt and minor 2020-02-04 10:11:27 +01:00
ec66079f65 renamed ServerInterface 2020-02-04 08:57:35 +01:00
e6340456f6 minor 2020-02-04 08:47:22 +01:00
f42d591845 sizeof 2020-02-03 16:51:57 +01:00
e9029ba8f2 removed unused functions 2020-02-03 16:44:14 +01:00
121747352d buffer 2020-02-03 16:35:30 +01:00
4cfea36b93 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-03 16:00:32 +01:00
a829e69313 minor 2020-02-03 16:00:24 +01:00
42124ca97c eiger rxr: setting exptime now also sets subperiod in rxr master file 2020-02-03 15:54:41 +01:00
972f21258a renamed multiSlsDetector 2020-02-03 14:57:37 +01:00
6bb1188c37 renamed exes 2020-02-03 14:43:40 +01:00
a57c677105 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-03 14:38:31 +01:00
254e8f85d8 moved non public headers 2020-02-03 14:38:24 +01:00
56484daf18 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-03 12:25:40 +01:00
6cc13f9dc1 naming 2020-02-03 12:05:52 +01:00
93ab8d05d7 eiger: change speed to full speed for dr of 4, 8, 16 2020-02-03 11:37:43 +01:00
88c65c506f Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-03 11:34:14 +01:00
074636a7d6 minor cleaning 2020-02-03 11:34:07 +01:00
e432e6f90d 4.1.1 changes: software trigger via stop server, disentangling rxr streamin from register call back 2020-02-03 11:25:19 +01:00
a3c686d271 renamed 2020-02-03 11:04:49 +01:00
9f79f132b7 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-02-03 10:34:51 +01:00
4a7424d749 renamed circularFifo 2020-02-03 10:34:43 +01:00
e4f2072067 Merge pull request #75 from slsdetectorgroup/nohardexit
initialchecks can be bypassed (version compatibility and oher tests a…
2020-02-03 09:13:38 +01:00
8bae1059db Merge branch 'developer' into nohardexit 2020-01-31 17:36:22 +01:00
4b39ca6e5f gotthard2 gui 2020-01-31 17:35:56 +01:00
f0cccf9de8 initialchecks can be bypassed (version compatibility and oher tests at server start up) 2020-01-31 16:46:33 +01:00
89c774dbf7 nios programming: check file size first 2020-01-31 11:24:48 +01:00
5ca3a1b685 gotthard2 and mythen3: programming fpga, reboot; jungfrau, ctb: modified programming (#74) 2020-01-30 19:52:35 -08:00
7d7302a90c mnior 2020-01-29 14:38:19 +01:00
ac3230c656 gotthard2 testing 2020-01-29 14:34:23 +01:00
5761642da0 Merge branch 'developer' into gotthard2testing 2020-01-29 11:37:59 +01:00
70ffdf9709 fixes for IpAddr and MacAddr in Gui 2020-01-28 15:00:05 +01:00
af2f2708ad rxr: remove file buffering 2020-01-28 13:55:44 +01:00
c42b4b8c0e incorrect printout to MB 2020-01-28 10:43:06 +01:00
d9b88ea7d2 performance optimization in fifodepth, ensure memory is allocated by writing something in the beginning 2020-01-27 20:10:49 +01:00
9f22c80081 Revert "performance optimization in fifodepth, ensure memory is allocated by writing something in the beginning"
This reverts commit ab6f448e1f.
2020-01-27 19:59:18 +01:00
ab6f448e1f performance optimization in fifodepth, ensure memory is allocated by writing something in the beginning 2020-01-27 18:34:10 +01:00
53e5a097ab rxr: semaphore instead of keeprunning variable at startup 2020-01-27 18:03:03 +01:00
e527aad6ab bugfix: high fifo depth more than 32 bit 2020-01-27 15:25:41 +01:00
a0208778c1 bugfix: high fifo depth more than 32 bit 2020-01-27 15:21:19 +01:00
69897d4c78 WIP testing 2020-01-27 13:56:44 +01:00
41035808e9 merge from mythen3 and gotthard2 2020-01-24 15:08:58 +01:00
2314fdabd1 merge from mythen3, and jungfrau fix 2020-01-23 16:44:01 +01:00
abe63acc79 jungfrau fix: wait for acquisition to be done before sending stop receiver 2020-01-23 16:41:09 +01:00
688e4e84d9 Merge pull request #73 from slsdetectorgroup/mythen3
mythen3: virtual server, connected timing mode, row and col in header…
2020-01-23 12:35:43 +01:00
0210b7358c autogen python bindings 2020-01-23 12:13:23 +01:00
dd84337ef3 autogen enums 2020-01-23 11:45:33 +01:00
a9e375ed34 gotthard2: bursttype to burstmode 2020-01-23 11:03:14 +01:00
f881133795 get/set timing, generate data for gotthard2, vref_rstore instead of restore for gotthard2 2020-01-22 18:18:56 +01:00
8cbf3c62a9 merge from developer 2020-01-22 17:30:13 +01:00
ffc09ed19c Gotthard2 (#72)
* rearranging

* gotthard2: updated register map; powerchip checking detector type; internal and external period, frames, exptime; set/get delay, get actualtime, measurement, framesfromstart enabled; which detector comment updated in cmdproxy, detector and slsdetector

* gotthard2: first edit

* gotthard2 bug fix: no module attached

* gotthard2: works

* updated client doc for gotthard2: the timers that are used in continuous mode only

* gotthard2 virtual server sends data

* gotthard2: gain updated
2020-01-22 14:03:59 +01:00
3ea2520615 PR minor changes 2020-01-22 13:55:10 +01:00
1dea112742 adding gotthard2 tests 2020-01-22 11:35:29 +01:00
d8fccdcefa Merge branch 'developer' into gotthard2 2020-01-21 18:18:57 +01:00
981b13494c mythen3: virtual server, connected timing mode, row and col in header, included pattern bit and mask 2020-01-21 18:16:27 +01:00
7131f77a3a eiger: vcal set to 0 2020-01-21 16:10:15 +01:00
f08d430d16 eiger: vcal set to 0 2020-01-21 16:09:39 +01:00
9c89f6a63d Merge branch 'developer' into gotthard2 2020-01-21 16:05:04 +01:00
e746256653 gotthard2: gain updated 2020-01-21 16:01:38 +01:00
2e78484b61 gotthard2 virtual server sends data 2020-01-21 14:50:31 +01:00
1908a82627 ctb 2020-01-21 10:44:43 +01:00
bdf3a010c3 updated client doc for gotthard2: the timers that are used in continuous mode only 2020-01-21 10:26:11 +01:00
6bd0256172 pattern stuff 2020-01-21 10:22:26 +01:00
5667353f47 WIP 2020-01-21 09:07:27 +01:00
c4137dc309 gotthard2: works 2020-01-20 17:03:11 +01:00
4b7edf2e62 ctb 2020-01-20 16:46:38 +01:00
0194d7ba1c ctb 2020-01-20 16:37:18 +01:00
23dffa47df gotthard2 bug fix: no module attached 2020-01-20 14:42:06 +01:00
5c35a33e02 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-01-20 14:27:30 +01:00
65d95480bd mythen3 bug fix: rxr needs to update dr 2020-01-20 13:50:50 +01:00
6cfd0f8962 gotthard2: first edit 2020-01-20 12:13:23 +01:00
6e47f0b7f7 merge resolved 2020-01-20 11:36:35 +01:00
3c891495db mythen3: bug fix detector type 2020-01-20 11:32:02 +01:00
95030bc55f Merge branch 'developer' into gotthard2 2020-01-16 16:52:08 +01:00
e8bdf5a505 gotthard2: updated register map; powerchip checking detector type; internal and external period, frames, exptime; set/get delay, get actualtime, measurement, framesfromstart enabled; which detector comment updated in cmdproxy, detector and slsdetector 2020-01-16 15:33:35 +01:00
b6d9015ed0 rearranging 2020-01-15 15:08:01 +01:00
182 changed files with 6786 additions and 3458 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)

View File

@ -0,0 +1,2 @@
Draft
- dr 4, 8, 16 in eiger -> speed 0, 32 stays same (speed 1)

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);
@ -859,6 +913,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 +982,7 @@ 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);
// 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);
@ -1200,6 +1259,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 +1272,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 +1284,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 +1395,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 +1621,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 +2087,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 +2116,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 +2130,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

@ -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,13 @@
hostname bchip085+ #############################################
### 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 +417,80 @@ 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.2.102
####gui listening to (on receiver pc) #############################################
zmqip 129.129.202.92 ### edit with any number in the subnet of your server (first 3 numbers as above)
zmqport 30001 ############################################
####data streaming out of 0:udp_srcip 10.1.2.19
rx_zmqip 10.1.1.100
rx_zmqport 30003 0:udp_dstport 32410
0:rx_hostname pcmoench01 #############################################
### 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
############################################
0:rx_hostname mpc2011
tengiga 1
#rx_datastream 1
#rx_readfreq 1
dac 6 800
dac 0 1300
dac 4 1428
dac 1 1000
dac 7 900
dac 3 680
dac 2 1400
#turn on datastream from commandline dac 5 1200
rx_datastream 1
r_readfreq 1
#0:configuremac -1
rx_datastream 1
r_readfreq 1
dac:6 800
dac:0 1300
dac:4 1428
dac:1 1000
dac:7 900
dac:3 680
dac:2 1400
dac:5 1200
adcinvert 4a342593 adcinvert 4a342593
samples 5000 samples 5000
adcphase 90 adcphase 30 deg
adcpipeline 15 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

@ -1,12 +1,12 @@
#include "catch.hpp" #include "catch.hpp"
#include "multiSlsDetector.h" #include "DetectorImpl.h"
#include "string_utils.h" #include "string_utils.h"
#include "tests/globals.h" #include "tests/globals.h"
#include <iostream> #include <iostream>
class MultiDetectorFixture { class MultiDetectorFixture {
protected: protected:
multiSlsDetector d; DetectorImpl d;
public: public:
MultiDetectorFixture() : d(0, true, true) { MultiDetectorFixture() : d(0, true, true) {

View File

@ -3,7 +3,7 @@
#include "ClientSocket.h" #include "ClientSocket.h"
#include "logger.h" #include "logger.h"
#include "multiSlsDetector.h" #include "DetectorImpl.h"
#include "slsDetector.h" #include "slsDetector.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
@ -252,7 +252,7 @@ TEST_CASE(
int ratecorr = 125; int ratecorr = 125;
// pick up multi detector from shm id 0 // pick up multi detector from shm id 0
multiSlsDetector m(0); DetectorImpl m(0);
// ensure eiger detector type, hostname and online // ensure eiger detector type, hostname and online
REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum); REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum);
@ -302,7 +302,7 @@ TEST_CASE("Chiptestboard Loading Patterns", "[.ctbintegration]") {
SingleDetectorConfig c; SingleDetectorConfig c;
// pick up multi detector from shm id 0 // pick up multi detector from shm id 0
multiSlsDetector m(0); DetectorImpl m(0);
// ensure ctb detector type, hostname and online // ensure ctb detector type, hostname and online
REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum); REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum);
@ -387,7 +387,7 @@ TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert", "[.ctbintegrat
SingleDetectorConfig c; SingleDetectorConfig c;
// pick up multi detector from shm id 0 // pick up multi detector from shm id 0
multiSlsDetector m(0); DetectorImpl m(0);
// ensure ctb detector type, hostname and online // ensure ctb detector type, hostname and online
REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum); REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum);
@ -457,7 +457,7 @@ TEST_CASE("Eiger or Jungfrau startingfnum", "[.eigerintegration][.jungfrauintegr
SingleDetectorConfig c; SingleDetectorConfig c;
// pick up multi detector from shm id 0 // pick up multi detector from shm id 0
multiSlsDetector m(0); DetectorImpl m(0);
// ensure ctb detector type, hostname and online // ensure ctb detector type, hostname and online
REQUIRE(((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER) || (m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::JUNGFRAU))); REQUIRE(((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER) || (m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::JUNGFRAU)));
@ -495,7 +495,7 @@ TEST_CASE("Eiger readnlines", "[.eigerintegration][readnlines]") {
SingleDetectorConfig c; SingleDetectorConfig c;
// pick up multi detector from shm id 0 // pick up multi detector from shm id 0
multiSlsDetector m(0); DetectorImpl m(0);
// ensure detector type, hostname // ensure detector type, hostname
REQUIRE((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER)); REQUIRE((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER));

View File

@ -1,5 +1,5 @@
#include "catch.hpp" #include "catch.hpp"
#include "multiSlsDetector.h" #include "DetectorImpl.h"
#include "string_utils.h" #include "string_utils.h"
#include "tests/globals.h" #include "tests/globals.h"
#include <iostream> #include <iostream>
@ -9,7 +9,7 @@ using namespace Catch::literals;
TEST_CASE("Initialize a multi detector", "[.integration][.multi]") { TEST_CASE("Initialize a multi detector", "[.integration][.multi]") {
auto hostnames = sls::split(test::hostname, '+'); auto hostnames = sls::split(test::hostname, '+');
multiSlsDetector d(0, true, true); DetectorImpl d(0, true, true);
d.setHostname(test::hostname.c_str()); d.setHostname(test::hostname.c_str());
CHECK(d.getHostname() == test::hostname); CHECK(d.getHostname() == test::hostname);
@ -28,7 +28,7 @@ TEST_CASE("Initialize a multi detector", "[.integration][.multi]") {
TEST_CASE("Set and read timers", "[.integration][.multi]") { TEST_CASE("Set and read timers", "[.integration][.multi]") {
multiSlsDetector d(0, true, true); DetectorImpl d(0, true, true);
d.setHostname(test::hostname.c_str()); d.setHostname(test::hostname.c_str());
// FRAME_NUMBER // FRAME_NUMBER

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
) )
@ -32,13 +34,14 @@ set( PYTHON_FILES
jungfrau.py jungfrau.py
mythen3.py mythen3.py
registers.py registers.py
lookup.py
utils.py utils.py
) )
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,13 +3,13 @@ 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 from slsdet import dacIndex, readoutMode
from slsdet.lookup import view, find
d = Detector() d = Detector()
# e = Eiger() # e = Eiger()
# c = Ctb() c = Ctb()
# j = Jungfrau() # j = Jungfrau()
m = Mythen3() # m = Mythen3()

View File

@ -10,7 +10,7 @@ pycmd = dir(Detector)+dir(Eiger)+dir(Ctb)
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_restore', 'vref_cds', 'rxb_lb', 'vref_prech', 'vref_rstore', 'vref_cds',
'vpreamp', 'vref_comp', 'vref_comp_fe vref_ds', 'vref_h_adc', 'vpreamp', 'vref_comp', 'vref_comp_fe vref_ds', 'vref_h_adc',
'vref_l_adc', 'iodelay', 'list', 'vref_ds', 'vis', 'vpl', 'vref_l_adc', 'iodelay', 'list', 'vref_ds', 'vis', 'vpl',
'vref_comp_fe', 'vph', 'vout_cm', 'vcp', 'vcn', 'vcmp_ll', 'vcmp_lr' 'vref_comp_fe', 'vph', 'vout_cm', 'vcp', 'vcn', 'vcmp_ll', 'vcmp_lr'

View File

@ -9,19 +9,7 @@ enums.cpp
import re import re
import subprocess import subprocess
from parse import remove_comments
# def remove_comments(text):
# def replacer(match):
# s = match.group(0)
# if s.startswith('/'):
# return " " # note: a space and not an empty string
# else:
# return s
# pattern = re.compile(
# r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
# re.DOTALL | re.MULTILINE
# )
# return re.sub(pattern, replacer, text)
def extract_enums(lines): def extract_enums(lines):
line_iter = iter(lines) line_iter = iter(lines)

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,22 +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
IpAddr = _sls_detector.IpAddr
MacAddr = _sls_detector.MacAddr

View File

@ -1,121 +0,0 @@
from .detector import Detector
from .utils import element_if_equal
from .dacs import DetectorDacs
import _sls_detector
dacIndex = _sls_detector.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty
class CtbDacs(DetectorDacs):
"""
Ctb dacs
"""
_dacs = [('dac0', dacIndex(0), 0, 4000, 1400),
('dac1', dacIndex(1), 0, 4000, 1200),
('dac2', dacIndex(2), 0, 4000, 900),
('dac3', dacIndex(3), 0, 4000, 1050),
('dac4', dacIndex(4), 0, 4000, 1400),
('dac5', dacIndex(5), 0, 4000, 655),
('dac6', dacIndex(6), 0, 4000, 2000),
('dac7', dacIndex(7), 0, 4000, 1400),
('dac8', dacIndex(8), 0, 4000, 850),
('dac9', dacIndex(9), 0, 4000, 2000),
('dac10', dacIndex(10), 0, 4000, 2294),
('dac11', dacIndex(11), 0, 4000, 983),
('dac12', dacIndex(12), 0, 4000, 1475),
('dac13', dacIndex(13), 0, 4000, 1200),
('dac14', dacIndex(14), 0, 4000, 1600),
('dac15', dacIndex(15), 0, 4000, 1455),
('dac16', dacIndex(16), 0, 4000, 0),
('dac17', dacIndex(17), 0, 4000, 1000),
]
_dacnames = [_d[0] for _d in _dacs]
from .utils import element
class Ctb(Detector):
def __init__(self, id = 0):
super().__init__(id)
self._frozen = False
self._dacs = CtbDacs(self)
@property
def dacs(self):
return self._dacs
@property
@element
def v_a(self):
return self.getDAC(dacIndex.V_POWER_A, True)
@v_a.setter
def v_a(self, value):
self.setDAC(dacIndex.V_POWER_A, value, True)
@property
@element
def v_b(self):
return self.getDAC(dacIndex.V_POWER_B, True)
@v_b.setter
def v_b(self, value):
self.setDAC(dacIndex.V_POWER_B, value, True)
@property
@element
def v_c(self):
return self.getDAC(dacIndex.V_POWER_C, True)
@v_c.setter
def v_c(self, value):
self.setDAC(dacIndex.V_POWER_C, value, True)
@property
@element
def v_d(self):
return self.getDAC(dacIndex.V_POWER_D, True)
@v_d.setter
def v_d(self, value):
self.setDAC(dacIndex.V_POWER_D, value, True)
@property
@element
def v_io(self):
return self.getDAC(dacIndex.V_POWER_IO, True)
@v_io.setter
def v_io(self, value):
self.setDAC(dacIndex.V_POWER_IO, value, True)
@property
@element
def v_limit(self):
return self.getDAC(dacIndex.V_LIMIT, True)
@v_limit.setter
def v_limit(self, value):
self.setDAC(dacIndex.V_LIMIT, value, True)
@property
@element
def im_a(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_A)
@property
@element
def im_b(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_B)
@property
@element
def im_c(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_C)
@property
@element
def im_d(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_D)
@property
@element
def im_io(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_IO)

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

43
python/slsdet/ctb.py Normal file
View File

@ -0,0 +1,43 @@
from .detector import Detector
from .utils import element_if_equal
from .dacs import DetectorDacs
import _slsdet
dacIndex = _slsdet.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty
class CtbDacs(DetectorDacs):
"""
Ctb dacs
"""
_dacs = [('dac0', dacIndex(0), 0, 4000, 1400),
('dac1', dacIndex(1), 0, 4000, 1200),
('dac2', dacIndex(2), 0, 4000, 900),
('dac3', dacIndex(3), 0, 4000, 1050),
('dac4', dacIndex(4), 0, 4000, 1400),
('dac5', dacIndex(5), 0, 4000, 655),
('dac6', dacIndex(6), 0, 4000, 2000),
('dac7', dacIndex(7), 0, 4000, 1400),
('dac8', dacIndex(8), 0, 4000, 850),
('dac9', dacIndex(9), 0, 4000, 2000),
('dac10', dacIndex(10), 0, 4000, 2294),
('dac11', dacIndex(11), 0, 4000, 983),
('dac12', dacIndex(12), 0, 4000, 1475),
('dac13', dacIndex(13), 0, 4000, 1200),
('dac14', dacIndex(14), 0, 4000, 1600),
('dac15', dacIndex(15), 0, 4000, 1455),
('dac16', dacIndex(16), 0, 4000, 0),
('dac17', dacIndex(17), 0, 4000, 1000),
]
_dacnames = [_d[0] for _d in _dacs]
from .utils import element
class Ctb(Detector):
def __init__(self, id = 0):
super().__init__(id)
self._frozen = False
self._dacs = CtbDacs(self)
@property
def dacs(self):
return self._dacs

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,33 +1,18 @@
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
dacIndex = slsDetectorDefs.dacIndex dacIndex = slsDetectorDefs.dacIndex
from .utils import element_if_equal, all_equal, get_set_bits, list_to_bitmask from .utils import element_if_equal, all_equal, get_set_bits, list_to_bitmask
from .utils import Geometry, to_geo from .utils import Geometry, to_geo, element
from .registers import Register, Adc_register from .registers import Register, Adc_register
import datetime as dt import datetime as dt
from functools import wraps from functools import wraps
from collections import namedtuple from collections import namedtuple
# class Register:
# """
# Helper class to read and write to registers using a
# more Pythonic syntax
# """
# def __init__(self, detector):
# self._detector = detector
# def __getitem__(self, key):
# return self._detector.readRegister(key)
# def __setitem__(self, key, value):
# self._detector.writeRegister(key, value)
def freeze(cls): def freeze(cls):
cls._frozen = False cls._frozen = False
@ -774,6 +759,22 @@ class Detector(CppDetectorApi):
CTB stuff CTB stuff
""" """
@property
def runclk(self):
return element_if_equal(self.getRUNClock())
@runclk.setter
def runclk(self, freq):
self.setRUNClock(freq)
@property
def romode(self):
return element_if_equal(self.getReadoutMode())
@romode.setter
def romode(self, mode):
self.setReadoutMode(mode)
@property @property
def asamples(self): def asamples(self):
return element_if_equal(self.getNumberOfAnalogSamples()) return element_if_equal(self.getNumberOfAnalogSamples())
@ -839,9 +840,249 @@ class Detector(CppDetectorApi):
return element_if_equal(self.getMaxADCPhaseShift()) return element_if_equal(self.getMaxADCPhaseShift())
@property @property
def maxclkphaseshift(self): def adcphase(self):
return element_if_equal(self.getMaxClockPhaseShift()) return element_if_equal(self.getADCPhase())
@adcphase.setter
def adcphase(self, value):
self.setADCPhase(value)
@property @property
def adcphase(self): def adcpipeline(self):
return element_if_equal() return element_if_equal(self.getADCPipeline())
@adcpipeline.setter
def adcpipeline(self, value):
self.setADCPipeline(value)
@property
def adcclk(self):
return element_if_equal(self.getADCClock())
@adcclk.setter
def adcclk(self, value):
self.setADCClock(value)
@property
def syncclk(self):
return element_if_equal(self.getSYNCClock())
@property
def pattern(self):
#TODO! Clean fix
print("Set only")
return 0
@property
def patclkctrl(self):
return element_if_equal(self.getPatternClockControl())
@patclkctrl.setter
def patclkctrl(self, mask):
self.setPatternClockControl(mask)
# patioctrl
@property
def patioctrl(self):
return element_if_equal(self.getPatternIOControl())
@patioctrl.setter
def patioctrl(self, mask):
self.setPatternIOControl(mask)
@property
def patlimits(self):
return element_if_equal(self.getPatternLoopAddresses(-1))
@patlimits.setter
def patlimits(self, lim):
self.setPatternLoopAddresses(-1, lim[0], lim[1])
@property
def patmask(self):
return element_if_equal(self.getPatternMask())
@patmask.setter
def patmask(self, mask):
self.setPatternMask(mask)
@pattern.setter
def pattern(self, fname):
self.setPattern(fname)
@property
def patwait0(self):
return element_if_equal(self.getPatternWaitAddr(0))
@patwait0.setter
def patwait0(self, addr):
self.setPatternWaitAddr(0, addr)
@property
def patwait1(self):
return element_if_equal(self.getPatternWaitAddr(1))
@patwait1.setter
def patwait1(self, addr):
self.setPatternWaitAddr(1, addr)
@property
def patwait2(self):
return element_if_equal(self.getPatternWaitAddr(2))
@patwait2.setter
def patwait2(self, addr):
self.setPatternWaitAddr(2, addr)
@property
def patwaittime0(self):
return element_if_equal(self.getPatternWaitTime(0))
@patwaittime0.setter
def patwaittime0(self, nclk):
self.setPatternWaitTime(0, nclk)
@property
def patwaittime1(self):
return element_if_equal(self.getPatternWaitTime(1))
@patwaittime1.setter
def patwaittime1(self, nclk):
self.setPatternWaitTime(1, nclk)
@property
def patwaittime2(self):
return element_if_equal(self.getPatternWaitTime(2))
@patwaittime2.setter
def patwaittime2(self, nclk):
self.setPatternWaitTime(2, nclk)
@property
def patloop0(self):
return element_if_equal(self.getPatternLoopAddresses(0))
@patloop0.setter
def patloop0(self, addr):
self.setPatternLoopAddresses(0, addr[0], addr[1])
@property
def patloop1(self):
return element_if_equal(self.getPatternLoopAddresses(1))
@patloop1.setter
def patloop1(self, addr):
self.setPatternLoopAddresses(1, addr[0], addr[1])
@property
def patloop2(self):
return element_if_equal(self.getPatternLoopAddresses(2))
@patloop2.setter
def patloop2(self, addr):
self.setPatternLoopAddresses(2, addr[0], addr[1])
@property
def patnloop0(self):
return element_if_equal(self.getPatternLoopCycles(0))
@patnloop0.setter
def patnloop0(self, n):
self.setPatternLoopCycles(0, n)
@property
def patnloop1(self):
return element_if_equal(self.getPatternLoopCycles(1))
@patnloop1.setter
def patnloop1(self, n):
self.setPatternLoopCycles(1, n)
@property
def patnloop2(self):
return element_if_equal(self.getPatternLoopCycles(2))
@patnloop2.setter
def patnloop2(self, n):
self.setPatternLoopCycles(2, n)
@property
@element
def v_a(self):
return self.getDAC(dacIndex.V_POWER_A, True)
@v_a.setter
def v_a(self, value):
self.setDAC(dacIndex.V_POWER_A, value, True)
@property
@element
def v_b(self):
return self.getDAC(dacIndex.V_POWER_B, True)
@v_b.setter
def v_b(self, value):
self.setDAC(dacIndex.V_POWER_B, value, True)
@property
@element
def v_c(self):
return self.getDAC(dacIndex.V_POWER_C, True)
@v_c.setter
def v_c(self, value):
self.setDAC(dacIndex.V_POWER_C, value, True)
@property
@element
def v_d(self):
return self.getDAC(dacIndex.V_POWER_D, True)
@v_d.setter
def v_d(self, value):
self.setDAC(dacIndex.V_POWER_D, value, True)
@property
@element
def v_io(self):
return self.getDAC(dacIndex.V_POWER_IO, True)
@v_io.setter
def v_io(self, value):
self.setDAC(dacIndex.V_POWER_IO, value, True)
@property
@element
def v_limit(self):
return self.getDAC(dacIndex.V_LIMIT, True)
@v_limit.setter
def v_limit(self, value):
self.setDAC(dacIndex.V_LIMIT, value, True)
@property
@element
def im_a(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_A)
@property
@element
def im_b(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_B)
@property
@element
def im_c(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_C)
@property
@element
def im_d(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_D)
@property
@element
def im_io(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_IO)

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

@ -2,10 +2,13 @@
Utility functions that are useful for testing and troubleshooting Utility functions that are useful for testing and troubleshooting
but not directly used in controlling the detector 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
Geometry = namedtuple('Geometry', ['x', 'y']) Geometry = namedtuple('Geometry', ['x', 'y'])
def get_set_bits(mask): def get_set_bits(mask):
@ -26,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")
@ -65,3 +68,4 @@ def eiger_register_to_time(register):
clocks = register >> 3 clocks = register >> 3
exponent = register & 0b111 exponent = register & 0b111
return clocks*10**exponent / 100e6 return clocks*10**exponent / 100e6

View File

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

View File

@ -2,7 +2,7 @@ sls_detector - Python interface for the slsDetectorsPackage
============================================================== ==============================================================
sls_detector provide Python bindings to the slsDetectorsPackage using mainly the sls_detector provide Python bindings to the slsDetectorsPackage using mainly the
multiSlsDetector API. This module contains two parts, a compiled C module to DetectorImpl API. This module contains two parts, a compiled C module to
expose the API and a Python class to offer a more Pythonic interface. expose the API and a Python class to offer a more Pythonic interface.

View File

@ -74,9 +74,12 @@ void init_det(py::module &m) {
py::arg() = Positions{}) py::arg() = Positions{})
.def("getNumberOfTriggersLeft", &Detector::getNumberOfTriggersLeft, .def("getNumberOfTriggersLeft", &Detector::getNumberOfTriggersLeft,
py::arg() = Positions{}) py::arg() = Positions{})
.def("getPeriodLeft", &Detector::getPeriodLeft, py::arg() = Positions{})
.def("getDelayAfterTriggerLeft", &Detector::getDelayAfterTriggerLeft, .def("getDelayAfterTriggerLeft", &Detector::getDelayAfterTriggerLeft,
py::arg() = Positions{}) py::arg() = Positions{})
.def("getPeriodLeft", &Detector::getPeriodLeft, py::arg() = Positions{}) .def("getTimingMode", &Detector::getTimingMode, py::arg() = Positions{})
.def("setTimingMode", &Detector::setTimingMode, py::arg(),
py::arg() = Positions{})
.def("getSpeed", &Detector::getSpeed, py::arg() = Positions{}) .def("getSpeed", &Detector::getSpeed, py::arg() = Positions{})
.def("setSpeed", &Detector::setSpeed, py::arg(), .def("setSpeed", &Detector::setSpeed, py::arg(),
py::arg() = Positions{}) py::arg() = Positions{})
@ -109,6 +112,9 @@ void init_det(py::module &m) {
py::arg(), py::arg() = Positions{}) py::arg(), py::arg() = Positions{})
.def("getHighVoltage", &Detector::getHighVoltage, .def("getHighVoltage", &Detector::getHighVoltage,
py::arg() = Positions{}) py::arg() = Positions{})
.def("getPowerChip", &Detector::getPowerChip, py::arg() = Positions{})
.def("setPowerChip", &Detector::setPowerChip, py::arg(),
py::arg() = Positions{})
.def("setHighVoltage", &Detector::setHighVoltage, py::arg(), .def("setHighVoltage", &Detector::setHighVoltage, py::arg(),
py::arg() = Positions{}) py::arg() = Positions{})
.def("getTemperature", &Detector::getTemperature, py::arg(), .def("getTemperature", &Detector::getTemperature, py::arg(),
@ -121,9 +127,6 @@ void init_det(py::module &m) {
py::arg() = Positions{}) py::arg() = Positions{})
.def("setOnChipDAC", &Detector::setOnChipDAC, py::arg(), py::arg(), .def("setOnChipDAC", &Detector::setOnChipDAC, py::arg(), py::arg(),
py::arg(), py::arg() = Positions{}) py::arg(), py::arg() = Positions{})
.def("getTimingMode", &Detector::getTimingMode, py::arg() = Positions{})
.def("setTimingMode", &Detector::setTimingMode, py::arg(),
py::arg() = Positions{})
.def("acquire", &Detector::acquire) .def("acquire", &Detector::acquire)
.def("clearAcquiringFlag", &Detector::clearAcquiringFlag) .def("clearAcquiringFlag", &Detector::clearAcquiringFlag)
.def("startReceiver", &Detector::startReceiver) .def("startReceiver", &Detector::startReceiver)
@ -395,9 +398,6 @@ void init_det(py::module &m) {
py::arg() = Positions{}) py::arg() = Positions{})
.def("resetTemperatureEvent", &Detector::resetTemperatureEvent, .def("resetTemperatureEvent", &Detector::resetTemperatureEvent,
py::arg() = Positions{}) py::arg() = Positions{})
.def("getPowerChip", &Detector::getPowerChip, py::arg() = Positions{})
.def("setPowerChip", &Detector::setPowerChip, py::arg(),
py::arg() = Positions{})
.def("getAutoCompDisable", &Detector::getAutoCompDisable, .def("getAutoCompDisable", &Detector::getAutoCompDisable,
py::arg() = Positions{}) py::arg() = Positions{})
.def("setAutoCompDisable", &Detector::setAutoCompDisable, py::arg(), .def("setAutoCompDisable", &Detector::setAutoCompDisable, py::arg(),
@ -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(),
@ -438,9 +445,17 @@ void init_det(py::module &m) {
py::arg(), py::arg(), py::arg() = Positions{}) py::arg(), py::arg(), py::arg() = Positions{})
.def("setVetoReference", &Detector::setVetoReference, py::arg(), .def("setVetoReference", &Detector::setVetoReference, py::arg(),
py::arg(), py::arg() = Positions{}) py::arg(), 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("getBurstMode", &Detector::getBurstMode, 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

@ -169,7 +169,7 @@ void init_enums(py::module &m) {
.value("VB_COMP_FE", slsDetectorDefs::dacIndex::VB_COMP_FE) .value("VB_COMP_FE", slsDetectorDefs::dacIndex::VB_COMP_FE)
.value("VB_COMP_ADC", slsDetectorDefs::dacIndex::VB_COMP_ADC) .value("VB_COMP_ADC", slsDetectorDefs::dacIndex::VB_COMP_ADC)
.value("VCOM_CDS", slsDetectorDefs::dacIndex::VCOM_CDS) .value("VCOM_CDS", slsDetectorDefs::dacIndex::VCOM_CDS)
.value("VREF_RESTORE", slsDetectorDefs::dacIndex::VREF_RESTORE) .value("VREF_RSTORE", slsDetectorDefs::dacIndex::VREF_RSTORE)
.value("VB_OPA_1ST", slsDetectorDefs::dacIndex::VB_OPA_1ST) .value("VB_OPA_1ST", slsDetectorDefs::dacIndex::VB_OPA_1ST)
.value("VREF_COMP_FE", slsDetectorDefs::dacIndex::VREF_COMP_FE) .value("VREF_COMP_FE", slsDetectorDefs::dacIndex::VREF_COMP_FE)
.value("VCOM_ADC1", slsDetectorDefs::dacIndex::VCOM_ADC1) .value("VCOM_ADC1", slsDetectorDefs::dacIndex::VCOM_ADC1)
@ -278,4 +278,17 @@ void init_enums(py::module &m) {
slsDetectorDefs::detectorModeType::INTERPOLATING) slsDetectorDefs::detectorModeType::INTERPOLATING)
.value("ANALOG", slsDetectorDefs::detectorModeType::ANALOG) .value("ANALOG", slsDetectorDefs::detectorModeType::ANALOG)
.export_values(); .export_values();
py::enum_<slsDetectorDefs::burstMode>(Defs, "burstMode")
.value("BURST_OFF", slsDetectorDefs::burstMode::BURST_OFF)
.value("BURST_INTERNAL", slsDetectorDefs::burstMode::BURST_INTERNAL)
.value("BURST_EXTERNAL", slsDetectorDefs::burstMode::BURST_EXTERNAL)
.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

@ -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;
} }
} }
@ -428,7 +449,7 @@ int main(int argc, char *argv[]) {
// } // }
dout[ix]=detimage[ix]; dout[ix]=detimage[ix];
if (dout[ix]<0) dout[ix]=0; if (dout[ix]<0) dout[ix]=0;
// cout << ix << " " << dout[ix] << endl; //cout << ix << " " << dout[ix] << endl;
// } // }
} }
} }
@ -448,42 +469,48 @@ 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, 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);
#endif // #endif
#endif // #endif
#ifdef DEVELOPER
// #ifdef DEVELOPER
#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); 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
#ifdef MOENCH_BRANCH #ifndef CTBGUI
/* zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,1,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
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
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);
*/
#endif #endif
// #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
// 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);
// */
// #endif
@ -577,6 +604,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 +614,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 +645,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 +719,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 +774,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
@ -778,9 +815,6 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
zmqsocket->ReceiveData(0, dummybuff, size); zmqsocket->ReceiveData(0, dummybuff, size);
} }
iframe++; iframe++;
} // exiting infinite loop } // exiting infinite loop

View File

@ -17,7 +17,7 @@
#include <pthread.h> #include <pthread.h>
#include "analogDetector.h" #include "analogDetector.h"
#include "circularFifo.h" #include "CircularFifo.h"
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -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

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

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

@ -98,6 +98,8 @@ 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; QFutureWatcher<std::string> *acqResultWatcher;
@ -124,6 +126,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};
@ -160,4 +163,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
unsigned int nPixelsY{0}; unsigned int nPixelsY{0};
const static int npixelsx_jctb = 400; const static int npixelsx_jctb = 400;
int npixelsy_jctb{0}; int npixelsy_jctb{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

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

@ -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,30 @@ SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
} }
SlsQt2DPlot::~SlsQt2DPlot() {
if (d_spectrogram) {
d_spectrogram->detach();
}
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

@ -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();
@ -229,6 +231,7 @@ void qDetectorMain::SetUpDetector(const std::string fName, int multiID) {
case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::MOENCH: case slsDetectorDefs::MOENCH:
case slsDetectorDefs::MYTHEN3: case slsDetectorDefs::MYTHEN3:
case slsDetectorDefs::GOTTHARD2:
break; break;
default: default:
std::ostringstream os; std::ostringstream os;
@ -446,7 +449,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, Gotthard, Jungfrau and Moench.<br><br>" "Eiger, Jungfrau, 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

@ -32,6 +32,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 +41,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)
@ -52,6 +58,25 @@ qDrawPlot::~qDrawPlot() {
void qDrawPlot::SetupWidgetWindow() { void qDrawPlot::SetupWidgetWindow() {
detType = det->getDetectorType().squash(); detType = det->getDetectorType().squash();
switch (detType) {
case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::MOENCH:
pixelMask = ((1 << 14) - 1);
gainMask = (3 << 14);
gainOffset = 14;
FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask
<< ", Gain Mask:" << gainMask << ", Gain Offset:" << std::dec << gainOffset;
break;
case slsDetectorDefs::GOTTHARD2:
pixelMask = ((1 << 12) - 1);
gainMask = (3 << 12);
gainOffset = 12;
FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask
<< ", Gain Mask:" << gainMask << ", Gain Offset:" << std::dec << gainOffset;
break;
default:
break;
}
// save // save
try { try {
std::string temp = det->getFilePath().squash("/tmp/"); std::string temp = det->getFilePath().squash("/tmp/");
@ -141,12 +166,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;
@ -184,17 +237,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);
} }
@ -203,6 +260,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();
} }
@ -317,9 +378,11 @@ void qDrawPlot::SetDataCallBack(bool enable) {
FILE_LOG(logINFO) << "Setting data call back to " << std::boolalpha << enable << std::noboolalpha; FILE_LOG(logINFO) << "Setting data call back to " << std::boolalpha << enable << std::noboolalpha;
if (enable) { if (enable) {
isPlot = true; isPlot = true;
det->setRxZmqDataStream(true);
det->registerDataCallback(&(GetDataCallBack), this); det->registerDataCallback(&(GetDataCallBack), this);
} else { } else {
isPlot = false; isPlot = false;
det->setRxZmqDataStream(false);
det->registerDataCallback(nullptr, this); det->registerDataCallback(nullptr, this);
} }
@ -532,6 +595,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() {
@ -651,7 +717,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);
@ -804,6 +871,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;
@ -879,7 +960,7 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, int data
int halfbyte = 0; int halfbyte = 0;
char cbyte = '\0'; char cbyte = '\0';
// mythen 3 debugging // mythen3 / gotthard2 debugging
int discardBits = numDiscardBits; int discardBits = numDiscardBits;
switch (dr) { switch (dr) {
@ -903,14 +984,15 @@ 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::MOENCH ||
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 & 0x3FFF); dest[ichan] = (temp & pixelMask);
source += 2; source += 2;
} }
} }
@ -918,7 +1000,7 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, int data
// only data plot // only data plot
else { else {
for (ichan = 0; ichan < size; ++ichan) { for (ichan = 0; ichan < size; ++ichan) {
dest[ichan] = ((*((u_int16_t *)source)) & 0x3FFF); dest[ichan] = ((*((u_int16_t *)source)) & pixelMask);
source += 2; source += 2;
} }
} }

View File

@ -30,6 +30,7 @@ void qTabAdvanced::SetupWidgetWindow() {
tab_roi->setEnabled(true); tab_roi->setEnabled(true);
break; break;
case slsDetectorDefs::MYTHEN3: case slsDetectorDefs::MYTHEN3:
case slsDetectorDefs::GOTTHARD2:
lblDiscardBits->setEnabled(true); lblDiscardBits->setEnabled(true);
spinDiscardBits->setEnabled(true); spinDiscardBits->setEnabled(true);
default: default:
@ -361,7 +362,7 @@ void qTabAdvanced::SetDetectorUDPIP() {
std::string s = dispDetectorUDPIP->text().toAscii().constData(); std::string s = dispDetectorUDPIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Detector UDP IP:" << s; FILE_LOG(logINFO) << "Setting Detector UDP IP:" << s;
try { try {
det->setSourceUDPIP(s, {comboDetector->currentIndex()}); det->setSourceUDPIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Detector UDP IP.", } CATCH_HANDLE ("Could not set Detector UDP IP.",
"qTabAdvanced::SetDetectorUDPIP", this, "qTabAdvanced::SetDetectorUDPIP", this,
&qTabAdvanced::GetDetectorUDPIP) &qTabAdvanced::GetDetectorUDPIP)
@ -371,7 +372,7 @@ void qTabAdvanced::SetDetectorUDPMAC() {
std::string s = dispDetectorUDPMAC->text().toAscii().constData(); std::string s = dispDetectorUDPMAC->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Detector UDP MAC:" << s; FILE_LOG(logINFO) << "Setting Detector UDP MAC:" << s;
try { try {
det->setSourceUDPMAC(s, {comboDetector->currentIndex()}); det->setSourceUDPMAC(sls::MacAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Detector UDP MAC.", } CATCH_HANDLE ("Could not set Detector UDP MAC.",
"qTabAdvanced::SetDetectorUDPMAC", this, "qTabAdvanced::SetDetectorUDPMAC", this,
&qTabAdvanced::GetDetectorUDPMAC) &qTabAdvanced::GetDetectorUDPMAC)
@ -390,7 +391,7 @@ void qTabAdvanced::SetCltZMQIP() {
std::string s = dispZMQIP->text().toAscii().constData(); std::string s = dispZMQIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Client ZMQ IP:" << s; FILE_LOG(logINFO) << "Setting Client ZMQ IP:" << s;
try { try {
det->setClientZmqIp(s, {comboDetector->currentIndex()}); det->setClientZmqIp(sls::IpAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Client ZMQ IP.", } CATCH_HANDLE ("Could not set Client ZMQ IP.",
"qTabAdvanced::SetCltZMQIP", this, "qTabAdvanced::SetCltZMQIP", this,
&qTabAdvanced::GetCltZMQIP) &qTabAdvanced::GetCltZMQIP)
@ -431,7 +432,7 @@ void qTabAdvanced::SetRxrUDPIP() {
std::string s = dispRxrUDPIP->text().toAscii().constData(); std::string s = dispRxrUDPIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver UDP IP:" << s; FILE_LOG(logINFO) << "Setting Receiver UDP IP:" << s;
try { try {
det->setDestinationUDPIP(s, {comboDetector->currentIndex()}); det->setDestinationUDPIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver UDP IP.", } CATCH_HANDLE ("Could not set Receiver UDP IP.",
"qTabAdvanced::SetRxrUDPIP", this, "qTabAdvanced::SetRxrUDPIP", this,
&qTabAdvanced::GetRxrUDPIP) &qTabAdvanced::GetRxrUDPIP)
@ -441,7 +442,7 @@ void qTabAdvanced::SetRxrUDPMAC() {
std::string s = dispRxrUDPMAC->text().toAscii().constData(); std::string s = dispRxrUDPMAC->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver UDP MAC:" << s; FILE_LOG(logINFO) << "Setting Receiver UDP MAC:" << s;
try { try {
det->setDestinationUDPMAC(s, {comboDetector->currentIndex()}); det->setDestinationUDPMAC(sls::MacAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver UDP MAC.", } CATCH_HANDLE ("Could not set Receiver UDP MAC.",
"qTabAdvanced::SetRxrUDPMAC", this, "qTabAdvanced::SetRxrUDPMAC", this,
&qTabAdvanced::GetRxrUDPMAC) &qTabAdvanced::GetRxrUDPMAC)
@ -460,7 +461,7 @@ void qTabAdvanced::SetRxrZMQIP() {
std::string s = dispRxrZMQIP->text().toAscii().constData(); std::string s = dispRxrZMQIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver ZMQ IP:" << s; FILE_LOG(logINFO) << "Setting Receiver ZMQ IP:" << s;
try { try {
det->setRxZmqIP(s, {comboDetector->currentIndex()}); det->setRxZmqIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver ZMQ IP.", } CATCH_HANDLE ("Could not set Receiver ZMQ IP.",
"qTabAdvanced::SetRxrZMQIP", this, "qTabAdvanced::SetRxrZMQIP", this,
&qTabAdvanced::GetRxrZMQIP) &qTabAdvanced::GetRxrZMQIP)

View File

@ -113,6 +113,26 @@ void qTabDeveloper::SetupWidgetWindow() {
dacWidgets.push_back(new qDacWidget(this, det, true, "vtrim: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(this, det, true, "vtrim: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vdcsh: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(this, det, true, "vdcsh: ", getSLSIndex(detType, tempid++)));
break; break;
case slsDetectorDefs::GOTTHARD2:
lblSpinHV->show();
spinHV->show();
hvmin = 0;
dacWidgets.push_back(new qDacWidget(this, det, true, "vref_h_adc: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vb_comp_fe: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vb_comp_adc: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vcom_cds: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vref_rstore: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vb_opa_1st: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vref_comp_fe: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vcom_adc1: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vref_prech: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vref_l_adc: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vref_cds: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vb_cs: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vb_opa_fd: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vcom_adc2: ", getSLSIndex(detType, tempid++)));
break;
default: default:
break; break;
} }
@ -367,6 +387,41 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorTy
} }
break; break;
case slsDetectorDefs::GOTTHARD2:
switch (index) {
case 0:
return slsDetectorDefs::VREF_H_ADC;
case 1:
return slsDetectorDefs::VB_COMP_FE;
case 2:
return slsDetectorDefs::VB_COMP_ADC;
case 3:
return slsDetectorDefs::VCOM_CDS;
case 4:
return slsDetectorDefs::VREF_RSTORE;
case 5:
return slsDetectorDefs::VB_OPA_1ST;
case 6:
return slsDetectorDefs::VREF_COMP_FE;
case 7:
return slsDetectorDefs::VCOM_ADC1;
case 8:
return slsDetectorDefs::VREF_PRECH;
case 9:
return slsDetectorDefs::VREF_L_ADC;
case 10:
return slsDetectorDefs::VREF_CDS;
case 11:
return slsDetectorDefs::VB_CS;
case 12:
return slsDetectorDefs::VB_OPA_FD;
case 13:
return slsDetectorDefs::VCOM_ADC2;
default:
throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index));
}
break;
default: default:
throw sls::RuntimeError(std::string("Unknown detector type")); throw sls::RuntimeError(std::string("Unknown detector type"));
} }

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

@ -62,12 +62,20 @@ void qTabPlot::SetupWidgetWindow() {
case slsDetectorDefs::MYTHEN3: case slsDetectorDefs::MYTHEN3:
is1d = true; is1d = true;
break; break;
case slsDetectorDefs::GOTTHARD2:
is1d = true;
chkGainPlot1D->setEnabled(true);
chkGainPlot1D->setChecked(true);
plot->EnableGainPlot(true);
break;
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
chkGapPixels->setEnabled(true); chkGapPixels->setEnabled(true);
break; break;
case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::MOENCH: case slsDetectorDefs::MOENCH:
chkGainPlot->setEnabled(true); chkGainPlot->setEnabled(true);
chkGainPlot->setChecked(true);
plot->EnableGainPlot(true);
break; break;
default: default:
break; break;
@ -127,6 +135,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)));
@ -578,6 +588,9 @@ void qTabPlot::Refresh() {
case slsDetectorDefs::MOENCH: case slsDetectorDefs::MOENCH:
chkGainPlot->setEnabled(true); chkGainPlot->setEnabled(true);
break; break;
case slsDetectorDefs::GOTTHARD2:
chkGainPlot1D->setEnabled(true);
break;
default: default:
break; break;
} }
@ -585,6 +598,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

@ -83,6 +83,11 @@ void qTabSettings::SetupDetectorSettings() {
item[(int)FORCESWITCHG1]->setEnabled(true); item[(int)FORCESWITCHG1]->setEnabled(true);
item[(int)FORCESWITCHG2]->setEnabled(true); item[(int)FORCESWITCHG2]->setEnabled(true);
break; break;
case slsDetectorDefs::GOTTHARD2:
item[(int)DYNAMICGAIN]->setEnabled(true);
item[(int)FIXGAIN1]->setEnabled(true);
item[(int)FIXGAIN2]->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

@ -15,7 +15,7 @@ add_executable(ctbDetectorServer_virtual
../slsDetectorServer/src/INA226.c ../slsDetectorServer/src/INA226.c
../slsDetectorServer/src/LTC2620.c ../slsDetectorServer/src/LTC2620.c
../slsDetectorServer/src/MAX1932.c ../slsDetectorServer/src/MAX1932.c
../slsDetectorServer/src/programfpga.c ../slsDetectorServer/src/programFpgaBlackfin.c
) )
include_directories( include_directories(

View File

@ -12,7 +12,7 @@ DESTDIR ?= bin
INSTMODE = 0777 INSTMODE = 0777
SRCS = slsDetectorFunctionList.c SRCS = slsDetectorFunctionList.c
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD7689.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)I2C.c $(main_src)INA226.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programfpga.c SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD7689.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)I2C.c $(main_src)INA226.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c
OBJS = $(SRCS:.c=.o) OBJS = $(SRCS:.c=.o)

View File

@ -12,9 +12,6 @@
#include "INA226.h" // i2c #include "INA226.h" // i2c
#include "ALTERA_PLL.h" // pll #include "ALTERA_PLL.h" // pll
#include "blackfin.h" #include "blackfin.h"
#ifndef VIRTUAL
#include "programfpga.h"
#endif
#include <string.h> #include <string.h>
#include <unistd.h> // usleep #include <unistd.h> // usleep
@ -56,9 +53,9 @@ uint32_t adcEnableMask_1g = 0;
uint8_t adcEnableMask_10g = 0; uint8_t adcEnableMask_10g = 0;
int32_t clkPhase[NUM_CLOCKS] = {0, 0, 0, 0}; int32_t clkPhase[NUM_CLOCKS] = {};
uint32_t clkFrequency[NUM_CLOCKS] = {40, 20, 20, 200}; uint32_t clkFrequency[NUM_CLOCKS] = {40, 20, 20, 200};
int dacValues[NDAC] = {0}; int dacValues[NDAC] = {};
// software limit that depends on the current chip on the ctb // software limit that depends on the current chip on the ctb
int vLimit = 0; int vLimit = 0;
int highvoltage = 0; int highvoltage = 0;
@ -1418,9 +1415,7 @@ int setHighVoltage(int val){
void setTiming( enum timingMode arg){ void setTiming( enum timingMode arg){
switch(arg){
if(arg != GET_TIMING_MODE){
switch((int)arg){
case AUTO_TIMING: case AUTO_TIMING:
FILE_LOG(logINFO, ("Set Timing: Auto\n")); FILE_LOG(logINFO, ("Set Timing: Auto\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK); bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
@ -1431,8 +1426,6 @@ void setTiming( enum timingMode arg){
break; break;
default: default:
FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg)); FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg));
return;
}
} }
} }
@ -2559,7 +2552,7 @@ int calculateDataBytes(){
return dataBytes; return dataBytes;
} }
int getTotalNumberOfChannels(){return ((int)getNumberOfChannelsPerChip() * (int)getNumberOfChips());} int getTotalNumberOfChannels() {return (getNumberOfChannelsPerChip() * getNumberOfChips());}
int getNumberOfChips(){return NCHIP;} int getNumberOfChips(){return NCHIP;}
int getNumberOfDACs(){return NDAC;} int getNumberOfDACs(){return NDAC;}
int getNumberOfChannelsPerChip(){return NCHAN;} int getNumberOfChannelsPerChip(){return NCHAN;}

View File

@ -1106,36 +1106,46 @@ int setHighVoltage(int val) {
/* parameters - timing, extsig */ /* parameters - timing, extsig */
void setTiming( enum timingMode arg) { void setTiming( enum timingMode arg) {
enum timingMode ret=GET_TIMING_MODE; int ret = 0;
if (arg != GET_TIMING_MODE) { switch(arg) {
switch((int)arg) { case AUTO_TIMING:
case AUTO_TIMING: ret = 0; break; ret = 0;
case TRIGGER_EXPOSURE: ret = 2; break; break;
case BURST_TRIGGER: ret = 1; break; case TRIGGER_EXPOSURE:
case GATED: ret = 3; break; ret = 2;
break;
case BURST_TRIGGER:
ret = 1;
break;
case GATED:
ret = 3;
break;
default:
FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg));
return;
} }
FILE_LOG(logDEBUG1, ("Setting Triggering Mode: %d\n", (int)ret)); FILE_LOG(logDEBUG1, ("Setting Triggering Mode: %d\n", (int)ret));
#ifndef VIRTUAL #ifndef VIRTUAL
if (Feb_Control_SetTriggerMode(ret,1)) if (Feb_Control_SetTriggerMode(ret,1))
#endif #endif
eiger_triggermode = ret; eiger_triggermode = ret;
}
} }
enum timingMode getTiming() { enum timingMode getTiming() {
enum timingMode ret = GET_TIMING_MODE; switch(eiger_triggermode) {
ret = eiger_triggermode; case 0:
switch((int)ret) { return AUTO_TIMING;
case 0: ret = AUTO_TIMING; break; case 2:
case 2: ret = TRIGGER_EXPOSURE; break; return TRIGGER_EXPOSURE;
case 1: ret = BURST_TRIGGER; break; case 1:
case 3: ret = GATED; break; return BURST_TRIGGER;
case 3:
return GATED;
default: default:
FILE_LOG(logERROR, ("Unknown trigger mode found %d\n", ret)); FILE_LOG(logERROR, ("Unknown trigger mode found %d\n", eiger_triggermode));
ret = 0; return GET_TIMING_MODE;
} }
return ret;
} }
@ -2041,7 +2051,7 @@ int calculateDataBytes() {
int getTotalNumberOfChannels() {return ((int)getNumberOfChannelsPerChip() * (int)getNumberOfChips());} int getTotalNumberOfChannels() {return (getNumberOfChannelsPerChip() * getNumberOfChips());}
int getNumberOfChips() {return NCHIP;} int getNumberOfChips() {return NCHIP;}
int getNumberOfDACs() {return NDAC;} int getNumberOfDACs() {return NDAC;}
int getNumberOfChannelsPerChip() {return NCHAN;} int getNumberOfChannelsPerChip() {return NCHAN;}

View File

@ -19,7 +19,7 @@ enum DACINDEX {E_SVP,E_VTR,E_VRF,E_VRS,E_SVN,E_VTGSTV,E_VCMP_LL,E_VCMP_L
2556, /* Vtgstv */ \ 2556, /* Vtgstv */ \
1000, /* Vcmp_ll */ \ 1000, /* Vcmp_ll */ \
1000, /* Vcmp_lr */ \ 1000, /* Vcmp_lr */ \
4000, /* cal */ \ 0, /* cal */ \
1000, /* Vcmp_rl */ \ 1000, /* Vcmp_rl */ \
1100, /* rxb_rb */ \ 1100, /* rxb_rb */ \
1100, /* rxb_lb */ \ 1100, /* rxb_lb */ \

View File

@ -10,6 +10,7 @@ add_executable(gotthard2DetectorServer_virtual
../slsDetectorServer/src/LTC2620_Driver.c ../slsDetectorServer/src/LTC2620_Driver.c
../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c ../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c
../slsDetectorServer/src/ASIC_Driver.c ../slsDetectorServer/src/ASIC_Driver.c
../slsDetectorServer/src/programFpgaNios.c
) )
include_directories( include_directories(
@ -22,7 +23,7 @@ target_include_directories(gotthard2DetectorServer_virtual
) )
target_compile_definitions(gotthard2DetectorServer_virtual target_compile_definitions(gotthard2DetectorServer_virtual
PUBLIC GOTTHARD2D VIRTUAL STOP_SERVER PUBLIC GOTTHARD2D VIRTUAL STOP_SERVER DEBUG1
) )
target_link_libraries(gotthard2DetectorServer_virtual target_link_libraries(gotthard2DetectorServer_virtual

View File

@ -12,7 +12,7 @@ DESTDIR ?= bin
INSTMODE = 0777 INSTMODE = 0777
SRCS = slsDetectorFunctionList.c SRCS = slsDetectorFunctionList.c
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)common.c $(main_src)DAC6571.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c $(main_src)ASIC_Driver.c SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)common.c $(main_src)DAC6571.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c $(main_src)ASIC_Driver.c $(main_src)/programFpgaNios.c
OBJS = $(SRCS:.c=.o) OBJS = $(SRCS:.c=.o)

View File

@ -14,13 +14,33 @@
/* Base addresses 0x1806 0000 ---------------------------------------------*/ /* Base addresses 0x1806 0000 ---------------------------------------------*/
/* General purpose control and status registers */ /* General purpose control and status registers */
#define BASE_CONTROL (0x0000) #define BASE_CONTROL (0x0000) // 0x1806_0000 - 0x1806_00FF
/* Acquisition? TODO */ // https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/ctrl/ctrl.vhd
#define BASE_ACQUISITION (0x0200)
/* ASIC Control */
#define BASE_ASIC (0x0100) // 0x1806_0100 - 0x1806_011F
// https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/asic/asic_ctrl.vhd
/* ASIC Digital Interface. Data recovery core */
#define BASE_ADIF (0x0120) // 0x1806_0120 - 0x1806_012F
// https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/adif/adif_ctrl.vhd
/* Formatting of data core */
#define BASE_FMT (0x0130) // 0x1806_0130 - 0x1806_013F
/* Packetizer */
#define BASE_PKT (0x0140) // 0x1806_0140 - 0x1806_014F
// https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/pkt/pkt_ctrl.vhd
/* Flow control and status registers */
#define BASE_FLOW_CONTROL (0x00200) // 0x1806_0200 - 0x1806_02FF
// https://git.psi.ch/sls_detectors_firmware/vhdl_library/blob/f37608230b4721661f29aacc20124555705ee705/flow/flow_ctrl.vhd
/* UDP datagram generator */ /* UDP datagram generator */
#define BASE_UDP_RAM (0x01000) // 0x1806_1000 - 0x1806_1FFF #define BASE_UDP_RAM (0x01000) // 0x1806_1000 - 0x1806_1FFF
/* Clock Generation registers ------------------------------------------------------*/ /* Clock Generation registers ------------------------------------------------------*/
#define PLL_RESET_REG (0x00 * REG_OFFSET + BASE_CLK_GENERATION) #define PLL_RESET_REG (0x00 * REG_OFFSET + BASE_CLK_GENERATION)
@ -30,6 +50,7 @@
#define PLL_RESET_SYSTEM_MSK (0x00000001 << PLL_RESET_SYSTEM_OFST) #define PLL_RESET_SYSTEM_MSK (0x00000001 << PLL_RESET_SYSTEM_OFST)
/* Control registers --------------------------------------------------*/ /* Control registers --------------------------------------------------*/
/* Module Control Board Serial Number register */ /* Module Control Board Serial Number register */
@ -61,11 +82,6 @@
/* Status register */ /* Status register */
#define STATUS_REG (0x04 * REG_OFFSET + BASE_CONTROL) #define STATUS_REG (0x04 * REG_OFFSET + BASE_CONTROL)
#ifdef VIRTUAL
#define RUN_BUSY_OFST (0)
#define RUN_BUSY_MSK (0x00000001 << RUN_BUSY_OFST)
#endif
/* Look at me read only register */ /* Look at me read only register */
#define LOOK_AT_ME_REG (0x05 * REG_OFFSET + BASE_CONTROL) #define LOOK_AT_ME_REG (0x05 * REG_OFFSET + BASE_CONTROL)
@ -88,43 +104,148 @@
#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)
/* Pattern IO Control 64 bit register */ #define CONTROL_TIMING_SOURCE_EXT_MSK (0x00000001 << CONTROL_TIMING_SOURCE_EXT_OFST)
#define PATTERN_IO_CTRL_LSB_REG (0x22 * REG_OFFSET + BASE_CONTROL) #define CONTROL_PWR_CHIP_OFST (31)
#define PATTERN_IO_CTRL_MSB_REG (0x23 * REG_OFFSET + BASE_CONTROL) #define CONTROL_PWR_CHIP_MSK (0x00000001 << CONTROL_PWR_CHIP_OFST)
/** DTA Offset Register */ /** DTA Offset Register */
#define DTA_OFFSET_REG (0x24 * REG_OFFSET + BASE_CONTROL) #define DTA_OFFSET_REG (0x24 * REG_OFFSET + BASE_CONTROL)
/* ASIC registers --------------------------------------------------*/
/* ASIC Config register */
#define ASIC_CONFIG_REG (0x00 * REG_OFFSET + BASE_ASIC)
#define ASIC_CONFIG_RUN_MODE_OFST (0)
#define ASIC_CONFIG_RUN_MODE_MSK (0x00000003 << ASIC_CONFIG_RUN_MODE_OFST)
#define ASIC_CONFIG_RUN_MODE_INT_BURST_VAL ((0x1 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK)
#define ASIC_CONFIG_RUN_MODE_CONT_VAL ((0x2 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK)
#define ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL ((0x3 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK)
#define ASIC_CONFIG_GAIN_OFST (4)
#define ASIC_CONFIG_GAIN_MSK (0x00000003 << ASIC_CONFIG_GAIN_OFST)
#define ASIC_CONFIG_DYNAMIC_GAIN_VAL ((0x0 << 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_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_MSK (0x00000001 << ASIC_CONFIG_RST_DAC_OFST)
#define ASIC_CONFIG_DONE_OFST (31)
#define ASIC_CONFIG_DONE_MSK (0x00000001 << ASIC_CONFIG_DONE_OFST)
/* ASIC Internal Frames Register */
#define ASIC_INT_FRAMES_REG (0x01 * REG_OFFSET + BASE_ASIC)
#define ASIC_INT_FRAMES_OFST (0)
#define ASIC_INT_FRAMES_MSK (0x00000FFF << ASIC_INT_FRAMES_OFST)
/* ASIC Period 64bit Register */
#define ASIC_INT_PERIOD_LSB_REG (0x02 * REG_OFFSET + BASE_ASIC)
#define ASIC_INT_PERIOD_MSB_REG (0x03 * REG_OFFSET + BASE_ASIC)
/* ASIC Exptime 64bit Register */
#define ASIC_INT_EXPTIME_LSB_REG (0x04 * REG_OFFSET + BASE_ASIC)
#define ASIC_INT_EXPTIME_MSB_REG (0x05 * REG_OFFSET + BASE_ASIC)
/* Packetizer -------------------------------------------------------------*/
/* Packetizer Config Register */
#define PKT_CONFIG_REG (0x00 * REG_OFFSET + BASE_PKT)
#define PKT_CONFIG_NRXR_MAX_OFST (0)
#define PKT_CONFIG_NRXR_MAX_MSK (0x0000003F << PKT_CONFIG_NRXR_MAX_OFST)
#define PKT_CONFIG_RXR_START_ID_OFST (8)
#define PKT_CONFIG_RXR_START_ID_MSK (0x0000003F << PKT_CONFIG_RXR_START_ID_OFST)
/* Module Coordinates Register */
#define COORD_0_REG (0x02 * REG_OFFSET + BASE_PKT)
#define COORD_ROW_OFST (0)
#define COORD_ROW_MSK (0x0000FFFF << COORD_ROW_OFST)
#define COORD_COL_OFST (16)
#define COORD_COL_MSK (0x0000FFFF << COORD_COL_OFST)
/* Module ID Register */
#define COORD_1_REG (0x03 * REG_OFFSET + BASE_PKT)
#define COORD_RESERVED_OFST (0)
#define COORD_RESERVED_MSK (0x0000FFFF << COORD_RESERVED_OFST)
#define COORD_ID_OFST (16) // Not connected in firmware TODO
#define COORD_ID_MSK (0x0000FFFF << COORD_ID_OFST) // Not connected in firmware TODO
/* Flow control registers --------------------------------------------------*/
/* Flow status Register*/
#define FLOW_STATUS_REG (0x00 * REG_OFFSET + BASE_FLOW_CONTROL)
#define FLOW_STATUS_RUN_BUSY_OFST (0)
#define FLOW_STATUS_RUN_BUSY_MSK (0x00000001 << FLOW_STATUS_RUN_BUSY_OFST)
#define FLOW_STATUS_WAIT_FOR_TRGGR_OFST (3)
#define FLOW_STATUS_WAIT_FOR_TRGGR_MSK (0x00000001 << FLOW_STATUS_WAIT_FOR_TRGGR_OFST)
#define FLOW_STATUS_DLY_BFRE_TRGGR_OFST (4)
#define FLOW_STATUS_DLY_BFRE_TRGGR_MSK (0x00000001 << FLOW_STATUS_DLY_BFRE_TRGGR_OFST)
#define FLOW_STATUS_FIFO_FULL_OFST (5)
#define FLOW_STATUS_FIFO_FULL_MSK (0x00000001 << FLOW_STATUS_FIFO_FULL_OFST)
#define FLOW_STATUS_DLY_AFTR_TRGGR_OFST (15)
#define FLOW_STATUS_DLY_AFTR_TRGGR_MSK (0x00000001 << FLOW_STATUS_DLY_AFTR_TRGGR_OFST)
#define FLOW_STATUS_CSM_BUSY_OFST (17)
#define FLOW_STATUS_CSM_BUSY_MSK (0x00000001 << FLOW_STATUS_CSM_BUSY_OFST)
/* Delay left 64bit Register */
#define GET_DELAY_LSB_REG (0x02 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_DELAY_MSB_REG (0x03 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Acquisition registers --------------------------------------------------*/
//TODO
/* Triggers left 64bit Register */ /* Triggers left 64bit Register */
#define GET_CYCLES_LSB_REG (0x10 + BASE_ACQUISITION) #define GET_CYCLES_LSB_REG (0x04 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_CYCLES_MSB_REG (0x14 + BASE_ACQUISITION) #define GET_CYCLES_MSB_REG (0x05 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Frames left 64bit Register */ /* Frames left 64bit Register */
#define GET_FRAMES_LSB_REG (0x18 + BASE_ACQUISITION) #define GET_FRAMES_LSB_REG (0x06 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_FRAMES_MSB_REG (0x1C + BASE_ACQUISITION) #define GET_FRAMES_MSB_REG (0x07 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Period left 64bit Register */
#define GET_PERIOD_LSB_REG (0x08 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_PERIOD_MSB_REG (0x09 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Time from Start 64 bit register */
#define TIME_FROM_START_LSB_REG (0x0A * REG_OFFSET + BASE_FLOW_CONTROL)
#define TIME_FROM_START_MSB_REG (0x0B * REG_OFFSET + BASE_FLOW_CONTROL)
/* Get Frames from Start 64 bit register (frames from last reset using CONTROL_CRST) */
#define FRAMES_FROM_START_LSB_REG (0x0C * REG_OFFSET + BASE_FLOW_CONTROL)
#define FRAMES_FROM_START_MSB_REG (0x0D * REG_OFFSET + BASE_FLOW_CONTROL)
/* Measurement Time 64 bit register (timestamp at a frame start until reset)*/
#define START_FRAME_TIME_LSB_REG (0x0E * REG_OFFSET + BASE_FLOW_CONTROL)
#define START_FRAME_TIME_MSB_REG (0x0F * REG_OFFSET + BASE_FLOW_CONTROL)
/* Delay 64bit Write-register */ /* Delay 64bit Write-register */
#define SET_DELAY_LSB_REG (0x88 + BASE_ACQUISITION) #define SET_DELAY_LSB_REG (0x22 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_DELAY_MSB_REG (0x8C + BASE_ACQUISITION) #define SET_DELAY_MSB_REG (0x23 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Cylces 64bit Write-register */ /* Cylces 64bit Write-register */
#define SET_CYCLES_LSB_REG (0x90 + BASE_ACQUISITION) #define SET_CYCLES_LSB_REG (0x24 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_CYCLES_MSB_REG (0x94 + BASE_ACQUISITION) #define SET_CYCLES_MSB_REG (0x25 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Frames 64bit Write-register */ /* Frames 64bit Write-register */
#define SET_FRAMES_LSB_REG (0x98 + BASE_ACQUISITION) #define SET_FRAMES_LSB_REG (0x26 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_FRAMES_MSB_REG (0x9C + BASE_ACQUISITION) #define SET_FRAMES_MSB_REG (0x27 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Period 64bit Write-register */ /* Period 64bit Write-register */
#define SET_PERIOD_LSB_REG (0xA0 + BASE_ACQUISITION) #define SET_PERIOD_LSB_REG (0x28 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_PERIOD_MSB_REG (0xA4 + BASE_ACQUISITION) #define SET_PERIOD_MSB_REG (0x29 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Exptime 64bit Write-register */ /* External Signal register */
#define SET_EXPTIME_LSB_REG (0xA8 + BASE_ACQUISITION) #define EXT_SIGNAL_REG (0x30 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_EXPTIME_MSB_REG (0xBC + BASE_ACQUISITION)
#define EXT_SIGNAL_OFST (0)
#define EXT_SIGNAL_MSK (0x00000001 << EXT_SIGNAL_OFST)
/* Trigger Delay 64 bit register */
#define SET_TRIGGER_DELAY_LSB_REG (0x32 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_TRIGGER_DELAY_MSB_REG (0x33 * REG_OFFSET + BASE_FLOW_CONTROL)

View File

@ -11,7 +11,7 @@ vref_h_adc 2099
vb_comp_fe 0 vb_comp_fe 0
vb_comp_adc 0 vb_comp_adc 0
vcom_cds 1400 vcom_cds 1400
vref_restore 640 vref_rstore 640
vb_opa_1st 0 vb_opa_1st 0
vref_comp_fe 0 vref_comp_fe 0
vcom_adc1 1400 vcom_adc1 1400

View File

@ -17,22 +17,35 @@
#define HV_DRIVER_FILE_NAME ("/etc/devlinks/hvdac") #define HV_DRIVER_FILE_NAME ("/etc/devlinks/hvdac")
#define DAC_DRIVER_FILE_NAME ("/etc/devlinks/dac") #define DAC_DRIVER_FILE_NAME ("/etc/devlinks/dac")
#define ONCHIP_DAC_DRIVER_FILE_NAME ("/etc/devlinks/chipdac") #define ONCHIP_DAC_DRIVER_FILE_NAME ("/etc/devlinks/chipdac")
#define TYPE_FILE_NAME ("/etc/devlinks/type")
#define CONFIG_FILE ("config.txt") #define CONFIG_FILE ("config.txt")
#define DAC_MAX_MV (2048) #define DAC_MAX_MV (2048)
#define ONCHIP_DAC_MAX_VAL (0x3FF) #define ONCHIP_DAC_MAX_VAL (0x3FF)
#define ADU_MAX_VAL (0xFFF) #define ADU_MAX_VAL (0xFFF)
#define ADU_MAX_BITS (12) #define ADU_MAX_BITS (12)
#define MAX_FRAMES_IN_BURST_MODE (2720) #define MAX_FRAMES_IN_BURST_MODE (2720)
#define TYPE_GOTTHARD2_MODULE_VAL (512)
#define TYPE_TOLERANCE (10)
#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_NUM_FRAMES (1) #define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_NUM_CYCLES (1) #define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_EXPTIME (1 * 1000 * 1000) // 1 ms #define DEFAULT_NUM_BURSTS (1)
#define DEFAULT_PERIOD (1 * 1000 * 1000 * 1000) // 1 s #define DEFAULT_EXPTIME (0) // 0 ms (220ns in firmware)
#define DEFAULT_PERIOD (0) // 0 ms
#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_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 (288888896) // rdo_x2_clk, 288 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
#define DEFAULT_SYSTEM_C1 (72222224) // chip_clk, 72 MHz #define DEFAULT_SYSTEM_C1 (72222224) // chip_clk, 72 MHz
#define DEFAULT_SYSTEM_C2 (18055556) // sync_clk, 18 MHz #define DEFAULT_SYSTEM_C2 (18055556) // sync_clk, 18 MHz
@ -40,8 +53,9 @@
/* Firmware Definitions */ /* Firmware Definitions */
#define IP_HEADER_SIZE (20) #define IP_HEADER_SIZE (20)
#define READOUT_PLL_VCO_FREQ_HZ (866666688) // Hz #define FIXED_PLL_FREQUENCY (20000000) // 20MHz
#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)
@ -52,7 +66,7 @@ enum DACINDEX {G2_VREF_H_ADC, /* 0 */ \
G2_VB_COMP_FE, /* 2 */ \ G2_VB_COMP_FE, /* 2 */ \
G2_VB_COMP_ADC, /* 3 */ \ G2_VB_COMP_ADC, /* 3 */ \
G2_VCOM_CDS, /* 4 */ \ G2_VCOM_CDS, /* 4 */ \
G2_VREF_RESTORE,/* 5 */ \ G2_VREF_RSTORE,/* 5 */ \
G2_VB_OPA_1ST, /* 6 */ \ G2_VB_OPA_1ST, /* 6 */ \
G2_VREF_COMP_FE,/* 7 */ \ G2_VREF_COMP_FE,/* 7 */ \
G2_VCOM_ADC1, /* 8 */ \ G2_VCOM_ADC1, /* 8 */ \
@ -64,7 +78,7 @@ enum DACINDEX {G2_VREF_H_ADC, /* 0 */ \
G2_DAC_UNUSED2, /* 14 */ \ G2_DAC_UNUSED2, /* 14 */ \
G2_VCOM_ADC2 /* 15*/ \ G2_VCOM_ADC2 /* 15*/ \
}; };
#define DAC_NAMES "vref_h_adc", "dac_unused", "vb_comp_fe", "vb_comp_adc", "vcom_cds", "vref_restore", "vb_opa_1st", "vref_comp_fe", "vcom_adc1", "vref_prech", "vref_l_adc", "vref_cds", "vb_cs", "vb_opa_fd", "dac_unused2", "vcom_adc2" #define DAC_NAMES "vref_h_adc", "dac_unused", "vb_comp_fe", "vb_comp_adc", "vcom_cds", "vref_rstore", "vb_opa_1st", "vref_comp_fe", "vcom_adc1", "vref_prech", "vref_l_adc", "vref_cds", "vb_cs", "vb_opa_fd", "dac_unused2", "vcom_adc2"
enum ONCHIP_DACINDEX {G2_VCHIP_COMP_FE, /* 0 */ \ enum ONCHIP_DACINDEX {G2_VCHIP_COMP_FE, /* 0 */ \
G2_VCHIP_OPA_1ST, /* 1 */ \ G2_VCHIP_OPA_1ST, /* 1 */ \

View File

@ -30,10 +30,10 @@ int virtual_status = 0;
int virtual_stop = 0; int virtual_stop = 0;
int highvoltage = 0; int highvoltage = 0;
#endif #endif
int detPos[2] = {0, 0}; int detPos[2] = {};
int detectorFirstServer = 1; int detectorFirstServer = 1;
int dacValues[NDAC] = {0}; int dacValues[NDAC] = {};
enum detectorSettings thisSettings = UNINITIALIZED; enum detectorSettings thisSettings = UNINITIALIZED;
enum externalSignalFlag signalMode = 0; enum externalSignalFlag signalMode = 0;
@ -128,7 +128,7 @@ int checkType() {
#ifdef VIRTUAL #ifdef VIRTUAL
return OK; return OK;
#endif #endif
volatile u_int32_t type = ((bus_r(BOARD_REVISION_REG) & DETECTOR_TYPE_MSK) >> DETECTOR_TYPE_OFST); u_int32_t type = ((bus_r(BOARD_REVISION_REG) & DETECTOR_TYPE_MSK) >> DETECTOR_TYPE_OFST);
if (type == DETECTOR_TYPE_MOENCH_VAL){ if (type == DETECTOR_TYPE_MOENCH_VAL){
FILE_LOG(logERROR, ("This is not a Gotthard Server (read %d, expected ?)\n", type)); FILE_LOG(logERROR, ("This is not a Gotthard Server (read %d, expected ?)\n", type));
return FAIL; return FAIL;
@ -1178,9 +1178,7 @@ int setHighVoltage(int val){
void setTiming( enum timingMode arg){ void setTiming( enum timingMode arg){
u_int32_t addr = EXT_SIGNAL_REG; u_int32_t addr = EXT_SIGNAL_REG;
switch(arg) {
if (arg != GET_TIMING_MODE){
switch((int)arg){
case AUTO_TIMING: case AUTO_TIMING:
FILE_LOG(logINFO, ("Set Timing: Auto\n")); FILE_LOG(logINFO, ("Set Timing: Auto\n"));
bus_w(addr, EXT_SIGNAL_OFF_VAL); bus_w(addr, EXT_SIGNAL_OFF_VAL);
@ -1196,8 +1194,6 @@ void setTiming( enum timingMode arg){
break; break;
default: default:
FILE_LOG(logERROR, ("Unknown timing mode %d for this detector\n", (int)arg)); FILE_LOG(logERROR, ("Unknown timing mode %d for this detector\n", (int)arg));
return;
}
} }
} }
@ -1680,7 +1676,7 @@ int calculateDataBytes(){
return DATA_BYTES; return DATA_BYTES;
} }
int getTotalNumberOfChannels(){return ((int)getNumberOfChannelsPerChip() * (int)getNumberOfChips());} int getTotalNumberOfChannels() {return (getNumberOfChannelsPerChip() * getNumberOfChips());}
int getNumberOfChips(){return NCHIP;} int getNumberOfChips(){return NCHIP;}
int getNumberOfDACs(){return NDAC;} int getNumberOfDACs(){return NDAC;}
int getNumberOfChannelsPerChip(){return NCHAN;} int getNumberOfChannelsPerChip(){return NCHAN;}

View File

@ -10,7 +10,7 @@ add_executable(jungfrauDetectorServer_virtual
../slsDetectorServer/src/ALTERA_PLL.c ../slsDetectorServer/src/ALTERA_PLL.c
../slsDetectorServer/src/LTC2620.c ../slsDetectorServer/src/LTC2620.c
../slsDetectorServer/src/MAX1932.c ../slsDetectorServer/src/MAX1932.c
../slsDetectorServer/src/programfpga.c ../slsDetectorServer/src/programFpgaBlackfin.c
../slsDetectorServer/src/communication_funcs_UDP.c ../slsDetectorServer/src/communication_funcs_UDP.c
) )
@ -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

@ -12,7 +12,7 @@ DESTDIR ?= bin
INSTMODE = 0777 INSTMODE = 0777
SRCS = slsDetectorFunctionList.c SRCS = slsDetectorFunctionList.c
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programfpga.c SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c
OBJS = $(SRCS:.c=.o) OBJS = $(SRCS:.c=.o)

View File

@ -8,9 +8,7 @@
#include "ALTERA_PLL.h" // pll #include "ALTERA_PLL.h" // pll
#include "blackfin.h" #include "blackfin.h"
#include "common.h" #include "common.h"
#ifndef VIRTUAL #ifdef VIRTUAL
#include "programfpga.h"
#else
#include "communication_funcs_UDP.h" #include "communication_funcs_UDP.h"
#endif #endif
@ -24,6 +22,7 @@
// Global variable from slsDetectorServer_funcs // Global variable from slsDetectorServer_funcs
extern int debugflag; extern int debugflag;
extern udpStruct udpDetails; extern udpStruct udpDetails;
extern const enum detectorType myDetectorType;
int initError = OK; int initError = OK;
int initCheckDone = 0; int initCheckDone = 0;
@ -37,9 +36,9 @@ int virtual_stop = 0;
enum detectorSettings thisSettings = UNINITIALIZED; enum detectorSettings thisSettings = UNINITIALIZED;
int highvoltage = 0; int highvoltage = 0;
int dacValues[NDAC] = {0}; int dacValues[NDAC] = {};
int adcPhase = 0; int adcPhase = 0;
int detPos[4] = {0, 0, 0, 0}; int detPos[4] = {};
int numUDPInterfaces = 1; int numUDPInterfaces = 1;
@ -66,7 +65,6 @@ void basictests() {
} }
return; return;
#else #else
defineGPIOpins(); defineGPIOpins();
resetFPGA(); resetFPGA();
if (mapCSP0() == FAIL) { if (mapCSP0() == FAIL) {
@ -170,7 +168,7 @@ int checkType() {
#ifdef VIRTUAL #ifdef VIRTUAL
return OK; return OK;
#endif #endif
volatile u_int32_t type = ((bus_r(FPGA_VERSION_REG) & DETECTOR_TYPE_MSK) >> DETECTOR_TYPE_OFST); u_int32_t type = ((bus_r(FPGA_VERSION_REG) & DETECTOR_TYPE_MSK) >> DETECTOR_TYPE_OFST);
if (type != JUNGFRAU){ if (type != JUNGFRAU){
FILE_LOG(logERROR, ("This is not a Jungfrau Server (read %d, expected %d)\n", type, JUNGFRAU)); FILE_LOG(logERROR, ("This is not a Jungfrau Server (read %d, expected %d)\n", type, JUNGFRAU));
return FAIL; return FAIL;
@ -918,9 +916,7 @@ int setHighVoltage(int val){
void setTiming( enum timingMode arg){ void setTiming( enum timingMode arg){
switch(arg){
if(arg != GET_TIMING_MODE){
switch((int)arg){
case AUTO_TIMING: case AUTO_TIMING:
FILE_LOG(logINFO, ("Set Timing: Auto\n")); FILE_LOG(logINFO, ("Set Timing: Auto\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK); bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
@ -931,8 +927,6 @@ void setTiming( enum timingMode arg){
break; break;
default: default:
FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg)); FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg));
return;
}
} }
} }
@ -1667,7 +1661,7 @@ void* start_timer(void* arg) {
usleep(exp_us); usleep(exp_us);
const int size = datasize + 112; const int size = datasize + sizeof(sls_detector_header);
char packetData[size]; char packetData[size];
memset(packetData, 0, sizeof(sls_detector_header)); memset(packetData, 0, sizeof(sls_detector_header));
@ -1679,6 +1673,11 @@ void* start_timer(void* arg) {
sls_detector_header* header = (sls_detector_header*)(packetData); sls_detector_header* header = (sls_detector_header*)(packetData);
header->frameNumber = frameNr; header->frameNumber = frameNr;
header->packetNumber = i; header->packetNumber = i;
header->modId = 0;
header->row = detPos[X];
header->column = detPos[Y];
header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
// fill data // fill data
memcpy(packetData + sizeof(sls_detector_header), imageData + srcOffset, datasize); memcpy(packetData + sizeof(sls_detector_header), imageData + srcOffset, datasize);
srcOffset += datasize; srcOffset += datasize;
@ -1782,11 +1781,11 @@ enum runStatus getRunStatus(){
void readFrame(int *ret, char *mess){ void readFrame(int *ret, char *mess){
#ifdef VIRTUAL
// wait for status to be done // wait for status to be done
while(runBusy()){ while(runBusy()){
usleep(500); usleep(500);
} }
#ifdef VIRTUAL
FILE_LOG(logINFOGREEN, ("acquisition successfully finished\n")); FILE_LOG(logINFOGREEN, ("acquisition successfully finished\n"));
return; return;
#endif #endif
@ -1826,7 +1825,7 @@ int calculateDataBytes(){
return DATA_BYTES; return DATA_BYTES;
} }
int getTotalNumberOfChannels(){return ((int)getNumberOfChannelsPerChip() * (int)getNumberOfChips());} int getTotalNumberOfChannels() {return (getNumberOfChannelsPerChip() * getNumberOfChips());}
int getNumberOfChips(){return NCHIP;} int getNumberOfChips(){return NCHIP;}
int getNumberOfDACs(){return NDAC;} int getNumberOfDACs(){return NDAC;}
int getNumberOfChannelsPerChip(){return NCHAN;} int getNumberOfChannelsPerChip(){return NCHAN;}

View File

@ -12,7 +12,7 @@ add_executable(moenchDetectorServer_virtual
../slsDetectorServer/src/ALTERA_PLL.c ../slsDetectorServer/src/ALTERA_PLL.c
../slsDetectorServer/src/LTC2620.c ../slsDetectorServer/src/LTC2620.c
../slsDetectorServer/src/MAX1932.c ../slsDetectorServer/src/MAX1932.c
../slsDetectorServer/src/programfpga.c ../slsDetectorServer/src/programFpgaBlackfin.c
) )
include_directories( include_directories(

View File

@ -12,7 +12,7 @@ DESTDIR ?= bin
INSTMODE = 0777 INSTMODE = 0777
SRCS = slsDetectorFunctionList.c SRCS = slsDetectorFunctionList.c
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programfpga.c SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c
OBJS = $(SRCS:.c=.o) OBJS = $(SRCS:.c=.o)

View File

@ -10,7 +10,7 @@
#include "ALTERA_PLL.h" // pll #include "ALTERA_PLL.h" // pll
#include "blackfin.h" #include "blackfin.h"
#ifndef VIRTUAL #ifndef VIRTUAL
#include "programfpga.h" #include "programFpgaBlackfin.h"
#endif #endif
#include <string.h> #include <string.h>

View File

@ -9,6 +9,7 @@ add_executable(mythen3DetectorServer_virtual
../slsDetectorServer/src/common.c ../slsDetectorServer/src/common.c
../slsDetectorServer/src/LTC2620_Driver.c ../slsDetectorServer/src/LTC2620_Driver.c
../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c ../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c
../slsDetectorServer/src/programFpgaNios.c
) )
include_directories( include_directories(

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