Compare commits

..

118 Commits
rhpatch ... udp

Author SHA1 Message Date
f08006db46 more tests 2020-02-17 17:24:36 +01:00
d5df63ce49 test socket 2020-02-17 17:02:50 +01:00
64d59b1dff revert qt 2020-02-14 13:33:47 +01:00
a0bc843018 cleanup 2020-02-13 18:38:36 +01:00
6126a401d0 pinned qt and qwt 2020-02-13 18:16:54 +01:00
7665d7b33a rename shared lib 2020-02-13 17:37:27 +01:00
d3d8d7ba8e WIP 2020-02-13 17:13:56 +01:00
938d90bfb8 another one 2020-02-13 16:57:12 +01:00
990f32397b WIP 2020-02-13 15:08:36 +01:00
53b1456f1a disable test 2020-02-13 12:30:54 +01:00
fbb901c8cc WIP 2020-02-13 12:18:53 +01:00
7b7641fb53 path 2020-02-13 12:07:10 +01:00
4de49906d4 WIP 2020-02-13 11:41:36 +01:00
c9b5db4d7f Matrix in conda2 2020-02-13 11:08:41 +01:00
2e6378f241 Matrix in conda 2020-02-13 10:53:25 +01:00
692584ced8 WIP 2020-02-12 17:27:44 +01:00
4ae93dbc73 WIP 2020-02-12 11:54:41 +01:00
f37ceaf517 WIP 2020-02-12 11:41:54 +01:00
75a9002f2c WIP 2020-02-12 11:26:47 +01:00
cfec18e441 WIP 2020-02-12 11:13:26 +01:00
3ff7654c29 WIP 2020-02-12 11:02:29 +01:00
9781dbe49e WIP 2020-02-12 10:51:26 +01:00
e777c0fa79 WIP 2020-02-12 10:34:57 +01:00
9981632b2d fix 2020-02-12 09:18:59 +01:00
d8436da540 conda 2020-02-12 09:05:34 +01:00
4dc4c1ec0a build 2020-02-11 19:33:33 +01:00
6537aa1ceb gui 2020-02-11 18:49:27 +01:00
467be41ccb zlib 2020-02-11 18:41:28 +01:00
73a39fcafe WIP 2020-02-11 18:22:28 +01:00
041c9fefa0 WIP 2020-02-11 16:22:48 +01:00
4f4f3baefc Merge branch 'udp' of github.com:slsdetectorgroup/slsDetectorPackage into udp 2020-02-11 16:07:47 +01:00
3523de8ba9 WIP 2020-02-11 16:01:32 +01:00
e77a93021d WIP 2020-02-10 17:59:29 +01:00
4dc14bf9d6 fixed looking up interface 2020-02-06 08:51:34 +01:00
a5cdd687e6 reverted server 2020-02-05 19:07:35 +01:00
89175586b4 replaced socket 2020-02-05 19:04:25 +01:00
c3bbe45b68 WIP 2020-02-04 17:50:21 +01:00
8f64449117 initial fixing 2020-02-04 17:34: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
156 changed files with 4085 additions and 2343 deletions

1
.gitignore vendored
View File

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

View File

