Compare commits

..

5 Commits

Author SHA1 Message Date
98f0b967e3 suppressed warning in qwt + added reason 2022-11-23 09:13:12 +01:00
a36670df42 added comments 2022-11-21 16:47:06 +01:00
670ec18c3b cleanup 2022-11-21 16:26:37 +01:00
0ae15e5aa2 static linking of qwt 2022-11-21 16:12:04 +01:00
b08bf08ea9 using external qwt 2022-11-21 11:41:12 +01:00
139 changed files with 2290 additions and 5876 deletions

View File

@ -2,7 +2,7 @@
# Copyright (C) 2021 Contributors to the SLS Detector Package
cmake_minimum_required(VERSION 3.12)
project(slsDetectorPackage)
set(PROJECT_VERSION 7.0.0)
set(PROJECT_VERSION 6.1.1)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")

File diff suppressed because it is too large Load Diff

View File

@ -21,4 +21,4 @@ echo "Building using: ${NCORES} cores"
cmake --build . -- -j${NCORES}
cmake --build . --target install
CTEST_OUTPUT_ON_FAILURE=1 ctest -j 1
CTEST_OUTPUT_ON_FAILURE=1 ctest -j 2

View File

@ -1,8 +1,9 @@
python:
- 3.6
- 3.7
- 3.8
- 3.9
- 3.10
- 3.11
numpy:
- 1.17

View File

@ -17,7 +17,8 @@ requirements:
- {{ compiler('c') }}
- {{compiler('cxx')}}
- cmake
- qt 5.*
- qwt 6.*
- qt 4.8.*
- zeromq
- xorg-libx11
- xorg-libice
@ -110,10 +111,12 @@ outputs:
- {{ compiler('c') }}
- {{compiler('cxx')}}
- {{ pin_subpackage('slsdetlib', exact=True) }}
- qwt 6.*
run:
- {{ pin_subpackage('slsdetlib', exact=True) }}
- qt 5.*
- qwt 6.*
- qt 4.8.*
- expat
- name: moenchzmq

View File

@ -21,8 +21,10 @@ the shared libraries these are needed:
GUI
-----------------------
* Qt 5.9
* Qwt 6.1.5 (packaged in libs/)
The GUI is currently using Qt4 but watch out for an upgrade to 5.
* Qt 4.8
* Qwt 6.1
-----------------------
Python bindings

View File

@ -92,30 +92,19 @@ Download
Upgrade
^^^^^^^^
.. warning ::
In case you have had issues in the past with programming via software:
* 6.1.2 server has a fix for seamless fpga programming
* We recommend first updating the on-board detector server to 6.1.2 (with client 6.1.x) using command 'updatedetectorserver' or 'copydetectorserver'.
* Then use command 'programfpga' to only update firmware or use command 'update' to update firmware and server to the latest release.
.. note ::
These instructions are for upgrades from v5.0.0. For earlier versions, contact us.
Check :ref:`firmware troubleshooting <blackfin firmware troubleshooting>` if you run into issues while programming firmware.
Always ensure that the client and server software are of the same release.
Program from console
.. code-block:: bash
# These instructions are for upgrades from v5.0.0. For earlier versions, please contact us.
# Always ensure that the client and server software are of the same release.
# copies server from tftp folder of pc, links new server to jungfrauDetectorServer,
# removes old server from respawn, sets up new lnked server to respawn
# programs fpga,
@ -166,6 +155,10 @@ Upgrade
Mythen III
-----------
.. note ::
As it is still in development, the rbf files must be picked up from us.
Download
^^^^^^^^^^^^^
@ -177,11 +170,11 @@ Download
Upgrade
^^^^^^^^
Always ensure that the client and server software are of the same release.
Program from console
.. code-block:: bash
# Always ensure that the client and server software are of the same release.
# copies server from tftp folder of pc, links new server to mythen3DetectorServer,
# programs fpga,
# reboots
@ -206,11 +199,11 @@ Download
Upgrade
^^^^^^^^
Always ensure that the client and server software are of the same release.
Program from console
.. code-block:: bash
# Always ensure that the client and server software are of the same release.
# copies server from tftp folder of pc, links new server to gotthard2DetectorServer,
# programs fpga,
# reboots
@ -237,26 +230,13 @@ Download
Upgrade
^^^^^^^^
.. warning ::
In case you have had issues in the past with programming via software:
* 6.1.2 server has a fix for seamless fpga programming
* We recommend first updating the on-board detector server to 6.1.2 (with client 6.1.x) using command 'updatedetectorserver' or 'copydetectorserver'.
* Then use command 'programfpga' to only update firmware or use command 'update' to update firmware and server to the latest release.
Check :ref:`firmware troubleshooting <blackfin firmware troubleshooting>` if you run into issues while programming firmware.
Always ensure that the client and server software are of the same release.
Program from console
.. code-block:: bash
# Always ensure that the client and server software are of the same release.
# copies server from tftp folder of pc, links new server to moenchDetectorServer,
# removes old server from respawn, sets up new lnked server to respawn
# programs fpga,
@ -282,12 +262,11 @@ Upgrade
Check :ref:`firmware troubleshooting <blackfin firmware troubleshooting>` if you run into issues while programming firmware.
Always ensure that the client and server software are of the same release.
Program from console
.. code-block:: bash
# Always ensure that the client and server software are of the same release.
# copies server from tftp folder of pc, links new server to ctbDetectorServer,
# removes old server from respawn, sets up new lnked server to respawn
# programs fpga,

View File

@ -13,149 +13,54 @@
Before building from source make sure that you have the
:doc:`dependencies <../dependencies>` installed. If installing using conda, conda will
manage the dependencies. Avoid also installing packages with pip.
manage the dependencies.
.. _Installation:
Installation
===============
Install binaries using conda
-------------------------------
Conda is not only useful to manage python environments but can also
be used as a user space package manager. Dates in the tag (for eg. 2020.07.23.dev0)
are from the developer branch. Please use released tags for stability.
We have three different packages available:
* **slsdetlib** shared libraries and command line utilities
* **slsdetgui** GUI
* **slsdet** Python bindings
.. code-block:: bash
#Add channels for dependencies and our library
conda config --add channels conda-forge
conda config --add channels slsdetectorgroup
conda config --set channel_priority strict
#create and activate an environment with our library
#replace 6.1.1 with the required tag
conda create -n myenv slsdetlib=6.1.1
conda activate myenv
#ready to use
sls_detector_get exptime
etc ...
.. code-block:: bash
#List available versions
# lib and binaries
conda search slsdetlib
# python
conda search slsdet
# gui
conda search slsdetgui
Build from source
-------------------
1. Download Source Code from github
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git --branch 6.1.1
| **Pybind for Python**
| v7.0.0+:
| pybind11 packaged into 'libs/pybind'. No longer a submodule. No need for "recursive" or "submodule update".
|
| Older versions:
| pybind11 is a submodule. Must be cloned using "recursive" and updated when switching between versions using the following commands.
.. code-block:: bash
# clone using recursive to get pybind11 submodule
git clone --recursive https://github.com/slsdetectorgroup/slsDetectorPackage.git
# update submodule when switching between releases
cd slsDetectorPackage
git submodule update --init
==============================================
.. _build from source using cmake:
Build from source using CMake
---------------------------------
Note that on some systems, for example RH7, cmake v3+ is available under the cmake3 alias.
It is also required to clone with the option --recursive to get the pybind11 submodules used
in the package. (Only needed for older versions than v7.0.0)
2. Build from Source
^^^^^^^^^^^^^^^^^^^^^^^^^^
Build using CMake
^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
# outside slsDetecorPackage folder
git clone --recursive https://github.com/slsdetectorgroup/slsDetectorPackage.git
# if older than v7.0.0 and using python, update pybind11 submodules
cd slsDetectorPackage
git submodule update --init
mkdir build && cd build
# configure & generate Makefiles using cmake
# by listing all your options (alternately use ccmake described below)
# cmake3 for some systems
cmake ../slsDetectorPackage -DCMAKE_INSTALL_PREFIX=/your/install/path
# compiled to the build/bin directory
make -j12 #or whatever number of cores you are using to build
# install headers and libs in /your/install/path directory
make install
Instead of the cmake command, one can use ccmake to get a list of options to configure and generate Makefiles at ease.
The easiest way to configure options is to use the ccmake utility.
.. code-block:: bash
# ccmake3 for some systems
ccmake ..
# choose the options
# first press [c] - configure
# then press [g] - generate
#from the build directory
ccmake .
=============================== ===========================================
Example cmake options Comment
=============================== ===========================================
-DSLS_USE_PYTHON=ON Python
-DPython_FIND_VIRTUALENV=ONLY Python from only the conda environment
-DZeroMQ_HINT=/usr/lib64 Use system zmq instead
-DSLS_USE_GUI=ON GUI
=============================== ===========================================
Build using in-built cmk.sh script
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Build using cmk.sh script
-------------------------
These are mainly aimed at those not familiar with using ccmake and cmake.
.. code-block:: bash
The binaries are generated in slsDetectorPackage/build/bin directory.
Usage: ./cmk.sh [-b] [-c] [-d <HDF5 directory>] [e] [g] [-h] [i] [-j <Number of threads>]
[-k <CMake command>] [-l <Install directory>] [m] [n] [-p] [-q <Zmq hint directory>]
[r] [s] [t] [u] [z]
Usage: ./cmk.sh [-b] [-c] [-d <HDF5 directory>] [e] [g] [-h] [i] [-j <Number of threads>] [-k <CMake command>] [-l <Install directory>] [m] [n] [-p] [-q <Zmq hint directory>] [r] [s] [t] [u] [z]
-[no option]: only make
-b: Builds/Rebuilds CMake files normal mode
-c: Clean
@ -181,19 +86,48 @@ Build using in-built cmk.sh script
# get all options
./cmk.sh -?
# new build and compile in parallel:
# new build and compile in parallel:
./cmk.sh -bj5
# new build, python and compile in parallel:
./cmk.sh -bpj5
#To use the system zmq (/usr/lib64) instead
./cmk.sh -bj5 -q /usr/lib64
Install binaries using conda
--------------------------------
Conda is not only useful to manage python environments but can also
be used as a user space package manager.
We have three different packages available:
* **slsdetlib**, shared libraries and command line utilities
* **slsdetgui**, GUI
* **slsdet**, Python bindings
.. code-block:: bash
Build on old distributions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#Add channels for dependencies and our library
conda config --add channels conda-forge
conda config --add channels slsdetectorgroup
conda config --set channel_priority strict
#cerate an environment with our library, then activate
#replace 2020.07.20.dev0 with the required tag
conda create -n myenv slsdetlib=2020.07.23.dev0
conda activate myenv
#ready to use
sls_detector_get exptime
etc ...
.. code-block:: bash
#List available versions
conda search slsdet
Build from source on old distributions
-----------------------------------------
If your linux distribution doesn't come with a C++11 compiler (gcc>4.8) then
it's possible to install a newer gcc using conda and build the slsDetectorPackage
@ -204,64 +138,12 @@ using this compiler
#Create an environment with the dependencies
conda create -n myenv gxx_linux-64 cmake zmq
conda activate myenv
# outside slsDetecorPackage folder
mkdir build && cd build
cmake ../slsDetectorPackage -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
make -j12
Build slsDetectorGui (Qt5)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1. Using pre-built binary on conda
.. code-block:: bash
conda create -n myenv slsdetgui=7.0.0
conda activate myenv
2. Using system installation on RHEL7
.. code-block:: bash
yum install qt5-qtbase-devel.x86_64
yum install qt5-qtsvg-devel.x86_64
3. Using conda
.. code-block:: bash
#Add channels for dependencies and our library
conda config --add channels conda-forge
conda config --add channels slsdetectorgroup
conda config --set channel_priority strict
# create environment to compile
# on rhel7
conda create -n slsgui zeromq gxx_linux-64 gxx_linux-64 mesa-libgl-devel-cos6-x86_64 qt
# on fedora or newer systems
conda create -n slsgui zeromq qt
# when using conda compilers, would also need libgl, but no need for it on fedora unless maybe using it with ROOT
# activate environment
conda activate slsgui
# compile with cmake outside slsDetecorPackage folder
mkdir build && cd build
cmake ../slsDetectorPackage -DSLS_USE_GUI=ON
make -j12
# or compile with cmk.sh
cd slsDetectorPackage
./cmk.sh -cbgj9
Build this documentation
^^^^^^^^^^^^^^^^^^^^^^^^
-------------------------------
The documentation for the slsDetectorPackage is build using a combination
of Doxygen, Sphinx and Breathe. The easiest way to install the dependencies
@ -269,15 +151,11 @@ is to use conda
.. code-block:: bash
conda create -n myenv python sphinx_rtd_theme breathe
conda create -n myenv python sphinx sphinx_rtd_theme
Then enable the option SLS_BUILD_DOCS to create the targets
.. code-block:: bash
# using cmake or ccmake to enable DSLS_BUILD_DOCS
# outside slsDetecorPackage folder
mkdir build && cd build
cmake ../slsDetectorPackage -DSLS_BUILD_DOCS=ON
make docs # generate API docs and build Sphinx RST
make rst # rst only, saves time in case the API did not change
make rst # rst only, saves time in case the API did not change

View File

@ -10,46 +10,27 @@ open an issue in our our `github repo
Setting exposure time
------------------------------------
Setting and reading back exposure time can be done either using a Python
datetime.timedelta, DurationWrapper or by setting the time in seconds.
Setting and reading back exposure time can be done either using a Python datetime.timedelta
or by setting the time in seconds.
::
# Set exposure time to 1.2 seconds
>>> d.exptime = 1.2
>>> d.exptime = 5e-07
# Setting exposure time using timedelta (upto microseconds precision)
# Setting exposure time using timedelta
import datetime as dt
>>> d.exptime = dt.timedelta(seconds = 1.2)
>>> d.exptime = dt.timedelta(seconds = 1, microseconds = 3)
# With timedelta any arbitrary combination of units can be used
>>> t = dt.timedelta(microseconds = 100, seconds = 5.3, minutes = .3)
# using DurationWrapper to set in seconds
>>> from slsdet import DurationWrapper
>>> d.exptime = DurationWrapper(1.2)
# using DurationWrapper to set in ns
>>> t = DurationWrapper()
>>> t.set_count(500)
>>> d.exptime = t
# To set exposure time for individual detector one have to resort
# to the C++ style API.
# Sets exposure time to 1.2 seconds for module 0, 6 and 12
>>> d.setExptime(1.2, [0, 6, 12])
>>> d.setExptime(dt.timedelta(seconds = 1.2), [0, 6, 12])
# to get in seconds
>>> d.period
181.23
# to get in DurationWrapper
>>> d.getExptime()
[sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)]
------------------------------------
@ -239,7 +220,8 @@ Setting and getting times
# This sets the exposure time for all modules
d.exptime = 0.5
# exptime also accepts a python datetime.timedelta (upto microseconds resolution)
# exptime also accepts a python datetime.timedelta
# which can be used to set the time in almost any unit
t = dt.timedelta(milliseconds = 2.3)
d.exptime = t
@ -247,25 +229,16 @@ Setting and getting times
t = dt.timedelta(minutes = 3, seconds = 1.23)
d.exptime = t
# using DurationWrapper to set in seconds
>>> from slsdet import DurationWrapper
>>> d.exptime = DurationWrapper(1.2)
# using DurationWrapper to set in ns
>>> t = DurationWrapper()
>>> t.set_count(500)
>>> d.exptime = t
# exptime however always returns the time in seconds
>>> d.exptime
181.23
# To get back the exposure time for each module
# it's possible to use getExptime, this also returns
# the values as DurationWrapper
# the values as datetime.timedelta
>>> d.getExptime()
[sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)]
[datetime.timedelta(seconds=181, microseconds=230000), datetime.timedelta(seconds=181, microseconds=230000)]
# In case the values are the same it's possible to use the
# element_if_equal function to reduce the values to a single
@ -273,8 +246,7 @@ Setting and getting times
>>> t = d.getExptime()
>>> element_if_equal(t)
sls::DurationWrapper(total_seconds: 1.2 count: 1200000000)
datetime.timedelta(seconds=1)
--------------
Reading dacs

View File

@ -6,7 +6,7 @@ Getting Started
Which Python?
--------------------
We require at least Python 3.6 and strongly recommended that you don't use the system
We require at lest Python 3.6 and strongly recommended that you don't use the system
Python installation. The examples in this documentation uses `conda
<https://docs.conda.io/en/latest/miniconda.html>`_ since it provides good support
also for non Python packages but there are also other alternatives like, pyenv.
@ -14,35 +14,44 @@ also for non Python packages but there are also other alternatives like, pyenv.
Using something like conda also allows you to quickly switch beteen different Python
environments.
.. warning ::
If you use conda avoid also installing packages with pip.
---------------------
Building from Source
PYBIND11
---------------------
**v7.0.0 of slsDetectorPackage:**
If you are not installing slsdet binaries from conda, but instead building from
source, please refer to :ref:`the installation section<Installation>` for details.
#. It is packaged into libs (pybind)
#. No longer a submodule of the slsDetectorPackage
Don't forget to compile with the option SLS_USE_PYTHON=ON to enable the Python
bindings or if you use the cmk.sh script -p.
**Older than v7.0.0:**
.. note ::
#. Submodule in libs (pybind11)
#. Switching between versions will require an update of the submodule as well using:
Ensure that the sls det python lib compiled is for the expected python version.
For example, build/bin/_slsdet.cpython-39-x86_64-linux-gnu.so for Python v3.9.x
.. code-block:: bash
git submodule update --init #from the main slsDetectorPackage folder
---------------------
PYTHONPATH
---------------------
If you install slsdet binaries using conda everything is set up and you can
If you install slsdet using conda everything is set up and you can
directly start using the Python bindings. However, if you build
from source you need to tell Python where to find slsdet to use it. This
can be done by adding your build/bin directory to PYTHONPATH.
from source you need to tell Python where to find slsdet. This
is be done by adding your build/bin directory to PYTHONPATH.
.. code-block:: bash
export PYTHONPATH = /path/to/your/build/bin:$PYTHONPATH
.. note ::
Don't forget to compile with the option SLS_USE_PYTHON=ON to enable
the Python bindings or if you use the cmk.sh script -p.
--------------------------------------
Which detector class should I use?
--------------------------------------
@ -153,11 +162,9 @@ their name.
::
>>> [item for item in dir(d) if 'time' in item]
['compdisabletime', 'exptime', 'exptimel', 'frametime', 'getExptime',
'getExptimeForAllGates', 'getExptimeLeft', 'getSubExptime', 'patwaittime',
'patwaittime0', 'patwaittime1', 'patwaittime2', 'runtime', 'setExptime',
'setSubExptime', 'subdeadtime', 'subexptime']
['exptime', 'getExptime', 'getExptimeForAllGates', 'getExptimeLeft',
'getSubExptime', 'patwaittime0', 'patwaittime1', 'patwaittime2',
'setExptime', 'setSubExptime', 'subdeadtime', 'subexptime']
The above method works on any Python object but for convenience we also
included two functions to find names. View prints the names one per line
@ -169,7 +176,6 @@ while find returns a list of names.
>>> view('exptime')
exptime
exptimel
getExptime
getExptimeForAllGates
getExptimeLeft
@ -178,7 +184,6 @@ while find returns a list of names.
setSubExptime
subexptime
>>> find('exptime')
['exptime', 'getExptime', 'getExptimeForAllGates', 'getExptimeLeft',
'getSubExptime', 'setExptime', 'setSubExptime', 'subexptime']
@ -196,39 +201,19 @@ To access the documentation of a function directly from the Python prompt use he
Help on property:
Period between frames, accepts either a value in seconds or datetime.timedelta
Note
-----
:getter: always returns in seconds. To get in DurationWrapper, use getPeriod
Example
:getter: always returns in seconds. To get in datetime.delta, use getPeriod
Examples
-----------
>>> # setting directly in seconds
>>> d.period = 1.05
>>>
>>> # setting directly in seconds
>>> d.period = 5e-07
>>>
>>> # using timedelta (up to microseconds precision)
>>> from datatime import timedelta
>>> d.period = timedelta(seconds = 1, microseconds = 3)
>>>
>>> # using DurationWrapper to set in seconds
>>> from slsdet import DurationWrapper
>>> d.period = DurationWrapper(1.2)
>>>
>>> # using DurationWrapper to set in ns
>>> t = DurationWrapper()
>>> t.set_count(500)
>>> d.period = t
>>>
>>> # to get in seconds
>>> d.period = datetime.timedelta(minutes = 3, seconds = 1.23)
>>> d.period
181.23
>>>
>>> d.getExptime()
[sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)]
>>> d.getPeriod()
[datetime.timedelta(seconds=181, microseconds=230000)]
----------------------
@ -248,12 +233,11 @@ The enums can be found in slsdet.enums
import slsdet
>>> [e for e in dir(slsdet.enums) if not e.startswith('_')]
['M3_GainCaps', 'burstMode', 'clockIndex', 'cls', 'dacIndex', 'detectorSettings',
'detectorType', 'dimension', 'externalSignalFlag', 'fileFormat',
'frameDiscardPolicy', 'gainMode', 'name', 'polarity', 'portPosition',
'readoutMode', 'runStatus', 'speedLevel', 'streamingInterface', 'timingMode',
'timingSourceType', 'vetoAlgorithm']
['burstMode', 'clockIndex', 'dacIndex',
'detectorSettings', 'detectorType', 'dimension', 'externalSignalFlag',
'fileFormat', 'frameDiscardPolicy',
'readoutMode', 'runStatus', 'speedLevel', 'timingMode',
'timingSourceType']
# Even though importing using * is not recommended one could
# get all the enums like this:

View File

@ -66,15 +66,11 @@ For a Single Module
# sets destination udp ports (not needed, default is 50001)
udp_dstport 50012
# 1g data out
# source udp ips must be same subnet at destintaion udp ips
# udp_srcip 192.168.1.112
# destination udp ip picked up from rx_hostname (if auto)
# udp_dstip auto
udp_srcip 192.168.1.112
# 10g data out
udp_srcip 10.30.20.200
udp_dstip 10.30.20.6
# destination udp ip picked up from rx_hostname (if auto)
udp_dstip auto
# set file path
fpath /tmp

View File

@ -23,19 +23,15 @@ Arguments
.. code-block:: bash
Possible arguments are:
-v, --version : Software version
-p, --port <port> : TCP communication port with client.
-g, --nomodule : [Mythen3][Gotthard2]
Generic or No Module mode. Skips detector type checks.
-f, --phaseshift <value> : [Gotthard] only. Sets phase shift.
-d, --devel : Developer mode. Skips firmware checks.
-u, --update : Update mode. Skips firmware checks and initial detector setup.
-i, --ignore-config : [Eiger][Jungfrau][Gotthard][Gotthard2][Moench]
Ignore config file.
-m, --master <master> : [Eiger][Mythen3][Gotthard][Gotthard2]
Set Master to 0 or 1. Precedence over config file. Only for virtual servers except Eiger.
-t, --top <top> : [Eiger] Set Top to 0 or 1. Precedence over config file.
-s, --stopserver : Stop server. Do not use as it is created by control server
-v, --version : Software version
-p, --port <port> : TCP communication port with client.
-g, --nomodule : [Mythen3][Gotthard2] Generic or No Module mode.
Skips detector type checks.
-f, --phaseshift <value> : [Gotthard] only. Sets phase shift.
-d, --devel : Developer mode. Skips firmware checks.
-u, --update : Update mode. Skips firmware checks and initial detector setup.
-s, --stopserver : Stop server. Do not use as it is created by control server
.. _Automatic start servers:
@ -92,8 +88,6 @@ One can start the on-board detector server automatically upon powering on the bo
.. code-block:: bash
sync
# physically reboot for Gotthard II or Mythen III
reboot
# verify

View File

@ -86,160 +86,16 @@ Client Commands
sls_detector_get -h rx_framescaught
ZMQ: Json Header Format
------------------------
**Change in field names from slsDetectorPackage v6.x.x to v7.0.0**
* detSpec1 <- bunchId
* detSpec2 <- reserved
* detSpec3 <- debug
* detSpec4 <- roundRNumber
**Format**
.. code-block:: bash
{
"jsonversion": unsigned int,
"bitmode": unsigned int,
"fileIndex": unsigned long int,
"detshape": [
unsigned int,
unsigned int
],
"shape": [
unsigned int,
unsigned int
],
"size": unsigned int,
"acqIndex": unsigned long int,
"frameIndex": unsigned long int,
"progress": double,
"fname": string,
"data": unsigned int,
"completeImage": unsigned int,
"frameNumber": unsigned long long int,
"expLength": unsigned int,
"packetNumber": unsigned int,
"detSpec1": unsigned long int,
"timestamp": unsigned long int,
"modId": unsigned int,
"row": unsigned int,
"column": unsigned int,
"detSpec2": unsigned int,
"detSpec3": unsigned int,
"detSpec4": unsigned int,
"detType": unsigned int,
"version": unsigned int,
"flipRows": unsigned int,
"quad": unsigned int,
"addJsonHeader": {
string : string
}
}
+--------------+----------------------------------------------+
| Field | Description |
+--------------+----------------------------------------------+
| jsonversion | Version of the json header. |
| | Value at 4 for v6.x.x and v7.x.x |
+--------------+----------------------------------------------+
| bitmode | Bits per pixel [4|8|16|32] |
+--------------+----------------------------------------------+
| fileIndex | Current file acquisition index |
+--------------+----------------------------------------------+
| detshape | Geometry of the entire detector |
+--------------+----------------------------------------------+
| shape | Geometry of the current port streamed out |
+--------------+----------------------------------------------+
| size | Size of image of current port in bytesout |
+--------------+----------------------------------------------+
| acqIndex | Frame number from the detector (redundant) |
+--------------+----------------------------------------------+
| frameIndex | Frame number of current acquisition |
| | (Starting at 0) |
+--------------+----------------------------------------------+
| progress | Progress of current acquisition in % |
+--------------+----------------------------------------------+
| fname | Current file name |
+--------------+----------------------------------------------+
| data | 1 if there is data following |
| | 0 if dummy header |
+--------------+----------------------------------------------+
| completeImage| 1 if no missing packets for this frame |
| | in this port, else 0 |
+--------------+----------------------------------------------+
| frameNumber | Frame number |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| expLength | subframe number (32 bit eiger) |
| | or real time exposure time in 100ns (others) |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| packetNumber | Number of packets caught for that frame |
+--------------+----------------------------------------------+
| detSpec1 | See :ref:`here<Detector Specific Fields>` |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| timestamp | Timestamp with 10 MHz clock |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| modId | Module Id |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| row | Row number in detector |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| column | Column number in detector |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| detSpec2 | See :ref:`here<Detector Specific Fields>` |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| detSpec3 | See :ref:`here<Detector Specific Fields>` |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| detSpec4 | See :ref:`here<Detector Specific Fields>` |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| detType | Detector type enum |
| detSpec3 | See :ref:`Detector enum<Detector Enum>` |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| version | Detector header version. At 2 |
| | [From detector udp header] |
+--------------+----------------------------------------------+
| flipRows | 1 if rows should be flipped. |
| | Usually for Eiger bottom. |
+--------------+----------------------------------------------+
| quad | 1 if its an Eiger quad. |
+--------------+----------------------------------------------+
| addJsonHeader| Optional custom parameters that is required |
| | for processing code. |
+--------------+----------------------------------------------+
File format
--------------
Master file is in json format.
* The file name format is [fpath]/[fname]_dx_fy_[findex].raw, where x is module index and y is file index. **fname** is file name prefix and by default "run". **fpath** is '/' by default.
The file name format is [fpath]/[fname]_dx_fy_[findex].raw, where x is module index and y is file index. **fname** is file name prefix and by default "run". **fpath** is '/' by default.
* Each acquisition will have an increasing acquisition index or findex (if file write enabled). This can be retrieved by using **findex** command.
* Each acquisition can have multiple files (the file index number **y**), with **rx_framesperfile** being the maximum number of frames per file. The default varies for each detector type.
Each acquisition will have an increasing acquisition index or findex (if file write enabled). This can be retrieved by using **findex** command.
Each acquisition can have multiple files (the file index number **y**), with **rx_framesperfile** being the maximum number of frames per file. The default varies for each detector type.
Some file name examples:
* Some file name examples:
.. code-block:: bash
@ -252,21 +108,17 @@ Some file name examples:
# second acquisition, first file
path-to-file/run_d0_f0_1.raw
* Each acquisition will create a master file that can be enabled/disabled using **fmaster**. This should have parameters relevant to the acquisition.
Each acquisition will create a master file that can be enabled/disabled using **fmaster**. This should have parameters relevant to the acquisition.
SLS Receiver Header consist of SLS Detector Header + 64 bytes of bitmask, altogether 112 bytes. The packetNumber in the sls detector header part, will be updated to number of packets caught by receiver for that frame. Furthermore, the bit mask will specify which packets have been received.
* SLS Receiver Header consist of SLS Detector Header + 64 bytes of bitmask, altogether 112 bytes. The packetNumber in the sls detector header part, will be updated to number of packets caught by receiver for that frame. Furthermore, the bit mask will specify which packets have been received.
**Binary file format**
This is the default file format.
* This is the default file format.
* Each data file will consist of frames, each consisting of slsReceiver Header followed by data for 1 frame.
Each data file will consist of frames, each consisting of slsReceiver Header followed by data for 1 frame.
Master file is of ASCII format and will also include the format of the slsReceiver Header.
* Master file is of ASCII format and will also include the format of the slsReceiver Header.
**HDF5 file formats**
@ -308,7 +160,7 @@ When handling callbacks, the control should be returned as soon as possible, to
**Example**
* `main cpp file <https://github.com/slsdetectorgroup/api-examples/blob/master/e4-receiver_callbacks.cpp>`_
* `cmake file <https://github.com/slsdetectorgroup/api-examples/blob/master/CMakeLists.txt>`_.
* how to install the slsDetectorPackage with cmake is provided :ref:`here <build from source using cmake>`.
* how to install the slsDetectorPackage is provided :ref:`here <build from source using cmake>`.
* compile the example **e4-rxr** by:
.. code-block:: bash

View File