@ -4,39 +4,31 @@ language: cpp
os: linux
env:
matrix:
- CONDA_PY=3.6
- CONDA_PY=3.7
- CONDA_PY=3.8
# env:
# matrix:
# - CONDA_PY="3.7"
dist: trusty
dist: bionic
install:
- sudo apt-get update
- ldd --version
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
- 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
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda config --add channels conda-forge
- conda config --add channels slsdetectorgroup
- conda update 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 update -q conda
- conda info -a
# Replace dep1 dep2 ... with your dependencies
- conda create -q -n test-environment python=$CONDA_PY
- source activate test-environment
# Useful for debugging any issues with conda
- conda create -q -n testenv conda-build anaconda-client conda-verify
- conda activate testenv
- conda-build .
script:
@ -45,7 +37,7 @@ script:
deploy:
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:
branch: developer
branch: udp

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.11)
cmake_minimum_required(VERSION 3.12)
project(slsDetectorPackage)
set(PROJECT_VERSION 5.0.0)
include(CheckIPOSupported)
@ -126,7 +126,7 @@ install(TARGETS slsProjectOptions slsProjectWarnings rapidjson
)
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 FALSE)
@ -174,6 +174,7 @@ if (SLS_USE_INTEGRATION_TESTS)
endif (SLS_USE_INTEGRATION_TESTS)
if (SLS_USE_PYTHON)
set(PYBIND11_CPP_STANDARD -std=c++11)
add_subdirectory(libs/pybind11)
add_subdirectory(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 install
cd build
@ -6,7 +7,7 @@ cmake .. \
-DCMAKE_INSTALL_PREFIX=install \
-DSLS_USE_TEXTCLIENT=ON \
-DSLS_USE_RECEIVER=ON \
-DSLS_USE_GUI=OFF \
-DSLS_USE_GUI=ON \
-DSLS_USE_TESTS=ON \
-DSLS_USE_PYTHON=OFF \
-DCMAKE_BUILD_TYPE=Release \

View File

@ -1,14 +1,4 @@
# mkdir $PREFIX/lib
# mkdir $PREFIX/include
# #Shared and static libraries
# cp build/bin/_sls_detector* $PREFIX/lib/.
# #Binaries
# cp -r build/bin/sls_detector $PREFIX/lib/.
echo "|<-------- starting python build"
cd python
${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 @@
mkdir $PREFIX/lib
#Copy the GUI
mkdir $PREFIX/bin
mkdir $PREFIX/include
#No libs for gui?
#Binaries
cp build/bin/gui_client $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:
name: sls_detector_software
version: "developer"
version: "udp"
source:
- path: ..
build:
number: 1
binary_relocation: True
rpaths:
- lib/
@ -16,10 +17,9 @@ requirements:
- {{ compiler('c') }}
- {{compiler('cxx')}}
- cmake
# - qwt 6.* #require qt5 investigate befor activating gui
# - qt=4.8.7=7
- zeromq=4.2.5=hfc679d8_5
- pyzmq
- qwt 6.*
- qt 4.8.*
- zeromq
- xorg-libx11
- xorg-libice
- xorg-libxext
@ -51,70 +51,46 @@ requirements:
outputs:
- name: sls_detector_lib
- name: slsdetlib
script: copy_lib.sh
- name: sls_detector
requirements:
run:
- libstdcxx-ng
- libgcc-ng
- zeromq
- name: slsdet
script: build_pylib.sh
requirements:
build:
- python
- {{ compiler('c') }}
- {{compiler('cxx')}}
- python {{ python }}
- {{ pin_subpackage('slsdetlib', exact=True) }}
- setuptools
- sls_detector_lib
- pyzmq
- pybind11 2.4
host:
- python
- pybind11 2.4
- pyzmq
- sls_detector_lib
run:
- libstdcxx-ng
- libgcc-ng
run:
- python
- numpy
- sls_detector_lib=developer
- pyzmq
- libstdcxx-ng
- libgcc-ng
- {{ pin_subpackage('slsdetlib', exact=True) }}
test:
imports:
- sls_detector
- slsdet
# requirements:
# build:
# - {{ compiler('c') }}
# - {{compiler('cxx')}}
# - name: sls_detector_gui
# version: "refactor"
# 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
- name: slsdetgui
script: copy_gui.sh
requirements:
run:
- {{ pin_subpackage('slsdetlib', exact=True) }}
- qwt 6.*
- qt 4.8.*

View File

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

View File

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

View File

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

View File

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

View File

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

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/enums.cpp
src/detector.cpp
src/network.cpp
)
target_link_libraries(_sls_detector PUBLIC
target_link_libraries(_slsdet PUBLIC
slsDetectorShared
slsReceiverShared
slsSupportLib
zmq )
)
set_target_properties(_sls_detector PROPERTIES
set_target_properties(_slsdet PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
@ -32,13 +34,14 @@ set( PYTHON_FILES
jungfrau.py
mythen3.py
registers.py
lookup.py
utils.py
)
foreach(FILE ${PYTHON_FILES})
configure_file( sls_detector/${FILE}
${CMAKE_BINARY_DIR}/bin/sls_detector/${FILE} )
configure_file( slsdet/${FILE}
${CMAKE_BINARY_DIR}/bin/slsdet/${FILE} )
endforeach(FILE ${PYTHON_FILES})

View File

@ -4,12 +4,12 @@ import numpy as np
sys.path.append(os.path.join(os.getcwd(), 'bin'))
from sls_detector import Detector, Mythen3, Eiger, Jungfrau, DetectorDacs, Dac, Ctb
from sls_detector import dacIndex
from sls_detector import dacIndex, readoutMode
from sls_detector.lookup import view, find
d = Detector()
# e = Eiger()
# c = Ctb()
c = Ctb()
# 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',
'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',
'vref_l_adc', 'iodelay', 'list', 'vref_ds', 'vis', 'vpl',
'vref_comp_fe', 'vph', 'vout_cm', 'vcp', 'vcn', 'vcmp_ll', 'vcmp_lr'

View File

@ -9,19 +9,7 @@ enums.cpp
import re
import subprocess
# 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)
from parse import remove_comments
def extract_enums(lines):
line_iter = iter(lines)

View File

@ -8,7 +8,7 @@ import sys
import setuptools
import os
__version__ = 'refactor'
__version__ = 'udp'
def get_conda_path():
@ -19,31 +19,32 @@ def get_conda_path():
return os.environ['CONDA_PREFIX']
class get_pybind_include(object):
"""Helper class to determine the pybind11 include path
The purpose of this class is to postpone importing pybind11
until it is actually installed, so that the ``get_include()``
method can be invoked. """
# class get_pybind_include(object):
# """Helper class to determine the pybind11 include path
# The purpose of this class is to postpone importing pybind11
# until it is actually installed, so that the ``get_include()``
# method can be invoked. """
def __init__(self, user=False):
self.user = user
# def __init__(self, user=False):
# self.user = user
def __str__(self):
import pybind11
return pybind11.get_include(self.user)
# def __str__(self):
# import pybind11
# return pybind11.get_include(self.user)
ext_modules = [
Extension(
'_sls_detector',
'_slsdet',
['src/main.cpp',
'src/enums.cpp',
'src/detector.cpp',
'src/network.cpp'],
include_dirs=[
# Path to pybind11 headers
get_pybind_include(),
get_pybind_include(user=True),
# get_pybind_include(),
# get_pybind_include(user=True),
os.path.join('../libs/pybind11/include'),
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())
for ext in self.extensions:
ext.extra_compile_args = opts
print('**************************************************')
print(ct)
print(opts)
print('**************************************************')
build_ext.build_extensions(self)
def get_shared_lib():
return [f for f in os.listdir('.') if '_slsdet' in f]
setup(
name='sls_detector',
name='slsdet',
version=__version__,
author='Erik Frojdh',
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',
long_description='',
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
ext_modules=ext_modules,
install_requires=['pybind11>=2.2'],
cmdclass={'build_ext': BuildExt},
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 functools import partial
import numpy as np
import _sls_detector
import _slsdet
from .detector import freeze
dacIndex = _sls_detector.slsDetectorDefs.dacIndex
dacIndex = _slsdet.slsDetectorDefs.dacIndex
class Dac(DetectorProperty):
"""
This class represents a dac on the detector. One instance handles all

View File

@ -1,33 +1,18 @@
from _sls_detector import CppDetectorApi
from _sls_detector import slsDetectorDefs
from _slsdet import CppDetectorApi
from _slsdet import slsDetectorDefs
runStatus = slsDetectorDefs.runStatus
speedLevel = slsDetectorDefs.speedLevel
dacIndex = slsDetectorDefs.dacIndex
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
import datetime as dt
from functools import wraps
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):
cls._frozen = False
@ -774,6 +759,22 @@ class Detector(CppDetectorApi):
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
def asamples(self):
return element_if_equal(self.getNumberOfAnalogSamples())
@ -839,9 +840,249 @@ class Detector(CppDetectorApi):
return element_if_equal(self.getMaxADCPhaseShift())
@property
def maxclkphaseshift(self):
return element_if_equal(self.getMaxClockPhaseShift())
def adcphase(self):
return element_if_equal(self.getADCPhase())
@adcphase.setter
def adcphase(self, value):
self.setADCPhase(value)
@property
def adcphase(self):
return element_if_equal()
def adcpipeline(self):
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 .dacs import DetectorDacs
import _sls_detector
dacIndex = _sls_detector.slsDetectorDefs.dacIndex
import _slsdet
dacIndex = _slsdet.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty
# from .utils import element_if_equal
# from sls_detector.errors import DetectorValueError, DetectorError

View File

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

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

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

View File

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

View File

@ -2,10 +2,13 @@
Utility functions that are useful for testing and troubleshooting
but not directly used in controlling the detector
"""
from collections import namedtuple
import _sls_detector #C++ lib
import _slsdet #C++ lib
import functools
Geometry = namedtuple('Geometry', ['x', 'y'])
def get_set_bits(mask):
@ -26,7 +29,7 @@ def list_to_bitmask(values):
return mask
def to_geo(value):
if isinstance(value, _sls_detector.xy):
if isinstance(value, _slsdet.xy):
return Geometry(x = value.x, y = value.y)
else:
raise ValueError("Can only convert sls_detector.xy")
@ -65,3 +68,4 @@ def eiger_register_to_time(register):
clocks = register >> 3
exponent = register & 0b111
return clocks*10**exponent / 100e6

View File

@ -2,7 +2,7 @@ C++ API
=====================================================
.. py:currentmodule:: _sls_detector
.. py:currentmodule:: _slsdet
.. autoclass:: DetectorApi
: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
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.

View File

@ -74,9 +74,12 @@ void init_det(py::module &m) {
py::arg() = Positions{})
.def("getNumberOfTriggersLeft", &Detector::getNumberOfTriggersLeft,
py::arg() = Positions{})
.def("getPeriodLeft", &Detector::getPeriodLeft, py::arg() = Positions{})
.def("getDelayAfterTriggerLeft", &Detector::getDelayAfterTriggerLeft,
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("setSpeed", &Detector::setSpeed, py::arg(),
py::arg() = Positions{})
@ -109,6 +112,9 @@ void init_det(py::module &m) {
py::arg(), py::arg() = Positions{})
.def("getHighVoltage", &Detector::getHighVoltage,
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(),
py::arg() = Positions{})
.def("getTemperature", &Detector::getTemperature, py::arg(),
@ -121,9 +127,6 @@ void init_det(py::module &m) {
py::arg() = Positions{})
.def("setOnChipDAC", &Detector::setOnChipDAC, py::arg(), py::arg(),
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("clearAcquiringFlag", &Detector::clearAcquiringFlag)
.def("startReceiver", &Detector::startReceiver)
@ -395,9 +398,6 @@ void init_det(py::module &m) {
py::arg() = Positions{})
.def("resetTemperatureEvent", &Detector::resetTemperatureEvent,
py::arg() = Positions{})
.def("getPowerChip", &Detector::getPowerChip, py::arg() = Positions{})
.def("setPowerChip", &Detector::setPowerChip, py::arg(),
py::arg() = Positions{})
.def("getAutoCompDisable", &Detector::getAutoCompDisable,
py::arg() = Positions{})
.def("setAutoCompDisable", &Detector::setAutoCompDisable, py::arg(),
@ -438,9 +438,9 @@ void init_det(py::module &m) {
py::arg(), py::arg(), py::arg() = Positions{})
.def("setVetoReference", &Detector::setVetoReference, py::arg(),
py::arg(), py::arg() = Positions{})
.def("getBurstMode", &Detector::getBurstMode, py::arg() = Positions{})
.def("setBurstMode", &Detector::setBurstMode, py::arg(),
py::arg() = Positions{})
.def("getBurstMode", &Detector::getBurstMode, py::arg() = Positions{})
.def("getCounterMask", &Detector::getCounterMask,
py::arg() = Positions{})
.def("setCounterMask", &Detector::setCounterMask, py::arg(),
@ -610,6 +610,8 @@ void init_det(py::module &m) {
py::arg() = Positions{})
.def("writeAdcRegister", &Detector::writeAdcRegister, py::arg(),
py::arg(), py::arg() = Positions{})
.def("getInitialChecks", &Detector::getInitialChecks)
.def("setInitialChecks", &Detector::setInitialChecks, py::arg())
.def("getControlPort", &Detector::getControlPort,
py::arg() = Positions{})
.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_ADC", slsDetectorDefs::dacIndex::VB_COMP_ADC)
.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("VREF_COMP_FE", slsDetectorDefs::dacIndex::VREF_COMP_FE)
.value("VCOM_ADC1", slsDetectorDefs::dacIndex::VCOM_ADC1)
@ -278,4 +278,10 @@ void init_enums(py::module &m) {
slsDetectorDefs::detectorModeType::INTERPOLATING)
.value("ANALOG", slsDetectorDefs::detectorModeType::ANALOG)
.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();
}

View File

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

View File

@ -16,12 +16,12 @@ def d():
def test_acq_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.acq')
m = mocker.patch('_slsdet.DetectorApi.acq')
d.acq()
m.assert_called_once_with()
def test_busy_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getAcquiringFlag')
m = mocker.patch('_slsdet.DetectorApi.getAcquiringFlag')
m.return_value = False
assert d.busy == False
@ -31,103 +31,103 @@ def test_assign_to_detector_type(d):
d.detector_type = 'Eiger'
def test_det_type(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDetectorType')
m = mocker.patch('_slsdet.DetectorApi.getDetectorType')
m.return_value = 'Eiger'
assert d.detector_type == 'Eiger'
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
m.assert_called_with(4)
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
m.assert_called_with(8)
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
m.assert_called_with(16)
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
m.assert_called_with(32)
def test_set_dynamic_range_raises_exception(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setDynamicRange')
mocker.patch('_slsdet.DetectorApi.setDynamicRange')
with pytest.raises(ValueError):
d.dynamic_range = 17
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
dr = d.dynamic_range
assert dr == 32
def test_eiger_matrix_reset(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getCounterBit')
m = mocker.patch('_slsdet.DetectorApi.getCounterBit')
m.return_value = True
assert d.eiger_matrix_reset == True
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
m.assert_called_once_with(True)
def test_get_exposure_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getExposureTime')
m = mocker.patch('_slsdet.DetectorApi.getExposureTime')
m.return_value = 100000000
assert d.exposure_time == 0.1
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
m.assert_called_once_with(1500000000)
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):
d.exposure_time = -7
def test_get_file_index(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFileIndex')
m = mocker.patch('_slsdet.DetectorApi.getFileIndex')
m.return_value = 8
assert d.file_index == 8
def test_set_file_index(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setFileIndex')
m = mocker.patch('_slsdet.DetectorApi.setFileIndex')
d.file_index = 9
m.assert_called_with(9)
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):
d.file_index = -9
def test_get_file_name(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFileName')
m = mocker.patch('_slsdet.DetectorApi.getFileName')
d.file_name
m.assert_called_once_with()
def test_set_file_name(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setFileName')
m = mocker.patch('_slsdet.DetectorApi.setFileName')
d.file_name = 'hej'
m.assert_called_once_with('hej')
def test_get_file_path(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFilePath')
m = mocker.patch('_slsdet.DetectorApi.getFilePath')
d.file_path
m.assert_called_once_with()
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
mock_os = mocker.patch('os.path.exists')
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/')
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.return_value = False
with pytest.raises(FileNotFoundError):
d.file_path = '/path/to/something/'
def test_get_file_write(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFileWrite')
m = mocker.patch('_slsdet.DetectorApi.getFileWrite')
m.return_value = False
assert d.file_write == False
def test_set_file_write(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setFileWrite')
m = mocker.patch('_slsdet.DetectorApi.setFileWrite')
d.file_write = True
m.assert_called_once_with(True)
def test_get_firmware_version(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getFirmwareVersion')
m = mocker.patch('_slsdet.DetectorApi.getFirmwareVersion')
m.return_value = 20
assert d.firmware_version == 20
@ -162,38 +162,38 @@ def test_cannot_set_fw_version(d):
d.firmware_version = 20
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
m.assert_called_once_with('vhighvoltage', -1)
def test_get_high_voltage(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDac')
m = mocker.patch('_slsdet.DetectorApi.getDac')
m.return_value = 80
assert d.high_voltage == 80
#self._api.setDac('vhighvoltage', -1, voltage)
def test_set_high_voltage(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setDac')
m = mocker.patch('_slsdet.DetectorApi.setDac')
d.high_voltage = 80
m.assert_called_once_with('vhighvoltage', -1, 80)
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+'
assert d.hostname == ['beb059', 'beb048']
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+'
assert d.hostname == ['beb059', 'beb048', 'beb120', 'beb153']
def test_decode_hostname_blank(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getHostname')
m = mocker.patch('_slsdet.DetectorApi.getHostname')
m.return_value = ''
assert d.hostname == []
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)
im_size = d.image_size
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):
m = mocker.patch('_sls_detector.DetectorApi.readConfigurationFile')
m = mocker.patch('_slsdet.DetectorApi.readConfigurationFile')
#To avoid raising an exception because path is not there
mock_os = mocker.patch('os.path.isfile')
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')
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.return_value = False
with pytest.raises(FileNotFoundError):
d.load_config('/path/to/my/file.config')
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
mock_os = mocker.patch('os.path.isfile')
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')
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.return_value = False
with pytest.raises(FileNotFoundError):
@ -233,14 +233,14 @@ def test_load_parameters_raises_when_file_is_not_found(d, mocker):
#getDetectorGeometry
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)
g = d.module_geometry
assert g.vertical == 7
assert g.horizontal == 13
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)
assert d.module_geometry[0] == 12
assert d.module_geometry[1] == 3
@ -248,237 +248,237 @@ def test_get_module_geometry_access(d, mocker):
assert d.module_geometry.horizontal == 12
def test_get_n_frames(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNumberOfFrames')
m = mocker.patch('_slsdet.DetectorApi.getNumberOfFrames')
m.return_value = 3
assert d.n_frames == 3
def test_set_n_frames(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames')
m = mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
d.n_frames = 9
m.assert_called_once_with(9)
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):
d.n_frames = -1
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):
d.n_frames = 0
def test_get_n_modules(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors')
m = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
m.return_value = 12
assert d.n_modules == 12
def test_get_period_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getPeriod')
m = mocker.patch('_slsdet.DetectorApi.getPeriod')
m.return_value = 130000000
assert d.period == 0.13
def test_set_period_time(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setPeriod')
m = mocker.patch('_slsdet.DetectorApi.setPeriod')
d.period = 1.953
m.assert_called_once_with(1953000000)
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):
d.period = -7
def test_pulse_chip_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.pulseChip')
m = mocker.patch('_slsdet.DetectorApi.pulseChip')
d.pulse_chip(15)
m.assert_called_once_with(15)
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)
m.assert_called_once_with(-1)
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):
d.pulse_chip(-3)
#--------------------------------------------------------------------subexptime
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
assert d.sub_exposure_time == 0.00237
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
m.assert_called_once_with(2000000)
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):
d.sub_exposure_time = 0
#-------------------------------------------------------------Rate correction
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]
assert d.rate_correction == [132,129]
def test_set_rate_correction(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setRateCorrection')
mock_n = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors')
m = mocker.patch('_slsdet.DetectorApi.setRateCorrection')
mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
mock_n.return_value = 3
d.rate_correction = [123,90,50]
m.assert_called_once_with([123,90,50])
def test_set_rate_correction_raises_on_wrong_number_of_values(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setRateCorrection')
mock_n = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors')
mocker.patch('_slsdet.DetectorApi.setRateCorrection')
mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
mock_n.return_value = 4
with pytest.raises(ValueError):
d.rate_correction = [123,90,50]
#----------------------------------------------------------------Readout clock
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
assert d.readout_clock == 'Full Speed'
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
assert d.readout_clock == 'Half Speed'
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
assert d.readout_clock == 'Quarter Speed'
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
assert d.readout_clock == 'Super Slow Speed'
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'
m.assert_called_once_with(0)
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'
m.assert_called_once_with(1)
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'
m.assert_called_once_with(2)
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'
m.assert_called_once_with(3)
#----------------------------------------------------------------rx_datastream
def test_get_rx_datastream(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getRxDataStreamStatus')
m = mocker.patch('_slsdet.DetectorApi.getRxDataStreamStatus')
m.return_value = False
assert d.rx_datastream == False
def test_set_rx_datastream(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setRxDataStreamStatus')
m = mocker.patch('_slsdet.DetectorApi.setRxDataStreamStatus')
d.rx_datastream = True
m.assert_called_once_with(True)
def test_get_rx_zmqip(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
d.rx_zmqip
m.assert_called_once_with('rx_zmqip')
def test_get_rx_zmqport_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
d.rx_zmqport
m.assert_called_once_with('rx_zmqport')
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+'
assert d.rx_zmqport == [30001, 30002, 30003, 30004]
def test_get_rx_zmqport_empty(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
m.return_value = ''
assert d.rx_zmqport == []
#--------------------------------------------------------------------status
def test_status_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getRunStatus')
m = mocker.patch('_slsdet.DetectorApi.getRunStatus')
d.status
m.assert_called_once_with()
def test_start_acq_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.startAcquisition')
m = mocker.patch('_slsdet.DetectorApi.startAcquisition')
d.start_acq()
m.assert_called_once_with()
def test_stop_acq_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.stopAcquisition')
m = mocker.patch('_slsdet.DetectorApi.stopAcquisition')
d.stop_acq()
m.assert_called_once_with()
#--------------------------------------------------------------------subexptime
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
assert d.sub_exposure_time == 0.00237
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
m.assert_called_once_with(2000000)
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):
d.sub_exposure_time = 0
#------------------------------------------------------------------timing mode
def test_get_timing_mode(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getTimingMode')
m = mocker.patch('_slsdet.DetectorApi.getTimingMode')
d.timing_mode
m.assert_called_once_with()
def test_set_timing_mode(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setTimingMode')
m = mocker.patch('_slsdet.DetectorApi.setTimingMode')
d.timing_mode = 'auto'
m.assert_called_once_with('auto')
#----------------------------------------------------------------vthreshold
def test_get_vthreshold(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getDac')
m = mocker.patch('_slsdet.DetectorApi.getDac')
d.vthreshold
m.assert_called_once_with('vthreshold', -1)
def test_set_vthreshold(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setDac')
m = mocker.patch('_slsdet.DetectorApi.setDac')
d.vthreshold = 1675
m.assert_called_once_with('vthreshold', -1, 1675)
#----------------------------------------------------------------trimbits
def test_get_trimbits(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getAllTrimbits')
m = mocker.patch('_slsdet.DetectorApi.getAllTrimbits')
d.trimbits
m.assert_called_once_with()
def test_set_trimbits(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.setAllTrimbits')
m = mocker.patch('_slsdet.DetectorApi.setAllTrimbits')
d.trimbits = 15
m.assert_called_once_with(15)
def test_set_trimbits_raises_outside_range(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setAllTrimbits')
mocker.patch('_slsdet.DetectorApi.setAllTrimbits')
with pytest.raises(ValueError):
d.trimbits = 69

View File

@ -15,7 +15,7 @@ from pytest_mock import mocker
import sys
sys.path.append('/home/l_frojdh/slsdetectorgrup/sls_detector')
import _sls_detector
import _slsdet
from sls_detector.errors import DetectorValueError, DetectorError
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):
# m = mocker.patch('_sls_detector.DetectorApi.getAcquiringFlag')
# m = mocker.patch('_slsdet.DetectorApi.getAcquiringFlag')
# m.return_value = False
# assert d.busy == False
@ -73,34 +73,34 @@ def test_set_counters_single(d, mocker):
# d.detector_type = 'Eiger'
# def test_det_type(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getDetectorType')
# m = mocker.patch('_slsdet.DetectorApi.getDetectorType')
# m.return_value = 'Eiger'
# assert d.detector_type == 'Eiger'
# def test_get_exposure_time(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getExposureTime')
# m = mocker.patch('_slsdet.DetectorApi.getExposureTime')
# m.return_value = 100000000
# assert d.exposure_time == 0.1
# 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
# m.assert_called_once_with(1500000000)
# 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):
# d.exposure_time = -7
# def test_get_file_index(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getFileIndex')
# m = mocker.patch('_slsdet.DetectorApi.getFileIndex')
# m.return_value = 8
# assert d.file_index == 8
# def test_set_file_index(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setFileIndex')
# m = mocker.patch('_slsdet.DetectorApi.setFileIndex')
# d.file_index = 9
# m.assert_called_with(9)
@ -112,28 +112,28 @@ def test_set_counters_single(d, mocker):
# assert d.dynamic_range == -100
# 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):
# d.file_index = -9
# def test_get_file_name(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getFileName')
# m = mocker.patch('_slsdet.DetectorApi.getFileName')
# d.file_name
# m.assert_called_once_with()
# def test_set_file_name(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setFileName')
# m = mocker.patch('_slsdet.DetectorApi.setFileName')
# d.file_name = 'hej'
# m.assert_called_once_with('hej')
# def test_get_file_path(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getFilePath')
# m = mocker.patch('_slsdet.DetectorApi.getFilePath')
# d.file_path
# m.assert_called_once_with()
# 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
# mock_os = mocker.patch('os.path.exists')
# mock_os.return_value = True
@ -141,25 +141,25 @@ def test_set_counters_single(d, mocker):
# m.assert_called_once_with('/path/to/something/')
# 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.return_value = False
# with pytest.raises(FileNotFoundError):
# d.file_path = '/path/to/something/'
# def test_get_file_write(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getFileWrite')
# m = mocker.patch('_slsdet.DetectorApi.getFileWrite')
# m.return_value = False
# assert d.file_write == False
# def test_set_file_write(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setFileWrite')
# m = mocker.patch('_slsdet.DetectorApi.setFileWrite')
# d.file_write = True
# m.assert_called_once_with(True)
# def test_get_firmware_version(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getFirmwareVersion')
# m = mocker.patch('_slsdet.DetectorApi.getFirmwareVersion')
# m.return_value = 20
# assert d.firmware_version == 20
@ -168,38 +168,38 @@ def test_set_counters_single(d, mocker):
# d.firmware_version = 20
# 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
# m.assert_called_once_with('vhighvoltage', -1)
# def test_get_high_voltage(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getDac')
# m = mocker.patch('_slsdet.DetectorApi.getDac')
# m.return_value = 80
# assert d.high_voltage == 80
# #self._api.setDac('vhighvoltage', -1, voltage)
# def test_set_high_voltage(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setDac')
# m = mocker.patch('_slsdet.DetectorApi.setDac')
# d.high_voltage = 80
# m.assert_called_once_with('vhighvoltage', -1, 80)
# 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+'
# assert d.hostname == ['beb059', 'beb048']
# 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+'
# assert d.hostname == ['beb059', 'beb048', 'beb120', 'beb153']
# def test_decode_hostname_blank(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getHostname')
# m = mocker.patch('_slsdet.DetectorApi.getHostname')
# m.return_value = ''
# assert d.hostname == []
# 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)
# im_size = d.image_size
# assert im_size.rows == 512
@ -208,7 +208,7 @@ def test_set_counters_single(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
# mock_os = mocker.patch('os.path.isfile')
# 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')
# 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.return_value = False
# with pytest.raises(FileNotFoundError):
# d.load_config('/path/to/my/file.config')
# 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
# mock_os = mocker.patch('os.path.isfile')
# 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')
# 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.return_value = False
# with pytest.raises(FileNotFoundError):
@ -239,14 +239,14 @@ def test_set_counters_single(d, mocker):
# #getDetectorGeometry
# 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)
# g = d.module_geometry
# assert g.vertical == 7
# assert g.horizontal == 13
# 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)
# assert d.module_geometry[0] == 12
# assert d.module_geometry[1] == 3
@ -259,12 +259,12 @@ def test_set_counters_single(d, mocker):
# assert t.vertical == 0
# def test_get_n_frames(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getNumberOfFrames')
# m = mocker.patch('_slsdet.DetectorApi.getNumberOfFrames')
# m.return_value = 3
# assert d.n_frames == 3
# def test_set_n_frames(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames')
# m = mocker.patch('_slsdet.DetectorApi.setNumberOfFrames')
# d.n_frames = 9
# m.assert_called_once_with(9)
@ -272,12 +272,12 @@ def test_set_counters_single(d, mocker):
# assert d.n_frames == -100
# 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):
# d.n_frames = -1
# 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):
# d.n_frames = 0
@ -285,12 +285,12 @@ def test_set_counters_single(d, mocker):
# assert d.n_cycles == -100
# 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):
# d.n_cycles = 0
# def test_set_n_cycles(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setCycles')
# m = mocker.patch('_slsdet.DetectorApi.setCycles')
# d.n_cycles = 56
# m.assert_called_once_with(56)
@ -300,12 +300,12 @@ def test_set_counters_single(d, mocker):
# assert d.n_measurements == -100
# 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):
# d.n_measurements = 0
# def test_set_n_measurements(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setNumberOfMeasurements')
# m = mocker.patch('_slsdet.DetectorApi.setNumberOfMeasurements')
# d.n_measurements = 560
# m.assert_called_once_with(560)
@ -313,33 +313,33 @@ def test_set_counters_single(d, mocker):
# assert d.n_modules == 0
# def test_get_n_modules(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors')
# m = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
# m.return_value = 12
# assert d.n_modules == 12
# def test_get_period_time(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getPeriod')
# m = mocker.patch('_slsdet.DetectorApi.getPeriod')
# m.return_value = 130000000
# assert d.period == 0.13
# def test_set_period_time(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setPeriod')
# m = mocker.patch('_slsdet.DetectorApi.setPeriod')
# d.period = 1.953
# m.assert_called_once_with(1953000000)
# 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):
# d.period = -7
# def test_get_online(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getOnline')
# m = mocker.patch('_slsdet.DetectorApi.getOnline')
# d.online
# m.assert_called_once_with()
# def test_set_online(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setOnline')
# m = mocker.patch('_slsdet.DetectorApi.setOnline')
# d.online = True
# m.assert_called_once_with(True)
@ -347,116 +347,116 @@ def test_set_counters_single(d, mocker):
# assert d.last_client_ip == ''
# 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
# m.assert_called_once_with()
# #-------------------------------------------------------------Rate correction
# 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]
# assert d.rate_correction == [132,129]
# def test_set_rate_correction(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setRateCorrection')
# mock_n = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors')
# m = mocker.patch('_slsdet.DetectorApi.setRateCorrection')
# mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
# mock_n.return_value = 3
# d.rate_correction = [123,90,50]
# m.assert_called_once_with([123,90,50])
# def test_set_rate_correction_raises_on_wrong_number_of_values(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setRateCorrection')
# mock_n = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors')
# mocker.patch('_slsdet.DetectorApi.setRateCorrection')
# mock_n = mocker.patch('_slsdet.DetectorApi.getNumberOfDetectors')
# mock_n.return_value = 4
# with pytest.raises(ValueError):
# d.rate_correction = [123,90,50]
# #----------------------------------------------------------------Readout clock
# 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
# assert d.readout_clock == 'Full Speed'
# 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
# assert d.readout_clock == 'Half Speed'
# 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
# assert d.readout_clock == 'Quarter Speed'
# 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
# assert d.readout_clock == 'Super Slow Speed'
# 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'
# m.assert_called_once_with(0)
# 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'
# m.assert_called_once_with(1)
# 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'
# m.assert_called_once_with(2)
# 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'
# m.assert_called_once_with(3)
# #----------------------------------------------------------------rx_datastream
# def test_get_rx_datastream(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getRxDataStreamStatus')
# m = mocker.patch('_slsdet.DetectorApi.getRxDataStreamStatus')
# m.return_value = False
# assert d.rx_datastream == False
# def test_set_rx_datastream(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setRxDataStreamStatus')
# m = mocker.patch('_slsdet.DetectorApi.setRxDataStreamStatus')
# d.rx_datastream = True
# m.assert_called_once_with(True)
# def test_get_rx_zmqip(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
# m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
# d.rx_zmqip
# m.assert_called_once_with('rx_zmqip')
# def test_get_rx_zmqport_call(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
# m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
# d.rx_zmqport
# m.assert_called_once_with('rx_zmqport')
# 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']
# assert d.rx_zmqport == [30001, 30003]
# def test_get_rx_zmqport_empty(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
# m = mocker.patch('_slsdet.DetectorApi.getNetworkParameter')
# m.return_value = ''
# assert d.rx_zmqport == []
# #--------------------------------------------------------------------status
# def test_status_call(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getRunStatus')
# m = mocker.patch('_slsdet.DetectorApi.getRunStatus')
# d.status
# m.assert_called_once_with()
# def test_start_detecor(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.startAcquisition')
# m = mocker.patch('_slsdet.DetectorApi.startAcquisition')
# d.start_detector()
# m.assert_called_once_with()
# def test_stop_acq_call(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.stopAcquisition')
# m = mocker.patch('_slsdet.DetectorApi.stopAcquisition')
# d.stop_detector()
# m.assert_called_once_with()
@ -464,23 +464,23 @@ def test_set_counters_single(d, mocker):
# #------------------------------------------------------------------timing mode
# def test_get_timing_mode(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getTimingMode')
# m = mocker.patch('_slsdet.DetectorApi.getTimingMode')
# d.timing_mode
# m.assert_called_once_with()
# def test_set_timing_mode(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setTimingMode')
# m = mocker.patch('_slsdet.DetectorApi.setTimingMode')
# d.timing_mode = 'auto'
# m.assert_called_once_with('auto')
# #----------------------------------------------------------------vthreshold
# def test_get_vthreshold(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getDac')
# m = mocker.patch('_slsdet.DetectorApi.getDac')
# d.vthreshold
# m.assert_called_once_with('vthreshold', -1)
# def test_set_vthreshold(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setDac')
# m = mocker.patch('_slsdet.DetectorApi.setDac')
# d.vthreshold = 1675
# m.assert_called_once_with('vthreshold', -1, 1675)

View File

@ -19,3 +19,18 @@ target_link_libraries(result
set_target_properties(result PROPERTIES
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

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

View File

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

View File

@ -160,4 +160,5 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
unsigned int nPixelsY{0};
const static int npixelsx_jctb = 400;
int npixelsy_jctb{0};
uint32_t pixelMask{0};
};

View File

@ -229,6 +229,7 @@ void qDetectorMain::SetUpDetector(const std::string fName, int multiID) {
case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::MOENCH:
case slsDetectorDefs::MYTHEN3:
case slsDetectorDefs::GOTTHARD2:
break;
default:
std::ostringstream os;
@ -446,7 +447,7 @@ void qDetectorMain::ExecuteHelp(QAction *action) {
clientVersion +
"<br><br>"
"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 "
"line interface:<br>"
"sls_detector_put,<br>sls_detector_get,<br>sls_"

View File

@ -52,6 +52,19 @@ qDrawPlot::~qDrawPlot() {
void qDrawPlot::SetupWidgetWindow() {
detType = det->getDetectorType().squash();
switch (detType) {
case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::MOENCH:
pixelMask = ((1 << 15) - 1);
FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask << std::dec;
break;
case slsDetectorDefs::GOTTHARD2:
pixelMask = ((1 << 13) - 1);
FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask << std::dec;
break;
default:
break;
}
// save
try {
std::string temp = det->getFilePath().squash("/tmp/");
@ -317,9 +330,11 @@ void qDrawPlot::SetDataCallBack(bool enable) {
FILE_LOG(logINFO) << "Setting data call back to " << std::boolalpha << enable << std::noboolalpha;
if (enable) {
isPlot = true;
det->setRxZmqDataStream(true);
det->registerDataCallback(&(GetDataCallBack), this);
} else {
isPlot = false;
det->setRxZmqDataStream(false);
det->registerDataCallback(nullptr, this);
}
@ -879,7 +894,7 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, int data
int halfbyte = 0;
char cbyte = '\0';
// mythen 3 debugging
// mythen3 / gotthard2 debugging
int discardBits = numDiscardBits;
switch (dr) {
@ -903,14 +918,15 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, int data
case 16:
if (detType == slsDetectorDefs::JUNGFRAU ||
detType == slsDetectorDefs::MOENCH) {
detType == slsDetectorDefs::MOENCH ||
detType == slsDetectorDefs::GOTTHARD2) {
// show gain plot
if (gaindest != NULL) {
for (ichan = 0; ichan < size; ++ichan) {
uint16_t temp = (*((u_int16_t *)source));
gaindest[ichan] = ((temp & 0xC000) >> 14);
dest[ichan] = (temp & 0x3FFF);
dest[ichan] = (temp & pixelMask);
source += 2;
}
}
@ -918,7 +934,7 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, int data
// only data plot
else {
for (ichan = 0; ichan < size; ++ichan) {
dest[ichan] = ((*((u_int16_t *)source)) & 0x3FFF);
dest[ichan] = ((*((u_int16_t *)source)) & pixelMask);
source += 2;
}
}

View File

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

View File

@ -60,6 +60,7 @@ void qTabPlot::SetupWidgetWindow() {
switch(det->getDetectorType().squash()) {
case slsDetectorDefs::GOTTHARD:
case slsDetectorDefs::MYTHEN3:
case slsDetectorDefs::GOTTHARD2:
is1d = true;
break;
case slsDetectorDefs::EIGER:

View File

@ -83,6 +83,11 @@ void qTabSettings::SetupDetectorSettings() {
item[(int)FORCESWITCHG1]->setEnabled(true);
item[(int)FORCESWITCHG2]->setEnabled(true);
break;
case slsDetectorDefs::GOTTHARD2:
item[(int)DYNAMICGAIN]->setEnabled(true);
item[(int)FIXGAIN1]->setEnabled(true);
item[(int)FIXGAIN2]->setEnabled(true);
break;
default:
FILE_LOG(logDEBUG) << "Unknown detector type. Exiting GUI.";
qDefs::Message(qDefs::CRITICAL,

View File

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

View File

@ -12,7 +12,7 @@ DESTDIR ?= bin
INSTMODE = 0777
SRCS = slsDetectorFunctionList.c
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)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)

View File

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

View File

@ -1106,13 +1106,23 @@ int setHighVoltage(int val) {
/* parameters - timing, extsig */
void setTiming( enum timingMode arg) {
enum timingMode ret=GET_TIMING_MODE;
if (arg != GET_TIMING_MODE) {
switch((int)arg) {
case AUTO_TIMING: ret = 0; break;
case TRIGGER_EXPOSURE: ret = 2; break;
case BURST_TRIGGER: ret = 1; break;
case GATED: ret = 3; break;
int ret = 0;
switch(arg) {
case AUTO_TIMING:
ret = 0;
break;
case TRIGGER_EXPOSURE:
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));
#ifndef VIRTUAL
@ -1120,22 +1130,22 @@ void setTiming( enum timingMode arg) {
#endif
eiger_triggermode = ret;
}
}
enum timingMode getTiming() {
enum timingMode ret = GET_TIMING_MODE;
ret = eiger_triggermode;
switch((int)ret) {
case 0: ret = AUTO_TIMING; break;
case 2: ret = TRIGGER_EXPOSURE; break;
case 1: ret = BURST_TRIGGER; break;
case 3: ret = GATED; break;
switch(eiger_triggermode) {
case 0:
return AUTO_TIMING;
case 2:
return TRIGGER_EXPOSURE;
case 1:
return BURST_TRIGGER;
case 3:
return GATED;
default:
FILE_LOG(logERROR, ("Unknown trigger mode found %d\n", ret));
ret = 0;
FILE_LOG(logERROR, ("Unknown trigger mode found %d\n", eiger_triggermode));
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 getNumberOfDACs() {return NDAC;}
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 */ \
1000, /* Vcmp_ll */ \
1000, /* Vcmp_lr */ \
4000, /* cal */ \
0, /* cal */ \
1000, /* Vcmp_rl */ \
1100, /* rxb_rb */ \
1100, /* rxb_lb */ \

View File

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

View File

@ -12,7 +12,7 @@ DESTDIR ?= bin
INSTMODE = 0777
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)

View File

@ -14,13 +14,33 @@
/* Base addresses 0x1806 0000 ---------------------------------------------*/
/* General purpose control and status registers */
#define BASE_CONTROL (0x0000)
/* Acquisition? TODO */
#define BASE_ACQUISITION (0x0200)
#define BASE_CONTROL (0x0000) // 0x1806_0000 - 0x1806_00FF
// https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/ctrl/ctrl.vhd
/* 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 */
#define BASE_UDP_RAM (0x01000) // 0x1806_1000 - 0x1806_1FFF
/* Clock Generation registers ------------------------------------------------------*/
#define PLL_RESET_REG (0x00 * REG_OFFSET + BASE_CLK_GENERATION)
@ -30,6 +50,7 @@
#define PLL_RESET_SYSTEM_MSK (0x00000001 << PLL_RESET_SYSTEM_OFST)
/* Control registers --------------------------------------------------*/
/* Module Control Board Serial Number register */
@ -61,11 +82,6 @@
/* Status register */
#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 */
#define LOOK_AT_ME_REG (0x05 * REG_OFFSET + BASE_CONTROL)
@ -88,43 +104,144 @@
#define CONTROL_PRPHRL_RST_MSK (0x00000001 << CONTROL_PRPHRL_RST_OFST)
#define CONTROL_CLR_ACQSTN_FIFO_OFST (15)
#define CONTROL_CLR_ACQSTN_FIFO_MSK (0x00000001 << CONTROL_CLR_ACQSTN_FIFO_OFST)
/* Pattern IO Control 64 bit register */
#define PATTERN_IO_CTRL_LSB_REG (0x22 * REG_OFFSET + BASE_CONTROL)
#define PATTERN_IO_CTRL_MSB_REG (0x23 * REG_OFFSET + BASE_CONTROL)
#define CONTROL_PWR_CHIP_OFST (31)
#define CONTROL_PWR_CHIP_MSK (0x00000001 << CONTROL_PWR_CHIP_OFST)
/** DTA Offset Register */
#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_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 */
#define GET_CYCLES_LSB_REG (0x10 + BASE_ACQUISITION)
#define GET_CYCLES_MSB_REG (0x14 + BASE_ACQUISITION)
#define GET_CYCLES_LSB_REG (0x04 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_CYCLES_MSB_REG (0x05 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Frames left 64bit Register */
#define GET_FRAMES_LSB_REG (0x18 + BASE_ACQUISITION)
#define GET_FRAMES_MSB_REG (0x1C + BASE_ACQUISITION)
#define GET_FRAMES_LSB_REG (0x06 * REG_OFFSET + BASE_FLOW_CONTROL)
#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 */
#define SET_DELAY_LSB_REG (0x88 + BASE_ACQUISITION)
#define SET_DELAY_MSB_REG (0x8C + BASE_ACQUISITION)
#define SET_DELAY_LSB_REG (0x22 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_DELAY_MSB_REG (0x23 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Cylces 64bit Write-register */
#define SET_CYCLES_LSB_REG (0x90 + BASE_ACQUISITION)
#define SET_CYCLES_MSB_REG (0x94 + BASE_ACQUISITION)
#define SET_CYCLES_LSB_REG (0x24 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_CYCLES_MSB_REG (0x25 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Frames 64bit Write-register */
#define SET_FRAMES_LSB_REG (0x98 + BASE_ACQUISITION)
#define SET_FRAMES_MSB_REG (0x9C + BASE_ACQUISITION)
#define SET_FRAMES_LSB_REG (0x26 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_FRAMES_MSB_REG (0x27 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Period 64bit Write-register */
#define SET_PERIOD_LSB_REG (0xA0 + BASE_ACQUISITION)
#define SET_PERIOD_MSB_REG (0xA4 + BASE_ACQUISITION)
#define SET_PERIOD_LSB_REG (0x28 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_PERIOD_MSB_REG (0x29 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Exptime 64bit Write-register */
#define SET_EXPTIME_LSB_REG (0xA8 + BASE_ACQUISITION)
#define SET_EXPTIME_MSB_REG (0xBC + BASE_ACQUISITION)
/* External Signal register */
#define EXT_SIGNAL_REG (0x30 * REG_OFFSET + BASE_FLOW_CONTROL)
#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_adc 0
vcom_cds 1400
vref_restore 640
vref_rstore 640
vb_opa_1st 0
vref_comp_fe 0
vcom_adc1 1400

View File

@ -17,22 +17,29 @@
#define HV_DRIVER_FILE_NAME ("/etc/devlinks/hvdac")
#define DAC_DRIVER_FILE_NAME ("/etc/devlinks/dac")
#define ONCHIP_DAC_DRIVER_FILE_NAME ("/etc/devlinks/chipdac")
#define TYPE_FILE_NAME ("/etc/devlinks/type")
#define CONFIG_FILE ("config.txt")
#define DAC_MAX_MV (2048)
#define ONCHIP_DAC_MAX_VAL (0x3FF)
#define ADU_MAX_VAL (0xFFF)
#define ADU_MAX_BITS (12)
#define MAX_FRAMES_IN_BURST_MODE (2720)
#define TYPE_GOTTHARD2_MODULE_VAL (512)
#define TYPE_TOLERANCE (10)
#define TYPE_NO_MODULE_STARTING_VAL (800)
/** Default Parameters */
#define DEFAULT_BURST_MODE (BURST_INTERNAL)
#define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_EXPTIME (1 * 1000 * 1000) // 1 ms
#define DEFAULT_PERIOD (1 * 1000 * 1000 * 1000) // 1 s
#define DEFAULT_EXPTIME (0) // 0 ms (220ns in firmware)
#define DEFAULT_PERIOD (1 * 1000) // 1 ms
#define DEFAULT_DELAY_AFTER_TRIGGER (0)
#define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_SETTINGS (DYNAMICGAIN)
#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_C1 (72222224) // chip_clk, 72 MHz
#define DEFAULT_SYSTEM_C2 (18055556) // sync_clk, 18 MHz
@ -40,6 +47,7 @@
/* Firmware Definitions */
#define IP_HEADER_SIZE (20)
#define FIXED_PLL_FREQUENCY (020000000) // 20MHz
#define READOUT_PLL_VCO_FREQ_HZ (866666688) // Hz
#define SYSTEM_PLL_VCO_FREQ_HZ (722222240) // Hz
@ -52,7 +60,7 @@ enum DACINDEX {G2_VREF_H_ADC, /* 0 */ \
G2_VB_COMP_FE, /* 2 */ \
G2_VB_COMP_ADC, /* 3 */ \
G2_VCOM_CDS, /* 4 */ \
G2_VREF_RESTORE,/* 5 */ \
G2_VREF_RSTORE,/* 5 */ \
G2_VB_OPA_1ST, /* 6 */ \
G2_VREF_COMP_FE,/* 7 */ \
G2_VCOM_ADC1, /* 8 */ \
@ -64,7 +72,7 @@ enum DACINDEX {G2_VREF_H_ADC, /* 0 */ \
G2_DAC_UNUSED2, /* 14 */ \
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 */ \
G2_VCHIP_OPA_1ST, /* 1 */ \

View File

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

View File

@ -10,7 +10,7 @@ add_executable(jungfrauDetectorServer_virtual
../slsDetectorServer/src/ALTERA_PLL.c
../slsDetectorServer/src/LTC2620.c
../slsDetectorServer/src/MAX1932.c
../slsDetectorServer/src/programfpga.c
../slsDetectorServer/src/programFpgaBlackfin.c
../slsDetectorServer/src/communication_funcs_UDP.c
)
@ -28,7 +28,7 @@ target_compile_definitions(jungfrauDetectorServer_virtual
)
target_link_libraries(jungfrauDetectorServer_virtual
PUBLIC pthread rt
PUBLIC pthread rt slsProjectOptions slsProjectWarnings
)
set_target_properties(jungfrauDetectorServer_virtual PROPERTIES

View File

@ -12,7 +12,7 @@ DESTDIR ?= bin
INSTMODE = 0777
SRCS = slsDetectorFunctionList.c
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)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)

View File

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

View File

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

View File

@ -12,7 +12,7 @@ DESTDIR ?= bin
INSTMODE = 0777
SRCS = slsDetectorFunctionList.c
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)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)

View File

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

View File

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

View File

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

View File

@ -4,29 +4,42 @@
#define REG_OFFSET (4)
/* Base addresses 0x1804 0000 ---------------------------------------------*/
/* Reconfiguration core for readout pll */
#define BASE_READOUT_PLL (0x0000) // 0x1804_0000 - 0x1804_07FF
/* Reconfiguration core for system pll */
#define BASE_SYSTEM_PLL (0x0800) // 0x1804_0800 - 0x1804_0FFF
/* Clock Generation */
#define BASE_CLK_GENERATION (0x1000) // 0x1804_1000 - 0x1804_XXXX //TODO
/* Base addresses 0x1806 0000 ---------------------------------------------*/
/* General purpose control and status registers */
#define BASE_CONTROL (0x0000) // 0x1806_0000 - 0x1806_00FF https://git.psi.ch/sls_detectors_firmware/mythen_III_mcb/blob/master/code/hdl/ctrl/ctrl.vhd
#define BASE_CONTROL (0x0000) // 0x1806_0000 - 0x1806_00FF
// https://git.psi.ch/sls_detectors_firmware/mythen_III_mcb/blob/master/code/hdl/ctrl/ctrl.vhd
/* ASIC Control */
#define BASE_ASIC (0x0100) // 0x1806_0100 - 0x1806_010F
/* ASIC Digital Interface. Data recovery core */
#define BASE_ADIF (0x0110) // 0x1806_0110 - 0x1806_011F https://git.psi.ch/sls_detectors_firmware/vhdl_library/blob/2e81ccbdbc5cb81813ba190fbdba43e8d6884eb9/adif/adif_ctrl.vhd
#define BASE_ADIF (0x0110) // 0x1806_0110 - 0x1806_011F
// https://git.psi.ch/sls_detectors_firmware/vhdl_library/blob/2e81ccbdbc5cb81813ba190fbdba43e8d6884eb9/adif/adif_ctrl.vhd
/* Formatting of data core */
#define BASE_FMT (0x0120) // 0x1806_0120 - 0x1806_012F
/* Packetizer */
#define BASE_PKT (0x0140) // 0x1806_0140 - 0x1806_014F
// https://git.psi.ch/sls_detectors_firmware/mythen_III_mcb/blob/master/code/hdl/pkt/pkt_ctrl.vhd
/* Pattern control and status registers */
#define BASE_PATTERN_CONTROL (0x00200) // 0x1806_0200 - 0x1806_02FF https://git.psi.ch/sls_detectors_firmware/vhdl_library/blob/2e81ccbdbc5cb81813ba190fbdba43e8d6884eb9/pattern_flow/pattern_flow_ctrl.vhd
#define BASE_PATTERN_CONTROL (0x00200) // 0x1806_0200 - 0x1806_02FF
// https://git.psi.ch/sls_detectors_firmware/vhdl_library/blob/2e81ccbdbc5cb81813ba190fbdba43e8d6884eb9/pattern_flow/pattern_flow_ctrl.vhd
/* UDP datagram generator */
#define BASE_UDP_RAM (0x01000) // 0x1806_1000 - 0x1806_1FFF
/* Pattern RAM. Pattern table */
#define BASE_PATTERN_RAM (0x10000) // 0x1807_0000 - 0x1807_FFFF
@ -119,6 +132,30 @@
/* 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
/* Pattern Control registers --------------------------------------------------*/
@ -126,15 +163,15 @@
#define PAT_STATUS_REG (0x00 * REG_OFFSET + BASE_PATTERN_CONTROL)
#define PAT_STATUS_RUN_BUSY_OFST (0)
#define PAT_STATUS_RUN_BUSY_MSK (0x00000001 << PAT_STATUS_RUN_BUSY_OFST)
#define PAT_STATUS_WAIT_FOR_TRGGR_OFST (0)
#define PAT_STATUS_WAIT_FOR_TRGGR_OFST (3)
#define PAT_STATUS_WAIT_FOR_TRGGR_MSK (0x00000001 << PAT_STATUS_WAIT_FOR_TRGGR_OFST)
#define PAT_STATUS_DLY_BFRE_TRGGR_OFST (0)
#define PAT_STATUS_DLY_BFRE_TRGGR_OFST (4)
#define PAT_STATUS_DLY_BFRE_TRGGR_MSK (0x00000001 << PAT_STATUS_DLY_BFRE_TRGGR_OFST)
#define PAT_STATUS_FIFO_FULL_OFST (0)
#define PAT_STATUS_FIFO_FULL_OFST (5)
#define PAT_STATUS_FIFO_FULL_MSK (0x00000001 << PAT_STATUS_FIFO_FULL_OFST)
#define PAT_STATUS_DLY_AFTR_TRGGR_OFST (0)
#define PAT_STATUS_DLY_AFTR_TRGGR_OFST (15)
#define PAT_STATUS_DLY_AFTR_TRGGR_MSK (0x00000001 << PAT_STATUS_DLY_AFTR_TRGGR_OFST)
#define PAT_STATUS_CSM_BUSY_OFST (0)
#define PAT_STATUS_CSM_BUSY_OFST (17)
#define PAT_STATUS_CSM_BUSY_MSK (0x00000001 << PAT_STATUS_CSM_BUSY_OFST)
/* Delay left 64bit Register */
@ -184,6 +221,9 @@
/* External Signal register */
#define EXT_SIGNAL_REG (0x30 * REG_OFFSET + BASE_PATTERN_CONTROL)
#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_PATTERN_CONTROL)
#define SET_TRIGGER_DELAY_MSB_REG (0x33 * REG_OFFSET + BASE_PATTERN_CONTROL)

View File

@ -21,6 +21,7 @@
// Global variable from slsDetectorServer_funcs
extern int debugflag;
extern udpStruct udpDetails;
extern const enum detectorType myDetectorType;
int initError = OK;
int initCheckDone = 0;
@ -32,12 +33,12 @@ int virtual_status = 0;
int virtual_stop = 0;
#endif
int32_t clkPhase[NUM_CLOCKS] = {0, 0, 0, 0, 0};
uint32_t clkFrequency[NUM_CLOCKS] = {0, 0, 0, 0, 0};
int32_t clkPhase[NUM_CLOCKS] = {};
uint32_t clkFrequency[NUM_CLOCKS] = {};
int highvoltage = 0;
int dacValues[NDAC] = {0};
int detPos[2] = {0, 0};
int detPos[2] = {};
uint32_t countermask = 0; // will be removed later when in firmware converted to mask
int isInitCheckDone() {
@ -84,13 +85,10 @@ void basictests() {
uint64_t macadd = getDetectorMAC();
int64_t fwversion = getFirmwareVersion();
int64_t swversion = getServerVersion();
int64_t sw_fw_apiversion = 0;
int64_t sw_fw_apiversion = getFirmwareAPIVersion();;
int64_t client_sw_apiversion = getClientServerAPIVersion();
uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN;
if (fwversion >= MIN_REQRD_VRSN_T_RD_API)
sw_fw_apiversion = getFirmwareAPIVersion();
FILE_LOG(logINFOBLUE, ("*************************************************\n"
"Hardware Version:\t\t 0x%x\n"
@ -161,7 +159,7 @@ int checkType() {
#ifdef VIRTUAL
return OK;
#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 != MYTHEN3){
FILE_LOG(logERROR, ("This is not a Mythen3 Server (read %d, expected %d)\n", type, MYTHEN3));
return FAIL;
@ -251,7 +249,7 @@ u_int32_t getDetectorNumber(){
#ifdef VIRTUAL
return 0;
#endif
return bus_r(MCB_SERIAL_NO_REG);
return ((bus_r(MCB_SERIAL_NO_REG) & MCB_SERIAL_NO_VRSN_MSK) >> MCB_SERIAL_NO_VRSN_OFST);
}
@ -305,10 +303,14 @@ u_int32_t getDetectorIP(){
/* initialization */
void initControlServer(){
CreateNotificationForCriticalTasks();
if (initError == OK) {
setupDetector();
}
initCheckDone = 1;
if (initError == OK) {
NotifyServerStartSuccess();
}
}
void initStopServer() {
@ -609,7 +611,6 @@ int setDelayAfterTrigger(int64_t val) {
int64_t getDelayAfterTrigger() {
return get64BitReg(SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG) / (1E-9 * FIXED_PLL_FREQUENCY);
}
int64_t getNumFramesLeft() {
@ -706,10 +707,25 @@ int setHighVoltage(int val){
/* parameters - timing */
void setTiming( enum timingMode arg){
// to be implemented
if(arg != GET_TIMING_MODE){
switch (arg) {
case AUTO_TIMING:
FILE_LOG(logINFO, ("Set Timing: Auto\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
break;
case TRIGGER_EXPOSURE:
FILE_LOG(logINFO, ("Set Timing: Trigger\n"));
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK);
break;
default:
FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg));
}
}
}
enum timingMode getTiming() {
if (bus_r(EXT_SIGNAL_REG) == EXT_SIGNAL_MSK)
return TRIGGER_EXPOSURE;
return AUTO_TIMING;
}
@ -835,6 +851,43 @@ void calcChecksum(udp_header* udp) {
udp->ip_checksum = checksum;
}
int setDetectorPosition(int pos[]) {
memcpy(detPos, pos, sizeof(detPos));
uint32_t addr = COORD_0_REG;
int value = 0;
int valueRead = 0;
int ret = OK;
// row
value = detPos[X];
bus_w(addr, (bus_r(addr) &~COORD_ROW_MSK) | ((value << COORD_ROW_OFST) & COORD_ROW_MSK));
valueRead = ((bus_r(addr) & COORD_ROW_MSK) >> COORD_ROW_OFST);
if (valueRead != value) {
FILE_LOG(logERROR, ("Could not set row. Set %d, read %d\n", value, valueRead));
ret = FAIL;
}
// col
value = detPos[Y];
bus_w(addr, (bus_r(addr) &~COORD_COL_MSK) | ((value << COORD_COL_OFST) & COORD_COL_MSK));
valueRead = ((bus_r(addr) & COORD_COL_MSK) >> COORD_COL_OFST);
if (valueRead != value) {
FILE_LOG(logERROR, ("Could not set column. Set %d, read %d\n", value, valueRead));
ret = FAIL;
}
if (ret == OK) {
FILE_LOG(logINFO, ("\tPosition set to [%d, %d]\n", detPos[X], detPos[Y]));
}
return ret;
}
int* getDetectorPosition() {
return detPos;
}
/* pattern */
uint64_t readPatternWord(int addr) {
@ -1052,6 +1105,22 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
}
}
void setPatternMask(uint64_t mask) {
set64BitReg(mask, PATTERN_MASK_LSB_REG, PATTERN_MASK_MSB_REG);
}
uint64_t getPatternMask() {
return get64BitReg(PATTERN_MASK_LSB_REG, PATTERN_MASK_MSB_REG);
}
void setPatternBitMask(uint64_t mask) {
set64BitReg(mask, PATTERN_SET_LSB_REG, PATTERN_SET_MSB_REG);
}
uint64_t getPatternBitMask() {
return get64BitReg(PATTERN_SET_LSB_REG, PATTERN_SET_MSB_REG);
}
int checkDetectorType() {
FILE_LOG(logINFO, ("Checking type of module\n"));
FILE* fd = fopen(TYPE_FILE_NAME, "r");
@ -1067,13 +1136,13 @@ int checkDetectorType() {
return -1;
}
int type = atoi(buffer);
if (type > TYPE_TOLERANCE) {
if (type > TYPE_NO_MODULE_STARTING_VAL) {
FILE_LOG(logERROR, ("No Module attached! Expected %d for Mythen, got %d\n", TYPE_MYTHEN3_MODULE_VAL, type));
return -2;
}
if (abs(type - TYPE_MYTHEN3_MODULE_VAL) > TYPE_TOLERANCE) {
FILE_LOG(logERROR, ("Wrong Module attached! Expected %d for Mythen, got %d\n", TYPE_MYTHEN3_MODULE_VAL, type));
FILE_LOG(logERROR, ("Wrong Module attached! Expected %d for Mythen3, got %d\n", TYPE_MYTHEN3_MODULE_VAL, type));
return FAIL;
}
return OK;
@ -1134,8 +1203,8 @@ int setPhase(enum CLKINDEX ind, int val, int degrees) {
relativePhase *= -1;
direction = 0;
}
int pllIndex = ind >= SYSTEM_C0 ? SYSTEM_PLL : READOUT_PLL;
int clkIndex = ind >= SYSTEM_C0 ? ind - SYSTEM_C0 : ind;
int pllIndex = (int)(ind >= SYSTEM_C0 ? SYSTEM_PLL : READOUT_PLL);
int clkIndex = (int)(ind >= SYSTEM_C0 ? ind - SYSTEM_C0 : ind);
ALTERA_PLL_C10_SetPhaseShift(pllIndex, clkIndex, relativePhase, direction);
clkPhase[ind] = valShift;
@ -1207,7 +1276,7 @@ int getVCOFrequency(enum CLKINDEX ind) {
FILE_LOG(logERROR, ("Unknown clock index %d to get vco frequency\n", ind));
return -1;
}
int pllIndex = ind >= SYSTEM_C0 ? SYSTEM_PLL : READOUT_PLL;
int pllIndex = (int)(ind >= SYSTEM_C0 ? SYSTEM_PLL : READOUT_PLL);
return ALTERA_PLL_C10_GetVCOFrequency(pllIndex);
}
@ -1225,7 +1294,7 @@ int setClockDivider(enum CLKINDEX ind, int val) {
}
char* clock_names[] = {CLK_NAMES};
int vcofreq = getVCOFrequency(ind);
int currentdiv = vcofreq / clkFrequency[ind];
int currentdiv = vcofreq / (int)clkFrequency[ind];
int newfreq = vcofreq / val;
FILE_LOG(logINFO, ("\tSetting %s clock (%d) divider from %d (%d Hz) to %d (%d Hz). \n\t(Vcofreq: %d Hz)\n", clock_names[ind], ind, currentdiv, clkFrequency[ind], val, newfreq, vcofreq));
@ -1240,8 +1309,8 @@ int setClockDivider(enum CLKINDEX ind, int val) {
}
// Calculate and set output frequency
int pllIndex = ind >= SYSTEM_C0 ? SYSTEM_PLL : READOUT_PLL;
int clkIndex = ind >= SYSTEM_C0 ? ind - SYSTEM_C0 : ind;
int pllIndex = (int)(ind >= SYSTEM_C0 ? SYSTEM_PLL : READOUT_PLL);
int clkIndex = (int)(ind >= SYSTEM_C0 ? ind - SYSTEM_C0 : ind);
ALTERA_PLL_C10_SetOuputFrequency (pllIndex, clkIndex, newfreq);
clkFrequency[ind] = newfreq;
FILE_LOG(logINFO, ("\t%s clock (%d) divider set to %d (%d Hz)\n", clock_names[ind], ind, val, clkFrequency[ind]));
@ -1275,20 +1344,11 @@ int getClockDivider(enum CLKINDEX ind) {
FILE_LOG(logERROR, ("Unknown clock index %d to get clock divider\n", ind));
return -1;
}
return (getVCOFrequency(ind) / clkFrequency[ind]);
return (getVCOFrequency(ind) / (int)clkFrequency[ind]);
}
/* aquisition */
int setDetectorPosition(int pos[]) {
memcpy(detPos, pos, sizeof(detPos));
return OK;
}
int* getDetectorPosition() {
return detPos;
}
int startStateMachine(){
#ifdef VIRTUAL
// create udp socket
@ -1327,8 +1387,21 @@ void* start_timer(void* arg) {
getNumTriggers() );
int64_t exp_ns = getExpTime();
int imagesize = calculateDataBytes();
int datasize = imagesize / PACKETS_PER_FRAME;
int packetsize = datasize + sizeof(sls_detector_header);
int frameNr = 0;
// Generate data
char imageData[imagesize];
memset(imageData, 0, imagesize);
{
int i = 0;
for (i = 0; i < imagesize; i += sizeof(uint8_t)) {
*((uint8_t*)(imageData + i)) = i;
}
}
int frameNr = 1;
// loop over number of frames
for (frameNr = 0; frameNr != numFrames; ++frameNr) {
@ -1336,13 +1409,42 @@ void* start_timer(void* arg) {
if(virtual_stop == 1){
break;
}
int srcOffset = 0;
// sleep for exposure time
struct timespec begin, end;
clock_gettime(CLOCK_REALTIME, &begin);
usleep(exp_ns / 1000);
clock_gettime(CLOCK_REALTIME, &end);
// loop packet
{
int i = 0;
for(i = 0; i!=PACKETS_PER_FRAME; ++i) {
char packetData[packetsize];
memset(packetData, 0, packetsize);
// set header
sls_detector_header* header = (sls_detector_header*)(packetData);
header->frameNumber = frameNr + 1;
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
memcpy(packetData + sizeof(sls_detector_header), imageData + srcOffset, datasize);
srcOffset += datasize;
sendUDPPacket(0, packetData, packetsize);
}
}
FILE_LOG(logINFO, ("Sent frame: %d\n", frameNr));
// calculate time left in period
clock_gettime(CLOCK_REALTIME, &end);
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
(end.tv_nsec - begin.tv_nsec));
@ -1450,7 +1552,6 @@ void readFrame(int *ret, char *mess){
} else {
FILE_LOG(logINFOGREEN, ("Acquisition successfully finished\n"));
}
}
u_int32_t runBusy() {
@ -1458,17 +1559,25 @@ u_int32_t runBusy() {
return virtual_status;
#endif
u_int32_t s = (bus_r(PAT_STATUS_REG) & PAT_STATUS_RUN_BUSY_MSK);
FILE_LOG(logDEBUG1, ("Status Register: %08x\n", s));
//FILE_LOG(logDEBUG1, ("Status Register: %08x\n", s));
return s;
}
/* common */
int calculateDataBytes() {
return 0;
int numCounters = __builtin_popcount(getCounterMask());
int dr = setDynamicRange(-1);
int databytes = NCHAN_1_COUNTER * NCHIP * numCounters *
((dr > 16) ? 4 : // 32 bit
((dr > 8) ? 2 : // 16 bit
((dr > 4) ? 0.5 : // 4 bit
0.125))); // 1 bit
return databytes;
}
int getTotalNumberOfChannels(){return ((int)getNumberOfChannelsPerChip() * (int)getNumberOfChips());}
int getTotalNumberOfChannels() {return (getNumberOfChannelsPerChip() * getNumberOfChips());}
int getNumberOfChips() {return NCHIP;}
int getNumberOfDACs() {return NDAC;}
int getNumberOfChannelsPerChip() {return NCHAN;}

View File

@ -2,13 +2,13 @@
#include "sls_detector_defs.h"
#define REQRD_FRMWRE_VRSN 0x190000
#define MIN_REQRD_VRSN_T_RD_API 0x190000
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
/* Hardware Definitions */
#define NCOUNTERS (3)
#define MAX_COUNTER_MSK (0x7)
#define NCHAN_1_COUNTER (128)
#define NCHAN (128 * NCOUNTERS)
#define NCHIP (10)
#define NDAC (16)
@ -45,7 +45,6 @@
#define READOUT_PLL_VCO_FREQ_HZ (1250000000) // 1.25GHz
#define SYSTEM_PLL_VCO_FREQ_HZ (1250000000) // 1.25GHz
#define MAX_PATTERN_LENGTH (0x2000) // maximum number of words (64bit)
#define WAIT_TIME_US_STP_ACQ (100)
/** Other Definitions */
#define BIT16_MASK (0xFFFF)
@ -98,3 +97,4 @@ typedef struct udp_header_struct {
uint16_t udp_destport;
} udp_header;
#define UDP_IP_HEADER_LENGTH_BYTES (28)
#define PACKETS_PER_FRAME (2)

View File

@ -1,6 +1,7 @@
#pragma once
#include <stdio.h>
#include <stdint.h>
/**
* Define GPIO pins if not defined
@ -49,4 +50,4 @@ void stopWritingFPGAprogram(FILE* filefp);
* @param filefp pointer to flash
* @return 0 for success, 1 for fail (cannot write)
*/
int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp);
int writeFPGAProgram(char* fpgasrc, uint64_t fsize, FILE* filefp);

View File

@ -0,0 +1,48 @@
#pragma once
#include <stdio.h>
#include <stdint.h>
#define NIOS_MAX_APP_IMAGE_SIZE (0x00580000)
/** Notify microcontroller of successful server start up */
void NotifyServerStartSuccess();
/** create notification file to notify watchdog of critical tasks (to not shutdown) */
void CreateNotificationForCriticalTasks();
/** write 1 to notification file to postpone shut down process if requested*/
void NotifyCriticalTask();
/** write 0 to notification file to allow shut down process if requested */
void NotifyCriticalTaskDone();
/** reset fpga and controller(only implemented for >= v1.1 boards) */
void rebootControllerAndFPGA();
/** finds the right mtd drive
* @param mess error message
* @returns ok or fail
*/
int findFlash(char* mess);
/** erase flash */
void eraseFlash();
/** erase and write flash
* @param mess error message
* @param fpgasrc program source
* @param fsize file size
* @returns ok or fail
*/
int eraseAndWriteToFlash(char* mess, char* fpgasrc, uint64_t fsize);
/**
* Write FPGA Program to flash
* @param mess error message
* @param fpgasrc source program
* @param fsize size of program
* @param filefp pointer to flash
* @return ok or fail
*/
int writeFPGAProgram(char* mess, char* fpgasrc, uint64_t fsize, FILE* filefp);

View File

@ -84,11 +84,10 @@ int updateDatabytesandAllocateRAM();
void updateDataBytes();
#endif
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MYTHEN3D) || GOTTHARD2D
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MYTHEN3D)
int setDefaultDacs();
#endif
#ifdef GOTTHARD2D
int setDefaultOnChipDacs();
int readConfigFile();
#endif
@ -101,13 +100,13 @@ int readRegister(uint32_t offset, uint32_t* retval);
uint32_t writeRegister16And32(uint32_t offset, uint32_t data); //FIXME its not there in ctb or moench?
uint32_t readRegister16And32(uint32_t offset);
#else
extern u_int32_t writeRegister(u_int32_t offset, u_int32_t data); // blackfin.h
extern u_int32_t readRegister(u_int32_t offset); // blackfin.h
extern u_int32_t writeRegister(u_int32_t offset, u_int32_t data); // blackfin.h or nios.h
extern u_int32_t readRegister(u_int32_t offset); // blackfin.h or nios.h
#endif
// firmware functions (resets)
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D)
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
void cleanFifos();
void resetCore();
void resetPeripheral();
@ -178,6 +177,20 @@ int setExpTime(int64_t val);
int64_t getExpTime();
int setPeriod(int64_t val);
int64_t getPeriod();
#ifdef GOTTHARD2D
void setNumFramesBurst(int64_t val);
int64_t getNumFramesBurst();
void setNumFramesCont(int64_t val);
int64_t getNumFramesCont();
int setExptimeBurst(int64_t val);
int setExptimeCont(int64_t val);
int setExptimeBoth(int64_t val);
int64_t getExptimeBoth();
int setPeriodBurst(int64_t val);
int64_t getPeriodBurst();
int setPeriodCont(int64_t val);
int64_t getPeriodCont();
#endif
#ifdef EIGERD
int setSubExpTime(int64_t val);
int64_t getSubExpTime();
@ -203,22 +216,18 @@ void setCounterMask(uint32_t arg);
uint32_t getCounterMask();
#endif
#if defined(JUNGFRAUD) || defined(GOTTHARDD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D)
#if defined(JUNGFRAUD) || defined(GOTTHARDD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
int setDelayAfterTrigger(int64_t val);
int64_t getDelayAfterTrigger();
#endif
#if defined(JUNGFRAUD) || defined(GOTTHARDD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
int64_t getNumFramesLeft();
int64_t getNumTriggersLeft();
#endif
#if defined(JUNGFRAUD) || defined(GOTTHARDD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D)
int64_t getDelayAfterTriggerLeft();
int64_t getPeriodLeft();
#endif
#ifdef GOTTHARDD
int64_t getExpTimeLeft();
#endif
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D)
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
int64_t getFramesFromStart();
int64_t getActualTime();
int64_t getMeasurementTime();
@ -230,9 +239,11 @@ int64_t getMeasurementTime();
#if (!defined(CHIPTESTBOARDD)) && (!defined(MOENCHD)) && (!defined(MYTHEN3D)) && (!defined(GOTTHARD2D))
int setModule(sls_detector_module myMod, char* mess);
int getModule(sls_detector_module *myMod);
#endif
#if (!defined(CHIPTESTBOARDD)) && (!defined(MOENCHD)) && (!defined(MYTHEN3D))
enum detectorSettings setSettings(enum detectorSettings sett);
#endif
#if !defined(MYTHEN3D) && !defined(GOTTHARD2D)
#if !defined(MYTHEN3D)
enum detectorSettings getSettings();
#endif
@ -293,10 +304,8 @@ int setHighVoltage(int val);
// parameters - timing, extsig
#if !defined(GOTTHARD2D)
void setTiming( enum timingMode arg);
enum timingMode getTiming();
#endif
#ifdef GOTTHARDD
void setExtSignal(enum externalSignalFlag mode);
int getExtSignal();
@ -324,7 +333,6 @@ int getAdcConfigured();
int configureMAC();
int setDetectorPosition(int pos[]);
int* getDetectorPosition();
int isConfigurable();
#ifdef EIGERD
@ -358,10 +366,10 @@ int getFrequency(enum CLKINDEX ind);
void configureSyncFrequency(enum CLKINDEX ind);
void setPipeline(enum CLKINDEX ind, int val);
int getPipeline(enum CLKINDEX ind);
extern void eraseFlash(); // programfpga.h
extern int startWritingFPGAprogram(FILE** filefp); // programfpga.h
extern void stopWritingFPGAprogram(FILE* filefp); // programfpga.h
extern int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp); // programfpga.h
extern void eraseFlash(); // programFpgaBlackfin.h
extern int startWritingFPGAprogram(FILE** filefp); // programFpgaBlackfin.h
extern void stopWritingFPGAprogram(FILE* filefp); // programFpgaBlackfin.h
extern int writeFPGAProgram(char* fpgasrc, uint64_t fsize, FILE* filefp); // programFpgaBlackfin.h
// patterns
uint64_t writePatternIOControl(uint64_t word);
uint64_t writePatternClkControl(uint64_t word);
@ -393,10 +401,10 @@ int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval);
int setThresholdTemperature(int val);
int setTemperatureControl(int val);
int setTemperatureEvent(int val);
extern void eraseFlash(); // programfpga.h
extern int startWritingFPGAprogram(FILE** filefp); // programfpga.h
extern void stopWritingFPGAprogram(FILE* filefp); // programfpga.h
extern int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp); // programfpga.h
extern void eraseFlash(); // programFpgaBlackfin.h
extern int startWritingFPGAprogram(FILE** filefp); // programFpgaBlackfin.h
extern void stopWritingFPGAprogram(FILE* filefp); // programFpgaBlackfin.h
extern int writeFPGAProgram(char* fpgasrc, uint64_t fsize, FILE* filefp); // programFpgaBlackfin.h
void alignDeserializer();
// eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter
@ -429,6 +437,10 @@ uint64_t writePatternWord(int addr, uint64_t word);
int setPatternWaitAddress(int level, int addr);
uint64_t setPatternWaitTime(int level, uint64_t t);
void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop);
void setPatternMask(uint64_t mask);
uint64_t getPatternMask();
void setPatternBitMask(uint64_t mask);
uint64_t getPatternBitMask();
int checkDetectorType();
int powerChip (int on);
int setPhase(enum CLKINDEX ind, int val, int degrees);
@ -443,6 +455,8 @@ int setClockDivider(enum CLKINDEX ind, int val);
int getClockDivider(enum CLKINDEX ind);
#elif GOTTHARD2D
int checkDetectorType();
int powerChip (int on);
int setPhase(enum CLKINDEX ind, int val, int degrees);
int getPhase(enum CLKINDEX ind, int degrees);
int getMaxPhase(enum CLKINDEX ind);
@ -460,12 +474,21 @@ int setVetoPhoton(int chipIndex, int gainIndex, int* values);
int getVetoPhoton(int chipIndex, int* retvals);
int configureSingleADCDriver(int chipIndex);
int configureADC();
int setBurstMode(int burst);
int getBurstMode();
int setBurstModeinFPGA(enum burstMode value);
int setBurstMode(enum burstMode burst);
enum burstMode getBurstMode();
#endif
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
extern void NotifyServerStartSuccess();
extern void CreateNotificationForCriticalTasks();
extern void rebootControllerAndFPGA(); // programFpgaNios.h
extern int findFlash(char* mess); // programFpgaNios.h
extern void eraseFlash(); // programFpgaNios.h
extern int eraseAndWriteToFlash(char* mess, char* fpgasrc, uint64_t fsize); // programFpgaNios.h
extern int writeFPGAProgram(char* mess, char* fpgasrc, uint64_t fsize, FILE* filefp); // programFpgaNios.h
#endif
#if defined(JUNGFRAUD) || defined(EIGERD)
@ -485,6 +508,9 @@ int setTransmissionDelayRight(int value);
// aquisition
#ifdef GOTTHARD2D
int updateAcquisitionRegisters(char* mess);
#endif
#ifdef EIGERD
int prepareAcquisition();
#endif

View File

@ -19,7 +19,9 @@ void validate(int arg, int retval, char* modename, enum numberMode nummode);
void validate64(int64_t arg, int64_t retval, char* modename, enum numberMode nummode);
int executeCommand(char* command, char* result, enum TLogLevel level);
int M_nofunc(int);
int M_nofuncMode(int);
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
extern void rebootControllerAndFPGA();
#endif
// functions called by client
int exec_command(int);
@ -199,7 +201,7 @@ int set_inject_channel(int);
int get_inject_channel(int);
int set_veto_photon(int);
int get_veto_photon(int);
int set_veto_refernce(int);
int set_veto_reference(int);
int get_burst_mode(int);
int set_burst_mode(int);
int set_adc_enable_mask_10g(int);

View File

@ -87,13 +87,9 @@ void ALTERA_PLL_C10_Reconfigure(int pllIndex) {
void ALTERA_PLL_C10_ResetPLL (int pllIndex) {
uint32_t resetreg = ALTERA_PLL_C10_Reset_Reg[pllIndex];
uint32_t resetmsk = ALTERA_PLL_C10_Reset_Msk[pllIndex];
#ifdef MYTHEN3D
FILE_LOG(logINFO, ("Resetting PLL %d\n", pllIndex));
bus_w_csp1(resetreg, bus_r_csp1(resetreg) | resetmsk);
#else
FILE_LOG(logWARNING, ("Resetting PLL %d not implemented!\n", pllIndex));
#endif
usleep(ALTERA_PLL_C10_WAIT_TIME_US);
}

View File

@ -28,16 +28,19 @@ void ASIC_Driver_SetDefines(char* driverfname) {
int ASIC_Driver_Set (int index, int length, char* buffer) {
char fname[MAX_STR_LENGTH];
sprintf(fname, "%s%d", ASIC_Driver_DriverFileName, index + 1);
FILE_LOG(logDEBUG1, ("\t[chip index: %d, length: %d, fname: %s]\n", index, length, fname));
FILE_LOG(logDEBUG2, ("\t[chip index: %d, length: %d, fname: %s]\n", index, length, fname));
{
FILE_LOG(logDEBUG1, ("\t[values: \n"));
FILE_LOG(logDEBUG2, ("\t[values: \n"));
int i;
for (i = 0; i < length; ++i) {
FILE_LOG(logDEBUG1, ("\t%d: 0x%02hhx\n", i, buffer[i]));
FILE_LOG(logDEBUG2, ("\t%d: 0x%02hhx\n", i, buffer[i]));
}
FILE_LOG(logDEBUG1, ("\t]\n"));
FILE_LOG(logDEBUG2, ("\t]\n"));
}
#ifdef VIRTUAL
return OK;
#endif
int fd=open(fname, O_RDWR);
if (fd == -1) {
FILE_LOG(logERROR, ("Could not open file %s for writing to control ASIC (%d)\n", fname, index));

View File

@ -252,8 +252,9 @@ void closeConnection(int file_des) {
}
void exitServer(int socketDescriptor) {
if (socketDescriptor >= 0)
if (socketDescriptor >= 0) {
close(socketDescriptor);
}
FILE_LOG(logINFO, ("Closing %s server\n", (isControlServer ? "control":"stop")));
FD_CLR(socketDescriptor, &readset);
isock--;

View File

@ -1,4 +1,4 @@
#include "programfpga.h"
#include "programFpgaBlackfin.h"
#include "ansi.h"
#include "clogger.h"
#include "slsDetectorServer_defs.h"
@ -57,6 +57,12 @@ int startWritingFPGAprogram(FILE** filefp){
FILE_LOG(logDEBUG1, ("Start Writing of FPGA program\n"));
//getting the drive
//root:/> cat /proc/mtd
//dev: size erasesize name
//mtd0: 00040000 00020000 "bootloader(nor)"
//mtd1: 00100000 00020000 "linux kernel(nor)"
//mtd2: 002c0000 00020000 "file system(nor)"
//mtd3: 01000000 00010000 "bitfile(spi)"
char output[255];
memset(output, 0, 255);
FILE* fp = popen("awk \'$4== \"\\\"bitfile(spi)\\\"\" {print $1}\' /proc/mtd", "r");
@ -120,14 +126,14 @@ void stopWritingFPGAprogram(FILE* filefp){
FILE_LOG(logINFO, ("FPGA has picked up the program from flash\n"));
}
int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp){
int writeFPGAProgram(char* fpgasrc, uint64_t fsize, FILE* filefp){
FILE_LOG(logDEBUG1, ("Writing of FPGA Program\n"
"\taddress of fpgasrc:%p\n"
"\tfsize:%lu\n\tpointer:%p\n",
(void *)fpgasrc, fsize, (void*)filefp));
"\tfsize:%llu\n\tpointer:%p\n",
(void *)fpgasrc, (long long unsigned int)fsize, (void*)filefp));
if(fwrite((void*)fpgasrc , sizeof(char) , fsize , filefp )!= fsize){
FILE_LOG(logERROR, ("Could not write FPGA source to flash (size:%lu)\n", fsize));
FILE_LOG(logERROR, ("Could not write FPGA source to flash (size:%llu)\n", (long long unsigned int)fsize));
return 1;
}
FILE_LOG(logDEBUG1, ("program written to flash\n"));

View File

@ -0,0 +1,152 @@
#include "programFpgaNios.h"
#include "ansi.h"
#include "clogger.h"
#include "slsDetectorServer_defs.h"
#include <unistd.h> // usleep
#include <string.h>
/* global variables */
#define MTDSIZE 10
char mtdvalue[MTDSIZE] = {0};
#define NOTIFICATION_FILE "/tmp/block_shutdown"
#define MICROCONTROLLER_FILE "/dev/ttyAL0"
void NotifyServerStartSuccess() {
FILE_LOG(logINFOBLUE, ("Server started successfully\n"));
char command[255];
memset(command, 0, 255);
sprintf(command,"echo r > %s",MICROCONTROLLER_FILE);
system(command);
}
void CreateNotificationForCriticalTasks() {
FILE* fd = fopen(NOTIFICATION_FILE, "r");
if (fd == NULL) {
fd = fopen(NOTIFICATION_FILE, "w");
if (fd == NULL) {
FILE_LOG(logERROR, ("Could not create notication file: %s\n", NOTIFICATION_FILE));
return;
}
FILE_LOG(logINFOBLUE, ("Created notification file: %s\n", NOTIFICATION_FILE));
}
fclose(fd);
NotifyCriticalTaskDone();
}
void NotifyCriticalTask() {
FILE_LOG(logINFO, ("\tNotifying Critical Task Ongoing\n"));
char command[255];
memset(command, 0, 255);
sprintf(command,"echo 1 > %s",NOTIFICATION_FILE);
system(command);
}
void NotifyCriticalTaskDone() {
FILE_LOG(logINFO, ("\tNotifying Critical Task Done\n"));
char command[255];
memset(command, 0, 255);
sprintf(command,"echo 0 > %s",NOTIFICATION_FILE);
system(command);
}
void rebootControllerAndFPGA() {
FILE_LOG(logDEBUG1, ("Reseting FPGA...\n"));
char command[255];
memset(command, 0, 255);
sprintf(command,"echo z > %s",MICROCONTROLLER_FILE);
system(command);
}
int findFlash(char* mess) {
FILE_LOG(logDEBUG1, ("Finding flash drive...\n"));
//getting the drive
// # cat /proc/mtd
// dev: size erasesize name
// mtd0: 00580000 00010000 "qspi BootInfo + Factory Image"
// mtd1: 00580000 00010000 "qspi Application Image"
// mtd2: 00800000 00010000 "qspi Linux Kernel with initramfs"
// mtd3: 00800000 00010000 "qspi Linux Kernel with initramfs Backup"
// mtd4: 02500000 00010000 "qspi ubi filesystem"
// mtd5: 04000000 00010000 "qspi Complete Flash"
char output[255];
memset(output, 0, 255);
FILE* fp = popen("awk \'$5== \"Application\" {print $1}\' /proc/mtd", "r");
if (fp == NULL) {
strcpy(mess, "popen returned NULL. Need that to get mtd drive.\n");
FILE_LOG(logERROR, (mess));
return RO_TRIGGER_IN_FALLING_EDGE;
}
if (fgets(output, sizeof(output), fp) == NULL) {
strcpy(mess, "fgets returned NULL. Need that to get mtd drive.\n");
FILE_LOG(logERROR, (mess));
return FAIL;
}
pclose(fp);
memset(mtdvalue, 0, MTDSIZE);
strcpy(mtdvalue, "/dev/");
char* pch = strtok(output, ":");
if (pch == NULL){
strcpy (mess, "Could not get mtd value\n");
FILE_LOG(logERROR, (mess));
return FAIL;
}
strcat(mtdvalue, pch);
FILE_LOG(logINFO, ("\tFlash drive found: %s\n", mtdvalue));
return OK;
}
void eraseFlash() {
FILE_LOG(logDEBUG1, ("Erasing Flash...\n"));
char command[255];
memset(command, 0, 255);
sprintf(command,"flash_erase %s 0 0",mtdvalue);
system(command);
FILE_LOG(logINFO, ("\tFlash erased\n"));
}
int eraseAndWriteToFlash(char* mess, char* fpgasrc, uint64_t fsize) {
if (findFlash(mess) == FAIL) {
return FAIL;
}
NotifyCriticalTask();
eraseFlash();
// open file pointer to flash
FILE *filefp = fopen(mtdvalue, "w");
if(filefp == NULL){
NotifyCriticalTaskDone();
sprintf (mess, "Unable to open %s in write mode\n", mtdvalue);
FILE_LOG(logERROR, (mess));
return FAIL;
}
FILE_LOG(logINFO, ("\tFlash ready for writing\n"));
// write to flash
if (writeFPGAProgram(mess, fpgasrc, fsize, filefp) == FAIL) {
NotifyCriticalTaskDone();
fclose(filefp);
return FAIL;
}
fclose(filefp);
NotifyCriticalTaskDone();
return OK;
}
int writeFPGAProgram(char* mess, char* fpgasrc, uint64_t fsize, FILE* filefp) {
FILE_LOG(logDEBUG1, ("Writing to flash...\n"
"\taddress of fpgasrc:%p\n"
"\tfsize:%lu\n\tpointer:%p\n",
(void *)fpgasrc, fsize, (void*)filefp));
uint64_t retval = fwrite((void*)fpgasrc , sizeof(char) , fsize , filefp);
if (retval != fsize) {
sprintf (mess, "Could not write FPGA source to flash (size:%llu), write %llu\n", (long long unsigned int) fsize, (long long unsigned int)retval);
FILE_LOG(logERROR, (mess));
return FAIL;
}
FILE_LOG(logINFO, ("\tProgram written to flash\n"));
return OK;
}

View File

@ -10,7 +10,7 @@
#include <signal.h>
#include <string.h>
#include <unistd.h>
// Global variables from communication_funcs
extern int isControlServer;
@ -19,6 +19,8 @@ extern int ret;
// Global variables from slsDetectorServer_funcs
extern int sockfd;
extern int debugflag;
extern int checkModuleFlag;
// Global variables from slsDetectorFunctionList
#ifdef GOTTHARDD
@ -67,7 +69,11 @@ int main(int argc, char *argv[]){
FILE_LOG(logINFO, ("Detected developer mode\n"));
debugflag = 1;
}
else if(!strcasecmp(argv[i],"--port")){
else if(!strcasecmp(argv[i],"-nomodule")){
FILE_LOG(logINFO, ("Detected No Module mode\n"));
checkModuleFlag = 0;
}
else if(!strcasecmp(argv[i],"-port")){
if ((i + 1) >= argc) {
FILE_LOG(logERROR, ("no port value given. Exiting.\n"));
return -1;
@ -105,7 +111,7 @@ int main(int argc, char *argv[]){
int i;
for (i = 0; i < argc; ++i)
sprintf(cmd, "%s %s", cmd, argv[i]);
sprintf(cmd,"%s -stopserver --port %d &", cmd, portno + 1);
sprintf(cmd,"%s -stopserver -port %d &", cmd, portno + 1);
FILE_LOG(logDEBUG1, ("Command to start stop server:%s\n", cmd));
system(cmd);
}
@ -143,9 +149,13 @@ int main(int argc, char *argv[]){
exitServer(sockfd);
if (retval == REBOOT) {
FILE_LOG(logINFOBLUE,("Rebooting!\n"));
FILE_LOG(logINFORED,("Rebooting!\n"));
fflush(stdout);
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
rebootControllerAndFPGA();
#else
system("reboot");
#endif
}
FILE_LOG(logINFO,("Goodbye!\n"));
return 0;

View File

@ -2,6 +2,13 @@
#include "slsDetectorFunctionList.h"
#include "communication_funcs.h"
#include "clogger.h"
#ifndef VIRTUAL
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
#include "programFpgaNios.h"
#elif defined(CHIPTESTBOARDD) || defined(JUNGFRAUD) || defined(MOENCHD)
#include "programFpgaBlackfin.h"
#endif
#endif
#include <string.h>
#include <arpa/inet.h>
@ -39,6 +46,7 @@ extern char mess[MAX_STR_LENGTH];
// Variables that will be exported
int sockfd = 0;
int debugflag = 0;
int checkModuleFlag = 1;
udpStruct udpDetails = {32410, 32411, 50001, 50002, 0, 0, 0, 0, 0, 0, 0, 0};
int configured = FAIL;
char configureMessage[MAX_STR_LENGTH]="udp parameters not configured yet";
@ -484,7 +492,7 @@ void function_table() {
flist[F_GET_INJECT_CHANNEL] = &get_inject_channel;
flist[F_SET_VETO_PHOTON] = &set_veto_photon;
flist[F_GET_VETO_PHOTON] = &get_veto_photon;
flist[F_SET_VETO_REFERENCE] = &set_veto_refernce;
flist[F_SET_VETO_REFERENCE] = &set_veto_reference;
flist[F_GET_BURST_MODE] = &get_burst_mode;
flist[F_SET_BURST_MODE] = &set_burst_mode;
flist[F_SET_ADC_ENABLE_MASK_10G] = &set_adc_enable_mask_10g;
@ -593,27 +601,6 @@ int M_nofunc(int file_des) {
}
// Jungfrau program mode
int M_nofuncMode(int file_des) {
ret = FAIL;
memset(mess, 0, sizeof(mess));
// to receive any arguments
int n = 1;
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
sprintf(mess,"This Function %s cannot be executed as the "
"On-board detector server in update mode.\n"
"Restart detector server in normal mode (without any arguments) to continue.\n",
getFunctionName((enum detFuncs)fnum));
FILE_LOG(logERROR, (mess));
return Server_SendResult(file_des, OTHER, NO_UPDATE, NULL, 0);
}
int exec_command(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
@ -685,10 +672,6 @@ int set_timing_mode(int file_des) {
return printSocketReadError();
FILE_LOG(logDEBUG1, ("Setting external communication mode to %d\n", arg));
#ifdef GOTTHARD2D
functionNotImplemented();
#else
// set
if ((arg != GET_TIMING_MODE) && (Server_VerifyLock() == OK)) {
switch (arg) {
@ -709,7 +692,6 @@ int set_timing_mode(int file_des) {
retval = getTiming();
validate((int)arg, (int)retval, "set timing mode", DEC);
FILE_LOG(logDEBUG1, ("Timing Mode: %d\n",retval));
#endif
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
}
@ -1000,8 +982,8 @@ int set_dac(int file_des) {
case VCOM_CDS:
serverDacIndex = G2_VCOM_CDS;
break;
case VREF_RESTORE:
serverDacIndex = G2_VREF_RESTORE;
case VREF_RSTORE:
serverDacIndex = G2_VREF_RSTORE;
break;
case VB_OPA_1ST:
serverDacIndex = G2_VB_OPA_1ST;
@ -1658,7 +1640,7 @@ int set_settings(int file_des) {
if (receiveData(file_des, &isett, sizeof(isett), INT32) < 0)
return printSocketReadError();
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D)
functionNotImplemented();
#else
FILE_LOG(logDEBUG1, ("Setting settings %d\n", isett));
@ -1682,12 +1664,16 @@ int set_settings(int file_des) {
case LOWGAIN:
case MEDIUMGAIN:
case VERYHIGHGAIN:
#elif GOTTHARD2D
case DYNAMICGAIN:
case FIXGAIN1:
case FIXGAIN2:
#endif
break;
default:
if (myDetectorType == EIGER) {
ret = FAIL;
sprintf(mess, "Cannot set settings via SET_SETTINGS, use SET_MODULE\n");
sprintf(mess, "Cannot set settings via SET_SETTINGS, use SET_MODULE (set threshold)\n");
FILE_LOG(logERROR,(mess));
} else
modeNotImplemented("Settings Index", (int)isett);
@ -1700,6 +1686,7 @@ int set_settings(int file_des) {
FILE_LOG(logDEBUG1, ("Settings: %d\n", retval));
validate((int)isett, (int)retval, "set settings", DEC);
#if defined(JUNGFRAUD) || defined (GOTTHARDD)
// gotthard2 does not set default dacs
if (ret == OK && isett >= 0) {
ret = setDefaultDacs();
if (ret == FAIL) {
@ -1782,6 +1769,12 @@ int start_acquisition(int file_des) {
FILE_LOG(logERROR,(mess));
}
else
#endif
#ifdef GOTTHARD2D
if (updateAcquisitionRegisters(mess) == FAIL) {
ret = FAIL;
}
else
#endif
if (configured == FAIL) {
ret = FAIL;
@ -1792,12 +1785,8 @@ int start_acquisition(int file_des) {
if (ret == FAIL) {
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(VIRTUAL)
sprintf(mess, "Could not start acquisition. Could not create udp socket in server. Check udp_dstip & udp_dstport.\n");
#else
#if defined(GOTTHARD2D)
sprintf(mess, "Could not start acquisition due to #frames > %d in burst mode\n", MAX_FRAMES_IN_BURST_MODE);
#else
sprintf(mess, "Could not start acquisition\n");
#endif
#endif
FILE_LOG(logERROR,(mess));
}
@ -1916,6 +1905,12 @@ int start_and_read_all(int file_des) {
FILE_LOG(logERROR,(mess));
}
else
#endif
#ifdef GOTTHARD2D
if (updateAcquisitionRegisters(mess) == FAIL) {
ret = FAIL;
}
else
#endif
if (configured == FAIL) {
ret = FAIL;
@ -1926,12 +1921,8 @@ int start_and_read_all(int file_des) {
if (ret == FAIL) {
#if defined(VIRTUAL) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
sprintf(mess, "Could not start acquisition. Could not create udp socket in server. Check udp_dstip & udp_dstport.\n");
#else
#if defined(GOTTHARD2D)
sprintf(mess, "Could not start acquisition due to #frames > %d in burst mode\n", MAX_FRAMES_IN_BURST_MODE);
#else
sprintf(mess, "Could not start acquisition\n");
#endif
#endif
FILE_LOG(logERROR,(mess));
}
@ -2225,7 +2216,7 @@ int get_delay_after_trigger(int file_des) {
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D)
#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// get only
@ -2244,7 +2235,7 @@ int set_delay_after_trigger(int file_des) {
return printSocketReadError();
FILE_LOG(logDEBUG1, ("Setting delay after trigger %lld ns\n", (long long int)arg));
#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D)
#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// only set
@ -2458,7 +2449,7 @@ int get_period_left(int file_des) {
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D)
#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// get only
@ -2473,7 +2464,7 @@ int get_delay_after_trigger_left(int file_des) {
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D)
#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// get only
@ -2518,7 +2509,7 @@ int get_frames_from_start(int file_des) {
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
#if !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D)
#if !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// get only
@ -2533,7 +2524,7 @@ int get_actual_time(int file_des) {
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
#if !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D)
#if !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// get only
@ -2548,7 +2539,7 @@ int get_measurement_time(int file_des) {
memset(mess, 0, sizeof(mess));
int64_t retval = -1;
#if !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D)
#if !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// get only
@ -2582,7 +2573,7 @@ int set_dynamic_range(int file_des) {
#elif EIGERD
case 4: case 8: case 16: case 32:
#endif
#if defined(GOTTHARD) || defined(JUNGFRAU) || defined(CHIPTESTBOARD) || defined(MOENCH) || defined(GOTTHARD2)
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(GOTTHARD2D)
case 16:
#endif
retval = setDynamicRange(dr);
@ -3190,7 +3181,7 @@ int set_pattern_mask(int file_des) {
return printSocketReadError();
FILE_LOG(logDEBUG1, ("Set Pattern Mask to %d\n", arg));
#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
#if !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// only set
@ -3211,7 +3202,7 @@ int get_pattern_mask(int file_des) {
FILE_LOG(logDEBUG1, ("Get Pattern Mask\n"));
#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
#if !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// only get
@ -3231,7 +3222,7 @@ int set_pattern_bit_mask(int file_des) {
return printSocketReadError();
FILE_LOG(logDEBUG1, ("Set Pattern Bit Mask to %d\n", arg));
#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
#if !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// only set
@ -3252,7 +3243,7 @@ int get_pattern_bit_mask(int file_des){
FILE_LOG(logDEBUG1, ("Get Pattern Bit Mask\n"));
#if (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD))
#if !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
// only get
@ -3705,7 +3696,7 @@ int program_fpga(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
#if defined(EIGERD) || defined(GOTTHARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
#if defined(EIGERD) || defined(GOTTHARDD)
//to receive any arguments
int n = 1;
while (n > 0)
@ -3718,9 +3709,38 @@ int program_fpga(int file_des) {
FILE_LOG(logINFOBLUE, ("Programming FPGA...\n"));
size_t filesize = 0;
size_t totalsize = 0;
size_t unitprogramsize = 0;
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
uint64_t filesize = 0;
// filesize
if (receiveData(file_des,&filesize,sizeof(filesize),INT64) < 0)
return printSocketReadError();
FILE_LOG(logDEBUG1, ("Total program size is: %llx\n", (long long unsigned int)filesize));
if (filesize > NIOS_MAX_APP_IMAGE_SIZE) {
ret = FAIL;
sprintf(mess,"Could not start programming FPGA. File size 0x%llx exceeds max size 0x%llx. Forgot Compression?\n", (long long unsigned int) filesize, (long long unsigned int)NIOS_MAX_APP_IMAGE_SIZE);
FILE_LOG(logERROR,(mess));
}
Server_SendResult(file_des, INT32, NO_UPDATE, NULL, 0);
// receive program
if (ret == OK) {
char* fpgasrc = (char*)malloc(filesize);
if (receiveData(file_des, fpgasrc, filesize, OTHER) < 0)
return printSocketReadError();
ret = eraseAndWriteToFlash(mess, fpgasrc, filesize);
Server_SendResult(file_des, INT32, NO_UPDATE, NULL, 0);
//free resources
if (fpgasrc != NULL)
free(fpgasrc);
}
#else // jungfrau, ctb, moench
uint64_t filesize = 0;
uint64_t totalsize = 0;
uint64_t unitprogramsize = 0;
char* fpgasrc = NULL;
FILE* fp = NULL;
@ -3728,7 +3748,7 @@ int program_fpga(int file_des) {
if (receiveData(file_des,&filesize,sizeof(filesize),INT32) < 0)
return printSocketReadError();
totalsize = filesize;
FILE_LOG(logDEBUG1, ("Total program size is: %d\n", totalsize));
FILE_LOG(logDEBUG1, ("Total program size is: %lld\n", (long long unsigned int)totalsize));
// opening file pointer to flash and telling FPGA to not touch flash
@ -3753,7 +3773,7 @@ int program_fpga(int file_des) {
unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb
if (unitprogramsize > filesize) //less than 2mb
unitprogramsize = filesize;
FILE_LOG(logDEBUG1, ("unit size to receive is:%d\nfilesize:%d\n", unitprogramsize, filesize));
FILE_LOG(logDEBUG1, ("unit size to receive is:%lld\nfilesize:%lld\n", (long long unsigned int)unitprogramsize, (long long unsigned int)filesize));
//receive part of program
if (receiveData(file_des,fpgasrc,unitprogramsize,OTHER) < 0)
@ -3778,7 +3798,6 @@ int program_fpga(int file_des) {
fflush(stdout);
}
}
printf("\n");
if (ret == OK) {
FILE_LOG(logINFO, ("Done copying program\n"));
}
@ -3792,7 +3811,12 @@ int program_fpga(int file_des) {
if (fp != NULL)
fclose(fp);
FILE_LOG(logINFO, ("Completed program fpga command with %s\n", (ret == OK ? "success" : "fail")));
#endif // end of Blackfin programming
if (ret == FAIL) {
FILE_LOG(logERROR, ("Program FPGA FAIL!\n"));
} else {
FILE_LOG(logINFOGREEN, ("Programming FPGA completed successfully\n"));
}
}
#endif
#endif
@ -3836,14 +3860,15 @@ int power_chip(int file_des) {
return printSocketReadError();
FILE_LOG(logDEBUG1, ("Powering chip to %d\n", arg));
#if (!defined(JUNGFRAUD)) && (!defined(MOENCHD)) && (!defined(MYTHEN3D))
#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// set & get
if ((arg == -1) || (Server_VerifyLock() == OK)) {
#ifdef MYTHEN3D
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
// check only when powering on
if (arg != -1 && arg != 0) {
if (checkModuleFlag) {
int type_ret = checkDetectorType();
if (type_ret == -1) {
ret = FAIL;
@ -3858,6 +3883,9 @@ int power_chip(int file_des) {
sprintf(mess, "Could not power on chip. Wrong module attached!\n");
FILE_LOG(logERROR,(mess));
}
} else {
FILE_LOG(logINFOBLUE, ("In No-Module mode: Ignoring module type. Continuing.\n"));
}
}
#endif
if (ret == OK) {
@ -4292,13 +4320,22 @@ int copy_detector_server(int file_des) {
int reboot_controller(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
#ifdef EIGERD
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
if (getHardwareVersionNumber() == 0) {
ret = FAIL;
strcpy(mess, "Old board version, reboot by yourself please!\n");
FILE_LOG(logINFORED, (mess));
Server_SendResult(file_des, INT32, NO_UPDATE, NULL, 0);
return GOODBYE;
}
ret = REBOOT;
#elif EIGERD
functionNotImplemented();
return ret;
#else
FILE_LOG(logINFORED, ("Rebooting controller\n"));
return REBOOT;
ret = REBOOT;
#endif
Server_SendResult(file_des, INT32, NO_UPDATE, NULL, 0);
return ret;
}
@ -6446,7 +6483,7 @@ int get_veto_photon(int file_des) {
}
int set_veto_refernce(int file_des) {
int set_veto_reference(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int args[2] = {-1, -1};
@ -6486,24 +6523,37 @@ int set_veto_refernce(int file_des) {
int set_burst_mode(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = -1;
enum burstMode arg = BURST_OFF;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
FILE_LOG(logINFO, ("Setting burst mode: %d\n", arg));
FILE_LOG(logDEBUG1, ("Setting burst mode: %d\n", arg));
#ifndef GOTTHARD2D
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
arg = arg == 0 ? 0 : 1;
ret = setBurstMode(arg);
if (ret == FAIL) {
sprintf(mess, "Could not set burst mode to %d\n", arg);
switch (arg) {
case BURST_OFF:
case BURST_INTERNAL:
case BURST_EXTERNAL:
break;
default:
modeNotImplemented("Burst mode", (int)arg);
break;
}
if (ret == OK) {
setBurstMode(arg);
enum burstMode retval = getBurstMode();
FILE_LOG(logDEBUG, ("burst mode retval: %d\n", retval));
if (retval != arg) {
ret = FAIL;
sprintf(mess, "Could not set burst type. Set %d, got %d\n", arg, retval);
FILE_LOG(logERROR, (mess));
}
}
}
#endif
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
}
@ -6512,7 +6562,7 @@ int set_burst_mode(int file_des) {
int get_burst_mode(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
enum burstMode retval = BURST_OFF;
FILE_LOG(logDEBUG1, ("Getting burst mode\n"));
@ -6521,7 +6571,7 @@ int get_burst_mode(int file_des) {
#else
// get only
retval = getBurstMode();
FILE_LOG(logDEBUG1, ("Get burst mode:%d\n", retval));
FILE_LOG(logDEBUG1, ("Get burst mode retval:%d\n", retval));
#endif
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
}

View File

@ -1,5 +1,5 @@
set(SOURCES
src/multiSlsDetector.cpp
src/DetectorImpl.cpp
src/slsDetectorUsers.cpp
src/slsDetector.cpp
src/Detector.cpp
@ -33,6 +33,8 @@ target_link_libraries(slsDetectorShared PUBLIC
slsProjectWarnings
slsSupportLib
${ZeroMQ_LIBRARIES}
pthread
rt
)
set(PUBLICHEADERS

View File

@ -5,7 +5,7 @@
#include <memory>
#include <vector>
class multiSlsDetector;
class DetectorImpl;
class detectorData;
namespace sls {
@ -23,7 +23,7 @@ void freeSharedMemory(int multiId, int detPos = -1);
* \class Detector
*/
class Detector {
std::unique_ptr<multiSlsDetector> pimpl;
std::unique_ptr<DetectorImpl> pimpl;
public:
/**
@ -95,10 +95,13 @@ class Detector {
*/
void setDetectorSize(const defs::xy value);
/** [Jungfrau][Gotthard] */
/** [Jungfrau][Gotthard][Gotthard2] */
Result<defs::detectorSettings> getSettings(Positions pos = {}) const;
/** [Jungfrau][Gotthard] */
/** [Jungfrau] Options:DYNAMICGAIN, DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2
* [Gotthard] Options: DYNAMICGAIN, HIGHGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN
* [Gotthard2] Options: DYNAMICGAIN, FIXGAIN1, FIXGAIN2
*/
void setSettings(defs::detectorSettings value, Positions pos = {});
/**************************************************
@ -152,23 +155,37 @@ class Detector {
void setPeriod(ns t, Positions pos = {});
/** [Gotthard][Jungfrau][CTB][Mythen3] */
/** [Gotthard][Jungfrau][CTB][Mythen3]
* [Gotthard2] only in continuous mode */
Result<ns> getDelayAfterTrigger(Positions pos = {}) const;
/** [Gotthard][Jungfrau][CTB][Mythen3] */
/** [Gotthard][Jungfrau][CTB][Mythen3]
* [Gotthard2] only in continuous mode */
void setDelayAfterTrigger(ns value, Positions pos = {});
/** [Gotthard][Jungfrau][CTB][Mythen3][Gotthard2] */
/** [Gotthard][Jungfrau][CTB][Mythen3]
* [Gotthard2] only in continuous mode */
Result<int64_t> getNumberOfFramesLeft(Positions pos = {}) const;
/** [Gotthard][Jungfrau][CTB][Mythen3][Gotthard2] */
/** [Gotthard][Jungfrau][CTB][Mythen3]
* [Gotthard2] only in continuous mode */
Result<int64_t> getNumberOfTriggersLeft(Positions pos = {}) const;
/** [Gotthard][Jungfrau][CTB] */
/** [Gotthard][Jungfrau][CTB][Mythen3]
* [Gotthard2] only in continuous mode */
Result<ns> getPeriodLeft(Positions pos = {}) const;
/** [Gotthard][Jungfrau][CTB][Mythen3]
* [Gotthard2] only in continuous mode */
Result<ns> getDelayAfterTriggerLeft(Positions pos = {}) const;
/** [Gotthard][Jungfrau][CTB] */
Result<ns> getPeriodLeft(Positions pos = {}) const;
Result<defs::timingMode> getTimingMode(Positions pos = {}) const;
/**
* [Gotthard][Jungfrau][CTB] Options: AUTO_TIMING, TRIGGER_EXPOSURE
* [Eiger] Options: AUTO_TIMING, TRIGGER_EXPOSURE, GATED, BURST_TRIGGER
*/
void setTimingMode(defs::timingMode value, Positions pos = {});
/** [Eiger][Jungfrau] */
Result<defs::speedLevel> getSpeed(Positions pos = {}) const;
@ -192,39 +209,45 @@ class Detector {
/** [Gotthard][Jungfrau][CTB] */
void setADCPhaseInDegrees(int value, Positions pos = {});
/** [Gotthard2] Hz */
/** [Mythen3][Gotthard2] Hz */
Result<int> getClockFrequency(int clkIndex, Positions pos = {});
/** [not implemented] Hz */
void setClockFrequency(int clkIndex, int value, Positions pos = {});
/** [Gotthard2] */
/** [Mythen3][Gotthard2] */
Result<int> getClockPhase(int clkIndex, Positions pos = {});
/** [Gotthard2] */
/** [Mythen3][Gotthard2] */
void setClockPhase(int clkIndex, int value, Positions pos = {});
/** [Gotthard2] */
/** [Mythen3][Gotthard2] */
Result<int> getMaxClockPhaseShift(int clkIndex, Positions pos = {});
/** [Gotthard2] */
/** [Mythen3][Gotthard2] */
Result<int> getClockPhaseinDegrees(int clkIndex, Positions pos = {});
/** [Gotthard2] */
/** [Mythen3][Gotthard2] */
void setClockPhaseinDegrees(int clkIndex, int value, Positions pos = {});
/** [Gotthard2] */
/** [Mythen3][Gotthard2] */
Result<int> getClockDivider(int clkIndex, Positions pos = {});
/** [Gotthard2] */
/** [Mythen3][Gotthard2] */
void setClockDivider(int clkIndex, int value, Positions pos = {});
Result<int> getHighVoltage(Positions pos = {}) const;
/** [Jungfrau][Mythen3][Gotthard2] */
Result<bool> getPowerChip(Positions pos = {}) const;
/** [Jungfrau][Mythen3][Gotthard2] */
void setPowerChip(bool on, Positions pos = {});
/**
* [Gotthard Options: 0, 90, 110, 120, 150, 180, 200]
* [Jungfrau, CTB Options: 0, 60 - 200]
* [Eiger Options: 0 - 200]
* [Gotthard] Options: 0, 90, 110, 120, 150, 180, 200
* [Jungfrau], CTB Options: 0, 60 - 200
* [Eiger][Mythen3][Gotthard2] Options: 0 - 200
*/
void setHighVoltage(int value, Positions pos = {});
@ -249,14 +272,6 @@ class Detector {
/* [Gotthard2] */
void setOnChipDAC(defs::dacIndex index, int chipIndex, int value, Positions pos = {});
Result<defs::timingMode> getTimingMode(Positions pos = {}) const;
/**
* [Gotthard, Jungfrau, CTB Options: AUTO_TIMING, TRIGGER_EXPOSURE]
* [Eiger Options: AUTO_TIMING, TRIGGER_EXPOSURE, GATED, BURST_TRIGGER]
*/
void setTimingMode(defs::timingMode value, Positions pos = {});
/**************************************************
* *
* Acquisition *
@ -807,12 +822,6 @@ class Detector {
/** [Jungfrau] */
void resetTemperatureEvent(Positions pos = {});
/** [Jungfrau] */
Result<bool> getPowerChip(Positions pos = {}) const;
/** [Jungfrau] */
void setPowerChip(bool on, Positions pos = {});
/** [Jungfrau] */
Result<bool> getAutoCompDisable(Positions pos = {}) const;
@ -906,11 +915,11 @@ class Detector {
/** [Gotthard2] */
void setVetoReference(const int gainIndex, const int value, Positions pos = {});
/** [Gotthard2] burst mode or continuous mode */
void setBurstMode(bool enable, Positions pos = {});
/** [Gotthard2] */
Result<bool> getBurstMode(Positions pos = {});
Result<defs::burstMode> getBurstMode(Positions pos = {});
/** [Gotthard2] BURST_OFF, BURST_INTERNAL (default), BURST_EXTERNAL */
void setBurstMode(defs::burstMode value, Positions pos = {});
/**************************************************
* *
@ -1100,52 +1109,54 @@ class Detector {
/** [CTB] */
void setPatternClockControl(uint64_t word, Positions pos = {});
/** [CTB] same as executing */
/** [CTB] same as executing
* [Mythen3] */
Result<uint64_t> getPatternWord(int addr, Positions pos = {});
/** [CTB] Caution: If word is -1 reads the addr (same as
* executing the pattern) */
* executing the pattern)
* [Mythen3] */
void setPatternWord(int addr, uint64_t word, Positions pos = {});
/**[CTB] Options: level: -1 (complete pattern) and 0-2 levels
/**[CTB][Mythen3] Options: level: -1 (complete pattern) and 0-2 levels
* @returns array of start address and stop address
*/
Result<std::array<int, 2>> getPatternLoopAddresses(int level,
Positions pos = {}) const;
/** [CTB] Options: level: -1 (complete pattern) and 0-2 levels */
/** [CTB][Mythen3] Options: level: -1 (complete pattern) and 0-2 levels */
void setPatternLoopAddresses(int level, int start, int stop, Positions pos = {});
/**[CTB] Options: level: -1 (complete pattern) and 0-2 levels
/**[CTB][Mythen3] Options: level: -1 (complete pattern) and 0-2 levels
* @returns number of loops
*/
Result<int> getPatternLoopCycles(int level, Positions pos = {}) const;
/** [CTB] n: 0-2, level: -1 (complete pattern) and 0-2 levels */
/** [CTB][Mythen3] n: 0-2, level: -1 (complete pattern) and 0-2 levels */
void setPatternLoopCycles(int level, int n, Positions pos = {});
/* [CTB] */
/* [CTB][Mythen3] */
Result<int> getPatternWaitAddr(int level, Positions pos = {}) const;
/** [CTB] Options: level 0-2 */
/** [CTB][Mythen3] Options: level 0-2 */
void setPatternWaitAddr(int level, int addr, Positions pos = {});
/** [CTB] */
/** [CTB][Mythen3] */
Result<uint64_t> getPatternWaitTime(int level, Positions pos = {}) const;
/** [CTB] Options: level 0-2 */
/** [CTB][Mythen3] Options: level 0-2 */
void setPatternWaitTime(int level, uint64_t t, Positions pos = {});
/** [CTB] */
/** [CTB][Mythen3] */
Result<uint64_t> getPatternMask(Positions pos = {});
/** [CTB] Sets the mask applied to every pattern to the selected bit mask */
/** [CTB][Mythen3] Sets the mask applied to every pattern to the selected bit mask */
void setPatternMask(uint64_t mask, Positions pos = {});
/** [CTB] */
/** [CTB][Mythen3] */
Result<uint64_t> getPatternBitMask(Positions pos = {}) const;
/** [CTB] Sets the bitmask that the mask will be applied to for every
/** [CTB][Mythen3] Sets the bitmask that the mask will be applied to for every
* pattern
*/
void setPatternBitMask(uint64_t mask, Positions pos = {});
@ -1205,7 +1216,9 @@ class Detector {
* *
* ************************************************/
/** [Jungfrau][CTB] */
/** [Jungfrau][CTB] fname is a pof file
* [Mythen3][Gotthard2] fname is an rbf file
*/
void programFPGA(const std::string &fname, Positions pos = {});
/** [Jungfrau][CTB] */
@ -1218,7 +1231,7 @@ class Detector {
void copyDetectorServer(const std::string &fname,
const std::string &hostname, Positions pos = {});
/** [Jungfrau][Gotthard][CTB] */
/** [Jungfrau][Gotthard][CTB][Mythen3][Gotthard2] */
void rebootController(Positions pos = {});
/**
@ -1243,15 +1256,21 @@ class Detector {
void clearBit(uint32_t addr, int bitnr, Positions pos = {});
/** [Gotthard][Jungfrau][CTB] */
/** [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB] */
void executeFirmwareTest(Positions pos = {});
/** [Gotthard][Jungfrau][CTB] */
/** [Gotthard][Jungfrau][Mythen3][Gotthard2][CTB] */
void executeBusTest(Positions pos = {});
/** [Gotthard][Jungfrau][CTB] not possible to read back*/
void writeAdcRegister(uint32_t addr, uint32_t value, Positions pos = {});
bool getInitialChecks() const;
/** initial compaibility and other server start up checks
* default enabled */
void setInitialChecks(const bool value);
/**************************************************
* *
* Insignificant *
@ -1280,13 +1299,16 @@ class Detector {
/** Execute a command on the detector server console */
void executeCommand(const std::string &value, Positions pos = {});
/** [Jungfrau][CTB] */
/** [Jungfrau][Mythen3][CTB]
* [Gotthard2] only in continuous mode */
Result<int64_t> getNumberOfFramesFromStart(Positions pos = {}) const;
/** [Jungfrau][CTB] Get time from detector start */
/** [Jungfrau][Mythen3][CTB] Get time from detector start
* [Gotthard2] only in continuous mode */
Result<ns> getActualTime(Positions pos = {}) const;
/** [Jungfrau][CTB] Get timestamp at a frame start */
/** [Jungfrau][Mythen3][CTB] Get timestamp at a frame start
* [Gotthard2] only in continuous mode */
Result<ns> getMeasurementTime(Positions pos = {}) const;
std::string getUserDetails() const;

View File

@ -45,9 +45,7 @@ void CmdParser::Parse(const std::string &s) {
auto old_size = arguments_.size();
arguments_.erase(std::remove_if(begin(arguments_), end(arguments_),
[](const std::string &item) {
if (item == "-h" || item == "--help")
return true;
return false;
return (item == "-h" || item == "--help");
}),
end(arguments_));
if (old_size - arguments_.size() > 0)

View File

@ -581,6 +581,7 @@ std::string CmdProxy::ClockDivider(int action) {
return os.str();
}
/** temperature */
/* dacs */
std::string CmdProxy::Dac(int action) {
std::ostringstream os;
@ -696,7 +697,7 @@ std::vector<std::string> CmdProxy::DacCommands() {
case defs::GOTTHARD2:
return std::vector<std::string>{
"vref_h_adc", "vb_comp_fe", "vb_comp_adc", "vcom_cds",
"vref_restore", "vb_opa_1st", "vref_comp_fe", "vcom_adc1",
"vref_rstore", "vb_opa_1st", "vref_comp_fe", "vcom_adc1",
"vref_prech", "vref_l_adc", "vref_cds", "vb_cs",
"vb_opa_fd", "vcom_adc2"};
break;
@ -757,11 +758,8 @@ std::string CmdProxy::Threshold(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[eV] [(optinal settings) standard, fast, highgain, dynamicgain, "
"lowgain, mediumgain, veryhighgain, dynamichg0, fixgain1, "
"fixgain2, forceswitchg1, forceswitchg2]\n\t[Eiger] Threshold in "
"eV"
<< '\n';
os << "[eV] [(optinal settings) standard, lowgain, veryhighgain, verylowgain]"
"\n\t[Eiger] Threshold in eV" << '\n';
} else if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
@ -792,10 +790,8 @@ std::string CmdProxy::ThresholdNoTb(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[eV] [(optional settings) standard, fast, highgain, "
"dynamicgain, lowgain, mediumgain, veryhighgain, dynamichg0, "
"fixgain1, fixgain2, forceswitchg1, forceswitchg2]\n\t[Eiger] "
"Threshold in eV set without setting trimbits"
os << "[eV] [(optional settings) standard, lowgain, veryhighgain, verylowgain]"
"\n\t[Eiger] Threshold in eV set without setting trimbits"
<< '\n';
} else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("cannot get");
@ -1229,6 +1225,51 @@ std::string CmdProxy::VetoReference(int action) {
return os.str();
}
std::string CmdProxy::BurstMode(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[off or 0, internal or 1, external or 2]\n\t[Gotthard2] Default is burst internal type"
<< '\n';
} else {
if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getBurstMode({det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
defs::burstMode t;
try {
int ival = std::stoi(args[0]);
switch (ival) {
case 0:
t = defs::BURST_OFF;
break;
case 1:
t = defs::BURST_INTERNAL;
break;
case 2:
t = defs::BURST_EXTERNAL;
break;
default:
throw sls::RuntimeError("Unknown burst mode " + args[0]);
}
} catch (...) {
t = sls::StringTo<defs::burstMode>(args[0]);
}
det->setBurstMode(t, {det_id});
os << sls::ToString(t) << '\n'; // no args to convert 0,1,2 as well
} else {
throw sls::RuntimeError("Unknown action");
}
}
return os.str();
}
/* Mythen3 Specific */
std::string CmdProxy::Counters(int action) {
@ -1247,7 +1288,7 @@ std::string CmdProxy::Counters(int action) {
std::vector <int> result;
for (size_t i = 0; i < 32; ++i) {
if (mask & (1 << i)) {
result.push_back((int)i);
result.push_back(static_cast<int>(i));
}
}
os << sls::ToString(result) << '\n';
@ -1454,7 +1495,7 @@ std::string CmdProxy::Pattern(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[fname]\n\t[Ctb] Loads binary pattern file with only pattern "
os << "[fname]\n\t[Mythen3][Ctb] Loads binary pattern file with only pattern "
"words"
<< '\n';
} else if (action == defs::GET_ACTION) {
@ -1475,7 +1516,7 @@ std::string CmdProxy::PatternWord(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[step or address] [64 bit mask]\n\t[Ctb] 64 bit pattern at "
os << "[step or address] [64 bit mask]\n\t[Ctb][Mythen3] 64 bit pattern at "
"address of pattern memory."
<< '\n';
} else if (action == defs::GET_ACTION) {
@ -1501,17 +1542,17 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patlimits") {
os << "[start addr] [stop addr] \n\t[Ctb] Limits of complete "
os << "[start addr] [stop addr] \n\t[Ctb][Mythen3] Limits of complete "
"pattern."
<< '\n';
} else if (cmd == "patloop0") {
os << "[start addr] [stop addr] \n\t[Ctb] Limits of loop 0."
os << "[start addr] [stop addr] \n\t[Ctb][Mythen3] Limits of loop 0."
<< '\n';
} else if (cmd == "patloop1") {
os << "[start addr] [stop addr] \n\t[Ctb] Limits of loop 1."
os << "[start addr] [stop addr] \n\t[Ctb][Mythen3] Limits of loop 1."
<< '\n';
} else if (cmd == "patloop2") {
os << "[start addr] [stop addr] \n\t[Ctb] Limits of loop 2."
os << "[start addr] [stop addr] \n\t[Ctb][Mythen3] Limits of loop 2."
<< '\n';
} else {
throw sls::RuntimeError(
@ -1556,11 +1597,11 @@ std::string CmdProxy::PatternLoopCycles(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patnloop0") {
os << "[n_cycles] \n\t[Ctb] Number of cycles of loop 0." << '\n';
os << "[n_cycles] \n\t[Ctb][Mythen3] Number of cycles of loop 0." << '\n';
} else if (cmd == "patnloop1") {
os << "[n_cycles] \n\t[Ctb] Number of cycles of loop 1." << '\n';
os << "[n_cycles] \n\t[Ctb][Mythen3] Number of cycles of loop 1." << '\n';
} else if (cmd == "patnloop2") {
os << "[n_cycles] \n\t[Ctb] Number of cycles of loop 2." << '\n';
os << "[n_cycles] \n\t[Ctb][Mythen3] Number of cycles of loop 2." << '\n';
} else {
throw sls::RuntimeError(
"Unknown command, use list to list all commands");
@ -1601,11 +1642,11 @@ std::string CmdProxy::PatternWaitAddress(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patwait0") {
os << "[addr] \n\t[Ctb] Wait 0 address." << '\n';
os << "[addr] \n\t[Ctb][Mythen3] Wait 0 address." << '\n';
} else if (cmd == "patwait1") {
os << "[addr] \n\t[Ctb] Wait 1 address." << '\n';
os << "[addr] \n\t[Ctb][Mythen3] Wait 1 address." << '\n';
} else if (cmd == "patwait2") {
os << "[addr] \n\t[Ctb] Wait 2 address." << '\n';
os << "[addr] \n\t[Ctb][Mythen3] Wait 2 address." << '\n';
} else {
throw sls::RuntimeError(
"Unknown command, use list to list all commands");
@ -1646,11 +1687,11 @@ std::string CmdProxy::PatternWaitTime(int action) {
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patwaittime0") {
os << "[n_clk] \n\t[Ctb] Wait 0 time in clock cycles." << '\n';
os << "[n_clk] \n\t[Ctb][Mythen3] Wait 0 time in clock cycles." << '\n';
} else if (cmd == "patwaittime1") {
os << "[n_clk] \n\t[Ctb] Wait 1 time in clock cycles." << '\n';
os << "[n_clk] \n\t[Ctb][Mythen3] Wait 1 time in clock cycles." << '\n';
} else if (cmd == "patwaittime2") {
os << "[n_clk] \n\t[Ctb] Wait 2 time in clock cycles." << '\n';
os << "[n_clk] \n\t[Ctb][Mythen3] Wait 2 time in clock cycles." << '\n';
} else {
throw sls::RuntimeError(
"Unknown command, use list to list all commands");
@ -1766,7 +1807,8 @@ std::string CmdProxy::ProgramFpga(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[fname.pof]\n\t[Jungfrau][Ctb] Programs FPGA from pof file."
os << "[fname.pof | fname.rbf]\n\t[Jungfrau][Ctb] Programs FPGA from pof file."
<< "\n\t[Mythen3][Gotthard2] Programs FPGA from rbf file."
<< '\n';
} else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get");
@ -1774,9 +1816,6 @@ std::string CmdProxy::ProgramFpga(int action) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
if (args[0].find(".pof") == std::string::npos) {
throw sls::RuntimeError("Programming file must be a pof file.");
}
det->programFPGA(args[0], {det_id});
os << "successful\n";
} else {
@ -1939,6 +1978,39 @@ std::string CmdProxy::BitOperations(int action) {
return os.str();
}
std::string CmdProxy::InitialChecks(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[0, 1]\n\tEnable or disable intial compatibility and other checks at detector start up. It is enabled by default. Must come before 'hostname' command to take effect. Can be used to reprogram fpga when current firmware is incompatible."
<< '\n';
} else if (action == defs::GET_ACTION) {
if (det_id != -1) {
throw sls::RuntimeError(
"Cannot enable/disable initial checks at module level");
}
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getInitialChecks();
os << t << '\n';
} else if (action == defs::PUT_ACTION) {
if (det_id != -1) {
throw sls::RuntimeError(
"Cannot get initial checks enable at module level");
}
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
det->setInitialChecks(std::stoi(args[0]));
os << args.front() << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
/* Insignificant */
std::string CmdProxy::ExecuteCommand(int action) {

View File

@ -478,6 +478,7 @@ class CmdProxy {
{"cyclesl", "triggersl"},
{"clkdivider", "speed"},
/** temperature */
/** dacs */
{"vcall", "vcal"},
@ -578,6 +579,7 @@ class CmdProxy {
{"triggersl", &CmdProxy::triggersl},
{"delayl", &CmdProxy::delayl},
{"periodl", &CmdProxy::periodl},
{"timing", &CmdProxy::timing},
{"speed", &CmdProxy::Speed},
{"adcphase", &CmdProxy::Adcphase},
{"maxadcphaseshift", &CmdProxy::maxadcphaseshift},
@ -586,6 +588,9 @@ class CmdProxy {
{"maxclkphaseshift", &CmdProxy::MaxClockPhaseShift},
{"clkdiv", &CmdProxy::ClockDivider},
{"vhighvoltage", &CmdProxy::vhighvoltage},
{"powerchip", &CmdProxy::powerchip},
/** temperature */
{"temp_adc", &CmdProxy::temp_adc},
{"temp_fpga", &CmdProxy::temp_fpga},
{"temp_fpgaext", &CmdProxy::temp_fpgaext},
@ -595,7 +600,6 @@ class CmdProxy {
{"temp_sodr", &CmdProxy::temp_sodr},
{"temp_fpgafl", &CmdProxy::temp_fpgafl},
{"temp_fpgafr", &CmdProxy::temp_fpgafr},
{"timing", &CmdProxy::timing},
/* dacs */
{"vthreshold", &CmdProxy::vthreshold},
@ -644,7 +648,7 @@ class CmdProxy {
{"vb_comp_fe", &CmdProxy::vb_comp_fe},
{"vb_comp_adc", &CmdProxy::vb_comp_adc},
{"vcom_cds", &CmdProxy::vcom_cds},
{"vref_restore", &CmdProxy::vref_restore},
{"vref_rstore", &CmdProxy::vref_rstore},
{"vb_opa_1st", &CmdProxy::vb_opa_1st},
{"vref_comp_fe", &CmdProxy::vref_comp_fe},
{"vcom_adc1", &CmdProxy::vcom_adc1},
@ -767,7 +771,6 @@ class CmdProxy {
{"temp_threshold", &CmdProxy::temp_threshold},
{"temp_control", &CmdProxy::temp_control},
{"temp_event", &CmdProxy::TemperatureEvent},
{"powerchip", &CmdProxy::powerchip},
{"auto_comp_disable", &CmdProxy::auto_comp_disable},
{"storagecells", &CmdProxy::storagecells},
{"storagecell_start", &CmdProxy::storagecell_start},
@ -784,7 +787,7 @@ class CmdProxy {
{"inj_ch", &CmdProxy::InjectChannel},
{"vetophoton", &CmdProxy::VetoPhoton},
{"vetoref", &CmdProxy::VetoReference},
{"burstmode", &CmdProxy::burstmode},
{"burstmode", &CmdProxy::BurstMode},
/* Mythen3 Specific */
{"counters", &CmdProxy::Counters},
@ -873,6 +876,7 @@ class CmdProxy {
{"getbit", &CmdProxy::BitOperations},
{"firmwaretest", &CmdProxy::firmwaretest},
{"bustest", &CmdProxy::bustest},
{"initialchecks", &CmdProxy::InitialChecks},
/* Insignificant */
{"port", &CmdProxy::port},
@ -911,6 +915,7 @@ class CmdProxy {
std::string ClockPhase(int action);
std::string MaxClockPhaseShift(int action);
std::string ClockDivider(int action);
/** temperature */
/* dacs */
std::string Dac(int action);
std::string DacList(int action);
@ -943,6 +948,7 @@ class CmdProxy {
std::string InjectChannel(int action);
std::string VetoPhoton(int action);
std::string VetoReference(int action);
std::string BurstMode(int action);
/* Mythen3 Specific */
std::string Counters(int action);
/* CTB Specific */
@ -968,6 +974,7 @@ class CmdProxy {
std::string Register(int action);
std::string AdcRegister(int action);
std::string BitOperations(int action);
std::string InitialChecks(int action);
/* Insignificant */
std::string ExecuteCommand(int action);
std::string UserDetails(int action);
@ -993,44 +1000,71 @@ class CmdProxy {
"\n\tSerial number or MAC of detector (hex).");
INTEGER_COMMAND(settings, getSettings, setSettings, sls::StringTo<slsDetectorDefs::detectorSettings>,
"[standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, dynamichg0, fixgain1, fixgain2, forceswitchg1, forceswitchg2]\n\t[Jungfrau][Gotthard] Detector Settings.\n\t[Eiger] Use threshold or thresholdnotb.");
"[standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, dynamichg0, fixgain1, fixgain2, forceswitchg1, forceswitchg2, verylowgain]"
"\n\t[Jungfrau] - Detector Settings [dynamicgain | dynamichg0 | fixgain1 | fixgain2 | forceswitchg1 | forceswitchg2]"
"\n\t[Gotthard] - Detector Settings [dynamicgain | highgain | lowgain | mediumgain | veryhighgain]"
"\n\t[Gotthard2] - Detector Settings [dynamicgain | fixgain1 | fixgain2]"
"\n\t[Eiger] Use threshold or thresholdnotb.");
/* acquisition parameters */
INTEGER_COMMAND_NOID(frames, getNumberOfFrames, setNumberOfFrames,
std::stol,
"[n_frames]\n\tNumber of frames per aquire. In trigger mode, number of frames per trigger.");
"[n_frames]\n\tNumber of frames per aquire. In trigger mode, number of frames per trigger."
"\n\t[Gotthard2] Burst mode has a maximum of 2720 frames. Frames number for both modes are uploaded to detector just before acquisition starts");
INTEGER_COMMAND_NOID(triggers, getNumberOfTriggers, setNumberOfTriggers,
std::stol,
"[n_triggers]\n\tNumber of triggers per aquire. Use timing command to set timing mode.");
TIME_COMMAND(exptime, getExptime, setExptime,
"[duration] [(optional unit) ns|us|ms|s]\n\tExposure time");
"[duration] [(optional unit) ns|us|ms|s]\n\tExposure time"
"\n\t[Gotthard2] Uploaded to detector just before acquisition starts");
TIME_COMMAND(period, getPeriod, setPeriod,
"[duration] [(optional unit) ns|us|ms|s]\n\tPeriod between frames");
"[duration] [(optional unit) ns|us|ms|s]\n\tPeriod between frames"
"\n\t[Gotthard2] Uploaded to detector just before acquisition starts");
TIME_COMMAND(delay, getDelayAfterTrigger, setDelayAfterTrigger,
"[duration] [(optional unit) ns|us|ms|s]\n\t[Jungfrau][Gotthard][Ctb][Mythen3] Delay after trigger");
"[duration] [(optional unit) ns|us|ms|s]\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb] Delay after trigger"
"\n\t[Gotthard2] only in continuous mode.");
GET_COMMAND(framesl, getNumberOfFramesLeft,
"\n\t[Gotthard][Jungfrau][CTB][Mythen3][Gotthard2] Number of frames left in acquisition.");
"\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB] Number of frames left in acquisition."
"\n\t[Gotthard2] only in continuous mode.");
GET_COMMAND(triggersl, getNumberOfTriggersLeft,
"\n\t[Gotthard][Jungfrau][CTB][Mythen3][Gotthard2] Number of triggers left in acquisition.");
"\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB] Number of triggers left in acquisition."
"\n\t[Gotthard2] only in continuous mode.");
TIME_GET_COMMAND(delayl, getDelayAfterTriggerLeft,
"\n\t[Gotthard][Jungfrau][CTB] DelayLeft Delay Left in Acquisition.");
"\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB] DelayLeft Delay Left in Acquisition."
"\n\t[Gotthard2] only in continuous mode.");
TIME_GET_COMMAND(periodl, getPeriodLeft,
"\n\t[Gotthard][Jungfrau][CTB] Period left for current frame.");
"\n\t[Gotthard][Jungfrau][Mythen3][Gotthard2][CTB] Period left for current frame."
"\n\t[Gotthard2] only in continuous mode.");
INTEGER_COMMAND(timing, getTimingMode, setTimingMode, sls::StringTo<slsDetectorDefs::timingMode>,
"[auto|trigger|gating|burst_trigger]\n\tTiming Mode of detector.\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb] [auto|trigger]\n\t[Eiger] [auto|trigger|gating|burst_trigger]");
GET_COMMAND(maxadcphaseshift, getMaxADCPhaseShift,
"\n\t[Jungfrau][CTB] Absolute maximum Phase shift of ADC clock.");
INTEGER_COMMAND(vhighvoltage, getHighVoltage, setHighVoltage, std::stoi,
"[n_value]\n\tHigh voltage to the sensor in Voltage.\n\t[Gotthard] [0|90|110|120|150|180|200]\n\t[Eiger] 0-200\n\t[Jungfrau][Ctb] [0|60-200]");
"[n_value]\n\tHigh voltage to the sensor in Voltage."
"\n\t[Gotthard] [0|90|110|120|150|180|200]"
"\n\t[Eiger][Mythen3][Gotthard2] 0-200"
"\n\t[Jungfrau][Ctb] [0|60-200]");
INTEGER_COMMAND(powerchip, getPowerChip, setPowerChip, std::stoi,
"[0, 1]\n\t[Jungfrau][Mythen3][Gotthard2] Power the chip. Default 0."
"\n\t[Jungfrau] Get will return power status."
"Can be off if temperature event occured (temperature over temp_threshold with temp_control enabled."
"\n\t[Mythen3] If module not connected or wrong module, 1 will fail. By default, not powered on"
"\n\t[Gotthard2] If module not connected or wrong module, 1 will fail. By default, powered on at server start up.");
/** temperature */
GET_IND_COMMAND(temp_adc, getTemperature, slsDetectorDefs::TEMPERATURE_ADC, " °C",
"[n_value]\n\t[Jungfrau][Gotthard] ADC Temperature");
@ -1059,9 +1093,6 @@ class CmdProxy {
GET_IND_COMMAND(temp_fpgafr, getTemperature, slsDetectorDefs::TEMPERATURE_FPGA3, " °C",
"[n_value]\n\t[Eiger]Temperature of the left front end board fpga");
INTEGER_COMMAND(timing, getTimingMode, setTimingMode, sls::StringTo<slsDetectorDefs::timingMode>,
"[auto|trigger|gating|burst_trigger]\n\tTiming Mode of detector.\n\t[Jungfrau][Gotthard][Ctb] [auto|trigger]\n\t[Eiger] [auto|trigger|gating|burst_trigger]");
/* dacs */
DAC_COMMAND(vthreshold, getDAC, setDAC, defs::THRESHOLD,
@ -1202,7 +1233,7 @@ class CmdProxy {
DAC_COMMAND(vcom_cds, getDAC, setDAC, defs::VCOM_CDS,
"[dac or mv value][(optional unit) mv] \n\t[Gotthard2] Dac for common mode voltage of CDS stage.");
DAC_COMMAND(vref_restore, getDAC, setDAC, defs::VREF_RESTORE,
DAC_COMMAND(vref_rstore, getDAC, setDAC, defs::VREF_RSTORE,
"[dac or mv value][(optional unit) mv] \n\t[Gotthard2] Dac for reference charging voltage of temparory storage cell in high gain.");
DAC_COMMAND(vb_opa_1st, getDAC, setDAC, defs::VB_OPA_1ST,
@ -1373,8 +1404,7 @@ class CmdProxy {
INTEGER_COMMAND(rx_tcpport, getRxPort, setRxPort, std::stoi,
"[port]\n\tTCP port for client-receiver communication. Default is 1954. Must be different if multiple receivers on same pc. Must be first command to set a receiver parameter. Multi command will automatically increment for individual modules.");
INTEGER_COMMAND(
rx_fifodepth, getRxFifoDepth, setRxFifoDepth, std::stoi,
INTEGER_COMMAND(rx_fifodepth, getRxFifoDepth, setRxFifoDepth, std::stoi,
"[n_frames]\n\tSet the number of frames in the receiver fifo (buffer between listener and writer threads).");
INTEGER_COMMAND(rx_silent, getRxSilentMode, setRxSilentMode, std::stoi,
@ -1502,9 +1532,6 @@ class CmdProxy {
INTEGER_COMMAND(temp_control, getTemperatureControl, setTemperatureControl, std::stoi,
"[0, 1]\n\t[Jungfrau] Temperature control enable. Default is 0 (disabled). If temperature crosses threshold temperature and temperature control is enabled, power to chip will be switched off and temperature event occurs. To power on chip again, temperature has to be less than threshold temperature and temperature event has to be cleared.");
INTEGER_COMMAND(powerchip, getPowerChip, setPowerChip, std::stoi,
"[0, 1]\n\t[Jungfrau][Mythen3] Power the chip. Default 0. \n\t[Jungfrau] Get will return power status. Can be off if temperature event occured (temperature over temp_threshold with temp_control enabled.");
INTEGER_COMMAND(auto_comp_disable, getAutoCompDisable, setAutoCompDisable, std::stoi,
"[0, 1]\n\t[Jungfrau] Auto comparator disable mode. Default 0 or this mode disabled(comparator enabled throughout). 1 enables mode. 0 disables mode. This mode disables the on-chip gain switching comparator automatically after 93.75% of exposure time (only for longer than 100us).");
@ -1529,9 +1556,6 @@ class CmdProxy {
"[0, 1]\n\t[Gotthard] 1 adds channel intensity with precalculated values when taking an acquisition. Default is 0.");
/* Gotthard2 Specific */
INTEGER_COMMAND(burstmode, getBurstMode, setBurstMode, std::stoi,
"[0, 1]\n\t[Gotthard2] 1 sets to burst mode. 0 sets to continuous mode. Default is burst mode.");
/* Mythen3 Specific */
/* CTB Specific */
@ -1651,10 +1675,10 @@ class CmdProxy {
"[64 bit mask]\n\t[Ctb] 64 bit mask defining output clock enable.");
INTEGER_COMMAND_HEX(patmask, getPatternMask, setPatternMask, stoulHex,
"[64 bit mask]\n\t[Ctb] 64 bit mask applied to every pattern. Only these bits for each pattern will be masked against.");
"[64 bit mask]\n\t[Ctb][Mythen3] 64 bit mask applied to every pattern. Only these bits for each pattern will be masked against.");
INTEGER_COMMAND_HEX(patsetbit, getPatternBitMask, setPatternBitMask, stoulHex,
"[64 bit mask]\n\t[Ctb] 64 bit values applied to the selected patmask for every pattern.");
"[64 bit mask]\n\t[Ctb][Mythen3] 64 bit values applied to the selected patmask for every pattern.");
/* Moench */
@ -1674,13 +1698,13 @@ class CmdProxy {
"\n\t[Jungfrau][Ctb] Reset FPGA.");
EXECUTE_SET_COMMAND(rebootcontroller, rebootController,
"\n\t[Jungfrau][Ctb] Reboot controler (blackfin) of detector.");
"\n\t[Jungfrau][Ctb][Gotthard][Mythen3][Gotthard2] Reboot controler (blackfin) of detector.");
EXECUTE_SET_COMMAND(firmwaretest, executeFirmwareTest,
"\n\t[Jungfrau][Ctb][Gotthard] Firmware test, ie. reads a read fixed pattern from a register.");
"\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb] Firmware test, ie. reads a read fixed pattern from a register.");
EXECUTE_SET_COMMAND(bustest, executeBusTest,
"\n\t[Jungfrau][Ctb][Gotthard] Bus test, ie. keeps writing and reading back different values in R/W register.");
"\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb] Bus test, ie. keeps writing and reading back different values in R/W register.");
/* Insignificant */
@ -1698,13 +1722,16 @@ class CmdProxy {
"\n\tClient IP Address that last communicated with the detector.");
GET_COMMAND(nframes, getNumberOfFramesFromStart,
"\n\t[Jungfrau][CTB] Number of frames from start run control.");
"\n\t[Jungfrau][Mythen3][Gotthard2][Moench][CTB] Number of frames from start run control."
"\n\t[Gotthard2] only in continuous mode.");
TIME_GET_COMMAND(now, getActualTime,
"[(optional unit) ns|us|ms|s]\n\t[Jungfrau][CTB] Time from detector start up.");
"[(optional unit) ns|us|ms|s]\n\t[Jungfrau][Mythen3][Gotthard2][Moench][CTB] Time from detector start up."
"\n\t[Gotthard2] only in continuous mode.");
TIME_GET_COMMAND(timestamp, getMeasurementTime,
"[(optional unit) ns|us|ms|s]\n\t[Jungfrau][CTB] Timestamp at a frame start.");
"[(optional unit) ns|us|ms|s]\n\t[Jungfrau][Mythen3][Gotthard2][Moench][CTB] Timestamp at a frame start."
"\n\t[Gotthard2] only in continuous mode.");
GET_COMMAND(rx_frameindex, getRxCurrentFrameIndex,
"\n\tCurrent frame index received in receiver.");

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