@ -8,24 +8,21 @@ open an issue at our `github repo issues
Common
------
Missing Packets
^^^^^^^^^^^^^^^
Possible causes could be the following:
1. Total Failure of Packet Delivery
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#. Receiver PC is not tuned for socket buffer size and input packet queue.
* Refer to :ref:`Increase rmem_default, rmem_max and max_backlog<Receiver PC Tuning>`
#. Data cable plugged into the wrong interface on board (Jungfrau)
* Please ensure that the data cable is plugged into the rightmost interface (default for single interface). The inner one is disabled for PCB v1.0 and must be selected via command for PCB v2.0.
#. Wiring
* Faulty wiring or connecting cable to incorrect interface.
#. Link up and speed
* Check ethtool and find if Link Deteced:Yes and Speed is acceptable (>10k).
* Check to see if the 10G link is up (blue or red LED on board, close to SFP+). If not:
* Check transeiver and fibers are compatible (all MMF 850nm or all SMF 1030nm)
* Check fiber
* Check fiber polarity (if short range, unplug the link anywhere, and look at the light/dark pattern: dark has to mate with light)
* Check to see if there is a blue LED on board to signal that the link is up. Check ethtool and find if Link Deteced:Yes and Speed is acceptable (>10k).
#. Detector is not acquiring (Not Eiger)
* Take an acquisition with many images and using the following steps instead of acquire:
.. code-block:: bash
sls_detector_put status start
@ -33,63 +30,37 @@ Common
# which means the detector is acquiring.
sls_detector_get framesl
# If you are using multiple modules, the previous command can return -1 because each module will return different values. Then, check for a single module instead: sls_detector_get 0:framesl
.. note ::
If you are using multiple modules, the previous command can return -1 because each module will return different values. Then, check for a single module instead: sls_detector_get 0:framesl
#. Data cable plugged into the wrong interface on board (Jungfrau)
* Please ensure that the data cable is plugged into the rightmost interface. The middle one is disabled for PCB v1.0 and must be selected via command for PCB v2.0.
#. Detector is not sending data (Except Eiger)
* Check the board to see if the green LED close to SFP is blinking (detector is sending data). If not, detector is not operated properly (period too short/long, no trigger in trigger mode) or misconfigured and needs reboot.
#. Detector is not sending data
* Check the board to see if the green LED is blinking next to the data cable, which means that the detector is sending data.
#. Power supply
* Check if power supply has enough current.
* For Jungfrau, refer to :ref:`Jungfrau Power Supply Troubleshooting<Jungfrau Troubleshooting Power Supply>`.
#. Firewall or security feature
* A firewall or some security feature could be blocking the reception of data.
#. Ethernet interface not configured properly
* Ensure that the interfaces used are configured properly with the right mask and ip. Eg. use ifconfig and route commands to verify.
#. Ethernet interface not configured for Jumbo frames (10Gb)
* Ensure that the interfaces (on NIC and the switch) used in receiver pc have MTU 9000 (jumbo frames) enabled.
* Ensure that the interfaces used in receiver pc have MTU 9000 (jumbo frames) enabled.
#. Detector IP (Not Eiger)
* Ensure it is valid and does not end if 0 or 255. Also ensure that the detector ip is in the same subnet as rx_udpip and the masking in the interface configuration ensures this rule.
#. Check if 'rx_frames' counter in 'ifconfig' do not increment for interface.
* If no, check switch configuration if present. Port counters of switch can also help to identify problem.
* If yes, but receiver software does not see it:
* Check no firewall (eg. firewalld) is present or add rules
* Check that selinux is disabled ( or add rules)
#. Source UDP IP in config file (Not Eiger)
* Ensure it is valid and does not end if 0 or 255. Also ensure that the source ip 'udp_srcip' is in the same subnet as destination ip 'udp_dstip' and the masking in the interface configuration ensures this rule.
* Eg. If interface IP is 102.10.10.110 and mask is 255.255.255.0, udp_srcip has to be 102.10.10.xxx (same subnet)
* Use ifconfig and route commands to verify etheret interface configuration
#. Netstat and netcat
* Try with netstat to see if its really listening to the right interface. Or netcat to see if you get packets.
#. Wireshark or Tcpdump
#. Tcpdump or wireshark
* Use one of these to confirm that you receive packets (with the right filtering ie. source and destination ports, ip).
2. Partial or Random Packet Loss (Performance)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. note ::
The following suggestions are for convenience. Please do not follow blindly, research each parameter and adapt it to your system.
#. Receiver PC is not tuned for socket buffer size and input packet queue or other parameters.
* Refer to :ref:`Receiver PC Tuning<Receiver PC Tuning>`
#. Wiring
* Faulty wiring or connecting cable to incorrect interface.
#. Check SFP modules
* Check if the SFP modules on both sides of the fiber are of same type.
#. Pinging the subnet (receiving only a few number of packets each time)
* If a switch is used between a receiver pc and detector instead of plugging the cables directly, one might have to ping any ip in the subnet of the Ethernet interface constantly so that it does not forget the ip during operation.
* Eg. if rx_udpip is 10.2.3.100, then ping constantly 10.2.3.xxx, where xxx is any ip other than 100.
* Using slsReceiver, you can use a command that does this for you:
.. code-block:: bash
# arping the interface in a separate thread every minute
sls_detector_put rx_arping 1
@ -97,12 +68,6 @@ Common
Receiver PC Tuning Options
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. note ::
| xth1 is example interface name in the following examples.
| These settings are lost at pc reboot.
#. Increase maximum receive socket buffer size and socket input packet queue.
* Temporarily (until shut down)
.. code-block:: bash
@ -146,7 +111,6 @@ Receiver PC Tuning Options
# check how many GB memory you can allocate, to avoid swapping otherwise
#. Modify ethtool settings.
* rx ring parameters
.. code-block:: bash
@ -163,9 +127,6 @@ Receiver PC Tuning Options
# check
ethtool -c xth1
# enable adaptive xoalescence parameters
ethtool -C xth1 adaptive-rx on
# set to max value in your pc settings
ethtool -C xth1 rx-usecs 100
@ -177,18 +138,13 @@ Receiver PC Tuning Options
# set to max value in your pc settings
ethtool -A xth1 rx on
* generic receiver offload (might not always work)
.. code-block:: bash
.. note ::
# check
ethtool -k xth1
| xth1 is example interface name.
| These settings are lost at pc reboot.
# enable generic receiver offload
ethtool -K xth1 gro
#. Disable power saving in CPU frequency scaling and set system to performance
#. Disable CPU frequency scaling and set system to performance
* Check current policy (default might be powersave or schedutil)
.. code-block:: bash
@ -203,10 +159,7 @@ Receiver PC Tuning Options
# set to performance
sudo cpupower frequency-set -g performance
# or
cpufreq-info
for i in seq 0 7; do cpufreq-set -c $i -g performance; done
* Permanently
.. code-block:: bash
@ -226,29 +179,18 @@ Receiver PC Tuning Options
This is also set if slsReceiver is run as root user.
#. Some more advanced options:
.. warning ::
Please do not try if you do not understand
#. Disable power saving in CPU frequency
.. code-block:: bash
#. reduce the number of queue per NIC to the number of expected streams: ethtool -L xth0 combined 2
#. assign each queue to its stream: ethtool -U xth0 flow-type tcp4 dst-port 50004 action 1
#. assign to each queue (IRQ) one CPU on the right socket: echo "3"> /proc/irq/47/smp_affinity_list #change the numbers looking at /proc/interrupts
#. disable irqbalance service
#. Be sure that the switch knows the receiver mac address. Most switches reset the mac lists every few minutes, and since the receiver only receives, there is not a periodic refresh of the mac list. In this case, one can set a fixed mac list in the switch, or setup some kind of script arping or pinging out from that interface (will be available in 7.0.0).
#. assign the receiver numa node (also with -m) to the socket where the NIC is attached. To know it, cat /sys/class/net/ethxxx/device/numa_node
#. ensure file system performance can handle sustained high data rate:
* One can use dd:
# or similar command depending on your distribution
cpupower frequency-info
cpupower frequency-set -g performance
.. code-block:: bash
dd if=/dev/zero of=/testpath/testfile bs=1M count=100000
* Or better fio (which needs to be installed)
# or
cpufreq-info
for i in seq 0 7; do cpufreq-set -c $i -g performance; done
.. code-block:: bash
fio --name=global directory=/testpath/ --rw=write --ioengine=libaio --direct=0 --size=200G -- numjobs=2 --iodepth=1 --bs=1M name=job
slsReceiver Tuning
^^^^^^^^^^^^^^^^^^
@ -256,25 +198,18 @@ slsReceiver Tuning
#. Starting receiver as root to have scheduling privileges.
#. For 10g, enable flow control
.. code-block:: bash
sls_detector_put flowcontrol10g 1
#. Increase slsReceiver ring buffer depth
This can be tuned depending on the number of receivers (modules) and memory available.
#. Increase slsReceiver fifo depth between listening and processing threads.
.. code-block:: bash
# sugggested not to use more than half memory of CPU socket in case of NUMA systems) for this
sls_detector_get rx_fifodepth
# sets number of frames in fifo to 1024 ~1GB per receiver. Default is 2500
sls_detector_put rx_fifodepth 1024
#. Increase number of frames per file
This can reduce time taken to open and close files.
# sets number of frames in fifo to 5000
sls_detector_put rx_fifodepth 5000
#. Increase number of frames per file to reduce time taken to open and close files.
.. code-block:: bash
sls_detector_get rx_framesperfile
@ -282,31 +217,10 @@ slsReceiver Tuning
# writes all frames into a single file
sls_detector_put rx_framesperfile 0
#. Disable file write
This can ensure it is not the file system performance hampering high date rate.
.. code-block:: bash
sls_detector_put fwrite 0
Shared memory error
^^^^^^^^^^^^^^^^^^^
For errors due to access or size, use any of the following suggestions.
#. Delete shared memory files and try again
#. Use environment variable to use a different shared memory ending in jfxx
.. code-block:: bash
# shared memory ending in jfxx
export SLSDETNAME=jfxx
#. USe a different multi shared memory ID
.. code-block:: bash
sls_detector_put 2-config xxxx.config
# or
sls_detector_put 2-hostname bchipxxx
| For errors due to access or size, delete shared memory files nd try again.
To list all shared memory files of sls detector package.
.. code-block:: bash
@ -417,7 +331,6 @@ Cannot get multi module data
#. Check :ref:`Common Multi Module Troubleshooting<common troubleshooting multi module data>`
#. Power Supply
* Jungfrau needs a ~4A per module for a short time at startup. If not, it reboots misconfigured.
* Comment out this line in the config file: powerchip 1
* Powering on the chip increases the power consumption by a considerable amount. If commenting out this line aids in getting data (strange data due to powered off chip), then it could be the power supply current limit. Fix it (possibly to 8A current limit) and uncomment the powerchip line back in config file.

View File

@ -6,10 +6,6 @@ Config file
Commands to configure the UDP in the config file:
.. note ::
These command are recommended to be placed before "rx_hostname" if it is used.
Source Port
-----------
Hardcoded in detector server, starting at 32410.

View File

@ -1,20 +1,11 @@
.. _detector specific fields:
Detector Specific Fields
========================
Please check out :ref:`the current detector header <detector udp header>` to see
where the detector specific fields are placed.
Eiger
------
-----
.. table:: Detector Specific Field
.. table::
+----------+------------------------------+
| expLength| Sub Frame Number |
+----------+------------------------------+
| detSpec1 | 0x0 |
+----------+------------------------------+
@ -26,127 +17,3 @@ Eiger
+----------+------------------------------+
Jungfrau
---------
.. table:: Detector Specific Field
+----------+------------------------------+
| detSpec1 | Bunch Id [#]_ |
+----------+------------------------------+
| detSpec2 | 0 |
+----------+------------------------------+
| detSpec3 | DAQ info |
+----------+------------------------------+
| detSpec4 | 0 |
+----------+------------------------------+
.. table:: DAQ Info Field
+----------+--------------------+----------------------------------------------+
| Bits | Name | Description |
+----------+--------------------+-----+----------------------------------------+
| 0 | High gain | 1 | High Gain enabled |
| | +-----+----------------------------------------+
| | | 0 | High Gain disabled |
+----------+--------------------+-----+----------------------------------------+
| 1 | Fix gain stage 1 | 1 | Gain stage 1 fixed. The switch that |
| | | | selects the gains stage 1 is active all|
| | | | the time. |
| | +-----+----------------------------------------+
| | | 0 | Gain stage 1 unset. The switch that |
| | | | selects the gains stage 1 is inactive |
| | | | all the time. |
+----------+--------------------+-----+----------------------------------------+
| 2 | Fix gain stage 2 | 1 | Gain stage 2 fixed. The switch that |
| | | | selects the gains stage 2 is active all|
| | | | the time. |
| | +-----+----------------------------------------+
| | | 0 | Gain stage 2 unset. The switch that |
| | | | selects the gains stage 2 is inactive |
| | | | all the time. |
+----------+--------------------+-----+----------------------------------------+
| 4 | Comparator reset | 1 | On-chip comparator in reset state. |
| | | | Dynamic-gain switching is therefore |
| | | | disabled. |
| | +-----+----------------------------------------+
| | | 0 | On-chip comparator active. |
+----------+--------------------+-----+-----+-----+----------------------------+
| 7-5 | Jungfrau chip |Bit 7|Bit 6|Bit 5| Description |
| | version +-----+-----+-----+----------------------------+
| | | 0 | 0 | 0 | v1.0 |
| | +-----+-----+-----+----------------------------+
| | | 0 | 0 | 1 | v1.1 |
| | +-----+-----+-----+----------------------------+
| | | 0 | 1 | X | Reserved |
| | +-----+-----+-----+----------------------------+
| | | 1 | X | X | Reserved |
+----------+--------------------+-----+-----+-----+----------------------------+
| 11-8 | Storage cell select|Storage cell used for this exposure. This |
| | |field defines the storage cell that was used |
| | |to acquire the data of this frame |
+----------+--------------------+-----+----------------------------------------+
| 12 | Force switching | 1 | Forced switching to gain stage 1 at the|
| | to gain stage 1 | | start of the exposure period. |
| | +-----+----------------------------------------+
| | | 0 | Disabled forced gain switching to gain |
| | | | stage 1. Dynamic gain switching |
| | | | conditions apply. |
+----------+--------------------+-----+----------------------------------------+
| 13 | Force switching | 1 | Forced switching to gain stage 2 at the|
| | to gain stage 2 | | start of the exposure period. |
| | +-----+----------------------------------------+
| | | 0 | Disabled forced gain switching to gain |
| | | | stage 2. Dynamic gain switching |
| | | | conditions apply. |
+----------+--------------------+-----+-----+-----+----------------------------+
| 23-16 | 10-Gigabit event |The 8-bit event code contains value of the |
| | code |event received over the 10 GbE interface by |
| | |JUNGFRAU detector at the moment of the frame |
| | |acquisition. |
+----------+--------------------+-----+----------------------------------------+
| 31 | External input flag| 1 | External input flag detected in the |
| | | | last exposure. |
| | +-----+----------------------------------------+
| | | 0 | External input flag not detected in the|
| | | | last exposure. |
+----------+--------------------+-----+----------------------------------------+
Gotthard2
----------
.. table:: Detector Specific Field
+----------+------------------------------+
| detSpec1 | Train Id [#]_ |
+----------+------------------------------+
| detSpec2 | Bunch Id [#]_ |
+----------+------------------------------+
| detSpec3 | 0 |
+----------+------------------------------+
| detSpec4 | 0 |
+----------+------------------------------+
Mythen3
----------
.. table:: Detector Specific Field
+----------+------------------------------+
| detSpec1 | 0 |
+----------+------------------------------+
| detSpec2 | 0 |
+----------+------------------------------+
| detSpec3 | 0 |
+----------+------------------------------+
| detSpec4 | 0 |
+----------+------------------------------+
.. [#] **Bunch Id**: bunch identification number received by the detector at the moment of frame acquisition.
.. [#] **Train Id**: train identification number received by the detector at the moment of frame acquisition.
.. [#] **Bunch Id**: bunch identification number to identify every single exposure during a burst acquisition.

View File

@ -9,7 +9,7 @@ The UDP data format for the packets consist of a common header for all detectors
Current Version
---------------------------
**v2.0 (slsDetectorPackage v7.0.0+)**
**v3.0 (slsDetectorPackage v7.0.0+)**
.. table:: <---------------------------------------------------- 8 bytes ---------------------------------------------------->
:align: center
@ -30,57 +30,6 @@ Current Version
+-------------------------------+---------------+-------+-------+
.. note ::
Since there is no difference in the format of the UDP header from the detector
from the previous version (v2.0), the version number stays the same.
Only the struture member names have changed in sls_detector_defs.h
Description
------------
* **Detector specific field** descriptions are found :ref:`here<detector specific fields>`.
* **frameNumber**: framenumber to which the current packet belongs to.
* **expLength**: measured exposure time of the frame in tenths of microsecond. It is instead the sub frame number for Eiger.
* **packetNumber**: packet number of the frame to which the current data belongs to.
* **timestamp**: time measured at the start of frame exposure since the start of the current measurement. It is expressed in tenths of microsecond.
* **modId**: module ID picked up from det_id_[detector type].txt on the detector cpu.
* **row**: row position of the module in the detector system. It is calculated by the order of the module in hostname command, as well as the detsize command.
* **column**: column position of the module in the detector system. It is calculated by the order of the module in hostname command, as well as the detsize command.
* **detType**: detector type from enum of detectorType in the package.
* **version**: current version of the detector header (0x2).
Detector Enum
--------------
================ ========
Detector Type Value
================ ========
GENERIC 0
EIGER 1
GOTTHARD 2
JUNGFRAU 3
CHIPTESTBOARD 4
MOENCH 5
MYTHEN3 6
GOTTHARD2 7
================ ========
Previous Versions
-----------------
**v2.0 (Package v4.0.0 - 6.x.x)**
@ -103,6 +52,7 @@ Previous Versions
| debug | roundRNumber |detType|version|
+-------------------------------+---------------+-------+-------+
**v1.0 (Package v3.0.0 - 3.1.5)**
.. table:: <---------------------------------------------------- 8 bytes ---------------------------------------------------->

View File

@ -13,14 +13,16 @@ Compilation
* Using cmk.sh script,
.. code-block:: bash
./cmk.sh -bsj9 # option -s is for simulator
./cmk.sh -bsj9 #option s is for simulator
Binaries
^^^^^^^^
.. code-block:: bash
eigerDetectorServer_virtual
eigerDetectorServerMaster_virtual
eigerDetectorServerSlaveTop_virtual
eigerDetectorServerSlaveBottom_virtual
jungfrauDetectorServer_virtual
gotthardDetectorServer_virtual
gotthard2DetectorServer_virtual
@ -65,15 +67,7 @@ Sample Config file
^^^^^^^^^^^^^^^^^^
There are sample config files for each detector in slsDetectorPackage/examples folder.
For a Single Module (Basic)
.. code-block:: bash
hostname localhost
rx_hostname localhost
udp_dstip auto
For a Single Module (With Options)
For a Single Module
.. code-block:: bash
# connects to control port 1912
@ -146,7 +140,7 @@ Gui
Limitations
-----------
#. Data coming out of virtual server is fake.
#. Data coming out of virtual server is fake. Value at each pixel/ channel is incremented by 1.
#. A stop will stop the virtual acquisition only at the start of every new frame.

View File

@ -1,6 +0,0 @@
0
10, 30
40:45 50:52
1279
# all bad channels are applied for all counters in deector

View File

@ -5,7 +5,7 @@ detsize 1024 1024
hostname bchip048+bchip052+
# 1Gb receiver pc hostname (default tcpport: 1954)
rx_hostname pcmoench01:1954+pcmoench01:1955+
rx_hostname pcmoench01+pcmoench01:1955

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 KiB

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed May 24 09:44:53 2017
@ -17,9 +16,13 @@ from numpy import *
from matplotlib.pyplot import *
from matplotlib.patches import Rectangle
import os
import argparse
###############################################################################
# Input the folder of the pattern file
Folder = "./patterns/"
# Prefix name of the .pat and .alias file
File_pat = "test_v2"
# COLORS AND LINE STYLES
# alternating colors of the plots (2 needed)
colors_plot = ['tab:blue', 'tab:orange']
@ -31,7 +34,7 @@ alpha_wait = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
alpha_wait_rect = [0.2, 0.2, 0.2, 0.2, 0.2, 0.2]
# Loop colors and line styles (6 needed from 0 to 5)
colors_loop = ['tab:green', 'tab:red', 'tab:purple', 'tab:brown', 'tab:pink', 'tab:grey']
colors_loop = ['tab:green', 'tab:red', 'tab:purple', 'tab:brown', 'tab:ping', 'tab:grey']
linestyles_loop = ['-.', '-.', '-.', '-.', '-.', '-.']
alpha_loop = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
alpha_loop_rect = [0.2, 0.2, 0.2, 0.2, 0.2, 0.2]
@ -40,6 +43,8 @@ alpha_loop_rect = [0.2, 0.2, 0.2, 0.2, 0.2, 0.2]
clock_vertical_lines_spacing = 1
show_clocks_number = True
# Verbosity
verbose = False
###############################################################################
@ -82,20 +87,6 @@ def hex2binary(string_num, width=None):
return dec2binary(hex2dec(string_num.upper()), width=width)
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--directory', required = True, help = "Working directory where the pattern is located")
parser.add_argument('-p', '--pattern', required = True, help = "Pattern name")
parser.add_argument('-a', '--alias', help = "Alias name")
parser.add_argument('-v', '--verbose', action='store_true')
args = parser.parse_args()
Folder = args.directory
File_pat = args.pattern
File_alias = args.alias
verbose = args.verbose
# Look at the alias file and generate the lookup table for pin names
# Create a 64 bit look up table
table = []
@ -111,34 +102,26 @@ for i in range(64):
table.append([str(i+1), ""])
# Loop all lines
try:
with open(Folder + "/" + File_alias + ".alias") as f:
lines = f.readlines()
f.close()
nlines = len(lines)
except:
nlines = 0
if nlines > 0:
for i in range(nlines):
# whether the line is bit definition
if lines[i][0:3] == "BIT":
# split words
words = lines[i].split()
bit_num = int(words[0][3:])
table[bit_num][0] = words[0][3:]
table[bit_num][1] = words[1]
else:
for i in range(64):
table[i][0] = i
table[i][1] = f'BIT#{i}'
with open(Folder+"/" + File_pat + ".alias") as f:
lines = f.readlines()
f.close()
nlines = len(lines)
for i in range(nlines):
# whether the line is bit definition
if lines[i][0:3] == "BIT":
# split words
words = lines[i].split()
bit_num = int(words[0][3:])
table[bit_num][0] = words[0][3:]
table[bit_num][1] = words[1]
if verbose:
print(table)
# Load the pattern and get all lines
# Loop all lines
with open(Folder + "/" + File_pat + ".pat") as f_pat:
with open(Folder+"/"+File_pat+".pat") as f_pat:
lines_pat = f_pat.readlines()
f_pat.close()
@ -148,7 +131,6 @@ nlines_pat = len(lines_pat)
cnt = 0
if verbose:
print("The total number of lines of pattern:", nlines_pat)
# Loop all lines of pattern
waittime0 = None
waittime1 = None
@ -527,7 +509,7 @@ for idx, i in enumerate(range(nbiteff)):
linestyle=linestyles_loop[2], color=colors_loop[2], alpha=alpha_loop[2],
label="loop 2: " + str(nloop2) + " times" if idx == 0 else "", linewidth=2.0)
axs2[idx].plot([loop2_end, loop2_end], [-10, 10],
linestyle=linestyles_loop[2], color=colors_loop[2], alpha=alpha_loop[2], linewidth=2.0)
linestyle=linestyles_loop[0], color=colors_loop[0], alpha=alpha_loop[2], linewidth=2.0)
# Loop 3
if nloop3 is not None:

201
patternGenerator/test.p Executable file
View File

@ -0,0 +1,201 @@
//define signals and directions (Input, outputs, clocks)
#define compTestIN 1
setoutput(compTestIN);
#define curON 32
setoutput(curON);
#define side_clk 2
setclk(side_clk);
#define side_din 3
setoutput(side_din);
#define clear_shr 4
setoutput(clear_shr);
#define bottom_din 5
setoutput(bottom_din);
#define bottom_clk 6
setclk(bottom_clk);
#define gHG 7
setoutput(gHG);
#define bypassCDS 31
setoutput(bypassCDS);
#define ENprechPRE 8
setoutput(ENprechPRE);
#define res 9
setoutput(res);
#define pulseOFF 30
setoutput(pulseOFF);
#define connCDS 27
setoutput(connCDS);
#define Dsg_1 24
setoutput(Dsg_1);
#define Dsg_2 25
setoutput(Dsg_2);
#define Dsg_3 23
setoutput(Dsg_3);
#define sto0 10
setoutput(sto0);
#define sto1 11
setoutput(sto1);
#define sto2 12
setoutput(sto2);
#define resCDS 13
setoutput(resCDS);
#define prechargeConnect 14
setoutput(prechargeConnect);
#define pulse 15
setoutput(pulse);
#define PCT_mode 21
setoutput(PCT_mode);
#define res_DGS 16
setoutput(res_DGS);
#define adc_ena 17
setoutput(adc_ena);
#define CLKBIT 18
setclk(CLKBIT);
#define adc_sync 63
setoutput(adc_sync);
#define PW pw()
#define SB(x) setbit(x)
#define CB(x) clearbit(x)
#define CLOCK clearbit(CLKBIT); pw();setbit(CLKBIT);pw()
#define LCLOCK clearbit(CLKBIT); pw();setbit(CLKBIT);pw();clearbit(CLKBIT); pw()
#define CLOCKS(x) for (i=0;i<x;i++) {clearbit(CLKBIT);pw(); setbit(CLKBIT); pw();}
#define STOP setstop();
#define START setstart();
#define REPEAT(x) for (i=0;i<(x);i++) {pw();}
#define DOFOR(x) for (j=0;j<(x);j++) {
// }
#define STARTUP1 CB(compTestIN);SB(clear_shr);CB(side_clk);CB(side_din);CB(bottom_din);CB(bottom_clk);
#define STARTUP2 CB(pulse);SB(PCT_mode);SB(pulseOFF);CB(curON);
#define STARTUP3 SB(res);SB(gHG);SB(ENprechPRE);
#define STARTUP4 SB(bypassCDS); CB(connCDS);CB(sto0);SB(sto1);SB(sto2);
#define STARTUP5 SB(resCDS);CB(Dsg_1);CB(Dsg_2);SB(Dsg_3);CB(prechargeConnect);SB(res_DGS);
#define STARTUP STARTUP1 STARTUP2 STARTUP3 STARTUP4 STARTUP5 PW;
//****NOTES****//
//FUNCTIONS
//Declare functions at the beginning
void load_pix(int nx, int ny)
{//SELECT PIXEL 1,1 for readout
SB(clear_shr);PW;PW;
CB(clear_shr);PW;PW;PW;PW;
SB(side_din);PW;
SB(side_clk);PW;
CB(side_din);
setstartloop(0); //loop on the rows
SB(side_clk);PW;
setstoploop(0); //finish loop on the rows
setnloop(0,ny); //set number row selected -can be changed dynamically
CB(side_clk);PW;
SB(bottom_din);PW;
SB(bottom_clk);PW;
CB(bottom_din);
setstartloop(1); //loop on the columns
SB(bottom_clk);PW;
setstoploop(1); //loop on the columns
setnloop(1,ny); //set number columns selected -can be changed dynamically
}
void load_col(void)
{//SELECT COLUMN 1 for readout
SB(clear_shr);PW;PW;
CB(clear_shr);PW;PW;PW;PW;
SB(bottom_din);PW;
SB(bottom_clk);PW;
CB(bottom_clk);PW;
CB(bottom_din);PW;
}
//END of FUNCTIONS
////////////////////////////////////////////////////////
//LET BYPASS PREAMP AND CDS and write on preamp out.//
//THIS ALLOWS CHECKING SOURCE FOLLOWERS //
////////////////////////////////////////////////////////
PW;
SB(5); PW;
CB(5); PW;
START; //pattern starts from here
STARTUP;
setwaitpoint(0); //set wait points
PW;
setwaittime(0,20); //wait time - can be changed dynamically
SB(adc_ena);PW;
printf("ADC sync %x %d %llx\n",iaddr,adc_sync, pat);
SB(adc_sync);PW;
printf("ADC sync %x %d %llx\n",iaddr, adc_sync, pat);
CB(gHG);
setwaitpoint(1); //set wait points
setwaittime(1,16); //wait time - can be changed dynamically
CB(adc_sync);PW;
load_pix(10, 20);
CB(res);
//CB(Dsg_3);PW;
CB(res_DGS);
setwaitpoint(2); //set wait points
setwaittime(2,1000); //wait time - can be changed dynamically
//SB(res_DGS);
//PW;
//SB(Dsg_3);
//
//CB(connCDS);
//TEST SIGNALS END
//
REPEAT(20)
//****************//
//*FINAL COMMANDS*//
//****************//
CB(adc_ena);PW;
//STARTUP;
STOP; PW; //stops here
//REPEAT(4);

View File

@ -7,7 +7,7 @@ Build upon the pybind11 example found here: https://github.com/pybind/python_exa
import os
import sys
sys.path.append('../libs/pybind')
sys.path.append('../libs/pybind11')
from setuptools import setup, find_packages
from pybind11.setup_helpers import Pybind11Extension, build_ext
@ -22,25 +22,19 @@ def get_conda_path():
return os.environ['CONDA_PREFIX']
#TODO migrate to CMake build or fetch files from cmake?
#TODO migrate to CMake build?
ext_modules = [
Pybind11Extension(
'_slsdet',
['src/main.cpp',
'src/enums.cpp',
'src/current.cpp',
'src/enums.cpp',
'src/detector.cpp',
'src/network.cpp',
'src/pattern.cpp',
'src/scan.cpp',
'src/duration.cpp',
'src/DurationWrapper.cpp',
]
,
'src/scan.cpp',],
include_dirs=[
os.path.join('../libs/pybind/include'),
os.path.join('../libs/pybind11/include'),
os.path.join(get_conda_path(), 'include'),
],

View File

@ -14,7 +14,7 @@ streamingInterface = slsDetectorDefs.streamingInterface
defs = slsDetectorDefs
from .utils import element_if_equal, all_equal, get_set_bits, list_to_bitmask
from .utils import Geometry, to_geo, element, reduce_time, is_iterable, hostname_list
from .utils import Geometry, to_geo, element, reduce_time, is_iterable
from _slsdet import xy
from . import utils as ut
from .proxy import JsonProxy, SlowAdcProxy, ClkDivProxy, MaxPhaseProxy, ClkFreqProxy, PatLoopProxy, PatNLoopProxy, PatWaitProxy, PatWaitTimeProxy
@ -162,8 +162,12 @@ class Detector(CppDetectorApi):
@hostname.setter
def hostname(self, hostnames):
args = hostname_list(hostnames)
self.setHostname(args)
if isinstance(hostnames, str):
hostnames = [hostnames]
if isinstance(hostnames, list):
self.setHostname(hostnames)
else:
raise ValueError("hostname needs to be string or list of strings")
@property
@ -225,14 +229,6 @@ class Detector(CppDetectorApi):
"""
return self.getDetectorServerVersion()
@property
@element
def hardwareversion(self):
"""
[Jungfrau][Gotthard2][Myhten3][Gotthard][Ctb][Moench] Hardware version of detector.
"""
return ut.lhex(self.getHardwareVersion())
@property
@element
def kernelversion(self):
@ -267,7 +263,7 @@ class Detector(CppDetectorApi):
@element
def rx_threads(self):
"""
Get kernel thread ids from the receiver in order of [parent, tcp, listener 0, processor 0, streamer 0, listener 1, processor 1, streamer 1, arping].
Get thread ids from the receiver in order of [parent, tcp, listener 0, processor 0, streamer 0, listener 1, processor 1, streamer 1, arping].
Note
-----
@ -462,35 +458,16 @@ class Detector(CppDetectorApi):
-----
[Mythen3] sets exposure time to all gate signals in auto and trigger mode (internal gating). To specify gateIndex, use getExptime or setExptime.
:getter: always returns in seconds. To get in DurationWrapper, use getExptime
:getter: always returns in seconds. To get in datetime.delta, use getExptime
Example
-----------
>>> # setting directly in seconds
>>> d.exptime = 1.05
>>>
>>> # setting directly in seconds
>>> d.exptime = 5e-07
>>>
>>> # using timedelta (up to microseconds precision)
>>> from datatime import timedelta
>>> d.exptime = timedelta(seconds = 1, microseconds = 3)
>>>
>>> # using DurationWrapper to set in seconds
>>> from slsdet import DurationWrapper
>>> d.exptime = DurationWrapper(1.2)
>>>
>>> # using DurationWrapper to set in ns
>>> t = DurationWrapper()
>>> t.set_count(500)
>>> d.exptime = t
>>>
>>> # to get in seconds
>>> d.exptime = datetime.timedelta(minutes = 3, seconds = 1.23)
>>> d.exptime
181.23
>>>
>>> d.getExptime()
[sls::DurationWrapper(total_seconds: 1e-08 count: 10)]
[datetime.timedelta(seconds=181, microseconds=230000)]
"""
if self.type == detectorType.MYTHEN3:
res = self.getExptimeForAllGates()
@ -518,35 +495,16 @@ class Detector(CppDetectorApi):
Note
-----
:getter: always returns in seconds. To get in DurationWrapper, use getPeriod
:getter: always returns in seconds. To get in datetime.delta, use getPeriod
Example
-----------
>>> # setting directly in seconds
>>> d.period = 1.05
>>>
>>> # setting directly in seconds
>>> d.period = 5e-07
>>>
>>> # using timedelta (up to microseconds precision)
>>> from datatime import timedelta
>>> d.period = timedelta(seconds = 1, microseconds = 3)
>>>
>>> # using DurationWrapper to set in seconds
>>> from slsdet import DurationWrapper
>>> d.period = DurationWrapper(1.2)
>>>
>>> # using DurationWrapper to set in ns
>>> t = DurationWrapper()
>>> t.set_count(500)
>>> d.period = t
>>>
>>> # to get in seconds
>>> d.period = datetime.timedelta(minutes = 3, seconds = 1.23)
>>> d.period
181.23
>>>
>>> d.getExptime()
sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)
>>> d.getPeriod()
[datetime.timedelta(seconds=181, microseconds=230000)]
"""
res = self.getPeriod()
return reduce_time(res)
@ -566,7 +524,7 @@ class Detector(CppDetectorApi):
-----
[Gotthard2] only in continuous mode.
:getter: always returns in seconds. To get in DurationWrapper, use getPeriodLeft
:getter: always returns in seconds. To get in datetime.delta, use getPeriodLeft
:setter: Not Implemented
Example
@ -574,7 +532,7 @@ class Detector(CppDetectorApi):
>>> d.periodl
181.23
>>> d.getPeriodLeft()
[sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)]
[datetime.timedelta(seconds=181, microseconds=230000)]
"""
return self.getPeriodLeft()
@ -582,40 +540,21 @@ class Detector(CppDetectorApi):
@element
def delay(self):
"""
[Gotthard][Jungfrau][CTB][Moench][Mythen3][Gotthard2] Delay after trigger, accepts either a value in seconds, DurationWrapper or datetime.timedelta
[Gotthard][Jungfrau][CTB][Moench][Mythen3][Gotthard2] Delay after trigger, accepts either a value in seconds or datetime.timedelta
Note
-----
:getter: always returns in seconds. To get in DurationWrapper, use getDelayAfterTrigger
:getter: always returns in seconds. To get in datetime.delta, use getDelayAfterTrigger
Example
-----------
>>> # setting directly in seconds
>>> d.delay = 1.05
>>>
>>> # setting directly in seconds
>>> d.delay = 5e-07
>>>
>>> # using timedelta (up to microseconds precision)
>>> from datatime import timedelta
>>> d.delay = timedelta(seconds = 1, microseconds = 3)
>>>
>>> # using DurationWrapper to set in seconds
>>> from slsdet import DurationWrapper
>>> d.delay = DurationWrapper(1.2)
>>>
>>> # using DurationWrapper to set in ns
>>> t = DurationWrapper()
>>> t.set_count(500)
>>> d.delay = t
>>>
>>> # to get in seconds
>>> d.delay = datetime.timedelta(minutes = 3, seconds = 1.23)
>>> d.delay
181.23
>>>
>>> d.getDelayAfterTrigger()
sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)
[datetime.timedelta(seconds=181, microseconds=230000)]
"""
return ut.reduce_time(self.getDelayAfterTrigger())
@ -627,13 +566,13 @@ class Detector(CppDetectorApi):
@element
def delayl(self):
"""
[Gotthard][Jungfrau][CTB][Moench][Mythen3][Gotthard2] Delay left after trigger during acquisition, accepts either a value in seconds, datetime.timedelta or DurationWrapper
[Gotthard][Jungfrau][CTB][Moench][Mythen3][Gotthard2] Delay left after trigger during acquisition, accepts either a value in seconds or datetime.timedelta
Note
-----
[Gotthard2] only in continuous mdoe.
:getter: always returns in seconds. To get in DurationWrapper, use getDelayAfterTriggerLeft
:getter: always returns in seconds. To get in datetime.delta, use getDelayAfterTriggerLeft
:setter: Not Implemented
Example
@ -641,7 +580,7 @@ class Detector(CppDetectorApi):
>>> d.delayl
181.23
>>> d.getDelayAfterTriggerLeft()
[sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)]
[datetime.timedelta(seconds=181, microseconds=230000)]
"""
return ut.reduce_time(self.getDelayAfterTriggerLeft())
@ -680,46 +619,25 @@ class Detector(CppDetectorApi):
@property
@element
def txdelay(self):
"""
[Eiger][Jungfrau][Mythen3] Set transmission delay for all modules in the detector using the step size provided.
Note
----
Sets up the following for every module:\n
\t\t[Eiger] txdelay_left to (2 * mod_index * n_delay), \n
\t\t[Eiger] txdelay_right to ((2 * mod_index + 1) * n_delay) and \n
\t\t[Eiger] txdelay_frame to (2 *num_modules * n_delay) \n
\t\t[Jungfrau][Mythen3] txdelay_frame to (num_modules * n_delay)\n\n
Please refer txdelay_left, txdelay_right and txdelay_frame for details.
"""
return self.getTransmissionDelay()
@txdelay.setter
def txdelay(self, args):
ut.set_using_dict(self.setTransmissionDelay, args)
@property
@element
def txdelay_frame(self):
def txndelay_frame(self):
"""
[Eiger][Jungfrau][Mythen3] Transmission delay of first udp packet being streamed out of the module.\n
Note
----
[Jungfrau] [0-31] Each value represents 1 ms. \n
[Eiger] Additional delay to txdelay_left and txdelay_right. Each value represents 10ns. Typical value is 50000. \n
[Eiger] Additional delay to txndelay_left and txndelay_right. Each value represents 10ns. Typical value is 50000. \n
[Mythen3] [0-16777215] Each value represents 8 ns (125 MHz clock), max is 134 ms.
"""
return self.getTransmissionDelayFrame()
@txdelay_frame.setter
def txdelay_frame(self, args):
@txndelay_frame.setter
def txndelay_frame(self, args):
ut.set_using_dict(self.setTransmissionDelayFrame, args)
@property
@element
def txdelay_left(self):
def txndelay_left(self):
"""[Eiger] Transmission delay of first packet in an image being streamed out of the module's left UDP port.
Note
@ -728,13 +646,13 @@ class Detector(CppDetectorApi):
"""
return self.getTransmissionDelayLeft()
@txdelay_left.setter
def txdelay_left(self, args):
@txndelay_left.setter
def txndelay_left(self, args):
ut.set_using_dict(self.setTransmissionDelayLeft, args)
@property
@element
def txdelay_right(self):
def txndelay_right(self):
"""
[Eiger] Transmission delay of first packet in an image being streamed out of the module's right UDP port.
@ -744,8 +662,8 @@ class Detector(CppDetectorApi):
"""
return self.getTransmissionDelayRight()
@txdelay_right.setter
def txdelay_right(self, args):
@txndelay_right.setter
def txndelay_right(self, args):
ut.set_using_dict(self.setTransmissionDelayRight, args)
@property
@ -780,8 +698,7 @@ class Detector(CppDetectorApi):
@rx_hostname.setter
def rx_hostname(self, hostname):
args = hostname_list(hostname)
self.setRxHostname(args)
self.setRxHostname(hostname)
@property
@element
@ -1565,20 +1482,6 @@ class Detector(CppDetectorApi):
def trimval(self, value):
ut.set_using_dict(self.setAllTrimbits, value)
@property
@element
def fliprows(self):
"""
[Eiger] flips rows paramater sent to slsreceiver to stream as json parameter to flip rows in gui. \n
[Jungfrau] flips rows in the detector itself. For bottom module and number of interfaces must be set to 2. slsReceiver and slsDetectorGui does not handle.
"""
return self.getFlipRows()
@fliprows.setter
def fliprows(self, value):
ut.set_using_dict(self.setFlipRows, value)
@property
@element
def master(self):
@ -1604,19 +1507,6 @@ class Detector(CppDetectorApi):
def sync(self, value):
ut.set_using_dict(self.setSynchronization, value)
@property
@element
def badchannels(self):
"""
[fname|none|0]\n\t[Gotthard2][Mythen3] Sets the bad channels (from file of bad channel numbers) to be masked out. None or 0 unsets all the badchannels.\n
[Mythen3] Also does trimming
"""
return self.getBadChannels()
@badchannels.setter
def badchannels(self, value):
ut.set_using_dict(self.setBadChannels, value)
@property
@element
def lock(self):
@ -1826,21 +1716,11 @@ class Detector(CppDetectorApi):
@property
def versions(self):
if self.type == detectorType.EIGER:
return {'type': self.type,
'package': self.packageversion,
'client': self.clientversion,
'firmware': self.firmwareversion,
'detectorserver': self.detectorserverversion,
'kernel': self.kernelversion,
'receiver': self.rx_version}
return {'type': self.type,
'package': self.packageversion,
'client': self.clientversion,
'firmware': self.firmwareversion,
'detectorserver': self.detectorserverversion,
'hardware':self.hardwareversion,
'kernel': self.kernelversion,
'receiver': self.rx_version}
@ -2115,35 +1995,16 @@ class Detector(CppDetectorApi):
----
Subperiod = subexptime + subdeadtime.
:getter: always returns in seconds. To get in DurationWrapper, use getSubExptime
:getter: always returns in seconds. To get in datetime.delta, use getSubExptime
Example
-----------
>>> # setting directly in seconds
>>> d.subexptime = 1.230203
>>>
>>> # setting directly in seconds
>>> d.subexptime = 5e-07
>>>
>>> # using timedelta (up to microseconds precision)
>>> from datatime import timedelta
>>> d.subexptime = timedelta(seconds = 1.23, microseconds = 203)
>>>
>>> # using DurationWrapper to set in seconds
>>> from slsdet import DurationWrapper
>>> d.subexptime = DurationWrapper(1.2)
>>>
>>> # using DurationWrapper to set in ns
>>> t = DurationWrapper()
>>> t.set_count(500)
>>> d.subexptime = t
>>>
>>> # to get in seconds
>>> d.subexptime = datetime.timedelta(seconds = 1.23, microseconds = 203)
>>> d.subexptime
181.23
>>>
1.230203
>>> d.getSubExptime()
sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)
[datetime.timedelta(seconds = 1, microseconds = 203)]
"""
res = self.getSubExptime()
return reduce_time(res)
@ -2175,41 +2036,22 @@ class Detector(CppDetectorApi):
@property
def subdeadtime(self):
"""
[Eiger] Dead time of EIGER subframes in 32 bit mode, accepts either a value in seconds, datetime.timedelta or DurationWrapper
[Eiger] Dead time of EIGER subframes in 32 bit mode, accepts either a value in seconds or datetime.timedelta
Note
----
Subperiod = subexptime + subdeadtime.
:getter: always returns in seconds. To get in DurationWrapper, use getSubDeadTime
:getter: always returns in seconds. To get in datetime.delta, use getSubDeadTime
Example
-----------
>>> # setting directly in seconds
>>> d.subdeadtime = 1.230203
>>>
>>> # setting directly in seconds
>>> d.subdeadtime = 5e-07
>>>
>>> # using timedelta (up to microseconds precision)
>>> from datatime import timedelta
>>> d.subdeadtime = timedelta(seconds = 1.23, microseconds = 203)
>>>
>>> # using DurationWrapper to set in seconds
>>> from slsdet import DurationWrapper
>>> d.subdeadtime = DurationWrapper(1.2)
>>>
>>> # using DurationWrapper to set in ns
>>> t = DurationWrapper()
>>> t.set_count(500)
>>> d.subdeadtime = t
>>>
>>> # to get in seconds
>>> d.subdeadtime = datetime.timedelta(seconds = 1.23, microseconds = 203)
>>> d.subdeadtime
181.23
>>>
1.230203
>>> d.getSubDeadTime()
sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)
[datetime.timedelta(seconds = 1, microseconds = 203)]
"""
res = self.getSubDeadTime()
return reduce_time(res)
@ -2385,35 +2227,16 @@ class Detector(CppDetectorApi):
-----
It is only possible for chipv1.1.
:getter: always returns in seconds. To get in DurationWrapper, use getComparatorDisableTime
:getter: always returns in seconds. To get in datetime.delta, use getComparatorDisableTime
Example
-----------
>>> # setting directly in seconds
>>> d.compdisabletime = 1.05
>>>
>>> # setting directly in seconds
>>> d.compdisabletime = 5e-07
>>>
>>> # using timedelta (up to microseconds precision)
>>> from datatime import timedelta
>>> d.compdisabletime = timedelta(seconds = 1, microseconds = 3)
>>>
>>> # using DurationWrapper to set in seconds
>>> from slsdet import DurationWrapper
>>> d.compdisabletime = DurationWrapper(1.2)
>>>
>>> # using DurationWrapper to set in ns
>>> t = DurationWrapper()
>>> t.set_count(500)
>>> d.compdisabletime = t
>>>
>>> # to get in seconds
>>> d.compdisabletime = datetime.timedelta(minutes = 3, seconds = 1.23)
>>> d.compdisabletime
181.23
>>>
>>> d.getComparatorDisableTime()
sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)
[datetime.timedelta(seconds=181, microseconds=230000)]
"""
return ut.reduce_time(self.getComparatorDisableTime())
@ -2471,42 +2294,23 @@ class Detector(CppDetectorApi):
@property
def storagecell_delay(self):
"""
[Jungfrau] Additional time delay between 2 consecutive exposures in burst mode, accepts either a value in seconds, datetime.timedelta or DurationWrapper
[Jungfrau] Additional time delay between 2 consecutive exposures in burst mode, accepts either a value in seconds or datetime.timedelta
Note
-----
Only applicable for chipv1.0. For advanced users only \n
Value: 0-1638375 ns (resolution of 25ns)
:getter: always returns in seconds. To get in DurationWrapper, use getStorageCellDelay
:getter: always returns in seconds. To get in datetime.delta, use getStorageCellDelay
Example
-----------
>>> # setting directly in seconds
>>> d.storagecell_delay = 1.05
>>>
>>> # setting directly in seconds
>>> d.storagecell_delay = 5e-07
>>>
>>> # using timedelta (up to microseconds precision)
>>> from datatime import timedelta
>>> d.storagecell_delay = timedelta(seconds = 1, microseconds = 3)
>>>
>>> # using DurationWrapper to set in seconds
>>> from slsdet import DurationWrapper
>>> d.storagecell_delay = DurationWrapper(1.2)
>>>
>>> # using DurationWrapper to set in ns
>>> t = DurationWrapper()
>>> t.set_count(500)
>>> d.storagecell_delay = t
>>>
>>> # to get in seconds
>>> d.storagecell_delay = 0.00056
>>> d.storagecell_delay = datetime.timedelta(microseconds = 45)
>>> d.storagecell_delay
181.23
>>>
4.5e-05
>>> d.getStorageCellDelay()
sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)
[datetime.timedelta(microseconds=45)]
"""
return ut.reduce_time(self.getStorageCellDelay())
@ -2780,36 +2584,18 @@ class Detector(CppDetectorApi):
Note
-----
:getter: always returns in seconds. To get in DurationWrapper, use getBurstPeriod
:getter: always returns in seconds. To get in datetime.delta, use getBurstPeriod
:setter: Not Implemented
Example
-----------
>>> # setting directly in seconds
>>> d.burstperiod = 1.05
>>>
>>> # setting directly in seconds
>>> d.burstperiod = 5e-07
>>>
>>> # using timedelta (up to microseconds precision)
>>> from datatime import timedelta
>>> d.burstperiod = timedelta(seconds = 1, microseconds = 3)
>>>
>>> # using DurationWrapper to set in seconds
>>> from slsdet import DurationWrapper
>>> d.burstperiod = DurationWrapper(1.2)
>>>
>>> # using DurationWrapper to set in ns
>>> t = DurationWrapper()
>>> t.set_count(500)
>>> d.burstperiod = t
>>>
>>> # to get in seconds
>>> d.burstperiod = datetime.timedelta(minutes = 3, seconds = 1.23)
>>> d.burstperiod
181.23
>>>
>>> d.getBurstPeriod()
sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)
[datetime.timedelta(seconds=181, microseconds=230000)]
"""
return ut.reduce_time(self.getBurstPeriod())
@ -2934,41 +2720,25 @@ class Detector(CppDetectorApi):
@property
def gatedelay(self):
"""
[Mythen3] Gate Delay of all gate signals in auto and trigger mode (internal gating), accepts either a value in seconds, datetime.timedelta or DurationWrapper
[Mythen3] Gate Delay of all gate signals in auto and trigger mode (internal gating), accepts either a value in seconds or datetime.timedelta
Note
-----
To specify gateIndex, use getGateDelay or setGateDelay.
:getter: always returns in seconds. To get in DurationWrapper, use getGateDelayForAllGates or getGateDelay(gateIndex)
:getter: always returns in seconds. To get in datetime.delta, use getGateDelayForAllGates or getGateDelay(gateIndex)
Example
-----------
>>> # setting directly in seconds
>>> d.gatedelay = 1.05
>>>
>>> # setting directly in seconds
>>> d.gatedelay = 5e-07
>>>
>>> # using timedelta (up to microseconds precision)
>>> from datatime import timedelta
>>> d.gatedelay = timedelta(seconds = 1, microseconds = 3)
>>>
>>> # using DurationWrapper to set in seconds
>>> from slsdet import DurationWrapper
>>> d.gatedelay = DurationWrapper(1.2)
>>>
>>> # using DurationWrapper to set in ns
>>> t = DurationWrapper()
>>> t.set_count(500)
>>> d.gatedelay = t
>>>
>>> # to get in seconds
>>> d.gatedelay = datetime.timedelta(minutes = 3, seconds = 1.23)
>>> d.gatedelay
181.23
>>>
>>> d.setGateDelay(1, datetime.timedelta(seconds = 2))
>>> d.gatedelay
>>> [1.0, 2.0, 1.0]
>>> d.getExptimeForAllGates()
sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)
>>> [[datetime.timedelta(seconds=181, microseconds=230000), datetime.timedelta(seconds=181, microseconds=230000), datetime.timedelta(seconds=181, microseconds=230000)]]
"""
return reduce_time(self.getGateDelayForAllGates())
@ -3772,7 +3542,7 @@ class Detector(CppDetectorApi):
Note
-----
:getter: always returns in seconds. To get in DurationWrapper, use getExptimeLeft
:getter: always returns in seconds. To get in datetime.delta, use getExptimeLeft
:setter: Not Implemented
Example
@ -3780,7 +3550,7 @@ class Detector(CppDetectorApi):
>>> d.exptimel
181.23
>>> d.getExptimeLeft()
[sls::DurationWrapper(total_seconds: 181.23 count: 181230000000)]
[datetime.timedelta(seconds=181, microseconds=230000)]
"""
t = self.getExptimeLeft()
return reduce_time(t)

View File

@ -260,21 +260,4 @@ def merge_args(*args):
return (ret,)
else:
raise ValueError("Multiple dictionaries passes cannot merge args")
def hostname_list(args):
"""
Generates a list from a hostname string
* Lists are passed through
* as are tuples (conversion in pybind11 to vector)
* if + is found it splits the string
"""
if isinstance(args, (list, tuple)):
return args
elif(isinstance(args, str)):
hosts = args.split('+')
hosts = [it for it in hosts if len(it)]
return hosts
else:
raise ValueError("hostname needs to be string or list of strings")
raise ValueError("Multiple dictionaries passes cannot merge args")

View File

@ -66,11 +66,6 @@ void init_det(py::module &m) {
(Result<std::string>(Detector::*)(sls::Positions) const) &
Detector::getDetectorServerVersion,
py::arg() = Positions{});
CppDetectorApi.def(
"getHardwareVersion",
(Result<std::string>(Detector::*)(sls::Positions) const) &
Detector::getHardwareVersion,
py::arg() = Positions{});
CppDetectorApi.def(
"getKernelVersion",
(Result<std::string>(Detector::*)(sls::Positions) const) &
@ -219,21 +214,6 @@ void init_det(py::module &m) {
(void (Detector::*)(const std::string &, sls::Positions)) &
Detector::setBadChannels,
py::arg(), py::arg() = Positions{});
CppDetectorApi.def(
"getBadChannels",
(Result<std::vector<int>>(Detector::*)(sls::Positions) const) &
Detector::getBadChannels,
py::arg() = Positions{});
CppDetectorApi.def(
"setBadChannels",
(void (Detector::*)(const std::vector<int>, sls::Positions)) &
Detector::setBadChannels,
py::arg(), py::arg() = Positions{});
CppDetectorApi.def(
"setBadChannels",
(void (Detector::*)(const std::vector<std::vector<int>>)) &
Detector::setBadChannels,
py::arg());
CppDetectorApi.def("isVirtualDetectorServer",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::isVirtualDetectorServer,
@ -798,12 +778,6 @@ void init_det(py::module &m) {
(void (Detector::*)(int, sls::Positions)) &
Detector::setTransmissionDelayRight,
py::arg(), py::arg() = Positions{});
CppDetectorApi.def("getTransmissionDelay",
(int (Detector::*)() const) &
Detector::getTransmissionDelay);
CppDetectorApi.def(
"setTransmissionDelay",
(void (Detector::*)(int)) & Detector::setTransmissionDelay, py::arg());
CppDetectorApi.def("getUseReceiverFlag",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getUseReceiverFlag,

View File

@ -12,7 +12,6 @@ void init_duration(py::module &m) {
.def("total_seconds", &DurationWrapper::total_seconds)
.def("count", &DurationWrapper::count)
.def("set_count", &DurationWrapper::set_count)
.def("__eq__", &DurationWrapper::operator==)
.def("__repr__", [](const DurationWrapper &self) {
std::stringstream ss;
ss << "sls::DurationWrapper(total_seconds: " << self.total_seconds()

View File

@ -8,7 +8,7 @@ Testing functions from utils.py
import pytest
from slsdet.utils import *
from slsdet import IpAddr, MacAddr, DurationWrapper
from slsdet import IpAddr, MacAddr
import datetime as dt
import pathlib
from pathlib import Path
@ -22,11 +22,7 @@ def test_iterable():
def test_reduce_time_to_single_value_from_list():
t = [dt.timedelta(seconds=1) for i in range(3)]
assert reduce_time(t) == 1
def test_reduce_time_to_single_value_from_list_DurationWrapper():
t = [DurationWrapper(1) for i in range(3)]
t = 3 * [dt.timedelta(seconds=1)]
assert reduce_time(t) == 1
@ -87,12 +83,6 @@ def test_all_equal_str_fails():
assert all_equal('aaab') == False
def test_all_equal_DurationWrapper():
assert all_equal([DurationWrapper(1), DurationWrapper(1)])
def test_all_equal_DurationWrapper_fail():
assert not all_equal([DurationWrapper(1), DurationWrapper(2)])
def test_element_if_equal_int():
assert element_if_equal([5, 5]) == 5
@ -351,33 +341,4 @@ def test_merge_args_tuple():
assert merge_args(*("a", "b"), 5) == ("a", "b", 5)
def test_merge_args_dict_with_tuple():
assert merge_args({0: (1,2)}, 3) == ({0: (1,2,3)},)
def test_hostname_to_list():
s = "localhost"
r = hostname_list(s)
assert r == [s]
def test_hostname_to_list_passthrough():
args = ["localhost"]
ret = hostname_list(args)
assert ret == args
args = ("localhost",)
ret = hostname_list(args)
assert ret == args
def test_splitting_hostname():
args = 'apple+banana+pear+'
ret = hostname_list(args)
assert ret == ['apple', 'banana', 'pear']
#not sensitive to trailing +
args = 'apple+banana+pear'
ret = hostname_list(args)
assert ret == ['apple', 'banana', 'pear']
def test_hostame_throws_on_wrong_args():
with pytest.raises(Exception) as e:
hostname_list(5)
assert merge_args({0: (1,2)}, 3) == ({0: (1,2,3)},)

View File

@ -0,0 +1 @@
../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv6.1.0

View File

@ -1 +0,0 @@
../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv7.0.0.rc3

View File

@ -0,0 +1 @@
../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv6.1.0

View File

@ -1 +0,0 @@
../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv7.0.0.rc3

View File

@ -0,0 +1 @@
../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv6.1.0

View File

@ -1 +0,0 @@
../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv7.0.0.rc3

View File

@ -0,0 +1 @@
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv6.1.0

View File

@ -1 +0,0 @@
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv7.0.0.rc3

View File

@ -0,0 +1 @@
../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv6.1.0

View File

@ -1 +0,0 @@
../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv7.0.0.rc3

View File

@ -0,0 +1 @@
../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv6.1.0

View File

@ -1 +0,0 @@
../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv7.0.0.rc3

View File

@ -0,0 +1 @@
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv6.1.0

View File

@ -1 +0,0 @@
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv7.0.0.rc3

View File

@ -40,31 +40,20 @@ class jungfrauModuleData : public slsDetectorData<uint16_t> {
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
1286 large etc.) \param c crosstalk parameter for the output buffer
*/
#ifndef ZMQ
#define off sizeof(jf_header)
#endif
#ifdef ZMQ
#define off 0
#endif
*/
jungfrauModuleData()
: slsDetectorData<uint16_t>(1024, 512,
1024* 512 * 2 + off) {
1024* 512 * 2 + sizeof(jf_header)) {
for (int ix = 0; ix < 1024; ix++) {
for (int iy = 0; iy < 512; iy++) {
dataMap[iy][ix] = off + (1024 * iy + ix) * 2;
dataMap[iy][ix] = sizeof(jf_header) + (1024 * iy + ix) * 2;
#ifdef HIGHZ
dataMask[iy][ix] = 0x3fff;
#endif
}
}
iframe = 0;
// cout << "data struct created" << endl;
};

View File

@ -1,64 +0,0 @@
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
#module add CBFlib/0.9.5
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ -I../tiffio/include
LDFLAG= ../tiffio/src/tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -pthread -lrt -ltiff -O3 -std=c++11
MAIN=jungfrauClusterFinder.cpp
all: jungfrauRawDataProcess
jungfrauRawDataProcess: jungfrauRawDataProcess.cpp $(INCS) clean
g++ -o jungfrauRawDataProcess jungfrauRawDataProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DMODULE
jungfrauRawDataProcessStrx: jungfrauRawDataProcess.cpp $(INCS) clean
g++ -o jungfrauRawDataProcessStrx jungfrauRawDataProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DJFSTRX
jungfrauRawDataProcessStrxAldo: jungfrauRawDataProcess.cpp $(INCS) clean
g++ -o jungfrauRawDataProcessStrxAldo jungfrauRawDataProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DJFSTRX -DALDO
jungfrauRawDataProcessStrxOld: jungfrauRawDataProcess.cpp $(INCS) clean
g++ -o jungfrauRawDataProcessStrxOld jungfrauRawDataProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DJFSTRXOLD
jungfrauRawDataProcessStrxOldAldo: jungfrauRawDataProcess.cpp $(INCS) clean
g++ -o jungfrauRawDataProcessStrxOldAldo jungfrauRawDataProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DJFSTRXOLD -DALDO
jungfrauClusterFinder: jungfrauClusterFinder.cpp $(INCS) clean
g++ -o jungfrauClusterFinder jungfrauClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
jungfrauClusterFinderHighZ: jungfrauClusterFinder.cpp $(INCS) clean
g++ -o jungfrauClusterFinderHighZ jungfrauClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DHIGHZ
jungfrauMakeEta: jungfrauInterpolation.cpp $(INCS) clean
g++ -o jungfrauMakeEta jungfrauInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF
jungfrauInterpolation: jungfrauInterpolation.cpp $(INCS) clean
g++ -o jungfrauInterpolation jungfrauInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
jungfrauNoInterpolation: jungfrauNoInterpolation.cpp $(INCS) clean
g++ -o jungfrauNoInterpolation jungfrauNoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
jungfrauPhotonCounter: jungfrauPhotonCounter.cpp $(INCS) clean
g++ -o jungfrauPhotonCounter jungfrauPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER
jungfrauAnalog: jungfrauPhotonCounter.cpp $(INCS) clean
g++ -o jungfrauAnalog jungfrauPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG
jungfrauPhotonCounterHighZ: jungfrauPhotonCounter.cpp $(INCS) clean
g++ -o jungfrauPhotonCounterHighZ jungfrauPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DHIGHZ
jungfrauAnalogHighZ: jungfrauPhotonCounter.cpp $(INCS) clean
g++ -o jungfrauAnalogHighZ jungfrauPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG -DHIGHZ
clean:
rm -f jungfrauClusterFinder jungfrauMakeEta jungfrauInterpolation jungfrauNoInterpolation jungfrauPhotonCounter jungfrauAnalog

View File

@ -1,19 +1,25 @@
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
INCDIR= -I. -I../dataStructures ../tiffio/src/tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ -I../../libs/rapidjson/ -I../tiffio/include
INCDIR= -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ -I../../libs/rapidjson/
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3 -std=c++11 -Wall -L../../build/bin/ -lSlsSupport
#-L../../bin -lhdf5 -L.
#DESTDIR?=../bin
all: jungfrauZmqProcess
#jungfrauZmqProcessCtbGui
all: moenchZmqProcess moenchZmq04Process
#moenchZmqProcessCtbGui
jungfrauZmqProcess: jungfrauZmqProcess.cpp clean
g++ -o jungfrauZmqProcess jungfrauZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP
moenchZmqProcess: moenchZmqProcess.cpp clean
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP
moenchZmq04Process: moenchZmqProcess.cpp clean
g++ -o moench04ZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DMOENCH04
#moenchZmqProcessCtbGui: moenchZmqProcess.cpp clean
# g++ -o moenchZmqProcessCtbGui moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DCTBGUI
clean:
rm -f jungfrauZmqProcess
rm -f moenchZmqProcess

View File

@ -1,26 +0,0 @@
ROOTSYS=/opt/cern/v6/root
#/afs/psi.ch/project/sls_det_sof/roottware/root_v5.34.23_sl6_64bit
LIBZMQDIR = $(PWD)
LIBZMQ = -L$(LIBZMQDIR) -lzmq
SHLIB_PATH=/opt/cern/v6/root/lib
CMAKE_PREFIX_PATH=/opt/cern/v6/root
DYLD_LIBRARY_PATH=/opt/cern/v6/root/lib
INCDIR= -I. -I../dataStructures ../tiffio/src/tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ -I../../libs/rapidjson/ -I../tiffio/include
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3 -std=c++11 -Wall -L../../build/bin/ -lSlsSupport
#-L../../bin -lhdf5 -L.
default: onlinedisp_zmq
onlinedisp_zmq: onlinedisp_zmq.cpp onlinedisp_zmq.h
# flags from root-config --cflags --glibs
g++ -o onlinedisp_zmq onlinedisp_zmq.cpp -I. -I$(ROOTSYS)/include -Wall -g -lm -L. -lzmq -pthread -lrt -L$(ROOTSYS)/lib -lGui -lCore -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -m64 $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
#-lCint

View File

@ -1,10 +0,0 @@
sls_detector_put rx_jsonpara detectorMode counting
sls_detector_put rx_jsonpara frameMode newPedestal
sls_detector_put rx_jsonpara frameMode frame
sls_detector_put rx_jsonpara detectorMode analog
sls_detector_put rx_jsonpara threshold 150
sls_detector_put rx_jsonpara threshold 0
sls_detector_put rx_jsonpara threshold 300
sls_detector_put rx_zmqhwm 50

View File

@ -1,418 +0,0 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
//#include "sls/ansi.h"
#include <iostream>
#undef CORR
#define C_GHOST 0.0004
#define CM_ROWS 50
#define RAWDATA
#ifndef JFSTRX
#ifndef JFSTRXOLD
#ifndef MODULE
#include "jungfrauHighZSingleChipData.h"
#endif
#ifdef MODULE
#include "jungfrauModuleData.h"
#endif
#endif
#endif
#ifdef JFSTRX
#include "jungfrauLGADStrixelsData.h"
#endif
#ifdef JFSTRXOLD
#include "jungfrauStrixelsHalfModuleOldDesign.h"
#endif
#include "multiThreadedCountingDetector.h"
#include "singlePhotonDetector.h"
#include <fstream>
#include <map>
#include <stdio.h>
#include <sys/stat.h>
#include <ctime>
using namespace std;
int main(int argc, char *argv[]) {
if (argc < 5) {
cout << "Usage is " << argv[0]
<< "indir outdir fname(no extension) fextension [runmin] [runmax] [pedfile (raw or tiff)] [threshold] "
"[nframes] [xmin xmax ymin ymax] [gainmap]"
<< endl;
cout << "threshold <0 means analog; threshold=0 means cluster finder; "
"threshold>0 means photon counting"
<< endl;
cout << "nframes <0 means sum everything; nframes=0 means one file per "
"run; nframes>0 means one file every nframes"
<< endl;
return 1;
}
int fifosize = 1000;
int nthreads = 10;
int csize = 3;
int nsigma = 5;
int nped = 10000;
int cf = 0;
#ifndef JFSTRX
#ifndef JFSTRXOLD
#ifndef MODULE
jungfrauHighZSingleChipData *decoder = new jungfrauHighZSingleChipData();
int nx = 256, ny = 256;
#endif
#ifdef MODULE
jungfrauModuleData *decoder = new jungfrauModuleData();
int nx = 1024, ny = 512;
#endif
#endif
#endif
#ifdef JFSTRX
cout << "bbb" << endl;
jungfrauLGADStrixelsData *decoder = new jungfrauLGADStrixelsData();
int nx = 1024/5, ny = 512*5;
#endif
#ifdef JFSTRXOLD
cout << "ccc" << endl;
jungfrauStrixelsHalfModuleOldDesign *decoder = new jungfrauStrixelsHalfModuleOldDesign();
int nx = 1024*3, ny = 512/3;
#endif
decoder->getDetectorSize(nx, ny);
cout << "Detector size is " << nx << " " << ny << endl;
double *gainmap = NULL;
//float *gm;
int ff, np;
// cout << " data size is " << dsize;
ifstream filebin;
char *indir = argv[1];
char *outdir = argv[2];
char *fformat = argv[3];
char *fext = argv[4];
int runmin = 0;
// cout << "argc is " << argc << endl;
if (argc >= 6) {
runmin = atoi(argv[5]);
}
int runmax = runmin;
if (argc >= 7) {
runmax = atoi(argv[6]);
}
char *pedfile = NULL;
if (argc >= 8) {
pedfile = argv[7];
}
double thr = 0;
double thr1 = 1;
if (argc >= 9) {
thr = atof(argv[8]);
}
int nframes = 0;
if (argc >= 10) {
nframes = atoi(argv[9]);
}
int xmin = 0, xmax = nx, ymin = 0, ymax = ny;
if (argc >= 14) {
xmin = atoi(argv[10]);
xmax = atoi(argv[11]);
ymin = atoi(argv[12]);
ymax = atoi(argv[13]);
}
char *gainfname = NULL;
if (argc > 14) {
gainfname = argv[14];
cout << "Gain map file name is: " << gainfname << endl;
}
char ffname[10000];
char fname[10000];
char imgfname[10000];
char cfname[10000];
std::time_t end_time;
FILE *of = NULL;
cout << "input directory is " << indir << endl;
cout << "output directory is " << outdir << endl;
cout << "input file is " << fformat << endl;
cout << "runmin is " << runmin << endl;
cout << "runmax is " << runmax << endl;
if (pedfile)
cout << "pedestal file is " << pedfile << endl;
if (thr > 0)
cout << "threshold is " << thr << endl;
cout << "Nframes is " << nframes << endl;
uint32_t nnx, nny;
singlePhotonDetector *filter = new singlePhotonDetector(
decoder, csize, nsigma, 1, NULL, nped, 200, -1, -1, gainmap, NULL);
if (gainfname) {
if (filter->readGainMap(gainfname))
cout << "using gain map " << gainfname << endl;
else
cout << "Could not open gain map " << gainfname << endl;
} else
thr = 0.15 * thr;
filter->newDataSet();
//int dsize = decoder->getDataSize();
if (thr > 0) {
cout << "threshold is " << thr << endl;
filter->setThreshold(thr);
cf = 0;
} else
cf = 1;
filter->setROI(xmin, xmax, ymin, ymax);
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
char *buff;
// multiThreadedAnalogDetector *mt=new
// multiThreadedAnalogDetector(filter,nthreads,fifosize);
multiThreadedCountingDetector *mt =
new multiThreadedCountingDetector(filter, nthreads, fifosize);
#ifndef ANALOG
mt->setDetectorMode(ePhotonCounting);
cout << "Counting!" << endl;
if (thr > 0) {
cf = 0;
}
#endif
//{
#ifdef ANALOG
mt->setDetectorMode(eAnalog);
cout << "Analog!" << endl;
cf = 0;
// thr1=thr;
#endif
// }
mt->StartThreads();
mt->popFree(buff);
// cout << "mt " << endl;
int ifr = 0;
char froot[1000];
double *ped=new double[nx * ny];//, *ped1;
int pos,pos1;
if (pedfile) {
if (string(pedfile).find(".dat") != std::string::npos) {
pos1=string(pedfile).rfind("/");
strcpy(froot,pedfile+pos1);
pos=string(froot).find(".dat");
froot[pos]='\0';
}
cout << "PEDESTAL " << endl;
// sprintf(imgfname, "%s/pedestals.tiff", outdir);
if (string(pedfile).find(".tif") == std::string::npos) {
sprintf(fname, "%s", pedfile);
cout << fname << endl;
std::time(&end_time);
//cout << "aaa" << std::ctime(&end_time) << endl;
mt->setFrameMode(ePedestal);
// sprintf(fn,fformat,irun);
filebin.open((const char *)(fname), ios::in | ios::binary);
// //open file
if (filebin.is_open()) {
ff = -1;
while (decoder->readNextFrame(filebin, ff, np, buff)) {
// if (np == 40) {
if ((ifr+1) % 100 == 0) {
cout << " ****" << decoder->getValue(buff,20,20);// << endl;
}
mt->pushData(buff);
mt->nextThread();
mt->popFree(buff);
ifr++;
if (ifr % 100 == 0) {
cout << " ****" << ifr << " " << ff << " " << np << endl;
} //else
//cout << ifr << " " << ff << " " << np << endl;
if (ifr>=1000)
break;
ff = -1;
}
filebin.close();
while (mt->isBusy()) {
;
}
sprintf(imgfname, "%s/%s_ped.tiff", outdir, froot);
mt->writePedestal(imgfname);
sprintf(imgfname, "%s/%s_rms.tiff", outdir, froot);
mt->writePedestalRMS(imgfname);
} else
cout << "Could not open pedestal file " << fname
<< " for reading " << endl;
} else {
float *pp = ReadFromTiff(pedfile, nny, nnx);
if (pp && (int)nnx == nx && (int)nny == ny) {
for (int i = 0; i < nx * ny; i++) {
ped[i] = pp[i];
}
delete[] pp;
mt->setPedestal(ped);
cout << "Pedestal set from tiff file " << pedfile << endl;
} else {
cout << "Could not open pedestal tiff file " << pedfile
<< " for reading " << endl;
}
}
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
}
ifr = 0;
int ifile = 0;
mt->setFrameMode(eFrame);
for (int irun = runmin; irun <= runmax; irun++) {
cout << "DATA ";
// sprintf(fn,fformat,irun);
sprintf(ffname, "%s/%s.%s", indir, fformat, fext);
sprintf(fname, (const char*)ffname, irun);
sprintf(ffname, "%s/%s.tiff", outdir, fformat);
sprintf(imgfname, (const char*)ffname, irun);
sprintf(ffname, "%s/%s.clust", outdir, fformat);
sprintf(cfname, (const char*)ffname, irun);
cout << fname << " ";
cout << imgfname << endl;
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
// cout << fname << " " << outfname << " " << imgfname << endl;
filebin.open((const char *)(fname), ios::in | ios::binary);
// //open file
ifile = 0;
if (filebin.is_open()) {
if (thr <= 0 && cf != 0) { // cluster finder
if (of == NULL) {
of = fopen(cfname, "w");
if (of) {
mt->setFilePointer(of);
cout << "file pointer set " << endl;
} else {
cout << "Could not open " << cfname << " for writing "
<< endl;
mt->setFilePointer(NULL);
return 1;
}
}
}
// //while read frame
ff = -1;
ifr = 0;
while (decoder->readNextFrame(filebin, ff, np, buff)) {
// if (np == 40) {
// //push
if ((ifr+1) % 100 == 0) {
cout << " ****" << decoder->getValue(buff,20,20);// << endl;
}
mt->pushData(buff);
// // //pop
mt->nextThread();
mt->popFree(buff);
ifr++;
if (ifr % 100 == 0)
cout << " " << ifr << " " << ff << endl;
if (nframes > 0) {
if (ifr % nframes == 0) {
sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat,
ifile);
sprintf(imgfname, (const char*)ffname, irun);
mt->writeImage(imgfname, thr1);
mt->clearImage();
ifile++;
}
}
// } else
// cout << ifr << " " << ff << " " << np << endl;
ff = -1;
}
cout << "--" << endl;
filebin.close();
while (mt->isBusy()) {
;
}
if (nframes >= 0) {
if (nframes > 0) {
sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat, ifile);
sprintf(imgfname, (const char*)ffname, irun);
} else {
sprintf(ffname, "%s/%s.tiff", outdir, fformat);
sprintf(imgfname, (const char*)ffname, irun);
}
cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
mt->writeImage(imgfname, thr1);
mt->clearImage();
if (of) {
fclose(of);
of = NULL;
mt->setFilePointer(NULL);
}
}
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
} else
cout << "Could not open " << fname << " for reading " << endl;
}
if (nframes < 0) {
sprintf(ffname, "%s/%s.tiff", outdir, fformat);
strcpy(imgfname, ffname);
cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
mt->writeImage(imgfname, thr1);
}
return 0;
}

View File

@ -1,679 +0,0 @@
#include "onlinedisp_zmq.h"
bool hasallpede;
TH1F * his102;TH1F * his101;
int processedf;
sls::zmqHeader zHeader;
#define PEDEFNAME "current_pede.dat"
#define NPRO 50
#define NPRI 50
//#define JFSTRX
#ifdef JFSTRX
#include "jungfrauLGADStrixelsData.h"
#else
#include "jungfrauModuleData.h"
#endif
int main(int argc, char* argv[])
{
goout=1;
hasallpede=false;
dophotonmap=true; if ((argc<3)) {printf("USAGE: command photon_energy_(peakinADC) [rx_ip] [port] \n"); return -1 ;}
else {
phene=atoi(argv[1]);
if (phene<0) dophotonmap=false;
threshold=float (phene/2);
printf( " \n");
printf( "phene %d \n",phene);
}
if (argc>=3) {
strcpy(serverip,argv[2]);
printf("ip is %s ",serverip);
}
portnum=30001;
if (argc>=4 ){ portnum= atoi(argv[3]);
}
printf(", port number is %d ",portnum); printf(". \n");
#ifdef JFSTRX
cout << "JFSTRX" << endl;
jungfrauLGADStrixelsData *decoder = new jungfrauLGADStrixelsData();
nx = 1024/5; ny= 512*5;
#else
nx = 1024; ny= 512;
#endif
gain_flag=false;
pede_flag=false;
bw_flag=false;
HDraw_every=20;
fixranges=false;
hchptr = (short*) malloc(NCH*sizeof(short));
startsocket(); //create and connect ZMQ
for (ipx=0;ipx<NCH;ipx++) hchptr[(ipx)]=0;
// cout<< decoder->getValue((char*)(hchptr),279,130)<<endl;
nonblock(NB_ENABLE);
cout <<"opening the rootapp" <<endl;
rootapp = new TApplication("Online JF display",&argc, argv);
LoadPaletteFalse();
char hname[100];
his1000= new TH2F("his1000","2d , ev. pede corrected",nx,-0.5,nx-0.5,ny,-0.5,ny-0.5);
his1000->SetOption("colz");
his2000= new TH2F("his2000","2d gain ",nx,-0.5,nx-0.5,ny,-0.5,ny-0.5);
his2000->GetZaxis()->SetRangeUser(0,4);
if (dophotonmap) {
his3000= new TH2F("his3000"," photon map ",nx,-0.5,nx-0.5,ny,-0.5,ny-0.5);
}
else {
his3000= new TH2F("his3000"," raw adc ",nx,-0.5,nx-0.5,ny,-0.5,ny-0.5);
}
his4500= new TH2F("his45000","L vs R",101,-50,500,101,-50,500);
hchip=new TH1I*[8];
for (i=0;i<8;i++) {
sprintf(hname,"hchip%d",i);
hchip[i] = new TH1I(hname,hname,NBIN,MIN_POS,MAX_POS);
}
cout <<"end of histo booking" <<endl;
if (A2==NULL) A2 = new TCanvas("A2","Plotting Canvas gain",150,10,500,250);
if (A3==NULL) A3 = new TCanvas("A3","Plotting Canvas ADC",150,360,1200,550);
if (A4==NULL) A4 = new TCanvas("A4","Plotting Canvas PHs",750,300,1000,800);
A4->Clear();
A4->Divide(4,2,0.005,0.005);
if (A5==NULL) A5 = new TCanvas("A5","Plotting Canvas Photon Map",750,300,1000,600);
if (A6==NULL) A6 = new TCanvas("A6","Plotting Canvas LvsR",650,250,650,660);
gSystem->ProcessEvents();
int running=0;
char runc[15]="*\\-/|";
printhelp();
while (1==1) { // loop on streamed frames
if(!zmqSocket->ReceiveHeader(0,zHeader, SLS_DETECTOR_JSON_HEADER_VERSION)){
cout<< "Receiver stopped, waiting for new stream" << endl;
zmqSocket->Disconnect();
zmqSocket->Connect();
}
else {
// if (((icount++)%10)==0) cout <<"recived frameindex "<<zHeader.frameIndex <<endl;
//cout <<"there" <<endl;
zmqSocket->ReceiveData(0, (char *)(&image_data), NCH*2);
}
{
framesinstream++;
running++;
fill1Ds=true; //alway fill 1d and LR plots
//if (((framesinstream%(int(HDraw_every)))==(int (HDraw_every)-1))) {fill1Ds=true;}else{fill1Ds=false;}
if (((framesinstream%(HDraw_every))==(HDraw_every)-1)) {show2Ds=true;}else{show2Ds=false;}
if (((framesinstream%NPRI)==NPRI-1)) { cout<<"\r "<<"frame (from start): "<<framesinstream<<" " << runc[((running/NPRI)%5)]<< " discarded frames %=" << (1-float(processedf)/float(zHeader.frameIndex-frameIndex_old))*100 << " current framenumber= " <<zHeader.frameIndex << " "<<std::flush; processedf=0;frameIndex_old=zHeader.frameIndex;}
npacket=0;
if (show2Ds) {
his1000->Reset();
his2000->Reset();
if (!dophotonmap) his3000->Reset(); //FOR RAW ADC DISPLAY
}
if ((fill1Ds)or(show2Ds)or(dophotonmap)) { // do something, otherwise skip to the next
processedf++;
for (i=0 ;i<NCH;i++) {
adcvalue= (image_data[i]) & 0x3fff;
if ((image_data[i] & 0xc000)!=0){ gain = (image_data[i]>>14) & 0x3;} else {gain=0;}
if (pede_flag){
if (gain_flag)
{
if ((gain==0)||(!hasallpede)) adcpedecorr=(adcvalue&0x3fff)*fgaind[i]-fpeded[i]*fgaind[i];
if ((gain==1)&&hasallpede) adcpedecorr=(fpedeG1d[i]*fgaind[i]+G1Poffset-adcvalue*fgaind[i])*30.0;
if ((gain==3)&&hasallpede) adcpedecorr=(fpedeG2d[i]*fgaind[i]+G2Poffset-adcvalue*fgaind[i])*340.0;
}
else
{
if ((gain==0)||(!hasallpede)) adcpedecorr=(adcvalue&0x3fff)-fpeded[i];
if ((gain==1)&&hasallpede) adcpedecorr=(fpedeG1d[i]+G1Poffset-adcvalue)*30.0;
if ((gain==3)&&hasallpede) adcpedecorr=(fpedeG2d[i]+G2Poffset-adcvalue)*340.0;
}
} else {adcpedecorr=float (adcvalue);} //end of if pede
if ((adcpedecorr>threshold)&&(pede_flag)) hchptr[(i)]= hchptr[(i)]+(int)((adcpedecorr+threshold)/phene);
if (fill1Ds) {
if (((i%1024)<1004)&&((i%1024)>20)&&((i/1024)>20)) { //skip the pix near guardring for PH plots
ichip= i/(256*256*4)*4+((i/256)%4) ;
hchip[ichip]->Fill(adcpedecorr,1);
if (((i%256)<253)&&((i%256)>2)) his4500->Fill(adcpedecorrold,adcpedecorr,1);
adcpedecorrold=adcpedecorr;
}
}//if (fill1Ds)
if ((show2Ds)) {
factor=2.0;
value=adcpedecorr;
if ((i%256==0)||(i%256==255)) value=int(value/factor);
if ((i/1024==255)||(i/1024==256)||(i/1024==767)||(i/1024==768)) value=int(value/factor);
his1000->Fill(float(i%1024),float(int (i/1024)),value);
if (!dophotonmap) his3000->Fill(float(i%1024),float(int (i/1024)) ,adcvalue);
his2000->Fill(float(i%1024),float(int (i/1024)) ,gain);
value=(int)(hchptr[i]);
if ((i%256==0)||(i%256==255)) value=int(value/factor);
if ((i/1024==255)||(i/1024==256)||(i/1024==767)||(i/1024==768)) value=int(value/factor);
if (dophotonmap) his3000->Fill(float(i%1024),float(int (i/1024)),float(value));
}
}// for (i=0 ;i<NCH-0;i++)
}// /end of do something
if ((show2Ds)) {
for (ipx=0;ipx<NCH;ipx++) hchptr[(ipx)]=0;
Plot2DHistos(); Plot1DHistos();
}
ifp=kbhit();
processifp(ifp);
if (((framesinstream%NPRO))==NPRO-1) gSystem->ProcessEvents();
}
}// end of infinite loop
rootapp->Run();
nonblock(NB_DISABLE);
return 0;
}
void processifp(int ifp){
if (ifp!=0){
c=fgetc(stdin);
if (c=='s') {if (goout==0){goout=1;}else {myloop();}}
if (c=='S') SetRanges();
if (c=='+') { HDraw_every=HDraw_every*0.8;cout<< endl <<"Drawing every "<< HDraw_every<<" frames "<<endl; }
if (c=='-') { HDraw_every=HDraw_every*1.25;cout<< endl <<"Drawing every "<< HDraw_every<<" frames "<<endl;}
if (c=='G') {gain_flag=not gain_flag ;if (gain_flag) {cout<<"gain corr enab."<< endl;}else {cout<<"gain corr disab."<< endl;}}
if (c=='[') { G1Poffset=G1Poffset-10;cout<< endl <<"G1Poffset "<<G1Poffset<<endl; }
if (c==']') { G1Poffset=G1Poffset+10;cout<< endl <<"G1Poffset "<<G1Poffset<<endl; }
if (c=='{') { G2Poffset=G2Poffset-10;cout<< endl <<"G2Poffset "<<G2Poffset<<endl; }
if (c=='}') { G2Poffset=G2Poffset+10;cout<< endl <<"G2Poffset "<<G2Poffset<<endl; }
if (c=='p') { //stopsocket();
loadpede();//startsocket();
}
if (c=='b') {LoadPaletteBW(1.1111);bw_flag=true; }
if (c=='B') {LoadPaletteBW(0.9);bw_flag=true; }
if (c=='O') savepede();
if (c=='o') readpede();
if (c=='P') loadallpede();
if (c=='u') his1000->SetOption("surf2z");
if (c=='C') his1000->SetOption("colz");
if (c=='q') exit(0);
if (c=='r') historeset();
if (c=='R') axisreset();
}
}
void loadallpede(){
cout <<"not implemented "<< endl;
// hasallpede=true;
// system("./sls_detector_put setbit 0x5d 12 "); //setting to FSG1 ;
// loadpede();
// loadpede();
// for (i=0;i<NCH;i++) {fpedeG1d[i]=fpeded[i];}
// system("./sls_detector_put setbit 0x5d 13 "); //setting to FSG0 ;
// sleep(1);
// loadpede();
// loadpede();
// for (i=0;i<NCH;i++) {fpedeG2d[i]=fpeded[i];}
// system("./sls_detector_put clearbit 0x5d 12 "); //setting to G0;
// system("./sls_detector_put clearbit 0x5d 13 "); //setting to G0;
// sleep(2);
// loadpede();
// loadpede();
}
void loadpede(void){
//startsocket();
framesinstream=0;
pede_flag=true;
nframes=0;
for (ipx=0;ipx<NCH;ipx++) fpeded[ipx]=0;
while (framesinstream<50) { // loop on files
if (!zmqSocket->ReceiveHeader(0,zHeader, SLS_DETECTOR_JSON_HEADER_VERSION)){
return;
}
cout <<"received frameindex "<<zHeader.frameIndex << endl;
zmqSocket->ReceiveData(0, (char *)(&image_data), NCH*2);
framesinstream++;nframes++;
for (ipx=0;ipx<NCH;ipx++) fpeded[ipx]=(fpeded[ipx]*(nframes-1)+(float)(image_data[ipx]&0x3fff))/(float)(nframes);
}
for (ipx=0;ipx<NCH;ipx++) { ipeded[ipx]=(short)(fpeded[ipx]);
if (ipx%60033==0) printf("i=%d pede= %d %f .\n",ipx, ipeded[ipx],fpeded[ipx]);
}
printf("total frames for pede: %d \n",nframes);
//stopsocket();
printhelp();
}
int kbhit()
{
struct timeval tv;
fd_set fds;
tv.tv_sec = 0;
tv.tv_usec = 0;
FD_ZERO(&fds);
FD_SET(STDIN_FILENO, &fds); //STDIN_FILENO is 0
select(STDIN_FILENO+1, &fds, NULL, NULL, &tv);
return FD_ISSET(STDIN_FILENO, &fds);
}
void myloop(void){ //wait doing nothing.
goout=0;
int ifp;
while (goout==0){
ifp=kbhit();
processifp(ifp);
gSystem->ProcessEvents();
usleep(5000);
}
}
void printhelp(){
cout<< endl << "s=start/pause| p/n=getnewpede/raw | o/O=read/save pede | n=nopede(raw) | r/R=rst His/Axis | +/- = faster/slower ref. |q=exit | U/C sUrf2/Colz " <<endl;
}
void historeset(){
his4500->Reset();
his3000->Reset();
for (i=0;i<8;i++) {
hchip[i]->Reset();
}
Plot2DHistos();
Plot1DHistos();
}
void SetRanges() {
string str;
std::cin.clear();
//cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
cout<< endl;
cout<< " adc min " <<endl;
//getline(cin, str);
// adcmin= stoi(str);
std::cin >> adcmin;
cout<< " adc max " <<endl;
std::cin >> adcmax;
cout<< " p.map min " <<endl;
std::cin >> pmmin;
cout<< " p.map max " <<endl;
std::cin >> pmmax;
fixranges=true;
}
void axisreset(){
fixranges=false;
his1000->GetXaxis()->UnZoom();
his1000->GetYaxis()->UnZoom();
his1000->GetZaxis()->UnZoom();
his2000->GetXaxis()->UnZoom();
his2000->GetYaxis()->UnZoom();
his3000->GetZaxis()->UnZoom();
for (i=0;i<8;i++) {
hchip[i]->GetXaxis()->UnZoom();
hchip[i]->GetYaxis()->UnZoom();
}
his4500->GetXaxis()->UnZoom();
his4500->GetYaxis()->UnZoom();
his4500->GetZaxis()->UnZoom();
Plot2DHistos();
Plot1DHistos();
}
void nonblock(int state)
{
struct termios ttystate;
//get the terminal state
tcgetattr(STDIN_FILENO, &ttystate);
if (state==NB_ENABLE)
{
//turn off canonical mode
ttystate.c_lflag &= ~ICANON;
//minimum of number input read.
ttystate.c_cc[VMIN] = 1;
}
else if (state==NB_DISABLE)
{ //turn on canonical mode
ttystate.c_lflag |= ICANON;
}
//set the terminal attributes.
tcsetattr(STDIN_FILENO, TCSANOW, &ttystate);
}
void LoadPaletteFalse(){
const Int_t NRGBs = 5;
const Int_t NCont = 90;
Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
TColor::CreateGradientColorTable(NRGBs, stops, red,green, blue, NCont);
gStyle->SetNumberContours(NCont);
TColor::CreateGradientColorTable(NRGBs, stops, red,green ,blue, NCont);
gStyle->SetNumberContours(NCont);
}
void LoadPaletteBW(float gammatune){
vgamma=vgamma*gammatune;
cout<< "gamma is "<<vgamma<<endl;
const Int_t NRGBs = 99;
const Int_t NCont = 990;
Double_t stops[NRGBs] ;
Double_t red[NRGBs] ;
Double_t green[NRGBs];
Double_t blue[NRGBs] ;
for (int iRGB=0;iRGB<NRGBs;iRGB++){
stops[iRGB] =(1/float(NRGBs)*float(iRGB));
red[iRGB] = pow(stops[iRGB],vgamma);
green[iRGB] = red[iRGB];
blue[iRGB] =red[iRGB];
// cout << iRGB<<" "<< stops[iRGB] <<" " << red[iRGB]<<endl;
}
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
gStyle->SetNumberContours(NCont);
// TColor::SetPalette(52,0,1);
}
void Plot1DHistos(void){
if (hchip[0]->GetXaxis()->GetLast()!=oldh0xlast){
oldh0xlast=hchip[0]->GetXaxis()->GetLast();
oldh0xfirst=hchip[0]->GetXaxis()->GetFirst();
for (int ipad=1; ipad<8;ipad++) {
hchip[ipad]->GetXaxis()->SetRange(oldh0xfirst,oldh0xlast);
}
}
for (int ipad=0; ipad<8;ipad++) {
A4->cd(ipad+1);
gStyle->SetOptStat(1); gPad->SetLogy();
hchip[ipad%4+(1-int(ipad/4))*4]->Draw();
}
A4->cd();
A4->Update();
}
void Plot2DHistos(void){
gStyle->SetOptStat(0);
A3->cd();
// if (bw_flag) LoadPaletteBW(1.0);
if (fixranges) {
his1000->GetZaxis()->SetRangeUser(float(adcmin),float(adcmax));
his3000->GetZaxis()->SetRangeUser(float(pmmin),float(pmmax));
}
his1000->SetMinimum(-200);
his1000->Draw();
A3->Update();
A2->cd();
// if (bw_flag) LoadPaletteFalse();
his2000->GetXaxis()->SetRange(his1000->GetXaxis()->GetFirst(),his1000->GetXaxis()->GetLast());
his2000->GetYaxis()->SetRange(his1000->GetYaxis()->GetFirst(),his1000->GetYaxis()->GetLast());
his2000->Draw("colz");
A2->Update();
A5->cd();
his3000->GetXaxis()->SetRange(his1000->GetXaxis()->GetFirst(),his1000->GetXaxis()->GetLast());
his3000->GetYaxis()->SetRange(his1000->GetYaxis()->GetFirst(),his1000->GetYaxis()->GetLast());
his3000->Draw("colz");
A5->Update();
A6->cd();
his4500->Draw("colz");
A6->Update();
}
void startsocket(void) {
try {
zmqSocket = new sls::ZmqSocket(serverip, portnum);
} catch (...) {
cprintf(RED,
"Error: Could not create Zmq socket on port %d with ip %s\n",
portnum, serverip);
delete zmqSocket;
return;
}
zmqSocket->SetReceiveHighWaterMark(3);
zmqSocket->SetReceiveBuffer(1024*1024);
zmqSocket->Connect();
cout<<"Zmq Client[] "<< zmqSocket->GetZmqServerAddress()<<endl;
haveconnection=true;
}
void tryconnect(void)
{
int itry=0;
cout<< endl;
while (haveconnection==false) {
sleep(1);
cout<<"\r trying to (re)connect " <<itry++ << " " << endl ;
startsocket();
}
}
void stopsocket(void) {
// cout<<" cfd " << cfd << endl;;
delete zmqSocket;
zmqSocket=0;
//zmqSocket->~ZmqSocket ();
haveconnection=false;
}
void savepede(void) {
int pfd;
pfd=open(PEDEFNAME,O_CREAT|O_WRONLY, 0666);
if (pfd==-1) perror("open pede file");
write(pfd,fpeded,2*NCH*sizeof(float));
write(pfd,fpedeG1d,2*NCH*sizeof(float));
write(pfd,fpedeG2d,2*NCH*sizeof(float));
close(pfd);
}
void readpede(void) {
int pfd;
pfd=open(PEDEFNAME,O_RDONLY);
if (pfd==-1) perror("open pede file");
read(pfd,fpeded,NCH*2*sizeof(float));
read(pfd,fpedeG1d,NCH*2*sizeof(float));
read(pfd,fpedeG2d,NCH*2*sizeof(float));
close(pfd);
pede_flag=true;
hasallpede=true;
}

View File

@ -1,204 +0,0 @@
/**************************************************************************/
/* Header files section needs cleanup */
/**************************************************************************/
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include "sls/ZmqSocket.h"
#include "sls/tiffIO.h"
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h> /* exit() */
#include <string.h> /* memset(), memcpy() */
#include <sys/utsname.h> /* uname() */
#include <sys/types.h>
#include <sys/socket.h> /* socket(), bind(),
listen(), accept() */
#include <sys/time.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h> /* fork(), write(), close() */
#include <time.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <cmath>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <rapidjson/document.h> //json header in zmq stream
#include <omp.h>
#define NTHREADS 2
#include <chrono>
#include <cstdio>
#include <ctime> // time_t
using namespace std;
using namespace std::chrono;
using namespace sls;
#include "TCanvas.h"
#include "TH1F.h"
#include "TF1.h"
#include "TH2F.h"
#include "TMath.h"
#include "TFile.h"
#include "TStyle.h"
#include "TSystem.h"
#include "TTimer.h"
#include "TProfile.h"
#include "TColor.h"
#include <iostream>
#include <fstream>
#include <termios.h>
#include <TApplication.h>
#include <stdio.h>
#include <math.h>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <iostream>
#include "sls/ansi.h"
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x4
#define PI 3.14159265
#define FALSE 0
#define OFFSET 0
#define NBIN 500
#define MIN_POS -500.5 // 400.5
#define MAX_POS 3499.5 //-100.5
#define NCH 524288
// #define NCH 262144 in case of half_frames
char serverip[256];
int portnum;
FILE * sfilefd;
short* hchptr; // photon counted map "histogram"
int value;
float factor=1.84;
int npacket=0;
int totalnpacket=0;
float vgamma;
struct sockaddr_in serveraddr;
struct sockaddr_in clientaddr;
struct in_addr inadr;
struct hostent *server;
int i=0;
int ipx=0;
bool haveconnection;
TStyle *gStyle;
TApplication* rootapp;
TCanvas *A2;
TCanvas *A3;
TCanvas *A4;
TCanvas *A5;
TCanvas *A6;
TH1I **hchip;
TH2F **h4500chip;
short image_data[NCH*2];
short imaged[NCH*2];
float fpeded[NCH*2];
float fpedeG2d[NCH*2];
float fpedeG1d[NCH*2];
short ipeded[NCH*2];
short pcimaged[NCH*2];
float fgaind[NCH*2];
float adcpedecorr,adcpedecorrold;
bool gain_flag;
bool bw_flag;
bool fill2Ds;
bool show2Ds;
bool fill1Ds;
bool pede_flag;
bool dophotonmap;
int nx, ny;
int nframes;
int goout;
int framesinstream;
int ifp;
float threshold;
int phene;
int adcvalue;
int gain;
int ichip;
int frameIndex_old;
char pedefilename[128];
int framenum,bunchid;
TH2F* his1000;
TH2F* his2000;
TH2F* his3000;
TH2F* his4500;
TH1I* hproj;
TH1I* hchcum;
using namespace std;
void printhelp(void);
void processifp(int ifp);
void historeset(void);
void SetRanges(void);
void startsocket(void);
void stopsocket(void);
void axisreset(void);
int kbhit(void);
void myloop(void);
void loadpede(void);
void loadallpede(void);
void loadgain(void);
void nonblock(int state);
void LoadPaletteFalse(void);
void LoadPaletteBW(float);
void Plot1DHistos(void);
void Plot2DHistos(void);
void savepede(void);
void readpede(void);
int findinterpoindex(int startindex);
int findclumax(int startindex);
void tryconnect(void) ;
#define NB_ENABLE 1
#define NB_DISABLE 0
char c;
int HDraw_every;
float oldh0xfirst,oldh0xlast;
int idx;
int GXPoffset,G1Poffset,G2Poffset;
int ix,iy;
int adcmin,adcmax;
int pmmin,pmmax; //min/mnx for the photon map
bool fixranges;
sls::ZmqSocket *zmqSocket= NULL;

View File

@ -333,20 +333,20 @@ int main(int argc, char *argv[]) {
// uint32_t dynamicRange = 0;
// infinite loop
uint32_t packetNumber = 0;
uint64_t detSpec1 = 0;
uint64_t bunchId = 0;
uint64_t timestamp = 0;
int16_t modId = 0;
uint32_t expLength = 0;
uint16_t xCoord = 0;
uint16_t yCoord = 0;
// uint16_t zCoord = 0;
uint32_t detSpec3 = 0;
uint32_t debug = 0;
// uint32_t dr = 16;
// int16_t *dout;//=new int16_t [nnx*nny];
uint32_t dr = 32;
int32_t *dout = NULL; //=new int32_t [nnx*nny];
float *doutf = NULL; //=new int32_t [nnx*nny];
uint16_t detSpec4 = 0;
uint16_t roundRNumber = 0;
uint8_t detType = 0;
uint8_t version = 0;
string additionalJsonHeader = "";
@ -555,9 +555,9 @@ int main(int argc, char *argv[]) {
// zmqsocket2->SendHeaderData (0,
// false,SLS_DETECTOR_JSON_HEADER_VERSION , dr,
// fileindex, 1,1,nnx,nny,nnx*nny*dr/8,acqIndex,
// frameIndex, fname,acqIndex,0 , packetNumber,detSpec1,
// timestamp, modId,xCoord, yCoord, zCoord,detSpec3,
// detSpec4, detType, version, 0,0,
// frameIndex, fname,acqIndex,0 , packetNumber,bunchId,
// timestamp, modId,xCoord, yCoord, zCoord,debug,
// roundRNumber, detType, version, 0,0,
// 0,&additionalJsonHeader);
outHeader.data = true;
@ -574,13 +574,13 @@ int main(int argc, char *argv[]) {
outHeader.frameNumber = acqIndex;
outHeader.expLength = expLength;
outHeader.packetNumber = packetNumber;
outHeader.detSpec1 = detSpec1;
outHeader.bunchId = bunchId;
outHeader.timestamp = timestamp;
outHeader.modId = modId;
outHeader.row = xCoord;
outHeader.column = yCoord;
outHeader.detSpec3 = detSpec3;
outHeader.detSpec4 = detSpec4;
outHeader.debug = debug;
outHeader.roundRNumber = roundRNumber;
outHeader.detType = detType;
outHeader.version = version;
@ -634,11 +634,11 @@ int main(int argc, char *argv[]) {
expLength = zHeader.expLength; // doc["expLength"].GetUint();
packetNumber =
zHeader.packetNumber; // doc["packetNumber"].GetUint();
detSpec1 = zHeader.detSpec1; // doc["detSpec1"].GetUint();
bunchId = zHeader.bunchId; // doc["bunchId"].GetUint();
timestamp = zHeader.timestamp; // doc["timestamp"].GetUint();
modId = zHeader.modId; // doc["modId"].GetUint();
detSpec3 = zHeader.detSpec3; // doc["detSpec3"].GetUint();
// detSpec4=r.detSpec4;//doc["detSpec4"].GetUint();
debug = zHeader.debug; // doc["debug"].GetUint();
// roundRNumber=r.roundRNumber;//doc["roundRNumber"].GetUint();
detType = zHeader.detType; // doc["detType"].GetUint();
version = zHeader.version; // doc["version"].GetUint();
/*document["bitmode"].GetUint(); zHeader.dynamicRange
@ -815,11 +815,11 @@ int main(int argc, char *argv[]) {
// subFrameIndex = doc["expLength"].GetUint();
// detSpec1=doc["detSpec1"].GetUint();
// bunchId=doc["bunchId"].GetUint();
// timestamp=doc["timestamp"].GetUint();
packetNumber = zHeader.packetNumber; // doc["packetNumber"].GetUint();
// cout << acqIndex << " " << frameIndex << " " << subFrameIndex << "
// "<< detSpec1 << " " << timestamp << " " << packetNumber << endl;
// "<< bunchId << " " << timestamp << " " << packetNumber << endl;
// cprintf(GREEN, "frame\n");
if (packetNumber >= 40) {
//*((int*)buff)=frameIndex;
@ -902,15 +902,15 @@ int main(int argc, char *argv[]) {
// zmqsocket2->SendHeaderData (0,
// false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex,
// 1,1,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0
// , packetNumber,detSpec1, timestamp, modId,xCoord, yCoord,
// zCoord,detSpec3, detSpec4, detType, version, 0,0,
// , packetNumber,bunchId, timestamp, modId,xCoord, yCoord,
// zCoord,debug, roundRNumber, detType, version, 0,0,
// 0,&additionalJsonHeader);
// zmqsocket2->SendHeaderData (0,
// false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex,
// 1,1,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0
// , packetNumber,detSpec1, timestamp, modId,xCoord, yCoord,
// zCoord,detSpec3, detSpec4, detType, version, 0,0,
// , packetNumber,bunchId, timestamp, modId,xCoord, yCoord,
// zCoord,debug, roundRNumber, detType, version, 0,0,
// 0,&additionalJsonHeader);
outHeader.data = true;
@ -927,13 +927,13 @@ int main(int argc, char *argv[]) {
outHeader.frameNumber = acqIndex;
outHeader.expLength = expLength;
outHeader.packetNumber = packetNumber;
outHeader.detSpec1 = detSpec1;
outHeader.bunchId = bunchId;
outHeader.timestamp = timestamp;
outHeader.modId = modId;
outHeader.row = xCoord;
outHeader.column = yCoord;
outHeader.detSpec3 = detSpec3;
outHeader.detSpec4 = detSpec4;
outHeader.debug = debug;
outHeader.roundRNumber = roundRNumber;
outHeader.detType = detType;
outHeader.version = version;

View File

@ -59,7 +59,6 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
void ClonePlot();
void SavePlot();
void SetGapPixels(bool enable);
void UpdatePlot();
protected:
void resizeEvent(QResizeEvent *event);
@ -68,7 +67,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
void Zoom1DGainPlot(const QRectF &rect);
void Zoom2DGainPlot(const QRectF &rect);
void SetSaveFileName(QString val);
// void UpdatePlot();
void UpdatePlot();
signals:
void AcquireFinishedSignal();

View File

@ -5,9 +5,9 @@
#include "qVersionResolve.h"
#include "sls/logger.h"
// Suppressing warning until qwt has a fix, avoid
// patching and should be backwards compatible
// https://doc.qt.io/qt-5/qflags-obsolete.html
//Suppressing warning until qwt has a fix, avoid
//patching and should be backwards compatible
//https://doc.qt.io/qt-5/qflags-obsolete.html
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#include <qlist.h>

View File

@ -487,7 +487,6 @@ void qTabPlot::SetXYRange() {
}
plot->SetXYRangeChanged(disablezoom, xyRange, isRange);
plot->UpdatePlot();
emit DisableZoomSignal(disablezoom);
}
@ -625,7 +624,6 @@ void qTabPlot::SetZRange() {
zRange[1] = val;
}
plot->SetZRange(zRange, isZRange);
plot->UpdatePlot();
}
void qTabPlot::GetStreamingFrequency() {

View File

@ -116,9 +116,7 @@ void basictests() {
return;
}
#endif
char hversion[MAX_STR_LENGTH] = {0};
memset(hversion, 0, MAX_STR_LENGTH);
getHardwareVersion(hversion);
uint16_t hversion = getHardwareVersionNumber();
uint16_t hsnumber = getHardwareSerialNumber();
uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC();
@ -132,7 +130,7 @@ void basictests() {
sw_fw_apiversion = getFirmwareAPIVersion();
LOG(logINFOBLUE,
("**************************************************\n"
"Hardware Version:\t\t %s\n"
"Hardware Version:\t\t 0x%x\n"
"Hardware Serial Nr:\t\t 0x%x\n"
"Detector IP Addr:\t\t 0x%x\n"
@ -343,24 +341,9 @@ uint64_t getFirmwareAPIVersion() {
return ((bus_r(API_VERSION_REG) & API_VERSION_MSK) >> API_VERSION_OFST);
}
void getHardwareVersion(char *version) {
strcpy(version, "unknown");
int hwversion = getHardwareVersionNumber();
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
const char *hwNamesList[] = HARDWARE_VERSION_NAMES;
for (int i = 0; i != NUM_HARDWARE_VERSIONS; ++i) {
LOG(logDEBUG, ("0x%x %d 0x%x %s\n", hwversion, i, hwNumberList[i],
hwNamesList[i]));
if (hwNumberList[i] == hwversion) {
strcpy(version, hwNamesList[i]);
return;
}
}
}
uint16_t getHardwareVersionNumber() {
#ifdef VIRTUAL
return 0x3f;
return 0;
#endif
return ((bus_r(MOD_SERIAL_NUMBER_REG) & MOD_SERIAL_NUMBER_VRSN_MSK) >>
MOD_SERIAL_NUMBER_VRSN_OFST);
@ -2066,7 +2049,7 @@ void *start_timer(void *arg) {
// set header
sls_detector_header *header = (sls_detector_header *)(packetData);
header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION;
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->frameNumber = frameNr + iframes;
header->packetNumber = i;
header->modId = 0;

View File

@ -5,92 +5,12 @@
#include "sls/sls_detector_defs.h"
#define MIN_REQRD_VRSN_T_RD_API 0x181130
#define REQRD_FRMWR_VRSN 0x221205
#define NUM_HARDWARE_VERSIONS (1)
#define HARDWARE_VERSION_NUMBERS \
{ 0x3f }
#define HARDWARE_VERSION_NAMES \
{ "5.1" }
#define REQRD_FRMWR_VRSN 0x220825
#define LINKED_SERVER_NAME "ctbDetectorServer"
#define CTRL_SRVR_INIT_TIME_US (2 * 1000 * 1000)
/* Hardware Definitions */
#define NCHAN (36)
#define NCHAN_ANALOG (32)
#define NCHAN_DIGITAL (64)
#define NCHIP (1)
#define NDAC (24)
#define NPWR (6)
#define NDAC_ONLY (NDAC - NPWR)
#define DYNAMIC_RANGE (16)
#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
#define CLK_FREQ (156.25) // MHz
#define I2C_POWER_VIO_DEVICE_ID (0x40)
#define I2C_POWER_VA_DEVICE_ID (0x41)
#define I2C_POWER_VB_DEVICE_ID (0x42)
#define I2C_POWER_VC_DEVICE_ID (0x43)
#define I2C_POWER_VD_DEVICE_ID (0x44)
#define I2C_SHUNT_RESISTER_OHMS (0.005)
/** Default Parameters */
#define DEFAULT_DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
#define DEFAULT_STARTING_FRAME_NUMBER (1)
#define DEFAULT_NUM_SAMPLES (1)
#define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_EXPTIME (0)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_PERIOD (1 * 1000 * 1000) // ns
#define DEFAULT_DELAY (0)
#define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_VLIMIT (-100)
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_TX_UDP_PORT (0x7e9a)
#define DEFAULT_RUN_CLK (200) // 40
#define DEFAULT_ADC_CLK (40) // 20
#define DEFAULT_SYNC_CLK (40) // 20
#define DEFAULT_DBIT_CLK (200)
#define UDP_HEADER_MAX_FRAME_VALUE (0xFFFFFFFFFFFF)
#define HIGHVOLTAGE_MIN (60)
#define HIGHVOLTAGE_MAX (200) // min dac val
#define DAC_MIN_MV (0)
#define DAC_MAX_MV (2500)
#define VCHIP_MIN_MV (1673)
#define VCHIP_MAX_MV (2668) // min dac val
#define POWER_RGLTR_MIN (636)
#define POWER_RGLTR_MAX \
(2638) // min dac val (not vchip-max) because of dac conversions
#define VCHIP_POWER_INCRMNT (200)
#define VIO_MIN_MV (1200) // for fpga to function
/* Defines in the Firmware */
#define DIGITAL_IO_DELAY_MAXIMUM_PS \
((OUTPUT_DELAY_0_OTPT_STTNG_MSK >> OUTPUT_DELAY_0_OTPT_STTNG_OFST) * \
OUTPUT_DELAY_0_OTPT_STTNG_STEPS)
#define MAX_PHASE_SHIFTS_STEPS (8)
#define WAIT_TME_US_FR_ACQDONE_REG \
(100) // wait time in us after acquisition done to ensure there is no data
// in fifo
#define WAIT_TIME_US_PLL (10 * 1000)
#define WAIT_TIME_US_STP_ACQ (100)
#define WAIT_TIME_CONFIGURE_MAC (2 * 1000 * 1000)
#define WAIT_TIME_PATTERN_READ (10)
#define WAIT_TIME_1US_FOR_LOOP_CNT (50) // around 30 is 1 us in blackfin
/* MSB & LSB DEFINES */
#define MSB_OF_64_BIT_REG_OFST (32)
#define LSB_OF_64_BIT_REG_OFST (0)
#define BIT32_MSK (0xFFFFFFFF)
#define BIT16_MASK (0xFFFF)
#define MAXIMUM_ADC_CLK (65)
#define PLL_VCO_FREQ_MHZ (800)
/* Struct Definitions */
typedef struct udp_header_struct {
uint32_t udp_destmac_msb;
@ -168,3 +88,77 @@ enum DACINDEX {
};
enum CLKINDEX { RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS };
#define CLK_NAMES "run", "adc", "sync", "dbit"
/* Hardware Definitions */
#define NCHAN (36)
#define NCHAN_ANALOG (32)
#define NCHAN_DIGITAL (64)
#define NCHIP (1)
#define NDAC (24)
#define NPWR (6)
#define NDAC_ONLY (NDAC - NPWR)
#define DYNAMIC_RANGE (16)
#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
#define CLK_FREQ (156.25) // MHz
#define I2C_POWER_VIO_DEVICE_ID (0x40)
#define I2C_POWER_VA_DEVICE_ID (0x41)
#define I2C_POWER_VB_DEVICE_ID (0x42)
#define I2C_POWER_VC_DEVICE_ID (0x43)
#define I2C_POWER_VD_DEVICE_ID (0x44)
#define I2C_SHUNT_RESISTER_OHMS (0.005)
/** Default Parameters */
#define DEFAULT_DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
#define DEFAULT_STARTING_FRAME_NUMBER (1)
#define DEFAULT_NUM_SAMPLES (1)
#define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_EXPTIME (0)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_PERIOD (1 * 1000 * 1000) // ns
#define DEFAULT_DELAY (0)
#define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_VLIMIT (-100)
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_TX_UDP_PORT (0x7e9a)
#define DEFAULT_RUN_CLK (200) // 40
#define DEFAULT_ADC_CLK (40) // 20
#define DEFAULT_SYNC_CLK (40) // 20
#define DEFAULT_DBIT_CLK (200)
#define UDP_HEADER_MAX_FRAME_VALUE (0xFFFFFFFFFFFF)
#define HIGHVOLTAGE_MIN (60)
#define HIGHVOLTAGE_MAX (200) // min dac val
#define DAC_MIN_MV (0)
#define DAC_MAX_MV (2500)
#define VCHIP_MIN_MV (1673)
#define VCHIP_MAX_MV (2668) // min dac val
#define POWER_RGLTR_MIN (636)
#define POWER_RGLTR_MAX \
(2638) // min dac val (not vchip-max) because of dac conversions
#define VCHIP_POWER_INCRMNT (200)
#define VIO_MIN_MV (1200) // for fpga to function
/* Defines in the Firmware */
#define DIGITAL_IO_DELAY_MAXIMUM_PS \
((OUTPUT_DELAY_0_OTPT_STTNG_MSK >> OUTPUT_DELAY_0_OTPT_STTNG_OFST) * \
OUTPUT_DELAY_0_OTPT_STTNG_STEPS)
#define MAX_PHASE_SHIFTS_STEPS (8)
#define WAIT_TME_US_FR_ACQDONE_REG \
(100) // wait time in us after acquisition done to ensure there is no data
// in fifo
#define WAIT_TIME_US_PLL (10 * 1000)
#define WAIT_TIME_US_STP_ACQ (100)
#define WAIT_TIME_CONFIGURE_MAC (2 * 1000 * 1000)
#define WAIT_TIME_PATTERN_READ (10)
#define WAIT_TIME_1US_FOR_LOOP_CNT (50) // around 30 is 1 us in blackfin
/* MSB & LSB DEFINES */
#define MSB_OF_64_BIT_REG_OFST (32)
#define LSB_OF_64_BIT_REG_OFST (0)
#define BIT32_MSK (0xFFFFFFFF)
#define BIT16_MASK (0xFFFF)
#define MAXIMUM_ADC_CLK (65)
#define PLL_VCO_FREQ_MHZ (800)

View File

@ -1106,9 +1106,7 @@ int Beb_SetDetectorPosition(int pos[]) {
int posRight[2] = {Beb_top ? pos[X] + 1 : pos[X], pos[Y]};
if (Beb_quadEnable) {
posLeft[Y] = 1; // left is next row
posLeft[X] = 0; // left same first row
posRight[Y] = 0; // right same first row
posRight[Y] = 1; // right is next row
posRight[X] = 0; // right same first column
}

View File

@ -25,7 +25,7 @@ target_include_directories(eigerDetectorServer_virtual
)
target_compile_definitions(eigerDetectorServer_virtual
PUBLIC EIGERD PCCOMPILE STOP_SERVER #TEST_MOD_GEOMETRY
PUBLIC EIGERD PCCOMPILE STOP_SERVER
PUBLIC VIRTUAL #VIRTUAL_9M
)

View File

@ -1240,16 +1240,19 @@ int Feb_Control_GetDynamicRange(int *retval) {
int Feb_Control_Disable16bitConversion(int disable) {
LOG(logINFO, ("%s 16 bit expansion\n", disable ? "Disabling" : "Enabling"));
uint32_t bitmask = DAQ_REG_HRDWRE_DSBL_16BIT_MSK;
unsigned int regval = 0;
if (!Feb_Control_ReadRegister(DAQ_REG_HRDWRE, &regval)) {
LOG(logERROR, ("Could not %s 16 bit expansion (bit mode)\n",
(disable ? "disable" : "enable")));
return 0;
}
if (disable) {
regval |= bitmask;
regval |= DAQ_REG_HRDWRE_DSBL_16BIT_MSK;
} else {
regval &= ~bitmask;
regval &= ~DAQ_REG_HRDWRE_DSBL_16BIT_MSK;
}
if (!Feb_Control_WriteRegister_BitMask(DAQ_REG_HRDWRE, regval, bitmask)) {
if (!Feb_Control_WriteRegister(DAQ_REG_HRDWRE, regval)) {
LOG(logERROR, ("Could not %s 16 bit expansion (bit mode)\n",
(disable ? "disable" : "enable")));
return 0;
@ -1259,12 +1262,11 @@ int Feb_Control_Disable16bitConversion(int disable) {
int Feb_Control_Get16bitConversionDisabled(int *ret) {
unsigned int regval = 0;
if (!Feb_Control_ReadRegister_BitMask(DAQ_REG_HRDWRE, &regval,
DAQ_REG_HRDWRE_DSBL_16BIT_MSK)) {
if (!Feb_Control_ReadRegister(DAQ_REG_HRDWRE, &regval)) {
LOG(logERROR, ("Could not get 16 bit expansion (bit mode)\n"));
return 0;
}
if (regval) {
if (regval & DAQ_REG_HRDWRE_DSBL_16BIT_MSK) {
*ret = 1;
} else {
*ret = 0;
@ -1665,15 +1667,6 @@ int Feb_Control_GetReadNRows() {
}
int Feb_Control_WriteRegister(uint32_t offset, uint32_t data) {
return Feb_Control_WriteRegister_BitMask(offset, data, BIT32_MSK);
}
int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval) {
return Feb_Control_ReadRegister_BitMask(offset, retval, BIT32_MASK);
}
int Feb_Control_WriteRegister_BitMask(uint32_t offset, uint32_t data,
uint32_t bitmask) {
uint32_t actualOffset = offset;
char side[2][10] = {"right", "left"};
unsigned int addr[2] = {Feb_Control_rightAddress, Feb_Control_leftAddress};
@ -1697,41 +1690,24 @@ int Feb_Control_WriteRegister_BitMask(uint32_t offset, uint32_t data,
for (int iloop = 0; iloop < 2; ++iloop) {
if (run[iloop]) {
LOG(logDEBUG1, ("Writing 0x%x to %s 0x%x (mask:0x%x)\n", data,
side[iloop], actualOffset, bitmask));
uint32_t writeVal = 0;
if (!Feb_Interface_ReadRegister(addr[iloop], actualOffset,
&writeVal)) {
LOG(logERROR, ("Could not read %s addr 0x%x register\n",
LOG(logDEBUG1,
("Writing 0x%x to %s 0x%x\n", data, side[iloop], actualOffset));
if (!Feb_Interface_WriteRegister(addr[iloop], actualOffset, data, 0,
0)) {
LOG(logERROR, ("Could not write 0x%x to %s addr 0x%x\n", data,
side[iloop], actualOffset));
return 0;
}
// set only the bits in the mask
writeVal &= ~(bitmask);
writeVal |= (data & bitmask);
LOG(logDEBUG1, ("writing 0x%x to 0x%x\n", writeVal, actualOffset));
if (!Feb_Interface_WriteRegister(addr[iloop], actualOffset,
writeVal, 0, 0)) {
LOG(logERROR, ("Could not write 0x%x to %s addr 0x%x\n",
writeVal, side[iloop], actualOffset));
return 0;
}
writeVal &= bitmask;
uint32_t readVal = 0;
uint32_t regVal = 0;
if (!Feb_Interface_ReadRegister(addr[iloop], actualOffset,
&readVal)) {
&regVal)) {
LOG(logERROR, ("Could not read %s register\n", addr[iloop]));
return 0;
}
readVal &= bitmask;
if (writeVal != readVal) {
if (regVal != data) {
LOG(logERROR,
("Could not write %s addr 0x%x register. Wrote "
"0x%x, read 0x%x (mask:0x%x)\n",
side[iloop], actualOffset, writeVal, readVal, bitmask));
("Could not write %s register. Write 0x%x, read 0x%x\n",
addr[iloop], data, regVal));
return 0;
}
}
@ -1740,8 +1716,7 @@ int Feb_Control_WriteRegister_BitMask(uint32_t offset, uint32_t data,
return 1;
}
int Feb_Control_ReadRegister_BitMask(uint32_t offset, uint32_t *retval,
uint32_t bitmask) {
int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval) {
uint32_t actualOffset = offset;
char side[2][10] = {"right", "left"};
unsigned int addr[2] = {Feb_Control_rightAddress, Feb_Control_leftAddress};
@ -1771,9 +1746,8 @@ int Feb_Control_ReadRegister_BitMask(uint32_t offset, uint32_t *retval,
side[iloop], actualOffset));
return 0;
}
value[iloop] &= bitmask;
LOG(logDEBUG1, ("Read 0x%x from %s 0x%x (mask:0x%x)\n",
value[iloop], side[iloop], actualOffset, bitmask));
LOG(logDEBUG1, ("Read 0x%x from %s 0x%x\n", value[iloop],
side[iloop], actualOffset));
*retval = value[iloop];
// if not the other (left, not right OR right, not left), return the
// value
@ -1784,7 +1758,7 @@ int Feb_Control_ReadRegister_BitMask(uint32_t offset, uint32_t *retval,
}
// Inconsistent values when reading both registers
if ((run[0] & run[1]) & (value[0] != value[1])) {
LOG(logERROR, ("Inconsistent values read from %s: 0x%x and %s: 0x%x\n",
LOG(logERROR, ("Inconsistent values read from %s 0x%x and %s 0x%x\n",
side[0], value[0], side[1], value[1]));
return 0;
}

View File

@ -95,10 +95,7 @@ int Feb_Control_SetReadNRows(int value);
int Feb_Control_GetReadNRows();
int Feb_Control_WriteRegister(uint32_t offset, uint32_t data);
int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval);
int Feb_Control_WriteRegister_BitMask(uint32_t offset, uint32_t data,
uint32_t bitmask);
int Feb_Control_ReadRegister_BitMask(uint32_t offset, uint32_t *retval,
uint32_t bitmask);
// pulsing
int Feb_Control_Pulse_Pixel(int npulses, int x, int y);
int Feb_Control_PulsePixelNMove(int npulses, int inc_x_pos, int inc_y_pos);

View File

@ -861,15 +861,12 @@ int setDynamicRange(int dr) {
LOG(logINFO, ("Setting dynamic range: %d\n", dr));
#else
sharedMemory_lockLocalLink();
if (!Feb_Control_SetDynamicRange(dr)) {
LOG(logERROR, ("Could not set dynamic range in feb\n"));
sharedMemory_unlockLocalLink();
return FAIL;
}
if (!Beb_SetUpTransferParameters(dr)) {
LOG(logERROR, ("Could not set bit mode in the back end\n"));
sharedMemory_unlockLocalLink();
return eiger_dynamicrange;
if (Feb_Control_SetDynamicRange(dr)) {
if (!Beb_SetUpTransferParameters(dr)) {
LOG(logERROR, ("Could not set bit mode in the back end\n"));
sharedMemory_unlockLocalLink();
return eiger_dynamicrange;
}
}
sharedMemory_unlockLocalLink();
#endif
@ -2667,10 +2664,6 @@ void *start_timer(void *arg) {
header->modId = eiger_virtual_module_id;
header->row = row;
header->column = colLeft;
if (eiger_virtual_quad_mode) {
header->row = 1; // left is next row
header->column = 0; // left same first column
}
char packetData2[packetsize];
memset(packetData2, 0, packetsize);
@ -2679,11 +2672,11 @@ void *start_timer(void *arg) {
header->version = SLS_DETECTOR_HEADER_VERSION;
header->frameNumber = frameNr + iframes;
header->packetNumber = i;
header->modId = eiger_virtual_module_id + 1;
header->modId = eiger_virtual_module_id;
header->row = row;
header->column = colRight;
if (eiger_virtual_quad_mode) {
header->row = 0; // right is next row
header->row = 1; // right is next row
header->column = 0; // right same first column
}

View File

@ -137,7 +137,6 @@ enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
#define UDP_HEADER_MAX_FRAME_VALUE (0xFFFFFFFFFFFF)
#define BIT16_MASK (0xFFFF)
#define BIT32_MSK (0xFFFFFFFF)
#define DAC_MIN_MV (0)
#define DAC_MAX_MV (2048)

View File

@ -113,9 +113,7 @@ void basictests() {
return;
}
#endif
char hversion[MAX_STR_LENGTH] = {0};
memset(hversion, 0, MAX_STR_LENGTH);
getHardwareVersion(hversion);
uint16_t hversion = getHardwareVersionNumber();
uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC();
int64_t fwversion = getFirmwareVersion();
@ -127,7 +125,7 @@ void basictests() {
LOG(logINFOBLUE,
("**************************************************\n"
"Hardware Version:\t\t %s\n"
"Hardware Version:\t\t 0x%x\n"
"Detector IP Addr:\t\t 0x%x\n"
"Detector MAC Addr:\t\t 0x%llx\n\n"
@ -269,34 +267,14 @@ u_int64_t getFirmwareAPIVersion() {
return ((bus_r(API_VERSION_REG) & API_VERSION_MSK) >> API_VERSION_OFST);
}
void getHardwareVersion(char *version) {
strcpy(version, "unknown");
int hwversion = getHardwareVersionNumber();
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
const char *hwNamesList[] = HARDWARE_VERSION_NAMES;
for (int i = 0; i != NUM_HARDWARE_VERSIONS; ++i) {
LOG(logDEBUG, ("0x%x %d 0x%x %s\n", hwversion, i, hwNumberList[i],
hwNamesList[i]));
if (hwNumberList[i] == hwversion) {
strcpy(version, hwNamesList[i]);
return;
}
}
}
u_int16_t getHardwareVersionNumber() {
#ifdef VIRTUAL
return 0x2;
return 0;
#endif
return ((bus_r(MCB_SERIAL_NO_REG) & MCB_SERIAL_NO_VRSN_MSK) >>
MCB_SERIAL_NO_VRSN_OFST);
}
int isHardwareVersion_1_0() {
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
return ((getHardwareVersionNumber() == hwNumberList[0]) ? 1 : 0);
}
u_int32_t getDetectorNumber() {
#ifdef VIRTUAL
return 0;
@ -3334,7 +3312,7 @@ void *start_timer(void *arg) {
// set header
sls_detector_header *header = (sls_detector_header *)(packetData);
header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION;
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->frameNumber = virtual_currentFrameNumber;
header->packetNumber = 0;
header->modId = virtual_moduleid;

View File

@ -3,15 +3,10 @@
#pragma once
#include "sls/sls_detector_defs.h"
#define REQRD_FRMWRE_VRSN (0x221123)
#define REQRD_FRMWRE_VRSN (0x220901)
#define KERNEL_DATE_VRSN "Mon May 10 18:00:21 CEST 2021"
#define ID_FILE "detid_gotthard2.txt"
#define NUM_HARDWARE_VERSIONS (2)
#define HARDWARE_VERSION_NUMBERS {0x0, 0x2};
#define HARDWARE_VERSION_NAMES \
{ "1.0", "1.2" }
#define LINKED_SERVER_NAME "gotthard2DetectorServer"
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)

View File

@ -103,9 +103,7 @@ void basictests() {
return;
}
#endif
char hversion[MAX_STR_LENGTH] = {0};
memset(hversion, 0, MAX_STR_LENGTH);
getHardwareVersion(hversion);
uint32_t boardrev = getBoardRevision();
uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC();
int64_t fwversion = getFirmwareVersion();
@ -115,7 +113,7 @@ void basictests() {
LOG(logINFOBLUE,
("**************************************************\n"
"Hardware Revision : %s\n"
"Board Revision : 0x%x\n"
"Detector IP Addr : 0x%x\n"
"Detector MAC Addr : 0x%llx\n\n"
@ -123,7 +121,7 @@ void basictests() {
"Firmware Version : 0x%llx\n"
"Software Version : %s\n"
"********************************************************\n",
hversion,
boardrev,
ipadd, (long long unsigned int)macadd,
@ -337,34 +335,14 @@ u_int32_t getDetectorIP() {
return res;
}
void getHardwareVersion(char *version) {
strcpy(version, "unknown");
int hwversion = getHardwareVersionNumber();
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
const char *hwNamesList[] = HARDWARE_VERSION_NAMES;
for (int i = 0; i != NUM_HARDWARE_VERSIONS; ++i) {
LOG(logDEBUG, ("0x%x %d 0x%x %s\n", hwversion, i, hwNumberList[i],
hwNamesList[i]));
if (hwNumberList[i] == hwversion) {
strcpy(version, hwNamesList[i]);
return;
}
}
}
u_int16_t getHardwareVersionNumber() {
u_int32_t getBoardRevision() {
#ifdef VIRTUAL
return 0x2;
return 0;
#endif
return ((bus_r(BOARD_REVISION_REG) & BOARD_REVISION_MSK) >>
BOARD_REVISION_OFST);
}
int isHardwareVersion_1_0() {
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
return ((getHardwareVersionNumber() == hwNumberList[0]) ? 1 : 0);
}
/* initialization */
void initControlServer() {
@ -416,7 +394,7 @@ void setupDetector() {
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
// adc
if (isHardwareVersion_1_0()) {
if (getBoardRevision() == 1) {
AD9252_SetDefines(ADC_SPI_REG, ADC_SPI_SRL_CS_OTPT_MSK,
ADC_SPI_SRL_CLK_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_MSK,
ADC_SPI_SRL_DT_OTPT_OFST);
@ -601,7 +579,7 @@ void setDAQRegister() {
// 0x1f16(board rev 1) 0x1f0f(board rev 2)
u_int32_t tokenTiming =
((isHardwareVersion_1_0()) ? DAQ_TKN_TMNG_BRD_RVSN_1_VAL
((getBoardRevision() == 1) ? DAQ_TKN_TMNG_BRD_RVSN_1_VAL
: DAQ_TKN_TMNG_BRD_RVSN_2_VAL);
// 0x13f(no roi), 0x7f(roi)
@ -1007,9 +985,7 @@ int setDelayAfterTrigger(int64_t val) {
// validate for tolerance
int64_t retval = getDelayAfterTrigger();
val /= (1E-9 * CLK_FREQ);
if (master) {
val -= masterdefaultdelay;
}
val -= masterdefaultdelay;
if (val != retval) {
return FAIL;
}

View File

@ -4,12 +4,6 @@
#include "sls/sls_detector_defs.h"
#include <stdlib.h>
#define NUM_HARDWARE_VERSIONS (2)
#define HARDWARE_VERSION_NUMBERS \
{ 0x1, 0x2 }
#define HARDWARE_VERSION_NAMES \
{ "1.0", "2.0" }
#define LINKED_SERVER_NAME "gotthardDetectorServer"
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)

View File

@ -42,4 +42,3 @@ install(TARGETS jungfrauDetectorServer_virtual
)
configure_file(config_jungfrau.txt ${CMAKE_BINARY_DIR}/bin/config_jungfrau.txt COPYONLY)
configure_file(detid_jungfrau.txt ${CMAKE_BINARY_DIR}/bin/detid_jungfrau.txt COPYONLY)

View File

@ -37,7 +37,6 @@ $(PROGS): $(OBJS)
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
mv $(PROGS) $(DESTDIR)
cp config_jungfrau.txt $(DESTDIR)
cp detid_jungfrau.txt $(DESTDIR)
rm *.gdb
rm $(main_src)*.o $(md5_dir)*.o

View File

@ -61,6 +61,7 @@
#define HARDWARE_SERIAL_NUM_MSK (0x000000FF << HARDWARE_SERIAL_NUM_OFST)
#define HARDWARE_VERSION_NUM_OFST (16)
#define HARDWARE_VERSION_NUM_MSK (0x0000003F << HARDWARE_VERSION_NUM_OFST)
#define HARDWARE_VERSION_2_VAL ((0x2 << HARDWARE_VERSION_NUM_OFST) & HARDWARE_VERSION_NUM_MSK)
/* API Version Register */
#define API_VERSION_REG (0x0F << MEM_MAP_SHIFT)
@ -439,11 +440,13 @@ Time before end of exposure when comparator is disabled */
#define COORD_COL_INNER_OFST (16)
#define COORD_COL_INNER_MSK (0x0000FFFF << COORD_COL_INNER_OFST)
/** Module ID coordinates */
#define MOD_ID_REG (0x7E << MEM_MAP_SHIFT)
/** Module column coordinates */
#define COORD_RESERVED_REG (0x7E << MEM_MAP_SHIFT)
#define MOD_ID_OFST (0)
#define MOD_ID_MSK (0x0000FFFF << MOD_ID_OFST)
#define COORD_RESERVED_OUTER_OFST (0)
#define COORD_RESERVED_OUTER_MSK (0x0000FFFF << COORD_RESERVED_OUTER_OFST)
#define COORD_RESERVED_INNER_OFST (16)
#define COORD_RESERVED_INNER_MSK (0x0000FFFF << COORD_RESERVED_INNER_OFST)
/* ASIC Control Register */
#define ASIC_CTRL_REG (0x7F << MEM_MAP_SHIFT)

View File

@ -42,7 +42,6 @@ char initErrorMessage[MAX_STR_LENGTH];
#ifdef VIRTUAL
pthread_t pthread_virtual_tid;
int virtual_image_test_mode = 0;
int virtual_moduleid = 0;
#endif
enum detectorSettings thisSettings = UNINITIALIZED;
@ -98,9 +97,7 @@ void basictests() {
return;
}
#endif
char hversion[MAX_STR_LENGTH] = {0};
memset(hversion, 0, MAX_STR_LENGTH);
getHardwareVersion(hversion);
uint16_t hversion = getHardwareVersionNumber();
uint16_t hsnumber = getHardwareSerialNumber();
uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC();
@ -110,15 +107,14 @@ void basictests() {
getServerVersion(swversion);
int64_t sw_fw_apiversion = 0;
uint32_t requiredFirmwareVersion =
(isHardwareVersion_1_0() ? REQRD_FRMWRE_VRSN_BOARD2
: REQRD_FRMWRE_VRSN);
(isHardwareVersion2() ? REQRD_FRMWRE_VRSN_BOARD2 : REQRD_FRMWRE_VRSN);
if (fwversion >= MIN_REQRD_VRSN_T_RD_API)
sw_fw_apiversion = getFirmwareAPIVersion();
LOG(logINFOBLUE,
("************ Jungfrau Server *********************\n"
"Hardware Version:\t\t %s\n"
"Hardware Version:\t\t 0x%x\n"
"Hardware Serial Nr:\t\t 0x%x\n"
"Detector IP Addr:\t\t 0x%x\n"
@ -277,24 +273,9 @@ u_int64_t getFirmwareAPIVersion() {
return ((bus_r(API_VERSION_REG) & API_VERSION_MSK) >> API_VERSION_OFST);
}
void getHardwareVersion(char *version) {
strcpy(version, "unknown");
int hwversion = getHardwareVersionNumber();
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
const char *hwNamesList[] = HARDWARE_VERSION_NAMES;
for (int i = 0; i != NUM_HARDWARE_VERSIONS; ++i) {
LOG(logDEBUG, ("0x%x %d 0x%x %s\n", hwversion, i, hwNumberList[i],
hwNamesList[i]));
if (hwNumberList[i] == hwversion) {
strcpy(version, hwNamesList[i]);
return;
}
}
}
u_int16_t getHardwareVersionNumber() {
#ifdef VIRTUAL
return 0x3;
return 0;
#endif
return ((bus_r(MOD_SERIAL_NUM_REG) & HARDWARE_VERSION_NUM_MSK) >>
HARDWARE_VERSION_NUM_OFST);
@ -308,9 +289,15 @@ u_int16_t getHardwareSerialNumber() {
HARDWARE_SERIAL_NUM_OFST);
}
int isHardwareVersion_1_0() {
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
return ((getHardwareVersionNumber() == hwNumberList[0]) ? 1 : 0);
// is board 1.0?, with value 2 (resistor network)
int isHardwareVersion2() {
#ifdef VIRTUAL
return 0;
#endif
return (((bus_r(MOD_SERIAL_NUM_REG) & HARDWARE_VERSION_NUM_MSK) ==
HARDWARE_VERSION_2_VAL)
? 1
: 0);
}
int getChipVersion() {
@ -339,29 +326,6 @@ u_int32_t getDetectorNumber() {
return bus_r(MOD_SERIAL_NUM_REG);
}
int getModuleId(int *ret, char *mess) {
return ((bus_r(MOD_ID_REG) & MOD_ID_MSK) >> MOD_ID_OFST);
}
void setModuleId(int modid) {
LOG(logINFOBLUE, ("Setting module id in fpga: %d\n", modid));
bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) & ~MOD_ID_MSK);
bus_w(MOD_ID_REG,
bus_r(MOD_ID_REG) | ((modid << MOD_ID_OFST) & MOD_ID_MSK));
}
int updateModuleId() {
int modid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
if (initError == FAIL) {
return FAIL;
}
#ifdef VIRTUAL
virtual_moduleid = modid;
#endif
setModuleId(modid);
return OK;
}
u_int64_t getDetectorMAC() {
#ifdef VIRTUAL
return 0;
@ -505,10 +469,6 @@ void setupDetector() {
return;
}
if (updateModuleId() == FAIL) {
return;
}
setReadoutSpeed(HALF_SPEED);
cleanFifos();
resetCore();
@ -516,8 +476,8 @@ void setupDetector() {
alignDeserializer();
configureASICTimer();
bus_w(ADC_PORT_INVERT_REG,
(isHardwareVersion_1_0() ? ADC_PORT_INVERT_BOARD2_VAL
: ADC_PORT_INVERT_VAL));
(isHardwareVersion2() ? ADC_PORT_INVERT_BOARD2_VAL
: ADC_PORT_INVERT_VAL));
initReadoutConfiguration();
@ -549,7 +509,7 @@ void setupDetector() {
setFilterResistor(DEFAULT_FILTER_RESISTOR);
setNumberOfFilterCells(DEFAULT_FILTER_CELL);
}
if (!isHardwareVersion_1_0()) {
if (!isHardwareVersion2()) {
setFlipRows(DEFAULT_FLIP_ROWS);
setReadNRows(MAX_ROWS_PER_READOUT);
}
@ -788,11 +748,11 @@ int readConfigFile() {
version, line);
break;
}
// chipversion 1.1 and HW 1.0 is incompatible
if (version == 11 && isHardwareVersion_1_0()) {
// version 1.1 and HW 1.0 (version reg value = 2) is incompatible
if (version == 11 && isHardwareVersion2()) {
strcpy(initErrorMessage,
"Chip version 1.1 (from on-board config file) is "
"incompatible with hardware version v1.0. Please update "
"incompatible with old board (v1.0). Please update "
"board or correct on-board config file.\n");
break;
}
@ -867,9 +827,8 @@ int getDynamicRange(int *retval) {
void setADCInvertRegister(uint32_t val) {
LOG(logINFO, ("Setting ADC Port Invert Reg to 0x%x\n", val));
uint32_t defaultValue =
(isHardwareVersion_1_0() ? ADC_PORT_INVERT_BOARD2_VAL
: ADC_PORT_INVERT_VAL);
uint32_t defaultValue = (isHardwareVersion2() ? ADC_PORT_INVERT_BOARD2_VAL
: ADC_PORT_INVERT_VAL);
uint32_t changeValue = defaultValue ^ val;
LOG(logINFO, ("\t default: 0x%x, final:0x%x\n", defaultValue, changeValue));
bus_w(ADC_PORT_INVERT_REG, changeValue);
@ -877,8 +836,8 @@ void setADCInvertRegister(uint32_t val) {
uint32_t getADCInvertRegister() {
uint32_t readValue = bus_r(ADC_PORT_INVERT_REG);
int32_t defaultValue = (isHardwareVersion_1_0() ? ADC_PORT_INVERT_BOARD2_VAL
: ADC_PORT_INVERT_VAL);
int32_t defaultValue = (isHardwareVersion2() ? ADC_PORT_INVERT_BOARD2_VAL
: ADC_PORT_INVERT_VAL);
uint32_t val = defaultValue ^ readValue;
LOG(logDEBUG1, ("\tread:0x%x, default:0x%x returned:0x%x\n", readValue,
defaultValue, val));
@ -1792,9 +1751,9 @@ int setReadNRows(int value) {
LOG(logERROR, ("Invalid number of rows %d\n", value));
return FAIL;
}
if (isHardwareVersion_1_0()) {
if (isHardwareVersion2()) {
LOG(logERROR, ("Could not set number of rows. Only available for "
"Hardware Board version v2.0.\n"));
"Hardware Board version 2.0.\n"));
return FAIL;
}
@ -1817,7 +1776,7 @@ int setReadNRows(int value) {
int getReadNRows() {
// cannot set it in old board
if (isHardwareVersion_1_0()) {
if (isHardwareVersion2()) {
return MAX_ROWS_PER_READOUT;
}
int enable = (bus_r(READ_N_ROWS_REG) & READ_N_ROWS_ENBL_MSK);
@ -1990,7 +1949,7 @@ int setReadoutSpeed(int val) {
switch (val) {
case FULL_SPEED:
if (isHardwareVersion_1_0()) {
if (isHardwareVersion2()) {
LOG(logERROR, ("Cannot set full speed. Should not be here\n"));
return FAIL;
}
@ -2011,7 +1970,7 @@ int setReadoutSpeed(int val) {
case HALF_SPEED:
LOG(logINFO, ("Setting Half Speed (20 MHz):\n"));
if (isHardwareVersion_1_0()) {
if (isHardwareVersion2()) {
adcOfst = ADC_OFST_HALF_SPEED_BOARD2_VAL;
sampleAdcSpeed = SAMPLE_ADC_HALF_SPEED_BOARD2;
adcPhase = ADC_PHASE_HALF_SPEED_BOARD2;
@ -2032,7 +1991,7 @@ int setReadoutSpeed(int val) {
case QUARTER_SPEED:
LOG(logINFO, ("Setting Half Speed (10 MHz):\n"));
if (isHardwareVersion_1_0()) {
if (isHardwareVersion2()) {
adcOfst = ADC_OFST_QUARTER_SPEED_BOARD2_VAL;
sampleAdcSpeed = SAMPLE_ADC_QUARTER_SPEED_BOARD2;
adcPhase = ADC_PHASE_QUARTER_SPEED_BOARD2;
@ -2292,7 +2251,7 @@ int getFlipRows() {
}
void setFlipRows(int arg) {
if (isHardwareVersion_1_0()) {
if (isHardwareVersion2()) {
LOG(logERROR, ("Could not set flip rows. Only available for "
"Hardware Board version 2.0.\n"));
return;
@ -2686,10 +2645,10 @@ void *start_timer(void *arg) {
sls_detector_header *header =
(sls_detector_header *)(packetData);
header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION;
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->frameNumber = frameNr + iframes;
header->packetNumber = pnum;
header->modId = virtual_moduleid;
header->modId = 0;
header->row = row0;
header->column = col0;
@ -2713,10 +2672,10 @@ void *start_timer(void *arg) {
sls_detector_header *header =
(sls_detector_header *)(packetData2);
header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION;
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->frameNumber = frameNr + iframes;
header->packetNumber = pnum;
header->modId = virtual_moduleid;
header->modId = 0;
header->row = row1;
header->column = col1;

View File

@ -5,20 +5,83 @@
#include "sls/sls_detector_defs.h"
#define MIN_REQRD_VRSN_T_RD_API 0x171220
#define REQRD_FRMWRE_VRSN_BOARD2 0x221104 // 1.0 pcb (version = 010)
#define REQRD_FRMWRE_VRSN 0x221103 // 2.0 pcb (version = 011)
#define REQRD_FRMWRE_VRSN_BOARD2 0x220421 // 1.0 pcb (version = 010)
#define REQRD_FRMWRE_VRSN 0x220422 // 2.0 pcb (version = 011)
#define NUM_HARDWARE_VERSIONS (2)
#define HARDWARE_VERSION_NUMBERS \
{ 0x2, 0x3 }
#define HARDWARE_VERSION_NAMES \
{ "1.0", "2.0" }
#define ID_FILE "detid_jungfrau.txt"
#define LINKED_SERVER_NAME "jungfrauDetectorServer"
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
/* Struct Definitions */
typedef struct udp_header_struct {
uint32_t udp_destmac_msb;
uint16_t udp_srcmac_msb;
uint16_t udp_destmac_lsb;
uint32_t udp_srcmac_lsb;
uint8_t ip_tos;
uint8_t ip_ihl : 4, ip_ver : 4;
uint16_t udp_ethertype;
uint16_t ip_identification;
uint16_t ip_totallength;
uint8_t ip_protocol;
uint8_t ip_ttl;
uint16_t ip_fragmentoffset : 13, ip_flags : 3;
uint16_t ip_srcip_msb;
uint16_t ip_checksum;
uint16_t ip_destip_msb;
uint16_t ip_srcip_lsb;
uint16_t udp_srcport;
uint16_t ip_destip_lsb;
uint16_t udp_checksum;
uint16_t udp_destport;
} udp_header;
#define IP_HEADER_SIZE (20)
#define UDP_IP_HEADER_LENGTH_BYTES (28)
/* Enums */
enum ADCINDEX { TEMP_FPGA, TEMP_ADC };
enum DACINDEX {
J_VB_COMP,
J_VDD_PROT,
J_VIN_COM,
J_VREF_PRECH,
J_VB_PIXBUF,
J_VB_DS,
J_VREF_DS,
J_VREF_COMP
};
#define DAC_NAMES \
"vb_comp", "vdd_prot", "vin_com", "vref_prech", "vb_pixbuf", "vb_ds", \
"vref_ds", "vref_comp"
#define DEFAULT_DAC_VALS \
{ \
1220, /* J_VB_COMP */ \
3000, /* J_VDD_PROT */ \
1053, /* J_VIN_COM */ \
1450, /* J_VREF_PRECH */ \
750, /* J_VB_PIXBUF */ \
1000, /* J_VB_DS */ \
480, /* J_VREF_DS */ \
420 /* J_VREF_COMP */ \
};
enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
#define MASTER_NAMES "hardware", "master", "slave"
#define NUMSETTINGS (2)
#define NSPECIALDACS (3)
#define SPECIALDACINDEX {J_VREF_PRECH, J_VREF_DS, J_VREF_COMP};
#define SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS \
{ 1450, 480, 420 }
#define SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS \
{ 1550, 450, 620 }
enum NETWORKINDEX { TXN_FRAME, FLOWCTRL_10G };
enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS };
#define CLK_NAMES "run", "adc", "dbit"
/* Hardware Definitions */
#define NCHAN (256 * 256)
#define NCHIP (8)
@ -144,73 +207,3 @@
#define ADC_OFST_HALF_SPEED_BOARD2_VAL (0x10)
#define ADC_OFST_QUARTER_SPEED_BOARD2_VAL (0x08)
/* Struct Definitions */
typedef struct udp_header_struct {
uint32_t udp_destmac_msb;
uint16_t udp_srcmac_msb;
uint16_t udp_destmac_lsb;
uint32_t udp_srcmac_lsb;
uint8_t ip_tos;
uint8_t ip_ihl : 4, ip_ver : 4;
uint16_t udp_ethertype;
uint16_t ip_identification;
uint16_t ip_totallength;
uint8_t ip_protocol;
uint8_t ip_ttl;
uint16_t ip_fragmentoffset : 13, ip_flags : 3;
uint16_t ip_srcip_msb;
uint16_t ip_checksum;
uint16_t ip_destip_msb;
uint16_t ip_srcip_lsb;
uint16_t udp_srcport;
uint16_t ip_destip_lsb;
uint16_t udp_checksum;
uint16_t udp_destport;
} udp_header;
#define IP_HEADER_SIZE (20)
#define UDP_IP_HEADER_LENGTH_BYTES (28)
/* Enums */
enum ADCINDEX { TEMP_FPGA, TEMP_ADC };
enum DACINDEX {
J_VB_COMP,
J_VDD_PROT,
J_VIN_COM,
J_VREF_PRECH,
J_VB_PIXBUF,
J_VB_DS,
J_VREF_DS,
J_VREF_COMP
};
#define DAC_NAMES \
"vb_comp", "vdd_prot", "vin_com", "vref_prech", "vb_pixbuf", "vb_ds", \
"vref_ds", "vref_comp"
#define DEFAULT_DAC_VALS \
{ \
1220, /* J_VB_COMP */ \
3000, /* J_VDD_PROT */ \
1053, /* J_VIN_COM */ \
1450, /* J_VREF_PRECH */ \
750, /* J_VB_PIXBUF */ \
1000, /* J_VB_DS */ \
480, /* J_VREF_DS */ \
420 /* J_VREF_COMP */ \
};
enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
#define MASTER_NAMES "hardware", "master", "slave"
#define NUMSETTINGS (2)
#define NSPECIALDACS (3)
#define SPECIALDACINDEX {J_VREF_PRECH, J_VREF_DS, J_VREF_COMP};
#define SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS \
{ 1450, 480, 420 }
#define SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS \
{ 1550, 450, 620 }
enum NETWORKINDEX { TXN_FRAME, FLOWCTRL_10G };
enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS };
#define CLK_NAMES "run", "adc", "dbit"

View File

@ -120,9 +120,7 @@ void basictests() {
return;
}
#endif
char hversion[MAX_STR_LENGTH] = {0};
memset(hversion, 0, MAX_STR_LENGTH);
getHardwareVersion(hversion);
uint16_t hversion = getHardwareVersionNumber();
uint16_t hsnumber = getHardwareSerialNumber();
uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC();
@ -136,7 +134,7 @@ void basictests() {
sw_fw_apiversion = getFirmwareAPIVersion();
LOG(logINFOBLUE,
("**************************************************\n"
"Hardware Version:\t\t %s\n"
"Hardware Version:\t\t 0x%x\n"
"Hardware Serial Nr:\t\t 0x%x\n"
"Detector IP Addr:\t\t 0x%x\n"
@ -347,24 +345,9 @@ uint64_t getFirmwareAPIVersion() {
return ((bus_r(API_VERSION_REG) & API_VERSION_MSK) >> API_VERSION_OFST);
}
void getHardwareVersion(char *version) {
strcpy(version, "unknown");
int hwversion = getHardwareVersionNumber();
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
const char *hwNamesList[] = HARDWARE_VERSION_NAMES;
for (int i = 0; i != NUM_HARDWARE_VERSIONS; ++i) {
LOG(logDEBUG, ("0x%x %d 0x%x %s\n", hwversion, i, hwNumberList[i],
hwNamesList[i]));
if (hwNumberList[i] == hwversion) {
strcpy(version, hwNamesList[i]);
return;
}
}
}
uint16_t getHardwareVersionNumber() {
#ifdef VIRTUAL
return 0x1;
return 0;
#endif
return ((bus_r(MOD_SERIAL_NUMBER_REG) & MOD_SERIAL_NUMBER_VRSN_MSK) >>
MOD_SERIAL_NUMBER_VRSN_OFST);
@ -1739,7 +1722,7 @@ void *start_timer(void *arg) {
memset(packetData, 0, packetSize);
sls_detector_header *header = (sls_detector_header *)(packetData);
header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION;
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->frameNumber = frameNr + iframes;
header->packetNumber = i;
header->modId = 0;

View File

@ -5,13 +5,7 @@
#include "sls/sls_detector_defs.h"
#define MIN_REQRD_VRSN_T_RD_API 0x180314
#define REQRD_FRMWR_VRSN 0x221205
#define NUM_HARDWARE_VERSIONS (1)
#define HARDWARE_VERSION_NUMBERS \
{ 0x1 }
#define HARDWARE_VERSION_NAMES \
{ "1.0" }
#define REQRD_FRMWR_VRSN 0x220825
#define LINKED_SERVER_NAME "moenchDetectorServer"

View File

@ -313,7 +313,7 @@ patternParameters *setChannelRegisterChip(int ichip, char *mask,
chanReg, ichip * NCHAN + ich * NCOUNTERS,
ichip * NCHAN_1_COUNTER + ich, ichip, ich));
}
for (int i = 0; i < 23; i++) {
for (int i = 0; i < 24; i++) {
patword = clearBit(SIGNAL_clk, patword);
pat->word[iaddr++] = patword;

View File

@ -106,9 +106,7 @@ void basictests() {
return;
}
#endif
char hversion[MAX_STR_LENGTH] = {0};
memset(hversion, 0, MAX_STR_LENGTH);
getHardwareVersion(hversion);
uint16_t hversion = getHardwareVersionNumber();
uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC();
int64_t fwversion = getFirmwareVersion();
@ -120,7 +118,7 @@ void basictests() {
LOG(logINFOBLUE,
("**************************************************\n"
"Hardware Version:\t\t %s\n"
"Hardware Version:\t\t 0x%x\n"
"Detector IP Addr:\t\t 0x%x\n"
"Detector MAC Addr:\t\t 0x%llx\n\n"
@ -261,34 +259,14 @@ u_int64_t getFirmwareAPIVersion() {
return ((bus_r(API_VERSION_REG) & API_VERSION_MSK) >> API_VERSION_OFST);
}
void getHardwareVersion(char *version) {
strcpy(version, "unknown");
int hwversion = getHardwareVersionNumber();
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
const char *hwNamesList[] = HARDWARE_VERSION_NAMES;
for (int i = 0; i != NUM_HARDWARE_VERSIONS; ++i) {
LOG(logDEBUG, ("0x%x %d 0x%x %s\n", hwversion, i, hwNumberList[i],
hwNamesList[i]));
if (hwNumberList[i] == hwversion) {
strcpy(version, hwNamesList[i]);
return;
}
}
}
u_int16_t getHardwareVersionNumber() {
#ifdef VIRTUAL
return 0x2;
return 0;
#endif
return ((bus_r(MCB_SERIAL_NO_REG) & MCB_SERIAL_NO_VRSN_MSK) >>
MCB_SERIAL_NO_VRSN_OFST);
}
int isHardwareVersion_1_0() {
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
return ((getHardwareVersionNumber() == hwNumberList[0]) ? 1 : 0);
}
u_int32_t getDetectorNumber() {
#ifdef VIRTUAL
return 0;
@ -2605,7 +2583,7 @@ void *start_timer(void *arg) {
// set header
sls_detector_header *header = (sls_detector_header *)(packetData);
header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION;
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->frameNumber = virtual_currentFrameNumber;
header->packetNumber = i;
header->modId = virtual_moduleid;

View File

@ -3,15 +3,10 @@
#pragma once
#include "sls/sls_detector_defs.h"
#define REQRD_FRMWRE_VRSN (0x230124)
#define REQRD_FRMWRE_VRSN (0x220824)
#define KERNEL_DATE_VRSN "Mon May 10 18:00:21 CEST 2021"
#define ID_FILE "detid_mythen3.txt"
#define NUM_HARDWARE_VERSIONS (2)
#define HARDWARE_VERSION_NUMBERS {0x0, 0x2};
#define HARDWARE_VERSION_NAMES \
{ "1.0", "1.2" }
#define LINKED_SERVER_NAME "mythen3DetectorServer"
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
@ -57,10 +52,10 @@
#define DEFAULT_TRIMBIT_VALUE (0)
#define DEFAULT_COUNTER_DISABLED_VTH_VAL (2800)
#define DEFAULT_READOUT_C0 (10) //(100000000) // rdo_clk, 100 MHz
#define DEFAULT_READOUT_C1 (10) //(100000000) // rdo_smp_clk, 100 MHz
#define DEFAULT_SYSTEM_C0 (10) //(100000000) // run_clk, 100 MHz
#define DEFAULT_SYSTEM_C1 (6) //(166666666) // str_clk, 166 MHz const
#define DEFAULT_READOUT_C0 (12) //(083333333) // rdo_clk, 83.33 MHz
#define DEFAULT_READOUT_C1 (12) //(083333333) // rdo_smp_clk, 83.33 MHz
#define DEFAULT_SYSTEM_C0 (20) //(050000000) // run_clk, 20 MHz
#define DEFAULT_SYSTEM_C1 (8) //(125000000) // str_clk, 125 MHz const
#define DEFAULT_SYSTEM_C2 (5) //(200000000) // smp_clk, 200 MHz const
#define DEFAULT_TRIMMING_RUN_CLKDIV (40) // (25000000) // 25 MHz

View File

@ -78,36 +78,35 @@ int getTestImageMode();
void getServerVersion(char *version);
u_int64_t getFirmwareVersion();
u_int64_t getFirmwareAPIVersion();
#ifndef EIGERD
void getHardwareVersion(char *version);
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || \
defined(MYTHEN3D) || defined(GOTTHARD2D)
u_int16_t getHardwareVersionNumber();
#endif
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
u_int16_t getHardwareSerialNumber();
#endif
#if defined(JUNGFRAUD) || defined(GOTTHARD2D) || defined(MYTHEN3D) || \
defined(GOTTHARDD)
int isHardwareVersion_1_0();
#endif
#ifdef JUNGFRAUD
int isHardwareVersion2();
int getChipVersion();
void setChipVersion(int version);
#endif
#ifndef EIGERD
u_int32_t getDetectorNumber();
#endif
#if defined(GOTTHARD2D) || defined(EIGERD) || defined(MYTHEN3D) || \
defined(JUNGFRAUD)
#if defined(GOTTHARD2D) || defined(EIGERD) || defined(MYTHEN3D)
int getModuleId(int *ret, char *mess);
#endif
#if defined(EIGERD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
int updateModuleId();
#ifndef EIGERD
#endif
#if defined(GOTTHARD2D) || defined(MYTHEN3D)
void setModuleId(int modid);
#endif
#endif
u_int64_t getDetectorMAC();
u_int32_t getDetectorIP();
#ifdef GOTTHARDD
u_int32_t getBoardRevision();
#endif
// initialization
void initControlServer();

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